@jolibox/implement 1.4.6 → 1.4.7
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 +2 -2
- package/dist/index.js +10 -10
- package/dist/index.native.js +4 -4
- package/implement.build.log +2 -2
- package/package.json +6 -6
- package/src/native/api/rewards.ts +13 -9
package/dist/index.native.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var nO=Object.create;var Ia=Object.defineProperty,iO=Object.defineProperties,oO=Object.getOwnPropertyDescriptor,aO=Object.getOwnPropertyDescriptors,sO=Object.getOwnPropertyNames,Sa=Object.getOwnPropertySymbols,cO=Object.getPrototypeOf,Ll=Object.prototype.hasOwnProperty,Sh=Object.prototype.propertyIsEnumerable;var wh=(e,t,r)=>t in e?Ia(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))Ll.call(t,r)&&wh(e,r,t[r]);if(Sa)for(var r of Sa(t))Sh.call(t,r)&&wh(e,r,t[r]);return e},B=(e,t)=>iO(e,aO(t));var Qe=(e,t)=>{var r={};for(var n in e)Ll.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Sa)for(var n of Sa(e))t.indexOf(n)<0&&Sh.call(e,n)&&(r[n]=e[n]);return r};var x=(e,t)=>()=>(e&&(t=e(e=0)),t);var h=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ih=(e,t)=>{for(var r in t)Ia(e,r,{get:t[r],enumerable:!0})},lO=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of sO(t))!Ll.call(e,i)&&i!==r&&Ia(e,i,{get:()=>t[i],enumerable:!(n=oO(t,i))||n.enumerable});return e};var se=(e,t,r)=>(r=e!=null?nO(cO(e)):{},lO(t||!e||!e.__esModule?Ia(r,"default",{value:e,enumerable:!0}):r,e));var g=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});function hO(e){return!!(e!=null&&e.__nativeBuffers__)}function Gl(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!hO(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 i;n.value?i=n.value:n.base64&&(i=gO(n.base64)),typeof i!="undefined"&&i instanceof ArrayBuffer&&(e[n.key]=i)}}return e}function yO(e={},t=!1){let r=e,n=[];for(let[i,o]of Object.entries(r))if(o!==void 0&&o instanceof ArrayBuffer&&o.byteLength!==void 0){let a=t?{value:o,key:i}:{base64:vO(o),key:i};n.push(a),delete r[i]}return n.length>0&&(r.__nativeBuffers__=n),r}function SO(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function qh(e){return typeof e=="string"}function Gn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Ah(e){return typeof e=="number"&&!isNaN(e)}function EO(e){return typeof e=="undefined"}function AO(e){return EO(e)||e===null}function Uh(e){return typeof e=="function"}function CO(e){return Gn(e)&&Uh(e.then)}function Mh(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function Gi(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function NO(e,t,r){let n=e;for(let i of t)if(n&&typeof n=="object")n=n[i];else return r;return n===void 0?r:n}function MO(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}function JO(e){return new Promise(t=>Fh(e)(t))}function Fh(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function HO(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Vi(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function $O(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)WO(e[n],t[n])}function WO(e,t){if(qh(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Uh(t)){try{if(e instanceof t)return}catch(r){}if(!AO(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 Xe(e,t){if(Hl.config[e]){Ta.warn(`[can i use] ${e} already registered`);return}Hl.config[e]=ur({},t)}function xh(e,t){return`[${e}]:${t}`}function eR(e,t){Th||(Ml=new Aa({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),Fl=new Aa({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),jl=new Aa({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),t("onJoliboxEnterBackground",()=>{Ml.flush(),Fl.flush(),jl.flush()}),Th=!0);function r(i){var o,a;let{method:s,args:c,startTime:l,isForeground:d,errMsg:u=`${s}:fail no errMsg`,errNo:p=0,__timing:f={receiveJSInvoke:0,invokeCallback:0}}=i,{receiveJSInvoke:m,invokeCallback:v}=f,b=(a=(o=u.match(/\S:(\S+)\s?/))==null?void 0:o[1])!=null?a:"fail";Ml.report({status:b,method:n(s,c),errNo:`${p}`,errMsg:u,isForeground:d,duration:Date.now()-l}),l&&m&&v&&(Fl.report({status:b,method:s,isForeground:d,duration:Number((m-l).toFixed(3))}),jl.report({status:b,method:s,isForeground:d,duration:Number((Date.now()-v).toFixed(3))}))}function n(i,o){return(i==="callHostMethod"||i==="callHostMethodSync")&&o!=null&&o.method?`${i}-${o.method}`:i}return r}function iR(e,t){let r=0,n=!0,i=nR.resolveMap,o=eR(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,Bl.forEach(c=>ka(this,[c],function*({method:l,args:d,resolve:u}){let p=yield s(l,d);u(p)})),Bl.length=0});let a=(c,l)=>{let d=i.get(Number(c));if(!d)return;let u=Gl(l);d(u),i.delete(Number(c))},s=(c,l)=>{var d,u;let p=Date.now(),f=`${n}`;r+=1;let m=new IO;if(i.set(r,m.resolve),!n&&YO.includes(c))return new Promise(C=>{Bl.push({method:c,args:l,resolve:C})});let v=fO(ur({},{method:c,startTime:p,args:l,isForeground:f}),{invokeType:"js-bridge"}),b=!tR&&KO.includes(c),y=yO(l,b),w=b?y:JSON.stringify(y),E;if(c.endsWith("Sync")||QO.includes(c)?E=(d=e.call)==null?void 0:d.call(e,c,y,r):typeof w=="string"?E=e.invoke(c,w,r):E=(u=e.call)==null?void 0:u.call(e,c,w,r),E){try{typeof E=="string"&&(E=JSON.parse(E)),E=Gl(E)}catch(C){Ta.error(C)}return i.delete(r),E.errorCode&&(E.errorCode=xh(c,E.errorCode)),o(ur(ur({},v),E)),E}return c.endsWith("Sync")&&i.delete(r),m.promise.then(C=>(C.errorCode&&(C.errorCode=xh(c,C.errorCode)),o(ur(ur({},v),C)),C))};return{invokeNative:s,applyNative:(c,l)=>{let d=s(c,l);return CO(d)?d.then(u=>Ph(c,u)):Ph(c,d)},invokeHandler:a}}function Ph(e,t){if(!Gn(t)){Ta.warn(`[Jolibox SDK]${e} no response value`);return}let r=t,{errMsg:n,errNo:i,errorType:o,errorCode:a}=r,s=mO(r,["errMsg","errNo","errorType","errorCode"]);if(n&&n!==`${e}:ok`)throw new PO(n,i,o,a);return s}function oR(e){if(globalThis[Ea])return globalThis[Ea];let t=new Wl,r=new Wl,n=new Aa({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}});return t.on("onJoliboxEnterBackground",()=>{n.flush()}),globalThis[Ea]={onNative:t.on.bind(t),offNative:t.off.bind(t),subscribe:r.on.bind(r),unsubscribe:r.off.bind(r),subscribeHandler(i,o,a){let s=Gl(o),c;if(s.__extra){c=s.params;let{type:l,startTime:d}=s.__extra;n.report({type:l,event:i,duration:Date.now()-d})}else c=s;if(i===jh){c.forEach(l=>{let[d,u]=l;try{r.emit(d.slice(Hi.length),u,a)}catch(p){}});return}if(i.startsWith(Hi)){r.emit(i.slice(Hi.length),c,a);return}t.emit(i,c,a)}},globalThis[Ea]}function aR(e){let t=new Map,r=new Map,n,i;return{publish:(o,a,s,c)=>{if(c){let d=s!==void 0?s==="*"?"*":[s]:void 0;e.publish(`${Hi}${o}`,a,d);return}n||(n=Promise.resolve().then(()=>{t.forEach((d,u)=>{try{let p=u!==void 0?u==="*"?"*":[u]:void 0;e.publish(jh,d,p)}catch(p){}}),n=void 0,t.clear()}));let l=t.get(s);l||(l=[],t.set(s,l)),l.push([`${Hi}${o}`,a])},emitNative:(o,a,s,c)=>{if(c){let d=s!==void 0?s==="*"?"*":[s]:void 0;e.publish(o,a,d),console.log("emitNative",o,a,d);return}i||(i=Promise.resolve().then(()=>{r.forEach((d,u)=>{try{let p=u!==void 0?u==="*"?"*":[u]:void 0;e.publish(XO,d,p)}catch(p){}}),i=void 0,r.clear()}));let l=r.get(s);l||(l=[],r.set(s,l)),l.push([o,a])}}}function sR(e){let{subscribeHandler:t,onNative:r,offNative:n,subscribe:i,unsubscribe:o}=oR(e),{invokeNative:a,invokeHandler:s,applyNative:c}=iR(e,r),{publish:l,emitNative:d}=aR(e);return{invokeHandler:s,subscribeHandler:t,applyNative:c,invokeNative:a,onNative:r,offNative:n,emitNative:d,publish:l,subscribe:i,unsubscribe:o}}function Bh(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var uO,dO,pO,Ca,Rh,Nh,Eh,ur,fO,mO,ka,gO,vO,Dh,bO,_O,Lh,wO,IO,kO,xO,xa,TO,PO,OO,ql,Ta,Ch,RO,Jl,DO,Hl,LO,qO,UO,Bn,FO,UW,Vl,me,jO,BO,Ji,Vi,Wl,zl,GO,Ul,VO,MW,Kl,kh,FW,Pa,zO,Hi,KO,YO,QO,jh,XO,ZO,Aa,Th,Ml,Fl,jl,Bl,tR,Yl,rR,nR,Ea,Ql,Pt,Gh,Jh,cR,Hh,Oh,de,L,_e,Vh,lR,$h,sn,jW,BW,ce=x(()=>{"use strict";uO=Object.defineProperty,dO=Object.defineProperties,pO=Object.getOwnPropertyDescriptors,Ca=Object.getOwnPropertySymbols,Rh=Object.prototype.hasOwnProperty,Nh=Object.prototype.propertyIsEnumerable,Eh=(e,t,r)=>t in e?uO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ur=(e,t)=>{for(var r in t||(t={}))Rh.call(t,r)&&Eh(e,r,t[r]);if(Ca)for(var r of Ca(t))Nh.call(t,r)&&Eh(e,r,t[r]);return e},fO=(e,t)=>dO(e,pO(t)),mO=(e,t)=>{var r={};for(var n in e)Rh.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ca)for(var n of Ca(e))t.indexOf(n)<0&&Nh.call(e,n)&&(r[n]=e[n]);return r},ka=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});gO=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t.charCodeAt(i);return n.buffer};vO=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let i=0;i<n;i++)t+=String.fromCharCode(r[i]);return btoa(t)};Dh=Object.defineProperty,bO=Object.getOwnPropertyDescriptor,_O=(e,t)=>{for(var r in t)Dh(e,r,{get:t[r],enumerable:!0})},Lh=(e,t,r,n)=>{for(var i=n>1?void 0:n?bO(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&Dh(t,r,i),i},wO=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}IO=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))}})}};kO=(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))(kO||{}),xO=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}},xa=class extends xO{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},TO=class extends xa{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},PO=class extends xa{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},OO=class extends xa{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},ql=class extends xa{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}};Ta={log:Gi("log"),warn:Gi("warn"),info:Gi("info"),error:Gi("error"),debug:Gi("debug")};Object.assign(globalThis,{logger:Ta});Ch=Symbol.for("Jolibox.canIUseMap"),RO={};globalThis[Ch]||(globalThis[Ch]=RO);Jl=Symbol.for("Jolibox.canIUseMap.native"),DO={};globalThis[Jl]||(globalThis[Jl]=DO);Hl={get config(){return globalThis[Jl]}},LO=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(LO||{}),qO=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(qO||{}),UO=(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))(UO||{});MO();Bn=typeof window=="undefined",FO=()=>!Bn&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),UW={isiOS:!Bn&&(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:!Bn&&navigator.userAgent.includes("Android"),isMac:!Bn&&navigator.userAgent.includes("Mac"),isFacebook:!Bn&&navigator.userAgent.includes("FB_IAB"),isPC:!Bn&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Vl=class $l{constructor(t){this.element=t,this.next=$l.Undefined,this.prev=$l.Undefined}};Vl.Undefined=new Vl(void 0);me=Vl,jO=class{constructor(){this._first=me.Undefined,this._last=me.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===me.Undefined}clear(){let e=this._first;for(;e!==me.Undefined;){let t=e.next;e.prev=me.Undefined,e.next=me.Undefined,e=t}this._first=me.Undefined,this._last=me.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new me(e);if(this._first===me.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==me.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==me.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==me.Undefined&&e.next!==me.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===me.Undefined&&e.next===me.Undefined?(this._first=me.Undefined,this._last=me.Undefined):e.next===me.Undefined?(this._last=this._last.prev,this._last.next=me.Undefined):e.prev===me.Undefined&&(this._first=this._first.next,this._first.prev=me.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==me.Undefined;)yield e.element,e=e.next}},BO=0,Ji=class{constructor(e){this.value=e,this.id=BO++}},Vi=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 Ji&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,i,o,a,s,c;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new Ji(t);return this._listeners?this._listeners instanceof Ji?this._listeners=[this._listeners,l]:this._listeners.push(l):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=l,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(c=(s=this.options)==null?void 0:s.onDidAddListener)==null||c.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof Ji)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(u=(d=this.options)==null?void 0:d.onDidRemoveLastListener)==null||u.call(d));else if(this._listeners){let m=this._listeners.indexOf(l);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof Ji?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Wl=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let i=(n=this.listeners.get(e))!=null?n:new Vi,o=c=>t(...c.args),a=i.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let c of s)t(...c.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new jO,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},zl={};_O(zl,{None:()=>GO,filter:()=>HO,once:()=>Fh,toPromise:()=>JO});GO=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});Ul=Symbol.for("Jolibox.hostEmitter"),VO=()=>{let e=new Wl;return globalThis[Ul]||(globalThis[Ul]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Ul]},MW=VO();Kl=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Vi,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 i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return $O(i,r),n(...i)}}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}};Kl=Lh([Mh],Kl);kh=class{constructor(){this._onWillExecuteCommand=new Vi,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Vi,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Kl,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=SO(3e4)),this._starActivation}executeCommand(e,...t){return wO(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),zl.toPromise(zl.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}}};kh=Lh([Mh],kh);FW=Symbol.for("Jolibox.commands");Xe("requestPaymentSync",{version:1e6,properties:{paymentBody:{appStoreProductId:102e4}}});Xe("requestProductDetailsAsync",{version:102e4});Xe("invokeSubscriptionPanelSync",{version:107e4,properties:{type:{game:107e4,drama:107e4}}});Xe("loginSync",{version:1e6,properties:{skipLogin:102e4,triggerFrom:102e4}});Xe("getABTest",{version:1050100,platforms:{android:1050100,ios:!1}});Xe("userTrackAsync",{version:1e6});Xe("openMiniapp",{version:1050100});Xe("requestCoinDetailsSync",{version:1070100});Xe("requestCoinDetailsAsync",{version:1070100});Xe("sendServerEventAsync",{version:1070100});Xe("requestGameLeaderboardSync",{version:108e4});Xe("requestGameLeaderboardAsync",{version:108e4});Xe("notifyTaskGameInfoAsync",{version:1080100});Xe("loadAdsAsync",{version:1070200});Xe("showAdAsync",{version:1070200});Xe("onJoliboxHideLoading",{version:1070300});Pa=(e,t)=>{function r(i){var o;let[a,...s]=i.split(":");if(!a)return!1;let c=Hl.config[a];if(!c)return!1;let l=(o=t==null?void 0:t())!=null?o:"",d=c.version;if(c.platforms&&l in c.platforms){let p=c.platforms[l];if(p===!1)return!1;typeof p=="number"&&(d=p)}if(typeof d!="number")return!1;let u=e();return typeof u!="number"||u<d?!1:s.length===0?!0:n(c,s,u)||n(c.properties,s,u)}function n(i,o,a){if(!i)return!1;let s=NO(i,o);if(!s)return!1;if(Gn(s)){let c=s.version;return Ah(c)?typeof a=="number"&&a>=c:!0}return Ah(s)?typeof a=="number"&&a>=s:s===!0}return{canIUseNative:r}};zO=()=>FO(),Hi="custom_event_",KO=[],YO=[],QO=["env","createRequestTask","login"],jh="__batch_event__",XO="__native_batch_event__",ZO=e=>e==="pv"?e:"default",Aa=class{constructor(e){this.interval=30,this.lastReportTime=0,this.cache={};let{reporter:t,interval:r=30,eventName:n,tagNameOrder:i,metricName:o,type:a}=e;this.reporter=t,this.interval=r,this.eventName=n,this.tagNameOrder=i,this.metricName=o,this.type=ZO(a)}report(e){this.type==="pv"?this.addPVPoint(e):this.addPoint(e),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(e){if(Object.keys(this.cache).length){if(e){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(e){let t=(r,n,i,o)=>{let a=n.shift();if(a){let s=o[a];r[s]||(r[s]={}),t(r[s],n,i,o)}else r[i]||(r[i]=[]),r[i].push(o[i])};t(this.cache,[...this.tagNameOrder],this.metricName,e)}addPVPoint(e){let t=(n,i,o,a)=>{let s=i.shift();if(!s&&Gn(a))throw new ql(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);if(s){let c=[];if(Gn(a))c.push(...Object.keys(a));else if(qh(a)){if(i.length>0)throw new ql(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);c.push(a)}else throw new ql(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(r)}`);c.forEach(l=>{n[l]||(n[l]={});let d=Gn(a)?a[l]:a;t(n[l],[...i],o,d)})}else n[o]?n[o]++:n[o]=1},r={point:e,metricName:this.metricName,tagNameOrder:this.tagNameOrder};t(this.cache,[...this.tagNameOrder],this.metricName,e)}processPoints(e){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:e}}clearPoints(){this.cache={}}},Th=!1;Bl=[],tR=!1,Yl=Symbol.for("Jolibox.invokeResolverInstance"),rR=new Map;globalThis[Yl]||(globalThis[Yl]=rR);nR={get resolveMap(){return globalThis[Yl]}};Ea=Symbol.for("Jolibox.subscribeInstance");Pt={trigger(){},exit(){return Promise.resolve(!1)},backPress(){return Promise.resolve(!1)},onReady(e){Pt.trigger=e},onDoExit(e){Pt.exit=e},onDoBackPress(e){Pt.backPress=e}},Gh=e=>{let t=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!t)e.onError(new TO("native env failed"));else{let{data:r}=JSON.parse(t);return r!=null?r:void 0}};if(typeof window!="undefined"&&window.webkit){let e=window.webkit.messageHandlers,t=(i="")=>{Pt.trigger(),e.onDocumentReady.postMessage({path:i})},r=i=>ka(void 0,null,function*(){let o=yield Pt.exit();e.doExit.postMessage({uuid:i,shouldInterrupt:o})});Ql={onDocumentReady:t,doExit:r,invoke(i,o,a){e.invoke.postMessage({event:i,paramsString:o,callbackId:a})},publish(i,o,a){let s=Bh(o,"joliboxJSCore");window.prompt("publish",JSON.stringify({event:i,paramsString:JSON.stringify(s),webviewIds:a}))},call(i,o,a){let s=window.prompt("invoke",JSON.stringify({event:i,paramsString:JSON.stringify(o),callbackId:a}));if(s)return JSON.parse(s)}};let n={onDocumentReady:t,env:Gh,doExit:r};globalThis.joliboxJSCore=ur({},n)}if(typeof window!="undefined"&&window.JoliAndroidSDKBridge){let e,t=window.JoliAndroidSDKBridge,r=(o="")=>{Pt.trigger(),t.onDocumentReady(JSON.stringify({path:o}))},n=o=>ka(void 0,null,function*(){let a=yield Pt.exit();t.doExit(JSON.stringify({uuid:o,shouldInterrupt:a}))});Ql={onDocumentReady:r,invoke(o,a,s){t.invoke(JSON.stringify({event:o,paramsString:a,callbackId:s}))},doExit:n,publish(o,a,s){let c=Bh(a,"joliboxJSCore");t.publish(JSON.stringify({event:o,paramsString:JSON.stringify(c),webviewIds:s}))},call(o,a,s){let c=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(a),callbackId:s}));if(c)return JSON.parse(c)},doBackPress(o){return ka(this,null,function*(){let a=yield Pt.backPress();t.doBackPress(JSON.stringify({uuid:o,shouldInterrupt:a}))})}};let i={onDocumentReady:r,env:Gh,doExit:n};globalThis.joliboxJSCore=ur({},i)}Jh=Ql;if(!Jh&&zO())throw new OO("No joliboxJScore is found, native bridge not found.");cR=ur({},Jh),Hh=sR(cR),{invokeHandler:Oh}=Hh,{applyNative:de,invokeNative:L,onNative:_e,offNative:Vh,subscribeHandler:lR,publish:$h,emitNative:sn,subscribe:jW,unsubscribe:BW}=Hh;globalThis.joliboxJSBridge={callHandler:Oh,invokeHandler:Oh,subscribeHandler:lR}});function mR(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Ra(e){return new Promise(t=>setTimeout(t,e))}function Yi(e){return typeof e=="string"}function ln(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Zh(e){return typeof e=="object"&&Array.isArray(e)}function Na(e){return typeof e=="number"&&!isNaN(e)}function qr(e){return e===!0||e===!1}function eg(e){return typeof e=="undefined"}function Qi(e){return eg(e)||e===null}function hR(e){return typeof e=="function"}function tg(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function rg(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(i,o){for(let a in o)if(Object.prototype.hasOwnProperty.call(o,a)){let s=i[a],c=o[a],l=r(s,c,a,i,o);l!==void 0?i[a]=l:Kh(c)&&Kh(s)?i[a]=n(Qh({},s),c):Array.isArray(c)&&Array.isArray(s)?i[a]=[...s,...c]:i[a]=c}return i}return n(e,t)}function Kh(e){return e&&typeof e=="object"&&e.constructor===Object}function ng(e,t){if(Array.isArray(e))return e.concat(t)}function Xi(e,t,r={}){let n=null,i,o,a,{leading:s=!1,trailing:c=!0}=r,l=()=>(a=e.apply(o,i),i=void 0,o=void 0,a),d=function(...u){i=u,o=this;let p=s&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,c&&!p&&l()},t),p)return l()};return d.cancel=()=>{n&&clearTimeout(n),n=null,i=o=void 0},d.flush=()=>{if(n)return clearTimeout(n),n=null,l()},d}function vR(e,t){return(...r)=>t(e,...r)}function Jn(e){return t=>vR(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new Vt(`${i}`))}})}function $i(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function cg(e,t,r){let n=0;if(e!==t){let i=e.split("."),o=t.split("."),a=Math.max(i.length,o.length);for(let s=0;s<a;s++){let c=parseInt(i[s],10)||0,l=parseInt(o[s],10)||0;if(c>l){n=1;break}else if(c<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}function uu(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}function IR(e,t,r){let n=window.location.hostname,i=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(i.length>=2){let a=i.slice(-2).join(".");if(a==="jolibox.com"||a==="pico-game.com"||a==="joyslite.com"||a==="mporia.com"||a==="pingplus.ai")return`${o}.${a}`}return`${o}.jolibox.com`}function du(e){return IR("app","stg-app",e)}function Vn(e){return`https://${du(e)}`}function kR(e){return new Promise(t=>pg(e)(t))}function pg(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function xR(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Ki(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function PR(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)OR(e[n],t[n])}function OR(e,t){if(Yi(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(hR(t)){try{if(e instanceof t)return}catch(r){}if(!Qi(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 RR(){return typeof globalThis!="undefined"?globalThis[fg]:void 0}function NR(e){typeof globalThis!="undefined"&&(globalThis[fg]=e)}function K(e=!1){let t=RR();if(!e&&t)return t;let r=new Oa,n=new nu,i={registerCommand(o,a,s){r.registerCommand({id:o,handler:a,metadata:s})},executeCommand(o,...a){return n.executeCommand(o,...a)},excuteCommandSync(o,...a){return n.executeCommandThowErr(o,...a)}};return NR(i),i}var iu,uR,Wh,dR,pR,zh,Qh,fR,Xh,cn,ut,gR,ou,Zi,au,ig,Vt,Da,og,La,ag,sg,eo,su,$t,Zl,yR,cu,Yh,bR,z,lu,_R,Hn,Wi,to,wR,SR,lg,ug,dg,Ut,eu,he,ER,AR,zi,Ki,Wt,ru,CR,Xl,TR,we,Oa,nu,fg,R=x(()=>{"use strict";iu=Object.defineProperty,uR=Object.getOwnPropertyDescriptor,Wh=Object.getOwnPropertySymbols,dR=Object.prototype.hasOwnProperty,pR=Object.prototype.propertyIsEnumerable,zh=(e,t,r)=>t in e?iu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Qh=(e,t)=>{for(var r in t||(t={}))dR.call(t,r)&&zh(e,r,t[r]);if(Wh)for(var r of Wh(t))pR.call(t,r)&&zh(e,r,t[r]);return e},fR=(e,t)=>{for(var r in t)iu(e,r,{get:t[r],enumerable:!0})},Xh=(e,t,r,n)=>{for(var i=n>1?void 0:n?uR(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&iu(t,r,i),i},cn=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}ut=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))}})}};gR=(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))(gR||{}),ou=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}},Zi=class extends ou{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},au=class extends ou{constructor(){super(...arguments),this.kind="USER_ERROR"}},ig=class extends au{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Vt=class extends au{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))}},Da=class extends au{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_PAYMENT_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},og=class extends Zi{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},La=class extends Zi{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="INTERNAL_PAYMENT_ERROR",this.priority="P0",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},ag=class extends Zi{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_METHOD_ERROR"}},sg=class extends Zi{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},eo=class extends ou{constructor(e,t,r,n,i){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),i&&(this.priority=i)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},su=class extends Zi{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};$t={log:$i("log"),warn:$i("warn"),info:$i("info"),error:$i("error"),debug:$i("debug")};Object.assign(globalThis,{logger:$t});Zl=Symbol.for("Jolibox.canIUseMap"),yR={};globalThis[Zl]||(globalThis[Zl]=yR);cu={get config(){return globalThis[Zl]}},Yh=Symbol.for("Jolibox.canIUseMap.native"),bR={};globalThis[Yh]||(globalThis[Yh]=bR);z=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(z||{}),lu=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(lu||{}),_R=(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))(_R||{}),Hn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});uu();Wi=typeof window=="undefined",to={isiOS:!Wi&&(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:!Wi&&navigator.userAgent.includes("Android"),isMac:!Wi&&navigator.userAgent.includes("Mac"),isFacebook:!Wi&&navigator.userAgent.includes("FB_IAB"),isPC:!Wi&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},wR="device_id",SR="advertising_id",lg=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Hn()),window.__joliboxLocalStorage__.getItem(e)),ug=()=>new URLSearchParams(window.location.search).get("deviceId")||lg(wR),dg=()=>new URLSearchParams(window.location.search).get("advertisingId")||lg(SR);Ut=class{constructor(e,t={}){this.requestAdapter=e,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=Qh({duration:10*60*1e3,timeout:3e3,keyGenerator:(r,n)=>r,consistencyChecker:()=>!0},t)}request(e,t){return cn(this,null,function*(){let r=this.config.keyGenerator(e,t),n=this.pendingRequests.get(r);if(n)return console.log(`[RequestCacheService] Reusing pending request for ${e}`),n;let i=this.requestInternal(e,t),o=this.createTimeoutPromise(),a=Promise.race([i,o]).catch(s=>cn(this,null,function*(){if(s.message.includes("timeout")){let c=this.getValidCachedData(r);if(c)return console.warn(`[RequestCacheService] Request timeout, falling back to cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}throw s}));this.pendingRequests.set(r,a),i.then(s=>{console.log(`[RequestCacheService] Background request completed successfully for ${e}`)}).catch(s=>{console.warn(`[RequestCacheService] Background request failed for ${e}:`,s)});try{return yield a}finally{this.pendingRequests.delete(r)}})}requestInternal(e,t){return cn(this,null,function*(){var r,n,i,o;let a=this.config.keyGenerator(e,t),s=++this.requestSequence,c=this.getValidCachedData(a);if(console.log("[RequestCacheService] requestInternal start",e,"cached:",c),c){if(this.requestAdapter.extractRealTimeData&&this.requestAdapter.mergeData)try{let u=yield this.requestAdapter.execute(e,t),p=this.requestAdapter.extractRealTimeData(u),f=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,u);return f&&!this.config.consistencyChecker(c,f)?(console.log(`[RequestCacheService] Cache invalidated due to data change for ${e}`),this.setCachedDataWithSequence(a,f,s),u):this.requestAdapter.mergeData(c,p)}catch(u){return console.warn(`[RequestCacheService] Failed to fetch real-time data, using cache only for ${e}:`,u),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}return console.log(`[RequestCacheService] use cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}console.log(`[RequestCacheService] Cache miss, fetching fresh data for ${e} (sequence: ${s})`);let l=yield this.requestAdapter.execute(e,t),d=(o=(i=this.requestAdapter).extractCacheableData)==null?void 0:o.call(i,l);return d&&this.setCachedDataWithSequence(a,d,s),l})}createTimeoutPromise(){return new Promise((e,t)=>{setTimeout(()=>{t(new Error(`[RequestCacheService] Request timeout after ${this.config.timeout/1e3} seconds`))},this.config.timeout)})}getValidCachedData(e){let t=this.cache.get(e);return t?Date.now()>t.expiresAt?(this.cache.delete(e),null):t.data:null}setCachedDataWithSequence(e,t,r,n){let i=this.cache.get(e);if(i&&i.sequence>r){console.log(`[RequestCacheService] Ignoring stale cache update for ${e} (current: ${i.sequence}, incoming: ${r})`);return}let o=Date.now();this.cache.set(e,{data:JSON.parse(JSON.stringify(t)),timestamp:o,expiresAt:o+this.config.duration,key:e,sequence:r,metadata:n}),this.cacheSequences.set(e,r),console.log(`[RequestCacheService] Updated cache for ${e} with sequence ${r}`)}refreshCache(e,t){return cn(this,null,function*(){let r=this.config.keyGenerator(e,t);return this.cache.delete(r),this.request(e,t)})}forceRequest(e,t){return cn(this,null,function*(){var r,n;let i=this.config.keyGenerator(e,t),o=++this.requestSequence;console.log(`[RequestCacheService] Force request for ${e} (sequence: ${o})`);let a=yield this.requestAdapter.execute(e,t),s=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,a);return s&&(this.setCachedDataWithSequence(i,s,o),console.log(`[RequestCacheService] Force updated cache for ${e}`)),a})}warmupCache(e,t){return cn(this,null,function*(){let r=this.config.keyGenerator(e,t);if(this.pendingRequests.has(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - request in progress`);return}if(this.hasValidCache(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - valid cache exists`);return}try{console.log(`[RequestCacheService] Warming up cache for ${e}`),yield this.forceRequest(e,t)}catch(n){console.warn(`[RequestCacheService] Cache warmup failed for ${e}:`,n)}})}clearCache(e){e?(this.cache.delete(e),this.cacheSequences.delete(e),this.pendingRequests.delete(e),console.log(`[RequestCacheService] Cleared cache for ${e}`)):(this.cache.clear(),this.cacheSequences.clear(),this.pendingRequests.clear(),this.requestSequence=0,console.log("[RequestCacheService] Cleared all cache"))}clearExpiredCache(){let e=Date.now();for(let[t,r]of this.cache)e>r.expiresAt&&(this.cache.delete(t),this.cacheSequences.delete(t));console.log("[RequestCacheService] Cleared expired cache entries")}getCacheStats(){let e=Date.now(),t=0,r=0;for(let n of this.cache.values())e>n.expiresAt?r++:t++;return{cacheCount:this.cache.size,validCount:t,expiredCount:r,pendingRequestCount:this.pendingRequests.size}}getCacheKeys(){return Array.from(this.cache.keys())}hasValidCache(e){let t=this.cache.get(e);return t?Date.now()<=t.expiresAt:!1}getPendingRequestKeys(){return Array.from(this.pendingRequests.keys())}hasPendingRequest(e){return this.pendingRequests.has(e)}getCacheSequence(e){return this.cacheSequences.get(e)}},eu=class tu{constructor(t){this.element=t,this.next=tu.Undefined,this.prev=tu.Undefined}};eu.Undefined=new eu(void 0);he=eu,ER=class{constructor(){this._first=he.Undefined,this._last=he.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===he.Undefined}clear(){let e=this._first;for(;e!==he.Undefined;){let t=e.next;e.prev=he.Undefined,e.next=he.Undefined,e=t}this._first=he.Undefined,this._last=he.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new he(e);if(this._first===he.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==he.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==he.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==he.Undefined&&e.next!==he.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===he.Undefined&&e.next===he.Undefined?(this._first=he.Undefined,this._last=he.Undefined):e.next===he.Undefined?(this._last=this._last.prev,this._last.next=he.Undefined):e.prev===he.Undefined&&(this._first=this._first.next,this._first.prev=he.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==he.Undefined;)yield e.element,e=e.next}},AR=0,zi=class{constructor(e){this.value=e,this.id=AR++}},Ki=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 zi&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,i,o,a,s,c;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new zi(t);return this._listeners?this._listeners instanceof zi?this._listeners=[this._listeners,l]:this._listeners.push(l):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=l,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(c=(s=this.options)==null?void 0:s.onDidAddListener)==null||c.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof zi)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(u=(d=this.options)==null?void 0:d.onDidRemoveLastListener)==null||u.call(d));else if(this._listeners){let m=this._listeners.indexOf(l);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof zi?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Wt=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let i=(n=this.listeners.get(e))!=null?n:new Ki,o=c=>t(...c.args),a=i.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let c of s)t(...c.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new ER,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},ru={};fR(ru,{None:()=>CR,filter:()=>xR,once:()=>pg,toPromise:()=>kR});CR=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});Xl=Symbol.for("Jolibox.hostEmitter"),TR=()=>{let e=new Wt;return globalThis[Xl]||(globalThis[Xl]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Xl]},we=TR();Oa=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Ki,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 i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return PR(i,r),n(...i)}}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}};Oa=Xh([tg],Oa);nu=class{constructor(){this._onWillExecuteCommand=new Ki,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Ki,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Oa,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=mR(3e4)),this._starActivation}executeCommand(e,...t){return cn(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),ru.toPromise(ru.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}}};nu=Xh([tg],nu);fg=Symbol.for("Jolibox.commands")});function Ae(e,t={}){pu.emit("ERROR_REPORT",{error:e,options:t})}var pu,un,yt=x(()=>{"use strict";R();R();pu=new Wt,un=new Wt;Ae.debounce=Xi(Ae,50,{leading:!0})});var fu,DR,mg,hg,gg=x(()=>{"use strict";R();yt();fu=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(i){return{}}},DR=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},mg=e=>{var t;try{let i=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(i!=null&&i.length){let[o,a,s]=i;return{headerJson:fu(o),payloadJson:fu(a),signature:fu(s)}}else throw"joli_source is missing"}catch(r){return Ae(new og(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},hg=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=DR(e),o=r[2];return`${n}.${i}.${o}`}return t}});var LR,mu,vg=x(()=>{"use strict";R();LR="1.4.6",mu=()=>LR});function gu(e,t){return(document==null?void 0:document.head.querySelector(`meta[name="${e}"][content="${t}"]`))!==null}var qR,yg,hu,bg,ge,UR,I,V=x(()=>{"use strict";R();gg();vg();R();qR={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:ug(),adId:dg(),pixelRatio:window.devicePixelRatio||1,platform:to.isAndroid?"android":to.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:mu()},schema:window.location.href,platform:to.isAndroid?"android":to.isiOS?"ios":"h5"},hu=(yg=globalThis.joliboxJSCore)==null?void 0:yg.env,ge=Object.assign({},(bg=hu==null?void 0:hu())!=null?bg:qR);UR=()=>{var v,b,y,w,E,C,T,k,A,J,ue;let{payloadJson:e,headerJson:t,signature:r}=ge.schema.length?mg(ge.schema):{},n=`${ge.deviceInfo.did}-${new Date().getTime()}`,o=new URL(ge.schema.length?ge.schema:window.location.href).searchParams,a=(y=(b=(v=o.get("mpId"))!=null?v:o.get("appId"))!=null?b:o.get("gameId"))!=null?y:"",s=(C=(E=(w=ge.clientSessionId)!=null?w:e==null?void 0:e.sessionId)!=null?E:o.get("sessionId"))!=null?C:n,c=!!((k=(T=e==null?void 0:e.testAdsMode)!=null?T:e==null?void 0:e.__testAdsMode)!=null?k:o.get("testAdsMode")==="true"),l=(ue=(J=(A=e==null?void 0:e.joliboxEnv)!=null?A:e==null?void 0:e.__joliboxEnv)!=null?J:o.get("joliboxEnv"))!=null?ue:"production",d=l==="staging",u=t==null?void 0:t.channel,f=new URL(window.location.href).searchParams,m=e==null?void 0:e.__shouldInterupt;return{get startTime(){var N;return(N=performance.timeOrigin)!=null?N:performance.timing.navigationStart},get testMode(){return d},get testAdsMode(){return c},get joliboxEnv(){return l},get joliSource(){var N,O;return(O=(N=f.get("joliSource"))!=null?N:o.get("joliSource"))!=null?O:null},get mpId(){var N;return(N=a!=null?a:e==null?void 0:e.id)!=null?N:""},get mpVersion(){var N;return(N=t==null?void 0:t.ver)!=null?N:mu()},get mpType(){var N,O;return(O=(N=t==null?void 0:t.__mpType)!=null?N:e==null?void 0:e.__mpType)!=null?O:"game"},get platform(){var N;return((N=ge.platform)!=null?N:ge.deviceInfo.platform).toLowerCase()},get deviceInfo(){return ge.deviceInfo},get sdkInfo(){return ge.sdkInfo},get hostInfo(){return ge.hostInfo},get hostUserInfo(){return ge.hostUserInfo},get sessionId(){var N,O;return(O=(N=ge.clientSessionId)!=null?N:s)!=null?O:n},get channel(){return u},get webviewId(){var N;return(N=ge.webviewId)!=null?N:-1},get shouldInterupt(){return m},get from(){return e==null?void 0:e.__from},get baseApiHost(){return du(d)},get adId(){var N;return(N=ge.deviceInfo.adId)!=null?N:ge.deviceInfo.did},get language(){return ge.deviceInfo.lang},get sdkEnvironment(){return gu("dlightek","jolibox")?"dlightek":o.get("huaweiQuick")==="true"?"huaweiQuick":gu("gamedistribution","jolibox")?"gamedistribution":gu("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var G,H,qt;let N=(G=ge.deviceInfo.pixelRatio)!=null?G:1,O=(H=ge.deviceInfo.statusBarHeight)!=null?H:e==null?void 0:e.__androidStatusBarHeight,F=(qt=ge.deviceInfo.navigationBarHeight)!=null?qt:e==null?void 0:e.__androidNavigationBarHeight;return{statusBarHeight:O!==void 0?O/N:20,navigationBarHeight:F!==void 0?F/N:10}},get abTests(){var N,O;return(O=(N=ge.abValues)==null?void 0:N.split(","))!=null?O:[]},get mpInfo(){var N;return(N=ge.mpInfo)!=null?N:{mpName:"unknown"}},onEnvConfigChanged:N=>{rg(ge,N,ng)},encodeJoliSourceQuery:N=>{var O,F;return t&&r?hg(P(P({},e),N),(O=o.get("joliSource"))!=null?O:""):(F=o.get("joliSource"))!=null?F:""},setDoExitDirectly:()=>{m=!1}}},I=UR()});var vu,wg,MR,FR,_g,jR,Sg=x(()=>{"use strict";R();yt();V();R();vu=!1,wg=(e,t)=>e==null?!1:t in e,MR=e=>wg(e,"kind"),FR=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},_g=(e,t={},r)=>{var o,a,s;let n={user_id:(a=(o=I.hostUserInfo)==null?void 0:o.uid)!=null?a:"",device_id:(s=I.deviceInfo.did)!=null?s:"",timestamp:Date.now(),tag:FR(e.name)},i=B(P({},n),{env:t.environment,isFromUser:r});r?un.emit("GLOBAL_USER_ERROR",e,i):un.emit("GLOBAL_ERROR",e,i)},jR=e=>wg(e,"kind")&&e.kind==="USER_ERROR";pu.on("ERROR_REPORT",({error:e,options:t})=>{if(vu)return;vu=!0;let r=MR(e)&&e.raw?e.raw:e;try{let n=jR(e);_g(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),o=new su(`${i}, origin error: ${r.message}`);$t.error(o),_g(new su(o.message),{environment:t.environment},!1)}finally{vu=!1}})});var Ce,yu,Ur=x(()=>{"use strict";yt();R();yt();Ce=(e,t)=>{var r,n;return new eo((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},yu=e=>new ig(e)});var Ig=x(()=>{"use strict";Sg();Ur();R();ce();un.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};L("trackAsync",{event:"reportJsError",data:r})});un.on("GLOBAL_USER_ERROR",(e,t)=>{$t.log("UserError",e,t)})});var bu=x(()=>{"use strict"});function Eg(e,t){let r=(n,i,o)=>{let l=i!=null?i:{},{eventType:a}=l,s=Qe(l,["eventType"]),c=B(P({tag:n,eventType:o!=null?o:a!=null?a:z.Other},t),{extra:P({},s)});n=="globalJsError"?Ae(new sg(JSON.stringify(c))):e("systemLog",c,I.webviewId)};return r.debounce=Xi(r,500,{leading:!0}),r}function Ag(e){let t=(r,n,i)=>{var s;let o=(s=i&&JSON.stringify(i))!=null?s:0,a={speed_value_type:r,total_duration:n};o&&Object.assign(a,{extra:o}),e("joliboxSpeedAnalysis",a)};return t.debounce=Xi(t,500,{leading:!0}),t}var Cg=x(()=>{"use strict";R();R();yt();V()});function kg(e,t){let r=Eg(e,t),n=Ag(r);return{track:r,trackPerformance:n}}var xg=x(()=>{"use strict";Cg()});var Tg=x(()=>{"use strict";V();R();R()});var Pg=x(()=>{"use strict";xg();bu();Tg()});var qa,Og=x(()=>{"use strict";qa=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.reportCount=0;this.notifyIframeGameEvent=(t,r)=>{window.parent&&window.parent.postMessage({type:t,data:r},"*")};this.playGame=t=>{this.reportCount++,(this.reportCount<=3||(this.reportCount-3)%3===0)&&(this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_PLAY",{duration:t}))};this.timer=this.createRAFTimer(t=>{this.playGame(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.notifyIframeGameEvent("JOLIBOX_GAME_OPEN",{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.notifyIframeGameEvent("JOLIBOX_GAME_CLOSE",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,i,o=!1,a=0,s=()=>{if(!o)return;let f=Date.now(),m=f-r;m>=this.interval&&(this.visible&&(a+=Math.min(m,this.interval+1e3),t(a)),r=f),n=requestAnimationFrame(s)},c=()=>{d(),r=Date.now(),i=window.setInterval(()=>{if(!o)return;let f=Date.now();f-r>=this.interval&&(r=f)},this.interval)},l=()=>{u(),r=Date.now(),n=requestAnimationFrame(s)},d=()=>{n&&(cancelAnimationFrame(n),n=0)},u=()=>{i&&(clearInterval(i),i=0)};this.eventEmitter.on("visible",f=>{o&&(console.log("visible",f),f?l():c())});let p=this.visible;return{start(){o||(o=!0,p?l():c())},stop(){o=!1,d(),u()}}}}});function Ua(e,t,r){var c,l,d;let n=new Map,i=(c=r==null?void 0:r.baseUrl)!=null?c:Vn(I.testMode),o=(l=r==null?void 0:r.type)!=null?l:"public",a=(d=r==null?void 0:r.defaultHeaders)!=null?d:{};return _e("onRequestTaskStateChange",u=>{if(typeof u.requestTaskId!="string")return;let p=n.get(u.requestTaskId);if(p)if(u.state==="success"){let f=u,{requestTaskId:v,state:b}=f,y=Qe(f,["requestTaskId","state"]);u.statusCode===200?p.resolve(y):p.reject(y),n.delete(v)}else if(u.state==="fail"){let m=u,{requestTaskId:v,state:b}=m,y=Qe(m,["requestTaskId","state"]);p.reject(y),n.delete(v)}else $t.warn("onRequestTaskStateChange unknown event",u)}),we.on("onLoginComplete",({isLogin:u,token:p})=>{o!=="public"&&u&&p&&(a["X-JOLI-TOKEN"]=p)}),(f,...m)=>g(this,[f,...m],function*(u,p={}){let v=Date.now(),b=BR(u,B(P({},p),{baseUrl:i})),{method:y="GET",responseType:w="text",dataType:E="json",timeout:C,enableCache:T=!1,appendHostCookie:k=!0}=p,A=Object.assign({"content-type":"application/json"},a,p.header),J={url:b,method:y,header:A,enableCache:T,responseType:w,appendHostCookie:k};if(y=="POST"||y=="PUT"){let G=JR(p.data,A["content-type"]);J.data=G}C&&Object.assign(J,{timeout:C});let{data:{requestTaskId:ue}}=L(e,J);if(typeof ue!="string")throw Ce({code:-1,msg:"requestTaskId is not a string"});let{resolve:N,reject:O,promise:F}=new ut;n.set(ue,{resolve:N,reject:O});try{let G=yield F,{data:H}=G;return E==="json"&&typeof H=="string"&&(H=GR(H)),{url:b,timeout:C,method:y,response:B(P({},G),{data:H})}}catch(G){let H=G;if(ln(H)){let{errMsg:qt,prefetchDetail:_h,isPrefetch:Dl,errNo:wa}=H;Yi(qt)&&Ae(Ce({code:-1,msg:qt},{errNo:wa,errMsg:qt}))}throw G}})}function GR(e){try{return JSON.parse(e.trim())}catch(t){return e}}function JR(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 BR,_u=x(()=>{"use strict";R();ce();yt();Ur();V();BR=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t==null?void 0:t.query,i=new URLSearchParams(r).toString();return t!=null&&t.baseUrl?`${t.baseUrl}${e}${i?`?${i}`:""}`:`${e}${i?`?${i}`:""}`}});var wu,Rg,Y,dt=x(()=>{"use strict";_u();V();R();wu={};(Rg=I.hostUserInfo)!=null&&Rg.token&&(wu["x-joli-token"]=I.hostUserInfo.token);I.joliSource&&(wu["x-joli-source"]=I.joliSource);Y=Ua("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:Vn(I.testMode),defaultHeaders:wu})});function Ng(e){let t=cu.config[e];return t||(t={},cu.config[e]=t),(r,n)=>{if(t[r]){$t.warn(`[can i use] ${r} already registered`);return}t[r]=P({},n)}}var Dg=x(()=>{"use strict";R()});function Su(e){Lg=e}function Ma(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Ma(t)):Object.keys(e).reduce((t,r)=>(t[r]=Ma(e[r]),t),{})}function dr(e){return typeof e=="number"}function Iu(e){let t=Eu(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Eu(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Lg,Te,Fa,ja,Ba,Ga,$n,Ja,Ha,Va,$a,Wa,za,Ka,Ya,Qa,Xa,Za,es,Au=x(()=>{"use strict";Lg=!1;Te=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Lg)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 ${Iu(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Ma(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Ma(this._default)}optional(){return this._optional=!0,this}};Fa=class extends Te{validate(t){return this._optional&&t===void 0?!0:dr(t)?dr(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):dr(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):dr(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}},ja=class extends Te{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Ba=class extends Te{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(dr(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(dr(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}},Ga=class extends Te{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},$n=class extends Te{validate(t){return!0}},Ja=class extends Te{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},Ha=class extends Te{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Va=class extends Te{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},$a=class extends Te{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 ${Iu(t)}`)}return!0}},Wa=class extends Te{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(dr(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(dr(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(dr(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 i=!0;if(r.forEach((o,a)=>{if(n.path=`${this.path}[${a}]`,n.errors=this.errors,o===void 0&&n.hasDefault){r[a]=n.defaultValue;return}n.validate(o)||(n.hasFallback?r[a]=n.fallbackValue:i=!1)}),this._uniqueItems){let o=new Map;for(let a in r)o.has(r[a])?i=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${o.get(r[a])}] and ${this.path}[${a}] are identical)`):o.set(r[a],a)}return i}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}},za=class extends Te{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Eu(r)!=="object")return this.fail({expect:"object",actual:r});let i=r,o=this._value;o.errors=this.errors;let a=!0;for(let s in i){let c=i[s];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(s)?o.path=`${this.path}.${s}`:o.path=`${this.path}["${s}"]`,!(c===void 0&&o._optional)){if(c===void 0&&o.hasDefault){i[s]=o.defaultValue;continue}o.validate(c)||(o.hasFallback?i[s]=o.fallbackValue:a=!1)}}return a}},Ka=class extends Te{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Eu(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,i=!0;for(let o in this._object){let a=n[o],s=this._object[o];if(s.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(o)?s.path=`${this.path}.${o}`:s.path=`${this.path}["${o}"]`,!(s._optional&&a===void 0)){if(a===void 0&&s.hasDefault){n[o]=s.defaultValue;continue}s.validate(a)||(s.hasFallback?n[o]=s.fallbackValue:i=!1)}}return i}},Ya=class extends Te{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:Iu(this.value),actual:r}):!0}},Qa=class extends Te{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,i=this._items.length;for(let o=0;o<i;o++){let a=this._items[o];if(a.errors=[],a.path=this.path,!a.validate(t))r.push(a.errors.join("; "));else if(!n){n=!0;break}}if(!n){let o=r.join(`
|
|
1
|
+
var nO=Object.create;var Ia=Object.defineProperty,iO=Object.defineProperties,oO=Object.getOwnPropertyDescriptor,aO=Object.getOwnPropertyDescriptors,sO=Object.getOwnPropertyNames,Sa=Object.getOwnPropertySymbols,cO=Object.getPrototypeOf,Ll=Object.prototype.hasOwnProperty,Sh=Object.prototype.propertyIsEnumerable;var wh=(e,t,r)=>t in e?Ia(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))Ll.call(t,r)&&wh(e,r,t[r]);if(Sa)for(var r of Sa(t))Sh.call(t,r)&&wh(e,r,t[r]);return e},B=(e,t)=>iO(e,aO(t));var Qe=(e,t)=>{var r={};for(var n in e)Ll.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Sa)for(var n of Sa(e))t.indexOf(n)<0&&Sh.call(e,n)&&(r[n]=e[n]);return r};var x=(e,t)=>()=>(e&&(t=e(e=0)),t);var h=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ih=(e,t)=>{for(var r in t)Ia(e,r,{get:t[r],enumerable:!0})},lO=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of sO(t))!Ll.call(e,i)&&i!==r&&Ia(e,i,{get:()=>t[i],enumerable:!(n=oO(t,i))||n.enumerable});return e};var se=(e,t,r)=>(r=e!=null?nO(cO(e)):{},lO(t||!e||!e.__esModule?Ia(r,"default",{value:e,enumerable:!0}):r,e));var g=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});function hO(e){return!!(e!=null&&e.__nativeBuffers__)}function Gl(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!hO(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 i;n.value?i=n.value:n.base64&&(i=gO(n.base64)),typeof i!="undefined"&&i instanceof ArrayBuffer&&(e[n.key]=i)}}return e}function yO(e={},t=!1){let r=e,n=[];for(let[i,o]of Object.entries(r))if(o!==void 0&&o instanceof ArrayBuffer&&o.byteLength!==void 0){let a=t?{value:o,key:i}:{base64:vO(o),key:i};n.push(a),delete r[i]}return n.length>0&&(r.__nativeBuffers__=n),r}function SO(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function qh(e){return typeof e=="string"}function Gn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Ah(e){return typeof e=="number"&&!isNaN(e)}function EO(e){return typeof e=="undefined"}function AO(e){return EO(e)||e===null}function Uh(e){return typeof e=="function"}function CO(e){return Gn(e)&&Uh(e.then)}function Mh(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function Gi(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function NO(e,t,r){let n=e;for(let i of t)if(n&&typeof n=="object")n=n[i];else return r;return n===void 0?r:n}function MO(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}function JO(e){return new Promise(t=>Fh(e)(t))}function Fh(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function HO(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Vi(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function $O(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)WO(e[n],t[n])}function WO(e,t){if(qh(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Uh(t)){try{if(e instanceof t)return}catch(r){}if(!AO(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 Xe(e,t){if(Hl.config[e]){Ta.warn(`[can i use] ${e} already registered`);return}Hl.config[e]=ur({},t)}function xh(e,t){return`[${e}]:${t}`}function eR(e,t){Th||(Ml=new Aa({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),Fl=new Aa({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),jl=new Aa({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),t("onJoliboxEnterBackground",()=>{Ml.flush(),Fl.flush(),jl.flush()}),Th=!0);function r(i){var o,a;let{method:s,args:c,startTime:l,isForeground:d,errMsg:u=`${s}:fail no errMsg`,errNo:p=0,__timing:f={receiveJSInvoke:0,invokeCallback:0}}=i,{receiveJSInvoke:m,invokeCallback:v}=f,b=(a=(o=u.match(/\S:(\S+)\s?/))==null?void 0:o[1])!=null?a:"fail";Ml.report({status:b,method:n(s,c),errNo:`${p}`,errMsg:u,isForeground:d,duration:Date.now()-l}),l&&m&&v&&(Fl.report({status:b,method:s,isForeground:d,duration:Number((m-l).toFixed(3))}),jl.report({status:b,method:s,isForeground:d,duration:Number((Date.now()-v).toFixed(3))}))}function n(i,o){return(i==="callHostMethod"||i==="callHostMethodSync")&&o!=null&&o.method?`${i}-${o.method}`:i}return r}function iR(e,t){let r=0,n=!0,i=nR.resolveMap,o=eR(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,Bl.forEach(c=>ka(this,[c],function*({method:l,args:d,resolve:u}){let p=yield s(l,d);u(p)})),Bl.length=0});let a=(c,l)=>{let d=i.get(Number(c));if(!d)return;let u=Gl(l);d(u),i.delete(Number(c))},s=(c,l)=>{var d,u;let p=Date.now(),f=`${n}`;r+=1;let m=new IO;if(i.set(r,m.resolve),!n&&YO.includes(c))return new Promise(C=>{Bl.push({method:c,args:l,resolve:C})});let v=fO(ur({},{method:c,startTime:p,args:l,isForeground:f}),{invokeType:"js-bridge"}),b=!tR&&KO.includes(c),y=yO(l,b),w=b?y:JSON.stringify(y),E;if(c.endsWith("Sync")||QO.includes(c)?E=(d=e.call)==null?void 0:d.call(e,c,y,r):typeof w=="string"?E=e.invoke(c,w,r):E=(u=e.call)==null?void 0:u.call(e,c,w,r),E){try{typeof E=="string"&&(E=JSON.parse(E)),E=Gl(E)}catch(C){Ta.error(C)}return i.delete(r),E.errorCode&&(E.errorCode=xh(c,E.errorCode)),o(ur(ur({},v),E)),E}return c.endsWith("Sync")&&i.delete(r),m.promise.then(C=>(C.errorCode&&(C.errorCode=xh(c,C.errorCode)),o(ur(ur({},v),C)),C))};return{invokeNative:s,applyNative:(c,l)=>{let d=s(c,l);return CO(d)?d.then(u=>Ph(c,u)):Ph(c,d)},invokeHandler:a}}function Ph(e,t){if(!Gn(t)){Ta.warn(`[Jolibox SDK]${e} no response value`);return}let r=t,{errMsg:n,errNo:i,errorType:o,errorCode:a}=r,s=mO(r,["errMsg","errNo","errorType","errorCode"]);if(n&&n!==`${e}:ok`)throw new PO(n,i,o,a);return s}function oR(e){if(globalThis[Ea])return globalThis[Ea];let t=new Wl,r=new Wl,n=new Aa({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}});return t.on("onJoliboxEnterBackground",()=>{n.flush()}),globalThis[Ea]={onNative:t.on.bind(t),offNative:t.off.bind(t),subscribe:r.on.bind(r),unsubscribe:r.off.bind(r),subscribeHandler(i,o,a){let s=Gl(o),c;if(s.__extra){c=s.params;let{type:l,startTime:d}=s.__extra;n.report({type:l,event:i,duration:Date.now()-d})}else c=s;if(i===jh){c.forEach(l=>{let[d,u]=l;try{r.emit(d.slice(Hi.length),u,a)}catch(p){}});return}if(i.startsWith(Hi)){r.emit(i.slice(Hi.length),c,a);return}t.emit(i,c,a)}},globalThis[Ea]}function aR(e){let t=new Map,r=new Map,n,i;return{publish:(o,a,s,c)=>{if(c){let d=s!==void 0?s==="*"?"*":[s]:void 0;e.publish(`${Hi}${o}`,a,d);return}n||(n=Promise.resolve().then(()=>{t.forEach((d,u)=>{try{let p=u!==void 0?u==="*"?"*":[u]:void 0;e.publish(jh,d,p)}catch(p){}}),n=void 0,t.clear()}));let l=t.get(s);l||(l=[],t.set(s,l)),l.push([`${Hi}${o}`,a])},emitNative:(o,a,s,c)=>{if(c){let d=s!==void 0?s==="*"?"*":[s]:void 0;e.publish(o,a,d),console.log("emitNative",o,a,d);return}i||(i=Promise.resolve().then(()=>{r.forEach((d,u)=>{try{let p=u!==void 0?u==="*"?"*":[u]:void 0;e.publish(XO,d,p)}catch(p){}}),i=void 0,r.clear()}));let l=r.get(s);l||(l=[],r.set(s,l)),l.push([o,a])}}}function sR(e){let{subscribeHandler:t,onNative:r,offNative:n,subscribe:i,unsubscribe:o}=oR(e),{invokeNative:a,invokeHandler:s,applyNative:c}=iR(e,r),{publish:l,emitNative:d}=aR(e);return{invokeHandler:s,subscribeHandler:t,applyNative:c,invokeNative:a,onNative:r,offNative:n,emitNative:d,publish:l,subscribe:i,unsubscribe:o}}function Bh(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var uO,dO,pO,Ca,Rh,Nh,Eh,ur,fO,mO,ka,gO,vO,Dh,bO,_O,Lh,wO,IO,kO,xO,xa,TO,PO,OO,ql,Ta,Ch,RO,Jl,DO,Hl,LO,qO,UO,Bn,FO,UW,Vl,me,jO,BO,Ji,Vi,Wl,zl,GO,Ul,VO,MW,Kl,kh,FW,Pa,zO,Hi,KO,YO,QO,jh,XO,ZO,Aa,Th,Ml,Fl,jl,Bl,tR,Yl,rR,nR,Ea,Ql,Pt,Gh,Jh,cR,Hh,Oh,de,L,_e,Vh,lR,$h,sn,jW,BW,ce=x(()=>{"use strict";uO=Object.defineProperty,dO=Object.defineProperties,pO=Object.getOwnPropertyDescriptors,Ca=Object.getOwnPropertySymbols,Rh=Object.prototype.hasOwnProperty,Nh=Object.prototype.propertyIsEnumerable,Eh=(e,t,r)=>t in e?uO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ur=(e,t)=>{for(var r in t||(t={}))Rh.call(t,r)&&Eh(e,r,t[r]);if(Ca)for(var r of Ca(t))Nh.call(t,r)&&Eh(e,r,t[r]);return e},fO=(e,t)=>dO(e,pO(t)),mO=(e,t)=>{var r={};for(var n in e)Rh.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ca)for(var n of Ca(e))t.indexOf(n)<0&&Nh.call(e,n)&&(r[n]=e[n]);return r},ka=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});gO=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t.charCodeAt(i);return n.buffer};vO=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let i=0;i<n;i++)t+=String.fromCharCode(r[i]);return btoa(t)};Dh=Object.defineProperty,bO=Object.getOwnPropertyDescriptor,_O=(e,t)=>{for(var r in t)Dh(e,r,{get:t[r],enumerable:!0})},Lh=(e,t,r,n)=>{for(var i=n>1?void 0:n?bO(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&Dh(t,r,i),i},wO=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}IO=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))}})}};kO=(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))(kO||{}),xO=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}},xa=class extends xO{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},TO=class extends xa{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},PO=class extends xa{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},OO=class extends xa{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},ql=class extends xa{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}};Ta={log:Gi("log"),warn:Gi("warn"),info:Gi("info"),error:Gi("error"),debug:Gi("debug")};Object.assign(globalThis,{logger:Ta});Ch=Symbol.for("Jolibox.canIUseMap"),RO={};globalThis[Ch]||(globalThis[Ch]=RO);Jl=Symbol.for("Jolibox.canIUseMap.native"),DO={};globalThis[Jl]||(globalThis[Jl]=DO);Hl={get config(){return globalThis[Jl]}},LO=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(LO||{}),qO=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(qO||{}),UO=(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))(UO||{});MO();Bn=typeof window=="undefined",FO=()=>!Bn&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),UW={isiOS:!Bn&&(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:!Bn&&navigator.userAgent.includes("Android"),isMac:!Bn&&navigator.userAgent.includes("Mac"),isFacebook:!Bn&&navigator.userAgent.includes("FB_IAB"),isPC:!Bn&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Vl=class $l{constructor(t){this.element=t,this.next=$l.Undefined,this.prev=$l.Undefined}};Vl.Undefined=new Vl(void 0);me=Vl,jO=class{constructor(){this._first=me.Undefined,this._last=me.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===me.Undefined}clear(){let e=this._first;for(;e!==me.Undefined;){let t=e.next;e.prev=me.Undefined,e.next=me.Undefined,e=t}this._first=me.Undefined,this._last=me.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new me(e);if(this._first===me.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==me.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==me.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==me.Undefined&&e.next!==me.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===me.Undefined&&e.next===me.Undefined?(this._first=me.Undefined,this._last=me.Undefined):e.next===me.Undefined?(this._last=this._last.prev,this._last.next=me.Undefined):e.prev===me.Undefined&&(this._first=this._first.next,this._first.prev=me.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==me.Undefined;)yield e.element,e=e.next}},BO=0,Ji=class{constructor(e){this.value=e,this.id=BO++}},Vi=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 Ji&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,i,o,a,s,c;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new Ji(t);return this._listeners?this._listeners instanceof Ji?this._listeners=[this._listeners,l]:this._listeners.push(l):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=l,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(c=(s=this.options)==null?void 0:s.onDidAddListener)==null||c.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof Ji)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(u=(d=this.options)==null?void 0:d.onDidRemoveLastListener)==null||u.call(d));else if(this._listeners){let m=this._listeners.indexOf(l);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof Ji?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Wl=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let i=(n=this.listeners.get(e))!=null?n:new Vi,o=c=>t(...c.args),a=i.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let c of s)t(...c.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new jO,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},zl={};_O(zl,{None:()=>GO,filter:()=>HO,once:()=>Fh,toPromise:()=>JO});GO=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});Ul=Symbol.for("Jolibox.hostEmitter"),VO=()=>{let e=new Wl;return globalThis[Ul]||(globalThis[Ul]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Ul]},MW=VO();Kl=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Vi,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 i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return $O(i,r),n(...i)}}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}};Kl=Lh([Mh],Kl);kh=class{constructor(){this._onWillExecuteCommand=new Vi,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Vi,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Kl,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=SO(3e4)),this._starActivation}executeCommand(e,...t){return wO(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),zl.toPromise(zl.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}}};kh=Lh([Mh],kh);FW=Symbol.for("Jolibox.commands");Xe("requestPaymentSync",{version:1e6,properties:{paymentBody:{appStoreProductId:102e4}}});Xe("requestProductDetailsAsync",{version:102e4});Xe("invokeSubscriptionPanelSync",{version:107e4,properties:{type:{game:107e4,drama:107e4}}});Xe("loginSync",{version:1e6,properties:{skipLogin:102e4,triggerFrom:102e4}});Xe("getABTest",{version:1050100,platforms:{android:1050100,ios:!1}});Xe("userTrackAsync",{version:1e6});Xe("openMiniapp",{version:1050100});Xe("requestCoinDetailsSync",{version:1070100});Xe("requestCoinDetailsAsync",{version:1070100});Xe("sendServerEventAsync",{version:1070100});Xe("requestGameLeaderboardSync",{version:108e4});Xe("requestGameLeaderboardAsync",{version:108e4});Xe("notifyTaskGameInfoAsync",{version:1080100});Xe("loadAdsAsync",{version:1070200});Xe("showAdAsync",{version:1070200});Xe("onJoliboxHideLoading",{version:1070300});Pa=(e,t)=>{function r(i){var o;let[a,...s]=i.split(":");if(!a)return!1;let c=Hl.config[a];if(!c)return!1;let l=(o=t==null?void 0:t())!=null?o:"",d=c.version;if(c.platforms&&l in c.platforms){let p=c.platforms[l];if(p===!1)return!1;typeof p=="number"&&(d=p)}if(typeof d!="number")return!1;let u=e();return typeof u!="number"||u<d?!1:s.length===0?!0:n(c,s,u)||n(c.properties,s,u)}function n(i,o,a){if(!i)return!1;let s=NO(i,o);if(!s)return!1;if(Gn(s)){let c=s.version;return Ah(c)?typeof a=="number"&&a>=c:!0}return Ah(s)?typeof a=="number"&&a>=s:s===!0}return{canIUseNative:r}};zO=()=>FO(),Hi="custom_event_",KO=[],YO=[],QO=["env","createRequestTask","login"],jh="__batch_event__",XO="__native_batch_event__",ZO=e=>e==="pv"?e:"default",Aa=class{constructor(e){this.interval=30,this.lastReportTime=0,this.cache={};let{reporter:t,interval:r=30,eventName:n,tagNameOrder:i,metricName:o,type:a}=e;this.reporter=t,this.interval=r,this.eventName=n,this.tagNameOrder=i,this.metricName=o,this.type=ZO(a)}report(e){this.type==="pv"?this.addPVPoint(e):this.addPoint(e),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(e){if(Object.keys(this.cache).length){if(e){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(e){let t=(r,n,i,o)=>{let a=n.shift();if(a){let s=o[a];r[s]||(r[s]={}),t(r[s],n,i,o)}else r[i]||(r[i]=[]),r[i].push(o[i])};t(this.cache,[...this.tagNameOrder],this.metricName,e)}addPVPoint(e){let t=(n,i,o,a)=>{let s=i.shift();if(!s&&Gn(a))throw new ql(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);if(s){let c=[];if(Gn(a))c.push(...Object.keys(a));else if(qh(a)){if(i.length>0)throw new ql(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);c.push(a)}else throw new ql(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(r)}`);c.forEach(l=>{n[l]||(n[l]={});let d=Gn(a)?a[l]:a;t(n[l],[...i],o,d)})}else n[o]?n[o]++:n[o]=1},r={point:e,metricName:this.metricName,tagNameOrder:this.tagNameOrder};t(this.cache,[...this.tagNameOrder],this.metricName,e)}processPoints(e){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:e}}clearPoints(){this.cache={}}},Th=!1;Bl=[],tR=!1,Yl=Symbol.for("Jolibox.invokeResolverInstance"),rR=new Map;globalThis[Yl]||(globalThis[Yl]=rR);nR={get resolveMap(){return globalThis[Yl]}};Ea=Symbol.for("Jolibox.subscribeInstance");Pt={trigger(){},exit(){return Promise.resolve(!1)},backPress(){return Promise.resolve(!1)},onReady(e){Pt.trigger=e},onDoExit(e){Pt.exit=e},onDoBackPress(e){Pt.backPress=e}},Gh=e=>{let t=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!t)e.onError(new TO("native env failed"));else{let{data:r}=JSON.parse(t);return r!=null?r:void 0}};if(typeof window!="undefined"&&window.webkit){let e=window.webkit.messageHandlers,t=(i="")=>{Pt.trigger(),e.onDocumentReady.postMessage({path:i})},r=i=>ka(void 0,null,function*(){let o=yield Pt.exit();e.doExit.postMessage({uuid:i,shouldInterrupt:o})});Ql={onDocumentReady:t,doExit:r,invoke(i,o,a){e.invoke.postMessage({event:i,paramsString:o,callbackId:a})},publish(i,o,a){let s=Bh(o,"joliboxJSCore");window.prompt("publish",JSON.stringify({event:i,paramsString:JSON.stringify(s),webviewIds:a}))},call(i,o,a){let s=window.prompt("invoke",JSON.stringify({event:i,paramsString:JSON.stringify(o),callbackId:a}));if(s)return JSON.parse(s)}};let n={onDocumentReady:t,env:Gh,doExit:r};globalThis.joliboxJSCore=ur({},n)}if(typeof window!="undefined"&&window.JoliAndroidSDKBridge){let e,t=window.JoliAndroidSDKBridge,r=(o="")=>{Pt.trigger(),t.onDocumentReady(JSON.stringify({path:o}))},n=o=>ka(void 0,null,function*(){let a=yield Pt.exit();t.doExit(JSON.stringify({uuid:o,shouldInterrupt:a}))});Ql={onDocumentReady:r,invoke(o,a,s){t.invoke(JSON.stringify({event:o,paramsString:a,callbackId:s}))},doExit:n,publish(o,a,s){let c=Bh(a,"joliboxJSCore");t.publish(JSON.stringify({event:o,paramsString:JSON.stringify(c),webviewIds:s}))},call(o,a,s){let c=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(a),callbackId:s}));if(c)return JSON.parse(c)},doBackPress(o){return ka(this,null,function*(){let a=yield Pt.backPress();t.doBackPress(JSON.stringify({uuid:o,shouldInterrupt:a}))})}};let i={onDocumentReady:r,env:Gh,doExit:n};globalThis.joliboxJSCore=ur({},i)}Jh=Ql;if(!Jh&&zO())throw new OO("No joliboxJScore is found, native bridge not found.");cR=ur({},Jh),Hh=sR(cR),{invokeHandler:Oh}=Hh,{applyNative:de,invokeNative:L,onNative:_e,offNative:Vh,subscribeHandler:lR,publish:$h,emitNative:sn,subscribe:jW,unsubscribe:BW}=Hh;globalThis.joliboxJSBridge={callHandler:Oh,invokeHandler:Oh,subscribeHandler:lR}});function mR(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Ra(e){return new Promise(t=>setTimeout(t,e))}function Yi(e){return typeof e=="string"}function ln(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Zh(e){return typeof e=="object"&&Array.isArray(e)}function Na(e){return typeof e=="number"&&!isNaN(e)}function qr(e){return e===!0||e===!1}function eg(e){return typeof e=="undefined"}function Qi(e){return eg(e)||e===null}function hR(e){return typeof e=="function"}function tg(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function rg(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(i,o){for(let a in o)if(Object.prototype.hasOwnProperty.call(o,a)){let s=i[a],c=o[a],l=r(s,c,a,i,o);l!==void 0?i[a]=l:Kh(c)&&Kh(s)?i[a]=n(Qh({},s),c):Array.isArray(c)&&Array.isArray(s)?i[a]=[...s,...c]:i[a]=c}return i}return n(e,t)}function Kh(e){return e&&typeof e=="object"&&e.constructor===Object}function ng(e,t){if(Array.isArray(e))return e.concat(t)}function Xi(e,t,r={}){let n=null,i,o,a,{leading:s=!1,trailing:c=!0}=r,l=()=>(a=e.apply(o,i),i=void 0,o=void 0,a),d=function(...u){i=u,o=this;let p=s&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,c&&!p&&l()},t),p)return l()};return d.cancel=()=>{n&&clearTimeout(n),n=null,i=o=void 0},d.flush=()=>{if(n)return clearTimeout(n),n=null,l()},d}function vR(e,t){return(...r)=>t(e,...r)}function Jn(e){return t=>vR(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new Vt(`${i}`))}})}function $i(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function cg(e,t,r){let n=0;if(e!==t){let i=e.split("."),o=t.split("."),a=Math.max(i.length,o.length);for(let s=0;s<a;s++){let c=parseInt(i[s],10)||0,l=parseInt(o[s],10)||0;if(c>l){n=1;break}else if(c<l){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}function uu(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}function IR(e,t,r){let n=window.location.hostname,i=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(i.length>=2){let a=i.slice(-2).join(".");if(a==="jolibox.com"||a==="pico-game.com"||a==="joyslite.com"||a==="mporia.com"||a==="pingplus.ai")return`${o}.${a}`}return`${o}.jolibox.com`}function du(e){return IR("app","stg-app",e)}function Vn(e){return`https://${du(e)}`}function kR(e){return new Promise(t=>pg(e)(t))}function pg(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function xR(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Ki(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function PR(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)OR(e[n],t[n])}function OR(e,t){if(Yi(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(hR(t)){try{if(e instanceof t)return}catch(r){}if(!Qi(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 RR(){return typeof globalThis!="undefined"?globalThis[fg]:void 0}function NR(e){typeof globalThis!="undefined"&&(globalThis[fg]=e)}function K(e=!1){let t=RR();if(!e&&t)return t;let r=new Oa,n=new nu,i={registerCommand(o,a,s){r.registerCommand({id:o,handler:a,metadata:s})},executeCommand(o,...a){return n.executeCommand(o,...a)},excuteCommandSync(o,...a){return n.executeCommandThowErr(o,...a)}};return NR(i),i}var iu,uR,Wh,dR,pR,zh,Qh,fR,Xh,cn,ut,gR,ou,Zi,au,ig,Vt,Da,og,La,ag,sg,eo,su,$t,Zl,yR,cu,Yh,bR,z,lu,_R,Hn,Wi,to,wR,SR,lg,ug,dg,Ut,eu,he,ER,AR,zi,Ki,Wt,ru,CR,Xl,TR,we,Oa,nu,fg,R=x(()=>{"use strict";iu=Object.defineProperty,uR=Object.getOwnPropertyDescriptor,Wh=Object.getOwnPropertySymbols,dR=Object.prototype.hasOwnProperty,pR=Object.prototype.propertyIsEnumerable,zh=(e,t,r)=>t in e?iu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Qh=(e,t)=>{for(var r in t||(t={}))dR.call(t,r)&&zh(e,r,t[r]);if(Wh)for(var r of Wh(t))pR.call(t,r)&&zh(e,r,t[r]);return e},fR=(e,t)=>{for(var r in t)iu(e,r,{get:t[r],enumerable:!0})},Xh=(e,t,r,n)=>{for(var i=n>1?void 0:n?uR(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&iu(t,r,i),i},cn=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}ut=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))}})}};gR=(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))(gR||{}),ou=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}},Zi=class extends ou{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},au=class extends ou{constructor(){super(...arguments),this.kind="USER_ERROR"}},ig=class extends au{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Vt=class extends au{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))}},Da=class extends au{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_PAYMENT_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},og=class extends Zi{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},La=class extends Zi{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="INTERNAL_PAYMENT_ERROR",this.priority="P0",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},ag=class extends Zi{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_METHOD_ERROR"}},sg=class extends Zi{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},eo=class extends ou{constructor(e,t,r,n,i){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),i&&(this.priority=i)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},su=class extends Zi{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};$t={log:$i("log"),warn:$i("warn"),info:$i("info"),error:$i("error"),debug:$i("debug")};Object.assign(globalThis,{logger:$t});Zl=Symbol.for("Jolibox.canIUseMap"),yR={};globalThis[Zl]||(globalThis[Zl]=yR);cu={get config(){return globalThis[Zl]}},Yh=Symbol.for("Jolibox.canIUseMap.native"),bR={};globalThis[Yh]||(globalThis[Yh]=bR);z=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(z||{}),lu=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(lu||{}),_R=(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))(_R||{}),Hn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});uu();Wi=typeof window=="undefined",to={isiOS:!Wi&&(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:!Wi&&navigator.userAgent.includes("Android"),isMac:!Wi&&navigator.userAgent.includes("Mac"),isFacebook:!Wi&&navigator.userAgent.includes("FB_IAB"),isPC:!Wi&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},wR="device_id",SR="advertising_id",lg=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Hn()),window.__joliboxLocalStorage__.getItem(e)),ug=()=>new URLSearchParams(window.location.search).get("deviceId")||lg(wR),dg=()=>new URLSearchParams(window.location.search).get("advertisingId")||lg(SR);Ut=class{constructor(e,t={}){this.requestAdapter=e,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=Qh({duration:10*60*1e3,timeout:3e3,keyGenerator:(r,n)=>r,consistencyChecker:()=>!0},t)}request(e,t){return cn(this,null,function*(){let r=this.config.keyGenerator(e,t),n=this.pendingRequests.get(r);if(n)return console.log(`[RequestCacheService] Reusing pending request for ${e}`),n;let i=this.requestInternal(e,t),o=this.createTimeoutPromise(),a=Promise.race([i,o]).catch(s=>cn(this,null,function*(){if(s.message.includes("timeout")){let c=this.getValidCachedData(r);if(c)return console.warn(`[RequestCacheService] Request timeout, falling back to cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}throw s}));this.pendingRequests.set(r,a),i.then(s=>{console.log(`[RequestCacheService] Background request completed successfully for ${e}`)}).catch(s=>{console.warn(`[RequestCacheService] Background request failed for ${e}:`,s)});try{return yield a}finally{this.pendingRequests.delete(r)}})}requestInternal(e,t){return cn(this,null,function*(){var r,n,i,o;let a=this.config.keyGenerator(e,t),s=++this.requestSequence,c=this.getValidCachedData(a);if(console.log("[RequestCacheService] requestInternal start",e,"cached:",c),c){if(this.requestAdapter.extractRealTimeData&&this.requestAdapter.mergeData)try{let u=yield this.requestAdapter.execute(e,t),p=this.requestAdapter.extractRealTimeData(u),f=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,u);return f&&!this.config.consistencyChecker(c,f)?(console.log(`[RequestCacheService] Cache invalidated due to data change for ${e}`),this.setCachedDataWithSequence(a,f,s),u):this.requestAdapter.mergeData(c,p)}catch(u){return console.warn(`[RequestCacheService] Failed to fetch real-time data, using cache only for ${e}:`,u),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}return console.log(`[RequestCacheService] use cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}console.log(`[RequestCacheService] Cache miss, fetching fresh data for ${e} (sequence: ${s})`);let l=yield this.requestAdapter.execute(e,t),d=(o=(i=this.requestAdapter).extractCacheableData)==null?void 0:o.call(i,l);return d&&this.setCachedDataWithSequence(a,d,s),l})}createTimeoutPromise(){return new Promise((e,t)=>{setTimeout(()=>{t(new Error(`[RequestCacheService] Request timeout after ${this.config.timeout/1e3} seconds`))},this.config.timeout)})}getValidCachedData(e){let t=this.cache.get(e);return t?Date.now()>t.expiresAt?(this.cache.delete(e),null):t.data:null}setCachedDataWithSequence(e,t,r,n){let i=this.cache.get(e);if(i&&i.sequence>r){console.log(`[RequestCacheService] Ignoring stale cache update for ${e} (current: ${i.sequence}, incoming: ${r})`);return}let o=Date.now();this.cache.set(e,{data:JSON.parse(JSON.stringify(t)),timestamp:o,expiresAt:o+this.config.duration,key:e,sequence:r,metadata:n}),this.cacheSequences.set(e,r),console.log(`[RequestCacheService] Updated cache for ${e} with sequence ${r}`)}refreshCache(e,t){return cn(this,null,function*(){let r=this.config.keyGenerator(e,t);return this.cache.delete(r),this.request(e,t)})}forceRequest(e,t){return cn(this,null,function*(){var r,n;let i=this.config.keyGenerator(e,t),o=++this.requestSequence;console.log(`[RequestCacheService] Force request for ${e} (sequence: ${o})`);let a=yield this.requestAdapter.execute(e,t),s=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,a);return s&&(this.setCachedDataWithSequence(i,s,o),console.log(`[RequestCacheService] Force updated cache for ${e}`)),a})}warmupCache(e,t){return cn(this,null,function*(){let r=this.config.keyGenerator(e,t);if(this.pendingRequests.has(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - request in progress`);return}if(this.hasValidCache(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - valid cache exists`);return}try{console.log(`[RequestCacheService] Warming up cache for ${e}`),yield this.forceRequest(e,t)}catch(n){console.warn(`[RequestCacheService] Cache warmup failed for ${e}:`,n)}})}clearCache(e){e?(this.cache.delete(e),this.cacheSequences.delete(e),this.pendingRequests.delete(e),console.log(`[RequestCacheService] Cleared cache for ${e}`)):(this.cache.clear(),this.cacheSequences.clear(),this.pendingRequests.clear(),this.requestSequence=0,console.log("[RequestCacheService] Cleared all cache"))}clearExpiredCache(){let e=Date.now();for(let[t,r]of this.cache)e>r.expiresAt&&(this.cache.delete(t),this.cacheSequences.delete(t));console.log("[RequestCacheService] Cleared expired cache entries")}getCacheStats(){let e=Date.now(),t=0,r=0;for(let n of this.cache.values())e>n.expiresAt?r++:t++;return{cacheCount:this.cache.size,validCount:t,expiredCount:r,pendingRequestCount:this.pendingRequests.size}}getCacheKeys(){return Array.from(this.cache.keys())}hasValidCache(e){let t=this.cache.get(e);return t?Date.now()<=t.expiresAt:!1}getPendingRequestKeys(){return Array.from(this.pendingRequests.keys())}hasPendingRequest(e){return this.pendingRequests.has(e)}getCacheSequence(e){return this.cacheSequences.get(e)}},eu=class tu{constructor(t){this.element=t,this.next=tu.Undefined,this.prev=tu.Undefined}};eu.Undefined=new eu(void 0);he=eu,ER=class{constructor(){this._first=he.Undefined,this._last=he.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===he.Undefined}clear(){let e=this._first;for(;e!==he.Undefined;){let t=e.next;e.prev=he.Undefined,e.next=he.Undefined,e=t}this._first=he.Undefined,this._last=he.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new he(e);if(this._first===he.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==he.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==he.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==he.Undefined&&e.next!==he.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===he.Undefined&&e.next===he.Undefined?(this._first=he.Undefined,this._last=he.Undefined):e.next===he.Undefined?(this._last=this._last.prev,this._last.next=he.Undefined):e.prev===he.Undefined&&(this._first=this._first.next,this._first.prev=he.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==he.Undefined;)yield e.element,e=e.next}},AR=0,zi=class{constructor(e){this.value=e,this.id=AR++}},Ki=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 zi&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,i,o,a,s,c;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new zi(t);return this._listeners?this._listeners instanceof zi?this._listeners=[this._listeners,l]:this._listeners.push(l):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=l,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(c=(s=this.options)==null?void 0:s.onDidAddListener)==null||c.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof zi)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(u=(d=this.options)==null?void 0:d.onDidRemoveLastListener)==null||u.call(d));else if(this._listeners){let m=this._listeners.indexOf(l);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof zi?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Wt=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let i=(n=this.listeners.get(e))!=null?n:new Ki,o=c=>t(...c.args),a=i.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let c of s)t(...c.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new ER,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},ru={};fR(ru,{None:()=>CR,filter:()=>xR,once:()=>pg,toPromise:()=>kR});CR=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});Xl=Symbol.for("Jolibox.hostEmitter"),TR=()=>{let e=new Wt;return globalThis[Xl]||(globalThis[Xl]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Xl]},we=TR();Oa=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Ki,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 i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return PR(i,r),n(...i)}}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}};Oa=Xh([tg],Oa);nu=class{constructor(){this._onWillExecuteCommand=new Ki,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Ki,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Oa,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=mR(3e4)),this._starActivation}executeCommand(e,...t){return cn(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),ru.toPromise(ru.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}}};nu=Xh([tg],nu);fg=Symbol.for("Jolibox.commands")});function Ae(e,t={}){pu.emit("ERROR_REPORT",{error:e,options:t})}var pu,un,yt=x(()=>{"use strict";R();R();pu=new Wt,un=new Wt;Ae.debounce=Xi(Ae,50,{leading:!0})});var fu,DR,mg,hg,gg=x(()=>{"use strict";R();yt();fu=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(i){return{}}},DR=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},mg=e=>{var t;try{let i=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(i!=null&&i.length){let[o,a,s]=i;return{headerJson:fu(o),payloadJson:fu(a),signature:fu(s)}}else throw"joli_source is missing"}catch(r){return Ae(new og(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},hg=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=DR(e),o=r[2];return`${n}.${i}.${o}`}return t}});var LR,mu,vg=x(()=>{"use strict";R();LR="1.4.7",mu=()=>LR});function gu(e,t){return(document==null?void 0:document.head.querySelector(`meta[name="${e}"][content="${t}"]`))!==null}var qR,yg,hu,bg,ge,UR,I,V=x(()=>{"use strict";R();gg();vg();R();qR={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:ug(),adId:dg(),pixelRatio:window.devicePixelRatio||1,platform:to.isAndroid?"android":to.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:mu()},schema:window.location.href,platform:to.isAndroid?"android":to.isiOS?"ios":"h5"},hu=(yg=globalThis.joliboxJSCore)==null?void 0:yg.env,ge=Object.assign({},(bg=hu==null?void 0:hu())!=null?bg:qR);UR=()=>{var v,b,y,w,E,C,T,k,A,J,ue;let{payloadJson:e,headerJson:t,signature:r}=ge.schema.length?mg(ge.schema):{},n=`${ge.deviceInfo.did}-${new Date().getTime()}`,o=new URL(ge.schema.length?ge.schema:window.location.href).searchParams,a=(y=(b=(v=o.get("mpId"))!=null?v:o.get("appId"))!=null?b:o.get("gameId"))!=null?y:"",s=(C=(E=(w=ge.clientSessionId)!=null?w:e==null?void 0:e.sessionId)!=null?E:o.get("sessionId"))!=null?C:n,c=!!((k=(T=e==null?void 0:e.testAdsMode)!=null?T:e==null?void 0:e.__testAdsMode)!=null?k:o.get("testAdsMode")==="true"),l=(ue=(J=(A=e==null?void 0:e.joliboxEnv)!=null?A:e==null?void 0:e.__joliboxEnv)!=null?J:o.get("joliboxEnv"))!=null?ue:"production",d=l==="staging",u=t==null?void 0:t.channel,f=new URL(window.location.href).searchParams,m=e==null?void 0:e.__shouldInterupt;return{get startTime(){var N;return(N=performance.timeOrigin)!=null?N:performance.timing.navigationStart},get testMode(){return d},get testAdsMode(){return c},get joliboxEnv(){return l},get joliSource(){var N,O;return(O=(N=f.get("joliSource"))!=null?N:o.get("joliSource"))!=null?O:null},get mpId(){var N;return(N=a!=null?a:e==null?void 0:e.id)!=null?N:""},get mpVersion(){var N;return(N=t==null?void 0:t.ver)!=null?N:mu()},get mpType(){var N,O;return(O=(N=t==null?void 0:t.__mpType)!=null?N:e==null?void 0:e.__mpType)!=null?O:"game"},get platform(){var N;return((N=ge.platform)!=null?N:ge.deviceInfo.platform).toLowerCase()},get deviceInfo(){return ge.deviceInfo},get sdkInfo(){return ge.sdkInfo},get hostInfo(){return ge.hostInfo},get hostUserInfo(){return ge.hostUserInfo},get sessionId(){var N,O;return(O=(N=ge.clientSessionId)!=null?N:s)!=null?O:n},get channel(){return u},get webviewId(){var N;return(N=ge.webviewId)!=null?N:-1},get shouldInterupt(){return m},get from(){return e==null?void 0:e.__from},get baseApiHost(){return du(d)},get adId(){var N;return(N=ge.deviceInfo.adId)!=null?N:ge.deviceInfo.did},get language(){return ge.deviceInfo.lang},get sdkEnvironment(){return gu("dlightek","jolibox")?"dlightek":o.get("huaweiQuick")==="true"?"huaweiQuick":gu("gamedistribution","jolibox")?"gamedistribution":gu("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var G,H,qt;let N=(G=ge.deviceInfo.pixelRatio)!=null?G:1,O=(H=ge.deviceInfo.statusBarHeight)!=null?H:e==null?void 0:e.__androidStatusBarHeight,F=(qt=ge.deviceInfo.navigationBarHeight)!=null?qt:e==null?void 0:e.__androidNavigationBarHeight;return{statusBarHeight:O!==void 0?O/N:20,navigationBarHeight:F!==void 0?F/N:10}},get abTests(){var N,O;return(O=(N=ge.abValues)==null?void 0:N.split(","))!=null?O:[]},get mpInfo(){var N;return(N=ge.mpInfo)!=null?N:{mpName:"unknown"}},onEnvConfigChanged:N=>{rg(ge,N,ng)},encodeJoliSourceQuery:N=>{var O,F;return t&&r?hg(P(P({},e),N),(O=o.get("joliSource"))!=null?O:""):(F=o.get("joliSource"))!=null?F:""},setDoExitDirectly:()=>{m=!1}}},I=UR()});var vu,wg,MR,FR,_g,jR,Sg=x(()=>{"use strict";R();yt();V();R();vu=!1,wg=(e,t)=>e==null?!1:t in e,MR=e=>wg(e,"kind"),FR=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},_g=(e,t={},r)=>{var o,a,s;let n={user_id:(a=(o=I.hostUserInfo)==null?void 0:o.uid)!=null?a:"",device_id:(s=I.deviceInfo.did)!=null?s:"",timestamp:Date.now(),tag:FR(e.name)},i=B(P({},n),{env:t.environment,isFromUser:r});r?un.emit("GLOBAL_USER_ERROR",e,i):un.emit("GLOBAL_ERROR",e,i)},jR=e=>wg(e,"kind")&&e.kind==="USER_ERROR";pu.on("ERROR_REPORT",({error:e,options:t})=>{if(vu)return;vu=!0;let r=MR(e)&&e.raw?e.raw:e;try{let n=jR(e);_g(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),o=new su(`${i}, origin error: ${r.message}`);$t.error(o),_g(new su(o.message),{environment:t.environment},!1)}finally{vu=!1}})});var Ce,yu,Ur=x(()=>{"use strict";yt();R();yt();Ce=(e,t)=>{var r,n;return new eo((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},yu=e=>new ig(e)});var Ig=x(()=>{"use strict";Sg();Ur();R();ce();un.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};L("trackAsync",{event:"reportJsError",data:r})});un.on("GLOBAL_USER_ERROR",(e,t)=>{$t.log("UserError",e,t)})});var bu=x(()=>{"use strict"});function Eg(e,t){let r=(n,i,o)=>{let l=i!=null?i:{},{eventType:a}=l,s=Qe(l,["eventType"]),c=B(P({tag:n,eventType:o!=null?o:a!=null?a:z.Other},t),{extra:P({},s)});n=="globalJsError"?Ae(new sg(JSON.stringify(c))):e("systemLog",c,I.webviewId)};return r.debounce=Xi(r,500,{leading:!0}),r}function Ag(e){let t=(r,n,i)=>{var s;let o=(s=i&&JSON.stringify(i))!=null?s:0,a={speed_value_type:r,total_duration:n};o&&Object.assign(a,{extra:o}),e("joliboxSpeedAnalysis",a)};return t.debounce=Xi(t,500,{leading:!0}),t}var Cg=x(()=>{"use strict";R();R();yt();V()});function kg(e,t){let r=Eg(e,t),n=Ag(r);return{track:r,trackPerformance:n}}var xg=x(()=>{"use strict";Cg()});var Tg=x(()=>{"use strict";V();R();R()});var Pg=x(()=>{"use strict";xg();bu();Tg()});var qa,Og=x(()=>{"use strict";qa=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.reportCount=0;this.notifyIframeGameEvent=(t,r)=>{window.parent&&window.parent.postMessage({type:t,data:r},"*")};this.playGame=t=>{this.reportCount++,(this.reportCount<=3||(this.reportCount-3)%3===0)&&(this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_PLAY",{duration:t}))};this.timer=this.createRAFTimer(t=>{this.playGame(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.notifyIframeGameEvent("JOLIBOX_GAME_OPEN",{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.notifyIframeGameEvent("JOLIBOX_GAME_CLOSE",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,i,o=!1,a=0,s=()=>{if(!o)return;let f=Date.now(),m=f-r;m>=this.interval&&(this.visible&&(a+=Math.min(m,this.interval+1e3),t(a)),r=f),n=requestAnimationFrame(s)},c=()=>{d(),r=Date.now(),i=window.setInterval(()=>{if(!o)return;let f=Date.now();f-r>=this.interval&&(r=f)},this.interval)},l=()=>{u(),r=Date.now(),n=requestAnimationFrame(s)},d=()=>{n&&(cancelAnimationFrame(n),n=0)},u=()=>{i&&(clearInterval(i),i=0)};this.eventEmitter.on("visible",f=>{o&&(console.log("visible",f),f?l():c())});let p=this.visible;return{start(){o||(o=!0,p?l():c())},stop(){o=!1,d(),u()}}}}});function Ua(e,t,r){var c,l,d;let n=new Map,i=(c=r==null?void 0:r.baseUrl)!=null?c:Vn(I.testMode),o=(l=r==null?void 0:r.type)!=null?l:"public",a=(d=r==null?void 0:r.defaultHeaders)!=null?d:{};return _e("onRequestTaskStateChange",u=>{if(typeof u.requestTaskId!="string")return;let p=n.get(u.requestTaskId);if(p)if(u.state==="success"){let f=u,{requestTaskId:v,state:b}=f,y=Qe(f,["requestTaskId","state"]);u.statusCode===200?p.resolve(y):p.reject(y),n.delete(v)}else if(u.state==="fail"){let m=u,{requestTaskId:v,state:b}=m,y=Qe(m,["requestTaskId","state"]);p.reject(y),n.delete(v)}else $t.warn("onRequestTaskStateChange unknown event",u)}),we.on("onLoginComplete",({isLogin:u,token:p})=>{o!=="public"&&u&&p&&(a["X-JOLI-TOKEN"]=p)}),(f,...m)=>g(this,[f,...m],function*(u,p={}){let v=Date.now(),b=BR(u,B(P({},p),{baseUrl:i})),{method:y="GET",responseType:w="text",dataType:E="json",timeout:C,enableCache:T=!1,appendHostCookie:k=!0}=p,A=Object.assign({"content-type":"application/json"},a,p.header),J={url:b,method:y,header:A,enableCache:T,responseType:w,appendHostCookie:k};if(y=="POST"||y=="PUT"){let G=JR(p.data,A["content-type"]);J.data=G}C&&Object.assign(J,{timeout:C});let{data:{requestTaskId:ue}}=L(e,J);if(typeof ue!="string")throw Ce({code:-1,msg:"requestTaskId is not a string"});let{resolve:N,reject:O,promise:F}=new ut;n.set(ue,{resolve:N,reject:O});try{let G=yield F,{data:H}=G;return E==="json"&&typeof H=="string"&&(H=GR(H)),{url:b,timeout:C,method:y,response:B(P({},G),{data:H})}}catch(G){let H=G;if(ln(H)){let{errMsg:qt,prefetchDetail:_h,isPrefetch:Dl,errNo:wa}=H;Yi(qt)&&Ae(Ce({code:-1,msg:qt},{errNo:wa,errMsg:qt}))}throw G}})}function GR(e){try{return JSON.parse(e.trim())}catch(t){return e}}function JR(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 BR,_u=x(()=>{"use strict";R();ce();yt();Ur();V();BR=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t==null?void 0:t.query,i=new URLSearchParams(r).toString();return t!=null&&t.baseUrl?`${t.baseUrl}${e}${i?`?${i}`:""}`:`${e}${i?`?${i}`:""}`}});var wu,Rg,Y,dt=x(()=>{"use strict";_u();V();R();wu={};(Rg=I.hostUserInfo)!=null&&Rg.token&&(wu["x-joli-token"]=I.hostUserInfo.token);I.joliSource&&(wu["x-joli-source"]=I.joliSource);Y=Ua("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:Vn(I.testMode),defaultHeaders:wu})});function Ng(e){let t=cu.config[e];return t||(t={},cu.config[e]=t),(r,n)=>{if(t[r]){$t.warn(`[can i use] ${r} already registered`);return}t[r]=P({},n)}}var Dg=x(()=>{"use strict";R()});function Su(e){Lg=e}function Ma(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Ma(t)):Object.keys(e).reduce((t,r)=>(t[r]=Ma(e[r]),t),{})}function dr(e){return typeof e=="number"}function Iu(e){let t=Eu(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Eu(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Lg,Te,Fa,ja,Ba,Ga,$n,Ja,Ha,Va,$a,Wa,za,Ka,Ya,Qa,Xa,Za,es,Au=x(()=>{"use strict";Lg=!1;Te=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Lg)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 ${Iu(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Ma(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Ma(this._default)}optional(){return this._optional=!0,this}};Fa=class extends Te{validate(t){return this._optional&&t===void 0?!0:dr(t)?dr(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):dr(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):dr(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}},ja=class extends Te{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Ba=class extends Te{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(dr(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(dr(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}},Ga=class extends Te{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},$n=class extends Te{validate(t){return!0}},Ja=class extends Te{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},Ha=class extends Te{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Va=class extends Te{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},$a=class extends Te{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 ${Iu(t)}`)}return!0}},Wa=class extends Te{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(dr(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(dr(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(dr(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 i=!0;if(r.forEach((o,a)=>{if(n.path=`${this.path}[${a}]`,n.errors=this.errors,o===void 0&&n.hasDefault){r[a]=n.defaultValue;return}n.validate(o)||(n.hasFallback?r[a]=n.fallbackValue:i=!1)}),this._uniqueItems){let o=new Map;for(let a in r)o.has(r[a])?i=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${o.get(r[a])}] and ${this.path}[${a}] are identical)`):o.set(r[a],a)}return i}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}},za=class extends Te{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Eu(r)!=="object")return this.fail({expect:"object",actual:r});let i=r,o=this._value;o.errors=this.errors;let a=!0;for(let s in i){let c=i[s];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(s)?o.path=`${this.path}.${s}`:o.path=`${this.path}["${s}"]`,!(c===void 0&&o._optional)){if(c===void 0&&o.hasDefault){i[s]=o.defaultValue;continue}o.validate(c)||(o.hasFallback?i[s]=o.fallbackValue:a=!1)}}return a}},Ka=class extends Te{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Eu(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,i=!0;for(let o in this._object){let a=n[o],s=this._object[o];if(s.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(o)?s.path=`${this.path}.${o}`:s.path=`${this.path}["${o}"]`,!(s._optional&&a===void 0)){if(a===void 0&&s.hasDefault){n[o]=s.defaultValue;continue}s.validate(a)||(s.hasFallback?n[o]=s.fallbackValue:i=!1)}}return i}},Ya=class extends Te{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:Iu(this.value),actual:r}):!0}},Qa=class extends Te{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,i=this._items.length;for(let o=0;o<i;o++){let a=this._items[o];if(a.errors=[],a.path=this.path,!a.validate(t))r.push(a.errors.join("; "));else if(!n){n=!0;break}}if(!n){let o=r.join(`
|
|
2
2
|
or `);this.errors.push(o)}return n}},Xa=class extends Te{constructor(...t){super(),this._items=t;let r=0,n=t.length-1;for(;n>=0;n--){let i=t[n];if(i._optional||i.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,i)=>{if(n.path=`${this.path}[${i}]`,n.errors=this.errors,t[i]===void 0&&n.hasDefault){t[i]=n.defaultValue;return}n.validate(t[i])||(n.hasFallback?t[i]=n._fallback:r=!1)}),r}},Za=class extends Te{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},es=class extends Te{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 Cu(e,t,r="param"){if(e.errors=[],e.path=r,Su(!0),!e.validate(t)){let n=e.errors.join(`
|
|
3
|
-
`);throw e.errors.length=0,Su(!1),new TypeError(n)}}var S,ku=x(()=>{"use strict";Au();Au();S={object(e){return new Ka(e)},array(e){return new Wa(e)},tuple(...e){return new Xa(...e)},literal(e){return new Ya(e)},or(...e){return new Qa(...e)},symbol(){return new Ga},record(e){return new za(e)},function(){return new Va},boolean(){return new ja},string(){return new Ba},number(){return new Fa},undefined(){return new Ja},null(){return new Ha},unknown(){return new $n},any(){return new $n},as(){return new $n},arraybuffer(){return new Za},enum(...e){return new $a(...e)},typedarray(e){return new es(e)}}});var ts,qg,Ug=x(()=>{"use strict";R();yt();ku();Ur();ts=1,qg=e=>{function t(n,i){return(...o)=>{var u,p,f,m;let a=Date.now(),s={method:n,trace_id:ts};ts+=1;let c="SUCCESS",l=`${n}:ok`,d=0;try{if(i.paramsSchema)try{Cu(i.paramsSchema,o,"params")}catch(w){throw yu(`${n}:fail ${w.message}`)}let v=i.implement(...o),b=v,y=`${n}:ok`;if(v&&"code"in v){let{code:w,data:E,message:C}=v;c=w,b=E,y=C}return{code:c,message:y,data:b}}catch(v){let b=v;d=(p=(u=b.code)!=null?u:b.errNo)!=null?p:2e3,c="FAILURE";let y=(m=(f=b.message)!=null?f:b.errMsg)!=null?m:`${v}`;return l=`${n}:${c} ${y.replace(/^\S+:(fail|cancel)\s?/,"")}`,Ae(new eo(l,d)),{code:c,message:l}}finally{let v=Date.now()-a}}}function r(n,i){return(...o)=>g(this,null,function*(){var p,f,m,v;let a=Zh(o)?o:[o],s=Date.now(),c={method:n,trace_id:ts};ts+=1;let l=`${n}:ok`,d="SUCCESS",u={code:d,message:l};try{if(i.paramsSchema)try{Cu(i.paramsSchema,a,"params")}catch(w){throw yu(w.message)}let y=yield i.implement(...a);if(y&&"code"in y){let{code:w,data:E,message:C}=y;d=w,l=C,y=E}return Object.assign(u,{code:d,message:l,data:y}),u}catch(b){let y=b,w=(f=(p=y.code)!=null?p:y.errNo)!=null?f:2e3;d="FAILURE";let E=(v=(m=y.message)!=null?m:y.errMsg)!=null?v:`${b}`,C=`${n}:${d} ${E.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(u,{code:d,message:C}),Ae(new eo(C,w)),u}finally{let b=Date.now()-s}})}return{createAPI:r,createSyncAPI:t}}});var ve,rs=x(()=>{"use strict";V();ce();({canIUseNative:ve}=Pa(()=>I.sdkInfo.nativeSDKVersionCode,()=>I.platform))});function xu(e){if(typeof e!="number"||e<=0)return"0.0.0";let t=e.toString(),r=0,n=0,i=0;return t.length>=1&&(r=parseInt(t.substring(0,1),10)),t.length>=3&&(n=parseInt(t.substring(1,3),10)),t.length>=5&&(i=parseInt(t.substring(3,5),10)),`${r}.${n}.${i}`}var Mg=x(()=>{"use strict"});var $,Q,D,Je=x(()=>{"use strict";Dg();bt();Ug();ku();rs();Mg();({createAPI:$,createSyncAPI:Q}=qg(j)),D=Ng("native")});function Fg(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return t==="array"&&(t="object"),KR.includes(t)?t:""}function jg(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 Bg(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 ns,VR,$R,WR,zR,
|
|
3
|
+
`);throw e.errors.length=0,Su(!1),new TypeError(n)}}var S,ku=x(()=>{"use strict";Au();Au();S={object(e){return new Ka(e)},array(e){return new Wa(e)},tuple(...e){return new Xa(...e)},literal(e){return new Ya(e)},or(...e){return new Qa(...e)},symbol(){return new Ga},record(e){return new za(e)},function(){return new Va},boolean(){return new ja},string(){return new Ba},number(){return new Fa},undefined(){return new Ja},null(){return new Ha},unknown(){return new $n},any(){return new $n},as(){return new $n},arraybuffer(){return new Za},enum(...e){return new $a(...e)},typedarray(e){return new es(e)}}});var ts,qg,Ug=x(()=>{"use strict";R();yt();ku();Ur();ts=1,qg=e=>{function t(n,i){return(...o)=>{var u,p,f,m;let a=Date.now(),s={method:n,trace_id:ts};ts+=1;let c="SUCCESS",l=`${n}:ok`,d=0;try{if(i.paramsSchema)try{Cu(i.paramsSchema,o,"params")}catch(w){throw yu(`${n}:fail ${w.message}`)}let v=i.implement(...o),b=v,y=`${n}:ok`;if(v&&"code"in v){let{code:w,data:E,message:C}=v;c=w,b=E,y=C}return{code:c,message:y,data:b}}catch(v){let b=v;d=(p=(u=b.code)!=null?u:b.errNo)!=null?p:2e3,c="FAILURE";let y=(m=(f=b.message)!=null?f:b.errMsg)!=null?m:`${v}`;return l=`${n}:${c} ${y.replace(/^\S+:(fail|cancel)\s?/,"")}`,Ae(new eo(l,d)),{code:c,message:l}}finally{let v=Date.now()-a}}}function r(n,i){return(...o)=>g(this,null,function*(){var p,f,m,v;let a=Zh(o)?o:[o],s=Date.now(),c={method:n,trace_id:ts};ts+=1;let l=`${n}:ok`,d="SUCCESS",u={code:d,message:l};try{if(i.paramsSchema)try{Cu(i.paramsSchema,a,"params")}catch(w){throw yu(w.message)}let y=yield i.implement(...a);if(y&&"code"in y){let{code:w,data:E,message:C}=y;d=w,l=C,y=E}return Object.assign(u,{code:d,message:l,data:y}),u}catch(b){let y=b,w=(f=(p=y.code)!=null?p:y.errNo)!=null?f:2e3;d="FAILURE";let E=(v=(m=y.message)!=null?m:y.errMsg)!=null?v:`${b}`,C=`${n}:${d} ${E.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(u,{code:d,message:C}),Ae(new eo(C,w)),u}finally{let b=Date.now()-s}})}return{createAPI:r,createSyncAPI:t}}});var ve,rs=x(()=>{"use strict";V();ce();({canIUseNative:ve}=Pa(()=>I.sdkInfo.nativeSDKVersionCode,()=>I.platform))});function xu(e){if(typeof e!="number"||e<=0)return"0.0.0";let t=e.toString(),r=0,n=0,i=0;return t.length>=1&&(r=parseInt(t.substring(0,1),10)),t.length>=3&&(n=parseInt(t.substring(1,3),10)),t.length>=5&&(i=parseInt(t.substring(3,5),10)),`${r}.${n}.${i}`}var Mg=x(()=>{"use strict"});var $,Q,D,Je=x(()=>{"use strict";Dg();bt();Ug();ku();rs();Mg();({createAPI:$,createSyncAPI:Q}=qg(j)),D=Ng("native")});function Fg(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return t==="array"&&(t="object"),KR.includes(t)?t:""}function jg(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 Bg(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 ns,VR,$R,WR,zR,h6,g6,KR,Mr,_t,ro=x(()=>{"use strict";Je();ce();R();dt();V();ns=K(),VR=$("getLocalStorage",{paramsSchema:S.tuple(S.string()),implement(e){return g(this,null,function*(){let{response:t}=yield Y(`/api/games/user-storage/${I.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:i}}=yield t;if(r==="SUCCESS")return{code:r,message:n,data:i==null?void 0:i.value};try{let{data:{data:o,dataType:a}}=yield de("getLocalStorageAsync",{key:e}),s=jg(o,a);return{code:r,message:`${n}. fallback to native`,data:s}}catch(o){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}})}});ns.registerCommand("StorageSDK.getItem",VR);D("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});$R=$("setStorage",{paramsSchema:S.tuple(S.string(),S.or(S.string(),S.boolean(),S.number())),implement(e,t){return g(this,null,function*(){let r=I.mpId,n=typeof t=="string"?t:String(t),{response:i}=yield Y(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:o,message:a}}=i,s=Fg(t),c=Bg(t,s);return yield de("setLocalStorageAsync",{key:e,data:c,dataType:s}),o=="SUCCESS"?{code:o,message:a}:{code:o,message:`${a}. fallback to native`}})}});ns.registerCommand("StorageSDK.setItem",$R);D("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});WR=$("removeStorage",{paramsSchema:S.tuple(S.string()),implement(e){return g(this,null,function*(){let t=I.mpId,{response:r}=yield Y(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:i}}=r;return yield de("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:i}:{code:n,message:"[Jolibox SDK] remove item succ"}})}});ns.registerCommand("StorageSDK.removeItem",WR);D("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});zR=$("clearStorage",{implement(){return g(this,null,function*(){let e=I.mpId,{response:t}=yield Y(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});de("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}})}});ns.registerCommand("StorageSDK.clear",zR);D("storage.clear",{version:"1.0.0"});h6=$("getStorageInfo",{implement(){return g(this,null,function*(){let{data:e}=yield de("getStorageInfoAsync");return e})}});D("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});g6=Q("getStorageInfoSync",{implement(){return L("getStorageInfoSync")}}),KR=["string","number","boolean","object",""];Mr=$("getGlobalStorage",{paramsSchema:S.tuple(S.string()),implement(e){return g(this,null,function*(){try{let{data:{data:t,dataType:r}}=yield de("getGlobalStorageAsync",{key:e});return{code:"SUCCESS",message:"success",data:jg(t,r)}}catch(t){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get global storage failed",data:null}}})}}),_t=$("setGlobalStorage",{paramsSchema:S.tuple(S.string(),S.or(S.string(),S.boolean(),S.number(),S.array())),implement(e,t){return g(this,null,function*(){try{let r=Fg(t),n=Bg(t,r);return yield de("setGlobalStorageAsync",{key:e,data:n,dataType:r}),{code:"SUCCESS",message:"success"}}catch(r){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] set global storage failed"}}})}})});var Gg,is,Jg=x(()=>{"use strict";V();Og();R();dt();ce();ro();rs();Gg="REPORT_FIRST_OPEN_GAME",is=class extends qa{constructor(r,n,i){super(n,i);this.started=!1;this.gameId=I.mpId,this.sessionId=I.sessionId,this.track=r,this.taskUrl=Vn(I.testMode)+"/api/base/app-event"}reporter(r){return g(this,null,function*(){let{event:n,params:i,extraParams:o}=r,a={eventType:n,gameInfo:P({gameId:this.gameId,sessionId:this.sessionId},i)};o&&Object.assign(a,o),yield this.createTask(a)})}reportToNative(r){return g(this,null,function*(){let{event:n,params:i}=r;yield de("userTrackAsync",{event:n,params:P({},i),gameId:this.gameId})})}tracker(r,n=null){this.track(r,n)}start(r){if(this.started){console.info("[JoliboxSDK] taskTrakcer has started");return}super.start(r),this.tryReportOpenGamePlus(),this.started=!0}tryReportOpenGamePlus(){Mr(Gg).then(r=>{qr(r.data)&&r.data&&this.tracker("OpenGame_2Plus"),_t(Gg,!0)})}createTask(r){return ve("sendServerEventAsync")?de("sendServerEventAsync",{payload:r}):I.platform==="android"?Y("/api/base/app-event",{method:"POST",data:r}):de("trackAppEventAsync",{url:this.taskUrl,body:JSON.stringify(r)})}}});var zg={};Ih(zg,{nativeTaskEmitter:()=>no,taskTracker:()=>wt,track:()=>j,trackPerformance:()=>$g});var YR,Hg,Vg,j,$g,Wg,no,wt,bt=x(()=>{"use strict";Ig();R();bu();Pg();V();Jg();ce();YR=(e,t,r)=>{var l,d,u,p,f,m,v;let n=t,i=ln(n.extra)?n.extra:Yi(n.extra)?JSON.parse(n.extra):{},{mpName:o,mpVersion:a}=(l=I.mpInfo)!=null?l:{},s=P(P(B(P({},i),{mp_id:(d=n.mp_id)!=null?d:"",mp_version:(u=n.mp_version)!=null?u:"",session_id:I.sessionId,user_id:(f=(p=I.hostUserInfo)==null?void 0:p.uid)!=null?f:""}),o?{mp_name:o}:{}),a?{mp_info_version:a}:{}),c=(m=n.eventType)!=null?m:z.Other;L("trackAsync",{event:(v=t.tag)!=null?v:e,data:s,webviewId:r,eventType:c})},{track:j,trackPerformance:$g}=kg(YR,{type:lu.AppSDK,platform:"native",jssdk_version:(Vg=(Hg=I.sdkInfo)==null?void 0:Hg.jssdkVersion)!=null?Vg:"1.0.0",mp_id:I.mpId,mp_version:I.mpVersion}),Wg=K();Wg.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{$g(e,t,r)});Wg.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{j(e,t)});no=new Wt,wt=new is(j,no)});function Kg(){let e=null,t=null,r=window.fetch,n=()=>{t=document.createElement("meta"),t.setAttribute("name","viewport"),t.setAttribute("content","viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"),t.setAttribute("data-jolibox-sdk","viewport-meta"),e=document.createElement("style"),e.setAttribute("data-jolibox-sdk","default-styles");let s=`
|
|
4
4
|
html[data-jolibox-root] {
|
|
5
5
|
height: 100%;
|
|
6
6
|
margin: 0;
|
|
@@ -866,7 +866,7 @@ If multiple caches share the same key they might "fight" for each other's style
|
|
|
866
866
|
width: 100%;
|
|
867
867
|
height: 100%;
|
|
868
868
|
}
|
|
869
|
-
`,g9=e=>{let{state:t}=e,{afterAd:r,adDismissed:n,adViewed:i,adBreakDone:o,adLoaded:a,adLinkClicked:s,visible:c,src:l}=t,[d,u]=gr(!1),p=m=>{var v,b,y,w;u(!1),c.value=!1,m==="dismiss"?(v=n.value)==null||v.call(n):m==="viewed"&&((b=i.value)==null||b.call(i)),(y=r.value)==null||y.call(r),(w=o.value)==null||w.call(o)},f=()=>{var m;(m=a.value)==null||m.call(a)};return Pi("appsrockets_ad_dismissed",()=>p("dismiss")),Pi("appsrockets_ad_rewarded",()=>p("viewed")),Pi("appsrockets_ad_completed",()=>p("viewed")),Pi("appsrockets_ad_skipped",()=>p("viewed")),Pi("appsrockets_ad_clicked",m=>{var v;return(v=s.value)==null?void 0:v.call(s,m)}),Pi("appsrockets_ad_loaded",()=>u(!0)),c.value?X("div",{className:h9,style:{display:d?"flex":"none"},children:c.value&&X("iframe",{src:l.value,onLoad:f,allowFullScreen:!0,allow:"autoplay",sandbox:"allow-scripts allow-same-origin allow-forms allow-modals allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation allow-top-navigation allow-top-navigation-by-user-activation allow-top-navigation-to-custom-protocols"})}):null};Pm=class{constructor(t,r){Tr(this,"name","APPSROCKETS"),Tr(this,"initialized",!1),Tr(this,"initCompleter",null),Tr(this,"context",void 0),Tr(this,"adsOverlay",null),Tr(this,"adsIsShowing",!1),Tr(this,"lastUnDisplayedAdBreak",null),Tr(this,"state",m9()),Tr(this,"processUrl",(n,i)=>{var o;let a=this.context.getContextInfo(),s=new URL(n),c=new URLSearchParams(s.search);return c.has("joliSource")||c.set("joliSource",a.joliSource),c.get("osType")||c.set("osType",a.osType),c.get("runtimeType")||c.set("runtimeType",a.runtimeType),c.get("mode")||c.set("mode","AFG"),c.get("deviceId")||c.set("deviceId",a.deviceId),c.get("statusBarHeight")||c.set("statusBarHeight",((o=this.context.getWindowInfo().statusBarHeight)!=null?o:0).toString()),c.get("adsType")||c.set("adsType",i),s.search=c.toString(),s.toString()}),this.context=t}init(){return g(this,null,function*(){var t;this.adsOverlay=document.createElement("div"),this.adsOverlay.setAttribute("data-placement-info","afg-appsrockets"),Is(X(g9,{state:this.state}),this.adsOverlay),document.documentElement.appendChild(this.adsOverlay),this.initialized=!0,(t=this.initCompleter)==null||t.call(this)})}adConfig(t){var r;if(this.initialized){(r=t.onReady)==null||r.call(t);return}this.initCompleter=()=>{var n;(n=t.onReady)==null||n.call(t)}}adBreak(t,r){var n,i,o,a,s,c,l,d;if(!this.initialized||!this.adsOverlay||!r.params.url){(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakName:t.type==="preroll"?"":t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"notReady"});return}if(this.adsIsShowing){(i=t.adBreakDone)==null||i.call(t,{breakType:t.type,breakName:t.type==="preroll"?"":t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}let u=f=>{var m,v;(v=(m=this.context).handleLinkClicked)==null||v.call(m,f)},p=t.type==="reward"?"REWARD":"INTERSTITIAL";switch(t.type){case"preroll":{(o=t.adBreakDone)==null||o.call(t,{breakType:t.type,breakName:"",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"start":case"browse":case"next":case"pause":{(a=t.beforeAd)==null||a.call(t);let f=()=>{var b;this.adsIsShowing=!1,(b=t.afterAd)==null||b.call(t)},m=()=>{var b;this.adsIsShowing=!1,(b=t.adBreakDone)==null||b.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"viewed"})},v=()=>{var b;this.adsIsShowing=!1,(b=t.adBreakDone)==null||b.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"noAdPreloaded"})};Ke(()=>{this.adsIsShowing=!0,this.state.afterAd.value=f,this.state.adBreakDone.value=m,this.state.src.value=this.processUrl(r.params.url,p),this.state.adLinkClicked.value=u,this.state.adError.value=v,this.state.visible.value=!0});break}case"reward":{this.lastUnDisplayedAdBreak&&((c=(s=this.lastUnDisplayedAdBreak).adBreakDone)==null||c.call(s,{breakType:this.lastUnDisplayedAdBreak.type,breakName:this.lastUnDisplayedAdBreak.type==="preroll"?"":this.lastUnDisplayedAdBreak.name,breakFormat:this.lastUnDisplayedAdBreak.type==="reward"?"reward":"interstitial",breakStatus:"ignored"}),this.lastUnDisplayedAdBreak=null),(l=t.beforeAd)==null||l.call(t);let f=()=>{var C;this.adsIsShowing=!1,(C=t.afterAd)==null||C.call(t)},m={breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"ignored"},v=()=>{var C;this.adsIsShowing=!1,m.breakStatus="dismissed",(C=t.adDismissed)==null||C.call(t)},b=()=>{var C;this.adsIsShowing=!1,m.breakStatus="viewed",(C=t.adViewed)==null||C.call(t)},y=()=>{var C;this.adsIsShowing=!1,(C=t.adBreakDone)==null||C.call(t,m)},w=()=>{this.adsIsShowing=!1,m.breakStatus="noAdPreloaded"};Ke(()=>{this.state.afterAd.value=f,this.state.adDismissed.value=v,this.state.adViewed.value=b,this.state.adBreakDone.value=y,this.state.adLinkClicked.value=u,this.state.adError.value=w});let E=()=>{var C;if(this.lastUnDisplayedAdBreak=null,!this.adsOverlay){(C=t.adBreakDone)==null||C.call(t,{breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"notReady"});return}this.adsIsShowing=!0,Ke(()=>{this.state.src.value=this.processUrl(r.params.url,p),this.state.visible.value=!0})};this.lastUnDisplayedAdBreak=t,(d=t.beforeReward)==null||d.call(t,E);break}}}},pP=()=>{window.googletag=window.googletag||{cmd:[]},window.googletag.pubadsReady||window.googletag.cmd.push(()=>{window.googletag.enableServices()})};w9=class{constructor(e,t,r){nt(this,"adUnit",void 0),nt(this,"project",void 0),nt(this,"keyValue",void 0),nt(this,"adsContext",null),nt(this,"rewardedSlot",null),nt(this,"rewardedPayload",null),nt(this,"readyEvent",null),nt(this,"withCommand",function(){googletag.cmd.push(...arguments)}),nt(this,"init",()=>{var n;this.rewardedSlot=googletag.defineOutOfPageSlot(this.adUnit,googletag.enums.OutOfPageFormat.REWARDED),this.rewardedSlot&&(this.rewardedSlot.addService(googletag.pubads()),googletag.pubads().addEventListener("rewardedSlotReady",this.handleSlotReady),googletag.pubads().addEventListener("rewardedSlotClosed",this.handleSlotClosed),googletag.pubads().addEventListener("rewardedSlotGranted",this.handleSlotGranted),googletag.pubads().addEventListener("slotRenderEnded",this.handleSlotRenderEnded),this.keyValue&&(Object.keys(this.keyValue).forEach(i=>{var o;(o=this.rewardedSlot)==null||o.setTargeting(i,this.keyValue[i])}),Object.keys(this.keyValue).includes("project")||(n=this.rewardedSlot)==null||n.setTargeting("project",this.project)),googletag.display(this.rewardedSlot))}),nt(this,"destroy",n=>{var i,o;this.rewardedPayload=null,this.readyEvent=null,googletag.pubads().removeEventListener("rewardedSlotReady",this.handleSlotReady),googletag.pubads().removeEventListener("rewardedSlotClosed",this.handleSlotClosed),googletag.pubads().removeEventListener("rewardedSlotGranted",this.handleSlotGranted),googletag.pubads().removeEventListener("slotRenderEnded",this.handleSlotRenderEnded),this.rewardedSlot&&(googletag.destroySlots([this.rewardedSlot]),this.rewardedSlot=null),(o=(i=this.adsContext)==null?void 0:i.adBreakDone)==null||o.call(i,n),n!=="ignored"&&(this.adsContext=null)}),nt(this,"reinit",n=>{this.destroy(n),this.init()}),nt(this,"handleSlotReady",n=>{n.slot===this.rewardedSlot&&(this.readyEvent=n)}),nt(this,"handleSlotClosed",n=>{var i,o;if(this.adsContext&&n.slot===this.rewardedSlot){let a=this.rewardedPayload?"viewed":"dismissed";a==="viewed"?this.adsContext.adViewed():this.adsContext.adDismissed(),(o=(i=this.adsContext).afterAd)==null||o.call(i),this.withCommand(()=>{this.reinit(a)})}}),nt(this,"handleSlotGranted",n=>{this.adsContext&&n.slot===this.rewardedSlot&&(this.rewardedPayload=n.payload)}),nt(this,"handleSlotRenderEnded",n=>{n.slot===this.rewardedSlot&&n.isEmpty&&this.adsContext&&this.withCommand(()=>{this.reinit("frequencyCapped")})}),nt(this,"requestAds",n=>{this.withCommand(()=>{if(this.adsContext){this.destroy("ignored");return}if(this.rewardedSlot||this.init(),this.adsContext=n,!this.rewardedSlot){this.reinit("notReady");return}if(this.readyEvent)this.adsContext.beforeReward(()=>{var i,o,a;(o=(i=this.adsContext)==null?void 0:i.beforeAd)==null||o.call(i),(a=this.readyEvent)==null||a.makeRewardedVisible()});else{let i=o=>{o.slot===this.rewardedSlot&&this.adsContext&&(googletag.pubads().removeEventListener("rewardedSlotReady",i),this.readyEvent=o,this.adsContext.beforeReward(()=>{var a,s,c;(s=(a=this.adsContext)==null?void 0:a.beforeAd)==null||s.call(a),(c=this.readyEvent)==null||c.makeRewardedVisible()}))};googletag.pubads().addEventListener("rewardedSlotReady",i),window.setTimeout(()=>{this.readyEvent||(this.reinit("timeout"),googletag.pubads().removeEventListener("rewardedSlotReady",i))},500)}})}),this.adUnit=e,this.project=t,this.keyValue=r,pP(),this.withCommand(()=>{this.init()})}};Om=class{constructor(t,r,n){var i=this;ht(this,"adUnit",void 0),ht(this,"project",void 0),ht(this,"keyValue",void 0),ht(this,"adsContext",null),ht(this,"gamingInterstitialSlot",null),ht(this,"readyEvent",null),ht(this,"isRetrying",!1),ht(this,"withCommand",function(){googletag.cmd.push(...arguments)}),ht(this,"init",()=>{var o;this.gamingInterstitialSlot=googletag.defineOutOfPageSlot(this.adUnit,googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL),this.gamingInterstitialSlot&&(this.gamingInterstitialSlot.addService(googletag.pubads()),googletag.pubads().addEventListener("gameManualInterstitialSlotReady",this.handleSlotReady),googletag.pubads().addEventListener("gameManualInterstitialSlotClosed",this.handleSlotClosed),this.keyValue&&(Object.keys(this.keyValue).forEach(a=>{var s;(s=this.gamingInterstitialSlot)==null||s.setTargeting(a,this.keyValue[a])}),Object.keys(this.keyValue).includes("project")||(o=this.gamingInterstitialSlot)==null||o.setTargeting("project",this.project)),googletag.display(this.gamingInterstitialSlot))}),ht(this,"destroy",function(o){var a,s;(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1])&&((s=(a=i.adsContext)==null?void 0:a.onEnd)==null||s.call(a,o),o!=="ignored"&&(i.adsContext=null)),googletag.pubads().removeEventListener("gameManualInterstitialSlotReady",i.handleSlotReady),googletag.pubads().removeEventListener("gameManualInterstitialSlotClosed",i.handleSlotClosed),i.gamingInterstitialSlot&&(googletag.destroySlots([i.gamingInterstitialSlot]),i.gamingInterstitialSlot=null,i.readyEvent=null)}),ht(this,"reinit",function(o){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;i.destroy(o,a),i.init()}),ht(this,"handleSlotReady",o=>{this.gamingInterstitialSlot===o.slot&&(this.readyEvent=o)}),ht(this,"handleSlotClosed",o=>{var a,s;this.adsContext&&this.gamingInterstitialSlot===o.slot&&((s=(a=this.adsContext).afterAd)==null||s.call(a),this.withCommand(()=>{this.reinit("viewed")}))}),ht(this,"requestAds",o=>{this.withCommand(()=>{var a,s,c;if(this.adsContext){this.destroy("ignored");return}if(this.gamingInterstitialSlot||this.init(),this.adsContext=o,!this.gamingInterstitialSlot){this.reinit("notReady");return}this.readyEvent?((a=o.beforeAd)==null||a.call(o),this.readyEvent.makeGameManualInterstitialVisible()):((c=(s=this.adsContext).onEnd)==null||c.call(s,"frequencyCapped"),this.adsContext=null,this.isRetrying||(this.isRetrying=!0,window.setTimeout(()=>{this.readyEvent||this.withCommand(()=>{this.reinit("frequencyCapped",!1)}),this.isRetrying=!1},31e3)))})}),pP(),this.adUnit=t,this.project=r,this.keyValue=n,this.withCommand(()=>{this.init()})}};Rm=class{constructor(t,r){Ln(this,"name","GOOGLE_GPT"),Ln(this,"context",void 0),Ln(this,"contextInfo",void 0),Ln(this,"initParams",void 0),Ln(this,"rewardAdManager",void 0),Ln(this,"interstitialManager",void 0),Ln(this,"insertScript",()=>{let n="jolibox-google-gpt",i=document.getElementById(n);i||(i=window.document.createElement("script"),i.id=n,i.async=!0,i.src="https://securepubads.g.doubleclick.net/tag/js/gpt.js",i.crossOrigin="anonymous",document.head.appendChild(i))}),this.context=t,this.contextInfo=this.context.getContextInfo(),this.initParams=r,this.insertScript()}init(){return g(this,null,function*(){let t=this.contextInfo.testAdsMode?"/22639388115/rewarded_web_example":this.initParams.rewardedSlot,r=this.contextInfo.testAdsMode?"/6355419/Travel/Europe/France/Paris":this.initParams.interstitialSlot,n=`minigame-${this.contextInfo.runtimeType==="APP"?"app":"h5"}`;t&&(this.rewardAdManager=new w9(t,n,this.initParams.keyValue)),r&&(this.interstitialManager=new Om(r,n,this.initParams.keyValue))})}adConfig(t,r){}adBreak(t,r){var n,i,o;switch(t.type){case"preroll":{(n=t.adBreakDone)==null||n.call(t,{breakType:"preroll",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"reward":{if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:a=>{var s;(s=t.adBreakDone)==null||s.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:a})}});break}default:{if(!this.interstitialManager){(o=t.adBreakDone)==null||o.call(t,{breakName:t.name,breakType:t.type,breakFormat:"interstitial",breakStatus:"noAdPreloaded"});return}this.interstitialManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,onEnd:a=>{var s;(s=t.adBreakDone)==null||s.call(t,{breakName:t.name,breakType:t.type,breakFormat:"interstitial",breakStatus:a})}});break}}}};Nm=class{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"GAME";um(this,"context",void 0),um(this,"placement","GAME"),um(this,"contextInfo",void 0),this.context=t,this.placement=r,this.contextInfo=this.context.getContextInfo()}getLocation(){let t=new URLSearchParams(window.location.search),r={};return t.forEach((n,i)=>{r[i]=n}),{name:this.placement==="GAME"?"GamePage":"DramaPage",params:r}}getDevice(){var t,r,n,i;return{platform:(t=this.contextInfo.platform)!=null?t:JT.WebSDK,os:this.contextInfo.osType+"_"+this.contextInfo.runtimeType,appVersion:"1.0.0",appId:(r=this.contextInfo.hostAppId)!=null?r:"1",model:(n=this.contextInfo.deviceModel)!=null?n:"UnknownModel",brand:(i=this.contextInfo.deviceBrand)!=null?i:"UnknownBrand",uuid:this.contextInfo.deviceId,jsSdkVersion:"1.0.0",extra:{}}}serialize(t,r){var n;let i={protocolVersion:"1.0.0",events:[{name:t,type:BT.System,location:this.getLocation(),target:null,extra:r,timestamp:Date.now(),userId:(n=this.contextInfo.userId)!=null?n:null}],device:this.getDevice(),project:GT.WebSDK};return CV(i)}};wl=class{constructor(t){lt(this,"context",void 0),lt(this,"adsTrackSerializer",void 0),lt(this,"contextInfo",void 0),this.context=t,this.contextInfo=t.getContextInfo(),this.adsTrackSerializer=new Nm(this.context)}getRequestContextData(t){var r,n;this.contextInfo=this.context.getContextInfo();let{width:i,height:o}=this.context.getWindowInfo();return{report:JSON.stringify(this.adsTrackSerializer.serialize(t,{sessionId:this.contextInfo.sessionId,objectType:this.contextInfo.objectType,objectId:this.contextInfo.objectId,testAdsMode:this.contextInfo.testAdsMode})),osType:this.contextInfo.osType,runtimeType:this.contextInfo.runtimeType,sessionId:this.contextInfo.sessionId,deviceId:this.contextInfo.deviceId,adId:this.contextInfo.adId,deviceModel:(r=this.contextInfo.deviceModel)!=null?r:"UnknownModel",deviceBrand:(n=this.contextInfo.deviceBrand)!=null?n:"UnknownBrand",dimension:{width:i,height:o}}}getRequestBizParams(){return{objectType:this.contextInfo.objectType,objectId:this.contextInfo.objectId}}},Dm=class{constructor(t,r){var n=this;lt(this,"context",void 0),lt(this,"contextInfo",void 0),lt(this,"requestContext",void 0),lt(this,"pendingAFGAdsInfo",{REWARD:Promise.resolve(null),INTERSTITIAL:Promise.resolve(null)}),lt(this,"pendingAFVAdsInfo",Promise.resolve(null)),lt(this,"doFetchAdsInfo",i=>g(this,null,function*(){let o=i==="afv"?"AdsAFVSDKRequest":"AdsAFGSDKAdBreak",a=[];switch(i){case"afv":{a=["REWARD_INTERSTITIAL","REWARD","NATIVE"];break}case"reward":{a=["REWARD_INTERSTITIAL","REWARD","NATIVE"];break}default:{a=["INTERSTITIAL"];break}}let s=i==="afv"?void 0:"cached",{data:c,code:l}=yield this.context.httpClient.post("/api/ads/info",{data:{contextData:this.requestContext.getRequestContextData(o),bizParams:this.requestContext.getRequestBizParams(),adsTypes:a,testAdsMode:this.contextInfo.testAdsMode,name:s}});return l==="SUCCESS"||l==="BYPASS_ADS"?{code:l,data:c}:null})),lt(this,"cacheRewardInfo",()=>{this.pendingAFGAdsInfo.REWARD=this.doFetchAdsInfo("reward").catch(()=>null)}),lt(this,"cacheInterstitialInfo",i=>{this.pendingAFGAdsInfo.INTERSTITIAL=this.doFetchAdsInfo(i).catch(()=>null)}),lt(this,"cacheAFVInfo",()=>{this.pendingAFVAdsInfo=this.doFetchAdsInfo("afv").catch(()=>null)}),lt(this,"cacheNextAFGAdsInfo",i=>g(this,null,function*(){i==="reward"?this.cacheRewardInfo():this.cacheInterstitialInfo(i)})),lt(this,"getAFGAdsInfo",i=>g(this,null,function*(){let o=yield i==="reward"?this.pendingAFGAdsInfo.REWARD:this.pendingAFGAdsInfo.INTERSTITIAL;return this.cacheNextAFGAdsInfo(i),o})),lt(this,"getAFVAdsInfo",function(){return g(this,arguments,function*(){if(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0]){let i=yield n.pendingAFVAdsInfo;return n.cacheAFVInfo(),i}else return n.cacheAFVInfo(),yield n.pendingAFVAdsInfo})}),this.context=t,this.contextInfo=this.context.getContextInfo(),this.requestContext=new wl(t),r!=null&&r.reward&&this.cacheRewardInfo(),r!=null&&r.interstitial&&this.cacheInterstitialInfo("start"),r!=null&&r.afv&&this.cacheAFVInfo()}};N9=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(e)try{e(...r)}catch(i){console.error("[JoliboxSDK] Callback error:",i)}},Sl=class{constructor(t){this.context=t,P9(this,"canIUseHelper",void 0),this.context=t;let{canIUseNative:r}=Pa(()=>this.context.getContextInfo().deviceInfo.nativeSDKVersionCode||1e6,()=>this.context.getContextInfo().deviceInfo.platform||"h5");this.canIUseHelper=r}loadAdsAsync(t){return g(this,null,function*(){try{let{errNo:r,errMsg:n}=yield L("loadAdsAsync",{params:{providers:t.providers}});return r!==0||n.length>0?{code:"FAILURE",message:n||"Failed to load ads"}:{code:"SUCCESS",message:"Ads loaded successfully"}}catch(r){return{code:"FAILURE",message:`Failed to load ads: ${r instanceof Error?r.message:String(r)}`}}})}canIUse(){return pm()&&this.canIUseHelper("loadAdsAsync")&&this.canIUseHelper("showAdAsync")}showAdAsync(t){return g(this,null,function*(){try{let r=yield L("showAdAsync",{params:{providers:t.providers}});if(r.errNo!==0)return{code:"FAILURE",message:r.errMsg||"Failed to show ad"};let n=r.data.UUID;if(t.callbacks){let i=t.timeout!==void 0?t.timeout:-1,o=null,a=()=>{Vh("onAdsStateChange",s),o&&(clearTimeout(o),o=null)},s=c=>{var l;if(c.UUID!==n)return;let d=(l=t.callbacks)==null?void 0:l[c.event];d&&N9(d,c.data),["onAdClosed","onAdError","onAdDismissed"].includes(c.event)&&a()};_e("onAdsStateChange",s),i>0&&(o=setTimeout(()=>{a(),console.warn(`[JoliboxSDK] Event listener for ad ${n} auto-cleaned after ${i}ms timeout`)},i))}return{code:"SUCCESS",message:"Ad shown successfully"}}catch(r){return{code:"FAILURE",message:`Failed to show ad: ${r instanceof Error?r.message:String(r)}`}}})}isAdsReadySync(t){try{let{errNo:r,data:n}=L("isAdsReadySync",{params:{providers:t.providers}});return r!==0||!n?(console.warn("[Jolibox SDK]isAdsReadySync returned an error or no data"),!1):!0}catch(r){return console.warn("[Jolibox SDK]isAdsReadySync invocation failed:",r),!1}}};Lm=class{get isAdsReady(){return this._isAdsReady}constructor(t,r){Pr(this,"providers",void 0),Pr(this,"helper",void 0),Pr(this,"adsContext",null),Pr(this,"_isAdsReady",!1),Pr(this,"init",()=>g(this,null,function*(){this.helper.canIUse()?(yield this.helper.loadAdsAsync({providers:this.providers})).code==="SUCCESS"?this._isAdsReady=!0:this._isAdsReady=!1:this._isAdsReady=!1})),Pr(this,"destroy",n=>{var i,o;this._isAdsReady=!1,(o=(i=this.adsContext)==null?void 0:i.adBreakDone)==null||o.call(i,n),n!=="ignored"&&(this.adsContext=null)}),Pr(this,"reinit",n=>g(this,null,function*(){this.destroy(n),yield this.init()})),Pr(this,"requestAds",(n,i)=>g(this,null,function*(){if(this.adsContext){this.destroy("ignored");return}this.adsContext=n,i&&i.length>0&&(this.providers=i);try{this.isAdsReady?this.showAd():yield this.reinit("frequencyCapped")}catch(o){this.destroy("notReady")}})),Pr(this,"showAd",()=>{if(!this.adsContext){this.destroy("error");return}let n=!1,i=!1;this.adsContext.beforeReward(()=>g(this,null,function*(){var o,a;(a=(o=this.adsContext)==null?void 0:o.beforeAd)==null||a.call(o);let s=l=>{var d,u,p;i||(i=!0,l==="dismissed"&&((d=this.adsContext)==null||d.adDismissed()),(p=(u=this.adsContext)==null?void 0:u.afterAd)==null||p.call(u),this.reinit(l))},c={onAdShow:()=>{},onAdError:()=>{s("error")},onAdRewarded:()=>{var l;n=!0,(l=this.adsContext)==null||l.adViewed()},onAdDismissed:()=>{s(n?"viewed":"dismissed")},onAdClosed:()=>{s(n?"viewed":"dismissed")}};(yield this.helper.showAdAsync({providers:this.providers,callbacks:c})).code!=="SUCCESS"&&this.reinit("noAdPreloaded")}))}),this.providers=r,this.helper=new Sl(t),this.init()}};qm=class{get isAdsReady(){return this._isAdsReady}constructor(t,r){var n=this;Or(this,"providers",void 0),Or(this,"helper",void 0),Or(this,"adsContext",null),Or(this,"_isAdsReady",!1),Or(this,"init",()=>g(this,null,function*(){this.helper.canIUse()&&((yield this.helper.loadAdsAsync({providers:this.providers})).code==="SUCCESS"?this._isAdsReady=!0:this._isAdsReady=!1)})),Or(this,"destroy",function(i){var o,a;let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;n._isAdsReady=!1,s&&((a=(o=n.adsContext)==null?void 0:o.onEnd)==null||a.call(o,i),i!=="ignored"&&(n.adsContext=null))}),Or(this,"reinit",function(o){return g(this,arguments,function*(i){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;n.destroy(i,a),yield n.init()})}),Or(this,"requestAds",(i,o)=>g(this,null,function*(){if(this.adsContext){this.destroy("ignored");return}this.adsContext=i,o&&o.length>0&&(this.providers=o);try{this.isAdsReady?yield this.showAd():yield this.reinit("frequencyCapped")}catch(a){this.destroy("notReady")}})),Or(this,"showAd",()=>g(this,null,function*(){var i,o;if(!this.adsContext){this.destroy("error");return}let a=!1;(o=(i=this.adsContext).beforeAd)==null||o.call(i);let s=l=>{var d,u;a||(a=!0,(u=(d=this.adsContext)==null?void 0:d.afterAd)==null||u.call(d),this.reinit(l))},c={onAdShow:()=>{},onAdError:()=>{s("error")},onAdDismissed:()=>{s("dismissed")},onAdClosed:()=>{s("viewed")}};(yield this.helper.showAdAsync({providers:this.providers,callbacks:c})).code!=="SUCCESS"&&this.reinit("noAdPreloaded")})),this.providers=r,this.helper=new Sl(t),this.init()}};Um=class{constructor(t,r){ca(this,"name","INTERNAL_NATIVE"),ca(this,"context",void 0),ca(this,"rewardAdManager",void 0),ca(this,"interstitialManager",void 0),ca(this,"initProviders",void 0),this.context=t,this.initProviders=r.providers;let n=this.getConfigsByTypes(["REWARD","REWARD_INTERSTITIAL","NATIVE"],r.providers),i=this.getConfigsByTypes(["INTERSTITIAL"],r.providers);n.length>0&&(this.rewardAdManager=new Lm(this.context,n)),i.length>0&&(this.interstitialManager=new qm(this.context,i))}getConfigsByTypes(t,r,n){let i=[];return(n?n.map(o=>r.find(a=>a.provider===o.provider)).filter(o=>!!o):r).forEach(o=>{t.forEach(a=>{let s="";a==="REWARD"&&(s=o.params.adUnitId.reward),a==="REWARD_INTERSTITIAL"&&(s=o.params.adUnitId.rewardInterstitial),a==="INTERSTITIAL"&&(s=o.params.adUnitId.interstitial),a==="NATIVE"&&(s=o.params.adUnitId.nativeAds),s&&i.push({provider:o.provider,params:{placementId:s,adsType:a,extra:o.params.extra}})})}),i}init(){return g(this,null,function*(){})}adConfig(t,r){}adBreak(t,r){var n,i,o;switch(t.type){case"preroll":{(n=t.adBreakDone)==null||n.call(t,{breakType:"preroll",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"reward":{if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}let a=this.getConfigsByTypes(["REWARD","REWARD_INTERSTITIAL","NATIVE"],this.initProviders,r.params);this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:s=>{var c;(c=t.adBreakDone)==null||c.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:s})}},a);break}default:{let a=t;if(!this.interstitialManager){(o=t.adBreakDone)==null||o.call(t,{breakName:a.name,breakType:t.type,breakFormat:"interstitial",breakStatus:"noAdPreloaded"});return}let s=this.getConfigsByTypes(["INTERSTITIAL"],this.initProviders,r.params);this.interstitialManager.requestAds({beforeAd:a.beforeAd,afterAd:a.afterAd,onEnd:c=>{var l;(l=t.adBreakDone)==null||l.call(t,{breakName:a.name,breakType:t.type,breakFormat:"interstitial",breakStatus:c})}},s);break}}}},dm="jolibox-nb-proxy",j9=0;hl=()=>{try{if(window.parent&&window.parent!==window)return B9("GameSDK")}catch(e){}};Mm=class{constructor(){en(this,"adsContext",null),en(this,"_isReady",!1),en(this,"_isAvailable",!1),en(this,"init",()=>g(this,null,function*(){this._isReady=!1;let t=hl();if(t)try{if(this._isAvailable=yield t.isAvailable("rewarded"),console.log("[JoliboxSDK] NewsBreak init isAvailable",this._isAvailable),!this._isAvailable)return;let r=yield t.createRewardAd({platform:"jolibox"});console.log("[JoliboxSDK] NewsBreak init createRewardAd result:",r),this._isReady=r.success&&r.ready}catch(r){this._isReady=!1}})),en(this,"destroy",t=>{var r,n;this._isReady=!1,(n=(r=this.adsContext)==null?void 0:r.adBreakDone)==null||n.call(r,t),t!=="ignored"&&(this.adsContext=null)}),en(this,"reinit",t=>g(this,null,function*(){this.destroy(t),yield this.init()})),en(this,"requestAds",t=>{if(console.log("[JoliboxSDK] NewsBreak newsbreak this.adsContext",this.adsContext),this.adsContext){this.destroy("ignored");return}this.adsContext=t;let r=hl();if(console.log("[JoliboxSDK] NewsBreak newsbreak sdk",r),!r){this.destroy("notReady");return}if(this._isReady||r.isRewardReady())this._isReady=!0,this.showAd();else{let n=window.setTimeout(()=>{this._isReady||this.reinit("timeout")},5e3);r.createRewardAd({platform:"jolibox"}).then(i=>{clearTimeout(n),i.success&&i.ready?(this._isReady=!0,this.showAd()):this.reinit("noAdPreloaded")}).catch(()=>{clearTimeout(n),this.reinit("noAdPreloaded")})}}),en(this,"showAd",()=>{if(!this.adsContext){this.destroy("error");return}this.adsContext.beforeReward(()=>g(this,null,function*(){var t,r,n,i,o,a,s,c,l,d,u,p,f,m;(r=(t=this.adsContext)==null?void 0:t.beforeAd)==null||r.call(t);let v=hl();if(!v){(i=(n=this.adsContext)==null?void 0:n.afterAd)==null||i.call(n),this.reinit("error");return}try{let b=yield v.showRewardAd();if(console.log("[JoliboxSDK] NewsBreak showRewardAd result:",b),!b.success){(a=(o=this.adsContext)==null?void 0:o.afterAd)==null||a.call(o),this.reinit("error");return}b.rewardGranted?((s=this.adsContext)==null||s.adViewed(),(l=(c=this.adsContext)==null?void 0:c.afterAd)==null||l.call(c),this.reinit("viewed")):((d=this.adsContext)==null||d.adDismissed(),(p=(u=this.adsContext)==null?void 0:u.afterAd)==null||p.call(u),this.reinit("dismissed"))}catch(b){(m=(f=this.adsContext)==null?void 0:f.afterAd)==null||m.call(f),this.reinit("error")}}))}),this.init()}};Fm=class{constructor(){DT(this,"name","NEWSBREAK"),DT(this,"rewardAdManager",void 0)}init(){return g(this,null,function*(){let t=hl();if(!t){console.warn("[JoliboxSDK] NewsBreak GameSDK is not available on window");return}t.onEnter(),this.rewardAdManager=new Mm})}adConfig(t,r){}adBreak(t,r){var n,i;if(t.type!=="reward"){(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:o=>{var a;(a=t.adBreakDone)==null||a.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:o})}})}};Li=class{constructor(t){if(Ht(this,"context",void 0),Ht(this,"contextInfo",void 0),Ht(this,"providers",{}),Ht(this,"channelPolicy",void 0),Ht(this,"adsActionDetection",void 0),Ht(this,"requestContext",void 0),Ht(this,"adsRequest",void 0),Ht(this,"initialized",!1),Ht(this,"adsIsShowing",!1),Ht(this,"lastAdBreak",void 0),Ht(this,"initializedTimeStamp",Date.now()),t)this.context=t,this.channelPolicy=new bm(this.context),this.adsActionDetection=new ym(this.context),this.contextInfo=this.context.getContextInfo(),this.adsRequest=new Dm(t),this.requestContext=new wl(t);else throw new Error("JoliboxAdsForGame requires a configuration object")}init(t){return g(this,null,function*(){window.adsbygoogle=window.adsbygoogle||[];let{data:r}=yield this.context.httpClient.post("/api/ads/init",{data:{contextData:this.requestContext.getRequestContextData("AdsAFGSDKInit"),bizParams:this.requestContext.getRequestBizParams(),testAdsMode:this.contextInfo.testAdsMode}});if((r==null?void 0:r.length)>0){let n=r.filter(s=>s.isNative),i=r.filter(s=>!s.isNative),o={provider:"INTERNAL_NATIVE",params:{providers:n}},a=i.concat([o]);for(let s of a)switch(s.provider){case"GOOGLE_GPT":{let c=new Rm(this.context,s.params);yield c.init(),this.providers[s.provider]=c;break}case"ADSENSE":case"ADSENSE_ADMOB":{let c=new _m(this.context,s.params);yield c.init(),this.providers[s.provider]=c;break}case"OKSPIN":{let c=new xm(this.context,s.params);yield c.init(),this.providers.OKSPIN=c;break}case"APPSROCKETS":{let c=new Pm(this.context,s.params);yield c.init(),this.providers.APPSROCKETS=c;break}case"ADSENSE_BANNER_AS_AFG":{let c=new Tm(this.context,s.params);yield c.init(),this.providers.ADSENSE_BANNER_AS_AFG=c;break}case"INTERNAL_NATIVE":{let c=new Um(this.context,s.params);yield c.init(),this.providers.INTERNAL_NATIVE=c;break}case"NEWSBREAK":{console.log("[JoliboxSDK] NewsBreak Provider",s);let c=new Fm;yield c.init(),this.providers.NEWSBREAK=c;break}}}this.adsRequest.cacheInterstitialInfo("start"),this.adsRequest.cacheRewardInfo(),this.initialized=!0})}adConfig(t){this.providers.ADSENSE?this.providers.ADSENSE.adConfig(t):window.adsbygoogle.push(t)}adBreak(t){return g(this,null,function*(){var r,n,i,o,a,s,c,l,d,u,p,f,m,v,b,y;let w=Date.now();if(w-this.initializedTimeStamp<3e3){(r=t.adBreakDone)==null||r.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}if(this.lastAdBreak&&w-this.lastAdBreak<500){console.warn("[Jolibox SDK Ads] You can't call adBreak too frequently"),(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}if(this.lastAdBreak=w,this.adsIsShowing){console.warn("[Jolibox SDK Ads] You can't call adBreak while ad is showing"),(i=t.adBreakDone)==null||i.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}if(this.initialized||(yield this.init()),t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){(o=t.adBreakDone)==null||o.call(t,{breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}if(!this.context.checkNetwork()){(a=t.adBreakDone)==null||a.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}try{let E=yield this.adsRequest.getAFGAdsInfo(t.type),C=E==null?void 0:E.data,T=E==null?void 0:E.code;if(T==="BYPASS_ADS"){switch(t.type){case"preroll":{(s=t.adBreakDone)==null||s.call(t,{breakType:t.type,breakFormat:"interstitial",breakStatus:"viewed"});break}case"reward":{t.beforeReward(()=>{var k,A,J,ue;(k=t.beforeAd)==null||k.call(t),(A=t.adViewed)==null||A.call(t),(J=t.afterAd)==null||J.call(t),(ue=t.adBreakDone)==null||ue.call(t,{breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"viewed"})});break}default:{(c=t.beforeAd)==null||c.call(t),(l=t.afterAd)==null||l.call(t),(d=t.adBreakDone)==null||d.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"viewed"});break}}return}if(!C||T!=="SUCCESS"){(u=t.adBreakDone)==null||u.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}else{if(C.length===0){(p=t.adBreakDone)==null||p.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}let k=!0,A=null,J=new vm(this.context);this.adsActionDetection.adBreakIsShowing=!0;let ue=C.filter(G=>G.isNative).sort((G,H)=>G.seq-H.seq),N=C.filter(G=>!G.isNative).sort((G,H)=>G.seq-H.seq),O={seq:(m=(f=ue[0])==null?void 0:f.seq)!=null?m:0,provider:"INTERNAL_NATIVE",params:ue},F;for(ue.length>0?F=[O].concat(N):F=N,F=F.sort((G,H)=>G.seq-H.seq).map((G,H)=>iV(UT({},G),{seq:H}));F.length>0;){let G=F.shift(),H=this.providers[G.provider];if(H){let[qt,_h]=yield J.callAdBreakAndContinue(H,t,G,Dl=>{var wa;this.adsIsShowing=Dl,(wa=this.context.eventEmitter)==null||wa.emit("isAdShowing",Dl)});k=qt,A=_h}else k=!0,A={breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"notReady"};if(!k)break}k&&A&&((v=t.adBreakDone)==null||v.call(t,A))}}catch(E){(b=t.adBreakDone)==null||b.call(t,{breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})}finally{this.adsIsShowing=!1,(y=this.context.eventEmitter)==null||y.emit("isAdShowing",!1),this.adsActionDetection.adBreakIsShowing=!1}})}adUnit(t){console.warn("This method has been deprecated. We will not support AdSense AdUnit in the future.")}},zne=ot`
|
|
869
|
+
`,g9=e=>{let{state:t}=e,{afterAd:r,adDismissed:n,adViewed:i,adBreakDone:o,adLoaded:a,adLinkClicked:s,visible:c,src:l}=t,[d,u]=gr(!1),p=m=>{var v,b,y,w;u(!1),c.value=!1,m==="dismiss"?(v=n.value)==null||v.call(n):m==="viewed"&&((b=i.value)==null||b.call(i)),(y=r.value)==null||y.call(r),(w=o.value)==null||w.call(o)},f=()=>{var m;(m=a.value)==null||m.call(a)};return Pi("appsrockets_ad_dismissed",()=>p("dismiss")),Pi("appsrockets_ad_rewarded",()=>p("viewed")),Pi("appsrockets_ad_completed",()=>p("viewed")),Pi("appsrockets_ad_skipped",()=>p("viewed")),Pi("appsrockets_ad_clicked",m=>{var v;return(v=s.value)==null?void 0:v.call(s,m)}),Pi("appsrockets_ad_loaded",()=>u(!0)),c.value?X("div",{className:h9,style:{display:d?"flex":"none"},children:c.value&&X("iframe",{src:l.value,onLoad:f,allowFullScreen:!0,allow:"autoplay",sandbox:"allow-scripts allow-same-origin allow-forms allow-modals allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation allow-top-navigation allow-top-navigation-by-user-activation allow-top-navigation-to-custom-protocols"})}):null};Pm=class{constructor(t,r){Tr(this,"name","APPSROCKETS"),Tr(this,"initialized",!1),Tr(this,"initCompleter",null),Tr(this,"context",void 0),Tr(this,"adsOverlay",null),Tr(this,"adsIsShowing",!1),Tr(this,"lastUnDisplayedAdBreak",null),Tr(this,"state",m9()),Tr(this,"processUrl",(n,i)=>{var o;let a=this.context.getContextInfo(),s=new URL(n),c=new URLSearchParams(s.search);return c.has("joliSource")||c.set("joliSource",a.joliSource),c.get("osType")||c.set("osType",a.osType),c.get("runtimeType")||c.set("runtimeType",a.runtimeType),c.get("mode")||c.set("mode","AFG"),c.get("deviceId")||c.set("deviceId",a.deviceId),c.get("statusBarHeight")||c.set("statusBarHeight",((o=this.context.getWindowInfo().statusBarHeight)!=null?o:0).toString()),c.get("adsType")||c.set("adsType",i),s.search=c.toString(),s.toString()}),this.context=t}init(){return g(this,null,function*(){var t;this.adsOverlay=document.createElement("div"),this.adsOverlay.setAttribute("data-placement-info","afg-appsrockets"),Is(X(g9,{state:this.state}),this.adsOverlay),document.documentElement.appendChild(this.adsOverlay),this.initialized=!0,(t=this.initCompleter)==null||t.call(this)})}adConfig(t){var r;if(this.initialized){(r=t.onReady)==null||r.call(t);return}this.initCompleter=()=>{var n;(n=t.onReady)==null||n.call(t)}}adBreak(t,r){var n,i,o,a,s,c,l,d;if(!this.initialized||!this.adsOverlay||!r.params.url){(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakName:t.type==="preroll"?"":t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"notReady"});return}if(this.adsIsShowing){(i=t.adBreakDone)==null||i.call(t,{breakType:t.type,breakName:t.type==="preroll"?"":t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}let u=f=>{var m,v;(v=(m=this.context).handleLinkClicked)==null||v.call(m,f)},p=t.type==="reward"?"REWARD":"INTERSTITIAL";switch(t.type){case"preroll":{(o=t.adBreakDone)==null||o.call(t,{breakType:t.type,breakName:"",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"start":case"browse":case"next":case"pause":{(a=t.beforeAd)==null||a.call(t);let f=()=>{var b;this.adsIsShowing=!1,(b=t.afterAd)==null||b.call(t)},m=()=>{var b;this.adsIsShowing=!1,(b=t.adBreakDone)==null||b.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"viewed"})},v=()=>{var b;this.adsIsShowing=!1,(b=t.adBreakDone)==null||b.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"noAdPreloaded"})};Ke(()=>{this.adsIsShowing=!0,this.state.afterAd.value=f,this.state.adBreakDone.value=m,this.state.src.value=this.processUrl(r.params.url,p),this.state.adLinkClicked.value=u,this.state.adError.value=v,this.state.visible.value=!0});break}case"reward":{this.lastUnDisplayedAdBreak&&((c=(s=this.lastUnDisplayedAdBreak).adBreakDone)==null||c.call(s,{breakType:this.lastUnDisplayedAdBreak.type,breakName:this.lastUnDisplayedAdBreak.type==="preroll"?"":this.lastUnDisplayedAdBreak.name,breakFormat:this.lastUnDisplayedAdBreak.type==="reward"?"reward":"interstitial",breakStatus:"ignored"}),this.lastUnDisplayedAdBreak=null),(l=t.beforeAd)==null||l.call(t);let f=()=>{var C;this.adsIsShowing=!1,(C=t.afterAd)==null||C.call(t)},m={breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"ignored"},v=()=>{var C;this.adsIsShowing=!1,m.breakStatus="dismissed",(C=t.adDismissed)==null||C.call(t)},b=()=>{var C;this.adsIsShowing=!1,m.breakStatus="viewed",(C=t.adViewed)==null||C.call(t)},y=()=>{var C;this.adsIsShowing=!1,(C=t.adBreakDone)==null||C.call(t,m)},w=()=>{this.adsIsShowing=!1,m.breakStatus="noAdPreloaded"};Ke(()=>{this.state.afterAd.value=f,this.state.adDismissed.value=v,this.state.adViewed.value=b,this.state.adBreakDone.value=y,this.state.adLinkClicked.value=u,this.state.adError.value=w});let E=()=>{var C;if(this.lastUnDisplayedAdBreak=null,!this.adsOverlay){(C=t.adBreakDone)==null||C.call(t,{breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"notReady"});return}this.adsIsShowing=!0,Ke(()=>{this.state.src.value=this.processUrl(r.params.url,p),this.state.visible.value=!0})};this.lastUnDisplayedAdBreak=t,(d=t.beforeReward)==null||d.call(t,E);break}}}},pP=()=>{window.googletag=window.googletag||{cmd:[]},window.googletag.pubadsReady||window.googletag.cmd.push(()=>{window.googletag.enableServices()})};w9=class{constructor(e,t,r){nt(this,"adUnit",void 0),nt(this,"project",void 0),nt(this,"keyValue",void 0),nt(this,"adsContext",null),nt(this,"rewardedSlot",null),nt(this,"rewardedPayload",null),nt(this,"readyEvent",null),nt(this,"withCommand",function(){googletag.cmd.push(...arguments)}),nt(this,"init",()=>{var n;this.rewardedSlot=googletag.defineOutOfPageSlot(this.adUnit,googletag.enums.OutOfPageFormat.REWARDED),this.rewardedSlot&&(this.rewardedSlot.addService(googletag.pubads()),googletag.pubads().addEventListener("rewardedSlotReady",this.handleSlotReady),googletag.pubads().addEventListener("rewardedSlotClosed",this.handleSlotClosed),googletag.pubads().addEventListener("rewardedSlotGranted",this.handleSlotGranted),googletag.pubads().addEventListener("slotRenderEnded",this.handleSlotRenderEnded),this.keyValue&&(Object.keys(this.keyValue).forEach(i=>{var o;(o=this.rewardedSlot)==null||o.setTargeting(i,this.keyValue[i])}),Object.keys(this.keyValue).includes("project")||(n=this.rewardedSlot)==null||n.setTargeting("project",this.project)),googletag.display(this.rewardedSlot))}),nt(this,"destroy",n=>{var i,o;this.rewardedPayload=null,this.readyEvent=null,googletag.pubads().removeEventListener("rewardedSlotReady",this.handleSlotReady),googletag.pubads().removeEventListener("rewardedSlotClosed",this.handleSlotClosed),googletag.pubads().removeEventListener("rewardedSlotGranted",this.handleSlotGranted),googletag.pubads().removeEventListener("slotRenderEnded",this.handleSlotRenderEnded),this.rewardedSlot&&(googletag.destroySlots([this.rewardedSlot]),this.rewardedSlot=null),(o=(i=this.adsContext)==null?void 0:i.adBreakDone)==null||o.call(i,n),n!=="ignored"&&(this.adsContext=null)}),nt(this,"reinit",n=>{this.destroy(n),this.init()}),nt(this,"handleSlotReady",n=>{n.slot===this.rewardedSlot&&(this.readyEvent=n)}),nt(this,"handleSlotClosed",n=>{var i,o;if(this.adsContext&&n.slot===this.rewardedSlot){let a=this.rewardedPayload?"viewed":"dismissed";a==="viewed"?this.adsContext.adViewed():this.adsContext.adDismissed(),(o=(i=this.adsContext).afterAd)==null||o.call(i),this.withCommand(()=>{this.reinit(a)})}}),nt(this,"handleSlotGranted",n=>{this.adsContext&&n.slot===this.rewardedSlot&&(this.rewardedPayload=n.payload)}),nt(this,"handleSlotRenderEnded",n=>{n.slot===this.rewardedSlot&&n.isEmpty&&this.adsContext&&this.withCommand(()=>{this.reinit("frequencyCapped")})}),nt(this,"requestAds",n=>{this.withCommand(()=>{if(this.adsContext){this.destroy("ignored");return}if(this.rewardedSlot||this.init(),this.adsContext=n,!this.rewardedSlot){this.reinit("notReady");return}if(this.readyEvent)this.adsContext.beforeReward(()=>{var i,o,a;(o=(i=this.adsContext)==null?void 0:i.beforeAd)==null||o.call(i),(a=this.readyEvent)==null||a.makeRewardedVisible()});else{let i=o=>{o.slot===this.rewardedSlot&&this.adsContext&&(googletag.pubads().removeEventListener("rewardedSlotReady",i),this.readyEvent=o,this.adsContext.beforeReward(()=>{var a,s,c;(s=(a=this.adsContext)==null?void 0:a.beforeAd)==null||s.call(a),(c=this.readyEvent)==null||c.makeRewardedVisible()}))};googletag.pubads().addEventListener("rewardedSlotReady",i),window.setTimeout(()=>{this.readyEvent||(this.reinit("timeout"),googletag.pubads().removeEventListener("rewardedSlotReady",i))},500)}})}),this.adUnit=e,this.project=t,this.keyValue=r,pP(),this.withCommand(()=>{this.init()})}};Om=class{constructor(t,r,n){var i=this;ht(this,"adUnit",void 0),ht(this,"project",void 0),ht(this,"keyValue",void 0),ht(this,"adsContext",null),ht(this,"gamingInterstitialSlot",null),ht(this,"readyEvent",null),ht(this,"isRetrying",!1),ht(this,"withCommand",function(){googletag.cmd.push(...arguments)}),ht(this,"init",()=>{var o;this.gamingInterstitialSlot=googletag.defineOutOfPageSlot(this.adUnit,googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL),this.gamingInterstitialSlot&&(this.gamingInterstitialSlot.addService(googletag.pubads()),googletag.pubads().addEventListener("gameManualInterstitialSlotReady",this.handleSlotReady),googletag.pubads().addEventListener("gameManualInterstitialSlotClosed",this.handleSlotClosed),this.keyValue&&(Object.keys(this.keyValue).forEach(a=>{var s;(s=this.gamingInterstitialSlot)==null||s.setTargeting(a,this.keyValue[a])}),Object.keys(this.keyValue).includes("project")||(o=this.gamingInterstitialSlot)==null||o.setTargeting("project",this.project)),googletag.display(this.gamingInterstitialSlot))}),ht(this,"destroy",function(o){var a,s;(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1])&&((s=(a=i.adsContext)==null?void 0:a.onEnd)==null||s.call(a,o),o!=="ignored"&&(i.adsContext=null)),googletag.pubads().removeEventListener("gameManualInterstitialSlotReady",i.handleSlotReady),googletag.pubads().removeEventListener("gameManualInterstitialSlotClosed",i.handleSlotClosed),i.gamingInterstitialSlot&&(googletag.destroySlots([i.gamingInterstitialSlot]),i.gamingInterstitialSlot=null,i.readyEvent=null)}),ht(this,"reinit",function(o){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;i.destroy(o,a),i.init()}),ht(this,"handleSlotReady",o=>{this.gamingInterstitialSlot===o.slot&&(this.readyEvent=o)}),ht(this,"handleSlotClosed",o=>{var a,s;this.adsContext&&this.gamingInterstitialSlot===o.slot&&((s=(a=this.adsContext).afterAd)==null||s.call(a),this.withCommand(()=>{this.reinit("viewed")}))}),ht(this,"requestAds",o=>{this.withCommand(()=>{var a,s,c;if(this.adsContext){this.destroy("ignored");return}if(this.gamingInterstitialSlot||this.init(),this.adsContext=o,!this.gamingInterstitialSlot){this.reinit("notReady");return}this.readyEvent?((a=o.beforeAd)==null||a.call(o),this.readyEvent.makeGameManualInterstitialVisible()):((c=(s=this.adsContext).onEnd)==null||c.call(s,"frequencyCapped"),this.adsContext=null,this.isRetrying||(this.isRetrying=!0,window.setTimeout(()=>{this.readyEvent||this.withCommand(()=>{this.reinit("frequencyCapped",!1)}),this.isRetrying=!1},31e3)))})}),pP(),this.adUnit=t,this.project=r,this.keyValue=n,this.withCommand(()=>{this.init()})}};Rm=class{constructor(t,r){Ln(this,"name","GOOGLE_GPT"),Ln(this,"context",void 0),Ln(this,"contextInfo",void 0),Ln(this,"initParams",void 0),Ln(this,"rewardAdManager",void 0),Ln(this,"interstitialManager",void 0),Ln(this,"insertScript",()=>{let n="jolibox-google-gpt",i=document.getElementById(n);i||(i=window.document.createElement("script"),i.id=n,i.async=!0,i.src="https://securepubads.g.doubleclick.net/tag/js/gpt.js",i.crossOrigin="anonymous",document.head.appendChild(i))}),this.context=t,this.contextInfo=this.context.getContextInfo(),this.initParams=r,this.insertScript()}init(){return g(this,null,function*(){let t=this.contextInfo.testAdsMode?"/22639388115/rewarded_web_example":this.initParams.rewardedSlot,r=this.contextInfo.testAdsMode?"/6355419/Travel/Europe/France/Paris":this.initParams.interstitialSlot,n=`minigame-${this.contextInfo.runtimeType==="APP"?"app":"h5"}`;t&&(this.rewardAdManager=new w9(t,n,this.initParams.keyValue)),r&&(this.interstitialManager=new Om(r,n,this.initParams.keyValue))})}adConfig(t,r){}adBreak(t,r){var n,i,o;switch(t.type){case"preroll":{(n=t.adBreakDone)==null||n.call(t,{breakType:"preroll",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"reward":{if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:a=>{var s;(s=t.adBreakDone)==null||s.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:a})}});break}default:{if(!this.interstitialManager){(o=t.adBreakDone)==null||o.call(t,{breakName:t.name,breakType:t.type,breakFormat:"interstitial",breakStatus:"noAdPreloaded"});return}this.interstitialManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,onEnd:a=>{var s;(s=t.adBreakDone)==null||s.call(t,{breakName:t.name,breakType:t.type,breakFormat:"interstitial",breakStatus:a})}});break}}}};Nm=class{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"GAME";um(this,"context",void 0),um(this,"placement","GAME"),um(this,"contextInfo",void 0),this.context=t,this.placement=r,this.contextInfo=this.context.getContextInfo()}getLocation(){let t=new URLSearchParams(window.location.search),r={};return t.forEach((n,i)=>{r[i]=n}),{name:this.placement==="GAME"?"GamePage":"DramaPage",params:r}}getDevice(){var t,r,n,i;return{platform:(t=this.contextInfo.platform)!=null?t:JT.WebSDK,os:this.contextInfo.osType+"_"+this.contextInfo.runtimeType,appVersion:"1.0.0",appId:(r=this.contextInfo.hostAppId)!=null?r:"1",model:(n=this.contextInfo.deviceModel)!=null?n:"UnknownModel",brand:(i=this.contextInfo.deviceBrand)!=null?i:"UnknownBrand",uuid:this.contextInfo.deviceId,jsSdkVersion:"1.0.0",extra:{}}}serialize(t,r){var n;let i={protocolVersion:"1.0.0",events:[{name:t,type:BT.System,location:this.getLocation(),target:null,extra:r,timestamp:Date.now(),userId:(n=this.contextInfo.userId)!=null?n:null}],device:this.getDevice(),project:GT.WebSDK};return CV(i)}};wl=class{constructor(t){lt(this,"context",void 0),lt(this,"adsTrackSerializer",void 0),lt(this,"contextInfo",void 0),this.context=t,this.contextInfo=t.getContextInfo(),this.adsTrackSerializer=new Nm(this.context)}getRequestContextData(t){var r,n;this.contextInfo=this.context.getContextInfo();let{width:i,height:o}=this.context.getWindowInfo();return{report:JSON.stringify(this.adsTrackSerializer.serialize(t,{sessionId:this.contextInfo.sessionId,objectType:this.contextInfo.objectType,objectId:this.contextInfo.objectId,testAdsMode:this.contextInfo.testAdsMode})),osType:this.contextInfo.osType,runtimeType:this.contextInfo.runtimeType,sessionId:this.contextInfo.sessionId,deviceId:this.contextInfo.deviceId,adId:this.contextInfo.adId,deviceModel:(r=this.contextInfo.deviceModel)!=null?r:"UnknownModel",deviceBrand:(n=this.contextInfo.deviceBrand)!=null?n:"UnknownBrand",dimension:{width:i,height:o}}}getRequestBizParams(){return{objectType:this.contextInfo.objectType,objectId:this.contextInfo.objectId}}},Dm=class{constructor(t,r){var n=this;lt(this,"context",void 0),lt(this,"contextInfo",void 0),lt(this,"requestContext",void 0),lt(this,"pendingAFGAdsInfo",{REWARD:Promise.resolve(null),INTERSTITIAL:Promise.resolve(null)}),lt(this,"pendingAFVAdsInfo",Promise.resolve(null)),lt(this,"doFetchAdsInfo",i=>g(this,null,function*(){let o=i==="afv"?"AdsAFVSDKRequest":"AdsAFGSDKAdBreak",a=[];switch(i){case"afv":{a=["REWARD_INTERSTITIAL","REWARD","NATIVE"];break}case"reward":{a=["REWARD_INTERSTITIAL","REWARD","NATIVE"];break}default:{a=["INTERSTITIAL"];break}}let s=i==="afv"?void 0:"cached",{data:c,code:l}=yield this.context.httpClient.post("/api/ads/info",{data:{contextData:this.requestContext.getRequestContextData(o),bizParams:this.requestContext.getRequestBizParams(),adsTypes:a,testAdsMode:this.contextInfo.testAdsMode,name:s}});return l==="SUCCESS"||l==="BYPASS_ADS"?{code:l,data:c}:null})),lt(this,"cacheRewardInfo",()=>{this.pendingAFGAdsInfo.REWARD=this.doFetchAdsInfo("reward").catch(()=>null)}),lt(this,"cacheInterstitialInfo",i=>{this.pendingAFGAdsInfo.INTERSTITIAL=this.doFetchAdsInfo(i).catch(()=>null)}),lt(this,"cacheAFVInfo",()=>{this.pendingAFVAdsInfo=this.doFetchAdsInfo("afv").catch(()=>null)}),lt(this,"cacheNextAFGAdsInfo",i=>g(this,null,function*(){i==="reward"?this.cacheRewardInfo():this.cacheInterstitialInfo(i)})),lt(this,"getAFGAdsInfo",i=>g(this,null,function*(){let o=yield i==="reward"?this.pendingAFGAdsInfo.REWARD:this.pendingAFGAdsInfo.INTERSTITIAL;return this.cacheNextAFGAdsInfo(i),o})),lt(this,"getAFVAdsInfo",function(){return g(this,arguments,function*(){if(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0]){let i=yield n.pendingAFVAdsInfo;return n.cacheAFVInfo(),i}else return n.cacheAFVInfo(),yield n.pendingAFVAdsInfo})}),this.context=t,this.contextInfo=this.context.getContextInfo(),this.requestContext=new wl(t),r!=null&&r.reward&&this.cacheRewardInfo(),r!=null&&r.interstitial&&this.cacheInterstitialInfo("start"),r!=null&&r.afv&&this.cacheAFVInfo()}};N9=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(e)try{e(...r)}catch(i){console.error("[JoliboxSDK] Callback error:",i)}},Sl=class{constructor(t){this.context=t,P9(this,"canIUseHelper",void 0),this.context=t;let{canIUseNative:r}=Pa(()=>this.context.getContextInfo().deviceInfo.nativeSDKVersionCode||1e6,()=>this.context.getContextInfo().deviceInfo.platform||"h5");this.canIUseHelper=r}loadAdsAsync(t){return g(this,null,function*(){try{let{errNo:r,errMsg:n}=yield L("loadAdsAsync",{params:{providers:t.providers}});return r!==0||n.length>0?{code:"FAILURE",message:n||"Failed to load ads"}:{code:"SUCCESS",message:"Ads loaded successfully"}}catch(r){return{code:"FAILURE",message:`Failed to load ads: ${r instanceof Error?r.message:String(r)}`}}})}canIUse(){return pm()&&this.canIUseHelper("loadAdsAsync")&&this.canIUseHelper("showAdAsync")}showAdAsync(t){return g(this,null,function*(){try{let r=yield L("showAdAsync",{params:{providers:t.providers}});if(r.errNo!==0)return{code:"FAILURE",message:r.errMsg||"Failed to show ad"};let n=r.data.UUID;if(t.callbacks){let i=t.timeout!==void 0?t.timeout:-1,o=null,a=()=>{Vh("onAdsStateChange",s),o&&(clearTimeout(o),o=null)},s=c=>{var l;if(c.UUID!==n)return;let d=(l=t.callbacks)==null?void 0:l[c.event];d&&N9(d,c.data),["onAdClosed","onAdError","onAdDismissed"].includes(c.event)&&a()};_e("onAdsStateChange",s),i>0&&(o=setTimeout(()=>{a(),console.warn(`[JoliboxSDK] Event listener for ad ${n} auto-cleaned after ${i}ms timeout`)},i))}return{code:"SUCCESS",message:"Ad shown successfully"}}catch(r){return{code:"FAILURE",message:`Failed to show ad: ${r instanceof Error?r.message:String(r)}`}}})}isAdsReadySync(t){try{let{errNo:r,data:n}=L("isAdsReadySync",{params:{providers:t.providers}});return r!==0||!n?(console.warn("[Jolibox SDK]isAdsReadySync returned an error or no data"),!1):!0}catch(r){return console.warn("[Jolibox SDK]isAdsReadySync invocation failed:",r),!1}}};Lm=class{get isAdsReady(){return this._isAdsReady}constructor(t,r){Pr(this,"providers",void 0),Pr(this,"helper",void 0),Pr(this,"adsContext",null),Pr(this,"_isAdsReady",!1),Pr(this,"init",()=>g(this,null,function*(){this.helper.canIUse()?(yield this.helper.loadAdsAsync({providers:this.providers})).code==="SUCCESS"?this._isAdsReady=!0:this._isAdsReady=!1:this._isAdsReady=!1})),Pr(this,"destroy",n=>{var i,o;this._isAdsReady=!1,(o=(i=this.adsContext)==null?void 0:i.adBreakDone)==null||o.call(i,n),n!=="ignored"&&(this.adsContext=null)}),Pr(this,"reinit",n=>g(this,null,function*(){this.destroy(n),yield this.init()})),Pr(this,"requestAds",(n,i)=>g(this,null,function*(){if(this.adsContext){this.destroy("ignored");return}this.adsContext=n,i&&i.length>0&&(this.providers=i);try{this.isAdsReady?this.showAd():yield this.reinit("frequencyCapped")}catch(o){this.destroy("notReady")}})),Pr(this,"showAd",()=>{if(!this.adsContext){this.destroy("error");return}let n=!1,i=!1;this.adsContext.beforeReward(()=>g(this,null,function*(){var o,a;(a=(o=this.adsContext)==null?void 0:o.beforeAd)==null||a.call(o);let s=l=>{var d,u,p;i||(i=!0,l==="dismissed"&&((d=this.adsContext)==null||d.adDismissed()),(p=(u=this.adsContext)==null?void 0:u.afterAd)==null||p.call(u),this.reinit(l))},c={onAdShow:()=>{},onAdError:()=>{s("error")},onAdRewarded:()=>{var l;n=!0,(l=this.adsContext)==null||l.adViewed()},onAdDismissed:()=>{s(n?"viewed":"dismissed")},onAdClosed:()=>{s(n?"viewed":"dismissed")}};(yield this.helper.showAdAsync({providers:this.providers,callbacks:c})).code!=="SUCCESS"&&this.reinit("noAdPreloaded")}))}),this.providers=r,this.helper=new Sl(t),this.init()}};qm=class{get isAdsReady(){return this._isAdsReady}constructor(t,r){var n=this;Or(this,"providers",void 0),Or(this,"helper",void 0),Or(this,"adsContext",null),Or(this,"_isAdsReady",!1),Or(this,"init",()=>g(this,null,function*(){this.helper.canIUse()&&((yield this.helper.loadAdsAsync({providers:this.providers})).code==="SUCCESS"?this._isAdsReady=!0:this._isAdsReady=!1)})),Or(this,"destroy",function(i){var o,a;let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;n._isAdsReady=!1,s&&((a=(o=n.adsContext)==null?void 0:o.onEnd)==null||a.call(o,i),i!=="ignored"&&(n.adsContext=null))}),Or(this,"reinit",function(o){return g(this,arguments,function*(i){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;n.destroy(i,a),yield n.init()})}),Or(this,"requestAds",(i,o)=>g(this,null,function*(){if(this.adsContext){this.destroy("ignored");return}this.adsContext=i,o&&o.length>0&&(this.providers=o);try{this.isAdsReady?yield this.showAd():yield this.reinit("frequencyCapped")}catch(a){this.destroy("notReady")}})),Or(this,"showAd",()=>g(this,null,function*(){var i,o;if(!this.adsContext){this.destroy("error");return}let a=!1;(o=(i=this.adsContext).beforeAd)==null||o.call(i);let s=l=>{var d,u;a||(a=!0,(u=(d=this.adsContext)==null?void 0:d.afterAd)==null||u.call(d),this.reinit(l))},c={onAdShow:()=>{},onAdError:()=>{s("error")},onAdDismissed:()=>{s("dismissed")},onAdClosed:()=>{s("viewed")}};(yield this.helper.showAdAsync({providers:this.providers,callbacks:c})).code!=="SUCCESS"&&this.reinit("noAdPreloaded")})),this.providers=r,this.helper=new Sl(t),this.init()}};Um=class{constructor(t,r){ca(this,"name","INTERNAL_NATIVE"),ca(this,"context",void 0),ca(this,"rewardAdManager",void 0),ca(this,"interstitialManager",void 0),ca(this,"initProviders",void 0),this.context=t,this.initProviders=r.providers;let n=this.getConfigsByTypes(["REWARD","REWARD_INTERSTITIAL","NATIVE"],r.providers),i=this.getConfigsByTypes(["INTERSTITIAL"],r.providers);n.length>0&&(this.rewardAdManager=new Lm(this.context,n)),i.length>0&&(this.interstitialManager=new qm(this.context,i))}getConfigsByTypes(t,r,n){let i=[];return(n?n.map(o=>r.find(a=>a.provider===o.provider)).filter(o=>!!o):r).forEach(o=>{t.forEach(a=>{let s="";a==="REWARD"&&(s=o.params.adUnitId.reward),a==="REWARD_INTERSTITIAL"&&(s=o.params.adUnitId.rewardInterstitial),a==="INTERSTITIAL"&&(s=o.params.adUnitId.interstitial),a==="NATIVE"&&(s=o.params.adUnitId.nativeAds),s&&i.push({provider:o.provider,params:{placementId:s,adsType:a,extra:o.params.extra}})})}),i}init(){return g(this,null,function*(){})}adConfig(t,r){}adBreak(t,r){var n,i,o;switch(t.type){case"preroll":{(n=t.adBreakDone)==null||n.call(t,{breakType:"preroll",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"reward":{if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}let a=this.getConfigsByTypes(["REWARD","REWARD_INTERSTITIAL","NATIVE"],this.initProviders,r.params);this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:s=>{var c;(c=t.adBreakDone)==null||c.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:s})}},a);break}default:{let a=t;if(!this.interstitialManager){(o=t.adBreakDone)==null||o.call(t,{breakName:a.name,breakType:t.type,breakFormat:"interstitial",breakStatus:"noAdPreloaded"});return}let s=this.getConfigsByTypes(["INTERSTITIAL"],this.initProviders,r.params);this.interstitialManager.requestAds({beforeAd:a.beforeAd,afterAd:a.afterAd,onEnd:c=>{var l;(l=t.adBreakDone)==null||l.call(t,{breakName:a.name,breakType:t.type,breakFormat:"interstitial",breakStatus:c})}},s);break}}}},dm="jolibox-nb-proxy",j9=0;hl=()=>{try{if(window.parent&&window.parent!==window)return B9("GameSDK")}catch(e){}};Mm=class{constructor(){en(this,"adsContext",null),en(this,"_isReady",!1),en(this,"_isAvailable",!1),en(this,"init",()=>g(this,null,function*(){this._isReady=!1;let t=hl();if(t)try{if(this._isAvailable=yield t.isAvailable("rewarded"),console.log("[JoliboxSDK] NewsBreak init isAvailable",this._isAvailable),!this._isAvailable)return;let r=yield t.createRewardAd({platform:"jolibox"});console.log("[JoliboxSDK] NewsBreak init createRewardAd result:",r),this._isReady=r.success&&r.ready}catch(r){this._isReady=!1}})),en(this,"destroy",t=>{var r,n;this._isReady=!1,(n=(r=this.adsContext)==null?void 0:r.adBreakDone)==null||n.call(r,t),t!=="ignored"&&(this.adsContext=null)}),en(this,"reinit",t=>g(this,null,function*(){this.destroy(t),yield this.init()})),en(this,"requestAds",t=>{if(console.log("[JoliboxSDK] NewsBreak newsbreak this.adsContext",this.adsContext),this.adsContext){this.destroy("ignored");return}this.adsContext=t;let r=hl();if(console.log("[JoliboxSDK] NewsBreak newsbreak sdk",r),!r){this.destroy("notReady");return}let n=r.isRewardReady();if(console.log("[JoliboxSDK] NewsBreak sdk.isRewardReady",n),this._isReady||n)this._isReady=!0,this.showAd();else{let i=window.setTimeout(()=>{this._isReady||this.reinit("timeout")},5e3);r.createRewardAd({platform:"jolibox"}).then(o=>{clearTimeout(i),o.success&&o.ready?(this._isReady=!0,this.showAd()):this.reinit("noAdPreloaded")}).catch(()=>{clearTimeout(i),this.reinit("noAdPreloaded")})}}),en(this,"showAd",()=>{if(!this.adsContext){this.destroy("error");return}this.adsContext.beforeReward(()=>g(this,null,function*(){var t,r,n,i,o,a,s,c,l,d,u,p,f,m;(r=(t=this.adsContext)==null?void 0:t.beforeAd)==null||r.call(t);let v=hl();if(!v){(i=(n=this.adsContext)==null?void 0:n.afterAd)==null||i.call(n),this.reinit("error");return}try{let b=yield v.showRewardAd();if(console.log("[JoliboxSDK] NewsBreak showRewardAd result:",b),!b.success){(a=(o=this.adsContext)==null?void 0:o.afterAd)==null||a.call(o),this.reinit("error");return}b.rewardGranted?((s=this.adsContext)==null||s.adViewed(),(l=(c=this.adsContext)==null?void 0:c.afterAd)==null||l.call(c),this.reinit("viewed")):((d=this.adsContext)==null||d.adDismissed(),(p=(u=this.adsContext)==null?void 0:u.afterAd)==null||p.call(u),this.reinit("dismissed"))}catch(b){(m=(f=this.adsContext)==null?void 0:f.afterAd)==null||m.call(f),this.reinit("error")}}))}),this.init()}};Fm=class{constructor(){DT(this,"name","NEWSBREAK"),DT(this,"rewardAdManager",void 0)}init(){return g(this,null,function*(){let t=hl();if(!t){console.warn("[JoliboxSDK] NewsBreak GameSDK is not available on window");return}t.onEnter(),this.rewardAdManager=new Mm})}adConfig(t,r){}adBreak(t,r){var n,i;if(t.type!=="reward"){(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:o=>{var a;(a=t.adBreakDone)==null||a.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:o})}})}};Li=class{constructor(t){if(Ht(this,"context",void 0),Ht(this,"contextInfo",void 0),Ht(this,"providers",{}),Ht(this,"channelPolicy",void 0),Ht(this,"adsActionDetection",void 0),Ht(this,"requestContext",void 0),Ht(this,"adsRequest",void 0),Ht(this,"initialized",!1),Ht(this,"adsIsShowing",!1),Ht(this,"lastAdBreak",void 0),Ht(this,"initializedTimeStamp",Date.now()),t)this.context=t,this.channelPolicy=new bm(this.context),this.adsActionDetection=new ym(this.context),this.contextInfo=this.context.getContextInfo(),this.adsRequest=new Dm(t),this.requestContext=new wl(t);else throw new Error("JoliboxAdsForGame requires a configuration object")}init(t){return g(this,null,function*(){window.adsbygoogle=window.adsbygoogle||[];let{data:r}=yield this.context.httpClient.post("/api/ads/init",{data:{contextData:this.requestContext.getRequestContextData("AdsAFGSDKInit"),bizParams:this.requestContext.getRequestBizParams(),testAdsMode:this.contextInfo.testAdsMode}});if((r==null?void 0:r.length)>0){let n=r.filter(s=>s.isNative),i=r.filter(s=>!s.isNative),o={provider:"INTERNAL_NATIVE",params:{providers:n}},a=i.concat([o]);for(let s of a)switch(s.provider){case"GOOGLE_GPT":{let c=new Rm(this.context,s.params);yield c.init(),this.providers[s.provider]=c;break}case"ADSENSE":case"ADSENSE_ADMOB":{let c=new _m(this.context,s.params);yield c.init(),this.providers[s.provider]=c;break}case"OKSPIN":{let c=new xm(this.context,s.params);yield c.init(),this.providers.OKSPIN=c;break}case"APPSROCKETS":{let c=new Pm(this.context,s.params);yield c.init(),this.providers.APPSROCKETS=c;break}case"ADSENSE_BANNER_AS_AFG":{let c=new Tm(this.context,s.params);yield c.init(),this.providers.ADSENSE_BANNER_AS_AFG=c;break}case"INTERNAL_NATIVE":{let c=new Um(this.context,s.params);yield c.init(),this.providers.INTERNAL_NATIVE=c;break}case"NEWSBREAK":{console.log("[JoliboxSDK] NewsBreak Provider",s);let c=new Fm;yield c.init(),this.providers.NEWSBREAK=c;break}}}this.adsRequest.cacheInterstitialInfo("start"),this.adsRequest.cacheRewardInfo(),this.initialized=!0})}adConfig(t){this.providers.ADSENSE?this.providers.ADSENSE.adConfig(t):window.adsbygoogle.push(t)}adBreak(t){return g(this,null,function*(){var r,n,i,o,a,s,c,l,d,u,p,f,m,v,b,y;let w=Date.now();if(w-this.initializedTimeStamp<3e3){(r=t.adBreakDone)==null||r.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}if(this.lastAdBreak&&w-this.lastAdBreak<500){console.warn("[Jolibox SDK Ads] You can't call adBreak too frequently"),(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}if(this.lastAdBreak=w,this.adsIsShowing){console.warn("[Jolibox SDK Ads] You can't call adBreak while ad is showing"),(i=t.adBreakDone)==null||i.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}if(this.initialized||(yield this.init()),t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){(o=t.adBreakDone)==null||o.call(t,{breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}if(!this.context.checkNetwork()){(a=t.adBreakDone)==null||a.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}try{let E=yield this.adsRequest.getAFGAdsInfo(t.type),C=E==null?void 0:E.data,T=E==null?void 0:E.code;if(T==="BYPASS_ADS"){switch(t.type){case"preroll":{(s=t.adBreakDone)==null||s.call(t,{breakType:t.type,breakFormat:"interstitial",breakStatus:"viewed"});break}case"reward":{t.beforeReward(()=>{var k,A,J,ue;(k=t.beforeAd)==null||k.call(t),(A=t.adViewed)==null||A.call(t),(J=t.afterAd)==null||J.call(t),(ue=t.adBreakDone)==null||ue.call(t,{breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"viewed"})});break}default:{(c=t.beforeAd)==null||c.call(t),(l=t.afterAd)==null||l.call(t),(d=t.adBreakDone)==null||d.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"viewed"});break}}return}if(!C||T!=="SUCCESS"){(u=t.adBreakDone)==null||u.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}else{if(C.length===0){(p=t.adBreakDone)==null||p.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}let k=!0,A=null,J=new vm(this.context);this.adsActionDetection.adBreakIsShowing=!0;let ue=C.filter(G=>G.isNative).sort((G,H)=>G.seq-H.seq),N=C.filter(G=>!G.isNative).sort((G,H)=>G.seq-H.seq),O={seq:(m=(f=ue[0])==null?void 0:f.seq)!=null?m:0,provider:"INTERNAL_NATIVE",params:ue},F;for(ue.length>0?F=[O].concat(N):F=N,F=F.sort((G,H)=>G.seq-H.seq).map((G,H)=>iV(UT({},G),{seq:H}));F.length>0;){let G=F.shift(),H=this.providers[G.provider];if(H){let[qt,_h]=yield J.callAdBreakAndContinue(H,t,G,Dl=>{var wa;this.adsIsShowing=Dl,(wa=this.context.eventEmitter)==null||wa.emit("isAdShowing",Dl)});k=qt,A=_h}else k=!0,A={breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"notReady"};if(!k)break}k&&A&&((v=t.adBreakDone)==null||v.call(t,A))}}catch(E){(b=t.adBreakDone)==null||b.call(t,{breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})}finally{this.adsIsShowing=!1,(y=this.context.eventEmitter)==null||y.emit("isAdShowing",!1),this.adsActionDetection.adBreakIsShowing=!1}})}adUnit(t){console.warn("This method has been deprecated. We will not support AdSense AdUnit in the future.")}},zne=ot`
|
|
870
870
|
${je}
|
|
871
871
|
position: fixed;
|
|
872
872
|
left: 0;
|
|
@@ -911,4 +911,4 @@ If multiple caches share the same key they might "fight" for each other's style
|
|
|
911
911
|
cursor: pointer;
|
|
912
912
|
}
|
|
913
913
|
}
|
|
914
|
-
`});function hP(){let e=new Map,t,r;return{registerRewardHandler(i,o){e.set(i,o)},handleReward(i,...o){return g(this,null,function*(){return yield i.reduce((s,c)=>g(this,null,function*(){let l=yield s;if(l===!0)return!0;mP&&console.log(`handleReward ${c}`);let d=e.get(c),u=d?yield d(...o):l;return mP&&console.log(`handleReward ${c} ${u}`),u}),Promise.resolve(!1))})},registerRewardsFetcher(i){return g(this,null,function*(){t=(...o)=>g(this,null,function*(){try{return yield i(...o)}catch(a){return console.error("getRewardOptions error:",a),["ADS"]}})})},registerRewardFrequencyConfigFetcher(i){return g(this,null,function*(){r=(...o)=>g(this,null,function*(){try{return yield i(...o)}catch(a){return console.error("getRewardOptions error:",a),{joliCoinUseAndCharge:Ar,loginGuide:Cr}}})})},getRewardsTypes(...i){return g(this,null,function*(){return t?yield t(...i):["ADS"]})},getRewardFrequencyConfig(...i){return g(this,null,function*(){return r?yield r(...i):{joliCoinUseAndCharge:Ar,loginGuide:Cr}})}}}var mP,gP=x(()=>{"use strict";V();Be();mP=I.testMode});var Vm,$m,kl,vP=x(()=>{"use strict";R();Vm=class{constructor(t){this.httpClient=t}execute(t,r){return g(this,null,function*(){let n=(r==null?void 0:r.method)||"POST",i=(r==null?void 0:r.body)||{};return n==="GET"?yield this.httpClient.get(t,i):yield this.httpClient.post(t,i)})}extractCacheableData(t){var r,n,i;return{unlockOptions:((r=t.data)==null?void 0:r.unlockOptions)||[],joliCoin:((n=t.extra)==null?void 0:n.joliCoin)||{balance:0,enableAutoDeduct:!1},joliGem:((i=t.extra)==null?void 0:i.joliGem)||{balance:0,enableAutoDeduct:!1}}}mergeData(t,r){return{code:"SUCCESS",message:"success",data:{unlockOptions:t.unlockOptions},extra:{joliCoin:t.joliCoin||{balance:0,enableAutoDeduct:!1},joliGem:t.joliGem||{balance:0,enableAutoDeduct:!1}}}}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:{unlockOptions:t.unlockOptions},extra:{joliCoin:t.joliCoin,joliGem:t.joliGem}}}},$m=class{constructor(t){this.httpClient=t}execute(t,r){return g(this,null,function*(){let n=(r==null?void 0:r.method)||"GET",i=(r==null?void 0:r.body)||{};return n==="GET"?yield this.httpClient.get(t,i):yield this.httpClient.post(t,i)})}extractCacheableData(t){let r=t.data;return P({joliCoinUseAndCharge:r==null?void 0:r.joliCoinUseAndCharge,loginGuide:r==null?void 0:r.loginGuide},r)}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:t}}},kl=class{constructor(t){this.unlockOptionsService=new Ut(new Vm(t),{duration:30*60*1e3,timeout:1e3,keyGenerator:r=>r,consistencyChecker:(r,n)=>r.unlockOptions.length!==n.unlockOptions.length?!1:r.unlockOptions.every((i,o)=>{var s,c;let a=n.unlockOptions[o];return i.type===a.type&&((s=i.joliGemChoice)==null?void 0:s.joliGemQuantity)===((c=a.joliGemChoice)==null?void 0:c.joliGemQuantity)})}),this.globalConfigService=new Ut(new $m(t),{duration:60*60*1e3,timeout:1e3,keyGenerator:r=>r})}getUnlockOptions(){return g(this,arguments,function*(t={}){return yield this.unlockOptionsService.request("/api/games/unlock-options",{endpoint:"/api/games/unlock-options",body:t,method:"POST"})})}getGlobalConfig(){return g(this,null,function*(){return yield this.globalConfigService.request("/api/fe-configs/web-common/global-config",{endpoint:"/api/fe-configs/web-common/global-config",method:"GET"})})}refreshUnlockOptions(){return g(this,arguments,function*(t={}){return yield this.unlockOptionsService.forceRequest("/api/games/unlock-options",{endpoint:"/api/games/unlock-options",body:t,method:"POST"})})}refreshGlobalConfig(){return g(this,null,function*(){return yield this.globalConfigService.forceRequest("/api/fe-configs/web-common/global-config",{endpoint:"/api/fe-configs/web-common/global-config",method:"GET"})})}warmupCache(){return g(this,null,function*(){yield Promise.all([this.unlockOptionsService.warmupCache("/api/games/unlock-options",{endpoint:"/api/games/unlock-options",method:"POST"}),this.globalConfigService.warmupCache("/api/fe-configs/web-common/global-config",{endpoint:"/api/fe-configs/web-common/global-config",method:"GET"})])})}clearAllCache(){this.unlockOptionsService.clearCache(),this.globalConfigService.clearCache()}getCacheStats(){return{unlockOptions:this.unlockOptionsService.getCacheStats(),globalConfig:this.globalConfigService.getCacheStats()}}clearExpiredCache(){this.unlockOptionsService.clearExpiredCache(),this.globalConfigService.clearExpiredCache()}}});function zm(e){return Wm||(Wm=new kl(e)),Wm}var z9,K9,Y9,Wm,Km,Ym,Qm,Xm=x(()=>{"use strict";vP();Be();R();z9=()=>(e,t)=>{let r={SUBSCRIPTION:4,JOLI_GEM:3,JOLI_GEM_ONLY:3,JOLI_COIN:2,JOLI_COIN_ONLY:2,ADS:1};return r[t]-r[e]},K9=["openJolicoinGuide",{method:"getABTest",platforms:["android"],nativeVersionCode:1050100},"userTrackAsync",{method:"openMiniapp",nativeVersionCode:1050100}],Y9=e=>{if(!e.length)return["ADS"];if(e.includes("JOLI_GEM")){if(e.length===1)return["JOLI_GEM_ONLY"];if(e.includes("SUBSCRIPTION")&&e.length===2)return["SUBSCRIPTION","JOLI_GEM_ONLY"]}if(e.includes("JOLI_COIN")){if(e.length===1)return["JOLI_COIN_ONLY"];if(e.includes("SUBSCRIPTION")&&e.length===2)return["SUBSCRIPTION","JOLI_COIN_ONLY"]}return e.sort(z9())},Wm=null;Km=e=>{e.registerRewardsFetcher(t=>g(void 0,null,function*(){var i,o,a,s,c;let r=["ADS"],n=zm(t);try{let l=yield n.getUnlockOptions({});if(l.code!=="SUCCESS")return r;M.emit(Jc,{options:((i=l.data)==null?void 0:i.unlockOptions)||[],userJoliCoin:((o=l.extra)==null?void 0:o.joliCoin)||{balance:0,enableAutoDeduct:!1},userGem:((a=l.extra)==null?void 0:a.joliGem)||{balance:0,enableAutoDeduct:!1}});let d=((c=(s=l.data)==null?void 0:s.unlockOptions)==null?void 0:c.map(u=>u.type))||Array.from(r);return Y9(d)}catch(l){return console.error("getRewardOptions error (cached):",l),r}}))},Ym=e=>{e.registerRewardFrequencyConfigFetcher(t=>g(void 0,null,function*(){var n,i,o,a;let r=zm(t);try{let s=yield r.getGlobalConfig();return M.emit(Jt,{joliCoinUseAndCharge:((n=s.data)==null?void 0:n.joliCoinUseAndCharge)||Ar,loginGuide:((i=s.data)==null?void 0:i.loginGuide)||Cr}),s.data&&we.emit("onGlobalConfigChanged",{globalConfig:s.data}),{joliCoinUseAndCharge:((o=s.data)==null?void 0:o.joliCoinUseAndCharge)||Ar,loginGuide:((a=s.data)==null?void 0:a.loginGuide)||Cr}}catch(s){return console.error("getGlobalConfig error (cached):",s),M.emit(Jt,{joliCoinUseAndCharge:Ar,loginGuide:Cr}),we.emit("onGlobalConfigChanged",{globalConfig:{joliCoinUseAndCharge:Ar,loginGuide:Cr,supportedHostMethods:K9}}),{joliCoinUseAndCharge:Ar,loginGuide:Cr}}}))},Qm=e=>g(void 0,null,function*(){yield zm(e).warmupCache(),console.log("Reward cache warmed up")})});var Zm=x(()=>{"use strict";Xm();Xm()});var yP,bP=x(()=>{"use strict";yP=e=>t=>g(void 0,null,function*(){try{console.log("trigger @jolibox/ads reward",t),yield e.adBreak(t)}catch(r){console.error("-----createAdsRewardHandler error-----",r)}return!0})});var Le,Fi,Tt=x(()=>{"use strict";Be();or();Be();Le=Ge(M,Jc),Fi=(e,t)=>{var n;let r=(n=e.options)==null?void 0:n.some(i=>i.type==="SUBSCRIPTION");return console.log("typeof extraCheck",typeof t,t==null?void 0:t()),r&&(!t||(t==null?void 0:t()))}});var xl,eh=x(()=>{"use strict";xl={JOLI_COIN:{balanceEndpoint:"/api/joli-coin/balance",balanceDetailEndpoint:"/api/joli-coin/balance-detail",unlockEndpoint:"/api/joli-coin/unlock",unlockType:"JOLI_COIN"},GEM:{balanceEndpoint:"/api/joli-gem/balance",balanceDetailEndpoint:"/api/joli-gem/balance-detail",unlockEndpoint:"/api/joli-gem/unlock",unlockType:"GEM"}}});var vt,nn=x(()=>{"use strict";R();vt=K()});function _P(e){return th||(th=new nh(e)),th}var rh,nh,th,ih,qn,ji=x(()=>{"use strict";R();rh=class{constructor(t){this.httpClient=t}execute(t,r){return g(this,null,function*(){let n=(r==null?void 0:r.method)||"GET",i=(r==null?void 0:r.query)||{};return n==="GET"?yield this.httpClient.get(t,{query:i}):yield this.httpClient.post(t,{query:i})})}extractCacheableData(t){var r;return{balance:((r=t.data)==null?void 0:r.balance)||0,timestamp:Date.now()}}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:{balance:t.balance}}}},nh=class{constructor(t){this.balanceService=new Ut(new rh(t),{duration:20*60*1e3,timeout:1e3,keyGenerator:(r,n)=>{let i=n!=null&&n.query?JSON.stringify(n.query):"";return`${r}:${i}`}})}getBalance(t="JOLI_COIN"){return g(this,null,function*(){return(yield this.balanceService.request("/api/joli-coin/balance",{endpoint:"/api/joli-coin/balance",query:{type:t},method:"GET"})).data})}refreshBalance(t="JOLI_COIN"){return g(this,null,function*(){return(yield this.balanceService.forceRequest("/api/joli-coin/balance",{endpoint:"/api/joli-coin/balance",query:{type:t},method:"GET"})).data})}warmupBalance(t="JOLI_COIN"){return g(this,null,function*(){yield this.balanceService.warmupCache("/api/joli-coin/balance",{endpoint:"/api/joli-coin/balance",query:{type:t},method:"GET"})})}clearBalanceCache(){this.balanceService.clearCache()}getBalanceCacheStats(){return this.balanceService.getCacheStats()}clearExpiredCache(){this.balanceService.clearExpiredCache()}},th=null;ih=(e,t="JOLI_COIN")=>g(void 0,null,function*(){return yield _P(e).getBalance(t)}),qn=(e,t="JOLI_COIN")=>g(void 0,null,function*(){let n=yield _P(e).refreshBalance(t);return console.log(`Balance cache refreshed for type: ${t}`),n})});var wP=x(()=>{"use strict";ji()});function ch(e){return oh||(oh=new sh(e)),oh}var ah,sh,oh,lh,Un,Tl,Bi=x(()=>{"use strict";R();ah=class{constructor(t){this.httpClient=t}execute(t,r){return g(this,null,function*(){let n=(r==null?void 0:r.method)||"GET",i=(r==null?void 0:r.query)||{};return n==="GET"?yield this.httpClient.get(t,{query:i}):yield this.httpClient.post(t,{query:i})})}extractCacheableData(t){var r;return{balance:((r=t.data)==null?void 0:r.balance)||0,timestamp:Date.now()}}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:{balance:t.balance}}}},sh=class{constructor(t){this.gemBalanceService=new Ut(new ah(t),{duration:20*60*1e3,timeout:1e3,keyGenerator:(r,n)=>{let i=n!=null&&n.query?JSON.stringify(n.query):"";return`${r}:${i}`}})}getGemBalance(t="GEM"){return g(this,null,function*(){return(yield this.gemBalanceService.request("/api/joli-gem/balance",{endpoint:"/api/joli-gem/balance",query:{type:t},method:"GET"})).data})}refreshGemBalance(t="GEM"){return g(this,null,function*(){return(yield this.gemBalanceService.forceRequest("/api/joli-gem/balance",{endpoint:"/api/joli-gem/balance",query:{type:t},method:"GET"})).data})}warmupGemBalance(t="GEM"){return g(this,null,function*(){yield this.gemBalanceService.warmupCache("/api/joli-gem/balance",{endpoint:"/api/joli-gem/balance",query:{type:t},method:"GET"})})}clearGemBalanceCache(){this.gemBalanceService.clearCache()}getGemBalanceCacheStats(){return this.gemBalanceService.getCacheStats()}clearExpiredCache(){this.gemBalanceService.clearExpiredCache()}},oh=null;lh=(e,t="GEM")=>g(void 0,null,function*(){return yield ch(e).getGemBalance(t)}),Un=(e,t="GEM")=>g(void 0,null,function*(){let n=yield ch(e).refreshGemBalance(t);return console.log(`Gem balance cache refreshed for type: ${t}`),n}),Tl=(e,t="GEM")=>g(void 0,null,function*(){yield ch(e).warmupGemBalance(t),console.log(`Gem balance cache warmed up for type: ${t}`)})});var SP=x(()=>{"use strict";Bi()});var Dt,Mn=x(()=>{"use strict";wP();SP();Dt={JOLI_COIN:{fetchBalance:ih,getQuantity:e=>{var t,r,n;return(n=(r=(t=e==null?void 0:e.options)==null?void 0:t.find(i=>i.type==="JOLI_COIN"))==null?void 0:r.joliCoinChoices[0].joliCoinQuantity)!=null?n:0},getCurrentUser:e=>{var t;return(t=e==null?void 0:e.userJoliCoin)!=null?t:{balance:0,enableAutoDeduct:!1}},createUpdatedUser:(e,t)=>({balance:e,enableAutoDeduct:t}),getUpdateKey:()=>"userJoliCoin",isEnough:(e,t)=>{var r,n;return(n=(r=e==null?void 0:e.options)==null?void 0:r.some(i=>i.type==="JOLI_COIN"&&i.joliCoinChoices.some(o=>{var a;return o.joliCoinQuantity<=((a=t==null?void 0:t.balance)!=null?a:0)})))!=null?n:!1}},JOLI_GEM:{fetchBalance:lh,getQuantity:e=>{var t,r,n,i;return(i=(n=(r=(t=e==null?void 0:e.options)==null?void 0:t.find(o=>o.type==="JOLI_GEM"))==null?void 0:r.joliGemChoice)==null?void 0:n.joliGemQuantity)!=null?i:0},getCurrentUser:e=>{var t;return(t=e==null?void 0:e.userGem)!=null?t:{balance:0,enableAutoDeduct:!1}},createUpdatedUser:(e,t)=>({balance:e,enableAutoDeduct:t}),getUpdateKey:()=>"userGem",isEnough:(e,t)=>{var n,i,o;let r=e==null?void 0:e.options.find(a=>a.type==="JOLI_GEM");return r?((i=(n=r.joliGemChoice)==null?void 0:n.joliGemQuantity)!=null?i:0)<=((o=t==null?void 0:t.balance)!=null?o:0):!1}}}});var va,Nr,uh=x(()=>{"use strict";nn();Tt();or();Be();Be();Mn();va=(e,t,r)=>{let{showUnlockWithCurrencyModal:n}=r;vt.registerCommand(`Rewards.${e}.useJolicoin`,()=>g(void 0,null,function*(){let i=yield Le.getData(),o=Dt[t],a=o.getCurrentUser(i),s=o.getQuantity(i),c=!!(a!=null&&a.enableAutoDeduct);return console.log("-----unlockOptions usemodal-----",i,c,s),(yield n({enableAutoDeduct:c,userCurrency:a,quantity:s,currency:t}))!=="CONFIRM"?{result:"FAILED"}:{result:"SUCCESS"}}))},Nr=(e,t)=>r=>g(void 0,null,function*(){let n=Ge(M,xn);return M.emit(Vc,e,{enableAutoDeduct:r.enableAutoDeduct,userCurrency:r.userCurrency,quantity:r.quantity,currency:r.currency,confirmButtonText:t.confirmButtonText,cancelButtonText:t.cancelButtonText}),(yield n.getFreshData()).useModalResult})});var ya,Dr,IP=x(()=>{"use strict";nn();Tt();Be();or();Be();Mn();Bi();ji();ya=(e,t,r)=>{let{httpClient:n,initiateAndAwaitPayment:i}=r;vt.registerCommand(`Rewards.${e}.usePayment`,()=>g(void 0,null,function*(){var p;let o=yield Le.getData(),a=Dt[t],s=yield a.fetchBalance(n),c=a.getQuantity(o),l=a.getCurrentUser(o),d=a.createUpdatedUser((p=s==null?void 0:s.balance)!=null?p:0,l.enableAutoDeduct),u=a.getUpdateKey();if(Le.updateData({[u]:d}),console.log("-----unlockOptions payment-----",o,d,c,t),!a.isEnough(o,d)){let f=yield i({userCurrency:d,currencyQuantity:c,currency:t});return t==="JOLI_GEM"?Un(n):qn(n),{result:f==="SUCCESS"?"SUCCESS":"FAILED"}}return{result:"CONTINUE"}}))},Dr=(e,t)=>r=>g(void 0,null,function*(){let n=Ge(M,Gt);return M.emit(Hc,e,{userCurrency:r.userCurrency,quantity:r.currencyQuantity,currency:r.currency,enableAutoDeduct:r.userCurrency.enableAutoDeduct,confirmButtonText:t.confirmButtonText,cancelButtonText:t.cancelButtonText}),(yield n.getFreshData()).paymentResult})});var dh,Lr,EP=x(()=>{"use strict";V();nn();or();Be();Be();R();Tt();Mn();dh=(e,t,r)=>{let{showUnloginModal:n,httpClient:i}=r;vt.registerCommand(`Rewards.${e}.useUnloginModal`,()=>g(void 0,null,function*(){var s,c,l;let o=(s=I.hostUserInfo)==null?void 0:s.isLogin,a=yield Le.getData();if(console.log("-----isLogin-----",!!o),!o){let d=yield n(t);if(console.log("-----unloginModalResult-----",d),d.result=="FAILED"||d.result=="CANCEL")return{result:"FAILED"};let{isFirstLogin:u,claimedRewardValue:p}=(c=d.rewards)!=null?c:{};if(d.result=="SUCCESS"){u&&p&&(yield Ra(3e3));let f=Dt[t],m=yield f.fetchBalance(i),v=f.getQuantity(a),b=f.getCurrentUser(a),y=f.createUpdatedUser((l=m==null?void 0:m.balance)!=null?l:0,b.enableAutoDeduct),w=f.getUpdateKey();if(Le.updateData({[w]:y}),y.balance>=v)return{result:"SUCCESS"}}}return{result:"CONTINUE"}}))},Lr=(e,t)=>r=>g(void 0,null,function*(){let n=Ge(M,Er);return M.emit($c,e,{confirmButtonText:t.confirmButtonText,cancelButtonText:t.cancelButtonText,currency:r}),yield n.getFreshData()})});var Fn=x(()=>{"use strict";uh();IP();EP()});var X9,Pl,ph=x(()=>{"use strict";V();R();eh();Fn();nn();ji();Mn();Tt();X9=(e,t,r,{handlers:{handleUnlockSuccess:n,handleUnlockFailed:i,unlockOptionsHandler:o,initiateAndAwaitPayment:a,showUnlockWithCurrencyModal:s,showUnloginModal:c,hasSubscription:l}})=>{ya(e,"JOLI_COIN",{httpClient:t,initiateAndAwaitPayment:a}),va(e,"JOLI_COIN",{showUnlockWithCurrencyModal:s});let d=[`Rewards.${e}.usePayment`,`Rewards.${e}.useJolicoin`];return u=>g(void 0,null,function*(){var p,f,m,v;try{let b=yield o.getData();if(Fi(b,l)){let C=Dt.JOLI_COIN,T=yield C.fetchBalance(t),k=C.getCurrentUser(b),A=C.createUpdatedUser((p=T==null?void 0:T.balance)!=null?p:0,k.enableAutoDeduct);if(!C.isEnough(b,A))return i==null||i(u),!1}else{let C=!0;for(let T of d){let k=yield vt.executeCommand(T);if(C=C&&k.result!=="FAILED",k.result!=="CONTINUE")break}if(!C)return i==null||i(u),!1}let w=xl[r],E=yield t.post(w.unlockEndpoint,{data:{type:"GAME_REWARD",reqId:`${Hn()}-${I.mpType}-${Date.now()}`,gameInfo:{gameId:I.mpId}}});if(console.log("-----unlockWithCurrency request result-----",E),E.code=="SUCCESS"){try{(m=u.adBreakDone)==null||m.call(u,{breakType:u.type,breakName:"name"in u&&(f=u.name)!=null?f:"",breakFormat:"reward",breakStatus:"viewed"}),"adViewed"in u&&((v=u.adViewed)==null||v.call(u)),qn(t)}catch(C){console.error("-----unlockWithJolicoin adBreakDone error-----",C)}return n==null||n({quantity:E.data.quantity,balance:E.data.balance}),!0}return i==null||i(u),!1}catch(b){if(console.info("JolicoinRewardHandler error:",b),b instanceof Error&&b.message=="CANCEL")throw b;return i==null||i(u),!1}finally{o.clearCache()}})},Pl=(e,t,r)=>X9(e,t,"JOLI_COIN",r)});var AP,CP=x(()=>{"use strict";Tt();ph();Fn();AP=(e,{onUnlockSuccess:t,onUnlockFailed:r,hasSubscription:n})=>{let i=()=>{r==null||r()},o=Nr("ADS-JOLI_COIN",{confirmButtonText:"jolicoin.useJolicoin",cancelButtonText:"jolicoin.noWatchAds"}),a=Dr("ADS-JOLI_COIN",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noWatchAds"}),s=Lr("ADS-JOLI_COIN",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noWatchAds"});return Pl("ADS-JOLI_COIN",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:i,unlockOptionsHandler:Le,initiateAndAwaitPayment:a,showUnlockWithCurrencyModal:o,showUnloginModal:s,hasSubscription:n}})}});var kP,xP=x(()=>{"use strict";ph();Tt();Fn();kP=(e,{onUnlockSuccess:t,onUnlockFailed:r,hasSubscription:n})=>{let i=l=>{var d;r==null||r(),(d=l.adBreakDone)==null||d.call(l,{breakType:l.type,breakFormat:l.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})},o=Nr("JOLI_COIN",{confirmButtonText:"jolicoin.useJolicoin",cancelButtonText:"jolicoin.noThanks"}),a=Dr("JOLI_COIN",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noThanks"}),s=Lr("JOLI_COIN",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noThanks"});return Pl("JOLI_COIN",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:i,unlockOptionsHandler:Le,initiateAndAwaitPayment:a,showUnlockWithCurrencyModal:o,showUnloginModal:s,hasSubscription:n}})}});var Ol,fh=x(()=>{"use strict";V();R();eh();Fn();uh();nn();Bi();Mn();Tt();Ol=(e,t,{handlers:{handleUnlockSuccess:r,handleUnlockFailed:n,unlockOptionsHandler:i,initiateAndAwaitPayment:o,showUnlockWithCurrencyModal:a,showUnloginModal:s,hasSubscription:c}})=>{dh(e,"JOLI_GEM",{httpClient:t,showUnloginModal:s}),ya(e,"JOLI_GEM",{httpClient:t,initiateAndAwaitPayment:o}),va(e,"JOLI_GEM",{showUnlockWithCurrencyModal:a});let l=[`Rewards.${e}.usePayment`,`Rewards.${e}.useJolicoin`];return d=>g(void 0,null,function*(){var u,p,f,m;try{let v=yield i.getData(),b=Fi(v,c);if(console.log("[GemHandler] supportSubscription",b,v),b){let E=Dt.JOLI_GEM,C=yield E.fetchBalance(t),T=E.getCurrentUser(v),k=E.createUpdatedUser((u=C==null?void 0:C.balance)!=null?u:0,T.enableAutoDeduct);if(!E.isEnough(v,k))return n==null||n(d),!1}else{let E=!0;for(let C of l){let T=yield vt.executeCommand(C);if(console.log("[GemHandler] command result",T,C),E=E&&T.result!=="FAILED",T.result!=="CONTINUE")break}if(!E)return n==null||n(d),!1}let y=xl.GEM,w=yield t.post(y.unlockEndpoint,{data:{type:"GAME_REWARD",reqId:`${Hn()}-${I.mpType}-${Date.now()}`,gameInfo:{gameId:I.mpId}}});if(console.log("-----unlockWithGem request result-----",w),w.code=="SUCCESS"){try{(f=d.adBreakDone)==null||f.call(d,{breakType:d.type,breakName:"name"in d&&(p=d.name)!=null?p:"",breakFormat:"reward",breakStatus:"viewed"}),"adViewed"in d&&((m=d.adViewed)==null||m.call(d)),Un(t)}catch(E){console.error("-----unlockWithGem adBreakDone error-----",E)}return r==null||r({quantity:w.data.quantity,balance:w.data.balance}),!0}return n==null||n(d),!1}catch(v){if(console.info("GemRewardHandler error:",v),v instanceof Error&&v.message=="CANCEL")throw v;return n==null||n(d),!1}finally{i.clearCache()}})}});var TP,PP=x(()=>{"use strict";Tt();fh();Fn();TP=(e,{onUnlockSuccess:t,onUnlockFailed:r,hasSubscription:n})=>{let i=()=>{r==null||r()},o=Nr("ADS-JOLI_GEM",{confirmButtonText:"joligem.useJolicoin",cancelButtonText:"jolicoin.noWatchAds"}),a=Dr("ADS-JOLI_GEM",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noWatchAds"}),s=Lr("ADS-JOLI_GEM",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noWatchAds"});return Ol("ADS-JOLI_GEM",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:i,unlockOptionsHandler:Le,initiateAndAwaitPayment:a,showUnlockWithCurrencyModal:o,showUnloginModal:s,hasSubscription:n}})}});var OP,RP=x(()=>{"use strict";fh();Tt();Fn();OP=(e,{onUnlockSuccess:t,onUnlockFailed:r,hasSubscription:n})=>{let i=l=>{var d;r==null||r(),(d=l.adBreakDone)==null||d.call(l,{breakType:l.type,breakFormat:l.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})},o=Nr("JOLI_GEM",{confirmButtonText:"joligem.useJolicoin",cancelButtonText:"jolicoin.noThanks"}),a=Dr("JOLI_GEM",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noThanks"}),s=Lr("JOLI_GEM",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noThanks"});return Ol("JOLI_GEM",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:i,unlockOptionsHandler:Le,initiateAndAwaitPayment:a,showUnlockWithCurrencyModal:o,showUnloginModal:s,hasSubscription:n}})}});var NP,DP,mh=x(()=>{"use strict";Mn();nn();Tt();or();Be();Be();NP=e=>{let{showSubscriptionModal:t}=e;vt.registerCommand("Rewards.subscription",()=>g(void 0,null,function*(){var s,c;let r=yield Le.getData(),n=(c=(s=r==null?void 0:r.options)==null?void 0:s.find(l=>l.type==="JOLI_GEM"))==null?void 0:c.type,i=Dt[n?"JOLI_GEM":"JOLI_COIN"],o=i.getCurrentUser(r);return i.isEnough(r,o)?{result:"FAILED"}:{result:(yield t())==="SUCCESS"?"SUCCESS":"FAILED"}}))},DP=e=>()=>g(void 0,null,function*(){let t=Ge(M,Tn);return M.emit(Wc,e),(yield t.getFreshData()).result})});var LP=x(()=>{"use strict";mh()});var qP,UP=x(()=>{"use strict";nn();LP();V();Tt();ji();Bi();qP=(e,t,{handlers:{handleSubSuccess:r,handleSubFailed:n,unlockOptionsHandler:i,showSubscriptionModal:o,hasSubscription:a}})=>{NP({showSubscriptionModal:o});let s=["Rewards.subscription"];return c=>g(void 0,null,function*(){var l,d,u,p,f,m;try{let v=yield i.getData();if(!Fi(v,a))return!1;let y=!0;for(let w of s){let E=yield vt.executeCommand(w);if(y=y&&E.result!=="FAILED",E.result!=="CONTINUE")break}if(qn(t),Un(t),console.log("-----unlockWithSubscription result-----",y),y){try{(d=c.adBreakDone)==null||d.call(c,{breakType:c.type,breakName:"name"in c&&(l=c.name)!=null?l:"",breakFormat:c.type==="reward"?"reward":"interstitial",breakStatus:"viewed"}),"adViewed"in c&&((u=c.adViewed)==null||u.call(c)),(m=(f=I).onEnvConfigChanged)==null||m.call(f,{hostUserInfo:B(P({},(p=I.hostUserInfo)!=null?p:{isLogin:!1}),{isSubUser:!0})})}catch(w){console.error("-----unlockWithSubscription adBreakDone error-----",w)}return r==null||r(),!0}return n==null||n(c),!1}catch(v){if(console.info("SubscriptionRewardHandler error:",v),v instanceof Error&&v.message=="CANCEL")throw v;return n==null||n(c),!1}finally{}})}});var MP,FP=x(()=>{"use strict";Tt();UP();mh();MP=(e,{onSubSuccess:t,onSubFailed:r,hasSubscription:n})=>{let i=()=>{r==null||r()},o=DP("SUBSCRIPTION");return qP("SUBSCRIPTION",e,{handlers:{handleSubSuccess:t,handleSubFailed:i,unlockOptionsHandler:Le,showSubscriptionModal:o,hasSubscription:n}})}});var Lt,jP=x(()=>{"use strict";gP();Zm();bP();CP();xP();PP();RP();FP();ji();Bi();Lt=hP();Km(Lt);Ym(Lt)});var Rl,Z9,lr,eW,ba,tW,BP,GP,rW,nW,hh,iW,oW,aW,JP=x(()=>{"use strict";R();Je();ir();sT();im();Hm();bt();V();dt();ce();jP();os();Zm();Rl=K(),Z9=()=>{let{data:e}=L("getNetworkStatusSync");return!!(e!=null&&e.isConnected)},lr={get:(e,t)=>Y(e,P({method:"GET",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data),post:(e,t)=>Y(e,P({method:"POST",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data)},eW={httpClient:lr,checkNetwork:Z9,track:j,eventEmitter:dn,getWindowInfo:()=>({width:window.innerWidth*window.devicePixelRatio,height:window.innerHeight*window.devicePixelRatio,statusBarHeight:30}),handleLinkClicked:e=>{window.open(e,"_blank")},getContextInfo:()=>{var e,t,r,n,i,o,a,s,c,l;return{hostAppId:(t=(e=I.hostInfo)==null?void 0:e.aid)!=null?t:"1",deviceId:(r=I.deviceInfo.did)!=null?r:"",adId:(n=I.deviceInfo.adId)!=null?n:"",sessionId:(i=I.sessionId)!=null?i:"",userId:(a=(o=I.hostUserInfo)==null?void 0:o.uid)!=null?a:"",objectType:"GAME",objectId:I.mpId,testAdsMode:I.testAdsMode,channel:(s=I.joliSource)!=null?s:"",deviceBrand:I.deviceInfo.brand,deviceModel:I.deviceInfo.model,osType:I.platform==="android"?"ANDROID":I.platform==="ios"?"IOS":"PC",runtimeType:"APP",platform:1e3,joliSource:(c=I.joliSource)!=null?c:"",deviceInfo:{platform:I.platform,nativeSDKVersionCode:(l=I.sdkInfo.nativeSDKVersionCode)!=null?l:0}}}},ba=new Li(eW);Lt.getRewardFrequencyConfig(lr).then(e=>{console.log("getRewardFrequencyConfig",e)});Lt.registerRewardHandler("ADS",yP(ba));Lt.registerRewardHandler("JOLI_COIN",AP(lr,{onUnlockSuccess:e=>{BP(e),j("jolicoin_unlock_success",{quantity:e.quantity})},onUnlockFailed:()=>{console.log("onUnlockFailed")},hasSubscription:()=>ve("invokeSubscriptionPanelSync")}));Lt.registerRewardHandler("JOLI_COIN_ONLY",kP(lr,{onUnlockSuccess:e=>{BP(e),j("jolicoin_unlock_success",{quantity:e.quantity,isOnly:!0})},onUnlockFailed:()=>{console.log("onUnlockFailed")},hasSubscription:()=>ve("invokeSubscriptionPanelSync")}));Lt.registerRewardHandler("JOLI_GEM",TP(lr,{onUnlockSuccess:e=>{GP(e),j("gem_unlock_success",{quantity:e.quantity})},hasSubscription:()=>ve("invokeSubscriptionPanelSync")}));Lt.registerRewardHandler("JOLI_GEM_ONLY",OP(lr,{onUnlockSuccess:e=>{GP(e),j("gem_unlock_success",{quantity:e.quantity,isOnly:!0})},hasSubscription:()=>ve("invokeSubscriptionPanelSync")}));tW=()=>{j("subscription_unlock_success",{})};Lt.registerRewardHandler("SUBSCRIPTION",MP(lr,{onSubSuccess:tW.bind(void 0),hasSubscription:()=>ve("invokeSubscriptionPanelSync")}));BP=e=>{let{quantity:t}=e,r=`{slot-coin} ${t} {slot-i18n-jolicoin.coinUsed}`;Ir(r,{customStyle:{mark:{marginRight:"8px"},base:{with:"auto"}},i18nParams:{text:"Jolicoin Used"}})};Qm(lr);Tl(lr);dn.on("isAdShowing",e=>{xi("JOLIBOX_ADS_EVENT",{isAdShowing:e})});GP=e=>{let{quantity:t}=e,r=`{slot-correct} ${t*-1} {slot-gem}`;Ir(r,{customStyle:{mark:{marginRight:"8px"},base:{"font-size":"25px","font-weight":"700","line-height":"18px"},span:{width:"auto",minWidth:"fit-content",maxWidth:"60px",textAlign:"center",padding:"0 2px",lineHeight:"25px"},gem:{transform:"translateY(-2px)",width:"28px",height:"28px"}}})},rW=Q("adInit",{implement:e=>{ba.init(e)}}),nW=Q("adConfig",{implement:e=>{ba.adConfig(e)}}),hh=!1,iW=e=>{var t,r,n;(r=e.adBreakDone)==null||r.call(e,{breakType:e.type,breakName:"name"in e&&(t=e.name)!=null?t:"",breakFormat:e.type==="reward"?"reward":"interstitial",breakStatus:"viewed"}),"adViewed"in e&&((n=e.adViewed)==null||n.call(e))},oW=Q("adBreak",{implement:e=>{var r;if((r=I.hostUserInfo)==null?void 0:r.isSubUser){iW(e);return}if(e.type==="reward"){if(hh)return;hh=!0,Lt.getRewardsTypes(lr).then(n=>{Lt.handleReward(n,e).catch(i=>{var o;console.info("handleReward failed in native",i),(o=e.adBreakDone)==null||o.call(e,{breakType:e.type,breakFormat:e.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})}).finally(()=>{hh=!1})})}else ba.adBreak(e)}}),aW=Q("adUnit",{implement:e=>{ba.adUnit(e)}});Rl.registerCommand("AdsSDK.init",rW);Rl.registerCommand("AdsSDK.adConfig",nW);Rl.registerCommand("AdsSDK.adBreak",oW);Rl.registerCommand("AdsSDK.adUnit",aW);D("AdsSDK.init",{version:"1.0.0"});D("AdsSDK.adConfig",{version:"1.0.0"});D("AdsSDK.adBreak",{version:"1.0.0"});D("AdsSDK.adUnit",{version:"1.0.0"})});var _a,sW,cW,lW,uW,dW,HP=x(()=>{"use strict";R();ce();Je();V();_a=K(),sW=Q("openSchemaSync",{paramsSchema:S.tuple(S.string()),implement:e=>{let t=e;e.match(/^https?:\/\//)||(t=`https://${I.mpId}.app.jolibox.com${e.startsWith("/")?"":"/"}${e}`);let r=L("openSchemaSync",{schema:t});if(r.errNo!==0)throw new Vt(r.errMsg,r.errNo)}}),cW=Q("openPageSync",{paramsSchema:S.tuple(S.string()),implement:e=>{let{errNo:t,errMsg:r,data:n}=L("openPageSync",{url:e});if(t!==0||!n)throw new Vt(r,t);return{webviewId:n.webviewId}}}),lW=Q("closePageSync",{paramsSchema:S.tuple(S.number()),implement:e=>{let{errNo:t,errMsg:r}=L("closePageSync",{webviewId:e});if(t!==0)throw new Vt(r,t)}}),uW=Q("interceptSystemExitSync",{paramsSchema:S.tuple(S.boolean()),implement:e=>{we.emit("onInterceptSystemExit",{intercept:e}),we.emit("onInterceptBackPress",{intercept:e})}}),dW=Q("navigateToNativePage",{paramsSchema:S.tuple(S.enum("openHistory","openDiscover","openDiscover","openGame","openDrama","openTopup","openFeed","openRewards"),S.object()),implement:(e,t)=>{L("callHostMethodAsync",{method:e,params:P({},t)})}});_a.registerCommand("RouterSDK.openSchema",sW);_a.registerCommand("RouterSDK.openPage",cW);_a.registerCommand("RouterSDK.closePage",lW);_a.registerCommand("RouterSDK.interceptSystemExit",uW);_a.registerCommand("RouterSDK.navigateToNativePage",dW);D("router.openSchema",{version:"1.1.10"});D("router.openPage",{version:"1.1.10"});D("router.closePage",{version:"1.1.10"});D("router.interceptSystemExit",{version:"1.1.18"});D("router.navigateToNativePage",{version:"1.1.19"})});function mW(e){sn("cpLoadProgressEvent",{progress:e},I.webviewId,!0),xi("CP_LOAD_PROGRESS",{progress:e})}var vh,pW,Nl,gh,VP,fW,hW,gW,$P=x(()=>{"use strict";R();Je();ce();V();bt();im();vh=K(),pW=Q("onLoadFinished",{implement:()=>{sn("cpLoadFinishEvent",{},I.webviewId,!0),xi("CP_LOAD_FINISH",{duration:performance.now()}),j("loadFinished",{duration:performance.now()})}}),Nl=null,gh=!1,VP=0,fW=200;hW=Q("onLoadProgress",{paramsSchema:S.tuple(S.number()),implement:e=>{Nl=e,gh||(gh=!0,requestAnimationFrame(function t(){let r=Date.now();r-VP>=fW?(Nl!==null&&(mW(Nl),VP=r,Nl=null),gh=!1):requestAnimationFrame(t)}))}}),gW=Q("onGameTTI",{paramsSchema:S.tuple(S.number().optional()),implement:()=>{sn("cpGameTTIEvent",{duration:performance.now()},I.webviewId,!0),xi("CP_GAME_TTI",{duration:performance.now()}),j("gameTTI",{duration:performance.now()})}});vh.registerCommand("RuntimeSDK.loadFinishedEvent",pW);vh.registerCommand("RuntimeSDK.loadProgressEvent",hW);vh.registerCommand("RuntimeSDK.gameTTIEvent",gW)});var vW,yW,bW,WP=x(()=>{"use strict";R();Je();V();vW=K(),yW="isNativeSupport",bW=Q(yW,{paramsSchema:S.tuple(S.object({version:S.string()})),implement:e=>{let t=I.sdkInfo.nativeSDKVersionCode,{version:r}=e;return r?{code:"SUCCESS",data:cg(xu(t!=null?t:0),r,">=")}:{code:"FAILURE",message:"[Jolibox SDK] api or versionCode is required",data:!1}}});vW.registerCommand("API.isNativeSupport",bW);D("isNativeSupport",{version:"1.1.46"})});var KP=h(yh=>{"use strict";Je();ce();R();R();V();var zP=K(),_W=$("callHostMethod",{paramsSchema:S.tuple(S.object({method:S.string(),params:S.object().optional().default({})})),implement:r=>g(yh,[r],function*({method:e,params:t}){if(!ve(e))throw new Vt("Method not supported",10001);let{errNo:n,errMsg:i,data:o}=yield L("callHostMethodAsync",{method:e,params:P({},t)});if(n!==0)throw new Vt(i,n);let c=o,{callHostMethodId:a}=c,s=Qe(c,["callHostMethodId"]);return P({},s)})});zP.registerCommand("API.callHostMethod",_W);D("callHostMethod",{version:"1.1.49"});var wW=$("userTrackAsync",{paramsSchema:S.tuple(S.object({event:S.string(),eventType:S.number(),params:S.object().optional().default({})})),implement:n=>g(yh,[n],function*({event:e,eventType:t,params:r}){if(!ve("userTrackAsync"))throw new Vt("Method not supported",10001);let{errNo:i,errMsg:o}=yield L("trackAsync",{event:e,eventType:t,data:P({},r),webviewId:I.webviewId});if(i!==0)throw new Vt(o,i)})});zP.registerCommand("API.track",wW);D("track",{version:"1.1.53"})});var XP=h(on=>{"use strict";R();Je();zf();Ur();nm();ce();var jn=K(),YP=Zc(),SW=$("purchaseGem",{paramsSchema:S.tuple(S.object({productId:S.string()})),implement:e=>g(on,null,function*(){var r,n;let t=yield YP.purchase(e.productId);if(t.code!=="SUCCESS")throw Ce({code:-1,msg:"[JoliboxSDK]: purchase gem failed: "+t.message});return{totalAmount:(n=(r=t.data)==null?void 0:r.totalAmount)!=null?n:""}})}),IW=$("getGemProducts",{paramsSchema:S.tuple(),implement:()=>g(on,null,function*(){var t,r;let e=(r=(t=yield YP.getProductsInfoWithBalance())==null?void 0:t.paymentChoices)!=null?r:[];return console.info("choices",e),{products:e.map(n=>{var i;return{productId:n.productId,totalAmountStr:(i=n.totalAmountStr)!=null?i:"",quantity:n.quantity}})}})}),EW=$("getSubscriptionPlans",{paramsSchema:S.tuple(),implement:()=>g(on,null,function*(){let e=yield Dn.getSubInfo();if(console.log("[PaymentAPI] getSubscriptionPlans result",e),!e)throw Ce({code:-1,msg:"[JoliboxSDK]: get subscription plans failed"});return{plans:e}})}),AW=$("flushSubInfoCache",{paramsSchema:S.tuple(),implement:()=>g(on,null,function*(){yield Dn.updateAllNativePriceCache()})}),QP=e=>g(on,null,function*(){var a;let{productId:t}=e,r=e.appStoreProductId,n=e.appStoreProductId,i=t;if(!e.appStoreProductId){let s=yield Dn.getTierByProductId(e.productId);if(!s)throw Ce({code:-1,msg:"[JoliboxSDK]: product not found"});r=s.basePlanId,n=s.appStoreProductId,i=s.nativeProductId}if(!r||!n||!i)throw Ce({code:-1,msg:"[JoliboxSDK]: product not found"});let o=yield Dn.subscribe({basePlanId:r,nativeProductId:i,appStoreProductId:n});return{result:o.result,subPlanId:o.subPlanId,errMsg:(a=o.message)!=null?a:""}}),CW=$("subscribe",{paramsSchema:S.tuple(S.object({productId:S.string(),appStoreProductId:S.string().optional()})),implement:QP}),kW=$("subscribeSpin",{paramsSchema:S.tuple(S.object({appStoreProductId:S.string().optional()})),implement:e=>g(on,null,function*(){return QP(B(P({},e),{productId:"jolibox_app_spin_sub"}))})});jn.registerCommand("PaymentSDK.purchaseGem",SW);jn.registerCommand("PaymentSDK.getGemProducts",IW);jn.registerCommand("PaymentSDK.getSubscriptionPlans",EW);jn.registerCommand("PaymentSDK.subscribe",CW);jn.registerCommand("PaymentSDK.subscribeSpin",kW);var xW=$("getSpinSubscriptionPrice",{paramsSchema:S.tuple(S.object({appStoreProductId:S.string()})),implement:e=>g(on,null,function*(){let{data:t}=yield de("requestSubscriptionPlansAsync",{appStoreProductIds:[e.appStoreProductId],type:"SPIN"});if(!t)throw Ce({code:-1,msg:"[JoliboxSDK]: get spin subscription price failed"});return{plans:Object.values(t).map(n=>{var i,o;return{basePlanId:n.basePlanId,productId:n.productId,formattedPrice:n.pricing.formattedPrice,originalPrice:n.pricing.originalPrice,trialDay:(o=(i=n.trial)==null?void 0:i.duration)!=null?o:0}})}})});jn.registerCommand("PaymentSDK.flushSubInfoCache",AW);jn.registerCommand("PaymentSDK.getSpinSubscriptionPrice",xW);D("payment.purchaseGem",{version:"1.2.9"});D("payment.getGemProducts",{version:"1.2.9"});D("payment.getSubscriptionPlans",{version:"1.2.9"});D("payment.subscribe",{version:"1.2.9"});D("payment.flushSubInfoCache",{version:"1.2.9"});D("payment.subscribeSpin",{version:"1.3.7"});D("payment.getSpinSubscriptionPrice",{version:"1.4.3"})});var eO=h(an=>{"use strict";R();Je();V();Ur();ce();os();bt();Hm();dt();var TW=()=>{let{data:e}=L("getNetworkStatusSync");return!!(e!=null&&e.isConnected)},PW={get:(e,t)=>Y(e,P({method:"GET",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data),post:(e,t)=>Y(e,P({method:"POST",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data)},OW={httpClient:PW,checkNetwork:TW,track:j,eventEmitter:dn,getWindowInfo:()=>({width:window.innerWidth*window.devicePixelRatio,height:window.innerHeight*window.devicePixelRatio,statusBarHeight:30}),handleLinkClicked:e=>{window.open(e,"_blank")},getContextInfo:()=>{var e,t,r,n,i,o,a,s,c,l;return{hostAppId:(t=(e=I.hostInfo)==null?void 0:e.aid)!=null?t:"1",deviceId:(r=I.deviceInfo.did)!=null?r:"",adId:(n=I.deviceInfo.adId)!=null?n:"",sessionId:(i=I.sessionId)!=null?i:"",userId:(a=(o=I.hostUserInfo)==null?void 0:o.uid)!=null?a:"",objectType:"TASK",objectId:I.mpId,testAdsMode:I.testAdsMode,channel:(s=I.joliSource)!=null?s:"",deviceBrand:I.deviceInfo.brand,deviceModel:I.deviceInfo.model,osType:I.platform==="android"?"ANDROID":I.platform==="ios"?"IOS":"PC",runtimeType:"APP",platform:1e3,joliSource:(c=I.joliSource)!=null?c:"",deviceInfo:{platform:I.platform,nativeSDKVersionCode:(l=I.sdkInfo.nativeSDKVersionCode)!=null?l:0}}}},bh=K(),ZP=Jn(reportError),RW=$("getCoinDetails",{paramsSchema:S.tuple(S.function().optional()),implement:e=>g(an,null,function*(){try{if(I.mpType!=="miniApp")return reportError(Ce({code:-1,msg:"[JoliboxSDK]: rewards info not supported in games. Only supported in mini apps."})),{code:"FAILURE",message:"[JoliboxSDK]: rewards info not supported in games. Only supported in mini apps."};if(!ve("requestCoinDetailsSync"))return reportError(Ce({code:-1,msg:"[JoliboxSDK]: rewards info not supported in this platform."})),{code:"FAILURE",message:"[JoliboxSDK]: rewards info not supported in this platform. lower than 1.7.1"};let r=e?ZP(e):(()=>{console.log("default update function called")}).bind(an),{errNo:n,errMsg:i,data:o}=L("requestCoinDetailsSync");if(n!==0)throw Ce({code:n!=null?n:-1,msg:i});return console.log("=====> sync data",o,n),L("requestCoinDetailsAsync").then(a=>{a.errNo==0&&a.data&&(r(a.data),console.log("=====> res.data",a.data))}),{code:"SUCCESS",message:"Successfully retrieved coin details",data:o}}catch(t){return{code:"FAILURE",message:"[JoliboxSDK]: Failed to get coin details: "+t.message}}})});bh.registerCommand("RewardsSDK.getCoinDetails",RW);D("rewards.getCoinDetails",{version:"1.3.2"});var NW=$("createRewardsAdsManager",{implement:()=>g(an,null,function*(){try{let e=new Li(OW);if(I.mpType!=="miniApp")throw Ce({code:-1,msg:"[JoliboxSDK]: createRewardsAdsManager not supported in games. Only supported in mini apps."});return{code:"SUCCESS",message:"Successfully created RewardsAdsManager",data:{init:()=>g(an,null,function*(){yield e.init(),e.adConfig({preloadAdBreaks:"on",sound:"off",onReady:()=>{}})}),showAd:t=>g(an,null,function*(){e.adBreak({type:"reward",beforeReward:r=>{var n;r(),(n=t.onAdLoaded)==null||n.call(t)},adDismissed:()=>{var r;(r=t.onAdDismissed)==null||r.call(t)},adViewed:()=>{},adBreakDone:r=>{var o,a;let n=r.breakStatus,i=n==="frequencyCapped"||n==="other"||n==="error"||n==="noAdPreloaded";n==="viewed"&&(console.log("-----> complete watch ads"),wt.reporter({event:"COMPLETE_WATCH_ADS"}),(o=t.onAdRewarded)==null||o.call(t)),i&&(console.log("-----> no ad preloaded or error occurred",n),(a=t.onAdError)==null||a.call(t,new Error("No ad preloaded or error occurred: "+n)))}})})}}}catch(e){return{code:"FAILURE",message:"[JoliboxSDK]: Failed to create RewardsAdsManager"}}})});bh.registerCommand("Rewards.createRewardsAdsManager",NW);D("rewards.createRewardsAdsManager",{version:"1.3.4"});var DW=$("getLeaderBoardData",{paramsSchema:S.tuple(S.object({gameId:S.string(),onUpdate:S.function().optional()})),implement:e=>g(an,null,function*(){try{if(!ve("requestGameLeaderboardSync"))return{code:"FAILURE",message:"[JoliboxSDK]: getLeaderBoardData not supported in this platform."};let t=e.onUpdate?ZP(e.onUpdate):(()=>{console.log("default update function called")}).bind(an),{errNo:r,errMsg:n,data:i}=L("requestGameLeaderboardSync",{gameId:e.gameId});if(r!==0)throw Ce({code:r!=null?r:-1,msg:n});return L("requestGameLeaderboardAsync",{gameId:e.gameId}).then(o=>{var a;if(o.errNo===0&&o.data)t(o.data);else throw Ce({code:(a=o.errNo)!=null?a:-1,msg:o.errMsg})}).catch(o=>{console.error("Failed to fetch leaderboard data asynchronously: ",o)}),{code:"SUCCESS",message:"Successfully retrieved leaderboard data",data:i}}catch(t){return{code:"FAILURE",message:"[JoliboxSDK]: Failed to get leaderboard data: "+t.message}}})});bh.registerCommand("RewardsSDK.getLeaderBoardData",DW);D("rewards.getLeaderBoardData",{version:"1.3.9"})});var LW={};var Ece,xce,Dce,Lce,qce,tO=x(()=>{"use strict";rx();Ece=se(nx());ux();ro();dx();xce=se(mx());Bc();JP();HP();$P();WP();Dce=se(KP()),Lce=se(XP()),qce=se(eO())});var rO=Symbol.for("JOLIBOX_IMPLEMENT_INIT");if(window[rO])throw console.info("Jolibox Implement Already Initialized"),new Error("Jolibox Implement Already Initialized");window[rO]=!0;g(void 0,null,function*(){let[{config:e}]=yield Promise.all([Promise.resolve().then(()=>(ex(),Zk)),Promise.resolve().then(()=>(tO(),LW)),Promise.resolve().then(()=>(bt(),zg))]);e()});
|
|
914
|
+
`});function hP(){let e=new Map,t,r;return{registerRewardHandler(i,o){e.set(i,o)},handleReward(i,...o){return g(this,null,function*(){return yield i.reduce((s,c)=>g(this,null,function*(){let l=yield s;if(l===!0)return!0;mP&&console.log(`handleReward ${c}`);let d=e.get(c),u=d?yield d(...o):l;return mP&&console.log(`handleReward ${c} ${u}`),u}),Promise.resolve(!1))})},registerRewardsFetcher(i){return g(this,null,function*(){t=(...o)=>g(this,null,function*(){try{return yield i(...o)}catch(a){return console.error("getRewardOptions error:",a),["ADS"]}})})},registerRewardFrequencyConfigFetcher(i){return g(this,null,function*(){r=(...o)=>g(this,null,function*(){try{return yield i(...o)}catch(a){return console.error("getRewardOptions error:",a),{joliCoinUseAndCharge:Ar,loginGuide:Cr}}})})},getRewardsTypes(...i){return g(this,null,function*(){return t?yield t(...i):["ADS"]})},getRewardFrequencyConfig(...i){return g(this,null,function*(){return r?yield r(...i):{joliCoinUseAndCharge:Ar,loginGuide:Cr}})}}}var mP,gP=x(()=>{"use strict";V();Be();mP=I.testMode});var Vm,$m,kl,vP=x(()=>{"use strict";R();Vm=class{constructor(t){this.httpClient=t}execute(t,r){return g(this,null,function*(){let n=(r==null?void 0:r.method)||"POST",i=(r==null?void 0:r.body)||{};return n==="GET"?yield this.httpClient.get(t,i):yield this.httpClient.post(t,i)})}extractCacheableData(t){var r,n,i;return{unlockOptions:((r=t.data)==null?void 0:r.unlockOptions)||[],joliCoin:((n=t.extra)==null?void 0:n.joliCoin)||{balance:0,enableAutoDeduct:!1},joliGem:((i=t.extra)==null?void 0:i.joliGem)||{balance:0,enableAutoDeduct:!1}}}mergeData(t,r){return{code:"SUCCESS",message:"success",data:{unlockOptions:t.unlockOptions},extra:{joliCoin:t.joliCoin||{balance:0,enableAutoDeduct:!1},joliGem:t.joliGem||{balance:0,enableAutoDeduct:!1}}}}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:{unlockOptions:t.unlockOptions},extra:{joliCoin:t.joliCoin,joliGem:t.joliGem}}}},$m=class{constructor(t){this.httpClient=t}execute(t,r){return g(this,null,function*(){let n=(r==null?void 0:r.method)||"GET",i=(r==null?void 0:r.body)||{};return n==="GET"?yield this.httpClient.get(t,i):yield this.httpClient.post(t,i)})}extractCacheableData(t){let r=t.data;return P({joliCoinUseAndCharge:r==null?void 0:r.joliCoinUseAndCharge,loginGuide:r==null?void 0:r.loginGuide},r)}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:t}}},kl=class{constructor(t){this.unlockOptionsService=new Ut(new Vm(t),{duration:30*60*1e3,timeout:1e3,keyGenerator:r=>r,consistencyChecker:(r,n)=>r.unlockOptions.length!==n.unlockOptions.length?!1:r.unlockOptions.every((i,o)=>{var s,c;let a=n.unlockOptions[o];return i.type===a.type&&((s=i.joliGemChoice)==null?void 0:s.joliGemQuantity)===((c=a.joliGemChoice)==null?void 0:c.joliGemQuantity)})}),this.globalConfigService=new Ut(new $m(t),{duration:60*60*1e3,timeout:1e3,keyGenerator:r=>r})}getUnlockOptions(){return g(this,arguments,function*(t={}){return yield this.unlockOptionsService.request("/api/games/unlock-options",{endpoint:"/api/games/unlock-options",body:t,method:"POST"})})}getGlobalConfig(){return g(this,null,function*(){return yield this.globalConfigService.request("/api/fe-configs/web-common/global-config",{endpoint:"/api/fe-configs/web-common/global-config",method:"GET"})})}refreshUnlockOptions(){return g(this,arguments,function*(t={}){return yield this.unlockOptionsService.forceRequest("/api/games/unlock-options",{endpoint:"/api/games/unlock-options",body:t,method:"POST"})})}refreshGlobalConfig(){return g(this,null,function*(){return yield this.globalConfigService.forceRequest("/api/fe-configs/web-common/global-config",{endpoint:"/api/fe-configs/web-common/global-config",method:"GET"})})}warmupCache(){return g(this,null,function*(){yield Promise.all([this.unlockOptionsService.warmupCache("/api/games/unlock-options",{endpoint:"/api/games/unlock-options",method:"POST"}),this.globalConfigService.warmupCache("/api/fe-configs/web-common/global-config",{endpoint:"/api/fe-configs/web-common/global-config",method:"GET"})])})}clearAllCache(){this.unlockOptionsService.clearCache(),this.globalConfigService.clearCache()}getCacheStats(){return{unlockOptions:this.unlockOptionsService.getCacheStats(),globalConfig:this.globalConfigService.getCacheStats()}}clearExpiredCache(){this.unlockOptionsService.clearExpiredCache(),this.globalConfigService.clearExpiredCache()}}});function zm(e){return Wm||(Wm=new kl(e)),Wm}var z9,K9,Y9,Wm,Km,Ym,Qm,Xm=x(()=>{"use strict";vP();Be();R();z9=()=>(e,t)=>{let r={SUBSCRIPTION:4,JOLI_GEM:3,JOLI_GEM_ONLY:3,JOLI_COIN:2,JOLI_COIN_ONLY:2,ADS:1};return r[t]-r[e]},K9=["openJolicoinGuide",{method:"getABTest",platforms:["android"],nativeVersionCode:1050100},"userTrackAsync",{method:"openMiniapp",nativeVersionCode:1050100}],Y9=e=>{if(!e.length)return["ADS"];if(e.includes("JOLI_GEM")){if(e.length===1)return["JOLI_GEM_ONLY"];if(e.includes("SUBSCRIPTION")&&e.length===2)return["SUBSCRIPTION","JOLI_GEM_ONLY"]}if(e.includes("JOLI_COIN")){if(e.length===1)return["JOLI_COIN_ONLY"];if(e.includes("SUBSCRIPTION")&&e.length===2)return["SUBSCRIPTION","JOLI_COIN_ONLY"]}return e.sort(z9())},Wm=null;Km=e=>{e.registerRewardsFetcher(t=>g(void 0,null,function*(){var i,o,a,s,c;let r=["ADS"],n=zm(t);try{let l=yield n.getUnlockOptions({});if(l.code!=="SUCCESS")return r;M.emit(Jc,{options:((i=l.data)==null?void 0:i.unlockOptions)||[],userJoliCoin:((o=l.extra)==null?void 0:o.joliCoin)||{balance:0,enableAutoDeduct:!1},userGem:((a=l.extra)==null?void 0:a.joliGem)||{balance:0,enableAutoDeduct:!1}});let d=((c=(s=l.data)==null?void 0:s.unlockOptions)==null?void 0:c.map(u=>u.type))||Array.from(r);return Y9(d)}catch(l){return console.error("getRewardOptions error (cached):",l),r}}))},Ym=e=>{e.registerRewardFrequencyConfigFetcher(t=>g(void 0,null,function*(){var n,i,o,a;let r=zm(t);try{let s=yield r.getGlobalConfig();return M.emit(Jt,{joliCoinUseAndCharge:((n=s.data)==null?void 0:n.joliCoinUseAndCharge)||Ar,loginGuide:((i=s.data)==null?void 0:i.loginGuide)||Cr}),s.data&&we.emit("onGlobalConfigChanged",{globalConfig:s.data}),{joliCoinUseAndCharge:((o=s.data)==null?void 0:o.joliCoinUseAndCharge)||Ar,loginGuide:((a=s.data)==null?void 0:a.loginGuide)||Cr}}catch(s){return console.error("getGlobalConfig error (cached):",s),M.emit(Jt,{joliCoinUseAndCharge:Ar,loginGuide:Cr}),we.emit("onGlobalConfigChanged",{globalConfig:{joliCoinUseAndCharge:Ar,loginGuide:Cr,supportedHostMethods:K9}}),{joliCoinUseAndCharge:Ar,loginGuide:Cr}}}))},Qm=e=>g(void 0,null,function*(){yield zm(e).warmupCache(),console.log("Reward cache warmed up")})});var Zm=x(()=>{"use strict";Xm();Xm()});var yP,bP=x(()=>{"use strict";yP=e=>t=>g(void 0,null,function*(){try{console.log("trigger @jolibox/ads reward",t),yield e.adBreak(t)}catch(r){console.error("-----createAdsRewardHandler error-----",r)}return!0})});var Le,Fi,Tt=x(()=>{"use strict";Be();or();Be();Le=Ge(M,Jc),Fi=(e,t)=>{var n;let r=(n=e.options)==null?void 0:n.some(i=>i.type==="SUBSCRIPTION");return console.log("typeof extraCheck",typeof t,t==null?void 0:t()),r&&(!t||(t==null?void 0:t()))}});var xl,eh=x(()=>{"use strict";xl={JOLI_COIN:{balanceEndpoint:"/api/joli-coin/balance",balanceDetailEndpoint:"/api/joli-coin/balance-detail",unlockEndpoint:"/api/joli-coin/unlock",unlockType:"JOLI_COIN"},GEM:{balanceEndpoint:"/api/joli-gem/balance",balanceDetailEndpoint:"/api/joli-gem/balance-detail",unlockEndpoint:"/api/joli-gem/unlock",unlockType:"GEM"}}});var vt,nn=x(()=>{"use strict";R();vt=K()});function _P(e){return th||(th=new nh(e)),th}var rh,nh,th,ih,qn,ji=x(()=>{"use strict";R();rh=class{constructor(t){this.httpClient=t}execute(t,r){return g(this,null,function*(){let n=(r==null?void 0:r.method)||"GET",i=(r==null?void 0:r.query)||{};return n==="GET"?yield this.httpClient.get(t,{query:i}):yield this.httpClient.post(t,{query:i})})}extractCacheableData(t){var r;return{balance:((r=t.data)==null?void 0:r.balance)||0,timestamp:Date.now()}}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:{balance:t.balance}}}},nh=class{constructor(t){this.balanceService=new Ut(new rh(t),{duration:20*60*1e3,timeout:1e3,keyGenerator:(r,n)=>{let i=n!=null&&n.query?JSON.stringify(n.query):"";return`${r}:${i}`}})}getBalance(t="JOLI_COIN"){return g(this,null,function*(){return(yield this.balanceService.request("/api/joli-coin/balance",{endpoint:"/api/joli-coin/balance",query:{type:t},method:"GET"})).data})}refreshBalance(t="JOLI_COIN"){return g(this,null,function*(){return(yield this.balanceService.forceRequest("/api/joli-coin/balance",{endpoint:"/api/joli-coin/balance",query:{type:t},method:"GET"})).data})}warmupBalance(t="JOLI_COIN"){return g(this,null,function*(){yield this.balanceService.warmupCache("/api/joli-coin/balance",{endpoint:"/api/joli-coin/balance",query:{type:t},method:"GET"})})}clearBalanceCache(){this.balanceService.clearCache()}getBalanceCacheStats(){return this.balanceService.getCacheStats()}clearExpiredCache(){this.balanceService.clearExpiredCache()}},th=null;ih=(e,t="JOLI_COIN")=>g(void 0,null,function*(){return yield _P(e).getBalance(t)}),qn=(e,t="JOLI_COIN")=>g(void 0,null,function*(){let n=yield _P(e).refreshBalance(t);return console.log(`Balance cache refreshed for type: ${t}`),n})});var wP=x(()=>{"use strict";ji()});function ch(e){return oh||(oh=new sh(e)),oh}var ah,sh,oh,lh,Un,Tl,Bi=x(()=>{"use strict";R();ah=class{constructor(t){this.httpClient=t}execute(t,r){return g(this,null,function*(){let n=(r==null?void 0:r.method)||"GET",i=(r==null?void 0:r.query)||{};return n==="GET"?yield this.httpClient.get(t,{query:i}):yield this.httpClient.post(t,{query:i})})}extractCacheableData(t){var r;return{balance:((r=t.data)==null?void 0:r.balance)||0,timestamp:Date.now()}}processCachedData(t){return{code:"SUCCESS",message:"success from cache",data:{balance:t.balance}}}},sh=class{constructor(t){this.gemBalanceService=new Ut(new ah(t),{duration:20*60*1e3,timeout:1e3,keyGenerator:(r,n)=>{let i=n!=null&&n.query?JSON.stringify(n.query):"";return`${r}:${i}`}})}getGemBalance(t="GEM"){return g(this,null,function*(){return(yield this.gemBalanceService.request("/api/joli-gem/balance",{endpoint:"/api/joli-gem/balance",query:{type:t},method:"GET"})).data})}refreshGemBalance(t="GEM"){return g(this,null,function*(){return(yield this.gemBalanceService.forceRequest("/api/joli-gem/balance",{endpoint:"/api/joli-gem/balance",query:{type:t},method:"GET"})).data})}warmupGemBalance(t="GEM"){return g(this,null,function*(){yield this.gemBalanceService.warmupCache("/api/joli-gem/balance",{endpoint:"/api/joli-gem/balance",query:{type:t},method:"GET"})})}clearGemBalanceCache(){this.gemBalanceService.clearCache()}getGemBalanceCacheStats(){return this.gemBalanceService.getCacheStats()}clearExpiredCache(){this.gemBalanceService.clearExpiredCache()}},oh=null;lh=(e,t="GEM")=>g(void 0,null,function*(){return yield ch(e).getGemBalance(t)}),Un=(e,t="GEM")=>g(void 0,null,function*(){let n=yield ch(e).refreshGemBalance(t);return console.log(`Gem balance cache refreshed for type: ${t}`),n}),Tl=(e,t="GEM")=>g(void 0,null,function*(){yield ch(e).warmupGemBalance(t),console.log(`Gem balance cache warmed up for type: ${t}`)})});var SP=x(()=>{"use strict";Bi()});var Dt,Mn=x(()=>{"use strict";wP();SP();Dt={JOLI_COIN:{fetchBalance:ih,getQuantity:e=>{var t,r,n;return(n=(r=(t=e==null?void 0:e.options)==null?void 0:t.find(i=>i.type==="JOLI_COIN"))==null?void 0:r.joliCoinChoices[0].joliCoinQuantity)!=null?n:0},getCurrentUser:e=>{var t;return(t=e==null?void 0:e.userJoliCoin)!=null?t:{balance:0,enableAutoDeduct:!1}},createUpdatedUser:(e,t)=>({balance:e,enableAutoDeduct:t}),getUpdateKey:()=>"userJoliCoin",isEnough:(e,t)=>{var r,n;return(n=(r=e==null?void 0:e.options)==null?void 0:r.some(i=>i.type==="JOLI_COIN"&&i.joliCoinChoices.some(o=>{var a;return o.joliCoinQuantity<=((a=t==null?void 0:t.balance)!=null?a:0)})))!=null?n:!1}},JOLI_GEM:{fetchBalance:lh,getQuantity:e=>{var t,r,n,i;return(i=(n=(r=(t=e==null?void 0:e.options)==null?void 0:t.find(o=>o.type==="JOLI_GEM"))==null?void 0:r.joliGemChoice)==null?void 0:n.joliGemQuantity)!=null?i:0},getCurrentUser:e=>{var t;return(t=e==null?void 0:e.userGem)!=null?t:{balance:0,enableAutoDeduct:!1}},createUpdatedUser:(e,t)=>({balance:e,enableAutoDeduct:t}),getUpdateKey:()=>"userGem",isEnough:(e,t)=>{var n,i,o;let r=e==null?void 0:e.options.find(a=>a.type==="JOLI_GEM");return r?((i=(n=r.joliGemChoice)==null?void 0:n.joliGemQuantity)!=null?i:0)<=((o=t==null?void 0:t.balance)!=null?o:0):!1}}}});var va,Nr,uh=x(()=>{"use strict";nn();Tt();or();Be();Be();Mn();va=(e,t,r)=>{let{showUnlockWithCurrencyModal:n}=r;vt.registerCommand(`Rewards.${e}.useJolicoin`,()=>g(void 0,null,function*(){let i=yield Le.getData(),o=Dt[t],a=o.getCurrentUser(i),s=o.getQuantity(i),c=!!(a!=null&&a.enableAutoDeduct);return console.log("-----unlockOptions usemodal-----",i,c,s),(yield n({enableAutoDeduct:c,userCurrency:a,quantity:s,currency:t}))!=="CONFIRM"?{result:"FAILED"}:{result:"SUCCESS"}}))},Nr=(e,t)=>r=>g(void 0,null,function*(){let n=Ge(M,xn);return M.emit(Vc,e,{enableAutoDeduct:r.enableAutoDeduct,userCurrency:r.userCurrency,quantity:r.quantity,currency:r.currency,confirmButtonText:t.confirmButtonText,cancelButtonText:t.cancelButtonText}),(yield n.getFreshData()).useModalResult})});var ya,Dr,IP=x(()=>{"use strict";nn();Tt();Be();or();Be();Mn();Bi();ji();ya=(e,t,r)=>{let{httpClient:n,initiateAndAwaitPayment:i}=r;vt.registerCommand(`Rewards.${e}.usePayment`,()=>g(void 0,null,function*(){var p;let o=yield Le.getData(),a=Dt[t],s=yield a.fetchBalance(n),c=a.getQuantity(o),l=a.getCurrentUser(o),d=a.createUpdatedUser((p=s==null?void 0:s.balance)!=null?p:0,l.enableAutoDeduct),u=a.getUpdateKey();if(Le.updateData({[u]:d}),console.log("-----unlockOptions payment-----",o,d,c,t),!a.isEnough(o,d)){let f=yield i({userCurrency:d,currencyQuantity:c,currency:t});return t==="JOLI_GEM"?Un(n):qn(n),{result:f==="SUCCESS"?"SUCCESS":"FAILED"}}return{result:"CONTINUE"}}))},Dr=(e,t)=>r=>g(void 0,null,function*(){let n=Ge(M,Gt);return M.emit(Hc,e,{userCurrency:r.userCurrency,quantity:r.currencyQuantity,currency:r.currency,enableAutoDeduct:r.userCurrency.enableAutoDeduct,confirmButtonText:t.confirmButtonText,cancelButtonText:t.cancelButtonText}),(yield n.getFreshData()).paymentResult})});var dh,Lr,EP=x(()=>{"use strict";V();nn();or();Be();Be();R();Tt();Mn();dh=(e,t,r)=>{let{showUnloginModal:n,httpClient:i}=r;vt.registerCommand(`Rewards.${e}.useUnloginModal`,()=>g(void 0,null,function*(){var s,c,l;let o=(s=I.hostUserInfo)==null?void 0:s.isLogin,a=yield Le.getData();if(console.log("-----isLogin-----",!!o),!o){let d=yield n(t);if(console.log("-----unloginModalResult-----",d),d.result=="FAILED"||d.result=="CANCEL")return{result:"FAILED"};let{isFirstLogin:u,claimedRewardValue:p}=(c=d.rewards)!=null?c:{};if(d.result=="SUCCESS"){u&&p&&(yield Ra(3e3));let f=Dt[t],m=yield f.fetchBalance(i),v=f.getQuantity(a),b=f.getCurrentUser(a),y=f.createUpdatedUser((l=m==null?void 0:m.balance)!=null?l:0,b.enableAutoDeduct),w=f.getUpdateKey();if(Le.updateData({[w]:y}),y.balance>=v)return{result:"SUCCESS"}}}return{result:"CONTINUE"}}))},Lr=(e,t)=>r=>g(void 0,null,function*(){let n=Ge(M,Er);return M.emit($c,e,{confirmButtonText:t.confirmButtonText,cancelButtonText:t.cancelButtonText,currency:r}),yield n.getFreshData()})});var Fn=x(()=>{"use strict";uh();IP();EP()});var X9,Pl,ph=x(()=>{"use strict";V();R();eh();Fn();nn();ji();Mn();Tt();X9=(e,t,r,{handlers:{handleUnlockSuccess:n,handleUnlockFailed:i,unlockOptionsHandler:o,initiateAndAwaitPayment:a,showUnlockWithCurrencyModal:s,showUnloginModal:c,hasSubscription:l}})=>{ya(e,"JOLI_COIN",{httpClient:t,initiateAndAwaitPayment:a}),va(e,"JOLI_COIN",{showUnlockWithCurrencyModal:s});let d=[`Rewards.${e}.usePayment`,`Rewards.${e}.useJolicoin`];return u=>g(void 0,null,function*(){var p,f,m,v;try{let b=yield o.getData();if(Fi(b,l)){let C=Dt.JOLI_COIN,T=yield C.fetchBalance(t),k=C.getCurrentUser(b),A=C.createUpdatedUser((p=T==null?void 0:T.balance)!=null?p:0,k.enableAutoDeduct);if(!C.isEnough(b,A))return i==null||i(u),!1}else{let C=!0;for(let T of d){let k=yield vt.executeCommand(T);if(C=C&&k.result!=="FAILED",k.result!=="CONTINUE")break}if(!C)return i==null||i(u),!1}let w=xl[r],E=yield t.post(w.unlockEndpoint,{data:{type:"GAME_REWARD",reqId:`${Hn()}-${I.mpType}-${Date.now()}`,gameInfo:{gameId:I.mpId}}});if(console.log("-----unlockWithCurrency request result-----",E),E.code=="SUCCESS"){try{(m=u.adBreakDone)==null||m.call(u,{breakType:u.type,breakName:"name"in u&&(f=u.name)!=null?f:"",breakFormat:"reward",breakStatus:"viewed"}),"adViewed"in u&&((v=u.adViewed)==null||v.call(u)),qn(t)}catch(C){console.error("-----unlockWithJolicoin adBreakDone error-----",C)}return n==null||n({quantity:E.data.quantity,balance:E.data.balance}),!0}return i==null||i(u),!1}catch(b){if(console.info("JolicoinRewardHandler error:",b),b instanceof Error&&b.message=="CANCEL")throw b;return i==null||i(u),!1}finally{o.clearCache()}})},Pl=(e,t,r)=>X9(e,t,"JOLI_COIN",r)});var AP,CP=x(()=>{"use strict";Tt();ph();Fn();AP=(e,{onUnlockSuccess:t,onUnlockFailed:r,hasSubscription:n})=>{let i=()=>{r==null||r()},o=Nr("ADS-JOLI_COIN",{confirmButtonText:"jolicoin.useJolicoin",cancelButtonText:"jolicoin.noWatchAds"}),a=Dr("ADS-JOLI_COIN",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noWatchAds"}),s=Lr("ADS-JOLI_COIN",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noWatchAds"});return Pl("ADS-JOLI_COIN",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:i,unlockOptionsHandler:Le,initiateAndAwaitPayment:a,showUnlockWithCurrencyModal:o,showUnloginModal:s,hasSubscription:n}})}});var kP,xP=x(()=>{"use strict";ph();Tt();Fn();kP=(e,{onUnlockSuccess:t,onUnlockFailed:r,hasSubscription:n})=>{let i=l=>{var d;r==null||r(),(d=l.adBreakDone)==null||d.call(l,{breakType:l.type,breakFormat:l.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})},o=Nr("JOLI_COIN",{confirmButtonText:"jolicoin.useJolicoin",cancelButtonText:"jolicoin.noThanks"}),a=Dr("JOLI_COIN",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noThanks"}),s=Lr("JOLI_COIN",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noThanks"});return Pl("JOLI_COIN",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:i,unlockOptionsHandler:Le,initiateAndAwaitPayment:a,showUnlockWithCurrencyModal:o,showUnloginModal:s,hasSubscription:n}})}});var Ol,fh=x(()=>{"use strict";V();R();eh();Fn();uh();nn();Bi();Mn();Tt();Ol=(e,t,{handlers:{handleUnlockSuccess:r,handleUnlockFailed:n,unlockOptionsHandler:i,initiateAndAwaitPayment:o,showUnlockWithCurrencyModal:a,showUnloginModal:s,hasSubscription:c}})=>{dh(e,"JOLI_GEM",{httpClient:t,showUnloginModal:s}),ya(e,"JOLI_GEM",{httpClient:t,initiateAndAwaitPayment:o}),va(e,"JOLI_GEM",{showUnlockWithCurrencyModal:a});let l=[`Rewards.${e}.usePayment`,`Rewards.${e}.useJolicoin`];return d=>g(void 0,null,function*(){var u,p,f,m;try{let v=yield i.getData(),b=Fi(v,c);if(console.log("[GemHandler] supportSubscription",b,v),b){let E=Dt.JOLI_GEM,C=yield E.fetchBalance(t),T=E.getCurrentUser(v),k=E.createUpdatedUser((u=C==null?void 0:C.balance)!=null?u:0,T.enableAutoDeduct);if(!E.isEnough(v,k))return n==null||n(d),!1}else{let E=!0;for(let C of l){let T=yield vt.executeCommand(C);if(console.log("[GemHandler] command result",T,C),E=E&&T.result!=="FAILED",T.result!=="CONTINUE")break}if(!E)return n==null||n(d),!1}let y=xl.GEM,w=yield t.post(y.unlockEndpoint,{data:{type:"GAME_REWARD",reqId:`${Hn()}-${I.mpType}-${Date.now()}`,gameInfo:{gameId:I.mpId}}});if(console.log("-----unlockWithGem request result-----",w),w.code=="SUCCESS"){try{(f=d.adBreakDone)==null||f.call(d,{breakType:d.type,breakName:"name"in d&&(p=d.name)!=null?p:"",breakFormat:"reward",breakStatus:"viewed"}),"adViewed"in d&&((m=d.adViewed)==null||m.call(d)),Un(t)}catch(E){console.error("-----unlockWithGem adBreakDone error-----",E)}return r==null||r({quantity:w.data.quantity,balance:w.data.balance}),!0}return n==null||n(d),!1}catch(v){if(console.info("GemRewardHandler error:",v),v instanceof Error&&v.message=="CANCEL")throw v;return n==null||n(d),!1}finally{i.clearCache()}})}});var TP,PP=x(()=>{"use strict";Tt();fh();Fn();TP=(e,{onUnlockSuccess:t,onUnlockFailed:r,hasSubscription:n})=>{let i=()=>{r==null||r()},o=Nr("ADS-JOLI_GEM",{confirmButtonText:"joligem.useJolicoin",cancelButtonText:"jolicoin.noWatchAds"}),a=Dr("ADS-JOLI_GEM",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noWatchAds"}),s=Lr("ADS-JOLI_GEM",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noWatchAds"});return Ol("ADS-JOLI_GEM",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:i,unlockOptionsHandler:Le,initiateAndAwaitPayment:a,showUnlockWithCurrencyModal:o,showUnloginModal:s,hasSubscription:n}})}});var OP,RP=x(()=>{"use strict";fh();Tt();Fn();OP=(e,{onUnlockSuccess:t,onUnlockFailed:r,hasSubscription:n})=>{let i=l=>{var d;r==null||r(),(d=l.adBreakDone)==null||d.call(l,{breakType:l.type,breakFormat:l.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})},o=Nr("JOLI_GEM",{confirmButtonText:"joligem.useJolicoin",cancelButtonText:"jolicoin.noThanks"}),a=Dr("JOLI_GEM",{confirmButtonText:"jolicoin.payAndUnlock",cancelButtonText:"jolicoin.noThanks"}),s=Lr("JOLI_GEM",{confirmButtonText:"loginGuide.login",cancelButtonText:"loginGuide.noThanks"});return Ol("JOLI_GEM",e,{handlers:{handleUnlockSuccess:t,handleUnlockFailed:i,unlockOptionsHandler:Le,initiateAndAwaitPayment:a,showUnlockWithCurrencyModal:o,showUnloginModal:s,hasSubscription:n}})}});var NP,DP,mh=x(()=>{"use strict";Mn();nn();Tt();or();Be();Be();NP=e=>{let{showSubscriptionModal:t}=e;vt.registerCommand("Rewards.subscription",()=>g(void 0,null,function*(){var s,c;let r=yield Le.getData(),n=(c=(s=r==null?void 0:r.options)==null?void 0:s.find(l=>l.type==="JOLI_GEM"))==null?void 0:c.type,i=Dt[n?"JOLI_GEM":"JOLI_COIN"],o=i.getCurrentUser(r);return i.isEnough(r,o)?{result:"FAILED"}:{result:(yield t())==="SUCCESS"?"SUCCESS":"FAILED"}}))},DP=e=>()=>g(void 0,null,function*(){let t=Ge(M,Tn);return M.emit(Wc,e),(yield t.getFreshData()).result})});var LP=x(()=>{"use strict";mh()});var qP,UP=x(()=>{"use strict";nn();LP();V();Tt();ji();Bi();qP=(e,t,{handlers:{handleSubSuccess:r,handleSubFailed:n,unlockOptionsHandler:i,showSubscriptionModal:o,hasSubscription:a}})=>{NP({showSubscriptionModal:o});let s=["Rewards.subscription"];return c=>g(void 0,null,function*(){var l,d,u,p,f,m;try{let v=yield i.getData();if(!Fi(v,a))return!1;let y=!0;for(let w of s){let E=yield vt.executeCommand(w);if(y=y&&E.result!=="FAILED",E.result!=="CONTINUE")break}if(qn(t),Un(t),console.log("-----unlockWithSubscription result-----",y),y){try{(d=c.adBreakDone)==null||d.call(c,{breakType:c.type,breakName:"name"in c&&(l=c.name)!=null?l:"",breakFormat:c.type==="reward"?"reward":"interstitial",breakStatus:"viewed"}),"adViewed"in c&&((u=c.adViewed)==null||u.call(c)),(m=(f=I).onEnvConfigChanged)==null||m.call(f,{hostUserInfo:B(P({},(p=I.hostUserInfo)!=null?p:{isLogin:!1}),{isSubUser:!0})})}catch(w){console.error("-----unlockWithSubscription adBreakDone error-----",w)}return r==null||r(),!0}return n==null||n(c),!1}catch(v){if(console.info("SubscriptionRewardHandler error:",v),v instanceof Error&&v.message=="CANCEL")throw v;return n==null||n(c),!1}finally{}})}});var MP,FP=x(()=>{"use strict";Tt();UP();mh();MP=(e,{onSubSuccess:t,onSubFailed:r,hasSubscription:n})=>{let i=()=>{r==null||r()},o=DP("SUBSCRIPTION");return qP("SUBSCRIPTION",e,{handlers:{handleSubSuccess:t,handleSubFailed:i,unlockOptionsHandler:Le,showSubscriptionModal:o,hasSubscription:n}})}});var Lt,jP=x(()=>{"use strict";gP();Zm();bP();CP();xP();PP();RP();FP();ji();Bi();Lt=hP();Km(Lt);Ym(Lt)});var Rl,Z9,lr,eW,ba,tW,BP,GP,rW,nW,hh,iW,oW,aW,JP=x(()=>{"use strict";R();Je();ir();sT();im();Hm();bt();V();dt();ce();jP();os();Zm();Rl=K(),Z9=()=>{let{data:e}=L("getNetworkStatusSync");return!!(e!=null&&e.isConnected)},lr={get:(e,t)=>Y(e,P({method:"GET",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data),post:(e,t)=>Y(e,P({method:"POST",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data)},eW={httpClient:lr,checkNetwork:Z9,track:j,eventEmitter:dn,getWindowInfo:()=>({width:window.innerWidth*window.devicePixelRatio,height:window.innerHeight*window.devicePixelRatio,statusBarHeight:30}),handleLinkClicked:e=>{window.open(e,"_blank")},getContextInfo:()=>{var e,t,r,n,i,o,a,s,c,l;return{hostAppId:(t=(e=I.hostInfo)==null?void 0:e.aid)!=null?t:"1",deviceId:(r=I.deviceInfo.did)!=null?r:"",adId:(n=I.deviceInfo.adId)!=null?n:"",sessionId:(i=I.sessionId)!=null?i:"",userId:(a=(o=I.hostUserInfo)==null?void 0:o.uid)!=null?a:"",objectType:"GAME",objectId:I.mpId,testAdsMode:I.testAdsMode,channel:(s=I.joliSource)!=null?s:"",deviceBrand:I.deviceInfo.brand,deviceModel:I.deviceInfo.model,osType:I.platform==="android"?"ANDROID":I.platform==="ios"?"IOS":"PC",runtimeType:"APP",platform:1e3,joliSource:(c=I.joliSource)!=null?c:"",deviceInfo:{platform:I.platform,nativeSDKVersionCode:(l=I.sdkInfo.nativeSDKVersionCode)!=null?l:0}}}},ba=new Li(eW);Lt.getRewardFrequencyConfig(lr).then(e=>{console.log("getRewardFrequencyConfig",e)});Lt.registerRewardHandler("ADS",yP(ba));Lt.registerRewardHandler("JOLI_COIN",AP(lr,{onUnlockSuccess:e=>{BP(e),j("jolicoin_unlock_success",{quantity:e.quantity})},onUnlockFailed:()=>{console.log("onUnlockFailed")},hasSubscription:()=>ve("invokeSubscriptionPanelSync")}));Lt.registerRewardHandler("JOLI_COIN_ONLY",kP(lr,{onUnlockSuccess:e=>{BP(e),j("jolicoin_unlock_success",{quantity:e.quantity,isOnly:!0})},onUnlockFailed:()=>{console.log("onUnlockFailed")},hasSubscription:()=>ve("invokeSubscriptionPanelSync")}));Lt.registerRewardHandler("JOLI_GEM",TP(lr,{onUnlockSuccess:e=>{GP(e),j("gem_unlock_success",{quantity:e.quantity})},hasSubscription:()=>ve("invokeSubscriptionPanelSync")}));Lt.registerRewardHandler("JOLI_GEM_ONLY",OP(lr,{onUnlockSuccess:e=>{GP(e),j("gem_unlock_success",{quantity:e.quantity,isOnly:!0})},hasSubscription:()=>ve("invokeSubscriptionPanelSync")}));tW=()=>{j("subscription_unlock_success",{})};Lt.registerRewardHandler("SUBSCRIPTION",MP(lr,{onSubSuccess:tW.bind(void 0),hasSubscription:()=>ve("invokeSubscriptionPanelSync")}));BP=e=>{let{quantity:t}=e,r=`{slot-coin} ${t} {slot-i18n-jolicoin.coinUsed}`;Ir(r,{customStyle:{mark:{marginRight:"8px"},base:{with:"auto"}},i18nParams:{text:"Jolicoin Used"}})};Qm(lr);Tl(lr);dn.on("isAdShowing",e=>{xi("JOLIBOX_ADS_EVENT",{isAdShowing:e})});GP=e=>{let{quantity:t}=e,r=`{slot-correct} ${t*-1} {slot-gem}`;Ir(r,{customStyle:{mark:{marginRight:"8px"},base:{"font-size":"25px","font-weight":"700","line-height":"18px"},span:{width:"auto",minWidth:"fit-content",maxWidth:"60px",textAlign:"center",padding:"0 2px",lineHeight:"25px"},gem:{transform:"translateY(-2px)",width:"28px",height:"28px"}}})},rW=Q("adInit",{implement:e=>{ba.init(e)}}),nW=Q("adConfig",{implement:e=>{ba.adConfig(e)}}),hh=!1,iW=e=>{var t,r,n;(r=e.adBreakDone)==null||r.call(e,{breakType:e.type,breakName:"name"in e&&(t=e.name)!=null?t:"",breakFormat:e.type==="reward"?"reward":"interstitial",breakStatus:"viewed"}),"adViewed"in e&&((n=e.adViewed)==null||n.call(e))},oW=Q("adBreak",{implement:e=>{var r;if((r=I.hostUserInfo)==null?void 0:r.isSubUser){iW(e);return}if(e.type==="reward"){if(hh)return;hh=!0,Lt.getRewardsTypes(lr).then(n=>{Lt.handleReward(n,e).catch(i=>{var o;console.info("handleReward failed in native",i),(o=e.adBreakDone)==null||o.call(e,{breakType:e.type,breakFormat:e.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})}).finally(()=>{hh=!1})})}else ba.adBreak(e)}}),aW=Q("adUnit",{implement:e=>{ba.adUnit(e)}});Rl.registerCommand("AdsSDK.init",rW);Rl.registerCommand("AdsSDK.adConfig",nW);Rl.registerCommand("AdsSDK.adBreak",oW);Rl.registerCommand("AdsSDK.adUnit",aW);D("AdsSDK.init",{version:"1.0.0"});D("AdsSDK.adConfig",{version:"1.0.0"});D("AdsSDK.adBreak",{version:"1.0.0"});D("AdsSDK.adUnit",{version:"1.0.0"})});var _a,sW,cW,lW,uW,dW,HP=x(()=>{"use strict";R();ce();Je();V();_a=K(),sW=Q("openSchemaSync",{paramsSchema:S.tuple(S.string()),implement:e=>{let t=e;e.match(/^https?:\/\//)||(t=`https://${I.mpId}.app.jolibox.com${e.startsWith("/")?"":"/"}${e}`);let r=L("openSchemaSync",{schema:t});if(r.errNo!==0)throw new Vt(r.errMsg,r.errNo)}}),cW=Q("openPageSync",{paramsSchema:S.tuple(S.string()),implement:e=>{let{errNo:t,errMsg:r,data:n}=L("openPageSync",{url:e});if(t!==0||!n)throw new Vt(r,t);return{webviewId:n.webviewId}}}),lW=Q("closePageSync",{paramsSchema:S.tuple(S.number()),implement:e=>{let{errNo:t,errMsg:r}=L("closePageSync",{webviewId:e});if(t!==0)throw new Vt(r,t)}}),uW=Q("interceptSystemExitSync",{paramsSchema:S.tuple(S.boolean()),implement:e=>{we.emit("onInterceptSystemExit",{intercept:e}),we.emit("onInterceptBackPress",{intercept:e})}}),dW=Q("navigateToNativePage",{paramsSchema:S.tuple(S.enum("openHistory","openDiscover","openDiscover","openGame","openDrama","openTopup","openFeed","openRewards"),S.object()),implement:(e,t)=>{L("callHostMethodAsync",{method:e,params:P({},t)})}});_a.registerCommand("RouterSDK.openSchema",sW);_a.registerCommand("RouterSDK.openPage",cW);_a.registerCommand("RouterSDK.closePage",lW);_a.registerCommand("RouterSDK.interceptSystemExit",uW);_a.registerCommand("RouterSDK.navigateToNativePage",dW);D("router.openSchema",{version:"1.1.10"});D("router.openPage",{version:"1.1.10"});D("router.closePage",{version:"1.1.10"});D("router.interceptSystemExit",{version:"1.1.18"});D("router.navigateToNativePage",{version:"1.1.19"})});function mW(e){sn("cpLoadProgressEvent",{progress:e},I.webviewId,!0),xi("CP_LOAD_PROGRESS",{progress:e})}var vh,pW,Nl,gh,VP,fW,hW,gW,$P=x(()=>{"use strict";R();Je();ce();V();bt();im();vh=K(),pW=Q("onLoadFinished",{implement:()=>{sn("cpLoadFinishEvent",{},I.webviewId,!0),xi("CP_LOAD_FINISH",{duration:performance.now()}),j("loadFinished",{duration:performance.now()})}}),Nl=null,gh=!1,VP=0,fW=200;hW=Q("onLoadProgress",{paramsSchema:S.tuple(S.number()),implement:e=>{Nl=e,gh||(gh=!0,requestAnimationFrame(function t(){let r=Date.now();r-VP>=fW?(Nl!==null&&(mW(Nl),VP=r,Nl=null),gh=!1):requestAnimationFrame(t)}))}}),gW=Q("onGameTTI",{paramsSchema:S.tuple(S.number().optional()),implement:()=>{sn("cpGameTTIEvent",{duration:performance.now()},I.webviewId,!0),xi("CP_GAME_TTI",{duration:performance.now()}),j("gameTTI",{duration:performance.now()})}});vh.registerCommand("RuntimeSDK.loadFinishedEvent",pW);vh.registerCommand("RuntimeSDK.loadProgressEvent",hW);vh.registerCommand("RuntimeSDK.gameTTIEvent",gW)});var vW,yW,bW,WP=x(()=>{"use strict";R();Je();V();vW=K(),yW="isNativeSupport",bW=Q(yW,{paramsSchema:S.tuple(S.object({version:S.string()})),implement:e=>{let t=I.sdkInfo.nativeSDKVersionCode,{version:r}=e;return r?{code:"SUCCESS",data:cg(xu(t!=null?t:0),r,">=")}:{code:"FAILURE",message:"[Jolibox SDK] api or versionCode is required",data:!1}}});vW.registerCommand("API.isNativeSupport",bW);D("isNativeSupport",{version:"1.1.46"})});var KP=h(yh=>{"use strict";Je();ce();R();R();V();var zP=K(),_W=$("callHostMethod",{paramsSchema:S.tuple(S.object({method:S.string(),params:S.object().optional().default({})})),implement:r=>g(yh,[r],function*({method:e,params:t}){if(!ve(e))throw new Vt("Method not supported",10001);let{errNo:n,errMsg:i,data:o}=yield L("callHostMethodAsync",{method:e,params:P({},t)});if(n!==0)throw new Vt(i,n);let c=o,{callHostMethodId:a}=c,s=Qe(c,["callHostMethodId"]);return P({},s)})});zP.registerCommand("API.callHostMethod",_W);D("callHostMethod",{version:"1.1.49"});var wW=$("userTrackAsync",{paramsSchema:S.tuple(S.object({event:S.string(),eventType:S.number(),params:S.object().optional().default({})})),implement:n=>g(yh,[n],function*({event:e,eventType:t,params:r}){if(!ve("userTrackAsync"))throw new Vt("Method not supported",10001);let{errNo:i,errMsg:o}=yield L("trackAsync",{event:e,eventType:t,data:P({},r),webviewId:I.webviewId});if(i!==0)throw new Vt(o,i)})});zP.registerCommand("API.track",wW);D("track",{version:"1.1.53"})});var XP=h(on=>{"use strict";R();Je();zf();Ur();nm();ce();var jn=K(),YP=Zc(),SW=$("purchaseGem",{paramsSchema:S.tuple(S.object({productId:S.string()})),implement:e=>g(on,null,function*(){var r,n;let t=yield YP.purchase(e.productId);if(t.code!=="SUCCESS")throw Ce({code:-1,msg:"[JoliboxSDK]: purchase gem failed: "+t.message});return{totalAmount:(n=(r=t.data)==null?void 0:r.totalAmount)!=null?n:""}})}),IW=$("getGemProducts",{paramsSchema:S.tuple(),implement:()=>g(on,null,function*(){var t,r;let e=(r=(t=yield YP.getProductsInfoWithBalance())==null?void 0:t.paymentChoices)!=null?r:[];return console.info("choices",e),{products:e.map(n=>{var i;return{productId:n.productId,totalAmountStr:(i=n.totalAmountStr)!=null?i:"",quantity:n.quantity}})}})}),EW=$("getSubscriptionPlans",{paramsSchema:S.tuple(),implement:()=>g(on,null,function*(){let e=yield Dn.getSubInfo();if(console.log("[PaymentAPI] getSubscriptionPlans result",e),!e)throw Ce({code:-1,msg:"[JoliboxSDK]: get subscription plans failed"});return{plans:e}})}),AW=$("flushSubInfoCache",{paramsSchema:S.tuple(),implement:()=>g(on,null,function*(){yield Dn.updateAllNativePriceCache()})}),QP=e=>g(on,null,function*(){var a;let{productId:t}=e,r=e.appStoreProductId,n=e.appStoreProductId,i=t;if(!e.appStoreProductId){let s=yield Dn.getTierByProductId(e.productId);if(!s)throw Ce({code:-1,msg:"[JoliboxSDK]: product not found"});r=s.basePlanId,n=s.appStoreProductId,i=s.nativeProductId}if(!r||!n||!i)throw Ce({code:-1,msg:"[JoliboxSDK]: product not found"});let o=yield Dn.subscribe({basePlanId:r,nativeProductId:i,appStoreProductId:n});return{result:o.result,subPlanId:o.subPlanId,errMsg:(a=o.message)!=null?a:""}}),CW=$("subscribe",{paramsSchema:S.tuple(S.object({productId:S.string(),appStoreProductId:S.string().optional()})),implement:QP}),kW=$("subscribeSpin",{paramsSchema:S.tuple(S.object({appStoreProductId:S.string().optional()})),implement:e=>g(on,null,function*(){return QP(B(P({},e),{productId:"jolibox_app_spin_sub"}))})});jn.registerCommand("PaymentSDK.purchaseGem",SW);jn.registerCommand("PaymentSDK.getGemProducts",IW);jn.registerCommand("PaymentSDK.getSubscriptionPlans",EW);jn.registerCommand("PaymentSDK.subscribe",CW);jn.registerCommand("PaymentSDK.subscribeSpin",kW);var xW=$("getSpinSubscriptionPrice",{paramsSchema:S.tuple(S.object({appStoreProductId:S.string()})),implement:e=>g(on,null,function*(){let{data:t}=yield de("requestSubscriptionPlansAsync",{appStoreProductIds:[e.appStoreProductId],type:"SPIN"});if(!t)throw Ce({code:-1,msg:"[JoliboxSDK]: get spin subscription price failed"});return{plans:Object.values(t).map(n=>{var i,o;return{basePlanId:n.basePlanId,productId:n.productId,formattedPrice:n.pricing.formattedPrice,originalPrice:n.pricing.originalPrice,trialDay:(o=(i=n.trial)==null?void 0:i.duration)!=null?o:0}})}})});jn.registerCommand("PaymentSDK.flushSubInfoCache",AW);jn.registerCommand("PaymentSDK.getSpinSubscriptionPrice",xW);D("payment.purchaseGem",{version:"1.2.9"});D("payment.getGemProducts",{version:"1.2.9"});D("payment.getSubscriptionPlans",{version:"1.2.9"});D("payment.subscribe",{version:"1.2.9"});D("payment.flushSubInfoCache",{version:"1.2.9"});D("payment.subscribeSpin",{version:"1.3.7"});D("payment.getSpinSubscriptionPrice",{version:"1.4.3"})});var eO=h(an=>{"use strict";R();Je();V();Ur();ce();os();bt();Hm();dt();var TW=()=>{let{data:e}=L("getNetworkStatusSync");return!!(e!=null&&e.isConnected)},PW={get:(e,t)=>Y(e,P({method:"GET",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data),post:(e,t)=>Y(e,P({method:"POST",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data)},OW={httpClient:PW,checkNetwork:TW,track:j,eventEmitter:dn,getWindowInfo:()=>({width:window.innerWidth*window.devicePixelRatio,height:window.innerHeight*window.devicePixelRatio,statusBarHeight:30}),handleLinkClicked:e=>{window.open(e,"_blank")},getContextInfo:()=>{var e,t,r,n,i,o,a,s,c,l;return{hostAppId:(t=(e=I.hostInfo)==null?void 0:e.aid)!=null?t:"1",deviceId:(r=I.deviceInfo.did)!=null?r:"",adId:(n=I.deviceInfo.adId)!=null?n:"",sessionId:(i=I.sessionId)!=null?i:"",userId:(a=(o=I.hostUserInfo)==null?void 0:o.uid)!=null?a:"",objectType:"TASK",objectId:I.mpId,testAdsMode:I.testAdsMode,channel:(s=I.joliSource)!=null?s:"",deviceBrand:I.deviceInfo.brand,deviceModel:I.deviceInfo.model,osType:I.platform==="android"?"ANDROID":I.platform==="ios"?"IOS":"PC",runtimeType:"APP",platform:1e3,joliSource:(c=I.joliSource)!=null?c:"",deviceInfo:{platform:I.platform,nativeSDKVersionCode:(l=I.sdkInfo.nativeSDKVersionCode)!=null?l:0}}}},bh=K(),ZP=Jn(reportError),RW=$("getCoinDetails",{paramsSchema:S.tuple(S.function().optional()),implement:e=>g(an,null,function*(){try{if(I.mpType!=="miniApp")return reportError(Ce({code:-1,msg:"[JoliboxSDK]: rewards info not supported in games. Only supported in mini apps."})),{code:"FAILURE",message:"[JoliboxSDK]: rewards info not supported in games. Only supported in mini apps."};if(!ve("requestCoinDetailsSync"))return reportError(Ce({code:-1,msg:"[JoliboxSDK]: rewards info not supported in this platform."})),{code:"FAILURE",message:"[JoliboxSDK]: rewards info not supported in this platform. lower than 1.7.1"};let r=e?ZP(e):(()=>{console.log("default update function called")}).bind(an),{errNo:n,errMsg:i,data:o}=L("requestCoinDetailsSync");if(n!==0)throw Ce({code:n!=null?n:-1,msg:i});return console.log("=====> sync data",o,n),L("requestCoinDetailsAsync").then(a=>{a.errNo==0&&a.data&&(r(a.data),console.log("=====> res.data",a.data))}),{code:"SUCCESS",message:"Successfully retrieved coin details",data:o}}catch(t){return{code:"FAILURE",message:"[JoliboxSDK]: Failed to get coin details: "+t.message}}})});bh.registerCommand("RewardsSDK.getCoinDetails",RW);D("rewards.getCoinDetails",{version:"1.3.2"});var NW=$("createRewardsAdsManager",{implement:()=>g(an,null,function*(){try{let e=new Li(OW);if(I.mpType!=="miniApp")throw Ce({code:-1,msg:"[JoliboxSDK]: createRewardsAdsManager not supported in games. Only supported in mini apps."});return{code:"SUCCESS",message:"Successfully created RewardsAdsManager",data:{init:()=>g(an,null,function*(){yield e.init(),e.adConfig({preloadAdBreaks:"on",sound:"off",onReady:()=>{}})}),showAd:(t,r=!1)=>g(an,null,function*(){e.adBreak({type:"reward",beforeReward:n=>{var i;n(),(i=t.onAdLoaded)==null||i.call(t)},adDismissed:()=>{var n;(n=t.onAdDismissed)==null||n.call(t)},adViewed:()=>{},adBreakDone:n=>{var a,s;let i=n.breakStatus,o=i==="frequencyCapped"||i==="other"||i==="error"||i==="noAdPreloaded";i==="viewed"&&(console.log("-----> complete watch ads"),!r&&wt.reporter({event:"COMPLETE_WATCH_ADS"}),(a=t.onAdRewarded)==null||a.call(t)),o&&(console.log("-----> no ad preloaded or error occurred",i),(s=t.onAdError)==null||s.call(t,new Error("No ad preloaded or error occurred: "+i)))}})})}}}catch(e){return{code:"FAILURE",message:"[JoliboxSDK]: Failed to create RewardsAdsManager"}}})});bh.registerCommand("Rewards.createRewardsAdsManager",NW);D("rewards.createRewardsAdsManager",{version:"1.3.4"});var DW=$("getLeaderBoardData",{paramsSchema:S.tuple(S.object({gameId:S.string(),onUpdate:S.function().optional()})),implement:e=>g(an,null,function*(){try{if(!ve("requestGameLeaderboardSync"))return{code:"FAILURE",message:"[JoliboxSDK]: getLeaderBoardData not supported in this platform."};let t=e.onUpdate?ZP(e.onUpdate):(()=>{console.log("default update function called")}).bind(an),{errNo:r,errMsg:n,data:i}=L("requestGameLeaderboardSync",{gameId:e.gameId});if(r!==0)throw Ce({code:r!=null?r:-1,msg:n});return L("requestGameLeaderboardAsync",{gameId:e.gameId}).then(o=>{var a;if(o.errNo===0&&o.data)t(o.data);else throw Ce({code:(a=o.errNo)!=null?a:-1,msg:o.errMsg})}).catch(o=>{console.error("Failed to fetch leaderboard data asynchronously: ",o)}),{code:"SUCCESS",message:"Successfully retrieved leaderboard data",data:i}}catch(t){return{code:"FAILURE",message:"[JoliboxSDK]: Failed to get leaderboard data: "+t.message}}})});bh.registerCommand("RewardsSDK.getLeaderBoardData",DW);D("rewards.getLeaderBoardData",{version:"1.3.9"})});var LW={};var Ece,xce,Dce,Lce,qce,tO=x(()=>{"use strict";rx();Ece=se(nx());ux();ro();dx();xce=se(mx());Bc();JP();HP();$P();WP();Dce=se(KP()),Lce=se(XP()),qce=se(eO())});var rO=Symbol.for("JOLIBOX_IMPLEMENT_INIT");if(window[rO])throw console.info("Jolibox Implement Already Initialized"),new Error("Jolibox Implement Already Initialized");window[rO]=!0;g(void 0,null,function*(){let[{config:e}]=yield Promise.all([Promise.resolve().then(()=>(ex(),Zk)),Promise.resolve().then(()=>(tO(),LW)),Promise.resolve().then(()=>(bt(),zg))]);e()});
|