@jolibox/sdk 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/package-deps_build.json +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +1 -1
- package/package.json +3 -3
- package/sdk.build.log +4 -4
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"packages/sdk/.eslintrc.js": "c11c589d14fe58bf4d37d259d8323b193bab6092",
|
|
5
5
|
"packages/sdk/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
|
|
6
6
|
"packages/sdk/esbuild.config.js": "1725a85515499085a7c9799b834c6f632073401c",
|
|
7
|
-
"packages/sdk/package.json": "
|
|
7
|
+
"packages/sdk/package.json": "1417808cd419cc1725c03c54e0b4cae531a912d6",
|
|
8
8
|
"packages/sdk/src/__tests__/index.test.ts": "f22e0c0741297803ac3ec016b1dcc166cd2248bd",
|
|
9
9
|
"packages/sdk/src/api/__tests__/canIUse.test.ts": "300e4de3768f9510e956050d326d4977bc621f34",
|
|
10
10
|
"packages/sdk/src/api/call-host-method.ts": "e373cd15fe1d9d1a86c3276545017c49e954c223",
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var U=Object.defineProperty,vt=Object.defineProperties,yt=Object.getOwnPropertyDescriptor,_t=Object.getOwnPropertyDescriptors,St=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable;var Se=(e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,C=(e,t)=>{for(var r in t||(t={}))be.call(t,r)&&Se(e,r,t[r]);if(_e)for(var r of _e(t))bt.call(t,r)&&Se(e,r,t[r]);return e},O=(e,t)=>vt(e,_t(t));var Rt=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0})},xt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of St(t))!be.call(e,o)&&o!==r&&U(e,o,{get:()=>t[o],enumerable:!(n=yt(t,o))||n.enumerable});return e};var It=e=>xt(U({},"__esModule",{value:!0}),e);var d=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});var Cr={};Rt(Cr,{JoliboxSDK:()=>Y});module.exports=It(Cr);if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var re=Object.defineProperty,wt=Object.defineProperties,Tt=Object.getOwnPropertyDescriptor,Lt=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertySymbols,At=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable,xe=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pt=(e,t)=>{for(var r in t||(t={}))At.call(t,r)&&xe(e,r,t[r]);if(Re)for(var r of Re(t))Dt.call(t,r)&&xe(e,r,t[r]);return e},Ut=(e,t)=>wt(e,Lt(t)),Ct=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},Te=(e,t,r,n)=>{for(var o=n>1?void 0:n?Tt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&re(t,r,o),o},Ot=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function kt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ne(e){return typeof e=="string"}function Le(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Nt(e){return typeof e=="undefined"}function Kt(e){return Nt(e)||e===null}function Mt(e){return typeof e=="function"}function Ae(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var jt=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(jt||{}),M=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},De=class extends M{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Pe=class extends De{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends De{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var j=class extends M{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Jt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Jt});var Q=Symbol.for("Jolibox.canIUseMap"),Ft={};globalThis[Q]||(globalThis[Q]=Ft);var Ue={get config(){return globalThis[Q]}};var Ie=Symbol.for("Jolibox.canIUseMap.native"),Bt={};globalThis[Ie]||(globalThis[Ie]=Bt);function oe(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var se=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(se||{}),ie=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ie||{}),Vt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Vt||{}),we=["name","params"],$t=["name","type","location","target","extra","timestamp","userId"],Ht=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function N(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Gt(e){let t=e.location?N(e.location,we):null,r=e.target?N(e.target,we):null;return N(Ut(Pt({},e),{location:t,target:r}),$t)}function Ce(e){let t=e.events.map(n=>Gt(n)),r=N(e.device,Ht);return[e.protocolVersion,t,r,e.project]}var Wt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function ae(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}ae();var _=typeof window=="undefined",ce=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),k={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},zt=()=>k.isiOS?"iOS":k.isAndroid?"Android":k.isMac?"Mac":k.isFacebook?"Facebook":"PC",Yt="device_id",qt="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Wt()),window.__joliboxLocalStorage__.getItem(e)),Qt=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe(Yt),Xt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(qt),Zt=e=>e.charAt(0).toUpperCase()+e.slice(1),er=()=>{var e;let t=new URLSearchParams(window.location.search);return Zt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},ke=e=>{if(ce())return window.navigator.userAgent;let t="JoliboxWebSDK",r=zt(),n=navigator.language,o=Qt(),s=Xt();return`${t} (${er()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function Ne(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function tr(e){return Ne("api","stg-api",e)}function Ke(e){return`https://${tr(e)}`}function rr(e){return Ne("collect","stg-collect",e)}function Me(e){return`https://${rr(e)}`}var X=class Z{constructor(t){this.element=t,this.next=Z.Undefined,this.prev=Z.Undefined}};X.Undefined=new X(void 0);var m=X,nr=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},or=0,I=class{constructor(e){this.value=e,this.id=or++}},w=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,v,ve;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ye=this._listeners.indexOf(l);ye>=0&&(this._listeners.splice(ye,1),this._size--,this._size===0&&((ve=(v=this.options)==null?void 0:v.onDidRemoveLastListener)==null||ve.call(v)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},le=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new nr,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},ee={};Ct(ee,{None:()=>sr,filter:()=>ar,once:()=>je,toPromise:()=>ir});var sr=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function ir(e){return new Promise(t=>je(e)(t))}function je(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function ar(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var q=Symbol.for("Jolibox.hostEmitter"),cr=()=>{let e=new le;return globalThis[q]||(globalThis[q]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[q]},S=cr();function lr(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)dr(e[n],t[n])}function dr(e,t){if(ne(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Mt(t)){try{if(e instanceof t)return}catch(r){}if(!Kt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var K=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return lr(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};K=Te([Ae],K);var te=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new K,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=kt(3e4)),this._starActivation}executeCommand(e,...t){return Ot(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),ee.toPromise(ee.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};te=Te([Ae],te);var Je=Symbol.for("Jolibox.commands");function mr(){return typeof globalThis!="undefined"?globalThis[Je]:void 0}function ur(e){typeof globalThis!="undefined"&&(globalThis[Je]=e)}function u(e=!1){let t=mr();if(!e&&t)return t;let r=new K,n=new te,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return ur(o),o}var J=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function pr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function fr(){return{platform:1e3,os:"h5",appVersion:"1.2.1",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.1",extra:{}}}var hr=()=>{var t;return Me((t=J)!=null?t:!1)},gr=hr(),Be=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Fe;(Fe=AbortSignal.timeout)!=null||(AbortSignal.timeout=Be);var Er=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},vr=Er(),yr=e=>d(void 0,null,function*(){try{let r=`${gr}/report`,n=ke("1.2.1"),o=vr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Be(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:se.ErrorTrace,location:pr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=fr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ie.WebSDK},s=Ce(o);yield yr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var _r=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=_r(),Ve=u(),de=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof M?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ve.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},y=de;window.addEventListener("unhandledrejection",de.bind(void 0));window.addEventListener("error",de.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Ve.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var me=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(me(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=me(e),{major:i,minor:c,patch:a,prerelease:l}=me(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var $e=u(),F=(e,t)=>{$e.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{$e.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ae();var We="jolibox-sdk-loadermeta",Ge,P=JSON.parse((Ge=window.__joliboxLocalStorage__.getItem(We))!=null?Ge:"{}"),ue=Date.now(),He=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Sr(){return d(this,null,function*(){let t=`${Ke(J)}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=O(C({},P),{timestamp:ue});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=O(C({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=O(C({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(We,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var ze=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!He(ue,l)&&A(a)==t&&D(a,r)>=0&&(n=pe(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new Pe(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();F("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let v=document.createElement("script");v.type="text/javascript",v.innerHTML=l,document.head.appendChild(v),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!He(ue,h)&&A(l)==t&&D(l,r)>=0&&(o=fe(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),Sr()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var Ye=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>d(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){y(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();F("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new T(`module load failed ${o}`))}}};var br="1.2.1",B=br,Ze=A(B),et=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Rr=et?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,he="https://jsdelivr.jolibox.com";var qe=window.document.currentScript;qe&&(he=new URL(qe.src).origin);var pe=(e,t)=>`${t!=null?t:he}/npm/@jolibox/bootstrap@${e}/dist/index.js`,fe=(e,t)=>`${t!=null?t:he}/npm/@jolibox/implement@${e}/dist/index.js`,xr=e=>/^\d+\.\d+\.\d+$/.test(e),tt=xr(B)?Ze:B,Qe=pe(tt),Xe=fe(tt);function Ir(){et?Ye(Rr,{bootstrapUrl:Qe,implementUrl:Xe})():ze({bootstrapUrl:Qe,implementUrl:Xe,currentMajorVersion:Ze,currentVersion:B})()}Ir();var wr=u();function rt(){return wr.excuteCommandSync("API.getSystemInfoSync")}function nt(e,t){var r;return(r=Ue.config[e])==null?void 0:r[t]}function ot(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var it="1.2.1";function f(e){let[t,...r]=e.split(":"),n=nt(ce()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||oe(it,o,"<")?!1:r.length===0?!0:st(n,r)||st(n.properties,r)}function st(e,t){if(!e)return!1;let r=ot(e,t);return r?Le(r)?!0:ne(r)?oe(it,r,">="):!1:!1}var at=u();function ct(){return d(this,null,function*(){return f("login")?yield at.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function lt(){return d(this,null,function*(){return f("checkSession")?yield at.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Tr=u();function dt(e){return d(this,null,function*(){return f("request")?yield Tr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ge=["onI18nChanged","onBackPress"],mt=(e,t)=>{if(!ge.includes(e)){y(new j(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},ut=(e,t)=>{if(!ge.includes(e)){y(new j(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},pt=(e,t)=>{if(!ge.includes(e)){y(new j(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Lr=u();function ft(e){return d(this,null,function*(){return f("isNativeSupport")?yield Lr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ar=u();function ht(e){return d(this,null,function*(){return f("callHostMethod")?yield Ar.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Dr=u();function gt(e){return d(this,null,function*(){return f("track")?yield Dr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new le}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var Ee=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},Et=window.JoliboxRuntime||Ee;var Pr="LifecycleSDK.onReady",V=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Pr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var $=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var H=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return d(this,null,function*(){})}};var G=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var W=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:i})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Ur=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],z=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Ur.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var E=class E{constructor(){this.jssdkVersion="1.2.1";this.runtime=new Et;this.ads=new H;this.lifecycle=new V;this.storage=new $;this.keyboard=new G;this.task=new W;this.router=new z;this.getSystemInfoSync=rt.bind(this);this.canIUse=f.bind(this);this.login=ct.bind(this);this.checkSession=lt.bind(this);this.request=dt.bind(this);this.on=mt.bind(this);this.off=ut.bind(this);this.once=pt.bind(this);this.isNativeSupport=ft.bind(this);this.callHostMethod=ht.bind(this);this.track=gt.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var Y=E;window.JoliboxSDK=Y;
|
|
1
|
+
"use strict";var U=Object.defineProperty,vt=Object.defineProperties,yt=Object.getOwnPropertyDescriptor,_t=Object.getOwnPropertyDescriptors,St=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable;var Se=(e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,C=(e,t)=>{for(var r in t||(t={}))be.call(t,r)&&Se(e,r,t[r]);if(_e)for(var r of _e(t))bt.call(t,r)&&Se(e,r,t[r]);return e},O=(e,t)=>vt(e,_t(t));var Rt=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0})},xt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of St(t))!be.call(e,o)&&o!==r&&U(e,o,{get:()=>t[o],enumerable:!(n=yt(t,o))||n.enumerable});return e};var It=e=>xt(U({},"__esModule",{value:!0}),e);var d=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});var Cr={};Rt(Cr,{JoliboxSDK:()=>Y});module.exports=It(Cr);if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var re=Object.defineProperty,wt=Object.defineProperties,Tt=Object.getOwnPropertyDescriptor,Lt=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertySymbols,At=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable,xe=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pt=(e,t)=>{for(var r in t||(t={}))At.call(t,r)&&xe(e,r,t[r]);if(Re)for(var r of Re(t))Dt.call(t,r)&&xe(e,r,t[r]);return e},Ut=(e,t)=>wt(e,Lt(t)),Ct=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},Te=(e,t,r,n)=>{for(var o=n>1?void 0:n?Tt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&re(t,r,o),o},Ot=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function kt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ne(e){return typeof e=="string"}function Le(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Nt(e){return typeof e=="undefined"}function Kt(e){return Nt(e)||e===null}function Mt(e){return typeof e=="function"}function Ae(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var jt=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(jt||{}),M=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},De=class extends M{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Pe=class extends De{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends De{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var j=class extends M{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Jt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Jt});var Q=Symbol.for("Jolibox.canIUseMap"),Ft={};globalThis[Q]||(globalThis[Q]=Ft);var Ue={get config(){return globalThis[Q]}};var Ie=Symbol.for("Jolibox.canIUseMap.native"),Bt={};globalThis[Ie]||(globalThis[Ie]=Bt);function oe(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var se=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(se||{}),ie=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ie||{}),Vt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Vt||{}),we=["name","params"],$t=["name","type","location","target","extra","timestamp","userId"],Ht=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function N(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Gt(e){let t=e.location?N(e.location,we):null,r=e.target?N(e.target,we):null;return N(Ut(Pt({},e),{location:t,target:r}),$t)}function Ce(e){let t=e.events.map(n=>Gt(n)),r=N(e.device,Ht);return[e.protocolVersion,t,r,e.project]}var Wt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function ae(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}ae();var _=typeof window=="undefined",ce=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),k={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},zt=()=>k.isiOS?"iOS":k.isAndroid?"Android":k.isMac?"Mac":k.isFacebook?"Facebook":"PC",Yt="device_id",qt="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Wt()),window.__joliboxLocalStorage__.getItem(e)),Qt=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe(Yt),Xt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(qt),Zt=e=>e.charAt(0).toUpperCase()+e.slice(1),er=()=>{var e;let t=new URLSearchParams(window.location.search);return Zt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},ke=e=>{if(ce())return window.navigator.userAgent;let t="JoliboxWebSDK",r=zt(),n=navigator.language,o=Qt(),s=Xt();return`${t} (${er()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function Ne(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function tr(e){return Ne("api","stg-api",e)}function Ke(e){return`https://${tr(e)}`}function rr(e){return Ne("collect","stg-collect",e)}function Me(e){return`https://${rr(e)}`}var X=class Z{constructor(t){this.element=t,this.next=Z.Undefined,this.prev=Z.Undefined}};X.Undefined=new X(void 0);var m=X,nr=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},or=0,I=class{constructor(e){this.value=e,this.id=or++}},w=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,v,ve;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ye=this._listeners.indexOf(l);ye>=0&&(this._listeners.splice(ye,1),this._size--,this._size===0&&((ve=(v=this.options)==null?void 0:v.onDidRemoveLastListener)==null||ve.call(v)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},le=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new nr,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},ee={};Ct(ee,{None:()=>sr,filter:()=>ar,once:()=>je,toPromise:()=>ir});var sr=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function ir(e){return new Promise(t=>je(e)(t))}function je(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function ar(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var q=Symbol.for("Jolibox.hostEmitter"),cr=()=>{let e=new le;return globalThis[q]||(globalThis[q]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[q]},S=cr();function lr(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)dr(e[n],t[n])}function dr(e,t){if(ne(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Mt(t)){try{if(e instanceof t)return}catch(r){}if(!Kt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var K=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return lr(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};K=Te([Ae],K);var te=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new K,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=kt(3e4)),this._starActivation}executeCommand(e,...t){return Ot(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),ee.toPromise(ee.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};te=Te([Ae],te);var Je=Symbol.for("Jolibox.commands");function mr(){return typeof globalThis!="undefined"?globalThis[Je]:void 0}function ur(e){typeof globalThis!="undefined"&&(globalThis[Je]=e)}function u(e=!1){let t=mr();if(!e&&t)return t;let r=new K,n=new te,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return ur(o),o}var J=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function pr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function fr(){return{platform:1e3,os:"h5",appVersion:"1.2.2",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.2",extra:{}}}var hr=()=>{var t;return Me((t=J)!=null?t:!1)},gr=hr(),Be=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Fe;(Fe=AbortSignal.timeout)!=null||(AbortSignal.timeout=Be);var Er=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},vr=Er(),yr=e=>d(void 0,null,function*(){try{let r=`${gr}/report`,n=ke("1.2.2"),o=vr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Be(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:se.ErrorTrace,location:pr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=fr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ie.WebSDK},s=Ce(o);yield yr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var _r=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=_r(),Ve=u(),de=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof M?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ve.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},y=de;window.addEventListener("unhandledrejection",de.bind(void 0));window.addEventListener("error",de.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Ve.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var me=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(me(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=me(e),{major:i,minor:c,patch:a,prerelease:l}=me(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var $e=u(),F=(e,t)=>{$e.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{$e.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ae();var We="jolibox-sdk-loadermeta",Ge,P=JSON.parse((Ge=window.__joliboxLocalStorage__.getItem(We))!=null?Ge:"{}"),ue=Date.now(),He=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Sr(){return d(this,null,function*(){let t=`${Ke(J)}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=O(C({},P),{timestamp:ue});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=O(C({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=O(C({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(We,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var ze=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!He(ue,l)&&A(a)==t&&D(a,r)>=0&&(n=pe(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new Pe(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();F("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let v=document.createElement("script");v.type="text/javascript",v.innerHTML=l,document.head.appendChild(v),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!He(ue,h)&&A(l)==t&&D(l,r)>=0&&(o=fe(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),Sr()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var Ye=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>d(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){y(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();F("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new T(`module load failed ${o}`))}}};var br="1.2.2",B=br,Ze=A(B),et=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Rr=et?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,he="https://jsdelivr.jolibox.com";var qe=window.document.currentScript;qe&&(he=new URL(qe.src).origin);var pe=(e,t)=>`${t!=null?t:he}/npm/@jolibox/bootstrap@${e}/dist/index.js`,fe=(e,t)=>`${t!=null?t:he}/npm/@jolibox/implement@${e}/dist/index.js`,xr=e=>/^\d+\.\d+\.\d+$/.test(e),tt=xr(B)?Ze:B,Qe=pe(tt),Xe=fe(tt);function Ir(){et?Ye(Rr,{bootstrapUrl:Qe,implementUrl:Xe})():ze({bootstrapUrl:Qe,implementUrl:Xe,currentMajorVersion:Ze,currentVersion:B})()}Ir();var wr=u();function rt(){return wr.excuteCommandSync("API.getSystemInfoSync")}function nt(e,t){var r;return(r=Ue.config[e])==null?void 0:r[t]}function ot(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var it="1.2.2";function f(e){let[t,...r]=e.split(":"),n=nt(ce()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||oe(it,o,"<")?!1:r.length===0?!0:st(n,r)||st(n.properties,r)}function st(e,t){if(!e)return!1;let r=ot(e,t);return r?Le(r)?!0:ne(r)?oe(it,r,">="):!1:!1}var at=u();function ct(){return d(this,null,function*(){return f("login")?yield at.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function lt(){return d(this,null,function*(){return f("checkSession")?yield at.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Tr=u();function dt(e){return d(this,null,function*(){return f("request")?yield Tr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ge=["onI18nChanged","onBackPress"],mt=(e,t)=>{if(!ge.includes(e)){y(new j(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},ut=(e,t)=>{if(!ge.includes(e)){y(new j(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},pt=(e,t)=>{if(!ge.includes(e)){y(new j(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Lr=u();function ft(e){return d(this,null,function*(){return f("isNativeSupport")?yield Lr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ar=u();function ht(e){return d(this,null,function*(){return f("callHostMethod")?yield Ar.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Dr=u();function gt(e){return d(this,null,function*(){return f("track")?yield Dr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new le}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var Ee=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},Et=window.JoliboxRuntime||Ee;var Pr="LifecycleSDK.onReady",V=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Pr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var $=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var H=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return d(this,null,function*(){})}};var G=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var W=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:i})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Ur=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],z=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Ur.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var E=class E{constructor(){this.jssdkVersion="1.2.2";this.runtime=new Et;this.ads=new H;this.lifecycle=new V;this.storage=new $;this.keyboard=new G;this.task=new W;this.router=new z;this.getSystemInfoSync=rt.bind(this);this.canIUse=f.bind(this);this.login=ct.bind(this);this.checkSession=lt.bind(this);this.request=dt.bind(this);this.on=mt.bind(this);this.off=ut.bind(this);this.once=pt.bind(this);this.isNativeSupport=ft.bind(this);this.callHostMethod=ht.bind(this);this.track=gt.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var Y=E;window.JoliboxSDK=Y;
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var gt=Object.defineProperty,Et=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var yt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&_e(e,r,t[r]);if(ye)for(var r of ye(t))_t.call(t,r)&&_e(e,r,t[r]);return e},C=(e,t)=>Et(e,vt(t));var d=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var ee=Object.defineProperty,St=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,Rt=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wt=(e,t)=>{for(var r in t||(t={}))xt.call(t,r)&&be(e,r,t[r]);if(Se)for(var r of Se(t))It.call(t,r)&&be(e,r,t[r]);return e},Tt=(e,t)=>St(e,Rt(t)),Lt=(e,t)=>{for(var r in t)ee(e,r,{get:t[r],enumerable:!0})},Ie=(e,t,r,n)=>{for(var o=n>1?void 0:n?bt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&ee(t,r,o),o},At=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Dt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function te(e){return typeof e=="string"}function we(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Pt(e){return typeof e=="undefined"}function Ut(e){return Pt(e)||e===null}function Ct(e){return typeof e=="function"}function Te(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Ot=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Ot||{}),K=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Le=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ae=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var kt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:kt});var Y=Symbol.for("Jolibox.canIUseMap"),Nt={};globalThis[Y]||(globalThis[Y]=Nt);var De={get config(){return globalThis[Y]}};var Re=Symbol.for("Jolibox.canIUseMap.native"),Kt={};globalThis[Re]||(globalThis[Re]=Kt);function re(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var ne=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ne||{}),oe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(oe||{}),Mt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Mt||{}),xe=["name","params"],jt=["name","type","location","target","extra","timestamp","userId"],Jt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Ft(e){let t=e.location?k(e.location,xe):null,r=e.target?k(e.target,xe):null;return k(Tt(wt({},e),{location:t,target:r}),jt)}function Pe(e){let t=e.events.map(n=>Ft(n)),r=k(e.device,Jt);return[e.protocolVersion,t,r,e.project]}var Bt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function se(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}se();var _=typeof window=="undefined",ie=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Vt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",$t="device_id",Ht="advertising_id",Ue=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Bt()),window.__joliboxLocalStorage__.getItem(e)),Gt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ue($t),Wt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ue(Ht),zt=e=>e.charAt(0).toUpperCase()+e.slice(1),Yt=()=>{var e;let t=new URLSearchParams(window.location.search);return zt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ce=e=>{if(ie())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,o=Gt(),s=Wt();return`${t} (${Yt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function Oe(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function qt(e){return Oe("api","stg-api",e)}function ke(e){return`https://${qt(e)}`}function Qt(e){return Oe("collect","stg-collect",e)}function Ne(e){return`https://${Qt(e)}`}var q=class Q{constructor(t){this.element=t,this.next=Q.Undefined,this.prev=Q.Undefined}};q.Undefined=new q(void 0);var m=q,Xt=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},Zt=0,I=class{constructor(e){this.value=e,this.id=Zt++}},w=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,v,Ee;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ve=this._listeners.indexOf(l);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((Ee=(v=this.options)==null?void 0:v.onDidRemoveLastListener)==null||Ee.call(v)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ae=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Xt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},X={};Lt(X,{None:()=>er,filter:()=>rr,once:()=>Ke,toPromise:()=>tr});var er=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function tr(e){return new Promise(t=>Ke(e)(t))}function Ke(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function rr(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var z=Symbol.for("Jolibox.hostEmitter"),nr=()=>{let e=new ae;return globalThis[z]||(globalThis[z]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[z]},S=nr();function or(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)sr(e[n],t[n])}function sr(e,t){if(te(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ct(t)){try{if(e instanceof t)return}catch(r){}if(!Ut(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var N=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return or(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};N=Ie([Te],N);var Z=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new N,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Dt(3e4)),this._starActivation}executeCommand(e,...t){return At(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),X.toPromise(X.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};Z=Ie([Te],Z);var Me=Symbol.for("Jolibox.commands");function ir(){return typeof globalThis!="undefined"?globalThis[Me]:void 0}function ar(e){typeof globalThis!="undefined"&&(globalThis[Me]=e)}function u(e=!1){let t=ir();if(!e&&t)return t;let r=new N,n=new Z,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return ar(o),o}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function cr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function lr(){return{platform:1e3,os:"h5",appVersion:"1.2.1",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.1",extra:{}}}var dr=()=>{var t;return Ne((t=j)!=null?t:!1)},mr=dr(),Je=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},je;(je=AbortSignal.timeout)!=null||(AbortSignal.timeout=Je);var ur=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},pr=ur(),fr=e=>d(void 0,null,function*(){try{let r=`${mr}/report`,n=Ce("1.2.1"),o=pr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Je(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:ne.ErrorTrace,location:cr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=lr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:oe.WebSDK},s=Pe(o);yield fr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var hr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=hr(),Fe=u(),ce=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},y=ce;window.addEventListener("unhandledrejection",ce.bind(void 0));window.addEventListener("error",ce.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var le=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(le(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=le(e),{major:i,minor:c,patch:a,prerelease:l}=le(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var Be=u(),J=(e,t)=>{Be.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};se();var He="jolibox-sdk-loadermeta",$e,P=JSON.parse(($e=window.__joliboxLocalStorage__.getItem(He))!=null?$e:"{}"),de=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function gr(){return d(this,null,function*(){let t=`${ke(j)}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=C(U({},P),{timestamp:de});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=C(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=C(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(He,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ge=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!Ve(de,l)&&A(a)==t&&D(a,r)>=0&&(n=me(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new Ae(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let v=document.createElement("script");v.type="text/javascript",v.innerHTML=l,document.head.appendChild(v),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!Ve(de,h)&&A(l)==t&&D(l,r)>=0&&(o=ue(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),gr()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var We=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>d(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){y(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new T(`module load failed ${o}`))}}};var Er="1.2.1",F=Er,Qe=A(F),Xe=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),vr=Xe?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,pe="https://jsdelivr.jolibox.com";var ze=window.document.currentScript;ze&&(pe=new URL(ze.src).origin);var me=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,ue=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/implement@${e}/dist/index.js`,yr=e=>/^\d+\.\d+\.\d+$/.test(e),Ze=yr(F)?Qe:F,Ye=me(Ze),qe=ue(Ze);function _r(){Xe?We(vr,{bootstrapUrl:Ye,implementUrl:qe})():Ge({bootstrapUrl:Ye,implementUrl:qe,currentMajorVersion:Qe,currentVersion:F})()}_r();var Sr=u();function et(){return Sr.excuteCommandSync("API.getSystemInfoSync")}function tt(e,t){var r;return(r=De.config[e])==null?void 0:r[t]}function rt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var ot="1.2.1";function f(e){let[t,...r]=e.split(":"),n=tt(ie()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||re(ot,o,"<")?!1:r.length===0?!0:nt(n,r)||nt(n.properties,r)}function nt(e,t){if(!e)return!1;let r=rt(e,t);return r?we(r)?!0:te(r)?re(ot,r,">="):!1:!1}var st=u();function it(){return d(this,null,function*(){return f("login")?yield st.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function at(){return d(this,null,function*(){return f("checkSession")?yield st.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var br=u();function ct(e){return d(this,null,function*(){return f("request")?yield br.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var fe=["onI18nChanged","onBackPress"],lt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},dt=(e,t)=>{if(!fe.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},mt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Rr=u();function ut(e){return d(this,null,function*(){return f("isNativeSupport")?yield Rr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var xr=u();function pt(e){return d(this,null,function*(){return f("callHostMethod")?yield xr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Ir=u();function ft(e){return d(this,null,function*(){return f("track")?yield Ir.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new ae}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var he=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},ht=window.JoliboxRuntime||he;var wr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(wr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return d(this,null,function*(){})}};var H=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var G=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:i})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Tr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],W=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Tr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var E=class E{constructor(){this.jssdkVersion="1.2.1";this.runtime=new ht;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new H;this.task=new G;this.router=new W;this.getSystemInfoSync=et.bind(this);this.canIUse=f.bind(this);this.login=it.bind(this);this.checkSession=at.bind(this);this.request=ct.bind(this);this.on=lt.bind(this);this.off=dt.bind(this);this.once=mt.bind(this);this.isNativeSupport=ut.bind(this);this.callHostMethod=pt.bind(this);this.track=ft.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var ge=E;window.JoliboxSDK=ge;export{ge as JoliboxSDK};
|
|
1
|
+
var gt=Object.defineProperty,Et=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var yt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&_e(e,r,t[r]);if(ye)for(var r of ye(t))_t.call(t,r)&&_e(e,r,t[r]);return e},C=(e,t)=>Et(e,vt(t));var d=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var ee=Object.defineProperty,St=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,Rt=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wt=(e,t)=>{for(var r in t||(t={}))xt.call(t,r)&&be(e,r,t[r]);if(Se)for(var r of Se(t))It.call(t,r)&&be(e,r,t[r]);return e},Tt=(e,t)=>St(e,Rt(t)),Lt=(e,t)=>{for(var r in t)ee(e,r,{get:t[r],enumerable:!0})},Ie=(e,t,r,n)=>{for(var o=n>1?void 0:n?bt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&ee(t,r,o),o},At=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Dt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function te(e){return typeof e=="string"}function we(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Pt(e){return typeof e=="undefined"}function Ut(e){return Pt(e)||e===null}function Ct(e){return typeof e=="function"}function Te(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Ot=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Ot||{}),K=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Le=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ae=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var kt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:kt});var Y=Symbol.for("Jolibox.canIUseMap"),Nt={};globalThis[Y]||(globalThis[Y]=Nt);var De={get config(){return globalThis[Y]}};var Re=Symbol.for("Jolibox.canIUseMap.native"),Kt={};globalThis[Re]||(globalThis[Re]=Kt);function re(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var ne=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ne||{}),oe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(oe||{}),Mt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Mt||{}),xe=["name","params"],jt=["name","type","location","target","extra","timestamp","userId"],Jt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Ft(e){let t=e.location?k(e.location,xe):null,r=e.target?k(e.target,xe):null;return k(Tt(wt({},e),{location:t,target:r}),jt)}function Pe(e){let t=e.events.map(n=>Ft(n)),r=k(e.device,Jt);return[e.protocolVersion,t,r,e.project]}var Bt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function se(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}se();var _=typeof window=="undefined",ie=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Vt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",$t="device_id",Ht="advertising_id",Ue=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Bt()),window.__joliboxLocalStorage__.getItem(e)),Gt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ue($t),Wt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ue(Ht),zt=e=>e.charAt(0).toUpperCase()+e.slice(1),Yt=()=>{var e;let t=new URLSearchParams(window.location.search);return zt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ce=e=>{if(ie())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,o=Gt(),s=Wt();return`${t} (${Yt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function Oe(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function qt(e){return Oe("api","stg-api",e)}function ke(e){return`https://${qt(e)}`}function Qt(e){return Oe("collect","stg-collect",e)}function Ne(e){return`https://${Qt(e)}`}var q=class Q{constructor(t){this.element=t,this.next=Q.Undefined,this.prev=Q.Undefined}};q.Undefined=new q(void 0);var m=q,Xt=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},Zt=0,I=class{constructor(e){this.value=e,this.id=Zt++}},w=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,v,Ee;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ve=this._listeners.indexOf(l);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((Ee=(v=this.options)==null?void 0:v.onDidRemoveLastListener)==null||Ee.call(v)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ae=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Xt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},X={};Lt(X,{None:()=>er,filter:()=>rr,once:()=>Ke,toPromise:()=>tr});var er=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function tr(e){return new Promise(t=>Ke(e)(t))}function Ke(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function rr(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var z=Symbol.for("Jolibox.hostEmitter"),nr=()=>{let e=new ae;return globalThis[z]||(globalThis[z]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[z]},S=nr();function or(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)sr(e[n],t[n])}function sr(e,t){if(te(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ct(t)){try{if(e instanceof t)return}catch(r){}if(!Ut(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var N=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return or(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};N=Ie([Te],N);var Z=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new N,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Dt(3e4)),this._starActivation}executeCommand(e,...t){return At(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),X.toPromise(X.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};Z=Ie([Te],Z);var Me=Symbol.for("Jolibox.commands");function ir(){return typeof globalThis!="undefined"?globalThis[Me]:void 0}function ar(e){typeof globalThis!="undefined"&&(globalThis[Me]=e)}function u(e=!1){let t=ir();if(!e&&t)return t;let r=new N,n=new Z,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return ar(o),o}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function cr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function lr(){return{platform:1e3,os:"h5",appVersion:"1.2.2",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.2",extra:{}}}var dr=()=>{var t;return Ne((t=j)!=null?t:!1)},mr=dr(),Je=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},je;(je=AbortSignal.timeout)!=null||(AbortSignal.timeout=Je);var ur=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},pr=ur(),fr=e=>d(void 0,null,function*(){try{let r=`${mr}/report`,n=Ce("1.2.2"),o=pr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Je(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:ne.ErrorTrace,location:cr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=lr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:oe.WebSDK},s=Pe(o);yield fr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var hr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=hr(),Fe=u(),ce=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},y=ce;window.addEventListener("unhandledrejection",ce.bind(void 0));window.addEventListener("error",ce.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var le=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(le(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=le(e),{major:i,minor:c,patch:a,prerelease:l}=le(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var Be=u(),J=(e,t)=>{Be.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};se();var He="jolibox-sdk-loadermeta",$e,P=JSON.parse(($e=window.__joliboxLocalStorage__.getItem(He))!=null?$e:"{}"),de=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function gr(){return d(this,null,function*(){let t=`${ke(j)}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=C(U({},P),{timestamp:de});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=C(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=C(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(He,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ge=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!Ve(de,l)&&A(a)==t&&D(a,r)>=0&&(n=me(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new Ae(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let v=document.createElement("script");v.type="text/javascript",v.innerHTML=l,document.head.appendChild(v),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!Ve(de,h)&&A(l)==t&&D(l,r)>=0&&(o=ue(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),gr()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var We=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>d(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){y(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new T(`module load failed ${o}`))}}};var Er="1.2.2",F=Er,Qe=A(F),Xe=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),vr=Xe?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,pe="https://jsdelivr.jolibox.com";var ze=window.document.currentScript;ze&&(pe=new URL(ze.src).origin);var me=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,ue=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/implement@${e}/dist/index.js`,yr=e=>/^\d+\.\d+\.\d+$/.test(e),Ze=yr(F)?Qe:F,Ye=me(Ze),qe=ue(Ze);function _r(){Xe?We(vr,{bootstrapUrl:Ye,implementUrl:qe})():Ge({bootstrapUrl:Ye,implementUrl:qe,currentMajorVersion:Qe,currentVersion:F})()}_r();var Sr=u();function et(){return Sr.excuteCommandSync("API.getSystemInfoSync")}function tt(e,t){var r;return(r=De.config[e])==null?void 0:r[t]}function rt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var ot="1.2.2";function f(e){let[t,...r]=e.split(":"),n=tt(ie()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||re(ot,o,"<")?!1:r.length===0?!0:nt(n,r)||nt(n.properties,r)}function nt(e,t){if(!e)return!1;let r=rt(e,t);return r?we(r)?!0:te(r)?re(ot,r,">="):!1:!1}var st=u();function it(){return d(this,null,function*(){return f("login")?yield st.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function at(){return d(this,null,function*(){return f("checkSession")?yield st.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var br=u();function ct(e){return d(this,null,function*(){return f("request")?yield br.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var fe=["onI18nChanged","onBackPress"],lt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},dt=(e,t)=>{if(!fe.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},mt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Rr=u();function ut(e){return d(this,null,function*(){return f("isNativeSupport")?yield Rr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var xr=u();function pt(e){return d(this,null,function*(){return f("callHostMethod")?yield xr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Ir=u();function ft(e){return d(this,null,function*(){return f("track")?yield Ir.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new ae}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var he=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},ht=window.JoliboxRuntime||he;var wr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(wr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return d(this,null,function*(){})}};var H=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var G=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:i})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Tr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],W=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Tr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var E=class E{constructor(){this.jssdkVersion="1.2.2";this.runtime=new ht;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new H;this.task=new G;this.router=new W;this.getSystemInfoSync=et.bind(this);this.canIUse=f.bind(this);this.login=it.bind(this);this.checkSession=at.bind(this);this.request=ct.bind(this);this.on=lt.bind(this);this.off=dt.bind(this);this.once=mt.bind(this);this.isNativeSupport=ut.bind(this);this.callHostMethod=pt.bind(this);this.track=ft.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var ge=E;window.JoliboxSDK=ge;export{ge as JoliboxSDK};
|
package/dist/index.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var gt=Object.defineProperty,Et=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var yt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&_e(e,r,t[r]);if(ye)for(var r of ye(t))_t.call(t,r)&&_e(e,r,t[r]);return e},C=(e,t)=>Et(e,vt(t));var d=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var ee=Object.defineProperty,St=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,Rt=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wt=(e,t)=>{for(var r in t||(t={}))xt.call(t,r)&&be(e,r,t[r]);if(Se)for(var r of Se(t))It.call(t,r)&&be(e,r,t[r]);return e},Tt=(e,t)=>St(e,Rt(t)),Lt=(e,t)=>{for(var r in t)ee(e,r,{get:t[r],enumerable:!0})},Ie=(e,t,r,n)=>{for(var o=n>1?void 0:n?bt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&ee(t,r,o),o},At=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Dt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function te(e){return typeof e=="string"}function we(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Pt(e){return typeof e=="undefined"}function Ut(e){return Pt(e)||e===null}function Ct(e){return typeof e=="function"}function Te(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Ot=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Ot||{}),K=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Le=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ae=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var kt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:kt});var Y=Symbol.for("Jolibox.canIUseMap"),Nt={};globalThis[Y]||(globalThis[Y]=Nt);var De={get config(){return globalThis[Y]}};var Re=Symbol.for("Jolibox.canIUseMap.native"),Kt={};globalThis[Re]||(globalThis[Re]=Kt);function re(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var ne=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ne||{}),oe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(oe||{}),Mt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Mt||{}),xe=["name","params"],jt=["name","type","location","target","extra","timestamp","userId"],Jt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Ft(e){let t=e.location?k(e.location,xe):null,r=e.target?k(e.target,xe):null;return k(Tt(wt({},e),{location:t,target:r}),jt)}function Pe(e){let t=e.events.map(n=>Ft(n)),r=k(e.device,Jt);return[e.protocolVersion,t,r,e.project]}var Bt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function se(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}se();var _=typeof window=="undefined",ie=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Vt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",$t="device_id",Ht="advertising_id",Ue=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Bt()),window.__joliboxLocalStorage__.getItem(e)),Gt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ue($t),Wt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ue(Ht),zt=e=>e.charAt(0).toUpperCase()+e.slice(1),Yt=()=>{var e;let t=new URLSearchParams(window.location.search);return zt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ce=e=>{if(ie())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,o=Gt(),s=Wt();return`${t} (${Yt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function Oe(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function qt(e){return Oe("api","stg-api",e)}function ke(e){return`https://${qt(e)}`}function Qt(e){return Oe("collect","stg-collect",e)}function Ne(e){return`https://${Qt(e)}`}var q=class Q{constructor(t){this.element=t,this.next=Q.Undefined,this.prev=Q.Undefined}};q.Undefined=new q(void 0);var m=q,Xt=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},Zt=0,I=class{constructor(e){this.value=e,this.id=Zt++}},w=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,v,Ee;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ve=this._listeners.indexOf(l);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((Ee=(v=this.options)==null?void 0:v.onDidRemoveLastListener)==null||Ee.call(v)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ae=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Xt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},X={};Lt(X,{None:()=>er,filter:()=>rr,once:()=>Ke,toPromise:()=>tr});var er=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function tr(e){return new Promise(t=>Ke(e)(t))}function Ke(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function rr(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var z=Symbol.for("Jolibox.hostEmitter"),nr=()=>{let e=new ae;return globalThis[z]||(globalThis[z]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[z]},S=nr();function or(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)sr(e[n],t[n])}function sr(e,t){if(te(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ct(t)){try{if(e instanceof t)return}catch(r){}if(!Ut(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var N=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return or(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};N=Ie([Te],N);var Z=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new N,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Dt(3e4)),this._starActivation}executeCommand(e,...t){return At(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),X.toPromise(X.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};Z=Ie([Te],Z);var Me=Symbol.for("Jolibox.commands");function ir(){return typeof globalThis!="undefined"?globalThis[Me]:void 0}function ar(e){typeof globalThis!="undefined"&&(globalThis[Me]=e)}function u(e=!1){let t=ir();if(!e&&t)return t;let r=new N,n=new Z,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return ar(o),o}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function cr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function lr(){return{platform:1e3,os:"h5",appVersion:"1.2.1",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.1",extra:{}}}var dr=()=>{var t;return Ne((t=j)!=null?t:!1)},mr=dr(),Je=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},je;(je=AbortSignal.timeout)!=null||(AbortSignal.timeout=Je);var ur=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},pr=ur(),fr=e=>d(void 0,null,function*(){try{let r=`${mr}/report`,n=Ce("1.2.1"),o=pr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Je(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:ne.ErrorTrace,location:cr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=lr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:oe.WebSDK},s=Pe(o);yield fr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var hr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=hr(),Fe=u(),ce=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},y=ce;window.addEventListener("unhandledrejection",ce.bind(void 0));window.addEventListener("error",ce.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var le=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(le(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=le(e),{major:i,minor:c,patch:a,prerelease:l}=le(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var Be=u(),J=(e,t)=>{Be.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};se();var He="jolibox-sdk-loadermeta",$e,P=JSON.parse(($e=window.__joliboxLocalStorage__.getItem(He))!=null?$e:"{}"),de=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function gr(){return d(this,null,function*(){let t=`${ke(j)}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=C(U({},P),{timestamp:de});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=C(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=C(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(He,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ge=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!Ve(de,l)&&A(a)==t&&D(a,r)>=0&&(n=me(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new Ae(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let v=document.createElement("script");v.type="text/javascript",v.innerHTML=l,document.head.appendChild(v),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!Ve(de,h)&&A(l)==t&&D(l,r)>=0&&(o=ue(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),gr()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var We=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>d(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){y(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new T(`module load failed ${o}`))}}};var Er="1.2.1",F=Er,Qe=A(F),Xe=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),vr=Xe?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,pe="https://jsdelivr.jolibox.com";var ze=window.document.currentScript;ze&&(pe=new URL(ze.src).origin);var me=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,ue=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/implement@${e}/dist/index.js`,yr=e=>/^\d+\.\d+\.\d+$/.test(e),Ze=yr(F)?Qe:F,Ye=me(Ze),qe=ue(Ze);function _r(){Xe?We(vr,{bootstrapUrl:Ye,implementUrl:qe})():Ge({bootstrapUrl:Ye,implementUrl:qe,currentMajorVersion:Qe,currentVersion:F})()}_r();var Sr=u();function et(){return Sr.excuteCommandSync("API.getSystemInfoSync")}function tt(e,t){var r;return(r=De.config[e])==null?void 0:r[t]}function rt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var ot="1.2.1";function f(e){let[t,...r]=e.split(":"),n=tt(ie()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||re(ot,o,"<")?!1:r.length===0?!0:nt(n,r)||nt(n.properties,r)}function nt(e,t){if(!e)return!1;let r=rt(e,t);return r?we(r)?!0:te(r)?re(ot,r,">="):!1:!1}var st=u();function it(){return d(this,null,function*(){return f("login")?yield st.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function at(){return d(this,null,function*(){return f("checkSession")?yield st.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var br=u();function ct(e){return d(this,null,function*(){return f("request")?yield br.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var fe=["onI18nChanged","onBackPress"],lt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},dt=(e,t)=>{if(!fe.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},mt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Rr=u();function ut(e){return d(this,null,function*(){return f("isNativeSupport")?yield Rr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var xr=u();function pt(e){return d(this,null,function*(){return f("callHostMethod")?yield xr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Ir=u();function ft(e){return d(this,null,function*(){return f("track")?yield Ir.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new ae}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var he=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},ht=window.JoliboxRuntime||he;var wr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(wr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return d(this,null,function*(){})}};var H=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var G=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:i})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Tr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],W=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Tr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var E=class E{constructor(){this.jssdkVersion="1.2.1";this.runtime=new ht;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new H;this.task=new G;this.router=new W;this.getSystemInfoSync=et.bind(this);this.canIUse=f.bind(this);this.login=it.bind(this);this.checkSession=at.bind(this);this.request=ct.bind(this);this.on=lt.bind(this);this.off=dt.bind(this);this.once=mt.bind(this);this.isNativeSupport=ut.bind(this);this.callHostMethod=pt.bind(this);this.track=ft.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var ge=E;window.JoliboxSDK=ge;})();
|
|
1
|
+
"use strict";(()=>{var gt=Object.defineProperty,Et=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var yt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&_e(e,r,t[r]);if(ye)for(var r of ye(t))_t.call(t,r)&&_e(e,r,t[r]);return e},C=(e,t)=>Et(e,vt(t));var d=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var ee=Object.defineProperty,St=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,Rt=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wt=(e,t)=>{for(var r in t||(t={}))xt.call(t,r)&&be(e,r,t[r]);if(Se)for(var r of Se(t))It.call(t,r)&&be(e,r,t[r]);return e},Tt=(e,t)=>St(e,Rt(t)),Lt=(e,t)=>{for(var r in t)ee(e,r,{get:t[r],enumerable:!0})},Ie=(e,t,r,n)=>{for(var o=n>1?void 0:n?bt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&ee(t,r,o),o},At=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Dt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function te(e){return typeof e=="string"}function we(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Pt(e){return typeof e=="undefined"}function Ut(e){return Pt(e)||e===null}function Ct(e){return typeof e=="function"}function Te(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Ot=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Ot||{}),K=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Le=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ae=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var kt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:kt});var Y=Symbol.for("Jolibox.canIUseMap"),Nt={};globalThis[Y]||(globalThis[Y]=Nt);var De={get config(){return globalThis[Y]}};var Re=Symbol.for("Jolibox.canIUseMap.native"),Kt={};globalThis[Re]||(globalThis[Re]=Kt);function re(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var ne=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ne||{}),oe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(oe||{}),Mt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Mt||{}),xe=["name","params"],jt=["name","type","location","target","extra","timestamp","userId"],Jt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Ft(e){let t=e.location?k(e.location,xe):null,r=e.target?k(e.target,xe):null;return k(Tt(wt({},e),{location:t,target:r}),jt)}function Pe(e){let t=e.events.map(n=>Ft(n)),r=k(e.device,Jt);return[e.protocolVersion,t,r,e.project]}var Bt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function se(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}se();var _=typeof window=="undefined",ie=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Vt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",$t="device_id",Ht="advertising_id",Ue=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Bt()),window.__joliboxLocalStorage__.getItem(e)),Gt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ue($t),Wt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ue(Ht),zt=e=>e.charAt(0).toUpperCase()+e.slice(1),Yt=()=>{var e;let t=new URLSearchParams(window.location.search);return zt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ce=e=>{if(ie())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,o=Gt(),s=Wt();return`${t} (${Yt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function Oe(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function qt(e){return Oe("api","stg-api",e)}function ke(e){return`https://${qt(e)}`}function Qt(e){return Oe("collect","stg-collect",e)}function Ne(e){return`https://${Qt(e)}`}var q=class Q{constructor(t){this.element=t,this.next=Q.Undefined,this.prev=Q.Undefined}};q.Undefined=new q(void 0);var m=q,Xt=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},Zt=0,I=class{constructor(e){this.value=e,this.id=Zt++}},w=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof I&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,v,Ee;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ve=this._listeners.indexOf(l);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((Ee=(v=this.options)==null?void 0:v.onDidRemoveLastListener)==null||Ee.call(v)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ae=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)t(...a.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Xt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},X={};Lt(X,{None:()=>er,filter:()=>rr,once:()=>Ke,toPromise:()=>tr});var er=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function tr(e){return new Promise(t=>Ke(e)(t))}function Ke(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function rr(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var z=Symbol.for("Jolibox.hostEmitter"),nr=()=>{let e=new ae;return globalThis[z]||(globalThis[z]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[z]},S=nr();function or(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)sr(e[n],t[n])}function sr(e,t){if(te(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ct(t)){try{if(e instanceof t)return}catch(r){}if(!Ut(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var N=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return or(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};N=Ie([Te],N);var Z=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new N,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Dt(3e4)),this._starActivation}executeCommand(e,...t){return At(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),X.toPromise(X.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};Z=Ie([Te],Z);var Me=Symbol.for("Jolibox.commands");function ir(){return typeof globalThis!="undefined"?globalThis[Me]:void 0}function ar(e){typeof globalThis!="undefined"&&(globalThis[Me]=e)}function u(e=!1){let t=ir();if(!e&&t)return t;let r=new N,n=new Z,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return ar(o),o}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function cr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function lr(){return{platform:1e3,os:"h5",appVersion:"1.2.2",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.2",extra:{}}}var dr=()=>{var t;return Ne((t=j)!=null?t:!1)},mr=dr(),Je=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},je;(je=AbortSignal.timeout)!=null||(AbortSignal.timeout=Je);var ur=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},pr=ur(),fr=e=>d(void 0,null,function*(){try{let r=`${mr}/report`,n=Ce("1.2.2"),o=pr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Je(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:ne.ErrorTrace,location:cr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=lr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:oe.WebSDK},s=Pe(o);yield fr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var hr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=hr(),Fe=u(),ce=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},y=ce;window.addEventListener("unhandledrejection",ce.bind(void 0));window.addEventListener("error",ce.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var le=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(le(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=le(e),{major:i,minor:c,patch:a,prerelease:l}=le(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var Be=u(),J=(e,t)=>{Be.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};se();var He="jolibox-sdk-loadermeta",$e,P=JSON.parse(($e=window.__joliboxLocalStorage__.getItem(He))!=null?$e:"{}"),de=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function gr(){return d(this,null,function*(){let t=`${ke(j)}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=C(U({},P),{timestamp:de});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=C(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=C(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(He,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ge=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!Ve(de,l)&&A(a)==t&&D(a,r)>=0&&(n=me(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new Ae(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let v=document.createElement("script");v.type="text/javascript",v.innerHTML=l,document.head.appendChild(v),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!Ve(de,h)&&A(l)==t&&D(l,r)>=0&&(o=ue(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),gr()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var We=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>d(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){y(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new T(`module load failed ${o}`))}}};var Er="1.2.2",F=Er,Qe=A(F),Xe=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),vr=Xe?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,pe="https://jsdelivr.jolibox.com";var ze=window.document.currentScript;ze&&(pe=new URL(ze.src).origin);var me=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,ue=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/implement@${e}/dist/index.js`,yr=e=>/^\d+\.\d+\.\d+$/.test(e),Ze=yr(F)?Qe:F,Ye=me(Ze),qe=ue(Ze);function _r(){Xe?We(vr,{bootstrapUrl:Ye,implementUrl:qe})():Ge({bootstrapUrl:Ye,implementUrl:qe,currentMajorVersion:Qe,currentVersion:F})()}_r();var Sr=u();function et(){return Sr.excuteCommandSync("API.getSystemInfoSync")}function tt(e,t){var r;return(r=De.config[e])==null?void 0:r[t]}function rt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var ot="1.2.2";function f(e){let[t,...r]=e.split(":"),n=tt(ie()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||re(ot,o,"<")?!1:r.length===0?!0:nt(n,r)||nt(n.properties,r)}function nt(e,t){if(!e)return!1;let r=rt(e,t);return r?we(r)?!0:te(r)?re(ot,r,">="):!1:!1}var st=u();function it(){return d(this,null,function*(){return f("login")?yield st.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function at(){return d(this,null,function*(){return f("checkSession")?yield st.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var br=u();function ct(e){return d(this,null,function*(){return f("request")?yield br.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var fe=["onI18nChanged","onBackPress"],lt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},dt=(e,t)=>{if(!fe.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},mt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Rr=u();function ut(e){return d(this,null,function*(){return f("isNativeSupport")?yield Rr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var xr=u();function pt(e){return d(this,null,function*(){return f("callHostMethod")?yield xr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Ir=u();function ft(e){return d(this,null,function*(){return f("track")?yield Ir.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new ae}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var he=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},ht=window.JoliboxRuntime||he;var wr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(wr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return d(this,null,function*(){})}};var H=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var G=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s,variation:i})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Tr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],W=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Tr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var E=class E{constructor(){this.jssdkVersion="1.2.2";this.runtime=new ht;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new H;this.task=new G;this.router=new W;this.getSystemInfoSync=et.bind(this);this.canIUse=f.bind(this);this.login=it.bind(this);this.checkSession=at.bind(this);this.request=ct.bind(this);this.on=lt.bind(this);this.off=dt.bind(this);this.once=mt.bind(this);this.isNativeSupport=ut.bind(this);this.callHostMethod=pt.bind(this);this.track=ft.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var ge=E;window.JoliboxSDK=ge;})();
|
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.2",
|
|
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.2",
|
|
11
|
+
"@jolibox/types": "1.2.2"
|
|
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.2 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/sdk@1.2.
|
|
7
|
+
> @jolibox/sdk@1.2.2 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.2 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.2 build:iife
|
|
16
16
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
|
|
17
17
|
|