@jolibox/sdk 1.3.5-beta.10 → 1.3.5-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/package-deps_build.json +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +1 -1
- package/package.json +3 -3
- package/sdk.build.log +4 -4
|
@@ -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": "
|
|
7
|
+
"packages/sdk/package.json": "c3bf22a16625305789e02eabb635c4adca95e7a9",
|
|
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",
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var P=Object.defineProperty,vt=Object.defineProperties,Rt=Object.getOwnPropertyDescriptor,_t=Object.getOwnPropertyDescriptors,bt=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols;var xe=Object.prototype.hasOwnProperty,xt=Object.prototype.propertyIsEnumerable;var be=(e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))xe.call(t,r)&&be(e,r,t[r]);if(_e)for(var r of _e(t))xt.call(t,r)&&be(e,r,t[r]);return e},O=(e,t)=>vt(e,_t(t));var It=(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 bt(t))!xe.call(e,s)&&s!==r&&P(e,s,{get:()=>t[s],enumerable:!(n=Rt(t,s))||n.enumerable});return e};var Ct=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={};It(Or,{JoliboxSDK:()=>Q});module.exports=Ct(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,Dt=Object.defineProperties,Tt=Object.getOwnPropertyDescriptor,At=Object.getOwnPropertyDescriptors,Ie=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(Ie)for(var r of Ie(t))Pt.call(t,r)&&we(e,r,t[r]);return e},Ot=(e,t)=>Dt(e,At(t)),kt=(e,t)=>{for(var r in t)se(e,r,{get:t[r],enumerable:!0})},Te=(e,t,r,n)=>{for(var s=n>1?void 0:n?Tt(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"}},C=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 x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Ft={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("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 Ce=Symbol.for("Jolibox.canIUseMap.native"),Bt={};globalThis[Ce]||(globalThis[Ce]=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||{}),De=["name","params"],Ht=["name","type","location","target","extra","timestamp","userId"],Gt=["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,De):null,r=e.target?K(e.target,De):null;return K(Ot(Ut({},e),{location:t,target:r}),Ht)}function ke(e){let t=e.events.map(n=>Wt(n)),r=K(e.device,Gt);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",Qt="device_id",Xt="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(Qt),er=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ke(Xt),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,I=class{constructor(e){this.value=e,this.id=or++}},w=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,s,o,i,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let d=new I(t);return this._listeners?this._listeners instanceof I?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,E,ve;if(!this._disposed){if(this._listeners instanceof I)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 Re=this._listeners.indexOf(d);Re>=0&&(this._listeners.splice(Re,1),this._size--,this._size===0&&((ve=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ve.call(E)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(s){n(s)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},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 X=Symbol.for("Jolibox.hostEmitter"),lr=()=>{let e=new ue;return globalThis[X]||(globalThis[X]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[X]},R=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=Te([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=Te([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.5-beta.10",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.3.5-beta.10",extra:{}}}var gr=()=>{var t;return qe((t=q)!=null?t:!1)},Sr=gr(),Be=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},$e;($e=AbortSignal.timeout)!=null||(AbortSignal.timeout=Be);var Er=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},yr=Er(),vr=e=>c(void 0,null,function*(){try{let r=`${Sr}/report`,n=Ne("1.3.5-beta.10"),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 _(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",()=>R.emit("onDocumentReady",D.startTime));var Rr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},D=Rr(),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)}`),_({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=>{_({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}},T=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 He=p(),J=(e,t)=>{He.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{He.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(),Ge=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function _r(){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&&!Ge(he,d)&&T(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}`);_({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),D.startTime=a;let{script:d,type:f}=(g=o())!=null?g:{};if(d){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=d,document.head.appendChild(E),b("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:d,timestamp:f}=L;d&&f&&!Ge(he,f)&&T(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=()=>{b("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),l(),_r()}catch(a){let d=new C(`module evaluate error: ${a}`);_({err:`${d}`})}}};var Qe=(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 C(`implement module evaluate error in native:${l} `))}}))(s)}return()=>{try{let s=Date.now();J("jsSdkBegin",{t:s}),D.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),b("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let l=Date.now(),a=r(t.implementUrl);n(a),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new C(`module load failed ${s}`))}}};var br="1.3.5-beta.10",F=br,tt=T(F),rt=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),xr=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,Se="https://jsdelivr.jolibox.com";var Xe=window.document.currentScript;Xe&&(Se=new URL(Xe.src).origin);var fe=(e,t)=>`${t!=null?t:Se}/npm/@jolibox/bootstrap@${e}/dist/index.js`,ge=(e,t)=>`${t!=null?t:Se}/npm/@jolibox/implement@${e}/dist/index.js`,Ir=e=>/^\d+\.\d+\.\d+$/.test(e),nt=Ir(F)?tt:F,Ze=fe(nt),et=ge(nt);function wr(){rt?Qe(xr,{bootstrapUrl:Ze,implementUrl:et})():Ye({bootstrapUrl:Ze,implementUrl:et,currentMajorVersion:tt,currentVersion:F})()}wr();var Cr=p();function st(){return Cr.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.5-beta.10";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 Dr=p();function mt(e){return c(this,null,function*(){return h("request")?yield Dr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var Ee=["onI18nChanged","onBackPress"],pt=(e,t)=>{if(!Ee.includes(e)){y(new j(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}R.on(e,t)},ht=(e,t)=>{if(!Ee.includes(e)){y(new j(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}R.off(e,t)},ft=(e,t)=>{if(!Ee.includes(e)){y(new j(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}R.once(e,t)};var Tr=p();function gt(e){return c(this,null,function*(){return h("isNativeSupport")?yield Tr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ar=p();function St(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 Et(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)}}},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 H=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 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 S=class S{constructor(){this.jssdkVersion="1.3.5-beta.10";this.runtime=new yt;this.ads=new V;this.lifecycle=new $;this.storage=new B;this.keyboard=new H;this.task=new G;this.router=new W;this.payment=new z;this.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=St.bind(this);this.track=Et.bind(this);if(S.instance)return S.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},S.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return S.instance||(S.instance=new S),S.instance}};S.instance=null;var Q=S;window.JoliboxSDK=Q;
|
|
1
|
+
"use strict";var P=Object.defineProperty,vt=Object.defineProperties,Rt=Object.getOwnPropertyDescriptor,_t=Object.getOwnPropertyDescriptors,bt=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols;var xe=Object.prototype.hasOwnProperty,xt=Object.prototype.propertyIsEnumerable;var be=(e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))xe.call(t,r)&&be(e,r,t[r]);if(_e)for(var r of _e(t))xt.call(t,r)&&be(e,r,t[r]);return e},O=(e,t)=>vt(e,_t(t));var It=(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 bt(t))!xe.call(e,s)&&s!==r&&P(e,s,{get:()=>t[s],enumerable:!(n=Rt(t,s))||n.enumerable});return e};var Ct=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={};It(Or,{JoliboxSDK:()=>Q});module.exports=Ct(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,Dt=Object.defineProperties,Tt=Object.getOwnPropertyDescriptor,At=Object.getOwnPropertyDescriptors,Ie=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(Ie)for(var r of Ie(t))Pt.call(t,r)&&we(e,r,t[r]);return e},Ot=(e,t)=>Dt(e,At(t)),kt=(e,t)=>{for(var r in t)se(e,r,{get:t[r],enumerable:!0})},Te=(e,t,r,n)=>{for(var s=n>1?void 0:n?Tt(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"}},C=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 x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Ft={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("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 Ce=Symbol.for("Jolibox.canIUseMap.native"),Bt={};globalThis[Ce]||(globalThis[Ce]=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||{}),De=["name","params"],Ht=["name","type","location","target","extra","timestamp","userId"],Gt=["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,De):null,r=e.target?K(e.target,De):null;return K(Ot(Ut({},e),{location:t,target:r}),Ht)}function ke(e){let t=e.events.map(n=>Wt(n)),r=K(e.device,Gt);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",Qt="device_id",Xt="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(Qt),er=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ke(Xt),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,I=class{constructor(e){this.value=e,this.id=or++}},w=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,s,o,i,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let d=new I(t);return this._listeners?this._listeners instanceof I?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,E,ve;if(!this._disposed){if(this._listeners instanceof I)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 Re=this._listeners.indexOf(d);Re>=0&&(this._listeners.splice(Re,1),this._size--,this._size===0&&((ve=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ve.call(E)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(s){n(s)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},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 X=Symbol.for("Jolibox.hostEmitter"),lr=()=>{let e=new ue;return globalThis[X]||(globalThis[X]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[X]},R=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=Te([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=Te([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.5-beta.11",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.3.5-beta.11",extra:{}}}var gr=()=>{var t;return qe((t=q)!=null?t:!1)},Sr=gr(),Be=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},$e;($e=AbortSignal.timeout)!=null||(AbortSignal.timeout=Be);var Er=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},yr=Er(),vr=e=>c(void 0,null,function*(){try{let r=`${Sr}/report`,n=Ne("1.3.5-beta.11"),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 _(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",()=>R.emit("onDocumentReady",D.startTime));var Rr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},D=Rr(),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)}`),_({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=>{_({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}},T=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 He=p(),J=(e,t)=>{He.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{He.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(),Ge=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function _r(){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&&!Ge(he,d)&&T(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}`);_({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),D.startTime=a;let{script:d,type:f}=(g=o())!=null?g:{};if(d){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=d,document.head.appendChild(E),b("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:d,timestamp:f}=L;d&&f&&!Ge(he,f)&&T(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=()=>{b("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),l(),_r()}catch(a){let d=new C(`module evaluate error: ${a}`);_({err:`${d}`})}}};var Qe=(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 C(`implement module evaluate error in native:${l} `))}}))(s)}return()=>{try{let s=Date.now();J("jsSdkBegin",{t:s}),D.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),b("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let l=Date.now(),a=r(t.implementUrl);n(a),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new C(`module load failed ${s}`))}}};var br="1.3.5-beta.11",F=br,tt=T(F),rt=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),xr=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,Se="https://jsdelivr.jolibox.com";var Xe=window.document.currentScript;Xe&&(Se=new URL(Xe.src).origin);var fe=(e,t)=>`${t!=null?t:Se}/npm/@jolibox/bootstrap@${e}/dist/index.js`,ge=(e,t)=>`${t!=null?t:Se}/npm/@jolibox/implement@${e}/dist/index.js`,Ir=e=>/^\d+\.\d+\.\d+$/.test(e),nt=Ir(F)?tt:F,Ze=fe(nt),et=ge(nt);function wr(){rt?Qe(xr,{bootstrapUrl:Ze,implementUrl:et})():Ye({bootstrapUrl:Ze,implementUrl:et,currentMajorVersion:tt,currentVersion:F})()}wr();var Cr=p();function st(){return Cr.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.5-beta.11";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 Dr=p();function mt(e){return c(this,null,function*(){return h("request")?yield Dr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var Ee=["onI18nChanged","onBackPress"],pt=(e,t)=>{if(!Ee.includes(e)){y(new j(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}R.on(e,t)},ht=(e,t)=>{if(!Ee.includes(e)){y(new j(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}R.off(e,t)},ft=(e,t)=>{if(!Ee.includes(e)){y(new j(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}R.once(e,t)};var Tr=p();function gt(e){return c(this,null,function*(){return h("isNativeSupport")?yield Tr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ar=p();function St(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 Et(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)}}},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 H=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 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 S=class S{constructor(){this.jssdkVersion="1.3.5-beta.11";this.runtime=new yt;this.ads=new V;this.lifecycle=new $;this.storage=new B;this.keyboard=new H;this.task=new G;this.router=new W;this.payment=new z;this.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=St.bind(this);this.track=Et.bind(this);if(S.instance)return S.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},S.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return S.instance||(S.instance=new S),S.instance}};S.instance=null;var Q=S;window.JoliboxSDK=Q;
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Et=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var Re=Object.getOwnPropertySymbols;var Rt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))Rt.call(t,r)&&_e(e,r,t[r]);if(Re)for(var r of Re(t))_t.call(t,r)&&_e(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,bt=Object.defineProperties,xt=Object.getOwnPropertyDescriptor,It=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,wt=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable,xe=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Dt=(e,t)=>{for(var r in t||(t={}))wt.call(t,r)&&xe(e,r,t[r]);if(be)for(var r of be(t))Ct.call(t,r)&&xe(e,r,t[r]);return e},Tt=(e,t)=>bt(e,It(t)),At=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},Ce=(e,t,r,n)=>{for(var s=n>1?void 0:n?xt(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&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 De(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 Te(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"}},C=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 x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Nt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Nt});var Q=Symbol.for("Jolibox.canIUseMap"),Mt={};globalThis[Q]||(globalThis[Q]=Mt);var Pe={get config(){return globalThis[Q]}};var Ie=Symbol.for("Jolibox.canIUseMap.native"),jt={};globalThis[Ie]||(globalThis[Ie]=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(Tt(Dt({},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",Ht="device_id",Gt="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(Ht),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(Gt),Yt=e=>e.charAt(0).toUpperCase()+e.slice(1),Qt=()=>{var e;let t=new URLSearchParams(window.location.search);return Yt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},ke=e=>{if(ce())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,s=Wt(),o=zt();return`${t} (${Qt()}${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 Xt(e){return Ke("collect","stg-collect",e)}function Me(e){return`https://${Xt(e)}`}var X=class Z{constructor(t){this.element=t,this.next=Z.Undefined,this.prev=Z.Undefined}};X.Undefined=new X(void 0);var u=X,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,I=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 I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,s,o,i,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let d=new I(t);return this._listeners?this._listeners instanceof I?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,E,ye;if(!this._disposed){if(this._listeners instanceof I)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=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ye.call(E)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(s){n(s)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},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]},R=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=Ce([Te],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=Ce([Te],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.5-beta.10",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.3.5-beta.10",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.5-beta.10"),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 _(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",()=>R.emit("onDocumentReady",D.startTime));var gr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},D=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)}`),_({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=>{_({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}},T=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})},b=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ae();var Ge="jolibox-sdk-loadermeta",He,L=JSON.parse((He=window.__joliboxLocalStorage__.getItem(Ge))!=null?He:"{}"),me=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Sr(){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(Ge,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)&&T(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}`);_({err:`${g}`})}}function i(){var g;let a=Date.now();q("jsSdkBegin",{t:a}),D.startTime=a;let{script:d,type:f}=(g=o())!=null?g:{};if(d){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=d,document.head.appendChild(E),b("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:d,timestamp:f}=L;d&&f&&!Ve(me,f)&&T(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=()=>{b("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),l(),Sr()}catch(a){let d=new C(`module evaluate error: ${a}`);_({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 C(`implement module evaluate error in native:${l} `))}}))(s)}return()=>{try{let s=Date.now();q("jsSdkBegin",{t:s}),D.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),b("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let l=Date.now(),a=r(t.implementUrl);n(a),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new C(`module load failed ${s}`))}}};var Er="1.3.5-beta.10",J=Er,Ze=T(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,Qe=pe(tt),Xe=he(tt);function Rr(){et?ze(yr,{bootstrapUrl:Qe,implementUrl:Xe})():We({bootstrapUrl:Qe,implementUrl:Xe,currentMajorVersion:Ze,currentVersion:J})()}Rr();var _r=p();function rt(){return _r.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.5-beta.10";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?De(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 br=p();function dt(e){return c(this,null,function*(){return h("request")?yield br.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}R.on(e,t)},mt=(e,t)=>{if(!ge.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}R.off(e,t)},pt=(e,t)=>{if(!ge.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}R.once(e,t)};var xr=p();function ht(e){return c(this,null,function*(){return h("isNativeSupport")?yield xr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ir=p();function ft(e){return c(this,null,function*(){return h("callHostMethod")?yield Ir.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 Se=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)}}},St=window.JoliboxRuntime||Se;var Cr="LifecycleSDK.onReady",F=class extends m{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Cr,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 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 Dr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],G=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||(Dr.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 S=class S{constructor(){this.jssdkVersion="1.3.5-beta.10";this.runtime=new St;this.ads=new B;this.lifecycle=new F;this.storage=new $;this.keyboard=new V;this.task=new H;this.router=new G;this.payment=new W;this.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(S.instance)return S.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},S.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return S.instance||(S.instance=new S),S.instance}};S.instance=null;var Ee=S;window.JoliboxSDK=Ee;export{Ee as JoliboxSDK};
|
|
1
|
+
var Et=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var Re=Object.getOwnPropertySymbols;var Rt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))Rt.call(t,r)&&_e(e,r,t[r]);if(Re)for(var r of Re(t))_t.call(t,r)&&_e(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,bt=Object.defineProperties,xt=Object.getOwnPropertyDescriptor,It=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,wt=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable,xe=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Dt=(e,t)=>{for(var r in t||(t={}))wt.call(t,r)&&xe(e,r,t[r]);if(be)for(var r of be(t))Ct.call(t,r)&&xe(e,r,t[r]);return e},Tt=(e,t)=>bt(e,It(t)),At=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},Ce=(e,t,r,n)=>{for(var s=n>1?void 0:n?xt(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&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 De(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 Te(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"}},C=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 x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Nt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Nt});var Q=Symbol.for("Jolibox.canIUseMap"),Mt={};globalThis[Q]||(globalThis[Q]=Mt);var Pe={get config(){return globalThis[Q]}};var Ie=Symbol.for("Jolibox.canIUseMap.native"),jt={};globalThis[Ie]||(globalThis[Ie]=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(Tt(Dt({},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",Ht="device_id",Gt="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(Ht),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(Gt),Yt=e=>e.charAt(0).toUpperCase()+e.slice(1),Qt=()=>{var e;let t=new URLSearchParams(window.location.search);return Yt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},ke=e=>{if(ce())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,s=Wt(),o=zt();return`${t} (${Qt()}${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 Xt(e){return Ke("collect","stg-collect",e)}function Me(e){return`https://${Xt(e)}`}var X=class Z{constructor(t){this.element=t,this.next=Z.Undefined,this.prev=Z.Undefined}};X.Undefined=new X(void 0);var u=X,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,I=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 I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,s,o,i,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let d=new I(t);return this._listeners?this._listeners instanceof I?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,E,ye;if(!this._disposed){if(this._listeners instanceof I)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=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ye.call(E)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(s){n(s)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},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]},R=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=Ce([Te],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=Ce([Te],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.5-beta.11",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.3.5-beta.11",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.5-beta.11"),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 _(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",()=>R.emit("onDocumentReady",D.startTime));var gr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},D=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)}`),_({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=>{_({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}},T=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})},b=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ae();var Ge="jolibox-sdk-loadermeta",He,L=JSON.parse((He=window.__joliboxLocalStorage__.getItem(Ge))!=null?He:"{}"),me=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Sr(){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(Ge,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)&&T(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}`);_({err:`${g}`})}}function i(){var g;let a=Date.now();q("jsSdkBegin",{t:a}),D.startTime=a;let{script:d,type:f}=(g=o())!=null?g:{};if(d){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=d,document.head.appendChild(E),b("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:d,timestamp:f}=L;d&&f&&!Ve(me,f)&&T(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=()=>{b("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),l(),Sr()}catch(a){let d=new C(`module evaluate error: ${a}`);_({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 C(`implement module evaluate error in native:${l} `))}}))(s)}return()=>{try{let s=Date.now();q("jsSdkBegin",{t:s}),D.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),b("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let l=Date.now(),a=r(t.implementUrl);n(a),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new C(`module load failed ${s}`))}}};var Er="1.3.5-beta.11",J=Er,Ze=T(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,Qe=pe(tt),Xe=he(tt);function Rr(){et?ze(yr,{bootstrapUrl:Qe,implementUrl:Xe})():We({bootstrapUrl:Qe,implementUrl:Xe,currentMajorVersion:Ze,currentVersion:J})()}Rr();var _r=p();function rt(){return _r.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.5-beta.11";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?De(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 br=p();function dt(e){return c(this,null,function*(){return h("request")?yield br.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}R.on(e,t)},mt=(e,t)=>{if(!ge.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}R.off(e,t)},pt=(e,t)=>{if(!ge.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}R.once(e,t)};var xr=p();function ht(e){return c(this,null,function*(){return h("isNativeSupport")?yield xr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ir=p();function ft(e){return c(this,null,function*(){return h("callHostMethod")?yield Ir.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 Se=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)}}},St=window.JoliboxRuntime||Se;var Cr="LifecycleSDK.onReady",F=class extends m{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Cr,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 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 Dr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],G=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||(Dr.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 S=class S{constructor(){this.jssdkVersion="1.3.5-beta.11";this.runtime=new St;this.ads=new B;this.lifecycle=new F;this.storage=new $;this.keyboard=new V;this.task=new H;this.router=new G;this.payment=new W;this.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(S.instance)return S.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},S.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return S.instance||(S.instance=new S),S.instance}};S.instance=null;var Ee=S;window.JoliboxSDK=Ee;export{Ee as JoliboxSDK};
|
package/dist/index.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var Et=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var Re=Object.getOwnPropertySymbols;var Rt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))Rt.call(t,r)&&_e(e,r,t[r]);if(Re)for(var r of Re(t))_t.call(t,r)&&_e(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,bt=Object.defineProperties,xt=Object.getOwnPropertyDescriptor,It=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,wt=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable,xe=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Dt=(e,t)=>{for(var r in t||(t={}))wt.call(t,r)&&xe(e,r,t[r]);if(be)for(var r of be(t))Ct.call(t,r)&&xe(e,r,t[r]);return e},Tt=(e,t)=>bt(e,It(t)),At=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},Ce=(e,t,r,n)=>{for(var s=n>1?void 0:n?xt(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&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 De(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 Te(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"}},C=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 x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Nt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Nt});var Q=Symbol.for("Jolibox.canIUseMap"),Mt={};globalThis[Q]||(globalThis[Q]=Mt);var Pe={get config(){return globalThis[Q]}};var Ie=Symbol.for("Jolibox.canIUseMap.native"),jt={};globalThis[Ie]||(globalThis[Ie]=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(Tt(Dt({},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",Ht="device_id",Gt="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(Ht),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(Gt),Yt=e=>e.charAt(0).toUpperCase()+e.slice(1),Qt=()=>{var e;let t=new URLSearchParams(window.location.search);return Yt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},ke=e=>{if(ce())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,s=Wt(),o=zt();return`${t} (${Qt()}${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 Xt(e){return Ke("collect","stg-collect",e)}function Me(e){return`https://${Xt(e)}`}var X=class Z{constructor(t){this.element=t,this.next=Z.Undefined,this.prev=Z.Undefined}};X.Undefined=new X(void 0);var u=X,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,I=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 I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,s,o,i,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let d=new I(t);return this._listeners?this._listeners instanceof I?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,E,ye;if(!this._disposed){if(this._listeners instanceof I)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=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ye.call(E)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(s){n(s)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},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]},R=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=Ce([Te],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=Ce([Te],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.5-beta.10",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.3.5-beta.10",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.5-beta.10"),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 _(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",()=>R.emit("onDocumentReady",D.startTime));var gr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},D=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)}`),_({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=>{_({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}},T=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})},b=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ae();var Ge="jolibox-sdk-loadermeta",He,L=JSON.parse((He=window.__joliboxLocalStorage__.getItem(Ge))!=null?He:"{}"),me=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Sr(){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(Ge,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)&&T(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}`);_({err:`${g}`})}}function i(){var g;let a=Date.now();q("jsSdkBegin",{t:a}),D.startTime=a;let{script:d,type:f}=(g=o())!=null?g:{};if(d){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=d,document.head.appendChild(E),b("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:d,timestamp:f}=L;d&&f&&!Ve(me,f)&&T(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=()=>{b("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),l(),Sr()}catch(a){let d=new C(`module evaluate error: ${a}`);_({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 C(`implement module evaluate error in native:${l} `))}}))(s)}return()=>{try{let s=Date.now();q("jsSdkBegin",{t:s}),D.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),b("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let l=Date.now(),a=r(t.implementUrl);n(a),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new C(`module load failed ${s}`))}}};var Er="1.3.5-beta.10",J=Er,Ze=T(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,Qe=pe(tt),Xe=he(tt);function Rr(){et?ze(yr,{bootstrapUrl:Qe,implementUrl:Xe})():We({bootstrapUrl:Qe,implementUrl:Xe,currentMajorVersion:Ze,currentVersion:J})()}Rr();var _r=p();function rt(){return _r.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.5-beta.10";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?De(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 br=p();function dt(e){return c(this,null,function*(){return h("request")?yield br.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}R.on(e,t)},mt=(e,t)=>{if(!ge.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}R.off(e,t)},pt=(e,t)=>{if(!ge.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}R.once(e,t)};var xr=p();function ht(e){return c(this,null,function*(){return h("isNativeSupport")?yield xr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ir=p();function ft(e){return c(this,null,function*(){return h("callHostMethod")?yield Ir.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 Se=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)}}},St=window.JoliboxRuntime||Se;var Cr="LifecycleSDK.onReady",F=class extends m{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Cr,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 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 Dr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],G=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||(Dr.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 S=class S{constructor(){this.jssdkVersion="1.3.5-beta.10";this.runtime=new St;this.ads=new B;this.lifecycle=new F;this.storage=new $;this.keyboard=new V;this.task=new H;this.router=new G;this.payment=new W;this.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(S.instance)return S.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},S.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return S.instance||(S.instance=new S),S.instance}};S.instance=null;var Ee=S;window.JoliboxSDK=Ee;})();
|
|
1
|
+
"use strict";(()=>{var Et=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var Re=Object.getOwnPropertySymbols;var Rt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))Rt.call(t,r)&&_e(e,r,t[r]);if(Re)for(var r of Re(t))_t.call(t,r)&&_e(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,bt=Object.defineProperties,xt=Object.getOwnPropertyDescriptor,It=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,wt=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable,xe=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Dt=(e,t)=>{for(var r in t||(t={}))wt.call(t,r)&&xe(e,r,t[r]);if(be)for(var r of be(t))Ct.call(t,r)&&xe(e,r,t[r]);return e},Tt=(e,t)=>bt(e,It(t)),At=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},Ce=(e,t,r,n)=>{for(var s=n>1?void 0:n?xt(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&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 De(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 Te(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"}},C=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 x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Nt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Nt});var Q=Symbol.for("Jolibox.canIUseMap"),Mt={};globalThis[Q]||(globalThis[Q]=Mt);var Pe={get config(){return globalThis[Q]}};var Ie=Symbol.for("Jolibox.canIUseMap.native"),jt={};globalThis[Ie]||(globalThis[Ie]=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(Tt(Dt({},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",Ht="device_id",Gt="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(Ht),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(Gt),Yt=e=>e.charAt(0).toUpperCase()+e.slice(1),Qt=()=>{var e;let t=new URLSearchParams(window.location.search);return Yt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},ke=e=>{if(ce())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,s=Wt(),o=zt();return`${t} (${Qt()}${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 Xt(e){return Ke("collect","stg-collect",e)}function Me(e){return`https://${Xt(e)}`}var X=class Z{constructor(t){this.element=t,this.next=Z.Undefined,this.prev=Z.Undefined}};X.Undefined=new X(void 0);var u=X,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,I=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 I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,s,o,i,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let d=new I(t);return this._listeners?this._listeners instanceof I?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,E,ye;if(!this._disposed){if(this._listeners instanceof I)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=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ye.call(E)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(s){n(s)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},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]},R=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=Ce([Te],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=Ce([Te],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.5-beta.11",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.3.5-beta.11",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.5-beta.11"),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 _(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",()=>R.emit("onDocumentReady",D.startTime));var gr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},D=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)}`),_({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=>{_({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}},T=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})},b=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ae();var Ge="jolibox-sdk-loadermeta",He,L=JSON.parse((He=window.__joliboxLocalStorage__.getItem(Ge))!=null?He:"{}"),me=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Sr(){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(Ge,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)&&T(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}`);_({err:`${g}`})}}function i(){var g;let a=Date.now();q("jsSdkBegin",{t:a}),D.startTime=a;let{script:d,type:f}=(g=o())!=null?g:{};if(d){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=d,document.head.appendChild(E),b("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:d,timestamp:f}=L;d&&f&&!Ve(me,f)&&T(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=()=>{b("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),l(),Sr()}catch(a){let d=new C(`module evaluate error: ${a}`);_({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 C(`implement module evaluate error in native:${l} `))}}))(s)}return()=>{try{let s=Date.now();q("jsSdkBegin",{t:s}),D.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),b("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let l=Date.now(),a=r(t.implementUrl);n(a),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new C(`module load failed ${s}`))}}};var Er="1.3.5-beta.11",J=Er,Ze=T(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,Qe=pe(tt),Xe=he(tt);function Rr(){et?ze(yr,{bootstrapUrl:Qe,implementUrl:Xe})():We({bootstrapUrl:Qe,implementUrl:Xe,currentMajorVersion:Ze,currentVersion:J})()}Rr();var _r=p();function rt(){return _r.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.5-beta.11";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?De(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 br=p();function dt(e){return c(this,null,function*(){return h("request")?yield br.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}R.on(e,t)},mt=(e,t)=>{if(!ge.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}R.off(e,t)},pt=(e,t)=>{if(!ge.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}R.once(e,t)};var xr=p();function ht(e){return c(this,null,function*(){return h("isNativeSupport")?yield xr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ir=p();function ft(e){return c(this,null,function*(){return h("callHostMethod")?yield Ir.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 Se=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)}}},St=window.JoliboxRuntime||Se;var Cr="LifecycleSDK.onReady",F=class extends m{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Cr,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 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 Dr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],G=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||(Dr.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 S=class S{constructor(){this.jssdkVersion="1.3.5-beta.11";this.runtime=new St;this.ads=new B;this.lifecycle=new F;this.storage=new $;this.keyboard=new V;this.task=new H;this.router=new G;this.payment=new W;this.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(S.instance)return S.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},S.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return S.instance||(S.instance=new S),S.instance}};S.instance=null;var Ee=S;window.JoliboxSDK=Ee;})();
|
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.5-beta.
|
|
4
|
+
"version": "1.3.5-beta.11",
|
|
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.5-beta.
|
|
11
|
-
"@jolibox/types": "1.3.5-beta.
|
|
10
|
+
"@jolibox/common": "1.3.5-beta.11",
|
|
11
|
+
"@jolibox/types": "1.3.5-beta.11"
|
|
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.5-beta.
|
|
3
|
+
> @jolibox/sdk@1.3.5-beta.11 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/sdk@1.3.5-beta.
|
|
7
|
+
> @jolibox/sdk@1.3.5-beta.11 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.5-beta.
|
|
11
|
+
> @jolibox/sdk@1.3.5-beta.11 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.5-beta.
|
|
15
|
+
> @jolibox/sdk@1.3.5-beta.11 build:iife
|
|
16
16
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
|
|
17
17
|
|