ydn.db
Version:
Javascript database library for IndexedDB, WebDatabase (WebSQL) and WebStorage (localStorage) storage mechanisms supporting version migration, advanced query and transaction workflow.
97 lines • 186 kB
JavaScript
(function(){var l,r=this;function u(a){return void 0!==a}function aa(a){a=a.split(".");for(var b=r,c;c=a.shift();)if(null!=b[c])b=b[c];else return null;return b}
function ca(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function v(a){return"array"==ca(a)}function w(a){var b=ca(a);return"array"==b||"object"==b&&"number"==typeof a.length}function x(a){return"string"==typeof a}function da(a){return"boolean"==typeof a}function y(a){return"number"==typeof a}function fa(a){return"function"==ca(a)}function A(a){var b=typeof a;return"object"==b&&null!=a||"function"==b}var ga="closure_uid_"+(1E9*Math.random()>>>0),ha=0;
function ia(a,b,c){return a.call.apply(a.bind,arguments)}function ja(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}}function ka(a,b,c){ka=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?ia:ja;return ka.apply(null,arguments)}
function la(a,b){var c=Array.prototype.slice.call(arguments,1);return function(){var b=c.slice();b.push.apply(b,arguments);return a.apply(this,b)}}var ma=Date.now||function(){return+new Date};function na(a,b){var c=a.split("."),d=r;c[0]in d||!d.execScript||d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)!c.length&&u(b)?d[e]=b:d[e]?d=d[e]:d=d[e]={}}
function C(a,b){function c(){}c.prototype=b.prototype;a.D=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.Mc=function(a,c,f){for(var g=Array(arguments.length-2),h=2;h<arguments.length;h++)g[h-2]=arguments[h];return b.prototype[c].apply(a,g)}};function oa(a){a.prototype.then=a.prototype.then;a.prototype.$goog_Thenable=!0}function pa(a){if(!a)return!1;try{return!!a.$goog_Thenable}catch(b){return!1}};function qa(a){if(Error.captureStackTrace)Error.captureStackTrace(this,qa);else{var b=Error().stack;b&&(this.stack=b)}a&&(this.message=String(a))}C(qa,Error);qa.prototype.name="CustomError";var ra;function sa(a,b){for(var c=a.split("%s"),d="",e=Array.prototype.slice.call(arguments,1);e.length&&1<c.length;)d+=c.shift()+e.shift();return d+c.join("%s")}function ta(a){return/^[\s\xa0]*$/.test(a)}var ua=String.prototype.trim?function(a){return a.trim()}:function(a){return a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")};
function va(a){if(!wa.test(a))return a;-1!=a.indexOf("&")&&(a=a.replace(xa,"&"));-1!=a.indexOf("<")&&(a=a.replace(ya,"<"));-1!=a.indexOf(">")&&(a=a.replace(za,">"));-1!=a.indexOf('"')&&(a=a.replace(Aa,"""));-1!=a.indexOf("'")&&(a=a.replace(Ba,"'"));-1!=a.indexOf("\x00")&&(a=a.replace(Ca,"�"));return a}var xa=/&/g,ya=/</g,za=/>/g,Aa=/"/g,Ba=/'/g,Ca=/\x00/g,wa=/[\x00&<>"']/;
function Da(a,b){for(var c=b.length,d=0;d<c;d++){var e=1==c?b:b.charAt(d);if(a.charAt(0)==e&&a.charAt(a.length-1)==e)return a.substring(1,a.length-1)}return a}var Ea={"\x00":"\\0","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\x0B",'"':'\\"',"\\":"\\\\"},Fa={"'":"\\'"};
function Ga(a){a=String(a);if(a.quote)return a.quote();for(var b=['"'],c=0;c<a.length;c++){var d=a.charAt(c),e=d.charCodeAt(0),f=c+1,g;if(!(g=Ea[d])){if(!(31<e&&127>e))if(d in Fa)d=Fa[d];else if(d in Ea)d=Fa[d]=Ea[d];else{e=d;g=d.charCodeAt(0);if(31<g&&127>g)e=d;else{if(256>g){if(e="\\x",16>g||256<g)e+="0"}else e="\\u",4096>g&&(e+="0");e+=g.toString(16).toUpperCase()}d=Fa[d]=e}g=d}b[f]=g}b.push('"');return b.join("")}function Ha(a,b){return a<b?-1:a>b?1:0};function Ia(a,b){b.unshift(a);qa.call(this,sa.apply(null,b));b.shift()}C(Ia,qa);Ia.prototype.name="AssertionError";function Ja(a,b){throw new Ia("Failure"+(a?": "+a:""),Array.prototype.slice.call(arguments,1));};var Ka=Array.prototype,La=Ka.indexOf?function(a,b,c){return Ka.indexOf.call(a,b,c)}:function(a,b,c){c=null==c?0:0>c?Math.max(0,a.length+c):c;if(x(a))return x(b)&&1==b.length?a.indexOf(b,c):-1;for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1},Ma=Ka.forEach?function(a,b,c){Ka.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=x(a)?a.split(""):a,f=0;f<d;f++)f in e&&b.call(c,e[f],f,a)},Na=Ka.map?function(a,b,c){return Ka.map.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=Array(d),f=
x(a)?a.split(""):a,g=0;g<d;g++)g in f&&(e[g]=b.call(c,f[g],g,a));return e},Oa=Ka.some?function(a,b,c){return Ka.some.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=x(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&b.call(c,e[f],f,a))return!0;return!1},Pa=Ka.every?function(a,b,c){return Ka.every.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=x(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&!b.call(c,e[f],f,a))return!1;return!0};function Qa(a,b){var c=Ra(a,b,void 0);return 0>c?null:x(a)?a.charAt(c):a[c]}
function Ra(a,b,c){for(var d=a.length,e=x(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&b.call(c,e[f],f,a))return f;return-1}function Sa(a){if(!v(a))for(var b=a.length-1;0<=b;b--)delete a[b];a.length=0}function Ta(a,b){var c=La(a,b),d;(d=0<=c)&&Ka.splice.call(a,c,1);return d}function Ua(a){var b=a.length;if(0<b){for(var c=Array(b),d=0;d<b;d++)c[d]=a[d];return c}return[]}function Va(a,b,c){return 2>=arguments.length?Ka.slice.call(a,b):Ka.slice.call(a,b,c)}
function Wa(a,b){if(!w(a)||!w(b)||a.length!=b.length)return!1;for(var c=a.length,d=Xa,e=0;e<c;e++)if(!d(a[e],b[e]))return!1;return!0}function Xa(a,b){return a===b};var Ya;a:{var Za=r.navigator;if(Za){var $a=Za.userAgent;if($a){Ya=$a;break a}}Ya=""}function ab(a){return-1!=Ya.indexOf(a)};function bb(a,b){for(var c in a)b.call(void 0,a[c],c,a)}function cb(a,b){for(var c=w(b),d=c?b:arguments,c=c?0:1;c<d.length&&(a=a[d[c]],u(a));c++);return a}var db="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function eb(a,b){for(var c,d,e=1;e<arguments.length;e++){d=arguments[e];for(c in d)a[c]=d[c];for(var f=0;f<db.length;f++)c=db[f],Object.prototype.hasOwnProperty.call(d,c)&&(a[c]=d[c])}}
function fb(a){var b=arguments.length;if(1==b&&v(arguments[0]))return fb.apply(null,arguments[0]);for(var c={},d=0;d<b;d++)c[arguments[d]]=!0;return c};function gb(a){r.setTimeout(function(){throw a;},0)}var hb;
function ib(){var a=r.MessageChannel;"undefined"===typeof a&&"undefined"!==typeof window&&window.postMessage&&window.addEventListener&&(a=function(){var a=document.createElement("iframe");a.style.display="none";a.src="";document.documentElement.appendChild(a);var b=a.contentWindow,a=b.document;a.open();a.write("");a.close();var c="callImmediate"+Math.random(),d="file:"==b.location.protocol?"*":b.location.protocol+"//"+b.location.host,a=ka(function(a){if(("*"==d||a.origin==d)&&a.data==c)this.port1.onmessage()},
this);b.addEventListener("message",a,!1);this.port1={};this.port2={postMessage:function(){b.postMessage(c,d)}}});if("undefined"!==typeof a&&!ab("Trident")&&!ab("MSIE")){var b=new a,c={},d=c;b.port1.onmessage=function(){if(u(c.next)){c=c.next;var a=c.Sb;c.Sb=null;a()}};return function(a){d.next={Sb:a};d=d.next;b.port2.postMessage(0)}}return"undefined"!==typeof document&&"onreadystatechange"in document.createElement("script")?function(a){var b=document.createElement("script");b.onreadystatechange=function(){b.onreadystatechange=
null;b.parentNode.removeChild(b);b=null;a();a=null};document.documentElement.appendChild(b)}:function(a){r.setTimeout(a,0)}};function jb(a,b){kb||lb();mb||(kb(),mb=!0);ob.push(new pb(a,b))}var kb;function lb(){if(r.Promise&&r.Promise.resolve){var a=r.Promise.resolve();kb=function(){a.then(qb)}}else kb=function(){var a=qb;!fa(r.setImmediate)||r.Window&&r.Window.prototype.setImmediate==r.setImmediate?(hb||(hb=ib()),hb(a)):r.setImmediate(a)}}var mb=!1,ob=[];[].push(function(){mb=!1;ob=[]});function qb(){for(;ob.length;){var a=ob;ob=[];for(var b=0;b<a.length;b++){var c=a[b];try{c.a.call(c.b)}catch(d){gb(d)}}}mb=!1}
function pb(a,b){this.a=a;this.b=b};function rb(a,b){this.b=sb;this.h=void 0;this.a=this.c=null;this.f=this.g=!1;try{var c=this;a.call(b,function(a){tb(c,ub,a)},function(a){if(!(a instanceof vb))try{if(a instanceof Error)throw a;throw Error("Promise rejected.");}catch(b){}tb(c,wb,a)})}catch(d){tb(this,wb,d)}}var sb=0,ub=2,wb=3;rb.prototype.then=function(a,b,c){return xb(this,fa(a)?a:null,fa(b)?b:null,c)};oa(rb);function yb(a){a.b==sb&&jb(function(){var a=new vb(void 0);zb(this,a)},a)}
function zb(a,b){if(a.b==sb)if(a.c){var c=a.c;if(c.a){for(var d=0,e=-1,f=0,g;g=c.a[f];f++)if(g=g.Ga)if(d++,g==a&&(e=f),0<=e&&1<d)break;0<=e&&(c.b==sb&&1==d?zb(c,b):(d=c.a.splice(e,1)[0],Bb(c,d,wb,b)))}}else tb(a,wb,b)}function Cb(a,b){a.a&&a.a.length||a.b!=ub&&a.b!=wb||Db(a);a.a||(a.a=[]);a.a.push(b)}
function xb(a,b,c,d){var e={Ga:null,ac:null,bc:null};e.Ga=new rb(function(a,g){e.ac=b?function(c){try{var e=b.call(d,c);a(e)}catch(m){g(m)}}:a;e.bc=c?function(b){try{var e=c.call(d,b);!u(e)&&b instanceof vb?g(b):a(e)}catch(m){g(m)}}:g});e.Ga.c=a;Cb(a,e);return e.Ga}rb.prototype.i=function(a){this.b=sb;tb(this,ub,a)};rb.prototype.j=function(a){this.b=sb;tb(this,wb,a)};
function tb(a,b,c){if(a.b==sb){if(a==c)b=wb,c=new TypeError("Promise cannot resolve to itself");else{if(pa(c)){a.b=1;c.then(a.i,a.j,a);return}if(A(c))try{var d=c.then;if(fa(d)){Eb(a,c,d);return}}catch(e){b=wb,c=e}}a.h=c;a.b=b;Db(a);b!=wb||c instanceof vb||Fb(a,c)}}function Eb(a,b,c){function d(b){f||(f=!0,a.j(b))}function e(b){f||(f=!0,a.i(b))}a.b=1;var f=!1;try{c.call(b,e,d)}catch(g){d(g)}}function Db(a){a.g||(a.g=!0,jb(a.o,a))}
rb.prototype.o=function(){for(;this.a&&this.a.length;){var a=this.a;this.a=[];for(var b=0;b<a.length;b++)Bb(this,a[b],this.b,this.h)}this.g=!1};function Bb(a,b,c,d){if(c==ub)b.ac(d);else{if(b.Ga)for(;a&&a.f;a=a.c)a.f=!1;b.bc(d)}}function Fb(a,b){a.f=!0;jb(function(){a.f&&Gb.call(null,b)})}var Gb=gb;function vb(a){qa.call(this,a)}C(vb,qa);vb.prototype.name="cancel";/*
Portions of this code are from MochiKit, received by
The Closure Authors under the MIT license. All other code is Copyright
2005-2009 The Closure Authors. All Rights Reserved.
*/
function D(a,b){this.j=[];this.O=b||null;this.b=this.c=!1;this.g=void 0;this.ka=this.I=this.o=!1;this.i=0;this.f=null;this.H=0}l=D.prototype;l.Ua=function(a,b){this.o=!1;Hb(this,a,b)};function Hb(a,b,c){a.c=!0;a.g=c;a.b=!b;a.wb()}function Ib(a){if(a.c){if(!a.ka)throw new Jb;a.ka=!1}}l.callback=function(a){Ib(this);Hb(this,!0,a)};l.l=function(a){Ib(this);Hb(this,!1,a)};l.B=function(a,b){return Kb(this,a,null,b)};l.Rb=function(a,b){return Kb(this,null,a,b)};l.la=function(a,b){return Kb(this,a,a,b)};
function Kb(a,b,c,d){a.j.push([b,c,d]);a.c&&a.wb();return a}l.then=function(a,b,c){var d,e,f=new rb(function(a,b){d=a;e=b});Kb(this,d,function(a){e(a)});return f.then(a,b,c)};oa(D);D.prototype.Sa=function(a){Kb(this,a.callback,a.l,a);return this};function Lb(a,b){b instanceof D?a.B(ka(b.ja,b)):a.B(function(){return b})}D.prototype.ja=function(a){var b=new D;this.Sa(b);a&&(b.f=this,this.H++);return b};function Mb(a){return Oa(a.j,function(a){return fa(a[1])})}
D.prototype.wb=function(){this.i&&this.c&&Mb(this)&&(Nb(this.i),this.i=0);this.f&&(this.f.H--,delete this.f);for(var a=this.g,b=!1,c=!1;this.j.length&&!this.o;){var d=this.j.shift(),e=d[0],f=d[1],d=d[2];if(e=this.b?f:e)try{var g=e.call(d||this.O,a);u(g)&&(this.b=this.b&&(g==a||g instanceof Error),this.g=a=g);pa(a)&&(this.o=c=!0)}catch(h){a=h,this.b=!0,Mb(this)||(b=!0)}}this.g=a;c&&(c=ka(this.Ua,this,!0),g=ka(this.Ua,this,!1),a instanceof D?(Kb(a,c,g),a.I=!0):a.then(c,g));b&&(a=new Ob(a),Pb[a.cb]=
a,this.i=a.cb)};function Qb(a){var b=new D;b.callback(a);return b}function Jb(){qa.call(this)}C(Jb,qa);Jb.prototype.message="Deferred has already fired";Jb.prototype.name="AlreadyCalledError";function Ob(a){this.cb=r.setTimeout(ka(this.b,this),0);this.a=a}Ob.prototype.b=function(){delete Pb[this.cb];window.console.error(this.a.stack);throw this.a;};var Pb={};function Nb(a){var b=Pb[a];b&&(r.clearTimeout(b.cb),delete Pb[a])};var Rb=fb("area base br col command embed hr img input keygen link meta param source track wbr".split(" "));function Sb(){this.a="";this.b=Vb}Sb.prototype.ra=!0;Sb.prototype.ia=function(){return this.a};Sb.prototype.toString=function(){return"Const{"+this.a+"}"};function Wb(a){if(a instanceof Sb&&a.constructor===Sb&&a.b===Vb)return a.a;Ja("expected object of type Const, got '"+a+"'");return"type_error:Const"}var Vb={};function Xb(a){var b=new Sb;b.a=a;return b};function Yb(){this.a="";this.b=Zb}Yb.prototype.ra=!0;var Zb={};Yb.prototype.ia=function(){return this.a};Yb.prototype.toString=function(){return"SafeStyle{"+this.a+"}"};function $b(a){var b=new Yb;b.a=a;return b}var ac=$b(""),bc=/^[-.%_!# a-zA-Z0-9]+$/;function cc(){this.a="";this.b=dc}l=cc.prototype;l.ra=!0;l.ia=function(){return this.a};l.Bb=!0;l.xa=function(){return 1};l.toString=function(){return"SafeUrl{"+this.a+"}"};function ec(a){if(a instanceof cc&&a.constructor===cc&&a.b===dc)return a.a;Ja("expected object of type SafeUrl, got '"+a+"'");return"type_error:SafeUrl"}var fc=/^(?:(?:https?|mailto):|[^&:/?#]*(?:[/?#]|$))/i;
function gc(a){try{var b=encodeURI(a)}catch(c){return"about:invalid#zClosurez"}return b.replace(hc,function(a){return ic[a]})}var hc=/[()']|%5B|%5D|%25/g,ic={"'":"%27","(":"%28",")":"%29","%5B":"[","%5D":"]","%25":"%"},dc={};function jc(a){var b=new cc;b.a=a;return b};function kc(){this.a=lc}l=kc.prototype;l.ra=!0;l.ia=function(){return""};l.Bb=!0;l.xa=function(){return 1};l.toString=function(){return"TrustedResourceUrl{}"};var lc={};function mc(){this.a="";this.c=nc;this.b=null}l=mc.prototype;l.Bb=!0;l.xa=function(){return this.b};l.ra=!0;l.ia=function(){return this.a};l.toString=function(){return"SafeHtml{"+this.a+"}"};function oc(a){if(a instanceof mc&&a.constructor===mc&&a.c===nc)return a.a;Ja("expected object of type SafeHtml, got '"+a+"'");return"type_error:SafeHtml"}function pc(a){if(a instanceof mc)return a;var b=null;a.Bb&&(b=a.xa());return qc(va(a.ra?a.ia():String(a)),b)}
function rc(a){if(a instanceof mc)return a;a=pc(a);var b;b=oc(a).replace(/ /g,"  ").replace(/(\r\n|\r|\n)/g,"<br>");return qc(b,a.xa())}var sc=/^[a-zA-Z0-9-]+$/,tc={action:!0,cite:!0,data:!0,formaction:!0,href:!0,manifest:!0,poster:!0,src:!0},uc={embed:!0,iframe:!0,link:!0,object:!0,script:!0,style:!0,template:!0};
function vc(a,b,c){if(!sc.test(a))throw Error("Invalid tag name <"+a+">.");if(a.toLowerCase()in uc)throw Error("Tag name <"+a+"> is not allowed for SafeHtml.");var d=null,e="<"+a;if(b)for(var f in b){if(!sc.test(f))throw Error('Invalid attribute name "'+f+'".');var g=b[f];if(null!=g){var h,k=a;h=f;if(g instanceof Sb)g=Wb(g);else if("style"==h.toLowerCase()){if(!A(g))throw Error('The "style" attribute requires goog.html.SafeStyle or map of style properties, '+typeof g+" given: "+g);if(!(g instanceof
Yb)){var k="",m=void 0;for(m in g){if(!/^[-_a-zA-Z0-9]+$/.test(m))throw Error("Name allows only [-_a-zA-Z0-9], got: "+m);var n=g[m];null!=n&&(n instanceof Sb?n=Wb(n):bc.test(n)||(Ja("String value allows only [-.%_!# a-zA-Z0-9], got: "+n),n="zClosurez"),k+=m+":"+n+";")}g=k?$b(k):ac}k=void 0;g instanceof Yb&&g.constructor===Yb&&g.b===Zb?k=g.a:(Ja("expected object of type SafeStyle, got '"+g+"'"),k="type_error:SafeStyle");g=k}else{if(/^on/i.test(h))throw Error('Attribute "'+h+'" requires goog.string.Const value, "'+
g+'" given.');if(h.toLowerCase()in tc)if(g instanceof kc)g instanceof kc&&g.constructor===kc&&g.a===lc?g="":(Ja("expected object of type TrustedResourceUrl, got '"+g+"'"),g="type_error:TrustedResourceUrl");else if(g instanceof cc)g=ec(g);else throw Error('Attribute "'+h+'" on tag "'+k+'" requires goog.html.SafeUrl or goog.string.Const value, "'+g+'" given.');}g.ra&&(g=g.ia());h=h+'="'+va(String(g))+'"';e=e+(" "+h)}}u(c)?v(c)||(c=[c]):c=[];!0===Rb[a.toLowerCase()]?e+=">":(d=wc(c),e+=">"+oc(d)+"</"+
a+">",d=d.xa());(a=b&&b.dir)&&(/^(ltr|rtl|auto)$/i.test(a)?d=0:d=null);return qc(e,d)}function wc(a){function b(a){v(a)?Ma(a,b):(a=pc(a),d+=oc(a),a=a.xa(),0==c?c=a:0!=a&&c!=a&&(c=null))}var c=0,d="";Ma(arguments,b);return qc(d,c)}var nc={};function qc(a,b){var c=new mc;c.a=a;c.b=b;return c}var xc=qc("",0);var yc="StopIteration"in r?r.StopIteration:Error("StopIteration");function zc(){}zc.prototype.next=function(){throw yc;};zc.prototype.qb=function(){return this};function Ac(a){if(a instanceof zc)return a;if("function"==typeof a.qb)return a.qb(!1);if(w(a)){var b=0,c=new zc;c.next=function(){for(;;){if(b>=a.length)throw yc;if(b in a)return a[b++];b++}};return c}throw Error("Not implemented");}
function Bc(a,b){if(w(a))try{Ma(a,b,void 0)}catch(c){if(c!==yc)throw c;}else{a=Ac(a);try{for(;;)b.call(void 0,a.next(),void 0,a)}catch(d){if(d!==yc)throw d;}}};function Cc(a,b){this.b={};this.a=[];this.f=this.c=0;var c=arguments.length;if(1<c){if(c%2)throw Error("Uneven number of arguments");for(var d=0;d<c;d+=2)this.set(arguments[d],arguments[d+1])}else if(a){var e;if(a instanceof Cc)e=a.qa(),d=a.$a();else{var c=[],f=0;for(e in a)c[f++]=e;e=c;c=[];f=0;for(d in a)c[f++]=a[d];d=c}for(c=0;c<e.length;c++)this.set(e[c],d[c])}}l=Cc.prototype;l.xb=function(){return this.c};
l.$a=function(){Dc(this);for(var a=[],b=0;b<this.a.length;b++)a.push(this.b[this.a[b]]);return a};l.qa=function(){Dc(this);return this.a.concat()};l.clear=function(){this.b={};this.f=this.c=this.a.length=0};l.remove=function(a){return Object.prototype.hasOwnProperty.call(this.b,a)?(delete this.b[a],this.c--,this.f++,this.a.length>2*this.c&&Dc(this),!0):!1};
function Dc(a){if(a.c!=a.a.length){for(var b=0,c=0;b<a.a.length;){var d=a.a[b];Object.prototype.hasOwnProperty.call(a.b,d)&&(a.a[c++]=d);b++}a.a.length=c}if(a.c!=a.a.length){for(var e={},c=b=0;b<a.a.length;)d=a.a[b],Object.prototype.hasOwnProperty.call(e,d)||(a.a[c++]=d,e[d]=1),b++;a.a.length=c}}l.get=function(a,b){return Object.prototype.hasOwnProperty.call(this.b,a)?this.b[a]:b};l.set=function(a,b){Object.prototype.hasOwnProperty.call(this.b,a)||(this.c++,this.a.push(a),this.f++);this.b[a]=b};
l.forEach=function(a,b){for(var c=this.qa(),d=0;d<c.length;d++){var e=c[d],f=this.get(e);a.call(b,f,e,this)}};l.clone=function(){return new Cc(this)};l.qb=function(a){Dc(this);var b=0,c=this.a,d=this.b,e=this.f,f=this,g=new zc;g.next=function(){for(;;){if(e!=f.f)throw Error("The map has changed since the iterator was created");if(b>=c.length)throw yc;var g=c[b++];return a?g:d[g]}};return g};var Ec=ab("Opera")||ab("OPR"),Fc=ab("Trident")||ab("MSIE"),Gc=ab("Gecko")&&-1==Ya.toLowerCase().indexOf("webkit")&&!(ab("Trident")||ab("MSIE")),Hc=-1!=Ya.toLowerCase().indexOf("webkit");Hc&&ab("Mobile");ab("Macintosh");ab("Windows");ab("Linux")||ab("CrOS");var Ic=r.navigator||null;Ic&&(Ic.appVersion||"").indexOf("X11");ab("Android");!ab("iPhone")||ab("iPod")||ab("iPad");ab("iPad");function Jc(){var a=r.document;return a?a.documentMode:void 0}
var Kc=function(){var a="",b;if(Ec&&r.opera)return a=r.opera.version,fa(a)?a():a;Gc?b=/rv\:([^\);]+)(\)|;)/:Fc?b=/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/:Hc&&(b=/WebKit\/(\S+)/);b&&(a=(a=b.exec(Ya))?a[1]:"");return Fc&&(b=Jc(),b>parseFloat(a))?String(b):a}(),Lc={};
function Mc(a){var b;if(!(b=Lc[a])){b=0;for(var c=ua(String(Kc)).split("."),d=ua(String(a)).split("."),e=Math.max(c.length,d.length),f=0;0==b&&f<e;f++){var g=c[f]||"",h=d[f]||"",k=RegExp("(\\d*)(\\D*)","g"),m=RegExp("(\\d*)(\\D*)","g");do{var n=k.exec(g)||["","",""],p=m.exec(h)||["","",""];if(0==n[0].length&&0==p[0].length)break;b=Ha(0==n[1].length?0:parseInt(n[1],10),0==p[1].length?0:parseInt(p[1],10))||Ha(0==n[2].length,0==p[2].length)||Ha(n[2],p[2])}while(0==b)}b=Lc[a]=0<=b}return b}
var Nc=r.document,Oc=Nc&&Fc?Jc()||("CSS1Compat"==Nc.compatMode?parseInt(Kc,10):5):void 0;function Pc(a){var b;b||(b=Qc(a||arguments.callee.caller,[]));return b}
function Qc(a,b){var c=[];if(0<=La(b,a))c.push("[...circular reference...]");else if(a&&50>b.length){c.push(Rc(a)+"(");for(var d=a.arguments,e=0;d&&e<d.length;e++){0<e&&c.push(", ");var f;f=d[e];switch(typeof f){case "object":f=f?"object":"null";break;case "string":break;case "number":f=String(f);break;case "boolean":f=f?"true":"false";break;case "function":f=(f=Rc(f))?f:"[fn]";break;default:f=typeof f}40<f.length&&(f=f.substr(0,40)+"...");c.push(f)}b.push(a);c.push(")\n");try{c.push(Qc(a.caller,
b))}catch(g){c.push("[exception trying to get caller]\n")}}else a?c.push("[...long stack...]"):c.push("[end]");return c.join("")}function Rc(a){if(Sc[a])return Sc[a];a=String(a);if(!Sc[a]){var b=/function ([^\(]+)/.exec(a);Sc[a]=b?b[1]:"[Anonymous]"}return Sc[a]}var Sc={};function Tc(a,b,c,d,e){"number"==typeof e||Uc++;this.g=d||ma();this.f=a;this.c=b;this.b=c;delete this.a}Tc.prototype.a=null;var Uc=0;function Vc(a){this.g=a;this.a=this.f=this.b=this.c=null}function Wc(a,b){this.name=a;this.value=b}Wc.prototype.toString=function(){return this.name};var Xc=new Wc("SHOUT",1200),Yc=new Wc("SEVERE",1E3),Zc=new Wc("WARNING",900),$c=new Wc("INFO",800),ad=new Wc("CONFIG",700),bd=new Wc("FINE",500),cd=new Wc("FINER",400),dd=new Wc("FINEST",300),ed=[new Wc("OFF",Infinity),Xc,Yc,Zc,$c,ad,bd,cd,dd,new Wc("ALL",0)],fd=null;Vc.prototype.getName=function(){return this.g};
function gd(a){if(a.b)return a.b;if(a.c)return gd(a.c);Ja("Root logger has no level set.");return null}Vc.prototype.log=function(a,b,c){if(a.value>=gd(this).value)for(fa(b)&&(b=b()),a=new Tc(a,String(b),this.g),c&&(a.a=c),c="log:"+a.c,r.console&&(r.console.timeStamp?r.console.timeStamp(c):r.console.markTimeline&&r.console.markTimeline(c)),r.msWriteProfilerMark&&r.msWriteProfilerMark(c),c=this;c;){b=c;var d=a;if(b.a)for(var e=0,f=void 0;f=b.a[e];e++)f(d);c=c.c}};var hd={},id=null;
function jd(){id||(id=new Vc(""),hd[""]=id,id.b=ad)}function kd(){jd();return id}function E(a){jd();var b;if(!(b=hd[a])){b=new Vc(a);var c=a.lastIndexOf("."),d=a.substr(c+1),c=E(a.substr(0,c));c.f||(c.f={});c.f[d]=b;b.c=c;hd[a]=b}return b};function ld(a,b,c){a&&a.log(b,c,void 0)}function md(a,b){a&&a.log(Yc,b,void 0)}function F(a,b){a&&a.log(Zc,b,void 0)}function nd(a,b){a&&a.log(bd,b,void 0)};function H(a,b){a&&a.log(dd,b,void 0)}function K(a,b){a&&a.log(cd,b,void 0)};function L(a){qa.call(this,a);this.name="ydn.error.ArgumentException"}C(L,qa);function od(a){qa.call(this,a);this.name="ydn.error.TypeError"}C(od,qa);function pd(a){qa.call(this,a);this.name="ydn.error.NotSupportedException"}C(pd,qa);function qd(a){qa.call(this,a);this.name="ydn.error.NotImplementedException"}C(qd,qa);function rd(a){qa.call(this,a);this.name="ydn.error.InvalidOperationException"}C(rd,qa);
function sd(a){Error.captureStackTrace?Error.captureStackTrace(this,sd):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.error.InternalError"}C(sd,Error);sd.prototype.name="ydn.error.InternalError";function td(a,b){D.call(this,0,b);this.h=[]}C(td,D);l=td.prototype;l.rb=function(a,b){this.h.push([a,b]);return this};function ud(a,b){for(var c=0;c<a.h.length;c++)a.h[c][0].call(a.h[c][1],b)}l.callback=function(a){this.h.length=0;td.D.callback.call(this,a)};l.l=function(a){this.h.length=0;td.D.l.call(this,a)};l.Sa=function(a){td.D.Sa.call(this,a);a instanceof td&&a.rb(function(a){ud(this,a)},this);return this};l.xc=function(){return this};D.prototype.done=D.prototype.B;D.prototype.fail=D.prototype.Rb;D.prototype.always=D.prototype.la;td.prototype.then=td.prototype.then;function M(a,b,c,d){a>b&&(b=a=void 0);null===a&&(a=void 0);null===b&&(b=void 0);this.lower=a;this.upper=b;this.lowerOpen=!!c;this.upperOpen=!!d}M.prototype.lower=void 0;M.prototype.upper=void 0;M.prototype.toJSON=function(){return vd(this)};function wd(a){return xd(a)}function yd(a){return new M(a,a,!1,!1)}function zd(a,b,c,d){return new M(a,b,c,d)}function Ad(a,b){return new M(void 0,a,void 0,!!b)}function Bd(a,b){return new M(a,void 0,!!b,void 0)}
function Cd(a){var b;if(v(a))b=Ua(a),b.push("\uffff");else if(x(a))b=a+"\uffff";else if(y(a))b=a+2.220460492503131E-16,a-=2.220460492503131E-16;else return yd(a);return zd(a,b,!1,!0)}function vd(a){a=a||{};return{lower:a.lower,upper:a.upper,lowerOpen:a.lowerOpen,upperOpen:a.upperOpen}}
function xd(a){return null!=a?null!=a.upper&&null!=a.lower?Dd.bound(a.lower,a.upper,!!a.lowerOpen,!!a.upperOpen):null!=a.upper?Dd.upperBound(a.upper,a.upperOpen):null!=a.lower?Dd.lowerBound(a.lower,a.lowerOpen):null:null}function Ed(a){if(a instanceof M)return"";if(null!=a){if(A(a)){for(var b in a){var c;if(c=a.hasOwnProperty(b))c=!(0<=La(["lower","upper","lowerOpen","upperOpen"],b));if(c)return'invalid attribute "'+b+'" in key range object'}return""}return"key range must be an object"}return""}
M.prototype.ma=function(a){var b=this.lower,c=this.upper,d=this.lowerOpen,e=this.upperOpen;null!=a.lower&&(null==this.lower||a.lower>=this.lower)&&(b=a.lower,d=a.lowerOpen||this.lowerOpen);null!=a.upper&&(null==this.upper||a.upper<=this.upper)&&(c=a.upper,e=a.upperOpen||this.upperOpen);return zd(b,c,d,e)};function Fd(a){if(!a)return"";var b=a.lowerOpen?"(":"[";null!=a.lower&&(b+=a.lower+", ");null!=a.upper&&(b+=a.upper);return b+=a.upperOpen?")":"]"}
function Gd(a,b,c,d,e){if(c)if(c.lowerOpen||c.upperOpen||null==c.lower||null==c.upper||0!==N(c.lower,c.upper)){if(null!=c.lower){var f=c.lowerOpen?" > ":" >= ";d.push(a+f+"?");e.push(Hd(c.lower,b))}null!=c.upper&&(f=c.upperOpen?" < ":" <= ",d.push(a+f+"?"),e.push(Hd(c.upper,b)))}else d.push(a+" = ?"),e.push(Hd(c.lower,b))}
function Id(a,b,c,d){var e,f,g,h;if("starts"==a||"^"==a)return Cd(b);if("<"==a||"<="==a)e=b,g="<"==a;else if(">"==a||">="==a)f=b,h=">"==a;else if("="==a||"=="==a)e=f=b;else throw new L("invalid op: "+a);if("<"==c||"<="==c)e=d,g="<"==c;else if(">"==c||">="==c)f=d,h=">"==c;else if(u(c))throw new L("invalid op2: "+c);return zd(f,e,h,g)}var Dd=r.IDBKeyRange||r.webkitIDBKeyRange||M;function Jd(a,b){var c,d;2==arguments.length&&x(arguments[1])?(c=!0,d=arguments[1].split(".")):d=(c=w(b))?b:arguments;for(c=c?0:1;c<d.length&&(a=a[d[c]],u(a));c++);return a}function Kd(a,b,c){if(a)if(-1==b.indexOf("."))a[b]=c;else{b=b.split(".");for(var d=b.pop(),e;e=b.shift();)A(a[e])||(a[e]={}),a=a[e];a[d]=c}}var Ld={};
function Md(a){var b=[a];a=new Nd;for(var c=0,d,e;void 0!==(e=b.pop());){0===c%4&&12<c+4&&(a.write(c),c=0);d=typeof e;if(e instanceof Array)if(c+=4,0<e.length){b.push(Ld);for(d=e.length;d--;)b.push(e[d]);continue}else a.write(c);else if("number"===d)c+=1,a.write(c),Od(a,e);else if(e instanceof Date)c+=2,a.write(c),Od(a,e.valueOf());else if("string"===d){c+=3;a.write(c);c=a;for(d=0;d<e.length;d++){var f=e.charCodeAt(d);126>=f?c.write(f+1):16510>=f?(f-=127,c.write(128|f>>8,f&255)):c.write(192|f>>10,
f>>2|255,(f|3)<<6)}c.write(0)}else if(e===Ld)a.write(0);else return"";c=0}for(b=a.a.length;"00"===a.a[--b];);a.a.length=++b;return a.toString()}function Pd(a){for(var b=[],c=b,d=[],e,f,g=new Qd(a);null!=Rd(g);)if(0===g.a)c=d.pop();else{if(null===g.a)break;do{e=g.a/4|0;a=g.a%4;for(var h=0;h<e;h++)f=[],c.push(f),d.push(c),c=f;if(0===a&&12<g.a+4)Rd(g);else break}while(1);1===a?c.push(Sd(g)):2===a?c.push(new Date(Sd(g))):3===a?c.push(Td(g)):0===a&&(c=d.pop())}return b[0]}
function Od(a,b){var c,d,e;c=b;var f=e=d=0;if(0!==c)if(isFinite(c)){0>c&&(d=1,c=-c);f=0;if(2.2250738585072014E-308<=c){for(e=c;1>e;)f--,e*=2;for(;2<=e;)f++,e/=2;e=f+1023}f=e?Math.floor(4503599627370496*(c/Math.pow(2,f)-1)):Math.floor(c/4.9E-324)}else e=2047,isNaN(c)?f=0x8000000000000:-Infinity===c&&(d=1);c=d;d=e;e=f;c&&(e=0xfffffffffffff-e,d=2047-d);a.write((c?0:128)|d>>4);a.write((d&15)<<4|0|e/281474976710656);e%=281474976710656;c=0|e/4294967296;a.write(c>>8,c&255);e%=4294967296;c=0|e/65536;a.write(c>>
8,c&255);c=e%65536;a.write(c>>8,c&255)}function Sd(a){var b=Rd(a)|0,c=b>>7?!1:!0,d=c?-1:1,e=(b&127)<<4,b=Rd(a)|0,e=e+(b>>4);c&&(e=2047-e);for(var b=[c?15-(b&15):b&15],f=6;f--;)b.push(c?255-(Rd(a)|0):Rd(a)|0);a=0;for(f=7;f--;)a=a/256+b[f];a/=16;return 0===a&&0===e?0:(a+1)*Math.pow(2,e-1023)*d}
function Td(a){for(var b=[],c=0,d=0,e=0,f,g;;){f=Rd(a);if(0===f||null==f)break;0===c?(g=f>>6,2>g&&!isNaN(f)?b.push(String.fromCharCode(f-1)):(c=g,d=f<<10,e++)):2===c?(b.push(String.fromCharCode(d+f+127)),c=d=e=0):2===e?(d+=f<<2,e++):(b.push(String.fromCharCode(d|f>>6)),c=d=e=0)}return b.join("")}function Qd(a){this.a=null;this.b=a;this.c=this.b.length-1;this.index=-1}function Rd(a){return a.a=a.index<a.c?parseInt(a.b.charAt(++a.index)+a.b.charAt(++a.index),16):null}
function Nd(){this.a=[];this.b=void 0}Nd.prototype.write=function(a){for(var b=0;b<arguments.length;b++)this.b=arguments[b].toString(16),this.a.push(2===this.b.length?this.b:this.b="0"+this.b)};Nd.prototype.toString=function(){return this.a.length?this.a.join(""):""};function Ud(a,b){var c=Md(a),d=Md(b);return c>d?1:c==d?0:-1};function Vd(a,b,c,d,e){if(!(b instanceof M))if(x(b)&&u(c))b=Id(b,c,d,e);else if(null!=b){if(!(b instanceof M))if(A(b))b=new M(b.lower,b.upper,b.lowerOpen,b.upperOpen);else throw new L("Invalid key range: "+b+" of type "+typeof b);}else b=null;this.a=b;this.pa=a}Vd.prototype.pa="";Vd.prototype.ma=function(a){if(this.pa!=a.pa)return null;a=null!=this.a&&null!=a.a?this.a.ma(a.a):this.a||a.a;return new Vd(this.pa,a)};var Wd={READ_ONLY:"readonly",READ_WRITE:"readwrite",VERSION_CHANGE:"versionchange"},Xd=Wd.READ_ONLY,O=Wd.READ_WRITE,Zd=Wd.VERSION_CHANGE,$d=r.indexedDB||r.mozIndexedDB||r.webkitIndexedDB||r.moz_indexedDB||r.msIndexedDB;function ae(){0!=be&&(ce[this[ga]||(this[ga]=++ha)]=this);this.ja=this.ja;this.ka=this.ka}var be=0,ce={};ae.prototype.ja=!1;ae.prototype.vb=function(){if(!this.ja&&(this.ja=!0,this.ha(),0!=be)){var a=this[ga]||(this[ga]=++ha);delete ce[a]}};ae.prototype.ha=function(){if(this.ka)for(;this.ka.length;)this.ka.shift()()};function de(a,b,c,d){ae.call(this);this.b=c;this.s=c.getName();this.R=void 0;this.g=!1;this.A=null;this.f=a;this.Qb=b;this.wa=0;this.O=this.I=!1;this.H=d||4;this.j=this.c=this.a=void 0;this.o=function(){throw new sd;};this.u=function(){throw new sd;};this.Pb=function(){}}C(de,ae);l=de.prototype;
l.Nb=function(a,b,c,d,e){if(u(b)){a=this.b;var f,g=b;v(b)?(f=ee(a,b),g=b.join(", ")):f=fe(a,b);if(!f)throw new L('require index "'+g+'" not found in store "'+a.getName()+'"');this.R=f.getName()}this.g=x(this.R);this.A=c||null;this.wa=0;this.O=this.I=!1;this.reverse="prev"==d||"prevunique"==d;this.unique="nextunique"==d||"prevunique"==d;this.Y=d;this.Ja=e;this.j=this.c=this.a=void 0};l.Y="";l.A=null;l.unique=!1;l.reverse=!1;l.Ja=!0;l.logger=E("ydn.db.core.req.AbstractCursor");
function ge(a,b){a.u(b);he(a);a.I=!0}l.W=function(a,b,c){null==a&&(K(this.logger,this+" finished."),this.I=!0);this.a=a;this.c=b;this.j=c;this.wa++;this.I?(H(this.logger,this+" DONE."),this.o(),he(this)):(H(this.logger,this+" new cursor position {"+(this.g?this.a+", "+this.c:this.a)+"}"),this.o(this.a))};l.ha=function(){this.f=null};l.toString=function(){return"Cursor:"+this.s+(u(this.R)?":"+this.R:"")+"["+(this.f?"":"~")+this.Qb+"]"};
function he(a){null!=a.c?a.c=ie(a.c):a.c=void 0;null!=a.a?a.a=ie(a.a):a.a=void 0;a.Pb(a.O,a.a,a.c)}l.open=function(a,b,c,d){this.f=a;this.Qb=b;this.I=this.O=!1;this.a=c;this.c=d;this.openCursor(this.a,this.c)};function je(a){a.O=!0;H(a.logger,a+": exit");he(a)}l.xb=function(){return this.wa};l.Ic=function(){return this.a};l.K=function(){return this.g?this.c:this.a};l.da=function(){return this.Ja?this.K():this.j};l.Pa=function(){};l.ua=function(){};
function ke(a,b,c){H(a.logger,a+" restarting");a.I=!1;a.O=!1;a.openCursor(c,b)};function le(){};function P(a,b,c,d,e,f,g){if(!x(a))throw new TypeError("store name must be a string, but "+a+" found.");this.c=a;this.f=b;this.h=g;this.o=!!this.f;if(u(d)&&!da(d))throw new L("reverse value must be a boolean, but "+typeof d+" found");if(u(e)&&!da(e))throw new L("unique value must be a boolean, but "+typeof e+" found");if(u(f)&&!da(f))throw new L("key_only value must be a boolean, but "+typeof f+" found");this.a=u(f)?f:!!x(this.f);a="next";d&&e?a="prevunique":d?a="prev":e&&(a="nextunique");this.u=
a;if(d=Ed(c))throw new L("Invalid key range: "+d);this.b=xd(c);this.g=me;this.w=NaN}C(P,le);P.prototype.a=!0;function ne(a,b,c){if(3<arguments.length)throw new L("too many argument");P.call(this,a,void 0,b,c,void 0,!0)}C(ne,P);function oe(a,b,c,d,e){if(!x(b))throw new L("index name must be string");P.call(this,a,b,c,d,e,!0)}C(oe,P);function pe(a,b,c){if(3<arguments.length)throw new L("too many argument");P.call(this,a,void 0,b,c,void 0,!1)}C(pe,P);
function qe(a,b,c,d,e){return new pe(a,Id(b,c,d,e))}function re(a,b,c,d,e){if(!x(b))throw new L("index name must be string");P.call(this,a,b,c,d,e,!1)}C(re,P);var me="init";l=P.prototype;l.logger=E("ydn.db.Iterator");l.Bc=function(){return this.c};l.yc=function(){return this.f};l.ec=function(){return this.b?this.b instanceof Dd?this.b:Dd.bound(this.b.lower,this.b.upper,this.b.lowerOpen,this.b.upperOpen):null};l.Cc=function(){return this.a};l.nc=function(){return this.o};
l.clone=function(){var a=new P(this.c,this.f,this.b,this.ba(),this.Ca(),this.a,this.h);a.w=this.w;return a};l.unique=function(a){return new P(this.c,this.f,this.b,this.ba(),a,this.a,this.h)};l.toJSON=function(){return{store:this.c,index:this.f,keyRange:this.b?vd(this.b):null,direction:this.u}};
l.toString=function(){var a=u(this.h)?":"+this.h.join(","):u(this.f)?":"+this.f:"",a=a+Fd(this.b);this.g!=me&&(a+=this.g+"{"+this.i,this.o&&(a+=", "+this.j),a+="}");var b=this.o?"Index":"",b=b+(this.a?"Key":"Value");return b+"Iterator:"+this.c+a};l.fc=function(a,b){var c=new P(this.c,this.f,this.b,this.ba(),this.Ca(),this.a,this.h);c.i=a;c.j=b;c.g="rest";return c};l.reverse=function(){return new P(this.c,this.f,this.b,!this.ba(),this.Ca(),this.a,this.h)};
l.ba=function(){return"prev"===this.u||"prevunique"===this.u};l.Ca=function(){return"nextunique"===this.u||"prevunique"===this.u};l.mc=function(){return this.g};l.load=function(a){a=a[0];a.Nb(this.c,this.h||this.f,this.b,this.u,this.a);this.g="busy";var b=this;a.Pb=function(a,d,e){b.i=d;b.j=e;b.g=a?"rest":"done"};a.openCursor(this.i,this.j);return a};l.zc=function(){return this.i};l.Ac=function(){return this.j};
l.Jb=function(a,b,c){a=a||me;"busy"==this.g?F(this.logger,this+": resetting state to "+a+" ignore during iteration"):(this.i=b,this.j=c,this.g=a)};l.stores=function(){return[this.c]};function se(a,b,c){td.call(this,0,c);this.w=a;this.h=[];this.u=[];this.wa=[];this.a=null;this.Ba="";this.N=0}C(se,td);l=se.prototype;l.Ba="";l.logger=E("ydn.db.Request");function te(a,b,c){a.a=b;a.Ba=c;K(a.logger,a+" BEGIN");if(b){for(c=0;c<a.u.length;c++)a.u[c][0].call(a.u[c][1],b);a.u.length=0}}function ue(a){var b=new se(a.w);a.N++;te(b,a.a,a.Ba+"C"+a.N);return b}function ve(a){K(a.logger,a+" END");a.a=null}l.ic=function(){return!!this.a};
l.abort=function(){K(this.logger,this+" aborting "+this.a);if(this.a)if(fa(this.a.abort))this.a.abort();else if(fa(this.a.executeSql))this.a.executeSql("ABORT",[],function(){},function(){return!0});else throw new pd;else throw new we(this+" No active transaction");};function Q(a,b,c){var d=a.wa.shift();c=!!c;d?d[0].call(d[1],b,c,function(b,c){Q(a,b,c)}):c?a.l(b):a.callback(b)}function xe(a,b,c){a.wa.push([b,c])}function R(a,b,c){a.a?b.call(c,a.a):a.u.push([b,c])}
l.callback=function(a){K(this.logger,this+" SUCCESS");se.D.callback.call(this,a)};l.l=function(a){K(this.logger,this+" ERROR");se.D.l.call(this,a)};l.state=function(){return this.c?this.b?"rejected":"resolved":"pending"};function S(a){var b="";a.Ba&&(b=a.a?"*":"",b="["+a.Ba+b+"]");return a.w+b}function ye(a,b){var c=new se(a);Q(c,b);return c}l.toString=function(){return"Request:"+S(this)};
l.wb=function(){this.i&&this.c&&Mb(this)&&(Nb(this.i),this.i=0);this.f&&(this.f.H--,delete this.f);for(var a=this.g,b=!1;this.j.length&&!this.o;){var c=this.j.shift(),d=c[0],e=c[1],c=c[2];if(d=this.b?e:d)d=d.call(c||this.O,a),u(d)&&(this.b=this.b&&(d==a||d instanceof Error),this.g=a=d),pa(a)&&(this.o=b=!0)}this.g=a;b&&(b=ka(this.Ua,this,!0),d=ka(this.Ua,this,!1),a instanceof D?(Kb(a,b,d),a.I=!0):a.then(b,d))};
l.toJSON=function(){var a=(this.Ba||"").match(/B(\d+)T(\d+)(?:Q(\d+?))?(?:R(\d+))?/)||[];return{method:this.w?this.w.split(":"):[],branchNo:parseFloat(a[1]),transactionNo:parseFloat(a[2]),queueNo:parseFloat(a[3]),requestNo:parseFloat(a[4])}};var N=$d&&$d.cmp?ka($d.cmp,$d):Ud,ze=[];function Ae(a,b,c,d){if("transaction"in a)this.i=a,this.c=this.h=null;else if("objectStore"in a){if(this.i=null,this.h=a.db,this.c=a,!this.c.db.objectStoreNames.contains(b))throw new Be('store "'+b+'" not in transaction.');}else throw new Be("storage instance require.");this.j=b;this.o=c;this.u=d;this.b=[];this.a=0;this.g=!1}Ae.prototype.logger=E("ydn.db.con.IdbCursorStream");Ae.prototype.g=!1;
function Ce(a,b){a.a++;b.onsuccess=function(b){if(b=b.target.result){if(fa(a.u)){var d=b.value;a.u(b.primaryKey,null!=a.o?d[a.o]:d)}else F(a.logger,"sink gone, dropping value for: "+b.primaryKey);if(b&&0<a.b.length)b["continue"](a.b.shift());else a.a--,0==a.a&&a.ga&&a.ga()}};b.onerror=function(){F(a.logger,"seeking fail. "+("error"in b?b.error.name+":"+b.error.message:""));a.a--;0==a.a&&a.ga&&a.ga()}}function De(a,b){0==a.b.length&&0==a.a?b():a.ga=b}
function Ee(a){if(!a.g){var b=function(b,c){a.c=null;"complete"!==b&&F(a.logger,c.name+":"+c.message);H(a.logger,a+" transaction "+b)},c=function(b){var c=a.b.shift();H(a.logger,a+" transaction started for "+c);b=b.objectStore(a.j);Ce(a,b.openCursor(c))};if(a.c)H(a.logger,a+" using existing tx."),c(a.c);else if(a.h)H(a.logger,a+" creating tx from IDBDatabase."),a.f=a.h.transaction([a.j],Xd),a.f.oncomplete=function(a){b("complete",a)},a.f.onerror=function(a){b("error",a)},a.f.onabort=function(a){b("abort",
a)};else if(a.i)H(a.logger,a+" creating tx from ydn.db.con.IStorage."),a.g=!0,a.i.transaction(function(b){a.g=!1;c(b)},[a.j],Xd,b);else throw new Fe("no way to create a transaction provided.");}};function Ge(a,b,c){a&&a instanceof T?this.Ma=a:a&&a.db&&(this.Ma=null,He(this,a));if(!x(b))throw new L("a store name required.");this.c=b;if(u(c)&&!x(c))throw new L("projection index name must be a string.");this.Na=c;this.ca=null;this.b=[];this.a=[];this.Ia=!1}l=Ge.prototype;l.logger=E("ydn.db.Streamer");l.Ma=null;l.Lb=null;l.ca=null;l.uc=function(a){this.Lb=a};function He(a,b){if(b.db)a.ca=new Ae(b,a.c,a.Na,ka(a.ga,a));else throw new L("Invalid IndexedDB Transaction.");}
function Ie(a){var b=0<a.a.length;if(b&&!a.Ia&&fa(a.Lb)){var c=function(){Ie(a)},d=a.b.shift(),e=a.a.shift(),b=0<a.a.length,c=a.Lb(d,e,b?c:null);b&&!c&&Ie(a)}}l.Ia=!1;l.fa=function(a){if(this.ca){this.Ia=!0;var b=this;De(this.ca,function(){a(b.b,b.a);b.b=[];b.a=[];b.Ia=!1})}else a(this.b,this.a),this.b=[],this.a=[]};l.done=function(){if(this.ca){var a=new D,b=this;De(this.ca,function(){a.callback(b.a)});return a}return Qb(this.a)};l.ga=function(a,b){this.b.push(a);this.a.push(b);Ie(this)};
l.push=function(a,b){if(this.Ia)throw new Je("push not allowed after a collection is started");if(2<=arguments.length)this.ga(a,b);else{if(!this.ca){if(!this.Ma)throw new Je("Database connection is not setup.");var c=this.Ma.Fa();if(c)if("indexeddb"===c)this.ca=new Ae(this.Ma,this.c,this.Na,ka(this.ga,this));else throw new Ke(c);else throw new Je("Database is not connected.");}c=this.ca;c.b.push(a);Ee(c)}};l.toString=function(){return"Streamer:"+this.c+(this.Na||"")};function Le(a,b){if(null!=a&&!("push"in a))throw new Be('output receiver object must have "push" method.');this.a=a||null;this.i=b;this.g=0;this.b=!1;this.f=a instanceof Ge&&!!a.Na}Le.prototype.logger=E("ydn.db.algo.AbstractSolver");
Le.prototype.h=function(a,b){this.b=b[0].ba();for(var c=0;c<b.length;c++){if(!(b[c]instanceof P))throw new od("item at iterators "+c+" is not an iterator.");if(0<c&&this.b!=b[c].ba())throw new od("iterator at "+c+" must "+(this.b?"be reverse":"not be reverse"));}this.a instanceof Ge&&He(this.a,a);if(this.f&&(c=b[0].h)&&1<c.length&&c[c.length-1]!=this.a.Na)throw new Je("Output streamer projection field must be same as postfix field in the iterator");for(var d="{",c=0;c<b.length;c++)0<c&&(d+=", "),
d+=b.toString();d+="}";this.b&&(d+=" reverse");nd(this.logger,this+" begin "+d);return!1};function Me(a,b,c){var d,e=null!=d;if(!u(d)){d=c[0];for(var e=null!=d,f=1;e&&f<c.length;f++)null!=c[f]&&0==N(c[f],d)||(e=!1)}return e&&(a.g++,a.a&&(a.f?a.a.push(d,void 0):a.a.push(d)),u(a.i)&&a.g>=a.i)?[]:b}Le.prototype.c=function(){return[]};function Ne(a){Error.captureStackTrace?Error.captureStackTrace(this,Ne):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ConstraintError"}C(Ne,Error);Ne.prototype.name="ConstraintError";Ne.prototype.toString=function(){return this.name+": "+this.message};function Oe(a){Error.captureStackTrace?Error.captureStackTrace(this,Oe):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.db.InvalidKeyException"}C(Oe,Error);
Oe.prototype.toString=function(){return this.name+": "+this.message};function Pe(a){Error.captureStackTrace?Error.captureStackTrace(this,Pe):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.db.VersionError"}C(Pe,Error);Pe.prototype.name="ydn.db.VersionError";Pe.prototype.toString=function(){return this.name+": "+this.message};function Qe(a){Error.captureStackTrace?Error.captureStackTrace(this,Qe):this.stack=Error().stack||"";a&&(this.message=String(a))}C(Qe,Error);
Qe.prototype.name="ydn.db.InternalError";function we(a){Error.captureStackTrace?Error.captureStackTrace(this,we):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="InvalidStateError"}C(we,Error);function Re(a){Error.captureStackTrace?Error.captureStackTrace(this,Re):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="InvalidAccessError"}C(Re,Error);
function Se(a){Error.captureStackTrace?Error.captureStackTrace(this,Se):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="NotFoundError"}C(Se,Error);Se.prototype.name="NotFoundError";Se.prototype.toString=function(){return this.name+": "+this.message};function Te(a,b){Error.captureStackTrace?Error.captureStackTrace(this,Te):this.stack=Error().stack||"";b&&(this.message=String(b));this.message+=" :"+a.message+" ["+a.code+"]";this.name="SQLError"}C(Te,Error);
Te.prototype.toString=function(){return this.name+": "+this.message};function Ue(a,b){Error.captureStackTrace?Error.captureStackTrace(this,Ue):this.stack=Error().stack||"";b&&(this.message=String(b));this.message+=" :"+a.message;this.name="SecurityError"}C(Ue,Error);Ue.prototype.toString=function(){return this.name+": "+this.message};function Ve(a){Error.captureStackTrace?Error.captureStackTrace(this,Ve):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.db.SqlParseError"}
C(Ve,Error);function We(a){Error.captureStackTrace?Error.captureStackTrace(this,We):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.db.TimeoutError"}C(We,Error);function Xe(a,b,c){var d;if(A(a))d=a.store,b=a.id,null!=a.parent&&(c=new Xe(a.parent));else if(u(b))d=a;else if(d=a.lastIndexOf("^|"),b=a,0<d&&(b=a.substr(d),c=new Xe(a.substring(0,d))),b=b.split("^:"),d=b[0],b=b[1],!u(b))throw Error("Invalid key value: "+a);this.s=d;this.id=b;this.parent=c||null}l=Xe.prototype;l.toJSON=function(){var a={store:this.s,id:this.id};this.parent&&(a.parent=this.parent.toJSON());return a};
l.valueOf=function(){return(this.parent?this.parent.valueOf()+"^|":"")+this.s+"^:"+this.id};l.toString=function(){return this.valueOf().replace("^|","|").replace("^:",":")};l.Ec=function(){return this.s};l.jc=function(){return this.id};function Ye(a){return v(a.id)?a.id.join("^|"):a.id instanceof Date?+a.id:a.id}l.Dc=function(){return this.parent};function Ze(a){return null!=a?y(a)||x(a)||a instanceof Date||v(a)&&Pa(a,Ze):!1}
function ie(a){if(w(a)){for(var b=[],c=0,d=a.length;c<d;c++)b[c]=a[c];return b}return a};function $e(a,b){this.a=b}$e.prototype.logger=E("ydn.db.crud.req.RequestExecuto");$e.prototype.toString=function(){return"RequestExecutor"};function af(a){this.c=a;this.a=null;this.b=0}af.prototype.logger=E("ydn.db.tr.Mutex");af.prototype.S=null;function bf(a){return!!a.a&&!a.f}af.prototype.L=null;af.prototype.toString=function(){return"Mutex:"+("B"+this.c+"T"+this.b)+(this.a?"*":"")};function cf(a,b,c,d,e,f){this.I=a;this.N=b;this.a=this.f=0;this.H=d;this.w=e;this.g=c||ff;this.j=f||0}cf.prototype.logger=E("ydn.db.tr.Thread");cf.prototype.type=function(){return this.I.Fa()};cf.prototype.m=function(){return this.I};cf.prototype.J=function(){return"B"+this.N+"T"+this.f};var ff="single";function gf(a){if(a)if(fa(a.abort))a.abort();else if(fa(a.executeSql))a.executeSql("ABORT",[],null,function(){return!0});else throw new pd;else throw new we("No active transaction");};function hf(a,b,c,d,e,f){cf.call(this,a,b,c,d,e,f);this.c=[];this.h=[];this.i=null;this.b=new af(b);this.o=f||0;this.u=!1}C(hf,cf);l=hf.prototype;l.logger=E("ydn.db.tr.Serial");
function jf(a,b,c){if("multi"==a.g)a:if(a=a.b,!a.S||!a.mode||c!=a.mode&&(a.mode!=O||c!=Xd)||b.length>a.S.length)b=!1;else{for(c=0;c<b.length;c++)if(-1==a.S.indexOf(b[c])){b=!1;break a}b=!0}else if("repeat"==a.g)a:if(a=a.b,a.S&&a.mode&&c==a.mode&&a.S.length==b.length){for(c=0;c<b.length;c++)if(-1==a.S.indexOf(b[c])){b=!1;break a}b=!0}else b=!1;else b="all"==a.g?!0:!1;return b}function kf(a){var b=0<a.c.length?a.c[0].S:null,c=0<a.c.length?a.c[0].mode:null;return null!=b&&null!=c?jf(a,b,c):!1}
function lf(a,b,c,d,e){H(a.logger,"push tx queue["+a.c.length+"]");a.c.push({Ya:b,S:c,mode:d,L:e})}l.abort=function(){K(this.logger,this+": aborting");gf(this.i)};
l.sa=function(a,b,c,d){var e=x(b)?[b]:b;if(w(e)){if(0==e.length)throw new L("number of store names must more than 0");for(var f=0;f<e.length;f++){if(!x(e[f]))throw new L("store name at "+f+" must be string but found "+e[f]+" of type "+typeof e[f]);if(this.O&&!(0<=La(this.O,e[f])))throw new L('store name "'+f+e[f]+'" in scope of '+this);}}else throw new L("store names must be an array");var g=u(c)?c:Xd,h=this;if(this.b.a||!mf(this.m())&&this.u)lf(this,a,b,g,d);else{var k=this.J();d&&this.h.push(d);
if(this.o&&this.f>=this.o)throw new rd("Exceed maximum number of transactions of "+this.o);this.u=!0;this.m().transaction(function(c){var d=h.b;d.a=c;d.f=!1;d.S=b;d.mode=g;d.b++;d.L=null;k=h.J();nd(h.logger,k+" BEGIN "+V(b)+" "+g);a(h);for(a=null;kf(h);)c=h.c.shift(),c.L&&h.h.push(c.L),H(h.logger,"pop tx queue"+(h.c.length+1)+" reusing T"+h.f),c.Ya()},e,g,function(a,b){nd(h.logger,k+" "+a);var c=h.b;c.a?(c.a=null,c.S=null,c.mode=null,fa(c.L)&&c.L(a,b),c.L=null):F(c.logger,c+" has no TX to be unlocked for "+
a);for(c=0;c<h.h.length;c++)(0,h.h[c])(a,b);h.h.length=0;(c=h.c.shift())&&h.sa(c.Ya,c.S,c.mode,c.L);h.a=0})}};l.J=function(){var a=this.b;return"B"+a.c+"T"+a.b};l.request=function(a,b,c,d){function e(a,b){ve(f);d&&d(a,b)}var f=new se(a);a=c||Xd;var g=this;bf(this.b)&&jf(this,b,a)?(b=this.b.a,this.a++,te(f,b,this.J()+"R"+this.a),this.h.push(e)):g.sa(function(){var a=g.b.a;g.a++;te(f,a,g.J()+"R"+g.a)},b,a,e);return f};
l.ea=function(a,b,c,d,e){d=d||Xd;var f=this,g;if(bf(f.b)&&jf(this,c,d)){var h=f.b.a;f.a++;g=f.J()+"R"+f.a;K(f.logger,g+" BEGIN");b(h,g,function(b,c){f.i=h;c?(K(f.logger,g+" ERROR"),a.l(b)):(K(f.logger,g+" SUCCESS"),a.callback(b));f.i=null});K(f.logger,g+" END");b=null}else f.sa(function(){var c=f.b.a;f.a++;g=f.J()+"R"+f.a;K(f.logger,g+" BEGIN");b(c,g,function(b,d){f.i=c;d?(K(f.logger,g+" ERROR"),a.l(b)):(K(f.logger,g+" SUCCESS"),a.callback(b));f.i=null});K(f.logger,g+" END");b=null},c,d,e)};
l.getName=function(){return this.m().getName()};l.toString=function(){return"Serial:"+this.J()+(this.i?"*":"")};function nf(a,b){hf.call(this,a,b)}C(nf,hf);nf.prototype.logger=E("ydn.db.tr.AtomicSerial");nf.prototype.request=function(a,b,c){var d,e,f,g=nf.D.request.call(this,a,b,c,function(a,b){ve(g);if(d)"complete"!=a&&(f=!0,e=b),d(e,f);else{var c=new We;Q(g,c,!0)}});xe(g,function(a,b,c){f=b;e=a;d=c});return g};
nf.prototype.ea=function(a,b,c,d,e){var f,g,h=new D;Kb(h,function(a){g=!1;f=a},function(a){g=!0;f=a});nf.D.ea.call(this,h,b,c,d,function(b,c){if("complete"!=b)a.l(c);else if(!0===g)a.l(f);else if(!1===g)a.callback(f);else{var d=new We;a.l(d)}e&&(e(b,c),e=void 0)})};nf.prototype.toString=function(){return"Atomic"+nf.D.toString.call(this)};function of(a,b,c){this.f=a;this.b=b;this.a=c;this.c=null}l=of.prototype;l.logger=E("ydn.db.tr.DbOperator");l.Kc=function(){return this.a.f};l.abort=function(){this.a.abort()};function W(a){a.c||(a.c=a.f.u());return a.c}l.m=function(){return this.f};
function pf(a,b){var c=a.m(),d=b instanceof qf?b:rf(b),e=b.name,f=X(c.a,e);if(0==sf(d,f).length)Qb(!1);else if(f=f?"update":"add",c.a instanceof tf)uf(c.a,d),c.b?(c.b.close(),c.b=null,vf(c)):Qb(!1);else throw new wf("Cannot "+f+" store: "+e+". Not auto schema generation mode.");}l.toString=function(){return"TxStorage:"+this.m().getName()};function xf(a,b,c){of.call(this,a,b,c)}C(xf,of);l=xf.prototype;l.logger=E("ydn.db.crud.DbOperator");
l.count=function(a,b,c,d){var e,f,g,h;if(null!=a)if(v(a)){if(u(c)||u(b))throw new L("too many arguments.");f=a;for(var k=0;k<f.length;k++)if(!yf(this.b,f[k]))throw new L('store name "'+f[k]+'" at '+k+" not found.");K(this.logger,"countStores: "+V(f));e=this.a.request("count",f);R(e,function(){W(this).Va(e,f)},this)}else if(x(a)){k=X(this.b,a);if(!k)throw new L('store name "'+a+'" not found.');if(u(d)&&!da(d))throw new L('unique value "'+d+'" must be boolean, but found '+typeof d+".");f=[a];if(x(b))if(g=
b,A(c)){var m=Ed(c);if(m)throw new L("invalid key range: "+zf(c)+" "+m);h=xd(c)}else{if(null!=c)throw new L("invalid key range: "+zf(c)+" of type "+typeof c);h=null}else if(A(b)||null==b)if(A(b)){if(m=Ed(b))throw new L("invalid key range: "+zf(b)+" "+m);h=xd(b)}else{if(null!=b)throw new L("key range must be an object but found "+zf(b)+" of type "+typeof b);h=