@jolibox/implement 1.1.4-beta.11 → 1.1.4-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  "packages/implement/.eslintrc.js": "7a3d2747dc887655ca9e2d3ff621f7dfd98500b9",
5
5
  "packages/implement/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
6
6
  "packages/implement/esbuild.config.js": "889e44fb2f426aae078b59a42fcfb9c2f28ebd89",
7
- "packages/implement/package.json": "bec5a4c9a74a670946dca3857eb8454a03a55748",
7
+ "packages/implement/package.json": "c447d4847118a4fce0f4b1349f0c4925e5e91bff",
8
8
  "packages/implement/src/common/api-factory/index.ts": "b1c4018f18db700c80826d70465c79f0adf10a8c",
9
9
  "packages/implement/src/common/api-factory/validator/__tests__/validate/any.test.ts": "6e225e09fce401b374221ad2e4fe33bc91df4152",
10
10
  "packages/implement/src/common/api-factory/validator/__tests__/validate/array.test.ts": "8a9cc32be03e952f1176a970fea033d597c176cb",
@@ -39,7 +39,7 @@
39
39
  "packages/implement/src/common/report/errors/report/index.ts": "bee6f5f324ebddcc423c3549916a0eee04e880cf",
40
40
  "packages/implement/src/common/report/errors/report/listeners.ts": "794e5731d27b073c0576d03a6fa4c2a8bfd3b87a",
41
41
  "packages/implement/src/common/report/index.ts": "6d94d6985cb79a460ab9e2e84fa1b77b5db2b25a",
42
- "packages/implement/src/common/report/task-track/index.ts": "c20be7f9f88d4f606851b210feddd034eddc44dd",
42
+ "packages/implement/src/common/report/task-track/index.ts": "056d4ce9121648e94aa177e8e6b261adb455d244",
43
43
  "packages/implement/src/common/report/track.ts": "b20618f24668a625164300cf8d6629c0cea9e95d",
44
44
  "packages/implement/src/common/report/types.ts": "72e1e2d96860335ce67df6c7083883e2b219f194",
45
45
  "packages/implement/src/h5/ads/ads-action-detection.ts": "ad06449b7471e27b505c8688c0dd014b9e0a6a0f",
@@ -6,6 +6,9 @@ export type TaskPoint = {
6
6
  params?: Record<string, unknown>;
7
7
  };
