client-web-storage
Advanced tools
Comparing version
@@ -1,2 +0,2 @@ | ||
(()=>{var wr=Object.create;var Je=Object.defineProperty;var Tr=Object.getOwnPropertyDescriptor;var Dr=Object.getOwnPropertyNames;var Ar=Object.getPrototypeOf,_r=Object.prototype.hasOwnProperty;var s=(p,i)=>Je(p,"name",{value:i,configurable:!0}),De=(p=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(p,{get:(i,u)=>(typeof require!="undefined"?require:i)[u]}):p)(function(p){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+p+'" is not supported')});var Ir=(p,i)=>()=>(i||p((i={exports:{}}).exports,i),i.exports);var Rr=(p,i,u,l)=>{if(i&&typeof i=="object"||typeof i=="function")for(let y of Dr(i))!_r.call(p,y)&&y!==u&&Je(p,y,{get:()=>i[y],enumerable:!(l=Tr(i,y))||l.enumerable});return p};var Cr=(p,i,u)=>(u=p!=null?wr(Ar(p)):{},Rr(i||!p||!p.__esModule?Je(u,"default",{value:p,enumerable:!0}):u,p));var We=(p,i,u)=>{if(!i.has(p))throw TypeError("Cannot "+u)};var b=(p,i,u)=>(We(p,i,"read from private field"),u?u.call(p):i.get(p)),G=(p,i,u)=>{if(i.has(p))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(p):i.set(p,u)},W=(p,i,u,l)=>(We(p,i,"write to private field"),l?l.call(p,u):i.set(p,u),u);var H=(p,i,u)=>(We(p,i,"access private method"),u);var Et=Ir((bt,je)=>{(function(p){if(typeof bt=="object"&&typeof je<"u")je.exports=p();else if(typeof define=="function"&&define.amd)define([],p);else{var i;typeof window<"u"?i=window:typeof global<"u"?i=global:typeof self<"u"?i=self:i=this,i.localforage=p()}})(function(){var p,i,u;return s(function l(y,_,D){function B(z,P){if(!_[z]){if(!y[z]){var g=typeof De=="function"&&De;if(!P&&g)return g(z,!0);if(I)return I(z,!0);var S=new Error("Cannot find module '"+z+"'");throw S.code="MODULE_NOT_FOUND",S}var L=_[z]={exports:{}};y[z][0].call(L.exports,function(V){var re=y[z][1][V];return B(re||V)},L,L.exports,l,y,_,D)}return _[z].exports}s(B,"s");for(var I=typeof De=="function"&&De,U=0;U<D.length;U++)B(D[U]);return B},"e")({1:[function(l,y,_){(function(D){"use strict";var B=D.MutationObserver||D.WebKitMutationObserver,I;if(B){var U=0,z=new B(V),P=D.document.createTextNode("");z.observe(P,{characterData:!0}),I=s(function(){P.data=U=++U%2},"scheduleDrain")}else if(!D.setImmediate&&typeof D.MessageChannel<"u"){var g=new D.MessageChannel;g.port1.onmessage=V,I=s(function(){g.port2.postMessage(0)},"scheduleDrain")}else"document"in D&&"onreadystatechange"in D.document.createElement("script")?I=s(function(){var $=D.document.createElement("script");$.onreadystatechange=function(){V(),$.onreadystatechange=null,$.parentNode.removeChild($),$=null},D.document.documentElement.appendChild($)},"scheduleDrain"):I=s(function(){setTimeout(V,0)},"scheduleDrain");var S,L=[];function V(){S=!0;for(var $,ie,K=L.length;K;){for(ie=L,L=[],$=-1;++$<K;)ie[$]();K=L.length}S=!1}s(V,"nextTick"),y.exports=re;function re($){L.push($)===1&&!S&&I()}s(re,"immediate")}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(l,y,_){"use strict";var D=l(1);function B(){}s(B,"INTERNAL");var I={},U=["REJECTED"],z=["FULFILLED"],P=["PENDING"];y.exports=g;function g(m){if(typeof m!="function")throw new TypeError("resolver must be a function");this.state=P,this.queue=[],this.outcome=void 0,m!==B&&re(this,m)}s(g,"Promise"),g.prototype.catch=function(m){return this.then(null,m)},g.prototype.then=function(m,R){if(typeof m!="function"&&this.state===z||typeof R!="function"&&this.state===U)return this;var T=new this.constructor(B);if(this.state!==P){var N=this.state===z?m:R;L(T,N,this.outcome)}else this.queue.push(new S(T,m,R));return T};function S(m,R,T){this.promise=m,typeof R=="function"&&(this.onFulfilled=R,this.callFulfilled=this.otherCallFulfilled),typeof T=="function"&&(this.onRejected=T,this.callRejected=this.otherCallRejected)}s(S,"QueueItem"),S.prototype.callFulfilled=function(m){I.resolve(this.promise,m)},S.prototype.otherCallFulfilled=function(m){L(this.promise,this.onFulfilled,m)},S.prototype.callRejected=function(m){I.reject(this.promise,m)},S.prototype.otherCallRejected=function(m){L(this.promise,this.onRejected,m)};function L(m,R,T){D(function(){var N;try{N=R(T)}catch(J){return I.reject(m,J)}N===m?I.reject(m,new TypeError("Cannot resolve promise with itself")):I.resolve(m,N)})}s(L,"unwrap"),I.resolve=function(m,R){var T=$(V,R);if(T.status==="error")return I.reject(m,T.value);var N=T.value;if(N)re(m,N);else{m.state=z,m.outcome=R;for(var J=-1,Q=m.queue.length;++J<Q;)m.queue[J].callFulfilled(R)}return m},I.reject=function(m,R){m.state=U,m.outcome=R;for(var T=-1,N=m.queue.length;++T<N;)m.queue[T].callRejected(R);return m};function V(m){var R=m&&m.then;if(m&&(typeof m=="object"||typeof m=="function")&&typeof R=="function")return s(function(){R.apply(m,arguments)},"appyThen")}s(V,"getThen");function re(m,R){var T=!1;function N(Z){T||(T=!0,I.reject(m,Z))}s(N,"onError");function J(Z){T||(T=!0,I.resolve(m,Z))}s(J,"onSuccess");function Q(){R(J,N)}s(Q,"tryToUnwrap");var X=$(Q);X.status==="error"&&N(X.value)}s(re,"safelyResolveThenable");function $(m,R){var T={};try{T.value=m(R),T.status="success"}catch(N){T.status="error",T.value=N}return T}s($,"tryCatch"),g.resolve=ie;function ie(m){return m instanceof this?m:I.resolve(new this(B),m)}s(ie,"resolve"),g.reject=K;function K(m){var R=new this(B);return I.reject(R,m)}s(K,"reject"),g.all=Pe;function Pe(m){var R=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var T=m.length,N=!1;if(!T)return this.resolve([]);for(var J=new Array(T),Q=0,X=-1,Z=new this(B);++X<T;)se(m[X],X);return Z;function se(Se,xe){R.resolve(Se).then(Le,function(be){N||(N=!0,I.reject(Z,be))});function Le(be){J[xe]=be,++Q===T&&!N&&(N=!0,I.resolve(Z,J))}s(Le,"resolveFromAll")}}s(Pe,"all"),g.race=me;function me(m){var R=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var T=m.length,N=!1;if(!T)return this.resolve([]);for(var J=-1,Q=new this(B);++J<T;)X(m[J]);return Q;function X(Z){R.resolve(Z).then(function(se){N||(N=!0,I.resolve(Q,se))},function(se){N||(N=!0,I.reject(Q,se))})}}s(me,"race")},{"1":1}],3:[function(l,y,_){(function(D){"use strict";typeof D.Promise!="function"&&(D.Promise=l(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{"2":2}],4:[function(l,y,_){"use strict";var D=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 B(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}s(B,"_classCallCheck");function I(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}s(I,"getIDB");var U=I();function z(){try{if(!U||!U.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{return!1}}s(z,"isIndexedDBValid");function P(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,a=new t,o=0;o<e.length;o+=1)a.append(e[o]);return a.getBlob(r.type)}}s(P,"createBlob"),typeof Promise>"u"&&l(3);var g=Promise;function S(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}s(S,"executeCallback");function L(e,r,t){typeof r=="function"&&e.then(r),typeof t=="function"&&e.catch(t)}s(L,"executeTwoCallbacks");function V(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}s(V,"normalizeKey");function re(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}s(re,"getCallback");var $="local-forage-detect-blob-support",ie=void 0,K={},Pe=Object.prototype.toString,me="readonly",m="readwrite";function R(e){for(var r=e.length,t=new ArrayBuffer(r),a=new Uint8Array(t),o=0;o<r;o++)a[o]=e.charCodeAt(o);return t}s(R,"_binStringToArrayBuffer");function T(e){return new g(function(r){var t=e.transaction($,m),a=P([""]);t.objectStore($).put(a,"key"),t.onabort=function(o){o.preventDefault(),o.stopPropagation(),r(!1)},t.oncomplete=function(){var o=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);r(n||!o||parseInt(o[1],10)>=43)}}).catch(function(){return!1})}s(T,"_checkBlobSupportWithoutCaching");function N(e){return typeof ie=="boolean"?g.resolve(ie):T(e).then(function(r){return ie=r,ie})}s(N,"_checkBlobSupport");function J(e){var r=K[e.name],t={};t.promise=new g(function(a,o){t.resolve=a,t.reject=o}),r.deferredOperations.push(t),r.dbReady?r.dbReady=r.dbReady.then(function(){return t.promise}):r.dbReady=t.promise}s(J,"_deferReadiness");function Q(e){var r=K[e.name],t=r.deferredOperations.pop();if(t)return t.resolve(),t.promise}s(Q,"_advanceReadiness");function X(e,r){var t=K[e.name],a=t.deferredOperations.pop();if(a)return a.reject(r),a.promise}s(X,"_rejectReadiness");function Z(e,r){return new g(function(t,a){if(K[e.name]=K[e.name]||Qe(),e.db)if(r)J(e),e.db.close();else return t(e.db);var o=[e.name];r&&o.push(e.version);var n=U.open.apply(U,o);r&&(n.onupgradeneeded=function(f){var c=n.result;try{c.createObjectStore(e.storeName),f.oldVersion<=1&&c.createObjectStore($)}catch(d){if(d.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw d}}),n.onerror=function(f){f.preventDefault(),a(n.error)},n.onsuccess=function(){var f=n.result;f.onversionchange=function(c){c.target.close()},t(f),Q(e)}})}s(Z,"_getConnection");function se(e){return Z(e,!1)}s(se,"_getOriginalConnection");function Se(e){return Z(e,!0)}s(Se,"_getUpgradedConnection");function xe(e,r){if(!e.db)return!0;var t=!e.db.objectStoreNames.contains(e.storeName),a=e.version<e.db.version,o=e.version>e.db.version;if(a&&(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),o||t){if(t){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}s(xe,"_isUpgradeNeeded");function Le(e){return new g(function(r,t){var a=new FileReader;a.onerror=t,a.onloadend=function(o){var n=btoa(o.target.result||"");r({__local_forage_encoded_blob:!0,data:n,type:e.type})},a.readAsBinaryString(e)})}s(Le,"_encodeBlob");function be(e){var r=R(atob(e.data));return P([r],{type:e.type})}s(be,"_decodeBlob");function Ge(e){return e&&e.__local_forage_encoded_blob}s(Ge,"_isEncodedBlob");function Tt(e){var r=this,t=r._initReady().then(function(){var a=K[r._dbInfo.name];if(a&&a.dbReady)return a.dbReady});return L(t,e,e),t}s(Tt,"_fullyReady");function Dt(e){J(e);for(var r=K[e.name],t=r.forages,a=0;a<t.length;a++){var o=t[a];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,se(e).then(function(n){return e.db=n,xe(e)?Se(e):n}).then(function(n){e.db=r.db=n;for(var f=0;f<t.length;f++)t[f]._dbInfo.db=n}).catch(function(n){throw X(e,n),n})}s(Dt,"_tryReconnect");function ue(e,r,t,a){a===void 0&&(a=1);try{var o=e.db.transaction(e.storeName,r);t(null,o)}catch(n){if(a>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return g.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),Se(e)}).then(function(){return Dt(e).then(function(){ue(e,r,t,a-1)})}).catch(t);t(n)}}s(ue,"createTransaction");function Qe(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}s(Qe,"createDbContext");function At(e){var r=this,t={db:null};if(e)for(var a in e)t[a]=e[a];var o=K[t.name];o||(o=Qe(),K[t.name]=o),o.forages.push(r),r._initReady||(r._initReady=r.ready,r.ready=Tt);var n=[];function f(){return g.resolve()}s(f,"ignoreErrors");for(var c=0;c<o.forages.length;c++){var d=o.forages[c];d!==r&&n.push(d._initReady().catch(f))}var h=o.forages.slice(0);return g.all(n).then(function(){return t.db=o.db,se(t)}).then(function(v){return t.db=v,xe(t,r._defaultConfig.version)?Se(t):v}).then(function(v){t.db=o.db=v,r._dbInfo=t;for(var E=0;E<h.length;E++){var w=h[E];w!==r&&(w._dbInfo.db=t.db,w._dbInfo.version=t.version)}})}s(At,"_initStorage");function _t(e,r){var t=this;e=V(e);var a=new g(function(o,n){t.ready().then(function(){ue(t._dbInfo,me,function(f,c){if(f)return n(f);try{var d=c.objectStore(t._dbInfo.storeName),h=d.get(e);h.onsuccess=function(){var v=h.result;v===void 0&&(v=null),Ge(v)&&(v=be(v)),o(v)},h.onerror=function(){n(h.error)}}catch(v){n(v)}})}).catch(n)});return S(a,r),a}s(_t,"getItem");function It(e,r){var t=this,a=new g(function(o,n){t.ready().then(function(){ue(t._dbInfo,me,function(f,c){if(f)return n(f);try{var d=c.objectStore(t._dbInfo.storeName),h=d.openCursor(),v=1;h.onsuccess=function(){var E=h.result;if(E){var w=E.value;Ge(w)&&(w=be(w));var C=e(w,E.key,v++);C!==void 0?o(C):E.continue()}else o()},h.onerror=function(){n(h.error)}}catch(E){n(E)}})}).catch(n)});return S(a,r),a}s(It,"iterate");function Rt(e,r,t){var a=this;e=V(e);var o=new g(function(n,f){var c;a.ready().then(function(){return c=a._dbInfo,Pe.call(r)==="[object Blob]"?N(c.db).then(function(d){return d?r:Le(r)}):r}).then(function(d){ue(a._dbInfo,m,function(h,v){if(h)return f(h);try{var E=v.objectStore(a._dbInfo.storeName);d===null&&(d=void 0);var w=E.put(d,e);v.oncomplete=function(){d===void 0&&(d=null),n(d)},v.onabort=v.onerror=function(){var C=w.error?w.error:w.transaction.error;f(C)}}catch(C){f(C)}})}).catch(f)});return S(o,t),o}s(Rt,"setItem");function Ct(e,r){var t=this;e=V(e);var a=new g(function(o,n){t.ready().then(function(){ue(t._dbInfo,m,function(f,c){if(f)return n(f);try{var d=c.objectStore(t._dbInfo.storeName),h=d.delete(e);c.oncomplete=function(){o()},c.onerror=function(){n(h.error)},c.onabort=function(){var v=h.error?h.error:h.transaction.error;n(v)}}catch(v){n(v)}})}).catch(n)});return S(a,r),a}s(Ct,"removeItem");function xt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){ue(r._dbInfo,m,function(n,f){if(n)return o(n);try{var c=f.objectStore(r._dbInfo.storeName),d=c.clear();f.oncomplete=function(){a()},f.onabort=f.onerror=function(){var h=d.error?d.error:d.transaction.error;o(h)}}catch(h){o(h)}})}).catch(o)});return S(t,e),t}s(xt,"clear");function Nt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){ue(r._dbInfo,me,function(n,f){if(n)return o(n);try{var c=f.objectStore(r._dbInfo.storeName),d=c.count();d.onsuccess=function(){a(d.result)},d.onerror=function(){o(d.error)}}catch(h){o(h)}})}).catch(o)});return S(t,e),t}s(Nt,"length");function Ot(e,r){var t=this,a=new g(function(o,n){if(e<0){o(null);return}t.ready().then(function(){ue(t._dbInfo,me,function(f,c){if(f)return n(f);try{var d=c.objectStore(t._dbInfo.storeName),h=!1,v=d.openKeyCursor();v.onsuccess=function(){var E=v.result;if(!E){o(null);return}e===0||h?o(E.key):(h=!0,E.advance(e))},v.onerror=function(){n(v.error)}}catch(E){n(E)}})}).catch(n)});return S(a,r),a}s(Ot,"key");function Bt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){ue(r._dbInfo,me,function(n,f){if(n)return o(n);try{var c=f.objectStore(r._dbInfo.storeName),d=c.openKeyCursor(),h=[];d.onsuccess=function(){var v=d.result;if(!v){a(h);return}h.push(v.key),v.continue()},d.onerror=function(){o(d.error)}}catch(v){o(v)}})}).catch(o)});return S(t,e),t}s(Bt,"keys");function Pt(e,r){r=re.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 a=this,o;if(!e.name)o=g.reject("Invalid arguments");else{var n=e.name===t.name&&a._dbInfo.db,f=n?g.resolve(a._dbInfo.db):se(e).then(function(c){var d=K[e.name],h=d.forages;d.db=c;for(var v=0;v<h.length;v++)h[v]._dbInfo.db=c;return c});e.storeName?o=f.then(function(c){if(!!c.objectStoreNames.contains(e.storeName)){var d=c.version+1;J(e);var h=K[e.name],v=h.forages;c.close();for(var E=0;E<v.length;E++){var w=v[E];w._dbInfo.db=null,w._dbInfo.version=d}var C=new g(function(x,F){var O=U.open(e.name,d);O.onerror=function(ee){var Te=O.result;Te.close(),F(ee)},O.onupgradeneeded=function(){var ee=O.result;ee.deleteObjectStore(e.storeName)},O.onsuccess=function(){var ee=O.result;ee.close(),x(ee)}});return C.then(function(x){h.db=x;for(var F=0;F<v.length;F++){var O=v[F];O._dbInfo.db=x,Q(O._dbInfo)}}).catch(function(x){throw(X(e,x)||g.resolve()).catch(function(){}),x})}}):o=f.then(function(c){J(e);var d=K[e.name],h=d.forages;c.close();for(var v=0;v<h.length;v++){var E=h[v];E._dbInfo.db=null}var w=new g(function(C,x){var F=U.deleteDatabase(e.name);F.onerror=function(){var O=F.result;O&&O.close(),x(F.error)},F.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},F.onsuccess=function(){var O=F.result;O&&O.close(),C(O)}});return w.then(function(C){d.db=C;for(var x=0;x<h.length;x++){var F=h[x];Q(F._dbInfo)}}).catch(function(C){throw(X(e,C)||g.resolve()).catch(function(){}),C})})}return S(o,r),o}s(Pt,"dropInstance");var Lt={_driver:"asyncStorage",_initStorage:At,_support:z(),iterate:It,getItem:_t,setItem:Rt,removeItem:Ct,clear:xt,length:Nt,key:Ot,keys:Bt,dropInstance:Pt};function Ft(){return typeof openDatabase=="function"}s(Ft,"isWebSQLValid");var de="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ut="~~local_forage_type~",qe=/^~~local_forage_type~([^~]+)~/,Ne="__lfsc__:",Fe=Ne.length,Ue="arbf",Ve="blob",Xe="si08",Ze="ui08",et="uic8",tt="si16",rt="si32",nt="ur16",at="ui32",ot="fl32",it="fl64",st=Fe+Ue.length,ut=Object.prototype.toString;function ft(e){var r=e.length*.75,t=e.length,a,o=0,n,f,c,d;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);var h=new ArrayBuffer(r),v=new Uint8Array(h);for(a=0;a<t;a+=4)n=de.indexOf(e[a]),f=de.indexOf(e[a+1]),c=de.indexOf(e[a+2]),d=de.indexOf(e[a+3]),v[o++]=n<<2|f>>4,v[o++]=(f&15)<<4|c>>2,v[o++]=(c&3)<<6|d&63;return h}s(ft,"stringToBuffer");function $e(e){var r=new Uint8Array(e),t="",a;for(a=0;a<r.length;a+=3)t+=de[r[a]>>2],t+=de[(r[a]&3)<<4|r[a+1]>>4],t+=de[(r[a+1]&15)<<2|r[a+2]>>6],t+=de[r[a+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}s($e,"bufferToString");function Vt(e,r){var t="";if(e&&(t=ut.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&ut.call(e.buffer)==="[object ArrayBuffer]")){var a,o=Ne;e instanceof ArrayBuffer?(a=e,o+=Ue):(a=e.buffer,t==="[object Int8Array]"?o+=Xe:t==="[object Uint8Array]"?o+=Ze:t==="[object Uint8ClampedArray]"?o+=et:t==="[object Int16Array]"?o+=tt:t==="[object Uint16Array]"?o+=nt:t==="[object Int32Array]"?o+=rt:t==="[object Uint32Array]"?o+=at:t==="[object Float32Array]"?o+=ot:t==="[object Float64Array]"?o+=it:r(new Error("Failed to get type for BinaryArray"))),r(o+$e(a))}else if(t==="[object Blob]"){var n=new FileReader;n.onload=function(){var f=Ut+e.type+"~"+$e(this.result);r(Ne+Ve+f)},n.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),r(null,f)}}s(Vt,"serialize");function $t(e){if(e.substring(0,Fe)!==Ne)return JSON.parse(e);var r=e.substring(st),t=e.substring(Fe,st),a;if(t===Ve&&qe.test(r)){var o=r.match(qe);a=o[1],r=r.substring(o[0].length)}var n=ft(r);switch(t){case Ue:return n;case Ve:return P([n],{type:a});case Xe:return new Int8Array(n);case Ze:return new Uint8Array(n);case et:return new Uint8ClampedArray(n);case tt:return new Int16Array(n);case nt:return new Uint16Array(n);case rt:return new Int32Array(n);case at:return new Uint32Array(n);case ot:return new Float32Array(n);case it:return new Float64Array(n);default:throw new Error("Unkown type: "+t)}}s($t,"deserialize");var Me={serialize:Vt,deserialize:$t,stringToBuffer:ft,bufferToString:$e};function ct(e,r,t,a){e.executeSql("CREATE TABLE IF NOT EXISTS "+r.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],t,a)}s(ct,"createDbTable");function Mt(e){var r=this,t={db:null};if(e)for(var a in e)t[a]=typeof e[a]!="string"?e[a].toString():e[a];var o=new g(function(n,f){try{t.db=openDatabase(t.name,String(t.version),t.description,t.size)}catch(c){return f(c)}t.db.transaction(function(c){ct(c,t,function(){r._dbInfo=t,n()},function(d,h){f(h)})},f)});return t.serializer=Me,o}s(Mt,"_initStorage$1");function he(e,r,t,a,o,n){e.executeSql(t,a,o,function(f,c){c.code===c.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[r.storeName],function(d,h){h.rows.length?n(d,c):ct(d,r,function(){d.executeSql(t,a,o,n)},n)},n):n(f,c)},n)}s(he,"tryExecuteSql");function kt(e,r){var t=this;e=V(e);var a=new g(function(o,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(c){he(c,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[e],function(d,h){var v=h.rows.length?h.rows.item(0).value:null;v&&(v=f.serializer.deserialize(v)),o(v)},function(d,h){n(h)})})}).catch(n)});return S(a,r),a}s(kt,"getItem$1");function Yt(e,r){var t=this,a=new g(function(o,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(c){he(c,f,"SELECT * FROM "+f.storeName,[],function(d,h){for(var v=h.rows,E=v.length,w=0;w<E;w++){var C=v.item(w),x=C.value;if(x&&(x=f.serializer.deserialize(x)),x=e(x,C.key,w+1),x!==void 0){o(x);return}}o()},function(d,h){n(h)})})}).catch(n)});return S(a,r),a}s(Yt,"iterate$1");function lt(e,r,t,a){var o=this;e=V(e);var n=new g(function(f,c){o.ready().then(function(){r===void 0&&(r=null);var d=r,h=o._dbInfo;h.serializer.serialize(r,function(v,E){E?c(E):h.db.transaction(function(w){he(w,h,"INSERT OR REPLACE INTO "+h.storeName+" (key, value) VALUES (?, ?)",[e,v],function(){f(d)},function(C,x){c(x)})},function(w){if(w.code===w.QUOTA_ERR){if(a>0){f(lt.apply(o,[e,d,t,a-1]));return}c(w)}})})}).catch(c)});return S(n,t),n}s(lt,"_setItem");function Kt(e,r,t){return lt.apply(this,[e,r,t,1])}s(Kt,"setItem$1");function zt(e,r){var t=this;e=V(e);var a=new g(function(o,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(c){he(c,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[e],function(){o()},function(d,h){n(h)})})}).catch(n)});return S(a,r),a}s(zt,"removeItem$1");function Jt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(f){he(f,n,"DELETE FROM "+n.storeName,[],function(){a()},function(c,d){o(d)})})}).catch(o)});return S(t,e),t}s(Jt,"clear$1");function Wt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(f){he(f,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(c,d){var h=d.rows.item(0).c;a(h)},function(c,d){o(d)})})}).catch(o)});return S(t,e),t}s(Wt,"length$1");function Ht(e,r){var t=this,a=new g(function(o,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(c){he(c,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[e+1],function(d,h){var v=h.rows.length?h.rows.item(0).key:null;o(v)},function(d,h){n(h)})})}).catch(n)});return S(a,r),a}s(Ht,"key$1");function jt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(f){he(f,n,"SELECT key FROM "+n.storeName,[],function(c,d){for(var h=[],v=0;v<d.rows.length;v++)h.push(d.rows.item(v).key);a(h)},function(c,d){o(d)})})}).catch(o)});return S(t,e),t}s(jt,"keys$1");function Gt(e){return new g(function(r,t){e.transaction(function(a){a.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(o,n){for(var f=[],c=0;c<n.rows.length;c++)f.push(n.rows.item(c).name);r({db:e,storeNames:f})},function(o,n){t(n)})},function(a){t(a)})})}s(Gt,"getAllStoreNames");function Qt(e,r){r=re.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 a=this,o;return e.name?o=new g(function(n){var f;e.name===t.name?f=a._dbInfo.db:f=openDatabase(e.name,"","",0),e.storeName?n({db:f,storeNames:[e.storeName]}):n(Gt(f))}).then(function(n){return new g(function(f,c){n.db.transaction(function(d){function h(C){return new g(function(x,F){d.executeSql("DROP TABLE IF EXISTS "+C,[],function(){x()},function(O,ee){F(ee)})})}s(h,"dropTable");for(var v=[],E=0,w=n.storeNames.length;E<w;E++)v.push(h(n.storeNames[E]));g.all(v).then(function(){f()}).catch(function(C){c(C)})},function(d){c(d)})})}):o=g.reject("Invalid arguments"),S(o,r),o}s(Qt,"dropInstance$1");var qt={_driver:"webSQLStorage",_initStorage:Mt,_support:Ft(),iterate:Yt,getItem:kt,setItem:Kt,removeItem:zt,clear:Jt,length:Wt,key:Ht,keys:jt,dropInstance:Qt};function Xt(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}s(Xt,"isLocalStorageValid");function dt(e,r){var t=e.name+"/";return e.storeName!==r.storeName&&(t+=e.storeName+"/"),t}s(dt,"_getKeyPrefix");function Zt(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}s(Zt,"checkIfLocalStorageThrows");function er(){return!Zt()||localStorage.length>0}s(er,"_isLocalStorageUsable");function tr(e){var r=this,t={};if(e)for(var a in e)t[a]=e[a];return t.keyPrefix=dt(e,r._defaultConfig),er()?(r._dbInfo=t,t.serializer=Me,g.resolve()):g.reject()}s(tr,"_initStorage$2");function rr(e){var r=this,t=r.ready().then(function(){for(var a=r._dbInfo.keyPrefix,o=localStorage.length-1;o>=0;o--){var n=localStorage.key(o);n.indexOf(a)===0&&localStorage.removeItem(n)}});return S(t,e),t}s(rr,"clear$2");function nr(e,r){var t=this;e=V(e);var a=t.ready().then(function(){var o=t._dbInfo,n=localStorage.getItem(o.keyPrefix+e);return n&&(n=o.serializer.deserialize(n)),n});return S(a,r),a}s(nr,"getItem$2");function ar(e,r){var t=this,a=t.ready().then(function(){for(var o=t._dbInfo,n=o.keyPrefix,f=n.length,c=localStorage.length,d=1,h=0;h<c;h++){var v=localStorage.key(h);if(v.indexOf(n)===0){var E=localStorage.getItem(v);if(E&&(E=o.serializer.deserialize(E)),E=e(E,v.substring(f),d++),E!==void 0)return E}}});return S(a,r),a}s(ar,"iterate$2");function or(e,r){var t=this,a=t.ready().then(function(){var o=t._dbInfo,n;try{n=localStorage.key(e)}catch{n=null}return n&&(n=n.substring(o.keyPrefix.length)),n});return S(a,r),a}s(or,"key$2");function ir(e){var r=this,t=r.ready().then(function(){for(var a=r._dbInfo,o=localStorage.length,n=[],f=0;f<o;f++){var c=localStorage.key(f);c.indexOf(a.keyPrefix)===0&&n.push(c.substring(a.keyPrefix.length))}return n});return S(t,e),t}s(ir,"keys$2");function sr(e){var r=this,t=r.keys().then(function(a){return a.length});return S(t,e),t}s(sr,"length$2");function ur(e,r){var t=this;e=V(e);var a=t.ready().then(function(){var o=t._dbInfo;localStorage.removeItem(o.keyPrefix+e)});return S(a,r),a}s(ur,"removeItem$2");function fr(e,r,t){var a=this;e=V(e);var o=a.ready().then(function(){r===void 0&&(r=null);var n=r;return new g(function(f,c){var d=a._dbInfo;d.serializer.serialize(r,function(h,v){if(v)c(v);else try{localStorage.setItem(d.keyPrefix+e,h),f(n)}catch(E){(E.name==="QuotaExceededError"||E.name==="NS_ERROR_DOM_QUOTA_REACHED")&&c(E),c(E)}})})});return S(o,t),o}s(fr,"setItem$2");function cr(e,r){if(r=re.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 a=this,o;return e.name?o=new g(function(n){e.storeName?n(dt(e,a._defaultConfig)):n(e.name+"/")}).then(function(n){for(var f=localStorage.length-1;f>=0;f--){var c=localStorage.key(f);c.indexOf(n)===0&&localStorage.removeItem(c)}}):o=g.reject("Invalid arguments"),S(o,r),o}s(cr,"dropInstance$2");var lr={_driver:"localStorageWrapper",_initStorage:tr,_support:Xt(),iterate:ar,getItem:nr,setItem:fr,removeItem:ur,clear:rr,length:sr,key:or,keys:ir,dropInstance:cr},dr=s(function(r,t){return r===t||typeof r=="number"&&typeof t=="number"&&isNaN(r)&&isNaN(t)},"sameValue"),hr=s(function(r,t){for(var a=r.length,o=0;o<a;){if(dr(r[o],t))return!0;o++}return!1},"includes"),ht=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},we={},yt={},Ee={INDEXEDDB:Lt,WEBSQL:qt,LOCALSTORAGE:lr},yr=[Ee.INDEXEDDB._driver,Ee.WEBSQL._driver,Ee.LOCALSTORAGE._driver],Oe=["dropInstance"],ke=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Oe),vr={description:"",driver:yr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function pr(e,r){e[r]=function(){var t=arguments;return e.ready().then(function(){return e[r].apply(e,t)})}}s(pr,"callWhenReady");function Ye(){for(var e=1;e<arguments.length;e++){var r=arguments[e];if(r)for(var t in r)r.hasOwnProperty(t)&&(ht(r[t])?arguments[0][t]=r[t].slice():arguments[0][t]=r[t])}return arguments[0]}s(Ye,"extend");var mr=function(){function e(r){B(this,e);for(var t in Ee)if(Ee.hasOwnProperty(t)){var a=Ee[t],o=a._driver;this[t]=o,we[o]||this.defineDriver(a)}this._defaultConfig=Ye({},vr),this._config=Ye({},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 s(e,"LocalForage"),e.prototype.config=s(function(t){if((typeof t>"u"?"undefined":D(t))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var a in t){if(a==="storeName"&&(t[a]=t[a].replace(/\W/g,"_")),a==="version"&&typeof t[a]!="number")return new Error("Database version must be a number.");this._config[a]=t[a]}return"driver"in t&&t.driver?this.setDriver(this._config.driver):!0}else return typeof t=="string"?this._config[t]:this._config},"config"),e.prototype.defineDriver=s(function(t,a,o){var n=new g(function(f,c){try{var d=t._driver,h=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver){c(h);return}for(var v=ke.concat("_initStorage"),E=0,w=v.length;E<w;E++){var C=v[E],x=!hr(Oe,C);if((x||t[C])&&typeof t[C]!="function"){c(h);return}}var F=s(function(){for(var Te=s(function(Er){return function(){var Sr=new Error("Method "+Er+" is not implemented by the current driver"),vt=g.reject(Sr);return S(vt,arguments[arguments.length-1]),vt}},"methodNotImplementedFactory"),Ke=0,br=Oe.length;Ke<br;Ke++){var ze=Oe[Ke];t[ze]||(t[ze]=Te(ze))}},"configureMissingMethods");F();var O=s(function(Te){we[d]&&console.info("Redefining LocalForage driver: "+d),we[d]=t,yt[d]=Te,f()},"setDriverSupport");"_support"in t?t._support&&typeof t._support=="function"?t._support().then(O,c):O(!!t._support):O(!0)}catch(ee){c(ee)}});return L(n,a,o),n},"defineDriver"),e.prototype.driver=s(function(){return this._driver||null},"driver"),e.prototype.getDriver=s(function(t,a,o){var n=we[t]?g.resolve(we[t]):g.reject(new Error("Driver not found."));return L(n,a,o),n},"getDriver"),e.prototype.getSerializer=s(function(t){var a=g.resolve(Me);return L(a,t),a},"getSerializer"),e.prototype.ready=s(function(t){var a=this,o=a._driverSet.then(function(){return a._ready===null&&(a._ready=a._initDriver()),a._ready});return L(o,t,t),o},"ready"),e.prototype.setDriver=s(function(t,a,o){var n=this;ht(t)||(t=[t]);var f=this._getSupportedDrivers(t);function c(){n._config.driver=n.driver()}s(c,"setDriverToConfig");function d(E){return n._extend(E),c(),n._ready=n._initStorage(n._config),n._ready}s(d,"extendSelfWithDriver");function h(E){return function(){var w=0;function C(){for(;w<E.length;){var x=E[w];return w++,n._dbInfo=null,n._ready=null,n.getDriver(x).then(d).catch(C)}c();var F=new Error("No available storage method found.");return n._driverSet=g.reject(F),n._driverSet}return s(C,"driverPromiseLoop"),C()}}s(h,"initDriver");var v=this._driverSet!==null?this._driverSet.catch(function(){return g.resolve()}):g.resolve();return this._driverSet=v.then(function(){var E=f[0];return n._dbInfo=null,n._ready=null,n.getDriver(E).then(function(w){n._driver=w._driver,c(),n._wrapLibraryMethodsWithReady(),n._initDriver=h(f)})}).catch(function(){c();var E=new Error("No available storage method found.");return n._driverSet=g.reject(E),n._driverSet}),L(this._driverSet,a,o),this._driverSet},"setDriver"),e.prototype.supports=s(function(t){return!!yt[t]},"supports"),e.prototype._extend=s(function(t){Ye(this,t)},"_extend"),e.prototype._getSupportedDrivers=s(function(t){for(var a=[],o=0,n=t.length;o<n;o++){var f=t[o];this.supports(f)&&a.push(f)}return a},"_getSupportedDrivers"),e.prototype._wrapLibraryMethodsWithReady=s(function(){for(var t=0,a=ke.length;t<a;t++)pr(this,ke[t])},"_wrapLibraryMethodsWithReady"),e.prototype.createInstance=s(function(t){return new e(t)},"createInstance"),e}(),gr=new mr;y.exports=gr},{"3":3}]},{},[4])(4)})});var pt=s(p=>p==null,"isNil");var mt=s(()=>{let p=new Date().getTime(),i=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(u){let l=Math.random()*16;return p>0?(l=(p+l)%16|0,p=Math.floor(p/16)):(l=(i+l)%16|0,i=Math.floor(i/16)),(u==="x"?l:l&3|8).toString(16)})},"generateUUID");var gt=s(p=>(typeof p=="string"||p instanceof String)&&p.trim()==="","isEmptyString");var ae=class{constructor(){this.value=(()=>{try{return crypto.randomUUID()}catch{return mt()}})()}};s(ae,"SchemaId");var xr=s(p=>{switch(p){case Number:return 0;case Boolean:return!1;case String:return"";case Array:case Float32Array:case Float64Array:case Int8Array:case Int16Array:case Int32Array:case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:return new p;case ArrayBuffer:return new p(0);default:return null}},"getDefaultValue"),He=s((p,i)=>{try{return i instanceof p||typeof i===p.name.toLowerCase()}catch{return!1}},"isSameValueType"),ne=class{constructor(i,u=!1,l=null){this.type=i;this.required=u;this.defaultValue=l;if(l!==null&&!He(i,l))throw new Error(`Default value "${l.toString()}" does not match type "${i.name}"`);this.defaultValue=l??xr(this.type)}toJSON(){return{type:this.type instanceof fe?this.type.toJSON():this.type.name,required:this.required,defaultValue:this.defaultValue}}toString(){return JSON.stringify(this.toJSON(),null,4)}};s(ne,"SchemaValue");var Ae,M,_e,Ie,ye=class{constructor(i,u=null,l=!0){G(this,Ae,["id","createdDate","lastUpdatedDate"]);G(this,M,{id:new ne(ae,!1),createdDate:new ne(Date,!1),lastUpdatedDate:new ne(Date,!1)});G(this,_e,void 0);G(this,Ie,!0);if(W(this,_e,i),W(this,Ie,l),l||W(this,M,{}),u){for(let y in u)if(u.hasOwnProperty(y))if(u[y]instanceof ne)b(this,Ae).includes(y)||(b(this,M)[y]=u[y]);else throw new Error(`Field "${y}" is not a SchemaValue`)}}get name(){return b(this,_e)}get includeDefaultKeys(){return b(this,Ie)}get defaultKeys(){return b(this,Ae)}defineField(i,u,{defaultValue:l,required:y}={defaultValue:null,required:!1}){b(this,M)[`${i}`]=new ne(u,y,l)}removeField(i){if(i){let[u,...l]=`${i}`.split("."),y=b(this,M)[u];y&&(l.length?y.type instanceof ye&&y.type.removeField(l.join(".")):delete b(this,M)[u])}}hasField(i){if(i){let[u,...l]=`${i}`.split("."),y=b(this,M)[u];if(y)if(l.length){if(y.type instanceof ye)return y.type.hasField(l.join("."))}else return b(this,M).hasOwnProperty(u)}return!1}getField(i){if(i){let[u,...l]=`${i}`.split("."),y=b(this,M)[u];return y&&l.length&&y.type instanceof ye?y.type.getField(l.join(".")):y??null}return null}isValidFieldValue(i,u=null){let l=this.getField(`${i}`);return l?u instanceof Array&&u.some(y=>!Nr(y))?!1:l.type instanceof ye?`${u}`=="[object Object]"&&l.type.getInvalidSchemaDataFields(u).length===0:l.required?!pt(u)&&(l.type!==String||!gt(u))&&He(l.type,u):u===null||u===l.defaultValue||He(l.type,u):!1}getInvalidSchemaDataFields(i){let u=new Set,l=Object.keys(b(this,M)).filter(y=>b(this,M)[y].required);for(let y of[...Object.keys(i),...l])if(!this.defaultKeys.includes(y)){let _=this.getField(y);if(_?.type instanceof ye){let D=i[y];`${D}`=="[object Object]"?_.type.getInvalidSchemaDataFields(D).map(B=>{u.add(`${y}.${B}`)}):u.add(y);continue}this.isValidFieldValue(y,i[y])||u.add(y)}return Array.from(u)}toJSON(){let i={};for(let u in b(this,M))if(b(this,M).hasOwnProperty(u)){let l=b(this,M)[u];i[u]=l.toJSON()}return i}toString(){return JSON.stringify(this.toJSON(),null,4)}toValue(){let i=new Date,u=this.includeDefaultKeys?{id:new ae().value,createdDate:i,lastUpdatedDate:i}:{};for(let l in b(this,M))if(b(this,M).hasOwnProperty(l)&&!this.defaultKeys.includes(l)){let y=b(this,M)[l];switch(!0){case y.type instanceof ye:u[l]=y.type.toValue();break;case y.type===ae:u[l]=new ae().value;break;case y.type===Date:u[l]=y.defaultValue instanceof Date?y.defaultValue:i;break;default:u[l]=y.defaultValue}}return u}},fe=ye;s(fe,"Schema"),Ae=new WeakMap,M=new WeakMap,_e=new WeakMap,Ie=new WeakMap;function Nr(p){return p===null||[fe,ae,Date,Number,String,Boolean,Array,ArrayBuffer,Blob,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array].some(i=>p instanceof i||typeof p===i.name.toLowerCase())}s(Nr,"isSupportedTypeValue");var te=Cr(Et());var ce=s((p,i)=>typeof i=="function"?i(null,p):Promise.resolve(p),"callBackOrPromise"),Be="Memory",St=s(()=>{let p=new Map;return{_driver:Be,_initStorage(){return p},async clear(i){ce(p.clear(),i)},async getItem(i,u){return ce(p.get(i)??null,u)||null},async iterate(i,u){let l=0,y;for(let[_,D]of p.entries()){if(y=i(D,_,l),y!==void 0)return ce(y,u);l+=1}return ce(null,u)},async key(i,u){return ce(Array.from(p.keys())[i],u)||""},async keys(i){return ce(Array.from(p.keys()),i)||[]},async length(i){return ce(p.size,i)||0},async removeItem(i,u){return ce(p.delete(i),u)},async setItem(i,u,l){return ce(p.set(i,u),l)}}},"MemoryStore");te.default.defineDriver(St());var wt={version:1,type:[te.INDEXEDDB,te.WEBSQL,te.LOCALSTORAGE,Be],description:"",appName:"App"},k,le,Re,q,ge,oe,Ce,ve,Y,j,A=class{constructor(i,u,l=wt){G(this,Y);G(this,k,void 0);G(this,le,void 0);G(this,Re,void 0);G(this,q,void 0);G(this,ge,[]);G(this,oe,s(()=>!0,"#beforeChangeHandler"));G(this,Ce,!1);G(this,ve,0);if(W(this,Re,i),W(this,le,{...wt,...l}),!(u instanceof fe))throw new Error('Missing or unknown "Schema"');let y=b(this,le).appName||"App";W(this,q,u),W(this,k,te.default.createInstance({driver:b(this,le).type,version:b(this,le).version,description:b(this,le).description,name:y,storeName:i})),b(this,k).ready(()=>{console.info(`[Info] ClientStore "${i}" successfully created`),W(this,Ce,!0),H(this,Y,j).call(this,A.EventType.READY,!0)})}get ready(){return b(this,Ce)}get type(){return b(this,k).driver()}get name(){return`${b(this,le).appName}-${b(this,Re)}`}get size(){return b(this,ve)}subscribe(i){return typeof i=="function"&&b(this,ge).push(i),()=>{W(this,ge,b(this,ge).filter(u=>u!==i))}}beforeChange(i){return typeof i=="function"&&W(this,oe,i),()=>{W(this,oe,()=>!0)}}async loadItems(i=[]){if(i.length)try{if(await b(this,oe).call(this,A.EventType.LOADED,i)===!0){let l=new Map;for(let _ of i){let D=_.id?await this.getItem(_.id):b(this,q).toValue();for(let I in D)if(D.hasOwnProperty(I)){let U=_[I];U&&(D[I]=U)}let B=b(this,q).getInvalidSchemaDataFields(D);if(!B.length)l.set(D.id,D);else throw new Error(`Missing or invalid field types: [${B.join(", ")}] in "${JSON.stringify(_,null,2)}".`)}let y=Array.from(l.values());return await Promise.all(y.map(_=>b(this,k).setItem(`${_.id}`,_))),W(this,ve,await b(this,k).length()),H(this,Y,j).call(this,A.EventType.LOADED,y),y}else H(this,Y,j).call(this,A.EventType.ABORTED,{action:A.EventType.LOADED,data:i})}catch(u){H(this,Y,j).call(this,A.EventType.ERROR,{action:A.EventType.LOADED,error:u,data:i})}return[]}async createItem(i){let u=b(this,q).getInvalidSchemaDataFields(i);if(!u.length){let l=b(this,q).toValue();for(let y in i)i.hasOwnProperty(y)&&!b(this,q).defaultKeys.includes(y)&&(l[y]=i[y]);try{if(await b(this,oe).call(this,A.EventType.CREATED,l)===!0)return await b(this,k).setItem(`${l.id}`,l),W(this,ve,await b(this,k).length()),H(this,Y,j).call(this,A.EventType.CREATED,l),l;H(this,Y,j).call(this,A.EventType.ABORTED,{action:A.EventType.CREATED,data:i})}catch(y){console.error(`Failed to create item "${JSON.stringify(i,null,2)}"`,y),H(this,Y,j).call(this,A.EventType.ERROR,{action:A.EventType.CREATED,error:y,data:i})}return null}throw new Error(`Failed to create item. Field(s) "${u.join(", ")}" do not match the schema: ${b(this,q)}`)}async updateItem(i,u){for(let _ in u)if(u.hasOwnProperty(_)&&!b(this,q).defaultKeys.includes(_)&&!b(this,q).isValidFieldValue(_,u[_]))throw new Error(`Failed to update item "${i}". Key "${_}" is unknown or has invalid value type: ${b(this,q).getField(_)}`);let l=await this.getItem(i),y={...l,...u,createdDate:l.createdDate,lastUpdatedDate:new Date,id:l.id};try{if(await b(this,oe).call(this,A.EventType.UPDATED,y)===!0)return await b(this,k).setItem(`${l.id}`,y),H(this,Y,j).call(this,A.EventType.UPDATED,y),y;H(this,Y,j).call(this,A.EventType.ABORTED,{action:A.EventType.UPDATED,data:u})}catch(_){console.error(`Failed to update item with id "${i}"`,_),H(this,Y,j).call(this,A.EventType.ERROR,{action:A.EventType.UPDATED,error:_,data:u})}return null}async getItems(){return this.findItems(()=>!0)}getItem(i){return b(this,k).getItem(`${i}`)}async removeItem(i){try{if(await b(this,oe).call(this,A.EventType.DELETED,i)===!0)return await b(this,k).removeItem(`${i}`),W(this,ve,await b(this,k).length()),H(this,Y,j).call(this,A.EventType.DELETED,i),!0;H(this,Y,j).call(this,A.EventType.ABORTED,{action:A.EventType.DELETED,data:i})}catch(u){console.error(`Failed to delete item with id "${i}"`,u),H(this,Y,j).call(this,A.EventType.ERROR,{action:A.EventType.DELETED,error:u,data:i})}return null}async clear(){let i=await b(this,k).keys();try{if(await b(this,oe).call(this,A.EventType.CLEARED,i))return await b(this,k).clear(),W(this,ve,await b(this,k).length()),H(this,Y,j).call(this,A.EventType.CLEARED,i),i;H(this,Y,j).call(this,A.EventType.ABORTED,{action:A.EventType.CLEARED,data:i})}catch(u){console.error("Failed to clear the store",u),H(this,Y,j).call(this,A.EventType.ERROR,{action:A.EventType.CLEARED,error:u,data:i})}return null}async findItem(i=()=>!1){return b(this,k).iterate((u,l)=>{if(i(u,l))return u})||null}async findItems(i=()=>!1){let u=[];return await b(this,k).iterate((l,y)=>{i(l,y)&&l&&u.push(l)}),u}},pe=A;s(pe,"ClientStore"),k=new WeakMap,le=new WeakMap,Re=new WeakMap,q=new WeakMap,ge=new WeakMap,oe=new WeakMap,Ce=new WeakMap,ve=new WeakMap,Y=new WeakSet,j=s(function(i,u){b(this,ge).forEach(l=>l(i,u))},"#broadcast");(u=>{let p;(P=>(P.READY="ready",P.CREATED="created",P.LOADED="loaded",P.ERROR="error",P.ABORTED="aborted",P.DELETED="deleted",P.UPDATED="updated",P.CLEARED="cleared"))(p=u.EventType||(u.EventType={})),u.Type={LOCALSTORAGE:te.LOCALSTORAGE,WEBSQL:te.WEBSQL,INDEXEDDB:te.INDEXEDDB,MEMORY_STORAGE:Be}})(pe||(pe={}));window&&(window.Schema=fe,window.SchemaValue=ne,window.SchemaId=ae,window.ClientStore=pe);})(); | ||
(()=>{var wr=Object.create;var Je=Object.defineProperty;var Tr=Object.getOwnPropertyDescriptor;var Dr=Object.getOwnPropertyNames;var Ar=Object.getPrototypeOf,_r=Object.prototype.hasOwnProperty;var s=(p,i)=>Je(p,"name",{value:i,configurable:!0}),De=(p=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(p,{get:(i,u)=>(typeof require!="undefined"?require:i)[u]}):p)(function(p){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+p+'" is not supported')});var Ir=(p,i)=>()=>(i||p((i={exports:{}}).exports,i),i.exports);var Rr=(p,i,u,l)=>{if(i&&typeof i=="object"||typeof i=="function")for(let y of Dr(i))!_r.call(p,y)&&y!==u&&Je(p,y,{get:()=>i[y],enumerable:!(l=Tr(i,y))||l.enumerable});return p};var Cr=(p,i,u)=>(u=p!=null?wr(Ar(p)):{},Rr(i||!p||!p.__esModule?Je(u,"default",{value:p,enumerable:!0}):u,p));var We=(p,i,u)=>{if(!i.has(p))throw TypeError("Cannot "+u)};var b=(p,i,u)=>(We(p,i,"read from private field"),u?u.call(p):i.get(p)),G=(p,i,u)=>{if(i.has(p))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(p):i.set(p,u)},W=(p,i,u,l)=>(We(p,i,"write to private field"),l?l.call(p,u):i.set(p,u),u);var H=(p,i,u)=>(We(p,i,"access private method"),u);var Et=Ir((bt,je)=>{(function(p){if(typeof bt=="object"&&typeof je<"u")je.exports=p();else if(typeof define=="function"&&define.amd)define([],p);else{var i;typeof window<"u"?i=window:typeof global<"u"?i=global:typeof self<"u"?i=self:i=this,i.localforage=p()}})(function(){var p,i,u;return s(function l(y,_,D){function B(z,P){if(!_[z]){if(!y[z]){var g=typeof De=="function"&&De;if(!P&&g)return g(z,!0);if(I)return I(z,!0);var S=new Error("Cannot find module '"+z+"'");throw S.code="MODULE_NOT_FOUND",S}var L=_[z]={exports:{}};y[z][0].call(L.exports,function(V){var re=y[z][1][V];return B(re||V)},L,L.exports,l,y,_,D)}return _[z].exports}s(B,"s");for(var I=typeof De=="function"&&De,U=0;U<D.length;U++)B(D[U]);return B},"e")({1:[function(l,y,_){(function(D){"use strict";var B=D.MutationObserver||D.WebKitMutationObserver,I;if(B){var U=0,z=new B(V),P=D.document.createTextNode("");z.observe(P,{characterData:!0}),I=s(function(){P.data=U=++U%2},"scheduleDrain")}else if(!D.setImmediate&&typeof D.MessageChannel<"u"){var g=new D.MessageChannel;g.port1.onmessage=V,I=s(function(){g.port2.postMessage(0)},"scheduleDrain")}else"document"in D&&"onreadystatechange"in D.document.createElement("script")?I=s(function(){var $=D.document.createElement("script");$.onreadystatechange=function(){V(),$.onreadystatechange=null,$.parentNode.removeChild($),$=null},D.document.documentElement.appendChild($)},"scheduleDrain"):I=s(function(){setTimeout(V,0)},"scheduleDrain");var S,L=[];function V(){S=!0;for(var $,ie,K=L.length;K;){for(ie=L,L=[],$=-1;++$<K;)ie[$]();K=L.length}S=!1}s(V,"nextTick"),y.exports=re;function re($){L.push($)===1&&!S&&I()}s(re,"immediate")}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(l,y,_){"use strict";var D=l(1);function B(){}s(B,"INTERNAL");var I={},U=["REJECTED"],z=["FULFILLED"],P=["PENDING"];y.exports=g;function g(m){if(typeof m!="function")throw new TypeError("resolver must be a function");this.state=P,this.queue=[],this.outcome=void 0,m!==B&&re(this,m)}s(g,"Promise"),g.prototype.catch=function(m){return this.then(null,m)},g.prototype.then=function(m,R){if(typeof m!="function"&&this.state===z||typeof R!="function"&&this.state===U)return this;var T=new this.constructor(B);if(this.state!==P){var N=this.state===z?m:R;L(T,N,this.outcome)}else this.queue.push(new S(T,m,R));return T};function S(m,R,T){this.promise=m,typeof R=="function"&&(this.onFulfilled=R,this.callFulfilled=this.otherCallFulfilled),typeof T=="function"&&(this.onRejected=T,this.callRejected=this.otherCallRejected)}s(S,"QueueItem"),S.prototype.callFulfilled=function(m){I.resolve(this.promise,m)},S.prototype.otherCallFulfilled=function(m){L(this.promise,this.onFulfilled,m)},S.prototype.callRejected=function(m){I.reject(this.promise,m)},S.prototype.otherCallRejected=function(m){L(this.promise,this.onRejected,m)};function L(m,R,T){D(function(){var N;try{N=R(T)}catch(J){return I.reject(m,J)}N===m?I.reject(m,new TypeError("Cannot resolve promise with itself")):I.resolve(m,N)})}s(L,"unwrap"),I.resolve=function(m,R){var T=$(V,R);if(T.status==="error")return I.reject(m,T.value);var N=T.value;if(N)re(m,N);else{m.state=z,m.outcome=R;for(var J=-1,Q=m.queue.length;++J<Q;)m.queue[J].callFulfilled(R)}return m},I.reject=function(m,R){m.state=U,m.outcome=R;for(var T=-1,N=m.queue.length;++T<N;)m.queue[T].callRejected(R);return m};function V(m){var R=m&&m.then;if(m&&(typeof m=="object"||typeof m=="function")&&typeof R=="function")return s(function(){R.apply(m,arguments)},"appyThen")}s(V,"getThen");function re(m,R){var T=!1;function N(Z){T||(T=!0,I.reject(m,Z))}s(N,"onError");function J(Z){T||(T=!0,I.resolve(m,Z))}s(J,"onSuccess");function Q(){R(J,N)}s(Q,"tryToUnwrap");var X=$(Q);X.status==="error"&&N(X.value)}s(re,"safelyResolveThenable");function $(m,R){var T={};try{T.value=m(R),T.status="success"}catch(N){T.status="error",T.value=N}return T}s($,"tryCatch"),g.resolve=ie;function ie(m){return m instanceof this?m:I.resolve(new this(B),m)}s(ie,"resolve"),g.reject=K;function K(m){var R=new this(B);return I.reject(R,m)}s(K,"reject"),g.all=Pe;function Pe(m){var R=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var T=m.length,N=!1;if(!T)return this.resolve([]);for(var J=new Array(T),Q=0,X=-1,Z=new this(B);++X<T;)se(m[X],X);return Z;function se(Se,xe){R.resolve(Se).then(Le,function(be){N||(N=!0,I.reject(Z,be))});function Le(be){J[xe]=be,++Q===T&&!N&&(N=!0,I.resolve(Z,J))}s(Le,"resolveFromAll")}}s(Pe,"all"),g.race=me;function me(m){var R=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var T=m.length,N=!1;if(!T)return this.resolve([]);for(var J=-1,Q=new this(B);++J<T;)X(m[J]);return Q;function X(Z){R.resolve(Z).then(function(se){N||(N=!0,I.resolve(Q,se))},function(se){N||(N=!0,I.reject(Q,se))})}}s(me,"race")},{"1":1}],3:[function(l,y,_){(function(D){"use strict";typeof D.Promise!="function"&&(D.Promise=l(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{"2":2}],4:[function(l,y,_){"use strict";var D=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 B(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}s(B,"_classCallCheck");function I(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}s(I,"getIDB");var U=I();function z(){try{if(!U||!U.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{return!1}}s(z,"isIndexedDBValid");function P(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,a=new t,o=0;o<e.length;o+=1)a.append(e[o]);return a.getBlob(r.type)}}s(P,"createBlob"),typeof Promise>"u"&&l(3);var g=Promise;function S(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}s(S,"executeCallback");function L(e,r,t){typeof r=="function"&&e.then(r),typeof t=="function"&&e.catch(t)}s(L,"executeTwoCallbacks");function V(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}s(V,"normalizeKey");function re(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}s(re,"getCallback");var $="local-forage-detect-blob-support",ie=void 0,K={},Pe=Object.prototype.toString,me="readonly",m="readwrite";function R(e){for(var r=e.length,t=new ArrayBuffer(r),a=new Uint8Array(t),o=0;o<r;o++)a[o]=e.charCodeAt(o);return t}s(R,"_binStringToArrayBuffer");function T(e){return new g(function(r){var t=e.transaction($,m),a=P([""]);t.objectStore($).put(a,"key"),t.onabort=function(o){o.preventDefault(),o.stopPropagation(),r(!1)},t.oncomplete=function(){var o=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);r(n||!o||parseInt(o[1],10)>=43)}}).catch(function(){return!1})}s(T,"_checkBlobSupportWithoutCaching");function N(e){return typeof ie=="boolean"?g.resolve(ie):T(e).then(function(r){return ie=r,ie})}s(N,"_checkBlobSupport");function J(e){var r=K[e.name],t={};t.promise=new g(function(a,o){t.resolve=a,t.reject=o}),r.deferredOperations.push(t),r.dbReady?r.dbReady=r.dbReady.then(function(){return t.promise}):r.dbReady=t.promise}s(J,"_deferReadiness");function Q(e){var r=K[e.name],t=r.deferredOperations.pop();if(t)return t.resolve(),t.promise}s(Q,"_advanceReadiness");function X(e,r){var t=K[e.name],a=t.deferredOperations.pop();if(a)return a.reject(r),a.promise}s(X,"_rejectReadiness");function Z(e,r){return new g(function(t,a){if(K[e.name]=K[e.name]||Qe(),e.db)if(r)J(e),e.db.close();else return t(e.db);var o=[e.name];r&&o.push(e.version);var n=U.open.apply(U,o);r&&(n.onupgradeneeded=function(f){var c=n.result;try{c.createObjectStore(e.storeName),f.oldVersion<=1&&c.createObjectStore($)}catch(d){if(d.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw d}}),n.onerror=function(f){f.preventDefault(),a(n.error)},n.onsuccess=function(){var f=n.result;f.onversionchange=function(c){c.target.close()},t(f),Q(e)}})}s(Z,"_getConnection");function se(e){return Z(e,!1)}s(se,"_getOriginalConnection");function Se(e){return Z(e,!0)}s(Se,"_getUpgradedConnection");function xe(e,r){if(!e.db)return!0;var t=!e.db.objectStoreNames.contains(e.storeName),a=e.version<e.db.version,o=e.version>e.db.version;if(a&&(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),o||t){if(t){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}s(xe,"_isUpgradeNeeded");function Le(e){return new g(function(r,t){var a=new FileReader;a.onerror=t,a.onloadend=function(o){var n=btoa(o.target.result||"");r({__local_forage_encoded_blob:!0,data:n,type:e.type})},a.readAsBinaryString(e)})}s(Le,"_encodeBlob");function be(e){var r=R(atob(e.data));return P([r],{type:e.type})}s(be,"_decodeBlob");function Ge(e){return e&&e.__local_forage_encoded_blob}s(Ge,"_isEncodedBlob");function Tt(e){var r=this,t=r._initReady().then(function(){var a=K[r._dbInfo.name];if(a&&a.dbReady)return a.dbReady});return L(t,e,e),t}s(Tt,"_fullyReady");function Dt(e){J(e);for(var r=K[e.name],t=r.forages,a=0;a<t.length;a++){var o=t[a];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,se(e).then(function(n){return e.db=n,xe(e)?Se(e):n}).then(function(n){e.db=r.db=n;for(var f=0;f<t.length;f++)t[f]._dbInfo.db=n}).catch(function(n){throw X(e,n),n})}s(Dt,"_tryReconnect");function ue(e,r,t,a){a===void 0&&(a=1);try{var o=e.db.transaction(e.storeName,r);t(null,o)}catch(n){if(a>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return g.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),Se(e)}).then(function(){return Dt(e).then(function(){ue(e,r,t,a-1)})}).catch(t);t(n)}}s(ue,"createTransaction");function Qe(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}s(Qe,"createDbContext");function At(e){var r=this,t={db:null};if(e)for(var a in e)t[a]=e[a];var o=K[t.name];o||(o=Qe(),K[t.name]=o),o.forages.push(r),r._initReady||(r._initReady=r.ready,r.ready=Tt);var n=[];function f(){return g.resolve()}s(f,"ignoreErrors");for(var c=0;c<o.forages.length;c++){var d=o.forages[c];d!==r&&n.push(d._initReady().catch(f))}var h=o.forages.slice(0);return g.all(n).then(function(){return t.db=o.db,se(t)}).then(function(v){return t.db=v,xe(t,r._defaultConfig.version)?Se(t):v}).then(function(v){t.db=o.db=v,r._dbInfo=t;for(var E=0;E<h.length;E++){var w=h[E];w!==r&&(w._dbInfo.db=t.db,w._dbInfo.version=t.version)}})}s(At,"_initStorage");function _t(e,r){var t=this;e=V(e);var a=new g(function(o,n){t.ready().then(function(){ue(t._dbInfo,me,function(f,c){if(f)return n(f);try{var d=c.objectStore(t._dbInfo.storeName),h=d.get(e);h.onsuccess=function(){var v=h.result;v===void 0&&(v=null),Ge(v)&&(v=be(v)),o(v)},h.onerror=function(){n(h.error)}}catch(v){n(v)}})}).catch(n)});return S(a,r),a}s(_t,"getItem");function It(e,r){var t=this,a=new g(function(o,n){t.ready().then(function(){ue(t._dbInfo,me,function(f,c){if(f)return n(f);try{var d=c.objectStore(t._dbInfo.storeName),h=d.openCursor(),v=1;h.onsuccess=function(){var E=h.result;if(E){var w=E.value;Ge(w)&&(w=be(w));var C=e(w,E.key,v++);C!==void 0?o(C):E.continue()}else o()},h.onerror=function(){n(h.error)}}catch(E){n(E)}})}).catch(n)});return S(a,r),a}s(It,"iterate");function Rt(e,r,t){var a=this;e=V(e);var o=new g(function(n,f){var c;a.ready().then(function(){return c=a._dbInfo,Pe.call(r)==="[object Blob]"?N(c.db).then(function(d){return d?r:Le(r)}):r}).then(function(d){ue(a._dbInfo,m,function(h,v){if(h)return f(h);try{var E=v.objectStore(a._dbInfo.storeName);d===null&&(d=void 0);var w=E.put(d,e);v.oncomplete=function(){d===void 0&&(d=null),n(d)},v.onabort=v.onerror=function(){var C=w.error?w.error:w.transaction.error;f(C)}}catch(C){f(C)}})}).catch(f)});return S(o,t),o}s(Rt,"setItem");function Ct(e,r){var t=this;e=V(e);var a=new g(function(o,n){t.ready().then(function(){ue(t._dbInfo,m,function(f,c){if(f)return n(f);try{var d=c.objectStore(t._dbInfo.storeName),h=d.delete(e);c.oncomplete=function(){o()},c.onerror=function(){n(h.error)},c.onabort=function(){var v=h.error?h.error:h.transaction.error;n(v)}}catch(v){n(v)}})}).catch(n)});return S(a,r),a}s(Ct,"removeItem");function xt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){ue(r._dbInfo,m,function(n,f){if(n)return o(n);try{var c=f.objectStore(r._dbInfo.storeName),d=c.clear();f.oncomplete=function(){a()},f.onabort=f.onerror=function(){var h=d.error?d.error:d.transaction.error;o(h)}}catch(h){o(h)}})}).catch(o)});return S(t,e),t}s(xt,"clear");function Nt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){ue(r._dbInfo,me,function(n,f){if(n)return o(n);try{var c=f.objectStore(r._dbInfo.storeName),d=c.count();d.onsuccess=function(){a(d.result)},d.onerror=function(){o(d.error)}}catch(h){o(h)}})}).catch(o)});return S(t,e),t}s(Nt,"length");function Ot(e,r){var t=this,a=new g(function(o,n){if(e<0){o(null);return}t.ready().then(function(){ue(t._dbInfo,me,function(f,c){if(f)return n(f);try{var d=c.objectStore(t._dbInfo.storeName),h=!1,v=d.openKeyCursor();v.onsuccess=function(){var E=v.result;if(!E){o(null);return}e===0||h?o(E.key):(h=!0,E.advance(e))},v.onerror=function(){n(v.error)}}catch(E){n(E)}})}).catch(n)});return S(a,r),a}s(Ot,"key");function Bt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){ue(r._dbInfo,me,function(n,f){if(n)return o(n);try{var c=f.objectStore(r._dbInfo.storeName),d=c.openKeyCursor(),h=[];d.onsuccess=function(){var v=d.result;if(!v){a(h);return}h.push(v.key),v.continue()},d.onerror=function(){o(d.error)}}catch(v){o(v)}})}).catch(o)});return S(t,e),t}s(Bt,"keys");function Pt(e,r){r=re.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 a=this,o;if(!e.name)o=g.reject("Invalid arguments");else{var n=e.name===t.name&&a._dbInfo.db,f=n?g.resolve(a._dbInfo.db):se(e).then(function(c){var d=K[e.name],h=d.forages;d.db=c;for(var v=0;v<h.length;v++)h[v]._dbInfo.db=c;return c});e.storeName?o=f.then(function(c){if(!!c.objectStoreNames.contains(e.storeName)){var d=c.version+1;J(e);var h=K[e.name],v=h.forages;c.close();for(var E=0;E<v.length;E++){var w=v[E];w._dbInfo.db=null,w._dbInfo.version=d}var C=new g(function(x,F){var O=U.open(e.name,d);O.onerror=function(ee){var Te=O.result;Te.close(),F(ee)},O.onupgradeneeded=function(){var ee=O.result;ee.deleteObjectStore(e.storeName)},O.onsuccess=function(){var ee=O.result;ee.close(),x(ee)}});return C.then(function(x){h.db=x;for(var F=0;F<v.length;F++){var O=v[F];O._dbInfo.db=x,Q(O._dbInfo)}}).catch(function(x){throw(X(e,x)||g.resolve()).catch(function(){}),x})}}):o=f.then(function(c){J(e);var d=K[e.name],h=d.forages;c.close();for(var v=0;v<h.length;v++){var E=h[v];E._dbInfo.db=null}var w=new g(function(C,x){var F=U.deleteDatabase(e.name);F.onerror=function(){var O=F.result;O&&O.close(),x(F.error)},F.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},F.onsuccess=function(){var O=F.result;O&&O.close(),C(O)}});return w.then(function(C){d.db=C;for(var x=0;x<h.length;x++){var F=h[x];Q(F._dbInfo)}}).catch(function(C){throw(X(e,C)||g.resolve()).catch(function(){}),C})})}return S(o,r),o}s(Pt,"dropInstance");var Lt={_driver:"asyncStorage",_initStorage:At,_support:z(),iterate:It,getItem:_t,setItem:Rt,removeItem:Ct,clear:xt,length:Nt,key:Ot,keys:Bt,dropInstance:Pt};function Ft(){return typeof openDatabase=="function"}s(Ft,"isWebSQLValid");var de="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ut="~~local_forage_type~",qe=/^~~local_forage_type~([^~]+)~/,Ne="__lfsc__:",Fe=Ne.length,Ue="arbf",Ve="blob",Xe="si08",Ze="ui08",et="uic8",tt="si16",rt="si32",nt="ur16",at="ui32",ot="fl32",it="fl64",st=Fe+Ue.length,ut=Object.prototype.toString;function ft(e){var r=e.length*.75,t=e.length,a,o=0,n,f,c,d;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);var h=new ArrayBuffer(r),v=new Uint8Array(h);for(a=0;a<t;a+=4)n=de.indexOf(e[a]),f=de.indexOf(e[a+1]),c=de.indexOf(e[a+2]),d=de.indexOf(e[a+3]),v[o++]=n<<2|f>>4,v[o++]=(f&15)<<4|c>>2,v[o++]=(c&3)<<6|d&63;return h}s(ft,"stringToBuffer");function $e(e){var r=new Uint8Array(e),t="",a;for(a=0;a<r.length;a+=3)t+=de[r[a]>>2],t+=de[(r[a]&3)<<4|r[a+1]>>4],t+=de[(r[a+1]&15)<<2|r[a+2]>>6],t+=de[r[a+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}s($e,"bufferToString");function Vt(e,r){var t="";if(e&&(t=ut.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&ut.call(e.buffer)==="[object ArrayBuffer]")){var a,o=Ne;e instanceof ArrayBuffer?(a=e,o+=Ue):(a=e.buffer,t==="[object Int8Array]"?o+=Xe:t==="[object Uint8Array]"?o+=Ze:t==="[object Uint8ClampedArray]"?o+=et:t==="[object Int16Array]"?o+=tt:t==="[object Uint16Array]"?o+=nt:t==="[object Int32Array]"?o+=rt:t==="[object Uint32Array]"?o+=at:t==="[object Float32Array]"?o+=ot:t==="[object Float64Array]"?o+=it:r(new Error("Failed to get type for BinaryArray"))),r(o+$e(a))}else if(t==="[object Blob]"){var n=new FileReader;n.onload=function(){var f=Ut+e.type+"~"+$e(this.result);r(Ne+Ve+f)},n.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),r(null,f)}}s(Vt,"serialize");function $t(e){if(e.substring(0,Fe)!==Ne)return JSON.parse(e);var r=e.substring(st),t=e.substring(Fe,st),a;if(t===Ve&&qe.test(r)){var o=r.match(qe);a=o[1],r=r.substring(o[0].length)}var n=ft(r);switch(t){case Ue:return n;case Ve:return P([n],{type:a});case Xe:return new Int8Array(n);case Ze:return new Uint8Array(n);case et:return new Uint8ClampedArray(n);case tt:return new Int16Array(n);case nt:return new Uint16Array(n);case rt:return new Int32Array(n);case at:return new Uint32Array(n);case ot:return new Float32Array(n);case it:return new Float64Array(n);default:throw new Error("Unkown type: "+t)}}s($t,"deserialize");var Me={serialize:Vt,deserialize:$t,stringToBuffer:ft,bufferToString:$e};function ct(e,r,t,a){e.executeSql("CREATE TABLE IF NOT EXISTS "+r.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],t,a)}s(ct,"createDbTable");function Mt(e){var r=this,t={db:null};if(e)for(var a in e)t[a]=typeof e[a]!="string"?e[a].toString():e[a];var o=new g(function(n,f){try{t.db=openDatabase(t.name,String(t.version),t.description,t.size)}catch(c){return f(c)}t.db.transaction(function(c){ct(c,t,function(){r._dbInfo=t,n()},function(d,h){f(h)})},f)});return t.serializer=Me,o}s(Mt,"_initStorage$1");function he(e,r,t,a,o,n){e.executeSql(t,a,o,function(f,c){c.code===c.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[r.storeName],function(d,h){h.rows.length?n(d,c):ct(d,r,function(){d.executeSql(t,a,o,n)},n)},n):n(f,c)},n)}s(he,"tryExecuteSql");function kt(e,r){var t=this;e=V(e);var a=new g(function(o,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(c){he(c,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[e],function(d,h){var v=h.rows.length?h.rows.item(0).value:null;v&&(v=f.serializer.deserialize(v)),o(v)},function(d,h){n(h)})})}).catch(n)});return S(a,r),a}s(kt,"getItem$1");function Yt(e,r){var t=this,a=new g(function(o,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(c){he(c,f,"SELECT * FROM "+f.storeName,[],function(d,h){for(var v=h.rows,E=v.length,w=0;w<E;w++){var C=v.item(w),x=C.value;if(x&&(x=f.serializer.deserialize(x)),x=e(x,C.key,w+1),x!==void 0){o(x);return}}o()},function(d,h){n(h)})})}).catch(n)});return S(a,r),a}s(Yt,"iterate$1");function lt(e,r,t,a){var o=this;e=V(e);var n=new g(function(f,c){o.ready().then(function(){r===void 0&&(r=null);var d=r,h=o._dbInfo;h.serializer.serialize(r,function(v,E){E?c(E):h.db.transaction(function(w){he(w,h,"INSERT OR REPLACE INTO "+h.storeName+" (key, value) VALUES (?, ?)",[e,v],function(){f(d)},function(C,x){c(x)})},function(w){if(w.code===w.QUOTA_ERR){if(a>0){f(lt.apply(o,[e,d,t,a-1]));return}c(w)}})})}).catch(c)});return S(n,t),n}s(lt,"_setItem");function Kt(e,r,t){return lt.apply(this,[e,r,t,1])}s(Kt,"setItem$1");function zt(e,r){var t=this;e=V(e);var a=new g(function(o,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(c){he(c,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[e],function(){o()},function(d,h){n(h)})})}).catch(n)});return S(a,r),a}s(zt,"removeItem$1");function Jt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(f){he(f,n,"DELETE FROM "+n.storeName,[],function(){a()},function(c,d){o(d)})})}).catch(o)});return S(t,e),t}s(Jt,"clear$1");function Wt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(f){he(f,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(c,d){var h=d.rows.item(0).c;a(h)},function(c,d){o(d)})})}).catch(o)});return S(t,e),t}s(Wt,"length$1");function Ht(e,r){var t=this,a=new g(function(o,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(c){he(c,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[e+1],function(d,h){var v=h.rows.length?h.rows.item(0).key:null;o(v)},function(d,h){n(h)})})}).catch(n)});return S(a,r),a}s(Ht,"key$1");function jt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(f){he(f,n,"SELECT key FROM "+n.storeName,[],function(c,d){for(var h=[],v=0;v<d.rows.length;v++)h.push(d.rows.item(v).key);a(h)},function(c,d){o(d)})})}).catch(o)});return S(t,e),t}s(jt,"keys$1");function Gt(e){return new g(function(r,t){e.transaction(function(a){a.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(o,n){for(var f=[],c=0;c<n.rows.length;c++)f.push(n.rows.item(c).name);r({db:e,storeNames:f})},function(o,n){t(n)})},function(a){t(a)})})}s(Gt,"getAllStoreNames");function Qt(e,r){r=re.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 a=this,o;return e.name?o=new g(function(n){var f;e.name===t.name?f=a._dbInfo.db:f=openDatabase(e.name,"","",0),e.storeName?n({db:f,storeNames:[e.storeName]}):n(Gt(f))}).then(function(n){return new g(function(f,c){n.db.transaction(function(d){function h(C){return new g(function(x,F){d.executeSql("DROP TABLE IF EXISTS "+C,[],function(){x()},function(O,ee){F(ee)})})}s(h,"dropTable");for(var v=[],E=0,w=n.storeNames.length;E<w;E++)v.push(h(n.storeNames[E]));g.all(v).then(function(){f()}).catch(function(C){c(C)})},function(d){c(d)})})}):o=g.reject("Invalid arguments"),S(o,r),o}s(Qt,"dropInstance$1");var qt={_driver:"webSQLStorage",_initStorage:Mt,_support:Ft(),iterate:Yt,getItem:kt,setItem:Kt,removeItem:zt,clear:Jt,length:Wt,key:Ht,keys:jt,dropInstance:Qt};function Xt(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}s(Xt,"isLocalStorageValid");function dt(e,r){var t=e.name+"/";return e.storeName!==r.storeName&&(t+=e.storeName+"/"),t}s(dt,"_getKeyPrefix");function Zt(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}s(Zt,"checkIfLocalStorageThrows");function er(){return!Zt()||localStorage.length>0}s(er,"_isLocalStorageUsable");function tr(e){var r=this,t={};if(e)for(var a in e)t[a]=e[a];return t.keyPrefix=dt(e,r._defaultConfig),er()?(r._dbInfo=t,t.serializer=Me,g.resolve()):g.reject()}s(tr,"_initStorage$2");function rr(e){var r=this,t=r.ready().then(function(){for(var a=r._dbInfo.keyPrefix,o=localStorage.length-1;o>=0;o--){var n=localStorage.key(o);n.indexOf(a)===0&&localStorage.removeItem(n)}});return S(t,e),t}s(rr,"clear$2");function nr(e,r){var t=this;e=V(e);var a=t.ready().then(function(){var o=t._dbInfo,n=localStorage.getItem(o.keyPrefix+e);return n&&(n=o.serializer.deserialize(n)),n});return S(a,r),a}s(nr,"getItem$2");function ar(e,r){var t=this,a=t.ready().then(function(){for(var o=t._dbInfo,n=o.keyPrefix,f=n.length,c=localStorage.length,d=1,h=0;h<c;h++){var v=localStorage.key(h);if(v.indexOf(n)===0){var E=localStorage.getItem(v);if(E&&(E=o.serializer.deserialize(E)),E=e(E,v.substring(f),d++),E!==void 0)return E}}});return S(a,r),a}s(ar,"iterate$2");function or(e,r){var t=this,a=t.ready().then(function(){var o=t._dbInfo,n;try{n=localStorage.key(e)}catch{n=null}return n&&(n=n.substring(o.keyPrefix.length)),n});return S(a,r),a}s(or,"key$2");function ir(e){var r=this,t=r.ready().then(function(){for(var a=r._dbInfo,o=localStorage.length,n=[],f=0;f<o;f++){var c=localStorage.key(f);c.indexOf(a.keyPrefix)===0&&n.push(c.substring(a.keyPrefix.length))}return n});return S(t,e),t}s(ir,"keys$2");function sr(e){var r=this,t=r.keys().then(function(a){return a.length});return S(t,e),t}s(sr,"length$2");function ur(e,r){var t=this;e=V(e);var a=t.ready().then(function(){var o=t._dbInfo;localStorage.removeItem(o.keyPrefix+e)});return S(a,r),a}s(ur,"removeItem$2");function fr(e,r,t){var a=this;e=V(e);var o=a.ready().then(function(){r===void 0&&(r=null);var n=r;return new g(function(f,c){var d=a._dbInfo;d.serializer.serialize(r,function(h,v){if(v)c(v);else try{localStorage.setItem(d.keyPrefix+e,h),f(n)}catch(E){(E.name==="QuotaExceededError"||E.name==="NS_ERROR_DOM_QUOTA_REACHED")&&c(E),c(E)}})})});return S(o,t),o}s(fr,"setItem$2");function cr(e,r){if(r=re.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 a=this,o;return e.name?o=new g(function(n){e.storeName?n(dt(e,a._defaultConfig)):n(e.name+"/")}).then(function(n){for(var f=localStorage.length-1;f>=0;f--){var c=localStorage.key(f);c.indexOf(n)===0&&localStorage.removeItem(c)}}):o=g.reject("Invalid arguments"),S(o,r),o}s(cr,"dropInstance$2");var lr={_driver:"localStorageWrapper",_initStorage:tr,_support:Xt(),iterate:ar,getItem:nr,setItem:fr,removeItem:ur,clear:rr,length:sr,key:or,keys:ir,dropInstance:cr},dr=s(function(r,t){return r===t||typeof r=="number"&&typeof t=="number"&&isNaN(r)&&isNaN(t)},"sameValue"),hr=s(function(r,t){for(var a=r.length,o=0;o<a;){if(dr(r[o],t))return!0;o++}return!1},"includes"),ht=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},we={},yt={},Ee={INDEXEDDB:Lt,WEBSQL:qt,LOCALSTORAGE:lr},yr=[Ee.INDEXEDDB._driver,Ee.WEBSQL._driver,Ee.LOCALSTORAGE._driver],Oe=["dropInstance"],ke=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Oe),vr={description:"",driver:yr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function pr(e,r){e[r]=function(){var t=arguments;return e.ready().then(function(){return e[r].apply(e,t)})}}s(pr,"callWhenReady");function Ye(){for(var e=1;e<arguments.length;e++){var r=arguments[e];if(r)for(var t in r)r.hasOwnProperty(t)&&(ht(r[t])?arguments[0][t]=r[t].slice():arguments[0][t]=r[t])}return arguments[0]}s(Ye,"extend");var mr=function(){function e(r){B(this,e);for(var t in Ee)if(Ee.hasOwnProperty(t)){var a=Ee[t],o=a._driver;this[t]=o,we[o]||this.defineDriver(a)}this._defaultConfig=Ye({},vr),this._config=Ye({},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 s(e,"LocalForage"),e.prototype.config=s(function(t){if((typeof t>"u"?"undefined":D(t))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var a in t){if(a==="storeName"&&(t[a]=t[a].replace(/\W/g,"_")),a==="version"&&typeof t[a]!="number")return new Error("Database version must be a number.");this._config[a]=t[a]}return"driver"in t&&t.driver?this.setDriver(this._config.driver):!0}else return typeof t=="string"?this._config[t]:this._config},"config"),e.prototype.defineDriver=s(function(t,a,o){var n=new g(function(f,c){try{var d=t._driver,h=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver){c(h);return}for(var v=ke.concat("_initStorage"),E=0,w=v.length;E<w;E++){var C=v[E],x=!hr(Oe,C);if((x||t[C])&&typeof t[C]!="function"){c(h);return}}var F=s(function(){for(var Te=s(function(Er){return function(){var Sr=new Error("Method "+Er+" is not implemented by the current driver"),vt=g.reject(Sr);return S(vt,arguments[arguments.length-1]),vt}},"methodNotImplementedFactory"),Ke=0,br=Oe.length;Ke<br;Ke++){var ze=Oe[Ke];t[ze]||(t[ze]=Te(ze))}},"configureMissingMethods");F();var O=s(function(Te){we[d]&&console.info("Redefining LocalForage driver: "+d),we[d]=t,yt[d]=Te,f()},"setDriverSupport");"_support"in t?t._support&&typeof t._support=="function"?t._support().then(O,c):O(!!t._support):O(!0)}catch(ee){c(ee)}});return L(n,a,o),n},"defineDriver"),e.prototype.driver=s(function(){return this._driver||null},"driver"),e.prototype.getDriver=s(function(t,a,o){var n=we[t]?g.resolve(we[t]):g.reject(new Error("Driver not found."));return L(n,a,o),n},"getDriver"),e.prototype.getSerializer=s(function(t){var a=g.resolve(Me);return L(a,t),a},"getSerializer"),e.prototype.ready=s(function(t){var a=this,o=a._driverSet.then(function(){return a._ready===null&&(a._ready=a._initDriver()),a._ready});return L(o,t,t),o},"ready"),e.prototype.setDriver=s(function(t,a,o){var n=this;ht(t)||(t=[t]);var f=this._getSupportedDrivers(t);function c(){n._config.driver=n.driver()}s(c,"setDriverToConfig");function d(E){return n._extend(E),c(),n._ready=n._initStorage(n._config),n._ready}s(d,"extendSelfWithDriver");function h(E){return function(){var w=0;function C(){for(;w<E.length;){var x=E[w];return w++,n._dbInfo=null,n._ready=null,n.getDriver(x).then(d).catch(C)}c();var F=new Error("No available storage method found.");return n._driverSet=g.reject(F),n._driverSet}return s(C,"driverPromiseLoop"),C()}}s(h,"initDriver");var v=this._driverSet!==null?this._driverSet.catch(function(){return g.resolve()}):g.resolve();return this._driverSet=v.then(function(){var E=f[0];return n._dbInfo=null,n._ready=null,n.getDriver(E).then(function(w){n._driver=w._driver,c(),n._wrapLibraryMethodsWithReady(),n._initDriver=h(f)})}).catch(function(){c();var E=new Error("No available storage method found.");return n._driverSet=g.reject(E),n._driverSet}),L(this._driverSet,a,o),this._driverSet},"setDriver"),e.prototype.supports=s(function(t){return!!yt[t]},"supports"),e.prototype._extend=s(function(t){Ye(this,t)},"_extend"),e.prototype._getSupportedDrivers=s(function(t){for(var a=[],o=0,n=t.length;o<n;o++){var f=t[o];this.supports(f)&&a.push(f)}return a},"_getSupportedDrivers"),e.prototype._wrapLibraryMethodsWithReady=s(function(){for(var t=0,a=ke.length;t<a;t++)pr(this,ke[t])},"_wrapLibraryMethodsWithReady"),e.prototype.createInstance=s(function(t){return new e(t)},"createInstance"),e}(),gr=new mr;y.exports=gr},{"3":3}]},{},[4])(4)})});var pt=s(p=>p==null,"isNil");var mt=s(()=>{let p=new Date().getTime(),i=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(u){let l=Math.random()*16;return p>0?(l=(p+l)%16|0,p=Math.floor(p/16)):(l=(i+l)%16|0,i=Math.floor(i/16)),(u==="x"?l:l&3|8).toString(16)})},"generateUUID");var gt=s(p=>(typeof p=="string"||p instanceof String)&&p.trim()==="","isEmptyString");var ae=class{constructor(){this.value=(()=>{try{return crypto.randomUUID()}catch{return mt()}})()}};s(ae,"SchemaId");var xr=s(p=>{switch(p){case Number:return 0;case Boolean:return!1;case String:return"";case Array:case Float32Array:case Float64Array:case Int8Array:case Int16Array:case Int32Array:case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:return new p;case ArrayBuffer:return new p(0);default:return null}},"getDefaultValue"),He=s((p,i)=>{try{return i instanceof p||typeof i===p.name.toLowerCase()}catch{return!1}},"isSameValueType"),ne=class{constructor(i,u=!1,l=null){this.type=i;this.required=u;this.defaultValue=l;if(l!==null&&!He(i,l))throw new Error(`Default value "${l.toString()}" does not match type "${i.name}"`);this.defaultValue=l??xr(this.type)}toJSON(){return{type:this.type instanceof fe?this.type.toJSON():this.type.name,required:this.required,defaultValue:this.defaultValue}}toString(){return JSON.stringify(this.toJSON(),null,4)}};s(ne,"SchemaValue");var Ae,M,_e,Ie,ye=class{constructor(i,u=null,l=!0){G(this,Ae,["id","createdDate","lastUpdatedDate"]);G(this,M,{id:new ne(ae,!1),createdDate:new ne(Date,!1),lastUpdatedDate:new ne(Date,!1)});G(this,_e,void 0);G(this,Ie,!0);if(W(this,_e,i),W(this,Ie,l),l||W(this,M,{}),u){for(let y in u)if(u.hasOwnProperty(y))if(u[y]instanceof ne)b(this,Ae).includes(y)||(b(this,M)[y]=u[y]);else throw new Error(`Field "${y}" is not a SchemaValue`)}}get name(){return b(this,_e)}get includeDefaultKeys(){return b(this,Ie)}get defaultKeys(){return b(this,Ae)}defineField(i,u,{defaultValue:l,required:y}={defaultValue:null,required:!1}){b(this,M)[`${i}`]=new ne(u,y,l)}removeField(i){if(i){let[u,...l]=`${i}`.split("."),y=b(this,M)[u];y&&(l.length?y.type instanceof ye&&y.type.removeField(l.join(".")):delete b(this,M)[u])}}hasField(i){if(i){let[u,...l]=`${i}`.split("."),y=b(this,M)[u];if(y)if(l.length){if(y.type instanceof ye)return y.type.hasField(l.join("."))}else return b(this,M).hasOwnProperty(u)}return!1}getField(i){if(i){let[u,...l]=`${i}`.split("."),y=b(this,M)[u];return y&&l.length&&y.type instanceof ye?y.type.getField(l.join(".")):y??null}return null}isValidFieldValue(i,u=null){let l=this.getField(`${i}`);return l?u instanceof Array&&u.some(y=>!Nr(y))?!1:l.type instanceof ye?`${u}`=="[object Object]"&&l.type.getInvalidSchemaDataFields(u).length===0:l.required?!pt(u)&&(l.type!==String||!gt(u))&&He(l.type,u):u===null||u===l.defaultValue||He(l.type,u):!1}getInvalidSchemaDataFields(i){let u=new Set,l=Object.keys(b(this,M)).filter(y=>b(this,M)[y].required);for(let y of[...Object.keys(i),...l])if(!this.defaultKeys.includes(y)){let _=this.getField(y);if(_?.type instanceof ye){let D=i[y];`${D}`=="[object Object]"?_.type.getInvalidSchemaDataFields(D).map(B=>{u.add(`${y}.${B}`)}):u.add(y);continue}this.isValidFieldValue(y,i[y])||u.add(y)}return Array.from(u)}toJSON(){let i={};for(let u in b(this,M))if(b(this,M).hasOwnProperty(u)){let l=b(this,M)[u];i[u]=l.toJSON()}return i}toString(){return JSON.stringify(this.toJSON(),null,4)}toValue(){let i=new Date,u=this.includeDefaultKeys?{id:new ae().value,createdDate:i,lastUpdatedDate:i}:{};for(let l in b(this,M))if(b(this,M).hasOwnProperty(l)&&!this.defaultKeys.includes(l)){let y=b(this,M)[l];switch(!0){case y.type instanceof ye:u[l]=y.type.toValue();break;case y.type===ae:u[l]=new ae().value;break;case y.type===Date:u[l]=y.defaultValue instanceof Date?y.defaultValue:i;break;default:u[l]=y.defaultValue}}return u}},fe=ye;s(fe,"Schema"),Ae=new WeakMap,M=new WeakMap,_e=new WeakMap,Ie=new WeakMap;function Nr(p){return p===null||[fe,ae,Date,Number,String,Boolean,Array,ArrayBuffer,Blob,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array].some(i=>p instanceof i||typeof p===i.name.toLowerCase())}s(Nr,"isSupportedTypeValue");var te=Cr(Et());var ce=s((p,i)=>typeof i=="function"?i(null,p):Promise.resolve(p),"callBackOrPromise"),Be="Memory",St=s(()=>{let p=new Map;return{_driver:Be,_initStorage(){return p},async clear(i){ce(p.clear(),i)},async getItem(i,u){return ce(p.get(i)??null,u)||null},async iterate(i,u){let l=0,y;for(let[_,D]of p.entries()){if(y=i(D,_,l),y!==void 0)return ce(y,u);l+=1}return ce(null,u)},async key(i,u){return ce(Array.from(p.keys())[i],u)||""},async keys(i){return ce(Array.from(p.keys()),i)||[]},async length(i){return ce(p.size,i)||0},async removeItem(i,u){return ce(p.delete(i),u)},async setItem(i,u,l){return ce(p.set(i,u),l)}}},"MemoryStore");te.default.defineDriver(St());var wt={version:1,type:[te.INDEXEDDB,te.WEBSQL,te.LOCALSTORAGE,Be],description:"",appName:"App"},k,le,Re,q,ge,oe,Ce,ve,Y,j,A=class{constructor(i,u,l=wt){G(this,Y);G(this,k,void 0);G(this,le,void 0);G(this,Re,void 0);G(this,q,void 0);G(this,ge,[]);G(this,oe,s(()=>!0,"#beforeChangeHandler"));G(this,Ce,!1);G(this,ve,0);if(W(this,Re,i),W(this,le,{...wt,...l}),!(u instanceof fe))throw new Error('Missing or unknown "Schema"');let y=b(this,le).appName||"App";W(this,q,u),W(this,k,te.default.createInstance({driver:b(this,le).type,version:b(this,le).version,description:b(this,le).description,name:y,storeName:i})),b(this,k).ready(()=>{console.info(`[Info] ClientStore "${i}" successfully created`),W(this,Ce,!0),H(this,Y,j).call(this,A.EventType.READY,!0)})}get ready(){return b(this,Ce)}get type(){return b(this,k).driver()}get name(){return`${b(this,le).appName}-${b(this,Re)}`}get size(){return b(this,ve)}subscribe(i){return typeof i=="function"&&b(this,ge).push(i),()=>{W(this,ge,b(this,ge).filter(u=>u!==i))}}beforeChange(i){return typeof i=="function"&&W(this,oe,i),()=>{W(this,oe,()=>!0)}}async loadItems(i=[]){if(i.length)try{if(await b(this,oe).call(this,A.EventType.LOADED,i)===!0){let l=new Map;for(let _ of i){let D=await this.getItem(_?.id)??b(this,q).toValue();for(let I in D)if(D.hasOwnProperty(I)){let U=_[I];U&&(D[I]=U)}let B=b(this,q).getInvalidSchemaDataFields(D);if(!B.length)l.set(D.id,D);else throw new Error(`Missing or invalid field types: [${B.join(", ")}] in "${JSON.stringify(_,null,2)}".`)}let y=Array.from(l.values());return await Promise.all(y.map(_=>b(this,k).setItem(`${_.id}`,_))),W(this,ve,await b(this,k).length()),H(this,Y,j).call(this,A.EventType.LOADED,y),y}else H(this,Y,j).call(this,A.EventType.ABORTED,{action:A.EventType.LOADED,data:i})}catch(u){H(this,Y,j).call(this,A.EventType.ERROR,{action:A.EventType.LOADED,error:u,data:i})}return[]}async createItem(i){let u=b(this,q).getInvalidSchemaDataFields(i);if(!u.length){let l=b(this,q).toValue();for(let y in i)i.hasOwnProperty(y)&&!b(this,q).defaultKeys.includes(y)&&(l[y]=i[y]);try{if(await b(this,oe).call(this,A.EventType.CREATED,l)===!0)return await b(this,k).setItem(`${l.id}`,l),W(this,ve,await b(this,k).length()),H(this,Y,j).call(this,A.EventType.CREATED,l),l;H(this,Y,j).call(this,A.EventType.ABORTED,{action:A.EventType.CREATED,data:i})}catch(y){console.error(`Failed to create item "${JSON.stringify(i,null,2)}"`,y),H(this,Y,j).call(this,A.EventType.ERROR,{action:A.EventType.CREATED,error:y,data:i})}return null}throw new Error(`Failed to create item. Field(s) "${u.join(", ")}" do not match the schema: ${b(this,q)}`)}async updateItem(i,u){for(let _ in u)if(u.hasOwnProperty(_)&&!b(this,q).defaultKeys.includes(_)&&!b(this,q).isValidFieldValue(_,u[_]))throw new Error(`Failed to update item "${i}". Key "${_}" is unknown or has invalid value type: ${b(this,q).getField(_)}`);let l=await this.getItem(i),y={...l,...u,createdDate:l.createdDate,lastUpdatedDate:new Date,id:l.id};try{if(await b(this,oe).call(this,A.EventType.UPDATED,y)===!0)return await b(this,k).setItem(`${l.id}`,y),H(this,Y,j).call(this,A.EventType.UPDATED,y),y;H(this,Y,j).call(this,A.EventType.ABORTED,{action:A.EventType.UPDATED,data:u})}catch(_){console.error(`Failed to update item with id "${i}"`,_),H(this,Y,j).call(this,A.EventType.ERROR,{action:A.EventType.UPDATED,error:_,data:u})}return null}async getItems(){return this.findItems(()=>!0)}getItem(i){return b(this,k).getItem(`${i}`)}async removeItem(i){try{if(await b(this,oe).call(this,A.EventType.DELETED,i)===!0)return await b(this,k).removeItem(`${i}`),W(this,ve,await b(this,k).length()),H(this,Y,j).call(this,A.EventType.DELETED,i),!0;H(this,Y,j).call(this,A.EventType.ABORTED,{action:A.EventType.DELETED,data:i})}catch(u){console.error(`Failed to delete item with id "${i}"`,u),H(this,Y,j).call(this,A.EventType.ERROR,{action:A.EventType.DELETED,error:u,data:i})}return null}async clear(){let i=await b(this,k).keys();try{if(await b(this,oe).call(this,A.EventType.CLEARED,i))return await b(this,k).clear(),W(this,ve,await b(this,k).length()),H(this,Y,j).call(this,A.EventType.CLEARED,i),i;H(this,Y,j).call(this,A.EventType.ABORTED,{action:A.EventType.CLEARED,data:i})}catch(u){console.error("Failed to clear the store",u),H(this,Y,j).call(this,A.EventType.ERROR,{action:A.EventType.CLEARED,error:u,data:i})}return null}async findItem(i=()=>!1){return b(this,k).iterate((u,l)=>{if(i(u,l))return u})||null}async findItems(i=()=>!1){let u=[];return await b(this,k).iterate((l,y)=>{i(l,y)&&l&&u.push(l)}),u}},pe=A;s(pe,"ClientStore"),k=new WeakMap,le=new WeakMap,Re=new WeakMap,q=new WeakMap,ge=new WeakMap,oe=new WeakMap,Ce=new WeakMap,ve=new WeakMap,Y=new WeakSet,j=s(function(i,u){b(this,ge).forEach(l=>l(i,u))},"#broadcast");(u=>{let p;(P=>(P.READY="ready",P.CREATED="created",P.LOADED="loaded",P.ERROR="error",P.ABORTED="aborted",P.DELETED="deleted",P.UPDATED="updated",P.CLEARED="cleared"))(p=u.EventType||(u.EventType={})),u.Type={LOCALSTORAGE:te.LOCALSTORAGE,WEBSQL:te.WEBSQL,INDEXEDDB:te.INDEXEDDB,MEMORY_STORAGE:Be}})(pe||(pe={}));window&&(window.Schema=fe,window.SchemaValue=ne,window.SchemaId=ae,window.ClientStore=pe);})(); | ||
/*! | ||
@@ -3,0 +3,0 @@ localForage -- Offline Storage, Improved |
@@ -115,3 +115,3 @@ "use strict"; | ||
for (let item of items) { | ||
let newItem = (item.id ? (await this.getItem(item.id)) : __classPrivateFieldGet(this, _ClientStore_schema, "f").toValue()); | ||
let newItem = (await this.getItem(item?.id) ?? __classPrivateFieldGet(this, _ClientStore_schema, "f").toValue()); | ||
for (const itemKey in newItem) { | ||
@@ -118,0 +118,0 @@ if (newItem.hasOwnProperty(itemKey)) { |
{ | ||
"name": "client-web-storage", | ||
"description": "Web browser (client) storage interface for IndexedDB, WebSQL, LocalStorage, and in memory data with Schema validation.", | ||
"version": "1.4.4", | ||
"version": "1.4.5", | ||
"main": "dist/", | ||
@@ -6,0 +6,0 @@ "repository": { |
84572
-0.02%