@jolibox/sdk 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var f=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var k=(e,o)=>{for(var t in o)f(e,t,{get:o[t],enumerable:!0})},_=(e,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of L(o))!A.call(e,a)&&a!==t&&f(e,a,{get:()=>o[a],enumerable:!(i=v(o,a))||i.enumerable});return e};var D=e=>_(f({},"__esModule",{value:!0}),e);var w=(e,o,t)=>new Promise((i,a)=>{var n=r=>{try{s(t.next(r))}catch(d){a(d)}},l=r=>{try{s(t.throw(r))}catch(d){a(d)}},s=r=>r.done?i(r.value):Promise.resolve(r.value).then(n,l);s((t=t.apply(e,o)).next())});var P={};k(P,{JoliboxSDK:()=>m,default:()=>M});module.exports=D(P);var g=e=>{var s,r,d;let o=e.split("-")[1];o&&(e=e.replace(`-${o}`,""));let t=e.split("+")[1];t&&(e=e.replace(`+${t}`,""));let i=e.split(".").slice(0,3),[a,n,l]=[(s=i[0])!=null?s:"0",(r=i[1])!=null?r:"0",(d=i[2])!=null?d:"0"];return{major:a,minor:n,patch:l,prerelease:o,build:t}},b=e=>parseInt(g(e).major,10),S=(e,o)=>{let{major:t,minor:i,patch:a}=g(e),{major:n,minor:l,patch:s}=g(o);return t!==n?t>n?1:-1:i!==l?i>l?1:-1:a!==s?a>s?1:-1:0};var J="jolibox-sdk-loader-metadata",x=class{constructor({loaderMetadata:o}={}){this.computeLoaderMetaData=()=>{var a,n;let o=this.currentVersion,t=null;try{if(t=JSON.parse((a=localStorage.getItem(J))!=null?a:"null"),!t||!t.version)throw new Error("Invalid loader metadata")}catch(l){t=this.defaultMetadata}let i=(n=t==null?void 0:t.version)!=null?n:o;return b(i)!==b(o)?t=this.defaultMetadata:S(i,o)<0&&(t=this.defaultMetadata),t};this.loadScript=()=>{if(this.loaderMetadata.syncScriptUrl){let o=new XMLHttpRequest;o.open("GET",this.loaderMetadata.syncScriptUrl,!1),o.send();let t=document.createElement("script");t.type="text/javascript",t.innerHTML=o.responseText,document.head.appendChild(t)}if(this.loaderMetadata.asyncScriptUrl){let o=document.createElement("script");o.type="text/javascript",o.src=this.loaderMetadata.asyncScriptUrl,o.async=!0,document.head.appendChild(o)}};this.fetchUpdateLoaderMetadata=(...n)=>w(this,[...n],function*(o=this.currentVersion,t=this.loaderMetadata.version,i=(a=>(a=window.JOLIBOX_ENV)!=null?a:"WEB")()){var s,r,d;let l=`${(r=(s=window.joliboxenv)==null?void 0:s.apiBaseURL)!=null?r:"https://api.jolibox.com"}/frontend/js-sdk/loader-metadata`;try{let p=yield(yield fetch(l,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({installedSDKVersion:o,localSDKVersion:t,env:i})})).json();if(p.code!=="SUCCESS")throw new Error(p.message);this.loaderMetadata=(d=p.data)!=null?d:this.defaultMetadata,localStorage.setItem(J,JSON.stringify(this.loaderMetadata))}catch(c){console.warn("Failed to fetch loader metadata: ",c)}});console.log("Loading Jolibox SDK..."),this.loaderMetadata=o!=null?o:this.computeLoaderMetaData(),this.loadScript(),this.fetchUpdateLoaderMetadata(),console.log("Jolibox SDK loaded.")}get currentVersion(){return window.__JOLIBOX_LOCAL_SDK_VERSION__}get defaultMetadata(){let o=this.currentVersion,t=b(o);return{version:o,syncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-sync-sdk@${t}/dist/index.iife.js`,asyncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-async-sdk@${t}/dist/index.iife.js`}}};window.JoliboxSDKLoader=x;var u=class{constructor(){this.init=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.init",params:o})};this.adConfig=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adConfig",params:o})};this.adBreak=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adBreak",params:o})};this.adUnit=o=>w(this,null,function*(){window.joliboxsdk._commandPipe.push({cmd:"ads.adUnit",params:o})})}};window.JoliboxAds=u;var h=class{constructor(){this.trackEvent=(o,t)=>{if(typeof o!="string")throw new Error("eventName must be a string");if(t!==null&&typeof t!="object"&&t!==void 0)throw new Error("extra must be an object or null or undefined");if(t){for(let i in t)if(typeof t[i]=="object")throw new Error("extra must not have nested objects")}window.joliboxsdk._commandPipe.push({cmd:"analytics.trackEvent",params:[o,t]})}}};window.JoliboxAnalytics=h;var F=require("@jolibox/web-sync-sdk");window.__JOLIBOX_LOCAL_SDK_VERSION__="1.1.2";var m=class{constructor({useRuntimeSDK:o=!0,loaderConfig:t,joliboxEnv:i,testAdsMode:a,apiBaseURL:n}={}){this.hostToApiMap={default:{stg:"https://stg-api.jolibox.com",prod:"https://api.jolibox.com"},"oss.jolibox.com":{stg:"https://stg-api.jolibox.com",prod:"https://api.jolibox.com"},"oss.pico-game.com":{stg:"https://stg-api.pico-game.com",prod:"https://api.pico-game.com"}};this.setJoliboxEnv=(o,t,i)=>{var I,y;let n=typeof window<"u"?new URLSearchParams(window.location.search):null,l=(n==null?void 0:n.get("testAdsMode"))==="true",s=t!=null?t:l,r=n==null?void 0:n.get("joliboxEnv"),d=(I=o!=null?o:r)!=null?I:"production",c=n==null?void 0:n.get("apiBaseURL"),p;if(i)p=i;else if(c)p=c;else{let j=(y=this.hostToApiMap[window.location.host])!=null?y:this.hostToApiMap.default;p=d==="staging"?j.stg:j.prod}window.joliboxenv={joliboxEnv:d,testAdsMode:s,apiBaseURL:p}};var l,s,r,d,c;this.setJoliboxEnv(i,a,n),o&&window.joliboxsdk?(this.loader=(l=window.joliboxsdk.loader)!=null?l:new window.JoliboxSDKLoader(t),this.ads=(s=window.joliboxsdk.ads)!=null?s:new window.JoliboxAds,this.anaytics=(r=window.joliboxsdk.anaytics)!=null?r:new window.JoliboxAnalytics,this.runtime=(d=window.joliboxsdk.runtime)!=null?d:new window.JoliboxRuntime,this.storage=(c=window.joliboxsdk.storage)!=null?c:new window.JoliboxCloudStorage):(window.joliboxsdk||(window.joliboxsdk={_commandPipe:[]}),this.loader=new window.JoliboxSDKLoader(t),this.ads=new window.JoliboxAds,this.anaytics=new window.JoliboxAnalytics,this.runtime=new window.JoliboxRuntime,this.storage=new window.JoliboxCloudStorage,window.joliboxsdk=Object.assign(this,window.joliboxsdk)),window.joliboxsdk._commandPipe||(window.joliboxsdk._commandPipe=[])}};window.JoliboxSDK||(window.JoliboxSDK=m);var M=m;0&&(module.exports={JoliboxSDK});
1
+ "use strict";var f=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var k=(e,o)=>{for(var t in o)f(e,t,{get:o[t],enumerable:!0})},_=(e,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of L(o))!A.call(e,a)&&a!==t&&f(e,a,{get:()=>o[a],enumerable:!(i=v(o,a))||i.enumerable});return e};var D=e=>_(f({},"__esModule",{value:!0}),e);var w=(e,o,t)=>new Promise((i,a)=>{var n=r=>{try{s(t.next(r))}catch(d){a(d)}},l=r=>{try{s(t.throw(r))}catch(d){a(d)}},s=r=>r.done?i(r.value):Promise.resolve(r.value).then(n,l);s((t=t.apply(e,o)).next())});var P={};k(P,{JoliboxSDK:()=>m,default:()=>M});module.exports=D(P);var g=e=>{var s,r,d;let o=e.split("-")[1];o&&(e=e.replace(`-${o}`,""));let t=e.split("+")[1];t&&(e=e.replace(`+${t}`,""));let i=e.split(".").slice(0,3),[a,n,l]=[(s=i[0])!=null?s:"0",(r=i[1])!=null?r:"0",(d=i[2])!=null?d:"0"];return{major:a,minor:n,patch:l,prerelease:o,build:t}},b=e=>parseInt(g(e).major,10),S=(e,o)=>{let{major:t,minor:i,patch:a}=g(e),{major:n,minor:l,patch:s}=g(o);return t!==n?t>n?1:-1:i!==l?i>l?1:-1:a!==s?a>s?1:-1:0};var J="jolibox-sdk-loader-metadata",x=class{constructor({loaderMetadata:o}={}){this.computeLoaderMetaData=()=>{var a,n;let o=this.currentVersion,t=null;try{if(t=JSON.parse((a=localStorage.getItem(J))!=null?a:"null"),!t||!t.version)throw new Error("Invalid loader metadata")}catch(l){t=this.defaultMetadata}let i=(n=t==null?void 0:t.version)!=null?n:o;return b(i)!==b(o)?t=this.defaultMetadata:S(i,o)<0&&(t=this.defaultMetadata),t};this.loadScript=()=>{if(this.loaderMetadata.syncScriptUrl){let o=new XMLHttpRequest;o.open("GET",this.loaderMetadata.syncScriptUrl,!1),o.send();let t=document.createElement("script");t.type="text/javascript",t.innerHTML=o.responseText,document.head.appendChild(t)}if(this.loaderMetadata.asyncScriptUrl){let o=document.createElement("script");o.type="text/javascript",o.src=this.loaderMetadata.asyncScriptUrl,o.async=!0,document.head.appendChild(o)}};this.fetchUpdateLoaderMetadata=(...n)=>w(this,[...n],function*(o=this.currentVersion,t=this.loaderMetadata.version,i=(a=>(a=window.JOLIBOX_ENV)!=null?a:"WEB")()){var s,r,d;let l=`${(r=(s=window.joliboxenv)==null?void 0:s.apiBaseURL)!=null?r:"https://api.jolibox.com"}/frontend/js-sdk/loader-metadata`;try{let p=yield(yield fetch(l,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({installedSDKVersion:o,localSDKVersion:t,env:i})})).json();if(p.code!=="SUCCESS")throw new Error(p.message);this.loaderMetadata=(d=p.data)!=null?d:this.defaultMetadata,localStorage.setItem(J,JSON.stringify(this.loaderMetadata))}catch(c){console.warn("Failed to fetch loader metadata: ",c)}});console.log("Loading Jolibox SDK..."),this.loaderMetadata=o!=null?o:this.computeLoaderMetaData(),this.loadScript(),this.fetchUpdateLoaderMetadata(),console.log("Jolibox SDK loaded.")}get currentVersion(){return window.__JOLIBOX_LOCAL_SDK_VERSION__}get defaultMetadata(){let o=this.currentVersion,t=b(o);return{version:o,syncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-sync-sdk@${t}/dist/index.iife.js`,asyncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-async-sdk@${t}/dist/index.iife.js`}}};window.JoliboxSDKLoader=x;var u=class{constructor(){this.init=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.init",params:o})};this.adConfig=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adConfig",params:o})};this.adBreak=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adBreak",params:o})};this.adUnit=o=>w(this,null,function*(){window.joliboxsdk._commandPipe.push({cmd:"ads.adUnit",params:o})})}};window.JoliboxAds=u;var h=class{constructor(){this.trackEvent=(o,t)=>{if(typeof o!="string")throw new Error("eventName must be a string");if(t!==null&&typeof t!="object"&&t!==void 0)throw new Error("extra must be an object or null or undefined");if(t){for(let i in t)if(typeof t[i]=="object")throw new Error("extra must not have nested objects")}window.joliboxsdk._commandPipe.push({cmd:"analytics.trackEvent",params:[o,t]})}}};window.JoliboxAnalytics=h;var F=require("@jolibox/web-sync-sdk");window.__JOLIBOX_LOCAL_SDK_VERSION__="1.1.3";var m=class{constructor({useRuntimeSDK:o=!0,loaderConfig:t,joliboxEnv:i,testAdsMode:a,apiBaseURL:n}={}){this.hostToApiMap={default:{stg:"https://stg-api.jolibox.com",prod:"https://api.jolibox.com"},"oss.jolibox.com":{stg:"https://stg-api.jolibox.com",prod:"https://api.jolibox.com"},"oss.pico-game.com":{stg:"https://stg-api.pico-game.com",prod:"https://api.pico-game.com"}};this.setJoliboxEnv=(o,t,i)=>{var I,y;let n=typeof window<"u"?new URLSearchParams(window.location.search):null,l=(n==null?void 0:n.get("testAdsMode"))==="true",s=t!=null?t:l,r=n==null?void 0:n.get("joliboxEnv"),d=(I=o!=null?o:r)!=null?I:"production",c=n==null?void 0:n.get("apiBaseURL"),p;if(i)p=i;else if(c)p=c;else{let j=(y=this.hostToApiMap[window.location.host])!=null?y:this.hostToApiMap.default;p=d==="staging"?j.stg:j.prod}window.joliboxenv={joliboxEnv:d,testAdsMode:s,apiBaseURL:p}};var l,s,r,d,c;this.setJoliboxEnv(i,a,n),o&&window.joliboxsdk?(this.loader=(l=window.joliboxsdk.loader)!=null?l:new window.JoliboxSDKLoader(t),this.ads=(s=window.joliboxsdk.ads)!=null?s:new window.JoliboxAds,this.anaytics=(r=window.joliboxsdk.anaytics)!=null?r:new window.JoliboxAnalytics,this.runtime=(d=window.joliboxsdk.runtime)!=null?d:new window.JoliboxRuntime,this.storage=(c=window.joliboxsdk.storage)!=null?c:new window.JoliboxCloudStorage):(window.joliboxsdk||(window.joliboxsdk={_commandPipe:[]}),this.loader=new window.JoliboxSDKLoader(t),this.ads=new window.JoliboxAds,this.anaytics=new window.JoliboxAnalytics,this.runtime=new window.JoliboxRuntime,this.storage=new window.JoliboxCloudStorage,window.joliboxsdk=Object.assign(this,window.joliboxsdk)),window.joliboxsdk._commandPipe||(window.joliboxsdk._commandPipe=[])}};window.JoliboxSDK||(window.JoliboxSDK=m);var M=m;0&&(module.exports={JoliboxSDK});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
1
- "use strict";(()=>{var gr=Object.create;var Ze=Object.defineProperty;var pr=Object.getOwnPropertyDescriptor;var yr=Object.getOwnPropertyNames;var br=Object.getPrototypeOf,wr=Object.prototype.hasOwnProperty;var ne=(u=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(u,{get:(s,f)=>(typeof require<"u"?require:s)[f]}):u)(function(u){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+u+'" is not supported')});var _r=(u,s)=>()=>(s||u((s={exports:{}}).exports,s),s.exports);var Sr=(u,s,f,w)=>{if(s&&typeof s=="object"||typeof s=="function")for(let g of yr(s))!wr.call(u,g)&&g!==f&&Ze(u,g,{get:()=>s[g],enumerable:!(w=pr(s,g))||w.enumerable});return u};var Ir=(u,s,f)=>(f=u!=null?gr(br(u)):{},Sr(s||!u||!u.__esModule?Ze(f,"default",{value:u,enumerable:!0}):f,u));var ue=(u,s,f)=>new Promise((w,g)=>{var _=p=>{try{x(f.next(p))}catch(I){g(I)}},b=p=>{try{x(f.throw(p))}catch(I){g(I)}},x=p=>p.done?w(p.value):Promise.resolve(p.value).then(_,b);x((f=f.apply(u,s)).next())});var nt=_r((rt,Ae)=>{"use strict";(function(u){if(typeof rt=="object"&&typeof Ae<"u")Ae.exports=u();else if(typeof define=="function"&&define.amd)define([],u);else{var s;typeof window<"u"?s=window:typeof global<"u"?s=global:typeof self<"u"?s=self:s=this,s.localforage=u()}})(function(){var u,s,f;return function w(g,_,b){function x(A,L){if(!_[A]){if(!g[A]){var h=typeof ne=="function"&&ne;if(!L&&h)return h(A,!0);if(p)return p(A,!0);var S=new Error("Cannot find module '"+A+"'");throw S.code="MODULE_NOT_FOUND",S}var P=_[A]={exports:{}};g[A][0].call(P.exports,function(U){var V=g[A][1][U];return x(V||U)},P,P.exports,w,g,_,b)}return _[A].exports}for(var p=typeof ne=="function"&&ne,I=0;I<b.length;I++)x(b[I]);return x}({1:[function(w,g,_){(function(b){"use strict";var x=b.MutationObserver||b.WebKitMutationObserver,p;if(x){var I=0,A=new x(U),L=b.document.createTextNode("");A.observe(L,{characterData:!0}),p=function(){L.data=I=++I%2}}else if(!b.setImmediate&&typeof b.MessageChannel<"u"){var h=new b.MessageChannel;h.port1.onmessage=U,p=function(){h.port2.postMessage(0)}}else"document"in b&&"onreadystatechange"in b.document.createElement("script")?p=function(){var j=b.document.createElement("script");j.onreadystatechange=function(){U(),j.onreadystatechange=null,j.parentNode.removeChild(j),j=null},b.document.documentElement.appendChild(j)}:p=function(){setTimeout(U,0)};var S,P=[];function U(){S=!0;for(var j,W,M=P.length;M;){for(W=P,P=[],j=-1;++j<M;)W[j]();M=P.length}S=!1}g.exports=V;function V(j){P.push(j)===1&&!S&&p()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(w,g,_){"use strict";var b=w(1);function x(){}var p={},I=["REJECTED"],A=["FULFILLED"],L=["PENDING"];g.exports=h;function h(m){if(typeof m!="function")throw new TypeError("resolver must be a function");this.state=L,this.queue=[],this.outcome=void 0,m!==x&&V(this,m)}h.prototype.catch=function(m){return this.then(null,m)},h.prototype.then=function(m,D){if(typeof m!="function"&&this.state===A||typeof D!="function"&&this.state===I)return this;var R=new this.constructor(x);if(this.state!==L){var N=this.state===A?m:D;P(R,N,this.outcome)}else this.queue.push(new S(R,m,D));return R};function S(m,D,R){this.promise=m,typeof D=="function"&&(this.onFulfilled=D,this.callFulfilled=this.otherCallFulfilled),typeof R=="function"&&(this.onRejected=R,this.callRejected=this.otherCallRejected)}S.prototype.callFulfilled=function(m){p.resolve(this.promise,m)},S.prototype.otherCallFulfilled=function(m){P(this.promise,this.onFulfilled,m)},S.prototype.callRejected=function(m){p.reject(this.promise,m)},S.prototype.otherCallRejected=function(m){P(this.promise,this.onRejected,m)};function P(m,D,R){b(function(){var N;try{N=D(R)}catch(J){return p.reject(m,J)}N===m?p.reject(m,new TypeError("Cannot resolve promise with itself")):p.resolve(m,N)})}p.resolve=function(m,D){var R=j(U,D);if(R.status==="error")return p.reject(m,R.value);var N=R.value;if(N)V(m,N);else{m.state=A,m.outcome=D;for(var J=-1,F=m.queue.length;++J<F;)m.queue[J].callFulfilled(D)}return m},p.reject=function(m,D){m.state=I,m.outcome=D;for(var R=-1,N=m.queue.length;++R<N;)m.queue[R].callRejected(D);return m};function U(m){var D=m&&m.then;if(m&&(typeof m=="object"||typeof m=="function")&&typeof D=="function")return function(){D.apply(m,arguments)}}function V(m,D){var R=!1;function N(k){R||(R=!0,p.reject(m,k))}function J(k){R||(R=!0,p.resolve(m,k))}function F(){D(J,N)}var $=j(F);$.status==="error"&&N($.value)}function j(m,D){var R={};try{R.value=m(D),R.status="success"}catch(N){R.status="error",R.value=N}return R}h.resolve=W;function W(m){return m instanceof this?m:p.resolve(new this(x),m)}h.reject=M;function M(m){var D=new this(x);return p.reject(D,m)}h.all=de;function de(m){var D=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var R=m.length,N=!1;if(!R)return this.resolve([]);for(var J=new Array(R),F=0,$=-1,k=new this(x);++$<R;)Y(m[$],$);return k;function Y(ee,ae){D.resolve(ee).then(ve,function(q){N||(N=!0,p.reject(k,q))});function ve(q){J[ae]=q,++F===R&&!N&&(N=!0,p.resolve(k,J))}}}h.race=H;function H(m){var D=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var R=m.length,N=!1;if(!R)return this.resolve([]);for(var J=-1,F=new this(x);++J<R;)$(m[J]);return F;function $(k){D.resolve(k).then(function(Y){N||(N=!0,p.resolve(F,Y))},function(Y){N||(N=!0,p.reject(F,Y))})}}},{1:1}],3:[function(w,g,_){(function(b){"use strict";typeof b.Promise!="function"&&(b.Promise=w(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(w,g,_){"use strict";var b=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function x(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function p(){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(e){return}}var I=p();function A(){try{if(!I||!I.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),r=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||r)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch(t){return!1}}function L(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(n){if(n.name!=="TypeError")throw n;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new t,a=0;a<e.length;a+=1)o.append(e[a]);return o.getBlob(r.type)}}typeof Promise>"u"&&w(3);var h=Promise;function S(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}function P(e,r,t){typeof r=="function"&&e.then(r),typeof t=="function"&&e.catch(t)}function U(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function V(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var j="local-forage-detect-blob-support",W=void 0,M={},de=Object.prototype.toString,H="readonly",m="readwrite";function D(e){for(var r=e.length,t=new ArrayBuffer(r),o=new Uint8Array(t),a=0;a<r;a++)o[a]=e.charCodeAt(a);return t}function R(e){return new h(function(r){var t=e.transaction(j,m),o=L([""]);t.objectStore(j).put(o,"key"),t.onabort=function(a){a.preventDefault(),a.stopPropagation(),r(!1)},t.oncomplete=function(){var a=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);r(n||!a||parseInt(a[1],10)>=43)}}).catch(function(){return!1})}function N(e){return typeof W=="boolean"?h.resolve(W):R(e).then(function(r){return W=r,W})}function J(e){var r=M[e.name],t={};t.promise=new h(function(o,a){t.resolve=o,t.reject=a}),r.deferredOperations.push(t),r.dbReady?r.dbReady=r.dbReady.then(function(){return t.promise}):r.dbReady=t.promise}function F(e){var r=M[e.name],t=r.deferredOperations.pop();if(t)return t.resolve(),t.promise}function $(e,r){var t=M[e.name],o=t.deferredOperations.pop();if(o)return o.reject(r),o.promise}function k(e,r){return new h(function(t,o){if(M[e.name]=M[e.name]||Pe(),e.db)if(r)J(e),e.db.close();else return t(e.db);var a=[e.name];r&&a.push(e.version);var n=I.open.apply(I,a);r&&(n.onupgradeneeded=function(i){var c=n.result;try{c.createObjectStore(e.storeName),i.oldVersion<=1&&c.createObjectStore(j)}catch(l){if(l.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+i.oldVersion+" to version "+i.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw l}}),n.onerror=function(i){i.preventDefault(),o(n.error)},n.onsuccess=function(){var i=n.result;i.onversionchange=function(c){c.target.close()},t(i),F(e)}})}function Y(e){return k(e,!1)}function ee(e){return k(e,!0)}function ae(e,r){if(!e.db)return!0;var t=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,a=e.version>e.db.version;if(o&&(e.version!==r&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),a||t){if(t){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}function ve(e){return new h(function(r,t){var o=new FileReader;o.onerror=t,o.onloadend=function(a){var n=btoa(a.target.result||"");r({__local_forage_encoded_blob:!0,data:n,type:e.type})},o.readAsBinaryString(e)})}function q(e){var r=D(atob(e.data));return L([r],{type:e.type})}function Ne(e){return e&&e.__local_forage_encoded_blob}function pt(e){var r=this,t=r._initReady().then(function(){var o=M[r._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return P(t,e,e),t}function yt(e){J(e);for(var r=M[e.name],t=r.forages,o=0;o<t.length;o++){var a=t[o];a._dbInfo.db&&(a._dbInfo.db.close(),a._dbInfo.db=null)}return e.db=null,Y(e).then(function(n){return e.db=n,ae(e)?ee(e):n}).then(function(n){e.db=r.db=n;for(var i=0;i<t.length;i++)t[i]._dbInfo.db=n}).catch(function(n){throw $(e,n),n})}function X(e,r,t,o){o===void 0&&(o=1);try{var a=e.db.transaction(e.storeName,r);t(null,a)}catch(n){if(o>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return h.resolve().then(function(){if(!e.db||n.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),ee(e)}).then(function(){return yt(e).then(function(){X(e,r,t,o-1)})}).catch(t);t(n)}}function Pe(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function bt(e){var r=this,t={db:null};if(e)for(var o in e)t[o]=e[o];var a=M[t.name];a||(a=Pe(),M[t.name]=a),a.forages.push(r),r._initReady||(r._initReady=r.ready,r.ready=pt);var n=[];function i(){return h.resolve()}for(var c=0;c<a.forages.length;c++){var l=a.forages[c];l!==r&&n.push(l._initReady().catch(i))}var d=a.forages.slice(0);return h.all(n).then(function(){return t.db=a.db,Y(t)}).then(function(v){return t.db=v,ae(t,r._defaultConfig.version)?ee(t):v}).then(function(v){t.db=a.db=v,r._dbInfo=t;for(var y=0;y<d.length;y++){var E=d[y];E!==r&&(E._dbInfo.db=t.db,E._dbInfo.version=t.version)}})}function wt(e,r){var t=this;e=U(e);var o=new h(function(a,n){t.ready().then(function(){X(t._dbInfo,H,function(i,c){if(i)return n(i);try{var l=c.objectStore(t._dbInfo.storeName),d=l.get(e);d.onsuccess=function(){var v=d.result;v===void 0&&(v=null),Ne(v)&&(v=q(v)),a(v)},d.onerror=function(){n(d.error)}}catch(v){n(v)}})}).catch(n)});return S(o,r),o}function _t(e,r){var t=this,o=new h(function(a,n){t.ready().then(function(){X(t._dbInfo,H,function(i,c){if(i)return n(i);try{var l=c.objectStore(t._dbInfo.storeName),d=l.openCursor(),v=1;d.onsuccess=function(){var y=d.result;if(y){var E=y.value;Ne(E)&&(E=q(E));var O=e(E,y.key,v++);O!==void 0?a(O):y.continue()}else a()},d.onerror=function(){n(d.error)}}catch(y){n(y)}})}).catch(n)});return S(o,r),o}function St(e,r,t){var o=this;e=U(e);var a=new h(function(n,i){var c;o.ready().then(function(){return c=o._dbInfo,de.call(r)==="[object Blob]"?N(c.db).then(function(l){return l?r:ve(r)}):r}).then(function(l){X(o._dbInfo,m,function(d,v){if(d)return i(d);try{var y=v.objectStore(o._dbInfo.storeName);l===null&&(l=void 0);var E=y.put(l,e);v.oncomplete=function(){l===void 0&&(l=null),n(l)},v.onabort=v.onerror=function(){var O=E.error?E.error:E.transaction.error;i(O)}}catch(O){i(O)}})}).catch(i)});return S(a,t),a}function It(e,r){var t=this;e=U(e);var o=new h(function(a,n){t.ready().then(function(){X(t._dbInfo,m,function(i,c){if(i)return n(i);try{var l=c.objectStore(t._dbInfo.storeName),d=l.delete(e);c.oncomplete=function(){a()},c.onerror=function(){n(d.error)},c.onabort=function(){var v=d.error?d.error:d.transaction.error;n(v)}}catch(v){n(v)}})}).catch(n)});return S(o,r),o}function xt(e){var r=this,t=new h(function(o,a){r.ready().then(function(){X(r._dbInfo,m,function(n,i){if(n)return a(n);try{var c=i.objectStore(r._dbInfo.storeName),l=c.clear();i.oncomplete=function(){o()},i.onabort=i.onerror=function(){var d=l.error?l.error:l.transaction.error;a(d)}}catch(d){a(d)}})}).catch(a)});return S(t,e),t}function Et(e){var r=this,t=new h(function(o,a){r.ready().then(function(){X(r._dbInfo,H,function(n,i){if(n)return a(n);try{var c=i.objectStore(r._dbInfo.storeName),l=c.count();l.onsuccess=function(){o(l.result)},l.onerror=function(){a(l.error)}}catch(d){a(d)}})}).catch(a)});return S(t,e),t}function Rt(e,r){var t=this,o=new h(function(a,n){if(e<0){a(null);return}t.ready().then(function(){X(t._dbInfo,H,function(i,c){if(i)return n(i);try{var l=c.objectStore(t._dbInfo.storeName),d=!1,v=l.openKeyCursor();v.onsuccess=function(){var y=v.result;if(!y){a(null);return}e===0||d?a(y.key):(d=!0,y.advance(e))},v.onerror=function(){n(v.error)}}catch(y){n(y)}})}).catch(n)});return S(o,r),o}function At(e){var r=this,t=new h(function(o,a){r.ready().then(function(){X(r._dbInfo,H,function(n,i){if(n)return a(n);try{var c=i.objectStore(r._dbInfo.storeName),l=c.openKeyCursor(),d=[];l.onsuccess=function(){var v=l.result;if(!v){o(d);return}d.push(v.key),v.continue()},l.onerror=function(){a(l.error)}}catch(v){a(v)}})}).catch(a)});return S(t,e),t}function Dt(e,r){r=V.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o=this,a;if(!e.name)a=h.reject("Invalid arguments");else{var n=e.name===t.name&&o._dbInfo.db,i=n?h.resolve(o._dbInfo.db):Y(e).then(function(c){var l=M[e.name],d=l.forages;l.db=c;for(var v=0;v<d.length;v++)d[v]._dbInfo.db=c;return c});e.storeName?a=i.then(function(c){if(c.objectStoreNames.contains(e.storeName)){var l=c.version+1;J(e);var d=M[e.name],v=d.forages;c.close();for(var y=0;y<v.length;y++){var E=v[y];E._dbInfo.db=null,E._dbInfo.version=l}var O=new h(function(T,B){var C=I.open(e.name,l);C.onerror=function(K){var re=C.result;re.close(),B(K)},C.onupgradeneeded=function(){var K=C.result;K.deleteObjectStore(e.storeName)},C.onsuccess=function(){var K=C.result;K.close(),T(K)}});return O.then(function(T){d.db=T;for(var B=0;B<v.length;B++){var C=v[B];C._dbInfo.db=T,F(C._dbInfo)}}).catch(function(T){throw($(e,T)||h.resolve()).catch(function(){}),T})}}):a=i.then(function(c){J(e);var l=M[e.name],d=l.forages;c.close();for(var v=0;v<d.length;v++){var y=d[v];y._dbInfo.db=null}var E=new h(function(O,T){var B=I.deleteDatabase(e.name);B.onerror=function(){var C=B.result;C&&C.close(),T(B.error)},B.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},B.onsuccess=function(){var C=B.result;C&&C.close(),O(C)}});return E.then(function(O){l.db=O;for(var T=0;T<d.length;T++){var B=d[T];F(B._dbInfo)}}).catch(function(O){throw($(e,O)||h.resolve()).catch(function(){}),O})})}return S(a,r),a}var Ot={_driver:"asyncStorage",_initStorage:bt,_support:A(),iterate:_t,getItem:wt,setItem:St,removeItem:It,clear:xt,length:Et,key:Rt,keys:At,dropInstance:Dt};function Lt(){return typeof openDatabase=="function"}var z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Tt="~~local_forage_type~",Ce=/^~~local_forage_type~([^~]+)~/,ie="__lfsc__:",he=ie.length,me="arbf",ge="blob",Be="si08",Ue="ui08",je="uic8",Me="si16",Je="si32",Fe="ur16",$e="ui32",ke="fl32",Ke="fl64",Ve=he+me.length,We=Object.prototype.toString;function Ye(e){var r=e.length*.75,t=e.length,o,a=0,n,i,c,l;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);var d=new ArrayBuffer(r),v=new Uint8Array(d);for(o=0;o<t;o+=4)n=z.indexOf(e[o]),i=z.indexOf(e[o+1]),c=z.indexOf(e[o+2]),l=z.indexOf(e[o+3]),v[a++]=n<<2|i>>4,v[a++]=(i&15)<<4|c>>2,v[a++]=(c&3)<<6|l&63;return d}function pe(e){var r=new Uint8Array(e),t="",o;for(o=0;o<r.length;o+=3)t+=z[r[o]>>2],t+=z[(r[o]&3)<<4|r[o+1]>>4],t+=z[(r[o+1]&15)<<2|r[o+2]>>6],t+=z[r[o+2]&63];return r.length%3===2?t=t.substring(0,t.length-1)+"=":r.length%3===1&&(t=t.substring(0,t.length-2)+"=="),t}function Nt(e,r){var t="";if(e&&(t=We.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&We.call(e.buffer)==="[object ArrayBuffer]")){var o,a=ie;e instanceof ArrayBuffer?(o=e,a+=me):(o=e.buffer,t==="[object Int8Array]"?a+=Be:t==="[object Uint8Array]"?a+=Ue:t==="[object Uint8ClampedArray]"?a+=je:t==="[object Int16Array]"?a+=Me:t==="[object Uint16Array]"?a+=Fe:t==="[object Int32Array]"?a+=Je:t==="[object Uint32Array]"?a+=$e:t==="[object Float32Array]"?a+=ke:t==="[object Float64Array]"?a+=Ke:r(new Error("Failed to get type for BinaryArray"))),r(a+pe(o))}else if(t==="[object Blob]"){var n=new FileReader;n.onload=function(){var i=Tt+e.type+"~"+pe(this.result);r(ie+ge+i)},n.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(i){console.error("Couldn't convert value into a JSON string: ",e),r(null,i)}}function Pt(e){if(e.substring(0,he)!==ie)return JSON.parse(e);var r=e.substring(Ve),t=e.substring(he,Ve),o;if(t===ge&&Ce.test(r)){var a=r.match(Ce);o=a[1],r=r.substring(a[0].length)}var n=Ye(r);switch(t){case me:return n;case ge:return L([n],{type:o});case Be:return new Int8Array(n);case Ue:return new Uint8Array(n);case je:return new Uint8ClampedArray(n);case Me:return new Int16Array(n);case Fe:return new Uint16Array(n);case Je:return new Int32Array(n);case $e:return new Uint32Array(n);case ke:return new Float32Array(n);case Ke:return new Float64Array(n);default:throw new Error("Unkown type: "+t)}}var ye={serialize:Nt,deserialize:Pt,stringToBuffer:Ye,bufferToString:pe};function Xe(e,r,t,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+r.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],t,o)}function Ct(e){var r=this,t={db:null};if(e)for(var o in e)t[o]=typeof e[o]!="string"?e[o].toString():e[o];var a=new h(function(n,i){try{t.db=openDatabase(t.name,String(t.version),t.description,t.size)}catch(c){return i(c)}t.db.transaction(function(c){Xe(c,t,function(){r._dbInfo=t,n()},function(l,d){i(d)})},i)});return t.serializer=ye,a}function G(e,r,t,o,a,n){e.executeSql(t,o,a,function(i,c){c.code===c.SYNTAX_ERR?i.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[r.storeName],function(l,d){d.rows.length?n(l,c):Xe(l,r,function(){l.executeSql(t,o,a,n)},n)},n):n(i,c)},n)}function Bt(e,r){var t=this;e=U(e);var o=new h(function(a,n){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(c){G(c,i,"SELECT * FROM "+i.storeName+" WHERE key = ? LIMIT 1",[e],function(l,d){var v=d.rows.length?d.rows.item(0).value:null;v&&(v=i.serializer.deserialize(v)),a(v)},function(l,d){n(d)})})}).catch(n)});return S(o,r),o}function Ut(e,r){var t=this,o=new h(function(a,n){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(c){G(c,i,"SELECT * FROM "+i.storeName,[],function(l,d){for(var v=d.rows,y=v.length,E=0;E<y;E++){var O=v.item(E),T=O.value;if(T&&(T=i.serializer.deserialize(T)),T=e(T,O.key,E+1),T!==void 0){a(T);return}}a()},function(l,d){n(d)})})}).catch(n)});return S(o,r),o}function ze(e,r,t,o){var a=this;e=U(e);var n=new h(function(i,c){a.ready().then(function(){r===void 0&&(r=null);var l=r,d=a._dbInfo;d.serializer.serialize(r,function(v,y){y?c(y):d.db.transaction(function(E){G(E,d,"INSERT OR REPLACE INTO "+d.storeName+" (key, value) VALUES (?, ?)",[e,v],function(){i(l)},function(O,T){c(T)})},function(E){if(E.code===E.QUOTA_ERR){if(o>0){i(ze.apply(a,[e,l,t,o-1]));return}c(E)}})})}).catch(c)});return S(n,t),n}function jt(e,r,t){return ze.apply(this,[e,r,t,1])}function Mt(e,r){var t=this;e=U(e);var o=new h(function(a,n){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(c){G(c,i,"DELETE FROM "+i.storeName+" WHERE key = ?",[e],function(){a()},function(l,d){n(d)})})}).catch(n)});return S(o,r),o}function Jt(e){var r=this,t=new h(function(o,a){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(i){G(i,n,"DELETE FROM "+n.storeName,[],function(){o()},function(c,l){a(l)})})}).catch(a)});return S(t,e),t}function Ft(e){var r=this,t=new h(function(o,a){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(i){G(i,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(c,l){var d=l.rows.item(0).c;o(d)},function(c,l){a(l)})})}).catch(a)});return S(t,e),t}function $t(e,r){var t=this,o=new h(function(a,n){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(c){G(c,i,"SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[e+1],function(l,d){var v=d.rows.length?d.rows.item(0).key:null;a(v)},function(l,d){n(d)})})}).catch(n)});return S(o,r),o}function kt(e){var r=this,t=new h(function(o,a){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(i){G(i,n,"SELECT key FROM "+n.storeName,[],function(c,l){for(var d=[],v=0;v<l.rows.length;v++)d.push(l.rows.item(v).key);o(d)},function(c,l){a(l)})})}).catch(a)});return S(t,e),t}function Kt(e){return new h(function(r,t){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(a,n){for(var i=[],c=0;c<n.rows.length;c++)i.push(n.rows.item(c).name);r({db:e,storeNames:i})},function(a,n){t(n)})},function(o){t(o)})})}function Vt(e,r){r=V.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o=this,a;return e.name?a=new h(function(n){var i;e.name===t.name?i=o._dbInfo.db:i=openDatabase(e.name,"","",0),e.storeName?n({db:i,storeNames:[e.storeName]}):n(Kt(i))}).then(function(n){return new h(function(i,c){n.db.transaction(function(l){function d(O){return new h(function(T,B){l.executeSql("DROP TABLE IF EXISTS "+O,[],function(){T()},function(C,K){B(K)})})}for(var v=[],y=0,E=n.storeNames.length;y<E;y++)v.push(d(n.storeNames[y]));h.all(v).then(function(){i()}).catch(function(O){c(O)})},function(l){c(l)})})}):a=h.reject("Invalid arguments"),S(a,r),a}var Wt={_driver:"webSQLStorage",_initStorage:Ct,_support:Lt(),iterate:Ut,getItem:Bt,setItem:jt,removeItem:Mt,clear:Jt,length:Ft,key:$t,keys:kt,dropInstance:Vt};function Yt(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}function Ge(e,r){var t=e.name+"/";return e.storeName!==r.storeName&&(t+=e.storeName+"/"),t}function Xt(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(r){return!0}}function zt(){return!Xt()||localStorage.length>0}function Gt(e){var r=this,t={};if(e)for(var o in e)t[o]=e[o];return t.keyPrefix=Ge(e,r._defaultConfig),zt()?(r._dbInfo=t,t.serializer=ye,h.resolve()):h.reject()}function Ht(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo.keyPrefix,a=localStorage.length-1;a>=0;a--){var n=localStorage.key(a);n.indexOf(o)===0&&localStorage.removeItem(n)}});return S(t,e),t}function Qt(e,r){var t=this;e=U(e);var o=t.ready().then(function(){var a=t._dbInfo,n=localStorage.getItem(a.keyPrefix+e);return n&&(n=a.serializer.deserialize(n)),n});return S(o,r),o}function qt(e,r){var t=this,o=t.ready().then(function(){for(var a=t._dbInfo,n=a.keyPrefix,i=n.length,c=localStorage.length,l=1,d=0;d<c;d++){var v=localStorage.key(d);if(v.indexOf(n)===0){var y=localStorage.getItem(v);if(y&&(y=a.serializer.deserialize(y)),y=e(y,v.substring(i),l++),y!==void 0)return y}}});return S(o,r),o}function Zt(e,r){var t=this,o=t.ready().then(function(){var a=t._dbInfo,n;try{n=localStorage.key(e)}catch(i){n=null}return n&&(n=n.substring(a.keyPrefix.length)),n});return S(o,r),o}function er(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo,a=localStorage.length,n=[],i=0;i<a;i++){var c=localStorage.key(i);c.indexOf(o.keyPrefix)===0&&n.push(c.substring(o.keyPrefix.length))}return n});return S(t,e),t}function tr(e){var r=this,t=r.keys().then(function(o){return o.length});return S(t,e),t}function rr(e,r){var t=this;e=U(e);var o=t.ready().then(function(){var a=t._dbInfo;localStorage.removeItem(a.keyPrefix+e)});return S(o,r),o}function nr(e,r,t){var o=this;e=U(e);var a=o.ready().then(function(){r===void 0&&(r=null);var n=r;return new h(function(i,c){var l=o._dbInfo;l.serializer.serialize(r,function(d,v){if(v)c(v);else try{localStorage.setItem(l.keyPrefix+e,d),i(n)}catch(y){(y.name==="QuotaExceededError"||y.name==="NS_ERROR_DOM_QUOTA_REACHED")&&c(y),c(y)}})})});return S(a,t),a}function or(e,r){if(r=V.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var t=this.config();e.name=e.name||t.name,e.storeName=e.storeName||t.storeName}var o=this,a;return e.name?a=new h(function(n){e.storeName?n(Ge(e,o._defaultConfig)):n(e.name+"/")}).then(function(n){for(var i=localStorage.length-1;i>=0;i--){var c=localStorage.key(i);c.indexOf(n)===0&&localStorage.removeItem(c)}}):a=h.reject("Invalid arguments"),S(a,r),a}var ar={_driver:"localStorageWrapper",_initStorage:Gt,_support:Yt(),iterate:qt,getItem:Qt,setItem:nr,removeItem:rr,clear:Ht,length:tr,key:Zt,keys:er,dropInstance:or},ir=function(r,t){return r===t||typeof r=="number"&&typeof t=="number"&&isNaN(r)&&isNaN(t)},sr=function(r,t){for(var o=r.length,a=0;a<o;){if(ir(r[a],t))return!0;a++}return!1},He=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},te={},Qe={},Z={INDEXEDDB:Ot,WEBSQL:Wt,LOCALSTORAGE:ar},ur=[Z.INDEXEDDB._driver,Z.WEBSQL._driver,Z.LOCALSTORAGE._driver],se=["dropInstance"],be=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(se),cr={description:"",driver:ur.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function fr(e,r){e[r]=function(){var t=arguments;return e.ready().then(function(){return e[r].apply(e,t)})}}function we(){for(var e=1;e<arguments.length;e++){var r=arguments[e];if(r)for(var t in r)r.hasOwnProperty(t)&&(He(r[t])?arguments[0][t]=r[t].slice():arguments[0][t]=r[t])}return arguments[0]}var lr=function(){function e(r){x(this,e);for(var t in Z)if(Z.hasOwnProperty(t)){var o=Z[t],a=o._driver;this[t]=a,te[a]||this.defineDriver(o)}this._defaultConfig=we({},cr),this._config=we({},this._defaultConfig,r),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(t){if((typeof t>"u"?"undefined":b(t))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var o in t){if(o==="storeName"&&(t[o]=t[o].replace(/\W/g,"_")),o==="version"&&typeof t[o]!="number")return new Error("Database version must be a number.");this._config[o]=t[o]}return"driver"in t&&t.driver?this.setDriver(this._config.driver):!0}else return typeof t=="string"?this._config[t]:this._config},e.prototype.defineDriver=function(t,o,a){var n=new h(function(i,c){try{var l=t._driver,d=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver){c(d);return}for(var v=be.concat("_initStorage"),y=0,E=v.length;y<E;y++){var O=v[y],T=!sr(se,O);if((T||t[O])&&typeof t[O]!="function"){c(d);return}}var B=function(){for(var re=function(hr){return function(){var mr=new Error("Method "+hr+" is not implemented by the current driver"),qe=h.reject(mr);return S(qe,arguments[arguments.length-1]),qe}},_e=0,vr=se.length;_e<vr;_e++){var Se=se[_e];t[Se]||(t[Se]=re(Se))}};B();var C=function(re){te[l]&&console.info("Redefining LocalForage driver: "+l),te[l]=t,Qe[l]=re,i()};"_support"in t?t._support&&typeof t._support=="function"?t._support().then(C,c):C(!!t._support):C(!0)}catch(K){c(K)}});return P(n,o,a),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(t,o,a){var n=te[t]?h.resolve(te[t]):h.reject(new Error("Driver not found."));return P(n,o,a),n},e.prototype.getSerializer=function(t){var o=h.resolve(ye);return P(o,t),o},e.prototype.ready=function(t){var o=this,a=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return P(a,t,t),a},e.prototype.setDriver=function(t,o,a){var n=this;He(t)||(t=[t]);var i=this._getSupportedDrivers(t);function c(){n._config.driver=n.driver()}function l(y){return n._extend(y),c(),n._ready=n._initStorage(n._config),n._ready}function d(y){return function(){var E=0;function O(){for(;E<y.length;){var T=y[E];return E++,n._dbInfo=null,n._ready=null,n.getDriver(T).then(l).catch(O)}c();var B=new Error("No available storage method found.");return n._driverSet=h.reject(B),n._driverSet}return O()}}var v=this._driverSet!==null?this._driverSet.catch(function(){return h.resolve()}):h.resolve();return this._driverSet=v.then(function(){var y=i[0];return n._dbInfo=null,n._ready=null,n.getDriver(y).then(function(E){n._driver=E._driver,c(),n._wrapLibraryMethodsWithReady(),n._initDriver=d(i)})}).catch(function(){c();var y=new Error("No available storage method found.");return n._driverSet=h.reject(y),n._driverSet}),P(this._driverSet,o,a),this._driverSet},e.prototype.supports=function(t){return!!Qe[t]},e.prototype._extend=function(t){we(this,t)},e.prototype._getSupportedDrivers=function(t){for(var o=[],a=0,n=t.length;a<n;a++){var i=t[a];this.supports(i)&&o.push(i)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var t=0,o=be.length;t<o;t++)fr(this,be[t])},e.prototype.createInstance=function(t){return new e(t)},e}(),dr=new lr;g.exports=dr},{3:3}]},{},[4])(4)})});var Ie=u=>{var x,p,I;let s=u.split("-")[1];s&&(u=u.replace(`-${s}`,""));let f=u.split("+")[1];f&&(u=u.replace(`+${f}`,""));let w=u.split(".").slice(0,3),[g,_,b]=[(x=w[0])!=null?x:"0",(p=w[1])!=null?p:"0",(I=w[2])!=null?I:"0"];return{major:g,minor:_,patch:b,prerelease:s,build:f}},ce=u=>parseInt(Ie(u).major,10),et=(u,s)=>{let{major:f,minor:w,patch:g}=Ie(u),{major:_,minor:b,patch:x}=Ie(s);return f!==_?f>_?1:-1:w!==b?w>b?1:-1:g!==x?g>x?1:-1:0};var tt="jolibox-sdk-loader-metadata",xe=class{constructor({loaderMetadata:s}={}){this.computeLoaderMetaData=()=>{var g,_;let s=this.currentVersion,f=null;try{if(f=JSON.parse((g=localStorage.getItem(tt))!=null?g:"null"),!f||!f.version)throw new Error("Invalid loader metadata")}catch(b){f=this.defaultMetadata}let w=(_=f==null?void 0:f.version)!=null?_:s;return ce(w)!==ce(s)?f=this.defaultMetadata:et(w,s)<0&&(f=this.defaultMetadata),f};this.loadScript=()=>{if(this.loaderMetadata.syncScriptUrl){let s=new XMLHttpRequest;s.open("GET",this.loaderMetadata.syncScriptUrl,!1),s.send();let f=document.createElement("script");f.type="text/javascript",f.innerHTML=s.responseText,document.head.appendChild(f)}if(this.loaderMetadata.asyncScriptUrl){let s=document.createElement("script");s.type="text/javascript",s.src=this.loaderMetadata.asyncScriptUrl,s.async=!0,document.head.appendChild(s)}};this.fetchUpdateLoaderMetadata=(..._)=>ue(this,[..._],function*(s=this.currentVersion,f=this.loaderMetadata.version,w=(g=>(g=window.JOLIBOX_ENV)!=null?g:"WEB")()){var x,p,I;let b=`${(p=(x=window.joliboxenv)==null?void 0:x.apiBaseURL)!=null?p:"https://api.jolibox.com"}/frontend/js-sdk/loader-metadata`;try{let L=yield(yield fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({installedSDKVersion:s,localSDKVersion:f,env:w})})).json();if(L.code!=="SUCCESS")throw new Error(L.message);this.loaderMetadata=(I=L.data)!=null?I:this.defaultMetadata,localStorage.setItem(tt,JSON.stringify(this.loaderMetadata))}catch(A){console.warn("Failed to fetch loader metadata: ",A)}});console.log("Loading Jolibox SDK..."),this.loaderMetadata=s!=null?s:this.computeLoaderMetaData(),this.loadScript(),this.fetchUpdateLoaderMetadata(),console.log("Jolibox SDK loaded.")}get currentVersion(){return window.__JOLIBOX_LOCAL_SDK_VERSION__}get defaultMetadata(){let s=this.currentVersion,f=ce(s);return{version:s,syncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-sync-sdk@${f}/dist/index.iife.js`,asyncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-async-sdk@${f}/dist/index.iife.js`}}};window.JoliboxSDKLoader=xe;var Ee=class{constructor(){this.init=s=>{window.joliboxsdk._commandPipe.push({cmd:"ads.init",params:s})};this.adConfig=s=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adConfig",params:s})};this.adBreak=s=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adBreak",params:s})};this.adUnit=s=>ue(this,null,function*(){window.joliboxsdk._commandPipe.push({cmd:"ads.adUnit",params:s})})}};window.JoliboxAds=Ee;var Re=class{constructor(){this.trackEvent=(s,f)=>{if(typeof s!="string")throw new Error("eventName must be a string");if(f!==null&&typeof f!="object"&&f!==void 0)throw new Error("extra must be an object or null or undefined");if(f){for(let w in f)if(typeof f[w]=="object")throw new Error("extra must not have nested objects")}window.joliboxsdk._commandPipe.push({cmd:"analytics.trackEvent",params:[s,f]})}}};window.JoliboxAnalytics=Re;var gt=Ir(nt(),1),xr=Object.defineProperty,Oe=(u,s)=>{for(var f in s)xr(u,f,{get:s[f],enumerable:!0})},Q=(u,s,f)=>new Promise((w,g)=>{var _=p=>{try{x(f.next(p))}catch(I){g(I)}},b=p=>{try{x(f.throw(p))}catch(I){g(I)}},x=p=>p.done?w(p.value):Promise.resolve(p.value).then(_,b);x((f=f.apply(u,s)).next())}),ot={};Oe(ot,{ADVERTISING_ID:()=>ct,DEVICE_ID:()=>ut,getAdvertisingId:()=>lt,getAppVersion:()=>st,getDeviceId:()=>ft,getPlatform:()=>it,getStorage:()=>Te,getUtmSource:()=>dt,platform:()=>oe,xUserAgent:()=>vt});var at={};Oe(at,{isValidUUIDV4:()=>Er,uuidv4:()=>Le});var Le=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,u=>{let s=Math.random()*16|0;return(u==="x"?s:s&3|8).toString(16)}),Er=u=>/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i.test(u),oe={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let u=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(u[1],10),parseInt(u[2],10),parseInt(u[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")},it=()=>oe.isiOS?"iOS":oe.isAndroid?"Android":oe.isMac?"Mac":oe.isFacebook?"Facebook":"PC",st=()=>window.__JOLIBOX_LOCAL_SDK_VERSION__,ut="device_id",ct="advertising_id",Te=u=>(localStorage.getItem(u)||localStorage.setItem(u,Le()),localStorage.getItem(u)),ft=()=>Te(ut),lt=()=>Te(ct),Rr=u=>u.charAt(0).toUpperCase()+u.slice(1),dt=()=>{var u;let s=new URLSearchParams(window.location.search);return Rr((u=s.get("utm_source"))!=null?u:"")||"JoliboxSDK"},vt=()=>{let u="JoliboxWebSDK",s=it(),f=navigator.language,w=ft(),g=lt(),_=st();return`${u} (${dt()}${s}; UnknownModel; UnknownSystemVersion; ${f}) uuid/${w} adid/${g} version/${_||""}`},Ar;(Ar=AbortSignal.timeout)!=null||(AbortSignal.timeout=function(u){let s=new AbortController;return setTimeout(()=>s.abort(),u),s.signal});var ht=class{constructor(u){this.xua=vt(),this.getGameId=()=>{var g;return(g=new URLSearchParams(window.location.search).get("gameId"))!=null?g:null},this.getJoliSource=()=>{var g;return(g=new URLSearchParams(window.location.search).get("joliSource"))!=null?g:null};var s,f,w;this.baseUrl=(w=(f=u==null?void 0:u.baseUrl)!=null?f:(s=window.joliboxenv)==null?void 0:s.apiBaseURL)!=null?w:"https://api.jolibox.com"}get(u,s){return Q(this,arguments,function*(f,{query:w,headers:g,timeout:_}){let b=new URLSearchParams(w).toString(),x=`${this.baseUrl}${f}${b?`?${b}`:""}`,p=this.xua,I=this.getJoliSource();return g=Object.assign({},g,p?{"x-user-agent":p}:{},I?{"x-joli-source":I}:{}),yield(yield fetch(x,{method:"GET",headers:g,signal:AbortSignal.timeout(_!=null?_:3e4)})).json()})}post(u,s){return Q(this,arguments,function*(f,{data:w,query:g,headers:_,timeout:b}){let x=new URLSearchParams(g).toString(),p=`${this.baseUrl}${f}${x?`?${x}`:""}`,I=this.xua,A=this.getJoliSource();_=Object.assign({},_,{"Content-Type":"application/json"},I?{"x-user-agent":I}:{},A?{"x-joli-source":A}:{});let L=yield fetch(p,{method:"POST",headers:_,body:JSON.stringify(w),signal:AbortSignal.timeout(b!=null?b:3e4)}),h=L.headers.get("content-type");if(h!=null&&h.includes("application/octet-stream"))try{return L.blob()}catch(S){return yield L.arrayBuffer()}if(h!=null&&h.includes("multipart/form-data")||h!=null&&h.includes("application/x-www-form-urlencoded"))try{return L.formData()}catch(S){return yield L.text()}if(h!=null&&h.includes("application/json"))try{return yield L.json()}catch(S){return yield L.text()}return L})}put(u,s){return Q(this,arguments,function*(f,{data:w,query:g,headers:_}){try{let b=new URLSearchParams(g).toString(),x=`${this.baseUrl}${f}${b?`?${b}`:""}`,p=this.xua,I=this.getJoliSource();_=Object.assign({},_,{"Content-Type":"application/json"},p?{"x-user-agent":p}:{},I?{"x-joli-source":I}:{});let A=yield fetch(x,{method:"PUT",headers:_,body:JSON.stringify(w!=null?w:{})});if(!A.ok)throw new Error(`HTTP error! status: ${A.status}`);return yield A.json()}catch(b){throw console.error("Error:",b),b}})}};window.JoliboxHttpClient=ht;var mt={};Oe(mt,{getGameSessionId:()=>Dr});var Dr=()=>{let u=sessionStorage.getItem("gameSessionId");return u||(u=Le(),sessionStorage.setItem("gameSessionId",u)),u},fe=class{};fe.xua=ot,fe.session=mt,fe.uuid=at;window.JoliboxUtil=fe;var Or=(u=>(u.LOAD_START="JOLIBOX_RUNTIME_LOAD_START",u.LOAD_FINISHED="JOLIBOX_RUNTIME_LOAD_FINISHED",u.LOAD_PROGRESS="JOLIBOX_RUNTIME_LOAD_PROGRESS",u))(Or||{});window.dispatchEvent(new Event("JOLIBOX_RUNTIME_LOAD_START"));var Lr=class{constructor(){this.loadFinished=()=>{let u=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(u),window.joliboxsdk._commandPipe.push({cmd:"analytics.trackSystemEvent",params:["CallRuntimeLoadFinished"]}),window.JoliTesterBridge&&console.log("joli-content-loaded")},this.notifyLoadProgress=u=>{let s=Math.ceil(u),f=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:s});window.dispatchEvent(f)}}};window.JoliboxRuntime=Lr;var De="INTERNAL_ERR",Tr=class{constructor(){this.getGameId=()=>{var u;return(u=new URLSearchParams(window.location.search).get("gameId"))!=null?u:""},this.getItem=u=>Q(this,null,function*(){try{let{code:s,data:f,message:w}=yield this.httpClient.get(`/api/games/user-storage/${this.gameId}`,{query:{key:u}}),g=f==null?void 0:f.value;return s!=="SUCCESS"&&(g=yield this.gameStore.getItem(u),console.info("[SDK] cloud storage getItem failed, read from localstorage",g)),{code:s,message:w,data:g!=null?g:null}}catch(s){let f=`[SDK] cloud storage getItem internal error: ${s}`;return console.error(f),{code:"INTERNAL_ERR",message:f}}}),this.setItem=(u,s)=>Q(this,null,function*(){var f,w;try{if(!this.isPrimitiveType(s))throw{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: typeof value should be number, string or boolean"};if(u.length>128)throw{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let g=typeof s=="string"?s:String(s);if(u.length+g.length>1024)throw{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"};yield this.gameStore.setItem(u,g);let{code:_,message:b}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}`,{data:{key:u,value:g}});return{code:_,message:b}}catch(g){let _=(f=g.code)!=null?f:De,b=(w=g.message)!=null?w:`${g}`;return console.error(b),{code:_,message:b}}}),this.removeItem=u=>Q(this,null,function*(){try{yield this.gameStore.removeItem(u);let{code:s,message:f}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}/remove`,{data:{key:u}});return{code:s,message:f}}catch(s){let f=`[SDK] cloud storage removeItem error: ${s}`;return console.error(f),{code:De,message:f}}}),this.clear=()=>Q(this,null,function*(){try{yield this.gameStore.clear();let{code:u,message:s}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}/clear`,{});return{code:u,message:s}}catch(u){let s=`[SDK] cloud storage clear error: ${u}`;return console.error(s),{code:De,message:s}}}),this.gameId=this.getGameId(),this.httpClient=new ht,this.gameStore=gt.default.createInstance({name:this.gameId.length?this.gameId:"default"})}isPrimitiveType(u){return typeof u=="string"||typeof u=="number"||typeof u=="boolean"}};window.JoliboxCloudStorage=Tr;window.__JOLIBOX_LOCAL_SDK_VERSION__="1.1.2";var le=class{constructor({useRuntimeSDK:s=!0,loaderConfig:f,joliboxEnv:w,testAdsMode:g,apiBaseURL:_}={}){this.hostToApiMap={default:{stg:"https://stg-api.jolibox.com",prod:"https://api.jolibox.com"},"oss.jolibox.com":{stg:"https://stg-api.jolibox.com",prod:"https://api.jolibox.com"},"oss.pico-game.com":{stg:"https://stg-api.pico-game.com",prod:"https://api.pico-game.com"}};this.setJoliboxEnv=(s,f,w)=>{var h,S;let _=typeof window<"u"?new URLSearchParams(window.location.search):null,b=(_==null?void 0:_.get("testAdsMode"))==="true",x=f!=null?f:b,p=_==null?void 0:_.get("joliboxEnv"),I=(h=s!=null?s:p)!=null?h:"production",A=_==null?void 0:_.get("apiBaseURL"),L;if(w)L=w;else if(A)L=A;else{let P=(S=this.hostToApiMap[window.location.host])!=null?S:this.hostToApiMap.default;L=I==="staging"?P.stg:P.prod}window.joliboxenv={joliboxEnv:I,testAdsMode:x,apiBaseURL:L}};var b,x,p,I,A;this.setJoliboxEnv(w,g,_),s&&window.joliboxsdk?(this.loader=(b=window.joliboxsdk.loader)!=null?b:new window.JoliboxSDKLoader(f),this.ads=(x=window.joliboxsdk.ads)!=null?x:new window.JoliboxAds,this.anaytics=(p=window.joliboxsdk.anaytics)!=null?p:new window.JoliboxAnalytics,this.runtime=(I=window.joliboxsdk.runtime)!=null?I:new window.JoliboxRuntime,this.storage=(A=window.joliboxsdk.storage)!=null?A:new window.JoliboxCloudStorage):(window.joliboxsdk||(window.joliboxsdk={_commandPipe:[]}),this.loader=new window.JoliboxSDKLoader(f),this.ads=new window.JoliboxAds,this.anaytics=new window.JoliboxAnalytics,this.runtime=new window.JoliboxRuntime,this.storage=new window.JoliboxCloudStorage,window.joliboxsdk=Object.assign(this,window.joliboxsdk)),window.joliboxsdk._commandPipe||(window.joliboxsdk._commandPipe=[])}};window.JoliboxSDK||(window.JoliboxSDK=le);var Qr=le;})();
1
+ "use strict";(()=>{var gr=Object.create;var Ze=Object.defineProperty;var pr=Object.getOwnPropertyDescriptor;var yr=Object.getOwnPropertyNames;var br=Object.getPrototypeOf,wr=Object.prototype.hasOwnProperty;var ne=(u=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(u,{get:(s,f)=>(typeof require<"u"?require:s)[f]}):u)(function(u){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+u+'" is not supported')});var _r=(u,s)=>()=>(s||u((s={exports:{}}).exports,s),s.exports);var Sr=(u,s,f,w)=>{if(s&&typeof s=="object"||typeof s=="function")for(let g of yr(s))!wr.call(u,g)&&g!==f&&Ze(u,g,{get:()=>s[g],enumerable:!(w=pr(s,g))||w.enumerable});return u};var Ir=(u,s,f)=>(f=u!=null?gr(br(u)):{},Sr(s||!u||!u.__esModule?Ze(f,"default",{value:u,enumerable:!0}):f,u));var ue=(u,s,f)=>new Promise((w,g)=>{var _=p=>{try{x(f.next(p))}catch(I){g(I)}},b=p=>{try{x(f.throw(p))}catch(I){g(I)}},x=p=>p.done?w(p.value):Promise.resolve(p.value).then(_,b);x((f=f.apply(u,s)).next())});var nt=_r((rt,Ae)=>{"use strict";(function(u){if(typeof rt=="object"&&typeof Ae<"u")Ae.exports=u();else if(typeof define=="function"&&define.amd)define([],u);else{var s;typeof window<"u"?s=window:typeof global<"u"?s=global:typeof self<"u"?s=self:s=this,s.localforage=u()}})(function(){var u,s,f;return function w(g,_,b){function x(A,L){if(!_[A]){if(!g[A]){var h=typeof ne=="function"&&ne;if(!L&&h)return h(A,!0);if(p)return p(A,!0);var S=new Error("Cannot find module '"+A+"'");throw S.code="MODULE_NOT_FOUND",S}var P=_[A]={exports:{}};g[A][0].call(P.exports,function(U){var V=g[A][1][U];return x(V||U)},P,P.exports,w,g,_,b)}return _[A].exports}for(var p=typeof ne=="function"&&ne,I=0;I<b.length;I++)x(b[I]);return x}({1:[function(w,g,_){(function(b){"use strict";var x=b.MutationObserver||b.WebKitMutationObserver,p;if(x){var I=0,A=new x(U),L=b.document.createTextNode("");A.observe(L,{characterData:!0}),p=function(){L.data=I=++I%2}}else if(!b.setImmediate&&typeof b.MessageChannel<"u"){var h=new b.MessageChannel;h.port1.onmessage=U,p=function(){h.port2.postMessage(0)}}else"document"in b&&"onreadystatechange"in b.document.createElement("script")?p=function(){var j=b.document.createElement("script");j.onreadystatechange=function(){U(),j.onreadystatechange=null,j.parentNode.removeChild(j),j=null},b.document.documentElement.appendChild(j)}:p=function(){setTimeout(U,0)};var S,P=[];function U(){S=!0;for(var j,W,M=P.length;M;){for(W=P,P=[],j=-1;++j<M;)W[j]();M=P.length}S=!1}g.exports=V;function V(j){P.push(j)===1&&!S&&p()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(w,g,_){"use strict";var b=w(1);function x(){}var p={},I=["REJECTED"],A=["FULFILLED"],L=["PENDING"];g.exports=h;function h(m){if(typeof m!="function")throw new TypeError("resolver must be a function");this.state=L,this.queue=[],this.outcome=void 0,m!==x&&V(this,m)}h.prototype.catch=function(m){return this.then(null,m)},h.prototype.then=function(m,D){if(typeof m!="function"&&this.state===A||typeof D!="function"&&this.state===I)return this;var R=new this.constructor(x);if(this.state!==L){var N=this.state===A?m:D;P(R,N,this.outcome)}else this.queue.push(new S(R,m,D));return R};function S(m,D,R){this.promise=m,typeof D=="function"&&(this.onFulfilled=D,this.callFulfilled=this.otherCallFulfilled),typeof R=="function"&&(this.onRejected=R,this.callRejected=this.otherCallRejected)}S.prototype.callFulfilled=function(m){p.resolve(this.promise,m)},S.prototype.otherCallFulfilled=function(m){P(this.promise,this.onFulfilled,m)},S.prototype.callRejected=function(m){p.reject(this.promise,m)},S.prototype.otherCallRejected=function(m){P(this.promise,this.onRejected,m)};function P(m,D,R){b(function(){var N;try{N=D(R)}catch(J){return p.reject(m,J)}N===m?p.reject(m,new TypeError("Cannot resolve promise with itself")):p.resolve(m,N)})}p.resolve=function(m,D){var R=j(U,D);if(R.status==="error")return p.reject(m,R.value);var N=R.value;if(N)V(m,N);else{m.state=A,m.outcome=D;for(var J=-1,F=m.queue.length;++J<F;)m.queue[J].callFulfilled(D)}return m},p.reject=function(m,D){m.state=I,m.outcome=D;for(var R=-1,N=m.queue.length;++R<N;)m.queue[R].callRejected(D);return m};function U(m){var D=m&&m.then;if(m&&(typeof m=="object"||typeof m=="function")&&typeof D=="function")return function(){D.apply(m,arguments)}}function V(m,D){var R=!1;function N(k){R||(R=!0,p.reject(m,k))}function J(k){R||(R=!0,p.resolve(m,k))}function F(){D(J,N)}var $=j(F);$.status==="error"&&N($.value)}function j(m,D){var R={};try{R.value=m(D),R.status="success"}catch(N){R.status="error",R.value=N}return R}h.resolve=W;function W(m){return m instanceof this?m:p.resolve(new this(x),m)}h.reject=M;function M(m){var D=new this(x);return p.reject(D,m)}h.all=de;function de(m){var D=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var R=m.length,N=!1;if(!R)return this.resolve([]);for(var J=new Array(R),F=0,$=-1,k=new this(x);++$<R;)Y(m[$],$);return k;function Y(ee,ae){D.resolve(ee).then(ve,function(q){N||(N=!0,p.reject(k,q))});function ve(q){J[ae]=q,++F===R&&!N&&(N=!0,p.resolve(k,J))}}}h.race=H;function H(m){var D=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var R=m.length,N=!1;if(!R)return this.resolve([]);for(var J=-1,F=new this(x);++J<R;)$(m[J]);return F;function $(k){D.resolve(k).then(function(Y){N||(N=!0,p.resolve(F,Y))},function(Y){N||(N=!0,p.reject(F,Y))})}}},{1:1}],3:[function(w,g,_){(function(b){"use strict";typeof b.Promise!="function"&&(b.Promise=w(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(w,g,_){"use strict";var b=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function x(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function p(){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(e){return}}var I=p();function A(){try{if(!I||!I.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),r=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||r)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch(t){return!1}}function L(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(n){if(n.name!=="TypeError")throw n;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new t,a=0;a<e.length;a+=1)o.append(e[a]);return o.getBlob(r.type)}}typeof Promise>"u"&&w(3);var h=Promise;function S(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}function P(e,r,t){typeof r=="function"&&e.then(r),typeof t=="function"&&e.catch(t)}function U(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function V(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var j="local-forage-detect-blob-support",W=void 0,M={},de=Object.prototype.toString,H="readonly",m="readwrite";function D(e){for(var r=e.length,t=new ArrayBuffer(r),o=new Uint8Array(t),a=0;a<r;a++)o[a]=e.charCodeAt(a);return t}function R(e){return new h(function(r){var t=e.transaction(j,m),o=L([""]);t.objectStore(j).put(o,"key"),t.onabort=function(a){a.preventDefault(),a.stopPropagation(),r(!1)},t.oncomplete=function(){var a=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);r(n||!a||parseInt(a[1],10)>=43)}}).catch(function(){return!1})}function N(e){return typeof W=="boolean"?h.resolve(W):R(e).then(function(r){return W=r,W})}function J(e){var r=M[e.name],t={};t.promise=new h(function(o,a){t.resolve=o,t.reject=a}),r.deferredOperations.push(t),r.dbReady?r.dbReady=r.dbReady.then(function(){return t.promise}):r.dbReady=t.promise}function F(e){var r=M[e.name],t=r.deferredOperations.pop();if(t)return t.resolve(),t.promise}function $(e,r){var t=M[e.name],o=t.deferredOperations.pop();if(o)return o.reject(r),o.promise}function k(e,r){return new h(function(t,o){if(M[e.name]=M[e.name]||Pe(),e.db)if(r)J(e),e.db.close();else return t(e.db);var a=[e.name];r&&a.push(e.version);var n=I.open.apply(I,a);r&&(n.onupgradeneeded=function(i){var c=n.result;try{c.createObjectStore(e.storeName),i.oldVersion<=1&&c.createObjectStore(j)}catch(l){if(l.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+i.oldVersion+" to version "+i.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw l}}),n.onerror=function(i){i.preventDefault(),o(n.error)},n.onsuccess=function(){var i=n.result;i.onversionchange=function(c){c.target.close()},t(i),F(e)}})}function Y(e){return k(e,!1)}function ee(e){return k(e,!0)}function ae(e,r){if(!e.db)return!0;var t=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,a=e.version>e.db.version;if(o&&(e.version!==r&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),a||t){if(t){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}function ve(e){return new h(function(r,t){var o=new FileReader;o.onerror=t,o.onloadend=function(a){var n=btoa(a.target.result||"");r({__local_forage_encoded_blob:!0,data:n,type:e.type})},o.readAsBinaryString(e)})}function q(e){var r=D(atob(e.data));return L([r],{type:e.type})}function Ne(e){return e&&e.__local_forage_encoded_blob}function pt(e){var r=this,t=r._initReady().then(function(){var o=M[r._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return P(t,e,e),t}function yt(e){J(e);for(var r=M[e.name],t=r.forages,o=0;o<t.length;o++){var a=t[o];a._dbInfo.db&&(a._dbInfo.db.close(),a._dbInfo.db=null)}return e.db=null,Y(e).then(function(n){return e.db=n,ae(e)?ee(e):n}).then(function(n){e.db=r.db=n;for(var i=0;i<t.length;i++)t[i]._dbInfo.db=n}).catch(function(n){throw $(e,n),n})}function X(e,r,t,o){o===void 0&&(o=1);try{var a=e.db.transaction(e.storeName,r);t(null,a)}catch(n){if(o>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return h.resolve().then(function(){if(!e.db||n.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),ee(e)}).then(function(){return yt(e).then(function(){X(e,r,t,o-1)})}).catch(t);t(n)}}function Pe(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function bt(e){var r=this,t={db:null};if(e)for(var o in e)t[o]=e[o];var a=M[t.name];a||(a=Pe(),M[t.name]=a),a.forages.push(r),r._initReady||(r._initReady=r.ready,r.ready=pt);var n=[];function i(){return h.resolve()}for(var c=0;c<a.forages.length;c++){var l=a.forages[c];l!==r&&n.push(l._initReady().catch(i))}var d=a.forages.slice(0);return h.all(n).then(function(){return t.db=a.db,Y(t)}).then(function(v){return t.db=v,ae(t,r._defaultConfig.version)?ee(t):v}).then(function(v){t.db=a.db=v,r._dbInfo=t;for(var y=0;y<d.length;y++){var E=d[y];E!==r&&(E._dbInfo.db=t.db,E._dbInfo.version=t.version)}})}function wt(e,r){var t=this;e=U(e);var o=new h(function(a,n){t.ready().then(function(){X(t._dbInfo,H,function(i,c){if(i)return n(i);try{var l=c.objectStore(t._dbInfo.storeName),d=l.get(e);d.onsuccess=function(){var v=d.result;v===void 0&&(v=null),Ne(v)&&(v=q(v)),a(v)},d.onerror=function(){n(d.error)}}catch(v){n(v)}})}).catch(n)});return S(o,r),o}function _t(e,r){var t=this,o=new h(function(a,n){t.ready().then(function(){X(t._dbInfo,H,function(i,c){if(i)return n(i);try{var l=c.objectStore(t._dbInfo.storeName),d=l.openCursor(),v=1;d.onsuccess=function(){var y=d.result;if(y){var E=y.value;Ne(E)&&(E=q(E));var O=e(E,y.key,v++);O!==void 0?a(O):y.continue()}else a()},d.onerror=function(){n(d.error)}}catch(y){n(y)}})}).catch(n)});return S(o,r),o}function St(e,r,t){var o=this;e=U(e);var a=new h(function(n,i){var c;o.ready().then(function(){return c=o._dbInfo,de.call(r)==="[object Blob]"?N(c.db).then(function(l){return l?r:ve(r)}):r}).then(function(l){X(o._dbInfo,m,function(d,v){if(d)return i(d);try{var y=v.objectStore(o._dbInfo.storeName);l===null&&(l=void 0);var E=y.put(l,e);v.oncomplete=function(){l===void 0&&(l=null),n(l)},v.onabort=v.onerror=function(){var O=E.error?E.error:E.transaction.error;i(O)}}catch(O){i(O)}})}).catch(i)});return S(a,t),a}function It(e,r){var t=this;e=U(e);var o=new h(function(a,n){t.ready().then(function(){X(t._dbInfo,m,function(i,c){if(i)return n(i);try{var l=c.objectStore(t._dbInfo.storeName),d=l.delete(e);c.oncomplete=function(){a()},c.onerror=function(){n(d.error)},c.onabort=function(){var v=d.error?d.error:d.transaction.error;n(v)}}catch(v){n(v)}})}).catch(n)});return S(o,r),o}function xt(e){var r=this,t=new h(function(o,a){r.ready().then(function(){X(r._dbInfo,m,function(n,i){if(n)return a(n);try{var c=i.objectStore(r._dbInfo.storeName),l=c.clear();i.oncomplete=function(){o()},i.onabort=i.onerror=function(){var d=l.error?l.error:l.transaction.error;a(d)}}catch(d){a(d)}})}).catch(a)});return S(t,e),t}function Et(e){var r=this,t=new h(function(o,a){r.ready().then(function(){X(r._dbInfo,H,function(n,i){if(n)return a(n);try{var c=i.objectStore(r._dbInfo.storeName),l=c.count();l.onsuccess=function(){o(l.result)},l.onerror=function(){a(l.error)}}catch(d){a(d)}})}).catch(a)});return S(t,e),t}function Rt(e,r){var t=this,o=new h(function(a,n){if(e<0){a(null);return}t.ready().then(function(){X(t._dbInfo,H,function(i,c){if(i)return n(i);try{var l=c.objectStore(t._dbInfo.storeName),d=!1,v=l.openKeyCursor();v.onsuccess=function(){var y=v.result;if(!y){a(null);return}e===0||d?a(y.key):(d=!0,y.advance(e))},v.onerror=function(){n(v.error)}}catch(y){n(y)}})}).catch(n)});return S(o,r),o}function At(e){var r=this,t=new h(function(o,a){r.ready().then(function(){X(r._dbInfo,H,function(n,i){if(n)return a(n);try{var c=i.objectStore(r._dbInfo.storeName),l=c.openKeyCursor(),d=[];l.onsuccess=function(){var v=l.result;if(!v){o(d);return}d.push(v.key),v.continue()},l.onerror=function(){a(l.error)}}catch(v){a(v)}})}).catch(a)});return S(t,e),t}function Dt(e,r){r=V.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o=this,a;if(!e.name)a=h.reject("Invalid arguments");else{var n=e.name===t.name&&o._dbInfo.db,i=n?h.resolve(o._dbInfo.db):Y(e).then(function(c){var l=M[e.name],d=l.forages;l.db=c;for(var v=0;v<d.length;v++)d[v]._dbInfo.db=c;return c});e.storeName?a=i.then(function(c){if(c.objectStoreNames.contains(e.storeName)){var l=c.version+1;J(e);var d=M[e.name],v=d.forages;c.close();for(var y=0;y<v.length;y++){var E=v[y];E._dbInfo.db=null,E._dbInfo.version=l}var O=new h(function(T,B){var C=I.open(e.name,l);C.onerror=function(K){var re=C.result;re.close(),B(K)},C.onupgradeneeded=function(){var K=C.result;K.deleteObjectStore(e.storeName)},C.onsuccess=function(){var K=C.result;K.close(),T(K)}});return O.then(function(T){d.db=T;for(var B=0;B<v.length;B++){var C=v[B];C._dbInfo.db=T,F(C._dbInfo)}}).catch(function(T){throw($(e,T)||h.resolve()).catch(function(){}),T})}}):a=i.then(function(c){J(e);var l=M[e.name],d=l.forages;c.close();for(var v=0;v<d.length;v++){var y=d[v];y._dbInfo.db=null}var E=new h(function(O,T){var B=I.deleteDatabase(e.name);B.onerror=function(){var C=B.result;C&&C.close(),T(B.error)},B.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},B.onsuccess=function(){var C=B.result;C&&C.close(),O(C)}});return E.then(function(O){l.db=O;for(var T=0;T<d.length;T++){var B=d[T];F(B._dbInfo)}}).catch(function(O){throw($(e,O)||h.resolve()).catch(function(){}),O})})}return S(a,r),a}var Ot={_driver:"asyncStorage",_initStorage:bt,_support:A(),iterate:_t,getItem:wt,setItem:St,removeItem:It,clear:xt,length:Et,key:Rt,keys:At,dropInstance:Dt};function Lt(){return typeof openDatabase=="function"}var z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Tt="~~local_forage_type~",Ce=/^~~local_forage_type~([^~]+)~/,ie="__lfsc__:",he=ie.length,me="arbf",ge="blob",Be="si08",Ue="ui08",je="uic8",Me="si16",Je="si32",Fe="ur16",$e="ui32",ke="fl32",Ke="fl64",Ve=he+me.length,We=Object.prototype.toString;function Ye(e){var r=e.length*.75,t=e.length,o,a=0,n,i,c,l;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);var d=new ArrayBuffer(r),v=new Uint8Array(d);for(o=0;o<t;o+=4)n=z.indexOf(e[o]),i=z.indexOf(e[o+1]),c=z.indexOf(e[o+2]),l=z.indexOf(e[o+3]),v[a++]=n<<2|i>>4,v[a++]=(i&15)<<4|c>>2,v[a++]=(c&3)<<6|l&63;return d}function pe(e){var r=new Uint8Array(e),t="",o;for(o=0;o<r.length;o+=3)t+=z[r[o]>>2],t+=z[(r[o]&3)<<4|r[o+1]>>4],t+=z[(r[o+1]&15)<<2|r[o+2]>>6],t+=z[r[o+2]&63];return r.length%3===2?t=t.substring(0,t.length-1)+"=":r.length%3===1&&(t=t.substring(0,t.length-2)+"=="),t}function Nt(e,r){var t="";if(e&&(t=We.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&We.call(e.buffer)==="[object ArrayBuffer]")){var o,a=ie;e instanceof ArrayBuffer?(o=e,a+=me):(o=e.buffer,t==="[object Int8Array]"?a+=Be:t==="[object Uint8Array]"?a+=Ue:t==="[object Uint8ClampedArray]"?a+=je:t==="[object Int16Array]"?a+=Me:t==="[object Uint16Array]"?a+=Fe:t==="[object Int32Array]"?a+=Je:t==="[object Uint32Array]"?a+=$e:t==="[object Float32Array]"?a+=ke:t==="[object Float64Array]"?a+=Ke:r(new Error("Failed to get type for BinaryArray"))),r(a+pe(o))}else if(t==="[object Blob]"){var n=new FileReader;n.onload=function(){var i=Tt+e.type+"~"+pe(this.result);r(ie+ge+i)},n.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(i){console.error("Couldn't convert value into a JSON string: ",e),r(null,i)}}function Pt(e){if(e.substring(0,he)!==ie)return JSON.parse(e);var r=e.substring(Ve),t=e.substring(he,Ve),o;if(t===ge&&Ce.test(r)){var a=r.match(Ce);o=a[1],r=r.substring(a[0].length)}var n=Ye(r);switch(t){case me:return n;case ge:return L([n],{type:o});case Be:return new Int8Array(n);case Ue:return new Uint8Array(n);case je:return new Uint8ClampedArray(n);case Me:return new Int16Array(n);case Fe:return new Uint16Array(n);case Je:return new Int32Array(n);case $e:return new Uint32Array(n);case ke:return new Float32Array(n);case Ke:return new Float64Array(n);default:throw new Error("Unkown type: "+t)}}var ye={serialize:Nt,deserialize:Pt,stringToBuffer:Ye,bufferToString:pe};function Xe(e,r,t,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+r.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],t,o)}function Ct(e){var r=this,t={db:null};if(e)for(var o in e)t[o]=typeof e[o]!="string"?e[o].toString():e[o];var a=new h(function(n,i){try{t.db=openDatabase(t.name,String(t.version),t.description,t.size)}catch(c){return i(c)}t.db.transaction(function(c){Xe(c,t,function(){r._dbInfo=t,n()},function(l,d){i(d)})},i)});return t.serializer=ye,a}function G(e,r,t,o,a,n){e.executeSql(t,o,a,function(i,c){c.code===c.SYNTAX_ERR?i.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[r.storeName],function(l,d){d.rows.length?n(l,c):Xe(l,r,function(){l.executeSql(t,o,a,n)},n)},n):n(i,c)},n)}function Bt(e,r){var t=this;e=U(e);var o=new h(function(a,n){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(c){G(c,i,"SELECT * FROM "+i.storeName+" WHERE key = ? LIMIT 1",[e],function(l,d){var v=d.rows.length?d.rows.item(0).value:null;v&&(v=i.serializer.deserialize(v)),a(v)},function(l,d){n(d)})})}).catch(n)});return S(o,r),o}function Ut(e,r){var t=this,o=new h(function(a,n){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(c){G(c,i,"SELECT * FROM "+i.storeName,[],function(l,d){for(var v=d.rows,y=v.length,E=0;E<y;E++){var O=v.item(E),T=O.value;if(T&&(T=i.serializer.deserialize(T)),T=e(T,O.key,E+1),T!==void 0){a(T);return}}a()},function(l,d){n(d)})})}).catch(n)});return S(o,r),o}function ze(e,r,t,o){var a=this;e=U(e);var n=new h(function(i,c){a.ready().then(function(){r===void 0&&(r=null);var l=r,d=a._dbInfo;d.serializer.serialize(r,function(v,y){y?c(y):d.db.transaction(function(E){G(E,d,"INSERT OR REPLACE INTO "+d.storeName+" (key, value) VALUES (?, ?)",[e,v],function(){i(l)},function(O,T){c(T)})},function(E){if(E.code===E.QUOTA_ERR){if(o>0){i(ze.apply(a,[e,l,t,o-1]));return}c(E)}})})}).catch(c)});return S(n,t),n}function jt(e,r,t){return ze.apply(this,[e,r,t,1])}function Mt(e,r){var t=this;e=U(e);var o=new h(function(a,n){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(c){G(c,i,"DELETE FROM "+i.storeName+" WHERE key = ?",[e],function(){a()},function(l,d){n(d)})})}).catch(n)});return S(o,r),o}function Jt(e){var r=this,t=new h(function(o,a){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(i){G(i,n,"DELETE FROM "+n.storeName,[],function(){o()},function(c,l){a(l)})})}).catch(a)});return S(t,e),t}function Ft(e){var r=this,t=new h(function(o,a){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(i){G(i,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(c,l){var d=l.rows.item(0).c;o(d)},function(c,l){a(l)})})}).catch(a)});return S(t,e),t}function $t(e,r){var t=this,o=new h(function(a,n){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(c){G(c,i,"SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[e+1],function(l,d){var v=d.rows.length?d.rows.item(0).key:null;a(v)},function(l,d){n(d)})})}).catch(n)});return S(o,r),o}function kt(e){var r=this,t=new h(function(o,a){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(i){G(i,n,"SELECT key FROM "+n.storeName,[],function(c,l){for(var d=[],v=0;v<l.rows.length;v++)d.push(l.rows.item(v).key);o(d)},function(c,l){a(l)})})}).catch(a)});return S(t,e),t}function Kt(e){return new h(function(r,t){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(a,n){for(var i=[],c=0;c<n.rows.length;c++)i.push(n.rows.item(c).name);r({db:e,storeNames:i})},function(a,n){t(n)})},function(o){t(o)})})}function Vt(e,r){r=V.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o=this,a;return e.name?a=new h(function(n){var i;e.name===t.name?i=o._dbInfo.db:i=openDatabase(e.name,"","",0),e.storeName?n({db:i,storeNames:[e.storeName]}):n(Kt(i))}).then(function(n){return new h(function(i,c){n.db.transaction(function(l){function d(O){return new h(function(T,B){l.executeSql("DROP TABLE IF EXISTS "+O,[],function(){T()},function(C,K){B(K)})})}for(var v=[],y=0,E=n.storeNames.length;y<E;y++)v.push(d(n.storeNames[y]));h.all(v).then(function(){i()}).catch(function(O){c(O)})},function(l){c(l)})})}):a=h.reject("Invalid arguments"),S(a,r),a}var Wt={_driver:"webSQLStorage",_initStorage:Ct,_support:Lt(),iterate:Ut,getItem:Bt,setItem:jt,removeItem:Mt,clear:Jt,length:Ft,key:$t,keys:kt,dropInstance:Vt};function Yt(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}function Ge(e,r){var t=e.name+"/";return e.storeName!==r.storeName&&(t+=e.storeName+"/"),t}function Xt(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(r){return!0}}function zt(){return!Xt()||localStorage.length>0}function Gt(e){var r=this,t={};if(e)for(var o in e)t[o]=e[o];return t.keyPrefix=Ge(e,r._defaultConfig),zt()?(r._dbInfo=t,t.serializer=ye,h.resolve()):h.reject()}function Ht(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo.keyPrefix,a=localStorage.length-1;a>=0;a--){var n=localStorage.key(a);n.indexOf(o)===0&&localStorage.removeItem(n)}});return S(t,e),t}function Qt(e,r){var t=this;e=U(e);var o=t.ready().then(function(){var a=t._dbInfo,n=localStorage.getItem(a.keyPrefix+e);return n&&(n=a.serializer.deserialize(n)),n});return S(o,r),o}function qt(e,r){var t=this,o=t.ready().then(function(){for(var a=t._dbInfo,n=a.keyPrefix,i=n.length,c=localStorage.length,l=1,d=0;d<c;d++){var v=localStorage.key(d);if(v.indexOf(n)===0){var y=localStorage.getItem(v);if(y&&(y=a.serializer.deserialize(y)),y=e(y,v.substring(i),l++),y!==void 0)return y}}});return S(o,r),o}function Zt(e,r){var t=this,o=t.ready().then(function(){var a=t._dbInfo,n;try{n=localStorage.key(e)}catch(i){n=null}return n&&(n=n.substring(a.keyPrefix.length)),n});return S(o,r),o}function er(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo,a=localStorage.length,n=[],i=0;i<a;i++){var c=localStorage.key(i);c.indexOf(o.keyPrefix)===0&&n.push(c.substring(o.keyPrefix.length))}return n});return S(t,e),t}function tr(e){var r=this,t=r.keys().then(function(o){return o.length});return S(t,e),t}function rr(e,r){var t=this;e=U(e);var o=t.ready().then(function(){var a=t._dbInfo;localStorage.removeItem(a.keyPrefix+e)});return S(o,r),o}function nr(e,r,t){var o=this;e=U(e);var a=o.ready().then(function(){r===void 0&&(r=null);var n=r;return new h(function(i,c){var l=o._dbInfo;l.serializer.serialize(r,function(d,v){if(v)c(v);else try{localStorage.setItem(l.keyPrefix+e,d),i(n)}catch(y){(y.name==="QuotaExceededError"||y.name==="NS_ERROR_DOM_QUOTA_REACHED")&&c(y),c(y)}})})});return S(a,t),a}function or(e,r){if(r=V.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var t=this.config();e.name=e.name||t.name,e.storeName=e.storeName||t.storeName}var o=this,a;return e.name?a=new h(function(n){e.storeName?n(Ge(e,o._defaultConfig)):n(e.name+"/")}).then(function(n){for(var i=localStorage.length-1;i>=0;i--){var c=localStorage.key(i);c.indexOf(n)===0&&localStorage.removeItem(c)}}):a=h.reject("Invalid arguments"),S(a,r),a}var ar={_driver:"localStorageWrapper",_initStorage:Gt,_support:Yt(),iterate:qt,getItem:Qt,setItem:nr,removeItem:rr,clear:Ht,length:tr,key:Zt,keys:er,dropInstance:or},ir=function(r,t){return r===t||typeof r=="number"&&typeof t=="number"&&isNaN(r)&&isNaN(t)},sr=function(r,t){for(var o=r.length,a=0;a<o;){if(ir(r[a],t))return!0;a++}return!1},He=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},te={},Qe={},Z={INDEXEDDB:Ot,WEBSQL:Wt,LOCALSTORAGE:ar},ur=[Z.INDEXEDDB._driver,Z.WEBSQL._driver,Z.LOCALSTORAGE._driver],se=["dropInstance"],be=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(se),cr={description:"",driver:ur.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function fr(e,r){e[r]=function(){var t=arguments;return e.ready().then(function(){return e[r].apply(e,t)})}}function we(){for(var e=1;e<arguments.length;e++){var r=arguments[e];if(r)for(var t in r)r.hasOwnProperty(t)&&(He(r[t])?arguments[0][t]=r[t].slice():arguments[0][t]=r[t])}return arguments[0]}var lr=function(){function e(r){x(this,e);for(var t in Z)if(Z.hasOwnProperty(t)){var o=Z[t],a=o._driver;this[t]=a,te[a]||this.defineDriver(o)}this._defaultConfig=we({},cr),this._config=we({},this._defaultConfig,r),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(t){if((typeof t>"u"?"undefined":b(t))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var o in t){if(o==="storeName"&&(t[o]=t[o].replace(/\W/g,"_")),o==="version"&&typeof t[o]!="number")return new Error("Database version must be a number.");this._config[o]=t[o]}return"driver"in t&&t.driver?this.setDriver(this._config.driver):!0}else return typeof t=="string"?this._config[t]:this._config},e.prototype.defineDriver=function(t,o,a){var n=new h(function(i,c){try{var l=t._driver,d=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver){c(d);return}for(var v=be.concat("_initStorage"),y=0,E=v.length;y<E;y++){var O=v[y],T=!sr(se,O);if((T||t[O])&&typeof t[O]!="function"){c(d);return}}var B=function(){for(var re=function(hr){return function(){var mr=new Error("Method "+hr+" is not implemented by the current driver"),qe=h.reject(mr);return S(qe,arguments[arguments.length-1]),qe}},_e=0,vr=se.length;_e<vr;_e++){var Se=se[_e];t[Se]||(t[Se]=re(Se))}};B();var C=function(re){te[l]&&console.info("Redefining LocalForage driver: "+l),te[l]=t,Qe[l]=re,i()};"_support"in t?t._support&&typeof t._support=="function"?t._support().then(C,c):C(!!t._support):C(!0)}catch(K){c(K)}});return P(n,o,a),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(t,o,a){var n=te[t]?h.resolve(te[t]):h.reject(new Error("Driver not found."));return P(n,o,a),n},e.prototype.getSerializer=function(t){var o=h.resolve(ye);return P(o,t),o},e.prototype.ready=function(t){var o=this,a=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return P(a,t,t),a},e.prototype.setDriver=function(t,o,a){var n=this;He(t)||(t=[t]);var i=this._getSupportedDrivers(t);function c(){n._config.driver=n.driver()}function l(y){return n._extend(y),c(),n._ready=n._initStorage(n._config),n._ready}function d(y){return function(){var E=0;function O(){for(;E<y.length;){var T=y[E];return E++,n._dbInfo=null,n._ready=null,n.getDriver(T).then(l).catch(O)}c();var B=new Error("No available storage method found.");return n._driverSet=h.reject(B),n._driverSet}return O()}}var v=this._driverSet!==null?this._driverSet.catch(function(){return h.resolve()}):h.resolve();return this._driverSet=v.then(function(){var y=i[0];return n._dbInfo=null,n._ready=null,n.getDriver(y).then(function(E){n._driver=E._driver,c(),n._wrapLibraryMethodsWithReady(),n._initDriver=d(i)})}).catch(function(){c();var y=new Error("No available storage method found.");return n._driverSet=h.reject(y),n._driverSet}),P(this._driverSet,o,a),this._driverSet},e.prototype.supports=function(t){return!!Qe[t]},e.prototype._extend=function(t){we(this,t)},e.prototype._getSupportedDrivers=function(t){for(var o=[],a=0,n=t.length;a<n;a++){var i=t[a];this.supports(i)&&o.push(i)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var t=0,o=be.length;t<o;t++)fr(this,be[t])},e.prototype.createInstance=function(t){return new e(t)},e}(),dr=new lr;g.exports=dr},{3:3}]},{},[4])(4)})});var Ie=u=>{var x,p,I;let s=u.split("-")[1];s&&(u=u.replace(`-${s}`,""));let f=u.split("+")[1];f&&(u=u.replace(`+${f}`,""));let w=u.split(".").slice(0,3),[g,_,b]=[(x=w[0])!=null?x:"0",(p=w[1])!=null?p:"0",(I=w[2])!=null?I:"0"];return{major:g,minor:_,patch:b,prerelease:s,build:f}},ce=u=>parseInt(Ie(u).major,10),et=(u,s)=>{let{major:f,minor:w,patch:g}=Ie(u),{major:_,minor:b,patch:x}=Ie(s);return f!==_?f>_?1:-1:w!==b?w>b?1:-1:g!==x?g>x?1:-1:0};var tt="jolibox-sdk-loader-metadata",xe=class{constructor({loaderMetadata:s}={}){this.computeLoaderMetaData=()=>{var g,_;let s=this.currentVersion,f=null;try{if(f=JSON.parse((g=localStorage.getItem(tt))!=null?g:"null"),!f||!f.version)throw new Error("Invalid loader metadata")}catch(b){f=this.defaultMetadata}let w=(_=f==null?void 0:f.version)!=null?_:s;return ce(w)!==ce(s)?f=this.defaultMetadata:et(w,s)<0&&(f=this.defaultMetadata),f};this.loadScript=()=>{if(this.loaderMetadata.syncScriptUrl){let s=new XMLHttpRequest;s.open("GET",this.loaderMetadata.syncScriptUrl,!1),s.send();let f=document.createElement("script");f.type="text/javascript",f.innerHTML=s.responseText,document.head.appendChild(f)}if(this.loaderMetadata.asyncScriptUrl){let s=document.createElement("script");s.type="text/javascript",s.src=this.loaderMetadata.asyncScriptUrl,s.async=!0,document.head.appendChild(s)}};this.fetchUpdateLoaderMetadata=(..._)=>ue(this,[..._],function*(s=this.currentVersion,f=this.loaderMetadata.version,w=(g=>(g=window.JOLIBOX_ENV)!=null?g:"WEB")()){var x,p,I;let b=`${(p=(x=window.joliboxenv)==null?void 0:x.apiBaseURL)!=null?p:"https://api.jolibox.com"}/frontend/js-sdk/loader-metadata`;try{let L=yield(yield fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({installedSDKVersion:s,localSDKVersion:f,env:w})})).json();if(L.code!=="SUCCESS")throw new Error(L.message);this.loaderMetadata=(I=L.data)!=null?I:this.defaultMetadata,localStorage.setItem(tt,JSON.stringify(this.loaderMetadata))}catch(A){console.warn("Failed to fetch loader metadata: ",A)}});console.log("Loading Jolibox SDK..."),this.loaderMetadata=s!=null?s:this.computeLoaderMetaData(),this.loadScript(),this.fetchUpdateLoaderMetadata(),console.log("Jolibox SDK loaded.")}get currentVersion(){return window.__JOLIBOX_LOCAL_SDK_VERSION__}get defaultMetadata(){let s=this.currentVersion,f=ce(s);return{version:s,syncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-sync-sdk@${f}/dist/index.iife.js`,asyncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-async-sdk@${f}/dist/index.iife.js`}}};window.JoliboxSDKLoader=xe;var Ee=class{constructor(){this.init=s=>{window.joliboxsdk._commandPipe.push({cmd:"ads.init",params:s})};this.adConfig=s=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adConfig",params:s})};this.adBreak=s=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adBreak",params:s})};this.adUnit=s=>ue(this,null,function*(){window.joliboxsdk._commandPipe.push({cmd:"ads.adUnit",params:s})})}};window.JoliboxAds=Ee;var Re=class{constructor(){this.trackEvent=(s,f)=>{if(typeof s!="string")throw new Error("eventName must be a string");if(f!==null&&typeof f!="object"&&f!==void 0)throw new Error("extra must be an object or null or undefined");if(f){for(let w in f)if(typeof f[w]=="object")throw new Error("extra must not have nested objects")}window.joliboxsdk._commandPipe.push({cmd:"analytics.trackEvent",params:[s,f]})}}};window.JoliboxAnalytics=Re;var gt=Ir(nt(),1),xr=Object.defineProperty,Oe=(u,s)=>{for(var f in s)xr(u,f,{get:s[f],enumerable:!0})},Q=(u,s,f)=>new Promise((w,g)=>{var _=p=>{try{x(f.next(p))}catch(I){g(I)}},b=p=>{try{x(f.throw(p))}catch(I){g(I)}},x=p=>p.done?w(p.value):Promise.resolve(p.value).then(_,b);x((f=f.apply(u,s)).next())}),ot={};Oe(ot,{ADVERTISING_ID:()=>ct,DEVICE_ID:()=>ut,getAdvertisingId:()=>lt,getAppVersion:()=>st,getDeviceId:()=>ft,getPlatform:()=>it,getStorage:()=>Te,getUtmSource:()=>dt,platform:()=>oe,xUserAgent:()=>vt});var at={};Oe(at,{isValidUUIDV4:()=>Er,uuidv4:()=>Le});var Le=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,u=>{let s=Math.random()*16|0;return(u==="x"?s:s&3|8).toString(16)}),Er=u=>/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i.test(u),oe={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let u=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(u[1],10),parseInt(u[2],10),parseInt(u[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")},it=()=>oe.isiOS?"iOS":oe.isAndroid?"Android":oe.isMac?"Mac":oe.isFacebook?"Facebook":"PC",st=()=>window.__JOLIBOX_LOCAL_SDK_VERSION__,ut="device_id",ct="advertising_id",Te=u=>(localStorage.getItem(u)||localStorage.setItem(u,Le()),localStorage.getItem(u)),ft=()=>Te(ut),lt=()=>Te(ct),Rr=u=>u.charAt(0).toUpperCase()+u.slice(1),dt=()=>{var u;let s=new URLSearchParams(window.location.search);return Rr((u=s.get("utm_source"))!=null?u:"")||"JoliboxSDK"},vt=()=>{let u="JoliboxWebSDK",s=it(),f=navigator.language,w=ft(),g=lt(),_=st();return`${u} (${dt()}${s}; UnknownModel; UnknownSystemVersion; ${f}) uuid/${w} adid/${g} version/${_||""}`},Ar;(Ar=AbortSignal.timeout)!=null||(AbortSignal.timeout=function(u){let s=new AbortController;return setTimeout(()=>s.abort(),u),s.signal});var ht=class{constructor(u){this.xua=vt(),this.getGameId=()=>{var g;return(g=new URLSearchParams(window.location.search).get("gameId"))!=null?g:null},this.getJoliSource=()=>{var g;return(g=new URLSearchParams(window.location.search).get("joliSource"))!=null?g:null};var s,f,w;this.baseUrl=(w=(f=u==null?void 0:u.baseUrl)!=null?f:(s=window.joliboxenv)==null?void 0:s.apiBaseURL)!=null?w:"https://api.jolibox.com"}get(u,s){return Q(this,arguments,function*(f,{query:w,headers:g,timeout:_}){let b=new URLSearchParams(w).toString(),x=`${this.baseUrl}${f}${b?`?${b}`:""}`,p=this.xua,I=this.getJoliSource();return g=Object.assign({},g,p?{"x-user-agent":p}:{},I?{"x-joli-source":I}:{}),yield(yield fetch(x,{method:"GET",headers:g,signal:AbortSignal.timeout(_!=null?_:3e4)})).json()})}post(u,s){return Q(this,arguments,function*(f,{data:w,query:g,headers:_,timeout:b}){let x=new URLSearchParams(g).toString(),p=`${this.baseUrl}${f}${x?`?${x}`:""}`,I=this.xua,A=this.getJoliSource();_=Object.assign({},_,{"Content-Type":"application/json"},I?{"x-user-agent":I}:{},A?{"x-joli-source":A}:{});let L=yield fetch(p,{method:"POST",headers:_,body:JSON.stringify(w),signal:AbortSignal.timeout(b!=null?b:3e4)}),h=L.headers.get("content-type");if(h!=null&&h.includes("application/octet-stream"))try{return L.blob()}catch(S){return yield L.arrayBuffer()}if(h!=null&&h.includes("multipart/form-data")||h!=null&&h.includes("application/x-www-form-urlencoded"))try{return L.formData()}catch(S){return yield L.text()}if(h!=null&&h.includes("application/json"))try{return yield L.json()}catch(S){return yield L.text()}return L})}put(u,s){return Q(this,arguments,function*(f,{data:w,query:g,headers:_}){try{let b=new URLSearchParams(g).toString(),x=`${this.baseUrl}${f}${b?`?${b}`:""}`,p=this.xua,I=this.getJoliSource();_=Object.assign({},_,{"Content-Type":"application/json"},p?{"x-user-agent":p}:{},I?{"x-joli-source":I}:{});let A=yield fetch(x,{method:"PUT",headers:_,body:JSON.stringify(w!=null?w:{})});if(!A.ok)throw new Error(`HTTP error! status: ${A.status}`);return yield A.json()}catch(b){throw console.error("Error:",b),b}})}};window.JoliboxHttpClient=ht;var mt={};Oe(mt,{getGameSessionId:()=>Dr});var Dr=()=>{let u=sessionStorage.getItem("gameSessionId");return u||(u=Le(),sessionStorage.setItem("gameSessionId",u)),u},fe=class{};fe.xua=ot,fe.session=mt,fe.uuid=at;window.JoliboxUtil=fe;var Or=(u=>(u.LOAD_START="JOLIBOX_RUNTIME_LOAD_START",u.LOAD_FINISHED="JOLIBOX_RUNTIME_LOAD_FINISHED",u.LOAD_PROGRESS="JOLIBOX_RUNTIME_LOAD_PROGRESS",u))(Or||{});window.dispatchEvent(new Event("JOLIBOX_RUNTIME_LOAD_START"));var Lr=class{constructor(){this.loadFinished=()=>{let u=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(u),window.joliboxsdk._commandPipe.push({cmd:"analytics.trackSystemEvent",params:["CallRuntimeLoadFinished"]}),window.JoliTesterBridge&&console.log("joli-content-loaded")},this.notifyLoadProgress=u=>{let s=Math.ceil(u),f=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:s});window.dispatchEvent(f)}}};window.JoliboxRuntime=Lr;var De="INTERNAL_ERR",Tr=class{constructor(){this.getGameId=()=>{var u;return(u=new URLSearchParams(window.location.search).get("gameId"))!=null?u:""},this.getItem=u=>Q(this,null,function*(){try{let{code:s,data:f,message:w}=yield this.httpClient.get(`/api/games/user-storage/${this.gameId}`,{query:{key:u}}),g=f==null?void 0:f.value;return s!=="SUCCESS"&&(g=yield this.gameStore.getItem(u),console.info("[SDK] cloud storage getItem failed, read from localstorage",g)),{code:s,message:w,data:g!=null?g:null}}catch(s){let f=`[SDK] cloud storage getItem internal error: ${s}`;return console.error(f),{code:"INTERNAL_ERR",message:f}}}),this.setItem=(u,s)=>Q(this,null,function*(){var f,w;try{if(!this.isPrimitiveType(s))throw{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: typeof value should be number, string or boolean"};if(u.length>128)throw{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let g=typeof s=="string"?s:String(s);if(u.length+g.length>1024)throw{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"};yield this.gameStore.setItem(u,g);let{code:_,message:b}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}`,{data:{key:u,value:g}});return{code:_,message:b}}catch(g){let _=(f=g.code)!=null?f:De,b=(w=g.message)!=null?w:`${g}`;return console.error(b),{code:_,message:b}}}),this.removeItem=u=>Q(this,null,function*(){try{yield this.gameStore.removeItem(u);let{code:s,message:f}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}/remove`,{data:{key:u}});return{code:s,message:f}}catch(s){let f=`[SDK] cloud storage removeItem error: ${s}`;return console.error(f),{code:De,message:f}}}),this.clear=()=>Q(this,null,function*(){try{yield this.gameStore.clear();let{code:u,message:s}=yield this.httpClient.post(`/api/games/user-storage/${this.gameId}/clear`,{});return{code:u,message:s}}catch(u){let s=`[SDK] cloud storage clear error: ${u}`;return console.error(s),{code:De,message:s}}}),this.gameId=this.getGameId(),this.httpClient=new ht,this.gameStore=gt.default.createInstance({name:this.gameId.length?this.gameId:"default"})}isPrimitiveType(u){return typeof u=="string"||typeof u=="number"||typeof u=="boolean"}};window.JoliboxCloudStorage=Tr;window.__JOLIBOX_LOCAL_SDK_VERSION__="1.1.3";var le=class{constructor({useRuntimeSDK:s=!0,loaderConfig:f,joliboxEnv:w,testAdsMode:g,apiBaseURL:_}={}){this.hostToApiMap={default:{stg:"https://stg-api.jolibox.com",prod:"https://api.jolibox.com"},"oss.jolibox.com":{stg:"https://stg-api.jolibox.com",prod:"https://api.jolibox.com"},"oss.pico-game.com":{stg:"https://stg-api.pico-game.com",prod:"https://api.pico-game.com"}};this.setJoliboxEnv=(s,f,w)=>{var h,S;let _=typeof window<"u"?new URLSearchParams(window.location.search):null,b=(_==null?void 0:_.get("testAdsMode"))==="true",x=f!=null?f:b,p=_==null?void 0:_.get("joliboxEnv"),I=(h=s!=null?s:p)!=null?h:"production",A=_==null?void 0:_.get("apiBaseURL"),L;if(w)L=w;else if(A)L=A;else{let P=(S=this.hostToApiMap[window.location.host])!=null?S:this.hostToApiMap.default;L=I==="staging"?P.stg:P.prod}window.joliboxenv={joliboxEnv:I,testAdsMode:x,apiBaseURL:L}};var b,x,p,I,A;this.setJoliboxEnv(w,g,_),s&&window.joliboxsdk?(this.loader=(b=window.joliboxsdk.loader)!=null?b:new window.JoliboxSDKLoader(f),this.ads=(x=window.joliboxsdk.ads)!=null?x:new window.JoliboxAds,this.anaytics=(p=window.joliboxsdk.anaytics)!=null?p:new window.JoliboxAnalytics,this.runtime=(I=window.joliboxsdk.runtime)!=null?I:new window.JoliboxRuntime,this.storage=(A=window.joliboxsdk.storage)!=null?A:new window.JoliboxCloudStorage):(window.joliboxsdk||(window.joliboxsdk={_commandPipe:[]}),this.loader=new window.JoliboxSDKLoader(f),this.ads=new window.JoliboxAds,this.anaytics=new window.JoliboxAnalytics,this.runtime=new window.JoliboxRuntime,this.storage=new window.JoliboxCloudStorage,window.joliboxsdk=Object.assign(this,window.joliboxsdk)),window.joliboxsdk._commandPipe||(window.joliboxsdk._commandPipe=[])}};window.JoliboxSDK||(window.JoliboxSDK=le);var Qr=le;})();
2
2
  /*! Bundled license information:
3
3
 
4
4
  localforage/dist/localforage.js:
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var m=(n,o,t)=>new Promise((i,s)=>{var e=a=>{try{r(t.next(a))}catch(d){s(d)}},l=a=>{try{r(t.throw(a))}catch(d){s(d)}},r=a=>a.done?i(a.value):Promise.resolve(a.value).then(e,l);r((t=t.apply(n,o)).next())});var f=n=>{var r,a,d;let o=n.split("-")[1];o&&(n=n.replace(`-${o}`,""));let t=n.split("+")[1];t&&(n=n.replace(`+${t}`,""));let i=n.split(".").slice(0,3),[s,e,l]=[(r=i[0])!=null?r:"0",(a=i[1])!=null?a:"0",(d=i[2])!=null?d:"0"];return{major:s,minor:e,patch:l,prerelease:o,build:t}},w=n=>parseInt(f(n).major,10),j=(n,o)=>{let{major:t,minor:i,patch:s}=f(n),{major:e,minor:l,patch:r}=f(o);return t!==e?t>e?1:-1:i!==l?i>l?1:-1:s!==r?s>r?1:-1:0};var S="jolibox-sdk-loader-metadata",g=class{constructor({loaderMetadata:o}={}){this.computeLoaderMetaData=()=>{var s,e;let o=this.currentVersion,t=null;try{if(t=JSON.parse((s=localStorage.getItem(S))!=null?s:"null"),!t||!t.version)throw new Error("Invalid loader metadata")}catch(l){t=this.defaultMetadata}let i=(e=t==null?void 0:t.version)!=null?e:o;return w(i)!==w(o)?t=this.defaultMetadata:j(i,o)<0&&(t=this.defaultMetadata),t};this.loadScript=()=>{if(this.loaderMetadata.syncScriptUrl){let o=new XMLHttpRequest;o.open("GET",this.loaderMetadata.syncScriptUrl,!1),o.send();let t=document.createElement("script");t.type="text/javascript",t.innerHTML=o.responseText,document.head.appendChild(t)}if(this.loaderMetadata.asyncScriptUrl){let o=document.createElement("script");o.type="text/javascript",o.src=this.loaderMetadata.asyncScriptUrl,o.async=!0,document.head.appendChild(o)}};this.fetchUpdateLoaderMetadata=(...e)=>m(this,[...e],function*(o=this.currentVersion,t=this.loaderMetadata.version,i=(s=>(s=window.JOLIBOX_ENV)!=null?s:"WEB")()){var r,a,d;let l=`${(a=(r=window.joliboxenv)==null?void 0:r.apiBaseURL)!=null?a:"https://api.jolibox.com"}/frontend/js-sdk/loader-metadata`;try{let p=yield(yield fetch(l,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({installedSDKVersion:o,localSDKVersion:t,env:i})})).json();if(p.code!=="SUCCESS")throw new Error(p.message);this.loaderMetadata=(d=p.data)!=null?d:this.defaultMetadata,localStorage.setItem(S,JSON.stringify(this.loaderMetadata))}catch(c){console.warn("Failed to fetch loader metadata: ",c)}});console.log("Loading Jolibox SDK..."),this.loaderMetadata=o!=null?o:this.computeLoaderMetaData(),this.loadScript(),this.fetchUpdateLoaderMetadata(),console.log("Jolibox SDK loaded.")}get currentVersion(){return window.__JOLIBOX_LOCAL_SDK_VERSION__}get defaultMetadata(){let o=this.currentVersion,t=w(o);return{version:o,syncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-sync-sdk@${t}/dist/index.iife.js`,asyncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-async-sdk@${t}/dist/index.iife.js`}}};window.JoliboxSDKLoader=g;var x=class{constructor(){this.init=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.init",params:o})};this.adConfig=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adConfig",params:o})};this.adBreak=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adBreak",params:o})};this.adUnit=o=>m(this,null,function*(){window.joliboxsdk._commandPipe.push({cmd:"ads.adUnit",params:o})})}};window.JoliboxAds=x;var u=class{constructor(){this.trackEvent=(o,t)=>{if(typeof o!="string")throw new Error("eventName must be a string");if(t!==null&&typeof t!="object"&&t!==void 0)throw new Error("extra must be an object or null or undefined");if(t){for(let i in t)if(typeof t[i]=="object")throw new Error("extra must not have nested objects")}window.joliboxsdk._commandPipe.push({cmd:"analytics.trackEvent",params:[o,t]})}}};window.JoliboxAnalytics=u;import"@jolibox/web-sync-sdk";window.__JOLIBOX_LOCAL_SDK_VERSION__="1.1.2";var b=class{constructor({useRuntimeSDK:o=!0,loaderConfig:t,joliboxEnv:i,testAdsMode:s,apiBaseURL:e}={}){this.hostToApiMap={default:{stg:"https://stg-api.jolibox.com",prod:"https://api.jolibox.com"},"oss.jolibox.com":{stg:"https://stg-api.jolibox.com",prod:"https://api.jolibox.com"},"oss.pico-game.com":{stg:"https://stg-api.pico-game.com",prod:"https://api.pico-game.com"}};this.setJoliboxEnv=(o,t,i)=>{var h,I;let e=typeof window<"u"?new URLSearchParams(window.location.search):null,l=(e==null?void 0:e.get("testAdsMode"))==="true",r=t!=null?t:l,a=e==null?void 0:e.get("joliboxEnv"),d=(h=o!=null?o:a)!=null?h:"production",c=e==null?void 0:e.get("apiBaseURL"),p;if(i)p=i;else if(c)p=c;else{let y=(I=this.hostToApiMap[window.location.host])!=null?I:this.hostToApiMap.default;p=d==="staging"?y.stg:y.prod}window.joliboxenv={joliboxEnv:d,testAdsMode:r,apiBaseURL:p}};var l,r,a,d,c;this.setJoliboxEnv(i,s,e),o&&window.joliboxsdk?(this.loader=(l=window.joliboxsdk.loader)!=null?l:new window.JoliboxSDKLoader(t),this.ads=(r=window.joliboxsdk.ads)!=null?r:new window.JoliboxAds,this.anaytics=(a=window.joliboxsdk.anaytics)!=null?a:new window.JoliboxAnalytics,this.runtime=(d=window.joliboxsdk.runtime)!=null?d:new window.JoliboxRuntime,this.storage=(c=window.joliboxsdk.storage)!=null?c:new window.JoliboxCloudStorage):(window.joliboxsdk||(window.joliboxsdk={_commandPipe:[]}),this.loader=new window.JoliboxSDKLoader(t),this.ads=new window.JoliboxAds,this.anaytics=new window.JoliboxAnalytics,this.runtime=new window.JoliboxRuntime,this.storage=new window.JoliboxCloudStorage,window.joliboxsdk=Object.assign(this,window.joliboxsdk)),window.joliboxsdk._commandPipe||(window.joliboxsdk._commandPipe=[])}};window.JoliboxSDK||(window.JoliboxSDK=b);var U=b;export{b as JoliboxSDK,U as default};
1
+ var m=(n,o,t)=>new Promise((i,s)=>{var e=a=>{try{r(t.next(a))}catch(d){s(d)}},l=a=>{try{r(t.throw(a))}catch(d){s(d)}},r=a=>a.done?i(a.value):Promise.resolve(a.value).then(e,l);r((t=t.apply(n,o)).next())});var f=n=>{var r,a,d;let o=n.split("-")[1];o&&(n=n.replace(`-${o}`,""));let t=n.split("+")[1];t&&(n=n.replace(`+${t}`,""));let i=n.split(".").slice(0,3),[s,e,l]=[(r=i[0])!=null?r:"0",(a=i[1])!=null?a:"0",(d=i[2])!=null?d:"0"];return{major:s,minor:e,patch:l,prerelease:o,build:t}},w=n=>parseInt(f(n).major,10),j=(n,o)=>{let{major:t,minor:i,patch:s}=f(n),{major:e,minor:l,patch:r}=f(o);return t!==e?t>e?1:-1:i!==l?i>l?1:-1:s!==r?s>r?1:-1:0};var S="jolibox-sdk-loader-metadata",g=class{constructor({loaderMetadata:o}={}){this.computeLoaderMetaData=()=>{var s,e;let o=this.currentVersion,t=null;try{if(t=JSON.parse((s=localStorage.getItem(S))!=null?s:"null"),!t||!t.version)throw new Error("Invalid loader metadata")}catch(l){t=this.defaultMetadata}let i=(e=t==null?void 0:t.version)!=null?e:o;return w(i)!==w(o)?t=this.defaultMetadata:j(i,o)<0&&(t=this.defaultMetadata),t};this.loadScript=()=>{if(this.loaderMetadata.syncScriptUrl){let o=new XMLHttpRequest;o.open("GET",this.loaderMetadata.syncScriptUrl,!1),o.send();let t=document.createElement("script");t.type="text/javascript",t.innerHTML=o.responseText,document.head.appendChild(t)}if(this.loaderMetadata.asyncScriptUrl){let o=document.createElement("script");o.type="text/javascript",o.src=this.loaderMetadata.asyncScriptUrl,o.async=!0,document.head.appendChild(o)}};this.fetchUpdateLoaderMetadata=(...e)=>m(this,[...e],function*(o=this.currentVersion,t=this.loaderMetadata.version,i=(s=>(s=window.JOLIBOX_ENV)!=null?s:"WEB")()){var r,a,d;let l=`${(a=(r=window.joliboxenv)==null?void 0:r.apiBaseURL)!=null?a:"https://api.jolibox.com"}/frontend/js-sdk/loader-metadata`;try{let p=yield(yield fetch(l,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({installedSDKVersion:o,localSDKVersion:t,env:i})})).json();if(p.code!=="SUCCESS")throw new Error(p.message);this.loaderMetadata=(d=p.data)!=null?d:this.defaultMetadata,localStorage.setItem(S,JSON.stringify(this.loaderMetadata))}catch(c){console.warn("Failed to fetch loader metadata: ",c)}});console.log("Loading Jolibox SDK..."),this.loaderMetadata=o!=null?o:this.computeLoaderMetaData(),this.loadScript(),this.fetchUpdateLoaderMetadata(),console.log("Jolibox SDK loaded.")}get currentVersion(){return window.__JOLIBOX_LOCAL_SDK_VERSION__}get defaultMetadata(){let o=this.currentVersion,t=w(o);return{version:o,syncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-sync-sdk@${t}/dist/index.iife.js`,asyncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-async-sdk@${t}/dist/index.iife.js`}}};window.JoliboxSDKLoader=g;var x=class{constructor(){this.init=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.init",params:o})};this.adConfig=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adConfig",params:o})};this.adBreak=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adBreak",params:o})};this.adUnit=o=>m(this,null,function*(){window.joliboxsdk._commandPipe.push({cmd:"ads.adUnit",params:o})})}};window.JoliboxAds=x;var u=class{constructor(){this.trackEvent=(o,t)=>{if(typeof o!="string")throw new Error("eventName must be a string");if(t!==null&&typeof t!="object"&&t!==void 0)throw new Error("extra must be an object or null or undefined");if(t){for(let i in t)if(typeof t[i]=="object")throw new Error("extra must not have nested objects")}window.joliboxsdk._commandPipe.push({cmd:"analytics.trackEvent",params:[o,t]})}}};window.JoliboxAnalytics=u;import"@jolibox/web-sync-sdk";window.__JOLIBOX_LOCAL_SDK_VERSION__="1.1.3";var b=class{constructor({useRuntimeSDK:o=!0,loaderConfig:t,joliboxEnv:i,testAdsMode:s,apiBaseURL:e}={}){this.hostToApiMap={default:{stg:"https://stg-api.jolibox.com",prod:"https://api.jolibox.com"},"oss.jolibox.com":{stg:"https://stg-api.jolibox.com",prod:"https://api.jolibox.com"},"oss.pico-game.com":{stg:"https://stg-api.pico-game.com",prod:"https://api.pico-game.com"}};this.setJoliboxEnv=(o,t,i)=>{var h,I;let e=typeof window<"u"?new URLSearchParams(window.location.search):null,l=(e==null?void 0:e.get("testAdsMode"))==="true",r=t!=null?t:l,a=e==null?void 0:e.get("joliboxEnv"),d=(h=o!=null?o:a)!=null?h:"production",c=e==null?void 0:e.get("apiBaseURL"),p;if(i)p=i;else if(c)p=c;else{let y=(I=this.hostToApiMap[window.location.host])!=null?I:this.hostToApiMap.default;p=d==="staging"?y.stg:y.prod}window.joliboxenv={joliboxEnv:d,testAdsMode:r,apiBaseURL:p}};var l,r,a,d,c;this.setJoliboxEnv(i,s,e),o&&window.joliboxsdk?(this.loader=(l=window.joliboxsdk.loader)!=null?l:new window.JoliboxSDKLoader(t),this.ads=(r=window.joliboxsdk.ads)!=null?r:new window.JoliboxAds,this.anaytics=(a=window.joliboxsdk.anaytics)!=null?a:new window.JoliboxAnalytics,this.runtime=(d=window.joliboxsdk.runtime)!=null?d:new window.JoliboxRuntime,this.storage=(c=window.joliboxsdk.storage)!=null?c:new window.JoliboxCloudStorage):(window.joliboxsdk||(window.joliboxsdk={_commandPipe:[]}),this.loader=new window.JoliboxSDKLoader(t),this.ads=new window.JoliboxAds,this.anaytics=new window.JoliboxAnalytics,this.runtime=new window.JoliboxRuntime,this.storage=new window.JoliboxCloudStorage,window.joliboxsdk=Object.assign(this,window.joliboxsdk)),window.joliboxsdk._commandPipe||(window.joliboxsdk._commandPipe=[])}};window.JoliboxSDK||(window.JoliboxSDK=b);var U=b;export{b as JoliboxSDK,U as default};
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jolibox/sdk",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Jolibox JavaScript SDK for Ads",
5
5
  "homepage": "https://sdk-docs.jolibox.com",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@jolibox/web-sync-sdk": "1.1.2"
31
+ "@jolibox/web-sync-sdk": "1.1.3"
32
32
  },
33
33
  "scripts": {
34
34
  "build": "tsup",