@shihengtech/utils 0.0.1 → 0.0.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/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # @shihengtech/utils
2
2
 
3
+ [![pipeline status](https://git.sh-internal.com/Front-End-Projects/Base/sh-tools/badges/main/pipeline.svg)](https://git.sh-internal.com/Front-End-Projects/Base/sh-tools/-/commits/main)
4
+ [![coverage report](https://git.sh-internal.com/Front-End-Projects/Base/sh-tools/badges/main/coverage.svg)](https://git.sh-internal.com/Front-End-Projects/Base/sh-tools/-/commits/main)
5
+
3
6
  一个轻量级的 JavaScript/TypeScript 工具函数库。
4
7
 
5
8
  ## ✨ 特性
@@ -25,17 +28,42 @@ yarn add @shihengtech/utils
25
28
 
26
29
  ## 🔨 使用
27
30
 
31
+ ### fnRunner - 带重试的异步执行器
32
+
33
+ ```typescript
34
+ import { fnRunner } from '@shihengtech/utils'
35
+
36
+ // 执行异步函数,失败后最多重试 3 次
37
+ const result = await fnRunner(
38
+ async () => fetch('/api/data').then(r => r.json()),
39
+ 3
40
+ )
41
+ ```
42
+
43
+ ### createQueryWithCache - 带缓存的查询函数
44
+
45
+ ```typescript
46
+ import { createQueryWithCache } from '@shihengtech/utils'
47
+
48
+ const fetchUser = createQueryWithCache(
49
+ 'user',
50
+ async (id: string) => fetch(`/api/users/${id}`).then(r => r.json()),
51
+ { maxAge: 60000 } // 缓存 1 分钟
52
+ )
53
+
54
+ const user = await fetchUser('123')
55
+ ```
56
+
57
+ ### ReplaySubject - 响应式数据流
58
+
28
59
  ```typescript
29
- import { isEmpty, isString } from '@shihengtech/utils'
60
+ import { ReplaySubject } from '@shihengtech/utils'
30
61
 
31
- // 类型判断
32
- isString('hello') // true
33
- isString(123) // false
62
+ const subject = new ReplaySubject<number>(1)
34
63
 
35
- // 空值检查
36
- isEmpty('') // true
37
- isEmpty([]) // true
38
- isEmpty({}) // true
64
+ subject.subscribe(value => console.log(value))
65
+ subject.next(1) // 输出: 1
66
+ subject.next(2) // 输出: 2
39
67
  ```
40
68
 
41
69
  ## 📖 文档
@@ -70,22 +98,30 @@ pnpm docs:dev
70
98
  pnpm docs:build
71
99
  ```
72
100
 
101
+ ## 📊 测试覆盖率
102
+
103
+ | 模块 | 语句 | 分支 | 函数 | 行 |
104
+ | -------------------- | ------ | ------ | ------ | ------ |
105
+ | **总计** | 92.83% | 87.09% | 88.23% | 92.83% |
106
+ | ReplaySubject | 100% | 100% | 100% | 100% |
107
+ | createQueryWithCache | 96.38% | 88.88% | 100% | 96.38% |
108
+ | fnRunner | 81.25% | 83.33% | 100% | 81.25% |
109
+
110
+ 运行 `pnpm test:coverage` 查看详细覆盖率报告。
111
+
73
112
  ## 📁 项目结构
74
113
 
75
114
  ```
76
115
  @shihengtech/utils/
77
- ├── src/ # 源代码
78
- │ ├── index.ts # 入口文件
79
- │ ├── is.ts # 类型判断工具
80
- │ └── is.test.ts # 测试文件
81
- ├── docs/ # VitePress 文档
82
- ├── .vitepress/ # VitePress 配置
83
- ├── guide/ # 使用指南
84
- │ └── api/ # API 文档
85
- ├── dist/ # 构建输出(git ignored)
86
- ├── tsconfig.json # TypeScript 配置
87
- ├── tsup.config.ts # 构建配置
88
- ├── vitest.config.ts # 测试配置
116
+ ├── src/
117
+ │ ├── index.ts # 入口文件
118
+ │ ├── class/ #
119
+ └── ReplaySubject/ # 响应式数据流
120
+ │ └── utils/ # 工具函数
121
+ ├── fnRunner/ # 重试执行器
122
+ └── createQueryWithCache/ # 缓存查询
123
+ ├── docs/ # VitePress 文档
124
+ ├── dist/ # 构建输出
89
125
  └── package.json
90
126
  ```
91
127
 
@@ -0,0 +1,11 @@
1
+ var ShihengUtils=(function(exports){'use strict';var pt=Object.create;var Ae=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var ht=Object.getOwnPropertyNames,nr=Object.getOwnPropertySymbols,vt=Object.getPrototypeOf,ar=Object.prototype.hasOwnProperty,yt=Object.prototype.propertyIsEnumerable;var or=(i,f,m)=>f in i?Ae(i,f,{enumerable:true,configurable:true,writable:true,value:m}):i[f]=m,pe=(i,f)=>{for(var m in f||(f={}))ar.call(f,m)&&or(i,m,f[m]);if(nr)for(var m of nr(f))yt.call(f,m)&&or(i,m,f[m]);return i};var ue=(i=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(i,{get:(f,m)=>(typeof require!="undefined"?require:f)[m]}):i)(function(i){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var xt=(i,f)=>()=>(f||i((f={exports:{}}).exports,f),f.exports);var gt=(i,f,m,x)=>{if(f&&typeof f=="object"||typeof f=="function")for(let y of ht(f))!ar.call(i,y)&&y!==m&&Ae(i,y,{get:()=>f[y],enumerable:!(x=mt(f,y))||x.enumerable});return i};var _t=(i,f,m)=>(m=i!=null?pt(vt(i)):{},gt(!i||!i.__esModule?Ae(m,"default",{value:i,enumerable:true}):m,i));var Z=(i,f,m)=>new Promise((x,y)=>{var A=g=>{try{N(m.next(g));}catch(D){y(D);}},S=g=>{try{N(m.throw(g));}catch(D){y(D);}},N=g=>g.done?x(g.value):Promise.resolve(g.value).then(A,S);N((m=m.apply(i,f)).next());});var ur=xt((fr,Ne)=>{(function(i){if(typeof fr=="object"&&typeof Ne!="undefined")Ne.exports=i();else if(typeof define=="function"&&define.amd)define([],i);else {var f;typeof window!="undefined"?f=window:typeof global!="undefined"?f=global:typeof self!="undefined"?f=self:f=this,f.localforage=i();}})(function(){return (function x(y,A,S){function N(L,z){if(!A[L]){if(!y[L]){var h=typeof ue=="function"&&ue;if(!z&&h)return h(L,true);if(g)return g(L,true);var _=new Error("Cannot find module '"+L+"'");throw _.code="MODULE_NOT_FOUND",_}var B=A[L]={exports:{}};y[L][0].call(B.exports,function(O){var W=y[L][1][O];return N(W||O)},B,B.exports,x,y,A,S);}return A[L].exports}for(var g=typeof ue=="function"&&ue,D=0;D<S.length;D++)N(S[D]);return N})({1:[function(x,y,A){(function(S){var N=S.MutationObserver||S.WebKitMutationObserver,g;if(N){var D=0,L=new N(O),z=S.document.createTextNode("");L.observe(z,{characterData:true}),g=function(){z.data=D=++D%2;};}else if(!S.setImmediate&&typeof S.MessageChannel!="undefined"){var h=new S.MessageChannel;h.port1.onmessage=O,g=function(){h.port2.postMessage(0);};}else "document"in S&&"onreadystatechange"in S.document.createElement("script")?g=function(){var C=S.document.createElement("script");C.onreadystatechange=function(){O(),C.onreadystatechange=null,C.parentNode.removeChild(C),C=null;},S.document.documentElement.appendChild(C);}:g=function(){setTimeout(O,0);};var _,B=[];function O(){_=true;for(var C,K,M=B.length;M;){for(K=B,B=[],C=-1;++C<M;)K[C]();M=B.length;}_=false;}y.exports=W;function W(C){B.push(C)===1&&!_&&g();}}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{});},{}],2:[function(x,y,A){var S=x(1);function N(){}var g={},D=["REJECTED"],L=["FULFILLED"],z=["PENDING"];y.exports=h;function h(c){if(typeof c!="function")throw new TypeError("resolver must be a function");this.state=z,this.queue=[],this.outcome=void 0,c!==N&&W(this,c);}h.prototype.catch=function(c){return this.then(null,c)},h.prototype.then=function(c,b){if(typeof c!="function"&&this.state===L||typeof b!="function"&&this.state===D)return this;var w=new this.constructor(N);if(this.state!==z){var I=this.state===L?c:b;B(w,I,this.outcome);}else this.queue.push(new _(w,c,b));return w};function _(c,b,w){this.promise=c,typeof b=="function"&&(this.onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected);}_.prototype.callFulfilled=function(c){g.resolve(this.promise,c);},_.prototype.otherCallFulfilled=function(c){B(this.promise,this.onFulfilled,c);},_.prototype.callRejected=function(c){g.reject(this.promise,c);},_.prototype.otherCallRejected=function(c){B(this.promise,this.onRejected,c);};function B(c,b,w){S(function(){var I;try{I=b(w);}catch(U){return g.reject(c,U)}I===c?g.reject(c,new TypeError("Cannot resolve promise with itself")):g.resolve(c,I);});}g.resolve=function(c,b){var w=C(O,b);if(w.status==="error")return g.reject(c,w.value);var I=w.value;if(I)W(c,I);else {c.state=L,c.outcome=b;for(var U=-1,Y=c.queue.length;++U<Y;)c.queue[U].callFulfilled(b);}return c},g.reject=function(c,b){c.state=D,c.outcome=b;for(var w=-1,I=c.queue.length;++w<I;)c.queue[w].callRejected(b);return c};function O(c){var b=c&&c.then;if(c&&(typeof c=="object"||typeof c=="function")&&typeof b=="function")return function(){b.apply(c,arguments);}}function W(c,b){var w=false;function I($){w||(w=true,g.reject(c,$));}function U($){w||(w=true,g.resolve(c,$));}function Y(){b(U,I);}var j=C(Y);j.status==="error"&&I(j.value);}function C(c,b){var w={};try{w.value=c(b),w.status="success";}catch(I){w.status="error",w.value=I;}return w}h.resolve=K;function K(c){return c instanceof this?c:g.resolve(new this(N),c)}h.reject=M;function M(c){var b=new this(N);return g.reject(b,c)}h.all=re;function re(c){var b=this;if(Object.prototype.toString.call(c)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=c.length,I=false;if(!w)return this.resolve([]);for(var U=new Array(w),Y=0,j=-1,$=new this(N);++j<w;)V(c[j],j);return $;function V(oe,le){b.resolve(oe).then(xe,function(te){I||(I=true,g.reject($,te));});function xe(te){U[le]=te,++Y===w&&!I&&(I=true,g.resolve($,U));}}}h.race=P;function P(c){var b=this;if(Object.prototype.toString.call(c)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=c.length,I=false;if(!w)return this.resolve([]);for(var U=-1,Y=new this(N);++U<w;)j(c[U]);return Y;function j($){b.resolve($).then(function(V){I||(I=true,g.resolve(Y,V));},function(V){I||(I=true,g.reject(Y,V));});}}},{1:1}],3:[function(x,y,A){(function(S){typeof S.Promise!="function"&&(S.Promise=x(2));}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{});},{2:2}],4:[function(x,y,A){var S=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 N(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function g(){try{if(typeof indexedDB!="undefined")return indexedDB;if(typeof webkitIndexedDB!="undefined")return webkitIndexedDB;if(typeof mozIndexedDB!="undefined")return mozIndexedDB;if(typeof OIndexedDB!="undefined")return OIndexedDB;if(typeof msIndexedDB!="undefined")return msIndexedDB}catch(e){return}}var D=g();function L(){try{if(!D||!D.open)return !1;var e=typeof openDatabase!="undefined"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return (!e||t)&&typeof indexedDB!="undefined"&&typeof IDBKeyRange!="undefined"}catch(r){return false}}function z(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(n){if(n.name!=="TypeError")throw n;for(var r=typeof BlobBuilder!="undefined"?BlobBuilder:typeof MSBlobBuilder!="undefined"?MSBlobBuilder:typeof MozBlobBuilder!="undefined"?MozBlobBuilder:WebKitBlobBuilder,o=new r,a=0;a<e.length;a+=1)o.append(e[a]);return o.getBlob(t.type)}}typeof Promise=="undefined"&&x(3);var h=Promise;function _(e,t){t&&e.then(function(r){t(null,r);},function(r){t(r);});}function B(e,t,r){typeof t=="function"&&e.then(t),typeof r=="function"&&e.catch(r);}function O(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function W(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var C="local-forage-detect-blob-support",K=void 0,M={},re=Object.prototype.toString,P="readonly",c="readwrite";function b(e){for(var t=e.length,r=new ArrayBuffer(t),o=new Uint8Array(r),a=0;a<t;a++)o[a]=e.charCodeAt(a);return r}function w(e){return new h(function(t){var r=e.transaction(C,c),o=z([""]);r.objectStore(C).put(o,"key"),r.onabort=function(a){a.preventDefault(),a.stopPropagation(),t(false);},r.oncomplete=function(){var a=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!a||parseInt(a[1],10)>=43);};}).catch(function(){return false})}function I(e){return typeof K=="boolean"?h.resolve(K):w(e).then(function(t){return K=t,K})}function U(e){var t=M[e.name],r={};r.promise=new h(function(o,a){r.resolve=o,r.reject=a;}),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then(function(){return r.promise}):t.dbReady=r.promise;}function Y(e){var t=M[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}function j(e,t){var r=M[e.name],o=r.deferredOperations.pop();if(o)return o.reject(t),o.promise}function $(e,t){return new h(function(r,o){if(M[e.name]=M[e.name]||Ue(),e.db)if(t)U(e),e.db.close();else return r(e.db);var a=[e.name];t&&a.push(e.version);var n=D.open.apply(D,a);t&&(n.onupgradeneeded=function(u){var s=n.result;try{s.createObjectStore(e.storeName),u.oldVersion<=1&&s.createObjectStore(C);}catch(l){if(l.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+u.oldVersion+" to version "+u.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw l}}),n.onerror=function(u){u.preventDefault(),o(n.error);},n.onsuccess=function(){var u=n.result;u.onversionchange=function(s){s.target.close();},r(u),Y(e);};})}function V(e){return $(e,false)}function oe(e){return $(e,true)}function le(e,t){if(!e.db)return true;var r=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,a=e.version>e.db.version;if(o&&(e.version!==t&&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||r){if(r){var n=e.db.version+1;n>e.version&&(e.version=n);}return true}return false}function xe(e){return new h(function(t,r){var o=new FileReader;o.onerror=r,o.onloadend=function(a){var n=btoa(a.target.result||"");t({__local_forage_encoded_blob:true,data:n,type:e.type});},o.readAsBinaryString(e);})}function te(e){var t=b(atob(e.data));return z([t],{type:e.type})}function We(e){return e&&e.__local_forage_encoded_blob}function mr(e){var t=this,r=t._initReady().then(function(){var o=M[t._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return B(r,e,e),r}function hr(e){U(e);for(var t=M[e.name],r=t.forages,o=0;o<r.length;o++){var a=r[o];a._dbInfo.db&&(a._dbInfo.db.close(),a._dbInfo.db=null);}return e.db=null,V(e).then(function(n){return e.db=n,le(e)?oe(e):n}).then(function(n){e.db=t.db=n;for(var u=0;u<r.length;u++)r[u]._dbInfo.db=n;}).catch(function(n){throw j(e,n),n})}function Q(e,t,r,o){o===void 0&&(o=1);try{var a=e.db.transaction(e.storeName,t);r(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),oe(e)}).then(function(){return hr(e).then(function(){Q(e,t,r,o-1);})}).catch(r);r(n);}}function Ue(){return {forages:[],db:null,dbReady:null,deferredOperations:[]}}function vr(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=e[o];var a=M[r.name];a||(a=Ue(),M[r.name]=a),a.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=mr);var n=[];function u(){return h.resolve()}for(var s=0;s<a.forages.length;s++){var l=a.forages[s];l!==t&&n.push(l._initReady().catch(u));}var d=a.forages.slice(0);return h.all(n).then(function(){return r.db=a.db,V(r)}).then(function(p){return r.db=p,le(r,t._defaultConfig.version)?oe(r):p}).then(function(p){r.db=a.db=p,t._dbInfo=r;for(var v=0;v<d.length;v++){var E=d[v];E!==t&&(E._dbInfo.db=r.db,E._dbInfo.version=r.version);}})}function yr(e,t){var r=this;e=O(e);var o=new h(function(a,n){r.ready().then(function(){Q(r._dbInfo,P,function(u,s){if(u)return n(u);try{var l=s.objectStore(r._dbInfo.storeName),d=l.get(e);d.onsuccess=function(){var p=d.result;p===void 0&&(p=null),We(p)&&(p=te(p)),a(p);},d.onerror=function(){n(d.error);};}catch(p){n(p);}});}).catch(n);});return _(o,t),o}function xr(e,t){var r=this,o=new h(function(a,n){r.ready().then(function(){Q(r._dbInfo,P,function(u,s){if(u)return n(u);try{var l=s.objectStore(r._dbInfo.storeName),d=l.openCursor(),p=1;d.onsuccess=function(){var v=d.result;if(v){var E=v.value;We(E)&&(E=te(E));var T=e(E,v.key,p++);T!==void 0?a(T):v.continue();}else a();},d.onerror=function(){n(d.error);};}catch(v){n(v);}});}).catch(n);});return _(o,t),o}function gr(e,t,r){var o=this;e=O(e);var a=new h(function(n,u){var s;o.ready().then(function(){return s=o._dbInfo,re.call(t)==="[object Blob]"?I(s.db).then(function(l){return l?t:xe(t)}):t}).then(function(l){Q(o._dbInfo,c,function(d,p){if(d)return u(d);try{var v=p.objectStore(o._dbInfo.storeName);l===null&&(l=void 0);var E=v.put(l,e);p.oncomplete=function(){l===void 0&&(l=null),n(l);},p.onabort=p.onerror=function(){var T=E.error?E.error:E.transaction.error;u(T);};}catch(T){u(T);}});}).catch(u);});return _(a,r),a}function _r(e,t){var r=this;e=O(e);var o=new h(function(a,n){r.ready().then(function(){Q(r._dbInfo,c,function(u,s){if(u)return n(u);try{var l=s.objectStore(r._dbInfo.storeName),d=l.delete(e);s.oncomplete=function(){a();},s.onerror=function(){n(d.error);},s.onabort=function(){var p=d.error?d.error:d.transaction.error;n(p);};}catch(p){n(p);}});}).catch(n);});return _(o,t),o}function br(e){var t=this,r=new h(function(o,a){t.ready().then(function(){Q(t._dbInfo,c,function(n,u){if(n)return a(n);try{var s=u.objectStore(t._dbInfo.storeName),l=s.clear();u.oncomplete=function(){o();},u.onabort=u.onerror=function(){var d=l.error?l.error:l.transaction.error;a(d);};}catch(d){a(d);}});}).catch(a);});return _(r,e),r}function wr(e){var t=this,r=new h(function(o,a){t.ready().then(function(){Q(t._dbInfo,P,function(n,u){if(n)return a(n);try{var s=u.objectStore(t._dbInfo.storeName),l=s.count();l.onsuccess=function(){o(l.result);},l.onerror=function(){a(l.error);};}catch(d){a(d);}});}).catch(a);});return _(r,e),r}function Er(e,t){var r=this,o=new h(function(a,n){if(e<0){a(null);return}r.ready().then(function(){Q(r._dbInfo,P,function(u,s){if(u)return n(u);try{var l=s.objectStore(r._dbInfo.storeName),d=!1,p=l.openKeyCursor();p.onsuccess=function(){var v=p.result;if(!v){a(null);return}e===0||d?a(v.key):(d=!0,v.advance(e));},p.onerror=function(){n(p.error);};}catch(v){n(v);}});}).catch(n);});return _(o,t),o}function Ir(e){var t=this,r=new h(function(o,a){t.ready().then(function(){Q(t._dbInfo,P,function(n,u){if(n)return a(n);try{var s=u.objectStore(t._dbInfo.storeName),l=s.openKeyCursor(),d=[];l.onsuccess=function(){var p=l.result;if(!p){o(d);return}d.push(p.key),p.continue();},l.onerror=function(){a(l.error);};}catch(p){a(p);}});}).catch(a);});return _(r,e),r}function Sr(e,t){t=W.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,a;if(!e.name)a=h.reject("Invalid arguments");else {var n=e.name===r.name&&o._dbInfo.db,u=n?h.resolve(o._dbInfo.db):V(e).then(function(s){var l=M[e.name],d=l.forages;l.db=s;for(var p=0;p<d.length;p++)d[p]._dbInfo.db=s;return s});e.storeName?a=u.then(function(s){if(s.objectStoreNames.contains(e.storeName)){var l=s.version+1;U(e);var d=M[e.name],p=d.forages;s.close();for(var v=0;v<p.length;v++){var E=p[v];E._dbInfo.db=null,E._dbInfo.version=l;}var T=new h(function(R,q){var F=D.open(e.name,l);F.onerror=function(k){var fe=F.result;fe.close(),q(k);},F.onupgradeneeded=function(){var k=F.result;k.deleteObjectStore(e.storeName);},F.onsuccess=function(){var k=F.result;k.close(),R(k);};});return T.then(function(R){d.db=R;for(var q=0;q<p.length;q++){var F=p[q];F._dbInfo.db=R,Y(F._dbInfo);}}).catch(function(R){throw (j(e,R)||h.resolve()).catch(function(){}),R})}}):a=u.then(function(s){U(e);var l=M[e.name],d=l.forages;s.close();for(var p=0;p<d.length;p++){var v=d[p];v._dbInfo.db=null;}var E=new h(function(T,R){var q=D.deleteDatabase(e.name);q.onerror=function(){var F=q.result;F&&F.close(),R(q.error);},q.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed');},q.onsuccess=function(){var F=q.result;F&&F.close(),T(F);};});return E.then(function(T){l.db=T;for(var R=0;R<d.length;R++){var q=d[R];Y(q._dbInfo);}}).catch(function(T){throw (j(e,T)||h.resolve()).catch(function(){}),T})});}return _(a,t),a}var Tr={_driver:"asyncStorage",_initStorage:vr,_support:L(),iterate:xr,getItem:yr,setItem:gr,removeItem:_r,clear:br,length:wr,key:Er,keys:Ir,dropInstance:Sr};function Rr(){return typeof openDatabase=="function"}var X="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ar="~~local_forage_type~",Fe=/^~~local_forage_type~([^~]+)~/,ce="__lfsc__:",ge=ce.length,_e="arbf",be="blob",Me="si08",qe="ui08",ze="uic8",Ye="si16",je="si32",$e="ur16",ke="ui32",Ke="fl32",He="fl64",Ve=ge+_e.length,Qe=Object.prototype.toString;function Ge(e){var t=e.length*.75,r=e.length,o,a=0,n,u,s,l;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var d=new ArrayBuffer(t),p=new Uint8Array(d);for(o=0;o<r;o+=4)n=X.indexOf(e[o]),u=X.indexOf(e[o+1]),s=X.indexOf(e[o+2]),l=X.indexOf(e[o+3]),p[a++]=n<<2|u>>4,p[a++]=(u&15)<<4|s>>2,p[a++]=(s&3)<<6|l&63;return d}function we(e){var t=new Uint8Array(e),r="",o;for(o=0;o<t.length;o+=3)r+=X[t[o]>>2],r+=X[(t[o]&3)<<4|t[o+1]>>4],r+=X[(t[o+1]&15)<<2|t[o+2]>>6],r+=X[t[o+2]&63];return t.length%3===2?r=r.substring(0,r.length-1)+"=":t.length%3===1&&(r=r.substring(0,r.length-2)+"=="),r}function Nr(e,t){var r="";if(e&&(r=Qe.call(e)),e&&(r==="[object ArrayBuffer]"||e.buffer&&Qe.call(e.buffer)==="[object ArrayBuffer]")){var o,a=ce;e instanceof ArrayBuffer?(o=e,a+=_e):(o=e.buffer,r==="[object Int8Array]"?a+=Me:r==="[object Uint8Array]"?a+=qe:r==="[object Uint8ClampedArray]"?a+=ze:r==="[object Int16Array]"?a+=Ye:r==="[object Uint16Array]"?a+=$e:r==="[object Int32Array]"?a+=je:r==="[object Uint32Array]"?a+=ke:r==="[object Float32Array]"?a+=Ke:r==="[object Float64Array]"?a+=He:t(new Error("Failed to get type for BinaryArray"))),t(a+we(o));}else if(r==="[object Blob]"){var n=new FileReader;n.onload=function(){var u=Ar+e.type+"~"+we(this.result);t(ce+be+u);},n.readAsArrayBuffer(e);}else try{t(JSON.stringify(e));}catch(u){console.error("Couldn't convert value into a JSON string: ",e),t(null,u);}}function Dr(e){if(e.substring(0,ge)!==ce)return JSON.parse(e);var t=e.substring(Ve),r=e.substring(ge,Ve),o;if(r===be&&Fe.test(t)){var a=t.match(Fe);o=a[1],t=t.substring(a[0].length);}var n=Ge(t);switch(r){case _e:return n;case be:return z([n],{type:o});case Me:return new Int8Array(n);case qe:return new Uint8Array(n);case ze:return new Uint8ClampedArray(n);case Ye:return new Int16Array(n);case $e:return new Uint16Array(n);case je:return new Int32Array(n);case ke:return new Uint32Array(n);case Ke:return new Float32Array(n);case He:return new Float64Array(n);default:throw new Error("Unkown type: "+r)}}var Ee={serialize:Nr,deserialize:Dr,stringToBuffer:Ge,bufferToString:we};function Xe(e,t,r,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,o);}function Pr(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=typeof e[o]!="string"?e[o].toString():e[o];var a=new h(function(n,u){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size);}catch(s){return u(s)}r.db.transaction(function(s){Xe(s,r,function(){t._dbInfo=r,n();},function(l,d){u(d);});},u);});return r.serializer=Ee,a}function J(e,t,r,o,a,n){e.executeSql(r,o,a,function(u,s){s.code===s.SYNTAX_ERR?u.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(l,d){d.rows.length?n(l,s):Xe(l,t,function(){l.executeSql(r,o,a,n);},n);},n):n(u,s);},n);}function Br(e,t){var r=this;e=O(e);var o=new h(function(a,n){r.ready().then(function(){var u=r._dbInfo;u.db.transaction(function(s){J(s,u,"SELECT * FROM "+u.storeName+" WHERE key = ? LIMIT 1",[e],function(l,d){var p=d.rows.length?d.rows.item(0).value:null;p&&(p=u.serializer.deserialize(p)),a(p);},function(l,d){n(d);});});}).catch(n);});return _(o,t),o}function Cr(e,t){var r=this,o=new h(function(a,n){r.ready().then(function(){var u=r._dbInfo;u.db.transaction(function(s){J(s,u,"SELECT * FROM "+u.storeName,[],function(l,d){for(var p=d.rows,v=p.length,E=0;E<v;E++){var T=p.item(E),R=T.value;if(R&&(R=u.serializer.deserialize(R)),R=e(R,T.key,E+1),R!==void 0){a(R);return}}a();},function(l,d){n(d);});});}).catch(n);});return _(o,t),o}function Je(e,t,r,o){var a=this;e=O(e);var n=new h(function(u,s){a.ready().then(function(){t===void 0&&(t=null);var l=t,d=a._dbInfo;d.serializer.serialize(t,function(p,v){v?s(v):d.db.transaction(function(E){J(E,d,"INSERT OR REPLACE INTO "+d.storeName+" (key, value) VALUES (?, ?)",[e,p],function(){u(l);},function(T,R){s(R);});},function(E){if(E.code===E.QUOTA_ERR){if(o>0){u(Je.apply(a,[e,l,r,o-1]));return}s(E);}});});}).catch(s);});return _(n,r),n}function Or(e,t,r){return Je.apply(this,[e,t,r,1])}function Lr(e,t){var r=this;e=O(e);var o=new h(function(a,n){r.ready().then(function(){var u=r._dbInfo;u.db.transaction(function(s){J(s,u,"DELETE FROM "+u.storeName+" WHERE key = ?",[e],function(){a();},function(l,d){n(d);});});}).catch(n);});return _(o,t),o}function Wr(e){var t=this,r=new h(function(o,a){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(u){J(u,n,"DELETE FROM "+n.storeName,[],function(){o();},function(s,l){a(l);});});}).catch(a);});return _(r,e),r}function Ur(e){var t=this,r=new h(function(o,a){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(u){J(u,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(s,l){var d=l.rows.item(0).c;o(d);},function(s,l){a(l);});});}).catch(a);});return _(r,e),r}function Fr(e,t){var r=this,o=new h(function(a,n){r.ready().then(function(){var u=r._dbInfo;u.db.transaction(function(s){J(s,u,"SELECT key FROM "+u.storeName+" WHERE id = ? LIMIT 1",[e+1],function(l,d){var p=d.rows.length?d.rows.item(0).key:null;a(p);},function(l,d){n(d);});});}).catch(n);});return _(o,t),o}function Mr(e){var t=this,r=new h(function(o,a){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(u){J(u,n,"SELECT key FROM "+n.storeName,[],function(s,l){for(var d=[],p=0;p<l.rows.length;p++)d.push(l.rows.item(p).key);o(d);},function(s,l){a(l);});});}).catch(a);});return _(r,e),r}function qr(e){return new h(function(t,r){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(a,n){for(var u=[],s=0;s<n.rows.length;s++)u.push(n.rows.item(s).name);t({db:e,storeNames:u});},function(a,n){r(n);});},function(o){r(o);});})}function zr(e,t){t=W.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,a;return e.name?a=new h(function(n){var u;e.name===r.name?u=o._dbInfo.db:u=openDatabase(e.name,"","",0),e.storeName?n({db:u,storeNames:[e.storeName]}):n(qr(u));}).then(function(n){return new h(function(u,s){n.db.transaction(function(l){function d(T){return new h(function(R,q){l.executeSql("DROP TABLE IF EXISTS "+T,[],function(){R();},function(F,k){q(k);});})}for(var p=[],v=0,E=n.storeNames.length;v<E;v++)p.push(d(n.storeNames[v]));h.all(p).then(function(){u();}).catch(function(T){s(T);});},function(l){s(l);});})}):a=h.reject("Invalid arguments"),_(a,t),a}var Yr={_driver:"webSQLStorage",_initStorage:Pr,_support:Rr(),iterate:Cr,getItem:Br,setItem:Or,removeItem:Lr,clear:Wr,length:Ur,key:Fr,keys:Mr,dropInstance:zr};function jr(){try{return typeof localStorage!="undefined"&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return false}}function Ze(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function $r(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(t){return true}}function kr(){return !$r()||localStorage.length>0}function Kr(e){var t=this,r={};if(e)for(var o in e)r[o]=e[o];return r.keyPrefix=Ze(e,t._defaultConfig),kr()?(t._dbInfo=r,r.serializer=Ee,h.resolve()):h.reject()}function Hr(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo.keyPrefix,a=localStorage.length-1;a>=0;a--){var n=localStorage.key(a);n.indexOf(o)===0&&localStorage.removeItem(n);}});return _(r,e),r}function Vr(e,t){var r=this;e=O(e);var o=r.ready().then(function(){var a=r._dbInfo,n=localStorage.getItem(a.keyPrefix+e);return n&&(n=a.serializer.deserialize(n)),n});return _(o,t),o}function Qr(e,t){var r=this,o=r.ready().then(function(){for(var a=r._dbInfo,n=a.keyPrefix,u=n.length,s=localStorage.length,l=1,d=0;d<s;d++){var p=localStorage.key(d);if(p.indexOf(n)===0){var v=localStorage.getItem(p);if(v&&(v=a.serializer.deserialize(v)),v=e(v,p.substring(u),l++),v!==void 0)return v}}});return _(o,t),o}function Gr(e,t){var r=this,o=r.ready().then(function(){var a=r._dbInfo,n;try{n=localStorage.key(e);}catch(u){n=null;}return n&&(n=n.substring(a.keyPrefix.length)),n});return _(o,t),o}function Xr(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo,a=localStorage.length,n=[],u=0;u<a;u++){var s=localStorage.key(u);s.indexOf(o.keyPrefix)===0&&n.push(s.substring(o.keyPrefix.length));}return n});return _(r,e),r}function Jr(e){var t=this,r=t.keys().then(function(o){return o.length});return _(r,e),r}function Zr(e,t){var r=this;e=O(e);var o=r.ready().then(function(){var a=r._dbInfo;localStorage.removeItem(a.keyPrefix+e);});return _(o,t),o}function et(e,t,r){var o=this;e=O(e);var a=o.ready().then(function(){t===void 0&&(t=null);var n=t;return new h(function(u,s){var l=o._dbInfo;l.serializer.serialize(t,function(d,p){if(p)s(p);else try{localStorage.setItem(l.keyPrefix+e,d),u(n);}catch(v){(v.name==="QuotaExceededError"||v.name==="NS_ERROR_DOM_QUOTA_REACHED")&&s(v),s(v);}});})});return _(a,r),a}function rt(e,t){if(t=W.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName;}var o=this,a;return e.name?a=new h(function(n){e.storeName?n(Ze(e,o._defaultConfig)):n(e.name+"/");}).then(function(n){for(var u=localStorage.length-1;u>=0;u--){var s=localStorage.key(u);s.indexOf(n)===0&&localStorage.removeItem(s);}}):a=h.reject("Invalid arguments"),_(a,t),a}var tt={_driver:"localStorageWrapper",_initStorage:Kr,_support:jr(),iterate:Qr,getItem:Vr,setItem:et,removeItem:Zr,clear:Hr,length:Jr,key:Gr,keys:Xr,dropInstance:rt},nt=function(t,r){return t===r||typeof t=="number"&&typeof r=="number"&&isNaN(t)&&isNaN(r)},ot=function(t,r){for(var o=t.length,a=0;a<o;){if(nt(t[a],r))return true;a++;}return false},er=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},ae={},rr={},ne={INDEXEDDB:Tr,WEBSQL:Yr,LOCALSTORAGE:tt},at=[ne.INDEXEDDB._driver,ne.WEBSQL._driver,ne.LOCALSTORAGE._driver],de=["dropInstance"],Ie=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(de),ft={description:"",driver:at.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function ut(e,t){e[t]=function(){var r=arguments;return e.ready().then(function(){return e[t].apply(e,r)})};}function Se(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(er(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r]);}return arguments[0]}var it=(function(){function e(t){N(this,e);for(var r in ne)if(ne.hasOwnProperty(r)){var o=ne[r],a=o._driver;this[r]=a,ae[a]||this.defineDriver(o);}this._defaultConfig=Se({},ft),this._config=Se({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=false,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){});}return e.prototype.config=function(r){if((typeof r=="undefined"?"undefined":S(r))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var o in r){if(o==="storeName"&&(r[o]=r[o].replace(/\W/g,"_")),o==="version"&&typeof r[o]!="number")return new Error("Database version must be a number.");this._config[o]=r[o];}return "driver"in r&&r.driver?this.setDriver(this._config.driver):true}else return typeof r=="string"?this._config[r]:this._config},e.prototype.defineDriver=function(r,o,a){var n=new h(function(u,s){try{var l=r._driver,d=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!r._driver){s(d);return}for(var p=Ie.concat("_initStorage"),v=0,E=p.length;v<E;v++){var T=p[v],R=!ot(de,T);if((R||r[T])&&typeof r[T]!="function"){s(d);return}}var q=function(){for(var fe=function(ct){return function(){var dt=new Error("Method "+ct+" is not implemented by the current driver"),tr=h.reject(dt);return _(tr,arguments[arguments.length-1]),tr}},Te=0,lt=de.length;Te<lt;Te++){var Re=de[Te];r[Re]||(r[Re]=fe(Re));}};q();var F=function(fe){ae[l]&&console.info("Redefining LocalForage driver: "+l),ae[l]=r,rr[l]=fe,u();};"_support"in r?r._support&&typeof r._support=="function"?r._support().then(F,s):F(!!r._support):F(!0);}catch(k){s(k);}});return B(n,o,a),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(r,o,a){var n=ae[r]?h.resolve(ae[r]):h.reject(new Error("Driver not found."));return B(n,o,a),n},e.prototype.getSerializer=function(r){var o=h.resolve(Ee);return B(o,r),o},e.prototype.ready=function(r){var o=this,a=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return B(a,r,r),a},e.prototype.setDriver=function(r,o,a){var n=this;er(r)||(r=[r]);var u=this._getSupportedDrivers(r);function s(){n._config.driver=n.driver();}function l(v){return n._extend(v),s(),n._ready=n._initStorage(n._config),n._ready}function d(v){return function(){var E=0;function T(){for(;E<v.length;){var R=v[E];return E++,n._dbInfo=null,n._ready=null,n.getDriver(R).then(l).catch(T)}s();var q=new Error("No available storage method found.");return n._driverSet=h.reject(q),n._driverSet}return T()}}var p=this._driverSet!==null?this._driverSet.catch(function(){return h.resolve()}):h.resolve();return this._driverSet=p.then(function(){var v=u[0];return n._dbInfo=null,n._ready=null,n.getDriver(v).then(function(E){n._driver=E._driver,s(),n._wrapLibraryMethodsWithReady(),n._initDriver=d(u);})}).catch(function(){s();var v=new Error("No available storage method found.");return n._driverSet=h.reject(v),n._driverSet}),B(this._driverSet,o,a),this._driverSet},e.prototype.supports=function(r){return !!rr[r]},e.prototype._extend=function(r){Se(this,r);},e.prototype._getSupportedDrivers=function(r){for(var o=[],a=0,n=r.length;a<n;a++){var u=r[a];this.supports(u)&&o.push(u);}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var r=0,o=Ie.length;r<o;r++)ut(this,Ie[r]);},e.prototype.createInstance=function(r){return new e(r)},e})(),st=new it;y.exports=st;},{3:3}]},{},[4])(4)});});var me=class{constructor(f=1){this.buffer=[];this.subscriptions=[];this.maxBufferSize=f;}subscribe(f){return this.subscriptions.push(f),this.buffer.forEach(m=>f(m)),()=>this.unsubscribe(f)}unsubscribe(f){this.subscriptions=this.subscriptions.filter(m=>m!==f);}next(f){this.subscriptions.forEach(m=>m(f)),this.buffer.push(f),this.buffer.length>this.maxBufferSize&&(this.buffer=this.buffer.slice(1));}};var Le=_t(ur());function G(i){return i!=null&&typeof i=="object"&&i["@@functional/placeholder"]===true}function H(i){return function f(m){return arguments.length===0||G(m)?f:i.apply(this,arguments)}}function De(i){return function f(m,x){switch(arguments.length){case 0:return f;case 1:return G(m)?f:H(function(y){return i(m,y)});default:return G(m)&&G(x)?f:G(m)?H(function(y){return i(y,x)}):G(x)?H(function(y){return i(m,y)}):i(m,x)}}}function he(i){for(var f=[],m;!(m=i.next()).done;)f.push(m.value);return f}function ve(i,f,m){for(var x=0,y=m.length;x<y;){if(i(f,m[x]))return true;x+=1;}return false}function Pe(i){var f=String(i).match(/^function (\w*)/);return f==null?"":f[1]}function ee(i,f){return Object.prototype.hasOwnProperty.call(f,i)}function bt(i,f){return i===f?i!==0||1/i===1/f:i!==i&&f!==f}var ye=typeof Object.is=="function"?Object.is:bt;var ir=Object.prototype.toString,wt=(function(){return ir.call(arguments)==="[object Arguments]"?function(f){return ir.call(f)==="[object Arguments]"}:function(f){return ee("callee",f)}})(),sr=wt;var Et=!{toString:null}.propertyIsEnumerable("toString"),lr=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],cr=(function(){return arguments.propertyIsEnumerable("length")})(),It=function(f,m){for(var x=0;x<f.length;){if(f[x]===m)return true;x+=1;}return false},St=typeof Object.keys=="function"&&!cr?H(function(f){return Object(f)!==f?[]:Object.keys(f)}):H(function(f){if(Object(f)!==f)return [];var m,x,y=[],A=cr&&sr(f);for(m in f)ee(m,f)&&(!A||m!=="length")&&(y[y.length]=m);if(Et)for(x=lr.length-1;x>=0;)m=lr[x],ee(m,f)&&!It(y,m)&&(y[y.length]=m),x-=1;return y}),Be=St;var Tt=H(function(f){return f===null?"Null":f===void 0?"Undefined":Object.prototype.toString.call(f).slice(8,-1)}),Ce=Tt;function dr(i,f,m,x){var y=he(i),A=he(f);function S(N,g){return ie(N,g,m.slice(),x.slice())}return !ve(function(N,g){return !ve(S,g,N)},A,y)}function ie(i,f,m,x){if(ye(i,f))return true;var y=Ce(i);if(y!==Ce(f))return false;if(typeof i["fantasy-land/equals"]=="function"||typeof f["fantasy-land/equals"]=="function")return typeof i["fantasy-land/equals"]=="function"&&i["fantasy-land/equals"](f)&&typeof f["fantasy-land/equals"]=="function"&&f["fantasy-land/equals"](i);if(typeof i.equals=="function"||typeof f.equals=="function")return typeof i.equals=="function"&&i.equals(f)&&typeof f.equals=="function"&&f.equals(i);switch(y){case "Arguments":case "Array":case "Object":if(typeof i.constructor=="function"&&Pe(i.constructor)==="Promise")return i===f;break;case "Boolean":case "Number":case "String":if(!(typeof i==typeof f&&ye(i.valueOf(),f.valueOf())))return false;break;case "Date":if(!ye(i.valueOf(),f.valueOf()))return false;break;case "Error":return i.name===f.name&&i.message===f.message;case "RegExp":if(!(i.source===f.source&&i.global===f.global&&i.ignoreCase===f.ignoreCase&&i.multiline===f.multiline&&i.sticky===f.sticky&&i.unicode===f.unicode))return false;break}for(var A=m.length-1;A>=0;){if(m[A]===i)return x[A]===f;A-=1;}switch(y){case "Map":return i.size!==f.size?false:dr(i.entries(),f.entries(),m.concat([i]),x.concat([f]));case "Set":return i.size!==f.size?false:dr(i.values(),f.values(),m.concat([i]),x.concat([f]));case "Arguments":case "Array":case "Object":case "Boolean":case "Number":case "String":case "Date":case "Error":case "RegExp":case "Int8Array":case "Uint8Array":case "Uint8ClampedArray":case "Int16Array":case "Uint16Array":case "Int32Array":case "Uint32Array":case "Float32Array":case "Float64Array":case "ArrayBuffer":break;default:return false}var S=Be(i);if(S.length!==Be(f).length)return false;var N=m.concat([i]),g=x.concat([f]);for(A=S.length-1;A>=0;){var D=S[A];if(!(ee(D,f)&&ie(f[D],i[D],N,g)))return false;A-=1;}return true}var Rt=De(function(f,m){return ie(f,m,[],[])}),Oe=Rt;function pr(i,f=0){return Z(this,null,function*(){let m=(f||0)+1;for(let x=0;x<m;x++)try{return yield i()}catch(y){if(x===m-1)throw y}throw new Error("fnRunner: Unexpected error - all retries exhausted.")})}var se=Le.default.createInstance({name:"sh-common-cache"});function At(i,f,m){let{retry:x,maxAge:y,version:A,compareBeforeUpdate:S,remoteMemoryCache:N,equals:g,cacheEnabled:D,beforeRequest:L,onSuccess:z,onError:h,errorHandler:_}=pe({equals:(P,c)=>P.length===c.length&&P.every((b,w)=>b===c[w]),retry:0,compareBeforeUpdate:Oe,remoteMemoryCache:false},m),B=new me(1),O=P=>Z(null,null,function*(){let c=yield se.getItem(i);if(c&&(!A||c.version===A)&&(!c.expires||c.expires>Date.now())&&g(c.args,P))return c.result;throw new Error("Cache not found")}),W={success:false,args:[],result:null},C=()=>{W.success=false,W.result=null,W.args=[];},K=P=>{if(W.success&&g(W.args,P))return {type:"memory",promiseResult:W.result};W.args=P,W.success=true;let c=W.result=pr(()=>f(...P),x);return Promise.resolve(c).then(b=>(!N&&C(),b)).catch(C),{type:"remote",promiseResult:c}},M=P=>Z(null,null,function*(){let c={type:"remote",result:null};try{let{type:b,promiseResult:w}=K(P),I=c.result=yield w;b==="remote"&&(!D||(yield D(P)))&&Promise.resolve().then(()=>Z(null,null,function*(){let U=yield O(P).catch(()=>null),Y=pe(pe({args:P,result:I},A&&{version:A}),y&&{expires:Date.now()+y});se.setItem(i,Y),!(S&&U&&S(U.result,I))&&B.next({result:I,cacheData:Y,isCacheHit:!!U});}));}catch(b){if(_)c.result=yield _(b);else throw b}return c.result}),re=(...P)=>Z(null,null,function*(){yield L==null?void 0:L();let[c,b]=[O(P),M(P)];return c.then(I=>z==null?void 0:z({type:"local",result:I})).catch(()=>{}),b.then(I=>z==null?void 0:z({type:"remote",result:I})).catch(I=>h==null?void 0:h(I)).catch(()=>{}),yield Promise.race([c.catch(()=>b),b])});return re.subscribeCacheUpdate=P=>B.subscribe(P),re.clearCache=()=>Z(null,null,function*(){C(),yield se.removeItem(i);}),re}At.useDb=i=>{typeof i=="string"?se=Le.default.createInstance({name:i}):se=i;};var gn="0.0.3";/*! Bundled license information:
2
+
3
+ localforage/dist/localforage.js:
4
+ (*!
5
+ localForage -- Offline Storage, Improved
6
+ Version 1.10.0
7
+ https://localforage.github.io/localForage
8
+ (c) 2013-2017 Mozilla, Apache License 2.0
9
+ *)
10
+ */exports.ReplaySubject=me;exports.createQueryWithCache=At;exports.fnRunner=pr;exports.version=gn;return exports;})({});//# sourceMappingURL=sh-utils.js.map
11
+ //# sourceMappingURL=sh-utils.js.map