@jolibox/sdk 1.3.8 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  "packages/sdk/.eslintrc.js": "c11c589d14fe58bf4d37d259d8323b193bab6092",
5
5
  "packages/sdk/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
6
6
  "packages/sdk/esbuild.config.js": "1725a85515499085a7c9799b834c6f632073401c",
7
- "packages/sdk/package.json": "3629abdd3b383527fe08f034fbf982dddfb5e9fc",
7
+ "packages/sdk/package.json": "1acb769ecb0a536d9df050211e097fc887b63d23",
8
8
  "packages/sdk/src/__tests__/index.test.ts": "f22e0c0741297803ac3ec016b1dcc166cd2248bd",
9
9
  "packages/sdk/src/api/__tests__/canIUse.test.ts": "300e4de3768f9510e956050d326d4977bc621f34",
10
10
  "packages/sdk/src/api/call-host-method.ts": "e373cd15fe1d9d1a86c3276545017c49e954c223",
@@ -26,13 +26,13 @@
26
26
  "packages/sdk/src/sdks/ads.ts": "bec143d0340fced14fa3d372e82de7cc02c419b0",
27
27
  "packages/sdk/src/sdks/keyboard.ts": "b30424cbecffa24c9d5249366a70afe2128e64be",
28
28
  "packages/sdk/src/sdks/lifecycle.ts": "4d9a3b770d528f59c0eb9272e18d5c2c5641320d",
29
- "packages/sdk/src/sdks/payment.ts": "cdbc5596d049a47163adcf7f371ad2f5b98439e3",
29
+ "packages/sdk/src/sdks/payment.ts": "f95c8c63202466f29c4d8dcd7473bfb639663300",
30
30
  "packages/sdk/src/sdks/rewards.ts": "9c75ae1ca86d06ead0c700ca225c4dbeb7393f41",
31
31
  "packages/sdk/src/sdks/router.ts": "5aca615f05f2c85e098cd6759a0bd7ad6a31a0f2",
32
32
  "packages/sdk/src/sdks/runtime.ts": "03fcb86b362f102355bf7b74a04bbc296afc82c4",
33
33
  "packages/sdk/src/sdks/sdk.ts": "789f8be82a9c3257306f3e40d21311a7873d4502",
34
34
  "packages/sdk/src/sdks/storage.ts": "43dbbdeea3484e9ff084958bf4137190d300ff17",
35
- "packages/sdk/src/sdks/task.ts": "1f6d24acc96c38557c2f9993ca670d05abb4deda",
35
+ "packages/sdk/src/sdks/task.ts": "43602636ae5004db30b5a03d03aaf755202ad541",
36
36
  "packages/sdk/src/utils/can-i-use.ts": "10993f013cf26c07b60fe60fb7b458bbd6847244",
37
37
  "packages/sdk/src/utils/env.ts": "d2e3db934d24a3b687de1f2df04fed7a5467e161",
