@jolibox/sdk 1.2.3 → 1.2.5-beta.3
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.
- package/.rush/temp/package-deps_build.json +7 -4
- package/CHANGELOG.json +11 -0
- package/CHANGELOG.md +9 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.js +373 -347
- package/dist/sdks/payment.d.ts +15 -0
- package/package.json +4 -4
- package/sdk.build.log +4 -4
- package/src/index.ts +10 -0
- package/src/loader/h5.ts +2 -2
- package/src/sdks/payment.ts +24 -0
- package/src/sdks/router.ts +2 -1
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
"files": {
|
|
3
3
|
"packages/sdk/.rush/temp/shrinkwrap-deps.json": "220776b56349f58e6c3047ae379258684eeeaf5c",
|
|
4
4
|
"packages/sdk/.eslintrc.js": "c11c589d14fe58bf4d37d259d8323b193bab6092",
|
|
5
|
+
"packages/sdk/CHANGELOG.json": "4f8df675541fcfda158219880107ee689b60e672",
|
|
6
|
+
"packages/sdk/CHANGELOG.md": "a240d1e0527489b87cde009f4baecf6a5db36430",
|
|
5
7
|
"packages/sdk/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
|
|
6
8
|
"packages/sdk/esbuild.config.js": "1725a85515499085a7c9799b834c6f632073401c",
|
|
7
|
-
"packages/sdk/package.json": "
|
|
9
|
+
"packages/sdk/package.json": "efae4c25ced13918c24beb9c3be6609cdef0896c",
|
|
8
10
|
"packages/sdk/src/__tests__/index.test.ts": "f22e0c0741297803ac3ec016b1dcc166cd2248bd",
|
|
9
11
|
"packages/sdk/src/api/__tests__/canIUse.test.ts": "300e4de3768f9510e956050d326d4977bc621f34",
|
|
10
12
|
"packages/sdk/src/api/call-host-method.ts": "e373cd15fe1d9d1a86c3276545017c49e954c223",
|
|
@@ -17,16 +19,17 @@
|
|
|
17
19
|
"packages/sdk/src/api/request.ts": "117baeceb72bd1602a01f3e1fe586faaea48d155",
|
|
18
20
|
"packages/sdk/src/api/track.ts": "423184430f6d9e6fd24da3328612fe7c3ac20275",
|
|
19
21
|
"packages/sdk/src/events.ts": "124aa9c3dbfa2477ba4d365d63446fae6b542f1f",
|
|
20
|
-
"packages/sdk/src/index.ts": "
|
|
22
|
+
"packages/sdk/src/index.ts": "9064e8319b592997f1cbb5f5fbeda796a5d0c530",
|
|
21
23
|
"packages/sdk/src/loader/__tests__/version.test.ts": "338ca817bfcb672d1065d6f32872b57bc43951b5",
|
|
22
|
-
"packages/sdk/src/loader/h5.ts": "
|
|
24
|
+
"packages/sdk/src/loader/h5.ts": "d4428c67612fd9cf5540afa2bdd3cd17db0f5c98",
|
|
23
25
|
"packages/sdk/src/loader/index.ts": "0ef5ddb69c89f6f7cd78ee318c7030ca3da8aee4",
|
|
24
26
|
"packages/sdk/src/loader/native.ts": "5f9f068c328222a28b457d19841b93c4a13ecccb",
|
|
25
27
|
"packages/sdk/src/loader/version.ts": "deacf56606b2c47f93e0dfa35e5b5dfbe774c69f",
|
|
26
28
|
"packages/sdk/src/sdks/ads.ts": "bec143d0340fced14fa3d372e82de7cc02c419b0",
|
|
27
29
|
"packages/sdk/src/sdks/keyboard.ts": "b30424cbecffa24c9d5249366a70afe2128e64be",
|
|
28
30
|
"packages/sdk/src/sdks/lifecycle.ts": "4d9a3b770d528f59c0eb9272e18d5c2c5641320d",
|
|
29
|
-
"packages/sdk/src/sdks/
|
|
31
|
+
"packages/sdk/src/sdks/payment.ts": "ce43642ae8b1950c08de6da0a2a4762e58b5a104",
|
|
32
|
+
"packages/sdk/src/sdks/router.ts": "5aca615f05f2c85e098cd6759a0bd7ad6a31a0f2",
|
|
30
33
|
"packages/sdk/src/sdks/runtime.ts": "179ae2ffd60125f6ba058c9b52ca4db46032c26b",
|
|
31
34
|
"packages/sdk/src/sdks/sdk.ts": "789f8be82a9c3257306f3e40d21311a7873d4502",
|
|
32
35
|
"packages/sdk/src/sdks/storage.ts": "43dbbdeea3484e9ff084958bf4137190d300ff17",
|
package/CHANGELOG.json
ADDED
package/CHANGELOG.md
ADDED
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var U=Object.defineProperty,vt=Object.defineProperties,yt=Object.getOwnPropertyDescriptor,_t=Object.getOwnPropertyDescriptors,St=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable;var Se=(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)&&Se(e,r,t[r]);if(_e)for(var r of _e(t))bt.call(t,r)&&Se(e,r,t[r]);return e},O=(e,t)=>vt(e,_t(t));var Rt=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0})},xt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of St(t))!be.call(e,o)&&o!==r&&U(e,o,{get:()=>t[o],enumerable:!(n=yt(t,o))||n.enumerable});return e};var It=e=>xt(U({},"__esModule",{value:!0}),e);var d=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});var Cr={};Rt(Cr,{JoliboxSDK:()=>Y});module.exports=It(Cr);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,wt=Object.defineProperties,Tt=Object.getOwnPropertyDescriptor,Lt=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertySymbols,At=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable,xe=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pt=(e,t)=>{for(var r in t||(t={}))At.call(t,r)&&xe(e,r,t[r]);if(Re)for(var r of Re(t))Dt.call(t,r)&&xe(e,r,t[r]);return e},Ut=(e,t)=>wt(e,Lt(t)),Ct=(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?Tt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&re(t,r,o),o},Ot=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((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 kt(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 Nt(e){return typeof e=="undefined"}function Kt(e){return Nt(e)||e===null}function Mt(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 jt=(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))(jt||{}),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 Jt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Jt});var Q=Symbol.for("Jolibox.canIUseMap"),Ft={};globalThis[Q]||(globalThis[Q]=Ft);var Ue={get config(){return globalThis[Q]}};var Ie=Symbol.for("Jolibox.canIUseMap.native"),Bt={};globalThis[Ie]||(globalThis[Ie]=Bt);function oe(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){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||{}),Vt=(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))(Vt||{}),we=["name","params"],$t=["name","type","location","target","extra","timestamp","userId"],Ht=["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 Gt(e){let t=e.location?N(e.location,we):null,r=e.target?N(e.target,we):null;return N(Ut(Pt({},e),{location:t,target:r}),$t)}function Ce(e){let t=e.events.map(n=>Gt(n)),r=N(e.device,Ht);return[e.protocolVersion,t,r,e.project]}var Wt=()=>"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 _=typeof window=="undefined",ce=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),k={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")},zt=()=>k.isiOS?"iOS":k.isAndroid?"Android":k.isMac?"Mac":k.isFacebook?"Facebook":"PC",Yt="device_id",qt="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Wt()),window.__joliboxLocalStorage__.getItem(e)),Qt=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe(Yt),Xt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(qt),Zt=e=>e.charAt(0).toUpperCase()+e.slice(1),er=()=>{var e;let t=new URLSearchParams(window.location.search);return Zt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},ke=e=>{if(ce())return window.navigator.userAgent;let t="JoliboxWebSDK",r=zt(),n=navigator.language,o=Qt(),s=Xt();return`${t} (${er()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function Ne(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function tr(e){return Ne("api","stg-api",e)}function Ke(e){return`https://${tr(e)}`}function rr(e){return Ne("collect","stg-collect",e)}function Me(e){return`https://${rr(e)}`}var X=class Z{constructor(t){this.element=t,this.next=Z.Undefined,this.prev=Z.Undefined}};X.Undefined=new X(void 0);var m=X,nr=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.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!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},or=0,I=class{constructor(e){this.value=e,this.id=or++}},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,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,v,ve;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ye=this._listeners.indexOf(l);ye>=0&&(this._listeners.splice(ye,1),this._size--,this._size===0&&((ve=(v=this.options)==null?void 0:v.onDidRemoveLastListener)==null||ve.call(v)))}}}}),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=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.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 nr,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={};Ct(ee,{None:()=>sr,filter:()=>ar,once:()=>je,toPromise:()=>ir});var sr=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function ir(e){return new Promise(t=>je(e)(t))}function je(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function ar(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 q=Symbol.for("Jolibox.hostEmitter"),cr=()=>{let e=new le;return globalThis[q]||(globalThis[q]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[q]},S=cr();function lr(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)dr(e[n],t[n])}function dr(e,t){if(ne(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Mt(t)){try{if(e instanceof t)return}catch(r){}if(!Kt(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 lr(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=kt(3e4)),this._starActivation}executeCommand(e,...t){return Ot(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 Je=Symbol.for("Jolibox.commands");function mr(){return typeof globalThis!="undefined"?globalThis[Je]:void 0}function ur(e){typeof globalThis!="undefined"&&(globalThis[Je]=e)}function u(e=!1){let t=mr();if(!e&&t)return t;let r=new K,n=new te,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return ur(o),o}var J=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function pr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function fr(){return{platform:1e3,os:"h5",appVersion:"1.2.3",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.3",extra:{}}}var hr=()=>{var t;return Me((t=J)!=null?t:!1)},gr=hr(),Be=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Fe;(Fe=AbortSignal.timeout)!=null||(AbortSignal.timeout=Be);var Er=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},vr=Er(),yr=e=>d(void 0,null,function*(){try{let r=`${gr}/report`,n=ke("1.2.3"),o=vr,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:Be(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:se.ErrorTrace,location:pr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=fr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ie.WebSDK},s=Ce(o);yield yr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var _r=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=_r(),Ve=u(),de=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};Ve.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)})})},y=de;window.addEventListener("unhandledrejection",de.bind(void 0));window.addEventListener("error",de.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()};Ve.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var me=e=>{var c,a,l;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,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(me(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=me(e),{major:i,minor:c,patch:a,prerelease:l}=me(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var $e=u(),F=(e,t)=>{$e.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{$e.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ae();var We="jolibox-sdk-loadermeta",Ge,P=JSON.parse((Ge=window.__joliboxLocalStorage__.getItem(We))!=null?Ge:"{}"),ue=Date.now(),He=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Sr(){return d(this,null,function*(){let t=`${Ke(J)}/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:i}=P;i&&D(i,o)>=0||(s=O(C({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=O(C({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(We,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var ze=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!He(ue,l)&&A(a)==t&&D(a,r)>=0&&(n=pe(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new Pe(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();F("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let v=document.createElement("script");v.type="text/javascript",v.innerHTML=l,document.head.appendChild(v),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!He(ue,h)&&A(l)==t&&D(l,r)>=0&&(o=fe(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),Sr()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var Ye=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>d(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){y(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();F("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new T(`module load failed ${o}`))}}};var br="1.2.3",B=br,Ze=A(B),et=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Rr=et?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,he="https://jsdelivr.jolibox.com";var qe=window.document.currentScript;qe&&(he=new URL(qe.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`,xr=e=>/^\d+\.\d+\.\d+$/.test(e),tt=xr(B)?Ze:B,Qe=pe(tt),Xe=fe(tt);function Ir(){et?Ye(Rr,{bootstrapUrl:Qe,implementUrl:Xe})():ze({bootstrapUrl:Qe,implementUrl:Xe,currentMajorVersion:Ze,currentVersion:B})()}Ir();var wr=u();function rt(){return wr.excuteCommandSync("API.getSystemInfoSync")}function nt(e,t){var r;return(r=Ue.config[e])==null?void 0:r[t]}function ot(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 it="1.2.3";function f(e){let[t,...r]=e.split(":"),n=nt(ce()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||oe(it,o,"<")?!1:r.length===0?!0:st(n,r)||st(n.properties,r)}function st(e,t){if(!e)return!1;let r=ot(e,t);return r?Le(r)?!0:ne(r)?oe(it,r,">="):!1:!1}var at=u();function ct(){return d(this,null,function*(){return f("login")?yield at.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function lt(){return d(this,null,function*(){return f("checkSession")?yield at.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Tr=u();function dt(e){return d(this,null,function*(){return f("request")?yield Tr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ge=["onI18nChanged","onBackPress"],mt=(e,t)=>{if(!ge.includes(e)){y(new j(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},ut=(e,t)=>{if(!ge.includes(e)){y(new j(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},pt=(e,t)=>{if(!ge.includes(e)){y(new j(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Lr=u();function ft(e){return d(this,null,function*(){return f("isNativeSupport")?yield Lr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ar=u();function ht(e){return d(this,null,function*(){return f("callHostMethod")?yield Ar.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Dr=u();function gt(e){return d(this,null,function*(){return f("track")?yield Dr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track 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 f(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)}}},Et=window.JoliboxRuntime||Ee;var Pr="LifecycleSDK.onReady",V=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Pr,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 d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(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 d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(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 d(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 d(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:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:i})})}onGamePlayEnded(t){return d(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,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return d(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");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Ur=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],z=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Ur.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.2.3";this.runtime=new Et;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=rt.bind(this);this.canIUse=f.bind(this);this.login=ct.bind(this);this.checkSession=lt.bind(this);this.request=dt.bind(this);this.on=mt.bind(this);this.off=ut.bind(this);this.once=pt.bind(this);this.isNativeSupport=ft.bind(this);this.callHostMethod=ht.bind(this);this.track=gt.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 Y=E;window.JoliboxSDK=Y;
|
|
1
|
+
"use strict";var P=Object.defineProperty,yt=Object.defineProperties,vt=Object.getOwnPropertyDescriptor,_t=Object.getOwnPropertyDescriptors,Rt=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols;var xe=Object.prototype.hasOwnProperty,xt=Object.prototype.propertyIsEnumerable;var Re=(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={}))xe.call(t,r)&&Re(e,r,t[r]);if(_e)for(var r of _e(t))xt.call(t,r)&&Re(e,r,t[r]);return e},O=(e,t)=>yt(e,_t(t));var bt=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},It=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Rt(t))!xe.call(e,s)&&s!==r&&P(e,s,{get:()=>t[s],enumerable:!(n=vt(t,s))||n.enumerable});return e};var wt=e=>It(P({},"__esModule",{value:!0}),e);var d=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{c(r.next(a))}catch(l){s(l)}},i=a=>{try{c(r.throw(a))}catch(l){s(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);c((r=r.apply(e,t)).next())});var Ur={};bt(Ur,{JoliboxSDK:()=>Y});module.exports=wt(Ur);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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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 ne=Object.defineProperty,Tt=Object.defineProperties,Ct=Object.getOwnPropertyDescriptor,At=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,Dt=Object.prototype.hasOwnProperty,Lt=Object.prototype.propertyIsEnumerable,Ie=(e,t,r)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pt=(e,t)=>{for(var r in t||(t={}))Dt.call(t,r)&&Ie(e,r,t[r]);if(be)for(var r of be(t))Lt.call(t,r)&&Ie(e,r,t[r]);return e},Ut=(e,t)=>Tt(e,At(t)),Ot=(e,t)=>{for(var r in t)ne(e,r,{get:t[r],enumerable:!0})},Ce=(e,t,r,n)=>{for(var s=n>1?void 0:n?Ct(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&ne(t,r,s),s},kt=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{c(r.next(a))}catch(l){s(l)}},i=a=>{try{c(r.throw(a))}catch(l){s(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);c((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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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 Nt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function se(e){return typeof e=="string"}function Ae(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Kt(e){return typeof e=="undefined"}function Mt(e){return Kt(e)||e===null}function jt(e){return typeof e=="function"}function De(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var qt=(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))(qt||{}),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}},Le=class extends M{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Pe=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 j=class extends M{constructor(e,t,r,n,s){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),s&&(this.priority=s)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function b(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Jt={log:b("log"),warn:b("warn"),info:b("info"),error:b("error"),debug:b("debug")};Object.assign(globalThis,{logger:Jt});var X=Symbol.for("Jolibox.canIUseMap"),Ft={};globalThis[X]||(globalThis[X]=Ft);var Ue={get config(){return globalThis[X]}};var we=Symbol.for("Jolibox.canIUseMap.native"),$t={};globalThis[we]||(globalThis[we]=$t);function oe(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let c=0;c<i;c++){let a=parseInt(s[c],10)||0,l=parseInt(o[c],10)||0;if(a>l){n=1;break}else if(a<l){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 ie=(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))(ie||{}),ae=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ae||{}),Bt=(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))(Bt||{}),Te=["name","params"],Vt=["name","type","location","target","extra","timestamp","userId"],Ht=["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((s,o)=>(s[o]=String(n[o]),s),{})}return e[r]})}function Gt(e){let t=e.location?N(e.location,Te):null,r=e.target?N(e.target,Te):null;return N(Ut(Pt({},e),{location:t,target:r}),Vt)}function Oe(e){let t=e.events.map(n=>Gt(n)),r=N(e.device,Ht);return[e.protocolVersion,t,r,e.project]}var Wt=()=>"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 ce(){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}}ce();var v=typeof window=="undefined",le=()=>!v&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),k={isiOS:!v&&(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:!v&&navigator.userAgent.includes("Android"),isMac:!v&&navigator.userAgent.includes("Mac"),isFacebook:!v&&navigator.userAgent.includes("FB_IAB"),isPC:!v&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},zt=()=>k.isiOS?"iOS":k.isAndroid?"Android":k.isMac?"Mac":k.isFacebook?"Facebook":"PC",Yt="device_id",Qt="advertising_id",ke=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Wt()),window.__joliboxLocalStorage__.getItem(e)),Xt=()=>new URLSearchParams(window.location.search).get("deviceId")||ke(Yt),Zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||ke(Qt),er=e=>e.charAt(0).toUpperCase()+e.slice(1),tr=()=>{var e;let t=new URLSearchParams(window.location.search);return er((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ne=e=>{if(le())return window.navigator.userAgent;let t="JoliboxWebSDK",r=zt(),n=navigator.language,s=Xt(),o=Zt();return`${t} (${tr()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`};function Ke(e,t,r){let n=window.location.hostname,s=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(s.length>=2){let i=s.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${o}.${i}`}return`${o}.jolibox.com`}function Me(e){return`https://${Ke("api","stg-api",e)}`}function rr(e){return Ke("collect","stg-collect",e)}function je(e){return`https://${rr(e)}`}var Z=class ee{constructor(t){this.element=t,this.next=ee.Undefined,this.prev=ee.Undefined}};Z.Undefined=new Z(void 0);var u=Z,nr=class{constructor(){this._first=u.Undefined,this._last=u.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===u.Undefined}clear(){let e=this._first;for(;e!==u.Undefined;){let t=e.next;e.prev=u.Undefined,e.next=u.Undefined,e=t}this._first=u.Undefined,this._last=u.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new u(e);if(this._first===u.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==u.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==u.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==u.Undefined&&e.next!==u.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===u.Undefined&&e.next===u.Undefined?(this._first=u.Undefined,this._last=u.Undefined):e.next===u.Undefined?(this._last=this._last.prev,this._last.next=u.Undefined):e.prev===u.Undefined&&(this._first=this._first.next,this._first.prev=u.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==u.Undefined;)yield e.element,e=e.next}},sr=0,I=class{constructor(e){this.value=e,this.id=sr++}},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,s,o,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((s=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||s.call(n,this),this._listeners=l,(i=(o=this.options)==null?void 0:o.onDidFirstListener)==null||i.call(o,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var f,g,S,ye;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(f=this.options)==null?void 0:f.onDidRemoveLastListener)==null||g.call(f));else if(this._listeners){let ve=this._listeners.indexOf(l);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((ye=(S=this.options)==null?void 0:S.onDidRemoveLastListener)==null||ye.call(S)))}}}}),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(s){n(s)}}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}},de=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let s=(n=this.listeners.get(e))!=null?n:new w,o=a=>t(...a.args),i=s.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:i}),this.listeners.set(e,s);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.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 nr,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)}},te={};Ot(te,{None:()=>or,filter:()=>ar,once:()=>qe,toPromise:()=>ir});var or=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function ir(e){return new Promise(t=>qe(e)(t))}function qe(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function ar(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new w(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var Q=Symbol.for("Jolibox.hostEmitter"),cr=()=>{let e=new de;return globalThis[Q]||(globalThis[Q]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Q]},_=cr();function lr(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)dr(e[n],t[n])}function dr(e,t){if(se(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(jt(t)){try{if(e instanceof t)return}catch(r){}if(!Mt(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 s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return lr(s,r),n(...s)}}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=Ce([De],K);var re=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=Nt(3e4)),this._starActivation}executeCommand(e,...t){return kt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),te.toPromise(te.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}}};re=Ce([De],re);var Je=Symbol.for("Jolibox.commands");function ur(){return typeof globalThis!="undefined"?globalThis[Je]:void 0}function mr(e){typeof globalThis!="undefined"&&(globalThis[Je]=e)}function m(e=!1){let t=ur();if(!e&&t)return t;let r=new K,n=new re,s={registerCommand(o,i,c){r.registerCommand({id:o,handler:i,metadata:c})},executeCommand(o,...i){return n.executeCommand(o,...i)},excuteCommandSync(o,...i){return n.executeCommandThowErr(o,...i)}};return mr(s),s}var q=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function pr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function hr(){return{platform:1e3,os:"h5",appVersion:"1.2.5-beta.3",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.5-beta.3",extra:{}}}var fr=()=>{var t;return je((t=q)!=null?t:!1)},gr=fr(),$e=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Fe;(Fe=AbortSignal.timeout)!=null||(AbortSignal.timeout=$e);var Er=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Sr=Er(),yr=e=>d(void 0,null,function*(){try{let r=`${gr}/report`,n=Ne("1.2.5-beta.3"),s=Sr,o={"Content-Type":"application/json"};return n&&(o["x-user-agent"]=n),s&&(o["x-joli-source"]=s),yield fetch(r,{method:"POST",headers:o,body:JSON.stringify(e),signal:$e(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function R(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:ie.ErrorTrace,location:pr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=hr(),s={protocolVersion:"1.0.0",events:[t],device:r,project:ae.WebSDK},o=Oe(s);yield yr(o)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",C.startTime));var vr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},C=vr(),Be=m(),ue=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};Be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),R({err:JSON.stringify(t)})})},y=ue;window.addEventListener("unhandledrejection",ue.bind(void 0));window.addEventListener("error",ue.bind(void 0));window.onerror=(e,t,r,n,s)=>{let o={message:e,source:t,lineno:r,colno:n,stack:s==null?void 0:s.stack,errorString:s==null?void 0:s.toString()};Be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(o)}}).catch(i=>{R({err:JSON.stringify(o)})})};var me=e=>{var c,a,l;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),[s,o,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},A=e=>parseInt(me(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=me(e),{major:i,minor:c,patch:a,prerelease:l}=me(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:s!==a?s>a?1:-1:o&&!l?-1:!o&&l?1:o&&l?o>l?1:o<l?-1:0:0};var Ve=m(),J=(e,t)=>{Ve.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},x=(e,t,r)=>{Ve.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ce();var We="jolibox-sdk-loadermeta",Ge,L=JSON.parse((Ge=window.__joliboxLocalStorage__.getItem(We))!=null?Ge:"{}"),pe=Date.now(),He=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function _r(){return d(this,null,function*(){let t=`${Me(q)}/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:s}=yield r.json(),o=O(U({},L),{timestamp:pe});if(s){let{bootstrap_version:i}=L;i&&D(i,s)>=0||(o=O(U({},o),{bootstrap_version:s}))}if(n){let{implement_version:i}=L;i&&D(i,n)>=0||(o=O(U({},o),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(We,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var ze=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,s=e.implementUrl;function o(){let{bootstrap_version:a,timestamp:l}=L;a&&l&&!He(pe,l)&&A(a)==t&&D(a,r)>=0&&(n=he(a));try{let f=new XMLHttpRequest;return f.open("GET",n,!1),f.send(),{script:f.responseText,type:"fetch_from_cdn"}}catch(f){let g=new Pe(`Bootstrap module faile to fetch ${f}`);R({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),C.startTime=a;let{script:l,type:f}=(g=o())!=null?g:{};if(l){let S=document.createElement("script");S.type="text/javascript",S.innerHTML=l,document.head.appendChild(S),x("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function c(){let a=Date.now(),{implement_version:l,timestamp:f}=L;l&&f&&!He(pe,f)&&A(l)==t&&D(l,r)>=0&&(s=fe(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=s,g.onload=()=>{x("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),_r()}catch(a){let l=new T(`module evaluate error: ${a}`);R({err:`${l}`})}}};var Ye=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>d(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){y(new T(`implement module evaluate error in native:${c} `))}}))(s)}return()=>{try{let s=Date.now();J("jsSdkBegin",{t:s}),C.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),x("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),x("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new T(`module load failed ${s}`))}}};var Rr="1.2.5-beta.3",F=Rr,et=A(F),tt=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),xr=tt?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,ge="https://jsdelivr.jolibox.com";var Qe=window.document.currentScript;Qe&&(ge=new URL(Qe.src).origin);var he=(e,t)=>`${t!=null?t:ge}/npm/@jolibox/bootstrap@${e}/dist/index.js`,fe=(e,t)=>`${t!=null?t:ge}/npm/@jolibox/implement@${e}/dist/index.js`,br=e=>/^\d+\.\d+\.\d+$/.test(e),rt=br(F)?et:F,Xe=he(rt),Ze=fe(rt);function Ir(){tt?Ye(xr,{bootstrapUrl:Xe,implementUrl:Ze})():ze({bootstrapUrl:Xe,implementUrl:Ze,currentMajorVersion:et,currentVersion:F})()}Ir();var wr=m();function nt(){return wr.excuteCommandSync("API.getSystemInfoSync")}function st(e,t){var r;return(r=Ue.config[e])==null?void 0:r[t]}function ot(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var at="1.2.5-beta.3";function h(e){let[t,...r]=e.split(":"),n=st(le()?"native":"h5",t);if(!n)return!1;let s=n.version;return typeof s!="string"||oe(at,s,"<")?!1:r.length===0?!0:it(n,r)||it(n.properties,r)}function it(e,t){if(!e)return!1;let r=ot(e,t);return r?Ae(r)?!0:se(r)?oe(at,r,">="):!1:!1}var ct=m();function lt(){return d(this,null,function*(){return h("login")?yield ct.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function dt(){return d(this,null,function*(){return h("checkSession")?yield ct.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Tr=m();function ut(e){return d(this,null,function*(){return h("request")?yield Tr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var Ee=["onI18nChanged","onBackPress"],mt=(e,t)=>{if(!Ee.includes(e)){y(new j(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},pt=(e,t)=>{if(!Ee.includes(e)){y(new j(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},ht=(e,t)=>{if(!Ee.includes(e)){y(new j(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var Cr=m();function ft(e){return d(this,null,function*(){return h("isNativeSupport")?yield Cr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ar=m();function gt(e){return d(this,null,function*(){return h("callHostMethod")?yield Ar.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Dr=m();function Et(e){return d(this,null,function*(){return h("track")?yield Dr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=m();this._emitter=new de}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return h(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var Se=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),s=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(s),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},St=window.JoliboxRuntime||Se;var Lr="LifecycleSDK.onReady",$=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Lr,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 p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(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 d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var V=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 d(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 d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:s,score:o,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:s,score:o,variation:i})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:s,variation:o}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:s,variation:o})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(s)return s;let o=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(o),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Pr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],W=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Pr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var z=class extends p{constructor(){super()}purchaseGem(t){return d(this,null,function*(){let r=this.canIUseIfThrow("payment.purchaseGem");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.purchaseGem",t)})}getGemProducts(){return d(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}};var E=class E{constructor(){this.jssdkVersion="1.2.5-beta.3";this.runtime=new St;this.ads=new V;this.lifecycle=new $;this.storage=new B;this.keyboard=new H;this.task=new G;this.router=new W;this.payment=new z;this.getSystemInfoSync=nt.bind(this);this.canIUse=h.bind(this);this.login=lt.bind(this);this.checkSession=dt.bind(this);this.request=ut.bind(this);this.on=mt.bind(this);this.off=pt.bind(this);this.once=ht.bind(this);this.isNativeSupport=ft.bind(this);this.callHostMethod=gt.bind(this);this.track=Et.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 Y=E;window.JoliboxSDK=Y;
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { JoliboxAds } from './sdks/ads';
|
|
|
15
15
|
import { KeyboardSDK } from './sdks/keyboard';
|
|
16
16
|
import { TaskTrackerSDK } from './sdks/task';
|
|
17
17
|
import { RouterSDK } from './sdks/router';
|
|
18
|
+
import { PaymentSDK } from './sdks/payment';
|
|
18
19
|
declare global {
|
|
19
20
|
interface Window {
|
|
20
21
|
JoliboxSDK: typeof JoliboxSDK;
|
|
@@ -99,6 +100,14 @@ export declare class JoliboxSDK {
|
|
|
99
100
|
* @type {RouterSDK}
|
|
100
101
|
*/
|
|
101
102
|
readonly router: RouterSDK;
|
|
103
|
+
/**
|
|
104
|
+
* @private
|
|
105
|
+
* @readonly
|
|
106
|
+
* Access to the Payment SDK module.
|
|
107
|
+
* @see {@link PaymentSDK} for more details.
|
|
108
|
+
* @type {PaymentSDK}
|
|
109
|
+
*/
|
|
110
|
+
readonly payment: PaymentSDK;
|
|
102
111
|
/**
|
|
103
112
|
* @public
|
|
104
113
|
* Synchronously gets system information.
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var gt=Object.defineProperty,Et=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var yt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&_e(e,r,t[r]);if(ye)for(var r of ye(t))_t.call(t,r)&&_e(e,r,t[r]);return e},C=(e,t)=>Et(e,vt(t));var d=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((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,St=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,Rt=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?ee(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)&&be(e,r,t[r]);if(Se)for(var r of Se(t))It.call(t,r)&&be(e,r,t[r]);return e},Tt=(e,t)=>St(e,Rt(t)),Lt=(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?bt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&ee(t,r,o),o},At=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((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 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 Pt(e){return typeof e=="undefined"}function Ut(e){return Pt(e)||e===null}function Ct(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 Ot=(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))(Ot||{}),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 kt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:kt});var Y=Symbol.for("Jolibox.canIUseMap"),Nt={};globalThis[Y]||(globalThis[Y]=Nt);var De={get config(){return globalThis[Y]}};var Re=Symbol.for("Jolibox.canIUseMap.native"),Kt={};globalThis[Re]||(globalThis[Re]=Kt);function re(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){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||{}),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||{}),xe=["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,xe):null,r=e.target?k(e.target,xe):null;return k(Tt(wt({},e),{location:t,target:r}),jt)}function Pe(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 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 _=typeof window=="undefined",ie=()=>!_&&!!(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")},Vt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",$t="device_id",Ht="advertising_id",Ue=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Bt()),window.__joliboxLocalStorage__.getItem(e)),Gt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ue($t),Wt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ue(Ht),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(ie())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,o=Gt(),s=Wt();return`${t} (${Yt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function Oe(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function qt(e){return Oe("api","stg-api",e)}function ke(e){return`https://${qt(e)}`}function Qt(e){return Oe("collect","stg-collect",e)}function Ne(e){return`https://${Qt(e)}`}var q=class Q{constructor(t){this.element=t,this.next=Q.Undefined,this.prev=Q.Undefined}};q.Undefined=new q(void 0);var m=q,Xt=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.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!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.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,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,v,Ee;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ve=this._listeners.indexOf(l);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((Ee=(v=this.options)==null?void 0:v.onDidRemoveLastListener)==null||Ee.call(v)))}}}}),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=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.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)}},X={};Lt(X,{None:()=>er,filter:()=>rr,once:()=>Ke,toPromise:()=>tr});var er=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function tr(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 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 z=Symbol.for("Jolibox.hostEmitter"),nr=()=>{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]},S=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(te(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ct(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 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}};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=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(),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 Me=Symbol.for("Jolibox.commands");function ir(){return typeof globalThis!="undefined"?globalThis[Me]:void 0}function ar(e){typeof globalThis!="undefined"&&(globalThis[Me]=e)}function u(e=!1){let t=ir();if(!e&&t)return t;let r=new N,n=new Z,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};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.2.3",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.3",extra:{}}}var dr=()=>{var t;return Ne((t=j)!=null?t:!1)},mr=dr(),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=>d(void 0,null,function*(){try{let r=`${mr}/report`,n=Ce("1.2.3"),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 d(this,null,function*(){try{let t={name:"globalJsError",type:ne.ErrorTrace,location:cr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=lr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:oe.WebSDK},s=Pe(o);yield fr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var hr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=hr(),Fe=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};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)})})},y=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()};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var le=e=>{var c,a,l;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,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,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:i,minor:c,patch:a,prerelease:l}=le(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var Be=u(),J=(e,t)=>{Be.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};se();var He="jolibox-sdk-loadermeta",$e,P=JSON.parse(($e=window.__joliboxLocalStorage__.getItem(He))!=null?$e:"{}"),de=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function gr(){return d(this,null,function*(){let t=`${ke(j)}/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:de});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=C(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=C(U({},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:a,timestamp:l}=P;a&&l&&!Ve(de,l)&&A(a)==t&&D(a,r)>=0&&(n=me(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new Ae(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let v=document.createElement("script");v.type="text/javascript",v.innerHTML=l,document.head.appendChild(v),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!Ve(de,h)&&A(l)==t&&D(l,r)>=0&&(o=ue(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),gr()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};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){(i=>d(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){y(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new T(`module load failed ${o}`))}}};var Er="1.2.3",F=Er,Qe=A(F),Xe=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),vr=Xe?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,pe="https://jsdelivr.jolibox.com";var ze=window.document.currentScript;ze&&(pe=new URL(ze.src).origin);var me=(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`,yr=e=>/^\d+\.\d+\.\d+$/.test(e),Ze=yr(F)?Qe:F,Ye=me(Ze),qe=ue(Ze);function _r(){Xe?We(vr,{bootstrapUrl:Ye,implementUrl:qe})():Ge({bootstrapUrl:Ye,implementUrl:qe,currentMajorVersion:Qe,currentVersion:F})()}_r();var Sr=u();function et(){return Sr.excuteCommandSync("API.getSystemInfoSync")}function tt(e,t){var r;return(r=De.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.2.3";function f(e){let[t,...r]=e.split(":"),n=tt(ie()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||re(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?we(r)?!0:te(r)?re(ot,r,">="):!1:!1}var st=u();function it(){return d(this,null,function*(){return f("login")?yield st.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function at(){return d(this,null,function*(){return f("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 d(this,null,function*(){return f("request")?yield br.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var fe=["onI18nChanged","onBackPress"],lt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},dt=(e,t)=>{if(!fe.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},mt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Rr=u();function ut(e){return d(this,null,function*(){return f("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 d(this,null,function*(){return f("callHostMethod")?yield xr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Ir=u();function ft(e){return d(this,null,function*(){return f("track")?yield Ir.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track 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 f(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)}}},ht=window.JoliboxRuntime||he;var wr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(wr,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 d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(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 d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(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 d(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 d(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:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:i})})}onGamePlayEnded(t){return d(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,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return d(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");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Tr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],W=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Tr.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.2.3";this.runtime=new ht;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=et.bind(this);this.canIUse=f.bind(this);this.login=it.bind(this);this.checkSession=at.bind(this);this.request=ct.bind(this);this.on=lt.bind(this);this.off=dt.bind(this);this.once=mt.bind(this);this.isNativeSupport=ut.bind(this);this.callHostMethod=pt.bind(this);this.track=ft.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
|
+
var Et=Object.defineProperty,St=Object.defineProperties;var yt=Object.getOwnPropertyDescriptors;var ve=Object.getOwnPropertySymbols;var vt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))vt.call(t,r)&&_e(e,r,t[r]);if(ve)for(var r of ve(t))_t.call(t,r)&&_e(e,r,t[r]);return e},U=(e,t)=>St(e,yt(t));var d=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{c(r.next(a))}catch(l){s(l)}},i=a=>{try{c(r.throw(a))}catch(l){s(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);c((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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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,Rt=Object.defineProperties,xt=Object.getOwnPropertyDescriptor,bt=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,xe=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tt=(e,t)=>{for(var r in t||(t={}))It.call(t,r)&&xe(e,r,t[r]);if(Re)for(var r of Re(t))wt.call(t,r)&&xe(e,r,t[r]);return e},Ct=(e,t)=>Rt(e,bt(t)),At=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},we=(e,t,r,n)=>{for(var s=n>1?void 0:n?xt(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&te(t,r,s),s},Dt=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{c(r.next(a))}catch(l){s(l)}},i=a=>{try{c(r.throw(a))}catch(l){s(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);c((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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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 Lt(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 Ce(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var kt=(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))(kt||{}),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"}},T=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,s){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),s&&(this.priority=s)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function b(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Nt={log:b("log"),warn:b("warn"),info:b("info"),error:b("error"),debug:b("debug")};Object.assign(globalThis,{logger:Nt});var Y=Symbol.for("Jolibox.canIUseMap"),Kt={};globalThis[Y]||(globalThis[Y]=Kt);var Le={get config(){return globalThis[Y]}};var be=Symbol.for("Jolibox.canIUseMap.native"),Mt={};globalThis[be]||(globalThis[be]=Mt);function ne(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let c=0;c<i;c++){let a=parseInt(s[c],10)||0,l=parseInt(o[c],10)||0;if(a>l){n=1;break}else if(a<l){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||{}),oe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(oe||{}),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||{}),Ie=["name","params"],qt=["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((s,o)=>(s[o]=String(n[o]),s),{})}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(Ct(Tt({},e),{location:t,target:r}),qt)}function Pe(e){let t=e.events.map(n=>Ft(n)),r=k(e.device,Jt);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 ie(){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}}ie();var v=typeof window=="undefined",ae=()=>!v&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!v&&(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:!v&&navigator.userAgent.includes("Android"),isMac:!v&&navigator.userAgent.includes("Mac"),isFacebook:!v&&navigator.userAgent.includes("FB_IAB"),isPC:!v&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Bt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Vt="device_id",Ht="advertising_id",Ue=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,$t()),window.__joliboxLocalStorage__.getItem(e)),Gt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ue(Vt),Wt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ue(Ht),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"},Oe=e=>{if(ae())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Bt(),n=navigator.language,s=Gt(),o=Wt();return`${t} (${Yt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`};function ke(e,t,r){let n=window.location.hostname,s=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(s.length>=2){let i=s.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${o}.${i}`}return`${o}.jolibox.com`}function Ne(e){return`https://${ke("api","stg-api",e)}`}function Qt(e){return ke("collect","stg-collect",e)}function Ke(e){return`https://${Qt(e)}`}var Q=class X{constructor(t){this.element=t,this.next=X.Undefined,this.prev=X.Undefined}};Q.Undefined=new Q(void 0);var u=Q,Xt=class{constructor(){this._first=u.Undefined,this._last=u.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===u.Undefined}clear(){let e=this._first;for(;e!==u.Undefined;){let t=e.next;e.prev=u.Undefined,e.next=u.Undefined,e=t}this._first=u.Undefined,this._last=u.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new u(e);if(this._first===u.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==u.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==u.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==u.Undefined&&e.next!==u.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===u.Undefined&&e.next===u.Undefined?(this._first=u.Undefined,this._last=u.Undefined):e.next===u.Undefined?(this._last=this._last.prev,this._last.next=u.Undefined):e.prev===u.Undefined&&(this._first=this._first.next,this._first.prev=u.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==u.Undefined;)yield e.element,e=e.next}},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,s,o,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((s=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||s.call(n,this),this._listeners=l,(i=(o=this.options)==null?void 0:o.onDidFirstListener)==null||i.call(o,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var f,g,S,Se;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(f=this.options)==null?void 0:f.onDidRemoveLastListener)==null||g.call(f));else if(this._listeners){let ye=this._listeners.indexOf(l);ye>=0&&(this._listeners.splice(ye,1),this._size--,this._size===0&&((Se=(S=this.options)==null?void 0:S.onDidRemoveLastListener)==null||Se.call(S)))}}}}),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(s){n(s)}}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}},ce=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let s=(n=this.listeners.get(e))!=null?n:new w,o=a=>t(...a.args),i=s.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:i}),this.listeners.set(e,s);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.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)}},Z={};At(Z,{None:()=>er,filter:()=>rr,once:()=>Me,toPromise:()=>tr});var er=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function tr(e){return new Promise(t=>Me(e)(t))}function Me(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function rr(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new w(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var z=Symbol.for("Jolibox.hostEmitter"),nr=()=>{let e=new ce;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]},_=nr();function sr(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)or(e[n],t[n])}function or(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 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 s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return sr(s,r),n(...s)}}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([Ce],N);var ee=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=Lt(3e4)),this._starActivation}executeCommand(e,...t){return Dt(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([Ce],ee);var je=Symbol.for("Jolibox.commands");function ir(){return typeof globalThis!="undefined"?globalThis[je]:void 0}function ar(e){typeof globalThis!="undefined"&&(globalThis[je]=e)}function m(e=!1){let t=ir();if(!e&&t)return t;let r=new N,n=new ee,s={registerCommand(o,i,c){r.registerCommand({id:o,handler:i,metadata:c})},executeCommand(o,...i){return n.executeCommand(o,...i)},excuteCommandSync(o,...i){return n.executeCommandThowErr(o,...i)}};return ar(s),s}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.2.5-beta.3",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.5-beta.3",extra:{}}}var dr=()=>{var t;return Ke((t=j)!=null?t:!1)},ur=dr(),Je=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},qe;(qe=AbortSignal.timeout)!=null||(AbortSignal.timeout=Je);var mr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},pr=mr(),hr=e=>d(void 0,null,function*(){try{let r=`${ur}/report`,n=Oe("1.2.5-beta.3"),s=pr,o={"Content-Type":"application/json"};return n&&(o["x-user-agent"]=n),s&&(o["x-joli-source"]=s),yield fetch(r,{method:"POST",headers:o,body:JSON.stringify(e),signal:Je(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function R(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:se.ErrorTrace,location:cr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=lr(),s={protocolVersion:"1.0.0",events:[t],device:r,project:oe.WebSDK},o=Pe(s);yield hr(o)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",C.startTime));var fr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},C=fr(),Fe=m(),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};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),R({err:JSON.stringify(t)})})},y=le;window.addEventListener("unhandledrejection",le.bind(void 0));window.addEventListener("error",le.bind(void 0));window.onerror=(e,t,r,n,s)=>{let o={message:e,source:t,lineno:r,colno:n,stack:s==null?void 0:s.stack,errorString:s==null?void 0:s.toString()};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(o)}}).catch(i=>{R({err:JSON.stringify(o)})})};var de=e=>{var c,a,l;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),[s,o,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},A=e=>parseInt(de(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=de(e),{major:i,minor:c,patch:a,prerelease:l}=de(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:s!==a?s>a?1:-1:o&&!l?-1:!o&&l?1:o&&l?o>l?1:o<l?-1:0:0};var $e=m(),q=(e,t)=>{$e.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},x=(e,t,r)=>{$e.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ie();var He="jolibox-sdk-loadermeta",Ve,L=JSON.parse((Ve=window.__joliboxLocalStorage__.getItem(He))!=null?Ve:"{}"),ue=Date.now(),Be=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function gr(){return d(this,null,function*(){let t=`${Ne(j)}/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:s}=yield r.json(),o=U(P({},L),{timestamp:ue});if(s){let{bootstrap_version:i}=L;i&&D(i,s)>=0||(o=U(P({},o),{bootstrap_version:s}))}if(n){let{implement_version:i}=L;i&&D(i,n)>=0||(o=U(P({},o),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(He,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ge=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,s=e.implementUrl;function o(){let{bootstrap_version:a,timestamp:l}=L;a&&l&&!Be(ue,l)&&A(a)==t&&D(a,r)>=0&&(n=me(a));try{let f=new XMLHttpRequest;return f.open("GET",n,!1),f.send(),{script:f.responseText,type:"fetch_from_cdn"}}catch(f){let g=new De(`Bootstrap module faile to fetch ${f}`);R({err:`${g}`})}}function i(){var g;let a=Date.now();q("jsSdkBegin",{t:a}),C.startTime=a;let{script:l,type:f}=(g=o())!=null?g:{};if(l){let S=document.createElement("script");S.type="text/javascript",S.innerHTML=l,document.head.appendChild(S),x("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function c(){let a=Date.now(),{implement_version:l,timestamp:f}=L;l&&f&&!Be(ue,f)&&A(l)==t&&D(l,r)>=0&&(s=pe(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=s,g.onload=()=>{x("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),gr()}catch(a){let l=new T(`module evaluate error: ${a}`);R({err:`${l}`})}}};var We=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>d(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){y(new T(`implement module evaluate error in native:${c} `))}}))(s)}return()=>{try{let s=Date.now();q("jsSdkBegin",{t:s}),C.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),x("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),x("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new T(`module load failed ${s}`))}}};var Er="1.2.5-beta.3",J=Er,Xe=A(J),Ze=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Sr=Ze?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,he="https://jsdelivr.jolibox.com";var ze=window.document.currentScript;ze&&(he=new URL(ze.src).origin);var me=(e,t)=>`${t!=null?t:he}/npm/@jolibox/bootstrap@${e}/dist/index.js`,pe=(e,t)=>`${t!=null?t:he}/npm/@jolibox/implement@${e}/dist/index.js`,yr=e=>/^\d+\.\d+\.\d+$/.test(e),et=yr(J)?Xe:J,Ye=me(et),Qe=pe(et);function vr(){Ze?We(Sr,{bootstrapUrl:Ye,implementUrl:Qe})():Ge({bootstrapUrl:Ye,implementUrl:Qe,currentMajorVersion:Xe,currentVersion:J})()}vr();var _r=m();function tt(){return _r.excuteCommandSync("API.getSystemInfoSync")}function rt(e,t){var r;return(r=Le.config[e])==null?void 0:r[t]}function nt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var ot="1.2.5-beta.3";function h(e){let[t,...r]=e.split(":"),n=rt(ae()?"native":"h5",t);if(!n)return!1;let s=n.version;return typeof s!="string"||ne(ot,s,"<")?!1:r.length===0?!0:st(n,r)||st(n.properties,r)}function st(e,t){if(!e)return!1;let r=nt(e,t);return r?Te(r)?!0:re(r)?ne(ot,r,">="):!1:!1}var it=m();function at(){return d(this,null,function*(){return h("login")?yield it.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ct(){return d(this,null,function*(){return h("checkSession")?yield it.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Rr=m();function lt(e){return d(this,null,function*(){return h("request")?yield Rr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var fe=["onI18nChanged","onBackPress"],dt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},ut=(e,t)=>{if(!fe.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},mt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var xr=m();function pt(e){return d(this,null,function*(){return h("isNativeSupport")?yield xr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var br=m();function ht(e){return d(this,null,function*(){return h("callHostMethod")?yield br.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Ir=m();function ft(e){return d(this,null,function*(){return h("track")?yield Ir.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=m();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 h(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ge=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),s=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(s),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},gt=window.JoliboxRuntime||ge;var wr="LifecycleSDK.onReady",F=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(wr,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 d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(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 d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var B=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 d(this,null,function*(){})}};var V=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 H=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:s,score:o,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:s,score:o,variation:i})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:s,variation:o}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:s,variation:o})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(s)return s;let o=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(o),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Tr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],G=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Tr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var W=class extends p{constructor(){super()}purchaseGem(t){return d(this,null,function*(){let r=this.canIUseIfThrow("payment.purchaseGem");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.purchaseGem",t)})}getGemProducts(){return d(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}};var E=class E{constructor(){this.jssdkVersion="1.2.5-beta.3";this.runtime=new gt;this.ads=new B;this.lifecycle=new F;this.storage=new $;this.keyboard=new V;this.task=new H;this.router=new G;this.payment=new W;this.getSystemInfoSync=tt.bind(this);this.canIUse=h.bind(this);this.login=at.bind(this);this.checkSession=ct.bind(this);this.request=lt.bind(this);this.on=dt.bind(this);this.off=ut.bind(this);this.once=mt.bind(this);this.isNativeSupport=pt.bind(this);this.callHostMethod=ht.bind(this);this.track=ft.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 Ee=E;window.JoliboxSDK=Ee;export{Ee as JoliboxSDK};
|