UNPKG

@betterbugs/web-sdk

Version:

A web sdk package for Betterbugs

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