@jolibox/implement 1.1.11-beta.2 → 1.1.11-beta.3

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/implement/.eslintrc.js": "7a3d2747dc887655ca9e2d3ff621f7dfd98500b9",
5
5
  "packages/implement/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
6
6
  "packages/implement/esbuild.config.js": "86f1fd21722a2cb05216751578dcca66326e664a",
7
- "packages/implement/package.json": "2e1933b7c1e804b9256d20a06fcb330b024b0136",
7
+ "packages/implement/package.json": "4d87df05230b3def4d35eb53c9de913fdbee9630",
8
8
  "packages/implement/src/common/ads/ads-action-detection.ts": "5a7b9f85d7eab9e744f8a9fc7638063f43baa214",
9
9
  "packages/implement/src/common/ads/anti-cheating.ts": "ef5223f92815b93cf5ad0637b12132ea1861d622",
10
10
  "packages/implement/src/common/ads/channel-policy.ts": "c6d036be5cedf0c5d545fac271c6c8447ca55d8a",
@@ -71,14 +71,14 @@
71
71
  "packages/implement/src/native/api/keyboard.ts": "89703b1d8b0929cd0366fd663fee7690be705b38",
72
72
  "packages/implement/src/native/api/lifecycle.ts": "7bb706370443627607563254a7cda00037c2aa3f",
73
73
  "packages/implement/src/native/api/login.ts": "b957d3142462589395aeeee20e75ff6724ac6fbd",
74
- "packages/implement/src/native/api/navigate.ts": "a342d956415883892ec29c9ad6a709ec99a7d85b",
74
+ "packages/implement/src/native/api/navigate.ts": "9a3150581f500135e9707da2c17943762dc5d901",
75
75
  "packages/implement/src/native/api/request.ts": "a749e8ac9bb0bada4bca3008ac0be976621dcaf4",
76
76
  "packages/implement/src/native/api/storage.ts": "7f56694e3a7f47605512f9cee7fce48ac620c169",
77
77
  "packages/implement/src/native/api/task.ts": "26e06a3d6bbeaed34fd704d096e712448296607e",
78
78
  "packages/implement/src/native/bootstrap/bridge.ts": "4fe89e79d7fe43a1411388347c3cb3d6edc50376",
79
- "packages/implement/src/native/bootstrap/index.ts": "e1c37962386a228ab41f691981199210dd3ec0c8",
79
+ "packages/implement/src/native/bootstrap/index.ts": "b469f1370ee6e80943ff8effb3f38bbdc4d87ec0",
80
80
  "packages/implement/src/native/bootstrap/init-env.ts": "b7514d5d2db60da990575c1426243777aee57748",
81
- "packages/implement/src/native/bootstrap/retention.ts": "305a7f5b8011f3030a6d608ac9d59f0e7f6d3b16",
81
+ "packages/implement/src/native/bootstrap/retention.ts": "981b306cba6a4e2ff5ebad0f446683f1368ffe9a",
82
82
  "packages/implement/src/native/js-bridge/const.ts": "896b30d0d1996f42e1a1c391db5dc095190e166c",
83
83
  "packages/implement/src/native/js-bridge/index.ts": "b65e1e20edcce8ce270381a9c7c79cc981761ad4",
84
84
  "packages/implement/src/native/js-bridge/invoke.ts": "f7fd744c9491e4eb21b8d5ec6ef314a602a5adcb",
@@ -101,7 +101,7 @@
101
101
  "packages/implement/src/native/report/index.ts": "b30ccb9ef8e9124cbf156c6bdc3751465721383a",
102
102
  "packages/implement/src/native/report/task-tracker.ts": "09f8bc1dd157fe9a2159c261278bd2a92930cee3",
103
103
  "packages/implement/src/native/types/global.d.ts": "f4711617013586d0f3c7e2d9bec06f44a86bbc5d",
104
- "packages/implement/src/native/types/native-method-map.d.ts": "0df87bcd0a5599739a3cfe65ec9e1c4e02f6618f",
104
+ "packages/implement/src/native/types/native-method-map.d.ts": "0e7d37d4b4d204c7dd5bb50119f20f9bf8e7106f",
105
105
  "packages/implement/src/native/types/native-method.d.ts": "e4e22c921a5b54d4e10fe5ca18158d691fbfe3e7",
106
106
  "packages/implement/tsconfig.json": "b150f4b2ef4eb9d98f92135d481fe530eb7145b5"
