@jolibox/sdk 1.1.15-beta.1 → 1.1.16-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,17 +4,17 @@
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": "d5a4b805910cf9d2a96190d5663a95be1fc8452b",
7
+ "packages/sdk/package.json": "597f15cdc3922a351702f162704cbbfc64752648",
8
8
  "packages/sdk/src/api/__tests__/canIUse.test.ts": "300e4de3768f9510e956050d326d4977bc621f34",
9
9
  "packages/sdk/src/api/can-i-use.ts": "4fd7efe21419d39e535584d7ab8e6a3c4e186877",
10
10
  "packages/sdk/src/api/get-system-info.ts": "c73be9f62c7055093effadaf6c48c54d6f383542",
11
11
  "packages/sdk/src/api/index.ts": "048e16bc8b4c8548d095e6304e432ad47ed50fa4",
12
12
  "packages/sdk/src/api/login.ts": "747c923c87175b467c17e303a14210bf0ab7a1cb",
13
13
  "packages/sdk/src/api/request.ts": "117baeceb72bd1602a01f3e1fe586faaea48d155",
14
- "packages/sdk/src/events.ts": "fc2df274eeedce36bedfc7d01ec580dba16e4502",
14
+ "packages/sdk/src/events.ts": "124aa9c3dbfa2477ba4d365d63446fae6b542f1f",
15
15
  "packages/sdk/src/index.ts": "81e4bc4294f165bd26fb60984fdc05154dabbcd3",
16
16
  "packages/sdk/src/loader/__tests__/version.test.ts": "338ca817bfcb672d1065d6f32872b57bc43951b5",
17
- "packages/sdk/src/loader/h5.ts": "462dd8c9c6ef6761d8139026b45d98d559db7e38",
17
+ "packages/sdk/src/loader/h5.ts": "1565cba2f78e9ca854cd25682c6f3ac90c19ba34",
18
18
  "packages/sdk/src/loader/index.ts": "d50f70d6ec8f67c78d9dfeed8c812400f524a746",
19
19
  "packages/sdk/src/loader/native.ts": "5f9f068c328222a28b457d19841b93c4a13ecccb",
