UNPKG

puppeteer-extra-plugin-session

Version:

A puppeteer plugin to dump and inject session data.

7 lines 124 kB
"use strict"; // https://cdnjs.cloudflare.com/ajax/libs/dexie/3.0.3/dexie.min.js // https://unpkg.com/dexie-export-import@1.0.0/dist/dexie-export-import.js Object.defineProperty(exports, "__esModule", { value: true }); exports.dexieExportImport = exports.dexieCore = void 0; exports.dexieCore = String.raw ` (function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Dexie=t()})(this,function(){"use strict";var m=function(){return(m=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 O(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var o=arguments[t],u=0,a=o.length;u<a;u++,i++)r[i]=o[u];return r}var _=Object.keys,d=Array.isArray,h="undefined"!=typeof self?self:"undefined"!=typeof window?window:global;function s(t,n){return"object"!=typeof n||_(n).forEach(function(e){t[e]=n[e]}),t}"undefined"==typeof Promise||h.Promise||(h.Promise=Promise);var r=Object.getPrototypeOf,n={}.hasOwnProperty;function g(e,t){return n.call(e,t)}function i(t,n){"function"==typeof n&&(n=n(r(t))),_(n).forEach(function(e){a(t,e,n[e])})}var u=Object.defineProperty;function a(e,t,n,r){u(e,t,s(n&&g(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function o(t){return{from:function(e){return t.prototype=Object.create(e.prototype),a(t.prototype,"constructor",t),{extend:i.bind(null,t.prototype)}}}}var c=Object.getOwnPropertyDescriptor;function l(e,t){var n;return c(e,t)||(n=r(e))&&l(n,t)}var f=[].slice;function p(e,t,n){return f.call(e,t,n)}function y(e,t){return t(e)}function v(e){if(!e)throw new Error("Assertion Failed")}function b(e){h.setImmediate?setImmediate(e):setTimeout(e,0)}function w(e,i){return e.reduce(function(e,t,n){var r=i(t,n);return r&&(e[r[0]]=r[1]),e},{})}function x(e,t){if(g(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=x(e,t[r]);n.push(o)}return n}var u=t.indexOf(".");if(-1!==u){var a=e[t.substr(0,u)];return void 0===a?void 0:x(a,t.substr(u+1))}}function k(e,t,n){if(e&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){v("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,u,a=t.indexOf(".");-1!==a?(o=t.substr(0,a),""===(u=t.substr(a+1))?void 0===n?d(e)&&!isNaN(parseInt(o))?e.splice(o,1):delete e[o]:e[o]=n:k(e[o]||(e[o]={}),u,n)):void 0===n?d(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function P(t,e){"string"==typeof e?k(t,e,void 0):"length"in e&&[].map.call(e,function(e){k(t,e,void 0)})}function E(e){var t={};for(var n in e)g(e,n)&&(t[n]=e[n]);return t}var t=[].concat;function j(e){return t.apply([],e)}var e="Boolean,String,Date,RegExp,Blob,File,FileList,ArrayBuffer,DataView,Uint8ClampedArray,ImageData,Map,Set".split(",").concat(j([8,16,32,64].map(function(t){return["Int","Uint","Float"].map(function(e){return e+t+"Array"})}))).filter(function(e){return h[e]}),S=e.map(function(e){return h[e]}),A=w(e,function(e){return[e,!0]});function K(e){if(!e||"object"!=typeof e)return e;var t;if(d(e)){t=[];for(var n=0,r=e.length;n<r;++n)t.push(K(e[n]))}else if(0<=S.indexOf(e.constructor))t=e;else for(var i in t=e.constructor?Object.create(e.constructor.prototype):{},e)g(e,i)&&(t[i]=K(e[i]));return t}var C={}.toString;function I(e){return C.call(e).slice(8,-1)}var T=function(e,t){return"Array"===t?""+e.map(function(e){return T(e,I(e))}):"ArrayBuffer"===t?""+new Uint8Array(e):"Date"===t?e.getTime():ArrayBuffer.isView(e)?""+new Uint8Array(e.buffer):e};function D(o,u,a,s){return a=a||{},s=s||"",_(o).forEach(function(e){var t,n,r,i;g(u,e)?(t=o[e],n=u[e],"object"==typeof t&&"object"==typeof n&&t&&n?(r=I(t))===(i=I(n))?A[r]?T(t,r)!==T(n,i)&&(a[s+e]=u[e]):D(t,n,a,s+e+"."):a[s+e]=u[e]:t!==n&&(a[s+e]=u[e])):a[s+e]=void 0}),_(u).forEach(function(e){g(o,e)||(a[s+e]=u[e])}),a}var B="undefined"!=typeof Symbol&&Symbol.iterator,R=B?function(e){var t;return null!=e&&(t=e[B])&&t.apply(e)}:function(){return null},F={};function q(e){var t,n,r,i;if(1===arguments.length){if(d(e))return e.slice();if(this===F&&"string"==typeof e)return[e];if(i=R(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 M="undefined"!=typeof Symbol?function(e){return"AsyncFunction"===e[Symbol.toStringTag]}:function(){return!1},N="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function U(e,t){N=e,V=t}var V=function(){return!0},W=!new Error("").stack;function z(){if(W)try{throw new Error}catch(e){return e}return new Error}function L(e,t){var n=e.stack;return n?(t=t||0,0===n.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),n.split("\n").slice(t).filter(V).map(function(e){return"\n"+e}).join("")):""}var Y=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],G=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Y),H={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed"};function Q(e,t){this._e=z(),this.name=e,this.message=t}function X(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 J(e,t,n,r){this._e=z(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=X(e,t)}function $(e,t){this._e=z(),this.name="BulkError",this.failures=t,this.message=X(e,t)}o(Q).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+L(this._e,2))}},toString:function(){return this.name+": "+this.message}}),o(J).from(Q),o($).from(Q);var Z=G.reduce(function(e,t){return e[t]=t+"Error",e},{}),ee=Q,te=G.reduce(function(e,n){var r=n+"Error";function t(e,t){this._e=z(),this.name=r,e?"string"==typeof e?(this.message=e+(t?"\n "+t:""),this.inner=t||null):"object"==typeof e&&(this.message=e.name+" "+e.message,this.inner=e):(this.message=H[n]||r,this.inner=null)}return o(t).from(ee),e[n]=t,e},{});te.Syntax=SyntaxError,te.Type=TypeError,te.Range=RangeError;var ne=Y.reduce(function(e,t){return e[t+"Error"]=te[t],e},{});var re=G.reduce(function(e,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=te[t]),e},{});function ie(){}function oe(e){return e}function ue(t,n){return null==t||t===oe?n:function(e){return n(t(e))}}function ae(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function se(i,o){return i===ie?o:function(){var e=i.apply(this,arguments);void 0!==e&&(arguments[0]=e);var t=this.onsuccess,n=this.onerror;this.onsuccess=null,this.onerror=null;var r=o.apply(this,arguments);return t&&(this.onsuccess=this.onsuccess?ae(t,this.onsuccess):t),n&&(this.onerror=this.onerror?ae(n,this.onerror):n),void 0!==r?r:e}}function ce(n,r){return n===ie?r:function(){n.apply(this,arguments);var e=this.onsuccess,t=this.onerror;this.onsuccess=this.onerror=null,r.apply(this,arguments),e&&(this.onsuccess=this.onsuccess?ae(e,this.onsuccess):e),t&&(this.onerror=this.onerror?ae(t,this.onerror):t)}}function le(o,u){return o===ie?u:function(e){var t=o.apply(this,arguments);s(e,t);var n=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;var i=u.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?ae(n,this.onsuccess):n),r&&(this.onerror=this.onerror?ae(r,this.onerror):r),void 0===t?void 0===i?void 0:i:s(t,i)}}function fe(e,t){return e===ie?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function he(i,o){return i===ie?o:function(){var e=i.apply(this,arguments);if(e&&"function"==typeof e.then){for(var t=this,n=arguments.length,r=new Array(n);n--;)r[n]=arguments[n];return e.then(function(){return o.apply(t,r)})}return o.apply(this,arguments)}}re.ModifyError=J,re.DexieError=Q,re.BulkError=$;var pe={},de=100,ye=100,ve="undefined"==typeof Promise?[]:function(){var e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,e.__proto__,e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,t.__proto__,e]}(),me=ve[0],ge=ve[1],be=ve[2],_e=ge&&ge.then,we=me&&me.constructor,xe=!!be,ke=!1,Pe=be?function(){be.then(Le)}:h.setImmediate?setImmediate.bind(null,Le):h.MutationObserver?function(){var e=document.createElement("div");new MutationObserver(function(){Le(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:function(){setTimeout(Le,0)},Ee=function(e,t){De.push([e,t]),je&&(Pe(),je=!1)},Oe=!0,je=!0,Se=[],Ae=[],Ke=null,Ce=oe,Ie={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:yt,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(function(e){try{yt(e[0],e[1])}catch(e){}})}},Te=Ie,De=[],Be=0,Re=[];function Fe(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=ie,this._lib=!1;var t=this._PSD=Te;if(N&&(this._stackHolder=z(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==pe)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Ne(this,this._value))}this._state=null,this._value=null,++t.ref,function t(r,e){try{e(function(n){if(null===r._state){if(n===r)throw new TypeError("A promise cannot be resolved with itself.");var e=r._lib&&Ye();n&&"function"==typeof n.then?t(r,function(e,t){n instanceof Fe?n._then(e,t):n.then(e,t)}):(r._state=!0,r._value=n,Ue(r)),e&&Ge()}},Ne.bind(null,r))}catch(e){Ne(r,e)}}(this,e)}var qe={get:function(){var a=Te,t=tt;function e(n,r){var i=this,o=!a.global&&(a!==Te||t!==tt),u=o&&!ot(),e=new Fe(function(e,t){Ve(i,new Me(ht(n,a,o,u),ht(r,a,o,u),e,t,a))});return N&&ze(e,this),e}return e.prototype=pe,e},set:function(e){a(this,"then",e&&e.prototype===pe?qe:{get:function(){return e},set:qe.set})}};function Me(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 Ne(t,n){var e,r;Ae.push(n),null===t._state&&(e=t._lib&&Ye(),n=Ce(n),t._state=!1,t._value=n,N&&null!==n&&"object"==typeof n&&!n._promise&&function(e,t,n){try{e.apply(null,n)}catch(e){t&&t(e)}}(function(){var e=l(n,"stack");n._promise=t,a(n,"stack",{get:function(){return ke?e&&(e.get?e.get.apply(n):e.value):t.stack}})}),r=t,Se.some(function(e){return e._value===r._value})||Se.push(r),Ue(t),e&&Ge())}function Ue(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Ve(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),0===Be&&(++Be,Ee(function(){0==--Be&&He()},[]))}function Ve(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,++Be,Ee(We,[n,e,t])}else e._listeners.push(t)}function We(e,t,n){try{var r,i=(Ke=t)._value;t._state?r=e(i):(Ae.length&&(Ae=[]),r=e(i),-1===Ae.indexOf(i)&&function(e){var t=Se.length;for(;t;)if(Se[--t]._value===e._value)return Se.splice(t,1)}(t)),n.resolve(r)}catch(e){n.reject(e)}finally{Ke=null,0==--Be&&He(),--n.psd.ref||n.psd.finalize()}}function ze(e,t){var n=t?t._numPrev+1:0;n<de&&(e._prev=t,e._numPrev=n)}function Le(){Ye()&&Ge()}function Ye(){var e=Oe;return je=Oe=!1,e}function Ge(){var e,t,n;do{for(;0<De.length;)for(e=De,De=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(0<De.length);je=Oe=!0}function He(){var e=Se;Se=[],e.forEach(function(e){e._PSD.onunhandled.call(null,e._value,e)});for(var t=Re.slice(0),n=t.length;n;)t[--n]()}function Qe(e){return new Fe(pe,!1,e)}function Xe(n,r){var i=Te;return function(){var e=Ye(),t=Te;try{return st(i,!0),n.apply(this,arguments)}catch(e){r&&r(e)}finally{st(t,!1),e&&Ge()}}}i(Fe.prototype,{then:qe,_then:function(e,t){Ve(this,new Me(null,null,e,t,Te))},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:Qe)(e)}):this.then(null,function(e){return(e&&e.name===t?n:Qe)(e)})},finally:function(t){return this.then(function(e){return t(),e},function(e){return t(),Qe(e)})},stack:{get:function(){if(this._stack)return this._stack;try{ke=!0;var e=function e(t,n,r){if(n.length===r)return n;var i="";{var o,u,a;!1===t._state&&(null!=(o=t._value)?(u=o.name||"Error",a=o.message||o,i=L(o,0)):(u=o,a=""),n.push(u+(a?": "+a:"")+i))}N&&((i=L(t._stackHolder,2))&&-1===n.indexOf(i)&&n.push(i),t._prev&&e(t._prev,n,r));return n}(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{ke=!1}}},timeout:function(r,i){var o=this;return r<1/0?new Fe(function(e,t){var n=setTimeout(function(){return t(new te.Timeout(i))},r);o.then(e,t).finally(clearTimeout.bind(null,n))}):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&a(Fe.prototype,Symbol.toStringTag,"Dexie.Promise"),Ie.env=ct(),i(Fe,{all:function(){var o=q.apply(null,arguments).map(ut);return new Fe(function(n,r){0===o.length&&n([]);var i=o.length;o.forEach(function(e,t){return Fe.resolve(e).then(function(e){o[t]=e,--i||n(o)},r)})})},resolve:function(n){if(n instanceof Fe)return n;if(n&&"function"==typeof n.then)return new Fe(function(e,t){n.then(e,t)});var e=new Fe(pe,!0,n);return ze(e,Ke),e},reject:Qe,race:function(){var e=q.apply(null,arguments).map(ut);return new Fe(function(t,n){e.map(function(e){return Fe.resolve(e).then(t,n)})})},PSD:{get:function(){return Te},set:function(e){return Te=e}},totalEchoes:{get:function(){return tt}},newPSD:rt,usePSD:lt,scheduler:{get:function(){return Ee},set:function(e){Ee=e}},rejectionMapper:{get:function(){return Ce},set:function(e){Ce=e}},follow:function(i,n){return new Fe(function(e,t){return rt(function(n,r){var e=Te;e.unhandleds=[],e.onunhandled=r,e.finalize=ae(function(){var t,e=this;t=function(){0===e.unhandleds.length?n():r(e.unhandleds[0])},Re.push(function e(){t(),Re.splice(Re.indexOf(e),1)}),++Be,Ee(function(){0==--Be&&He()},[])},e.finalize),i()},n,e,t)})}}),we&&(we.allSettled&&a(Fe,"allSettled",function(){var e=q.apply(null,arguments).map(ut);return new Fe(function(n){0===e.length&&n([]);var r=e.length,i=new Array(r);e.forEach(function(e,t){return Fe.resolve(e).then(function(e){return i[t]={status:"fulfilled",value:e}},function(e){return i[t]={status:"rejected",reason:e}}).then(function(){return--r||n(i)})})})}),we.any&&"undefined"!=typeof AggregateError&&a(Fe,"any",function(){var e=q.apply(null,arguments).map(ut);return new Fe(function(n,r){0===e.length&&r(new AggregateError([]));var i=e.length,o=new Array(i);e.forEach(function(e,t){return Fe.resolve(e).then(function(e){return n(e)},function(e){o[t]=e,--i||r(new AggregateError(o))})})})}));var Je={awaits:0,echoes:0,id:0},$e=0,Ze=[],et=0,tt=0,nt=0;function rt(e,t,n,r){var i=Te,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++nt;var u=Ie.env;o.env=xe?{Promise:Fe,PromiseProp:{value:Fe,configurable:!0,writable:!0},all:Fe.all,race:Fe.race,allSettled:Fe.allSettled,any:Fe.any,resolve:Fe.resolve,reject:Fe.reject,nthen:pt(u.nthen,o),gthen:pt(u.gthen,o)}:{},t&&s(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=lt(o,e,n,r);return 0===o.ref&&o.finalize(),a}function it(){return Je.id||(Je.id=++$e),++Je.awaits,Je.echoes+=ye,Je.id}function ot(){return!!Je.awaits&&(0==--Je.awaits&&(Je.id=0),Je.echoes=Je.awaits*ye,!0)}function ut(e){return Je.echoes&&e&&e.constructor===we?(it(),e.then(function(e){return ot(),e},function(e){return ot(),vt(e)})):e}function at(){var e=Ze[Ze.length-1];Ze.pop(),st(e,!1)}function st(e,t){var n,r,i=Te;(t?!Je.echoes||et++&&e===Te:!et||--et&&e===Te)||ft(t?function(e){++tt,Je.echoes&&0!=--Je.echoes||(Je.echoes=Je.id=0),Ze.push(Te),st(e,!0)}.bind(null,e):at),e!==Te&&(Te=e,i===Ie&&(Ie.env=ct()),xe&&(n=Ie.env.Promise,r=e.env,ge.then=r.nthen,n.prototype.then=r.gthen,(i.global||e.global)&&(Object.defineProperty(h,"Promise",r.PromiseProp),n.all=r.all,n.race=r.race,n.resolve=r.resolve,n.reject=r.reject,r.allSettled&&(n.allSettled=r.allSettled),r.any&&(n.any=r.any))))}function ct(){var e=h.Promise;return xe?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(h,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:ge.then,gthen:e.prototype.then}:{}}function lt(e,t,n,r,i){var o=Te;try{return st(e,!0),t(n,r,i)}finally{st(o,!1)}}function ft(e){_e.call(me,e)}function ht(t,n,r,i){return"function"!=typeof t?t:function(){var e=Te;r&&it(),st(n,!0);try{return t.apply(this,arguments)}finally{st(e,!1),i&&ft(ot)}}}function pt(n,r){return function(e,t){return n.call(this,ht(e,r),ht(t,r))}}-1===(""+_e).indexOf("[native code]")&&(it=ot=ie);var dt="unhandledrejection";function yt(e,t){var n;try{n=t.onuncatched(e)}catch(e){}if(!1!==n)try{var r,i={promise:t,reason:e};if(h.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(dt,!0,!0),s(r,i)):h.CustomEvent&&s(r=new CustomEvent(dt,{detail:i}),i),r&&h.dispatchEvent&&(dispatchEvent(r),!h.PromiseRejectionEvent&&h.onunhandledrejection))try{h.onunhandledrejection(r)}catch(e){}N&&r&&!r.defaultPrevented&&console.warn("Unhandled rejection: "+(e.stack||e))}catch(e){}}var vt=Fe.reject;function mt(e){return!/(dexie\.js|dexie\.min\.js)/.test(e)}var gt=String.fromCharCode(65535),bt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",_t="String expected.",wt=[],xt="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),kt=xt,Pt=xt,Et="__dbnames",Ot="readonly",jt="readwrite";function St(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 Kt(t){return function(e){return void 0===x(e,t)&&P(e=K(e),t),e}}var Ct=(It.prototype._trans=function(e,r,t){var n=this._tx||Te.trans,i=this.name;function o(e,t,n){if(!n.schema[i])throw new te.NotFound("Table "+i+" not part of transaction");return r(n.idbtrans,n)}var u=Ye();try{return n&&n.db===this.db?n===Te.trans?n._promise(e,o,t):rt(function(){return n._promise(e,o,t)},{trans:n,transless:Te.transless||Te}):function e(t,n,r,i){if(t._state.openComplete||Te.letThrough){var o=t._createTransaction(n,r,t._dbSchema);try{o.create()}catch(e){return vt(e)}return o._promise(n,function(e,t){return rt(function(){return Te.trans=o,i(e,t,o)})}).then(function(e){return o._completion.then(function(){return e})})}if(!t._state.isBeingOpened){if(!t._options.autoOpen)return vt(new te.DatabaseClosed);t.open().catch(ie)}return t._state.dbReadyPromise.then(function(){return e(t,n,r,i)})}(this.db,e,[this.name],o)}finally{u&&Ge()}},It.prototype.get=function(t,e){var n=this;return t&&t.constructor===Object?this.where(t).first(e):this._trans("readonly",function(e){return n.core.get({trans:e,key:t}).then(function(e){return n.hook.reading.fire(e)})}).then(e)},It.prototype.where=function(u){if("string"==typeof u)return new this.db.WhereClause(this,u);if(d(u))return new this.db.WhereClause(this,"["+u.join("+")+"]");var n=_(u);if(1===n.length)return this.where(n[0]).equals(u[n[0]]);var e=this.schema.indexes.concat(this.schema.primKey).filter(function(t){return t.compound&&n.every(function(e){return 0<=t.keyPath.indexOf(e)})&&t.keyPath.every(function(e){return 0<=n.indexOf(e)})})[0];if(e&&this.db._maxKey!==gt)return this.where(e.name).equals(e.keyPath.map(function(e){return u[e]}));!e&&N&&console.warn("The query "+JSON.stringify(u)+" on "+this.name+" would benefit of a compound index ["+n.join("+")+"]");var a=this.schema.idxByName,r=this.db._deps.indexedDB;function s(e,t){try{return 0===r.cmp(e,t)}catch(e){return!1}}var t=n.reduce(function(e,n){var t=e[0],r=e[1],i=a[n],o=u[n];return[t||i,t||!i?St(r,i&&i.multi?function(e){var t=x(e,n);return d(t)&&t.some(function(e){return s(o,e)})}:function(e){return s(o,x(e,n))}):r]},[null,null]),i=t[0],o=t[1];return i?this.where(i.name).equals(u[i.keyPath]).filter(o):e?this.filter(o):this.where(n).equals("")},It.prototype.filter=function(e){return this.toCollection().and(e)},It.prototype.count=function(e){return this.toCollection().count(e)},It.prototype.offset=function(e){return this.toCollection().offset(e)},It.prototype.limit=function(e){return this.toCollection().limit(e)},It.prototype.each=function(e){return this.toCollection().each(e)},It.prototype.toArray=function(e){return this.toCollection().toArray(e)},It.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},It.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,d(e)?"["+e.join("+")+"]":e))},It.prototype.reverse=function(){return this.toCollection().reverse()},It.prototype.mapToClass=function(r){function e(e){if(!e)return e;var t=Object.create(r.prototype);for(var n in e)if(g(e,n))try{t[n]=e[n]}catch(e){}return t}return this.schema.mappedClass=r,this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=e,this.hook("reading",e),r},It.prototype.defineClass=function(){return this.mapToClass(function(e){s(this,e)})},It.prototype.add=function(t,n){var r=this,e=this.schema.primKey,i=e.auto,o=e.keyPath,u=t;return o&&i&&(u=Kt(o)(t)),this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[u]})}).then(function(e){return e.numFailures?Fe.reject(e.failures[0]):e.lastResult}).then(function(e){if(o)try{k(t,o,e)}catch(e){}return e})},It.prototype.update=function(t,n){if("object"!=typeof n||d(n))throw new te.InvalidArgument("Modifications must be an object.");if("object"!=typeof t||d(t))return this.where(":id").equals(t).modify(n);_(n).forEach(function(e){k(t,e,n[e])});var e=x(t,this.schema.primKey.keyPath);return void 0===e?vt(new te.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(n)},It.prototype.put=function(t,n){var r=this,e=this.schema.primKey,i=e.auto,o=e.keyPath,u=t;return o&&i&&(u=Kt(o)(t)),this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"put",values:[u],keys:null!=n?[n]:null})}).then(function(e){return e.numFailures?Fe.reject(e.failures[0]):e.lastResult}).then(function(e){if(o)try{k(t,o,e)}catch(e){}return e})},It.prototype.delete=function(t){var n=this;return this._trans("readwrite",function(e){return n.core.mutate({trans:e,type:"delete",keys:[t]})}).then(function(e){return e.numFailures?Fe.reject(e.failures[0]):void 0})},It.prototype.clear=function(){var t=this;return this._trans("readwrite",function(e){return t.core.mutate({trans:e,type:"deleteRange",range:At})}).then(function(e){return e.numFailures?Fe.reject(e.failures[0]):void 0})},It.prototype.bulkGet=function(t){var n=this;return this._trans("readonly",function(e){return n.core.getMany({keys:t,trans:e}).then(function(e){return e.map(function(e){return n.hook.reading.fire(e)})})})},It.prototype.bulkAdd=function(u,e,t){var a=this,s=Array.isArray(e)?e:void 0,c=(t=t||(s?void 0:e))?t.allKeys:void 0;return this._trans("readwrite",function(e){var t=a.schema.primKey,n=t.auto,r=t.keyPath;if(r&&s)throw new te.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(s&&s.length!==u.length)throw new te.InvalidArgument("Arguments objects and keys must have the same length");var o=u.length,i=r&&n?u.map(Kt(r)):u;return a.core.mutate({trans:e,type:"add",keys:s,values:i,wantResults:c}).then(function(e){var t=e.numFailures,n=e.results,r=e.lastResult,i=e.failures;if(0===t)return c?n:r;throw new $(a.name+".bulkAdd(): "+t+" of "+o+" operations failed",Object.keys(i).map(function(e){return i[e]}))})})},It.prototype.bulkPut=function(u,e,t){var a=this,s=Array.isArray(e)?e:void 0,c=(t=t||(s?void 0:e))?t.allKeys:void 0;return this._trans("readwrite",function(e){var t=a.schema.primKey,n=t.auto,r=t.keyPath;if(r&&s)throw new te.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(s&&s.length!==u.length)throw new te.InvalidArgument("Arguments objects and keys must have the same length");var o=u.length,i=r&&n?u.map(Kt(r)):u;return a.core.mutate({trans:e,type:"put",keys:s,values:i,wantResults:c}).then(function(e){var t=e.numFailures,n=e.results,r=e.lastResult,i=e.failures;if(0===t)return c?n:r;throw new $(a.name+".bulkPut(): "+t+" of "+o+" operations failed",Object.keys(i).map(function(e){return i[e]}))})})},It.prototype.bulkDelete=function(t){var i=this,o=t.length;return this._trans("readwrite",function(e){return i.core.mutate({trans:e,type:"delete",keys:t})}).then(function(e){var t=e.numFailures,n=e.lastResult,r=e.failures;if(0===t)return n;throw new $(i.name+".bulkDelete(): "+t+" of "+o+" operations failed",r)})},It);function It(){}function Tt(i){var u={},t=function(e,t){if(t){for(var n=arguments.length,r=new Array(n-1);--n;)r[n-1]=arguments[n];return u[e].subscribe.apply(null,r),i}if("string"==typeof e)return u[e]};t.addEventType=a;for(var e=1,n=arguments.length;e<n;++e)a(arguments[e]);return t;function a(e,n,r){if("object"!=typeof e){var i;n=n||fe;var o={subscribers:[],fire:r=r||ie,subscribe:function(e){-1===o.subscribers.indexOf(e)&&(o.subscribers.push(e),o.fire=n(o.fire,e))},unsubscribe:function(t){o.subscribers=o.subscribers.filter(function(e){return e!==t}),o.fire=o.subscribers.reduce(n,r)}};return u[e]=t[e]=o,o}_(i=e).forEach(function(e){var t=i[e];if(d(t))a(e,i[e][0],i[e][1]);else{if("asap"!==t)throw new te.InvalidArgument("Invalid event config");var n=a(e,oe,function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){b(function(){e.apply(null,t)})})})}})}}function Dt(e,t){return o(t).from({prototype:e}),t}function Bt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Rt(e,t){e.filter=St(e.filter,t)}function Ft(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return St(r(),t())}:t,e.justLimit=n&&!r}function qt(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(!n)throw new te.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Mt(e,t,n){var r=qt(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 Nt(e,o,t,n){var u=e.replayFilter?St(e.filter,e.replayFilter()):e.filter;if(e.or){var a={},r=function(e,t,n){var r,i;u&&!u(t,n,function(e){return t.stop(e)},function(e){return t.fail(e)})||("[object ArrayBuffer]"===(i=""+(r=t.primaryKey))&&(i=""+new Uint8Array(r)),g(a,i)||(a[i]=!0,o(e,t,n)))};return Promise.all([e.or._iterate(r,t),Ut(Mt(e,n,t),e.algorithm,r,!e.keysOnly&&e.valueMapper)])}return Ut(Mt(e,n,t),St(e.algorithm,u),o,!e.keysOnly&&e.valueMapper)}function Ut(e,r,i,o){var u=Xe(o?function(e,t,n){return i(o(e),t,n)}:i);return e.then(function(n){if(n)return n.start(function(){var t=function(){return n.continue()};r&&!r(n,function(e){return t=e},function(e){n.stop(e),t=ie},function(e){n.fail(e),t=ie})||u(n.value,n,function(e){return t=e}),t()})})}var Vt=(Wt.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,vt.bind(null,n.error)):n.table._trans("readonly",e).then(t)},Wt.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,vt.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},Wt.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=St(t.algorithm,e)},Wt.prototype._iterate=function(e,t){return Nt(this._ctx,e,t,this._ctx.table.core)},Wt.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},Wt.prototype.raw=function(){return this._ctx.valueMapper=null,this},Wt.prototype.each=function(t){var n=this._ctx;return this._read(function(e){return Nt(n,t,e,n.table.core)})},Wt.prototype.count=function(e){var i=this;return this._read(function(e){var t=i._ctx,n=t.table.core;if(Bt(t,!0))return n.count({trans:e,query:{index:qt(t,n.schema),range:t.range}}).then(function(e){return Math.min(e,t.limit)});var r=0;return Nt(t,function(){return++r,!1},e,n).then(function(){return r})}).then(e)},Wt.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 u="next"===this._ctx.dir?1:-1;function a(e,t){var n=o(e,i),r=o(t,i);return n<r?-u:r<n?u:0}return this.toArray(function(e){return e.sort(a)}).then(t)},Wt.prototype.toArray=function(e){var o=this;return this._read(function(e){var t=o._ctx;if("next"===t.dir&&Bt(t,!0)&&0<t.limit){var n=t.valueMapper,r=qt(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:r,range:t.range}}).then(function(e){var t=e.result;return n?t.map(n):t})}var i=[];return Nt(t,function(e){return i.push(e)},e,t.table.core).then(function(){return i})},e)},Wt.prototype.offset=function(t){var e=this._ctx;return t<=0||(e.offset+=t,Bt(e)?Ft(e,function(){var n=t;return function(e,t){return 0===n||(1===n?--n:t(function(){e.advance(n),n=0}),!1)}}):Ft(e,function(){var e=t;return function(){return--e<0}})),this},Wt.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Ft(this._ctx,function(){var r=e;return function(e,t,n){return--r<=0&&t(n),0<=r}},!0),this},Wt.prototype.until=function(r,i){return Rt(this._ctx,function(e,t,n){return!r(e.value)||(t(n),i)}),this},Wt.prototype.first=function(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)},Wt.prototype.last=function(e){return this.reverse().first(e)},Wt.prototype.filter=function(t){var e,n;return Rt(this._ctx,function(e){return t(e.value)}),e=this._ctx,n=t,e.isMatch=St(e.isMatch,n),this},Wt.prototype.and=function(e){return this.filter(e)},Wt.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},Wt.prototype.reverse=function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},Wt.prototype.desc=function(){return this.reverse()},Wt.prototype.eachKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.key,t)})},Wt.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},Wt.prototype.eachPrimaryKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.primaryKey,t)})},Wt.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)},Wt.prototype.primaryKeys=function(e){var n=this._ctx;if("next"===n.dir&&Bt(n,!0)&&0<n.limit)return this._read(function(e){var t=qt(n,n.table.core.schema);return n.table.core.query({trans:e,values:!1,limit:n.limit,query:{index:t,range:n.range}})}).then(function(e){return e.result}).then(e);n.keysOnly=!n.isMatch;var r=[];return this.each(function(e,t){r.push(t.primaryKey)}).then(function(){return r}).then(e)},Wt.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},Wt.prototype.firstKey=function(e){return this.limit(1).keys(function(e){return e[0]}).then(e)},Wt.prototype.lastKey=function(e){return this.reverse().firstKey(e)},Wt.prototype.distinct=function(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var r={};return Rt(this._ctx,function(e){var t=e.primaryKey.toString(),n=g(r,t);return r[t]=!0,!n}),this},Wt.prototype.modify=function(c){var n=this,r=this._ctx;return this._write(function(h){var o,u,p;function d(e,t){var n=t.failures,r=t.numFailures;s+=e-r;for(var i=0,o=_(n);i<o.length;i++){var u=o[i];a.push(n[u])}}p="function"==typeof c?c:(o=_(c),u=o.length,function(e){for(var t=!1,n=0;n<u;++n){var r=o[n],i=c[r];x(e,r)!==i&&(k(e,r,i),t=!0)}return t});var y=r.table.core,e=y.schema.primaryKey,v=e.outbound,m=e.extractKey,g="testmode"in Rn?1:2e3,b=n.db.core.cmp,a=[],s=0,t=[];return n.clone().primaryKeys().then(function(l){var f=function(s){var c=Math.min(g,l.length-s);return y.getMany({trans:h,keys:l.slice(s,s+c)}).then(function(e){for(var n=[],t=[],r=v?[]:null,i=[],o=0;o<c;++o){var u=e[o],a={value:K(u),primKey:l[s+o]};!1!==p.call(a,a.value,a)&&(null==a.value?i.push(l[s+o]):v||0===b(m(u),m(a.value))?(t.push(a.value),v&&r.push(l[s+o])):(i.push(l[s+o]),n.push(a.value)))}return Promise.resolve(0<n.length&&y.mutate({trans:h,type:"add",values:n}).then(function(e){for(var t in e.failures)i.splice(parseInt(t),1);d(n.length,e)})).then(function(e){return 0<t.length&&y.mutate({trans:h,type:"put",keys:r,values:t}).then(function(e){return d(t.length,e)})}).then(function(){return 0<i.length&&y.mutate({trans:h,type:"delete",keys:i}).then(function(e){return d(i.length,e)})}).then(function(){return l.length>s+c&&f(s+g)})})};return f(0).then(function(){if(0<a.length)throw new J("Error modifying one or more objects",a,s,t);return l.length})})})},Wt.prototype.delete=function(){var i=this._ctx,r=i.range;return Bt(i)&&(i.isPrimKey&&!Pt||3===r.type)?this._write(function(e){var t=i.table.core.schema.primaryKey,n=r;return i.table.core.count({trans:e,query:{index:t,range:n}}).then(function(r){return i.table.core.mutate({trans:e,type:"deleteRange",range:n}).then(function(e){var t=e.failures,n=(e.lastResult,e.results,e.numFailures);if(n)throw new J("Could not delete some values",Object.keys(t).map(function(e){return t[e]}),r-n);return r-n})})}):this.modify(function(e,t){return t.value=null})},Wt);function Wt(){}function zt(e,t){return e<t?-1:e===t?0:1}function Lt(e,t){return t<e?-1:e===t?0:1}function Yt(e,t,n){var r=e instanceof $t?new e.Collection(e):e;return r._ctx.error=new(n||TypeError)(t),r}function Gt(e){return new e.Collection(e,function(){return Jt("")}).limit(0)}function Ht(e,t,n,r,i,o){for(var u=Math.min(e.length,r.length),a=-1,s=0;s<u;++s){var c=t[s];if(c!==r[s])return i(e[s],n[s])<0?e.substr(0,s)+n[s]+n.substr(s+1):i(e[s],r[s])<0?e.substr(0,s)+r[s]+n.substr(s+1):0<=a?e.substr(0,a)+t[a]+n.substr(a+1):null;i(e[s],c)<0&&(a=s)}return u<r.length&&"next"===o?e+n.substr(e.length):u<e.length&&"prev"===o?e.substr(0,n.length):a<0?null:e.substr(0,a)+r[a]+n.substr(a+1)}function Qt(e,s,n,r){var i,c,l,f,h,p,d,y=n.length;if(!n.every(function(e){return"string"==typeof e}))return Yt(e,_t);function t(e){i="next"===e?function(e){return e.toUpperCase()}:function(e){return e.toLowerCase()},c="next"===e?function(e){return e.toLowerCase()}:function(e){return e.toUpperCase()},l="next"===e?zt:Lt;var t=n.map(function(e){return{lower:c(e),upper:i(e)}}).sort(function(e,t){return l(e.lower,t.lower)});f=t.map(function(e){return e.upper}),h=t.map(function(e){return e.lower}),d="next"===(p=e)?"":r}t("next");var o=new e.Collection(e,function(){return Xt(f[0],h[y-1]+r)});o._ondirectionchange=function(e){t(e)};var v=0;return o._addAlgorithm(function(e,t,n){var r=e.key;if("string"!=typeof r)return!1;var i=c(r);if(s(i,h,v))return!0;for(var o=null,u=v;u<y;++u){var a=Ht(r,i,f[u],h[u],l,p);null===a&&null===o?v=u+1:(null===o||0<l(o,a))&&(o=a)}return t(null!==o?function(){e.continue(o+d)}:n),!1}),o}function Xt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Jt(e){return{type:1,lower:e,upper:e}}var $t=(Object.defineProperty(Zt.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!0,configurable:!0}),Zt.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)?Gt(this):new this.Collection(this,function(){return Xt(e,t,!n,!r)})}catch(e){return Yt(this,bt)}},Zt.prototype.equals=function(e){return null==e?Yt(this,bt):new this.Collection(this,function(){return Jt(e)})},Zt.prototype.above=function(e){return null==e?Yt(this,bt):new this.Collection(this,function(){return Xt(e,void 0,!0)})},Zt.prototype.aboveOrEqual=function(e){return null==e?Yt(this,bt):new this.Collection(this,function(){return Xt(e,void 0,!1)})},Zt.prototype.below=function(e){return null==e?Yt(this,bt):new this.Collection(this,function(){return Xt(void 0,e,!1,!0)})},Zt.prototype.belowOrEqual=function(e){return null==e?Yt(this,bt):new this.Collection(this,function(){return Xt(void 0,e)})},Zt.prototype.startsWith=function(e){return"string"!=typeof e?Yt(this,_t):this.between(e,e+gt,!0,!0)},Zt.prototype.startsWithIgnoreCase=function(e){return""===e?this.startsWith(e):Qt(this,function(e,t){return 0===e.indexOf(t[0])},[e],gt)},Zt.prototype.equalsIgnoreCase=function(e){return Qt(this,function(e,t){return e===t[0]},[e],"")},Zt.prototype.anyOfIgnoreCase=function(){var e=q.apply(F,arguments);return 0===e.length?Gt(this):Qt(this,function(e,t){return-1!==t.indexOf(e)},e,"")},Zt.prototype.startsWithAnyOfIgnoreCase=function(){var e=q.apply(F,arguments);return 0===e.length?Gt(this):Qt(this,function(t,e){return e.some(function(e){return 0===t.indexOf(e)})},e,gt)},Zt.prototype.anyOf=function(){var t=this,i=q.apply(F,arguments),o=this._cmp;try{i.sort(o)}catch(e){return Yt(this,bt)}if(0===i.length)return Gt(this);var e=new this.Collection(this,function(){return Xt(i[0],i[i.length-1])});e._ondirectionchange=function(e){o="next"===e?t._ascending:t._descending,i.sort(o)};var u=0;return e._addAlgorithm(function(e,t,n){for(var r=e.key;0<o(r,i[u]);)if(++u===i.length)return t(n),!1;return 0===o(r,i[u])||(t(function(){e.continue(i[u])}),!1)}),e},Zt.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},Zt.prototype.noneOf=function(){var e=q.apply(F,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return Yt(this,bt)}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})},Zt.prototype.inAnyRange=function(e,t){var o=this,u=this._cmp,a=this._ascending,n=this._descending,s=this._min,c=this._max;if(0===e.length)return Gt(this);if(!e.every(function(e){return void 0!==e[0]&&void 0!==e[1]&&a(e[0],e[1])<=0}))return Yt(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",te.InvalidArgument);var l,r=!t||!1!==t.includeLowers,i=t&&!0===t.includeUppers,f=a;function h(e,t){return f(e[0],t[0])}try{(l=e.reduce(function(e,t){for(var n=0,r=e.length;n<r;++n){var i=e[n];if(u(t[0],i[1])<0&&0<u(t[1],i[0])){i[0]=s(i[0],t[0]),i[1]=c(i[1],t[1]);break}}return n===r&&e.push(t),e},[])).sort(h)}catch(e){return Yt(this,bt)}var p=0,d=i?function(e){return 0<a(e,l[p][1])}:function(e){return 0<=a(e,l[p][1])},y=r?function(e){return 0<n(e,l[p][0])}:function(e){return 0<=n(e,l[p][0])},v=d,m=new this.Collection(this,function(){return Xt(l[0][0],l[l.length-1][1],!r,!i)});return m._ondirectionchange=function(e){f="next"===e?(v=d,a):(v=y,n),l.sort(h)},m._addAlgorithm(function(e,t,n){for(var r,i=e.key;v(i);)if(++p===l.length)return t(n),!1;return!d(r=i)&&!y(r)||(0===o._cmp(i,l[p][1])||0===o._cmp(i,l[p][0])||t(function(){f===a?e.continue(l[p][0]):e.continue(l[p][1])}),!1)}),m},Zt.prototype.startsWithAnyOf=function(){var e=q.apply(F,arguments);return e.every(function(e){return"string"==typeof e})?0===e.length?Gt(this):this.inAnyRange(e.map(function(e){return[e,e+gt]})):Yt(this,"startsWithAnyOf() only works with strings")},Zt);function Zt(){}function en(e){return 1===e.length?e[0]:e}function tn(e){try{return e.only([[]]),[[]]}catch(e){return gt}}function nn(t){return Xe(function(e){return rn(e),t(e.target.error),!1})}function rn(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var on=(un.prototype._lock=function(){return v(!Te.global),++this._reculock,1!==this._reculock||Te.global||(Te.lockOwnerFor=this),this},un.prototype._unlock=function(){if(v(!Te.global),0==--this._reculock)for(Te.global||(Te.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{lt(e[1],e[0])}catch(e){}}return this},un.prototype._locked=function(){return this._reculock&&Te.lockOwnerFor!==this},un.prototype.create=function(t){var n=this;if(!this.mode)return this;var e=this.db.idbdb,r=this.db._state.dbOpenError;if(v(!this.idbtrans),!t&&!e)switch(r&&r.name){case"DatabaseClosedError":throw new te.DatabaseClosed(r);case"MissingAPIError":throw new te.MissingAPI(r.message,r);default:throw new te.OpenFailed(r)}if(!this.active)throw new te.TransactionInactive;return v(null===this._completion._state),(t=this.idbtrans=t||e.transaction(en(this.storeNames),this.mode)).onerror=Xe(function(e){rn(e),n._reject(t.error)}),t.onabort=Xe(function(e){rn(e),n.active&&n._reject(new te.Abort(t.error)),n.active=!1,n.on("abort").fire(e)}),t.oncomplete=Xe(function(){n.active=!1,n._resolve()}),this},un.prototype._promise=function(n,r,i){var o=this;if("readwrite"===n&&"readwrite"!==this.mode)return vt(new te.ReadOnly("Transaction is readonly"));if(!this.active)return vt(new te.TransactionInactive);if(this._locked())return new Fe(function(e,t){o._blockedFuncs.push([function(){o._promise(n,r,i).then(e,t)},Te])});if(i)return rt(function(){var e=new Fe(function(e,t){o._lock();var n=r(e,t,o);n&&n.then&&n.then(e,t)});return e.finally(function(){return o._unlock()}),e._lib=!0,e});var e=new Fe(function(e,t){var n=r(e,t,o);n&&n.then&&n.then(e,t)});return e._lib=!0,e},un.prototype._root=function(){return this.parent?this.parent._root():this},un.prototype.waitFor=function(e){var t,r=this._root(),i=Fe.resolve(e);r._waitingFor?r._waitingFor=r._waitingFor.then(function(){return i}):(r._waitingFor=i,r._waitingQueue=[],t=r.idbtrans.objectStore(r.storeNames[0]),function e(){for(++r._spinCount;r._waitingQueue.length;)r._waitingQueue.shift()();r._waitingFor&&(t.get(-1/0).onsuccess=e)}());var o=r._waitingFor;return new Fe(function(t,n){i.then(function(e){return r._waitingQueue.push(Xe(t.bind(null,e)))},function(e){return r._waitingQueue.push(Xe(n.bind(null,e)))}).finally(function(){r._waitingFor===o&&(r._waitingFor=null)})})},un.prototype.abort=function(){this.active&&this._reject(new te.Abort),this.active=!1},un.prototype.table=function(e){var t=this._memoizedTables||(this._memoizedTables={});if(g(t,e))return t[e];var n=this.schema[e];if(!n)throw new te.NotFound("Table "+e+" not part of transaction");var r=new this.db.Table(e,n,this);return r.core=this.db.core.table(e),t[e]=r},un);function un(){}function an(e,t,n,r,i,o,u){return{name:e,keyPath:t,unique:n,multi:r,auto:i,compound:o,src:(n&&!u?"&":"")+(r?"*":"")+(i?"++":"")+sn(t)}}function sn(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function cn(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:w(n,function(e){return[e.name,e]})}}function ln(t){return null==t?function(){}:"string"==typeof t?1===(n=t).split(".").length?function(e){return e[n]}:function(e){return x(e,n)}:function(e){return x(e,t)};var n}function fn(e,t){return"delete"===t.type?t.keys:t.keys||t.values.map(e.extractKey)}function hn(e){return[].slice.call(e)}var pn=0;function dn(e){return null==e?":id":"string"==typeof e?e:"["+e.join("+")+"]"}function yn(e,t,o,n){var r=t.cmp.bind(t);function E(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");var t=e.lower,n=e.upper,r=e.lowerOpen,i=e.upperOpen;return void 0===t?void 0===n?null:o.upperBound(n,!!i):void 0===n?o.lowerBound(t,!!r):o.bound(t,n,!!r,!!i)}function i(k){var m,P=k.name;return{name:P,schema:k,mutate:function(e){var m=e.trans,g=e.type,b=e.keys,_=e.values,w=e.range,x=e.wantResults;return new Promise(function(n,e){n=Xe(n);var t=m.objectStore(P),r=null==t.keyPath,i="put"===g||"add"===g;if(!i&&"delete"!==g&&"deleteRange"!==g)throw new Error("Invalid operation type: "+g);var o=(b||_||{length:1}).length;if(b&&_&&b.length!==_.length)throw new Error("Given keys array must have same length as given values array.");if(0===o)return n({numFailures:0,failures:{},results:[],lastResult:void 0});function u(e){++f,rn(e),c&&(c[e.target._reqno]=void 0),l[e.target._reqno]=e.target.error}function a(e){var t=e.target;c[t._reqno]=t.result}var s,c=x&&O(b||fn(k.primaryKey,{type:g,keys:b,values:_})),l=[],f=0;if("deleteRange"===g){if(4===w.type)return n({numFailures:f,failures:l,results:c,lastResult:void 0});s=3===w.type?t.clear():t.delete(E(w))}else{var h=i?r?[_,b]:[_,null]:[b,null],p=h[0],d=h[1];if(i)for(var y=0;y<o;++y)(s=d&&void 0!==d[y]?t[g](p[y],d[y]):t[g](p[y]))._reqno=y,c&&void 0===c[y]&&(s.onsuccess=a),s.onerror=u;else for(y=0;y<o;++y)(s=t[g](p[y]))._reqno=y,s.onerror=u}function v(e){var t=e.target.result;c&&(c[o-1]=t),n({numFailures:f,failures:l,results:c,lastResult:t})}s.onerror=function(e){u(e),v(e)},s.onsuccess=v})},getMany:function(e){var f=e.trans,h=e.keys;return new Promise(function(n,e){n=Xe(n);for(var t,r=f.objectStore(P),i=h.length,o=new Array(i),u=0,a=0,s=function(e){var t=e.target;null!=(o[t._pos]=t.result)&&0,++a===u&&n(o)},c=nn(e),l=0;l<i;++l){null!=h[l]&&((t=r.get(h[l]))._pos=l,t.onsuccess=s,t.onerror=c,++u)}0===u&&n(o)})},get:function(e){var r=e.trans,i=e.key;return new Promise(function(t,e){t=Xe(t);var n=r.objectStore(P).get(i);n.onsuccess=function(e){return t(e.target.result)},n.onerror=nn(e)})},query:(m=f,function(v){return new Promise(function(n,e){n=Xe(n);var t,r,i,o,u=v.trans,a=v.values,s=v.limit,c=v.query,l=s===1/0?void 0:s,f=c.index,h=c.range,p=u.objectStore(P),d=f.isPrimaryKey?p:p.index(f.name),y=E(h);if(0===s)return n({result:[]});m?((t=a?d.getAll(y,l):d.getAllKeys(y,l)).onsuccess=function(e){return n({result:e.target.result})},t.onerror=nn(e)):(r=0,i=!a&&"openKeyCursor"in d?d.openKeyCursor(y):d.openCursor(y),o=[],i.onsuccess=function(e){var t=i.result;return t?(o.push(a?t.value:t.primaryKey),++r===s?n({result:o}):void t.continue()):n({result:o})},i.onerror=nn(e))})}),openCursor:function(e){var c=e.trans,a=e.values,l=e.query,f=e.reverse,h=e.unique;return new Promise(function(t,n){t=Xe(t);var e=l.index,r=l.range,i=c.objectStore(P),o=e.isPrimaryKey?i:i.index(e.name),u=f?h?"prevunique":"prev":h?"nextunique":"next",s=!a&&"openKeyCursor"in o?o.openKeyCursor(E(r),u):o.openCursor(E(r),u);s.onerror=nn(n),s.onsuccess=Xe(function(e){var r,i,o,u,a=s.result;a?(a.___id=++pn,a.done=!1,r=a.continue.bind(a),i=(i=a.continuePrimaryKey)&&i.bind(a),o=a.advance.bind(a),u=function(){throw new Error("Cursor not stopped")},a.trans=c,a.stop=a.continue=a.continuePrimaryKey=a.advance=function(){throw new Error("Cursor not started")},a.fail=Xe(n),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(s.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(t,e){t=Xe(t),s.onerror=nn(e),a.fail=e,a.stop=function(e){a.stop=a.continue=a.continuePrimaryKey=a.advance=u,t(e)}});return s.onsuccess=Xe(function(e){(s.onsuccess=t)()}),a.continue=r,a.continuePrimaryKey=i,a.advance=o,t(),n},t(a)):t(null)},n)})},count:function(e){var t=e.query,u=e.trans,a=t.index,s=t.range;return new Promise(function(t,e){var n=u.objectStore(P),r=a.isPrimaryKey?n:n.index(a.name),i=E(s),o=i?r.count(i):r.count();o.onsuccess=Xe(function(e){return t(e.target.result)}),o.onerror=nn(e)})}}}var u,a,s,c=(a=n,s=hn((u=e).objectStoreNames),{schema:{name:u.name,tables:s.map(function(e){return a.objectStore(e)}).map(function(t){var e=t.keyPath,n=t.autoIncrement,r=d(e),i=null==e,u={},o={name:t.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:i,compound:r,keyPath:e,autoIncrement:n,unique:!0,extractKey:ln(e)},indexes:hn(t.indexNames).map(function(e){return t.index(e)}).map(function(e){var t=e.name,n=e.unique,r=e.multiEntry,i=e.keyPath,o={name:t,compound:d(i),keyPath:i,unique:n,multiEntry:r,extractKey:ln(i)};return u[dn(i)]=o}),getIndexByKeyPath:function(e){return u[dn(e)]}};return u[":id"]=o.primaryKey,null!=e&&(u[dn(e)]=o.primaryKey),o})},hasGetAll:0<s.length&&"getAll"in a.objectStore(s[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),l=c.schema,f=c.hasGetAll,h=l.tables.map(i),p={};return h.forEach(function(e){return p[e.name]=e}),{stack:"dbcore",transaction:e.transaction.bind(e),table:function(e){if(!p[e])throw new Error("Table '"+e+"' not found");return p[e]},cmp:r,MIN_KEY:-1/0,MAX_KEY:tn(o),schema:l}}function vn(e,t,n,r){var i,o=n.IDBKeyRange,u=n.indexedDB;return{dbcore:(i=yn(t,u,o,r),e.dbcore.reduce(function(e,t){var n=t.create;return m(m({},e),n(e))},i))}}function mn(n,e){var t=e.db,r=vn(n._middlewares,t,n._deps,e);n.core=r.dbcore,n.tables.forEach(function(e){var t=e.name;n.core.schema.tables.some(function(e){return e.name===t})&&(e.core=n.core.table(t),n[t]instanceof n.Table&&(n[t].core=e.core))})}function gn(i,e,t,o){t.forEach(function(n){var r=o[n];e.forEach(function(e){var t=l(e,n);(!t||"value"in t&&void 0===t.value)&&(e===i.Transaction.prototype||e instanceof i.Transaction?a(e,n,{get:function(){return this.table(n)},set:function(e){u(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):e[n]=new i.Table(n,r))})})}function bn(n,e){e.forEach(function(e){for(var t in e)e[t]instanceof n.Table&&delete e[t]})}function _n(e,t){return e._cfg.version-t._cfg.version}function wn(n,r,i,e){var o=n._dbSchema,u=n._createTransaction("readwrite",n._storeNames,o);u.create(i),u._completion.catch(e);var a=u._reject.bind(u),s=Te.transless||Te;rt(function(){var c,l,f,h,t,e,p,d;Te.trans=u,Te.transless=s,0===r?(_(o).forEach(function(e){kn(i,e,o[e].primKey,o[e].indexes)}),mn(n,i),Fe.follow(function(){r