@jolibox/implement 1.1.11-beta.5 → 1.1.12
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 +14 -17
- package/dist/common/context/index.d.ts +0 -4
- package/dist/common/context/url-parse.d.ts +1 -8
- package/dist/index.js +3 -3
- package/dist/index.native.js +4 -4
- package/dist/native/api/index.d.ts +0 -1
- package/dist/native/bootstrap/bridge.d.ts +1 -1
- package/dist/native/js-bridge/const.d.ts +0 -1
- package/dist/native/js-bridge/subscribe.d.ts +0 -2
- package/dist/native/js-bridge/types.d.ts +0 -4
- package/dist/native/js-core/jolibox-js-core.d.ts +3 -8
- package/implement.build.log +2 -2
- package/package.json +3 -3
- package/src/common/context/index.ts +3 -20
- package/src/common/context/url-parse.ts +1 -21
- package/src/native/api/index.ts +0 -1
- package/src/native/api/lifecycle.ts +4 -16
- package/src/native/bootstrap/bridge.ts +1 -10
- package/src/native/bootstrap/index.ts +2 -32
- package/src/native/js-bridge/const.ts +0 -2
- package/src/native/js-bridge/js-bridge.ts +2 -7
- package/src/native/js-bridge/subscribe.ts +1 -25
- package/src/native/js-bridge/types.ts +0 -10
- package/src/native/js-core/jolibox-js-core.ts +25 -29
- package/src/native/types/global.d.ts +0 -1
- package/src/native/types/native-method-map.d.ts +0 -29
- package/dist/native/api/navigate.d.ts +0 -1
- package/dist/native/bootstrap/retention.d.ts +0 -1
- package/dist/native/js-bridge/publish.d.ts +0 -1
- package/src/native/api/navigate.ts +0 -61
- package/src/native/bootstrap/retention.ts +0 -44
- package/src/native/js-bridge/publish.ts +0 -44
package/dist/index.native.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _o=Object.create;var Ne=Object.defineProperty,Io=Object.defineProperties,wo=Object.getOwnPropertyDescriptor,Ro=Object.getOwnPropertyDescriptors,Ao=Object.getOwnPropertyNames,Ce=Object.getOwnPropertySymbols,xo=Object.getPrototypeOf,It=Object.prototype.hasOwnProperty,fr=Object.prototype.propertyIsEnumerable;var pr=(e,t,r)=>t in e?Ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,h=(e,t)=>{for(var r in t||(t={}))It.call(t,r)&&pr(e,r,t[r]);if(Ce)for(var r of Ce(t))fr.call(t,r)&&pr(e,r,t[r]);return e},P=(e,t)=>Io(e,Ro(t));var ce=(e,t)=>{var r={};for(var n in e)It.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ce)for(var n of Ce(e))t.indexOf(n)<0&&fr.call(e,n)&&(r[n]=e[n]);return r};var f=(e,t)=>()=>(e&&(t=e(e=0)),t);var hr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),gr=(e,t)=>{for(var r in t)Ne(e,r,{get:t[r],enumerable:!0})},Po=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ao(t))!It.call(e,o)&&o!==r&&Ne(e,o,{get:()=>t[o],enumerable:!(n=wo(t,o))||n.enumerable});return e};var yr=(e,t,r)=>(r=e!=null?_o(xo(e)):{},Po(t||!e||!e.__esModule?Ne(r,"default",{value:e,enumerable:!0}):r,e));var v=(e,t,r)=>new Promise((n,o)=>{var s=c=>{try{a(r.next(c))}catch(u){o(u)}},i=c=>{try{a(r.throw(c))}catch(u){o(u)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,i);a((r=r.apply(e,t)).next())});function Co(e){return!!(e!=null&&e.__nativeBuffers__)}function Ee(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!Co(e))return e;let t=e.__nativeBuffers__;if(delete e.__nativeBuffers__,t)for(let r=0;r<t.length;r++){let n=t[r];if(n){let o;n.value?o=n.value:n.base64&&(o=No(n.base64)),typeof o!="undefined"&&o instanceof ArrayBuffer&&(e[n.key]=o)}}return e}function vr(e={},t=!1){let r=e,n=[];for(let[o,s]of Object.entries(r))if(s!==void 0&&s instanceof ArrayBuffer&&s.byteLength!==void 0){let i=t?{value:s,key:o}:{base64:Oo(s),key:o};n.push(i),delete r[o]}return n.length>0&&(r.__nativeBuffers__=n),r}var No,Oo,wt=f(()=>{"use strict";No=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=t.charCodeAt(o);return n.buffer};Oo=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let o=0;o<n;o++)t+=String.fromCharCode(r[o]);return btoa(t)}});function Uo(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function le(e){return typeof e=="string"}function B(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Er(e){return typeof e=="object"&&Array.isArray(e)}function Ie(e){return e===!0||e===!1}function Mo(e){return typeof e>"u"}function Lo(e){return Mo(e)||e===null}function Sr(e){return typeof e=="function"}function _r(e){return B(e)&&Sr(e.then)}function Ir(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}function wr(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(o,s){for(let i in s)if(Object.prototype.hasOwnProperty.call(s,i)){let a=o[i],c=s[i],u=r(a,c,i,o,s);u!==void 0?o[i]=u:br(c)&&br(a)?o[i]=n(h({},a),c):Array.isArray(c)&&Array.isArray(a)?o[i]=[...a,...c]:o[i]=c}return o}return n(e,t)}function br(e){return e&&typeof e=="object"&&e.constructor===Object}function Rr(e,t){if(Array.isArray(e))return e.concat(t)}function we(e,t,r={}){let n=null,o,s,i,{leading:a=!1,trailing:c=!0}=r,u=()=>(i=e.apply(s,o),o=void 0,s=void 0,i),l=function(...m){o=m,s=this;let p=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,c&&!p&&u()},t),p)return u()};return l.cancel=()=>{n&&clearTimeout(n),n=null,o=s=void 0},l.flush=()=>{if(n)return clearTimeout(n),n=null,u()},l}function jo(e,t){return(...r)=>t(e,...r)}function Me(e){return t=>jo(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(o){e(new Re(`${o}`))}})}function Se(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function es(e){return new Promise(t=>Lr(e)(t))}function Lr(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function ts(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new _e(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}function ns(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)os(e[n],t[n])}function os(e,t){if(le(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Sr(t)){try{if(e instanceof t)return}catch(r){}if(!Lo(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function O(){if(globalThis[At])return globalThis[At];let e=new Fe,t=new Pt,r={registerCommand(n,o,s){e.registerCommand({id:n,handler:o,metadata:s})},executeCommand(n,...o){return t.executeCommand(n,...o)},excuteCommandSync(n,...o){return t.executeCommandThowErr(n,...o)}};return globalThis[At]=r,r}var kr,Do,Fo,Tr,Q,Bo,Ct,ue,Ar,xr,Re,Pr,Cr,Nr,Or,Dr,Ae,Ue,Nt,$,Fr,Jo,Ot,Ho,Dt,$o,Vo,Oe,Ko,qo,Go,Ur,Ft,zo,Wo,Qo,Mr,te,C,Yo,Xo,De,_e,q,xt,Zo,Rt,rs,re,Fe,Pt,At,S=f(()=>{"use strict";kr=Object.defineProperty,Do=Object.getOwnPropertyDescriptor,Fo=(e,t)=>{for(var r in t)kr(e,r,{get:t[r],enumerable:!0})},Tr=(e,t,r,n)=>{for(var o=n>1?void 0:n?Do(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&kr(t,r,o),o};Q=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};Bo=(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))(Bo||{}),Ct=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},ue=class extends Ct{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Ar=class extends Ct{constructor(){super(...arguments),this.kind="USER_ERROR"}},xr=class extends Ar{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Re=class extends Ar{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Pr=class extends ue{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Cr=class extends ue{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},Nr=class extends ue{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},Or=class extends ue{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Dr=class extends ue{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Ae=class extends Ct{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},Ue=class extends ue{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},Nt=class extends ue{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};$={log:Se("log"),warn:Se("warn"),info:Se("info"),error:Se("error"),debug:Se("debug")};Object.assign(globalThis,{logger:$});Fr=Symbol.for("Jolibox.canIUseMap"),Jo={};globalThis[Fr]=Jo;Ot={get config(){return globalThis[Fr]}},Ho=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Ho||{}),Dt=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Dt||{}),$o=(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))($o||{}),Vo=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),Oe={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Ko=()=>Oe.isiOS?"iOS":Oe.isAndroid?"Android":Oe.isMac?"Mac":Oe.isFacebook?"Facebook":"PC",qo="device_id",Go="advertising_id",Ur=e=>(localStorage.getItem(e)||localStorage.setItem(e,Vo()),localStorage.getItem(e)),Ft=()=>Ur(qo),zo=()=>Ur(Go),Wo=e=>e.charAt(0).toUpperCase()+e.slice(1),Qo=()=>{var t;let e=new URLSearchParams(window.location.search);return Wo((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},Mr=e=>{let t="JoliboxWebSDK",r=Ko(),n=navigator.language,o=Ft(),s=zo();return`${t} (${Qo()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},C=(te=class{constructor(t){this.element=t,this.next=te.Undefined,this.prev=te.Undefined}},te.Undefined=new te(void 0),te),Yo=class{constructor(){this._first=C.Undefined,this._last=C.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===C.Undefined}clear(){let e=this._first;for(;e!==C.Undefined;){let t=e.next;e.prev=C.Undefined,e.next=C.Undefined,e=t}this._first=C.Undefined,this._last=C.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new C(e);if(this._first===C.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==C.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==C.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==C.Undefined&&e.next!==C.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===C.Undefined&&e.next===C.Undefined?(this._first=C.Undefined,this._last=C.Undefined):e.next===C.Undefined?(this._last=this._last.prev,this._last.next=C.Undefined):e.prev===C.Undefined&&(this._first=this._first.next,this._first.prev=C.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==C.Undefined;)yield e.element,e=e.next}},Xo=0,De=class{constructor(e){this.value=e,this.id=Xo++}},_e=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof De&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var o,s,i,a,c,u;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let n=new De(t);this._listeners?this._listeners instanceof De?this._listeners=[this._listeners,n]:this._listeners.push(n):((s=(o=this.options)==null?void 0:o.onWillAddFirstListener)==null||s.call(o,this),this._listeners=n,(a=(i=this.options)==null?void 0:i.onDidFirstListener)==null||a.call(i,this)),(u=(c=this.options)==null?void 0:c.onDidAddListener)==null||u.call(c,this),this._size++}),this._event}_deliver(e,t){var n;if(!e)return;let r=((n=this.options)==null?void 0:n.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(o){r(o)}}fire(e){this._listeners&&(this._listeners instanceof De?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},q=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var s;let r=(s=this.listeners.get(e))!=null?s:new _e,n=i=>t(...i.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let o=this.cachedEventQueue.get(e);if(o)for(;o.size>0;)r.fire(h({event:e},o.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Yo,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},xt={};Fo(xt,{None:()=>Zo,filter:()=>ts,once:()=>Lr,toPromise:()=>es});Zo=()=>{console.log("[Jolibox SDK] None Event")};Rt=Symbol.for("Jolibox.hostEmitter"),rs=()=>{let e=new q;return globalThis[Rt]||(globalThis[Rt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[Rt]},re=rs();Fe=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new _e,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return ns(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};Fe=Tr([Ir],Fe);Pt=class{constructor(){this._onWillExecuteCommand=new _e,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new _e,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Fe,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Uo(3e4)),this._starActivation}executeCommand(e,...t){return v(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),xt.toPromise(xt.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};Pt=Tr([Ir],Pt);At=Symbol.for("Jolibox.commands")});function M(e,t={}){Ut.emit("ERROR_REPORT",{error:e,options:t})}var Ut,de,G=f(()=>{"use strict";S();S();Ut=new q,de=new q;M.debounce=we(M,50,{leading:!0})});function Le(e,t){return`[${e}]:${t}`}var me,Mt,se=f(()=>{"use strict";G();S();G();me=(e,t)=>{var r,n;return new Ae((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Mt=e=>new xr(e)});var pe,Br,jr,Jr,Be,je=f(()=>{"use strict";pe="custom_event_",Br=[],jr=[],Jr=["env","createRequestTask","login"],Be="__batch_event__"});function $r(e,t){Hr||(Lt=new fe({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),Bt=new fe({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),jt=new fe({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),t("onJoliboxEnterBackground",()=>{Lt.flush(),Bt.flush(),jt.flush()}),Hr=!0);function r(o){var b,g;let{method:s,args:i,startTime:a,isForeground:c,errMsg:u=`${s}:fail no errMsg`,errNo:l=0,__timing:m={receiveJSInvoke:0,invokeCallback:0}}=o,{receiveJSInvoke:p,invokeCallback:k}=m,I=(g=(b=u.match(/\S:(\S+)\s?/))==null?void 0:b[1])!=null?g:"fail";Lt.report({status:I,method:n(s,i),errNo:`${l}`,errMsg:u,isForeground:c,duration:Date.now()-a}),a&&p&&k&&(Bt.report({status:I,method:s,isForeground:c,duration:Number((p-a).toFixed(3))}),jt.report({status:I,method:s,isForeground:c,duration:Number((Date.now()-k).toFixed(3))}))}function n(o,s){return(o==="callHostMethod"||o==="callHostMethodSync")&&s!=null&&s.method?`${o}-${s.method}`:o}return r}var ss,fe,Hr,Lt,Bt,jt,Jt=f(()=>{"use strict";S();ss=e=>e==="pv"?e:"default",fe=class{constructor(t){this.interval=30;this.lastReportTime=0;this.cache={};let{reporter:r,interval:n=30,eventName:o,tagNameOrder:s,metricName:i,type:a}=t;this.reporter=r,this.interval=n,this.eventName=o,this.tagNameOrder=s,this.metricName=i,this.type=ss(a)}report(t){this.type==="pv"?this.addPVPoint(t):this.addPoint(t),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(t){if(Object.keys(this.cache).length){if(t){this.reporter(this.processPoints(this.cache)),this.clearPoints();return}this.lastReportTime=this.lastReportTime||Date.now(),Date.now()-this.lastReportTime>=this.interval*1e3&&(this.reporter(this.processPoints(this.cache)),this.clearPoints(),this.lastReportTime=Date.now())}}addPoint(t){let r=(n,o,s,i)=>{let a=o.shift();if(a){let c=i[a];n[c]||(n[c]={}),r(n[c],o,s,i)}else n[s]||(n[s]=[]),n[s].push(i[s])};r(this.cache,[...this.tagNameOrder],this.metricName,t)}addPVPoint(t){let r=(o,s,i,a)=>{let c=s.shift();if(!c&&B(a))throw new Ue(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(c){let u=[];if(B(a))u.push(...Object.keys(a));else if(le(a)){if(s.length>0)throw new Ue(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);u.push(a)}else throw new Ue(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);u.forEach(l=>{o[l]||(o[l]={});let m=B(a)?a[l]:a;r(o[l],[...s],i,m)})}else o[i]?o[i]++:o[i]=1},n={point:t,metricName:this.metricName,tagNameOrder:this.tagNameOrder};r(this.cache,[...this.tagNameOrder],this.metricName,t)}processPoints(t){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:t}}clearPoints(){this.cache={}}},Hr=!1});function Kr(e,t){let r=0,n=!0,o=new Map,s=$r(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,Ht.forEach(p=>v(this,[p],function*({method:u,args:l,resolve:m}){let k=yield a(u,l);m(k)})),Ht.length=0});let i=(u,l)=>{let m=o.get(Number(u));if(!m)return;let p=Ee(l);m(p),o.delete(Number(u))},a=(u,l)=>{var U,w;let m=Date.now(),p=`${n}`;r+=1;let k=new Q;if(o.set(r,k.resolve),!n&&jr.includes(u))return new Promise(x=>{Ht.push({method:u,args:l,resolve:x})});let b=P(h({},{method:u,startTime:m,args:l,isForeground:p}),{invokeType:"js-bridge"}),g=!is&&Br.includes(u),T=vr(l,g),R=g?T:JSON.stringify(T),_;if(u.endsWith("Sync")||Jr.includes(u)?_=(U=e.call)==null?void 0:U.call(e,u,T,r):typeof R=="string"?_=e.invoke(u,R,r):_=(w=e.call)==null?void 0:w.call(e,u,R,r),_){try{typeof _=="string"&&(_=JSON.parse(_)),_=Ee(_)}catch(x){$.error(x)}return o.delete(r),_.errorCode&&(_.errorCode=Le(u,_.errorCode)),s(h(h({},b),_)),_}return u.endsWith("Sync")&&o.delete(r),k.promise.then(x=>(x.errorCode&&(x.errorCode=Le(u,x.errorCode)),s(h(h({},b),x)),x))};return{invokeNative:a,applyNative:(u,l)=>{let m=a(u,l);return _r(m)?m.then(p=>Vr(u,p)):Vr(u,m)},invokeHandler:i}}function Vr(e,t){if(!B(t)){$.warn(`[Jolibox SDK]${e} no response value`);return}let a=t,{errMsg:r,errNo:n,errorType:o,errorCode:s}=a,i=ce(a,["errMsg","errNo","errorType","errorCode"]);if(r&&r!==`${e}:ok`)throw new Nr(r,n,o,s);return i}var Ht,is,qr=f(()=>{"use strict";wt();S();se();je();Jt();Ht=[],is=!1});function Gr(e){let t=new q,r=new q,n=new fe({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}});return t.on("onJoliboxEnterBackground",()=>{n.flush()}),{onNative:t.on.bind(t),offNative:t.off.bind(t),subscribe:r.on.bind(r),unsubscribe:r.off.bind(r),subscribeHandler(o,s,i){let a=Ee(s),c;if(a.__extra){c=a.params;let{type:u,startTime:l}=a.__extra;n.report({type:u,event:o,duration:Date.now()-l})}else c=a;if(o===Be){c.forEach(l=>{let[m,p]=l;try{r.emit(m.slice(pe.length),p,i)}catch(k){}});return}if(o.startsWith(pe)){r.emit(o.slice(pe.length),c,i);return}t.emit(o,c,i)}}}var zr=f(()=>{"use strict";S();wt();Jt();je()});function Wr(e){let t=new Map,r;return(o,s,i,a)=>{if(a){let u=i?[i]:"*";e.publish(`${pe}${o}`,s,u);return}r||(r=Promise.resolve().then(()=>{t.forEach((u,l)=>{try{let m=l?[l]:"*";e.publish(Be,u,m)}catch(m){}}),r=void 0,t.clear()}));let c=t.get(i);c||(c=[],t.set(i,c)),c.push([`${pe}${o}`,s])}}var Qr=f(()=>{"use strict";je()});function $t(e){let{subscribeHandler:t,onNative:r,offNative:n,subscribe:o,unsubscribe:s}=Gr(e),{invokeNative:i,invokeHandler:a,applyNative:c}=Kr(e,r),u=Wr(e);return{invokeHandler:a,subscribeHandler:t,applyNative:c,invokeNative:i,onNative:r,offNative:n,publish:u,subscribe:o,unsubscribe:s}}var Yr=f(()=>{"use strict";qr();zr();Qr()});var Xr=f(()=>{"use strict"});var Zr=f(()=>{"use strict";Yr();Xr()});function ge(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var Je=f(()=>{"use strict"});var ie,z,en,tn=f(()=>{"use strict";S();Je();G();z={trigger(){},exit(){return Promise.resolve(!1)},onReady(e){z.trigger=e},doExit(e){z.exit=e}},en=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)M(new Cr("native env failed"));else{let{data:t}=JSON.parse(e);return t!=null?t:void 0}};if(window.webkit){let e=window.webkit.messageHandlers,t=(o="")=>{z.trigger(),e.onDocumentReady.postMessage({path:o})};ie={onDocumentReady:t,doExit:o=>v(void 0,null,function*(){let s=yield z.exit();e.doExit.postMessage({uuid:o,shouldInterrupt:s})}),invoke(o,s,i){e.invoke.postMessage({event:o,paramsString:s,callbackId:i})},publish(o,s,i){let a=ge(s,"joliboxJSCore");window.prompt("publish",JSON.stringify({event:o,paramsString:JSON.stringify(a),webviewIds:i}))},call(o,s,i){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(s),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:en};globalThis.joliboxJSCore=h({},n)}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(o="")=>{z.trigger(),e.onDocumentReady(JSON.stringify({path:o}))};ie={onDocumentReady:t,invoke(o,s,i){e.invoke(JSON.stringify({event:o,paramsString:s,callbackId:i}))},doExit:o=>v(void 0,null,function*(){let s=yield z.exit();e.doExit(JSON.stringify({uuid:o,shouldInterrupt:s}))}),publish(o,s,i){let a=ge(s,"joliboxJSCore");e.publish({event:o,paramsString:JSON.stringify(a),webviewIds:i})},call(o,s,i){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(s),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:en};globalThis.joliboxJSCore=h({},n)}});function Vt(){globalThis.onmessage=function(e){e.data==="msg:setup"&&([ye]=e.ports,ye.onmessage=function(t){let r=JSON.parse(t.data);r[0]==="publish"?globalThis.ttJSBridge.subscribeHandler(r[1],r[2]):r[0]==="invoke"&&globalThis.ttJSBridge.invokeHandler(r[1],r[2])},ye.publish=function(t,r){let n=ge(r,"messagePort");ye.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},ye.postMessage("msg:setup:ok"))}}var ye,rn=f(()=>{"use strict";Je()});var He=f(()=>{"use strict";tn();rn();Je()});var on,as,sn,nn,V,A,Y,Ha,cs,an,cn,$a,j=f(()=>{"use strict";Zr();He();se();S();He();on=ie;if(!on)throw new Or("No joliboxJScore is found, native bridge not found.");Vt();as=h({},on),sn=$t(as),{invokeHandler:nn}=sn,{applyNative:V,invokeNative:A,onNative:Y,offNative:Ha,subscribeHandler:cs,publish:an,subscribe:cn,unsubscribe:$a}=sn;globalThis.joliboxJSBridge={callHandler:nn,invokeHandler:nn,subscribeHandler:cs}});var Kt,qt,ln,un,dn=f(()=>{"use strict";S();G();Kt=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch(o){return{}}},qt=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},ln=e=>{var t;try{let o=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(o!=null&&o.length){let[s,i,a]=o;return{headerJson:Kt(s),payloadJson:Kt(i),signature:Kt(a)}}else throw"joli_source is missing"}catch(r){return M(new Pr(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},un=e=>{let{headerJson:t,payloadJson:r,signature:n}=e,o=qt(t),s=qt(r),i=qt(n);return`${o}.${s}.${i}`}});var ls,$e,mn,Gt=f(()=>{"use strict";S();ls="1.1.11-beta.5",$e=()=>ls,mn=()=>{let e=$e();return`${Mr(e)}`}});var us,pn,zt,fn,L,ds,y,J=f(()=>{"use strict";S();dn();Gt();S();us={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:Ft(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:$e()},schema:window.location.href,platform:"h5"},zt=(pn=globalThis.joliboxJSCore)==null?void 0:pn.env,L=Object.assign({},(fn=zt==null?void 0:zt())!=null?fn:us),ds=()=>{var p,k,I,b,g,T,R,_,U;let{payloadJson:e,headerJson:t,signature:r}=L.schema.length?ln(L.schema):{},n=`${L.deviceInfo.did}-${new Date().getTime()}`,s=new URL(L.schema.length?L.schema:window.location.href).searchParams,i=(I=(k=(p=s.get("mpId"))!=null?p:s.get("appId"))!=null?k:s.get("gameId"))!=null?I:"",a=(T=(g=(b=L.clientSessionId)!=null?b:e==null?void 0:e.sessionId)!=null?g:s.get("sessionId"))!=null?T:n,c=!!((R=e==null?void 0:e.testAdsMode)!=null?R:s.get("testAdsMode")==="true"),u=(U=(_=e==null?void 0:e.joliboxEnv)!=null?_:s.get("joliboxEnv"))!=null?U:"production",l=u==="staging",m=t==null?void 0:t.channel;return{get testMode(){return l},get testAdsMode(){return c},get joliboxEnv(){return u},get joliSource(){var w;return(w=s.get("joliSource"))!=null?w:null},get mpId(){var w;return(w=i!=null?i:e==null?void 0:e.id)!=null?w:""},get mpVersion(){var w;return(w=t==null?void 0:t.ver)!=null?w:$e()},get mpType(){var w,x;return(x=(w=t==null?void 0:t.__mpType)!=null?w:e==null?void 0:e.__mpType)!=null?x:"game"},get platform(){var w;return(w=L.platform)!=null?w:L.deviceInfo.platform},get deviceInfo(){return L.deviceInfo},get sdkInfo(){return L.sdkInfo},get hostInfo(){return L.hostInfo},get hostUserInfo(){return L.hostUserInfo},get sessionId(){var w,x;return(x=(w=L.clientSessionId)!=null?w:a)!=null?x:n},get channel(){return m},get webviewId(){var w;return(w=L.webviewId)!=null?w:-1},get shouldInterupt(){return e==null?void 0:e.__shouldInterupt},get from(){return e==null?void 0:e.__from},onEnvConfigChanged:w=>{wr(L,w,Rr)},encodeJoliSourceQuery:w=>{var x;return t&&r?un({headerJson:t,payloadJson:h(h({},e),w),signature:r}):(x=s.get("joliSource"))!=null?x:""}}},y=ds()});var Wt,gn,ms,ps,hn,fs,yn=f(()=>{"use strict";S();G();J();S();Wt=!1,gn=(e,t)=>e==null?!1:t in e,ms=e=>gn(e,"kind"),ps=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},hn=(e,t={},r)=>{var s,i,a;let n={user_id:(i=(s=y.hostUserInfo)==null?void 0:s.uid)!=null?i:"",device_id:(a=y.deviceInfo.did)!=null?a:"",timestamp:Date.now(),tag:ps(e.name)},o=P(h({},n),{env:t.environment,isFromUser:r});r?de.emit("GLOBAL_USER_ERROR",e,o):de.emit("GLOBAL_ERROR",e,o)},fs=e=>gn(e,"kind")&&e.kind==="USER_ERROR";Ut.on("ERROR_REPORT",({error:e,options:t})=>{if(Wt)return;Wt=!0;let r=ms(e)&&e.raw?e.raw:e;try{let n=fs(e);hn(e,t,n)}catch(n){let o=n instanceof Error?n.message:String(n),s=new Nt(`${o}, origin error: ${r.message}`);$.error(s),hn(new Nt(s.message),{environment:t.environment},!1)}finally{Wt=!1}})});var vn=f(()=>{"use strict";yn();se();S();j();de.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};A("trackAsync",{event:"reportJsError",data:r})});de.on("GLOBAL_USER_ERROR",(e,t)=>{$.log("UserError",e,t)})});var Qt=f(()=>{"use strict"});function bn(e,t){let r=(n,o,s)=>{let i=P(h({tag:n},t),{extra:h({},o)});n=="globalJsError"?M(new Dr(JSON.stringify(i))):e("systemLog",i,s)};return r.debounce=we(r,500,{leading:!0}),r}function kn(e){let t=(r,n,o)=>{var a;let s=(a=o&&JSON.stringify(o))!=null?a:0,i={speed_value_type:r,total_duration:n};s&&Object.assign(i,{extra:s}),e("joliboxSpeedAnalysis",i)};return t.debounce=we(t,500,{leading:!0}),t}var Tn=f(()=>{"use strict";S();S();G()});function En(e,t){let r=bn(e,t),n=kn(r);return{track:r,trackPerformance:n}}var Sn=f(()=>{"use strict";Tn()});var _n=f(()=>{"use strict";J();S();S()});var In=f(()=>{"use strict";Sn();Qt();_n()});var Ve,wn=f(()=>{"use strict";Ve=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,o,s=!1,i=0,a=()=>{if(!s)return;let k=Date.now(),I=k-r;I>=this.interval&&(this.visible&&(i+=I,t(i)),r=k),n=requestAnimationFrame(a)},c=()=>{l(),r=Date.now(),o=window.setInterval(()=>{if(!s)return;let k=Date.now();k-r>=this.interval&&(r=k)},this.interval)},u=()=>{m(),r=Date.now(),n=requestAnimationFrame(a)},l=()=>{n&&(cancelAnimationFrame(n),n=0)},m=()=>{o&&(clearInterval(o),o=0)};this.eventEmitter.on("visible",k=>{s&&(console.log("visible",k),k?u():c())});let p=this.visible;return{start(){s||(s=!0,p?u():c())},stop(){s=!1,l(),m()}}}}});var Yt=f(()=>{"use strict"});function An(e,t,r){let{response:n,startTime:o,endTime:s,requestFrom:i}=r,{errMsg:a="",profile:c={}}=n,l={duration:s-o,request_type:e,url:t.split("?")[0],result:r.state,error_msg:r.state==="fail"?a:"",socket_reused:c.socketReused?1:0,request_from:i};(i==="public"&&Rn<gs||i==="inner")&&(l.joli_request_number=Rn++,setTimeout(()=>{K("joliboxNetRequestResult",l)},500))}var Rn,gs,xn=f(()=>{"use strict";Yt();ae();Rn=0,gs=10});function Ke(e,t,r){var c,u,l;let n=new Map,o=(c=r==null?void 0:r.baseUrl)!=null?c:"https://api.jolibox.com",s=(u=r==null?void 0:r.type)!=null?u:"public",i=(l=r==null?void 0:r.defaultHeaders)!=null?l:{};return Y("onRequestTaskStateChange",m=>{if(typeof m.requestTaskId!="string")return;let p=n.get(m.requestTaskId);if(p)if(m.state==="success"){let k=m,{requestTaskId:b,state:g}=k,T=ce(k,["requestTaskId","state"]);p.resolve(T),n.delete(b)}else if(m.state==="fail"){let I=m,{requestTaskId:b,state:g}=I,T=ce(I,["requestTaskId","state"]);p.reject(T),n.delete(b)}else $.warn("onRequestTaskStateChange unknown event",m)}),re.on("onLoginComplete",({isLogin:m,token:p})=>{m&&p&&(i["X-JOLI-TOKEN"]=p)}),(k,...I)=>v(this,[k,...I],function*(m,p={}){let b=Date.now(),g=ys(m,P(h({},p),{baseUrl:o})),{method:T="GET",responseType:R="text",dataType:_="json",timeout:U,enableCache:w=!1,appendHostCookie:x=!0}=p,Te=Object.assign({"content-type":"application/json"},i,p.header),oe={url:g,method:T,header:Te,enableCache:w,responseType:R,appendHostCookie:x};if(T=="POST"||T=="PUT"){let W=bs(p.data,Te["content-type"]);oe.data=W}U&&Object.assign(oe,{timeout:U});let{data:{requestTaskId:_t}}=A(e,oe);if(typeof _t!="string")throw me({code:-1,msg:"requestTaskId is not a string"});let mr=(W,ee)=>{An("request",g,{state:W,startTime:b,endTime:Date.now(),params:oe,response:ee,requestId:_t,requestFrom:s=="public"?"public":"inner"})},{resolve:vo,reject:bo,promise:ko}=new Q;n.set(_t,{resolve:vo,reject:bo});try{let W=yield ko;mr("success",W);let{data:ee}=W;return _==="json"&&typeof ee=="string"&&(ee=vs(ee)),{url:g,timeout:U,method:T,response:P(h({},W),{data:ee})}}catch(W){let ee=W;if(B(ee)){let{errMsg:Pe,prefetchDetail:To,isPrefetch:Eo,errNo:So}=ee;le(Pe)&&(mr("fail",{errMsg:Pe,isPrefetch:Eo,prefetchDetail:To}),M(me({code:-1,msg:Pe},{errNo:So,errMsg:Pe})))}throw W}})}function vs(e){try{return JSON.parse(e.trim())}catch(t){return e}}function bs(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 ys,Xt=f(()=>{"use strict";S();xn();Yt();j();G();se();ys=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t==null?void 0:t.query,o=new URLSearchParams(r).toString();return t!=null&&t.baseUrl?`${t.baseUrl}${e}${o?`?${o}`:""}`:`${e}${o?`?${o}`:""}`}});var Zt,Pn,X,qe=f(()=>{"use strict";Gt();Xt();J();Zt={"x-user-agent":mn()};(Pn=y.hostUserInfo)!=null&&Pn.token&&(Zt["x-joli-token"]=y.hostUserInfo.token);y.joliSource&&(Zt["x-joli-source"]=y.joliSource);X=Ke("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:y.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:Zt})});var Ge,Cn=f(()=>{"use strict";J();wn();qe();j();Ge=class extends Ve{constructor(t,r,n){super(r,n),this.gameId=y.mpId,this.sessionId=y.sessionId,this.track=t}reporter(t){return v(this,null,function*(){let{event:r,params:n}=t,o=[];o.push(X("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:h({gameId:this.gameId,sessionId:this.sessionId},n)}})),yield Promise.all(o)})}reportToNative(t){return v(this,null,function*(){let{event:r,params:n}=t;yield V("userTrackAsync",{event:r,params:h({},n),gameId:this.gameId})})}tracker(t,r=null){this.track(t,r)}}});var Un={};gr(Un,{nativeTaskEmitter:()=>xe,taskTracker:()=>H,track:()=>K,trackPerformance:()=>Dn});var ks,Nn,On,K,Dn,Fn,xe,H,ae=f(()=>{"use strict";vn();S();Qt();In();J();Cn();j();ks=(e,t,r)=>{var i,a;let n=t,o=B(n.extra)?n.extra:le(n.extra)?JSON.parse(n.extra):{},s=P(h({},o),{mp_id:(i=n.mp_id)!=null?i:"",mp_version:(a=n.mp_version)!=null?a:""});A("trackAsync",{event:e,data:s,webviewId:r})},{track:K,trackPerformance:Dn}=En(ks,{type:Dt.AppSDK,platform:"native",jssdk_version:(On=(Nn=y.sdkInfo)==null?void 0:Nn.jssdkVersion)!=null?On:"1.0.0",mp_id:y.mpId,mp_version:y.mpVersion}),Fn=O();Fn.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{Dn(e,t,r)});Fn.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{K(e,t)});xe=new q,H=new Ge(K,xe)});function Mn(){let e=null,t=window.fetch,r=()=>{e=document.createElement("style"),e.setAttribute("data-jolibox-sdk","default-styles");let s=`
|
|
1
|
+
var lo=Object.create;var Ae=Object.defineProperty,uo=Object.defineProperties,mo=Object.getOwnPropertyDescriptor,po=Object.getOwnPropertyDescriptors,fo=Object.getOwnPropertyNames,Re=Object.getOwnPropertySymbols,ho=Object.getPrototypeOf,vt=Object.prototype.hasOwnProperty,ar=Object.prototype.propertyIsEnumerable;var ir=(e,t,r)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))vt.call(t,r)&&ir(e,r,t[r]);if(Re)for(var r of Re(t))ar.call(t,r)&&ir(e,r,t[r]);return e},x=(e,t)=>uo(e,po(t));var ae=(e,t)=>{var r={};for(var n in e)vt.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Re)for(var n of Re(e))t.indexOf(n)<0&&ar.call(e,n)&&(r[n]=e[n]);return r};var g=(e,t)=>()=>(e&&(t=e(e=0)),t);var cr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),lr=(e,t)=>{for(var r in t)Ae(e,r,{get:t[r],enumerable:!0})},go=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of fo(t))!vt.call(e,o)&&o!==r&&Ae(e,o,{get:()=>t[o],enumerable:!(n=mo(t,o))||n.enumerable});return e};var dr=(e,t,r)=>(r=e!=null?lo(ho(e)):{},go(t||!e||!e.__esModule?Ae(r,"default",{value:e,enumerable:!0}):r,e));var b=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{a(r.next(l))}catch(d){o(d)}},i=l=>{try{a(r.throw(l))}catch(d){o(d)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,i);a((r=r.apply(e,t)).next())});function yo(e){return!!(e!=null&&e.__nativeBuffers__)}function ke(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!yo(e))return e;let t=e.__nativeBuffers__;if(delete e.__nativeBuffers__,t)for(let r=0;r<t.length;r++){let n=t[r];if(n){let o;n.value?o=n.value:n.base64&&(o=vo(n.base64)),typeof o!="undefined"&&o instanceof ArrayBuffer&&(e[n.key]=o)}}return e}function ur(e={},t=!1){let r=e,n=[];for(let[o,s]of Object.entries(r))if(s!==void 0&&s instanceof ArrayBuffer&&s.byteLength!==void 0){let i=t?{value:s,key:o}:{base64:bo(s),key:o};n.push(i),delete r[o]}return n.length>0&&(r.__nativeBuffers__=n),r}var vo,bo,bt=g(()=>{"use strict";vo=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=t.charCodeAt(o);return n.buffer};bo=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let o=0;o<n;o++)t+=String.fromCharCode(r[o]);return btoa(t)}});function Eo(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ce(e){return typeof e=="string"}function M(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function hr(e){return typeof e=="object"&&Array.isArray(e)}function gr(e){return e===!0||e===!1}function So(e){return typeof e>"u"}function Io(e){return So(e)||e===null}function yr(e){return typeof e=="function"}function vr(e){return M(e)&&yr(e.then)}function br(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}function kr(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(o,s){for(let i in s)if(Object.prototype.hasOwnProperty.call(s,i)){let a=o[i],l=s[i],d=r(a,l,i,o,s);d!==void 0?o[i]=d:mr(l)&&mr(a)?o[i]=n(y({},a),l):Array.isArray(l)&&Array.isArray(a)?o[i]=[...a,...l]:o[i]=l}return o}return n(e,t)}function mr(e){return e&&typeof e=="object"&&e.constructor===Object}function Tr(e,t){if(Array.isArray(e))return e.concat(t)}function Se(e,t,r={}){let n=null,o,s,i,{leading:a=!1,trailing:l=!0}=r,d=()=>(i=e.apply(s,o),o=void 0,s=void 0,i),c=function(...m){o=m,s=this;let p=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,l&&!p&&d()},t),p)return d()};return c.cancel=()=>{n&&clearTimeout(n),n=null,o=s=void 0},c.flush=()=>{if(n)return clearTimeout(n),n=null,d()},c}function Ro(e,t){return(...r)=>t(e,...r)}function Oe(e){return t=>Ro(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(o){e(new _o(`${o}`))}})}function Te(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function Ho(e){return new Promise(t=>Nr(e)(t))}function Nr(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Jo(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new Ee(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}function $o(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Ko(e[n],t[n])}function Ko(e,t){if(ce(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(yr(t)){try{if(e instanceof t)return}catch(r){}if(!Io(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function O(){if(globalThis[Tt])return globalThis[Tt];let e=new Pe,t=new St,r={registerCommand(n,o,s){e.registerCommand({id:n,handler:o,metadata:s})},executeCommand(n,...o){return t.executeCommand(n,...o)},excuteCommandSync(n,...o){return t.executeCommandThowErr(n,...o)}};return globalThis[Tt]=r,r}var pr,ko,To,fr,ne,wo,It,le,Er,Sr,_o,Ir,wr,_r,Rr,Ar,Ie,Ne,wt,j,xr,Ao,_t,xo,Rt,Co,Po,xe,No,Oo,Do,Cr,At,Fo,Uo,Mo,Pr,X,R,Lo,Bo,Ce,Ee,z,Et,jo,kt,Vo,Z,Pe,St,Tt,S=g(()=>{"use strict";pr=Object.defineProperty,ko=Object.getOwnPropertyDescriptor,To=(e,t)=>{for(var r in t)pr(e,r,{get:t[r],enumerable:!0})},fr=(e,t,r,n)=>{for(var o=n>1?void 0:n?ko(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&pr(t,r,o),o};ne=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};wo=(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))(wo||{}),It=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},le=class extends It{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},Er=class extends It{constructor(){super(...arguments),this.kind="USER_ERROR"}},Sr=class extends Er{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},_o=class extends Er{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Ir=class extends le{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},wr=class extends le{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},_r=class extends le{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},Rr=class extends le{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Ar=class extends le{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},Ie=class extends It{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},Ne=class extends le{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},wt=class extends le{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};j={log:Te("log"),warn:Te("warn"),info:Te("info"),error:Te("error"),debug:Te("debug")};Object.assign(globalThis,{logger:j});xr=Symbol.for("Jolibox.canIUseMap"),Ao={};globalThis[xr]=Ao;_t={get config(){return globalThis[xr]}},xo=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(xo||{}),Rt=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Rt||{}),Co=(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))(Co||{}),Po=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),xe={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},No=()=>xe.isiOS?"iOS":xe.isAndroid?"Android":xe.isMac?"Mac":xe.isFacebook?"Facebook":"PC",Oo="device_id",Do="advertising_id",Cr=e=>(localStorage.getItem(e)||localStorage.setItem(e,Po()),localStorage.getItem(e)),At=()=>Cr(Oo),Fo=()=>Cr(Do),Uo=e=>e.charAt(0).toUpperCase()+e.slice(1),Mo=()=>{var t;let e=new URLSearchParams(window.location.search);return Uo((t=e.get("utm_source"))!=null?t:"")||"JoliboxSDK"},Pr=e=>{let t="JoliboxWebSDK",r=No(),n=navigator.language,o=At(),s=Fo();return`${t} (${Mo()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},R=(X=class{constructor(t){this.element=t,this.next=X.Undefined,this.prev=X.Undefined}},X.Undefined=new X(void 0),X),Lo=class{constructor(){this._first=R.Undefined,this._last=R.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===R.Undefined}clear(){let e=this._first;for(;e!==R.Undefined;){let t=e.next;e.prev=R.Undefined,e.next=R.Undefined,e=t}this._first=R.Undefined,this._last=R.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new R(e);if(this._first===R.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==R.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==R.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==R.Undefined&&e.next!==R.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===R.Undefined&&e.next===R.Undefined?(this._first=R.Undefined,this._last=R.Undefined):e.next===R.Undefined?(this._last=this._last.prev,this._last.next=R.Undefined):e.prev===R.Undefined&&(this._first=this._first.next,this._first.prev=R.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==R.Undefined;)yield e.element,e=e.next}},Bo=0,Ce=class{constructor(e){this.value=e,this.id=Bo++}},Ee=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof Ce&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var o,s,i,a,l,d;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let n=new Ce(t);this._listeners?this._listeners instanceof Ce?this._listeners=[this._listeners,n]:this._listeners.push(n):((s=(o=this.options)==null?void 0:o.onWillAddFirstListener)==null||s.call(o,this),this._listeners=n,(a=(i=this.options)==null?void 0:i.onDidFirstListener)==null||a.call(i,this)),(d=(l=this.options)==null?void 0:l.onDidAddListener)==null||d.call(l,this),this._size++}),this._event}_deliver(e,t){var n;if(!e)return;let r=((n=this.options)==null?void 0:n.onListenerError)||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(o){r(o)}}fire(e){this._listeners&&(this._listeners instanceof Ce?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},z=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var s;let r=(s=this.listeners.get(e))!=null?s:new Ee,n=i=>t(...i.args);this.listerHandlerMap.set(t,n),r.event(n),this.listeners.set(e,r);let o=this.cachedEventQueue.get(e);if(o)for(;o.size>0;)r.fire(y({event:e},o.shift()))}off(e,t){let r=this.listeners.get(e);if(r){let n=this.listerHandlerMap.get(t);r.dispose(n)}}emit(e,...t){let r=this.listeners.get(e);if(r)r.fire({event:e,args:t});else{let n=this.cachedEventQueue.get(e);n||(n=new Lo,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},Et={};To(Et,{None:()=>jo,filter:()=>Jo,once:()=>Nr,toPromise:()=>Ho});jo=()=>{console.log("[Jolibox SDK] None Event")};kt=Symbol.for("Jolibox.hostEmitter"),Vo=()=>{let e=new z;return globalThis[kt]||(globalThis[kt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[kt]},Z=Vo();Pe=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Ee,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return $o(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};Pe=fr([br],Pe);St=class{constructor(){this._onWillExecuteCommand=new Ee,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Ee,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Pe,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Eo(3e4)),this._starActivation}executeCommand(e,...t){return b(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Et.toPromise(Et.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};St=fr([br],St);Tt=Symbol.for("Jolibox.commands")});function F(e,t={}){xt.emit("ERROR_REPORT",{error:e,options:t})}var xt,de,$=g(()=>{"use strict";S();S();xt=new z,de=new z;F.debounce=Se(F,50,{leading:!0})});function De(e,t){return`[${e}]:${t}`}var ue,Ct,oe=g(()=>{"use strict";$();S();$();ue=(e,t)=>{var r,n;return new Ie((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Ct=e=>new Sr(e)});var Or,Dr,Fr,Ur=g(()=>{"use strict";Or=[],Dr=[],Fr=["env","createRequestTask","login"]});function Lr(e,t){Mr||(Pt=new me({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),Nt=new me({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),Ot=new me({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),t("onJoliboxEnterBackground",()=>{Pt.flush(),Nt.flush(),Ot.flush()}),Mr=!0);function r(o){var v,f;let{method:s,args:i,startTime:a,isForeground:l,errMsg:d=`${s}:fail no errMsg`,errNo:c=0,__timing:m={receiveJSInvoke:0,invokeCallback:0}}=o,{receiveJSInvoke:p,invokeCallback:T}=m,w=(f=(v=d.match(/\S:(\S+)\s?/))==null?void 0:v[1])!=null?f:"fail";Pt.report({status:w,method:n(s,i),errNo:`${c}`,errMsg:d,isForeground:l,duration:Date.now()-a}),a&&p&&T&&(Nt.report({status:w,method:s,isForeground:l,duration:Number((p-a).toFixed(3))}),Ot.report({status:w,method:s,isForeground:l,duration:Number((Date.now()-T).toFixed(3))}))}function n(o,s){return(o==="callHostMethod"||o==="callHostMethodSync")&&s!=null&&s.method?`${o}-${s.method}`:o}return r}var qo,me,Mr,Pt,Nt,Ot,Dt=g(()=>{"use strict";S();qo=e=>e==="pv"?e:"default",me=class{constructor(t){this.interval=30;this.lastReportTime=0;this.cache={};let{reporter:r,interval:n=30,eventName:o,tagNameOrder:s,metricName:i,type:a}=t;this.reporter=r,this.interval=n,this.eventName=o,this.tagNameOrder=s,this.metricName=i,this.type=qo(a)}report(t){this.type==="pv"?this.addPVPoint(t):this.addPoint(t),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(t){if(Object.keys(this.cache).length){if(t){this.reporter(this.processPoints(this.cache)),this.clearPoints();return}this.lastReportTime=this.lastReportTime||Date.now(),Date.now()-this.lastReportTime>=this.interval*1e3&&(this.reporter(this.processPoints(this.cache)),this.clearPoints(),this.lastReportTime=Date.now())}}addPoint(t){let r=(n,o,s,i)=>{let a=o.shift();if(a){let l=i[a];n[l]||(n[l]={}),r(n[l],o,s,i)}else n[s]||(n[s]=[]),n[s].push(i[s])};r(this.cache,[...this.tagNameOrder],this.metricName,t)}addPVPoint(t){let r=(o,s,i,a)=>{let l=s.shift();if(!l&&M(a))throw new Ne(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(l){let d=[];if(M(a))d.push(...Object.keys(a));else if(ce(a)){if(s.length>0)throw new Ne(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);d.push(a)}else throw new Ne(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);d.forEach(c=>{o[c]||(o[c]={});let m=M(a)?a[c]:a;r(o[c],[...s],i,m)})}else o[i]?o[i]++:o[i]=1},n={point:t,metricName:this.metricName,tagNameOrder:this.tagNameOrder};r(this.cache,[...this.tagNameOrder],this.metricName,t)}processPoints(t){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:t}}clearPoints(){this.cache={}}},Mr=!1});function jr(e,t){let r=0,n=!0,o=new Map,s=Lr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,Ft.forEach(p=>b(this,[p],function*({method:d,args:c,resolve:m}){let T=yield a(d,c);m(T)})),Ft.length=0});let i=(d,c)=>{let m=o.get(Number(d));if(!m)return;let p=ke(c);m(p),o.delete(Number(d))},a=(d,c)=>{var A,fe;let m=Date.now(),p=`${n}`;r+=1;let T=new ne;if(o.set(r,T.resolve),!n&&Dr.includes(d))return new Promise(U=>{Ft.push({method:d,args:c,resolve:U})});let v=x(y({},{method:d,startTime:m,args:c,isForeground:p}),{invokeType:"js-bridge"}),f=!Go&&Or.includes(d),k=ur(c,f),_=f?k:JSON.stringify(k),h;if(d.endsWith("Sync")||Fr.includes(d)?h=(A=e.call)==null?void 0:A.call(e,d,k,r):typeof _=="string"?h=e.invoke(d,_,r):h=(fe=e.call)==null?void 0:fe.call(e,d,_,r),h){try{typeof h=="string"&&(h=JSON.parse(h)),h=ke(h)}catch(U){j.error(U)}return o.delete(r),h.errorCode&&(h.errorCode=De(d,h.errorCode)),s(y(y({},v),h)),h}return d.endsWith("Sync")&&o.delete(r),T.promise.then(U=>(U.errorCode&&(U.errorCode=De(d,U.errorCode)),s(y(y({},v),U)),U))};return{invokeNative:a,applyNative:(d,c)=>{let m=a(d,c);return vr(m)?m.then(p=>Br(d,p)):Br(d,m)},invokeHandler:i}}function Br(e,t){if(!M(t)){j.warn(`[Jolibox SDK]${e} no response value`);return}let a=t,{errMsg:r,errNo:n,errorType:o,errorCode:s}=a,i=ae(a,["errMsg","errNo","errorType","errorCode"]);if(r&&r!==`${e}:ok`)throw new _r(r,n,o,s);return i}var Ft,Go,Hr=g(()=>{"use strict";bt();S();oe();Ur();Dt();Ft=[],Go=!1});function Jr(e){let t=new z,r=new me({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(n){e.invoke("track",JSON.stringify({event:"reportMetrics",data:n}),-1)}});return t.on("onJoliboxEnterBackground",()=>{r.flush()}),{onNative:t.on.bind(t),offNative:t.off.bind(t),subscribeHandler(n,o,s){let i=ke(o),a;if(i.__extra){a=i.params;let{type:l,startTime:d}=i.__extra;r.report({type:l,event:n,duration:Date.now()-d})}else a=i;t.emit(n,a,s)}}}var Vr=g(()=>{"use strict";S();bt();Dt()});function Ut(e){let{subscribeHandler:t,onNative:r,offNative:n}=Jr(e),{invokeNative:o,invokeHandler:s,applyNative:i}=jr(e,r);return{invokeHandler:s,subscribeHandler:t,applyNative:i,invokeNative:o,onNative:r,offNative:n}}var $r=g(()=>{"use strict";Hr();Vr()});var Kr=g(()=>{"use strict"});var qr=g(()=>{"use strict";$r();Kr()});var se,K,Gr,zr=g(()=>{"use strict";S();$();K={trigger(){},exit(){return!1},onReady(e){K.trigger=e},doExit(e){K.exit=e}},Gr=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)F(new wr("native env failed"));else{let{data:t}=JSON.parse(e);return t!=null?t:void 0}};if(window.webkit){let e=window.webkit.messageHandlers,t=(o="")=>{K.trigger(),e.onDocumentReady.postMessage({path:o})};se={onDocumentReady:t,doExit:o=>{let s=K.exit();e.doExit.postMessage({uuid:o,shouldInterrupt:s})},invoke(o,s,i){e.invoke.postMessage({event:o,paramsString:s,callbackId:i})},call(o,s,i){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(s),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:Gr};globalThis.joliboxJSCore=y({},n)}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(o="")=>{K.trigger(),e.onDocumentReady(JSON.stringify({path:o}))};se={onDocumentReady:t,invoke(o,s,i){e.invoke(JSON.stringify({event:o,paramsString:s,callbackId:i}))},doExit:o=>{let s=K.exit();e.doExit(JSON.stringify({uuid:o,shouldInterrupt:s}))},call(o,s,i){let a=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(s),callbackId:i}));if(a)return JSON.parse(a)}};let n={onDocumentReady:t,env:Gr};globalThis.joliboxJSCore=y({},n)}});function Mt(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var Lt=g(()=>{"use strict"});function Bt(){globalThis.onmessage=function(e){e.data==="msg:setup"&&([he]=e.ports,he.onmessage=function(t){let r=JSON.parse(t.data);r[0]==="publish"?globalThis.ttJSBridge.subscribeHandler(r[1],r[2]):r[0]==="invoke"&&globalThis.ttJSBridge.invokeHandler(r[1],r[2])},he.publish=function(t,r){let n=Mt(r,"messagePort");he.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},he.postMessage("msg:setup:ok"))}}var he,Wr=g(()=>{"use strict";Lt()});var Fe=g(()=>{"use strict";zr();Wr();Lt()});var Qr,zo,Xr,Yr,H,C,W,ka,Wo,V=g(()=>{"use strict";qr();Fe();oe();S();Fe();Qr=se;if(!Qr)throw new Rr("No joliboxJScore is found, native bridge not found.");Bt();zo=y({},Qr),Xr=Ut(zo),{invokeHandler:Yr}=Xr,{applyNative:H,invokeNative:C,onNative:W,offNative:ka,subscribeHandler:Wo}=Xr;globalThis.joliboxJSBridge={callHandler:Yr,invokeHandler:Yr,subscribeHandler:Wo}});var jt,Zr,en=g(()=>{"use strict";S();$();jt=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch(o){return{}}},Zr=e=>{var t;try{let o=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(o!=null&&o.length){let[s,i,a]=o;return{headerJson:jt(s),payloadJson:jt(i),signature:jt(a)}}else throw"joli_source is missing"}catch(r){return F(new Ir(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}}});var Yo,Ue,tn,Ht=g(()=>{"use strict";S();Yo="1.1.12",Ue=()=>Yo,tn=()=>{let e=Ue();return`${Pr(e)}`}});var Qo,rn,Jt,nn,L,Xo,E,q=g(()=>{"use strict";S();en();Ht();S();Qo={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:At(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Ue()},schema:window.location.href,platform:"h5"},Jt=(rn=globalThis.joliboxJSCore)==null?void 0:rn.env,L=Object.assign({},(nn=Jt==null?void 0:Jt())!=null?nn:Qo),Xo=()=>{var m,p,T,w,v,f,k,_;let{payloadJson:e,headerJson:t}=L.schema.length?Zr(L.schema):{},r=`${L.deviceInfo.did}-${new Date().getTime()}`,o=new URL(L.schema.length?L.schema:window.location.href).searchParams,s=(T=(p=(m=o.get("mpId"))!=null?m:o.get("appId"))!=null?p:o.get("gameId"))!=null?T:"",i=(v=(w=e==null?void 0:e.sessionId)!=null?w:o.get("sessionId"))!=null?v:r,a=!!((f=e==null?void 0:e.testAdsMode)!=null?f:o.get("testAdsMode")==="true"),l=(_=(k=e==null?void 0:e.joliboxEnv)!=null?k:o.get("joliboxEnv"))!=null?_:"production",d=l==="staging",c=t==null?void 0:t.channel;return{get testMode(){return d},get testAdsMode(){return a},get joliboxEnv(){return l},get joliSource(){var h;return(h=o.get("joliSource"))!=null?h:null},get mpId(){var h;return(h=s!=null?s:e==null?void 0:e.id)!=null?h:""},get mpVersion(){var h;return(h=t==null?void 0:t.ver)!=null?h:Ue()},get mpType(){var h,A;return(A=(h=t==null?void 0:t.__mpType)!=null?h:e==null?void 0:e.__mpType)!=null?A:"game"},get platform(){var h;return(h=L.platform)!=null?h:L.deviceInfo.platform},get deviceInfo(){return L.deviceInfo},get sdkInfo(){return L.sdkInfo},get hostInfo(){return L.hostInfo},get hostUserInfo(){return L.hostUserInfo},get sessionId(){var h,A;return(A=(h=L.clientSessionId)!=null?h:i)!=null?A:r},get channel(){return c},get webviewId(){var h;return(h=L.webviewId)!=null?h:-1},onEnvConfigChanged:h=>{kr(L,h,Tr)}}},E=Xo()});var Vt,sn,Zo,es,on,ts,an=g(()=>{"use strict";S();$();q();S();Vt=!1,sn=(e,t)=>e==null?!1:t in e,Zo=e=>sn(e,"kind"),es=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},on=(e,t={},r)=>{var s,i,a;let n={user_id:(i=(s=E.hostUserInfo)==null?void 0:s.uid)!=null?i:"",device_id:(a=E.deviceInfo.did)!=null?a:"",timestamp:Date.now(),tag:es(e.name)},o=x(y({},n),{env:t.environment,isFromUser:r});r?de.emit("GLOBAL_USER_ERROR",e,o):de.emit("GLOBAL_ERROR",e,o)},ts=e=>sn(e,"kind")&&e.kind==="USER_ERROR";xt.on("ERROR_REPORT",({error:e,options:t})=>{if(Vt)return;Vt=!0;let r=Zo(e)&&e.raw?e.raw:e;try{let n=ts(e);on(e,t,n)}catch(n){let o=n instanceof Error?n.message:String(n),s=new wt(`${o}, origin error: ${r.message}`);j.error(s),on(new wt(s.message),{environment:t.environment},!1)}finally{Vt=!1}})});var cn=g(()=>{"use strict";an();oe();S();V();de.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};C("trackAsync",{event:"reportJsError",data:r})});de.on("GLOBAL_USER_ERROR",(e,t)=>{j.log("UserError",e,t)})});var $t=g(()=>{"use strict"});function ln(e,t){let r=(n,o,s)=>{let i=x(y({tag:n},t),{extra:y({},o)});n=="globalJsError"?F(new Ar(JSON.stringify(i))):e("systemLog",i,s)};return r.debounce=Se(r,500,{leading:!0}),r}function dn(e){let t=(r,n,o)=>{var a;let s=(a=o&&JSON.stringify(o))!=null?a:0,i={speed_value_type:r,total_duration:n};s&&Object.assign(i,{extra:s}),e("joliboxSpeedAnalysis",i)};return t.debounce=Se(t,500,{leading:!0}),t}var un=g(()=>{"use strict";S();S();$()});function mn(e,t){let r=ln(e,t),n=dn(r);return{track:r,trackPerformance:n}}var pn=g(()=>{"use strict";un()});var fn=g(()=>{"use strict";q();S();S()});var hn=g(()=>{"use strict";pn();$t();fn()});var Me,gn=g(()=>{"use strict";Me=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.timer=this.createRAFTimer(t=>{this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t})});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,o,s=!1,i=0,a=()=>{if(!s)return;let T=Date.now(),w=T-r;w>=this.interval&&(this.visible&&(i+=w,t(i)),r=T),n=requestAnimationFrame(a)},l=()=>{c(),r=Date.now(),o=window.setInterval(()=>{if(!s)return;let T=Date.now();T-r>=this.interval&&(r=T)},this.interval)},d=()=>{m(),r=Date.now(),n=requestAnimationFrame(a)},c=()=>{n&&(cancelAnimationFrame(n),n=0)},m=()=>{o&&(clearInterval(o),o=0)};this.eventEmitter.on("visible",T=>{s&&(console.log("visible",T),T?d():l())});let p=this.visible;return{start(){s||(s=!0,p?d():l())},stop(){s=!1,c(),m()}}}}});var Kt=g(()=>{"use strict"});function vn(e,t,r){let{response:n,startTime:o,endTime:s,requestFrom:i}=r,{errMsg:a="",profile:l={}}=n,c={duration:s-o,request_type:e,url:t.split("?")[0],result:r.state,error_msg:r.state==="fail"?a:"",socket_reused:l.socketReused?1:0,request_from:i};(i==="public"&&yn<ns||i==="inner")&&(c.joli_request_number=yn++,setTimeout(()=>{J("joliboxNetRequestResult",c)},500))}var yn,ns,bn=g(()=>{"use strict";Kt();ie();yn=0,ns=10});function Le(e,t,r){var l,d,c;let n=new Map,o=(l=r==null?void 0:r.baseUrl)!=null?l:"https://api.jolibox.com",s=(d=r==null?void 0:r.type)!=null?d:"public",i=(c=r==null?void 0:r.defaultHeaders)!=null?c:{};return W("onRequestTaskStateChange",m=>{if(typeof m.requestTaskId!="string")return;let p=n.get(m.requestTaskId);if(p)if(m.state==="success"){let T=m,{requestTaskId:v,state:f}=T,k=ae(T,["requestTaskId","state"]);p.resolve(k),n.delete(v)}else if(m.state==="fail"){let w=m,{requestTaskId:v,state:f}=w,k=ae(w,["requestTaskId","state"]);p.reject(k),n.delete(v)}else j.warn("onRequestTaskStateChange unknown event",m)}),Z.on("onLoginComplete",({isLogin:m,token:p})=>{m&&p&&(i["X-JOLI-TOKEN"]=p)}),(T,...w)=>b(this,[T,...w],function*(m,p={}){let v=Date.now(),f=os(m,x(y({},p),{baseUrl:o})),{method:k="GET",responseType:_="text",dataType:h="json",timeout:A,enableCache:fe=!1,appendHostCookie:U=!0}=p,be=Object.assign({"content-type":"application/json"},i,p.header),re={url:f,method:k,header:be,enableCache:fe,responseType:_,appendHostCookie:U};if(k=="POST"||k=="PUT"){let G=is(p.data,be["content-type"]);re.data=G}A&&Object.assign(re,{timeout:A});let{data:{requestTaskId:yt}}=C(e,re);if(typeof yt!="string")throw ue({code:-1,msg:"requestTaskId is not a string"});let sr=(G,Q)=>{vn("request",f,{state:G,startTime:v,endTime:Date.now(),params:re,response:Q,requestId:yt,requestFrom:s=="public"?"public":"inner"})},{resolve:no,reject:oo,promise:so}=new ne;n.set(yt,{resolve:no,reject:oo});try{let G=yield so;sr("success",G);let{data:Q}=G;return h==="json"&&typeof Q=="string"&&(Q=ss(Q)),{url:f,timeout:A,method:k,response:x(y({},G),{data:Q})}}catch(G){let Q=G;if(M(Q)){let{errMsg:_e,prefetchDetail:io,isPrefetch:ao,errNo:co}=Q;ce(_e)&&(sr("fail",{errMsg:_e,isPrefetch:ao,prefetchDetail:io}),F(ue({code:-1,msg:_e},{errNo:co,errMsg:_e})))}throw G}})}function ss(e){try{return JSON.parse(e.trim())}catch(t){return e}}function is(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 os,qt=g(()=>{"use strict";S();bn();Kt();V();$();oe();os=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t==null?void 0:t.query,o=new URLSearchParams(r).toString();return t!=null&&t.baseUrl?`${t.baseUrl}${e}${o?`?${o}`:""}`:`${e}${o?`?${o}`:""}`}});var Gt,kn,Y,Be=g(()=>{"use strict";Ht();qt();q();Gt={"x-user-agent":tn()};(kn=E.hostUserInfo)!=null&&kn.token&&(Gt["x-joli-token"]=E.hostUserInfo.token);E.joliSource&&(Gt["x-joli-source"]=E.joliSource);Y=Le("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:E.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:Gt})});var je,Tn=g(()=>{"use strict";q();gn();Be();V();je=class extends Me{constructor(t,r,n){super(r,n),this.gameId=E.mpId,this.sessionId=E.sessionId,this.track=t}reporter(t){return b(this,null,function*(){let{event:r,params:n}=t,o=[];o.push(Y("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:y({gameId:this.gameId,sessionId:this.sessionId},n)}})),yield Promise.all(o)})}reportToNative(t){return b(this,null,function*(){let{event:r,params:n}=t;yield H("userTrackAsync",{event:r,params:y({},n),gameId:this.gameId})})}tracker(t,r=null){this.track(t,r)}}});var _n={};lr(_n,{nativeTaskEmitter:()=>we,taskTracker:()=>B,track:()=>J,trackPerformance:()=>In});var as,En,Sn,J,In,wn,we,B,ie=g(()=>{"use strict";cn();S();$t();hn();q();Tn();V();as=(e,t,r)=>{var i,a;let n=t,o=M(n.extra)?n.extra:ce(n.extra)?JSON.parse(n.extra):{},s=x(y({},o),{mp_id:(i=n.mp_id)!=null?i:"",mp_version:(a=n.mp_version)!=null?a:""});C("trackAsync",{event:e,data:s,webviewId:r})},{track:J,trackPerformance:In}=mn(as,{type:Rt.AppSDK,platform:"native",jssdk_version:(Sn=(En=E.sdkInfo)==null?void 0:En.jssdkVersion)!=null?Sn:"1.0.0",mp_id:E.mpId,mp_version:E.mpVersion}),wn=O();wn.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{In(e,t,r)});wn.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{J(e,t)});we=new z,B=new je(J,we)});function Rn(){let e=null,t=window.fetch,r=()=>{e=document.createElement("style"),e.setAttribute("data-jolibox-sdk","default-styles");let s=`
|
|
2
2
|
html[data-jolibox-root] {
|
|
3
3
|
height: 100%;
|
|
4
4
|
margin: 0;
|
|
@@ -16,6 +16,6 @@ var _o=Object.create;var Ne=Object.defineProperty,Io=Object.defineProperties,wo=
|
|
|
16
16
|
min-height: 100dvh;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
`;e.textContent=s;let i=document.head||document.getElementsByTagName("head")[0];i.insertBefore(e,i.firstChild),document.documentElement.setAttribute("data-jolibox-root","")},n=()=>{function s(a){return v(this,null,function*(){let c=a instanceof URL?a.href:a,u=new Promise((l,m)=>{let p=new XMLHttpRequest;p.open("GET",c),p.responseType="arraybuffer",p.addEventListener("load",()=>l(p.response)),p.addEventListener("error",m),p.send()});try{let l=yield u;return new Response(l,{headers:new Headers([["Content-Type","application/wasm"]])}).clone()}catch(l){throw console.error("Failed to load wasm:",l),l}})}let i=window.fetch;window.fetch=(a,c)=>{let u=a instanceof URL?a.href:a.toString();return u.endsWith(".wasm")?s(u):i(a,c)}},o=()=>{e!=null&&e.parentNode&&(e.parentNode.removeChild(e),e=null),document.documentElement.removeAttribute("data-jolibox-root"),window.fetch=t};return r(),n(),o}var Ln=f(()=>{"use strict"});var ze,Bn=f(()=>{"use strict";ze=class{constructor(t){this.track=t;this.adBreakIsShowing=!1;this.reportPageJumpOut=()=>{this.track("AdBreakJumpOut",{context:"AdsActionDetection"})};this.reportPageHide=()=>{this.track("AdBreakHide",{context:"AdsActionDetection"})};window.addEventListener("visibilitychange",()=>{document.hidden&&this.adBreakIsShowing&&this.reportPageHide()}),window.addEventListener("beforeunload",r=>{this.adBreakIsShowing&&this.reportPageJumpOut()})}}});var We,Ts,Es,Ss,_s,jn=f(()=>{"use strict";We=class{constructor(t,r,n,o){this.track=t;this.httpClient=r;this.checkNetwork=n;this.checkAdsDisplayPermission=t=>{if(!this.checkNetwork())return{reason:"NETWORK_NOT_OK"};let r=this.checkShouldBanInitial();if(r)return{reason:r};let n=this.checkShouldBanForSession(t);if(n)return{reason:n};let o=this.checkShouldBanHighFreq(t);if(o)return o;let s=this.checkShouldBanForTime(t);return s?{reason:s}:{reason:"ALLOWED"}};var p,k,I,b,g,T,R;let s=(p=o==null?void 0:o.maxAllowedAdsForTime)!=null?p:8,i=(k=o==null?void 0:o.banForTimeThreshold)!=null?k:6e4,a=(I=o==null?void 0:o.bannedReleaseTime)!=null?I:6e4,c=(b=o==null?void 0:o.maxAllowedAdsForSession)!=null?b:200,u=(g=o==null?void 0:o.banForSessionThreshold)!=null?g:6e5,l=(T=o==null?void 0:o.initialThreshold)!=null?T:2e3,m=(R=o==null?void 0:o.highFreqThreshold)!=null?R:2e3;this.checkShouldBanInitial=Ss(l),this.checkShouldBanHighFreq=_s(m),this.checkShouldBanForTime=Es(s,i,a),this.checkShouldBanForSession=Ts(c,u)}report(t,r){let n=r?{reason:t,count:r}:{reason:t};this.track("PreventAdsCheating",n),this.httpClient.post("/api/base/app-event",{data:{eventType:"PREVENT_ADS_CHEATING",adsInfo:n}})}},Ts=(e,t)=>{let r=!1,n=[];return s=>{if(r)return"BANNED_FOR_SESSION";let i=Date.now();if(n=n.concat({timestamp:i,type:s}),n.length!==1&&(n.length>e&&(n=n.slice(-e)),n.length===e&&i-n[0].timestamp<=t))return r=!0,"BANNED_FOR_SESSION"}},Es=(e,t,r)=>{let n=null,o=l=>{n&&(window.clearTimeout(n),n=null),n=window.setTimeout(()=>{c.value=!1,n=null},l)},s="jolibox-sdk-ads-callbreak-timestamps",i="jolibox-sdk-ads-ban-for-time",a={_records:[],init(){var l;try{let m=JSON.parse((l=window.localStorage.getItem(s))!=null?l:"[]");Array.isArray(m)?this._records=m:this._records=[]}catch(m){this._records=[]}},get values(){return this._records},set values(l){try{window.localStorage.setItem(s,JSON.stringify(l))}catch(m){}this._records=l}},c={_record:!1,init(){var l;try{let m=JSON.parse((l=window.localStorage.getItem(i))!=null?l:"false");typeof m=="boolean"&&(this._record=m)}catch(m){this._record=!1}if(this._record){let m=a.values[a.values.length-1],p=m?Date.now()-m.timestamp:r;p<=r&&p>0?o(p):this._record=!1}},get value(){return this._record},set value(l){try{window.localStorage.setItem(i,JSON.stringify(l))}catch(m){}this._record=l}};return a.init(),c.init(),l=>{if(c.value)return"WAITING_BANNED_RELEASE";let m=Date.now();if(a.values=a.values.concat({timestamp:m,type:l}),a.values.length!==1&&(a.values.length>e&&(a.values=a.values.slice(-e)),a.values.length===e&&m-a.values[0].timestamp<=t))return c.value=!0,o(r),"BANNED_FOR_TIME"}},Ss=e=>{let t=Date.now();return()=>{if(Date.now()-t<=e)return"BLOCK_INITIAL"}},_s=(e=2e3)=>{let t=0,r=null;return o=>{if(o==="reward"){if(r)return t+=1,{reason:"HOLDING_HIGH_FREQ",info:{count:t}};r=window.setTimeout(()=>{r&&(window.clearTimeout(r),r=0,t=0)},e)}}}});var Qe,Jn=f(()=>{"use strict";J();Qe=class{constructor(t){this.httpClient=t;this.configs=null;this.firstRun=!0;this.init()}init(){return v(this,null,function*(){try{this.configs=yield this.httpClient.get("/api/fe-configs/js-sdk/ads-channel-config")}catch(t){}})}shouldBypassCallingInterstitial(){var r,n;let t;if(!this.configs)this.init(),t=!this.firstRun;else{let o=(r=y.channel)!=null?r:"",s=this.configs[o],i=(n=s==null?void 0:s.interstitialRate)!=null?n:1;t=Math.random()<i}return this.firstRun=!1,t}}});var ve,Ye,er=f(()=>{"use strict";Bn();jn();J();Jn();S();ve=new q,Ye=class{constructor(t,r,n){this.track=t;this.httpClient=r;this.checkNetwork=n;this.configured=!1;this.config={};this.getGameId=()=>y.mpId;this.getTestAdsMode=()=>y.testAdsMode;this.asyncLoad=()=>v(this,null,function*(){var i,a,c,u,l;let t="ca-pub-7171363994453626",r,n,o=window.encodeURIComponent(window.btoa((i=this.getGameId())!=null?i:"")),s=(a=this.getTestAdsMode())!=null?a:!1;try{let m=yield this.httpClient.get("/public/ads",{query:{objectId:o,testAdsMode:`${s}`}});t=(c=m.data)==null?void 0:c.clientId,r=(u=m.data)==null?void 0:u.channelId,n=(l=m.data)==null?void 0:l.unitId}catch(m){console.error("Failed to fetch client info",m)}this.clientId=t,this.channelId=r,this.unitId=n});this.asyncInit=t=>v(this,null,function*(){var o;if(typeof window=="undefined")return;yield this.asyncLoad();let r="google-adsense",n=(o=this.getTestAdsMode())!=null?o:!1;if(!document.getElementById(r)&&this.clientId){let s=document.createElement("script");s.id=r,s.async=!0,s.crossOrigin="anonymous",s.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`,n&&s.setAttribute("data-adbreak-test","on"),this.channelId&&s.setAttribute("data-ad-channel",this.channelId),document.head.appendChild(s),this.track("LoadAdsenseCompleted",null)}});this.push=(t={})=>{window.adsbygoogle.push(t)};this.wrapAdBreakParams=t=>{if((n=>n.type==="preroll")(t)){ve.emit("isAdShowing",!0);let n=t.adBreakDone,o=s=>{ve.emit("isAdShowing",!1),n&&n(s)};return P(h({},t),{adBreakDone:o})}else{let n=t.beforeAd,o=t.afterAd,s=()=>{var a;ve.emit("isAdShowing",!0),this.track("CallBeforeAd",{type:t.type,name:(a=t.name)!=null?a:""}),n&&n()},i=()=>{var a;ve.emit("isAdShowing",!1),this.track("CallAfterAd",{type:t.type,name:(a=t.name)!=null?a:""}),o&&o()};return P(h({},t),{beforeAd:s,afterAd:i})}};this.adConfig=t=>{let o=t,{onReady:r}=o,n=ce(o,["onReady"]);this.track("CallAdConfig",n),this.configured?console.warn("Ad config already set, skipping"):(this.configured=!0,this.push(t))};this.adBreak=t=>{var u,l,m,p,k,I;if(!this.getGameId()){console.warn("Game ID is not set, skip calling adBreak");return}if(t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){(u=t.adBreakDone)==null||u.call(t,{breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}let{reason:r,info:n}=this.antiCheating.checkAdsDisplayPermission(t.type==="reward"?"reward":"interstitial");switch(r){case"NETWORK_NOT_OK":case"BANNED_FOR_SESSION":(l=t.adBreakDone)==null||l.call(t,{breakType:t.type,breakName:r,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"}),this.antiCheating.report(r);return;case"BLOCK_INITIAL":case"BANNED_FOR_TIME":case"WAITING_BANNED_RELEASE":(m=t.adBreakDone)==null||m.call(t,{breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"}),this.antiCheating.report(r);return;case"HOLDING_HIGH_FREQ":(k=t.adBreakDone)==null||k.call(t,{breakFormat:t.type==="reward"?"reward":"interstitial",breakName:"",breakStatus:((p=n==null?void 0:n.count)!=null?p:0)>6?"other":"frequencyCapped",breakType:t.type}),n!=null&&n.count&&n.count!==0&&n.count%3===0&&this.antiCheating.report(r,n==null?void 0:n.count);return;default:break}let o=t.type,s=t.adBreakDone,i=b=>{var g;this.adsActionDetection.adBreakIsShowing=!1,this.track("CallAdBreakDone",{breakType:b.breakType,breakName:(g=b.breakName)!=null?g:"",breakFormat:b.breakFormat,breakStatus:b.breakStatus}),s&&s(b)};if(t.adBreakDone=i,t.type==="reward"){let b=t.beforeReward,g=R=>()=>{this.track("CallShowAdFn",null),R()},T=R=>{b&&b(g(R))};t.beforeReward=T}let a;switch(o){case"preroll":a={type:o};break;case"start":case"pause":case"next":case"browse":case"reward":a={type:o,name:(I=t.name)!=null?I:""};break}this.adsActionDetection.adBreakIsShowing=!0,this.track("CallAdBreak",a);let c=this.wrapAdBreakParams(t);this.push(c),window.JoliTesterBridge&&console.log("joli-fullscreen-ad-show")};this.adUnit=t=>v(this,null,function*(){var p,k,I,b;if(this.track("CallAdUnit",{adFormat:(k=(p=t.adFormat)==null?void 0:p.toString())!=null?k:null,fullWidthResponsive:(I=t.fullWidthResponsive)!=null?I:null}),this.clientId||(yield this.asyncLoad()),document.querySelector("#jolibox-ads")){console.warn("Ad unit already set, skipping");return}let{el:r,slot:n,adFormat:o,fullWidthResponsive:s,style:i}=t,a;if(!r)throw new Error("targeting element is required");if(typeof r=="string"?a=document.querySelector(r):a=r,!a)throw new Error("targeting element not found");let c=n;if(c||(c=this.unitId),!c)throw new Error("slot is required");let u=typeof o=="object"&&Array.isArray(o)?o.join(", "):o,l=document.createElement("ins");if(l.className="adsbygoogle",l.id="jolibox-ads",l.style.display="block",l.setAttribute("data-ad-client",this.clientId),l.setAttribute("data-ad-slot",c),u&&l.setAttribute("data-ad-format",u),s&&l.setAttribute("data-full-width-responsive",s),i&&l.setAttribute("style",i),(b=this.getTestAdsMode())!=null?b:!1){let g=document.createElement("div");g.style.position="absolute",g.style.top="0",g.style.left="0",g.style.width="100%",g.style.height="100%",g.style.display="flex",g.style.justifyContent="center",g.style.alignItems="center",g.style.backgroundColor="rgba(0, 0, 0, 0.5)",g.style.color="white",g.innerHTML="Test Ad",l.style.position="relative",a.appendChild(l),l.appendChild(g)}else a.appendChild(l),new MutationObserver(T=>{T.forEach(R=>{if(R.type==="attributes"&&R.attributeName==="data-ad-status"){let _=l.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:_!=null?_:"null"})}})}).observe(l,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})});this.antiCheating=new We(t,r,n),this.adsActionDetection=new ze(this.track),this.channelPolicy=new Qe(r)}init(t){this.track("CallAdsInit",null),typeof window!="undefined"&&(this.config=t!=null?t:{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}}});function Hn(){return v(this,null,function*(){let{data:e}=A("envSync"),{orientation:t,webviewId:r}=e,n={__mpType:"miniApp",__transparent:!0,__orientation:t!=null?t:"VERTICAL",__showStatusBar:!1,__shouldInterupt:!1,__showCapsuleButton:!1};r&&(n=P(h({},n),{__from:r}));let o=y.encodeJoliSourceQuery(n),i=`${y.testMode,"https://G32115508989327465281365749294.app.jolibox.com"}/recommended-guide/${y.mpId}?appId=${y.mpId}&joliSource=${o}&navigationStyle=present`,a=new Q;return cn("onRetentionResult",({shouldStay:c})=>{a.resolve(c)}),setTimeout(()=>{A("openSchemaSync",{schema:i})},0),a.promise})}var $n=f(()=>{"use strict";J();j();S()});var Kn={};gr(Kn,{config:()=>As});function Is(){re.on("onDocumentReady",()=>{var e;(e=ie)==null||e.onDocumentReady(window.location.href),K("onDocumentReady",{start_timestamp:et,timestamp:Date.now()})})}function ws(e){y.mpType==="game"&&H.start(e)}function Rs(){Y("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&y.onEnvConfigChanged({hostUserInfo:e}),re.emit("LifecycleEvent.onReady",h({},y.hostUserInfo?y.hostUserInfo:{isLogin:!1})),K("joliboxServiceReady",{start_timestamp:et,timestamp:Date.now()}),ws(t)}),Y("onBeforeExit",({uuid:e})=>{var t;(t=ie)==null||t.doExit(e)})}function As(){et=Date.now(),Rs(),Is(),Xe=Mn()}var Xe,Vn,Ze,et,qn=f(()=>{"use strict";j();He();J();S();ae();Ln();er();$n();z.onReady(()=>{});Vn=()=>{K("onBeforeExit",{timestamp:Date.now()}),Xe==null||Xe(),H.close(Date.now()-et)};z.doExit(()=>v(void 0,null,function*(){return Ze?!0:Ie(y.shouldInterupt)?(y.shouldInterupt||Vn(),y.shouldInterupt):(yield Hn())?!0:(Vn(),!1)}));Ze=!1;ve.on("isAdShowing",e=>{Ze=e,Ie(Ze)&&A("updateContainerConfigSync",{displayCapsuleButton:!Ze,webviewId:y.webviewId})})});function Gn(e){let t=Ot.config[e];return t||(t={},Ot.config[e]=t),(r,n)=>{if(t[r]){$.warn(`[can i use] ${r} already registered`);return}t[r]=h({},n)}}var zn=f(()=>{"use strict";S()});function tr(e){Wn=e}function tt(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>tt(t)):Object.keys(e).reduce((t,r)=>(t[r]=tt(e[r]),t),{})}function ne(e){return typeof e=="number"}function rr(e){let t=nr(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function nr(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Wn,D,rt,nt,ot,st,be,it,at,ct,lt,ut,dt,mt,pt,ft,ht,gt,yt,or=f(()=>{"use strict";Wn=!1;D=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Wn)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${rr(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return tt(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:tt(this._default)}optional(){return this._optional=!0,this}};rt=class extends D{validate(t){return this._optional&&t===void 0?!0:ne(t)?ne(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):ne(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):ne(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},nt=class extends D{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},ot=class extends D{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(ne(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(ne(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},st=class extends D{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},be=class extends D{validate(t){return!0}},it=class extends D{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},at=class extends D{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},ct=class extends D{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},lt=class extends D{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(n=>JSON.stringify(n)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${rr(t)}`)}return!0}},ut=class extends D{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(ne(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(ne(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(ne(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let n=this._item;if(!n)return!0;let o=!0;if(r.forEach((s,i)=>{if(n.path=`${this.path}[${i}]`,n.errors=this.errors,s===void 0&&n.hasDefault){r[i]=n.defaultValue;return}n.validate(s)||(n.hasFallback?r[i]=n.fallbackValue:o=!1)}),this._uniqueItems){let s=new Map;for(let i in r)s.has(r[i])?o=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${s.get(r[i])}] and ${this.path}[${i}] are identical)`):s.set(r[i],i)}return o}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},dt=class extends D{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(nr(r)!=="object")return this.fail({expect:"object",actual:r});let o=r,s=this._value;s.errors=this.errors;let i=!0;for(let a in o){let c=o[a];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(a)?s.path=`${this.path}.${a}`:s.path=`${this.path}["${a}"]`,!(c===void 0&&s._optional)){if(c===void 0&&s.hasDefault){o[a]=s.defaultValue;continue}s.validate(c)||(s.hasFallback?o[a]=s.fallbackValue:i=!1)}}return i}},mt=class extends D{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(nr(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,o=!0;for(let s in this._object){let i=n[s],a=this._object[s];if(a.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(s)?a.path=`${this.path}.${s}`:a.path=`${this.path}["${s}"]`,!(a._optional&&i===void 0)){if(i===void 0&&a.hasDefault){n[s]=a.defaultValue;continue}a.validate(i)||(a.hasFallback?n[s]=a.fallbackValue:o=!1)}}return o}},pt=class extends D{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:rr(this.value),actual:r}):!0}},ft=class extends D{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,o=this._items.length;for(let s=0;s<o;s++){let i=this._items[s];if(i.errors=[],i.path=this.path,!i.validate(t))r.push(i.errors.join("; "));else if(!n){n=!0;break}}if(!n){let s=r.join(`
|
|
20
|
-
or `);this.errors.push(s)}return n}},
|
|
21
|
-
`);throw e.errors.length=0,tr(!1),new TypeError(n)}}var d,ir=f(()=>{"use strict";or();or();d={object(e){return new mt(e)},array(e){return new ut(e)},tuple(...e){return new ht(...e)},literal(e){return new pt(e)},or(...e){return new ft(...e)},symbol(){return new st},record(e){return new dt(e)},function(){return new ct},boolean(){return new nt},string(){return new ot},number(){return new rt},undefined(){return new it},null(){return new at},unknown(){return new be},any(){return new be},as(){return new be},arraybuffer(){return new gt},enum(...e){return new lt(...e)},typedarray(e){return new yt(e)}}});var vt,Qn,Yn=f(()=>{"use strict";S();G();ir();se();vt=1,Qn=e=>{function t(n,o){return(...s)=>{var m,p,k,I;let i=Date.now(),a={method:n,trace_id:vt};vt+=1;let c="SUCCESS",u=`${n}:ok`,l=0;try{if(o.paramsSchema)try{sr(o.paramsSchema,s,"params")}catch(R){throw Mt(`${n}:fail ${R.message}`)}let b=o.implement(...s),g=b,T=`${n}:ok`;if(b&&"code"in b){let{code:R,data:_,message:U}=b;c=R,g=_,T=U}return{code:c,message:T,data:g}}catch(b){let g=b;l=(p=(m=g.code)!=null?m:g.errNo)!=null?p:2e3,c="FAILURE";let T=(I=(k=g.message)!=null?k:g.errMsg)!=null?I:`${b}`;return u=`${n}:${c} ${T.replace(/^\S+:(fail|cancel)\s?/,"")}`,M(new Ae(u,l)),{code:c,message:u}}finally{let b=Date.now()-i;e("apiInvoked",P(h({},a),{duration:b,status:c}))}}}function r(n,o){return(...s)=>v(this,null,function*(){var p,k,I,b;let i=Er(s)?s:[s],a=Date.now(),c={method:n,trace_id:vt};vt+=1;let u=`${n}:ok`,l="SUCCESS",m={code:l,message:u};try{if(o.paramsSchema)try{sr(o.paramsSchema,i,"params")}catch(R){throw Mt(R.message)}let T=yield o.implement(...i);if(T&&"code"in T){let{code:R,data:_,message:U}=T;l=R,u=U,T=_}return Object.assign(m,{code:l,message:u,data:T}),m}catch(g){let T=g,R=(k=(p=T.code)!=null?p:T.errNo)!=null?k:2e3;l="FAILURE";let _=(b=(I=T.message)!=null?I:T.errMsg)!=null?b:`${g}`,U=`${n}:${l} ${_.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(m,{code:l,message:U}),M(new Ae(U,R)),m}finally{let g=Date.now()-a;e("apiInvoked",P(h({},c),{duration:g,status:l}))}})}return{createAPI:r,createSyncAPI:t}}});var F,N,E,Z=f(()=>{"use strict";zn();ae();Yn();ir();({createAPI:F,createSyncAPI:N}=Qn(K)),E=Gn("native")});var Xn,Ps,Cs,Ns,Os,Zn=f(()=>{"use strict";S();Z();j();Xn=O(),Ps="env",Cs="getSystemInfoSync",Ns=N(Cs,{implement:()=>{var r;let e=A("envSync"),{data:t}=e;return{system:t.deviceInfo.system,platform:t.deviceInfo.platform,version:t.sdkInfo.jssdkVersion,pixelRatio:t.deviceInfo.pixelRatio,language:t.deviceInfo.lang,brand:t.deviceInfo.brand,appName:(r=t.hostInfo)==null?void 0:r.appName,SDKVersion:t.sdkInfo.jssdkVersion}}}),Os=N(Ps,{implement:()=>{var t;let e=A("envSync");return(t=e==null?void 0:e.data)!=null?t:void 0}});Xn.registerCommand("API.getSystemInfoSync",Ns);Xn.registerCommand("API.env",Os);E("env",{version:"1.0.0"});E("getSystemInfoSync",{version:"1.0.0"})});var eo=hr(ar=>{"use strict";S();Z();G();j();ae();J();var Ds="exitGame",Fs="onReady",Us="onJoliboxShow",Ms="onJoliboxHide",bt=O(),kt=Me(M),Ls=F(Ds,{paramsSchema:d.tuple(d.function(),d.boolean().optional().default(!1)),implement:(e,t=!1)=>v(ar,null,function*(){kt(e).call(ar),Ie(y.shouldInterupt)&&!y.shouldInterupt&&y.from&&an("onRetentionResult",{shouldStay:t},y.from,!0),yield V("exitAppAsync")})}),Bs=N(Us,{paramsSchema:d.tuple(d.function()),implement(e){let t=kt(e);Y("onJoliboxEnterForeground",()=>{t.call(this),xe.emit("visible",!0)})}}),js=N(Ms,{paramsSchema:d.tuple(d.function()),implement(e){let t=kt(e);Y("onJoliboxEnterBackground",()=>{t.call(this),xe.emit("visible",!1)})}}),Js=N(Fs,{paramsSchema:d.tuple(d.function()),implement(e){let t=kt(e);re.on("LifecycleEvent.onReady",r=>{t(r)})}});bt.registerCommand("LifecycleSDK.exit",Ls);bt.registerCommand("LifecycleSDK.onReady",Js);bt.registerCommand("LifecycleSDK.onJoliboxShow",Bs);bt.registerCommand("LifecycleSDK.onJoliboxHide",js);E("lifeCycle.exit",{version:"1.0.0"});E("lifeCycle.onReady",{version:"1.0.0"});E("lifeCycle.onJoliboxShow",{version:"1.0.0"});E("lifeCycle.onJoliboxHide",{version:"1.0.0"})});function to(e){let t={};if(!B(e))return t;for(let[r,n]of Object.entries(e)){let o=r.toLocaleLowerCase();n?typeof n=="object"?t[o]=Object.prototype.toString.call(n):t[o]=String(n):t[o]=""}return t}function ro(e="GET"){if(e==="")return"POST";let t=e.toUpperCase();return["GET","OPTIONS","HEAD","POST","PUT","DELETE","TRACE","CONNECT","PATCH"].includes(t)?t:"GET"}function no(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function oo(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!B(r))return e;let[n,o=""]=e.split("?"),s=JSON.stringify(h(h({},JSON.parse(o)),r));return`${n}?${s}`}var so=f(()=>{"use strict";S()});var Hs,$s,cr,lr,io,Vs,Ks,qs,ao=f(()=>{"use strict";se();Xt();Z();so();S();G();Hs=15,$s=Ke("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),cr=0,lr=[],io=Me(M),Vs=(e,t)=>{let r=e.filter(t),n=e.filter(o=>!t(o));return e.length=0,e.push(...n),r},Ks=e=>{let t=new Q,r=()=>{};return F("request",{paramsSchema:d.tuple(d.object({url:d.string(),method:d.string(),header:d.object(),data:d.object().optional(),query:d.object().optional(),dataType:d.string().default("json"),responseType:d.string().default("text"),enableCache:d.boolean().default(!1),appendHostCookie:d.boolean().default(!0),timeout:d.number().default(3e4),success:d.function(),fail:d.function()})),implement(o){let s=()=>v(this,null,function*(){var a,c;let i=io(o.fail);try{if(cr+=1,t.state!=="pending")return;let{data:u,dataType:l,responseType:m,enableCache:p,appendHostCookie:k}=o,I=to(o.header),b=ro(o.method),g=no(o.timeout),T=oo(o.url,b,u),R=io(o.success),_=Object.assign({},o,{method:b,header:I,data:b==="GET"||b==="HEAD"?void 0:u,enableCache:p,query:(a=o.query)!=null?a:{},dataType:l,responseType:m,appendHostCookie:k});g&&(_.timeout=g);let U=$s(T,_);{let{response:w}=yield U,{code:x,data:Te,message:oe}=w;t.resolve({code:x!=null?x:"SUCCESS",data:Te,message:oe!=null?oe:"request:ok"}),R({code:"SUCCESS",message:"request:ok",data:Te})}}catch(u){t.reject(u),i({code:"FAILURE",message:"httpRequst: failed"})}finally{cr-=1,(c=lr.shift())==null||c()}});return cr>=Hs?(r=()=>{Vs(lr,i=>i===s)},lr.push(s)):s(),t.promise}})(e),{abort(){t.reject(me({code:-1,msg:"request:fail abort"})),r()}}},qs=O();qs.registerCommand("HttpSDK.request",Ks);E("request",{version:"1.0.0"})});function Xs(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return Ys.includes(t)?t:""}function Zs(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 ei(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch(r){return""}}var Tt,Gs,zs,Ws,Qs,Vu,Ku,Ys,co=f(()=>{"use strict";Z();j();S();qe();J();Tt=O(),Gs=F("getLocalStorage",{paramsSchema:d.tuple(d.string()),implement(e){return v(this,null,function*(){let{response:t}=yield X(`/api/games/user-storage/${y.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:o}}=yield t;if(r==="SUCCESS")return{code:r,message:n,data:o==null?void 0:o.value};try{let{data:{data:s,dataType:i}}=yield V("getLocalStorageAsync",{key:e}),a=Zs(s,i);return{code:r,message:`${n}. fallback to native`,data:a}}catch(s){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}})}});Tt.registerCommand("StorageSDK.getItem",Gs);E("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});zs=F("setStorage",{paramsSchema:d.tuple(d.string(),d.or(d.string(),d.boolean(),d.number())),implement(e,t){return v(this,null,function*(){let r=y.mpId,n=typeof t=="string"?t:String(t),{response:o}=yield X(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:s,message:i}}=o,a=Xs(t),c=ei(t,a);return yield V("setLocalStorageAsync",{key:e,data:c,dataType:a}),s=="SUCCESS"?{code:s,message:i}:{code:s,message:`${i}. fallback to native`}})}});Tt.registerCommand("StorageSDK.setItem",zs);E("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});Ws=F("removeStorage",{paramsSchema:d.tuple(d.string()),implement(e){return v(this,null,function*(){let t=y.mpId,{response:r}=yield X(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:o}}=r;return yield V("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:o}:{code:n,message:"[Jolibox SDK] remove item succ"}})}});Tt.registerCommand("StorageSDK.removeItem",Ws);E("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});Qs=F("clearStorage",{implement(){return v(this,null,function*(){let e=y.mpId,{response:t}=yield X(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});V("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}})}});Tt.registerCommand("StorageSDK.clear",Qs);E("storage.clear",{version:"1.0.0"});Vu=F("getStorageInfo",{implement(){return v(this,null,function*(){let{data:e}=yield V("getStorageInfoAsync");return e})}});E("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});Ku=N("getStorageInfoSync",{implement(){return A("getStorageInfoSync")}}),Ys=["string","number","boolean","object",""]});var ti,ri,ni,ur,lo=f(()=>{"use strict";S();j();Z();ti=N("showKeyboard",{paramsSchema:d.tuple(d.object({defaultValue:d.string().optional().default(""),multiple:d.boolean().optional().default(!1),maxLength:d.unknown().optional().default(1e5)})),implement(e){var n;let t=Math.floor((n=Number(e.maxLength))!=null?n:1e5),{defaultValue:r}=e;r&&t&&(r=r.slice(0,t)),A("showKeyboardSync",P(h({},e),{defaultValue:r,maxLength:t}))}});E("keyboard.showKeyboard",{version:"1.0.0",properties:{params:{defaultValue:"1.0.0",multiple:"1.0.0",confirmHold:"1.0.0",confirmType:"1.0.0",maxLength:"1.0.0"}},success:{errMsg:"1.0.0"}});ri=N("updateKeyboard",{paramsSchema:d.tuple(d.object({value:d.string()})),implement(e){A("updateKeyboardSync",e)}});E("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});ni=N("hideKeyboard",{implement(){A("hideKeyboardSync")}});E("keyboard.hideKeyboard",{version:"1.0.0"});ur=O();ur.registerCommand("KeyboardSDK.showKeyboard",ti);ur.registerCommand("KeyboardSDK.updateKeyboard",ri);ur.registerCommand("KeyboardSDK.hideKeyboard",ni)});var uo=hr(he=>{"use strict";S();Z();ae();var ke=O(),oi=F("levelFinished",{paramsSchema:d.tuple(d.string(),d.object({result:d.boolean(),duration:d.number()})),implement:(e,t)=>v(he,null,function*(){let{result:r,duration:n}=t,o=[];o.push(H.tracker("LevelFinished",{levelId:e,result:r,duration:n})),o.push(H.reporter({event:"COMPLETE_GAME_LEVEL"})),yield Promise.all(o)})}),si=F("taskFinished",{paramsSchema:d.tuple(d.string(),d.object({duration:d.number()})),implement:(e,t)=>v(he,null,function*(){let{duration:r}=t;return yield H.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})})}),ii=F("levelUpgrade",{paramsSchema:d.tuple(d.string(),d.string()),implement:(e,t)=>v(he,null,function*(){let r=[];r.push(H.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),yield Promise.all(r)})}),ai=F("onHistoryUserLevel",{paramsSchema:d.tuple(d.number()),implement:e=>v(he,null,function*(){return yield H.reportToNative({event:"HistoryUserLevel",params:{level:e}})})}),ci=F("onHistoryUserScore",{paramsSchema:d.tuple(d.number()),implement:e=>v(he,null,function*(){return yield H.reportToNative({event:"HistoryUserScore",params:{score:e}})})}),li=F("taskEvent",{paramsSchema:d.tuple(d.string(),d.object({tools:d.array(d.object({id:d.string(),name:d.string(),count:d.number(),description:d.string().optional(),price:d.object({amount:d.number(),unit:d.string()}).optional()})).optional(),awards:d.array(d.object({id:d.string(),name:d.string()})).optional()})),implement:(e,t)=>v(he,null,function*(){var n,o;let r=[];r.push(H.reportToNative({event:"TaskEvent",params:h({taskId:e},t)})),(o=(n=t.tools)==null?void 0:n.length)!=null&&o&&(r.push(H.reporter({event:"USE_GAME_ITEM"})),r.push(H.reportToNative({event:"UseGameItem",params:h({taskId:e},t)}))),yield Promise.all(r)})});ke.registerCommand("TaskTrackerSDK.levelFinished",oi);ke.registerCommand("TaskTrackerSDK.taskFinished",si);ke.registerCommand("TaskTrackerSDK.levelUpgrade",ii);ke.registerCommand("TaskTrackerSDK.historyUserLevel",ai);ke.registerCommand("TaskTrackerSDK.historyUserScore",ci);ke.registerCommand("TaskTrackerSDK.taskEvent",li);E("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});E("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});E("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});E("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});E("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});E("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}})});var ui,di,mo,po=f(()=>{"use strict";J();j();Z();S();se();E("login",{version:"1.0.0",properties:{force:"1.0.0"},success:{errMsg:"1.0.0",code:"1.0.0",token:"1.0.0",isLogin:"1.0.0"}});E("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});ui=F("login",{implement(){return v(this,null,function*(){var i;let{data:{isLogin:e}}=yield V("checkLoginAsync");if(e)return{isLogin:!0,token:(i=y.hostUserInfo)==null?void 0:i.token};Y("onLoginStateChange",({isLogin:a,token:c,uuid:u})=>{u==r&&o({isLogin:a,token:c})});let t=A("loginSync"),{data:{uuid:r}}=t;if(!r)throw me({code:-1,msg:"login failed"});let{promise:n,resolve:o}=new Q,s=yield n;return y.onEnvConfigChanged({hostUserInfo:s}),re.emit("onLoginComplete",s),s})}}),di=F("checkSession",{implement(){return v(this,null,function*(){let{data:{isLogin:e}}=yield V("checkLoginAsync");return{isLogin:e}})}}),mo=O();mo.registerCommand("API.login",ui);mo.registerCommand("API.checkSession",di)});var Et,mi,St,pi,fi,hi,gi,fo=f(()=>{"use strict";S();Z();er();ae();qe();j();Et=O(),mi=()=>{let{data:e}=A("getNetworkStatusSync");return!!(e!=null&&e.isConnected)},St=new Ye(K,{get:(e,t)=>X(e,h({method:"GET",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data),post:(e,t,r)=>X(e,h({method:"POST",responseType:"json",appendHostCookie:!0},r)).then(n=>n.response.data)},mi),pi=N("adInit",{implement:e=>{St.init(e)}}),fi=N("adConfig",{implement:e=>{St.adConfig(e)}}),hi=N("adBreak",{implement:e=>{St.adBreak(e)}}),gi=N("adUnit",{implement:e=>{St.adUnit(e)}});Et.registerCommand("AdsSDK.init",pi);Et.registerCommand("AdsSDK.adConfig",fi);Et.registerCommand("AdsSDK.adBreak",hi);Et.registerCommand("AdsSDK.adUnit",gi);E("AdsSDK.init",{version:"1.0.0"});E("AdsSDK.adConfig",{version:"1.0.0"});E("AdsSDK.adBreak",{version:"1.0.0"});E("AdsSDK.adUnit",{version:"1.0.0"})});var dr,yi,vi,bi,ho=f(()=>{"use strict";S();j();Z();J();dr=O(),yi=N("openSchemaSync",{paramsSchema:d.tuple(d.string()),implement:e=>{let t=e;e.match(/^https?:\/\//)||(t=`https://${y.mpId}.app.jolibox.com${e.startsWith("/")?"":"/"}${e}`);let r=A("openSchemaSync",{schema:t});if(r.errNo!==0)throw new Re(r.errMsg,r.errNo)}}),vi=N("openPageSync",{paramsSchema:d.tuple(d.string()),implement:e=>{let{errNo:t,errMsg:r,data:n}=A("openPageSync",{url:e});if(t!==0||!n)throw new Re(r,t);return{webviewId:n.webviewId}}}),bi=N("closePageSync",{paramsSchema:d.tuple(d.number()),implement:e=>{let{errNo:t,errMsg:r}=A("closePageSync",{webviewId:e});if(t!==0)throw new Re(r,t)}});dr.registerCommand("RouterSDK.openSchema",yi);dr.registerCommand("RouterSDK.openPage",vi);dr.registerCommand("RouterSDK.closePage",bi);E("router.openSchema",{version:"1.1.10"});E("router.openPage",{version:"1.1.10"});E("router.closePage",{version:"1.1.10"})});var ki={};var Ad,Nd,go=f(()=>{"use strict";Zn();Ad=yr(eo());ao();co();lo();Nd=yr(uo());po();fo();ho()});var yo=Symbol.for("JOLIBOX_IMPLEMENT_INIT");if(window[yo])throw console.info("Jolibox Implement Already Initialized"),new Error("Jolibox Implement Already Initialized");window[yo]=!0;v(void 0,null,function*(){let[{config:e}]=yield Promise.all([Promise.resolve().then(()=>(qn(),Kn)),Promise.resolve().then(()=>(go(),ki)),Promise.resolve().then(()=>(ae(),Un))]);e()});
|
|
19
|
+
`;e.textContent=s;let i=document.head||document.getElementsByTagName("head")[0];i.insertBefore(e,i.firstChild),document.documentElement.setAttribute("data-jolibox-root","")},n=()=>{function s(a){return b(this,null,function*(){let l=a instanceof URL?a.href:a,d=new Promise((c,m)=>{let p=new XMLHttpRequest;p.open("GET",l),p.responseType="arraybuffer",p.addEventListener("load",()=>c(p.response)),p.addEventListener("error",m),p.send()});try{let c=yield d;return new Response(c,{headers:new Headers([["Content-Type","application/wasm"]])}).clone()}catch(c){throw console.error("Failed to load wasm:",c),c}})}let i=window.fetch;window.fetch=(a,l)=>{let d=a instanceof URL?a.href:a.toString();return d.endsWith(".wasm")?s(d):i(a,l)}},o=()=>{e!=null&&e.parentNode&&(e.parentNode.removeChild(e),e=null),document.documentElement.removeAttribute("data-jolibox-root"),window.fetch=t};return r(),n(),o}var An=g(()=>{"use strict"});var He,xn=g(()=>{"use strict";He=class{constructor(t){this.track=t;this.adBreakIsShowing=!1;this.reportPageJumpOut=()=>{this.track("AdBreakJumpOut",{context:"AdsActionDetection"})};this.reportPageHide=()=>{this.track("AdBreakHide",{context:"AdsActionDetection"})};window.addEventListener("visibilitychange",()=>{document.hidden&&this.adBreakIsShowing&&this.reportPageHide()}),window.addEventListener("beforeunload",r=>{this.adBreakIsShowing&&this.reportPageJumpOut()})}}});var Je,cs,ls,ds,us,Cn=g(()=>{"use strict";Je=class{constructor(t,r,n,o){this.track=t;this.httpClient=r;this.checkNetwork=n;this.checkAdsDisplayPermission=t=>{if(!this.checkNetwork())return{reason:"NETWORK_NOT_OK"};let r=this.checkShouldBanInitial();if(r)return{reason:r};let n=this.checkShouldBanForSession(t);if(n)return{reason:n};let o=this.checkShouldBanHighFreq(t);if(o)return o;let s=this.checkShouldBanForTime(t);return s?{reason:s}:{reason:"ALLOWED"}};var p,T,w,v,f,k,_;let s=(p=o==null?void 0:o.maxAllowedAdsForTime)!=null?p:8,i=(T=o==null?void 0:o.banForTimeThreshold)!=null?T:6e4,a=(w=o==null?void 0:o.bannedReleaseTime)!=null?w:6e4,l=(v=o==null?void 0:o.maxAllowedAdsForSession)!=null?v:200,d=(f=o==null?void 0:o.banForSessionThreshold)!=null?f:6e5,c=(k=o==null?void 0:o.initialThreshold)!=null?k:2e3,m=(_=o==null?void 0:o.highFreqThreshold)!=null?_:2e3;this.checkShouldBanInitial=ds(c),this.checkShouldBanHighFreq=us(m),this.checkShouldBanForTime=ls(s,i,a),this.checkShouldBanForSession=cs(l,d)}report(t,r){let n=r?{reason:t,count:r}:{reason:t};this.track("PreventAdsCheating",n),this.httpClient.post("/api/base/app-event",{data:{eventType:"PREVENT_ADS_CHEATING",adsInfo:n}})}},cs=(e,t)=>{let r=!1,n=[];return s=>{if(r)return"BANNED_FOR_SESSION";let i=Date.now();if(n=n.concat({timestamp:i,type:s}),n.length!==1&&(n.length>e&&(n=n.slice(-e)),n.length===e&&i-n[0].timestamp<=t))return r=!0,"BANNED_FOR_SESSION"}},ls=(e,t,r)=>{let n=null,o=c=>{n&&(window.clearTimeout(n),n=null),n=window.setTimeout(()=>{l.value=!1,n=null},c)},s="jolibox-sdk-ads-callbreak-timestamps",i="jolibox-sdk-ads-ban-for-time",a={_records:[],init(){var c;try{let m=JSON.parse((c=window.localStorage.getItem(s))!=null?c:"[]");Array.isArray(m)?this._records=m:this._records=[]}catch(m){this._records=[]}},get values(){return this._records},set values(c){try{window.localStorage.setItem(s,JSON.stringify(c))}catch(m){}this._records=c}},l={_record:!1,init(){var c;try{let m=JSON.parse((c=window.localStorage.getItem(i))!=null?c:"false");typeof m=="boolean"&&(this._record=m)}catch(m){this._record=!1}if(this._record){let m=a.values[a.values.length-1],p=m?Date.now()-m.timestamp:r;p<=r&&p>0?o(p):this._record=!1}},get value(){return this._record},set value(c){try{window.localStorage.setItem(i,JSON.stringify(c))}catch(m){}this._record=c}};return a.init(),l.init(),c=>{if(l.value)return"WAITING_BANNED_RELEASE";let m=Date.now();if(a.values=a.values.concat({timestamp:m,type:c}),a.values.length!==1&&(a.values.length>e&&(a.values=a.values.slice(-e)),a.values.length===e&&m-a.values[0].timestamp<=t))return l.value=!0,o(r),"BANNED_FOR_TIME"}},ds=e=>{let t=Date.now();return()=>{if(Date.now()-t<=e)return"BLOCK_INITIAL"}},us=(e=2e3)=>{let t=0,r=null;return o=>{if(o==="reward"){if(r)return t+=1,{reason:"HOLDING_HIGH_FREQ",info:{count:t}};r=window.setTimeout(()=>{r&&(window.clearTimeout(r),r=0,t=0)},e)}}}});var Ve,Pn=g(()=>{"use strict";q();Ve=class{constructor(t){this.httpClient=t;this.configs=null;this.firstRun=!0;this.init()}init(){return b(this,null,function*(){try{this.configs=yield this.httpClient.get("/api/fe-configs/js-sdk/ads-channel-config")}catch(t){}})}shouldBypassCallingInterstitial(){var r,n;let t;if(!this.configs)this.init(),t=!this.firstRun;else{let o=(r=E.channel)!=null?r:"",s=this.configs[o],i=(n=s==null?void 0:s.interstitialRate)!=null?n:1;t=Math.random()<i}return this.firstRun=!1,t}}});var ge,$e,zt=g(()=>{"use strict";xn();Cn();q();Pn();S();ge=new z,$e=class{constructor(t,r,n){this.track=t;this.httpClient=r;this.checkNetwork=n;this.configured=!1;this.config={};this.getGameId=()=>E.mpId;this.getTestAdsMode=()=>E.testAdsMode;this.asyncLoad=()=>b(this,null,function*(){var i,a,l,d,c;let t="ca-pub-7171363994453626",r,n,o=window.encodeURIComponent(window.btoa((i=this.getGameId())!=null?i:"")),s=(a=this.getTestAdsMode())!=null?a:!1;try{let m=yield this.httpClient.get("/public/ads",{query:{objectId:o,testAdsMode:`${s}`}});t=(l=m.data)==null?void 0:l.clientId,r=(d=m.data)==null?void 0:d.channelId,n=(c=m.data)==null?void 0:c.unitId}catch(m){console.error("Failed to fetch client info",m)}this.clientId=t,this.channelId=r,this.unitId=n});this.asyncInit=t=>b(this,null,function*(){var o;if(typeof window=="undefined")return;yield this.asyncLoad();let r="google-adsense",n=(o=this.getTestAdsMode())!=null?o:!1;if(!document.getElementById(r)&&this.clientId){let s=document.createElement("script");s.id=r,s.async=!0,s.crossOrigin="anonymous",s.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`,n&&s.setAttribute("data-adbreak-test","on"),this.channelId&&s.setAttribute("data-ad-channel",this.channelId),document.head.appendChild(s),this.track("LoadAdsenseCompleted",null)}});this.push=(t={})=>{window.adsbygoogle.push(t)};this.wrapAdBreakParams=t=>{if((n=>n.type==="preroll")(t)){ge.emit("isAdShowing",!0);let n=t.adBreakDone,o=s=>{ge.emit("isAdShowing",!1),n&&n(s)};return x(y({},t),{adBreakDone:o})}else{let n=t.beforeAd,o=t.afterAd,s=()=>{var a;ge.emit("isAdShowing",!0),this.track("CallBeforeAd",{type:t.type,name:(a=t.name)!=null?a:""}),n&&n()},i=()=>{var a;ge.emit("isAdShowing",!1),this.track("CallAfterAd",{type:t.type,name:(a=t.name)!=null?a:""}),o&&o()};return x(y({},t),{beforeAd:s,afterAd:i})}};this.adConfig=t=>{let o=t,{onReady:r}=o,n=ae(o,["onReady"]);this.track("CallAdConfig",n),this.configured?console.warn("Ad config already set, skipping"):(this.configured=!0,this.push(t))};this.adBreak=t=>{var d,c,m,p,T,w;if(!this.getGameId()){console.warn("Game ID is not set, skip calling adBreak");return}if(t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){(d=t.adBreakDone)==null||d.call(t,{breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}let{reason:r,info:n}=this.antiCheating.checkAdsDisplayPermission(t.type==="reward"?"reward":"interstitial");switch(r){case"NETWORK_NOT_OK":case"BANNED_FOR_SESSION":(c=t.adBreakDone)==null||c.call(t,{breakType:t.type,breakName:r,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"}),this.antiCheating.report(r);return;case"BLOCK_INITIAL":case"BANNED_FOR_TIME":case"WAITING_BANNED_RELEASE":(m=t.adBreakDone)==null||m.call(t,{breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"}),this.antiCheating.report(r);return;case"HOLDING_HIGH_FREQ":(T=t.adBreakDone)==null||T.call(t,{breakFormat:t.type==="reward"?"reward":"interstitial",breakName:"",breakStatus:((p=n==null?void 0:n.count)!=null?p:0)>6?"other":"frequencyCapped",breakType:t.type}),n!=null&&n.count&&n.count!==0&&n.count%3===0&&this.antiCheating.report(r,n==null?void 0:n.count);return;default:break}let o=t.type,s=t.adBreakDone,i=v=>{var f;this.adsActionDetection.adBreakIsShowing=!1,this.track("CallAdBreakDone",{breakType:v.breakType,breakName:(f=v.breakName)!=null?f:"",breakFormat:v.breakFormat,breakStatus:v.breakStatus}),s&&s(v)};if(t.adBreakDone=i,t.type==="reward"){let v=t.beforeReward,f=_=>()=>{this.track("CallShowAdFn",null),_()},k=_=>{v&&v(f(_))};t.beforeReward=k}let a;switch(o){case"preroll":a={type:o};break;case"start":case"pause":case"next":case"browse":case"reward":a={type:o,name:(w=t.name)!=null?w:""};break}this.adsActionDetection.adBreakIsShowing=!0,this.track("CallAdBreak",a);let l=this.wrapAdBreakParams(t);this.push(l),window.JoliTesterBridge&&console.log("joli-fullscreen-ad-show")};this.adUnit=t=>b(this,null,function*(){var p,T,w,v;if(this.track("CallAdUnit",{adFormat:(T=(p=t.adFormat)==null?void 0:p.toString())!=null?T:null,fullWidthResponsive:(w=t.fullWidthResponsive)!=null?w:null}),this.clientId||(yield this.asyncLoad()),document.querySelector("#jolibox-ads")){console.warn("Ad unit already set, skipping");return}let{el:r,slot:n,adFormat:o,fullWidthResponsive:s,style:i}=t,a;if(!r)throw new Error("targeting element is required");if(typeof r=="string"?a=document.querySelector(r):a=r,!a)throw new Error("targeting element not found");let l=n;if(l||(l=this.unitId),!l)throw new Error("slot is required");let d=typeof o=="object"&&Array.isArray(o)?o.join(", "):o,c=document.createElement("ins");if(c.className="adsbygoogle",c.id="jolibox-ads",c.style.display="block",c.setAttribute("data-ad-client",this.clientId),c.setAttribute("data-ad-slot",l),d&&c.setAttribute("data-ad-format",d),s&&c.setAttribute("data-full-width-responsive",s),i&&c.setAttribute("style",i),(v=this.getTestAdsMode())!=null?v:!1){let f=document.createElement("div");f.style.position="absolute",f.style.top="0",f.style.left="0",f.style.width="100%",f.style.height="100%",f.style.display="flex",f.style.justifyContent="center",f.style.alignItems="center",f.style.backgroundColor="rgba(0, 0, 0, 0.5)",f.style.color="white",f.innerHTML="Test Ad",c.style.position="relative",a.appendChild(c),c.appendChild(f)}else a.appendChild(c),new MutationObserver(k=>{k.forEach(_=>{if(_.type==="attributes"&&_.attributeName==="data-ad-status"){let h=c.getAttribute("data-ad-status");this.track("AdSenseUnitStatusChanged",{status:h!=null?h:"null"})}})}).observe(c,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})});this.antiCheating=new Je(t,r,n),this.adsActionDetection=new He(this.track),this.channelPolicy=new Ve(r)}init(t){this.track("CallAdsInit",null),typeof window!="undefined"&&(this.config=t!=null?t:{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}}});var Nn={};lr(Nn,{config:()=>hs});function ms(){Z.on("onDocumentReady",()=>{var e;(e=se)==null||e.onDocumentReady(window.location.href),J("onDocumentReady",{start_timestamp:Ge,timestamp:Date.now()})})}function ps(e){E.mpType==="game"&&B.start(e)}function fs(){W("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&E.onEnvConfigChanged({hostUserInfo:e}),Z.emit("LifecycleEvent.onReady",y({},E.hostUserInfo?E.hostUserInfo:{isLogin:!1})),J("joliboxServiceReady",{start_timestamp:Ge,timestamp:Date.now()}),ps(t)}),W("onBeforeExit",({uuid:e})=>{var t;(t=se)==null||t.doExit(e)})}function hs(){Ge=Date.now(),fs(),ms(),Ke=Rn()}var Ke,qe,Ge,On=g(()=>{"use strict";V();Fe();q();S();ie();An();zt();K.onReady(()=>{});K.doExit(()=>(J("onBeforeExit",{timestamp:Date.now()}),Ke==null||Ke(),B.close(Date.now()-Ge),!!qe));qe=!1;ge.on("isAdShowing",e=>{qe=e,gr(qe)&&C("updateContainerConfigSync",{displayCapsuleButton:!qe,webviewId:E.webviewId})})});function Dn(e){let t=_t.config[e];return t||(t={},_t.config[e]=t),(r,n)=>{if(t[r]){j.warn(`[can i use] ${r} already registered`);return}t[r]=y({},n)}}var Fn=g(()=>{"use strict";S()});function Wt(e){Un=e}function ze(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>ze(t)):Object.keys(e).reduce((t,r)=>(t[r]=ze(e[r]),t),{})}function ee(e){return typeof e=="number"}function Yt(e){let t=Qt(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Qt(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Un,P,We,Ye,Qe,Xe,ye,Ze,et,tt,rt,nt,ot,st,it,at,ct,lt,dt,Xt=g(()=>{"use strict";Un=!1;P=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Un)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${Yt(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return ze(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:ze(this._default)}optional(){return this._optional=!0,this}};We=class extends P{validate(t){return this._optional&&t===void 0?!0:ee(t)?ee(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):ee(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):ee(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},Ye=class extends P{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Qe=class extends P{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(ee(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(ee(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},Xe=class extends P{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ye=class extends P{validate(t){return!0}},Ze=class extends P{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},et=class extends P{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},tt=class extends P{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},rt=class extends P{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(n=>JSON.stringify(n)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${Yt(t)}`)}return!0}},nt=class extends P{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(ee(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(ee(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(ee(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let n=this._item;if(!n)return!0;let o=!0;if(r.forEach((s,i)=>{if(n.path=`${this.path}[${i}]`,n.errors=this.errors,s===void 0&&n.hasDefault){r[i]=n.defaultValue;return}n.validate(s)||(n.hasFallback?r[i]=n.fallbackValue:o=!1)}),this._uniqueItems){let s=new Map;for(let i in r)s.has(r[i])?o=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${s.get(r[i])}] and ${this.path}[${i}] are identical)`):s.set(r[i],i)}return o}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},ot=class extends P{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Qt(r)!=="object")return this.fail({expect:"object",actual:r});let o=r,s=this._value;s.errors=this.errors;let i=!0;for(let a in o){let l=o[a];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(a)?s.path=`${this.path}.${a}`:s.path=`${this.path}["${a}"]`,!(l===void 0&&s._optional)){if(l===void 0&&s.hasDefault){o[a]=s.defaultValue;continue}s.validate(l)||(s.hasFallback?o[a]=s.fallbackValue:i=!1)}}return i}},st=class extends P{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Qt(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,o=!0;for(let s in this._object){let i=n[s],a=this._object[s];if(a.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(s)?a.path=`${this.path}.${s}`:a.path=`${this.path}["${s}"]`,!(a._optional&&i===void 0)){if(i===void 0&&a.hasDefault){n[s]=a.defaultValue;continue}a.validate(i)||(a.hasFallback?n[s]=a.fallbackValue:o=!1)}}return o}},it=class extends P{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:Yt(this.value),actual:r}):!0}},at=class extends P{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,o=this._items.length;for(let s=0;s<o;s++){let i=this._items[s];if(i.errors=[],i.path=this.path,!i.validate(t))r.push(i.errors.join("; "));else if(!n){n=!0;break}}if(!n){let s=r.join(`
|
|
20
|
+
or `);this.errors.push(s)}return n}},ct=class extends P{constructor(...t){super(),this._items=t;let r=0,n=t.length-1;for(;n>=0;n--){let o=t[n];if(o._optional||o.hasDefault)r+=1;else break}this._minItems=t.length-r}validate(t){if(t===void 0&&this._optional)return!0;if(!Array.isArray(t))return this.fail({expect:"array",actual:t});if(t.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let r=!0;return this._items.forEach((n,o)=>{if(n.path=`${this.path}[${o}]`,n.errors=this.errors,t[o]===void 0&&n.hasDefault){t[o]=n.defaultValue;return}n.validate(t[o])||(n.hasFallback?t[o]=n._fallback:r=!1)}),r}},lt=class extends P{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},dt=class extends P{constructor(t){super(),this._ctor=t}validate(t){return t===void 0&&this._optional||t instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:t})}}});function Zt(e,t,r="param"){if(e.errors=[],e.path=r,Wt(!0),!e.validate(t)){let n=e.errors.join(`
|
|
21
|
+
`);throw e.errors.length=0,Wt(!1),new TypeError(n)}}var u,er=g(()=>{"use strict";Xt();Xt();u={object(e){return new st(e)},array(e){return new nt(e)},tuple(...e){return new ct(...e)},literal(e){return new it(e)},or(...e){return new at(...e)},symbol(){return new Xe},record(e){return new ot(e)},function(){return new tt},boolean(){return new Ye},string(){return new Qe},number(){return new We},undefined(){return new Ze},null(){return new et},unknown(){return new ye},any(){return new ye},as(){return new ye},arraybuffer(){return new lt},enum(...e){return new rt(...e)},typedarray(e){return new dt(e)}}});var ut,Mn,Ln=g(()=>{"use strict";S();$();er();oe();ut=1,Mn=e=>{function t(n,o){return(...s)=>{var m,p,T,w;let i=Date.now(),a={method:n,trace_id:ut};ut+=1;let l="SUCCESS",d=`${n}:ok`,c=0;try{if(o.paramsSchema)try{Zt(o.paramsSchema,s,"params")}catch(_){throw Ct(`${n}:fail ${_.message}`)}let v=o.implement(...s),f=v,k=`${n}:ok`;if(v&&"code"in v){let{code:_,data:h,message:A}=v;l=_,f=h,k=A}return{code:l,message:k,data:f}}catch(v){let f=v;c=(p=(m=f.code)!=null?m:f.errNo)!=null?p:2e3,l="FAILURE";let k=(w=(T=f.message)!=null?T:f.errMsg)!=null?w:`${v}`;return d=`${n}:${l} ${k.replace(/^\S+:(fail|cancel)\s?/,"")}`,F(new Ie(d,c)),{code:l,message:d}}finally{let v=Date.now()-i;e("apiInvoked",x(y({},a),{duration:v,status:l}))}}}function r(n,o){return(...s)=>b(this,null,function*(){var p,T,w,v;let i=hr(s)?s:[s],a=Date.now(),l={method:n,trace_id:ut};ut+=1;let d=`${n}:ok`,c="SUCCESS",m={code:c,message:d};try{if(o.paramsSchema)try{Zt(o.paramsSchema,i,"params")}catch(_){throw Ct(_.message)}let k=yield o.implement(...i);if(k&&"code"in k){let{code:_,data:h,message:A}=k;c=_,d=A,k=h}return Object.assign(m,{code:c,message:d,data:k}),m}catch(f){let k=f,_=(T=(p=k.code)!=null?p:k.errNo)!=null?T:2e3;c="FAILURE";let h=(v=(w=k.message)!=null?w:k.errMsg)!=null?v:`${f}`,A=`${n}:${c} ${h.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(m,{code:c,message:A}),F(new Ie(A,_)),m}finally{let f=Date.now()-a;e("apiInvoked",x(y({},l),{duration:f,status:c}))}})}return{createAPI:r,createSyncAPI:t}}});var N,D,I,te=g(()=>{"use strict";Fn();ie();Ln();er();({createAPI:N,createSyncAPI:D}=Mn(J)),I=Dn("native")});var Bn,ys,vs,bs,ks,jn=g(()=>{"use strict";S();te();V();Bn=O(),ys="env",vs="getSystemInfoSync",bs=D(vs,{implement:()=>{var r;let e=C("envSync"),{data:t}=e;return{system:t.deviceInfo.system,platform:t.deviceInfo.platform,version:t.sdkInfo.jssdkVersion,pixelRatio:t.deviceInfo.pixelRatio,language:t.deviceInfo.lang,brand:t.deviceInfo.brand,appName:(r=t.hostInfo)==null?void 0:r.appName,SDKVersion:t.sdkInfo.jssdkVersion}}}),ks=D(ys,{implement:()=>{var t;let e=C("envSync");return(t=e==null?void 0:e.data)!=null?t:void 0}});Bn.registerCommand("API.getSystemInfoSync",bs);Bn.registerCommand("API.env",ks);I("env",{version:"1.0.0"});I("getSystemInfoSync",{version:"1.0.0"})});var Hn=cr(tr=>{"use strict";S();te();$();V();ie();var Ts="exitGame",Es="onReady",Ss="onJoliboxShow",Is="onJoliboxHide",mt=O(),pt=Oe(F),ws=N(Ts,{paramsSchema:u.tuple(u.function()),implement:e=>b(tr,null,function*(){pt(e).call(tr),yield H("exitAppAsync")})}),_s=D(Ss,{paramsSchema:u.tuple(u.function()),implement(e){let t=pt(e);W("onJoliboxEnterForeground",()=>{t.call(this),we.emit("visible",!0)})}}),Rs=D(Is,{paramsSchema:u.tuple(u.function()),implement(e){let t=pt(e);W("onJoliboxEnterBackground",()=>{t.call(this),we.emit("visible",!1)})}}),As=D(Es,{paramsSchema:u.tuple(u.function()),implement(e){let t=pt(e);Z.on("LifecycleEvent.onReady",r=>{t(r)})}});mt.registerCommand("LifecycleSDK.exit",ws);mt.registerCommand("LifecycleSDK.onReady",As);mt.registerCommand("LifecycleSDK.onJoliboxShow",_s);mt.registerCommand("LifecycleSDK.onJoliboxHide",Rs);I("lifeCycle.exit",{version:"1.0.0"});I("lifeCycle.onReady",{version:"1.0.0"});I("lifeCycle.onJoliboxShow",{version:"1.0.0"});I("lifeCycle.onJoliboxHide",{version:"1.0.0"})});function Jn(e){let t={};if(!M(e))return t;for(let[r,n]of Object.entries(e)){let o=r.toLocaleLowerCase();n?typeof n=="object"?t[o]=Object.prototype.toString.call(n):t[o]=String(n):t[o]=""}return t}function Vn(e="GET"){if(e==="")return"POST";let t=e.toUpperCase();return["GET","OPTIONS","HEAD","POST","PUT","DELETE","TRACE","CONNECT","PATCH"].includes(t)?t:"GET"}function $n(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function Kn(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!M(r))return e;let[n,o=""]=e.split("?"),s=JSON.stringify(y(y({},JSON.parse(o)),r));return`${n}?${s}`}var qn=g(()=>{"use strict";S()});var xs,Cs,rr,nr,Gn,Ps,Ns,Os,zn=g(()=>{"use strict";oe();qt();te();qn();S();$();xs=15,Cs=Le("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),rr=0,nr=[],Gn=Oe(F),Ps=(e,t)=>{let r=e.filter(t),n=e.filter(o=>!t(o));return e.length=0,e.push(...n),r},Ns=e=>{let t=new ne,r=()=>{};return N("request",{paramsSchema:u.tuple(u.object({url:u.string(),method:u.string(),header:u.object(),data:u.object().optional(),query:u.object().optional(),dataType:u.string().default("json"),responseType:u.string().default("text"),enableCache:u.boolean().default(!1),appendHostCookie:u.boolean().default(!0),timeout:u.number().default(3e4),success:u.function(),fail:u.function()})),implement(o){let s=()=>b(this,null,function*(){var a,l;let i=Gn(o.fail);try{if(rr+=1,t.state!=="pending")return;let{data:d,dataType:c,responseType:m,enableCache:p,appendHostCookie:T}=o,w=Jn(o.header),v=Vn(o.method),f=$n(o.timeout),k=Kn(o.url,v,d),_=Gn(o.success),h=Object.assign({},o,{method:v,header:w,data:v==="GET"||v==="HEAD"?void 0:d,enableCache:p,query:(a=o.query)!=null?a:{},dataType:c,responseType:m,appendHostCookie:T});f&&(h.timeout=f);let A=Cs(k,h);{let{response:fe}=yield A,{code:U,data:be,message:re}=fe;t.resolve({code:U!=null?U:"SUCCESS",data:be,message:re!=null?re:"request:ok"}),_({code:"SUCCESS",message:"request:ok",data:be})}}catch(d){t.reject(d),i({code:"FAILURE",message:"httpRequst: failed"})}finally{rr-=1,(l=nr.shift())==null||l()}});return rr>=xs?(r=()=>{Ps(nr,i=>i===s)},nr.push(s)):s(),t.promise}})(e),{abort(){t.reject(ue({code:-1,msg:"request:fail abort"})),r()}}},Os=O();Os.registerCommand("HttpSDK.request",Ns);I("request",{version:"1.0.0"})});function Bs(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return Ls.includes(t)?t:""}function js(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 Hs(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch(r){return""}}var ft,Ds,Fs,Us,Ms,ud,md,Ls,Wn=g(()=>{"use strict";te();V();S();Be();q();ft=O(),Ds=N("getLocalStorage",{paramsSchema:u.tuple(u.string()),implement(e){return b(this,null,function*(){let{response:t}=yield Y(`/api/games/user-storage/${E.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:o}}=yield t;if(r==="SUCCESS")return{code:r,message:n,data:o==null?void 0:o.value};try{let{data:{data:s,dataType:i}}=yield H("getLocalStorageAsync",{key:e}),a=js(s,i);return{code:r,message:`${n}. fallback to native`,data:a}}catch(s){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}})}});ft.registerCommand("StorageSDK.getItem",Ds);I("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});Fs=N("setStorage",{paramsSchema:u.tuple(u.string(),u.or(u.string(),u.boolean(),u.number())),implement(e,t){return b(this,null,function*(){let r=E.mpId,n=typeof t=="string"?t:String(t),{response:o}=yield Y(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:s,message:i}}=o,a=Bs(t),l=Hs(t,a);return yield H("setLocalStorageAsync",{key:e,data:l,dataType:a}),s=="SUCCESS"?{code:s,message:i}:{code:s,message:`${i}. fallback to native`}})}});ft.registerCommand("StorageSDK.setItem",Fs);I("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});Us=N("removeStorage",{paramsSchema:u.tuple(u.string()),implement(e){return b(this,null,function*(){let t=E.mpId,{response:r}=yield Y(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:o}}=r;return yield H("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:o}:{code:n,message:"[Jolibox SDK] remove item succ"}})}});ft.registerCommand("StorageSDK.removeItem",Us);I("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});Ms=N("clearStorage",{implement(){return b(this,null,function*(){let e=E.mpId,{response:t}=yield Y(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});H("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}})}});ft.registerCommand("StorageSDK.clear",Ms);I("storage.clear",{version:"1.0.0"});ud=N("getStorageInfo",{implement(){return b(this,null,function*(){let{data:e}=yield H("getStorageInfoAsync");return e})}});I("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});md=D("getStorageInfoSync",{implement(){return C("getStorageInfoSync")}}),Ls=["string","number","boolean","object",""]});var Js,Vs,$s,or,Yn=g(()=>{"use strict";S();V();te();Js=D("showKeyboard",{paramsSchema:u.tuple(u.object({defaultValue:u.string().optional().default(""),multiple:u.boolean().optional().default(!1),maxLength:u.unknown().optional().default(1e5)})),implement(e){var n;let t=Math.floor((n=Number(e.maxLength))!=null?n:1e5),{defaultValue:r}=e;r&&t&&(r=r.slice(0,t)),C("showKeyboardSync",x(y({},e),{defaultValue:r,maxLength:t}))}});I("keyboard.showKeyboard",{version:"1.0.0",properties:{params:{defaultValue:"1.0.0",multiple:"1.0.0",confirmHold:"1.0.0",confirmType:"1.0.0",maxLength:"1.0.0"}},success:{errMsg:"1.0.0"}});Vs=D("updateKeyboard",{paramsSchema:u.tuple(u.object({value:u.string()})),implement(e){C("updateKeyboardSync",e)}});I("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});$s=D("hideKeyboard",{implement(){C("hideKeyboardSync")}});I("keyboard.hideKeyboard",{version:"1.0.0"});or=O();or.registerCommand("KeyboardSDK.showKeyboard",Js);or.registerCommand("KeyboardSDK.updateKeyboard",Vs);or.registerCommand("KeyboardSDK.hideKeyboard",$s)});var Qn=cr(pe=>{"use strict";S();te();ie();var ve=O(),Ks=N("levelFinished",{paramsSchema:u.tuple(u.string(),u.object({result:u.boolean(),duration:u.number()})),implement:(e,t)=>b(pe,null,function*(){let{result:r,duration:n}=t,o=[];o.push(B.tracker("LevelFinished",{levelId:e,result:r,duration:n})),o.push(B.reporter({event:"COMPLETE_GAME_LEVEL"})),yield Promise.all(o)})}),qs=N("taskFinished",{paramsSchema:u.tuple(u.string(),u.object({duration:u.number()})),implement:(e,t)=>b(pe,null,function*(){let{duration:r}=t;return yield B.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})})}),Gs=N("levelUpgrade",{paramsSchema:u.tuple(u.string(),u.string()),implement:(e,t)=>b(pe,null,function*(){let r=[];r.push(B.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),yield Promise.all(r)})}),zs=N("onHistoryUserLevel",{paramsSchema:u.tuple(u.number()),implement:e=>b(pe,null,function*(){return yield B.reportToNative({event:"HistoryUserLevel",params:{level:e}})})}),Ws=N("onHistoryUserScore",{paramsSchema:u.tuple(u.number()),implement:e=>b(pe,null,function*(){return yield B.reportToNative({event:"HistoryUserScore",params:{score:e}})})}),Ys=N("taskEvent",{paramsSchema:u.tuple(u.string(),u.object({tools:u.array(u.object({id:u.string(),name:u.string(),count:u.number(),description:u.string().optional(),price:u.object({amount:u.number(),unit:u.string()}).optional()})).optional(),awards:u.array(u.object({id:u.string(),name:u.string()})).optional()})),implement:(e,t)=>b(pe,null,function*(){var n,o;let r=[];r.push(B.reportToNative({event:"TaskEvent",params:y({taskId:e},t)})),(o=(n=t.tools)==null?void 0:n.length)!=null&&o&&(r.push(B.reporter({event:"USE_GAME_ITEM"})),r.push(B.reportToNative({event:"UseGameItem",params:y({taskId:e},t)}))),yield Promise.all(r)})});ve.registerCommand("TaskTrackerSDK.levelFinished",Ks);ve.registerCommand("TaskTrackerSDK.taskFinished",qs);ve.registerCommand("TaskTrackerSDK.levelUpgrade",Gs);ve.registerCommand("TaskTrackerSDK.historyUserLevel",zs);ve.registerCommand("TaskTrackerSDK.historyUserScore",Ws);ve.registerCommand("TaskTrackerSDK.taskEvent",Ys);I("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});I("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});I("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});I("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});I("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});I("TaskTrackerSDK.onTaskEvent",{version:"1.0.0",properties:{taskId:"1.0.0",params:{tools:{id:"1.0.0",name:"1.0.0",count:"1.0.0",description:"1.0.0",price:{amount:"1.0.0",unit:"1.0.0"}},awards:{id:"1.0.0",name:"1.0.0"}}}})});var Qs,Xs,Xn,Zn=g(()=>{"use strict";q();V();te();S();oe();I("login",{version:"1.0.0",properties:{force:"1.0.0"},success:{errMsg:"1.0.0",code:"1.0.0",token:"1.0.0",isLogin:"1.0.0"}});I("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});Qs=N("login",{implement(){return b(this,null,function*(){var i;let{data:{isLogin:e}}=yield H("checkLoginAsync");if(e)return{isLogin:!0,token:(i=E.hostUserInfo)==null?void 0:i.token};W("onLoginStateChange",({isLogin:a,token:l,uuid:d})=>{d==r&&o({isLogin:a,token:l})});let t=C("loginSync"),{data:{uuid:r}}=t;if(!r)throw ue({code:-1,msg:"login failed"});let{promise:n,resolve:o}=new ne,s=yield n;return E.onEnvConfigChanged({hostUserInfo:s}),Z.emit("onLoginComplete",s),s})}}),Xs=N("checkSession",{implement(){return b(this,null,function*(){let{data:{isLogin:e}}=yield H("checkLoginAsync");return{isLogin:e}})}}),Xn=O();Xn.registerCommand("API.login",Qs);Xn.registerCommand("API.checkSession",Xs)});var ht,Zs,gt,ei,ti,ri,ni,eo=g(()=>{"use strict";S();te();zt();ie();Be();V();ht=O(),Zs=()=>{let{data:e}=C("getNetworkStatusSync");return!!(e!=null&&e.isConnected)},gt=new $e(J,{get:(e,t)=>Y(e,y({method:"GET",responseType:"json",appendHostCookie:!0},t)).then(r=>r.response.data),post:(e,t,r)=>Y(e,y({method:"POST",responseType:"json",appendHostCookie:!0},r)).then(n=>n.response.data)},Zs),ei=D("adInit",{implement:e=>{gt.init(e)}}),ti=D("adConfig",{implement:e=>{gt.adConfig(e)}}),ri=D("adBreak",{implement:e=>{gt.adBreak(e)}}),ni=D("adUnit",{implement:e=>{gt.adUnit(e)}});ht.registerCommand("AdsSDK.init",ei);ht.registerCommand("AdsSDK.adConfig",ti);ht.registerCommand("AdsSDK.adBreak",ri);ht.registerCommand("AdsSDK.adUnit",ni);I("AdsSDK.init",{version:"1.0.0"});I("AdsSDK.adConfig",{version:"1.0.0"});I("AdsSDK.adBreak",{version:"1.0.0"});I("AdsSDK.adUnit",{version:"1.0.0"})});var oi={};var Kd,Wd,to=g(()=>{"use strict";jn();Kd=dr(Hn());zn();Wn();Yn();Wd=dr(Qn());Zn();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;b(void 0,null,function*(){let[{config:e}]=yield Promise.all([Promise.resolve().then(()=>(On(),Nn)),Promise.resolve().then(()=>(to(),oi)),Promise.resolve().then(()=>(ie(),_n))]);e()});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { On } from '../js-bridge';
|
|
2
|
-
export declare const applyNative: jsb.service.ApplyNative, invokeNative: jsb.service.InvokeNative, onNative: jsb.service.OnNative, offNative: jsb.service.OnNative, subscribeHandler: import("../js-bridge").SubscribeHandler
|
|
2
|
+
export declare const applyNative: jsb.service.ApplyNative, invokeNative: jsb.service.InvokeNative, onNative: jsb.service.OnNative, offNative: jsb.service.OnNative, subscribeHandler: import("../js-bridge").SubscribeHandler;
|
|
3
3
|
export declare const onNativeWithError: On;
|
|
4
4
|
export { RuntimeLoader } from '../js-core';
|
|
@@ -2,7 +2,6 @@ export type Listener = (...args: any[]) => any;
|
|
|
2
2
|
export type On = <T extends string>(event: T, handler: Listener) => void;
|
|
3
3
|
export type Off = <T extends string>(event: T, handler: Listener) => void;
|
|
4
4
|
export type InvokeHandler = (callbackId: string | number, data: string | Record<string, unknown>) => void;
|
|
5
|
-
export type Publish = (event: string, data: Record<string, unknown>, webviewId?: number, force?: boolean) => void;
|
|
6
5
|
export type SubscribeHandler = (event: string, data: string | Record<string, unknown>, webviewId?: number) => void;
|
|
7
6
|
export type AnyFunction = (...args: any[]) => any;
|
|
8
7
|
export interface JSBridge {
|
|
@@ -12,7 +11,4 @@ export interface JSBridge {
|
|
|
12
11
|
applyNative: jsb.service.ApplyNative;
|
|
13
12
|
onNative: jsb.service.OnNative;
|
|
14
13
|
offNative: jsb.service.OffNative;
|
|
15
|
-
publish: Publish;
|
|
16
|
-
subscribe: On;
|
|
17
|
-
unsubscribe: Off;
|
|
18
14
|
}
|
|
@@ -5,11 +5,6 @@ declare global {
|
|
|
5
5
|
invoke: (invokeString: string) => void;
|
|
6
6
|
onDocumentReady: (paramsstr: string) => void;
|
|
7
7
|
doExit: (uuidString: string) => void;
|
|
8
|
-
publish: (params: {
|
|
9
|
-
event: string;
|
|
10
|
-
webviewIds: number[] | '*';
|
|
11
|
-
paramsString: string;
|
|
12
|
-
}) => void;
|
|
13
8
|
};
|
|
14
9
|
webkit?: {
|
|
15
10
|
messageHandlers: {
|
|
@@ -23,7 +18,7 @@ declare global {
|
|
|
23
18
|
publish: {
|
|
24
19
|
postMessage: (params: {
|
|
25
20
|
event: string;
|
|
26
|
-
webviewIds:
|
|
21
|
+
webviewIds: string;
|
|
27
22
|
paramsString: string;
|
|
28
23
|
}) => void;
|
|
29
24
|
};
|
|
@@ -44,7 +39,7 @@ declare global {
|
|
|
44
39
|
}
|
|
45
40
|
export declare const RuntimeLoader: {
|
|
46
41
|
trigger(): void;
|
|
47
|
-
exit():
|
|
42
|
+
exit(): boolean;
|
|
48
43
|
onReady(fn: () => void): void;
|
|
49
|
-
doExit(fn: () =>
|
|
44
|
+
doExit(fn: () => boolean): void;
|
|
50
45
|
};
|
package/implement.build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Invoking: npm run clean && npm run build:esm && tsc
|
|
2
2
|
|
|
3
|
-
> @jolibox/implement@1.1.
|
|
3
|
+
> @jolibox/implement@1.1.12 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/implement@1.1.
|
|
7
|
+
> @jolibox/implement@1.1.12 build:esm
|
|
8
8
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jolibox/implement",
|
|
3
3
|
"description": "This project is Jolibox JS-SDk implement for Native && H5",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.12",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@jolibox/common": "1.1.
|
|
10
|
-
"@jolibox/types": "1.1.
|
|
9
|
+
"@jolibox/common": "1.1.12",
|
|
10
|
+
"@jolibox/types": "1.1.12",
|
|
11
11
|
"localforage": "1.10.0",
|
|
12
12
|
"web-vitals": "4.2.4"
|
|
13
13
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mergeArray, mergeWith } from '@jolibox/common';
|
|
2
2
|
import { DeviceInfo, HostInfo, HostUserInfo, SdkInfo } from './types';
|
|
3
3
|
import { Env } from '@jolibox/types';
|
|
4
|
-
import { parseUrlQuery
|
|
4
|
+
import { parseUrlQuery } from './url-parse';
|
|
5
5
|
import { getAppVersion } from '../http/xua';
|
|
6
6
|
import { getDeviceId } from '@jolibox/common';
|
|
7
7
|
|
|
@@ -36,13 +36,12 @@ const env = Object.assign({}, nativeEnv?.() ?? defaultEnv);
|
|
|
36
36
|
type MPType = 'game' | 'miniApp';
|
|
37
37
|
|
|
38
38
|
const wrapContext = () => {
|
|
39
|
-
const { payloadJson, headerJson
|
|
39
|
+
const { payloadJson, headerJson } = env.schema.length ? parseUrlQuery(env.schema) : {};
|
|
40
40
|
const defaultSessionId = `${env.deviceInfo.did}-${new Date().getTime()}`;
|
|
41
41
|
const url = new URL(env.schema.length ? env.schema : window.location.href);
|
|
42
42
|
const urlParams = url.searchParams;
|
|
43
43
|
const defaultGameID = urlParams.get('mpId') ?? urlParams.get('appId') ?? urlParams.get('gameId') ?? '';
|
|
44
|
-
const sessionId =
|
|
45
|
-
env.clientSessionId ?? payloadJson?.sessionId ?? urlParams.get('sessionId') ?? defaultSessionId;
|
|
44
|
+
const sessionId = payloadJson?.sessionId ?? urlParams.get('sessionId') ?? defaultSessionId;
|
|
46
45
|
const testAdsMode = !!(payloadJson?.testAdsMode ?? urlParams.get('testAdsMode') === 'true');
|
|
47
46
|
const joliboxEnv = payloadJson?.joliboxEnv ?? urlParams.get('joliboxEnv') ?? 'production';
|
|
48
47
|
const testMode = joliboxEnv === 'staging';
|
|
@@ -94,24 +93,8 @@ const wrapContext = () => {
|
|
|
94
93
|
get webviewId(): number {
|
|
95
94
|
return env.webviewId ?? -1;
|
|
96
95
|
},
|
|
97
|
-
get shouldInterupt(): boolean | undefined {
|
|
98
|
-
return payloadJson?.__shouldInterupt;
|
|
99
|
-
},
|
|
100
|
-
get from(): number | undefined {
|
|
101
|
-
return payloadJson?.__from;
|
|
102
|
-
},
|
|
103
96
|
onEnvConfigChanged: (newConfig: Partial<Env>) => {
|
|
104
97
|
mergeWith(env, newConfig, mergeArray);
|
|
105
|
-
},
|
|
106
|
-
encodeJoliSourceQuery: (newPayloadJson: QueryParams['payloadJson']) => {
|
|
107
|
-
if (headerJson && signature) {
|
|
108
|
-
return encodeJoliSourceQuery({
|
|
109
|
-
headerJson,
|
|
110
|
-
payloadJson: { ...payloadJson, ...newPayloadJson },
|
|
111
|
-
signature
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
return urlParams.get('joliSource') ?? '';
|
|
115
98
|
}
|
|
116
99
|
};
|
|
117
100
|
};
|
|
@@ -14,12 +14,6 @@ interface PayloadJson {
|
|
|
14
14
|
joliboxEnv?: 'staging' | 'production';
|
|
15
15
|
sessionId?: string;
|
|
16
16
|
__mpType?: 'game' | 'miniApp';
|
|
17
|
-
__orientation?: 'HORIZONTAL' | 'VERTICAL';
|
|
18
|
-
__transparent?: boolean;
|
|
19
|
-
__entryPath?: string;
|
|
20
|
-
__showStatusBar?: boolean;
|
|
21
|
-
__shouldInterupt?: boolean;
|
|
22
|
-
__from?: number; // 从哪个小程序打开的
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
interface Signature {
|
|
@@ -27,7 +21,7 @@ interface Signature {
|
|
|
27
21
|
payloadSig?: string;
|
|
28
22
|
}
|
|
29
23
|
|
|
30
|
-
|
|
24
|
+
interface QueryParams {
|
|
31
25
|
headerJson: HeaderJson;
|
|
32
26
|
payloadJson: PayloadJson;
|
|
33
27
|
signature: Signature;
|
|
@@ -44,12 +38,6 @@ const base64UrlDecode = <T>(input: string): T => {
|
|
|
44
38
|
}
|
|
45
39
|
};
|
|
46
40
|
|
|
47
|
-
const base64UrlEncode = <T>(input: T): string => {
|
|
48
|
-
const jsonStr = JSON.stringify(input);
|
|
49
|
-
const base64 = btoa(jsonStr);
|
|
50
|
-
return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
51
|
-
};
|
|
52
|
-
|
|
53
41
|
export const parseUrlQuery = (url: string): QueryParams => {
|
|
54
42
|
try {
|
|
55
43
|
const urlObj = new URL(url);
|
|
@@ -75,11 +63,3 @@ export const parseUrlQuery = (url: string): QueryParams => {
|
|
|
75
63
|
};
|
|
76
64
|
}
|
|
77
65
|
};
|
|
78
|
-
|
|
79
|
-
export const encodeJoliSourceQuery = (queryParams: QueryParams): string => {
|
|
80
|
-
const { headerJson, payloadJson, signature } = queryParams;
|
|
81
|
-
const headerJsonStr = base64UrlEncode(headerJson);
|
|
82
|
-
const payloadJsonStr = base64UrlEncode(payloadJson);
|
|
83
|
-
const signatureJsonStr = base64UrlEncode(signature);
|
|
84
|
-
return `${headerJsonStr}.${payloadJsonStr}.${signatureJsonStr}`;
|
|
85
|
-
};
|
package/src/native/api/index.ts
CHANGED