@jolibox/sdk 1.2.4 → 1.2.5
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 +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.js +76 -79
- package/package.json +3 -3
- package/sdk.build.log +4 -4
- package/src/loader/h5.ts +2 -2
|
@@ -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": "9dd776f1774a6f16451b43c58701fd258283eef2",
|
|
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",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"packages/sdk/src/events.ts": "124aa9c3dbfa2477ba4d365d63446fae6b542f1f",
|
|
20
20
|
"packages/sdk/src/index.ts": "9064e8319b592997f1cbb5f5fbeda796a5d0c530",
|
|
21
21
|
"packages/sdk/src/loader/__tests__/version.test.ts": "338ca817bfcb672d1065d6f32872b57bc43951b5",
|
|
22
|
-
"packages/sdk/src/loader/h5.ts": "
|
|
22
|
+
"packages/sdk/src/loader/h5.ts": "d4428c67612fd9cf5540afa2bdd3cd17db0f5c98",
|
|
23
23
|
"packages/sdk/src/loader/index.ts": "0ef5ddb69c89f6f7cd78ee318c7030ca3da8aee4",
|
|
24
24
|
"packages/sdk/src/loader/native.ts": "5f9f068c328222a28b457d19841b93c4a13ecccb",
|
|
25
25
|
"packages/sdk/src/loader/version.ts": "deacf56606b2c47f93e0dfa35e5b5dfbe774c69f",
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var U=Object.defineProperty,vt=Object.defineProperties,_t=Object.getOwnPropertyDescriptor,St=Object.getOwnPropertyDescriptors,bt=Object.getOwnPropertyNames,Se=Object.getOwnPropertySymbols;var Re=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable;var be=(e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,C=(e,t)=>{for(var r in t||(t={}))Re.call(t,r)&&be(e,r,t[r]);if(Se)for(var r of Se(t))Rt.call(t,r)&&be(e,r,t[r]);return e},O=(e,t)=>vt(e,St(t));var xt=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0})},It=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of bt(t))!Re.call(e,o)&&o!==r&&U(e,o,{get:()=>t[o],enumerable:!(n=_t(t,o))||n.enumerable});return e};var wt=e=>It(U({},"__esModule",{value:!0}),e);var m=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});var Or={};xt(Or,{JoliboxSDK:()=>q});module.exports=wt(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 o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var ne=Object.defineProperty,Tt=Object.defineProperties,Lt=Object.getOwnPropertyDescriptor,At=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertySymbols,Dt=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable,Ie=(e,t,r)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ut=(e,t)=>{for(var r in t||(t={}))Dt.call(t,r)&&Ie(e,r,t[r]);if(xe)for(var r of xe(t))Pt.call(t,r)&&Ie(e,r,t[r]);return e},Ct=(e,t)=>Tt(e,At(t)),Ot=(e,t)=>{for(var r in t)ne(e,r,{get:t[r],enumerable:!0})},Le=(e,t,r,n)=>{for(var o=n>1?void 0:n?Lt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&ne(t,r,o),o},kt=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function 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 Kt(e){return typeof e=="undefined"}function Mt(e){return Kt(e)||e===null}function jt(e){return typeof e=="function"}function De(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Jt=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Jt||{}),M=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Pe=class extends M{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ue=class extends Pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var j=class extends M{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Ft={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Ft});var X=Symbol.for("Jolibox.canIUseMap"),Bt={};globalThis[X]||(globalThis[X]=Bt);var Ce={get config(){return globalThis[X]}};var we=Symbol.for("Jolibox.canIUseMap.native"),Vt={};globalThis[we]||(globalThis[we]=Vt);function se(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var ie=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ie||{}),ae=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ae||{}),$t=(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))($t||{}),Te=["name","params"],Ht=["name","type","location","target","extra","timestamp","userId"],Gt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function N(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Wt(e){let t=e.location?N(e.location,Te):null,r=e.target?N(e.target,Te):null;return N(Ct(Ut({},e),{location:t,target:r}),Ht)}function Oe(e){let t=e.events.map(n=>Wt(n)),r=N(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 ce(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}ce();var _=typeof window=="undefined",le=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),k={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Yt=()=>k.isiOS?"iOS":k.isAndroid?"Android":k.isMac?"Mac":k.isFacebook?"Facebook":"PC",qt="device_id",Qt="advertising_id",ke=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,zt()),window.__joliboxLocalStorage__.getItem(e)),Xt=()=>new URLSearchParams(window.location.search).get("deviceId")||ke(qt),Zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||ke(Qt),er=e=>e.charAt(0).toUpperCase()+e.slice(1),tr=()=>{var e;let t=new URLSearchParams(window.location.search);return er((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ne=e=>{if(le())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Yt(),n=navigator.language,o=Xt(),s=Zt();return`${t} (${tr()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function Ke(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function rr(e){return Ke("api","stg-api",e)}function Me(e){return`https://${rr(e)}`}function nr(e){return Ke("collect","stg-collect",e)}function je(e){return`https://${nr(e)}`}var Z=class ee{constructor(t){this.element=t,this.next=ee.Undefined,this.prev=ee.Undefined}};Z.Undefined=new Z(void 0);var d=Z,or=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},sr=0,I=class{constructor(e){this.value=e,this.id=sr++}},w=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,y,ve;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let _e=this._listeners.indexOf(l);_e>=0&&(this._listeners.splice(_e,1),this._size--,this._size===0&&((ve=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ve.call(y)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},me=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new or,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},te={};Ot(te,{None:()=>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(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function cr(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var Q=Symbol.for("Jolibox.hostEmitter"),lr=()=>{let e=new me;return globalThis[Q]||(globalThis[Q]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Q]},S=lr();function mr(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)dr(e[n],t[n])}function dr(e,t){if(oe(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(jt(t)){try{if(e instanceof t)return}catch(r){}if(!Mt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var K=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return mr(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};K=Le([De],K);var re=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new K,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Nt(3e4)),this._starActivation}executeCommand(e,...t){return kt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),te.toPromise(te.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};re=Le([De],re);var Fe=Symbol.for("Jolibox.commands");function ur(){return typeof globalThis!="undefined"?globalThis[Fe]:void 0}function pr(e){typeof globalThis!="undefined"&&(globalThis[Fe]=e)}function u(e=!1){let t=ur();if(!e&&t)return t;let r=new K,n=new re,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return pr(o),o}var J=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function fr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function hr(){return{platform:1e3,os:"h5",appVersion:"1.2.4",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.4",extra:{}}}var gr=()=>{var t;return je((t=J)!=null?t:!1)},Er=gr(),Ve=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Be;(Be=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ve);var yr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},vr=yr(),_r=e=>m(void 0,null,function*(){try{let r=`${Er}/report`,n=Ne("1.2.4"),o=vr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Ve(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:ie.ErrorTrace,location:fr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=hr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ae.WebSDK},s=Oe(o);yield _r(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var Sr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=Sr(),$e=u(),de=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof M?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};$e.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},v=de;window.addEventListener("unhandledrejection",de.bind(void 0));window.addEventListener("error",de.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};$e.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var ue=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(ue(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ue(e),{major:i,minor:c,patch:a,prerelease:l}=ue(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var He=u(),F=(e,t)=>{He.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{He.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ce();var ze="jolibox-sdk-loadermeta",We,P=JSON.parse((We=window.__joliboxLocalStorage__.getItem(ze))!=null?We:"{}"),pe=Date.now(),Ge=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function br(){return m(this,null,function*(){let t=`${Me(J)}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=O(C({},P),{timestamp:pe});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=O(C({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=O(C({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(ze,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ye=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!Ge(pe,l)&&A(a)==t&&D(a,r)>=0&&(n=fe(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new Ue(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();F("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=l,document.head.appendChild(y),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!Ge(pe,h)&&A(l)==t&&D(l,r)>=0&&(o=he(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),br()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var qe=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>m(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){v(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();F("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),v(new T(`module load failed ${o}`))}}};var Rr="1.2.4",B=Rr,et=A(B),tt=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),xr=tt?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,ge="https://jsdelivr.jolibox.com";var Qe=window.document.currentScript;Qe&&(ge=new URL(Qe.src).origin);var fe=(e,t)=>`${t!=null?t:ge}/npm/@jolibox/bootstrap@${e}/dist/index.js`,he=(e,t)=>`${t!=null?t:ge}/npm/@jolibox/implement@${e}/dist/index.js`,Ir=e=>/^\d+\.\d+\.\d+$/.test(e),rt=Ir(B)?et:B,Xe=fe(rt),Ze=he(rt);function wr(){tt?qe(xr,{bootstrapUrl:Xe,implementUrl:Ze})():Ye({bootstrapUrl:Xe,implementUrl:Ze,currentMajorVersion:et,currentVersion:B})()}wr();var Tr=u();function nt(){return Tr.excuteCommandSync("API.getSystemInfoSync")}function ot(e,t){var r;return(r=Ce.config[e])==null?void 0:r[t]}function st(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var at="1.2.4";function f(e){let[t,...r]=e.split(":"),n=ot(le()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||se(at,o,"<")?!1:r.length===0?!0:it(n,r)||it(n.properties,r)}function it(e,t){if(!e)return!1;let r=st(e,t);return r?Ae(r)?!0:oe(r)?se(at,r,">="):!1:!1}var ct=u();function lt(){return m(this,null,function*(){return f("login")?yield ct.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function mt(){return m(this,null,function*(){return f("checkSession")?yield ct.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Lr=u();function dt(e){return m(this,null,function*(){return f("request")?yield Lr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var Ee=["onI18nChanged","onBackPress"],ut=(e,t)=>{if(!Ee.includes(e)){v(new j(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},pt=(e,t)=>{if(!Ee.includes(e)){v(new j(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},ft=(e,t)=>{if(!Ee.includes(e)){v(new j(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Ar=u();function ht(e){return m(this,null,function*(){return f("isNativeSupport")?yield Ar.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Dr=u();function gt(e){return m(this,null,function*(){return f("callHostMethod")?yield Dr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Pr=u();function Et(e){return m(this,null,function*(){return f("track")?yield Pr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new me}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ye=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},yt=window.JoliboxRuntime||ye;var Ur="LifecycleSDK.onReady",V=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Ur,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var $=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var H=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return m(this,null,function*(){})}};var G=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var W=class extends p{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:i})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Cr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],z=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Cr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var Y=class extends p{constructor(){super()}purchaseGem(t){return m(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 m(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}};var E=class E{constructor(){this.jssdkVersion="1.2.4";this.runtime=new yt;this.ads=new H;this.lifecycle=new V;this.storage=new $;this.keyboard=new G;this.task=new W;this.router=new z;this.payment=new Y;this.getSystemInfoSync=nt.bind(this);this.canIUse=f.bind(this);this.login=lt.bind(this);this.checkSession=mt.bind(this);this.request=dt.bind(this);this.on=ut.bind(this);this.off=pt.bind(this);this.once=ft.bind(this);this.isNativeSupport=ht.bind(this);this.callHostMethod=gt.bind(this);this.track=Et.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var q=E;window.JoliboxSDK=q;
|
|
1
|
+
"use strict";var U=Object.defineProperty,vt=Object.defineProperties,_t=Object.getOwnPropertyDescriptor,St=Object.getOwnPropertyDescriptors,bt=Object.getOwnPropertyNames,Se=Object.getOwnPropertySymbols;var Re=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable;var be=(e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,C=(e,t)=>{for(var r in t||(t={}))Re.call(t,r)&&be(e,r,t[r]);if(Se)for(var r of Se(t))Rt.call(t,r)&&be(e,r,t[r]);return e},O=(e,t)=>vt(e,St(t));var xt=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0})},It=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of bt(t))!Re.call(e,o)&&o!==r&&U(e,o,{get:()=>t[o],enumerable:!(n=_t(t,o))||n.enumerable});return e};var wt=e=>It(U({},"__esModule",{value:!0}),e);var m=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});var Cr={};xt(Cr,{JoliboxSDK:()=>q});module.exports=wt(Cr);if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var ne=Object.defineProperty,Tt=Object.defineProperties,Lt=Object.getOwnPropertyDescriptor,At=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertySymbols,Dt=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable,Ie=(e,t,r)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ut=(e,t)=>{for(var r in t||(t={}))Dt.call(t,r)&&Ie(e,r,t[r]);if(xe)for(var r of xe(t))Pt.call(t,r)&&Ie(e,r,t[r]);return e},Ct=(e,t)=>Tt(e,At(t)),Ot=(e,t)=>{for(var r in t)ne(e,r,{get:t[r],enumerable:!0})},Le=(e,t,r,n)=>{for(var o=n>1?void 0:n?Lt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&ne(t,r,o),o},kt=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function 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 Kt(e){return typeof e=="undefined"}function Mt(e){return Kt(e)||e===null}function jt(e){return typeof e=="function"}function De(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Jt=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Jt||{}),M=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Pe=class extends M{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ue=class extends Pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var j=class extends M{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Ft={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Ft});var X=Symbol.for("Jolibox.canIUseMap"),Bt={};globalThis[X]||(globalThis[X]=Bt);var Ce={get config(){return globalThis[X]}};var we=Symbol.for("Jolibox.canIUseMap.native"),Vt={};globalThis[we]||(globalThis[we]=Vt);function se(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var ie=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ie||{}),ae=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ae||{}),Ht=(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))(Ht||{}),Te=["name","params"],$t=["name","type","location","target","extra","timestamp","userId"],Gt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function N(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Wt(e){let t=e.location?N(e.location,Te):null,r=e.target?N(e.target,Te):null;return N(Ct(Ut({},e),{location:t,target:r}),$t)}function Oe(e){let t=e.events.map(n=>Wt(n)),r=N(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 ce(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}ce();var _=typeof window=="undefined",le=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),k={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Yt=()=>k.isiOS?"iOS":k.isAndroid?"Android":k.isMac?"Mac":k.isFacebook?"Facebook":"PC",qt="device_id",Qt="advertising_id",ke=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,zt()),window.__joliboxLocalStorage__.getItem(e)),Xt=()=>new URLSearchParams(window.location.search).get("deviceId")||ke(qt),Zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||ke(Qt),er=e=>e.charAt(0).toUpperCase()+e.slice(1),tr=()=>{var e;let t=new URLSearchParams(window.location.search);return er((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ne=e=>{if(le())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Yt(),n=navigator.language,o=Xt(),s=Zt();return`${t} (${tr()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function Ke(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function Me(e){return`https://${Ke("api","stg-api",e)}`}function rr(e){return Ke("collect","stg-collect",e)}function je(e){return`https://${rr(e)}`}var Z=class ee{constructor(t){this.element=t,this.next=ee.Undefined,this.prev=ee.Undefined}};Z.Undefined=new Z(void 0);var d=Z,nr=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},or=0,I=class{constructor(e){this.value=e,this.id=or++}},w=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,y,ve;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let _e=this._listeners.indexOf(l);_e>=0&&(this._listeners.splice(_e,1),this._size--,this._size===0&&((ve=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ve.call(y)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},me=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new nr,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},te={};Ot(te,{None:()=>sr,filter:()=>ar,once:()=>Je,toPromise:()=>ir});var sr=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function ir(e){return new Promise(t=>Je(e)(t))}function Je(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function ar(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var Q=Symbol.for("Jolibox.hostEmitter"),cr=()=>{let e=new me;return globalThis[Q]||(globalThis[Q]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Q]},S=cr();function lr(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)mr(e[n],t[n])}function mr(e,t){if(oe(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(jt(t)){try{if(e instanceof t)return}catch(r){}if(!Mt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var K=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return lr(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};K=Le([De],K);var re=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new K,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Nt(3e4)),this._starActivation}executeCommand(e,...t){return kt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),te.toPromise(te.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};re=Le([De],re);var Fe=Symbol.for("Jolibox.commands");function dr(){return typeof globalThis!="undefined"?globalThis[Fe]:void 0}function ur(e){typeof globalThis!="undefined"&&(globalThis[Fe]=e)}function u(e=!1){let t=dr();if(!e&&t)return t;let r=new K,n=new re,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return ur(o),o}var J=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function pr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function fr(){return{platform:1e3,os:"h5",appVersion:"1.2.5",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.5",extra:{}}}var hr=()=>{var t;return je((t=J)!=null?t:!1)},gr=hr(),Ve=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Be;(Be=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ve);var Er=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},yr=Er(),vr=e=>m(void 0,null,function*(){try{let r=`${gr}/report`,n=Ne("1.2.5"),o=yr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Ve(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:ie.ErrorTrace,location:pr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=fr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ae.WebSDK},s=Oe(o);yield vr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var _r=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=_r(),He=u(),de=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof M?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};He.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},v=de;window.addEventListener("unhandledrejection",de.bind(void 0));window.addEventListener("error",de.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};He.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var ue=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(ue(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ue(e),{major:i,minor:c,patch:a,prerelease:l}=ue(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var $e=u(),F=(e,t)=>{$e.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{$e.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ce();var ze="jolibox-sdk-loadermeta",We,P=JSON.parse((We=window.__joliboxLocalStorage__.getItem(ze))!=null?We:"{}"),pe=Date.now(),Ge=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Sr(){return m(this,null,function*(){let t=`${Me(J)}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=O(C({},P),{timestamp:pe});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=O(C({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=O(C({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(ze,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ye=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!Ge(pe,l)&&A(a)==t&&D(a,r)>=0&&(n=fe(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new Ue(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();F("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=l,document.head.appendChild(y),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!Ge(pe,h)&&A(l)==t&&D(l,r)>=0&&(o=he(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),Sr()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var qe=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>m(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){v(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();F("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),v(new T(`module load failed ${o}`))}}};var br="1.2.5",B=br,et=A(B),tt=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Rr=tt?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,ge="https://jsdelivr.jolibox.com";var Qe=window.document.currentScript;Qe&&(ge=new URL(Qe.src).origin);var fe=(e,t)=>`${t!=null?t:ge}/npm/@jolibox/bootstrap@${e}/dist/index.js`,he=(e,t)=>`${t!=null?t:ge}/npm/@jolibox/implement@${e}/dist/index.js`,xr=e=>/^\d+\.\d+\.\d+$/.test(e),rt=xr(B)?et:B,Xe=fe(rt),Ze=he(rt);function Ir(){tt?qe(Rr,{bootstrapUrl:Xe,implementUrl:Ze})():Ye({bootstrapUrl:Xe,implementUrl:Ze,currentMajorVersion:et,currentVersion:B})()}Ir();var wr=u();function nt(){return wr.excuteCommandSync("API.getSystemInfoSync")}function ot(e,t){var r;return(r=Ce.config[e])==null?void 0:r[t]}function st(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var at="1.2.5";function f(e){let[t,...r]=e.split(":"),n=ot(le()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||se(at,o,"<")?!1:r.length===0?!0:it(n,r)||it(n.properties,r)}function it(e,t){if(!e)return!1;let r=st(e,t);return r?Ae(r)?!0:oe(r)?se(at,r,">="):!1:!1}var ct=u();function lt(){return m(this,null,function*(){return f("login")?yield ct.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function mt(){return m(this,null,function*(){return f("checkSession")?yield ct.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Tr=u();function dt(e){return m(this,null,function*(){return f("request")?yield Tr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var Ee=["onI18nChanged","onBackPress"],ut=(e,t)=>{if(!Ee.includes(e)){v(new j(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},pt=(e,t)=>{if(!Ee.includes(e)){v(new j(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},ft=(e,t)=>{if(!Ee.includes(e)){v(new j(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Lr=u();function ht(e){return m(this,null,function*(){return f("isNativeSupport")?yield Lr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ar=u();function gt(e){return m(this,null,function*(){return f("callHostMethod")?yield Ar.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Dr=u();function Et(e){return m(this,null,function*(){return f("track")?yield Dr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new me}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ye=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},yt=window.JoliboxRuntime||ye;var Pr="LifecycleSDK.onReady",V=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Pr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var H=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return m(this,null,function*(){})}};var G=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var W=class extends p{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:i})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Ur=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],z=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Ur.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var Y=class extends p{constructor(){super()}purchaseGem(t){return m(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 m(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}};var E=class E{constructor(){this.jssdkVersion="1.2.5";this.runtime=new yt;this.ads=new $;this.lifecycle=new V;this.storage=new H;this.keyboard=new G;this.task=new W;this.router=new z;this.payment=new Y;this.getSystemInfoSync=nt.bind(this);this.canIUse=f.bind(this);this.login=lt.bind(this);this.checkSession=mt.bind(this);this.request=dt.bind(this);this.on=ut.bind(this);this.off=pt.bind(this);this.once=ft.bind(this);this.isNativeSupport=ht.bind(this);this.callHostMethod=gt.bind(this);this.track=Et.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var q=E;window.JoliboxSDK=q;
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Et=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable;var Se=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&Se(e,r,t[r]);if(_e)for(var r of _e(t))St.call(t,r)&&Se(e,r,t[r]);return e},C=(e,t)=>yt(e,vt(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var te=Object.defineProperty,bt=Object.defineProperties,Rt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,Re=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tt=(e,t)=>{for(var r in t||(t={}))It.call(t,r)&&Re(e,r,t[r]);if(be)for(var r of be(t))wt.call(t,r)&&Re(e,r,t[r]);return e},Lt=(e,t)=>bt(e,xt(t)),At=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},we=(e,t,r,n)=>{for(var o=n>1?void 0:n?Rt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&te(t,r,o),o},Dt=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Pt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function re(e){return typeof e=="string"}function Te(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Ut(e){return typeof e=="undefined"}function Ct(e){return Ut(e)||e===null}function Ot(e){return typeof e=="function"}function Le(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var kt=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(kt||{}),K=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Ae=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var De=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var 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"),Kt={};globalThis[q]||(globalThis[q]=Kt);var Pe={get config(){return globalThis[q]}};var xe=Symbol.for("Jolibox.canIUseMap.native"),Mt={};globalThis[xe]||(globalThis[xe]=Mt);function ne(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var oe=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),se=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(se||{}),jt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(jt||{}),Ie=["name","params"],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((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Bt(e){let t=e.location?k(e.location,Ie):null,r=e.target?k(e.target,Ie):null;return k(Lt(Tt({},e),{location:t,target:r}),Jt)}function Ue(e){let t=e.events.map(n=>Bt(n)),r=k(e.device,Ft);return[e.protocolVersion,t,r,e.project]}var Vt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function ie(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}ie();var _=typeof window=="undefined",ae=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},$t=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Ht="device_id",Gt="advertising_id",Ce=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Vt()),window.__joliboxLocalStorage__.getItem(e)),Wt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ce(Ht),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ce(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"},Oe=e=>{if(ae())return window.navigator.userAgent;let t="JoliboxWebSDK",r=$t(),n=navigator.language,o=Wt(),s=zt();return`${t} (${qt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function ke(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function Qt(e){return ke("api","stg-api",e)}function Ne(e){return`https://${Qt(e)}`}function Xt(e){return ke("collect","stg-collect",e)}function Ke(e){return`https://${Xt(e)}`}var Q=class X{constructor(t){this.element=t,this.next=X.Undefined,this.prev=X.Undefined}};Q.Undefined=new Q(void 0);var d=Q,Zt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},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,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,y,ye;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ve=this._listeners.indexOf(l);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((ye=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ye.call(y)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ce=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new 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)}},Z={};At(Z,{None:()=>tr,filter:()=>nr,once:()=>Me,toPromise:()=>rr});var tr=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function rr(e){return new Promise(t=>Me(e)(t))}function Me(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function nr(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var Y=Symbol.for("Jolibox.hostEmitter"),or=()=>{let e=new ce;return globalThis[Y]||(globalThis[Y]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Y]},S=or();function sr(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(re(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ot(t)){try{if(e instanceof t)return}catch(r){}if(!Ct(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var N=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return sr(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};N=we([Le],N);var ee=class{constructor(){this._onWillExecuteCommand=new 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=Pt(3e4)),this._starActivation}executeCommand(e,...t){return Dt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Z.toPromise(Z.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};ee=we([Le],ee);var je=Symbol.for("Jolibox.commands");function ar(){return typeof globalThis!="undefined"?globalThis[je]:void 0}function cr(e){typeof globalThis!="undefined"&&(globalThis[je]=e)}function u(e=!1){let t=ar();if(!e&&t)return t;let r=new N,n=new ee,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return cr(o),o}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 mr(){return{platform:1e3,os:"h5",appVersion:"1.2.4",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.4",extra:{}}}var dr=()=>{var t;return Ke((t=j)!=null?t:!1)},ur=dr(),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},fr=pr(),hr=e=>m(void 0,null,function*(){try{let r=`${ur}/report`,n=Oe("1.2.4"),o=fr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Fe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:lr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=mr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:se.WebSDK},s=Ue(o);yield hr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var gr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=gr(),Be=u(),le=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},v=le;window.addEventListener("unhandledrejection",le.bind(void 0));window.addEventListener("error",le.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var me=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(me(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=me(e),{major:i,minor:c,patch:a,prerelease:l}=me(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var Ve=u(),J=(e,t)=>{Ve.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Ve.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ie();var Ge="jolibox-sdk-loadermeta",He,P=JSON.parse((He=window.__joliboxLocalStorage__.getItem(Ge))!=null?He:"{}"),de=Date.now(),$e=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Er(){return m(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:o}=yield r.json(),s=C(U({},P),{timestamp:de});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=C(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=C(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ge,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var We=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!$e(de,l)&&A(a)==t&&D(a,r)>=0&&(n=ue(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new De(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=l,document.head.appendChild(y),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!$e(de,h)&&A(l)==t&&D(l,r)>=0&&(o=pe(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),Er()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var ze=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>m(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){v(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),v(new T(`module load failed ${o}`))}}};var yr="1.2.4",F=yr,Xe=A(F),Ze=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),vr=Ze?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,fe="https://jsdelivr.jolibox.com";var Ye=window.document.currentScript;Ye&&(fe=new URL(Ye.src).origin);var ue=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,pe=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/implement@${e}/dist/index.js`,_r=e=>/^\d+\.\d+\.\d+$/.test(e),et=_r(F)?Xe:F,qe=ue(et),Qe=pe(et);function Sr(){Ze?ze(vr,{bootstrapUrl:qe,implementUrl:Qe})():We({bootstrapUrl:qe,implementUrl:Qe,currentMajorVersion:Xe,currentVersion:F})()}Sr();var br=u();function tt(){return br.excuteCommandSync("API.getSystemInfoSync")}function rt(e,t){var r;return(r=Pe.config[e])==null?void 0:r[t]}function nt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var st="1.2.4";function f(e){let[t,...r]=e.split(":"),n=rt(ae()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||ne(st,o,"<")?!1:r.length===0?!0:ot(n,r)||ot(n.properties,r)}function ot(e,t){if(!e)return!1;let r=nt(e,t);return r?Te(r)?!0:re(r)?ne(st,r,">="):!1:!1}var it=u();function at(){return m(this,null,function*(){return f("login")?yield it.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ct(){return m(this,null,function*(){return f("checkSession")?yield it.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Rr=u();function lt(e){return m(this,null,function*(){return f("request")?yield Rr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var he=["onI18nChanged","onBackPress"],mt=(e,t)=>{if(!he.includes(e)){v(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},dt=(e,t)=>{if(!he.includes(e)){v(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},ut=(e,t)=>{if(!he.includes(e)){v(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var xr=u();function pt(e){return m(this,null,function*(){return f("isNativeSupport")?yield xr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ir=u();function ft(e){return m(this,null,function*(){return f("callHostMethod")?yield Ir.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var wr=u();function ht(e){return m(this,null,function*(){return f("track")?yield wr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new ce}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ge=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},gt=window.JoliboxRuntime||ge;var Tr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Tr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return m(this,null,function*(){})}};var H=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var G=class extends p{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:i})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Lr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],W=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Lr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var z=class extends p{constructor(){super()}purchaseGem(t){return m(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 m(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}};var E=class E{constructor(){this.jssdkVersion="1.2.4";this.runtime=new gt;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new H;this.task=new G;this.router=new W;this.payment=new z;this.getSystemInfoSync=tt.bind(this);this.canIUse=f.bind(this);this.login=at.bind(this);this.checkSession=ct.bind(this);this.request=lt.bind(this);this.on=mt.bind(this);this.off=dt.bind(this);this.once=ut.bind(this);this.isNativeSupport=pt.bind(this);this.callHostMethod=ft.bind(this);this.track=ht.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var Ee=E;window.JoliboxSDK=Ee;export{Ee as JoliboxSDK};
|
|
1
|
+
var Et=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable;var Se=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&Se(e,r,t[r]);if(_e)for(var r of _e(t))St.call(t,r)&&Se(e,r,t[r]);return e},C=(e,t)=>yt(e,vt(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var te=Object.defineProperty,bt=Object.defineProperties,Rt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,Re=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tt=(e,t)=>{for(var r in t||(t={}))It.call(t,r)&&Re(e,r,t[r]);if(be)for(var r of be(t))wt.call(t,r)&&Re(e,r,t[r]);return e},Lt=(e,t)=>bt(e,xt(t)),At=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},we=(e,t,r,n)=>{for(var o=n>1?void 0:n?Rt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&te(t,r,o),o},Dt=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Pt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function re(e){return typeof e=="string"}function Te(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Ut(e){return typeof e=="undefined"}function Ct(e){return Ut(e)||e===null}function Ot(e){return typeof e=="function"}function Le(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var kt=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(kt||{}),K=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Ae=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var De=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var 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"),Kt={};globalThis[q]||(globalThis[q]=Kt);var Pe={get config(){return globalThis[q]}};var xe=Symbol.for("Jolibox.canIUseMap.native"),Mt={};globalThis[xe]||(globalThis[xe]=Mt);function ne(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var oe=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),se=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(se||{}),jt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(jt||{}),Ie=["name","params"],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((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Bt(e){let t=e.location?k(e.location,Ie):null,r=e.target?k(e.target,Ie):null;return k(Lt(Tt({},e),{location:t,target:r}),Jt)}function Ue(e){let t=e.events.map(n=>Bt(n)),r=k(e.device,Ft);return[e.protocolVersion,t,r,e.project]}var Vt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function ie(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}ie();var _=typeof window=="undefined",ae=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Ht=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",$t="device_id",Gt="advertising_id",Ce=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Vt()),window.__joliboxLocalStorage__.getItem(e)),Wt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ce($t),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ce(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"},Oe=e=>{if(ae())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Ht(),n=navigator.language,o=Wt(),s=zt();return`${t} (${qt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function ke(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function Ne(e){return`https://${ke("api","stg-api",e)}`}function Qt(e){return ke("collect","stg-collect",e)}function Ke(e){return`https://${Qt(e)}`}var Q=class X{constructor(t){this.element=t,this.next=X.Undefined,this.prev=X.Undefined}};Q.Undefined=new Q(void 0);var d=Q,Xt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Zt=0,I=class{constructor(e){this.value=e,this.id=Zt++}},w=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,y,ye;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ve=this._listeners.indexOf(l);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((ye=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ye.call(y)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ce=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Xt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},Z={};At(Z,{None:()=>er,filter:()=>rr,once:()=>Me,toPromise:()=>tr});var er=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function tr(e){return new Promise(t=>Me(e)(t))}function Me(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function rr(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var Y=Symbol.for("Jolibox.hostEmitter"),nr=()=>{let e=new ce;return globalThis[Y]||(globalThis[Y]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Y]},S=nr();function or(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)sr(e[n],t[n])}function sr(e,t){if(re(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ot(t)){try{if(e instanceof t)return}catch(r){}if(!Ct(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var N=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return or(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};N=we([Le],N);var ee=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new N,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Pt(3e4)),this._starActivation}executeCommand(e,...t){return Dt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Z.toPromise(Z.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};ee=we([Le],ee);var je=Symbol.for("Jolibox.commands");function ir(){return typeof globalThis!="undefined"?globalThis[je]:void 0}function ar(e){typeof globalThis!="undefined"&&(globalThis[je]=e)}function u(e=!1){let t=ir();if(!e&&t)return t;let r=new N,n=new ee,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return ar(o),o}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function cr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function lr(){return{platform:1e3,os:"h5",appVersion:"1.2.5",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.5",extra:{}}}var mr=()=>{var t;return Ke((t=j)!=null?t:!1)},dr=mr(),Fe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Je;(Je=AbortSignal.timeout)!=null||(AbortSignal.timeout=Fe);var ur=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},pr=ur(),fr=e=>m(void 0,null,function*(){try{let r=`${dr}/report`,n=Oe("1.2.5"),o=pr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Fe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:cr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=lr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:se.WebSDK},s=Ue(o);yield fr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var hr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=hr(),Be=u(),le=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},v=le;window.addEventListener("unhandledrejection",le.bind(void 0));window.addEventListener("error",le.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var me=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(me(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=me(e),{major:i,minor:c,patch:a,prerelease:l}=me(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var Ve=u(),J=(e,t)=>{Ve.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Ve.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ie();var Ge="jolibox-sdk-loadermeta",$e,P=JSON.parse(($e=window.__joliboxLocalStorage__.getItem(Ge))!=null?$e:"{}"),de=Date.now(),He=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function gr(){return m(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:o}=yield r.json(),s=C(U({},P),{timestamp:de});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=C(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=C(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ge,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var We=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!He(de,l)&&A(a)==t&&D(a,r)>=0&&(n=ue(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new De(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=l,document.head.appendChild(y),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!He(de,h)&&A(l)==t&&D(l,r)>=0&&(o=pe(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),gr()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var ze=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>m(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){v(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),v(new T(`module load failed ${o}`))}}};var Er="1.2.5",F=Er,Xe=A(F),Ze=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),yr=Ze?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,fe="https://jsdelivr.jolibox.com";var Ye=window.document.currentScript;Ye&&(fe=new URL(Ye.src).origin);var ue=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,pe=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/implement@${e}/dist/index.js`,vr=e=>/^\d+\.\d+\.\d+$/.test(e),et=vr(F)?Xe:F,qe=ue(et),Qe=pe(et);function _r(){Ze?ze(yr,{bootstrapUrl:qe,implementUrl:Qe})():We({bootstrapUrl:qe,implementUrl:Qe,currentMajorVersion:Xe,currentVersion:F})()}_r();var Sr=u();function tt(){return Sr.excuteCommandSync("API.getSystemInfoSync")}function rt(e,t){var r;return(r=Pe.config[e])==null?void 0:r[t]}function nt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var st="1.2.5";function f(e){let[t,...r]=e.split(":"),n=rt(ae()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||ne(st,o,"<")?!1:r.length===0?!0:ot(n,r)||ot(n.properties,r)}function ot(e,t){if(!e)return!1;let r=nt(e,t);return r?Te(r)?!0:re(r)?ne(st,r,">="):!1:!1}var it=u();function at(){return m(this,null,function*(){return f("login")?yield it.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ct(){return m(this,null,function*(){return f("checkSession")?yield it.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var br=u();function lt(e){return m(this,null,function*(){return f("request")?yield br.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var he=["onI18nChanged","onBackPress"],mt=(e,t)=>{if(!he.includes(e)){v(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},dt=(e,t)=>{if(!he.includes(e)){v(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},ut=(e,t)=>{if(!he.includes(e)){v(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Rr=u();function pt(e){return m(this,null,function*(){return f("isNativeSupport")?yield Rr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var xr=u();function ft(e){return m(this,null,function*(){return f("callHostMethod")?yield xr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Ir=u();function ht(e){return m(this,null,function*(){return f("track")?yield Ir.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new ce}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ge=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},gt=window.JoliboxRuntime||ge;var wr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(wr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var H=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return m(this,null,function*(){})}};var $=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var G=class extends p{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:i})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Tr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],W=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Tr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var z=class extends p{constructor(){super()}purchaseGem(t){return m(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 m(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}};var E=class E{constructor(){this.jssdkVersion="1.2.5";this.runtime=new gt;this.ads=new H;this.lifecycle=new B;this.storage=new V;this.keyboard=new $;this.task=new G;this.router=new W;this.payment=new z;this.getSystemInfoSync=tt.bind(this);this.canIUse=f.bind(this);this.login=at.bind(this);this.checkSession=ct.bind(this);this.request=lt.bind(this);this.on=mt.bind(this);this.off=dt.bind(this);this.once=ut.bind(this);this.isNativeSupport=pt.bind(this);this.callHostMethod=ft.bind(this);this.track=ht.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var Ee=E;window.JoliboxSDK=Ee;export{Ee as JoliboxSDK};
|
package/dist/index.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var Et=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable;var Se=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&Se(e,r,t[r]);if(_e)for(var r of _e(t))St.call(t,r)&&Se(e,r,t[r]);return e},C=(e,t)=>yt(e,vt(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var te=Object.defineProperty,bt=Object.defineProperties,Rt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,Re=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tt=(e,t)=>{for(var r in t||(t={}))It.call(t,r)&&Re(e,r,t[r]);if(be)for(var r of be(t))wt.call(t,r)&&Re(e,r,t[r]);return e},Lt=(e,t)=>bt(e,xt(t)),At=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},we=(e,t,r,n)=>{for(var o=n>1?void 0:n?Rt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&te(t,r,o),o},Dt=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Pt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function re(e){return typeof e=="string"}function Te(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Ut(e){return typeof e=="undefined"}function Ct(e){return Ut(e)||e===null}function Ot(e){return typeof e=="function"}function Le(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var kt=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(kt||{}),K=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Ae=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var De=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var 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"),Kt={};globalThis[q]||(globalThis[q]=Kt);var Pe={get config(){return globalThis[q]}};var xe=Symbol.for("Jolibox.canIUseMap.native"),Mt={};globalThis[xe]||(globalThis[xe]=Mt);function ne(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var oe=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),se=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(se||{}),jt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(jt||{}),Ie=["name","params"],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((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Bt(e){let t=e.location?k(e.location,Ie):null,r=e.target?k(e.target,Ie):null;return k(Lt(Tt({},e),{location:t,target:r}),Jt)}function Ue(e){let t=e.events.map(n=>Bt(n)),r=k(e.device,Ft);return[e.protocolVersion,t,r,e.project]}var Vt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function ie(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}ie();var _=typeof window=="undefined",ae=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},$t=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Ht="device_id",Gt="advertising_id",Ce=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Vt()),window.__joliboxLocalStorage__.getItem(e)),Wt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ce(Ht),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ce(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"},Oe=e=>{if(ae())return window.navigator.userAgent;let t="JoliboxWebSDK",r=$t(),n=navigator.language,o=Wt(),s=zt();return`${t} (${qt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function ke(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function Qt(e){return ke("api","stg-api",e)}function Ne(e){return`https://${Qt(e)}`}function Xt(e){return ke("collect","stg-collect",e)}function Ke(e){return`https://${Xt(e)}`}var Q=class X{constructor(t){this.element=t,this.next=X.Undefined,this.prev=X.Undefined}};Q.Undefined=new Q(void 0);var d=Q,Zt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},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,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,y,ye;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ve=this._listeners.indexOf(l);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((ye=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ye.call(y)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ce=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new 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)}},Z={};At(Z,{None:()=>tr,filter:()=>nr,once:()=>Me,toPromise:()=>rr});var tr=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function rr(e){return new Promise(t=>Me(e)(t))}function Me(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function nr(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var Y=Symbol.for("Jolibox.hostEmitter"),or=()=>{let e=new ce;return globalThis[Y]||(globalThis[Y]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Y]},S=or();function sr(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(re(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ot(t)){try{if(e instanceof t)return}catch(r){}if(!Ct(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var N=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return sr(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};N=we([Le],N);var ee=class{constructor(){this._onWillExecuteCommand=new 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=Pt(3e4)),this._starActivation}executeCommand(e,...t){return Dt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Z.toPromise(Z.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};ee=we([Le],ee);var je=Symbol.for("Jolibox.commands");function ar(){return typeof globalThis!="undefined"?globalThis[je]:void 0}function cr(e){typeof globalThis!="undefined"&&(globalThis[je]=e)}function u(e=!1){let t=ar();if(!e&&t)return t;let r=new N,n=new ee,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return cr(o),o}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 mr(){return{platform:1e3,os:"h5",appVersion:"1.2.4",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.4",extra:{}}}var dr=()=>{var t;return Ke((t=j)!=null?t:!1)},ur=dr(),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},fr=pr(),hr=e=>m(void 0,null,function*(){try{let r=`${ur}/report`,n=Oe("1.2.4"),o=fr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Fe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:lr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=mr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:se.WebSDK},s=Ue(o);yield hr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var gr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=gr(),Be=u(),le=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},v=le;window.addEventListener("unhandledrejection",le.bind(void 0));window.addEventListener("error",le.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var me=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(me(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=me(e),{major:i,minor:c,patch:a,prerelease:l}=me(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var Ve=u(),J=(e,t)=>{Ve.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Ve.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ie();var Ge="jolibox-sdk-loadermeta",He,P=JSON.parse((He=window.__joliboxLocalStorage__.getItem(Ge))!=null?He:"{}"),de=Date.now(),$e=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Er(){return m(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:o}=yield r.json(),s=C(U({},P),{timestamp:de});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=C(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=C(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ge,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var We=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!$e(de,l)&&A(a)==t&&D(a,r)>=0&&(n=ue(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new De(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=l,document.head.appendChild(y),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!$e(de,h)&&A(l)==t&&D(l,r)>=0&&(o=pe(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),Er()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var ze=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>m(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){v(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),v(new T(`module load failed ${o}`))}}};var yr="1.2.4",F=yr,Xe=A(F),Ze=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),vr=Ze?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,fe="https://jsdelivr.jolibox.com";var Ye=window.document.currentScript;Ye&&(fe=new URL(Ye.src).origin);var ue=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,pe=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/implement@${e}/dist/index.js`,_r=e=>/^\d+\.\d+\.\d+$/.test(e),et=_r(F)?Xe:F,qe=ue(et),Qe=pe(et);function Sr(){Ze?ze(vr,{bootstrapUrl:qe,implementUrl:Qe})():We({bootstrapUrl:qe,implementUrl:Qe,currentMajorVersion:Xe,currentVersion:F})()}Sr();var br=u();function tt(){return br.excuteCommandSync("API.getSystemInfoSync")}function rt(e,t){var r;return(r=Pe.config[e])==null?void 0:r[t]}function nt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var st="1.2.4";function f(e){let[t,...r]=e.split(":"),n=rt(ae()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||ne(st,o,"<")?!1:r.length===0?!0:ot(n,r)||ot(n.properties,r)}function ot(e,t){if(!e)return!1;let r=nt(e,t);return r?Te(r)?!0:re(r)?ne(st,r,">="):!1:!1}var it=u();function at(){return m(this,null,function*(){return f("login")?yield it.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ct(){return m(this,null,function*(){return f("checkSession")?yield it.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Rr=u();function lt(e){return m(this,null,function*(){return f("request")?yield Rr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var he=["onI18nChanged","onBackPress"],mt=(e,t)=>{if(!he.includes(e)){v(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},dt=(e,t)=>{if(!he.includes(e)){v(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},ut=(e,t)=>{if(!he.includes(e)){v(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var xr=u();function pt(e){return m(this,null,function*(){return f("isNativeSupport")?yield xr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ir=u();function ft(e){return m(this,null,function*(){return f("callHostMethod")?yield Ir.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var wr=u();function ht(e){return m(this,null,function*(){return f("track")?yield wr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new ce}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ge=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},gt=window.JoliboxRuntime||ge;var Tr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Tr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return m(this,null,function*(){})}};var H=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var G=class extends p{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:i})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Lr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],W=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Lr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var z=class extends p{constructor(){super()}purchaseGem(t){return m(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 m(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}};var E=class E{constructor(){this.jssdkVersion="1.2.4";this.runtime=new gt;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new H;this.task=new G;this.router=new W;this.payment=new z;this.getSystemInfoSync=tt.bind(this);this.canIUse=f.bind(this);this.login=at.bind(this);this.checkSession=ct.bind(this);this.request=lt.bind(this);this.on=mt.bind(this);this.off=dt.bind(this);this.once=ut.bind(this);this.isNativeSupport=pt.bind(this);this.callHostMethod=ft.bind(this);this.track=ht.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var Ee=E;window.JoliboxSDK=Ee;})();
|
|
1
|
+
"use strict";(()=>{var Et=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable;var Se=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&Se(e,r,t[r]);if(_e)for(var r of _e(t))St.call(t,r)&&Se(e,r,t[r]);return e},C=(e,t)=>yt(e,vt(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var te=Object.defineProperty,bt=Object.defineProperties,Rt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,Re=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tt=(e,t)=>{for(var r in t||(t={}))It.call(t,r)&&Re(e,r,t[r]);if(be)for(var r of be(t))wt.call(t,r)&&Re(e,r,t[r]);return e},Lt=(e,t)=>bt(e,xt(t)),At=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},we=(e,t,r,n)=>{for(var o=n>1?void 0:n?Rt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&te(t,r,o),o},Dt=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Pt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function re(e){return typeof e=="string"}function Te(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Ut(e){return typeof e=="undefined"}function Ct(e){return Ut(e)||e===null}function Ot(e){return typeof e=="function"}function Le(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var kt=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(kt||{}),K=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Ae=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var De=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var 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"),Kt={};globalThis[q]||(globalThis[q]=Kt);var Pe={get config(){return globalThis[q]}};var xe=Symbol.for("Jolibox.canIUseMap.native"),Mt={};globalThis[xe]||(globalThis[xe]=Mt);function ne(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var oe=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),se=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(se||{}),jt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(jt||{}),Ie=["name","params"],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((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Bt(e){let t=e.location?k(e.location,Ie):null,r=e.target?k(e.target,Ie):null;return k(Lt(Tt({},e),{location:t,target:r}),Jt)}function Ue(e){let t=e.events.map(n=>Bt(n)),r=k(e.device,Ft);return[e.protocolVersion,t,r,e.project]}var Vt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function ie(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}ie();var _=typeof window=="undefined",ae=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Ht=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",$t="device_id",Gt="advertising_id",Ce=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Vt()),window.__joliboxLocalStorage__.getItem(e)),Wt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ce($t),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ce(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"},Oe=e=>{if(ae())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Ht(),n=navigator.language,o=Wt(),s=zt();return`${t} (${qt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function ke(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function Ne(e){return`https://${ke("api","stg-api",e)}`}function Qt(e){return ke("collect","stg-collect",e)}function Ke(e){return`https://${Qt(e)}`}var Q=class X{constructor(t){this.element=t,this.next=X.Undefined,this.prev=X.Undefined}};Q.Undefined=new Q(void 0);var d=Q,Xt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Zt=0,I=class{constructor(e){this.value=e,this.id=Zt++}},w=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,y,ye;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ve=this._listeners.indexOf(l);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((ye=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ye.call(y)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ce=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Xt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},Z={};At(Z,{None:()=>er,filter:()=>rr,once:()=>Me,toPromise:()=>tr});var er=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function tr(e){return new Promise(t=>Me(e)(t))}function Me(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function rr(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var Y=Symbol.for("Jolibox.hostEmitter"),nr=()=>{let e=new ce;return globalThis[Y]||(globalThis[Y]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Y]},S=nr();function or(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)sr(e[n],t[n])}function sr(e,t){if(re(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ot(t)){try{if(e instanceof t)return}catch(r){}if(!Ct(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var N=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return or(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};N=we([Le],N);var ee=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new N,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Pt(3e4)),this._starActivation}executeCommand(e,...t){return Dt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Z.toPromise(Z.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};ee=we([Le],ee);var je=Symbol.for("Jolibox.commands");function ir(){return typeof globalThis!="undefined"?globalThis[je]:void 0}function ar(e){typeof globalThis!="undefined"&&(globalThis[je]=e)}function u(e=!1){let t=ir();if(!e&&t)return t;let r=new N,n=new ee,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return ar(o),o}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function cr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function lr(){return{platform:1e3,os:"h5",appVersion:"1.2.5",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.5",extra:{}}}var mr=()=>{var t;return Ke((t=j)!=null?t:!1)},dr=mr(),Fe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Je;(Je=AbortSignal.timeout)!=null||(AbortSignal.timeout=Fe);var ur=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},pr=ur(),fr=e=>m(void 0,null,function*(){try{let r=`${dr}/report`,n=Oe("1.2.5"),o=pr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Fe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:cr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=lr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:se.WebSDK},s=Ue(o);yield fr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var hr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=hr(),Be=u(),le=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},v=le;window.addEventListener("unhandledrejection",le.bind(void 0));window.addEventListener("error",le.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var me=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(me(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=me(e),{major:i,minor:c,patch:a,prerelease:l}=me(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var Ve=u(),J=(e,t)=>{Ve.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Ve.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ie();var Ge="jolibox-sdk-loadermeta",$e,P=JSON.parse(($e=window.__joliboxLocalStorage__.getItem(Ge))!=null?$e:"{}"),de=Date.now(),He=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function gr(){return m(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:o}=yield r.json(),s=C(U({},P),{timestamp:de});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=C(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=C(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ge,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var We=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!He(de,l)&&A(a)==t&&D(a,r)>=0&&(n=ue(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new De(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=l,document.head.appendChild(y),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!He(de,h)&&A(l)==t&&D(l,r)>=0&&(o=pe(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),gr()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var ze=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>m(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){v(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),v(new T(`module load failed ${o}`))}}};var Er="1.2.5",F=Er,Xe=A(F),Ze=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),yr=Ze?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,fe="https://jsdelivr.jolibox.com";var Ye=window.document.currentScript;Ye&&(fe=new URL(Ye.src).origin);var ue=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,pe=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/implement@${e}/dist/index.js`,vr=e=>/^\d+\.\d+\.\d+$/.test(e),et=vr(F)?Xe:F,qe=ue(et),Qe=pe(et);function _r(){Ze?ze(yr,{bootstrapUrl:qe,implementUrl:Qe})():We({bootstrapUrl:qe,implementUrl:Qe,currentMajorVersion:Xe,currentVersion:F})()}_r();var Sr=u();function tt(){return Sr.excuteCommandSync("API.getSystemInfoSync")}function rt(e,t){var r;return(r=Pe.config[e])==null?void 0:r[t]}function nt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var st="1.2.5";function f(e){let[t,...r]=e.split(":"),n=rt(ae()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||ne(st,o,"<")?!1:r.length===0?!0:ot(n,r)||ot(n.properties,r)}function ot(e,t){if(!e)return!1;let r=nt(e,t);return r?Te(r)?!0:re(r)?ne(st,r,">="):!1:!1}var it=u();function at(){return m(this,null,function*(){return f("login")?yield it.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ct(){return m(this,null,function*(){return f("checkSession")?yield it.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var br=u();function lt(e){return m(this,null,function*(){return f("request")?yield br.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var he=["onI18nChanged","onBackPress"],mt=(e,t)=>{if(!he.includes(e)){v(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},dt=(e,t)=>{if(!he.includes(e)){v(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},ut=(e,t)=>{if(!he.includes(e)){v(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Rr=u();function pt(e){return m(this,null,function*(){return f("isNativeSupport")?yield Rr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var xr=u();function ft(e){return m(this,null,function*(){return f("callHostMethod")?yield xr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Ir=u();function ht(e){return m(this,null,function*(){return f("track")?yield Ir.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new ce}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ge=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},gt=window.JoliboxRuntime||ge;var wr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(wr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var H=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return m(this,null,function*(){})}};var $=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var G=class extends p{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:i})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Tr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],W=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Tr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var z=class extends p{constructor(){super()}purchaseGem(t){return m(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 m(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}};var E=class E{constructor(){this.jssdkVersion="1.2.5";this.runtime=new gt;this.ads=new H;this.lifecycle=new B;this.storage=new V;this.keyboard=new $;this.task=new G;this.router=new W;this.payment=new z;this.getSystemInfoSync=tt.bind(this);this.canIUse=f.bind(this);this.login=at.bind(this);this.checkSession=ct.bind(this);this.request=lt.bind(this);this.on=mt.bind(this);this.off=dt.bind(this);this.once=ut.bind(this);this.isNativeSupport=pt.bind(this);this.callHostMethod=ft.bind(this);this.track=ht.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var Ee=E;window.JoliboxSDK=Ee;})();
|
package/dist/index.js
CHANGED
|
@@ -3,34 +3,34 @@
|
|
|
3
3
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
4
4
|
(_JoliboxSDK2 => {
|
|
5
5
|
// ../common/dist/index.es.js
|
|
6
|
-
var
|
|
6
|
+
var V = Object.defineProperty;
|
|
7
7
|
var Ie = Object.defineProperties;
|
|
8
8
|
var Ae = Object.getOwnPropertyDescriptor;
|
|
9
9
|
var Ce = Object.getOwnPropertyDescriptors;
|
|
10
|
-
var
|
|
10
|
+
var B = Object.getOwnPropertySymbols;
|
|
11
11
|
var we = Object.prototype.hasOwnProperty;
|
|
12
12
|
var Ne = Object.prototype.propertyIsEnumerable;
|
|
13
|
-
var
|
|
13
|
+
var W = (n, e, t) => e in n ? V(n, e, {
|
|
14
14
|
enumerable: true,
|
|
15
15
|
configurable: true,
|
|
16
16
|
writable: true,
|
|
17
17
|
value: t
|
|
18
18
|
}) : n[e] = t;
|
|
19
19
|
var _ = (n, e) => {
|
|
20
|
-
for (var t in e || (e = {})) we.call(e, t) &&
|
|
21
|
-
if (
|
|
20
|
+
for (var t in e || (e = {})) we.call(e, t) && W(n, t, e[t]);
|
|
21
|
+
if (B) for (var t of B(e)) Ne.call(e, t) && W(n, t, e[t]);
|
|
22
22
|
return n;
|
|
23
23
|
};
|
|
24
24
|
var N = (n, e) => Ie(n, Ce(e));
|
|
25
25
|
var Oe = (n, e) => {
|
|
26
|
-
for (var t in e)
|
|
26
|
+
for (var t in e) V(n, t, {
|
|
27
27
|
get: e[t],
|
|
28
28
|
enumerable: true
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
31
|
var O = (n, e, t, r) => {
|
|
32
32
|
for (var o = r > 1 ? void 0 : r ? Ae(e, t) : e, i = n.length - 1, s; i >= 0; i--) (s = n[i]) && (o = (r ? s(e, t, o) : s(o)) || o);
|
|
33
|
-
return r && o &&
|
|
33
|
+
return r && o && V(e, t, o), o;
|
|
34
34
|
};
|
|
35
35
|
var P = (n, e, t) => new Promise((r, o) => {
|
|
36
36
|
var i = a => {
|
|
@@ -76,14 +76,14 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
76
76
|
if (this._eventListeners[t.type]) for (let r of this._eventListeners[t.type]) r.call(this, t);
|
|
77
77
|
}, window.AbortController = n, window.AbortSignal = e;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function Y(n) {
|
|
80
80
|
return new Promise(e => {
|
|
81
81
|
setTimeout(() => {
|
|
82
82
|
e();
|
|
83
83
|
}, n);
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function F(n) {
|
|
87
87
|
return typeof n == "string";
|
|
88
88
|
}
|
|
89
89
|
function Pe(n) {
|
|
@@ -92,10 +92,10 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
92
92
|
function Se(n) {
|
|
93
93
|
return typeof n == "undefined";
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function j(n) {
|
|
96
96
|
return Se(n) || n === null;
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function H(n) {
|
|
99
99
|
return typeof n == "function";
|
|
100
100
|
}
|
|
101
101
|
function S(n) {
|
|
@@ -125,21 +125,21 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
125
125
|
this.kind = "INTERNAL_ERROR";
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
|
-
var
|
|
128
|
+
var oe = class extends p {
|
|
129
129
|
constructor() {
|
|
130
130
|
super(...arguments);
|
|
131
131
|
this.name = "INTERNAL_JS_MODULE_FETCH_ERROR";
|
|
132
132
|
this.priority = "P0";
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
|
-
var
|
|
135
|
+
var ie = class extends p {
|
|
136
136
|
constructor() {
|
|
137
137
|
super(...arguments);
|
|
138
138
|
this.name = "INTERNAL_JS_MODULE_EVAL_ERROR";
|
|
139
139
|
this.priority = "P0";
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
|
-
var
|
|
142
|
+
var fe = class extends I {
|
|
143
143
|
constructor(t, r, o, i, s) {
|
|
144
144
|
super(t);
|
|
145
145
|
this.message = t;
|
|
@@ -164,7 +164,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
164
164
|
((o = (r = globalThis.VConsole) == null ? void 0 : r[n]) != null ? o : globalThis.console[n])(...arguments);
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
|
-
var
|
|
167
|
+
var xe = {
|
|
168
168
|
log: A("log"),
|
|
169
169
|
warn: A("warn"),
|
|
170
170
|
info: A("info"),
|
|
@@ -172,14 +172,14 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
172
172
|
debug: A("debug")
|
|
173
173
|
};
|
|
174
174
|
Object.assign(globalThis, {
|
|
175
|
-
logger:
|
|
175
|
+
logger: xe
|
|
176
176
|
});
|
|
177
|
-
var
|
|
177
|
+
var $ = Symbol.for("Jolibox.canIUseMap");
|
|
178
178
|
var Me = {};
|
|
179
|
-
globalThis[
|
|
179
|
+
globalThis[$] || (globalThis[$] = Me);
|
|
180
180
|
var Qn = {
|
|
181
181
|
get config() {
|
|
182
|
-
return globalThis[
|
|
182
|
+
return globalThis[$];
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
185
|
var K = Symbol.for("Jolibox.canIUseMap.native");
|
|
@@ -222,7 +222,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
222
222
|
var De = (l => (l[l.Other = 0] = "Other", l[l.Route = 1] = "Route", l[l.Click = 2] = "Click", l[l.View = 3] = "View", l[l.Expose = 4] = "Expose", l[l.Swipe = 5] = "Swipe", l[l.Input = 6] = "Input", l[l.Select = 7] = "Select", l[l.SwitchOn = 8] = "SwitchOn", l[l.SwitchOff = 9] = "SwitchOff", l[l.Submit = 10] = "Submit", l[l.Scroll = 11] = "Scroll", l[l.Hide = 12] = "Hide", l[l.System = 1e3] = "System", l[l.ErrorTrace = 1001] = "ErrorTrace", l[l.UserDefined = 1002] = "UserDefined", l))(De || {});
|
|
223
223
|
var Ve = (i => (i.MiniGame = "mini-game", i.MiniDrama = "mini-drama", i.App = "app", i.WebSDK = "web-sdk", i.AppSDK = "app-sdk", i))(Ve || {});
|
|
224
224
|
var Fe = (c => (c[c.App = 0] = "App", c[c.H5 = 1] = "H5", c[c.Weapp = 2] = "Weapp", c[c.Alipay = 3] = "Alipay", c[c.Gcash = 4] = "Gcash", c[c.Dana = 5] = "Dana", c[c.Umma = 6] = "Umma", c[c.WebSDK = 1e3] = "WebSDK", c[c.AppSDK = 1001] = "AppSDK", c[c.Other = 9999] = "Other", c))(Fe || {});
|
|
225
|
-
var
|
|
225
|
+
var he = ["name", "params"];
|
|
226
226
|
var je = ["name", "type", "location", "target", "extra", "timestamp", "userId"];
|
|
227
227
|
var He = ["platform", "os", "appVersion", "appId", "model", "brand", "uuid", "jsSdkVersion", "extra"];
|
|
228
228
|
function k(n, e) {
|
|
@@ -234,24 +234,24 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
234
234
|
return n[t];
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
|
-
function
|
|
238
|
-
let e = n.location ? k(n.location,
|
|
239
|
-
t = n.target ? k(n.target,
|
|
237
|
+
function $e(n) {
|
|
238
|
+
let e = n.location ? k(n.location, he) : null,
|
|
239
|
+
t = n.target ? k(n.target, he) : null;
|
|
240
240
|
return k(N(_({}, n), {
|
|
241
241
|
location: e,
|
|
242
242
|
target: t
|
|
243
243
|
}), je);
|
|
244
244
|
}
|
|
245
245
|
function rt(n) {
|
|
246
|
-
let e = n.events.map(r =>
|
|
246
|
+
let e = n.events.map(r => $e(r)),
|
|
247
247
|
t = k(n.device, He);
|
|
248
248
|
return [n.protocolVersion, e, t, n.project];
|
|
249
249
|
}
|
|
250
|
-
var
|
|
250
|
+
var _e = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, n => {
|
|
251
251
|
let e = Math.random() * 16 | 0;
|
|
252
252
|
return (n === "x" ? e : e & 3 | 8).toString(16);
|
|
253
253
|
});
|
|
254
|
-
function
|
|
254
|
+
function Ee() {
|
|
255
255
|
if (typeof window == "undefined") return {
|
|
256
256
|
getItem: () => null,
|
|
257
257
|
setItem: () => {},
|
|
@@ -279,9 +279,9 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
279
279
|
return console.warn("Failed to get original localStorage, fallback to default implementation", n), localStorage;
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
|
|
282
|
+
Ee();
|
|
283
283
|
var E = typeof window == "undefined";
|
|
284
|
-
var
|
|
284
|
+
var Ke = () => !E && !!(navigator.userAgent || "").includes("JoliboxPlatformSDK");
|
|
285
285
|
var M = {
|
|
286
286
|
isiOS: !E && (navigator.userAgent.includes("iPhone") || navigator.userAgent.includes("iPod") || navigator.userAgent.includes("iPad") || navigator.userAgent.includes("iPhone OS")),
|
|
287
287
|
iosVersion: () => {
|
|
@@ -296,14 +296,14 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
296
296
|
var Ge = () => M.isiOS ? "iOS" : M.isAndroid ? "Android" : M.isMac ? "Mac" : M.isFacebook ? "Facebook" : "PC";
|
|
297
297
|
var Je = "device_id";
|
|
298
298
|
var ze = "advertising_id";
|
|
299
|
-
var
|
|
299
|
+
var Re = n => (window.__joliboxLocalStorage__.getItem(n) || window.__joliboxLocalStorage__.setItem(n, _e()), window.__joliboxLocalStorage__.getItem(n));
|
|
300
300
|
var Be = () => {
|
|
301
301
|
let e = new URLSearchParams(window.location.search).get("deviceId");
|
|
302
|
-
return e ||
|
|
302
|
+
return e || Re(Je);
|
|
303
303
|
};
|
|
304
304
|
var We = () => {
|
|
305
305
|
let e = new URLSearchParams(window.location.search).get("advertisingId");
|
|
306
|
-
return e ||
|
|
306
|
+
return e || Re(ze);
|
|
307
307
|
};
|
|
308
308
|
var Qe = n => n.charAt(0).toUpperCase() + n.slice(1);
|
|
309
309
|
var Ye = () => {
|
|
@@ -312,7 +312,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
312
312
|
return Qe((e = n.get("utm_source")) != null ? e : "") || "JoliboxSDK";
|
|
313
313
|
};
|
|
314
314
|
var ft = n => {
|
|
315
|
-
if (
|
|
315
|
+
if (Ke()) return window.navigator.userAgent;
|
|
316
316
|
let e = "JoliboxWebSDK",
|
|
317
317
|
t = Ge(),
|
|
318
318
|
r = navigator.language,
|
|
@@ -320,7 +320,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
320
320
|
i = We();
|
|
321
321
|
return `${e} (${Ye()}${t}; UnknownModel; UnknownSystemVersion; ${r}) uuid/${o} adid/${i} version/${n || ""}`;
|
|
322
322
|
};
|
|
323
|
-
function
|
|
323
|
+
function U(n, e, t) {
|
|
324
324
|
let r = window.location.hostname,
|
|
325
325
|
o = r.split("."),
|
|
326
326
|
i = t ? e : n;
|
|
@@ -331,16 +331,13 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
331
331
|
}
|
|
332
332
|
return `${i}.jolibox.com`;
|
|
333
333
|
}
|
|
334
|
-
function
|
|
335
|
-
return
|
|
336
|
-
}
|
|
337
|
-
function xt(n) {
|
|
338
|
-
return `https://${qe(n)}`;
|
|
334
|
+
function ht(n) {
|
|
335
|
+
return `https://${U("api", "stg-api", n)}`;
|
|
339
336
|
}
|
|
340
337
|
function Xe(n) {
|
|
341
|
-
return
|
|
338
|
+
return U("collect", "stg-collect", n);
|
|
342
339
|
}
|
|
343
|
-
function
|
|
340
|
+
function Et(n) {
|
|
344
341
|
return `https://${Xe(n)}`;
|
|
345
342
|
}
|
|
346
343
|
var R = class R2 {
|
|
@@ -350,7 +347,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
350
347
|
};
|
|
351
348
|
R.Undefined = new R(void 0);
|
|
352
349
|
var m = R;
|
|
353
|
-
var
|
|
350
|
+
var D = class {
|
|
354
351
|
constructor() {
|
|
355
352
|
this._first = m.Undefined;
|
|
356
353
|
this._last = m.Undefined;
|
|
@@ -441,11 +438,11 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
441
438
|
r && (t = t.bind(r));
|
|
442
439
|
let o = new x(t);
|
|
443
440
|
return this._listeners ? this._listeners instanceof x ? this._listeners = [this._listeners, o] : this._listeners.push(o) : ((s = (i = this.options) == null ? void 0 : i.onWillAddFirstListener) == null || s.call(i, this), this._listeners = o, (a = (d = this.options) == null ? void 0 : d.onDidFirstListener) == null || a.call(d, this)), (c = (u = this.options) == null ? void 0 : u.onDidAddListener) == null || c.call(u, this), this._size++, () => {
|
|
444
|
-
var h, b, w,
|
|
441
|
+
var h, b, w, J;
|
|
445
442
|
if (!this._disposed) {
|
|
446
443
|
if (this._listeners instanceof x) this._listeners.id === o.id && (this._listeners = void 0, this._size = 0, (b = (h = this.options) == null ? void 0 : h.onDidRemoveLastListener) == null || b.call(h));else if (this._listeners) {
|
|
447
|
-
let
|
|
448
|
-
|
|
444
|
+
let z = this._listeners.indexOf(o);
|
|
445
|
+
z >= 0 && (this._listeners.splice(z, 1), this._size--, this._size === 0 && ((J = (w = this.options) == null ? void 0 : w.onDidRemoveLastListener) == null || J.call(w)));
|
|
449
446
|
}
|
|
450
447
|
}
|
|
451
448
|
};
|
|
@@ -504,7 +501,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
504
501
|
for (var _len2 = arguments.length, t = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
505
502
|
t[_key2 - 1] = arguments[_key2];
|
|
506
503
|
}
|
|
507
|
-
o || (o = new
|
|
504
|
+
o || (o = new D(), this.cachedEventQueue.set(e, o)), o.push({
|
|
508
505
|
args: t
|
|
509
506
|
}), r && r.fire({
|
|
510
507
|
event: e,
|
|
@@ -556,29 +553,29 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
556
553
|
return n(i => e(i) && r.call(o, i), null);
|
|
557
554
|
});
|
|
558
555
|
}
|
|
559
|
-
var
|
|
556
|
+
var G = Symbol.for("Jolibox.hostEmitter");
|
|
560
557
|
var rn = () => {
|
|
561
558
|
let n = new C();
|
|
562
|
-
return globalThis[
|
|
559
|
+
return globalThis[G] || (globalThis[G] = {
|
|
563
560
|
on: n.on.bind(n),
|
|
564
561
|
off: n.off.bind(n),
|
|
565
562
|
emit: n.emit.bind(n),
|
|
566
563
|
once: n.once.bind(n)
|
|
567
|
-
}), globalThis[
|
|
564
|
+
}), globalThis[G];
|
|
568
565
|
};
|
|
569
|
-
var
|
|
566
|
+
var Yt = rn();
|
|
570
567
|
function ve(n, e) {
|
|
571
568
|
let t = Math.min(n.length, e.length);
|
|
572
569
|
for (let r = 0; r < t; r++) on(n[r], e[r]);
|
|
573
570
|
}
|
|
574
571
|
function on(n, e) {
|
|
575
|
-
if (
|
|
572
|
+
if (F(e)) {
|
|
576
573
|
if (typeof n !== e) throw new Error(`argument does not match constraint: typeof ${e}`);
|
|
577
|
-
} else if (
|
|
574
|
+
} else if (H(e)) {
|
|
578
575
|
try {
|
|
579
576
|
if (n instanceof e) return;
|
|
580
577
|
} catch (t) {}
|
|
581
|
-
if (!
|
|
578
|
+
if (!j(n) && n.constructor === e || e.length === 1 && e.call(void 0, n) === true) return;
|
|
582
579
|
throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true");
|
|
583
580
|
}
|
|
584
581
|
}
|
|
@@ -630,7 +627,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
630
627
|
this._starActivation = null;
|
|
631
628
|
}
|
|
632
629
|
_activateStar() {
|
|
633
|
-
return this._starActivation || (this._starActivation =
|
|
630
|
+
return this._starActivation || (this._starActivation = Y(3e4)), this._starActivation;
|
|
634
631
|
}
|
|
635
632
|
executeCommand(e) {
|
|
636
633
|
for (var _len4 = arguments.length, t = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
@@ -693,7 +690,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
693
690
|
function an(n) {
|
|
694
691
|
typeof globalThis != "undefined" && (globalThis[be] = n);
|
|
695
692
|
}
|
|
696
|
-
function
|
|
693
|
+
function Ir() {
|
|
697
694
|
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
698
695
|
let e = sn();
|
|
699
696
|
if (!n && e) return e;
|
|
@@ -754,7 +751,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
754
751
|
};
|
|
755
752
|
}
|
|
756
753
|
var apiBaseURL = () => {
|
|
757
|
-
const api =
|
|
754
|
+
const api = Et(testMode ?? false);
|
|
758
755
|
return api;
|
|
759
756
|
};
|
|
760
757
|
var API_BASE_URL = apiBaseURL();
|
|
@@ -819,7 +816,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
819
816
|
}
|
|
820
817
|
|
|
821
818
|
// src/events.ts
|
|
822
|
-
document.addEventListener("DOMContentLoaded", () =>
|
|
819
|
+
document.addEventListener("DOMContentLoaded", () => Yt.emit("onDocumentReady", timeline.startTime));
|
|
823
820
|
var timelineFactory = () => {
|
|
824
821
|
let _beginLoad = 0;
|
|
825
822
|
return {
|
|
@@ -832,7 +829,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
832
829
|
};
|
|
833
830
|
};
|
|
834
831
|
var timeline = timelineFactory();
|
|
835
|
-
var commands =
|
|
832
|
+
var commands = Ir();
|
|
836
833
|
var rejectHandler = event => {
|
|
837
834
|
let errorInfo;
|
|
838
835
|
if (event instanceof ErrorEvent) {
|
|
@@ -949,7 +946,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
949
946
|
};
|
|
950
947
|
|
|
951
948
|
// src/utils/report.ts
|
|
952
|
-
var commands2 =
|
|
949
|
+
var commands2 = Ir();
|
|
953
950
|
var track = (event, info) => {
|
|
954
951
|
commands2.executeCommand("ReportSDK.traceSystem", {
|
|
955
952
|
event,
|
|
@@ -965,13 +962,13 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
965
962
|
};
|
|
966
963
|
|
|
967
964
|
// src/loader/h5.ts
|
|
968
|
-
|
|
965
|
+
Ee();
|
|
969
966
|
var LOCAL_STORE_KEY = "jolibox-sdk-loadermeta";
|
|
970
967
|
var CURRENT_VERSION_STORE = JSON.parse(window.__joliboxLocalStorage__.getItem(LOCAL_STORE_KEY) ?? "{}");
|
|
971
968
|
var now = Date.now();
|
|
972
969
|
var expired = (now2, prev) => now2 > prev && Math.abs(now2 - prev) / (1e3 * 60 * 60 * 24) >= 7;
|
|
973
970
|
async function fetchCurrentRemoteScript() {
|
|
974
|
-
const host =
|
|
971
|
+
const host = ht(testMode);
|
|
975
972
|
const path = `${host}/api/fe-configs/js-sdk/version-metadata`;
|
|
976
973
|
try {
|
|
977
974
|
const response = await fetch(path, {
|
|
@@ -1041,7 +1038,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1041
1038
|
type: "fetch_from_cdn"
|
|
1042
1039
|
};
|
|
1043
1040
|
} catch (e) {
|
|
1044
|
-
const internalError = new
|
|
1041
|
+
const internalError = new oe(`Bootstrap module faile to fetch ${e}`);
|
|
1045
1042
|
trackError({
|
|
1046
1043
|
err: `${internalError}`
|
|
1047
1044
|
});
|
|
@@ -1095,7 +1092,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1095
1092
|
loadRemoteImplement();
|
|
1096
1093
|
fetchCurrentRemoteScript();
|
|
1097
1094
|
} catch (e) {
|
|
1098
|
-
const internalError = new
|
|
1095
|
+
const internalError = new ie(`module evaluate error: ${e}`);
|
|
1099
1096
|
trackError({
|
|
1100
1097
|
err: `${internalError}`
|
|
1101
1098
|
});
|
|
@@ -1125,7 +1122,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1125
1122
|
URL.revokeObjectURL(blobUrl);
|
|
1126
1123
|
return module;
|
|
1127
1124
|
} catch (error) {
|
|
1128
|
-
reportError(new
|
|
1125
|
+
reportError(new ie(`implement module evaluate error in native:${error} `));
|
|
1129
1126
|
}
|
|
1130
1127
|
};
|
|
1131
1128
|
evalJS(code);
|
|
@@ -1153,7 +1150,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1153
1150
|
});
|
|
1154
1151
|
} catch (e) {
|
|
1155
1152
|
console.error(`native load script error: ${e}`);
|
|
1156
|
-
reportError(new
|
|
1153
|
+
reportError(new ie(`module load failed ${e}`));
|
|
1157
1154
|
}
|
|
1158
1155
|
};
|
|
1159
1156
|
};
|
|
@@ -1212,7 +1209,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1212
1209
|
loadImplement();
|
|
1213
1210
|
|
|
1214
1211
|
// src/api/get-system-info.ts
|
|
1215
|
-
var commands3 =
|
|
1212
|
+
var commands3 = Ir();
|
|
1216
1213
|
function getSystemInfoSync() {
|
|
1217
1214
|
return commands3.excuteCommandSync("API.getSystemInfoSync");
|
|
1218
1215
|
}
|
|
@@ -1238,7 +1235,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1238
1235
|
var __VERSION__ = "__JOLIBOX_LOCAL_SDK_VERSION__";
|
|
1239
1236
|
function canIUse(schema) {
|
|
1240
1237
|
const [name, ...rest] = schema.split(":");
|
|
1241
|
-
const api = getCanIUseConfig(
|
|
1238
|
+
const api = getCanIUseConfig(Ke() ? "native" : "h5", name);
|
|
1242
1239
|
if (!api) return false;
|
|
1243
1240
|
const apiVersion = api["version"];
|
|
1244
1241
|
if (typeof apiVersion !== "string") return false;
|
|
@@ -1251,12 +1248,12 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1251
1248
|
const v2 = get(info, paths);
|
|
1252
1249
|
if (!v2) return false;
|
|
1253
1250
|
if (Pe(v2)) return true;
|
|
1254
|
-
if (
|
|
1251
|
+
if (F(v2)) return et(__VERSION__, v2, ">=");
|
|
1255
1252
|
return false;
|
|
1256
1253
|
}
|
|
1257
1254
|
|
|
1258
1255
|
// src/api/login.ts
|
|
1259
|
-
var commands4 =
|
|
1256
|
+
var commands4 = Ir();
|
|
1260
1257
|
async function login() {
|
|
1261
1258
|
if (!canIUse("login")) {
|
|
1262
1259
|
return {
|
|
@@ -1277,7 +1274,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1277
1274
|
}
|
|
1278
1275
|
|
|
1279
1276
|
// src/api/request.ts
|
|
1280
|
-
var commands5 =
|
|
1277
|
+
var commands5 = Ir();
|
|
1281
1278
|
async function request(params) {
|
|
1282
1279
|
if (!canIUse("request")) {
|
|
1283
1280
|
return {
|
|
@@ -1292,28 +1289,28 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1292
1289
|
var supportedEvents = ["onI18nChanged", "onBackPress"];
|
|
1293
1290
|
var onCustomEvent = (event, callback) => {
|
|
1294
1291
|
if (!supportedEvents.includes(event)) {
|
|
1295
|
-
reportError(new
|
|
1292
|
+
reportError(new fe(`[onCustomEvent] Unsupported event: ${event}`, 2e3));
|
|
1296
1293
|
return;
|
|
1297
1294
|
}
|
|
1298
|
-
|
|
1295
|
+
Yt.on(event, callback);
|
|
1299
1296
|
};
|
|
1300
1297
|
var offCustomEvent = (event, callback) => {
|
|
1301
1298
|
if (!supportedEvents.includes(event)) {
|
|
1302
|
-
reportError(new
|
|
1299
|
+
reportError(new fe(`[offCustomEvent] Unsupported event: ${event}`, 2e3));
|
|
1303
1300
|
return;
|
|
1304
1301
|
}
|
|
1305
|
-
|
|
1302
|
+
Yt.off(event, callback);
|
|
1306
1303
|
};
|
|
1307
1304
|
var onceCustomEvent = (event, callback) => {
|
|
1308
1305
|
if (!supportedEvents.includes(event)) {
|
|
1309
|
-
reportError(new
|
|
1306
|
+
reportError(new fe(`[onceCustomEvent] Unsupported event: ${event}`, 2e3));
|
|
1310
1307
|
return;
|
|
1311
1308
|
}
|
|
1312
|
-
|
|
1309
|
+
Yt.once(event, callback);
|
|
1313
1310
|
};
|
|
1314
1311
|
|
|
1315
1312
|
// src/api/is-native-support.ts
|
|
1316
|
-
var commands6 =
|
|
1313
|
+
var commands6 = Ir();
|
|
1317
1314
|
async function isNativeSupport(params) {
|
|
1318
1315
|
if (!canIUse("isNativeSupport")) {
|
|
1319
1316
|
return {
|
|
@@ -1325,7 +1322,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1325
1322
|
}
|
|
1326
1323
|
|
|
1327
1324
|
// src/api/call-host-method.ts
|
|
1328
|
-
var commands7 =
|
|
1325
|
+
var commands7 = Ir();
|
|
1329
1326
|
async function callHostMethod(params) {
|
|
1330
1327
|
if (!canIUse("callHostMethod")) {
|
|
1331
1328
|
return {
|
|
@@ -1337,7 +1334,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1337
1334
|
}
|
|
1338
1335
|
|
|
1339
1336
|
// src/api/track.ts
|
|
1340
|
-
var commands8 =
|
|
1337
|
+
var commands8 = Ir();
|
|
1341
1338
|
async function track2(params) {
|
|
1342
1339
|
if (!canIUse("track")) {
|
|
1343
1340
|
return {
|
|
@@ -1355,7 +1352,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1355
1352
|
* @private
|
|
1356
1353
|
* Instance for executing commands. Intended for internal SDK use.
|
|
1357
1354
|
*/
|
|
1358
|
-
this.commands =
|
|
1355
|
+
this.commands = Ir();
|
|
1359
1356
|
/**
|
|
1360
1357
|
* @private
|
|
1361
1358
|
* Event emitter instance for handling internal events. Intended for internal SDK use.
|
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.2.
|
|
4
|
+
"version": "1.2.5",
|
|
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.2.
|
|
11
|
-
"@jolibox/types": "1.2.
|
|
10
|
+
"@jolibox/common": "1.2.5",
|
|
11
|
+
"@jolibox/types": "1.2.5"
|
|
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.2.
|
|
3
|
+
> @jolibox/sdk@1.2.5 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/sdk@1.2.
|
|
7
|
+
> @jolibox/sdk@1.2.5 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.2.
|
|
11
|
+
> @jolibox/sdk@1.2.5 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.2.
|
|
15
|
+
> @jolibox/sdk@1.2.5 build:iife
|
|
16
16
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
|
|
17
17
|
|
package/src/loader/h5.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getH5ApiHost, getOriginalLocalStorage } from '@jolibox/common';
|
|
2
2
|
import { compare, major } from './version';
|
|
3
3
|
import { track, trackPerformance } from '../utils/report';
|
|
4
4
|
import { InternalJSModuleEvalError, InternalJSModuleFetchError } from '@jolibox/common';
|
|
@@ -30,7 +30,7 @@ const expired = (now: number, prev: number) =>
|
|
|
30
30
|
now > prev && Math.abs(now - prev) / (1000 * 60 * 60 * 24) >= 7;
|
|
31
31
|
|
|
32
32
|
async function fetchCurrentRemoteScript() {
|
|
33
|
-
const host =
|
|
33
|
+
const host = getH5ApiHost(testMode);
|
|
34
34
|
const path = `${host}/api/fe-configs/js-sdk/version-metadata`;
|
|
35
35
|
|
|
36
36
|
try {
|