@jolibox/sdk 1.1.48 → 1.1.50

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,18 +4,19 @@
4
4
  "packages/sdk/.eslintrc.js": "c11c589d14fe58bf4d37d259d8323b193bab6092",
5
5
  "packages/sdk/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
6
6
  "packages/sdk/esbuild.config.js": "1725a85515499085a7c9799b834c6f632073401c",
7
- "packages/sdk/package.json": "7cb8ee73f521c8188266d162ac93afe0126ff962",
7
+ "packages/sdk/package.json": "e6849d3dace7a8f8feee1a8f559452a162b3a031",
8
8
  "packages/sdk/src/__tests__/index.test.ts": "f22e0c0741297803ac3ec016b1dcc166cd2248bd",
9
9
  "packages/sdk/src/api/__tests__/canIUse.test.ts": "300e4de3768f9510e956050d326d4977bc621f34",
10
+ "packages/sdk/src/api/call-host-method.ts": "e373cd15fe1d9d1a86c3276545017c49e954c223",
10
11
  "packages/sdk/src/api/can-i-use.ts": "f3294bb1dd64849bcc95a3490c13ec0cf0509628",
11
12
  "packages/sdk/src/api/get-system-info.ts": "46c47e0850aa63b8c95069879f82579a290ab89b",
12
- "packages/sdk/src/api/index.ts": "4a9fa940de4cf7733804d6ac24e2a90969c95079",
13
+ "packages/sdk/src/api/index.ts": "7ef5372d67e13cd1367bbb3c8b2d49b309affec6",
13
14
  "packages/sdk/src/api/is-native-support.ts": "ba345fc8a26b5d58993930bb61f793d47926f84b",
14
15
  "packages/sdk/src/api/login.ts": "f576da331edc1e3e698393edee6e35d7e0e6a916",
15
16
  "packages/sdk/src/api/on-custom-event.ts": "913b19d91f9c073f2985e91fd7c523bc4c112307",
16
17
  "packages/sdk/src/api/request.ts": "117baeceb72bd1602a01f3e1fe586faaea48d155",
17
18
  "packages/sdk/src/events.ts": "124aa9c3dbfa2477ba4d365d63446fae6b542f1f",
18
- "packages/sdk/src/index.ts": "a5e4ed1c52c48827704d1b1f761784f44a942678",
19
+ "packages/sdk/src/index.ts": "f4c4ccc7fdfd36c9feff54bd82253fe9f535742b",
19
20
  "packages/sdk/src/loader/__tests__/version.test.ts": "338ca817bfcb672d1065d6f32872b57bc43951b5",
20
21
  "packages/sdk/src/loader/h5.ts": "1565cba2f78e9ca854cd25682c6f3ac90c19ba34",
21
22
  "packages/sdk/src/loader/index.ts": "b3233a259705a720f141a3d1b2dd2d031f589a22",
@@ -24,11 +25,11 @@
24
25
  "packages/sdk/src/sdks/ads.ts": "bec143d0340fced14fa3d372e82de7cc02c419b0",
25
26
  "packages/sdk/src/sdks/keyboard.ts": "b30424cbecffa24c9d5249366a70afe2128e64be",
26
27
  "packages/sdk/src/sdks/lifecycle.ts": "4d9a3b770d528f59c0eb9272e18d5c2c5641320d",
27
- "packages/sdk/src/sdks/router.ts": "f71c1292340b2c2e373ac6e059f2997e5c0ced84",
28
+ "packages/sdk/src/sdks/router.ts": "9233f2c709ae650cf05dd3d8766c785e5bf58807",
28
29
  "packages/sdk/src/sdks/runtime.ts": "179ae2ffd60125f6ba058c9b52ca4db46032c26b",
29
30
  "packages/sdk/src/sdks/sdk.ts": "789f8be82a9c3257306f3e40d21311a7873d4502",
30
31
  "packages/sdk/src/sdks/storage.ts": "43dbbdeea3484e9ff084958bf4137190d300ff17",
31
- "packages/sdk/src/sdks/task.ts": "4d1cc3ec6569b615e98c1b74dacd58e645c0f3a2",
32
+ "packages/sdk/src/sdks/task.ts": "a05f8b32d220ce6ff6ce17d51938652c944c5252",
32
33
  "packages/sdk/src/utils/can-i-use.ts": "10993f013cf26c07b60fe60fb7b458bbd6847244",
33
34
  "packages/sdk/src/utils/env.ts": "d2e3db934d24a3b687de1f2df04fed7a5467e161",
34
35
  "packages/sdk/src/utils/event-tracker.ts": "2c034397c0a39730840ea4d2f11c0b7cee39414a",
@@ -0,0 +1,5 @@
1
+ import { ICallHostMethodParams } from '@jolibox/types';
2
+ export declare function callHostMethod(params: ICallHostMethodParams): Promise<import("@jolibox/types").StandardResponse<void, unknown> | {
3
+ code: ResponseType;
4
+ message: string;
5
+ }>;
@@ -4,3 +4,4 @@ export * from './login';
4
4
  export * from './request';
5
5
  export * from './on-custom-event';
6
6
  export * from './is-native-support';
