@converse/skeletor 4.0.1 → 4.0.2
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/CHANGES.md +14 -0
- package/dist/skeletor.d.ts +19 -16
- package/dist/skeletor.esm.js +4 -19
- package/dist/skeletor.esm.js.map +1 -1
- package/dist/skeletor.js +4 -19
- package/dist/skeletor.js.map +1 -1
- package/dist/skeletor.min.js +1 -1
- package/dist/skeletor.node.d.ts +19 -16
- package/dist/skeletor.node.js +4 -19
- package/dist/skeletor.node.mjs +4 -19
- package/package.json +3 -10
- package/src/collection.ts +21 -25
- package/src/types.ts +5 -6
package/dist/skeletor.min.js
CHANGED
|
@@ -57,5 +57,5 @@ return function(t,e){t=t||[],e=e||{};try{return new Blob(t,e)}catch(o){if("TypeE
|
|
|
57
57
|
Version 1.10.0
|
|
58
58
|
https://localforage.github.io/localForage
|
|
59
59
|
(c) 2013-2017 Mozilla, Apache License 2.0
|
|
60
|
-
*/function _r(){return br||(br=1,function(t){t.exports=function t(e,r,n){function o(s,a){if(!r[s]){if(!e[s]){if(!a&&gr)return gr(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=gr,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 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=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 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=-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=g,c.race=b},{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={},g=Object.prototype.toString,b="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 S(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 I(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]||z(),t.db){if(!e)return r(t.db);S(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),I(t)}})}function E(t){return A(t,!1)}function x(t){return A(t,!0)}function k(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 N(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 P(t){return u([_(atob(t.data))],{type:t.type})}function R(t){return t&&t.__local_forage_encoded_blob}function T(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 B(t){S(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,E(t).then(function(e){return t.db=e,k(t)?x(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),x(t)}).then(function(){return B(t).then(function(){D(t,e,r,n-1)})}).catch(r);r(o)}}function z(){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=z(),y[r.name]=o),o.forages.push(e),e._initReady||(e._initReady=e.ready,e.ready=T);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,E(r)}).then(function(t){return r.db=t,k(r,e._defaultConfig.version)?x(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,b,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=P(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,b,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=P(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 L(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]"===g.call(e)?j(i.db).then(function(t){return t?e:N(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 U(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 W(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 q(t){var e=this,r=new c(function(t,r){e.ready().then(function(){D(e._dbInfo,b,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,b,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 $(t){var e=this,r=new c(function(t,r){e.ready().then(function(){D(e._dbInfo,b,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 K(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):E(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;S(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,I(r._dbInfo)}}).catch(function(e){throw(O(t,e)||c.resolve()).catch(function(){}),e})}}):i.then(function(e){S(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++)I(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 H={_driver:"asyncStorage",_initStorage:C,_support:a(),iterate:F,getItem:M,setItem:L,removeItem:U,clear:W,length:q,key:J,keys:$,dropInstance:K};function V(){return"function"==typeof openDatabase}var G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Q="~~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=G.indexOf(t[e]),n=G.indexOf(t[e+1]),o=G.indexOf(t[e+2]),i=G.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+=G[r[e]>>2],n+=G[(3&r[e])<<4|r[e+1]>>4],n+=G[(15&r[e+1])<<2|r[e+2]>>6],n+=G[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=Q+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 gt={serialize:pt,deserialize:yt,stringToBuffer:dt,bufferToString:vt};function bt(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){bt(o,r,function(){e._dbInfo=r,t()},function(t,e){n(e)})},n)});return r.serializer=gt,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):bt(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 St(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(St.apply(o,[t,a,r,n-1]));s(e)}})})}).catch(s)});return l(i,r),i}function It(t,e,r){return St.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 Et(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 xt(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 kt(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 Nt(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 Pt(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(Nt(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:V(),iterate:jt,getItem:wt,setItem:It,removeItem:Ot,clear:At,length:Et,key:xt,keys:kt,dropInstance:Pt};function Tt(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(t){return!1}}function Bt(t,e){var r=t.name+"/";return t.storeName!==e.storeName&&(r+=t.storeName+"/"),r}function Dt(){var t="_localforage_support_test";try{return localStorage.setItem(t,!0),localStorage.removeItem(t),!1}catch(t){return!0}}function zt(){return!Dt()||localStorage.length>0}function Ct(t){var e=this,r={};if(t)for(var n in t)r[n]=t[n];return r.keyPrefix=Bt(t,e._defaultConfig),zt()?(e._dbInfo=r,r.serializer=gt,c.resolve()):c.reject()}function Mt(t){var e=this,r=e.ready().then(function(){for(var t=e._dbInfo.keyPrefix,r=localStorage.length-1;r>=0;r--){var n=localStorage.key(r);0===n.indexOf(t)&&localStorage.removeItem(n)}});return l(r,t),r}function Ft(t,e){var r=this;t=h(t);var n=r.ready().then(function(){var e=r._dbInfo,n=localStorage.getItem(e.keyPrefix+t);return n&&(n=e.serializer.deserialize(n)),n});return l(n,e),n}function Lt(t,e){var r=this,n=r.ready().then(function(){for(var e=r._dbInfo,n=e.keyPrefix,o=n.length,i=localStorage.length,s=1,a=0;a<i;a++){var u=localStorage.key(a);if(0===u.indexOf(n)){var c=localStorage.getItem(u);if(c&&(c=e.serializer.deserialize(c)),void 0!==(c=t(c,u.substring(o),s++)))return c}}});return l(n,e),n}function Ut(t,e){var r=this,n=r.ready().then(function(){var e,n=r._dbInfo;try{e=localStorage.key(t)}catch(t){e=null}return e&&(e=e.substring(n.keyPrefix.length)),e});return l(n,e),n}function Wt(t){var e=this,r=e.ready().then(function(){for(var t=e._dbInfo,r=localStorage.length,n=[],o=0;o<r;o++){var i=localStorage.key(o);0===i.indexOf(t.keyPrefix)&&n.push(i.substring(t.keyPrefix.length))}return n});return l(r,t),r}function qt(t){var e=this.keys().then(function(t){return t.length});return l(e,t),e}function Jt(t,e){var r=this;t=h(t);var n=r.ready().then(function(){var e=r._dbInfo;localStorage.removeItem(e.keyPrefix+t)});return l(n,e),n}function $t(t,e,r){var n=this;t=h(t);var o=n.ready().then(function(){void 0===e&&(e=null);var r=e;return new c(function(o,i){var s=n._dbInfo;s.serializer.serialize(e,function(e,n){if(n)i(n);else try{localStorage.setItem(s.keyPrefix+t,e),o(r)}catch(t){"QuotaExceededError"!==t.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==t.name||i(t),i(t)}})})});return l(o,r),o}function Kt(t,e){if(e=d.apply(this,arguments),!(t="function"!=typeof t&&t||{}).name){var r=this.config();t.name=t.name||r.name,t.storeName=t.storeName||r.storeName}var n,o=this;return n=t.name?new c(function(e){t.storeName?e(Bt(t,o._defaultConfig)):e(t.name+"/")}).then(function(t){for(var e=localStorage.length-1;e>=0;e--){var r=localStorage.key(e);0===r.indexOf(t)&&localStorage.removeItem(r)}}):c.reject("Invalid arguments"),l(n,e),n}var Ht={_driver:"localStorageWrapper",_initStorage:Ct,_support:Tt(),iterate:Lt,getItem:Ft,setItem:$t,removeItem:Jt,clear:Mt,length:qt,key:Ut,keys:Wt,dropInstance:Kt},Vt=function(t,e){return t===e||"number"==typeof t&&"number"==typeof e&&isNaN(t)&&isNaN(e)},Gt=function(t,e){for(var r=t.length,n=0;n<r;){if(Vt(t[n],e))return!0;n++}return!1},Qt=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},Xt={},Yt={},Zt={INDEXEDDB:H,WEBSQL:Rt,LOCALSTORAGE:Ht},te=[Zt.INDEXEDDB._driver,Zt.WEBSQL._driver,Zt.LOCALSTORAGE._driver],ee=["dropInstance"],re=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ee),ne={description:"",driver:te.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function oe(t,e){t[e]=function(){var r=arguments;return t.ready().then(function(){return t[e].apply(t,r)})}}function ie(){for(var t=1;t<arguments.length;t++){var e=arguments[t];if(e)for(var r in e)e.hasOwnProperty(r)&&(Qt(e[r])?arguments[0][r]=e[r].slice():arguments[0][r]=e[r])}return arguments[0]}var se=function(){function t(e){for(var r in o(this,t),Zt)if(Zt.hasOwnProperty(r)){var n=Zt[r],i=n._driver;this[r]=i,Xt[i]||this.defineDriver(n)}this._defaultConfig=ie({},ne),this._config=ie({},this._defaultConfig,e),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return t.prototype.config=function(t){if("object"===(void 0===t?"undefined":n(t))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var e in t){if("storeName"===e&&(t[e]=t[e].replace(/\W/g,"_")),"version"===e&&"number"!=typeof t[e])return new Error("Database version must be a number.");this._config[e]=t[e]}return!("driver"in t)||!t.driver||this.setDriver(this._config.driver)}return"string"==typeof t?this._config[t]:this._config},t.prototype.defineDriver=function(t,e,r){var n=new c(function(e,r){try{var n=t._driver,o=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver)return void r(o);for(var i=re.concat("_initStorage"),s=0,a=i.length;s<a;s++){var u=i[s];if((!Gt(ee,u)||t[u])&&"function"!=typeof t[u])return void r(o)}var f=function(){for(var e=function(t){return function(){var e=new Error("Method "+t+" is not implemented by the current driver"),r=c.reject(e);return l(r,arguments[arguments.length-1]),r}},r=0,n=ee.length;r<n;r++){var o=ee[r];t[o]||(t[o]=e(o))}};f();var h=function(r){Xt[n]&&console.info("Redefining LocalForage driver: "+n),Xt[n]=t,Yt[n]=r,e()};"_support"in t?t._support&&"function"==typeof t._support?t._support().then(h,r):h(!!t._support):h(!0)}catch(t){r(t)}});return f(n,e,r),n},t.prototype.driver=function(){return this._driver||null},t.prototype.getDriver=function(t,e,r){var n=Xt[t]?c.resolve(Xt[t]):c.reject(new Error("Driver not found."));return f(n,e,r),n},t.prototype.getSerializer=function(t){var e=c.resolve(gt);return f(e,t),e},t.prototype.ready=function(t){var e=this,r=e._driverSet.then(function(){return null===e._ready&&(e._ready=e._initDriver()),e._ready});return f(r,t,t),r},t.prototype.setDriver=function(t,e,r){var n=this;Qt(t)||(t=[t]);var o=this._getSupportedDrivers(t);function i(){n._config.driver=n.driver()}function s(t){return n._extend(t),i(),n._ready=n._initStorage(n._config),n._ready}function a(t){return function(){var e=0;function r(){for(;e<t.length;){var o=t[e];return e++,n._dbInfo=null,n._ready=null,n.getDriver(o).then(s).catch(r)}i();var a=new Error("No available storage method found.");return n._driverSet=c.reject(a),n._driverSet}return r()}}var u=null!==this._driverSet?this._driverSet.catch(function(){return c.resolve()}):c.resolve();return this._driverSet=u.then(function(){var t=o[0];return n._dbInfo=null,n._ready=null,n.getDriver(t).then(function(t){n._driver=t._driver,i(),n._wrapLibraryMethodsWithReady(),n._initDriver=a(o)})}).catch(function(){i();var t=new Error("No available storage method found.");return n._driverSet=c.reject(t),n._driverSet}),f(this._driverSet,e,r),this._driverSet},t.prototype.supports=function(t){return!!Yt[t]},t.prototype._extend=function(t){ie(this,t)},t.prototype._getSupportedDrivers=function(t){for(var e=[],r=0,n=t.length;r<n;r++){var o=t[r];this.supports(o)&&e.push(o)}return e},t.prototype._wrapLibraryMethodsWithReady=function(){for(var t=0,e=re.length;t<e;t++)oe(this,re[t])},t.prototype.createInstance=function(e){return new t(e)},t}(),ae=new se;e.exports=ae},{3:3}]},{},[4])(4)}(mr)),mr.exports}var wr=yr(_r());function jr(t,e,r){(void 0!==r&&!de(t[e],r)||void 0===r&&!(e in t))&&Oe(t,e,r)}var Sr=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),s=i.length;s--;){var a=i[++n];if(!1===e(o[a],a,o))break}return t};var Ir=Function.prototype,Or=Object.prototype,Ar=Ir.toString,Er=Or.hasOwnProperty,xr=Ar.call(Object);function kr(t){if(!G(t)||"[object Object]"!=g(t))return!1;var e=qe(t);if(null===e)return!0;var r=Er.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Ar.call(r)==xr}function Nr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Pr(t,e,r,n,o,i,s){var a=Nr(t,r),u=Nr(e,r),c=s.get(u);if(c)jr(t,r,c);else{var l,f=i?i(a,u,r+"",t,e,s):void 0,h=void 0===f;if(h){var d=et(u),v=!d&&at(u),p=!d&&!v&&pt(u);f=u,d||v||p?et(a)?f=a:G(l=a)&&nt(l)?f=Ce(a):v?(h=!1,f=ze(u,!0)):p?(h=!1,f=tr(u,!0)):f=[]:kr(u)||tt(u)?(f=a,tt(a)?f=function(t){return xe(t,Pe(t))}(a):b(a)&&!m(a)||(f=or(u))):h=!1}h&&(s.set(u,f),o(f,u,n,i,s),s.delete(u)),jr(t,r,f)}}function Rr(t,e,r,n,o){t!==e&&Sr(e,function(i,s){if(o||(o=new Se),b(i))Pr(t,e,s,r,Rr,n,o);else{var a=n?n(Nr(t,s),i,s+"",t,e,o):void 0;void 0===a&&(a=i),jr(t,s,a)}},Pe)}function Tr(t){return t}var Br=Math.max;function Dr(t,e,r){return e=Br(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Br(n.length-e,0),s=Array(i);++o<i;)s[o]=n[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=n[o];return a[e]=r(s),function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,a)}}function zr(t){return function(){return t}}var Cr=Ie?function(t,e){return Ie(t,"toString",{configurable:!0,enumerable:!1,value:zr(e),writable:!0})}:Tr,Mr=Date.now;var Fr,Lr,Ur,Wr=(Fr=Cr,Lr=0,Ur=0,function(){var t=Mr(),e=16-(t-Ur);if(Ur=t,e>0){if(++Lr>=800)return arguments[0]}else Lr=0;return Fr.apply(void 0,arguments)});function qr(t,e){return Wr(Dr(t,e,Tr),t+"")}function Jr(t,e,r){if(!b(r))return!1;var n=typeof e;return!!("number"==n?nt(r)&&mt(e,r.length):"string"==n&&e in r)&&de(r[e],t)}function $r(t){return qr(function(e,r){var n=-1,o=r.length,i=o>1?r[o-1]:void 0,s=o>2?r[2]:void 0;for(i=t.length>3&&"function"==typeof i?(o--,i):void 0,s&&Jr(r[0],r[1],s)&&(i=o<3?void 0:i,o=1),e=Object(e);++n<o;){var a=r[n];a&&t(e,a,n,i)}return e})}var Kr=$r(function(t,e,r){Rr(t,e,r)}),Hr=$r(function(t,e,r,n){Rr(t,e,r,n)});function Vr(){let t,e=()=>{},r=()=>{};if("function"==typeof Promise.withResolvers){const{promise:n,resolve:o,reject:i}=Promise.withResolvers();t=n,e=o,r=i}else t=new Promise((t,n)=>{e=t,r=n});return Object.assign(t,{isResolved:!1,isPending:!0,isRejected:!1,resolve:e,reject:r}),t.then(e=>(t.isResolved=!0,t.isPending=!1,t.isRejected=!1,e),e=>{throw t.isResolved=!1,t.isPending=!1,t.isRejected=!0,e}),t}const Gr=Math.max,Qr=Math.min;function Xr(t){if("number"==typeof t)return t;if("string"==typeof t){const e=parseFloat(t);return isNaN(e)?0:e}return 0}function Yr(t,e,r={}){let n,o,i,s,a,u,c=0,l=!1,f=r.promise?Vr():null;if("function"!=typeof t)throw new TypeError("Expected a function");function h(e){const i=n,a=o,u=f;return n=o=void 0,c=e,s=t.apply(a,i),r.promise&&(u.resolve(s),f=Vr()),r.promise?u:s}function d(t){const r=t-u;return void 0===u||r>=e||r<0||l&&t-c>=i}function v(){const t=Date.now();if(d(t))return p(t);a=setTimeout(v,function(t){const r=e-(t-u);return l?Qr(r,i-(t-c)):r}(t))}function p(t){return a=void 0,n?h(t):(n=o=void 0,r.promise?f:s)}function y(t,e){if(Array.isArray(t)&&Array.isArray(e))return r?.dedupeArrays?t.concat(e.filter(e=>-1===t.indexOf(e))):t.concat(e)}function g(){const t=Date.now(),i=d(t);var p;if(p=Array.from(arguments),n=n?.length?p.length?r?.concatArrays||r?.dedupeArrays?Hr(n,p,y):Kr(n,p):n:p||[],o=this,u=t,i){if(void 0===a)return function(t){return c=t,a=setTimeout(v,e),r.promise?f:s}(u);if(l)return clearTimeout(a),a=setTimeout(v,e),h(u)}return void 0===a&&(a=setTimeout(v,e)),r.promise?f:s}return e=Xr(e)||0,function(t){const e=typeof t;return null!=t&&("object"===e||"function"===e)}(r)&&(l="maxWait"in r,i=l?Gr(Xr(r.maxWait)||0,e):i),g.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=u=o=a=void 0},g.flush=function(){return void 0===a?s:p(Date.now())},g}function Zr(t,e){e&&t.then(t=>e(null,t),t=>e(t))}function tn(t){return"string"!=typeof t&&(console.warn(`${t} used as a key, but it is not a string.`),t=String(t)),t}function en(t,e){let r=t.name+"/";return t.storeName!==e.storeName&&(r+=t.storeName+"/"),r}const rn={keyPrefix:"",serializer:{serialize:function(t,e){try{e(function(t){return JSON.stringify(t,(t,e)=>e instanceof Date?e.toISOString():e)}(t),null)}catch(t){e("",t)}},deserialize:function(t){return JSON.parse(t)}}};const nn={_driver:"sessionStorageWrapper",_initStorage:function(t){if(rn.keyPrefix=en(t,this._defaultConfig),t)for(const e in t)rn[e]=t[e]},_support:function(){try{if(sessionStorage&&"setItem"in sessionStorage)return!0}catch(t){console.log(t)}return!1}(),iterate:function(t,e){const r=this.ready().then(function(){const e=rn.keyPrefix,r=e.length,n=sessionStorage.length;let o=1;for(let i=0;i<n;i++){const n=sessionStorage.key(i);if(!n||0!==n.indexOf(e))continue;const s=sessionStorage.getItem(n),a=s?rn.serializer.deserialize(s):s,u=t(a,n.substring(r),o++);if(void 0!==u)return u}});return Zr(r,e),r},getItem:function(t,e){t=tn(t);const r=this.ready().then(function(){const e=sessionStorage.getItem(rn.keyPrefix+t);return e?rn.serializer.deserialize(e):null});return Zr(r,e),r},setItem:async function(t,e,r){t=tn(t),await this.ready();const n=e=e??null;return new Promise((o,i)=>{rn.serializer.serialize(e,(e,s)=>{if(s)return i(s),void Zr(Promise.reject(s),r);try{sessionStorage.setItem(rn.keyPrefix+t,e),o(n),Zr(Promise.resolve(n),r)}catch(t){"QuotaExceededError"!==t.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==t.name||console.error("Your sessionStorage capacity is used up."),i(t),Zr(Promise.reject(t),r)}})})},removeItem:function(t,e){t=tn(t);const r=this.ready().then(function(){sessionStorage.removeItem(rn.keyPrefix+t)});return Zr(r,e),r},clear:function(t){const e=this.ready().then(function(){const t=rn.keyPrefix;for(let e=sessionStorage.length-1;e>=0;e--){const r=sessionStorage.key(e);r&&0===r.indexOf(t)&&sessionStorage.removeItem(r)}});return Zr(e,t),e},length:function(t){const e=this.keys().then(function(t){return t.length});return Zr(e,t),e},key:function(t,e){const r=this.ready().then(function(){let e;try{e=sessionStorage.key(t)}catch(t){e=null}return e&&(e=e.substring(rn.keyPrefix.length)),e});return Zr(r,e),r},keys:function(t){const e=this.ready().then(function(){const t=sessionStorage.length,e=[];for(let r=0;r<t;r++){const t=sessionStorage.key(r);t&&0===t.indexOf(rn.keyPrefix)&&e.push(t.substring(rn.keyPrefix.length))}return e});return Zr(e,t),e},dropInstance:function(...t){const e=function(...t){if(t.length&&"function"==typeof t[t.length-1])return t[t.length-1]}(...t);let r="function"!=typeof t[0]&&t[0]||{};if(!r.name){const t=this.config();r.name=r.name||t.name,r.storeName=r.storeName||t.storeName}const n=this;let o;return o=r.name?new Promise(function(t){r.storeName?t(en(r,n._defaultConfig)):t(`${r.name}/`)}).then(function(t){for(let e=sessionStorage.length-1;e>=0;e--){const r=sessionStorage.key(e);r&&0===r.indexOf(t)&&sessionStorage.removeItem(r)}}):Promise.reject(new Error("Invalid arguments")),Zr(o,e),o}};var on,sn={exports:{}};var an,un=(on||(on=1,function(t,e){!function(t,e){function r(t){return r.result?r.result:t&&"function"==typeof t.getSerializer?(r.result=t.getSerializer(),r.result):Promise.reject(new Error("localforage.getSerializer() was not available! localforage v1.4+ is required!"))}function n(t,e){e&&t.then(function(t){e(null,t)},function(t){e(t)})}function o(t,e,r,n){function o(t,e){var r=t||e;return t&&"function"==typeof t||"string"!=typeof r||(t=function(t){return t[r]}),t}var i=[];if("[object Array]"===Object.prototype.toString.call(t)){e=o(e,"key"),r=o(r,"value");for(var s=0,a=t.length;s<a;s++){var u=t[s];i.push(n(e(u),r(u)))}}else for(var c in t)t.hasOwnProperty(c)&&i.push(n(c,t[c]));return i}function i(t,e,r,i){var s=this,a=s.ready().then(function(){return new Promise(function(n,i){var a,u=s._dbInfo,c=u.db.transaction(u.storeName,"readwrite"),l=c.objectStore(u.storeName);function f(t){var e=t.target||this;a=e.error||e.transaction.error,i(a)}c.oncomplete=function(){n(t)},c.onabort=c.onerror=function(t){i(a||t.target)},o(t,e,r,function(t,e){null===e&&(e=void 0),l.put(e,t).onerror=f})})});return n(a,i),a}function s(t,e,i,s){var a=this,u=new Promise(function(n,s){a.ready().then(function(){return r(a)}).then(function(r){var u=a._dbInfo;u.db.transaction(function(a){var c="INSERT OR REPLACE INTO "+u.storeName+" (key, value) VALUES (?, ?)",l=o(t,e,i,function(t,e){return new Promise(function(n,o){r.serialize(e,function(e,r){r?o(r):a.executeSql(c,[t,e],function(){n()},function(t,e){o(e)})})})});Promise.all(l).then(function(){n(t)},s)},function(t){s(t)})}).catch(s)});return n(u,s),u}function a(t,e,r,i){var s=this,a=o(t,e,r,function(t,e){return s.setItem(t,e)}),u=Promise.all(a);return n(u,i),u}function u(t,e,r,n){var o=this,u=o.driver();return u===o.INDEXEDDB?i.call(o,t,e,r,n):u===o.WEBSQL?s.call(o,t,e,r,n):a.call(o,t,e,r,n)}function c(t){var e=Object.getPrototypeOf(t);e&&(e.setItems=u,e.setItems.indexedDB=function(){return i.apply(this,arguments)},e.setItems.websql=function(){return s.apply(this,arguments)},e.setItems.generic=function(){return a.apply(this,arguments)})}var l=c(e="default"in e?e.default:e);t.setItemsGeneric=a,t.localforageSetItems=u,t.extendPrototype=c,t.extendPrototypeResult=l,Object.defineProperty(t,"__esModule",{value:!0})}(e,_r())}(0,sn.exports)),sn.exports),cn={exports:{}};var ln=(an||(an=1,function(t,e){!function(t,e){function r(t){return r.result?r.result:t&&"function"==typeof t.getSerializer?(r.result=t.getSerializer(),r.result):Promise.reject(new Error("localforage.getSerializer() was not available! localforage v1.4+ is required!"))}function n(t,e){return e&&t.then(function(t){e(null,t)},function(t){e(t)}),t}function o(t,e){var r=this.getItem(t).then(function(e){return{key:t,value:e}});return n(r,e),r}function i(t){var e=this,r=new Promise(function(r,n){for(var i=[],s=0,a=t.length;s<a;s++)i.push(o.call(e,t[s]));Promise.all(i).then(function(t){for(var e={},n=0,o=t.length;n<o;n++){var i=t[n];e[i.key]=i.value}r(e)}).catch(n)});return r}function s(){var t={};return this.iterate(function(e,r){t[r]=e}).then(function(){return t})}function a(){return"undefined"!=typeof IDBKeyRange?IDBKeyRange:"undefined"!=typeof webkitIDBKeyRange?webkitIDBKeyRange:"undefined"!=typeof mozIDBKeyRange?mozIDBKeyRange:void 0}e="default"in e?e.default:e;var u=a();function c(t){t=t.slice();var e=this;function r(t,e){return t<e?-1:t>e?1:0}var n=new Promise(function(n,o){e.ready().then(function(){var i,s=e._dbInfo,a=s.db.transaction(s.storeName,"readonly").objectStore(s.storeName),c=t.sort(r),l=u.bound(t[0],t[t.length-1],!1,!1);if("getAll"in a)(i=a.getAll(l)).onsuccess=function(){var t=i.result;void 0===t&&(t=null),n(t)};else{i=a.openCursor(l);var f={},h=0;i.onsuccess=function(){var t=i.result;if(t){for(var e=t.key;e>c[h];)if(++h===c.length)return void n(f);if(e===c[h]){var r=t.value;void 0===r&&(r=null),f[e]=r,t.continue()}else t.continue(c[h])}else n(f)}}i.onerror=function(){o(i.error)}}).catch(o)});return n}function l(t){var e=this,n=new Promise(function(n,o){e.ready().then(function(){return r(e)}).then(function(r){var i=e._dbInfo;i.db.transaction(function(e){for(var s=new Array(t.length),a=0,u=t.length;a<u;a++)s[a]="?";e.executeSql("SELECT * FROM "+i.storeName+" WHERE (key IN ("+s.join(",")+"))",t,function(t,e){for(var o={},i=e.rows,s=0,a=i.length;s<a;s++){var u=i.item(s),c=u.value;c&&(c=r.deserialize(c)),o[u.key]=c}n(o)},function(t,e){o(e)})})}).catch(o)});return n}function f(t,e){var r,o=this;if(arguments.length&&null!==t){var a=o.driver();r=a===o.INDEXEDDB?c.apply(o,arguments):a===o.WEBSQL?l.apply(o,arguments):i.apply(o,arguments)}else r=s.apply(o);return n(r,e),r}function h(t){var e=Object.getPrototypeOf(t);e&&(e.getItems=f,e.getItems.indexedDB=function(){return c.apply(this,arguments)},e.getItems.websql=function(){return l.apply(this,arguments)},e.getItems.generic=function(){return i.apply(this,arguments)})}var d=h(e);t.localforageGetItems=f,t.extendPrototype=h,t.extendPrototypeResult=d,t.getItemsGeneric=i,Object.defineProperty(t,"__esModule",{value:!0})}(e,_r())}(0,cn.exports)),cn.exports),fn=Object.prototype.hasOwnProperty;function hn(t,e){return null!=t&&fn.call(t,e)}var dn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,vn=/^\w*$/;function pn(t,e){if(et(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!It(t))||(vn.test(t)||!dn.test(t)||null!=e&&t in Object(e))}function yn(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var s=t.apply(this,n);return r.cache=i.set(o,s)||i,s};return r.cache=new(yn.Cache||je),r}yn.Cache=je;var gn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,bn=/\\(\\)?/g,mn=function(t){var e=yn(t,function(t){return 500===r.size&&r.clear(),t}),r=e.cache;return e}(function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(gn,function(t,r,n,o){e.push(n?o.replace(bn,"$1"):r||t)}),e});function _n(t,e){return et(t)?t:pn(t,e)?[t]:mn(xt(t))}function wn(t){if("string"==typeof t||It(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function jn(t,e,r){for(var n=-1,o=(e=_n(e,t)).length,i=!1;++n<o;){var s=wn(e[n]);if(!(i=null!=t&&r(t,s)))break;t=t[s]}return i||++n!=o?i:!!(o=null==t?0:t.length)&&rt(o)&&mt(s,o)&&(et(t)||tt(t))}function Sn(t,e,r){var n=-1,o=(e=_n(e,t)).length;for(o||(o=1,t=void 0);++n<o;){var i=null==t?void 0:t[wn(e[n])];void 0===i&&(n=o,i=r),t=m(i)?i.call(t):i}return t}function In(){return(65536*(1+Math.random())|0).toString(16).substring(1)}function On(){const t={isResolved:!1,isPending:!0,isRejected:!1,resolve:null,reject:null},e=new Promise((e,r)=>{t.resolve=e,t.reject=r});return Object.assign(e,t),e.then(function(){e.isResolved=!0,e.isPending=!1,e.isRejected=!1},function(){e.isResolved=!1,e.isPending=!1,e.isRejected=!0}),e}function An(){throw new Error('A "url" property or function must be specified')}function En(t,e,r){const n=e.error;e.error=function(o){n&&n.call(e.context,t,o,e),t.trigger("error",t,o,e),r&&r.reject&&r.reject(o)}}function xn(t,e,r){if(!e)return r();let n=!1;const o=t.success,i=t.error;t.success=(...t)=>(n=!0,o&&o(...t)),t.error=(...t)=>(n=!0,i&&i(...t));const s=r();var a;return null!=(a=s)&&"function"==typeof a.then&&Promise.resolve(s).then(e=>{n||t.success(e)},r=>{n?e.reject(r):t.error(r)}).catch(t=>e.reject(t)),s}const kn={create:"POST",update:"PUT",patch:"PATCH",delete:"DELETE",read:"GET"},Nn=new WeakSet;function Pn(t){const e=t?.constructor;if(!e||Nn.has(e))return;Nn.add(e);const r=e.name;console.warn(`Skeletor: \`browserStorage\` is deprecated and will be removed in a future major version; use \`storage\` instead${r?` (on \`${r}\`)`:""}.`)}function Rn(t){if(!t)return;const e=Sn(t,"storage");if(null!=e)return e;const r=Sn(t,"browserStorage");return null!=r&&Pn(t),r}function Tn(t){const e=Rn(t)||Rn(t.collection);return e?e.sync():Dn}class Bn extends Error{constructor(t,e,r){const n=t.statusText?` ${t.statusText}`:"";super(`${e} ${r} failed with HTTP ${t.status}${n}`),this.name="HTTPError",this.status=t.status,this.response=t}}function Dn(t,e,r={}){const n=kn[t];let o=r.data;null!=o||!e||"create"!==t&&"update"!==t&&"patch"!==t||(o=r.attrs||e.toJSON());let i=r.url||Sn(e,"url")||An();const s={method:n};null!=o&&("GET"===n?i+=(i.includes("?")?"&":"?")+new URLSearchParams(o).toString():(s.body=JSON.stringify(o),s.headers={"Content-Type":"application/json"}));const a=fetch(i,s);return r.xhr=a,e.trigger("request",e,a,{...s,xhr:a}),Promise.resolve(a).then(async t=>{if(!t.ok)throw new Bn(t,n,i);const e=await t.text();return e?JSON.parse(e):null}).then(t=>(r.success?.(t,r),t),t=>{throw r.error?.(t),t})}const zn=ce;wr.defineDriver(he),un.extendPrototype(wr),ln.extendPrototype(wr);const Cn=new Set,Mn=new WeakSet;class Fn{static register(t){Mn.has(t)||(Mn.add(t),Cn.add(new WeakRef(t)))}static flushAll(){for(const t of Cn){const e=t.deref();e?e.flush():Cn.delete(t)}}constructor(t,e,r=!1){if(this.storeReady=!1,this.name=t,"local"===e&&"undefined"!=typeof window&&!window.localStorage)throw new Error("Skeletor.storage: Environment does not support localStorage.");if("session"===e&&"undefined"!=typeof window&&!window.sessionStorage)throw new Error("Skeletor.storage: Environment does not support sessionStorage.");vr(e)?this.storeInitialized=this.initStore(e,r):(this.store=e,r&&(this.store.debouncedSetItems=Yr(t=>this.store.setItems(t),50,{promise:!0})),this.storeInitialized=Promise.resolve()),this.storeInitialized.then(()=>this.storeReady=!0).catch(()=>{})}async initStore(t,e){if("session"===t)await wr.setDriver(nn._driver);else if("local"===t)await wr.config({driver:wr.LOCALSTORAGE});else if("in_memory"===t)await wr.config({driver:zn});else{if("node"===t){const t=Fn.nodeStorage;if(!t)throw new Error("Skeletor.storage: the 'node' storage type is only available in Node.js builds. Import from '@converse/skeletor/node' instead of '@converse/skeletor'.");return this.store=new t(this.name,Fn.nodeStorageDir??void 0),void(e&&(this.store.debouncedSetItems=Yr(t=>this.store.setItems(t),50,{promise:!0})))}if("indexed"!==t)throw new Error("Skeletor.storage: No storage type was specified")}this.store=wr,e&&(this.store.debouncedSetItems=Yr(t=>this.store.setItems(t),50,{promise:!0}))}flush(){this.store.debouncedSetItems&&"function"==typeof this.store.debouncedSetItems.flush&&this.store.debouncedSetItems.flush()}async clear(){await this.storeInitialized,await this.store.removeItem(this.name).catch(t=>console.error(t));const t=new RegExp(`^${this.name}-`),e=(await this.store.keys()).filter(e=>t.test(e));await Promise.all(e.map(t=>this.store.removeItem(t).catch(t=>console.error(t))))}sync(){const t=this;async function e(e,r,n){let o,i,s,a;const u=n.collection??r.collection;["patch","update"].includes(e)&&(a=dr(r.attributes,5)),t.storeReady||await t.storeInitialized;try{const i=r.attributes;switch(e){case"read":o=void 0!==r.id?await t.find(r):await t.findAll();break;case"create":o=await t.create(r,n);break;case"patch":case"update":n.wait&&(r.attributes=a),s=t.update(r),n.wait&&(r.attributes=i),o=await s;break;case"delete":o=await t.destroy(r,u)}}catch(e){const r=await t.getStorageSize();i=22===e.code&&0===r?new Error("Private browsing is unsupported"):e instanceof Error?e:new Error(e?.message??String(e))}if(i)n?.error?.(i);else if(n?.success){const t="read"===e?o??null:null;n.success(t,n)}}return e.__name__="localSync",e}removeCollectionReference(t,e){if(!e)return;const r=e.filter(e=>e.id!==t.id).map(t=>this.getItemName(t.id));return this.store.setItem(this.name,r)}addCollectionReference(t,e){if(!e)return;const r=e.map(t=>this.getItemName(t.id)),n=this.getItemName(t.id);return r.includes(n)||r.push(n),this.store.setItem(this.name,r)}getCollectionReferenceData(t){if(!t.collection)return{};const e=t.collection.map(t=>this.getItemName(t.id)),r=this.getItemName(t.id);e.includes(r)||e.push(r);const n={};return n[this.name]=e,n}async save(t){if(this.store.setItems){const e={};return e[this.getItemName(t.id)]=t.toJSON(),Object.assign(e,this.getCollectionReferenceData(t)),this.store.debouncedSetItems?this.store.debouncedSetItems(e):this.store.setItems(e)}{const e=this.getItemName(t.id),r=await this.store.setItem(e,t.toJSON());return await this.addCollectionReference(t,t.collection),r}}create(t,e){return t.id||(t.id=In()+In()+"-"+In()+"-"+In()+"-"+In()+"-"+In()+In()+In(),t.set(t.idAttribute,t.id,e)),this.save(t)}update(t){return this.save(t)}find(t){return this.store.getItem(this.getItemName(t.id))}async findAll(){const t=await this.store.getItem(this.name);if(t?.length){const e=await this.store.getItems(t);return Object.values(e)}return[]}async destroy(t,e){return await this.flush(),await this.store.removeItem(this.getItemName(t.id)),await this.removeCollectionReference(t,e),t}async getStorageSize(){return await this.store.length()}getItemName(t){return this.name+"-"+t}}Fn.nodeStorage=null,Fn.nodeStorageDir=null,Fn.sessionStorageInitialized=wr.defineDriver(nn),Fn.localForage=wr;function Ln(t){return dr(t,4)}function Un(t,e,r,n){for(var o=-1,i=null==t?0:t.length;++o<i;){var s=t[o];e(n,s,r(s),t)}return n}function Wn(t,e){return t&&Sr(t,e,jt)}var qn,Jn=(qn=Wn,function(t,e){if(null==t)return t;if(!nt(t))return qn(t,e);for(var r=t.length,n=-1,o=Object(t);++n<r&&!1!==e(o[n],n,o););return t});function $n(t,e,r,n){return Jn(t,function(t,o,i){e(n,t,r(t),i)}),n}function Kn(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new je;++e<r;)this.add(t[e])}function Hn(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function Vn(t,e){return t.has(e)}Kn.prototype.add=Kn.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Kn.prototype.has=function(t){return this.__data__.has(t)};function Gn(t,e,r,n,o,i){var s=1&r,a=t.length,u=e.length;if(a!=u&&!(s&&u>a))return!1;var c=i.get(t),l=i.get(e);if(c&&l)return c==e&&l==t;var f=-1,h=!0,d=2&r?new Kn:void 0;for(i.set(t,e),i.set(e,t);++f<a;){var v=t[f],p=e[f];if(n)var y=s?n(p,v,f,e,t,i):n(v,p,f,t,e,i);if(void 0!==y){if(y)continue;h=!1;break}if(d){if(!Hn(e,function(t,e){if(!Vn(d,e)&&(v===t||o(v,t,r,n,i)))return d.push(e)})){h=!1;break}}else if(v!==p&&!o(v,p,r,n,i)){h=!1;break}}return i.delete(t),i.delete(e),h}function Qn(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function Xn(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}var Yn=l?l.prototype:void 0,Zn=Yn?Yn.valueOf:void 0;var to=Object.prototype.hasOwnProperty;var eo="[object Arguments]",ro="[object Array]",no="[object Object]",oo=Object.prototype.hasOwnProperty;function io(t,e,r,n,o,i){var s=et(t),a=et(e),u=s?ro:V(t),c=a?ro:V(e),l=(u=u==eo?no:u)==no,f=(c=c==eo?no:c)==no,h=u==c;if(h&&at(t)){if(!at(e))return!1;s=!0,l=!1}if(h&&!l)return i||(i=new Se),s||pt(t)?Gn(t,e,r,n,o,i):function(t,e,r,n,o,i,s){switch(r){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!i(new Ge(t),new Ge(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return de(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Qn;case"[object Set]":var u=1&n;if(a||(a=Xn),t.size!=e.size&&!u)return!1;var c=s.get(t);if(c)return c==e;n|=2,s.set(t,e);var l=Gn(a(t),a(e),n,o,i,s);return s.delete(t),l;case"[object Symbol]":if(Zn)return Zn.call(t)==Zn.call(e)}return!1}(t,e,u,r,n,o,i);if(!(1&r)){var d=l&&oo.call(t,"__wrapped__"),v=f&&oo.call(e,"__wrapped__");if(d||v){var p=d?t.value():t,y=v?e.value():e;return i||(i=new Se),o(p,y,r,n,i)}}return!!h&&(i||(i=new Se),function(t,e,r,n,o,i){var s=1&r,a=Ke(t),u=a.length;if(u!=Ke(e).length&&!s)return!1;for(var c=u;c--;){var l=a[c];if(!(s?l in e:to.call(e,l)))return!1}var f=i.get(t),h=i.get(e);if(f&&h)return f==e&&h==t;var d=!0;i.set(t,e),i.set(e,t);for(var v=s;++c<u;){var p=t[l=a[c]],y=e[l];if(n)var g=s?n(y,p,l,e,t,i):n(p,y,l,t,e,i);if(!(void 0===g?p===y||o(p,y,r,n,i):g)){d=!1;break}v||(v="constructor"==l)}if(d&&!v){var b=t.constructor,m=e.constructor;b==m||!("constructor"in t)||!("constructor"in e)||"function"==typeof b&&b instanceof b&&"function"==typeof m&&m instanceof m||(d=!1)}return i.delete(t),i.delete(e),d}(t,e,r,n,o,i))}function so(t,e,r,n,o){return t===e||(null==t||null==e||!G(t)&&!G(e)?t!=t&&e!=e:io(t,e,r,n,so,o))}function ao(t,e,r,n){var o=r.length,i=o;if(null==t)return!i;for(t=Object(t);o--;){var s=r[o];if(s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++o<i;){var a=(s=r[o])[0],u=t[a],c=s[1];if(s[2]){if(void 0===u&&!(a in t))return!1}else if(!so(c,u,3,n,new Se))return!1}return!0}function uo(t){return t==t&&!b(t)}function co(t){for(var e=jt(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,uo(o)]}return e}function lo(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}function fo(t){var e=co(t);return 1==e.length&&e[0][2]?lo(e[0][0],e[0][1]):function(r){return r===t||ao(r,0,e)}}function ho(t,e){for(var r=0,n=(e=_n(e,t)).length;null!=t&&r<n;)t=t[wn(e[r++])];return r&&r==n?t:void 0}function vo(t,e){return null!=t&&e in Object(t)}function po(t,e){return null!=t&&jn(t,e,vo)}function yo(t,e){return pn(t)&&uo(e)?lo(wn(t),e):function(r){var n=function(t,e,r){var n=null==t?void 0:ho(t,e);return void 0===n?r:n}(r,t);return void 0===n&&n===e?po(r,t):so(e,n,3)}}function go(t){return pn(t)?function(t){return function(e){return null==e?void 0:e[t]}}(wn(t)):function(t){return function(e){return ho(e,t)}}(t)}function bo(t){return"function"==typeof t?t:null==t?Tr:"object"==typeof t?et(t)?yo(t[0],t[1]):fo(t):go(t)}function mo(t,e){return function(e,r){return(et(e)?Un:$n)(e,t,bo(r),{})}}var _o=Object.prototype.hasOwnProperty,wo=mo(function(t,e,r){_o.call(t,r)?++t[r]:Oe(t,r,1)}),jo=Object.prototype.hasOwnProperty,So=mo(function(t,e,r){jo.call(t,r)?t[r].push(e):Oe(t,r,[e])}),Io=mo(function(t,e,r){Oe(t,r,e)});var Oo=l?l.isConcatSpreadable:void 0;function Ao(t){return et(t)||tt(t)||!!(Oo&&t&&t[Oo])}function Eo(t,e,r,n,o){var i=-1,s=t.length;for(r||(r=Ao),o||(o=[]);++i<s;){var a=t[i];r(a)?We(o,a):o[o.length]=a}return o}function xo(t,e){if(t!==e){var r=void 0!==t,n=null===t,o=t==t,i=It(t),s=void 0!==e,a=null===e,u=e==e,c=It(e);if(!a&&!c&&!i&&t>e||i&&s&&u&&!a&&!c||n&&s&&u||!r&&u||!o)return 1;if(!n&&!i&&!c&&t<e||c&&r&&o&&!n&&!i||a&&r&&o||!s&&o||!u)return-1}return 0}function ko(t,e,r){e=e.length?St(e,function(t){return et(t)?function(e){return ho(e,1===t.length?t[0]:t)}:t}):[Tr];var n=-1;e=St(e,ct(bo));var o=function(t,e){var r=-1,n=nt(t)?Array(t.length):[];return Jn(t,function(t,o,i){n[++r]=e(t,o,i)}),n}(t,function(t,r,o){return{criteria:St(e,function(e){return e(t)}),index:++n,value:t}});return function(t,e){var r=t.length;for(t.sort(e);r--;)t[r]=t[r].value;return t}(o,function(t,e){return function(t,e,r){for(var n=-1,o=t.criteria,i=e.criteria,s=o.length,a=r.length;++n<s;){var u=xo(o[n],i[n]);if(u)return n>=a?u:u*("desc"==r[n]?-1:1)}return t.index-e.index}(t,e,r)})}var No=qr(function(t,e){if(null==t)return[];var r=e.length;return r>1&&Jr(t,e[0],e[1])?e=[]:r>2&&Jr(e[0],e[1],e[2])&&(e=[e[0]]),ko(t,Eo(e),[])});const Po=new Map,Ro=new Set,To=new Map;let Bo=!1;function Do(t,e){const r=Promise.resolve(e()).catch(e=>{console.error("Skeletor autoSync save error:",e),t?.trigger?.("error",t,e)});let n;Ro.add(r),t&&(n=To.get(t),n||(n=new Set,To.set(t,n)),n.add(r)),r.finally(()=>{Ro.delete(r),n&&(n.delete(r),0===n.size&&To.delete(t))})}function zo(t){if(Bo||"undefined"==typeof window)return;Bo=!0;const e=()=>function({storage:t,wait:e=!1}={}){for(const[t,{timerId:e,run:r}]of Po.entries())clearTimeout(e),Do(t,r);if(Po.clear(),t&&t.flushAll(),e)return Promise.all([...Ro]).then(()=>{})}({storage:t});window.addEventListener("pagehide",e),window.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&e()})}var Co=Object.prototype,Mo=Co.hasOwnProperty,Fo=qr(function(t,e){t=Object(t);var r=-1,n=e.length,o=n>2?e[2]:void 0;for(o&&Jr(e[0],e[1],o)&&(n=1);++r<n;)for(var i=e[r],s=Pe(i),a=-1,u=s.length;++a<u;){var c=s[a],l=t[c];(void 0===l||de(l,Co[c])&&!Mo.call(t,c))&&(t[c]=i[c])}return t});var Lo=qr(function(t,e){return function(t,e,r){if("function"!=typeof t)throw new TypeError("Expected a function");return setTimeout(function(){t.apply(void 0,r)},e)}(t,1,e)});var Uo,Wo,qo=Object.prototype.toString,Jo=(Uo=function(t,e,r){null!=e&&"function"!=typeof e.toString&&(e=qo.call(e)),t[e]=r},Wo=zr(Tr),function(t,e){return function(t,e,r,n){return Wn(t,function(t,o,i){e(n,r(t),o,i)}),n}(t,Uo,Wo(e),{})});function $o(t,e){return so(t,e)}function Ko(t,e){return e.length<2?t:ho(t,function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n<o;)i[n]=t[n+e];return i}(e,0,-1))}var Ho=Object.prototype.hasOwnProperty;function Vo(t,e){var r=-1,n=(e=_n(e,t)).length;if(!n)return!0;for(;++r<n;){var o=wn(e[r]);if("__proto__"===o&&!Ho.call(t,"__proto__"))return!1;if(("constructor"===o||"prototype"===o)&&r<n-1)return!1}var i=Ko(t,e);return null==i||delete i[wn(function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}(e))]}function Go(t){return kr(t)?void 0:t}function Qo(t){return(null==t?0:t.length)?Eo(t):[]}function Xo(t){return Wr(Dr(t,void 0,Qo),t+"")}var Yo=Xo(function(t,e){var r={};if(null==t)return r;var n=!1;e=St(e,function(e){return e=_n(e,t),n||(n=e.length>1),e}),xe(t,He(t),r),n&&(r=dr(r,7,Go));for(var o=e.length;o--;)Vo(r,e[o]);return r});function Zo(t,e,r,n){if(!b(t))return t;for(var o=-1,i=(e=_n(e,t)).length,s=i-1,a=t;null!=a&&++o<i;){var u=wn(e[o]),c=r;if("__proto__"===u||"constructor"===u||"prototype"===u)return t;if(o!=s){var l=a[u];void 0===(c=void 0)&&(c=b(l)?l:mt(e[o+1])?[]:{})}Ee(a,u,c),a=a[u]}return t}function ti(t,e){return function(t,e,r){for(var n=-1,o=e.length,i={};++n<o;){var s=e[n],a=ho(t,s);r(a,s)&&Zo(i,_n(s,t),a)}return i}(t,e,function(e,r){return po(t,r)})}var ei=Xo(function(t,e){return null==t?{}:ti(t,e)});const ri=new WeakMap;function ni(t){let e=ri.get(t);return e||(e={state:"constructing"},ri.set(t,e)),e}function oi(t,e,r,n,o,i){const s=n.fn(t);$o(e.computedCache[r],s)||(e.computedCache[r]=s,o||(t.changed[r]=s,t.trigger("change:"+r,t,s,i)))}class ii extends Xt{constructor(t,e){super(),this._changing=!1,this._pending=!1,this._url="",this.changed={},this.validationError=null;const r=ni(this);let n=t||{};e=e||{},this.preinitialize.apply(this,arguments),this.cid=Nt(this.cidPrefix),this.attributes={},e.collection&&(this.collection=e.collection),e.parse&&(n=this.parse(n,e)||{});const o=Sn(this,"defaults");n=Fo(Object.assign({},o,n),o),this.set(n,e),function(t,e){const r=Sn(t,"computed");if(r&&!gt(r)){e.computedDefs=r,e.computedCache={};for(const[n,o]of Object.entries(r))e.computedCache[n]=o.fn(t)}}(this,r),this.attrs=new Proxy(this.attributes,{get:(t,e)=>{const n=r.computedCache;return"symbol"!=typeof e&&n&&e in n?n[e]:this.attributes[e]},set:(t,e,r)=>(this.set(e,r),!0)}),this.initialize.apply(this,arguments),this.changed={},this.autoSync?Rn(this)&&!this.isNew()?(r.state="hydrating",this.hydrated=async function(t,e){zo(Fn);try{await t.fetch({fromStorage:!0,promise:!0})}finally{e.state="ready"}}(this,r)):(r.state="ready",this.hydrated=Promise.resolve()):r.state="ready"}get storage(){return this._storage}set storage(t){this._storage=t,Fn.register(t)}get browserStorage(){return this._storage}set browserStorage(t){Pn(this),this.storage=t}get autoSync(){return!1}get autoSyncDelay(){return 100}get idAttribute(){return"id"}get cidPrefix(){return"c"}preinitialize(...t){}initialize(t,e){}validate(t,e){return null}defaults(){return{}}get computed(){return{}}toJSON(){return Ln(this.attributes)}sync(t,e,r){return Tn(e)(t,e,r)}get(t){const e=ni(this).computedCache;return e&&t in e?e[t]:this.attributes[t]}keys(){return Object.keys(this.attributes)}values(){return Object.values(this.attributes)}pairs(){return this.entries()}entries(){return Object.entries(this.attributes)}invert(){return Jo(this.attributes)}pick(...t){return 1===t.length&&Array.isArray(t[0])&&(t=t[0]),ei(this.attributes,t)}omit(...t){return 1===t.length&&Array.isArray(t[0])&&(t=t[0]),Yo(this.attributes,t)}isEmpty(){return gt(this.attributes)}has(t){return null!=this.get(t)}matches(t){return"function"==typeof t?!!t(this.attributes):(e=this.attributes)===(r=t)||ao(e,0,co(r));var e,r}set(t,e,r){if(null==t)return this;let n;"object"==typeof t?(n=t,r=e):(n={},n[t]=e),r=r||{};const o=ni(this);if(this.autoSync&&"hydrating"===o.state&&!r.fromStorage)throw new Error("Skeletor: set() called on an autoSync model before hydration resolved. Await model.hydrated first.");if(!this._validate(n,r))return null;const i=r.unset,s=r.silent,a=[],u=this._changing;this._changing=!0,u||(this._previousAttributes=Ln(this.attributes),this.changed={});const c=this.attributes,l=this.changed,f=this._previousAttributes;for(const t in n)e=n[t],$o(c[t],e)||a.push(t),$o(f[t],e)?delete l[t]:l[t]=e,i?delete c[t]:c[t]=e;if(this.idAttribute in n&&(this.id=this.get(this.idAttribute)),!s){a.length&&(this._pending=r);for(let t=0;t<a.length;t++)this.trigger("change:"+a[t],this,c[a[t]],r)}if(a.length&&o.computedDefs)for(const[t,e]of Object.entries(o.computedDefs))e.deps.some(t=>a.includes(t))&&oi(this,o,t,e,s,r);if(u)return this;if(!s)for(;this._pending;)r=this._pending,this._pending=!1,this.trigger("change",this,r);return this._pending=!1,this._changing=!1,"ready"===o.state&&this.autoSync&&Rn(this)&&a.length&&!r.fromStorage&&!r.noAutoSave&&function(t,e,r){const n=Po.get(t);n&&clearTimeout(n.timerId);const o=setTimeout(()=>{Po.delete(t),Do(t,e)},r);Po.set(t,{timerId:o,run:e})}(this,()=>this.save(null,{noAutoSave:!0}),this.autoSyncDelay),this}unset(t,e){return this.set(t,void 0,Object.assign({},e,{unset:!0}))}clear(t){const e={};for(const t in this.attributes)e[t]=void 0;return this.set(e,Object.assign({},t,{unset:!0}))}hasChanged(t){return null==t?!gt(this.changed):(e=this.changed,r=t,null!=e&&jn(e,r,hn));var e,r}changedAttributes(t){if(!t)return!!this.hasChanged()&&Ln(this.changed);const e=this._changing?this._previousAttributes:this.attributes,r={};let n=!1;for(const o in t){const i=t[o];$o(e[o],i)||(r[o]=i,n=!0)}return!!n&&r}previous(t){return null!=t&&this._previousAttributes?this._previousAttributes[t]:null}previousAttributes(){return this._previousAttributes?Ln(this._previousAttributes):void 0}fetch(t={}){const e=(t=Object.assign({parse:!0},t)).success,r=t.promise?On():void 0;t.success=n=>{const o=t.parse?this.parse(n,t):n;if(!this.set(o,Object.assign({},t,{fromStorage:!0})))return r&&r.reject(this.validationError),!1;e&&e.call(t.context,this,n,t),this.trigger("sync",this,n,t),r&&r.resolve(n)},En(this,t,r);const n=xn(t,r,()=>this.sync("read",this,t));return r??n}save(t,e,r){let n;null==t||"object"==typeof t?(n=t,r=e):(n={},n[t]=e);const o=(r=Object.assign({validate:!0,parse:!0},r)).wait,i=r.promise,s=i?On():void 0;if(!(n&&!o?!!this.set(n,r):this._validate(n||{},r)))return!!s&&(s.reject(this.validationError),s);const a=r.success,u=r.error,c=this.attributes;r.success=t=>{this.attributes=c;let e=r.parse?this.parse(t,r):t;if(o&&(e=Object.assign({},n,e)),e&&!this.set(e,r))return i&&s.reject(this.validationError),!1;a&&a.call(r.context,this,t,r),this.trigger("sync",this,t,r),i&&s.resolve()},r.error=(t,e,r)=>{u&&u.call(r.context,t,e,r),i&&s.reject(e)},En(this,r),n&&o&&(this.attributes=Object.assign({},c,n));const l=this.isNew()?"create":r.patch?"patch":"update";"patch"!==l||r.attrs||(r.attrs=n);const f=xn(r,s,()=>this.sync(l,this,r));return this.attributes=c,s??f}destroy(t){!function(t){const e=Po.get(t);e&&(clearTimeout(e.timerId),Po.delete(t))}(this);const e=(t=t?Ln(t):{}).success,r=t.wait,n=()=>{this.stopListening(),this.trigger("destroy",this,this.collection,t)};t.success=o=>{r&&n(),e&&e.call(t.context,this,o,t),this.isNew()||this.trigger("sync",this,o,t)};const o=function(t){const e=To.get(t);return e&&0!==e.size?Promise.all([...e]).then(()=>{}):null}(this);o&&this.collection&&(t.collection=this.collection);let i=!1;return this.isNew()?Lo(t.success):(En(this,t),i=o?o.then(()=>this.sync("delete",this,t)):this.sync("delete",this,t)),r||n(),i}get urlRoot(){return this._urlRoot}set urlRoot(t){this._urlRoot=t}get url(){if(this._url)return this._url;const t=Sn(this,"urlRoot")||Sn(this.collection,"url")||An();if(this.isNew())return t;const e=this.get(this.idAttribute);return t.replace(/[^\/]$/,"$&/")+encodeURIComponent(String(e))}set url(t){this._url=t}parse(t,e){return t}isNew(){return!this.has(this.idAttribute)}isValid(t){return this._validate({},Object.assign({},t,{validate:!0}))}subscribe(t,e,r){if("function"==typeof t){const e=e=>t(e,this.changed);return this.on("change",e),()=>this.off("change",e)}return super.subscribe(t,e,r)}_validate(t,e){if(!e?.validate||!this.validate)return!0;t=Object.assign({},this.attributes,t);const r=this.validationError=this.validate(t,e)||null;return!r||(this.trigger("invalid",this,r,Object.assign(e,{validationError:r})),!1)}}var si;const ai={add:!0,remove:!0,merge:!0},ui={add:!0,remove:!1};function ci(t){if(m(t))return t;if(vr(t))return e=>e.get(t);const e=fo(dr(t,1));return t=>e(t.attributes)}class li extends Xt{constructor(t,e){super(),this._url="",this[si]=this.values,e=e||{},this.preinitialize.apply(this,arguments),e.model&&(this._model=e.model),void 0!==e.comparator&&(this.comparator=e.comparator),this._reset(),this.initialize.apply(this,arguments),t&&this.reset(t,Object.assign({silent:!0},e)),this[Symbol.iterator]=this.values,this.autoSync&&(this.hydrated=Rn(this)?async function(t){zo(Fn),await t.fetch({fromStorage:!0,promise:!0})}(this):Promise.resolve())}get comparator(){return this._comparator}set comparator(t){this._comparator=t}get storage(){return this._storage}set storage(t){this._storage=t,Fn.register(t)}get browserStorage(){return this._storage}set browserStorage(t){Pn(this),this.storage=t}get autoSync(){return!1}get model(){return this._model??ii}set model(t){this._model=t}get length(){return this.models.length}get url(){return this._url}set url(t){this._url=t}preinitialize(...t){}initialize(...t){}toJSON(){return this.map(function(t){return t.toJSON()})}sync(t,e,r){return Tn(this)(t,e,r)}add(t,e){return this.set(t,Object.assign({merge:!1},e,ui))}remove(t,e){e=Object.assign({},e);const r=!Array.isArray(t),n=r?[t]:t.slice(),o=this._removeModels(n,e);return!e.silent&&o.length&&(e.changes={added:[],merged:[],removed:o},this.trigger("update",this,e)),r?o[0]:o}set(t,e){if(null==t)return;(e=Object.assign({},ai,e)).parse&&!this._isModel(t)&&(t=this.parse(t,e)||[]);const r=!Array.isArray(t);t=r?[t]:t.slice();let n=e.at;null!=n&&(n=+n),n>this.length&&(n=this.length),n<0&&(n+=this.length+1);const o=[],i=[],s=[],a=[],u={},c=e.add,l=e.merge,f=e.remove;let h=!1;const d=this.comparator&&null==n&&!1!==e.sort,v=vr(this.comparator)?this.comparator:null;let p,y;for(y=0;y<t.length;y++){p=t[y];const r=this.get(p);if(r){if(l&&p!==r){let t=this._isModel(p)?p.attributes:p;e.parse&&(t=r.parse(t,e)),r.set(t,e),s.push(r),d&&!h&&(h=r.hasChanged(v))}u[r.cid]||(u[r.cid]=!0,o.push(r)),t[y]=r}else c&&(p=t[y]=this._prepareModel(p,e),p&&(i.push(p),this._addReference(p,e),u[p.cid]=!0,o.push(p)))}if(f){for(y=0;y<this.length;y++)p=this.models[y],u[p.cid]||a.push(p);a.length&&this._removeModels(a,e)}let g=!1;const b=!d&&c&&f;if(o.length&&b)g=this.length!==o.length||this.models.some((t,e)=>t!==o[e]),this.models.length=0,this.models.splice(0,0,...o);else if(i.length){d&&(h=!0);let t=n??this.length;t=Math.min(Math.max(t,0),this.models.length),this.models.splice(t,0,...i)}if(h&&this.sort({silent:!0}),!e.silent){for(y=0;y<i.length;y++)null!=n&&(e.index=n+y),p=i[y],p.trigger("add",p,this,e);(h||g)&&this.trigger("sort",this,e),(i.length||a.length||s.length)&&(e.changes={added:i,removed:a,merged:s},this.trigger("update",this,e))}return r?t[0]:t}async clearStore(t={},e=()=>!0){await Promise.all(this.models.filter(e).map(e=>new Promise(r=>{e.destroy(Object.assign(t,{success:r,error:(t,e)=>{console.error(e),r()}}))}))),await(Rn(this)?.clear()),this.reset()}reset(t,e){e=e?Ln(e):{};for(let t=0;t<this.models.length;t++)this._removeReference(this.models[t],e);return e.previousModels=this.models,this._reset(),t=this.add(t,Object.assign({silent:!0},e)),e.silent||this.trigger("reset",this,e),t}push(t,e){return this.add(t,Object.assign({at:this.length},e))}pop(t){const e=this.at(this.length-1);return this.remove(e,t)}unshift(t,e){return this.add(t,Object.assign({at:0},e))}shift(t){const e=this.at(0);return this.remove(e,t)}slice(t,e){return this.models.slice(t,e)}filter(t,e){return this.models.filter(ci(t),e)}every(t){return m(t)?this.models.every(e=>t(e.attributes)):this.models.every(ci(t))}difference(t){return this.models.filter(e=>!t.includes(e))}max(){return Math.max.apply(Math,this.models)}min(){return Math.min.apply(Math,this.models)}drop(t=1){return this.models.slice(t)}some(t){return m(t)?this.models.some(e=>t(e.attributes)):this.models.some(ci(t))}sortBy(t){return No(this.models,ci(t))}isEmpty(){return!this.models.length}keyBy(t){return Io(this.models,t)}each(t,e){return this.forEach(t,e)}forEach(t,e){return this.models.forEach(t,e)}includes(t){return this.models.includes(t)}size(){return this.models.length}countBy(t){return wo(this.models,ci(t))}groupBy(t){return So(this.models,ci(t))}indexOf(t,e){return this.models.indexOf(t,e)}findLastIndex(t,e){return this.models.findLastIndex(ci(t),e)}lastIndexOf(t,e){return this.models.lastIndexOf(t,e)}findIndex(t){return this.models.findIndex(ci(t))}last(){const t=null==this.models?0:this.models.length;return t?this.models[t-1]:void 0}head(){return this.models[0]}first(){return this.head()}map(t,e){return this.models.map(ci(t),e)}reduce(t,e){return this.models.reduce(t,e||this.models[0])}reduceRight(t,e){return this.models.reduceRight(t,e||this.models[0])}toArray(){return Array.from(this.models)}get(t){if(null!=t)return this._byId[t]||this._byId[this.modelId(this._isModel(t)?t.attributes:t)]||t.cid&&this._byId[t.cid]}has(t){return null!=this.get(t)}at(t){return t<0&&(t+=this.length),this.models[t]}where(t,e){return this[e?"find":"filter"](t)}findWhere(t){return this.where(t,!0)}find(t,e){return this.models.find(ci(t),e)}sort(t){let e=this.comparator;if(!e)throw new Error("Cannot sort a set without a comparator");t=t||{};const r=m(e)?e.length:0;return m(e)&&(e=e.bind(this)),1===r||vr(e)?this.models=this.sortBy(e):this.models.sort(e),t.silent||this.trigger("sort",this,t),this}pluck(t){return this.map(t+"")}fetch(t){const e=(t=Object.assign({parse:!0},t)).success,r=this,n=t.promise?On():void 0;t.success=function(o){const i=t.reset?"reset":"set";r[i](o,Object.assign({},t,{fromStorage:!0})),e&&e.call(t.context,r,o,t),r.trigger("sync",r,o,t),n&&n.resolve()},En(this,t,n);const o=xn(t,n,()=>this.sync("read",this,t));return n??o}create(t,e){const r=(e=e?Ln(e):{}).wait,n=e.promise,o=n&&On();let i;const s=(t,e)=>i=e;n&&this.on("invalid",s);const a=this._prepareModel(t,e);if(n&&this.off("invalid",s),!a)return n?(o.reject(i),o):null;r||this.add(a,e);const u=this,c=e.success,l=e.error;e.success=function(t,e,i){r&&u.add(t,i),c&&c.call(i.context,t,e,i),n&&o.resolve(t)},e.error=function(t,e,r){l&&l.call(r.context,t,e,r),n&&o.reject(e)};const f=a.save(null,e);return n?(Promise.resolve(f).catch(t=>o.reject(t)),o):a}subscribe(t,e,r){if("function"==typeof t){const e=()=>t(this);return this.on("update reset sort",e),()=>this.off("update reset sort",e)}return super.subscribe(t,e,r)}parse(t,e){return t}modelId(t){return t[this.model.prototype?.idAttribute||"id"]}values(){return new vi(this,fi)}keys(){return new vi(this,hi)}entries(){return new vi(this,di)}_reset(){this.models=[],this._byId={}}createModel(t,e){return new(0,this.model)(t,e)}_prepareModel(t,e){if(this._isModel(t))return t.collection||(t.collection=this),t;(e=e?Ln(e):{}).collection=this;const r=this.createModel(t,e);return r.validationError?(this.trigger("invalid",this,r.validationError,e),null):r}_removeModels(t,e){const r=[];for(let n=0;n<t.length;n++){const o=this.get(t[n]);if(!o)continue;const i=this.indexOf(o);this.models.splice(i,1),delete this._byId[o.cid];const s=this.modelId(o.attributes);null!=s&&delete this._byId[s],e?.silent||((e=e||{}).index=i,o.trigger("remove",o,this,e)),r.push(o),this._removeReference(o,e)}return r}_isModel(t){return t instanceof ii}_addReference(t,e){this._byId[t.cid]=t;const r=this.modelId(t.attributes);null!=r&&(this._byId[r]=t),t.on("all",this._onModelEvent,this)}_removeReference(t,e){delete this._byId[t.cid];const r=this.modelId(t.attributes);null!=r&&delete this._byId[r],this===t.collection&&delete t.collection,t.off("all",this._onModelEvent,this)}_onModelEvent(t,e,r,n){if(e){if(("add"===t||"remove"===t)&&r!==this)return;if("destroy"===t&&this.remove(e,n),"change"===t){const t=this.modelId(e.previousAttributes()),r=this.modelId(e.attributes);t!==r&&(null!=t&&delete this._byId[t],null!=r&&(this._byId[r]=e))}}this.trigger.apply(this,arguments)}}si=Symbol.iterator;const fi=1,hi=2,di=3;class vi{constructor(t,e){this._collection=t,this._kind=e,this._index=0}next(){if(this._collection){if(this._index<this._collection.length){const t=this._collection.at(this._index);if(this._index++,!t)return{value:void 0,done:!0};let e;if(this._kind===fi)e=t;else{const r=this._collection.modelId(t.attributes);e=this._kind===hi?r:[r,t]}return{value:e,done:!1}}this._collection=void 0}return{value:void 0,done:!0}}[Symbol.iterator](){return this}}const pi={Collection:li,EventEmitter:Qt,Model:ii,sync:Dn,HTTPError:Bn},yi="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global;pi.VERSION="0.0.1";const gi=yi.Skeletor;function bi(){return yi.Skeletor=gi,this}pi.noConflict=bi,yi.Skeletor=pi;const mi=Fn;t.BrowserStorage=mi,t.Collection=li,t.EventEmitter=Qt,t.HTTPError=Bn,t.Model=ii,t.PersistentStorage=Fn,t.default=pi,t.getStorage=Rn,t.noConflict=bi,t.sync=Dn,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
60
|
+
*/function _r(){return br||(br=1,function(t){t.exports=function t(e,r,n){function o(s,a){if(!r[s]){if(!e[s]){if(!a&&gr)return gr(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=gr,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 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=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 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=-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=g,c.race=b},{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={},g=Object.prototype.toString,b="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 S(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 I(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]||z(),t.db){if(!e)return r(t.db);S(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),I(t)}})}function E(t){return A(t,!1)}function x(t){return A(t,!0)}function k(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 N(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 P(t){return u([_(atob(t.data))],{type:t.type})}function R(t){return t&&t.__local_forage_encoded_blob}function T(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 B(t){S(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,E(t).then(function(e){return t.db=e,k(t)?x(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),x(t)}).then(function(){return B(t).then(function(){D(t,e,r,n-1)})}).catch(r);r(o)}}function z(){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=z(),y[r.name]=o),o.forages.push(e),e._initReady||(e._initReady=e.ready,e.ready=T);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,E(r)}).then(function(t){return r.db=t,k(r,e._defaultConfig.version)?x(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,b,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=P(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,b,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=P(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 L(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]"===g.call(e)?j(i.db).then(function(t){return t?e:N(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 U(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 W(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 q(t){var e=this,r=new c(function(t,r){e.ready().then(function(){D(e._dbInfo,b,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,b,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 $(t){var e=this,r=new c(function(t,r){e.ready().then(function(){D(e._dbInfo,b,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 K(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):E(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;S(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,I(r._dbInfo)}}).catch(function(e){throw(O(t,e)||c.resolve()).catch(function(){}),e})}}):i.then(function(e){S(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++)I(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 H={_driver:"asyncStorage",_initStorage:C,_support:a(),iterate:F,getItem:M,setItem:L,removeItem:U,clear:W,length:q,key:J,keys:$,dropInstance:K};function V(){return"function"==typeof openDatabase}var G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Q="~~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=G.indexOf(t[e]),n=G.indexOf(t[e+1]),o=G.indexOf(t[e+2]),i=G.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+=G[r[e]>>2],n+=G[(3&r[e])<<4|r[e+1]>>4],n+=G[(15&r[e+1])<<2|r[e+2]>>6],n+=G[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=Q+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 gt={serialize:pt,deserialize:yt,stringToBuffer:dt,bufferToString:vt};function bt(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){bt(o,r,function(){e._dbInfo=r,t()},function(t,e){n(e)})},n)});return r.serializer=gt,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):bt(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 St(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(St.apply(o,[t,a,r,n-1]));s(e)}})})}).catch(s)});return l(i,r),i}function It(t,e,r){return St.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 Et(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 xt(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 kt(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 Nt(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 Pt(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(Nt(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:V(),iterate:jt,getItem:wt,setItem:It,removeItem:Ot,clear:At,length:Et,key:xt,keys:kt,dropInstance:Pt};function Tt(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(t){return!1}}function Bt(t,e){var r=t.name+"/";return t.storeName!==e.storeName&&(r+=t.storeName+"/"),r}function Dt(){var t="_localforage_support_test";try{return localStorage.setItem(t,!0),localStorage.removeItem(t),!1}catch(t){return!0}}function zt(){return!Dt()||localStorage.length>0}function Ct(t){var e=this,r={};if(t)for(var n in t)r[n]=t[n];return r.keyPrefix=Bt(t,e._defaultConfig),zt()?(e._dbInfo=r,r.serializer=gt,c.resolve()):c.reject()}function Mt(t){var e=this,r=e.ready().then(function(){for(var t=e._dbInfo.keyPrefix,r=localStorage.length-1;r>=0;r--){var n=localStorage.key(r);0===n.indexOf(t)&&localStorage.removeItem(n)}});return l(r,t),r}function Ft(t,e){var r=this;t=h(t);var n=r.ready().then(function(){var e=r._dbInfo,n=localStorage.getItem(e.keyPrefix+t);return n&&(n=e.serializer.deserialize(n)),n});return l(n,e),n}function Lt(t,e){var r=this,n=r.ready().then(function(){for(var e=r._dbInfo,n=e.keyPrefix,o=n.length,i=localStorage.length,s=1,a=0;a<i;a++){var u=localStorage.key(a);if(0===u.indexOf(n)){var c=localStorage.getItem(u);if(c&&(c=e.serializer.deserialize(c)),void 0!==(c=t(c,u.substring(o),s++)))return c}}});return l(n,e),n}function Ut(t,e){var r=this,n=r.ready().then(function(){var e,n=r._dbInfo;try{e=localStorage.key(t)}catch(t){e=null}return e&&(e=e.substring(n.keyPrefix.length)),e});return l(n,e),n}function Wt(t){var e=this,r=e.ready().then(function(){for(var t=e._dbInfo,r=localStorage.length,n=[],o=0;o<r;o++){var i=localStorage.key(o);0===i.indexOf(t.keyPrefix)&&n.push(i.substring(t.keyPrefix.length))}return n});return l(r,t),r}function qt(t){var e=this.keys().then(function(t){return t.length});return l(e,t),e}function Jt(t,e){var r=this;t=h(t);var n=r.ready().then(function(){var e=r._dbInfo;localStorage.removeItem(e.keyPrefix+t)});return l(n,e),n}function $t(t,e,r){var n=this;t=h(t);var o=n.ready().then(function(){void 0===e&&(e=null);var r=e;return new c(function(o,i){var s=n._dbInfo;s.serializer.serialize(e,function(e,n){if(n)i(n);else try{localStorage.setItem(s.keyPrefix+t,e),o(r)}catch(t){"QuotaExceededError"!==t.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==t.name||i(t),i(t)}})})});return l(o,r),o}function Kt(t,e){if(e=d.apply(this,arguments),!(t="function"!=typeof t&&t||{}).name){var r=this.config();t.name=t.name||r.name,t.storeName=t.storeName||r.storeName}var n,o=this;return n=t.name?new c(function(e){t.storeName?e(Bt(t,o._defaultConfig)):e(t.name+"/")}).then(function(t){for(var e=localStorage.length-1;e>=0;e--){var r=localStorage.key(e);0===r.indexOf(t)&&localStorage.removeItem(r)}}):c.reject("Invalid arguments"),l(n,e),n}var Ht={_driver:"localStorageWrapper",_initStorage:Ct,_support:Tt(),iterate:Lt,getItem:Ft,setItem:$t,removeItem:Jt,clear:Mt,length:qt,key:Ut,keys:Wt,dropInstance:Kt},Vt=function(t,e){return t===e||"number"==typeof t&&"number"==typeof e&&isNaN(t)&&isNaN(e)},Gt=function(t,e){for(var r=t.length,n=0;n<r;){if(Vt(t[n],e))return!0;n++}return!1},Qt=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},Xt={},Yt={},Zt={INDEXEDDB:H,WEBSQL:Rt,LOCALSTORAGE:Ht},te=[Zt.INDEXEDDB._driver,Zt.WEBSQL._driver,Zt.LOCALSTORAGE._driver],ee=["dropInstance"],re=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ee),ne={description:"",driver:te.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function oe(t,e){t[e]=function(){var r=arguments;return t.ready().then(function(){return t[e].apply(t,r)})}}function ie(){for(var t=1;t<arguments.length;t++){var e=arguments[t];if(e)for(var r in e)e.hasOwnProperty(r)&&(Qt(e[r])?arguments[0][r]=e[r].slice():arguments[0][r]=e[r])}return arguments[0]}var se=function(){function t(e){for(var r in o(this,t),Zt)if(Zt.hasOwnProperty(r)){var n=Zt[r],i=n._driver;this[r]=i,Xt[i]||this.defineDriver(n)}this._defaultConfig=ie({},ne),this._config=ie({},this._defaultConfig,e),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return t.prototype.config=function(t){if("object"===(void 0===t?"undefined":n(t))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var e in t){if("storeName"===e&&(t[e]=t[e].replace(/\W/g,"_")),"version"===e&&"number"!=typeof t[e])return new Error("Database version must be a number.");this._config[e]=t[e]}return!("driver"in t)||!t.driver||this.setDriver(this._config.driver)}return"string"==typeof t?this._config[t]:this._config},t.prototype.defineDriver=function(t,e,r){var n=new c(function(e,r){try{var n=t._driver,o=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver)return void r(o);for(var i=re.concat("_initStorage"),s=0,a=i.length;s<a;s++){var u=i[s];if((!Gt(ee,u)||t[u])&&"function"!=typeof t[u])return void r(o)}var f=function(){for(var e=function(t){return function(){var e=new Error("Method "+t+" is not implemented by the current driver"),r=c.reject(e);return l(r,arguments[arguments.length-1]),r}},r=0,n=ee.length;r<n;r++){var o=ee[r];t[o]||(t[o]=e(o))}};f();var h=function(r){Xt[n]&&console.info("Redefining LocalForage driver: "+n),Xt[n]=t,Yt[n]=r,e()};"_support"in t?t._support&&"function"==typeof t._support?t._support().then(h,r):h(!!t._support):h(!0)}catch(t){r(t)}});return f(n,e,r),n},t.prototype.driver=function(){return this._driver||null},t.prototype.getDriver=function(t,e,r){var n=Xt[t]?c.resolve(Xt[t]):c.reject(new Error("Driver not found."));return f(n,e,r),n},t.prototype.getSerializer=function(t){var e=c.resolve(gt);return f(e,t),e},t.prototype.ready=function(t){var e=this,r=e._driverSet.then(function(){return null===e._ready&&(e._ready=e._initDriver()),e._ready});return f(r,t,t),r},t.prototype.setDriver=function(t,e,r){var n=this;Qt(t)||(t=[t]);var o=this._getSupportedDrivers(t);function i(){n._config.driver=n.driver()}function s(t){return n._extend(t),i(),n._ready=n._initStorage(n._config),n._ready}function a(t){return function(){var e=0;function r(){for(;e<t.length;){var o=t[e];return e++,n._dbInfo=null,n._ready=null,n.getDriver(o).then(s).catch(r)}i();var a=new Error("No available storage method found.");return n._driverSet=c.reject(a),n._driverSet}return r()}}var u=null!==this._driverSet?this._driverSet.catch(function(){return c.resolve()}):c.resolve();return this._driverSet=u.then(function(){var t=o[0];return n._dbInfo=null,n._ready=null,n.getDriver(t).then(function(t){n._driver=t._driver,i(),n._wrapLibraryMethodsWithReady(),n._initDriver=a(o)})}).catch(function(){i();var t=new Error("No available storage method found.");return n._driverSet=c.reject(t),n._driverSet}),f(this._driverSet,e,r),this._driverSet},t.prototype.supports=function(t){return!!Yt[t]},t.prototype._extend=function(t){ie(this,t)},t.prototype._getSupportedDrivers=function(t){for(var e=[],r=0,n=t.length;r<n;r++){var o=t[r];this.supports(o)&&e.push(o)}return e},t.prototype._wrapLibraryMethodsWithReady=function(){for(var t=0,e=re.length;t<e;t++)oe(this,re[t])},t.prototype.createInstance=function(e){return new t(e)},t}(),ae=new se;e.exports=ae},{3:3}]},{},[4])(4)}(mr)),mr.exports}var wr=yr(_r());function jr(t,e,r){(void 0!==r&&!de(t[e],r)||void 0===r&&!(e in t))&&Oe(t,e,r)}var Sr=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),s=i.length;s--;){var a=i[++n];if(!1===e(o[a],a,o))break}return t};var Ir=Function.prototype,Or=Object.prototype,Ar=Ir.toString,Er=Or.hasOwnProperty,xr=Ar.call(Object);function kr(t){if(!G(t)||"[object Object]"!=g(t))return!1;var e=qe(t);if(null===e)return!0;var r=Er.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Ar.call(r)==xr}function Nr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Pr(t,e,r,n,o,i,s){var a=Nr(t,r),u=Nr(e,r),c=s.get(u);if(c)jr(t,r,c);else{var l,f=i?i(a,u,r+"",t,e,s):void 0,h=void 0===f;if(h){var d=et(u),v=!d&&at(u),p=!d&&!v&&pt(u);f=u,d||v||p?et(a)?f=a:G(l=a)&&nt(l)?f=Ce(a):v?(h=!1,f=ze(u,!0)):p?(h=!1,f=tr(u,!0)):f=[]:kr(u)||tt(u)?(f=a,tt(a)?f=function(t){return xe(t,Pe(t))}(a):b(a)&&!m(a)||(f=or(u))):h=!1}h&&(s.set(u,f),o(f,u,n,i,s),s.delete(u)),jr(t,r,f)}}function Rr(t,e,r,n,o){t!==e&&Sr(e,function(i,s){if(o||(o=new Se),b(i))Pr(t,e,s,r,Rr,n,o);else{var a=n?n(Nr(t,s),i,s+"",t,e,o):void 0;void 0===a&&(a=i),jr(t,s,a)}},Pe)}function Tr(t){return t}var Br=Math.max;function Dr(t,e,r){return e=Br(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Br(n.length-e,0),s=Array(i);++o<i;)s[o]=n[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=n[o];return a[e]=r(s),function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,a)}}function zr(t){return function(){return t}}var Cr=Ie?function(t,e){return Ie(t,"toString",{configurable:!0,enumerable:!1,value:zr(e),writable:!0})}:Tr,Mr=Date.now;var Fr,Lr,Ur,Wr=(Fr=Cr,Lr=0,Ur=0,function(){var t=Mr(),e=16-(t-Ur);if(Ur=t,e>0){if(++Lr>=800)return arguments[0]}else Lr=0;return Fr.apply(void 0,arguments)});function qr(t,e){return Wr(Dr(t,e,Tr),t+"")}function Jr(t,e,r){if(!b(r))return!1;var n=typeof e;return!!("number"==n?nt(r)&&mt(e,r.length):"string"==n&&e in r)&&de(r[e],t)}function $r(t){return qr(function(e,r){var n=-1,o=r.length,i=o>1?r[o-1]:void 0,s=o>2?r[2]:void 0;for(i=t.length>3&&"function"==typeof i?(o--,i):void 0,s&&Jr(r[0],r[1],s)&&(i=o<3?void 0:i,o=1),e=Object(e);++n<o;){var a=r[n];a&&t(e,a,n,i)}return e})}var Kr=$r(function(t,e,r){Rr(t,e,r)}),Hr=$r(function(t,e,r,n){Rr(t,e,r,n)});function Vr(){let t,e=()=>{},r=()=>{};if("function"==typeof Promise.withResolvers){const{promise:n,resolve:o,reject:i}=Promise.withResolvers();t=n,e=o,r=i}else t=new Promise((t,n)=>{e=t,r=n});return Object.assign(t,{isResolved:!1,isPending:!0,isRejected:!1,resolve:e,reject:r}),t.then(e=>(t.isResolved=!0,t.isPending=!1,t.isRejected=!1,e),e=>{throw t.isResolved=!1,t.isPending=!1,t.isRejected=!0,e}),t}const Gr=Math.max,Qr=Math.min;function Xr(t){if("number"==typeof t)return t;if("string"==typeof t){const e=parseFloat(t);return isNaN(e)?0:e}return 0}function Yr(t,e,r={}){let n,o,i,s,a,u,c=0,l=!1,f=r.promise?Vr():null;if("function"!=typeof t)throw new TypeError("Expected a function");function h(e){const i=n,a=o,u=f;return n=o=void 0,c=e,s=t.apply(a,i),r.promise&&(u.resolve(s),f=Vr()),r.promise?u:s}function d(t){const r=t-u;return void 0===u||r>=e||r<0||l&&t-c>=i}function v(){const t=Date.now();if(d(t))return p(t);a=setTimeout(v,function(t){const r=e-(t-u);return l?Qr(r,i-(t-c)):r}(t))}function p(t){return a=void 0,n?h(t):(n=o=void 0,r.promise?f:s)}function y(t,e){if(Array.isArray(t)&&Array.isArray(e))return r?.dedupeArrays?t.concat(e.filter(e=>-1===t.indexOf(e))):t.concat(e)}function g(){const t=Date.now(),i=d(t);var p;if(p=Array.from(arguments),n=n?.length?p.length?r?.concatArrays||r?.dedupeArrays?Hr(n,p,y):Kr(n,p):n:p||[],o=this,u=t,i){if(void 0===a)return function(t){return c=t,a=setTimeout(v,e),r.promise?f:s}(u);if(l)return clearTimeout(a),a=setTimeout(v,e),h(u)}return void 0===a&&(a=setTimeout(v,e)),r.promise?f:s}return e=Xr(e)||0,function(t){const e=typeof t;return null!=t&&("object"===e||"function"===e)}(r)&&(l="maxWait"in r,i=l?Gr(Xr(r.maxWait)||0,e):i),g.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=u=o=a=void 0},g.flush=function(){return void 0===a?s:p(Date.now())},g}function Zr(t,e){e&&t.then(t=>e(null,t),t=>e(t))}function tn(t){return"string"!=typeof t&&(console.warn(`${t} used as a key, but it is not a string.`),t=String(t)),t}function en(t,e){let r=t.name+"/";return t.storeName!==e.storeName&&(r+=t.storeName+"/"),r}const rn={keyPrefix:"",serializer:{serialize:function(t,e){try{e(function(t){return JSON.stringify(t,(t,e)=>e instanceof Date?e.toISOString():e)}(t),null)}catch(t){e("",t)}},deserialize:function(t){return JSON.parse(t)}}};const nn={_driver:"sessionStorageWrapper",_initStorage:function(t){if(rn.keyPrefix=en(t,this._defaultConfig),t)for(const e in t)rn[e]=t[e]},_support:function(){try{if(sessionStorage&&"setItem"in sessionStorage)return!0}catch(t){console.log(t)}return!1}(),iterate:function(t,e){const r=this.ready().then(function(){const e=rn.keyPrefix,r=e.length,n=sessionStorage.length;let o=1;for(let i=0;i<n;i++){const n=sessionStorage.key(i);if(!n||0!==n.indexOf(e))continue;const s=sessionStorage.getItem(n),a=s?rn.serializer.deserialize(s):s,u=t(a,n.substring(r),o++);if(void 0!==u)return u}});return Zr(r,e),r},getItem:function(t,e){t=tn(t);const r=this.ready().then(function(){const e=sessionStorage.getItem(rn.keyPrefix+t);return e?rn.serializer.deserialize(e):null});return Zr(r,e),r},setItem:async function(t,e,r){t=tn(t),await this.ready();const n=e=e??null;return new Promise((o,i)=>{rn.serializer.serialize(e,(e,s)=>{if(s)return i(s),void Zr(Promise.reject(s),r);try{sessionStorage.setItem(rn.keyPrefix+t,e),o(n),Zr(Promise.resolve(n),r)}catch(t){"QuotaExceededError"!==t.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==t.name||console.error("Your sessionStorage capacity is used up."),i(t),Zr(Promise.reject(t),r)}})})},removeItem:function(t,e){t=tn(t);const r=this.ready().then(function(){sessionStorage.removeItem(rn.keyPrefix+t)});return Zr(r,e),r},clear:function(t){const e=this.ready().then(function(){const t=rn.keyPrefix;for(let e=sessionStorage.length-1;e>=0;e--){const r=sessionStorage.key(e);r&&0===r.indexOf(t)&&sessionStorage.removeItem(r)}});return Zr(e,t),e},length:function(t){const e=this.keys().then(function(t){return t.length});return Zr(e,t),e},key:function(t,e){const r=this.ready().then(function(){let e;try{e=sessionStorage.key(t)}catch(t){e=null}return e&&(e=e.substring(rn.keyPrefix.length)),e});return Zr(r,e),r},keys:function(t){const e=this.ready().then(function(){const t=sessionStorage.length,e=[];for(let r=0;r<t;r++){const t=sessionStorage.key(r);t&&0===t.indexOf(rn.keyPrefix)&&e.push(t.substring(rn.keyPrefix.length))}return e});return Zr(e,t),e},dropInstance:function(...t){const e=function(...t){if(t.length&&"function"==typeof t[t.length-1])return t[t.length-1]}(...t);let r="function"!=typeof t[0]&&t[0]||{};if(!r.name){const t=this.config();r.name=r.name||t.name,r.storeName=r.storeName||t.storeName}const n=this;let o;return o=r.name?new Promise(function(t){r.storeName?t(en(r,n._defaultConfig)):t(`${r.name}/`)}).then(function(t){for(let e=sessionStorage.length-1;e>=0;e--){const r=sessionStorage.key(e);r&&0===r.indexOf(t)&&sessionStorage.removeItem(r)}}):Promise.reject(new Error("Invalid arguments")),Zr(o,e),o}};var on,sn={exports:{}};var an,un=(on||(on=1,function(t,e){!function(t,e){function r(t){return r.result?r.result:t&&"function"==typeof t.getSerializer?(r.result=t.getSerializer(),r.result):Promise.reject(new Error("localforage.getSerializer() was not available! localforage v1.4+ is required!"))}function n(t,e){e&&t.then(function(t){e(null,t)},function(t){e(t)})}function o(t,e,r,n){function o(t,e){var r=t||e;return t&&"function"==typeof t||"string"!=typeof r||(t=function(t){return t[r]}),t}var i=[];if("[object Array]"===Object.prototype.toString.call(t)){e=o(e,"key"),r=o(r,"value");for(var s=0,a=t.length;s<a;s++){var u=t[s];i.push(n(e(u),r(u)))}}else for(var c in t)t.hasOwnProperty(c)&&i.push(n(c,t[c]));return i}function i(t,e,r,i){var s=this,a=s.ready().then(function(){return new Promise(function(n,i){var a,u=s._dbInfo,c=u.db.transaction(u.storeName,"readwrite"),l=c.objectStore(u.storeName);function f(t){var e=t.target||this;a=e.error||e.transaction.error,i(a)}c.oncomplete=function(){n(t)},c.onabort=c.onerror=function(t){i(a||t.target)},o(t,e,r,function(t,e){null===e&&(e=void 0),l.put(e,t).onerror=f})})});return n(a,i),a}function s(t,e,i,s){var a=this,u=new Promise(function(n,s){a.ready().then(function(){return r(a)}).then(function(r){var u=a._dbInfo;u.db.transaction(function(a){var c="INSERT OR REPLACE INTO "+u.storeName+" (key, value) VALUES (?, ?)",l=o(t,e,i,function(t,e){return new Promise(function(n,o){r.serialize(e,function(e,r){r?o(r):a.executeSql(c,[t,e],function(){n()},function(t,e){o(e)})})})});Promise.all(l).then(function(){n(t)},s)},function(t){s(t)})}).catch(s)});return n(u,s),u}function a(t,e,r,i){var s=this,a=o(t,e,r,function(t,e){return s.setItem(t,e)}),u=Promise.all(a);return n(u,i),u}function u(t,e,r,n){var o=this,u=o.driver();return u===o.INDEXEDDB?i.call(o,t,e,r,n):u===o.WEBSQL?s.call(o,t,e,r,n):a.call(o,t,e,r,n)}function c(t){var e=Object.getPrototypeOf(t);e&&(e.setItems=u,e.setItems.indexedDB=function(){return i.apply(this,arguments)},e.setItems.websql=function(){return s.apply(this,arguments)},e.setItems.generic=function(){return a.apply(this,arguments)})}var l=c(e="default"in e?e.default:e);t.setItemsGeneric=a,t.localforageSetItems=u,t.extendPrototype=c,t.extendPrototypeResult=l,Object.defineProperty(t,"__esModule",{value:!0})}(e,_r())}(0,sn.exports)),sn.exports),cn={exports:{}};var ln=(an||(an=1,function(t,e){!function(t,e){function r(t){return r.result?r.result:t&&"function"==typeof t.getSerializer?(r.result=t.getSerializer(),r.result):Promise.reject(new Error("localforage.getSerializer() was not available! localforage v1.4+ is required!"))}function n(t,e){return e&&t.then(function(t){e(null,t)},function(t){e(t)}),t}function o(t,e){var r=this.getItem(t).then(function(e){return{key:t,value:e}});return n(r,e),r}function i(t){var e=this,r=new Promise(function(r,n){for(var i=[],s=0,a=t.length;s<a;s++)i.push(o.call(e,t[s]));Promise.all(i).then(function(t){for(var e={},n=0,o=t.length;n<o;n++){var i=t[n];e[i.key]=i.value}r(e)}).catch(n)});return r}function s(){var t={};return this.iterate(function(e,r){t[r]=e}).then(function(){return t})}function a(){return"undefined"!=typeof IDBKeyRange?IDBKeyRange:"undefined"!=typeof webkitIDBKeyRange?webkitIDBKeyRange:"undefined"!=typeof mozIDBKeyRange?mozIDBKeyRange:void 0}e="default"in e?e.default:e;var u=a();function c(t){t=t.slice();var e=this;function r(t,e){return t<e?-1:t>e?1:0}var n=new Promise(function(n,o){e.ready().then(function(){var i,s=e._dbInfo,a=s.db.transaction(s.storeName,"readonly").objectStore(s.storeName),c=t.sort(r),l=u.bound(t[0],t[t.length-1],!1,!1);if("getAll"in a)(i=a.getAll(l)).onsuccess=function(){var t=i.result;void 0===t&&(t=null),n(t)};else{i=a.openCursor(l);var f={},h=0;i.onsuccess=function(){var t=i.result;if(t){for(var e=t.key;e>c[h];)if(++h===c.length)return void n(f);if(e===c[h]){var r=t.value;void 0===r&&(r=null),f[e]=r,t.continue()}else t.continue(c[h])}else n(f)}}i.onerror=function(){o(i.error)}}).catch(o)});return n}function l(t){var e=this,n=new Promise(function(n,o){e.ready().then(function(){return r(e)}).then(function(r){var i=e._dbInfo;i.db.transaction(function(e){for(var s=new Array(t.length),a=0,u=t.length;a<u;a++)s[a]="?";e.executeSql("SELECT * FROM "+i.storeName+" WHERE (key IN ("+s.join(",")+"))",t,function(t,e){for(var o={},i=e.rows,s=0,a=i.length;s<a;s++){var u=i.item(s),c=u.value;c&&(c=r.deserialize(c)),o[u.key]=c}n(o)},function(t,e){o(e)})})}).catch(o)});return n}function f(t,e){var r,o=this;if(arguments.length&&null!==t){var a=o.driver();r=a===o.INDEXEDDB?c.apply(o,arguments):a===o.WEBSQL?l.apply(o,arguments):i.apply(o,arguments)}else r=s.apply(o);return n(r,e),r}function h(t){var e=Object.getPrototypeOf(t);e&&(e.getItems=f,e.getItems.indexedDB=function(){return c.apply(this,arguments)},e.getItems.websql=function(){return l.apply(this,arguments)},e.getItems.generic=function(){return i.apply(this,arguments)})}var d=h(e);t.localforageGetItems=f,t.extendPrototype=h,t.extendPrototypeResult=d,t.getItemsGeneric=i,Object.defineProperty(t,"__esModule",{value:!0})}(e,_r())}(0,cn.exports)),cn.exports),fn=Object.prototype.hasOwnProperty;function hn(t,e){return null!=t&&fn.call(t,e)}var dn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,vn=/^\w*$/;function pn(t,e){if(et(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!It(t))||(vn.test(t)||!dn.test(t)||null!=e&&t in Object(e))}function yn(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var s=t.apply(this,n);return r.cache=i.set(o,s)||i,s};return r.cache=new(yn.Cache||je),r}yn.Cache=je;var gn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,bn=/\\(\\)?/g,mn=function(t){var e=yn(t,function(t){return 500===r.size&&r.clear(),t}),r=e.cache;return e}(function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(gn,function(t,r,n,o){e.push(n?o.replace(bn,"$1"):r||t)}),e});function _n(t,e){return et(t)?t:pn(t,e)?[t]:mn(xt(t))}function wn(t){if("string"==typeof t||It(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function jn(t,e,r){for(var n=-1,o=(e=_n(e,t)).length,i=!1;++n<o;){var s=wn(e[n]);if(!(i=null!=t&&r(t,s)))break;t=t[s]}return i||++n!=o?i:!!(o=null==t?0:t.length)&&rt(o)&&mt(s,o)&&(et(t)||tt(t))}function Sn(t,e,r){var n=-1,o=(e=_n(e,t)).length;for(o||(o=1,t=void 0);++n<o;){var i=null==t?void 0:t[wn(e[n])];void 0===i&&(n=o,i=r),t=m(i)?i.call(t):i}return t}function In(){return(65536*(1+Math.random())|0).toString(16).substring(1)}function On(){const t={isResolved:!1,isPending:!0,isRejected:!1,resolve:null,reject:null},e=new Promise((e,r)=>{t.resolve=e,t.reject=r});return Object.assign(e,t),e.then(function(){e.isResolved=!0,e.isPending=!1,e.isRejected=!1},function(){e.isResolved=!1,e.isPending=!1,e.isRejected=!0}),e}function An(){throw new Error('A "url" property or function must be specified')}function En(t,e,r){const n=e.error;e.error=function(o){n&&n.call(e.context,t,o,e),t.trigger("error",t,o,e),r&&r.reject&&r.reject(o)}}function xn(t,e,r){if(!e)return r();let n=!1;const o=t.success,i=t.error;t.success=(...t)=>(n=!0,o&&o(...t)),t.error=(...t)=>(n=!0,i&&i(...t));const s=r();var a;return null!=(a=s)&&"function"==typeof a.then&&Promise.resolve(s).then(e=>{n||t.success(e)},r=>{n?e.reject(r):t.error(r)}).catch(t=>e.reject(t)),s}const kn={create:"POST",update:"PUT",patch:"PATCH",delete:"DELETE",read:"GET"},Nn=new WeakSet;function Pn(t){const e=t?.constructor;if(!e||Nn.has(e))return;Nn.add(e);const r=e.name;console.warn(`Skeletor: \`browserStorage\` is deprecated and will be removed in a future major version; use \`storage\` instead${r?` (on \`${r}\`)`:""}.`)}function Rn(t){if(!t)return;const e=Sn(t,"storage");if(null!=e)return e;const r=Sn(t,"browserStorage");return null!=r&&Pn(t),r}function Tn(t){const e=Rn(t)||Rn(t.collection);return e?e.sync():Dn}class Bn extends Error{constructor(t,e,r){const n=t.statusText?` ${t.statusText}`:"";super(`${e} ${r} failed with HTTP ${t.status}${n}`),this.name="HTTPError",this.status=t.status,this.response=t}}function Dn(t,e,r={}){const n=kn[t];let o=r.data;null!=o||!e||"create"!==t&&"update"!==t&&"patch"!==t||(o=r.attrs||e.toJSON());let i=r.url||Sn(e,"url")||An();const s={method:n};null!=o&&("GET"===n?i+=(i.includes("?")?"&":"?")+new URLSearchParams(o).toString():(s.body=JSON.stringify(o),s.headers={"Content-Type":"application/json"}));const a=fetch(i,s);return r.xhr=a,e.trigger("request",e,a,{...s,xhr:a}),Promise.resolve(a).then(async t=>{if(!t.ok)throw new Bn(t,n,i);const e=await t.text();return e?JSON.parse(e):null}).then(t=>(r.success?.(t,r),t),t=>{throw r.error?.(t),t})}const zn=ce;wr.defineDriver(he),un.extendPrototype(wr),ln.extendPrototype(wr);const Cn=new Set,Mn=new WeakSet;class Fn{static register(t){Mn.has(t)||(Mn.add(t),Cn.add(new WeakRef(t)))}static flushAll(){for(const t of Cn){const e=t.deref();e?e.flush():Cn.delete(t)}}constructor(t,e,r=!1){if(this.storeReady=!1,this.name=t,"local"===e&&"undefined"!=typeof window&&!window.localStorage)throw new Error("Skeletor.storage: Environment does not support localStorage.");if("session"===e&&"undefined"!=typeof window&&!window.sessionStorage)throw new Error("Skeletor.storage: Environment does not support sessionStorage.");vr(e)?this.storeInitialized=this.initStore(e,r):(this.store=e,r&&(this.store.debouncedSetItems=Yr(t=>this.store.setItems(t),50,{promise:!0})),this.storeInitialized=Promise.resolve()),this.storeInitialized.then(()=>this.storeReady=!0).catch(()=>{})}async initStore(t,e){if("session"===t)await wr.setDriver(nn._driver);else if("local"===t)await wr.config({driver:wr.LOCALSTORAGE});else if("in_memory"===t)await wr.config({driver:zn});else{if("node"===t){const t=Fn.nodeStorage;if(!t)throw new Error("Skeletor.storage: the 'node' storage type is only available in Node.js builds. Import from '@converse/skeletor/node' instead of '@converse/skeletor'.");return this.store=new t(this.name,Fn.nodeStorageDir??void 0),void(e&&(this.store.debouncedSetItems=Yr(t=>this.store.setItems(t),50,{promise:!0})))}if("indexed"!==t)throw new Error("Skeletor.storage: No storage type was specified")}this.store=wr,e&&(this.store.debouncedSetItems=Yr(t=>this.store.setItems(t),50,{promise:!0}))}flush(){this.store.debouncedSetItems&&"function"==typeof this.store.debouncedSetItems.flush&&this.store.debouncedSetItems.flush()}async clear(){await this.storeInitialized,await this.store.removeItem(this.name).catch(t=>console.error(t));const t=new RegExp(`^${this.name}-`),e=(await this.store.keys()).filter(e=>t.test(e));await Promise.all(e.map(t=>this.store.removeItem(t).catch(t=>console.error(t))))}sync(){const t=this;async function e(e,r,n){let o,i,s,a;const u=n.collection??r.collection;["patch","update"].includes(e)&&(a=dr(r.attributes,5)),t.storeReady||await t.storeInitialized;try{const i=r.attributes;switch(e){case"read":o=void 0!==r.id?await t.find(r):await t.findAll();break;case"create":o=await t.create(r,n);break;case"patch":case"update":n.wait&&(r.attributes=a),s=t.update(r),n.wait&&(r.attributes=i),o=await s;break;case"delete":o=await t.destroy(r,u)}}catch(e){const r=await t.getStorageSize();i=22===e.code&&0===r?new Error("Private browsing is unsupported"):e instanceof Error?e:new Error(e?.message??String(e))}if(i)n?.error?.(i);else if(n?.success){const t="read"===e?o??null:null;n.success(t,n)}}return e.__name__="localSync",e}removeCollectionReference(t,e){if(!e)return;const r=e.filter(e=>e.id!==t.id).map(t=>this.getItemName(t.id));return this.store.setItem(this.name,r)}addCollectionReference(t,e){if(!e)return;const r=e.map(t=>this.getItemName(t.id)),n=this.getItemName(t.id);return r.includes(n)||r.push(n),this.store.setItem(this.name,r)}getCollectionReferenceData(t){if(!t.collection)return{};const e=t.collection.map(t=>this.getItemName(t.id)),r=this.getItemName(t.id);e.includes(r)||e.push(r);const n={};return n[this.name]=e,n}async save(t){if(this.store.setItems){const e={};return e[this.getItemName(t.id)]=t.toJSON(),Object.assign(e,this.getCollectionReferenceData(t)),this.store.debouncedSetItems?this.store.debouncedSetItems(e):this.store.setItems(e)}{const e=this.getItemName(t.id),r=await this.store.setItem(e,t.toJSON());return await this.addCollectionReference(t,t.collection),r}}create(t,e){return t.id||(t.id=In()+In()+"-"+In()+"-"+In()+"-"+In()+"-"+In()+In()+In(),t.set(t.idAttribute,t.id,e)),this.save(t)}update(t){return this.save(t)}find(t){return this.store.getItem(this.getItemName(t.id))}async findAll(){const t=await this.store.getItem(this.name);if(t?.length){const e=await this.store.getItems(t);return Object.values(e)}return[]}async destroy(t,e){return await this.flush(),await this.store.removeItem(this.getItemName(t.id)),await this.removeCollectionReference(t,e),t}async getStorageSize(){return await this.store.length()}getItemName(t){return this.name+"-"+t}}Fn.nodeStorage=null,Fn.nodeStorageDir=null,Fn.sessionStorageInitialized=wr.defineDriver(nn),Fn.localForage=wr;function Ln(t){return dr(t,4)}function Un(t,e,r,n){for(var o=-1,i=null==t?0:t.length;++o<i;){var s=t[o];e(n,s,r(s),t)}return n}function Wn(t,e){return t&&Sr(t,e,jt)}var qn,Jn=(qn=Wn,function(t,e){if(null==t)return t;if(!nt(t))return qn(t,e);for(var r=t.length,n=-1,o=Object(t);++n<r&&!1!==e(o[n],n,o););return t});function $n(t,e,r,n){return Jn(t,function(t,o,i){e(n,t,r(t),i)}),n}function Kn(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new je;++e<r;)this.add(t[e])}function Hn(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function Vn(t,e){return t.has(e)}Kn.prototype.add=Kn.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Kn.prototype.has=function(t){return this.__data__.has(t)};function Gn(t,e,r,n,o,i){var s=1&r,a=t.length,u=e.length;if(a!=u&&!(s&&u>a))return!1;var c=i.get(t),l=i.get(e);if(c&&l)return c==e&&l==t;var f=-1,h=!0,d=2&r?new Kn:void 0;for(i.set(t,e),i.set(e,t);++f<a;){var v=t[f],p=e[f];if(n)var y=s?n(p,v,f,e,t,i):n(v,p,f,t,e,i);if(void 0!==y){if(y)continue;h=!1;break}if(d){if(!Hn(e,function(t,e){if(!Vn(d,e)&&(v===t||o(v,t,r,n,i)))return d.push(e)})){h=!1;break}}else if(v!==p&&!o(v,p,r,n,i)){h=!1;break}}return i.delete(t),i.delete(e),h}function Qn(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function Xn(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}var Yn=l?l.prototype:void 0,Zn=Yn?Yn.valueOf:void 0;var to=Object.prototype.hasOwnProperty;var eo="[object Arguments]",ro="[object Array]",no="[object Object]",oo=Object.prototype.hasOwnProperty;function io(t,e,r,n,o,i){var s=et(t),a=et(e),u=s?ro:V(t),c=a?ro:V(e),l=(u=u==eo?no:u)==no,f=(c=c==eo?no:c)==no,h=u==c;if(h&&at(t)){if(!at(e))return!1;s=!0,l=!1}if(h&&!l)return i||(i=new Se),s||pt(t)?Gn(t,e,r,n,o,i):function(t,e,r,n,o,i,s){switch(r){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!i(new Ge(t),new Ge(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return de(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Qn;case"[object Set]":var u=1&n;if(a||(a=Xn),t.size!=e.size&&!u)return!1;var c=s.get(t);if(c)return c==e;n|=2,s.set(t,e);var l=Gn(a(t),a(e),n,o,i,s);return s.delete(t),l;case"[object Symbol]":if(Zn)return Zn.call(t)==Zn.call(e)}return!1}(t,e,u,r,n,o,i);if(!(1&r)){var d=l&&oo.call(t,"__wrapped__"),v=f&&oo.call(e,"__wrapped__");if(d||v){var p=d?t.value():t,y=v?e.value():e;return i||(i=new Se),o(p,y,r,n,i)}}return!!h&&(i||(i=new Se),function(t,e,r,n,o,i){var s=1&r,a=Ke(t),u=a.length;if(u!=Ke(e).length&&!s)return!1;for(var c=u;c--;){var l=a[c];if(!(s?l in e:to.call(e,l)))return!1}var f=i.get(t),h=i.get(e);if(f&&h)return f==e&&h==t;var d=!0;i.set(t,e),i.set(e,t);for(var v=s;++c<u;){var p=t[l=a[c]],y=e[l];if(n)var g=s?n(y,p,l,e,t,i):n(p,y,l,t,e,i);if(!(void 0===g?p===y||o(p,y,r,n,i):g)){d=!1;break}v||(v="constructor"==l)}if(d&&!v){var b=t.constructor,m=e.constructor;b==m||!("constructor"in t)||!("constructor"in e)||"function"==typeof b&&b instanceof b&&"function"==typeof m&&m instanceof m||(d=!1)}return i.delete(t),i.delete(e),d}(t,e,r,n,o,i))}function so(t,e,r,n,o){return t===e||(null==t||null==e||!G(t)&&!G(e)?t!=t&&e!=e:io(t,e,r,n,so,o))}function ao(t,e,r,n){var o=r.length,i=o;if(null==t)return!i;for(t=Object(t);o--;){var s=r[o];if(s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++o<i;){var a=(s=r[o])[0],u=t[a],c=s[1];if(s[2]){if(void 0===u&&!(a in t))return!1}else if(!so(c,u,3,n,new Se))return!1}return!0}function uo(t){return t==t&&!b(t)}function co(t){for(var e=jt(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,uo(o)]}return e}function lo(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}function fo(t){var e=co(t);return 1==e.length&&e[0][2]?lo(e[0][0],e[0][1]):function(r){return r===t||ao(r,0,e)}}function ho(t,e){for(var r=0,n=(e=_n(e,t)).length;null!=t&&r<n;)t=t[wn(e[r++])];return r&&r==n?t:void 0}function vo(t,e){return null!=t&&e in Object(t)}function po(t,e){return null!=t&&jn(t,e,vo)}function yo(t,e){return pn(t)&&uo(e)?lo(wn(t),e):function(r){var n=function(t,e,r){var n=null==t?void 0:ho(t,e);return void 0===n?r:n}(r,t);return void 0===n&&n===e?po(r,t):so(e,n,3)}}function go(t){return pn(t)?function(t){return function(e){return null==e?void 0:e[t]}}(wn(t)):function(t){return function(e){return ho(e,t)}}(t)}function bo(t){return"function"==typeof t?t:null==t?Tr:"object"==typeof t?et(t)?yo(t[0],t[1]):fo(t):go(t)}function mo(t,e){return function(e,r){return(et(e)?Un:$n)(e,t,bo(r),{})}}var _o=Object.prototype.hasOwnProperty,wo=mo(function(t,e,r){_o.call(t,r)?++t[r]:Oe(t,r,1)}),jo=Object.prototype.hasOwnProperty,So=mo(function(t,e,r){jo.call(t,r)?t[r].push(e):Oe(t,r,[e])}),Io=mo(function(t,e,r){Oe(t,r,e)});var Oo=l?l.isConcatSpreadable:void 0;function Ao(t){return et(t)||tt(t)||!!(Oo&&t&&t[Oo])}function Eo(t,e,r,n,o){var i=-1,s=t.length;for(r||(r=Ao),o||(o=[]);++i<s;){var a=t[i];r(a)?We(o,a):o[o.length]=a}return o}function xo(t,e){if(t!==e){var r=void 0!==t,n=null===t,o=t==t,i=It(t),s=void 0!==e,a=null===e,u=e==e,c=It(e);if(!a&&!c&&!i&&t>e||i&&s&&u&&!a&&!c||n&&s&&u||!r&&u||!o)return 1;if(!n&&!i&&!c&&t<e||c&&r&&o&&!n&&!i||a&&r&&o||!s&&o||!u)return-1}return 0}function ko(t,e,r){e=e.length?St(e,function(t){return et(t)?function(e){return ho(e,1===t.length?t[0]:t)}:t}):[Tr];var n=-1;e=St(e,ct(bo));var o=function(t,e){var r=-1,n=nt(t)?Array(t.length):[];return Jn(t,function(t,o,i){n[++r]=e(t,o,i)}),n}(t,function(t,r,o){return{criteria:St(e,function(e){return e(t)}),index:++n,value:t}});return function(t,e){var r=t.length;for(t.sort(e);r--;)t[r]=t[r].value;return t}(o,function(t,e){return function(t,e,r){for(var n=-1,o=t.criteria,i=e.criteria,s=o.length,a=r.length;++n<s;){var u=xo(o[n],i[n]);if(u)return n>=a?u:u*("desc"==r[n]?-1:1)}return t.index-e.index}(t,e,r)})}var No=qr(function(t,e){if(null==t)return[];var r=e.length;return r>1&&Jr(t,e[0],e[1])?e=[]:r>2&&Jr(e[0],e[1],e[2])&&(e=[e[0]]),ko(t,Eo(e),[])});const Po=new Map,Ro=new Set,To=new Map;let Bo=!1;function Do(t,e){const r=Promise.resolve(e()).catch(e=>{console.error("Skeletor autoSync save error:",e),t?.trigger?.("error",t,e)});let n;Ro.add(r),t&&(n=To.get(t),n||(n=new Set,To.set(t,n)),n.add(r)),r.finally(()=>{Ro.delete(r),n&&(n.delete(r),0===n.size&&To.delete(t))})}function zo(t){if(Bo||"undefined"==typeof window)return;Bo=!0;const e=()=>function({storage:t,wait:e=!1}={}){for(const[t,{timerId:e,run:r}]of Po.entries())clearTimeout(e),Do(t,r);if(Po.clear(),t&&t.flushAll(),e)return Promise.all([...Ro]).then(()=>{})}({storage:t});window.addEventListener("pagehide",e),window.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&e()})}var Co=Object.prototype,Mo=Co.hasOwnProperty,Fo=qr(function(t,e){t=Object(t);var r=-1,n=e.length,o=n>2?e[2]:void 0;for(o&&Jr(e[0],e[1],o)&&(n=1);++r<n;)for(var i=e[r],s=Pe(i),a=-1,u=s.length;++a<u;){var c=s[a],l=t[c];(void 0===l||de(l,Co[c])&&!Mo.call(t,c))&&(t[c]=i[c])}return t});var Lo=qr(function(t,e){return function(t,e,r){if("function"!=typeof t)throw new TypeError("Expected a function");return setTimeout(function(){t.apply(void 0,r)},e)}(t,1,e)});var Uo,Wo,qo=Object.prototype.toString,Jo=(Uo=function(t,e,r){null!=e&&"function"!=typeof e.toString&&(e=qo.call(e)),t[e]=r},Wo=zr(Tr),function(t,e){return function(t,e,r,n){return Wn(t,function(t,o,i){e(n,r(t),o,i)}),n}(t,Uo,Wo(e),{})});function $o(t,e){return so(t,e)}function Ko(t,e){return e.length<2?t:ho(t,function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n<o;)i[n]=t[n+e];return i}(e,0,-1))}var Ho=Object.prototype.hasOwnProperty;function Vo(t,e){var r=-1,n=(e=_n(e,t)).length;if(!n)return!0;for(;++r<n;){var o=wn(e[r]);if("__proto__"===o&&!Ho.call(t,"__proto__"))return!1;if(("constructor"===o||"prototype"===o)&&r<n-1)return!1}var i=Ko(t,e);return null==i||delete i[wn(function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}(e))]}function Go(t){return kr(t)?void 0:t}function Qo(t){return(null==t?0:t.length)?Eo(t):[]}function Xo(t){return Wr(Dr(t,void 0,Qo),t+"")}var Yo=Xo(function(t,e){var r={};if(null==t)return r;var n=!1;e=St(e,function(e){return e=_n(e,t),n||(n=e.length>1),e}),xe(t,He(t),r),n&&(r=dr(r,7,Go));for(var o=e.length;o--;)Vo(r,e[o]);return r});function Zo(t,e,r,n){if(!b(t))return t;for(var o=-1,i=(e=_n(e,t)).length,s=i-1,a=t;null!=a&&++o<i;){var u=wn(e[o]),c=r;if("__proto__"===u||"constructor"===u||"prototype"===u)return t;if(o!=s){var l=a[u];void 0===(c=void 0)&&(c=b(l)?l:mt(e[o+1])?[]:{})}Ee(a,u,c),a=a[u]}return t}function ti(t,e){return function(t,e,r){for(var n=-1,o=e.length,i={};++n<o;){var s=e[n],a=ho(t,s);r(a,s)&&Zo(i,_n(s,t),a)}return i}(t,e,function(e,r){return po(t,r)})}var ei=Xo(function(t,e){return null==t?{}:ti(t,e)});const ri=new WeakMap;function ni(t){let e=ri.get(t);return e||(e={state:"constructing"},ri.set(t,e)),e}function oi(t,e,r,n,o,i){const s=n.fn(t);$o(e.computedCache[r],s)||(e.computedCache[r]=s,o||(t.changed[r]=s,t.trigger("change:"+r,t,s,i)))}class ii extends Xt{constructor(t,e){super(),this._changing=!1,this._pending=!1,this._url="",this.changed={},this.validationError=null;const r=ni(this);let n=t||{};e=e||{},this.preinitialize.apply(this,arguments),this.cid=Nt(this.cidPrefix),this.attributes={},e.collection&&(this.collection=e.collection),e.parse&&(n=this.parse(n,e)||{});const o=Sn(this,"defaults");n=Fo(Object.assign({},o,n),o),this.set(n,e),function(t,e){const r=Sn(t,"computed");if(r&&!gt(r)){e.computedDefs=r,e.computedCache={};for(const[n,o]of Object.entries(r))e.computedCache[n]=o.fn(t)}}(this,r),this.attrs=new Proxy(this.attributes,{get:(t,e)=>{const n=r.computedCache;return"symbol"!=typeof e&&n&&e in n?n[e]:this.attributes[e]},set:(t,e,r)=>(this.set(e,r),!0)}),this.initialize.apply(this,arguments),this.changed={},this.autoSync?Rn(this)&&!this.isNew()?(r.state="hydrating",this.hydrated=async function(t,e){zo(Fn);try{await t.fetch({fromStorage:!0,promise:!0})}finally{e.state="ready"}}(this,r)):(r.state="ready",this.hydrated=Promise.resolve()):r.state="ready"}get storage(){return this._storage}set storage(t){this._storage=t,Fn.register(t)}get browserStorage(){return this._storage}set browserStorage(t){Pn(this),this.storage=t}get autoSync(){return!1}get autoSyncDelay(){return 100}get idAttribute(){return"id"}get cidPrefix(){return"c"}preinitialize(...t){}initialize(t,e){}validate(t,e){return null}defaults(){return{}}get computed(){return{}}toJSON(){return Ln(this.attributes)}sync(t,e,r){return Tn(e)(t,e,r)}get(t){const e=ni(this).computedCache;return e&&t in e?e[t]:this.attributes[t]}keys(){return Object.keys(this.attributes)}values(){return Object.values(this.attributes)}pairs(){return this.entries()}entries(){return Object.entries(this.attributes)}invert(){return Jo(this.attributes)}pick(...t){return 1===t.length&&Array.isArray(t[0])&&(t=t[0]),ei(this.attributes,t)}omit(...t){return 1===t.length&&Array.isArray(t[0])&&(t=t[0]),Yo(this.attributes,t)}isEmpty(){return gt(this.attributes)}has(t){return null!=this.get(t)}matches(t){return"function"==typeof t?!!t(this.attributes):(e=this.attributes)===(r=t)||ao(e,0,co(r));var e,r}set(t,e,r){if(null==t)return this;let n;"object"==typeof t?(n=t,r=e):(n={},n[t]=e),r=r||{};const o=ni(this);if(this.autoSync&&"hydrating"===o.state&&!r.fromStorage)throw new Error("Skeletor: set() called on an autoSync model before hydration resolved. Await model.hydrated first.");if(!this._validate(n,r))return null;const i=r.unset,s=r.silent,a=[],u=this._changing;this._changing=!0,u||(this._previousAttributes=Ln(this.attributes),this.changed={});const c=this.attributes,l=this.changed,f=this._previousAttributes;for(const t in n)e=n[t],$o(c[t],e)||a.push(t),$o(f[t],e)?delete l[t]:l[t]=e,i?delete c[t]:c[t]=e;if(this.idAttribute in n&&(this.id=this.get(this.idAttribute)),!s){a.length&&(this._pending=r);for(let t=0;t<a.length;t++)this.trigger("change:"+a[t],this,c[a[t]],r)}if(a.length&&o.computedDefs)for(const[t,e]of Object.entries(o.computedDefs))e.deps.some(t=>a.includes(t))&&oi(this,o,t,e,s,r);if(u)return this;if(!s)for(;this._pending;)r=this._pending,this._pending=!1,this.trigger("change",this,r);return this._pending=!1,this._changing=!1,"ready"===o.state&&this.autoSync&&Rn(this)&&a.length&&!r.fromStorage&&!r.noAutoSave&&function(t,e,r){const n=Po.get(t);n&&clearTimeout(n.timerId);const o=setTimeout(()=>{Po.delete(t),Do(t,e)},r);Po.set(t,{timerId:o,run:e})}(this,()=>this.save(null,{noAutoSave:!0}),this.autoSyncDelay),this}unset(t,e){return this.set(t,void 0,Object.assign({},e,{unset:!0}))}clear(t){const e={};for(const t in this.attributes)e[t]=void 0;return this.set(e,Object.assign({},t,{unset:!0}))}hasChanged(t){return null==t?!gt(this.changed):(e=this.changed,r=t,null!=e&&jn(e,r,hn));var e,r}changedAttributes(t){if(!t)return!!this.hasChanged()&&Ln(this.changed);const e=this._changing?this._previousAttributes:this.attributes,r={};let n=!1;for(const o in t){const i=t[o];$o(e[o],i)||(r[o]=i,n=!0)}return!!n&&r}previous(t){return null!=t&&this._previousAttributes?this._previousAttributes[t]:null}previousAttributes(){return this._previousAttributes?Ln(this._previousAttributes):void 0}fetch(t={}){const e=(t=Object.assign({parse:!0},t)).success,r=t.promise?On():void 0;t.success=n=>{const o=t.parse?this.parse(n,t):n;if(!this.set(o,Object.assign({},t,{fromStorage:!0})))return r&&r.reject(this.validationError),!1;e&&e.call(t.context,this,n,t),this.trigger("sync",this,n,t),r&&r.resolve(n)},En(this,t,r);const n=xn(t,r,()=>this.sync("read",this,t));return r??n}save(t,e,r){let n;null==t||"object"==typeof t?(n=t,r=e):(n={},n[t]=e);const o=(r=Object.assign({validate:!0,parse:!0},r)).wait,i=r.promise,s=i?On():void 0;if(!(n&&!o?!!this.set(n,r):this._validate(n||{},r)))return!!s&&(s.reject(this.validationError),s);const a=r.success,u=r.error,c=this.attributes;r.success=t=>{this.attributes=c;let e=r.parse?this.parse(t,r):t;if(o&&(e=Object.assign({},n,e)),e&&!this.set(e,r))return i&&s.reject(this.validationError),!1;a&&a.call(r.context,this,t,r),this.trigger("sync",this,t,r),i&&s.resolve()},r.error=(t,e,r)=>{u&&u.call(r.context,t,e,r),i&&s.reject(e)},En(this,r),n&&o&&(this.attributes=Object.assign({},c,n));const l=this.isNew()?"create":r.patch?"patch":"update";"patch"!==l||r.attrs||(r.attrs=n);const f=xn(r,s,()=>this.sync(l,this,r));return this.attributes=c,s??f}destroy(t){!function(t){const e=Po.get(t);e&&(clearTimeout(e.timerId),Po.delete(t))}(this);const e=(t=t?Ln(t):{}).success,r=t.wait,n=()=>{this.stopListening(),this.trigger("destroy",this,this.collection,t)};t.success=o=>{r&&n(),e&&e.call(t.context,this,o,t),this.isNew()||this.trigger("sync",this,o,t)};const o=function(t){const e=To.get(t);return e&&0!==e.size?Promise.all([...e]).then(()=>{}):null}(this);o&&this.collection&&(t.collection=this.collection);let i=!1;return this.isNew()?Lo(t.success):(En(this,t),i=o?o.then(()=>this.sync("delete",this,t)):this.sync("delete",this,t)),r||n(),i}get urlRoot(){return this._urlRoot}set urlRoot(t){this._urlRoot=t}get url(){if(this._url)return this._url;const t=Sn(this,"urlRoot")||Sn(this.collection,"url")||An();if(this.isNew())return t;const e=this.get(this.idAttribute);return t.replace(/[^\/]$/,"$&/")+encodeURIComponent(String(e))}set url(t){this._url=t}parse(t,e){return t}isNew(){return!this.has(this.idAttribute)}isValid(t){return this._validate({},Object.assign({},t,{validate:!0}))}subscribe(t,e,r){if("function"==typeof t){const e=e=>t(e,this.changed);return this.on("change",e),()=>this.off("change",e)}return super.subscribe(t,e,r)}_validate(t,e){if(!e?.validate||!this.validate)return!0;t=Object.assign({},this.attributes,t);const r=this.validationError=this.validate(t,e)||null;return!r||(this.trigger("invalid",this,r,Object.assign(e,{validationError:r})),!1)}}var si;const ai={add:!0,remove:!0,merge:!0},ui={add:!0,remove:!1};function ci(t){if(m(t))return t;if(vr(t))return e=>e.get(t);const e=fo(dr(t,1));return t=>e(t.attributes)}class li extends Xt{constructor(t,e){super(),this._url="",this[si]=this.values,e=e||{},this.preinitialize.apply(this,arguments),e.model&&(this.model=e.model),void 0!==e.comparator&&(this.comparator=e.comparator),this._reset(),this.initialize.apply(this,arguments),t&&this.reset(t,Object.assign({silent:!0},e)),this[Symbol.iterator]=this.values,this.autoSync&&(this.hydrated=Rn(this)?async function(t){zo(Fn),await t.fetch({fromStorage:!0,promise:!0})}(this):Promise.resolve())}get storage(){return this._storage}set storage(t){this._storage=t,Fn.register(t)}get browserStorage(){return this._storage}set browserStorage(t){Pn(this),this.storage=t}get autoSync(){return!1}get length(){return this.models.length}get url(){return this._url}set url(t){this._url=t}preinitialize(...t){}initialize(...t){}toJSON(){return this.map(function(t){return t.toJSON()})}sync(t,e,r){return Tn(this)(t,e,r)}add(t,e){return this.set(t,Object.assign({merge:!1},e,ui))}remove(t,e){e=Object.assign({},e);const r=!Array.isArray(t),n=r?[t]:t.slice(),o=this._removeModels(n,e);return!e.silent&&o.length&&(e.changes={added:[],merged:[],removed:o},this.trigger("update",this,e)),r?o[0]:o}set(t,e){if(null==t)return;(e=Object.assign({},ai,e)).parse&&!this._isModel(t)&&(t=this.parse(t,e)||[]);const r=!Array.isArray(t);t=r?[t]:t.slice();let n=e.at;null!=n&&(n=+n),n>this.length&&(n=this.length),n<0&&(n+=this.length+1);const o=[],i=[],s=[],a=[],u={},c=e.add,l=e.merge,f=e.remove;let h=!1;const d=this.comparator&&null==n&&!1!==e.sort,v=vr(this.comparator)?this.comparator:null;let p,y;for(y=0;y<t.length;y++){p=t[y];const r=this.get(p);if(r){if(l&&p!==r){let t=this._isModel(p)?p.attributes:p;e.parse&&(t=r.parse(t,e)),r.set(t,e),s.push(r),d&&!h&&(h=r.hasChanged(v))}u[r.cid]||(u[r.cid]=!0,o.push(r)),t[y]=r}else c&&(p=t[y]=this._prepareModel(p,e),p&&(i.push(p),this._addReference(p,e),u[p.cid]=!0,o.push(p)))}if(f){for(y=0;y<this.length;y++)p=this.models[y],u[p.cid]||a.push(p);a.length&&this._removeModels(a,e)}let g=!1;const b=!d&&c&&f;if(o.length&&b)g=this.length!==o.length||this.models.some((t,e)=>t!==o[e]),this.models.length=0,this.models.splice(0,0,...o);else if(i.length){d&&(h=!0);let t=n??this.length;t=Math.min(Math.max(t,0),this.models.length),this.models.splice(t,0,...i)}if(h&&this.sort({silent:!0}),!e.silent){for(y=0;y<i.length;y++)null!=n&&(e.index=n+y),p=i[y],p.trigger("add",p,this,e);(h||g)&&this.trigger("sort",this,e),(i.length||a.length||s.length)&&(e.changes={added:i,removed:a,merged:s},this.trigger("update",this,e))}return r?t[0]:t}async clearStore(t={},e=()=>!0){await Promise.all(this.models.filter(e).map(e=>new Promise(r=>{e.destroy(Object.assign(t,{success:r,error:(t,e)=>{console.error(e),r()}}))}))),await(Rn(this)?.clear()),this.reset()}reset(t,e){e=e?Ln(e):{};for(let t=0;t<this.models.length;t++)this._removeReference(this.models[t],e);return e.previousModels=this.models,this._reset(),t=this.add(t,Object.assign({silent:!0},e)),e.silent||this.trigger("reset",this,e),t}push(t,e){return this.add(t,Object.assign({at:this.length},e))}pop(t){const e=this.at(this.length-1);return this.remove(e,t)}unshift(t,e){return this.add(t,Object.assign({at:0},e))}shift(t){const e=this.at(0);return this.remove(e,t)}slice(t,e){return this.models.slice(t,e)}filter(t,e){return this.models.filter(ci(t),e)}every(t){return m(t)?this.models.every(e=>t(e.attributes)):this.models.every(ci(t))}difference(t){return this.models.filter(e=>!t.includes(e))}max(){return Math.max.apply(Math,this.models)}min(){return Math.min.apply(Math,this.models)}drop(t=1){return this.models.slice(t)}some(t){return m(t)?this.models.some(e=>t(e.attributes)):this.models.some(ci(t))}sortBy(t){return No(this.models,ci(t))}isEmpty(){return!this.models.length}keyBy(t){return Io(this.models,t)}each(t,e){return this.forEach(t,e)}forEach(t,e){return this.models.forEach(t,e)}includes(t){return this.models.includes(t)}size(){return this.models.length}countBy(t){return wo(this.models,ci(t))}groupBy(t){return So(this.models,ci(t))}indexOf(t,e){return this.models.indexOf(t,e)}findLastIndex(t,e){return this.models.findLastIndex(ci(t),e)}lastIndexOf(t,e){return this.models.lastIndexOf(t,e)}findIndex(t){return this.models.findIndex(ci(t))}last(){const t=null==this.models?0:this.models.length;return t?this.models[t-1]:void 0}head(){return this.models[0]}first(){return this.head()}map(t,e){return this.models.map(ci(t),e)}reduce(t,e){return this.models.reduce(t,e||this.models[0])}reduceRight(t,e){return this.models.reduceRight(t,e||this.models[0])}toArray(){return Array.from(this.models)}get(t){if(null!=t)return this._byId[t]||this._byId[this.modelId(this._isModel(t)?t.attributes:t)]||t.cid&&this._byId[t.cid]}has(t){return null!=this.get(t)}at(t){return t<0&&(t+=this.length),this.models[t]}where(t,e){return this[e?"find":"filter"](t)}findWhere(t){return this.where(t,!0)}find(t,e){return this.models.find(ci(t),e)}sort(t){let e=this.comparator;if(!e)throw new Error("Cannot sort a set without a comparator");t=t||{};const r=m(e)?e.length:0;return m(e)&&(e=e.bind(this)),1===r||vr(e)?this.models=this.sortBy(e):this.models.sort(e),t.silent||this.trigger("sort",this,t),this}pluck(t){return this.map(t+"")}fetch(t){const e=(t=Object.assign({parse:!0},t)).success,r=this,n=t.promise?On():void 0;t.success=function(o){const i=t.reset?"reset":"set";r[i](o,Object.assign({},t,{fromStorage:!0})),e&&e.call(t.context,r,o,t),r.trigger("sync",r,o,t),n&&n.resolve()},En(this,t,n);const o=xn(t,n,()=>this.sync("read",this,t));return n??o}create(t,e){const r=(e=e?Ln(e):{}).wait,n=e.promise,o=n&&On();let i;const s=(t,e)=>i=e;n&&this.on("invalid",s);const a=this._prepareModel(t,e);if(n&&this.off("invalid",s),!a)return n?(o.reject(i),o):null;r||this.add(a,e);const u=this,c=e.success,l=e.error;e.success=function(t,e,i){r&&u.add(t,i),c&&c.call(i.context,t,e,i),n&&o.resolve(t)},e.error=function(t,e,r){l&&l.call(r.context,t,e,r),n&&o.reject(e)};const f=a.save(null,e);return n?(Promise.resolve(f).catch(t=>o.reject(t)),o):a}subscribe(t,e,r){if("function"==typeof t){const e=()=>t(this);return this.on("update reset sort",e),()=>this.off("update reset sort",e)}return super.subscribe(t,e,r)}parse(t,e){return t}modelId(t){return t[(this.model??ii).prototype?.idAttribute||"id"]}values(){return new vi(this,fi)}keys(){return new vi(this,hi)}entries(){return new vi(this,di)}_reset(){this.models=[],this._byId={}}createModel(t,e){return new(this.model??ii)(t,e)}_prepareModel(t,e){if(this._isModel(t))return t.collection||(t.collection=this),t;(e=e?Ln(e):{}).collection=this;const r=this.createModel(t,e);return r.validationError?(this.trigger("invalid",this,r.validationError,e),null):r}_removeModels(t,e){const r=[];for(let n=0;n<t.length;n++){const o=this.get(t[n]);if(!o)continue;const i=this.indexOf(o);this.models.splice(i,1),delete this._byId[o.cid];const s=this.modelId(o.attributes);null!=s&&delete this._byId[s],e?.silent||((e=e||{}).index=i,o.trigger("remove",o,this,e)),r.push(o),this._removeReference(o,e)}return r}_isModel(t){return t instanceof ii}_addReference(t,e){this._byId[t.cid]=t;const r=this.modelId(t.attributes);null!=r&&(this._byId[r]=t),t.on("all",this._onModelEvent,this)}_removeReference(t,e){delete this._byId[t.cid];const r=this.modelId(t.attributes);null!=r&&delete this._byId[r],this===t.collection&&delete t.collection,t.off("all",this._onModelEvent,this)}_onModelEvent(t,e,r,n){if(e){if(("add"===t||"remove"===t)&&r!==this)return;if("destroy"===t&&this.remove(e,n),"change"===t){const t=this.modelId(e.previousAttributes()),r=this.modelId(e.attributes);t!==r&&(null!=t&&delete this._byId[t],null!=r&&(this._byId[r]=e))}}this.trigger.apply(this,arguments)}}si=Symbol.iterator;const fi=1,hi=2,di=3;class vi{constructor(t,e){this._collection=t,this._kind=e,this._index=0}next(){if(this._collection){if(this._index<this._collection.length){const t=this._collection.at(this._index);if(this._index++,!t)return{value:void 0,done:!0};let e;if(this._kind===fi)e=t;else{const r=this._collection.modelId(t.attributes);e=this._kind===hi?r:[r,t]}return{value:e,done:!1}}this._collection=void 0}return{value:void 0,done:!0}}[Symbol.iterator](){return this}}const pi={Collection:li,EventEmitter:Qt,Model:ii,sync:Dn,HTTPError:Bn},yi="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global;pi.VERSION="0.0.1";const gi=yi.Skeletor;function bi(){return yi.Skeletor=gi,this}pi.noConflict=bi,yi.Skeletor=pi;const mi=Fn;t.BrowserStorage=mi,t.Collection=li,t.EventEmitter=Qt,t.HTTPError=Bn,t.Model=ii,t.PersistentStorage=Fn,t.default=pi,t.getStorage=Rn,t.noConflict=bi,t.sync=Dn,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
61
61
|
//# sourceMappingURL=skeletor.min.js.map
|
package/dist/skeletor.node.d.ts
CHANGED
|
@@ -334,6 +334,22 @@ declare class PersistentStorage {
|
|
|
334
334
|
getItemName(id: string | number): string;
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
+
/**
|
|
338
|
+
* `model` and `comparator` are declared on an interface merged with the class
|
|
339
|
+
* rather than on the class itself, so that subclasses may override them either
|
|
340
|
+
* as instance properties (`model = Contact`) or as accessors (`get model()`).
|
|
341
|
+
* TypeScript rejects the one form overriding the other (TS2610, TS2611) only
|
|
342
|
+
* when the base member is declared on a class.
|
|
343
|
+
*/
|
|
344
|
+
interface Collection<T extends Model = Model> {
|
|
345
|
+
/**
|
|
346
|
+
* The model class to instantiate when raw attributes are added. Defaults to
|
|
347
|
+
* `Model` when unset. Typed loosely so that model classes whose constructors
|
|
348
|
+
* take required or narrower attributes and options fit.
|
|
349
|
+
*/
|
|
350
|
+
model: new (attributes?: any, options?: any) => T;
|
|
351
|
+
comparator: Comparator<T>;
|
|
352
|
+
}
|
|
337
353
|
/**
|
|
338
354
|
* @public
|
|
339
355
|
* If models tend to represent a single row of data, a Collection is
|
|
@@ -346,20 +362,16 @@ declare class PersistentStorage {
|
|
|
346
362
|
declare class Collection<T extends Model = Model> extends EventEmitterObject {
|
|
347
363
|
[key: symbol]: () => CollectionIterator<T>;
|
|
348
364
|
_storage?: PersistentStorage;
|
|
349
|
-
_comparator?: Comparator<T>;
|
|
350
365
|
_url: string;
|
|
351
366
|
hydrated?: Promise<void>;
|
|
352
367
|
models: T[];
|
|
353
368
|
protected _byId: Record<string, T>;
|
|
354
|
-
protected _model?: new (attributes?: Partial<ModelAttributes>, options?: ModelOptions) => T;
|
|
355
369
|
/**
|
|
356
370
|
* Create a new **Collection**, perhaps to contain a specific type of `model`.
|
|
357
371
|
* If a `comparator` is specified, the Collection will maintain
|
|
358
372
|
* its models in sort order, as they're added and removed.
|
|
359
373
|
*/
|
|
360
374
|
constructor(models?: T[] | ModelAttributes[] | T | ModelAttributes, options?: CollectionOptions<T>);
|
|
361
|
-
get comparator(): Comparator<T>;
|
|
362
|
-
set comparator(c: Comparator<T>);
|
|
363
375
|
/**
|
|
364
376
|
* The canonical storage accessor. Set to a `PersistentStorage` instance
|
|
365
377
|
* to enable local persistence for this collection.
|
|
@@ -383,12 +395,6 @@ declare class Collection<T extends Model = Model> extends EventEmitterObject {
|
|
|
383
395
|
* record. A collection-level write would be redundant with that.
|
|
384
396
|
*/
|
|
385
397
|
get autoSync(): boolean;
|
|
386
|
-
/**
|
|
387
|
-
* The default model for a collection is just a **Model**.
|
|
388
|
-
* This should be overridden in most cases.
|
|
389
|
-
*/
|
|
390
|
-
get model(): new (attributes?: Partial<ModelAttributes>, options?: ModelOptions) => T | Model;
|
|
391
|
-
set model(model: new (attributes?: Partial<ModelAttributes>, options?: ModelOptions) => T);
|
|
392
398
|
get length(): number;
|
|
393
399
|
get url(): string;
|
|
394
400
|
set url(url: string);
|
|
@@ -655,10 +661,7 @@ type EventListenerMap = Record<string, ListeningType>;
|
|
|
655
661
|
/**
|
|
656
662
|
* @public
|
|
657
663
|
*/
|
|
658
|
-
|
|
659
|
-
all?: EventHandler[];
|
|
660
|
-
[name: string]: EventHandler[];
|
|
661
|
-
}
|
|
664
|
+
type EventHandlersMap = Record<string, EventHandler[]>;
|
|
662
665
|
/**
|
|
663
666
|
* @public
|
|
664
667
|
*/
|
|
@@ -717,7 +720,7 @@ type Comparator<T extends Model = Model> = string | boolean | ((a: T, b: T) => n
|
|
|
717
720
|
*/
|
|
718
721
|
type ComputedProperty<M> = {
|
|
719
722
|
deps: string[];
|
|
720
|
-
fn
|
|
723
|
+
fn(model: M): any;
|
|
721
724
|
};
|
|
722
725
|
/**
|
|
723
726
|
* @public
|
|
@@ -744,7 +747,7 @@ type FetchOrCreateOptions = Options & {
|
|
|
744
747
|
* @public
|
|
745
748
|
*/
|
|
746
749
|
type CollectionOptions<T extends Model = Model> = Options & {
|
|
747
|
-
model?: new (attributes?:
|
|
750
|
+
model?: new (attributes?: any, options?: any) => T;
|
|
748
751
|
comparator?: Comparator<T>;
|
|
749
752
|
previousModels?: Model[];
|
|
750
753
|
};
|
package/dist/skeletor.node.js
CHANGED
|
@@ -11830,6 +11830,7 @@ async function hydrate(collection) {
|
|
|
11830
11830
|
* belonging to this particular author, and so on. Collections maintain
|
|
11831
11831
|
* indexes of their models, both in order, and for lookup by `id`.
|
|
11832
11832
|
*/
|
|
11833
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging -- see the interface above
|
|
11833
11834
|
class Collection extends EventEmitterObject {
|
|
11834
11835
|
/**
|
|
11835
11836
|
* Create a new **Collection**, perhaps to contain a specific type of `model`.
|
|
@@ -11847,7 +11848,7 @@ class Collection extends EventEmitterObject {
|
|
|
11847
11848
|
options = options || {};
|
|
11848
11849
|
this.preinitialize.apply(this, arguments);
|
|
11849
11850
|
if (options.model)
|
|
11850
|
-
this.
|
|
11851
|
+
this.model = options.model;
|
|
11851
11852
|
if (options.comparator !== undefined)
|
|
11852
11853
|
this.comparator = options.comparator;
|
|
11853
11854
|
this._reset();
|
|
@@ -11862,12 +11863,6 @@ class Collection extends EventEmitterObject {
|
|
|
11862
11863
|
this.hydrated = getStorage(this) ? hydrate(this) : Promise.resolve();
|
|
11863
11864
|
}
|
|
11864
11865
|
}
|
|
11865
|
-
get comparator() {
|
|
11866
|
-
return this._comparator;
|
|
11867
|
-
}
|
|
11868
|
-
set comparator(c) {
|
|
11869
|
-
this._comparator = c;
|
|
11870
|
-
}
|
|
11871
11866
|
/**
|
|
11872
11867
|
* The canonical storage accessor. Set to a `PersistentStorage` instance
|
|
11873
11868
|
* to enable local persistence for this collection.
|
|
@@ -11903,16 +11898,6 @@ class Collection extends EventEmitterObject {
|
|
|
11903
11898
|
get autoSync() {
|
|
11904
11899
|
return false;
|
|
11905
11900
|
}
|
|
11906
|
-
/**
|
|
11907
|
-
* The default model for a collection is just a **Model**.
|
|
11908
|
-
* This should be overridden in most cases.
|
|
11909
|
-
*/
|
|
11910
|
-
get model() {
|
|
11911
|
-
return this._model ?? Model;
|
|
11912
|
-
}
|
|
11913
|
-
set model(model) {
|
|
11914
|
-
this._model = model;
|
|
11915
|
-
}
|
|
11916
11901
|
get length() {
|
|
11917
11902
|
return this.models.length;
|
|
11918
11903
|
}
|
|
@@ -12416,7 +12401,7 @@ class Collection extends EventEmitterObject {
|
|
|
12416
12401
|
* Define how to uniquely identify models in the collection.
|
|
12417
12402
|
*/
|
|
12418
12403
|
modelId(attrs) {
|
|
12419
|
-
return attrs[this.model.prototype?.idAttribute || 'id'];
|
|
12404
|
+
return attrs[(this.model ?? Model).prototype?.idAttribute || 'id'];
|
|
12420
12405
|
}
|
|
12421
12406
|
/** Get an iterator of all models in this collection. */
|
|
12422
12407
|
values() {
|
|
@@ -12439,7 +12424,7 @@ class Collection extends EventEmitterObject {
|
|
|
12439
12424
|
this._byId = {};
|
|
12440
12425
|
}
|
|
12441
12426
|
createModel(attrs, options) {
|
|
12442
|
-
const Klass = this.model;
|
|
12427
|
+
const Klass = this.model ?? Model;
|
|
12443
12428
|
return new Klass(attrs, options);
|
|
12444
12429
|
}
|
|
12445
12430
|
/**
|
package/dist/skeletor.node.mjs
CHANGED
|
@@ -11826,6 +11826,7 @@ async function hydrate(collection) {
|
|
|
11826
11826
|
* belonging to this particular author, and so on. Collections maintain
|
|
11827
11827
|
* indexes of their models, both in order, and for lookup by `id`.
|
|
11828
11828
|
*/
|
|
11829
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging -- see the interface above
|
|
11829
11830
|
class Collection extends EventEmitterObject {
|
|
11830
11831
|
/**
|
|
11831
11832
|
* Create a new **Collection**, perhaps to contain a specific type of `model`.
|
|
@@ -11843,7 +11844,7 @@ class Collection extends EventEmitterObject {
|
|
|
11843
11844
|
options = options || {};
|
|
11844
11845
|
this.preinitialize.apply(this, arguments);
|
|
11845
11846
|
if (options.model)
|
|
11846
|
-
this.
|
|
11847
|
+
this.model = options.model;
|
|
11847
11848
|
if (options.comparator !== undefined)
|
|
11848
11849
|
this.comparator = options.comparator;
|
|
11849
11850
|
this._reset();
|
|
@@ -11858,12 +11859,6 @@ class Collection extends EventEmitterObject {
|
|
|
11858
11859
|
this.hydrated = getStorage(this) ? hydrate(this) : Promise.resolve();
|
|
11859
11860
|
}
|
|
11860
11861
|
}
|
|
11861
|
-
get comparator() {
|
|
11862
|
-
return this._comparator;
|
|
11863
|
-
}
|
|
11864
|
-
set comparator(c) {
|
|
11865
|
-
this._comparator = c;
|
|
11866
|
-
}
|
|
11867
11862
|
/**
|
|
11868
11863
|
* The canonical storage accessor. Set to a `PersistentStorage` instance
|
|
11869
11864
|
* to enable local persistence for this collection.
|
|
@@ -11899,16 +11894,6 @@ class Collection extends EventEmitterObject {
|
|
|
11899
11894
|
get autoSync() {
|
|
11900
11895
|
return false;
|
|
11901
11896
|
}
|
|
11902
|
-
/**
|
|
11903
|
-
* The default model for a collection is just a **Model**.
|
|
11904
|
-
* This should be overridden in most cases.
|
|
11905
|
-
*/
|
|
11906
|
-
get model() {
|
|
11907
|
-
return this._model ?? Model;
|
|
11908
|
-
}
|
|
11909
|
-
set model(model) {
|
|
11910
|
-
this._model = model;
|
|
11911
|
-
}
|
|
11912
11897
|
get length() {
|
|
11913
11898
|
return this.models.length;
|
|
11914
11899
|
}
|
|
@@ -12412,7 +12397,7 @@ class Collection extends EventEmitterObject {
|
|
|
12412
12397
|
* Define how to uniquely identify models in the collection.
|
|
12413
12398
|
*/
|
|
12414
12399
|
modelId(attrs) {
|
|
12415
|
-
return attrs[this.model.prototype?.idAttribute || 'id'];
|
|
12400
|
+
return attrs[(this.model ?? Model).prototype?.idAttribute || 'id'];
|
|
12416
12401
|
}
|
|
12417
12402
|
/** Get an iterator of all models in this collection. */
|
|
12418
12403
|
values() {
|
|
@@ -12435,7 +12420,7 @@ class Collection extends EventEmitterObject {
|
|
|
12435
12420
|
this._byId = {};
|
|
12436
12421
|
}
|
|
12437
12422
|
createModel(attrs, options) {
|
|
12438
|
-
const Klass = this.model;
|
|
12423
|
+
const Klass = this.model ?? Model;
|
|
12439
12424
|
return new Klass(attrs, options);
|
|
12440
12425
|
}
|
|
12441
12426
|
/**
|