!function(n,t){"object"==typeofexports&&"undefined"!=typeofmodule?module.exports=t():"function"==typeofdefine&&define.amd?define(t):n.Dexie=t()}(this,function(){"use strict";functionn(n,t){return"object"!=typeoft?n:(Cn(t).forEach(function(e){n[e]=t[e]}),n)}functiont(n,t){returnFn.call(n,t)}functione(n,t){"function"==typeoft&&(t=t(Bn(n))),Cn(t).forEach(function(e){r(n,e,t[e])})}functionr(e,r,i,o){Mn(e,r,n(i&&t(i,"get")&&"function"==typeofi.get?{get:i.get,set:i.set,configurable:!0}:{value:i,configurable:!0,writable:!0},o))}functioni(n){return{from:function(t){returnn.prototype=Object.create(t.prototype),r(n.prototype,"constructor",n),{extend:e.bind(null,n.prototype)}}}}functiono(n,t){vare,r=Nn(n,t);returnr||(e=Bn(n))&&o(e,t)}functionu(n,t,e){returnqn.call(n,t,e)}functiona(n,t){returnt(n)}functionc(n){vart=setTimeout(n,1e3);clearTimeout(t)}functions(n){if(!n)thrownewError("Assertion Failed")}functionf(n){Kn.setImmediate?setImmediate(n):setTimeout(n,0)}functionl(n,t){returnn.reduce(function(n,e,r){vari=t(e,r);returni&&(n[i[0]]=i[1]),n},{})}functionh(n,t){returnfunction(){try{n.apply(this,arguments)}catch(n){t(n)}}}functiond(n,t,e){try{n.apply(null,e)}catch(n){t&&t(n)}}functionv(n,e){if(t(n,e))returnn[e];if(!e)returnn;if("string"!=typeofe){for(varr=[],i=0,o=e.length;i<o;++i){varu=v(n,e[i]);r.push(u)}returnr}vara=e.indexOf(".");if(a!==-1){varc=n[e.substr(0,a)];returnvoid0===c?void0:v(c,e.substr(a+1))}}functionp(n,t,e){if(n&&void0!==t&&!("isFrozen"inObject&&Object.isFrozen(n)))if("string"!=typeoft&&"length"int){s("string"!=typeofe&&"length"ine);for(varr=0,i=t.length;r<i;++r)p(n,t[r],e[r])}else{varo=t.indexOf(".");if(o!==-1){varu=t.substr(0,o),a=t.substr(o+1);if(""===a)void0===e?deleten[u]:n[u]=e;else{varc=n[u];c||(c=n[u]={}),p(c,a,e)}}elsevoid0===e?deleten[t]:n[t]=e}}functiony(n,t){"string"==typeoft?p(n,t,void0):"length"int&&[].map.call(t,function(t){p(n,t,void0)})}functionm(n){vare={};for(varrinn)t(n,r)&&(e[r]=n[r]);returne}functiong(n){returnRn.apply([],n)}functionb(n){if(!n||"object"!=typeofn)returnn;vare;if(Tn(n)){e=[];for(varr=0,i=n.length;r<i;++r)e.push(b(n[r]))}elseif(Un.indexOf(n.constructor)>=0)e=n;else{e=n.constructor?Object.create(n.constructor.prototype):{};for(varoinn)t(n,o)&&(e[o]=b(n[o]))}returne}functionw(n,e,r,i){returnr=r||{},i=i||"",Cn(n).forEach(function(o){if(t(e,o)){varu=n[o],a=e[o];"object"==typeofu&&"object"==typeofa&&u&&a&&u.constructor===a.constructor?w(u,a,r,i+o+"."):u!==a&&(r[i+o]=e[o])}elser[i+o]=void0}),Cn(e).forEach(function(o){t(n,o)||(r[i+o]=e[o])}),r}function_(n){vart,e,r,i;if(1===arguments.length){if(Tn(n))returnn.slice();if(this===Ln&&"string"==typeofn)return[n];if(i=zn(n)){for(e=[];r=i.next(),!r.done;)e.push(r.value);returne}if(null==n)return[n];if(t=n.length,"number"==typeoft){for(e=newArray(t);t--;)e[t]=n[t];returne}return[n]}for(t=arguments.length,e=newArray(t);t--;)e[t]=arguments[t];returne}functionk(n,t){Wn=n,Qn=t}functionx(){if(Hn)try{throwx.arguments,newError}catch(n){returnn}returnnewError}functionj(n,t){vare=n.stack;returne?(t=t||0,0===e.indexOf(n.name)&&(t+=(n.name+n.message).split("\n").length),e.split("\n").slice(t).filter(Qn).map(function(n){return"\n"+n}).join("")):""}functionE(n,t){returnfunction(){returnconsole.warn(n+" is deprecated. See https://github.com/dfahlander/Dexie.js/wiki/Deprecations. "+j(x(),1)),t.apply(this,arguments)}}functionP(n,t){this._e=x(),this.name=n,this.message=t}functionA(n,t){returnn+". Errors: "+t.map(function(n){returnn.toString()}).filter(function(n,t,e){returne.indexOf(n)===t}).join("\n")}functionO(n,t,e,r){this._e=x(),this.failures=t,this.failedKeys=r,this.successCount=e}functionS(n,t){this._e=x(),this.name="BulkError",this.failures=t,this.message=A(n,t)}functionI(n,t){if(!n||ninstanceofP||ninstanceofTypeError||ninstanceofSyntaxError||!n.name||!tt[n.name])returnn;vare=newtt[n.name](t||n.message,n);return"stack"inn&&r(e,"stack",{get:function(){returnthis.inner.stack}}),e}functionD(){}functionC(n){returnn}function
vari=r.delete(n);i.onerror=xn(e),i.onsuccess=rn(function(){t(i.result)})})},clear:function(){returnthis.hook.deleting.subscribers.length?this.toCollection().delete():this._idbstore(tt,function(n,t,e){varr=e.clear();r.onerror=xn(t),r.onsuccess=rn(function(){n(r.result)})})},update:function(n,t){if("object"!=typeoft||Tn(t))thrownewnt.InvalidArgument("Modifications must be an object.");if("object"!=typeofn||Tn(n))returnthis.where(":id").equals(n).modify(t);Cn(t).forEach(function(e){p(n,e,t[e])});vare=v(n,this.schema.primKey.keyPath);returnvoid0===e?Nt(newnt.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t)}}),e(Q.prototype,{_lock:function(){returns(!Et.global),++this._reculock,1!==this._reculock||Et.global||(Et.lockOwnerFor=this),this},_unlock:function(){if(s(!Et.global),0===--this._reculock)for(Et.global||(Et.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){varn=this._blockedFuncs.shift();try{dn(n[1],n[0])}catch(n){}}returnthis},_locked:function(){returnthis._reculock&&Et.lockOwnerFor!==this},create:function(n){vart=this;if(!this.mode)returnthis;if(s(!this.idbtrans),!n&&!Gn)switch(Jn&&Jn.name){case"DatabaseClosedError":thrownewnt.DatabaseClosed(Jn);case"MissingAPIError":thrownewnt.MissingAPI(Jn.message,Jn);default:thrownewnt.OpenFailed(Jn)}if(!this.active)thrownewnt.TransactionInactive;returns(null===this._completion._state),n=this.idbtrans=n||Gn.transaction(In(this.storeNames),this.mode),n.onerror=rn(function(e){Pn(e),t._reject(n.error)}),n.onabort=rn(function(n){Pn(n),t.active&&t._reject(newnt.Abort),t.active=!1,t.on("abort").fire(n)}),n.oncomplete=rn(function(){t.active=!1,t._resolve()}),this},_promise:function(n,t,e){varr=this;if(n===tt&&this.mode!==tt)returnNt(newnt.ReadOnly("Transaction is readonly"));if(!this.active)returnNt(newnt.TransactionInactive);if(this._locked())returnnewR(function(i,o){r._blockedFuncs.push([function(){r._promise(n,t,e).then(i,o)},Et])});if(e)returnon(function(){varn=newR(function(n,e){r._lock();vari=t(n,e,r);i&&i.then&&i.then(n,e)});returnn.finally(function(){returnr._unlock()}),n._lib=!0,n});vari=newR(function(n,e){vari=t(n,e,r);i&&i.then&&i.then(n,e)});returni._lib=!0,i},_root:function(){returnthis.parent?this.parent._root():this},waitFor:function(n){vart=this._root();if(n=R.resolve(n),t._waitingFor)t._waitingFor=t._waitingFor.then(function(){returnn});else{t._waitingFor=n,t._waitingQueue=[];vare=t.idbtrans.objectStore(t.storeNames[0]);!functionn(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(e.get(-(1/0)).onsuccess=n)}()}varr=t._waitingFor;returnnewR(function(e,i){n.then(function(n){returnt._waitingQueue.push(rn(e.bind(null,n)))},function(n){returnt._waitingQueue.push(rn(i.bind(null,n)))}).finally(function(){t._waitingFor===r&&(t._waitingFor=null)})})},abort:function(){this.active&&this._reject(newnt.Abort),this.active=!1},tables:{get:E("Transaction.tables",function(){returnHn})},table:function(n){vart=et.table(n);returnnewz(n,t.schema,this)}}),e(H.prototype,function(){functionn(n,t,e){varr=ninstanceofH?newG(n):n;returnr._ctx.error=e?newe(t):newTypeError(t),r}functiont(n){returnnewG(n,function(){returnUn.only("")}).limit(0)}functione(n){return"next"===n?function(n){returnn.toUpperCase()}:function(n){returnn.toLowerCase()}}functionr(n){return"next"===n?function(n){returnn.toLowerCase()}:function(n){returnn.toUpperCase()}}functioni(n,t,e,r,i,o){for(varu=Math.min(n.length,r.length),a=-1,c=0;c<u;++c){vars=t[c];if(s!==r[c])returni(n[c],e[c])<0?n.substr(0,c)+e[c]+e.substr(c+1):i(n[c],r[c])<0?n.substr(0,c)+r[c]+e.substr(c+1):a>=0?n.substr(0,a)+t[a]+e.substr(a+1):null;i(n[c],s)<0&&(a=c)}returnu<r.length&&"next"===o?n+e.substr(n.length):u<n.length&&"prev"===o?n.substr(0,e.length):a<0?null:n.substr(0,a)+r[a]+e.substr(a+1)}functiono(t,o,u,a){functionc(n){s=e(n),f=r(n),l="next"===n?ln:hn;vart=u.map(function(n){return{lower:f(n),upper:s(n)}}).sort(function(n,t){returnl(n.lower,t.lower)});h=t.map(function(n