@betterbugs/web-sdk
Version:
A web sdk package for Betterbugs
2 lines • 217 kB
JavaScript
/*! For license information please see logs-capture.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Betterbugs=t():e.Betterbugs=t()}(this,function(){return function(){var e={7753:function(e,t,n){e.exports=function(){"use strict";var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)},t=function(){return(t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function r(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||((r=r||Array.prototype.slice.call(t,0,i))[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:n.g,o=Object.keys,a=Array.isArray;function s(e,t){return"object"!=typeof t||o(t).forEach(function(n){e[n]=t[n]}),e}"undefined"==typeof Promise||i.Promise||(i.Promise=Promise);var u=Object.getPrototypeOf,c={}.hasOwnProperty;function l(e,t){return c.call(e,t)}function d(e,t){"function"==typeof t&&(t=t(u(e))),("undefined"==typeof Reflect?o:Reflect.ownKeys)(t).forEach(function(n){f(e,n,t[n])})}var h=Object.defineProperty;function f(e,t,n,r){h(e,t,s(n&&l(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function p(e){return{from:function(t){return e.prototype=Object.create(t.prototype),f(e.prototype,"constructor",e),{extend:d.bind(null,e.prototype)}}}}var m=Object.getOwnPropertyDescriptor,y=[].slice;function v(e,t,n){return y.call(e,t,n)}function g(e,t){return t(e)}function b(e){if(!e)throw new Error("Assertion Failed")}function w(e){i.setImmediate?setImmediate(e):setTimeout(e,0)}function S(e,t){if("string"==typeof t&&l(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],r=0,i=t.length;r<i;++r){var o=S(e,t[r]);n.push(o)}return n}var a=t.indexOf(".");if(-1!==a){var s=e[t.substr(0,a)];return null==s?void 0:S(s,t.substr(a+1))}}function k(e,t,n){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){b("string"!=typeof n&&"length"in n);for(var r=0,i=t.length;r<i;++r)k(e,t[r],n[r])}else{var o,s,u=t.indexOf(".");-1!==u?(o=t.substr(0,u),""===(s=t.substr(u+1))?void 0===n?a(e)&&!isNaN(parseInt(o))?e.splice(o,1):delete e[o]:e[o]=n:k(u=(u=e[o])&&l(e,o)?u:e[o]={},s,n)):void 0===n?a(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function I(e){var t,n={};for(t in e)l(e,t)&&(n[t]=e[t]);return n}var x=[].concat;function _(e){return x.apply([],e)}var C="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(_([8,16,32,64].map(function(e){return["Int","Uint","Float"].map(function(t){return t+e+"Array"})}))).filter(function(e){return i[e]}),E=new Set(C.map(function(e){return i[e]})),O=null;function M(e){return O=new WeakMap,e=function e(t){if(!t||"object"!=typeof t)return t;var n=O.get(t);if(n)return n;if(a(t)){n=[],O.set(t,n);for(var r=0,i=t.length;r<i;++r)n.push(e(t[r]))}else if(E.has(t.constructor))n=t;else{var o,s=u(t);for(o in n=s===Object.prototype?{}:Object.create(s),O.set(t,n),t)l(t,o)&&(n[o]=e(t[o]))}return n}(e),O=null,e}var T={}.toString;function R(e){return T.call(e).slice(8,-1)}var D="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",N="symbol"==typeof D?function(e){var t;return null!=e&&(t=e[D])&&t.apply(e)}:function(){return null};function A(e,t){return 0<=(t=e.indexOf(t))&&e.splice(t,1),0<=t}var L={};function P(e){var t,n,r,i;if(1===arguments.length){if(a(e))return e.slice();if(this===L&&"string"==typeof e)return[e];if(i=N(e)){for(n=[];!(r=i.next()).done;)n.push(r.value);return n}if(null==e)return[e];if("number"!=typeof(t=e.length))return[e];for(n=new Array(t);t--;)n[t]=e[t];return n}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}var F="undefined"!=typeof Symbol?function(e){return"AsyncFunction"===e[Symbol.toStringTag]}:function(){return!1},j=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(ue=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"]),B={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function q(e,t){this.name=e,this.message=t}function K(e,t){return e+". Errors: "+Object.keys(t).map(function(e){return t[e].toString()}).filter(function(e,t,n){return n.indexOf(e)===t}).join("\n")}function U(e,t,n,r){this.failures=t,this.failedKeys=r,this.successCount=n,this.message=K(e,t)}function z(e,t){this.name="BulkError",this.failures=Object.keys(t).map(function(e){return t[e]}),this.failuresByPos=t,this.message=K(e,this.failures)}p(q).from(Error).extend({toString:function(){return this.name+": "+this.message}}),p(U).from(q),p(z).from(q);var W=j.reduce(function(e,t){return e[t]=t+"Error",e},{}),H=q,V=j.reduce(function(e,t){var n=t+"Error";function r(e,r){this.name=n,e?"string"==typeof e?(this.message="".concat(e).concat(r?"\n "+r:""),this.inner=r||null):"object"==typeof e&&(this.message="".concat(e.name," ").concat(e.message),this.inner=e):(this.message=B[t]||n,this.inner=null)}return p(r).from(H),e[t]=r,e},{});V.Syntax=SyntaxError,V.Type=TypeError,V.Range=RangeError;var $=ue.reduce(function(e,t){return e[t+"Error"]=V[t],e},{}),G=j.reduce(function(e,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=V[t]),e},{});function X(){}function Y(e){return e}function Q(e,t){return null==e||e===Y?t:function(n){return t(e(n))}}function J(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function Z(e,t){return e===X?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?J(r,this.onsuccess):r),i&&(this.onerror=this.onerror?J(i,this.onerror):i),void 0!==o?o:n}}function ee(e,t){return e===X?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?J(n,this.onsuccess):n),r&&(this.onerror=this.onerror?J(r,this.onerror):r)}}function te(e,t){return e===X?t:function(n){var r=e.apply(this,arguments);s(n,r);var i=this.onsuccess,o=this.onerror;return this.onsuccess=null,this.onerror=null,n=t.apply(this,arguments),i&&(this.onsuccess=this.onsuccess?J(i,this.onsuccess):i),o&&(this.onerror=this.onerror?J(o,this.onerror):o),void 0===r?void 0===n?void 0:n:s(r,n)}}function ne(e,t){return e===X?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function re(e,t){return e===X?t:function(){var n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var r=this,i=arguments.length,o=new Array(i);i--;)o[i]=arguments[i];return n.then(function(){return t.apply(r,o)})}return t.apply(this,arguments)}}G.ModifyError=U,G.DexieError=q,G.BulkError=z;var ie="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function oe(e){ie=e}var ae={},se=100,ue=(C="undefined"==typeof Promise?[]:function(){var e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,u(e),e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,u(t),e]}(),C[0]),ce=(j=C[1],C=C[2],j=j&&j.then,ue&&ue.constructor),le=!!C,de=function(e,t){be.push([e,t]),fe&&(queueMicrotask(Me),fe=!1)},he=!0,fe=!0,pe=[],me=[],ye=Y,ve={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:X,pgp:!1,env:{},finalize:X},ge=ve,be=[],we=0,Se=[];function ke(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var t=this._PSD=ge;if("function"!=typeof e){if(e!==ae)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&_e(this,this._value))}this._state=null,this._value=null,++t.ref,function e(t,n){try{n(function(n){if(null===t._state){if(n===t)throw new TypeError("A promise cannot be resolved with itself.");var r=t._lib&&Te();n&&"function"==typeof n.then?e(t,function(e,t){n instanceof ke?n._then(e,t):n.then(e,t)}):(t._state=!0,t._value=n,Ce(t)),r&&Re()}},_e.bind(null,t))}catch(n){_e(t,n)}}(this,e)}var Ie={get:function(){var e=ge,t=Be;function n(n,r){var i=this,o=!e.global&&(e!==ge||t!==Be),a=o&&!ze(),s=new ke(function(t,s){Ee(i,new xe(Xe(n,e,o,a),Xe(r,e,o,a),t,s,e))});return this._consoleTask&&(s._consoleTask=this._consoleTask),s}return n.prototype=ae,n},set:function(e){f(this,"then",e&&e.prototype===ae?Ie:{get:function(){return e},set:Ie.set})}};function xe(e,t,n,r,i){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=i}function _e(e,t){var n,r;me.push(t),null===e._state&&(n=e._lib&&Te(),t=ye(t),e._state=!1,e._value=t,r=e,pe.some(function(e){return e._value===r._value})||pe.push(r),Ce(e),n&&Re())}function Ce(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Ee(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),0===we&&(++we,de(function(){0==--we&&De()},[]))}function Ee(e,t){if(null!==e._state){var n=e._state?t.onFulfilled:t.onRejected;if(null===n)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++we,de(Oe,[n,e,t])}else e._listeners.push(t)}function Oe(e,t,n){try{var r,i=t._value;!t._state&&me.length&&(me=[]),r=ie&&t._consoleTask?t._consoleTask.run(function(){return e(i)}):e(i),t._state||-1!==me.indexOf(i)||function(e){for(var t=pe.length;t;)if(pe[--t]._value===e._value)return pe.splice(t,1)}(t),n.resolve(r)}catch(e){n.reject(e)}finally{0==--we&&De(),--n.psd.ref||n.psd.finalize()}}function Me(){Ge(ve,function(){Te()&&Re()})}function Te(){var e=he;return fe=he=!1,e}function Re(){var e,t,n;do{for(;0<be.length;)for(e=be,be=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(0<be.length);fe=he=!0}function De(){var e=pe;pe=[],e.forEach(function(e){e._PSD.onunhandled.call(null,e._value,e)});for(var t=Se.slice(0),n=t.length;n;)t[--n]()}function Ne(e){return new ke(ae,!1,e)}function Ae(e,t){var n=ge;return function(){var r=Te(),i=ge;try{return Ve(n,!0),e.apply(this,arguments)}catch(r){t&&t(r)}finally{Ve(i,!1),r&&Re()}}}d(ke.prototype,{then:Ie,_then:function(e,t){Ee(this,new xe(null,null,e,t,ge))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=e,n=arguments[1];return"function"==typeof t?this.then(null,function(e){return(e instanceof t?n:Ne)(e)}):this.then(null,function(e){return(e&&e.name===t?n:Ne)(e)})},finally:function(e){return this.then(function(t){return ke.resolve(e()).then(function(){return t})},function(t){return ke.resolve(e()).then(function(){return Ne(t)})})},timeout:function(e,t){var n=this;return e<1/0?new ke(function(r,i){var o=setTimeout(function(){return i(new V.Timeout(t))},e);n.then(r,i).finally(clearTimeout.bind(null,o))}):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&f(ke.prototype,Symbol.toStringTag,"Dexie.Promise"),ve.env=$e(),d(ke,{all:function(){var e=P.apply(null,arguments).map(We);return new ke(function(t,n){0===e.length&&t([]);var r=e.length;e.forEach(function(i,o){return ke.resolve(i).then(function(n){e[o]=n,--r||t(e)},n)})})},resolve:function(e){return e instanceof ke?e:e&&"function"==typeof e.then?new ke(function(t,n){e.then(t,n)}):new ke(ae,!0,e)},reject:Ne,race:function(){var e=P.apply(null,arguments).map(We);return new ke(function(t,n){e.map(function(e){return ke.resolve(e).then(t,n)})})},PSD:{get:function(){return ge},set:function(e){return ge=e}},totalEchoes:{get:function(){return Be}},newPSD:Ke,usePSD:Ge,scheduler:{get:function(){return de},set:function(e){de=e}},rejectionMapper:{get:function(){return ye},set:function(e){ye=e}},follow:function(e,t){return new ke(function(n,r){return Ke(function(t,n){var r=ge;r.unhandleds=[],r.onunhandled=n,r.finalize=J(function(){var e,r=this;e=function(){0===r.unhandleds.length?t():n(r.unhandleds[0])},Se.push(function t(){e(),Se.splice(Se.indexOf(t),1)}),++we,de(function(){0==--we&&De()},[])},r.finalize),e()},t,n,r)})}}),ce&&(ce.allSettled&&f(ke,"allSettled",function(){var e=P.apply(null,arguments).map(We);return new ke(function(t){0===e.length&&t([]);var n=e.length,r=new Array(n);e.forEach(function(e,i){return ke.resolve(e).then(function(e){return r[i]={status:"fulfilled",value:e}},function(e){return r[i]={status:"rejected",reason:e}}).then(function(){return--n||t(r)})})})}),ce.any&&"undefined"!=typeof AggregateError&&f(ke,"any",function(){var e=P.apply(null,arguments).map(We);return new ke(function(t,n){0===e.length&&n(new AggregateError([]));var r=e.length,i=new Array(r);e.forEach(function(e,o){return ke.resolve(e).then(function(e){return t(e)},function(e){i[o]=e,--r||n(new AggregateError(i))})})})}),ce.withResolvers&&(ke.withResolvers=ce.withResolvers));var Le={awaits:0,echoes:0,id:0},Pe=0,Fe=[],je=0,Be=0,qe=0;function Ke(e,t,n,r){var i=ge,o=Object.create(i);return o.parent=i,o.ref=0,o.global=!1,o.id=++qe,ve.env,o.env=le?{Promise:ke,PromiseProp:{value:ke,configurable:!0,writable:!0},all:ke.all,race:ke.race,allSettled:ke.allSettled,any:ke.any,resolve:ke.resolve,reject:ke.reject}:{},t&&s(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()},r=Ge(o,e,n,r),0===o.ref&&o.finalize(),r}function Ue(){return Le.id||(Le.id=++Pe),++Le.awaits,Le.echoes+=se,Le.id}function ze(){return!!Le.awaits&&(0==--Le.awaits&&(Le.id=0),Le.echoes=Le.awaits*se,!0)}function We(e){return Le.echoes&&e&&e.constructor===ce?(Ue(),e.then(function(e){return ze(),e},function(e){return ze(),Qe(e)})):e}function He(){var e=Fe[Fe.length-1];Fe.pop(),Ve(e,!1)}function Ve(e,t){var n,r=ge;(t?!Le.echoes||je++&&e===ge:!je||--je&&e===ge)||queueMicrotask(t?function(e){++Be,Le.echoes&&0!=--Le.echoes||(Le.echoes=Le.awaits=Le.id=0),Fe.push(ge),Ve(e,!0)}.bind(null,e):He),e!==ge&&(ge=e,r===ve&&(ve.env=$e()),le&&(n=ve.env.Promise,t=e.env,(r.global||e.global)&&(Object.defineProperty(i,"Promise",t.PromiseProp),n.all=t.all,n.race=t.race,n.resolve=t.resolve,n.reject=t.reject,t.allSettled&&(n.allSettled=t.allSettled),t.any&&(n.any=t.any))))}function $e(){var e=i.Promise;return le?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(i,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function Ge(e,t,n,r,i){var o=ge;try{return Ve(e,!0),t(n,r,i)}finally{Ve(o,!1)}}function Xe(e,t,n,r){return"function"!=typeof e?e:function(){var i=ge;n&&Ue(),Ve(t,!0);try{return e.apply(this,arguments)}finally{Ve(i,!1),r&&queueMicrotask(ze)}}}function Ye(e){Promise===ce&&0===Le.echoes?0===je?e():enqueueNativeMicroTask(e):setTimeout(e,0)}-1===(""+j).indexOf("[native code]")&&(Ue=ze=X);var Qe=ke.reject,Je=String.fromCharCode(65535),Ze="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",et="String expected.",tt=[],nt="__dbnames",rt="readonly",it="readwrite";function ot(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var at={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function st(e){return"string"!=typeof e||/\./.test(e)?function(e){return e}:function(t){return void 0===t[e]&&e in t&&delete(t=M(t))[e],t}}function ut(){throw V.Type()}function ct(e,t){try{var n=lt(e),r=lt(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return t<e?1:e<t?-1:0;case"binary":return function(e,t){for(var n=e.length,r=t.length,i=n<r?n:r,o=0;o<i;++o)if(e[o]!==t[o])return e[o]<t[o]?-1:1;return n===r?0:n<r?-1:1}(dt(e),dt(t));case"Array":return function(e,t){for(var n=e.length,r=t.length,i=n<r?n:r,o=0;o<i;++o){var a=ct(e[o],t[o]);if(0!==a)return a}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function lt(e){var t=typeof e;return"object"!=t?t:ArrayBuffer.isView(e)||"ArrayBuffer"===(e=R(e))?"binary":e}function dt(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var ht=(ft.prototype._trans=function(e,t,n){var r=this._tx||ge.trans,i=this.name,o=ie&&"undefined"!=typeof console&&console.createTask&&void 0;function a(e,n,r){if(!r.schema[i])throw new V.NotFound("Table "+i+" not part of transaction");return t(r.idbtrans,r)}var s=Te();try{var u=r&&r.db._novip===this.db._novip?r===ge.trans?r._promise(e,a,n):Ke(function(){return r._promise(e,a,n)},{trans:r,transless:ge.transless||ge}):function e(t,n,r,i){if(t.idbdb&&(t._state.openComplete||ge.letThrough||t._vip)){var o=t._createTransaction(n,r,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===W.InvalidState&&t.isOpen()&&0<--t._state.PR1398_maxLoop?(t.close({disableAutoOpen:!1}),t.open().then(function(){return e(t,n,r,i)})):Qe(o)}return o._promise(n,function(e,t){return Ke(function(){return ge.trans=o,i(e,t,o)})}).then(function(e){if("readwrite"===n)try{o.idbtrans.commit()}catch(e){}return"readonly"===n?e:o._completion.then(function(){return e})})}if(t._state.openComplete)return Qe(new V.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._state.autoOpen)return Qe(new V.DatabaseClosed);t.open().catch(X)}return t._state.dbReadyPromise.then(function(){return e(t,n,r,i)})}(this.db,e,[this.name],a);return o&&(u._consoleTask=o,u=u.catch(function(e){return Qe(e)})),u}finally{s&&Re()}},ft.prototype.get=function(e,t){var n=this;return e&&e.constructor===Object?this.where(e).first(t):null==e?Qe(new V.Type("Invalid argument to Table.get()")):this._trans("readonly",function(t){return n.core.get({trans:t,key:e}).then(function(e){return n.hook.reading.fire(e)})}).then(t)},ft.prototype.where=function(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(a(e))return new this.db.WhereClause(this,"[".concat(e.join("+"),"]"));var t=o(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);var n=this.schema.indexes.concat(this.schema.primKey).filter(function(e){if(e.compound&&t.every(function(t){return 0<=e.keyPath.indexOf(t)})){for(var n=0;n<t.length;++n)if(-1===t.indexOf(e.keyPath[n]))return!1;return!0}return!1}).sort(function(e,t){return e.keyPath.length-t.keyPath.length})[0];if(n&&this.db._maxKey!==Je){var r=n.keyPath.slice(0,t.length);return this.where(r).equals(r.map(function(t){return e[t]}))}var i=this.schema.idxByName;function s(e,t){return 0===ct(e,t)}var u=t.reduce(function(t,n){var r=t[0],o=t[1],u=(t=i[n],e[n]);return[r||t,r||!t?ot(o,t&&t.multi?function(e){return e=S(e,n),a(e)&&e.some(function(e){return s(u,e)})}:function(e){return s(u,S(e,n))}):o]},[null,null]);return r=u[0],u=u[1],r?this.where(r.name).equals(e[r.keyPath]).filter(u):n?this.filter(u):this.where(t).equals("")},ft.prototype.filter=function(e){return this.toCollection().and(e)},ft.prototype.count=function(e){return this.toCollection().count(e)},ft.prototype.offset=function(e){return this.toCollection().offset(e)},ft.prototype.limit=function(e){return this.toCollection().limit(e)},ft.prototype.each=function(e){return this.toCollection().each(e)},ft.prototype.toArray=function(e){return this.toCollection().toArray(e)},ft.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},ft.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,a(e)?"[".concat(e.join("+"),"]"):e))},ft.prototype.reverse=function(){return this.toCollection().reverse()},ft.prototype.mapToClass=function(t){var n,r=this.db,i=this.name;function o(){return null!==n&&n.apply(this,arguments)||this}(this.schema.mappedClass=t).prototype instanceof ut&&(function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(o,n=t),Object.defineProperty(o.prototype,"db",{get:function(){return r},enumerable:!1,configurable:!0}),o.prototype.table=function(){return i},t=o);for(var a=new Set,s=t.prototype;s;s=u(s))Object.getOwnPropertyNames(s).forEach(function(e){return a.add(e)});function c(e){if(!e)return e;var n,r=Object.create(t.prototype);for(n in e)if(!a.has(n))try{r[n]=e[n]}catch(e){}return r}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=c,this.hook("reading",c),t},ft.prototype.defineClass=function(){return this.mapToClass(function(e){s(this,e)})},ft.prototype.add=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,o=r.keyPath,a=e;return o&&i&&(a=st(o)(e)),this._trans("readwrite",function(e){return n.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[a]})}).then(function(e){return e.numFailures?ke.reject(e.failures[0]):e.lastResult}).then(function(t){if(o)try{k(e,o,t)}catch(t){}return t})},ft.prototype.update=function(e,t){return"object"!=typeof e||a(e)?this.where(":id").equals(e).modify(t):void 0===(e=S(e,this.schema.primKey.keyPath))?Qe(new V.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t)},ft.prototype.put=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,o=r.keyPath,a=e;return o&&i&&(a=st(o)(e)),this._trans("readwrite",function(e){return n.core.mutate({trans:e,type:"put",values:[a],keys:null!=t?[t]:null})}).then(function(e){return e.numFailures?ke.reject(e.failures[0]):e.lastResult}).then(function(t){if(o)try{k(e,o,t)}catch(t){}return t})},ft.prototype.delete=function(e){var t=this;return this._trans("readwrite",function(n){return t.core.mutate({trans:n,type:"delete",keys:[e]})}).then(function(e){return e.numFailures?ke.reject(e.failures[0]):void 0})},ft.prototype.clear=function(){var e=this;return this._trans("readwrite",function(t){return e.core.mutate({trans:t,type:"deleteRange",range:at})}).then(function(e){return e.numFailures?ke.reject(e.failures[0]):void 0})},ft.prototype.bulkGet=function(e){var t=this;return this._trans("readonly",function(n){return t.core.getMany({keys:e,trans:n}).then(function(e){return e.map(function(e){return t.hook.reading.fire(e)})})})},ft.prototype.bulkAdd=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,o=(n=n||(i?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(t){var n=(s=r.schema.primKey).auto;if((s=s.keyPath)&&i)throw new V.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new V.InvalidArgument("Arguments objects and keys must have the same length");var a=e.length,s=s&&n?e.map(st(s)):e;return r.core.mutate({trans:t,type:"add",keys:i,values:s,wantResults:o}).then(function(e){var t=e.numFailures,n=e.results,i=e.lastResult;if(e=e.failures,0===t)return o?n:i;throw new z("".concat(r.name,".bulkAdd(): ").concat(t," of ").concat(a," operations failed"),e)})})},ft.prototype.bulkPut=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,o=(n=n||(i?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(t){var n=(s=r.schema.primKey).auto;if((s=s.keyPath)&&i)throw new V.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new V.InvalidArgument("Arguments objects and keys must have the same length");var a=e.length,s=s&&n?e.map(st(s)):e;return r.core.mutate({trans:t,type:"put",keys:i,values:s,wantResults:o}).then(function(e){var t=e.numFailures,n=e.results,i=e.lastResult;if(e=e.failures,0===t)return o?n:i;throw new z("".concat(r.name,".bulkPut(): ").concat(t," of ").concat(a," operations failed"),e)})})},ft.prototype.bulkUpdate=function(e){var t=this,n=this.core,r=e.map(function(e){return e.key}),i=e.map(function(e){return e.changes}),o=[];return this._trans("readwrite",function(a){return n.getMany({trans:a,keys:r,cache:"clone"}).then(function(s){var u=[],c=[];e.forEach(function(e,n){var r=e.key,i=e.changes,a=s[n];if(a){for(var l=0,d=Object.keys(i);l<d.length;l++){var h=d[l],f=i[h];if(h===t.schema.primKey.keyPath){if(0!==ct(f,r))throw new V.Constraint("Cannot update primary key in bulkUpdate()")}else k(a,h,f)}o.push(n),u.push(r),c.push(a)}});var l=u.length;return n.mutate({trans:a,type:"put",keys:u,values:c,updates:{keys:r,changeSpecs:i}}).then(function(e){var n=e.numFailures,r=e.failures;if(0===n)return l;for(var i=0,a=Object.keys(r);i<a.length;i++){var s,u=a[i],c=o[Number(u)];null!=c&&(s=r[u],delete r[u],r[c]=s)}throw new z("".concat(t.name,".bulkUpdate(): ").concat(n," of ").concat(l," operations failed"),r)})})})},ft.prototype.bulkDelete=function(e){var t=this,n=e.length;return this._trans("readwrite",function(n){return t.core.mutate({trans:n,type:"delete",keys:e})}).then(function(e){var r=e.numFailures,i=e.lastResult;if(e=e.failures,0===r)return i;throw new z("".concat(t.name,".bulkDelete(): ").concat(r," of ").concat(n," operations failed"),e)})},ft);function ft(){}function pt(e){function t(t,r){if(r){for(var i=arguments.length,o=new Array(i-1);--i;)o[i-1]=arguments[i];return n[t].subscribe.apply(null,o),e}if("string"==typeof t)return n[t]}var n={};t.addEventType=s;for(var r=1,i=arguments.length;r<i;++r)s(arguments[r]);return t;function s(e,r,i){if("object"!=typeof e){var u;r=r||ne;var c={subscribers:[],fire:i=i||X,subscribe:function(e){-1===c.subscribers.indexOf(e)&&(c.subscribers.push(e),c.fire=r(c.fire,e))},unsubscribe:function(e){c.subscribers=c.subscribers.filter(function(t){return t!==e}),c.fire=c.subscribers.reduce(r,i)}};return n[e]=t[e]=c}o(u=e).forEach(function(e){var t=u[e];if(a(t))s(e,u[e][0],u[e][1]);else{if("asap"!==t)throw new V.InvalidArgument("Invalid event config");var n=s(e,Y,function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){w(function(){e.apply(null,t)})})})}})}}function mt(e,t){return p(t).from({prototype:e}),t}function yt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function vt(e,t){e.filter=ot(e.filter,t)}function gt(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return ot(r(),t())}:t,e.justLimit=n&&!r}function bt(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(!n)throw new V.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function wt(e,t,n){var r=bt(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function St(e,t,n,r){var i=e.replayFilter?ot(e.filter,e.replayFilter()):e.filter;if(e.or){var o={},a=function(e,n,r){var a,s;i&&!i(n,r,function(e){return n.stop(e)},function(e){return n.fail(e)})||("[object ArrayBuffer]"==(s=""+(a=n.primaryKey))&&(s=""+new Uint8Array(a)),l(o,s)||(o[s]=!0,t(e,n,r)))};return Promise.all([e.or._iterate(a,n),kt(wt(e,r,n),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return kt(wt(e,r,n),ot(e.algorithm,i),t,!e.keysOnly&&e.valueMapper)}function kt(e,t,n,r){var i=Ae(r?function(e,t,i){return n(r(e),t,i)}:n);return e.then(function(e){if(e)return e.start(function(){var n=function(){return e.continue()};t&&!t(e,function(e){return n=e},function(t){e.stop(t),n=X},function(t){e.fail(t),n=X})||i(e.value,e,function(e){return n=e}),n()})})}var It=(xt.prototype.execute=function(e){var t=this["@@propmod"];if(void 0!==t.add){var n=t.add;if(a(n))return r(r([],a(e)?e:[],!0),n,!0).sort();if("number"==typeof n)return(Number(e)||0)+n;if("bigint"==typeof n)try{return BigInt(e)+n}catch(e){return BigInt(0)+n}throw new TypeError("Invalid term ".concat(n))}if(void 0!==t.remove){var i=t.remove;if(a(i))return a(e)?e.filter(function(e){return!i.includes(e)}).sort():[];if("number"==typeof i)return Number(e)-i;if("bigint"==typeof i)try{return BigInt(e)-i}catch(e){return BigInt(0)-i}throw new TypeError("Invalid subtrahend ".concat(i))}return(n=null===(n=t.replacePrefix)||void 0===n?void 0:n[0])&&"string"==typeof e&&e.startsWith(n)?t.replacePrefix[1]+e.substring(n.length):e},xt);function xt(e){this["@@propmod"]=e}var _t=(Ct.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,Qe.bind(null,n.error)):n.table._trans("readonly",e).then(t)},Ct.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,Qe.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},Ct.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=ot(t.algorithm,e)},Ct.prototype._iterate=function(e,t){return St(this._ctx,e,t,this._ctx.table.core)},Ct.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&s(n,e),t._ctx=n,t},Ct.prototype.raw=function(){return this._ctx.valueMapper=null,this},Ct.prototype.each=function(e){var t=this._ctx;return this._read(function(n){return St(t,e,n,t.table.core)})},Ct.prototype.count=function(e){var t=this;return this._read(function(e){var n=t._ctx,r=n.table.core;if(yt(n,!0))return r.count({trans:e,query:{index:bt(n,r.schema),range:n.range}}).then(function(e){return Math.min(e,n.limit)});var i=0;return St(n,function(){return++i,!1},e,r).then(function(){return i})}).then(e)},Ct.prototype.sortBy=function(e,t){var n=e.split(".").reverse(),r=n[0],i=n.length-1;function o(e,t){return t?o(e[n[t]],t-1):e[r]}var a="next"===this._ctx.dir?1:-1;function s(e,t){return ct(o(e,i),o(t,i))*a}return this.toArray(function(e){return e.sort(s)}).then(t)},Ct.prototype.toArray=function(e){var t=this;return this._read(function(e){var n=t._ctx;if("next"===n.dir&&yt(n,!0)&&0<n.limit){var r=n.valueMapper,i=bt(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:i,range:n.range}}).then(function(e){return e=e.result,r?e.map(r):e})}var o=[];return St(n,function(e){return o.push(e)},e,n.table.core).then(function(){return o})},e)},Ct.prototype.offset=function(e){var t=this._ctx;return e<=0||(t.offset+=e,yt(t)?gt(t,function(){var t=e;return function(e,n){return 0===t||(1===t?--t:n(function(){e.advance(t),t=0}),!1)}}):gt(t,function(){var t=e;return function(){return--t<0}})),this},Ct.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),gt(this._ctx,function(){var t=e;return function(e,n,r){return--t<=0&&n(r),0<=t}},!0),this},Ct.prototype.until=function(e,t){return vt(this._ctx,function(n,r,i){return!e(n.value)||(r(i),t)}),this},Ct.prototype.first=function(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)},Ct.prototype.last=function(e){return this.reverse().first(e)},Ct.prototype.filter=function(e){var t;return vt(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=ot(t.isMatch,e),this},Ct.prototype.and=function(e){return this.filter(e)},Ct.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},Ct.prototype.reverse=function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},Ct.prototype.desc=function(){return this.reverse()},Ct.prototype.eachKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.key,n)})},Ct.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},Ct.prototype.eachPrimaryKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.primaryKey,n)})},Ct.prototype.keys=function(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.key)}).then(function(){return n}).then(e)},Ct.prototype.primaryKeys=function(e){var t=this._ctx;if("next"===t.dir&&yt(t,!0)&&0<t.limit)return this._read(function(e){var n=bt(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})}).then(function(e){return e.result}).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.primaryKey)}).then(function(){return n}).then(e)},Ct.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},Ct.prototype.firstKey=function(e){return this.limit(1).keys(function(e){return e[0]}).then(e)},Ct.prototype.lastKey=function(e){return this.reverse().firstKey(e)},Ct.prototype.distinct=function(){var e;if(!(e=(e=this._ctx).index&&e.table.schema.idxByName[e.index])||!e.multi)return this;var t={};return vt(this._ctx,function(e){var n=e.primaryKey.toString();return e=l(t,n),t[n]=!0,!e}),this},Ct.prototype.modify=function(e){var t=this,n=this._ctx;return this._write(function(r){var i,a,s;s="function"==typeof e?e:(i=o(e),a=i.length,function(t){for(var n=!1,r=0;r<a;++r){var o=i[r],s=e[o],u=S(t,o);s instanceof It?(k(t,o,s.execute(u)),n=!0):u!==s&&(k(t,o,s),n=!0)}return n});var u,c=n.table.core,l=(u=c.schema.primaryKey).outbound,d=u.extractKey,h=200;function f(e,t){var n=t.failures;t=t.numFailures,m+=e-t;for(var r=0,i=o(n);r<i.length;r++){var a=i[r];p.push(n[a])}}(u=t.db._options.modifyChunkSize)&&(h="object"==typeof u?u[c.name]||u["*"]||200:u);var p=[],m=0,y=[];return t.clone().primaryKeys().then(function(t){function i(n){var a=Math.min(h,t.length-n);return c.getMany({trans:r,keys:t.slice(n,n+a),cache:"immutable"}).then(function(u){for(var p=[],m=[],y=l?[]:null,v=[],g=0;g<a;++g){var b=u[g],w={value:M(b),primKey:t[n+g]};!1!==s.call(w,w.value,w)&&(null==w.value?v.push(t[n+g]):l||0===ct(d(b),d(w.value))?(m.push(w.value),l&&y.push(t[n+g])):(v.push(t[n+g]),p.push(w.value)))}return Promise.resolve(0<p.length&&c.mutate({trans:r,type:"add",values:p}).then(function(e){for(var t in e.failures)v.splice(parseInt(t),1);f(p.length,e)})).then(function(){return(0<m.length||o&&"object"==typeof e)&&c.mutate({trans:r,type:"put",keys:y,values:m,criteria:o,changeSpec:"function"!=typeof e&&e,isAdditionalChunk:0<n}).then(function(e){return f(m.length,e)})}).then(function(){return(0<v.length||o&&e===Et)&&c.mutate({trans:r,type:"delete",keys:v,criteria:o,isAdditionalChunk:0<n}).then(function(e){return f(v.length,e)})}).then(function(){return t.length>n+a&&i(n+h)})})}var o=yt(n)&&n.limit===1/0&&("function"!=typeof e||e===Et)&&{index:n.index,range:n.range};return i(0).then(function(){if(0<p.length)throw new U("Error modifying one or more objects",p,m,y);return t.length})})})},Ct.prototype.delete=function(){var e=this._ctx,t=e.range;return yt(e)&&(e.isPrimKey||3===t.type)?this._write(function(n){var r=e.table.core.schema.primaryKey,i=t;return e.table.core.count({trans:n,query:{index:r,range:i}}).then(function(t){return e.table.core.mutate({trans:n,type:"deleteRange",range:i}).then(function(e){var n=e.failures;if(e.lastResult,e.results,e=e.numFailures)throw new U("Could not delete some values",Object.keys(n).map(function(e){return n[e]}),t-e);return t-e})})}):this.modify(Et)},Ct);function Ct(){}var Et=function(e,t){return t.value=null};function Ot(e,t){return e<t?-1:e===t?0:1}function Mt(e,t){return t<e?-1:e===t?0:1}function Tt(e,t,n){return(e=e instanceof Lt?new e.Collection(e):e)._ctx.error=new(n||TypeError)(t),e}function Rt(e){return new e.Collection(e,function(){return At("")}).limit(0)}function Dt(e,t,n,r){var i,o,a,s,u,c,l,d=n.length;if(!n.every(function(e){return"string"==typeof e}))return Tt(e,et);function h(e){i="next"===e?function(e){return e.toUpperCase()}:function(e){return e.toLowerCase()},o="next"===e?function(e){return e.toLowerCase()}:function(e){return e.toUpperCase()},a="next"===e?Ot:Mt;var t=n.map(function(e){return{lower:o(e),upper:i(e)}}).sort(function(e,t){return a(e.lower,t.lower)});s=t.map(function(e){return e.upper}),u=t.map(function(e){return e.lower}),l="next"===(c=e)?"":r}h("next"),(e=new e.Collection(e,function(){return Nt(s[0],u[d-1]+r)}))._ondirectionchange=function(e){h(e)};var f=0;return e._addAlgorithm(function(e,n,r){var i=e.key;if("string"!=typeof i)return!1;var h=o(i);if(t(h,u,f))return!0;for(var p=null,m=f;m<d;++m){var y=function(e,t,n,r,i,o){for(var a=Math.min(e.length,r.length),s=-1,u=0;u<a;++u){var c=t[u];if(c!==r[u])return i(e[u],n[u])<0?e.substr(0,u)+n[u]+n.substr(u+1):i(e[u],r[u])<0?e.substr(0,u)+r[u]+n.substr(u+1):0<=s?e.substr(0,s)+t[s]+n.substr(s+1):null;i(e[u],c)<0&&(s=u)}return a<r.length&&"next"===o?e+n.substr(e.length):a<e.length&&"prev"===o?e.substr(0,n.length):s<0?null:e.substr(0,s)+r[s]+n.substr(s+1)}(i,h,s[m],u[m],a,c);null===y&&null===p?f=m+1:(null===p||0<a(p,y))&&(p=y)}return n(null!==p?function(){e.continue(p+l)}:r),!1}),e}function Nt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function At(e){return{type:1,lower:e,upper:e}}var Lt=(Object.defineProperty(Pt.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),Pt.prototype.between=function(e,t,n,r){n=!1!==n,r=!0===r;try{return 0<this._cmp(e,t)||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?Rt(this):new this.Collection(this,function(){return Nt(e,t,!n,!r)})}catch(e){return Tt(this,Ze)}},Pt.prototype.equals=function(e){return null==e?Tt(this,Ze):new this.Collection(this,function(){return At(e)})},Pt.prototype.above=function(e){return null==e?Tt(this,Ze):new this.Collection(this,function(){return Nt(e,void 0,!0)})},Pt.prototype.aboveOrEqual=function(e){return null==e?Tt(this,Ze):new this.Collection(this,function(){return Nt(e,void 0,!1)})},Pt.prototype.below=function(e){return null==e?Tt(this,Ze):new this.Collection(this,function(){return Nt(void 0,e,!1,!0)})},Pt.prototype.belowOrEqual=function(e){return null==e?Tt(this,Ze):new this.Collection(this,function(){return Nt(void 0,e)})},Pt.prototype.startsWith=function(e){return"string"!=typeof e?Tt(this,et):this.between(e,e+Je,!0,!0)},Pt.prototype.startsWithIgnoreCase=function(e){return""===e?this.startsWith(e):Dt(this,function(e,t){return 0===e.indexOf(t[0])},[e],Je)},Pt.prototype.equalsIgnoreCase=function(e){return Dt(this,function(e,t){return e===t[0]},[e],"")},Pt.prototype.anyOfIgnoreCase=function(){var e=P.apply(L,arguments);return 0===e.length?Rt(this):Dt(this,function(e,t){return-1!==t.indexOf(e)},e,"")},Pt.prototype.startsWithAnyOfIgnoreCase=function(){var e=P.apply(L,arguments);return 0===e.length?Rt(this):Dt(this,function(e,t){return t.some(function(t){return 0===e.indexOf(t)})},e,Je)},Pt.prototype.anyOf=function(){var e=this,t=P.apply(L,arguments),n=this._cmp;try{t.sort(n)}catch(r){return Tt(this,Ze)}if(0===t.length)return Rt(this);var r=new this.Collection(this,function(){return Nt(t[0],t[t.length-1])});r._ondirectionchange=function(r){n="next"===r?e._ascending:e._descending,t.sort(n)};var i=0;return r._addAlgorithm(function(e,r,o){for(var a=e.key;0<n(a,t[i]);)if(++i===t.length)return r(o),!1;return 0===n(a,t[i])||(r(function(){e.continue(t[i])}),!1)}),r},Pt.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},Pt.prototype.noneOf=function(){var e=P.apply(L,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return Tt(this,Ze)}var t=e.reduce(function(e,t){return e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]]},null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},Pt.prototype.inAnyRange=function(e,t){var n=this,r=this._cmp,i=this._ascending,o=this._descending,a=this._min,s=this._max;if(0===e.length)return Rt(this);if(!e.every(function(e){return void 0!==e[0]&&void 0!==e[1]&&i(e[0],e[1])<=0}))return Tt(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",V.InvalidArgument);var u,c=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers,d=i;function h(e,t){return d(e[0],t[0])}try{(u=e.reduce(function(e,t){for(var n=0,i=e.length;n<i;++n){var o=e[n];if(r(t[0],o[1])<0&&0<r(t[1],o[0])){o[0]=a(o[0],t[0]),o[1]=s(o[1],t[1]);break}}return n===i&&e.push(t),e},[])).sort(h)}catch(e){return Tt(this,Ze)}var f=0,p=l?function(e){return 0<i(e,u[f][1])}:function(e){return 0<=i(e,u[f][1])},m=c?function(e){return 0<o(e,u[f][0])}:function(e){return 0<=o(e,u[f][0])},y=p;return(e=new this.Collection(this,function(){return Nt(u[0][0],u[u.length-1][1],!c,!l)}))._ondirectionchange=function(e){d="next"===e?(y=p,i):(y=m,o),u.sort(h)},e._addAlgorithm(function(e,t,r){for(var o,a=e.key;y(a);)if(++f===u.length)return t(r),!1;return!p(o=a)&&!m(o)||(0===n._cmp(a,u[f][1])||0===n._cmp(a,u[f][0])||t(function(){d===i?e.continue(u[f][0]):e.continue(u[f][1])}),!1)}),e},Pt.prototype.startsWithAnyOf=function(){var e=P.apply(L,arguments);return e.every(function(e){return"string"==typeof e})?0===e.length?Rt(this):this.inAnyRange(e.map(function(e){return[e,e+Je]})):Tt(this,"startsWithAnyOf() only works with strings")},Pt);function Pt(){}function Ft(e){return Ae(function(t){return jt(t),e(t.target.error),!1})}function jt(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var Bt="storagemutated",qt="x-storagemutated-1",Kt=pt(null,Bt),Ut=(zt.prototype._lock=function(){return b(!ge.global),++this._reculock,1!==this._reculock||ge.global||(ge.lockOwnerFor=this),this},zt.prototype._unlock=function(){if(b(!ge.global),0==--this._reculock)for(ge.global||(ge.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{Ge(e[1],e[0])}catch(e){}}return this},zt.prototype._locked=function(){return this._reculock&&ge.lockOwnerFor!==this},zt.prototype.create=function(e){var t=this;if(!this.mode)return this;var n=this.db.idbdb,r=this.db._state.dbOpenError;if(b(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new V.DatabaseClosed(r);case"MissingAPIError":throw new V.MissingAPI(r.message,r);default:throw new V.OpenFailed(r)}if(!this.active)throw new V.TransactionInactive;return b(null===this._completion._state),(e=this.idbtrans=e||(this.db.core||n).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=Ae(function(n){jt(n),t._reject(e.error)}),e.onabort=Ae(function(n){jt(n),t.active&&t._reject(new V.Abort(e.error)),t.active=!1,t.on("abort").fire(n)}),e.oncomplete=Ae(function(){t.active=!1,t._resolve(),"mutatedParts"in e&&Kt.storagemutated.fire(e.mutatedParts)}),this},zt.prototype._promise=function(e,t,n){var r=this;if("readwrite"===e&&"readwrite"!==this.mode)return Qe(new V.ReadOnly("Transaction is readonly"));if(!this.active)return Qe(new V.TransactionInactive);if(this._locked())return new ke(function(i,o){r._blockedFuncs.push([function(){r._promise(e,t,n).then(i,o)},ge])});if(n)return Ke(function(){var e=new ke(function(e,n){r._lock();var i=t(e,n,r);i&&i.then&&i.then(e,n)});return e.finally(function(){return r._unlock()}),e._lib=!0,e});var i=new ke(function(e,n){var i=t(e,n,r);i&&i.then&&i.then(e,n)});return i._lib=!0,i},zt.prototype._root=function(){return this.parent?this.parent._root():this},zt.prototype.waitFor=function(e){var t,n=this._root(),r=ke.resolve(e);n._waitingFor?n._waitingFor=n._waitingFor.then(function(){return r}):(n._waitingFor=r,n._waitingQueue=[],t=n.idbtrans.objectStore(n.storeNames[0]),function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(t.get(-1/0).onsuccess=e)}());var i=n._waitingFor;return new ke(function(e,t){r.then(function(t){return n._waitingQueue.push(Ae(e.bind(null,t)))},function(e){return n._waitingQueue.push(Ae(t.bind(null,e)))}).finally(function(){n._waitingFor===i&&(n._waitingFor=null)})})},zt.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new V.Abort))},zt.prototype.table=function(e){var t=this._memoizedTables||(this._memoizedTables={});if(l(t,e))return t[e];var n=this.schema[e];if(!n)throw new V.NotFound("Table "+e+" not part of transaction");return(n=new this.db.Table(e,n,this)).core=this.db.core.table(e),t[e]=n},zt);function zt(){}function Wt(e,t,n,r,i,o,a){return{name:e,keyPath:t,unique:n,multi:r,auto:i,compound:o,src:(n&&!a?"&":"")+(r?"*":"")+(i?"++":"")+Ht(t)}}function Ht(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function Vt(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:(r=function(e){return[e.name,e]},n.reduce(function(e,t,n){return(n=r(t,n))&&(e[n[0]]=n[1]),e},{}))};var r}var $t=function(e){try{return e.only([[]]),$t=function(){return[[]]},[[]]}catch(e){return $t=function(){return Je},Je}};function Gt(e){return null==e?function(){}:"string"==typeof e?1===(t=e).split(".").length?function(e){return e[t]}:function(e){return S(e,t)}:function(t){return S(t,e)};var t}function Xt(e){return[].slice.call(e)}var Yt=0;function Qt(e){return null==e?":id":"string"==typeof e?e:"[".concat(e.join("+"),"]")}function Jt(e,t,n){function r(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");var n=e.lower,r=e.upper,i=e.lowerOpen;return e=e.upperOpen,void 0===n?void 0===r?null:t.upperBound(r,!!e):void 0===r?t.lowerBound(n,!!i):t.bound(n,r,!!i,!!e)}function i(e){var t,n=e.name;return{name:n,schema:e,mutate:function(e){var t=e.trans,i=e.type,o=e.keys,a=e.values,s=e.range;return new Promise(function(e,u){e=Ae(e);var c=t.objectStore(n),l=null==c.keyPath,d="put"===i||"add"===i;if(!d&&"delete"!==i&&"deleteRange"!==i)throw new Error("Invalid operation type: "+i);var h,f=(o||a||{length:1}).length;if(o&&a&&o.length!==a.length)throw new Error("Given keys array must have same length as given values array.");if(0===f)return e({numFailures:0,failures:{},results:[],lastResult:void 0});function p(e){++v,jt(e)}var m=[],y=[],v=0;if("deleteRange"===i){if(4===s.type)return e({numFailures:v,failures:y,results:[],lastResult:void 0});3===s.type?m.push(h=c.clear()):m.push(h=c.delete(r(s)))}else{var g=(l=d?l?[a,o]:[a,null]:[o,null])[0],b=l[1];if(d)for(var w=0;w<f;++w)m.push(h=b&&void 0!==b[w]?c[i](g[w],b[w]):c[i](g[w])),h.onerror=p;else for(w=0;w<f;++w)m.push(h=c[i](g[w])),h.onerror=p}function S(t){t=t.target.result,m.forEach(function(e,t){return null!=e.error&&(y[t]=e.error)}),e({numFailures:v,failures:y,results:"delete"===i?o:m.map(function(e){return e.result}),lastResult:t})}h.onerror=function(e){p(e),S(e)},h.onsuccess=S})},getMany:function(e){var t=e.trans,r=e.keys;return new Promise(function(e,i){e=Ae(e);for(var o,a=t.objectStore(n),s=r.length,u=new Array(s),c=0,l=0,d=function(t){t=t.target,u[t._pos]=t.result,++l===c&&e(u)},h=Ft(i),f=0;f<s;++f)null!=r[f]&&((o=a.get(r[f]))._pos=f,o.onsuccess=d,o.onerror=h,++c);0===c&&e(u)})},get:function(e){var t=e.trans,r=e.key;return new Promise(function(e,i){e=Ae(e);var o=t.objectStore(n).get(r);o.onsuccess=function(t){return e(t.target.result)},o.onerror=Ft(i)})},query:(t=l,function(e){return new Promise(function(i,o){i=Ae(i);var a,s,u,c=e.trans,l=e.values,d=e.limit,h=e.query,f=d===1/0?void 0:d,p=h.index;if(h=h.range,c=c.objectStore(n),p=p.isPrimaryKey?c:c.index(p.name),h=r(h),0===d)return i({result:[]});t?((f=l?p.getAll(h,f):p.getAllKeys(h,f)).onsuccess=function(e){return i({result:e.target.result})},f.onerror=Ft(o)):(a=0,s=!l&&"openKeyCursor"in p?p.openKeyCursor(h):p.openCursor(h),u=[],s.onsuccess=function(e){var t=s.result;return t?(u.push(l?t.value:t.primaryKey),++a===d?i({result:u}):void t.continue()):i({result:u})},s.onerror=Ft(o))})}),openCursor:function(e){var t=e.trans,i=e.values,o=e.query,a=e.reverse,s=e.unique;return new Promise(function(e,u){e=Ae(e);var c=o.index,l=o.range,d=t.objectStore(n),h=(d=c.isPrimaryKey?d:d.index(c.name),c=a?s?"prevunique":"prev":s?"nextunique":"next",!i&&"openKeyCursor"in d?d.openKeyCursor(r(l),c):d.openCursor(r(l),c));h.onerror=Ft(u),h.onsuccess=Ae(function(n){var r,i,o,a,s=h.result;s?(s.___id=++Yt,s.done=!1,r=s.continue.bind(s),i=(i=s.continuePrimaryKey)&&i.bind(s),o=s.advance.bind(s),a=function(){throw new Error("Cursor not stopped")},s.trans=t,s.stop=s.continue=s.continuePrimaryKey=s.advance=function(){throw new Error("Cursor not started")},s.fail=Ae(u),s.next=function(){var e=this,t=1;return this.start(function(){return t--?e.continue():e.stop()}).then(function(){return e})},s.start=function(e){function t(){if(h.result)try{e()}catch(e){s.fail(e)}else s.done=!0,s.start=function(){throw new Error("Cursor behind last entry")},s.stop()}var n=new Promise(function(e,t){e=Ae(e),h.onerror=Ft(t),s.fail=t,s.stop=function(t){s.stop=s.continue=s.continuePrimaryKey=s.advance=a,e(t)}});return h.onsuccess=Ae(function(e){h.onsuccess=t,t()}),s.continue=r,s.continuePrimaryKey=i,s.advance=o,t(),n},e(s)):e(null)},u)})},count:function(e){var t=e.query,i=e.trans,o=t.index,a=t.range;return new Promise(function(e,t){var s=i.objectStore(n),u=o.isPrimaryKey?s:s.index(o.name);(u=(s=r(a))?u.count(s):u.count()).onsuccess=Ae(function(t){return e(t.target.result)}),u.onerror=Ft(t)})}}}var o,s,u,c=(s=n,u=Xt((o=e).objectStoreNames),{schema:{name:o.name,tables:u.map(function(e){return s.objectStore(e)}).map(function(e){var t=e.keyPath,n=e.autoIncrement,r=a(t),i={};return n={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:null==t,compound:r,keyPath:t,autoIncrement:n,unique:!0,extractKey:Gt(t)},indexes:Xt(e.indexNames).map(function(t){return e.index(t)}).map(function(e){var t=e.name,n=e.unique,r=e.multiEntry;return e=e.keyPath,r={name:t,compound:a(e),keyPath:e,unique:n,multiEntry:r,extractKey:Gt(e)},i[Qt(e)]=r}),getIndexByKeyPath:function(e){return i[Qt(e)]}},i[":id"]=n.primaryKey,null!=t&&(i[Qt(t)]=n.primaryKey),n})},hasGetAll:0<u.length&&"getAll"in s.objectStore(u[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.user