38
38
  "packages/sdk/src/utils/event-tracker.ts": "552a14bf0dbb8e9a68e33355dd34c4f33e4fc1d1",
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var P=Object.defineProperty,vt=Object.defineProperties,_t=Object.getOwnPropertyDescriptor,Rt=Object.getOwnPropertyDescriptors,xt=Object.getOwnPropertyNames,Re=Object.getOwnPropertySymbols;var Ie=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable;var xe=(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={}))Ie.call(t,r)&&xe(e,r,t[r]);if(Re)for(var r of Re(t))It.call(t,r)&&xe(e,r,t[r]);return e},O=(e,t)=>vt(e,Rt(t));var bt=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},wt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of xt(t))!Ie.call(e,s)&&s!==r&&P(e,s,{get:()=>t[s],enumerable:!(n=_t(t,s))||n.enumerable});return e};var Tt=e=>wt(P({},"__esModule",{value:!0}),e);var c=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(d){s(d)}},i=a=>{try{l(r.throw(a))}catch(d){s(d)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);l((r=r.apply(e,t)).next())});var Or={};bt(Or,{JoliboxSDK:()=>X});module.exports=Tt(Or);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 se=Object.defineProperty,Ct=Object.defineProperties,Dt=Object.getOwnPropertyDescriptor,At=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,Lt=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable,we=(e,t,r)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ut=(e,t)=>{for(var r in t||(t={}))Lt.call(t,r)&&we(e,r,t[r]);if(be)for(var r of be(t))Pt.call(t,r)&&we(e,r,t[r]);return e},Ot=(e,t)=>Ct(e,At(t)),kt=(e,t)=>{for(var r in t)se(e,r,{get:t[r],enumerable:!0})},De=(e,t,r,n)=>{for(var s=n>1?void 0:n?Dt(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&&se(t,r,s),s},Kt=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(d){s(d)}},i=a=>{try{l(r.throw(a))}catch(d){s(d)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 oe(e){return typeof e=="string"}function Ae(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Mt(e){return typeof e=="undefined"}function jt(e){return Mt(e)||e===null}function qt(e){return typeof e=="function"}function Le(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),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}},Pe=class extends M{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ue=class extends Pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Pe{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 I(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Ft={log:I("log"),warn:I("warn"),info:I("info"),error:I("error"),debug:I("debug")};Object.assign(globalThis,{logger:Ft});var Z=Symbol.for("Jolibox.canIUseMap"),$t={};globalThis[Z]||(globalThis[Z]=$t);var Oe={get config(){return globalThis[Z]}};var Te=Symbol.for("Jolibox.canIUseMap.native"),Bt={};globalThis[Te]||(globalThis[Te]=Bt);function ie(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 l=0;l<i;l++){let a=parseInt(s[l],10)||0,d=parseInt(o[l],10)||0;if(a>d){n=1;break}else if(a<d){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 ae=(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))(ae||{}),ce=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ce||{}),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||{}),Ce=["name","params"],Gt=["name","type","location","target","extra","timestamp","userId"],Ht=["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 Wt(e){let t=e.location?K(e.location,Ce):null,r=e.target?K(e.target,Ce):null;return K(Ot(Ut({},e),{location:t,target:r}),Gt)}function ke(e){let t=e.events.map(n=>Wt(n)),r=K(e.device,Ht);return[e.protocolVersion,t,r,e.project]}var zt=()=>"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 le(){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}}le();var v=typeof window=="undefined",de=()=>!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")},Yt=()=>k.isiOS?"iOS":k.isAndroid?"Android":k.isMac?"Mac":k.isFacebook?"Facebook":"PC",Xt="device_id",Qt="advertising_id",Ke=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,zt()),window.__joliboxLocalStorage__.getItem(e)),Zt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ke(Xt),er=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ke(Qt),tr=e=>e.charAt(0).toUpperCase()+e.slice(1),rr=()=>{var e;let t=new URLSearchParams(window.location.search);return tr((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ne=e=>{if(de())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Yt(),n=navigator.language,s=Zt(),o=er();return`${t} (${rr()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`};function Me(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"||i==="mporia.com"||i==="pingplus.ai")return`${o}.${i}`}return`${o}.jolibox.com`}function je(e){return`https://${Me("api","stg-api",e)}`}function nr(e){return Me("collect","stg-collect",e)}function qe(e){return`https://${nr(e)}`}var ee=class te{constructor(t){this.element=t,this.next=te.Undefined,this.prev=te.Undefined}};ee.Undefined=new ee(void 0);var u=ee,sr=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}},or=0,b=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 b&&(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,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let d=new b(t);return this._listeners?this._listeners instanceof b?this._listeners=[this._listeners,d]:this._listeners.push(d):((s=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||s.call(n,this),this._listeners=d,(i=(o=this.options)==null?void 0:o.onDidFirstListener)==null||i.call(o,this)),(a=(l=this.options)==null?void 0:l.onDidAddListener)==null||a.call(l,this),this._size++,()=>{var f,g,S,ve;if(!this._disposed){if(this._listeners instanceof b)this._listeners.id===d.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 _e=this._listeners.indexOf(d);_e>=0&&(this._listeners.splice(_e,1),this._size--,this._size===0&&((ve=(S=this.options)==null?void 0:S.onDidRemoveLastListener)==null||ve.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 b?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ue=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 l=this.cachedEventQueue.get(e);if(l&&r)for(let a of l)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 sr,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)}},re={};kt(re,{None:()=>ir,filter:()=>cr,once:()=>Je,toPromise:()=>ar});var ir=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function ar(e){return new Promise(t=>Je(e)(t))}function Je(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function cr(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"),lr=()=>{let e=new ue;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]},_=lr();function dr(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ur(e[n],t[n])}function ur(e,t){if(oe(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(qt(t)){try{if(e instanceof t)return}catch(r){}if(!jt(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 dr(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=De([Le],N);var ne=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=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(),re.toPromise(re.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}}};ne=De([Le],ne);var Fe=Symbol.for("Jolibox.commands");function mr(){return typeof globalThis!="undefined"?globalThis[Fe]:void 0}function pr(e){typeof globalThis!="undefined"&&(globalThis[Fe]=e)}function p(e=!1){let t=mr();if(!e&&t)return t;let r=new N,n=new ne,s={registerCommand(o,i,l){r.registerCommand({id:o,handler:i,metadata:l})},executeCommand(o,...i){return n.executeCommand(o,...i)},excuteCommandSync(o,...i){return n.executeCommandThowErr(o,...i)}};return pr(s),s}var q=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function hr(){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.3.8",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.3.8",extra:{}}}var gr=()=>{var t;return qe((t=q)!=null?t:!1)},Er=gr(),Be=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},$e;($e=AbortSignal.timeout)!=null||(AbortSignal.timeout=Be);var Sr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},yr=Sr(),vr=e=>c(void 0,null,function*(){try{let r=`${Er}/report`,n=Ne("1.3.8"),s=yr,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:Be(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function R(e){return c(this,null,function*(){try{let t={name:"globalJsError",type:ae.ErrorTrace,location:hr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=fr(),s={protocolVersion:"1.0.0",events:[t],device:r,project:ce.WebSDK},o=ke(s);yield vr(o)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",C.startTime));var _r=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},C=_r(),Ve=p(),me=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof M?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ve.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=me;window.addEventListener("unhandledrejection",me.bind(void 0));window.addEventListener("error",me.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()};Ve.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(o)}}).catch(i=>{R({err:JSON.stringify(o)})})};var pe=e=>{var l,a,d;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]=[(l=n[0])!=null?l:"0",(a=n[1])!=null?a:"0",(d=n[2])!=null?d:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},D=e=>parseInt(pe(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=pe(e),{major:i,minor:l,patch:a,prerelease:d}=pe(t);return r!==i?r>i?1:-1:n!==l?n>l?1:-1:s!==a?s>a?1:-1:o&&!d?-1:!o&&d?1:o&&d?o>d?1:o<d?-1:0:0};var Ge=p(),J=(e,t)=>{Ge.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},x=(e,t,r)=>{Ge.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};le();var ze="jolibox-sdk-loadermeta",We,L=JSON.parse((We=window.__joliboxLocalStorage__.getItem(ze))!=null?We:"{}"),he=Date.now(),He=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Rr(){return c(this,null,function*(){let t=`${je(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:he});if(s){let{bootstrap_version:i}=L;i&&A(i,s)>=0||(o=O(U({},o),{bootstrap_version:s}))}if(n){let{implement_version:i}=L;i&&A(i,n)>=0||(o=O(U({},o),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(ze,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ye=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,s=e.implementUrl;function o(){let{bootstrap_version:a,timestamp:d}=L;a&&d&&!He(he,d)&&D(a)==t&&A(a,r)>=0&&(n=fe(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 Ue(`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:d,type:f}=(g=o())!=null?g:{};if(d){let S=document.createElement("script");S.type="text/javascript",S.innerHTML=d,document.head.appendChild(S),x("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:d,timestamp:f}=L;d&&f&&!He(he,f)&&D(d)==t&&A(d,r)>=0&&(s=ge(d));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(),l(),Rr()}catch(a){let d=new T(`module evaluate error: ${a}`);R({err:`${d}`})}}};var Xe=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>c(this,null,function*(){try{let l=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(l),d=yield import(a);return URL.revokeObjectURL(a),d}catch(l){y(new T(`implement module evaluate error in native:${l} `))}}))(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 l=Date.now(),a=r(t.implementUrl);n(a),x("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new T(`module load failed ${s}`))}}};var xr="1.3.8",F=xr,tt=D(F),rt=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Ir=rt?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,Ee="https://jsdelivr.jolibox.com";var Qe=window.document.currentScript;Qe&&(Ee=new URL(Qe.src).origin);var fe=(e,t)=>`${t!=null?t:Ee}/npm/@jolibox/bootstrap@${e}/dist/index.js`,ge=(e,t)=>`${t!=null?t:Ee}/npm/@jolibox/implement@${e}/dist/index.js`,br=e=>/^\d+\.\d+\.\d+$/.test(e),nt=br(F)?tt:F,Ze=fe(nt),et=ge(nt);function wr(){rt?Xe(Ir,{bootstrapUrl:Ze,implementUrl:et})():Ye({bootstrapUrl:Ze,implementUrl:et,currentMajorVersion:tt,currentVersion:F})()}wr();var Tr=p();function st(){return Tr.excuteCommandSync("API.getSystemInfoSync")}function ot(e,t){var r;return(r=Oe.config[e])==null?void 0:r[t]}function it(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 ct="1.3.8";function h(e){let[t,...r]=e.split(":"),n=ot(de()?"native":"h5",t);if(!n)return!1;let s=n.version;return typeof s!="string"||ie(ct,s,"<")?!1:r.length===0?!0:at(n,r)||at(n.properties,r)}function at(e,t){if(!e)return!1;let r=it(e,t);return r?Ae(r)?!0:oe(r)?ie(ct,r,">="):!1:!1}var lt=p();function dt(){return c(this,null,function*(){return h("login")?yield lt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ut(){return c(this,null,function*(){return h("checkSession")?yield lt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Cr=p();function mt(e){return c(this,null,function*(){return h("request")?yield Cr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var Se=["onI18nChanged","onBackPress"],pt=(e,t)=>{if(!Se.includes(e)){y(new j(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},ht=(e,t)=>{if(!Se.includes(e)){y(new j(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},ft=(e,t)=>{if(!Se.includes(e)){y(new j(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var Dr=p();function gt(e){return c(this,null,function*(){return h("isNativeSupport")?yield Dr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ar=p();function Et(e){return c(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 Lr=p();function St(e){return c(this,null,function*(){return h("track")?yield Lr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var m=class{constructor(){this.commands=p();this._emitter=new ue}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 ye=class extends m{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)};this.gameTTI=()=>{let r=new CustomEvent("JOLIBOX_RUNTIME_GAME_TTI",{});window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.gameTTIEvent")}}},yt=window.JoliboxRuntime||ye;var Pr="LifecycleSDK.onReady",$=class extends m{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 B=class extends m{getItem(t){return c(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return c(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 c(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var V=class extends m{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 c(this,null,function*(){})}};var G=class extends m{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 m{onLevelFinished(t){return c(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,l=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(l)return Promise.resolve(l);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 c(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 l=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(l),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:s,variation:o})})}onLevelUpgrade(t){return c(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 Ur=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],W=class extends m{openSchema(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return c(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 z=class extends m{constructor(){super()}purchaseGem(t){return c(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 c(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}getSubscriptionPlans(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getSubscriptionPlans");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getSubscriptionPlans")})}subscribe(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.subscribe");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.subscribe",{productId:t.productId})})}flushSubInfoCache(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.flushSubInfoCache");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.flushSubInfoCache")})}};var Y=class extends m{constructor(){super()}getCoinDetails(r){return c(this,arguments,function*({onUpdate:t}){let n=this.canIUseIfThrow("rewards.getCoinDetails");return(n==null?void 0:n.code)==="FAILURE"?n:yield this.commands.executeCommand("RewardsSDK.getCoinDetails",t)})}createRewardsAdsManager(){let t=this.canIUseIfThrow("rewards.createRewardsAdsManager");return(t==null?void 0:t.code)==="FAILURE"?t:this.commands.executeCommand("Rewards.createRewardsAdsManager")}};var E=class E{constructor(){this.jssdkVersion="1.3.8";this.runtime=new yt;this.ads=new V;this.lifecycle=new $;this.storage=new B;this.keyboard=new G;this.task=new H;this.router=new W;this.payment=new z;this.rewards=new Y;this.getSystemInfoSync=st.bind(this);this.canIUse=h.bind(this);this.login=dt.bind(this);this.checkSession=ut.bind(this);this.request=mt.bind(this);this.on=pt.bind(this);this.off=ht.bind(this);this.once=ft.bind(this);this.isNativeSupport=gt.bind(this);this.callHostMethod=Et.bind(this);this.track=St.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 X=E;window.JoliboxSDK=X;
1
+ "use strict";var P=Object.defineProperty,vt=Object.defineProperties,_t=Object.getOwnPropertyDescriptor,Rt=Object.getOwnPropertyDescriptors,It=Object.getOwnPropertyNames,Re=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable;var Ie=(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={}))be.call(t,r)&&Ie(e,r,t[r]);if(Re)for(var r of Re(t))bt.call(t,r)&&Ie(e,r,t[r]);return e},O=(e,t)=>vt(e,Rt(t));var xt=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},wt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of It(t))!be.call(e,s)&&s!==r&&P(e,s,{get:()=>t[s],enumerable:!(n=_t(t,s))||n.enumerable});return e};var Tt=e=>wt(P({},"__esModule",{value:!0}),e);var c=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(d){s(d)}},i=a=>{try{l(r.throw(a))}catch(d){s(d)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);l((r=r.apply(e,t)).next())});var Or={};xt(Or,{JoliboxSDK:()=>X});module.exports=Tt(Or);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 se=Object.defineProperty,Ct=Object.defineProperties,Dt=Object.getOwnPropertyDescriptor,At=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertySymbols,Lt=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable,we=(e,t,r)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ut=(e,t)=>{for(var r in t||(t={}))Lt.call(t,r)&&we(e,r,t[r]);if(xe)for(var r of xe(t))Pt.call(t,r)&&we(e,r,t[r]);return e},Ot=(e,t)=>Ct(e,At(t)),kt=(e,t)=>{for(var r in t)se(e,r,{get:t[r],enumerable:!0})},De=(e,t,r,n)=>{for(var s=n>1?void 0:n?Dt(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&&se(t,r,s),s},Kt=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(d){s(d)}},i=a=>{try{l(r.throw(a))}catch(d){s(d)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 oe(e){return typeof e=="string"}function Ae(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Mt(e){return typeof e=="undefined"}function jt(e){return Mt(e)||e===null}function qt(e){return typeof e=="function"}function Le(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var Ft=(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))(Ft||{}),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}},Pe=class extends M{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ue=class extends Pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Pe{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 Z=Symbol.for("Jolibox.canIUseMap"),$t={};globalThis[Z]||(globalThis[Z]=$t);var Oe={get config(){return globalThis[Z]}};var Te=Symbol.for("Jolibox.canIUseMap.native"),Vt={};globalThis[Te]||(globalThis[Te]=Vt);function ie(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 l=0;l<i;l++){let a=parseInt(s[l],10)||0,d=parseInt(o[l],10)||0;if(a>d){n=1;break}else if(a<d){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 ae=(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))(ae||{}),ce=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ce||{}),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||{}),Ce=["name","params"],Gt=["name","type","location","target","extra","timestamp","userId"],Ht=["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 Wt(e){let t=e.location?K(e.location,Ce):null,r=e.target?K(e.target,Ce):null;return K(Ot(Ut({},e),{location:t,target:r}),Gt)}function ke(e){let t=e.events.map(n=>Wt(n)),r=K(e.device,Ht);return[e.protocolVersion,t,r,e.project]}var zt=()=>"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 le(){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}}le();var v=typeof window=="undefined",de=()=>!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")},Yt=()=>k.isiOS?"iOS":k.isAndroid?"Android":k.isMac?"Mac":k.isFacebook?"Facebook":"PC",Xt="device_id",Qt="advertising_id",Ke=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,zt()),window.__joliboxLocalStorage__.getItem(e)),Zt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ke(Xt),er=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ke(Qt),tr=e=>e.charAt(0).toUpperCase()+e.slice(1),rr=()=>{var e;let t=new URLSearchParams(window.location.search);return tr((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ne=e=>{if(de())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Yt(),n=navigator.language,s=Zt(),o=er();return`${t} (${rr()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`};function Me(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"||i==="mporia.com"||i==="pingplus.ai")return`${o}.${i}`}return`${o}.jolibox.com`}function je(e){return`https://${Me("api","stg-api",e)}`}function nr(e){return Me("collect","stg-collect",e)}function qe(e){return`https://${nr(e)}`}var ee=class te{constructor(t){this.element=t,this.next=te.Undefined,this.prev=te.Undefined}};ee.Undefined=new ee(void 0);var u=ee,sr=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}},or=0,x=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 x&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,s,o,i,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let d=new x(t);return this._listeners?this._listeners instanceof x?this._listeners=[this._listeners,d]:this._listeners.push(d):((s=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||s.call(n,this),this._listeners=d,(i=(o=this.options)==null?void 0:o.onDidFirstListener)==null||i.call(o,this)),(a=(l=this.options)==null?void 0:l.onDidAddListener)==null||a.call(l,this),this._size++,()=>{var f,g,S,ve;if(!this._disposed){if(this._listeners instanceof x)this._listeners.id===d.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 _e=this._listeners.indexOf(d);_e>=0&&(this._listeners.splice(_e,1),this._size--,this._size===0&&((ve=(S=this.options)==null?void 0:S.onDidRemoveLastListener)==null||ve.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 x?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ue=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 l=this.cachedEventQueue.get(e);if(l&&r)for(let a of l)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 sr,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)}},re={};kt(re,{None:()=>ir,filter:()=>cr,once:()=>Fe,toPromise:()=>ar});var ir=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function ar(e){return new Promise(t=>Fe(e)(t))}function Fe(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function cr(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"),lr=()=>{let e=new ue;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]},_=lr();function dr(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ur(e[n],t[n])}function ur(e,t){if(oe(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(qt(t)){try{if(e instanceof t)return}catch(r){}if(!jt(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 dr(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=De([Le],N);var ne=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=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(),re.toPromise(re.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}}};ne=De([Le],ne);var Je=Symbol.for("Jolibox.commands");function mr(){return typeof globalThis!="undefined"?globalThis[Je]:void 0}function pr(e){typeof globalThis!="undefined"&&(globalThis[Je]=e)}function p(e=!1){let t=mr();if(!e&&t)return t;let r=new N,n=new ne,s={registerCommand(o,i,l){r.registerCommand({id:o,handler:i,metadata:l})},executeCommand(o,...i){return n.executeCommand(o,...i)},excuteCommandSync(o,...i){return n.executeCommandThowErr(o,...i)}};return pr(s),s}var q=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function hr(){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.4.0",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.4.0",extra:{}}}var gr=()=>{var t;return qe((t=q)!=null?t:!1)},Er=gr(),Ve=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},$e;($e=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ve);var Sr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},yr=Sr(),vr=e=>c(void 0,null,function*(){try{let r=`${Er}/report`,n=Ne("1.4.0"),s=yr,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:Ve(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function R(e){return c(this,null,function*(){try{let t={name:"globalJsError",type:ae.ErrorTrace,location:hr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=fr(),s={protocolVersion:"1.0.0",events:[t],device:r,project:ce.WebSDK},o=ke(s);yield vr(o)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",C.startTime));var _r=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},C=_r(),Be=p(),me=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof M?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};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=me;window.addEventListener("unhandledrejection",me.bind(void 0));window.addEventListener("error",me.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 pe=e=>{var l,a,d;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]=[(l=n[0])!=null?l:"0",(a=n[1])!=null?a:"0",(d=n[2])!=null?d:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},D=e=>parseInt(pe(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=pe(e),{major:i,minor:l,patch:a,prerelease:d}=pe(t);return r!==i?r>i?1:-1:n!==l?n>l?1:-1:s!==a?s>a?1:-1:o&&!d?-1:!o&&d?1:o&&d?o>d?1:o<d?-1:0:0};var Ge=p(),F=(e,t)=>{Ge.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},I=(e,t,r)=>{Ge.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};le();var ze="jolibox-sdk-loadermeta",We,L=JSON.parse((We=window.__joliboxLocalStorage__.getItem(ze))!=null?We:"{}"),he=Date.now(),He=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Rr(){return c(this,null,function*(){let t=`${je(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:he});if(s){let{bootstrap_version:i}=L;i&&A(i,s)>=0||(o=O(U({},o),{bootstrap_version:s}))}if(n){let{implement_version:i}=L;i&&A(i,n)>=0||(o=O(U({},o),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(ze,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ye=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,s=e.implementUrl;function o(){let{bootstrap_version:a,timestamp:d}=L;a&&d&&!He(he,d)&&D(a)==t&&A(a,r)>=0&&(n=fe(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 Ue(`Bootstrap module faile to fetch ${f}`);R({err:`${g}`})}}function i(){var g;let a=Date.now();F("jsSdkBegin",{t:a}),C.startTime=a;let{script:d,type:f}=(g=o())!=null?g:{};if(d){let S=document.createElement("script");S.type="text/javascript",S.innerHTML=d,document.head.appendChild(S),I("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:d,timestamp:f}=L;d&&f&&!He(he,f)&&D(d)==t&&A(d,r)>=0&&(s=ge(d));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=s,g.onload=()=>{I("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),l(),Rr()}catch(a){let d=new T(`module evaluate error: ${a}`);R({err:`${d}`})}}};var Xe=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>c(this,null,function*(){try{let l=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(l),d=yield import(a);return URL.revokeObjectURL(a),d}catch(l){y(new T(`implement module evaluate error in native:${l} `))}}))(s)}return()=>{try{let s=Date.now();F("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),I("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let l=Date.now(),a=r(t.implementUrl);n(a),I("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new T(`module load failed ${s}`))}}};var Ir="1.4.0",J=Ir,tt=D(J),rt=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),br=rt?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,Ee="https://jsdelivr.jolibox.com";var Qe=window.document.currentScript;Qe&&(Ee=new URL(Qe.src).origin);var fe=(e,t)=>`${t!=null?t:Ee}/npm/@jolibox/bootstrap@${e}/dist/index.js`,ge=(e,t)=>`${t!=null?t:Ee}/npm/@jolibox/implement@${e}/dist/index.js`,xr=e=>/^\d+\.\d+\.\d+$/.test(e),nt=xr(J)?tt:J,Ze=fe(nt),et=ge(nt);function wr(){rt?Xe(br,{bootstrapUrl:Ze,implementUrl:et})():Ye({bootstrapUrl:Ze,implementUrl:et,currentMajorVersion:tt,currentVersion:J})()}wr();var Tr=p();function st(){return Tr.excuteCommandSync("API.getSystemInfoSync")}function ot(e,t){var r;return(r=Oe.config[e])==null?void 0:r[t]}function it(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 ct="1.4.0";function h(e){let[t,...r]=e.split(":"),n=ot(de()?"native":"h5",t);if(!n)return!1;let s=n.version;return typeof s!="string"||ie(ct,s,"<")?!1:r.length===0?!0:at(n,r)||at(n.properties,r)}function at(e,t){if(!e)return!1;let r=it(e,t);return r?Ae(r)?!0:oe(r)?ie(ct,r,">="):!1:!1}var lt=p();function dt(){return c(this,null,function*(){return h("login")?yield lt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ut(){return c(this,null,function*(){return h("checkSession")?yield lt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Cr=p();function mt(e){return c(this,null,function*(){return h("request")?yield Cr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var Se=["onI18nChanged","onBackPress"],pt=(e,t)=>{if(!Se.includes(e)){y(new j(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},ht=(e,t)=>{if(!Se.includes(e)){y(new j(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},ft=(e,t)=>{if(!Se.includes(e)){y(new j(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var Dr=p();function gt(e){return c(this,null,function*(){return h("isNativeSupport")?yield Dr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ar=p();function Et(e){return c(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 Lr=p();function St(e){return c(this,null,function*(){return h("track")?yield Lr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var m=class{constructor(){this.commands=p();this._emitter=new ue}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 ye=class extends m{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)};this.gameTTI=()=>{let r=new CustomEvent("JOLIBOX_RUNTIME_GAME_TTI",{});window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.gameTTIEvent")}}},yt=window.JoliboxRuntime||ye;var Pr="LifecycleSDK.onReady",$=class extends m{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 V=class extends m{getItem(t){return c(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return c(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 c(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var B=class extends m{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 c(this,null,function*(){})}};var G=class extends m{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 m{onLevelFinished(t){return c(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,l=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(l)return Promise.resolve(l);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 c(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 l=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(l),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:s,variation:o})})}onLevelUpgrade(t){return c(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})})}onLevelStart(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r}=t,n=this.canIUseIfThrow("TaskTrackerSDK.onLevelStart");if(n)return Promise.resolve(n);let s=new CustomEvent("JOLIBOX_LEVEL_START_EVENT",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelStart",{levelId:r})})}onLevelFailed(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,score:n,rating:s,duration:o}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onLevelFailed");if(i)return Promise.resolve(i);let l=new CustomEvent("JOLIBOX_LEVEL_FAIL_EVENT",{detail:t});return window.dispatchEvent(l),yield this.commands.executeCommand("TaskTrackerSDK.levelFailed",{levelId:r,score:n,rating:s,duration:o})})}};var Ur=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],W=class extends m{openSchema(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return c(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 z=class extends m{constructor(){super()}purchaseGem(t){return c(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 c(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}getSubscriptionPlans(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getSubscriptionPlans");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getSubscriptionPlans")})}subscribe(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.subscribe");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.subscribe",{productId:t.productId,appStoreProductId:t.appStoreProductId})})}subscribeSpin(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.subscribeSpin");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.subscribeSpin",{productId:t.productId,appStoreProductId:t.appStoreProductId})})}flushSubInfoCache(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.flushSubInfoCache");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.flushSubInfoCache")})}};var Y=class extends m{constructor(){super()}getCoinDetails(r){return c(this,arguments,function*({onUpdate:t}){let n=this.canIUseIfThrow("rewards.getCoinDetails");return(n==null?void 0:n.code)==="FAILURE"?n:yield this.commands.executeCommand("RewardsSDK.getCoinDetails",t)})}createRewardsAdsManager(){let t=this.canIUseIfThrow("rewards.createRewardsAdsManager");return(t==null?void 0:t.code)==="FAILURE"?t:this.commands.executeCommand("Rewards.createRewardsAdsManager")}};var E=class E{constructor(){this.jssdkVersion="1.4.0";this.runtime=new yt;this.ads=new B;this.lifecycle=new $;this.storage=new V;this.keyboard=new G;this.task=new H;this.router=new W;this.payment=new z;this.rewards=new Y;this.getSystemInfoSync=st.bind(this);this.canIUse=h.bind(this);this.login=dt.bind(this);this.checkSession=ut.bind(this);this.request=mt.bind(this);this.on=pt.bind(this);this.off=ht.bind(this);this.once=ft.bind(this);this.isNativeSupport=gt.bind(this);this.callHostMethod=Et.bind(this);this.track=St.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 X=E;window.JoliboxSDK=X;
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- var St=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable;var Re=(e,t,r)=>t in e?St(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&Re(e,r,t[r]);if(_e)for(var r of _e(t))Rt.call(t,r)&&Re(e,r,t[r]);return e},U=(e,t)=>yt(e,vt(t));var c=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(d){s(d)}},i=a=>{try{l(r.throw(a))}catch(d){s(d)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 re=Object.defineProperty,xt=Object.defineProperties,It=Object.getOwnPropertyDescriptor,bt=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertySymbols,wt=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable,Ie=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ct=(e,t)=>{for(var r in t||(t={}))wt.call(t,r)&&Ie(e,r,t[r]);if(xe)for(var r of xe(t))Tt.call(t,r)&&Ie(e,r,t[r]);return e},Dt=(e,t)=>xt(e,bt(t)),At=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},Te=(e,t,r,n)=>{for(var s=n>1?void 0:n?It(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&&re(t,r,s),s},Lt=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(d){s(d)}},i=a=>{try{l(r.throw(a))}catch(d){s(d)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 Pt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ne(e){return typeof e=="string"}function Ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Ut(e){return typeof e=="undefined"}function Ot(e){return Ut(e)||e===null}function kt(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 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||{}),N=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Ae=class extends N{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Le=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 N{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 I(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Nt={log:I("log"),warn:I("warn"),info:I("info"),error:I("error"),debug:I("debug")};Object.assign(globalThis,{logger:Nt});var X=Symbol.for("Jolibox.canIUseMap"),Mt={};globalThis[X]||(globalThis[X]=Mt);var Pe={get config(){return globalThis[X]}};var be=Symbol.for("Jolibox.canIUseMap.native"),jt={};globalThis[be]||(globalThis[be]=jt);function se(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 l=0;l<i;l++){let a=parseInt(s[l],10)||0,d=parseInt(o[l],10)||0;if(a>d){n=1;break}else if(a<d){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var oe=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),ie=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ie||{}),qt=(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))(qt||{}),we=["name","params"],Jt=["name","type","location","target","extra","timestamp","userId"],Ft=["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 $t(e){let t=e.location?k(e.location,we):null,r=e.target?k(e.target,we):null;return k(Dt(Ct({},e),{location:t,target:r}),Jt)}function Ue(e){let t=e.events.map(n=>$t(n)),r=k(e.device,Ft);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 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 v=typeof window=="undefined",ce=()=>!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")},Vt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Gt="device_id",Ht="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Bt()),window.__joliboxLocalStorage__.getItem(e)),Wt=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe(Gt),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(Ht),Yt=e=>e.charAt(0).toUpperCase()+e.slice(1),Xt=()=>{var e;let t=new URLSearchParams(window.location.search);return Yt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},ke=e=>{if(ce())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,s=Wt(),o=zt();return`${t} (${Xt()}${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"||i==="mporia.com"||i==="pingplus.ai")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 Me(e){return`https://${Qt(e)}`}var Q=class Z{constructor(t){this.element=t,this.next=Z.Undefined,this.prev=Z.Undefined}};Q.Undefined=new Q(void 0);var u=Q,Zt=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}},er=0,b=class{constructor(e){this.value=e,this.id=er++}},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 b&&(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,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let d=new b(t);return this._listeners?this._listeners instanceof b?this._listeners=[this._listeners,d]:this._listeners.push(d):((s=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||s.call(n,this),this._listeners=d,(i=(o=this.options)==null?void 0:o.onDidFirstListener)==null||i.call(o,this)),(a=(l=this.options)==null?void 0:l.onDidAddListener)==null||a.call(l,this),this._size++,()=>{var f,g,S,ye;if(!this._disposed){if(this._listeners instanceof b)this._listeners.id===d.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(d);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 b?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 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 l=this.cachedEventQueue.get(e);if(l&&r)for(let a of l)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 Zt,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={};At(ee,{None:()=>tr,filter:()=>nr,once:()=>je,toPromise:()=>rr});var tr=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function rr(e){return new Promise(t=>je(e)(t))}function je(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function nr(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 Y=Symbol.for("Jolibox.hostEmitter"),sr=()=>{let e=new le;return globalThis[Y]||(globalThis[Y]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Y]},_=sr();function or(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ir(e[n],t[n])}function ir(e,t){if(ne(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(kt(t)){try{if(e instanceof t)return}catch(r){}if(!Ot(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var K=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return or(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=Te([De],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=Pt(3e4)),this._starActivation}executeCommand(e,...t){return Lt(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([De],te);var qe=Symbol.for("Jolibox.commands");function ar(){return typeof globalThis!="undefined"?globalThis[qe]:void 0}function cr(e){typeof globalThis!="undefined"&&(globalThis[qe]=e)}function p(e=!1){let t=ar();if(!e&&t)return t;let r=new K,n=new te,s={registerCommand(o,i,l){r.registerCommand({id:o,handler:i,metadata:l})},executeCommand(o,...i){return n.executeCommand(o,...i)},excuteCommandSync(o,...i){return n.executeCommandThowErr(o,...i)}};return cr(s),s}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function lr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function dr(){return{platform:1e3,os:"h5",appVersion:"1.3.8",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.3.8",extra:{}}}var ur=()=>{var t;return Me((t=j)!=null?t:!1)},mr=ur(),Fe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Je;(Je=AbortSignal.timeout)!=null||(AbortSignal.timeout=Fe);var pr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},hr=pr(),fr=e=>c(void 0,null,function*(){try{let r=`${mr}/report`,n=ke("1.3.8"),s=hr,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:Fe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function R(e){return c(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:lr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=dr(),s={protocolVersion:"1.0.0",events:[t],device:r,project:ie.WebSDK},o=Ue(s);yield fr(o)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",C.startTime));var gr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},C=gr(),$e=p(),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 N?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};$e.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=de;window.addEventListener("unhandledrejection",de.bind(void 0));window.addEventListener("error",de.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()};$e.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(o)}}).catch(i=>{R({err:JSON.stringify(o)})})};var ue=e=>{var l,a,d;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]=[(l=n[0])!=null?l:"0",(a=n[1])!=null?a:"0",(d=n[2])!=null?d:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},D=e=>parseInt(ue(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=ue(e),{major:i,minor:l,patch:a,prerelease:d}=ue(t);return r!==i?r>i?1:-1:n!==l?n>l?1:-1:s!==a?s>a?1:-1:o&&!d?-1:!o&&d?1:o&&d?o>d?1:o<d?-1:0:0};var Be=p(),q=(e,t)=>{Be.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},x=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ae();var He="jolibox-sdk-loadermeta",Ge,L=JSON.parse((Ge=window.__joliboxLocalStorage__.getItem(He))!=null?Ge:"{}"),me=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Er(){return c(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:me});if(s){let{bootstrap_version:i}=L;i&&A(i,s)>=0||(o=U(P({},o),{bootstrap_version:s}))}if(n){let{implement_version:i}=L;i&&A(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 We=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,s=e.implementUrl;function o(){let{bootstrap_version:a,timestamp:d}=L;a&&d&&!Ve(me,d)&&D(a)==t&&A(a,r)>=0&&(n=pe(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 Le(`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:d,type:f}=(g=o())!=null?g:{};if(d){let S=document.createElement("script");S.type="text/javascript",S.innerHTML=d,document.head.appendChild(S),x("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:d,timestamp:f}=L;d&&f&&!Ve(me,f)&&D(d)==t&&A(d,r)>=0&&(s=he(d));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(),l(),Er()}catch(a){let d=new T(`module evaluate error: ${a}`);R({err:`${d}`})}}};var ze=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>c(this,null,function*(){try{let l=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(l),d=yield import(a);return URL.revokeObjectURL(a),d}catch(l){y(new T(`implement module evaluate error in native:${l} `))}}))(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 l=Date.now(),a=r(t.implementUrl);n(a),x("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new T(`module load failed ${s}`))}}};var Sr="1.3.8",J=Sr,Ze=D(J),et=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),yr=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,fe="https://jsdelivr.jolibox.com";var Ye=window.document.currentScript;Ye&&(fe=new URL(Ye.src).origin);var pe=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,he=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/implement@${e}/dist/index.js`,vr=e=>/^\d+\.\d+\.\d+$/.test(e),tt=vr(J)?Ze:J,Xe=pe(tt),Qe=he(tt);function _r(){et?ze(yr,{bootstrapUrl:Xe,implementUrl:Qe})():We({bootstrapUrl:Xe,implementUrl:Qe,currentMajorVersion:Ze,currentVersion:J})()}_r();var Rr=p();function rt(){return Rr.excuteCommandSync("API.getSystemInfoSync")}function nt(e,t){var r;return(r=Pe.config[e])==null?void 0:r[t]}function st(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 it="1.3.8";function h(e){let[t,...r]=e.split(":"),n=nt(ce()?"native":"h5",t);if(!n)return!1;let s=n.version;return typeof s!="string"||se(it,s,"<")?!1:r.length===0?!0:ot(n,r)||ot(n.properties,r)}function ot(e,t){if(!e)return!1;let r=st(e,t);return r?Ce(r)?!0:ne(r)?se(it,r,">="):!1:!1}var at=p();function ct(){return c(this,null,function*(){return h("login")?yield at.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function lt(){return c(this,null,function*(){return h("checkSession")?yield at.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var xr=p();function dt(e){return c(this,null,function*(){return h("request")?yield xr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ge=["onI18nChanged","onBackPress"],ut=(e,t)=>{if(!ge.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},mt=(e,t)=>{if(!ge.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},pt=(e,t)=>{if(!ge.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var Ir=p();function ht(e){return c(this,null,function*(){return h("isNativeSupport")?yield Ir.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var br=p();function ft(e){return c(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 wr=p();function gt(e){return c(this,null,function*(){return h("track")?yield wr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var m=class{constructor(){this.commands=p();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 h(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var Ee=class extends m{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)};this.gameTTI=()=>{let r=new CustomEvent("JOLIBOX_RUNTIME_GAME_TTI",{});window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.gameTTIEvent")}}},Et=window.JoliboxRuntime||Ee;var Tr="LifecycleSDK.onReady",F=class extends m{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Tr,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 m{getItem(t){return c(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return c(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 c(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var B=class extends m{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 c(this,null,function*(){})}};var V=class extends m{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 m{onLevelFinished(t){return c(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,l=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(l)return Promise.resolve(l);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 c(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 l=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(l),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:s,variation:o})})}onLevelUpgrade(t){return c(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 Cr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],H=class extends m{openSchema(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return c(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Cr.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 m{constructor(){super()}purchaseGem(t){return c(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 c(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}getSubscriptionPlans(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getSubscriptionPlans");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getSubscriptionPlans")})}subscribe(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.subscribe");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.subscribe",{productId:t.productId})})}flushSubInfoCache(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.flushSubInfoCache");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.flushSubInfoCache")})}};var z=class extends m{constructor(){super()}getCoinDetails(r){return c(this,arguments,function*({onUpdate:t}){let n=this.canIUseIfThrow("rewards.getCoinDetails");return(n==null?void 0:n.code)==="FAILURE"?n:yield this.commands.executeCommand("RewardsSDK.getCoinDetails",t)})}createRewardsAdsManager(){let t=this.canIUseIfThrow("rewards.createRewardsAdsManager");return(t==null?void 0:t.code)==="FAILURE"?t:this.commands.executeCommand("Rewards.createRewardsAdsManager")}};var E=class E{constructor(){this.jssdkVersion="1.3.8";this.runtime=new Et;this.ads=new B;this.lifecycle=new F;this.storage=new $;this.keyboard=new V;this.task=new G;this.router=new H;this.payment=new W;this.rewards=new z;this.getSystemInfoSync=rt.bind(this);this.canIUse=h.bind(this);this.login=ct.bind(this);this.checkSession=lt.bind(this);this.request=dt.bind(this);this.on=ut.bind(this);this.off=mt.bind(this);this.once=pt.bind(this);this.isNativeSupport=ht.bind(this);this.callHostMethod=ft.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 Se=E;window.JoliboxSDK=Se;export{Se as JoliboxSDK};
1
+ var St=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable;var Re=(e,t,r)=>t in e?St(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&Re(e,r,t[r]);if(_e)for(var r of _e(t))Rt.call(t,r)&&Re(e,r,t[r]);return e},U=(e,t)=>yt(e,vt(t));var c=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(d){s(d)}},i=a=>{try{l(r.throw(a))}catch(d){s(d)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 re=Object.defineProperty,It=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyDescriptors,Ie=Object.getOwnPropertySymbols,wt=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ct=(e,t)=>{for(var r in t||(t={}))wt.call(t,r)&&be(e,r,t[r]);if(Ie)for(var r of Ie(t))Tt.call(t,r)&&be(e,r,t[r]);return e},Dt=(e,t)=>It(e,xt(t)),At=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},Te=(e,t,r,n)=>{for(var s=n>1?void 0:n?bt(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&&re(t,r,s),s},Lt=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(d){s(d)}},i=a=>{try{l(r.throw(a))}catch(d){s(d)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 Pt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ne(e){return typeof e=="string"}function Ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Ut(e){return typeof e=="undefined"}function Ot(e){return Ut(e)||e===null}function kt(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 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||{}),N=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Ae=class extends N{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Le=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 N{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 X=Symbol.for("Jolibox.canIUseMap"),Mt={};globalThis[X]||(globalThis[X]=Mt);var Pe={get config(){return globalThis[X]}};var xe=Symbol.for("Jolibox.canIUseMap.native"),jt={};globalThis[xe]||(globalThis[xe]=jt);function se(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 l=0;l<i;l++){let a=parseInt(s[l],10)||0,d=parseInt(o[l],10)||0;if(a>d){n=1;break}else if(a<d){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var oe=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),ie=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ie||{}),qt=(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))(qt||{}),we=["name","params"],Ft=["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 $t(e){let t=e.location?k(e.location,we):null,r=e.target?k(e.target,we):null;return k(Dt(Ct({},e),{location:t,target:r}),Ft)}function Ue(e){let t=e.events.map(n=>$t(n)),r=k(e.device,Jt);return[e.protocolVersion,t,r,e.project]}var Vt=()=>"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 v=typeof window=="undefined",ce=()=>!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",Gt="device_id",Ht="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Vt()),window.__joliboxLocalStorage__.getItem(e)),Wt=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe(Gt),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(Ht),Yt=e=>e.charAt(0).toUpperCase()+e.slice(1),Xt=()=>{var e;let t=new URLSearchParams(window.location.search);return Yt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},ke=e=>{if(ce())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Bt(),n=navigator.language,s=Wt(),o=zt();return`${t} (${Xt()}${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"||i==="mporia.com"||i==="pingplus.ai")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 Me(e){return`https://${Qt(e)}`}var Q=class Z{constructor(t){this.element=t,this.next=Z.Undefined,this.prev=Z.Undefined}};Q.Undefined=new Q(void 0);var u=Q,Zt=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}},er=0,x=class{constructor(e){this.value=e,this.id=er++}},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 x&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,s,o,i,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let d=new x(t);return this._listeners?this._listeners instanceof x?this._listeners=[this._listeners,d]:this._listeners.push(d):((s=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||s.call(n,this),this._listeners=d,(i=(o=this.options)==null?void 0:o.onDidFirstListener)==null||i.call(o,this)),(a=(l=this.options)==null?void 0:l.onDidAddListener)==null||a.call(l,this),this._size++,()=>{var f,g,S,ye;if(!this._disposed){if(this._listeners instanceof x)this._listeners.id===d.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(d);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 x?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 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 l=this.cachedEventQueue.get(e);if(l&&r)for(let a of l)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 Zt,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={};At(ee,{None:()=>tr,filter:()=>nr,once:()=>je,toPromise:()=>rr});var tr=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function rr(e){return new Promise(t=>je(e)(t))}function je(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function nr(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 Y=Symbol.for("Jolibox.hostEmitter"),sr=()=>{let e=new le;return globalThis[Y]||(globalThis[Y]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Y]},_=sr();function or(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ir(e[n],t[n])}function ir(e,t){if(ne(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(kt(t)){try{if(e instanceof t)return}catch(r){}if(!Ot(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var K=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return or(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=Te([De],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=Pt(3e4)),this._starActivation}executeCommand(e,...t){return Lt(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([De],te);var qe=Symbol.for("Jolibox.commands");function ar(){return typeof globalThis!="undefined"?globalThis[qe]:void 0}function cr(e){typeof globalThis!="undefined"&&(globalThis[qe]=e)}function p(e=!1){let t=ar();if(!e&&t)return t;let r=new K,n=new te,s={registerCommand(o,i,l){r.registerCommand({id:o,handler:i,metadata:l})},executeCommand(o,...i){return n.executeCommand(o,...i)},excuteCommandSync(o,...i){return n.executeCommandThowErr(o,...i)}};return cr(s),s}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function lr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function dr(){return{platform:1e3,os:"h5",appVersion:"1.4.0",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.4.0",extra:{}}}var ur=()=>{var t;return Me((t=j)!=null?t:!1)},mr=ur(),Je=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Fe;(Fe=AbortSignal.timeout)!=null||(AbortSignal.timeout=Je);var pr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},hr=pr(),fr=e=>c(void 0,null,function*(){try{let r=`${mr}/report`,n=ke("1.4.0"),s=hr,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 c(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:lr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=dr(),s={protocolVersion:"1.0.0",events:[t],device:r,project:ie.WebSDK},o=Ue(s);yield fr(o)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",C.startTime));var gr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},C=gr(),$e=p(),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 N?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};$e.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=de;window.addEventListener("unhandledrejection",de.bind(void 0));window.addEventListener("error",de.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()};$e.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(o)}}).catch(i=>{R({err:JSON.stringify(o)})})};var ue=e=>{var l,a,d;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]=[(l=n[0])!=null?l:"0",(a=n[1])!=null?a:"0",(d=n[2])!=null?d:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},D=e=>parseInt(ue(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=ue(e),{major:i,minor:l,patch:a,prerelease:d}=ue(t);return r!==i?r>i?1:-1:n!==l?n>l?1:-1:s!==a?s>a?1:-1:o&&!d?-1:!o&&d?1:o&&d?o>d?1:o<d?-1:0:0};var Ve=p(),q=(e,t)=>{Ve.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},I=(e,t,r)=>{Ve.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ae();var He="jolibox-sdk-loadermeta",Ge,L=JSON.parse((Ge=window.__joliboxLocalStorage__.getItem(He))!=null?Ge:"{}"),me=Date.now(),Be=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Er(){return c(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:me});if(s){let{bootstrap_version:i}=L;i&&A(i,s)>=0||(o=U(P({},o),{bootstrap_version:s}))}if(n){let{implement_version:i}=L;i&&A(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 We=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,s=e.implementUrl;function o(){let{bootstrap_version:a,timestamp:d}=L;a&&d&&!Be(me,d)&&D(a)==t&&A(a,r)>=0&&(n=pe(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 Le(`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:d,type:f}=(g=o())!=null?g:{};if(d){let S=document.createElement("script");S.type="text/javascript",S.innerHTML=d,document.head.appendChild(S),I("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:d,timestamp:f}=L;d&&f&&!Be(me,f)&&D(d)==t&&A(d,r)>=0&&(s=he(d));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=s,g.onload=()=>{I("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),l(),Er()}catch(a){let d=new T(`module evaluate error: ${a}`);R({err:`${d}`})}}};var ze=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>c(this,null,function*(){try{let l=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(l),d=yield import(a);return URL.revokeObjectURL(a),d}catch(l){y(new T(`implement module evaluate error in native:${l} `))}}))(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),I("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let l=Date.now(),a=r(t.implementUrl);n(a),I("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new T(`module load failed ${s}`))}}};var Sr="1.4.0",F=Sr,Ze=D(F),et=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),yr=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,fe="https://jsdelivr.jolibox.com";var Ye=window.document.currentScript;Ye&&(fe=new URL(Ye.src).origin);var pe=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,he=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/implement@${e}/dist/index.js`,vr=e=>/^\d+\.\d+\.\d+$/.test(e),tt=vr(F)?Ze:F,Xe=pe(tt),Qe=he(tt);function _r(){et?ze(yr,{bootstrapUrl:Xe,implementUrl:Qe})():We({bootstrapUrl:Xe,implementUrl:Qe,currentMajorVersion:Ze,currentVersion:F})()}_r();var Rr=p();function rt(){return Rr.excuteCommandSync("API.getSystemInfoSync")}function nt(e,t){var r;return(r=Pe.config[e])==null?void 0:r[t]}function st(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 it="1.4.0";function h(e){let[t,...r]=e.split(":"),n=nt(ce()?"native":"h5",t);if(!n)return!1;let s=n.version;return typeof s!="string"||se(it,s,"<")?!1:r.length===0?!0:ot(n,r)||ot(n.properties,r)}function ot(e,t){if(!e)return!1;let r=st(e,t);return r?Ce(r)?!0:ne(r)?se(it,r,">="):!1:!1}var at=p();function ct(){return c(this,null,function*(){return h("login")?yield at.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function lt(){return c(this,null,function*(){return h("checkSession")?yield at.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Ir=p();function dt(e){return c(this,null,function*(){return h("request")?yield Ir.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ge=["onI18nChanged","onBackPress"],ut=(e,t)=>{if(!ge.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},mt=(e,t)=>{if(!ge.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},pt=(e,t)=>{if(!ge.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var br=p();function ht(e){return c(this,null,function*(){return h("isNativeSupport")?yield br.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var xr=p();function ft(e){return c(this,null,function*(){return h("callHostMethod")?yield xr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var wr=p();function gt(e){return c(this,null,function*(){return h("track")?yield wr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var m=class{constructor(){this.commands=p();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 h(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var Ee=class extends m{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)};this.gameTTI=()=>{let r=new CustomEvent("JOLIBOX_RUNTIME_GAME_TTI",{});window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.gameTTIEvent")}}},Et=window.JoliboxRuntime||Ee;var Tr="LifecycleSDK.onReady",J=class extends m{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Tr,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 m{getItem(t){return c(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return c(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 c(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var V=class extends m{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 c(this,null,function*(){})}};var B=class extends m{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 m{onLevelFinished(t){return c(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,l=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(l)return Promise.resolve(l);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 c(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 l=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(l),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:s,variation:o})})}onLevelUpgrade(t){return c(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})})}onLevelStart(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r}=t,n=this.canIUseIfThrow("TaskTrackerSDK.onLevelStart");if(n)return Promise.resolve(n);let s=new CustomEvent("JOLIBOX_LEVEL_START_EVENT",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelStart",{levelId:r})})}onLevelFailed(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,score:n,rating:s,duration:o}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onLevelFailed");if(i)return Promise.resolve(i);let l=new CustomEvent("JOLIBOX_LEVEL_FAIL_EVENT",{detail:t});return window.dispatchEvent(l),yield this.commands.executeCommand("TaskTrackerSDK.levelFailed",{levelId:r,score:n,rating:s,duration:o})})}};var Cr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],H=class extends m{openSchema(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return c(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Cr.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 m{constructor(){super()}purchaseGem(t){return c(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 c(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}getSubscriptionPlans(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getSubscriptionPlans");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getSubscriptionPlans")})}subscribe(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.subscribe");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.subscribe",{productId:t.productId,appStoreProductId:t.appStoreProductId})})}subscribeSpin(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.subscribeSpin");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.subscribeSpin",{productId:t.productId,appStoreProductId:t.appStoreProductId})})}flushSubInfoCache(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.flushSubInfoCache");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.flushSubInfoCache")})}};var z=class extends m{constructor(){super()}getCoinDetails(r){return c(this,arguments,function*({onUpdate:t}){let n=this.canIUseIfThrow("rewards.getCoinDetails");return(n==null?void 0:n.code)==="FAILURE"?n:yield this.commands.executeCommand("RewardsSDK.getCoinDetails",t)})}createRewardsAdsManager(){let t=this.canIUseIfThrow("rewards.createRewardsAdsManager");return(t==null?void 0:t.code)==="FAILURE"?t:this.commands.executeCommand("Rewards.createRewardsAdsManager")}};var E=class E{constructor(){this.jssdkVersion="1.4.0";this.runtime=new Et;this.ads=new V;this.lifecycle=new J;this.storage=new $;this.keyboard=new B;this.task=new G;this.router=new H;this.payment=new W;this.rewards=new z;this.getSystemInfoSync=rt.bind(this);this.canIUse=h.bind(this);this.login=ct.bind(this);this.checkSession=lt.bind(this);this.request=dt.bind(this);this.on=ut.bind(this);this.off=mt.bind(this);this.once=pt.bind(this);this.isNativeSupport=ht.bind(this);this.callHostMethod=ft.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 Se=E;window.JoliboxSDK=Se;export{Se as JoliboxSDK};
@@ -1 +1 @@
1
- "use strict";(()=>{var St=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable;var Re=(e,t,r)=>t in e?St(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&Re(e,r,t[r]);if(_e)for(var r of _e(t))Rt.call(t,r)&&Re(e,r,t[r]);return e},U=(e,t)=>yt(e,vt(t));var c=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(d){s(d)}},i=a=>{try{l(r.throw(a))}catch(d){s(d)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 re=Object.defineProperty,xt=Object.defineProperties,It=Object.getOwnPropertyDescriptor,bt=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertySymbols,wt=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable,Ie=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ct=(e,t)=>{for(var r in t||(t={}))wt.call(t,r)&&Ie(e,r,t[r]);if(xe)for(var r of xe(t))Tt.call(t,r)&&Ie(e,r,t[r]);return e},Dt=(e,t)=>xt(e,bt(t)),At=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},Te=(e,t,r,n)=>{for(var s=n>1?void 0:n?It(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&&re(t,r,s),s},Lt=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(d){s(d)}},i=a=>{try{l(r.throw(a))}catch(d){s(d)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 Pt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ne(e){return typeof e=="string"}function Ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Ut(e){return typeof e=="undefined"}function Ot(e){return Ut(e)||e===null}function kt(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 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||{}),N=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Ae=class extends N{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Le=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 N{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 I(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Nt={log:I("log"),warn:I("warn"),info:I("info"),error:I("error"),debug:I("debug")};Object.assign(globalThis,{logger:Nt});var X=Symbol.for("Jolibox.canIUseMap"),Mt={};globalThis[X]||(globalThis[X]=Mt);var Pe={get config(){return globalThis[X]}};var be=Symbol.for("Jolibox.canIUseMap.native"),jt={};globalThis[be]||(globalThis[be]=jt);function se(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 l=0;l<i;l++){let a=parseInt(s[l],10)||0,d=parseInt(o[l],10)||0;if(a>d){n=1;break}else if(a<d){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var oe=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),ie=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ie||{}),qt=(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))(qt||{}),we=["name","params"],Jt=["name","type","location","target","extra","timestamp","userId"],Ft=["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 $t(e){let t=e.location?k(e.location,we):null,r=e.target?k(e.target,we):null;return k(Dt(Ct({},e),{location:t,target:r}),Jt)}function Ue(e){let t=e.events.map(n=>$t(n)),r=k(e.device,Ft);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 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 v=typeof window=="undefined",ce=()=>!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")},Vt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Gt="device_id",Ht="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Bt()),window.__joliboxLocalStorage__.getItem(e)),Wt=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe(Gt),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(Ht),Yt=e=>e.charAt(0).toUpperCase()+e.slice(1),Xt=()=>{var e;let t=new URLSearchParams(window.location.search);return Yt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},ke=e=>{if(ce())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,s=Wt(),o=zt();return`${t} (${Xt()}${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"||i==="mporia.com"||i==="pingplus.ai")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 Me(e){return`https://${Qt(e)}`}var Q=class Z{constructor(t){this.element=t,this.next=Z.Undefined,this.prev=Z.Undefined}};Q.Undefined=new Q(void 0);var u=Q,Zt=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}},er=0,b=class{constructor(e){this.value=e,this.id=er++}},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 b&&(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,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let d=new b(t);return this._listeners?this._listeners instanceof b?this._listeners=[this._listeners,d]:this._listeners.push(d):((s=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||s.call(n,this),this._listeners=d,(i=(o=this.options)==null?void 0:o.onDidFirstListener)==null||i.call(o,this)),(a=(l=this.options)==null?void 0:l.onDidAddListener)==null||a.call(l,this),this._size++,()=>{var f,g,S,ye;if(!this._disposed){if(this._listeners instanceof b)this._listeners.id===d.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(d);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 b?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 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 l=this.cachedEventQueue.get(e);if(l&&r)for(let a of l)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 Zt,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={};At(ee,{None:()=>tr,filter:()=>nr,once:()=>je,toPromise:()=>rr});var tr=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function rr(e){return new Promise(t=>je(e)(t))}function je(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function nr(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 Y=Symbol.for("Jolibox.hostEmitter"),sr=()=>{let e=new le;return globalThis[Y]||(globalThis[Y]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Y]},_=sr();function or(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ir(e[n],t[n])}function ir(e,t){if(ne(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(kt(t)){try{if(e instanceof t)return}catch(r){}if(!Ot(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var K=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return or(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=Te([De],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=Pt(3e4)),this._starActivation}executeCommand(e,...t){return Lt(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([De],te);var qe=Symbol.for("Jolibox.commands");function ar(){return typeof globalThis!="undefined"?globalThis[qe]:void 0}function cr(e){typeof globalThis!="undefined"&&(globalThis[qe]=e)}function p(e=!1){let t=ar();if(!e&&t)return t;let r=new K,n=new te,s={registerCommand(o,i,l){r.registerCommand({id:o,handler:i,metadata:l})},executeCommand(o,...i){return n.executeCommand(o,...i)},excuteCommandSync(o,...i){return n.executeCommandThowErr(o,...i)}};return cr(s),s}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function lr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function dr(){return{platform:1e3,os:"h5",appVersion:"1.3.8",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.3.8",extra:{}}}var ur=()=>{var t;return Me((t=j)!=null?t:!1)},mr=ur(),Fe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Je;(Je=AbortSignal.timeout)!=null||(AbortSignal.timeout=Fe);var pr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},hr=pr(),fr=e=>c(void 0,null,function*(){try{let r=`${mr}/report`,n=ke("1.3.8"),s=hr,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:Fe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function R(e){return c(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:lr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=dr(),s={protocolVersion:"1.0.0",events:[t],device:r,project:ie.WebSDK},o=Ue(s);yield fr(o)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",C.startTime));var gr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},C=gr(),$e=p(),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 N?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};$e.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=de;window.addEventListener("unhandledrejection",de.bind(void 0));window.addEventListener("error",de.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()};$e.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(o)}}).catch(i=>{R({err:JSON.stringify(o)})})};var ue=e=>{var l,a,d;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]=[(l=n[0])!=null?l:"0",(a=n[1])!=null?a:"0",(d=n[2])!=null?d:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},D=e=>parseInt(ue(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=ue(e),{major:i,minor:l,patch:a,prerelease:d}=ue(t);return r!==i?r>i?1:-1:n!==l?n>l?1:-1:s!==a?s>a?1:-1:o&&!d?-1:!o&&d?1:o&&d?o>d?1:o<d?-1:0:0};var Be=p(),q=(e,t)=>{Be.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},x=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ae();var He="jolibox-sdk-loadermeta",Ge,L=JSON.parse((Ge=window.__joliboxLocalStorage__.getItem(He))!=null?Ge:"{}"),me=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Er(){return c(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:me});if(s){let{bootstrap_version:i}=L;i&&A(i,s)>=0||(o=U(P({},o),{bootstrap_version:s}))}if(n){let{implement_version:i}=L;i&&A(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 We=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,s=e.implementUrl;function o(){let{bootstrap_version:a,timestamp:d}=L;a&&d&&!Ve(me,d)&&D(a)==t&&A(a,r)>=0&&(n=pe(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 Le(`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:d,type:f}=(g=o())!=null?g:{};if(d){let S=document.createElement("script");S.type="text/javascript",S.innerHTML=d,document.head.appendChild(S),x("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:d,timestamp:f}=L;d&&f&&!Ve(me,f)&&D(d)==t&&A(d,r)>=0&&(s=he(d));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(),l(),Er()}catch(a){let d=new T(`module evaluate error: ${a}`);R({err:`${d}`})}}};var ze=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>c(this,null,function*(){try{let l=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(l),d=yield import(a);return URL.revokeObjectURL(a),d}catch(l){y(new T(`implement module evaluate error in native:${l} `))}}))(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 l=Date.now(),a=r(t.implementUrl);n(a),x("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new T(`module load failed ${s}`))}}};var Sr="1.3.8",J=Sr,Ze=D(J),et=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),yr=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,fe="https://jsdelivr.jolibox.com";var Ye=window.document.currentScript;Ye&&(fe=new URL(Ye.src).origin);var pe=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,he=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/implement@${e}/dist/index.js`,vr=e=>/^\d+\.\d+\.\d+$/.test(e),tt=vr(J)?Ze:J,Xe=pe(tt),Qe=he(tt);function _r(){et?ze(yr,{bootstrapUrl:Xe,implementUrl:Qe})():We({bootstrapUrl:Xe,implementUrl:Qe,currentMajorVersion:Ze,currentVersion:J})()}_r();var Rr=p();function rt(){return Rr.excuteCommandSync("API.getSystemInfoSync")}function nt(e,t){var r;return(r=Pe.config[e])==null?void 0:r[t]}function st(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 it="1.3.8";function h(e){let[t,...r]=e.split(":"),n=nt(ce()?"native":"h5",t);if(!n)return!1;let s=n.version;return typeof s!="string"||se(it,s,"<")?!1:r.length===0?!0:ot(n,r)||ot(n.properties,r)}function ot(e,t){if(!e)return!1;let r=st(e,t);return r?Ce(r)?!0:ne(r)?se(it,r,">="):!1:!1}var at=p();function ct(){return c(this,null,function*(){return h("login")?yield at.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function lt(){return c(this,null,function*(){return h("checkSession")?yield at.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var xr=p();function dt(e){return c(this,null,function*(){return h("request")?yield xr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ge=["onI18nChanged","onBackPress"],ut=(e,t)=>{if(!ge.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},mt=(e,t)=>{if(!ge.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},pt=(e,t)=>{if(!ge.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var Ir=p();function ht(e){return c(this,null,function*(){return h("isNativeSupport")?yield Ir.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var br=p();function ft(e){return c(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 wr=p();function gt(e){return c(this,null,function*(){return h("track")?yield wr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var m=class{constructor(){this.commands=p();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 h(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var Ee=class extends m{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)};this.gameTTI=()=>{let r=new CustomEvent("JOLIBOX_RUNTIME_GAME_TTI",{});window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.gameTTIEvent")}}},Et=window.JoliboxRuntime||Ee;var Tr="LifecycleSDK.onReady",F=class extends m{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Tr,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 m{getItem(t){return c(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return c(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 c(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var B=class extends m{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 c(this,null,function*(){})}};var V=class extends m{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 m{onLevelFinished(t){return c(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,l=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(l)return Promise.resolve(l);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 c(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 l=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(l),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:s,variation:o})})}onLevelUpgrade(t){return c(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 Cr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],H=class extends m{openSchema(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return c(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Cr.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 m{constructor(){super()}purchaseGem(t){return c(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 c(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}getSubscriptionPlans(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getSubscriptionPlans");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getSubscriptionPlans")})}subscribe(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.subscribe");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.subscribe",{productId:t.productId})})}flushSubInfoCache(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.flushSubInfoCache");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.flushSubInfoCache")})}};var z=class extends m{constructor(){super()}getCoinDetails(r){return c(this,arguments,function*({onUpdate:t}){let n=this.canIUseIfThrow("rewards.getCoinDetails");return(n==null?void 0:n.code)==="FAILURE"?n:yield this.commands.executeCommand("RewardsSDK.getCoinDetails",t)})}createRewardsAdsManager(){let t=this.canIUseIfThrow("rewards.createRewardsAdsManager");return(t==null?void 0:t.code)==="FAILURE"?t:this.commands.executeCommand("Rewards.createRewardsAdsManager")}};var E=class E{constructor(){this.jssdkVersion="1.3.8";this.runtime=new Et;this.ads=new B;this.lifecycle=new F;this.storage=new $;this.keyboard=new V;this.task=new G;this.router=new H;this.payment=new W;this.rewards=new z;this.getSystemInfoSync=rt.bind(this);this.canIUse=h.bind(this);this.login=ct.bind(this);this.checkSession=lt.bind(this);this.request=dt.bind(this);this.on=ut.bind(this);this.off=mt.bind(this);this.once=pt.bind(this);this.isNativeSupport=ht.bind(this);this.callHostMethod=ft.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 Se=E;window.JoliboxSDK=Se;})();
1
+ "use strict";(()=>{var St=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable;var Re=(e,t,r)=>t in e?St(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&Re(e,r,t[r]);if(_e)for(var r of _e(t))Rt.call(t,r)&&Re(e,r,t[r]);return e},U=(e,t)=>yt(e,vt(t));var c=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(d){s(d)}},i=a=>{try{l(r.throw(a))}catch(d){s(d)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 re=Object.defineProperty,It=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyDescriptors,Ie=Object.getOwnPropertySymbols,wt=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ct=(e,t)=>{for(var r in t||(t={}))wt.call(t,r)&&be(e,r,t[r]);if(Ie)for(var r of Ie(t))Tt.call(t,r)&&be(e,r,t[r]);return e},Dt=(e,t)=>It(e,xt(t)),At=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},Te=(e,t,r,n)=>{for(var s=n>1?void 0:n?bt(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&&re(t,r,s),s},Lt=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(d){s(d)}},i=a=>{try{l(r.throw(a))}catch(d){s(d)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 Pt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ne(e){return typeof e=="string"}function Ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Ut(e){return typeof e=="undefined"}function Ot(e){return Ut(e)||e===null}function kt(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 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||{}),N=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Ae=class extends N{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Le=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 N{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 X=Symbol.for("Jolibox.canIUseMap"),Mt={};globalThis[X]||(globalThis[X]=Mt);var Pe={get config(){return globalThis[X]}};var xe=Symbol.for("Jolibox.canIUseMap.native"),jt={};globalThis[xe]||(globalThis[xe]=jt);function se(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 l=0;l<i;l++){let a=parseInt(s[l],10)||0,d=parseInt(o[l],10)||0;if(a>d){n=1;break}else if(a<d){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var oe=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),ie=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ie||{}),qt=(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))(qt||{}),we=["name","params"],Ft=["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 $t(e){let t=e.location?k(e.location,we):null,r=e.target?k(e.target,we):null;return k(Dt(Ct({},e),{location:t,target:r}),Ft)}function Ue(e){let t=e.events.map(n=>$t(n)),r=k(e.device,Jt);return[e.protocolVersion,t,r,e.project]}var Vt=()=>"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 v=typeof window=="undefined",ce=()=>!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",Gt="device_id",Ht="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Vt()),window.__joliboxLocalStorage__.getItem(e)),Wt=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe(Gt),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(Ht),Yt=e=>e.charAt(0).toUpperCase()+e.slice(1),Xt=()=>{var e;let t=new URLSearchParams(window.location.search);return Yt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},ke=e=>{if(ce())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Bt(),n=navigator.language,s=Wt(),o=zt();return`${t} (${Xt()}${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"||i==="mporia.com"||i==="pingplus.ai")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 Me(e){return`https://${Qt(e)}`}var Q=class Z{constructor(t){this.element=t,this.next=Z.Undefined,this.prev=Z.Undefined}};Q.Undefined=new Q(void 0);var u=Q,Zt=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}},er=0,x=class{constructor(e){this.value=e,this.id=er++}},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 x&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,s,o,i,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let d=new x(t);return this._listeners?this._listeners instanceof x?this._listeners=[this._listeners,d]:this._listeners.push(d):((s=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||s.call(n,this),this._listeners=d,(i=(o=this.options)==null?void 0:o.onDidFirstListener)==null||i.call(o,this)),(a=(l=this.options)==null?void 0:l.onDidAddListener)==null||a.call(l,this),this._size++,()=>{var f,g,S,ye;if(!this._disposed){if(this._listeners instanceof x)this._listeners.id===d.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(d);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 x?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 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 l=this.cachedEventQueue.get(e);if(l&&r)for(let a of l)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 Zt,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={};At(ee,{None:()=>tr,filter:()=>nr,once:()=>je,toPromise:()=>rr});var tr=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function rr(e){return new Promise(t=>je(e)(t))}function je(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function nr(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 Y=Symbol.for("Jolibox.hostEmitter"),sr=()=>{let e=new le;return globalThis[Y]||(globalThis[Y]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Y]},_=sr();function or(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ir(e[n],t[n])}function ir(e,t){if(ne(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(kt(t)){try{if(e instanceof t)return}catch(r){}if(!Ot(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var K=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return or(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=Te([De],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=Pt(3e4)),this._starActivation}executeCommand(e,...t){return Lt(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([De],te);var qe=Symbol.for("Jolibox.commands");function ar(){return typeof globalThis!="undefined"?globalThis[qe]:void 0}function cr(e){typeof globalThis!="undefined"&&(globalThis[qe]=e)}function p(e=!1){let t=ar();if(!e&&t)return t;let r=new K,n=new te,s={registerCommand(o,i,l){r.registerCommand({id:o,handler:i,metadata:l})},executeCommand(o,...i){return n.executeCommand(o,...i)},excuteCommandSync(o,...i){return n.executeCommandThowErr(o,...i)}};return cr(s),s}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function lr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function dr(){return{platform:1e3,os:"h5",appVersion:"1.4.0",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.4.0",extra:{}}}var ur=()=>{var t;return Me((t=j)!=null?t:!1)},mr=ur(),Je=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Fe;(Fe=AbortSignal.timeout)!=null||(AbortSignal.timeout=Je);var pr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},hr=pr(),fr=e=>c(void 0,null,function*(){try{let r=`${mr}/report`,n=ke("1.4.0"),s=hr,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 c(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:lr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=dr(),s={protocolVersion:"1.0.0",events:[t],device:r,project:ie.WebSDK},o=Ue(s);yield fr(o)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",C.startTime));var gr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},C=gr(),$e=p(),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 N?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};$e.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=de;window.addEventListener("unhandledrejection",de.bind(void 0));window.addEventListener("error",de.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()};$e.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(o)}}).catch(i=>{R({err:JSON.stringify(o)})})};var ue=e=>{var l,a,d;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]=[(l=n[0])!=null?l:"0",(a=n[1])!=null?a:"0",(d=n[2])!=null?d:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},D=e=>parseInt(ue(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=ue(e),{major:i,minor:l,patch:a,prerelease:d}=ue(t);return r!==i?r>i?1:-1:n!==l?n>l?1:-1:s!==a?s>a?1:-1:o&&!d?-1:!o&&d?1:o&&d?o>d?1:o<d?-1:0:0};var Ve=p(),q=(e,t)=>{Ve.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},I=(e,t,r)=>{Ve.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ae();var He="jolibox-sdk-loadermeta",Ge,L=JSON.parse((Ge=window.__joliboxLocalStorage__.getItem(He))!=null?Ge:"{}"),me=Date.now(),Be=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Er(){return c(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:me});if(s){let{bootstrap_version:i}=L;i&&A(i,s)>=0||(o=U(P({},o),{bootstrap_version:s}))}if(n){let{implement_version:i}=L;i&&A(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 We=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,s=e.implementUrl;function o(){let{bootstrap_version:a,timestamp:d}=L;a&&d&&!Be(me,d)&&D(a)==t&&A(a,r)>=0&&(n=pe(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 Le(`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:d,type:f}=(g=o())!=null?g:{};if(d){let S=document.createElement("script");S.type="text/javascript",S.innerHTML=d,document.head.appendChild(S),I("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:d,timestamp:f}=L;d&&f&&!Be(me,f)&&D(d)==t&&A(d,r)>=0&&(s=he(d));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=s,g.onload=()=>{I("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),l(),Er()}catch(a){let d=new T(`module evaluate error: ${a}`);R({err:`${d}`})}}};var ze=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>c(this,null,function*(){try{let l=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(l),d=yield import(a);return URL.revokeObjectURL(a),d}catch(l){y(new T(`implement module evaluate error in native:${l} `))}}))(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),I("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let l=Date.now(),a=r(t.implementUrl);n(a),I("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new T(`module load failed ${s}`))}}};var Sr="1.4.0",F=Sr,Ze=D(F),et=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),yr=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,fe="https://jsdelivr.jolibox.com";var Ye=window.document.currentScript;Ye&&(fe=new URL(Ye.src).origin);var pe=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,he=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/implement@${e}/dist/index.js`,vr=e=>/^\d+\.\d+\.\d+$/.test(e),tt=vr(F)?Ze:F,Xe=pe(tt),Qe=he(tt);function _r(){et?ze(yr,{bootstrapUrl:Xe,implementUrl:Qe})():We({bootstrapUrl:Xe,implementUrl:Qe,currentMajorVersion:Ze,currentVersion:F})()}_r();var Rr=p();function rt(){return Rr.excuteCommandSync("API.getSystemInfoSync")}function nt(e,t){var r;return(r=Pe.config[e])==null?void 0:r[t]}function st(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 it="1.4.0";function h(e){let[t,...r]=e.split(":"),n=nt(ce()?"native":"h5",t);if(!n)return!1;let s=n.version;return typeof s!="string"||se(it,s,"<")?!1:r.length===0?!0:ot(n,r)||ot(n.properties,r)}function ot(e,t){if(!e)return!1;let r=st(e,t);return r?Ce(r)?!0:ne(r)?se(it,r,">="):!1:!1}var at=p();function ct(){return c(this,null,function*(){return h("login")?yield at.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function lt(){return c(this,null,function*(){return h("checkSession")?yield at.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Ir=p();function dt(e){return c(this,null,function*(){return h("request")?yield Ir.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ge=["onI18nChanged","onBackPress"],ut=(e,t)=>{if(!ge.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},mt=(e,t)=>{if(!ge.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},pt=(e,t)=>{if(!ge.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var br=p();function ht(e){return c(this,null,function*(){return h("isNativeSupport")?yield br.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var xr=p();function ft(e){return c(this,null,function*(){return h("callHostMethod")?yield xr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var wr=p();function gt(e){return c(this,null,function*(){return h("track")?yield wr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var m=class{constructor(){this.commands=p();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 h(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var Ee=class extends m{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)};this.gameTTI=()=>{let r=new CustomEvent("JOLIBOX_RUNTIME_GAME_TTI",{});window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.gameTTIEvent")}}},Et=window.JoliboxRuntime||Ee;var Tr="LifecycleSDK.onReady",J=class extends m{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Tr,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 m{getItem(t){return c(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return c(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 c(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var V=class extends m{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 c(this,null,function*(){})}};var B=class extends m{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 m{onLevelFinished(t){return c(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,l=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(l)return Promise.resolve(l);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 c(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 l=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(l),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:s,variation:o})})}onLevelUpgrade(t){return c(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})})}onLevelStart(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r}=t,n=this.canIUseIfThrow("TaskTrackerSDK.onLevelStart");if(n)return Promise.resolve(n);let s=new CustomEvent("JOLIBOX_LEVEL_START_EVENT",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelStart",{levelId:r})})}onLevelFailed(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,score:n,rating:s,duration:o}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onLevelFailed");if(i)return Promise.resolve(i);let l=new CustomEvent("JOLIBOX_LEVEL_FAIL_EVENT",{detail:t});return window.dispatchEvent(l),yield this.commands.executeCommand("TaskTrackerSDK.levelFailed",{levelId:r,score:n,rating:s,duration:o})})}};var Cr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],H=class extends m{openSchema(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return c(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Cr.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 m{constructor(){super()}purchaseGem(t){return c(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 c(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}getSubscriptionPlans(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getSubscriptionPlans");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getSubscriptionPlans")})}subscribe(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.subscribe");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.subscribe",{productId:t.productId,appStoreProductId:t.appStoreProductId})})}subscribeSpin(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.subscribeSpin");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.subscribeSpin",{productId:t.productId,appStoreProductId:t.appStoreProductId})})}flushSubInfoCache(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.flushSubInfoCache");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.flushSubInfoCache")})}};var z=class extends m{constructor(){super()}getCoinDetails(r){return c(this,arguments,function*({onUpdate:t}){let n=this.canIUseIfThrow("rewards.getCoinDetails");return(n==null?void 0:n.code)==="FAILURE"?n:yield this.commands.executeCommand("RewardsSDK.getCoinDetails",t)})}createRewardsAdsManager(){let t=this.canIUseIfThrow("rewards.createRewardsAdsManager");return(t==null?void 0:t.code)==="FAILURE"?t:this.commands.executeCommand("Rewards.createRewardsAdsManager")}};var E=class E{constructor(){this.jssdkVersion="1.4.0";this.runtime=new Et;this.ads=new V;this.lifecycle=new J;this.storage=new $;this.keyboard=new B;this.task=new G;this.router=new H;this.payment=new W;this.rewards=new z;this.getSystemInfoSync=rt.bind(this);this.canIUse=h.bind(this);this.login=ct.bind(this);this.checkSession=lt.bind(this);this.request=dt.bind(this);this.on=ut.bind(this);this.off=mt.bind(this);this.once=pt.bind(this);this.isNativeSupport=ht.bind(this);this.callHostMethod=ft.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 Se=E;window.JoliboxSDK=Se;})();
package/dist/index.js CHANGED
@@ -1708,6 +1708,75 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
1708
1708
  name
1709
1709
  });
1710
1710
  }
1711
+ /**
1712
+ * Tracks when a game level starts
1713
+ *
1714
+ * @param params - Object containing level start details:
1715
+ * @param params.levelId - Unique identifier for the level being started (string or number)
1716
+ * @returns Promise resolving to TaskResponse or error message if validation fails
1717
+ * @throws {Promise} Rejects with error if params is not an object
1718
+ */
1719
+ async onLevelStart(params) {
1720
+ if (typeof params !== "object") {
1721
+ return Promise.reject({
1722
+ code: "FAILURE",
1723
+ message: "params must be an object"
1724
+ });
1725
+ }
1726
+ const {
1727
+ levelId
1728
+ } = params;
1729
+ const errMsg = this.canIUseIfThrow("TaskTrackerSDK.onLevelStart");
1730
+ if (errMsg) {
1731
+ return Promise.resolve(errMsg);
1732
+ }
1733
+ const event = new CustomEvent("JOLIBOX_LEVEL_START_EVENT" /* LEVEL_START */, {
1734
+ detail: params
1735
+ });
1736
+ window.dispatchEvent(event);
1737
+ return await this.commands.executeCommand("TaskTrackerSDK.levelStart", {
1738
+ levelId
1739
+ });
1740
+ }
1741
+ /**
1742
+ * Tracks when a game level fails
1743
+ *
1744
+ * @param params - Object containing level failure details:
1745
+ * @param params.levelId - Unique identifier for the failed level (string or number)
1746
+ * @param params.score - Optional total score achieved in the level
1747
+ * @param params.rating - Optional star rating (how many stars earned)
1748
+ * @param params.duration - Optional time spent in the level (milliseconds)
1749
+ * @returns Promise resolving to TaskResponse or error message if validation fails
1750
+ * @throws {Promise} Rejects with error if params is not an object
1751
+ */
1752
+ async onLevelFailed(params) {
1753
+ if (typeof params !== "object") {
1754
+ return Promise.reject({
1755
+ code: "FAILURE",
1756
+ message: "params must be an object"
1757
+ });
1758
+ }
1759
+ const {
1760
+ levelId,
1761
+ score,
1762
+ rating,
1763
+ duration
1764
+ } = params;
1765
+ const errMsg = this.canIUseIfThrow("TaskTrackerSDK.onLevelFailed");
1766
+ if (errMsg) {
1767
+ return Promise.resolve(errMsg);
1768
+ }
1769
+ const event = new CustomEvent("JOLIBOX_LEVEL_FAIL_EVENT" /* LEVEL_FAILED */, {
1770
+ detail: params
1771
+ });
1772
+ window.dispatchEvent(event);
1773
+ return await this.commands.executeCommand("TaskTrackerSDK.levelFailed", {
1774
+ levelId,
1775
+ score,
1776
+ rating,
1777
+ duration
1778
+ });
1779
+ }
1711
1780
  };
1712
1781
 
1713
1782
  // src/sdks/router.ts
@@ -1824,7 +1893,18 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
1824
1893
  return canIUseResult;
1825
1894
  }
1826
1895
  return await this.commands.executeCommand("PaymentSDK.subscribe", {
1827
- productId: params.productId
1896
+ productId: params.productId,
1897
+ appStoreProductId: params.appStoreProductId
1898
+ });
1899
+ }
1900
+ async subscribeSpin(params) {
1901
+ const canIUseResult = this.canIUseIfThrow("payment.subscribeSpin");
1902
+ if (canIUseResult?.code === "FAILURE") {
1903
+ return canIUseResult;
1904
+ }
1905
+ return await this.commands.executeCommand("PaymentSDK.subscribeSpin", {
1906
+ productId: params.productId,
1907
+ appStoreProductId: params.appStoreProductId
1828
1908
  });
1829
1909
  }
1830
1910
  async flushSubInfoCache() {
@@ -18,6 +18,14 @@ export declare class PaymentSDK extends BaseSDK implements Payment {
18
18
  }>;
19
19
  subscribe(params: {
20
20
  productId: string;
21
+ appStoreProductId?: string;
22
+ }): Promise<{
23
+ code: ResponseType;
24
+ message: string;
25
+ }>;
26
+ subscribeSpin(params: {
27
+ productId: string;
28
+ appStoreProductId?: string;
21
29
  }): Promise<{
22
30
  code: ResponseType;
23
31
  message: string;
@@ -3,7 +3,9 @@ import { TaskTracker, TaskResponse } from '@jolibox/types';
3
3
  export declare enum JoliboxTaskEvents {
4
4
  LEVEL_FINISHED = "JOLIBOX_TASK_LEVEL_FINISHED",
5
5
  GAME_PLAY_ENDED = "JOLIBOX_TASK_GAME_PLAY_ENDED",
6
- LEVEL_UPGRADE = "JOLIBOX_TASK_LEVEL_UPGRADE"
6
+ LEVEL_UPGRADE = "JOLIBOX_TASK_LEVEL_UPGRADE",
7
+ LEVEL_START = "JOLIBOX_LEVEL_START_EVENT",
8
+ LEVEL_FAILED = "JOLIBOX_LEVEL_FAIL_EVENT"
7
9
  }
8
10
  /**
9
11
  * @public
@@ -61,4 +63,32 @@ export declare class TaskTrackerSDK extends BaseSDK implements TaskTracker {
61
63
  levelId: string | number;
62
64
  name?: string;
63
65
  }): Promise<TaskResponse>;
66
+ /**
67
+ * Tracks when a game level starts
68
+ *
69
+ * @param params - Object containing level start details:
70
+ * @param params.levelId - Unique identifier for the level being started (string or number)
71
+ * @returns Promise resolving to TaskResponse or error message if validation fails
72
+ * @throws {Promise} Rejects with error if params is not an object
73
+ */
74
+ onLevelStart(params: {
75
+ levelId: string | number;
76
+ }): Promise<TaskResponse>;
77
+ /**
78
+ * Tracks when a game level fails
79
+ *
80
+ * @param params - Object containing level failure details:
81
+ * @param params.levelId - Unique identifier for the failed level (string or number)
82
+ * @param params.score - Optional total score achieved in the level
83
+ * @param params.rating - Optional star rating (how many stars earned)
84
+ * @param params.duration - Optional time spent in the level (milliseconds)
85
+ * @returns Promise resolving to TaskResponse or error message if validation fails
86
+ * @throws {Promise} Rejects with error if params is not an object
87
+ */
88
+ onLevelFailed(params: {
89
+ levelId: string | number;
90
+ score?: number;
91
+ rating?: number;
92
+ duration?: number;
93
+ }): Promise<TaskResponse>;
64
94
  }
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@jolibox/sdk",
3
3
  "description": "This project is common Jolibox JS-SDk interfere",
4
- "version": "1.3.8",
4
+ "version": "1.4.0",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "typings": "dist/index.d.ts",
8
8
  "license": "MIT",
9
9
  "dependencies": {
10
- "@jolibox/common": "1.3.8",
11
- "@jolibox/types": "1.3.8"
10
+ "@jolibox/common": "1.4.0",
11
+ "@jolibox/types": "1.4.0"
12
12
  },
13
13
  "devDependencies": {
14
14
  "typescript": "5.7.3",
package/sdk.build.log CHANGED
@@ -1,17 +1,17 @@
1
1
  Invoking: npm run clean && npm run build:cjs && npm run build:esm && npm run build:iife && tsc
2
2
 
3
- > @jolibox/sdk@1.3.8 clean
3
+ > @jolibox/sdk@1.4.0 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/sdk@1.3.8 build:cjs
7
+ > @jolibox/sdk@1.4.0 build:cjs
8
8
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=cjs
9
9
 
10
10
 
11
- > @jolibox/sdk@1.3.8 build:esm
11
+ > @jolibox/sdk@1.4.0 build:esm
12
12
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
13
13
 
14
14
 
15
- > @jolibox/sdk@1.3.8 build:iife
15
+ > @jolibox/sdk@1.4.0 build:iife
16
16
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
17
17
 
@@ -30,13 +30,25 @@ export class PaymentSDK extends BaseSDK implements Payment {
30
30
  return await this.commands.executeCommand('PaymentSDK.getSubscriptionPlans');
31
31
  }
32
32
 
33
- async subscribe(params: { productId: string }) {
33
+ async subscribe(params: { productId: string; appStoreProductId?: string }) {
34
34
  const canIUseResult = this.canIUseIfThrow('payment.subscribe');
35
35
  if (canIUseResult?.code === 'FAILURE') {
36
36
  return canIUseResult;
37
37
  }
38
38
  return await this.commands.executeCommand('PaymentSDK.subscribe', {
39
- productId: params.productId
39
+ productId: params.productId,
40
+ appStoreProductId: params.appStoreProductId
41
+ });
42
+ }
43
+
44
+ async subscribeSpin(params: { productId: string; appStoreProductId?: string }) {
45
+ const canIUseResult = this.canIUseIfThrow('payment.subscribeSpin');
46
+ if (canIUseResult?.code === 'FAILURE') {
47
+ return canIUseResult;
48
+ }
49
+ return await this.commands.executeCommand('PaymentSDK.subscribeSpin', {
50
+ productId: params.productId,
51
+ appStoreProductId: params.appStoreProductId
40
52
  });
41
53
  }
42
54
 
package/src/sdks/task.ts CHANGED
@@ -4,7 +4,9 @@ import { TaskTracker, TaskResponse, type ResponseType } from '@jolibox/types';
4
4
  export enum JoliboxTaskEvents {
5
5
  LEVEL_FINISHED = 'JOLIBOX_TASK_LEVEL_FINISHED',
6
6
  GAME_PLAY_ENDED = 'JOLIBOX_TASK_GAME_PLAY_ENDED',
7
- LEVEL_UPGRADE = 'JOLIBOX_TASK_LEVEL_UPGRADE'
7
+ LEVEL_UPGRADE = 'JOLIBOX_TASK_LEVEL_UPGRADE',
8
+ LEVEL_START = 'JOLIBOX_LEVEL_START_EVENT',
9
+ LEVEL_FAILED = 'JOLIBOX_LEVEL_FAIL_EVENT'
8
10
  }
9
11
 
10
12
  /**
@@ -112,4 +114,63 @@ export class TaskTrackerSDK extends BaseSDK implements TaskTracker {
112
114
  name
113
115
  });
114
116
  }
117
+
118
+ /**
119
+ * Tracks when a game level starts
120
+ *
121
+ * @param params - Object containing level start details:
122
+ * @param params.levelId - Unique identifier for the level being started (string or number)
123
+ * @returns Promise resolving to TaskResponse or error message if validation fails
124
+ * @throws {Promise} Rejects with error if params is not an object
125
+ */
126
+ async onLevelStart(params: { levelId: string | number }): Promise<TaskResponse> {
127
+ if (typeof params !== 'object') {
128
+ return Promise.reject({ code: 'FAILURE' as ResponseType, message: 'params must be an object' });
129
+ }
130
+ const { levelId } = params;
131
+ const errMsg = this.canIUseIfThrow('TaskTrackerSDK.onLevelStart');
132
+ if (errMsg) {
133
+ return Promise.resolve(errMsg);
134
+ }
135
+ const event = new CustomEvent(JoliboxTaskEvents.LEVEL_START, { detail: params });
136
+ window.dispatchEvent(event);
137
+ return await this.commands.executeCommand('TaskTrackerSDK.levelStart', {
138
+ levelId
139
+ });
140
+ }
141
+
142
+ /**
143
+ * Tracks when a game level fails
144
+ *
145
+ * @param params - Object containing level failure details:
146
+ * @param params.levelId - Unique identifier for the failed level (string or number)
147
+ * @param params.score - Optional total score achieved in the level
148
+ * @param params.rating - Optional star rating (how many stars earned)
149
+ * @param params.duration - Optional time spent in the level (milliseconds)
150
+ * @returns Promise resolving to TaskResponse or error message if validation fails
151
+ * @throws {Promise} Rejects with error if params is not an object
152
+ */
153
+ async onLevelFailed(params: {
154
+ levelId: string | number;
155
+ score?: number;
156
+ rating?: number;
157
+ duration?: number;
158
+ }): Promise<TaskResponse> {
159
+ if (typeof params !== 'object') {
160
+ return Promise.reject({ code: 'FAILURE' as ResponseType, message: 'params must be an object' });
161
+ }
162
+ const { levelId, score, rating, duration } = params;
163
+ const errMsg = this.canIUseIfThrow('TaskTrackerSDK.onLevelFailed');
164
+ if (errMsg) {
165
+ return Promise.resolve(errMsg);
166
+ }
167
+ const event = new CustomEvent(JoliboxTaskEvents.LEVEL_FAILED, { detail: params });
168
+ window.dispatchEvent(event);
169
+ return await this.commands.executeCommand('TaskTrackerSDK.levelFailed', {
170
+ levelId,
171
+ score,
172
+ rating,
173
+ duration
174
+ });
175
+ }
115
176
  }