7
+ export * from './call-host-method';
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var P=Object.defineProperty,pt=Object.defineProperties,ft=Object.getOwnPropertyDescriptor,ht=Object.getOwnPropertyDescriptors,gt=Object.getOwnPropertyNames,ve=Object.getOwnPropertySymbols;var _e=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable;var Se=(e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))_e.call(t,r)&&Se(e,r,t[r]);if(ve)for(var r of ve(t))Et.call(t,r)&&Se(e,r,t[r]);return e},O=(e,t)=>pt(e,ht(t));var yt=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},vt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of gt(t))!_e.call(e,o)&&o!==r&&P(e,o,{get:()=>t[o],enumerable:!(n=ft(t,o))||n.enumerable});return e};var St=e=>vt(P({},"__esModule",{value:!0}),e);var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});var xr={};yt(xr,{JoliboxSDK:()=>z});module.exports=St(xr);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}var te=Object.defineProperty,_t=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,Rt=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable,Re=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wt=(e,t)=>{for(var r in t||(t={}))xt.call(t,r)&&Re(e,r,t[r]);if(be)for(var r of be(t))It.call(t,r)&&Re(e,r,t[r]);return e},Tt=(e,t)=>_t(e,Rt(t)),Lt=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},we=(e,t,r,n)=>{for(var o=n>1?void 0:n?bt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&te(t,r,o),o},At=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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}function Dt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function re(e){return typeof e=="string"}function Te(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Pt(e){return typeof e=="undefined"}function Ut(e){return Pt(e)||e===null}function Ot(e){return typeof e=="function"}function Le(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Ct=(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))(Ct||{}),K=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}},Ae=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var De=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},w=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends K{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}}};function R(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var kt={log:R("log"),warn:R("warn"),info:R("info"),error:R("error"),debug:R("debug")};Object.assign(globalThis,{logger:kt});var q=Symbol.for("Jolibox.canIUseMap"),Nt={};globalThis[q]||(globalThis[q]=Nt);var Pe={get config(){return globalThis[q]}};var xe=Symbol.for("Jolibox.canIUseMap.native"),Kt={};globalThis[xe]||(globalThis[xe]=Kt);function ne(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var oe=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),se=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(se||{}),Mt=(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))(Mt||{}),Ie=["name","params"],jt=["name","type","location","target","extra","timestamp","userId"],Jt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Ft(e){let t=e.location?k(e.location,Ie):null,r=e.target?k(e.target,Ie):null;return k(Tt(wt({},e),{location:t,target:r}),jt)}function Ue(e){let t=e.events.map(n=>Ft(n)),r=k(e.device,Jt);return[e.protocolVersion,t,r,e.project]}var Bt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function ie(){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}}ie();var ae=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),C={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")},Vt=()=>C.isiOS?"iOS":C.isAndroid?"Android":C.isMac?"Mac":C.isFacebook?"Facebook":"PC",$t="device_id",Gt="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Bt()),window.__joliboxLocalStorage__.getItem(e)),Ht=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe($t),Wt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(Gt),zt=e=>e.charAt(0).toUpperCase()+e.slice(1),Yt=()=>{var e;let t=new URLSearchParams(window.location.search);return zt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ce=e=>{if(ae())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,o=Ht(),s=Wt();return`${t} (${Yt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},Q=class X{constructor(t){this.element=t,this.next=X.Undefined,this.prev=X.Undefined}};Q.Undefined=new Q(void 0);var d=Q,qt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.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!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Qt=0,x=class{constructor(e){this.value=e,this.id=Qt++}},I=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 x&&(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,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new x(t);return this._listeners?this._listeners instanceof x?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,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var p,h,y,Ee;if(!this._disposed){if(this._listeners instanceof x)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(h=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||h.call(p));else if(this._listeners){let ye=this._listeners.indexOf(c);ye>=0&&(this._listeners.splice(ye,1),this._size--,this._size===0&&((Ee=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||Ee.call(y)))}}}}),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 x?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ce=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new I,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new qt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},Z={};Lt(Z,{None:()=>Xt,filter:()=>er,once:()=>ke,toPromise:()=>Zt});var Xt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Zt(e){return new Promise(t=>ke(e)(t))}function ke(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function er(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new I(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var Y=Symbol.for("Jolibox.hostEmitter"),tr=()=>{let e=new ce;return globalThis[Y]||(globalThis[Y]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Y]},S=tr();function rr(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)nr(e[n],t[n])}function nr(e,t){if(re(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ot(t)){try{if(e instanceof t)return}catch(r){}if(!Ut(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")}}var N=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new I,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 rr(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}};N=we([Le],N);var ee=class{constructor(){this._onWillExecuteCommand=new I,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new I,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new N,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Dt(3e4)),this._starActivation}executeCommand(e,...t){return At(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Z.toPromise(Z.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}}};ee=we([Le],ee);var Ne=Symbol.for("Jolibox.commands");function or(){return typeof globalThis!="undefined"?globalThis[Ne]:void 0}function sr(e){typeof globalThis!="undefined"&&(globalThis[Ne]=e)}function f(e=!1){let t=or();if(!e&&t)return t;let r=new N,n=new ee,o={registerCommand(s,a,l){r.registerCommand({id:s,handler:a,metadata:l})},executeCommand(s,...a){return n.executeCommand(s,...a)},excuteCommandSync(s,...a){return n.executeCommandThowErr(s,...a)}};return sr(o),o}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function ir(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function ar(){return{platform:1e3,os:"h5",appVersion:"1.1.48",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.48",extra:{}}}var Ke={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"}},cr=()=>{var t;let e=(t=Ke[window.location.host])!=null?t:Ke.default;return j?e.test:e.prod},lr=cr(),je=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Me;(Me=AbortSignal.timeout)!=null||(AbortSignal.timeout=je);var mr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},dr=mr(),ur=e=>m(void 0,null,function*(){try{let r=`${lr}/report`,n=Ce("1.1.48"),o=dr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:je(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function _(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:ir(),target:null,extra:e,timestamp:Date.now(),userId:null},r=ar(),o={protocolVersion:"1.0.0",events:[t],device:r,project:se.WebSDK},s=Ue(o);yield ur(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",T.startTime));var pr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=pr(),Je=f(),le=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Je.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),_({err:JSON.stringify(t)})})},v=le;window.addEventListener("unhandledrejection",le.bind(void 0));window.addEventListener("error",le.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Je.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{_({err:JSON.stringify(s)})})};var me=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},L=e=>parseInt(me(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=me(e),{major:a,minor:l,patch:i,prerelease:c}=me(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Fe=f(),J=(e,t)=>{Fe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{Fe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ie();var $e="jolibox-sdk-loadermeta",Ve,D=JSON.parse((Ve=window.__joliboxLocalStorage__.getItem($e))!=null?Ve:"{}"),de=Date.now(),Be=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function fr(){return m(this,null,function*(){let t=`${j?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=O(U({},D),{timestamp:de});if(o){let{bootstrap_version:a}=D;a&&A(a,o)>=0||(s=O(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=D;a&&A(a,n)>=0||(s=O(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem($e,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ge=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=D;i&&c&&!Be(de,c)&&L(i)==t&&A(i,r)>=0&&(n=ue(i));try{let p=new XMLHttpRequest;return p.open("GET",n,!1),p.send(),{script:p.responseText,type:"fetch_from_cdn"}}catch(p){let h=new De(`Bootstrap module faile to fetch ${p}`);_({err:`${h}`})}}function a(){var h;let i=Date.now();J("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:p}=(h=s())!=null?h:{};if(c){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=c,document.head.appendChild(y),b("bootstrapModuleLoaded",Date.now()-i,{type:p})}}function l(){let i=Date.now(),{implement_version:c,timestamp:p}=D;c&&p&&!Be(de,p)&&L(c)==t&&A(c,r)>=0&&(o=pe(c));let h=document.createElement("script");h.type="module",h.crossOrigin="anonymous",h.src=o,h.onload=()=>{b("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(h)}return()=>{try{a(),l(),fr()}catch(i){let c=new w(`module evaluate error: ${i}`);_({err:`${c}`})}}};var He=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){v(new w(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),b("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),v(new w(`module load failed ${o}`))}}};var hr="1.1.48",F=hr,qe=L(F),Qe=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),gr=Qe?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,fe="https://jsdelivr.jolibox.com";var We=window.document.currentScript;We&&(fe=new URL(We.src).origin);var ue=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,pe=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/implement@${e}/dist/index.js`,Er=e=>/^\d+\.\d+\.\d+$/.test(e),Xe=Er(F)?qe:F,ze=ue(Xe),Ye=pe(Xe);function yr(){Qe?He(gr,{bootstrapUrl:ze,implementUrl:Ye})():Ge({bootstrapUrl:ze,implementUrl:Ye,currentMajorVersion:qe,currentVersion:F})()}yr();var vr=f();function Ze(){return vr.excuteCommandSync("API.getSystemInfoSync")}function et(e,t){var r;return(r=Pe.config[e])==null?void 0:r[t]}function tt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var nt="1.1.48";function g(e){let[t,...r]=e.split(":"),n=et(ae()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||ne(nt,o,"<")?!1:r.length===0?!0:rt(n,r)||rt(n.properties,r)}function rt(e,t){if(!e)return!1;let r=tt(e,t);return r?Te(r)?!0:re(r)?ne(nt,r,">="):!1:!1}var ot=f();function st(){return m(this,null,function*(){return g("login")?yield ot.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function it(){return m(this,null,function*(){return g("checkSession")?yield ot.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Sr=f();function at(e){return m(this,null,function*(){return g("request")?yield Sr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var he=["onI18nChanged","onBackPress"],ct=(e,t)=>{if(!he.includes(e)){v(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},lt=(e,t)=>{if(!he.includes(e)){v(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},mt=(e,t)=>{if(!he.includes(e)){v(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var _r=f();function dt(e){return m(this,null,function*(){return g("isNativeSupport")?yield _r.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var u=class{constructor(){this.commands=f();this._emitter=new ce}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return g(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ge=class extends u{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},ut=window.JoliboxRuntime||ge;var br="LifecycleSDK.onReady",B=class extends u{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(br,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends u{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends u{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return m(this,null,function*(){})}};var G=class extends u{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var H=class extends u{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var Rr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],W=class extends u{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Rr.includes(t)?yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r):{code:"FAILURE",message:"invalid path"})})}};var E=class E{constructor(){this.jssdkVersion="1.1.48";this.runtime=new ut;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new G;this.task=new H;this.router=new W;this.getSystemInfoSync=Ze.bind(this);this.canIUse=g.bind(this);this.login=st.bind(this);this.checkSession=it.bind(this);this.request=at.bind(this);this.on=ct.bind(this);this.off=lt.bind(this);this.once=mt.bind(this);this.isNativeSupport=dt.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var z=E;window.JoliboxSDK=z;
1
+ "use strict";var U=Object.defineProperty,ht=Object.defineProperties,gt=Object.getOwnPropertyDescriptor,Et=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertyNames,Se=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,C=(e,t)=>{for(var r in t||(t={}))be.call(t,r)&&_e(e,r,t[r]);if(Se)for(var r of Se(t))vt.call(t,r)&&_e(e,r,t[r]);return e},O=(e,t)=>ht(e,Et(t));var St=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0})},_t=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of yt(t))!be.call(e,o)&&o!==r&&U(e,o,{get:()=>t[o],enumerable:!(n=gt(t,o))||n.enumerable});return e};var bt=e=>_t(U({},"__esModule",{value:!0}),e);var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});var Tr={};St(Tr,{JoliboxSDK:()=>q});module.exports=bt(Tr);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}var re=Object.defineProperty,Rt=Object.defineProperties,xt=Object.getOwnPropertyDescriptor,It=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertySymbols,wt=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable,xe=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Lt=(e,t)=>{for(var r in t||(t={}))wt.call(t,r)&&xe(e,r,t[r]);if(Re)for(var r of Re(t))Tt.call(t,r)&&xe(e,r,t[r]);return e},At=(e,t)=>Rt(e,It(t)),Dt=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},Te=(e,t,r,n)=>{for(var o=n>1?void 0:n?xt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&re(t,r,o),o},Pt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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}function Ut(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ne(e){return typeof e=="string"}function Le(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Ct(e){return typeof e=="undefined"}function Ot(e){return Ct(e)||e===null}function kt(e){return typeof e=="function"}function Ae(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Nt=(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))(Nt||{}),M=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}},De=class extends M{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Pe=class extends De{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends De{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var j=class extends M{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}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Kt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Kt});var Q=Symbol.for("Jolibox.canIUseMap"),Mt={};globalThis[Q]||(globalThis[Q]=Mt);var Ue={get config(){return globalThis[Q]}};var Ie=Symbol.for("Jolibox.canIUseMap.native"),jt={};globalThis[Ie]||(globalThis[Ie]=jt);function oe(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var se=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(se||{}),ie=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ie||{}),Jt=(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))(Jt||{}),we=["name","params"],Ft=["name","type","location","target","extra","timestamp","userId"],Bt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function N(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Vt(e){let t=e.location?N(e.location,we):null,r=e.target?N(e.target,we):null;return N(At(Lt({},e),{location:t,target:r}),Ft)}function Ce(e){let t=e.events.map(n=>Vt(n)),r=N(e.device,Bt);return[e.protocolVersion,t,r,e.project]}var $t=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function ae(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};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}}ae();var S=typeof window=="undefined",ce=()=>!S&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),k={isiOS:!S&&(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:!S&&navigator.userAgent.includes("Android"),isMac:!S&&navigator.userAgent.includes("Mac"),isFacebook:!S&&navigator.userAgent.includes("FB_IAB"),isPC:!S&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Ht=()=>k.isiOS?"iOS":k.isAndroid?"Android":k.isMac?"Mac":k.isFacebook?"Facebook":"PC",Gt="device_id",Wt="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,$t()),window.__joliboxLocalStorage__.getItem(e)),zt=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe(Gt),qt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(Wt),Yt=e=>e.charAt(0).toUpperCase()+e.slice(1),Qt=()=>{var e;let t=new URLSearchParams(window.location.search);return Yt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},ke=e=>{if(ce())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Ht(),n=navigator.language,o=zt(),s=qt();return`${t} (${Qt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},X=class Z{constructor(t){this.element=t,this.next=Z.Undefined,this.prev=Z.Undefined}};X.Undefined=new X(void 0);var d=X,Xt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.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!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Zt=0,I=class{constructor(e){this.value=e,this.id=Zt++}},w=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 I&&(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,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new I(t);return this._listeners?this._listeners instanceof I?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,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var f,h,y,ye;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(h=(f=this.options)==null?void 0:f.onDidRemoveLastListener)==null||h.call(f));else if(this._listeners){let ve=this._listeners.indexOf(c);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((ye=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ye.call(y)))}}}}),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 I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},le=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Xt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},ee={};Dt(ee,{None:()=>er,filter:()=>rr,once:()=>Ne,toPromise:()=>tr});var er=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function tr(e){return new Promise(t=>Ne(e)(t))}function Ne(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function rr(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var Y=Symbol.for("Jolibox.hostEmitter"),nr=()=>{let e=new le;return globalThis[Y]||(globalThis[Y]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Y]},_=nr();function or(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)sr(e[n],t[n])}function sr(e,t){if(ne(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(kt(t)){try{if(e instanceof t)return}catch(r){}if(!Ot(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")}}var K=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,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 or(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}};K=Te([Ae],K);var te=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new K,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Ut(3e4)),this._starActivation}executeCommand(e,...t){return Pt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),ee.toPromise(ee.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}}};te=Te([Ae],te);var Ke=Symbol.for("Jolibox.commands");function ir(){return typeof globalThis!="undefined"?globalThis[Ke]:void 0}function ar(e){typeof globalThis!="undefined"&&(globalThis[Ke]=e)}function u(e=!1){let t=ir();if(!e&&t)return t;let r=new K,n=new te,o={registerCommand(s,a,l){r.registerCommand({id:s,handler:a,metadata:l})},executeCommand(s,...a){return n.executeCommand(s,...a)},excuteCommandSync(s,...a){return n.executeCommandThowErr(s,...a)}};return ar(o),o}var J=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function cr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function lr(){return{platform:1e3,os:"h5",appVersion:"1.1.50",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.50",extra:{}}}var Me={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"}},mr=()=>{var t;let e=(t=Me[window.location.host])!=null?t:Me.default;return J?e.test:e.prod},dr=mr(),Je=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},je;(je=AbortSignal.timeout)!=null||(AbortSignal.timeout=Je);var ur=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},pr=ur(),fr=e=>m(void 0,null,function*(){try{let r=`${dr}/report`,n=ke("1.1.50"),o=pr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Je(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:se.ErrorTrace,location:cr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=lr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ie.WebSDK},s=Ce(o);yield fr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",L.startTime));var hr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=hr(),Fe=u(),me=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof M?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},v=me;window.addEventListener("unhandledrejection",me.bind(void 0));window.addEventListener("error",me.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{b({err:JSON.stringify(s)})})};var de=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},A=e=>parseInt(de(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=de(e),{major:a,minor:l,patch:i,prerelease:c}=de(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Be=u(),F=(e,t)=>{Be.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ae();var He="jolibox-sdk-loadermeta",$e,P=JSON.parse(($e=window.__joliboxLocalStorage__.getItem(He))!=null?$e:"{}"),ue=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function gr(){return m(this,null,function*(){let t=`${J?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=O(C({},P),{timestamp:ue});if(o){let{bootstrap_version:a}=P;a&&D(a,o)>=0||(s=O(C({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=P;a&&D(a,n)>=0||(s=O(C({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(He,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ge=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=P;i&&c&&!Ve(ue,c)&&A(i)==t&&D(i,r)>=0&&(n=pe(i));try{let f=new XMLHttpRequest;return f.open("GET",n,!1),f.send(),{script:f.responseText,type:"fetch_from_cdn"}}catch(f){let h=new Pe(`Bootstrap module faile to fetch ${f}`);b({err:`${h}`})}}function a(){var h;let i=Date.now();F("jsSdkBegin",{t:i}),L.startTime=i;let{script:c,type:f}=(h=s())!=null?h:{};if(c){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=c,document.head.appendChild(y),R("bootstrapModuleLoaded",Date.now()-i,{type:f})}}function l(){let i=Date.now(),{implement_version:c,timestamp:f}=P;c&&f&&!Ve(ue,f)&&A(c)==t&&D(c,r)>=0&&(o=fe(c));let h=document.createElement("script");h.type="module",h.crossOrigin="anonymous",h.src=o,h.onload=()=>{R("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(h)}return()=>{try{a(),l(),gr()}catch(i){let c=new T(`module evaluate error: ${i}`);b({err:`${c}`})}}};var We=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){v(new T(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();F("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),R("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),v(new T(`module load failed ${o}`))}}};var Er="1.1.50",B=Er,Qe=A(B),Xe=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),yr=Xe?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,he="https://jsdelivr.jolibox.com";var ze=window.document.currentScript;ze&&(he=new URL(ze.src).origin);var pe=(e,t)=>`${t!=null?t:he}/npm/@jolibox/bootstrap@${e}/dist/index.js`,fe=(e,t)=>`${t!=null?t:he}/npm/@jolibox/implement@${e}/dist/index.js`,vr=e=>/^\d+\.\d+\.\d+$/.test(e),Ze=vr(B)?Qe:B,qe=pe(Ze),Ye=fe(Ze);function Sr(){Xe?We(yr,{bootstrapUrl:qe,implementUrl:Ye})():Ge({bootstrapUrl:qe,implementUrl:Ye,currentMajorVersion:Qe,currentVersion:B})()}Sr();var _r=u();function et(){return _r.excuteCommandSync("API.getSystemInfoSync")}function tt(e,t){var r;return(r=Ue.config[e])==null?void 0:r[t]}function rt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var ot="1.1.50";function g(e){let[t,...r]=e.split(":"),n=tt(ce()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||oe(ot,o,"<")?!1:r.length===0?!0:nt(n,r)||nt(n.properties,r)}function nt(e,t){if(!e)return!1;let r=rt(e,t);return r?Le(r)?!0:ne(r)?oe(ot,r,">="):!1:!1}var st=u();function it(){return m(this,null,function*(){return g("login")?yield st.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function at(){return m(this,null,function*(){return g("checkSession")?yield st.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var br=u();function ct(e){return m(this,null,function*(){return g("request")?yield br.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ge=["onI18nChanged","onBackPress"],lt=(e,t)=>{if(!ge.includes(e)){v(new j(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},mt=(e,t)=>{if(!ge.includes(e)){v(new j(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},dt=(e,t)=>{if(!ge.includes(e)){v(new j(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var Rr=u();function ut(e){return m(this,null,function*(){return g("isNativeSupport")?yield Rr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var xr=u();function pt(e){return m(this,null,function*(){return g("callHostMethod")?yield xr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new le}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return g(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var Ee=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},ft=window.JoliboxRuntime||Ee;var Ir="LifecycleSDK.onReady",V=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Ir,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var $=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var H=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return m(this,null,function*(){})}};var G=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var W=class extends p{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:a}=t,l=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return l?Promise.resolve(l):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:a})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var wr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],z=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(wr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var E=class E{constructor(){this.jssdkVersion="1.1.50";this.runtime=new ft;this.ads=new H;this.lifecycle=new V;this.storage=new $;this.keyboard=new G;this.task=new W;this.router=new z;this.getSystemInfoSync=et.bind(this);this.canIUse=g.bind(this);this.login=it.bind(this);this.checkSession=at.bind(this);this.request=ct.bind(this);this.on=lt.bind(this);this.off=mt.bind(this);this.once=dt.bind(this);this.isNativeSupport=ut.bind(this);this.callHostMethod=pt.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var q=E;window.JoliboxSDK=q;
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import './loader';
7
7
  /**
8
8
  * @public Jolibox JS SDK Entry
9
9
  */
10
- import { getSystemInfoSync, isNativeSupport, canIUse, login, checkSession, request } from './api';
10
+ import { getSystemInfoSync, isNativeSupport, canIUse, login, checkSession, request, callHostMethod } from './api';
11
11
  import { RuntimeSDK } from './sdks/runtime';
12
12
  import { LifecycleSDK } from './sdks/lifecycle';
13
13
  import { StorageSDK } from './sdks/storage';
@@ -164,6 +164,14 @@ export declare class JoliboxSDK {
164
164
  * @private
165
165
  */
166
166
  isNativeSupport: typeof isNativeSupport;
167
+ /**
168
+ * @private
169
+ * Calls a host method.
170
+ * @see {@link callHostMethod} for more details.
171
+ * @param {ICallHostMethodParams} params - Parameters for the host method.
172
+ * @returns {Promise<void>} A promise that resolves with the host method response.
173
+ */
174
+ callHostMethod: typeof callHostMethod;
167
175
  /**
168
176
  * @public
169
177
  * Constructs a new JoliboxSDK instance or returns the existing singleton instance.
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- var dt=Object.defineProperty,ut=Object.defineProperties;var pt=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var ft=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var ve=(e,t,r)=>t in e?dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))ft.call(t,r)&&ve(e,r,t[r]);if(ye)for(var r of ye(t))ht.call(t,r)&&ve(e,r,t[r]);return e},U=(e,t)=>ut(e,pt(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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}var Z=Object.defineProperty,gt=Object.defineProperties,Et=Object.getOwnPropertyDescriptor,yt=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,vt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,_e=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,_t=(e,t)=>{for(var r in t||(t={}))vt.call(t,r)&&_e(e,r,t[r]);if(Se)for(var r of Se(t))St.call(t,r)&&_e(e,r,t[r]);return e},bt=(e,t)=>gt(e,yt(t)),Rt=(e,t)=>{for(var r in t)Z(e,r,{get:t[r],enumerable:!0})},xe=(e,t,r,n)=>{for(var o=n>1?void 0:n?Et(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&Z(t,r,o),o},xt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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}function It(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ee(e){return typeof e=="string"}function Ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function wt(e){return typeof e=="undefined"}function Tt(e){return wt(e)||e===null}function Lt(e){return typeof e=="function"}function we(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var At=(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))(At||{}),N=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}},Te=class extends N{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Le=class extends Te{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},w=class extends Te{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var K=class extends N{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}}};function R(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Dt={log:R("log"),warn:R("warn"),info:R("info"),error:R("error"),debug:R("debug")};Object.assign(globalThis,{logger:Dt});var z=Symbol.for("Jolibox.canIUseMap"),Pt={};globalThis[z]||(globalThis[z]=Pt);var Ae={get config(){return globalThis[z]}};var be=Symbol.for("Jolibox.canIUseMap.native"),Ut={};globalThis[be]||(globalThis[be]=Ut);function te(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var re=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(re||{}),ne=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ne||{}),Ot=(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))(Ot||{}),Re=["name","params"],Ct=["name","type","location","target","extra","timestamp","userId"],kt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function C(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Nt(e){let t=e.location?C(e.location,Re):null,r=e.target?C(e.target,Re):null;return C(bt(_t({},e),{location:t,target:r}),Ct)}function De(e){let t=e.events.map(n=>Nt(n)),r=C(e.device,kt);return[e.protocolVersion,t,r,e.project]}var Kt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function oe(){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}}oe();var se=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={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")},Mt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",jt="device_id",Jt="advertising_id",Pe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Kt()),window.__joliboxLocalStorage__.getItem(e)),Ft=()=>new URLSearchParams(window.location.search).get("deviceId")||Pe(jt),Bt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Pe(Jt),Vt=e=>e.charAt(0).toUpperCase()+e.slice(1),$t=()=>{var e;let t=new URLSearchParams(window.location.search);return Vt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ue=e=>{if(se())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Mt(),n=navigator.language,o=Ft(),s=Bt();return`${t} (${$t()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},Y=class q{constructor(t){this.element=t,this.next=q.Undefined,this.prev=q.Undefined}};Y.Undefined=new Y(void 0);var d=Y,Gt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.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!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Ht=0,x=class{constructor(e){this.value=e,this.id=Ht++}},I=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 x&&(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,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new x(t);return this._listeners?this._listeners instanceof x?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,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var p,h,y,ge;if(!this._disposed){if(this._listeners instanceof x)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(h=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||h.call(p));else if(this._listeners){let Ee=this._listeners.indexOf(c);Ee>=0&&(this._listeners.splice(Ee,1),this._size--,this._size===0&&((ge=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ge.call(y)))}}}}),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 x?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ie=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new I,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Gt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},Q={};Rt(Q,{None:()=>Wt,filter:()=>Yt,once:()=>Oe,toPromise:()=>zt});var Wt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function zt(e){return new Promise(t=>Oe(e)(t))}function Oe(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Yt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new I(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var W=Symbol.for("Jolibox.hostEmitter"),qt=()=>{let e=new ie;return globalThis[W]||(globalThis[W]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[W]},S=qt();function Qt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Xt(e[n],t[n])}function Xt(e,t){if(ee(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Lt(t)){try{if(e instanceof t)return}catch(r){}if(!Tt(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")}}var k=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new I,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 Qt(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}};k=xe([we],k);var X=class{constructor(){this._onWillExecuteCommand=new I,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new I,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=It(3e4)),this._starActivation}executeCommand(e,...t){return xt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Q.toPromise(Q.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}}};X=xe([we],X);var Ce=Symbol.for("Jolibox.commands");function Zt(){return typeof globalThis!="undefined"?globalThis[Ce]:void 0}function er(e){typeof globalThis!="undefined"&&(globalThis[Ce]=e)}function f(e=!1){let t=Zt();if(!e&&t)return t;let r=new k,n=new X,o={registerCommand(s,a,l){r.registerCommand({id:s,handler:a,metadata:l})},executeCommand(s,...a){return n.executeCommand(s,...a)},excuteCommandSync(s,...a){return n.executeCommandThowErr(s,...a)}};return er(o),o}var M=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function tr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function rr(){return{platform:1e3,os:"h5",appVersion:"1.1.48",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.48",extra:{}}}var ke={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"}},nr=()=>{var t;let e=(t=ke[window.location.host])!=null?t:ke.default;return M?e.test:e.prod},or=nr(),Ke=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ne;(Ne=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ke);var sr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},ir=sr(),ar=e=>m(void 0,null,function*(){try{let r=`${or}/report`,n=Ue("1.1.48"),o=ir,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Ke(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function _(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:tr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=rr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=De(o);yield ar(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",T.startTime));var cr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=cr(),Me=f(),ae=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof N?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Me.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),_({err:JSON.stringify(t)})})},v=ae;window.addEventListener("unhandledrejection",ae.bind(void 0));window.addEventListener("error",ae.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Me.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{_({err:JSON.stringify(s)})})};var ce=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},L=e=>parseInt(ce(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ce(e),{major:a,minor:l,patch:i,prerelease:c}=ce(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var je=f(),j=(e,t)=>{je.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{je.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Be="jolibox-sdk-loadermeta",Fe,D=JSON.parse((Fe=window.__joliboxLocalStorage__.getItem(Be))!=null?Fe:"{}"),le=Date.now(),Je=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function lr(){return m(this,null,function*(){let t=`${M?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=U(P({},D),{timestamp:le});if(o){let{bootstrap_version:a}=D;a&&A(a,o)>=0||(s=U(P({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=D;a&&A(a,n)>=0||(s=U(P({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Be,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ve=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=D;i&&c&&!Je(le,c)&&L(i)==t&&A(i,r)>=0&&(n=me(i));try{let p=new XMLHttpRequest;return p.open("GET",n,!1),p.send(),{script:p.responseText,type:"fetch_from_cdn"}}catch(p){let h=new Le(`Bootstrap module faile to fetch ${p}`);_({err:`${h}`})}}function a(){var h;let i=Date.now();j("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:p}=(h=s())!=null?h:{};if(c){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=c,document.head.appendChild(y),b("bootstrapModuleLoaded",Date.now()-i,{type:p})}}function l(){let i=Date.now(),{implement_version:c,timestamp:p}=D;c&&p&&!Je(le,p)&&L(c)==t&&A(c,r)>=0&&(o=de(c));let h=document.createElement("script");h.type="module",h.crossOrigin="anonymous",h.src=o,h.onload=()=>{b("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(h)}return()=>{try{a(),l(),lr()}catch(i){let c=new w(`module evaluate error: ${i}`);_({err:`${c}`})}}};var $e=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){v(new w(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();j("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),b("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),v(new w(`module load failed ${o}`))}}};var mr="1.1.48",J=mr,ze=L(J),Ye=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),dr=Ye?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,ue="https://jsdelivr.jolibox.com";var Ge=window.document.currentScript;Ge&&(ue=new URL(Ge.src).origin);var me=(e,t)=>`${t!=null?t:ue}/npm/@jolibox/bootstrap@${e}/dist/index.js`,de=(e,t)=>`${t!=null?t:ue}/npm/@jolibox/implement@${e}/dist/index.js`,ur=e=>/^\d+\.\d+\.\d+$/.test(e),qe=ur(J)?ze:J,He=me(qe),We=de(qe);function pr(){Ye?$e(dr,{bootstrapUrl:He,implementUrl:We})():Ve({bootstrapUrl:He,implementUrl:We,currentMajorVersion:ze,currentVersion:J})()}pr();var fr=f();function Qe(){return fr.excuteCommandSync("API.getSystemInfoSync")}function Xe(e,t){var r;return(r=Ae.config[e])==null?void 0:r[t]}function Ze(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var tt="1.1.48";function g(e){let[t,...r]=e.split(":"),n=Xe(se()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||te(tt,o,"<")?!1:r.length===0?!0:et(n,r)||et(n.properties,r)}function et(e,t){if(!e)return!1;let r=Ze(e,t);return r?Ie(r)?!0:ee(r)?te(tt,r,">="):!1:!1}var rt=f();function nt(){return m(this,null,function*(){return g("login")?yield rt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ot(){return m(this,null,function*(){return g("checkSession")?yield rt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var hr=f();function st(e){return m(this,null,function*(){return g("request")?yield hr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var pe=["onI18nChanged","onBackPress"],it=(e,t)=>{if(!pe.includes(e)){v(new K(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},at=(e,t)=>{if(!pe.includes(e)){v(new K(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},ct=(e,t)=>{if(!pe.includes(e)){v(new K(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var gr=f();function lt(e){return m(this,null,function*(){return g("isNativeSupport")?yield gr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var u=class{constructor(){this.commands=f();this._emitter=new ie}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return g(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var fe=class extends u{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},mt=window.JoliboxRuntime||fe;var Er="LifecycleSDK.onReady",F=class extends u{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Er,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var B=class extends u{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var V=class extends u{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return m(this,null,function*(){})}};var $=class extends u{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var G=class extends u{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var yr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],H=class extends u{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(yr.includes(t)?yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r):{code:"FAILURE",message:"invalid path"})})}};var E=class E{constructor(){this.jssdkVersion="1.1.48";this.runtime=new mt;this.ads=new V;this.lifecycle=new F;this.storage=new B;this.keyboard=new $;this.task=new G;this.router=new H;this.getSystemInfoSync=Qe.bind(this);this.canIUse=g.bind(this);this.login=nt.bind(this);this.checkSession=ot.bind(this);this.request=st.bind(this);this.on=it.bind(this);this.off=at.bind(this);this.once=ct.bind(this);this.isNativeSupport=lt.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var he=E;window.JoliboxSDK=he;export{he as JoliboxSDK};
1
+ var pt=Object.defineProperty,ft=Object.defineProperties;var ht=Object.getOwnPropertyDescriptors;var ve=Object.getOwnPropertySymbols;var gt=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable;var Se=(e,t,r)=>t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))gt.call(t,r)&&Se(e,r,t[r]);if(ve)for(var r of ve(t))Et.call(t,r)&&Se(e,r,t[r]);return e},C=(e,t)=>ft(e,ht(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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}var ee=Object.defineProperty,yt=Object.defineProperties,vt=Object.getOwnPropertyDescriptor,St=Object.getOwnPropertyDescriptors,_e=Object.getOwnPropertySymbols,_t=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Rt=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&be(e,r,t[r]);if(_e)for(var r of _e(t))bt.call(t,r)&&be(e,r,t[r]);return e},xt=(e,t)=>yt(e,St(t)),It=(e,t)=>{for(var r in t)ee(e,r,{get:t[r],enumerable:!0})},Ie=(e,t,r,n)=>{for(var o=n>1?void 0:n?vt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&ee(t,r,o),o},wt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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}function Tt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function te(e){return typeof e=="string"}function we(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Lt(e){return typeof e=="undefined"}function At(e){return Lt(e)||e===null}function Dt(e){return typeof e=="function"}function Te(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Pt=(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))(Pt||{}),K=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}},Le=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ae=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends K{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}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Ut={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Ut});var q=Symbol.for("Jolibox.canIUseMap"),Ct={};globalThis[q]||(globalThis[q]=Ct);var De={get config(){return globalThis[q]}};var Re=Symbol.for("Jolibox.canIUseMap.native"),Ot={};globalThis[Re]||(globalThis[Re]=Ot);function re(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var ne=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ne||{}),oe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(oe||{}),kt=(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))(kt||{}),xe=["name","params"],Nt=["name","type","location","target","extra","timestamp","userId"],Kt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Mt(e){let t=e.location?k(e.location,xe):null,r=e.target?k(e.target,xe):null;return k(xt(Rt({},e),{location:t,target:r}),Nt)}function Pe(e){let t=e.events.map(n=>Mt(n)),r=k(e.device,Kt);return[e.protocolVersion,t,r,e.project]}var jt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function se(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};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}}se();var S=typeof window=="undefined",ie=()=>!S&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!S&&(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:!S&&navigator.userAgent.includes("Android"),isMac:!S&&navigator.userAgent.includes("Mac"),isFacebook:!S&&navigator.userAgent.includes("FB_IAB"),isPC:!S&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Jt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Ft="device_id",Bt="advertising_id",Ue=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,jt()),window.__joliboxLocalStorage__.getItem(e)),Vt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ue(Ft),$t=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ue(Bt),Ht=e=>e.charAt(0).toUpperCase()+e.slice(1),Gt=()=>{var e;let t=new URLSearchParams(window.location.search);return Ht((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ce=e=>{if(ie())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Jt(),n=navigator.language,o=Vt(),s=$t();return`${t} (${Gt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},Y=class Q{constructor(t){this.element=t,this.next=Q.Undefined,this.prev=Q.Undefined}};Y.Undefined=new Y(void 0);var d=Y,Wt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.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!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},zt=0,I=class{constructor(e){this.value=e,this.id=zt++}},w=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 I&&(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,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new I(t);return this._listeners?this._listeners instanceof I?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,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var f,h,y,Ee;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(h=(f=this.options)==null?void 0:f.onDidRemoveLastListener)==null||h.call(f));else if(this._listeners){let ye=this._listeners.indexOf(c);ye>=0&&(this._listeners.splice(ye,1),this._size--,this._size===0&&((Ee=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||Ee.call(y)))}}}}),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 I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ae=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Wt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},X={};It(X,{None:()=>qt,filter:()=>Qt,once:()=>Oe,toPromise:()=>Yt});var qt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Yt(e){return new Promise(t=>Oe(e)(t))}function Oe(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Qt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var z=Symbol.for("Jolibox.hostEmitter"),Xt=()=>{let e=new ae;return globalThis[z]||(globalThis[z]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[z]},_=Xt();function Zt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)er(e[n],t[n])}function er(e,t){if(te(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Dt(t)){try{if(e instanceof t)return}catch(r){}if(!At(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")}}var N=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,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 Zt(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}};N=Ie([Te],N);var Z=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new N,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Tt(3e4)),this._starActivation}executeCommand(e,...t){return wt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),X.toPromise(X.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}}};Z=Ie([Te],Z);var ke=Symbol.for("Jolibox.commands");function tr(){return typeof globalThis!="undefined"?globalThis[ke]:void 0}function rr(e){typeof globalThis!="undefined"&&(globalThis[ke]=e)}function u(e=!1){let t=tr();if(!e&&t)return t;let r=new N,n=new Z,o={registerCommand(s,a,l){r.registerCommand({id:s,handler:a,metadata:l})},executeCommand(s,...a){return n.executeCommand(s,...a)},excuteCommandSync(s,...a){return n.executeCommandThowErr(s,...a)}};return rr(o),o}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function nr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function or(){return{platform:1e3,os:"h5",appVersion:"1.1.50",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.50",extra:{}}}var Ne={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"}},sr=()=>{var t;let e=(t=Ne[window.location.host])!=null?t:Ne.default;return j?e.test:e.prod},ir=sr(),Me=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ke;(Ke=AbortSignal.timeout)!=null||(AbortSignal.timeout=Me);var ar=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},cr=ar(),lr=e=>m(void 0,null,function*(){try{let r=`${ir}/report`,n=Ce("1.1.50"),o=cr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Me(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:ne.ErrorTrace,location:nr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=or(),o={protocolVersion:"1.0.0",events:[t],device:r,project:oe.WebSDK},s=Pe(o);yield lr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",L.startTime));var mr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=mr(),je=u(),ce=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};je.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},v=ce;window.addEventListener("unhandledrejection",ce.bind(void 0));window.addEventListener("error",ce.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};je.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{b({err:JSON.stringify(s)})})};var le=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},A=e=>parseInt(le(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=le(e),{major:a,minor:l,patch:i,prerelease:c}=le(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Je=u(),J=(e,t)=>{Je.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Je.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};se();var Ve="jolibox-sdk-loadermeta",Be,P=JSON.parse((Be=window.__joliboxLocalStorage__.getItem(Ve))!=null?Be:"{}"),me=Date.now(),Fe=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function dr(){return m(this,null,function*(){let t=`${j?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=C(U({},P),{timestamp:me});if(o){let{bootstrap_version:a}=P;a&&D(a,o)>=0||(s=C(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=P;a&&D(a,n)>=0||(s=C(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ve,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var $e=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=P;i&&c&&!Fe(me,c)&&A(i)==t&&D(i,r)>=0&&(n=de(i));try{let f=new XMLHttpRequest;return f.open("GET",n,!1),f.send(),{script:f.responseText,type:"fetch_from_cdn"}}catch(f){let h=new Ae(`Bootstrap module faile to fetch ${f}`);b({err:`${h}`})}}function a(){var h;let i=Date.now();J("jsSdkBegin",{t:i}),L.startTime=i;let{script:c,type:f}=(h=s())!=null?h:{};if(c){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=c,document.head.appendChild(y),R("bootstrapModuleLoaded",Date.now()-i,{type:f})}}function l(){let i=Date.now(),{implement_version:c,timestamp:f}=P;c&&f&&!Fe(me,f)&&A(c)==t&&D(c,r)>=0&&(o=ue(c));let h=document.createElement("script");h.type="module",h.crossOrigin="anonymous",h.src=o,h.onload=()=>{R("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(h)}return()=>{try{a(),l(),dr()}catch(i){let c=new T(`module evaluate error: ${i}`);b({err:`${c}`})}}};var He=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){v(new T(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),R("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),v(new T(`module load failed ${o}`))}}};var ur="1.1.50",F=ur,qe=A(F),Ye=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),pr=Ye?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,pe="https://jsdelivr.jolibox.com";var Ge=window.document.currentScript;Ge&&(pe=new URL(Ge.src).origin);var de=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,ue=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/implement@${e}/dist/index.js`,fr=e=>/^\d+\.\d+\.\d+$/.test(e),Qe=fr(F)?qe:F,We=de(Qe),ze=ue(Qe);function hr(){Ye?He(pr,{bootstrapUrl:We,implementUrl:ze})():$e({bootstrapUrl:We,implementUrl:ze,currentMajorVersion:qe,currentVersion:F})()}hr();var gr=u();function Xe(){return gr.excuteCommandSync("API.getSystemInfoSync")}function Ze(e,t){var r;return(r=De.config[e])==null?void 0:r[t]}function et(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var rt="1.1.50";function g(e){let[t,...r]=e.split(":"),n=Ze(ie()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||re(rt,o,"<")?!1:r.length===0?!0:tt(n,r)||tt(n.properties,r)}function tt(e,t){if(!e)return!1;let r=et(e,t);return r?we(r)?!0:te(r)?re(rt,r,">="):!1:!1}var nt=u();function ot(){return m(this,null,function*(){return g("login")?yield nt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function st(){return m(this,null,function*(){return g("checkSession")?yield nt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Er=u();function it(e){return m(this,null,function*(){return g("request")?yield Er.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var fe=["onI18nChanged","onBackPress"],at=(e,t)=>{if(!fe.includes(e)){v(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},ct=(e,t)=>{if(!fe.includes(e)){v(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},lt=(e,t)=>{if(!fe.includes(e)){v(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var yr=u();function mt(e){return m(this,null,function*(){return g("isNativeSupport")?yield yr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var vr=u();function dt(e){return m(this,null,function*(){return g("callHostMethod")?yield vr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new ae}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return g(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var he=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},ut=window.JoliboxRuntime||he;var Sr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Sr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return m(this,null,function*(){})}};var H=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var G=class extends p{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:a}=t,l=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return l?Promise.resolve(l):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:a})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var _r=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],W=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(_r.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var E=class E{constructor(){this.jssdkVersion="1.1.50";this.runtime=new ut;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new H;this.task=new G;this.router=new W;this.getSystemInfoSync=Xe.bind(this);this.canIUse=g.bind(this);this.login=ot.bind(this);this.checkSession=st.bind(this);this.request=it.bind(this);this.on=at.bind(this);this.off=ct.bind(this);this.once=lt.bind(this);this.isNativeSupport=mt.bind(this);this.callHostMethod=dt.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var ge=E;window.JoliboxSDK=ge;export{ge as JoliboxSDK};
@@ -1 +1 @@
1
- "use strict";(()=>{var dt=Object.defineProperty,ut=Object.defineProperties;var pt=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var ft=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var ve=(e,t,r)=>t in e?dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))ft.call(t,r)&&ve(e,r,t[r]);if(ye)for(var r of ye(t))ht.call(t,r)&&ve(e,r,t[r]);return e},U=(e,t)=>ut(e,pt(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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}var Z=Object.defineProperty,gt=Object.defineProperties,Et=Object.getOwnPropertyDescriptor,yt=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,vt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,_e=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,_t=(e,t)=>{for(var r in t||(t={}))vt.call(t,r)&&_e(e,r,t[r]);if(Se)for(var r of Se(t))St.call(t,r)&&_e(e,r,t[r]);return e},bt=(e,t)=>gt(e,yt(t)),Rt=(e,t)=>{for(var r in t)Z(e,r,{get:t[r],enumerable:!0})},xe=(e,t,r,n)=>{for(var o=n>1?void 0:n?Et(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&Z(t,r,o),o},xt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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}function It(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ee(e){return typeof e=="string"}function Ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function wt(e){return typeof e=="undefined"}function Tt(e){return wt(e)||e===null}function Lt(e){return typeof e=="function"}function we(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var At=(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))(At||{}),N=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}},Te=class extends N{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Le=class extends Te{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},w=class extends Te{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var K=class extends N{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}}};function R(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Dt={log:R("log"),warn:R("warn"),info:R("info"),error:R("error"),debug:R("debug")};Object.assign(globalThis,{logger:Dt});var z=Symbol.for("Jolibox.canIUseMap"),Pt={};globalThis[z]||(globalThis[z]=Pt);var Ae={get config(){return globalThis[z]}};var be=Symbol.for("Jolibox.canIUseMap.native"),Ut={};globalThis[be]||(globalThis[be]=Ut);function te(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var re=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(re||{}),ne=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ne||{}),Ot=(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))(Ot||{}),Re=["name","params"],Ct=["name","type","location","target","extra","timestamp","userId"],kt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function C(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Nt(e){let t=e.location?C(e.location,Re):null,r=e.target?C(e.target,Re):null;return C(bt(_t({},e),{location:t,target:r}),Ct)}function De(e){let t=e.events.map(n=>Nt(n)),r=C(e.device,kt);return[e.protocolVersion,t,r,e.project]}var Kt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function oe(){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}}oe();var se=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={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")},Mt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",jt="device_id",Jt="advertising_id",Pe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Kt()),window.__joliboxLocalStorage__.getItem(e)),Ft=()=>new URLSearchParams(window.location.search).get("deviceId")||Pe(jt),Bt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Pe(Jt),Vt=e=>e.charAt(0).toUpperCase()+e.slice(1),$t=()=>{var e;let t=new URLSearchParams(window.location.search);return Vt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ue=e=>{if(se())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Mt(),n=navigator.language,o=Ft(),s=Bt();return`${t} (${$t()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},Y=class q{constructor(t){this.element=t,this.next=q.Undefined,this.prev=q.Undefined}};Y.Undefined=new Y(void 0);var d=Y,Gt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.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!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Ht=0,x=class{constructor(e){this.value=e,this.id=Ht++}},I=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 x&&(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,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new x(t);return this._listeners?this._listeners instanceof x?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,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var p,h,y,ge;if(!this._disposed){if(this._listeners instanceof x)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(h=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||h.call(p));else if(this._listeners){let Ee=this._listeners.indexOf(c);Ee>=0&&(this._listeners.splice(Ee,1),this._size--,this._size===0&&((ge=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ge.call(y)))}}}}),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 x?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ie=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new I,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Gt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},Q={};Rt(Q,{None:()=>Wt,filter:()=>Yt,once:()=>Oe,toPromise:()=>zt});var Wt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function zt(e){return new Promise(t=>Oe(e)(t))}function Oe(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Yt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new I(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var W=Symbol.for("Jolibox.hostEmitter"),qt=()=>{let e=new ie;return globalThis[W]||(globalThis[W]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[W]},S=qt();function Qt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Xt(e[n],t[n])}function Xt(e,t){if(ee(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Lt(t)){try{if(e instanceof t)return}catch(r){}if(!Tt(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")}}var k=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new I,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 Qt(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}};k=xe([we],k);var X=class{constructor(){this._onWillExecuteCommand=new I,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new I,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=It(3e4)),this._starActivation}executeCommand(e,...t){return xt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Q.toPromise(Q.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}}};X=xe([we],X);var Ce=Symbol.for("Jolibox.commands");function Zt(){return typeof globalThis!="undefined"?globalThis[Ce]:void 0}function er(e){typeof globalThis!="undefined"&&(globalThis[Ce]=e)}function f(e=!1){let t=Zt();if(!e&&t)return t;let r=new k,n=new X,o={registerCommand(s,a,l){r.registerCommand({id:s,handler:a,metadata:l})},executeCommand(s,...a){return n.executeCommand(s,...a)},excuteCommandSync(s,...a){return n.executeCommandThowErr(s,...a)}};return er(o),o}var M=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function tr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function rr(){return{platform:1e3,os:"h5",appVersion:"1.1.48",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.48",extra:{}}}var ke={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"}},nr=()=>{var t;let e=(t=ke[window.location.host])!=null?t:ke.default;return M?e.test:e.prod},or=nr(),Ke=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ne;(Ne=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ke);var sr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},ir=sr(),ar=e=>m(void 0,null,function*(){try{let r=`${or}/report`,n=Ue("1.1.48"),o=ir,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Ke(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function _(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:tr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=rr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=De(o);yield ar(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",T.startTime));var cr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=cr(),Me=f(),ae=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof N?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Me.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),_({err:JSON.stringify(t)})})},v=ae;window.addEventListener("unhandledrejection",ae.bind(void 0));window.addEventListener("error",ae.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Me.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{_({err:JSON.stringify(s)})})};var ce=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},L=e=>parseInt(ce(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ce(e),{major:a,minor:l,patch:i,prerelease:c}=ce(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var je=f(),j=(e,t)=>{je.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{je.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Be="jolibox-sdk-loadermeta",Fe,D=JSON.parse((Fe=window.__joliboxLocalStorage__.getItem(Be))!=null?Fe:"{}"),le=Date.now(),Je=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function lr(){return m(this,null,function*(){let t=`${M?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=U(P({},D),{timestamp:le});if(o){let{bootstrap_version:a}=D;a&&A(a,o)>=0||(s=U(P({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=D;a&&A(a,n)>=0||(s=U(P({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Be,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ve=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=D;i&&c&&!Je(le,c)&&L(i)==t&&A(i,r)>=0&&(n=me(i));try{let p=new XMLHttpRequest;return p.open("GET",n,!1),p.send(),{script:p.responseText,type:"fetch_from_cdn"}}catch(p){let h=new Le(`Bootstrap module faile to fetch ${p}`);_({err:`${h}`})}}function a(){var h;let i=Date.now();j("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:p}=(h=s())!=null?h:{};if(c){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=c,document.head.appendChild(y),b("bootstrapModuleLoaded",Date.now()-i,{type:p})}}function l(){let i=Date.now(),{implement_version:c,timestamp:p}=D;c&&p&&!Je(le,p)&&L(c)==t&&A(c,r)>=0&&(o=de(c));let h=document.createElement("script");h.type="module",h.crossOrigin="anonymous",h.src=o,h.onload=()=>{b("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(h)}return()=>{try{a(),l(),lr()}catch(i){let c=new w(`module evaluate error: ${i}`);_({err:`${c}`})}}};var $e=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){v(new w(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();j("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),b("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),v(new w(`module load failed ${o}`))}}};var mr="1.1.48",J=mr,ze=L(J),Ye=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),dr=Ye?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,ue="https://jsdelivr.jolibox.com";var Ge=window.document.currentScript;Ge&&(ue=new URL(Ge.src).origin);var me=(e,t)=>`${t!=null?t:ue}/npm/@jolibox/bootstrap@${e}/dist/index.js`,de=(e,t)=>`${t!=null?t:ue}/npm/@jolibox/implement@${e}/dist/index.js`,ur=e=>/^\d+\.\d+\.\d+$/.test(e),qe=ur(J)?ze:J,He=me(qe),We=de(qe);function pr(){Ye?$e(dr,{bootstrapUrl:He,implementUrl:We})():Ve({bootstrapUrl:He,implementUrl:We,currentMajorVersion:ze,currentVersion:J})()}pr();var fr=f();function Qe(){return fr.excuteCommandSync("API.getSystemInfoSync")}function Xe(e,t){var r;return(r=Ae.config[e])==null?void 0:r[t]}function Ze(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var tt="1.1.48";function g(e){let[t,...r]=e.split(":"),n=Xe(se()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||te(tt,o,"<")?!1:r.length===0?!0:et(n,r)||et(n.properties,r)}function et(e,t){if(!e)return!1;let r=Ze(e,t);return r?Ie(r)?!0:ee(r)?te(tt,r,">="):!1:!1}var rt=f();function nt(){return m(this,null,function*(){return g("login")?yield rt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ot(){return m(this,null,function*(){return g("checkSession")?yield rt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var hr=f();function st(e){return m(this,null,function*(){return g("request")?yield hr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var pe=["onI18nChanged","onBackPress"],it=(e,t)=>{if(!pe.includes(e)){v(new K(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},at=(e,t)=>{if(!pe.includes(e)){v(new K(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},ct=(e,t)=>{if(!pe.includes(e)){v(new K(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var gr=f();function lt(e){return m(this,null,function*(){return g("isNativeSupport")?yield gr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var u=class{constructor(){this.commands=f();this._emitter=new ie}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return g(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var fe=class extends u{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},mt=window.JoliboxRuntime||fe;var Er="LifecycleSDK.onReady",F=class extends u{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Er,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var B=class extends u{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var V=class extends u{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return m(this,null,function*(){})}};var $=class extends u{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var G=class extends u{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var yr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],H=class extends u{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(yr.includes(t)?yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r):{code:"FAILURE",message:"invalid path"})})}};var E=class E{constructor(){this.jssdkVersion="1.1.48";this.runtime=new mt;this.ads=new V;this.lifecycle=new F;this.storage=new B;this.keyboard=new $;this.task=new G;this.router=new H;this.getSystemInfoSync=Qe.bind(this);this.canIUse=g.bind(this);this.login=nt.bind(this);this.checkSession=ot.bind(this);this.request=st.bind(this);this.on=it.bind(this);this.off=at.bind(this);this.once=ct.bind(this);this.isNativeSupport=lt.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var he=E;window.JoliboxSDK=he;})();
1
+ "use strict";(()=>{var pt=Object.defineProperty,ft=Object.defineProperties;var ht=Object.getOwnPropertyDescriptors;var ve=Object.getOwnPropertySymbols;var gt=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable;var Se=(e,t,r)=>t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))gt.call(t,r)&&Se(e,r,t[r]);if(ve)for(var r of ve(t))Et.call(t,r)&&Se(e,r,t[r]);return e},C=(e,t)=>ft(e,ht(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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}var ee=Object.defineProperty,yt=Object.defineProperties,vt=Object.getOwnPropertyDescriptor,St=Object.getOwnPropertyDescriptors,_e=Object.getOwnPropertySymbols,_t=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Rt=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&be(e,r,t[r]);if(_e)for(var r of _e(t))bt.call(t,r)&&be(e,r,t[r]);return e},xt=(e,t)=>yt(e,St(t)),It=(e,t)=>{for(var r in t)ee(e,r,{get:t[r],enumerable:!0})},Ie=(e,t,r,n)=>{for(var o=n>1?void 0:n?vt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&ee(t,r,o),o},wt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((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}function Tt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function te(e){return typeof e=="string"}function we(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Lt(e){return typeof e=="undefined"}function At(e){return Lt(e)||e===null}function Dt(e){return typeof e=="function"}function Te(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Pt=(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))(Pt||{}),K=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}},Le=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ae=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends K{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}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Ut={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Ut});var q=Symbol.for("Jolibox.canIUseMap"),Ct={};globalThis[q]||(globalThis[q]=Ct);var De={get config(){return globalThis[q]}};var Re=Symbol.for("Jolibox.canIUseMap.native"),Ot={};globalThis[Re]||(globalThis[Re]=Ot);function re(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var ne=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ne||{}),oe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(oe||{}),kt=(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))(kt||{}),xe=["name","params"],Nt=["name","type","location","target","extra","timestamp","userId"],Kt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Mt(e){let t=e.location?k(e.location,xe):null,r=e.target?k(e.target,xe):null;return k(xt(Rt({},e),{location:t,target:r}),Nt)}function Pe(e){let t=e.events.map(n=>Mt(n)),r=k(e.device,Kt);return[e.protocolVersion,t,r,e.project]}var jt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function se(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};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}}se();var S=typeof window=="undefined",ie=()=>!S&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!S&&(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:!S&&navigator.userAgent.includes("Android"),isMac:!S&&navigator.userAgent.includes("Mac"),isFacebook:!S&&navigator.userAgent.includes("FB_IAB"),isPC:!S&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Jt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Ft="device_id",Bt="advertising_id",Ue=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,jt()),window.__joliboxLocalStorage__.getItem(e)),Vt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ue(Ft),$t=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ue(Bt),Ht=e=>e.charAt(0).toUpperCase()+e.slice(1),Gt=()=>{var e;let t=new URLSearchParams(window.location.search);return Ht((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ce=e=>{if(ie())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Jt(),n=navigator.language,o=Vt(),s=$t();return`${t} (${Gt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},Y=class Q{constructor(t){this.element=t,this.next=Q.Undefined,this.prev=Q.Undefined}};Y.Undefined=new Y(void 0);var d=Y,Wt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.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!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},zt=0,I=class{constructor(e){this.value=e,this.id=zt++}},w=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 I&&(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,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new I(t);return this._listeners?this._listeners instanceof I?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,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var f,h,y,Ee;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(h=(f=this.options)==null?void 0:f.onDidRemoveLastListener)==null||h.call(f));else if(this._listeners){let ye=this._listeners.indexOf(c);ye>=0&&(this._listeners.splice(ye,1),this._size--,this._size===0&&((Ee=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||Ee.call(y)))}}}}),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 I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ae=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Wt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},X={};It(X,{None:()=>qt,filter:()=>Qt,once:()=>Oe,toPromise:()=>Yt});var qt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Yt(e){return new Promise(t=>Oe(e)(t))}function Oe(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Qt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var z=Symbol.for("Jolibox.hostEmitter"),Xt=()=>{let e=new ae;return globalThis[z]||(globalThis[z]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[z]},_=Xt();function Zt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)er(e[n],t[n])}function er(e,t){if(te(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Dt(t)){try{if(e instanceof t)return}catch(r){}if(!At(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")}}var N=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,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 Zt(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}};N=Ie([Te],N);var Z=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new N,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Tt(3e4)),this._starActivation}executeCommand(e,...t){return wt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),X.toPromise(X.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}}};Z=Ie([Te],Z);var ke=Symbol.for("Jolibox.commands");function tr(){return typeof globalThis!="undefined"?globalThis[ke]:void 0}function rr(e){typeof globalThis!="undefined"&&(globalThis[ke]=e)}function u(e=!1){let t=tr();if(!e&&t)return t;let r=new N,n=new Z,o={registerCommand(s,a,l){r.registerCommand({id:s,handler:a,metadata:l})},executeCommand(s,...a){return n.executeCommand(s,...a)},excuteCommandSync(s,...a){return n.executeCommandThowErr(s,...a)}};return rr(o),o}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function nr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function or(){return{platform:1e3,os:"h5",appVersion:"1.1.50",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.50",extra:{}}}var Ne={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"}},sr=()=>{var t;let e=(t=Ne[window.location.host])!=null?t:Ne.default;return j?e.test:e.prod},ir=sr(),Me=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ke;(Ke=AbortSignal.timeout)!=null||(AbortSignal.timeout=Me);var ar=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},cr=ar(),lr=e=>m(void 0,null,function*(){try{let r=`${ir}/report`,n=Ce("1.1.50"),o=cr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Me(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:ne.ErrorTrace,location:nr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=or(),o={protocolVersion:"1.0.0",events:[t],device:r,project:oe.WebSDK},s=Pe(o);yield lr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",L.startTime));var mr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=mr(),je=u(),ce=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};je.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},v=ce;window.addEventListener("unhandledrejection",ce.bind(void 0));window.addEventListener("error",ce.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};je.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{b({err:JSON.stringify(s)})})};var le=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},A=e=>parseInt(le(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=le(e),{major:a,minor:l,patch:i,prerelease:c}=le(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Je=u(),J=(e,t)=>{Je.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Je.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};se();var Ve="jolibox-sdk-loadermeta",Be,P=JSON.parse((Be=window.__joliboxLocalStorage__.getItem(Ve))!=null?Be:"{}"),me=Date.now(),Fe=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function dr(){return m(this,null,function*(){let t=`${j?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=C(U({},P),{timestamp:me});if(o){let{bootstrap_version:a}=P;a&&D(a,o)>=0||(s=C(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=P;a&&D(a,n)>=0||(s=C(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ve,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var $e=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=P;i&&c&&!Fe(me,c)&&A(i)==t&&D(i,r)>=0&&(n=de(i));try{let f=new XMLHttpRequest;return f.open("GET",n,!1),f.send(),{script:f.responseText,type:"fetch_from_cdn"}}catch(f){let h=new Ae(`Bootstrap module faile to fetch ${f}`);b({err:`${h}`})}}function a(){var h;let i=Date.now();J("jsSdkBegin",{t:i}),L.startTime=i;let{script:c,type:f}=(h=s())!=null?h:{};if(c){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=c,document.head.appendChild(y),R("bootstrapModuleLoaded",Date.now()-i,{type:f})}}function l(){let i=Date.now(),{implement_version:c,timestamp:f}=P;c&&f&&!Fe(me,f)&&A(c)==t&&D(c,r)>=0&&(o=ue(c));let h=document.createElement("script");h.type="module",h.crossOrigin="anonymous",h.src=o,h.onload=()=>{R("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(h)}return()=>{try{a(),l(),dr()}catch(i){let c=new T(`module evaluate error: ${i}`);b({err:`${c}`})}}};var He=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){v(new T(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),R("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),v(new T(`module load failed ${o}`))}}};var ur="1.1.50",F=ur,qe=A(F),Ye=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),pr=Ye?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,pe="https://jsdelivr.jolibox.com";var Ge=window.document.currentScript;Ge&&(pe=new URL(Ge.src).origin);var de=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,ue=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/implement@${e}/dist/index.js`,fr=e=>/^\d+\.\d+\.\d+$/.test(e),Qe=fr(F)?qe:F,We=de(Qe),ze=ue(Qe);function hr(){Ye?He(pr,{bootstrapUrl:We,implementUrl:ze})():$e({bootstrapUrl:We,implementUrl:ze,currentMajorVersion:qe,currentVersion:F})()}hr();var gr=u();function Xe(){return gr.excuteCommandSync("API.getSystemInfoSync")}function Ze(e,t){var r;return(r=De.config[e])==null?void 0:r[t]}function et(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var rt="1.1.50";function g(e){let[t,...r]=e.split(":"),n=Ze(ie()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||re(rt,o,"<")?!1:r.length===0?!0:tt(n,r)||tt(n.properties,r)}function tt(e,t){if(!e)return!1;let r=et(e,t);return r?we(r)?!0:te(r)?re(rt,r,">="):!1:!1}var nt=u();function ot(){return m(this,null,function*(){return g("login")?yield nt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function st(){return m(this,null,function*(){return g("checkSession")?yield nt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Er=u();function it(e){return m(this,null,function*(){return g("request")?yield Er.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var fe=["onI18nChanged","onBackPress"],at=(e,t)=>{if(!fe.includes(e)){v(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},ct=(e,t)=>{if(!fe.includes(e)){v(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},lt=(e,t)=>{if(!fe.includes(e)){v(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var yr=u();function mt(e){return m(this,null,function*(){return g("isNativeSupport")?yield yr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var vr=u();function dt(e){return m(this,null,function*(){return g("callHostMethod")?yield vr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new ae}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return g(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var he=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},ut=window.JoliboxRuntime||he;var Sr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Sr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return m(this,null,function*(){})}};var H=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var G=class extends p{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:a}=t,l=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return l?Promise.resolve(l):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:a})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var _r=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],W=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(_r.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var E=class E{constructor(){this.jssdkVersion="1.1.50";this.runtime=new ut;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new H;this.task=new G;this.router=new W;this.getSystemInfoSync=Xe.bind(this);this.canIUse=g.bind(this);this.login=ot.bind(this);this.checkSession=st.bind(this);this.request=it.bind(this);this.on=at.bind(this);this.off=ct.bind(this);this.once=lt.bind(this);this.isNativeSupport=mt.bind(this);this.callHostMethod=dt.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var ge=E;window.JoliboxSDK=ge;})();