20
20
  "packages/sdk/src/loader/version.ts": "deacf56606b2c47f93e0dfa35e5b5dfbe774c69f",
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var L=Object.defineProperty,st=Object.defineProperties,it=Object.getOwnPropertyDescriptor,at=Object.getOwnPropertyDescriptors,ct=Object.getOwnPropertyNames,me=Object.getOwnPropertySymbols;var ue=Object.prototype.hasOwnProperty,lt=Object.prototype.propertyIsEnumerable;var de=(e,t,r)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,A=(e,t)=>{for(var r in t||(t={}))ue.call(t,r)&&de(e,r,t[r]);if(me)for(var r of me(t))lt.call(t,r)&&de(e,r,t[r]);return e},D=(e,t)=>st(e,at(t));var mt=(e,t)=>{for(var r in t)L(e,r,{get:t[r],enumerable:!0})},dt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ct(t))!ue.call(e,o)&&o!==r&&L(e,o,{get:()=>t[o],enumerable:!(n=it(t,o))||n.enumerable});return e};var ut=e=>dt(L({},"__esModule",{value:!0}),e);var m=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{c(r.next(l))}catch(i){o(i)}},a=l=>{try{c(r.throw(l))}catch(i){o(i)}},c=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);c((r=r.apply(e,t)).next())});var ur={};mt(ur,{JoliboxSDK:()=>$});module.exports=ut(ur);if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 Y=Object.defineProperty,pt=Object.defineProperties,ft=Object.getOwnPropertyDescriptor,ht=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertySymbols,gt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable,fe=(e,t,r)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ge=(e,t)=>{for(var r in t||(t={}))gt.call(t,r)&&fe(e,r,t[r]);if(pe)for(var r of pe(t))_t.call(t,r)&&fe(e,r,t[r]);return e},yt=(e,t)=>pt(e,ht(t)),Et=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},_e=(e,t,r,n)=>{for(var o=n>1?void 0:n?ft(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&Y(t,r,o),o},vt=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{c(r.next(l))}catch(i){o(i)}},a=l=>{try{c(r.throw(l))}catch(i){o(i)}},c=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);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 bt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Q(e){return typeof e=="string"}function ye(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function St(e){return typeof e=="undefined"}function xt(e){return St(e)||e===null}function Rt(e){return typeof e=="function"}function Ee(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var wt=(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))(wt||{}),It=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}},ve=class extends It{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var be=class extends ve{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},b=class extends ve{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Tt={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:Tt});var Se=Symbol.for("Jolibox.canIUseMap"),Lt={};globalThis[Se]=Lt;var xe={get config(){return globalThis[Se]}};function X(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let c=0;c<a;c++){let l=parseInt(o[c],10)||0,i=parseInt(s[c],10)||0;if(l>i){n=1;break}else if(l<i){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 Z=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Z||{}),ee=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ee||{}),At=(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))(At||{}),he=["name","params"],Dt=["name","type","location","target","extra","timestamp","userId"],Ut=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function P(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 Ot(e){let t=e.location?P(e.location,he):null,r=e.target?P(e.target,he):null;return P(yt(ge({},e),{location:t,target:r}),Dt)}function Re(e){let t=e.events.map(n=>Ot(n)),r=P(e.device,Ut);return[e.protocolVersion,t,r,e.project]}var Pt=()=>"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 te(){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}}te();var U={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")},kt=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.isFacebook?"Facebook":"PC",Ct="device_id",Kt="advertising_id",we=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Pt()),window.__joliboxLocalStorage__.getItem(e)),Mt=()=>new URLSearchParams(window.location.search).get("deviceId")||we(Ct),jt=()=>we(Kt),Nt=e=>e.charAt(0).toUpperCase()+e.slice(1),Jt=()=>{var e;let t=new URLSearchParams(window.location.search);return Nt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ie=e=>{let t="JoliboxWebSDK",r=kt(),n=navigator.language,o=Mt(),s=jt();return`${t} (${Jt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},H=class W{constructor(t){this.element=t,this.next=W.Undefined,this.prev=W.Undefined}};H.Undefined=new H(void 0);var d=H,Ft=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Bt=0,O=class{constructor(e){this.value=e,this.id=Bt++}},x=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 O&&(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,a,c,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let i=new O(t);this._listeners?this._listeners instanceof O?this._listeners=[this._listeners,i]:this._listeners.push(i):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=i,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(l=(c=this.options)==null?void 0:c.onDidAddListener)==null||l.call(c,this),this._size++}),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 O?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},re=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=a=>t(...a.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)n.fire(ge({event:e},s.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Ft,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},z={};Et(z,{None:()=>Vt,filter:()=>Gt,once:()=>Te,toPromise:()=>$t});var Vt=()=>{console.log("[Jolibox SDK] None Event")};function $t(e){return new Promise(t=>Te(e)(t))}function Te(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Gt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var G=Symbol.for("Jolibox.hostEmitter"),Ht=()=>{let e=new re;return globalThis[G]||(globalThis[G]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[G]},Le=Ht();function Wt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)zt(e[n],t[n])}function zt(e,t){if(Q(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Rt(t)){try{if(e instanceof t)return}catch(r){}if(!xt(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 x,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 Wt(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=_e([Ee],k);var q=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=bt(3e4)),this._starActivation}executeCommand(e,...t){return vt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),z.toPromise(z.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};q=_e([Ee],q);var Ae=Symbol.for("Jolibox.commands");function qt(){return typeof globalThis!="undefined"?globalThis[Ae]:void 0}function Yt(e){typeof globalThis!="undefined"&&(globalThis[Ae]=e)}function h(){let e=qt();if(e)return e;let t=new k,r=new q,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Yt(n),n}var C=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Qt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Xt(){return{platform:1e3,os:"h5",appVersion:"1.1.15-beta.1",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.15-beta.1",extra:{}}}var De={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Zt=()=>{var t;let e=(t=De[window.location.host])!=null?t:De.default;return C?e.test:e.prod},er=Zt(),Oe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ue;(Ue=AbortSignal.timeout)!=null||(AbortSignal.timeout=Oe);var tr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},rr=tr(),nr=e=>m(void 0,null,function*(){try{let r=`${er}/report`,n=Ie("1.1.15-beta.1"),o=rr,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:Oe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function E(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:Z.ErrorTrace,location:Qt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Xt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ee.WebSDK},s=Re(o);yield nr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>Le.emit("onDocumentReady",R.startTime));var or=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},R=or(),Pe=h(),ne=e=>{Pe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`),E({err:JSON.stringify({message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,error:t.error})})})},oe=ne;window.addEventListener("unhandledrejection",ne.bind(void 0));window.addEventListener("error",ne.bind(void 0));window.onerror=(e,t,r,n,o)=>{Pe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})}}).catch(s=>{E({err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})})})};var se=e=>{var c,l,i;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,a]=[(c=n[0])!=null?c:"0",(l=n[1])!=null?l:"0",(i=n[2])!=null?i:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},w=e=>parseInt(se(e).major,10),I=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=se(e),{major:a,minor:c,patch:l,prerelease:i}=se(t);return r!==a?r>a?1:-1:n!==c?n>c?1:-1:o!==l?o>l?1:-1:s&&!i?-1:!s&&i?1:s&&i?s>i?1:s<i?-1:0:0};var ke=h(),K=(e,t)=>{ke.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{ke.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};te();var je="jolibox-sdk-loadermeta",Me,T=JSON.parse((Me=window.__joliboxLocalStorage__.getItem(je))!=null?Me:"{}"),ie=Date.now(),Ce=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,Ke=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);function sr(){return m(this,null,function*(){let t=`${C?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/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=D(A({},T),{timestamp:ie});if(o){let{bootstrap_version:a}=T;if(!(a&&I(a,o)>=0)){let c=yield(yield fetch(ae(o))).text();Ke(c)&&(s=D(A({},s),{bootstrap_version:o,bootstrap_script:c}))}}if(n){let{implement_version:a}=T;if(!(a&&I(a,n)>=0)){let c=yield(yield fetch(ce(n))).text();Ke(c)&&(s=D(A({},s),{implement_version:n,implement_script:c}))}}window.__joliboxLocalStorage__.setItem(je,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ne=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:o}=e;function s(){let{bootstrap_version:i,bootstrap_script:g,timestamp:_}=T;if(i&&g&&_&&!Ce(ie,_)&&w(i)==t&&I(i,r)>=0)return{script:g,type:"localscript"};try{let p=new XMLHttpRequest;return p.open("GET",n,!1),p.send(),{script:p.responseText,type:"fetch_from_cdn"}}catch(p){let u=new be(`Bootstrap module faile to fetch ${p}`);E({err:`${u}`})}}function a(){var p;let i=Date.now();K("jsSdkBegin",{t:i}),R.startTime=i;let{script:g,type:_}=(p=s())!=null?p:{};if(g){let u=document.createElement("script");u.type="text/javascript",u.innerHTML=g,document.head.appendChild(u),v("bootstrapModuleLoaded",Date.now()-i,{type:_})}}function c(i){(_=>m(this,null,function*(){try{let p=new Blob([_],{type:"application/javascript"}),u=URL.createObjectURL(p),ot=yield import(u);return URL.revokeObjectURL(u),ot}catch(p){let u=new b(`implement module evaluate error in h5:${p} `);E({err:`${u}`})}}))(i)}function l(){let i=Date.now(),{implement_script:g,implement_version:_,timestamp:p}=T;if(g&&_&&p&&!Ce(ie,p)&&w(_)==t&&I(_,r)>=0){c(g),v("implementModuleLoaded",Date.now()-i,{type:"loadscript"});return}let u=document.createElement("script");u.type="module",u.crossOrigin="anonymous",u.src=o,u.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(u)}return()=>{try{a(),l(),sr()}catch(i){let g=new b(`module evaluate error: ${i}`);E({err:`${g}`})}}};var Je=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let c=new Blob([a],{type:"application/javascript"}),l=URL.createObjectURL(c),i=yield import(l);return URL.revokeObjectURL(l),i}catch(c){oe(new b(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();K("jsSdkBegin",{t:o}),R.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),v("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),l=r(t.implementUrl);n(l),v("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),oe(new b(`module load failed ${o}`))}}};var ir="1.1.15-beta.1",M=ir,Ve=w(M),$e=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),ar=$e?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,ae=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,ce=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,cr=e=>/^\d+\.\d+\.\d+$/.test(e),Ge=cr(M)?Ve:M,Fe=ae(Ge),Be=ce(Ge);function lr(){$e?Je(ar,{bootstrapUrl:Fe,implementUrl:Be})():Ne({bootstrapUrl:Fe,implementUrl:Be,currentMajorVersion:Ve,currentVersion:M})()}lr();var He=h();function We(){return He.excuteCommandSync("API.getSystemInfoSync")}function ze(){return He.excuteCommandSync("API.env")}function qe(e,t){var r;return(r=xe.config[e])==null?void 0:r[t]}function Ye(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 Xe="1.1.15-beta.1";function y(e){var c,l;let r=(l=(c=ze().data)==null?void 0:c.deviceInfo)==null?void 0:l.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=qe(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||X(Xe,a,"<")?!1:o.length===0?!0:Qe(s,o)||Qe(s.properties,o)}function Qe(e,t){if(!e)return!1;let r=Ye(e,t);return r?ye(r)?!0:Q(r)?X(Xe,r,">="):!1:!1}var Ze=h();function et(){return m(this,null,function*(){return y("login")?yield Ze.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function tt(){return m(this,null,function*(){return y("checkSession")?yield Ze.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var mr=h();function rt(e){return m(this,null,function*(){return y("request")?yield mr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var le=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},nt=window.JoliboxRuntime||le;var f=class{constructor(){this.commands=h();this._emitter=new re}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return y(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var dr="LifecycleSDK.onReady",j=class extends f{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(dr,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 N=class extends f{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var J=class extends f{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)}}};var F=class extends f{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 B=class extends f{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var V=class extends f{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var $=class{constructor(){this.jssdkVersion="1.1.15-beta.1";this.runtime=new nt;this.ads=new J;this.lifecycle=new j;this.storage=new N;this.keyboard=new F;this.task=new B;this.router=new V;this.getSystemInfoSync=We.bind(this);this.canIUse=y.bind(this);this.login=et.bind(this);this.checkSession=tt.bind(this);this.request=rt.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router}}};window.JoliboxSDK=$;
1
+ "use strict";var w=Object.defineProperty,nt=Object.defineProperties,ot=Object.getOwnPropertyDescriptor,st=Object.getOwnPropertyDescriptors,it=Object.getOwnPropertyNames,me=Object.getOwnPropertySymbols;var ue=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable;var de=(e,t,r)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,T=(e,t)=>{for(var r in t||(t={}))ue.call(t,r)&&de(e,r,t[r]);if(me)for(var r of me(t))at.call(t,r)&&de(e,r,t[r]);return e},A=(e,t)=>nt(e,st(t));var ct=(e,t)=>{for(var r in t)w(e,r,{get:t[r],enumerable:!0})},lt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of it(t))!ue.call(e,o)&&o!==r&&w(e,o,{get:()=>t[o],enumerable:!(n=ot(t,o))||n.enumerable});return e};var mt=e=>lt(w({},"__esModule",{value:!0}),e);var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});var lr={};ct(lr,{JoliboxSDK:()=>B});module.exports=mt(lr);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 q=Object.defineProperty,dt=Object.defineProperties,ut=Object.getOwnPropertyDescriptor,pt=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertySymbols,ft=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable,fe=(e,t,r)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ge=(e,t)=>{for(var r in t||(t={}))ft.call(t,r)&&fe(e,r,t[r]);if(pe)for(var r of pe(t))ht.call(t,r)&&fe(e,r,t[r]);return e},gt=(e,t)=>dt(e,pt(t)),_t=(e,t)=>{for(var r in t)q(e,r,{get:t[r],enumerable:!0})},_e=(e,t,r,n)=>{for(var o=n>1?void 0:n?ut(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&q(t,r,o),o},Et=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 yt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Y(e){return typeof e=="string"}function Ee(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function St(e){return typeof e=="undefined"}function bt(e){return St(e)||e===null}function vt(e){return typeof e=="function"}function ye(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var xt=(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))(xt||{}),Q=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}},Se=class extends Q{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var be=class extends Se{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},b=class extends Se{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function y(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Rt={log:y("log"),warn:y("warn"),info:y("info"),error:y("error"),debug:y("debug")};Object.assign(globalThis,{logger:Rt});var ve=Symbol.for("Jolibox.canIUseMap"),It={};globalThis[ve]=It;var xe={get config(){return globalThis[ve]}};function X(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){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 Z=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Z||{}),ee=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ee||{}),wt=(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))(wt||{}),he=["name","params"],Tt=["name","type","location","target","extra","timestamp","userId"],At=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function U(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 Lt(e){let t=e.location?U(e.location,he):null,r=e.target?U(e.target,he):null;return U(gt(ge({},e),{location:t,target:r}),Tt)}function Re(e){let t=e.events.map(n=>Lt(n)),r=U(e.device,At);return[e.protocolVersion,t,r,e.project]}var Dt=()=>"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 te(){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}}te();var L={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")},Ut=()=>L.isiOS?"iOS":L.isAndroid?"Android":L.isMac?"Mac":L.isFacebook?"Facebook":"PC",Ot="device_id",kt="advertising_id",Ie=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Dt()),window.__joliboxLocalStorage__.getItem(e)),Pt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ie(Ot),Ct=()=>Ie(kt),Kt=e=>e.charAt(0).toUpperCase()+e.slice(1),Mt=()=>{var e;let t=new URLSearchParams(window.location.search);return Kt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},we=e=>{let t="JoliboxWebSDK",r=Ut(),n=navigator.language,o=Pt(),s=Ct();return`${t} (${Mt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},G=class H{constructor(t){this.element=t,this.next=H.Undefined,this.prev=H.Undefined}};G.Undefined=new G(void 0);var d=G,jt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Nt=0,D=class{constructor(e){this.value=e,this.id=Nt++}},S=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 D&&(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,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new D(t);this._listeners?this._listeners instanceof D?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++}),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 D?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},re=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new S,o=a=>t(...a.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)n.fire(ge({event:e},s.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new jt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},W={};_t(W,{None:()=>Jt,filter:()=>Bt,once:()=>Te,toPromise:()=>Ft});var Jt=()=>{console.log("[Jolibox SDK] None Event")};function Ft(e){return new Promise(t=>Te(e)(t))}function Te(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Bt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new S(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var $=Symbol.for("Jolibox.hostEmitter"),Vt=()=>{let e=new re;return globalThis[$]||(globalThis[$]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[$]},Ae=Vt();function $t(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Gt(e[n],t[n])}function Gt(e,t){if(Y(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(vt(t)){try{if(e instanceof t)return}catch(r){}if(!bt(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 O=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new S,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 $t(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}};O=_e([ye],O);var z=class{constructor(){this._onWillExecuteCommand=new S,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new S,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new O,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=yt(3e4)),this._starActivation}executeCommand(e,...t){return Et(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),W.toPromise(W.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=_e([ye],z);var Le=Symbol.for("Jolibox.commands");function Ht(){return typeof globalThis!="undefined"?globalThis[Le]:void 0}function Wt(e){typeof globalThis!="undefined"&&(globalThis[Le]=e)}function p(){let e=Ht();if(e)return e;let t=new O,r=new z,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Wt(n),n}var k=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function zt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function qt(){return{platform:1e3,os:"h5",appVersion:"1.1.16-beta.1",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.16-beta.1",extra:{}}}var De={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Yt=()=>{var t;let e=(t=De[window.location.host])!=null?t:De.default;return k?e.test:e.prod},Qt=Yt(),Oe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ue;(Ue=AbortSignal.timeout)!=null||(AbortSignal.timeout=Oe);var Xt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Zt=Xt(),er=e=>m(void 0,null,function*(){try{let r=`${Qt}/report`,n=we("1.1.16-beta.1"),o=Zt,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:Oe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function _(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:Z.ErrorTrace,location:zt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=qt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ee.WebSDK},s=Re(o);yield er(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>Ae.emit("onDocumentReady",v.startTime));var tr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},v=tr(),ke=p(),ne=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 Q?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),_({err:JSON.stringify(t)})})},oe=ne;window.addEventListener("unhandledrejection",ne.bind(void 0));window.addEventListener("error",ne.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()};ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{_({err:JSON.stringify(s)})})};var se=e=>{var l,i,c;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,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},x=e=>parseInt(se(e).major,10),R=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=se(e),{major:a,minor:l,patch:i,prerelease:c}=se(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Pe=p(),P=(e,t)=>{Pe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},E=(e,t,r)=>{Pe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};te();var Me="jolibox-sdk-loadermeta",Ke,I=JSON.parse((Ke=window.__joliboxLocalStorage__.getItem(Me))!=null?Ke:"{}"),ie=Date.now(),Ce=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function rr(){return m(this,null,function*(){let t=`${k?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/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=A(T({},I),{timestamp:ie});if(o){let{bootstrap_version:a}=I;a&&R(a,o)>=0||(s=A(T({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=I;a&&R(a,n)>=0||(s=A(T({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Me,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var je=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=I;i&&c&&!Ce(ie,c)&&x(i)==t&&R(i,r)>=0&&(n=ae(i));try{let f=new XMLHttpRequest;return f.open("GET",n,!1),f.send(),{script:f.responseText,type:"fetch_from_cdn"}}catch(f){let h=new be(`Bootstrap module faile to fetch ${f}`);_({err:`${h}`})}}function a(){var h;let i=Date.now();P("jsSdkBegin",{t:i}),v.startTime=i;let{script:c,type:f}=(h=s())!=null?h:{};if(c){let V=document.createElement("script");V.type="text/javascript",V.innerHTML=c,document.head.appendChild(V),E("bootstrapModuleLoaded",Date.now()-i,{type:f})}}function l(){let i=Date.now(),{implement_version:c,timestamp:f}=I;c&&f&&!Ce(ie,f)&&x(c)==t&&R(c,r)>=0&&(o=ce(c));let h=document.createElement("script");h.type="module",h.crossOrigin="anonymous",h.src=o,h.onload=()=>{E("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(h)}return()=>{try{a(),l(),rr()}catch(i){let c=new b(`module evaluate error: ${i}`);_({err:`${c}`})}}};var Ne=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){oe(new b(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();P("jsSdkBegin",{t:o}),v.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),E("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),E("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),oe(new b(`module load failed ${o}`))}}};var nr="1.1.16-beta.1",C=nr,Be=x(C),Ve=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),or=Ve?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,ae=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,ce=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,sr=e=>/^\d+\.\d+\.\d+$/.test(e),$e=sr(C)?Be:C,Je=ae($e),Fe=ce($e);function ir(){Ve?Ne(or,{bootstrapUrl:Je,implementUrl:Fe})():je({bootstrapUrl:Je,implementUrl:Fe,currentMajorVersion:Be,currentVersion:C})()}ir();var Ge=p();function He(){return Ge.excuteCommandSync("API.getSystemInfoSync")}function We(){return Ge.excuteCommandSync("API.env")}function ze(e,t){var r;return(r=xe.config[e])==null?void 0:r[t]}function qe(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 Qe="1.1.16-beta.1";function g(e){var l,i;let r=(i=(l=We().data)==null?void 0:l.deviceInfo)==null?void 0:i.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=ze(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||X(Qe,a,"<")?!1:o.length===0?!0:Ye(s,o)||Ye(s.properties,o)}function Ye(e,t){if(!e)return!1;let r=qe(e,t);return r?Ee(r)?!0:Y(r)?X(Qe,r,">="):!1:!1}var Xe=p();function Ze(){return m(this,null,function*(){return g("login")?yield Xe.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function et(){return m(this,null,function*(){return g("checkSession")?yield Xe.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ar=p();function tt(e){return m(this,null,function*(){return g("request")?yield ar.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var le=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},rt=window.JoliboxRuntime||le;var u=class{constructor(){this.commands=p();this._emitter=new re}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return g(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var cr="LifecycleSDK.onReady",K=class extends u{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(cr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var M=class extends u{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var j=class extends u{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)}}};var N=class extends u{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 J=class extends u{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var F=class extends u{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var B=class{constructor(){this.jssdkVersion="1.1.16-beta.1";this.runtime=new rt;this.ads=new j;this.lifecycle=new K;this.storage=new M;this.keyboard=new N;this.task=new J;this.router=new F;this.getSystemInfoSync=He.bind(this);this.canIUse=g.bind(this);this.login=Ze.bind(this);this.checkSession=et.bind(this);this.request=tt.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router}}};window.JoliboxSDK=B;
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- var nt=Object.defineProperty,ot=Object.defineProperties;var st=Object.getOwnPropertyDescriptors;var le=Object.getOwnPropertySymbols;var it=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable;var me=(e,t,r)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,L=(e,t)=>{for(var r in t||(t={}))it.call(t,r)&&me(e,r,t[r]);if(le)for(var r of le(t))at.call(t,r)&&me(e,r,t[r]);return e},A=(e,t)=>ot(e,st(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{c(r.next(l))}catch(i){o(i)}},a=l=>{try{c(r.throw(l))}catch(i){o(i)}},c=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);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 z=Object.defineProperty,ct=Object.defineProperties,lt=Object.getOwnPropertyDescriptor,mt=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertySymbols,dt=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,ue=(e,t,r)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fe=(e,t)=>{for(var r in t||(t={}))dt.call(t,r)&&ue(e,r,t[r]);if(de)for(var r of de(t))ut.call(t,r)&&ue(e,r,t[r]);return e},pt=(e,t)=>ct(e,mt(t)),ft=(e,t)=>{for(var r in t)z(e,r,{get:t[r],enumerable:!0})},he=(e,t,r,n)=>{for(var o=n>1?void 0:n?lt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&z(t,r,o),o},ht=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{c(r.next(l))}catch(i){o(i)}},a=l=>{try{c(r.throw(l))}catch(i){o(i)}},c=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);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 gt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function q(e){return typeof e=="string"}function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function _t(e){return typeof e=="undefined"}function yt(e){return _t(e)||e===null}function Et(e){return typeof e=="function"}function _e(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var vt=(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))(vt||{}),bt=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}},ye=class extends bt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ee=class extends ye{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},b=class extends ye{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var St={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:St});var ve=Symbol.for("Jolibox.canIUseMap"),xt={};globalThis[ve]=xt;var be={get config(){return globalThis[ve]}};function Y(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let c=0;c<a;c++){let l=parseInt(o[c],10)||0,i=parseInt(s[c],10)||0;if(l>i){n=1;break}else if(l<i){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 Q=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Q||{}),X=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(X||{}),Rt=(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))(Rt||{}),pe=["name","params"],wt=["name","type","location","target","extra","timestamp","userId"],It=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function O(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 Tt(e){let t=e.location?O(e.location,pe):null,r=e.target?O(e.target,pe):null;return O(pt(fe({},e),{location:t,target:r}),wt)}function Se(e){let t=e.events.map(n=>Tt(n)),r=O(e.device,It);return[e.protocolVersion,t,r,e.project]}var Lt=()=>"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 Z(){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}}Z();var D={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")},At=()=>D.isiOS?"iOS":D.isAndroid?"Android":D.isMac?"Mac":D.isFacebook?"Facebook":"PC",Dt="device_id",Ut="advertising_id",xe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Lt()),window.__joliboxLocalStorage__.getItem(e)),Ot=()=>new URLSearchParams(window.location.search).get("deviceId")||xe(Dt),Pt=()=>xe(Ut),kt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ct=()=>{var e;let t=new URLSearchParams(window.location.search);return kt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Re=e=>{let t="JoliboxWebSDK",r=At(),n=navigator.language,o=Ot(),s=Pt();return`${t} (${Ct()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},$=class G{constructor(t){this.element=t,this.next=G.Undefined,this.prev=G.Undefined}};$.Undefined=new $(void 0);var d=$,Kt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Mt=0,U=class{constructor(e){this.value=e,this.id=Mt++}},x=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 U&&(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,a,c,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let i=new U(t);this._listeners?this._listeners instanceof U?this._listeners=[this._listeners,i]:this._listeners.push(i):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=i,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(l=(c=this.options)==null?void 0:c.onDidAddListener)==null||l.call(c,this),this._size++}),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 U?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ee=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=a=>t(...a.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)n.fire(fe({event:e},s.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Kt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},H={};ft(H,{None:()=>jt,filter:()=>Jt,once:()=>we,toPromise:()=>Nt});var jt=()=>{console.log("[Jolibox SDK] None Event")};function Nt(e){return new Promise(t=>we(e)(t))}function we(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Jt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var V=Symbol.for("Jolibox.hostEmitter"),Ft=()=>{let e=new ee;return globalThis[V]||(globalThis[V]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[V]},Ie=Ft();function Bt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Vt(e[n],t[n])}function Vt(e,t){if(q(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Et(t)){try{if(e instanceof t)return}catch(r){}if(!yt(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 P=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new x,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 Bt(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}};P=he([_e],P);var W=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new P,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=gt(3e4)),this._starActivation}executeCommand(e,...t){return ht(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),H.toPromise(H.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}}};W=he([_e],W);var Te=Symbol.for("Jolibox.commands");function $t(){return typeof globalThis!="undefined"?globalThis[Te]:void 0}function Gt(e){typeof globalThis!="undefined"&&(globalThis[Te]=e)}function h(){let e=$t();if(e)return e;let t=new P,r=new W,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Gt(n),n}var k=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Ht(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Wt(){return{platform:1e3,os:"h5",appVersion:"1.1.15-beta.1",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.15-beta.1",extra:{}}}var Le={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},zt=()=>{var t;let e=(t=Le[window.location.host])!=null?t:Le.default;return k?e.test:e.prod},qt=zt(),De=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ae;(Ae=AbortSignal.timeout)!=null||(AbortSignal.timeout=De);var Yt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Qt=Yt(),Xt=e=>m(void 0,null,function*(){try{let r=`${qt}/report`,n=Re("1.1.15-beta.1"),o=Qt,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:De(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function E(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:Q.ErrorTrace,location:Ht(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Wt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:X.WebSDK},s=Se(o);yield Xt(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>Ie.emit("onDocumentReady",R.startTime));var Zt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},R=Zt(),Ue=h(),te=e=>{Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`),E({err:JSON.stringify({message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,error:t.error})})})},re=te;window.addEventListener("unhandledrejection",te.bind(void 0));window.addEventListener("error",te.bind(void 0));window.onerror=(e,t,r,n,o)=>{Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})}}).catch(s=>{E({err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})})})};var ne=e=>{var c,l,i;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,a]=[(c=n[0])!=null?c:"0",(l=n[1])!=null?l:"0",(i=n[2])!=null?i:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},w=e=>parseInt(ne(e).major,10),I=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ne(e),{major:a,minor:c,patch:l,prerelease:i}=ne(t);return r!==a?r>a?1:-1:n!==c?n>c?1:-1:o!==l?o>l?1:-1:s&&!i?-1:!s&&i?1:s&&i?s>i?1:s<i?-1:0:0};var Oe=h(),C=(e,t)=>{Oe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Oe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};Z();var Ke="jolibox-sdk-loadermeta",Ce,T=JSON.parse((Ce=window.__joliboxLocalStorage__.getItem(Ke))!=null?Ce:"{}"),oe=Date.now(),Pe=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,ke=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);function er(){return m(this,null,function*(){let t=`${k?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/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=A(L({},T),{timestamp:oe});if(o){let{bootstrap_version:a}=T;if(!(a&&I(a,o)>=0)){let c=yield(yield fetch(se(o))).text();ke(c)&&(s=A(L({},s),{bootstrap_version:o,bootstrap_script:c}))}}if(n){let{implement_version:a}=T;if(!(a&&I(a,n)>=0)){let c=yield(yield fetch(ie(n))).text();ke(c)&&(s=A(L({},s),{implement_version:n,implement_script:c}))}}window.__joliboxLocalStorage__.setItem(Ke,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Me=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:o}=e;function s(){let{bootstrap_version:i,bootstrap_script:g,timestamp:_}=T;if(i&&g&&_&&!Pe(oe,_)&&w(i)==t&&I(i,r)>=0)return{script:g,type:"localscript"};try{let p=new XMLHttpRequest;return p.open("GET",n,!1),p.send(),{script:p.responseText,type:"fetch_from_cdn"}}catch(p){let u=new Ee(`Bootstrap module faile to fetch ${p}`);E({err:`${u}`})}}function a(){var p;let i=Date.now();C("jsSdkBegin",{t:i}),R.startTime=i;let{script:g,type:_}=(p=s())!=null?p:{};if(g){let u=document.createElement("script");u.type="text/javascript",u.innerHTML=g,document.head.appendChild(u),v("bootstrapModuleLoaded",Date.now()-i,{type:_})}}function c(i){(_=>m(this,null,function*(){try{let p=new Blob([_],{type:"application/javascript"}),u=URL.createObjectURL(p),rt=yield import(u);return URL.revokeObjectURL(u),rt}catch(p){let u=new b(`implement module evaluate error in h5:${p} `);E({err:`${u}`})}}))(i)}function l(){let i=Date.now(),{implement_script:g,implement_version:_,timestamp:p}=T;if(g&&_&&p&&!Pe(oe,p)&&w(_)==t&&I(_,r)>=0){c(g),v("implementModuleLoaded",Date.now()-i,{type:"loadscript"});return}let u=document.createElement("script");u.type="module",u.crossOrigin="anonymous",u.src=o,u.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(u)}return()=>{try{a(),l(),er()}catch(i){let g=new b(`module evaluate error: ${i}`);E({err:`${g}`})}}};var je=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let c=new Blob([a],{type:"application/javascript"}),l=URL.createObjectURL(c),i=yield import(l);return URL.revokeObjectURL(l),i}catch(c){re(new b(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();C("jsSdkBegin",{t:o}),R.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),v("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),l=r(t.implementUrl);n(l),v("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),re(new b(`module load failed ${o}`))}}};var tr="1.1.15-beta.1",K=tr,Fe=w(K),Be=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),rr=Be?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,se=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,ie=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,nr=e=>/^\d+\.\d+\.\d+$/.test(e),Ve=nr(K)?Fe:K,Ne=se(Ve),Je=ie(Ve);function or(){Be?je(rr,{bootstrapUrl:Ne,implementUrl:Je})():Me({bootstrapUrl:Ne,implementUrl:Je,currentMajorVersion:Fe,currentVersion:K})()}or();var $e=h();function Ge(){return $e.excuteCommandSync("API.getSystemInfoSync")}function He(){return $e.excuteCommandSync("API.env")}function We(e,t){var r;return(r=be.config[e])==null?void 0:r[t]}function ze(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 Ye="1.1.15-beta.1";function y(e){var c,l;let r=(l=(c=He().data)==null?void 0:c.deviceInfo)==null?void 0:l.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=We(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||Y(Ye,a,"<")?!1:o.length===0?!0:qe(s,o)||qe(s.properties,o)}function qe(e,t){if(!e)return!1;let r=ze(e,t);return r?ge(r)?!0:q(r)?Y(Ye,r,">="):!1:!1}var Qe=h();function Xe(){return m(this,null,function*(){return y("login")?yield Qe.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function Ze(){return m(this,null,function*(){return y("checkSession")?yield Qe.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var sr=h();function et(e){return m(this,null,function*(){return y("request")?yield sr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ae=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},tt=window.JoliboxRuntime||ae;var f=class{constructor(){this.commands=h();this._emitter=new ee}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return y(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ir="LifecycleSDK.onReady",M=class extends f{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(ir,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 j=class extends f{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var N=class extends f{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)}}};var J=class extends f{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 F=class extends f{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var B=class extends f{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var ce=class{constructor(){this.jssdkVersion="1.1.15-beta.1";this.runtime=new tt;this.ads=new N;this.lifecycle=new M;this.storage=new j;this.keyboard=new J;this.task=new F;this.router=new B;this.getSystemInfoSync=Ge.bind(this);this.canIUse=y.bind(this);this.login=Xe.bind(this);this.checkSession=Ze.bind(this);this.request=et.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router}}};window.JoliboxSDK=ce;export{ce as JoliboxSDK};
1
+ var tt=Object.defineProperty,rt=Object.defineProperties;var nt=Object.getOwnPropertyDescriptors;var le=Object.getOwnPropertySymbols;var ot=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable;var me=(e,t,r)=>t in e?tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,w=(e,t)=>{for(var r in t||(t={}))ot.call(t,r)&&me(e,r,t[r]);if(le)for(var r of le(t))st.call(t,r)&&me(e,r,t[r]);return e},T=(e,t)=>rt(e,nt(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 W=Object.defineProperty,it=Object.defineProperties,at=Object.getOwnPropertyDescriptor,ct=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertySymbols,lt=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable,ue=(e,t,r)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fe=(e,t)=>{for(var r in t||(t={}))lt.call(t,r)&&ue(e,r,t[r]);if(de)for(var r of de(t))mt.call(t,r)&&ue(e,r,t[r]);return e},dt=(e,t)=>it(e,ct(t)),ut=(e,t)=>{for(var r in t)W(e,r,{get:t[r],enumerable:!0})},he=(e,t,r,n)=>{for(var o=n>1?void 0:n?at(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&W(t,r,o),o},pt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 ft(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function z(e){return typeof e=="string"}function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function ht(e){return typeof e=="undefined"}function gt(e){return ht(e)||e===null}function _t(e){return typeof e=="function"}function _e(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Et=(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))(Et||{}),q=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}},Ee=class extends q{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var ye=class extends Ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},b=class extends Ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function y(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var yt={log:y("log"),warn:y("warn"),info:y("info"),error:y("error"),debug:y("debug")};Object.assign(globalThis,{logger:yt});var Se=Symbol.for("Jolibox.canIUseMap"),St={};globalThis[Se]=St;var be={get config(){return globalThis[Se]}};function Y(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){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 Q=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Q||{}),X=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(X||{}),bt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(bt||{}),pe=["name","params"],vt=["name","type","location","target","extra","timestamp","userId"],xt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function D(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 Rt(e){let t=e.location?D(e.location,pe):null,r=e.target?D(e.target,pe):null;return D(dt(fe({},e),{location:t,target:r}),vt)}function ve(e){let t=e.events.map(n=>Rt(n)),r=D(e.device,xt);return[e.protocolVersion,t,r,e.project]}var It=()=>"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 Z(){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}}Z();var A={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")},wt=()=>A.isiOS?"iOS":A.isAndroid?"Android":A.isMac?"Mac":A.isFacebook?"Facebook":"PC",Tt="device_id",At="advertising_id",xe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,It()),window.__joliboxLocalStorage__.getItem(e)),Lt=()=>new URLSearchParams(window.location.search).get("deviceId")||xe(Tt),Dt=()=>xe(At),Ut=e=>e.charAt(0).toUpperCase()+e.slice(1),Ot=()=>{var e;let t=new URLSearchParams(window.location.search);return Ut((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Re=e=>{let t="JoliboxWebSDK",r=wt(),n=navigator.language,o=Lt(),s=Dt();return`${t} (${Ot()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},V=class ${constructor(t){this.element=t,this.next=$.Undefined,this.prev=$.Undefined}};V.Undefined=new V(void 0);var d=V,kt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Pt=0,L=class{constructor(e){this.value=e,this.id=Pt++}},S=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 L&&(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,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new L(t);this._listeners?this._listeners instanceof L?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++}),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 L?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ee=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new S,o=a=>t(...a.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)n.fire(fe({event:e},s.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new kt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},G={};ut(G,{None:()=>Ct,filter:()=>Mt,once:()=>Ie,toPromise:()=>Kt});var Ct=()=>{console.log("[Jolibox SDK] None Event")};function Kt(e){return new Promise(t=>Ie(e)(t))}function Ie(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Mt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new S(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var B=Symbol.for("Jolibox.hostEmitter"),jt=()=>{let e=new ee;return globalThis[B]||(globalThis[B]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[B]},we=jt();function Nt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Jt(e[n],t[n])}function Jt(e,t){if(z(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(_t(t)){try{if(e instanceof t)return}catch(r){}if(!gt(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 U=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new S,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 Nt(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}};U=he([_e],U);var H=class{constructor(){this._onWillExecuteCommand=new S,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new S,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new U,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=ft(3e4)),this._starActivation}executeCommand(e,...t){return pt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),G.toPromise(G.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}}};H=he([_e],H);var Te=Symbol.for("Jolibox.commands");function Ft(){return typeof globalThis!="undefined"?globalThis[Te]:void 0}function Bt(e){typeof globalThis!="undefined"&&(globalThis[Te]=e)}function p(){let e=Ft();if(e)return e;let t=new U,r=new H,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Bt(n),n}var O=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Vt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function $t(){return{platform:1e3,os:"h5",appVersion:"1.1.16-beta.1",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.16-beta.1",extra:{}}}var Ae={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Gt=()=>{var t;let e=(t=Ae[window.location.host])!=null?t:Ae.default;return O?e.test:e.prod},Ht=Gt(),De=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Le;(Le=AbortSignal.timeout)!=null||(AbortSignal.timeout=De);var Wt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},zt=Wt(),qt=e=>m(void 0,null,function*(){try{let r=`${Ht}/report`,n=Re("1.1.16-beta.1"),o=zt,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:De(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function _(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:Q.ErrorTrace,location:Vt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=$t(),o={protocolVersion:"1.0.0",events:[t],device:r,project:X.WebSDK},s=ve(o);yield qt(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>we.emit("onDocumentReady",v.startTime));var Yt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},v=Yt(),Ue=p(),te=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 q?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),_({err:JSON.stringify(t)})})},re=te;window.addEventListener("unhandledrejection",te.bind(void 0));window.addEventListener("error",te.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()};Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{_({err:JSON.stringify(s)})})};var ne=e=>{var l,i,c;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,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},x=e=>parseInt(ne(e).major,10),R=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ne(e),{major:a,minor:l,patch:i,prerelease:c}=ne(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Oe=p(),k=(e,t)=>{Oe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},E=(e,t,r)=>{Oe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};Z();var Ce="jolibox-sdk-loadermeta",Pe,I=JSON.parse((Pe=window.__joliboxLocalStorage__.getItem(Ce))!=null?Pe:"{}"),oe=Date.now(),ke=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Qt(){return m(this,null,function*(){let t=`${O?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/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=T(w({},I),{timestamp:oe});if(o){let{bootstrap_version:a}=I;a&&R(a,o)>=0||(s=T(w({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=I;a&&R(a,n)>=0||(s=T(w({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ce,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ke=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=I;i&&c&&!ke(oe,c)&&x(i)==t&&R(i,r)>=0&&(n=se(i));try{let f=new XMLHttpRequest;return f.open("GET",n,!1),f.send(),{script:f.responseText,type:"fetch_from_cdn"}}catch(f){let h=new ye(`Bootstrap module faile to fetch ${f}`);_({err:`${h}`})}}function a(){var h;let i=Date.now();k("jsSdkBegin",{t:i}),v.startTime=i;let{script:c,type:f}=(h=s())!=null?h:{};if(c){let F=document.createElement("script");F.type="text/javascript",F.innerHTML=c,document.head.appendChild(F),E("bootstrapModuleLoaded",Date.now()-i,{type:f})}}function l(){let i=Date.now(),{implement_version:c,timestamp:f}=I;c&&f&&!ke(oe,f)&&x(c)==t&&R(c,r)>=0&&(o=ie(c));let h=document.createElement("script");h.type="module",h.crossOrigin="anonymous",h.src=o,h.onload=()=>{E("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(h)}return()=>{try{a(),l(),Qt()}catch(i){let c=new b(`module evaluate error: ${i}`);_({err:`${c}`})}}};var Me=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){re(new b(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();k("jsSdkBegin",{t:o}),v.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),E("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),E("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),re(new b(`module load failed ${o}`))}}};var Xt="1.1.16-beta.1",P=Xt,Je=x(P),Fe=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Zt=Fe?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,se=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,ie=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,er=e=>/^\d+\.\d+\.\d+$/.test(e),Be=er(P)?Je:P,je=se(Be),Ne=ie(Be);function tr(){Fe?Me(Zt,{bootstrapUrl:je,implementUrl:Ne})():Ke({bootstrapUrl:je,implementUrl:Ne,currentMajorVersion:Je,currentVersion:P})()}tr();var Ve=p();function $e(){return Ve.excuteCommandSync("API.getSystemInfoSync")}function Ge(){return Ve.excuteCommandSync("API.env")}function He(e,t){var r;return(r=be.config[e])==null?void 0:r[t]}function We(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 qe="1.1.16-beta.1";function g(e){var l,i;let r=(i=(l=Ge().data)==null?void 0:l.deviceInfo)==null?void 0:i.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=He(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||Y(qe,a,"<")?!1:o.length===0?!0:ze(s,o)||ze(s.properties,o)}function ze(e,t){if(!e)return!1;let r=We(e,t);return r?ge(r)?!0:z(r)?Y(qe,r,">="):!1:!1}var Ye=p();function Qe(){return m(this,null,function*(){return g("login")?yield Ye.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function Xe(){return m(this,null,function*(){return g("checkSession")?yield Ye.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var rr=p();function Ze(e){return m(this,null,function*(){return g("request")?yield rr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ae=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},et=window.JoliboxRuntime||ae;var u=class{constructor(){this.commands=p();this._emitter=new ee}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return g(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var nr="LifecycleSDK.onReady",C=class extends u{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(nr,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 K=class extends u{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var M=class extends u{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)}}};var j=class extends u{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 N=class extends u{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var J=class extends u{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var ce=class{constructor(){this.jssdkVersion="1.1.16-beta.1";this.runtime=new et;this.ads=new M;this.lifecycle=new C;this.storage=new K;this.keyboard=new j;this.task=new N;this.router=new J;this.getSystemInfoSync=$e.bind(this);this.canIUse=g.bind(this);this.login=Qe.bind(this);this.checkSession=Xe.bind(this);this.request=Ze.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router}}};window.JoliboxSDK=ce;export{ce as JoliboxSDK};
@@ -1 +1 @@
1
- "use strict";(()=>{var nt=Object.defineProperty,ot=Object.defineProperties;var st=Object.getOwnPropertyDescriptors;var le=Object.getOwnPropertySymbols;var it=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable;var me=(e,t,r)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,L=(e,t)=>{for(var r in t||(t={}))it.call(t,r)&&me(e,r,t[r]);if(le)for(var r of le(t))at.call(t,r)&&me(e,r,t[r]);return e},A=(e,t)=>ot(e,st(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{c(r.next(l))}catch(i){o(i)}},a=l=>{try{c(r.throw(l))}catch(i){o(i)}},c=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);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 z=Object.defineProperty,ct=Object.defineProperties,lt=Object.getOwnPropertyDescriptor,mt=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertySymbols,dt=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,ue=(e,t,r)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fe=(e,t)=>{for(var r in t||(t={}))dt.call(t,r)&&ue(e,r,t[r]);if(de)for(var r of de(t))ut.call(t,r)&&ue(e,r,t[r]);return e},pt=(e,t)=>ct(e,mt(t)),ft=(e,t)=>{for(var r in t)z(e,r,{get:t[r],enumerable:!0})},he=(e,t,r,n)=>{for(var o=n>1?void 0:n?lt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&z(t,r,o),o},ht=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{c(r.next(l))}catch(i){o(i)}},a=l=>{try{c(r.throw(l))}catch(i){o(i)}},c=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);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 gt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function q(e){return typeof e=="string"}function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function _t(e){return typeof e=="undefined"}function yt(e){return _t(e)||e===null}function Et(e){return typeof e=="function"}function _e(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var vt=(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))(vt||{}),bt=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}},ye=class extends bt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ee=class extends ye{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},b=class extends ye{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function S(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var St={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:St});var ve=Symbol.for("Jolibox.canIUseMap"),xt={};globalThis[ve]=xt;var be={get config(){return globalThis[ve]}};function Y(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let c=0;c<a;c++){let l=parseInt(o[c],10)||0,i=parseInt(s[c],10)||0;if(l>i){n=1;break}else if(l<i){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 Q=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Q||{}),X=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(X||{}),Rt=(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))(Rt||{}),pe=["name","params"],wt=["name","type","location","target","extra","timestamp","userId"],It=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function O(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 Tt(e){let t=e.location?O(e.location,pe):null,r=e.target?O(e.target,pe):null;return O(pt(fe({},e),{location:t,target:r}),wt)}function Se(e){let t=e.events.map(n=>Tt(n)),r=O(e.device,It);return[e.protocolVersion,t,r,e.project]}var Lt=()=>"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 Z(){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}}Z();var D={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")},At=()=>D.isiOS?"iOS":D.isAndroid?"Android":D.isMac?"Mac":D.isFacebook?"Facebook":"PC",Dt="device_id",Ut="advertising_id",xe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Lt()),window.__joliboxLocalStorage__.getItem(e)),Ot=()=>new URLSearchParams(window.location.search).get("deviceId")||xe(Dt),Pt=()=>xe(Ut),kt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ct=()=>{var e;let t=new URLSearchParams(window.location.search);return kt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Re=e=>{let t="JoliboxWebSDK",r=At(),n=navigator.language,o=Ot(),s=Pt();return`${t} (${Ct()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},$=class G{constructor(t){this.element=t,this.next=G.Undefined,this.prev=G.Undefined}};$.Undefined=new $(void 0);var d=$,Kt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Mt=0,U=class{constructor(e){this.value=e,this.id=Mt++}},x=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 U&&(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,a,c,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let i=new U(t);this._listeners?this._listeners instanceof U?this._listeners=[this._listeners,i]:this._listeners.push(i):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=i,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(l=(c=this.options)==null?void 0:c.onDidAddListener)==null||l.call(c,this),this._size++}),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 U?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ee=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=a=>t(...a.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)n.fire(fe({event:e},s.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Kt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},H={};ft(H,{None:()=>jt,filter:()=>Jt,once:()=>we,toPromise:()=>Nt});var jt=()=>{console.log("[Jolibox SDK] None Event")};function Nt(e){return new Promise(t=>we(e)(t))}function we(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Jt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var V=Symbol.for("Jolibox.hostEmitter"),Ft=()=>{let e=new ee;return globalThis[V]||(globalThis[V]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[V]},Ie=Ft();function Bt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Vt(e[n],t[n])}function Vt(e,t){if(q(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Et(t)){try{if(e instanceof t)return}catch(r){}if(!yt(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 P=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new x,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 Bt(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}};P=he([_e],P);var W=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new P,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=gt(3e4)),this._starActivation}executeCommand(e,...t){return ht(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),H.toPromise(H.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}}};W=he([_e],W);var Te=Symbol.for("Jolibox.commands");function $t(){return typeof globalThis!="undefined"?globalThis[Te]:void 0}function Gt(e){typeof globalThis!="undefined"&&(globalThis[Te]=e)}function h(){let e=$t();if(e)return e;let t=new P,r=new W,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Gt(n),n}var k=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Ht(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Wt(){return{platform:1e3,os:"h5",appVersion:"1.1.15-beta.1",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.15-beta.1",extra:{}}}var Le={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},zt=()=>{var t;let e=(t=Le[window.location.host])!=null?t:Le.default;return k?e.test:e.prod},qt=zt(),De=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ae;(Ae=AbortSignal.timeout)!=null||(AbortSignal.timeout=De);var Yt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Qt=Yt(),Xt=e=>m(void 0,null,function*(){try{let r=`${qt}/report`,n=Re("1.1.15-beta.1"),o=Qt,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:De(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function E(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:Q.ErrorTrace,location:Ht(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Wt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:X.WebSDK},s=Se(o);yield Xt(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>Ie.emit("onDocumentReady",R.startTime));var Zt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},R=Zt(),Ue=h(),te=e=>{Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(e)}}).catch(t=>{console.error(`Fallback report: ${t} ${JSON.stringify(e)}`),E({err:JSON.stringify({message:t.message,source:t.source,lineno:t.lineno,colno:t.colno,error:t.error})})})},re=te;window.addEventListener("unhandledrejection",te.bind(void 0));window.addEventListener("error",te.bind(void 0));window.onerror=(e,t,r,n,o)=>{Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})}}).catch(s=>{E({err:JSON.stringify({message:e,source:t,lineno:r,colno:n,error:o})})})};var ne=e=>{var c,l,i;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,a]=[(c=n[0])!=null?c:"0",(l=n[1])!=null?l:"0",(i=n[2])!=null?i:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},w=e=>parseInt(ne(e).major,10),I=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ne(e),{major:a,minor:c,patch:l,prerelease:i}=ne(t);return r!==a?r>a?1:-1:n!==c?n>c?1:-1:o!==l?o>l?1:-1:s&&!i?-1:!s&&i?1:s&&i?s>i?1:s<i?-1:0:0};var Oe=h(),C=(e,t)=>{Oe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Oe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};Z();var Ke="jolibox-sdk-loadermeta",Ce,T=JSON.parse((Ce=window.__joliboxLocalStorage__.getItem(Ke))!=null?Ce:"{}"),oe=Date.now(),Pe=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7,ke=e=>!/^(Failed to fetch version|Couldn't find the requested file)/.test(e);function er(){return m(this,null,function*(){let t=`${k?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/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=A(L({},T),{timestamp:oe});if(o){let{bootstrap_version:a}=T;if(!(a&&I(a,o)>=0)){let c=yield(yield fetch(se(o))).text();ke(c)&&(s=A(L({},s),{bootstrap_version:o,bootstrap_script:c}))}}if(n){let{implement_version:a}=T;if(!(a&&I(a,n)>=0)){let c=yield(yield fetch(ie(n))).text();ke(c)&&(s=A(L({},s),{implement_version:n,implement_script:c}))}}window.__joliboxLocalStorage__.setItem(Ke,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Me=e=>{let{currentMajorVersion:t,currentVersion:r,bootstrapUrl:n,implementUrl:o}=e;function s(){let{bootstrap_version:i,bootstrap_script:g,timestamp:_}=T;if(i&&g&&_&&!Pe(oe,_)&&w(i)==t&&I(i,r)>=0)return{script:g,type:"localscript"};try{let p=new XMLHttpRequest;return p.open("GET",n,!1),p.send(),{script:p.responseText,type:"fetch_from_cdn"}}catch(p){let u=new Ee(`Bootstrap module faile to fetch ${p}`);E({err:`${u}`})}}function a(){var p;let i=Date.now();C("jsSdkBegin",{t:i}),R.startTime=i;let{script:g,type:_}=(p=s())!=null?p:{};if(g){let u=document.createElement("script");u.type="text/javascript",u.innerHTML=g,document.head.appendChild(u),v("bootstrapModuleLoaded",Date.now()-i,{type:_})}}function c(i){(_=>m(this,null,function*(){try{let p=new Blob([_],{type:"application/javascript"}),u=URL.createObjectURL(p),rt=yield import(u);return URL.revokeObjectURL(u),rt}catch(p){let u=new b(`implement module evaluate error in h5:${p} `);E({err:`${u}`})}}))(i)}function l(){let i=Date.now(),{implement_script:g,implement_version:_,timestamp:p}=T;if(g&&_&&p&&!Pe(oe,p)&&w(_)==t&&I(_,r)>=0){c(g),v("implementModuleLoaded",Date.now()-i,{type:"loadscript"});return}let u=document.createElement("script");u.type="module",u.crossOrigin="anonymous",u.src=o,u.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(u)}return()=>{try{a(),l(),er()}catch(i){let g=new b(`module evaluate error: ${i}`);E({err:`${g}`})}}};var je=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let c=new Blob([a],{type:"application/javascript"}),l=URL.createObjectURL(c),i=yield import(l);return URL.revokeObjectURL(l),i}catch(c){re(new b(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();C("jsSdkBegin",{t:o}),R.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),v("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),l=r(t.implementUrl);n(l),v("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),re(new b(`module load failed ${o}`))}}};var tr="1.1.15-beta.1",K=tr,Fe=w(K),Be=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),rr=Be?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,se=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,ie=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,nr=e=>/^\d+\.\d+\.\d+$/.test(e),Ve=nr(K)?Fe:K,Ne=se(Ve),Je=ie(Ve);function or(){Be?je(rr,{bootstrapUrl:Ne,implementUrl:Je})():Me({bootstrapUrl:Ne,implementUrl:Je,currentMajorVersion:Fe,currentVersion:K})()}or();var $e=h();function Ge(){return $e.excuteCommandSync("API.getSystemInfoSync")}function He(){return $e.excuteCommandSync("API.env")}function We(e,t){var r;return(r=be.config[e])==null?void 0:r[t]}function ze(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 Ye="1.1.15-beta.1";function y(e){var c,l;let r=(l=(c=He().data)==null?void 0:c.deviceInfo)==null?void 0:l.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=We(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||Y(Ye,a,"<")?!1:o.length===0?!0:qe(s,o)||qe(s.properties,o)}function qe(e,t){if(!e)return!1;let r=ze(e,t);return r?ge(r)?!0:q(r)?Y(Ye,r,">="):!1:!1}var Qe=h();function Xe(){return m(this,null,function*(){return y("login")?yield Qe.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function Ze(){return m(this,null,function*(){return y("checkSession")?yield Qe.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var sr=h();function et(e){return m(this,null,function*(){return y("request")?yield sr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ae=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},tt=window.JoliboxRuntime||ae;var f=class{constructor(){this.commands=h();this._emitter=new ee}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return y(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ir="LifecycleSDK.onReady",M=class extends f{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(ir,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 j=class extends f{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var N=class extends f{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)}}};var J=class extends f{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 F=class extends f{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var B=class extends f{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var ce=class{constructor(){this.jssdkVersion="1.1.15-beta.1";this.runtime=new tt;this.ads=new N;this.lifecycle=new M;this.storage=new j;this.keyboard=new J;this.task=new F;this.router=new B;this.getSystemInfoSync=Ge.bind(this);this.canIUse=y.bind(this);this.login=Xe.bind(this);this.checkSession=Ze.bind(this);this.request=et.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router}}};window.JoliboxSDK=ce;})();
1
+ "use strict";(()=>{var tt=Object.defineProperty,rt=Object.defineProperties;var nt=Object.getOwnPropertyDescriptors;var le=Object.getOwnPropertySymbols;var ot=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable;var me=(e,t,r)=>t in e?tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,w=(e,t)=>{for(var r in t||(t={}))ot.call(t,r)&&me(e,r,t[r]);if(le)for(var r of le(t))st.call(t,r)&&me(e,r,t[r]);return e},T=(e,t)=>rt(e,nt(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 W=Object.defineProperty,it=Object.defineProperties,at=Object.getOwnPropertyDescriptor,ct=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertySymbols,lt=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable,ue=(e,t,r)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fe=(e,t)=>{for(var r in t||(t={}))lt.call(t,r)&&ue(e,r,t[r]);if(de)for(var r of de(t))mt.call(t,r)&&ue(e,r,t[r]);return e},dt=(e,t)=>it(e,ct(t)),ut=(e,t)=>{for(var r in t)W(e,r,{get:t[r],enumerable:!0})},he=(e,t,r,n)=>{for(var o=n>1?void 0:n?at(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&W(t,r,o),o},pt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let 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 ft(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function z(e){return typeof e=="string"}function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function ht(e){return typeof e=="undefined"}function gt(e){return ht(e)||e===null}function _t(e){return typeof e=="function"}function _e(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Et=(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))(Et||{}),q=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}},Ee=class extends q{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var ye=class extends Ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},b=class extends Ee{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function y(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var yt={log:y("log"),warn:y("warn"),info:y("info"),error:y("error"),debug:y("debug")};Object.assign(globalThis,{logger:yt});var Se=Symbol.for("Jolibox.canIUseMap"),St={};globalThis[Se]=St;var be={get config(){return globalThis[Se]}};function Y(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){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 Q=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Q||{}),X=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(X||{}),bt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(bt||{}),pe=["name","params"],vt=["name","type","location","target","extra","timestamp","userId"],xt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function D(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 Rt(e){let t=e.location?D(e.location,pe):null,r=e.target?D(e.target,pe):null;return D(dt(fe({},e),{location:t,target:r}),vt)}function ve(e){let t=e.events.map(n=>Rt(n)),r=D(e.device,xt);return[e.protocolVersion,t,r,e.project]}var It=()=>"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 Z(){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}}Z();var A={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")},wt=()=>A.isiOS?"iOS":A.isAndroid?"Android":A.isMac?"Mac":A.isFacebook?"Facebook":"PC",Tt="device_id",At="advertising_id",xe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,It()),window.__joliboxLocalStorage__.getItem(e)),Lt=()=>new URLSearchParams(window.location.search).get("deviceId")||xe(Tt),Dt=()=>xe(At),Ut=e=>e.charAt(0).toUpperCase()+e.slice(1),Ot=()=>{var e;let t=new URLSearchParams(window.location.search);return Ut((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Re=e=>{let t="JoliboxWebSDK",r=wt(),n=navigator.language,o=Lt(),s=Dt();return`${t} (${Ot()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},V=class ${constructor(t){this.element=t,this.next=$.Undefined,this.prev=$.Undefined}};V.Undefined=new V(void 0);var d=V,kt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Pt=0,L=class{constructor(e){this.value=e,this.id=Pt++}},S=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 L&&(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,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new L(t);this._listeners?this._listeners instanceof L?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++}),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 L?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ee=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new S,o=a=>t(...a.args);this.listerHandlerMap.set(t,o),n.event(o),this.listeners.set(e,n);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)n.fire(fe({event:e},s.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new kt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},G={};ut(G,{None:()=>Ct,filter:()=>Mt,once:()=>Ie,toPromise:()=>Kt});var Ct=()=>{console.log("[Jolibox SDK] None Event")};function Kt(e){return new Promise(t=>Ie(e)(t))}function Ie(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Mt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new S(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var B=Symbol.for("Jolibox.hostEmitter"),jt=()=>{let e=new ee;return globalThis[B]||(globalThis[B]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[B]},we=jt();function Nt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Jt(e[n],t[n])}function Jt(e,t){if(z(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(_t(t)){try{if(e instanceof t)return}catch(r){}if(!gt(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 U=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new S,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 Nt(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}};U=he([_e],U);var H=class{constructor(){this._onWillExecuteCommand=new S,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new S,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new U,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=ft(3e4)),this._starActivation}executeCommand(e,...t){return pt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),G.toPromise(G.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}}};H=he([_e],H);var Te=Symbol.for("Jolibox.commands");function Ft(){return typeof globalThis!="undefined"?globalThis[Te]:void 0}function Bt(e){typeof globalThis!="undefined"&&(globalThis[Te]=e)}function p(){let e=Ft();if(e)return e;let t=new U,r=new H,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Bt(n),n}var O=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Vt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function $t(){return{platform:1e3,os:"h5",appVersion:"1.1.16-beta.1",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.16-beta.1",extra:{}}}var Ae={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Gt=()=>{var t;let e=(t=Ae[window.location.host])!=null?t:Ae.default;return O?e.test:e.prod},Ht=Gt(),De=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Le;(Le=AbortSignal.timeout)!=null||(AbortSignal.timeout=De);var Wt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},zt=Wt(),qt=e=>m(void 0,null,function*(){try{let r=`${Ht}/report`,n=Re("1.1.16-beta.1"),o=zt,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:De(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function _(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:Q.ErrorTrace,location:Vt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=$t(),o={protocolVersion:"1.0.0",events:[t],device:r,project:X.WebSDK},s=ve(o);yield qt(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>we.emit("onDocumentReady",v.startTime));var Yt=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},v=Yt(),Ue=p(),te=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 q?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),_({err:JSON.stringify(t)})})},re=te;window.addEventListener("unhandledrejection",te.bind(void 0));window.addEventListener("error",te.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()};Ue.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{_({err:JSON.stringify(s)})})};var ne=e=>{var l,i,c;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,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},x=e=>parseInt(ne(e).major,10),R=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ne(e),{major:a,minor:l,patch:i,prerelease:c}=ne(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Oe=p(),k=(e,t)=>{Oe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},E=(e,t,r)=>{Oe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};Z();var Ce="jolibox-sdk-loadermeta",Pe,I=JSON.parse((Pe=window.__joliboxLocalStorage__.getItem(Ce))!=null?Pe:"{}"),oe=Date.now(),ke=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Qt(){return m(this,null,function*(){let t=`${O?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/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=T(w({},I),{timestamp:oe});if(o){let{bootstrap_version:a}=I;a&&R(a,o)>=0||(s=T(w({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=I;a&&R(a,n)>=0||(s=T(w({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ce,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ke=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=I;i&&c&&!ke(oe,c)&&x(i)==t&&R(i,r)>=0&&(n=se(i));try{let f=new XMLHttpRequest;return f.open("GET",n,!1),f.send(),{script:f.responseText,type:"fetch_from_cdn"}}catch(f){let h=new ye(`Bootstrap module faile to fetch ${f}`);_({err:`${h}`})}}function a(){var h;let i=Date.now();k("jsSdkBegin",{t:i}),v.startTime=i;let{script:c,type:f}=(h=s())!=null?h:{};if(c){let F=document.createElement("script");F.type="text/javascript",F.innerHTML=c,document.head.appendChild(F),E("bootstrapModuleLoaded",Date.now()-i,{type:f})}}function l(){let i=Date.now(),{implement_version:c,timestamp:f}=I;c&&f&&!ke(oe,f)&&x(c)==t&&R(c,r)>=0&&(o=ie(c));let h=document.createElement("script");h.type="module",h.crossOrigin="anonymous",h.src=o,h.onload=()=>{E("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(h)}return()=>{try{a(),l(),Qt()}catch(i){let c=new b(`module evaluate error: ${i}`);_({err:`${c}`})}}};var Me=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){re(new b(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();k("jsSdkBegin",{t:o}),v.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),E("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),E("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),re(new b(`module load failed ${o}`))}}};var Xt="1.1.16-beta.1",P=Xt,Je=x(P),Fe=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Zt=Fe?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,se=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,ie=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,er=e=>/^\d+\.\d+\.\d+$/.test(e),Be=er(P)?Je:P,je=se(Be),Ne=ie(Be);function tr(){Fe?Me(Zt,{bootstrapUrl:je,implementUrl:Ne})():Ke({bootstrapUrl:je,implementUrl:Ne,currentMajorVersion:Je,currentVersion:P})()}tr();var Ve=p();function $e(){return Ve.excuteCommandSync("API.getSystemInfoSync")}function Ge(){return Ve.excuteCommandSync("API.env")}function He(e,t){var r;return(r=be.config[e])==null?void 0:r[t]}function We(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 qe="1.1.16-beta.1";function g(e){var l,i;let r=(i=(l=Ge().data)==null?void 0:l.deviceInfo)==null?void 0:i.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=He(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||Y(qe,a,"<")?!1:o.length===0?!0:ze(s,o)||ze(s.properties,o)}function ze(e,t){if(!e)return!1;let r=We(e,t);return r?ge(r)?!0:z(r)?Y(qe,r,">="):!1:!1}var Ye=p();function Qe(){return m(this,null,function*(){return g("login")?yield Ye.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function Xe(){return m(this,null,function*(){return g("checkSession")?yield Ye.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var rr=p();function Ze(e){return m(this,null,function*(){return g("request")?yield rr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ae=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},et=window.JoliboxRuntime||ae;var u=class{constructor(){this.commands=p();this._emitter=new ee}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return g(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var nr="LifecycleSDK.onReady",C=class extends u{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(nr,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 K=class extends u{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var M=class extends u{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)}}};var j=class extends u{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 N=class extends u{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var J=class extends u{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var ce=class{constructor(){this.jssdkVersion="1.1.16-beta.1";this.runtime=new et;this.ads=new M;this.lifecycle=new C;this.storage=new K;this.keyboard=new j;this.task=new N;this.router=new J;this.getSystemInfoSync=$e.bind(this);this.canIUse=g.bind(this);this.login=Qe.bind(this);this.checkSession=Xe.bind(this);this.request=Ze.bind(this);window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router}}};window.JoliboxSDK=ce;})();
package/dist/index.js CHANGED
@@ -772,21 +772,42 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
772
772
  var timeline = timelineFactory();
773
773
  var commands = ir();
774
774
  var rejectHandler = event => {
775
+ let errorInfo;
776
+ if (event instanceof ErrorEvent) {
777
+ errorInfo = {
778
+ message: event.message,
779
+ source: event.filename,
780
+ lineno: event.lineno,
781
+ colno: event.colno,
782
+ error: event.error ? event.error.stack || event.error.toString() : null
783
+ };
784
+ } else if ("reason" in event) {
785
+ const reason = event.reason;
786
+ errorInfo = {
787
+ message: reason instanceof Error ? reason.message : String(reason),
788
+ stack: reason instanceof Error ? reason.stack : null,
789
+ type: "unhandledrejection"
790
+ };
791
+ } else if (event instanceof h) {
792
+ errorInfo = {
793
+ message: event.message,
794
+ name: event.name,
795
+ stack: event.stack
796
+ };
797
+ } else {
798
+ errorInfo = {
799
+ unknownError: true
800
+ };
801
+ }
775
802
  commands.executeCommand("ReportSDK.traceSystem", {
776
803
  event: "globalJsError",
777
804
  info: {
778
- err: JSON.stringify(event)
805
+ err: JSON.stringify(errorInfo)
779
806
  }
780
807
  }).catch(e => {
781
- console.error(`Fallback report: ${e} ${JSON.stringify(event)}`);
808
+ console.error(`Fallback report: ${e} ${JSON.stringify(errorInfo)}`);
782
809
  trackError({
783
- err: JSON.stringify({
784
- message: e.message,
785
- source: e.source,
786
- lineno: e.lineno,
787
- colno: e.colno,
788
- error: e.error
789
- })
810
+ err: JSON.stringify(errorInfo)
790
811
  });
791
812
  });
792
813
  };
@@ -794,26 +815,22 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
794
815
  window.addEventListener("unhandledrejection", rejectHandler.bind(void 0));
795
816
  window.addEventListener("error", rejectHandler.bind(void 0));
796
817
  window.onerror = (message, source, lineno, colno, error) => {
818
+ const errorInfo = {
819
+ message,
820
+ source,
821
+ lineno,
822
+ colno,
823
+ stack: error?.stack,
824
+ errorString: error?.toString()
825
+ };
797
826
  commands.executeCommand("ReportSDK.traceSystem", {
798
827
  event: "globalJsError",
799
828
  info: {
800
- err: JSON.stringify({
801
- message,
802
- source,
803
- lineno,
804
- colno,
805
- error
806
- })
829
+ err: JSON.stringify(errorInfo)
807
830
  }
808
831
  }).catch(e => {
809
832
  trackError({
810
- err: JSON.stringify({
811
- message,
812
- source,
813
- lineno,
814
- colno,
815
- error
816
- })
833
+ err: JSON.stringify(errorInfo)
817
834
  });
818
835
  });
819
836
  };
@@ -891,7 +908,6 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
891
908
  var CURRENT_VERSION_STORE = JSON.parse(window.__joliboxLocalStorage__.getItem(LOCAL_STORE_KEY) ?? "{}");
892
909
  var now = Date.now();
893
910
  var expired = (now2, prev) => now2 > prev && Math.abs(now2 - prev) / (1e3 * 60 * 60 * 24) >= 7;
894
- var isLegalScript = str => !/^(Failed to fetch version|Couldn't find the requested file)/.test(str);
895
911
  async function fetchCurrentRemoteScript() {
896
912
  const host = testMode ? "https://stg-api.jolibox.com" : "https://api.jolibox.com";
897
913
  const path = `${host}/api/fe-configs/js-sdk/version-metadata`;
@@ -915,12 +931,10 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
915
931
  bootstrap_version: currentLocalBootstrapVersion
916
932
  } = CURRENT_VERSION_STORE;
917
933
  if (currentLocalBootstrapVersion && compare(currentLocalBootstrapVersion, bootstrap_version) >= 0) {} else {
918
- const currentBootstrapModuleStr = await (await fetch(getBoostrapModuleUrl(bootstrap_version))).text();
919
- isLegalScript(currentBootstrapModuleStr) && (currentStore = {
934
+ currentStore = {
920
935
  ...currentStore,
921
- bootstrap_version,
922
- bootstrap_script: currentBootstrapModuleStr
923
- });
936
+ bootstrap_version
937
+ };
924
938
  }
925
939
  }
926
940
  if (implement_version) {
@@ -928,12 +942,10 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
928
942
  implement_version: currentLocalImpelementVersion
929
943
  } = CURRENT_VERSION_STORE;
930
944
  if (currentLocalImpelementVersion && compare(currentLocalImpelementVersion, implement_version) >= 0) {} else {
931
- const currentImplementModuleStr = await (await fetch(getImplementModuleUrl(implement_version))).text();
932
- isLegalScript(currentImplementModuleStr) && (currentStore = {
945
+ currentStore = {
933
946
  ...currentStore,
934
- implement_version,
935
- implement_script: currentImplementModuleStr
936
- });
947
+ implement_version
948
+ };
937
949
  }
938
950
  }
939
951
  window.__joliboxLocalStorage__.setItem(LOCAL_STORE_KEY, JSON.stringify(currentStore));
@@ -944,22 +956,18 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
944
956
  var createLoadImplement = params => {
945
957
  const {
946
958
  currentMajorVersion: currentMajorVersion2,
947
- currentVersion: currentVersion2,
948
- bootstrapUrl,
949
- implementUrl
959
+ currentVersion: currentVersion2
950
960
  } = params;
961
+ let bootstrapUrl = params.bootstrapUrl;
962
+ let implementUrl = params.implementUrl;
951
963
  function fetchCurrentBootstrapModule() {
952
964
  const {
953
965
  bootstrap_version,
954
- bootstrap_script,
955
966
  timestamp
956
967
  } = CURRENT_VERSION_STORE;
957
- if (bootstrap_version && bootstrap_script && timestamp) {
968
+ if (bootstrap_version && timestamp) {
958
969
  if (!expired(now, timestamp) && major(bootstrap_version) == currentMajorVersion2 && compare(bootstrap_version, currentVersion2) >= 0) {
959
- return {
960
- script: bootstrap_script,
961
- type: "localscript"
962
- };
970
+ bootstrapUrl = getBoostrapModuleUrl(bootstrap_version);
963
971
  }
964
972
  }
965
973
  try {
@@ -997,39 +1005,15 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
997
1005
  });
998
1006
  }
999
1007
  }
1000
- function evalLocalJSModule(code) {
1001
- const evalJS = async code2 => {
1002
- try {
1003
- const blob = new Blob([code2], {
1004
- type: "application/javascript"
1005
- });
1006
- const blobUrl = URL.createObjectURL(blob);
1007
- const module = await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(blobUrl);
1008
- URL.revokeObjectURL(blobUrl);
1009
- return module;
1010
- } catch (error) {
1011
- const internalError = new Q(`implement module evaluate error in h5:${error} `);
1012
- trackError({
1013
- err: `${internalError}`
1014
- });
1015
- }
1016
- };
1017
- evalJS(code);
1018
- }
1019
1008
  function loadRemoteImplement() {
1020
1009
  const implStartLoad = Date.now();
1021
1010
  const {
1022
- implement_script,
1023
1011
  implement_version,
1024
1012
  timestamp
1025
1013
  } = CURRENT_VERSION_STORE;
1026
- if (implement_script && implement_version && timestamp) {
1014
+ if (implement_version && timestamp) {
1027
1015
  if (!expired(now, timestamp) && major(implement_version) == currentMajorVersion2 && compare(implement_version, currentVersion2) >= 0) {
1028
- evalLocalJSModule(implement_script);
1029
- trackPerformance("implementModuleLoaded", Date.now() - implStartLoad, {
1030
- type: "loadscript"
1031
- });
1032
- return;
1016
+ implementUrl = getImplementModuleUrl(implement_version);
1033
1017
  }
1034
1018
  }
1035
1019
  const asyncScript = document.createElement("script");
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.1.15-beta.1",
4
+ "version": "1.1.16-beta.1",
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.1.15-beta.1",
11
- "@jolibox/types": "1.1.15-beta.1"
10
+ "@jolibox/common": "1.1.16-beta.1",
11
+ "@jolibox/types": "1.1.16-beta.1"
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.1.15-beta.1 clean
3
+ > @jolibox/sdk@1.1.16-beta.1 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/sdk@1.1.15-beta.1 build:cjs
7
+ > @jolibox/sdk@1.1.16-beta.1 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.1.15-beta.1 build:esm
11
+ > @jolibox/sdk@1.1.16-beta.1 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.1.15-beta.1 build:iife
15
+ > @jolibox/sdk@1.1.16-beta.1 build:iife
16
16
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
17
17
 
package/src/events.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { hostEmitter, createCommands, BaseError, EProject } from '@jolibox/common';
1
+ import { hostEmitter, createCommands, BaseError } from '@jolibox/common';
2
2
  import { trackError } from './utils/event-tracker';
3
3
  document.addEventListener('DOMContentLoaded', () => hostEmitter.emit('onDocumentReady', timeline.startTime));
4
4
 
@@ -19,24 +19,46 @@ export const timeline = timelineFactory();
19
19
  const commands = createCommands();
20
20
 
21
21
  const rejectHandler = (event: PromiseRejectionEvent | ErrorEvent | BaseError) => {
22
+ let errorInfo;
23
+
24
+ if (event instanceof ErrorEvent) {
25
+ errorInfo = {
26
+ message: event.message,
27
+ source: event.filename,
28
+ lineno: event.lineno,
29
+ colno: event.colno,
30
+ error: event.error ? event.error.stack || event.error.toString() : null
31
+ };
32
+ } else if ('reason' in event) {
33
+ // PromiseRejectionEvent
34
+ const reason = event.reason;
35
+ errorInfo = {
36
+ message: reason instanceof Error ? reason.message : String(reason),
37
+ stack: reason instanceof Error ? reason.stack : null,
38
+ type: 'unhandledrejection'
39
+ };
40
+ } else if (event instanceof BaseError) {
41
+ errorInfo = {
42
+ message: event.message,
43
+ name: event.name,
44
+ stack: event.stack
45
+ };
46
+ } else {
47
+ errorInfo = { unknownError: true };
48
+ }
49
+
22
50
  commands
23
51
  .executeCommand('ReportSDK.traceSystem', {
24
52
  event: 'globalJsError',
25
53
  info: {
26
- err: JSON.stringify(event)
54
+ err: JSON.stringify(errorInfo)
27
55
  }
28
56
  })
29
57
  .catch((e) => {
30
58
  // 兜底上报
31
- console.error(`Fallback report: ${e} ${JSON.stringify(event)}`);
59
+ console.error(`Fallback report: ${e} ${JSON.stringify(errorInfo)}`);
32
60
  trackError({
33
- err: JSON.stringify({
34
- message: e.message,
35
- source: e.source,
36
- lineno: e.lineno,
37
- colno: e.colno,
38
- error: e.error
39
- })
61
+ err: JSON.stringify(errorInfo)
40
62
  });
41
63
  });
42
64
  };
@@ -46,29 +68,26 @@ export const reportError = rejectHandler;
46
68
  window.addEventListener('unhandledrejection', rejectHandler.bind(this));
47
69
  window.addEventListener('error', rejectHandler.bind(this));
48
70
  window.onerror = (message, source, lineno, colno, error) => {
71
+ const errorInfo = {
72
+ message,
73
+ source,
74
+ lineno,
75
+ colno,
76
+ stack: error?.stack,
77
+ errorString: error?.toString()
78
+ };
79
+
49
80
  commands
50
81
  .executeCommand('ReportSDK.traceSystem', {
51
82
  event: 'globalJsError',
52
83
  info: {
53
- err: JSON.stringify({
54
- message,
55
- source,
56
- lineno,
57
- colno,
58
- error
59
- })
84
+ err: JSON.stringify(errorInfo)
60
85
  }
61
86
  })
62
87
  .catch((e) => {
63
88
  // 兜底上报
64
89
  trackError({
65
- err: JSON.stringify({
66
- message,
67
- source,
68
- lineno,
69
- colno,
70
- error
71
- })
90
+ err: JSON.stringify(errorInfo)
72
91
  });
73
92
  });
74
93
  };
package/src/loader/h5.ts CHANGED
@@ -17,10 +17,7 @@ declare global {
17
17
  const LOCAL_STORE_KEY = 'jolibox-sdk-loadermeta';
18
18
  interface LocalStoreMeta {
19
19
  bootstrap_version?: string;
20
- bootstrap_script?: string;
21
-
22
20
  implement_version?: string;
23
- implement_script?: string;
24
21
  timestamp?: number;
25
22
  }
26
23
 
@@ -32,11 +29,10 @@ const now = Date.now();
32
29
  const expired = (now: number, prev: number) =>
33
30
  now > prev && Math.abs(now - prev) / (1000 * 60 * 60 * 24) >= 7;
34
31
 
35
- const isLegalScript = (str: string) =>
36
- !/^(Failed to fetch version|Couldn't find the requested file)/.test(str);
37
32
  async function fetchCurrentRemoteScript() {
38
33
  const host = testMode ? 'https://stg-api.jolibox.com' : 'https://api.jolibox.com';
39
34
  const path = `${host}/api/fe-configs/js-sdk/version-metadata`;
35
+
40
36
  try {
41
37
  const response = await fetch(path, {
42
38
  method: 'GET',
@@ -51,13 +47,10 @@ async function fetchCurrentRemoteScript() {
51
47
  if (currentLocalBootstrapVersion && compare(currentLocalBootstrapVersion, bootstrap_version) >= 0) {
52
48
  // no-op
53
49
  } else {
54
- const currentBootstrapModuleStr = await (await fetch(getBoostrapModuleUrl(bootstrap_version))).text();
55
- isLegalScript(currentBootstrapModuleStr) &&
56
- (currentStore = {
57
- ...currentStore,
58
- bootstrap_version,
59
- bootstrap_script: currentBootstrapModuleStr
60
- });
50
+ currentStore = {
51
+ ...currentStore,
52
+ bootstrap_version
53
+ };
61
54
  }
62
55
  }
63
56
  if (implement_version) {
@@ -65,15 +58,10 @@ async function fetchCurrentRemoteScript() {
65
58
  if (currentLocalImpelementVersion && compare(currentLocalImpelementVersion, implement_version) >= 0) {
66
59
  // no-op
67
60
  } else {
68
- const currentImplementModuleStr = await (
69
- await fetch(getImplementModuleUrl(implement_version))
70
- ).text();
71
- isLegalScript(currentImplementModuleStr) &&
72
- (currentStore = {
73
- ...currentStore,
74
- implement_version,
75
- implement_script: currentImplementModuleStr
76
- });
61
+ currentStore = {
62
+ ...currentStore,
63
+ implement_version
64
+ };
77
65
  }
78
66
  }
79
67
 
@@ -89,12 +77,15 @@ export const createLoadImplement = (params: {
89
77
  bootstrapUrl: string;
90
78
  implementUrl: string;
91
79
  }) => {
92
- const { currentMajorVersion, currentVersion, bootstrapUrl, implementUrl } = params;
80
+ const { currentMajorVersion, currentVersion } = params;
81
+
82
+ let bootstrapUrl = params.bootstrapUrl;
83
+ let implementUrl = params.implementUrl;
93
84
  function fetchCurrentBootstrapModule():
94
85
  | { script: string; type: 'localscript' | 'fetch_from_cdn' }
95
86
  | undefined {
96
- const { bootstrap_version, bootstrap_script, timestamp } = CURRENT_VERSION_STORE;
97
- if (bootstrap_version && bootstrap_script && timestamp) {
87
+ const { bootstrap_version, timestamp } = CURRENT_VERSION_STORE;
88
+ if (bootstrap_version && timestamp) {
98
89
  /**
99
90
  * if current SDK major version is same && remote version is larget than current, use latest version
100
91
  */
@@ -103,7 +94,7 @@ export const createLoadImplement = (params: {
103
94
  major(bootstrap_version) == currentMajorVersion &&
104
95
  compare(bootstrap_version, currentVersion) >= 0
105
96
  ) {
106
- return { script: bootstrap_script, type: 'localscript' };
97
+ bootstrapUrl = getBoostrapModuleUrl(bootstrap_version);
107
98
  }
108
99
  }
109
100
  try {
@@ -136,31 +127,11 @@ export const createLoadImplement = (params: {
136
127
  }
137
128
  }
138
129
 
139
- function evalLocalJSModule(code: string) {
140
- const evalJS = async (code: string) => {
141
- try {
142
- const blob = new Blob([code], { type: 'application/javascript' });
143
- const blobUrl = URL.createObjectURL(blob);
144
- const module = await import(blobUrl);
145
- URL.revokeObjectURL(blobUrl);
146
- return module;
147
- } catch (error) {
148
- const internalError = new InternalJSModuleEvalError(
149
- `implement module evaluate error in h5:${error} `
150
- );
151
- trackError({
152
- err: `${internalError}`
153
- });
154
- }
155
- };
156
- evalJS(code);
157
- }
158
-
159
130
  // load remote impletation
160
131
  function loadRemoteImplement() {
161
132
  const implStartLoad = Date.now();
162
- const { implement_script, implement_version, timestamp } = CURRENT_VERSION_STORE;
163
- if (implement_script && implement_version && timestamp) {
133
+ const { implement_version, timestamp } = CURRENT_VERSION_STORE;
134
+ if (implement_version && timestamp) {
164
135
  /**
165
136
  * if current SDK major version is same && remote version is larget than current, use latest version
166
137
  */
@@ -169,9 +140,7 @@ export const createLoadImplement = (params: {
169
140
  major(implement_version) == currentMajorVersion &&
170
141
  compare(implement_version, currentVersion) >= 0
171
142
  ) {
172
- evalLocalJSModule(implement_script);
173
- trackPerformance('implementModuleLoaded', Date.now() - implStartLoad, { type: 'loadscript' });
174
- return;
143
+ implementUrl = getImplementModuleUrl(implement_version);
175
144
  }
176
145
  }
177
146
  const asyncScript = document.createElement('script');