@jolibox/sdk 1.1.16-beta.5 → 1.1.16-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  "packages/sdk/.eslintrc.js": "c11c589d14fe58bf4d37d259d8323b193bab6092",
5
5
  "packages/sdk/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
6
6
  "packages/sdk/esbuild.config.js": "1725a85515499085a7c9799b834c6f632073401c",
7
- "packages/sdk/package.json": "b311ec1c9203697af2f3ad603a8c3801a707ca42",
7
+ "packages/sdk/package.json": "7abda10603c3ea6bfb876a479ba3050cb9c5ecce",
8
8
  "packages/sdk/src/__tests__/index.test.ts": "f22e0c0741297803ac3ec016b1dcc166cd2248bd",
9
9
  "packages/sdk/src/api/__tests__/canIUse.test.ts": "300e4de3768f9510e956050d326d4977bc621f34",
10
10
  "packages/sdk/src/api/can-i-use.ts": "4fd7efe21419d39e535584d7ab8e6a3c4e186877",
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var D=Object.defineProperty,it=Object.defineProperties,at=Object.getOwnPropertyDescriptor,ct=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertyNames,fe=Object.getOwnPropertySymbols;var ge=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable;var he=(e,t,r)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,A=(e,t)=>{for(var r in t||(t={}))ge.call(t,r)&&he(e,r,t[r]);if(fe)for(var r of fe(t))mt.call(t,r)&&he(e,r,t[r]);return e},U=(e,t)=>it(e,ct(t));var dt=(e,t)=>{for(var r in t)D(e,r,{get:t[r],enumerable:!0})},ut=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of lt(t))!ge.call(e,o)&&o!==r&&D(e,o,{get:()=>t[o],enumerable:!(n=at(t,o))||n.enumerable});return e};var pt=e=>ut(D({},"__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 pr={};dt(pr,{JoliboxSDK:()=>H});module.exports=pt(pr);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,ft=Object.defineProperties,ht=Object.getOwnPropertyDescriptor,gt=Object.getOwnPropertyDescriptors,_e=Object.getOwnPropertySymbols,_t=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable,Ee=(e,t,r)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yt=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&Ee(e,r,t[r]);if(_e)for(var r of _e(t))Et.call(t,r)&&Ee(e,r,t[r]);return e},vt=(e,t)=>ft(e,gt(t)),St=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},ve=(e,t,r,n)=>{for(var o=n>1?void 0:n?ht(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},bt=(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 xt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function X(e){return typeof e=="string"}function Se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Rt(e){return typeof e=="undefined"}function It(e){return Rt(e)||e===null}function wt(e){return typeof e=="function"}function be(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Tt=(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))(Tt||{}),Z=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}},xe=class extends Z{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Re=class extends xe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends xe{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 Lt={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:Lt});var Ie=Symbol.for("Jolibox.canIUseMap"),Dt={};globalThis[Ie]=Dt;var we={get config(){return globalThis[Ie]}};function ee(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 te=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(te||{}),re=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(re||{}),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||{}),ye=["name","params"],Ut=["name","type","location","target","extra","timestamp","userId"],Ot=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function kt(e){let t=e.location?k(e.location,ye):null,r=e.target?k(e.target,ye):null;return k(vt(yt({},e),{location:t,target:r}),Ut)}function Te(e){let t=e.events.map(n=>kt(n)),r=k(e.device,Ot);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 ne(){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}}ne();var O={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Ct=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Kt="device_id",Mt="advertising_id",Le=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Pt()),window.__joliboxLocalStorage__.getItem(e)),jt=()=>new URLSearchParams(window.location.search).get("deviceId")||Le(Kt),Nt=()=>Le(Mt),Jt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ft=()=>{var e;let t=new URLSearchParams(window.location.search);return Jt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},De=e=>{let t="JoliboxWebSDK",r=Ct(),n=navigator.language,o=jt(),s=Nt();return`${t} (${Ft()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},W=class z{constructor(t){this.element=t,this.next=z.Undefined,this.prev=z.Undefined}};W.Undefined=new W(void 0);var d=W,Bt=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}},Vt=0,b=class{constructor(e){this.value=e,this.id=Vt++}},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 b&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new b(t);return this._listeners?this._listeners instanceof b?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++,()=>{var u,f,E,ue;if(!this._disposed){if(this._listeners instanceof b)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let pe=this._listeners.indexOf(c);pe>=0&&(this._listeners.splice(pe,1),this._size--,this._size===0&&((ue=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ue.call(E)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof b?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},oe=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=l=>t(...l.args),s=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:s}),this.listeners.set(e,n);let a=this.cachedEventQueue.get(e);if(a)for(let l of a)t(...l.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Bt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},q={};St(q,{None:()=>$t,filter:()=>Gt,once:()=>Ae,toPromise:()=>Ht});var $t=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Ht(e){return new Promise(t=>Ae(e)(t))}function Ae(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"),Wt=()=>{let e=new oe;return globalThis[G]||(globalThis[G]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[G]},C=Wt();function zt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)qt(e[n],t[n])}function qt(e,t){if(X(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(wt(t)){try{if(e instanceof t)return}catch(r){}if(!It(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 zt(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=ve([be],P);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 P,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=xt(3e4)),this._starActivation}executeCommand(e,...t){return bt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),q.toPromise(q.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=ve([be],Q);var Ue=Symbol.for("Jolibox.commands");function Qt(){return typeof globalThis!="undefined"?globalThis[Ue]:void 0}function Yt(e){typeof globalThis!="undefined"&&(globalThis[Ue]=e)}function h(){let e=Qt();if(e)return e;let t=new P,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 K=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Xt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Zt(){return{platform:1e3,os:"h5",appVersion:"1.1.16-beta.5",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.16-beta.5",extra:{}}}var Oe={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"}},er=()=>{var t;let e=(t=Oe[window.location.host])!=null?t:Oe.default;return K?e.test:e.prod},tr=er(),Pe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},ke;(ke=AbortSignal.timeout)!=null||(AbortSignal.timeout=Pe);var rr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},nr=rr(),or=e=>m(void 0,null,function*(){try{let r=`${tr}/report`,n=De("1.1.16-beta.5"),o=nr,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:Pe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:te.ErrorTrace,location:Xt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Zt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:re.WebSDK},s=Te(o);yield or(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>C.emit("onDocumentReady",I.startTime));var sr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},I=sr(),Ce=h(),se=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 Z?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ce.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),y({err:JSON.stringify(t)})})},ie=se;window.addEventListener("unhandledrejection",se.bind(void 0));window.addEventListener("error",se.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()};Ce.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{y({err:JSON.stringify(s)})})};var ae=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}},w=e=>parseInt(ae(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ae(e),{major:a,minor:l,patch:i,prerelease:c}=ae(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 Ke=h(),M=(e,t)=>{Ke.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Ke.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ne();var Ne="jolibox-sdk-loadermeta",je,L=JSON.parse((je=window.__joliboxLocalStorage__.getItem(Ne))!=null?je:"{}"),ce=Date.now(),Me=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function ir(){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=U(A({},L),{timestamp:ce});if(o){let{bootstrap_version:a}=L;a&&T(a,o)>=0||(s=U(A({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=L;a&&T(a,n)>=0||(s=U(A({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ne,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}=L;i&&c&&!Me(ce,c)&&w(i)==t&&T(i,r)>=0&&(n=le(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new Re(`Bootstrap module faile to fetch ${u}`);y({err:`${f}`})}}function a(){var f;let i=Date.now();M("jsSdkBegin",{t:i}),I.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=c,document.head.appendChild(E),v("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=L;c&&u&&!Me(ce,u)&&w(c)==t&&T(c,r)>=0&&(o=me(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),ir()}catch(i){let c=new R(`module evaluate error: ${i}`);y({err:`${c}`})}}};var Fe=(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){ie(new R(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();M("jsSdkBegin",{t:o}),I.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 l=Date.now(),i=r(t.implementUrl);n(i),v("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),ie(new R(`module load failed ${o}`))}}};var ar="1.1.16-beta.5",j=ar,$e=w(j),He=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),cr=He?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,le=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,me=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,lr=e=>/^\d+\.\d+\.\d+$/.test(e),Ge=lr(j)?$e:j,Be=le(Ge),Ve=me(Ge);function mr(){He?Fe(cr,{bootstrapUrl:Be,implementUrl:Ve})():Je({bootstrapUrl:Be,implementUrl:Ve,currentMajorVersion:$e,currentVersion:j})()}mr();var We=h();function ze(){return We.excuteCommandSync("API.getSystemInfoSync")}function qe(){return We.excuteCommandSync("API.env")}function Qe(e,t){var r;return(r=we.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 Ze="1.1.16-beta.5";function _(e){var l,i;let r=(i=(l=qe().data)==null?void 0:l.deviceInfo)==null?void 0:i.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"||ee(Ze,a,"<")?!1:o.length===0?!0:Xe(s,o)||Xe(s.properties,o)}function Xe(e,t){if(!e)return!1;let r=Ye(e,t);return r?Se(r)?!0:X(r)?ee(Ze,r,">="):!1:!1}var et=h();function tt(){return m(this,null,function*(){return _("login")?yield et.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function rt(){return m(this,null,function*(){return _("checkSession")?yield et.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var dr=h();function nt(e){return m(this,null,function*(){return _("request")?yield dr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ot=(e,t)=>{C.on(e,t)};var de=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)}}},st=window.JoliboxRuntime||de;var p=class{constructor(){this.commands=h();this._emitter=new oe}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return _(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ur="LifecycleSDK.onReady",N=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(ur,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var J=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,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 F=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var B=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var V=class extends p{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 $=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.16-beta.5";this.runtime=new st;this.ads=new F;this.lifecycle=new N;this.storage=new J;this.keyboard=new B;this.task=new V;this.router=new $;this.getSystemInfoSync=ze.bind(this);this.canIUse=_.bind(this);this.login=tt.bind(this);this.checkSession=rt.bind(this);this.request=nt.bind(this);this.on=ot.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var H=g;window.JoliboxSDK=H;
1
+ "use strict";var D=Object.defineProperty,it=Object.defineProperties,at=Object.getOwnPropertyDescriptor,ct=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertyNames,he=Object.getOwnPropertySymbols;var _e=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable;var ge=(e,t,r)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,A=(e,t)=>{for(var r in t||(t={}))_e.call(t,r)&&ge(e,r,t[r]);if(he)for(var r of he(t))mt.call(t,r)&&ge(e,r,t[r]);return e},U=(e,t)=>it(e,ct(t));var dt=(e,t)=>{for(var r in t)D(e,r,{get:t[r],enumerable:!0})},ut=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of lt(t))!_e.call(e,o)&&o!==r&&D(e,o,{get:()=>t[o],enumerable:!(n=at(t,o))||n.enumerable});return e};var pt=e=>ut(D({},"__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 fr={};dt(fr,{JoliboxSDK:()=>H});module.exports=pt(fr);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,ft=Object.defineProperties,ht=Object.getOwnPropertyDescriptor,gt=Object.getOwnPropertyDescriptors,Ee=Object.getOwnPropertySymbols,_t=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable,ye=(e,t,r)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yt=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&ye(e,r,t[r]);if(Ee)for(var r of Ee(t))Et.call(t,r)&&ye(e,r,t[r]);return e},vt=(e,t)=>ft(e,gt(t)),bt=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},be=(e,t,r,n)=>{for(var o=n>1?void 0:n?ht(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},St=(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 xt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Z(e){return typeof e=="string"}function Se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Rt(e){return typeof e=="undefined"}function wt(e){return Rt(e)||e===null}function It(e){return typeof e=="function"}function xe(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Tt=(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))(Tt||{}),ee=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}},Re=class extends ee{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var we=class extends Re{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends Re{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function b(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Lt={log:b("log"),warn:b("warn"),info:b("info"),error:b("error"),debug:b("debug")};Object.assign(globalThis,{logger:Lt});var W=Symbol.for("Jolibox.canIUseMap"),Dt={};globalThis[W]||(globalThis[W]=Dt);var Ie={get config(){return globalThis[W]}};function te(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 re=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(re||{}),ne=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ne||{}),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||{}),ve=["name","params"],Ut=["name","type","location","target","extra","timestamp","userId"],Ot=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function kt(e){let t=e.location?k(e.location,ve):null,r=e.target?k(e.target,ve):null;return k(vt(yt({},e),{location:t,target:r}),Ut)}function Te(e){let t=e.events.map(n=>kt(n)),r=k(e.device,Ot);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 oe(){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}}oe();var Ct=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Kt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Mt="device_id",jt="advertising_id",Le=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Pt()),window.__joliboxLocalStorage__.getItem(e)),Nt=()=>new URLSearchParams(window.location.search).get("deviceId")||Le(Mt),Jt=()=>Le(jt),Ft=e=>e.charAt(0).toUpperCase()+e.slice(1),Bt=()=>{var e;let t=new URLSearchParams(window.location.search);return Ft((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},De=e=>{if(Ct())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Kt(),n=navigator.language,o=Nt(),s=Jt();return`${t} (${Bt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},z=class q{constructor(t){this.element=t,this.next=q.Undefined,this.prev=q.Undefined}};z.Undefined=new z(void 0);var d=z,Vt=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}},$t=0,S=class{constructor(e){this.value=e,this.id=$t++}},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 S&&(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 S(t);return this._listeners?this._listeners instanceof S?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++,()=>{var u,f,E,pe;if(!this._disposed){if(this._listeners instanceof S)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let fe=this._listeners.indexOf(c);fe>=0&&(this._listeners.splice(fe,1),this._size--,this._size===0&&((pe=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||pe.call(E)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof S?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},se=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=l=>t(...l.args),s=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:s}),this.listeners.set(e,n);let a=this.cachedEventQueue.get(e);if(a)for(let l of a)t(...l.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Vt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},Q={};bt(Q,{None:()=>Ht,filter:()=>Wt,once:()=>Ae,toPromise:()=>Gt});var Ht=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Gt(e){return new Promise(t=>Ae(e)(t))}function Ae(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Wt(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"),zt=()=>{let e=new se;return globalThis[G]||(globalThis[G]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[G]},C=zt();function qt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Qt(e[n],t[n])}function Qt(e,t){if(Z(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(It(t)){try{if(e instanceof t)return}catch(r){}if(!wt(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 qt(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=be([xe],P);var X=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=xt(3e4)),this._starActivation}executeCommand(e,...t){return St(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Q.toPromise(Q.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}}};X=be([xe],X);var Ue=Symbol.for("Jolibox.commands");function Xt(){return typeof globalThis!="undefined"?globalThis[Ue]:void 0}function Yt(e){typeof globalThis!="undefined"&&(globalThis[Ue]=e)}function h(){let e=Xt();if(e)return e;let t=new P,r=new X,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 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 er(){return{platform:1e3,os:"h5",appVersion:"1.1.16-beta.6",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.16-beta.6",extra:{}}}var Oe={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"}},tr=()=>{var t;let e=(t=Oe[window.location.host])!=null?t:Oe.default;return K?e.test:e.prod},rr=tr(),Pe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},ke;(ke=AbortSignal.timeout)!=null||(AbortSignal.timeout=Pe);var nr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},or=nr(),sr=e=>m(void 0,null,function*(){try{let r=`${rr}/report`,n=De("1.1.16-beta.6"),o=or,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:Pe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:Zt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=er(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=Te(o);yield sr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>C.emit("onDocumentReady",w.startTime));var ir=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},w=ir(),Ce=h(),ie=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 ee?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ce.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),y({err:JSON.stringify(t)})})},ae=ie;window.addEventListener("unhandledrejection",ie.bind(void 0));window.addEventListener("error",ie.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()};Ce.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{y({err:JSON.stringify(s)})})};var ce=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}},I=e=>parseInt(ce(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ce(e),{major:a,minor:l,patch:i,prerelease:c}=ce(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 Ke=h(),M=(e,t)=>{Ke.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Ke.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Ne="jolibox-sdk-loadermeta",je,L=JSON.parse((je=window.__joliboxLocalStorage__.getItem(Ne))!=null?je:"{}"),le=Date.now(),Me=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function ar(){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=U(A({},L),{timestamp:le});if(o){let{bootstrap_version:a}=L;a&&T(a,o)>=0||(s=U(A({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=L;a&&T(a,n)>=0||(s=U(A({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ne,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}=L;i&&c&&!Me(le,c)&&I(i)==t&&T(i,r)>=0&&(n=me(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new we(`Bootstrap module faile to fetch ${u}`);y({err:`${f}`})}}function a(){var f;let i=Date.now();M("jsSdkBegin",{t:i}),w.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=c,document.head.appendChild(E),v("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=L;c&&u&&!Me(le,u)&&I(c)==t&&T(c,r)>=0&&(o=de(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),ar()}catch(i){let c=new R(`module evaluate error: ${i}`);y({err:`${c}`})}}};var Fe=(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){ae(new R(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();M("jsSdkBegin",{t:o}),w.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 l=Date.now(),i=r(t.implementUrl);n(i),v("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),ae(new R(`module load failed ${o}`))}}};var cr="1.1.16-beta.6",j=cr,$e=I(j),He=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),lr=He?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,me=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,de=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,mr=e=>/^\d+\.\d+\.\d+$/.test(e),Ge=mr(j)?$e:j,Be=me(Ge),Ve=de(Ge);function dr(){He?Fe(lr,{bootstrapUrl:Be,implementUrl:Ve})():Je({bootstrapUrl:Be,implementUrl:Ve,currentMajorVersion:$e,currentVersion:j})()}dr();var We=h();function ze(){return We.excuteCommandSync("API.getSystemInfoSync")}function qe(){return We.excuteCommandSync("API.env")}function Qe(e,t){var r;return(r=Ie.config[e])==null?void 0:r[t]}function Xe(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 Ze="1.1.16-beta.6";function _(e){var l,i;let r=(i=(l=qe().data)==null?void 0:l.deviceInfo)==null?void 0:i.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"||te(Ze,a,"<")?!1:o.length===0?!0:Ye(s,o)||Ye(s.properties,o)}function Ye(e,t){if(!e)return!1;let r=Xe(e,t);return r?Se(r)?!0:Z(r)?te(Ze,r,">="):!1:!1}var et=h();function tt(){return m(this,null,function*(){return _("login")?yield et.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function rt(){return m(this,null,function*(){return _("checkSession")?yield et.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ur=h();function nt(e){return m(this,null,function*(){return _("request")?yield ur.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ot=(e,t)=>{C.on(e,t)};var ue=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)}}},st=window.JoliboxRuntime||ue;var p=class{constructor(){this.commands=h();this._emitter=new se}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return _(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var pr="LifecycleSDK.onReady",N=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(pr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var J=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,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 F=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var B=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var V=class extends p{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 $=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.16-beta.6";this.runtime=new st;this.ads=new F;this.lifecycle=new N;this.storage=new J;this.keyboard=new B;this.task=new V;this.router=new $;this.getSystemInfoSync=ze.bind(this);this.canIUse=_.bind(this);this.login=tt.bind(this);this.checkSession=rt.bind(this);this.request=nt.bind(this);this.on=ot.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var H=g;window.JoliboxSDK=H;
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- var ot=Object.defineProperty,st=Object.defineProperties;var it=Object.getOwnPropertyDescriptors;var pe=Object.getOwnPropertySymbols;var at=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var fe=(e,t,r)=>t in e?ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,D=(e,t)=>{for(var r in t||(t={}))at.call(t,r)&&fe(e,r,t[r]);if(pe)for(var r of pe(t))ct.call(t,r)&&fe(e,r,t[r]);return e},A=(e,t)=>st(e,it(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 q=Object.defineProperty,lt=Object.defineProperties,mt=Object.getOwnPropertyDescriptor,dt=Object.getOwnPropertyDescriptors,he=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,ge=(e,t,r)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ft=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&ge(e,r,t[r]);if(he)for(var r of he(t))pt.call(t,r)&&ge(e,r,t[r]);return e},ht=(e,t)=>lt(e,dt(t)),gt=(e,t)=>{for(var r in t)q(e,r,{get:t[r],enumerable:!0})},Ee=(e,t,r,n)=>{for(var o=n>1?void 0:n?mt(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},_t=(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 Et(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 yt(e){return typeof e=="undefined"}function vt(e){return yt(e)||e===null}function St(e){return typeof e=="function"}function ve(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var bt=(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))(bt||{}),Y=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 Y{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"}},R=class extends Se{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 xt={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:xt});var xe=Symbol.for("Jolibox.canIUseMap"),Rt={};globalThis[xe]=Rt;var Re={get config(){return globalThis[xe]}};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||{}),It=(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))(It||{}),_e=["name","params"],wt=["name","type","location","target","extra","timestamp","userId"],Tt=["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 Lt(e){let t=e.location?O(e.location,_e):null,r=e.target?O(e.target,_e):null;return O(ht(ft({},e),{location:t,target:r}),wt)}function Ie(e){let t=e.events.map(n=>Lt(n)),r=O(e.device,Tt);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 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")},At=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.isFacebook?"Facebook":"PC",Ut="device_id",Ot="advertising_id",we=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Dt()),window.__joliboxLocalStorage__.getItem(e)),kt=()=>new URLSearchParams(window.location.search).get("deviceId")||we(Ut),Pt=()=>we(Ot),Ct=e=>e.charAt(0).toUpperCase()+e.slice(1),Kt=()=>{var e;let t=new URLSearchParams(window.location.search);return Ct((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Te=e=>{let t="JoliboxWebSDK",r=At(),n=navigator.language,o=kt(),s=Pt();return`${t} (${Kt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},H=class G{constructor(t){this.element=t,this.next=G.Undefined,this.prev=G.Undefined}};H.Undefined=new H(void 0);var d=H,Mt=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}},jt=0,b=class{constructor(e){this.value=e,this.id=jt++}},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 b&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new b(t);return this._listeners?this._listeners instanceof b?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++,()=>{var u,f,E,de;if(!this._disposed){if(this._listeners instanceof b)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let ue=this._listeners.indexOf(c);ue>=0&&(this._listeners.splice(ue,1),this._size--,this._size===0&&((de=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||de.call(E)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof b?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},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=l=>t(...l.args),s=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:s}),this.listeners.set(e,n);let a=this.cachedEventQueue.get(e);if(a)for(let l of a)t(...l.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Mt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},W={};gt(W,{None:()=>Nt,filter:()=>Ft,once:()=>Le,toPromise:()=>Jt});var Nt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Jt(e){return new Promise(t=>Le(e)(t))}function Le(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Ft(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 $=Symbol.for("Jolibox.hostEmitter"),Bt=()=>{let e=new re;return globalThis[$]||(globalThis[$]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[$]},P=Bt();function Vt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)$t(e[n],t[n])}function $t(e,t){if(Q(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(St(t)){try{if(e instanceof t)return}catch(r){}if(!vt(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 Vt(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=Ee([ve],k);var z=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=Et(3e4)),this._starActivation}executeCommand(e,...t){return _t(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=Ee([ve],z);var De=Symbol.for("Jolibox.commands");function Ht(){return typeof globalThis!="undefined"?globalThis[De]:void 0}function Gt(e){typeof globalThis!="undefined"&&(globalThis[De]=e)}function h(){let e=Ht();if(e)return e;let t=new k,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 Gt(n),n}var C=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Wt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function zt(){return{platform:1e3,os:"h5",appVersion:"1.1.16-beta.5",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.16-beta.5",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"}},qt=()=>{var t;let e=(t=Ae[window.location.host])!=null?t:Ae.default;return C?e.test:e.prod},Qt=qt(),Oe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ue;(Ue=AbortSignal.timeout)!=null||(AbortSignal.timeout=Oe);var Yt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Xt=Yt(),Zt=e=>m(void 0,null,function*(){try{let r=`${Qt}/report`,n=Te("1.1.16-beta.5"),o=Xt,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 y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:Z.ErrorTrace,location:Wt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=zt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ee.WebSDK},s=Ie(o);yield Zt(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>P.emit("onDocumentReady",I.startTime));var er=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},I=er(),ke=h(),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 Y?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)}`),y({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=>{y({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}},w=e=>parseInt(se(e).major,10),T=(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=h(),K=(e,t)=>{Pe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Pe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};te();var Me="jolibox-sdk-loadermeta",Ke,L=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 tr(){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=A(D({},L),{timestamp:ie});if(o){let{bootstrap_version:a}=L;a&&T(a,o)>=0||(s=A(D({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=L;a&&T(a,n)>=0||(s=A(D({},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}=L;i&&c&&!Ce(ie,c)&&w(i)==t&&T(i,r)>=0&&(n=ae(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new be(`Bootstrap module faile to fetch ${u}`);y({err:`${f}`})}}function a(){var f;let i=Date.now();K("jsSdkBegin",{t:i}),I.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=c,document.head.appendChild(E),v("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=L;c&&u&&!Ce(ie,u)&&w(c)==t&&T(c,r)>=0&&(o=ce(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),tr()}catch(i){let c=new R(`module evaluate error: ${i}`);y({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 R(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();K("jsSdkBegin",{t:o}),I.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 l=Date.now(),i=r(t.implementUrl);n(i),v("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),oe(new R(`module load failed ${o}`))}}};var rr="1.1.16-beta.5",M=rr,Be=w(M),Ve=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),nr=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`,or=e=>/^\d+\.\d+\.\d+$/.test(e),$e=or(M)?Be:M,Je=ae($e),Fe=ce($e);function sr(){Ve?Ne(nr,{bootstrapUrl:Je,implementUrl:Fe})():je({bootstrapUrl:Je,implementUrl:Fe,currentMajorVersion:Be,currentVersion:M})()}sr();var He=h();function Ge(){return He.excuteCommandSync("API.getSystemInfoSync")}function We(){return He.excuteCommandSync("API.env")}function ze(e,t){var r;return(r=Re.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 Ye="1.1.16-beta.5";function _(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(Ye,a,"<")?!1:o.length===0?!0:Qe(s,o)||Qe(s.properties,o)}function Qe(e,t){if(!e)return!1;let r=qe(e,t);return r?ye(r)?!0:Q(r)?X(Ye,r,">="):!1:!1}var Xe=h();function Ze(){return m(this,null,function*(){return _("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 _("checkSession")?yield Xe.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ir=h();function tt(e){return m(this,null,function*(){return _("request")?yield ir.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var rt=(e,t)=>{P.on(e,t)};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 p=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 _(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ar="LifecycleSDK.onReady",j=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(ar,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 p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,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 p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var F=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var B=class extends p{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 p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.16-beta.5";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=Ge.bind(this);this.canIUse=_.bind(this);this.login=Ze.bind(this);this.checkSession=et.bind(this);this.request=tt.bind(this);this.on=rt.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var me=g;window.JoliboxSDK=me;export{me as JoliboxSDK};
1
+ var ot=Object.defineProperty,st=Object.defineProperties;var it=Object.getOwnPropertyDescriptors;var fe=Object.getOwnPropertySymbols;var at=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var he=(e,t,r)=>t in e?ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,D=(e,t)=>{for(var r in t||(t={}))at.call(t,r)&&he(e,r,t[r]);if(fe)for(var r of fe(t))ct.call(t,r)&&he(e,r,t[r]);return e},A=(e,t)=>st(e,it(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 Q=Object.defineProperty,lt=Object.defineProperties,mt=Object.getOwnPropertyDescriptor,dt=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,_e=(e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ft=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&_e(e,r,t[r]);if(ge)for(var r of ge(t))pt.call(t,r)&&_e(e,r,t[r]);return e},ht=(e,t)=>lt(e,dt(t)),gt=(e,t)=>{for(var r in t)Q(e,r,{get:t[r],enumerable:!0})},ye=(e,t,r,n)=>{for(var o=n>1?void 0:n?mt(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},_t=(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 Et(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function X(e){return typeof e=="string"}function ve(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function yt(e){return typeof e=="undefined"}function vt(e){return yt(e)||e===null}function bt(e){return typeof e=="function"}function be(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var St=(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))(St||{}),Y=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 Y{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var xe=class extends Se{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends Se{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function b(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var xt={log:b("log"),warn:b("warn"),info:b("info"),error:b("error"),debug:b("debug")};Object.assign(globalThis,{logger:xt});var H=Symbol.for("Jolibox.canIUseMap"),Rt={};globalThis[H]||(globalThis[H]=Rt);var Re={get config(){return globalThis[H]}};function Z(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 ee=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ee||{}),te=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(te||{}),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||{}),Ee=["name","params"],It=["name","type","location","target","extra","timestamp","userId"],Tt=["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 Lt(e){let t=e.location?O(e.location,Ee):null,r=e.target?O(e.target,Ee):null;return O(ht(ft({},e),{location:t,target:r}),It)}function we(e){let t=e.events.map(n=>Lt(n)),r=O(e.device,Tt);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 re(){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}}re();var At=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),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")},Ut=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.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"},Te=e=>{if(At())return window.navigator.userAgent;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 W{constructor(t){this.element=t,this.next=W.Undefined,this.prev=W.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,S=class{constructor(e){this.value=e,this.id=Nt++}},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 S&&(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 S(t);return this._listeners?this._listeners instanceof S?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++,()=>{var u,f,E,ue;if(!this._disposed){if(this._listeners instanceof S)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let pe=this._listeners.indexOf(c);pe>=0&&(this._listeners.splice(pe,1),this._size--,this._size===0&&((ue=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ue.call(E)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof S?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ne=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=l=>t(...l.args),s=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:s}),this.listeners.set(e,n);let a=this.cachedEventQueue.get(e);if(a)for(let l of a)t(...l.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e);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})}}},z={};gt(z,{None:()=>Jt,filter:()=>Bt,once:()=>Le,toPromise:()=>Ft});var Jt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Ft(e){return new Promise(t=>Le(e)(t))}function Le(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 x(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 ne;return globalThis[$]||(globalThis[$]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[$]},P=Vt();function $t(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ht(e[n],t[n])}function Ht(e,t){if(X(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(bt(t)){try{if(e instanceof t)return}catch(r){}if(!vt(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 $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}};k=ye([be],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=Et(3e4)),this._starActivation}executeCommand(e,...t){return _t(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=ye([be],q);var De=Symbol.for("Jolibox.commands");function Gt(){return typeof globalThis!="undefined"?globalThis[De]:void 0}function Wt(e){typeof globalThis!="undefined"&&(globalThis[De]=e)}function h(){let e=Gt();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 Wt(n),n}var C=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.6",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.16-beta.6",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"}},Qt=()=>{var t;let e=(t=Ae[window.location.host])!=null?t:Ae.default;return C?e.test:e.prod},Xt=Qt(),Oe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ue;(Ue=AbortSignal.timeout)!=null||(AbortSignal.timeout=Oe);var Yt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Zt=Yt(),er=e=>m(void 0,null,function*(){try{let r=`${Xt}/report`,n=Te("1.1.16-beta.6"),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 y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:ee.ErrorTrace,location:zt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=qt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:te.WebSDK},s=we(o);yield er(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>P.emit("onDocumentReady",w.startTime));var tr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},w=tr(),ke=h(),oe=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 Y?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)}`),y({err:JSON.stringify(t)})})},se=oe;window.addEventListener("unhandledrejection",oe.bind(void 0));window.addEventListener("error",oe.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=>{y({err:JSON.stringify(s)})})};var ie=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}},I=e=>parseInt(ie(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ie(e),{major:a,minor:l,patch:i,prerelease:c}=ie(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=h(),K=(e,t)=>{Pe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Pe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};re();var Me="jolibox-sdk-loadermeta",Ke,L=JSON.parse((Ke=window.__joliboxLocalStorage__.getItem(Me))!=null?Ke:"{}"),ae=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=`${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=A(D({},L),{timestamp:ae});if(o){let{bootstrap_version:a}=L;a&&T(a,o)>=0||(s=A(D({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=L;a&&T(a,n)>=0||(s=A(D({},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}=L;i&&c&&!Ce(ae,c)&&I(i)==t&&T(i,r)>=0&&(n=ce(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new xe(`Bootstrap module faile to fetch ${u}`);y({err:`${f}`})}}function a(){var f;let i=Date.now();K("jsSdkBegin",{t:i}),w.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=c,document.head.appendChild(E),v("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=L;c&&u&&!Ce(ae,u)&&I(c)==t&&T(c,r)>=0&&(o=le(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),rr()}catch(i){let c=new R(`module evaluate error: ${i}`);y({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){se(new R(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();K("jsSdkBegin",{t:o}),w.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 l=Date.now(),i=r(t.implementUrl);n(i),v("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),se(new R(`module load failed ${o}`))}}};var nr="1.1.16-beta.6",M=nr,Be=I(M),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,ce=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,le=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,sr=e=>/^\d+\.\d+\.\d+$/.test(e),$e=sr(M)?Be:M,Je=ce($e),Fe=le($e);function ir(){Ve?Ne(or,{bootstrapUrl:Je,implementUrl:Fe})():je({bootstrapUrl:Je,implementUrl:Fe,currentMajorVersion:Be,currentVersion:M})()}ir();var He=h();function Ge(){return He.excuteCommandSync("API.getSystemInfoSync")}function We(){return He.excuteCommandSync("API.env")}function ze(e,t){var r;return(r=Re.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 Xe="1.1.16-beta.6";function _(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"||Z(Xe,a,"<")?!1:o.length===0?!0:Qe(s,o)||Qe(s.properties,o)}function Qe(e,t){if(!e)return!1;let r=qe(e,t);return r?ve(r)?!0:X(r)?Z(Xe,r,">="):!1:!1}var Ye=h();function Ze(){return m(this,null,function*(){return _("login")?yield Ye.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function et(){return m(this,null,function*(){return _("checkSession")?yield Ye.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ar=h();function tt(e){return m(this,null,function*(){return _("request")?yield ar.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var rt=(e,t)=>{P.on(e,t)};var me=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||me;var p=class{constructor(){this.commands=h();this._emitter=new ne}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return _(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var cr="LifecycleSDK.onReady",j=class extends p{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 N=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,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 p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var F=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var B=class extends p{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 p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.16-beta.6";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=Ge.bind(this);this.canIUse=_.bind(this);this.login=Ze.bind(this);this.checkSession=et.bind(this);this.request=tt.bind(this);this.on=rt.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var de=g;window.JoliboxSDK=de;export{de as JoliboxSDK};
@@ -1 +1 @@
1
- "use strict";(()=>{var ot=Object.defineProperty,st=Object.defineProperties;var it=Object.getOwnPropertyDescriptors;var pe=Object.getOwnPropertySymbols;var at=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var fe=(e,t,r)=>t in e?ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,D=(e,t)=>{for(var r in t||(t={}))at.call(t,r)&&fe(e,r,t[r]);if(pe)for(var r of pe(t))ct.call(t,r)&&fe(e,r,t[r]);return e},A=(e,t)=>st(e,it(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 q=Object.defineProperty,lt=Object.defineProperties,mt=Object.getOwnPropertyDescriptor,dt=Object.getOwnPropertyDescriptors,he=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,ge=(e,t,r)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ft=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&ge(e,r,t[r]);if(he)for(var r of he(t))pt.call(t,r)&&ge(e,r,t[r]);return e},ht=(e,t)=>lt(e,dt(t)),gt=(e,t)=>{for(var r in t)q(e,r,{get:t[r],enumerable:!0})},Ee=(e,t,r,n)=>{for(var o=n>1?void 0:n?mt(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},_t=(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 Et(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 yt(e){return typeof e=="undefined"}function vt(e){return yt(e)||e===null}function St(e){return typeof e=="function"}function ve(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var bt=(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))(bt||{}),Y=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 Y{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"}},R=class extends Se{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 xt={log:S("log"),warn:S("warn"),info:S("info"),error:S("error"),debug:S("debug")};Object.assign(globalThis,{logger:xt});var xe=Symbol.for("Jolibox.canIUseMap"),Rt={};globalThis[xe]=Rt;var Re={get config(){return globalThis[xe]}};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||{}),It=(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))(It||{}),_e=["name","params"],wt=["name","type","location","target","extra","timestamp","userId"],Tt=["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 Lt(e){let t=e.location?O(e.location,_e):null,r=e.target?O(e.target,_e):null;return O(ht(ft({},e),{location:t,target:r}),wt)}function Ie(e){let t=e.events.map(n=>Lt(n)),r=O(e.device,Tt);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 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")},At=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.isFacebook?"Facebook":"PC",Ut="device_id",Ot="advertising_id",we=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Dt()),window.__joliboxLocalStorage__.getItem(e)),kt=()=>new URLSearchParams(window.location.search).get("deviceId")||we(Ut),Pt=()=>we(Ot),Ct=e=>e.charAt(0).toUpperCase()+e.slice(1),Kt=()=>{var e;let t=new URLSearchParams(window.location.search);return Ct((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Te=e=>{let t="JoliboxWebSDK",r=At(),n=navigator.language,o=kt(),s=Pt();return`${t} (${Kt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},H=class G{constructor(t){this.element=t,this.next=G.Undefined,this.prev=G.Undefined}};H.Undefined=new H(void 0);var d=H,Mt=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}},jt=0,b=class{constructor(e){this.value=e,this.id=jt++}},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 b&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new b(t);return this._listeners?this._listeners instanceof b?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++,()=>{var u,f,E,de;if(!this._disposed){if(this._listeners instanceof b)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let ue=this._listeners.indexOf(c);ue>=0&&(this._listeners.splice(ue,1),this._size--,this._size===0&&((de=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||de.call(E)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof b?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},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=l=>t(...l.args),s=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:s}),this.listeners.set(e,n);let a=this.cachedEventQueue.get(e);if(a)for(let l of a)t(...l.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Mt,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},W={};gt(W,{None:()=>Nt,filter:()=>Ft,once:()=>Le,toPromise:()=>Jt});var Nt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Jt(e){return new Promise(t=>Le(e)(t))}function Le(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Ft(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 $=Symbol.for("Jolibox.hostEmitter"),Bt=()=>{let e=new re;return globalThis[$]||(globalThis[$]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[$]},P=Bt();function Vt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)$t(e[n],t[n])}function $t(e,t){if(Q(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(St(t)){try{if(e instanceof t)return}catch(r){}if(!vt(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 Vt(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=Ee([ve],k);var z=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=Et(3e4)),this._starActivation}executeCommand(e,...t){return _t(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=Ee([ve],z);var De=Symbol.for("Jolibox.commands");function Ht(){return typeof globalThis!="undefined"?globalThis[De]:void 0}function Gt(e){typeof globalThis!="undefined"&&(globalThis[De]=e)}function h(){let e=Ht();if(e)return e;let t=new k,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 Gt(n),n}var C=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Wt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function zt(){return{platform:1e3,os:"h5",appVersion:"1.1.16-beta.5",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.16-beta.5",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"}},qt=()=>{var t;let e=(t=Ae[window.location.host])!=null?t:Ae.default;return C?e.test:e.prod},Qt=qt(),Oe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ue;(Ue=AbortSignal.timeout)!=null||(AbortSignal.timeout=Oe);var Yt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Xt=Yt(),Zt=e=>m(void 0,null,function*(){try{let r=`${Qt}/report`,n=Te("1.1.16-beta.5"),o=Xt,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 y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:Z.ErrorTrace,location:Wt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=zt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ee.WebSDK},s=Ie(o);yield Zt(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>P.emit("onDocumentReady",I.startTime));var er=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},I=er(),ke=h(),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 Y?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)}`),y({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=>{y({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}},w=e=>parseInt(se(e).major,10),T=(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=h(),K=(e,t)=>{Pe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Pe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};te();var Me="jolibox-sdk-loadermeta",Ke,L=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 tr(){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=A(D({},L),{timestamp:ie});if(o){let{bootstrap_version:a}=L;a&&T(a,o)>=0||(s=A(D({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=L;a&&T(a,n)>=0||(s=A(D({},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}=L;i&&c&&!Ce(ie,c)&&w(i)==t&&T(i,r)>=0&&(n=ae(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new be(`Bootstrap module faile to fetch ${u}`);y({err:`${f}`})}}function a(){var f;let i=Date.now();K("jsSdkBegin",{t:i}),I.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=c,document.head.appendChild(E),v("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=L;c&&u&&!Ce(ie,u)&&w(c)==t&&T(c,r)>=0&&(o=ce(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),tr()}catch(i){let c=new R(`module evaluate error: ${i}`);y({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 R(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();K("jsSdkBegin",{t:o}),I.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 l=Date.now(),i=r(t.implementUrl);n(i),v("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),oe(new R(`module load failed ${o}`))}}};var rr="1.1.16-beta.5",M=rr,Be=w(M),Ve=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),nr=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`,or=e=>/^\d+\.\d+\.\d+$/.test(e),$e=or(M)?Be:M,Je=ae($e),Fe=ce($e);function sr(){Ve?Ne(nr,{bootstrapUrl:Je,implementUrl:Fe})():je({bootstrapUrl:Je,implementUrl:Fe,currentMajorVersion:Be,currentVersion:M})()}sr();var He=h();function Ge(){return He.excuteCommandSync("API.getSystemInfoSync")}function We(){return He.excuteCommandSync("API.env")}function ze(e,t){var r;return(r=Re.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 Ye="1.1.16-beta.5";function _(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(Ye,a,"<")?!1:o.length===0?!0:Qe(s,o)||Qe(s.properties,o)}function Qe(e,t){if(!e)return!1;let r=qe(e,t);return r?ye(r)?!0:Q(r)?X(Ye,r,">="):!1:!1}var Xe=h();function Ze(){return m(this,null,function*(){return _("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 _("checkSession")?yield Xe.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ir=h();function tt(e){return m(this,null,function*(){return _("request")?yield ir.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var rt=(e,t)=>{P.on(e,t)};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 p=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 _(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ar="LifecycleSDK.onReady",j=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(ar,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 p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,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 p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var F=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var B=class extends p{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 p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.16-beta.5";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=Ge.bind(this);this.canIUse=_.bind(this);this.login=Ze.bind(this);this.checkSession=et.bind(this);this.request=tt.bind(this);this.on=rt.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var me=g;window.JoliboxSDK=me;})();
1
+ "use strict";(()=>{var ot=Object.defineProperty,st=Object.defineProperties;var it=Object.getOwnPropertyDescriptors;var fe=Object.getOwnPropertySymbols;var at=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var he=(e,t,r)=>t in e?ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,D=(e,t)=>{for(var r in t||(t={}))at.call(t,r)&&he(e,r,t[r]);if(fe)for(var r of fe(t))ct.call(t,r)&&he(e,r,t[r]);return e},A=(e,t)=>st(e,it(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 Q=Object.defineProperty,lt=Object.defineProperties,mt=Object.getOwnPropertyDescriptor,dt=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,_e=(e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ft=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&_e(e,r,t[r]);if(ge)for(var r of ge(t))pt.call(t,r)&&_e(e,r,t[r]);return e},ht=(e,t)=>lt(e,dt(t)),gt=(e,t)=>{for(var r in t)Q(e,r,{get:t[r],enumerable:!0})},ye=(e,t,r,n)=>{for(var o=n>1?void 0:n?mt(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},_t=(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 Et(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function X(e){return typeof e=="string"}function ve(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function yt(e){return typeof e=="undefined"}function vt(e){return yt(e)||e===null}function bt(e){return typeof e=="function"}function be(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var St=(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))(St||{}),Y=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 Y{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var xe=class extends Se{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends Se{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function b(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var xt={log:b("log"),warn:b("warn"),info:b("info"),error:b("error"),debug:b("debug")};Object.assign(globalThis,{logger:xt});var H=Symbol.for("Jolibox.canIUseMap"),Rt={};globalThis[H]||(globalThis[H]=Rt);var Re={get config(){return globalThis[H]}};function Z(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 ee=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ee||{}),te=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(te||{}),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||{}),Ee=["name","params"],It=["name","type","location","target","extra","timestamp","userId"],Tt=["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 Lt(e){let t=e.location?O(e.location,Ee):null,r=e.target?O(e.target,Ee):null;return O(ht(ft({},e),{location:t,target:r}),It)}function we(e){let t=e.events.map(n=>Lt(n)),r=O(e.device,Tt);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 re(){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}}re();var At=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),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")},Ut=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.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"},Te=e=>{if(At())return window.navigator.userAgent;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 W{constructor(t){this.element=t,this.next=W.Undefined,this.prev=W.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,S=class{constructor(e){this.value=e,this.id=Nt++}},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 S&&(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 S(t);return this._listeners?this._listeners instanceof S?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++,()=>{var u,f,E,ue;if(!this._disposed){if(this._listeners instanceof S)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let pe=this._listeners.indexOf(c);pe>=0&&(this._listeners.splice(pe,1),this._size--,this._size===0&&((ue=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ue.call(E)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof S?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ne=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=l=>t(...l.args),s=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:s}),this.listeners.set(e,n);let a=this.cachedEventQueue.get(e);if(a)for(let l of a)t(...l.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e);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})}}},z={};gt(z,{None:()=>Jt,filter:()=>Bt,once:()=>Le,toPromise:()=>Ft});var Jt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Ft(e){return new Promise(t=>Le(e)(t))}function Le(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 x(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 ne;return globalThis[$]||(globalThis[$]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[$]},P=Vt();function $t(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ht(e[n],t[n])}function Ht(e,t){if(X(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(bt(t)){try{if(e instanceof t)return}catch(r){}if(!vt(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 $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}};k=ye([be],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=Et(3e4)),this._starActivation}executeCommand(e,...t){return _t(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=ye([be],q);var De=Symbol.for("Jolibox.commands");function Gt(){return typeof globalThis!="undefined"?globalThis[De]:void 0}function Wt(e){typeof globalThis!="undefined"&&(globalThis[De]=e)}function h(){let e=Gt();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 Wt(n),n}var C=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.6",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.16-beta.6",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"}},Qt=()=>{var t;let e=(t=Ae[window.location.host])!=null?t:Ae.default;return C?e.test:e.prod},Xt=Qt(),Oe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ue;(Ue=AbortSignal.timeout)!=null||(AbortSignal.timeout=Oe);var Yt=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Zt=Yt(),er=e=>m(void 0,null,function*(){try{let r=`${Xt}/report`,n=Te("1.1.16-beta.6"),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 y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:ee.ErrorTrace,location:zt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=qt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:te.WebSDK},s=we(o);yield er(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>P.emit("onDocumentReady",w.startTime));var tr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},w=tr(),ke=h(),oe=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 Y?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)}`),y({err:JSON.stringify(t)})})},se=oe;window.addEventListener("unhandledrejection",oe.bind(void 0));window.addEventListener("error",oe.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=>{y({err:JSON.stringify(s)})})};var ie=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}},I=e=>parseInt(ie(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ie(e),{major:a,minor:l,patch:i,prerelease:c}=ie(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=h(),K=(e,t)=>{Pe.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},v=(e,t,r)=>{Pe.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};re();var Me="jolibox-sdk-loadermeta",Ke,L=JSON.parse((Ke=window.__joliboxLocalStorage__.getItem(Me))!=null?Ke:"{}"),ae=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=`${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=A(D({},L),{timestamp:ae});if(o){let{bootstrap_version:a}=L;a&&T(a,o)>=0||(s=A(D({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=L;a&&T(a,n)>=0||(s=A(D({},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}=L;i&&c&&!Ce(ae,c)&&I(i)==t&&T(i,r)>=0&&(n=ce(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new xe(`Bootstrap module faile to fetch ${u}`);y({err:`${f}`})}}function a(){var f;let i=Date.now();K("jsSdkBegin",{t:i}),w.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=c,document.head.appendChild(E),v("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=L;c&&u&&!Ce(ae,u)&&I(c)==t&&T(c,r)>=0&&(o=le(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{v("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),rr()}catch(i){let c=new R(`module evaluate error: ${i}`);y({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){se(new R(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();K("jsSdkBegin",{t:o}),w.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 l=Date.now(),i=r(t.implementUrl);n(i),v("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),se(new R(`module load failed ${o}`))}}};var nr="1.1.16-beta.6",M=nr,Be=I(M),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,ce=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/bootstrap@${e}/dist/index.js`,le=e=>`https://jsdelivr.jolibox.com/npm/@jolibox/implement@${e}/dist/index.js`,sr=e=>/^\d+\.\d+\.\d+$/.test(e),$e=sr(M)?Be:M,Je=ce($e),Fe=le($e);function ir(){Ve?Ne(or,{bootstrapUrl:Je,implementUrl:Fe})():je({bootstrapUrl:Je,implementUrl:Fe,currentMajorVersion:Be,currentVersion:M})()}ir();var He=h();function Ge(){return He.excuteCommandSync("API.getSystemInfoSync")}function We(){return He.excuteCommandSync("API.env")}function ze(e,t){var r;return(r=Re.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 Xe="1.1.16-beta.6";function _(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"||Z(Xe,a,"<")?!1:o.length===0?!0:Qe(s,o)||Qe(s.properties,o)}function Qe(e,t){if(!e)return!1;let r=qe(e,t);return r?ve(r)?!0:X(r)?Z(Xe,r,">="):!1:!1}var Ye=h();function Ze(){return m(this,null,function*(){return _("login")?yield Ye.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function et(){return m(this,null,function*(){return _("checkSession")?yield Ye.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var ar=h();function tt(e){return m(this,null,function*(){return _("request")?yield ar.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var rt=(e,t)=>{P.on(e,t)};var me=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||me;var p=class{constructor(){this.commands=h();this._emitter=new ne}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return _(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var cr="LifecycleSDK.onReady",j=class extends p{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 N=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,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 p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var F=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var B=class extends p{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 p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.16-beta.6";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=Ge.bind(this);this.canIUse=_.bind(this);this.login=Ze.bind(this);this.checkSession=et.bind(this);this.request=tt.bind(this);this.on=rt.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var de=g;window.JoliboxSDK=de;})();
package/dist/index.js CHANGED
@@ -5,24 +5,24 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
5
5
  (_JoliboxSDK2 => {
6
6
  // ../common/dist/index.es.js
7
7
  var M = Object.defineProperty;
8
- var xe = Object.defineProperties;
8
+ var Ee = Object.defineProperties;
9
9
  var Te = Object.getOwnPropertyDescriptor;
10
10
  var he = Object.getOwnPropertyDescriptors;
11
- var K = Object.getOwnPropertySymbols;
11
+ var J = Object.getOwnPropertySymbols;
12
12
  var Re = Object.prototype.hasOwnProperty;
13
13
  var ve = Object.prototype.propertyIsEnumerable;
14
- var J = (n, e, t) => e in n ? M(n, e, {
14
+ var G = (n, e, t) => e in n ? M(n, e, {
15
15
  enumerable: true,
16
16
  configurable: true,
17
17
  writable: true,
18
18
  value: t
19
19
  }) : n[e] = t;
20
- var E = (n, e) => {
21
- for (var t in e || (e = {})) Re.call(e, t) && J(n, t, e[t]);
22
- if (K) for (var t of K(e)) ve.call(e, t) && J(n, t, e[t]);
20
+ var x = (n, e) => {
21
+ for (var t in e || (e = {})) Re.call(e, t) && G(n, t, e[t]);
22
+ if (J) for (var t of J(e)) ve.call(e, t) && G(n, t, e[t]);
23
23
  return n;
24
24
  };
25
- var C = (n, e) => xe(n, he(e));
25
+ var C = (n, e) => Ee(n, he(e));
26
26
  var be = (n, e) => {
27
27
  for (var t in e) M(n, t, {
28
28
  get: e[t],
@@ -33,7 +33,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
33
33
  for (var o = r > 1 ? void 0 : r ? Te(e, t) : e, i = n.length - 1, a; i >= 0; i--) (a = n[i]) && (o = (r ? a(e, t, o) : a(o)) || o);
34
34
  return r && o && M(e, t, o), o;
35
35
  };
36
- var O = (n, e, t) => new Promise((r, o) => {
36
+ var N = (n, e, t) => new Promise((r, o) => {
37
37
  var i = s => {
38
38
  try {
39
39
  l(t.next(s));
@@ -77,7 +77,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
77
77
  if (this._eventListeners[t.type]) for (let r of this._eventListeners[t.type]) r.call(this, t);
78
78
  }, window.AbortController = n, window.AbortSignal = e;
79
79
  }
80
- function z(n) {
80
+ function $(n) {
81
81
  return new Promise(e => {
82
82
  setTimeout(() => {
83
83
  e();
@@ -99,7 +99,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
99
99
  function F(n) {
100
100
  return typeof n == "function";
101
101
  }
102
- function N(n) {
102
+ function O(n) {
103
103
  let e = n,
104
104
  t = null,
105
105
  r = function () {
@@ -126,14 +126,14 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
126
126
  this.kind = "INTERNAL_ERROR";
127
127
  }
128
128
  };
129
- var Y = class extends u {
129
+ var Z = class extends u {
130
130
  constructor() {
131
131
  super(...arguments);
132
132
  this.name = "INTERNAL_JS_MODULE_FETCH_ERROR";
133
133
  this.priority = "P0";
134
134
  }
135
135
  };
136
- var Z = class extends u {
136
+ var ee = class extends u {
137
137
  constructor() {
138
138
  super(...arguments);
139
139
  this.name = "INTERNAL_JS_MODULE_EVAL_ERROR";
@@ -146,7 +146,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
146
146
  ((o = (r = globalThis.VConsole) == null ? void 0 : r[n]) != null ? o : globalThis.console[n])(...arguments);
147
147
  };
148
148
  }
149
- var ce = {
149
+ var me = {
150
150
  log: b("log"),
151
151
  warn: b("warn"),
152
152
  info: b("info"),
@@ -154,17 +154,17 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
154
154
  debug: b("debug")
155
155
  };
156
156
  Object.assign(globalThis, {
157
- logger: ce
157
+ logger: me
158
158
  });
159
- var me = Symbol.for("Jolibox.canIUseMap");
160
- var Oe = {};
161
- globalThis[me] = Oe;
162
- var Vn = {
159
+ var V = Symbol.for("Jolibox.canIUseMap");
160
+ var Ne = {};
161
+ globalThis[V] || (globalThis[V] = Ne);
162
+ var jn = {
163
163
  get config() {
164
- return globalThis[me];
164
+ return globalThis[V];
165
165
  }
166
166
  };
167
- function Jn(n, e, t) {
167
+ function Gn(n, e, t) {
168
168
  let r = 0;
169
169
  if (n !== e) {
170
170
  let o = n.split("."),
@@ -198,7 +198,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
198
198
  return false;
199
199
  }
200
200
  }
201
- var Ne = (r => (r[r.System = 1e3] = "System", r[r.ErrorTrace = 1001] = "ErrorTrace", r[r.UserDefined = 1002] = "UserDefined", r))(Ne || {});
201
+ var Oe = (r => (r[r.System = 1e3] = "System", r[r.ErrorTrace = 1001] = "ErrorTrace", r[r.UserDefined = 1002] = "UserDefined", r))(Oe || {});
202
202
  var Le = (i => (i.MiniGame = "mini-game", i.MiniDrama = "mini-drama", i.App = "app", i.WebSDK = "web-sdk", i.AppSDK = "app-sdk", i))(Le || {});
203
203
  var Pe = (d => (d[d.App = 0] = "App", d[d.H5 = 1] = "H5", d[d.Weapp = 2] = "Weapp", d[d.Alipay = 3] = "Alipay", d[d.Gcash = 4] = "Gcash", d[d.Dana = 5] = "Dana", d[d.Umma = 6] = "Umma", d[d.WebSDK = 1e3] = "WebSDK", d[d.AppSDK = 1001] = "AppSDK", d[d.Other = 9999] = "Other", d))(Pe || {});
204
204
  var ue = ["name", "params"];
@@ -216,12 +216,12 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
216
216
  function Me(n) {
217
217
  let e = n.location ? P(n.location, ue) : null,
218
218
  t = n.target ? P(n.target, ue) : null;
219
- return P(C(E({}, n), {
219
+ return P(C(x({}, n), {
220
220
  location: e,
221
221
  target: t
222
222
  }), Se);
223
223
  }
224
- function $n(n) {
224
+ function Bn(n) {
225
225
  let e = n.events.map(r => Me(r)),
226
226
  t = P(n.device, ke);
227
227
  return [n.protocolVersion, e, t, n.project];
@@ -251,6 +251,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
251
251
  }
252
252
  }
253
253
  fe();
254
+ var Ue = () => !!(navigator.userAgent || "").includes("JoliboxPlatformSDK");
254
255
  var S = {
255
256
  isiOS: navigator.userAgent.includes("iPhone") || navigator.userAgent.includes("iPod") || navigator.userAgent.includes("iPad") || navigator.userAgent.includes("iPhone OS"),
256
257
  iosVersion: () => {
@@ -262,36 +263,37 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
262
263
  isFacebook: navigator.userAgent.includes("FB_IAB"),
263
264
  isPC: !navigator.userAgent.includes("iPhone") && !navigator.userAgent.includes("Android")
264
265
  };
265
- var Ue = () => S.isiOS ? "iOS" : S.isAndroid ? "Android" : S.isMac ? "Mac" : S.isFacebook ? "Facebook" : "PC";
266
- var De = "device_id";
267
- var Fe = "advertising_id";
266
+ var De = () => S.isiOS ? "iOS" : S.isAndroid ? "Android" : S.isMac ? "Mac" : S.isFacebook ? "Facebook" : "PC";
267
+ var Fe = "device_id";
268
+ var Ve = "advertising_id";
268
269
  var ge = n => (window.__joliboxLocalStorage__.getItem(n) || window.__joliboxLocalStorage__.setItem(n, pe()), window.__joliboxLocalStorage__.getItem(n));
269
- var Ve = () => {
270
+ var je = () => {
270
271
  let e = new URLSearchParams(window.location.search).get("deviceId");
271
- return e || ge(De);
272
+ return e || ge(Fe);
272
273
  };
273
- var je = () => ge(Fe);
274
- var He = n => n.charAt(0).toUpperCase() + n.slice(1);
275
- var Ke = () => {
274
+ var He = () => ge(Ve);
275
+ var Ke = n => n.charAt(0).toUpperCase() + n.slice(1);
276
+ var Je = () => {
276
277
  var e;
277
278
  let n = new URLSearchParams(window.location.search);
278
- return He((e = n.get("utm_source")) != null ? e : "") || "JoliboxSDK";
279
+ return Ke((e = n.get("utm_source")) != null ? e : "") || "JoliboxSDK";
279
280
  };
280
- var rt = n => {
281
+ var ot = n => {
282
+ if (Ue()) return window.navigator.userAgent;
281
283
  let e = "JoliboxWebSDK",
282
- t = Ue(),
284
+ t = De(),
283
285
  r = navigator.language,
284
- o = Ve(),
285
- i = je();
286
- return `${e} (${Ke()}${t}; UnknownModel; UnknownSystemVersion; ${r}) uuid/${o} adid/${i} version/${n || ""}`;
286
+ o = je(),
287
+ i = He();
288
+ return `${e} (${Je()}${t}; UnknownModel; UnknownSystemVersion; ${r}) uuid/${o} adid/${i} version/${n || ""}`;
287
289
  };
288
- var x = class x2 {
290
+ var E = class E2 {
289
291
  constructor(e) {
290
- this.element = e, this.next = x2.Undefined, this.prev = x2.Undefined;
292
+ this.element = e, this.next = E2.Undefined, this.prev = E2.Undefined;
291
293
  }
292
294
  };
293
- x.Undefined = new x(void 0);
294
- var c = x;
295
+ E.Undefined = new E(void 0);
296
+ var c = E;
295
297
  var k = class {
296
298
  constructor() {
297
299
  this._first = c.Undefined;
@@ -357,11 +359,11 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
357
359
  for (; e !== c.Undefined;) yield e.element, e = e.next;
358
360
  }
359
361
  };
360
- var Je = 0;
362
+ var Ge = 0;
361
363
  var y = class {
362
364
  constructor(e) {
363
365
  this.value = e;
364
- this.id = Je++;
366
+ this.id = Ge++;
365
367
  }
366
368
  };
367
369
  var p = class {
@@ -383,11 +385,11 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
383
385
  r && (t = t.bind(r));
384
386
  let o = new y(t);
385
387
  return this._listeners ? this._listeners instanceof y ? this._listeners = [this._listeners, o] : this._listeners.push(o) : ((a = (i = this.options) == null ? void 0 : i.onWillAddFirstListener) == null || a.call(i, this), this._listeners = o, (s = (l = this.options) == null ? void 0 : l.onDidFirstListener) == null || s.call(l, this)), (d = (m = this.options) == null ? void 0 : m.onDidAddListener) == null || d.call(m, this), this._size++, () => {
386
- var _, R, A, j;
388
+ var _, R, A, H;
387
389
  if (!this._disposed) {
388
390
  if (this._listeners instanceof y) this._listeners.id === o.id && (this._listeners = void 0, this._size = 0, (R = (_ = this.options) == null ? void 0 : _.onDidRemoveLastListener) == null || R.call(_));else if (this._listeners) {
389
- let H = this._listeners.indexOf(o);
390
- H >= 0 && (this._listeners.splice(H, 1), this._size--, this._size === 0 && ((j = (A = this.options) == null ? void 0 : A.onDidRemoveLastListener) == null || j.call(A)));
391
+ let K = this._listeners.indexOf(o);
392
+ K >= 0 && (this._listeners.splice(K, 1), this._size--, this._size === 0 && ((H = (A = this.options) == null ? void 0 : A.onDidRemoveLastListener) == null || H.call(A)));
391
393
  }
392
394
  }
393
395
  };
@@ -457,15 +459,15 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
457
459
  };
458
460
  var T = {};
459
461
  be(T, {
460
- None: () => Ge,
461
- filter: () => $e,
462
+ None: () => ze,
463
+ filter: () => Be,
462
464
  once: () => ye,
463
- toPromise: () => ze
465
+ toPromise: () => $e
464
466
  });
465
- var Ge = () => (console.log("[Jolibox SDK] None Event"), () => {
467
+ var ze = () => (console.log("[Jolibox SDK] None Event"), () => {
466
468
  console.log("[Jolibox SDK] None Event dispose");
467
469
  });
468
- function ze(n) {
470
+ function $e(n) {
469
471
  return new Promise(e => ye(n)(e));
470
472
  }
471
473
  function ye(n) {
@@ -477,7 +479,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
477
479
  }, null);
478
480
  };
479
481
  }
480
- function $e(n, e) {
482
+ function Be(n, e) {
481
483
  return (r => {
482
484
  let o,
483
485
  i = {
@@ -492,21 +494,21 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
492
494
  return n(i => e(i) && r.call(o, i), null);
493
495
  });
494
496
  }
495
- var V = Symbol.for("Jolibox.hostEmitter");
496
- var Be = () => {
497
+ var j = Symbol.for("Jolibox.hostEmitter");
498
+ var We = () => {
497
499
  let n = new I();
498
- return globalThis[V] || (globalThis[V] = {
500
+ return globalThis[j] || (globalThis[j] = {
499
501
  on: n.on.bind(n),
500
502
  off: n.off.bind(n),
501
503
  emit: n.emit.bind(n)
502
- }), globalThis[V];
504
+ }), globalThis[j];
503
505
  };
504
- var Pt = Be();
506
+ var St = We();
505
507
  function _e(n, e) {
506
508
  let t = Math.min(n.length, e.length);
507
- for (let r = 0; r < t; r++) We(n[r], e[r]);
509
+ for (let r = 0; r < t; r++) Qe(n[r], e[r]);
508
510
  }
509
- function We(n, e) {
511
+ function Qe(n, e) {
510
512
  if (U(e)) {
511
513
  if (typeof n !== e) throw new Error(`argument does not match constraint: typeof ${e}`);
512
514
  } else if (F(e)) {
@@ -554,7 +556,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
554
556
  return e;
555
557
  }
556
558
  };
557
- f = w([N], f);
559
+ f = w([O], f);
558
560
  var h = class {
559
561
  constructor() {
560
562
  this._onWillExecuteCommand = new p();
@@ -565,13 +567,13 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
565
567
  this._starActivation = null;
566
568
  }
567
569
  _activateStar() {
568
- return this._starActivation || (this._starActivation = z(3e4)), this._starActivation;
570
+ return this._starActivation || (this._starActivation = $(3e4)), this._starActivation;
569
571
  }
570
572
  executeCommand(e) {
571
573
  for (var _len4 = arguments.length, t = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
572
574
  t[_key4 - 1] = arguments[_key4];
573
575
  }
574
- return O(this, null, function* () {
576
+ return N(this, null, function* () {
575
577
  return this.registry.getCommand(e) ? this._tryExecuteCommand(e, t) : (yield Promise.all([Promise.race([this._activateStar(), T.toPromise(T.filter(this.registry.onDidRegisterCommand, o => o === e))])]), this._tryExecuteCommand(e, t));
576
578
  });
577
579
  }
@@ -620,16 +622,16 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
620
622
  }
621
623
  }
622
624
  };
623
- h = w([N], h);
624
- var Ee = Symbol.for("Jolibox.commands");
625
- function Qe() {
626
- return typeof globalThis != "undefined" ? globalThis[Ee] : void 0;
625
+ h = w([O], h);
626
+ var xe = Symbol.for("Jolibox.commands");
627
+ function qe() {
628
+ return typeof globalThis != "undefined" ? globalThis[xe] : void 0;
627
629
  }
628
- function qe(n) {
629
- typeof globalThis != "undefined" && (globalThis[Ee] = n);
630
+ function Xe(n) {
631
+ typeof globalThis != "undefined" && (globalThis[xe] = n);
630
632
  }
631
- function ar() {
632
- let n = Qe();
633
+ function dr() {
634
+ let n = qe();
633
635
  if (n) return n;
634
636
  let e = new f(),
635
637
  t = new h(),
@@ -654,7 +656,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
654
656
  return t.executeCommandThowErr(o, ...i);
655
657
  }
656
658
  };
657
- return qe(r), r;
659
+ return Xe(r), r;
658
660
  }
659
661
 
660
662
  // src/utils/env.ts
@@ -721,7 +723,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
721
723
  try {
722
724
  const reporterHost = API_BASE_URL;
723
725
  const url = `${reporterHost}/report`;
724
- const xua = rt("__JOLIBOX_LOCAL_SDK_VERSION__");
726
+ const xua = ot("__JOLIBOX_LOCAL_SDK_VERSION__");
725
727
  const joliSource = JOLI_SOURCE;
726
728
  const headers = {
727
729
  "Content-Type": "application/json"
@@ -744,7 +746,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
744
746
  try {
745
747
  const errEvent = {
746
748
  name: "globalJsError",
747
- type: Ne.ErrorTrace,
749
+ type: Oe.ErrorTrace,
748
750
  location: getLocation(),
749
751
  target: null,
750
752
  extra: errorData,
@@ -759,7 +761,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
759
761
  device,
760
762
  project: Le.WebSDK
761
763
  };
762
- const serializedEventPackage = $n(eventPackage);
764
+ const serializedEventPackage = Bn(eventPackage);
763
765
  await postToReporter(serializedEventPackage);
764
766
  } catch (error) {
765
767
  console.error("Failed to track error:", error);
@@ -767,7 +769,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
767
769
  }
768
770
 
769
771
  // src/events.ts
770
- document.addEventListener("DOMContentLoaded", () => Pt.emit("onDocumentReady", timeline.startTime));
772
+ document.addEventListener("DOMContentLoaded", () => St.emit("onDocumentReady", timeline.startTime));
771
773
  var timelineFactory = () => {
772
774
  let _beginLoad = 0;
773
775
  return {
@@ -780,7 +782,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
780
782
  };
781
783
  };
782
784
  var timeline = timelineFactory();
783
- var commands = ar();
785
+ var commands = dr();
784
786
  var rejectHandler = event => {
785
787
  let errorInfo;
786
788
  if (event instanceof ErrorEvent) {
@@ -897,7 +899,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
897
899
  };
898
900
 
899
901
  // src/utils/report.ts
900
- var commands2 = ar();
902
+ var commands2 = dr();
901
903
  var track = (event, info) => {
902
904
  commands2.executeCommand("ReportSDK.traceSystem", {
903
905
  event,
@@ -989,7 +991,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
989
991
  type: "fetch_from_cdn"
990
992
  };
991
993
  } catch (e) {
992
- const internalError = new Y(`Bootstrap module faile to fetch ${e}`);
994
+ const internalError = new Z(`Bootstrap module faile to fetch ${e}`);
993
995
  trackError({
994
996
  err: `${internalError}`
995
997
  });
@@ -1043,7 +1045,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
1043
1045
  loadRemoteImplement();
1044
1046
  fetchCurrentRemoteScript();
1045
1047
  } catch (e) {
1046
- const internalError = new Z(`module evaluate error: ${e}`);
1048
+ const internalError = new ee(`module evaluate error: ${e}`);
1047
1049
  trackError({
1048
1050
  err: `${internalError}`
1049
1051
  });
@@ -1073,7 +1075,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
1073
1075
  URL.revokeObjectURL(blobUrl);
1074
1076
  return module;
1075
1077
  } catch (error) {
1076
- reportError(new Z(`implement module evaluate error in native:${error} `));
1078
+ reportError(new ee(`implement module evaluate error in native:${error} `));
1077
1079
  }
1078
1080
  };
1079
1081
  evalJS(code);
@@ -1101,7 +1103,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
1101
1103
  });
1102
1104
  } catch (e) {
1103
1105
  console.error(`native load script error: ${e}`);
1104
- reportError(new Z(`module load failed ${e}`));
1106
+ reportError(new ee(`module load failed ${e}`));
1105
1107
  }
1106
1108
  };
1107
1109
  };
@@ -1151,7 +1153,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
1151
1153
  loadImplement();
1152
1154
 
1153
1155
  // src/api/get-system-info.ts
1154
- var commands3 = ar();
1156
+ var commands3 = dr();
1155
1157
  function getSystemInfoSync() {
1156
1158
  return commands3.excuteCommandSync("API.getSystemInfoSync");
1157
1159
  }
@@ -1161,7 +1163,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
1161
1163
 
1162
1164
  // src/utils/can-i-use.ts
1163
1165
  function getCanIUseConfig(platform, key) {
1164
- return Vn.config[platform]?.[key];
1166
+ return jn.config[platform]?.[key];
1165
1167
  }
1166
1168
  function get(obj, path, defaultValue) {
1167
1169
  const pathArray = Array.isArray(path) ? path : path.replace(/\[(\d+)\]/g, ".$1").split(".");
@@ -1189,7 +1191,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
1189
1191
  if (!api) return false;
1190
1192
  const apiVersion = api["version"];
1191
1193
  if (typeof apiVersion !== "string") return false;
1192
- if (Jn(__VERSION__, apiVersion, "<")) return false;
1194
+ if (Gn(__VERSION__, apiVersion, "<")) return false;
1193
1195
  if (rest.length === 0) return true;
1194
1196
  return checkRest(api, rest) || checkRest(api["properties"], rest);
1195
1197
  }
@@ -1198,12 +1200,12 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
1198
1200
  const v2 = get(info, paths);
1199
1201
  if (!v2) return false;
1200
1202
  if (Ie(v2)) return true;
1201
- if (U(v2)) return Jn(__VERSION__, v2, ">=");
1203
+ if (U(v2)) return Gn(__VERSION__, v2, ">=");
1202
1204
  return false;
1203
1205
  }
1204
1206
 
1205
1207
  // src/api/login.ts
1206
- var commands4 = ar();
1208
+ var commands4 = dr();
1207
1209
  async function login() {
1208
1210
  if (!canIUse("login")) {
1209
1211
  return {
@@ -1224,7 +1226,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
1224
1226
  }
1225
1227
 
1226
1228
  // src/api/request.ts
1227
- var commands5 = ar();
1229
+ var commands5 = dr();
1228
1230
  async function request(params) {
1229
1231
  if (!canIUse("request")) {
1230
1232
  return {
@@ -1237,7 +1239,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
1237
1239
 
1238
1240
  // src/api/on-custom-event.ts
1239
1241
  var onCustomEvent = (event, callback) => {
1240
- Pt.on(event, callback);
1242
+ St.on(event, callback);
1241
1243
  };
1242
1244
 
1243
1245
  // src/sdks/runtime.ts
@@ -1268,7 +1270,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
1268
1270
  // src/sdks/sdk.ts
1269
1271
  var BaseSDK = class {
1270
1272
  constructor() {
1271
- this.commands = ar();
1273
+ this.commands = dr();
1272
1274
  this._emitter = new I();
1273
1275
  }
1274
1276
  addEventListener(event, callback) {
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.16-beta.5",
4
+ "version": "1.1.16-beta.6",
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.16-beta.5",
11
- "@jolibox/types": "1.1.16-beta.5"
10
+ "@jolibox/common": "1.1.16-beta.6",
11
+ "@jolibox/types": "1.1.16-beta.6"
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.16-beta.5 clean
3
+ > @jolibox/sdk@1.1.16-beta.6 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/sdk@1.1.16-beta.5 build:cjs
7
+ > @jolibox/sdk@1.1.16-beta.6 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.16-beta.5 build:esm
11
+ > @jolibox/sdk@1.1.16-beta.6 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.16-beta.5 build:iife
15
+ > @jolibox/sdk@1.1.16-beta.6 build:iife
16
16
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
17
17