8
8
  export declare abstract class TaskTracker {
9
+ readonly eventEmitter: EventEmitter<{
10
+ visible: [boolean];
11
+ }>;
9
12
  interval: number;
10
13
  lastReportTime: number;
11
14
  visible: boolean;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- var oo=Object.create;var Ir=Object.defineProperty;var io=Object.getOwnPropertyDescriptor;var so=Object.getOwnPropertyNames;var ao=Object.getPrototypeOf,co=Object.prototype.hasOwnProperty;var Ie=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var lo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var uo=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of so(t))!co.call(e,l)&&l!==n&&Ir(e,l,{get:()=>t[l],enumerable:!(i=io(t,l))||i.enumerable});return e};var fo=(e,t,n)=>(n=e!=null?oo(ao(e)):{},uo(t||!e||!e.__esModule?Ir(n,"default",{value:e,enumerable:!0}):n,e));var en=lo((Zr,Zt)=>{(function(e){if(typeof Zr=="object"&&typeof Zt<"u")Zt.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t=this,t.localforage=e()}})(function(){var e,t,n;return function i(l,d,m){function b(I,x){if(!d[I]){if(!l[I]){var h=typeof Ie=="function"&&Ie;if(!x&&h)return h(I,!0);if(_)return _(I,!0);var T=new Error("Cannot find module '"+I+"'");throw T.code="MODULE_NOT_FOUND",T}var C=d[I]={exports:{}};l[I][0].call(C.exports,function(N){var K=l[I][1][N];return b(K||N)},C,C.exports,i,l,d,m)}return d[I].exports}for(var _=typeof Ie=="function"&&Ie,A=0;A<m.length;A++)b(m[A]);return b}({1:[function(i,l,d){(function(m){"use strict";var b=m.MutationObserver||m.WebKitMutationObserver,_;if(b){var A=0,I=new b(N),x=m.document.createTextNode("");I.observe(x,{characterData:!0}),_=function(){x.data=A=++A%2}}else if(!m.setImmediate&&typeof m.MessageChannel<"u"){var h=new m.MessageChannel;h.port1.onmessage=N,_=function(){h.port2.postMessage(0)}}else"document"in m&&"onreadystatechange"in m.document.createElement("script")?_=function(){var V=m.document.createElement("script");V.onreadystatechange=function(){N(),V.onreadystatechange=null,V.parentNode.removeChild(V),V=null},m.document.documentElement.appendChild(V)}:_=function(){setTimeout(N,0)};var T,C=[];function N(){T=!0;for(var V,ne,J=C.length;J;){for(ne=C,C=[],V=-1;++V<J;)ne[V]();J=C.length}T=!1}l.exports=K;function K(V){C.push(V)===1&&!T&&_()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(i,l,d){"use strict";var m=i(1);function b(){}var _={},A=["REJECTED"],I=["FULFILLED"],x=["PENDING"];l.exports=h;function h(E){if(typeof E!="function")throw new TypeError("resolver must be a function");this.state=x,this.queue=[],this.outcome=void 0,E!==b&&K(this,E)}h.prototype.catch=function(E){return this.then(null,E)},h.prototype.then=function(E,D){if(typeof E!="function"&&this.state===I||typeof D!="function"&&this.state===A)return this;var P=new this.constructor(b);if(this.state!==x){var U=this.state===I?E:D;C(P,U,this.outcome)}else this.queue.push(new T(P,E,D));return P};function T(E,D,P){this.promise=E,typeof D=="function"&&(this.onFulfilled=D,this.callFulfilled=this.otherCallFulfilled),typeof P=="function"&&(this.onRejected=P,this.callRejected=this.otherCallRejected)}T.prototype.callFulfilled=function(E){_.resolve(this.promise,E)},T.prototype.otherCallFulfilled=function(E){C(this.promise,this.onFulfilled,E)},T.prototype.callRejected=function(E){_.reject(this.promise,E)},T.prototype.otherCallRejected=function(E){C(this.promise,this.onRejected,E)};function C(E,D,P){m(function(){var U;try{U=D(P)}catch(H){return _.reject(E,H)}U===E?_.reject(E,new TypeError("Cannot resolve promise with itself")):_.resolve(E,U)})}_.resolve=function(E,D){var P=V(N,D);if(P.status==="error")return _.reject(E,P.value);var U=P.value;if(U)K(E,U);else{E.state=I,E.outcome=D;for(var H=-1,z=E.queue.length;++H<z;)E.queue[H].callFulfilled(D)}return E},_.reject=function(E,D){E.state=A,E.outcome=D;for(var P=-1,U=E.queue.length;++P<U;)E.queue[P].callRejected(D);return E};function N(E){var D=E&&E.then;if(E&&(typeof E=="object"||typeof E=="function")&&typeof D=="function")return function(){D.apply(E,arguments)}}function K(E,D){var P=!1;function U(q){P||(P=!0,_.reject(E,q))}function H(q){P||(P=!0,_.resolve(E,q))}function z(){D(H,U)}var Y=V(z);Y.status==="error"&&U(Y.value)}function V(E,D){var P={};try{P.value=E(D),P.status="success"}catch(U){P.status="error",P.value=U}return P}h.resolve=ne;function ne(E){return E instanceof this?E:_.resolve(new this(b),E)}h.reject=J;function J(E){var D=new this(b);return _.reject(D,E)}h.all=gt;function gt(E){var D=this;if(Object.prototype.toString.call(E)!=="[object Array]")return this.reject(new TypeError("must be an array"));var P=E.length,U=!1;if(!P)return this.resolve([]);for(var H=new Array(P),z=0,Y=-1,q=new this(b);++Y<P;)oe(E[Y],Y);return q;function oe(_e,Pe){D.resolve(_e).then(vt,function(me){U||(U=!0,_.reject(q,me))});function vt(me){H[Pe]=me,++z===P&&!U&&(U=!0,_.resolve(q,H))}}}h.race=ue;function ue(E){var D=this;if(Object.prototype.toString.call(E)!=="[object Array]")return this.reject(new TypeError("must be an array"));var P=E.length,U=!1;if(!P)return this.resolve([]);for(var H=-1,z=new this(b);++H<P;)Y(E[H]);return z;function Y(q){D.resolve(q).then(function(oe){U||(U=!0,_.resolve(z,oe))},function(oe){U||(U=!0,_.reject(z,oe))})}}},{1:1}],3:[function(i,l,d){(function(m){"use strict";typeof m.Promise!="function"&&(m.Promise=i(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(i,l,d){"use strict";var m=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r};function b(r,s){if(!(r instanceof s))throw new TypeError("Cannot call a class as a function")}function _(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var A=_();function I(){try{if(!A||!A.open)return!1;var r=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),s=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!r||s)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function x(r,s){r=r||[],s=s||{};try{return new Blob(r,s)}catch(a){if(a.name!=="TypeError")throw a;for(var o=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,c=new o,u=0;u<r.length;u+=1)c.append(r[u]);return c.getBlob(s.type)}}typeof Promise>"u"&&i(3);var h=Promise;function T(r,s){s&&r.then(function(o){s(null,o)},function(o){s(o)})}function C(r,s,o){typeof s=="function"&&r.then(s),typeof o=="function"&&r.catch(o)}function N(r){return typeof r!="string"&&(console.warn(r+" used as a key, but it is not a string."),r=String(r)),r}function K(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var V="local-forage-detect-blob-support",ne=void 0,J={},gt=Object.prototype.toString,ue="readonly",E="readwrite";function D(r){for(var s=r.length,o=new ArrayBuffer(s),c=new Uint8Array(o),u=0;u<s;u++)c[u]=r.charCodeAt(u);return o}function P(r){return new h(function(s){var o=r.transaction(V,E),c=x([""]);o.objectStore(V).put(c,"key"),o.onabort=function(u){u.preventDefault(),u.stopPropagation(),s(!1)},o.oncomplete=function(){var u=navigator.userAgent.match(/Chrome\/(\d+)/),a=navigator.userAgent.match(/Edge\//);s(a||!u||parseInt(u[1],10)>=43)}}).catch(function(){return!1})}function U(r){return typeof ne=="boolean"?h.resolve(ne):P(r).then(function(s){return ne=s,ne})}function H(r){var s=J[r.name],o={};o.promise=new h(function(c,u){o.resolve=c,o.reject=u}),s.deferredOperations.push(o),s.dbReady?s.dbReady=s.dbReady.then(function(){return o.promise}):s.dbReady=o.promise}function z(r){var s=J[r.name],o=s.deferredOperations.pop();if(o)return o.resolve(),o.promise}function Y(r,s){var o=J[r.name],c=o.deferredOperations.pop();if(c)return c.reject(s),c.promise}function q(r,s){return new h(function(o,c){if(J[r.name]=J[r.name]||nr(),r.db)if(s)H(r),r.db.close();else return o(r.db);var u=[r.name];s&&u.push(r.version);var a=A.open.apply(A,u);s&&(a.onupgradeneeded=function(f){var p=a.result;try{p.createObjectStore(r.storeName),f.oldVersion<=1&&p.createObjectStore(V)}catch(g){if(g.name==="ConstraintError")console.warn('The database "'+r.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+r.storeName+'" already exists.');else throw g}}),a.onerror=function(f){f.preventDefault(),c(a.error)},a.onsuccess=function(){var f=a.result;f.onversionchange=function(p){p.target.close()},o(f),z(r)}})}function oe(r){return q(r,!1)}function _e(r){return q(r,!0)}function Pe(r,s){if(!r.db)return!0;var o=!r.db.objectStoreNames.contains(r.storeName),c=r.version<r.db.version,u=r.version>r.db.version;if(c&&(r.version!==s&&console.warn('The database "'+r.name+`" can't be downgraded from version `+r.db.version+" to version "+r.version+"."),r.version=r.db.version),u||o){if(o){var a=r.db.version+1;a>r.version&&(r.version=a)}return!0}return!1}function vt(r){return new h(function(s,o){var c=new FileReader;c.onerror=o,c.onloadend=function(u){var a=btoa(u.target.result||"");s({__local_forage_encoded_blob:!0,data:a,type:r.type})},c.readAsBinaryString(r)})}function me(r){var s=D(atob(r.data));return x([s],{type:r.type})}function rr(r){return r&&r.__local_forage_encoded_blob}function on(r){var s=this,o=s._initReady().then(function(){var c=J[s._dbInfo.name];if(c&&c.dbReady)return c.dbReady});return C(o,r,r),o}function sn(r){H(r);for(var s=J[r.name],o=s.forages,c=0;c<o.length;c++){var u=o[c];u._dbInfo.db&&(u._dbInfo.db.close(),u._dbInfo.db=null)}return r.db=null,oe(r).then(function(a){return r.db=a,Pe(r)?_e(r):a}).then(function(a){r.db=s.db=a;for(var f=0;f<o.length;f++)o[f]._dbInfo.db=a}).catch(function(a){throw Y(r,a),a})}function ie(r,s,o,c){c===void 0&&(c=1);try{var u=r.db.transaction(r.storeName,s);o(null,u)}catch(a){if(c>0&&(!r.db||a.name==="InvalidStateError"||a.name==="NotFoundError"))return h.resolve().then(function(){if(!r.db||a.name==="NotFoundError"&&!r.db.objectStoreNames.contains(r.storeName)&&r.version<=r.db.version)return r.db&&(r.version=r.db.version+1),_e(r)}).then(function(){return sn(r).then(function(){ie(r,s,o,c-1)})}).catch(o);o(a)}}function nr(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function an(r){var s=this,o={db:null};if(r)for(var c in r)o[c]=r[c];var u=J[o.name];u||(u=nr(),J[o.name]=u),u.forages.push(s),s._initReady||(s._initReady=s.ready,s.ready=on);var a=[];function f(){return h.resolve()}for(var p=0;p<u.forages.length;p++){var g=u.forages[p];g!==s&&a.push(g._initReady().catch(f))}var v=u.forages.slice(0);return h.all(a).then(function(){return o.db=u.db,oe(o)}).then(function(y){return o.db=y,Pe(o,s._defaultConfig.version)?_e(o):y}).then(function(y){o.db=u.db=y,s._dbInfo=o;for(var w=0;w<v.length;w++){var k=v[w];k!==s&&(k._dbInfo.db=o.db,k._dbInfo.version=o.version)}})}function cn(r,s){var o=this;r=N(r);var c=new h(function(u,a){o.ready().then(function(){ie(o._dbInfo,ue,function(f,p){if(f)return a(f);try{var g=p.objectStore(o._dbInfo.storeName),v=g.get(r);v.onsuccess=function(){var y=v.result;y===void 0&&(y=null),rr(y)&&(y=me(y)),u(y)},v.onerror=function(){a(v.error)}}catch(y){a(y)}})}).catch(a)});return T(c,s),c}function ln(r,s){var o=this,c=new h(function(u,a){o.ready().then(function(){ie(o._dbInfo,ue,function(f,p){if(f)return a(f);try{var g=p.objectStore(o._dbInfo.storeName),v=g.openCursor(),y=1;v.onsuccess=function(){var w=v.result;if(w){var k=w.value;rr(k)&&(k=me(k));var O=r(k,w.key,y++);O!==void 0?u(O):w.continue()}else u()},v.onerror=function(){a(v.error)}}catch(w){a(w)}})}).catch(a)});return T(c,s),c}function un(r,s,o){var c=this;r=N(r);var u=new h(function(a,f){var p;c.ready().then(function(){return p=c._dbInfo,gt.call(s)==="[object Blob]"?U(p.db).then(function(g){return g?s:vt(s)}):s}).then(function(g){ie(c._dbInfo,E,function(v,y){if(v)return f(v);try{var w=y.objectStore(c._dbInfo.storeName);g===null&&(g=void 0);var k=w.put(g,r);y.oncomplete=function(){g===void 0&&(g=null),a(g)},y.onabort=y.onerror=function(){var O=k.error?k.error:k.transaction.error;f(O)}}catch(O){f(O)}})}).catch(f)});return T(u,o),u}function dn(r,s){var o=this;r=N(r);var c=new h(function(u,a){o.ready().then(function(){ie(o._dbInfo,E,function(f,p){if(f)return a(f);try{var g=p.objectStore(o._dbInfo.storeName),v=g.delete(r);p.oncomplete=function(){u()},p.onerror=function(){a(v.error)},p.onabort=function(){var y=v.error?v.error:v.transaction.error;a(y)}}catch(y){a(y)}})}).catch(a)});return T(c,s),c}function fn(r){var s=this,o=new h(function(c,u){s.ready().then(function(){ie(s._dbInfo,E,function(a,f){if(a)return u(a);try{var p=f.objectStore(s._dbInfo.storeName),g=p.clear();f.oncomplete=function(){c()},f.onabort=f.onerror=function(){var v=g.error?g.error:g.transaction.error;u(v)}}catch(v){u(v)}})}).catch(u)});return T(o,r),o}function mn(r){var s=this,o=new h(function(c,u){s.ready().then(function(){ie(s._dbInfo,ue,function(a,f){if(a)return u(a);try{var p=f.objectStore(s._dbInfo.storeName),g=p.count();g.onsuccess=function(){c(g.result)},g.onerror=function(){u(g.error)}}catch(v){u(v)}})}).catch(u)});return T(o,r),o}function hn(r,s){var o=this,c=new h(function(u,a){if(r<0){u(null);return}o.ready().then(function(){ie(o._dbInfo,ue,function(f,p){if(f)return a(f);try{var g=p.objectStore(o._dbInfo.storeName),v=!1,y=g.openKeyCursor();y.onsuccess=function(){var w=y.result;if(!w){u(null);return}r===0||v?u(w.key):(v=!0,w.advance(r))},y.onerror=function(){a(y.error)}}catch(w){a(w)}})}).catch(a)});return T(c,s),c}function pn(r){var s=this,o=new h(function(c,u){s.ready().then(function(){ie(s._dbInfo,ue,function(a,f){if(a)return u(a);try{var p=f.objectStore(s._dbInfo.storeName),g=p.openKeyCursor(),v=[];g.onsuccess=function(){var y=g.result;if(!y){c(v);return}v.push(y.key),y.continue()},g.onerror=function(){u(g.error)}}catch(y){u(y)}})}).catch(u)});return T(o,r),o}function gn(r,s){s=K.apply(this,arguments);var o=this.config();r=typeof r!="function"&&r||{},r.name||(r.name=r.name||o.name,r.storeName=r.storeName||o.storeName);var c=this,u;if(!r.name)u=h.reject("Invalid arguments");else{var a=r.name===o.name&&c._dbInfo.db,f=a?h.resolve(c._dbInfo.db):oe(r).then(function(p){var g=J[r.name],v=g.forages;g.db=p;for(var y=0;y<v.length;y++)v[y]._dbInfo.db=p;return p});r.storeName?u=f.then(function(p){if(p.objectStoreNames.contains(r.storeName)){var g=p.version+1;H(r);var v=J[r.name],y=v.forages;p.close();for(var w=0;w<y.length;w++){var k=y[w];k._dbInfo.db=null,k._dbInfo.version=g}var O=new h(function(F,$){var B=A.open(r.name,g);B.onerror=function(Q){var Te=B.result;Te.close(),$(Q)},B.onupgradeneeded=function(){var Q=B.result;Q.deleteObjectStore(r.storeName)},B.onsuccess=function(){var Q=B.result;Q.close(),F(Q)}});return O.then(function(F){v.db=F;for(var $=0;$<y.length;$++){var B=y[$];B._dbInfo.db=F,z(B._dbInfo)}}).catch(function(F){throw(Y(r,F)||h.resolve()).catch(function(){}),F})}}):u=f.then(function(p){H(r);var g=J[r.name],v=g.forages;p.close();for(var y=0;y<v.length;y++){var w=v[y];w._dbInfo.db=null}var k=new h(function(O,F){var $=A.deleteDatabase(r.name);$.onerror=function(){var B=$.result;B&&B.close(),F($.error)},$.onblocked=function(){console.warn('dropInstance blocked for database "'+r.name+'" until all open connections are closed')},$.onsuccess=function(){var B=$.result;B&&B.close(),O(B)}});return k.then(function(O){g.db=O;for(var F=0;F<v.length;F++){var $=v[F];z($._dbInfo)}}).catch(function(O){throw(Y(r,O)||h.resolve()).catch(function(){}),O})})}return T(u,s),u}var vn={_driver:"asyncStorage",_initStorage:an,_support:I(),iterate:ln,getItem:cn,setItem:un,removeItem:dn,clear:fn,length:mn,key:hn,keys:pn,dropInstance:gn};function yn(){return typeof openDatabase=="function"}var ae="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bn="~~local_forage_type~",or=/^~~local_forage_type~([^~]+)~/,Ce="__lfsc__:",yt=Ce.length,bt="arbf",_t="blob",ir="si08",sr="ui08",ar="uic8",cr="si16",lr="si32",ur="ur16",dr="ui32",fr="fl32",mr="fl64",hr=yt+bt.length,pr=Object.prototype.toString;function gr(r){var s=r.length*.75,o=r.length,c,u=0,a,f,p,g;r[r.length-1]==="="&&(s--,r[r.length-2]==="="&&s--);var v=new ArrayBuffer(s),y=new Uint8Array(v);for(c=0;c<o;c+=4)a=ae.indexOf(r[c]),f=ae.indexOf(r[c+1]),p=ae.indexOf(r[c+2]),g=ae.indexOf(r[c+3]),y[u++]=a<<2|f>>4,y[u++]=(f&15)<<4|p>>2,y[u++]=(p&3)<<6|g&63;return v}function Et(r){var s=new Uint8Array(r),o="",c;for(c=0;c<s.length;c+=3)o+=ae[s[c]>>2],o+=ae[(s[c]&3)<<4|s[c+1]>>4],o+=ae[(s[c+1]&15)<<2|s[c+2]>>6],o+=ae[s[c+2]&63];return s.length%3===2?o=o.substring(0,o.length-1)+"=":s.length%3===1&&(o=o.substring(0,o.length-2)+"=="),o}function _n(r,s){var o="";if(r&&(o=pr.call(r)),r&&(o==="[object ArrayBuffer]"||r.buffer&&pr.call(r.buffer)==="[object ArrayBuffer]")){var c,u=Ce;r instanceof ArrayBuffer?(c=r,u+=bt):(c=r.buffer,o==="[object Int8Array]"?u+=ir:o==="[object Uint8Array]"?u+=sr:o==="[object Uint8ClampedArray]"?u+=ar:o==="[object Int16Array]"?u+=cr:o==="[object Uint16Array]"?u+=ur:o==="[object Int32Array]"?u+=lr:o==="[object Uint32Array]"?u+=dr:o==="[object Float32Array]"?u+=fr:o==="[object Float64Array]"?u+=mr:s(new Error("Failed to get type for BinaryArray"))),s(u+Et(c))}else if(o==="[object Blob]"){var a=new FileReader;a.onload=function(){var f=bn+r.type+"~"+Et(this.result);s(Ce+_t+f)},a.readAsArrayBuffer(r)}else try{s(JSON.stringify(r))}catch(f){console.error("Couldn't convert value into a JSON string: ",r),s(null,f)}}function En(r){if(r.substring(0,yt)!==Ce)return JSON.parse(r);var s=r.substring(hr),o=r.substring(yt,hr),c;if(o===_t&&or.test(s)){var u=s.match(or);c=u[1],s=s.substring(u[0].length)}var a=gr(s);switch(o){case bt:return a;case _t:return x([a],{type:c});case ir:return new Int8Array(a);case sr:return new Uint8Array(a);case ar:return new Uint8ClampedArray(a);case cr:return new Int16Array(a);case ur:return new Uint16Array(a);case lr:return new Int32Array(a);case dr:return new Uint32Array(a);case fr:return new Float32Array(a);case mr:return new Float64Array(a);default:throw new Error("Unkown type: "+o)}}var Tt={serialize:_n,deserialize:En,stringToBuffer:gr,bufferToString:Et};function vr(r,s,o,c){r.executeSql("CREATE TABLE IF NOT EXISTS "+s.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],o,c)}function Tn(r){var s=this,o={db:null};if(r)for(var c in r)o[c]=typeof r[c]!="string"?r[c].toString():r[c];var u=new h(function(a,f){try{o.db=openDatabase(o.name,String(o.version),o.description,o.size)}catch(p){return f(p)}o.db.transaction(function(p){vr(p,o,function(){s._dbInfo=o,a()},function(g,v){f(v)})},f)});return o.serializer=Tt,u}function ce(r,s,o,c,u,a){r.executeSql(o,c,u,function(f,p){p.code===p.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[s.storeName],function(g,v){v.rows.length?a(g,p):vr(g,s,function(){g.executeSql(o,c,u,a)},a)},a):a(f,p)},a)}function In(r,s){var o=this;r=N(r);var c=new h(function(u,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(p){ce(p,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[r],function(g,v){var y=v.rows.length?v.rows.item(0).value:null;y&&(y=f.serializer.deserialize(y)),u(y)},function(g,v){a(v)})})}).catch(a)});return T(c,s),c}function wn(r,s){var o=this,c=new h(function(u,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(p){ce(p,f,"SELECT * FROM "+f.storeName,[],function(g,v){for(var y=v.rows,w=y.length,k=0;k<w;k++){var O=y.item(k),F=O.value;if(F&&(F=f.serializer.deserialize(F)),F=r(F,O.key,k+1),F!==void 0){u(F);return}}u()},function(g,v){a(v)})})}).catch(a)});return T(c,s),c}function yr(r,s,o,c){var u=this;r=N(r);var a=new h(function(f,p){u.ready().then(function(){s===void 0&&(s=null);var g=s,v=u._dbInfo;v.serializer.serialize(s,function(y,w){w?p(w):v.db.transaction(function(k){ce(k,v,"INSERT OR REPLACE INTO "+v.storeName+" (key, value) VALUES (?, ?)",[r,y],function(){f(g)},function(O,F){p(F)})},function(k){if(k.code===k.QUOTA_ERR){if(c>0){f(yr.apply(u,[r,g,o,c-1]));return}p(k)}})})}).catch(p)});return T(a,o),a}function Sn(r,s,o){return yr.apply(this,[r,s,o,1])}function An(r,s){var o=this;r=N(r);var c=new h(function(u,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(p){ce(p,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[r],function(){u()},function(g,v){a(v)})})}).catch(a)});return T(c,s),c}function Rn(r){var s=this,o=new h(function(c,u){s.ready().then(function(){var a=s._dbInfo;a.db.transaction(function(f){ce(f,a,"DELETE FROM "+a.storeName,[],function(){c()},function(p,g){u(g)})})}).catch(u)});return T(o,r),o}function xn(r){var s=this,o=new h(function(c,u){s.ready().then(function(){var a=s._dbInfo;a.db.transaction(function(f){ce(f,a,"SELECT COUNT(key) as c FROM "+a.storeName,[],function(p,g){var v=g.rows.item(0).c;c(v)},function(p,g){u(g)})})}).catch(u)});return T(o,r),o}function kn(r,s){var o=this,c=new h(function(u,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(p){ce(p,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[r+1],function(g,v){var y=v.rows.length?v.rows.item(0).key:null;u(y)},function(g,v){a(v)})})}).catch(a)});return T(c,s),c}function Pn(r){var s=this,o=new h(function(c,u){s.ready().then(function(){var a=s._dbInfo;a.db.transaction(function(f){ce(f,a,"SELECT key FROM "+a.storeName,[],function(p,g){for(var v=[],y=0;y<g.rows.length;y++)v.push(g.rows.item(y).key);c(v)},function(p,g){u(g)})})}).catch(u)});return T(o,r),o}function Cn(r){return new h(function(s,o){r.transaction(function(c){c.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(u,a){for(var f=[],p=0;p<a.rows.length;p++)f.push(a.rows.item(p).name);s({db:r,storeNames:f})},function(u,a){o(a)})},function(c){o(c)})})}function Dn(r,s){s=K.apply(this,arguments);var o=this.config();r=typeof r!="function"&&r||{},r.name||(r.name=r.name||o.name,r.storeName=r.storeName||o.storeName);var c=this,u;return r.name?u=new h(function(a){var f;r.name===o.name?f=c._dbInfo.db:f=openDatabase(r.name,"","",0),r.storeName?a({db:f,storeNames:[r.storeName]}):a(Cn(f))}).then(function(a){return new h(function(f,p){a.db.transaction(function(g){function v(O){return new h(function(F,$){g.executeSql("DROP TABLE IF EXISTS "+O,[],function(){F()},function(B,Q){$(Q)})})}for(var y=[],w=0,k=a.storeNames.length;w<k;w++)y.push(v(a.storeNames[w]));h.all(y).then(function(){f()}).catch(function(O){p(O)})},function(g){p(g)})})}):u=h.reject("Invalid arguments"),T(u,s),u}var On={_driver:"webSQLStorage",_initStorage:Tn,_support:yn(),iterate:wn,getItem:In,setItem:Sn,removeItem:An,clear:Rn,length:xn,key:kn,keys:Pn,dropInstance:Dn};function Fn(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function br(r,s){var o=r.name+"/";return r.storeName!==s.storeName&&(o+=r.storeName+"/"),o}function Nn(){var r="_localforage_support_test";try{return localStorage.setItem(r,!0),localStorage.removeItem(r),!1}catch{return!0}}function Un(){return!Nn()||localStorage.length>0}function Ln(r){var s=this,o={};if(r)for(var c in r)o[c]=r[c];return o.keyPrefix=br(r,s._defaultConfig),Un()?(s._dbInfo=o,o.serializer=Tt,h.resolve()):h.reject()}function Bn(r){var s=this,o=s.ready().then(function(){for(var c=s._dbInfo.keyPrefix,u=localStorage.length-1;u>=0;u--){var a=localStorage.key(u);a.indexOf(c)===0&&localStorage.removeItem(a)}});return T(o,r),o}function $n(r,s){var o=this;r=N(r);var c=o.ready().then(function(){var u=o._dbInfo,a=localStorage.getItem(u.keyPrefix+r);return a&&(a=u.serializer.deserialize(a)),a});return T(c,s),c}function Mn(r,s){var o=this,c=o.ready().then(function(){for(var u=o._dbInfo,a=u.keyPrefix,f=a.length,p=localStorage.length,g=1,v=0;v<p;v++){var y=localStorage.key(v);if(y.indexOf(a)===0){var w=localStorage.getItem(y);if(w&&(w=u.serializer.deserialize(w)),w=r(w,y.substring(f),g++),w!==void 0)return w}}});return T(c,s),c}function Vn(r,s){var o=this,c=o.ready().then(function(){var u=o._dbInfo,a;try{a=localStorage.key(r)}catch{a=null}return a&&(a=a.substring(u.keyPrefix.length)),a});return T(c,s),c}function jn(r){var s=this,o=s.ready().then(function(){for(var c=s._dbInfo,u=localStorage.length,a=[],f=0;f<u;f++){var p=localStorage.key(f);p.indexOf(c.keyPrefix)===0&&a.push(p.substring(c.keyPrefix.length))}return a});return T(o,r),o}function Kn(r){var s=this,o=s.keys().then(function(c){return c.length});return T(o,r),o}function Jn(r,s){var o=this;r=N(r);var c=o.ready().then(function(){var u=o._dbInfo;localStorage.removeItem(u.keyPrefix+r)});return T(c,s),c}function Gn(r,s,o){var c=this;r=N(r);var u=c.ready().then(function(){s===void 0&&(s=null);var a=s;return new h(function(f,p){var g=c._dbInfo;g.serializer.serialize(s,function(v,y){if(y)p(y);else try{localStorage.setItem(g.keyPrefix+r,v),f(a)}catch(w){(w.name==="QuotaExceededError"||w.name==="NS_ERROR_DOM_QUOTA_REACHED")&&p(w),p(w)}})})});return T(u,o),u}function Hn(r,s){if(s=K.apply(this,arguments),r=typeof r!="function"&&r||{},!r.name){var o=this.config();r.name=r.name||o.name,r.storeName=r.storeName||o.storeName}var c=this,u;return r.name?u=new h(function(a){r.storeName?a(br(r,c._defaultConfig)):a(r.name+"/")}).then(function(a){for(var f=localStorage.length-1;f>=0;f--){var p=localStorage.key(f);p.indexOf(a)===0&&localStorage.removeItem(p)}}):u=h.reject("Invalid arguments"),T(u,s),u}var Wn={_driver:"localStorageWrapper",_initStorage:Ln,_support:Fn(),iterate:Mn,getItem:$n,setItem:Gn,removeItem:Jn,clear:Bn,length:Kn,key:Vn,keys:jn,dropInstance:Hn},zn=function(s,o){return s===o||typeof s=="number"&&typeof o=="number"&&isNaN(s)&&isNaN(o)},Yn=function(s,o){for(var c=s.length,u=0;u<c;){if(zn(s[u],o))return!0;u++}return!1},_r=Array.isArray||function(r){return Object.prototype.toString.call(r)==="[object Array]"},Ee={},Er={},he={INDEXEDDB:vn,WEBSQL:On,LOCALSTORAGE:Wn},qn=[he.INDEXEDDB._driver,he.WEBSQL._driver,he.LOCALSTORAGE._driver],De=["dropInstance"],It=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(De),Qn={description:"",driver:qn.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Xn(r,s){r[s]=function(){var o=arguments;return r.ready().then(function(){return r[s].apply(r,o)})}}function wt(){for(var r=1;r<arguments.length;r++){var s=arguments[r];if(s)for(var o in s)s.hasOwnProperty(o)&&(_r(s[o])?arguments[0][o]=s[o].slice():arguments[0][o]=s[o])}return arguments[0]}var Zn=function(){function r(s){b(this,r);for(var o in he)if(he.hasOwnProperty(o)){var c=he[o],u=c._driver;this[o]=u,Ee[u]||this.defineDriver(c)}this._defaultConfig=wt({},Qn),this._config=wt({},this._defaultConfig,s),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return r.prototype.config=function(o){if((typeof o>"u"?"undefined":m(o))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var c in o){if(c==="storeName"&&(o[c]=o[c].replace(/\W/g,"_")),c==="version"&&typeof o[c]!="number")return new Error("Database version must be a number.");this._config[c]=o[c]}return"driver"in o&&o.driver?this.setDriver(this._config.driver):!0}else return typeof o=="string"?this._config[o]:this._config},r.prototype.defineDriver=function(o,c,u){var a=new h(function(f,p){try{var g=o._driver,v=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!o._driver){p(v);return}for(var y=It.concat("_initStorage"),w=0,k=y.length;w<k;w++){var O=y[w],F=!Yn(De,O);if((F||o[O])&&typeof o[O]!="function"){p(v);return}}var $=function(){for(var Te=function(ro){return function(){var no=new Error("Method "+ro+" is not implemented by the current driver"),Tr=h.reject(no);return T(Tr,arguments[arguments.length-1]),Tr}},St=0,to=De.length;St<to;St++){var At=De[St];o[At]||(o[At]=Te(At))}};$();var B=function(Te){Ee[g]&&console.info("Redefining LocalForage driver: "+g),Ee[g]=o,Er[g]=Te,f()};"_support"in o?o._support&&typeof o._support=="function"?o._support().then(B,p):B(!!o._support):B(!0)}catch(Q){p(Q)}});return C(a,c,u),a},r.prototype.driver=function(){return this._driver||null},r.prototype.getDriver=function(o,c,u){var a=Ee[o]?h.resolve(Ee[o]):h.reject(new Error("Driver not found."));return C(a,c,u),a},r.prototype.getSerializer=function(o){var c=h.resolve(Tt);return C(c,o),c},r.prototype.ready=function(o){var c=this,u=c._driverSet.then(function(){return c._ready===null&&(c._ready=c._initDriver()),c._ready});return C(u,o,o),u},r.prototype.setDriver=function(o,c,u){var a=this;_r(o)||(o=[o]);var f=this._getSupportedDrivers(o);function p(){a._config.driver=a.driver()}function g(w){return a._extend(w),p(),a._ready=a._initStorage(a._config),a._ready}function v(w){return function(){var k=0;function O(){for(;k<w.length;){var F=w[k];return k++,a._dbInfo=null,a._ready=null,a.getDriver(F).then(g).catch(O)}p();var $=new Error("No available storage method found.");return a._driverSet=h.reject($),a._driverSet}return O()}}var y=this._driverSet!==null?this._driverSet.catch(function(){return h.resolve()}):h.resolve();return this._driverSet=y.then(function(){var w=f[0];return a._dbInfo=null,a._ready=null,a.getDriver(w).then(function(k){a._driver=k._driver,p(),a._wrapLibraryMethodsWithReady(),a._initDriver=v(f)})}).catch(function(){p();var w=new Error("No available storage method found.");return a._driverSet=h.reject(w),a._driverSet}),C(this._driverSet,c,u),this._driverSet},r.prototype.supports=function(o){return!!Er[o]},r.prototype._extend=function(o){wt(this,o)},r.prototype._getSupportedDrivers=function(o){for(var c=[],u=0,a=o.length;u<a;u++){var f=o[u];this.supports(f)&&c.push(f)}return c},r.prototype._wrapLibraryMethodsWithReady=function(){for(var o=0,c=It.length;o<c;o++)Xn(this,It[o])},r.prototype.createInstance=function(o){return new r(o)},r}(),eo=new Zn;l.exports=eo},{3:3}]},{},[4])(4)})});var Ar=Object.defineProperty,mo=Object.getOwnPropertyDescriptor,ho=(e,t)=>{for(var n in t)Ar(e,n,{get:t[n],enumerable:!0})},Rr=(e,t,n,i)=>{for(var l=i>1?void 0:i?mo(t,n):t,d=e.length-1,m;d>=0;d--)(m=e[d])&&(l=(i?m(t,n,l):m(l))||l);return i&&l&&Ar(t,n,l),l};function po(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Ct(e){return typeof e=="string"}function xr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function kr(e){return typeof e=="object"&&Array.isArray(e)}function go(e){return typeof e>"u"}function vo(e){return go(e)||e===null}function yo(e){return typeof e=="function"}function Pr(e){let t=e,n=null,i=function(...l){return n||(n=new t(...l)),n};return i.prototype=t.prototype,i}function Cr(e,t,n){if(typeof n!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function i(l,d){for(let m in d)if(Object.prototype.hasOwnProperty.call(d,m)){let b=l[m],_=d[m],A=n(b,_,m,l,d);A!==void 0?l[m]=A:wr(_)&&wr(b)?l[m]=i({...b},_):Array.isArray(_)&&Array.isArray(b)?l[m]=[...b,..._]:l[m]=_}return l}return i(e,t)}function wr(e){return e&&typeof e=="object"&&e.constructor===Object}function Dr(e,t){if(Array.isArray(e))return e.concat(t)}function Ae(e,t,n={}){let i=null,l,d,m,{leading:b=!1,trailing:_=!0}=n,A=()=>(m=e.apply(d,l),l=void 0,d=void 0,m),I=function(...x){l=x,d=this;let h=b&&!i;if(i&&clearTimeout(i),i=setTimeout(()=>{i=null,_&&!h&&A()},t),h)return A()};return I.cancel=()=>{i&&clearTimeout(i),i=null,l=d=void 0},I.flush=()=>{if(i)return clearTimeout(i),i=null,A()},I}var 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||{}),Dt=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}},Ot=class extends Dt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},_o=class extends Dt{constructor(){super(...arguments),this.kind="USER_ERROR"}};var Ft=class extends _o{constructor(e,t,n){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,n&&(this.extra=Object.assign({},this.extra,n))}};var Or=class extends Ot{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}};var Fr=class extends Ot{constructor(e,t){super(e),this.message=e,this.name="INTERNAL_CONTEXT_ERROR",this.property=t}},Be=class extends Dt{constructor(e,t,n,i,l){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",n&&(this.errorType=n),i!==void 0&&(this.stack=i),l&&(this.priority=l)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};var Nt=class extends Ot{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};function Eo(e,t){return(...n)=>t(e,...n)}function Nr(e){return t=>Eo(t,function(n,...i){if(typeof n=="function")try{return n.apply(this,i)}catch(l){e(new Ft(`${l}`))}})}function we(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}var W={log:we("log"),warn:we("warn"),info:we("info"),error:we("error"),debug:we("debug")};Object.assign(globalThis,{logger:W});var Ur=Symbol.for("Jolibox.canIUseMap"),To={};globalThis[Ur]=To;var Ut={get config(){return globalThis[Ur]}};var Re=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Re||{}),pe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(pe||{}),Io=(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))(Io||{}),Sr=["name","params"],wo=["name","type","location","target","extra","timestamp","userId"],So=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function Ne(e,t){return t.map(n=>{if(n==="params"&&e[n]){let i=e[n];return Object.keys(i).reduce((l,d)=>(l[d]=String(i[d]),l),{})}return e[n]})}function Ao(e){let t=e.location?Ne(e.location,Sr):null,n=e.target?Ne(e.target,Sr):null;return Ne({...e,location:t,target:n},wo)}function Lt(e){let t=e.events.map(i=>Ao(i)),n=Ne(e.device,So);return[e.protocolVersion,t,n,e.project]}var Ro=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});var 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")},xo=()=>Oe.isiOS?"iOS":Oe.isAndroid?"Android":Oe.isMac?"Mac":Oe.isFacebook?"Facebook":"PC",ko="device_id",Po="advertising_id",Lr=e=>(localStorage.getItem(e)||localStorage.setItem(e,Ro()),localStorage.getItem(e)),Bt=()=>Lr(ko),Co=()=>Lr(Po),Do=e=>e.charAt(0).toUpperCase()+e.slice(1),Oo=()=>{let e=new URLSearchParams(window.location.search);return Do(e.get("utm_source")??"")||"JoliboxSDK"},Br=e=>{let t="JoliboxWebSDK",n=xo(),i=navigator.language,l=Bt(),d=Co();return`${t} (${Oo()}${n}; UnknownModel; UnknownSystemVersion; ${i}) uuid/${l} adid/${d} version/${e||""}`},L=class Ue{static{this.Undefined=new Ue(void 0)}constructor(t){this.element=t,this.next=Ue.Undefined,this.prev=Ue.Undefined}},Fo=class{constructor(){this._first=L.Undefined,this._last=L.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===L.Undefined}clear(){let e=this._first;for(;e!==L.Undefined;){let t=e.next;e.prev=L.Undefined,e.next=L.Undefined,e=t}this._first=L.Undefined,this._last=L.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new L(e);if(this._first===L.Undefined)this._first=n,this._last=n;else if(t){let l=this._last;this._last=n,n.prev=l,l.next=n}else{let l=this._first;this._first=n,n.next=l,l.prev=n}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(n))}}shift(){if(this._first!==L.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==L.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==L.Undefined&&e.next!==L.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===L.Undefined&&e.next===L.Undefined?(this._first=L.Undefined,this._last=L.Undefined):e.next===L.Undefined?(this._last=this._last.prev,this._last.next=L.Undefined):e.prev===L.Undefined&&(this._first=this._first.next,this._first.prev=L.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==L.Undefined;)yield e.element,e=e.next}},No=0,Fe=class{constructor(e){this.value=e,this.id=No++}},Se=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof Fe&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(t=>t?.value===e)):(this._listeners=void 0,this._size=0)),this.options?.onDidRemoveLastListener?.())}get event(){return this._event??=(e,t)=>{if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};t&&(e=e.bind(t));let n=new Fe(e);this._listeners?this._listeners instanceof Fe?this._listeners=[this._listeners,n]:this._listeners.push(n):(this.options?.onWillAddFirstListener?.(this),this._listeners=n,this.options?.onDidFirstListener?.(this)),this.options?.onDidAddListener?.(this),this._size++},this._event}_deliver(e,t){if(!e)return;let n=this.options?.onListenerError||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof Fe?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ge=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){let n=this.listeners.get(e)??new Se,i=d=>t(...d.args);this.listerHandlerMap.set(t,i),n.event(i),this.listeners.set(e,n);let l=this.cachedEventQueue.get(e);if(l)for(;l.size>0;)n.fire({event:e,...l.shift()})}off(e,t){let n=this.listeners.get(e);if(n){let i=this.listerHandlerMap.get(t);n.dispose(i)}}emit(e,...t){let n=this.listeners.get(e);if(n)n.fire({event:e,args:t});else{let i=this.cachedEventQueue.get(e);i||(i=new Fo,this.cachedEventQueue.set(e,i)),i.push({args:t})}}},kt={};ho(kt,{None:()=>Uo,filter:()=>Bo,once:()=>$r,toPromise:()=>Lo});var Uo=()=>{console.log("[Jolibox SDK] None Event")};function Lo(e){return new Promise(t=>$r(e)(t))}function $r(e){return(t,n=null)=>{let i=!1;return e(l=>{if(!i)return i=!0,t.call(n,l)},null)}}function Bo(e,t){return(n=>{let i,l={onWillAddFirstListener(){i=n(d.fire,d)}},d=new Se(l);return d.event})((n,i=null)=>e(l=>t(l)&&n.call(i,l),null))}var Rt=Symbol.for("Jolibox.hostEmitter"),$o=()=>{let e=new ge;return globalThis[Rt]||(globalThis[Rt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[Rt]},xe=$o();function Mo(e,t){let n=Math.min(e.length,t.length);for(let i=0;i<n;i++)Vo(e[i],t[i])}function Vo(e,t){if(Ct(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(yo(t)){try{if(e instanceof t)return}catch{}if(!vo(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var Le=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Se,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 n=[];for(let l of e.metadata.args)n.push(l.constraint);let i=e.handler;e.handler=function(...l){return Mo(l,n),i(...l)}}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 n=this.getCommand(t);n&&e.set(t,n)}return e}};Le=Rr([Pr],Le);var Pt=class{constructor(){this._onWillExecuteCommand=new Se,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Se,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Le,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=po(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),kt.toPromise(kt.filter(this.registry.onDidRegisterCommand,n=>n===e))])]),this._tryExecuteCommand(e,t))}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let n=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let i=this.invokeFunction(n.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),i}_tryExecuteCommand(e,t){let n=this.registry.getCommand(e);if(!n)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let i=this.invokeFunction(n.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(i)}catch(i){return Promise.reject(i)}}invokeFunction(e,...t){let n=!1;try{return e(...t)}finally{n=!0}}};Pt=Rr([Pr],Pt);var xt=Symbol.for("Jolibox.commands");function X(){if(globalThis[xt])return globalThis[xt];let e=new Le,t=new Pt,n={registerCommand(i,l,d){e.registerCommand({id:i,handler:l,metadata:d})},executeCommand(i,...l){return t.executeCommand(i,...l)},excuteCommandSync(i,...l){return t.executeCommandThowErr(i,...l)}};return globalThis[xt]=n,n}var $t=new ge,de=new ge;function ee(e,t={}){$t.emit("ERROR_REPORT",{error:e,options:t})}ee.debounce=Ae(ee,50,{leading:!0});var Mt=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t.length%4===0?"":"=".repeat(4-t.length%4),i=atob(t+n);try{return JSON.parse(i)}catch{return{}}},Mr=e=>{try{let i=new URL(e).searchParams.get("joliSource")?.split(".");if(i?.length){let[l,d,m]=i;return{headerJson:Mt(l),payloadJson:Mt(d),signature:Mt(m)}}else throw"joli_source is missing"}catch(t){return ee(new Or(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}};var jo="1.1.4-beta.11",$e=()=>jo,Vr=()=>{let e=$e();return`${Br(e)}`};var Ko={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:Bt(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:$e()},schema:"",platform:"h5"},Jo=globalThis.joliboxJSCore?.env,te=Object.assign({},Jo?.()??Ko),Go=()=>{let{payloadJson:e,headerJson:t}=Mr(te.schema),n=`${te.deviceInfo.did}-${new Date().getTime()}`,i=new URLSearchParams(te.schema.length?te.schema:window.location.search),l=i.get("mpId")??i.get("appId")??i.get("gameId")??"",d=e.sessionId??i.get("sessionId")??n,m=!!(e.testAdsMode??i.get("testAdsMode")==="true"),b=e.joliboxEnv??i.get("joliboxEnv")??"production",_=b==="staging";return{get testMode(){return _},get testAdsMode(){return m},get joliboxEnv(){return b},get mpId(){return l??e.id},get mpVersion(){return t.ver??$e()},get platform(){return te.platform},get deviceInfo(){return te.deviceInfo},get sdkInfo(){return te.sdkInfo},get hostInfo(){return te.hostInfo},get hostUserInfo(){return te.hostUserInfo},get sessionId(){return te.clientSessionId??d??n},onEnvConfigChanged:A=>{Cr(te,A,Dr)}}},R=Go();var Vt=!1,Kr=(e,t)=>e==null?!1:t in e,Ho=e=>Kr(e,"kind"),Wo=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")},jr=(e,t={},n)=>{let i=e.priority??"P1",d={...{user_id:R.hostUserInfo?.uid??"",device_id:R.deviceInfo.did??"",timestamp:Date.now(),tag:Wo(e.name)},env:t.environment,isFromUser:n};n?de.emit("GLOBAL_USER_ERROR",e,d):de.emit("GLOBAL_ERROR",e,d)},zo=e=>Kr(e,"kind")&&e.kind==="USER_ERROR";$t.on("ERROR_REPORT",({error:e,options:t})=>{if(Vt)return;Vt=!0;let n=Ho(e)&&e.raw?e.raw:e;try{let i=zo(e);jr(e,t,i)}catch(i){let l=i instanceof Error?i.message:String(i),d=new Nt(`${l}, origin error: ${n.message}`);W.error(d),jr(new Nt(d.message),{environment:t.environment},!1)}finally{Vt=!1}});var jt=e=>new Ft(e);function Jr(e,t){let n=(i,l,d)=>{let m={tag:i,...t,extra:{...l}};i=="globalJsError"?ee(new Fr(JSON.stringify(m),"P0")):e("systemLog",m,d)};return n.debounce=Ae(n,500,{leading:!0}),n}function Gr(e){let t=(n,i,l)=>{let d=(l&&JSON.stringify(l))??0,m={speed_value_type:n,total_duration:i};d&&Object.assign(m,{extra:d}),e("joliboxSpeedAnalysis",m)};return t.debounce=Ae(t,500,{leading:!0}),t}function Hr(e,t){let n=Jr(e,t),i=Gr(n);return{track:n,trackPerformance:i}}var Me=class{constructor(){this.deviceInfo=null;this.pastTrackings=[];this.pushPastTracking=t=>{this.pastTrackings.push(t),this.pastTrackings.length>10&&this.pastTrackings.slice(-10)}}get networkIsOk(){return this.pastTrackings.length<=4||this.pastTrackings.filter(Boolean).length/this.pastTrackings.length>=.6}getDevice(){let{nativeSDKVersion:t,jssdkVersion:n}=R.sdkInfo;return{platform:1e3,os:R.deviceInfo.platform,appVersion:t??n??"1.0.0",appId:R.hostInfo?.aid??"1",model:R.deviceInfo.model??"UnknownModel",brand:R.deviceInfo.brand??"UnknownBrand",uuid:R.deviceInfo.did,jsSdkVersion:n,extra:{}}}getLocation(){let t=new URLSearchParams(window.location.search),n={};return t.forEach((i,l)=>{n[l]=i}),{name:"GamePage",params:n}}async trackEvent(t,n,i){let l=t.location?t.location:await this.getLocation(),d=t.target||null,m=t.extra||null;this.deviceInfo||(this.deviceInfo=await this.getDevice());let b=this.deviceInfo,A={protocolVersion:"1.0.0",events:[{...t,location:l,target:d,extra:m,timestamp:Date.now(),userId:null}],device:b,project:n};try{i?this.doReport(Lt(A),i):this.doReport(Lt(A)),this.pushPastTracking(!0)}catch(I){this.pushPastTracking(!1),W.log("[Jolibox SDK] report API error",I)}}};var Kt=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};AbortSignal.timeout??=Kt;var Ve=class{constructor(t){this.xua=Vr();this.getJoliSource=()=>new URLSearchParams(window.location.search).get("joliSource")??null;let n=R.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com";this.baseUrl=t?.baseUrl??n}async get(t,{query:n,headers:i,timeout:l}){let m=new URLSearchParams(n).toString(),b=`${this.baseUrl}${t}${m?`?${m}`:""}`,_=this.xua,A=this.getJoliSource();return i=Object.assign({},i,_?{"x-user-agent":_}:{},A?{"x-joli-source":A}:{}),await(await fetch(b,{method:"GET",headers:i,credentials:"include",signal:Kt(l??3e4)})).json()}async post(t,{data:n,query:i,headers:l,timeout:d}){let b=new URLSearchParams(i).toString(),_=`${this.baseUrl}${t}${b?`?${b}`:""}`,A=this.xua,I=this.getJoliSource();l=Object.assign({},l,{"Content-Type":"application/json"},A?{"x-user-agent":A}:{},I?{"x-joli-source":I}:{});let x=await fetch(_,{method:"POST",headers:l,body:JSON.stringify(n),signal:Kt(d??3e4),credentials:"include"}),h=x.headers.get("content-type");if(h?.includes("application/octet-stream"))try{return x.blob()}catch{return await x.arrayBuffer()}if(h?.includes("multipart/form-data")||h?.includes("application/x-www-form-urlencoded"))try{return x.formData()}catch{return await x.text()}if(h?.includes("application/json"))try{return await x.json()}catch{return await x.text()}return x}async put(t,{data:n,query:i,headers:l}){try{let m=new URLSearchParams(i).toString(),b=`${this.baseUrl}${t}${m?`?${m}`:""}`,_=this.xua,A=this.getJoliSource();l=Object.assign({},l,{"Content-Type":"application/json"},_?{"x-user-agent":_}:{},A?{"x-joli-source":A}:{});let I=await fetch(b,{method:"PUT",headers:l,credentials:"include",body:JSON.stringify(n??{})});if(!I.ok)throw new Error(`HTTP error! status: ${I.status}`);return await I.json()}catch(d){throw console.error("Error:",d),d}}};window.JoliboxHttpClient=Ve;var le=Ve;var Jt=class extends Me{constructor(){super(...arguments);this.hostToApiMap={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}};this.httpClient=new le({baseUrl:this.apiBaseURL})}get apiBaseURL(){let n=this.hostToApiMap[window.location.host]??this.hostToApiMap.default;return R.testMode??!1?n.test:n.prod}doReport(n){this.httpClient.post("/report",{data:n,timeout:5e3}),W.info("Track",n)}},ve=new Jt;var Yo=(e,t)=>{let n={message:t.message,stack:t.stack??"",errorType:t.name,source:0},i={name:e,type:Re.ErrorTrace,location:null,target:null,extra:n,timestamp:Date.now(),userId:R.hostUserInfo?.uid??null};ve.trackEvent(i,pe.WebSDK)};de.on("GLOBAL_ERROR",(e,t)=>{Yo(t.tag,e)});de.on("GLOBAL_USER_ERROR",(e,t)=>{W.log("UserError",e,t)});var je=class{constructor(t,n){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=n??5*1e3,t.on("visible",i=>{this.visible=i})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t??0}}),this.tracker("OpenGame",{duration: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 n=performance.now(),i,l=!1,d=0,m=b=>{if(!l)return;let _=b-n;_>=this.interval&&(this.visible&&(d+=_,t(d)),n=b),i=requestAnimationFrame(m)};return{start(){l||(l=!0,n=performance.now(),i=requestAnimationFrame(m))},stop(){l=!1,i&&cancelAnimationFrame(i)}}}};var Ke=class extends je{constructor(n,i,l){super(i,l);this.httpClient=new le;this.gameId=R.mpId,this.sessionId=R.sessionId,this.track=n}async reporter(n){let{event:i,params:l}=n;await this.httpClient.post("/api/base/app-event",{data:{eventType:i,gameInfo:{gameId:this.gameId,sessionId:this.sessionId,...l}}}),W.log("-----task tracker-----",i,l)}tracker(n,i=null){this.track(n,i)}};var Wr=X(),qo={type:pe.WebSDK,platform:"h5",jssdk_version:R.sdkInfo.jssdkVersion,mp_id:R.mpId,mp_version:R.mpVersion},{track:G,trackPerformance:Qo}=Hr((...e)=>{let[,t]=e,n=t,l={...xr(n.extra)?n.extra:Ct(n.extra)?JSON.parse(n.extra):{},mp_id:n.mp_id??"",mp_version:n.mp_version??""},d={name:t.tag,type:Re.System,location:null,target:null,extra:l,timestamp:Date.now(),userId:R.hostUserInfo?.uid??null};ve.trackEvent(d,pe.WebSDK)},qo);Wr.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t})=>{Qo(e,t)});Wr.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{G(e,t)});var Gt=new ge,re=new Ke(G,Gt);function zr(e){let t=Ut.config[e];return t||(t={},Ut.config[e]=t),(n,i)=>{if(t[n]){W.warn(`[can i use] ${n} already registered`);return}t[n]={...i}}}var Yr=!1;function Ht(e){Yr=e}function Je(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Je(t)):Object.keys(e).reduce((t,n)=>(t[n]=Je(e[n]),t),{})}var M=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Yr)if(typeof t=="string")this.errors.push(t);else{let n=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?n+=" or undefined, ":n+=", ",n+=`but got ${Wt(t.actual)}`,this.errors.push(n)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Je(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Je(this._default)}optional(){return this._optional=!0,this}};function se(e){return typeof e=="number"}function Wt(e){let t=zt(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function zt(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Ge=class extends M{validate(t){return this._optional&&t===void 0?!0:se(t)?se(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):se(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):se(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}},He=class extends M{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},We=class extends M{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(se(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(se(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}},ze=class extends M{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ye=class extends M{validate(t){return!0}},Ye=class extends M{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},qe=class extends M{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Qe=class extends M{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Xe=class extends M{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let n=this._items.map(i=>JSON.stringify(i)).join(", ");return this.fail(`expect ${this.path} to be one of ${n}, but got ${Wt(t)}`)}return!0}},Ze=class extends M{constructor(n){super();this._item=n}validate(n){if(this._optional&&n===void 0)return!0;if(!Array.isArray(n))return this.fail({expect:"array",actual:n});if(se(this._minItems)&&n.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(se(this._maxItems)&&n.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(se(this._length)&&n.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let i=this._item;if(!i)return!0;let l=!0;if(n.forEach((d,m)=>{if(i.path=`${this.path}[${m}]`,i.errors=this.errors,d===void 0&&i.hasDefault){n[m]=i.defaultValue;return}i.validate(d)||(i.hasFallback?n[m]=i.fallbackValue:l=!1)}),this._uniqueItems){let d=new Map;for(let m in n)d.has(n[m])?l=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${d.get(n[m])}] and ${this.path}[${m}] are identical)`):d.set(n[m],m)}return l}minItems(n){return this._minItems=n,this}maxItems(n){return this._maxItems=n,this}uniqueItems(){return this._uniqueItems=!0,this}length(n){return this._length=n,this}},et=class extends M{constructor(n){super();this._value=n}validate(n){if(this._optional&&n===void 0)return!0;if(zt(n)!=="object")return this.fail({expect:"object",actual:n});let l=n,d=this._value;d.errors=this.errors;let m=!0;for(let b in l){let _=l[b];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(b)?d.path=`${this.path}.${b}`:d.path=`${this.path}["${b}"]`,!(_===void 0&&d._optional)){if(_===void 0&&d.hasDefault){l[b]=d.defaultValue;continue}d.validate(_)||(d.hasFallback?l[b]=d.fallbackValue:m=!1)}}return m}},tt=class extends M{constructor(n={}){super();this._object=n}validate(n){if(this._optional&&n===void 0)return!0;if(zt(n)!=="object")return this.fail({expect:"object",actual:n});let i=n,l=!0;for(let d in this._object){let m=i[d],b=this._object[d];if(b.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(d)?b.path=`${this.path}.${d}`:b.path=`${this.path}["${d}"]`,!(b._optional&&m===void 0)){if(m===void 0&&b.hasDefault){i[d]=b.defaultValue;continue}b.validate(m)||(b.hasFallback?i[d]=b.fallbackValue:l=!1)}}return l}},rt=class extends M{constructor(n){super();this.value=n}validate(n){return n===void 0&&this._optional?!0:n!==this.value?this.fail({expect:Wt(this.value),actual:n}):!0}},nt=class extends M{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let n=[],i=!1,l=this._items.length;for(let d=0;d<l;d++){let m=this._items[d];if(m.errors=[],m.path=this.path,!m.validate(t))n.push(m.errors.join("; "));else if(!i){i=!0;break}}if(!i){let d=n.join(`
1
+ var oo=Object.create;var Ir=Object.defineProperty;var io=Object.getOwnPropertyDescriptor;var so=Object.getOwnPropertyNames;var ao=Object.getPrototypeOf,co=Object.prototype.hasOwnProperty;var Ie=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var lo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var uo=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of so(t))!co.call(e,l)&&l!==n&&Ir(e,l,{get:()=>t[l],enumerable:!(i=io(t,l))||i.enumerable});return e};var fo=(e,t,n)=>(n=e!=null?oo(ao(e)):{},uo(t||!e||!e.__esModule?Ir(n,"default",{value:e,enumerable:!0}):n,e));var en=lo((Zr,Zt)=>{(function(e){if(typeof Zr=="object"&&typeof Zt<"u")Zt.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t=this,t.localforage=e()}})(function(){var e,t,n;return function i(l,d,h){function b(I,x){if(!d[I]){if(!l[I]){var m=typeof Ie=="function"&&Ie;if(!x&&m)return m(I,!0);if(E)return E(I,!0);var _=new Error("Cannot find module '"+I+"'");throw _.code="MODULE_NOT_FOUND",_}var P=d[I]={exports:{}};l[I][0].call(P.exports,function(N){var K=l[I][1][N];return b(K||N)},P,P.exports,i,l,d,h)}return d[I].exports}for(var E=typeof Ie=="function"&&Ie,A=0;A<h.length;A++)b(h[A]);return b}({1:[function(i,l,d){(function(h){"use strict";var b=h.MutationObserver||h.WebKitMutationObserver,E;if(b){var A=0,I=new b(N),x=h.document.createTextNode("");I.observe(x,{characterData:!0}),E=function(){x.data=A=++A%2}}else if(!h.setImmediate&&typeof h.MessageChannel<"u"){var m=new h.MessageChannel;m.port1.onmessage=N,E=function(){m.port2.postMessage(0)}}else"document"in h&&"onreadystatechange"in h.document.createElement("script")?E=function(){var V=h.document.createElement("script");V.onreadystatechange=function(){N(),V.onreadystatechange=null,V.parentNode.removeChild(V),V=null},h.document.documentElement.appendChild(V)}:E=function(){setTimeout(N,0)};var _,P=[];function N(){_=!0;for(var V,ne,J=P.length;J;){for(ne=P,P=[],V=-1;++V<J;)ne[V]();J=P.length}_=!1}l.exports=K;function K(V){P.push(V)===1&&!_&&E()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(i,l,d){"use strict";var h=i(1);function b(){}var E={},A=["REJECTED"],I=["FULFILLED"],x=["PENDING"];l.exports=m;function m(T){if(typeof T!="function")throw new TypeError("resolver must be a function");this.state=x,this.queue=[],this.outcome=void 0,T!==b&&K(this,T)}m.prototype.catch=function(T){return this.then(null,T)},m.prototype.then=function(T,D){if(typeof T!="function"&&this.state===I||typeof D!="function"&&this.state===A)return this;var C=new this.constructor(b);if(this.state!==x){var U=this.state===I?T:D;P(C,U,this.outcome)}else this.queue.push(new _(C,T,D));return C};function _(T,D,C){this.promise=T,typeof D=="function"&&(this.onFulfilled=D,this.callFulfilled=this.otherCallFulfilled),typeof C=="function"&&(this.onRejected=C,this.callRejected=this.otherCallRejected)}_.prototype.callFulfilled=function(T){E.resolve(this.promise,T)},_.prototype.otherCallFulfilled=function(T){P(this.promise,this.onFulfilled,T)},_.prototype.callRejected=function(T){E.reject(this.promise,T)},_.prototype.otherCallRejected=function(T){P(this.promise,this.onRejected,T)};function P(T,D,C){h(function(){var U;try{U=D(C)}catch(H){return E.reject(T,H)}U===T?E.reject(T,new TypeError("Cannot resolve promise with itself")):E.resolve(T,U)})}E.resolve=function(T,D){var C=V(N,D);if(C.status==="error")return E.reject(T,C.value);var U=C.value;if(U)K(T,U);else{T.state=I,T.outcome=D;for(var H=-1,z=T.queue.length;++H<z;)T.queue[H].callFulfilled(D)}return T},E.reject=function(T,D){T.state=A,T.outcome=D;for(var C=-1,U=T.queue.length;++C<U;)T.queue[C].callRejected(D);return T};function N(T){var D=T&&T.then;if(T&&(typeof T=="object"||typeof T=="function")&&typeof D=="function")return function(){D.apply(T,arguments)}}function K(T,D){var C=!1;function U(q){C||(C=!0,E.reject(T,q))}function H(q){C||(C=!0,E.resolve(T,q))}function z(){D(H,U)}var Y=V(z);Y.status==="error"&&U(Y.value)}function V(T,D){var C={};try{C.value=T(D),C.status="success"}catch(U){C.status="error",C.value=U}return C}m.resolve=ne;function ne(T){return T instanceof this?T:E.resolve(new this(b),T)}m.reject=J;function J(T){var D=new this(b);return E.reject(D,T)}m.all=gt;function gt(T){var D=this;if(Object.prototype.toString.call(T)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=T.length,U=!1;if(!C)return this.resolve([]);for(var H=new Array(C),z=0,Y=-1,q=new this(b);++Y<C;)oe(T[Y],Y);return q;function oe(_e,Pe){D.resolve(_e).then(vt,function(me){U||(U=!0,E.reject(q,me))});function vt(me){H[Pe]=me,++z===C&&!U&&(U=!0,E.resolve(q,H))}}}m.race=ue;function ue(T){var D=this;if(Object.prototype.toString.call(T)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=T.length,U=!1;if(!C)return this.resolve([]);for(var H=-1,z=new this(b);++H<C;)Y(T[H]);return z;function Y(q){D.resolve(q).then(function(oe){U||(U=!0,E.resolve(z,oe))},function(oe){U||(U=!0,E.reject(z,oe))})}}},{1:1}],3:[function(i,l,d){(function(h){"use strict";typeof h.Promise!="function"&&(h.Promise=i(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(i,l,d){"use strict";var h=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r};function b(r,s){if(!(r instanceof s))throw new TypeError("Cannot call a class as a function")}function E(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var A=E();function I(){try{if(!A||!A.open)return!1;var r=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),s=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!r||s)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function x(r,s){r=r||[],s=s||{};try{return new Blob(r,s)}catch(a){if(a.name!=="TypeError")throw a;for(var o=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,c=new o,u=0;u<r.length;u+=1)c.append(r[u]);return c.getBlob(s.type)}}typeof Promise>"u"&&i(3);var m=Promise;function _(r,s){s&&r.then(function(o){s(null,o)},function(o){s(o)})}function P(r,s,o){typeof s=="function"&&r.then(s),typeof o=="function"&&r.catch(o)}function N(r){return typeof r!="string"&&(console.warn(r+" used as a key, but it is not a string."),r=String(r)),r}function K(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var V="local-forage-detect-blob-support",ne=void 0,J={},gt=Object.prototype.toString,ue="readonly",T="readwrite";function D(r){for(var s=r.length,o=new ArrayBuffer(s),c=new Uint8Array(o),u=0;u<s;u++)c[u]=r.charCodeAt(u);return o}function C(r){return new m(function(s){var o=r.transaction(V,T),c=x([""]);o.objectStore(V).put(c,"key"),o.onabort=function(u){u.preventDefault(),u.stopPropagation(),s(!1)},o.oncomplete=function(){var u=navigator.userAgent.match(/Chrome\/(\d+)/),a=navigator.userAgent.match(/Edge\//);s(a||!u||parseInt(u[1],10)>=43)}}).catch(function(){return!1})}function U(r){return typeof ne=="boolean"?m.resolve(ne):C(r).then(function(s){return ne=s,ne})}function H(r){var s=J[r.name],o={};o.promise=new m(function(c,u){o.resolve=c,o.reject=u}),s.deferredOperations.push(o),s.dbReady?s.dbReady=s.dbReady.then(function(){return o.promise}):s.dbReady=o.promise}function z(r){var s=J[r.name],o=s.deferredOperations.pop();if(o)return o.resolve(),o.promise}function Y(r,s){var o=J[r.name],c=o.deferredOperations.pop();if(c)return c.reject(s),c.promise}function q(r,s){return new m(function(o,c){if(J[r.name]=J[r.name]||nr(),r.db)if(s)H(r),r.db.close();else return o(r.db);var u=[r.name];s&&u.push(r.version);var a=A.open.apply(A,u);s&&(a.onupgradeneeded=function(f){var p=a.result;try{p.createObjectStore(r.storeName),f.oldVersion<=1&&p.createObjectStore(V)}catch(g){if(g.name==="ConstraintError")console.warn('The database "'+r.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+r.storeName+'" already exists.');else throw g}}),a.onerror=function(f){f.preventDefault(),c(a.error)},a.onsuccess=function(){var f=a.result;f.onversionchange=function(p){p.target.close()},o(f),z(r)}})}function oe(r){return q(r,!1)}function _e(r){return q(r,!0)}function Pe(r,s){if(!r.db)return!0;var o=!r.db.objectStoreNames.contains(r.storeName),c=r.version<r.db.version,u=r.version>r.db.version;if(c&&(r.version!==s&&console.warn('The database "'+r.name+`" can't be downgraded from version `+r.db.version+" to version "+r.version+"."),r.version=r.db.version),u||o){if(o){var a=r.db.version+1;a>r.version&&(r.version=a)}return!0}return!1}function vt(r){return new m(function(s,o){var c=new FileReader;c.onerror=o,c.onloadend=function(u){var a=btoa(u.target.result||"");s({__local_forage_encoded_blob:!0,data:a,type:r.type})},c.readAsBinaryString(r)})}function me(r){var s=D(atob(r.data));return x([s],{type:r.type})}function rr(r){return r&&r.__local_forage_encoded_blob}function on(r){var s=this,o=s._initReady().then(function(){var c=J[s._dbInfo.name];if(c&&c.dbReady)return c.dbReady});return P(o,r,r),o}function sn(r){H(r);for(var s=J[r.name],o=s.forages,c=0;c<o.length;c++){var u=o[c];u._dbInfo.db&&(u._dbInfo.db.close(),u._dbInfo.db=null)}return r.db=null,oe(r).then(function(a){return r.db=a,Pe(r)?_e(r):a}).then(function(a){r.db=s.db=a;for(var f=0;f<o.length;f++)o[f]._dbInfo.db=a}).catch(function(a){throw Y(r,a),a})}function ie(r,s,o,c){c===void 0&&(c=1);try{var u=r.db.transaction(r.storeName,s);o(null,u)}catch(a){if(c>0&&(!r.db||a.name==="InvalidStateError"||a.name==="NotFoundError"))return m.resolve().then(function(){if(!r.db||a.name==="NotFoundError"&&!r.db.objectStoreNames.contains(r.storeName)&&r.version<=r.db.version)return r.db&&(r.version=r.db.version+1),_e(r)}).then(function(){return sn(r).then(function(){ie(r,s,o,c-1)})}).catch(o);o(a)}}function nr(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function an(r){var s=this,o={db:null};if(r)for(var c in r)o[c]=r[c];var u=J[o.name];u||(u=nr(),J[o.name]=u),u.forages.push(s),s._initReady||(s._initReady=s.ready,s.ready=on);var a=[];function f(){return m.resolve()}for(var p=0;p<u.forages.length;p++){var g=u.forages[p];g!==s&&a.push(g._initReady().catch(f))}var v=u.forages.slice(0);return m.all(a).then(function(){return o.db=u.db,oe(o)}).then(function(y){return o.db=y,Pe(o,s._defaultConfig.version)?_e(o):y}).then(function(y){o.db=u.db=y,s._dbInfo=o;for(var w=0;w<v.length;w++){var k=v[w];k!==s&&(k._dbInfo.db=o.db,k._dbInfo.version=o.version)}})}function cn(r,s){var o=this;r=N(r);var c=new m(function(u,a){o.ready().then(function(){ie(o._dbInfo,ue,function(f,p){if(f)return a(f);try{var g=p.objectStore(o._dbInfo.storeName),v=g.get(r);v.onsuccess=function(){var y=v.result;y===void 0&&(y=null),rr(y)&&(y=me(y)),u(y)},v.onerror=function(){a(v.error)}}catch(y){a(y)}})}).catch(a)});return _(c,s),c}function ln(r,s){var o=this,c=new m(function(u,a){o.ready().then(function(){ie(o._dbInfo,ue,function(f,p){if(f)return a(f);try{var g=p.objectStore(o._dbInfo.storeName),v=g.openCursor(),y=1;v.onsuccess=function(){var w=v.result;if(w){var k=w.value;rr(k)&&(k=me(k));var O=r(k,w.key,y++);O!==void 0?u(O):w.continue()}else u()},v.onerror=function(){a(v.error)}}catch(w){a(w)}})}).catch(a)});return _(c,s),c}function un(r,s,o){var c=this;r=N(r);var u=new m(function(a,f){var p;c.ready().then(function(){return p=c._dbInfo,gt.call(s)==="[object Blob]"?U(p.db).then(function(g){return g?s:vt(s)}):s}).then(function(g){ie(c._dbInfo,T,function(v,y){if(v)return f(v);try{var w=y.objectStore(c._dbInfo.storeName);g===null&&(g=void 0);var k=w.put(g,r);y.oncomplete=function(){g===void 0&&(g=null),a(g)},y.onabort=y.onerror=function(){var O=k.error?k.error:k.transaction.error;f(O)}}catch(O){f(O)}})}).catch(f)});return _(u,o),u}function dn(r,s){var o=this;r=N(r);var c=new m(function(u,a){o.ready().then(function(){ie(o._dbInfo,T,function(f,p){if(f)return a(f);try{var g=p.objectStore(o._dbInfo.storeName),v=g.delete(r);p.oncomplete=function(){u()},p.onerror=function(){a(v.error)},p.onabort=function(){var y=v.error?v.error:v.transaction.error;a(y)}}catch(y){a(y)}})}).catch(a)});return _(c,s),c}function fn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){ie(s._dbInfo,T,function(a,f){if(a)return u(a);try{var p=f.objectStore(s._dbInfo.storeName),g=p.clear();f.oncomplete=function(){c()},f.onabort=f.onerror=function(){var v=g.error?g.error:g.transaction.error;u(v)}}catch(v){u(v)}})}).catch(u)});return _(o,r),o}function mn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){ie(s._dbInfo,ue,function(a,f){if(a)return u(a);try{var p=f.objectStore(s._dbInfo.storeName),g=p.count();g.onsuccess=function(){c(g.result)},g.onerror=function(){u(g.error)}}catch(v){u(v)}})}).catch(u)});return _(o,r),o}function hn(r,s){var o=this,c=new m(function(u,a){if(r<0){u(null);return}o.ready().then(function(){ie(o._dbInfo,ue,function(f,p){if(f)return a(f);try{var g=p.objectStore(o._dbInfo.storeName),v=!1,y=g.openKeyCursor();y.onsuccess=function(){var w=y.result;if(!w){u(null);return}r===0||v?u(w.key):(v=!0,w.advance(r))},y.onerror=function(){a(y.error)}}catch(w){a(w)}})}).catch(a)});return _(c,s),c}function pn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){ie(s._dbInfo,ue,function(a,f){if(a)return u(a);try{var p=f.objectStore(s._dbInfo.storeName),g=p.openKeyCursor(),v=[];g.onsuccess=function(){var y=g.result;if(!y){c(v);return}v.push(y.key),y.continue()},g.onerror=function(){u(g.error)}}catch(y){u(y)}})}).catch(u)});return _(o,r),o}function gn(r,s){s=K.apply(this,arguments);var o=this.config();r=typeof r!="function"&&r||{},r.name||(r.name=r.name||o.name,r.storeName=r.storeName||o.storeName);var c=this,u;if(!r.name)u=m.reject("Invalid arguments");else{var a=r.name===o.name&&c._dbInfo.db,f=a?m.resolve(c._dbInfo.db):oe(r).then(function(p){var g=J[r.name],v=g.forages;g.db=p;for(var y=0;y<v.length;y++)v[y]._dbInfo.db=p;return p});r.storeName?u=f.then(function(p){if(p.objectStoreNames.contains(r.storeName)){var g=p.version+1;H(r);var v=J[r.name],y=v.forages;p.close();for(var w=0;w<y.length;w++){var k=y[w];k._dbInfo.db=null,k._dbInfo.version=g}var O=new m(function(F,$){var B=A.open(r.name,g);B.onerror=function(Q){var Te=B.result;Te.close(),$(Q)},B.onupgradeneeded=function(){var Q=B.result;Q.deleteObjectStore(r.storeName)},B.onsuccess=function(){var Q=B.result;Q.close(),F(Q)}});return O.then(function(F){v.db=F;for(var $=0;$<y.length;$++){var B=y[$];B._dbInfo.db=F,z(B._dbInfo)}}).catch(function(F){throw(Y(r,F)||m.resolve()).catch(function(){}),F})}}):u=f.then(function(p){H(r);var g=J[r.name],v=g.forages;p.close();for(var y=0;y<v.length;y++){var w=v[y];w._dbInfo.db=null}var k=new m(function(O,F){var $=A.deleteDatabase(r.name);$.onerror=function(){var B=$.result;B&&B.close(),F($.error)},$.onblocked=function(){console.warn('dropInstance blocked for database "'+r.name+'" until all open connections are closed')},$.onsuccess=function(){var B=$.result;B&&B.close(),O(B)}});return k.then(function(O){g.db=O;for(var F=0;F<v.length;F++){var $=v[F];z($._dbInfo)}}).catch(function(O){throw(Y(r,O)||m.resolve()).catch(function(){}),O})})}return _(u,s),u}var vn={_driver:"asyncStorage",_initStorage:an,_support:I(),iterate:ln,getItem:cn,setItem:un,removeItem:dn,clear:fn,length:mn,key:hn,keys:pn,dropInstance:gn};function yn(){return typeof openDatabase=="function"}var ae="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bn="~~local_forage_type~",or=/^~~local_forage_type~([^~]+)~/,Ce="__lfsc__:",yt=Ce.length,bt="arbf",_t="blob",ir="si08",sr="ui08",ar="uic8",cr="si16",lr="si32",ur="ur16",dr="ui32",fr="fl32",mr="fl64",hr=yt+bt.length,pr=Object.prototype.toString;function gr(r){var s=r.length*.75,o=r.length,c,u=0,a,f,p,g;r[r.length-1]==="="&&(s--,r[r.length-2]==="="&&s--);var v=new ArrayBuffer(s),y=new Uint8Array(v);for(c=0;c<o;c+=4)a=ae.indexOf(r[c]),f=ae.indexOf(r[c+1]),p=ae.indexOf(r[c+2]),g=ae.indexOf(r[c+3]),y[u++]=a<<2|f>>4,y[u++]=(f&15)<<4|p>>2,y[u++]=(p&3)<<6|g&63;return v}function Et(r){var s=new Uint8Array(r),o="",c;for(c=0;c<s.length;c+=3)o+=ae[s[c]>>2],o+=ae[(s[c]&3)<<4|s[c+1]>>4],o+=ae[(s[c+1]&15)<<2|s[c+2]>>6],o+=ae[s[c+2]&63];return s.length%3===2?o=o.substring(0,o.length-1)+"=":s.length%3===1&&(o=o.substring(0,o.length-2)+"=="),o}function _n(r,s){var o="";if(r&&(o=pr.call(r)),r&&(o==="[object ArrayBuffer]"||r.buffer&&pr.call(r.buffer)==="[object ArrayBuffer]")){var c,u=Ce;r instanceof ArrayBuffer?(c=r,u+=bt):(c=r.buffer,o==="[object Int8Array]"?u+=ir:o==="[object Uint8Array]"?u+=sr:o==="[object Uint8ClampedArray]"?u+=ar:o==="[object Int16Array]"?u+=cr:o==="[object Uint16Array]"?u+=ur:o==="[object Int32Array]"?u+=lr:o==="[object Uint32Array]"?u+=dr:o==="[object Float32Array]"?u+=fr:o==="[object Float64Array]"?u+=mr:s(new Error("Failed to get type for BinaryArray"))),s(u+Et(c))}else if(o==="[object Blob]"){var a=new FileReader;a.onload=function(){var f=bn+r.type+"~"+Et(this.result);s(Ce+_t+f)},a.readAsArrayBuffer(r)}else try{s(JSON.stringify(r))}catch(f){console.error("Couldn't convert value into a JSON string: ",r),s(null,f)}}function En(r){if(r.substring(0,yt)!==Ce)return JSON.parse(r);var s=r.substring(hr),o=r.substring(yt,hr),c;if(o===_t&&or.test(s)){var u=s.match(or);c=u[1],s=s.substring(u[0].length)}var a=gr(s);switch(o){case bt:return a;case _t:return x([a],{type:c});case ir:return new Int8Array(a);case sr:return new Uint8Array(a);case ar:return new Uint8ClampedArray(a);case cr:return new Int16Array(a);case ur:return new Uint16Array(a);case lr:return new Int32Array(a);case dr:return new Uint32Array(a);case fr:return new Float32Array(a);case mr:return new Float64Array(a);default:throw new Error("Unkown type: "+o)}}var Tt={serialize:_n,deserialize:En,stringToBuffer:gr,bufferToString:Et};function vr(r,s,o,c){r.executeSql("CREATE TABLE IF NOT EXISTS "+s.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],o,c)}function Tn(r){var s=this,o={db:null};if(r)for(var c in r)o[c]=typeof r[c]!="string"?r[c].toString():r[c];var u=new m(function(a,f){try{o.db=openDatabase(o.name,String(o.version),o.description,o.size)}catch(p){return f(p)}o.db.transaction(function(p){vr(p,o,function(){s._dbInfo=o,a()},function(g,v){f(v)})},f)});return o.serializer=Tt,u}function ce(r,s,o,c,u,a){r.executeSql(o,c,u,function(f,p){p.code===p.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[s.storeName],function(g,v){v.rows.length?a(g,p):vr(g,s,function(){g.executeSql(o,c,u,a)},a)},a):a(f,p)},a)}function In(r,s){var o=this;r=N(r);var c=new m(function(u,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(p){ce(p,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[r],function(g,v){var y=v.rows.length?v.rows.item(0).value:null;y&&(y=f.serializer.deserialize(y)),u(y)},function(g,v){a(v)})})}).catch(a)});return _(c,s),c}function wn(r,s){var o=this,c=new m(function(u,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(p){ce(p,f,"SELECT * FROM "+f.storeName,[],function(g,v){for(var y=v.rows,w=y.length,k=0;k<w;k++){var O=y.item(k),F=O.value;if(F&&(F=f.serializer.deserialize(F)),F=r(F,O.key,k+1),F!==void 0){u(F);return}}u()},function(g,v){a(v)})})}).catch(a)});return _(c,s),c}function yr(r,s,o,c){var u=this;r=N(r);var a=new m(function(f,p){u.ready().then(function(){s===void 0&&(s=null);var g=s,v=u._dbInfo;v.serializer.serialize(s,function(y,w){w?p(w):v.db.transaction(function(k){ce(k,v,"INSERT OR REPLACE INTO "+v.storeName+" (key, value) VALUES (?, ?)",[r,y],function(){f(g)},function(O,F){p(F)})},function(k){if(k.code===k.QUOTA_ERR){if(c>0){f(yr.apply(u,[r,g,o,c-1]));return}p(k)}})})}).catch(p)});return _(a,o),a}function An(r,s,o){return yr.apply(this,[r,s,o,1])}function Sn(r,s){var o=this;r=N(r);var c=new m(function(u,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(p){ce(p,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[r],function(){u()},function(g,v){a(v)})})}).catch(a)});return _(c,s),c}function Rn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){var a=s._dbInfo;a.db.transaction(function(f){ce(f,a,"DELETE FROM "+a.storeName,[],function(){c()},function(p,g){u(g)})})}).catch(u)});return _(o,r),o}function xn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){var a=s._dbInfo;a.db.transaction(function(f){ce(f,a,"SELECT COUNT(key) as c FROM "+a.storeName,[],function(p,g){var v=g.rows.item(0).c;c(v)},function(p,g){u(g)})})}).catch(u)});return _(o,r),o}function kn(r,s){var o=this,c=new m(function(u,a){o.ready().then(function(){var f=o._dbInfo;f.db.transaction(function(p){ce(p,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[r+1],function(g,v){var y=v.rows.length?v.rows.item(0).key:null;u(y)},function(g,v){a(v)})})}).catch(a)});return _(c,s),c}function Pn(r){var s=this,o=new m(function(c,u){s.ready().then(function(){var a=s._dbInfo;a.db.transaction(function(f){ce(f,a,"SELECT key FROM "+a.storeName,[],function(p,g){for(var v=[],y=0;y<g.rows.length;y++)v.push(g.rows.item(y).key);c(v)},function(p,g){u(g)})})}).catch(u)});return _(o,r),o}function Cn(r){return new m(function(s,o){r.transaction(function(c){c.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(u,a){for(var f=[],p=0;p<a.rows.length;p++)f.push(a.rows.item(p).name);s({db:r,storeNames:f})},function(u,a){o(a)})},function(c){o(c)})})}function Dn(r,s){s=K.apply(this,arguments);var o=this.config();r=typeof r!="function"&&r||{},r.name||(r.name=r.name||o.name,r.storeName=r.storeName||o.storeName);var c=this,u;return r.name?u=new m(function(a){var f;r.name===o.name?f=c._dbInfo.db:f=openDatabase(r.name,"","",0),r.storeName?a({db:f,storeNames:[r.storeName]}):a(Cn(f))}).then(function(a){return new m(function(f,p){a.db.transaction(function(g){function v(O){return new m(function(F,$){g.executeSql("DROP TABLE IF EXISTS "+O,[],function(){F()},function(B,Q){$(Q)})})}for(var y=[],w=0,k=a.storeNames.length;w<k;w++)y.push(v(a.storeNames[w]));m.all(y).then(function(){f()}).catch(function(O){p(O)})},function(g){p(g)})})}):u=m.reject("Invalid arguments"),_(u,s),u}var On={_driver:"webSQLStorage",_initStorage:Tn,_support:yn(),iterate:wn,getItem:In,setItem:An,removeItem:Sn,clear:Rn,length:xn,key:kn,keys:Pn,dropInstance:Dn};function Fn(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function br(r,s){var o=r.name+"/";return r.storeName!==s.storeName&&(o+=r.storeName+"/"),o}function Nn(){var r="_localforage_support_test";try{return localStorage.setItem(r,!0),localStorage.removeItem(r),!1}catch{return!0}}function Un(){return!Nn()||localStorage.length>0}function Ln(r){var s=this,o={};if(r)for(var c in r)o[c]=r[c];return o.keyPrefix=br(r,s._defaultConfig),Un()?(s._dbInfo=o,o.serializer=Tt,m.resolve()):m.reject()}function Bn(r){var s=this,o=s.ready().then(function(){for(var c=s._dbInfo.keyPrefix,u=localStorage.length-1;u>=0;u--){var a=localStorage.key(u);a.indexOf(c)===0&&localStorage.removeItem(a)}});return _(o,r),o}function $n(r,s){var o=this;r=N(r);var c=o.ready().then(function(){var u=o._dbInfo,a=localStorage.getItem(u.keyPrefix+r);return a&&(a=u.serializer.deserialize(a)),a});return _(c,s),c}function Mn(r,s){var o=this,c=o.ready().then(function(){for(var u=o._dbInfo,a=u.keyPrefix,f=a.length,p=localStorage.length,g=1,v=0;v<p;v++){var y=localStorage.key(v);if(y.indexOf(a)===0){var w=localStorage.getItem(y);if(w&&(w=u.serializer.deserialize(w)),w=r(w,y.substring(f),g++),w!==void 0)return w}}});return _(c,s),c}function Vn(r,s){var o=this,c=o.ready().then(function(){var u=o._dbInfo,a;try{a=localStorage.key(r)}catch{a=null}return a&&(a=a.substring(u.keyPrefix.length)),a});return _(c,s),c}function jn(r){var s=this,o=s.ready().then(function(){for(var c=s._dbInfo,u=localStorage.length,a=[],f=0;f<u;f++){var p=localStorage.key(f);p.indexOf(c.keyPrefix)===0&&a.push(p.substring(c.keyPrefix.length))}return a});return _(o,r),o}function Kn(r){var s=this,o=s.keys().then(function(c){return c.length});return _(o,r),o}function Jn(r,s){var o=this;r=N(r);var c=o.ready().then(function(){var u=o._dbInfo;localStorage.removeItem(u.keyPrefix+r)});return _(c,s),c}function Gn(r,s,o){var c=this;r=N(r);var u=c.ready().then(function(){s===void 0&&(s=null);var a=s;return new m(function(f,p){var g=c._dbInfo;g.serializer.serialize(s,function(v,y){if(y)p(y);else try{localStorage.setItem(g.keyPrefix+r,v),f(a)}catch(w){(w.name==="QuotaExceededError"||w.name==="NS_ERROR_DOM_QUOTA_REACHED")&&p(w),p(w)}})})});return _(u,o),u}function Hn(r,s){if(s=K.apply(this,arguments),r=typeof r!="function"&&r||{},!r.name){var o=this.config();r.name=r.name||o.name,r.storeName=r.storeName||o.storeName}var c=this,u;return r.name?u=new m(function(a){r.storeName?a(br(r,c._defaultConfig)):a(r.name+"/")}).then(function(a){for(var f=localStorage.length-1;f>=0;f--){var p=localStorage.key(f);p.indexOf(a)===0&&localStorage.removeItem(p)}}):u=m.reject("Invalid arguments"),_(u,s),u}var Wn={_driver:"localStorageWrapper",_initStorage:Ln,_support:Fn(),iterate:Mn,getItem:$n,setItem:Gn,removeItem:Jn,clear:Bn,length:Kn,key:Vn,keys:jn,dropInstance:Hn},zn=function(s,o){return s===o||typeof s=="number"&&typeof o=="number"&&isNaN(s)&&isNaN(o)},Yn=function(s,o){for(var c=s.length,u=0;u<c;){if(zn(s[u],o))return!0;u++}return!1},_r=Array.isArray||function(r){return Object.prototype.toString.call(r)==="[object Array]"},Ee={},Er={},he={INDEXEDDB:vn,WEBSQL:On,LOCALSTORAGE:Wn},qn=[he.INDEXEDDB._driver,he.WEBSQL._driver,he.LOCALSTORAGE._driver],De=["dropInstance"],It=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(De),Qn={description:"",driver:qn.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Xn(r,s){r[s]=function(){var o=arguments;return r.ready().then(function(){return r[s].apply(r,o)})}}function wt(){for(var r=1;r<arguments.length;r++){var s=arguments[r];if(s)for(var o in s)s.hasOwnProperty(o)&&(_r(s[o])?arguments[0][o]=s[o].slice():arguments[0][o]=s[o])}return arguments[0]}var Zn=function(){function r(s){b(this,r);for(var o in he)if(he.hasOwnProperty(o)){var c=he[o],u=c._driver;this[o]=u,Ee[u]||this.defineDriver(c)}this._defaultConfig=wt({},Qn),this._config=wt({},this._defaultConfig,s),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return r.prototype.config=function(o){if((typeof o>"u"?"undefined":h(o))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var c in o){if(c==="storeName"&&(o[c]=o[c].replace(/\W/g,"_")),c==="version"&&typeof o[c]!="number")return new Error("Database version must be a number.");this._config[c]=o[c]}return"driver"in o&&o.driver?this.setDriver(this._config.driver):!0}else return typeof o=="string"?this._config[o]:this._config},r.prototype.defineDriver=function(o,c,u){var a=new m(function(f,p){try{var g=o._driver,v=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!o._driver){p(v);return}for(var y=It.concat("_initStorage"),w=0,k=y.length;w<k;w++){var O=y[w],F=!Yn(De,O);if((F||o[O])&&typeof o[O]!="function"){p(v);return}}var $=function(){for(var Te=function(ro){return function(){var no=new Error("Method "+ro+" is not implemented by the current driver"),Tr=m.reject(no);return _(Tr,arguments[arguments.length-1]),Tr}},At=0,to=De.length;At<to;At++){var St=De[At];o[St]||(o[St]=Te(St))}};$();var B=function(Te){Ee[g]&&console.info("Redefining LocalForage driver: "+g),Ee[g]=o,Er[g]=Te,f()};"_support"in o?o._support&&typeof o._support=="function"?o._support().then(B,p):B(!!o._support):B(!0)}catch(Q){p(Q)}});return P(a,c,u),a},r.prototype.driver=function(){return this._driver||null},r.prototype.getDriver=function(o,c,u){var a=Ee[o]?m.resolve(Ee[o]):m.reject(new Error("Driver not found."));return P(a,c,u),a},r.prototype.getSerializer=function(o){var c=m.resolve(Tt);return P(c,o),c},r.prototype.ready=function(o){var c=this,u=c._driverSet.then(function(){return c._ready===null&&(c._ready=c._initDriver()),c._ready});return P(u,o,o),u},r.prototype.setDriver=function(o,c,u){var a=this;_r(o)||(o=[o]);var f=this._getSupportedDrivers(o);function p(){a._config.driver=a.driver()}function g(w){return a._extend(w),p(),a._ready=a._initStorage(a._config),a._ready}function v(w){return function(){var k=0;function O(){for(;k<w.length;){var F=w[k];return k++,a._dbInfo=null,a._ready=null,a.getDriver(F).then(g).catch(O)}p();var $=new Error("No available storage method found.");return a._driverSet=m.reject($),a._driverSet}return O()}}var y=this._driverSet!==null?this._driverSet.catch(function(){return m.resolve()}):m.resolve();return this._driverSet=y.then(function(){var w=f[0];return a._dbInfo=null,a._ready=null,a.getDriver(w).then(function(k){a._driver=k._driver,p(),a._wrapLibraryMethodsWithReady(),a._initDriver=v(f)})}).catch(function(){p();var w=new Error("No available storage method found.");return a._driverSet=m.reject(w),a._driverSet}),P(this._driverSet,c,u),this._driverSet},r.prototype.supports=function(o){return!!Er[o]},r.prototype._extend=function(o){wt(this,o)},r.prototype._getSupportedDrivers=function(o){for(var c=[],u=0,a=o.length;u<a;u++){var f=o[u];this.supports(f)&&c.push(f)}return c},r.prototype._wrapLibraryMethodsWithReady=function(){for(var o=0,c=It.length;o<c;o++)Xn(this,It[o])},r.prototype.createInstance=function(o){return new r(o)},r}(),eo=new Zn;l.exports=eo},{3:3}]},{},[4])(4)})});var Sr=Object.defineProperty,mo=Object.getOwnPropertyDescriptor,ho=(e,t)=>{for(var n in t)Sr(e,n,{get:t[n],enumerable:!0})},Rr=(e,t,n,i)=>{for(var l=i>1?void 0:i?mo(t,n):t,d=e.length-1,h;d>=0;d--)(h=e[d])&&(l=(i?h(t,n,l):h(l))||l);return i&&l&&Sr(t,n,l),l};function po(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Ct(e){return typeof e=="string"}function xr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function kr(e){return typeof e=="object"&&Array.isArray(e)}function go(e){return typeof e>"u"}function vo(e){return go(e)||e===null}function yo(e){return typeof e=="function"}function Pr(e){let t=e,n=null,i=function(...l){return n||(n=new t(...l)),n};return i.prototype=t.prototype,i}function Cr(e,t,n){if(typeof n!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function i(l,d){for(let h in d)if(Object.prototype.hasOwnProperty.call(d,h)){let b=l[h],E=d[h],A=n(b,E,h,l,d);A!==void 0?l[h]=A:wr(E)&&wr(b)?l[h]=i({...b},E):Array.isArray(E)&&Array.isArray(b)?l[h]=[...b,...E]:l[h]=E}return l}return i(e,t)}function wr(e){return e&&typeof e=="object"&&e.constructor===Object}function Dr(e,t){if(Array.isArray(e))return e.concat(t)}function Se(e,t,n={}){let i=null,l,d,h,{leading:b=!1,trailing:E=!0}=n,A=()=>(h=e.apply(d,l),l=void 0,d=void 0,h),I=function(...x){l=x,d=this;let m=b&&!i;if(i&&clearTimeout(i),i=setTimeout(()=>{i=null,E&&!m&&A()},t),m)return A()};return I.cancel=()=>{i&&clearTimeout(i),i=null,l=d=void 0},I.flush=()=>{if(i)return clearTimeout(i),i=null,A()},I}var 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||{}),Dt=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}},Ot=class extends Dt{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},_o=class extends Dt{constructor(){super(...arguments),this.kind="USER_ERROR"}};var Ft=class extends _o{constructor(e,t,n){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,n&&(this.extra=Object.assign({},this.extra,n))}};var Or=class extends Ot{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}};var Fr=class extends Ot{constructor(e,t){super(e),this.message=e,this.name="INTERNAL_CONTEXT_ERROR",this.property=t}},Be=class extends Dt{constructor(e,t,n,i,l){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",n&&(this.errorType=n),i!==void 0&&(this.stack=i),l&&(this.priority=l)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};var Nt=class extends Ot{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};function Eo(e,t){return(...n)=>t(e,...n)}function Nr(e){return t=>Eo(t,function(n,...i){if(typeof n=="function")try{return n.apply(this,i)}catch(l){e(new Ft(`${l}`))}})}function we(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}var W={log:we("log"),warn:we("warn"),info:we("info"),error:we("error"),debug:we("debug")};Object.assign(globalThis,{logger:W});var Ur=Symbol.for("Jolibox.canIUseMap"),To={};globalThis[Ur]=To;var Ut={get config(){return globalThis[Ur]}};var Re=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Re||{}),pe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(pe||{}),Io=(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))(Io||{}),Ar=["name","params"],wo=["name","type","location","target","extra","timestamp","userId"],Ao=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function Ne(e,t){return t.map(n=>{if(n==="params"&&e[n]){let i=e[n];return Object.keys(i).reduce((l,d)=>(l[d]=String(i[d]),l),{})}return e[n]})}function So(e){let t=e.location?Ne(e.location,Ar):null,n=e.target?Ne(e.target,Ar):null;return Ne({...e,location:t,target:n},wo)}function Lt(e){let t=e.events.map(i=>So(i)),n=Ne(e.device,Ao);return[e.protocolVersion,t,n,e.project]}var Ro=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});var 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")},xo=()=>Oe.isiOS?"iOS":Oe.isAndroid?"Android":Oe.isMac?"Mac":Oe.isFacebook?"Facebook":"PC",ko="device_id",Po="advertising_id",Lr=e=>(localStorage.getItem(e)||localStorage.setItem(e,Ro()),localStorage.getItem(e)),Bt=()=>Lr(ko),Co=()=>Lr(Po),Do=e=>e.charAt(0).toUpperCase()+e.slice(1),Oo=()=>{let e=new URLSearchParams(window.location.search);return Do(e.get("utm_source")??"")||"JoliboxSDK"},Br=e=>{let t="JoliboxWebSDK",n=xo(),i=navigator.language,l=Bt(),d=Co();return`${t} (${Oo()}${n}; UnknownModel; UnknownSystemVersion; ${i}) uuid/${l} adid/${d} version/${e||""}`},L=class Ue{static{this.Undefined=new Ue(void 0)}constructor(t){this.element=t,this.next=Ue.Undefined,this.prev=Ue.Undefined}},Fo=class{constructor(){this._first=L.Undefined,this._last=L.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===L.Undefined}clear(){let e=this._first;for(;e!==L.Undefined;){let t=e.next;e.prev=L.Undefined,e.next=L.Undefined,e=t}this._first=L.Undefined,this._last=L.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new L(e);if(this._first===L.Undefined)this._first=n,this._last=n;else if(t){let l=this._last;this._last=n,n.prev=l,l.next=n}else{let l=this._first;this._first=n,n.next=l,l.prev=n}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(n))}}shift(){if(this._first!==L.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==L.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==L.Undefined&&e.next!==L.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===L.Undefined&&e.next===L.Undefined?(this._first=L.Undefined,this._last=L.Undefined):e.next===L.Undefined?(this._last=this._last.prev,this._last.next=L.Undefined):e.prev===L.Undefined&&(this._first=this._first.next,this._first.prev=L.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==L.Undefined;)yield e.element,e=e.next}},No=0,Fe=class{constructor(e){this.value=e,this.id=No++}},Ae=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof Fe&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(t=>t?.value===e)):(this._listeners=void 0,this._size=0)),this.options?.onDidRemoveLastListener?.())}get event(){return this._event??=(e,t)=>{if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};t&&(e=e.bind(t));let n=new Fe(e);this._listeners?this._listeners instanceof Fe?this._listeners=[this._listeners,n]:this._listeners.push(n):(this.options?.onWillAddFirstListener?.(this),this._listeners=n,this.options?.onDidFirstListener?.(this)),this.options?.onDidAddListener?.(this),this._size++},this._event}_deliver(e,t){if(!e)return;let n=this.options?.onListenerError||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof Fe?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ge=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){let n=this.listeners.get(e)??new Ae,i=d=>t(...d.args);this.listerHandlerMap.set(t,i),n.event(i),this.listeners.set(e,n);let l=this.cachedEventQueue.get(e);if(l)for(;l.size>0;)n.fire({event:e,...l.shift()})}off(e,t){let n=this.listeners.get(e);if(n){let i=this.listerHandlerMap.get(t);n.dispose(i)}}emit(e,...t){let n=this.listeners.get(e);if(n)n.fire({event:e,args:t});else{let i=this.cachedEventQueue.get(e);i||(i=new Fo,this.cachedEventQueue.set(e,i)),i.push({args:t})}}},kt={};ho(kt,{None:()=>Uo,filter:()=>Bo,once:()=>$r,toPromise:()=>Lo});var Uo=()=>{console.log("[Jolibox SDK] None Event")};function Lo(e){return new Promise(t=>$r(e)(t))}function $r(e){return(t,n=null)=>{let i=!1;return e(l=>{if(!i)return i=!0,t.call(n,l)},null)}}function Bo(e,t){return(n=>{let i,l={onWillAddFirstListener(){i=n(d.fire,d)}},d=new Ae(l);return d.event})((n,i=null)=>e(l=>t(l)&&n.call(i,l),null))}var Rt=Symbol.for("Jolibox.hostEmitter"),$o=()=>{let e=new ge;return globalThis[Rt]||(globalThis[Rt]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[Rt]},xe=$o();function Mo(e,t){let n=Math.min(e.length,t.length);for(let i=0;i<n;i++)Vo(e[i],t[i])}function Vo(e,t){if(Ct(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(yo(t)){try{if(e instanceof t)return}catch{}if(!vo(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var Le=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Ae,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 n=[];for(let l of e.metadata.args)n.push(l.constraint);let i=e.handler;e.handler=function(...l){return Mo(l,n),i(...l)}}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 n=this.getCommand(t);n&&e.set(t,n)}return e}};Le=Rr([Pr],Le);var Pt=class{constructor(){this._onWillExecuteCommand=new Ae,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Ae,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Le,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=po(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),kt.toPromise(kt.filter(this.registry.onDidRegisterCommand,n=>n===e))])]),this._tryExecuteCommand(e,t))}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let n=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let i=this.invokeFunction(n.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),i}_tryExecuteCommand(e,t){let n=this.registry.getCommand(e);if(!n)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let i=this.invokeFunction(n.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(i)}catch(i){return Promise.reject(i)}}invokeFunction(e,...t){let n=!1;try{return e(...t)}finally{n=!0}}};Pt=Rr([Pr],Pt);var xt=Symbol.for("Jolibox.commands");function X(){if(globalThis[xt])return globalThis[xt];let e=new Le,t=new Pt,n={registerCommand(i,l,d){e.registerCommand({id:i,handler:l,metadata:d})},executeCommand(i,...l){return t.executeCommand(i,...l)},excuteCommandSync(i,...l){return t.executeCommandThowErr(i,...l)}};return globalThis[xt]=n,n}var $t=new ge,de=new ge;function ee(e,t={}){$t.emit("ERROR_REPORT",{error:e,options:t})}ee.debounce=Se(ee,50,{leading:!0});var Mt=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t.length%4===0?"":"=".repeat(4-t.length%4),i=atob(t+n);try{return JSON.parse(i)}catch{return{}}},Mr=e=>{try{let i=new URL(e).searchParams.get("joliSource")?.split(".");if(i?.length){let[l,d,h]=i;return{headerJson:Mt(l),payloadJson:Mt(d),signature:Mt(h)}}else throw"joli_source is missing"}catch(t){return ee(new Or(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}};var jo="1.1.4-beta.13",$e=()=>jo,Vr=()=>{let e=$e();return`${Br(e)}`};var Ko={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:Bt(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:$e()},schema:"",platform:"h5"},Jo=globalThis.joliboxJSCore?.env,te=Object.assign({},Jo?.()??Ko),Go=()=>{let{payloadJson:e,headerJson:t}=Mr(te.schema),n=`${te.deviceInfo.did}-${new Date().getTime()}`,i=new URLSearchParams(te.schema.length?te.schema:window.location.search),l=i.get("mpId")??i.get("appId")??i.get("gameId")??"",d=e.sessionId??i.get("sessionId")??n,h=!!(e.testAdsMode??i.get("testAdsMode")==="true"),b=e.joliboxEnv??i.get("joliboxEnv")??"production",E=b==="staging";return{get testMode(){return E},get testAdsMode(){return h},get joliboxEnv(){return b},get mpId(){return l??e.id},get mpVersion(){return t.ver??$e()},get platform(){return te.platform},get deviceInfo(){return te.deviceInfo},get sdkInfo(){return te.sdkInfo},get hostInfo(){return te.hostInfo},get hostUserInfo(){return te.hostUserInfo},get sessionId(){return te.clientSessionId??d??n},onEnvConfigChanged:A=>{Cr(te,A,Dr)}}},R=Go();var Vt=!1,Kr=(e,t)=>e==null?!1:t in e,Ho=e=>Kr(e,"kind"),Wo=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")},jr=(e,t={},n)=>{let i=e.priority??"P1",d={...{user_id:R.hostUserInfo?.uid??"",device_id:R.deviceInfo.did??"",timestamp:Date.now(),tag:Wo(e.name)},env:t.environment,isFromUser:n};n?de.emit("GLOBAL_USER_ERROR",e,d):de.emit("GLOBAL_ERROR",e,d)},zo=e=>Kr(e,"kind")&&e.kind==="USER_ERROR";$t.on("ERROR_REPORT",({error:e,options:t})=>{if(Vt)return;Vt=!0;let n=Ho(e)&&e.raw?e.raw:e;try{let i=zo(e);jr(e,t,i)}catch(i){let l=i instanceof Error?i.message:String(i),d=new Nt(`${l}, origin error: ${n.message}`);W.error(d),jr(new Nt(d.message),{environment:t.environment},!1)}finally{Vt=!1}});var jt=e=>new Ft(e);function Jr(e,t){let n=(i,l,d)=>{let h={tag:i,...t,extra:{...l}};i=="globalJsError"?ee(new Fr(JSON.stringify(h),"P0")):e("systemLog",h,d)};return n.debounce=Se(n,500,{leading:!0}),n}function Gr(e){let t=(n,i,l)=>{let d=(l&&JSON.stringify(l))??0,h={speed_value_type:n,total_duration:i};d&&Object.assign(h,{extra:d}),e("joliboxSpeedAnalysis",h)};return t.debounce=Se(t,500,{leading:!0}),t}function Hr(e,t){let n=Jr(e,t),i=Gr(n);return{track:n,trackPerformance:i}}var Me=class{constructor(){this.deviceInfo=null;this.pastTrackings=[];this.pushPastTracking=t=>{this.pastTrackings.push(t),this.pastTrackings.length>10&&this.pastTrackings.slice(-10)}}get networkIsOk(){return this.pastTrackings.length<=4||this.pastTrackings.filter(Boolean).length/this.pastTrackings.length>=.6}getDevice(){let{nativeSDKVersion:t,jssdkVersion:n}=R.sdkInfo;return{platform:1e3,os:R.deviceInfo.platform,appVersion:t??n??"1.0.0",appId:R.hostInfo?.aid??"1",model:R.deviceInfo.model??"UnknownModel",brand:R.deviceInfo.brand??"UnknownBrand",uuid:R.deviceInfo.did,jsSdkVersion:n,extra:{}}}getLocation(){let t=new URLSearchParams(window.location.search),n={};return t.forEach((i,l)=>{n[l]=i}),{name:"GamePage",params:n}}async trackEvent(t,n,i){let l=t.location?t.location:await this.getLocation(),d=t.target||null,h=t.extra||null;this.deviceInfo||(this.deviceInfo=await this.getDevice());let b=this.deviceInfo,A={protocolVersion:"1.0.0",events:[{...t,location:l,target:d,extra:h,timestamp:Date.now(),userId:null}],device:b,project:n};try{i?this.doReport(Lt(A),i):this.doReport(Lt(A)),this.pushPastTracking(!0)}catch(I){this.pushPastTracking(!1),W.log("[Jolibox SDK] report API error",I)}}};var Kt=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};AbortSignal.timeout??=Kt;var Ve=class{constructor(t){this.xua=Vr();this.getJoliSource=()=>new URLSearchParams(window.location.search).get("joliSource")??null;let n=R.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com";this.baseUrl=t?.baseUrl??n}async get(t,{query:n,headers:i,timeout:l}){let h=new URLSearchParams(n).toString(),b=`${this.baseUrl}${t}${h?`?${h}`:""}`,E=this.xua,A=this.getJoliSource();return i=Object.assign({},i,E?{"x-user-agent":E}:{},A?{"x-joli-source":A}:{}),await(await fetch(b,{method:"GET",headers:i,credentials:"include",signal:Kt(l??3e4)})).json()}async post(t,{data:n,query:i,headers:l,timeout:d}){let b=new URLSearchParams(i).toString(),E=`${this.baseUrl}${t}${b?`?${b}`:""}`,A=this.xua,I=this.getJoliSource();l=Object.assign({},l,{"Content-Type":"application/json"},A?{"x-user-agent":A}:{},I?{"x-joli-source":I}:{});let x=await fetch(E,{method:"POST",headers:l,body:JSON.stringify(n),signal:Kt(d??3e4),credentials:"include"}),m=x.headers.get("content-type");if(m?.includes("application/octet-stream"))try{return x.blob()}catch{return await x.arrayBuffer()}if(m?.includes("multipart/form-data")||m?.includes("application/x-www-form-urlencoded"))try{return x.formData()}catch{return await x.text()}if(m?.includes("application/json"))try{return await x.json()}catch{return await x.text()}return x}async put(t,{data:n,query:i,headers:l}){try{let h=new URLSearchParams(i).toString(),b=`${this.baseUrl}${t}${h?`?${h}`:""}`,E=this.xua,A=this.getJoliSource();l=Object.assign({},l,{"Content-Type":"application/json"},E?{"x-user-agent":E}:{},A?{"x-joli-source":A}:{});let I=await fetch(b,{method:"PUT",headers:l,credentials:"include",body:JSON.stringify(n??{})});if(!I.ok)throw new Error(`HTTP error! status: ${I.status}`);return await I.json()}catch(d){throw console.error("Error:",d),d}}};window.JoliboxHttpClient=Ve;var le=Ve;var Jt=class extends Me{constructor(){super(...arguments);this.hostToApiMap={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}};this.httpClient=new le({baseUrl:this.apiBaseURL})}get apiBaseURL(){let n=this.hostToApiMap[window.location.host]??this.hostToApiMap.default;return R.testMode??!1?n.test:n.prod}doReport(n){this.httpClient.post("/report",{data:n,timeout:5e3}),W.info("Track",n)}},ve=new Jt;var Yo=(e,t)=>{let n={message:t.message,stack:t.stack??"",errorType:t.name,source:0},i={name:e,type:Re.ErrorTrace,location:null,target:null,extra:n,timestamp:Date.now(),userId:R.hostUserInfo?.uid??null};ve.trackEvent(i,pe.WebSDK)};de.on("GLOBAL_ERROR",(e,t)=>{Yo(t.tag,e)});de.on("GLOBAL_USER_ERROR",(e,t)=>{W.log("UserError",e,t)});var je=class{constructor(t,n){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=n??5*1e3,t.on("visible",i=>{this.visible=i})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t??0}}),this.tracker("OpenGame",{duration: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 n=Date.now(),i,l,d=!1,h=0,b=()=>{if(!d)return;let _=Date.now(),P=_-n;P>=this.interval&&(this.visible&&(h+=P,t(h)),n=_),i=requestAnimationFrame(b)},E=()=>{I(),n=Date.now(),l=window.setInterval(()=>{if(!d)return;let _=Date.now();_-n>=this.interval&&(n=_)},this.interval)},A=()=>{x(),n=Date.now(),i=requestAnimationFrame(b)},I=()=>{i&&(cancelAnimationFrame(i),i=0)},x=()=>{l&&(clearInterval(l),l=0)};this.eventEmitter.on("visible",_=>{d&&(console.log("visible",_),_?A():E())});let m=this.visible;return{start(){d||(d=!0,m?A():E())},stop(){d=!1,I(),x()}}}};var Ke=class extends je{constructor(n,i,l){super(i,l);this.httpClient=new le;this.gameId=R.mpId,this.sessionId=R.sessionId,this.track=n}async reporter(n){let{event:i,params:l}=n;await this.httpClient.post("/api/base/app-event",{data:{eventType:i,gameInfo:{gameId:this.gameId,sessionId:this.sessionId,...l}}}),W.log("-----task tracker-----",i,l)}tracker(n,i=null){this.track(n,i)}};var Wr=X(),qo={type:pe.WebSDK,platform:"h5",jssdk_version:R.sdkInfo.jssdkVersion,mp_id:R.mpId,mp_version:R.mpVersion},{track:G,trackPerformance:Qo}=Hr((...e)=>{let[,t]=e,n=t,l={...xr(n.extra)?n.extra:Ct(n.extra)?JSON.parse(n.extra):{},mp_id:n.mp_id??"",mp_version:n.mp_version??""},d={name:t.tag,type:Re.System,location:null,target:null,extra:l,timestamp:Date.now(),userId:R.hostUserInfo?.uid??null};ve.trackEvent(d,pe.WebSDK)},qo);Wr.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t})=>{Qo(e,t)});Wr.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{G(e,t)});var Gt=new ge,re=new Ke(G,Gt);function zr(e){let t=Ut.config[e];return t||(t={},Ut.config[e]=t),(n,i)=>{if(t[n]){W.warn(`[can i use] ${n} already registered`);return}t[n]={...i}}}var Yr=!1;function Ht(e){Yr=e}function Je(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Je(t)):Object.keys(e).reduce((t,n)=>(t[n]=Je(e[n]),t),{})}var M=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Yr)if(typeof t=="string")this.errors.push(t);else{let n=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?n+=" or undefined, ":n+=", ",n+=`but got ${Wt(t.actual)}`,this.errors.push(n)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Je(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Je(this._default)}optional(){return this._optional=!0,this}};function se(e){return typeof e=="number"}function Wt(e){let t=zt(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function zt(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Ge=class extends M{validate(t){return this._optional&&t===void 0?!0:se(t)?se(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):se(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):se(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}},He=class extends M{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},We=class extends M{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(se(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(se(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}},ze=class extends M{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ye=class extends M{validate(t){return!0}},Ye=class extends M{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},qe=class extends M{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Qe=class extends M{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Xe=class extends M{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let n=this._items.map(i=>JSON.stringify(i)).join(", ");return this.fail(`expect ${this.path} to be one of ${n}, but got ${Wt(t)}`)}return!0}},Ze=class extends M{constructor(n){super();this._item=n}validate(n){if(this._optional&&n===void 0)return!0;if(!Array.isArray(n))return this.fail({expect:"array",actual:n});if(se(this._minItems)&&n.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(se(this._maxItems)&&n.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(se(this._length)&&n.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let i=this._item;if(!i)return!0;let l=!0;if(n.forEach((d,h)=>{if(i.path=`${this.path}[${h}]`,i.errors=this.errors,d===void 0&&i.hasDefault){n[h]=i.defaultValue;return}i.validate(d)||(i.hasFallback?n[h]=i.fallbackValue:l=!1)}),this._uniqueItems){let d=new Map;for(let h in n)d.has(n[h])?l=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${d.get(n[h])}] and ${this.path}[${h}] are identical)`):d.set(n[h],h)}return l}minItems(n){return this._minItems=n,this}maxItems(n){return this._maxItems=n,this}uniqueItems(){return this._uniqueItems=!0,this}length(n){return this._length=n,this}},et=class extends M{constructor(n){super();this._value=n}validate(n){if(this._optional&&n===void 0)return!0;if(zt(n)!=="object")return this.fail({expect:"object",actual:n});let l=n,d=this._value;d.errors=this.errors;let h=!0;for(let b in l){let E=l[b];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(b)?d.path=`${this.path}.${b}`:d.path=`${this.path}["${b}"]`,!(E===void 0&&d._optional)){if(E===void 0&&d.hasDefault){l[b]=d.defaultValue;continue}d.validate(E)||(d.hasFallback?l[b]=d.fallbackValue:h=!1)}}return h}},tt=class extends M{constructor(n={}){super();this._object=n}validate(n){if(this._optional&&n===void 0)return!0;if(zt(n)!=="object")return this.fail({expect:"object",actual:n});let i=n,l=!0;for(let d in this._object){let h=i[d],b=this._object[d];if(b.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(d)?b.path=`${this.path}.${d}`:b.path=`${this.path}["${d}"]`,!(b._optional&&h===void 0)){if(h===void 0&&b.hasDefault){i[d]=b.defaultValue;continue}b.validate(h)||(b.hasFallback?i[d]=b.fallbackValue:l=!1)}}return l}},rt=class extends M{constructor(n){super();this.value=n}validate(n){return n===void 0&&this._optional?!0:n!==this.value?this.fail({expect:Wt(this.value),actual:n}):!0}},nt=class extends M{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let n=[],i=!1,l=this._items.length;for(let d=0;d<l;d++){let h=this._items[d];if(h.errors=[],h.path=this.path,!h.validate(t))n.push(h.errors.join("; "));else if(!i){i=!0;break}}if(!i){let d=n.join(`
2
2
  or `);this.errors.push(d)}return i}},ot=class extends M{constructor(...t){super(),this._items=t;let n=0,i=t.length-1;for(;i>=0;i--){let l=t[i];if(l._optional||l.hasDefault)n+=1;else break}this._minItems=t.length-n}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 n=!0;return this._items.forEach((i,l)=>{if(i.path=`${this.path}[${l}]`,i.errors=this.errors,t[l]===void 0&&i.hasDefault){t[l]=i.defaultValue;return}i.validate(t[l])||(i.hasFallback?t[l]=i._fallback:n=!1)}),n}},it=class extends M{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},st=class extends M{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})}};var S={object(e){return new tt(e)},array(e){return new Ze(e)},tuple(...e){return new ot(...e)},literal(e){return new rt(e)},or(...e){return new nt(...e)},symbol(){return new ze},record(e){return new et(e)},function(){return new Qe},boolean(){return new He},string(){return new We},number(){return new Ge},undefined(){return new Ye},null(){return new qe},unknown(){return new ye},any(){return new ye},as(){return new ye},arraybuffer(){return new it},enum(...e){return new Xe(...e)},typedarray(e){return new st(e)}};function Yt(e,t,n="param"){if(e.errors=[],e.path=n,Ht(!0),!e.validate(t)){let i=e.errors.join(`
3
- `);throw e.errors.length=0,Ht(!1),new TypeError(i)}}var at=1,qr=e=>{function t(i,l){return(...d)=>{let m=Date.now(),b={method:i,trace_id:at};at+=1;let _="SUCCESS",A=`${i}:ok`,I=0;try{if(l.paramsSchema)try{Yt(l.paramsSchema,d,"params")}catch(C){throw jt(`${i}:fail ${C.message}`)}let x=l.implement(...d),h=x,T=`${i}:ok`;if(x&&"code"in x){let{code:C,data:N,message:K}=x;_=C,h=N,T=K}return{code:_,message:T,data:h}}catch(x){let h=x;I=h.code??h.errNo??2e3,_="FAILURE";let T=h.message??h.errMsg??`${x}`;return A=`${i}:${_} ${T.replace(/^\S+:(fail|cancel)\s?/,"")}`,ee(new Be(A,I)),{code:_,message:A}}finally{let x=Date.now()-m;e("apiInvoked",{...b,duration:x,status:_})}}}function n(i,l){return async(...d)=>{let m=kr(d)?d:[d],b=Date.now(),_={method:i,trace_id:at};at+=1;let A=`${i}:ok`,I="SUCCESS",x={code:I,message:A};try{if(l.paramsSchema)try{Yt(l.paramsSchema,m,"params")}catch(C){throw jt(C.message)}let T=await l.implement(...m);if(T&&"code"in T){let{code:C,data:N,message:K}=T;I=C,A=K,T=N}return Object.assign(x,{code:I,message:A,data:T}),x}catch(h){let T=h,C=T.code??T.errNo??2e3;I="FAILURE";let N=T.message??T.errMsg??`${h}`,K=`${i}:${I} ${N.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(x,{code:I,message:K}),ee(new Be(K,C)),x}finally{let h=Date.now()-b;e("apiInvoked",{..._,duration:h,status:I})}}}return{createAPI:n,createSyncAPI:t}};var{createAPI:Z,createSyncAPI:fe}=qr(G),j=zr("h5");var Qr=X(),Zo="env",ei="getSystemInfoSync",ti=()=>{let e={system:R.deviceInfo.system,platform:R.deviceInfo.platform,brand:R.deviceInfo.brand,pixelRatio:R.deviceInfo.pixelRatio,language:R.deviceInfo.lang,version:R.sdkInfo.jssdkVersion,appName:R.hostInfo?.appName,SDKVersion:R.sdkInfo.nativeSDKVersion},t=R.hostInfo?.version;t&&(e={...e,version:t});let n=R.hostInfo?.appName;n&&(e={...e,appName:n});let i=R.sdkInfo?.jssdkVersion;return i&&(e={...e,SDKVersion:i}),e},ri=fe(ei,{implement:ti}),ni=fe(Zo,{implement:()=>({...R.hostInfo,sdkInfo:R.sdkInfo,platform:R.platform,deviceInfo:R.deviceInfo})});Qr.registerCommand("API.env",ni);Qr.registerCommand("API.getSystemInfoSync",ri);j("env",{version:"1.0.0"});j("getSystemInfoSync",{version:"1.0.0"});var oi="onJoliboxShow",ii="onJoliboxHide",si="onReady",Qt=X(),Xt=Nr(ee),qt=!0,ke=!0,ct=0,lt=Gt;function ai(){let e=Date.now();if(e-ct<100)return;ct=e;let t=document.visibilityState==="visible";t!==qt&&(qt=t,lt.emit("visible",qt))}function Xr(e){let t=Date.now();t-ct<100||(ct=t,e==="focus"&&!ke?ke=!0:e==="blur"&&ke&&(ke=!1),lt.emit("visible",ke))}document.addEventListener("visibilitychange",ai);window.addEventListener("focus",()=>Xr("focus"));window.addEventListener("blur",()=>Xr("blur"));var ci=fe(oi,{paramsSchema:S.tuple(S.function()),implement(e){let t=Xt(e);lt.on("visible",n=>{n&&t()})}}),li=fe(ii,{paramsSchema:S.tuple(S.function()),implement(e){let t=Xt(e);lt.on("visible",n=>{!n&&t()})}}),ui=fe(si,{paramsSchema:S.tuple(S.function()),implement(e){let t=Xt(e);xe.on("LifecycleEvent.onReady",n=>{t(n)})}});Qt.registerCommand("LifecycleSDK.onReady",ui);Qt.registerCommand("LifecycleSDK.onJoliboxShow",ci);Qt.registerCommand("LifecycleSDK.onJoliboxHide",li);j("lifeCycle.onReady",{version:"1.0.0"});j("lifeCycle.onJoliboxShow",{version:"1.0.0"});j("lifeCycle.onJoliboxHide",{version:"1.0.0"});var tn=fo(en()),ut=X(),er=class{constructor(){this.getGameId=()=>R.mpId;this.getItem=async t=>{let{code:n,data:i,message:l}=await this.httpClient.get(`/api/games/user-storage/${this.gameId}`,{query:{key:t}}),d=i?.value,m=l;return n!=="SUCCESS"&&(d=await this.gameStore.getItem(t),console.info("[SDK] cloud storage getItem failed, read from localstorage",d),m+="fallback to localstorage"),{code:n,message:m,data:d&&d!=="undefined"?d:null}};this.setItem=async(t,n)=>{let i=typeof n=="string"?n:String(n),{code:l,message:d}=await this.httpClient.post(`/api/games/user-storage/${this.gameId}`,{data:{key:t,value:i}});return await this.gameStore.setItem(t,i),{code:l,message:d}};this.removeItem=async t=>{await this.gameStore.removeItem(t);let{code:n,message:i}=await this.httpClient.post(`/api/games/user-storage/${this.gameId}/remove`,{data:{key:t}});return{code:n,message:i}};this.clear=async()=>{await this.gameStore.clear();let{code:t,message:n}=await this.httpClient.post(`/api/games/user-storage/${this.gameId}/clear`,{});return{code:t,message:n}};this.gameId=this.getGameId(),this.httpClient=new le({baseUrl:R.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com"}),this.gameStore=tn.default.createInstance({name:this.gameId.length?this.gameId:"default"})}},dt=new er,di=Z("getLocalStorage",{paramsSchema:S.tuple(S.string()),async implement(e){return await dt.getItem(e)}});ut.registerCommand("StorageSDK.getItem",di);j("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var fi=Z("setStorage",{paramsSchema:S.tuple(S.string(),S.or(S.string(),S.boolean(),S.number())),async implement(e,t){return await dt.setItem(e,t)}});ut.registerCommand("StorageSDK.setItem",fi);j("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var mi=Z("removeStorage",{paramsSchema:S.tuple(S.string()),async implement(e){return await dt.removeItem(e)}});ut.registerCommand("StorageSDK.removeItem",mi);j("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var hi=Z("clearStorage",{async implement(){return await dt.clear()}});ut.registerCommand("StorageSDK.clear",hi);j("storage.clear",{version:"1.0.0"});var be=X(),pi=Z("levelFinished",{paramsSchema:S.tuple(S.string(),S.object({result:S.boolean(),duration:S.number()})),implement:async(e,t)=>{let{result:n,duration:i}=t;W.info("onLevelFinished",n,i),await Promise.all([re.reporter({event:"COMPLETE_GAME_LEVEL"}),re.tracker("LevelFinished",{levelId:e,result:n,duration:i})])}}),gi=Z("taskFinished",{paramsSchema:S.tuple(S.string(),S.object({duration:S.number()})),implement:async(e,t)=>{let{duration:n}=t;await re.tracker("TaskFinished",{duration:n,taskId:e})}}),vi=Z("levelUpgrade",{paramsSchema:S.tuple(S.string(),S.string()),implement:async(e,t)=>await re.tracker("LevelUpgrade",{name:t,levelId:e})}),yi=Z("onHistoryUserLevel",{paramsSchema:S.tuple(S.number()),implement:async e=>await re.tracker("HistoryUserLevel",{level:e})}),bi=Z("onHistoryUserScore",{paramsSchema:S.tuple(S.number()),implement:async e=>await re.tracker("HistoryUserScore",{score:e})}),_i=Z("taskEvent",{paramsSchema:S.tuple(S.string(),S.object({tools:S.array(S.object({id:S.string(),name:S.string(),count:S.number(),description:S.string().optional(),price:S.object({amount:S.number(),unit:S.string()}).optional()})).optional(),awards:S.array(S.object({id:S.string(),name:S.string()})).optional()})),implement:async(e,t)=>{t.tools?.length&&await Promise.all([re.reporter({event:"USE_GAME_ITEM"}),re.tracker("UseGameItem",{taskId:e,...t})])}});be.registerCommand("TaskTrackerSDK.levelFinished",pi);be.registerCommand("TaskTrackerSDK.taskFinished",gi);be.registerCommand("TaskTrackerSDK.levelUpgrade",vi);be.registerCommand("TaskTrackerSDK.historyUserLevel",yi);be.registerCommand("TaskTrackerSDK.historyUserScore",bi);be.registerCommand("TaskTrackerSDK.taskEvent",_i);j("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});j("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});j("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});j("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});j("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});j("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 ft=class{constructor(){this.adBreakIsShowing=!1;this.reportPageJumpOut=()=>{G("AdBreakJumpOut",{context:"AdsActionDetection"})};this.reportPageHide=()=>{G("AdBreakHide",{context:"AdsActionDetection"})};window.addEventListener("visibilitychange",()=>{document.hidden&&this.adBreakIsShowing&&this.reportPageHide()}),window.addEventListener("beforeunload",t=>{this.adBreakIsShowing&&this.reportPageJumpOut()})}};var rn="jolibox-sdk-ads-callbreak-timestamps",mt=class{constructor(t){this.maxAllowedAdsForTime=8;this.bannedForTimeThreshold=6e4;this.bannedReleaseTime=6e4;this.isBanningForTime=!1;this.releaseBannedForTimeTimeout=null;this.maxAllowedAdsForSession=200;this.bannedForSessionThreshold=6e5;this.isBanningForSession=!1;this.initialThreshold=2e3;this._callAdsTimestampsForTime=[];this.callAdsTimestampsForSession=[];this.initTimestamp=0;this.report=ve;this.initCallAdsTimestampsForTime=()=>{try{let t=JSON.parse(window.localStorage.getItem(rn)??"[]");Array.isArray(t)?this._callAdsTimestampsForTime=t:this._callAdsTimestampsForTime=[]}catch{this._callAdsTimestampsForTime=[]}};this.setReleaseBannedForTime=()=>{this.releaseBannedForTimeTimeout&&(window.clearTimeout(this.releaseBannedForTimeTimeout),this.releaseBannedForTimeTimeout=null),this.releaseBannedForTimeTimeout=window.setTimeout(()=>{this.isBanningForTime=!1,this.releaseBannedForTimeTimeout=null},this.bannedReleaseTime)};this.checkShouldBannedInitial=()=>{if(Date.now()-this.initTimestamp<=this.initialThreshold)return"BLOCK_INITIAL"};this.checkShouldBannedForSession=t=>{if(this.isBanningForSession)return"BANNED_FOR_SESSION";let n=Date.now();if(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.concat({timestamp:n,type:t}),this.callAdsTimestampsForSession.length!==1&&(this.callAdsTimestampsForSession.length>this.maxAllowedAdsForSession&&(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.slice(-this.maxAllowedAdsForSession)),this.callAdsTimestampsForSession.length===this.maxAllowedAdsForSession&&n-this.callAdsTimestampsForSession[0].timestamp<=this.bannedForSessionThreshold))return this.isBanningForSession=!0,"BANNED_FOR_SESSION"};this.checkShouldBannedForTime=t=>{if(this.isBanningForTime)return"WAITING_BANNED_RELEASE";let n=Date.now();if(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.concat({timestamp:n,type:t}),this.callAdsTimestampsForTime.length!==1&&(this.callAdsTimestampsForTime.length>this.maxAllowedAdsForTime&&(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.slice(-this.maxAllowedAdsForTime)),this.callAdsTimestampsForTime.length===this.maxAllowedAdsForTime&&n-this.callAdsTimestampsForTime[0].timestamp<=this.bannedForTimeThreshold))return this.isBanningForTime=!0,this.setReleaseBannedForTime(),"BANNED_FOR_TIME"};this.checkAdsDisplayPermission=t=>{if(!this.report.networkIsOk)return"NETWORK_NOT_OK";let n=this.checkShouldBannedInitial();if(n)return n;let i=this.checkShouldBannedForSession(t);if(i)return i;let l=this.checkShouldBannedForTime(t);return l||"ALLOWED"};if(this.maxAllowedAdsForTime=t?.maxAllowedAdsForTime??8,this.bannedForTimeThreshold=t?.bannedForTimeThreshold??6e4,this.bannedReleaseTime=t?.bannedReleaseTime??6e4,this.maxAllowedAdsForSession=t?.maxAllowedAdsForSession??200,this.bannedForSessionThreshold=t?.bannedForSessionThreshold??6e5,this.initialThreshold=t?.initialThreshold??2e3,this.maxAllowedAdsForTime<=1)throw new Error("maxAllowedAdsForTime must be greater than 1");if(this.bannedForTimeThreshold<0)throw new Error("bannedForTimeThreshold must be greater than or equal to 0");if(this.bannedReleaseTime<this.bannedForTimeThreshold)throw new Error("bannedReleaseTime must be greater than or equal to bannedForTimeThreshold");if(this.initialThreshold<0)throw new Error("initialThreshold must be greater than or equal to 0");this.initCallAdsTimestampsForTime(),this.initTimestamp=Date.now()}get callAdsTimestampsForTime(){return this._callAdsTimestampsForTime}set callAdsTimestampsForTime(t){try{window.localStorage.setItem(rn,JSON.stringify(t))}catch{console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=t}};var ht=X(),tr=class{constructor(){this.configured=!1;this.config={};this.httpClient=new le;this.getGameId=()=>new URLSearchParams(window.location.search).get("gameId")??this.config.gameId;this.getTestAdsMode=()=>new URLSearchParams(window.location.search).get("testAdsMode")==="true";this.asyncLoad=async()=>{let t="ca-pub-7171363994453626",n,i,l=window.encodeURIComponent(window.btoa(this.getGameId()??"")),d=this.getTestAdsMode()??!1;try{let m=await this.httpClient.get("/public/ads",{query:{objectId:l,testAdsMode:`${d}`}});t=m.data?.clientId,n=m.data?.channelId,i=m.data?.unitId}catch(m){console.error("Failed to fetch client info",m)}this.clientId=t,this.channelId=n,this.unitId=i};this.asyncInit=async t=>{if(typeof window>"u")return;await this.asyncLoad();let n="google-adsense",i=this.getTestAdsMode()??!1;if(!document.getElementById(n)&&this.clientId){let l=document.createElement("script");l.id=n,l.async=!0,l.crossOrigin="anonymous",l.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`,i&&l.setAttribute("data-adbreak-test","on"),this.channelId&&l.setAttribute("data-ad-channel",this.channelId),document.head.appendChild(l),G("LoadAdsenseCompleted",null)}};this.push=(t={})=>{window.adsbygoogle.push(t)};this.adConfig=t=>{let{onReady:n,...i}=t;G("CallAdConfig",i),this.configured?console.warn("Ad config already set, skipping"):(this.configured=!0,this.push(t))};this.adBreak=t=>{if(!this.getGameId()){console.warn("Game ID is not set, skip calling adBreak");return}let n=this.antiCheating.checkAdsDisplayPermission(t.type==="reward"?"reward":"interstitial");switch(n){case"NETWORK_NOT_OK":case"BANNED_FOR_SESSION":console.warn("Ads not allowed",n),t.adBreakDone?.({breakType:t.type,breakName:n,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"}),G("PreventAdsCheating",{reason:n});return;case"BLOCK_INITIAL":case"BANNED_FOR_TIME":case"WAITING_BANNED_RELEASE":console.warn("Ads not allowed",n),t.adBreakDone?.({breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"viewed"}),G("PreventAdsCheating",{reason:n});return;default:break}let i=t.type,l=t.adBreakDone,d=b=>{this.adsActionDetection.adBreakIsShowing=!1,G("CallAdBreakDone",{breakType:b.breakType,breakName:b.breakName??"",breakFormat:b.breakFormat,breakStatus:b.breakStatus}),l&&l(b)};if(t.adBreakDone=d,t.type==="reward"){let b=t.beforeReward,_=I=>()=>{G("CallShowAdFn",null),I()},A=I=>{b&&b(_(I))};t.beforeReward=A}let m;switch(i){case"preroll":m={type:i};break;case"start":case"pause":case"next":case"browse":case"reward":m={type:i,name:t.name??""};break}this.adsActionDetection.adBreakIsShowing=!0,G("CallAdBreak",m),this.push(t),window.JoliTesterBridge&&console.log("joli-fullscreen-ad-show")};this.adUnit=async t=>{if(G("CallAdUnit",{adFormat:t.adFormat?.toString()??null,fullWidthResponsive:t.fullWidthResponsive??null}),this.clientId||await this.asyncLoad(),document.querySelector("#jolibox-ads")){console.warn("Ad unit already set, skipping");return}let{el:n,slot:i,adFormat:l,fullWidthResponsive:d,style:m}=t,b;if(!n)throw new Error("targeting element is required");if(typeof n=="string"?b=document.querySelector(n):b=n,!b)throw new Error("targeting element not found");let _=i;if(_||(_=this.unitId),!_)throw new Error("slot is required");let A=typeof l=="object"&&Array.isArray(l)?l.join(", "):l,I=document.createElement("ins");if(I.className="adsbygoogle",I.id="jolibox-ads",I.style.display="block",I.setAttribute("data-ad-client",this.clientId),I.setAttribute("data-ad-slot",_),A&&I.setAttribute("data-ad-format",A),d&&I.setAttribute("data-full-width-responsive",d),m&&I.setAttribute("style",m),this.getTestAdsMode()??!1){let h=document.createElement("div");h.style.position="absolute",h.style.top="0",h.style.left="0",h.style.width="100%",h.style.height="100%",h.style.display="flex",h.style.justifyContent="center",h.style.alignItems="center",h.style.backgroundColor="rgba(0, 0, 0, 0.5)",h.style.color="white",h.innerHTML="Test Ad",I.style.position="relative",b.appendChild(I),I.appendChild(h)}else b.appendChild(I),new MutationObserver(T=>{T.forEach(C=>{if(C.type==="attributes"&&C.attributeName==="data-ad-status"){let N=I.getAttribute("data-ad-status");G("AdSenseUnitStatusChanged",{status:N??"null"})}})}).observe(I,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})};this.antiCheating=new mt,this.adsActionDetection=new ft}init(t){G("CallAdsInit",null),!(typeof window>"u")&&(this.config=t??{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}};var pt=new tr;ht.registerCommand("AdsSDK.init",e=>{pt.init(e)});ht.registerCommand("AdsSDK.adConfig",e=>{pt.adConfig(e)});ht.registerCommand("AdsSDK.adBreak",e=>{pt.adBreak(e)});ht.registerCommand("AdsSDK.adUnit",e=>{pt.adUnit(e)});function Ei(){xe.on("onDocumentReady",e=>{xe.emit("LifecycleEvent.onReady",{isLogin:!1}),re.start(Date.now()-e)})}function nn(){Ei()}nn();
3
+ `);throw e.errors.length=0,Ht(!1),new TypeError(i)}}var at=1,qr=e=>{function t(i,l){return(...d)=>{let h=Date.now(),b={method:i,trace_id:at};at+=1;let E="SUCCESS",A=`${i}:ok`,I=0;try{if(l.paramsSchema)try{Yt(l.paramsSchema,d,"params")}catch(P){throw jt(`${i}:fail ${P.message}`)}let x=l.implement(...d),m=x,_=`${i}:ok`;if(x&&"code"in x){let{code:P,data:N,message:K}=x;E=P,m=N,_=K}return{code:E,message:_,data:m}}catch(x){let m=x;I=m.code??m.errNo??2e3,E="FAILURE";let _=m.message??m.errMsg??`${x}`;return A=`${i}:${E} ${_.replace(/^\S+:(fail|cancel)\s?/,"")}`,ee(new Be(A,I)),{code:E,message:A}}finally{let x=Date.now()-h;e("apiInvoked",{...b,duration:x,status:E})}}}function n(i,l){return async(...d)=>{let h=kr(d)?d:[d],b=Date.now(),E={method:i,trace_id:at};at+=1;let A=`${i}:ok`,I="SUCCESS",x={code:I,message:A};try{if(l.paramsSchema)try{Yt(l.paramsSchema,h,"params")}catch(P){throw jt(P.message)}let _=await l.implement(...h);if(_&&"code"in _){let{code:P,data:N,message:K}=_;I=P,A=K,_=N}return Object.assign(x,{code:I,message:A,data:_}),x}catch(m){let _=m,P=_.code??_.errNo??2e3;I="FAILURE";let N=_.message??_.errMsg??`${m}`,K=`${i}:${I} ${N.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(x,{code:I,message:K}),ee(new Be(K,P)),x}finally{let m=Date.now()-b;e("apiInvoked",{...E,duration:m,status:I})}}}return{createAPI:n,createSyncAPI:t}};var{createAPI:Z,createSyncAPI:fe}=qr(G),j=zr("h5");var Qr=X(),Zo="env",ei="getSystemInfoSync",ti=()=>{let e={system:R.deviceInfo.system,platform:R.deviceInfo.platform,brand:R.deviceInfo.brand,pixelRatio:R.deviceInfo.pixelRatio,language:R.deviceInfo.lang,version:R.sdkInfo.jssdkVersion,appName:R.hostInfo?.appName,SDKVersion:R.sdkInfo.nativeSDKVersion},t=R.hostInfo?.version;t&&(e={...e,version:t});let n=R.hostInfo?.appName;n&&(e={...e,appName:n});let i=R.sdkInfo?.jssdkVersion;return i&&(e={...e,SDKVersion:i}),e},ri=fe(ei,{implement:ti}),ni=fe(Zo,{implement:()=>({...R.hostInfo,sdkInfo:R.sdkInfo,platform:R.platform,deviceInfo:R.deviceInfo})});Qr.registerCommand("API.env",ni);Qr.registerCommand("API.getSystemInfoSync",ri);j("env",{version:"1.0.0"});j("getSystemInfoSync",{version:"1.0.0"});var oi="onJoliboxShow",ii="onJoliboxHide",si="onReady",Qt=X(),Xt=Nr(ee),qt=!0,ke=!0,ct=0,lt=Gt;function ai(){let e=Date.now();if(e-ct<100)return;ct=e;let t=document.visibilityState==="visible";t!==qt&&(qt=t,lt.emit("visible",qt))}function Xr(e){let t=Date.now();t-ct<100||(ct=t,e==="focus"&&!ke?ke=!0:e==="blur"&&ke&&(ke=!1),lt.emit("visible",ke))}document.addEventListener("visibilitychange",ai);window.addEventListener("focus",()=>Xr("focus"));window.addEventListener("blur",()=>Xr("blur"));var ci=fe(oi,{paramsSchema:S.tuple(S.function()),implement(e){let t=Xt(e);lt.on("visible",n=>{n&&t()})}}),li=fe(ii,{paramsSchema:S.tuple(S.function()),implement(e){let t=Xt(e);lt.on("visible",n=>{!n&&t()})}}),ui=fe(si,{paramsSchema:S.tuple(S.function()),implement(e){let t=Xt(e);xe.on("LifecycleEvent.onReady",n=>{t(n)})}});Qt.registerCommand("LifecycleSDK.onReady",ui);Qt.registerCommand("LifecycleSDK.onJoliboxShow",ci);Qt.registerCommand("LifecycleSDK.onJoliboxHide",li);j("lifeCycle.onReady",{version:"1.0.0"});j("lifeCycle.onJoliboxShow",{version:"1.0.0"});j("lifeCycle.onJoliboxHide",{version:"1.0.0"});var tn=fo(en()),ut=X(),er=class{constructor(){this.getGameId=()=>R.mpId;this.getItem=async t=>{let{code:n,data:i,message:l}=await this.httpClient.get(`/api/games/user-storage/${this.gameId}`,{query:{key:t}}),d=i?.value,h=l;return n!=="SUCCESS"&&(d=await this.gameStore.getItem(t),console.info("[SDK] cloud storage getItem failed, read from localstorage",d),h+="fallback to localstorage"),{code:n,message:h,data:d&&d!=="undefined"?d:null}};this.setItem=async(t,n)=>{let i=typeof n=="string"?n:String(n),{code:l,message:d}=await this.httpClient.post(`/api/games/user-storage/${this.gameId}`,{data:{key:t,value:i}});return await this.gameStore.setItem(t,i),{code:l,message:d}};this.removeItem=async t=>{await this.gameStore.removeItem(t);let{code:n,message:i}=await this.httpClient.post(`/api/games/user-storage/${this.gameId}/remove`,{data:{key:t}});return{code:n,message:i}};this.clear=async()=>{await this.gameStore.clear();let{code:t,message:n}=await this.httpClient.post(`/api/games/user-storage/${this.gameId}/clear`,{});return{code:t,message:n}};this.gameId=this.getGameId(),this.httpClient=new le({baseUrl:R.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com"}),this.gameStore=tn.default.createInstance({name:this.gameId.length?this.gameId:"default"})}},dt=new er,di=Z("getLocalStorage",{paramsSchema:S.tuple(S.string()),async implement(e){return await dt.getItem(e)}});ut.registerCommand("StorageSDK.getItem",di);j("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var fi=Z("setStorage",{paramsSchema:S.tuple(S.string(),S.or(S.string(),S.boolean(),S.number())),async implement(e,t){return await dt.setItem(e,t)}});ut.registerCommand("StorageSDK.setItem",fi);j("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var mi=Z("removeStorage",{paramsSchema:S.tuple(S.string()),async implement(e){return await dt.removeItem(e)}});ut.registerCommand("StorageSDK.removeItem",mi);j("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var hi=Z("clearStorage",{async implement(){return await dt.clear()}});ut.registerCommand("StorageSDK.clear",hi);j("storage.clear",{version:"1.0.0"});var be=X(),pi=Z("levelFinished",{paramsSchema:S.tuple(S.string(),S.object({result:S.boolean(),duration:S.number()})),implement:async(e,t)=>{let{result:n,duration:i}=t;W.info("onLevelFinished",n,i),await Promise.all([re.reporter({event:"COMPLETE_GAME_LEVEL"}),re.tracker("LevelFinished",{levelId:e,result:n,duration:i})])}}),gi=Z("taskFinished",{paramsSchema:S.tuple(S.string(),S.object({duration:S.number()})),implement:async(e,t)=>{let{duration:n}=t;await re.tracker("TaskFinished",{duration:n,taskId:e})}}),vi=Z("levelUpgrade",{paramsSchema:S.tuple(S.string(),S.string()),implement:async(e,t)=>await re.tracker("LevelUpgrade",{name:t,levelId:e})}),yi=Z("onHistoryUserLevel",{paramsSchema:S.tuple(S.number()),implement:async e=>await re.tracker("HistoryUserLevel",{level:e})}),bi=Z("onHistoryUserScore",{paramsSchema:S.tuple(S.number()),implement:async e=>await re.tracker("HistoryUserScore",{score:e})}),_i=Z("taskEvent",{paramsSchema:S.tuple(S.string(),S.object({tools:S.array(S.object({id:S.string(),name:S.string(),count:S.number(),description:S.string().optional(),price:S.object({amount:S.number(),unit:S.string()}).optional()})).optional(),awards:S.array(S.object({id:S.string(),name:S.string()})).optional()})),implement:async(e,t)=>{t.tools?.length&&await Promise.all([re.reporter({event:"USE_GAME_ITEM"}),re.tracker("UseGameItem",{taskId:e,...t})])}});be.registerCommand("TaskTrackerSDK.levelFinished",pi);be.registerCommand("TaskTrackerSDK.taskFinished",gi);be.registerCommand("TaskTrackerSDK.levelUpgrade",vi);be.registerCommand("TaskTrackerSDK.historyUserLevel",yi);be.registerCommand("TaskTrackerSDK.historyUserScore",bi);be.registerCommand("TaskTrackerSDK.taskEvent",_i);j("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});j("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});j("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});j("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});j("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});j("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 ft=class{constructor(){this.adBreakIsShowing=!1;this.reportPageJumpOut=()=>{G("AdBreakJumpOut",{context:"AdsActionDetection"})};this.reportPageHide=()=>{G("AdBreakHide",{context:"AdsActionDetection"})};window.addEventListener("visibilitychange",()=>{document.hidden&&this.adBreakIsShowing&&this.reportPageHide()}),window.addEventListener("beforeunload",t=>{this.adBreakIsShowing&&this.reportPageJumpOut()})}};var rn="jolibox-sdk-ads-callbreak-timestamps",mt=class{constructor(t){this.maxAllowedAdsForTime=8;this.bannedForTimeThreshold=6e4;this.bannedReleaseTime=6e4;this.isBanningForTime=!1;this.releaseBannedForTimeTimeout=null;this.maxAllowedAdsForSession=200;this.bannedForSessionThreshold=6e5;this.isBanningForSession=!1;this.initialThreshold=2e3;this._callAdsTimestampsForTime=[];this.callAdsTimestampsForSession=[];this.initTimestamp=0;this.report=ve;this.initCallAdsTimestampsForTime=()=>{try{let t=JSON.parse(window.localStorage.getItem(rn)??"[]");Array.isArray(t)?this._callAdsTimestampsForTime=t:this._callAdsTimestampsForTime=[]}catch{this._callAdsTimestampsForTime=[]}};this.setReleaseBannedForTime=()=>{this.releaseBannedForTimeTimeout&&(window.clearTimeout(this.releaseBannedForTimeTimeout),this.releaseBannedForTimeTimeout=null),this.releaseBannedForTimeTimeout=window.setTimeout(()=>{this.isBanningForTime=!1,this.releaseBannedForTimeTimeout=null},this.bannedReleaseTime)};this.checkShouldBannedInitial=()=>{if(Date.now()-this.initTimestamp<=this.initialThreshold)return"BLOCK_INITIAL"};this.checkShouldBannedForSession=t=>{if(this.isBanningForSession)return"BANNED_FOR_SESSION";let n=Date.now();if(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.concat({timestamp:n,type:t}),this.callAdsTimestampsForSession.length!==1&&(this.callAdsTimestampsForSession.length>this.maxAllowedAdsForSession&&(this.callAdsTimestampsForSession=this.callAdsTimestampsForSession.slice(-this.maxAllowedAdsForSession)),this.callAdsTimestampsForSession.length===this.maxAllowedAdsForSession&&n-this.callAdsTimestampsForSession[0].timestamp<=this.bannedForSessionThreshold))return this.isBanningForSession=!0,"BANNED_FOR_SESSION"};this.checkShouldBannedForTime=t=>{if(this.isBanningForTime)return"WAITING_BANNED_RELEASE";let n=Date.now();if(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.concat({timestamp:n,type:t}),this.callAdsTimestampsForTime.length!==1&&(this.callAdsTimestampsForTime.length>this.maxAllowedAdsForTime&&(this.callAdsTimestampsForTime=this.callAdsTimestampsForTime.slice(-this.maxAllowedAdsForTime)),this.callAdsTimestampsForTime.length===this.maxAllowedAdsForTime&&n-this.callAdsTimestampsForTime[0].timestamp<=this.bannedForTimeThreshold))return this.isBanningForTime=!0,this.setReleaseBannedForTime(),"BANNED_FOR_TIME"};this.checkAdsDisplayPermission=t=>{if(!this.report.networkIsOk)return"NETWORK_NOT_OK";let n=this.checkShouldBannedInitial();if(n)return n;let i=this.checkShouldBannedForSession(t);if(i)return i;let l=this.checkShouldBannedForTime(t);return l||"ALLOWED"};if(this.maxAllowedAdsForTime=t?.maxAllowedAdsForTime??8,this.bannedForTimeThreshold=t?.bannedForTimeThreshold??6e4,this.bannedReleaseTime=t?.bannedReleaseTime??6e4,this.maxAllowedAdsForSession=t?.maxAllowedAdsForSession??200,this.bannedForSessionThreshold=t?.bannedForSessionThreshold??6e5,this.initialThreshold=t?.initialThreshold??2e3,this.maxAllowedAdsForTime<=1)throw new Error("maxAllowedAdsForTime must be greater than 1");if(this.bannedForTimeThreshold<0)throw new Error("bannedForTimeThreshold must be greater than or equal to 0");if(this.bannedReleaseTime<this.bannedForTimeThreshold)throw new Error("bannedReleaseTime must be greater than or equal to bannedForTimeThreshold");if(this.initialThreshold<0)throw new Error("initialThreshold must be greater than or equal to 0");this.initCallAdsTimestampsForTime(),this.initTimestamp=Date.now()}get callAdsTimestampsForTime(){return this._callAdsTimestampsForTime}set callAdsTimestampsForTime(t){try{window.localStorage.setItem(rn,JSON.stringify(t))}catch{console.error("Failed to save timestamps")}this._callAdsTimestampsForTime=t}};var ht=X(),tr=class{constructor(){this.configured=!1;this.config={};this.httpClient=new le;this.getGameId=()=>new URLSearchParams(window.location.search).get("gameId")??this.config.gameId;this.getTestAdsMode=()=>new URLSearchParams(window.location.search).get("testAdsMode")==="true";this.asyncLoad=async()=>{let t="ca-pub-7171363994453626",n,i,l=window.encodeURIComponent(window.btoa(this.getGameId()??"")),d=this.getTestAdsMode()??!1;try{let h=await this.httpClient.get("/public/ads",{query:{objectId:l,testAdsMode:`${d}`}});t=h.data?.clientId,n=h.data?.channelId,i=h.data?.unitId}catch(h){console.error("Failed to fetch client info",h)}this.clientId=t,this.channelId=n,this.unitId=i};this.asyncInit=async t=>{if(typeof window>"u")return;await this.asyncLoad();let n="google-adsense",i=this.getTestAdsMode()??!1;if(!document.getElementById(n)&&this.clientId){let l=document.createElement("script");l.id=n,l.async=!0,l.crossOrigin="anonymous",l.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`,i&&l.setAttribute("data-adbreak-test","on"),this.channelId&&l.setAttribute("data-ad-channel",this.channelId),document.head.appendChild(l),G("LoadAdsenseCompleted",null)}};this.push=(t={})=>{window.adsbygoogle.push(t)};this.adConfig=t=>{let{onReady:n,...i}=t;G("CallAdConfig",i),this.configured?console.warn("Ad config already set, skipping"):(this.configured=!0,this.push(t))};this.adBreak=t=>{if(!this.getGameId()){console.warn("Game ID is not set, skip calling adBreak");return}let n=this.antiCheating.checkAdsDisplayPermission(t.type==="reward"?"reward":"interstitial");switch(n){case"NETWORK_NOT_OK":case"BANNED_FOR_SESSION":console.warn("Ads not allowed",n),t.adBreakDone?.({breakType:t.type,breakName:n,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"}),G("PreventAdsCheating",{reason:n});return;case"BLOCK_INITIAL":case"BANNED_FOR_TIME":case"WAITING_BANNED_RELEASE":console.warn("Ads not allowed",n),t.adBreakDone?.({breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"viewed"}),G("PreventAdsCheating",{reason:n});return;default:break}let i=t.type,l=t.adBreakDone,d=b=>{this.adsActionDetection.adBreakIsShowing=!1,G("CallAdBreakDone",{breakType:b.breakType,breakName:b.breakName??"",breakFormat:b.breakFormat,breakStatus:b.breakStatus}),l&&l(b)};if(t.adBreakDone=d,t.type==="reward"){let b=t.beforeReward,E=I=>()=>{G("CallShowAdFn",null),I()},A=I=>{b&&b(E(I))};t.beforeReward=A}let h;switch(i){case"preroll":h={type:i};break;case"start":case"pause":case"next":case"browse":case"reward":h={type:i,name:t.name??""};break}this.adsActionDetection.adBreakIsShowing=!0,G("CallAdBreak",h),this.push(t),window.JoliTesterBridge&&console.log("joli-fullscreen-ad-show")};this.adUnit=async t=>{if(G("CallAdUnit",{adFormat:t.adFormat?.toString()??null,fullWidthResponsive:t.fullWidthResponsive??null}),this.clientId||await this.asyncLoad(),document.querySelector("#jolibox-ads")){console.warn("Ad unit already set, skipping");return}let{el:n,slot:i,adFormat:l,fullWidthResponsive:d,style:h}=t,b;if(!n)throw new Error("targeting element is required");if(typeof n=="string"?b=document.querySelector(n):b=n,!b)throw new Error("targeting element not found");let E=i;if(E||(E=this.unitId),!E)throw new Error("slot is required");let A=typeof l=="object"&&Array.isArray(l)?l.join(", "):l,I=document.createElement("ins");if(I.className="adsbygoogle",I.id="jolibox-ads",I.style.display="block",I.setAttribute("data-ad-client",this.clientId),I.setAttribute("data-ad-slot",E),A&&I.setAttribute("data-ad-format",A),d&&I.setAttribute("data-full-width-responsive",d),h&&I.setAttribute("style",h),this.getTestAdsMode()??!1){let m=document.createElement("div");m.style.position="absolute",m.style.top="0",m.style.left="0",m.style.width="100%",m.style.height="100%",m.style.display="flex",m.style.justifyContent="center",m.style.alignItems="center",m.style.backgroundColor="rgba(0, 0, 0, 0.5)",m.style.color="white",m.innerHTML="Test Ad",I.style.position="relative",b.appendChild(I),I.appendChild(m)}else b.appendChild(I),new MutationObserver(_=>{_.forEach(P=>{if(P.type==="attributes"&&P.attributeName==="data-ad-status"){let N=I.getAttribute("data-ad-status");G("AdSenseUnitStatusChanged",{status:N??"null"})}})}).observe(I,{attributes:!0,attributeFilter:["data-ad-status"]}),this.push({})};this.antiCheating=new mt,this.adsActionDetection=new ft}init(t){G("CallAdsInit",null),!(typeof window>"u")&&(this.config=t??{},window.adsbygoogle=window.adsbygoogle||[],this.asyncInit(t))}};var pt=new tr;ht.registerCommand("AdsSDK.init",e=>{pt.init(e)});ht.registerCommand("AdsSDK.adConfig",e=>{pt.adConfig(e)});ht.registerCommand("AdsSDK.adBreak",e=>{pt.adBreak(e)});ht.registerCommand("AdsSDK.adUnit",e=>{pt.adUnit(e)});function Ei(){xe.on("onDocumentReady",e=>{xe.emit("LifecycleEvent.onReady",{isLogin:!1}),re.start(Date.now()-e)})}function nn(){Ei()}nn();
4
4
  /*! Bundled license information:
5
5
 
6
6
  localforage/dist/localforage.js:
@@ -1,3 +1,3 @@
1
- var ln=Object.create;var Lt=Object.defineProperty;var mn=Object.getOwnPropertyDescriptor;var pn=Object.getOwnPropertyNames;var dn=Object.getPrototypeOf,fn=Object.prototype.hasOwnProperty;var f=(e,t)=>()=>(e&&(t=e(e=0)),t);var gn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var hn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pn(t))!fn.call(e,o)&&o!==r&&Lt(e,o,{get:()=>t[o],enumerable:!(n=mn(t,o))||n.enumerable});return e};var vn=(e,t,r)=>(r=e!=null?ln(dn(e)):{},hn(t||!e||!e.__esModule?Lt(r,"default",{value:e,enumerable:!0}):r,e));function yn(e){return!!e?.__nativeBuffers__}function le(e){if(typeof e=="string")try{e=JSON.parse(e)}catch{return{}}if(typeof e!="object"||e===null)return{};if(!yn(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=bn(n.base64)),typeof o<"u"&&o instanceof ArrayBuffer&&(e[n.key]=o)}}return e}function Ft(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:kn(s),key:o};n.push(i),delete r[o]}return n.length>0&&(r.__nativeBuffers__=n),r}var bn,kn,Ze=f(()=>{"use strict";bn=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};kn=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 _n(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Z(e){return typeof e=="string"}function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Vt(e){return typeof e=="object"&&Array.isArray(e)}function Sn(e){return typeof e>"u"}function Rn(e){return Sn(e)||e===null}function Kt(e){return typeof e=="function"}function Ht(e){return C(e)&&Kt(e.then)}function Bt(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}function qt(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],u=r(a,l,i,o,s);u!==void 0?o[i]=u:jt(l)&&jt(a)?o[i]=n({...a},l):Array.isArray(l)&&Array.isArray(a)?o[i]=[...a,...l]:o[i]=l}return o}return n(e,t)}function jt(e){return e&&typeof e=="object"&&e.constructor===Object}function Gt(e,t){if(Array.isArray(e))return e.concat(t)}function de(e,t,r={}){let n=null,o,s,i,{leading:a=!1,trailing:l=!0}=r,u=()=>(i=e.apply(s,o),o=void 0,s=void 0,i),m=function(...p){o=p,s=this;let d=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,l&&!d&&u()},t),d)return u()};return m.cancel=()=>{n&&clearTimeout(n),n=null,o=s=void 0},m.flush=()=>{if(n)return clearTimeout(n),n=null,u()},m}function wn(e,t){return(...r)=>t(e,...r)}function Ee(e){return t=>wn(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(o){e(new st(`${o}`))}})}function me(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}function Vn(e){return new Promise(t=>rr(e)(t))}function rr(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Kn(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new pe(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}function Bn(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)qn(e[n],t[n])}function qn(e,t){if(Z(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Kt(t)){try{if(e instanceof t)return}catch{}if(!Rn(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 R(){if(globalThis[tt])return globalThis[tt];let e=new be,t=new nt,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 Jt,En,Tn,$t,W,xn,ot,ee,In,st,zt,Wt,Yt,Qt,Xt,fe,ke,it,S,Zt,An,at,Pn,ct,Cn,Nn,he,On,Dn,Un,er,ut,Mn,Ln,Fn,tr,b,jn,Jn,ve,pe,Y,rt,$n,et,Hn,K,be,nt,tt,h=f(()=>{"use strict";Jt=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Tn=(e,t)=>{for(var r in t)Jt(e,r,{get:t[r],enumerable:!0})},$t=(e,t,r,n)=>{for(var o=n>1?void 0:n?En(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&&Jt(t,r,o),o};W=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))}})}};xn=(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))(xn||{}),ot=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}},ee=class extends ot{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},In=class extends ot{constructor(){super(...arguments),this.kind="USER_ERROR"}},st=class extends In{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))}},zt=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Wt=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},Yt=class extends ee{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},Qt=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Xt=class extends ee{constructor(e,t){super(e),this.message=e,this.name="INTERNAL_CONTEXT_ERROR",this.property=t}},fe=class extends ot{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}}},ke=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},it=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};S={log:me("log"),warn:me("warn"),info:me("info"),error:me("error"),debug:me("debug")};Object.assign(globalThis,{logger:S});Zt=Symbol.for("Jolibox.canIUseMap"),An={};globalThis[Zt]=An;at={get config(){return globalThis[Zt]}},Pn=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Pn||{}),ct=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ct||{}),Cn=(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))(Cn||{}),Nn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),he={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")},On=()=>he.isiOS?"iOS":he.isAndroid?"Android":he.isMac?"Mac":he.isFacebook?"Facebook":"PC",Dn="device_id",Un="advertising_id",er=e=>(localStorage.getItem(e)||localStorage.setItem(e,Nn()),localStorage.getItem(e)),ut=()=>er(Dn),Mn=()=>er(Un),Ln=e=>e.charAt(0).toUpperCase()+e.slice(1),Fn=()=>{let e=new URLSearchParams(window.location.search);return Ln(e.get("utm_source")??"")||"JoliboxSDK"},tr=e=>{let t="JoliboxWebSDK",r=On(),n=navigator.language,o=ut(),s=Mn();return`${t} (${Fn()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},b=class ye{static{this.Undefined=new ye(void 0)}constructor(t){this.element=t,this.next=ye.Undefined,this.prev=ye.Undefined}},jn=class{constructor(){this._first=b.Undefined,this._last=b.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===b.Undefined}clear(){let e=this._first;for(;e!==b.Undefined;){let t=e.next;e.prev=b.Undefined,e.next=b.Undefined,e=t}this._first=b.Undefined,this._last=b.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new b(e);if(this._first===b.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!==b.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==b.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==b.Undefined&&e.next!==b.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===b.Undefined&&e.next===b.Undefined?(this._first=b.Undefined,this._last=b.Undefined):e.next===b.Undefined?(this._last=this._last.prev,this._last.next=b.Undefined):e.prev===b.Undefined&&(this._first=this._first.next,this._first.prev=b.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==b.Undefined;)yield e.element,e=e.next}},Jn=0,ve=class{constructor(e){this.value=e,this.id=Jn++}},pe=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof ve&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(t=>t?.value===e)):(this._listeners=void 0,this._size=0)),this.options?.onDidRemoveLastListener?.())}get event(){return this._event??=(e,t)=>{if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};t&&(e=e.bind(t));let r=new ve(e);this._listeners?this._listeners instanceof ve?this._listeners=[this._listeners,r]:this._listeners.push(r):(this.options?.onWillAddFirstListener?.(this),this._listeners=r,this.options?.onDidFirstListener?.(this)),this.options?.onDidAddListener?.(this),this._size++},this._event}_deliver(e,t){if(!e)return;let r=this.options?.onListenerError||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(n){r(n)}}fire(e){this._listeners&&(this._listeners instanceof ve?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Y=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){let r=this.listeners.get(e)??new pe,n=s=>t(...s.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({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 jn,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},rt={};Tn(rt,{None:()=>$n,filter:()=>Kn,once:()=>rr,toPromise:()=>Vn});$n=()=>{console.log("[Jolibox SDK] None Event")};et=Symbol.for("Jolibox.hostEmitter"),Hn=()=>{let e=new Y;return globalThis[et]||(globalThis[et]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[et]},K=Hn();be=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new pe,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 Bn(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}};be=$t([Bt],be);nt=class{constructor(){this._onWillExecuteCommand=new pe,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new pe,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new be,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=_n(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),rt.toPromise(rt.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};nt=$t([Bt],nt);tt=Symbol.for("Jolibox.commands")});function I(e,t={}){lt.emit("ERROR_REPORT",{error:e,options:t})}var lt,te,U=f(()=>{"use strict";h();h();lt=new Y,te=new Y;I.debounce=de(I,50,{leading:!0})});function Te(e,t){return`[${e}]:${t}`}var re,mt,Q=f(()=>{"use strict";U();h();U();re=(e,t)=>new fe(t?.errMsg??e.msg??"",e.code,e.type),mt=e=>new st(e)});var nr,or,sr,ir=f(()=>{"use strict";nr=[],or=[],sr=["env","createRequestTask","login"]});function cr(e,t){ar||(pt=new ne({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),dt=new ne({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),ft=new ne({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(),dt.flush(),ft.flush()}),ar=!0);function r(o){let{method:s,args:i,startTime:a,isForeground:l,errMsg:u=`${s}:fail no errMsg`,errNo:m=0,__timing:p={receiveJSInvoke:0,invokeCallback:0}}=o,{receiveJSInvoke:d,invokeCallback:v}=p,_=u.match(/\S:(\S+)\s?/)?.[1]??"fail";pt.report({status:_,method:n(s,i),errNo:`${m}`,errMsg:u,isForeground:l,duration:Date.now()-a}),a&&d&&v&&(dt.report({status:_,method:s,isForeground:l,duration:Number((d-a).toFixed(3))}),ft.report({status:_,method:s,isForeground:l,duration:Number((Date.now()-v).toFixed(3))}))}function n(o,s){return(o==="callHostMethod"||o==="callHostMethodSync")&&s?.method?`${o}-${s.method}`:o}return r}var Gn,ne,ar,pt,dt,ft,gt=f(()=>{"use strict";h();Gn=e=>e==="pv"?e:"default",ne=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=Gn(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&&C(a))throw new ke(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(l){let u=[];if(C(a))u.push(...Object.keys(a));else if(Z(a)){if(s.length>0)throw new ke(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);u.push(a)}else throw new ke(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);u.forEach(m=>{o[m]||(o[m]={});let p=C(a)?a[m]:a;r(o[m],[...s],i,p)})}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={}}},ar=!1});function lr(e,t){let r=0,n=!0,o=new Map,s=cr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,ht.forEach(async({method:u,args:m,resolve:p})=>{let d=await a(u,m);p(d)}),ht.length=0});let i=(u,m)=>{S.info("----resolveId",u,m);let p=o.get(Number(u));if(!p)return;let d=le(m);p(d),o.delete(Number(u))},a=(u,m)=>{let p=Date.now(),d=`${n}`;r+=1;let v=new W;if(o.set(r,v.resolve),!n&&or.includes(u))return new Promise(P=>{ht.push({method:u,args:m,resolve:P})});let A={...{method:u,startTime:p,args:m,isForeground:d},invokeType:"js-bridge"},N=!zn&&nr.includes(u),G=Ft(m,N),z=N?G:JSON.stringify(G),k;if(u.endsWith("Sync")||sr.includes(u)?k=e.call?.(u,G,r):typeof z=="string"?(console.log("-----params",u,r),k=e.invoke(u,z,r)):k=e.call?.(u,z,r),k){try{typeof k=="string"&&(k=JSON.parse(k)),k=le(k)}catch(P){S.error(P)}return o.delete(r),k.errorCode&&(k.errorCode=Te(u,k.errorCode)),s({...A,...k}),k}return u.endsWith("Sync")&&o.delete(r),v.promise.then(P=>(P.errorCode&&(P.errorCode=Te(u,P.errorCode)),s({...A,...P}),P))};return{invokeNative:a,applyNative:(u,m)=>{let p=a(u,m);return Ht(p)?p.then(d=>ur(u,d)):ur(u,p)},invokeHandler:i}}function ur(e,t){if(!C(t)){S.warn(`[Jolibox SDK]${e} no response value`);return}let{errMsg:r,errNo:n,errorType:o,errorCode:s,...i}=t;if(r&&r!==`${e}:ok`)throw new Yt(r,n,o,s);return i}var ht,zn,mr=f(()=>{"use strict";Ze();h();Q();ir();gt();ht=[],zn=!1});function pr(e){let t=new Y,r=new ne({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=le(o),a;if(i.__extra){a=i.params;let{type:l,startTime:u}=i.__extra;r.report({type:l,event:n,duration:Date.now()-u})}else a=i;t.emit(n,a,s)}}}var dr=f(()=>{"use strict";h();Ze();gt()});function vt(e){let{subscribeHandler:t,onNative:r,offNative:n}=pr(e),{invokeNative:o,invokeHandler:s,applyNative:i}=lr(e,r);return{invokeHandler:s,subscribeHandler:t,applyNative:i,invokeNative:o,onNative:r,offNative:n}}var fr=f(()=>{"use strict";mr();dr()});var gr=f(()=>{"use strict"});var hr=f(()=>{"use strict";fr();gr()});var X,M,vr,yr=f(()=>{"use strict";h();U();M={trigger(){},exit(){return!1},onReady(e){M.trigger=e},doExit(e){M.exit=e}},vr=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)I(new Wt("native env failed"));else{let{data:t}=JSON.parse(e);return t??void 0}};if(window.webkit){let e=window.webkit.messageHandlers,t=(o="")=>{M.trigger(),e.onDocumentReady.postMessage({path:o})};X={onDocumentReady:t,doExit:o=>{let s=M.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:vr};globalThis.joliboxJSCore={...n}}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(o="")=>{M.trigger(),e.onDocumentReady(JSON.stringify({path:o}))};X={onDocumentReady:t,invoke(o,s,i){e.invoke(JSON.stringify({event:o,paramsString:s,callbackId:i}))},doExit:o=>{let s=M.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:vr};globalThis.joliboxJSCore={...n}}});function yt(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var bt=f(()=>{"use strict"});function kt(){globalThis.onmessage=function(e){e.data==="msg:setup"&&([ie]=e.ports,ie.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])},ie.publish=function(t,r){let n=yt(r,"messagePort");ie.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},ie.postMessage("msg:setup:ok"))}}var ie,br=f(()=>{"use strict";bt()});var _e=f(()=>{"use strict";yr();br();bt()});var Er,Wn,Tr,kr,O,w,J,pi,Yn,L=f(()=>{"use strict";hr();_e();Q();h();_e();Er=X;if(!Er)throw new Qt("No joliboxJScore is found, native bridge not found.");kt();Wn={...Er},Tr=vt(Wn),{invokeHandler:kr}=Tr,{applyNative:O,invokeNative:w,onNative:J,offNative:pi,subscribeHandler:Yn}=Tr;globalThis.joliboxJSBridge={callHandler:kr,invokeHandler:kr,subscribeHandler:Yn}});var Et,_r,Sr=f(()=>{"use strict";h();U();Et=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{return{}}},_r=e=>{try{let n=new URL(e).searchParams.get("joliSource")?.split(".");if(n?.length){let[o,s,i]=n;return{headerJson:Et(o),payloadJson:Et(s),signature:Et(i)}}else throw"joli_source is missing"}catch(t){return I(new zt(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}}});var Qn,Se,Rr,Tt=f(()=>{"use strict";h();Qn="1.1.4-beta.11",Se=()=>Qn,Rr=()=>{let e=Se();return`${tr(e)}`}});var Xn,Zn,F,eo,y,H=f(()=>{"use strict";h();Sr();Tt();h();Xn={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:ut(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Se()},schema:"",platform:"h5"},Zn=globalThis.joliboxJSCore?.env,F=Object.assign({},Zn?.()??Xn),eo=()=>{let{payloadJson:e,headerJson:t}=_r(F.schema),r=`${F.deviceInfo.did}-${new Date().getTime()}`,n=new URLSearchParams(F.schema.length?F.schema:window.location.search),o=n.get("mpId")??n.get("appId")??n.get("gameId")??"",s=e.sessionId??n.get("sessionId")??r,i=!!(e.testAdsMode??n.get("testAdsMode")==="true"),a=e.joliboxEnv??n.get("joliboxEnv")??"production",l=a==="staging";return{get testMode(){return l},get testAdsMode(){return i},get joliboxEnv(){return a},get mpId(){return o??e.id},get mpVersion(){return t.ver??Se()},get platform(){return F.platform},get deviceInfo(){return F.deviceInfo},get sdkInfo(){return F.sdkInfo},get hostInfo(){return F.hostInfo},get hostUserInfo(){return F.hostUserInfo},get sessionId(){return F.clientSessionId??s??r},onEnvConfigChanged:u=>{qt(F,u,Gt)}}},y=eo()});var _t,Ir,to,ro,xr,no,wr=f(()=>{"use strict";h();U();H();h();_t=!1,Ir=(e,t)=>e==null?!1:t in e,to=e=>Ir(e,"kind"),ro=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},xr=(e,t={},r)=>{let n=e.priority??"P1",s={...{user_id:y.hostUserInfo?.uid??"",device_id:y.deviceInfo.did??"",timestamp:Date.now(),tag:ro(e.name)},env:t.environment,isFromUser:r};r?te.emit("GLOBAL_USER_ERROR",e,s):te.emit("GLOBAL_ERROR",e,s)},no=e=>Ir(e,"kind")&&e.kind==="USER_ERROR";lt.on("ERROR_REPORT",({error:e,options:t})=>{if(_t)return;_t=!0;let r=to(e)&&e.raw?e.raw:e;try{let n=no(e);xr(e,t,n)}catch(n){let o=n instanceof Error?n.message:String(n),s=new it(`${o}, origin error: ${r.message}`);S.error(s),xr(new it(s.message),{environment:t.environment},!1)}finally{_t=!1}})});var Ar=f(()=>{"use strict";wr();Q();h();L();te.on("GLOBAL_ERROR",(e,t)=>{let r={message:e.message,stack:e.stack??"",errorType:e.name,source:0};w("trackAsync",{event:"reportJsError",data:r})});te.on("GLOBAL_USER_ERROR",(e,t)=>{S.log("UserError",e,t)})});var St=f(()=>{"use strict"});function Pr(e,t){let r=(n,o,s)=>{let i={tag:n,...t,extra:{...o}};n=="globalJsError"?I(new Xt(JSON.stringify(i),"P0")):e("systemLog",i,s)};return r.debounce=de(r,500,{leading:!0}),r}function Cr(e){let t=(r,n,o)=>{let s=(o&&JSON.stringify(o))??0,i={speed_value_type:r,total_duration:n};s&&Object.assign(i,{extra:s}),e("joliboxSpeedAnalysis",i)};return t.debounce=de(t,500,{leading:!0}),t}var Nr=f(()=>{"use strict";h();h();U()});function Or(e,t){let r=Pr(e,t),n=Cr(r);return{track:r,trackPerformance:n}}var Dr=f(()=>{"use strict";Nr()});var Ur=f(()=>{"use strict";H();h();h()});var Mr=f(()=>{"use strict";Dr();St();Ur()});var Re,Lr=f(()=>{"use strict";Re=class{constructor(t,r){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??5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t??0}}),this.tracker("OpenGame",{duration: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=performance.now(),n,o=!1,s=0,i=a=>{if(!o)return;let l=a-r;l>=this.interval&&(this.visible&&(s+=l,t(s)),r=a),n=requestAnimationFrame(i)};return{start(){o||(o=!0,r=performance.now(),n=requestAnimationFrame(i))},stop(){o=!1,n&&cancelAnimationFrame(n)}}}}});var Rt=f(()=>{"use strict"});function jr(e,t,r){let{response:n,startTime:o,endTime:s,requestFrom:i}=r,{errMsg:a="",profile:l={}}=n,m={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"&&Fr<so||i==="inner")&&(m.joli_request_number=Fr++,setTimeout(()=>{$("joliboxNetRequestResult",m)},500))}var Fr,so,Jr=f(()=>{"use strict";Rt();oe();Fr=0,so=10});function xe(e,t,r){let n=new Map,o=r?.baseUrl??"https://api.jolibox.com",s=r?.type??"public",i=r?.defaultHeaders??{};return J("onRequestTaskStateChange",l=>{if(typeof l.requestTaskId!="string")return;let u=n.get(l.requestTaskId);if(u)if(l.state==="success"){let{requestTaskId:m,state:p,...d}=l;u.resolve(d),n.delete(m)}else if(l.state==="fail"){let{requestTaskId:m,state:p,...d}=l;u.reject(d),n.delete(m)}else S.warn("onRequestTaskStateChange unknown event",l)}),K.on("onLoginComplete",({isLogin:l,token:u})=>{l&&u&&(i["X-JOLI-TOKEN"]=u)}),async(l,u={})=>{let m=Date.now(),p=io(l,{...u,baseUrl:o}),{method:d="GET",responseType:v="text",dataType:_="json",timeout:A,enableCache:N=!1,appendHostCookie:G=!0}=u,z=Object.assign({"content-type":"application/json"},i,u.header),k={url:p,method:d,header:z,enableCache:N,responseType:v,appendHostCookie:G};if(d=="POST"||d=="PUT"){let j=co(u.data,z["content-type"]);k.data=j}A&&Object.assign(k,{timeout:A});let{data:{requestTaskId:P}}=w(e,k);if(typeof P!="string")throw re({code:-1,msg:"requestTaskId is not a string"});let ue=(j,V)=>{jr("request",p,{state:j,startTime:m,endTime:Date.now(),params:k,response:V,requestId:P,requestFrom:s=="public"?"public":"inner"})},{resolve:Xe,reject:on,promise:sn}=new W;n.set(P,{resolve:Xe,reject:on});try{let j=await sn;ue("success",j);let{data:V}=j;return _==="json"&&typeof V=="string"&&(V=ao(V)),{url:p,timeout:A,method:d,response:{...j,data:V}}}catch(j){let V=j;if(C(V)){let{errMsg:ge,prefetchDetail:an,isPrefetch:cn,errNo:un}=V;Z(ge)&&(ue("fail",{errMsg:ge,isPrefetch:cn,prefetchDetail:an}),I(re({code:-1,msg:ge},{errNo:un,errMsg:ge})))}throw j}}}function ao(e){try{return JSON.parse(e.trim())}catch{return e}}function co(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 io,xt=f(()=>{"use strict";h();Jr();Rt();L();U();Q();io=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t?.query,o=new URLSearchParams(r).toString();return t?.baseUrl?`${t.baseUrl}${e}${o?`?${o}`:""}`:`${e}${o?`?${o}`:""}`}});var se,It=f(()=>{"use strict";Tt();xt();H();se=xe("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:y.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:{"x-user-agent":Rr(),"X-JOLI-TOKEN":y.hostUserInfo?.token??""}})});var Ie,$r=f(()=>{"use strict";H();Lr();It();L();Ie=class extends Re{constructor(t,r,n){super(r,n),this.gameId=y.mpId,this.sessionId=y.sessionId,this.track=t}async reporter(t){let{event:r,params:n}=t,o=[];o.push(se("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:{gameId:this.gameId,sessionId:this.sessionId,...n}}})),await Promise.all(o)}async reportToNative(t){let{event:r,params:n}=t;await O("userTrackAsync",{event:r,params:{...n},gameId:this.gameId})}tracker(t,r=null){this.track(t,r)}}});var uo,$,lo,Vr,we,D,oe=f(()=>{"use strict";Ar();h();St();Mr();H();$r();L();uo=(e,t,r)=>{let n=t,s={...C(n.extra)?n.extra:Z(n.extra)?JSON.parse(n.extra):{},mp_id:n.mp_id??"",mp_version:n.mp_version??""};w("trackAsync",{event:e,data:s,webviewId:r})},{track:$,trackPerformance:lo}=Or(uo,{type:ct.AppSDK,platform:"native",jssdk_version:y.sdkInfo?.jssdkVersion??"1.0.0",mp_id:y.mpId,mp_version:y.mpVersion}),Vr=R();Vr.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t})=>{lo(e,t)});Vr.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{$(e,t)});we=new Y,D=new Ie($,we)});function Hr(e){let t=at.config[e];return t||(t={},at.config[e]=t),(r,n)=>{if(t[r]){S.warn(`[can i use] ${r} already registered`);return}t[r]={...n}}}var Br=f(()=>{"use strict";h()});function wt(e){qr=e}function Pe(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Pe(t)):Object.keys(e).reduce((t,r)=>(t[r]=Pe(e[r]),t),{})}function B(e){return typeof e=="number"}function At(e){let t=Pt(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Pt(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var qr,E,Ce,Ne,Oe,De,ae,Ue,Me,Le,Fe,je,Je,$e,Ve,Ke,He,Be,qe,Ct=f(()=>{"use strict";qr=!1;E=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(qr)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 ${At(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Pe(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Pe(this._default)}optional(){return this._optional=!0,this}};Ce=class extends E{validate(t){return this._optional&&t===void 0?!0:B(t)?B(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):B(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):B(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}},Ne=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Oe=class extends E{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(B(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(B(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}},De=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ae=class extends E{validate(t){return!0}},Ue=class extends E{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},Me=class extends E{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Le=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Fe=class extends E{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 ${At(t)}`)}return!0}},je=class extends E{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(B(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(B(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(B(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}},Je=class extends E{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Pt(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}},$e=class extends E{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Pt(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}},Ve=class extends E{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:At(this.value),actual:r}):!0}},Ke=class extends E{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(`
1
+ var ln=Object.create;var Lt=Object.defineProperty;var mn=Object.getOwnPropertyDescriptor;var pn=Object.getOwnPropertyNames;var dn=Object.getPrototypeOf,fn=Object.prototype.hasOwnProperty;var f=(e,t)=>()=>(e&&(t=e(e=0)),t);var gn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var hn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pn(t))!fn.call(e,o)&&o!==r&&Lt(e,o,{get:()=>t[o],enumerable:!(n=mn(t,o))||n.enumerable});return e};var vn=(e,t,r)=>(r=e!=null?ln(dn(e)):{},hn(t||!e||!e.__esModule?Lt(r,"default",{value:e,enumerable:!0}):r,e));function yn(e){return!!e?.__nativeBuffers__}function le(e){if(typeof e=="string")try{e=JSON.parse(e)}catch{return{}}if(typeof e!="object"||e===null)return{};if(!yn(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=bn(n.base64)),typeof o<"u"&&o instanceof ArrayBuffer&&(e[n.key]=o)}}return e}function Ft(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:kn(s),key:o};n.push(i),delete r[o]}return n.length>0&&(r.__nativeBuffers__=n),r}var bn,kn,Ze=f(()=>{"use strict";bn=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};kn=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 _n(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Z(e){return typeof e=="string"}function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Vt(e){return typeof e=="object"&&Array.isArray(e)}function Sn(e){return typeof e>"u"}function Rn(e){return Sn(e)||e===null}function Kt(e){return typeof e=="function"}function Ht(e){return C(e)&&Kt(e.then)}function Bt(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}function qt(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],u=r(a,l,i,o,s);u!==void 0?o[i]=u:jt(l)&&jt(a)?o[i]=n({...a},l):Array.isArray(l)&&Array.isArray(a)?o[i]=[...a,...l]:o[i]=l}return o}return n(e,t)}function jt(e){return e&&typeof e=="object"&&e.constructor===Object}function Gt(e,t){if(Array.isArray(e))return e.concat(t)}function de(e,t,r={}){let n=null,o,s,i,{leading:a=!1,trailing:l=!0}=r,u=()=>(i=e.apply(s,o),o=void 0,s=void 0,i),m=function(...p){o=p,s=this;let d=a&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,l&&!d&&u()},t),d)return u()};return m.cancel=()=>{n&&clearTimeout(n),n=null,o=s=void 0},m.flush=()=>{if(n)return clearTimeout(n),n=null,u()},m}function wn(e,t){return(...r)=>t(e,...r)}function Te(e){return t=>wn(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(o){e(new st(`${o}`))}})}function me(e){return(...t)=>{(globalThis.VConsole?.[e]??globalThis.console[e])(...t)}}function Vn(e){return new Promise(t=>rr(e)(t))}function rr(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Kn(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new pe(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}function Bn(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)qn(e[n],t[n])}function qn(e,t){if(Z(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Kt(t)){try{if(e instanceof t)return}catch{}if(!Rn(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 R(){if(globalThis[tt])return globalThis[tt];let e=new be,t=new nt,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 Jt,Tn,En,$t,W,xn,ot,ee,In,st,zt,Wt,Yt,Qt,Xt,fe,ke,it,S,Zt,An,at,Pn,ct,Cn,Nn,he,On,Dn,Un,er,ut,Mn,Ln,Fn,tr,k,jn,Jn,ve,pe,Y,rt,$n,et,Hn,K,be,nt,tt,v=f(()=>{"use strict";Jt=Object.defineProperty,Tn=Object.getOwnPropertyDescriptor,En=(e,t)=>{for(var r in t)Jt(e,r,{get:t[r],enumerable:!0})},$t=(e,t,r,n)=>{for(var o=n>1?void 0:n?Tn(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&&Jt(t,r,o),o};W=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))}})}};xn=(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))(xn||{}),ot=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}},ee=class extends ot{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},In=class extends ot{constructor(){super(...arguments),this.kind="USER_ERROR"}},st=class extends In{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))}},zt=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Wt=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},Yt=class extends ee{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},Qt=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Xt=class extends ee{constructor(e,t){super(e),this.message=e,this.name="INTERNAL_CONTEXT_ERROR",this.property=t}},fe=class extends ot{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}}},ke=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}},it=class extends ee{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};S={log:me("log"),warn:me("warn"),info:me("info"),error:me("error"),debug:me("debug")};Object.assign(globalThis,{logger:S});Zt=Symbol.for("Jolibox.canIUseMap"),An={};globalThis[Zt]=An;at={get config(){return globalThis[Zt]}},Pn=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(Pn||{}),ct=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ct||{}),Cn=(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))(Cn||{}),Nn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),he={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")},On=()=>he.isiOS?"iOS":he.isAndroid?"Android":he.isMac?"Mac":he.isFacebook?"Facebook":"PC",Dn="device_id",Un="advertising_id",er=e=>(localStorage.getItem(e)||localStorage.setItem(e,Nn()),localStorage.getItem(e)),ut=()=>er(Dn),Mn=()=>er(Un),Ln=e=>e.charAt(0).toUpperCase()+e.slice(1),Fn=()=>{let e=new URLSearchParams(window.location.search);return Ln(e.get("utm_source")??"")||"JoliboxSDK"},tr=e=>{let t="JoliboxWebSDK",r=On(),n=navigator.language,o=ut(),s=Mn();return`${t} (${Fn()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},k=class ye{static{this.Undefined=new ye(void 0)}constructor(t){this.element=t,this.next=ye.Undefined,this.prev=ye.Undefined}},jn=class{constructor(){this._first=k.Undefined,this._last=k.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===k.Undefined}clear(){let e=this._first;for(;e!==k.Undefined;){let t=e.next;e.prev=k.Undefined,e.next=k.Undefined,e=t}this._first=k.Undefined,this._last=k.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new k(e);if(this._first===k.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!==k.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==k.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==k.Undefined&&e.next!==k.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===k.Undefined&&e.next===k.Undefined?(this._first=k.Undefined,this._last=k.Undefined):e.next===k.Undefined?(this._last=this._last.prev,this._last.next=k.Undefined):e.prev===k.Undefined&&(this._first=this._first.next,this._first.prev=k.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==k.Undefined;)yield e.element,e=e.next}},Jn=0,ve=class{constructor(e){this.value=e,this.id=Jn++}},pe=class{constructor(e){this.options=e,this._size=0}dispose(e){this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof ve&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(t=>t?.value===e)):(this._listeners=void 0,this._size=0)),this.options?.onDidRemoveLastListener?.())}get event(){return this._event??=(e,t)=>{if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};t&&(e=e.bind(t));let r=new ve(e);this._listeners?this._listeners instanceof ve?this._listeners=[this._listeners,r]:this._listeners.push(r):(this.options?.onWillAddFirstListener?.(this),this._listeners=r,this.options?.onDidFirstListener?.(this)),this.options?.onDidAddListener?.(this),this._size++},this._event}_deliver(e,t){if(!e)return;let r=this.options?.onListenerError||Error.constructor;if(!r){e.value(t);return}try{e.value(t)}catch(n){r(n)}}fire(e){this._listeners&&(this._listeners instanceof ve?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Y=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){let r=this.listeners.get(e)??new pe,n=s=>t(...s.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({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 jn,this.cachedEventQueue.set(e,n)),n.push({args:t})}}},rt={};En(rt,{None:()=>$n,filter:()=>Kn,once:()=>rr,toPromise:()=>Vn});$n=()=>{console.log("[Jolibox SDK] None Event")};et=Symbol.for("Jolibox.hostEmitter"),Hn=()=>{let e=new Y;return globalThis[et]||(globalThis[et]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[et]},K=Hn();be=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new pe,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 Bn(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}};be=$t([Bt],be);nt=class{constructor(){this._onWillExecuteCommand=new pe,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new pe,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new be,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=_n(3e4)),this._starActivation}async executeCommand(e,...t){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(await Promise.all([Promise.race([this._activateStar(),rt.toPromise(rt.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};nt=$t([Bt],nt);tt=Symbol.for("Jolibox.commands")});function I(e,t={}){lt.emit("ERROR_REPORT",{error:e,options:t})}var lt,te,U=f(()=>{"use strict";v();v();lt=new Y,te=new Y;I.debounce=de(I,50,{leading:!0})});function Ee(e,t){return`[${e}]:${t}`}var re,mt,Q=f(()=>{"use strict";U();v();U();re=(e,t)=>new fe(t?.errMsg??e.msg??"",e.code,e.type),mt=e=>new st(e)});var nr,or,sr,ir=f(()=>{"use strict";nr=[],or=[],sr=["env","createRequestTask","login"]});function cr(e,t){ar||(pt=new ne({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),dt=new ne({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(o){e.invoke("track",JSON.stringify({event:"reportMetrics",data:o}),-1)}}),ft=new ne({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(),dt.flush(),ft.flush()}),ar=!0);function r(o){let{method:s,args:i,startTime:a,isForeground:l,errMsg:u=`${s}:fail no errMsg`,errNo:m=0,__timing:p={receiveJSInvoke:0,invokeCallback:0}}=o,{receiveJSInvoke:d,invokeCallback:g}=p,b=u.match(/\S:(\S+)\s?/)?.[1]??"fail";pt.report({status:b,method:n(s,i),errNo:`${m}`,errMsg:u,isForeground:l,duration:Date.now()-a}),a&&d&&g&&(dt.report({status:b,method:s,isForeground:l,duration:Number((d-a).toFixed(3))}),ft.report({status:b,method:s,isForeground:l,duration:Number((Date.now()-g).toFixed(3))}))}function n(o,s){return(o==="callHostMethod"||o==="callHostMethodSync")&&s?.method?`${o}-${s.method}`:o}return r}var Gn,ne,ar,pt,dt,ft,gt=f(()=>{"use strict";v();Gn=e=>e==="pv"?e:"default",ne=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=Gn(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&&C(a))throw new ke(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);if(l){let u=[];if(C(a))u.push(...Object.keys(a));else if(Z(a)){if(s.length>0)throw new ke(`report value failed to match tagNameOrder, ${JSON.stringify(n)}`);u.push(a)}else throw new ke(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(n)}`);u.forEach(m=>{o[m]||(o[m]={});let p=C(a)?a[m]:a;r(o[m],[...s],i,p)})}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={}}},ar=!1});function lr(e,t){let r=0,n=!0,o=new Map,s=cr(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,ht.forEach(async({method:u,args:m,resolve:p})=>{let d=await a(u,m);p(d)}),ht.length=0});let i=(u,m)=>{S.info("----resolveId",u,m);let p=o.get(Number(u));if(!p)return;let d=le(m);p(d),o.delete(Number(u))},a=(u,m)=>{let p=Date.now(),d=`${n}`;r+=1;let g=new W;if(o.set(r,g.resolve),!n&&or.includes(u))return new Promise(P=>{ht.push({method:u,args:m,resolve:P})});let A={...{method:u,startTime:p,args:m,isForeground:d},invokeType:"js-bridge"},N=!zn&&nr.includes(u),G=Ft(m,N),z=N?G:JSON.stringify(G),T;if(u.endsWith("Sync")||sr.includes(u)?T=e.call?.(u,G,r):typeof z=="string"?(console.log("-----params",u,r),T=e.invoke(u,z,r)):T=e.call?.(u,z,r),T){try{typeof T=="string"&&(T=JSON.parse(T)),T=le(T)}catch(P){S.error(P)}return o.delete(r),T.errorCode&&(T.errorCode=Ee(u,T.errorCode)),s({...A,...T}),T}return u.endsWith("Sync")&&o.delete(r),g.promise.then(P=>(P.errorCode&&(P.errorCode=Ee(u,P.errorCode)),s({...A,...P}),P))};return{invokeNative:a,applyNative:(u,m)=>{let p=a(u,m);return Ht(p)?p.then(d=>ur(u,d)):ur(u,p)},invokeHandler:i}}function ur(e,t){if(!C(t)){S.warn(`[Jolibox SDK]${e} no response value`);return}let{errMsg:r,errNo:n,errorType:o,errorCode:s,...i}=t;if(r&&r!==`${e}:ok`)throw new Yt(r,n,o,s);return i}var ht,zn,mr=f(()=>{"use strict";Ze();v();Q();ir();gt();ht=[],zn=!1});function pr(e){let t=new Y,r=new ne({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=le(o),a;if(i.__extra){a=i.params;let{type:l,startTime:u}=i.__extra;r.report({type:l,event:n,duration:Date.now()-u})}else a=i;t.emit(n,a,s)}}}var dr=f(()=>{"use strict";v();Ze();gt()});function vt(e){let{subscribeHandler:t,onNative:r,offNative:n}=pr(e),{invokeNative:o,invokeHandler:s,applyNative:i}=lr(e,r);return{invokeHandler:s,subscribeHandler:t,applyNative:i,invokeNative:o,onNative:r,offNative:n}}var fr=f(()=>{"use strict";mr();dr()});var gr=f(()=>{"use strict"});var hr=f(()=>{"use strict";fr();gr()});var X,M,vr,yr=f(()=>{"use strict";v();U();M={trigger(){},exit(){return!1},onReady(e){M.trigger=e},doExit(e){M.exit=e}},vr=()=>{let e=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!e)I(new Wt("native env failed"));else{let{data:t}=JSON.parse(e);return t??void 0}};if(window.webkit){let e=window.webkit.messageHandlers,t=(o="")=>{M.trigger(),e.onDocumentReady.postMessage({path:o})};X={onDocumentReady:t,doExit:o=>{let s=M.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:vr};globalThis.joliboxJSCore={...n}}if(window.JoliAndroidSDKBridge){let e=window.JoliAndroidSDKBridge,t=(o="")=>{M.trigger(),e.onDocumentReady(JSON.stringify({path:o}))};X={onDocumentReady:t,invoke(o,s,i){e.invoke(JSON.stringify({event:o,paramsString:s,callbackId:i}))},doExit:o=>{let s=M.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:vr};globalThis.joliboxJSCore={...n}}});function yt(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var bt=f(()=>{"use strict"});function kt(){globalThis.onmessage=function(e){e.data==="msg:setup"&&([ie]=e.ports,ie.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])},ie.publish=function(t,r){let n=yt(r,"messagePort");ie.postMessage(JSON.stringify(["publish",t,JSON.stringify(n)]))},ie.postMessage("msg:setup:ok"))}}var ie,br=f(()=>{"use strict";bt()});var _e=f(()=>{"use strict";yr();br();bt()});var Tr,Wn,Er,kr,O,w,J,pi,Yn,L=f(()=>{"use strict";hr();_e();Q();v();_e();Tr=X;if(!Tr)throw new Qt("No joliboxJScore is found, native bridge not found.");kt();Wn={...Tr},Er=vt(Wn),{invokeHandler:kr}=Er,{applyNative:O,invokeNative:w,onNative:J,offNative:pi,subscribeHandler:Yn}=Er;globalThis.joliboxJSBridge={callHandler:kr,invokeHandler:kr,subscribeHandler:Yn}});var Tt,_r,Sr=f(()=>{"use strict";v();U();Tt=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{return{}}},_r=e=>{try{let n=new URL(e).searchParams.get("joliSource")?.split(".");if(n?.length){let[o,s,i]=n;return{headerJson:Tt(o),payloadJson:Tt(s),signature:Tt(i)}}else throw"joli_source is missing"}catch(t){return I(new zt(`${e} not a valid schema: ${t}`)),{headerJson:{},payloadJson:{},signature:{}}}}});var Qn,Se,Rr,Et=f(()=>{"use strict";v();Qn="1.1.4-beta.13",Se=()=>Qn,Rr=()=>{let e=Se();return`${tr(e)}`}});var Xn,Zn,F,eo,y,H=f(()=>{"use strict";v();Sr();Et();v();Xn={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:ut(),pixelRatio:window.devicePixelRatio||1,platform:"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:Se()},schema:"",platform:"h5"},Zn=globalThis.joliboxJSCore?.env,F=Object.assign({},Zn?.()??Xn),eo=()=>{let{payloadJson:e,headerJson:t}=_r(F.schema),r=`${F.deviceInfo.did}-${new Date().getTime()}`,n=new URLSearchParams(F.schema.length?F.schema:window.location.search),o=n.get("mpId")??n.get("appId")??n.get("gameId")??"",s=e.sessionId??n.get("sessionId")??r,i=!!(e.testAdsMode??n.get("testAdsMode")==="true"),a=e.joliboxEnv??n.get("joliboxEnv")??"production",l=a==="staging";return{get testMode(){return l},get testAdsMode(){return i},get joliboxEnv(){return a},get mpId(){return o??e.id},get mpVersion(){return t.ver??Se()},get platform(){return F.platform},get deviceInfo(){return F.deviceInfo},get sdkInfo(){return F.sdkInfo},get hostInfo(){return F.hostInfo},get hostUserInfo(){return F.hostUserInfo},get sessionId(){return F.clientSessionId??s??r},onEnvConfigChanged:u=>{qt(F,u,Gt)}}},y=eo()});var _t,Ir,to,ro,xr,no,wr=f(()=>{"use strict";v();U();H();v();_t=!1,Ir=(e,t)=>e==null?!1:t in e,to=e=>Ir(e,"kind"),ro=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},xr=(e,t={},r)=>{let n=e.priority??"P1",s={...{user_id:y.hostUserInfo?.uid??"",device_id:y.deviceInfo.did??"",timestamp:Date.now(),tag:ro(e.name)},env:t.environment,isFromUser:r};r?te.emit("GLOBAL_USER_ERROR",e,s):te.emit("GLOBAL_ERROR",e,s)},no=e=>Ir(e,"kind")&&e.kind==="USER_ERROR";lt.on("ERROR_REPORT",({error:e,options:t})=>{if(_t)return;_t=!0;let r=to(e)&&e.raw?e.raw:e;try{let n=no(e);xr(e,t,n)}catch(n){let o=n instanceof Error?n.message:String(n),s=new it(`${o}, origin error: ${r.message}`);S.error(s),xr(new it(s.message),{environment:t.environment},!1)}finally{_t=!1}})});var Ar=f(()=>{"use strict";wr();Q();v();L();te.on("GLOBAL_ERROR",(e,t)=>{let r={message:e.message,stack:e.stack??"",errorType:e.name,source:0};w("trackAsync",{event:"reportJsError",data:r})});te.on("GLOBAL_USER_ERROR",(e,t)=>{S.log("UserError",e,t)})});var St=f(()=>{"use strict"});function Pr(e,t){let r=(n,o,s)=>{let i={tag:n,...t,extra:{...o}};n=="globalJsError"?I(new Xt(JSON.stringify(i),"P0")):e("systemLog",i,s)};return r.debounce=de(r,500,{leading:!0}),r}function Cr(e){let t=(r,n,o)=>{let s=(o&&JSON.stringify(o))??0,i={speed_value_type:r,total_duration:n};s&&Object.assign(i,{extra:s}),e("joliboxSpeedAnalysis",i)};return t.debounce=de(t,500,{leading:!0}),t}var Nr=f(()=>{"use strict";v();v();U()});function Or(e,t){let r=Pr(e,t),n=Cr(r);return{track:r,trackPerformance:n}}var Dr=f(()=>{"use strict";Nr()});var Ur=f(()=>{"use strict";H();v();v()});var Mr=f(()=>{"use strict";Dr();St();Ur()});var Re,Lr=f(()=>{"use strict";Re=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??5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t??0}}),this.tracker("OpenGame",{duration: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 g=Date.now(),b=g-r;b>=this.interval&&(this.visible&&(i+=b,t(i)),r=g),n=requestAnimationFrame(a)},l=()=>{m(),r=Date.now(),o=window.setInterval(()=>{if(!s)return;let g=Date.now();g-r>=this.interval&&(r=g)},this.interval)},u=()=>{p(),r=Date.now(),n=requestAnimationFrame(a)},m=()=>{n&&(cancelAnimationFrame(n),n=0)},p=()=>{o&&(clearInterval(o),o=0)};this.eventEmitter.on("visible",g=>{s&&(console.log("visible",g),g?u():l())});let d=this.visible;return{start(){s||(s=!0,d?u():l())},stop(){s=!1,m(),p()}}}}});var Rt=f(()=>{"use strict"});function jr(e,t,r){let{response:n,startTime:o,endTime:s,requestFrom:i}=r,{errMsg:a="",profile:l={}}=n,m={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"&&Fr<so||i==="inner")&&(m.joli_request_number=Fr++,setTimeout(()=>{$("joliboxNetRequestResult",m)},500))}var Fr,so,Jr=f(()=>{"use strict";Rt();oe();Fr=0,so=10});function xe(e,t,r){let n=new Map,o=r?.baseUrl??"https://api.jolibox.com",s=r?.type??"public",i=r?.defaultHeaders??{};return J("onRequestTaskStateChange",l=>{if(typeof l.requestTaskId!="string")return;let u=n.get(l.requestTaskId);if(u)if(l.state==="success"){let{requestTaskId:m,state:p,...d}=l;u.resolve(d),n.delete(m)}else if(l.state==="fail"){let{requestTaskId:m,state:p,...d}=l;u.reject(d),n.delete(m)}else S.warn("onRequestTaskStateChange unknown event",l)}),K.on("onLoginComplete",({isLogin:l,token:u})=>{l&&u&&(i["X-JOLI-TOKEN"]=u)}),async(l,u={})=>{let m=Date.now(),p=io(l,{...u,baseUrl:o}),{method:d="GET",responseType:g="text",dataType:b="json",timeout:A,enableCache:N=!1,appendHostCookie:G=!0}=u,z=Object.assign({"content-type":"application/json"},i,u.header),T={url:p,method:d,header:z,enableCache:N,responseType:g,appendHostCookie:G};if(d=="POST"||d=="PUT"){let j=co(u.data,z["content-type"]);T.data=j}A&&Object.assign(T,{timeout:A});let{data:{requestTaskId:P}}=w(e,T);if(typeof P!="string")throw re({code:-1,msg:"requestTaskId is not a string"});let ue=(j,V)=>{jr("request",p,{state:j,startTime:m,endTime:Date.now(),params:T,response:V,requestId:P,requestFrom:s=="public"?"public":"inner"})},{resolve:Xe,reject:on,promise:sn}=new W;n.set(P,{resolve:Xe,reject:on});try{let j=await sn;ue("success",j);let{data:V}=j;return b==="json"&&typeof V=="string"&&(V=ao(V)),{url:p,timeout:A,method:d,response:{...j,data:V}}}catch(j){let V=j;if(C(V)){let{errMsg:ge,prefetchDetail:an,isPrefetch:cn,errNo:un}=V;Z(ge)&&(ue("fail",{errMsg:ge,isPrefetch:cn,prefetchDetail:an}),I(re({code:-1,msg:ge},{errNo:un,errMsg:ge})))}throw j}}}function ao(e){try{return JSON.parse(e.trim())}catch{return e}}function co(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 io,xt=f(()=>{"use strict";v();Jr();Rt();L();U();Q();io=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t?.query,o=new URLSearchParams(r).toString();return t?.baseUrl?`${t.baseUrl}${e}${o?`?${o}`:""}`:`${e}${o?`?${o}`:""}`}});var se,It=f(()=>{"use strict";Et();xt();H();se=xe("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:y.testMode?"https://stg-api.jolibox.com":"https://api.jolibox.com",defaultHeaders:{"x-user-agent":Rr(),"X-JOLI-TOKEN":y.hostUserInfo?.token??""}})});var Ie,$r=f(()=>{"use strict";H();Lr();It();L();Ie=class extends Re{constructor(t,r,n){super(r,n),this.gameId=y.mpId,this.sessionId=y.sessionId,this.track=t}async reporter(t){let{event:r,params:n}=t,o=[];o.push(se("/api/base/app-event",{method:"POST",data:{eventType:r,gameInfo:{gameId:this.gameId,sessionId:this.sessionId,...n}}})),await Promise.all(o)}async reportToNative(t){let{event:r,params:n}=t;await O("userTrackAsync",{event:r,params:{...n},gameId:this.gameId})}tracker(t,r=null){this.track(t,r)}}});var uo,$,lo,Vr,we,D,oe=f(()=>{"use strict";Ar();v();St();Mr();H();$r();L();uo=(e,t,r)=>{let n=t,s={...C(n.extra)?n.extra:Z(n.extra)?JSON.parse(n.extra):{},mp_id:n.mp_id??"",mp_version:n.mp_version??""};w("trackAsync",{event:e,data:s,webviewId:r})},{track:$,trackPerformance:lo}=Or(uo,{type:ct.AppSDK,platform:"native",jssdk_version:y.sdkInfo?.jssdkVersion??"1.0.0",mp_id:y.mpId,mp_version:y.mpVersion}),Vr=R();Vr.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t})=>{lo(e,t)});Vr.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{$(e,t)});we=new Y,D=new Ie($,we)});function Hr(e){let t=at.config[e];return t||(t={},at.config[e]=t),(r,n)=>{if(t[r]){S.warn(`[can i use] ${r} already registered`);return}t[r]={...n}}}var Br=f(()=>{"use strict";v()});function wt(e){qr=e}function Pe(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Pe(t)):Object.keys(e).reduce((t,r)=>(t[r]=Pe(e[r]),t),{})}function B(e){return typeof e=="number"}function At(e){let t=Pt(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Pt(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var qr,E,Ce,Ne,Oe,De,ae,Ue,Me,Le,Fe,je,Je,$e,Ve,Ke,He,Be,qe,Ct=f(()=>{"use strict";qr=!1;E=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(qr)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 ${At(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return Pe(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:Pe(this._default)}optional(){return this._optional=!0,this}};Ce=class extends E{validate(t){return this._optional&&t===void 0?!0:B(t)?B(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):B(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):B(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}},Ne=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Oe=class extends E{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(B(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(B(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}},De=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},ae=class extends E{validate(t){return!0}},Ue=class extends E{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},Me=class extends E{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},Le=class extends E{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},Fe=class extends E{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 ${At(t)}`)}return!0}},je=class extends E{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(B(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(B(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(B(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}},Je=class extends E{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Pt(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}},$e=class extends E{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Pt(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}},Ve=class extends E{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:At(this.value),actual:r}):!0}},Ke=class extends E{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(`
2
2
  or `);this.errors.push(s)}return n}},He=class extends E{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}},Be=class extends E{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},qe=class extends E{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 Nt(e,t,r="param"){if(e.errors=[],e.path=r,wt(!0),!e.validate(t)){let n=e.errors.join(`
3
- `);throw e.errors.length=0,wt(!1),new TypeError(n)}}var c,Ot=f(()=>{"use strict";Ct();Ct();c={object(e){return new $e(e)},array(e){return new je(e)},tuple(...e){return new He(...e)},literal(e){return new Ve(e)},or(...e){return new Ke(...e)},symbol(){return new De},record(e){return new Je(e)},function(){return new Le},boolean(){return new Ne},string(){return new Oe},number(){return new Ce},undefined(){return new Ue},null(){return new Me},unknown(){return new ae},any(){return new ae},as(){return new ae},arraybuffer(){return new Be},enum(...e){return new Fe(...e)},typedarray(e){return new qe(e)}}});var Ge,Gr,zr=f(()=>{"use strict";h();U();Ot();Q();Ge=1,Gr=e=>{function t(n,o){return(...s)=>{let i=Date.now(),a={method:n,trace_id:Ge};Ge+=1;let l="SUCCESS",u=`${n}:ok`,m=0;try{if(o.paramsSchema)try{Nt(o.paramsSchema,s,"params")}catch(_){throw mt(`${n}:fail ${_.message}`)}let p=o.implement(...s),d=p,v=`${n}:ok`;if(p&&"code"in p){let{code:_,data:A,message:N}=p;l=_,d=A,v=N}return{code:l,message:v,data:d}}catch(p){let d=p;m=d.code??d.errNo??2e3,l="FAILURE";let v=d.message??d.errMsg??`${p}`;return u=`${n}:${l} ${v.replace(/^\S+:(fail|cancel)\s?/,"")}`,I(new fe(u,m)),{code:l,message:u}}finally{let p=Date.now()-i;e("apiInvoked",{...a,duration:p,status:l})}}}function r(n,o){return async(...s)=>{let i=Vt(s)?s:[s],a=Date.now(),l={method:n,trace_id:Ge};Ge+=1;let u=`${n}:ok`,m="SUCCESS",p={code:m,message:u};try{if(o.paramsSchema)try{Nt(o.paramsSchema,i,"params")}catch(_){throw mt(_.message)}let v=await o.implement(...i);if(v&&"code"in v){let{code:_,data:A,message:N}=v;m=_,u=N,v=A}return Object.assign(p,{code:m,message:u,data:v}),p}catch(d){let v=d,_=v.code??v.errNo??2e3;m="FAILURE";let A=v.message??v.errMsg??`${d}`,N=`${n}:${m} ${A.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(p,{code:m,message:N}),I(new fe(N,_)),p}finally{let d=Date.now()-a;e("apiInvoked",{...l,duration:d,status:m})}}}return{createAPI:r,createSyncAPI:t}}});var T,x,g,q=f(()=>{"use strict";Br();oe();zr();Ot();({createAPI:T,createSyncAPI:x}=Gr($)),g=Hr("native")});var Qr=gn(Yr=>{"use strict";h();q();U();L();oe();var bo="exitGame",ko="onReady",Eo="onJoliboxShow",To="onJoliboxHide",ze=R(),We=Ee(I),_o=T(bo,{paramsSchema:c.tuple(c.function()),implement:async e=>{We(e).call(Yr),await O("exitAppAsync")}}),So=x(Eo,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);J("onJoliboxEnterForeground",()=>{t.call(this),we.emit("visible",!0)})}}),Ro=x(To,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);J("onJoliboxEnterBackground",()=>{t.call(this),we.emit("visible",!1)})}}),xo=x(ko,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);K.on("LifecycleEvent.onReady",r=>{t(r)})}});ze.registerCommand("LifecycleSDK.exit",_o);ze.registerCommand("LifecycleSDK.onReady",xo);ze.registerCommand("LifecycleSDK.onJoliboxShow",So);ze.registerCommand("LifecycleSDK.onJoliboxHide",Ro);g("lifeCycle.exit",{version:"1.0.0"});g("lifeCycle.onReady",{version:"1.0.0"});g("lifeCycle.onJoliboxShow",{version:"1.0.0"});g("lifeCycle.onJoliboxHide",{version:"1.0.0"})});L();_e();H();h();oe();M.onReady(()=>{});M.doExit(()=>($("onBeforeExit",{timestamp:Date.now()}),D.close(Date.now()-Ae),!1));function mo(){K.on("onDocumentReady",()=>{X?.onDocumentReady(window.location.href),$("onDocumentReady",{start_timestamp:Ae,timestamp:Date.now()})})}function po(){J("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&y.onEnvConfigChanged({hostUserInfo:e}),K.emit("LifecycleEvent.onReady",{...y.hostUserInfo?y.hostUserInfo:{isLogin:!1}}),$("joliboxServiceReady",{start_timestamp:Ae,timestamp:Date.now()}),D.start(t)}),J("onBeforeExit",({uuid:e})=>{X?.doExit(e)})}var Ae;function Kr(){Ae=Date.now(),po(),mo()}h();q();L();var Wr=R(),go="env",ho="getSystemInfoSync",vo=x(ho,{implement:()=>{let e=w("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:t.hostInfo?.appName,SDKVersion:t.sdkInfo.jssdkVersion}}}),yo=x(go,{implement:()=>w("envSync")?.data??void 0});Wr.registerCommand("API.getSystemInfoSync",vo);Wr.registerCommand("API.env",yo);g("env",{version:"1.0.0"});g("getSystemInfoSync",{version:"1.0.0"});var Qc=vn(Qr());Q();xt();q();h();function Xr(e){let t={};if(!C(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 Zr(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 en(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function tn(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!C(r))return e;let[n,o=""]=e.split("?"),s=JSON.stringify({...JSON.parse(o),...r});return`${n}?${s}`}h();U();var Io=15,wo=xe("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),Dt=0,Ut=[],rn=Ee(I),Ao=(e,t)=>{let r=e.filter(t),n=e.filter(o=>!t(o));return e.length=0,e.push(...n),r},Po=e=>{let t=new W,r=()=>{};return T("request",{paramsSchema:c.tuple(c.object({url:c.string(),method:c.string(),header:c.object(),data:c.object().optional(),query:c.object().optional(),dataType:c.string().default("json"),responseType:c.string().default("text"),enableCache:c.boolean().default(!1),appendHostCookie:c.boolean().default(!0),timeout:c.number().default(3e4),success:c.function(),fail:c.function()})),implement(o){let s=async()=>{let i=rn(o.fail);try{if(Dt+=1,t.state!=="pending")return;let{data:a,dataType:l,responseType:u,enableCache:m,appendHostCookie:p}=o,d=Xr(o.header),v=Zr(o.method),_=en(o.timeout),A=tn(o.url,v,a),N=rn(o.success),G=Object.assign({},o,{method:v,header:d,data:v==="GET"||v==="HEAD"?void 0:a,enableCache:m,query:o.query??{},dataType:l,responseType:u,appendHostCookie:p});_&&(G.timeout=_);let z=wo(A,G);{let{response:k}=await z,{code:P,data:ue,message:Xe}=k;t.resolve({code:P??"SUCCESS",data:ue,message:Xe??"request:ok"}),N({code:"SUCCESS",message:"request:ok",data:ue})}}catch(a){t.reject(a),i({code:"FAILURE",message:"httpRequst: failed"})}finally{Dt-=1,Ut.shift()?.()}};return Dt>=Io?(r=()=>{Ao(Ut,i=>i===s)},Ut.push(s)):s(),t.promise}})(e),{abort(){t.reject(re({code:-1,msg:"request:fail abort"})),r()}}},Co=R();Co.registerCommand("HttpSDK.request",Po);g("request",{version:"1.0.0"});q();L();h();It();H();var Ye=R(),No=T("getLocalStorage",{paramsSchema:c.tuple(c.string()),async implement(e){let{response:t}=await se(`/api/games/user-storage/${y.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:o}}=await t;if(r==="SUCCESS")return{code:r,message:n,data:o?.value};try{let{data:{data:s,dataType:i}}=await O("getLocalStorageAsync",{key:e}),a=Fo(s,i);return{code:r,message:`${n}. fallback to native`,data:a}}catch{return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}}});Ye.registerCommand("StorageSDK.getItem",No);g("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var Oo=T("setStorage",{paramsSchema:c.tuple(c.string(),c.or(c.string(),c.boolean(),c.number())),async implement(e,t){let r=y.mpId,n=typeof t=="string"?t:String(t),{response:o}=await se(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:s,message:i}}=o,a=Lo(t),l=jo(t,a);return await O("setLocalStorageAsync",{key:e,data:l,dataType:a}),s=="SUCCESS"?{code:s,message:i}:{code:s,message:`${i}. fallback to native`}}});Ye.registerCommand("StorageSDK.setItem",Oo);g("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var Do=T("removeStorage",{paramsSchema:c.tuple(c.string()),async implement(e){let t=y.mpId,{response:r}=await se(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:o}}=r;return await O("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:o}:{code:n,message:"[Jolibox SDK] remove item succ"}}});Ye.registerCommand("StorageSDK.removeItem",Do);g("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var Uo=T("clearStorage",{async implement(){let e=y.mpId,{response:t}=await se(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});O("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}}});Ye.registerCommand("StorageSDK.clear",Uo);g("storage.clear",{version:"1.0.0"});var Cc=T("getStorageInfo",{async implement(){let{data:e}=await O("getStorageInfoAsync");return e}});g("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});var Nc=x("getStorageInfoSync",{implement(){return w("getStorageInfoSync")}}),Mo=["string","number","boolean","object",""];function Lo(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return Mo.includes(t)?t:""}function Fo(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{return""}}function jo(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch{return""}}h();L();q();var Jo=x("showKeyboard",{paramsSchema:c.tuple(c.object({defaultValue:c.string().optional().default(""),multiple:c.boolean().optional().default(!1),maxLength:c.unknown().optional().default(1e5)})),implement(e){let t=Math.floor(Number(e.maxLength)??1e5),{defaultValue:r}=e;r&&t&&(r=r.slice(0,t)),w("showKeyboardSync",{...e,defaultValue:r,maxLength:t})}});g("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"}});var $o=x("updateKeyboard",{paramsSchema:c.tuple(c.object({value:c.string()})),implement(e){w("updateKeyboardSync",e)}});g("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});var Vo=x("hideKeyboard",{implement(){w("hideKeyboardSync")}});g("keyboard.hideKeyboard",{version:"1.0.0"});var Mt=R();Mt.registerCommand("KeyboardSDK.showKeyboard",Jo);Mt.registerCommand("KeyboardSDK.updateKeyboard",$o);Mt.registerCommand("KeyboardSDK.hideKeyboard",Vo);h();q();oe();var ce=R(),Ko=T("levelFinished",{paramsSchema:c.tuple(c.string(),c.object({result:c.boolean(),duration:c.number()})),implement:async(e,t)=>{let{result:r,duration:n}=t,o=[];o.push(D.tracker("LevelFinished",{levelId:e,result:r,duration:n})),o.push(D.reporter({event:"COMPLETE_GAME_LEVEL"})),await Promise.all(o)}}),Ho=T("taskFinished",{paramsSchema:c.tuple(c.string(),c.object({duration:c.number()})),implement:async(e,t)=>{let{duration:r}=t;return await D.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})}}),Bo=T("levelUpgrade",{paramsSchema:c.tuple(c.string(),c.string()),implement:async(e,t)=>{let r=[];r.push(D.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),await Promise.all(r)}}),qo=T("onHistoryUserLevel",{paramsSchema:c.tuple(c.number()),implement:async e=>await D.reportToNative({event:"HistoryUserLevel",params:{level:e}})}),Go=T("onHistoryUserScore",{paramsSchema:c.tuple(c.number()),implement:async e=>await D.reportToNative({event:"HistoryUserScore",params:{score:e}})}),zo=T("taskEvent",{paramsSchema:c.tuple(c.string(),c.object({tools:c.array(c.object({id:c.string(),name:c.string(),count:c.number(),description:c.string().optional(),price:c.object({amount:c.number(),unit:c.string()}).optional()})).optional(),awards:c.array(c.object({id:c.string(),name:c.string()})).optional()})),implement:async(e,t)=>{let r=[];r.push(D.reportToNative({event:"TaskEvent",params:{taskId:e,...t}})),(t.tools?.length??!1)&&(r.push(D.reporter({event:"USE_GAME_ITEM"})),r.push(D.reportToNative({event:"UseGameItem",params:{taskId:e,...t}}))),await Promise.all(r)}});ce.registerCommand("TaskTrackerSDK.levelFinished",Ko);ce.registerCommand("TaskTrackerSDK.taskFinished",Ho);ce.registerCommand("TaskTrackerSDK.levelUpgrade",Bo);ce.registerCommand("TaskTrackerSDK.historyUserLevel",qo);ce.registerCommand("TaskTrackerSDK.historyUserScore",Go);ce.registerCommand("TaskTrackerSDK.taskEvent",zo);g("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});g("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});g("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});g("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});g("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});g("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"}}}});H();L();q();h();Q();g("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"}});g("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});var Wo=T("login",{async implement(){let{data:{isLogin:e}}=await O("checkLoginAsync");if(e)return{isLogin:!0,token:y.hostUserInfo?.token};J("onLoginStateChange",({isLogin:i,token:a,uuid:l})=>{l==r&&o({isLogin:i,token:a})});let t=w("loginSync"),{data:{uuid:r}}=t;if(!r)throw re({code:-1,msg:"login failed"});let{promise:n,resolve:o}=new W,s=await n;return y.onEnvConfigChanged({hostUserInfo:s}),K.emit("onLoginComplete",s),s}}),Yo=T("checkSession",{async implement(){let{data:{isLogin:e}}=await O("checkLoginAsync");return{isLogin:e}}}),nn=R();nn.registerCommand("API.login",Wo);nn.registerCommand("API.checkSession",Yo);h();q();var Qe=R(),Qo=x("adInit",{implement:e=>{S.log("[JoliboxAdsSDK] adInit",e)}}),Xo=x("adConfig",{implement:e=>{S.log("[JoliboxAdsSDK] adConfig",e)}}),Zo=x("adBreak",{implement:e=>{S.log("[JoliboxAdsSDK] adBreak",e)}}),es=x("adUnit",{implement:e=>{S.log("[JoliboxAdsSDK] adUnit",e)}});Qe.registerCommand("AdsSDK.init",Qo);Qe.registerCommand("AdsSDK.adConfig",Xo);Qe.registerCommand("AdsSDK.adBreak",Zo);Qe.registerCommand("AdsSDK.adUnit",es);g("AdsSDK.init",{version:"1.0.0"});g("AdsSDK.adConfig",{version:"1.0.0"});g("AdsSDK.adBreak",{version:"1.0.0"});g("AdsSDK.adUnit",{version:"1.0.0"});oe();Kr();
3
+ `);throw e.errors.length=0,wt(!1),new TypeError(n)}}var c,Ot=f(()=>{"use strict";Ct();Ct();c={object(e){return new $e(e)},array(e){return new je(e)},tuple(...e){return new He(...e)},literal(e){return new Ve(e)},or(...e){return new Ke(...e)},symbol(){return new De},record(e){return new Je(e)},function(){return new Le},boolean(){return new Ne},string(){return new Oe},number(){return new Ce},undefined(){return new Ue},null(){return new Me},unknown(){return new ae},any(){return new ae},as(){return new ae},arraybuffer(){return new Be},enum(...e){return new Fe(...e)},typedarray(e){return new qe(e)}}});var Ge,Gr,zr=f(()=>{"use strict";v();U();Ot();Q();Ge=1,Gr=e=>{function t(n,o){return(...s)=>{let i=Date.now(),a={method:n,trace_id:Ge};Ge+=1;let l="SUCCESS",u=`${n}:ok`,m=0;try{if(o.paramsSchema)try{Nt(o.paramsSchema,s,"params")}catch(b){throw mt(`${n}:fail ${b.message}`)}let p=o.implement(...s),d=p,g=`${n}:ok`;if(p&&"code"in p){let{code:b,data:A,message:N}=p;l=b,d=A,g=N}return{code:l,message:g,data:d}}catch(p){let d=p;m=d.code??d.errNo??2e3,l="FAILURE";let g=d.message??d.errMsg??`${p}`;return u=`${n}:${l} ${g.replace(/^\S+:(fail|cancel)\s?/,"")}`,I(new fe(u,m)),{code:l,message:u}}finally{let p=Date.now()-i;e("apiInvoked",{...a,duration:p,status:l})}}}function r(n,o){return async(...s)=>{let i=Vt(s)?s:[s],a=Date.now(),l={method:n,trace_id:Ge};Ge+=1;let u=`${n}:ok`,m="SUCCESS",p={code:m,message:u};try{if(o.paramsSchema)try{Nt(o.paramsSchema,i,"params")}catch(b){throw mt(b.message)}let g=await o.implement(...i);if(g&&"code"in g){let{code:b,data:A,message:N}=g;m=b,u=N,g=A}return Object.assign(p,{code:m,message:u,data:g}),p}catch(d){let g=d,b=g.code??g.errNo??2e3;m="FAILURE";let A=g.message??g.errMsg??`${d}`,N=`${n}:${m} ${A.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(p,{code:m,message:N}),I(new fe(N,b)),p}finally{let d=Date.now()-a;e("apiInvoked",{...l,duration:d,status:m})}}}return{createAPI:r,createSyncAPI:t}}});var _,x,h,q=f(()=>{"use strict";Br();oe();zr();Ot();({createAPI:_,createSyncAPI:x}=Gr($)),h=Hr("native")});var Qr=gn(Yr=>{"use strict";v();q();U();L();oe();var bo="exitGame",ko="onReady",To="onJoliboxShow",Eo="onJoliboxHide",ze=R(),We=Te(I),_o=_(bo,{paramsSchema:c.tuple(c.function()),implement:async e=>{We(e).call(Yr),await O("exitAppAsync")}}),So=x(To,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);J("onJoliboxEnterForeground",()=>{t.call(this),we.emit("visible",!0)})}}),Ro=x(Eo,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);J("onJoliboxEnterBackground",()=>{t.call(this),we.emit("visible",!1)})}}),xo=x(ko,{paramsSchema:c.tuple(c.function()),implement(e){let t=We(e);K.on("LifecycleEvent.onReady",r=>{t(r)})}});ze.registerCommand("LifecycleSDK.exit",_o);ze.registerCommand("LifecycleSDK.onReady",xo);ze.registerCommand("LifecycleSDK.onJoliboxShow",So);ze.registerCommand("LifecycleSDK.onJoliboxHide",Ro);h("lifeCycle.exit",{version:"1.0.0"});h("lifeCycle.onReady",{version:"1.0.0"});h("lifeCycle.onJoliboxShow",{version:"1.0.0"});h("lifeCycle.onJoliboxHide",{version:"1.0.0"})});L();_e();H();v();oe();M.onReady(()=>{});M.doExit(()=>($("onBeforeExit",{timestamp:Date.now()}),D.close(Date.now()-Ae),!1));function mo(){K.on("onDocumentReady",()=>{X?.onDocumentReady(window.location.href),$("onDocumentReady",{start_timestamp:Ae,timestamp:Date.now()})})}function po(){J("onJoliboxServiceReady",({runtimeInfo:e,loadDuration:t})=>{e&&y.onEnvConfigChanged({hostUserInfo:e}),K.emit("LifecycleEvent.onReady",{...y.hostUserInfo?y.hostUserInfo:{isLogin:!1}}),$("joliboxServiceReady",{start_timestamp:Ae,timestamp:Date.now()}),D.start(t)}),J("onBeforeExit",({uuid:e})=>{X?.doExit(e)})}var Ae;function Kr(){Ae=Date.now(),po(),mo()}v();q();L();var Wr=R(),go="env",ho="getSystemInfoSync",vo=x(ho,{implement:()=>{let e=w("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:t.hostInfo?.appName,SDKVersion:t.sdkInfo.jssdkVersion}}}),yo=x(go,{implement:()=>w("envSync")?.data??void 0});Wr.registerCommand("API.getSystemInfoSync",vo);Wr.registerCommand("API.env",yo);h("env",{version:"1.0.0"});h("getSystemInfoSync",{version:"1.0.0"});var Qc=vn(Qr());Q();xt();q();v();function Xr(e){let t={};if(!C(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 Zr(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 en(e,t=!1){if(e)return t||e>0&&e<=6e4?Math.ceil(e):6e4}function tn(e,t,r){if(["POST","PUT","PATCH"].includes(t)||!C(r))return e;let[n,o=""]=e.split("?"),s=JSON.stringify({...JSON.parse(o),...r});return`${n}?${s}`}v();U();var Io=15,wo=xe("createRequestTaskSync","operateRequestTaskSync",{type:"public"}),Dt=0,Ut=[],rn=Te(I),Ao=(e,t)=>{let r=e.filter(t),n=e.filter(o=>!t(o));return e.length=0,e.push(...n),r},Po=e=>{let t=new W,r=()=>{};return _("request",{paramsSchema:c.tuple(c.object({url:c.string(),method:c.string(),header:c.object(),data:c.object().optional(),query:c.object().optional(),dataType:c.string().default("json"),responseType:c.string().default("text"),enableCache:c.boolean().default(!1),appendHostCookie:c.boolean().default(!0),timeout:c.number().default(3e4),success:c.function(),fail:c.function()})),implement(o){let s=async()=>{let i=rn(o.fail);try{if(Dt+=1,t.state!=="pending")return;let{data:a,dataType:l,responseType:u,enableCache:m,appendHostCookie:p}=o,d=Xr(o.header),g=Zr(o.method),b=en(o.timeout),A=tn(o.url,g,a),N=rn(o.success),G=Object.assign({},o,{method:g,header:d,data:g==="GET"||g==="HEAD"?void 0:a,enableCache:m,query:o.query??{},dataType:l,responseType:u,appendHostCookie:p});b&&(G.timeout=b);let z=wo(A,G);{let{response:T}=await z,{code:P,data:ue,message:Xe}=T;t.resolve({code:P??"SUCCESS",data:ue,message:Xe??"request:ok"}),N({code:"SUCCESS",message:"request:ok",data:ue})}}catch(a){t.reject(a),i({code:"FAILURE",message:"httpRequst: failed"})}finally{Dt-=1,Ut.shift()?.()}};return Dt>=Io?(r=()=>{Ao(Ut,i=>i===s)},Ut.push(s)):s(),t.promise}})(e),{abort(){t.reject(re({code:-1,msg:"request:fail abort"})),r()}}},Co=R();Co.registerCommand("HttpSDK.request",Po);h("request",{version:"1.0.0"});q();L();v();It();H();var Ye=R(),No=_("getLocalStorage",{paramsSchema:c.tuple(c.string()),async implement(e){let{response:t}=await se(`/api/games/user-storage/${y.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:o}}=await t;if(r==="SUCCESS")return{code:r,message:n,data:o?.value};try{let{data:{data:s,dataType:i}}=await O("getLocalStorageAsync",{key:e}),a=Fo(s,i);return{code:r,message:`${n}. fallback to native`,data:a}}catch{return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}}});Ye.registerCommand("StorageSDK.getItem",No);h("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var Oo=_("setStorage",{paramsSchema:c.tuple(c.string(),c.or(c.string(),c.boolean(),c.number())),async implement(e,t){let r=y.mpId,n=typeof t=="string"?t:String(t),{response:o}=await se(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:s,message:i}}=o,a=Lo(t),l=jo(t,a);return await O("setLocalStorageAsync",{key:e,data:l,dataType:a}),s=="SUCCESS"?{code:s,message:i}:{code:s,message:`${i}. fallback to native`}}});Ye.registerCommand("StorageSDK.setItem",Oo);h("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});var Do=_("removeStorage",{paramsSchema:c.tuple(c.string()),async implement(e){let t=y.mpId,{response:r}=await se(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:o}}=r;return await O("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:o}:{code:n,message:"[Jolibox SDK] remove item succ"}}});Ye.registerCommand("StorageSDK.removeItem",Do);h("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});var Uo=_("clearStorage",{async implement(){let e=y.mpId,{response:t}=await se(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});O("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}}});Ye.registerCommand("StorageSDK.clear",Uo);h("storage.clear",{version:"1.0.0"});var Cc=_("getStorageInfo",{async implement(){let{data:e}=await O("getStorageInfoAsync");return e}});h("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});var Nc=x("getStorageInfoSync",{implement(){return w("getStorageInfoSync")}}),Mo=["string","number","boolean","object",""];function Lo(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return Mo.includes(t)?t:""}function Fo(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{return""}}function jo(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch{return""}}v();L();q();var Jo=x("showKeyboard",{paramsSchema:c.tuple(c.object({defaultValue:c.string().optional().default(""),multiple:c.boolean().optional().default(!1),maxLength:c.unknown().optional().default(1e5)})),implement(e){let t=Math.floor(Number(e.maxLength)??1e5),{defaultValue:r}=e;r&&t&&(r=r.slice(0,t)),w("showKeyboardSync",{...e,defaultValue:r,maxLength:t})}});h("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"}});var $o=x("updateKeyboard",{paramsSchema:c.tuple(c.object({value:c.string()})),implement(e){w("updateKeyboardSync",e)}});h("keyboard.updateKeyboard",{version:"1.0.0",properties:{params:{value:"1.0.0"}}});var Vo=x("hideKeyboard",{implement(){w("hideKeyboardSync")}});h("keyboard.hideKeyboard",{version:"1.0.0"});var Mt=R();Mt.registerCommand("KeyboardSDK.showKeyboard",Jo);Mt.registerCommand("KeyboardSDK.updateKeyboard",$o);Mt.registerCommand("KeyboardSDK.hideKeyboard",Vo);v();q();oe();var ce=R(),Ko=_("levelFinished",{paramsSchema:c.tuple(c.string(),c.object({result:c.boolean(),duration:c.number()})),implement:async(e,t)=>{let{result:r,duration:n}=t,o=[];o.push(D.tracker("LevelFinished",{levelId:e,result:r,duration:n})),o.push(D.reporter({event:"COMPLETE_GAME_LEVEL"})),await Promise.all(o)}}),Ho=_("taskFinished",{paramsSchema:c.tuple(c.string(),c.object({duration:c.number()})),implement:async(e,t)=>{let{duration:r}=t;return await D.reportToNative({event:"TaskFinished",params:{duration:r,taskId:e}})}}),Bo=_("levelUpgrade",{paramsSchema:c.tuple(c.string(),c.string()),implement:async(e,t)=>{let r=[];r.push(D.reportToNative({event:"LevelUpgrade",params:{name:t,levelId:e}})),await Promise.all(r)}}),qo=_("onHistoryUserLevel",{paramsSchema:c.tuple(c.number()),implement:async e=>await D.reportToNative({event:"HistoryUserLevel",params:{level:e}})}),Go=_("onHistoryUserScore",{paramsSchema:c.tuple(c.number()),implement:async e=>await D.reportToNative({event:"HistoryUserScore",params:{score:e}})}),zo=_("taskEvent",{paramsSchema:c.tuple(c.string(),c.object({tools:c.array(c.object({id:c.string(),name:c.string(),count:c.number(),description:c.string().optional(),price:c.object({amount:c.number(),unit:c.string()}).optional()})).optional(),awards:c.array(c.object({id:c.string(),name:c.string()})).optional()})),implement:async(e,t)=>{let r=[];r.push(D.reportToNative({event:"TaskEvent",params:{taskId:e,...t}})),(t.tools?.length??!1)&&(r.push(D.reporter({event:"USE_GAME_ITEM"})),r.push(D.reportToNative({event:"UseGameItem",params:{taskId:e,...t}}))),await Promise.all(r)}});ce.registerCommand("TaskTrackerSDK.levelFinished",Ko);ce.registerCommand("TaskTrackerSDK.taskFinished",Ho);ce.registerCommand("TaskTrackerSDK.levelUpgrade",Bo);ce.registerCommand("TaskTrackerSDK.historyUserLevel",qo);ce.registerCommand("TaskTrackerSDK.historyUserScore",Go);ce.registerCommand("TaskTrackerSDK.taskEvent",zo);h("TaskTrackerSDK.onLevelFinished",{version:"1.0.0",properties:{levelId:"1.0.0",params:{result:"1.0.0",duration:"1.0.0"}}});h("TaskTrackerSDK.onTaskFinished",{version:"1.0.0",properties:{taskId:"1.0.0",duration:"1.0.0"}});h("TaskTrackerSDK.onLevelUpgrade",{version:"1.0.0",properties:{levelId:"1.0.0",name:"1.0.0"}});h("TaskTrackerSDK.onHistoryUserLevel",{version:"1.0.0",properties:{level:"1.0.0"}});h("TaskTrackerSDK.onHistoryUserScore",{version:"1.0.0",properties:{score:"1.0.0"}});h("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"}}}});H();L();q();v();Q();h("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"}});h("checkSession",{version:"1.0.0",success:{errMsg:"1.0.0"}});var Wo=_("login",{async implement(){let{data:{isLogin:e}}=await O("checkLoginAsync");if(e)return{isLogin:!0,token:y.hostUserInfo?.token};J("onLoginStateChange",({isLogin:i,token:a,uuid:l})=>{l==r&&o({isLogin:i,token:a})});let t=w("loginSync"),{data:{uuid:r}}=t;if(!r)throw re({code:-1,msg:"login failed"});let{promise:n,resolve:o}=new W,s=await n;return y.onEnvConfigChanged({hostUserInfo:s}),K.emit("onLoginComplete",s),s}}),Yo=_("checkSession",{async implement(){let{data:{isLogin:e}}=await O("checkLoginAsync");return{isLogin:e}}}),nn=R();nn.registerCommand("API.login",Wo);nn.registerCommand("API.checkSession",Yo);v();q();var Qe=R(),Qo=x("adInit",{implement:e=>{S.log("[JoliboxAdsSDK] adInit",e)}}),Xo=x("adConfig",{implement:e=>{S.log("[JoliboxAdsSDK] adConfig",e)}}),Zo=x("adBreak",{implement:e=>{S.log("[JoliboxAdsSDK] adBreak",e)}}),es=x("adUnit",{implement:e=>{S.log("[JoliboxAdsSDK] adUnit",e)}});Qe.registerCommand("AdsSDK.init",Qo);Qe.registerCommand("AdsSDK.adConfig",Xo);Qe.registerCommand("AdsSDK.adBreak",Zo);Qe.registerCommand("AdsSDK.adUnit",es);h("AdsSDK.init",{version:"1.0.0"});h("AdsSDK.adConfig",{version:"1.0.0"});h("AdsSDK.adBreak",{version:"1.0.0"});h("AdsSDK.adUnit",{version:"1.0.0"});oe();Kr();
@@ -1,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.1.4-beta.11 clean
3
+ > @jolibox/implement@1.1.4-beta.13 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.1.4-beta.11 build:esm
7
+ > @jolibox/implement@1.1.4-beta.13 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-beta.11",
4
+ "version": "1.1.4-beta.13",
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.4-beta.11",
10
- "@jolibox/types": "1.1.4-beta.11",
9
+ "@jolibox/common": "1.1.4-beta.13",
10
+ "@jolibox/types": "1.1.4-beta.13",
11
11
  "localforage": "1.10.0"
12
12
  },
13
13
  "devDependencies": {
@@ -30,7 +30,7 @@ export abstract class TaskTracker {
30
30
 
31
31
  abstract reporter(point: TaskPoint): void;
32
32
  abstract tracker(point: TrackEvent, info: Record<string, unknown> | null): void;
33
- constructor(eventEmitter: EventEmitter<{ visible: [boolean] }>, interval?: number) {
33
+ constructor(readonly eventEmitter: EventEmitter<{ visible: [boolean] }>, interval?: number) {
34
34
  this.interval = interval ?? 5 * 1000;
35
35
 
36
36
  eventEmitter.on('visible', (visible) => {
@@ -63,14 +63,16 @@ export abstract class TaskTracker {
63
63
  }
64
64
 
65
65
  private createRAFTimer(callback: (duration: number) => void) {
66
- let lastTime = performance.now();
66
+ let lastTime = Date.now();
67
67
  let rafId: number;
68
+ let intervalId: number;
68
69
  let isRunning = false;
69
70
  let totalTime = 0;
70
71
 
71
- const tick = (currentTime: number) => {
72
+ const tick = () => {
72
73
  if (!isRunning) return;
73
74
 
75
+ const currentTime = Date.now();
74
76
  const deltaTime = currentTime - lastTime;
75
77
  if (deltaTime >= this.interval) {
76
78
  if (this.visible) {
@@ -83,19 +85,66 @@ export abstract class TaskTracker {
83
85
  rafId = requestAnimationFrame(tick);
84
86
  };
85
87
 
88
+ const startInterval = () => {
89
+ stopRAF();
90
+ lastTime = Date.now();
91
+ intervalId = window.setInterval(() => {
92
+ if (!isRunning) return;
93
+ const currentTime = Date.now();
94
+ const deltaTime = currentTime - lastTime;
95
+ if (deltaTime >= this.interval) {
96
+ lastTime = currentTime;
97
+ }
98
+ }, this.interval) as unknown as number;
99
+ };
100
+
101
+ const startRAF = () => {
102
+ stopInterval();
103
+ lastTime = Date.now();
104
+ rafId = requestAnimationFrame(tick);
105
+ };
106
+
107
+ const stopRAF = () => {
108
+ if (rafId) {
109
+ cancelAnimationFrame(rafId);
110
+ rafId = 0;
111
+ }
112
+ };
113
+
114
+ const stopInterval = () => {
115
+ if (intervalId) {
116
+ clearInterval(intervalId);
117
+ intervalId = 0;
118
+ }
119
+ };
120
+
121
+ this.eventEmitter.on('visible', (visible) => {
122
+ if (!isRunning) return;
123
+
124
+ console.log('visible', visible);
125
+ if (visible) {
126
+ startRAF();
127
+ } else {
128
+ startInterval();
129
+ }
130
+ });
131
+
132
+ const originVisible = this.visible;
86
133
  return {
87
134
  start() {
88
135
  if (!isRunning) {
89
136
  isRunning = true;
90
- lastTime = performance.now();
91
- rafId = requestAnimationFrame(tick);
137
+ if (originVisible) {
138
+ startRAF();
139
+ } else {
140
+ startInterval();
141
+ }
92
142
  }
93
143
  },
94
144
  stop() {
95
145
  isRunning = false;
96
- if (rafId) {
97
- cancelAnimationFrame(rafId);
98
- }
146
+ stopRAF();
147
+ stopInterval();
99
148
  }
100
149
  };
101
150
  }