@converse/skeletor
Version:
Models and Collections for modern web apps
73 lines (61 loc) • 99.1 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).skeletor={})}(this,function(t){var e=Object.prototype;function r(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||e)}function n(t,e){return function(r){return t(e(r))}}var o=n(Object.keys,Object),i=Object.prototype.hasOwnProperty;function s(t){if(!r(t))return o(t);var e=[];for(var n in Object(t))i.call(t,n)&&"constructor"!=n&&e.push(n);return e}var a="object"==typeof global&&global&&global.Object===Object&&global,u="object"==typeof self&&self&&self.Object===Object&&self,c=a||u||Function("return this")(),l=c.Symbol,f=Object.prototype,h=f.hasOwnProperty,d=f.toString,v=l?l.toStringTag:void 0;var p=Object.prototype.toString;var y=l?l.toStringTag:void 0;function b(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":y&&y in Object(t)?function(t){var e=h.call(t,v),r=t[v];try{t[v]=void 0;var n=!0}catch(t){}var o=d.call(t);return n&&(e?t[v]=r:delete t[v]),o}(t):function(t){return p.call(t)}(t)}function g(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function m(t){if(!g(t))return!1;var e=b(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var _,w=c["__core-js_shared__"],j=(_=/[^.]+$/.exec(w&&w.keys&&w.keys.IE_PROTO||""))?"Symbol(src)_1."+_:"";var I=Function.prototype.toString;function S(t){if(null!=t){try{return I.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var O=/^\[object .+?Constructor\]$/,A=Function.prototype,x=Object.prototype,E=A.toString,N=x.hasOwnProperty,k=RegExp("^"+E.call(N).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function B(t){return!(!g(t)||(e=t,j&&j in e))&&(m(t)?k:O).test(S(t));var e}function R(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return B(r)?r:void 0}var P=R(c,"DataView"),z=R(c,"Map"),D=R(c,"Promise"),T=R(c,"Set"),C=R(c,"WeakMap"),M="[object Map]",F="[object Promise]",U="[object Set]",L="[object WeakMap]",q="[object DataView]",W=S(P),J=S(z),K=S(D),V=S(T),Q=S(C),G=b;function H(t){return null!=t&&"object"==typeof t}(P&&G(new P(new ArrayBuffer(1)))!=q||z&&G(new z)!=M||D&&G(D.resolve())!=F||T&&G(new T)!=U||C&&G(new C)!=L)&&(G=function(t){var e=b(t),r="[object Object]"==e?t.constructor:void 0,n=r?S(r):"";if(n)switch(n){case W:return q;case J:return M;case K:return F;case V:return U;case Q:return L}return e});function $(t){return H(t)&&"[object Arguments]"==b(t)}var X=Object.prototype,Y=X.hasOwnProperty,Z=X.propertyIsEnumerable,tt=$(function(){return arguments}())?$:function(t){return H(t)&&Y.call(t,"callee")&&!Z.call(t,"callee")},et=Array.isArray;function rt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function nt(t){return null!=t&&rt(t.length)&&!m(t)}var ot="object"==typeof t&&t&&!t.nodeType&&t,it=ot&&"object"==typeof module&&module&&!module.nodeType&&module,st=it&&it.exports===ot?c.Buffer:void 0,at=(st?st.isBuffer:void 0)||function(){return!1},ut={};function ct(t){return function(e){return t(e)}}ut["[object Float32Array]"]=ut["[object Float64Array]"]=ut["[object Int8Array]"]=ut["[object Int16Array]"]=ut["[object Int32Array]"]=ut["[object Uint8Array]"]=ut["[object Uint8ClampedArray]"]=ut["[object Uint16Array]"]=ut["[object Uint32Array]"]=!0,ut["[object Arguments]"]=ut["[object Array]"]=ut["[object ArrayBuffer]"]=ut["[object Boolean]"]=ut["[object DataView]"]=ut["[object Date]"]=ut["[object Error]"]=ut["[object Function]"]=ut["[object Map]"]=ut["[object Number]"]=ut["[object Object]"]=ut["[object RegExp]"]=ut["[object Set]"]=ut["[object String]"]=ut["[object WeakMap]"]=!1;var lt="object"==typeof t&&t&&!t.nodeType&&t,ft=lt&&"object"==typeof module&&module&&!module.nodeType&&module,ht=ft&&ft.exports===lt&&a.process,dt=function(){try{var t=ft&&ft.require&&ft.require("util").types;return t||ht&&ht.binding&&ht.binding("util")}catch(t){}}(),vt=dt&&dt.isTypedArray,pt=vt?ct(vt):function(t){return H(t)&&rt(t.length)&&!!ut[b(t)]},yt=Object.prototype.hasOwnProperty;function bt(t){if(null==t)return!0;if(nt(t)&&(et(t)||"string"==typeof t||"function"==typeof t.splice||at(t)||pt(t)||tt(t)))return!t.length;var e=G(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(r(t))return!s(t).length;for(var n in t)if(yt.call(t,n))return!1;return!0}var gt=/^(?:0|[1-9]\d*)$/;function mt(t,e){var r=typeof t;return!!(e=e??9007199254740991)&&("number"==r||"symbol"!=r&>.test(t))&&t>-1&&t%1==0&&t<e}var _t=Object.prototype.hasOwnProperty;function wt(t,e){var r=et(t),n=!r&&tt(t),o=!r&&!n&&at(t),i=!r&&!n&&!o&&pt(t),s=r||n||o||i,a=s?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],u=a.length;for(var c in t)!e&&!_t.call(t,c)||s&&("length"==c||o&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||mt(c,u))||a.push(c);return a}function jt(t){return nt(t)?wt(t):s(t)}function It(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}function St(t){return"symbol"==typeof t||H(t)&&"[object Symbol]"==b(t)}var Ot=l?l.prototype:void 0,At=Ot?Ot.toString:void 0;function xt(t){if("string"==typeof t)return t;if(et(t))return It(t,xt)+"";if(St(t))return At?At.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Et(t){return null==t?"":xt(t)}var Nt=0;function kt(t){var e=++Nt;return Et(t)+e}var Bt=/\s/;var Rt=/^\s+/;function Pt(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&Bt.test(t.charAt(e)););return e}(t)+1).replace(Rt,""):t}var zt=/^[-+]0x[0-9a-f]+$/i,Dt=/^0b[01]+$/i,Tt=/^0o[0-7]+$/i,Ct=parseInt;var Mt=1/0;function Ft(t){return t?(t=function(t){if("number"==typeof t)return t;if(St(t))return NaN;if(g(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=g(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Pt(t);var r=Dt.test(t);return r||Tt.test(t)?Ct(t.slice(2),r?2:8):zt.test(t)?NaN:+t}(t))===Mt||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function Ut(t,e){var r;if("function"!=typeof e)throw new TypeError("Expected a function");return t=function(t){var e=Ft(t),r=e%1;return e==e?r?e-r:e:0}(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=void 0),r}}const Lt=/\s+/;function qt(t,e,r,n,o){let i,s=0;if(r&&"object"==typeof r){void 0!==n&&"context"in o&&void 0===o.context&&(o.context=n);for(i=Object.keys(r);s<i.length;s++)e=qt(t,e,i[s],r[i[s]],o)}else if(r&&"string"==typeof r&&Lt.test(r))for(i=r.split(Lt);s<i.length;s++){const r=t(e,i[s],n,o);void 0!==r&&(e=r)}else e=t(e,r,n,o);return e}function Wt(t,e,r,n){if(r){const o=t[e]||(t[e]=[]),i=n.context,s=n.ctx,a=n.listening;a&&a.count++,o.push({callback:r,context:i,ctx:i||s,listening:a})}return t}function Jt(t,e,r,n){if(!t)return;const o=n.context,i=n.listeners;let s,a=0;if(e||o||r){for(s=e?[e]:Object.keys(t);a<s.length;a++){const e=s[a],n=t[e];if(!n)continue;const i=[];for(let t=0;t<n.length;t++){const s=n[t];if(r&&r!==s.callback&&r!==s.callback._callback||o&&o!==s.context)i.push(s);else{const t=s.listening;t&&t.stop(e,r)}}i.length?t[e]=i:delete t[e]}return t}if(i)for(s=Object.keys(i);a<s.length;a++)i[s[a]].cleanup()}function Kt(t,e,r,n){if(r){const o=Ut(2,function(...t){n(e,o),r.apply(this,t)});t[e]=o,o._callback=r}return t}function Vt(t,e,r,n){if(t){const r=t[e];let o=t.all;r&&o&&(o=o.slice()),r&&Qt(r,n),o&&Qt(o,[e].concat(n))}return t}function Qt(t,e){let r,n=-1;const o=t.length,i=e[0],s=e[1],a=e[2];switch(e.length){case 0:for(;++n<o;)(r=t[n]).callback.call(r.ctx);return;case 1:for(;++n<o;)(r=t[n]).callback.call(r.ctx,i);return;case 2:for(;++n<o;)(r=t[n]).callback.call(r.ctx,i,s);return;case 3:for(;++n<o;)(r=t[n]).callback.call(r.ctx,i,s,a);return;default:for(;++n<o;)(r=t[n]).callback.apply(r.ctx,e);return}}class Gt{constructor(t,e){this.id=t._listenId,this.listener=t,this.obj=e,this.interop=!0,this.count=0,this._events=void 0}start(t,e,r,n){const o={context:this.obj,ctx:r,listening:n};if(this._events=qt(Wt,this._events||{},t,e,o),n){(this.obj._listeners||(this.obj._listeners={}))[this.id]=this,this.interop=!1}return this}stop(t,e){let r;this.interop?(this._events=qt(Jt,this._events,t,e,{context:void 0,listeners:void 0}),r=!this._events):(this.count--,r=0===this.count),r&&this.cleanup()}cleanup(){this.listener._listeningTo&&delete this.listener._listeningTo[this.obj._listenId],!this.interop&&this.obj._listeners&&delete this.obj._listeners[this.id]}}
/**
* @copyright 2010-2019 Jeremy Ashkenas and DocumentCloud
* @copyright 2023 JC Brand
*/let Ht;function $t(t){return class extends t{on(t,e,r){if(this._events=qt(Wt,this._events||{},t,e,{context:r,ctx:this,listening:Ht}),Ht){(this._listeners||(this._listeners={}))[Ht.id]=Ht,Ht.interop=!1}return this}listenTo(t,e,r){if(!t)return this;const n=t._listenId||(t._listenId=kt("l")),o=this._listeningTo||(this._listeningTo={});let i=Ht=o[n];i||(this._listenId||(this._listenId=kt("l")),i=Ht=o[n]=new Gt(this,t));const s=function(t,e,r,n){try{t.on(e,r,n)}catch(t){return t}}(t,e,r,this);if(Ht=void 0,s)throw s;return i.interop&&i.start(e,r,this,Ht),this}off(t,e,r){return this._events?(this._events=qt(Jt,this._events,t,e,{context:r,listeners:this._listeners}),this):this}stopListening(t,e,r){const n=this._listeningTo;if(!n)return this;const o=t?[t._listenId]:jt(n);for(let t=0;t<o.length;t++){const i=n[o[t]];if(!i)break;i.obj.off(e,r,this),i.interop&&i.stop(e,r)}return bt(n)&&(this._listeningTo=void 0),this}once(t,e,r){const n=qt(Kt,{},t,e,this.off.bind(this));return"string"==typeof t&&null==r&&(e=void 0),this.on(n,e,r)}listenToOnce(t,e,r){const n=qt(Kt,{},e,r,this.stopListening.bind(this,t));return this.listenTo(t,n)}trigger(t,...e){return this._events?(qt(Vt,this._events,t,void 0,e),this):this}}}const Xt=$t(Object);
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var Yt=/^~~local_forage_type~([^~]+)~/,Zt=Object.prototype.toString;function te(t){var e=.75*t.length,r=t.length;"="===t[t.length-1]&&(e--,"="===t[t.length-2]&&e--);for(var n=new ArrayBuffer(e),o=new Uint8Array(n),i=0,s=0;i<r;i+=4){var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(t[i]),u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(t[i+1]),c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(t[i+2]),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(t[i+3]);o[s++]=a<<2|u>>4,o[s++]=(15&u)<<4|c>>2,o[s++]=(3&c)<<6|63&l}return n}function ee(t){for(var e=new Uint8Array(t),r="",n=0;n<e.length;n+=3)r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e[n]>>2],r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(3&e[n])<<4|e[n+1]>>4],r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(15&e[n+1])<<2|e[n+2]>>6],r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[63&e[n+2]];return e.length%3==2?r=r.substring(0,r.length-1)+"=":e.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}function re(t){var e,r;if(null===t||"object"!=typeof t||"isActiveClone"in t)return t;var n=t instanceof Date?new Date(t):t.constructor();try{for(var o=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}
/*!
MIT License
Copyright (c) 2018 Arturas Molcanovas <a.molcanovas@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/(Object.keys(t)),i=o.next();!i.done;i=o.next()){var s=i.value;Object.prototype.hasOwnProperty.call(t,s)&&(t.isActiveClone=null,n[s]=re(t[s]),delete t.isActiveClone)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return n}function ne(t,e){return(t.name||e.name)+"/"+(t.storeName||e.storeName)+"/"}function oe(t,e){e&&t.then(function(t){e(null,t)},function(t){e(t)})}function ie(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}function se(t,e){var r=this;if(e=ie.apply(this,arguments),!(t="function"!=typeof t&&t||{}).name){var n=this.config();t.name=t.name||n.name,t.storeName=t.storeName||n.storeName}return{promise:t.name?new Promise(function(e){t.storeName?e(ne(t,r._defaultConfig)):e(t.name+"/")}):Promise.reject("Invalid arguments"),callback:e}}function ae(t){return"string"!=typeof t&&(console.warn(t+" used as a key, but it is not a string."),t=String(t)),t}var ue={bufferToString:ee,deserialize:function(t){if("__lfsc__:"!==t.substring(0,9))return JSON.parse(t);var e,r=t.substring(13),n=t.substring(9,13);if("blob"===n&&Yt.test(r)){var o=r.match(Yt);e=o[1],r=r.substring(o[0].length)}var i=te(r);switch(n){case"arbf":return i;case"blob":return function(t,e){t=t||[],e=e||{};try{return new Blob(t,e)}catch(o){if("TypeError"!==o.name)throw o;for(var r=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),n=0;n<t.length;n+=1)r.append(t[n]);return r.getBlob(e.type)}}([i],{type:e});case"si08":return new Int8Array(i);case"ui08":return new Uint8Array(i);case"uic8":return new Uint8ClampedArray(i);case"si16":return new Int16Array(i);case"ur16":return new Uint16Array(i);case"si32":return new Int32Array(i);case"ui32":return new Uint32Array(i);case"fl32":return new Float32Array(i);case"fl64":return new Float64Array(i);default:throw new Error("Unkown type: "+n)}},serialize:function(t,e){var r="";if(t&&(r=Zt.call(t)),t&&("[object ArrayBuffer]"===r||t.buffer&&"[object ArrayBuffer]"===Zt.call(t.buffer))){var n=void 0,o="__lfsc__:";t instanceof ArrayBuffer?(n=t,o+="arbf"):(n=t.buffer,"[object Int8Array]"===r?o+="si08":"[object Uint8Array]"===r?o+="ui08":"[object Uint8ClampedArray]"===r?o+="uic8":"[object Int16Array]"===r?o+="si16":"[object Uint16Array]"===r?o+="ur16":"[object Int32Array]"===r?o+="si32":"[object Uint32Array]"===r?o+="ui32":"[object Float32Array]"===r?o+="fl32":"[object Float64Array]"===r?o+="fl64":e(new Error("Failed to get type for BinaryArray"))),e(o+ee(n))}else if("[object Blob]"===r){var i=new FileReader;i.onload=function(){var r="~~local_forage_type~"+t.type+"~"+ee(this.result);e("__lfsc__:blob"+r)},i.readAsArrayBuffer(t)}else try{e(JSON.stringify(t))}catch(r){console.error("Couldn't convert value into a JSON string: ",t),e(null,r)}},stringToBuffer:te},ce="localforage-driver-memory",le={},fe=function(){function t(t){this.kp=t,this.data={}}return t.resolve=function(e){return le[e]||(le[e]=new t(e)),le[e]},t.prototype.clear=function(){this.data={}},t.prototype.drop=function(){this.clear(),delete le[this.kp]},t.prototype.get=function(t){return this.data[t]},t.prototype.key=function(t){return this.keys()[t]},t.prototype.keys=function(){return Object.keys(this.data)},t.prototype.rm=function(t){delete this.data[t]},t.prototype.set=function(t,e){this.data[t]=e},t}();
/*!
MIT License
Copyright (c) 2018 Arturas Molcanovas <a.molcanovas@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/var he=Object.freeze({__proto__:null,_driver:ce,_initStorage:function(t){var e=t?re(t):{},r=ne(e,this._defaultConfig),n=fe.resolve(r);return this._dbInfo=e,this._dbInfo.serializer=ue,this._dbInfo.keyPrefix=r,this._dbInfo.mStore=n,Promise.resolve()},_support:!0,clear:function(t){var e=this,r=this.ready().then(function(){e._dbInfo.mStore.clear()});return oe(r,t),r},dropInstance:function(t,e){var r=se.apply(this,arguments),n=r.promise,o=r.callback;return oe(n.then(function(t){fe.resolve(t).drop()}),o),n},getItem:function(t,e){var r=this;t=ae(t);var n=this.ready().then(function(){var e=r._dbInfo.mStore.get(t);return null==e?null:r._dbInfo.serializer.deserialize(e)});return oe(n,e),n},iterate:function(t,e){var r=this,n=this.ready().then(function(){for(var e=r._dbInfo.mStore,n=e.keys(),o=0;o<n.length;o++){var i=e.get(n[o]);if(i&&(i=r._dbInfo.serializer.deserialize(i)),void 0!==(i=t(i,n[o],o+1)))return i}});return oe(n,e),n},key:function(t,e){var r=this,n=this.ready().then(function(){var e;try{void 0===(e=r._dbInfo.mStore.key(t))&&(e=null)}catch(t){e=null}return e});return oe(n,e),n},keys:function(t){var e=this,r=this.ready().then(function(){return e._dbInfo.mStore.keys()});return oe(r,t),r},length:function(t){var e=this.keys().then(function(t){return t.length});return oe(e,t),e},removeItem:function(t,e){var r=this;t=ae(t);var n=this.ready().then(function(){r._dbInfo.mStore.rm(t)});return oe(n,e),n},setItem:function(t,e,r){var n=this;t=ae(t);var o=this.ready().then(function(){void 0===e&&(e=null);var r=e;return new Promise(function(o,i){n._dbInfo.serializer.serialize(e,function(e,s){if(s)i(s);else try{n._dbInfo.mStore.set(t,e),o(r)}catch(t){i(t)}})})});return oe(o,r),o}});function de(t,e){return t===e||t!=t&&e!=e}function ve(t,e){for(var r=t.length;r--;)if(de(t[r][0],e))return r;return-1}var pe=Array.prototype.splice;function ye(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ye.prototype.clear=function(){this.__data__=[],this.size=0},ye.prototype.delete=function(t){var e=this.__data__,r=ve(e,t);return!(r<0)&&(r==e.length-1?e.pop():pe.call(e,r,1),--this.size,!0)},ye.prototype.get=function(t){var e=this.__data__,r=ve(e,t);return r<0?void 0:e[r][1]},ye.prototype.has=function(t){return ve(this.__data__,t)>-1},ye.prototype.set=function(t,e){var r=this.__data__,n=ve(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var be=R(Object,"create");var ge=Object.prototype.hasOwnProperty;var me=Object.prototype.hasOwnProperty;function _e(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function we(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function je(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}_e.prototype.clear=function(){this.__data__=be?be(null):{},this.size=0},_e.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},_e.prototype.get=function(t){var e=this.__data__;if(be){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return ge.call(e,t)?e[t]:void 0},_e.prototype.has=function(t){var e=this.__data__;return be?void 0!==e[t]:me.call(e,t)},_e.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=be&&void 0===e?"__lodash_hash_undefined__":e,this},je.prototype.clear=function(){this.size=0,this.__data__={hash:new _e,map:new(z||ye),string:new _e}},je.prototype.delete=function(t){var e=we(this,t).delete(t);return this.size-=e?1:0,e},je.prototype.get=function(t){return we(this,t).get(t)},je.prototype.has=function(t){return we(this,t).has(t)},je.prototype.set=function(t,e){var r=we(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function Ie(t){var e=this.__data__=new ye(t);this.size=e.size}Ie.prototype.clear=function(){this.__data__=new ye,this.size=0},Ie.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Ie.prototype.get=function(t){return this.__data__.get(t)},Ie.prototype.has=function(t){return this.__data__.has(t)},Ie.prototype.set=function(t,e){var r=this.__data__;if(r instanceof ye){var n=r.__data__;if(!z||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new je(n)}return r.set(t,e),this.size=r.size,this};var Se=function(){try{var t=R(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Oe(t,e,r){"__proto__"==e&&Se?Se(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Ae=Object.prototype.hasOwnProperty;function xe(t,e,r){var n=t[e];Ae.call(t,e)&&de(n,r)&&(void 0!==r||e in t)||Oe(t,e,r)}function Ee(t,e,r,n){var o=!r;r||(r={});for(var i=-1,s=e.length;++i<s;){var a=e[i],u=void 0;void 0===u&&(u=t[a]),o?Oe(r,a,u):xe(r,a,u)}return r}var Ne=Object.prototype.hasOwnProperty;function ke(t){if(!g(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=r(t),n=[];for(var o in t)("constructor"!=o||!e&&Ne.call(t,o))&&n.push(o);return n}function Be(t){return nt(t)?wt(t,!0):ke(t)}var Re="object"==typeof t&&t&&!t.nodeType&&t,Pe=Re&&"object"==typeof module&&module&&!module.nodeType&&module,ze=Pe&&Pe.exports===Re?c.Buffer:void 0,De=ze?ze.allocUnsafe:void 0;function Te(t,e){if(e)return t.slice();var r=t.length,n=De?De(r):new t.constructor(r);return t.copy(n),n}function Ce(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}function Me(){return[]}var Fe=Object.prototype.propertyIsEnumerable,Ue=Object.getOwnPropertySymbols,Le=Ue?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var s=t[r];e(s,r,t)&&(i[o++]=s)}return i}(Ue(t),function(e){return Fe.call(t,e)}))}:Me;function qe(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}var We=n(Object.getPrototypeOf,Object),Je=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)qe(e,Le(t)),t=We(t);return e}:Me;function Ke(t,e,r){var n=e(t);return et(t)?n:qe(n,r(t))}function Ve(t){return Ke(t,jt,Le)}function Qe(t){return Ke(t,Be,Je)}var Ge=Object.prototype.hasOwnProperty;var He=c.Uint8Array;function $e(t){var e=new t.constructor(t.byteLength);return new He(e).set(new He(t)),e}var Xe=/\w*$/;var Ye=l?l.prototype:void 0,Ze=Ye?Ye.valueOf:void 0;function tr(t,e){var r=e?$e(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function er(t,e,r){var n,o=t.constructor;switch(e){case"[object ArrayBuffer]":return $e(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return function(t,e){var r=e?$e(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return tr(t,r);case"[object Map]":case"[object Set]":return new o;case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,Xe.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return n=t,Ze?Object(Ze.call(n)):{}}}var rr=Object.create,nr=function(){function t(){}return function(e){if(!g(e))return{};if(rr)return rr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function or(t){return"function"!=typeof t.constructor||r(t)?{}:nr(We(t))}var ir=dt&&dt.isMap,sr=ir?ct(ir):function(t){return H(t)&&"[object Map]"==G(t)};var ar=dt&&dt.isSet,ur=ar?ct(ar):function(t){return H(t)&&"[object Set]"==G(t)},cr="[object Arguments]",lr="[object Function]",fr="[object Object]",hr={};function dr(t,e,r,n,o,i){var s,a=1&e,u=2&e,c=4&e;if(r&&(s=o?r(t,n,o,i):r(t)),void 0!==s)return s;if(!g(t))return t;var l=et(t);if(l){if(s=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&Ge.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!a)return Ce(t,s)}else{var f=G(t),h=f==lr||"[object GeneratorFunction]"==f;if(at(t))return Te(t,a);if(f==fr||f==cr||h&&!o){if(s=u||h?{}:or(t),!a)return u?function(t,e){return Ee(t,Je(t),e)}(t,function(t,e){return t&&Ee(e,Be(e),t)}(s,t)):function(t,e){return Ee(t,Le(t),e)}(t,function(t,e){return t&&Ee(e,jt(e),t)}(s,t))}else{if(!hr[f])return o?t:{};s=er(t,f,a)}}i||(i=new Ie);var d=i.get(t);if(d)return d;i.set(t,s),ur(t)?t.forEach(function(n){s.add(dr(n,e,r,n,t,i))}):sr(t)&&t.forEach(function(n,o){s.set(o,dr(n,e,r,o,t,i))});var v=l?void 0:(c?u?Qe:Ve:u?Be:jt)(t);return function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););}(v||t,function(n,o){v&&(n=t[o=n]),xe(s,o,dr(n,e,r,o,t,i))}),s}hr[cr]=hr["[object Array]"]=hr["[object ArrayBuffer]"]=hr["[object DataView]"]=hr["[object Boolean]"]=hr["[object Date]"]=hr["[object Float32Array]"]=hr["[object Float64Array]"]=hr["[object Int8Array]"]=hr["[object Int16Array]"]=hr["[object Int32Array]"]=hr["[object Map]"]=hr["[object Number]"]=hr[fr]=hr["[object RegExp]"]=hr["[object Set]"]=hr["[object String]"]=hr["[object Symbol]"]=hr["[object Uint8Array]"]=hr["[object Uint8ClampedArray]"]=hr["[object Uint16Array]"]=hr["[object Uint32Array]"]=!0,hr["[object Error]"]=hr[lr]=hr["[object WeakMap]"]=!1;function vr(t){return"string"==typeof t||!et(t)&&H(t)&&"[object String]"==b(t)}var pr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function yr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function br(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var gr,mr={exports:{}};
/*!
localForage -- Offline Storage, Improved
Version 1.10.0
https://localforage.github.io/localForage
(c) 2013-2017 Mozilla, Apache License 2.0
*/function _r(){return gr||(gr=1,function(t){t.exports=function t(e,r,n){function o(s,a){if(!r[s]){if(!e[s]){if(!a&&br)return br(s);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var c=r[s]={exports:{}};e[s][0].call(c.exports,function(t){var r=e[s][1][t];return o(r||t)},c,c.exports,t,e,r,n)}return r[s].exports}for(var i=br,s=0;s<n.length;s++)o(n[s]);return o}({1:[function(t,e,r){(function(t){var r,n,o=t.MutationObserver||t.WebKitMutationObserver;if(o){var i=0,s=new o(l),a=t.document.createTextNode("");s.observe(a,{characterData:!0}),r=function(){a.data=i=++i%2}}else if(t.setImmediate||void 0===t.MessageChannel)r="document"in t&&"onreadystatechange"in t.document.createElement("script")?function(){var e=t.document.createElement("script");e.onreadystatechange=function(){l(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},t.document.documentElement.appendChild(e)}:function(){setTimeout(l,0)};else{var u=new t.MessageChannel;u.port1.onmessage=l,r=function(){u.port2.postMessage(0)}}var c=[];function l(){var t,e;n=!0;for(var r=c.length;r;){for(e=c,c=[],t=-1;++t<r;)e[t]();r=c.length}n=!1}function f(t){1!==c.push(t)||n||r()}e.exports=f}).call(this,void 0!==pr?pr:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(t,e,r){var n=t(1);function o(){}var i={},s=["REJECTED"],a=["FULFILLED"],u=["PENDING"];function c(t){if("function"!=typeof t)throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,t!==o&&d(this,t)}function l(t,e,r){this.promise=t,"function"==typeof e&&(this.onFulfilled=e,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function f(t,e,r){n(function(){var n;try{n=e(r)}catch(e){return i.reject(t,e)}n===t?i.reject(t,new TypeError("Cannot resolve promise with itself")):i.resolve(t,n)})}function h(t){var e=t&&t.then;if(t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof e)return function(){e.apply(t,arguments)}}function d(t,e){var r=!1;function n(e){r||(r=!0,i.reject(t,e))}function o(e){r||(r=!0,i.resolve(t,e))}function s(){e(o,n)}var a=v(s);"error"===a.status&&n(a.value)}function v(t,e){var r={};try{r.value=t(e),r.status="success"}catch(t){r.status="error",r.value=t}return r}function p(t){return t instanceof this?t:i.resolve(new this(o),t)}function y(t){var e=new this(o);return i.reject(e,t)}function b(t){var e=this;if("[object Array]"!==Object.prototype.toString.call(t))return this.reject(new TypeError("must be an array"));var r=t.length,n=!1;if(!r)return this.resolve([]);for(var s=new Array(r),a=0,u=-1,c=new this(o);++u<r;)l(t[u],u);return c;function l(t,o){function u(t){s[o]=t,++a!==r||n||(n=!0,i.resolve(c,s))}e.resolve(t).then(u,function(t){n||(n=!0,i.reject(c,t))})}}function g(t){var e=this;if("[object Array]"!==Object.prototype.toString.call(t))return this.reject(new TypeError("must be an array"));var r=t.length,n=!1;if(!r)return this.resolve([]);for(var s=-1,a=new this(o);++s<r;)u(t[s]);return a;function u(t){e.resolve(t).then(function(t){n||(n=!0,i.resolve(a,t))},function(t){n||(n=!0,i.reject(a,t))})}}e.exports=c,c.prototype.catch=function(t){return this.then(null,t)},c.prototype.then=function(t,e){if("function"!=typeof t&&this.state===a||"function"!=typeof e&&this.state===s)return this;var r=new this.constructor(o);return this.state!==u?f(r,this.state===a?t:e,this.outcome):this.queue.push(new l(r,t,e)),r},l.prototype.callFulfilled=function(t){i.resolve(this.promise,t)},l.prototype.otherCallFulfilled=function(t){f(this.promise,this.onFulfilled,t)},l.prototype.callRejected=function(t){i.reject(this.promise,t)},l.prototype.otherCallRejected=function(t){f(this.promise,this.onRejected,t)},i.resolve=function(t,e){var r=v(h,e);if("error"===r.status)return i.reject(t,r.value);var n=r.value;if(n)d(t,n);else{t.state=a,t.outcome=e;for(var o=-1,s=t.queue.length;++o<s;)t.queue[o].callFulfilled(e)}return t},i.reject=function(t,e){t.state=s,t.outcome=e;for(var r=-1,n=t.queue.length;++r<n;)t.queue[r].callRejected(e);return t},c.resolve=p,c.reject=y,c.all=b,c.race=g},{1:1}],3:[function(t,e,r){(function(e){"function"!=typeof e.Promise&&(e.Promise=t(2))}).call(this,void 0!==pr?pr:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(t){return}}var s=i();function a(){try{if(!s||!s.open)return!1;var t="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),e="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!t||e)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(t){return!1}}function u(t,e){t=t||[],e=e||{};try{return new Blob(t,e)}catch(o){if("TypeError"!==o.name)throw o;for(var r=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),n=0;n<t.length;n+=1)r.append(t[n]);return r.getBlob(e.type)}}"undefined"==typeof Promise&&t(3);var c=Promise;function l(t,e){e&&t.then(function(t){e(null,t)},function(t){e(t)})}function f(t,e,r){"function"==typeof e&&t.then(e),"function"==typeof r&&t.catch(r)}function h(t){return"string"!=typeof t&&(console.warn(t+" used as a key, but it is not a string."),t=String(t)),t}function d(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var v="local-forage-detect-blob-support",p=void 0,y={},b=Object.prototype.toString,g="readonly",m="readwrite";function _(t){for(var e=t.length,r=new ArrayBuffer(e),n=new Uint8Array(r),o=0;o<e;o++)n[o]=t.charCodeAt(o);return r}function w(t){return new c(function(e){var r=t.transaction(v,m),n=u([""]);r.objectStore(v).put(n,"key"),r.onabort=function(t){t.preventDefault(),t.stopPropagation(),e(!1)},r.oncomplete=function(){var t=navigator.userAgent.match(/Chrome\/(\d+)/),r=navigator.userAgent.match(/Edge\//);e(r||!t||parseInt(t[1],10)>=43)}}).catch(function(){return!1})}function j(t){return"boolean"==typeof p?c.resolve(p):w(t).then(function(t){return p=t})}function I(t){var e=y[t.name],r={};r.promise=new c(function(t,e){r.resolve=t,r.reject=e}),e.deferredOperations.push(r),e.dbReady?e.dbReady=e.dbReady.then(function(){return r.promise}):e.dbReady=r.promise}function S(t){var e=y[t.name].deferredOperations.pop();if(e)return e.resolve(),e.promise}function O(t,e){var r=y[t.name].deferredOperations.pop();if(r)return r.reject(e),r.promise}function A(t,e){return new c(function(r,n){if(y[t.name]=y[t.name]||T(),t.db){if(!e)return r(t.db);I(t),t.db.close()}var o=[t.name];e&&o.push(t.version);var i=s.open.apply(s,o);e&&(i.onupgradeneeded=function(e){var r=i.result;try{r.createObjectStore(t.storeName),e.oldVersion<=1&&r.createObjectStore(v)}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+t.name+'" has been upgraded from version '+e.oldVersion+" to version "+e.newVersion+', but the storage "'+t.storeName+'" already exists.')}}),i.onerror=function(t){t.preventDefault(),n(i.error)},i.onsuccess=function(){var e=i.result;e.onversionchange=function(t){t.target.close()},r(e),S(t)}})}function x(t){return A(t,!1)}function E(t){return A(t,!0)}function N(t,e){if(!t.db)return!0;var r=!t.db.objectStoreNames.contains(t.storeName),n=t.version<t.db.version,o=t.version>t.db.version;if(n&&(t.version!==e&&console.warn('The database "'+t.name+"\" can't be downgraded from version "+t.db.version+" to version "+t.version+"."),t.version=t.db.version),o||r){if(r){var i=t.db.version+1;i>t.version&&(t.version=i)}return!0}return!1}function k(t){return new c(function(e,r){var n=new FileReader;n.onerror=r,n.onloadend=function(r){var n=btoa(r.target.result||"");e({__local_forage_encoded_blob:!0,data:n,type:t.type})},n.readAsBinaryString(t)})}function B(t){return u([_(atob(t.data))],{type:t.type})}function R(t){return t&&t.__local_forage_encoded_blob}function P(t){var e=this,r=e._initReady().then(function(){var t=y[e._dbInfo.name];if(t&&t.dbReady)return t.dbReady});return f(r,t,t),r}function z(t){I(t);for(var e=y[t.name],r=e.forages,n=0;n<r.length;n++){var o=r[n];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return t.db=null,x(t).then(function(e){return t.db=e,N(t)?E(t):e}).then(function(n){t.db=e.db=n;for(var o=0;o<r.length;o++)r[o]._dbInfo.db=n}).catch(function(e){throw O(t,e),e})}function D(t,e,r,n){void 0===n&&(n=1);try{var o=t.db.transaction(t.storeName,e);r(null,o)}catch(o){if(n>0&&(!t.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return c.resolve().then(function(){if(!t.db||"NotFoundError"===o.name&&!t.db.objectStoreNames.contains(t.storeName)&&t.version<=t.db.version)return t.db&&(t.version=t.db.version+1),E(t)}).then(function(){return z(t).then(function(){D(t,e,r,n-1)})}).catch(r);r(o)}}function T(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function C(t){var e=this,r={db:null};if(t)for(var n in t)r[n]=t[n];var o=y[r.name];o||(o=T(),y[r.name]=o),o.forages.push(e),e._initReady||(e._initReady=e.ready,e.ready=P);var i=[];function s(){return c.resolve()}for(var a=0;a<o.forages.length;a++){var u=o.forages[a];u!==e&&i.push(u._initReady().catch(s))}var l=o.forages.slice(0);return c.all(i).then(function(){return r.db=o.db,x(r)}).then(function(t){return r.db=t,N(r,e._defaultConfig.version)?E(r):t}).then(function(t){r.db=o.db=t,e._dbInfo=r;for(var n=0;n<l.length;n++){var i=l[n];i!==e&&(i._dbInfo.db=r.db,i._dbInfo.version=r.version)}})}function M(t,e){var r=this;t=h(t);var n=new c(function(e,n){r.ready().then(function(){D(r._dbInfo,g,function(o,i){if(o)return n(o);try{var s=i.objectStore(r._dbInfo.storeName).get(t);s.onsuccess=function(){var t=s.result;void 0===t&&(t=null),R(t)&&(t=B(t)),e(t)},s.onerror=function(){n(s.error)}}catch(t){n(t)}})}).catch(n)});return l(n,e),n}function F(t,e){var r=this,n=new c(function(e,n){r.ready().then(function(){D(r._dbInfo,g,function(o,i){if(o)return n(o);try{var s=i.objectStore(r._dbInfo.storeName).openCursor(),a=1;s.onsuccess=function(){var r=s.result;if(r){var n=r.value;R(n)&&(n=B(n));var o=t(n,r.key,a++);void 0!==o?e(o):r.continue()}else e()},s.onerror=function(){n(s.error)}}catch(t){n(t)}})}).catch(n)});return l(n,e),n}function U(t,e,r){var n=this;t=h(t);var o=new c(function(r,o){var i;n.ready().then(function(){return i=n._dbInfo,"[object Blob]"===b.call(e)?j(i.db).then(function(t){return t?e:k(e)}):e}).then(function(e){D(n._dbInfo,m,function(i,s){if(i)return o(i);try{var a=s.objectStore(n._dbInfo.storeName);null===e&&(e=void 0);var u=a.put(e,t);s.oncomplete=function(){void 0===e&&(e=null),r(e)},s.onabort=s.onerror=function(){var t=u.error?u.error:u.transaction.error;o(t)}}catch(t){o(t)}})}).catch(o)});return l(o,r),o}function L(t,e){var r=this;t=h(t);var n=new c(function(e,n){r.ready().then(function(){D(r._dbInfo,m,function(o,i){if(o)return n(o);try{var s=i.objectStore(r._dbInfo.storeName).delete(t);i.oncomplete=function(){e()},i.onerror=function(){n(s.error)},i.onabort=function(){var t=s.error?s.error:s.transaction.error;n(t)}}catch(t){n(t)}})}).catch(n)});return l(n,e),n}function q(t){var e=this,r=new c(function(t,r){e.ready().then(function(){D(e._dbInfo,m,function(n,o){if(n)return r(n);try{var i=o.objectStore(e._dbInfo.storeName).clear();o.oncomplete=function(){t()},o.onabort=o.onerror=function(){var t=i.error?i.error:i.transaction.error;r(t)}}catch(t){r(t)}})}).catch(r)});return l(r,t),r}function W(t){var e=this,r=new c(function(t,r){e.ready().then(function(){D(e._dbInfo,g,function(n,o){if(n)return r(n);try{var i=o.objectStore(e._dbInfo.storeName).count();i.onsuccess=function(){t(i.result)},i.onerror=function(){r(i.error)}}catch(t){r(t)}})}).catch(r)});return l(r,t),r}function J(t,e){var r=this,n=new c(function(e,n){t<0?e(null):r.ready().then(function(){D(r._dbInfo,g,function(o,i){if(o)return n(o);try{var s=i.objectStore(r._dbInfo.storeName),a=!1,u=s.openKeyCursor();u.onsuccess=function(){var r=u.result;r?0===t||a?e(r.key):(a=!0,r.advance(t)):e(null)},u.onerror=function(){n(u.error)}}catch(t){n(t)}})}).catch(n)});return l(n,e),n}function K(t){var e=this,r=new c(function(t,r){e.ready().then(function(){D(e._dbInfo,g,function(n,o){if(n)return r(n);try{var i=o.objectStore(e._dbInfo.storeName).openKeyCursor(),s=[];i.onsuccess=function(){var e=i.result;e?(s.push(e.key),e.continue()):t(s)},i.onerror=function(){r(i.error)}}catch(t){r(t)}})}).catch(r)});return l(r,t),r}function V(t,e){e=d.apply(this,arguments);var r=this.config();(t="function"!=typeof t&&t||{}).name||(t.name=t.name||r.name,t.storeName=t.storeName||r.storeName);var n,o=this;if(t.name){var i=t.name===r.name&&o._dbInfo.db?c.resolve(o._dbInfo.db):x(t).then(function(e){var r=y[t.name],n=r.forages;r.db=e;for(var o=0;o<n.length;o++)n[o]._dbInfo.db=e;return e});n=t.storeName?i.then(function(e){if(e.objectStoreNames.contains(t.storeName)){var r=e.version+1;I(t);var n=y[t.name],o=n.forages;e.close();for(var i=0;i<o.length;i++){var a=o[i];a._dbInfo.db=null,a._dbInfo.version=r}var u=new c(function(e,n){var o=s.open(t.name,r);o.onerror=function(t){o.result.close(),n(t)},o.onupgradeneeded=function(){o.result.deleteObjectStore(t.storeName)},o.onsuccess=function(){var t=o.result;t.close(),e(t)}});return u.then(function(t){n.db=t;for(var e=0;e<o.length;e++){var r=o[e];r._dbInfo.db=t,S(r._dbInfo)}}).catch(function(e){throw(O(t,e)||c.resolve()).catch(function(){}),e})}}):i.then(function(e){I(t);var r=y[t.name],n=r.forages;e.close();for(var o=0;o<n.length;o++)n[o]._dbInfo.db=null;var i=new c(function(e,r){var n=s.deleteDatabase(t.name);n.onerror=function(){var t=n.result;t&&t.close(),r(n.error)},n.onblocked=function(){console.warn('dropInstance blocked for database "'+t.name+'" until all open connections are closed')},n.onsuccess=function(){var t=n.result;t&&t.close(),e(t)}});return i.then(function(t){r.db=t;for(var e=0;e<n.length;e++)S(n[e]._dbInfo)}).catch(function(e){throw(O(t,e)||c.resolve()).catch(function(){}),e})})}else n=c.reject("Invalid arguments");return l(n,e),n}var Q={_driver:"asyncStorage",_initStorage:C,_support:a(),iterate:F,getItem:M,setItem:U,removeItem:L,clear:q,length:W,key:J,keys:K,dropInstance:V};function G(){return"function"==typeof openDatabase}var H="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",$="~~local_forage_type~",X=/^~~local_forage_type~([^~]+)~/,Y="__lfsc__:",Z=Y.length,tt="arbf",et="blob",rt="si08",nt="ui08",ot="uic8",it="si16",st="si32",at="ur16",ut="ui32",ct="fl32",lt="fl64",ft=Z+tt.length,ht=Object.prototype.toString;function dt(t){var e,r,n,o,i,s=.75*t.length,a=t.length,u=0;"="===t[t.length-1]&&(s--,"="===t[t.length-2]&&s--);var c=new ArrayBuffer(s),l=new Uint8Array(c);for(e=0;e<a;e+=4)r=H.indexOf(t[e]),n=H.indexOf(t[e+1]),o=H.indexOf(t[e+2]),i=H.indexOf(t[e+3]),l[u++]=r<<2|n>>4,l[u++]=(15&n)<<4|o>>2,l[u++]=(3&o)<<6|63&i;return c}function vt(t){var e,r=new Uint8Array(t),n="";for(e=0;e<r.length;e+=3)n+=H[r[e]>>2],n+=H[(3&r[e])<<4|r[e+1]>>4],n+=H[(15&r[e+1])<<2|r[e+2]>>6],n+=H[63&r[e+2]];return r.length%3==2?n=n.substring(0,n.length-1)+"=":r.length%3==1&&(n=n.substring(0,n.length-2)+"=="),n}function pt(t,e){var r="";if(t&&(r=ht.call(t)),t&&("[object ArrayBuffer]"===r||t.buffer&&"[object ArrayBuffer]"===ht.call(t.buffer))){var n,o=Y;t instanceof ArrayBuffer?(n=t,o+=tt):(n=t.buffer,"[object Int8Array]"===r?o+=rt:"[object Uint8Array]"===r?o+=nt:"[object Uint8ClampedArray]"===r?o+=ot:"[object Int16Array]"===r?o+=it:"[object Uint16Array]"===r?o+=at:"[object Int32Array]"===r?o+=st:"[object Uint32Array]"===r?o+=ut:"[object Float32Array]"===r?o+=ct:"[object Float64Array]"===r?o+=lt:e(new Error("Failed to get type for BinaryArray"))),e(o+vt(n))}else if("[object Blob]"===r){var i=new FileReader;i.onload=function(){var r=$+t.type+"~"+vt(this.result);e(Y+et+r)},i.readAsArrayBuffer(t)}else try{e(JSON.stringify(t))}catch(r){console.error("Couldn't convert value into a JSON string: ",t),e(null,r)}}function yt(t){if(t.substring(0,Z)!==Y)return JSON.parse(t);var e,r=t.substring(ft),n=t.substring(Z,ft);if(n===et&&X.test(r)){var o=r.match(X);e=o[1],r=r.substring(o[0].length)}var i=dt(r);switch(n){case tt:return i;case et:return u([i],{type:e});case rt:return new Int8Array(i);case nt:return new Uint8Array(i);case ot:return new Uint8ClampedArray(i);case it:return new Int16Array(i);case at:return new Uint16Array(i);case st:return new Int32Array(i);case ut:return new Uint32Array(i);case ct:return new Float32Array(i);case lt:return new Float64Array(i);default:throw new Error("Unkown type: "+n)}}var bt={serialize:pt,deserialize:yt,stringToBuffer:dt,bufferToString:vt};function gt(t,e,r,n){t.executeSql("CREATE TABLE IF NOT EXISTS "+e.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,n)}function mt(t){var e=this,r={db:null};if(t)for(var n in t)r[n]="string"!=typeof t[n]?t[n].toString():t[n];var o=new c(function(t,n){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(t){return n(t)}r.db.transaction(function(o){gt(o,r,function(){e._dbInfo=r,t()},function(t,e){n(e)})},n)});return r.serializer=bt,o}function _t(t,e,r,n,o,i){t.executeSql(r,n,o,function(t,s){s.code===s.SYNTAX_ERR?t.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[e.storeName],function(t,a){a.rows.length?i(t,s):gt(t,e,function(){t.executeSql(r,n,o,i)},i)},i):i(t,s)},i)}function wt(t,e){var r=this;t=h(t);var n=new c(function(e,n){r.ready().then(function(){var o=r._dbInfo;o.db.transaction(function(r){_t(r,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[t],function(t,r){var n=r.rows.length?r.rows.item(0).value:null;n&&(n=o.serializer.deserialize(n)),e(n)},function(t,e){n(e)})})}).catch(n)});return l(n,e),n}function jt(t,e){var r=this,n=new c(function(e,n){r.ready().then(function(){var o=r._dbInfo;o.db.transaction(function(r){_t(r,o,"SELECT * FROM "+o.storeName,[],function(r,n){for(var i=n.rows,s=i.length,a=0;a<s;a++){var u=i.item(a),c=u.value;if(c&&(c=o.serializer.deserialize(c)),void 0!==(c=t(c,u.key,a+1)))return void e(c)}e()},function(t,e){n(e)})})}).catch(n)});return l(n,e),n}function It(t,e,r,n){var o=this;t=h(t);var i=new c(function(i,s){o.ready().then(function(){void 0===e&&(e=null);var a=e,u=o._dbInfo;u.serializer.serialize(e,function(e,c){c?s(c):u.db.transaction(function(r){_t(r,u,"INSERT OR REPLACE INTO "+u.storeName+" (key, value) VALUES (?, ?)",[t,e],function(){i(a)},function(t,e){s(e)})},function(e){if(e.code===e.QUOTA_ERR){if(n>0)return void i(It.apply(o,[t,a,r,n-1]));s(e)}})})}).catch(s)});return l(i,r),i}function St(t,e,r){return It.apply(this,[t,e,r,1])}function Ot(t,e){var r=this;t=h(t);var n=new c(function(e,n){r.ready().then(function(){var o=r._dbInfo;o.db.transaction(function(r){_t(r,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[t],function(){e()},function(t,e){n(e)})})}).catch(n)});return l(n,e),n}function At(t){var e=this,r=new c(function(t,r){e.ready().then(function(){var n=e._dbInfo;n.db.transaction(function(e){_t(e,n,"DELETE FROM "+n.storeName,[],function(){t()},function(t,e){r(e)})})}).catch(r)});return l(r,t),r}function xt(t){var e=this,r=new c(function(t,r){e.ready().then(function(){var n=e._dbInfo;n.db.transaction(function(e){_t(e,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(e,r){var n=r.rows.item(0).c;t(n)},function(t,e){r(e)})})}).catch(r)});return l(r,t),r}function Et(t,e){var r=this,n=new c(function(e,n){r.ready().then(function(){var o=r._dbInfo;o.db.transaction(function(r){_t(r,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[t+1],function(t,r){var n=r.rows.length?r.rows.item(0).key:null;e(n)},function(t,e){n(e)})})}).catch(n)});return l(n,e),n}function Nt(t){var e=this,r=new c(function(t,r){e.ready().then(function(){var n=e._dbInfo;n.db.transaction(function(e){_t(e,n,"SELECT key FROM "+n.storeName,[],function(e,r){for(var n=[],o=0;o<r.rows.length;o++)n.push(r.rows.item(o).key);t(n)},function(t,e){r(e)})})}).catch(r)});return l(r,t),r}function kt(t){return new c(function(e,r){t.transaction(function(n){n.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(r,n){for(var o=[],i=0;i<n.rows.length;i++)o.push(n.rows.item(i).name);e({db:t,storeNames:o})},function(t,e){r(e)})},function(t){r(t)})})}function Bt(t,e){e=d.apply(this,arguments);var r=this.config();(t="function"!=typeof t&&t||{}).name||(t.name=t.name||r.name,t.storeName=t.storeName||r.storeName);var n,o=this;return l(n=t.name?new c(function(e){var n;n=t.name===r.name?o._dbInfo.db:openDatabase(t.name,"","",0),t.storeName?e({db:n,storeNames:[t.storeName]}):e(kt(n))}).then(function(t){return new c(function(e,r){t.db.transaction(function(n){function o(t){return new c(function(e,r){n.executeSql("DROP TABLE IF EXISTS "+t,[],function(){e()},function(t,e){r(e)})})}for(var i=[],s=0,a=t.storeNames.length;s<a;s++)i.push(o(t.storeNames[s]));c.all(i).then(function(){e()}).catch(function(t){r(t)})},function(t){r(t)})})}):c.reject("Invalid arguments"),e),n}var Rt={_driver:"webSQLStorage",_initStorage:mt,_support:G(),iterate:jt,getItem:wt,setItem:St,removeItem:Ot,clear:At,length:xt,key:Et,keys:Nt,dropInstance:Bt};function Pt(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(t){return!1}}function zt(t,e){var r=t.name+"/";return t.storeName!==e.storeName&&