107
107
  },
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var Ti=Object.create;var zt=Object.defineProperty,Ei=Object.defineProperties,Ii=Object.getOwnPropertyDescriptor,wi=Object.getOwnPropertyDescriptors,Si=Object.getOwnPropertyNames,Ye=Object.getOwnPropertySymbols,Ai=Object.getPrototypeOf,Yt=Object.prototype.hasOwnProperty,on=Object.prototype.propertyIsEnumerable;var nn=(e,t,r)=>t in e?zt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,L=(e,t)=>{for(var r in t||(t={}))Yt.call(t,r)&&nn(e,r,t[r]);if(Ye)for(var r of Ye(t))on.call(t,r)&&nn(e,r,t[r]);return e},q=(e,t)=>Ei(e,wi(t));var Be=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var an=(e,t)=>{var r={};for(var o in e)Yt.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&Ye)for(var o of Ye(e))t.indexOf(o)<0&&on.call(e,o)&&(r[o]=e[o]);return r};var G=(e,t)=>()=>(e&&(t=e(e=0)),t);var sn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ri=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Si(t))!Yt.call(e,a)&&a!==r&&zt(e,a,{get:()=>t[a],enumerable:!(o=Ii(t,a))||o.enumerable});return e};var cn=(e,t,r)=>(r=e!=null?Ti(Ai(e)):{},Ri(t||!e||!e.__esModule?zt(r,"default",{value:e,enumerable:!0}):r,e));var N=(e,t,r)=>new Promise((o,a)=>{var l=g=>{try{m(r.next(g))}catch(I){a(I)}},f=g=>{try{m(r.throw(g))}catch(I){a(I)}},m=g=>g.done?o(g.value):Promise.resolve(g.value).then(l,f);m((r=r.apply(e,t)).next())});function Ci(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function tr(e){return typeof e=="string"}function mn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function pn(e){return typeof e=="object"&&Array.isArray(e)}function Pi(e){return typeof e>"u"}function Di(e){return Pi(e)||e===null}function Oi(e){return typeof e=="function"}function hn(e){let t=e,r=null,o=function(...a){return r||(r=new t(...a)),r};return o.prototype=t.prototype,o}function gn(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function o(a,l){for(let f in l)if(Object.prototype.hasOwnProperty.call(l,f)){let m=a[f],g=l[f],I=r(m,g,f,a,l);I!==void 0?a[f]=I:un(g)&&un(m)?a[f]=o(L({},m),g):Array.isArray(g)&&Array.isArray(m)?a[f]=[...m,...g]:a[f]=g}return a}return o(e,t)}function un(e){return e&&typeof e=="object"&&e.constructor===Object}function vn(e,t){if(Array.isArray(e))return e.concat(t)}function Ve(e,t,r={}){let o=null,a,l,f,{leading:m=!1,trailing:g=!0}=r,I=()=>(f=e.apply(l,a),a=void 0,l=void 0,f),w=function(...x){a=x,l=this;let h=m&&!o;if(o&&clearTimeout(o),o=setTimeout(()=>{o=null,g&&!h&&I()},t),h)return I()};return w.cancel=()=>{o&&clearTimeout(o),o=null,a=l=void 0},w.flush=()=>{if(o)return clearTimeout(o),o=null,I()},w}function Li(e,t){return(...r)=>t(e,...r)}function En(e){return t=>Li(t,function(r,...o){if(typeof r=="function")try{return r.apply(this,o)}catch(a){e(new Ni(`${a}`))}})}function Me(e){return(...t)=>{var r,o;((o=(r=globalThis.VConsole)==null?void 0:r[e])!=null?o:globalThis.console[e])(...t)}}function Ze(e,t){return t.map(r=>{if(r==="params"&&e[r]){let o=e[r];return Object.keys(o).reduce((a,l)=>(a[l]=String(o[l]),a),{})}return e[r]})}function Vi(e){let t=e.location?Ze(e.location,ln):null,r=e.target?Ze(e.target,ln):null;return Ze(q(L({},e),{location:t,target:r}),Mi)}function ar(e){let t=e.events.map(o=>Vi(o)),r=Ze(e.device,$i);return[e.protocolVersion,t,r,e.project]}function Xi(e){return new Promise(t=>An(e)(t))}function An(e){return(t,r=null)=>{let o=!1;return e(a=>{if(!o)return o=!0,t.call(r,a)},null)}}function Zi(e,t){return(r=>{let o,a={onWillAddFirstListener(){o=r(l.fire,l)}},l=new $e(a);return l.event})((r,o=null)=>e(a=>t(a)&&r.call(o,a),null))}function ta(e,t){let r=Math.min(e.length,t.length);for(let o=0;o<r;o++)ra(e[o],t[o])}function ra(e,t){if(tr(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Oi(t)){try{if(e instanceof t)return}catch(r){}if(!Di(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")}}function ae(){if(globalThis[Xt])return globalThis[Xt];let e=new et,t=new er,r={registerCommand(o,a,l){e.registerCommand({id:o,handler:a,metadata:l})},executeCommand(o,...a){return t.executeCommand(o,...a)},excuteCommandSync(o,...a){return t.executeCommandThowErr(o,...a)}};return globalThis[Xt]=r,r}var dn,xi,ki,fn,Fi,rr,nr,yn,bn,Ni,_n,Tn,tt,or,ce,In,Ui,ir,je,xe,Bi,ln,Mi,$i,ji,Qe,Ki,Hi,Gi,wn,sr,Ji,Wi,qi,Sn,pe,J,zi,Yi,Xe,$e,_e,Zt,Qi,Qt,ea,Ke,et,er,Xt,K=G(()=>{"use strict";dn=Object.defineProperty,xi=Object.getOwnPropertyDescriptor,ki=(e,t)=>{for(var r in t)dn(e,r,{get:t[r],enumerable:!0})},fn=(e,t,r,o)=>{for(var a=o>1?void 0:o?xi(t,r):t,l=e.length-1,f;l>=0;l--)(f=e[l])&&(a=(o?f(t,r,a):f(a))||a);return o&&a&&dn(t,r,a),a};Fi=(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))(Fi||{}),rr=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}},nr=class extends rr{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},yn=class extends rr{constructor(){super(...arguments),this.kind="USER_ERROR"}},bn=class extends yn{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Ni=class extends yn{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},_n=class extends nr{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Tn=class extends nr{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},tt=class extends rr{constructor(e,t,r,o,a){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),o!==void 0&&(this.stack=o),a&&(this.priority=a)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},or=class extends nr{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};ce={log:Me("log"),warn:Me("warn"),info:Me("info"),error:Me("error"),debug:Me("debug")};Object.assign(globalThis,{logger:ce});In=Symbol.for("Jolibox.canIUseMap"),Ui={};globalThis[In]=Ui;ir={get config(){return globalThis[In]}},je=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(je||{}),xe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(xe||{}),Bi=(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))(Bi||{}),ln=["name","params"],Mi=["name","type","location","target","extra","timestamp","userId"],$i=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];ji=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),Qe={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")},Ki=()=>Qe.isiOS?"iOS":Qe.isAndroid?"Android":Qe.isMac?"Mac":Qe.isFacebook?"Facebook":"PC",Hi="device_id",Gi="advertising_id",wn=e=>(localStorage.getItem(e)||localStorage.setItem(e,ji()),localStorage.getItem(e)),sr=()=>wn(Hi),Ji=()=>wn(Gi),Wi=e=>e.charAt(0).toUpperCase()+e.slice(1),qi=()=>{var t;let e=new URLSearchParams(window.location.search);return Wi((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},Sn=e=>{let t="JoliboxWebSDK",r=Ki(),o=navigator.language,a=sr(),l=Ji();return`${t} (${qi()}${r}; UnknownModel; UnknownSystemVersion; ${o}) uuid/${a} adid/${l} version/${e||""}`},J=(pe=class{constructor(t){this.element=t,this.next=pe.Undefined,this.prev=pe.Undefined}},pe.Undefined=new pe(void 0),pe),zi=class{constructor(){this._first=J.Undefined,this._last=J.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===J.Undefined}clear(){let e=this._first;for(;e!==J.Undefined;){let t=e.next;e.prev=J.Undefined,e.next=J.Undefined,e=t}this._first=J.Undefined,this._last=J.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new J(e);if(this._first===J.Undefined)this._first=r,this._last=r;else if(t){let a=this._last;this._last=r,r.prev=a,a.next=r}else{let a=this._first;this._first=r,r.next=a,a.prev=r}this._size+=1;let o=!1;return()=>{o||(o=!0,this._remove(r))}}shift(){if(this._first!==J.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==J.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==J.Undefined&&e.next!==J.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===J.Undefined&&e.next===J.Undefined?(this._first=J.Undefined,this._last=J.Undefined):e.next===J.Undefined?(this._last=this._last.prev,this._last.next=J.Undefined):e.prev===J.Undefined&&(this._first=this._first.next,this._first.prev=J.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==J.Undefined;)yield e.element,e=e.next}},Yi=0,Xe=class{constructor(e){this.value=e,this.id=Yi++}},$e=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 Xe&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(o=>(o==null?void 0:o.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 a,l,f,m,g,I;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let o=new Xe(t);this._listeners?this._listeners instanceof Xe?this._listeners=[this._listeners,o]:this._listeners.push(o):((l=(a=this.options)==null?void 0:a.onWillAddFirstListener)==null||l.call(a,this),this._listeners=o,(m=(f=this.options)==null?void 0:f.onDidFirstListener)==null||m.call(f,this)),(I=(g=this.options)==null?void 0:g.onDidAddListener)==null||I.call(g,this),this._size++}),this._event}_deliver(e,t){var o;if(!e)return;let r=((o=this.options)==null?void 0:o.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(a){r(a)}}fire(e){this._listeners&&(this._listeners instanceof Xe?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},_e=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var l;let r=(l=this.listeners.get(e))!=null?l:new $e,o=f=>t(...f.args);this.listerHandlerMap.set(t,o),r.event(o),this.listeners.set(e,r);let a=this.cachedEventQueue.get(e);if(a)for(;a.size>0;)r.fire(L({event:e},a.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let o=this.listerHandlerMap.get(t);r.dispose(o)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let o=this.cachedEventQueue.get(e);o||(o=new zi,this.cachedEventQueue.set(e,o)),o.push({args:t})}}},Zt={};ki(Zt,{None:()=>Qi,filter:()=>Zi,once:()=>An,toPromise:()=>Xi});Qi=()=>{console.log("[Jolibox SDK] None Event")};Qt=Symbol.for("Jolibox.hostEmitter"),ea=()=>{let e=new _e;return globalThis[Qt]||(globalThis[Qt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[Qt]},Ke=ea();et=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new $e,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 a of e.metadata.args)r.push(a.constraint);let o=e.handler;e.handler=function(...a){return ta(a,r),o(...a)}}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}};et=fn([hn],et);er=class{constructor(){this._onWillExecuteCommand=new $e,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new $e,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new et,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Ci(3e4)),this._starActivation}executeCommand(e,...t){return N(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Zt.toPromise(Zt.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 o=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),o}_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 o=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(o)}catch(o){return Promise.reject(o)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};er=fn([hn],er);Xt=Symbol.for("Jolibox.commands")});function ue(e,t={}){cr.emit("ERROR_REPORT",{error:e,options:t})}var cr,Ee,Te=G(()=>{"use strict";K();K();cr=new _e,Ee=new _e;ue.debounce=Ve(ue,50,{leading:!0})});var ur,lr,Rn,xn,kn=G(()=>{"use strict";K();Te();ur=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),o=atob(t+r);try{return JSON.parse(o)}catch(a){return{}}},lr=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Rn=e=>{var t;try{let a=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(a!=null&&a.length){let[l,f,m]=a;return{headerJson:ur(l),payloadJson:ur(f),signature:ur(m)}}else throw"joli_source is missing"}catch(r){return ue(new _n(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},xn=e=>{let{headerJson:t,payloadJson:r,signature:o}=e,a=lr(t),l=lr(r),f=lr(o);return`${a}.${l}.${f}`}});var na,rt,Cn,dr=G(()=>{"use strict";K();na="1.1.11-beta.2",rt=()=>na,Cn=()=>{let e=rt();return`${Sn(e)}`}});var oa,Pn,fr,Dn,Z,ia,A,re=G(()=>{"use strict";K();kn();dr();K();oa={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:sr(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:rt()},schema:window.location.href,platform:"h5"},fr=(Pn=globalThis.joliboxJSCore)==null?void 0:Pn.env,Z=Object.assign({},(Dn=fr==null?void 0:fr())!=null?Dn:oa),ia=()=>{var h,T,P,k,C,D,H,U,ee;let{payloadJson:e,headerJson:t,signature:r}=Z.schema.length?Rn(Z.schema):{},o=`${Z.deviceInfo.did}-${new Date().getTime()}`,l=new URL(Z.schema.length?Z.schema:window.location.href).searchParams,f=(P=(T=(h=l.get("mpId"))!=null?h:l.get("appId"))!=null?T:l.get("gameId"))!=null?P:"",m=(D=(C=(k=Z.clientSessionId)!=null?k:e==null?void 0:e.sessionId)!=null?C:l.get("sessionId"))!=null?D:o,g=!!((H=e==null?void 0:e.testAdsMode)!=null?H:l.get("testAdsMode")==="true"),I=(ee=(U=e==null?void 0:e.joliboxEnv)!=null?U:l.get("joliboxEnv"))!=null?ee:"production",w=I==="staging",x=t==null?void 0:t.channel;return{get testMode(){return w},get testAdsMode(){return g},get joliboxEnv(){return I},get joliSource(){var B;return(B=l.get("joliSource"))!=null?B:null},get mpId(){var B;return(B=f!=null?f:e==null?void 0:e.id)!=null?B:""},get mpVersion(){var B;return(B=t==null?void 0:t.ver)!=null?B:rt()},get mpType(){var B,E;return(E=(B=t==null?void 0:t.__mpType)!=null?B:e==null?void 0:e.__mpType)!=null?E:"game"},get platform(){var B;return(B=Z.platform)!=null?B:Z.deviceInfo.platform},get deviceInfo(){return Z.deviceInfo},get sdkInfo(){return Z.sdkInfo},get hostInfo(){return Z.hostInfo},get hostUserInfo(){return Z.hostUserInfo},get sessionId(){var B,E;return(E=(B=Z.clientSessionId)!=null?B:m)!=null?E:o},get channel(){return x},get webviewId(){var B;return(B=Z.webviewId)!=null?B:-1},get shouldInterupt(){return e==null?void 0:e.__shouldInterupt},get from(){return e==null?void 0:e.__from},onEnvConfigChanged:B=>{gn(Z,B,vn)},encodeJoliSourceQuery:B=>{var E;return t&&r?xn({headerJson:t,payloadJson:L(L({},e),B),signature:r}):(E=l.get("joliSource"))!=null?E:""}}},A=ia()});var mr,Fn,aa,sa,On,ca,Nn=G(()=>{"use strict";K();Te();re();K();mr=!1,Fn=(e,t)=>e==null?!1:t in e,aa=e=>Fn(e,"kind"),sa=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},On=(e,t={},r)=>{var l,f,m;let o={user_id:(f=(l=A.hostUserInfo)==null?void 0:l.uid)!=null?f:"",device_id:(m=A.deviceInfo.did)!=null?m:"",timestamp:Date.now(),tag:sa(e.name)},a=q(L({},o),{env:t.environment,isFromUser:r});r?Ee.emit("GLOBAL_USER_ERROR",e,a):Ee.emit("GLOBAL_ERROR",e,a)},ca=e=>Fn(e,"kind")&&e.kind==="USER_ERROR";cr.on("ERROR_REPORT",({error:e,options:t})=>{if(mr)return;mr=!0;let r=aa(e)&&e.raw?e.raw:e;try{let o=ca(e);On(e,t,o)}catch(o){let a=o instanceof Error?o.message:String(o),l=new or(`${a}, origin error: ${r.message}`);ce.error(l),On(new or(l.message),{environment:t.environment},!1)}finally{mr=!1}})});var pr,hr=G(()=>{"use strict";Te();K();Te();pr=e=>new bn(e)});function Ln(e,t){let r=(o,a,l)=>{let f=q(L({tag:o},t),{extra:L({},a)});o=="globalJsError"?ue(new Tn(JSON.stringify(f))):e("systemLog",f,l)};return r.debounce=Ve(r,500,{leading:!0}),r}function Un(e){let t=(r,o,a)=>{var m;let l=(m=a&&JSON.stringify(a))!=null?m:0,f={speed_value_type:r,total_duration:o};l&&Object.assign(f,{extra:l}),e("joliboxSpeedAnalysis",f)};return t.debounce=Ve(t,500,{leading:!0}),t}var Bn=G(()=>{"use strict";K();K();Te()});function Mn(e,t){let r=Ln(e,t),o=Un(r);return{track:r,trackPerformance:o}}var $n=G(()=>{"use strict";Bn()});var gr=G(()=>{"use strict"});var nt,Vn=G(()=>{"use strict";re();K();K();nt=class{constructor(){this.deviceInfo=null;this.samplesConfig=null;this.fetchSamplesConfig()}fetchSamplesConfig(){return N(this,null,function*(){let r=`${A.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/samples-config`,o=yield(yield fetch(r)).json();this.samplesConfig=o})}checkIsSampled(t){if(!this.samplesConfig)return!1;let{samples:r}=this.samplesConfig;for(let[o,a]of Object.entries(r))if(a.includes(t.name))return Math.floor(Math.random()*101)<parseFloat(o);return!1}getDevice(){var o,a,l,f,m;let{nativeSDKVersion:t,jssdkVersion:r}=A.sdkInfo;return{platform:1e3,os:A.deviceInfo.platform,appVersion:(o=t!=null?t:r)!=null?o:"1.0.0",appId:(l=(a=A.hostInfo)==null?void 0:a.aid)!=null?l:"1",model:(f=A.deviceInfo.model)!=null?f:"UnknownModel",brand:(m=A.deviceInfo.brand)!=null?m:"UnknownBrand",uuid:A.deviceInfo.did,jsSdkVersion:r,extra:{}}}getLocation(){let t=new URLSearchParams(window.location.search),r={};return t.forEach((o,a)=>{r[a]=o}),{name:"GamePage",params:r}}trackEvent(t,r,o){return N(this,null,function*(){if(this.checkIsSampled(t))return;let a=t.location?t.location:yield this.getLocation(),l=t.target||null,f=t.extra||null;this.deviceInfo||(this.deviceInfo=yield this.getDevice());let m=this.deviceInfo,I={protocolVersion:"1.0.0",events:[q(L({},t),{location:a,target:l,extra:f,timestamp:Date.now(),userId:null})],device:m,project:r};try{o?yield this.doReport(ar(I),o):yield this.doReport(ar(I))}catch(w){ce.log("[Jolibox SDK] report API error",w)}})}}});var vr=G(()=>{"use strict";$n();gr();Vn()});var yr,jn,he,ot,ge,He=G(()=>{"use strict";dr();re();yr=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};(jn=AbortSignal.timeout)!=null||(AbortSignal.timeout=yr);he=class e{constructor(){this.httpClients=new WeakSet;this.networkRequests=[];this.maxRequestsToTrack=20}static getInstance(){return e._instance||(e._instance=new e),e._instance}create(t){let r=new ot(t);return e.getInstance().httpClients.add(r),r}recordNetworkRequest(t){this.networkRequests.push(t),this.networkRequests.length>this.maxRequestsToTrack&&this.networkRequests.shift()}getNetworkStatus(){return this.networkRequests.length===0?!0:this.networkRequests.filter(o=>o).length/this.networkRequests.length>=.6}},ot=class{constructor(t){this.xua=Cn();this.getJoliSource=()=>A.joliSource;var o;let r=A.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com";this.baseUrl=(o=t==null?void 0:t.baseUrl)!=null?o:r}get(t,r){return N(this,null,function*(){try{let{query:o,timeout:a}=r!=null?r:{},{headers:l}=r!=null?r:{},f=o?new URLSearchParams(o):null,m=f==null?void 0:f.toString(),g=`${this.baseUrl}${t}${m?`?${m}`:""}`,I=this.xua,w=this.getJoliSource();l=Object.assign({},l!=null?l:{},I?{"x-user-agent":I}:{},w?{"x-joli-source":w}:{});let x=yield fetch(g,{method:"GET",headers:l,credentials:"include",signal:yr(a!=null?a:3e4)});return he.getInstance().recordNetworkRequest(!0),yield x.json()}catch(o){throw he.getInstance().recordNetworkRequest(!1),o}})}post(t,r){return N(this,null,function*(){try{let{data:o,query:a,timeout:l}=r!=null?r:{},{headers:f}=r!=null?r:{},m=a?new URLSearchParams(a):null,g=m==null?void 0:m.toString(),I=`${this.baseUrl}${t}${g?`?${g}`:""}`,w=this.xua,x=this.getJoliSource();f=Object.assign({},f!=null?f:{},{"Content-Type":"application/json"},w?{"x-user-agent":w}:{},x?{"x-joli-source":x}:{});let h=yield fetch(I,{method:"POST",headers:f,body:JSON.stringify(o),signal:yr(l!=null?l:3e4),credentials:"include"});he.getInstance().recordNetworkRequest(!0);let T=h.headers.get("content-type");if(T!=null&&T.includes("application/octet-stream"))try{return h.blob()}catch(P){return yield h.arrayBuffer()}if(T!=null&&T.includes("multipart/form-data")||T!=null&&T.includes("application/x-www-form-urlencoded"))try{return h.formData()}catch(P){return yield h.text()}if(T!=null&&T.includes("application/json"))try{return yield h.json()}catch(P){return yield h.text()}return h}catch(o){throw he.getInstance().recordNetworkRequest(!1),o}})}put(t,r){return N(this,null,function*(){try{let{data:o,query:a,timeout:l}=r!=null?r:{},{headers:f}=r!=null?r:{},m=a?new URLSearchParams(a):null,g=m==null?void 0:m.toString(),I=`${this.baseUrl}${t}${g?`?${g}`:""}`,w=this.xua,x=this.getJoliSource();f=Object.assign({},f!=null?f:{},{"Content-Type":"application/json"},w?{"x-user-agent":w}:{},x?{"x-joli-source":x}:{});let h=yield fetch(I,{method:"PUT",headers:f,credentials:"include",body:JSON.stringify(o!=null?o:{})});if(!h.ok)throw he.getInstance().recordNetworkRequest(!1),new Error(`HTTP error! status: ${h.status}`);return he.getInstance().recordNetworkRequest(!0),yield h.json()}catch(o){throw console.error("Error:",o),o}})}};window.JoliboxHttpClient=ot;ge=he.getInstance()});var br,it,_r=G(()=>{"use strict";re();vr();He();br=class extends nt{constructor(){super(...arguments);this.hostToApiMap={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"}};this.httpClient=ge.create({baseUrl:this.apiBaseURL})}get apiBaseURL(){var o,a;let r=(o=this.hostToApiMap[window.location.host])!=null?o:this.hostToApiMap.default;return(a=A.testMode)!=null&&a?r.test:r.prod}doReport(r){this.httpClient.post("/report",{data:r,timeout:5e3}).catch(o=>{console.info("report error",o)})}},it=new br});var ua,Kn=G(()=>{"use strict";Nn();K();hr();K();_r();re();ua=(e,t)=>{var a,l,f;let r={message:t.message,stack:(a=t.stack)!=null?a:"",errorType:t.name,source:0},o={name:e,type:je.ErrorTrace,location:null,target:null,extra:r,timestamp:Date.now(),userId:(f=(l=A.hostUserInfo)==null?void 0:l.uid)!=null?f:null};it.trackEvent(o,xe.WebSDK)};Ee.on("GLOBAL_ERROR",(e,t)=>{ua(t.tag,e)});Ee.on("GLOBAL_USER_ERROR",(e,t)=>{ce.log("UserError",e,t)})});var at,Hn=G(()=>{"use strict";at=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r!=null?r:5*1e3,t.on("visible",o=>{this.visible=o})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),o,a,l=!1,f=0,m=()=>{if(!l)return;let T=Date.now(),P=T-r;P>=this.interval&&(this.visible&&(f+=P,t(f)),r=T),o=requestAnimationFrame(m)},g=()=>{w(),r=Date.now(),a=window.setInterval(()=>{if(!l)return;let T=Date.now();T-r>=this.interval&&(r=T)},this.interval)},I=()=>{x(),r=Date.now(),o=requestAnimationFrame(m)},w=()=>{o&&(cancelAnimationFrame(o),o=0)},x=()=>{a&&(clearInterval(a),a=0)};this.eventEmitter.on("visible",T=>{l&&(console.log("visible",T),T?I():g())});let h=this.visible;return{start(){l||(l=!0,h?I():g())},stop(){l=!1,w(),x()}}}}});var st,Gn=G(()=>{"use strict";re();Hn();He();st=class extends at{constructor(r,o,a){super(o,a);this.httpClient=ge.create();this.gameId=A.mpId,this.sessionId=A.sessionId,this.track=r}reporter(r){return N(this,null,function*(){let{event:o,params:a}=r;yield this.httpClient.post("/api/base/app-event",{data:{eventType:o,gameInfo:L({gameId:this.gameId,sessionId:this.sessionId},a)}})})}tracker(r,o=null){this.track(r,o)}}});var Jn,la,de,da,Tr,le,Ie=G(()=>{"use strict";Kn();K();K();vr();_r();Gn();re();gr();Jn=ae(),la={type:xe.WebSDK,platform:"h5",jssdk_version:A.sdkInfo.jssdkVersion,mp_id:A.mpId,mp_version:A.mpVersion},{track:de,trackPerformance:da}=Mn((...e)=>{var f,m,g,I;let[,t]=e,r=t,o=mn(r.extra)?r.extra:tr(r.extra)?JSON.parse(r.extra):{},a=q(L({},o),{mp_id:(f=r.mp_id)!=null?f:"",mp_version:(m=r.mp_version)!=null?m:""}),l={name:t.tag,type:je.System,location:null,target:null,extra:a,timestamp:Date.now(),userId:(I=(g=A.hostUserInfo)==null?void 0:g.uid)!=null?I:null};it.trackEvent(l,xe.WebSDK)},la);Jn.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{da(e,t,r)});Jn.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{de(e,t)});Tr=new _e,le=new st(de,Tr)});function Wn(e){let t=ir.config[e];return t||(t={},ir.config[e]=t),(r,o)=>{if(t[r]){ce.warn(`[can i use] ${r} already registered`);return}t[r]=L({},o)}}var qn=G(()=>{"use strict";K()});function Er(e){zn=e}function ct(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>ct(t)):Object.keys(e).reduce((t,r)=>(t[r]=ct(e[r]),t),{})}function ve(e){return typeof e=="number"}function Ir(e){let t=wr(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function wr(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var zn,Y,ut,lt,dt,ft,ke,mt,pt,ht,gt,vt,yt,bt,_t,Tt,Et,It,wt,Sr=G(()=>{"use strict";zn=!1;Y=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(zn)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${Ir(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return ct(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:ct(this._default)}optional(){return this._optional=!0,this}};ut=class extends Y{validate(t){return this._optional&&t===void 0?!0:ve(t)?ve(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):ve(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):ve(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},lt=class extends Y{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},dt=class extends Y{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(ve(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(ve(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},ft=class extends Y{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ke=class extends Y{validate(t){return!0}},mt=class extends Y{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},pt=class extends Y{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},ht=class extends Y{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},gt=class extends Y{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(o=>JSON.stringify(o)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${Ir(t)}`)}return!0}},vt=class extends Y{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(ve(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(ve(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(ve(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let o=this._item;if(!o)return!0;let a=!0;if(r.forEach((l,f)=>{if(o.path=`${this.path}[${f}]`,o.errors=this.errors,l===void 0&&o.hasDefault){r[f]=o.defaultValue;return}o.validate(l)||(o.hasFallback?r[f]=o.fallbackValue:a=!1)}),this._uniqueItems){let l=new Map;for(let f in r)l.has(r[f])?a=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${l.get(r[f])}] and ${this.path}[${f}] are identical)`):l.set(r[f],f)}return a}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},yt=class extends Y{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(wr(r)!=="object")return this.fail({expect:"object",actual:r});let a=r,l=this._value;l.errors=this.errors;let f=!0;for(let m in a){let g=a[m];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(m)?l.path=`${this.path}.${m}`:l.path=`${this.path}["${m}"]`,!(g===void 0&&l._optional)){if(g===void 0&&l.hasDefault){a[m]=l.defaultValue;continue}l.validate(g)||(l.hasFallback?a[m]=l.fallbackValue:f=!1)}}return f}},bt=class extends Y{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(wr(r)!=="object")return this.fail({expect:"object",actual:r});let o=r,a=!0;for(let l in this._object){let f=o[l],m=this._object[l];if(m.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(l)?m.path=`${this.path}.${l}`:m.path=`${this.path}["${l}"]`,!(m._optional&&f===void 0)){if(f===void 0&&m.hasDefault){o[l]=m.defaultValue;continue}m.validate(f)||(m.hasFallback?o[l]=m.fallbackValue:a=!1)}}return a}},_t=class extends Y{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:Ir(this.value),actual:r}):!0}},Tt=class extends Y{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],o=!1,a=this._items.length;for(let l=0;l<a;l++){let f=this._items[l];if(f.errors=[],f.path=this.path,!f.validate(t))r.push(f.errors.join("; "));else if(!o){o=!0;break}}if(!o){let l=r.join(`
1
+ var Ti=Object.create;var zt=Object.defineProperty,Ei=Object.defineProperties,Ii=Object.getOwnPropertyDescriptor,wi=Object.getOwnPropertyDescriptors,Si=Object.getOwnPropertyNames,Ye=Object.getOwnPropertySymbols,Ai=Object.getPrototypeOf,Yt=Object.prototype.hasOwnProperty,on=Object.prototype.propertyIsEnumerable;var nn=(e,t,r)=>t in e?zt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,L=(e,t)=>{for(var r in t||(t={}))Yt.call(t,r)&&nn(e,r,t[r]);if(Ye)for(var r of Ye(t))on.call(t,r)&&nn(e,r,t[r]);return e},q=(e,t)=>Ei(e,wi(t));var Be=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var an=(e,t)=>{var r={};for(var o in e)Yt.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&Ye)for(var o of Ye(e))t.indexOf(o)<0&&on.call(e,o)&&(r[o]=e[o]);return r};var G=(e,t)=>()=>(e&&(t=e(e=0)),t);var sn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ri=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Si(t))!Yt.call(e,a)&&a!==r&&zt(e,a,{get:()=>t[a],enumerable:!(o=Ii(t,a))||o.enumerable});return e};var cn=(e,t,r)=>(r=e!=null?Ti(Ai(e)):{},Ri(t||!e||!e.__esModule?zt(r,"default",{value:e,enumerable:!0}):r,e));var N=(e,t,r)=>new Promise((o,a)=>{var l=g=>{try{m(r.next(g))}catch(I){a(I)}},f=g=>{try{m(r.throw(g))}catch(I){a(I)}},m=g=>g.done?o(g.value):Promise.resolve(g.value).then(l,f);m((r=r.apply(e,t)).next())});function Ci(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function tr(e){return typeof e=="string"}function mn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function pn(e){return typeof e=="object"&&Array.isArray(e)}function Pi(e){return typeof e>"u"}function Di(e){return Pi(e)||e===null}function Oi(e){return typeof e=="function"}function hn(e){let t=e,r=null,o=function(...a){return r||(r=new t(...a)),r};return o.prototype=t.prototype,o}function gn(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function o(a,l){for(let f in l)if(Object.prototype.hasOwnProperty.call(l,f)){let m=a[f],g=l[f],I=r(m,g,f,a,l);I!==void 0?a[f]=I:un(g)&&un(m)?a[f]=o(L({},m),g):Array.isArray(g)&&Array.isArray(m)?a[f]=[...m,...g]:a[f]=g}return a}return o(e,t)}function un(e){return e&&typeof e=="object"&&e.constructor===Object}function vn(e,t){if(Array.isArray(e))return e.concat(t)}function Ve(e,t,r={}){let o=null,a,l,f,{leading:m=!1,trailing:g=!0}=r,I=()=>(f=e.apply(l,a),a=void 0,l=void 0,f),w=function(...x){a=x,l=this;let h=m&&!o;if(o&&clearTimeout(o),o=setTimeout(()=>{o=null,g&&!h&&I()},t),h)return I()};return w.cancel=()=>{o&&clearTimeout(o),o=null,a=l=void 0},w.flush=()=>{if(o)return clearTimeout(o),o=null,I()},w}function Li(e,t){return(...r)=>t(e,...r)}function En(e){return t=>Li(t,function(r,...o){if(typeof r=="function")try{return r.apply(this,o)}catch(a){e(new Ni(`${a}`))}})}function Me(e){return(...t)=>{var r,o;((o=(r=globalThis.VConsole)==null?void 0:r[e])!=null?o:globalThis.console[e])(...t)}}function Ze(e,t){return t.map(r=>{if(r==="params"&&e[r]){let o=e[r];return Object.keys(o).reduce((a,l)=>(a[l]=String(o[l]),a),{})}return e[r]})}function Vi(e){let t=e.location?Ze(e.location,ln):null,r=e.target?Ze(e.target,ln):null;return Ze(q(L({},e),{location:t,target:r}),Mi)}function ar(e){let t=e.events.map(o=>Vi(o)),r=Ze(e.device,$i);return[e.protocolVersion,t,r,e.project]}function Xi(e){return new Promise(t=>An(e)(t))}function An(e){return(t,r=null)=>{let o=!1;return e(a=>{if(!o)return o=!0,t.call(r,a)},null)}}function Zi(e,t){return(r=>{let o,a={onWillAddFirstListener(){o=r(l.fire,l)}},l=new $e(a);return l.event})((r,o=null)=>e(a=>t(a)&&r.call(o,a),null))}function ta(e,t){let r=Math.min(e.length,t.length);for(let o=0;o<r;o++)ra(e[o],t[o])}function ra(e,t){if(tr(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Oi(t)){try{if(e instanceof t)return}catch(r){}if(!Di(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")}}function ae(){if(globalThis[Xt])return globalThis[Xt];let e=new et,t=new er,r={registerCommand(o,a,l){e.registerCommand({id:o,handler:a,metadata:l})},executeCommand(o,...a){return t.executeCommand(o,...a)},excuteCommandSync(o,...a){return t.executeCommandThowErr(o,...a)}};return globalThis[Xt]=r,r}var dn,xi,ki,fn,Fi,rr,nr,yn,bn,Ni,_n,Tn,tt,or,ce,In,Ui,ir,je,xe,Bi,ln,Mi,$i,ji,Qe,Ki,Hi,Gi,wn,sr,Ji,Wi,qi,Sn,pe,J,zi,Yi,Xe,$e,_e,Zt,Qi,Qt,ea,Ke,et,er,Xt,K=G(()=>{"use strict";dn=Object.defineProperty,xi=Object.getOwnPropertyDescriptor,ki=(e,t)=>{for(var r in t)dn(e,r,{get:t[r],enumerable:!0})},fn=(e,t,r,o)=>{for(var a=o>1?void 0:o?xi(t,r):t,l=e.length-1,f;l>=0;l--)(f=e[l])&&(a=(o?f(t,r,a):f(a))||a);return o&&a&&dn(t,r,a),a};Fi=(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))(Fi||{}),rr=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}},nr=class extends rr{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},yn=class extends rr{constructor(){super(...arguments),this.kind="USER_ERROR"}},bn=class extends yn{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Ni=class extends yn{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},_n=class extends nr{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Tn=class extends nr{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},tt=class extends rr{constructor(e,t,r,o,a){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),o!==void 0&&(this.stack=o),a&&(this.priority=a)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},or=class extends nr{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};ce={log:Me("log"),warn:Me("warn"),info:Me("info"),error:Me("error"),debug:Me("debug")};Object.assign(globalThis,{logger:ce});In=Symbol.for("Jolibox.canIUseMap"),Ui={};globalThis[In]=Ui;ir={get config(){return globalThis[In]}},je=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(je||{}),xe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(xe||{}),Bi=(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))(Bi||{}),ln=["name","params"],Mi=["name","type","location","target","extra","timestamp","userId"],$i=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];ji=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),Qe={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")},Ki=()=>Qe.isiOS?"iOS":Qe.isAndroid?"Android":Qe.isMac?"Mac":Qe.isFacebook?"Facebook":"PC",Hi="device_id",Gi="advertising_id",wn=e=>(localStorage.getItem(e)||localStorage.setItem(e,ji()),localStorage.getItem(e)),sr=()=>wn(Hi),Ji=()=>wn(Gi),Wi=e=>e.charAt(0).toUpperCase()+e.slice(1),qi=()=>{var t;let e=new URLSearchParams(window.location.search);return Wi((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},Sn=e=>{let t="JoliboxWebSDK",r=Ki(),o=navigator.language,a=sr(),l=Ji();return`${t} (${qi()}${r}; UnknownModel; UnknownSystemVersion; ${o}) uuid/${a} adid/${l} version/${e||""}`},J=(pe=class{constructor(t){this.element=t,this.next=pe.Undefined,this.prev=pe.Undefined}},pe.Undefined=new pe(void 0),pe),zi=class{constructor(){this._first=J.Undefined,this._last=J.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===J.Undefined}clear(){let e=this._first;for(;e!==J.Undefined;){let t=e.next;e.prev=J.Undefined,e.next=J.Undefined,e=t}this._first=J.Undefined,this._last=J.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new J(e);if(this._first===J.Undefined)this._first=r,this._last=r;else if(t){let a=this._last;this._last=r,r.prev=a,a.next=r}else{let a=this._first;this._first=r,r.next=a,a.prev=r}this._size+=1;let o=!1;return()=>{o||(o=!0,this._remove(r))}}shift(){if(this._first!==J.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==J.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==J.Undefined&&e.next!==J.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===J.Undefined&&e.next===J.Undefined?(this._first=J.Undefined,this._last=J.Undefined):e.next===J.Undefined?(this._last=this._last.prev,this._last.next=J.Undefined):e.prev===J.Undefined&&(this._first=this._first.next,this._first.prev=J.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==J.Undefined;)yield e.element,e=e.next}},Yi=0,Xe=class{constructor(e){this.value=e,this.id=Yi++}},$e=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 Xe&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(o=>(o==null?void 0:o.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 a,l,f,m,g,I;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let o=new Xe(t);this._listeners?this._listeners instanceof Xe?this._listeners=[this._listeners,o]:this._listeners.push(o):((l=(a=this.options)==null?void 0:a.onWillAddFirstListener)==null||l.call(a,this),this._listeners=o,(m=(f=this.options)==null?void 0:f.onDidFirstListener)==null||m.call(f,this)),(I=(g=this.options)==null?void 0:g.onDidAddListener)==null||I.call(g,this),this._size++}),this._event}_deliver(e,t){var o;if(!e)return;let r=((o=this.options)==null?void 0:o.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(a){r(a)}}fire(e){this._listeners&&(this._listeners instanceof Xe?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},_e=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var l;let r=(l=this.listeners.get(e))!=null?l:new $e,o=f=>t(...f.args);this.listerHandlerMap.set(t,o),r.event(o),this.listeners.set(e,r);let a=this.cachedEventQueue.get(e);if(a)for(;a.size>0;)r.fire(L({event:e},a.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let o=this.listerHandlerMap.get(t);r.dispose(o)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let o=this.cachedEventQueue.get(e);o||(o=new zi,this.cachedEventQueue.set(e,o)),o.push({args:t})}}},Zt={};ki(Zt,{None:()=>Qi,filter:()=>Zi,once:()=>An,toPromise:()=>Xi});Qi=()=>{console.log("[Jolibox SDK] None Event")};Qt=Symbol.for("Jolibox.hostEmitter"),ea=()=>{let e=new _e;return globalThis[Qt]||(globalThis[Qt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[Qt]},Ke=ea();et=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new $e,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 a of e.metadata.args)r.push(a.constraint);let o=e.handler;e.handler=function(...a){return ta(a,r),o(...a)}}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}};et=fn([hn],et);er=class{constructor(){this._onWillExecuteCommand=new $e,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new $e,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new et,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Ci(3e4)),this._starActivation}executeCommand(e,...t){return N(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Zt.toPromise(Zt.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 o=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),o}_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 o=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(o)}catch(o){return Promise.reject(o)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};er=fn([hn],er);Xt=Symbol.for("Jolibox.commands")});function ue(e,t={}){cr.emit("ERROR_REPORT",{error:e,options:t})}var cr,Ee,Te=G(()=>{"use strict";K();K();cr=new _e,Ee=new _e;ue.debounce=Ve(ue,50,{leading:!0})});var ur,lr,Rn,xn,kn=G(()=>{"use strict";K();Te();ur=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),o=atob(t+r);try{return JSON.parse(o)}catch(a){return{}}},lr=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Rn=e=>{var t;try{let a=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(a!=null&&a.length){let[l,f,m]=a;return{headerJson:ur(l),payloadJson:ur(f),signature:ur(m)}}else throw"joli_source is missing"}catch(r){return ue(new _n(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},xn=e=>{let{headerJson:t,payloadJson:r,signature:o}=e,a=lr(t),l=lr(r),f=lr(o);return`${a}.${l}.${f}`}});var na,rt,Cn,dr=G(()=>{"use strict";K();na="1.1.11-beta.3",rt=()=>na,Cn=()=>{let e=rt();return`${Sn(e)}`}});var oa,Pn,fr,Dn,Z,ia,A,re=G(()=>{"use strict";K();kn();dr();K();oa={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:sr(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:rt()},schema:window.location.href,platform:"h5"},fr=(Pn=globalThis.joliboxJSCore)==null?void 0:Pn.env,Z=Object.assign({},(Dn=fr==null?void 0:fr())!=null?Dn:oa),ia=()=>{var h,T,P,k,C,D,H,U,ee;let{payloadJson:e,headerJson:t,signature:r}=Z.schema.length?Rn(Z.schema):{},o=`${Z.deviceInfo.did}-${new Date().getTime()}`,l=new URL(Z.schema.length?Z.schema:window.location.href).searchParams,f=(P=(T=(h=l.get("mpId"))!=null?h:l.get("appId"))!=null?T:l.get("gameId"))!=null?P:"",m=(D=(C=(k=Z.clientSessionId)!=null?k:e==null?void 0:e.sessionId)!=null?C:l.get("sessionId"))!=null?D:o,g=!!((H=e==null?void 0:e.testAdsMode)!=null?H:l.get("testAdsMode")==="true"),I=(ee=(U=e==null?void 0:e.joliboxEnv)!=null?U:l.get("joliboxEnv"))!=null?ee:"production",w=I==="staging",x=t==null?void 0:t.channel;return{get testMode(){return w},get testAdsMode(){return g},get joliboxEnv(){return I},get joliSource(){var B;return(B=l.get("joliSource"))!=null?B:null},get mpId(){var B;return(B=f!=null?f:e==null?void 0:e.id)!=null?B:""},get mpVersion(){var B;return(B=t==null?void 0:t.ver)!=null?B:rt()},get mpType(){var B,E;return(E=(B=t==null?void 0:t.__mpType)!=null?B:e==null?void 0:e.__mpType)!=null?E:"game"},get platform(){var B;return(B=Z.platform)!=null?B:Z.deviceInfo.platform},get deviceInfo(){return Z.deviceInfo},get sdkInfo(){return Z.sdkInfo},get hostInfo(){return Z.hostInfo},get hostUserInfo(){return Z.hostUserInfo},get sessionId(){var B,E;return(E=(B=Z.clientSessionId)!=null?B:m)!=null?E:o},get channel(){return x},get webviewId(){var B;return(B=Z.webviewId)!=null?B:-1},get shouldInterupt(){return e==null?void 0:e.__shouldInterupt},get from(){return e==null?void 0:e.__from},onEnvConfigChanged:B=>{gn(Z,B,vn)},encodeJoliSourceQuery:B=>{var E;return t&&r?xn({headerJson:t,payloadJson:L(L({},e),B),signature:r}):(E=l.get("joliSource"))!=null?E:""}}},A=ia()});var mr,Fn,aa,sa,On,ca,Nn=G(()=>{"use strict";K();Te();re();K();mr=!1,Fn=(e,t)=>e==null?!1:t in e,aa=e=>Fn(e,"kind"),sa=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},On=(e,t={},r)=>{var l,f,m;let o={user_id:(f=(l=A.hostUserInfo)==null?void 0:l.uid)!=null?f:"",device_id:(m=A.deviceInfo.did)!=null?m:"",timestamp:Date.now(),tag:sa(e.name)},a=q(L({},o),{env:t.environment,isFromUser:r});r?Ee.emit("GLOBAL_USER_ERROR",e,a):Ee.emit("GLOBAL_ERROR",e,a)},ca=e=>Fn(e,"kind")&&e.kind==="USER_ERROR";cr.on("ERROR_REPORT",({error:e,options:t})=>{if(mr)return;mr=!0;let r=aa(e)&&e.raw?e.raw:e;try{let o=ca(e);On(e,t,o)}catch(o){let a=o instanceof Error?o.message:String(o),l=new or(`${a}, origin error: ${r.message}`);ce.error(l),On(new or(l.message),{environment:t.environment},!1)}finally{mr=!1}})});var pr,hr=G(()=>{"use strict";Te();K();Te();pr=e=>new bn(e)});function Ln(e,t){let r=(o,a,l)=>{let f=q(L({tag:o},t),{extra:L({},a)});o=="globalJsError"?ue(new Tn(JSON.stringify(f))):e("systemLog",f,l)};return r.debounce=Ve(r,500,{leading:!0}),r}function Un(e){let t=(r,o,a)=>{var m;let l=(m=a&&JSON.stringify(a))!=null?m:0,f={speed_value_type:r,total_duration:o};l&&Object.assign(f,{extra:l}),e("joliboxSpeedAnalysis",f)};return t.debounce=Ve(t,500,{leading:!0}),t}var Bn=G(()=>{"use strict";K();K();Te()});function Mn(e,t){let r=Ln(e,t),o=Un(r);return{track:r,trackPerformance:o}}var $n=G(()=>{"use strict";Bn()});var gr=G(()=>{"use strict"});var nt,Vn=G(()=>{"use strict";re();K();K();nt=class{constructor(){this.deviceInfo=null;this.samplesConfig=null;this.fetchSamplesConfig()}fetchSamplesConfig(){return N(this,null,function*(){let r=`${A.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/samples-config`,o=yield(yield fetch(r)).json();this.samplesConfig=o})}checkIsSampled(t){if(!this.samplesConfig)return!1;let{samples:r}=this.samplesConfig;for(let[o,a]of Object.entries(r))if(a.includes(t.name))return Math.floor(Math.random()*101)<parseFloat(o);return!1}getDevice(){var o,a,l,f,m;let{nativeSDKVersion:t,jssdkVersion:r}=A.sdkInfo;return{platform:1e3,os:A.deviceInfo.platform,appVersion:(o=t!=null?t:r)!=null?o:"1.0.0",appId:(l=(a=A.hostInfo)==null?void 0:a.aid)!=null?l:"1",model:(f=A.deviceInfo.model)!=null?f:"UnknownModel",brand:(m=A.deviceInfo.brand)!=null?m:"UnknownBrand",uuid:A.deviceInfo.did,jsSdkVersion:r,extra:{}}}getLocation(){let t=new URLSearchParams(window.location.search),r={};return t.forEach((o,a)=>{r[a]=o}),{name:"GamePage",params:r}}trackEvent(t,r,o){return N(this,null,function*(){if(this.checkIsSampled(t))return;let a=t.location?t.location:yield this.getLocation(),l=t.target||null,f=t.extra||null;this.deviceInfo||(this.deviceInfo=yield this.getDevice());let m=this.deviceInfo,I={protocolVersion:"1.0.0",events:[q(L({},t),{location:a,target:l,extra:f,timestamp:Date.now(),userId:null})],device:m,project:r};try{o?yield this.doReport(ar(I),o):yield this.doReport(ar(I))}catch(w){ce.log("[Jolibox SDK] report API error",w)}})}}});var vr=G(()=>{"use strict";$n();gr();Vn()});var yr,jn,he,ot,ge,He=G(()=>{"use strict";dr();re();yr=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};(jn=AbortSignal.timeout)!=null||(AbortSignal.timeout=yr);he=class e{constructor(){this.httpClients=new WeakSet;this.networkRequests=[];this.maxRequestsToTrack=20}static getInstance(){return e._instance||(e._instance=new e),e._instance}create(t){let r=new ot(t);return e.getInstance().httpClients.add(r),r}recordNetworkRequest(t){this.networkRequests.push(t),this.networkRequests.length>this.maxRequestsToTrack&&this.networkRequests.shift()}getNetworkStatus(){return this.networkRequests.length===0?!0:this.networkRequests.filter(o=>o).length/this.networkRequests.length>=.6}},ot=class{constructor(t){this.xua=Cn();this.getJoliSource=()=>A.joliSource;var o;let r=A.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com";this.baseUrl=(o=t==null?void 0:t.baseUrl)!=null?o:r}get(t,r){return N(this,null,function*(){try{let{query:o,timeout:a}=r!=null?r:{},{headers:l}=r!=null?r:{},f=o?new URLSearchParams(o):null,m=f==null?void 0:f.toString(),g=`${this.baseUrl}${t}${m?`?${m}`:""}`,I=this.xua,w=this.getJoliSource();l=Object.assign({},l!=null?l:{},I?{"x-user-agent":I}:{},w?{"x-joli-source":w}:{});let x=yield fetch(g,{method:"GET",headers:l,credentials:"include",signal:yr(a!=null?a:3e4)});return he.getInstance().recordNetworkRequest(!0),yield x.json()}catch(o){throw he.getInstance().recordNetworkRequest(!1),o}})}post(t,r){return N(this,null,function*(){try{let{data:o,query:a,timeout:l}=r!=null?r:{},{headers:f}=r!=null?r:{},m=a?new URLSearchParams(a):null,g=m==null?void 0:m.toString(),I=`${this.baseUrl}${t}${g?`?${g}`:""}`,w=this.xua,x=this.getJoliSource();f=Object.assign({},f!=null?f:{},{"Content-Type":"application/json"},w?{"x-user-agent":w}:{},x?{"x-joli-source":x}:{});let h=yield fetch(I,{method:"POST",headers:f,body:JSON.stringify(o),signal:yr(l!=null?l:3e4),credentials:"include"});he.getInstance().recordNetworkRequest(!0);let T=h.headers.get("content-type");if(T!=null&&T.includes("application/octet-stream"))try{return h.blob()}catch(P){return yield h.arrayBuffer()}if(T!=null&&T.includes("multipart/form-data")||T!=null&&T.includes("application/x-www-form-urlencoded"))try{return h.formData()}catch(P){return yield h.text()}if(T!=null&&T.includes("application/json"))try{return yield h.json()}catch(P){return yield h.text()}return h}catch(o){throw he.getInstance().recordNetworkRequest(!1),o}})}put(t,r){return N(this,null,function*(){try{let{data:o,query:a,timeout:l}=r!=null?r:{},{headers:f}=r!=null?r:{},m=a?new URLSearchParams(a):null,g=m==null?void 0:m.toString(),I=`${this.baseUrl}${t}${g?`?${g}`:""}`,w=this.xua,x=this.getJoliSource();f=Object.assign({},f!=null?f:{},{"Content-Type":"application/json"},w?{"x-user-agent":w}:{},x?{"x-joli-source":x}:{});let h=yield fetch(I,{method:"PUT",headers:f,credentials:"include",body:JSON.stringify(o!=null?o:{})});if(!h.ok)throw he.getInstance().recordNetworkRequest(!1),new Error(`HTTP error! status: ${h.status}`);return he.getInstance().recordNetworkRequest(!0),yield h.json()}catch(o){throw console.error("Error:",o),o}})}};window.JoliboxHttpClient=ot;ge=he.getInstance()});var br,it,_r=G(()=>{"use strict";re();vr();He();br=class extends nt{constructor(){super(...arguments);this.hostToApiMap={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"}};this.httpClient=ge.create({baseUrl:this.apiBaseURL})}get apiBaseURL(){var o,a;let r=(o=this.hostToApiMap[window.location.host])!=null?o:this.hostToApiMap.default;return(a=A.testMode)!=null&&a?r.test:r.prod}doReport(r){this.httpClient.post("/report",{data:r,timeout:5e3}).catch(o=>{console.info("report error",o)})}},it=new br});var ua,Kn=G(()=>{"use strict";Nn();K();hr();K();_r();re();ua=(e,t)=>{var a,l,f;let r={message:t.message,stack:(a=t.stack)!=null?a:"",errorType:t.name,source:0},o={name:e,type:je.ErrorTrace,location:null,target:null,extra:r,timestamp:Date.now(),userId:(f=(l=A.hostUserInfo)==null?void 0:l.uid)!=null?f:null};it.trackEvent(o,xe.WebSDK)};Ee.on("GLOBAL_ERROR",(e,t)=>{ua(t.tag,e)});Ee.on("GLOBAL_USER_ERROR",(e,t)=>{ce.log("UserError",e,t)})});var at,Hn=G(()=>{"use strict";at=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r!=null?r:5*1e3,t.on("visible",o=>{this.visible=o})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),o,a,l=!1,f=0,m=()=>{if(!l)return;let T=Date.now(),P=T-r;P>=this.interval&&(this.visible&&(f+=P,t(f)),r=T),o=requestAnimationFrame(m)},g=()=>{w(),r=Date.now(),a=window.setInterval(()=>{if(!l)return;let T=Date.now();T-r>=this.interval&&(r=T)},this.interval)},I=()=>{x(),r=Date.now(),o=requestAnimationFrame(m)},w=()=>{o&&(cancelAnimationFrame(o),o=0)},x=()=>{a&&(clearInterval(a),a=0)};this.eventEmitter.on("visible",T=>{l&&(console.log("visible",T),T?I():g())});let h=this.visible;return{start(){l||(l=!0,h?I():g())},stop(){l=!1,w(),x()}}}}});var st,Gn=G(()=>{"use strict";re();Hn();He();st=class extends at{constructor(r,o,a){super(o,a);this.httpClient=ge.create();this.gameId=A.mpId,this.sessionId=A.sessionId,this.track=r}reporter(r){return N(this,null,function*(){let{event:o,params:a}=r;yield this.httpClient.post("/api/base/app-event",{data:{eventType:o,gameInfo:L({gameId:this.gameId,sessionId:this.sessionId},a)}})})}tracker(r,o=null){this.track(r,o)}}});var Jn,la,de,da,Tr,le,Ie=G(()=>{"use strict";Kn();K();K();vr();_r();Gn();re();gr();Jn=ae(),la={type:xe.WebSDK,platform:"h5",jssdk_version:A.sdkInfo.jssdkVersion,mp_id:A.mpId,mp_version:A.mpVersion},{track:de,trackPerformance:da}=Mn((...e)=>{var f,m,g,I;let[,t]=e,r=t,o=mn(r.extra)?r.extra:tr(r.extra)?JSON.parse(r.extra):{},a=q(L({},o),{mp_id:(f=r.mp_id)!=null?f:"",mp_version:(m=r.mp_version)!=null?m:""}),l={name:t.tag,type:je.System,location:null,target:null,extra:a,timestamp:Date.now(),userId:(I=(g=A.hostUserInfo)==null?void 0:g.uid)!=null?I:null};it.trackEvent(l,xe.WebSDK)},la);Jn.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{da(e,t,r)});Jn.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{de(e,t)});Tr=new _e,le=new st(de,Tr)});function Wn(e){let t=ir.config[e];return t||(t={},ir.config[e]=t),(r,o)=>{if(t[r]){ce.warn(`[can i use] ${r} already registered`);return}t[r]=L({},o)}}var qn=G(()=>{"use strict";K()});function Er(e){zn=e}function ct(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>ct(t)):Object.keys(e).reduce((t,r)=>(t[r]=ct(e[r]),t),{})}function ve(e){return typeof e=="number"}function Ir(e){let t=wr(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function wr(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var zn,Y,ut,lt,dt,ft,ke,mt,pt,ht,gt,vt,yt,bt,_t,Tt,Et,It,wt,Sr=G(()=>{"use strict";zn=!1;Y=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(zn)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${Ir(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return ct(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:ct(this._default)}optional(){return this._optional=!0,this}};ut=class extends Y{validate(t){return this._optional&&t===void 0?!0:ve(t)?ve(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):ve(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):ve(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},lt=class extends Y{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},dt=class extends Y{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(ve(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(ve(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},ft=class extends Y{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ke=class extends Y{validate(t){return!0}},mt=class extends Y{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},pt=class extends Y{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},ht=class extends Y{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},gt=class extends Y{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(o=>JSON.stringify(o)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${Ir(t)}`)}return!0}},vt=class extends Y{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(ve(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(ve(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(ve(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let o=this._item;if(!o)return!0;let a=!0;if(r.forEach((l,f)=>{if(o.path=`${this.path}[${f}]`,o.errors=this.errors,l===void 0&&o.hasDefault){r[f]=o.defaultValue;return}o.validate(l)||(o.hasFallback?r[f]=o.fallbackValue:a=!1)}),this._uniqueItems){let l=new Map;for(let f in r)l.has(r[f])?a=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${l.get(r[f])}] and ${this.path}[${f}] are identical)`):l.set(r[f],f)}return a}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},yt=class extends Y{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(wr(r)!=="object")return this.fail({expect:"object",actual:r});let a=r,l=this._value;l.errors=this.errors;let f=!0;for(let m in a){let g=a[m];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(m)?l.path=`${this.path}.${m}`:l.path=`${this.path}["${m}"]`,!(g===void 0&&l._optional)){if(g===void 0&&l.hasDefault){a[m]=l.defaultValue;continue}l.validate(g)||(l.hasFallback?a[m]=l.fallbackValue:f=!1)}}return f}},bt=class extends Y{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(wr(r)!=="object")return this.fail({expect:"object",actual:r});let o=r,a=!0;for(let l in this._object){let f=o[l],m=this._object[l];if(m.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(l)?m.path=`${this.path}.${l}`:m.path=`${this.path}["${l}"]`,!(m._optional&&f===void 0)){if(f===void 0&&m.hasDefault){o[l]=m.defaultValue;continue}m.validate(f)||(m.hasFallback?o[l]=m.fallbackValue:a=!1)}}return a}},_t=class extends Y{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:Ir(this.value),actual:r}):!0}},Tt=class extends Y{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],o=!1,a=this._items.length;for(let l=0;l<a;l++){let f=this._items[l];if(f.errors=[],f.path=this.path,!f.validate(t))r.push(f.errors.join("; "));else if(!o){o=!0;break}}if(!o){let l=r.join(`
2
2
  or `);this.errors.push(l)}return o}},Et=class extends Y{constructor(...t){super(),this._items=t;let r=0,o=t.length-1;for(;o>=0;o--){let a=t[o];if(a._optional||a.hasDefault)r+=1;else break}this._minItems=t.length-r}validate(t){if(t===void 0&&this._optional)return!0;if(!Array.isArray(t))return this.fail({expect:"array",actual:t});if(t.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let r=!0;return this._items.forEach((o,a)=>{if(o.path=`${this.path}[${a}]`,o.errors=this.errors,t[a]===void 0&&o.hasDefault){t[a]=o.defaultValue;return}o.validate(t[a])||(o.hasFallback?t[a]=o._fallback:r=!1)}),r}},It=class extends Y{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},wt=class extends Y{constructor(t){super(),this._ctor=t}validate(t){return t===void 0&&this._optional||t instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:t})}}});function Ar(e,t,r="param"){if(e.errors=[],e.path=r,Er(!0),!e.validate(t)){let o=e.errors.join(`
3
3
  `);throw e.errors.length=0,Er(!1),new TypeError(o)}}var R,Rr=G(()=>{"use strict";Sr();Sr();R={object(e){return new bt(e)},array(e){return new vt(e)},tuple(...e){return new Et(...e)},literal(e){return new _t(e)},or(...e){return new Tt(...e)},symbol(){return new ft},record(e){return new yt(e)},function(){return new ht},boolean(){return new lt},string(){return new dt},number(){return new ut},undefined(){return new mt},null(){return new pt},unknown(){return new ke},any(){return new ke},as(){return new ke},arraybuffer(){return new It},enum(...e){return new gt(...e)},typedarray(e){return new wt(e)}}});var St,Yn,Qn=G(()=>{"use strict";K();Te();Rr();hr();St=1,Yn=e=>{function t(o,a){return(...l)=>{var x,h,T,P;let f=Date.now(),m={method:o,trace_id:St};St+=1;let g="SUCCESS",I=`${o}:ok`,w=0;try{if(a.paramsSchema)try{Ar(a.paramsSchema,l,"params")}catch(H){throw pr(`${o}:fail ${H.message}`)}let k=a.implement(...l),C=k,D=`${o}:ok`;if(k&&"code"in k){let{code:H,data:U,message:ee}=k;g=H,C=U,D=ee}return{code:g,message:D,data:C}}catch(k){let C=k;w=(h=(x=C.code)!=null?x:C.errNo)!=null?h:2e3,g="FAILURE";let D=(P=(T=C.message)!=null?T:C.errMsg)!=null?P:`${k}`;return I=`${o}:${g} ${D.replace(/^\S+:(fail|cancel)\s?/,"")}`,ue(new tt(I,w)),{code:g,message:I}}finally{let k=Date.now()-f;e("apiInvoked",q(L({},m),{duration:k,status:g}))}}}function r(o,a){return(...l)=>N(this,null,function*(){var h,T,P,k;let f=pn(l)?l:[l],m=Date.now(),g={method:o,trace_id:St};St+=1;let I=`${o}:ok`,w="SUCCESS",x={code:w,message:I};try{if(a.paramsSchema)try{Ar(a.paramsSchema,f,"params")}catch(H){throw pr(H.message)}let D=yield a.implement(...f);if(D&&"code"in D){let{code:H,data:U,message:ee}=D;w=H,I=ee,D=U}return Object.assign(x,{code:w,message:I,data:D}),x}catch(C){let D=C,H=(T=(h=D.code)!=null?h:D.errNo)!=null?T:2e3;w="FAILURE";let U=(k=(P=D.message)!=null?P:D.errMsg)!=null?k:`${C}`,ee=`${o}:${w} ${U.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(x,{code:w,message:ee}),ue(new tt(ee,H)),x}finally{let C=Date.now()-m;e("apiInvoked",q(L({},g),{duration:C,status:w}))}})}return{createAPI:r,createSyncAPI:t}}});var se,we,Q,Ge=G(()=>{"use strict";qn();Ie();Qn();Rr();({createAPI:se,createSyncAPI:we}=Yn(de)),Q=Wn("h5")});var to=sn((eo,Pr)=>{(function(e){if(typeof eo=="object"&&typeof Pr!="undefined")Pr.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t=this,t.localforage=e()}})(function(){var e,t,r;return function o(a,l,f){function m(w,x){if(!l[w]){if(!a[w]){var h=typeof Be=="function"&&Be;if(!x&&h)return h(w,!0);if(g)return g(w,!0);var T=new Error("Cannot find module '"+w+"'");throw T.code="MODULE_NOT_FOUND",T}var P=l[w]={exports:{}};a[w][0].call(P.exports,function(k){var C=a[w][1][k];return m(C||k)},P,P.exports,o,a,l,f)}return l[w].exports}for(var g=typeof Be=="function"&&Be,I=0;I<f.length;I++)m(f[I]);return m}({1:[function(o,a,l){(function(f){"use strict";var m=f.MutationObserver||f.WebKitMutationObserver,g;if(m){var I=0,w=new m(k),x=f.document.createTextNode("");w.observe(x,{characterData:!0}),g=function(){x.data=I=++I%2}}else if(!f.setImmediate&&typeof f.MessageChannel!="undefined"){var h=new f.MessageChannel;h.port1.onmessage=k,g=function(){h.port2.postMessage(0)}}else"document"in f&&"onreadystatechange"in f.document.createElement("script")?g=function(){var D=f.document.createElement("script");D.onreadystatechange=function(){k(),D.onreadystatechange=null,D.parentNode.removeChild(D),D=null},f.document.documentElement.appendChild(D)}:g=function(){setTimeout(k,0)};var T,P=[];function k(){T=!0;for(var D,H,U=P.length;U;){for(H=P,P=[],D=-1;++D<U;)H[D]();U=P.length}T=!1}a.exports=C;function C(D){P.push(D)===1&&!T&&g()}}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],2:[function(o,a,l){"use strict";var f=o(1);function m(){}var g={},I=["REJECTED"],w=["FULFILLED"],x=["PENDING"];a.exports=h;function h(E){if(typeof E!="function")throw new TypeError("resolver must be a function");this.state=x,this.queue=[],this.outcome=void 0,E!==m&&C(this,E)}h.prototype.catch=function(E){return this.then(null,E)},h.prototype.then=function(E,M){if(typeof E!="function"&&this.state===w||typeof M!="function"&&this.state===I)return this;var F=new this.constructor(m);if(this.state!==x){var j=this.state===w?E:M;P(F,j,this.outcome)}else this.queue.push(new T(F,E,M));return F};function T(E,M,F){this.promise=E,typeof M=="function"&&(this.onFulfilled=M,this.callFulfilled=this.otherCallFulfilled),typeof F=="function"&&(this.onRejected=F,this.callRejected=this.otherCallRejected)}T.prototype.callFulfilled=function(E){g.resolve(this.promise,E)},T.prototype.otherCallFulfilled=function(E){P(this.promise,this.onFulfilled,E)},T.prototype.callRejected=function(E){g.reject(this.promise,E)},T.prototype.otherCallRejected=function(E){P(this.promise,this.onRejected,E)};function P(E,M,F){f(function(){var j;try{j=M(F)}catch(X){return g.reject(E,X)}j===E?g.reject(E,new TypeError("Cannot resolve promise with itself")):g.resolve(E,j)})}g.resolve=function(E,M){var F=D(k,M);if(F.status==="error")return g.reject(E,F.value);var j=F.value;if(j)C(E,j);else{E.state=w,E.outcome=M;for(var X=-1,te=E.queue.length;++X<te;)E.queue[X].callFulfilled(M)}return E},g.reject=function(E,M){E.state=I,E.outcome=M;for(var F=-1,j=E.queue.length;++F<j;)E.queue[F].callRejected(M);return E};function k(E){var M=E&&E.then;if(E&&(typeof E=="object"||typeof E=="function")&&typeof M=="function")return function(){M.apply(E,arguments)}}function C(E,M){var F=!1;function j(oe){F||(F=!0,g.reject(E,oe))}function X(oe){F||(F=!0,g.resolve(E,oe))}function te(){M(X,j)}var ne=D(te);ne.status==="error"&&j(ne.value)}function D(E,M){var F={};try{F.value=E(M),F.status="success"}catch(j){F.status="error",F.value=j}return F}h.resolve=H;function H(E){return E instanceof this?E:g.resolve(new this(m),E)}h.reject=U;function U(E){var M=new this(m);return g.reject(M,E)}h.all=ee;function ee(E){var M=this;if(Object.prototype.toString.call(E)!=="[object Array]")return this.reject(new TypeError("must be an array"));var F=E.length,j=!1;if(!F)return this.resolve([]);for(var X=new Array(F),te=0,ne=-1,oe=new this(m);++ne<F;)fe(E[ne],ne);return oe;function fe(Ne,We){M.resolve(Ne).then(Mt,function(Ae){j||(j=!0,g.reject(oe,Ae))});function Mt(Ae){X[We]=Ae,++te===F&&!j&&(j=!0,g.resolve(oe,X))}}}h.race=B;function B(E){var M=this;if(Object.prototype.toString.call(E)!=="[object Array]")return this.reject(new TypeError("must be an array"));var F=E.length,j=!1;if(!F)return this.resolve([]);for(var X=-1,te=new this(m);++X<F;)ne(E[X]);return te;function ne(oe){M.resolve(oe).then(function(fe){j||(j=!0,g.resolve(te,fe))},function(fe){j||(j=!0,g.reject(te,fe))})}}},{1:1}],3:[function(o,a,l){(function(f){"use strict";typeof f.Promise!="function"&&(f.Promise=o(2))}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{2:2}],4:[function(o,a,l){"use strict";var f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n};function m(n,s){if(!(n instanceof s))throw new TypeError("Cannot call a class as a function")}function g(){try{if(typeof indexedDB!="undefined")return indexedDB;if(typeof webkitIndexedDB!="undefined")return webkitIndexedDB;if(typeof mozIndexedDB!="undefined")return mozIndexedDB;if(typeof OIndexedDB!="undefined")return OIndexedDB;if(typeof msIndexedDB!="undefined")return msIndexedDB}catch(n){return}}var I=g();function w(){try{if(!I||!I.open)return!1;var n=typeof openDatabase!="undefined"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),s=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!n||s)&&typeof indexedDB!="undefined"&&typeof IDBKeyRange!="undefined"}catch(i){return!1}}function x(n,s){n=n||[],s=s||{};try{return new Blob(n,s)}catch(c){if(c.name!=="TypeError")throw c;for(var i=typeof BlobBuilder!="undefined"?BlobBuilder:typeof MSBlobBuilder!="undefined"?MSBlobBuilder:typeof MozBlobBuilder!="undefined"?MozBlobBuilder:WebKitBlobBuilder,u=new i,d=0;d<n.length;d+=1)u.append(n[d]);return u.getBlob(s.type)}}typeof Promise=="undefined"&&o(3);var h=Promise;function T(n,s){s&&n.then(function(i){s(null,i)},function(i){s(i)})}function P(n,s,i){typeof s=="function"&&n.then(s),typeof i=="function"&&n.catch(i)}function k(n){return typeof n!="string"&&(console.warn(n+" used as a key, but it is not a string."),n=String(n)),n}function C(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var D="local-forage-detect-blob-support",H=void 0,U={},ee=Object.prototype.toString,B="readonly",E="readwrite";function M(n){for(var s=n.length,i=new ArrayBuffer(s),u=new Uint8Array(i),d=0;d<s;d++)u[d]=n.charCodeAt(d);return i}function F(n){return new h(function(s){var i=n.transaction(D,E),u=x([""]);i.objectStore(D).put(u,"key"),i.onabort=function(d){d.preventDefault(),d.stopPropagation(),s(!1)},i.oncomplete=function(){var d=navigator.userAgent.match(/Chrome\/(\d+)/),c=navigator.userAgent.match(/Edge\//);s(c||!d||parseInt(d[1],10)>=43)}}).catch(function(){return!1})}function j(n){return typeof H=="boolean"?h.resolve(H):F(n).then(function(s){return H=s,H})}function X(n){var s=U[n.name],i={};i.promise=new h(function(u,d){i.resolve=u,i.reject=d}),s.deferredOperations.push(i),s.dbReady?s.dbReady=s.dbReady.then(function(){return i.promise}):s.dbReady=i.promise}function te(n){var s=U[n.name],i=s.deferredOperations.pop();if(i)return i.resolve(),i.promise}function ne(n,s){var i=U[n.name],u=i.deferredOperations.pop();if(u)return u.reject(s),u.promise}function oe(n,s){return new h(function(i,u){if(U[n.name]=U[n.name]||Ur(),n.db)if(s)X(n),n.db.close();else return i(n.db);var d=[n.name];s&&d.push(n.version);var c=I.open.apply(I,d);s&&(c.onupgradeneeded=function(p){var v=c.result;try{v.createObjectStore(n.storeName),p.oldVersion<=1&&v.createObjectStore(D)}catch(y){if(y.name==="ConstraintError")console.warn('The database "'+n.name+'" has been upgraded from version '+p.oldVersion+" to version "+p.newVersion+', but the storage "'+n.storeName+'" already exists.');else throw y}}),c.onerror=function(p){p.preventDefault(),u(c.error)},c.onsuccess=function(){var p=c.result;p.onversionchange=function(v){v.target.close()},i(p),te(n)}})}function fe(n){return oe(n,!1)}function Ne(n){return oe(n,!0)}function We(n,s){if(!n.db)return!0;var i=!n.db.objectStoreNames.contains(n.storeName),u=n.version<n.db.version,d=n.version>n.db.version;if(u&&(n.version!==s&&console.warn('The database "'+n.name+`" can't be downgraded from version `+n.db.version+" to version "+n.version+"."),n.version=n.db.version),d||i){if(i){var c=n.db.version+1;c>n.version&&(n.version=c)}return!0}return!1}function Mt(n){return new h(function(s,i){var u=new FileReader;u.onerror=i,u.onloadend=function(d){var c=btoa(d.target.result||"");s({__local_forage_encoded_blob:!0,data:c,type:n.type})},u.readAsBinaryString(n)})}function Ae(n){var s=M(atob(n.data));return x([s],{type:n.type})}function Lr(n){return n&&n.__local_forage_encoded_blob}function Eo(n){var s=this,i=s._initReady().then(function(){var u=U[s._dbInfo.name];if(u&&u.dbReady)return u.dbReady});return P(i,n,n),i}function Io(n){X(n);for(var s=U[n.name],i=s.forages,u=0;u<i.length;u++){var d=i[u];d._dbInfo.db&&(d._dbInfo.db.close(),d._dbInfo.db=null)}return n.db=null,fe(n).then(function(c){return n.db=c,We(n)?Ne(n):c}).then(function(c){n.db=s.db=c;for(var p=0;p<i.length;p++)i[p]._dbInfo.db=c}).catch(function(c){throw ne(n,c),c})}function me(n,s,i,u){u===void 0&&(u=1);try{var d=n.db.transaction(n.storeName,s);i(null,d)}catch(c){if(u>0&&(!n.db||c.name==="InvalidStateError"||c.name==="NotFoundError"))return h.resolve().then(function(){if(!n.db||c.name==="NotFoundError"&&!n.db.objectStoreNames.contains(n.storeName)&&n.version<=n.db.version)return n.db&&(n.version=n.db.version+1),Ne(n)}).then(function(){return Io(n).then(function(){me(n,s,i,u-1)})}).catch(i);i(c)}}function Ur(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function wo(n){var s=this,i={db:null};if(n)for(var u in n)i[u]=n[u];var d=U[i.name];d||(d=Ur(),U[i.name]=d),d.forages.push(s),s._initReady||(s._initReady=s.ready,s.ready=Eo);var c=[];function p(){return h.resolve()}for(var v=0;v<d.forages.length;v++){var y=d.forages[v];y!==s&&c.push(y._initReady().catch(p))}var b=d.forages.slice(0);return h.all(c).then(function(){return i.db=d.db,fe(i)}).then(function(_){return i.db=_,We(i,s._defaultConfig.version)?Ne(i):_}).then(function(_){i.db=d.db=_,s._dbInfo=i;for(var S=0;S<b.length;S++){var O=b[S];O!==s&&(O._dbInfo.db=i.db,O._dbInfo.version=i.version)}})}function So(n,s){var i=this;n=k(n);var u=new h(function(d,c){i.ready().then(function(){me(i._dbInfo,B,function(p,v){if(p)return c(p);try{var y=v.objectStore(i._dbInfo.storeName),b=y.get(n);b.onsuccess=function(){var _=b.result;_===void 0&&(_=null),Lr(_)&&(_=Ae(_)),d(_)},b.onerror=function(){c(b.error)}}catch(_){c(_)}})}).catch(c)});return T(u,s),u}function Ao(n,s){var i=this,u=new h(function(d,c){i.ready().then(function(){me(i._dbInfo,B,function(p,v){if(p)return c(p);try{var y=v.objectStore(i._dbInfo.storeName),b=y.openCursor(),_=1;b.onsuccess=function(){var S=b.result;if(S){var O=S.value;Lr(O)&&(O=Ae(O));var $=n(O,S.key,_++);$!==void 0?d($):S.continue()}else d()},b.onerror=function(){c(b.error)}}catch(S){c(S)}})}).catch(c)});return T(u,s),u}function Ro(n,s,i){var u=this;n=k(n);var d=new h(function(c,p){var v;u.ready().then(function(){return v=u._dbInfo,ee.call(s)==="[object Blob]"?j(v.db).then(function(y){return y?s:Mt(s)}):s}).then(function(y){me(u._dbInfo,E,function(b,_){if(b)return p(b);try{var S=_.objectStore(u._dbInfo.storeName);y===null&&(y=void 0);var O=S.put(y,n);_.oncomplete=function(){y===void 0&&(y=null),c(y)},_.onabort=_.onerror=function(){var $=O.error?O.error:O.transaction.error;p($)}}catch($){p($)}})}).catch(p)});return T(d,i),d}function xo(n,s){var i=this;n=k(n);var u=new h(function(d,c){i.ready().then(function(){me(i._dbInfo,E,function(p,v){if(p)return c(p);try{var y=v.objectStore(i._dbInfo.storeName),b=y.delete(n);v.oncomplete=function(){d()},v.onerror=function(){c(b.error)},v.onabort=function(){var _=b.error?b.error:b.transaction.error;c(_)}}catch(_){c(_)}})}).catch(c)});return T(u,s),u}function ko(n){var s=this,i=new h(function(u,d){s.ready().then(function(){me(s._dbInfo,E,function(c,p){if(c)return d(c);try{var v=p.objectStore(s._dbInfo.storeName),y=v.clear();p.oncomplete=function(){u()},p.onabort=p.onerror=function(){var b=y.error?y.error:y.transaction.error;d(b)}}catch(b){d(b)}})}).catch(d)});return T(i,n),i}function Co(n){var s=this,i=new h(function(u,d){s.ready().then(function(){me(s._dbInfo,B,function(c,p){if(c)return d(c);try{var v=p.objectStore(s._dbInfo.storeName),y=v.count();y.onsuccess=function(){u(y.result)},y.onerror=function(){d(y.error)}}catch(b){d(b)}})}).catch(d)});return T(i,n),i}function Po(n,s){var i=this,u=new h(function(d,c){if(n<0){d(null);return}i.ready().then(function(){me(i._dbInfo,B,function(p,v){if(p)return c(p);try{var y=v.objectStore(i._dbInfo.storeName),b=!1,_=y.openKeyCursor();_.onsuccess=function(){var S=_.result;if(!S){d(null);return}n===0||b?d(S.key):(b=!0,S.advance(n))},_.onerror=function(){c(_.error)}}catch(S){c(S)}})}).catch(c)});return T(u,s),u}function Do(n){var s=this,i=new h(function(u,d){s.ready().then(function(){me(s._dbInfo,B,function(c,p){if(c)return d(c);try{var v=p.objectStore(s._dbInfo.storeName),y=v.openKeyCursor(),b=[];y.onsuccess=function(){var _=y.result;if(!_){u(b);return}b.push(_.key),_.continue()},y.onerror=function(){d(y.error)}}catch(_){d(_)}})}).catch(d)});return T(i,n),i}function Oo(n,s){s=C.apply(this,arguments);var i=this.config();n=typeof n!="function"&&n||{},n.name||(n.name=n.name||i.name,n.storeName=n.storeName||i.storeName);var u=this,d;if(!n.name)d=h.reject("Invalid arguments");else{var c=n.name===i.name&&u._dbInfo.db,p=c?h.resolve(u._dbInfo.db):fe(n).then(function(v){var y=U[n.name],b=y.forages;y.db=v;for(var _=0;_<b.length;_++)b[_]._dbInfo.db=v;return v});n.storeName?d=p.then(function(v){if(v.objectStoreNames.contains(n.storeName)){var y=v.version+1;X(n);var b=U[n.name],_=b.forages;v.close();for(var S=0;S<_.length;S++){var O=_[S];O._dbInfo.db=null,O._dbInfo.version=y}var $=new h(function(V,z){var W=I.open(n.name,y);W.onerror=function(ie){var Ue=W.result;Ue.close(),z(ie)},W.onupgradeneeded=function(){var ie=W.result;ie.deleteObjectStore(n.storeName)},W.onsuccess=function(){var ie=W.result;ie.close(),V(ie)}});return $.then(function(V){b.db=V;for(var z=0;z<_.length;z++){var W=_[z];W._dbInfo.db=V,te(W._dbInfo)}}).catch(function(V){throw(ne(n,V)||h.resolve()).catch(function(){}),V})}}):d=p.then(function(v){X(n);var y=U[n.name],b=y.forages;v.close();for(var _=0;_<b.length;_++){var S=b[_];S._dbInfo.db=null}var O=new h(function($,V){var z=I.deleteDatabase(n.name);z.onerror=function(){var W=z.result;W&&W.close(),V(z.error)},z.onblocked=function(){console.warn('dropInstance blocked for database "'+n.name+'" until all open connections are closed')},z.onsuccess=function(){var W=z.result;W&&W.close(),$(W)}});return O.then(function($){y.db=$;for(var V=0;V<b.length;V++){var z=b[V];te(z._dbInfo)}}).catch(function($){throw(ne(n,$)||h.resolve()).catch(function(){}),$})})}return T(d,s),d}var Fo={_driver:"asyncStorage",_initStorage:wo,_support:w(),iterate:Ao,getItem:So,setItem:Ro,removeItem:xo,clear:ko,length:Co,key:Po,keys:Do,dropInstance:Oo};function No(){return typeof openDatabase=="function"}var ye="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Lo="~~local_forage_type~",Br=/^~~local_forage_type~([^~]+)~/,qe="__lfsc__:",$t=qe.length,Vt="arbf",jt="blob",Mr="si08",$r="ui08",Vr="uic8",jr="si16",Kr="si32",Hr="ur16",Gr="ui32",Jr="fl32",Wr="fl64",qr=$t+Vt.length,zr=Object.prototype.toString;function Yr(n){var s=n.length*.75,i=n.length,u,d=0,c,p,v,y;n[n.length-1]==="="&&(s--,n[n.length-2]==="="&&s--);var b=new ArrayBuffer(s),_=new Uint8Array(b);for(u=0;u<i;u+=4)c=ye.indexOf(n[u]),p=ye.indexOf(n[u+1]),v=ye.indexOf(n[u+2]),y=ye.indexOf(n[u+3]),_[d++]=c<<2|p>>4,_[d++]=(p&15)<<4|v>>2,_[d++]=(v&3)<<6|y&63;return b}function Kt(n){var s=new Uint8Array(n),i="",u;for(u=0;u<s.length;u+=3)i+=ye[s[u]>>2],i+=ye[(s[u]&3)<<4|s[u+1]>>4],i+=ye[(s[u+1]&15)<<2|s[u+2]>>6],i+=ye[s[u+2]&63];return s.length%3===2?i=i.substring(0,i.length-1)+"=":s.length%3===1&&(i=i.substring(0,i.length-2)+"=="),i}function Uo(n,s){var i="";if(n&&(i=zr.call(n)),n&&(i==="[object ArrayBuffer]"||n.buffer&&zr.call(n.buffer)==="[object ArrayBuffer]")){var u,d=qe;n instanceof ArrayBuffer?(u=n,d+=Vt):(u=n.buffer,i==="[object Int8Array]"?d+=Mr:i==="[object Uint8Array]"?d+=$r:i==="[object Uint8ClampedArray]"?d+=Vr:i==="[object Int16Array]"?d+=jr:i==="[object Uint16Array]"?d+=Hr:i==="[object Int32Array]"?d+=Kr:i==="[object Uint32Array]"?d+=Gr:i==="[object Float32Array]"?d+=Jr:i==="[object Float64Array]"?d+=Wr:s(new Error("Failed to get type for BinaryArray"))),s(d+Kt(u))}else if(i==="[object Blob]"){var c=new FileReader;c.onload=function(){var p=Lo+n.type+"~"+Kt(this.result);s(qe+jt+p)},c.readAsArrayBuffer(n)}else try{s(JSON.stringify(n))}catch(p){console.error("Couldn't convert value into a JSON string: ",n),s(null,p)}}function Bo(n){if(n.substring(0,$t)!==qe)return JSON.parse(n);var s=n.substring(qr),i=n.substring($t,qr),u;if(i===jt&&Br.test(s)){var d=s.match(Br);u=d[1],s=s.substring(d[0].length)}var c=Yr(s);switch(i){case Vt:return c;case jt:return x([c],{type:u});case Mr:return new Int8Array(c);case $r:return new Uint8Array(c);case Vr:return new Uint8ClampedArray(c);case jr:return new Int16Array(c);case Hr:return new Uint16Array(c);case Kr:return new Int32Array(c);case Gr:return new Uint32Array(c);case Jr:return new Float32Array(c);case Wr:return new Float64Array(c);default:throw new Error("Unkown type: "+i)}}var Ht={serialize:Uo,deserialize:Bo,stringToBuffer:Yr,bufferToString:Kt};function Qr(n,s,i,u){n.executeSql("CREATE TABLE IF NOT EXISTS "+s.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],i,u)}function Mo(n){var s=this,i={db:null};if(n)for(var u in n)i[u]=typeof n[u]!="string"?n[u].toString():n[u];var d=new h(function(c,p){try{i.db=openDatabase(i.name,String(i.version),i.description,i.size)}catch(v){return p(v)}i.db.transaction(function(v){Qr(v,i,function(){s._dbInfo=i,c()},function(y,b){p(b)})},p)});return i.serializer=Ht,d}function be(n,s,i,u,d,c){n.executeSql(i,u,d,function(p,v){v.code===v.SYNTAX_ERR?p.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[s.storeName],function(y,b){b.rows.length?c(y,v):Qr(y,s,function(){y.executeSql(i,u,d,c)},c)},c):c(p,v)},c)}function $o(n,s){var i=this;n=k(n);var u=new h(function(d,c){i.ready().then(function(){var p=i._dbInfo;p.db.transaction(function(v){be(v,p,"SELECT * FROM "+p.storeName+" WHERE key = ? LIMIT 1",[n],function(y,b){var _=b.rows.length?b.rows.item(0).value:null;_&&(_=p.serializer.deserialize(_)),d(_)},function(y,b){c(b)})})}).catch(c)});return T(u,s),u}function Vo(n,s){var i=this,u=new h(function(d,c){i.ready().then(function(){var p=i._dbInfo;p.db.transaction(function(v){be(v,p,"SELECT * FROM "+p.storeName,[],function(y,b){for(var _=b.rows,S=_.length,O=0;O<S;O++){var $=_.item(O),V=$.value;if(V&&(V=p.serializer.deserialize(V)),V=n(V,$.key,O+1),V!==void 0){d(V);return}}d()},function(y,b){c(b)})})}).catch(c)});return T(u,s),u}function Xr(n,s,i,u){var d=this;n=k(n);var c=new h(function(p,v){d.ready().then(function(){s===void 0&&(s=null);var y=s,b=d._dbInfo;b.serializer.serialize(s,function(_,S){S?v(S):b.db.transaction(function(O){be(O,b,"INSERT OR REPLACE INTO "+b.storeName+" (key, value) VALUES (?, ?)",[n,_],function(){p(y)},function($,V){v(V)})},function(O){if(O.code===O.QUOTA_ERR){if(u>0){p(Xr.apply(d,[n,y,i,u-1]));return}v(O)}})})}).catch(v)});return T(c,i),c}function jo(n,s,i){return Xr.apply(this,[n,s,i,1])}function Ko(n,s){var i=this;n=k(n);var u=new h(function(d,c){i.ready().then(function(){var p=i._dbInfo;p.db.transaction(function(v){be(v,p,"DELETE FROM "+p.storeName+" WHERE key = ?",[n],function(){d()},function(y,b){c(b)})})}).catch(c)});return T(u,s),u}function Ho(n){var s=this,i=new h(function(u,d){s.ready().then(function(){var c=s._dbInfo;c.db.transaction(function(p){be(p,c,"DELETE FROM "+c.storeName,[],function(){u()},function(v,y){d(y)})})}).catch(d)});return T(i,n),i}function Go(n){var s=this,i=new h(function(u,d){s.ready().then(function(){var c=s._dbInfo;c.db.transaction(function(p){be(p,c,"SELECT COUNT(key) as c FROM "+c.storeName,[],function(v,y){var b=y.rows.item(0).c;u(b)},function(v,y){d(y)})})}).catch(d)});return T(i,n),i}function Jo(n,s){var i=this,u=new h(function(d,c){i.ready().then(function(){var p=i._dbInfo;p.db.transaction(function(v){be(v,p,"SELECT key FROM "+p.storeName+" WHERE id = ? LIMIT 1",[n+1],function(y,b){var _=b.rows.length?b.rows.item(0).key:null;d(_)},function(y,b){c(b)})})}).catch(c)});return T(u,s),u}function Wo(n){var s=this,i=new h(function(u,d){s.ready().then(function(){var c=s._dbInfo;c.db.transaction(function(p){be(p,c,"SELECT key FROM "+c.storeName,[],function(v,y){for(var b=[],_=0;_<y.rows.length;_++)b.push(y.rows.item(_).key);u(b)},function(v,y){d(y)})})}).catch(d)});return T(i,n),i}function qo(n){return new h(function(s,i){n.transaction(function(u){u.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(d,c){for(var p=[],v=0;v<c.rows.length;v++)p.push(c.rows.item(v).name);s({db:n,storeNames:p})},function(d,c){i(c)})},function(u){i(u)})})}function zo(n,s){s=C.apply(this,arguments);var i=this.config();n=typeof n!="function"&&n||{},n.name||(n.name=n.name||i.name,n.storeName=n.storeName||i.storeName);var u=this,d;return n.name?d=new h(function(c){var p;n.name===i.name?p=u._dbInfo.db:p=openDatabase(n.name,"","",0),n.storeName?c({db:p,storeNames:[n.storeName]}):c(qo(p))}).then(function(c){return new h(function(p,v){c.db.transaction(function(y){function b($){return new h(function(V,z){y.executeSql("DROP TABLE IF EXISTS "+$,[],function(){V()},function(W,ie){z(ie)})})}for(var _=[],S=0,O=c.storeNames.length;S<O;S++)_.push(b(c.storeNames[S]));h.all(_).then(function(){p()}).catch(function($){v($)})},function(y){v(y)})})}):d=h.reject("Invalid arguments"),T(d,s),d}var Yo={_driver:"webSQLStorage",_initStorage:Mo,_support:No(),iterate:Vo,getItem:$o,setItem:jo,removeItem:Ko,clear:Ho,length:Go,key:Jo,keys:Wo,dropInstance:zo};function Qo(){try{return typeof localStorage!="undefined"&&"setItem"in localStorage&&!!localStorage.setItem}catch(n){return!1}}function Zr(n,s){var i=n.name+"/";return n.storeName!==s.storeName&&(i+=n.storeName+"/"),i}function Xo(){var n="_localforage_support_test";try{return localStorage.setItem(n,!0),localStorage.removeItem(n),!1}catch(s){return!0}}function Zo(){return!Xo()||localStorage.length>0}function ei(n){var s=this,i={};if(n)for(var u in n)i[u]=n[u];return i.keyPrefix=Zr(n,s._defaultConfig),Zo()?(s._dbInfo=i,i.serializer=Ht,h.resolve()):h.reject()}function ti(n){var s=this,i=s.ready().then(function(){for(var u=s._dbInfo.keyPrefix,d=localStorage.length-1;d>=0;d--){var c=localStorage.key(d);c.indexOf(u)===0&&localStorage.removeItem(c)}});return T(i,n),i}function ri(n,s){var i=this;n=k(n);var u=i.ready().then(function(){var d=i._dbInfo,c=localStorage.getItem(d.keyPrefix+n);return c&&(c=d.serializer.deserialize(c)),c});return T(u,s),u}function ni(n,s){var i=this,u=i.ready().then(function(){for(var d=i._dbInfo,c=d.keyPrefix,p=c.length,v=localStorage.length,y=1,b=0;b<v;b++){var _=localStorage.key(b);if(_.indexOf(c)===0){var S=localStorage.getItem(_);if(S&&(S=d.serializer.deserialize(S)),S=n(S,_.substring(p),y++),S!==void 0)return S}}});return T(u,s),u}function oi(n,s){var i=this,u=i.ready().then(function(){var d=i._dbInfo,c;try{c=localStorage.key(n)}catch(p){c=null}return c&&(c=c.substring(d.keyPrefix.length)),c});return T(u,s),u}function ii(n){var s=this,i=s.ready().then(function(){for(var u=s._dbInfo,d=localStorage.length,c=[],p=0;p<d;p++){var v=localStorage.key(p);v.indexOf(u.keyPrefix)===0&&c.push(v.substring(u.keyPrefix.length))}return c});return T(i,n),i}function ai(n){var s=this,i=s.keys().then(function(u){return u.length});return T(i,n),i}function si(n,s){var i=this;n=k(n);var u=i.ready().then(function(){var d=i._dbInfo;localStorage.removeItem(d.keyPrefix+n)});return T(u,s),u}function ci(n,s,i){var u=this;n=k(n);var d=u.ready().then(function(){s===void 0&&(s=null);var c=s;return new h(function(p,v){var y=u._dbInfo;y.serializer.serialize(s,function(b,_){if(_)v(_);else try{localStorage.setItem(y.keyPrefix+n,b),p(c)}catch(S){(S.name==="QuotaExceededError"||S.name==="NS_ERROR_DOM_QUOTA_REACHED")&&v(S),v(S)}})})});return T(d,i),d}function ui(n,s){if(s=C.apply(this,arguments),n=typeof n!="function"&&n||{},!n.name){var i=this.config();n.name=n.name||i.name,n.storeName=n.storeName||i.storeName}var u=this,d;return n.name?d=new h(function(c){n.storeName?c(Zr(n,u._defaultConfig)):c(n.name+"/")}).then(function(c){for(var p=localStorage.length-1;p>=0;p--){var v=localStorage.key(p);v.indexOf(c)===0&&localStorage.removeItem(v)}}):d=h.reject("Invalid arguments"),T(d,s),d}var li={_driver:"localStorageWrapper",_initStorage:ei,_support:Qo(),iterate:ni,getItem:ri,setItem:ci,removeItem:si,clear:ti,length:ai,key:oi,keys:ii,dropInstance:ui},di=function(s,i){return s===i||typeof s=="number"&&typeof i=="number"&&isNaN(s)&&isNaN(i)},fi=function(s,i){for(var u=s.length,d=0;d<u;){if(di(s[d],i))return!0;d++}return!1},en=Array.isArray||function(n){return Object.prototype.toString.call(n)==="[object Array]"},Le={},tn={},Re={INDEXEDDB:Fo,WEBSQL:Yo,LOCALSTORAGE:li},mi=[Re.INDEXEDDB._driver,Re.WEBSQL._driver,Re.LOCALSTORAGE._driver],ze=["dropInstance"],Gt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ze),pi={description:"",driver:mi.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function hi(n,s){n[s]=function(){var i=arguments;return n.ready().then(function(){return n[s].apply(n,i)})}}function Jt(){for(var n=1;n<arguments.length;n++){var s=arguments[n];if(s)for(var i in s)s.hasOwnProperty(i)&&(en(s[i])?arguments[0][i]=s[i].slice():arguments[0][i]=s[i])}return arguments[0]}var gi=function(){function n(s){m(this,n);for(var i in Re)if(Re.hasOwnProperty(i)){var u=Re[i],d=u._driver;this[i]=d,Le[d]||this.defineDriver(u)}this._defaultConfig=Jt({},pi),this._config=Jt({},this._defaultConfig,s),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return n.prototype.config=function(i){if((typeof i=="undefined"?"undefined":f(i))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var u in i){if(u==="storeName"&&(i[u]=i[u].replace(/\W/g,"_")),u==="version"&&typeof i[u]!="number")return new Error("Database version must be a number.");this._config[u]=i[u]}return"driver"in i&&i.driver?this.setDriver(this._config.driver):!0}else return typeof i=="string"?this._config[i]:this._config},n.prototype.defineDriver=function(i,u,d){var c=new h(function(p,v){try{var y=i._driver,b=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!i._driver){v(b);return}for(var _=Gt.concat("_initStorage"),S=0,O=_.length;S<O;S++){var $=_[S],V=!fi(ze,$);if((V||i[$])&&typeof i[$]!="function"){v(b);return}}var z=function(){for(var Ue=function(bi){return function(){var _i=new Error("Method "+bi+" is not implemented by the current driver"),rn=h.reject(_i);return T(rn,arguments[arguments.length-1]),rn}},Wt=0,yi=ze.length;Wt<yi;Wt++){var qt=ze[Wt];i[qt]||(i[qt]=Ue(qt))}};z();var W=function(Ue){Le[y]&&console.info("Redefining LocalForage driver: "+y),Le[y]=i,tn[y]=Ue,p()};"_support"in i?i._support&&typeof i._support=="function"?i._support().then(W,v):W(!!i._support):W(!0)}catch(ie){v(ie)}});return P(c,u,d),c},n.prototype.driver=function(){return this._driver||null},n.prototype.getDriver=function(i,u,d){var c=Le[i]?h.resolve(Le[i]):h.reject(new Error("Driver not found."));return P(c,u,d),c},n.prototype.getSerializer=function(i){var u=h.resolve(Ht);return P(u,i),u},n.prototype.ready=function(i){var u=this,d=u._driverSet.then(function(){return u._ready===null&&(u._ready=u._initDriver()),u._ready});return P(d,i,i),d},n.prototype.setDriver=function(i,u,d){var c=this;en(i)||(i=[i]);var p=this._getSupportedDrivers(i);function v(){c._config.driver=c.driver()}function y(S){return c._extend(S),v(),c._ready=c._initStorage(c._config),c._ready}function b(S){return function(){var O=0;function $(){for(;O<S.length;){var V=S[O];return O++,c._dbInfo=null,c._ready=null,c.getDriver(V).then(y).catch($)}v();var z=new Error("No available storage method found.");return c._driverSet=h.reject(z),c._driverSet}return $()}}var _=this._driverSet!==null?this._driverSet.catch(function(){return h.resolve()}):h.resolve();return this._driverSet=_.then(function(){var S=p[0];return c._dbInfo=null,c._ready=null,c.getDriver(S).then(function(O){c._driver=O._driver,v(),c._wrapLibraryMethodsWithReady(),c._initDriver=b(p)})}).catch(function(){v();var S=new Error("No available storage method found.");return c._driverSet=h.reject(S),c._driverSet}),P(this._driverSet,u,d),this._driverSet},n.prototype.supports=function(i){return!!tn[i]},n.prototype._extend=function(i){Jt(this,i)},n.prototype._getSupportedDrivers=function(i){for(var u=[],d=0,c=i.length;d<c;d++){var p=i[d];this.supports(p)&&u.push(p)}return u},n.prototype._wrapLibraryMethodsWithReady=function(){for(var i=0,u=Gt.length;i<u;i++)hi(this,Gt[i])},n.prototype.createInstance=function(i){return new n(i)},n}(),vi=new gi;a.exports=vi},{3:3}]},{},[4])(4)})});var no=sn(Se=>{"use strict";K();Ge();Ie();var Ce=ae(),ka=se("levelFinished",{paramsSchema:R.tuple(R.string(),R.object({result:R.boolean(),duration:R.number()})),implement:(e,t)=>N(Se,null,function*(){let{result:r,duration:o}=t;ce.info("onLevelFinished",r,o),yield Promise.all([le.reporter({event:"COMPLETE_GAME_LEVEL"}),le.tracker("LevelFinished",{levelId:e,result:r,duration:o})])})}),Ca=se("taskFinished",{paramsSchema:R.tuple(R.string(),R.object({duration:R.number()})),implement:(e,t)=>N(Se,null,function*(){let{duration:r}=t;yield le.tracker("TaskFinished",{duration:r,taskId:e})})}),Pa=se("levelUpgrade",{paramsSchema:R.tuple(R.string(),R.string()),implement:(e,t)=>N(Se,null,function*(){return yield le.tracker("LevelUpgrade",{name:t,levelId:e})})}),Da=se("onHistoryUserLevel",{paramsSchema:R.tuple(R.number()),implement:e=>N(Se,null,function*(){return yield le.tracker("HistoryUserLevel",{level:e})})}),Oa=se("onHistoryUserScore",{paramsSchema:R.tuple(R.number()),implement:e=>N(Se,null,function*(){return yield le.tracker("HistoryUserScore",{score:e})})}),Fa=se("taskEvent",{paramsSchema:R.tuple(R.string(),R.object({tools:R.array(R.object({id:R.string(),name:R.string(),count:R.number(),description:R.string().optional(),price:R.object({amount:R.number(),unit:R.string()}).optional()})).optional(),awards:R.array(R.object({id:R.string(),name:R.string()})).optional()})),implement:(e,t)=>N(Se,null,function*(){var r;(r=t.tools)!=null&&r.length&&(yield Promise.all([le.reporter({event:"USE_GAME_ITEM"}),le.tracker("UseGameItem",L({taskId:e},t))]))})});Ce.registerCommand("TaskTrackerSDK.levelFinished",ka);Ce.registerCommand("TaskTrackerSDK.taskFinished",Ca);Ce.registerCommand("TaskTrackerSDK.levelUpgrade",Pa);Ce.registerCommand("TaskTrackerSDK.historyUserLevel",Da);Ce.registerCommand("TaskTrackerSDK.historyUserScore",Oa);Ce.registerCommand("TaskTrackerSDK.taskEvent",Fa);Q("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});Q("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});Q("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});Q("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});Q("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});Q("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}})});Ie();re();Ge();K();var Xn=ae(),ma="env",pa="getSystemInfoSync",ha=()=>{var a,l,f,m;let e={system:A.deviceInfo.system,platform:A.deviceInfo.platform,brand:A.deviceInfo.brand,pixelRatio:A.deviceInfo.pixelRatio,language:A.deviceInfo.lang,version:A.sdkInfo.jssdkVersion,appName:(a=A.hostInfo)==null?void 0:a.appName,SDKVersion:A.sdkInfo.nativeSDKVersion},t=(l=A.hostInfo)==null?void 0:l.version;t&&(e=q(L({},e),{version:t}));let r=(f=A.hostInfo)==null?void 0:f.appName;r&&(e=q(L({},e),{appName:r}));let o=(m=A.sdkInfo)==null?void 0:m.jssdkVersion;return o&&(e=q(L({},e),{SDKVersion:o})),e},ga=we(pa,{implement:ha}),va=we(ma,{implement:()=>q(L({},A.hostInfo),{sdkInfo:A.sdkInfo,platform:A.platform,deviceInfo:A.deviceInfo})});Xn.registerCommand("API.env",va);Xn.registerCommand("API.getSystemInfoSync",ga);Q("env",{version:"1.0.0"});Q("getSystemInfoSync",{version:"1.0.0"});K();Ge();Te();Ie();var ya="onJoliboxShow",ba="onJoliboxHide",_a="onReady",kr=ae(),Cr=En(ue),xr=!0,Je=!0,At=0,Rt=Tr;function Ta(){let e=Date.now();if(e-At<100)return;At=e;let t=document.visibilityState==="visible";t!==xr&&(xr=t,Rt.emit("visible",xr))}function Zn(e){let t=Date.now();t-At<100||(At=t,e==="focus"&&!Je?Je=!0:e==="blur"&&Je&&(Je=!1),Rt.emit("visible",Je))}document.addEventListener("visibilitychange",Ta);window.addEventListener("focus",()=>Zn("focus"));window.addEventListener("blur",()=>Zn("blur"));var Ea=we(ya,{paramsSchema:R.tuple(R.function()),implement(e){let t=Cr(e);Rt.on("visible",r=>{r&&t()})}}),Ia=we(ba,{paramsSchema:R.tuple(R.function()),implement(e){let t=Cr(e);Rt.on("visible",r=>{!r&&t()})}}),wa=we(_a,{paramsSchema:R.tuple(R.function()),implement(e){let t=Cr(e);Ke.on("LifecycleEvent.onReady",r=>{t(r)})}});kr.registerCommand("LifecycleSDK.onReady",wa);kr.registerCommand("LifecycleSDK.onJoliboxShow",Ea);kr.registerCommand("LifecycleSDK.onJoliboxHide",Ia);Q("lifeCycle.onReady",{version:"1.0.0"});Q("lifeCycle.onJoliboxShow",{version:"1.0.0"});Q("lifeCycle.onJoliboxHide",{version:"1.0.0"});Ge();K();He();re();var ro=cn(to());var xt=ae(),Dr=class{constructor(){this.httpClient=ge.create({baseUrl:A.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com"});this.getGameId=()=>A.mpId;this.getItem=t=>N(this,null,function*(){let{code:r,data:o,message:a}=yield this.httpClient.get(`/api/games/user-storage/${this.gameId}`,{query:{key:t}}),l=o==null?void 0:o.value,f=a;return r!=="SUCCESS"&&(l=yield this.gameStore.getItem(t),console.info("[SDK] cloud storage getItem failed, read from localstorage",l),f+="fallback to localstorage"),{code:r,message:f,data:l&&l!=="undefined"?l:null}});this.setItem=(t,r)=>N(this,null,function*(){let o=typeof r=="string"?r:String(r),{code:a,message:l}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}`,{data:{key:t,value:o}});return yield this.gameStore.setItem(t,o),{code:a,message:l}});this.removeItem=t=>N(this,null,function*(){yield this.gameStore.removeItem(t);let{code:r,message:o}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}/remove`,{data:{key:t}});return{code:r,message:o}});this.clear=()=>N(this,null,function*(){yield this.gameStore.clear();let{code:t,message:r}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}/clear`,{});return{code:t,message:r}});this.gameId=this.getGameId(),this.gameStore=ro.default.createInstance({name:this.gameId.length?this.gameId:"default"})}},kt=new Dr,Sa=se("getLocalStorage",{paramsSchema:R.tuple(R.string()),implement(e){return N(this,null,function*(){return yield kt.getItem(e)})}});xt.registerCommand("StorageSDK.getItem",Sa);Q("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var Aa=se("setStorage",{paramsSchema:R.tuple(R.string(),R.or(R.string(),R.boolean(),R.number())),implement(e,t){return N(this,null,function*(){return yield kt.setItem(e,t)})}});xt.registerCommand("StorageSDK.setItem",Aa);Q("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var Ra=se("removeStorage",{paramsSchema:R.tuple(R.string()),implement(e){return N(this,null,function*(){return yield kt.removeItem(e)})}});xt.registerCommand("StorageSDK.removeItem",Ra);Q("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var xa=se("clearStorage",{implement(){return N(this,null,function*(){return yield kt.clear()})}});xt.registerCommand("StorageSDK.clear",xa);Q("storage.clear",{version:"1.0.0"});var Ku=cn(no());var Ct=class{constructor(t){this.track=t;this.adBreakIsShowing=!1;this.reportPageJumpOut=()=>{this.track("AdBreakJumpOut",{context:"AdsActionDetection"})};this.reportPageHide=()=>{this.track("AdBreakHide",{context:"AdsActionDetection"})};window.addEventListener("visibilitychange",()=>{document.hidden&&this.adBreakIsShowing&&this.reportPageHide()}),window.addEventListener("beforeunload",r=>{this.adBreakIsShowing&&this.reportPageJumpOut()})}};var oo="jolibox-sdk-ads-callbreak-timestamps",Pt=class{constructor(t,r,o,a){this.track=t;this.httpClient=r;this.checkNetwork=o;this.maxAllowedAdsForTime=8;this.bannedForTimeThreshold=6e4;this.bannedReleaseTime=6e4;this.isBanningForTime=!1;this.releaseBannedForTimeTimeout=null;this.maxAllowedAdsForSession=200;this.bannedForSessionThreshold=6e5;this.isBanningForSession=!1;this.initialThreshold=2e3;this._callAdsTimestampsForTime=[];this.callAdsTimestampsForSession=[];this.initTimestamp=0;this.initCallAdsTimestampsForTime=()=>{var t;try{let r=JSON.parse((t=window.localStorage.getItem(oo))!=null?t:"[]");Array.isArray(r)?this._callAdsTimestampsForTime=r:this._callAdsTimestampsForTime=[]}catch(r){this._callAdsTimestampsForTime=[]}};this.setReleaseBannedForTime=()=>{this.releaseBannedForTimeTimeout&&(window.clearTimeout(this.releaseBannedForTimeTimeout),this.releaseBannedForTimeTimeout=null),this.releaseBannedForTimeTimeout=window.setTimeout(()=>{this.isBanningForTime=!1,this.releaseBannedForTimeTimeout=null},this.bannedReleaseTime)};this.checkShouldBannedInitial=()=>{if(Date.now()-this.initTimestamp<=this.initialThreshold)return"BLOCK_INITIAL"};this.checkShouldBannedForSession=t=>{if(this.isBanningForSession)return"BANNED_FOR_SESSION";let r=Date.now();if(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.concat({timestamp:r,type:t}),this.callAdsTimestampsForSession.length!==1&&(this.callAdsTimestampsForSession.length>this.maxAllowedAdsForSession&&(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.slice(-this.maxAllowedAdsForSession)),this.callAdsTimestampsForSession.length===this.maxAllowedAdsForSession&&r-this.callAdsTimestampsForSession[0].timestamp<=this.bannedForSessionThreshold))return this.isBanningForSession=!0,"BANNED_FOR_SESSION"};this.checkShouldBannedForTime=t=>{if(this.isBanningForTime)return"WAITING_BANNED_RELEASE";let r=Date.now();if(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.concat({timestamp:r,type:t}),this.callAdsTimestampsForTime.length!==1&&(this.callAdsTimestampsForTime.length>this.maxAllowedAdsForTime&&(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.slice(-this.maxAllowedAdsForTime)),this.callAdsTimestampsForTime.length===this.maxAllowedAdsForTime&&r-this.callAdsTimestampsForTime[0].timestamp<=this.bannedForTimeThreshold))return this.isBanningForTime=!0,this.setReleaseBannedForTime(),"BANNED_FOR_TIME"};this.checkAdsDisplayPermission=t=>{if(!this.checkNetwork())return"NETWORK_NOT_OK";let r=this.checkShouldBannedInitial();if(r)return r;let o=this.checkShouldBannedForSession(t);if(o)return o;let a=this.checkShouldBannedForTime(t);return a||"ALLOWED"};var l,f,m,g,I,w;if(this.maxAllowedAdsForTime=(l=a==null?void 0:a.maxAllowedAdsForTime)!=null?l:8,this.bannedForTimeThreshold=(f=a==null?void 0:a.bannedForTimeThreshold)!=null?f:6e4,this.bannedReleaseTime=(m=a==null?void 0:a.bannedReleaseTime)!=null?m:6e4,this.maxAllowedAdsForSession=(g=a==null?void 0:a.maxAllowedAdsForSession)!=null?g:200,this.bannedForSessionThreshold=(I=a==null?void 0:a.bannedForSessionThreshold)!=null?I:6e5,this.initialThreshold=(w=a==null?void 0:a.initialThreshold)!=null?w:2e3,this.maxAllowedAdsForTime<=1)throw new Error("maxAllowedAdsForTime must be greater than 1");if(this.bannedForTimeThreshold<0)throw new Error("bannedForTimeThreshold must be greater than or equal to 0");if(this.bannedReleaseTime<this.bannedForTimeThreshold)throw new Error("bannedReleaseTime must be greater than or equal to bannedForTimeThreshold");if(this.initialThreshold<0)throw new Error("initialThreshold must be greater than or equal to 0");this.initCallAdsTimestampsForTime(),this.initTimestamp=Date.now()}get callAdsTimestampsForTime(){return this._callAdsTimestampsForTime}set callAdsTimestampsForTime(t){try{window.localStorage.setItem(oo,JSON.stringify(t))}catch(r){console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=t}report(t){this.track("PreventAdsCheating",{reason:t}),this.httpClient.post("/api/base/app-event",{data:{eventType:"PREVENT_ADS_CHEATING",adsInfo:{reason:t}}})}};re();re();var Dt=class{constructor(t){this.httpClient=t;this.configs=null;this.firstRun=!0;this.init()}init(){return N(this,null,function*(){try{this.configs=yield this.httpClient.get("/api/fe-configs/js-sdk/ads-channel-config")}catch(t){}})}shouldBypassCallingInterstitial(){var r,o;let t;if(!this.configs)this.init(),t=!this.firstRun;else{let a=(r=A.channel)!=null?r:"",l=this.configs[a],f=(o=l==null?void 0:l.interstitialRate)!=null?o:1;t=Math.random()<f}return this.firstRun=!1,t}};K();var Pe=new _e,Ot=class{constructor(t,r,o){this.track=t;this.httpClient=r;this.checkNetwork=o;this.configured=!1;this.config={};this.getGameId=()=>A.mpId;this.getTestAdsMode=()=>A.testAdsMode;this.asyncLoad=()=>N(this,null,function*(){var f,m,g,I,w;let t="ca-pub-7171363994453626",r,o,a=window.encodeURIComponent(window.btoa((f=this.getGameId())!=null?f:"")),l=(m=this.getTestAdsMode())!=null?m:!1;try{let x=yield this.httpClient.get("/public/ads",{query:{objectId:a,testAdsMode:`${l}`}});t=(g=x.data)==null?void 0:g.clientId,r=(I=x.data)==null?void 0:I.channelId,o=(w=x.data)==null?void 0:w.unitId}catch(x){console.error("Failed to fetch client info",x)}this.clientId=t,this.channelId=r,this.unitId=o});this.asyncInit=t=>N(this,null,function*(){var a;if(typeof window=="undefined")return;yield this.asyncLoad();let r="google-adsense",o=(a=this.getTestAdsMode())!=null?a:!1;if(!document.getElementById(r)&&this.clientId){let l=document.createElement("script");l.id=r,l.async=!0,l.crossOrigin="anonymous",l.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`,o&&l.setAttribute("data-adbreak-test","on"),this.channelId&&l.setAttribute("data-ad-channel",this.channelId),document.head.appendChild(l),this.track("LoadAdsenseCompleted",null)}});this.push=(t={})=>{window.adsbygoogle.push(t)};this.wrapAdBreakParams=t=>{if((o=>o.type==="preroll")(t)){Pe.emit("isAdShowing",!0);let o=t.adBreakDone,a=l=>{Pe.emit("isAdShowing",!1),o&&o(l)};return q(L({},t),{adBreakDone:a})}else{let o=t.beforeAd,a=t.afterAd,l=()=>{var m;Pe.emit("isAdShowing",!0),this.track("CallBeforeAd",{type:t.type,name:(m=t.name)!=null?m:""}),o&&o()},f=()=>{var m;Pe.emit("isAdShowing",!1),this.track("CallAfterAd",{type:t.type,name:(m=t.name)!=null?m:""}),a&&a()};return q(L({},t),{beforeAd:l,afterAd:f})}};this.adConfig=t=>{let a=t,{onReady:r}=a,o=an(a,["onReady"]);this.track("CallAdConfig",o),this.configured?console.warn("Ad config already set, skipping"):(this.configured=!0,this.push(t))};this.adBreak=t=>{var g,I,w,x;if(!this.getGameId()){console.warn("Game ID is not set, skip calling adBreak");return}if(t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){(g=t.adBreakDone)==null||g.call(t,{breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}let r=this.antiCheating.checkAdsDisplayPermission(t.type==="reward"?"reward":"interstitial");switch(r){case"NETWORK_NOT_OK":case"BANNED_FOR_SESSION":console.warn("Ads not allowed",r),(I=t.adBreakDone)==null||I.call(t,{breakType:t.type,breakName:r,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"}),this.antiCheating.report(r);return;case"BLOCK_INITIAL":case"BANNED_FOR_TIME":case"WAITING_BANNED_RELEASE":console.warn("Ads not allowed",r),(w=t.adBreakDone)==null||w.call(t,{breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"}),this.antiCheating.report(r);return;default:break}let o=t.type,a=t.adBreakDone,l=h=>{var T;this.adsActionDetection.adBreakIsShowing=!1,this.track("CallAdBreakDone",{breakType:h.breakType,breakName:(T=h.breakName)!=null?T:"",breakFormat:h.breakFormat,breakStatus:h.breakStatus}),a&&a(h)};if(t.adBreakDone=l,t.type==="reward"){let h=t.beforeReward,T=k=>()=>{this.track("CallShowAdFn",null),k()},P=k=>{h&&h(T(k))};t.beforeReward=P}let f;switch(o){case"preroll":f={type:o};break;case"start":case"pause":case"next":case"browse":case"reward":f={type:o,name:(x=t.name)!=null?x:""};break}this.adsActionDetection.adBreakIsShowing=!0,this.track("CallAdBreak",f);let m=this.wrapAdBreakParams(t);this.push(m),window.JoliTesterBridge&&console.log("joli-fullscreen-ad-show")};this.adUnit=t=>N(this,null,function*(){var h,T,P,k;if(this.track("CallAdUnit",{adFormat:(T=(h=t.adFormat)==null?void 0:h.toString())!=null?T:null,fullWidthResponsive:(P=t.fullWidthResponsive)!=null?P:null}),this.clientId||(yield this.asyncLoad()),document.querySelector("#jolibox-ads")){console.warn("Ad unit already set, skipping");return}let{el:r,slot:o,adFormat:a,fullWidthResponsive:l,style:f}=t,m;if(!r)throw new Error("targeting element is required");if(typeof r=="string"?m=document.querySelector(r):m=r,!m)throw new Error("targeting element not found");let g=o;if(g||(g=this.unitId),!g)throw new Error("slot is required");let I=typeof a=="object"&&Array.isArray(a)?a.join(", "):a,w=document.createElement("ins");if(w.className="adsbygoogle",w.id="jolibox-ads",w.style.display="block",w.setAttribute("data-ad-client",this.clientId),w.setAttribute("data-ad-slot",g),I&&w.setAttribute("data-ad-format",I),l&&w.setAttribute("data-full-width-responsive",l),f&&w.setAttribute("style",f),(k=this.getTestAdsMode())!=null?k:!1){let C=document.createElement("div");C.style.position="absolute",C.style.top="0",C.style.left="0",C.style.width="100%",C.style.height="100%",C.style.display="flex",C.style.justifyContent="center",C.style.alignItems="center",C.style.backgroundColor="rgba(0, 0, 0, 0.5)",C.style.color="white",C.innerHTML="Test Ad",w.style.position="relative",m.appendChild(w),w.appendChild(C)}else m.appendChild(w),new MutationObserver(D=>{D.forEach(H=>{if(H.type==="attributes"&&H.attributeName==="data-ad-status"){let U=w.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:U!=null?U:"null"})}})}).observe(w,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})});this.antiCheating=new Pt(t,r,o),this.adsActionDetection=new Ct(this.track),this.channelPolicy=new Dt(r)}init(t){this.track("CallAdsInit",null),typeof window!="undefined"&&(this.config=t!=null?t:{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}};Ie();K();He();var io=(e,t)=>{var r;window.dispatchEvent(new CustomEvent(e,{detail:t})),(r=window.parent)==null||r.postMessage({type:e,data:{detail:t}},"*")};var Ft=ae(),Na=ge.create(),Nt=new Ot(de,Na,()=>ge.getNetworkStatus());Pe.on("isAdShowing",e=>{io("JOLIBOX_ADS_EVENT",{isAdShowing:e})});Ft.registerCommand("AdsSDK.init",e=>{Nt.init(e)});Ft.registerCommand("AdsSDK.adConfig",e=>{Nt.adConfig(e)});Ft.registerCommand("AdsSDK.adBreak",e=>{Nt.adBreak(e)});Ft.registerCommand("AdsSDK.adUnit",e=>{Nt.adUnit(e)});K();Ie();var fo=-1,Ut=function(e){addEventListener("pageshow",function(t){t.persisted&&(fo=t.timeStamp,e(t))},!0)},Fr=function(){var e=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},Bt=function(){var e=Fr();return e&&e.activationStart||0},Oe=function(e,t){var r=Fr(),o="navigate";return fo>=0?o="back-forward-cache":r&&(document.prerendering||Bt()>0?o="prerender":document.wasDiscarded?o="restore":r.type&&(o=r.type.replace(/_/g,"-"))),{name:e,value:t===void 0?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:o}},mo=function(e,t,r){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var o=new PerformanceObserver(function(a){Promise.resolve().then(function(){t(a.getEntries())})});return o.observe(Object.assign({type:e,buffered:!0},r||{})),o}}catch(a){}},Fe=function(e,t,r,o){var a,l;return function(f){t.value>=0&&(f||o)&&((l=t.value-(a||0))||a===void 0)&&(a=t.value,t.delta=l,t.rating=function(m,g){return m>g[1]?"poor":m>g[0]?"needs-improvement":"good"}(t.value,r),e(t))}},po=function(e){requestAnimationFrame(function(){return requestAnimationFrame(function(){return e()})})},ho=function(e){document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"&&e()})},go=function(e){var t=!1;return function(){t||(e(),t=!0)}},De=-1,ao=function(){return document.visibilityState!=="hidden"||document.prerendering?1/0:0},Lt=function(e){document.visibilityState==="hidden"&&De>-1&&(De=e.type==="visibilitychange"?e.timeStamp:0,La())},so=function(){addEventListener("visibilitychange",Lt,!0),addEventListener("prerenderingchange",Lt,!0)},La=function(){removeEventListener("visibilitychange",Lt,!0),removeEventListener("prerenderingchange",Lt,!0)},vo=function(){return De<0&&(De=ao(),so(),Ut(function(){setTimeout(function(){De=ao(),so()},0)})),{get firstHiddenTime(){return De}}},Nr=function(e){document.prerendering?addEventListener("prerenderingchange",function(){return e()},!0):e()},co=[1800,3e3],yo=function(e,t){t=t||{},Nr(function(){var r,o=vo(),a=Oe("FCP"),l=mo("paint",function(f){f.forEach(function(m){m.name==="first-contentful-paint"&&(l.disconnect(),m.startTime<o.firstHiddenTime&&(a.value=Math.max(m.startTime-Bt(),0),a.entries.push(m),r(!0)))})});l&&(r=Fe(e,a,co,t.reportAllChanges),Ut(function(f){a=Oe("FCP"),r=Fe(e,a,co,t.reportAllChanges),po(function(){a.value=performance.now()-f.timeStamp,r(!0)})}))})};var Ua=function(e){var t=self.requestIdleCallback||self.setTimeout,r=-1;return e=go(e),document.visibilityState==="hidden"?e():(r=t(e),ho(e)),r};var uo=[2500,4e3],Or={},bo=function(e,t){t=t||{},Nr(function(){var r,o=vo(),a=Oe("LCP"),l=function(g){t.reportAllChanges||(g=g.slice(-1)),g.forEach(function(I){I.startTime<o.firstHiddenTime&&(a.value=Math.max(I.startTime-Bt(),0),a.entries=[I],r())})},f=mo("largest-contentful-paint",l);if(f){r=Fe(e,a,uo,t.reportAllChanges);var m=go(function(){Or[a.id]||(l(f.takeRecords()),f.disconnect(),Or[a.id]=!0,r(!0))});["keydown","click"].forEach(function(g){addEventListener(g,function(){return Ua(m)},{once:!0,capture:!0})}),ho(m),Ut(function(g){a=Oe("LCP"),r=Fe(e,a,uo,t.reportAllChanges),po(function(){a.value=performance.now()-g.timeStamp,Or[a.id]=!0,r(!0)})})}})},lo=[800,1800],Ba=function e(t){document.prerendering?Nr(function(){return e(t)}):document.readyState!=="complete"?addEventListener("load",function(){return e(t)},!0):setTimeout(t,0)},_o=function(e,t){t=t||{};var r=Oe("TTFB"),o=Fe(e,r,lo,t.reportAllChanges);Ba(function(){var a=Fr();a&&(r.value=Math.max(a.responseStart-Bt(),0),r.entries=[a],o(!0),Ut(function(){r=Oe("TTFB",0),(o=Fe(e,r,lo,t.reportAllChanges))(!0)}))})};re();function Ma(){yo(e=>{de("GameFCP",{value:e.value,rating:e.rating,navigationType:e.navigationType})}),bo(e=>{de("GameLCP",{value:e.value,rating:e.rating,navigationType:e.navigationType})}),_o(e=>{de("GameTTFB",{value:e.value,rating:e.rating,navigationType:e.navigationType})})}function $a(){Ke.on("onDocumentReady",e=>{Ke.emit("LifecycleEvent.onReady",{isLogin:!1}),A.mpType==="game"&&le.start(Date.now()-e)})}function To(){$a(),Ma()}To();
4
4
  /*! Bundled license information:
@@ -1,4 +1,4 @@
1
- var Ts=Object.create;var Ce=Object.defineProperty,ks=Object.defineProperties,Es=Object.getOwnPropertyDescriptor,Ss=Object.getOwnPropertyDescriptors,ws=Object.getOwnPropertyNames,Pe=Object.getOwnPropertySymbols,Is=Object.getPrototypeOf,wt=Object.prototype.hasOwnProperty,pr=Object.prototype.propertyIsEnumerable;var mr=(e,t,r)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,h=(e,t)=>{for(var r in t||(t={}))wt.call(t,r)&&mr(e,r,t[r]);if(Pe)for(var r of Pe(t))pr.call(t,r)&&mr(e,r,t[r]);return e},C=(e,t)=>ks(e,Ss(t));var ce=(e,t)=>{var r={};for(var n in e)wt.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Pe)for(var n of Pe(e))t.indexOf(n)<0&&pr.call(e,n)&&(r[n]=e[n]);return r};var f=(e,t)=>()=>(e&&(t=e(e=0)),t);var fr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),hr=(e,t)=>{for(var r in t)Ce(e,r,{get:t[r],enumerable:!0})},_s=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ws(t))!wt.call(e,s)&&s!==r&&Ce(e,s,{get:()=>t[s],enumerable:!(n=Es(t,s))||n.enumerable});return e};var gr=(e,t,r)=>(r=e!=null?Ts(Is(e)):{},_s(t||!e||!e.__esModule?Ce(r,"default",{value:e,enumerable:!0}):r,e));var g=(e,t,r)=>new Promise((n,s)=>{var o=c=>{try{a(r.next(c))}catch(l){s(l)}},i=c=>{try{a(r.throw(c))}catch(l){s(l)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,i);a((r=r.apply(e,t)).next())});function As(e){return!!(e!=null&&e.__nativeBuffers__)}function Ee(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!As(e))return e;let t=e.__nativeBuffers__;if(delete e.__nativeBuffers__,t)for(let r=0;r<t.length;r++){let n=t[r];if(n){let s;n.value?s=n.value:n.base64&&(s=Rs(n.base64)),typeof s!="undefined"&&s instanceof ArrayBuffer&&(e[n.key]=s)}}return e}function yr(e={},t=!1){let r=e,n=[];for(let[s,o]of Object.entries(r))if(o!==void 0&&o instanceof ArrayBuffer&&o.byteLength!==void 0){let i=t?{value:o,key:s}:{base64:xs(o),key:s};n.push(i),delete r[s]}return n.length>0&&(r.__nativeBuffers__=n),r}var Rs,xs,It=f(()=>{"use strict";Rs=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let s=0;s<r;s++)n[s]=t.charCodeAt(s);return n.buffer};xs=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let s=0;s<n;s++)t+=String.fromCharCode(r[s]);return btoa(t)}});function Ns(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function le(e){return typeof e=="string"}function B(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function kr(e){return typeof e=="object"&&Array.isArray(e)}function Ie(e){return e===!0||e===!1}function Os(e){return typeof e>"u"}function Fs(e){return Os(e)||e===null}function Er(e){return typeof e=="function"}function Sr(e){return B(e)&&Er(e.then)}function wr(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}function Ir(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(s,o){for(let i in o)if(Object.prototype.hasOwnProperty.call(o,i)){let a=s[i],c=o[i],l=r(a,c,i,s,o);l!==void 0?s[i]=l:vr(c)&&vr(a)?s[i]=n(h({},a),c):Array.isArray(c)&&Array.isArray(a)?s[i]=[...a,...c]:s[i]=c}return s}return n(e,t)}function vr(e){return e&&typeof e=="object"&&e.constructor===Object}function _r(e,t){if(Array.isArray(e))return e.concat(t)}function _e(e,t,r={}){let n=null,s,o,i,{leading:a=!1,trailing:c=!0}=r,l=()=>(i=e.apply(o,s),s=void 0,o=void 0,i),d=function(...m){s=m,o=this;let p=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,c&&!p&&l()},t),p)return l()};return d.cancel=()=>{n&&clearTimeout(n),n=null,s=o=void 0},d.flush=()=>{if(n)return clearTimeout(n),n=null,l()},d}function Us(e,t){return(...r)=>t(e,...r)}function Ue(e){return t=>Us(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(s){e(new Ct(`${s}`))}})}function Se(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function Qs(e){return new Promise(t=>Mr(e)(t))}function Mr(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function Ys(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new we(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}function Zs(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)eo(e[n],t[n])}function eo(e,t){if(le(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Er(t)){try{if(e instanceof t)return}catch(r){}if(!Fs(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")}}function N(){if(globalThis[At])return globalThis[At];let e=new Fe,t=new xt,r={registerCommand(n,s,o){e.registerCommand({id:n,handler:s,metadata:o})},executeCommand(n,...s){return t.executeCommand(n,...s)},excuteCommandSync(n,...s){return t.executeCommandThowErr(n,...s)}};return globalThis[At]=r,r}var br,Ps,Cs,Tr,se,Ds,Pt,de,Ar,Rr,Ct,xr,Pr,Cr,Nr,Or,Ae,De,Nt,J,Fr,Ms,Ot,Ls,Ft,Bs,js,Ne,Js,Hs,$s,Dr,Dt,Vs,Ks,qs,Ur,ee,x,Gs,zs,Oe,we,q,Rt,Ws,_t,Xs,te,Fe,xt,At,E=f(()=>{"use strict";br=Object.defineProperty,Ps=Object.getOwnPropertyDescriptor,Cs=(e,t)=>{for(var r in t)br(e,r,{get:t[r],enumerable:!0})},Tr=(e,t,r,n)=>{for(var s=n>1?void 0:n?Ps(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&br(t,r,s),s};se=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};Ds=(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))(Ds||{}),Pt=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},de=class extends Pt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Ar=class extends Pt{constructor(){super(...arguments),this.kind="USER_ERROR"}},Rr=class extends Ar{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Ct=class extends Ar{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},xr=class extends de{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Pr=class extends de{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},Cr=class extends de{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},Nr=class extends de{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Or=class extends de{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Ae=class extends Pt{constructor(e,t,r,n,s){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),s&&(this.priority=s)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},De=class extends de{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},Nt=class extends de{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};J={log:Se("log"),warn:Se("warn"),info:Se("info"),error:Se("error"),debug:Se("debug")};Object.assign(globalThis,{logger:J});Fr=Symbol.for("Jolibox.canIUseMap"),Ms={};globalThis[Fr]=Ms;Ot={get config(){return globalThis[Fr]}},Ls=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Ls||{}),Ft=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Ft||{}),Bs=(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))(Bs||{}),js=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),Ne={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")},Js=()=>Ne.isiOS?"iOS":Ne.isAndroid?"Android":Ne.isMac?"Mac":Ne.isFacebook?"Facebook":"PC",Hs="device_id",$s="advertising_id",Dr=e=>(localStorage.getItem(e)||localStorage.setItem(e,js()),localStorage.getItem(e)),Dt=()=>Dr(Hs),Vs=()=>Dr($s),Ks=e=>e.charAt(0).toUpperCase()+e.slice(1),qs=()=>{var t;let e=new URLSearchParams(window.location.search);return Ks((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},Ur=e=>{let t="JoliboxWebSDK",r=Js(),n=navigator.language,s=Dt(),o=Vs();return`${t} (${qs()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`},x=(ee=class{constructor(t){this.element=t,this.next=ee.Undefined,this.prev=ee.Undefined}},ee.Undefined=new ee(void 0),ee),Gs=class{constructor(){this._first=x.Undefined,this._last=x.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===x.Undefined}clear(){let e=this._first;for(;e!==x.Undefined;){let t=e.next;e.prev=x.Undefined,e.next=x.Undefined,e=t}this._first=x.Undefined,this._last=x.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new x(e);if(this._first===x.Undefined)this._first=r,this._last=r;else if(t){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==x.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==x.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==x.Undefined&&e.next!==x.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===x.Undefined&&e.next===x.Undefined?(this._first=x.Undefined,this._last=x.Undefined):e.next===x.Undefined?(this._last=this._last.prev,this._last.next=x.Undefined):e.prev===x.Undefined&&(this._first=this._first.next,this._first.prev=x.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==x.Undefined;)yield e.element,e=e.next}},zs=0,Oe=class{constructor(e){this.value=e,this.id=zs++}},we=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 Oe&&(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 s,o,i,a,c,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let n=new Oe(t);this._listeners?this._listeners instanceof Oe?this._listeners=[this._listeners,n]:this._listeners.push(n):((o=(s=this.options)==null?void 0:s.onWillAddFirstListener)==null||o.call(s,this),this._listeners=n,(a=(i=this.options)==null?void 0:i.onDidFirstListener)==null||a.call(i,this)),(l=(c=this.options)==null?void 0:c.onDidAddListener)==null||l.call(c,this),this._size++}),this._event}_deliver(e,t){var n;if(!e)return;let r=((n=this.options)==null?void 0:n.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(s){r(s)}}fire(e){this._listeners&&(this._listeners instanceof Oe?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},q=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var o;let r=(o=this.listeners.get(e))!=null?o:new we,n=i=>t(...i.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let s=this.cachedEventQueue.get(e);if(s)for(;s.size>0;)r.fire(h({event:e},s.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Gs,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},Rt={};Cs(Rt,{None:()=>Ws,filter:()=>Ys,once:()=>Mr,toPromise:()=>Qs});Ws=()=>{console.log("[Jolibox SDK] None Event")};_t=Symbol.for("Jolibox.hostEmitter"),Xs=()=>{let e=new q;return globalThis[_t]||(globalThis[_t]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[_t]},te=Xs();Fe=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new we,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return Zs(s,r),n(...s)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};Fe=Tr([wr],Fe);xt=class{constructor(){this._onWillExecuteCommand=new we,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new we,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Fe,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Ns(3e4)),this._starActivation}executeCommand(e,...t){return g(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Rt.toPromise(Rt.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}}};xt=Tr([wr],xt);At=Symbol.for("Jolibox.commands")});function M(e,t={}){Ut.emit("ERROR_REPORT",{error:e,options:t})}var Ut,ue,G=f(()=>{"use strict";E();E();Ut=new q,ue=new q;M.debounce=_e(M,50,{leading:!0})});function Me(e,t){return`[${e}]:${t}`}var me,Mt,oe=f(()=>{"use strict";G();E();G();me=(e,t)=>{var r,n;return new Ae((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Mt=e=>new Rr(e)});var pe,Lr,Br,jr,Le,Be=f(()=>{"use strict";pe="custom_event_",Lr=[],Br=[],jr=["env","createRequestTask","login"],Le="__batch_event__"});function Hr(e,t){Jr||(Lt=new fe({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),Bt=new fe({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),jt=new fe({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),t("onJoliboxEnterBackground",()=>{Lt.flush(),Bt.flush(),jt.flush()}),Jr=!0);function r(s){var T,y;let{method:o,args:i,startTime:a,isForeground:c,errMsg:l=`${o}:fail no errMsg`,errNo:d=0,__timing:m={receiveJSInvoke:0,invokeCallback:0}}=s,{receiveJSInvoke:p,invokeCallback:b}=m,_=(y=(T=l.match(/\S:(\S+)\s?/))==null?void 0:T[1])!=null?y:"fail";Lt.report({status:_,method:n(o,i),errNo:`${d}`,errMsg:l,isForeground:c,duration:Date.now()-a}),a&&p&&b&&(Bt.report({status:_,method:o,isForeground:c,duration:Number((p-a).toFixed(3))}),jt.report({status:_,method:o,isForeground:c,duration:Number((Date.now()-b).toFixed(3))}))}function n(s,o){return(s==="callHostMethod"||s==="callHostMethodSync")&&o!=null&&o.method?`${s}-${o.method}`:s}return r}var to,fe,Jr,Lt,Bt,jt,Jt=f(()=>{"use strict";E();to=e=>e==="pv"?e:"default",fe=class{constructor(t){this.interval=30;this.lastReportTime=0;this.cache={};let{reporter:r,interval:n=30,eventName:s,tagNameOrder:o,metricName:i,type:a}=t;this.reporter=r,this.interval=n,this.eventName=s,this.tagNameOrder=o,this.metricName=i,this.type=to(a)}report(t){this.type==="pv"?this.addPVPoint(t):this.addPoint(t),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(t){if(Object.keys(this.cache).length){if(t){this.reporter(this.processPoints(this.cache)),this.clearPoints();return}this.lastReportTime=this.lastReportTime||Date.now(),Date.now()-this.lastReportTime>=this.interval*1e3&&(this.reporter(this.processPoints(this.cache)),this.clearPoints(),this.lastReportTime=Date.now())}}addPoint(t){let r=(n,s,o,i)=>{let a=s.shift();if(a){let c=i[a];n[c]||(n[c]={}),r(n[c],s,o,i)}else n[o]||(n[o]=[]),n[o].push(i[o])};r(this.cache,[...this.tagNameOrder],this.metricName,t)}addPVPoint(t){let r=(s,o,i,a)=>{let c=o.shift();if(!c&&B(a))throw new De(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(c){let l=[];if(B(a))l.push(...Object.keys(a));else if(le(a)){if(o.length>0)throw new De(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);l.push(a)}else throw new De(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);l.forEach(d=>{s[d]||(s[d]={});let m=B(a)?a[d]:a;r(s[d],[...o],i,m)})}else s[i]?s[i]++:s[i]=1},n={point:t,metricName:this.metricName,tagNameOrder:this.tagNameOrder};r(this.cache,[...this.tagNameOrder],this.metricName,t)}processPoints(t){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:t}}clearPoints(){this.cache={}}},Jr=!1});function Vr(e,t){let r=0,n=!0,s=new Map,o=Hr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,Ht.forEach(p=>g(this,[p],function*({method:l,args:d,resolve:m}){let b=yield a(l,d);m(b)})),Ht.length=0});let i=(l,d)=>{let m=s.get(Number(l));if(!m)return;let p=Ee(d);m(p),s.delete(Number(l))},a=(l,d)=>{var U,I;let m=Date.now(),p=`${n}`;r+=1;let b=new se;if(s.set(r,b.resolve),!n&&Br.includes(l))return new Promise(A=>{Ht.push({method:l,args:d,resolve:A})});let T=C(h({},{method:l,startTime:m,args:d,isForeground:p}),{invokeType:"js-bridge"}),y=!ro&&Lr.includes(l),S=yr(d,y),R=y?S:JSON.stringify(S),w;if(l.endsWith("Sync")||jr.includes(l)?w=(U=e.call)==null?void 0:U.call(e,l,S,r):typeof R=="string"?w=e.invoke(l,R,r):w=(I=e.call)==null?void 0:I.call(e,l,R,r),w){try{typeof w=="string"&&(w=JSON.parse(w)),w=Ee(w)}catch(A){J.error(A)}return s.delete(r),w.errorCode&&(w.errorCode=Me(l,w.errorCode)),o(h(h({},T),w)),w}return l.endsWith("Sync")&&s.delete(r),b.promise.then(A=>(A.errorCode&&(A.errorCode=Me(l,A.errorCode)),o(h(h({},T),A)),A))};return{invokeNative:a,applyNative:(l,d)=>{let m=a(l,d);return Sr(m)?m.then(p=>$r(l,p)):$r(l,m)},invokeHandler:i}}function $r(e,t){if(!B(t)){J.warn(`[Jolibox SDK]${e} no response value`);return}let a=t,{errMsg:r,errNo:n,errorType:s,errorCode:o}=a,i=ce(a,["errMsg","errNo","errorType","errorCode"]);if(r&&r!==`${e}:ok`)throw new Cr(r,n,s,o);return i}var Ht,ro,Kr=f(()=>{"use strict";It();E();oe();Be();Jt();Ht=[],ro=!1});function qr(e){let t=new q,r=new q,n=new fe({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}});return t.on("onJoliboxEnterBackground",()=>{n.flush()}),{onNative:t.on.bind(t),offNative:t.off.bind(t),subscribe:r.on.bind(r),unsubscribe:r.off.bind(r),subscribeHandler(s,o,i){let a=Ee(o),c;if(a.__extra){c=a.params;let{type:l,startTime:d}=a.__extra;n.report({type:l,event:s,duration:Date.now()-d})}else c=a;if(s===Le){c.forEach(d=>{let[m,p]=d;try{r.emit(m.slice(pe.length),p,i)}catch(b){}});return}if(s.startsWith(pe)){r.emit(s.slice(pe.length),c,i);return}t.emit(s,c,i)}}}var Gr=f(()=>{"use strict";E();It();Jt();Be()});function zr(e){let t=new Map,r;return(s,o,i,a)=>{if(a){let l=i?[i]:"*";e.publish(`${pe}${s}`,o,l);return}r||(r=Promise.resolve().then(()=>{t.forEach((l,d)=>{try{let m=d?[d]:"*";e.publish(Le,l,m)}catch(m){}}),r=void 0,t.clear()}));let c=t.get(i);c||(c=[],t.set(i,c)),c.push([`${pe}${s}`,o])}}var Wr=f(()=>{"use strict";Be()});function $t(e){let{subscribeHandler:t,onNative:r,offNative:n,subscribe:s,unsubscribe:o}=qr(e),{invokeNative:i,invokeHandler:a,applyNative:c}=Vr(e,r),l=zr(e);return{invokeHandler:a,subscribeHandler:t,applyNative:c,invokeNative:i,onNative:r,offNative:n,publish:l,subscribe:s,unsubscribe:o}}var Qr=f(()=>{"use strict";Kr();Gr();Wr()});var Yr=f(()=>{"use strict"});var Xr=f(()=>{"use strict";Qr();Yr()});function ge(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var je=f(()=>{"use strict"});var ie,z,Zr,en=f(()=>{"use strict";E();je();G();z={trigger(){},exit(){return Promise.resolve(!1)},onReady(e){z.trigger=e},doExit(e){z.exit=e}},Zr=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)M(new Pr("native env failed"));else{let{data:t}=JSON.parse(e);return t!=null?t:void 0}};if(window.webkit){let e=window.webkit.messageHandlers,t=(s="")=>{z.trigger(),e.onDocumentReady.postMessage({path:s})};ie={onDocumentReady:t,doExit:s=>g(void 0,null,function*(){let o=yield z.exit();e.doExit.postMessage({uuid:s,shouldInterrupt:o})}),invoke(s,o,i){e.invoke.postMessage({event:s,paramsString:o,callbackId:i})},publish(s,o,i){let a=ge(o,"joliboxJSCore");window.prompt("publish",JSON.stringify({event:s,paramsString:JSON.stringify(a),webviewIds:i}))},call(s,o,i){let a=window.prompt("invoke",JSON.stringify({event:s,paramsString:JSON.stringify(o),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:Zr};globalThis.joliboxJSCore=h({},n)}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(s="")=>{z.trigger(),e.onDocumentReady(JSON.stringify({path:s}))};ie={onDocumentReady:t,invoke(s,o,i){e.invoke(JSON.stringify({event:s,paramsString:o,callbackId:i}))},doExit:s=>g(void 0,null,function*(){let o=yield z.exit();e.doExit(JSON.stringify({uuid:s,shouldInterrupt:o}))}),publish(s,o,i){let a=ge(o,"joliboxJSCore");e.publish({event:s,paramsString:JSON.stringify(a),webviewIds:i})},call(s,o,i){let a=window.prompt("invoke",JSON.stringify({event:s,paramsString:JSON.stringify(o),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:Zr};globalThis.joliboxJSCore=h({},n)}});function Vt(){globalThis.onmessage=function(e){e.data==="msg:setup"&&([ye]=e.ports,ye.onmessage=function(t){let r=JSON.parse(t.data);r[0]==="publish"?globalThis.ttJSBridge.subscribeHandler(r[1],r[2]):r[0]==="invoke"&&globalThis.ttJSBridge.invokeHandler(r[1],r[2])},ye.publish=function(t,r){let n=ge(r,"messagePort");ye.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},ye.postMessage("msg:setup:ok"))}}var ye,tn=f(()=>{"use strict";je()});var Je=f(()=>{"use strict";en();tn();je()});var nn,no,sn,rn,H,P,Q,Fa,so,on,Da,Ua,$=f(()=>{"use strict";Xr();Je();oe();E();Je();nn=ie;if(!nn)throw new Nr("No joliboxJScore is found, native bridge not found.");Vt();no=h({},nn),sn=$t(no),{invokeHandler:rn}=sn,{applyNative:H,invokeNative:P,onNative:Q,offNative:Fa,subscribeHandler:so,publish:on,subscribe:Da,unsubscribe:Ua}=sn;globalThis.joliboxJSBridge={callHandler:rn,invokeHandler:rn,subscribeHandler:so}});var Kt,qt,an,cn,ln=f(()=>{"use strict";E();G();Kt=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch(s){return{}}},qt=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},an=e=>{var t;try{let s=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(s!=null&&s.length){let[o,i,a]=s;return{headerJson:Kt(o),payloadJson:Kt(i),signature:Kt(a)}}else throw"joli_source is missing"}catch(r){return M(new xr(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},cn=e=>{let{headerJson:t,payloadJson:r,signature:n}=e,s=qt(t),o=qt(r),i=qt(n);return`${s}.${o}.${i}`}});var oo,He,dn,Gt=f(()=>{"use strict";E();oo="1.1.11-beta.2",He=()=>oo,dn=()=>{let e=He();return`${Ur(e)}`}});var io,un,zt,mn,L,ao,v,K=f(()=>{"use strict";E();ln();Gt();E();io={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:Dt(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:He()},schema:window.location.href,platform:"h5"},zt=(un=globalThis.joliboxJSCore)==null?void 0:un.env,L=Object.assign({},(mn=zt==null?void 0:zt())!=null?mn:io),ao=()=>{var p,b,_,T,y,S,R,w,U;let{payloadJson:e,headerJson:t,signature:r}=L.schema.length?an(L.schema):{},n=`${L.deviceInfo.did}-${new Date().getTime()}`,o=new URL(L.schema.length?L.schema:window.location.href).searchParams,i=(_=(b=(p=o.get("mpId"))!=null?p:o.get("appId"))!=null?b:o.get("gameId"))!=null?_:"",a=(S=(y=(T=L.clientSessionId)!=null?T:e==null?void 0:e.sessionId)!=null?y:o.get("sessionId"))!=null?S:n,c=!!((R=e==null?void 0:e.testAdsMode)!=null?R:o.get("testAdsMode")==="true"),l=(U=(w=e==null?void 0:e.joliboxEnv)!=null?w:o.get("joliboxEnv"))!=null?U:"production",d=l==="staging",m=t==null?void 0:t.channel;return{get testMode(){return d},get testAdsMode(){return c},get joliboxEnv(){return l},get joliSource(){var I;return(I=o.get("joliSource"))!=null?I:null},get mpId(){var I;return(I=i!=null?i:e==null?void 0:e.id)!=null?I:""},get mpVersion(){var I;return(I=t==null?void 0:t.ver)!=null?I:He()},get mpType(){var I,A;return(A=(I=t==null?void 0:t.__mpType)!=null?I:e==null?void 0:e.__mpType)!=null?A:"game"},get platform(){var I;return(I=L.platform)!=null?I:L.deviceInfo.platform},get deviceInfo(){return L.deviceInfo},get sdkInfo(){return L.sdkInfo},get hostInfo(){return L.hostInfo},get hostUserInfo(){return L.hostUserInfo},get sessionId(){var I,A;return(A=(I=L.clientSessionId)!=null?I:a)!=null?A:n},get channel(){return m},get webviewId(){var I;return(I=L.webviewId)!=null?I:-1},get shouldInterupt(){return e==null?void 0:e.__shouldInterupt},get from(){return e==null?void 0:e.__from},onEnvConfigChanged:I=>{Ir(L,I,_r)},encodeJoliSourceQuery:I=>{var A;return t&&r?cn({headerJson:t,payloadJson:h(h({},e),I),signature:r}):(A=o.get("joliSource"))!=null?A:""}}},v=ao()});var Wt,fn,co,lo,pn,uo,hn=f(()=>{"use strict";E();G();K();E();Wt=!1,fn=(e,t)=>e==null?!1:t in e,co=e=>fn(e,"kind"),lo=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},pn=(e,t={},r)=>{var o,i,a;let n={user_id:(i=(o=v.hostUserInfo)==null?void 0:o.uid)!=null?i:"",device_id:(a=v.deviceInfo.did)!=null?a:"",timestamp:Date.now(),tag:lo(e.name)},s=C(h({},n),{env:t.environment,isFromUser:r});r?ue.emit("GLOBAL_USER_ERROR",e,s):ue.emit("GLOBAL_ERROR",e,s)},uo=e=>fn(e,"kind")&&e.kind==="USER_ERROR";Ut.on("ERROR_REPORT",({error:e,options:t})=>{if(Wt)return;Wt=!0;let r=co(e)&&e.raw?e.raw:e;try{let n=uo(e);pn(e,t,n)}catch(n){let s=n instanceof Error?n.message:String(n),o=new Nt(`${s}, origin error: ${r.message}`);J.error(o),pn(new Nt(o.message),{environment:t.environment},!1)}finally{Wt=!1}})});var gn=f(()=>{"use strict";hn();oe();E();$();ue.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};P("trackAsync",{event:"reportJsError",data:r})});ue.on("GLOBAL_USER_ERROR",(e,t)=>{J.log("UserError",e,t)})});var Qt=f(()=>{"use strict"});function yn(e,t){let r=(n,s,o)=>{let i=C(h({tag:n},t),{extra:h({},s)});n=="globalJsError"?M(new Or(JSON.stringify(i))):e("systemLog",i,o)};return r.debounce=_e(r,500,{leading:!0}),r}function vn(e){let t=(r,n,s)=>{var a;let o=(a=s&&JSON.stringify(s))!=null?a:0,i={speed_value_type:r,total_duration:n};o&&Object.assign(i,{extra:o}),e("joliboxSpeedAnalysis",i)};return t.debounce=_e(t,500,{leading:!0}),t}var bn=f(()=>{"use strict";E();E();G()});function Tn(e,t){let r=yn(e,t),n=vn(r);return{track:r,trackPerformance:n}}var kn=f(()=>{"use strict";bn()});var En=f(()=>{"use strict";K();E();E()});var Sn=f(()=>{"use strict";kn();Qt();En()});var $e,wn=f(()=>{"use strict";$e=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,s,o=!1,i=0,a=()=>{if(!o)return;let b=Date.now(),_=b-r;_>=this.interval&&(this.visible&&(i+=_,t(i)),r=b),n=requestAnimationFrame(a)},c=()=>{d(),r=Date.now(),s=window.setInterval(()=>{if(!o)return;let b=Date.now();b-r>=this.interval&&(r=b)},this.interval)},l=()=>{m(),r=Date.now(),n=requestAnimationFrame(a)},d=()=>{n&&(cancelAnimationFrame(n),n=0)},m=()=>{s&&(clearInterval(s),s=0)};this.eventEmitter.on("visible",b=>{o&&(console.log("visible",b),b?l():c())});let p=this.visible;return{start(){o||(o=!0,p?l():c())},stop(){o=!1,d(),m()}}}}});var Yt=f(()=>{"use strict"});function _n(e,t,r){let{response:n,startTime:s,endTime:o,requestFrom:i}=r,{errMsg:a="",profile:c={}}=n,d={duration:o-s,request_type:e,url:t.split("?")[0],result:r.state,error_msg:r.state==="fail"?a:"",socket_reused:c.socketReused?1:0,request_from:i};(i==="public"&&In<po||i==="inner")&&(d.joli_request_number=In++,setTimeout(()=>{V("joliboxNetRequestResult",d)},500))}var In,po,An=f(()=>{"use strict";Yt();ae();In=0,po=10});function Ve(e,t,r){var c,l,d;let n=new Map,s=(c=r==null?void 0:r.baseUrl)!=null?c:"https://api.jolibox.com",o=(l=r==null?void 0:r.type)!=null?l:"public",i=(d=r==null?void 0:r.defaultHeaders)!=null?d:{};return Q("onRequestTaskStateChange",m=>{if(typeof m.requestTaskId!="string")return;let p=n.get(m.requestTaskId);if(p)if(m.state==="success"){let b=m,{requestTaskId:T,state:y}=b,S=ce(b,["requestTaskId","state"]);p.resolve(S),n.delete(T)}else if(m.state==="fail"){let _=m,{requestTaskId:T,state:y}=_,S=ce(_,["requestTaskId","state"]);p.reject(S),n.delete(T)}else J.warn("onRequestTaskStateChange unknown event",m)}),te.on("onLoginComplete",({isLogin:m,token:p})=>{m&&p&&(i["X-JOLI-TOKEN"]=p)}),(b,..._)=>g(this,[b,..._],function*(m,p={}){let T=Date.now(),y=fo(m,C(h({},p),{baseUrl:s})),{method:S="GET",responseType:R="text",dataType:w="json",timeout:U,enableCache:I=!1,appendHostCookie:A=!0}=p,ke=Object.assign({"content-type":"application/json"},i,p.header),ne={url:y,method:S,header:ke,enableCache:I,responseType:R,appendHostCookie:A};if(S=="POST"||S=="PUT"){let W=go(p.data,ke["content-type"]);ne.data=W}U&&Object.assign(ne,{timeout:U});let{data:{requestTaskId:St}}=P(e,ne);if(typeof St!="string")throw me({code:-1,msg:"requestTaskId is not a string"});let ur=(W,Z)=>{_n("request",y,{state:W,startTime:T,endTime:Date.now(),params:ne,response:Z,requestId:St,requestFrom:o=="public"?"public":"inner"})},{resolve:fs,reject:hs,promise:gs}=new se;n.set(St,{resolve:fs,reject:hs});try{let W=yield gs;ur("success",W);let{data:Z}=W;return w==="json"&&typeof Z=="string"&&(Z=ho(Z)),{url:y,timeout:U,method:S,response:C(h({},W),{data:Z})}}catch(W){let Z=W;if(B(Z)){let{errMsg:xe,prefetchDetail:ys,isPrefetch:vs,errNo:bs}=Z;le(xe)&&(ur("fail",{errMsg:xe,isPrefetch:vs,prefetchDetail:ys}),M(me({code:-1,msg:xe},{errNo:bs,errMsg:xe})))}throw W}})}function ho(e){try{return JSON.parse(e.trim())}catch(t){return e}}function go(e,t="application/json"){let r=t.toLowerCase();return e===void 0?"":typeof e=="string"||e instanceof ArrayBuffer?e:r.includes("application/x-www-form-urlencoded")||r.includes("application/json")||typeof e=="object"?JSON.stringify(e):String(e)}var fo,Xt=f(()=>{"use strict";E();An();Yt();$();G();oe();fo=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t==null?void 0:t.query,s=new URLSearchParams(r).toString();return t!=null&&t.baseUrl?`${t.baseUrl}${e}${s?`?${s}`:""}`:`${e}${s?`?${s}`:""}`}});var Zt,Rn,Y,Ke=f(()=>{"use strict";Gt();Xt();K();Zt={"x-user-agent":dn()};(Rn=v.hostUserInfo)!=null&&Rn.token&&(Zt["x-joli-token"]=v.hostUserInfo.token);v.joliSource&&(Zt["x-joli-source"]=v.joliSource);Y=Ve("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:v.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:Zt})});var qe,xn=f(()=>{"use strict";K();wn();Ke();$();qe=class extends $e{constructor(t,r,n){super(r,n),this.gameId=v.mpId,this.sessionId=v.sessionId,this.track=t}reporter(t){return g(this,null,function*(){let{event:r,params:n}=t,s=[];s.push(Y("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:h({gameId:this.gameId,sessionId:this.sessionId},n)}})),yield Promise.all(s)})}reportToNative(t){return g(this,null,function*(){let{event:r,params:n}=t;yield H("userTrackAsync",{event:r,params:h({},n),gameId:this.gameId})})}tracker(t,r=null){this.track(t,r)}}});var Fn={};hr(Fn,{nativeTaskEmitter:()=>Re,taskTracker:()=>j,track:()=>V,trackPerformance:()=>Nn});var yo,Pn,Cn,V,Nn,On,Re,j,ae=f(()=>{"use strict";gn();E();Qt();Sn();K();xn();$();yo=(e,t,r)=>{var i,a;let n=t,s=B(n.extra)?n.extra:le(n.extra)?JSON.parse(n.extra):{},o=C(h({},s),{mp_id:(i=n.mp_id)!=null?i:"",mp_version:(a=n.mp_version)!=null?a:""});P("trackAsync",{event:e,data:o,webviewId:r})},{track:V,trackPerformance:Nn}=Tn(yo,{type:Ft.AppSDK,platform:"native",jssdk_version:(Cn=(Pn=v.sdkInfo)==null?void 0:Pn.jssdkVersion)!=null?Cn:"1.0.0",mp_id:v.mpId,mp_version:v.mpVersion}),On=N();On.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{Nn(e,t,r)});On.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{V(e,t)});Re=new q,j=new qe(V,Re)});function Dn(){let e=null,t=window.fetch,r=()=>{e=document.createElement("style"),e.setAttribute("data-jolibox-sdk","default-styles");let o=`
1
+ var Io=Object.create;var Ne=Object.defineProperty,_o=Object.defineProperties,Ro=Object.getOwnPropertyDescriptor,Ao=Object.getOwnPropertyDescriptors,xo=Object.getOwnPropertyNames,Ce=Object.getOwnPropertySymbols,Po=Object.getPrototypeOf,It=Object.prototype.hasOwnProperty,fr=Object.prototype.propertyIsEnumerable;var pr=(e,t,r)=>t in e?Ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,h=(e,t)=>{for(var r in t||(t={}))It.call(t,r)&&pr(e,r,t[r]);if(Ce)for(var r of Ce(t))fr.call(t,r)&&pr(e,r,t[r]);return e},P=(e,t)=>_o(e,Ao(t));var ce=(e,t)=>{var r={};for(var n in e)It.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ce)for(var n of Ce(e))t.indexOf(n)<0&&fr.call(e,n)&&(r[n]=e[n]);return r};var f=(e,t)=>()=>(e&&(t=e(e=0)),t);var hr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),gr=(e,t)=>{for(var r in t)Ne(e,r,{get:t[r],enumerable:!0})},Co=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of xo(t))!It.call(e,o)&&o!==r&&Ne(e,o,{get:()=>t[o],enumerable:!(n=Ro(t,o))||n.enumerable});return e};var yr=(e,t,r)=>(r=e!=null?Io(Po(e)):{},Co(t||!e||!e.__esModule?Ne(r,"default",{value:e,enumerable:!0}):r,e));var y=(e,t,r)=>new Promise((n,o)=>{var s=c=>{try{a(r.next(c))}catch(l){o(l)}},i=c=>{try{a(r.throw(c))}catch(l){o(l)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,i);a((r=r.apply(e,t)).next())});function No(e){return!!(e!=null&&e.__nativeBuffers__)}function Ee(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!No(e))return e;let t=e.__nativeBuffers__;if(delete e.__nativeBuffers__,t)for(let r=0;r<t.length;r++){let n=t[r];if(n){let o;n.value?o=n.value:n.base64&&(o=Oo(n.base64)),typeof o!="undefined"&&o instanceof ArrayBuffer&&(e[n.key]=o)}}return e}function vr(e={},t=!1){let r=e,n=[];for(let[o,s]of Object.entries(r))if(s!==void 0&&s instanceof ArrayBuffer&&s.byteLength!==void 0){let i=t?{value:s,key:o}:{base64:Fo(s),key:o};n.push(i),delete r[o]}return n.length>0&&(r.__nativeBuffers__=n),r}var Oo,Fo,_t=f(()=>{"use strict";Oo=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=t.charCodeAt(o);return n.buffer};Fo=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let o=0;o<n;o++)t+=String.fromCharCode(r[o]);return btoa(t)}});function Mo(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function le(e){return typeof e=="string"}function B(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Er(e){return typeof e=="object"&&Array.isArray(e)}function Ie(e){return e===!0||e===!1}function Lo(e){return typeof e>"u"}function Bo(e){return Lo(e)||e===null}function Sr(e){return typeof e=="function"}function wr(e){return B(e)&&Sr(e.then)}function Ir(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}function _r(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(o,s){for(let i in s)if(Object.prototype.hasOwnProperty.call(s,i)){let a=o[i],c=s[i],l=r(a,c,i,o,s);l!==void 0?o[i]=l:br(c)&&br(a)?o[i]=n(h({},a),c):Array.isArray(c)&&Array.isArray(a)?o[i]=[...a,...c]:o[i]=c}return o}return n(e,t)}function br(e){return e&&typeof e=="object"&&e.constructor===Object}function Rr(e,t){if(Array.isArray(e))return e.concat(t)}function _e(e,t,r={}){let n=null,o,s,i,{leading:a=!1,trailing:c=!0}=r,l=()=>(i=e.apply(s,o),o=void 0,s=void 0,i),u=function(...m){o=m,s=this;let p=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,c&&!p&&l()},t),p)return l()};return u.cancel=()=>{n&&clearTimeout(n),n=null,o=s=void 0},u.flush=()=>{if(n)return clearTimeout(n),n=null,l()},u}function Jo(e,t){return(...r)=>t(e,...r)}function Me(e){return t=>Jo(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(o){e(new Re(`${o}`))}})}function Se(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function ts(e){return new Promise(t=>Lr(e)(t))}function Lr(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function rs(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new we(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}function os(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ss(e[n],t[n])}function ss(e,t){if(le(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Sr(t)){try{if(e instanceof t)return}catch(r){}if(!Bo(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")}}function O(){if(globalThis[At])return globalThis[At];let e=new De,t=new Pt,r={registerCommand(n,o,s){e.registerCommand({id:n,handler:o,metadata:s})},executeCommand(n,...o){return t.executeCommand(n,...o)},excuteCommandSync(n,...o){return t.executeCommandThowErr(n,...o)}};return globalThis[At]=r,r}var Tr,Do,Uo,kr,Q,jo,Ct,de,Ar,xr,Re,Pr,Cr,Nr,Or,Fr,Ae,Ue,Nt,H,Dr,$o,Ot,Ho,Ft,Vo,Ko,Oe,qo,Go,zo,Ur,Dt,Wo,Qo,Yo,Mr,te,C,Xo,Zo,Fe,we,q,xt,es,Rt,ns,re,De,Pt,At,E=f(()=>{"use strict";Tr=Object.defineProperty,Do=Object.getOwnPropertyDescriptor,Uo=(e,t)=>{for(var r in t)Tr(e,r,{get:t[r],enumerable:!0})},kr=(e,t,r,n)=>{for(var o=n>1?void 0:n?Do(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&Tr(t,r,o),o};Q=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};jo=(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))(jo||{}),Ct=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},de=class extends Ct{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Ar=class extends Ct{constructor(){super(...arguments),this.kind="USER_ERROR"}},xr=class extends Ar{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Re=class extends Ar{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Pr=class extends de{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Cr=class extends de{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},Nr=class extends de{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},Or=class extends de{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Fr=class extends de{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Ae=class extends Ct{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},Ue=class extends de{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},Nt=class extends de{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};H={log:Se("log"),warn:Se("warn"),info:Se("info"),error:Se("error"),debug:Se("debug")};Object.assign(globalThis,{logger:H});Dr=Symbol.for("Jolibox.canIUseMap"),$o={};globalThis[Dr]=$o;Ot={get config(){return globalThis[Dr]}},Ho=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Ho||{}),Ft=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Ft||{}),Vo=(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))(Vo||{}),Ko=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),Oe={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")},qo=()=>Oe.isiOS?"iOS":Oe.isAndroid?"Android":Oe.isMac?"Mac":Oe.isFacebook?"Facebook":"PC",Go="device_id",zo="advertising_id",Ur=e=>(localStorage.getItem(e)||localStorage.setItem(e,Ko()),localStorage.getItem(e)),Dt=()=>Ur(Go),Wo=()=>Ur(zo),Qo=e=>e.charAt(0).toUpperCase()+e.slice(1),Yo=()=>{var t;let e=new URLSearchParams(window.location.search);return Qo((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},Mr=e=>{let t="JoliboxWebSDK",r=qo(),n=navigator.language,o=Dt(),s=Wo();return`${t} (${Yo()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},C=(te=class{constructor(t){this.element=t,this.next=te.Undefined,this.prev=te.Undefined}},te.Undefined=new te(void 0),te),Xo=class{constructor(){this._first=C.Undefined,this._last=C.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===C.Undefined}clear(){let e=this._first;for(;e!==C.Undefined;){let t=e.next;e.prev=C.Undefined,e.next=C.Undefined,e=t}this._first=C.Undefined,this._last=C.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new C(e);if(this._first===C.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!==C.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==C.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==C.Undefined&&e.next!==C.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===C.Undefined&&e.next===C.Undefined?(this._first=C.Undefined,this._last=C.Undefined):e.next===C.Undefined?(this._last=this._last.prev,this._last.next=C.Undefined):e.prev===C.Undefined&&(this._first=this._first.next,this._first.prev=C.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==C.Undefined;)yield e.element,e=e.next}},Zo=0,Fe=class{constructor(e){this.value=e,this.id=Zo++}},we=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 Fe&&(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 o,s,i,a,c,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let n=new Fe(t);this._listeners?this._listeners instanceof Fe?this._listeners=[this._listeners,n]:this._listeners.push(n):((s=(o=this.options)==null?void 0:o.onWillAddFirstListener)==null||s.call(o,this),this._listeners=n,(a=(i=this.options)==null?void 0:i.onDidFirstListener)==null||a.call(i,this)),(l=(c=this.options)==null?void 0:c.onDidAddListener)==null||l.call(c,this),this._size++}),this._event}_deliver(e,t){var n;if(!e)return;let r=((n=this.options)==null?void 0:n.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(o){r(o)}}fire(e){this._listeners&&(this._listeners instanceof Fe?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},q=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var s;let r=(s=this.listeners.get(e))!=null?s:new we,n=i=>t(...i.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let o=this.cachedEventQueue.get(e);if(o)for(;o.size>0;)r.fire(h({event:e},o.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Xo,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},xt={};Uo(xt,{None:()=>es,filter:()=>rs,once:()=>Lr,toPromise:()=>ts});es=()=>{console.log("[Jolibox SDK] None Event")};Rt=Symbol.for("Jolibox.hostEmitter"),ns=()=>{let e=new q;return globalThis[Rt]||(globalThis[Rt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[Rt]},re=ns();De=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new we,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 os(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}};De=kr([Ir],De);Pt=class{constructor(){this._onWillExecuteCommand=new we,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new we,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new De,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Mo(3e4)),this._starActivation}executeCommand(e,...t){return y(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),xt.toPromise(xt.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}}};Pt=kr([Ir],Pt);At=Symbol.for("Jolibox.commands")});function M(e,t={}){Ut.emit("ERROR_REPORT",{error:e,options:t})}var Ut,ue,G=f(()=>{"use strict";E();E();Ut=new q,ue=new q;M.debounce=_e(M,50,{leading:!0})});function Le(e,t){return`[${e}]:${t}`}var me,Mt,se=f(()=>{"use strict";G();E();G();me=(e,t)=>{var r,n;return new Ae((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Mt=e=>new xr(e)});var pe,Br,jr,Jr,Be,je=f(()=>{"use strict";pe="custom_event_",Br=[],jr=[],Jr=["env","createRequestTask","login"],Be="__batch_event__"});function Hr(e,t){$r||(Lt=new fe({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),Bt=new fe({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),jt=new fe({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),t("onJoliboxEnterBackground",()=>{Lt.flush(),Bt.flush(),jt.flush()}),$r=!0);function r(o){var T,v;let{method:s,args:i,startTime:a,isForeground:c,errMsg:l=`${s}:fail no errMsg`,errNo:u=0,__timing:m={receiveJSInvoke:0,invokeCallback:0}}=o,{receiveJSInvoke:p,invokeCallback:b}=m,R=(v=(T=l.match(/\S:(\S+)\s?/))==null?void 0:T[1])!=null?v:"fail";Lt.report({status:R,method:n(s,i),errNo:`${u}`,errMsg:l,isForeground:c,duration:Date.now()-a}),a&&p&&b&&(Bt.report({status:R,method:s,isForeground:c,duration:Number((p-a).toFixed(3))}),jt.report({status:R,method:s,isForeground:c,duration:Number((Date.now()-b).toFixed(3))}))}function n(o,s){return(o==="callHostMethod"||o==="callHostMethodSync")&&s!=null&&s.method?`${o}-${s.method}`:o}return r}var is,fe,$r,Lt,Bt,jt,Jt=f(()=>{"use strict";E();is=e=>e==="pv"?e:"default",fe=class{constructor(t){this.interval=30;this.lastReportTime=0;this.cache={};let{reporter:r,interval:n=30,eventName:o,tagNameOrder:s,metricName:i,type:a}=t;this.reporter=r,this.interval=n,this.eventName=o,this.tagNameOrder=s,this.metricName=i,this.type=is(a)}report(t){this.type==="pv"?this.addPVPoint(t):this.addPoint(t),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(t){if(Object.keys(this.cache).length){if(t){this.reporter(this.processPoints(this.cache)),this.clearPoints();return}this.lastReportTime=this.lastReportTime||Date.now(),Date.now()-this.lastReportTime>=this.interval*1e3&&(this.reporter(this.processPoints(this.cache)),this.clearPoints(),this.lastReportTime=Date.now())}}addPoint(t){let r=(n,o,s,i)=>{let a=o.shift();if(a){let c=i[a];n[c]||(n[c]={}),r(n[c],o,s,i)}else n[s]||(n[s]=[]),n[s].push(i[s])};r(this.cache,[...this.tagNameOrder],this.metricName,t)}addPVPoint(t){let r=(o,s,i,a)=>{let c=s.shift();if(!c&&B(a))throw new Ue(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(c){let l=[];if(B(a))l.push(...Object.keys(a));else if(le(a)){if(s.length>0)throw new Ue(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);l.push(a)}else throw new Ue(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);l.forEach(u=>{o[u]||(o[u]={});let m=B(a)?a[u]:a;r(o[u],[...s],i,m)})}else o[i]?o[i]++:o[i]=1},n={point:t,metricName:this.metricName,tagNameOrder:this.tagNameOrder};r(this.cache,[...this.tagNameOrder],this.metricName,t)}processPoints(t){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:t}}clearPoints(){this.cache={}}},$r=!1});function Kr(e,t){let r=0,n=!0,o=new Map,s=Hr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,$t.forEach(p=>y(this,[p],function*({method:l,args:u,resolve:m}){let b=yield a(l,u);m(b)})),$t.length=0});let i=(l,u)=>{let m=o.get(Number(l));if(!m)return;let p=Ee(u);m(p),o.delete(Number(l))},a=(l,u)=>{var U,I;let m=Date.now(),p=`${n}`;r+=1;let b=new Q;if(o.set(r,b.resolve),!n&&jr.includes(l))return new Promise(A=>{$t.push({method:l,args:u,resolve:A})});let T=P(h({},{method:l,startTime:m,args:u,isForeground:p}),{invokeType:"js-bridge"}),v=!as&&Br.includes(l),S=vr(u,v),x=v?S:JSON.stringify(S),w;if(l.endsWith("Sync")||Jr.includes(l)?w=(U=e.call)==null?void 0:U.call(e,l,S,r):typeof x=="string"?w=e.invoke(l,x,r):w=(I=e.call)==null?void 0:I.call(e,l,x,r),w){try{typeof w=="string"&&(w=JSON.parse(w)),w=Ee(w)}catch(A){H.error(A)}return o.delete(r),w.errorCode&&(w.errorCode=Le(l,w.errorCode)),s(h(h({},T),w)),w}return l.endsWith("Sync")&&o.delete(r),b.promise.then(A=>(A.errorCode&&(A.errorCode=Le(l,A.errorCode)),s(h(h({},T),A)),A))};return{invokeNative:a,applyNative:(l,u)=>{let m=a(l,u);return wr(m)?m.then(p=>Vr(l,p)):Vr(l,m)},invokeHandler:i}}function Vr(e,t){if(!B(t)){H.warn(`[Jolibox SDK]${e} no response value`);return}let a=t,{errMsg:r,errNo:n,errorType:o,errorCode:s}=a,i=ce(a,["errMsg","errNo","errorType","errorCode"]);if(r&&r!==`${e}:ok`)throw new Nr(r,n,o,s);return i}var $t,as,qr=f(()=>{"use strict";_t();E();se();je();Jt();$t=[],as=!1});function Gr(e){let t=new q,r=new q,n=new fe({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}});return t.on("onJoliboxEnterBackground",()=>{n.flush()}),{onNative:t.on.bind(t),offNative:t.off.bind(t),subscribe:r.on.bind(r),unsubscribe:r.off.bind(r),subscribeHandler(o,s,i){let a=Ee(s),c;if(a.__extra){c=a.params;let{type:l,startTime:u}=a.__extra;n.report({type:l,event:o,duration:Date.now()-u})}else c=a;if(o===Be){c.forEach(u=>{let[m,p]=u;try{r.emit(m.slice(pe.length),p,i)}catch(b){}});return}if(o.startsWith(pe)){r.emit(o.slice(pe.length),c,i);return}t.emit(o,c,i)}}}var zr=f(()=>{"use strict";E();_t();Jt();je()});function Wr(e){let t=new Map,r;return(o,s,i,a)=>{if(a){let l=i?[i]:"*";e.publish(`${pe}${o}`,s,l);return}r||(r=Promise.resolve().then(()=>{t.forEach((l,u)=>{try{let m=u?[u]:"*";e.publish(Be,l,m)}catch(m){}}),r=void 0,t.clear()}));let c=t.get(i);c||(c=[],t.set(i,c)),c.push([`${pe}${o}`,s])}}var Qr=f(()=>{"use strict";je()});function Ht(e){let{subscribeHandler:t,onNative:r,offNative:n,subscribe:o,unsubscribe:s}=Gr(e),{invokeNative:i,invokeHandler:a,applyNative:c}=Kr(e,r),l=Wr(e);return{invokeHandler:a,subscribeHandler:t,applyNative:c,invokeNative:i,onNative:r,offNative:n,publish:l,subscribe:o,unsubscribe:s}}var Yr=f(()=>{"use strict";qr();zr();Qr()});var Xr=f(()=>{"use strict"});var Zr=f(()=>{"use strict";Yr();Xr()});function ge(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var Je=f(()=>{"use strict"});var ie,z,en,tn=f(()=>{"use strict";E();Je();G();z={trigger(){},exit(){return Promise.resolve(!1)},onReady(e){z.trigger=e},doExit(e){z.exit=e}},en=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)M(new Cr("native env failed"));else{let{data:t}=JSON.parse(e);return t!=null?t:void 0}};if(window.webkit){let e=window.webkit.messageHandlers,t=(o="")=>{z.trigger(),e.onDocumentReady.postMessage({path:o})};ie={onDocumentReady:t,doExit:o=>y(void 0,null,function*(){let s=yield z.exit();e.doExit.postMessage({uuid:o,shouldInterrupt:s})}),invoke(o,s,i){e.invoke.postMessage({event:o,paramsString:s,callbackId:i})},publish(o,s,i){let a=ge(s,"joliboxJSCore");window.prompt("publish",JSON.stringify({event:o,paramsString:JSON.stringify(a),webviewIds:i}))},call(o,s,i){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(s),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:en};globalThis.joliboxJSCore=h({},n)}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(o="")=>{z.trigger(),e.onDocumentReady(JSON.stringify({path:o}))};ie={onDocumentReady:t,invoke(o,s,i){e.invoke(JSON.stringify({event:o,paramsString:s,callbackId:i}))},doExit:o=>y(void 0,null,function*(){let s=yield z.exit();e.doExit(JSON.stringify({uuid:o,shouldInterrupt:s}))}),publish(o,s,i){let a=ge(s,"joliboxJSCore");e.publish({event:o,paramsString:JSON.stringify(a),webviewIds:i})},call(o,s,i){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(s),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:en};globalThis.joliboxJSCore=h({},n)}});function Vt(){globalThis.onmessage=function(e){e.data==="msg:setup"&&([ye]=e.ports,ye.onmessage=function(t){let r=JSON.parse(t.data);r[0]==="publish"?globalThis.ttJSBridge.subscribeHandler(r[1],r[2]):r[0]==="invoke"&&globalThis.ttJSBridge.invokeHandler(r[1],r[2])},ye.publish=function(t,r){let n=ge(r,"messagePort");ye.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},ye.postMessage("msg:setup:ok"))}}var ye,rn=f(()=>{"use strict";Je()});var $e=f(()=>{"use strict";tn();rn();Je()});var on,cs,sn,nn,V,_,Y,Ba,ls,an,cn,ja,j=f(()=>{"use strict";Zr();$e();se();E();$e();on=ie;if(!on)throw new Or("No joliboxJScore is found, native bridge not found.");Vt();cs=h({},on),sn=Ht(cs),{invokeHandler:nn}=sn,{applyNative:V,invokeNative:_,onNative:Y,offNative:Ba,subscribeHandler:ls,publish:an,subscribe:cn,unsubscribe:ja}=sn;globalThis.joliboxJSBridge={callHandler:nn,invokeHandler:nn,subscribeHandler:ls}});var Kt,qt,ln,dn,un=f(()=>{"use strict";E();G();Kt=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch(o){return{}}},qt=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},ln=e=>{var t;try{let o=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(o!=null&&o.length){let[s,i,a]=o;return{headerJson:Kt(s),payloadJson:Kt(i),signature:Kt(a)}}else throw"joli_source is missing"}catch(r){return M(new Pr(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},dn=e=>{let{headerJson:t,payloadJson:r,signature:n}=e,o=qt(t),s=qt(r),i=qt(n);return`${o}.${s}.${i}`}});var ds,He,mn,Gt=f(()=>{"use strict";E();ds="1.1.11-beta.3",He=()=>ds,mn=()=>{let e=He();return`${Mr(e)}`}});var us,pn,zt,fn,L,ms,g,J=f(()=>{"use strict";E();un();Gt();E();us={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:Dt(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:He()},schema:window.location.href,platform:"h5"},zt=(pn=globalThis.joliboxJSCore)==null?void 0:pn.env,L=Object.assign({},(fn=zt==null?void 0:zt())!=null?fn:us),ms=()=>{var p,b,R,T,v,S,x,w,U;let{payloadJson:e,headerJson:t,signature:r}=L.schema.length?ln(L.schema):{},n=`${L.deviceInfo.did}-${new Date().getTime()}`,s=new URL(L.schema.length?L.schema:window.location.href).searchParams,i=(R=(b=(p=s.get("mpId"))!=null?p:s.get("appId"))!=null?b:s.get("gameId"))!=null?R:"",a=(S=(v=(T=L.clientSessionId)!=null?T:e==null?void 0:e.sessionId)!=null?v:s.get("sessionId"))!=null?S:n,c=!!((x=e==null?void 0:e.testAdsMode)!=null?x:s.get("testAdsMode")==="true"),l=(U=(w=e==null?void 0:e.joliboxEnv)!=null?w:s.get("joliboxEnv"))!=null?U:"production",u=l==="staging",m=t==null?void 0:t.channel;return{get testMode(){return u},get testAdsMode(){return c},get joliboxEnv(){return l},get joliSource(){var I;return(I=s.get("joliSource"))!=null?I:null},get mpId(){var I;return(I=i!=null?i:e==null?void 0:e.id)!=null?I:""},get mpVersion(){var I;return(I=t==null?void 0:t.ver)!=null?I:He()},get mpType(){var I,A;return(A=(I=t==null?void 0:t.__mpType)!=null?I:e==null?void 0:e.__mpType)!=null?A:"game"},get platform(){var I;return(I=L.platform)!=null?I:L.deviceInfo.platform},get deviceInfo(){return L.deviceInfo},get sdkInfo(){return L.sdkInfo},get hostInfo(){return L.hostInfo},get hostUserInfo(){return L.hostUserInfo},get sessionId(){var I,A;return(A=(I=L.clientSessionId)!=null?I:a)!=null?A:n},get channel(){return m},get webviewId(){var I;return(I=L.webviewId)!=null?I:-1},get shouldInterupt(){return e==null?void 0:e.__shouldInterupt},get from(){return e==null?void 0:e.__from},onEnvConfigChanged:I=>{_r(L,I,Rr)},encodeJoliSourceQuery:I=>{var A;return t&&r?dn({headerJson:t,payloadJson:h(h({},e),I),signature:r}):(A=s.get("joliSource"))!=null?A:""}}},g=ms()});var Wt,gn,ps,fs,hn,hs,yn=f(()=>{"use strict";E();G();J();E();Wt=!1,gn=(e,t)=>e==null?!1:t in e,ps=e=>gn(e,"kind"),fs=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},hn=(e,t={},r)=>{var s,i,a;let n={user_id:(i=(s=g.hostUserInfo)==null?void 0:s.uid)!=null?i:"",device_id:(a=g.deviceInfo.did)!=null?a:"",timestamp:Date.now(),tag:fs(e.name)},o=P(h({},n),{env:t.environment,isFromUser:r});r?ue.emit("GLOBAL_USER_ERROR",e,o):ue.emit("GLOBAL_ERROR",e,o)},hs=e=>gn(e,"kind")&&e.kind==="USER_ERROR";Ut.on("ERROR_REPORT",({error:e,options:t})=>{if(Wt)return;Wt=!0;let r=ps(e)&&e.raw?e.raw:e;try{let n=hs(e);hn(e,t,n)}catch(n){let o=n instanceof Error?n.message:String(n),s=new Nt(`${o}, origin error: ${r.message}`);H.error(s),hn(new Nt(s.message),{environment:t.environment},!1)}finally{Wt=!1}})});var vn=f(()=>{"use strict";yn();se();E();j();ue.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};_("trackAsync",{event:"reportJsError",data:r})});ue.on("GLOBAL_USER_ERROR",(e,t)=>{H.log("UserError",e,t)})});var Qt=f(()=>{"use strict"});function bn(e,t){let r=(n,o,s)=>{let i=P(h({tag:n},t),{extra:h({},o)});n=="globalJsError"?M(new Fr(JSON.stringify(i))):e("systemLog",i,s)};return r.debounce=_e(r,500,{leading:!0}),r}function Tn(e){let t=(r,n,o)=>{var a;let s=(a=o&&JSON.stringify(o))!=null?a:0,i={speed_value_type:r,total_duration:n};s&&Object.assign(i,{extra:s}),e("joliboxSpeedAnalysis",i)};return t.debounce=_e(t,500,{leading:!0}),t}var kn=f(()=>{"use strict";E();E();G()});function En(e,t){let r=bn(e,t),n=Tn(r);return{track:r,trackPerformance:n}}var Sn=f(()=>{"use strict";kn()});var wn=f(()=>{"use strict";J();E();E()});var In=f(()=>{"use strict";Sn();Qt();wn()});var Ve,_n=f(()=>{"use strict";Ve=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,o,s=!1,i=0,a=()=>{if(!s)return;let b=Date.now(),R=b-r;R>=this.interval&&(this.visible&&(i+=R,t(i)),r=b),n=requestAnimationFrame(a)},c=()=>{u(),r=Date.now(),o=window.setInterval(()=>{if(!s)return;let b=Date.now();b-r>=this.interval&&(r=b)},this.interval)},l=()=>{m(),r=Date.now(),n=requestAnimationFrame(a)},u=()=>{n&&(cancelAnimationFrame(n),n=0)},m=()=>{o&&(clearInterval(o),o=0)};this.eventEmitter.on("visible",b=>{s&&(console.log("visible",b),b?l():c())});let p=this.visible;return{start(){s||(s=!0,p?l():c())},stop(){s=!1,u(),m()}}}}});var Yt=f(()=>{"use strict"});function An(e,t,r){let{response:n,startTime:o,endTime:s,requestFrom:i}=r,{errMsg:a="",profile:c={}}=n,u={duration:s-o,request_type:e,url:t.split("?")[0],result:r.state,error_msg:r.state==="fail"?a:"",socket_reused:c.socketReused?1:0,request_from:i};(i==="public"&&Rn<ys||i==="inner")&&(u.joli_request_number=Rn++,setTimeout(()=>{K("joliboxNetRequestResult",u)},500))}var Rn,ys,xn=f(()=>{"use strict";Yt();ae();Rn=0,ys=10});function Ke(e,t,r){var c,l,u;let n=new Map,o=(c=r==null?void 0:r.baseUrl)!=null?c:"https://api.jolibox.com",s=(l=r==null?void 0:r.type)!=null?l:"public",i=(u=r==null?void 0:r.defaultHeaders)!=null?u:{};return Y("onRequestTaskStateChange",m=>{if(typeof m.requestTaskId!="string")return;let p=n.get(m.requestTaskId);if(p)if(m.state==="success"){let b=m,{requestTaskId:T,state:v}=b,S=ce(b,["requestTaskId","state"]);p.resolve(S),n.delete(T)}else if(m.state==="fail"){let R=m,{requestTaskId:T,state:v}=R,S=ce(R,["requestTaskId","state"]);p.reject(S),n.delete(T)}else H.warn("onRequestTaskStateChange unknown event",m)}),re.on("onLoginComplete",({isLogin:m,token:p})=>{m&&p&&(i["X-JOLI-TOKEN"]=p)}),(b,...R)=>y(this,[b,...R],function*(m,p={}){let T=Date.now(),v=vs(m,P(h({},p),{baseUrl:o})),{method:S="GET",responseType:x="text",dataType:w="json",timeout:U,enableCache:I=!1,appendHostCookie:A=!0}=p,ke=Object.assign({"content-type":"application/json"},i,p.header),oe={url:v,method:S,header:ke,enableCache:I,responseType:x,appendHostCookie:A};if(S=="POST"||S=="PUT"){let W=Ts(p.data,ke["content-type"]);oe.data=W}U&&Object.assign(oe,{timeout:U});let{data:{requestTaskId:wt}}=_(e,oe);if(typeof wt!="string")throw me({code:-1,msg:"requestTaskId is not a string"});let mr=(W,ee)=>{An("request",v,{state:W,startTime:T,endTime:Date.now(),params:oe,response:ee,requestId:wt,requestFrom:s=="public"?"public":"inner"})},{resolve:bo,reject:To,promise:ko}=new Q;n.set(wt,{resolve:bo,reject:To});try{let W=yield ko;mr("success",W);let{data:ee}=W;return w==="json"&&typeof ee=="string"&&(ee=bs(ee)),{url:v,timeout:U,method:S,response:P(h({},W),{data:ee})}}catch(W){let ee=W;if(B(ee)){let{errMsg:Pe,prefetchDetail:Eo,isPrefetch:So,errNo:wo}=ee;le(Pe)&&(mr("fail",{errMsg:Pe,isPrefetch:So,prefetchDetail:Eo}),M(me({code:-1,msg:Pe},{errNo:wo,errMsg:Pe})))}throw W}})}function bs(e){try{return JSON.parse(e.trim())}catch(t){return e}}function Ts(e,t="application/json"){let r=t.toLowerCase();return e===void 0?"":typeof e=="string"||e instanceof ArrayBuffer?e:r.includes("application/x-www-form-urlencoded")||r.includes("application/json")||typeof e=="object"?JSON.stringify(e):String(e)}var vs,Xt=f(()=>{"use strict";E();xn();Yt();j();G();se();vs=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t==null?void 0:t.query,o=new URLSearchParams(r).toString();return t!=null&&t.baseUrl?`${t.baseUrl}${e}${o?`?${o}`:""}`:`${e}${o?`?${o}`:""}`}});var Zt,Pn,X,qe=f(()=>{"use strict";Gt();Xt();J();Zt={"x-user-agent":mn()};(Pn=g.hostUserInfo)!=null&&Pn.token&&(Zt["x-joli-token"]=g.hostUserInfo.token);g.joliSource&&(Zt["x-joli-source"]=g.joliSource);X=Ke("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:g.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:Zt})});var Ge,Cn=f(()=>{"use strict";J();_n();qe();j();Ge=class extends Ve{constructor(t,r,n){super(r,n),this.gameId=g.mpId,this.sessionId=g.sessionId,this.track=t}reporter(t){return y(this,null,function*(){let{event:r,params:n}=t,o=[];o.push(X("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:h({gameId:this.gameId,sessionId:this.sessionId},n)}})),yield Promise.all(o)})}reportToNative(t){return y(this,null,function*(){let{event:r,params:n}=t;yield V("userTrackAsync",{event:r,params:h({},n),gameId:this.gameId})})}tracker(t,r=null){this.track(t,r)}}});var Un={};gr(Un,{nativeTaskEmitter:()=>xe,taskTracker:()=>$,track:()=>K,trackPerformance:()=>Fn});var ks,Nn,On,K,Fn,Dn,xe,$,ae=f(()=>{"use strict";vn();E();Qt();In();J();Cn();j();ks=(e,t,r)=>{var i,a;let n=t,o=B(n.extra)?n.extra:le(n.extra)?JSON.parse(n.extra):{},s=P(h({},o),{mp_id:(i=n.mp_id)!=null?i:"",mp_version:(a=n.mp_version)!=null?a:""});_("trackAsync",{event:e,data:s,webviewId:r})},{track:K,trackPerformance:Fn}=En(ks,{type:Ft.AppSDK,platform:"native",jssdk_version:(On=(Nn=g.sdkInfo)==null?void 0:Nn.jssdkVersion)!=null?On:"1.0.0",mp_id:g.mpId,mp_version:g.mpVersion}),Dn=O();Dn.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{Fn(e,t,r)});Dn.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{K(e,t)});xe=new q,$=new Ge(K,xe)});function Mn(){let e=null,t=window.fetch,r=()=>{e=document.createElement("style"),e.setAttribute("data-jolibox-sdk","default-styles");let s=`
2
2
  html[data-jolibox-root] {
3
3
  height: 100%;
4
4
  margin: 0;
@@ -16,6 +16,6 @@ var Ts=Object.create;var Ce=Object.defineProperty,ks=Object.defineProperties,Es=
16
16
  min-height: 100dvh;
17
17
  }
18
18
  }
19
- `;e.textContent=o;let i=document.head||document.getElementsByTagName("head")[0];i.insertBefore(e,i.firstChild),document.documentElement.setAttribute("data-jolibox-root","")},n=()=>{function o(a){return g(this,null,function*(){let c=a instanceof URL?a.href:a,l=new Promise((d,m)=>{let p=new XMLHttpRequest;p.open("GET",c),p.responseType="arraybuffer",p.addEventListener("load",()=>d(p.response)),p.addEventListener("error",m),p.send()});try{let d=yield l;return new Response(d,{headers:new Headers([["Content-Type","application/wasm"]])}).clone()}catch(d){throw console.error("Failed to load wasm:",d),d}})}let i=window.fetch;window.fetch=(a,c)=>{let l=a instanceof URL?a.href:a.toString();return l.endsWith(".wasm")?o(l):i(a,c)}},s=()=>{e!=null&&e.parentNode&&(e.parentNode.removeChild(e),e=null),document.documentElement.removeAttribute("data-jolibox-root"),window.fetch=t};return r(),n(),s}var Un=f(()=>{"use strict"});var Ge,Mn=f(()=>{"use strict";Ge=class{constructor(t){this.track=t;this.adBreakIsShowing=!1;this.reportPageJumpOut=()=>{this.track("AdBreakJumpOut",{context:"AdsActionDetection"})};this.reportPageHide=()=>{this.track("AdBreakHide",{context:"AdsActionDetection"})};window.addEventListener("visibilitychange",()=>{document.hidden&&this.adBreakIsShowing&&this.reportPageHide()}),window.addEventListener("beforeunload",r=>{this.adBreakIsShowing&&this.reportPageJumpOut()})}}});var Ln,ze,Bn=f(()=>{"use strict";Ln="jolibox-sdk-ads-callbreak-timestamps",ze=class{constructor(t,r,n,s){this.track=t;this.httpClient=r;this.checkNetwork=n;this.maxAllowedAdsForTime=8;this.bannedForTimeThreshold=6e4;this.bannedReleaseTime=6e4;this.isBanningForTime=!1;this.releaseBannedForTimeTimeout=null;this.maxAllowedAdsForSession=200;this.bannedForSessionThreshold=6e5;this.isBanningForSession=!1;this.initialThreshold=2e3;this._callAdsTimestampsForTime=[];this.callAdsTimestampsForSession=[];this.initTimestamp=0;this.initCallAdsTimestampsForTime=()=>{var t;try{let r=JSON.parse((t=window.localStorage.getItem(Ln))!=null?t:"[]");Array.isArray(r)?this._callAdsTimestampsForTime=r:this._callAdsTimestampsForTime=[]}catch(r){this._callAdsTimestampsForTime=[]}};this.setReleaseBannedForTime=()=>{this.releaseBannedForTimeTimeout&&(window.clearTimeout(this.releaseBannedForTimeTimeout),this.releaseBannedForTimeTimeout=null),this.releaseBannedForTimeTimeout=window.setTimeout(()=>{this.isBanningForTime=!1,this.releaseBannedForTimeTimeout=null},this.bannedReleaseTime)};this.checkShouldBannedInitial=()=>{if(Date.now()-this.initTimestamp<=this.initialThreshold)return"BLOCK_INITIAL"};this.checkShouldBannedForSession=t=>{if(this.isBanningForSession)return"BANNED_FOR_SESSION";let r=Date.now();if(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.concat({timestamp:r,type:t}),this.callAdsTimestampsForSession.length!==1&&(this.callAdsTimestampsForSession.length>this.maxAllowedAdsForSession&&(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.slice(-this.maxAllowedAdsForSession)),this.callAdsTimestampsForSession.length===this.maxAllowedAdsForSession&&r-this.callAdsTimestampsForSession[0].timestamp<=this.bannedForSessionThreshold))return this.isBanningForSession=!0,"BANNED_FOR_SESSION"};this.checkShouldBannedForTime=t=>{if(this.isBanningForTime)return"WAITING_BANNED_RELEASE";let r=Date.now();if(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.concat({timestamp:r,type:t}),this.callAdsTimestampsForTime.length!==1&&(this.callAdsTimestampsForTime.length>this.maxAllowedAdsForTime&&(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.slice(-this.maxAllowedAdsForTime)),this.callAdsTimestampsForTime.length===this.maxAllowedAdsForTime&&r-this.callAdsTimestampsForTime[0].timestamp<=this.bannedForTimeThreshold))return this.isBanningForTime=!0,this.setReleaseBannedForTime(),"BANNED_FOR_TIME"};this.checkAdsDisplayPermission=t=>{if(!this.checkNetwork())return"NETWORK_NOT_OK";let r=this.checkShouldBannedInitial();if(r)return r;let n=this.checkShouldBannedForSession(t);if(n)return n;let s=this.checkShouldBannedForTime(t);return s||"ALLOWED"};var o,i,a,c,l,d;if(this.maxAllowedAdsForTime=(o=s==null?void 0:s.maxAllowedAdsForTime)!=null?o:8,this.bannedForTimeThreshold=(i=s==null?void 0:s.bannedForTimeThreshold)!=null?i:6e4,this.bannedReleaseTime=(a=s==null?void 0:s.bannedReleaseTime)!=null?a:6e4,this.maxAllowedAdsForSession=(c=s==null?void 0:s.maxAllowedAdsForSession)!=null?c:200,this.bannedForSessionThreshold=(l=s==null?void 0:s.bannedForSessionThreshold)!=null?l:6e5,this.initialThreshold=(d=s==null?void 0:s.initialThreshold)!=null?d:2e3,this.maxAllowedAdsForTime<=1)throw new Error("maxAllowedAdsForTime must be greater than 1");if(this.bannedForTimeThreshold<0)throw new Error("bannedForTimeThreshold must be greater than or equal to 0");if(this.bannedReleaseTime<this.bannedForTimeThreshold)throw new Error("bannedReleaseTime must be greater than or equal to bannedForTimeThreshold");if(this.initialThreshold<0)throw new Error("initialThreshold must be greater than or equal to 0");this.initCallAdsTimestampsForTime(),this.initTimestamp=Date.now()}get callAdsTimestampsForTime(){return this._callAdsTimestampsForTime}set callAdsTimestampsForTime(t){try{window.localStorage.setItem(Ln,JSON.stringify(t))}catch(r){console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=t}report(t){this.track("PreventAdsCheating",{reason:t}),this.httpClient.post("/api/base/app-event",{data:{eventType:"PREVENT_ADS_CHEATING",adsInfo:{reason:t}}})}}});var We,jn=f(()=>{"use strict";K();We=class{constructor(t){this.httpClient=t;this.configs=null;this.firstRun=!0;this.init()}init(){return g(this,null,function*(){try{this.configs=yield this.httpClient.get("/api/fe-configs/js-sdk/ads-channel-config")}catch(t){}})}shouldBypassCallingInterstitial(){var r,n;let t;if(!this.configs)this.init(),t=!this.firstRun;else{let s=(r=v.channel)!=null?r:"",o=this.configs[s],i=(n=o==null?void 0:o.interstitialRate)!=null?n:1;t=Math.random()<i}return this.firstRun=!1,t}}});var ve,Qe,er=f(()=>{"use strict";Mn();Bn();K();jn();E();ve=new q,Qe=class{constructor(t,r,n){this.track=t;this.httpClient=r;this.checkNetwork=n;this.configured=!1;this.config={};this.getGameId=()=>v.mpId;this.getTestAdsMode=()=>v.testAdsMode;this.asyncLoad=()=>g(this,null,function*(){var i,a,c,l,d;let t="ca-pub-7171363994453626",r,n,s=window.encodeURIComponent(window.btoa((i=this.getGameId())!=null?i:"")),o=(a=this.getTestAdsMode())!=null?a:!1;try{let m=yield this.httpClient.get("/public/ads",{query:{objectId:s,testAdsMode:`${o}`}});t=(c=m.data)==null?void 0:c.clientId,r=(l=m.data)==null?void 0:l.channelId,n=(d=m.data)==null?void 0:d.unitId}catch(m){console.error("Failed to fetch client info",m)}this.clientId=t,this.channelId=r,this.unitId=n});this.asyncInit=t=>g(this,null,function*(){var s;if(typeof window=="undefined")return;yield this.asyncLoad();let r="google-adsense",n=(s=this.getTestAdsMode())!=null?s:!1;if(!document.getElementById(r)&&this.clientId){let o=document.createElement("script");o.id=r,o.async=!0,o.crossOrigin="anonymous",o.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`,n&&o.setAttribute("data-adbreak-test","on"),this.channelId&&o.setAttribute("data-ad-channel",this.channelId),document.head.appendChild(o),this.track("LoadAdsenseCompleted",null)}});this.push=(t={})=>{window.adsbygoogle.push(t)};this.wrapAdBreakParams=t=>{if((n=>n.type==="preroll")(t)){ve.emit("isAdShowing",!0);let n=t.adBreakDone,s=o=>{ve.emit("isAdShowing",!1),n&&n(o)};return C(h({},t),{adBreakDone:s})}else{let n=t.beforeAd,s=t.afterAd,o=()=>{var a;ve.emit("isAdShowing",!0),this.track("CallBeforeAd",{type:t.type,name:(a=t.name)!=null?a:""}),n&&n()},i=()=>{var a;ve.emit("isAdShowing",!1),this.track("CallAfterAd",{type:t.type,name:(a=t.name)!=null?a:""}),s&&s()};return C(h({},t),{beforeAd:o,afterAd:i})}};this.adConfig=t=>{let s=t,{onReady:r}=s,n=ce(s,["onReady"]);this.track("CallAdConfig",n),this.configured?console.warn("Ad config already set, skipping"):(this.configured=!0,this.push(t))};this.adBreak=t=>{var c,l,d,m;if(!this.getGameId()){console.warn("Game ID is not set, skip calling adBreak");return}if(t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){(c=t.adBreakDone)==null||c.call(t,{breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}let r=this.antiCheating.checkAdsDisplayPermission(t.type==="reward"?"reward":"interstitial");switch(r){case"NETWORK_NOT_OK":case"BANNED_FOR_SESSION":console.warn("Ads not allowed",r),(l=t.adBreakDone)==null||l.call(t,{breakType:t.type,breakName:r,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"}),this.antiCheating.report(r);return;case"BLOCK_INITIAL":case"BANNED_FOR_TIME":case"WAITING_BANNED_RELEASE":console.warn("Ads not allowed",r),(d=t.adBreakDone)==null||d.call(t,{breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"}),this.antiCheating.report(r);return;default:break}let n=t.type,s=t.adBreakDone,o=p=>{var b;this.adsActionDetection.adBreakIsShowing=!1,this.track("CallAdBreakDone",{breakType:p.breakType,breakName:(b=p.breakName)!=null?b:"",breakFormat:p.breakFormat,breakStatus:p.breakStatus}),s&&s(p)};if(t.adBreakDone=o,t.type==="reward"){let p=t.beforeReward,b=T=>()=>{this.track("CallShowAdFn",null),T()},_=T=>{p&&p(b(T))};t.beforeReward=_}let i;switch(n){case"preroll":i={type:n};break;case"start":case"pause":case"next":case"browse":case"reward":i={type:n,name:(m=t.name)!=null?m:""};break}this.adsActionDetection.adBreakIsShowing=!0,this.track("CallAdBreak",i);let a=this.wrapAdBreakParams(t);this.push(a),window.JoliTesterBridge&&console.log("joli-fullscreen-ad-show")};this.adUnit=t=>g(this,null,function*(){var p,b,_,T;if(this.track("CallAdUnit",{adFormat:(b=(p=t.adFormat)==null?void 0:p.toString())!=null?b:null,fullWidthResponsive:(_=t.fullWidthResponsive)!=null?_:null}),this.clientId||(yield this.asyncLoad()),document.querySelector("#jolibox-ads")){console.warn("Ad unit already set, skipping");return}let{el:r,slot:n,adFormat:s,fullWidthResponsive:o,style:i}=t,a;if(!r)throw new Error("targeting element is required");if(typeof r=="string"?a=document.querySelector(r):a=r,!a)throw new Error("targeting element not found");let c=n;if(c||(c=this.unitId),!c)throw new Error("slot is required");let l=typeof s=="object"&&Array.isArray(s)?s.join(", "):s,d=document.createElement("ins");if(d.className="adsbygoogle",d.id="jolibox-ads",d.style.display="block",d.setAttribute("data-ad-client",this.clientId),d.setAttribute("data-ad-slot",c),l&&d.setAttribute("data-ad-format",l),o&&d.setAttribute("data-full-width-responsive",o),i&&d.setAttribute("style",i),(T=this.getTestAdsMode())!=null?T:!1){let y=document.createElement("div");y.style.position="absolute",y.style.top="0",y.style.left="0",y.style.width="100%",y.style.height="100%",y.style.display="flex",y.style.justifyContent="center",y.style.alignItems="center",y.style.backgroundColor="rgba(0, 0, 0, 0.5)",y.style.color="white",y.innerHTML="Test Ad",d.style.position="relative",a.appendChild(d),d.appendChild(y)}else a.appendChild(d),new MutationObserver(S=>{S.forEach(R=>{if(R.type==="attributes"&&R.attributeName==="data-ad-status"){let w=d.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:w!=null?w:"null"})}})}).observe(d,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})});this.antiCheating=new ze(t,r,n),this.adsActionDetection=new Ge(this.track),this.channelPolicy=new We(r)}init(t){this.track("CallAdsInit",null),typeof window!="undefined"&&(this.config=t!=null?t:{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}}});var Hn={};hr(Hn,{config:()=>ko});function vo(){te.on("onDocumentReady",()=>{var e;(e=ie)==null||e.onDocumentReady(window.location.href),V("onDocumentReady",{start_timestamp:Ze,timestamp:Date.now()})})}function bo(e){v.mpType==="game"&&j.start(e)}function To(){Q("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&v.onEnvConfigChanged({hostUserInfo:e}),te.emit("LifecycleEvent.onReady",h({},v.hostUserInfo?v.hostUserInfo:{isLogin:!1})),V("joliboxServiceReady",{start_timestamp:Ze,timestamp:Date.now()}),bo(t)}),Q("onBeforeExit",({uuid:e})=>{var t;(t=ie)==null||t.doExit(e)})}function ko(){Ze=Date.now(),To(),vo(),Ye=Dn()}var Ye,Jn,Xe,Ze,$n=f(()=>{"use strict";$();Je();K();E();ae();Un();er();z.onReady(()=>{});Jn=()=>{V("onBeforeExit",{timestamp:Date.now()}),Ye==null||Ye(),j.close(Date.now()-Ze)};z.doExit(()=>g(void 0,null,function*(){return Xe?!0:Ie(v.shouldInterupt)?(v.shouldInterupt||Jn(),v.shouldInterupt):(Jn(),!1)}));Xe=!1;ve.on("isAdShowing",e=>{Xe=e,Ie(Xe)&&P("updateContainerConfigSync",{displayCapsuleButton:!Xe,webviewId:v.webviewId})})});function Vn(e){let t=Ot.config[e];return t||(t={},Ot.config[e]=t),(r,n)=>{if(t[r]){J.warn(`[can i use] ${r} already registered`);return}t[r]=h({},n)}}var Kn=f(()=>{"use strict";E()});function tr(e){qn=e}function et(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>et(t)):Object.keys(e).reduce((t,r)=>(t[r]=et(e[r]),t),{})}function re(e){return typeof e=="number"}function rr(e){let t=nr(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function nr(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var qn,O,tt,rt,nt,st,be,ot,it,at,ct,lt,dt,ut,mt,pt,ft,ht,gt,sr=f(()=>{"use strict";qn=!1;O=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(qn)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${rr(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return et(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:et(this._default)}optional(){return this._optional=!0,this}};tt=class extends O{validate(t){return this._optional&&t===void 0?!0:re(t)?re(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):re(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):re(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},rt=class extends O{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},nt=class extends O{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(re(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(re(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},st=class extends O{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},be=class extends O{validate(t){return!0}},ot=class extends O{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},it=class extends O{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},at=class extends O{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},ct=class extends O{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(n=>JSON.stringify(n)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${rr(t)}`)}return!0}},lt=class extends O{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(re(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(re(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(re(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let n=this._item;if(!n)return!0;let s=!0;if(r.forEach((o,i)=>{if(n.path=`${this.path}[${i}]`,n.errors=this.errors,o===void 0&&n.hasDefault){r[i]=n.defaultValue;return}n.validate(o)||(n.hasFallback?r[i]=n.fallbackValue:s=!1)}),this._uniqueItems){let o=new Map;for(let i in r)o.has(r[i])?s=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${o.get(r[i])}] and ${this.path}[${i}] are identical)`):o.set(r[i],i)}return s}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},dt=class extends O{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(nr(r)!=="object")return this.fail({expect:"object",actual:r});let s=r,o=this._value;o.errors=this.errors;let i=!0;for(let a in s){let c=s[a];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(a)?o.path=`${this.path}.${a}`:o.path=`${this.path}["${a}"]`,!(c===void 0&&o._optional)){if(c===void 0&&o.hasDefault){s[a]=o.defaultValue;continue}o.validate(c)||(o.hasFallback?s[a]=o.fallbackValue:i=!1)}}return i}},ut=class extends O{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(nr(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,s=!0;for(let o in this._object){let i=n[o],a=this._object[o];if(a.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(o)?a.path=`${this.path}.${o}`:a.path=`${this.path}["${o}"]`,!(a._optional&&i===void 0)){if(i===void 0&&a.hasDefault){n[o]=a.defaultValue;continue}a.validate(i)||(a.hasFallback?n[o]=a.fallbackValue:s=!1)}}return s}},mt=class extends O{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:rr(this.value),actual:r}):!0}},pt=class extends O{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,s=this._items.length;for(let o=0;o<s;o++){let i=this._items[o];if(i.errors=[],i.path=this.path,!i.validate(t))r.push(i.errors.join("; "));else if(!n){n=!0;break}}if(!n){let o=r.join(`
20
- or `);this.errors.push(o)}return n}},ft=class extends O{constructor(...t){super(),this._items=t;let r=0,n=t.length-1;for(;n>=0;n--){let s=t[n];if(s._optional||s.hasDefault)r+=1;else break}this._minItems=t.length-r}validate(t){if(t===void 0&&this._optional)return!0;if(!Array.isArray(t))return this.fail({expect:"array",actual:t});if(t.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let r=!0;return this._items.forEach((n,s)=>{if(n.path=`${this.path}[${s}]`,n.errors=this.errors,t[s]===void 0&&n.hasDefault){t[s]=n.defaultValue;return}n.validate(t[s])||(n.hasFallback?t[s]=n._fallback:r=!1)}),r}},ht=class extends O{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},gt=class extends O{constructor(t){super(),this._ctor=t}validate(t){return t===void 0&&this._optional||t instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:t})}}});function or(e,t,r="param"){if(e.errors=[],e.path=r,tr(!0),!e.validate(t)){let n=e.errors.join(`
21
- `);throw e.errors.length=0,tr(!1),new TypeError(n)}}var u,ir=f(()=>{"use strict";sr();sr();u={object(e){return new ut(e)},array(e){return new lt(e)},tuple(...e){return new ft(...e)},literal(e){return new mt(e)},or(...e){return new pt(...e)},symbol(){return new st},record(e){return new dt(e)},function(){return new at},boolean(){return new rt},string(){return new nt},number(){return new tt},undefined(){return new ot},null(){return new it},unknown(){return new be},any(){return new be},as(){return new be},arraybuffer(){return new ht},enum(...e){return new ct(...e)},typedarray(e){return new gt(e)}}});var yt,Gn,zn=f(()=>{"use strict";E();G();ir();oe();yt=1,Gn=e=>{function t(n,s){return(...o)=>{var m,p,b,_;let i=Date.now(),a={method:n,trace_id:yt};yt+=1;let c="SUCCESS",l=`${n}:ok`,d=0;try{if(s.paramsSchema)try{or(s.paramsSchema,o,"params")}catch(R){throw Mt(`${n}:fail ${R.message}`)}let T=s.implement(...o),y=T,S=`${n}:ok`;if(T&&"code"in T){let{code:R,data:w,message:U}=T;c=R,y=w,S=U}return{code:c,message:S,data:y}}catch(T){let y=T;d=(p=(m=y.code)!=null?m:y.errNo)!=null?p:2e3,c="FAILURE";let S=(_=(b=y.message)!=null?b:y.errMsg)!=null?_:`${T}`;return l=`${n}:${c} ${S.replace(/^\S+:(fail|cancel)\s?/,"")}`,M(new Ae(l,d)),{code:c,message:l}}finally{let T=Date.now()-i;e("apiInvoked",C(h({},a),{duration:T,status:c}))}}}function r(n,s){return(...o)=>g(this,null,function*(){var p,b,_,T;let i=kr(o)?o:[o],a=Date.now(),c={method:n,trace_id:yt};yt+=1;let l=`${n}:ok`,d="SUCCESS",m={code:d,message:l};try{if(s.paramsSchema)try{or(s.paramsSchema,i,"params")}catch(R){throw Mt(R.message)}let S=yield s.implement(...i);if(S&&"code"in S){let{code:R,data:w,message:U}=S;d=R,l=U,S=w}return Object.assign(m,{code:d,message:l,data:S}),m}catch(y){let S=y,R=(b=(p=S.code)!=null?p:S.errNo)!=null?b:2e3;d="FAILURE";let w=(T=(_=S.message)!=null?_:S.errMsg)!=null?T:`${y}`,U=`${n}:${d} ${w.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(m,{code:d,message:U}),M(new Ae(U,R)),m}finally{let y=Date.now()-a;e("apiInvoked",C(h({},c),{duration:y,status:d}))}})}return{createAPI:r,createSyncAPI:t}}});var F,D,k,X=f(()=>{"use strict";Kn();ae();zn();ir();({createAPI:F,createSyncAPI:D}=Gn(V)),k=Vn("native")});var Wn,So,wo,Io,_o,Qn=f(()=>{"use strict";E();X();$();Wn=N(),So="env",wo="getSystemInfoSync",Io=D(wo,{implement:()=>{var r;let e=P("envSync"),{data:t}=e;return{system:t.deviceInfo.system,platform:t.deviceInfo.platform,version:t.sdkInfo.jssdkVersion,pixelRatio:t.deviceInfo.pixelRatio,language:t.deviceInfo.lang,brand:t.deviceInfo.brand,appName:(r=t.hostInfo)==null?void 0:r.appName,SDKVersion:t.sdkInfo.jssdkVersion}}}),_o=D(So,{implement:()=>{var t;let e=P("envSync");return(t=e==null?void 0:e.data)!=null?t:void 0}});Wn.registerCommand("API.getSystemInfoSync",Io);Wn.registerCommand("API.env",_o);k("env",{version:"1.0.0"});k("getSystemInfoSync",{version:"1.0.0"})});var Yn=fr(ar=>{"use strict";E();X();G();$();ae();K();var Ao="exitGame",Ro="onReady",xo="onJoliboxShow",Po="onJoliboxHide",vt=N(),bt=Ue(M),Co=F(Ao,{paramsSchema:u.tuple(u.function(),u.boolean().optional().default(!1)),implement:(e,t=!1)=>g(ar,null,function*(){bt(e).call(ar),Ie(v.shouldInterupt)&&!v.shouldInterupt&&v.from&&on("onRetentionResult",{shouldStay:t},v.from,!0),yield H("exitAppAsync")})}),No=D(xo,{paramsSchema:u.tuple(u.function()),implement(e){let t=bt(e);Q("onJoliboxEnterForeground",()=>{t.call(this),Re.emit("visible",!0)})}}),Oo=D(Po,{paramsSchema:u.tuple(u.function()),implement(e){let t=bt(e);Q("onJoliboxEnterBackground",()=>{t.call(this),Re.emit("visible",!1)})}}),Fo=D(Ro,{paramsSchema:u.tuple(u.function()),implement(e){let t=bt(e);te.on("LifecycleEvent.onReady",r=>{t(r)})}});vt.registerCommand("LifecycleSDK.exit",Co);vt.registerCommand("LifecycleSDK.onReady",Fo);vt.registerCommand("LifecycleSDK.onJoliboxShow",No);vt.registerCommand("LifecycleSDK.onJoliboxHide",Oo);k("lifeCycle.exit",{version:"1.0.0"});k("lifeCycle.onReady",{version:"1.0.0"});k("lifeCycle.onJoliboxShow",{version:"1.0.0"});k("lifeCycle.onJoliboxHide",{version:"1.0.0"})});function Xn(e){let t={};if(!B(e))return t;for(let[r,n]of Object.entries(e)){let s=r.toLocaleLowerCase();n?typeof n=="object"?t[s]=Object.prototype.toString.call(n):t[s]=String(n):t[s]=""}return t}function Zn(e="GET"){if(e==="")return"POST";let t=e.toUpperCase();return["GET","OPTIONS","HEAD","POST","PUT","DELETE","TRACE","CONNECT","PATCH"].includes(t)?t:"GET"}function es(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function ts(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!B(r))return e;let[n,s=""]=e.split("?"),o=JSON.stringify(h(h({},JSON.parse(s)),r));return`${n}?${o}`}var rs=f(()=>{"use strict";E()});var Do,Uo,cr,lr,ns,Mo,Lo,Bo,ss=f(()=>{"use strict";oe();Xt();X();rs();E();G();Do=15,Uo=Ve("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),cr=0,lr=[],ns=Ue(M),Mo=(e,t)=>{let r=e.filter(t),n=e.filter(s=>!t(s));return e.length=0,e.push(...n),r},Lo=e=>{let t=new se,r=()=>{};return F("request",{paramsSchema:u.tuple(u.object({url:u.string(),method:u.string(),header:u.object(),data:u.object().optional(),query:u.object().optional(),dataType:u.string().default("json"),responseType:u.string().default("text"),enableCache:u.boolean().default(!1),appendHostCookie:u.boolean().default(!0),timeout:u.number().default(3e4),success:u.function(),fail:u.function()})),implement(s){let o=()=>g(this,null,function*(){var a,c;let i=ns(s.fail);try{if(cr+=1,t.state!=="pending")return;let{data:l,dataType:d,responseType:m,enableCache:p,appendHostCookie:b}=s,_=Xn(s.header),T=Zn(s.method),y=es(s.timeout),S=ts(s.url,T,l),R=ns(s.success),w=Object.assign({},s,{method:T,header:_,data:T==="GET"||T==="HEAD"?void 0:l,enableCache:p,query:(a=s.query)!=null?a:{},dataType:d,responseType:m,appendHostCookie:b});y&&(w.timeout=y);let U=Uo(S,w);{let{response:I}=yield U,{code:A,data:ke,message:ne}=I;t.resolve({code:A!=null?A:"SUCCESS",data:ke,message:ne!=null?ne:"request:ok"}),R({code:"SUCCESS",message:"request:ok",data:ke})}}catch(l){t.reject(l),i({code:"FAILURE",message:"httpRequst: failed"})}finally{cr-=1,(c=lr.shift())==null||c()}});return cr>=Do?(r=()=>{Mo(lr,i=>i===o)},lr.push(o)):o(),t.promise}})(e),{abort(){t.reject(me({code:-1,msg:"request:fail abort"})),r()}}},Bo=N();Bo.registerCommand("HttpSDK.request",Lo);k("request",{version:"1.0.0"})});function Ko(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return Vo.includes(t)?t:""}function qo(e,t){try{switch(t){case"string":return e;case"object":return JSON.parse(e);case"number":return parseFloat(e);case"boolean":return e==="true";default:return""}}catch(r){return""}}function Go(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch(r){return""}}var Tt,jo,Jo,Ho,$o,Cd,Nd,Vo,os=f(()=>{"use strict";X();$();E();Ke();K();Tt=N(),jo=F("getLocalStorage",{paramsSchema:u.tuple(u.string()),implement(e){return g(this,null,function*(){let{response:t}=yield Y(`/api/games/user-storage/${v.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:s}}=yield t;if(r==="SUCCESS")return{code:r,message:n,data:s==null?void 0:s.value};try{let{data:{data:o,dataType:i}}=yield H("getLocalStorageAsync",{key:e}),a=qo(o,i);return{code:r,message:`${n}. fallback to native`,data:a}}catch(o){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}})}});Tt.registerCommand("StorageSDK.getItem",jo);k("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});Jo=F("setStorage",{paramsSchema:u.tuple(u.string(),u.or(u.string(),u.boolean(),u.number())),implement(e,t){return g(this,null,function*(){let r=v.mpId,n=typeof t=="string"?t:String(t),{response:s}=yield Y(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:o,message:i}}=s,a=Ko(t),c=Go(t,a);return yield H("setLocalStorageAsync",{key:e,data:c,dataType:a}),o=="SUCCESS"?{code:o,message:i}:{code:o,message:`${i}. fallback to native`}})}});Tt.registerCommand("StorageSDK.setItem",Jo);k("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});Ho=F("removeStorage",{paramsSchema:u.tuple(u.string()),implement(e){return g(this,null,function*(){let t=v.mpId,{response:r}=yield Y(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:s}}=r;return yield H("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:s}:{code:n,message:"[Jolibox SDK] remove item succ"}})}});Tt.registerCommand("StorageSDK.removeItem",Ho);k("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});$o=F("clearStorage",{implement(){return g(this,null,function*(){let e=v.mpId,{response:t}=yield Y(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});H("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}})}});Tt.registerCommand("StorageSDK.clear",$o);k("storage.clear",{version:"1.0.0"});Cd=F("getStorageInfo",{implement(){return g(this,null,function*(){let{data:e}=yield H("getStorageInfoAsync");return e})}});k("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});Nd=D("getStorageInfoSync",{implement(){return P("getStorageInfoSync")}}),Vo=["string","number","boolean","object",""]});var zo,Wo,Qo,dr,is=f(()=>{"use strict";E();$();X();zo=D("showKeyboard",{paramsSchema:u.tuple(u.object({defaultValue:u.string().optional().default(""),multiple:u.boolean().optional().default(!1),maxLength:u.unknown().optional().default(1e5)})),implement(e){var n;let t=Math.floor((n=Number(e.maxLength))!=null?n:1e5),{defaultValue:r}=e;r&&t&&(r=r.slice(0,t)),P("showKeyboardSync",C(h({},e),{defaultValue:r,maxLength:t}))}});k("keyboard.showKeyboard",{version:"1.0.0",properties:{params:{defaultValue:"1.0.0",multiple:"1.0.0",confirmHold:"1.0.0",confirmType:"1.0.0",maxLength:"1.0.0"}},success:{errMsg:"1.0.0"}});Wo=D("updateKeyboard",{paramsSchema:u.tuple(u.object({value:u.string()})),implement(e){P("updateKeyboardSync",e)}});k("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});Qo=D("hideKeyboard",{implement(){P("hideKeyboardSync")}});k("keyboard.hideKeyboard",{version:"1.0.0"});dr=N();dr.registerCommand("KeyboardSDK.showKeyboard",zo);dr.registerCommand("KeyboardSDK.updateKeyboard",Wo);dr.registerCommand("KeyboardSDK.hideKeyboard",Qo)});var as=fr(he=>{"use strict";E();X();ae();var Te=N(),Yo=F("levelFinished",{paramsSchema:u.tuple(u.string(),u.object({result:u.boolean(),duration:u.number()})),implement:(e,t)=>g(he,null,function*(){let{result:r,duration:n}=t,s=[];s.push(j.tracker("LevelFinished",{levelId:e,result:r,duration:n})),s.push(j.reporter({event:"COMPLETE_GAME_LEVEL"})),yield Promise.all(s)})}),Xo=F("taskFinished",{paramsSchema:u.tuple(u.string(),u.object({duration:u.number()})),implement:(e,t)=>g(he,null,function*(){let{duration:r}=t;return yield j.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})})}),Zo=F("levelUpgrade",{paramsSchema:u.tuple(u.string(),u.string()),implement:(e,t)=>g(he,null,function*(){let r=[];r.push(j.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),yield Promise.all(r)})}),ei=F("onHistoryUserLevel",{paramsSchema:u.tuple(u.number()),implement:e=>g(he,null,function*(){return yield j.reportToNative({event:"HistoryUserLevel",params:{level:e}})})}),ti=F("onHistoryUserScore",{paramsSchema:u.tuple(u.number()),implement:e=>g(he,null,function*(){return yield j.reportToNative({event:"HistoryUserScore",params:{score:e}})})}),ri=F("taskEvent",{paramsSchema:u.tuple(u.string(),u.object({tools:u.array(u.object({id:u.string(),name:u.string(),count:u.number(),description:u.string().optional(),price:u.object({amount:u.number(),unit:u.string()}).optional()})).optional(),awards:u.array(u.object({id:u.string(),name:u.string()})).optional()})),implement:(e,t)=>g(he,null,function*(){var n,s;let r=[];r.push(j.reportToNative({event:"TaskEvent",params:h({taskId:e},t)})),(s=(n=t.tools)==null?void 0:n.length)!=null&&s&&(r.push(j.reporter({event:"USE_GAME_ITEM"})),r.push(j.reportToNative({event:"UseGameItem",params:h({taskId:e},t)}))),yield Promise.all(r)})});Te.registerCommand("TaskTrackerSDK.levelFinished",Yo);Te.registerCommand("TaskTrackerSDK.taskFinished",Xo);Te.registerCommand("TaskTrackerSDK.levelUpgrade",Zo);Te.registerCommand("TaskTrackerSDK.historyUserLevel",ei);Te.registerCommand("TaskTrackerSDK.historyUserScore",ti);Te.registerCommand("TaskTrackerSDK.taskEvent",ri);k("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});k("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});k("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});k("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});k("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});k("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}})});var ni,si,cs,ls=f(()=>{"use strict";K();$();X();E();oe();k("login",{version:"1.0.0",properties:{force:"1.0.0"},success:{errMsg:"1.0.0",code:"1.0.0",token:"1.0.0",isLogin:"1.0.0"}});k("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});ni=F("login",{implement(){return g(this,null,function*(){var i;let{data:{isLogin:e}}=yield H("checkLoginAsync");if(e)return{isLogin:!0,token:(i=v.hostUserInfo)==null?void 0:i.token};Q("onLoginStateChange",({isLogin:a,token:c,uuid:l})=>{l==r&&s({isLogin:a,token:c})});let t=P("loginSync"),{data:{uuid:r}}=t;if(!r)throw me({code:-1,msg:"login failed"});let{promise:n,resolve:s}=new se,o=yield n;return v.onEnvConfigChanged({hostUserInfo:o}),te.emit("onLoginComplete",o),o})}}),si=F("checkSession",{implement(){return g(this,null,function*(){let{data:{isLogin:e}}=yield H("checkLoginAsync");return{isLogin:e}})}}),cs=N();cs.registerCommand("API.login",ni);cs.registerCommand("API.checkSession",si)});var kt,oi,Et,ii,ai,ci,li,ds=f(()=>{"use strict";E();X();er();ae();Ke();$();kt=N(),oi=()=>{let{data:e}=P("getNetworkStatusSync");return!!(e!=null&&e.isConnected)},Et=new Qe(V,{get:(e,t)=>Y(e,h({method:"GET",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data),post:(e,t,r)=>Y(e,h({method:"POST",responseType:"json",appendHostCookie:!0},r)).then(n=>n.response.data)},oi),ii=D("adInit",{implement:e=>{Et.init(e)}}),ai=D("adConfig",{implement:e=>{Et.adConfig(e)}}),ci=D("adBreak",{implement:e=>{Et.adBreak(e)}}),li=D("adUnit",{implement:e=>{Et.adUnit(e)}});kt.registerCommand("AdsSDK.init",ii);kt.registerCommand("AdsSDK.adConfig",ai);kt.registerCommand("AdsSDK.adBreak",ci);kt.registerCommand("AdsSDK.adUnit",li);k("AdsSDK.init",{version:"1.0.0"});k("AdsSDK.adConfig",{version:"1.0.0"});k("AdsSDK.adBreak",{version:"1.0.0"});k("AdsSDK.adUnit",{version:"1.0.0"})});var di,ui,us=f(()=>{"use strict";E();$();X();di=N(),ui=D("openSchemaSync",{paramsSchema:u.tuple(u.string()),implement:e=>{let t=P("openSchemaSync",{schema:e});if(t.errNo!==0)throw new Ct(t.errMsg,t.errNo)}});di.registerCommand("API.openSchemaSync",ui);k("openSchemaSync",{version:"1.1.9"})});var mi={};var fu,vu,ms=f(()=>{"use strict";Qn();fu=gr(Yn());ss();os();is();vu=gr(as());ls();ds();us()});var ps=Symbol.for("JOLIBOX_IMPLEMENT_INIT");if(window[ps])throw console.info("Jolibox Implement Already Initialized"),new Error("Jolibox Implement Already Initialized");window[ps]=!0;g(void 0,null,function*(){let[{config:e}]=yield Promise.all([Promise.resolve().then(()=>($n(),Hn)),Promise.resolve().then(()=>(ms(),mi)),Promise.resolve().then(()=>(ae(),Fn))]);e()});
19
+ `;e.textContent=s;let i=document.head||document.getElementsByTagName("head")[0];i.insertBefore(e,i.firstChild),document.documentElement.setAttribute("data-jolibox-root","")},n=()=>{function s(a){return y(this,null,function*(){let c=a instanceof URL?a.href:a,l=new Promise((u,m)=>{let p=new XMLHttpRequest;p.open("GET",c),p.responseType="arraybuffer",p.addEventListener("load",()=>u(p.response)),p.addEventListener("error",m),p.send()});try{let u=yield l;return new Response(u,{headers:new Headers([["Content-Type","application/wasm"]])}).clone()}catch(u){throw console.error("Failed to load wasm:",u),u}})}let i=window.fetch;window.fetch=(a,c)=>{let l=a instanceof URL?a.href:a.toString();return l.endsWith(".wasm")?s(l):i(a,c)}},o=()=>{e!=null&&e.parentNode&&(e.parentNode.removeChild(e),e=null),document.documentElement.removeAttribute("data-jolibox-root"),window.fetch=t};return r(),n(),o}var Ln=f(()=>{"use strict"});var ze,Bn=f(()=>{"use strict";ze=class{constructor(t){this.track=t;this.adBreakIsShowing=!1;this.reportPageJumpOut=()=>{this.track("AdBreakJumpOut",{context:"AdsActionDetection"})};this.reportPageHide=()=>{this.track("AdBreakHide",{context:"AdsActionDetection"})};window.addEventListener("visibilitychange",()=>{document.hidden&&this.adBreakIsShowing&&this.reportPageHide()}),window.addEventListener("beforeunload",r=>{this.adBreakIsShowing&&this.reportPageJumpOut()})}}});var jn,We,Jn=f(()=>{"use strict";jn="jolibox-sdk-ads-callbreak-timestamps",We=class{constructor(t,r,n,o){this.track=t;this.httpClient=r;this.checkNetwork=n;this.maxAllowedAdsForTime=8;this.bannedForTimeThreshold=6e4;this.bannedReleaseTime=6e4;this.isBanningForTime=!1;this.releaseBannedForTimeTimeout=null;this.maxAllowedAdsForSession=200;this.bannedForSessionThreshold=6e5;this.isBanningForSession=!1;this.initialThreshold=2e3;this._callAdsTimestampsForTime=[];this.callAdsTimestampsForSession=[];this.initTimestamp=0;this.initCallAdsTimestampsForTime=()=>{var t;try{let r=JSON.parse((t=window.localStorage.getItem(jn))!=null?t:"[]");Array.isArray(r)?this._callAdsTimestampsForTime=r:this._callAdsTimestampsForTime=[]}catch(r){this._callAdsTimestampsForTime=[]}};this.setReleaseBannedForTime=()=>{this.releaseBannedForTimeTimeout&&(window.clearTimeout(this.releaseBannedForTimeTimeout),this.releaseBannedForTimeTimeout=null),this.releaseBannedForTimeTimeout=window.setTimeout(()=>{this.isBanningForTime=!1,this.releaseBannedForTimeTimeout=null},this.bannedReleaseTime)};this.checkShouldBannedInitial=()=>{if(Date.now()-this.initTimestamp<=this.initialThreshold)return"BLOCK_INITIAL"};this.checkShouldBannedForSession=t=>{if(this.isBanningForSession)return"BANNED_FOR_SESSION";let r=Date.now();if(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.concat({timestamp:r,type:t}),this.callAdsTimestampsForSession.length!==1&&(this.callAdsTimestampsForSession.length>this.maxAllowedAdsForSession&&(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.slice(-this.maxAllowedAdsForSession)),this.callAdsTimestampsForSession.length===this.maxAllowedAdsForSession&&r-this.callAdsTimestampsForSession[0].timestamp<=this.bannedForSessionThreshold))return this.isBanningForSession=!0,"BANNED_FOR_SESSION"};this.checkShouldBannedForTime=t=>{if(this.isBanningForTime)return"WAITING_BANNED_RELEASE";let r=Date.now();if(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.concat({timestamp:r,type:t}),this.callAdsTimestampsForTime.length!==1&&(this.callAdsTimestampsForTime.length>this.maxAllowedAdsForTime&&(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.slice(-this.maxAllowedAdsForTime)),this.callAdsTimestampsForTime.length===this.maxAllowedAdsForTime&&r-this.callAdsTimestampsForTime[0].timestamp<=this.bannedForTimeThreshold))return this.isBanningForTime=!0,this.setReleaseBannedForTime(),"BANNED_FOR_TIME"};this.checkAdsDisplayPermission=t=>{if(!this.checkNetwork())return"NETWORK_NOT_OK";let r=this.checkShouldBannedInitial();if(r)return r;let n=this.checkShouldBannedForSession(t);if(n)return n;let o=this.checkShouldBannedForTime(t);return o||"ALLOWED"};var s,i,a,c,l,u;if(this.maxAllowedAdsForTime=(s=o==null?void 0:o.maxAllowedAdsForTime)!=null?s:8,this.bannedForTimeThreshold=(i=o==null?void 0:o.bannedForTimeThreshold)!=null?i:6e4,this.bannedReleaseTime=(a=o==null?void 0:o.bannedReleaseTime)!=null?a:6e4,this.maxAllowedAdsForSession=(c=o==null?void 0:o.maxAllowedAdsForSession)!=null?c:200,this.bannedForSessionThreshold=(l=o==null?void 0:o.bannedForSessionThreshold)!=null?l:6e5,this.initialThreshold=(u=o==null?void 0:o.initialThreshold)!=null?u:2e3,this.maxAllowedAdsForTime<=1)throw new Error("maxAllowedAdsForTime must be greater than 1");if(this.bannedForTimeThreshold<0)throw new Error("bannedForTimeThreshold must be greater than or equal to 0");if(this.bannedReleaseTime<this.bannedForTimeThreshold)throw new Error("bannedReleaseTime must be greater than or equal to bannedForTimeThreshold");if(this.initialThreshold<0)throw new Error("initialThreshold must be greater than or equal to 0");this.initCallAdsTimestampsForTime(),this.initTimestamp=Date.now()}get callAdsTimestampsForTime(){return this._callAdsTimestampsForTime}set callAdsTimestampsForTime(t){try{window.localStorage.setItem(jn,JSON.stringify(t))}catch(r){console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=t}report(t){this.track("PreventAdsCheating",{reason:t}),this.httpClient.post("/api/base/app-event",{data:{eventType:"PREVENT_ADS_CHEATING",adsInfo:{reason:t}}})}}});var Qe,$n=f(()=>{"use strict";J();Qe=class{constructor(t){this.httpClient=t;this.configs=null;this.firstRun=!0;this.init()}init(){return y(this,null,function*(){try{this.configs=yield this.httpClient.get("/api/fe-configs/js-sdk/ads-channel-config")}catch(t){}})}shouldBypassCallingInterstitial(){var r,n;let t;if(!this.configs)this.init(),t=!this.firstRun;else{let o=(r=g.channel)!=null?r:"",s=this.configs[o],i=(n=s==null?void 0:s.interstitialRate)!=null?n:1;t=Math.random()<i}return this.firstRun=!1,t}}});var ve,Ye,er=f(()=>{"use strict";Bn();Jn();J();$n();E();ve=new q,Ye=class{constructor(t,r,n){this.track=t;this.httpClient=r;this.checkNetwork=n;this.configured=!1;this.config={};this.getGameId=()=>g.mpId;this.getTestAdsMode=()=>g.testAdsMode;this.asyncLoad=()=>y(this,null,function*(){var i,a,c,l,u;let t="ca-pub-7171363994453626",r,n,o=window.encodeURIComponent(window.btoa((i=this.getGameId())!=null?i:"")),s=(a=this.getTestAdsMode())!=null?a:!1;try{let m=yield this.httpClient.get("/public/ads",{query:{objectId:o,testAdsMode:`${s}`}});t=(c=m.data)==null?void 0:c.clientId,r=(l=m.data)==null?void 0:l.channelId,n=(u=m.data)==null?void 0:u.unitId}catch(m){console.error("Failed to fetch client info",m)}this.clientId=t,this.channelId=r,this.unitId=n});this.asyncInit=t=>y(this,null,function*(){var o;if(typeof window=="undefined")return;yield this.asyncLoad();let r="google-adsense",n=(o=this.getTestAdsMode())!=null?o:!1;if(!document.getElementById(r)&&this.clientId){let s=document.createElement("script");s.id=r,s.async=!0,s.crossOrigin="anonymous",s.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`,n&&s.setAttribute("data-adbreak-test","on"),this.channelId&&s.setAttribute("data-ad-channel",this.channelId),document.head.appendChild(s),this.track("LoadAdsenseCompleted",null)}});this.push=(t={})=>{window.adsbygoogle.push(t)};this.wrapAdBreakParams=t=>{if((n=>n.type==="preroll")(t)){ve.emit("isAdShowing",!0);let n=t.adBreakDone,o=s=>{ve.emit("isAdShowing",!1),n&&n(s)};return P(h({},t),{adBreakDone:o})}else{let n=t.beforeAd,o=t.afterAd,s=()=>{var a;ve.emit("isAdShowing",!0),this.track("CallBeforeAd",{type:t.type,name:(a=t.name)!=null?a:""}),n&&n()},i=()=>{var a;ve.emit("isAdShowing",!1),this.track("CallAfterAd",{type:t.type,name:(a=t.name)!=null?a:""}),o&&o()};return P(h({},t),{beforeAd:s,afterAd:i})}};this.adConfig=t=>{let o=t,{onReady:r}=o,n=ce(o,["onReady"]);this.track("CallAdConfig",n),this.configured?console.warn("Ad config already set, skipping"):(this.configured=!0,this.push(t))};this.adBreak=t=>{var c,l,u,m;if(!this.getGameId()){console.warn("Game ID is not set, skip calling adBreak");return}if(t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){(c=t.adBreakDone)==null||c.call(t,{breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}let r=this.antiCheating.checkAdsDisplayPermission(t.type==="reward"?"reward":"interstitial");switch(r){case"NETWORK_NOT_OK":case"BANNED_FOR_SESSION":console.warn("Ads not allowed",r),(l=t.adBreakDone)==null||l.call(t,{breakType:t.type,breakName:r,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"}),this.antiCheating.report(r);return;case"BLOCK_INITIAL":case"BANNED_FOR_TIME":case"WAITING_BANNED_RELEASE":console.warn("Ads not allowed",r),(u=t.adBreakDone)==null||u.call(t,{breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"}),this.antiCheating.report(r);return;default:break}let n=t.type,o=t.adBreakDone,s=p=>{var b;this.adsActionDetection.adBreakIsShowing=!1,this.track("CallAdBreakDone",{breakType:p.breakType,breakName:(b=p.breakName)!=null?b:"",breakFormat:p.breakFormat,breakStatus:p.breakStatus}),o&&o(p)};if(t.adBreakDone=s,t.type==="reward"){let p=t.beforeReward,b=T=>()=>{this.track("CallShowAdFn",null),T()},R=T=>{p&&p(b(T))};t.beforeReward=R}let i;switch(n){case"preroll":i={type:n};break;case"start":case"pause":case"next":case"browse":case"reward":i={type:n,name:(m=t.name)!=null?m:""};break}this.adsActionDetection.adBreakIsShowing=!0,this.track("CallAdBreak",i);let a=this.wrapAdBreakParams(t);this.push(a),window.JoliTesterBridge&&console.log("joli-fullscreen-ad-show")};this.adUnit=t=>y(this,null,function*(){var p,b,R,T;if(this.track("CallAdUnit",{adFormat:(b=(p=t.adFormat)==null?void 0:p.toString())!=null?b:null,fullWidthResponsive:(R=t.fullWidthResponsive)!=null?R:null}),this.clientId||(yield this.asyncLoad()),document.querySelector("#jolibox-ads")){console.warn("Ad unit already set, skipping");return}let{el:r,slot:n,adFormat:o,fullWidthResponsive:s,style:i}=t,a;if(!r)throw new Error("targeting element is required");if(typeof r=="string"?a=document.querySelector(r):a=r,!a)throw new Error("targeting element not found");let c=n;if(c||(c=this.unitId),!c)throw new Error("slot is required");let l=typeof o=="object"&&Array.isArray(o)?o.join(", "):o,u=document.createElement("ins");if(u.className="adsbygoogle",u.id="jolibox-ads",u.style.display="block",u.setAttribute("data-ad-client",this.clientId),u.setAttribute("data-ad-slot",c),l&&u.setAttribute("data-ad-format",l),s&&u.setAttribute("data-full-width-responsive",s),i&&u.setAttribute("style",i),(T=this.getTestAdsMode())!=null?T:!1){let v=document.createElement("div");v.style.position="absolute",v.style.top="0",v.style.left="0",v.style.width="100%",v.style.height="100%",v.style.display="flex",v.style.justifyContent="center",v.style.alignItems="center",v.style.backgroundColor="rgba(0, 0, 0, 0.5)",v.style.color="white",v.innerHTML="Test Ad",u.style.position="relative",a.appendChild(u),u.appendChild(v)}else a.appendChild(u),new MutationObserver(S=>{S.forEach(x=>{if(x.type==="attributes"&&x.attributeName==="data-ad-status"){let w=u.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:w!=null?w:"null"})}})}).observe(u,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})});this.antiCheating=new We(t,r,n),this.adsActionDetection=new ze(this.track),this.channelPolicy=new Qe(r)}init(t){this.track("CallAdsInit",null),typeof window!="undefined"&&(this.config=t!=null?t:{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}}});function Hn(){return y(this,null,function*(){let{data:e}=_("envSync"),{orientation:t,webviewId:r}=e,n={__mpType:"miniApp",__transparent:!0,__orientation:t!=null?t:"VERTICAL",__showStatusBar:!1,__shouldInterupt:!1,__showCapsuleButton:!1};r&&(n=P(h({},n),{__from:r}));let o=g.encodeJoliSourceQuery(n),i=`${g.testMode,"https://G32115508989327465281365749294.app.jolibox.com"}/recommended-guide/${g.mpId}?appId=${g.mpId}&joliSource=${o}&navigationStyle=present`,a=new Q;return cn("onRetentionResult",({shouldStay:c})=>{a.resolve(c)}),setTimeout(()=>{_("openSchemaSync",{schema:i})},0),a.promise})}var Vn=f(()=>{"use strict";J();j();E()});var qn={};gr(qn,{config:()=>Is});function Es(){re.on("onDocumentReady",()=>{var e;(e=ie)==null||e.onDocumentReady(window.location.href),K("onDocumentReady",{start_timestamp:et,timestamp:Date.now()})})}function Ss(e){g.mpType==="game"&&$.start(e)}function ws(){Y("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&g.onEnvConfigChanged({hostUserInfo:e}),re.emit("LifecycleEvent.onReady",h({},g.hostUserInfo?g.hostUserInfo:{isLogin:!1})),K("joliboxServiceReady",{start_timestamp:et,timestamp:Date.now()}),Ss(t)}),Y("onBeforeExit",({uuid:e})=>{var t;(t=ie)==null||t.doExit(e)})}function Is(){et=Date.now(),ws(),Es(),Xe=Mn()}var Xe,Kn,Ze,et,Gn=f(()=>{"use strict";j();$e();J();E();ae();Ln();er();Vn();z.onReady(()=>{});Kn=()=>{K("onBeforeExit",{timestamp:Date.now()}),Xe==null||Xe(),$.close(Date.now()-et)};z.doExit(()=>y(void 0,null,function*(){return Ze?!0:Ie(g.shouldInterupt)?(g.shouldInterupt||Kn(),g.shouldInterupt):(yield Hn())?!0:(Kn(),!1)}));Ze=!1;ve.on("isAdShowing",e=>{Ze=e,Ie(Ze)&&_("updateContainerConfigSync",{displayCapsuleButton:!Ze,webviewId:g.webviewId})})});function zn(e){let t=Ot.config[e];return t||(t={},Ot.config[e]=t),(r,n)=>{if(t[r]){H.warn(`[can i use] ${r} already registered`);return}t[r]=h({},n)}}var Wn=f(()=>{"use strict";E()});function tr(e){Qn=e}function tt(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>tt(t)):Object.keys(e).reduce((t,r)=>(t[r]=tt(e[r]),t),{})}function ne(e){return typeof e=="number"}function rr(e){let t=nr(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function nr(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Qn,F,rt,nt,ot,st,be,it,at,ct,lt,dt,ut,mt,pt,ft,ht,gt,yt,or=f(()=>{"use strict";Qn=!1;F=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Qn)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${rr(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return tt(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:tt(this._default)}optional(){return this._optional=!0,this}};rt=class extends F{validate(t){return this._optional&&t===void 0?!0:ne(t)?ne(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):ne(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):ne(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},nt=class extends F{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},ot=class extends F{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(ne(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(ne(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},st=class extends F{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},be=class extends F{validate(t){return!0}},it=class extends F{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},at=class extends F{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},ct=class extends F{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},lt=class extends F{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(n=>JSON.stringify(n)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${rr(t)}`)}return!0}},dt=class extends F{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(ne(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(ne(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(ne(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let n=this._item;if(!n)return!0;let o=!0;if(r.forEach((s,i)=>{if(n.path=`${this.path}[${i}]`,n.errors=this.errors,s===void 0&&n.hasDefault){r[i]=n.defaultValue;return}n.validate(s)||(n.hasFallback?r[i]=n.fallbackValue:o=!1)}),this._uniqueItems){let s=new Map;for(let i in r)s.has(r[i])?o=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${s.get(r[i])}] and ${this.path}[${i}] are identical)`):s.set(r[i],i)}return o}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},ut=class extends F{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(nr(r)!=="object")return this.fail({expect:"object",actual:r});let o=r,s=this._value;s.errors=this.errors;let i=!0;for(let a in o){let c=o[a];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(a)?s.path=`${this.path}.${a}`:s.path=`${this.path}["${a}"]`,!(c===void 0&&s._optional)){if(c===void 0&&s.hasDefault){o[a]=s.defaultValue;continue}s.validate(c)||(s.hasFallback?o[a]=s.fallbackValue:i=!1)}}return i}},mt=class extends F{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(nr(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,o=!0;for(let s in this._object){let i=n[s],a=this._object[s];if(a.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(s)?a.path=`${this.path}.${s}`:a.path=`${this.path}["${s}"]`,!(a._optional&&i===void 0)){if(i===void 0&&a.hasDefault){n[s]=a.defaultValue;continue}a.validate(i)||(a.hasFallback?n[s]=a.fallbackValue:o=!1)}}return o}},pt=class extends F{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:rr(this.value),actual:r}):!0}},ft=class extends F{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,o=this._items.length;for(let s=0;s<o;s++){let i=this._items[s];if(i.errors=[],i.path=this.path,!i.validate(t))r.push(i.errors.join("; "));else if(!n){n=!0;break}}if(!n){let s=r.join(`
20
+ or `);this.errors.push(s)}return n}},ht=class extends F{constructor(...t){super(),this._items=t;let r=0,n=t.length-1;for(;n>=0;n--){let o=t[n];if(o._optional||o.hasDefault)r+=1;else break}this._minItems=t.length-r}validate(t){if(t===void 0&&this._optional)return!0;if(!Array.isArray(t))return this.fail({expect:"array",actual:t});if(t.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let r=!0;return this._items.forEach((n,o)=>{if(n.path=`${this.path}[${o}]`,n.errors=this.errors,t[o]===void 0&&n.hasDefault){t[o]=n.defaultValue;return}n.validate(t[o])||(n.hasFallback?t[o]=n._fallback:r=!1)}),r}},gt=class extends F{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},yt=class extends F{constructor(t){super(),this._ctor=t}validate(t){return t===void 0&&this._optional||t instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:t})}}});function sr(e,t,r="param"){if(e.errors=[],e.path=r,tr(!0),!e.validate(t)){let n=e.errors.join(`
21
+ `);throw e.errors.length=0,tr(!1),new TypeError(n)}}var d,ir=f(()=>{"use strict";or();or();d={object(e){return new mt(e)},array(e){return new dt(e)},tuple(...e){return new ht(...e)},literal(e){return new pt(e)},or(...e){return new ft(...e)},symbol(){return new st},record(e){return new ut(e)},function(){return new ct},boolean(){return new nt},string(){return new ot},number(){return new rt},undefined(){return new it},null(){return new at},unknown(){return new be},any(){return new be},as(){return new be},arraybuffer(){return new gt},enum(...e){return new lt(...e)},typedarray(e){return new yt(e)}}});var vt,Yn,Xn=f(()=>{"use strict";E();G();ir();se();vt=1,Yn=e=>{function t(n,o){return(...s)=>{var m,p,b,R;let i=Date.now(),a={method:n,trace_id:vt};vt+=1;let c="SUCCESS",l=`${n}:ok`,u=0;try{if(o.paramsSchema)try{sr(o.paramsSchema,s,"params")}catch(x){throw Mt(`${n}:fail ${x.message}`)}let T=o.implement(...s),v=T,S=`${n}:ok`;if(T&&"code"in T){let{code:x,data:w,message:U}=T;c=x,v=w,S=U}return{code:c,message:S,data:v}}catch(T){let v=T;u=(p=(m=v.code)!=null?m:v.errNo)!=null?p:2e3,c="FAILURE";let S=(R=(b=v.message)!=null?b:v.errMsg)!=null?R:`${T}`;return l=`${n}:${c} ${S.replace(/^\S+:(fail|cancel)\s?/,"")}`,M(new Ae(l,u)),{code:c,message:l}}finally{let T=Date.now()-i;e("apiInvoked",P(h({},a),{duration:T,status:c}))}}}function r(n,o){return(...s)=>y(this,null,function*(){var p,b,R,T;let i=Er(s)?s:[s],a=Date.now(),c={method:n,trace_id:vt};vt+=1;let l=`${n}:ok`,u="SUCCESS",m={code:u,message:l};try{if(o.paramsSchema)try{sr(o.paramsSchema,i,"params")}catch(x){throw Mt(x.message)}let S=yield o.implement(...i);if(S&&"code"in S){let{code:x,data:w,message:U}=S;u=x,l=U,S=w}return Object.assign(m,{code:u,message:l,data:S}),m}catch(v){let S=v,x=(b=(p=S.code)!=null?p:S.errNo)!=null?b:2e3;u="FAILURE";let w=(T=(R=S.message)!=null?R:S.errMsg)!=null?T:`${v}`,U=`${n}:${u} ${w.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(m,{code:u,message:U}),M(new Ae(U,x)),m}finally{let v=Date.now()-a;e("apiInvoked",P(h({},c),{duration:v,status:u}))}})}return{createAPI:r,createSyncAPI:t}}});var D,N,k,Z=f(()=>{"use strict";Wn();ae();Xn();ir();({createAPI:D,createSyncAPI:N}=Yn(K)),k=zn("native")});var Zn,Rs,As,xs,Ps,eo=f(()=>{"use strict";E();Z();j();Zn=O(),Rs="env",As="getSystemInfoSync",xs=N(As,{implement:()=>{var r;let e=_("envSync"),{data:t}=e;return{system:t.deviceInfo.system,platform:t.deviceInfo.platform,version:t.sdkInfo.jssdkVersion,pixelRatio:t.deviceInfo.pixelRatio,language:t.deviceInfo.lang,brand:t.deviceInfo.brand,appName:(r=t.hostInfo)==null?void 0:r.appName,SDKVersion:t.sdkInfo.jssdkVersion}}}),Ps=N(Rs,{implement:()=>{var t;let e=_("envSync");return(t=e==null?void 0:e.data)!=null?t:void 0}});Zn.registerCommand("API.getSystemInfoSync",xs);Zn.registerCommand("API.env",Ps);k("env",{version:"1.0.0"});k("getSystemInfoSync",{version:"1.0.0"})});var to=hr(ar=>{"use strict";E();Z();G();j();ae();J();var Cs="exitGame",Ns="onReady",Os="onJoliboxShow",Fs="onJoliboxHide",bt=O(),Tt=Me(M),Ds=D(Cs,{paramsSchema:d.tuple(d.function(),d.boolean().optional().default(!1)),implement:(e,t=!1)=>y(ar,null,function*(){Tt(e).call(ar),Ie(g.shouldInterupt)&&!g.shouldInterupt&&g.from&&an("onRetentionResult",{shouldStay:t},g.from,!0),yield V("exitAppAsync")})}),Us=N(Os,{paramsSchema:d.tuple(d.function()),implement(e){let t=Tt(e);Y("onJoliboxEnterForeground",()=>{t.call(this),xe.emit("visible",!0)})}}),Ms=N(Fs,{paramsSchema:d.tuple(d.function()),implement(e){let t=Tt(e);Y("onJoliboxEnterBackground",()=>{t.call(this),xe.emit("visible",!1)})}}),Ls=N(Ns,{paramsSchema:d.tuple(d.function()),implement(e){let t=Tt(e);re.on("LifecycleEvent.onReady",r=>{t(r)})}});bt.registerCommand("LifecycleSDK.exit",Ds);bt.registerCommand("LifecycleSDK.onReady",Ls);bt.registerCommand("LifecycleSDK.onJoliboxShow",Us);bt.registerCommand("LifecycleSDK.onJoliboxHide",Ms);k("lifeCycle.exit",{version:"1.0.0"});k("lifeCycle.onReady",{version:"1.0.0"});k("lifeCycle.onJoliboxShow",{version:"1.0.0"});k("lifeCycle.onJoliboxHide",{version:"1.0.0"})});function ro(e){let t={};if(!B(e))return t;for(let[r,n]of Object.entries(e)){let o=r.toLocaleLowerCase();n?typeof n=="object"?t[o]=Object.prototype.toString.call(n):t[o]=String(n):t[o]=""}return t}function no(e="GET"){if(e==="")return"POST";let t=e.toUpperCase();return["GET","OPTIONS","HEAD","POST","PUT","DELETE","TRACE","CONNECT","PATCH"].includes(t)?t:"GET"}function oo(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function so(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!B(r))return e;let[n,o=""]=e.split("?"),s=JSON.stringify(h(h({},JSON.parse(o)),r));return`${n}?${s}`}var io=f(()=>{"use strict";E()});var Bs,js,cr,lr,ao,Js,$s,Hs,co=f(()=>{"use strict";se();Xt();Z();io();E();G();Bs=15,js=Ke("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),cr=0,lr=[],ao=Me(M),Js=(e,t)=>{let r=e.filter(t),n=e.filter(o=>!t(o));return e.length=0,e.push(...n),r},$s=e=>{let t=new Q,r=()=>{};return D("request",{paramsSchema:d.tuple(d.object({url:d.string(),method:d.string(),header:d.object(),data:d.object().optional(),query:d.object().optional(),dataType:d.string().default("json"),responseType:d.string().default("text"),enableCache:d.boolean().default(!1),appendHostCookie:d.boolean().default(!0),timeout:d.number().default(3e4),success:d.function(),fail:d.function()})),implement(o){let s=()=>y(this,null,function*(){var a,c;let i=ao(o.fail);try{if(cr+=1,t.state!=="pending")return;let{data:l,dataType:u,responseType:m,enableCache:p,appendHostCookie:b}=o,R=ro(o.header),T=no(o.method),v=oo(o.timeout),S=so(o.url,T,l),x=ao(o.success),w=Object.assign({},o,{method:T,header:R,data:T==="GET"||T==="HEAD"?void 0:l,enableCache:p,query:(a=o.query)!=null?a:{},dataType:u,responseType:m,appendHostCookie:b});v&&(w.timeout=v);let U=js(S,w);{let{response:I}=yield U,{code:A,data:ke,message:oe}=I;t.resolve({code:A!=null?A:"SUCCESS",data:ke,message:oe!=null?oe:"request:ok"}),x({code:"SUCCESS",message:"request:ok",data:ke})}}catch(l){t.reject(l),i({code:"FAILURE",message:"httpRequst: failed"})}finally{cr-=1,(c=lr.shift())==null||c()}});return cr>=Bs?(r=()=>{Js(lr,i=>i===s)},lr.push(s)):s(),t.promise}})(e),{abort(){t.reject(me({code:-1,msg:"request:fail abort"})),r()}}},Hs=O();Hs.registerCommand("HttpSDK.request",$s);k("request",{version:"1.0.0"})});function Ws(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return zs.includes(t)?t:""}function Qs(e,t){try{switch(t){case"string":return e;case"object":return JSON.parse(e);case"number":return parseFloat(e);case"boolean":return e==="true";default:return""}}catch(r){return""}}function Ys(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch(r){return""}}var kt,Vs,Ks,qs,Gs,Jd,$d,zs,lo=f(()=>{"use strict";Z();j();E();qe();J();kt=O(),Vs=D("getLocalStorage",{paramsSchema:d.tuple(d.string()),implement(e){return y(this,null,function*(){let{response:t}=yield X(`/api/games/user-storage/${g.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:o}}=yield t;if(r==="SUCCESS")return{code:r,message:n,data:o==null?void 0:o.value};try{let{data:{data:s,dataType:i}}=yield V("getLocalStorageAsync",{key:e}),a=Qs(s,i);return{code:r,message:`${n}. fallback to native`,data:a}}catch(s){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}})}});kt.registerCommand("StorageSDK.getItem",Vs);k("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});Ks=D("setStorage",{paramsSchema:d.tuple(d.string(),d.or(d.string(),d.boolean(),d.number())),implement(e,t){return y(this,null,function*(){let r=g.mpId,n=typeof t=="string"?t:String(t),{response:o}=yield X(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:s,message:i}}=o,a=Ws(t),c=Ys(t,a);return yield V("setLocalStorageAsync",{key:e,data:c,dataType:a}),s=="SUCCESS"?{code:s,message:i}:{code:s,message:`${i}. fallback to native`}})}});kt.registerCommand("StorageSDK.setItem",Ks);k("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});qs=D("removeStorage",{paramsSchema:d.tuple(d.string()),implement(e){return y(this,null,function*(){let t=g.mpId,{response:r}=yield X(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:o}}=r;return yield V("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:o}:{code:n,message:"[Jolibox SDK] remove item succ"}})}});kt.registerCommand("StorageSDK.removeItem",qs);k("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});Gs=D("clearStorage",{implement(){return y(this,null,function*(){let e=g.mpId,{response:t}=yield X(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});V("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}})}});kt.registerCommand("StorageSDK.clear",Gs);k("storage.clear",{version:"1.0.0"});Jd=D("getStorageInfo",{implement(){return y(this,null,function*(){let{data:e}=yield V("getStorageInfoAsync");return e})}});k("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});$d=N("getStorageInfoSync",{implement(){return _("getStorageInfoSync")}}),zs=["string","number","boolean","object",""]});var Xs,Zs,ei,dr,uo=f(()=>{"use strict";E();j();Z();Xs=N("showKeyboard",{paramsSchema:d.tuple(d.object({defaultValue:d.string().optional().default(""),multiple:d.boolean().optional().default(!1),maxLength:d.unknown().optional().default(1e5)})),implement(e){var n;let t=Math.floor((n=Number(e.maxLength))!=null?n:1e5),{defaultValue:r}=e;r&&t&&(r=r.slice(0,t)),_("showKeyboardSync",P(h({},e),{defaultValue:r,maxLength:t}))}});k("keyboard.showKeyboard",{version:"1.0.0",properties:{params:{defaultValue:"1.0.0",multiple:"1.0.0",confirmHold:"1.0.0",confirmType:"1.0.0",maxLength:"1.0.0"}},success:{errMsg:"1.0.0"}});Zs=N("updateKeyboard",{paramsSchema:d.tuple(d.object({value:d.string()})),implement(e){_("updateKeyboardSync",e)}});k("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});ei=N("hideKeyboard",{implement(){_("hideKeyboardSync")}});k("keyboard.hideKeyboard",{version:"1.0.0"});dr=O();dr.registerCommand("KeyboardSDK.showKeyboard",Xs);dr.registerCommand("KeyboardSDK.updateKeyboard",Zs);dr.registerCommand("KeyboardSDK.hideKeyboard",ei)});var mo=hr(he=>{"use strict";E();Z();ae();var Te=O(),ti=D("levelFinished",{paramsSchema:d.tuple(d.string(),d.object({result:d.boolean(),duration:d.number()})),implement:(e,t)=>y(he,null,function*(){let{result:r,duration:n}=t,o=[];o.push($.tracker("LevelFinished",{levelId:e,result:r,duration:n})),o.push($.reporter({event:"COMPLETE_GAME_LEVEL"})),yield Promise.all(o)})}),ri=D("taskFinished",{paramsSchema:d.tuple(d.string(),d.object({duration:d.number()})),implement:(e,t)=>y(he,null,function*(){let{duration:r}=t;return yield $.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})})}),ni=D("levelUpgrade",{paramsSchema:d.tuple(d.string(),d.string()),implement:(e,t)=>y(he,null,function*(){let r=[];r.push($.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),yield Promise.all(r)})}),oi=D("onHistoryUserLevel",{paramsSchema:d.tuple(d.number()),implement:e=>y(he,null,function*(){return yield $.reportToNative({event:"HistoryUserLevel",params:{level:e}})})}),si=D("onHistoryUserScore",{paramsSchema:d.tuple(d.number()),implement:e=>y(he,null,function*(){return yield $.reportToNative({event:"HistoryUserScore",params:{score:e}})})}),ii=D("taskEvent",{paramsSchema:d.tuple(d.string(),d.object({tools:d.array(d.object({id:d.string(),name:d.string(),count:d.number(),description:d.string().optional(),price:d.object({amount:d.number(),unit:d.string()}).optional()})).optional(),awards:d.array(d.object({id:d.string(),name:d.string()})).optional()})),implement:(e,t)=>y(he,null,function*(){var n,o;let r=[];r.push($.reportToNative({event:"TaskEvent",params:h({taskId:e},t)})),(o=(n=t.tools)==null?void 0:n.length)!=null&&o&&(r.push($.reporter({event:"USE_GAME_ITEM"})),r.push($.reportToNative({event:"UseGameItem",params:h({taskId:e},t)}))),yield Promise.all(r)})});Te.registerCommand("TaskTrackerSDK.levelFinished",ti);Te.registerCommand("TaskTrackerSDK.taskFinished",ri);Te.registerCommand("TaskTrackerSDK.levelUpgrade",ni);Te.registerCommand("TaskTrackerSDK.historyUserLevel",oi);Te.registerCommand("TaskTrackerSDK.historyUserScore",si);Te.registerCommand("TaskTrackerSDK.taskEvent",ii);k("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});k("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});k("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});k("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});k("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});k("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}})});var ai,ci,po,fo=f(()=>{"use strict";J();j();Z();E();se();k("login",{version:"1.0.0",properties:{force:"1.0.0"},success:{errMsg:"1.0.0",code:"1.0.0",token:"1.0.0",isLogin:"1.0.0"}});k("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});ai=D("login",{implement(){return y(this,null,function*(){var i;let{data:{isLogin:e}}=yield V("checkLoginAsync");if(e)return{isLogin:!0,token:(i=g.hostUserInfo)==null?void 0:i.token};Y("onLoginStateChange",({isLogin:a,token:c,uuid:l})=>{l==r&&o({isLogin:a,token:c})});let t=_("loginSync"),{data:{uuid:r}}=t;if(!r)throw me({code:-1,msg:"login failed"});let{promise:n,resolve:o}=new Q,s=yield n;return g.onEnvConfigChanged({hostUserInfo:s}),re.emit("onLoginComplete",s),s})}}),ci=D("checkSession",{implement(){return y(this,null,function*(){let{data:{isLogin:e}}=yield V("checkLoginAsync");return{isLogin:e}})}}),po=O();po.registerCommand("API.login",ai);po.registerCommand("API.checkSession",ci)});var Et,li,St,di,ui,mi,pi,ho=f(()=>{"use strict";E();Z();er();ae();qe();j();Et=O(),li=()=>{let{data:e}=_("getNetworkStatusSync");return!!(e!=null&&e.isConnected)},St=new Ye(K,{get:(e,t)=>X(e,h({method:"GET",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data),post:(e,t,r)=>X(e,h({method:"POST",responseType:"json",appendHostCookie:!0},r)).then(n=>n.response.data)},li),di=N("adInit",{implement:e=>{St.init(e)}}),ui=N("adConfig",{implement:e=>{St.adConfig(e)}}),mi=N("adBreak",{implement:e=>{St.adBreak(e)}}),pi=N("adUnit",{implement:e=>{St.adUnit(e)}});Et.registerCommand("AdsSDK.init",di);Et.registerCommand("AdsSDK.adConfig",ui);Et.registerCommand("AdsSDK.adBreak",mi);Et.registerCommand("AdsSDK.adUnit",pi);k("AdsSDK.init",{version:"1.0.0"});k("AdsSDK.adConfig",{version:"1.0.0"});k("AdsSDK.adBreak",{version:"1.0.0"});k("AdsSDK.adUnit",{version:"1.0.0"})});var ur,fi,hi,gi,go=f(()=>{"use strict";E();j();Z();J();ur=O(),fi=N("openSchemaSync",{paramsSchema:d.tuple(d.string()),implement:e=>{let t=e;e.match(/^https?:\/\//)||(t=`https://${g.mpId}.app.jolibox.com${e.startsWith("/")?"":"/"}${e}`);let r=_("openSchemaSync",{schema:t});if(r.errNo!==0)throw new Re(r.errMsg,r.errNo)}}),hi=N("openPageSync",{paramsSchema:d.tuple(d.string()),implement:e=>{let{errNo:t,errMsg:r,data:n}=_("openPageSync",{url:e});if(t!==0||!n)throw new Re(r,t);return{webviewId:n.webviewId}}}),gi=N("closePageSync",{paramsSchema:d.tuple(d.number()),implement:e=>{let{errNo:t,errMsg:r}=_("closePageSync",{webviewId:e});if(t!==0)throw new Re(r,t)}});ur.registerCommand("RouterSDK.openSchema",fi);ur.registerCommand("RouterSDK.openPage",hi);ur.registerCommand("RouterSDK.closePage",gi);k("router.openSchema",{version:"1.1.10"});k("router.openPage",{version:"1.1.10"});k("router.closePage",{version:"1.1.10"})});var yi={};var Iu,xu,yo=f(()=>{"use strict";eo();Iu=yr(to());co();lo();uo();xu=yr(mo());fo();ho();go()});var vo=Symbol.for("JOLIBOX_IMPLEMENT_INIT");if(window[vo])throw console.info("Jolibox Implement Already Initialized"),new Error("Jolibox Implement Already Initialized");window[vo]=!0;y(void 0,null,function*(){let[{config:e}]=yield Promise.all([Promise.resolve().then(()=>(Gn(),qn)),Promise.resolve().then(()=>(yo(),yi)),Promise.resolve().then(()=>(ae(),Un))]);e()});
@@ -1,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.1.11-beta.2 clean
3
+ > @jolibox/implement@1.1.11-beta.3 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.1.11-beta.2 build:esm
7
+ > @jolibox/implement@1.1.11-beta.3 build:esm
8
8
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
9
9
 
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@jolibox/implement",
3
3
  "description": "This project is Jolibox JS-SDk implement for Native && H5",
4
- "version": "1.1.11-beta.2",
4
+ "version": "1.1.11-beta.3",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "@jolibox/common": "1.1.11-beta.2",
10
- "@jolibox/types": "1.1.11-beta.2",
9
+ "@jolibox/common": "1.1.11-beta.3",
10
+ "@jolibox/types": "1.1.11-beta.3",
11
11
  "localforage": "1.10.0",
12
12
  "web-vitals": "4.2.4"
13
13
  },
@@ -1,14 +1,21 @@
1
1
  import { createCommands, UserCustomError } from '@jolibox/common';
2
2
  import { invokeNative } from '../bootstrap/bridge';
3
3
  import { createSyncAPI, t, registerCanIUse } from './base';
4
+ import { context } from '@/common/context';
4
5
 
5
6
  const commands = createCommands();
6
7
 
7
8
  const openSchemaSync = createSyncAPI('openSchemaSync', {
8
9
  paramsSchema: t.tuple(t.string()),
9
10
  implement: (schema) => {
11
+ // Add compatibility logic for incomplete URLs
12
+ let finalSchema = schema;
13
+ if (!schema.match(/^https?:\/\//)) {
14
+ finalSchema = `https://${context.mpId}.app.jolibox.com${schema.startsWith('/') ? '' : '/'}${schema}`;
15
+ }
16
+
10
17
  const res = invokeNative('openSchemaSync', {
11
- schema
18
+ schema: finalSchema
12
19
  });
13
20
  if (res.errNo !== 0) {
14
21
  throw new UserCustomError(res.errMsg, res.errNo);
@@ -16,8 +23,39 @@ const openSchemaSync = createSyncAPI('openSchemaSync', {
16
23
  }
17
24
  });
18
25
 
19
- commands.registerCommand('API.openSchemaSync', openSchemaSync);
26
+ const openPageSync = createSyncAPI('openPageSync', {
27
+ paramsSchema: t.tuple(t.string()),
28
+ implement: (page) => {
29
+ const { errNo, errMsg, data } = invokeNative('openPageSync', { url: page });
30
+ if (errNo !== 0 || !data) {
31
+ throw new UserCustomError(errMsg, errNo);
32
+ }
33
+ return { webviewId: data.webviewId };
34
+ }
35
+ });
36
+
37
+ const closePageSync = createSyncAPI('closePageSync', {
38
+ paramsSchema: t.tuple(t.number()),
39
+ implement: (webviewId) => {
40
+ const { errNo, errMsg } = invokeNative('closePageSync', { webviewId });
41
+ if (errNo !== 0) {
42
+ throw new UserCustomError(errMsg, errNo);
43
+ }
44
+ }
45
+ });
46
+
47
+ commands.registerCommand('RouterSDK.openSchema', openSchemaSync);
48
+ commands.registerCommand('RouterSDK.openPage', openPageSync);
49
+ commands.registerCommand('RouterSDK.closePage', closePageSync);
50
+
51
+ registerCanIUse('router.openSchema', {
52
+ version: '1.1.10'
53
+ });
54
+
55
+ registerCanIUse('router.openPage', {
56
+ version: '1.1.10'
57
+ });
20
58
 
21
- registerCanIUse('openSchemaSync', {
22
- version: '1.1.9'
59
+ registerCanIUse('router.closePage', {
60
+ version: '1.1.10'
23
61
  });
@@ -42,11 +42,11 @@ RuntimeLoader.doExit(async () => {
42
42
  return context.shouldInterupt;
43
43
  }
44
44
 
45
- // const stay = await openRetentionSchema();
46
- // if (stay) {
47
- // // 挽留成功,打断退出
48
- // return true;
49
- // }
45
+ const stay = await openRetentionSchema();
46
+ if (stay) {
47
+ // 挽留成功,打断退出
48
+ return true;
49
+ }
50
50
 
51
51
  // 退出,对应上报
52
52
  //埋点上报
@@ -1,7 +1,6 @@
1
1
  import { context } from '@/common/context';
2
2
  import { invokeNative, subscribe } from './bridge';
3
3
  import { Deferred } from '@jolibox/common';
4
-
5
4
  export async function openRetentionSchema() {
6
5
  const { data } = invokeNative('envSync');
7
6
  const { orientation, webviewId } = data;
@@ -11,7 +10,8 @@ export async function openRetentionSchema() {
11
10
  // set entryPath
12
11
  __orientation: orientation ?? 'VERTICAL', // 默认竖屏
13
12
  __showStatusBar: false,
14
- __shouldInterupt: false
13
+ __shouldInterupt: false,
14
+ __showCapsuleButton: false
15
15
  };
16
16
  if (webviewId) {
17
17
  joliPayload = {
@@ -22,8 +22,10 @@ export async function openRetentionSchema() {
22
22
 
23
23
  const joliSource = context.encodeJoliSourceQuery(joliPayload);
24
24
 
25
- const host = context.testMode ? 'stg-game.jolibox.com' : 'game.jolibox.com';
26
- const retentionSchema = `https://${host}/game/G32115508989327465281365749294/?appId=G32115508989327465281365749294&joliSource=${joliSource}`;
25
+ const host = context.testMode
26
+ ? `https://G32115508989327465281365749294.app.jolibox.com`
27
+ : `https://G32115508989327465281365749294.app.jolibox.com`;
28
+ const retentionSchema = `${host}/recommended-guide/${context.mpId}?appId=${context.mpId}&joliSource=${joliSource}&navigationStyle=present`;
27
29
 
28
30
  const quitResultDeffer = new Deferred<boolean>();
29
31
 
@@ -38,3 +40,5 @@ export async function openRetentionSchema() {
38
40
  }, 0);
39
41
  return quitResultDeffer.promise;
40
42
  }
43
+
44
+ // 添加锁变量,防止多次执行
@@ -262,6 +262,23 @@ declare global {
262
262
  /** 错误码 */
263
263
  errNo?: number;
264
264
  };
265
+
266
+ openPageSync: (params: { url: string }) => {
267
+ /** 错误消息 */
268
+ errMsg: string;
269
+ /** 错误码 */
270
+ errNo?: number;
271
+ data?: {
272
+ webviewId: number;
273
+ };
274
+ };
275
+
276
+ closePageSync: (params: { webviewId: number }) => {
277
+ /** 错误消息 */
278
+ errMsg: string;
279
+ /** 错误码 */
280
+ errNo?: number;
281
+ };
265
282
  }
266
283
 
267
284
  interface NativeEventMap {