@jolibox/implement 1.1.9 → 1.1.10-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/package-deps_build.json +9 -9
- package/dist/common/report/base-tracker.d.ts +0 -3
- package/dist/h5/http/index.d.ts +14 -3
- package/dist/index.js +3 -3
- package/dist/index.native.js +3 -3
- package/implement.build.log +2 -2
- package/package.json +3 -3
- package/src/common/report/base-tracker.ts +2 -20
- package/src/h5/api/ads.ts +4 -3
- package/src/h5/api/storage.ts +6 -7
- package/src/h5/bootstrap/index.ts +4 -1
- package/src/h5/http/index.ts +125 -80
- package/src/h5/report/event-tracker.ts +10 -7
- package/src/h5/report/task-tracker.ts +2 -2
- package/src/native/bootstrap/index.ts +4 -1
package/dist/index.native.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ds=Object.create;var Re=Object.defineProperty,us=Object.defineProperties,ms=Object.getOwnPropertyDescriptor,ps=Object.getOwnPropertyDescriptors,fs=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols,hs=Object.getPrototypeOf,yt=Object.prototype.hasOwnProperty,ar=Object.prototype.propertyIsEnumerable;var ir=(e,t,r)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,g=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&ir(e,r,t[r]);if(_e)for(var r of _e(t))ar.call(t,r)&&ir(e,r,t[r]);return e},x=(e,t)=>us(e,ps(t));var ae=(e,t)=>{var r={};for(var n in e)yt.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&_e)for(var n of _e(e))t.indexOf(n)<0&&ar.call(e,n)&&(r[n]=e[n]);return r};var h=(e,t)=>()=>(e&&(t=e(e=0)),t);var cr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),lr=(e,t)=>{for(var r in t)Re(e,r,{get:t[r],enumerable:!0})},gs=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of fs(t))!yt.call(e,s)&&s!==r&&Re(e,s,{get:()=>t[s],enumerable:!(n=ms(t,s))||n.enumerable});return e};var dr=(e,t,r)=>(r=e!=null?ds(hs(e)):{},gs(t||!e||!e.__esModule?Re(r,"default",{value:e,enumerable:!0}):r,e));var y=(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 vs(e){return!!(e!=null&&e.__nativeBuffers__)}function Te(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!vs(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=ys(n.base64)),typeof s!="undefined"&&s instanceof ArrayBuffer&&(e[n.key]=s)}}return e}function ur(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:bs(o),key:s};n.push(i),delete r[s]}return n.length>0&&(r.__nativeBuffers__=n),r}var ys,bs,bt=h(()=>{"use strict";ys=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};bs=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 Es(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ce(e){return typeof e=="string"}function M(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function hr(e){return typeof e=="object"&&Array.isArray(e)}function gr(e){return e===!0||e===!1}function ws(e){return typeof e>"u"}function Ss(e){return ws(e)||e===null}function vr(e){return typeof e=="function"}function yr(e){return M(e)&&vr(e.then)}function br(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}function Tr(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:mr(c)&&mr(a)?s[i]=n(g({},a),c):Array.isArray(c)&&Array.isArray(a)?s[i]=[...a,...c]:s[i]=c}return s}return n(e,t)}function mr(e){return e&&typeof e=="object"&&e.constructor===Object}function kr(e,t){if(Array.isArray(e))return e.concat(t)}function we(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),u=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 u.cancel=()=>{n&&clearTimeout(n),n=null,s=o=void 0},u.flush=()=>{if(n)return clearTimeout(n),n=null,l()},u}function _s(e,t){return(...r)=>t(e,...r)}function Oe(e){return t=>_s(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(s){e(new As(`${s}`))}})}function ke(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function Js(e){return new Promise(t=>Nr(e)(t))}function Nr(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function Hs(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Ee(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}function Vs(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ks(e[n],t[n])}function Ks(e,t){if(ce(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(vr(t)){try{if(e instanceof t)return}catch(r){}if(!Ss(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[kt])return globalThis[kt];let e=new Ce,t=new wt,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[kt]=r,r}var pr,Ts,ks,fr,ne,Is,St,le,Er,wr,As,Sr,Ir,Ar,_r,Rr,Se,Ne,It,j,xr,Rs,At,xs,_t,Ps,Cs,xe,Ns,Os,Fs,Pr,Rt,Ds,Us,Ms,Cr,Q,_,Ls,Bs,Pe,Ee,z,Et,js,Tt,$s,X,Ce,wt,kt,E=h(()=>{"use strict";pr=Object.defineProperty,Ts=Object.getOwnPropertyDescriptor,ks=(e,t)=>{for(var r in t)pr(e,r,{get:t[r],enumerable:!0})},fr=(e,t,r,n)=>{for(var s=n>1?void 0:n?Ts(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&&pr(t,r,s),s};ne=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))}})}};Is=(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))(Is||{}),St=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},le=class extends St{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Er=class extends St{constructor(){super(...arguments),this.kind="USER_ERROR"}},wr=class extends Er{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},As=class extends Er{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))}},Sr=class extends le{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Ir=class extends le{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},Ar=class extends le{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},_r=class extends le{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Rr=class extends le{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Se=class extends St{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}}},Ne=class extends le{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},It=class extends le{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};j={log:ke("log"),warn:ke("warn"),info:ke("info"),error:ke("error"),debug:ke("debug")};Object.assign(globalThis,{logger:j});xr=Symbol.for("Jolibox.canIUseMap"),Rs={};globalThis[xr]=Rs;At={get config(){return globalThis[xr]}},xs=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(xs||{}),_t=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(_t||{}),Ps=(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))(Ps||{}),Cs=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),xe={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")},Ns=()=>xe.isiOS?"iOS":xe.isAndroid?"Android":xe.isMac?"Mac":xe.isFacebook?"Facebook":"PC",Os="device_id",Fs="advertising_id",Pr=e=>(localStorage.getItem(e)||localStorage.setItem(e,Cs()),localStorage.getItem(e)),Rt=()=>Pr(Os),Ds=()=>Pr(Fs),Us=e=>e.charAt(0).toUpperCase()+e.slice(1),Ms=()=>{var t;let e=new URLSearchParams(window.location.search);return Us((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},Cr=e=>{let t="JoliboxWebSDK",r=Ns(),n=navigator.language,s=Rt(),o=Ds();return`${t} (${Ms()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`},_=(Q=class{constructor(t){this.element=t,this.next=Q.Undefined,this.prev=Q.Undefined}},Q.Undefined=new Q(void 0),Q),Ls=class{constructor(){this._first=_.Undefined,this._last=_.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===_.Undefined}clear(){let e=this._first;for(;e!==_.Undefined;){let t=e.next;e.prev=_.Undefined,e.next=_.Undefined,e=t}this._first=_.Undefined,this._last=_.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new _(e);if(this._first===_.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!==_.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==_.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==_.Undefined&&e.next!==_.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===_.Undefined&&e.next===_.Undefined?(this._first=_.Undefined,this._last=_.Undefined):e.next===_.Undefined?(this._last=this._last.prev,this._last.next=_.Undefined):e.prev===_.Undefined&&(this._first=this._first.next,this._first.prev=_.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==_.Undefined;)yield e.element,e=e.next}},Bs=0,Pe=class{constructor(e){this.value=e,this.id=Bs++}},Ee=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 Pe&&(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 Pe(t);this._listeners?this._listeners instanceof Pe?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 Pe?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},z=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 Ee,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(g({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 Ls,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},Et={};ks(Et,{None:()=>js,filter:()=>Hs,once:()=>Nr,toPromise:()=>Js});js=()=>{console.log("[Jolibox SDK] None Event")};Tt=Symbol.for("Jolibox.hostEmitter"),$s=()=>{let e=new z;return globalThis[Tt]||(globalThis[Tt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[Tt]},X=$s();Ce=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Ee,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 Vs(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}};Ce=fr([br],Ce);wt=class{constructor(){this._onWillExecuteCommand=new Ee,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Ee,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Ce,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Es(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(),Et.toPromise(Et.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}}};wt=fr([br],wt);kt=Symbol.for("Jolibox.commands")});function D(e,t={}){xt.emit("ERROR_REPORT",{error:e,options:t})}var xt,de,V=h(()=>{"use strict";E();E();xt=new z,de=new z;D.debounce=we(D,50,{leading:!0})});function Fe(e,t){return`[${e}]:${t}`}var ue,Pt,se=h(()=>{"use strict";V();E();V();ue=(e,t)=>{var r,n;return new Se((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Pt=e=>new wr(e)});var Or,Fr,Dr,Ur=h(()=>{"use strict";Or=[],Fr=[],Dr=["env","createRequestTask","login"]});function Lr(e,t){Mr||(Ct=new me({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),Nt=new me({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),Ot=new me({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),t("onJoliboxEnterBackground",()=>{Ct.flush(),Nt.flush(),Ot.flush()}),Mr=!0);function r(s){var b,v;let{method:o,args:i,startTime:a,isForeground:c,errMsg:l=`${o}:fail no errMsg`,errNo:u=0,__timing:m={receiveJSInvoke:0,invokeCallback:0}}=s,{receiveJSInvoke:p,invokeCallback:T}=m,I=(v=(b=l.match(/\S:(\S+)\s?/))==null?void 0:b[1])!=null?v:"fail";Ct.report({status:I,method:n(o,i),errNo:`${u}`,errMsg:l,isForeground:c,duration:Date.now()-a}),a&&p&&T&&(Nt.report({status:I,method:o,isForeground:c,duration:Number((p-a).toFixed(3))}),Ot.report({status:I,method:o,isForeground:c,duration:Number((Date.now()-T).toFixed(3))}))}function n(s,o){return(s==="callHostMethod"||s==="callHostMethodSync")&&o!=null&&o.method?`${s}-${o.method}`:s}return r}var qs,me,Mr,Ct,Nt,Ot,Ft=h(()=>{"use strict";E();qs=e=>e==="pv"?e:"default",me=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=qs(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&&M(a))throw new Ne(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(c){let l=[];if(M(a))l.push(...Object.keys(a));else if(ce(a)){if(o.length>0)throw new Ne(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);l.push(a)}else throw new Ne(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);l.forEach(u=>{s[u]||(s[u]={});let m=M(a)?a[u]:a;r(s[u],[...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={}}},Mr=!1});function jr(e,t){let r=0,n=!0,s=new Map,o=Lr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,Dt.forEach(p=>y(this,[p],function*({method:l,args:u,resolve:m}){let T=yield a(l,u);m(T)})),Dt.length=0});let i=(l,u)=>{let m=s.get(Number(l));if(!m)return;let p=Te(u);m(p),s.delete(Number(l))},a=(l,u)=>{var R,fe;let m=Date.now(),p=`${n}`;r+=1;let T=new ne;if(s.set(r,T.resolve),!n&&Fr.includes(l))return new Promise(U=>{Dt.push({method:l,args:u,resolve:U})});let b=x(g({},{method:l,startTime:m,args:u,isForeground:p}),{invokeType:"js-bridge"}),v=!Gs&&Or.includes(l),k=ur(u,v),A=v?k:JSON.stringify(k),f;if(l.endsWith("Sync")||Dr.includes(l)?f=(R=e.call)==null?void 0:R.call(e,l,k,r):typeof A=="string"?f=e.invoke(l,A,r):f=(fe=e.call)==null?void 0:fe.call(e,l,A,r),f){try{typeof f=="string"&&(f=JSON.parse(f)),f=Te(f)}catch(U){j.error(U)}return s.delete(r),f.errorCode&&(f.errorCode=Fe(l,f.errorCode)),o(g(g({},b),f)),f}return l.endsWith("Sync")&&s.delete(r),T.promise.then(U=>(U.errorCode&&(U.errorCode=Fe(l,U.errorCode)),o(g(g({},b),U)),U))};return{invokeNative:a,applyNative:(l,u)=>{let m=a(l,u);return yr(m)?m.then(p=>Br(l,p)):Br(l,m)},invokeHandler:i}}function Br(e,t){if(!M(t)){j.warn(`[Jolibox SDK]${e} no response value`);return}let a=t,{errMsg:r,errNo:n,errorType:s,errorCode:o}=a,i=ae(a,["errMsg","errNo","errorType","errorCode"]);if(r&&r!==`${e}:ok`)throw new Ar(r,n,s,o);return i}var Dt,Gs,Jr=h(()=>{"use strict";bt();E();se();Ur();Ft();Dt=[],Gs=!1});function Hr(e){let t=new z,r=new me({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(n){e.invoke("track",JSON.stringify({event:"reportMetrics",data:n}),-1)}});return t.on("onJoliboxEnterBackground",()=>{r.flush()}),{onNative:t.on.bind(t),offNative:t.off.bind(t),subscribeHandler(n,s,o){let i=Te(s),a;if(i.__extra){a=i.params;let{type:c,startTime:l}=i.__extra;r.report({type:c,event:n,duration:Date.now()-l})}else a=i;t.emit(n,a,o)}}}var $r=h(()=>{"use strict";E();bt();Ft()});function Ut(e){let{subscribeHandler:t,onNative:r,offNative:n}=Hr(e),{invokeNative:s,invokeHandler:o,applyNative:i}=jr(e,r);return{invokeHandler:o,subscribeHandler:t,applyNative:i,invokeNative:s,onNative:r,offNative:n}}var Vr=h(()=>{"use strict";Jr();$r()});var Kr=h(()=>{"use strict"});var qr=h(()=>{"use strict";Vr();Kr()});var oe,K,Gr,zr=h(()=>{"use strict";E();V();K={trigger(){},exit(){return!1},onReady(e){K.trigger=e},doExit(e){K.exit=e}},Gr=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)D(new Ir("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="")=>{K.trigger(),e.onDocumentReady.postMessage({path:s})};oe={onDocumentReady:t,doExit:s=>{let o=K.exit();e.doExit.postMessage({uuid:s,shouldInterrupt:o})},invoke(s,o,i){e.invoke.postMessage({event:s,paramsString:o,callbackId: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:Gr};globalThis.joliboxJSCore=g({},n)}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(s="")=>{K.trigger(),e.onDocumentReady(JSON.stringify({path:s}))};oe={onDocumentReady:t,invoke(s,o,i){e.invoke(JSON.stringify({event:s,paramsString:o,callbackId:i}))},doExit:s=>{let o=K.exit();e.doExit(JSON.stringify({uuid:s,shouldInterrupt:o}))},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:Gr};globalThis.joliboxJSCore=g({},n)}});function Mt(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var Lt=h(()=>{"use strict"});function Bt(){globalThis.onmessage=function(e){e.data==="msg:setup"&&([he]=e.ports,he.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])},he.publish=function(t,r){let n=Mt(r,"messagePort");he.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},he.postMessage("msg:setup:ok"))}}var he,Wr=h(()=>{"use strict";Lt()});var De=h(()=>{"use strict";zr();Wr();Lt()});var Qr,zs,Xr,Yr,J,P,W,va,Ws,$=h(()=>{"use strict";qr();De();se();E();De();Qr=oe;if(!Qr)throw new _r("No joliboxJScore is found, native bridge not found.");Bt();zs=g({},Qr),Xr=Ut(zs),{invokeHandler:Yr}=Xr,{applyNative:J,invokeNative:P,onNative:W,offNative:va,subscribeHandler:Ws}=Xr;globalThis.joliboxJSBridge={callHandler:Yr,invokeHandler:Yr,subscribeHandler:Ws}});var jt,Zr,en=h(()=>{"use strict";E();V();jt=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{}}},Zr=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:jt(o),payloadJson:jt(i),signature:jt(a)}}else throw"joli_source is missing"}catch(r){return D(new Sr(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}}});var Ys,Ue,tn,Jt=h(()=>{"use strict";E();Ys="1.1.9",Ue=()=>Ys,tn=()=>{let e=Ue();return`${Cr(e)}`}});var Qs,rn,Ht,nn,L,Xs,w,q=h(()=>{"use strict";E();en();Jt();E();Qs={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:Rt(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Ue()},schema:window.location.href,platform:"h5"},Ht=(rn=globalThis.joliboxJSCore)==null?void 0:rn.env,L=Object.assign({},(nn=Ht==null?void 0:Ht())!=null?nn:Qs),Xs=()=>{var m,p,T,I,b,v,k,A;let{payloadJson:e,headerJson:t}=L.schema.length?Zr(L.schema):{},r=`${L.deviceInfo.did}-${new Date().getTime()}`,s=new URL(L.schema.length?L.schema:window.location.href).searchParams,o=(T=(p=(m=s.get("mpId"))!=null?m:s.get("appId"))!=null?p:s.get("gameId"))!=null?T:"",i=(b=(I=e==null?void 0:e.sessionId)!=null?I:s.get("sessionId"))!=null?b:r,a=!!((v=e==null?void 0:e.testAdsMode)!=null?v:s.get("testAdsMode")==="true"),c=(A=(k=e==null?void 0:e.joliboxEnv)!=null?k:s.get("joliboxEnv"))!=null?A:"production",l=c==="staging",u=t==null?void 0:t.channel;return{get testMode(){return l},get testAdsMode(){return a},get joliboxEnv(){return c},get joliSource(){var f;return(f=s.get("joliSource"))!=null?f:null},get mpId(){var f;return(f=o!=null?o:e==null?void 0:e.id)!=null?f:""},get mpVersion(){var f;return(f=t==null?void 0:t.ver)!=null?f:Ue()},get mpType(){var f,R;return(R=(f=t==null?void 0:t.__mpType)!=null?f:e==null?void 0:e.__mpType)!=null?R:"game"},get platform(){var f;return(f=L.platform)!=null?f: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 f,R;return(R=(f=L.clientSessionId)!=null?f:i)!=null?R:r},get channel(){return u},get webviewId(){var f;return(f=L.webviewId)!=null?f:-1},onEnvConfigChanged:f=>{Tr(L,f,kr)}}},w=Xs()});var $t,on,Zs,eo,sn,to,an=h(()=>{"use strict";E();V();q();E();$t=!1,on=(e,t)=>e==null?!1:t in e,Zs=e=>on(e,"kind"),eo=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},sn=(e,t={},r)=>{var o,i,a;let n={user_id:(i=(o=w.hostUserInfo)==null?void 0:o.uid)!=null?i:"",device_id:(a=w.deviceInfo.did)!=null?a:"",timestamp:Date.now(),tag:eo(e.name)},s=x(g({},n),{env:t.environment,isFromUser:r});r?de.emit("GLOBAL_USER_ERROR",e,s):de.emit("GLOBAL_ERROR",e,s)},to=e=>on(e,"kind")&&e.kind==="USER_ERROR";xt.on("ERROR_REPORT",({error:e,options:t})=>{if($t)return;$t=!0;let r=Zs(e)&&e.raw?e.raw:e;try{let n=to(e);sn(e,t,n)}catch(n){let s=n instanceof Error?n.message:String(n),o=new It(`${s}, origin error: ${r.message}`);j.error(o),sn(new It(o.message),{environment:t.environment},!1)}finally{$t=!1}})});var cn=h(()=>{"use strict";an();se();E();$();de.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})});de.on("GLOBAL_USER_ERROR",(e,t)=>{j.log("UserError",e,t)})});var Vt=h(()=>{"use strict"});function ln(e,t){let r=(n,s,o)=>{let i=x(g({tag:n},t),{extra:g({},s)});n=="globalJsError"?D(new Rr(JSON.stringify(i))):e("systemLog",i,o)};return r.debounce=we(r,500,{leading:!0}),r}function dn(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=we(t,500,{leading:!0}),t}var un=h(()=>{"use strict";E();E();V()});function mn(e,t){let r=ln(e,t),n=dn(r);return{track:r,trackPerformance:n}}var pn=h(()=>{"use strict";un()});var fn=h(()=>{"use strict";q();E();E()});var hn=h(()=>{"use strict";pn();Vt();fn()});var Me,gn=h(()=>{"use strict";Me=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 T=Date.now(),I=T-r;I>=this.interval&&(this.visible&&(i+=I,t(i)),r=T),n=requestAnimationFrame(a)},c=()=>{u(),r=Date.now(),s=window.setInterval(()=>{if(!o)return;let T=Date.now();T-r>=this.interval&&(r=T)},this.interval)},l=()=>{m(),r=Date.now(),n=requestAnimationFrame(a)},u=()=>{n&&(cancelAnimationFrame(n),n=0)},m=()=>{s&&(clearInterval(s),s=0)};this.eventEmitter.on("visible",T=>{o&&(console.log("visible",T),T?l():c())});let p=this.visible;return{start(){o||(o=!0,p?l():c())},stop(){o=!1,u(),m()}}}}});var Kt=h(()=>{"use strict"});function yn(e,t,r){let{response:n,startTime:s,endTime:o,requestFrom:i}=r,{errMsg:a="",profile:c={}}=n,u={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"&&vn<no||i==="inner")&&(u.joli_request_number=vn++,setTimeout(()=>{H("joliboxNetRequestResult",u)},500))}var vn,no,bn=h(()=>{"use strict";Kt();ie();vn=0,no=10});function Le(e,t,r){var c,l,u;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=(u=r==null?void 0:r.defaultHeaders)!=null?u:{};return W("onRequestTaskStateChange",m=>{if(typeof m.requestTaskId!="string")return;let p=n.get(m.requestTaskId);if(p)if(m.state==="success"){let T=m,{requestTaskId:b,state:v}=T,k=ae(T,["requestTaskId","state"]);p.resolve(k),n.delete(b)}else if(m.state==="fail"){let I=m,{requestTaskId:b,state:v}=I,k=ae(I,["requestTaskId","state"]);p.reject(k),n.delete(b)}else j.warn("onRequestTaskStateChange unknown event",m)}),X.on("onLoginComplete",({isLogin:m,token:p})=>{m&&p&&(i["X-JOLI-TOKEN"]=p)}),(T,...I)=>y(this,[T,...I],function*(m,p={}){let b=Date.now(),v=so(m,x(g({},p),{baseUrl:s})),{method:k="GET",responseType:A="text",dataType:f="json",timeout:R,enableCache:fe=!1,appendHostCookie:U=!0}=p,be=Object.assign({"content-type":"application/json"},i,p.header),re={url:v,method:k,header:be,enableCache:fe,responseType:A,appendHostCookie:U};if(k=="POST"||k=="PUT"){let G=io(p.data,be["content-type"]);re.data=G}R&&Object.assign(re,{timeout:R});let{data:{requestTaskId:vt}}=P(e,re);if(typeof vt!="string")throw ue({code:-1,msg:"requestTaskId is not a string"});let or=(G,Y)=>{yn("request",v,{state:G,startTime:b,endTime:Date.now(),params:re,response:Y,requestId:vt,requestFrom:o=="public"?"public":"inner"})},{resolve:ss,reject:os,promise:is}=new ne;n.set(vt,{resolve:ss,reject:os});try{let G=yield is;or("success",G);let{data:Y}=G;return f==="json"&&typeof Y=="string"&&(Y=oo(Y)),{url:v,timeout:R,method:k,response:x(g({},G),{data:Y})}}catch(G){let Y=G;if(M(Y)){let{errMsg:Ae,prefetchDetail:as,isPrefetch:cs,errNo:ls}=Y;ce(Ae)&&(or("fail",{errMsg:Ae,isPrefetch:cs,prefetchDetail:as}),D(ue({code:-1,msg:Ae},{errNo:ls,errMsg:Ae})))}throw G}})}function oo(e){try{return JSON.parse(e.trim())}catch(t){return e}}function io(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 so,qt=h(()=>{"use strict";E();bn();Kt();$();V();se();so=(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 Gt,Tn,Z,Be=h(()=>{"use strict";Jt();qt();q();Gt={"x-user-agent":tn()};(Tn=w.hostUserInfo)!=null&&Tn.token&&(Gt["x-joli-token"]=w.hostUserInfo.token);w.joliSource&&(Gt["x-joli-source"]=w.joliSource);Z=Le("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:w.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:Gt})});var je,kn=h(()=>{"use strict";q();gn();Be();$();je=class extends Me{constructor(t,r,n){super(r,n),this.gameId=w.mpId,this.sessionId=w.sessionId,this.track=t}reporter(t){return y(this,null,function*(){let{event:r,params:n}=t,s=[];s.push(Z("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:g({gameId:this.gameId,sessionId:this.sessionId},n)}})),yield Promise.all(s)})}reportToNative(t){return y(this,null,function*(){let{event:r,params:n}=t;yield J("userTrackAsync",{event:r,params:g({},n),gameId:this.gameId})})}tracker(t,r=null){this.track(t,r)}}});var An={};lr(An,{nativeTaskEmitter:()=>Ie,taskTracker:()=>B,track:()=>H,trackPerformance:()=>Sn});var ao,En,wn,H,Sn,In,Ie,B,ie=h(()=>{"use strict";cn();E();Vt();hn();q();kn();$();ao=(e,t,r)=>{var i,a;let n=t,s=M(n.extra)?n.extra:ce(n.extra)?JSON.parse(n.extra):{},o=x(g({},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:H,trackPerformance:Sn}=mn(ao,{type:_t.AppSDK,platform:"native",jssdk_version:(wn=(En=w.sdkInfo)==null?void 0:En.jssdkVersion)!=null?wn:"1.0.0",mp_id:w.mpId,mp_version:w.mpVersion}),In=O();In.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{Sn(e,t,r)});In.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{H(e,t)});Ie=new z,B=new je(H,Ie)});function _n(){let e=null,t=window.fetch,r=()=>{e=document.createElement("style"),e.setAttribute("data-jolibox-sdk","default-styles");let o=`
|
|
1
|
+
var ds=Object.create;var Re=Object.defineProperty,us=Object.defineProperties,ms=Object.getOwnPropertyDescriptor,ps=Object.getOwnPropertyDescriptors,fs=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols,hs=Object.getPrototypeOf,yt=Object.prototype.hasOwnProperty,ar=Object.prototype.propertyIsEnumerable;var ir=(e,t,r)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,g=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&ir(e,r,t[r]);if(_e)for(var r of _e(t))ar.call(t,r)&&ir(e,r,t[r]);return e},x=(e,t)=>us(e,ps(t));var ae=(e,t)=>{var r={};for(var n in e)yt.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&_e)for(var n of _e(e))t.indexOf(n)<0&&ar.call(e,n)&&(r[n]=e[n]);return r};var h=(e,t)=>()=>(e&&(t=e(e=0)),t);var cr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),lr=(e,t)=>{for(var r in t)Re(e,r,{get:t[r],enumerable:!0})},gs=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of fs(t))!yt.call(e,s)&&s!==r&&Re(e,s,{get:()=>t[s],enumerable:!(n=ms(t,s))||n.enumerable});return e};var dr=(e,t,r)=>(r=e!=null?ds(hs(e)):{},gs(t||!e||!e.__esModule?Re(r,"default",{value:e,enumerable:!0}):r,e));var y=(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 vs(e){return!!(e!=null&&e.__nativeBuffers__)}function Te(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!vs(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=ys(n.base64)),typeof s!="undefined"&&s instanceof ArrayBuffer&&(e[n.key]=s)}}return e}function ur(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:bs(o),key:s};n.push(i),delete r[s]}return n.length>0&&(r.__nativeBuffers__=n),r}var ys,bs,bt=h(()=>{"use strict";ys=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};bs=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 Es(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ce(e){return typeof e=="string"}function M(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function hr(e){return typeof e=="object"&&Array.isArray(e)}function gr(e){return e===!0||e===!1}function ws(e){return typeof e>"u"}function Ss(e){return ws(e)||e===null}function vr(e){return typeof e=="function"}function yr(e){return M(e)&&vr(e.then)}function br(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}function Tr(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:mr(c)&&mr(a)?s[i]=n(g({},a),c):Array.isArray(c)&&Array.isArray(a)?s[i]=[...a,...c]:s[i]=c}return s}return n(e,t)}function mr(e){return e&&typeof e=="object"&&e.constructor===Object}function kr(e,t){if(Array.isArray(e))return e.concat(t)}function we(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),u=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 u.cancel=()=>{n&&clearTimeout(n),n=null,s=o=void 0},u.flush=()=>{if(n)return clearTimeout(n),n=null,l()},u}function _s(e,t){return(...r)=>t(e,...r)}function Oe(e){return t=>_s(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(s){e(new As(`${s}`))}})}function ke(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function Js(e){return new Promise(t=>Nr(e)(t))}function Nr(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function Hs(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Ee(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}function Vs(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ks(e[n],t[n])}function Ks(e,t){if(ce(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(vr(t)){try{if(e instanceof t)return}catch(r){}if(!Ss(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[kt])return globalThis[kt];let e=new Ce,t=new wt,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[kt]=r,r}var pr,Ts,ks,fr,ne,Is,St,le,Er,wr,As,Sr,Ir,Ar,_r,Rr,Se,Ne,It,j,xr,Rs,At,xs,_t,Ps,Cs,xe,Ns,Os,Fs,Pr,Rt,Ds,Us,Ms,Cr,Q,_,Ls,Bs,Pe,Ee,z,Et,js,Tt,$s,X,Ce,wt,kt,w=h(()=>{"use strict";pr=Object.defineProperty,Ts=Object.getOwnPropertyDescriptor,ks=(e,t)=>{for(var r in t)pr(e,r,{get:t[r],enumerable:!0})},fr=(e,t,r,n)=>{for(var s=n>1?void 0:n?Ts(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&&pr(t,r,s),s};ne=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))}})}};Is=(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))(Is||{}),St=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},le=class extends St{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Er=class extends St{constructor(){super(...arguments),this.kind="USER_ERROR"}},wr=class extends Er{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},As=class extends Er{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))}},Sr=class extends le{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Ir=class extends le{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},Ar=class extends le{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},_r=class extends le{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Rr=class extends le{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Se=class extends St{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}}},Ne=class extends le{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},It=class extends le{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};j={log:ke("log"),warn:ke("warn"),info:ke("info"),error:ke("error"),debug:ke("debug")};Object.assign(globalThis,{logger:j});xr=Symbol.for("Jolibox.canIUseMap"),Rs={};globalThis[xr]=Rs;At={get config(){return globalThis[xr]}},xs=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(xs||{}),_t=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(_t||{}),Ps=(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))(Ps||{}),Cs=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),xe={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")},Ns=()=>xe.isiOS?"iOS":xe.isAndroid?"Android":xe.isMac?"Mac":xe.isFacebook?"Facebook":"PC",Os="device_id",Fs="advertising_id",Pr=e=>(localStorage.getItem(e)||localStorage.setItem(e,Cs()),localStorage.getItem(e)),Rt=()=>Pr(Os),Ds=()=>Pr(Fs),Us=e=>e.charAt(0).toUpperCase()+e.slice(1),Ms=()=>{var t;let e=new URLSearchParams(window.location.search);return Us((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},Cr=e=>{let t="JoliboxWebSDK",r=Ns(),n=navigator.language,s=Rt(),o=Ds();return`${t} (${Ms()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`},_=(Q=class{constructor(t){this.element=t,this.next=Q.Undefined,this.prev=Q.Undefined}},Q.Undefined=new Q(void 0),Q),Ls=class{constructor(){this._first=_.Undefined,this._last=_.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===_.Undefined}clear(){let e=this._first;for(;e!==_.Undefined;){let t=e.next;e.prev=_.Undefined,e.next=_.Undefined,e=t}this._first=_.Undefined,this._last=_.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new _(e);if(this._first===_.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!==_.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==_.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==_.Undefined&&e.next!==_.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===_.Undefined&&e.next===_.Undefined?(this._first=_.Undefined,this._last=_.Undefined):e.next===_.Undefined?(this._last=this._last.prev,this._last.next=_.Undefined):e.prev===_.Undefined&&(this._first=this._first.next,this._first.prev=_.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==_.Undefined;)yield e.element,e=e.next}},Bs=0,Pe=class{constructor(e){this.value=e,this.id=Bs++}},Ee=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 Pe&&(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 Pe(t);this._listeners?this._listeners instanceof Pe?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 Pe?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},z=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 Ee,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(g({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 Ls,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},Et={};ks(Et,{None:()=>js,filter:()=>Hs,once:()=>Nr,toPromise:()=>Js});js=()=>{console.log("[Jolibox SDK] None Event")};Tt=Symbol.for("Jolibox.hostEmitter"),$s=()=>{let e=new z;return globalThis[Tt]||(globalThis[Tt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[Tt]},X=$s();Ce=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Ee,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 Vs(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}};Ce=fr([br],Ce);wt=class{constructor(){this._onWillExecuteCommand=new Ee,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Ee,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Ce,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Es(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(),Et.toPromise(Et.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}}};wt=fr([br],wt);kt=Symbol.for("Jolibox.commands")});function D(e,t={}){xt.emit("ERROR_REPORT",{error:e,options:t})}var xt,de,V=h(()=>{"use strict";w();w();xt=new z,de=new z;D.debounce=we(D,50,{leading:!0})});function Fe(e,t){return`[${e}]:${t}`}var ue,Pt,se=h(()=>{"use strict";V();w();V();ue=(e,t)=>{var r,n;return new Se((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Pt=e=>new wr(e)});var Or,Fr,Dr,Ur=h(()=>{"use strict";Or=[],Fr=[],Dr=["env","createRequestTask","login"]});function Lr(e,t){Mr||(Ct=new me({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),Nt=new me({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),Ot=new me({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(s){e.invoke("track",JSON.stringify({event:"reportMetrics",data:s}),-1)}}),t("onJoliboxEnterBackground",()=>{Ct.flush(),Nt.flush(),Ot.flush()}),Mr=!0);function r(s){var b,v;let{method:o,args:i,startTime:a,isForeground:c,errMsg:l=`${o}:fail no errMsg`,errNo:u=0,__timing:m={receiveJSInvoke:0,invokeCallback:0}}=s,{receiveJSInvoke:p,invokeCallback:T}=m,I=(v=(b=l.match(/\S:(\S+)\s?/))==null?void 0:b[1])!=null?v:"fail";Ct.report({status:I,method:n(o,i),errNo:`${u}`,errMsg:l,isForeground:c,duration:Date.now()-a}),a&&p&&T&&(Nt.report({status:I,method:o,isForeground:c,duration:Number((p-a).toFixed(3))}),Ot.report({status:I,method:o,isForeground:c,duration:Number((Date.now()-T).toFixed(3))}))}function n(s,o){return(s==="callHostMethod"||s==="callHostMethodSync")&&o!=null&&o.method?`${s}-${o.method}`:s}return r}var qs,me,Mr,Ct,Nt,Ot,Ft=h(()=>{"use strict";w();qs=e=>e==="pv"?e:"default",me=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=qs(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&&M(a))throw new Ne(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(c){let l=[];if(M(a))l.push(...Object.keys(a));else if(ce(a)){if(o.length>0)throw new Ne(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);l.push(a)}else throw new Ne(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);l.forEach(u=>{s[u]||(s[u]={});let m=M(a)?a[u]:a;r(s[u],[...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={}}},Mr=!1});function jr(e,t){let r=0,n=!0,s=new Map,o=Lr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,Dt.forEach(p=>y(this,[p],function*({method:l,args:u,resolve:m}){let T=yield a(l,u);m(T)})),Dt.length=0});let i=(l,u)=>{let m=s.get(Number(l));if(!m)return;let p=Te(u);m(p),s.delete(Number(l))},a=(l,u)=>{var R,fe;let m=Date.now(),p=`${n}`;r+=1;let T=new ne;if(s.set(r,T.resolve),!n&&Fr.includes(l))return new Promise(U=>{Dt.push({method:l,args:u,resolve:U})});let b=x(g({},{method:l,startTime:m,args:u,isForeground:p}),{invokeType:"js-bridge"}),v=!Gs&&Or.includes(l),E=ur(u,v),A=v?E:JSON.stringify(E),f;if(l.endsWith("Sync")||Dr.includes(l)?f=(R=e.call)==null?void 0:R.call(e,l,E,r):typeof A=="string"?f=e.invoke(l,A,r):f=(fe=e.call)==null?void 0:fe.call(e,l,A,r),f){try{typeof f=="string"&&(f=JSON.parse(f)),f=Te(f)}catch(U){j.error(U)}return s.delete(r),f.errorCode&&(f.errorCode=Fe(l,f.errorCode)),o(g(g({},b),f)),f}return l.endsWith("Sync")&&s.delete(r),T.promise.then(U=>(U.errorCode&&(U.errorCode=Fe(l,U.errorCode)),o(g(g({},b),U)),U))};return{invokeNative:a,applyNative:(l,u)=>{let m=a(l,u);return yr(m)?m.then(p=>Br(l,p)):Br(l,m)},invokeHandler:i}}function Br(e,t){if(!M(t)){j.warn(`[Jolibox SDK]${e} no response value`);return}let a=t,{errMsg:r,errNo:n,errorType:s,errorCode:o}=a,i=ae(a,["errMsg","errNo","errorType","errorCode"]);if(r&&r!==`${e}:ok`)throw new Ar(r,n,s,o);return i}var Dt,Gs,Jr=h(()=>{"use strict";bt();w();se();Ur();Ft();Dt=[],Gs=!1});function Hr(e){let t=new z,r=new me({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(n){e.invoke("track",JSON.stringify({event:"reportMetrics",data:n}),-1)}});return t.on("onJoliboxEnterBackground",()=>{r.flush()}),{onNative:t.on.bind(t),offNative:t.off.bind(t),subscribeHandler(n,s,o){let i=Te(s),a;if(i.__extra){a=i.params;let{type:c,startTime:l}=i.__extra;r.report({type:c,event:n,duration:Date.now()-l})}else a=i;t.emit(n,a,o)}}}var $r=h(()=>{"use strict";w();bt();Ft()});function Ut(e){let{subscribeHandler:t,onNative:r,offNative:n}=Hr(e),{invokeNative:s,invokeHandler:o,applyNative:i}=jr(e,r);return{invokeHandler:o,subscribeHandler:t,applyNative:i,invokeNative:s,onNative:r,offNative:n}}var Vr=h(()=>{"use strict";Jr();$r()});var Kr=h(()=>{"use strict"});var qr=h(()=>{"use strict";Vr();Kr()});var oe,K,Gr,zr=h(()=>{"use strict";w();V();K={trigger(){},exit(){return!1},onReady(e){K.trigger=e},doExit(e){K.exit=e}},Gr=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)D(new Ir("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="")=>{K.trigger(),e.onDocumentReady.postMessage({path:s})};oe={onDocumentReady:t,doExit:s=>{let o=K.exit();e.doExit.postMessage({uuid:s,shouldInterrupt:o})},invoke(s,o,i){e.invoke.postMessage({event:s,paramsString:o,callbackId: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:Gr};globalThis.joliboxJSCore=g({},n)}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(s="")=>{K.trigger(),e.onDocumentReady(JSON.stringify({path:s}))};oe={onDocumentReady:t,invoke(s,o,i){e.invoke(JSON.stringify({event:s,paramsString:o,callbackId:i}))},doExit:s=>{let o=K.exit();e.doExit(JSON.stringify({uuid:s,shouldInterrupt:o}))},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:Gr};globalThis.joliboxJSCore=g({},n)}});function Mt(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var Lt=h(()=>{"use strict"});function Bt(){globalThis.onmessage=function(e){e.data==="msg:setup"&&([he]=e.ports,he.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])},he.publish=function(t,r){let n=Mt(r,"messagePort");he.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},he.postMessage("msg:setup:ok"))}}var he,Wr=h(()=>{"use strict";Lt()});var De=h(()=>{"use strict";zr();Wr();Lt()});var Qr,zs,Xr,Yr,J,P,W,va,Ws,$=h(()=>{"use strict";qr();De();se();w();De();Qr=oe;if(!Qr)throw new _r("No joliboxJScore is found, native bridge not found.");Bt();zs=g({},Qr),Xr=Ut(zs),{invokeHandler:Yr}=Xr,{applyNative:J,invokeNative:P,onNative:W,offNative:va,subscribeHandler:Ws}=Xr;globalThis.joliboxJSBridge={callHandler:Yr,invokeHandler:Yr,subscribeHandler:Ws}});var jt,Zr,en=h(()=>{"use strict";w();V();jt=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{}}},Zr=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:jt(o),payloadJson:jt(i),signature:jt(a)}}else throw"joli_source is missing"}catch(r){return D(new Sr(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}}});var Ys,Ue,tn,Jt=h(()=>{"use strict";w();Ys="1.1.10-beta.1",Ue=()=>Ys,tn=()=>{let e=Ue();return`${Cr(e)}`}});var Qs,rn,Ht,nn,L,Xs,k,q=h(()=>{"use strict";w();en();Jt();w();Qs={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:Rt(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Ue()},schema:window.location.href,platform:"h5"},Ht=(rn=globalThis.joliboxJSCore)==null?void 0:rn.env,L=Object.assign({},(nn=Ht==null?void 0:Ht())!=null?nn:Qs),Xs=()=>{var m,p,T,I,b,v,E,A;let{payloadJson:e,headerJson:t}=L.schema.length?Zr(L.schema):{},r=`${L.deviceInfo.did}-${new Date().getTime()}`,s=new URL(L.schema.length?L.schema:window.location.href).searchParams,o=(T=(p=(m=s.get("mpId"))!=null?m:s.get("appId"))!=null?p:s.get("gameId"))!=null?T:"",i=(b=(I=e==null?void 0:e.sessionId)!=null?I:s.get("sessionId"))!=null?b:r,a=!!((v=e==null?void 0:e.testAdsMode)!=null?v:s.get("testAdsMode")==="true"),c=(A=(E=e==null?void 0:e.joliboxEnv)!=null?E:s.get("joliboxEnv"))!=null?A:"production",l=c==="staging",u=t==null?void 0:t.channel;return{get testMode(){return l},get testAdsMode(){return a},get joliboxEnv(){return c},get joliSource(){var f;return(f=s.get("joliSource"))!=null?f:null},get mpId(){var f;return(f=o!=null?o:e==null?void 0:e.id)!=null?f:""},get mpVersion(){var f;return(f=t==null?void 0:t.ver)!=null?f:Ue()},get mpType(){var f,R;return(R=(f=t==null?void 0:t.__mpType)!=null?f:e==null?void 0:e.__mpType)!=null?R:"game"},get platform(){var f;return(f=L.platform)!=null?f: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 f,R;return(R=(f=L.clientSessionId)!=null?f:i)!=null?R:r},get channel(){return u},get webviewId(){var f;return(f=L.webviewId)!=null?f:-1},onEnvConfigChanged:f=>{Tr(L,f,kr)}}},k=Xs()});var $t,on,Zs,eo,sn,to,an=h(()=>{"use strict";w();V();q();w();$t=!1,on=(e,t)=>e==null?!1:t in e,Zs=e=>on(e,"kind"),eo=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},sn=(e,t={},r)=>{var o,i,a;let n={user_id:(i=(o=k.hostUserInfo)==null?void 0:o.uid)!=null?i:"",device_id:(a=k.deviceInfo.did)!=null?a:"",timestamp:Date.now(),tag:eo(e.name)},s=x(g({},n),{env:t.environment,isFromUser:r});r?de.emit("GLOBAL_USER_ERROR",e,s):de.emit("GLOBAL_ERROR",e,s)},to=e=>on(e,"kind")&&e.kind==="USER_ERROR";xt.on("ERROR_REPORT",({error:e,options:t})=>{if($t)return;$t=!0;let r=Zs(e)&&e.raw?e.raw:e;try{let n=to(e);sn(e,t,n)}catch(n){let s=n instanceof Error?n.message:String(n),o=new It(`${s}, origin error: ${r.message}`);j.error(o),sn(new It(o.message),{environment:t.environment},!1)}finally{$t=!1}})});var cn=h(()=>{"use strict";an();se();w();$();de.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})});de.on("GLOBAL_USER_ERROR",(e,t)=>{j.log("UserError",e,t)})});var Vt=h(()=>{"use strict"});function ln(e,t){let r=(n,s,o)=>{let i=x(g({tag:n},t),{extra:g({},s)});n=="globalJsError"?D(new Rr(JSON.stringify(i))):e("systemLog",i,o)};return r.debounce=we(r,500,{leading:!0}),r}function dn(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=we(t,500,{leading:!0}),t}var un=h(()=>{"use strict";w();w();V()});function mn(e,t){let r=ln(e,t),n=dn(r);return{track:r,trackPerformance:n}}var pn=h(()=>{"use strict";un()});var fn=h(()=>{"use strict";q();w();w()});var hn=h(()=>{"use strict";pn();Vt();fn()});var Me,gn=h(()=>{"use strict";Me=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 T=Date.now(),I=T-r;I>=this.interval&&(this.visible&&(i+=I,t(i)),r=T),n=requestAnimationFrame(a)},c=()=>{u(),r=Date.now(),s=window.setInterval(()=>{if(!o)return;let T=Date.now();T-r>=this.interval&&(r=T)},this.interval)},l=()=>{m(),r=Date.now(),n=requestAnimationFrame(a)},u=()=>{n&&(cancelAnimationFrame(n),n=0)},m=()=>{s&&(clearInterval(s),s=0)};this.eventEmitter.on("visible",T=>{o&&(console.log("visible",T),T?l():c())});let p=this.visible;return{start(){o||(o=!0,p?l():c())},stop(){o=!1,u(),m()}}}}});var Kt=h(()=>{"use strict"});function yn(e,t,r){let{response:n,startTime:s,endTime:o,requestFrom:i}=r,{errMsg:a="",profile:c={}}=n,u={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"&&vn<no||i==="inner")&&(u.joli_request_number=vn++,setTimeout(()=>{H("joliboxNetRequestResult",u)},500))}var vn,no,bn=h(()=>{"use strict";Kt();ie();vn=0,no=10});function Le(e,t,r){var c,l,u;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=(u=r==null?void 0:r.defaultHeaders)!=null?u:{};return W("onRequestTaskStateChange",m=>{if(typeof m.requestTaskId!="string")return;let p=n.get(m.requestTaskId);if(p)if(m.state==="success"){let T=m,{requestTaskId:b,state:v}=T,E=ae(T,["requestTaskId","state"]);p.resolve(E),n.delete(b)}else if(m.state==="fail"){let I=m,{requestTaskId:b,state:v}=I,E=ae(I,["requestTaskId","state"]);p.reject(E),n.delete(b)}else j.warn("onRequestTaskStateChange unknown event",m)}),X.on("onLoginComplete",({isLogin:m,token:p})=>{m&&p&&(i["X-JOLI-TOKEN"]=p)}),(T,...I)=>y(this,[T,...I],function*(m,p={}){let b=Date.now(),v=so(m,x(g({},p),{baseUrl:s})),{method:E="GET",responseType:A="text",dataType:f="json",timeout:R,enableCache:fe=!1,appendHostCookie:U=!0}=p,be=Object.assign({"content-type":"application/json"},i,p.header),re={url:v,method:E,header:be,enableCache:fe,responseType:A,appendHostCookie:U};if(E=="POST"||E=="PUT"){let G=io(p.data,be["content-type"]);re.data=G}R&&Object.assign(re,{timeout:R});let{data:{requestTaskId:vt}}=P(e,re);if(typeof vt!="string")throw ue({code:-1,msg:"requestTaskId is not a string"});let or=(G,Y)=>{yn("request",v,{state:G,startTime:b,endTime:Date.now(),params:re,response:Y,requestId:vt,requestFrom:o=="public"?"public":"inner"})},{resolve:ss,reject:os,promise:is}=new ne;n.set(vt,{resolve:ss,reject:os});try{let G=yield is;or("success",G);let{data:Y}=G;return f==="json"&&typeof Y=="string"&&(Y=oo(Y)),{url:v,timeout:R,method:E,response:x(g({},G),{data:Y})}}catch(G){let Y=G;if(M(Y)){let{errMsg:Ae,prefetchDetail:as,isPrefetch:cs,errNo:ls}=Y;ce(Ae)&&(or("fail",{errMsg:Ae,isPrefetch:cs,prefetchDetail:as}),D(ue({code:-1,msg:Ae},{errNo:ls,errMsg:Ae})))}throw G}})}function oo(e){try{return JSON.parse(e.trim())}catch(t){return e}}function io(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 so,qt=h(()=>{"use strict";w();bn();Kt();$();V();se();so=(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 Gt,Tn,Z,Be=h(()=>{"use strict";Jt();qt();q();Gt={"x-user-agent":tn()};(Tn=k.hostUserInfo)!=null&&Tn.token&&(Gt["x-joli-token"]=k.hostUserInfo.token);k.joliSource&&(Gt["x-joli-source"]=k.joliSource);Z=Le("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:k.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:Gt})});var je,kn=h(()=>{"use strict";q();gn();Be();$();je=class extends Me{constructor(t,r,n){super(r,n),this.gameId=k.mpId,this.sessionId=k.sessionId,this.track=t}reporter(t){return y(this,null,function*(){let{event:r,params:n}=t,s=[];s.push(Z("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:g({gameId:this.gameId,sessionId:this.sessionId},n)}})),yield Promise.all(s)})}reportToNative(t){return y(this,null,function*(){let{event:r,params:n}=t;yield J("userTrackAsync",{event:r,params:g({},n),gameId:this.gameId})})}tracker(t,r=null){this.track(t,r)}}});var An={};lr(An,{nativeTaskEmitter:()=>Ie,taskTracker:()=>B,track:()=>H,trackPerformance:()=>Sn});var ao,En,wn,H,Sn,In,Ie,B,ie=h(()=>{"use strict";cn();w();Vt();hn();q();kn();$();ao=(e,t,r)=>{var i,a;let n=t,s=M(n.extra)?n.extra:ce(n.extra)?JSON.parse(n.extra):{},o=x(g({},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:H,trackPerformance:Sn}=mn(ao,{type:_t.AppSDK,platform:"native",jssdk_version:(wn=(En=k.sdkInfo)==null?void 0:En.jssdkVersion)!=null?wn:"1.0.0",mp_id:k.mpId,mp_version:k.mpVersion}),In=O();In.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{Sn(e,t,r)});In.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{H(e,t)});Ie=new z,B=new je(H,Ie)});function _n(){let e=null,t=window.fetch,r=()=>{e=document.createElement("style"),e.setAttribute("data-jolibox-sdk","default-styles");let o=`
|
|
2
2
|
html[data-jolibox-root] {
|
|
3
3
|
height: 100%;
|
|
4
4
|
margin: 0;
|
|
@@ -16,6 +16,6 @@ var ds=Object.create;var Re=Object.defineProperty,us=Object.defineProperties,ms=
|
|
|
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 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")?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 Rn=h(()=>{"use strict"});var Je,xn=h(()=>{"use strict";Je=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 Pn,He,Cn=h(()=>{"use strict";Pn="jolibox-sdk-ads-callbreak-timestamps",He=class{constructor(t,r){this.checkNetwork=t;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(Pn))!=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 n,s,o,i,a,c;if(this.maxAllowedAdsForTime=(n=r==null?void 0:r.maxAllowedAdsForTime)!=null?n:8,this.bannedForTimeThreshold=(s=r==null?void 0:r.bannedForTimeThreshold)!=null?s:6e4,this.bannedReleaseTime=(o=r==null?void 0:r.bannedReleaseTime)!=null?o:6e4,this.maxAllowedAdsForSession=(i=r==null?void 0:r.maxAllowedAdsForSession)!=null?i:200,this.bannedForSessionThreshold=(a=r==null?void 0:r.bannedForSessionThreshold)!=null?a:6e5,this.initialThreshold=(c=r==null?void 0:r.initialThreshold)!=null?c: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(Pn,JSON.stringify(t))}catch(r){console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=t}}});var $e,Nn=h(()=>{"use strict";q();$e=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 s=(r=w.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 ge,Ve,zt=h(()=>{"use strict";xn();Cn();q();Nn();E();ge=new z,Ve=class{constructor(t,r,n){this.track=t;this.httpClient=r;this.checkNetwork=n;this.configured=!1;this.config={};this.getGameId=()=>w.mpId;this.getTestAdsMode=()=>w.testAdsMode;this.asyncLoad=()=>y(this,null,function*(){var i,a,c,l,u;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=(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 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)){ge.emit("isAdShowing",!0);let n=t.adBreakDone,s=o=>{ge.emit("isAdShowing",!1),n&&n(o)};return x(g({},t),{adBreakDone:s})}else{let n=t.beforeAd,s=t.afterAd,o=()=>{ge.emit("isAdShowing",!0),this.track("CallBeforeAd",{}),n&&n()},i=()=>{ge.emit("isAdShowing",!1),this.track("CallAfterAd",{}),s&&s()};return x(g({},t),{beforeAd:o,afterAd:i})}};this.adConfig=t=>{let s=t,{onReady:r}=s,n=ae(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,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.track("PreventAdsCheating",{reason: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:"viewed"}),this.track("PreventAdsCheating",{reason:r});return;default:break}let n=t.type,s=t.adBreakDone,o=p=>{var T;this.adsActionDetection.adBreakIsShowing=!1,this.track("CallAdBreakDone",{breakType:p.breakType,breakName:(T=p.breakName)!=null?T:"",breakFormat:p.breakFormat,breakStatus:p.breakStatus}),s&&s(p)};if(t.adBreakDone=o,t.type==="reward"){let p=t.beforeReward,T=b=>()=>{this.track("CallShowAdFn",null),b()},I=b=>{p&&p(T(b))};t.beforeReward=I}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,T,I,b;if(this.track("CallAdUnit",{adFormat:(T=(p=t.adFormat)==null?void 0:p.toString())!=null?T:null,fullWidthResponsive:(I=t.fullWidthResponsive)!=null?I: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,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),o&&u.setAttribute("data-full-width-responsive",o),i&&u.setAttribute("style",i),(b=this.getTestAdsMode())!=null?b:!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(k=>{k.forEach(A=>{if(A.type==="attributes"&&A.attributeName==="data-ad-status"){let f=u.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:f!=null?f:"null"})}})}).observe(u,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})});this.antiCheating=new He(n),this.adsActionDetection=new Je(this.track),this.channelPolicy=new $e(r)}init(t){this.track("CallAdsInit",null),typeof window!="undefined"&&(this.config=t!=null?t:{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}}});var On={};lr(On,{config:()=>mo});function co(){X.on("onDocumentReady",()=>{var e;(e=oe)==null||e.onDocumentReady(window.location.href),H("onDocumentReady",{start_timestamp:Ge,timestamp:Date.now()})})}function lo(e){B.start(e)}function uo(){W("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&w.onEnvConfigChanged({hostUserInfo:e}),X.emit("LifecycleEvent.onReady",g({},w.hostUserInfo?w.hostUserInfo:{isLogin:!1})),H("joliboxServiceReady",{start_timestamp:Ge,timestamp:Date.now()}),lo(t)}),W("onBeforeExit",({uuid:e})=>{var t;(t=oe)==null||t.doExit(e)})}function mo(){Ge=Date.now(),uo(),co(),Ke=_n()}var Ke,qe,Ge,Fn=h(()=>{"use strict";$();De();q();E();ie();Rn();zt();K.onReady(()=>{});K.doExit(()=>(H("onBeforeExit",{timestamp:Date.now()}),Ke==null||Ke(),B.close(Date.now()-Ge),!!qe));qe=!1;ge.on("isAdShowing",e=>{qe=e,gr(qe)&&P("updateContainerConfigSync",{displayCapsuleButton:!qe,webviewId:w.webviewId})})});function Dn(e){let t=At.config[e];return t||(t={},At.config[e]=t),(r,n)=>{if(t[r]){j.warn(`[can i use] ${r} already registered`);return}t[r]=g({},n)}}var Un=h(()=>{"use strict";E()});function Wt(e){Mn=e}function ze(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>ze(t)):Object.keys(e).reduce((t,r)=>(t[r]=ze(e[r]),t),{})}function ee(e){return typeof e=="number"}function Yt(e){let t=Qt(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Qt(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Mn,C,We,Ye,Qe,Xe,ve,Ze,et,tt,rt,nt,st,ot,it,at,ct,lt,dt,Xt=h(()=>{"use strict";Mn=!1;C=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Mn)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 ${Yt(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return ze(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:ze(this._default)}optional(){return this._optional=!0,this}};We=class extends C{validate(t){return this._optional&&t===void 0?!0:ee(t)?ee(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):ee(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):ee(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}},Ye=class extends C{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Qe=class extends C{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(ee(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(ee(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}},Xe=class extends C{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ve=class extends C{validate(t){return!0}},Ze=class extends C{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},et=class extends C{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},tt=class extends C{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},rt=class extends C{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 ${Yt(t)}`)}return!0}},nt=class extends C{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(ee(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(ee(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(ee(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}},st=class extends C{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Qt(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}},ot=class extends C{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Qt(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}},it=class extends C{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:Yt(this.value),actual:r}):!0}},at=class extends C{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(`
|
|
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 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")?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 Rn=h(()=>{"use strict"});var Je,xn=h(()=>{"use strict";Je=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 Pn,He,Cn=h(()=>{"use strict";Pn="jolibox-sdk-ads-callbreak-timestamps",He=class{constructor(t,r){this.checkNetwork=t;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(Pn))!=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 n,s,o,i,a,c;if(this.maxAllowedAdsForTime=(n=r==null?void 0:r.maxAllowedAdsForTime)!=null?n:8,this.bannedForTimeThreshold=(s=r==null?void 0:r.bannedForTimeThreshold)!=null?s:6e4,this.bannedReleaseTime=(o=r==null?void 0:r.bannedReleaseTime)!=null?o:6e4,this.maxAllowedAdsForSession=(i=r==null?void 0:r.maxAllowedAdsForSession)!=null?i:200,this.bannedForSessionThreshold=(a=r==null?void 0:r.bannedForSessionThreshold)!=null?a:6e5,this.initialThreshold=(c=r==null?void 0:r.initialThreshold)!=null?c: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(Pn,JSON.stringify(t))}catch(r){console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=t}}});var $e,Nn=h(()=>{"use strict";q();$e=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 s=(r=k.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 ge,Ve,zt=h(()=>{"use strict";xn();Cn();q();Nn();w();ge=new z,Ve=class{constructor(t,r,n){this.track=t;this.httpClient=r;this.checkNetwork=n;this.configured=!1;this.config={};this.getGameId=()=>k.mpId;this.getTestAdsMode=()=>k.testAdsMode;this.asyncLoad=()=>y(this,null,function*(){var i,a,c,l,u;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=(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 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)){ge.emit("isAdShowing",!0);let n=t.adBreakDone,s=o=>{ge.emit("isAdShowing",!1),n&&n(o)};return x(g({},t),{adBreakDone:s})}else{let n=t.beforeAd,s=t.afterAd,o=()=>{ge.emit("isAdShowing",!0),this.track("CallBeforeAd",{}),n&&n()},i=()=>{ge.emit("isAdShowing",!1),this.track("CallAfterAd",{}),s&&s()};return x(g({},t),{beforeAd:o,afterAd:i})}};this.adConfig=t=>{let s=t,{onReady:r}=s,n=ae(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,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.track("PreventAdsCheating",{reason: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:"viewed"}),this.track("PreventAdsCheating",{reason:r});return;default:break}let n=t.type,s=t.adBreakDone,o=p=>{var T;this.adsActionDetection.adBreakIsShowing=!1,this.track("CallAdBreakDone",{breakType:p.breakType,breakName:(T=p.breakName)!=null?T:"",breakFormat:p.breakFormat,breakStatus:p.breakStatus}),s&&s(p)};if(t.adBreakDone=o,t.type==="reward"){let p=t.beforeReward,T=b=>()=>{this.track("CallShowAdFn",null),b()},I=b=>{p&&p(T(b))};t.beforeReward=I}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,T,I,b;if(this.track("CallAdUnit",{adFormat:(T=(p=t.adFormat)==null?void 0:p.toString())!=null?T:null,fullWidthResponsive:(I=t.fullWidthResponsive)!=null?I: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,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),o&&u.setAttribute("data-full-width-responsive",o),i&&u.setAttribute("style",i),(b=this.getTestAdsMode())!=null?b:!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(E=>{E.forEach(A=>{if(A.type==="attributes"&&A.attributeName==="data-ad-status"){let f=u.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:f!=null?f:"null"})}})}).observe(u,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})});this.antiCheating=new He(n),this.adsActionDetection=new Je(this.track),this.channelPolicy=new $e(r)}init(t){this.track("CallAdsInit",null),typeof window!="undefined"&&(this.config=t!=null?t:{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}}});var On={};lr(On,{config:()=>mo});function co(){X.on("onDocumentReady",()=>{var e;(e=oe)==null||e.onDocumentReady(window.location.href),H("onDocumentReady",{start_timestamp:Ge,timestamp:Date.now()})})}function lo(e){k.mpType==="game"&&B.start(e)}function uo(){W("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&k.onEnvConfigChanged({hostUserInfo:e}),X.emit("LifecycleEvent.onReady",g({},k.hostUserInfo?k.hostUserInfo:{isLogin:!1})),H("joliboxServiceReady",{start_timestamp:Ge,timestamp:Date.now()}),lo(t)}),W("onBeforeExit",({uuid:e})=>{var t;(t=oe)==null||t.doExit(e)})}function mo(){Ge=Date.now(),uo(),co(),Ke=_n()}var Ke,qe,Ge,Fn=h(()=>{"use strict";$();De();q();w();ie();Rn();zt();K.onReady(()=>{});K.doExit(()=>(H("onBeforeExit",{timestamp:Date.now()}),Ke==null||Ke(),B.close(Date.now()-Ge),!!qe));qe=!1;ge.on("isAdShowing",e=>{qe=e,gr(qe)&&P("updateContainerConfigSync",{displayCapsuleButton:!qe,webviewId:k.webviewId})})});function Dn(e){let t=At.config[e];return t||(t={},At.config[e]=t),(r,n)=>{if(t[r]){j.warn(`[can i use] ${r} already registered`);return}t[r]=g({},n)}}var Un=h(()=>{"use strict";w()});function Wt(e){Mn=e}function ze(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>ze(t)):Object.keys(e).reduce((t,r)=>(t[r]=ze(e[r]),t),{})}function ee(e){return typeof e=="number"}function Yt(e){let t=Qt(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Qt(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Mn,C,We,Ye,Qe,Xe,ve,Ze,et,tt,rt,nt,st,ot,it,at,ct,lt,dt,Xt=h(()=>{"use strict";Mn=!1;C=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Mn)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 ${Yt(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return ze(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:ze(this._default)}optional(){return this._optional=!0,this}};We=class extends C{validate(t){return this._optional&&t===void 0?!0:ee(t)?ee(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):ee(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):ee(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}},Ye=class extends C{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Qe=class extends C{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(ee(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(ee(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}},Xe=class extends C{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ve=class extends C{validate(t){return!0}},Ze=class extends C{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},et=class extends C{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},tt=class extends C{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},rt=class extends C{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 ${Yt(t)}`)}return!0}},nt=class extends C{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(ee(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(ee(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(ee(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}},st=class extends C{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Qt(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}},ot=class extends C{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Qt(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}},it=class extends C{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:Yt(this.value),actual:r}):!0}},at=class extends C{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
20
|
or `);this.errors.push(o)}return n}},ct=class extends C{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}},lt=class extends C{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},dt=class extends C{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 Zt(e,t,r="param"){if(e.errors=[],e.path=r,Wt(!0),!e.validate(t)){let n=e.errors.join(`
|
|
21
|
-
`);throw e.errors.length=0,Wt(!1),new TypeError(n)}}var d,er=h(()=>{"use strict";Xt();Xt();d={object(e){return new ot(e)},array(e){return new nt(e)},tuple(...e){return new ct(...e)},literal(e){return new it(e)},or(...e){return new at(...e)},symbol(){return new Xe},record(e){return new st(e)},function(){return new tt},boolean(){return new Ye},string(){return new Qe},number(){return new We},undefined(){return new Ze},null(){return new et},unknown(){return new ve},any(){return new ve},as(){return new ve},arraybuffer(){return new lt},enum(...e){return new rt(...e)},typedarray(e){return new dt(e)}}});var ut,Ln,Bn=h(()=>{"use strict";E();V();er();se();ut=1,Ln=e=>{function t(n,s){return(...o)=>{var m,p,T,I;let i=Date.now(),a={method:n,trace_id:ut};ut+=1;let c="SUCCESS",l=`${n}:ok`,u=0;try{if(s.paramsSchema)try{Zt(s.paramsSchema,o,"params")}catch(A){throw Pt(`${n}:fail ${A.message}`)}let b=s.implement(...o),v=b,k=`${n}:ok`;if(b&&"code"in b){let{code:A,data:f,message:R}=b;c=A,v=f,k=R}return{code:c,message:k,data:v}}catch(b){let v=b;u=(p=(m=v.code)!=null?m:v.errNo)!=null?p:2e3,c="FAILURE";let k=(I=(T=v.message)!=null?T:v.errMsg)!=null?I:`${b}`;return l=`${n}:${c} ${k.replace(/^\S+:(fail|cancel)\s?/,"")}`,D(new Se(l,u)),{code:c,message:l}}finally{let b=Date.now()-i;e("apiInvoked",x(g({},a),{duration:b,status:c}))}}}function r(n,s){return(...o)=>y(this,null,function*(){var p,T,I,b;let i=hr(o)?o:[o],a=Date.now(),c={method:n,trace_id:ut};ut+=1;let l=`${n}:ok`,u="SUCCESS",m={code:u,message:l};try{if(s.paramsSchema)try{Zt(s.paramsSchema,i,"params")}catch(A){throw Pt(A.message)}let k=yield s.implement(...i);if(k&&"code"in k){let{code:A,data:f,message:R}=k;u=A,l=R,k=f}return Object.assign(m,{code:u,message:l,data:k}),m}catch(v){let k=v,A=(T=(p=k.code)!=null?p:k.errNo)!=null?T:2e3;u="FAILURE";let f=(b=(I=k.message)!=null?I:k.errMsg)!=null?b:`${v}`,R=`${n}:${u} ${f.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(m,{code:u,message:R}),D(new Se(R,A)),m}finally{let v=Date.now()-a;e("apiInvoked",x(g({},c),{duration:v,status:u}))}})}return{createAPI:r,createSyncAPI:t}}});var N,F,S,te=h(()=>{"use strict";Un();ie();Bn();er();({createAPI:N,createSyncAPI:F}=Ln(H)),S=Dn("native")});var jn,fo,ho,go,vo,Jn=h(()=>{"use strict";E();te();$();jn=O(),fo="env",ho="getSystemInfoSync",go=F(ho,{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}}}),vo=F(fo,{implement:()=>{var t;let e=P("envSync");return(t=e==null?void 0:e.data)!=null?t:void 0}});jn.registerCommand("API.getSystemInfoSync",go);jn.registerCommand("API.env",vo);S("env",{version:"1.0.0"});S("getSystemInfoSync",{version:"1.0.0"})});var Hn=cr(tr=>{"use strict";E();te();V();$();ie();var yo="exitGame",bo="onReady",To="onJoliboxShow",ko="onJoliboxHide",mt=O(),pt=Oe(D),Eo=N(yo,{paramsSchema:d.tuple(d.function()),implement:e=>y(tr,null,function*(){pt(e).call(tr),yield J("exitAppAsync")})}),wo=F(To,{paramsSchema:d.tuple(d.function()),implement(e){let t=pt(e);W("onJoliboxEnterForeground",()=>{t.call(this),Ie.emit("visible",!0)})}}),So=F(ko,{paramsSchema:d.tuple(d.function()),implement(e){let t=pt(e);W("onJoliboxEnterBackground",()=>{t.call(this),Ie.emit("visible",!1)})}}),Io=F(bo,{paramsSchema:d.tuple(d.function()),implement(e){let t=pt(e);X.on("LifecycleEvent.onReady",r=>{t(r)})}});mt.registerCommand("LifecycleSDK.exit",Eo);mt.registerCommand("LifecycleSDK.onReady",Io);mt.registerCommand("LifecycleSDK.onJoliboxShow",wo);mt.registerCommand("LifecycleSDK.onJoliboxHide",So);S("lifeCycle.exit",{version:"1.0.0"});S("lifeCycle.onReady",{version:"1.0.0"});S("lifeCycle.onJoliboxShow",{version:"1.0.0"});S("lifeCycle.onJoliboxHide",{version:"1.0.0"})});function $n(e){let t={};if(!M(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 Vn(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 Kn(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function qn(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!M(r))return e;let[n,s=""]=e.split("?"),o=JSON.stringify(g(g({},JSON.parse(s)),r));return`${n}?${o}`}var Gn=h(()=>{"use strict";E()});var Ao,_o,rr,nr,zn,Ro,xo,Po,Wn=h(()=>{"use strict";se();qt();te();Gn();E();V();Ao=15,_o=Le("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),rr=0,nr=[],zn=Oe(D),Ro=(e,t)=>{let r=e.filter(t),n=e.filter(s=>!t(s));return e.length=0,e.push(...n),r},xo=e=>{let t=new ne,r=()=>{};return N("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(s){let o=()=>y(this,null,function*(){var a,c;let i=zn(s.fail);try{if(rr+=1,t.state!=="pending")return;let{data:l,dataType:u,responseType:m,enableCache:p,appendHostCookie:T}=s,I=$n(s.header),b=Vn(s.method),v=Kn(s.timeout),k=qn(s.url,b,l),A=zn(s.success),f=Object.assign({},s,{method:b,header:I,data:b==="GET"||b==="HEAD"?void 0:l,enableCache:p,query:(a=s.query)!=null?a:{},dataType:u,responseType:m,appendHostCookie:T});v&&(f.timeout=v);let R=_o(k,f);{let{response:fe}=yield R,{code:U,data:be,message:re}=fe;t.resolve({code:U!=null?U:"SUCCESS",data:be,message:re!=null?re:"request:ok"}),A({code:"SUCCESS",message:"request:ok",data:be})}}catch(l){t.reject(l),i({code:"FAILURE",message:"httpRequst: failed"})}finally{rr-=1,(c=nr.shift())==null||c()}});return rr>=Ao?(r=()=>{Ro(nr,i=>i===o)},nr.push(o)):o(),t.promise}})(e),{abort(){t.reject(ue({code:-1,msg:"request:fail abort"})),r()}}},Po=O();Po.registerCommand("HttpSDK.request",xo);S("request",{version:"1.0.0"})});function Uo(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return Do.includes(t)?t:""}function Mo(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 Lo(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 ft,Co,No,Oo,Fo,cd,ld,Do,Yn=h(()=>{"use strict";te();$();E();Be();q();ft=O(),Co=N("getLocalStorage",{paramsSchema:d.tuple(d.string()),implement(e){return y(this,null,function*(){let{response:t}=yield Z(`/api/games/user-storage/${w.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 J("getLocalStorageAsync",{key:e}),a=Mo(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}}})}});ft.registerCommand("StorageSDK.getItem",Co);S("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});No=N("setStorage",{paramsSchema:d.tuple(d.string(),d.or(d.string(),d.boolean(),d.number())),implement(e,t){return y(this,null,function*(){let r=w.mpId,n=typeof t=="string"?t:String(t),{response:s}=yield Z(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:o,message:i}}=s,a=Uo(t),c=Lo(t,a);return yield J("setLocalStorageAsync",{key:e,data:c,dataType:a}),o=="SUCCESS"?{code:o,message:i}:{code:o,message:`${i}. fallback to native`}})}});ft.registerCommand("StorageSDK.setItem",No);S("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});Oo=N("removeStorage",{paramsSchema:d.tuple(d.string()),implement(e){return y(this,null,function*(){let t=w.mpId,{response:r}=yield Z(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:s}}=r;return yield J("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:s}:{code:n,message:"[Jolibox SDK] remove item succ"}})}});ft.registerCommand("StorageSDK.removeItem",Oo);S("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});Fo=N("clearStorage",{implement(){return y(this,null,function*(){let e=w.mpId,{response:t}=yield Z(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});J("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}})}});ft.registerCommand("StorageSDK.clear",Fo);S("storage.clear",{version:"1.0.0"});cd=N("getStorageInfo",{implement(){return y(this,null,function*(){let{data:e}=yield J("getStorageInfoAsync");return e})}});S("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});ld=F("getStorageInfoSync",{implement(){return P("getStorageInfoSync")}}),Do=["string","number","boolean","object",""]});var Bo,jo,Jo,sr,Qn=h(()=>{"use strict";E();$();te();Bo=F("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)),P("showKeyboardSync",x(g({},e),{defaultValue:r,maxLength:t}))}});S("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"}});jo=F("updateKeyboard",{paramsSchema:d.tuple(d.object({value:d.string()})),implement(e){P("updateKeyboardSync",e)}});S("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});Jo=F("hideKeyboard",{implement(){P("hideKeyboardSync")}});S("keyboard.hideKeyboard",{version:"1.0.0"});sr=O();sr.registerCommand("KeyboardSDK.showKeyboard",Bo);sr.registerCommand("KeyboardSDK.updateKeyboard",jo);sr.registerCommand("KeyboardSDK.hideKeyboard",Jo)});var Xn=cr(pe=>{"use strict";E();te();ie();var ye=O(),Ho=N("levelFinished",{paramsSchema:d.tuple(d.string(),d.object({result:d.boolean(),duration:d.number()})),implement:(e,t)=>y(pe,null,function*(){let{result:r,duration:n}=t,s=[];s.push(B.tracker("LevelFinished",{levelId:e,result:r,duration:n})),s.push(B.reporter({event:"COMPLETE_GAME_LEVEL"})),yield Promise.all(s)})}),$o=N("taskFinished",{paramsSchema:d.tuple(d.string(),d.object({duration:d.number()})),implement:(e,t)=>y(pe,null,function*(){let{duration:r}=t;return yield B.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})})}),Vo=N("levelUpgrade",{paramsSchema:d.tuple(d.string(),d.string()),implement:(e,t)=>y(pe,null,function*(){let r=[];r.push(B.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),yield Promise.all(r)})}),Ko=N("onHistoryUserLevel",{paramsSchema:d.tuple(d.number()),implement:e=>y(pe,null,function*(){return yield B.reportToNative({event:"HistoryUserLevel",params:{level:e}})})}),qo=N("onHistoryUserScore",{paramsSchema:d.tuple(d.number()),implement:e=>y(pe,null,function*(){return yield B.reportToNative({event:"HistoryUserScore",params:{score:e}})})}),Go=N("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(pe,null,function*(){var n,s;let r=[];r.push(B.reportToNative({event:"TaskEvent",params:g({taskId:e},t)})),(s=(n=t.tools)==null?void 0:n.length)!=null&&s&&(r.push(B.reporter({event:"USE_GAME_ITEM"})),r.push(B.reportToNative({event:"UseGameItem",params:g({taskId:e},t)}))),yield Promise.all(r)})});ye.registerCommand("TaskTrackerSDK.levelFinished",Ho);ye.registerCommand("TaskTrackerSDK.taskFinished",$o);ye.registerCommand("TaskTrackerSDK.levelUpgrade",Vo);ye.registerCommand("TaskTrackerSDK.historyUserLevel",Ko);ye.registerCommand("TaskTrackerSDK.historyUserScore",qo);ye.registerCommand("TaskTrackerSDK.taskEvent",Go);S("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});S("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});S("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});S("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});S("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});S("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 zo,Wo,Zn,es=h(()=>{"use strict";q();$();te();E();se();S("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"}});S("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});zo=N("login",{implement(){return y(this,null,function*(){var i;let{data:{isLogin:e}}=yield J("checkLoginAsync");if(e)return{isLogin:!0,token:(i=w.hostUserInfo)==null?void 0:i.token};W("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 ue({code:-1,msg:"login failed"});let{promise:n,resolve:s}=new ne,o=yield n;return w.onEnvConfigChanged({hostUserInfo:o}),X.emit("onLoginComplete",o),o})}}),Wo=N("checkSession",{implement(){return y(this,null,function*(){let{data:{isLogin:e}}=yield J("checkLoginAsync");return{isLogin:e}})}}),Zn=O();Zn.registerCommand("API.login",zo);Zn.registerCommand("API.checkSession",Wo)});var ht,Yo,gt,Qo,Xo,Zo,ei,ts=h(()=>{"use strict";E();te();zt();ie();Be();$();ht=O(),Yo=()=>{let{data:e}=P("getNetworkStatusSync");return!!(e!=null&&e.isConnected)},gt=new Ve(H,{get:(e,t)=>Z(e,g({method:"GET",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data)},Yo),Qo=F("adInit",{implement:e=>{gt.init(e)}}),Xo=F("adConfig",{implement:e=>{gt.adConfig(e)}}),Zo=F("adBreak",{implement:e=>{gt.adBreak(e)}}),ei=F("adUnit",{implement:e=>{gt.adUnit(e)}});ht.registerCommand("AdsSDK.init",Qo);ht.registerCommand("AdsSDK.adConfig",Xo);ht.registerCommand("AdsSDK.adBreak",Zo);ht.registerCommand("AdsSDK.adUnit",ei);S("AdsSDK.init",{version:"1.0.0"});S("AdsSDK.adConfig",{version:"1.0.0"});S("AdsSDK.adBreak",{version:"1.0.0"});S("AdsSDK.adUnit",{version:"1.0.0"})});var ti={};var Hd,qd,rs=h(()=>{"use strict";Jn();Hd=dr(Hn());Wn();Yn();Qn();qd=dr(Xn());es();ts()});var ns=Symbol.for("JOLIBOX_IMPLEMENT_INIT");if(window[ns])throw console.info("Jolibox Implement Already Initialized"),new Error("Jolibox Implement Already Initialized");window[ns]=!0;y(void 0,null,function*(){let[{config:e}]=yield Promise.all([Promise.resolve().then(()=>(Fn(),On)),Promise.resolve().then(()=>(rs(),ti)),Promise.resolve().then(()=>(ie(),An))]);e()});
|
|
21
|
+
`);throw e.errors.length=0,Wt(!1),new TypeError(n)}}var d,er=h(()=>{"use strict";Xt();Xt();d={object(e){return new ot(e)},array(e){return new nt(e)},tuple(...e){return new ct(...e)},literal(e){return new it(e)},or(...e){return new at(...e)},symbol(){return new Xe},record(e){return new st(e)},function(){return new tt},boolean(){return new Ye},string(){return new Qe},number(){return new We},undefined(){return new Ze},null(){return new et},unknown(){return new ve},any(){return new ve},as(){return new ve},arraybuffer(){return new lt},enum(...e){return new rt(...e)},typedarray(e){return new dt(e)}}});var ut,Ln,Bn=h(()=>{"use strict";w();V();er();se();ut=1,Ln=e=>{function t(n,s){return(...o)=>{var m,p,T,I;let i=Date.now(),a={method:n,trace_id:ut};ut+=1;let c="SUCCESS",l=`${n}:ok`,u=0;try{if(s.paramsSchema)try{Zt(s.paramsSchema,o,"params")}catch(A){throw Pt(`${n}:fail ${A.message}`)}let b=s.implement(...o),v=b,E=`${n}:ok`;if(b&&"code"in b){let{code:A,data:f,message:R}=b;c=A,v=f,E=R}return{code:c,message:E,data:v}}catch(b){let v=b;u=(p=(m=v.code)!=null?m:v.errNo)!=null?p:2e3,c="FAILURE";let E=(I=(T=v.message)!=null?T:v.errMsg)!=null?I:`${b}`;return l=`${n}:${c} ${E.replace(/^\S+:(fail|cancel)\s?/,"")}`,D(new Se(l,u)),{code:c,message:l}}finally{let b=Date.now()-i;e("apiInvoked",x(g({},a),{duration:b,status:c}))}}}function r(n,s){return(...o)=>y(this,null,function*(){var p,T,I,b;let i=hr(o)?o:[o],a=Date.now(),c={method:n,trace_id:ut};ut+=1;let l=`${n}:ok`,u="SUCCESS",m={code:u,message:l};try{if(s.paramsSchema)try{Zt(s.paramsSchema,i,"params")}catch(A){throw Pt(A.message)}let E=yield s.implement(...i);if(E&&"code"in E){let{code:A,data:f,message:R}=E;u=A,l=R,E=f}return Object.assign(m,{code:u,message:l,data:E}),m}catch(v){let E=v,A=(T=(p=E.code)!=null?p:E.errNo)!=null?T:2e3;u="FAILURE";let f=(b=(I=E.message)!=null?I:E.errMsg)!=null?b:`${v}`,R=`${n}:${u} ${f.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(m,{code:u,message:R}),D(new Se(R,A)),m}finally{let v=Date.now()-a;e("apiInvoked",x(g({},c),{duration:v,status:u}))}})}return{createAPI:r,createSyncAPI:t}}});var N,F,S,te=h(()=>{"use strict";Un();ie();Bn();er();({createAPI:N,createSyncAPI:F}=Ln(H)),S=Dn("native")});var jn,fo,ho,go,vo,Jn=h(()=>{"use strict";w();te();$();jn=O(),fo="env",ho="getSystemInfoSync",go=F(ho,{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}}}),vo=F(fo,{implement:()=>{var t;let e=P("envSync");return(t=e==null?void 0:e.data)!=null?t:void 0}});jn.registerCommand("API.getSystemInfoSync",go);jn.registerCommand("API.env",vo);S("env",{version:"1.0.0"});S("getSystemInfoSync",{version:"1.0.0"})});var Hn=cr(tr=>{"use strict";w();te();V();$();ie();var yo="exitGame",bo="onReady",To="onJoliboxShow",ko="onJoliboxHide",mt=O(),pt=Oe(D),Eo=N(yo,{paramsSchema:d.tuple(d.function()),implement:e=>y(tr,null,function*(){pt(e).call(tr),yield J("exitAppAsync")})}),wo=F(To,{paramsSchema:d.tuple(d.function()),implement(e){let t=pt(e);W("onJoliboxEnterForeground",()=>{t.call(this),Ie.emit("visible",!0)})}}),So=F(ko,{paramsSchema:d.tuple(d.function()),implement(e){let t=pt(e);W("onJoliboxEnterBackground",()=>{t.call(this),Ie.emit("visible",!1)})}}),Io=F(bo,{paramsSchema:d.tuple(d.function()),implement(e){let t=pt(e);X.on("LifecycleEvent.onReady",r=>{t(r)})}});mt.registerCommand("LifecycleSDK.exit",Eo);mt.registerCommand("LifecycleSDK.onReady",Io);mt.registerCommand("LifecycleSDK.onJoliboxShow",wo);mt.registerCommand("LifecycleSDK.onJoliboxHide",So);S("lifeCycle.exit",{version:"1.0.0"});S("lifeCycle.onReady",{version:"1.0.0"});S("lifeCycle.onJoliboxShow",{version:"1.0.0"});S("lifeCycle.onJoliboxHide",{version:"1.0.0"})});function $n(e){let t={};if(!M(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 Vn(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 Kn(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function qn(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!M(r))return e;let[n,s=""]=e.split("?"),o=JSON.stringify(g(g({},JSON.parse(s)),r));return`${n}?${o}`}var Gn=h(()=>{"use strict";w()});var Ao,_o,rr,nr,zn,Ro,xo,Po,Wn=h(()=>{"use strict";se();qt();te();Gn();w();V();Ao=15,_o=Le("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),rr=0,nr=[],zn=Oe(D),Ro=(e,t)=>{let r=e.filter(t),n=e.filter(s=>!t(s));return e.length=0,e.push(...n),r},xo=e=>{let t=new ne,r=()=>{};return N("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(s){let o=()=>y(this,null,function*(){var a,c;let i=zn(s.fail);try{if(rr+=1,t.state!=="pending")return;let{data:l,dataType:u,responseType:m,enableCache:p,appendHostCookie:T}=s,I=$n(s.header),b=Vn(s.method),v=Kn(s.timeout),E=qn(s.url,b,l),A=zn(s.success),f=Object.assign({},s,{method:b,header:I,data:b==="GET"||b==="HEAD"?void 0:l,enableCache:p,query:(a=s.query)!=null?a:{},dataType:u,responseType:m,appendHostCookie:T});v&&(f.timeout=v);let R=_o(E,f);{let{response:fe}=yield R,{code:U,data:be,message:re}=fe;t.resolve({code:U!=null?U:"SUCCESS",data:be,message:re!=null?re:"request:ok"}),A({code:"SUCCESS",message:"request:ok",data:be})}}catch(l){t.reject(l),i({code:"FAILURE",message:"httpRequst: failed"})}finally{rr-=1,(c=nr.shift())==null||c()}});return rr>=Ao?(r=()=>{Ro(nr,i=>i===o)},nr.push(o)):o(),t.promise}})(e),{abort(){t.reject(ue({code:-1,msg:"request:fail abort"})),r()}}},Po=O();Po.registerCommand("HttpSDK.request",xo);S("request",{version:"1.0.0"})});function Uo(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return Do.includes(t)?t:""}function Mo(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 Lo(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 ft,Co,No,Oo,Fo,cd,ld,Do,Yn=h(()=>{"use strict";te();$();w();Be();q();ft=O(),Co=N("getLocalStorage",{paramsSchema:d.tuple(d.string()),implement(e){return y(this,null,function*(){let{response:t}=yield Z(`/api/games/user-storage/${k.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 J("getLocalStorageAsync",{key:e}),a=Mo(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}}})}});ft.registerCommand("StorageSDK.getItem",Co);S("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});No=N("setStorage",{paramsSchema:d.tuple(d.string(),d.or(d.string(),d.boolean(),d.number())),implement(e,t){return y(this,null,function*(){let r=k.mpId,n=typeof t=="string"?t:String(t),{response:s}=yield Z(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:o,message:i}}=s,a=Uo(t),c=Lo(t,a);return yield J("setLocalStorageAsync",{key:e,data:c,dataType:a}),o=="SUCCESS"?{code:o,message:i}:{code:o,message:`${i}. fallback to native`}})}});ft.registerCommand("StorageSDK.setItem",No);S("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});Oo=N("removeStorage",{paramsSchema:d.tuple(d.string()),implement(e){return y(this,null,function*(){let t=k.mpId,{response:r}=yield Z(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:s}}=r;return yield J("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:s}:{code:n,message:"[Jolibox SDK] remove item succ"}})}});ft.registerCommand("StorageSDK.removeItem",Oo);S("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});Fo=N("clearStorage",{implement(){return y(this,null,function*(){let e=k.mpId,{response:t}=yield Z(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});J("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}})}});ft.registerCommand("StorageSDK.clear",Fo);S("storage.clear",{version:"1.0.0"});cd=N("getStorageInfo",{implement(){return y(this,null,function*(){let{data:e}=yield J("getStorageInfoAsync");return e})}});S("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});ld=F("getStorageInfoSync",{implement(){return P("getStorageInfoSync")}}),Do=["string","number","boolean","object",""]});var Bo,jo,Jo,sr,Qn=h(()=>{"use strict";w();$();te();Bo=F("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)),P("showKeyboardSync",x(g({},e),{defaultValue:r,maxLength:t}))}});S("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"}});jo=F("updateKeyboard",{paramsSchema:d.tuple(d.object({value:d.string()})),implement(e){P("updateKeyboardSync",e)}});S("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});Jo=F("hideKeyboard",{implement(){P("hideKeyboardSync")}});S("keyboard.hideKeyboard",{version:"1.0.0"});sr=O();sr.registerCommand("KeyboardSDK.showKeyboard",Bo);sr.registerCommand("KeyboardSDK.updateKeyboard",jo);sr.registerCommand("KeyboardSDK.hideKeyboard",Jo)});var Xn=cr(pe=>{"use strict";w();te();ie();var ye=O(),Ho=N("levelFinished",{paramsSchema:d.tuple(d.string(),d.object({result:d.boolean(),duration:d.number()})),implement:(e,t)=>y(pe,null,function*(){let{result:r,duration:n}=t,s=[];s.push(B.tracker("LevelFinished",{levelId:e,result:r,duration:n})),s.push(B.reporter({event:"COMPLETE_GAME_LEVEL"})),yield Promise.all(s)})}),$o=N("taskFinished",{paramsSchema:d.tuple(d.string(),d.object({duration:d.number()})),implement:(e,t)=>y(pe,null,function*(){let{duration:r}=t;return yield B.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})})}),Vo=N("levelUpgrade",{paramsSchema:d.tuple(d.string(),d.string()),implement:(e,t)=>y(pe,null,function*(){let r=[];r.push(B.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),yield Promise.all(r)})}),Ko=N("onHistoryUserLevel",{paramsSchema:d.tuple(d.number()),implement:e=>y(pe,null,function*(){return yield B.reportToNative({event:"HistoryUserLevel",params:{level:e}})})}),qo=N("onHistoryUserScore",{paramsSchema:d.tuple(d.number()),implement:e=>y(pe,null,function*(){return yield B.reportToNative({event:"HistoryUserScore",params:{score:e}})})}),Go=N("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(pe,null,function*(){var n,s;let r=[];r.push(B.reportToNative({event:"TaskEvent",params:g({taskId:e},t)})),(s=(n=t.tools)==null?void 0:n.length)!=null&&s&&(r.push(B.reporter({event:"USE_GAME_ITEM"})),r.push(B.reportToNative({event:"UseGameItem",params:g({taskId:e},t)}))),yield Promise.all(r)})});ye.registerCommand("TaskTrackerSDK.levelFinished",Ho);ye.registerCommand("TaskTrackerSDK.taskFinished",$o);ye.registerCommand("TaskTrackerSDK.levelUpgrade",Vo);ye.registerCommand("TaskTrackerSDK.historyUserLevel",Ko);ye.registerCommand("TaskTrackerSDK.historyUserScore",qo);ye.registerCommand("TaskTrackerSDK.taskEvent",Go);S("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});S("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});S("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});S("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});S("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});S("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 zo,Wo,Zn,es=h(()=>{"use strict";q();$();te();w();se();S("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"}});S("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});zo=N("login",{implement(){return y(this,null,function*(){var i;let{data:{isLogin:e}}=yield J("checkLoginAsync");if(e)return{isLogin:!0,token:(i=k.hostUserInfo)==null?void 0:i.token};W("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 ue({code:-1,msg:"login failed"});let{promise:n,resolve:s}=new ne,o=yield n;return k.onEnvConfigChanged({hostUserInfo:o}),X.emit("onLoginComplete",o),o})}}),Wo=N("checkSession",{implement(){return y(this,null,function*(){let{data:{isLogin:e}}=yield J("checkLoginAsync");return{isLogin:e}})}}),Zn=O();Zn.registerCommand("API.login",zo);Zn.registerCommand("API.checkSession",Wo)});var ht,Yo,gt,Qo,Xo,Zo,ei,ts=h(()=>{"use strict";w();te();zt();ie();Be();$();ht=O(),Yo=()=>{let{data:e}=P("getNetworkStatusSync");return!!(e!=null&&e.isConnected)},gt=new Ve(H,{get:(e,t)=>Z(e,g({method:"GET",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data)},Yo),Qo=F("adInit",{implement:e=>{gt.init(e)}}),Xo=F("adConfig",{implement:e=>{gt.adConfig(e)}}),Zo=F("adBreak",{implement:e=>{gt.adBreak(e)}}),ei=F("adUnit",{implement:e=>{gt.adUnit(e)}});ht.registerCommand("AdsSDK.init",Qo);ht.registerCommand("AdsSDK.adConfig",Xo);ht.registerCommand("AdsSDK.adBreak",Zo);ht.registerCommand("AdsSDK.adUnit",ei);S("AdsSDK.init",{version:"1.0.0"});S("AdsSDK.adConfig",{version:"1.0.0"});S("AdsSDK.adBreak",{version:"1.0.0"});S("AdsSDK.adUnit",{version:"1.0.0"})});var ti={};var Hd,qd,rs=h(()=>{"use strict";Jn();Hd=dr(Hn());Wn();Yn();Qn();qd=dr(Xn());es();ts()});var ns=Symbol.for("JOLIBOX_IMPLEMENT_INIT");if(window[ns])throw console.info("Jolibox Implement Already Initialized"),new Error("Jolibox Implement Already Initialized");window[ns]=!0;y(void 0,null,function*(){let[{config:e}]=yield Promise.all([Promise.resolve().then(()=>(Fn(),On)),Promise.resolve().then(()=>(rs(),ti)),Promise.resolve().then(()=>(ie(),An))]);e()});
|
package/implement.build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Invoking: npm run clean && npm run build:esm && tsc
|
|
2
2
|
|
|
3
|
-
> @jolibox/implement@1.1.
|
|
3
|
+
> @jolibox/implement@1.1.10-beta.1 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/implement@1.1.
|
|
7
|
+
> @jolibox/implement@1.1.10-beta.1 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.
|
|
4
|
+
"version": "1.1.10-beta.1",
|
|
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.
|
|
10
|
-
"@jolibox/types": "1.1.
|
|
9
|
+
"@jolibox/common": "1.1.10-beta.1",
|
|
10
|
+
"@jolibox/types": "1.1.10-beta.1",
|
|
11
11
|
"localforage": "1.10.0",
|
|
12
12
|
"web-vitals": "4.2.4"
|
|
13
13
|
},
|
|
@@ -20,28 +20,12 @@ export abstract class EventTracker {
|
|
|
20
20
|
abstract doReport<T extends Record<string, unknown>>(event: unknown[], extra: T): void;
|
|
21
21
|
abstract doReport<T extends Record<string, unknown>>(event: unknown[], extra?: T): void;
|
|
22
22
|
|
|
23
|
-
private pastTrackings: boolean[] = [];
|
|
24
23
|
private samplesConfig: ISamplesConfig | null = null;
|
|
25
24
|
|
|
26
|
-
private pushPastTracking = (tracking: boolean) => {
|
|
27
|
-
this.pastTrackings.push(tracking);
|
|
28
|
-
if (this.pastTrackings.length > 10) {
|
|
29
|
-
this.pastTrackings.slice(-10);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
25
|
constructor() {
|
|
34
26
|
this.fetchSamplesConfig();
|
|
35
27
|
}
|
|
36
28
|
|
|
37
|
-
public get networkIsOk() {
|
|
38
|
-
// in the past 10 trackings, at least 60% of them are successful
|
|
39
|
-
return (
|
|
40
|
-
this.pastTrackings.length <= 4 ||
|
|
41
|
-
this.pastTrackings.filter(Boolean).length / this.pastTrackings.length >= 0.6
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
29
|
private async fetchSamplesConfig() {
|
|
46
30
|
const host = context.testMode ? 'https://stg-api.jolibox.com' : 'https://api.jolibox.com';
|
|
47
31
|
const path = `${host}/api/fe-configs/js-sdk/samples-config`;
|
|
@@ -119,11 +103,9 @@ export abstract class EventTracker {
|
|
|
119
103
|
};
|
|
120
104
|
try {
|
|
121
105
|
extraInfo
|
|
122
|
-
? this.doReport(serializeEventPackage(eventPackage), extraInfo)
|
|
123
|
-
: this.doReport(serializeEventPackage(eventPackage));
|
|
124
|
-
this.pushPastTracking(true);
|
|
106
|
+
? await this.doReport(serializeEventPackage(eventPackage), extraInfo)
|
|
107
|
+
: await this.doReport(serializeEventPackage(eventPackage));
|
|
125
108
|
} catch (e) {
|
|
126
|
-
this.pushPastTracking(false);
|
|
127
109
|
logger.log('[Jolibox SDK] report API error', e);
|
|
128
110
|
}
|
|
129
111
|
}
|
package/src/h5/api/ads.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { JoliboxAdsImpl, adEventEmitter } from '@/common/ads';
|
|
2
2
|
import { track } from '../report';
|
|
3
|
-
import { tracker as h5Tracker } from '../report/event-tracker';
|
|
4
3
|
import { createCommands } from '@jolibox/common';
|
|
5
|
-
import
|
|
4
|
+
import { httpClientManager } from '../http';
|
|
6
5
|
import { notifyCustomEvent } from '@/common/utils';
|
|
7
6
|
const commands = createCommands();
|
|
8
|
-
|
|
7
|
+
|
|
8
|
+
const httpClient = httpClientManager.create();
|
|
9
|
+
const ads = new JoliboxAdsImpl(track, httpClient, () => httpClientManager.getNetworkStatus());
|
|
9
10
|
|
|
10
11
|
adEventEmitter.on('isAdShowing', (isAdShowing) => {
|
|
11
12
|
notifyCustomEvent('JOLIBOX_ADS_EVENT', { isAdShowing });
|
package/src/h5/api/storage.ts
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { createAPI, t, registerCanIUse } from './base';
|
|
2
|
-
import { createCommands
|
|
3
|
-
import
|
|
2
|
+
import { createCommands } from '@jolibox/common';
|
|
3
|
+
import { httpClientManager } from '@/h5/http';
|
|
4
4
|
import { context } from '@/common/context';
|
|
5
|
-
import {
|
|
5
|
+
import { StorageResponse } from '@jolibox/types';
|
|
6
6
|
import localForage from 'localforage';
|
|
7
7
|
|
|
8
8
|
const commands = createCommands();
|
|
9
9
|
|
|
10
10
|
export class JoliboxCloudStorage {
|
|
11
11
|
private gameId: string;
|
|
12
|
-
private httpClient
|
|
12
|
+
private httpClient = httpClientManager.create({
|
|
13
|
+
baseUrl: context.testMode ? 'https://stg-api.jolibox.com' : 'https://api.jolibox.com'
|
|
14
|
+
});
|
|
13
15
|
private gameStore: LocalForage;
|
|
14
16
|
constructor() {
|
|
15
17
|
this.gameId = this.getGameId();
|
|
16
|
-
this.httpClient = new JoliboxHttpClient({
|
|
17
|
-
baseUrl: context.testMode ? 'https://stg-api.jolibox.com' : 'https://api.jolibox.com'
|
|
18
|
-
});
|
|
19
18
|
//没有game的情况使用全局空间
|
|
20
19
|
this.gameStore = localForage.createInstance({
|
|
21
20
|
name: this.gameId.length ? this.gameId : 'default'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { hostEmitter } from '@jolibox/common';
|
|
2
2
|
import { taskTracker, track } from '../report';
|
|
3
3
|
import { onFCP, onLCP, onTTFB } from 'web-vitals';
|
|
4
|
+
import { context } from '@/common/context';
|
|
4
5
|
|
|
5
6
|
function trackPerformance() {
|
|
6
7
|
onFCP((metric) => {
|
|
@@ -34,7 +35,9 @@ function addDomContentLoaded() {
|
|
|
34
35
|
isLogin: false
|
|
35
36
|
});
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
if (context.mpType === 'game') {
|
|
39
|
+
taskTracker.start(Date.now() - startTime);
|
|
40
|
+
}
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
43
|
|