@jolibox/implement 1.1.13-beta.10 → 1.1.13-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  "packages/implement/.eslintrc.js": "7a3d2747dc887655ca9e2d3ff621f7dfd98500b9",
5
5
  "packages/implement/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
6
6
  "packages/implement/esbuild.config.js": "86f1fd21722a2cb05216751578dcca66326e664a",
7
- "packages/implement/package.json": "6f91a5f04be9820dd05ddc3f68536e6db7f29972",
7
+ "packages/implement/package.json": "f21838638276909b24e4649d6fd7622620db3366",
8
8
  "packages/implement/src/common/ads/ads-action-detection.ts": "5a7b9f85d7eab9e744f8a9fc7638063f43baa214",
9
9
  "packages/implement/src/common/ads/anti-cheating.test.ts": "e2ff3dc6760cfd28d0f8c15703d7fb20d43df583",
10
10
  "packages/implement/src/common/ads/anti-cheating.ts": "a3ffb6a78e289e1c0ce45c7f7c0cee000e75e541",
@@ -47,15 +47,15 @@
47
47
  "packages/implement/src/common/report/track.ts": "1c71050f8caadfe7065f0db5a4a0708c264c21b4",
48
48
  "packages/implement/src/common/report/types.ts": "fd127bfd31586f1d712152ef60a4e9175f8bfe8f",
49
49
  "packages/implement/src/common/rewards/__tests__/can-use-jolicoin.test.ts": "ec0f7225cb1b322e9278a3d8d6848bc50190696a",
50
- "packages/implement/src/common/rewards/fetch-reward.ts": "bef4af1b9314cc4d06b2609edffdfad024b57081",
50
+ "packages/implement/src/common/rewards/fetch-reward.ts": "7cc61f44ed5b111f7904daceb1fc6e3396ee34be",
51
51
  "packages/implement/src/common/rewards/index.ts": "f6160318ce7393684ebf229729b3168beb0c2d99",
52
52
  "packages/implement/src/common/rewards/registers/use-ads.ts": "e6eb324d5ac39d0a5df478760fdf0ee75fded1b5",
53
- "packages/implement/src/common/rewards/registers/use-jolicoin.ts": "ee28989dea8aca243439cb1508d3fac55a689ae1",
53
+ "packages/implement/src/common/rewards/registers/use-jolicoin.ts": "b6af27f7f44c7fbf90dedd6b772a244f65497fe5",
54
54
  "packages/implement/src/common/rewards/registers/utils/index.ts": "a297dfc50b091368fba6e12e67663693f14ac1b8",
55
55
  "packages/implement/src/common/rewards/reward-helper.ts": "2113cbd370da5be4beaf88bed865f1846e43d472",
56
56
  "packages/implement/src/common/rewards/type.ts": "75c8444405686dbee1628f6d67c4a6b803e0623e",
57
57
  "packages/implement/src/common/utils/index.ts": "6e2af1b721d5a9caf8fa40fd22fc73a2fdd5c4c0",
58
- "packages/implement/src/h5/api/ads.ts": "35f3efdc7b7ca6399ba589d97691e2e6a811b4c2",
58
+ "packages/implement/src/h5/api/ads.ts": "a329694886a101b9627b0df61254a619e1acddbe",
59
59
  "packages/implement/src/h5/api/base.ts": "ead2c3cdcbe174b0e725c31a3885c7985bd8f667",
60
60
  "packages/implement/src/h5/api/get-system-info.ts": "158d66156c720446457318b7eaa9112452114dbb",
61
61
  "packages/implement/src/h5/api/index.ts": "81b815f5ac8e1bd3e3f019f94c28bd5522a36193",
@@ -73,7 +73,7 @@
73
73
  "packages/implement/src/h5/report/task-tracker.ts": "9b55e81e5c20d459ff851f70689e9280e89c0e63",
74
74
  "packages/implement/src/index.native.ts": "96cc46c8919ba2333600e9c3ee100f47c511a79a",
75
75
  "packages/implement/src/index.ts": "d0ca7b5312b0a258ae8887e725440c70190442f7",
76
- "packages/implement/src/native/api/ads.ts": "61820883bebf9eb011dc78b48b614bfac69aed9b",
76
+ "packages/implement/src/native/api/ads.ts": "9958f0e3819b1e015e875df9a924c05983c1b950",
77
77
  "packages/implement/src/native/api/base.ts": "c4c4d04519cdbc3a08226c620f6314ee3b151435",
78
78
  "packages/implement/src/native/api/get-system-info.ts": "187333a4eca5304e896360d1496744cb7535ab49",
79
79
  "packages/implement/src/native/api/index.ts": "39c85b6c6d93f91d9ecc4a96a38a39a425d5487a",
@@ -1,5 +1,6 @@
1
1
  import { IHttpClient } from '@/common/http';
2
- export type JolicoinRewardsHandler = () => Promise<boolean>;
2
+ import { IAdBreakParams } from '@/common/ads';
3
+ export type JolicoinRewardsHandler = (params: IAdBreakParams) => Promise<boolean>;
3
4
  export declare const createJolicoinRewardHandler: (httpClient: IHttpClient, { onUnlockSuccess, onUnlockFailed }: {
4
5
  onUnlockSuccess?: (data: {
5
6
  quantity: number;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- var Ni=Object.create;var Qt=Object.defineProperty,Li=Object.defineProperties,Ui=Object.getOwnPropertyDescriptor,Fi=Object.getOwnPropertyDescriptors,Bi=Object.getOwnPropertyNames,Qe=Object.getOwnPropertySymbols,Mi=Object.getPrototypeOf,Xt=Object.prototype.hasOwnProperty,fn=Object.prototype.propertyIsEnumerable;var dn=(e,t,r)=>t in e?Qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,V=(e,t)=>{for(var r in t||(t={}))Xt.call(t,r)&&dn(e,r,t[r]);if(Qe)for(var r of Qe(t))fn.call(t,r)&&dn(e,r,t[r]);return e},z=(e,t)=>Li(e,Fi(t));var Me=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var mn=(e,t)=>{var r={};for(var n in e)Xt.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Qe)for(var n of Qe(e))t.indexOf(n)<0&&fn.call(e,n)&&(r[n]=e[n]);return r};var K=(e,t)=>()=>(e&&(t=e(e=0)),t);var pn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var $i=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Bi(t))!Xt.call(e,i)&&i!==r&&Qt(e,i,{get:()=>t[i],enumerable:!(n=Ui(t,i))||n.enumerable});return e};var hn=(e,t,r)=>(r=e!=null?Ni(Mi(e)):{},$i(t||!e||!e.__esModule?Qt(r,"default",{value:e,enumerable:!0}):r,e));var C=(e,t,r)=>new Promise((n,i)=>{var c=p=>{try{m(r.next(p))}catch(b){i(b)}},d=p=>{try{m(r.throw(p))}catch(b){i(b)}},m=p=>p.done?n(p.value):Promise.resolve(p.value).then(c,d);m((r=r.apply(e,t)).next())});function Yi(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ar(e){return typeof e=="string"}function wn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function En(e){return typeof e=="object"&&Array.isArray(e)}function zi(e){return typeof e=="undefined"}function Qi(e){return zi(e)||e===null}function Xi(e){return typeof e=="function"}function In(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function Tn(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(i,c){for(let d in c)if(Object.prototype.hasOwnProperty.call(c,d)){let m=i[d],p=c[d],b=r(m,p,d,i,c);b!==void 0?i[d]=b:yn(p)&&yn(m)?i[d]=n(ir({},m),p):Array.isArray(p)&&Array.isArray(m)?i[d]=[...m,...p]:i[d]=p}return i}return n(e,t)}function yn(e){return e&&typeof e=="object"&&e.constructor===Object}function Sn(e,t){if(Array.isArray(e))return e.concat(t)}function Ve(e,t,r={}){let n=null,i,c,d,{leading:m=!1,trailing:p=!0}=r,b=()=>(d=e.apply(c,i),i=void 0,c=void 0,d),v=function(...S){i=S,c=this;let g=m&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,p&&!g&&b()},t),g)return b()};return v.cancel=()=>{n&&clearTimeout(n),n=null,i=c=void 0},v.flush=()=>{if(n)return clearTimeout(n),n=null,b()},v}function ta(e,t){return(...r)=>t(e,...r)}function Cn(e){return t=>ta(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new ea(`${i}`))}})}function $e(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function et(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((i,c)=>(i[c]=String(n[c]),i),{})}return e[r]})}function aa(e){let t=e.location?et(e.location,bn):null,r=e.target?et(e.target,bn):null;return et(Gi(ir({},e),{location:t,target:r}),oa)}function dr(e){let t=e.events.map(n=>aa(n)),r=et(e.device,ia);return[e.protocolVersion,t,r,e.project]}function mr(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}function ga(e){return new Promise(t=>Nn(e)(t))}function Nn(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function va(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(c.fire,c)}},c=new je(i);return c.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function ba(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)_a(e[n],t[n])}function _a(e,t){if(ar(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Xi(t)){try{if(e instanceof t)return}catch(r){}if(!Qi(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function wa(){return typeof globalThis!="undefined"?globalThis[Ln]:void 0}function Ea(e){typeof globalThis!="undefined"&&(globalThis[Ln]=e)}function ae(){let e=wa();if(e)return e;let t=new tt,r=new nr,n={registerCommand(i,c,d){t.registerCommand({id:i,handler:c,metadata:d})},executeCommand(i,...c){return r.executeCommand(i,...c)},excuteCommandSync(i,...c){return r.executeCommandThowErr(i,...c)}};return Ea(n),n}var or,ji,Vi,Hi,gn,Ji,Ki,vn,ir,Gi,qi,_n,Wi,Zi,sr,cr,Rn,An,ea,xn,kn,rt,ur,ce,Pn,ra,lr,He,xe,na,bn,oa,ia,fr,Xe,sa,ca,ua,On,pr,la,da,fa,Dn,er,G,ma,pa,Ze,je,de,rr,ha,Zt,ya,Je,tt,nr,Ln,$=K(()=>{"use strict";or=Object.defineProperty,ji=Object.defineProperties,Vi=Object.getOwnPropertyDescriptor,Hi=Object.getOwnPropertyDescriptors,gn=Object.getOwnPropertySymbols,Ji=Object.prototype.hasOwnProperty,Ki=Object.prototype.propertyIsEnumerable,vn=(e,t,r)=>t in e?or(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ir=(e,t)=>{for(var r in t||(t={}))Ji.call(t,r)&&vn(e,r,t[r]);if(gn)for(var r of gn(t))Ki.call(t,r)&&vn(e,r,t[r]);return e},Gi=(e,t)=>ji(e,Hi(t)),qi=(e,t)=>{for(var r in t)or(e,r,{get:t[r],enumerable:!0})},_n=(e,t,r,n)=>{for(var i=n>1?void 0:n?Vi(t,r):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(i=(n?d(t,r,i):d(i))||i);return n&&i&&or(t,r,i),i},Wi=(e,t,r)=>new Promise((n,i)=>{var c=p=>{try{m(r.next(p))}catch(b){i(b)}},d=p=>{try{m(r.throw(p))}catch(b){i(b)}},m=p=>p.done?n(p.value):Promise.resolve(p.value).then(c,d);m((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}Zi=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Zi||{}),sr=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},cr=class extends sr{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Rn=class extends sr{constructor(){super(...arguments),this.kind="USER_ERROR"}},An=class extends Rn{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},ea=class extends Rn{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},xn=class extends cr{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},kn=class extends cr{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},rt=class extends sr{constructor(e,t,r,n,i){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),i&&(this.priority=i)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},ur=class extends cr{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};ce={log:$e("log"),warn:$e("warn"),info:$e("info"),error:$e("error"),debug:$e("debug")};Object.assign(globalThis,{logger:ce});Pn=Symbol.for("Jolibox.canIUseMap"),ra={};globalThis[Pn]=ra;lr={get config(){return globalThis[Pn]}},He=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(He||{}),xe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(xe||{}),na=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(na||{}),bn=["name","params"],oa=["name","type","location","target","extra","timestamp","userId"],ia=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];fr=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});mr();Xe={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},sa=()=>Xe.isiOS?"iOS":Xe.isAndroid?"Android":Xe.isMac?"Mac":Xe.isFacebook?"Facebook":"PC",ca="device_id",ua="advertising_id",On=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,fr()),window.__joliboxLocalStorage__.getItem(e)),pr=()=>new URLSearchParams(window.location.search).get("deviceId")||On(ca),la=()=>On(ua),da=e=>e.charAt(0).toUpperCase()+e.slice(1),fa=()=>{var e;let t=new URLSearchParams(window.location.search);return da((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Dn=e=>{let t="JoliboxWebSDK",r=sa(),n=navigator.language,i=pr(),c=la();return`${t} (${fa()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${i} adid/${c} version/${e||""}`},er=class tr{constructor(t){this.element=t,this.next=tr.Undefined,this.prev=tr.Undefined}};er.Undefined=new er(void 0);G=er,ma=class{constructor(){this._first=G.Undefined,this._last=G.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===G.Undefined}clear(){let e=this._first;for(;e!==G.Undefined;){let t=e.next;e.prev=G.Undefined,e.next=G.Undefined,e=t}this._first=G.Undefined,this._last=G.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new G(e);if(this._first===G.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==G.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==G.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==G.Undefined&&e.next!==G.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===G.Undefined&&e.next===G.Undefined?(this._first=G.Undefined,this._last=G.Undefined):e.next===G.Undefined?(this._last=this._last.prev,this._last.next=G.Undefined):e.prev===G.Undefined&&(this._first=this._first.next,this._first.prev=G.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==G.Undefined;)yield e.element,e=e.next}},pa=0,Ze=class{constructor(e){this.value=e,this.id=pa++}},je=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof Ze&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,i,c,d,m,p;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let b=new Ze(t);this._listeners?this._listeners instanceof Ze?this._listeners=[this._listeners,b]:this._listeners.push(b):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=b,(d=(c=this.options)==null?void 0:c.onDidFirstListener)==null||d.call(c,this)),(p=(m=this.options)==null?void 0:m.onDidAddListener)==null||p.call(m,this),this._size++}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof Ze?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},de=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new je,i=d=>t(...d.args);this.listerHandlerMap.set(t,i),n.event(i),this.listeners.set(e,n);let c=this.cachedEventQueue.get(e);if(c)for(;c.size>0;)n.fire(ir({event:e},c.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new ma,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},rr={};qi(rr,{None:()=>ha,filter:()=>va,once:()=>Nn,toPromise:()=>ga});ha=()=>{console.log("[Jolibox SDK] None Event")};Zt=Symbol.for("Jolibox.hostEmitter"),ya=()=>{let e=new de;return globalThis[Zt]||(globalThis[Zt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[Zt]},Je=ya();tt=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new je,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return ba(i,r),n(...i)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};tt=_n([In],tt);nr=class{constructor(){this._onWillExecuteCommand=new je,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new je,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new tt,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Yi(3e4)),this._starActivation}executeCommand(e,...t){return Wi(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),rr.toPromise(rr.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};nr=_n([In],nr);Ln=Symbol.for("Jolibox.commands")});function ue(e,t={}){hr.emit("ERROR_REPORT",{error:e,options:t})}var hr,we,_e=K(()=>{"use strict";$();$();hr=new de,we=new de;ue.debounce=Ve(ue,50,{leading:!0})});var gr,Ia,Un,Fn,Bn=K(()=>{"use strict";$();_e();gr=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch(i){return{}}},Ia=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Un=e=>{var t;try{let i=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(i!=null&&i.length){let[c,d,m]=i;return{headerJson:gr(c),payloadJson:gr(d),signature:gr(m)}}else throw"joli_source is missing"}catch(r){return ue(new xn(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},Fn=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=Ia(e),c=r[2];return`${n}.${i}.${c}`}return t}});var Ta,nt,Mn,vr=K(()=>{"use strict";$();Ta="1.1.13-beta.10",nt=()=>Ta,Mn=()=>{let e=nt();return`${Dn(e)}`}});var Sa,$n,yr,jn,Z,Ra,A,ee=K(()=>{"use strict";$();Bn();vr();$();Sa={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:pr(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:nt()},schema:window.location.href,platform:"h5"},yr=($n=globalThis.joliboxJSCore)==null?void 0:$n.env,Z=Object.assign({},(jn=yr==null?void 0:yr())!=null?jn:Sa),Ra=()=>{var g,I,O,D,k,P,H,F,te;let{payloadJson:e,headerJson:t,signature:r}=Z.schema.length?Un(Z.schema):{},n=`${Z.deviceInfo.did}-${new Date().getTime()}`,c=new URL(Z.schema.length?Z.schema:window.location.href).searchParams,d=(O=(I=(g=c.get("mpId"))!=null?g:c.get("appId"))!=null?I:c.get("gameId"))!=null?O:"",m=(P=(k=(D=Z.clientSessionId)!=null?D:e==null?void 0:e.sessionId)!=null?k:c.get("sessionId"))!=null?P:n,p=!!((H=e==null?void 0:e.testAdsMode)!=null?H:c.get("testAdsMode")==="true"),b=(te=(F=e==null?void 0:e.joliboxEnv)!=null?F:c.get("joliboxEnv"))!=null?te:"production",v=b==="staging",S=t==null?void 0:t.channel;return{get testMode(){return v},get testAdsMode(){return p},get joliboxEnv(){return b},get joliSource(){var B;return(B=c.get("joliSource"))!=null?B:null},get mpId(){var B;return(B=d!=null?d:e==null?void 0:e.id)!=null?B:""},get mpVersion(){var B;return(B=t==null?void 0:t.ver)!=null?B:nt()},get mpType(){var B,T;return(T=(B=t==null?void 0:t.__mpType)!=null?B:e==null?void 0:e.__mpType)!=null?T:"game"},get platform(){var B;return(B=Z.platform)!=null?B:Z.deviceInfo.platform},get deviceInfo(){return Z.deviceInfo},get sdkInfo(){return Z.sdkInfo},get hostInfo(){return Z.hostInfo},get hostUserInfo(){return Z.hostUserInfo},get sessionId(){var B,T;return(T=(B=Z.clientSessionId)!=null?B:m)!=null?T:n},get channel(){return S},get webviewId(){var B;return(B=Z.webviewId)!=null?B:-1},get shouldInterupt(){return e==null?void 0:e.__shouldInterupt},get from(){return e==null?void 0:e.__from},get baseApiHost(){return v?"https://stg-api.jolibox.com":"https://api.jolibox.com"},onEnvConfigChanged:B=>{Tn(Z,B,Sn)},encodeJoliSourceQuery:B=>{var T,U;return t&&r?Fn(V(V({},e),B),(T=c.get("joliSource"))!=null?T:""):(U=c.get("joliSource"))!=null?U:""}}},A=Ra()});var br,Hn,Aa,xa,Vn,ka,Jn=K(()=>{"use strict";$();_e();ee();$();br=!1,Hn=(e,t)=>e==null?!1:t in e,Aa=e=>Hn(e,"kind"),xa=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},Vn=(e,t={},r)=>{var c,d,m;let n={user_id:(d=(c=A.hostUserInfo)==null?void 0:c.uid)!=null?d:"",device_id:(m=A.deviceInfo.did)!=null?m:"",timestamp:Date.now(),tag:xa(e.name)},i=z(V({},n),{env:t.environment,isFromUser:r});r?we.emit("GLOBAL_USER_ERROR",e,i):we.emit("GLOBAL_ERROR",e,i)},ka=e=>Hn(e,"kind")&&e.kind==="USER_ERROR";hr.on("ERROR_REPORT",({error:e,options:t})=>{if(br)return;br=!0;let r=Aa(e)&&e.raw?e.raw:e;try{let n=ka(e);Vn(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),c=new ur(`${i}, origin error: ${r.message}`);ce.error(c),Vn(new ur(c.message),{environment:t.environment},!1)}finally{br=!1}})});var _r,wr=K(()=>{"use strict";_e();$();_e();_r=e=>new An(e)});function Kn(e,t){let r=(n,i,c)=>{let d=z(V({tag:n},t),{extra:V({},i)});n=="globalJsError"?ue(new kn(JSON.stringify(d))):e("systemLog",d,c)};return r.debounce=Ve(r,500,{leading:!0}),r}function Gn(e){let t=(r,n,i)=>{var m;let c=(m=i&&JSON.stringify(i))!=null?m:0,d={speed_value_type:r,total_duration:n};c&&Object.assign(d,{extra:c}),e("joliboxSpeedAnalysis",d)};return t.debounce=Ve(t,500,{leading:!0}),t}var qn=K(()=>{"use strict";$();$();_e()});function Wn(e,t){let r=Kn(e,t),n=Gn(r);return{track:r,trackPerformance:n}}var Yn=K(()=>{"use strict";qn()});var Er=K(()=>{"use strict"});var ot,zn=K(()=>{"use strict";ee();$();$();ot=class{constructor(){this.deviceInfo=null;this.samplesConfig=null;this.fetchSamplesConfig()}fetchSamplesConfig(){return C(this,null,function*(){let r=`${A.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/samples-config`,n=yield(yield fetch(r)).json();this.samplesConfig=n})}checkIsSampled(t){if(!this.samplesConfig)return!1;let{samples:r}=this.samplesConfig;for(let[n,i]of Object.entries(r))if(i.includes(t.name))return Math.floor(Math.random()*101)<parseFloat(n);return!1}getDevice(){var n,i,c,d,m;let{nativeSDKVersion:t,jssdkVersion:r}=A.sdkInfo;return{platform:1e3,os:A.deviceInfo.platform,appVersion:(n=t!=null?t:r)!=null?n:"1.0.0",appId:(c=(i=A.hostInfo)==null?void 0:i.aid)!=null?c:"1",model:(d=A.deviceInfo.model)!=null?d:"UnknownModel",brand:(m=A.deviceInfo.brand)!=null?m:"UnknownBrand",uuid:A.deviceInfo.did,jsSdkVersion:r,extra:{}}}getLocation(){let t=new URLSearchParams(window.location.search),r={};return t.forEach((n,i)=>{r[i]=n}),{name:"GamePage",params:r}}trackEvent(t,r,n){return C(this,null,function*(){if(this.checkIsSampled(t))return;let i=t.location?t.location:yield this.getLocation(),c=t.target||null,d=t.extra||null;this.deviceInfo||(this.deviceInfo=yield this.getDevice());let m=this.deviceInfo,b={protocolVersion:"1.0.0",events:[z(V({},t),{location:i,target:c,extra:d,timestamp:Date.now(),userId:null})],device:m,project:r};try{n?yield this.doReport(dr(b),n):yield this.doReport(dr(b))}catch(v){ce.log("[Jolibox SDK] report API error",v)}})}}});var Ir=K(()=>{"use strict";Yn();Er();zn()});var Tr,Qn,he,it,ge,Ke=K(()=>{"use strict";vr();ee();Tr=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};(Qn=AbortSignal.timeout)!=null||(AbortSignal.timeout=Tr);he=class e{constructor(){this.httpClients=new WeakSet;this.networkRequests=[];this.maxRequestsToTrack=20}static getInstance(){return e._instance||(e._instance=new e),e._instance}create(t){let r=new it(t);return e.getInstance().httpClients.add(r),r}recordNetworkRequest(t){this.networkRequests.push(t),this.networkRequests.length>this.maxRequestsToTrack&&this.networkRequests.shift()}getNetworkStatus(){return this.networkRequests.length===0?!0:this.networkRequests.filter(n=>n).length/this.networkRequests.length>=.6}},it=class{constructor(t){this.xua=Mn();this.getJoliSource=()=>A.joliSource;var n;let r=A.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com";this.baseUrl=(n=t==null?void 0:t.baseUrl)!=null?n:r}get(t,r){return C(this,null,function*(){try{let{query:n,timeout:i}=r!=null?r:{},{headers:c}=r!=null?r:{},d=n?new URLSearchParams(n):null,m=d==null?void 0:d.toString(),p=`${this.baseUrl}${t}${m?`?${m}`:""}`,b=this.xua,v=this.getJoliSource();c=Object.assign({},c!=null?c:{},b?{"x-user-agent":b}:{},v?{"x-joli-source":v}:{});let S=yield fetch(p,{method:"GET",headers:c,credentials:"include",signal:Tr(i!=null?i:3e4)});return he.getInstance().recordNetworkRequest(!0),yield S.json()}catch(n){throw he.getInstance().recordNetworkRequest(!1),n}})}post(t,r){return C(this,null,function*(){try{let{data:n,query:i,timeout:c}=r!=null?r:{},{headers:d}=r!=null?r:{},m=i?new URLSearchParams(i):null,p=m==null?void 0:m.toString(),b=`${this.baseUrl}${t}${p?`?${p}`:""}`,v=this.xua,S=this.getJoliSource();d=Object.assign({},d!=null?d:{},{"Content-Type":"application/json"},v?{"x-user-agent":v}:{},S?{"x-joli-source":S}:{});let g=yield fetch(b,{method:"POST",headers:d,body:JSON.stringify(n),signal:Tr(c!=null?c:3e4),credentials:"include"});he.getInstance().recordNetworkRequest(!0);let I=g.headers.get("content-type");if(I!=null&&I.includes("application/octet-stream"))try{return g.blob()}catch(O){return yield g.arrayBuffer()}if(I!=null&&I.includes("multipart/form-data")||I!=null&&I.includes("application/x-www-form-urlencoded"))try{return g.formData()}catch(O){return yield g.text()}if(I!=null&&I.includes("application/json"))try{return yield g.json()}catch(O){return yield g.text()}return g}catch(n){throw he.getInstance().recordNetworkRequest(!1),n}})}put(t,r){return C(this,null,function*(){try{let{data:n,query:i,timeout:c}=r!=null?r:{},{headers:d}=r!=null?r:{},m=i?new URLSearchParams(i):null,p=m==null?void 0:m.toString(),b=`${this.baseUrl}${t}${p?`?${p}`:""}`,v=this.xua,S=this.getJoliSource();d=Object.assign({},d!=null?d:{},{"Content-Type":"application/json"},v?{"x-user-agent":v}:{},S?{"x-joli-source":S}:{});let g=yield fetch(b,{method:"PUT",headers:d,credentials:"include",body:JSON.stringify(n!=null?n:{})});if(!g.ok)throw he.getInstance().recordNetworkRequest(!1),new Error(`HTTP error! status: ${g.status}`);return he.getInstance().recordNetworkRequest(!0),yield g.json()}catch(n){throw console.error("Error:",n),n}})}};window.JoliboxHttpClient=it;ge=he.getInstance()});var Sr,at,Rr=K(()=>{"use strict";ee();Ir();Ke();Sr=class extends ot{constructor(){super(...arguments);this.hostToApiMap={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}};this.httpClient=ge.create({baseUrl:this.apiBaseURL})}get apiBaseURL(){var n,i;let r=(n=this.hostToApiMap[window.location.host])!=null?n:this.hostToApiMap.default;return(i=A.testMode)!=null&&i?r.test:r.prod}doReport(r){this.httpClient.post("/report",{data:r,timeout:5e3}).catch(n=>{console.info("report error",n)})}},at=new Sr});var Ca,Xn=K(()=>{"use strict";Jn();$();wr();$();Rr();ee();Ca=(e,t)=>{var i,c,d;let r={message:t.message,stack:(i=t.stack)!=null?i:"",errorType:t.name,source:0},n={name:e,type:He.ErrorTrace,location:null,target:null,extra:r,timestamp:Date.now(),userId:(d=(c=A.hostUserInfo)==null?void 0:c.uid)!=null?d:null};at.trackEvent(n,xe.WebSDK)};we.on("GLOBAL_ERROR",(e,t)=>{Ca(t.tag,e)});we.on("GLOBAL_USER_ERROR",(e,t)=>{ce.log("UserError",e,t)})});var st,Zn=K(()=>{"use strict";st=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,i,c=!1,d=0,m=()=>{if(!c)return;let I=Date.now(),O=I-r;O>=this.interval&&(this.visible&&(d+=O,t(d)),r=I),n=requestAnimationFrame(m)},p=()=>{v(),r=Date.now(),i=window.setInterval(()=>{if(!c)return;let I=Date.now();I-r>=this.interval&&(r=I)},this.interval)},b=()=>{S(),r=Date.now(),n=requestAnimationFrame(m)},v=()=>{n&&(cancelAnimationFrame(n),n=0)},S=()=>{i&&(clearInterval(i),i=0)};this.eventEmitter.on("visible",I=>{c&&(console.log("visible",I),I?b():p())});let g=this.visible;return{start(){c||(c=!0,g?b():p())},stop(){c=!1,v(),S()}}}}});var ct,eo=K(()=>{"use strict";ee();Zn();Ke();ct=class extends st{constructor(r,n,i){super(n,i);this.httpClient=ge.create();this.gameId=A.mpId,this.sessionId=A.sessionId,this.track=r}reporter(r){return C(this,null,function*(){let{event:n,params:i}=r;yield this.httpClient.post("/api/base/app-event",{data:{eventType:n,gameInfo:V({gameId:this.gameId,sessionId:this.sessionId},i)}})})}tracker(r,n=null){this.track(r,n)}}});var to,Pa,fe,Oa,Ar,le,Ee=K(()=>{"use strict";Xn();$();$();Ir();Rr();eo();ee();Er();to=ae(),Pa={type:xe.WebSDK,platform:"h5",jssdk_version:A.sdkInfo.jssdkVersion,mp_id:A.mpId,mp_version:A.mpVersion},{track:fe,trackPerformance:Oa}=Wn((...e)=>{var d,m,p,b;let[,t]=e,r=t,n=wn(r.extra)?r.extra:ar(r.extra)?JSON.parse(r.extra):{},i=z(V({},n),{mp_id:(d=r.mp_id)!=null?d:"",mp_version:(m=r.mp_version)!=null?m:""}),c={name:t.tag,type:He.System,location:null,target:null,extra:i,timestamp:Date.now(),userId:(b=(p=A.hostUserInfo)==null?void 0:p.uid)!=null?b:null};at.trackEvent(c,xe.WebSDK)},Pa);to.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{Oa(e,t,r)});to.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{fe(e,t)});Ar=new de,le=new ct(fe,Ar)});function ro(e){let t=lr.config[e];return t||(t={},lr.config[e]=t),(r,n)=>{if(t[r]){ce.warn(`[can i use] ${r} already registered`);return}t[r]=V({},n)}}var no=K(()=>{"use strict";$()});function xr(e){oo=e}function ut(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>ut(t)):Object.keys(e).reduce((t,r)=>(t[r]=ut(e[r]),t),{})}function ve(e){return typeof e=="number"}function kr(e){let t=Cr(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Cr(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var oo,Y,lt,dt,ft,mt,ke,pt,ht,gt,vt,yt,bt,_t,wt,Et,It,Tt,St,Pr=K(()=>{"use strict";oo=!1;Y=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(oo)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${kr(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return ut(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:ut(this._default)}optional(){return this._optional=!0,this}};lt=class extends Y{validate(t){return this._optional&&t===void 0?!0:ve(t)?ve(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):ve(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):ve(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},dt=class extends Y{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},ft=class extends Y{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(ve(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(ve(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},mt=class extends Y{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ke=class extends Y{validate(t){return!0}},pt=class extends Y{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},ht=class extends Y{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},gt=class extends Y{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},vt=class extends Y{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(n=>JSON.stringify(n)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${kr(t)}`)}return!0}},yt=class extends Y{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(ve(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(ve(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(ve(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let n=this._item;if(!n)return!0;let i=!0;if(r.forEach((c,d)=>{if(n.path=`${this.path}[${d}]`,n.errors=this.errors,c===void 0&&n.hasDefault){r[d]=n.defaultValue;return}n.validate(c)||(n.hasFallback?r[d]=n.fallbackValue:i=!1)}),this._uniqueItems){let c=new Map;for(let d in r)c.has(r[d])?i=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${c.get(r[d])}] and ${this.path}[${d}] are identical)`):c.set(r[d],d)}return i}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},bt=class extends Y{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Cr(r)!=="object")return this.fail({expect:"object",actual:r});let i=r,c=this._value;c.errors=this.errors;let d=!0;for(let m in i){let p=i[m];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(m)?c.path=`${this.path}.${m}`:c.path=`${this.path}["${m}"]`,!(p===void 0&&c._optional)){if(p===void 0&&c.hasDefault){i[m]=c.defaultValue;continue}c.validate(p)||(c.hasFallback?i[m]=c.fallbackValue:d=!1)}}return d}},_t=class extends Y{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Cr(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,i=!0;for(let c in this._object){let d=n[c],m=this._object[c];if(m.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(c)?m.path=`${this.path}.${c}`:m.path=`${this.path}["${c}"]`,!(m._optional&&d===void 0)){if(d===void 0&&m.hasDefault){n[c]=m.defaultValue;continue}m.validate(d)||(m.hasFallback?n[c]=m.fallbackValue:i=!1)}}return i}},wt=class extends Y{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:kr(this.value),actual:r}):!0}},Et=class extends Y{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,i=this._items.length;for(let c=0;c<i;c++){let d=this._items[c];if(d.errors=[],d.path=this.path,!d.validate(t))r.push(d.errors.join("; "));else if(!n){n=!0;break}}if(!n){let c=r.join(`
2
- or `);this.errors.push(c)}return n}},It=class extends Y{constructor(...t){super(),this._items=t;let r=0,n=t.length-1;for(;n>=0;n--){let i=t[n];if(i._optional||i.hasDefault)r+=1;else break}this._minItems=t.length-r}validate(t){if(t===void 0&&this._optional)return!0;if(!Array.isArray(t))return this.fail({expect:"array",actual:t});if(t.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let r=!0;return this._items.forEach((n,i)=>{if(n.path=`${this.path}[${i}]`,n.errors=this.errors,t[i]===void 0&&n.hasDefault){t[i]=n.defaultValue;return}n.validate(t[i])||(n.hasFallback?t[i]=n._fallback:r=!1)}),r}},Tt=class extends Y{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},St=class extends Y{constructor(t){super(),this._ctor=t}validate(t){return t===void 0&&this._optional||t instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:t})}}});function Or(e,t,r="param"){if(e.errors=[],e.path=r,xr(!0),!e.validate(t)){let n=e.errors.join(`
3
- `);throw e.errors.length=0,xr(!1),new TypeError(n)}}var x,Dr=K(()=>{"use strict";Pr();Pr();x={object(e){return new _t(e)},array(e){return new yt(e)},tuple(...e){return new It(...e)},literal(e){return new wt(e)},or(...e){return new Et(...e)},symbol(){return new mt},record(e){return new bt(e)},function(){return new gt},boolean(){return new dt},string(){return new ft},number(){return new lt},undefined(){return new pt},null(){return new ht},unknown(){return new ke},any(){return new ke},as(){return new ke},arraybuffer(){return new Tt},enum(...e){return new vt(...e)},typedarray(e){return new St(e)}}});var Rt,io,ao=K(()=>{"use strict";$();_e();Dr();wr();Rt=1,io=e=>{function t(n,i){return(...c)=>{var S,g,I,O;let d=Date.now(),m={method:n,trace_id:Rt};Rt+=1;let p="SUCCESS",b=`${n}:ok`,v=0;try{if(i.paramsSchema)try{Or(i.paramsSchema,c,"params")}catch(H){throw _r(`${n}:fail ${H.message}`)}let D=i.implement(...c),k=D,P=`${n}:ok`;if(D&&"code"in D){let{code:H,data:F,message:te}=D;p=H,k=F,P=te}return{code:p,message:P,data:k}}catch(D){let k=D;v=(g=(S=k.code)!=null?S:k.errNo)!=null?g:2e3,p="FAILURE";let P=(O=(I=k.message)!=null?I:k.errMsg)!=null?O:`${D}`;return b=`${n}:${p} ${P.replace(/^\S+:(fail|cancel)\s?/,"")}`,ue(new rt(b,v)),{code:p,message:b}}finally{let D=Date.now()-d;e("apiInvoked",z(V({},m),{duration:D,status:p}))}}}function r(n,i){return(...c)=>C(this,null,function*(){var g,I,O,D;let d=En(c)?c:[c],m=Date.now(),p={method:n,trace_id:Rt};Rt+=1;let b=`${n}:ok`,v="SUCCESS",S={code:v,message:b};try{if(i.paramsSchema)try{Or(i.paramsSchema,d,"params")}catch(H){throw _r(H.message)}let P=yield i.implement(...d);if(P&&"code"in P){let{code:H,data:F,message:te}=P;v=H,b=te,P=F}return Object.assign(S,{code:v,message:b,data:P}),S}catch(k){let P=k,H=(I=(g=P.code)!=null?g:P.errNo)!=null?I:2e3;v="FAILURE";let F=(D=(O=P.message)!=null?O:P.errMsg)!=null?D:`${k}`,te=`${n}:${v} ${F.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(S,{code:v,message:te}),ue(new rt(te,H)),S}finally{let k=Date.now()-m;e("apiInvoked",z(V({},p),{duration:k,status:v}))}})}return{createAPI:r,createSyncAPI:t}}});var se,Ie,Q,Ge=K(()=>{"use strict";no();Ee();ao();Dr();({createAPI:se,createSyncAPI:Ie}=io(fe)),Q=ro("h5")});var lo=pn((uo,Fr)=>{(function(e){if(typeof uo=="object"&&typeof Fr!="undefined")Fr.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t=this,t.localforage=e()}})(function(){var e,t,r;return function n(i,c,d){function m(v,S){if(!c[v]){if(!i[v]){var g=typeof Me=="function"&&Me;if(!S&&g)return g(v,!0);if(p)return p(v,!0);var I=new Error("Cannot find module '"+v+"'");throw I.code="MODULE_NOT_FOUND",I}var O=c[v]={exports:{}};i[v][0].call(O.exports,function(D){var k=i[v][1][D];return m(k||D)},O,O.exports,n,i,c,d)}return c[v].exports}for(var p=typeof Me=="function"&&Me,b=0;b<d.length;b++)m(d[b]);return m}({1:[function(n,i,c){(function(d){"use strict";var m=d.MutationObserver||d.WebKitMutationObserver,p;if(m){var b=0,v=new m(D),S=d.document.createTextNode("");v.observe(S,{characterData:!0}),p=function(){S.data=b=++b%2}}else if(!d.setImmediate&&typeof d.MessageChannel!="undefined"){var g=new d.MessageChannel;g.port1.onmessage=D,p=function(){g.port2.postMessage(0)}}else"document"in d&&"onreadystatechange"in d.document.createElement("script")?p=function(){var P=d.document.createElement("script");P.onreadystatechange=function(){D(),P.onreadystatechange=null,P.parentNode.removeChild(P),P=null},d.document.documentElement.appendChild(P)}:p=function(){setTimeout(D,0)};var I,O=[];function D(){I=!0;for(var P,H,F=O.length;F;){for(H=O,O=[],P=-1;++P<F;)H[P]();F=O.length}I=!1}i.exports=k;function k(P){O.push(P)===1&&!I&&p()}}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],2:[function(n,i,c){"use strict";var d=n(1);function m(){}var p={},b=["REJECTED"],v=["FULFILLED"],S=["PENDING"];i.exports=g;function g(T){if(typeof T!="function")throw new TypeError("resolver must be a function");this.state=S,this.queue=[],this.outcome=void 0,T!==m&&k(this,T)}g.prototype.catch=function(T){return this.then(null,T)},g.prototype.then=function(T,U){if(typeof T!="function"&&this.state===v||typeof U!="function"&&this.state===b)return this;var L=new this.constructor(m);if(this.state!==S){var J=this.state===v?T:U;O(L,J,this.outcome)}else this.queue.push(new I(L,T,U));return L};function I(T,U,L){this.promise=T,typeof U=="function"&&(this.onFulfilled=U,this.callFulfilled=this.otherCallFulfilled),typeof L=="function"&&(this.onRejected=L,this.callRejected=this.otherCallRejected)}I.prototype.callFulfilled=function(T){p.resolve(this.promise,T)},I.prototype.otherCallFulfilled=function(T){O(this.promise,this.onFulfilled,T)},I.prototype.callRejected=function(T){p.reject(this.promise,T)},I.prototype.otherCallRejected=function(T){O(this.promise,this.onRejected,T)};function O(T,U,L){d(function(){var J;try{J=U(L)}catch(X){return p.reject(T,X)}J===T?p.reject(T,new TypeError("Cannot resolve promise with itself")):p.resolve(T,J)})}p.resolve=function(T,U){var L=P(D,U);if(L.status==="error")return p.reject(T,L.value);var J=L.value;if(J)k(T,J);else{T.state=v,T.outcome=U;for(var X=-1,re=T.queue.length;++X<re;)T.queue[X].callFulfilled(U)}return T},p.reject=function(T,U){T.state=b,T.outcome=U;for(var L=-1,J=T.queue.length;++L<J;)T.queue[L].callRejected(U);return T};function D(T){var U=T&&T.then;if(T&&(typeof T=="object"||typeof T=="function")&&typeof U=="function")return function(){U.apply(T,arguments)}}function k(T,U){var L=!1;function J(oe){L||(L=!0,p.reject(T,oe))}function X(oe){L||(L=!0,p.resolve(T,oe))}function re(){U(X,J)}var ne=P(re);ne.status==="error"&&J(ne.value)}function P(T,U){var L={};try{L.value=T(U),L.status="success"}catch(J){L.status="error",L.value=J}return L}g.resolve=H;function H(T){return T instanceof this?T:p.resolve(new this(m),T)}g.reject=F;function F(T){var U=new this(m);return p.reject(U,T)}g.all=te;function te(T){var U=this;if(Object.prototype.toString.call(T)!=="[object Array]")return this.reject(new TypeError("must be an array"));var L=T.length,J=!1;if(!L)return this.resolve([]);for(var X=new Array(L),re=0,ne=-1,oe=new this(m);++ne<L;)me(T[ne],ne);return oe;function me(Ue,We){U.resolve(Ue).then(jt,function(Re){J||(J=!0,p.reject(oe,Re))});function jt(Re){X[We]=Re,++re===L&&!J&&(J=!0,p.resolve(oe,X))}}}g.race=B;function B(T){var U=this;if(Object.prototype.toString.call(T)!=="[object Array]")return this.reject(new TypeError("must be an array"));var L=T.length,J=!1;if(!L)return this.resolve([]);for(var X=-1,re=new this(m);++X<L;)ne(T[X]);return re;function ne(oe){U.resolve(oe).then(function(me){J||(J=!0,p.resolve(re,me))},function(me){J||(J=!0,p.reject(re,me))})}}},{1:1}],3:[function(n,i,c){(function(d){"use strict";typeof d.Promise!="function"&&(d.Promise=n(2))}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{2:2}],4:[function(n,i,c){"use strict";var d=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o};function m(o,s){if(!(o instanceof s))throw new TypeError("Cannot call a class as a function")}function p(){try{if(typeof indexedDB!="undefined")return indexedDB;if(typeof webkitIndexedDB!="undefined")return webkitIndexedDB;if(typeof mozIndexedDB!="undefined")return mozIndexedDB;if(typeof OIndexedDB!="undefined")return OIndexedDB;if(typeof msIndexedDB!="undefined")return msIndexedDB}catch(o){return}}var b=p();function v(){try{if(!b||!b.open)return!1;var o=typeof openDatabase!="undefined"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),s=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!o||s)&&typeof indexedDB!="undefined"&&typeof IDBKeyRange!="undefined"}catch(a){return!1}}function S(o,s){o=o||[],s=s||{};try{return new Blob(o,s)}catch(u){if(u.name!=="TypeError")throw u;for(var a=typeof BlobBuilder!="undefined"?BlobBuilder:typeof MSBlobBuilder!="undefined"?MSBlobBuilder:typeof MozBlobBuilder!="undefined"?MozBlobBuilder:WebKitBlobBuilder,l=new a,f=0;f<o.length;f+=1)l.append(o[f]);return l.getBlob(s.type)}}typeof Promise=="undefined"&&n(3);var g=Promise;function I(o,s){s&&o.then(function(a){s(null,a)},function(a){s(a)})}function O(o,s,a){typeof s=="function"&&o.then(s),typeof a=="function"&&o.catch(a)}function D(o){return typeof o!="string"&&(console.warn(o+" used as a key, but it is not a string."),o=String(o)),o}function k(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var P="local-forage-detect-blob-support",H=void 0,F={},te=Object.prototype.toString,B="readonly",T="readwrite";function U(o){for(var s=o.length,a=new ArrayBuffer(s),l=new Uint8Array(a),f=0;f<s;f++)l[f]=o.charCodeAt(f);return a}function L(o){return new g(function(s){var a=o.transaction(P,T),l=S([""]);a.objectStore(P).put(l,"key"),a.onabort=function(f){f.preventDefault(),f.stopPropagation(),s(!1)},a.oncomplete=function(){var f=navigator.userAgent.match(/Chrome\/(\d+)/),u=navigator.userAgent.match(/Edge\//);s(u||!f||parseInt(f[1],10)>=43)}}).catch(function(){return!1})}function J(o){return typeof H=="boolean"?g.resolve(H):L(o).then(function(s){return H=s,H})}function X(o){var s=F[o.name],a={};a.promise=new g(function(l,f){a.resolve=l,a.reject=f}),s.deferredOperations.push(a),s.dbReady?s.dbReady=s.dbReady.then(function(){return a.promise}):s.dbReady=a.promise}function re(o){var s=F[o.name],a=s.deferredOperations.pop();if(a)return a.resolve(),a.promise}function ne(o,s){var a=F[o.name],l=a.deferredOperations.pop();if(l)return l.reject(s),l.promise}function oe(o,s){return new g(function(a,l){if(F[o.name]=F[o.name]||Jr(),o.db)if(s)X(o),o.db.close();else return a(o.db);var f=[o.name];s&&f.push(o.version);var u=b.open.apply(b,f);s&&(u.onupgradeneeded=function(h){var y=u.result;try{y.createObjectStore(o.storeName),h.oldVersion<=1&&y.createObjectStore(P)}catch(_){if(_.name==="ConstraintError")console.warn('The database "'+o.name+'" has been upgraded from version '+h.oldVersion+" to version "+h.newVersion+', but the storage "'+o.storeName+'" already exists.');else throw _}}),u.onerror=function(h){h.preventDefault(),l(u.error)},u.onsuccess=function(){var h=u.result;h.onversionchange=function(y){y.target.close()},a(h),re(o)}})}function me(o){return oe(o,!1)}function Ue(o){return oe(o,!0)}function We(o,s){if(!o.db)return!0;var a=!o.db.objectStoreNames.contains(o.storeName),l=o.version<o.db.version,f=o.version>o.db.version;if(l&&(o.version!==s&&console.warn('The database "'+o.name+`" can't be downgraded from version `+o.db.version+" to version "+o.version+"."),o.version=o.db.version),f||a){if(a){var u=o.db.version+1;u>o.version&&(o.version=u)}return!0}return!1}function jt(o){return new g(function(s,a){var l=new FileReader;l.onerror=a,l.onloadend=function(f){var u=btoa(f.target.result||"");s({__local_forage_encoded_blob:!0,data:u,type:o.type})},l.readAsBinaryString(o)})}function Re(o){var s=U(atob(o.data));return S([s],{type:o.type})}function Hr(o){return o&&o.__local_forage_encoded_blob}function Lo(o){var s=this,a=s._initReady().then(function(){var l=F[s._dbInfo.name];if(l&&l.dbReady)return l.dbReady});return O(a,o,o),a}function Uo(o){X(o);for(var s=F[o.name],a=s.forages,l=0;l<a.length;l++){var f=a[l];f._dbInfo.db&&(f._dbInfo.db.close(),f._dbInfo.db=null)}return o.db=null,me(o).then(function(u){return o.db=u,We(o)?Ue(o):u}).then(function(u){o.db=s.db=u;for(var h=0;h<a.length;h++)a[h]._dbInfo.db=u}).catch(function(u){throw ne(o,u),u})}function pe(o,s,a,l){l===void 0&&(l=1);try{var f=o.db.transaction(o.storeName,s);a(null,f)}catch(u){if(l>0&&(!o.db||u.name==="InvalidStateError"||u.name==="NotFoundError"))return g.resolve().then(function(){if(!o.db||u.name==="NotFoundError"&&!o.db.objectStoreNames.contains(o.storeName)&&o.version<=o.db.version)return o.db&&(o.version=o.db.version+1),Ue(o)}).then(function(){return Uo(o).then(function(){pe(o,s,a,l-1)})}).catch(a);a(u)}}function Jr(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Fo(o){var s=this,a={db:null};if(o)for(var l in o)a[l]=o[l];var f=F[a.name];f||(f=Jr(),F[a.name]=f),f.forages.push(s),s._initReady||(s._initReady=s.ready,s.ready=Lo);var u=[];function h(){return g.resolve()}for(var y=0;y<f.forages.length;y++){var _=f.forages[y];_!==s&&u.push(_._initReady().catch(h))}var w=f.forages.slice(0);return g.all(u).then(function(){return a.db=f.db,me(a)}).then(function(E){return a.db=E,We(a,s._defaultConfig.version)?Ue(a):E}).then(function(E){a.db=f.db=E,s._dbInfo=a;for(var R=0;R<w.length;R++){var N=w[R];N!==s&&(N._dbInfo.db=a.db,N._dbInfo.version=a.version)}})}function Bo(o,s){var a=this;o=D(o);var l=new g(function(f,u){a.ready().then(function(){pe(a._dbInfo,B,function(h,y){if(h)return u(h);try{var _=y.objectStore(a._dbInfo.storeName),w=_.get(o);w.onsuccess=function(){var E=w.result;E===void 0&&(E=null),Hr(E)&&(E=Re(E)),f(E)},w.onerror=function(){u(w.error)}}catch(E){u(E)}})}).catch(u)});return I(l,s),l}function Mo(o,s){var a=this,l=new g(function(f,u){a.ready().then(function(){pe(a._dbInfo,B,function(h,y){if(h)return u(h);try{var _=y.objectStore(a._dbInfo.storeName),w=_.openCursor(),E=1;w.onsuccess=function(){var R=w.result;if(R){var N=R.value;Hr(N)&&(N=Re(N));var M=o(N,R.key,E++);M!==void 0?f(M):R.continue()}else f()},w.onerror=function(){u(w.error)}}catch(R){u(R)}})}).catch(u)});return I(l,s),l}function $o(o,s,a){var l=this;o=D(o);var f=new g(function(u,h){var y;l.ready().then(function(){return y=l._dbInfo,te.call(s)==="[object Blob]"?J(y.db).then(function(_){return _?s:jt(s)}):s}).then(function(_){pe(l._dbInfo,T,function(w,E){if(w)return h(w);try{var R=E.objectStore(l._dbInfo.storeName);_===null&&(_=void 0);var N=R.put(_,o);E.oncomplete=function(){_===void 0&&(_=null),u(_)},E.onabort=E.onerror=function(){var M=N.error?N.error:N.transaction.error;h(M)}}catch(M){h(M)}})}).catch(h)});return I(f,a),f}function jo(o,s){var a=this;o=D(o);var l=new g(function(f,u){a.ready().then(function(){pe(a._dbInfo,T,function(h,y){if(h)return u(h);try{var _=y.objectStore(a._dbInfo.storeName),w=_.delete(o);y.oncomplete=function(){f()},y.onerror=function(){u(w.error)},y.onabort=function(){var E=w.error?w.error:w.transaction.error;u(E)}}catch(E){u(E)}})}).catch(u)});return I(l,s),l}function Vo(o){var s=this,a=new g(function(l,f){s.ready().then(function(){pe(s._dbInfo,T,function(u,h){if(u)return f(u);try{var y=h.objectStore(s._dbInfo.storeName),_=y.clear();h.oncomplete=function(){l()},h.onabort=h.onerror=function(){var w=_.error?_.error:_.transaction.error;f(w)}}catch(w){f(w)}})}).catch(f)});return I(a,o),a}function Ho(o){var s=this,a=new g(function(l,f){s.ready().then(function(){pe(s._dbInfo,B,function(u,h){if(u)return f(u);try{var y=h.objectStore(s._dbInfo.storeName),_=y.count();_.onsuccess=function(){l(_.result)},_.onerror=function(){f(_.error)}}catch(w){f(w)}})}).catch(f)});return I(a,o),a}function Jo(o,s){var a=this,l=new g(function(f,u){if(o<0){f(null);return}a.ready().then(function(){pe(a._dbInfo,B,function(h,y){if(h)return u(h);try{var _=y.objectStore(a._dbInfo.storeName),w=!1,E=_.openKeyCursor();E.onsuccess=function(){var R=E.result;if(!R){f(null);return}o===0||w?f(R.key):(w=!0,R.advance(o))},E.onerror=function(){u(E.error)}}catch(R){u(R)}})}).catch(u)});return I(l,s),l}function Ko(o){var s=this,a=new g(function(l,f){s.ready().then(function(){pe(s._dbInfo,B,function(u,h){if(u)return f(u);try{var y=h.objectStore(s._dbInfo.storeName),_=y.openKeyCursor(),w=[];_.onsuccess=function(){var E=_.result;if(!E){l(w);return}w.push(E.key),E.continue()},_.onerror=function(){f(_.error)}}catch(E){f(E)}})}).catch(f)});return I(a,o),a}function Go(o,s){s=k.apply(this,arguments);var a=this.config();o=typeof o!="function"&&o||{},o.name||(o.name=o.name||a.name,o.storeName=o.storeName||a.storeName);var l=this,f;if(!o.name)f=g.reject("Invalid arguments");else{var u=o.name===a.name&&l._dbInfo.db,h=u?g.resolve(l._dbInfo.db):me(o).then(function(y){var _=F[o.name],w=_.forages;_.db=y;for(var E=0;E<w.length;E++)w[E]._dbInfo.db=y;return y});o.storeName?f=h.then(function(y){if(y.objectStoreNames.contains(o.storeName)){var _=y.version+1;X(o);var w=F[o.name],E=w.forages;y.close();for(var R=0;R<E.length;R++){var N=E[R];N._dbInfo.db=null,N._dbInfo.version=_}var M=new g(function(j,W){var q=b.open(o.name,_);q.onerror=function(ie){var Be=q.result;Be.close(),W(ie)},q.onupgradeneeded=function(){var ie=q.result;ie.deleteObjectStore(o.storeName)},q.onsuccess=function(){var ie=q.result;ie.close(),j(ie)}});return M.then(function(j){w.db=j;for(var W=0;W<E.length;W++){var q=E[W];q._dbInfo.db=j,re(q._dbInfo)}}).catch(function(j){throw(ne(o,j)||g.resolve()).catch(function(){}),j})}}):f=h.then(function(y){X(o);var _=F[o.name],w=_.forages;y.close();for(var E=0;E<w.length;E++){var R=w[E];R._dbInfo.db=null}var N=new g(function(M,j){var W=b.deleteDatabase(o.name);W.onerror=function(){var q=W.result;q&&q.close(),j(W.error)},W.onblocked=function(){console.warn('dropInstance blocked for database "'+o.name+'" until all open connections are closed')},W.onsuccess=function(){var q=W.result;q&&q.close(),M(q)}});return N.then(function(M){_.db=M;for(var j=0;j<w.length;j++){var W=w[j];re(W._dbInfo)}}).catch(function(M){throw(ne(o,M)||g.resolve()).catch(function(){}),M})})}return I(f,s),f}var qo={_driver:"asyncStorage",_initStorage:Fo,_support:v(),iterate:Mo,getItem:Bo,setItem:$o,removeItem:jo,clear:Vo,length:Ho,key:Jo,keys:Ko,dropInstance:Go};function Wo(){return typeof openDatabase=="function"}var ye="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Yo="~~local_forage_type~",Kr=/^~~local_forage_type~([^~]+)~/,Ye="__lfsc__:",Vt=Ye.length,Ht="arbf",Jt="blob",Gr="si08",qr="ui08",Wr="uic8",Yr="si16",zr="si32",Qr="ur16",Xr="ui32",Zr="fl32",en="fl64",tn=Vt+Ht.length,rn=Object.prototype.toString;function nn(o){var s=o.length*.75,a=o.length,l,f=0,u,h,y,_;o[o.length-1]==="="&&(s--,o[o.length-2]==="="&&s--);var w=new ArrayBuffer(s),E=new Uint8Array(w);for(l=0;l<a;l+=4)u=ye.indexOf(o[l]),h=ye.indexOf(o[l+1]),y=ye.indexOf(o[l+2]),_=ye.indexOf(o[l+3]),E[f++]=u<<2|h>>4,E[f++]=(h&15)<<4|y>>2,E[f++]=(y&3)<<6|_&63;return w}function Kt(o){var s=new Uint8Array(o),a="",l;for(l=0;l<s.length;l+=3)a+=ye[s[l]>>2],a+=ye[(s[l]&3)<<4|s[l+1]>>4],a+=ye[(s[l+1]&15)<<2|s[l+2]>>6],a+=ye[s[l+2]&63];return s.length%3===2?a=a.substring(0,a.length-1)+"=":s.length%3===1&&(a=a.substring(0,a.length-2)+"=="),a}function zo(o,s){var a="";if(o&&(a=rn.call(o)),o&&(a==="[object ArrayBuffer]"||o.buffer&&rn.call(o.buffer)==="[object ArrayBuffer]")){var l,f=Ye;o instanceof ArrayBuffer?(l=o,f+=Ht):(l=o.buffer,a==="[object Int8Array]"?f+=Gr:a==="[object Uint8Array]"?f+=qr:a==="[object Uint8ClampedArray]"?f+=Wr:a==="[object Int16Array]"?f+=Yr:a==="[object Uint16Array]"?f+=Qr:a==="[object Int32Array]"?f+=zr:a==="[object Uint32Array]"?f+=Xr:a==="[object Float32Array]"?f+=Zr:a==="[object Float64Array]"?f+=en:s(new Error("Failed to get type for BinaryArray"))),s(f+Kt(l))}else if(a==="[object Blob]"){var u=new FileReader;u.onload=function(){var h=Yo+o.type+"~"+Kt(this.result);s(Ye+Jt+h)},u.readAsArrayBuffer(o)}else try{s(JSON.stringify(o))}catch(h){console.error("Couldn't convert value into a JSON string: ",o),s(null,h)}}function Qo(o){if(o.substring(0,Vt)!==Ye)return JSON.parse(o);var s=o.substring(tn),a=o.substring(Vt,tn),l;if(a===Jt&&Kr.test(s)){var f=s.match(Kr);l=f[1],s=s.substring(f[0].length)}var u=nn(s);switch(a){case Ht:return u;case Jt:return S([u],{type:l});case Gr:return new Int8Array(u);case qr:return new Uint8Array(u);case Wr:return new Uint8ClampedArray(u);case Yr:return new Int16Array(u);case Qr:return new Uint16Array(u);case zr:return new Int32Array(u);case Xr:return new Uint32Array(u);case Zr:return new Float32Array(u);case en:return new Float64Array(u);default:throw new Error("Unkown type: "+a)}}var Gt={serialize:zo,deserialize:Qo,stringToBuffer:nn,bufferToString:Kt};function on(o,s,a,l){o.executeSql("CREATE TABLE IF NOT EXISTS "+s.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],a,l)}function Xo(o){var s=this,a={db:null};if(o)for(var l in o)a[l]=typeof o[l]!="string"?o[l].toString():o[l];var f=new g(function(u,h){try{a.db=openDatabase(a.name,String(a.version),a.description,a.size)}catch(y){return h(y)}a.db.transaction(function(y){on(y,a,function(){s._dbInfo=a,u()},function(_,w){h(w)})},h)});return a.serializer=Gt,f}function be(o,s,a,l,f,u){o.executeSql(a,l,f,function(h,y){y.code===y.SYNTAX_ERR?h.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[s.storeName],function(_,w){w.rows.length?u(_,y):on(_,s,function(){_.executeSql(a,l,f,u)},u)},u):u(h,y)},u)}function Zo(o,s){var a=this;o=D(o);var l=new g(function(f,u){a.ready().then(function(){var h=a._dbInfo;h.db.transaction(function(y){be(y,h,"SELECT * FROM "+h.storeName+" WHERE key = ? LIMIT 1",[o],function(_,w){var E=w.rows.length?w.rows.item(0).value:null;E&&(E=h.serializer.deserialize(E)),f(E)},function(_,w){u(w)})})}).catch(u)});return I(l,s),l}function ei(o,s){var a=this,l=new g(function(f,u){a.ready().then(function(){var h=a._dbInfo;h.db.transaction(function(y){be(y,h,"SELECT * FROM "+h.storeName,[],function(_,w){for(var E=w.rows,R=E.length,N=0;N<R;N++){var M=E.item(N),j=M.value;if(j&&(j=h.serializer.deserialize(j)),j=o(j,M.key,N+1),j!==void 0){f(j);return}}f()},function(_,w){u(w)})})}).catch(u)});return I(l,s),l}function an(o,s,a,l){var f=this;o=D(o);var u=new g(function(h,y){f.ready().then(function(){s===void 0&&(s=null);var _=s,w=f._dbInfo;w.serializer.serialize(s,function(E,R){R?y(R):w.db.transaction(function(N){be(N,w,"INSERT OR REPLACE INTO "+w.storeName+" (key, value) VALUES (?, ?)",[o,E],function(){h(_)},function(M,j){y(j)})},function(N){if(N.code===N.QUOTA_ERR){if(l>0){h(an.apply(f,[o,_,a,l-1]));return}y(N)}})})}).catch(y)});return I(u,a),u}function ti(o,s,a){return an.apply(this,[o,s,a,1])}function ri(o,s){var a=this;o=D(o);var l=new g(function(f,u){a.ready().then(function(){var h=a._dbInfo;h.db.transaction(function(y){be(y,h,"DELETE FROM "+h.storeName+" WHERE key = ?",[o],function(){f()},function(_,w){u(w)})})}).catch(u)});return I(l,s),l}function ni(o){var s=this,a=new g(function(l,f){s.ready().then(function(){var u=s._dbInfo;u.db.transaction(function(h){be(h,u,"DELETE FROM "+u.storeName,[],function(){l()},function(y,_){f(_)})})}).catch(f)});return I(a,o),a}function oi(o){var s=this,a=new g(function(l,f){s.ready().then(function(){var u=s._dbInfo;u.db.transaction(function(h){be(h,u,"SELECT COUNT(key) as c FROM "+u.storeName,[],function(y,_){var w=_.rows.item(0).c;l(w)},function(y,_){f(_)})})}).catch(f)});return I(a,o),a}function ii(o,s){var a=this,l=new g(function(f,u){a.ready().then(function(){var h=a._dbInfo;h.db.transaction(function(y){be(y,h,"SELECT key FROM "+h.storeName+" WHERE id = ? LIMIT 1",[o+1],function(_,w){var E=w.rows.length?w.rows.item(0).key:null;f(E)},function(_,w){u(w)})})}).catch(u)});return I(l,s),l}function ai(o){var s=this,a=new g(function(l,f){s.ready().then(function(){var u=s._dbInfo;u.db.transaction(function(h){be(h,u,"SELECT key FROM "+u.storeName,[],function(y,_){for(var w=[],E=0;E<_.rows.length;E++)w.push(_.rows.item(E).key);l(w)},function(y,_){f(_)})})}).catch(f)});return I(a,o),a}function si(o){return new g(function(s,a){o.transaction(function(l){l.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(f,u){for(var h=[],y=0;y<u.rows.length;y++)h.push(u.rows.item(y).name);s({db:o,storeNames:h})},function(f,u){a(u)})},function(l){a(l)})})}function ci(o,s){s=k.apply(this,arguments);var a=this.config();o=typeof o!="function"&&o||{},o.name||(o.name=o.name||a.name,o.storeName=o.storeName||a.storeName);var l=this,f;return o.name?f=new g(function(u){var h;o.name===a.name?h=l._dbInfo.db:h=openDatabase(o.name,"","",0),o.storeName?u({db:h,storeNames:[o.storeName]}):u(si(h))}).then(function(u){return new g(function(h,y){u.db.transaction(function(_){function w(M){return new g(function(j,W){_.executeSql("DROP TABLE IF EXISTS "+M,[],function(){j()},function(q,ie){W(ie)})})}for(var E=[],R=0,N=u.storeNames.length;R<N;R++)E.push(w(u.storeNames[R]));g.all(E).then(function(){h()}).catch(function(M){y(M)})},function(_){y(_)})})}):f=g.reject("Invalid arguments"),I(f,s),f}var ui={_driver:"webSQLStorage",_initStorage:Xo,_support:Wo(),iterate:ei,getItem:Zo,setItem:ti,removeItem:ri,clear:ni,length:oi,key:ii,keys:ai,dropInstance:ci};function li(){try{return typeof localStorage!="undefined"&&"setItem"in localStorage&&!!localStorage.setItem}catch(o){return!1}}function sn(o,s){var a=o.name+"/";return o.storeName!==s.storeName&&(a+=o.storeName+"/"),a}function di(){var o="_localforage_support_test";try{return localStorage.setItem(o,!0),localStorage.removeItem(o),!1}catch(s){return!0}}function fi(){return!di()||localStorage.length>0}function mi(o){var s=this,a={};if(o)for(var l in o)a[l]=o[l];return a.keyPrefix=sn(o,s._defaultConfig),fi()?(s._dbInfo=a,a.serializer=Gt,g.resolve()):g.reject()}function pi(o){var s=this,a=s.ready().then(function(){for(var l=s._dbInfo.keyPrefix,f=localStorage.length-1;f>=0;f--){var u=localStorage.key(f);u.indexOf(l)===0&&localStorage.removeItem(u)}});return I(a,o),a}function hi(o,s){var a=this;o=D(o);var l=a.ready().then(function(){var f=a._dbInfo,u=localStorage.getItem(f.keyPrefix+o);return u&&(u=f.serializer.deserialize(u)),u});return I(l,s),l}function gi(o,s){var a=this,l=a.ready().then(function(){for(var f=a._dbInfo,u=f.keyPrefix,h=u.length,y=localStorage.length,_=1,w=0;w<y;w++){var E=localStorage.key(w);if(E.indexOf(u)===0){var R=localStorage.getItem(E);if(R&&(R=f.serializer.deserialize(R)),R=o(R,E.substring(h),_++),R!==void 0)return R}}});return I(l,s),l}function vi(o,s){var a=this,l=a.ready().then(function(){var f=a._dbInfo,u;try{u=localStorage.key(o)}catch(h){u=null}return u&&(u=u.substring(f.keyPrefix.length)),u});return I(l,s),l}function yi(o){var s=this,a=s.ready().then(function(){for(var l=s._dbInfo,f=localStorage.length,u=[],h=0;h<f;h++){var y=localStorage.key(h);y.indexOf(l.keyPrefix)===0&&u.push(y.substring(l.keyPrefix.length))}return u});return I(a,o),a}function bi(o){var s=this,a=s.keys().then(function(l){return l.length});return I(a,o),a}function _i(o,s){var a=this;o=D(o);var l=a.ready().then(function(){var f=a._dbInfo;localStorage.removeItem(f.keyPrefix+o)});return I(l,s),l}function wi(o,s,a){var l=this;o=D(o);var f=l.ready().then(function(){s===void 0&&(s=null);var u=s;return new g(function(h,y){var _=l._dbInfo;_.serializer.serialize(s,function(w,E){if(E)y(E);else try{localStorage.setItem(_.keyPrefix+o,w),h(u)}catch(R){(R.name==="QuotaExceededError"||R.name==="NS_ERROR_DOM_QUOTA_REACHED")&&y(R),y(R)}})})});return I(f,a),f}function Ei(o,s){if(s=k.apply(this,arguments),o=typeof o!="function"&&o||{},!o.name){var a=this.config();o.name=o.name||a.name,o.storeName=o.storeName||a.storeName}var l=this,f;return o.name?f=new g(function(u){o.storeName?u(sn(o,l._defaultConfig)):u(o.name+"/")}).then(function(u){for(var h=localStorage.length-1;h>=0;h--){var y=localStorage.key(h);y.indexOf(u)===0&&localStorage.removeItem(y)}}):f=g.reject("Invalid arguments"),I(f,s),f}var Ii={_driver:"localStorageWrapper",_initStorage:mi,_support:li(),iterate:gi,getItem:hi,setItem:wi,removeItem:_i,clear:pi,length:bi,key:vi,keys:yi,dropInstance:Ei},Ti=function(s,a){return s===a||typeof s=="number"&&typeof a=="number"&&isNaN(s)&&isNaN(a)},Si=function(s,a){for(var l=s.length,f=0;f<l;){if(Ti(s[f],a))return!0;f++}return!1},cn=Array.isArray||function(o){return Object.prototype.toString.call(o)==="[object Array]"},Fe={},un={},Ae={INDEXEDDB:qo,WEBSQL:ui,LOCALSTORAGE:Ii},Ri=[Ae.INDEXEDDB._driver,Ae.WEBSQL._driver,Ae.LOCALSTORAGE._driver],ze=["dropInstance"],qt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ze),Ai={description:"",driver:Ri.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function xi(o,s){o[s]=function(){var a=arguments;return o.ready().then(function(){return o[s].apply(o,a)})}}function Wt(){for(var o=1;o<arguments.length;o++){var s=arguments[o];if(s)for(var a in s)s.hasOwnProperty(a)&&(cn(s[a])?arguments[0][a]=s[a].slice():arguments[0][a]=s[a])}return arguments[0]}var ki=function(){function o(s){m(this,o);for(var a in Ae)if(Ae.hasOwnProperty(a)){var l=Ae[a],f=l._driver;this[a]=f,Fe[f]||this.defineDriver(l)}this._defaultConfig=Wt({},Ai),this._config=Wt({},this._defaultConfig,s),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return o.prototype.config=function(a){if((typeof a=="undefined"?"undefined":d(a))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var l in a){if(l==="storeName"&&(a[l]=a[l].replace(/\W/g,"_")),l==="version"&&typeof a[l]!="number")return new Error("Database version must be a number.");this._config[l]=a[l]}return"driver"in a&&a.driver?this.setDriver(this._config.driver):!0}else return typeof a=="string"?this._config[a]:this._config},o.prototype.defineDriver=function(a,l,f){var u=new g(function(h,y){try{var _=a._driver,w=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!a._driver){y(w);return}for(var E=qt.concat("_initStorage"),R=0,N=E.length;R<N;R++){var M=E[R],j=!Si(ze,M);if((j||a[M])&&typeof a[M]!="function"){y(w);return}}var W=function(){for(var Be=function(Oi){return function(){var Di=new Error("Method "+Oi+" is not implemented by the current driver"),ln=g.reject(Di);return I(ln,arguments[arguments.length-1]),ln}},Yt=0,Pi=ze.length;Yt<Pi;Yt++){var zt=ze[Yt];a[zt]||(a[zt]=Be(zt))}};W();var q=function(Be){Fe[_]&&console.info("Redefining LocalForage driver: "+_),Fe[_]=a,un[_]=Be,h()};"_support"in a?a._support&&typeof a._support=="function"?a._support().then(q,y):q(!!a._support):q(!0)}catch(ie){y(ie)}});return O(u,l,f),u},o.prototype.driver=function(){return this._driver||null},o.prototype.getDriver=function(a,l,f){var u=Fe[a]?g.resolve(Fe[a]):g.reject(new Error("Driver not found."));return O(u,l,f),u},o.prototype.getSerializer=function(a){var l=g.resolve(Gt);return O(l,a),l},o.prototype.ready=function(a){var l=this,f=l._driverSet.then(function(){return l._ready===null&&(l._ready=l._initDriver()),l._ready});return O(f,a,a),f},o.prototype.setDriver=function(a,l,f){var u=this;cn(a)||(a=[a]);var h=this._getSupportedDrivers(a);function y(){u._config.driver=u.driver()}function _(R){return u._extend(R),y(),u._ready=u._initStorage(u._config),u._ready}function w(R){return function(){var N=0;function M(){for(;N<R.length;){var j=R[N];return N++,u._dbInfo=null,u._ready=null,u.getDriver(j).then(_).catch(M)}y();var W=new Error("No available storage method found.");return u._driverSet=g.reject(W),u._driverSet}return M()}}var E=this._driverSet!==null?this._driverSet.catch(function(){return g.resolve()}):g.resolve();return this._driverSet=E.then(function(){var R=h[0];return u._dbInfo=null,u._ready=null,u.getDriver(R).then(function(N){u._driver=N._driver,y(),u._wrapLibraryMethodsWithReady(),u._initDriver=w(h)})}).catch(function(){y();var R=new Error("No available storage method found.");return u._driverSet=g.reject(R),u._driverSet}),O(this._driverSet,l,f),this._driverSet},o.prototype.supports=function(a){return!!un[a]},o.prototype._extend=function(a){Wt(this,a)},o.prototype._getSupportedDrivers=function(a){for(var l=[],f=0,u=a.length;f<u;f++){var h=a[f];this.supports(h)&&l.push(h)}return l},o.prototype._wrapLibraryMethodsWithReady=function(){for(var a=0,l=qt.length;a<l;a++)xi(this,qt[a])},o.prototype.createInstance=function(a){return new o(a)},o}(),Ci=new ki;i.exports=Ci},{3:3}]},{},[4])(4)})});var mo=pn(Te=>{"use strict";$();Ge();Ee();var Ce=ae(),za=se("levelFinished",{paramsSchema:x.tuple(x.string(),x.object({result:x.boolean(),duration:x.number()})),implement:(e,t)=>C(Te,null,function*(){let{result:r,duration:n}=t;ce.info("onLevelFinished",r,n),yield Promise.all([le.reporter({event:"COMPLETE_GAME_LEVEL"}),le.tracker("LevelFinished",{levelId:e,result:r,duration:n})])})}),Qa=se("taskFinished",{paramsSchema:x.tuple(x.string(),x.object({duration:x.number()})),implement:(e,t)=>C(Te,null,function*(){let{duration:r}=t;yield le.tracker("TaskFinished",{duration:r,taskId:e})})}),Xa=se("levelUpgrade",{paramsSchema:x.tuple(x.string(),x.string()),implement:(e,t)=>C(Te,null,function*(){return yield le.tracker("LevelUpgrade",{name:t,levelId:e})})}),Za=se("onHistoryUserLevel",{paramsSchema:x.tuple(x.number()),implement:e=>C(Te,null,function*(){return yield le.tracker("HistoryUserLevel",{level:e})})}),es=se("onHistoryUserScore",{paramsSchema:x.tuple(x.number()),implement:e=>C(Te,null,function*(){return yield le.tracker("HistoryUserScore",{score:e})})}),ts=se("taskEvent",{paramsSchema:x.tuple(x.string(),x.object({tools:x.array(x.object({id:x.string(),name:x.string(),count:x.number(),description:x.string().optional(),price:x.object({amount:x.number(),unit:x.string()}).optional()})).optional(),awards:x.array(x.object({id:x.string(),name:x.string()})).optional()})),implement:(e,t)=>C(Te,null,function*(){var r;(r=t.tools)!=null&&r.length&&(yield Promise.all([le.reporter({event:"USE_GAME_ITEM"}),le.tracker("UseGameItem",V({taskId:e},t))]))})});Ce.registerCommand("TaskTrackerSDK.levelFinished",za);Ce.registerCommand("TaskTrackerSDK.taskFinished",Qa);Ce.registerCommand("TaskTrackerSDK.levelUpgrade",Xa);Ce.registerCommand("TaskTrackerSDK.historyUserLevel",Za);Ce.registerCommand("TaskTrackerSDK.historyUserScore",es);Ce.registerCommand("TaskTrackerSDK.taskEvent",ts);Q("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});Q("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});Q("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});Q("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});Q("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});Q("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}})});Ee();ee();Ge();$();var so=ae(),Na="env",La="getSystemInfoSync",Ua=()=>{var i,c,d,m;let e={system:A.deviceInfo.system,platform:A.deviceInfo.platform.toLowerCase(),brand:A.deviceInfo.brand,pixelRatio:A.deviceInfo.pixelRatio,language:A.deviceInfo.lang,version:A.sdkInfo.jssdkVersion,appName:(i=A.hostInfo)==null?void 0:i.appName,SDKVersion:A.sdkInfo.nativeSDKVersion},t=(c=A.hostInfo)==null?void 0:c.version;t&&(e=z(V({},e),{version:t}));let r=(d=A.hostInfo)==null?void 0:d.appName;r&&(e=z(V({},e),{appName:r}));let n=(m=A.sdkInfo)==null?void 0:m.jssdkVersion;return n&&(e=z(V({},e),{SDKVersion:n})),e},Fa=Ie(La,{implement:Ua}),Ba=Ie(Na,{implement:()=>z(V({},A.hostInfo),{sdkInfo:A.sdkInfo,platform:A.platform,deviceInfo:A.deviceInfo})});so.registerCommand("API.env",Ba);so.registerCommand("API.getSystemInfoSync",Fa);Q("env",{version:"1.0.0"});Q("getSystemInfoSync",{version:"1.0.0"});$();Ge();_e();Ee();var Ma="onJoliboxShow",$a="onJoliboxHide",ja="onReady",Lr=ae(),Ur=Cn(ue),Nr=!0,qe=!0,At=0,xt=Ar;function Va(){let e=Date.now();if(e-At<100)return;At=e;let t=document.visibilityState==="visible";t!==Nr&&(Nr=t,xt.emit("visible",Nr))}function co(e){let t=Date.now();t-At<100||(At=t,e==="focus"&&!qe?qe=!0:e==="blur"&&qe&&(qe=!1),xt.emit("visible",qe))}document.addEventListener("visibilitychange",Va);window.addEventListener("focus",()=>co("focus"));window.addEventListener("blur",()=>co("blur"));var Ha=Ie(Ma,{paramsSchema:x.tuple(x.function()),implement(e){let t=Ur(e);xt.on("visible",r=>{r&&t()})}}),Ja=Ie($a,{paramsSchema:x.tuple(x.function()),implement(e){let t=Ur(e);xt.on("visible",r=>{!r&&t()})}}),Ka=Ie(ja,{paramsSchema:x.tuple(x.function()),implement(e){let t=Ur(e);Je.on("LifecycleEvent.onReady",r=>{t(r)})}});Lr.registerCommand("LifecycleSDK.onReady",Ka);Lr.registerCommand("LifecycleSDK.onJoliboxShow",Ha);Lr.registerCommand("LifecycleSDK.onJoliboxHide",Ja);Q("lifeCycle.onReady",{version:"1.0.0"});Q("lifeCycle.onJoliboxShow",{version:"1.0.0"});Q("lifeCycle.onJoliboxHide",{version:"1.0.0"});Ge();$();Ke();ee();var fo=hn(lo());var kt=ae(),Br=class{constructor(){this.httpClient=ge.create({baseUrl:A.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com"});this.getGameId=()=>A.mpId;this.getItem=t=>C(this,null,function*(){let{code:r,data:n,message:i}=yield this.httpClient.get(`/api/games/user-storage/${this.gameId}`,{query:{key:t}}),c=n==null?void 0:n.value,d=i;return r!=="SUCCESS"&&(c=yield this.gameStore.getItem(t),console.info("[SDK] cloud storage getItem failed, read from localstorage",c),d+="fallback to localstorage"),{code:r,message:d,data:c&&c!=="undefined"?c:null}});this.setItem=(t,r)=>C(this,null,function*(){let n=typeof r=="string"?r:String(r),{code:i,message:c}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}`,{data:{key:t,value:n}});return yield this.gameStore.setItem(t,n),{code:i,message:c}});this.removeItem=t=>C(this,null,function*(){yield this.gameStore.removeItem(t);let{code:r,message:n}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}/remove`,{data:{key:t}});return{code:r,message:n}});this.clear=()=>C(this,null,function*(){yield this.gameStore.clear();let{code:t,message:r}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}/clear`,{});return{code:t,message:r}});this.gameId=this.getGameId(),this.gameStore=fo.default.createInstance({name:this.gameId.length?this.gameId:"default"})}},Ct=new Br,Ga=se("getLocalStorage",{paramsSchema:x.tuple(x.string()),implement(e){return C(this,null,function*(){return yield Ct.getItem(e)})}});kt.registerCommand("StorageSDK.getItem",Ga);Q("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var qa=se("setStorage",{paramsSchema:x.tuple(x.string(),x.or(x.string(),x.boolean(),x.number())),implement(e,t){return C(this,null,function*(){return yield Ct.setItem(e,t)})}});kt.registerCommand("StorageSDK.setItem",qa);Q("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var Wa=se("removeStorage",{paramsSchema:x.tuple(x.string()),implement(e){return C(this,null,function*(){return yield Ct.removeItem(e)})}});kt.registerCommand("StorageSDK.removeItem",Wa);Q("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var Ya=se("clearStorage",{implement(){return C(this,null,function*(){return yield Ct.clear()})}});kt.registerCommand("StorageSDK.clear",Ya);Q("storage.clear",{version:"1.0.0"});var Bl=hn(mo());var Pt=class{constructor(t){this.track=t;this.adBreakIsShowing=!1;this.reportPageJumpOut=()=>{this.track("AdBreakJumpOut",{context:"AdsActionDetection"})};this.reportPageHide=()=>{this.track("AdBreakHide",{context:"AdsActionDetection"})};window.addEventListener("visibilitychange",()=>{document.hidden&&this.adBreakIsShowing&&this.reportPageHide()}),window.addEventListener("beforeunload",r=>{this.adBreakIsShowing&&this.reportPageJumpOut()})}};$();mr();var Ot=class{constructor(t,r,n,i){this.track=t;this.httpClient=r;this.checkNetwork=n;this.checkAdsDisplayPermission=t=>{if(!this.checkNetwork())return{reason:"NETWORK_NOT_OK"};let r=this.checkShouldBanInitial();if(r)return{reason:r};let n=this.checkShouldBanForSession(t);if(n)return{reason:n};let i=this.checkShouldBanHighFreq(t);if(i)return i;let c=this.checkShouldBanForTime(t);return c?{reason:c}:{reason:"ALLOWED"}};var g,I,O,D,k,P,H;let c=(g=i==null?void 0:i.maxAllowedAdsForTime)!=null?g:8,d=(I=i==null?void 0:i.banForTimeThreshold)!=null?I:6e4,m=(O=i==null?void 0:i.bannedReleaseTime)!=null?O:6e4,p=(D=i==null?void 0:i.maxAllowedAdsForSession)!=null?D:200,b=(k=i==null?void 0:i.banForSessionThreshold)!=null?k:6e5,v=(P=i==null?void 0:i.initialThreshold)!=null?P:2e3,S=(H=i==null?void 0:i.highFreqThreshold)!=null?H:2e3;this.checkShouldBanInitial=os(v),this.checkShouldBanHighFreq=is(S),this.checkShouldBanForTime=ns(c,d,m),this.checkShouldBanForSession=rs(p,b)}report(t,r){let n=r?{reason:t,count:r}:{reason:t};this.track("PreventAdsCheating",n),this.httpClient.post("/api/base/app-event",{data:{eventType:"PREVENT_ADS_CHEATING",adsInfo:n}})}},rs=(e,t)=>{let r=!1,n=[];return c=>{if(r)return"BANNED_FOR_SESSION";let d=Date.now();if(n=n.concat({timestamp:d,type:c}),n.length!==1&&(n.length>e&&(n=n.slice(-e)),n.length===e&&d-n[0].timestamp<=t))return r=!0,"BANNED_FOR_SESSION"}},ns=(e,t,r)=>{let n=null,i=v=>{n&&(window.clearTimeout(n),n=null),n=window.setTimeout(()=>{p.value=!1,n=null},v)},c="jolibox-sdk-ads-callbreak-timestamps",d="jolibox-sdk-ads-ban-for-time",m={_records:[],init(){var v;try{let S=JSON.parse((v=window.__joliboxLocalStorage__.getItem(c))!=null?v:"[]");Array.isArray(S)?this._records=S:this._records=[]}catch(S){this._records=[]}},get values(){return this._records},set values(v){try{window.__joliboxLocalStorage__.setItem(c,JSON.stringify(v))}catch(S){}this._records=v}},p={_record:!1,init(){var v;try{let S=JSON.parse((v=window.__joliboxLocalStorage__.getItem(d))!=null?v:"false");typeof S=="boolean"&&(this._record=S)}catch(S){this._record=!1}if(this._record){let S=m.values[m.values.length-1],g=S?Date.now()-S.timestamp:r;g<=r&&g>0?i(g):this._record=!1}},get value(){return this._record},set value(v){try{window.__joliboxLocalStorage__.setItem(d,JSON.stringify(v))}catch(S){}this._record=v}};return m.init(),p.init(),v=>{if(p.value)return"WAITING_BANNED_RELEASE";let S=Date.now();if(m.values=m.values.concat({timestamp:S,type:v}),m.values.length!==1&&(m.values.length>e&&(m.values=m.values.slice(-e)),m.values.length===e&&S-m.values[0].timestamp<=t))return p.value=!0,i(r),"BANNED_FOR_TIME"}},os=e=>{let t=Date.now();return()=>{if(Date.now()-t<=e)return"BLOCK_INITIAL"}},is=(e=2e3)=>{let t=0,r=null;return i=>{if(i==="reward"){if(r)return t+=1,{reason:"HOLDING_HIGH_FREQ",info:{count:t}};r=window.setTimeout(()=>{r&&(window.clearTimeout(r),r=0,t=0)},e)}}};ee();ee();var Dt=class{constructor(t){this.httpClient=t;this.configs=null;this.firstRun=!0;this.init()}init(){return C(this,null,function*(){try{this.configs=yield this.httpClient.get("/api/fe-configs/js-sdk/ads-channel-config")}catch(t){}})}shouldBypassCallingInterstitial(){var r,n;let t;if(!this.configs)this.init(),t=!this.firstRun;else{let i=(r=A.channel)!=null?r:"",c=this.configs[i],d=(n=c==null?void 0:c.interstitialRate)!=null?n:1;t=Math.random()<d}return this.firstRun=!1,t}};$();var Pe=new de,Nt=class{constructor(t,r,n){this.track=t;this.httpClient=r;this.checkNetwork=n;this.configured=!1;this.config={};this.getGameId=()=>A.mpId;this.getTestAdsMode=()=>A.testAdsMode;this.asyncLoad=()=>C(this,null,function*(){var d,m,p,b,v;let t="ca-pub-7171363994453626",r,n,i=window.encodeURIComponent(window.btoa((d=this.getGameId())!=null?d:"")),c=(m=this.getTestAdsMode())!=null?m:!1;try{let S=yield this.httpClient.get("/public/ads",{query:{objectId:i,testAdsMode:`${c}`}});t=(p=S.data)==null?void 0:p.clientId,r=(b=S.data)==null?void 0:b.channelId,n=(v=S.data)==null?void 0:v.unitId}catch(S){console.error("Failed to fetch client info",S)}this.clientId=t,this.channelId=r,this.unitId=n});this.asyncInit=t=>C(this,null,function*(){var i;if(typeof window=="undefined")return;yield this.asyncLoad();let r="google-adsense",n=(i=this.getTestAdsMode())!=null?i:!1;if(!document.getElementById(r)&&this.clientId){let c=document.createElement("script");c.id=r,c.async=!0,c.crossOrigin="anonymous",c.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`,n&&c.setAttribute("data-adbreak-test","on"),this.channelId&&c.setAttribute("data-ad-channel",this.channelId),document.head.appendChild(c),this.track("LoadAdsenseCompleted",null)}});this.push=(t={})=>{window.adsbygoogle.push(t)};this.wrapAdBreakParams=t=>{let r=!1,n=t.adBreakDone,i=d=>{var m;r=!0,this.adsActionDetection.adBreakIsShowing=!1,this.track("CallAdBreakDone",{breakType:d.breakType,breakName:(m=d.breakName)!=null?m:"",breakFormat:d.breakFormat,breakStatus:d.breakStatus}),n&&n(d)};if(t.adBreakDone=i,t.type==="reward"){let d=t.beforeReward,m=b=>()=>{this.track("CallShowAdFn",null),b()},p=b=>{r=!0,d&&d(m(b))};t.beforeReward=p,window.setTimeout(()=>{var b,v;r||(this.track("CallAdBreakTimeout",{type:t.type}),(v=t.adBreakDone)==null||v.call(t,{breakType:t.type,breakName:(b=t.name)!=null?b:"",breakFormat:"reward",breakStatus:"timeout"}))},5e3)}if((d=>d.type==="preroll")(t)){Pe.emit("isAdShowing",!0);let d=t.adBreakDone,m=p=>{Pe.emit("isAdShowing",!1),d&&d(p)};return z(V({},t),{adBreakDone:m})}else{let d=t.beforeAd,m=t.afterAd,p=()=>{var v;r=!0,Pe.emit("isAdShowing",!0),this.track("CallBeforeAd",{type:t.type,name:(v=t.name)!=null?v:""}),d&&d()},b=()=>{var v;r=!0,Pe.emit("isAdShowing",!1),this.track("CallAfterAd",{type:t.type,name:(v=t.name)!=null?v:""}),m&&m()};return z(V({},t),{beforeAd:p,afterAd:b})}};this.adConfig=t=>{let i=t,{onReady:r}=i,n=mn(i,["onReady"]);this.track("CallAdConfig",n),this.configured?console.warn("Ad config already set, skipping"):(this.configured=!0,this.push(t))};this.adBreak=t=>{var m,p,b,v,S,g;if(!this.getGameId()){console.warn("Game ID is not set, skip calling adBreak");return}if(t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){(m=t.adBreakDone)==null||m.call(t,{breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}let{reason:r,info:n}=this.antiCheating.checkAdsDisplayPermission(t.type==="reward"?"reward":"interstitial");switch(r){case"NETWORK_NOT_OK":case"BANNED_FOR_SESSION":(p=t.adBreakDone)==null||p.call(t,{breakType:t.type,breakName:r,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"}),this.antiCheating.report(r);return;case"BLOCK_INITIAL":case"BANNED_FOR_TIME":case"WAITING_BANNED_RELEASE":(b=t.adBreakDone)==null||b.call(t,{breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"}),this.antiCheating.report(r);return;case"HOLDING_HIGH_FREQ":(S=t.adBreakDone)==null||S.call(t,{breakFormat:t.type==="reward"?"reward":"interstitial",breakName:"",breakStatus:((v=n==null?void 0:n.count)!=null?v:0)>6?"other":"frequencyCapped",breakType:t.type}),n!=null&&n.count&&n.count!==0&&n.count%3===0&&this.antiCheating.report(r,n==null?void 0:n.count);return;default:break}let i=t.type,c;switch(i){case"preroll":c={type:i};break;case"start":case"pause":case"next":case"browse":case"reward":c={type:i,name:(g=t.name)!=null?g:""};break}this.adsActionDetection.adBreakIsShowing=!0,this.track("CallAdBreak",c);let d=this.wrapAdBreakParams(t);this.push(d),window.JoliTesterBridge&&console.log("joli-fullscreen-ad-show")};this.adUnit=t=>C(this,null,function*(){var g,I,O,D;if(this.track("CallAdUnit",{adFormat:(I=(g=t.adFormat)==null?void 0:g.toString())!=null?I:null,fullWidthResponsive:(O=t.fullWidthResponsive)!=null?O:null}),this.clientId||(yield this.asyncLoad()),document.querySelector("#jolibox-ads")){console.warn("Ad unit already set, skipping");return}let{el:r,slot:n,adFormat:i,fullWidthResponsive:c,style:d}=t,m;if(!r)throw new Error("targeting element is required");if(typeof r=="string"?m=document.querySelector(r):m=r,!m)throw new Error("targeting element not found");let p=n;if(p||(p=this.unitId),!p)throw new Error("slot is required");let b=typeof i=="object"&&Array.isArray(i)?i.join(", "):i,v=document.createElement("ins");if(v.className="adsbygoogle",v.id="jolibox-ads",v.style.display="block",v.setAttribute("data-ad-client",this.clientId),v.setAttribute("data-ad-slot",p),b&&v.setAttribute("data-ad-format",b),c&&v.setAttribute("data-full-width-responsive",c),d&&v.setAttribute("style",d),(D=this.getTestAdsMode())!=null?D:!1){let k=document.createElement("div");k.style.position="absolute",k.style.top="0",k.style.left="0",k.style.width="100%",k.style.height="100%",k.style.display="flex",k.style.justifyContent="center",k.style.alignItems="center",k.style.backgroundColor="rgba(0, 0, 0, 0.5)",k.style.color="white",k.innerHTML="Test Ad",v.style.position="relative",m.appendChild(v),v.appendChild(k)}else m.appendChild(v),new MutationObserver(P=>{P.forEach(H=>{if(H.type==="attributes"&&H.attributeName==="data-ad-status"){let F=v.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:F!=null?F:"null"})}})}).observe(v,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})});this.antiCheating=new Ot(t,r,n),this.adsActionDetection=new Pt(this.track),this.channelPolicy=new Dt(r)}init(t){this.track("CallAdsInit",null),typeof window!="undefined"&&(this.config=t!=null?t:{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}};Ee();$();Ke();var Mr=(e,t)=>{var r;window.dispatchEvent(new CustomEvent(e,{detail:t})),(r=window.parent)==null||r.postMessage({type:e,data:{detail:t}},"*")};ee();var po=A.testMode;function ho(){let e=new Map,t;return{registerRewardHandler(n,i){e.set(n,i)},handleReward(n,...i){return C(this,null,function*(){return yield n.reduce((d,m)=>C(this,null,function*(){let p=yield d;if(p===!0)return!0;po&&console.log(`handleReward ${m}`);let b=e.get(m),v=b?yield b(...i):p;return po&&console.log(`handleReward ${m} ${v}`),v}),Promise.resolve(!1))})},registerRewardsFetcher(n){return C(this,null,function*(){t=(...i)=>C(this,null,function*(){try{return yield n(...i)}catch(c){return console.error("getRewardOptions error:",c),["ADS"]}})})},getRewardsTypes(...n){return C(this,null,function*(){return t?yield t(...n):["ADS"]})}}}var as=()=>(e,t)=>e==="JOLI_COIN"&&t==="ADS"?-1:e==="ADS"&&t==="JOLI_COIN"?1:0,go=e=>{e.registerRewardsFetcher(t=>C(void 0,null,function*(){var c,d,m,p;let r=[],n=yield t.post("/api/games/unlock-options",{});return n.code!=="SUCCESS"?r:(Ut.emit(Lt,{options:((c=n.data)==null?void 0:c.unlockOptions)||[],userJoliCoin:((d=n.extra)==null?void 0:d.joliCoin)||{balance:0,enableAutoDeduct:!1}}),(((p=(m=n.data)==null?void 0:m.unlockOptions)==null?void 0:p.map(b=>b.type))||Array.from(r)).sort(as()))}))};$();var vo=e=>t=>C(void 0,null,function*(){return e.adBreak(t),!0});ee();$();var yo=(e,t)=>e.some(r=>r.type==="JOLI_COIN"&&r.joliCoinChoices.some(n=>{var i;return n.joliCoinQuantity<=((i=t==null?void 0:t.balance)!=null?i:0)&&!!(t!=null&&t.enableAutoDeduct)}));var bo=(e,{onUnlockSuccess:t,onUnlockFailed:r})=>{let n=null,i=null,c=null,d=()=>{if(c){n=Promise.resolve(c);return}n=new Promise(m=>{i=m})};return d(),Ut.on(Lt,m=>{c=m,i&&(i(m),i=null)}),()=>C(void 0,null,function*(){try{n||d();let m=yield n;if(!yo((m==null?void 0:m.options)||[],m==null?void 0:m.userJoliCoin))return r==null||r(),!1;let p=yield e.post("/api/joli-coin/unlock",{data:{type:"GAME_REWARD",reqId:`${fr()}-${A.mpType}-${Date.now()}`,gameInfo:{gameId:A.mpId}}});return p.code=="SUCCESS"?(t==null||t({quantity:p.data.quantity,balance:p.data.balance}),!0):(r==null||r(),!1)}catch(m){return console.error("JolicoinRewardHandler error:",m),r==null||r(),!1}})};var Oe=ho();go(Oe);var Lt="UNLOCK_OPTIONS_CHANGED",Ut=new de;var Ft=ae(),ss=ge.create(),Se=new Nt(fe,ss,()=>ge.getNetworkStatus());Oe.registerRewardHandler("ADS",vo(Se));Oe.registerRewardHandler("JOLI_COIN",bo(Se.httpClient,{onUnlockSuccess:e=>{Mr("JOLIBOX_CUSTOM_REWARDS_EVENT",{JOLI_COIN:e})}}));Pe.on("isAdShowing",e=>{Mr("JOLIBOX_ADS_EVENT",{isAdShowing:e})});Ft.registerCommand("AdsSDK.init",e=>{Se.init(e)});Ft.registerCommand("AdsSDK.adConfig",e=>{Se.adConfig(e)});Ft.registerCommand("AdsSDK.adBreak",e=>{e.type==="reward"?Oe.getRewardsTypes(Se.httpClient).then(t=>{Oe.handleReward(t,e)}):Se.adBreak(e)});Ft.registerCommand("AdsSDK.adUnit",e=>{Se.adUnit(e)});$();Ee();var So=-1,Mt=function(e){addEventListener("pageshow",function(t){t.persisted&&(So=t.timeStamp,e(t))},!0)},jr=function(){var e=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},$t=function(){var e=jr();return e&&e.activationStart||0},Ne=function(e,t){var r=jr(),n="navigate";return So>=0?n="back-forward-cache":r&&(document.prerendering||$t()>0?n="prerender":document.wasDiscarded?n="restore":r.type&&(n=r.type.replace(/_/g,"-"))),{name:e,value:t===void 0?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:n}},Ro=function(e,t,r){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var n=new PerformanceObserver(function(i){Promise.resolve().then(function(){t(i.getEntries())})});return n.observe(Object.assign({type:e,buffered:!0},r||{})),n}}catch(i){}},Le=function(e,t,r,n){var i,c;return function(d){t.value>=0&&(d||n)&&((c=t.value-(i||0))||i===void 0)&&(i=t.value,t.delta=c,t.rating=function(m,p){return m>p[1]?"poor":m>p[0]?"needs-improvement":"good"}(t.value,r),e(t))}},Ao=function(e){requestAnimationFrame(function(){return requestAnimationFrame(function(){return e()})})},xo=function(e){document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"&&e()})},ko=function(e){var t=!1;return function(){t||(e(),t=!0)}},De=-1,_o=function(){return document.visibilityState!=="hidden"||document.prerendering?1/0:0},Bt=function(e){document.visibilityState==="hidden"&&De>-1&&(De=e.type==="visibilitychange"?e.timeStamp:0,cs())},wo=function(){addEventListener("visibilitychange",Bt,!0),addEventListener("prerenderingchange",Bt,!0)},cs=function(){removeEventListener("visibilitychange",Bt,!0),removeEventListener("prerenderingchange",Bt,!0)},Co=function(){return De<0&&(De=_o(),wo(),Mt(function(){setTimeout(function(){De=_o(),wo()},0)})),{get firstHiddenTime(){return De}}},Vr=function(e){document.prerendering?addEventListener("prerenderingchange",function(){return e()},!0):e()},Eo=[1800,3e3],Po=function(e,t){t=t||{},Vr(function(){var r,n=Co(),i=Ne("FCP"),c=Ro("paint",function(d){d.forEach(function(m){m.name==="first-contentful-paint"&&(c.disconnect(),m.startTime<n.firstHiddenTime&&(i.value=Math.max(m.startTime-$t(),0),i.entries.push(m),r(!0)))})});c&&(r=Le(e,i,Eo,t.reportAllChanges),Mt(function(d){i=Ne("FCP"),r=Le(e,i,Eo,t.reportAllChanges),Ao(function(){i.value=performance.now()-d.timeStamp,r(!0)})}))})};var us=function(e){var t=self.requestIdleCallback||self.setTimeout,r=-1;return e=ko(e),document.visibilityState==="hidden"?e():(r=t(e),xo(e)),r};var Io=[2500,4e3],$r={},Oo=function(e,t){t=t||{},Vr(function(){var r,n=Co(),i=Ne("LCP"),c=function(p){t.reportAllChanges||(p=p.slice(-1)),p.forEach(function(b){b.startTime<n.firstHiddenTime&&(i.value=Math.max(b.startTime-$t(),0),i.entries=[b],r())})},d=Ro("largest-contentful-paint",c);if(d){r=Le(e,i,Io,t.reportAllChanges);var m=ko(function(){$r[i.id]||(c(d.takeRecords()),d.disconnect(),$r[i.id]=!0,r(!0))});["keydown","click"].forEach(function(p){addEventListener(p,function(){return us(m)},{once:!0,capture:!0})}),xo(m),Mt(function(p){i=Ne("LCP"),r=Le(e,i,Io,t.reportAllChanges),Ao(function(){i.value=performance.now()-p.timeStamp,$r[i.id]=!0,r(!0)})})}})},To=[800,1800],ls=function e(t){document.prerendering?Vr(function(){return e(t)}):document.readyState!=="complete"?addEventListener("load",function(){return e(t)},!0):setTimeout(t,0)},Do=function(e,t){t=t||{};var r=Ne("TTFB"),n=Le(e,r,To,t.reportAllChanges);ls(function(){var i=jr();i&&(r.value=Math.max(i.responseStart-$t(),0),r.entries=[i],n(!0),Mt(function(){r=Ne("TTFB",0),(n=Le(e,r,To,t.reportAllChanges))(!0)}))})};ee();function ds(){Po(e=>{fe("GameFCP",{value:e.value,rating:e.rating,navigationType:e.navigationType})}),Oo(e=>{fe("GameLCP",{value:e.value,rating:e.rating,navigationType:e.navigationType})}),Do(e=>{fe("GameTTFB",{value:e.value,rating:e.rating,navigationType:e.navigationType})})}function fs(){Je.on("onDocumentReady",e=>{Je.emit("LifecycleEvent.onReady",{isLogin:!1}),A.mpType==="game"&&le.start(Date.now()-e)})}function No(){fs(),ds()}No();
1
+ var Ni=Object.create;var Qt=Object.defineProperty,Li=Object.defineProperties,Ui=Object.getOwnPropertyDescriptor,Fi=Object.getOwnPropertyDescriptors,Bi=Object.getOwnPropertyNames,Qe=Object.getOwnPropertySymbols,Mi=Object.getPrototypeOf,Xt=Object.prototype.hasOwnProperty,fn=Object.prototype.propertyIsEnumerable;var dn=(e,t,r)=>t in e?Qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,V=(e,t)=>{for(var r in t||(t={}))Xt.call(t,r)&&dn(e,r,t[r]);if(Qe)for(var r of Qe(t))fn.call(t,r)&&dn(e,r,t[r]);return e},z=(e,t)=>Li(e,Fi(t));var Me=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var mn=(e,t)=>{var r={};for(var n in e)Xt.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Qe)for(var n of Qe(e))t.indexOf(n)<0&&fn.call(e,n)&&(r[n]=e[n]);return r};var K=(e,t)=>()=>(e&&(t=e(e=0)),t);var pn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var $i=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Bi(t))!Xt.call(e,i)&&i!==r&&Qt(e,i,{get:()=>t[i],enumerable:!(n=Ui(t,i))||n.enumerable});return e};var hn=(e,t,r)=>(r=e!=null?Ni(Mi(e)):{},$i(t||!e||!e.__esModule?Qt(r,"default",{value:e,enumerable:!0}):r,e));var C=(e,t,r)=>new Promise((n,i)=>{var c=p=>{try{m(r.next(p))}catch(b){i(b)}},d=p=>{try{m(r.throw(p))}catch(b){i(b)}},m=p=>p.done?n(p.value):Promise.resolve(p.value).then(c,d);m((r=r.apply(e,t)).next())});function Yi(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ar(e){return typeof e=="string"}function wn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function En(e){return typeof e=="object"&&Array.isArray(e)}function zi(e){return typeof e=="undefined"}function Qi(e){return zi(e)||e===null}function Xi(e){return typeof e=="function"}function In(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function Tn(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(i,c){for(let d in c)if(Object.prototype.hasOwnProperty.call(c,d)){let m=i[d],p=c[d],b=r(m,p,d,i,c);b!==void 0?i[d]=b:yn(p)&&yn(m)?i[d]=n(ir({},m),p):Array.isArray(p)&&Array.isArray(m)?i[d]=[...m,...p]:i[d]=p}return i}return n(e,t)}function yn(e){return e&&typeof e=="object"&&e.constructor===Object}function Sn(e,t){if(Array.isArray(e))return e.concat(t)}function Ve(e,t,r={}){let n=null,i,c,d,{leading:m=!1,trailing:p=!0}=r,b=()=>(d=e.apply(c,i),i=void 0,c=void 0,d),g=function(...S){i=S,c=this;let v=m&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,p&&!v&&b()},t),v)return b()};return g.cancel=()=>{n&&clearTimeout(n),n=null,i=c=void 0},g.flush=()=>{if(n)return clearTimeout(n),n=null,b()},g}function ta(e,t){return(...r)=>t(e,...r)}function Cn(e){return t=>ta(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new ea(`${i}`))}})}function $e(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function et(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((i,c)=>(i[c]=String(n[c]),i),{})}return e[r]})}function aa(e){let t=e.location?et(e.location,bn):null,r=e.target?et(e.target,bn):null;return et(Gi(ir({},e),{location:t,target:r}),oa)}function dr(e){let t=e.events.map(n=>aa(n)),r=et(e.device,ia);return[e.protocolVersion,t,r,e.project]}function mr(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}function ga(e){return new Promise(t=>Nn(e)(t))}function Nn(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function va(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(c.fire,c)}},c=new je(i);return c.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function ba(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)_a(e[n],t[n])}function _a(e,t){if(ar(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Xi(t)){try{if(e instanceof t)return}catch(r){}if(!Qi(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function wa(){return typeof globalThis!="undefined"?globalThis[Ln]:void 0}function Ea(e){typeof globalThis!="undefined"&&(globalThis[Ln]=e)}function ae(){let e=wa();if(e)return e;let t=new tt,r=new nr,n={registerCommand(i,c,d){t.registerCommand({id:i,handler:c,metadata:d})},executeCommand(i,...c){return r.executeCommand(i,...c)},excuteCommandSync(i,...c){return r.executeCommandThowErr(i,...c)}};return Ea(n),n}var or,ji,Vi,Hi,gn,Ji,Ki,vn,ir,Gi,qi,_n,Wi,Zi,sr,cr,Rn,An,ea,kn,xn,rt,ur,ce,Pn,ra,lr,He,ke,na,bn,oa,ia,fr,Xe,sa,ca,ua,On,pr,la,da,fa,Dn,er,G,ma,pa,Ze,je,de,rr,ha,Zt,ya,Je,tt,nr,Ln,$=K(()=>{"use strict";or=Object.defineProperty,ji=Object.defineProperties,Vi=Object.getOwnPropertyDescriptor,Hi=Object.getOwnPropertyDescriptors,gn=Object.getOwnPropertySymbols,Ji=Object.prototype.hasOwnProperty,Ki=Object.prototype.propertyIsEnumerable,vn=(e,t,r)=>t in e?or(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ir=(e,t)=>{for(var r in t||(t={}))Ji.call(t,r)&&vn(e,r,t[r]);if(gn)for(var r of gn(t))Ki.call(t,r)&&vn(e,r,t[r]);return e},Gi=(e,t)=>ji(e,Hi(t)),qi=(e,t)=>{for(var r in t)or(e,r,{get:t[r],enumerable:!0})},_n=(e,t,r,n)=>{for(var i=n>1?void 0:n?Vi(t,r):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(i=(n?d(t,r,i):d(i))||i);return n&&i&&or(t,r,i),i},Wi=(e,t,r)=>new Promise((n,i)=>{var c=p=>{try{m(r.next(p))}catch(b){i(b)}},d=p=>{try{m(r.throw(p))}catch(b){i(b)}},m=p=>p.done?n(p.value):Promise.resolve(p.value).then(c,d);m((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}Zi=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Zi||{}),sr=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},cr=class extends sr{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Rn=class extends sr{constructor(){super(...arguments),this.kind="USER_ERROR"}},An=class extends Rn{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},ea=class extends Rn{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},kn=class extends cr{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},xn=class extends cr{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},rt=class extends sr{constructor(e,t,r,n,i){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),i&&(this.priority=i)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},ur=class extends cr{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};ce={log:$e("log"),warn:$e("warn"),info:$e("info"),error:$e("error"),debug:$e("debug")};Object.assign(globalThis,{logger:ce});Pn=Symbol.for("Jolibox.canIUseMap"),ra={};globalThis[Pn]=ra;lr={get config(){return globalThis[Pn]}},He=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(He||{}),ke=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ke||{}),na=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(na||{}),bn=["name","params"],oa=["name","type","location","target","extra","timestamp","userId"],ia=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];fr=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});mr();Xe={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},sa=()=>Xe.isiOS?"iOS":Xe.isAndroid?"Android":Xe.isMac?"Mac":Xe.isFacebook?"Facebook":"PC",ca="device_id",ua="advertising_id",On=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,fr()),window.__joliboxLocalStorage__.getItem(e)),pr=()=>new URLSearchParams(window.location.search).get("deviceId")||On(ca),la=()=>On(ua),da=e=>e.charAt(0).toUpperCase()+e.slice(1),fa=()=>{var e;let t=new URLSearchParams(window.location.search);return da((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Dn=e=>{let t="JoliboxWebSDK",r=sa(),n=navigator.language,i=pr(),c=la();return`${t} (${fa()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${i} adid/${c} version/${e||""}`},er=class tr{constructor(t){this.element=t,this.next=tr.Undefined,this.prev=tr.Undefined}};er.Undefined=new er(void 0);G=er,ma=class{constructor(){this._first=G.Undefined,this._last=G.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===G.Undefined}clear(){let e=this._first;for(;e!==G.Undefined;){let t=e.next;e.prev=G.Undefined,e.next=G.Undefined,e=t}this._first=G.Undefined,this._last=G.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new G(e);if(this._first===G.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==G.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==G.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==G.Undefined&&e.next!==G.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===G.Undefined&&e.next===G.Undefined?(this._first=G.Undefined,this._last=G.Undefined):e.next===G.Undefined?(this._last=this._last.prev,this._last.next=G.Undefined):e.prev===G.Undefined&&(this._first=this._first.next,this._first.prev=G.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==G.Undefined;)yield e.element,e=e.next}},pa=0,Ze=class{constructor(e){this.value=e,this.id=pa++}},je=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof Ze&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,i,c,d,m,p;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let b=new Ze(t);this._listeners?this._listeners instanceof Ze?this._listeners=[this._listeners,b]:this._listeners.push(b):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=b,(d=(c=this.options)==null?void 0:c.onDidFirstListener)==null||d.call(c,this)),(p=(m=this.options)==null?void 0:m.onDidAddListener)==null||p.call(m,this),this._size++}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof Ze?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},de=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new je,i=d=>t(...d.args);this.listerHandlerMap.set(t,i),n.event(i),this.listeners.set(e,n);let c=this.cachedEventQueue.get(e);if(c)for(;c.size>0;)n.fire(ir({event:e},c.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new ma,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},rr={};qi(rr,{None:()=>ha,filter:()=>va,once:()=>Nn,toPromise:()=>ga});ha=()=>{console.log("[Jolibox SDK] None Event")};Zt=Symbol.for("Jolibox.hostEmitter"),ya=()=>{let e=new de;return globalThis[Zt]||(globalThis[Zt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[Zt]},Je=ya();tt=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new je,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return ba(i,r),n(...i)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};tt=_n([In],tt);nr=class{constructor(){this._onWillExecuteCommand=new je,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new je,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new tt,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Yi(3e4)),this._starActivation}executeCommand(e,...t){return Wi(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),rr.toPromise(rr.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};nr=_n([In],nr);Ln=Symbol.for("Jolibox.commands")});function ue(e,t={}){hr.emit("ERROR_REPORT",{error:e,options:t})}var hr,we,_e=K(()=>{"use strict";$();$();hr=new de,we=new de;ue.debounce=Ve(ue,50,{leading:!0})});var gr,Ia,Un,Fn,Bn=K(()=>{"use strict";$();_e();gr=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch(i){return{}}},Ia=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Un=e=>{var t;try{let i=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(i!=null&&i.length){let[c,d,m]=i;return{headerJson:gr(c),payloadJson:gr(d),signature:gr(m)}}else throw"joli_source is missing"}catch(r){return ue(new kn(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},Fn=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=Ia(e),c=r[2];return`${n}.${i}.${c}`}return t}});var Ta,nt,Mn,vr=K(()=>{"use strict";$();Ta="1.1.13-beta.11",nt=()=>Ta,Mn=()=>{let e=nt();return`${Dn(e)}`}});var Sa,$n,yr,jn,Z,Ra,A,ee=K(()=>{"use strict";$();Bn();vr();$();Sa={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:pr(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:nt()},schema:window.location.href,platform:"h5"},yr=($n=globalThis.joliboxJSCore)==null?void 0:$n.env,Z=Object.assign({},(jn=yr==null?void 0:yr())!=null?jn:Sa),Ra=()=>{var v,I,O,D,x,P,H,F,te;let{payloadJson:e,headerJson:t,signature:r}=Z.schema.length?Un(Z.schema):{},n=`${Z.deviceInfo.did}-${new Date().getTime()}`,c=new URL(Z.schema.length?Z.schema:window.location.href).searchParams,d=(O=(I=(v=c.get("mpId"))!=null?v:c.get("appId"))!=null?I:c.get("gameId"))!=null?O:"",m=(P=(x=(D=Z.clientSessionId)!=null?D:e==null?void 0:e.sessionId)!=null?x:c.get("sessionId"))!=null?P:n,p=!!((H=e==null?void 0:e.testAdsMode)!=null?H:c.get("testAdsMode")==="true"),b=(te=(F=e==null?void 0:e.joliboxEnv)!=null?F:c.get("joliboxEnv"))!=null?te:"production",g=b==="staging",S=t==null?void 0:t.channel;return{get testMode(){return g},get testAdsMode(){return p},get joliboxEnv(){return b},get joliSource(){var B;return(B=c.get("joliSource"))!=null?B:null},get mpId(){var B;return(B=d!=null?d:e==null?void 0:e.id)!=null?B:""},get mpVersion(){var B;return(B=t==null?void 0:t.ver)!=null?B:nt()},get mpType(){var B,T;return(T=(B=t==null?void 0:t.__mpType)!=null?B:e==null?void 0:e.__mpType)!=null?T:"game"},get platform(){var B;return(B=Z.platform)!=null?B:Z.deviceInfo.platform},get deviceInfo(){return Z.deviceInfo},get sdkInfo(){return Z.sdkInfo},get hostInfo(){return Z.hostInfo},get hostUserInfo(){return Z.hostUserInfo},get sessionId(){var B,T;return(T=(B=Z.clientSessionId)!=null?B:m)!=null?T:n},get channel(){return S},get webviewId(){var B;return(B=Z.webviewId)!=null?B:-1},get shouldInterupt(){return e==null?void 0:e.__shouldInterupt},get from(){return e==null?void 0:e.__from},get baseApiHost(){return g?"https://stg-api.jolibox.com":"https://api.jolibox.com"},onEnvConfigChanged:B=>{Tn(Z,B,Sn)},encodeJoliSourceQuery:B=>{var T,U;return t&&r?Fn(V(V({},e),B),(T=c.get("joliSource"))!=null?T:""):(U=c.get("joliSource"))!=null?U:""}}},A=Ra()});var br,Hn,Aa,ka,Vn,xa,Jn=K(()=>{"use strict";$();_e();ee();$();br=!1,Hn=(e,t)=>e==null?!1:t in e,Aa=e=>Hn(e,"kind"),ka=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},Vn=(e,t={},r)=>{var c,d,m;let n={user_id:(d=(c=A.hostUserInfo)==null?void 0:c.uid)!=null?d:"",device_id:(m=A.deviceInfo.did)!=null?m:"",timestamp:Date.now(),tag:ka(e.name)},i=z(V({},n),{env:t.environment,isFromUser:r});r?we.emit("GLOBAL_USER_ERROR",e,i):we.emit("GLOBAL_ERROR",e,i)},xa=e=>Hn(e,"kind")&&e.kind==="USER_ERROR";hr.on("ERROR_REPORT",({error:e,options:t})=>{if(br)return;br=!0;let r=Aa(e)&&e.raw?e.raw:e;try{let n=xa(e);Vn(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),c=new ur(`${i}, origin error: ${r.message}`);ce.error(c),Vn(new ur(c.message),{environment:t.environment},!1)}finally{br=!1}})});var _r,wr=K(()=>{"use strict";_e();$();_e();_r=e=>new An(e)});function Kn(e,t){let r=(n,i,c)=>{let d=z(V({tag:n},t),{extra:V({},i)});n=="globalJsError"?ue(new xn(JSON.stringify(d))):e("systemLog",d,c)};return r.debounce=Ve(r,500,{leading:!0}),r}function Gn(e){let t=(r,n,i)=>{var m;let c=(m=i&&JSON.stringify(i))!=null?m:0,d={speed_value_type:r,total_duration:n};c&&Object.assign(d,{extra:c}),e("joliboxSpeedAnalysis",d)};return t.debounce=Ve(t,500,{leading:!0}),t}var qn=K(()=>{"use strict";$();$();_e()});function Wn(e,t){let r=Kn(e,t),n=Gn(r);return{track:r,trackPerformance:n}}var Yn=K(()=>{"use strict";qn()});var Er=K(()=>{"use strict"});var ot,zn=K(()=>{"use strict";ee();$();$();ot=class{constructor(){this.deviceInfo=null;this.samplesConfig=null;this.fetchSamplesConfig()}fetchSamplesConfig(){return C(this,null,function*(){let r=`${A.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/samples-config`,n=yield(yield fetch(r)).json();this.samplesConfig=n})}checkIsSampled(t){if(!this.samplesConfig)return!1;let{samples:r}=this.samplesConfig;for(let[n,i]of Object.entries(r))if(i.includes(t.name))return Math.floor(Math.random()*101)<parseFloat(n);return!1}getDevice(){var n,i,c,d,m;let{nativeSDKVersion:t,jssdkVersion:r}=A.sdkInfo;return{platform:1e3,os:A.deviceInfo.platform,appVersion:(n=t!=null?t:r)!=null?n:"1.0.0",appId:(c=(i=A.hostInfo)==null?void 0:i.aid)!=null?c:"1",model:(d=A.deviceInfo.model)!=null?d:"UnknownModel",brand:(m=A.deviceInfo.brand)!=null?m:"UnknownBrand",uuid:A.deviceInfo.did,jsSdkVersion:r,extra:{}}}getLocation(){let t=new URLSearchParams(window.location.search),r={};return t.forEach((n,i)=>{r[i]=n}),{name:"GamePage",params:r}}trackEvent(t,r,n){return C(this,null,function*(){if(this.checkIsSampled(t))return;let i=t.location?t.location:yield this.getLocation(),c=t.target||null,d=t.extra||null;this.deviceInfo||(this.deviceInfo=yield this.getDevice());let m=this.deviceInfo,b={protocolVersion:"1.0.0",events:[z(V({},t),{location:i,target:c,extra:d,timestamp:Date.now(),userId:null})],device:m,project:r};try{n?yield this.doReport(dr(b),n):yield this.doReport(dr(b))}catch(g){ce.log("[Jolibox SDK] report API error",g)}})}}});var Ir=K(()=>{"use strict";Yn();Er();zn()});var Tr,Qn,he,it,ge,Ke=K(()=>{"use strict";vr();ee();Tr=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};(Qn=AbortSignal.timeout)!=null||(AbortSignal.timeout=Tr);he=class e{constructor(){this.httpClients=new WeakSet;this.networkRequests=[];this.maxRequestsToTrack=20}static getInstance(){return e._instance||(e._instance=new e),e._instance}create(t){let r=new it(t);return e.getInstance().httpClients.add(r),r}recordNetworkRequest(t){this.networkRequests.push(t),this.networkRequests.length>this.maxRequestsToTrack&&this.networkRequests.shift()}getNetworkStatus(){return this.networkRequests.length===0?!0:this.networkRequests.filter(n=>n).length/this.networkRequests.length>=.6}},it=class{constructor(t){this.xua=Mn();this.getJoliSource=()=>A.joliSource;var n;let r=A.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com";this.baseUrl=(n=t==null?void 0:t.baseUrl)!=null?n:r}get(t,r){return C(this,null,function*(){try{let{query:n,timeout:i}=r!=null?r:{},{headers:c}=r!=null?r:{},d=n?new URLSearchParams(n):null,m=d==null?void 0:d.toString(),p=`${this.baseUrl}${t}${m?`?${m}`:""}`,b=this.xua,g=this.getJoliSource();c=Object.assign({},c!=null?c:{},b?{"x-user-agent":b}:{},g?{"x-joli-source":g}:{});let S=yield fetch(p,{method:"GET",headers:c,credentials:"include",signal:Tr(i!=null?i:3e4)});return he.getInstance().recordNetworkRequest(!0),yield S.json()}catch(n){throw he.getInstance().recordNetworkRequest(!1),n}})}post(t,r){return C(this,null,function*(){try{let{data:n,query:i,timeout:c}=r!=null?r:{},{headers:d}=r!=null?r:{},m=i?new URLSearchParams(i):null,p=m==null?void 0:m.toString(),b=`${this.baseUrl}${t}${p?`?${p}`:""}`,g=this.xua,S=this.getJoliSource();d=Object.assign({},d!=null?d:{},{"Content-Type":"application/json"},g?{"x-user-agent":g}:{},S?{"x-joli-source":S}:{});let v=yield fetch(b,{method:"POST",headers:d,body:JSON.stringify(n),signal:Tr(c!=null?c:3e4),credentials:"include"});he.getInstance().recordNetworkRequest(!0);let I=v.headers.get("content-type");if(I!=null&&I.includes("application/octet-stream"))try{return v.blob()}catch(O){return yield v.arrayBuffer()}if(I!=null&&I.includes("multipart/form-data")||I!=null&&I.includes("application/x-www-form-urlencoded"))try{return v.formData()}catch(O){return yield v.text()}if(I!=null&&I.includes("application/json"))try{return yield v.json()}catch(O){return yield v.text()}return v}catch(n){throw he.getInstance().recordNetworkRequest(!1),n}})}put(t,r){return C(this,null,function*(){try{let{data:n,query:i,timeout:c}=r!=null?r:{},{headers:d}=r!=null?r:{},m=i?new URLSearchParams(i):null,p=m==null?void 0:m.toString(),b=`${this.baseUrl}${t}${p?`?${p}`:""}`,g=this.xua,S=this.getJoliSource();d=Object.assign({},d!=null?d:{},{"Content-Type":"application/json"},g?{"x-user-agent":g}:{},S?{"x-joli-source":S}:{});let v=yield fetch(b,{method:"PUT",headers:d,credentials:"include",body:JSON.stringify(n!=null?n:{})});if(!v.ok)throw he.getInstance().recordNetworkRequest(!1),new Error(`HTTP error! status: ${v.status}`);return he.getInstance().recordNetworkRequest(!0),yield v.json()}catch(n){throw console.error("Error:",n),n}})}};window.JoliboxHttpClient=it;ge=he.getInstance()});var Sr,at,Rr=K(()=>{"use strict";ee();Ir();Ke();Sr=class extends ot{constructor(){super(...arguments);this.hostToApiMap={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}};this.httpClient=ge.create({baseUrl:this.apiBaseURL})}get apiBaseURL(){var n,i;let r=(n=this.hostToApiMap[window.location.host])!=null?n:this.hostToApiMap.default;return(i=A.testMode)!=null&&i?r.test:r.prod}doReport(r){this.httpClient.post("/report",{data:r,timeout:5e3}).catch(n=>{console.info("report error",n)})}},at=new Sr});var Ca,Xn=K(()=>{"use strict";Jn();$();wr();$();Rr();ee();Ca=(e,t)=>{var i,c,d;let r={message:t.message,stack:(i=t.stack)!=null?i:"",errorType:t.name,source:0},n={name:e,type:He.ErrorTrace,location:null,target:null,extra:r,timestamp:Date.now(),userId:(d=(c=A.hostUserInfo)==null?void 0:c.uid)!=null?d:null};at.trackEvent(n,ke.WebSDK)};we.on("GLOBAL_ERROR",(e,t)=>{Ca(t.tag,e)});we.on("GLOBAL_USER_ERROR",(e,t)=>{ce.log("UserError",e,t)})});var st,Zn=K(()=>{"use strict";st=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,i,c=!1,d=0,m=()=>{if(!c)return;let I=Date.now(),O=I-r;O>=this.interval&&(this.visible&&(d+=O,t(d)),r=I),n=requestAnimationFrame(m)},p=()=>{g(),r=Date.now(),i=window.setInterval(()=>{if(!c)return;let I=Date.now();I-r>=this.interval&&(r=I)},this.interval)},b=()=>{S(),r=Date.now(),n=requestAnimationFrame(m)},g=()=>{n&&(cancelAnimationFrame(n),n=0)},S=()=>{i&&(clearInterval(i),i=0)};this.eventEmitter.on("visible",I=>{c&&(console.log("visible",I),I?b():p())});let v=this.visible;return{start(){c||(c=!0,v?b():p())},stop(){c=!1,g(),S()}}}}});var ct,eo=K(()=>{"use strict";ee();Zn();Ke();ct=class extends st{constructor(r,n,i){super(n,i);this.httpClient=ge.create();this.gameId=A.mpId,this.sessionId=A.sessionId,this.track=r}reporter(r){return C(this,null,function*(){let{event:n,params:i}=r;yield this.httpClient.post("/api/base/app-event",{data:{eventType:n,gameInfo:V({gameId:this.gameId,sessionId:this.sessionId},i)}})})}tracker(r,n=null){this.track(r,n)}}});var to,Pa,fe,Oa,Ar,le,Ee=K(()=>{"use strict";Xn();$();$();Ir();Rr();eo();ee();Er();to=ae(),Pa={type:ke.WebSDK,platform:"h5",jssdk_version:A.sdkInfo.jssdkVersion,mp_id:A.mpId,mp_version:A.mpVersion},{track:fe,trackPerformance:Oa}=Wn((...e)=>{var d,m,p,b;let[,t]=e,r=t,n=wn(r.extra)?r.extra:ar(r.extra)?JSON.parse(r.extra):{},i=z(V({},n),{mp_id:(d=r.mp_id)!=null?d:"",mp_version:(m=r.mp_version)!=null?m:""}),c={name:t.tag,type:He.System,location:null,target:null,extra:i,timestamp:Date.now(),userId:(b=(p=A.hostUserInfo)==null?void 0:p.uid)!=null?b:null};at.trackEvent(c,ke.WebSDK)},Pa);to.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{Oa(e,t,r)});to.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{fe(e,t)});Ar=new de,le=new ct(fe,Ar)});function ro(e){let t=lr.config[e];return t||(t={},lr.config[e]=t),(r,n)=>{if(t[r]){ce.warn(`[can i use] ${r} already registered`);return}t[r]=V({},n)}}var no=K(()=>{"use strict";$()});function kr(e){oo=e}function ut(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>ut(t)):Object.keys(e).reduce((t,r)=>(t[r]=ut(e[r]),t),{})}function ve(e){return typeof e=="number"}function xr(e){let t=Cr(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Cr(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var oo,Y,lt,dt,ft,mt,xe,pt,ht,gt,vt,yt,bt,_t,wt,Et,It,Tt,St,Pr=K(()=>{"use strict";oo=!1;Y=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(oo)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${xr(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return ut(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:ut(this._default)}optional(){return this._optional=!0,this}};lt=class extends Y{validate(t){return this._optional&&t===void 0?!0:ve(t)?ve(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):ve(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):ve(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},dt=class extends Y{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},ft=class extends Y{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(ve(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(ve(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},mt=class extends Y{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},xe=class extends Y{validate(t){return!0}},pt=class extends Y{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},ht=class extends Y{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},gt=class extends Y{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},vt=class extends Y{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(n=>JSON.stringify(n)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${xr(t)}`)}return!0}},yt=class extends Y{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(ve(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(ve(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(ve(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let n=this._item;if(!n)return!0;let i=!0;if(r.forEach((c,d)=>{if(n.path=`${this.path}[${d}]`,n.errors=this.errors,c===void 0&&n.hasDefault){r[d]=n.defaultValue;return}n.validate(c)||(n.hasFallback?r[d]=n.fallbackValue:i=!1)}),this._uniqueItems){let c=new Map;for(let d in r)c.has(r[d])?i=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${c.get(r[d])}] and ${this.path}[${d}] are identical)`):c.set(r[d],d)}return i}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},bt=class extends Y{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Cr(r)!=="object")return this.fail({expect:"object",actual:r});let i=r,c=this._value;c.errors=this.errors;let d=!0;for(let m in i){let p=i[m];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(m)?c.path=`${this.path}.${m}`:c.path=`${this.path}["${m}"]`,!(p===void 0&&c._optional)){if(p===void 0&&c.hasDefault){i[m]=c.defaultValue;continue}c.validate(p)||(c.hasFallback?i[m]=c.fallbackValue:d=!1)}}return d}},_t=class extends Y{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Cr(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,i=!0;for(let c in this._object){let d=n[c],m=this._object[c];if(m.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(c)?m.path=`${this.path}.${c}`:m.path=`${this.path}["${c}"]`,!(m._optional&&d===void 0)){if(d===void 0&&m.hasDefault){n[c]=m.defaultValue;continue}m.validate(d)||(m.hasFallback?n[c]=m.fallbackValue:i=!1)}}return i}},wt=class extends Y{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:xr(this.value),actual:r}):!0}},Et=class extends Y{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,i=this._items.length;for(let c=0;c<i;c++){let d=this._items[c];if(d.errors=[],d.path=this.path,!d.validate(t))r.push(d.errors.join("; "));else if(!n){n=!0;break}}if(!n){let c=r.join(`
2
+ or `);this.errors.push(c)}return n}},It=class extends Y{constructor(...t){super(),this._items=t;let r=0,n=t.length-1;for(;n>=0;n--){let i=t[n];if(i._optional||i.hasDefault)r+=1;else break}this._minItems=t.length-r}validate(t){if(t===void 0&&this._optional)return!0;if(!Array.isArray(t))return this.fail({expect:"array",actual:t});if(t.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let r=!0;return this._items.forEach((n,i)=>{if(n.path=`${this.path}[${i}]`,n.errors=this.errors,t[i]===void 0&&n.hasDefault){t[i]=n.defaultValue;return}n.validate(t[i])||(n.hasFallback?t[i]=n._fallback:r=!1)}),r}},Tt=class extends Y{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},St=class extends Y{constructor(t){super(),this._ctor=t}validate(t){return t===void 0&&this._optional||t instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:t})}}});function Or(e,t,r="param"){if(e.errors=[],e.path=r,kr(!0),!e.validate(t)){let n=e.errors.join(`
3
+ `);throw e.errors.length=0,kr(!1),new TypeError(n)}}var k,Dr=K(()=>{"use strict";Pr();Pr();k={object(e){return new _t(e)},array(e){return new yt(e)},tuple(...e){return new It(...e)},literal(e){return new wt(e)},or(...e){return new Et(...e)},symbol(){return new mt},record(e){return new bt(e)},function(){return new gt},boolean(){return new dt},string(){return new ft},number(){return new lt},undefined(){return new pt},null(){return new ht},unknown(){return new xe},any(){return new xe},as(){return new xe},arraybuffer(){return new Tt},enum(...e){return new vt(...e)},typedarray(e){return new St(e)}}});var Rt,io,ao=K(()=>{"use strict";$();_e();Dr();wr();Rt=1,io=e=>{function t(n,i){return(...c)=>{var S,v,I,O;let d=Date.now(),m={method:n,trace_id:Rt};Rt+=1;let p="SUCCESS",b=`${n}:ok`,g=0;try{if(i.paramsSchema)try{Or(i.paramsSchema,c,"params")}catch(H){throw _r(`${n}:fail ${H.message}`)}let D=i.implement(...c),x=D,P=`${n}:ok`;if(D&&"code"in D){let{code:H,data:F,message:te}=D;p=H,x=F,P=te}return{code:p,message:P,data:x}}catch(D){let x=D;g=(v=(S=x.code)!=null?S:x.errNo)!=null?v:2e3,p="FAILURE";let P=(O=(I=x.message)!=null?I:x.errMsg)!=null?O:`${D}`;return b=`${n}:${p} ${P.replace(/^\S+:(fail|cancel)\s?/,"")}`,ue(new rt(b,g)),{code:p,message:b}}finally{let D=Date.now()-d;e("apiInvoked",z(V({},m),{duration:D,status:p}))}}}function r(n,i){return(...c)=>C(this,null,function*(){var v,I,O,D;let d=En(c)?c:[c],m=Date.now(),p={method:n,trace_id:Rt};Rt+=1;let b=`${n}:ok`,g="SUCCESS",S={code:g,message:b};try{if(i.paramsSchema)try{Or(i.paramsSchema,d,"params")}catch(H){throw _r(H.message)}let P=yield i.implement(...d);if(P&&"code"in P){let{code:H,data:F,message:te}=P;g=H,b=te,P=F}return Object.assign(S,{code:g,message:b,data:P}),S}catch(x){let P=x,H=(I=(v=P.code)!=null?v:P.errNo)!=null?I:2e3;g="FAILURE";let F=(D=(O=P.message)!=null?O:P.errMsg)!=null?D:`${x}`,te=`${n}:${g} ${F.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(S,{code:g,message:te}),ue(new rt(te,H)),S}finally{let x=Date.now()-m;e("apiInvoked",z(V({},p),{duration:x,status:g}))}})}return{createAPI:r,createSyncAPI:t}}});var se,Ie,Q,Ge=K(()=>{"use strict";no();Ee();ao();Dr();({createAPI:se,createSyncAPI:Ie}=io(fe)),Q=ro("h5")});var lo=pn((uo,Fr)=>{(function(e){if(typeof uo=="object"&&typeof Fr!="undefined")Fr.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t=this,t.localforage=e()}})(function(){var e,t,r;return function n(i,c,d){function m(g,S){if(!c[g]){if(!i[g]){var v=typeof Me=="function"&&Me;if(!S&&v)return v(g,!0);if(p)return p(g,!0);var I=new Error("Cannot find module '"+g+"'");throw I.code="MODULE_NOT_FOUND",I}var O=c[g]={exports:{}};i[g][0].call(O.exports,function(D){var x=i[g][1][D];return m(x||D)},O,O.exports,n,i,c,d)}return c[g].exports}for(var p=typeof Me=="function"&&Me,b=0;b<d.length;b++)m(d[b]);return m}({1:[function(n,i,c){(function(d){"use strict";var m=d.MutationObserver||d.WebKitMutationObserver,p;if(m){var b=0,g=new m(D),S=d.document.createTextNode("");g.observe(S,{characterData:!0}),p=function(){S.data=b=++b%2}}else if(!d.setImmediate&&typeof d.MessageChannel!="undefined"){var v=new d.MessageChannel;v.port1.onmessage=D,p=function(){v.port2.postMessage(0)}}else"document"in d&&"onreadystatechange"in d.document.createElement("script")?p=function(){var P=d.document.createElement("script");P.onreadystatechange=function(){D(),P.onreadystatechange=null,P.parentNode.removeChild(P),P=null},d.document.documentElement.appendChild(P)}:p=function(){setTimeout(D,0)};var I,O=[];function D(){I=!0;for(var P,H,F=O.length;F;){for(H=O,O=[],P=-1;++P<F;)H[P]();F=O.length}I=!1}i.exports=x;function x(P){O.push(P)===1&&!I&&p()}}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],2:[function(n,i,c){"use strict";var d=n(1);function m(){}var p={},b=["REJECTED"],g=["FULFILLED"],S=["PENDING"];i.exports=v;function v(T){if(typeof T!="function")throw new TypeError("resolver must be a function");this.state=S,this.queue=[],this.outcome=void 0,T!==m&&x(this,T)}v.prototype.catch=function(T){return this.then(null,T)},v.prototype.then=function(T,U){if(typeof T!="function"&&this.state===g||typeof U!="function"&&this.state===b)return this;var L=new this.constructor(m);if(this.state!==S){var J=this.state===g?T:U;O(L,J,this.outcome)}else this.queue.push(new I(L,T,U));return L};function I(T,U,L){this.promise=T,typeof U=="function"&&(this.onFulfilled=U,this.callFulfilled=this.otherCallFulfilled),typeof L=="function"&&(this.onRejected=L,this.callRejected=this.otherCallRejected)}I.prototype.callFulfilled=function(T){p.resolve(this.promise,T)},I.prototype.otherCallFulfilled=function(T){O(this.promise,this.onFulfilled,T)},I.prototype.callRejected=function(T){p.reject(this.promise,T)},I.prototype.otherCallRejected=function(T){O(this.promise,this.onRejected,T)};function O(T,U,L){d(function(){var J;try{J=U(L)}catch(X){return p.reject(T,X)}J===T?p.reject(T,new TypeError("Cannot resolve promise with itself")):p.resolve(T,J)})}p.resolve=function(T,U){var L=P(D,U);if(L.status==="error")return p.reject(T,L.value);var J=L.value;if(J)x(T,J);else{T.state=g,T.outcome=U;for(var X=-1,re=T.queue.length;++X<re;)T.queue[X].callFulfilled(U)}return T},p.reject=function(T,U){T.state=b,T.outcome=U;for(var L=-1,J=T.queue.length;++L<J;)T.queue[L].callRejected(U);return T};function D(T){var U=T&&T.then;if(T&&(typeof T=="object"||typeof T=="function")&&typeof U=="function")return function(){U.apply(T,arguments)}}function x(T,U){var L=!1;function J(oe){L||(L=!0,p.reject(T,oe))}function X(oe){L||(L=!0,p.resolve(T,oe))}function re(){U(X,J)}var ne=P(re);ne.status==="error"&&J(ne.value)}function P(T,U){var L={};try{L.value=T(U),L.status="success"}catch(J){L.status="error",L.value=J}return L}v.resolve=H;function H(T){return T instanceof this?T:p.resolve(new this(m),T)}v.reject=F;function F(T){var U=new this(m);return p.reject(U,T)}v.all=te;function te(T){var U=this;if(Object.prototype.toString.call(T)!=="[object Array]")return this.reject(new TypeError("must be an array"));var L=T.length,J=!1;if(!L)return this.resolve([]);for(var X=new Array(L),re=0,ne=-1,oe=new this(m);++ne<L;)me(T[ne],ne);return oe;function me(Ue,We){U.resolve(Ue).then(jt,function(Re){J||(J=!0,p.reject(oe,Re))});function jt(Re){X[We]=Re,++re===L&&!J&&(J=!0,p.resolve(oe,X))}}}v.race=B;function B(T){var U=this;if(Object.prototype.toString.call(T)!=="[object Array]")return this.reject(new TypeError("must be an array"));var L=T.length,J=!1;if(!L)return this.resolve([]);for(var X=-1,re=new this(m);++X<L;)ne(T[X]);return re;function ne(oe){U.resolve(oe).then(function(me){J||(J=!0,p.resolve(re,me))},function(me){J||(J=!0,p.reject(re,me))})}}},{1:1}],3:[function(n,i,c){(function(d){"use strict";typeof d.Promise!="function"&&(d.Promise=n(2))}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{2:2}],4:[function(n,i,c){"use strict";var d=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o};function m(o,s){if(!(o instanceof s))throw new TypeError("Cannot call a class as a function")}function p(){try{if(typeof indexedDB!="undefined")return indexedDB;if(typeof webkitIndexedDB!="undefined")return webkitIndexedDB;if(typeof mozIndexedDB!="undefined")return mozIndexedDB;if(typeof OIndexedDB!="undefined")return OIndexedDB;if(typeof msIndexedDB!="undefined")return msIndexedDB}catch(o){return}}var b=p();function g(){try{if(!b||!b.open)return!1;var o=typeof openDatabase!="undefined"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),s=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!o||s)&&typeof indexedDB!="undefined"&&typeof IDBKeyRange!="undefined"}catch(a){return!1}}function S(o,s){o=o||[],s=s||{};try{return new Blob(o,s)}catch(u){if(u.name!=="TypeError")throw u;for(var a=typeof BlobBuilder!="undefined"?BlobBuilder:typeof MSBlobBuilder!="undefined"?MSBlobBuilder:typeof MozBlobBuilder!="undefined"?MozBlobBuilder:WebKitBlobBuilder,l=new a,f=0;f<o.length;f+=1)l.append(o[f]);return l.getBlob(s.type)}}typeof Promise=="undefined"&&n(3);var v=Promise;function I(o,s){s&&o.then(function(a){s(null,a)},function(a){s(a)})}function O(o,s,a){typeof s=="function"&&o.then(s),typeof a=="function"&&o.catch(a)}function D(o){return typeof o!="string"&&(console.warn(o+" used as a key, but it is not a string."),o=String(o)),o}function x(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var P="local-forage-detect-blob-support",H=void 0,F={},te=Object.prototype.toString,B="readonly",T="readwrite";function U(o){for(var s=o.length,a=new ArrayBuffer(s),l=new Uint8Array(a),f=0;f<s;f++)l[f]=o.charCodeAt(f);return a}function L(o){return new v(function(s){var a=o.transaction(P,T),l=S([""]);a.objectStore(P).put(l,"key"),a.onabort=function(f){f.preventDefault(),f.stopPropagation(),s(!1)},a.oncomplete=function(){var f=navigator.userAgent.match(/Chrome\/(\d+)/),u=navigator.userAgent.match(/Edge\//);s(u||!f||parseInt(f[1],10)>=43)}}).catch(function(){return!1})}function J(o){return typeof H=="boolean"?v.resolve(H):L(o).then(function(s){return H=s,H})}function X(o){var s=F[o.name],a={};a.promise=new v(function(l,f){a.resolve=l,a.reject=f}),s.deferredOperations.push(a),s.dbReady?s.dbReady=s.dbReady.then(function(){return a.promise}):s.dbReady=a.promise}function re(o){var s=F[o.name],a=s.deferredOperations.pop();if(a)return a.resolve(),a.promise}function ne(o,s){var a=F[o.name],l=a.deferredOperations.pop();if(l)return l.reject(s),l.promise}function oe(o,s){return new v(function(a,l){if(F[o.name]=F[o.name]||Jr(),o.db)if(s)X(o),o.db.close();else return a(o.db);var f=[o.name];s&&f.push(o.version);var u=b.open.apply(b,f);s&&(u.onupgradeneeded=function(h){var y=u.result;try{y.createObjectStore(o.storeName),h.oldVersion<=1&&y.createObjectStore(P)}catch(_){if(_.name==="ConstraintError")console.warn('The database "'+o.name+'" has been upgraded from version '+h.oldVersion+" to version "+h.newVersion+', but the storage "'+o.storeName+'" already exists.');else throw _}}),u.onerror=function(h){h.preventDefault(),l(u.error)},u.onsuccess=function(){var h=u.result;h.onversionchange=function(y){y.target.close()},a(h),re(o)}})}function me(o){return oe(o,!1)}function Ue(o){return oe(o,!0)}function We(o,s){if(!o.db)return!0;var a=!o.db.objectStoreNames.contains(o.storeName),l=o.version<o.db.version,f=o.version>o.db.version;if(l&&(o.version!==s&&console.warn('The database "'+o.name+`" can't be downgraded from version `+o.db.version+" to version "+o.version+"."),o.version=o.db.version),f||a){if(a){var u=o.db.version+1;u>o.version&&(o.version=u)}return!0}return!1}function jt(o){return new v(function(s,a){var l=new FileReader;l.onerror=a,l.onloadend=function(f){var u=btoa(f.target.result||"");s({__local_forage_encoded_blob:!0,data:u,type:o.type})},l.readAsBinaryString(o)})}function Re(o){var s=U(atob(o.data));return S([s],{type:o.type})}function Hr(o){return o&&o.__local_forage_encoded_blob}function Lo(o){var s=this,a=s._initReady().then(function(){var l=F[s._dbInfo.name];if(l&&l.dbReady)return l.dbReady});return O(a,o,o),a}function Uo(o){X(o);for(var s=F[o.name],a=s.forages,l=0;l<a.length;l++){var f=a[l];f._dbInfo.db&&(f._dbInfo.db.close(),f._dbInfo.db=null)}return o.db=null,me(o).then(function(u){return o.db=u,We(o)?Ue(o):u}).then(function(u){o.db=s.db=u;for(var h=0;h<a.length;h++)a[h]._dbInfo.db=u}).catch(function(u){throw ne(o,u),u})}function pe(o,s,a,l){l===void 0&&(l=1);try{var f=o.db.transaction(o.storeName,s);a(null,f)}catch(u){if(l>0&&(!o.db||u.name==="InvalidStateError"||u.name==="NotFoundError"))return v.resolve().then(function(){if(!o.db||u.name==="NotFoundError"&&!o.db.objectStoreNames.contains(o.storeName)&&o.version<=o.db.version)return o.db&&(o.version=o.db.version+1),Ue(o)}).then(function(){return Uo(o).then(function(){pe(o,s,a,l-1)})}).catch(a);a(u)}}function Jr(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Fo(o){var s=this,a={db:null};if(o)for(var l in o)a[l]=o[l];var f=F[a.name];f||(f=Jr(),F[a.name]=f),f.forages.push(s),s._initReady||(s._initReady=s.ready,s.ready=Lo);var u=[];function h(){return v.resolve()}for(var y=0;y<f.forages.length;y++){var _=f.forages[y];_!==s&&u.push(_._initReady().catch(h))}var w=f.forages.slice(0);return v.all(u).then(function(){return a.db=f.db,me(a)}).then(function(E){return a.db=E,We(a,s._defaultConfig.version)?Ue(a):E}).then(function(E){a.db=f.db=E,s._dbInfo=a;for(var R=0;R<w.length;R++){var N=w[R];N!==s&&(N._dbInfo.db=a.db,N._dbInfo.version=a.version)}})}function Bo(o,s){var a=this;o=D(o);var l=new v(function(f,u){a.ready().then(function(){pe(a._dbInfo,B,function(h,y){if(h)return u(h);try{var _=y.objectStore(a._dbInfo.storeName),w=_.get(o);w.onsuccess=function(){var E=w.result;E===void 0&&(E=null),Hr(E)&&(E=Re(E)),f(E)},w.onerror=function(){u(w.error)}}catch(E){u(E)}})}).catch(u)});return I(l,s),l}function Mo(o,s){var a=this,l=new v(function(f,u){a.ready().then(function(){pe(a._dbInfo,B,function(h,y){if(h)return u(h);try{var _=y.objectStore(a._dbInfo.storeName),w=_.openCursor(),E=1;w.onsuccess=function(){var R=w.result;if(R){var N=R.value;Hr(N)&&(N=Re(N));var M=o(N,R.key,E++);M!==void 0?f(M):R.continue()}else f()},w.onerror=function(){u(w.error)}}catch(R){u(R)}})}).catch(u)});return I(l,s),l}function $o(o,s,a){var l=this;o=D(o);var f=new v(function(u,h){var y;l.ready().then(function(){return y=l._dbInfo,te.call(s)==="[object Blob]"?J(y.db).then(function(_){return _?s:jt(s)}):s}).then(function(_){pe(l._dbInfo,T,function(w,E){if(w)return h(w);try{var R=E.objectStore(l._dbInfo.storeName);_===null&&(_=void 0);var N=R.put(_,o);E.oncomplete=function(){_===void 0&&(_=null),u(_)},E.onabort=E.onerror=function(){var M=N.error?N.error:N.transaction.error;h(M)}}catch(M){h(M)}})}).catch(h)});return I(f,a),f}function jo(o,s){var a=this;o=D(o);var l=new v(function(f,u){a.ready().then(function(){pe(a._dbInfo,T,function(h,y){if(h)return u(h);try{var _=y.objectStore(a._dbInfo.storeName),w=_.delete(o);y.oncomplete=function(){f()},y.onerror=function(){u(w.error)},y.onabort=function(){var E=w.error?w.error:w.transaction.error;u(E)}}catch(E){u(E)}})}).catch(u)});return I(l,s),l}function Vo(o){var s=this,a=new v(function(l,f){s.ready().then(function(){pe(s._dbInfo,T,function(u,h){if(u)return f(u);try{var y=h.objectStore(s._dbInfo.storeName),_=y.clear();h.oncomplete=function(){l()},h.onabort=h.onerror=function(){var w=_.error?_.error:_.transaction.error;f(w)}}catch(w){f(w)}})}).catch(f)});return I(a,o),a}function Ho(o){var s=this,a=new v(function(l,f){s.ready().then(function(){pe(s._dbInfo,B,function(u,h){if(u)return f(u);try{var y=h.objectStore(s._dbInfo.storeName),_=y.count();_.onsuccess=function(){l(_.result)},_.onerror=function(){f(_.error)}}catch(w){f(w)}})}).catch(f)});return I(a,o),a}function Jo(o,s){var a=this,l=new v(function(f,u){if(o<0){f(null);return}a.ready().then(function(){pe(a._dbInfo,B,function(h,y){if(h)return u(h);try{var _=y.objectStore(a._dbInfo.storeName),w=!1,E=_.openKeyCursor();E.onsuccess=function(){var R=E.result;if(!R){f(null);return}o===0||w?f(R.key):(w=!0,R.advance(o))},E.onerror=function(){u(E.error)}}catch(R){u(R)}})}).catch(u)});return I(l,s),l}function Ko(o){var s=this,a=new v(function(l,f){s.ready().then(function(){pe(s._dbInfo,B,function(u,h){if(u)return f(u);try{var y=h.objectStore(s._dbInfo.storeName),_=y.openKeyCursor(),w=[];_.onsuccess=function(){var E=_.result;if(!E){l(w);return}w.push(E.key),E.continue()},_.onerror=function(){f(_.error)}}catch(E){f(E)}})}).catch(f)});return I(a,o),a}function Go(o,s){s=x.apply(this,arguments);var a=this.config();o=typeof o!="function"&&o||{},o.name||(o.name=o.name||a.name,o.storeName=o.storeName||a.storeName);var l=this,f;if(!o.name)f=v.reject("Invalid arguments");else{var u=o.name===a.name&&l._dbInfo.db,h=u?v.resolve(l._dbInfo.db):me(o).then(function(y){var _=F[o.name],w=_.forages;_.db=y;for(var E=0;E<w.length;E++)w[E]._dbInfo.db=y;return y});o.storeName?f=h.then(function(y){if(y.objectStoreNames.contains(o.storeName)){var _=y.version+1;X(o);var w=F[o.name],E=w.forages;y.close();for(var R=0;R<E.length;R++){var N=E[R];N._dbInfo.db=null,N._dbInfo.version=_}var M=new v(function(j,W){var q=b.open(o.name,_);q.onerror=function(ie){var Be=q.result;Be.close(),W(ie)},q.onupgradeneeded=function(){var ie=q.result;ie.deleteObjectStore(o.storeName)},q.onsuccess=function(){var ie=q.result;ie.close(),j(ie)}});return M.then(function(j){w.db=j;for(var W=0;W<E.length;W++){var q=E[W];q._dbInfo.db=j,re(q._dbInfo)}}).catch(function(j){throw(ne(o,j)||v.resolve()).catch(function(){}),j})}}):f=h.then(function(y){X(o);var _=F[o.name],w=_.forages;y.close();for(var E=0;E<w.length;E++){var R=w[E];R._dbInfo.db=null}var N=new v(function(M,j){var W=b.deleteDatabase(o.name);W.onerror=function(){var q=W.result;q&&q.close(),j(W.error)},W.onblocked=function(){console.warn('dropInstance blocked for database "'+o.name+'" until all open connections are closed')},W.onsuccess=function(){var q=W.result;q&&q.close(),M(q)}});return N.then(function(M){_.db=M;for(var j=0;j<w.length;j++){var W=w[j];re(W._dbInfo)}}).catch(function(M){throw(ne(o,M)||v.resolve()).catch(function(){}),M})})}return I(f,s),f}var qo={_driver:"asyncStorage",_initStorage:Fo,_support:g(),iterate:Mo,getItem:Bo,setItem:$o,removeItem:jo,clear:Vo,length:Ho,key:Jo,keys:Ko,dropInstance:Go};function Wo(){return typeof openDatabase=="function"}var ye="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Yo="~~local_forage_type~",Kr=/^~~local_forage_type~([^~]+)~/,Ye="__lfsc__:",Vt=Ye.length,Ht="arbf",Jt="blob",Gr="si08",qr="ui08",Wr="uic8",Yr="si16",zr="si32",Qr="ur16",Xr="ui32",Zr="fl32",en="fl64",tn=Vt+Ht.length,rn=Object.prototype.toString;function nn(o){var s=o.length*.75,a=o.length,l,f=0,u,h,y,_;o[o.length-1]==="="&&(s--,o[o.length-2]==="="&&s--);var w=new ArrayBuffer(s),E=new Uint8Array(w);for(l=0;l<a;l+=4)u=ye.indexOf(o[l]),h=ye.indexOf(o[l+1]),y=ye.indexOf(o[l+2]),_=ye.indexOf(o[l+3]),E[f++]=u<<2|h>>4,E[f++]=(h&15)<<4|y>>2,E[f++]=(y&3)<<6|_&63;return w}function Kt(o){var s=new Uint8Array(o),a="",l;for(l=0;l<s.length;l+=3)a+=ye[s[l]>>2],a+=ye[(s[l]&3)<<4|s[l+1]>>4],a+=ye[(s[l+1]&15)<<2|s[l+2]>>6],a+=ye[s[l+2]&63];return s.length%3===2?a=a.substring(0,a.length-1)+"=":s.length%3===1&&(a=a.substring(0,a.length-2)+"=="),a}function zo(o,s){var a="";if(o&&(a=rn.call(o)),o&&(a==="[object ArrayBuffer]"||o.buffer&&rn.call(o.buffer)==="[object ArrayBuffer]")){var l,f=Ye;o instanceof ArrayBuffer?(l=o,f+=Ht):(l=o.buffer,a==="[object Int8Array]"?f+=Gr:a==="[object Uint8Array]"?f+=qr:a==="[object Uint8ClampedArray]"?f+=Wr:a==="[object Int16Array]"?f+=Yr:a==="[object Uint16Array]"?f+=Qr:a==="[object Int32Array]"?f+=zr:a==="[object Uint32Array]"?f+=Xr:a==="[object Float32Array]"?f+=Zr:a==="[object Float64Array]"?f+=en:s(new Error("Failed to get type for BinaryArray"))),s(f+Kt(l))}else if(a==="[object Blob]"){var u=new FileReader;u.onload=function(){var h=Yo+o.type+"~"+Kt(this.result);s(Ye+Jt+h)},u.readAsArrayBuffer(o)}else try{s(JSON.stringify(o))}catch(h){console.error("Couldn't convert value into a JSON string: ",o),s(null,h)}}function Qo(o){if(o.substring(0,Vt)!==Ye)return JSON.parse(o);var s=o.substring(tn),a=o.substring(Vt,tn),l;if(a===Jt&&Kr.test(s)){var f=s.match(Kr);l=f[1],s=s.substring(f[0].length)}var u=nn(s);switch(a){case Ht:return u;case Jt:return S([u],{type:l});case Gr:return new Int8Array(u);case qr:return new Uint8Array(u);case Wr:return new Uint8ClampedArray(u);case Yr:return new Int16Array(u);case Qr:return new Uint16Array(u);case zr:return new Int32Array(u);case Xr:return new Uint32Array(u);case Zr:return new Float32Array(u);case en:return new Float64Array(u);default:throw new Error("Unkown type: "+a)}}var Gt={serialize:zo,deserialize:Qo,stringToBuffer:nn,bufferToString:Kt};function on(o,s,a,l){o.executeSql("CREATE TABLE IF NOT EXISTS "+s.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],a,l)}function Xo(o){var s=this,a={db:null};if(o)for(var l in o)a[l]=typeof o[l]!="string"?o[l].toString():o[l];var f=new v(function(u,h){try{a.db=openDatabase(a.name,String(a.version),a.description,a.size)}catch(y){return h(y)}a.db.transaction(function(y){on(y,a,function(){s._dbInfo=a,u()},function(_,w){h(w)})},h)});return a.serializer=Gt,f}function be(o,s,a,l,f,u){o.executeSql(a,l,f,function(h,y){y.code===y.SYNTAX_ERR?h.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[s.storeName],function(_,w){w.rows.length?u(_,y):on(_,s,function(){_.executeSql(a,l,f,u)},u)},u):u(h,y)},u)}function Zo(o,s){var a=this;o=D(o);var l=new v(function(f,u){a.ready().then(function(){var h=a._dbInfo;h.db.transaction(function(y){be(y,h,"SELECT * FROM "+h.storeName+" WHERE key = ? LIMIT 1",[o],function(_,w){var E=w.rows.length?w.rows.item(0).value:null;E&&(E=h.serializer.deserialize(E)),f(E)},function(_,w){u(w)})})}).catch(u)});return I(l,s),l}function ei(o,s){var a=this,l=new v(function(f,u){a.ready().then(function(){var h=a._dbInfo;h.db.transaction(function(y){be(y,h,"SELECT * FROM "+h.storeName,[],function(_,w){for(var E=w.rows,R=E.length,N=0;N<R;N++){var M=E.item(N),j=M.value;if(j&&(j=h.serializer.deserialize(j)),j=o(j,M.key,N+1),j!==void 0){f(j);return}}f()},function(_,w){u(w)})})}).catch(u)});return I(l,s),l}function an(o,s,a,l){var f=this;o=D(o);var u=new v(function(h,y){f.ready().then(function(){s===void 0&&(s=null);var _=s,w=f._dbInfo;w.serializer.serialize(s,function(E,R){R?y(R):w.db.transaction(function(N){be(N,w,"INSERT OR REPLACE INTO "+w.storeName+" (key, value) VALUES (?, ?)",[o,E],function(){h(_)},function(M,j){y(j)})},function(N){if(N.code===N.QUOTA_ERR){if(l>0){h(an.apply(f,[o,_,a,l-1]));return}y(N)}})})}).catch(y)});return I(u,a),u}function ti(o,s,a){return an.apply(this,[o,s,a,1])}function ri(o,s){var a=this;o=D(o);var l=new v(function(f,u){a.ready().then(function(){var h=a._dbInfo;h.db.transaction(function(y){be(y,h,"DELETE FROM "+h.storeName+" WHERE key = ?",[o],function(){f()},function(_,w){u(w)})})}).catch(u)});return I(l,s),l}function ni(o){var s=this,a=new v(function(l,f){s.ready().then(function(){var u=s._dbInfo;u.db.transaction(function(h){be(h,u,"DELETE FROM "+u.storeName,[],function(){l()},function(y,_){f(_)})})}).catch(f)});return I(a,o),a}function oi(o){var s=this,a=new v(function(l,f){s.ready().then(function(){var u=s._dbInfo;u.db.transaction(function(h){be(h,u,"SELECT COUNT(key) as c FROM "+u.storeName,[],function(y,_){var w=_.rows.item(0).c;l(w)},function(y,_){f(_)})})}).catch(f)});return I(a,o),a}function ii(o,s){var a=this,l=new v(function(f,u){a.ready().then(function(){var h=a._dbInfo;h.db.transaction(function(y){be(y,h,"SELECT key FROM "+h.storeName+" WHERE id = ? LIMIT 1",[o+1],function(_,w){var E=w.rows.length?w.rows.item(0).key:null;f(E)},function(_,w){u(w)})})}).catch(u)});return I(l,s),l}function ai(o){var s=this,a=new v(function(l,f){s.ready().then(function(){var u=s._dbInfo;u.db.transaction(function(h){be(h,u,"SELECT key FROM "+u.storeName,[],function(y,_){for(var w=[],E=0;E<_.rows.length;E++)w.push(_.rows.item(E).key);l(w)},function(y,_){f(_)})})}).catch(f)});return I(a,o),a}function si(o){return new v(function(s,a){o.transaction(function(l){l.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(f,u){for(var h=[],y=0;y<u.rows.length;y++)h.push(u.rows.item(y).name);s({db:o,storeNames:h})},function(f,u){a(u)})},function(l){a(l)})})}function ci(o,s){s=x.apply(this,arguments);var a=this.config();o=typeof o!="function"&&o||{},o.name||(o.name=o.name||a.name,o.storeName=o.storeName||a.storeName);var l=this,f;return o.name?f=new v(function(u){var h;o.name===a.name?h=l._dbInfo.db:h=openDatabase(o.name,"","",0),o.storeName?u({db:h,storeNames:[o.storeName]}):u(si(h))}).then(function(u){return new v(function(h,y){u.db.transaction(function(_){function w(M){return new v(function(j,W){_.executeSql("DROP TABLE IF EXISTS "+M,[],function(){j()},function(q,ie){W(ie)})})}for(var E=[],R=0,N=u.storeNames.length;R<N;R++)E.push(w(u.storeNames[R]));v.all(E).then(function(){h()}).catch(function(M){y(M)})},function(_){y(_)})})}):f=v.reject("Invalid arguments"),I(f,s),f}var ui={_driver:"webSQLStorage",_initStorage:Xo,_support:Wo(),iterate:ei,getItem:Zo,setItem:ti,removeItem:ri,clear:ni,length:oi,key:ii,keys:ai,dropInstance:ci};function li(){try{return typeof localStorage!="undefined"&&"setItem"in localStorage&&!!localStorage.setItem}catch(o){return!1}}function sn(o,s){var a=o.name+"/";return o.storeName!==s.storeName&&(a+=o.storeName+"/"),a}function di(){var o="_localforage_support_test";try{return localStorage.setItem(o,!0),localStorage.removeItem(o),!1}catch(s){return!0}}function fi(){return!di()||localStorage.length>0}function mi(o){var s=this,a={};if(o)for(var l in o)a[l]=o[l];return a.keyPrefix=sn(o,s._defaultConfig),fi()?(s._dbInfo=a,a.serializer=Gt,v.resolve()):v.reject()}function pi(o){var s=this,a=s.ready().then(function(){for(var l=s._dbInfo.keyPrefix,f=localStorage.length-1;f>=0;f--){var u=localStorage.key(f);u.indexOf(l)===0&&localStorage.removeItem(u)}});return I(a,o),a}function hi(o,s){var a=this;o=D(o);var l=a.ready().then(function(){var f=a._dbInfo,u=localStorage.getItem(f.keyPrefix+o);return u&&(u=f.serializer.deserialize(u)),u});return I(l,s),l}function gi(o,s){var a=this,l=a.ready().then(function(){for(var f=a._dbInfo,u=f.keyPrefix,h=u.length,y=localStorage.length,_=1,w=0;w<y;w++){var E=localStorage.key(w);if(E.indexOf(u)===0){var R=localStorage.getItem(E);if(R&&(R=f.serializer.deserialize(R)),R=o(R,E.substring(h),_++),R!==void 0)return R}}});return I(l,s),l}function vi(o,s){var a=this,l=a.ready().then(function(){var f=a._dbInfo,u;try{u=localStorage.key(o)}catch(h){u=null}return u&&(u=u.substring(f.keyPrefix.length)),u});return I(l,s),l}function yi(o){var s=this,a=s.ready().then(function(){for(var l=s._dbInfo,f=localStorage.length,u=[],h=0;h<f;h++){var y=localStorage.key(h);y.indexOf(l.keyPrefix)===0&&u.push(y.substring(l.keyPrefix.length))}return u});return I(a,o),a}function bi(o){var s=this,a=s.keys().then(function(l){return l.length});return I(a,o),a}function _i(o,s){var a=this;o=D(o);var l=a.ready().then(function(){var f=a._dbInfo;localStorage.removeItem(f.keyPrefix+o)});return I(l,s),l}function wi(o,s,a){var l=this;o=D(o);var f=l.ready().then(function(){s===void 0&&(s=null);var u=s;return new v(function(h,y){var _=l._dbInfo;_.serializer.serialize(s,function(w,E){if(E)y(E);else try{localStorage.setItem(_.keyPrefix+o,w),h(u)}catch(R){(R.name==="QuotaExceededError"||R.name==="NS_ERROR_DOM_QUOTA_REACHED")&&y(R),y(R)}})})});return I(f,a),f}function Ei(o,s){if(s=x.apply(this,arguments),o=typeof o!="function"&&o||{},!o.name){var a=this.config();o.name=o.name||a.name,o.storeName=o.storeName||a.storeName}var l=this,f;return o.name?f=new v(function(u){o.storeName?u(sn(o,l._defaultConfig)):u(o.name+"/")}).then(function(u){for(var h=localStorage.length-1;h>=0;h--){var y=localStorage.key(h);y.indexOf(u)===0&&localStorage.removeItem(y)}}):f=v.reject("Invalid arguments"),I(f,s),f}var Ii={_driver:"localStorageWrapper",_initStorage:mi,_support:li(),iterate:gi,getItem:hi,setItem:wi,removeItem:_i,clear:pi,length:bi,key:vi,keys:yi,dropInstance:Ei},Ti=function(s,a){return s===a||typeof s=="number"&&typeof a=="number"&&isNaN(s)&&isNaN(a)},Si=function(s,a){for(var l=s.length,f=0;f<l;){if(Ti(s[f],a))return!0;f++}return!1},cn=Array.isArray||function(o){return Object.prototype.toString.call(o)==="[object Array]"},Fe={},un={},Ae={INDEXEDDB:qo,WEBSQL:ui,LOCALSTORAGE:Ii},Ri=[Ae.INDEXEDDB._driver,Ae.WEBSQL._driver,Ae.LOCALSTORAGE._driver],ze=["dropInstance"],qt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ze),Ai={description:"",driver:Ri.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function ki(o,s){o[s]=function(){var a=arguments;return o.ready().then(function(){return o[s].apply(o,a)})}}function Wt(){for(var o=1;o<arguments.length;o++){var s=arguments[o];if(s)for(var a in s)s.hasOwnProperty(a)&&(cn(s[a])?arguments[0][a]=s[a].slice():arguments[0][a]=s[a])}return arguments[0]}var xi=function(){function o(s){m(this,o);for(var a in Ae)if(Ae.hasOwnProperty(a)){var l=Ae[a],f=l._driver;this[a]=f,Fe[f]||this.defineDriver(l)}this._defaultConfig=Wt({},Ai),this._config=Wt({},this._defaultConfig,s),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return o.prototype.config=function(a){if((typeof a=="undefined"?"undefined":d(a))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var l in a){if(l==="storeName"&&(a[l]=a[l].replace(/\W/g,"_")),l==="version"&&typeof a[l]!="number")return new Error("Database version must be a number.");this._config[l]=a[l]}return"driver"in a&&a.driver?this.setDriver(this._config.driver):!0}else return typeof a=="string"?this._config[a]:this._config},o.prototype.defineDriver=function(a,l,f){var u=new v(function(h,y){try{var _=a._driver,w=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!a._driver){y(w);return}for(var E=qt.concat("_initStorage"),R=0,N=E.length;R<N;R++){var M=E[R],j=!Si(ze,M);if((j||a[M])&&typeof a[M]!="function"){y(w);return}}var W=function(){for(var Be=function(Oi){return function(){var Di=new Error("Method "+Oi+" is not implemented by the current driver"),ln=v.reject(Di);return I(ln,arguments[arguments.length-1]),ln}},Yt=0,Pi=ze.length;Yt<Pi;Yt++){var zt=ze[Yt];a[zt]||(a[zt]=Be(zt))}};W();var q=function(Be){Fe[_]&&console.info("Redefining LocalForage driver: "+_),Fe[_]=a,un[_]=Be,h()};"_support"in a?a._support&&typeof a._support=="function"?a._support().then(q,y):q(!!a._support):q(!0)}catch(ie){y(ie)}});return O(u,l,f),u},o.prototype.driver=function(){return this._driver||null},o.prototype.getDriver=function(a,l,f){var u=Fe[a]?v.resolve(Fe[a]):v.reject(new Error("Driver not found."));return O(u,l,f),u},o.prototype.getSerializer=function(a){var l=v.resolve(Gt);return O(l,a),l},o.prototype.ready=function(a){var l=this,f=l._driverSet.then(function(){return l._ready===null&&(l._ready=l._initDriver()),l._ready});return O(f,a,a),f},o.prototype.setDriver=function(a,l,f){var u=this;cn(a)||(a=[a]);var h=this._getSupportedDrivers(a);function y(){u._config.driver=u.driver()}function _(R){return u._extend(R),y(),u._ready=u._initStorage(u._config),u._ready}function w(R){return function(){var N=0;function M(){for(;N<R.length;){var j=R[N];return N++,u._dbInfo=null,u._ready=null,u.getDriver(j).then(_).catch(M)}y();var W=new Error("No available storage method found.");return u._driverSet=v.reject(W),u._driverSet}return M()}}var E=this._driverSet!==null?this._driverSet.catch(function(){return v.resolve()}):v.resolve();return this._driverSet=E.then(function(){var R=h[0];return u._dbInfo=null,u._ready=null,u.getDriver(R).then(function(N){u._driver=N._driver,y(),u._wrapLibraryMethodsWithReady(),u._initDriver=w(h)})}).catch(function(){y();var R=new Error("No available storage method found.");return u._driverSet=v.reject(R),u._driverSet}),O(this._driverSet,l,f),this._driverSet},o.prototype.supports=function(a){return!!un[a]},o.prototype._extend=function(a){Wt(this,a)},o.prototype._getSupportedDrivers=function(a){for(var l=[],f=0,u=a.length;f<u;f++){var h=a[f];this.supports(h)&&l.push(h)}return l},o.prototype._wrapLibraryMethodsWithReady=function(){for(var a=0,l=qt.length;a<l;a++)ki(this,qt[a])},o.prototype.createInstance=function(a){return new o(a)},o}(),Ci=new xi;i.exports=Ci},{3:3}]},{},[4])(4)})});var mo=pn(Te=>{"use strict";$();Ge();Ee();var Ce=ae(),za=se("levelFinished",{paramsSchema:k.tuple(k.string(),k.object({result:k.boolean(),duration:k.number()})),implement:(e,t)=>C(Te,null,function*(){let{result:r,duration:n}=t;ce.info("onLevelFinished",r,n),yield Promise.all([le.reporter({event:"COMPLETE_GAME_LEVEL"}),le.tracker("LevelFinished",{levelId:e,result:r,duration:n})])})}),Qa=se("taskFinished",{paramsSchema:k.tuple(k.string(),k.object({duration:k.number()})),implement:(e,t)=>C(Te,null,function*(){let{duration:r}=t;yield le.tracker("TaskFinished",{duration:r,taskId:e})})}),Xa=se("levelUpgrade",{paramsSchema:k.tuple(k.string(),k.string()),implement:(e,t)=>C(Te,null,function*(){return yield le.tracker("LevelUpgrade",{name:t,levelId:e})})}),Za=se("onHistoryUserLevel",{paramsSchema:k.tuple(k.number()),implement:e=>C(Te,null,function*(){return yield le.tracker("HistoryUserLevel",{level:e})})}),es=se("onHistoryUserScore",{paramsSchema:k.tuple(k.number()),implement:e=>C(Te,null,function*(){return yield le.tracker("HistoryUserScore",{score:e})})}),ts=se("taskEvent",{paramsSchema:k.tuple(k.string(),k.object({tools:k.array(k.object({id:k.string(),name:k.string(),count:k.number(),description:k.string().optional(),price:k.object({amount:k.number(),unit:k.string()}).optional()})).optional(),awards:k.array(k.object({id:k.string(),name:k.string()})).optional()})),implement:(e,t)=>C(Te,null,function*(){var r;(r=t.tools)!=null&&r.length&&(yield Promise.all([le.reporter({event:"USE_GAME_ITEM"}),le.tracker("UseGameItem",V({taskId:e},t))]))})});Ce.registerCommand("TaskTrackerSDK.levelFinished",za);Ce.registerCommand("TaskTrackerSDK.taskFinished",Qa);Ce.registerCommand("TaskTrackerSDK.levelUpgrade",Xa);Ce.registerCommand("TaskTrackerSDK.historyUserLevel",Za);Ce.registerCommand("TaskTrackerSDK.historyUserScore",es);Ce.registerCommand("TaskTrackerSDK.taskEvent",ts);Q("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});Q("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});Q("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});Q("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});Q("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});Q("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}})});Ee();ee();Ge();$();var so=ae(),Na="env",La="getSystemInfoSync",Ua=()=>{var i,c,d,m;let e={system:A.deviceInfo.system,platform:A.deviceInfo.platform.toLowerCase(),brand:A.deviceInfo.brand,pixelRatio:A.deviceInfo.pixelRatio,language:A.deviceInfo.lang,version:A.sdkInfo.jssdkVersion,appName:(i=A.hostInfo)==null?void 0:i.appName,SDKVersion:A.sdkInfo.nativeSDKVersion},t=(c=A.hostInfo)==null?void 0:c.version;t&&(e=z(V({},e),{version:t}));let r=(d=A.hostInfo)==null?void 0:d.appName;r&&(e=z(V({},e),{appName:r}));let n=(m=A.sdkInfo)==null?void 0:m.jssdkVersion;return n&&(e=z(V({},e),{SDKVersion:n})),e},Fa=Ie(La,{implement:Ua}),Ba=Ie(Na,{implement:()=>z(V({},A.hostInfo),{sdkInfo:A.sdkInfo,platform:A.platform,deviceInfo:A.deviceInfo})});so.registerCommand("API.env",Ba);so.registerCommand("API.getSystemInfoSync",Fa);Q("env",{version:"1.0.0"});Q("getSystemInfoSync",{version:"1.0.0"});$();Ge();_e();Ee();var Ma="onJoliboxShow",$a="onJoliboxHide",ja="onReady",Lr=ae(),Ur=Cn(ue),Nr=!0,qe=!0,At=0,kt=Ar;function Va(){let e=Date.now();if(e-At<100)return;At=e;let t=document.visibilityState==="visible";t!==Nr&&(Nr=t,kt.emit("visible",Nr))}function co(e){let t=Date.now();t-At<100||(At=t,e==="focus"&&!qe?qe=!0:e==="blur"&&qe&&(qe=!1),kt.emit("visible",qe))}document.addEventListener("visibilitychange",Va);window.addEventListener("focus",()=>co("focus"));window.addEventListener("blur",()=>co("blur"));var Ha=Ie(Ma,{paramsSchema:k.tuple(k.function()),implement(e){let t=Ur(e);kt.on("visible",r=>{r&&t()})}}),Ja=Ie($a,{paramsSchema:k.tuple(k.function()),implement(e){let t=Ur(e);kt.on("visible",r=>{!r&&t()})}}),Ka=Ie(ja,{paramsSchema:k.tuple(k.function()),implement(e){let t=Ur(e);Je.on("LifecycleEvent.onReady",r=>{t(r)})}});Lr.registerCommand("LifecycleSDK.onReady",Ka);Lr.registerCommand("LifecycleSDK.onJoliboxShow",Ha);Lr.registerCommand("LifecycleSDK.onJoliboxHide",Ja);Q("lifeCycle.onReady",{version:"1.0.0"});Q("lifeCycle.onJoliboxShow",{version:"1.0.0"});Q("lifeCycle.onJoliboxHide",{version:"1.0.0"});Ge();$();Ke();ee();var fo=hn(lo());var xt=ae(),Br=class{constructor(){this.httpClient=ge.create({baseUrl:A.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com"});this.getGameId=()=>A.mpId;this.getItem=t=>C(this,null,function*(){let{code:r,data:n,message:i}=yield this.httpClient.get(`/api/games/user-storage/${this.gameId}`,{query:{key:t}}),c=n==null?void 0:n.value,d=i;return r!=="SUCCESS"&&(c=yield this.gameStore.getItem(t),console.info("[SDK] cloud storage getItem failed, read from localstorage",c),d+="fallback to localstorage"),{code:r,message:d,data:c&&c!=="undefined"?c:null}});this.setItem=(t,r)=>C(this,null,function*(){let n=typeof r=="string"?r:String(r),{code:i,message:c}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}`,{data:{key:t,value:n}});return yield this.gameStore.setItem(t,n),{code:i,message:c}});this.removeItem=t=>C(this,null,function*(){yield this.gameStore.removeItem(t);let{code:r,message:n}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}/remove`,{data:{key:t}});return{code:r,message:n}});this.clear=()=>C(this,null,function*(){yield this.gameStore.clear();let{code:t,message:r}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}/clear`,{});return{code:t,message:r}});this.gameId=this.getGameId(),this.gameStore=fo.default.createInstance({name:this.gameId.length?this.gameId:"default"})}},Ct=new Br,Ga=se("getLocalStorage",{paramsSchema:k.tuple(k.string()),implement(e){return C(this,null,function*(){return yield Ct.getItem(e)})}});xt.registerCommand("StorageSDK.getItem",Ga);Q("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var qa=se("setStorage",{paramsSchema:k.tuple(k.string(),k.or(k.string(),k.boolean(),k.number())),implement(e,t){return C(this,null,function*(){return yield Ct.setItem(e,t)})}});xt.registerCommand("StorageSDK.setItem",qa);Q("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var Wa=se("removeStorage",{paramsSchema:k.tuple(k.string()),implement(e){return C(this,null,function*(){return yield Ct.removeItem(e)})}});xt.registerCommand("StorageSDK.removeItem",Wa);Q("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var Ya=se("clearStorage",{implement(){return C(this,null,function*(){return yield Ct.clear()})}});xt.registerCommand("StorageSDK.clear",Ya);Q("storage.clear",{version:"1.0.0"});var Bl=hn(mo());var Pt=class{constructor(t){this.track=t;this.adBreakIsShowing=!1;this.reportPageJumpOut=()=>{this.track("AdBreakJumpOut",{context:"AdsActionDetection"})};this.reportPageHide=()=>{this.track("AdBreakHide",{context:"AdsActionDetection"})};window.addEventListener("visibilitychange",()=>{document.hidden&&this.adBreakIsShowing&&this.reportPageHide()}),window.addEventListener("beforeunload",r=>{this.adBreakIsShowing&&this.reportPageJumpOut()})}};$();mr();var Ot=class{constructor(t,r,n,i){this.track=t;this.httpClient=r;this.checkNetwork=n;this.checkAdsDisplayPermission=t=>{if(!this.checkNetwork())return{reason:"NETWORK_NOT_OK"};let r=this.checkShouldBanInitial();if(r)return{reason:r};let n=this.checkShouldBanForSession(t);if(n)return{reason:n};let i=this.checkShouldBanHighFreq(t);if(i)return i;let c=this.checkShouldBanForTime(t);return c?{reason:c}:{reason:"ALLOWED"}};var v,I,O,D,x,P,H;let c=(v=i==null?void 0:i.maxAllowedAdsForTime)!=null?v:8,d=(I=i==null?void 0:i.banForTimeThreshold)!=null?I:6e4,m=(O=i==null?void 0:i.bannedReleaseTime)!=null?O:6e4,p=(D=i==null?void 0:i.maxAllowedAdsForSession)!=null?D:200,b=(x=i==null?void 0:i.banForSessionThreshold)!=null?x:6e5,g=(P=i==null?void 0:i.initialThreshold)!=null?P:2e3,S=(H=i==null?void 0:i.highFreqThreshold)!=null?H:2e3;this.checkShouldBanInitial=os(g),this.checkShouldBanHighFreq=is(S),this.checkShouldBanForTime=ns(c,d,m),this.checkShouldBanForSession=rs(p,b)}report(t,r){let n=r?{reason:t,count:r}:{reason:t};this.track("PreventAdsCheating",n),this.httpClient.post("/api/base/app-event",{data:{eventType:"PREVENT_ADS_CHEATING",adsInfo:n}})}},rs=(e,t)=>{let r=!1,n=[];return c=>{if(r)return"BANNED_FOR_SESSION";let d=Date.now();if(n=n.concat({timestamp:d,type:c}),n.length!==1&&(n.length>e&&(n=n.slice(-e)),n.length===e&&d-n[0].timestamp<=t))return r=!0,"BANNED_FOR_SESSION"}},ns=(e,t,r)=>{let n=null,i=g=>{n&&(window.clearTimeout(n),n=null),n=window.setTimeout(()=>{p.value=!1,n=null},g)},c="jolibox-sdk-ads-callbreak-timestamps",d="jolibox-sdk-ads-ban-for-time",m={_records:[],init(){var g;try{let S=JSON.parse((g=window.__joliboxLocalStorage__.getItem(c))!=null?g:"[]");Array.isArray(S)?this._records=S:this._records=[]}catch(S){this._records=[]}},get values(){return this._records},set values(g){try{window.__joliboxLocalStorage__.setItem(c,JSON.stringify(g))}catch(S){}this._records=g}},p={_record:!1,init(){var g;try{let S=JSON.parse((g=window.__joliboxLocalStorage__.getItem(d))!=null?g:"false");typeof S=="boolean"&&(this._record=S)}catch(S){this._record=!1}if(this._record){let S=m.values[m.values.length-1],v=S?Date.now()-S.timestamp:r;v<=r&&v>0?i(v):this._record=!1}},get value(){return this._record},set value(g){try{window.__joliboxLocalStorage__.setItem(d,JSON.stringify(g))}catch(S){}this._record=g}};return m.init(),p.init(),g=>{if(p.value)return"WAITING_BANNED_RELEASE";let S=Date.now();if(m.values=m.values.concat({timestamp:S,type:g}),m.values.length!==1&&(m.values.length>e&&(m.values=m.values.slice(-e)),m.values.length===e&&S-m.values[0].timestamp<=t))return p.value=!0,i(r),"BANNED_FOR_TIME"}},os=e=>{let t=Date.now();return()=>{if(Date.now()-t<=e)return"BLOCK_INITIAL"}},is=(e=2e3)=>{let t=0,r=null;return i=>{if(i==="reward"){if(r)return t+=1,{reason:"HOLDING_HIGH_FREQ",info:{count:t}};r=window.setTimeout(()=>{r&&(window.clearTimeout(r),r=0,t=0)},e)}}};ee();ee();var Dt=class{constructor(t){this.httpClient=t;this.configs=null;this.firstRun=!0;this.init()}init(){return C(this,null,function*(){try{this.configs=yield this.httpClient.get("/api/fe-configs/js-sdk/ads-channel-config")}catch(t){}})}shouldBypassCallingInterstitial(){var r,n;let t;if(!this.configs)this.init(),t=!this.firstRun;else{let i=(r=A.channel)!=null?r:"",c=this.configs[i],d=(n=c==null?void 0:c.interstitialRate)!=null?n:1;t=Math.random()<d}return this.firstRun=!1,t}};$();var Pe=new de,Nt=class{constructor(t,r,n){this.track=t;this.httpClient=r;this.checkNetwork=n;this.configured=!1;this.config={};this.getGameId=()=>A.mpId;this.getTestAdsMode=()=>A.testAdsMode;this.asyncLoad=()=>C(this,null,function*(){var d,m,p,b,g;let t="ca-pub-7171363994453626",r,n,i=window.encodeURIComponent(window.btoa((d=this.getGameId())!=null?d:"")),c=(m=this.getTestAdsMode())!=null?m:!1;try{let S=yield this.httpClient.get("/public/ads",{query:{objectId:i,testAdsMode:`${c}`}});t=(p=S.data)==null?void 0:p.clientId,r=(b=S.data)==null?void 0:b.channelId,n=(g=S.data)==null?void 0:g.unitId}catch(S){console.error("Failed to fetch client info",S)}this.clientId=t,this.channelId=r,this.unitId=n});this.asyncInit=t=>C(this,null,function*(){var i;if(typeof window=="undefined")return;yield this.asyncLoad();let r="google-adsense",n=(i=this.getTestAdsMode())!=null?i:!1;if(!document.getElementById(r)&&this.clientId){let c=document.createElement("script");c.id=r,c.async=!0,c.crossOrigin="anonymous",c.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`,n&&c.setAttribute("data-adbreak-test","on"),this.channelId&&c.setAttribute("data-ad-channel",this.channelId),document.head.appendChild(c),this.track("LoadAdsenseCompleted",null)}});this.push=(t={})=>{window.adsbygoogle.push(t)};this.wrapAdBreakParams=t=>{let r=!1,n=t.adBreakDone,i=d=>{var m;r=!0,this.adsActionDetection.adBreakIsShowing=!1,this.track("CallAdBreakDone",{breakType:d.breakType,breakName:(m=d.breakName)!=null?m:"",breakFormat:d.breakFormat,breakStatus:d.breakStatus}),n&&n(d)};if(t.adBreakDone=i,t.type==="reward"){let d=t.beforeReward,m=b=>()=>{this.track("CallShowAdFn",null),b()},p=b=>{r=!0,d&&d(m(b))};t.beforeReward=p,window.setTimeout(()=>{var b,g;r||(this.track("CallAdBreakTimeout",{type:t.type}),(g=t.adBreakDone)==null||g.call(t,{breakType:t.type,breakName:(b=t.name)!=null?b:"",breakFormat:"reward",breakStatus:"timeout"}))},5e3)}if((d=>d.type==="preroll")(t)){Pe.emit("isAdShowing",!0);let d=t.adBreakDone,m=p=>{Pe.emit("isAdShowing",!1),d&&d(p)};return z(V({},t),{adBreakDone:m})}else{let d=t.beforeAd,m=t.afterAd,p=()=>{var g;r=!0,Pe.emit("isAdShowing",!0),this.track("CallBeforeAd",{type:t.type,name:(g=t.name)!=null?g:""}),d&&d()},b=()=>{var g;r=!0,Pe.emit("isAdShowing",!1),this.track("CallAfterAd",{type:t.type,name:(g=t.name)!=null?g:""}),m&&m()};return z(V({},t),{beforeAd:p,afterAd:b})}};this.adConfig=t=>{let i=t,{onReady:r}=i,n=mn(i,["onReady"]);this.track("CallAdConfig",n),this.configured?console.warn("Ad config already set, skipping"):(this.configured=!0,this.push(t))};this.adBreak=t=>{var m,p,b,g,S,v;if(!this.getGameId()){console.warn("Game ID is not set, skip calling adBreak");return}if(t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){(m=t.adBreakDone)==null||m.call(t,{breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}let{reason:r,info:n}=this.antiCheating.checkAdsDisplayPermission(t.type==="reward"?"reward":"interstitial");switch(r){case"NETWORK_NOT_OK":case"BANNED_FOR_SESSION":(p=t.adBreakDone)==null||p.call(t,{breakType:t.type,breakName:r,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"}),this.antiCheating.report(r);return;case"BLOCK_INITIAL":case"BANNED_FOR_TIME":case"WAITING_BANNED_RELEASE":(b=t.adBreakDone)==null||b.call(t,{breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"}),this.antiCheating.report(r);return;case"HOLDING_HIGH_FREQ":(S=t.adBreakDone)==null||S.call(t,{breakFormat:t.type==="reward"?"reward":"interstitial",breakName:"",breakStatus:((g=n==null?void 0:n.count)!=null?g:0)>6?"other":"frequencyCapped",breakType:t.type}),n!=null&&n.count&&n.count!==0&&n.count%3===0&&this.antiCheating.report(r,n==null?void 0:n.count);return;default:break}let i=t.type,c;switch(i){case"preroll":c={type:i};break;case"start":case"pause":case"next":case"browse":case"reward":c={type:i,name:(v=t.name)!=null?v:""};break}this.adsActionDetection.adBreakIsShowing=!0,this.track("CallAdBreak",c);let d=this.wrapAdBreakParams(t);this.push(d),window.JoliTesterBridge&&console.log("joli-fullscreen-ad-show")};this.adUnit=t=>C(this,null,function*(){var v,I,O,D;if(this.track("CallAdUnit",{adFormat:(I=(v=t.adFormat)==null?void 0:v.toString())!=null?I:null,fullWidthResponsive:(O=t.fullWidthResponsive)!=null?O:null}),this.clientId||(yield this.asyncLoad()),document.querySelector("#jolibox-ads")){console.warn("Ad unit already set, skipping");return}let{el:r,slot:n,adFormat:i,fullWidthResponsive:c,style:d}=t,m;if(!r)throw new Error("targeting element is required");if(typeof r=="string"?m=document.querySelector(r):m=r,!m)throw new Error("targeting element not found");let p=n;if(p||(p=this.unitId),!p)throw new Error("slot is required");let b=typeof i=="object"&&Array.isArray(i)?i.join(", "):i,g=document.createElement("ins");if(g.className="adsbygoogle",g.id="jolibox-ads",g.style.display="block",g.setAttribute("data-ad-client",this.clientId),g.setAttribute("data-ad-slot",p),b&&g.setAttribute("data-ad-format",b),c&&g.setAttribute("data-full-width-responsive",c),d&&g.setAttribute("style",d),(D=this.getTestAdsMode())!=null?D:!1){let x=document.createElement("div");x.style.position="absolute",x.style.top="0",x.style.left="0",x.style.width="100%",x.style.height="100%",x.style.display="flex",x.style.justifyContent="center",x.style.alignItems="center",x.style.backgroundColor="rgba(0, 0, 0, 0.5)",x.style.color="white",x.innerHTML="Test Ad",g.style.position="relative",m.appendChild(g),g.appendChild(x)}else m.appendChild(g),new MutationObserver(P=>{P.forEach(H=>{if(H.type==="attributes"&&H.attributeName==="data-ad-status"){let F=g.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:F!=null?F:"null"})}})}).observe(g,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})});this.antiCheating=new Ot(t,r,n),this.adsActionDetection=new Pt(this.track),this.channelPolicy=new Dt(r)}init(t){this.track("CallAdsInit",null),typeof window!="undefined"&&(this.config=t!=null?t:{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}};Ee();$();Ke();var Mr=(e,t)=>{var r;window.dispatchEvent(new CustomEvent(e,{detail:t})),(r=window.parent)==null||r.postMessage({type:e,data:{detail:t}},"*")};ee();var po=A.testMode;function ho(){let e=new Map,t;return{registerRewardHandler(n,i){e.set(n,i)},handleReward(n,...i){return C(this,null,function*(){return yield n.reduce((d,m)=>C(this,null,function*(){let p=yield d;if(p===!0)return!0;po&&console.log(`handleReward ${m}`);let b=e.get(m),g=b?yield b(...i):p;return po&&console.log(`handleReward ${m} ${g}`),g}),Promise.resolve(!1))})},registerRewardsFetcher(n){return C(this,null,function*(){t=(...i)=>C(this,null,function*(){try{return yield n(...i)}catch(c){return console.error("getRewardOptions error:",c),["ADS"]}})})},getRewardsTypes(...n){return C(this,null,function*(){return t?yield t(...n):["ADS"]})}}}var as=()=>(e,t)=>e==="JOLI_COIN"&&t==="ADS"?-1:e==="ADS"&&t==="JOLI_COIN"?1:0,go=e=>{e.registerRewardsFetcher(t=>C(void 0,null,function*(){var n,i,c,d;let r=["ADS"];try{let m=yield t.post("/api/games/unlock-options",{});return m.code!=="SUCCESS"?r:(Ut.emit(Lt,{options:((n=m.data)==null?void 0:n.unlockOptions)||[],userJoliCoin:((i=m.extra)==null?void 0:i.joliCoin)||{balance:0,enableAutoDeduct:!1}}),(((d=(c=m.data)==null?void 0:c.unlockOptions)==null?void 0:d.map(b=>b.type))||Array.from(r)).sort(as()))}catch(m){return console.error("getRewardOptions error:",m),r}}))};$();var vo=e=>t=>C(void 0,null,function*(){return e.adBreak(t),!0});ee();$();var yo=(e,t)=>e.some(r=>r.type==="JOLI_COIN"&&r.joliCoinChoices.some(n=>{var i;return n.joliCoinQuantity<=((i=t==null?void 0:t.balance)!=null?i:0)&&!!(t!=null&&t.enableAutoDeduct)}));var bo=(e,{onUnlockSuccess:t,onUnlockFailed:r})=>{let n=null,i=null,c=null,d=()=>{if(c){n=Promise.resolve(c);return}n=new Promise(m=>{i=m})};return d(),Ut.on(Lt,m=>{c=m,i&&(i(m),i=null)}),m=>C(void 0,null,function*(){var p,b;try{n||d();let g=yield n;if(!yo((g==null?void 0:g.options)||[],g==null?void 0:g.userJoliCoin))return r==null||r(),!1;let S=yield e.post("/api/joli-coin/unlock",{data:{type:"GAME_REWARD",reqId:`${fr()}-${A.mpType}-${Date.now()}`,gameInfo:{gameId:A.mpId}}});return S.code=="SUCCESS"?(t==null||t({quantity:S.data.quantity,balance:S.data.balance}),(b=m.adBreakDone)==null||b.call(m,{breakType:m.type,breakName:"name"in m&&(p=m.name)!=null?p:"",breakFormat:"reward",breakStatus:"viewed"}),!0):(r==null||r(),!1)}catch(g){return console.error("JolicoinRewardHandler error:",g),r==null||r(),!1}})};var Oe=ho();go(Oe);var Lt="UNLOCK_OPTIONS_CHANGED",Ut=new de;var Ft=ae(),ss=ge.create(),Se=new Nt(fe,ss,()=>ge.getNetworkStatus());Oe.registerRewardHandler("ADS",vo(Se));Oe.registerRewardHandler("JOLI_COIN",bo(Se.httpClient,{onUnlockSuccess:e=>{Mr("JOLIBOX_CUSTOM_REWARDS_EVENT",{JOLI_COIN:e})}}));Pe.on("isAdShowing",e=>{Mr("JOLIBOX_ADS_EVENT",{isAdShowing:e})});Ft.registerCommand("AdsSDK.init",e=>{Se.init(e)});Ft.registerCommand("AdsSDK.adConfig",e=>{Se.adConfig(e)});Ft.registerCommand("AdsSDK.adBreak",e=>{e.type==="reward"?Oe.getRewardsTypes(Se.httpClient).then(t=>{Oe.handleReward(t,e)}):Se.adBreak(e)});Ft.registerCommand("AdsSDK.adUnit",e=>{Se.adUnit(e)});$();Ee();var So=-1,Mt=function(e){addEventListener("pageshow",function(t){t.persisted&&(So=t.timeStamp,e(t))},!0)},jr=function(){var e=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},$t=function(){var e=jr();return e&&e.activationStart||0},Ne=function(e,t){var r=jr(),n="navigate";return So>=0?n="back-forward-cache":r&&(document.prerendering||$t()>0?n="prerender":document.wasDiscarded?n="restore":r.type&&(n=r.type.replace(/_/g,"-"))),{name:e,value:t===void 0?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:n}},Ro=function(e,t,r){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var n=new PerformanceObserver(function(i){Promise.resolve().then(function(){t(i.getEntries())})});return n.observe(Object.assign({type:e,buffered:!0},r||{})),n}}catch(i){}},Le=function(e,t,r,n){var i,c;return function(d){t.value>=0&&(d||n)&&((c=t.value-(i||0))||i===void 0)&&(i=t.value,t.delta=c,t.rating=function(m,p){return m>p[1]?"poor":m>p[0]?"needs-improvement":"good"}(t.value,r),e(t))}},Ao=function(e){requestAnimationFrame(function(){return requestAnimationFrame(function(){return e()})})},ko=function(e){document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"&&e()})},xo=function(e){var t=!1;return function(){t||(e(),t=!0)}},De=-1,_o=function(){return document.visibilityState!=="hidden"||document.prerendering?1/0:0},Bt=function(e){document.visibilityState==="hidden"&&De>-1&&(De=e.type==="visibilitychange"?e.timeStamp:0,cs())},wo=function(){addEventListener("visibilitychange",Bt,!0),addEventListener("prerenderingchange",Bt,!0)},cs=function(){removeEventListener("visibilitychange",Bt,!0),removeEventListener("prerenderingchange",Bt,!0)},Co=function(){return De<0&&(De=_o(),wo(),Mt(function(){setTimeout(function(){De=_o(),wo()},0)})),{get firstHiddenTime(){return De}}},Vr=function(e){document.prerendering?addEventListener("prerenderingchange",function(){return e()},!0):e()},Eo=[1800,3e3],Po=function(e,t){t=t||{},Vr(function(){var r,n=Co(),i=Ne("FCP"),c=Ro("paint",function(d){d.forEach(function(m){m.name==="first-contentful-paint"&&(c.disconnect(),m.startTime<n.firstHiddenTime&&(i.value=Math.max(m.startTime-$t(),0),i.entries.push(m),r(!0)))})});c&&(r=Le(e,i,Eo,t.reportAllChanges),Mt(function(d){i=Ne("FCP"),r=Le(e,i,Eo,t.reportAllChanges),Ao(function(){i.value=performance.now()-d.timeStamp,r(!0)})}))})};var us=function(e){var t=self.requestIdleCallback||self.setTimeout,r=-1;return e=xo(e),document.visibilityState==="hidden"?e():(r=t(e),ko(e)),r};var Io=[2500,4e3],$r={},Oo=function(e,t){t=t||{},Vr(function(){var r,n=Co(),i=Ne("LCP"),c=function(p){t.reportAllChanges||(p=p.slice(-1)),p.forEach(function(b){b.startTime<n.firstHiddenTime&&(i.value=Math.max(b.startTime-$t(),0),i.entries=[b],r())})},d=Ro("largest-contentful-paint",c);if(d){r=Le(e,i,Io,t.reportAllChanges);var m=xo(function(){$r[i.id]||(c(d.takeRecords()),d.disconnect(),$r[i.id]=!0,r(!0))});["keydown","click"].forEach(function(p){addEventListener(p,function(){return us(m)},{once:!0,capture:!0})}),ko(m),Mt(function(p){i=Ne("LCP"),r=Le(e,i,Io,t.reportAllChanges),Ao(function(){i.value=performance.now()-p.timeStamp,$r[i.id]=!0,r(!0)})})}})},To=[800,1800],ls=function e(t){document.prerendering?Vr(function(){return e(t)}):document.readyState!=="complete"?addEventListener("load",function(){return e(t)},!0):setTimeout(t,0)},Do=function(e,t){t=t||{};var r=Ne("TTFB"),n=Le(e,r,To,t.reportAllChanges);ls(function(){var i=jr();i&&(r.value=Math.max(i.responseStart-$t(),0),r.entries=[i],n(!0),Mt(function(){r=Ne("TTFB",0),(n=Le(e,r,To,t.reportAllChanges))(!0)}))})};ee();function ds(){Po(e=>{fe("GameFCP",{value:e.value,rating:e.rating,navigationType:e.navigationType})}),Oo(e=>{fe("GameLCP",{value:e.value,rating:e.rating,navigationType:e.navigationType})}),Do(e=>{fe("GameTTFB",{value:e.value,rating:e.rating,navigationType:e.navigationType})})}function fs(){Je.on("onDocumentReady",e=>{Je.emit("LifecycleEvent.onReady",{isLogin:!1}),A.mpType==="game"&&le.start(Date.now()-e)})}function No(){fs(),ds()}No();
4
4
  /*! Bundled license information:
5
5
 
6
6
  localforage/dist/localforage.js:
@@ -1,4 +1,4 @@
1
- var ws=Object.create;var Ze=Object.defineProperty,Es=Object.defineProperties,ks=Object.getOwnPropertyDescriptor,xs=Object.getOwnPropertyDescriptors,Ss=Object.getOwnPropertyNames,Xe=Object.getOwnPropertySymbols,Ts=Object.getPrototypeOf,tr=Object.prototype.hasOwnProperty,gn=Object.prototype.propertyIsEnumerable;var _n=(e,t,r)=>t in e?Ze(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,w=(e,t)=>{for(var r in t||(t={}))tr.call(t,r)&&_n(e,r,t[r]);if(Xe)for(var r of Xe(t))gn.call(t,r)&&_n(e,r,t[r]);return e},O=(e,t)=>Es(e,xs(t));var Z=(e,t)=>{var r={};for(var n in e)tr.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Xe)for(var n of Xe(e))t.indexOf(n)<0&&gn.call(e,n)&&(r[n]=e[n]);return r};var x=(e,t)=>()=>(e&&(t=e(e=0)),t);var vn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),yn=(e,t)=>{for(var r in t)Ze(e,r,{get:t[r],enumerable:!0})},Is=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ss(t))!tr.call(e,o)&&o!==r&&Ze(e,o,{get:()=>t[o],enumerable:!(n=ks(t,o))||n.enumerable});return e};var bn=(e,t,r)=>(r=e!=null?ws(Ts(e)):{},Is(t||!e||!e.__esModule?Ze(r,"default",{value:e,enumerable:!0}):r,e));var y=(e,t,r)=>new Promise((n,o)=>{var i=l=>{try{a(r.next(l))}catch(c){o(c)}},s=l=>{try{a(r.throw(l))}catch(c){o(c)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(i,s);a((r=r.apply(e,t)).next())});function Ns(e){return!!(e!=null&&e.__nativeBuffers__)}function lr(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!Ns(e))return e;let t=e.__nativeBuffers__;if(delete e.__nativeBuffers__,t)for(let r=0;r<t.length;r++){let n=t[r];if(n){let o;n.value?o=n.value:n.base64&&(o=Ds(n.base64)),typeof o!="undefined"&&o instanceof ArrayBuffer&&(e[n.key]=o)}}return e}function Us(e={},t=!1){let r=e,n=[];for(let[o,i]of Object.entries(r))if(i!==void 0&&i instanceof ArrayBuffer&&i.byteLength!==void 0){let s=t?{value:i,key:o}:{base64:Ls(i),key:o};n.push(s),delete r[o]}return n.length>0&&(r.__nativeBuffers__=n),r}function Js(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function On(e){return typeof e=="string"}function Ue(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Vs(e){return typeof e=="undefined"}function Gs(e){return Vs(e)||e===null}function Nn(e){return typeof e=="function"}function qs(e){return Ue(e)&&Nn(e.then)}function Dn(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}function Le(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function oa(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}function la(e){return new Promise(t=>Ln(e)(t))}function Ln(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function ca(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(i.fire,i)}},i=new je(o);return i.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}function da(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)pa(e[n],t[n])}function pa(e,t){if(On(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Nn(t)){try{if(e instanceof t)return}catch(r){}if(!Gs(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function Sn(e,t){return`[${e}]:${t}`}function ga(e,t){Tn||(or=new tt({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(o){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),ir=new tt({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),sr=new tt({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),t("onJoliboxEnterBackground",()=>{or.flush(),ir.flush(),sr.flush()}),Tn=!0);function r(o){var i,s;let{method:a,args:l,startTime:c,isForeground:d,errMsg:u=`${a}:fail no errMsg`,errNo:p=0,__timing:m={receiveJSInvoke:0,invokeCallback:0}}=o,{receiveJSInvoke:v,invokeCallback:E}=m,h=(s=(i=u.match(/\S:(\S+)\s?/))==null?void 0:i[1])!=null?s:"fail";or.report({status:h,method:n(a,l),errNo:`${p}`,errMsg:u,isForeground:d,duration:Date.now()-c}),c&&v&&E&&(ir.report({status:h,method:a,isForeground:d,duration:Number((v-c).toFixed(3))}),sr.report({status:h,method:a,isForeground:d,duration:Number((Date.now()-E).toFixed(3))}))}function n(o,i){return(o==="callHostMethod"||o==="callHostMethodSync")&&i!=null&&i.method?`${o}-${i.method}`:o}return r}function ya(e,t){let r=0,n=!0,o=new Map,i=ga(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,ar.forEach(l=>fr(this,[l],function*({method:c,args:d,resolve:u}){let p=yield a(c,d);u(p)})),ar.length=0});let s=(l,c)=>{let d=o.get(Number(l));if(!d)return;let u=lr(c);d(u),o.delete(Number(l))},a=(l,c)=>{var d,u;let p=Date.now(),m=`${n}`;r+=1;let v=new Ks;if(o.set(r,v.resolve),!n&&fa.includes(l))return new Promise(A=>{ar.push({method:l,args:c,resolve:A})});let E=Ps(fe({},{method:l,startTime:p,args:c,isForeground:m}),{invokeType:"js-bridge"}),h=!va&&ma.includes(l),_=Us(c,h),b=h?_:JSON.stringify(_),T;if(l.endsWith("Sync")||ha.includes(l)?T=(d=e.call)==null?void 0:d.call(e,l,_,r):typeof b=="string"?T=e.invoke(l,b,r):T=(u=e.call)==null?void 0:u.call(e,l,b,r),T){try{typeof T=="string"&&(T=JSON.parse(T)),T=lr(T)}catch(A){_r.error(A)}return o.delete(r),T.errorCode&&(T.errorCode=Sn(l,T.errorCode)),i(fe(fe({},E),T)),T}return l.endsWith("Sync")&&o.delete(r),v.promise.then(A=>(A.errorCode&&(A.errorCode=Sn(l,A.errorCode)),i(fe(fe({},E),A)),A))};return{invokeNative:a,applyNative:(l,c)=>{let d=a(l,c);return qs(d)?d.then(u=>In(l,u)):In(l,d)},invokeHandler:s}}function In(e,t){if(!Ue(t)){_r.warn(`[Jolibox SDK]${e} no response value`);return}let r=t,{errMsg:n,errNo:o,errorType:i,errorCode:s}=r,a=Os(r,["errMsg","errNo","errorType","errorCode"]);if(n&&n!==`${e}:ok`)throw new Qs(n,o,i,s);return a}function ba(e){let t=new dr,r=new dr,n=new tt({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(o){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:o}),-1)}});return t.on("onJoliboxEnterBackground",()=>{n.flush()}),{onNative:t.on.bind(t),offNative:t.off.bind(t),subscribe:r.on.bind(r),unsubscribe:r.off.bind(r),subscribeHandler(o,i,s){let a=lr(i),l;if(a.__extra){l=a.params;let{type:c,startTime:d}=a.__extra;n.report({type:c,event:o,duration:Date.now()-d})}else l=a;if(o===Un){l.forEach(c=>{let[d,u]=c;try{r.emit(d.slice(Fe.length),u,s)}catch(p){}});return}if(o.startsWith(Fe)){r.emit(o.slice(Fe.length),l,s);return}t.emit(o,l,s)}}}function wa(e){let t=new Map,r;return(n,o,i,s)=>{if(s){let l=i?[i]:"*";e.publish(`${Fe}${n}`,o,l);return}r||(r=Promise.resolve().then(()=>{t.forEach((l,c)=>{try{let d=c?[c]:"*";e.publish(Un,l,d)}catch(d){}}),r=void 0,t.clear()}));let a=t.get(i);a||(a=[],t.set(i,a)),a.push([`${Fe}${n}`,o])}}function Ea(e){let{subscribeHandler:t,onNative:r,offNative:n,subscribe:o,unsubscribe:i}=ba(e),{invokeNative:s,invokeHandler:a,applyNative:l}=ya(e,r),c=wa(e);return{invokeHandler:a,subscribeHandler:t,applyNative:l,invokeNative:s,onNative:r,offNative:n,publish:c,subscribe:o,unsubscribe:i}}function Fn(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var Rs,As,Cs,rt,An,Cn,wn,fe,Ps,Os,fr,Ds,Ls,hr,Fs,En,js,Ms,kn,Bs,Hs,Pn,$s,Ks,Ws,zs,nt,Ys,Qs,Xs,rr,_r,Zs,ea,ta,ra,na,su,cr,L,ia,sa,et,je,dr,pr,aa,nr,ua,au,mr,xn,lu,Fe,ma,fa,ha,Un,_a,tt,Tn,or,ir,sr,ar,va,gr,ce,jn,Mn,ka,Bn,Rn,Y,N,re,cu,xa,Hn,uu,du,G=x(()=>{"use strict";Rs=Object.defineProperty,As=Object.defineProperties,Cs=Object.getOwnPropertyDescriptors,rt=Object.getOwnPropertySymbols,An=Object.prototype.hasOwnProperty,Cn=Object.prototype.propertyIsEnumerable,wn=(e,t,r)=>t in e?Rs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fe=(e,t)=>{for(var r in t||(t={}))An.call(t,r)&&wn(e,r,t[r]);if(rt)for(var r of rt(t))Cn.call(t,r)&&wn(e,r,t[r]);return e},Ps=(e,t)=>As(e,Cs(t)),Os=(e,t)=>{var r={};for(var n in e)An.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&rt)for(var n of rt(e))t.indexOf(n)<0&&Cn.call(e,n)&&(r[n]=e[n]);return r},fr=(e,t,r)=>new Promise((n,o)=>{var i=l=>{try{a(r.next(l))}catch(c){o(c)}},s=l=>{try{a(r.throw(l))}catch(c){o(c)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(i,s);a((r=r.apply(e,t)).next())});Ds=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=t.charCodeAt(o);return n.buffer};Ls=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let o=0;o<n;o++)t+=String.fromCharCode(r[o]);return btoa(t)};hr=Object.defineProperty,Fs=Object.getOwnPropertyDescriptor,En=Object.getOwnPropertySymbols,js=Object.prototype.hasOwnProperty,Ms=Object.prototype.propertyIsEnumerable,kn=(e,t,r)=>t in e?hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Bs=(e,t)=>{for(var r in t||(t={}))js.call(t,r)&&kn(e,r,t[r]);if(En)for(var r of En(t))Ms.call(t,r)&&kn(e,r,t[r]);return e},Hs=(e,t)=>{for(var r in t)hr(e,r,{get:t[r],enumerable:!0})},Pn=(e,t,r,n)=>{for(var o=n>1?void 0:n?Fs(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&hr(t,r,o),o},$s=(e,t,r)=>new Promise((n,o)=>{var i=l=>{try{a(r.next(l))}catch(c){o(c)}},s=l=>{try{a(r.throw(l))}catch(c){o(c)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(i,s);a((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}Ks=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};Ws=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Ws||{}),zs=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},nt=class extends zs{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Ys=class extends nt{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},Qs=class extends nt{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},Xs=class extends nt{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},rr=class extends nt{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}};_r={log:Le("log"),warn:Le("warn"),info:Le("info"),error:Le("error"),debug:Le("debug")};Object.assign(globalThis,{logger:_r});Zs=Symbol.for("Jolibox.canIUseMap"),ea={};globalThis[Zs]=ea;ta=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ta||{}),ra=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ra||{}),na=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(na||{});oa();su={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},cr=class ur{constructor(t){this.element=t,this.next=ur.Undefined,this.prev=ur.Undefined}};cr.Undefined=new cr(void 0);L=cr,ia=class{constructor(){this._first=L.Undefined,this._last=L.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===L.Undefined}clear(){let e=this._first;for(;e!==L.Undefined;){let t=e.next;e.prev=L.Undefined,e.next=L.Undefined,e=t}this._first=L.Undefined,this._last=L.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new L(e);if(this._first===L.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==L.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==L.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==L.Undefined&&e.next!==L.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===L.Undefined&&e.next===L.Undefined?(this._first=L.Undefined,this._last=L.Undefined):e.next===L.Undefined?(this._last=this._last.prev,this._last.next=L.Undefined):e.prev===L.Undefined&&(this._first=this._first.next,this._first.prev=L.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==L.Undefined;)yield e.element,e=e.next}},sa=0,et=class{constructor(e){this.value=e,this.id=sa++}},je=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof et&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,i,s,a,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new et(t);this._listeners?this._listeners instanceof et?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(s=(i=this.options)==null?void 0:i.onDidFirstListener)==null||s.call(i,this)),(l=(a=this.options)==null?void 0:a.onDidAddListener)==null||l.call(a,this),this._size++}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof et?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},dr=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new je,o=s=>t(...s.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let i=this.cachedEventQueue.get(e);if(i)for(;i.size>0;)n.fire(Bs({event:e},i.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new ia,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},pr={};Hs(pr,{None:()=>aa,filter:()=>ca,once:()=>Ln,toPromise:()=>la});aa=()=>{console.log("[Jolibox SDK] None Event")};nr=Symbol.for("Jolibox.hostEmitter"),ua=()=>{let e=new dr;return globalThis[nr]||(globalThis[nr]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[nr]},au=ua();mr=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new je,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return da(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};mr=Pn([Dn],mr);xn=class{constructor(){this._onWillExecuteCommand=new je,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new je,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new mr,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Js(3e4)),this._starActivation}executeCommand(e,...t){return $s(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),pr.toPromise(pr.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};xn=Pn([Dn],xn);lu=Symbol.for("Jolibox.commands");Fe="custom_event_",ma=[],fa=[],ha=["env","createRequestTask","login"],Un="__batch_event__",_a=e=>e==="pv"?e:"default",tt=class{constructor(e){this.interval=30,this.lastReportTime=0,this.cache={};let{reporter:t,interval:r=30,eventName:n,tagNameOrder:o,metricName:i,type:s}=e;this.reporter=t,this.interval=r,this.eventName=n,this.tagNameOrder=o,this.metricName=i,this.type=_a(s)}report(e){this.type==="pv"?this.addPVPoint(e):this.addPoint(e),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(e){if(Object.keys(this.cache).length){if(e){this.reporter(this.processPoints(this.cache)),this.clearPoints();return}this.lastReportTime=this.lastReportTime||Date.now(),Date.now()-this.lastReportTime>=this.interval*1e3&&(this.reporter(this.processPoints(this.cache)),this.clearPoints(),this.lastReportTime=Date.now())}}addPoint(e){let t=(r,n,o,i)=>{let s=n.shift();if(s){let a=i[s];r[a]||(r[a]={}),t(r[a],n,o,i)}else r[o]||(r[o]=[]),r[o].push(i[o])};t(this.cache,[...this.tagNameOrder],this.metricName,e)}addPVPoint(e){let t=(n,o,i,s)=>{let a=o.shift();if(!a&&Ue(s))throw new rr(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);if(a){let l=[];if(Ue(s))l.push(...Object.keys(s));else if(On(s)){if(o.length>0)throw new rr(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);l.push(s)}else throw new rr(`expected metric value to be a string, but got a(n) ${typeof s}, ${JSON.stringify(r)}`);l.forEach(c=>{n[c]||(n[c]={});let d=Ue(s)?s[c]:s;t(n[c],[...o],i,d)})}else n[i]?n[i]++:n[i]=1},r={point:e,metricName:this.metricName,tagNameOrder:this.tagNameOrder};t(this.cache,[...this.tagNameOrder],this.metricName,e)}processPoints(e){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:e}}clearPoints(){this.cache={}}},Tn=!1;ar=[],va=!1;ce={trigger(){},exit(){return Promise.resolve(!1)},onReady(e){ce.trigger=e},onDoExit(e){ce.exit=e}},jn=e=>{let t=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!t)e.onError(new Ys("native env failed"));else{let{data:r}=JSON.parse(t);return r!=null?r:void 0}};if(window.webkit){let e=window.webkit.messageHandlers,t=(o="")=>{ce.trigger(),e.onDocumentReady.postMessage({path:o})},r=o=>fr(void 0,null,function*(){let i=yield ce.exit();e.doExit.postMessage({uuid:o,shouldInterrupt:i})});gr={onDocumentReady:t,doExit:r,invoke(o,i,s){e.invoke.postMessage({event:o,paramsString:i,callbackId:s})},publish(o,i,s){let a=Fn(i,"joliboxJSCore");window.prompt("publish",JSON.stringify({event:o,paramsString:JSON.stringify(a),webviewIds:s}))},call(o,i,s){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(i),callbackId:s}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:jn,doExit:r};globalThis.joliboxJSCore=fe({},n)}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(o="")=>{ce.trigger(),e.onDocumentReady(JSON.stringify({path:o}))},r=o=>fr(void 0,null,function*(){let i=yield ce.exit();e.doExit(JSON.stringify({uuid:o,shouldInterrupt:i}))});gr={onDocumentReady:t,invoke(o,i,s){e.invoke(JSON.stringify({event:o,paramsString:i,callbackId:s}))},doExit:r,publish(o,i,s){let a=Fn(i,"joliboxJSCore");e.publish({event:o,paramsString:JSON.stringify(a),webviewIds:s})},call(o,i,s){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(i),callbackId:s}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:jn,doExit:r};globalThis.joliboxJSCore=fe({},n)}Mn=gr;if(!Mn)throw new Xs("No joliboxJScore is found, native bridge not found.");ka=fe({},Mn),Bn=Ea(ka),{invokeHandler:Rn}=Bn,{applyNative:Y,invokeNative:N,onNative:re,offNative:cu,subscribeHandler:xa,publish:Hn,subscribe:uu,unsubscribe:du}=Bn;globalThis.joliboxJSBridge={callHandler:Rn,invokeHandler:Rn,subscribeHandler:xa}});function Ca(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function He(e){return typeof e=="string"}function ye(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function qn(e){return typeof e=="object"&&Array.isArray(e)}function $e(e){return e===!0||e===!1}function Pa(e){return typeof e=="undefined"}function Oa(e){return Pa(e)||e===null}function Na(e){return typeof e=="function"}function Wn(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}function zn(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(o,i){for(let s in i)if(Object.prototype.hasOwnProperty.call(i,s)){let a=o[s],l=i[s],c=r(a,l,s,o,i);c!==void 0?o[s]=c:Kn(l)&&Kn(a)?o[s]=n(Vn({},a),l):Array.isArray(l)&&Array.isArray(a)?o[s]=[...a,...l]:o[s]=l}return o}return n(e,t)}function Kn(e){return e&&typeof e=="object"&&e.constructor===Object}function Yn(e,t){if(Array.isArray(e))return e.concat(t)}function Je(e,t,r={}){let n=null,o,i,s,{leading:a=!1,trailing:l=!0}=r,c=()=>(s=e.apply(i,o),o=void 0,i=void 0,s),d=function(...u){o=u,i=this;let p=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,l&&!p&&c()},t),p)return c()};return d.cancel=()=>{n&&clearTimeout(n),n=null,o=i=void 0},d.flush=()=>{if(n)return clearTimeout(n),n=null,c()},d}function La(e,t){return(...r)=>t(e,...r)}function at(e){return t=>La(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(o){e(new Ke(`${o}`))}})}function Me(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function Cr(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}function Wa(e){return new Promise(t=>oo(e)(t))}function oo(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function za(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(i.fire,i)}},i=new Be(o);return i.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}function Qa(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Xa(e[n],t[n])}function Xa(e,t){if(He(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Na(t)){try{if(e instanceof t)return}catch(r){}if(!Oa(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function Za(){return typeof globalThis!="undefined"?globalThis[io]:void 0}function el(e){typeof globalThis!="undefined"&&(globalThis[io]=e)}function j(){let e=Za();if(e)return e;let t=new st,r=new Er,n={registerCommand(o,i,s){t.registerCommand({id:o,handler:i,metadata:s})},executeCommand(o,...i){return r.executeCommand(o,...i)},excuteCommandSync(o,...i){return r.executeCommandThowErr(o,...i)}};return el(n),n}var kr,Sa,$n,Ta,Ia,Jn,Vn,Ra,Gn,Aa,he,Da,xr,Sr,Qn,Xn,Ke,Zn,eo,Ve,Tr,ne,to,Ua,Ir,Fa,Rr,ja,Ar,ot,Ma,Ba,Ha,ro,Pr,$a,Ja,Ka,no,yr,U,Va,Ga,it,Be,oe,wr,qa,vr,Ya,ue,st,Er,io,P=x(()=>{"use strict";kr=Object.defineProperty,Sa=Object.getOwnPropertyDescriptor,$n=Object.getOwnPropertySymbols,Ta=Object.prototype.hasOwnProperty,Ia=Object.prototype.propertyIsEnumerable,Jn=(e,t,r)=>t in e?kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Vn=(e,t)=>{for(var r in t||(t={}))Ta.call(t,r)&&Jn(e,r,t[r]);if($n)for(var r of $n(t))Ia.call(t,r)&&Jn(e,r,t[r]);return e},Ra=(e,t)=>{for(var r in t)kr(e,r,{get:t[r],enumerable:!0})},Gn=(e,t,r,n)=>{for(var o=n>1?void 0:n?Sa(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&kr(t,r,o),o},Aa=(e,t,r)=>new Promise((n,o)=>{var i=l=>{try{a(r.next(l))}catch(c){o(c)}},s=l=>{try{a(r.throw(l))}catch(c){o(c)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(i,s);a((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}he=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};Da=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Da||{}),xr=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Sr=class extends xr{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Qn=class extends xr{constructor(){super(...arguments),this.kind="USER_ERROR"}},Xn=class extends Qn{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Ke=class extends Qn{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Zn=class extends Sr{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},eo=class extends Sr{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Ve=class extends xr{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},Tr=class extends Sr{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};ne={log:Me("log"),warn:Me("warn"),info:Me("info"),error:Me("error"),debug:Me("debug")};Object.assign(globalThis,{logger:ne});to=Symbol.for("Jolibox.canIUseMap"),Ua={};globalThis[to]=Ua;Ir={get config(){return globalThis[to]}},Fa=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Fa||{}),Rr=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Rr||{}),ja=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(ja||{}),Ar=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});Cr();ot={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Ma=()=>ot.isiOS?"iOS":ot.isAndroid?"Android":ot.isMac?"Mac":ot.isFacebook?"Facebook":"PC",Ba="device_id",Ha="advertising_id",ro=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Ar()),window.__joliboxLocalStorage__.getItem(e)),Pr=()=>new URLSearchParams(window.location.search).get("deviceId")||ro(Ba),$a=()=>ro(Ha),Ja=e=>e.charAt(0).toUpperCase()+e.slice(1),Ka=()=>{var e;let t=new URLSearchParams(window.location.search);return Ja((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},no=e=>{let t="JoliboxWebSDK",r=Ma(),n=navigator.language,o=Pr(),i=$a();return`${t} (${Ka()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${i} version/${e||""}`},yr=class br{constructor(t){this.element=t,this.next=br.Undefined,this.prev=br.Undefined}};yr.Undefined=new yr(void 0);U=yr,Va=class{constructor(){this._first=U.Undefined,this._last=U.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===U.Undefined}clear(){let e=this._first;for(;e!==U.Undefined;){let t=e.next;e.prev=U.Undefined,e.next=U.Undefined,e=t}this._first=U.Undefined,this._last=U.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new U(e);if(this._first===U.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==U.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==U.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==U.Undefined&&e.next!==U.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===U.Undefined&&e.next===U.Undefined?(this._first=U.Undefined,this._last=U.Undefined):e.next===U.Undefined?(this._last=this._last.prev,this._last.next=U.Undefined):e.prev===U.Undefined&&(this._first=this._first.next,this._first.prev=U.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==U.Undefined;)yield e.element,e=e.next}},Ga=0,it=class{constructor(e){this.value=e,this.id=Ga++}},Be=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof it&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,i,s,a,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new it(t);this._listeners?this._listeners instanceof it?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(s=(i=this.options)==null?void 0:i.onDidFirstListener)==null||s.call(i,this)),(l=(a=this.options)==null?void 0:a.onDidAddListener)==null||l.call(a,this),this._size++}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof it?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},oe=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new Be,o=s=>t(...s.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let i=this.cachedEventQueue.get(e);if(i)for(;i.size>0;)n.fire(Vn({event:e},i.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Va,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},wr={};Ra(wr,{None:()=>qa,filter:()=>za,once:()=>oo,toPromise:()=>Wa});qa=()=>{console.log("[Jolibox SDK] None Event")};vr=Symbol.for("Jolibox.hostEmitter"),Ya=()=>{let e=new oe;return globalThis[vr]||(globalThis[vr]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[vr]},ue=Ya();st=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Be,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Qa(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};st=Gn([Wn],st);Er=class{constructor(){this._onWillExecuteCommand=new Be,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Be,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new st,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Ca(3e4)),this._starActivation}executeCommand(e,...t){return Aa(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),wr.toPromise(wr.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};Er=Gn([Wn],Er);io=Symbol.for("Jolibox.commands")});function K(e,t={}){Or.emit("ERROR_REPORT",{error:e,options:t})}var Or,be,ie=x(()=>{"use strict";P();P();Or=new oe,be=new oe;K.debounce=Je(K,50,{leading:!0})});var Nr,tl,so,ao,lo=x(()=>{"use strict";P();ie();Nr=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch(o){return{}}},tl=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},so=e=>{var t;try{let o=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(o!=null&&o.length){let[i,s,a]=o;return{headerJson:Nr(i),payloadJson:Nr(s),signature:Nr(a)}}else throw"joli_source is missing"}catch(r){return K(new Zn(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},ao=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],o=tl(e),i=r[2];return`${n}.${o}.${i}`}return t}});var rl,lt,co,Dr=x(()=>{"use strict";P();rl="1.1.13-beta.10",lt=()=>rl,co=()=>{let e=lt();return`${no(e)}`}});var nl,uo,Lr,po,V,ol,g,J=x(()=>{"use strict";P();lo();Dr();P();nl={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:Pr(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:lt()},schema:window.location.href,platform:"h5"},Lr=(uo=globalThis.joliboxJSCore)==null?void 0:uo.env,V=Object.assign({},(po=Lr==null?void 0:Lr())!=null?po:nl),ol=()=>{var p,m,v,E,h,_,b,T,A;let{payloadJson:e,headerJson:t,signature:r}=V.schema.length?so(V.schema):{},n=`${V.deviceInfo.did}-${new Date().getTime()}`,i=new URL(V.schema.length?V.schema:window.location.href).searchParams,s=(v=(m=(p=i.get("mpId"))!=null?p:i.get("appId"))!=null?m:i.get("gameId"))!=null?v:"",a=(_=(h=(E=V.clientSessionId)!=null?E:e==null?void 0:e.sessionId)!=null?h:i.get("sessionId"))!=null?_:n,l=!!((b=e==null?void 0:e.testAdsMode)!=null?b:i.get("testAdsMode")==="true"),c=(A=(T=e==null?void 0:e.joliboxEnv)!=null?T:i.get("joliboxEnv"))!=null?A:"production",d=c==="staging",u=t==null?void 0:t.channel;return{get testMode(){return d},get testAdsMode(){return l},get joliboxEnv(){return c},get joliSource(){var C;return(C=i.get("joliSource"))!=null?C:null},get mpId(){var C;return(C=s!=null?s:e==null?void 0:e.id)!=null?C:""},get mpVersion(){var C;return(C=t==null?void 0:t.ver)!=null?C:lt()},get mpType(){var C,k;return(k=(C=t==null?void 0:t.__mpType)!=null?C:e==null?void 0:e.__mpType)!=null?k:"game"},get platform(){var C;return(C=V.platform)!=null?C:V.deviceInfo.platform},get deviceInfo(){return V.deviceInfo},get sdkInfo(){return V.sdkInfo},get hostInfo(){return V.hostInfo},get hostUserInfo(){return V.hostUserInfo},get sessionId(){var C,k;return(k=(C=V.clientSessionId)!=null?C:a)!=null?k:n},get channel(){return u},get webviewId(){var C;return(C=V.webviewId)!=null?C:-1},get shouldInterupt(){return e==null?void 0:e.__shouldInterupt},get from(){return e==null?void 0:e.__from},get baseApiHost(){return d?"https://stg-api.jolibox.com":"https://api.jolibox.com"},onEnvConfigChanged:C=>{zn(V,C,Yn)},encodeJoliSourceQuery:C=>{var k,$;return t&&r?ao(w(w({},e),C),(k=i.get("joliSource"))!=null?k:""):($=i.get("joliSource"))!=null?$:""}}},g=ol()});var Ur,fo,il,sl,mo,al,ho=x(()=>{"use strict";P();ie();J();P();Ur=!1,fo=(e,t)=>e==null?!1:t in e,il=e=>fo(e,"kind"),sl=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},mo=(e,t={},r)=>{var i,s,a;let n={user_id:(s=(i=g.hostUserInfo)==null?void 0:i.uid)!=null?s:"",device_id:(a=g.deviceInfo.did)!=null?a:"",timestamp:Date.now(),tag:sl(e.name)},o=O(w({},n),{env:t.environment,isFromUser:r});r?be.emit("GLOBAL_USER_ERROR",e,o):be.emit("GLOBAL_ERROR",e,o)},al=e=>fo(e,"kind")&&e.kind==="USER_ERROR";Or.on("ERROR_REPORT",({error:e,options:t})=>{if(Ur)return;Ur=!0;let r=il(e)&&e.raw?e.raw:e;try{let n=al(e);mo(e,t,n)}catch(n){let o=n instanceof Error?n.message:String(n),i=new Tr(`${o}, origin error: ${r.message}`);ne.error(i),mo(new Tr(i.message),{environment:t.environment},!1)}finally{Ur=!1}})});var _e,Fr,Re=x(()=>{"use strict";ie();P();ie();_e=(e,t)=>{var r,n;return new Ve((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Fr=e=>new Xn(e)});var _o=x(()=>{"use strict";ho();Re();P();G();be.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};N("trackAsync",{event:"reportJsError",data:r})});be.on("GLOBAL_USER_ERROR",(e,t)=>{ne.log("UserError",e,t)})});var jr=x(()=>{"use strict"});function go(e,t){let r=(n,o,i)=>{let s=O(w({tag:n},t),{extra:w({},o)});n=="globalJsError"?K(new eo(JSON.stringify(s))):e("systemLog",s,i)};return r.debounce=Je(r,500,{leading:!0}),r}function vo(e){let t=(r,n,o)=>{var a;let i=(a=o&&JSON.stringify(o))!=null?a:0,s={speed_value_type:r,total_duration:n};i&&Object.assign(s,{extra:i}),e("joliboxSpeedAnalysis",s)};return t.debounce=Je(t,500,{leading:!0}),t}var yo=x(()=>{"use strict";P();P();ie()});function bo(e,t){let r=go(e,t),n=vo(r);return{track:r,trackPerformance:n}}var wo=x(()=>{"use strict";yo()});var Eo=x(()=>{"use strict";J();P();P()});var ko=x(()=>{"use strict";wo();jr();Eo()});var ct,xo=x(()=>{"use strict";ct=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,o,i=!1,s=0,a=()=>{if(!i)return;let m=Date.now(),v=m-r;v>=this.interval&&(this.visible&&(s+=v,t(s)),r=m),n=requestAnimationFrame(a)},l=()=>{d(),r=Date.now(),o=window.setInterval(()=>{if(!i)return;let m=Date.now();m-r>=this.interval&&(r=m)},this.interval)},c=()=>{u(),r=Date.now(),n=requestAnimationFrame(a)},d=()=>{n&&(cancelAnimationFrame(n),n=0)},u=()=>{o&&(clearInterval(o),o=0)};this.eventEmitter.on("visible",m=>{i&&(console.log("visible",m),m?c():l())});let p=this.visible;return{start(){i||(i=!0,p?c():l())},stop(){i=!1,d(),u()}}}}});var Mr=x(()=>{"use strict"});function To(e,t,r){let{response:n,startTime:o,endTime:i,requestFrom:s}=r,{errMsg:a="",profile:l={}}=n,d={duration:i-o,request_type:e,url:t.split("?")[0],result:r.state,error_msg:r.state==="fail"?a:"",socket_reused:l.socketReused?1:0,request_from:s};(s==="public"&&So<cl||s==="inner")&&(d.joli_request_number=So++,setTimeout(()=>{Q("joliboxNetRequestResult",d)},500))}var So,cl,Io=x(()=>{"use strict";Mr();ge();So=0,cl=10});function ut(e,t,r){var l,c,d;let n=new Map,o=(l=r==null?void 0:r.baseUrl)!=null?l:"https://api.jolibox.com",i=(c=r==null?void 0:r.type)!=null?c:"public",s=(d=r==null?void 0:r.defaultHeaders)!=null?d:{};return re("onRequestTaskStateChange",u=>{if(typeof u.requestTaskId!="string")return;let p=n.get(u.requestTaskId);if(p)if(u.state==="success"){let m=u,{requestTaskId:E,state:h}=m,_=Z(m,["requestTaskId","state"]);u.statusCode===200?p.resolve(_):p.reject(_),n.delete(E)}else if(u.state==="fail"){let v=u,{requestTaskId:E,state:h}=v,_=Z(v,["requestTaskId","state"]);p.reject(_),n.delete(E)}else ne.warn("onRequestTaskStateChange unknown event",u)}),ue.on("onLoginComplete",({isLogin:u,token:p})=>{u&&p&&(s["X-JOLI-TOKEN"]=p)}),(m,...v)=>y(this,[m,...v],function*(u,p={}){let E=Date.now(),h=ul(u,O(w({},p),{baseUrl:o})),{method:_="GET",responseType:b="text",dataType:T="json",timeout:A,enableCache:C=!1,appendHostCookie:k=!0}=p,$=Object.assign({"content-type":"application/json"},s,p.header),z={url:h,method:_,header:$,enableCache:C,responseType:b,appendHostCookie:k};if(_=="POST"||_=="PUT"){let te=pl(p.data,$["content-type"]);z.data=te}A&&Object.assign(z,{timeout:A});let{data:{requestTaskId:ae}}=N(e,z);if(typeof ae!="string")throw _e({code:-1,msg:"requestTaskId is not a string"});let Ie=(te,le)=>{To("request",h,{state:te,startTime:E,endTime:Date.now(),params:z,response:le,requestId:ae,requestFrom:i=="public"?"public":"inner"})},{resolve:X,reject:ve,promise:gs}=new he;n.set(ae,{resolve:X,reject:ve});try{let te=yield gs;Ie("success",te);let{data:le}=te;return T==="json"&&typeof le=="string"&&(le=dl(le)),{url:h,timeout:A,method:_,response:O(w({},te),{data:le})}}catch(te){let le=te;if(ye(le)){let{errMsg:Qe,prefetchDetail:vs,isPrefetch:ys,errNo:bs}=le;He(Qe)&&(Ie("fail",{errMsg:Qe,isPrefetch:ys,prefetchDetail:vs}),K(_e({code:-1,msg:Qe},{errNo:bs,errMsg:Qe})))}throw te}})}function dl(e){try{return JSON.parse(e.trim())}catch(t){return e}}function pl(e,t="application/json"){let r=t.toLowerCase();return e===void 0?"":typeof e=="string"||e instanceof ArrayBuffer?e:r.includes("application/x-www-form-urlencoded")||r.includes("application/json")||typeof e=="object"?JSON.stringify(e):String(e)}var ul,Br=x(()=>{"use strict";P();Io();Mr();G();ie();Re();ul=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t==null?void 0:t.query,o=new URLSearchParams(r).toString();return t!=null&&t.baseUrl?`${t.baseUrl}${e}${o?`?${o}`:""}`:`${e}${o?`?${o}`:""}`}});var Hr,Ro,q,Ae=x(()=>{"use strict";Dr();Br();J();Hr={"x-user-agent":co()};(Ro=g.hostUserInfo)!=null&&Ro.token&&(Hr["x-joli-token"]=g.hostUserInfo.token);g.joliSource&&(Hr["x-joli-source"]=g.joliSource);q=ut("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:g.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:Hr})});var dt,Ao=x(()=>{"use strict";J();xo();Ae();G();dt=class extends ct{constructor(t,r,n){super(r,n),this.gameId=g.mpId,this.sessionId=g.sessionId,this.track=t}reporter(t){return y(this,null,function*(){let{event:r,params:n}=t,o=[];o.push(q("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:w({gameId:this.gameId,sessionId:this.sessionId},n)}})),yield Promise.all(o)})}reportToNative(t){return y(this,null,function*(){let{event:r,params:n}=t;yield Y("userTrackAsync",{event:r,params:w({},n),gameId:this.gameId})})}tracker(t,r=null){this.track(t,r)}}});var Do={};yn(Do,{nativeTaskEmitter:()=>Ge,taskTracker:()=>W,track:()=>Q,trackPerformance:()=>Oo});var ml,Co,Po,Q,Oo,No,Ge,W,ge=x(()=>{"use strict";_o();P();jr();ko();J();Ao();G();ml=(e,t,r)=>{var s,a;let n=t,o=ye(n.extra)?n.extra:He(n.extra)?JSON.parse(n.extra):{},i=O(w({},o),{mp_id:(s=n.mp_id)!=null?s:"",mp_version:(a=n.mp_version)!=null?a:""});N("trackAsync",{event:e,data:i,webviewId:r})},{track:Q,trackPerformance:Oo}=bo(ml,{type:Rr.AppSDK,platform:"native",jssdk_version:(Po=(Co=g.sdkInfo)==null?void 0:Co.jssdkVersion)!=null?Po:"1.0.0",mp_id:g.mpId,mp_version:g.mpVersion}),No=j();No.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{Oo(e,t,r)});No.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{Q(e,t)});Ge=new oe,W=new dt(Q,Ge)});function Lo(){let e=null,t=window.fetch,r=()=>{e=document.createElement("style"),e.setAttribute("data-jolibox-sdk","default-styles");let i=`
1
+ var ws=Object.create;var Ze=Object.defineProperty,Es=Object.defineProperties,ks=Object.getOwnPropertyDescriptor,xs=Object.getOwnPropertyDescriptors,Ss=Object.getOwnPropertyNames,Xe=Object.getOwnPropertySymbols,Ts=Object.getPrototypeOf,tr=Object.prototype.hasOwnProperty,gn=Object.prototype.propertyIsEnumerable;var _n=(e,t,r)=>t in e?Ze(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,w=(e,t)=>{for(var r in t||(t={}))tr.call(t,r)&&_n(e,r,t[r]);if(Xe)for(var r of Xe(t))gn.call(t,r)&&_n(e,r,t[r]);return e},O=(e,t)=>Es(e,xs(t));var Z=(e,t)=>{var r={};for(var n in e)tr.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Xe)for(var n of Xe(e))t.indexOf(n)<0&&gn.call(e,n)&&(r[n]=e[n]);return r};var x=(e,t)=>()=>(e&&(t=e(e=0)),t);var vn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),yn=(e,t)=>{for(var r in t)Ze(e,r,{get:t[r],enumerable:!0})},Is=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ss(t))!tr.call(e,o)&&o!==r&&Ze(e,o,{get:()=>t[o],enumerable:!(n=ks(t,o))||n.enumerable});return e};var bn=(e,t,r)=>(r=e!=null?ws(Ts(e)):{},Is(t||!e||!e.__esModule?Ze(r,"default",{value:e,enumerable:!0}):r,e));var y=(e,t,r)=>new Promise((n,o)=>{var i=l=>{try{a(r.next(l))}catch(c){o(c)}},s=l=>{try{a(r.throw(l))}catch(c){o(c)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(i,s);a((r=r.apply(e,t)).next())});function Ns(e){return!!(e!=null&&e.__nativeBuffers__)}function lr(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!Ns(e))return e;let t=e.__nativeBuffers__;if(delete e.__nativeBuffers__,t)for(let r=0;r<t.length;r++){let n=t[r];if(n){let o;n.value?o=n.value:n.base64&&(o=Ds(n.base64)),typeof o!="undefined"&&o instanceof ArrayBuffer&&(e[n.key]=o)}}return e}function Us(e={},t=!1){let r=e,n=[];for(let[o,i]of Object.entries(r))if(i!==void 0&&i instanceof ArrayBuffer&&i.byteLength!==void 0){let s=t?{value:i,key:o}:{base64:Ls(i),key:o};n.push(s),delete r[o]}return n.length>0&&(r.__nativeBuffers__=n),r}function Js(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function On(e){return typeof e=="string"}function Ue(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Vs(e){return typeof e=="undefined"}function Gs(e){return Vs(e)||e===null}function Nn(e){return typeof e=="function"}function qs(e){return Ue(e)&&Nn(e.then)}function Dn(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}function Le(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function oa(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}function la(e){return new Promise(t=>Ln(e)(t))}function Ln(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function ca(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(i.fire,i)}},i=new je(o);return i.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}function da(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)pa(e[n],t[n])}function pa(e,t){if(On(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Nn(t)){try{if(e instanceof t)return}catch(r){}if(!Gs(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function Sn(e,t){return`[${e}]:${t}`}function ga(e,t){Tn||(or=new tt({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(o){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),ir=new tt({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),sr=new tt({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),t("onJoliboxEnterBackground",()=>{or.flush(),ir.flush(),sr.flush()}),Tn=!0);function r(o){var i,s;let{method:a,args:l,startTime:c,isForeground:d,errMsg:u=`${a}:fail no errMsg`,errNo:p=0,__timing:m={receiveJSInvoke:0,invokeCallback:0}}=o,{receiveJSInvoke:v,invokeCallback:E}=m,h=(s=(i=u.match(/\S:(\S+)\s?/))==null?void 0:i[1])!=null?s:"fail";or.report({status:h,method:n(a,l),errNo:`${p}`,errMsg:u,isForeground:d,duration:Date.now()-c}),c&&v&&E&&(ir.report({status:h,method:a,isForeground:d,duration:Number((v-c).toFixed(3))}),sr.report({status:h,method:a,isForeground:d,duration:Number((Date.now()-E).toFixed(3))}))}function n(o,i){return(o==="callHostMethod"||o==="callHostMethodSync")&&i!=null&&i.method?`${o}-${i.method}`:o}return r}function ya(e,t){let r=0,n=!0,o=new Map,i=ga(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,ar.forEach(l=>fr(this,[l],function*({method:c,args:d,resolve:u}){let p=yield a(c,d);u(p)})),ar.length=0});let s=(l,c)=>{let d=o.get(Number(l));if(!d)return;let u=lr(c);d(u),o.delete(Number(l))},a=(l,c)=>{var d,u;let p=Date.now(),m=`${n}`;r+=1;let v=new Ks;if(o.set(r,v.resolve),!n&&fa.includes(l))return new Promise(A=>{ar.push({method:l,args:c,resolve:A})});let E=Ps(fe({},{method:l,startTime:p,args:c,isForeground:m}),{invokeType:"js-bridge"}),h=!va&&ma.includes(l),_=Us(c,h),b=h?_:JSON.stringify(_),T;if(l.endsWith("Sync")||ha.includes(l)?T=(d=e.call)==null?void 0:d.call(e,l,_,r):typeof b=="string"?T=e.invoke(l,b,r):T=(u=e.call)==null?void 0:u.call(e,l,b,r),T){try{typeof T=="string"&&(T=JSON.parse(T)),T=lr(T)}catch(A){_r.error(A)}return o.delete(r),T.errorCode&&(T.errorCode=Sn(l,T.errorCode)),i(fe(fe({},E),T)),T}return l.endsWith("Sync")&&o.delete(r),v.promise.then(A=>(A.errorCode&&(A.errorCode=Sn(l,A.errorCode)),i(fe(fe({},E),A)),A))};return{invokeNative:a,applyNative:(l,c)=>{let d=a(l,c);return qs(d)?d.then(u=>In(l,u)):In(l,d)},invokeHandler:s}}function In(e,t){if(!Ue(t)){_r.warn(`[Jolibox SDK]${e} no response value`);return}let r=t,{errMsg:n,errNo:o,errorType:i,errorCode:s}=r,a=Os(r,["errMsg","errNo","errorType","errorCode"]);if(n&&n!==`${e}:ok`)throw new Qs(n,o,i,s);return a}function ba(e){let t=new dr,r=new dr,n=new tt({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(o){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:o}),-1)}});return t.on("onJoliboxEnterBackground",()=>{n.flush()}),{onNative:t.on.bind(t),offNative:t.off.bind(t),subscribe:r.on.bind(r),unsubscribe:r.off.bind(r),subscribeHandler(o,i,s){let a=lr(i),l;if(a.__extra){l=a.params;let{type:c,startTime:d}=a.__extra;n.report({type:c,event:o,duration:Date.now()-d})}else l=a;if(o===Un){l.forEach(c=>{let[d,u]=c;try{r.emit(d.slice(Fe.length),u,s)}catch(p){}});return}if(o.startsWith(Fe)){r.emit(o.slice(Fe.length),l,s);return}t.emit(o,l,s)}}}function wa(e){let t=new Map,r;return(n,o,i,s)=>{if(s){let l=i?[i]:"*";e.publish(`${Fe}${n}`,o,l);return}r||(r=Promise.resolve().then(()=>{t.forEach((l,c)=>{try{let d=c?[c]:"*";e.publish(Un,l,d)}catch(d){}}),r=void 0,t.clear()}));let a=t.get(i);a||(a=[],t.set(i,a)),a.push([`${Fe}${n}`,o])}}function Ea(e){let{subscribeHandler:t,onNative:r,offNative:n,subscribe:o,unsubscribe:i}=ba(e),{invokeNative:s,invokeHandler:a,applyNative:l}=ya(e,r),c=wa(e);return{invokeHandler:a,subscribeHandler:t,applyNative:l,invokeNative:s,onNative:r,offNative:n,publish:c,subscribe:o,unsubscribe:i}}function Fn(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var Rs,As,Cs,rt,An,Cn,wn,fe,Ps,Os,fr,Ds,Ls,hr,Fs,En,js,Ms,kn,Bs,Hs,Pn,$s,Ks,Ws,zs,nt,Ys,Qs,Xs,rr,_r,Zs,ea,ta,ra,na,su,cr,L,ia,sa,et,je,dr,pr,aa,nr,ua,au,mr,xn,lu,Fe,ma,fa,ha,Un,_a,tt,Tn,or,ir,sr,ar,va,gr,ce,jn,Mn,ka,Bn,Rn,Y,N,re,cu,xa,Hn,uu,du,G=x(()=>{"use strict";Rs=Object.defineProperty,As=Object.defineProperties,Cs=Object.getOwnPropertyDescriptors,rt=Object.getOwnPropertySymbols,An=Object.prototype.hasOwnProperty,Cn=Object.prototype.propertyIsEnumerable,wn=(e,t,r)=>t in e?Rs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fe=(e,t)=>{for(var r in t||(t={}))An.call(t,r)&&wn(e,r,t[r]);if(rt)for(var r of rt(t))Cn.call(t,r)&&wn(e,r,t[r]);return e},Ps=(e,t)=>As(e,Cs(t)),Os=(e,t)=>{var r={};for(var n in e)An.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&rt)for(var n of rt(e))t.indexOf(n)<0&&Cn.call(e,n)&&(r[n]=e[n]);return r},fr=(e,t,r)=>new Promise((n,o)=>{var i=l=>{try{a(r.next(l))}catch(c){o(c)}},s=l=>{try{a(r.throw(l))}catch(c){o(c)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(i,s);a((r=r.apply(e,t)).next())});Ds=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=t.charCodeAt(o);return n.buffer};Ls=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let o=0;o<n;o++)t+=String.fromCharCode(r[o]);return btoa(t)};hr=Object.defineProperty,Fs=Object.getOwnPropertyDescriptor,En=Object.getOwnPropertySymbols,js=Object.prototype.hasOwnProperty,Ms=Object.prototype.propertyIsEnumerable,kn=(e,t,r)=>t in e?hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Bs=(e,t)=>{for(var r in t||(t={}))js.call(t,r)&&kn(e,r,t[r]);if(En)for(var r of En(t))Ms.call(t,r)&&kn(e,r,t[r]);return e},Hs=(e,t)=>{for(var r in t)hr(e,r,{get:t[r],enumerable:!0})},Pn=(e,t,r,n)=>{for(var o=n>1?void 0:n?Fs(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&hr(t,r,o),o},$s=(e,t,r)=>new Promise((n,o)=>{var i=l=>{try{a(r.next(l))}catch(c){o(c)}},s=l=>{try{a(r.throw(l))}catch(c){o(c)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(i,s);a((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}Ks=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};Ws=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Ws||{}),zs=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},nt=class extends zs{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Ys=class extends nt{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},Qs=class extends nt{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},Xs=class extends nt{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},rr=class extends nt{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}};_r={log:Le("log"),warn:Le("warn"),info:Le("info"),error:Le("error"),debug:Le("debug")};Object.assign(globalThis,{logger:_r});Zs=Symbol.for("Jolibox.canIUseMap"),ea={};globalThis[Zs]=ea;ta=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ta||{}),ra=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ra||{}),na=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(na||{});oa();su={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},cr=class ur{constructor(t){this.element=t,this.next=ur.Undefined,this.prev=ur.Undefined}};cr.Undefined=new cr(void 0);L=cr,ia=class{constructor(){this._first=L.Undefined,this._last=L.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===L.Undefined}clear(){let e=this._first;for(;e!==L.Undefined;){let t=e.next;e.prev=L.Undefined,e.next=L.Undefined,e=t}this._first=L.Undefined,this._last=L.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new L(e);if(this._first===L.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==L.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==L.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==L.Undefined&&e.next!==L.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===L.Undefined&&e.next===L.Undefined?(this._first=L.Undefined,this._last=L.Undefined):e.next===L.Undefined?(this._last=this._last.prev,this._last.next=L.Undefined):e.prev===L.Undefined&&(this._first=this._first.next,this._first.prev=L.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==L.Undefined;)yield e.element,e=e.next}},sa=0,et=class{constructor(e){this.value=e,this.id=sa++}},je=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof et&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,i,s,a,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new et(t);this._listeners?this._listeners instanceof et?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(s=(i=this.options)==null?void 0:i.onDidFirstListener)==null||s.call(i,this)),(l=(a=this.options)==null?void 0:a.onDidAddListener)==null||l.call(a,this),this._size++}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof et?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},dr=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new je,o=s=>t(...s.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let i=this.cachedEventQueue.get(e);if(i)for(;i.size>0;)n.fire(Bs({event:e},i.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new ia,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},pr={};Hs(pr,{None:()=>aa,filter:()=>ca,once:()=>Ln,toPromise:()=>la});aa=()=>{console.log("[Jolibox SDK] None Event")};nr=Symbol.for("Jolibox.hostEmitter"),ua=()=>{let e=new dr;return globalThis[nr]||(globalThis[nr]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[nr]},au=ua();mr=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new je,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return da(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};mr=Pn([Dn],mr);xn=class{constructor(){this._onWillExecuteCommand=new je,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new je,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new mr,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Js(3e4)),this._starActivation}executeCommand(e,...t){return $s(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),pr.toPromise(pr.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};xn=Pn([Dn],xn);lu=Symbol.for("Jolibox.commands");Fe="custom_event_",ma=[],fa=[],ha=["env","createRequestTask","login"],Un="__batch_event__",_a=e=>e==="pv"?e:"default",tt=class{constructor(e){this.interval=30,this.lastReportTime=0,this.cache={};let{reporter:t,interval:r=30,eventName:n,tagNameOrder:o,metricName:i,type:s}=e;this.reporter=t,this.interval=r,this.eventName=n,this.tagNameOrder=o,this.metricName=i,this.type=_a(s)}report(e){this.type==="pv"?this.addPVPoint(e):this.addPoint(e),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(e){if(Object.keys(this.cache).length){if(e){this.reporter(this.processPoints(this.cache)),this.clearPoints();return}this.lastReportTime=this.lastReportTime||Date.now(),Date.now()-this.lastReportTime>=this.interval*1e3&&(this.reporter(this.processPoints(this.cache)),this.clearPoints(),this.lastReportTime=Date.now())}}addPoint(e){let t=(r,n,o,i)=>{let s=n.shift();if(s){let a=i[s];r[a]||(r[a]={}),t(r[a],n,o,i)}else r[o]||(r[o]=[]),r[o].push(i[o])};t(this.cache,[...this.tagNameOrder],this.metricName,e)}addPVPoint(e){let t=(n,o,i,s)=>{let a=o.shift();if(!a&&Ue(s))throw new rr(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);if(a){let l=[];if(Ue(s))l.push(...Object.keys(s));else if(On(s)){if(o.length>0)throw new rr(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);l.push(s)}else throw new rr(`expected metric value to be a string, but got a(n) ${typeof s}, ${JSON.stringify(r)}`);l.forEach(c=>{n[c]||(n[c]={});let d=Ue(s)?s[c]:s;t(n[c],[...o],i,d)})}else n[i]?n[i]++:n[i]=1},r={point:e,metricName:this.metricName,tagNameOrder:this.tagNameOrder};t(this.cache,[...this.tagNameOrder],this.metricName,e)}processPoints(e){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:e}}clearPoints(){this.cache={}}},Tn=!1;ar=[],va=!1;ce={trigger(){},exit(){return Promise.resolve(!1)},onReady(e){ce.trigger=e},onDoExit(e){ce.exit=e}},jn=e=>{let t=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!t)e.onError(new Ys("native env failed"));else{let{data:r}=JSON.parse(t);return r!=null?r:void 0}};if(window.webkit){let e=window.webkit.messageHandlers,t=(o="")=>{ce.trigger(),e.onDocumentReady.postMessage({path:o})},r=o=>fr(void 0,null,function*(){let i=yield ce.exit();e.doExit.postMessage({uuid:o,shouldInterrupt:i})});gr={onDocumentReady:t,doExit:r,invoke(o,i,s){e.invoke.postMessage({event:o,paramsString:i,callbackId:s})},publish(o,i,s){let a=Fn(i,"joliboxJSCore");window.prompt("publish",JSON.stringify({event:o,paramsString:JSON.stringify(a),webviewIds:s}))},call(o,i,s){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(i),callbackId:s}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:jn,doExit:r};globalThis.joliboxJSCore=fe({},n)}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(o="")=>{ce.trigger(),e.onDocumentReady(JSON.stringify({path:o}))},r=o=>fr(void 0,null,function*(){let i=yield ce.exit();e.doExit(JSON.stringify({uuid:o,shouldInterrupt:i}))});gr={onDocumentReady:t,invoke(o,i,s){e.invoke(JSON.stringify({event:o,paramsString:i,callbackId:s}))},doExit:r,publish(o,i,s){let a=Fn(i,"joliboxJSCore");e.publish({event:o,paramsString:JSON.stringify(a),webviewIds:s})},call(o,i,s){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(i),callbackId:s}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:jn,doExit:r};globalThis.joliboxJSCore=fe({},n)}Mn=gr;if(!Mn)throw new Xs("No joliboxJScore is found, native bridge not found.");ka=fe({},Mn),Bn=Ea(ka),{invokeHandler:Rn}=Bn,{applyNative:Y,invokeNative:N,onNative:re,offNative:cu,subscribeHandler:xa,publish:Hn,subscribe:uu,unsubscribe:du}=Bn;globalThis.joliboxJSBridge={callHandler:Rn,invokeHandler:Rn,subscribeHandler:xa}});function Ca(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function He(e){return typeof e=="string"}function ye(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function qn(e){return typeof e=="object"&&Array.isArray(e)}function $e(e){return e===!0||e===!1}function Pa(e){return typeof e=="undefined"}function Oa(e){return Pa(e)||e===null}function Na(e){return typeof e=="function"}function Wn(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}function zn(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(o,i){for(let s in i)if(Object.prototype.hasOwnProperty.call(i,s)){let a=o[s],l=i[s],c=r(a,l,s,o,i);c!==void 0?o[s]=c:Kn(l)&&Kn(a)?o[s]=n(Vn({},a),l):Array.isArray(l)&&Array.isArray(a)?o[s]=[...a,...l]:o[s]=l}return o}return n(e,t)}function Kn(e){return e&&typeof e=="object"&&e.constructor===Object}function Yn(e,t){if(Array.isArray(e))return e.concat(t)}function Je(e,t,r={}){let n=null,o,i,s,{leading:a=!1,trailing:l=!0}=r,c=()=>(s=e.apply(i,o),o=void 0,i=void 0,s),d=function(...u){o=u,i=this;let p=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,l&&!p&&c()},t),p)return c()};return d.cancel=()=>{n&&clearTimeout(n),n=null,o=i=void 0},d.flush=()=>{if(n)return clearTimeout(n),n=null,c()},d}function La(e,t){return(...r)=>t(e,...r)}function at(e){return t=>La(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(o){e(new Ke(`${o}`))}})}function Me(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function Cr(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}function Wa(e){return new Promise(t=>oo(e)(t))}function oo(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function za(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(i.fire,i)}},i=new Be(o);return i.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}function Qa(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Xa(e[n],t[n])}function Xa(e,t){if(He(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Na(t)){try{if(e instanceof t)return}catch(r){}if(!Oa(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function Za(){return typeof globalThis!="undefined"?globalThis[io]:void 0}function el(e){typeof globalThis!="undefined"&&(globalThis[io]=e)}function j(){let e=Za();if(e)return e;let t=new st,r=new Er,n={registerCommand(o,i,s){t.registerCommand({id:o,handler:i,metadata:s})},executeCommand(o,...i){return r.executeCommand(o,...i)},excuteCommandSync(o,...i){return r.executeCommandThowErr(o,...i)}};return el(n),n}var kr,Sa,$n,Ta,Ia,Jn,Vn,Ra,Gn,Aa,he,Da,xr,Sr,Qn,Xn,Ke,Zn,eo,Ve,Tr,ne,to,Ua,Ir,Fa,Rr,ja,Ar,ot,Ma,Ba,Ha,ro,Pr,$a,Ja,Ka,no,yr,U,Va,Ga,it,Be,oe,wr,qa,vr,Ya,ue,st,Er,io,P=x(()=>{"use strict";kr=Object.defineProperty,Sa=Object.getOwnPropertyDescriptor,$n=Object.getOwnPropertySymbols,Ta=Object.prototype.hasOwnProperty,Ia=Object.prototype.propertyIsEnumerable,Jn=(e,t,r)=>t in e?kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Vn=(e,t)=>{for(var r in t||(t={}))Ta.call(t,r)&&Jn(e,r,t[r]);if($n)for(var r of $n(t))Ia.call(t,r)&&Jn(e,r,t[r]);return e},Ra=(e,t)=>{for(var r in t)kr(e,r,{get:t[r],enumerable:!0})},Gn=(e,t,r,n)=>{for(var o=n>1?void 0:n?Sa(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&kr(t,r,o),o},Aa=(e,t,r)=>new Promise((n,o)=>{var i=l=>{try{a(r.next(l))}catch(c){o(c)}},s=l=>{try{a(r.throw(l))}catch(c){o(c)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(i,s);a((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}he=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};Da=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Da||{}),xr=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Sr=class extends xr{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Qn=class extends xr{constructor(){super(...arguments),this.kind="USER_ERROR"}},Xn=class extends Qn{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Ke=class extends Qn{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Zn=class extends Sr{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},eo=class extends Sr{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Ve=class extends xr{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},Tr=class extends Sr{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};ne={log:Me("log"),warn:Me("warn"),info:Me("info"),error:Me("error"),debug:Me("debug")};Object.assign(globalThis,{logger:ne});to=Symbol.for("Jolibox.canIUseMap"),Ua={};globalThis[to]=Ua;Ir={get config(){return globalThis[to]}},Fa=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Fa||{}),Rr=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Rr||{}),ja=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(ja||{}),Ar=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});Cr();ot={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Ma=()=>ot.isiOS?"iOS":ot.isAndroid?"Android":ot.isMac?"Mac":ot.isFacebook?"Facebook":"PC",Ba="device_id",Ha="advertising_id",ro=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Ar()),window.__joliboxLocalStorage__.getItem(e)),Pr=()=>new URLSearchParams(window.location.search).get("deviceId")||ro(Ba),$a=()=>ro(Ha),Ja=e=>e.charAt(0).toUpperCase()+e.slice(1),Ka=()=>{var e;let t=new URLSearchParams(window.location.search);return Ja((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},no=e=>{let t="JoliboxWebSDK",r=Ma(),n=navigator.language,o=Pr(),i=$a();return`${t} (${Ka()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${i} version/${e||""}`},yr=class br{constructor(t){this.element=t,this.next=br.Undefined,this.prev=br.Undefined}};yr.Undefined=new yr(void 0);U=yr,Va=class{constructor(){this._first=U.Undefined,this._last=U.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===U.Undefined}clear(){let e=this._first;for(;e!==U.Undefined;){let t=e.next;e.prev=U.Undefined,e.next=U.Undefined,e=t}this._first=U.Undefined,this._last=U.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new U(e);if(this._first===U.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==U.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==U.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==U.Undefined&&e.next!==U.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===U.Undefined&&e.next===U.Undefined?(this._first=U.Undefined,this._last=U.Undefined):e.next===U.Undefined?(this._last=this._last.prev,this._last.next=U.Undefined):e.prev===U.Undefined&&(this._first=this._first.next,this._first.prev=U.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==U.Undefined;)yield e.element,e=e.next}},Ga=0,it=class{constructor(e){this.value=e,this.id=Ga++}},Be=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof it&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,i,s,a,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new it(t);this._listeners?this._listeners instanceof it?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(s=(i=this.options)==null?void 0:i.onDidFirstListener)==null||s.call(i,this)),(l=(a=this.options)==null?void 0:a.onDidAddListener)==null||l.call(a,this),this._size++}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof it?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},oe=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new Be,o=s=>t(...s.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let i=this.cachedEventQueue.get(e);if(i)for(;i.size>0;)n.fire(Vn({event:e},i.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Va,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},wr={};Ra(wr,{None:()=>qa,filter:()=>za,once:()=>oo,toPromise:()=>Wa});qa=()=>{console.log("[Jolibox SDK] None Event")};vr=Symbol.for("Jolibox.hostEmitter"),Ya=()=>{let e=new oe;return globalThis[vr]||(globalThis[vr]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[vr]},ue=Ya();st=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Be,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Qa(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};st=Gn([Wn],st);Er=class{constructor(){this._onWillExecuteCommand=new Be,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Be,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new st,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Ca(3e4)),this._starActivation}executeCommand(e,...t){return Aa(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),wr.toPromise(wr.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};Er=Gn([Wn],Er);io=Symbol.for("Jolibox.commands")});function K(e,t={}){Or.emit("ERROR_REPORT",{error:e,options:t})}var Or,be,ie=x(()=>{"use strict";P();P();Or=new oe,be=new oe;K.debounce=Je(K,50,{leading:!0})});var Nr,tl,so,ao,lo=x(()=>{"use strict";P();ie();Nr=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch(o){return{}}},tl=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},so=e=>{var t;try{let o=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(o!=null&&o.length){let[i,s,a]=o;return{headerJson:Nr(i),payloadJson:Nr(s),signature:Nr(a)}}else throw"joli_source is missing"}catch(r){return K(new Zn(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},ao=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],o=tl(e),i=r[2];return`${n}.${o}.${i}`}return t}});var rl,lt,co,Dr=x(()=>{"use strict";P();rl="1.1.13-beta.11",lt=()=>rl,co=()=>{let e=lt();return`${no(e)}`}});var nl,uo,Lr,po,V,ol,g,J=x(()=>{"use strict";P();lo();Dr();P();nl={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:Pr(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:lt()},schema:window.location.href,platform:"h5"},Lr=(uo=globalThis.joliboxJSCore)==null?void 0:uo.env,V=Object.assign({},(po=Lr==null?void 0:Lr())!=null?po:nl),ol=()=>{var p,m,v,E,h,_,b,T,A;let{payloadJson:e,headerJson:t,signature:r}=V.schema.length?so(V.schema):{},n=`${V.deviceInfo.did}-${new Date().getTime()}`,i=new URL(V.schema.length?V.schema:window.location.href).searchParams,s=(v=(m=(p=i.get("mpId"))!=null?p:i.get("appId"))!=null?m:i.get("gameId"))!=null?v:"",a=(_=(h=(E=V.clientSessionId)!=null?E:e==null?void 0:e.sessionId)!=null?h:i.get("sessionId"))!=null?_:n,l=!!((b=e==null?void 0:e.testAdsMode)!=null?b:i.get("testAdsMode")==="true"),c=(A=(T=e==null?void 0:e.joliboxEnv)!=null?T:i.get("joliboxEnv"))!=null?A:"production",d=c==="staging",u=t==null?void 0:t.channel;return{get testMode(){return d},get testAdsMode(){return l},get joliboxEnv(){return c},get joliSource(){var C;return(C=i.get("joliSource"))!=null?C:null},get mpId(){var C;return(C=s!=null?s:e==null?void 0:e.id)!=null?C:""},get mpVersion(){var C;return(C=t==null?void 0:t.ver)!=null?C:lt()},get mpType(){var C,k;return(k=(C=t==null?void 0:t.__mpType)!=null?C:e==null?void 0:e.__mpType)!=null?k:"game"},get platform(){var C;return(C=V.platform)!=null?C:V.deviceInfo.platform},get deviceInfo(){return V.deviceInfo},get sdkInfo(){return V.sdkInfo},get hostInfo(){return V.hostInfo},get hostUserInfo(){return V.hostUserInfo},get sessionId(){var C,k;return(k=(C=V.clientSessionId)!=null?C:a)!=null?k:n},get channel(){return u},get webviewId(){var C;return(C=V.webviewId)!=null?C:-1},get shouldInterupt(){return e==null?void 0:e.__shouldInterupt},get from(){return e==null?void 0:e.__from},get baseApiHost(){return d?"https://stg-api.jolibox.com":"https://api.jolibox.com"},onEnvConfigChanged:C=>{zn(V,C,Yn)},encodeJoliSourceQuery:C=>{var k,$;return t&&r?ao(w(w({},e),C),(k=i.get("joliSource"))!=null?k:""):($=i.get("joliSource"))!=null?$:""}}},g=ol()});var Ur,fo,il,sl,mo,al,ho=x(()=>{"use strict";P();ie();J();P();Ur=!1,fo=(e,t)=>e==null?!1:t in e,il=e=>fo(e,"kind"),sl=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},mo=(e,t={},r)=>{var i,s,a;let n={user_id:(s=(i=g.hostUserInfo)==null?void 0:i.uid)!=null?s:"",device_id:(a=g.deviceInfo.did)!=null?a:"",timestamp:Date.now(),tag:sl(e.name)},o=O(w({},n),{env:t.environment,isFromUser:r});r?be.emit("GLOBAL_USER_ERROR",e,o):be.emit("GLOBAL_ERROR",e,o)},al=e=>fo(e,"kind")&&e.kind==="USER_ERROR";Or.on("ERROR_REPORT",({error:e,options:t})=>{if(Ur)return;Ur=!0;let r=il(e)&&e.raw?e.raw:e;try{let n=al(e);mo(e,t,n)}catch(n){let o=n instanceof Error?n.message:String(n),i=new Tr(`${o}, origin error: ${r.message}`);ne.error(i),mo(new Tr(i.message),{environment:t.environment},!1)}finally{Ur=!1}})});var _e,Fr,Re=x(()=>{"use strict";ie();P();ie();_e=(e,t)=>{var r,n;return new Ve((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Fr=e=>new Xn(e)});var _o=x(()=>{"use strict";ho();Re();P();G();be.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};N("trackAsync",{event:"reportJsError",data:r})});be.on("GLOBAL_USER_ERROR",(e,t)=>{ne.log("UserError",e,t)})});var jr=x(()=>{"use strict"});function go(e,t){let r=(n,o,i)=>{let s=O(w({tag:n},t),{extra:w({},o)});n=="globalJsError"?K(new eo(JSON.stringify(s))):e("systemLog",s,i)};return r.debounce=Je(r,500,{leading:!0}),r}function vo(e){let t=(r,n,o)=>{var a;let i=(a=o&&JSON.stringify(o))!=null?a:0,s={speed_value_type:r,total_duration:n};i&&Object.assign(s,{extra:i}),e("joliboxSpeedAnalysis",s)};return t.debounce=Je(t,500,{leading:!0}),t}var yo=x(()=>{"use strict";P();P();ie()});function bo(e,t){let r=go(e,t),n=vo(r);return{track:r,trackPerformance:n}}var wo=x(()=>{"use strict";yo()});var Eo=x(()=>{"use strict";J();P();P()});var ko=x(()=>{"use strict";wo();jr();Eo()});var ct,xo=x(()=>{"use strict";ct=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,o,i=!1,s=0,a=()=>{if(!i)return;let m=Date.now(),v=m-r;v>=this.interval&&(this.visible&&(s+=v,t(s)),r=m),n=requestAnimationFrame(a)},l=()=>{d(),r=Date.now(),o=window.setInterval(()=>{if(!i)return;let m=Date.now();m-r>=this.interval&&(r=m)},this.interval)},c=()=>{u(),r=Date.now(),n=requestAnimationFrame(a)},d=()=>{n&&(cancelAnimationFrame(n),n=0)},u=()=>{o&&(clearInterval(o),o=0)};this.eventEmitter.on("visible",m=>{i&&(console.log("visible",m),m?c():l())});let p=this.visible;return{start(){i||(i=!0,p?c():l())},stop(){i=!1,d(),u()}}}}});var Mr=x(()=>{"use strict"});function To(e,t,r){let{response:n,startTime:o,endTime:i,requestFrom:s}=r,{errMsg:a="",profile:l={}}=n,d={duration:i-o,request_type:e,url:t.split("?")[0],result:r.state,error_msg:r.state==="fail"?a:"",socket_reused:l.socketReused?1:0,request_from:s};(s==="public"&&So<cl||s==="inner")&&(d.joli_request_number=So++,setTimeout(()=>{Q("joliboxNetRequestResult",d)},500))}var So,cl,Io=x(()=>{"use strict";Mr();ge();So=0,cl=10});function ut(e,t,r){var l,c,d;let n=new Map,o=(l=r==null?void 0:r.baseUrl)!=null?l:"https://api.jolibox.com",i=(c=r==null?void 0:r.type)!=null?c:"public",s=(d=r==null?void 0:r.defaultHeaders)!=null?d:{};return re("onRequestTaskStateChange",u=>{if(typeof u.requestTaskId!="string")return;let p=n.get(u.requestTaskId);if(p)if(u.state==="success"){let m=u,{requestTaskId:E,state:h}=m,_=Z(m,["requestTaskId","state"]);u.statusCode===200?p.resolve(_):p.reject(_),n.delete(E)}else if(u.state==="fail"){let v=u,{requestTaskId:E,state:h}=v,_=Z(v,["requestTaskId","state"]);p.reject(_),n.delete(E)}else ne.warn("onRequestTaskStateChange unknown event",u)}),ue.on("onLoginComplete",({isLogin:u,token:p})=>{u&&p&&(s["X-JOLI-TOKEN"]=p)}),(m,...v)=>y(this,[m,...v],function*(u,p={}){let E=Date.now(),h=ul(u,O(w({},p),{baseUrl:o})),{method:_="GET",responseType:b="text",dataType:T="json",timeout:A,enableCache:C=!1,appendHostCookie:k=!0}=p,$=Object.assign({"content-type":"application/json"},s,p.header),z={url:h,method:_,header:$,enableCache:C,responseType:b,appendHostCookie:k};if(_=="POST"||_=="PUT"){let te=pl(p.data,$["content-type"]);z.data=te}A&&Object.assign(z,{timeout:A});let{data:{requestTaskId:ae}}=N(e,z);if(typeof ae!="string")throw _e({code:-1,msg:"requestTaskId is not a string"});let Ie=(te,le)=>{To("request",h,{state:te,startTime:E,endTime:Date.now(),params:z,response:le,requestId:ae,requestFrom:i=="public"?"public":"inner"})},{resolve:X,reject:ve,promise:gs}=new he;n.set(ae,{resolve:X,reject:ve});try{let te=yield gs;Ie("success",te);let{data:le}=te;return T==="json"&&typeof le=="string"&&(le=dl(le)),{url:h,timeout:A,method:_,response:O(w({},te),{data:le})}}catch(te){let le=te;if(ye(le)){let{errMsg:Qe,prefetchDetail:vs,isPrefetch:ys,errNo:bs}=le;He(Qe)&&(Ie("fail",{errMsg:Qe,isPrefetch:ys,prefetchDetail:vs}),K(_e({code:-1,msg:Qe},{errNo:bs,errMsg:Qe})))}throw te}})}function dl(e){try{return JSON.parse(e.trim())}catch(t){return e}}function pl(e,t="application/json"){let r=t.toLowerCase();return e===void 0?"":typeof e=="string"||e instanceof ArrayBuffer?e:r.includes("application/x-www-form-urlencoded")||r.includes("application/json")||typeof e=="object"?JSON.stringify(e):String(e)}var ul,Br=x(()=>{"use strict";P();Io();Mr();G();ie();Re();ul=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t==null?void 0:t.query,o=new URLSearchParams(r).toString();return t!=null&&t.baseUrl?`${t.baseUrl}${e}${o?`?${o}`:""}`:`${e}${o?`?${o}`:""}`}});var Hr,Ro,q,Ae=x(()=>{"use strict";Dr();Br();J();Hr={"x-user-agent":co()};(Ro=g.hostUserInfo)!=null&&Ro.token&&(Hr["x-joli-token"]=g.hostUserInfo.token);g.joliSource&&(Hr["x-joli-source"]=g.joliSource);q=ut("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:g.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:Hr})});var dt,Ao=x(()=>{"use strict";J();xo();Ae();G();dt=class extends ct{constructor(t,r,n){super(r,n),this.gameId=g.mpId,this.sessionId=g.sessionId,this.track=t}reporter(t){return y(this,null,function*(){let{event:r,params:n}=t,o=[];o.push(q("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:w({gameId:this.gameId,sessionId:this.sessionId},n)}})),yield Promise.all(o)})}reportToNative(t){return y(this,null,function*(){let{event:r,params:n}=t;yield Y("userTrackAsync",{event:r,params:w({},n),gameId:this.gameId})})}tracker(t,r=null){this.track(t,r)}}});var Do={};yn(Do,{nativeTaskEmitter:()=>Ge,taskTracker:()=>W,track:()=>Q,trackPerformance:()=>Oo});var ml,Co,Po,Q,Oo,No,Ge,W,ge=x(()=>{"use strict";_o();P();jr();ko();J();Ao();G();ml=(e,t,r)=>{var s,a;let n=t,o=ye(n.extra)?n.extra:He(n.extra)?JSON.parse(n.extra):{},i=O(w({},o),{mp_id:(s=n.mp_id)!=null?s:"",mp_version:(a=n.mp_version)!=null?a:""});N("trackAsync",{event:e,data:i,webviewId:r})},{track:Q,trackPerformance:Oo}=bo(ml,{type:Rr.AppSDK,platform:"native",jssdk_version:(Po=(Co=g.sdkInfo)==null?void 0:Co.jssdkVersion)!=null?Po:"1.0.0",mp_id:g.mpId,mp_version:g.mpVersion}),No=j();No.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{Oo(e,t,r)});No.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{Q(e,t)});Ge=new oe,W=new dt(Q,Ge)});function Lo(){let e=null,t=window.fetch,r=()=>{e=document.createElement("style"),e.setAttribute("data-jolibox-sdk","default-styles");let i=`
2
2
  html[data-jolibox-root] {
3
3
  height: 100%;
4
4
  margin: 0;
@@ -145,4 +145,4 @@ var ws=Object.create;var Ze=Object.defineProperty,Es=Object.defineProperties,ks=
145
145
  }
146
146
  `;let m=document.createElement("div");m.id="recommend-panel-content",u.appendChild(p),u.appendChild(m),s(u)}},[]);return Ee(()=>{if(i){let d=i.getElementById("recommend-panel-content");d&&Et(S("div",{className:"recommend-panel",children:S("div",{className:"container",children:[S("p",{className:"title",children:r}),S("div",{className:"games-container",children:S(Zl,{list:t||[],routeMode:"REDIRECT",layerName:"RecommendedGuide",onGameClick:l})}),S("div",{className:"buttons-container",children:S(Si,{children:S(Ti,{gutter:10,children:(n!=null?n:[]).map((u,p)=>S("div",{className:"button-wrapper",children:S("button",{className:`button ${u.type===Yr.Quit?"quit-button":"action-button"}`,onClick:()=>a(u),children:u.text})},p))})})})]})}),d)}},[i,t,r,n,a,l]),S("div",{ref:c})},Ii=e=>{let t=Gl({title:e.title,content:S(ec,{games:e.games,title:e.title,buttons:e.buttons,onClose:e.onClose}),backdropColor:"#1a1a1a",placement:"bottom",noHeader:!0,padding:"0px",onClose:()=>{console.log("onClose")},onOpen:e.onOpen});return t.show(),t},Ri=new Map,Ai=(e,t)=>{Ri.set(e,t)};Ai(/^\{slot-checkmark\}/,(e,t)=>{var n,o;let r=(o=(n=t==null?void 0:t.customStyle)==null?void 0:n.mark)!=null?o:{};return S("div",{style:r,children:S("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",style:{height:"24px",verticalAlign:"middle"},children:[S("g",{clipPath:"url(#clip0_2247_16523)",children:S("path",{d:"M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM9.29 16.29L5.7 12.7C5.31 12.31 5.31 11.68 5.7 11.29C6.09 10.9 6.72 10.9 7.11 11.29L10 14.17L16.88 7.29C17.27 6.9 17.9 6.9 18.29 7.29C18.68 7.68 18.68 8.31 18.29 8.7L10.7 16.29C10.32 16.68 9.68 16.68 9.29 16.29Z",fill:"white"})}),S("defs",{children:S("clipPath",{id:"clip0_2247_16523",children:S("rect",{width:"24",height:"24",fill:"white"})})})]})})});tc="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAUNSURBVHgBfVRZbFRlFP7+e+/cmc5MO22ntGALLZUWhoZFqBgaNUYJMUYehBgwJLw0wRd9MJr4AokvJibG6JtLoompkhgNBoNbERQqVEQLtdu0dN9nptPOcvft98xU3Kje5Cb3vzn/d77zfeccYO1HaG9vr0xlZz+ZvZXJ955TeO8XKh+5oPPRzrR29Uz8fbwCoRC31mW2FuB8PD3HRH/N2Od5NnDLQlmlH9x1sZhU4CvT0XpfEyyf4/GqTOqRp+tr6Y77X6BsfHz8QHip5ht3SBDKDwiYHbQQLpOQHxfBZA5XNFBRK8BeAT58bxg1tTvRtMPlXek32k69fOqnu0B7+3sfb9m+7bx+1hOVqAl3yYcQcei6MIW6xghEDvR0p7Dl3iiEsAxFtTD0M0PN1nUQxGXPt6N7z+HDh3v/DirM3VBc55KDymN+5PtcDAzE8djx3XCzXlE4z2LwvMILXO25DTvZBCE4jdR4GOLmEASW4kdfbBAplBdAhZFLWmLg41TVpr0yMotBhFsW0bprM7jDiyG8AOYUkAFSsnieT2ZIZwm2yjCbTmDDjgYEfcmRpoc3biu6l9fNyn2H6jC27IfujGJPbDOSoyZuXluEp5KGGgETU9ddBeREtyZajuu/TkLnLuoq6sCSDi686TbvPblXYjMzM+96c5UnHVPAwqCKfY9WgOc8pKYNhJqDEKW/1P/t8gx2xkhoKoARHRYETGaB2wJk2YNBMSNfxl+XskOR45lrHkp2SwhIGsxUhKI5bINDDgGDXy9CEFYZlkBG3/AcYg21xSSFfKGN1BkhAT7dh2Alw9Jk2QnJy/lDuXwWK/E8ttaFYemFeBGGSZnzHpqbN8AwXALlxI6kiLq48tU09u/ftCrFBCWv4bDggAUEuitVS4oKqNxACQsjq5oIqqVgzINJcuiaAEnhxUScSvZJDEYYUHQLhu5B9gRqJwZlhr6DHD5iHAoxJhTa5PbCFKrqXSTTBlRFgKLQiJDTjEpU6VujxJrGoVGCPJ0tGzDIQEsDsgs2cssckiPDyJFptUEIkai+MpdLY2XGT2DlyOXpIhnlwY9vO4Yhl7sINJqQa03och66IlEXEGPLo0TUOUmRxPJhflQl5jI+PZ9YYmN9I+8MXYk8m56S4VAvVkU8lAZLCwZT03P0x+NY11QB26YhIOrD8TEcanuoOAQyja2VJMbkvEjv8KSB7qvZV9nBgwdDR9o+U3p+nMATR6sR7wqhdbefSmZ/DpxEujHGV0eP9BbpHPSTniRVzpeCoMtY5AHc6Erwt75rEIXOzk7t0Ak+8dSx9ei+GMa2+1V0/7JEa0eH4VAHkLia5cIkpjZVYpMHkuRBT3m4nUlDTwcQ8PlQKjmIrlevFxMXZvWexsiWvFXGo5V9uPy9g/rmABYWJCgJEs01yWEKpHaSRAvqgo7pcR0TpgJTlxCRAmAxGRNZlZ/+qOXBAt6dJetVxfr2BNe1eEeeCSE1S5O0IYNl0tRwbFgKga3k4IvYsAMGFnUBAY+qipZAaKUBcDRvaPDMxjt79R9LuqPj7K6y/JM3t8dclpnIwsuEyXWvKENqDAhUu3Amy4uxWTuLTW1+XP9B8+T6K43PvXRkCv+z+cXBc4nemepALBD2CzHLQSBMeiYljI66uNjnoIbkMSYs9M+b/W93VO9EcRusvfnv+p9L5V6Dydt7LktRTSFzdMFzBCWRdCc/eP6FB07/Ecv/ffl3auuKkJv2jm0AAAAASUVORK5CYII=";Ai(/^\{slot-coin\}/,(e,t)=>{var n;let r=(n=t==null?void 0:t.coinImage)!=null?n:tc;return S("img",{src:r,alt:"\u{1FA99}",style:{height:"1em",verticalAlign:"middle"}})});rc=(e,t)=>{if(!e.includes("{slot-"))return e;let r=[],n=0;for(;n<e.length;){let o=null,i=1/0,s=null;for(let[a,l]of Ri.entries()){let c=a.source.startsWith("^")?a.source.slice(1):a.source,d=new RegExp(c,"g");d.lastIndex=n;let u=d.exec(e);u&&u.index<i&&(o=u,i=u.index,s=l)}if(o&&s)i>n&&r.push(e.substring(n,i)),r.push(s(o,t)),n=i+o[0].length;else{r.push(e.substring(n));break}}return r.length===1?r[0]:S("div",{style:{display:"flex",alignItems:"center",gap:"4px",color:"#FFF",fontFamily:'"PingFang SC"',fontSize:"16px",fontStyle:"normal",fontWeight:600,lineHeight:"18px",width:"max-content"},children:r})},nc=({message:e,type:t="info",duration:r=3e3,onClose:n})=>{let[o,i]=kt(!0);return Ee(()=>{let s=setTimeout(()=>{i(!1),setTimeout(()=>{n==null||n()},300)},r);return()=>clearTimeout(s)},[r,n]),S("div",{className:`toast toast-${t} ${o?"toast-visible":"toast-hidden"}`,style:{position:"fixed",top:"max(20px, env(safe-area-inset-top))",left:"50%",padding:"8px 12px",maxWidth:"min(85vw, 400px)",minWidth:"200px",width:"auto",background:t==="success"?"#4caf50":t==="error"?"#f44336":t==="warning"?"#ff9800":"#2F2F3B",color:"white",borderRadius:"8px",boxShadow:"0 2px 10px rgba(0, 0, 0, 0.2)",zIndex:9999,transition:"opacity 0.3s, transform 0.3s",opacity:o?1:0,transform:o?"translate(-50%, 0)":"translate(-50%, -20px)",textAlign:"center",wordWrap:"break-word"},children:e})},Ci=(e,t)=>{let r=document.createElement("div");document.body.appendChild(r);let n=()=>{document.body.removeChild(r)},o=rc(e,t);Et(S(nc,{message:o,type:t==null?void 0:t.type,duration:t==null?void 0:t.duration,onClose:n}),r)}});function Pi(){return y(this,null,function*(){if(nn)return nn;let t=`${g.testMode?"https://stg-game.jolibox.com":"https://game.jolibox.com"}/api/user-retention/exit-recommendations?objectId=${g.mpId}&from=GAME_DETAIL`,{response:{data:r}}=yield q(t);return nn=r,r})}function Oi(){return y(this,null,function*(){let e=new he;if(g.mpType!=="game")return e.resolve(!1),e.promise;let t=yield Pi();if(t.code!=="SUCCESS")return e.resolve(!1),e.promise;let{gameListInfo:r,title:n,buttons:o}=t.data,i=Ii({games:r.games,title:n,buttons:o,onClose:s=>{var a;switch(s.type){case"quit":e.resolve(!1);break;case"dismiss":e.resolve(!0),i.hide();break;case"navigate":(a=s.data)!=null&&a.game?oc(s.data.game):e.resolve(!0),i.hide();break;default:e.resolve(!0);break}}});return e.promise})}var nn,oc,Ni=x(()=>{"use strict";J();G();P();rn();Ae();nn=null;Pi();oc=e=>{var a;let{data:t}=N("envSync"),r=new URL(t.schema),n=r.pathname,o=new URLSearchParams(r.search);o.set("gameId",g.mpId),o.set("joliSource",g.encodeJoliSourceQuery({__mpType:"game",__orientation:(a=e.orientation)!=null?a:"VERTICAL"}));let s=`${`https://${e.gameId}.content.jolibox.com/`}${n}?${o.toString()}`;N("openSchemaSync",{schema:s})}});var Di={};yn(Di,{config:()=>dc});function ic(){Ce.on("isAdShowing",e=>{It=e,$e(It)&&N("updateContainerConfigSync",{displayCapsuleButton:!It,webviewId:g.webviewId})})}function sc(){ue.on("onDocumentReady",()=>{var e;(e=globalThis.joliboxJSCore)==null||e.onDocumentReady(window.location.href),Q("onDocumentReady",{start_timestamp:At,timestamp:Date.now()})})}function ac(e){g.mpType==="game"&&W.start(e)}function lc(){re("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&g.onEnvConfigChanged({hostUserInfo:e}),ue.emit("LifecycleEvent.onReady",w({},g.hostUserInfo?g.hostUserInfo:{isLogin:!1})),Q("joliboxServiceReady",{start_timestamp:At,timestamp:Date.now()}),ac(t)}),re("onBeforeExit",({uuid:e})=>{var t;(t=globalThis.joliboxJSCore)==null||t.doExit(e)})}function cc(){let e=()=>{Q("onBeforeExit",{timestamp:Date.now()}),Tt==null||Tt(),W.close(Date.now()-At)};ce.onDoExit(()=>y(this,null,function*(){return It?!0:$e(g.shouldInterupt)?(g.shouldInterupt||e(),g.shouldInterupt):Rt!=null&&Rt.canShowRecommended&&(yield Oi())?!0:(e(),!1)}))}function uc(){return y(this,null,function*(){let e=`${g.baseApiHost}/api/fe-configs/js-sdk/basic-meta`,{response:{data:t}}=yield q(e);t&&(Rt=t)})}function dc(){At=Date.now(),lc(),ic(),cc(),sc(),uc(),Tt=Lo()}var Tt,At,It,Rt,Li=x(()=>{"use strict";G();J();P();ge();Uo();$r();Ni();Ae();It=!1,Rt=null;ce.onReady(()=>{})});function Ui(e){let t=Ir.config[e];return t||(t={},Ir.config[e]=t),(r,n)=>{if(t[r]){ne.warn(`[can i use] ${r} already registered`);return}t[r]=w({},n)}}var Fi=x(()=>{"use strict";P()});function on(e){ji=e}function Ct(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Ct(t)):Object.keys(e).reduce((t,r)=>(t[r]=Ct(e[r]),t),{})}function me(e){return typeof e=="number"}function sn(e){let t=an(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function an(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var ji,B,Pt,Ot,Nt,Dt,Oe,Lt,Ut,Ft,jt,Mt,Bt,Ht,$t,Jt,Kt,Vt,Gt,ln=x(()=>{"use strict";ji=!1;B=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(ji)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${sn(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Ct(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Ct(this._default)}optional(){return this._optional=!0,this}};Pt=class extends B{validate(t){return this._optional&&t===void 0?!0:me(t)?me(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):me(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):me(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},Ot=class extends B{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Nt=class extends B{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(me(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(me(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},Dt=class extends B{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},Oe=class extends B{validate(t){return!0}},Lt=class extends B{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},Ut=class extends B{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Ft=class extends B{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},jt=class extends B{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(n=>JSON.stringify(n)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${sn(t)}`)}return!0}},Mt=class extends B{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(me(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(me(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(me(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let n=this._item;if(!n)return!0;let o=!0;if(r.forEach((i,s)=>{if(n.path=`${this.path}[${s}]`,n.errors=this.errors,i===void 0&&n.hasDefault){r[s]=n.defaultValue;return}n.validate(i)||(n.hasFallback?r[s]=n.fallbackValue:o=!1)}),this._uniqueItems){let i=new Map;for(let s in r)i.has(r[s])?o=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${i.get(r[s])}] and ${this.path}[${s}] are identical)`):i.set(r[s],s)}return o}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},Bt=class extends B{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(an(r)!=="object")return this.fail({expect:"object",actual:r});let o=r,i=this._value;i.errors=this.errors;let s=!0;for(let a in o){let l=o[a];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(a)?i.path=`${this.path}.${a}`:i.path=`${this.path}["${a}"]`,!(l===void 0&&i._optional)){if(l===void 0&&i.hasDefault){o[a]=i.defaultValue;continue}i.validate(l)||(i.hasFallback?o[a]=i.fallbackValue:s=!1)}}return s}},Ht=class extends B{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(an(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,o=!0;for(let i in this._object){let s=n[i],a=this._object[i];if(a.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(i)?a.path=`${this.path}.${i}`:a.path=`${this.path}["${i}"]`,!(a._optional&&s===void 0)){if(s===void 0&&a.hasDefault){n[i]=a.defaultValue;continue}a.validate(s)||(a.hasFallback?n[i]=a.fallbackValue:o=!1)}}return o}},$t=class extends B{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:sn(this.value),actual:r}):!0}},Jt=class extends B{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,o=this._items.length;for(let i=0;i<o;i++){let s=this._items[i];if(s.errors=[],s.path=this.path,!s.validate(t))r.push(s.errors.join("; "));else if(!n){n=!0;break}}if(!n){let i=r.join(`
147
147
  or `);this.errors.push(i)}return n}},Kt=class extends B{constructor(...t){super(),this._items=t;let r=0,n=t.length-1;for(;n>=0;n--){let o=t[n];if(o._optional||o.hasDefault)r+=1;else break}this._minItems=t.length-r}validate(t){if(t===void 0&&this._optional)return!0;if(!Array.isArray(t))return this.fail({expect:"array",actual:t});if(t.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let r=!0;return this._items.forEach((n,o)=>{if(n.path=`${this.path}[${o}]`,n.errors=this.errors,t[o]===void 0&&n.hasDefault){t[o]=n.defaultValue;return}n.validate(t[o])||(n.hasFallback?t[o]=n._fallback:r=!1)}),r}},Vt=class extends B{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},Gt=class extends B{constructor(t){super(),this._ctor=t}validate(t){return t===void 0&&this._optional||t instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:t})}}});function cn(e,t,r="param"){if(e.errors=[],e.path=r,on(!0),!e.validate(t)){let n=e.errors.join(`
148
- `);throw e.errors.length=0,on(!1),new TypeError(n)}}var f,un=x(()=>{"use strict";ln();ln();f={object(e){return new Ht(e)},array(e){return new Mt(e)},tuple(...e){return new Kt(...e)},literal(e){return new $t(e)},or(...e){return new Jt(...e)},symbol(){return new Dt},record(e){return new Bt(e)},function(){return new Ft},boolean(){return new Ot},string(){return new Nt},number(){return new Pt},undefined(){return new Lt},null(){return new Ut},unknown(){return new Oe},any(){return new Oe},as(){return new Oe},arraybuffer(){return new Vt},enum(...e){return new jt(...e)},typedarray(e){return new Gt(e)}}});var qt,Mi,Bi=x(()=>{"use strict";P();ie();un();Re();qt=1,Mi=e=>{function t(n,o){return(...i)=>{var u,p,m,v;let s=Date.now(),a={method:n,trace_id:qt};qt+=1;let l="SUCCESS",c=`${n}:ok`,d=0;try{if(o.paramsSchema)try{cn(o.paramsSchema,i,"params")}catch(b){throw Fr(`${n}:fail ${b.message}`)}let E=o.implement(...i),h=E,_=`${n}:ok`;if(E&&"code"in E){let{code:b,data:T,message:A}=E;l=b,h=T,_=A}return{code:l,message:_,data:h}}catch(E){let h=E;d=(p=(u=h.code)!=null?u:h.errNo)!=null?p:2e3,l="FAILURE";let _=(v=(m=h.message)!=null?m:h.errMsg)!=null?v:`${E}`;return c=`${n}:${l} ${_.replace(/^\S+:(fail|cancel)\s?/,"")}`,K(new Ve(c,d)),{code:l,message:c}}finally{let E=Date.now()-s;e("apiInvoked",O(w({},a),{duration:E,status:l}))}}}function r(n,o){return(...i)=>y(this,null,function*(){var p,m,v,E;let s=qn(i)?i:[i],a=Date.now(),l={method:n,trace_id:qt};qt+=1;let c=`${n}:ok`,d="SUCCESS",u={code:d,message:c};try{if(o.paramsSchema)try{cn(o.paramsSchema,s,"params")}catch(b){throw Fr(b.message)}let _=yield o.implement(...s);if(_&&"code"in _){let{code:b,data:T,message:A}=_;d=b,c=A,_=T}return Object.assign(u,{code:d,message:c,data:_}),u}catch(h){let _=h,b=(m=(p=_.code)!=null?p:_.errNo)!=null?m:2e3;d="FAILURE";let T=(E=(v=_.message)!=null?v:_.errMsg)!=null?E:`${h}`,A=`${n}:${d} ${T.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(u,{code:d,message:A}),K(new Ve(A,b)),u}finally{let h=Date.now()-a;e("apiInvoked",O(w({},l),{duration:h,status:d}))}})}return{createAPI:r,createSyncAPI:t}}});var H,D,R,se=x(()=>{"use strict";Fi();ge();Bi();un();({createAPI:H,createSyncAPI:D}=Mi(Q)),R=Ui("native")});var Hi,mc,fc,hc,_c,$i=x(()=>{"use strict";P();se();G();Hi=j(),mc="env",fc="getSystemInfoSync",hc=D(fc,{implement:()=>{var r;let e=N("envSync"),{data:t}=e;return{system:t.deviceInfo.system,platform:t.deviceInfo.platform.toLowerCase(),version:t.sdkInfo.jssdkVersion,pixelRatio:t.deviceInfo.pixelRatio,language:t.deviceInfo.lang,brand:t.deviceInfo.brand,appName:(r=t.hostInfo)==null?void 0:r.appName,SDKVersion:t.sdkInfo.jssdkVersion}}}),_c=D(mc,{implement:()=>{var t;let e=N("envSync");return(t=e==null?void 0:e.data)!=null?t:void 0}});Hi.registerCommand("API.getSystemInfoSync",hc);Hi.registerCommand("API.env",_c);R("env",{version:"1.0.0"});R("getSystemInfoSync",{version:"1.0.0"})});var Ji=vn(dn=>{"use strict";P();se();ie();G();ge();J();var gc="exitGame",vc="onReady",yc="onJoliboxShow",bc="onJoliboxHide",Wt=j(),zt=at(K),wc=H(gc,{paramsSchema:f.tuple(f.function(),f.boolean().optional().default(!1)),implement:(e,t=!1)=>y(dn,null,function*(){zt(e).call(dn),$e(g.shouldInterupt)&&!g.shouldInterupt&&g.from&&Hn("onRetentionResult",{shouldStay:t},g.from,!0),yield Y("exitAppAsync")})}),Ec=D(yc,{paramsSchema:f.tuple(f.function()),implement(e){let t=zt(e);re("onJoliboxEnterForeground",()=>{t.call(this),Ge.emit("visible",!0)})}}),kc=D(bc,{paramsSchema:f.tuple(f.function()),implement(e){let t=zt(e);re("onJoliboxEnterBackground",()=>{t.call(this),Ge.emit("visible",!1)})}}),xc=D(vc,{paramsSchema:f.tuple(f.function()),implement(e){let t=zt(e);ue.on("LifecycleEvent.onReady",r=>{t(r)})}});Wt.registerCommand("LifecycleSDK.exit",wc);Wt.registerCommand("LifecycleSDK.onReady",xc);Wt.registerCommand("LifecycleSDK.onJoliboxShow",Ec);Wt.registerCommand("LifecycleSDK.onJoliboxHide",kc);R("lifeCycle.exit",{version:"1.0.0"});R("lifeCycle.onReady",{version:"1.0.0"});R("lifeCycle.onJoliboxShow",{version:"1.0.0"});R("lifeCycle.onJoliboxHide",{version:"1.0.0"})});function Ki(e){let t={};if(!ye(e))return t;for(let[r,n]of Object.entries(e)){let o=r.toLocaleLowerCase();n?typeof n=="object"?t[o]=Object.prototype.toString.call(n):t[o]=String(n):t[o]=""}return t}function Vi(e="GET"){if(e==="")return"POST";let t=e.toUpperCase();return["GET","OPTIONS","HEAD","POST","PUT","DELETE","TRACE","CONNECT","PATCH"].includes(t)?t:"GET"}function Gi(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function qi(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!ye(r))return e;let[n,o=""]=e.split("?"),i=new URLSearchParams(o);for(let[a,l]of Object.entries(r))l!=null&&i.append(a,String(l));let s=i.toString();return s?`${n}?${s}`:n}var Wi=x(()=>{"use strict";P()});var Sc,Tc,pn,mn,zi,Ic,Rc,Ac,Yi=x(()=>{"use strict";Re();Br();se();Wi();P();ie();J();Sc=15,Tc=ut("createRequestTaskSync","operateRequestTaskSync",{type:"public",baseUrl:g.baseApiHost}),pn=0,mn=[],zi=at(K),Ic=(e,t)=>{let r=e.filter(t),n=e.filter(o=>!t(o));return e.length=0,e.push(...n),r},Rc=e=>{let t=new he,r=()=>{};return D("request",{paramsSchema:f.tuple(f.object({url:f.string(),method:f.string(),headers:f.object(),data:f.object().optional(),query:f.object().optional(),dataType:f.string().default("json"),responseType:f.string().default("text"),enableCache:f.boolean().default(!1),appendHostCookie:f.boolean().default(!0),timeout:f.number().default(3e4),success:f.function(),fail:f.function()})),implement(o){let i=()=>y(this,null,function*(){var a,l;let s=zi(o.fail);try{if(pn+=1,t.state!=="pending")return;let{data:c,dataType:d,responseType:u,enableCache:p,appendHostCookie:m}=o,v=Ki(o.headers),E=Vi(o.method),h=Gi(o.timeout),_=qi(o.url,E,c),b=zi(o.success),T=Object.assign({},o,{method:E,header:v,data:E==="GET"||E==="HEAD"?void 0:c,enableCache:p,query:(a=o.query)!=null?a:{},dataType:d,responseType:u,appendHostCookie:m});h&&(T.timeout=h);let A=Tc(_,T);{let{response:C}=yield A,{code:k,data:$,message:z}=C;if($&&typeof $=="object"&&"status"in $&&$.status!==200)throw _e({code:$.status||-1,msg:`request:fail status ${$.status}`});t.resolve({code:k!=null?k:"SUCCESS",data:$,message:z!=null?z:"request:ok"}),b({code:"SUCCESS",message:"request:ok",data:$})}}catch(c){t.reject(c),s({code:"FAILURE",message:"httpRequst: failed"})}finally{pn-=1,(l=mn.shift())==null||l()}});return pn>=Sc?(r=()=>{Ic(mn,s=>s===i)},mn.push(i)):i(),t.promise}})(e),{abort(){t.reject(_e({code:-1,msg:"request:fail abort"})),r()}}},Ac=j();Ac.registerCommand("HttpSDK.request",Rc);R("request",{version:"1.0.0"})});function Lc(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return Dc.includes(t)?t:""}function Uc(e,t){try{switch(t){case"string":return e;case"object":return JSON.parse(e);case"number":return parseFloat(e);case"boolean":return e==="true";default:return""}}catch(r){return""}}function Fc(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch(r){return""}}var Yt,Cc,Pc,Oc,Nc,rf,nf,Dc,Qi=x(()=>{"use strict";se();G();P();Ae();J();Yt=j(),Cc=H("getLocalStorage",{paramsSchema:f.tuple(f.string()),implement(e){return y(this,null,function*(){let{response:t}=yield q(`/api/games/user-storage/${g.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:o}}=yield t;if(r==="SUCCESS")return{code:r,message:n,data:o==null?void 0:o.value};try{let{data:{data:i,dataType:s}}=yield Y("getLocalStorageAsync",{key:e}),a=Uc(i,s);return{code:r,message:`${n}. fallback to native`,data:a}}catch(i){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}})}});Yt.registerCommand("StorageSDK.getItem",Cc);R("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});Pc=H("setStorage",{paramsSchema:f.tuple(f.string(),f.or(f.string(),f.boolean(),f.number())),implement(e,t){return y(this,null,function*(){let r=g.mpId,n=typeof t=="string"?t:String(t),{response:o}=yield q(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:i,message:s}}=o,a=Lc(t),l=Fc(t,a);return yield Y("setLocalStorageAsync",{key:e,data:l,dataType:a}),i=="SUCCESS"?{code:i,message:s}:{code:i,message:`${s}. fallback to native`}})}});Yt.registerCommand("StorageSDK.setItem",Pc);R("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});Oc=H("removeStorage",{paramsSchema:f.tuple(f.string()),implement(e){return y(this,null,function*(){let t=g.mpId,{response:r}=yield q(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:o}}=r;return yield Y("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:o}:{code:n,message:"[Jolibox SDK] remove item succ"}})}});Yt.registerCommand("StorageSDK.removeItem",Oc);R("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});Nc=H("clearStorage",{implement(){return y(this,null,function*(){let e=g.mpId,{response:t}=yield q(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});Y("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}})}});Yt.registerCommand("StorageSDK.clear",Nc);R("storage.clear",{version:"1.0.0"});rf=H("getStorageInfo",{implement(){return y(this,null,function*(){let{data:e}=yield Y("getStorageInfoAsync");return e})}});R("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});nf=D("getStorageInfoSync",{implement(){return N("getStorageInfoSync")}}),Dc=["string","number","boolean","object",""]});var jc,Mc,Bc,fn,Xi=x(()=>{"use strict";P();G();se();jc=D("showKeyboard",{paramsSchema:f.tuple(f.object({defaultValue:f.string().optional().default(""),multiple:f.boolean().optional().default(!1),maxLength:f.unknown().optional().default(1e5)})),implement(e){var n;let t=Math.floor((n=Number(e.maxLength))!=null?n:1e5),{defaultValue:r}=e;r&&t&&(r=r.slice(0,t)),N("showKeyboardSync",O(w({},e),{defaultValue:r,maxLength:t}))}});R("keyboard.showKeyboard",{version:"1.0.0",properties:{params:{defaultValue:"1.0.0",multiple:"1.0.0",confirmHold:"1.0.0",confirmType:"1.0.0",maxLength:"1.0.0"}},success:{errMsg:"1.0.0"}});Mc=D("updateKeyboard",{paramsSchema:f.tuple(f.object({value:f.string()})),implement(e){N("updateKeyboardSync",e)}});R("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});Bc=D("hideKeyboard",{implement(){N("hideKeyboardSync")}});R("keyboard.hideKeyboard",{version:"1.0.0"});fn=j();fn.registerCommand("KeyboardSDK.showKeyboard",jc);fn.registerCommand("KeyboardSDK.updateKeyboard",Mc);fn.registerCommand("KeyboardSDK.hideKeyboard",Bc)});var Zi=vn(Se=>{"use strict";P();se();ge();var Ne=j(),Hc=H("levelFinished",{paramsSchema:f.tuple(f.string(),f.object({result:f.boolean(),duration:f.number()})),implement:(e,t)=>y(Se,null,function*(){let{result:r,duration:n}=t,o=[];o.push(W.tracker("LevelFinished",{levelId:e,result:r,duration:n})),o.push(W.reporter({event:"COMPLETE_GAME_LEVEL"})),yield Promise.all(o)})}),$c=H("taskFinished",{paramsSchema:f.tuple(f.string(),f.object({duration:f.number()})),implement:(e,t)=>y(Se,null,function*(){let{duration:r}=t;return yield W.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})})}),Jc=H("levelUpgrade",{paramsSchema:f.tuple(f.string(),f.string()),implement:(e,t)=>y(Se,null,function*(){let r=[];r.push(W.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),yield Promise.all(r)})}),Kc=H("onHistoryUserLevel",{paramsSchema:f.tuple(f.number()),implement:e=>y(Se,null,function*(){return yield W.reportToNative({event:"HistoryUserLevel",params:{level:e}})})}),Vc=H("onHistoryUserScore",{paramsSchema:f.tuple(f.number()),implement:e=>y(Se,null,function*(){return yield W.reportToNative({event:"HistoryUserScore",params:{score:e}})})}),Gc=H("taskEvent",{paramsSchema:f.tuple(f.string(),f.object({tools:f.array(f.object({id:f.string(),name:f.string(),count:f.number(),description:f.string().optional(),price:f.object({amount:f.number(),unit:f.string()}).optional()})).optional(),awards:f.array(f.object({id:f.string(),name:f.string()})).optional()})),implement:(e,t)=>y(Se,null,function*(){var n,o;let r=[];r.push(W.reportToNative({event:"TaskEvent",params:w({taskId:e},t)})),(o=(n=t.tools)==null?void 0:n.length)!=null&&o&&(r.push(W.reporter({event:"USE_GAME_ITEM"})),r.push(W.reportToNative({event:"UseGameItem",params:w({taskId:e},t)}))),yield Promise.all(r)})});Ne.registerCommand("TaskTrackerSDK.levelFinished",Hc);Ne.registerCommand("TaskTrackerSDK.taskFinished",$c);Ne.registerCommand("TaskTrackerSDK.levelUpgrade",Jc);Ne.registerCommand("TaskTrackerSDK.historyUserLevel",Kc);Ne.registerCommand("TaskTrackerSDK.historyUserScore",Vc);Ne.registerCommand("TaskTrackerSDK.taskEvent",Gc);R("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});R("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});R("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});R("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});R("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});R("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}})});var qc,Wc,es,ts=x(()=>{"use strict";J();G();se();P();Re();R("login",{version:"1.0.0",properties:{force:"1.0.0"},success:{errMsg:"1.0.0",code:"1.0.0",token:"1.0.0",isLogin:"1.0.0"}});R("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});qc=H("login",{implement(){return y(this,null,function*(){var s;let{data:{isLogin:e}}=yield Y("checkLoginAsync");if(e)return{isLogin:!0,token:(s=g.hostUserInfo)==null?void 0:s.token};re("onLoginStateChange",({isLogin:a,token:l,uuid:c})=>{c==r&&o({isLogin:a,token:l})});let t=N("loginSync"),{data:{uuid:r}}=t;if(!r)throw _e({code:-1,msg:"login failed"});let{promise:n,resolve:o}=new he,i=yield n;return g.onEnvConfigChanged({hostUserInfo:i}),ue.emit("onLoginComplete",i),i})}}),Wc=H("checkSession",{implement(){return y(this,null,function*(){let{data:{isLogin:e}}=yield Y("checkLoginAsync");return{isLogin:e}})}}),es=j();es.registerCommand("API.login",qc);es.registerCommand("API.checkSession",Wc)});function ns(){let e=new Map,t;return{registerRewardHandler(n,o){e.set(n,o)},handleReward(n,...o){return y(this,null,function*(){return yield n.reduce((s,a)=>y(this,null,function*(){let l=yield s;if(l===!0)return!0;rs&&console.log(`handleReward ${a}`);let c=e.get(a),d=c?yield c(...o):l;return rs&&console.log(`handleReward ${a} ${d}`),d}),Promise.resolve(!1))})},registerRewardsFetcher(n){return y(this,null,function*(){t=(...o)=>y(this,null,function*(){try{return yield n(...o)}catch(i){return console.error("getRewardOptions error:",i),["ADS"]}})})},getRewardsTypes(...n){return y(this,null,function*(){return t?yield t(...n):["ADS"]})}}}var rs,os=x(()=>{"use strict";J();rs=g.testMode});var zc,is,ss=x(()=>{"use strict";Zt();zc=()=>(e,t)=>e==="JOLI_COIN"&&t==="ADS"?-1:e==="ADS"&&t==="JOLI_COIN"?1:0,is=e=>{e.registerRewardsFetcher(t=>y(void 0,null,function*(){var i,s,a,l;let r=[],n=yield t.post("/api/games/unlock-options",{});return n.code!=="SUCCESS"?r:(Xt.emit(Qt,{options:((i=n.data)==null?void 0:i.unlockOptions)||[],userJoliCoin:((s=n.extra)==null?void 0:s.joliCoin)||{balance:0,enableAutoDeduct:!1}}),(((l=(a=n.data)==null?void 0:a.unlockOptions)==null?void 0:l.map(c=>c.type))||Array.from(r)).sort(zc()))}))}});var as,ls=x(()=>{"use strict";as=e=>t=>y(void 0,null,function*(){return e.adBreak(t),!0})});var cs,us=x(()=>{"use strict";cs=(e,t)=>e.some(r=>r.type==="JOLI_COIN"&&r.joliCoinChoices.some(n=>{var o;return n.joliCoinQuantity<=((o=t==null?void 0:t.balance)!=null?o:0)&&!!(t!=null&&t.enableAutoDeduct)}))});var ds,ps=x(()=>{"use strict";J();P();us();Zt();ds=(e,{onUnlockSuccess:t,onUnlockFailed:r})=>{let n=null,o=null,i=null,s=()=>{if(i){n=Promise.resolve(i);return}n=new Promise(a=>{o=a})};return s(),Xt.on(Qt,a=>{i=a,o&&(o(a),o=null)}),()=>y(void 0,null,function*(){try{n||s();let a=yield n;if(!cs((a==null?void 0:a.options)||[],a==null?void 0:a.userJoliCoin))return r==null||r(),!1;let l=yield e.post("/api/joli-coin/unlock",{data:{type:"GAME_REWARD",reqId:`${Ar()}-${g.mpType}-${Date.now()}`,gameInfo:{gameId:g.mpId}}});return l.code=="SUCCESS"?(t==null||t({quantity:l.data.quantity,balance:l.data.balance}),!0):(r==null||r(),!1)}catch(a){return console.error("JolicoinRewardHandler error:",a),r==null||r(),!1}})}});var De,Qt,Xt,Zt=x(()=>{"use strict";os();ss();P();ls();ps();De=ns();is(De);Qt="UNLOCK_OPTIONS_CHANGED",Xt=new oe});var er,Yc,Te,Qc,Xc,Zc,eu,ms=x(()=>{"use strict";P();se();rn();$r();ge();Ae();G();Zt();er=j(),Yc=()=>{let{data:e}=N("getNetworkStatusSync");return!!(e!=null&&e.isConnected)},Te=new ht(Q,{get:(e,t)=>q(e,w({method:"GET",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data),post:(e,t,r)=>q(e,w({method:"POST",responseType:"json",appendHostCookie:!0},r)).then(n=>n.response.data)},Yc);De.registerRewardHandler("ADS",as(Te));De.registerRewardHandler("JOLI_COIN",ds(Te.httpClient,{onUnlockSuccess:e=>{let{quantity:t,balance:r}=e,n=r>=1e3?"999+":r;Ci(`{slot-checkmark} \u2212${t} {slot-coin} | Balance: ${n} {slot-coin}`,{customStyle:{mark:{marginRight:"8px"}}})},onUnlockFailed:()=>{console.log("onUnlockFailed")}}));Qc=D("adInit",{implement:e=>{Te.init(e)}}),Xc=D("adConfig",{implement:e=>{Te.adConfig(e)}}),Zc=D("adBreak",{implement:e=>{e.type==="reward"?De.getRewardsTypes(Te.httpClient).then(t=>{De.handleReward(t,e)}):Te.adBreak(e)}}),eu=D("adUnit",{implement:e=>{Te.adUnit(e)}});er.registerCommand("AdsSDK.init",Qc);er.registerCommand("AdsSDK.adConfig",Xc);er.registerCommand("AdsSDK.adBreak",Zc);er.registerCommand("AdsSDK.adUnit",eu);R("AdsSDK.init",{version:"1.0.0"});R("AdsSDK.adConfig",{version:"1.0.0"});R("AdsSDK.adBreak",{version:"1.0.0"});R("AdsSDK.adUnit",{version:"1.0.0"})});var hn,tu,ru,nu,fs=x(()=>{"use strict";P();G();se();J();hn=j(),tu=D("openSchemaSync",{paramsSchema:f.tuple(f.string()),implement:e=>{let t=e;e.match(/^https?:\/\//)||(t=`https://${g.mpId}.app.jolibox.com${e.startsWith("/")?"":"/"}${e}`);let r=N("openSchemaSync",{schema:t});if(r.errNo!==0)throw new Ke(r.errMsg,r.errNo)}}),ru=D("openPageSync",{paramsSchema:f.tuple(f.string()),implement:e=>{let{errNo:t,errMsg:r,data:n}=N("openPageSync",{url:e});if(t!==0||!n)throw new Ke(r,t);return{webviewId:n.webviewId}}}),nu=D("closePageSync",{paramsSchema:f.tuple(f.number()),implement:e=>{let{errNo:t,errMsg:r}=N("closePageSync",{webviewId:e});if(t!==0)throw new Ke(r,t)}});hn.registerCommand("RouterSDK.openSchema",tu);hn.registerCommand("RouterSDK.openPage",ru);hn.registerCommand("RouterSDK.closePage",nu);R("router.openSchema",{version:"1.1.10"});R("router.openPage",{version:"1.1.10"});R("router.closePage",{version:"1.1.10"})});var ou={};var uh,fh,hs=x(()=>{"use strict";$i();uh=bn(Ji());Yi();Qi();Xi();fh=bn(Zi());ts();ms();fs()});var _s=Symbol.for("JOLIBOX_IMPLEMENT_INIT");if(window[_s])throw console.info("Jolibox Implement Already Initialized"),new Error("Jolibox Implement Already Initialized");window[_s]=!0;y(void 0,null,function*(){let[{config:e}]=yield Promise.all([Promise.resolve().then(()=>(Li(),Di)),Promise.resolve().then(()=>(hs(),ou)),Promise.resolve().then(()=>(ge(),Do))]);e()});
148
+ `);throw e.errors.length=0,on(!1),new TypeError(n)}}var f,un=x(()=>{"use strict";ln();ln();f={object(e){return new Ht(e)},array(e){return new Mt(e)},tuple(...e){return new Kt(...e)},literal(e){return new $t(e)},or(...e){return new Jt(...e)},symbol(){return new Dt},record(e){return new Bt(e)},function(){return new Ft},boolean(){return new Ot},string(){return new Nt},number(){return new Pt},undefined(){return new Lt},null(){return new Ut},unknown(){return new Oe},any(){return new Oe},as(){return new Oe},arraybuffer(){return new Vt},enum(...e){return new jt(...e)},typedarray(e){return new Gt(e)}}});var qt,Mi,Bi=x(()=>{"use strict";P();ie();un();Re();qt=1,Mi=e=>{function t(n,o){return(...i)=>{var u,p,m,v;let s=Date.now(),a={method:n,trace_id:qt};qt+=1;let l="SUCCESS",c=`${n}:ok`,d=0;try{if(o.paramsSchema)try{cn(o.paramsSchema,i,"params")}catch(b){throw Fr(`${n}:fail ${b.message}`)}let E=o.implement(...i),h=E,_=`${n}:ok`;if(E&&"code"in E){let{code:b,data:T,message:A}=E;l=b,h=T,_=A}return{code:l,message:_,data:h}}catch(E){let h=E;d=(p=(u=h.code)!=null?u:h.errNo)!=null?p:2e3,l="FAILURE";let _=(v=(m=h.message)!=null?m:h.errMsg)!=null?v:`${E}`;return c=`${n}:${l} ${_.replace(/^\S+:(fail|cancel)\s?/,"")}`,K(new Ve(c,d)),{code:l,message:c}}finally{let E=Date.now()-s;e("apiInvoked",O(w({},a),{duration:E,status:l}))}}}function r(n,o){return(...i)=>y(this,null,function*(){var p,m,v,E;let s=qn(i)?i:[i],a=Date.now(),l={method:n,trace_id:qt};qt+=1;let c=`${n}:ok`,d="SUCCESS",u={code:d,message:c};try{if(o.paramsSchema)try{cn(o.paramsSchema,s,"params")}catch(b){throw Fr(b.message)}let _=yield o.implement(...s);if(_&&"code"in _){let{code:b,data:T,message:A}=_;d=b,c=A,_=T}return Object.assign(u,{code:d,message:c,data:_}),u}catch(h){let _=h,b=(m=(p=_.code)!=null?p:_.errNo)!=null?m:2e3;d="FAILURE";let T=(E=(v=_.message)!=null?v:_.errMsg)!=null?E:`${h}`,A=`${n}:${d} ${T.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(u,{code:d,message:A}),K(new Ve(A,b)),u}finally{let h=Date.now()-a;e("apiInvoked",O(w({},l),{duration:h,status:d}))}})}return{createAPI:r,createSyncAPI:t}}});var H,D,R,se=x(()=>{"use strict";Fi();ge();Bi();un();({createAPI:H,createSyncAPI:D}=Mi(Q)),R=Ui("native")});var Hi,mc,fc,hc,_c,$i=x(()=>{"use strict";P();se();G();Hi=j(),mc="env",fc="getSystemInfoSync",hc=D(fc,{implement:()=>{var r;let e=N("envSync"),{data:t}=e;return{system:t.deviceInfo.system,platform:t.deviceInfo.platform.toLowerCase(),version:t.sdkInfo.jssdkVersion,pixelRatio:t.deviceInfo.pixelRatio,language:t.deviceInfo.lang,brand:t.deviceInfo.brand,appName:(r=t.hostInfo)==null?void 0:r.appName,SDKVersion:t.sdkInfo.jssdkVersion}}}),_c=D(mc,{implement:()=>{var t;let e=N("envSync");return(t=e==null?void 0:e.data)!=null?t:void 0}});Hi.registerCommand("API.getSystemInfoSync",hc);Hi.registerCommand("API.env",_c);R("env",{version:"1.0.0"});R("getSystemInfoSync",{version:"1.0.0"})});var Ji=vn(dn=>{"use strict";P();se();ie();G();ge();J();var gc="exitGame",vc="onReady",yc="onJoliboxShow",bc="onJoliboxHide",Wt=j(),zt=at(K),wc=H(gc,{paramsSchema:f.tuple(f.function(),f.boolean().optional().default(!1)),implement:(e,t=!1)=>y(dn,null,function*(){zt(e).call(dn),$e(g.shouldInterupt)&&!g.shouldInterupt&&g.from&&Hn("onRetentionResult",{shouldStay:t},g.from,!0),yield Y("exitAppAsync")})}),Ec=D(yc,{paramsSchema:f.tuple(f.function()),implement(e){let t=zt(e);re("onJoliboxEnterForeground",()=>{t.call(this),Ge.emit("visible",!0)})}}),kc=D(bc,{paramsSchema:f.tuple(f.function()),implement(e){let t=zt(e);re("onJoliboxEnterBackground",()=>{t.call(this),Ge.emit("visible",!1)})}}),xc=D(vc,{paramsSchema:f.tuple(f.function()),implement(e){let t=zt(e);ue.on("LifecycleEvent.onReady",r=>{t(r)})}});Wt.registerCommand("LifecycleSDK.exit",wc);Wt.registerCommand("LifecycleSDK.onReady",xc);Wt.registerCommand("LifecycleSDK.onJoliboxShow",Ec);Wt.registerCommand("LifecycleSDK.onJoliboxHide",kc);R("lifeCycle.exit",{version:"1.0.0"});R("lifeCycle.onReady",{version:"1.0.0"});R("lifeCycle.onJoliboxShow",{version:"1.0.0"});R("lifeCycle.onJoliboxHide",{version:"1.0.0"})});function Ki(e){let t={};if(!ye(e))return t;for(let[r,n]of Object.entries(e)){let o=r.toLocaleLowerCase();n?typeof n=="object"?t[o]=Object.prototype.toString.call(n):t[o]=String(n):t[o]=""}return t}function Vi(e="GET"){if(e==="")return"POST";let t=e.toUpperCase();return["GET","OPTIONS","HEAD","POST","PUT","DELETE","TRACE","CONNECT","PATCH"].includes(t)?t:"GET"}function Gi(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function qi(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!ye(r))return e;let[n,o=""]=e.split("?"),i=new URLSearchParams(o);for(let[a,l]of Object.entries(r))l!=null&&i.append(a,String(l));let s=i.toString();return s?`${n}?${s}`:n}var Wi=x(()=>{"use strict";P()});var Sc,Tc,pn,mn,zi,Ic,Rc,Ac,Yi=x(()=>{"use strict";Re();Br();se();Wi();P();ie();J();Sc=15,Tc=ut("createRequestTaskSync","operateRequestTaskSync",{type:"public",baseUrl:g.baseApiHost}),pn=0,mn=[],zi=at(K),Ic=(e,t)=>{let r=e.filter(t),n=e.filter(o=>!t(o));return e.length=0,e.push(...n),r},Rc=e=>{let t=new he,r=()=>{};return D("request",{paramsSchema:f.tuple(f.object({url:f.string(),method:f.string(),headers:f.object(),data:f.object().optional(),query:f.object().optional(),dataType:f.string().default("json"),responseType:f.string().default("text"),enableCache:f.boolean().default(!1),appendHostCookie:f.boolean().default(!0),timeout:f.number().default(3e4),success:f.function(),fail:f.function()})),implement(o){let i=()=>y(this,null,function*(){var a,l;let s=zi(o.fail);try{if(pn+=1,t.state!=="pending")return;let{data:c,dataType:d,responseType:u,enableCache:p,appendHostCookie:m}=o,v=Ki(o.headers),E=Vi(o.method),h=Gi(o.timeout),_=qi(o.url,E,c),b=zi(o.success),T=Object.assign({},o,{method:E,header:v,data:E==="GET"||E==="HEAD"?void 0:c,enableCache:p,query:(a=o.query)!=null?a:{},dataType:d,responseType:u,appendHostCookie:m});h&&(T.timeout=h);let A=Tc(_,T);{let{response:C}=yield A,{code:k,data:$,message:z}=C;if($&&typeof $=="object"&&"status"in $&&$.status!==200)throw _e({code:$.status||-1,msg:`request:fail status ${$.status}`});t.resolve({code:k!=null?k:"SUCCESS",data:$,message:z!=null?z:"request:ok"}),b({code:"SUCCESS",message:"request:ok",data:$})}}catch(c){t.reject(c),s({code:"FAILURE",message:"httpRequst: failed"})}finally{pn-=1,(l=mn.shift())==null||l()}});return pn>=Sc?(r=()=>{Ic(mn,s=>s===i)},mn.push(i)):i(),t.promise}})(e),{abort(){t.reject(_e({code:-1,msg:"request:fail abort"})),r()}}},Ac=j();Ac.registerCommand("HttpSDK.request",Rc);R("request",{version:"1.0.0"})});function Lc(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return Dc.includes(t)?t:""}function Uc(e,t){try{switch(t){case"string":return e;case"object":return JSON.parse(e);case"number":return parseFloat(e);case"boolean":return e==="true";default:return""}}catch(r){return""}}function Fc(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch(r){return""}}var Yt,Cc,Pc,Oc,Nc,rf,nf,Dc,Qi=x(()=>{"use strict";se();G();P();Ae();J();Yt=j(),Cc=H("getLocalStorage",{paramsSchema:f.tuple(f.string()),implement(e){return y(this,null,function*(){let{response:t}=yield q(`/api/games/user-storage/${g.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:o}}=yield t;if(r==="SUCCESS")return{code:r,message:n,data:o==null?void 0:o.value};try{let{data:{data:i,dataType:s}}=yield Y("getLocalStorageAsync",{key:e}),a=Uc(i,s);return{code:r,message:`${n}. fallback to native`,data:a}}catch(i){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}})}});Yt.registerCommand("StorageSDK.getItem",Cc);R("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});Pc=H("setStorage",{paramsSchema:f.tuple(f.string(),f.or(f.string(),f.boolean(),f.number())),implement(e,t){return y(this,null,function*(){let r=g.mpId,n=typeof t=="string"?t:String(t),{response:o}=yield q(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:i,message:s}}=o,a=Lc(t),l=Fc(t,a);return yield Y("setLocalStorageAsync",{key:e,data:l,dataType:a}),i=="SUCCESS"?{code:i,message:s}:{code:i,message:`${s}. fallback to native`}})}});Yt.registerCommand("StorageSDK.setItem",Pc);R("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});Oc=H("removeStorage",{paramsSchema:f.tuple(f.string()),implement(e){return y(this,null,function*(){let t=g.mpId,{response:r}=yield q(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:o}}=r;return yield Y("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:o}:{code:n,message:"[Jolibox SDK] remove item succ"}})}});Yt.registerCommand("StorageSDK.removeItem",Oc);R("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});Nc=H("clearStorage",{implement(){return y(this,null,function*(){let e=g.mpId,{response:t}=yield q(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});Y("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}})}});Yt.registerCommand("StorageSDK.clear",Nc);R("storage.clear",{version:"1.0.0"});rf=H("getStorageInfo",{implement(){return y(this,null,function*(){let{data:e}=yield Y("getStorageInfoAsync");return e})}});R("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});nf=D("getStorageInfoSync",{implement(){return N("getStorageInfoSync")}}),Dc=["string","number","boolean","object",""]});var jc,Mc,Bc,fn,Xi=x(()=>{"use strict";P();G();se();jc=D("showKeyboard",{paramsSchema:f.tuple(f.object({defaultValue:f.string().optional().default(""),multiple:f.boolean().optional().default(!1),maxLength:f.unknown().optional().default(1e5)})),implement(e){var n;let t=Math.floor((n=Number(e.maxLength))!=null?n:1e5),{defaultValue:r}=e;r&&t&&(r=r.slice(0,t)),N("showKeyboardSync",O(w({},e),{defaultValue:r,maxLength:t}))}});R("keyboard.showKeyboard",{version:"1.0.0",properties:{params:{defaultValue:"1.0.0",multiple:"1.0.0",confirmHold:"1.0.0",confirmType:"1.0.0",maxLength:"1.0.0"}},success:{errMsg:"1.0.0"}});Mc=D("updateKeyboard",{paramsSchema:f.tuple(f.object({value:f.string()})),implement(e){N("updateKeyboardSync",e)}});R("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});Bc=D("hideKeyboard",{implement(){N("hideKeyboardSync")}});R("keyboard.hideKeyboard",{version:"1.0.0"});fn=j();fn.registerCommand("KeyboardSDK.showKeyboard",jc);fn.registerCommand("KeyboardSDK.updateKeyboard",Mc);fn.registerCommand("KeyboardSDK.hideKeyboard",Bc)});var Zi=vn(Se=>{"use strict";P();se();ge();var Ne=j(),Hc=H("levelFinished",{paramsSchema:f.tuple(f.string(),f.object({result:f.boolean(),duration:f.number()})),implement:(e,t)=>y(Se,null,function*(){let{result:r,duration:n}=t,o=[];o.push(W.tracker("LevelFinished",{levelId:e,result:r,duration:n})),o.push(W.reporter({event:"COMPLETE_GAME_LEVEL"})),yield Promise.all(o)})}),$c=H("taskFinished",{paramsSchema:f.tuple(f.string(),f.object({duration:f.number()})),implement:(e,t)=>y(Se,null,function*(){let{duration:r}=t;return yield W.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})})}),Jc=H("levelUpgrade",{paramsSchema:f.tuple(f.string(),f.string()),implement:(e,t)=>y(Se,null,function*(){let r=[];r.push(W.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),yield Promise.all(r)})}),Kc=H("onHistoryUserLevel",{paramsSchema:f.tuple(f.number()),implement:e=>y(Se,null,function*(){return yield W.reportToNative({event:"HistoryUserLevel",params:{level:e}})})}),Vc=H("onHistoryUserScore",{paramsSchema:f.tuple(f.number()),implement:e=>y(Se,null,function*(){return yield W.reportToNative({event:"HistoryUserScore",params:{score:e}})})}),Gc=H("taskEvent",{paramsSchema:f.tuple(f.string(),f.object({tools:f.array(f.object({id:f.string(),name:f.string(),count:f.number(),description:f.string().optional(),price:f.object({amount:f.number(),unit:f.string()}).optional()})).optional(),awards:f.array(f.object({id:f.string(),name:f.string()})).optional()})),implement:(e,t)=>y(Se,null,function*(){var n,o;let r=[];r.push(W.reportToNative({event:"TaskEvent",params:w({taskId:e},t)})),(o=(n=t.tools)==null?void 0:n.length)!=null&&o&&(r.push(W.reporter({event:"USE_GAME_ITEM"})),r.push(W.reportToNative({event:"UseGameItem",params:w({taskId:e},t)}))),yield Promise.all(r)})});Ne.registerCommand("TaskTrackerSDK.levelFinished",Hc);Ne.registerCommand("TaskTrackerSDK.taskFinished",$c);Ne.registerCommand("TaskTrackerSDK.levelUpgrade",Jc);Ne.registerCommand("TaskTrackerSDK.historyUserLevel",Kc);Ne.registerCommand("TaskTrackerSDK.historyUserScore",Vc);Ne.registerCommand("TaskTrackerSDK.taskEvent",Gc);R("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});R("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});R("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});R("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});R("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});R("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}})});var qc,Wc,es,ts=x(()=>{"use strict";J();G();se();P();Re();R("login",{version:"1.0.0",properties:{force:"1.0.0"},success:{errMsg:"1.0.0",code:"1.0.0",token:"1.0.0",isLogin:"1.0.0"}});R("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});qc=H("login",{implement(){return y(this,null,function*(){var s;let{data:{isLogin:e}}=yield Y("checkLoginAsync");if(e)return{isLogin:!0,token:(s=g.hostUserInfo)==null?void 0:s.token};re("onLoginStateChange",({isLogin:a,token:l,uuid:c})=>{c==r&&o({isLogin:a,token:l})});let t=N("loginSync"),{data:{uuid:r}}=t;if(!r)throw _e({code:-1,msg:"login failed"});let{promise:n,resolve:o}=new he,i=yield n;return g.onEnvConfigChanged({hostUserInfo:i}),ue.emit("onLoginComplete",i),i})}}),Wc=H("checkSession",{implement(){return y(this,null,function*(){let{data:{isLogin:e}}=yield Y("checkLoginAsync");return{isLogin:e}})}}),es=j();es.registerCommand("API.login",qc);es.registerCommand("API.checkSession",Wc)});function ns(){let e=new Map,t;return{registerRewardHandler(n,o){e.set(n,o)},handleReward(n,...o){return y(this,null,function*(){return yield n.reduce((s,a)=>y(this,null,function*(){let l=yield s;if(l===!0)return!0;rs&&console.log(`handleReward ${a}`);let c=e.get(a),d=c?yield c(...o):l;return rs&&console.log(`handleReward ${a} ${d}`),d}),Promise.resolve(!1))})},registerRewardsFetcher(n){return y(this,null,function*(){t=(...o)=>y(this,null,function*(){try{return yield n(...o)}catch(i){return console.error("getRewardOptions error:",i),["ADS"]}})})},getRewardsTypes(...n){return y(this,null,function*(){return t?yield t(...n):["ADS"]})}}}var rs,os=x(()=>{"use strict";J();rs=g.testMode});var zc,is,ss=x(()=>{"use strict";Zt();zc=()=>(e,t)=>e==="JOLI_COIN"&&t==="ADS"?-1:e==="ADS"&&t==="JOLI_COIN"?1:0,is=e=>{e.registerRewardsFetcher(t=>y(void 0,null,function*(){var n,o,i,s;let r=["ADS"];try{let a=yield t.post("/api/games/unlock-options",{});return a.code!=="SUCCESS"?r:(Xt.emit(Qt,{options:((n=a.data)==null?void 0:n.unlockOptions)||[],userJoliCoin:((o=a.extra)==null?void 0:o.joliCoin)||{balance:0,enableAutoDeduct:!1}}),(((s=(i=a.data)==null?void 0:i.unlockOptions)==null?void 0:s.map(c=>c.type))||Array.from(r)).sort(zc()))}catch(a){return console.error("getRewardOptions error:",a),r}}))}});var as,ls=x(()=>{"use strict";as=e=>t=>y(void 0,null,function*(){return e.adBreak(t),!0})});var cs,us=x(()=>{"use strict";cs=(e,t)=>e.some(r=>r.type==="JOLI_COIN"&&r.joliCoinChoices.some(n=>{var o;return n.joliCoinQuantity<=((o=t==null?void 0:t.balance)!=null?o:0)&&!!(t!=null&&t.enableAutoDeduct)}))});var ds,ps=x(()=>{"use strict";J();P();us();Zt();ds=(e,{onUnlockSuccess:t,onUnlockFailed:r})=>{let n=null,o=null,i=null,s=()=>{if(i){n=Promise.resolve(i);return}n=new Promise(a=>{o=a})};return s(),Xt.on(Qt,a=>{i=a,o&&(o(a),o=null)}),a=>y(void 0,null,function*(){var l,c;try{n||s();let d=yield n;if(!cs((d==null?void 0:d.options)||[],d==null?void 0:d.userJoliCoin))return r==null||r(),!1;let u=yield e.post("/api/joli-coin/unlock",{data:{type:"GAME_REWARD",reqId:`${Ar()}-${g.mpType}-${Date.now()}`,gameInfo:{gameId:g.mpId}}});return u.code=="SUCCESS"?(t==null||t({quantity:u.data.quantity,balance:u.data.balance}),(c=a.adBreakDone)==null||c.call(a,{breakType:a.type,breakName:"name"in a&&(l=a.name)!=null?l:"",breakFormat:"reward",breakStatus:"viewed"}),!0):(r==null||r(),!1)}catch(d){return console.error("JolicoinRewardHandler error:",d),r==null||r(),!1}})}});var De,Qt,Xt,Zt=x(()=>{"use strict";os();ss();P();ls();ps();De=ns();is(De);Qt="UNLOCK_OPTIONS_CHANGED",Xt=new oe});var er,Yc,Te,Qc,Xc,Zc,eu,ms=x(()=>{"use strict";P();se();rn();$r();ge();Ae();G();Zt();er=j(),Yc=()=>{let{data:e}=N("getNetworkStatusSync");return!!(e!=null&&e.isConnected)},Te=new ht(Q,{get:(e,t)=>q(e,w({method:"GET",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data),post:(e,t,r)=>q(e,w({method:"POST",responseType:"json",appendHostCookie:!0},r)).then(n=>n.response.data)},Yc);De.registerRewardHandler("ADS",as(Te));De.registerRewardHandler("JOLI_COIN",ds(Te.httpClient,{onUnlockSuccess:e=>{let{quantity:t,balance:r}=e,n=r>=1e3?"999+":r;Ci(`{slot-checkmark} \u2212${t} {slot-coin} | Balance: ${n} {slot-coin}`,{customStyle:{mark:{marginRight:"8px"}}})},onUnlockFailed:()=>{console.log("onUnlockFailed")}}));Qc=D("adInit",{implement:e=>{Te.init(e)}}),Xc=D("adConfig",{implement:e=>{Te.adConfig(e)}}),Zc=D("adBreak",{implement:e=>{e.type==="reward"?De.getRewardsTypes(Te.httpClient).then(t=>{De.handleReward(t,e)}):Te.adBreak(e)}}),eu=D("adUnit",{implement:e=>{Te.adUnit(e)}});er.registerCommand("AdsSDK.init",Qc);er.registerCommand("AdsSDK.adConfig",Xc);er.registerCommand("AdsSDK.adBreak",Zc);er.registerCommand("AdsSDK.adUnit",eu);R("AdsSDK.init",{version:"1.0.0"});R("AdsSDK.adConfig",{version:"1.0.0"});R("AdsSDK.adBreak",{version:"1.0.0"});R("AdsSDK.adUnit",{version:"1.0.0"})});var hn,tu,ru,nu,fs=x(()=>{"use strict";P();G();se();J();hn=j(),tu=D("openSchemaSync",{paramsSchema:f.tuple(f.string()),implement:e=>{let t=e;e.match(/^https?:\/\//)||(t=`https://${g.mpId}.app.jolibox.com${e.startsWith("/")?"":"/"}${e}`);let r=N("openSchemaSync",{schema:t});if(r.errNo!==0)throw new Ke(r.errMsg,r.errNo)}}),ru=D("openPageSync",{paramsSchema:f.tuple(f.string()),implement:e=>{let{errNo:t,errMsg:r,data:n}=N("openPageSync",{url:e});if(t!==0||!n)throw new Ke(r,t);return{webviewId:n.webviewId}}}),nu=D("closePageSync",{paramsSchema:f.tuple(f.number()),implement:e=>{let{errNo:t,errMsg:r}=N("closePageSync",{webviewId:e});if(t!==0)throw new Ke(r,t)}});hn.registerCommand("RouterSDK.openSchema",tu);hn.registerCommand("RouterSDK.openPage",ru);hn.registerCommand("RouterSDK.closePage",nu);R("router.openSchema",{version:"1.1.10"});R("router.openPage",{version:"1.1.10"});R("router.closePage",{version:"1.1.10"})});var ou={};var uh,fh,hs=x(()=>{"use strict";$i();uh=bn(Ji());Yi();Qi();Xi();fh=bn(Zi());ts();ms();fs()});var _s=Symbol.for("JOLIBOX_IMPLEMENT_INIT");if(window[_s])throw console.info("Jolibox Implement Already Initialized"),new Error("Jolibox Implement Already Initialized");window[_s]=!0;y(void 0,null,function*(){let[{config:e}]=yield Promise.all([Promise.resolve().then(()=>(Li(),Di)),Promise.resolve().then(()=>(hs(),ou)),Promise.resolve().then(()=>(ge(),Do))]);e()});
@@ -1,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.1.13-beta.10 clean
3
+ > @jolibox/implement@1.1.13-beta.11 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.1.13-beta.10 build:esm
7
+ > @jolibox/implement@1.1.13-beta.11 build:esm
8
8
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
9
9
 
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@jolibox/implement",
3
3
  "description": "This project is Jolibox JS-SDk implement for Native && H5",
4
- "version": "1.1.13-beta.10",
4
+ "version": "1.1.13-beta.11",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "@jolibox/common": "1.1.13-beta.10",
10
- "@jolibox/types": "1.1.13-beta.10",
11
- "@jolibox/native-bridge": "1.1.13-beta.10",
9
+ "@jolibox/common": "1.1.13-beta.11",
10
+ "@jolibox/types": "1.1.13-beta.11",
11
+ "@jolibox/native-bridge": "1.1.13-beta.11",
12
12
  "localforage": "1.10.0",
13
13
  "@jolibox/ui": "1.0.0",
14
14
  "web-vitals": "4.2.4"
@@ -13,21 +13,27 @@ const priority = () => {
13
13
 
14
14
  export const createRewardFetcher = (rewardsHelper: RewardsHelper) => {
15
15
  rewardsHelper.registerRewardsFetcher(async (httpClient: IHttpClient) => {
16
- const defaultRewards: RewardType[] = [];
17
- const res = await httpClient.post<IJolicoinRewardOption>('/api/games/unlock-options', {});
18
- if (res.code !== 'SUCCESS') {
19
- return defaultRewards;
20
- }
21
- unlockOptionsEmitter.emit(UnlockOptionsEventName, {
22
- options: res.data?.unlockOptions || [],
23
- userJoliCoin: res.extra?.joliCoin || {
24
- balance: 0,
25
- enableAutoDeduct: false
16
+ const defaultRewards: RewardType[] = ['ADS'];
17
+ try {
18
+ const res = await httpClient.post<IJolicoinRewardOption>('/api/games/unlock-options', {});
19
+ if (res.code !== 'SUCCESS') {
20
+ return defaultRewards;
26
21
  }
27
- });
22
+ unlockOptionsEmitter.emit(UnlockOptionsEventName, {
23
+ options: res.data?.unlockOptions || [],
24
+ userJoliCoin: res.extra?.joliCoin || {
25
+ balance: 0,
26
+ enableAutoDeduct: false
27
+ }
28
+ });
28
29
 
29
- const rewardsTypes = res.data?.unlockOptions?.map((option) => option.type) || Array.from(defaultRewards);
30
- // Sort reward types with JOLI_COIN having higher priority than ADS
31
- return rewardsTypes.sort(priority());
30
+ const rewardsTypes =
31
+ res.data?.unlockOptions?.map((option) => option.type) || Array.from(defaultRewards);
32
+ // Sort reward types with JOLI_COIN having higher priority than ADS
33
+ return rewardsTypes.sort(priority());
34
+ } catch (e) {
35
+ console.error('getRewardOptions error:', e);
36
+ return defaultRewards;
37
+ }
32
38
  });
33
39
  };
@@ -3,6 +3,7 @@ import { context } from '@/common/context';
3
3
  import { uuidv4 } from '@jolibox/common';
4
4
  import { canUseJolicoin } from './utils';
5
5
  import { unlockOptionsEmitter, UnlockOptionsEventName, IUnlockOptionsEvent } from '..';
6
+ import { IAdBreakParams } from '@/common/ads';
6
7
 
7
8
  interface IJolicoinUnlockRes {
8
9
  code: 'SUCCESS' | 'BALANCE_NOT_ENOUGH' | 'EPISODE_LOCK_JUMP' | 'EPISODE_UNLOCK_ALREADY';
@@ -14,7 +15,7 @@ interface IJolicoinUnlockRes {
14
15
  };
15
16
  }
16
17
 
17
- export type JolicoinRewardsHandler = () => Promise<boolean>;
18
+ export type JolicoinRewardsHandler = (params: IAdBreakParams) => Promise<boolean>;
18
19
  export const createJolicoinRewardHandler = (
19
20
  httpClient: IHttpClient,
20
21
  {
@@ -50,7 +51,7 @@ export const createJolicoinRewardHandler = (
50
51
  }
51
52
  });
52
53
 
53
- return async () => {
54
+ return async (params: IAdBreakParams) => {
54
55
  try {
55
56
  if (!unlockOptionsPromise) {
56
57
  createUnlockOptionsPromise();
@@ -76,6 +77,12 @@ export const createJolicoinRewardHandler = (
76
77
  quantity: unlockWithJolicoin.data.quantity,
77
78
  balance: unlockWithJolicoin.data.balance
78
79
  });
80
+ params.adBreakDone?.({
81
+ breakType: params.type,
82
+ breakName: 'name' in params ? params.name ?? '' : '',
83
+ breakFormat: 'reward',
84
+ breakStatus: 'viewed'
85
+ });
79
86
  return true;
80
87
  }
81
88
  onUnlockFailed?.();
package/src/h5/api/ads.ts CHANGED
@@ -18,7 +18,7 @@ rewardsHelper.registerRewardHandler(
18
18
  JOLI_COIN: params
19
19
  });
20
20
  }
21
- })
21
+ }) as unknown as (params?: unknown) => Promise<boolean>
22
22
  );
23
23
 
24
24
  adEventEmitter.on('isAdShowing', (isAdShowing) => {
@@ -54,7 +54,7 @@ rewardsHelper.registerRewardHandler(
54
54
  onUnlockFailed: () => {
55
55
  console.log('onUnlockFailed');
56
56
  }
57
- })
57
+ }) as unknown as (params?: unknown) => Promise<boolean>
58
58
  );
59
59
  const adInit = createSyncAPI('adInit', {
60
60
  implement: (config?: IAdsInitParams) => {