UNPKG

bimplus-websdk

Version:

bim+ websdk

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