UNPKG

ydn.db

Version:

Javascript database library for IndexedDB, WebDatabase (WebSQL) and WebStorage (localStorage) storage mechanisms supporting version migration, advanced query and transaction workflow.

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