diff --git a/feedhenry-forms.js b/feedhenry-forms.js index 18d9a4c2..d413b7b1 100644 --- a/feedhenry-forms.js +++ b/feedhenry-forms.js @@ -6777,8 +6777,8 @@ function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } -}).call(this,_dereq_("/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":6,"/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,"inherits":10}],8:[function(_dereq_,module,exports){ +}).call(this,_dereq_("/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./support/isBuffer":6,"/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,"inherits":10}],8:[function(_dereq_,module,exports){ (function (global){ /*global window, global*/ var util = _dereq_("util") @@ -7253,7 +7253,7 @@ process.chdir = function (dir) { module.exports=_dereq_(6) },{}],13:[function(_dereq_,module,exports){ module.exports=_dereq_(7) -},{"./support/isBuffer":12,"/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,"inherits":10}],14:[function(_dereq_,module,exports){ +},{"./support/isBuffer":12,"/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,"inherits":10}],14:[function(_dereq_,module,exports){ /* * loglevel - https://github.com/pimterry/loglevel * @@ -7453,35 +7453,35 @@ module.exports=_dereq_(7) })(); },{}],15:[function(_dereq_,module,exports){ -var toString = Object.prototype.toString - -module.exports = function(val){ - switch (toString.call(val)) { - case '[object Function]': return 'function' - case '[object Date]': return 'date' - case '[object RegExp]': return 'regexp' - case '[object Arguments]': return 'arguments' - case '[object Array]': return 'array' - case '[object String]': return 'string' - } - - if (typeof val == 'object' && val && typeof val.length == 'number') { - try { - if (typeof val.callee == 'function') return 'arguments'; - } catch (ex) { - if (ex instanceof TypeError) { - return 'arguments'; - } - } - } - - if (val === null) return 'null' - if (val === undefined) return 'undefined' - if (val && val.nodeType === 1) return 'element' - if (val === Object(val)) return 'object' - - return typeof val -} +var toString = Object.prototype.toString + +module.exports = function(val){ + switch (toString.call(val)) { + case '[object Function]': return 'function' + case '[object Date]': return 'date' + case '[object RegExp]': return 'regexp' + case '[object Arguments]': return 'arguments' + case '[object Array]': return 'array' + case '[object String]': return 'string' + } + + if (typeof val == 'object' && val && typeof val.length == 'number') { + try { + if (typeof val.callee == 'function') return 'arguments'; + } catch (ex) { + if (ex instanceof TypeError) { + return 'arguments'; + } + } + } + + if (val === null) return 'null' + if (val === undefined) return 'undefined' + if (val && val.nodeType === 1) return 'element' + if (val === Object(val)) return 'object' + + return typeof val +} },{}],16:[function(_dereq_,module,exports){ var constants = _dereq_("./modules/constants"); diff --git a/feedhenry-forms.min.js b/feedhenry-forms.min.js index 391191a3..bc8c6451 100644 --- a/feedhenry-forms.min.js +++ b/feedhenry-forms.min.js @@ -1,8 +1,8 @@ !function(a){if("object"==typeof exports)module.exports=a();else if("function"==typeof define&&define.amd)define(a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.feedhenry=a()}}(function(){var define,module,exports;return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gf;f++){var g=c[f>>>2]>>>24-f%4*8&255;b[d+f>>>2]|=g<<24-(d+f)%4*8}else if(c.length>65535)for(var f=0;e>f;f+=4)b[d+f>>>2]=c[f>>>2];else b.push.apply(b,c);return this.sigBytes+=e,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-c%4*8,b.length=a.ceil(c/4)},clone:function(){var a=e.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;b>d;d+=4)c.push(4294967296*a.random()|0);return new f.init(c,b)}}),g=c.enc={},h=g.Hex={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push((f>>>4).toString(16)),d.push((15&f).toString(16))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-d%8*4;return new f.init(c,b/2)}},i=g.Latin1={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push(String.fromCharCode(f))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-d%4*8;return new f.init(c,b)}},j=g.Utf8={stringify:function(a){try{return decodeURIComponent(escape(i.stringify(a)))}catch(b){throw new Error("Malformed UTF-8 data")}},parse:function(a){return i.parse(unescape(encodeURIComponent(a)))}},k=d.BufferedBlockAlgorithm=e.extend({reset:function(){this._data=new f.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,g=this.blockSize,h=4*g,i=e/h;i=b?a.ceil(i):a.max((0|i)-this._minBufferSize,0);var j=i*g,k=a.min(4*j,e);if(j){for(var l=0;j>l;l+=g)this._doProcessBlock(d,l);var m=d.splice(0,j);c.sigBytes-=k}return new f.init(m,k)},clone:function(){var a=e.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0}),l=(d.Hasher=k.extend({cfg:e.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){k.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){a&&this._append(a);var b=this._doFinalize();return b},blockSize:16,_createHelper:function(a){return function(b,c){return new a.init(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return new l.HMAC.init(a,c).finalize(b)}}}),c.algo={});return c}(Math);!function(){{var a=f,b=a.lib,c=b.WordArray,d=a.enc;d.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp();for(var e=[],f=0;c>f;f+=3)for(var g=b[f>>>2]>>>24-f%4*8&255,h=b[f+1>>>2]>>>24-(f+1)%4*8&255,i=b[f+2>>>2]>>>24-(f+2)%4*8&255,j=g<<16|h<<8|i,k=0;4>k&&c>f+.75*k;k++)e.push(d.charAt(j>>>6*(3-k)&63));var l=d.charAt(64);if(l)for(;e.length%4;)e.push(l);return e.join("")},parse:function(a){var b=a.length,d=this._map,e=d.charAt(64);if(e){var f=a.indexOf(e);-1!=f&&(b=f)}for(var g=[],h=0,i=0;b>i;i++)if(i%4){var j=d.indexOf(a.charAt(i-1))<>>6-i%4*2;g[h>>>2]|=(j|k)<<24-h%4*8,h++}return c.create(g,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}}(),f.lib.Cipher||function(a){var b=f,c=b.lib,d=c.Base,e=c.WordArray,g=c.BufferedBlockAlgorithm,h=b.enc,i=(h.Utf8,h.Base64),j=b.algo,k=j.EvpKDF,l=c.Cipher=g.extend({cfg:d.extend(),createEncryptor:function(a,b){return this.create(this._ENC_XFORM_MODE,a,b)},createDecryptor:function(a,b){return this.create(this._DEC_XFORM_MODE,a,b)},init:function(a,b,c){this.cfg=this.cfg.extend(c),this._xformMode=a,this._key=b,this.reset()},reset:function(){g.reset.call(this),this._doReset()},process:function(a){return this._append(a),this._process()},finalize:function(a){a&&this._append(a);var b=this._doFinalize();return b},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function a(a){return"string"==typeof a?x:u}return function(b){return{encrypt:function(c,d,e){return a(d).encrypt(b,c,d,e)},decrypt:function(c,d,e){return a(d).decrypt(b,c,d,e)}}}}()}),m=(c.StreamCipher=l.extend({_doFinalize:function(){var a=this._process(!0);return a},blockSize:1}),b.mode={}),n=c.BlockCipherMode=d.extend({createEncryptor:function(a,b){return this.Encryptor.create(a,b)},createDecryptor:function(a,b){return this.Decryptor.create(a,b)},init:function(a,b){this._cipher=a,this._iv=b}}),o=m.CBC=function(){function b(b,c,d){var e=this._iv;if(e){var f=e;this._iv=a}else var f=this._prevBlock;for(var g=0;d>g;g++)b[c+g]^=f[g]}var c=n.extend();return c.Encryptor=c.extend({processBlock:function(a,c){var d=this._cipher,e=d.blockSize;b.call(this,a,c,e),d.encryptBlock(a,c),this._prevBlock=a.slice(c,c+e)}}),c.Decryptor=c.extend({processBlock:function(a,c){var d=this._cipher,e=d.blockSize,f=a.slice(c,c+e);d.decryptBlock(a,c),b.call(this,a,c,e),this._prevBlock=f}}),c}(),p=b.pad={},q=p.Pkcs7={pad:function(a,b){for(var c=4*b,d=c-a.sigBytes%c,f=d<<24|d<<16|d<<8|d,g=[],h=0;d>h;h+=4)g.push(f);var i=e.create(g,d);a.concat(i)},unpad:function(a){var b=255&a.words[a.sigBytes-1>>>2];a.sigBytes-=b}},r=(c.BlockCipher=l.extend({cfg:l.cfg.extend({mode:o,padding:q}),reset:function(){l.reset.call(this);var a=this.cfg,b=a.iv,c=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var d=c.createEncryptor;else{var d=c.createDecryptor;this._minBufferSize=1}this._mode=d.call(c,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else{var b=this._process(!0);a.unpad(b)}return b},blockSize:4}),c.CipherParams=d.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}})),s=b.format={},t=s.OpenSSL={stringify:function(a){var b=a.ciphertext,c=a.salt;if(c)var d=e.create([1398893684,1701076831]).concat(c).concat(b);else var d=b;return d.toString(i)},parse:function(a){var b=i.parse(a),c=b.words;if(1398893684==c[0]&&1701076831==c[1]){var d=e.create(c.slice(2,4));c.splice(0,4),b.sigBytes-=16}return r.create({ciphertext:b,salt:d})}},u=c.SerializableCipher=d.extend({cfg:d.extend({format:t}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d),f=e.finalize(b),g=e.cfg;return r.create({ciphertext:f,key:c,iv:g.iv,algorithm:a,mode:g.mode,padding:g.padding,blockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){d=this.cfg.extend(d),b=this._parse(b,d.format);var e=a.createDecryptor(c,d).finalize(b.ciphertext);return e},_parse:function(a,b){return"string"==typeof a?b.parse(a,this):a}}),v=b.kdf={},w=v.OpenSSL={execute:function(a,b,c,d){d||(d=e.random(8));var f=k.create({keySize:b+c}).compute(a,d),g=e.create(f.words.slice(b),4*c);return f.sigBytes=4*b,r.create({key:f,iv:g,salt:d})}},x=c.PasswordBasedCipher=u.extend({cfg:u.cfg.extend({kdf:w}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=d.kdf.execute(c,a.keySize,a.ivSize);d.iv=e.iv;var f=u.encrypt.call(this,a,b,e.key,d);return f.mixIn(e),f},decrypt:function(a,b,c,d){d=this.cfg.extend(d),b=this._parse(b,d.format);var e=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=e.iv;var f=u.decrypt.call(this,a,b,e.key,d);return f}})}(),function(){var a=f,b=a.lib,c=b.BlockCipher,d=a.algo,e=[],g=[],h=[],i=[],j=[],k=[],l=[],m=[],n=[],o=[];!function(){for(var a=[],b=0;256>b;b++)a[b]=128>b?b<<1:b<<1^283;for(var c=0,d=0,b=0;256>b;b++){var f=d^d<<1^d<<2^d<<3^d<<4;f=f>>>8^255&f^99,e[c]=f,g[f]=c;var p=a[c],q=a[p],r=a[q],s=257*a[f]^16843008*f;h[c]=s<<24|s>>>8,i[c]=s<<16|s>>>16,j[c]=s<<8|s>>>24,k[c]=s;var s=16843009*r^65537*q^257*p^16843008*c;l[f]=s<<24|s>>>8,m[f]=s<<16|s>>>16,n[f]=s<<8|s>>>24,o[f]=s,c?(c=p^a[a[a[r^p]]],d^=a[a[d]]):c=d=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],q=d.AES=c.extend({_doReset:function(){for(var a=this._key,b=a.words,c=a.sigBytes/4,d=this._nRounds=c+6,f=4*(d+1),g=this._keySchedule=[],h=0;f>h;h++)if(c>h)g[h]=b[h];else{var i=g[h-1];h%c?c>6&&h%c==4&&(i=e[i>>>24]<<24|e[i>>>16&255]<<16|e[i>>>8&255]<<8|e[255&i]):(i=i<<8|i>>>24,i=e[i>>>24]<<24|e[i>>>16&255]<<16|e[i>>>8&255]<<8|e[255&i],i^=p[h/c|0]<<24),g[h]=g[h-c]^i}for(var j=this._invKeySchedule=[],k=0;f>k;k++){var h=f-k;if(k%4)var i=g[h];else var i=g[h-4];j[k]=4>k||4>=h?i:l[e[i>>>24]]^m[e[i>>>16&255]]^n[e[i>>>8&255]]^o[e[255&i]]}},encryptBlock:function(a,b){this._doCryptBlock(a,b,this._keySchedule,h,i,j,k,e)},decryptBlock:function(a,b){var c=a[b+1];a[b+1]=a[b+3],a[b+3]=c,this._doCryptBlock(a,b,this._invKeySchedule,l,m,n,o,g);var c=a[b+1];a[b+1]=a[b+3],a[b+3]=c},_doCryptBlock:function(a,b,c,d,e,f,g,h){for(var i=this._nRounds,j=a[b]^c[0],k=a[b+1]^c[1],l=a[b+2]^c[2],m=a[b+3]^c[3],n=4,o=1;i>o;o++){var p=d[j>>>24]^e[k>>>16&255]^f[l>>>8&255]^g[255&m]^c[n++],q=d[k>>>24]^e[l>>>16&255]^f[m>>>8&255]^g[255&j]^c[n++],r=d[l>>>24]^e[m>>>16&255]^f[j>>>8&255]^g[255&k]^c[n++],s=d[m>>>24]^e[j>>>16&255]^f[k>>>8&255]^g[255&l]^c[n++];j=p,k=q,l=r,m=s}var p=(h[j>>>24]<<24|h[k>>>16&255]<<16|h[l>>>8&255]<<8|h[255&m])^c[n++],q=(h[k>>>24]<<24|h[l>>>16&255]<<16|h[m>>>8&255]<<8|h[255&j])^c[n++],r=(h[l>>>24]<<24|h[m>>>16&255]<<16|h[j>>>8&255]<<8|h[255&k])^c[n++],s=(h[m>>>24]<<24|h[j>>>16&255]<<16|h[k>>>8&255]<<8|h[255&l])^c[n++];a[b]=p,a[b+1]=q,a[b+2]=r,a[b+3]=s},keySize:8});a.AES=c._createHelper(q)}(),function(a){function b(a,b,c,d,e,f,g){var h=a+(b&c|~b&d)+e+g;return(h<>>32-f)+b}function c(a,b,c,d,e,f,g){var h=a+(b&d|c&~d)+e+g;return(h<>>32-f)+b}function d(a,b,c,d,e,f,g){var h=a+(b^c^d)+e+g;return(h<>>32-f)+b}function e(a,b,c,d,e,f,g){var h=a+(c^(b|~d))+e+g;return(h<>>32-f)+b}var g=f,h=g.lib,i=h.WordArray,j=h.Hasher,k=g.algo,l=[];!function(){for(var b=0;64>b;b++)l[b]=4294967296*a.abs(a.sin(b+1))|0}();var m=k.MD5=j.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(a,f){for(var g=0;16>g;g++){var h=f+g,i=a[h];a[h]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var j=this._hash.words,k=a[f+0],m=a[f+1],n=a[f+2],o=a[f+3],p=a[f+4],q=a[f+5],r=a[f+6],s=a[f+7],t=a[f+8],u=a[f+9],v=a[f+10],w=a[f+11],x=a[f+12],y=a[f+13],z=a[f+14],A=a[f+15],B=j[0],C=j[1],D=j[2],E=j[3];B=b(B,C,D,E,k,7,l[0]),E=b(E,B,C,D,m,12,l[1]),D=b(D,E,B,C,n,17,l[2]),C=b(C,D,E,B,o,22,l[3]),B=b(B,C,D,E,p,7,l[4]),E=b(E,B,C,D,q,12,l[5]),D=b(D,E,B,C,r,17,l[6]),C=b(C,D,E,B,s,22,l[7]),B=b(B,C,D,E,t,7,l[8]),E=b(E,B,C,D,u,12,l[9]),D=b(D,E,B,C,v,17,l[10]),C=b(C,D,E,B,w,22,l[11]),B=b(B,C,D,E,x,7,l[12]),E=b(E,B,C,D,y,12,l[13]),D=b(D,E,B,C,z,17,l[14]),C=b(C,D,E,B,A,22,l[15]),B=c(B,C,D,E,m,5,l[16]),E=c(E,B,C,D,r,9,l[17]),D=c(D,E,B,C,w,14,l[18]),C=c(C,D,E,B,k,20,l[19]),B=c(B,C,D,E,q,5,l[20]),E=c(E,B,C,D,v,9,l[21]),D=c(D,E,B,C,A,14,l[22]),C=c(C,D,E,B,p,20,l[23]),B=c(B,C,D,E,u,5,l[24]),E=c(E,B,C,D,z,9,l[25]),D=c(D,E,B,C,o,14,l[26]),C=c(C,D,E,B,t,20,l[27]),B=c(B,C,D,E,y,5,l[28]),E=c(E,B,C,D,n,9,l[29]),D=c(D,E,B,C,s,14,l[30]),C=c(C,D,E,B,x,20,l[31]),B=d(B,C,D,E,q,4,l[32]),E=d(E,B,C,D,t,11,l[33]),D=d(D,E,B,C,w,16,l[34]),C=d(C,D,E,B,z,23,l[35]),B=d(B,C,D,E,m,4,l[36]),E=d(E,B,C,D,p,11,l[37]),D=d(D,E,B,C,s,16,l[38]),C=d(C,D,E,B,v,23,l[39]),B=d(B,C,D,E,y,4,l[40]),E=d(E,B,C,D,k,11,l[41]),D=d(D,E,B,C,o,16,l[42]),C=d(C,D,E,B,r,23,l[43]),B=d(B,C,D,E,u,4,l[44]),E=d(E,B,C,D,x,11,l[45]),D=d(D,E,B,C,A,16,l[46]),C=d(C,D,E,B,n,23,l[47]),B=e(B,C,D,E,k,6,l[48]),E=e(E,B,C,D,s,10,l[49]),D=e(D,E,B,C,z,15,l[50]),C=e(C,D,E,B,q,21,l[51]),B=e(B,C,D,E,x,6,l[52]),E=e(E,B,C,D,o,10,l[53]),D=e(D,E,B,C,v,15,l[54]),C=e(C,D,E,B,m,21,l[55]),B=e(B,C,D,E,t,6,l[56]),E=e(E,B,C,D,A,10,l[57]),D=e(D,E,B,C,r,15,l[58]),C=e(C,D,E,B,y,21,l[59]),B=e(B,C,D,E,p,6,l[60]),E=e(E,B,C,D,w,10,l[61]),D=e(D,E,B,C,n,15,l[62]),C=e(C,D,E,B,u,21,l[63]),j[0]=j[0]+B|0,j[1]=j[1]+C|0,j[2]=j[2]+D|0,j[3]=j[3]+E|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;c[e>>>5]|=128<<24-e%32;var f=a.floor(d/4294967296),g=d;c[(e+64>>>9<<4)+15]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),c[(e+64>>>9<<4)+14]=16711935&(g<<8|g>>>24)|4278255360&(g<<24|g>>>8),b.sigBytes=4*(c.length+1),this._process();for(var h=this._hash,i=h.words,j=0;4>j;j++){var k=i[j];i[j]=16711935&(k<<8|k>>>24)|4278255360&(k<<24|k>>>8)}return h},clone:function(){var a=j.clone.call(this);return a._hash=this._hash.clone(),a}});g.MD5=j._createHelper(m),g.HmacMD5=j._createHmacHelper(m)}(Math),function(){var a=f,b=a.lib,c=b.WordArray,d=b.Hasher,e=a.algo,g=[],h=e.SHA1=d.extend({_doReset:function(){this._hash=new c.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],h=c[3],i=c[4],j=0;80>j;j++){if(16>j)g[j]=0|a[b+j];else{var k=g[j-3]^g[j-8]^g[j-14]^g[j-16];g[j]=k<<1|k>>>31}var l=(d<<5|d>>>27)+i+g[j];l+=20>j?(e&f|~e&h)+1518500249:40>j?(e^f^h)+1859775393:60>j?(e&f|e&h|f&h)-1894007588:(e^f^h)-899497514,i=h,h=f,f=e<<30|e>>>2,e=d,d=l}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;return b[d>>>5]|=128<<24-d%32,b[(d+64>>>9<<4)+14]=Math.floor(c/4294967296),b[(d+64>>>9<<4)+15]=c,a.sigBytes=4*b.length,this._process(),this._hash},clone:function(){var a=d.clone.call(this);return a._hash=this._hash.clone(),a}});a.SHA1=d._createHelper(h),a.HmacSHA1=d._createHmacHelper(h)}(),function(a){{var b=f,c=b.lib,d=c.Base,e=c.WordArray,g=b.x64={};g.Word=d.extend({init:function(a,b){this.high=a,this.low=b}}),g.WordArray=d.extend({init:function(b,c){b=this.words=b||[],this.sigBytes=c!=a?c:8*b.length},toX32:function(){for(var a=this.words,b=a.length,c=[],d=0;b>d;d++){var f=a[d];c.push(f.high),c.push(f.low)}return e.create(c,this.sigBytes)},clone:function(){for(var a=d.clone.call(this),b=a.words=this.words.slice(0),c=b.length,e=0;c>e;e++)b[e]=b[e].clone();return a}})}}(),function(a){var b=f,c=b.lib,d=c.WordArray,e=c.Hasher,g=b.algo,h=[],i=[];!function(){function b(b){for(var c=a.sqrt(b),d=2;c>=d;d++)if(!(b%d))return!1;return!0}function c(a){return 4294967296*(a-(0|a))|0}for(var d=2,e=0;64>e;)b(d)&&(8>e&&(h[e]=c(a.pow(d,.5))),i[e]=c(a.pow(d,1/3)),e++),d++}();var j=[],k=g.SHA256=e.extend({_doReset:function(){this._hash=new d.init(h.slice(0))},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],k=c[5],l=c[6],m=c[7],n=0;64>n;n++){if(16>n)j[n]=0|a[b+n];else{var o=j[n-15],p=(o<<25|o>>>7)^(o<<14|o>>>18)^o>>>3,q=j[n-2],r=(q<<15|q>>>17)^(q<<13|q>>>19)^q>>>10;j[n]=p+j[n-7]+r+j[n-16]}var s=h&k^~h&l,t=d&e^d&f^e&f,u=(d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22),v=(h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25),w=m+v+s+i[n]+j[n],x=u+t;m=l,l=k,k=h,h=g+w|0,g=f,f=e,e=d,d=w+x|0}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+g|0,c[4]=c[4]+h|0,c[5]=c[5]+k|0,c[6]=c[6]+l|0,c[7]=c[7]+m|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;return c[e>>>5]|=128<<24-e%32,c[(e+64>>>9<<4)+14]=a.floor(d/4294967296),c[(e+64>>>9<<4)+15]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=e.clone.call(this);return a._hash=this._hash.clone(),a}});b.SHA256=e._createHelper(k),b.HmacSHA256=e._createHmacHelper(k)}(Math),function(){function a(){return g.create.apply(g,arguments)}var b=f,c=b.lib,d=c.Hasher,e=b.x64,g=e.Word,h=e.WordArray,i=b.algo,j=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],k=[];!function(){for(var b=0;80>b;b++)k[b]=a()}();var l=i.SHA512=d.extend({_doReset:function(){this._hash=new h.init([new g.init(1779033703,4089235720),new g.init(3144134277,2227873595),new g.init(1013904242,4271175723),new g.init(2773480762,1595750129),new g.init(1359893119,2917565137),new g.init(2600822924,725511199),new g.init(528734635,4215389547),new g.init(1541459225,327033209)])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],i=c[5],l=c[6],m=c[7],n=d.high,o=d.low,p=e.high,q=e.low,r=f.high,s=f.low,t=g.high,u=g.low,v=h.high,w=h.low,x=i.high,y=i.low,z=l.high,A=l.low,B=m.high,C=m.low,D=n,E=o,F=p,G=q,H=r,I=s,J=t,K=u,L=v,M=w,N=x,O=y,P=z,Q=A,R=B,S=C,T=0;80>T;T++){var U=k[T];if(16>T)var V=U.high=0|a[b+2*T],W=U.low=0|a[b+2*T+1];else{var X=k[T-15],Y=X.high,Z=X.low,$=(Y>>>1|Z<<31)^(Y>>>8|Z<<24)^Y>>>7,_=(Z>>>1|Y<<31)^(Z>>>8|Y<<24)^(Z>>>7|Y<<25),ab=k[T-2],bb=ab.high,cb=ab.low,db=(bb>>>19|cb<<13)^(bb<<3|cb>>>29)^bb>>>6,eb=(cb>>>19|bb<<13)^(cb<<3|bb>>>29)^(cb>>>6|bb<<26),fb=k[T-7],gb=fb.high,hb=fb.low,ib=k[T-16],jb=ib.high,kb=ib.low,W=_+hb,V=$+gb+(_>>>0>W>>>0?1:0),W=W+eb,V=V+db+(eb>>>0>W>>>0?1:0),W=W+kb,V=V+jb+(kb>>>0>W>>>0?1:0);U.high=V,U.low=W}var lb=L&N^~L&P,mb=M&O^~M&Q,nb=D&F^D&H^F&H,ob=E&G^E&I^G&I,pb=(D>>>28|E<<4)^(D<<30|E>>>2)^(D<<25|E>>>7),qb=(E>>>28|D<<4)^(E<<30|D>>>2)^(E<<25|D>>>7),rb=(L>>>14|M<<18)^(L>>>18|M<<14)^(L<<23|M>>>9),sb=(M>>>14|L<<18)^(M>>>18|L<<14)^(M<<23|L>>>9),tb=j[T],ub=tb.high,vb=tb.low,wb=S+sb,xb=R+rb+(S>>>0>wb>>>0?1:0),wb=wb+mb,xb=xb+lb+(mb>>>0>wb>>>0?1:0),wb=wb+vb,xb=xb+ub+(vb>>>0>wb>>>0?1:0),wb=wb+W,xb=xb+V+(W>>>0>wb>>>0?1:0),yb=qb+ob,zb=pb+nb+(qb>>>0>yb>>>0?1:0);R=P,S=Q,P=N,Q=O,N=L,O=M,M=K+wb|0,L=J+xb+(K>>>0>M>>>0?1:0)|0,J=H,K=I,H=F,I=G,F=D,G=E,E=wb+yb|0,D=xb+zb+(wb>>>0>E>>>0?1:0)|0}o=d.low=o+E,d.high=n+D+(E>>>0>o>>>0?1:0),q=e.low=q+G,e.high=p+F+(G>>>0>q>>>0?1:0),s=f.low=s+I,f.high=r+H+(I>>>0>s>>>0?1:0),u=g.low=u+K,g.high=t+J+(K>>>0>u>>>0?1:0),w=h.low=w+M,h.high=v+L+(M>>>0>w>>>0?1:0),y=i.low=y+O,i.high=x+N+(O>>>0>y>>>0?1:0),A=l.low=A+Q,l.high=z+P+(Q>>>0>A>>>0?1:0),C=m.low=C+S,m.high=B+R+(S>>>0>C>>>0?1:0)},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;b[d>>>5]|=128<<24-d%32,b[(d+128>>>10<<5)+30]=Math.floor(c/4294967296),b[(d+128>>>10<<5)+31]=c,a.sigBytes=4*b.length,this._process();var e=this._hash.toX32();return e},clone:function(){var a=d.clone.call(this);return a._hash=this._hash.clone(),a},blockSize:32});b.SHA512=d._createHelper(l),b.HmacSHA512=d._createHmacHelper(l)}(),function(a){var b=f,c=b.lib,d=c.WordArray,e=c.Hasher,g=b.x64,h=g.Word,i=b.algo,j=[],k=[],l=[];!function(){for(var a=1,b=0,c=0;24>c;c++){j[a+5*b]=(c+1)*(c+2)/2%64;var d=b%5,e=(2*a+3*b)%5;a=d,b=e}for(var a=0;5>a;a++)for(var b=0;5>b;b++)k[a+5*b]=b+(2*a+3*b)%5*5;for(var f=1,g=0;24>g;g++){for(var i=0,m=0,n=0;7>n;n++){if(1&f){var o=(1<o?m^=1<a;a++)m[a]=h.create()}();var n=i.SHA3=e.extend({cfg:e.cfg.extend({outputLength:512}),_doReset:function(){for(var a=this._state=[],b=0;25>b;b++)a[b]=new h.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(a,b){for(var c=this._state,d=this.blockSize/2,e=0;d>e;e++){var f=a[b+2*e],g=a[b+2*e+1];f=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),g=16711935&(g<<8|g>>>24)|4278255360&(g<<24|g>>>8);var h=c[e];h.high^=g,h.low^=f}for(var i=0;24>i;i++){for(var n=0;5>n;n++){for(var o=0,p=0,q=0;5>q;q++){var h=c[n+5*q];o^=h.high,p^=h.low}var r=m[n];r.high=o,r.low=p}for(var n=0;5>n;n++)for(var s=m[(n+4)%5],t=m[(n+1)%5],u=t.high,v=t.low,o=s.high^(u<<1|v>>>31),p=s.low^(v<<1|u>>>31),q=0;5>q;q++){var h=c[n+5*q];h.high^=o,h.low^=p}for(var w=1;25>w;w++){var h=c[w],x=h.high,y=h.low,z=j[w];if(32>z)var o=x<>>32-z,p=y<>>32-z;else var o=y<>>64-z,p=x<>>64-z;var A=m[k[w]];A.high=o,A.low=p}var B=m[0],C=c[0];B.high=C.high,B.low=C.low;for(var n=0;5>n;n++)for(var q=0;5>q;q++){var w=n+5*q,h=c[w],D=m[w],E=m[(n+1)%5+5*q],F=m[(n+2)%5+5*q];h.high=D.high^~E.high&F.high,h.low=D.low^~E.low&F.low}var h=c[0],G=l[i];h.high^=G.high,h.low^=G.low}},_doFinalize:function(){var b=this._data,c=b.words,e=(8*this._nDataBytes,8*b.sigBytes),f=32*this.blockSize;c[e>>>5]|=1<<24-e%32,c[(a.ceil((e+1)/f)*f>>>5)-1]|=128,b.sigBytes=4*c.length,this._process();for(var g=this._state,h=this.cfg.outputLength/8,i=h/8,j=[],k=0;i>k;k++){var l=g[k],m=l.high,n=l.low;m=16711935&(m<<8|m>>>24)|4278255360&(m<<24|m>>>8),n=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),j.push(n),j.push(m)}return new d.init(j,h)},clone:function(){for(var a=e.clone.call(this),b=a._state=this._state.slice(0),c=0;25>c;c++)b[c]=b[c].clone();return a}});b.SHA3=e._createHelper(n),b.HmacSHA3=e._createHmacHelper(n)}(Math),e("undefined"!=typeof f?f:window.CryptoJS)}.call(c,void 0,void 0,void 0,void 0,function(a){b.exports=a})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(a,b){(function(c){__browserify_shim_require__=a,function(a,b,c,d,e){var f=function(a,b){if(!(this instanceof f))return new f(a,b);if(!JSON)throw"JSON unavailable! Include http://www.json.org/json2.js to fix.";if(!(arguments.length<=2&&arguments.length>0))throw"Incorrect # of ctor args!";if(b="function"==typeof arguments[0]?arguments[0]:arguments[1],a="function"==typeof arguments[0]?{}:arguments[0],"function"!=typeof b)throw"No callback was provided";this.record=a.record||"record",this.name=a.name||"records";var c;if(a.adapter){"string"==typeof a.adapter&&(a.adapter=[a.adapter]);for(var d=0,e=a.adapter.length;e>d;d++){for(var g=f.adapters.length-1;g>=0&&(f.adapters[g].adapter!==a.adapter[d]||!(c=f.adapters[g].valid()?f.adapters[g]:void 0));g--);if(c)break}}else for(var g=0,h=f.adapters.length;h>g&&!(c=f.adapters[g].valid()?f.adapters[g]:void 0);g++);if(!c)throw"No valid adapter.";for(var d in c)this[d]=c[d];for(var g=0,h=f.plugins.length;h>g;g++)f.plugins[g].call(this);this.init(a,b)};f.adapters=[],f.adapter=function(a,b){b.adapter=a;var c="adapter valid init keys save batch get exists all remove nuke".split(" "),d=this.prototype.indexOf;for(var e in b)if(-1===d(c,e))throw"Invalid adapter! Nonstandard method: "+e;f.adapters.splice(0,0,b)},f.plugins=[],f.plugin=function(a){for(var b in a)"init"===b?f.plugins.push(a[b]):this.prototype[b]=a[b]},f.prototype={isArray:Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},indexOf:function(a,b,c,d){if(a.indexOf)return a.indexOf(b);for(c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},lambda:function(a){return this.fn(this.record,a)},fn:function(a,b){return"string"==typeof b?new Function(a,b):b},uuid:function(){var a=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()},each:function(a){var b=this.lambda(a);if(this.__results)for(var c=0,d=this.__results.length;d>c;c++)b.call(this,this.__results[c],c);else this.all(function(a){for(var c=0,d=a.length;d>c;c++)b.call(this,a[c],c)});return this}},f.adapter("window-name",function(){"undefined"==typeof window&&(window={top:{}});var a={};try{a=JSON.parse(window.top.name)}catch(b){}return{valid:function(){return"undefined"!=typeof window.top.name},init:function(b,c){return a[this.name]=a[this.name]||{index:[],store:{}},this.index=a[this.name].index,this.store=a[this.name].store,this.fn(this.name,c).call(this,this),this},keys:function(a){return this.fn("keys",a).call(this,this.index),this},save:function(b,c){var d=b.key||this.uuid();return this.exists(d,function(e){e||(b.key&&delete b.key,this.index.push(d)),this.store[d]=b;try{window.top.name=JSON.stringify(a)}catch(f){throw e||(this.index.pop(),delete this.store[d]),f}c&&(b.key=d,this.lambda(c).call(this,b))}),this},batch:function(a,b){for(var c=[],d=0,e=a.length;e>d;d++)this.save(a[d],function(a){c.push(a)});return b&&this.lambda(b).call(this,c),this},get:function(a,b){var c;if(this.isArray(a)){c=[];for(var d=0,e=a.length;e>d;d++)c.push(this.store[a[d]])}else c=this.store[a],c&&(c.key=a);return b&&this.lambda(b).call(this,c),this},exists:function(a,b){return this.lambda(b).call(this,!!this.store[a]),this},all:function(a){for(var b=[],c=0,d=this.index.length;d>c;c++){var e=this.store[this.index[c]];e.key=this.index[c],b.push(e)}return this.fn(this.name,a).call(this,b),this},remove:function(b,c){for(var d=this.isArray(b)?b:[b],e=0,f=d.length;f>e;e++){var g=d[e].key?d[e].key:d[e],h=this.indexOf(this.index,g);0>h||(delete this.store[g],this.index.splice(h,1))}return window.top.name=JSON.stringify(a),c&&this.lambda(c).call(this),this},nuke:function(b){return this.store=a[this.name].store={},this.index=a[this.name].index=[],window.top.name=JSON.stringify(a),b&&this.lambda(b).call(this),this}}}()),f.adapter("dom",function(){var a=null;try{a=window.localStorage}catch(b){}var c=function(b){return{key:b+"._index_",all:function(){var b=a.getItem(this.key);return b&&(b=JSON.parse(b)),null===b&&a.setItem(this.key,JSON.stringify([])),JSON.parse(a.getItem(this.key))},add:function(b){var c=this.all();c.push(b),a.setItem(this.key,JSON.stringify(c))},del:function(b){for(var c=this.all(),d=[],e=0,f=c.length;f>e;e++)c[e]!=b&&d.push(c[e]);a.setItem(this.key,JSON.stringify(d))},find:function(a){for(var b=this.all(),c=0,d=b.length;d>c;c++)if(a===b[c])return c;return!1}}};return{valid:function(){return!!a&&function(){var b=!0,c=Math.random();try{a.setItem(c,c)}catch(d){b=!1}return a.removeItem(c),b}()},init:function(a,b){this.indexer=c(this.name),b&&this.fn(this.name,b).call(this,this)},save:function(b,c){var d=b.key?this.name+"."+b.key:this.name+"."+this.uuid();return delete b.key,a.setItem(d,JSON.stringify(b)),this.indexer.find(d)===!1&&this.indexer.add(d),b.key=d.slice(this.name.length+1),c&&this.lambda(c).call(this,b),this},batch:function(a,b){for(var c=[],d=0,e=a.length;e>d;d++)this.save(a[d],function(a){c.push(a)});return b&&this.lambda(b).call(this,c),this},keys:function(a){if(a){var b=this.name,c=this.indexer.all(),d=[];if(Array.prototype.map)d=c.map(function(a){return a.replace(b+".","")});else for(var e in c)d.push(e.replace(b+".",""));this.fn("keys",a).call(this,d)}return this},get:function(b,c){if(this.isArray(b)){for(var d=[],e=0,f=b.length;f>e;e++){var g=this.name+"."+b[e],h=a.getItem(g);h&&(h=JSON.parse(h),h.key=b[e]),d.push(h)}c&&this.lambda(c).call(this,d)}else{var g=this.name+"."+b,h=a.getItem(g);h&&(h=JSON.parse(h),h.key=b),c&&this.lambda(c).call(this,h)}return this},exists:function(a,b){var c=this.indexer.find(this.name+"."+a)===!1?!1:!0;return this.lambda(b).call(this,c),this},all:function(b){for(var c,d,e=this.indexer.all(),f=[],g=0,h=e.length;h>g;g++)d=e[g],c=JSON.parse(a.getItem(d)),c.key=d.replace(this.name+".",""),f.push(c);return b&&this.fn(this.name,b).call(this,f),this},remove:function(b,c){var d=this;if(this.isArray(b)){var e,f=b.length,g=function(a){d.remove(b[a],function(){--f>0||c&&d.lambda(c).call(d)})};for(e=0;ec;c++)this.remove(b[c]);a&&this.lambda(a).call(this)}),this}}}()),f.adapter("webkit-sqlite",function(){var a=function(a,b){console&&console.log("error in sqlite adaptor!",a,b)},b=function(){return new Date};return{valid:function(){return!!window.openDatabase},init:function(b,c){var d=this,e=d.fn(d.name,c),f="CREATE TABLE IF NOT EXISTS "+this.record+" (id NVARCHAR(32) UNIQUE PRIMARY KEY, value TEXT, timestamp REAL)",g=function(){return e.call(d,d)};b&&"function"==typeof b.fail&&(a=b.fail),this.db=openDatabase(this.name,"1.0.0",this.name,65536),this.db.transaction(function(b){b.executeSql(f,[],g,a)})},keys:function(b){var c=this.lambda(b),d=this,e="SELECT id FROM "+this.record+" ORDER BY timestamp DESC";return this.db.readTransaction(function(b){var f=function(a,b){if(0==b.rows.length)c.call(d,[]);else{for(var e=[],f=0,g=b.rows.length;g>f;f++)e.push(b.rows.item(f).id);c.call(d,e)}};b.executeSql(e,[],f,a)}),this},save:function(c,d,e){var f=this;objs=(this.isArray(c)?c:[c]).map(function(a){return a.key||(a.key=f.uuid()),a}),ins="INSERT OR REPLACE INTO "+this.record+" (value, timestamp, id) VALUES (?,?,?)",win=function(){d&&f.lambda(d).call(f,f.isArray(c)?objs:objs[0])},e=e||function(){},insvals=[],ts=b();try{for(var g=0,h=objs.length;h>g;g++)insvals[g]=[JSON.stringify(objs[g]),ts,objs[g].key]}catch(i){throw a(i),i}return f.db.transaction(function(a){for(var b=0,c=objs.length;c>b;b++)a.executeSql(ins,insvals[b])},function(b,c){a(b,c)},win),this},batch:function(a,b){return this.save(a,b)},get:function(b,c){var d=this,e="",f=this.isArray(b)?b:[b];e="SELECT id, value FROM "+this.record+" WHERE id IN ("+f.map(function(){return"?"}).join(",")+")";var g=function(a,e){for(var g,h,i={},j=0,k=e.rows.length;k>j;j++)g=JSON.parse(e.rows.item(j).value),g.key=e.rows.item(j).id,i[g.key]=g;h=f.map(function(a){return i[a]}),d.isArray(b)||(h=h.length?h[0]:null),c&&d.lambda(c).call(d,h)};return this.db.readTransaction(function(b){b.executeSql(e,f,g,a)}),this},exists:function(b,c){var d="SELECT * FROM "+this.record+" WHERE id = ?",e=this,f=function(a,b){c&&e.fn("exists",c).call(e,b.rows.length>0)};return this.db.readTransaction(function(c){c.executeSql(d,[b],f,a)}),this -},all:function(b){var c=this,d="SELECT * FROM "+this.record,e=[],f=this.fn(this.name,b)||void 0,g=function(a,b){if(0!=b.rows.length)for(var d=0,g=b.rows.length;g>d;d++){var h=JSON.parse(b.rows.item(d).value);h.key=b.rows.item(d).id,e.push(h)}f&&f.call(c,e)};return this.db.readTransaction(function(b){b.executeSql(d,[],g,a)}),this},remove:function(b,c){var d,e=this,f="DELETE FROM "+this.record+" WHERE id ",g=function(){c&&e.lambda(c).call(e)};return this.isArray(b)?(d=b,f+="IN ("+d.map(function(){return"?"}).join(",")+")"):(f+="= ?",d=[b]),d=d.map(function(a){return a.key?a.key:a}),this.db.transaction(function(b){b.executeSql(f,d,g,a)}),this},nuke:function(b){var c="DELETE FROM "+this.record,d=this,e=b?function(){d.lambda(b).call(d)}:function(){};return this.db.transaction(function(b){b.executeSql(c,[],e,a)}),this}}}()),f.adapter("html5-filesystem",function(a){var b=a.FileError,c=function(a){var c,d=!0;switch(a.code){case b.QUOTA_EXCEEDED_ERR:c="QUOTA_EXCEEDED_ERR";break;case b.NOT_FOUND_ERR:c="NOT_FOUND_ERR",d=!1;break;case b.SECURITY_ERR:c="SECURITY_ERR";break;case b.INVALID_MODIFICATION_ERR:c="INVALID_MODIFICATION_ERR";break;case b.INVALID_STATE_ERR:c="INVALID_STATE_ERR";break;default:c="Unknown Error"}console&&d&&console.error(a,c)},d=function(a,b,e){var f=e||[];a.readEntries(function(c){c.length?d(a,b,f.concat(Array.prototype.slice.call(c))):b&&b(f.map(function(a){return a.name}))},c)},e={},f=function(a,b){var c=e[a.name];c?b(c):setTimeout(function(){f(a,b)},10)},g=function(){var a=-1===document.URL.indexOf("http://")&&-1===document.URL.indexOf("https://");return a?!0:!1},h=function(a){var b;if(g())b=a;else{var c="application/json";try{b=new Blob([a],{type:c})}catch(d){var e=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if("TypeError"==d.name&&e){var f=new e;f.append([a.buffer]),b=f.getBlob(c)}else b=a}}return b};return{valid:function(){var b=a.requestFileSystem||a.webkitRequestFileSystem||a.moz_requestFileSystem;return!!b},init:function(b,d){function f(b){var c=a.requestFileSystem||a.webkitRequestFileSystem||a.moz_requestFileSystem,f=window.PERSISTENT;"undefined"!=typeof LocalFileSystem&&"undefined"!=typeof LocalFileSystem.PERSISTENT&&(f=LocalFileSystem.PERSISTENT),c(f,b,function(a){a.root.getDirectory(j,{create:!0},function(a){e[j]=a,d&&g.fn(g.name,d).call(g,g)},function(a){h(a)})},function(a){h(a)})}var g=this,h=function(a){c(a),d&&g.fn(g.name,d).call(g,g)},i=b.size||104857600,j=this.name;"undefined"!=typeof navigator.webkitPersistentStorage?navigator.webkitPersistentStorage.requestQuota(i,f,function(){logger.warn("User declined file storage"),h("User declined file storage")}):f(0)},keys:function(a){var b=this;return f(this,function(c){d(c.createReader(),function(c){a&&b.fn("keys",a).call(b,c)})}),this},save:function(a,b){var d=this,e=a.key||this.uuid();a.key=e;var g=function(a){c(a),b&&d.lambda(b).call(d)};return f(this,function(c){c.getFile(e,{create:!0},function(c){c.createWriter(function(c){c.onerror=g,c.onwriteend=function(){this.onwriteend=null,this.truncate(this.position),b&&d.lambda(b).call(d,a)};var e=JSON.stringify(a),f=h(e);c.write(f)},g)},g)}),this},batch:function(a,b){for(var c=this,d=[],e=0,f=a.length;f>e;e++)c.save(a[e],function(a){d.push(a),d.length===f&&b&&c.lambda(b).call(c,d)});return this},get:function(a,b){var d=this;if(this.isArray(a))for(var e=[],g=0,h=a.length;h>g;g++)d.get(a[g],function(a){a&&e.push(a),e.length===h&&b&&d.lambda(b).call(d,e)});else{var i=function(a){c(a),b&&d.lambda(b).call(d)};f(this,function(c){c.getFile(a,{create:!1},function(c){c.file(function(c){var e=new FileReader;e.onerror=i,e.onload=function(c){var e={};try{e=JSON.parse(c.target.result),e.key=a}catch(c){e={key:a}}b&&d.lambda(b).call(d,e)},e.readAsText(c)},i)},i)})}return this},exists:function(a,b){var c=this;return f(this,function(d){d.getFile(a,{create:!1},function(){b&&c.lambda(b).call(c,!0)},function(){b&&c.lambda(b).call(c,!1)})}),this},all:function(a){var b=this;return a&&this.keys(function(c){c.length?b.get(c,function(c){b.fn(b.name,a).call(b,c)}):b.fn(b.name,a).call(b,[])}),this},remove:function(a,b){var d=this,e=function(a){c(a),b&&d.lambda(b).call(d)};return f(this,function(c){c.getFile("string"==typeof a?a:a.key,{create:!1},function(a){a.remove(function(){b&&d.lambda(b).call(d)},e)},e)}),this},nuke:function(a){var b=this,c=0;return this.keys(function(d){if(d.length)for(var e=0,f=d.length;f>e;e++)b.remove(d[e],function(){c++,c===f&&a&&b.lambda(a).call(b)});else a&&b.lambda(a).call(b)}),this}}}(this)),f.adapter("memory",function(){var a={};return{valid:function(){return!0},init:function(b,c){a[this.name]=a[this.name]||{index:[],store:{}},this.index=a[this.name].index,this.store=a[this.name].store;var d=this.fn(this.name,c);return d&&d.call(this,this),this},keys:function(a){return this.fn("keys",a).call(this,this.index),this},save:function(a,b){var c=a.key||this.uuid();return this.exists(c,function(d){d||(a.key&&delete a.key,this.index.push(c)),this.store[c]=a,b&&(a.key=c,this.lambda(b).call(this,a))}),this},batch:function(a,b){for(var c=[],d=0,e=a.length;e>d;d++)this.save(a[d],function(a){c.push(a)});return b&&this.lambda(b).call(this,c),this},get:function(a,b){var c;if(this.isArray(a)){c=[];for(var d=0,e=a.length;e>d;d++)c.push(this.store[a[d]])}else c=this.store[a],c&&(c.key=a);return b&&this.lambda(b).call(this,c),this},exists:function(a,b){return this.lambda(b).call(this,!!this.store[a]),this},all:function(a){for(var b=[],c=0,d=this.index.length;d>c;c++){var e=this.store[this.index[c]];e.key=this.index[c],b.push(e)}return this.fn(this.name,a).call(this,b),this},remove:function(a,b){for(var c=this.isArray(a)?a:[a],d=0,e=c.length;e>d;d++){var f=c[d].key?c[d].key:c[d],g=this.indexOf(this.index,f);0>g||(delete this.store[f],this.index.splice(g,1))}return b&&this.lambda(b).call(this),this},nuke:function(b){return this.store=a[this.name].store={},this.index=a[this.name].index=[],b&&this.lambda(b).call(this),this}}}()),e("undefined"!=typeof f?f:window.Lawnchair)}.call(c,void 0,void 0,void 0,void 0,function(a){b.exports=a})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(_dereq_,module,exports){(function(global){__browserify_shim_require__=_dereq_,function browserifyShim(module,exports,_dereq_,define,browserify_shim__define__module__export__){var JSON;JSON||(JSON={}),function(){"use strict";function f(a){return 10>a?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g,h=gap,i=b[a];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(a)),"function"==typeof rep&&(i=rep.call(b,a,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";if(gap+=indent,g=[],"[object Array]"===Object.prototype.toString.apply(i)){for(f=i.length,c=0;f>c;c+=1)g[c]=str(c,i)||"null";return e=0===g.length?"[]":gap?"[\n"+gap+g.join(",\n"+gap)+"\n"+h+"]":"["+g.join(",")+"]",gap=h,e}if(rep&&"object"==typeof rep)for(f=rep.length,c=0;f>c;c+=1)"string"==typeof rep[c]&&(d=rep[c],e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));return e=0===g.length?"{}":gap?"{\n"+gap+g.join(",\n"+gap)+"\n"+h+"}":"{"+g.join(",")+"}",gap=h,e}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;"function"!=typeof JSON.stringify&&(JSON.stringify=function(a,b,c){var d;if(gap="",indent="","number"==typeof c)for(d=0;c>d;d+=1)indent+=" ";else"string"==typeof c&&(indent=c);if(rep=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return str("",{"":a})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&"object"==typeof e)for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),void 0!==d?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),browserify_shim__define__module__export__("undefined"!=typeof JSON?JSON:window.JSON)}.call(global,void 0,void 0,void 0,void 0,function(a){module.exports=a})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(a,b){function c(a,b,c){null!=a&&("number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))}function d(){return new c(null)}function e(a,b,c,d,e,f){for(;--f>=0;){var g=b*this[a++]+c[d]+e;e=Math.floor(g/67108864),c[d++]=67108863&g}return e}function f(a,b,c,d,e,f){for(var g=32767&b,h=b>>15;--f>=0;){var i=32767&this[a],j=this[a++]>>15,k=h*i+j*g;i=g*i+((32767&k)<<15)+c[d]+(1073741823&e),e=(i>>>30)+(k>>>15)+h*j+(e>>>30),c[d++]=1073741823&i}return e}function g(a,b,c,d,e,f){for(var g=16383&b,h=b>>14;--f>=0;){var i=16383&this[a],j=this[a++]>>14,k=h*i+j*g;i=g*i+((16383&k)<<14)+c[d]+e,e=(i>>28)+(k>>14)+h*j,c[d++]=268435455&i}return e}function h(a){return nb.charAt(a)}function i(a,b){var c=ob[a.charCodeAt(b)];return null==c?-1:c}function j(a){for(var b=this.t-1;b>=0;--b)a[b]=this[b];a.t=this.t,a.s=this.s}function k(a){this.t=1,this.s=0>a?-1:0,a>0?this[0]=a:-1>a?this[0]=a+DV:this.t=0}function l(a){var b=d();return b.fromInt(a),b}function m(a,b){var d;if(16==b)d=4;else if(8==b)d=3;else if(256==b)d=8;else if(2==b)d=1;else if(32==b)d=5;else{if(4!=b)return void this.fromRadix(a,b);d=2}this.t=0,this.s=0;for(var e=a.length,f=!1,g=0;--e>=0;){var h=8==d?255&a[e]:i(a,e);0>h?"-"==a.charAt(e)&&(f=!0):(f=!1,0==g?this[this.t++]=h:g+d>this.DB?(this[this.t-1]|=(h&(1<>this.DB-g):this[this.t-1]|=h<=this.DB&&(g-=this.DB))}8==d&&0!=(128&a[0])&&(this.s=-1,g>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==a;)--this.t}function o(a){if(this.s<0)return"-"+this.negate().toString(a);var b;if(16==a)b=4;else if(8==a)b=3;else if(2==a)b=1;else if(32==a)b=5;else{if(4!=a)return this.toRadix(a);b=2}var c,d=(1<0)for(i>i)>0&&(e=!0,f=h(c));g>=0;)b>i?(c=(this[g]&(1<>(i+=this.DB-b)):(c=this[g]>>(i-=b)&d,0>=i&&(i+=this.DB,--g)),c>0&&(e=!0),e&&(f+=h(c));return e?f:"0"}function p(){var a=d();return c.ZERO.subTo(this,a),a}function q(){return this.s<0?this.negate():this}function r(a){var b=this.s-a.s;if(0!=b)return b;var c=this.t;if(b=c-a.t,0!=b)return this.s<0?-b:b;for(;--c>=0;)if(0!=(b=this[c]-a[c]))return b;return 0}function s(a){var b,c=1;return 0!=(b=a>>>16)&&(a=b,c+=16),0!=(b=a>>8)&&(a=b,c+=8),0!=(b=a>>4)&&(a=b,c+=4),0!=(b=a>>2)&&(a=b,c+=2),0!=(b=a>>1)&&(a=b,c+=1),c}function t(){return this.t<=0?0:this.DB*(this.t-1)+s(this[this.t-1]^this.s&this.DM)}function u(a,b){var c;for(c=this.t-1;c>=0;--c)b[c+a]=this[c];for(c=a-1;c>=0;--c)b[c]=0;b.t=this.t+a,b.s=this.s}function v(a,b){for(var c=a;c=0;--c)b[c+g+1]=this[c]>>e|h,h=(this[c]&f)<=0;--c)b[c]=0;b[g]=h,b.t=this.t+g+1,b.s=this.s,b.clamp()}function x(a,b){b.s=this.s;var c=Math.floor(a/this.DB);if(c>=this.t)return void(b.t=0);var d=a%this.DB,e=this.DB-d,f=(1<>d;for(var g=c+1;g>d;d>0&&(b[this.t-c-1]|=(this.s&f)<c;)d+=this[c]-a[c],b[c++]=d&this.DM,d>>=this.DB;if(a.t>=this.DB;d+=this.s}else{for(d+=this.s;c>=this.DB;d-=a.s}b.s=0>d?-1:0,-1>d?b[c++]=this.DV+d:d>0&&(b[c++]=d),b.t=c,b.clamp()}function z(a,b){var d=this.abs(),e=a.abs(),f=d.t;for(b.t=f+e.t;--f>=0;)b[f]=0;for(f=0;f=0;)a[c]=0;for(c=0;c=b.DV&&(a[c+b.t]-=b.DV,a[c+b.t+1]=1)}a.t>0&&(a[a.t-1]+=b.am(c,b[c],a,2*c,0,1)),a.s=0,a.clamp()}function B(a,b,e){var f=a.abs();if(!(f.t<=0)){var g=this.abs();if(g.t0?(f.lShiftTo(k,h),g.lShiftTo(k,e)):(f.copyTo(h),g.copyTo(e));var l=h.t,m=h[l-1];if(0!=m){var n=m*(1<1?h[l-2]>>this.F2:0),o=this.FV/n,p=(1<=0&&(e[e.t++]=1,e.subTo(u,e)),c.ONE.dlShiftTo(l,u),u.subTo(h,h);h.t=0;){var v=e[--r]==m?this.DM:Math.floor(e[r]*o+(e[r-1]+q)*p);if((e[r]+=h.am(0,v,e,t,0,l))0&&e.rShiftTo(k,e),0>i&&c.ZERO.subTo(e,e)}}}function C(a){var b=d();return this.abs().divRemTo(a,null,b),this.s<0&&b.compareTo(c.ZERO)>0&&a.subTo(b,b),b}function D(a){this.m=a}function E(a){return a.s<0||a.compareTo(this.m)>=0?a.mod(this.m):a}function F(a){return a}function G(a){a.divRemTo(this.m,null,a)}function H(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function I(a,b){a.squareTo(b),this.reduce(b)}function J(){if(this.t<1)return 0;var a=this[0];if(0==(1&a))return 0;var b=3&a;return b=b*(2-(15&a)*b)&15,b=b*(2-(255&a)*b)&255,b=b*(2-((65535&a)*b&65535))&65535,b=b*(2-a*b%this.DV)%this.DV,b>0?this.DV-b:-b}function K(a){this.m=a,this.mp=a.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(b,b),b}function M(a){var b=d();return a.copyTo(b),this.reduce(b),b}function N(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var b=0;b>15)*this.mpl&this.um)<<15)&a.DM;for(c=b+this.m.t,a[c]+=this.m.am(0,d,a,b,0,this.m.t);a[c]>=a.DV;)a[c]-=a.DV,a[++c]++}a.clamp(),a.drShiftTo(this.m.t,a),a.compareTo(this.m)>=0&&a.subTo(this.m,a)}function O(a,b){a.squareTo(b),this.reduce(b)}function P(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function Q(){return 0==(this.t>0?1&this[0]:this.s)}function R(a,b){if(a>4294967295||1>a)return c.ONE;var e=d(),f=d(),g=b.convert(this),h=s(a)-1;for(g.copyTo(e);--h>=0;)if(b.sqrTo(e,f),(a&1<0)b.mulTo(f,g,e);else{var i=e;e=f,f=i}return b.revert(e)}function S(a,b){var c;return c=256>a||b.isEven()?new D(b):new K(b),this.exp(a,c)}function T(){this.i=0,this.j=0,this.S=new Array}function U(a){var b,c,d;for(b=0;256>b;++b)this.S[b]=b;for(c=0,b=0;256>b;++b)c=c+this.S[b]+a[b%a.length]&255,d=this.S[b],this.S[b]=this.S[c],this.S[c]=d;this.i=0,this.j=0}function V(){var a;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,a=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=a,this.S[a+this.S[this.i]&255]}function W(){return new T}function X(a){qb[rb++]^=255&a,qb[rb++]^=a>>8&255,qb[rb++]^=a>>16&255,qb[rb++]^=a>>24&255,rb>=sb&&(rb-=sb)}function Y(){X((new Date).getTime())}function Z(){if(null==pb){for(Y(),pb=W(),pb.init(qb),rb=0;rba?"0"+a.toString(16):a.toString(16)}function cb(a,b){if(b=0&&b>0;){var f=a.charCodeAt(e--);128>f?d[--b]=f:f>127&&2048>f?(d[--b]=63&f|128,d[--b]=f>>6|192):(d[--b]=63&f|128,d[--b]=f>>6&63|128,d[--b]=f>>12|224)}d[--b]=0;for(var g=new _,h=new Array;b>2;){for(h[0]=0;0==h[0];)g.nextBytes(h);d[--b]=h[0]}return d[--b]=2,d[--b]=0,new c(d)}function db(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function eb(a,b){null!=a&&null!=b&&a.length>0&&b.length>0?(this.n=ab(a,16),this.e=parseInt(b,16)):alert("Invalid RSA public key")}function fb(a){return a.modPowInt(this.e,this.n)}function gb(a){var b=cb(a,this.n.bitLength()+7>>3);if(null==b)return null;var c=this.doPublic(b);if(null==c)return null;var d=c.toString(16);return 0==(1&d.length)?d:"0"+d}var hb,ib=0xdeadbeefcafe,jb=15715070==(16777215&ib);jb&&"Microsoft Internet Explorer"==navigator.appName?(c.prototype.am=f,hb=30):jb&&"Netscape"!=navigator.appName?(c.prototype.am=e,hb=26):(c.prototype.am=g,hb=28),c.prototype.DB=hb,c.prototype.DM=(1<=mb;++mb)ob[lb++]=mb;for(lb="a".charCodeAt(0),mb=10;36>mb;++mb)ob[lb++]=mb;for(lb="A".charCodeAt(0),mb=10;36>mb;++mb)ob[lb++]=mb;D.prototype.convert=E,D.prototype.revert=F,D.prototype.reduce=G,D.prototype.mulTo=H,D.prototype.sqrTo=I,K.prototype.convert=L,K.prototype.revert=M,K.prototype.reduce=N,K.prototype.mulTo=P,K.prototype.sqrTo=O,c.prototype.copyTo=j,c.prototype.fromInt=k,c.prototype.fromString=m,c.prototype.clamp=n,c.prototype.dlShiftTo=u,c.prototype.drShiftTo=v,c.prototype.lShiftTo=w,c.prototype.rShiftTo=x,c.prototype.subTo=y,c.prototype.multiplyTo=z,c.prototype.squareTo=A,c.prototype.divRemTo=B,c.prototype.invDigit=J,c.prototype.isEven=Q,c.prototype.exp=R,c.prototype.toString=o,c.prototype.negate=p,c.prototype.abs=q,c.prototype.compareTo=r,c.prototype.bitLength=t,c.prototype.mod=C,c.prototype.modPowInt=S,c.ZERO=l(0),c.ONE=l(1),T.prototype.init=U,T.prototype.next=V;var pb,qb,rb,sb=256;if(null==qb){qb=new Array,rb=0;var tb;if("Netscape"==navigator.appName&&navigator.appVersion<"5"&&window.crypto){var ub=window.crypto.random(32);for(tb=0;tbrb;)tb=Math.floor(65536*Math.random()),qb[rb++]=tb>>>8,qb[rb++]=255&tb;rb=0,Y()}_.prototype.nextBytes=$,db.prototype.doPublic=fb,db.prototype.setPublic=eb,db.prototype.encrypt=gb,b.exports={SecureRandom:_,byte2Hex:bb,RSAKey:db}},{}],5:[function(a,b){function c(a,b){return m.isUndefined(b)?""+b:!m.isNumber(b)||!isNaN(b)&&isFinite(b)?m.isFunction(b)||m.isRegExp(b)?b.toString():b:b.toString()}function d(a,b){return m.isString(a)?a.length=0;d--)if(e[d]!=f[d])return!1;for(d=e.length-1;d>=0;d--)if(c=e[d],!h(a[c],b[c]))return!1;return!0}function k(a,b){return a&&b?"[object RegExp]"==Object.prototype.toString.call(b)?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function l(a,b,c,d){var e;m.isString(c)&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f(e,c,"Missing expected exception"+d),!a&&k(e,c)&&f(e,c,"Got unwanted exception"+d),a&&e&&c&&!k(e,c)||!a&&e)throw e}var m=a("util/"),n=Array.prototype.slice,o=Object.prototype.hasOwnProperty,p=b.exports=g;p.AssertionError=function(a){this.name="AssertionError",this.actual=a.actual,this.expected=a.expected,this.operator=a.operator,a.message?(this.message=a.message,this.generatedMessage=!1):(this.message=e(this),this.generatedMessage=!0);var b=a.stackStartFunction||f;if(Error.captureStackTrace)Error.captureStackTrace(this,b);else{var c=new Error;if(c.stack){var d=c.stack,g=b.name,h=d.indexOf("\n"+g);if(h>=0){var i=d.indexOf("\n",h+1);d=d.substring(i+1)}this.stack=d}}},m.inherits(p.AssertionError,Error),p.fail=f,p.ok=g,p.equal=function(a,b,c){a!=b&&f(a,b,c,"==",p.equal)},p.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",p.notEqual)},p.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",p.deepEqual)},p.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",p.notDeepEqual)},p.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",p.strictEqual)},p.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",p.notStrictEqual)},p.throws=function(){l.apply(this,[!0].concat(n.call(arguments)))},p.doesNotThrow=function(){l.apply(this,[!1].concat(n.call(arguments)))},p.ifError=function(a){if(a)throw a};var q=Object.keys||function(a){var b=[];for(var c in a)o.call(a,c)&&b.push(c);return b}},{"util/":7}],6:[function(a,b){b.exports=function(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.readUInt8}},{}],7:[function(a,b,c){(function(b,d){function e(a,b){var d={seen:[],stylize:g};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),p(b)?d.showHidden=b:b&&c._extend(d,b),v(d.showHidden)&&(d.showHidden=!1),v(d.depth)&&(d.depth=2),v(d.colors)&&(d.colors=!1),v(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=f),i(d,a,d.depth)}function f(a,b){var c=e.styles[b];return c?"["+e.colors[c][0]+"m"+a+"["+e.colors[c][1]+"m":a}function g(a){return a}function h(a){var b={};return a.forEach(function(a){b[a]=!0}),b}function i(a,b,d){if(a.customInspect&&b&&A(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d,a);return t(e)||(e=i(a,e,d)),e}var f=j(a,b);if(f)return f;var g=Object.keys(b),p=h(g);if(a.showHidden&&(g=Object.getOwnPropertyNames(b)),z(b)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return k(b);if(0===g.length){if(A(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(w(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(y(b))return a.stylize(Date.prototype.toString.call(b),"date");if(z(b))return k(b)}var r="",s=!1,u=["{","}"];if(o(b)&&(s=!0,u=["[","]"]),A(b)){var v=b.name?": "+b.name:"";r=" [Function"+v+"]"}if(w(b)&&(r=" "+RegExp.prototype.toString.call(b)),y(b)&&(r=" "+Date.prototype.toUTCString.call(b)),z(b)&&(r=" "+k(b)),0===g.length&&(!s||0==b.length))return u[0]+r+u[1];if(0>d)return w(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var x;return x=s?l(a,b,d,p,g):g.map(function(c){return m(a,b,d,p,c,s)}),a.seen.pop(),n(x,r,u)}function j(a,b){if(v(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return s(b)?a.stylize(""+b,"number"):p(b)?a.stylize(""+b,"boolean"):q(b)?a.stylize("null","null"):void 0}function k(a){return"["+Error.prototype.toString.call(a)+"]"}function l(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)f.push(F(b,String(g))?m(a,b,c,d,String(g),!0):"");return e.forEach(function(e){e.match(/^\d+$/)||f.push(m(a,b,c,d,e,!0))}),f}function m(a,b,c,d,e,f){var g,h,j;if(j=Object.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?h=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(h=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),h||(a.seen.indexOf(j.value)<0?(h=q(c)?i(a,j.value,null):i(a,j.value,c-1),h.indexOf("\n")>-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),v(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function n(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function o(a){return Array.isArray(a)}function p(a){return"boolean"==typeof a}function q(a){return null===a}function r(a){return null==a}function s(a){return"number"==typeof a}function t(a){return"string"==typeof a}function u(a){return"symbol"==typeof a}function v(a){return void 0===a}function w(a){return x(a)&&"[object RegExp]"===C(a)}function x(a){return"object"==typeof a&&null!==a}function y(a){return x(a)&&"[object Date]"===C(a)}function z(a){return x(a)&&("[object Error]"===C(a)||a instanceof Error)}function A(a){return"function"==typeof a}function B(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),J[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=/%[sdj%]/g;c.format=function(a){if(!t(a)){for(var b=[],c=0;c=f)return a;switch(a){case"%s":return String(d[c++]);case"%d":return Number(d[c++]);case"%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),h=d[c];f>c;h=d[++c])g+=q(h)||!x(h)?" "+h:" "+e(h);return g},c.deprecate=function(a,e){function f(){if(!g){if(b.throwDeprecation)throw new Error(e);b.traceDeprecation?console.trace(e):console.error(e),g=!0}return a.apply(this,arguments)}if(v(d.process))return function(){return c.deprecate(a,e).apply(this,arguments)};if(b.noDeprecation===!0)return a;var g=!1;return f};var H,I={};c.debuglog=function(a){if(v(H)&&(H=b.env.NODE_DEBUG||""),a=a.toUpperCase(),!I[a])if(new RegExp("\\b"+a+"\\b","i").test(H)){var d=b.pid;I[a]=function(){var b=c.format.apply(c,arguments);console.error("%s %d: %s",a,d,b)}}else I[a]=function(){};return I[a]},c.inspect=e,e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=o,c.isBoolean=p,c.isNull=q,c.isNullOrUndefined=r,c.isNumber=s,c.isString=t,c.isSymbol=u,c.isUndefined=v,c.isRegExp=w,c.isObject=x,c.isDate=y,c.isError=z,c.isFunction=A,c.isPrimitive=B,c.isBuffer=a("./support/isBuffer");var J=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=a("inherits"),c._extend=function(a,b){if(!b||!x(b))return a;for(var c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}}).call(this,a("/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":6,"/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,inherits:10}],8:[function(a,b){(function(c){function d(){}function e(){m.log.apply(m,arguments)}function f(){m.log.apply(m,arguments)}function g(){m.warn.apply(m,arguments)}function h(a){p[a]=Date.now()}function i(a){var b=p[a];if(!b)throw new Error("No such label: "+a);var c=Date.now()-b;m.log(a+": "+c+"ms")}function j(){var a=new Error;a.name="Trace",a.message=n.format.apply(null,arguments),m.error(a.stack)}function k(a){m.log(n.inspect(a)+"\n")}function l(a){if(!a){var b=o.call(arguments,1);l.ok(!1,n.format.apply(null,b))}}var m,n=a("util"),l=a("assert"),o=Array.prototype.slice,p={};m="undefined"!=typeof c&&c.console?c.console:"undefined"!=typeof window&&window.console?window.console:{};for(var q=[[d,"log"],[e,"info"],[f,"warn"],[g,"error"],[h,"time"],[i,"timeEnd"],[j,"trace"],[k,"dir"],[l,"assert"]],r=0;ra||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,h,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||f(this._events.error)&&!this._events.error.length))throw b=arguments[1],b instanceof Error?b:TypeError('Uncaught, unspecified "error" event.');if(c=this._events[a],g(c))return!1;if(d(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];c.apply(this,h)}else if(f(c)){for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];for(j=c.slice(),e=j.length,i=0;e>i;i++)j[i].apply(this,h)}return!0},c.prototype.addListener=function(a,b){var e;if(!d(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d(b.listener)?b.listener:b),this._events[a]?f(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,f(this._events[a])&&!this._events[a].warned){var e;e=g(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace()) -}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),e||(e=!0,b.apply(this,arguments))}if(!d(b))throw TypeError("listener must be a function");var e=!1;return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,g,h;if(!d(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],g=c.length,e=-1,c===b||d(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(f(c)){for(h=g;h-->0;)if(c[h]===b||c[h].listener&&c[h].listener===b){e=h;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d(a._events[b])?1:a._events[b].length:0}},{}],10:[function(a,b){b.exports="function"==typeof Object.create?function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],11:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],12:[function(a,b){b.exports=a(6)},{}],13:[function(a,b){b.exports=a(7)},{"./support/isBuffer":12,"/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,inherits:10}],14:[function(a,b){!function(a){var c="undefined";!function(a,c){"undefined"!=typeof b?b.exports=c():"function"==typeof define&&"object"==typeof define.amd?define(c):this[a]=c()}("log",function(){function b(b){return typeof console===c?l:console[b]===a?console.log!==a?d(console,"log"):l:d(console,b)}function d(b,c){var d=b[c];if(d.bind!==a)return b[c].bind(b);if(Function.prototype.bind===a)return e(d,b);try{return Function.prototype.bind.call(b[c],b)}catch(f){return e(d,b)}}function e(a,b){return function(){Function.prototype.apply.apply(a,[b,arguments])}}function f(a){for(var b=0;b=0&&d<=k.levels.SILENT){if(i(d),d===k.levels.SILENT)return void f(function(){return l});if(typeof console===c)return f(function(a){return function(){typeof console!==c&&(k.setLevel(d),k[a].apply(k,arguments))}}),"No console available for logging";f(function(a){return d<=k.levels[a.toUpperCase()]?b(a):l})}else{if("string"!=typeof d||k.levels[d.toUpperCase()]===a)throw"log.setLevel() called with invalid level: "+d;k.setLevel(k.levels[d.toUpperCase()])}},k.enableAll=function(){k.setLevel(k.levels.TRACE)},k.disableAll=function(){k.setLevel(k.levels.SILENT)},j(),k})}()},{}],15:[function(a,b){var c=Object.prototype.toString;b.exports=function(a){switch(c.call(a)){case"[object Function]":return"function";case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object String]":return"string"}if("object"==typeof a&&a&&"number"==typeof a.length)try{if("function"==typeof a.callee)return"arguments"}catch(b){if(b instanceof TypeError)return"arguments"}return null===a?"null":void 0===a?"undefined":a&&1===a.nodeType?"element":a===Object(a)?"object":typeof a}},{}],16:[function(a,b){var c=a("./modules/constants"),d=a("./modules/logger"),e=a("./modules/ajax"),f=a("./modules/events"),g=a("./modules/waitForCloud"),h=a("./modules/api_act"),i=a("./modules/api_auth"),j=a("./modules/api_sec"),k=a("./modules/api_hash"),l=a("./modules/sync-cli"),m=a("./modules/api_mbaas"),n=a("./modules/api_cloud"),o=a("./modules/fhparams"),p=a("./modules/appProps"),q=a("./modules/device"),r=function(a,b){f.addListener(a,b),a===c.INIT_EVENT&&(g.isReady()?b(null,{host:g.getCloudHostUrl()}):g.getInitError()&&b(g.getInitError()))},s=function(a,b){a===c.INIT_EVENT&&g.isReady()?b(null,{host:g.getCloudHostUrl()}):a===c.INIT_EVENT&&g.getInitError()?b(g.getInitError()):f.once(a,b)},t=function(a,b,c){d.warn("$fh.init will be deprecated soon"),g.ready(function(a,d){if(a){if("function"==typeof c)return c(a)}else"function"==typeof b&&b(d.host)})},u=window.$fh||{};u.init=t,u.act=h,u.auth=i,u.cloud=n,u.sec=j,u.hash=k,u.sync=l,u.ajax=u.__ajax=e,u.mbaas=m,u._getDeviceId=q.getDeviceId,u.fh_timeout=6e4,u.getCloudURL=function(){return g.getCloudHostUrl()},u.getFHParams=function(){return o.buildFHParams()},u.addListener=r,u.on=r,u.once=s;for(var v=["removeListener","removeAllListeners","setMaxListeners","listeners","emit"],w=0;w=0&&(a=!0),a}function m(a){var b=null;return window.XMLHttpRequest&&(b=new XMLHttpRequest),l()&&a===!0&&"undefined"!=typeof window.XDomainRequest&&(b=new v(new XDomainRequest)),"undefined"!=typeof Titanium&&(b=Titanium.Network.createHTTPClient({timeout:I.settings.timeout})),b}function n(a){return a&&(a==G?"html":a==F?"json":D.test(a)?"script":E.test(a)&&"xml")||"text"}function o(a,b){return(a+"&"+b).replace(/[&?]{1,2}/,"?")}function p(a){"object"===t(a.data)&&("function"==typeof a.data.append?a.formdata=!0:a.data=r(a.data)),!a.data||a.type&&"GET"!=a.type.toUpperCase()||(a.url=o(a.url,a.data))}function q(a,b,c,d){var e="array"===t(b);for(var f in b){var g=b[f];d&&(f=c?d:d+"["+(e?"":f)+"]"),!d&&e?a.add(g.name,g.value):(c?"array"===t(g):"object"===t(g))?q(a,g,c,f):a.add(f,g)}}function r(a,b){var c=[];return c.add=function(a,b){this.push(J(a)+"="+J(b))},q(c,a,b),c.join("&").replace("%20","+")}function s(a){var b=Array.prototype.slice;return b.call(arguments,1).forEach(function(b){for(z in b)void 0!==b[z]&&(a[z]=b[z])}),a}var t,u=a("./events"),v=a("./XDomainRequestWrapper"),w=a("./logger");try{t=a("type-of")}catch(x){var y=a;t=y("type")}var z,A,B=0,C=window.document,D=/^(?:text|application)\/javascript/i,E=/^(?:text|application)\/xml/i,F="application/json",G="text/html",H=/^\s*$/,I=b.exports=function(a){var b=s({},a||{});window&&window.$fh&&"number"==typeof window.$fh.fh_timeout&&(I.settings.timeout=window.$fh.fh_timeout);for(z in I.settings)void 0===b[z]&&(b[z]=I.settings[z]);e(b),b.crossDomain||(b.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(b.url)&&(RegExp.$1!=window.location.protocol||RegExp.$2!=window.location.host));var c=b.dataType,d=/=\?/.test(b.url);if("jsonp"==c||d)return d||(b.url=o(b.url,(b.jsonp?b.jsonp:"_callback")+"=?")),I.JSONP(b);b.url||(b.url=window.location.toString()),p(b);var f,j=b.accepts[c],l={},m=/^([\w-]+:)\/\//.test(b.url)?RegExp.$1:window.location.protocol,q=b.xhr(b.crossDomain);b.crossDomain||(l["X-Requested-With"]="XMLHttpRequest"),j&&(l.Accept=j,j.indexOf(",")>-1&&(j=j.split(",",2)[0]),q.overrideMimeType&&q.overrideMimeType(j)),(b.contentType||b.data&&!b.formdata&&"GET"!=b.type.toUpperCase())&&(l["Content-Type"]=b.contentType||"application/x-www-form-urlencoded"),b.headers=s(l,b.headers||{}),"undefined"!=typeof Titanium&&q.setOnerror(function(){f&&(clearTimeout(f),i(null,"error",q,b))}),q.onreadystatechange=function(){if(4==q.readyState){clearTimeout(f),f=void 0;var a,d=!1;if(b.tryJSONP&&0===q.status&&b.crossDomain&&!q.isTimeout&&"file:"!=m)return w.debug("retry ajax call with jsonp"),b.type="GET",b.dataType="jsonp",b.data="_jsonpdata="+b.data,I(b);if(q.status>=200&&q.status<300||304==q.status||0==q.status&&"file:"==m){c=c||n(q.getResponseHeader("content-type")),a=q.responseText,w.debug("ajax response :: status = "+q.status+" :: body = "+a);try{"script"==c?(1,eval)(a):"xml"==c?a=q.responseXML:"json"==c&&(a=H.test(a)?null:JSON.parse(a))}catch(e){d=e}d?(w.debug("ajax error",d),i(d,"parsererror",q,b)):h(a,q,b)}else i(null,"error",q,b)}};var r="async"in b?b.async:!0;w.debug("ajax call settings",b),q.open(b.type,b.url,r);for(A in b.headers)q.setRequestHeader(A,b.headers[A]);return g(q,b)===!1?(w.debug("ajax call is aborted due to ajaxBeforeSend"),q.abort(),!1):(b.timeout>0&&(f=setTimeout(function(){w.debug("ajax call timed out"),q.onreadystatechange=k,q.abort(),q.isTimeout=!0,i(null,"timeout",q,b)},b.timeout)),q.send(b.data?b.data:null),q)};I.active=0,I.JSONP=function(a){if(!("type"in a))return I(a);var b,c="jsonp"+ ++B,d=C.createElement("script"),e=function(){c in window&&(window[c]=k),j("abort",f,a)},f={abort:e},g=C.getElementsByTagName("head")[0]||C.documentElement;return a.error&&(d.onerror=function(){f.abort(),a.error()}),window[c]=function(d){clearTimeout(b),b=void 0,delete window[c],h(d,f,a)},p(a),d.src=a.url.replace(/=\?/,"="+c),g.insertBefore(d,g.firstChild),a.timeout>0&&(b=setTimeout(function(){f.abort(),j("timeout",f,a)},a.timeout)),f},I.settings={type:"GET",beforeSend:k,success:k,error:k,complete:k,context:null,global:!0,xhr:m,accepts:{script:"text/javascript, application/javascript",json:F,xml:"application/xml, text/xml",html:G,text:"text/plain"},crossDomain:!1},I.get=function(a,b){return I({url:a,success:b})},I.post=function(a,b,c,d){return"function"===t(b)&&(d=d||c,c=b,b=null),I({type:"POST",url:a,data:b,success:c,dataType:d})},I.getJSON=function(a,b){return I({url:a,success:b,dataType:"json"})};var J=encodeURIComponent},{"./XDomainRequestWrapper":17,"./events":30,"./logger":37,"type-of":15}],19:[function(a,b){function c(a,b,c){var d=e.getCloudHost(),k=d.getActUrl(a.act),l=a.req||{};return l=f.addFHParams(l),g({url:k,tryJSONP:!0,type:"POST",dataType:"json",data:h.stringify(l),contentType:"application/json",timeout:a.timeout||j.timeout,success:b,error:function(a,b,d){return i(c,a,b,d)}})}var d=a("./logger"),e=a("./waitForCloud"),f=a("./fhparams"),g=a("./ajax"),h=a("JSON"),i=a("./handleError"),j=a("./appProps");b.exports=function(a,b,f){return d.debug("act is called"),f||(f=function(a,b){d.debug(a+":"+h.stringify(b))}),a.act?void e.ready(function(e){return d.debug("Calling fhact now"),e?f(e.message,e):void c(a,b,f)}):f("act_no_action",{})}},{"./ajax":18,"./appProps":25,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],20:[function(a,b){var c=a("./logger"),d=a("./waitForCloud"),e=a("./fhparams"),f=a("./ajax"),g=a("JSON"),h=a("./handleError"),i=a("./device"),j=a("./constants"),k=a("./checkAuth"),l=a("./appProps");b.exports=function(a,b,m){return m||(m=function(a,b){c.debug(a+":"+g.stringify(b))}),a.policyId?a.clientToken?void d.ready(function(c){if(c)return m(c.message,c);var d={};d.policyId=a.policyId,d.clientToken=a.clientToken,a.endRedirectUrl&&(d.endRedirectUrl=a.endRedirectUrl,a.authCallback&&(d.endRedirectUrl+=(/\?/.test(d.endRedirectUrl)?"&":"?")+"_fhAuthCallback="+a.authCallback)),d.params={},a.params&&(d.params=a.params);var n=a.endRedirectUrl||"status=complete";d.device=i.getDeviceId();var o=l.getAppProps(),p=o.host+j.boxprefix+"admin/authpolicy/auth";d=e.addFHParams(d),f({url:p,type:"POST",tryJSONP:!0,data:g.stringify(d),dataType:"json",contentType:"application/json",timeout:a.timeout||o.timeout,success:function(a){k.handleAuthResponse(n,a,b,m)},error:function(a,b,c){h(m,a,b,c)}})}):m("auth_no_clientToken",{}):m("auth_no_policyId",{})}},{"./ajax":18,"./appProps":25,"./checkAuth":26,"./constants":27,"./device":29,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],21:[function(a,b){function c(a,b,c){var d=e.getCloudHost(),k=d.getCloudUrl(a.path),l=a.data||{};return l=f.addFHParams(l),g({url:k,type:a.method||"POST",dataType:a.dataType||"json",data:h.stringify(l),contentType:a.contentType||"application/json",timeout:a.timeout||j.timeout,success:b,error:function(a,b,d){return i(c,a,b,d)}})}var d=a("./logger"),e=a("./waitForCloud"),f=a("./fhparams"),g=a("./ajax"),h=a("JSON"),i=a("./handleError"),j=a("./appProps");b.exports=function(a,b,f){d.debug("cloud is called"),f||(f=function(a,b){d.debug(a+":"+h.stringify(b))}),e.ready(function(e){return d.debug("Calling fhact now"),e?f(e.message,e):void c(a,b,f)})}},{"./ajax":18,"./appProps":25,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],22:[function(a,b){var c=a("./security/hash");b.exports=function(a,b,d){var e={};"undefined"==typeof a.algorithm&&(a.algorithm="MD5"),e.act="hash",e.params=a,c(e,b,d)}},{"./security/hash":43}],23:[function(a,b){var c=a("./logger"),d=a("./waitForCloud"),e=a("./fhparams"),f=a("./ajax"),g=a("JSON"),h=a("./handleError"),i=(a("./constants"),a("./appProps"));b.exports=function(a,b,j){c.debug("mbaas is called."),j||(j=function(a,b){console.debug(a+":"+g.stringify(b))});var k=a.service,l=a.params;d.ready(function(m){if(c.debug("Calling mbaas now"),m)return j(m.message,m);var n=d.getCloudHost(),o=n.getMBAASUrl(k);return l=e.addFHParams(l),f({url:o,tryJSONP:!0,type:"POST",dataType:"json",data:g.stringify(l),contentType:"application/json",timeout:a.timeout||i.timeout,success:b,error:function(a,b,c){return h(j,a,b,c)}})})}},{"./ajax":18,"./appProps":25,"./constants":27,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],24:[function(a,b){var c=a("./security/aes-keygen"),d=a("./security/aes-node"),e=a("./security/rsa-node"),f=a("./security/hash");b.exports=function(a,b,g){return a.act?a.params?a.params.algorithm?(a.params.algorithm=a.params.algorithm.toLowerCase(),"hash"===a.act?f(a,b,g):"encrypt"===a.act?"aes"===a.params.algorithm?d.encrypt(a,b,g):"rsa"===a.params.algorithm?e.encrypt(a,b,g):g("encrypt_bad_algorithm:"+a.params.algorithm,{},a):"decrypt"===a.act?"aes"===a.params.algorithm?d.decrypt(a,b,g):g("decrypt_bad_algorithm:"+a.params.algorithm,{},a):"keygen"===a.act?"aes"===a.params.algorithm?c(a,b,g):g("keygen_bad_algorithm:"+a.params.algorithm,{},a):void 0):void g("no_params_algorithm",{},a):void g("no_params",{},a):void g("bad_act",{},a)}},{"./security/aes-keygen":41,"./security/aes-node":42,"./security/hash":43,"./security/rsa-node":44}],25:[function(a,b){var c=a("./constants"),d=a("./ajax"),e=a("./logger"),f=a("./queryMap"),g=null,h=function(a){var b=document.location.href,h=f(b),i="undefined"!=typeof h.url;if(i)return g={},g.local=!0,g.host=h.url.replace(/#.*?$/g,""),g.appid="000000000000000000000000",g.appkey="0000000000000000000000000000000000000000",g.projectid="000000000000000000000000",g.connectiontag="0.0.1",g.loglevel=h.loglevel,a(null,g);var j=h.fhconfig||c.config_js;d({url:j,dataType:"json",success:function(b){return e.debug("fhconfig = "+JSON.stringify(b)),null==b?window.fh_app_props?(g=window.fh_app_props,a(null,window.fh_app_props)):a(new Error("app_config_missing")):(g=b,void a(null,g))},error:function(){return window.fh_app_props?(g=window.fh_app_props,a(null,window.fh_app_props)):(e.error(c.config_js+" Not Found"),void a(new Error("app_config_missing")))}})},i=function(a){g=a},j=function(){return g};b.exports={load:h,getAppProps:j,setAppProps:i}},{"./ajax":18,"./constants":27,"./logger":37,"./queryMap":39}],26:[function(a,b){var c=a("./logger"),d=a("./queryMap"),e=a("JSON"),f=a("./fhparams"),g=function(a){if(/\_fhAuthCallback/.test(a)){var b=d(a);if(b){var c=b._fhAuthCallback;if(c)if(b.result&&"success"===b.result){var g={sessionToken:b.fh_auth_session,authResponse:e.parse(decodeURIComponent(decodeURIComponent(b.authResponse)))};f.setAuthSessionToken(b.fh_auth_session),window[c](null,g)}else window[c]({message:b.message})}}},h=function(a,b,g,h){if(b.status&&"ok"===b.status){var i=function(a){a.sessionToken&&f.setAuthSessionToken(a.sessionToken),g(a)};if(b.url){var j=null,k=function(b){if(b.indexOf(a)>-1){j&&j.close();var c=d(b);if(c)if(c.result&&"success"===c.result){var f={sessionToken:c.fh_auth_session,authResponse:e.parse(decodeURIComponent(decodeURIComponent(c.authResponse)))};i(f)}else h&&h("auth_failed",{message:c.message});else h&&h("auth_failed",{message:c.message})}};if(window.PhoneGap||window.cordova)if(window.plugins&&window.plugins.childBrowser)"function"==typeof window.plugins.childBrowser.showWebPage&&(window.plugins.childBrowser.onLocationChange=k,window.plugins.childBrowser.showWebPage(b.url),j=window.plugins.childBrowser);else try{j=window.open(b.url,"_blank","location=yes"),j.addEventListener("loadstart",function(a){k(a.url)})}catch(l){c.info("InAppBrowser plugin is not intalled."),i(b)}else document.location.href=b.url}else i(b)}else h&&h("auth_failed",b)};window.addEventListener?window.addEventListener("load",function(){g(window.location.href)},!1):window.attachEvent&&window.attachEvent("onload",function(){g(window.location.href)}),b.exports={handleAuthResponse:h}},{"./fhparams":31,"./logger":37,"./queryMap":39,JSON:3}],27:[function(a,b){b.exports={boxprefix:"/box/srv/1.1/",sdk_version:"2.0.17-alpha",config_js:"fhconfig.json",INIT_EVENT:"fhinit"}},{}],28:[function(a,b){b.exports={readCookieValue:function(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d1?b=f[1]:"undefined"!=typeof window.fh_destination_code?b=window.fh_destination_code:c.forEach(function(a){a.test.forEach(function(c){d.indexOf(c)>-1&&(b=a.destination)})}),null==b&&(b="web"),e.debug("destination = "+b),b}}},{"./cookies":28,"./logger":37,"./platformsMap":38,"./uuid":46}],30:[function(a,b){var c=a("events").EventEmitter,d=new c;d.setMaxListeners(0),b.exports=d},{events:9}],31:[function(a,b){var c=a("./device"),d=a("./sdkversion"),e=a("./appProps"),f=a("./logger"),g=null,h=null,i=function(){if(g)return g;var a={};a.cuid=c.getDeviceId(),a.cuidMap=c.getCuidMap(),a.destination=c.getDestination(),(window.device||navigator.device)&&(a.device=window.device||navigator.device),"undefined"!=typeof window.fh_app_version&&(a.app_version=fh_app_version),"undefined"!=typeof window.fh_project_version&&(a.project_version=fh_project_version),"undefined"!=typeof window.fh_project_app_version&&(a.project_app_version=fh_project_app_version),a.sdk_version=d(),h&&(a.sessionToken=h);var b=e.getAppProps();return b&&(a.appid=b.appid,a.appkey=b.appkey,a.projectid=b.projectid,a.analyticsTag=b.analyticsTag,a.connectiontag=b.connectiontag,b.init&&(a.init="string"==typeof b.init?JSON.parse(b.init):b.init)),g=a,f.debug("fhparams = ",g),a},j=function(a){var a=a||{};return a.__fh=i(),a},k=function(a){h=a};b.exports={buildFHParams:i,addFHParams:j,setAuthSessionToken:k}},{"./appProps":25,"./device":29,"./logger":37,"./sdkversion":40}],32:[function(a,b){var c=a("JSON");b.exports=function(a,b,d,e){var f,g=0;if(b)try{g=b.status;var h=c.parse(b.responseText);f=h.error||h.msg,f instanceof Array&&(f=f.join("\n"))}catch(i){f=b.responseText}a&&a(f,{status:g,message:d,error:e})}},{JSON:3}],33:[function(a,b){function c(a){var b=a;return"/"===b.charAt(b.length-1)&&(b=b.substring(0,b.length-1)),b}function d(a){var b=a;return b.length>1&&"/"===b.charAt(0)&&(b=b.substring(1,b.length)),b}function e(a){this.cloud_props=a,this.cloud_host=void 0,this.isLegacy=!1}var f=a("./constants"),g=a("./appProps");e.prototype.getHost=function(a){if(this.cloud_host)return this.cloud_host;var b,d;if(this.cloud_props&&this.cloud_props.hosts&&(b=this.cloud_props.hosts.url,"undefined"==typeof b)){var e=this.cloud_props.hosts.releaseCloudUrl;d=this.cloud_props.hosts.releaseCloudType,"undefined"!=typeof a&&a.indexOf("dev")>-1&&(e=this.cloud_props.hosts.debugCloudUrl,d=this.cloud_props.hosts.debugCloudType),b=e}return b=c(b),this.cloud_host=b,"fh"===d&&(this.isLegacy=!0),b},e.prototype.getActUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.isLegacy?this.cloud_host+f.boxprefix+"act/"+this.cloud_props.domain+"/"+b.appid+"/"+a+"/"+b.appid:this.cloud_host+"/cloud/"+a},e.prototype.getMBAASUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.cloud_host+"/mbaas/"+a},e.prototype.getCloudUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.cloud_host+"/"+d(a)},b.exports=e},{"./appProps":25,"./constants":27}],34:[function(a,b){var c=(a("./loadScript"),a("../../libs/generated/lawnchair")),d=a("./lawnchair-ext"),e=a("./constants"),f=a("./fhparams"),g=a("./ajax"),h=a("./handleError"),i=a("./logger"),j=a("JSON"),k=a("./security/hash"),l=a("./appProps"),m=function(a){l.load(function(b,c){return b?a(b):n(c,a)})},n=function(a,b){if(a.loglevel&&i.setLevel(a.loglevel),a.local){var l={domain:"local",firstTime:!1,hosts:{debugCloudType:"node",debugCloudUrl:a.host,releaseCloudType:"node",releaseCloudUrl:a.host,type:"cloud_nodejs",url:a.host},init:{trackId:"000000000000000000000000"},status:"ok"};return b(null,{cloud:l})}d.addAdapter(a,k);var m={name:"fh_init_storage",adapter:["dom","webkit-sqlite","window-name"],fail:function(a,b){var c="read/save from/to local storage failed msg:"+a+" err:"+b;return fail(c,{})}};"undefined"!=typeof Titanium&&(m.adapter=["titanium"]);var n=function(a,c,d,e){var k=f.buildFHParams();g({url:a,type:"POST",tryJSONP:!0,dataType:"json",contentType:"application/json",data:j.stringify(k),timeout:c.timeout,success:function(a){e&&e.save({key:"fh_init",value:a},function(){}),b&&b(null,{cloud:a})},error:function(a,c,e){var f="unknown";a&&(f=a.status+" - "+a.responseText),i.error("App init returned error : "+f),d?(i.info("Using cached host: "+j.stringify(d)),b&&b(null,{cloud:d})):(i.error("No cached host found. Init failed."),h(function(a,c){b&&b({error:c,message:a})},a,c,e))}})},o=null,p=a.host+e.boxprefix+"app/init";try{o=new c(m,function(){}),o.get("fh_init",function(b){var c=null;b&&null!==b.value&&"undefined"!=typeof b.value&&""!==b&&(b="string"==typeof b?j.parse(b):b,b.value="string"==typeof b.value?j.parse(b.value):b.value,a.init=b.value.init?b.value.init:"string"==typeof b.value?j.parse(b.value):b.value,b.value.hosts&&(c=b.value)),n(p,a,c,o)})}catch(q){n(p,a,null,null)}};b.exports={init:m,loadCloudProps:n}},{"../../libs/generated/lawnchair":2,"./ajax":18,"./appProps":25,"./constants":27,"./fhparams":31,"./handleError":32,"./lawnchair-ext":35,"./loadScript":36,"./logger":37,"./security/hash":43,JSON:3}],35:[function(a,b){var c=a("../../libs/generated/lawnchair"),d=function(a,b){function c(a){console&&console.log(a)}function d(d,e){d=a.appid+d,b({algorithm:"MD5",text:d},function(a){var b=a.hashvalue+".txt";return"undefined"==typeof navigator.externalstorage?(c("filenameForKey key="+d+" , Filename: "+b),e(b)):void navigator.externalstorage.enable(function(a){var c=b;return a.path&&(c=a.path,c.match(/\/$/)||(c+="/"),c+=b),b=c,e(b)},function(){return e(b)})})}var e=function(a,b){if(!console)throw a;console.log("error in file system adapter !",a,b)};return{valid:function(){return!!window.requestFileSystem},init:function(a,b){a&&"function"==typeof a.fail&&(e=a.fail),b&&this.fn(this.name,b).call(this,this)},keys:function(){throw"Currently not supported"},save:function(a,b){var c=a.key,f=a.val||a.value;d(c,function(a){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(a,{create:!0},function(a){a.createWriter(function(a){a.onwrite=function(){return b({key:c,val:f})},a.write(f)},function(){e("[save] Failed to create file writer")})},function(){e("[save] Failed to getFile")})},function(){e("[save] Failed to requestFileSystem")})})},batch:function(){throw"Currently not supported"},get:function(a,b){d(a,function(c){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(c,{},function(c){c.file(function(c){var d=new FileReader;d.onloadend=function(c){var d=c.target.result;try{d=decodeURIComponent(d)}catch(e){}return b({key:a,val:d})},d.readAsText(c)},function(){e("[load] Failed to getFile")})},function(){b({key:a,val:null})})},function(){e("[load] Failed to get fileSystem")})})},exists:function(a,b){d(a,function(a){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(c){c.root.getFile(a,{},function(){return b(!0)},function(){return b(!1)})})})},all:function(){throw"Currently not supported"},remove:function(a,b){d(a,function(c){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(c,{},function(c){c.remove(function(){return b({key:a,val:null})},function(){e("[remove] Failed to remove file")})},function(){e("[remove] Failed to getFile")})},function(){e("[remove] Failed to get fileSystem")})})},nuke:function(){throw"Currently not supported"}}},e=function(a,b){c.adapter("localFileStorage",d(a,b))};b.exports={addAdapter:e}},{"../../libs/generated/lawnchair":2}],36:[function(a,b){b.exports=function(a,b){var c,d=document.head||document.getElementsByTagName("head")[0]||document.documentElement;c=document.createElement("script"),c.async="async",c.src=a,c.type="text/javascript",c.onload=c.onreadystatechange=function(){(!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,d&&c.parentNode&&d.removeChild(c),c=void 0,b&&"function"==typeof b&&b())},d.insertBefore(c,d.firstChild)}},{}],37:[function(a,b){var c=(a("console"),a("loglevel"));c.setLevel("info"),b.exports=c},{console:8,loglevel:14}],38:[function(a,b){b.exports=[{destination:"ipad",test:["iPad"]},{destination:"iphone",test:["iPhone"]},{destination:"android",test:["Android"]},{destination:"blackberry",test:["BlackBerry","BB10","RIM Tablet OS"]},{destination:"windowsphone",test:["Windows Phone 8"]},{destination:"windowsphone7",test:["Windows Phone OS 7"]}]},{}],39:[function(a,b){b.exports=function(a){var b={},c=a.split("?");if(2===c.length){var d=c[1],e=d.split("&");b={};for(var f=0;f100&&(e/=8),"undefined"==typeof d?c("security library is not loaded."):b({algorithm:"AES",secretkey:f(e),iv:f(e)})};b.exports=g},{"../../../libs/rsa":4}],42:[function(a,b){var c=a("../../../libs/generated/crypto"),d=function(a,b,d){var e=["key","plaintext","iv"];if("aes"!==a.params.algorithm.toLowerCase())return d("encrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return d("no_params_"+g,{},a)}var h=c.AES.encrypt(a.params.plaintext,c.enc.Hex.parse(a.params.key),{iv:c.enc.Hex.parse(a.params.iv)});return cipher_text=c.enc.Hex.stringify(h.ciphertext),b({ciphertext:cipher_text})},e=function(a,b,d){var e=["key","ciphertext","iv"]; -if("aes"!==a.params.algorithm.toLowerCase())return d("decrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return d("no_params_"+g,{},a)}var h=c.enc.Hex.parse(a.params.ciphertext),i=c.enc.Base64.stringify(h),j=c.AES.decrypt(i,c.enc.Hex.parse(a.params.key),{iv:c.enc.Hex.parse(a.params.iv)});return plain_text=j.toString(c.enc.Utf8),b({plaintext:plain_text})};b.exports={encrypt:d,decrypt:e}},{"../../../libs/generated/crypto":1}],43:[function(a,b){var c=a("../../../libs/generated/crypto"),d=function(a,b,d){if(!a.params.text)return void d("hash_no_text",{},a);var e;if("md5"===a.params.algorithm.toLowerCase())e=c.MD5(a.params.text).toString(c.enc.Hex);else if("sha1"===a.params.algorithm.toLowerCase())e=c.SHA1(a.params.text).toString(c.enc.Hex);else if("sha256"===a.params.algorithm.toLowerCase())e=c.SHA256(a.params.text).toString(c.enc.Hex);else{if("sha512"!==a.params.algorithm.toLowerCase())return d("hash_unsupported_algorithm: "+a.params.algorithm);e=c.SHA512(a.params.text).toString(c.enc.Hex)}return b({hashvalue:e})};b.exports=d},{"../../../libs/generated/crypto":1}],44:[function(a,b){var c=a("../../../libs/rsa"),d=c.RSAKey,e=function(a,b,c){var e=["modulu","plaintext"];if("rsa"!==a.params.algorithm.toLowerCase())return c("encrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return c("no_params_"+g,{},a)}var h=new d;h.setPublic(a.params.modulu,"10001");var i=a.params.plaintext;return cipher_text=h.encrypt(i),b({ciphertext:cipher_text})};b.exports={encrypt:e}},{"../../../libs/rsa":4}],45:[function(a,b){var c=a("JSON"),d=a("./api_act"),e=a("./api_cloud"),f=a("../../libs/generated/crypto"),g=a("../../libs/generated/lawnchair"),h={defaults:{sync_frequency:10,auto_sync_local_updates:!0,notify_client_storage_failed:!0,notify_sync_started:!0,notify_sync_complete:!0,notify_offline_update:!0,notify_collision_detected:!0,notify_remote_update_failed:!0,notify_local_update_applied:!0,notify_remote_update_applied:!0,notify_delta_received:!0,notify_record_delta_received:!0,notify_sync_failed:!0,do_console_log:!1,crashed_count_wait:10,resend_crashed_updates:!0,sync_active:!0,storage_strategy:"html5-filesystem",file_system_quota:61644800,has_custom_sync:null},notifications:{CLIENT_STORAGE_FAILED:"client_storage_failed",SYNC_STARTED:"sync_started",SYNC_COMPLETE:"sync_complete",OFFLINE_UPDATE:"offline_update",COLLISION_DETECTED:"collision_detected",REMOTE_UPDATE_FAILED:"remote_update_failed",REMOTE_UPDATE_APPLIED:"remote_update_applied",LOCAL_UPDATE_APPLIED:"local_update_applied",DELTA_RECEIVED:"delta_received",RECORD_DELTA_RECEIVED:"record_delta_received",SYNC_FAILED:"sync_failed"},datasets:{},config:void 0,notify_callback:void 0,init_is_called:!1,init:function(a){h.consoleLog("sync - init called"),h.config=c.parse(c.stringify(h.defaults));for(var b in a)h.config[b]=a[b];h.init_is_called||(h.init_is_called=!0,h.datasetMonitor())},notify:function(a){h.notify_callback=a},manage:function(a,b,d,e,f){h.consoleLog("manage - START");var b=b||{},g=function(g){h.consoleLog("doManage dataset :: initialised = "+g.initialised+" :: "+a+" :: "+c.stringify(b));var i=h.setOptions(b);g.query_params=d||g.query_params||{},g.meta_data=e||g.meta_data||{},g.config=i,g.syncRunning=!1,g.syncPending=!0,g.initialised=!0,"undefined"==typeof g.meta&&(g.meta={}),h.saveDataSet(a,function(){f&&f()})};h.getDataSet(a,function(a){h.consoleLog("manage - dataset already loaded"),g(a)},function(){h.consoleLog("manage - dataset not loaded... trying to load"),h.loadDataSet(a,function(b){h.consoleLog("manage - dataset loaded from local storage"),h.doNotify(a,null,h.notifications.LOCAL_UPDATE_APPLIED,"load"),g(b)},function(){h.consoleLog("manage - Creating new dataset for id "+a);var b={};b.data={},b.pending={},b.meta={},h.datasets[a]=b,g(b)})})},setOptions:function(a){h.config||(h.config=c.parse(c.stringify(h.defaults)));var b=c.parse(c.stringify(h.config)),d=c.parse(c.stringify(a));for(var e in d)b[e]=d[e];return b},list:function(a,b,d){h.getDataSet(a,function(a){if(a&&a.data){var e=c.parse(c.stringify(a.data));b(e)}else d&&d("no_data")},function(a,b){d&&d(a,b)})},create:function(a,b,c,d){return null==b&&d?d("null_data"):void h.addPendingObj(a,null,b,"create",c,d)},read:function(a,b,d,e){h.getDataSet(a,function(a){var f=a.data[b];if(f){var g=c.parse(c.stringify(f));d(g)}else e("unknown_uid")},function(a,b){e&&e(a,b)})},update:function(a,b,c,d,e){h.addPendingObj(a,b,c,"update",d,e)},"delete":function(a,b,c,d){h.addPendingObj(a,b,null,"delete",c,d)},getPending:function(a,b){h.getDataSet(a,function(a){var c;a&&(c=a.pending),b(c)},function(a){h.consoleLog(a)})},clearPending:function(a,b){h.getDataSet(a,function(c){c.pending={},h.saveDataSet(a,b)})},listCollisions:function(a,b,c){h.getDataSet(a,function(d){h.doCloudCall({dataset_id:a,req:{fn:"listCollisions",meta_data:d.meta_data}},b,c)},c)},removeCollision:function(a,b,c,d){h.getDataSet(a,function(e){h.doCloudCall({dataset_id:a,req:{fn:"removeCollision",hash:b,meta_data:e.meta_data}},c,d)})},isOnline:function(a){var b=!0;if("undefined"!=typeof navigator.onLine&&(b=navigator.onLine),b&&"undefined"!=typeof navigator.network&&"undefined"!=typeof navigator.network.connection){var c=navigator.network.connection.type;("none"===c||null===c)&&(b=!1)}return a(b)},doNotify:function(a,b,c,d){if(h.notify_callback&&h.config["notify_"+c]){var e={dataset_id:a,uid:b,code:c,message:d};setTimeout(function(){h.notify_callback(e)},0)}},getDataSet:function(a,b,c){var d=h.datasets[a];d?b(d):c&&c("unknown_dataset "+a,a)},getQueryParams:function(a,b,c){var d=h.datasets[a];d?b(d.query_params):c&&c("unknown_dataset "+a,a)},setQueryParams:function(a,b,c,d){var e=h.datasets[a];e?(e.query_params=b,h.saveDataSet(a),c&&c(e.query_params)):d&&d("unknown_dataset "+a,a)},getMetaData:function(a,b,c){var d=h.datasets[a];d?b(d.meta_data):c&&c("unknown_dataset "+a,a)},setMetaData:function(a,b,c,d){var e=h.datasets[a];e?(e.meta_data=b,h.saveDataSet(a),c&&c(e.meta_data)):d&&d("unknown_dataset "+a,a)},getConfig:function(a,b,c){var d=h.datasets[a];d?b(d.config):c&&c("unknown_dataset "+a,a)},setConfig:function(a,b,c,d){var e=h.datasets[a];if(e){var f=h.setOptions(b);e.config=f,h.saveDataSet(a),c&&c(e.config)}else d&&d("unknown_dataset "+a,a)},stopSync:function(a,b,c){h.setConfig(a,{sync_active:!1},function(){b&&b()},c)},startSync:function(a,b,c){h.setConfig(a,{sync_active:!0},function(){b&&b()},c)},doSync:function(a,b,c){var d=h.datasets[a];d?(d.syncPending=!0,h.saveDataSet(a),b&&b()):c&&c("unknown_dataset "+a,a)},forceSync:function(a,b,c){var d=h.datasets[a];d?(d.syncForced=!0,h.saveDataSet(a),b&&b()):c&&c("unknown_dataset "+a,a)},sortObject:function(a){if("object"!=typeof a||null===a)return a;var b=[];return Object.keys(a).sort().forEach(function(c){b.push({key:c,value:h.sortObject(a[c])})}),b},sortedStringify:function(a){var b="";try{b=c.stringify(h.sortObject(a))}catch(d){console.error("Error stringifying sorted object:"+d)}return b},generateHash:function(a){var b=f.SHA1(h.sortedStringify(a));return b.toString()},addPendingObj:function(a,b,d,e,f,g){function i(c){c.hash=h.generateHash(c),h.getDataSet(a,function(d){d.pending[c.hash]=c,h.updateDatasetFromLocal(d,c),h.config.auto_sync_local_updates&&(d.syncPending=!0),h.saveDataSet(a),h.doNotify(a,b,h.notifications.LOCAL_UPDATE_APPLIED,e),f(c)},function(a,b){g&&g(a,b)})}h.isOnline(function(c){c||h.doNotify(a,b,h.notifications.OFFLINE_UPDATE,e)});var j={};j.inFlight=!1,j.action=e,j.post=c.parse(c.stringify(d)),j.postHash=h.generateHash(j.post),j.timestamp=(new Date).getTime(),"create"===e?(j.uid=j.postHash,i(j)):h.read(a,b,function(a){j.uid=b,j.pre=a.data,j.preHash=h.generateHash(a.data),i(j)},function(a,b){g&&g(a,b)})},syncLoop:function(a){h.getDataSet(a,function(b){b.syncPending=!1,b.syncRunning=!0,b.syncLoopStart=(new Date).getTime(),h.doNotify(a,null,h.notifications.SYNC_STARTED,null),h.isOnline(function(d){d?h.checkHasCustomSync(a,function(){var d={};d.fn="sync",d.dataset_id=a,d.query_params=b.query_params,d.config=b.config,d.meta_data=b.meta_data,d.dataset_hash=b.hash,d.acknowledgements=b.acknowledgements||[];var e=b.pending,f=[];for(var g in e)e[g].inFlight||e[g].crashed||e[g].delayed||(e[g].inFlight=!0,e[g].inFlightDate=(new Date).getTime(),f.push(e[g]));d.pending=f,f.length>0&&h.consoleLog("Starting sync loop - global hash = "+b.hash+" :: params = "+c.stringify(d,null,2));try{h.doCloudCall({dataset_id:a,req:d},function(c){function d(c,d,f){if(c)for(var g in c)e=c[g],f.push(e),b.pending[g]&&b.pending[g].inFlight&&!b.pending[g].crashed&&(delete b.pending[g],h.doNotify(a,e.uid,d,e))}var e;if(h.updatePendingFromNewData(a,b,c),h.updateCrashedInFlightFromNewData(a,b,c),h.updateDelayedFromNewData(a,b,c),h.updateMetaFromNewData(a,b,c),h.updateNewDataFromInFlight(a,b,c),h.updateNewDataFromPending(a,b,c),c.records&&(b.data=c.records,b.hash=c.hash,h.doNotify(a,c.hash,h.notifications.DELTA_RECEIVED,"full dataset")),c.updates){var f=[];d(c.updates.applied,h.notifications.REMOTE_UPDATE_APPLIED,f),d(c.updates.failed,h.notifications.REMOTE_UPDATE_FAILED,f),d(c.updates.collisions,h.notifications.COLLISION_DETECTED,f),b.acknowledgements=f}!c.records&&c.hash&&c.hash!==b.hash?(h.consoleLog("Local dataset stale - syncing records :: local hash= "+b.hash+" - remoteHash="+c.hash),h.syncRecords(a)):(h.consoleLog("Local dataset up to date"),h.syncComplete(a,"online",h.notifications.SYNC_COMPLETE))},function(c,d){h.markInFlightAsCrashed(b),h.consoleLog("syncLoop failed : msg="+c+" :: err = "+d),h.syncComplete(a,c,h.notifications.SYNC_FAILED)})}catch(i){h.consoleLog("Error performing sync - "+i),h.syncComplete(a,i,h.notifications.SYNC_FAILED)}}):h.syncComplete(a,"offline",h.notifications.SYNC_FAILED)})})},syncRecords:function(a){h.getDataSet(a,function(b){var d=b.data||{},e={};for(var f in d){var g=f,i=d[f].hash;e[g]=i}var j={};j.fn="syncRecords",j.dataset_id=a,j.query_params=b.query_params,j.clientRecs=e,h.consoleLog("syncRecParams :: "+c.stringify(j)),h.doCloudCall({dataset_id:a,req:j},function(c){var e;if(c.create)for(e in c.create)d[e]={hash:c.create[e].hash,data:c.create[e].data},h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"create");if(c.update)for(e in c.update)d[e].hash=c.update[e].hash,d[e].data=c.update[e].data,h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"update");if(c["delete"])for(e in c["delete"])delete d[e],h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"delete");h.doNotify(a,c.hash,h.notifications.DELTA_RECEIVED,"partial dataset"),b.data=d,c.hash&&(b.hash=c.hash),h.syncComplete(a,"online",h.notifications.SYNC_COMPLETE)},function(b,c){h.consoleLog("syncRecords failed : msg="+b+" :: err="+c),h.syncComplete(a,b,h.notifications.SYNC_FAILED)})})},syncComplete:function(a,b,c){h.getDataSet(a,function(d){d.syncRunning=!1,d.syncLoopEnd=(new Date).getTime(),h.saveDataSet(a),h.doNotify(a,d.hash,c,b)})},checkDatasets:function(){for(var a in h.datasets)if(h.datasets.hasOwnProperty(a)){var b=h.datasets[a];if(!b.syncRunning&&(b.config.sync_active||b.syncForced)){var c=b.syncLoopStart,d=b.syncLoopEnd;if(b.syncForced)b.syncPending=!0;else if(null==c)h.consoleLog(a+" - Performing initial sync"),b.syncPending=!0;else if(null!=d){var e=(new Date).getTime()-d,f=1e3*b.config.sync_frequency;e>f&&(b.syncPending=!0)}b.syncPending&&(b.syncForced=!1,h.syncLoop(a))}}},checkHasCustomSync:function(a,b){var c=h.datasets[a];return c&&c.config?(h.consoleLog("dataset.config.has_custom_sync = "+c.config.has_custom_sync),null!=c.config.has_custom_sync?b():(h.consoleLog("starting check has custom sync"),void d({act:a,req:{fn:"sync"}},function(a){return h.consoleLog("check has_custom_sync - success - ",a),c.config.has_custom_sync=!0,b()},function(a,d){return h.consoleLog("check has_custom_sync - failure - ",d),d.status&&500===d.status?(h.consoleLog("check has_custom_sync - failed with 500, endpoint does exists"),c.config.has_custom_sync=!0):c.config.has_custom_sync=!1,b()}))):b()},doCloudCall:function(a,b,c){var f=!1,g=h.datasets[a.dataset_id];g&&g.config&&(f=g.config.has_custom_sync),1==f?d({act:a.dataset_id,req:a.req},function(a){b(a)},function(a,b){c(a,b)}):e({path:"/mbaas/sync/"+a.dataset_id,method:"post",data:a.req},function(a){b(a)},function(a,b){c(a,b)})},datasetMonitor:function(){h.checkDatasets(),setTimeout(function(){h.datasetMonitor()},500)},saveDataSet:function(a,b){var c=function(b,c){var d="save to local storage failed msg:"+b+" err:"+c;h.doNotify(a,null,h.notifications.CLIENT_STORAGE_FAILED,d),h.consoleLog(d)};h.getDataSet(a,function(d){g({fail:c,adapter:h.config.storage_strategy,size:h.config.file_system_quota},function(){this.save({key:"dataset_"+a,val:d},function(){return b?b():void 0})})})},loadDataSet:function(a,b,d){var e=function(b){var c="load from local storage failed msg:"+b;h.doNotify(a,null,h.notifications.CLIENT_STORAGE_FAILED,c),h.consoleLog(c)};g({fail:e,adapter:h.config.storage_strategy,size:h.config.file_system_quota},function(){this.get("dataset_"+a,function(e){if(e&&e.val){var f=e.val;if("string"==typeof f&&(f=c.parse(f)),f.initialised=!1,h.datasets[a]=f,h.consoleLog("load from local storage success for dataset_id :"+a),b)return b(f)}else if(d)return d()})})},updateDatasetFromLocal:function(a,b){var d,e,f=a.pending,g=b.uid;h.consoleLog("updating local dataset for uid "+g+" - action = "+b.action),a.meta[g]=a.meta[g]||{},"create"===b.action&&(a.data[g]&&(h.consoleLog("dataset already exists for uid in create :: "+c.stringify(a.data[g])),a.meta[g].fromPending&&(d=a.meta[g].pendingUid,delete f[d])),a.data[g]={}),"update"===b.action&&a.data[g]&&a.meta[g].fromPending&&(h.consoleLog("updating an existing pending record for dataset :: "+c.stringify(a.data[g])),d=a.meta[g].pendingUid,a.meta[g].previousPendingUid=d,e=f[d],e&&(e.inFlight?(h.consoleLog("existing in-inflight pending record = "+c.stringify(e)),b.delayed=!0,b.waiting=e.hash):(h.consoleLog("existing pre-flight pending record = "+c.stringify(e)),e.post=b.post,e.postHash=b.postHash,delete f[b.hash],b.hash=d))),"delete"===b.action&&a.data[g]&&(a.meta[g].fromPending&&(h.consoleLog("Deleting an existing pending record for dataset :: "+c.stringify(a.data[g])),d=a.meta[g].pendingUid,a.meta[g].previousPendingUid=d,e=f[d],e&&(e.inFlight?(h.consoleLog("existing in-inflight pending record = "+c.stringify(e)),b.delayed=!0,b.waiting=e.hash):(h.consoleLog("existing pending record = "+c.stringify(e)),"create"===e.action&&(delete f[b.hash],delete f[d]),"update"===e.action&&(b.pre=e.pre,b.preHash=e.preHash,b.inFlight=!1,delete f[d])))),delete a.data[g]),a.data[g]&&(a.data[g].data=b.post,a.data[g].hash=b.postHash,a.meta[g].fromPending=!0,a.meta[g].pendingUid=b.hash)},updatePendingFromNewData:function(a,b,d){var e,f=b.pending;if(f&&d.records)for(var g in f)if(f.hasOwnProperty(g)){var i=f[g];if(b.meta[i.uid]=b.meta[i.uid]||{},i.inFlight===!1){if(h.consoleLog("updatePendingFromNewData - Found Non inFlight record -> action="+i.action+" :: uid="+i.uid+" :: hash="+i.hash),"update"===i.action||"delete"===i.action)if(e=d.records[i.uid])h.consoleLog("updatePendingFromNewData - Updating pre values for existing pending record "+i.uid),i.pre=e.data,i.preHash=e.hash;else{var j=b.meta[i.uid].previousPendingUid,k=f[j];if(k&&d&&d.updates&&d.updates.applied&&d.updates.applied[k.hash]){var l=d.updates.applied[k.hash].uid;e=d.records[l],e&&(h.consoleLog("updatePendingFromNewData - Updating pre values for existing pending record which was previously a create "+i.uid+" ==> "+l),i.pre=e.data,i.preHash=e.hash,i.uid=l)}}"create"===i.action&&d&&d.updates&&d.updates.applied&&d.updates.applied[g]&&(h.consoleLog("updatePendingFromNewData - Found an update for a pending create "+c.stringify(d.updates.applied[g])),e=d.records[d.updates.applied[g].uid],e&&(h.consoleLog("updatePendingFromNewData - Changing pending create to an update based on new record "+c.stringify(e)),i.action="update",i.pre=e.data,i.preHash=e.hash,i.uid=d.updates.applied[g].uid))}}},updateNewDataFromInFlight:function(a,b,c){var d=b.pending;if(d&&c.records)for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];if(f.inFlight){var g=c&&c.updates&&c.updates.hashes&&c.updates.hashes[e]?!0:!1;if(h.consoleLog("updateNewDataFromInFlight - Found inflight pending Record - action = "+f.action+" :: hash = "+e+" :: updateReceivedForPending="+g),!g){var i=c.records[f.uid];if("update"===f.action&&i)i.data=f.post,i.hash=f.postHash;else if("delete"===f.action&&i)delete c.records[f.uid];else if("create"===f.action){h.consoleLog("updateNewDataFromInFlight - re adding pending create to incomming dataset");var j={data:f.post,hash:f.postHash};c.records[f.uid]=j}}}}},updateNewDataFromPending:function(a,b,c){var d=b.pending;if(d&&c.records)for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];if(f.inFlight===!1){h.consoleLog("updateNewDataFromPending - Found Non inFlight record -> action="+f.action+" :: uid="+f.uid+" :: hash="+f.hash);var g=c.records[f.uid];if("update"===f.action&&g)g.data=f.post,g.hash=f.postHash;else if("delete"===f.action&&g)delete c.records[f.uid];else if("create"===f.action){h.consoleLog("updateNewDataFromPending - re adding pending create to incomming dataset");var i={data:f.post,hash:f.postHash};c.records[f.uid]=i}}}},updateCrashedInFlightFromNewData:function(a,b,d){var e,f,g={applied:h.notifications.REMOTE_UPDATE_APPLIED,failed:h.notifications.REMOTE_UPDATE_FAILED,collisions:h.notifications.COLLISION_DETECTED},i=b.pending,j={};if(i){for(e in i)if(i.hasOwnProperty(e)&&(f=i[e],f.inFlight&&f.crashed))if(h.consoleLog("updateCrashedInFlightFromNewData - Found crashed inFlight pending record uid="+f.uid+" :: hash="+f.hash),d&&d.updates&&d.updates.hashes){var k=d.updates.hashes[e];k?(j[k.uid]=k,h.consoleLog("updateCrashedInFlightFromNewData - Resolving status for crashed inflight pending record "+c.stringify(k)),"failed"===k.type&&("create"===k.action?(h.consoleLog("updateCrashedInFlightFromNewData - Deleting failed create from dataset"),delete b.data[k.uid]):("update"===k.action||"delete"===k.action)&&(h.consoleLog("updateCrashedInFlightFromNewData - Reverting failed "+k.action+" in dataset"),b.data[k.uid]={data:f.pre,hash:f.preHash})),delete i[e],h.doNotify(a,k.uid,g[k.type],k)):f.crashedCount?f.crashedCount++:f.crashedCount=1}else f.crashedCount?f.crashedCount++:f.crashedCount=1;for(e in i)i.hasOwnProperty(e)&&(f=i[e],f.inFlight&&f.crashed&&f.crashedCount>b.config.crashed_count_wait&&(h.consoleLog("updateCrashedInFlightFromNewData - Crashed inflight pending record has reached crashed_count_wait limit : "+c.stringify(f)),b.config.resend_crashed_updates?(h.consoleLog("updateCrashedInFlightFromNewData - Retryig crashed inflight pending record"),f.crashed=!1,f.inFlight=!1):(h.consoleLog("updateCrashedInFlightFromNewData - Deleting crashed inflight pending record"),delete i[e])))}},updateDelayedFromNewData:function(a,b,d){var e,f,g=b.pending;if(g)for(e in g)if(g.hasOwnProperty(e)&&(f=g[e],f.delayed&&f.waiting&&(h.consoleLog("updateDelayedFromNewData - Found delayed pending record uid="+f.uid+" :: hash="+f.hash+" :: waiting="+f.waiting),d&&d.updates&&d.updates.hashes))){var i=d.updates.hashes[f.waiting];i&&(h.consoleLog("updateDelayedFromNewData - Waiting pending record is resolved rec="+c.stringify(i)),f.delayed=!1,f.waiting=void 0)}},updateMetaFromNewData:function(a,b,d){var e=b.meta;if(e&&d&&d.updates&&d.updates.hashes)for(var f in e)if(e.hasOwnProperty(f)){var g=e[f],i=g.pendingUid,j=g.previousPendingUid;h.consoleLog("updateMetaFromNewData - Found metadata with uid = "+f+" :: pendingHash = "+i+" :: previousPendingHash ="+j);var k=!0,l=!0;if(j){k=!1;var m=d.updates.hashes[j];m&&(h.consoleLog("updateMetaFromNewData - Found previousPendingUid in meta data resolved - resolved = "+c.stringify(m)),g.previousPendingUid=void 0,k=!0)}if(i){l=!1;var m=d.updates.hashes[i];m&&(h.consoleLog("updateMetaFromNewData - Found pendingUid in meta data resolved - resolved = "+c.stringify(m)),g.pendingUid=void 0,l=!0)}k&&l&&(h.consoleLog("updateMetaFromNewData - both previous and current pendings are resolved for meta data with uid "+f+". Delete it."),delete e[f])}},markInFlightAsCrashed:function(a){var b,c,d=a.pending;if(d){var e={};for(b in d)d.hasOwnProperty(b)&&(c=d[b],c.inFlight&&(h.consoleLog("Marking in flight pending record as crashed : "+b),c.crashed=!0,e[c.uid]=c))}},consoleLog:function(a){h.config.do_console_log&&console.log(a)}};!function(){h.config=h.defaults}(),b.exports={init:h.init,manage:h.manage,notify:h.notify,doList:h.list,doCreate:h.create,doRead:h.read,doUpdate:h.update,doDelete:h["delete"],listCollisions:h.listCollisions,removeCollision:h.removeCollision,getPending:h.getPending,clearPending:h.clearPending,getDataset:h.getDataSet,getQueryParams:h.getQueryParams,setQueryParams:h.setQueryParams,getMetaData:h.getMetaData,setMetaData:h.setMetaData,getConfig:h.getConfig,setConfig:h.setConfig,startSync:h.startSync,stopSync:h.stopSync,doSync:h.doSync,forceSync:h.forceSync,generateHash:h.generateHash,loadDataSet:h.loadDataSet,checkHasCustomSync:h.checkHasCustomSync}},{"../../libs/generated/crypto":1,"../../libs/generated/lawnchair":2,"./api_act":19,"./api_cloud":21,JSON:3}],46:[function(a,b){b.exports={createUUID:function(){for(var a=[],b="0123456789ABCDEF",c=0;32>c;c++)a[c]=b.substr(Math.floor(16*Math.random()),1);a[12]="4",a[16]=b.substr(3&a[16]|8,1);var d=a.join("");return d}}},{}],47:[function(a,b){var c,d=a("./initializer"),e=a("./events"),f=a("./hosts"),g=a("./constants"),h=a("./logger"),i=!1,j=!1,k=null,l=function(a){return j?a(null,{host:n()}):(e.once(g.INIT_EVENT,function(b,c){return a(b,c)}),void(i||(i=!0,d.init(function(a,b){return i=!1,a?(k=a,e.emit(g.INIT_EVENT,a)):(k=null,j=!0,c=new f(b.cloud),e.emit(g.INIT_EVENT,null,{host:n()}))}))))},m=function(){return c},n=function(){if("undefined"!=typeof c){var b=a("./appProps").getAppProps();return c.getHost(b.mode)}return void 0},o=function(){return j},p=function(){return k},q=function(){j=!1,i=!1,c=void 0,k=void 0,l(function(){})};l(function(a){a?"app_config_missing"!==a.message?h.error("Failed to initialise fh."):h.info("No fh config file"):h.info("fh cloud is ready")}),b.exports={ready:l,isReady:o,getCloudHost:m,getCloudHostUrl:n,getInitError:p,reset:q}},{"./appProps":25,"./constants":27,"./events":30,"./hosts":33,"./initializer":34,"./logger":37}]},{},[16])(16)}),function(root){if(!JSON)var JSON=function(){function f(a){return 10>a?"0"+a:a}function quote(a){return escapeable.test(a)?'"'+a.replace(escapeable,function(a){var b=meta[a];return"string"==typeof b?b:(b=a.charCodeAt(),"\\u00"+Math.floor(b/16).toString(16)+(b%16).toString(16))})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g,h=gap,i=b[a];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(a)),"function"==typeof rep&&(i=rep.call(b,a,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";if(gap+=indent,g=[],"number"==typeof i.length&&!i.propertyIsEnumerable("length")){for(f=i.length,c=0;f>c;c+=1)g[c]=str(c,i)||"null";return e=0===g.length?"[]":gap?"[\n"+gap+g.join(",\n"+gap)+"\n"+h+"]":"["+g.join(",")+"]",gap=h,e}if("object"==typeof rep)for(f=rep.length,c=0;f>c;c+=1)d=rep[c],"string"==typeof d&&(e=str(d,i,rep),e&&g.push(quote(d)+(gap?": ":":")+e));else for(d in i)e=str(d,i,rep),e&&g.push(quote(d)+(gap?": ":":")+e);return e=0===g.length?"{}":gap?"{\n"+gap+g.join(",\n"+gap)+"\n"+h+"}":"{"+g.join(",")+"}",gap=h,e}}Date.prototype.toJSON=function(){return this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z"};var escapeable=/["\\\x00-\x1f\x7f-\x9f]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;return{stringify:function(a,b,c){var d;if(gap="",indent="",c)if("number"==typeof c)for(d=0;c>d;d+=1)indent+=" ";else"string"==typeof c&&(indent=c);if(b){if("function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");rep=b}else rep=function(a,b){return Object.hasOwnProperty.call(this,a)?b:void 0};return str("",{"":a})},parse:function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&"object"==typeof e)for(c in e)Object.hasOwnProperty.call(e,c)&&(d=walk(e,c),void 0!==d?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;if(/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/bfnrtu]/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")},quote:quote}}();if(function(){if(!window.google||!google.gears){var a=null;if("undefined"!=typeof GearsFactory)a=new GearsFactory;else try{a=new ActiveXObject("Gears.Factory"),-1!=a.getBuildInfo().indexOf("ie_mobile")&&a.privateSetGlobalObject(this)}catch(b){"undefined"!=typeof navigator.mimeTypes&&navigator.mimeTypes["application/x-googlegears"]&&(a=document.createElement("object"),a.style.display="none",a.width=0,a.height=0,a.type="application/x-googlegears",document.documentElement.appendChild(a))}a&&(window.google||(google={}),google.gears||(google.gears={factory:a}))}}(),Persist=function(){var a,b,c,d,e,f,g="0.2.0";f=function(){var a,b="Thu, 01-Jan-1970 00:00:01 GMT",c=864e5,d=["expires","path","domain"],e=escape,f=unescape,g=document,h=function(){var a=new Date;return a.setTime(a.getTime()),a},j=function(a,b){var c,f,g,h=[],i=arguments.length>2?arguments[2]:{};for(h.push(e(a)+"="+e(b)),c=0;c2?arguments[2]:{},e=h(),f={};d.expires&&(d.expires*=c,f.expires=new Date(e.getTime()+d.expires),f.expires=f.expires.toGMTString());var k=["path","domain","secure"];for(i=0;ic?!1:!0},get:function(a){a=e(a);var b,c=g.cookie,d=c.indexOf(a+"="),h=d+a.length+1,i=c.substring(0,a.length);return!d&&a!=i||0>d?null:(b=c.indexOf(";",h),0>b&&(b=c.length),f(c.substring(h,b)))},remove:function(c){var d=a.get(c),e={expires:b};return g.cookie=j(c,"",e),d},keys:function(){var a,b,c=g.cookie,d=c.split("; "),e=[];for(a=0;ac;c++)if(a[c]==b)return c;return-1}}();e=function(){},c=function(a){return"PS"+a.replace(/_/g,"__").replace(/ /g,"_s")},C={search_order:["localstorage","whatwg_db","globalstorage","gears","ie","flash","cookie"],name_re:/^[a-z][a-z0-9_ -]+$/i,methods:["init","get","set","remove","load","save"],sql:{version:"1",create:"CREATE TABLE IF NOT EXISTS persist_data (k TEXT UNIQUE NOT NULL PRIMARY KEY, v TEXT NOT NULL)",get:"SELECT v FROM persist_data WHERE k = ?",set:"INSERT INTO persist_data(k, v) VALUES (?, ?)",remove:"DELETE FROM persist_data WHERE k = ?"},flash:{div_id:"_persist_flash_wrap",id:"_persist_flash",path:"persist.swf",size:{w:1,h:1},args:{autostart:!0}}},b={gears:{size:-1,test:function(){try{return window.google&&window.google.gears?!0:!1}catch(a){return!1}},methods:{transaction:function(a){var b=this.db;b.execute("BEGIN").close(),a.call(this,b),b.execute("COMMIT").close()},init:function(){var a;a=this.db=google.gears.factory.create("beta.database"),a.open(c(this.name)),a.execute(C.sql.create).close()},get:function(a,b,c){var d,e=C.sql.get;b&&this.transaction(function(f){var g,h;d=f.execute(e,[a]),g=d.isValidRow(),h=g?d.field(0):null,d.close(),b.call(c||this,g,h)})},set:function(a,b,c,d){var e=C.sql.remove,f=C.sql.set;this.transaction(function(g){g.execute(e,[a]).close(),g.execute(f,[a,b]).close(),c&&c.call(d||this,!0,b)})},remove:function(a,b,c){var d=C.sql.get;sql=C.sql.remove,val=null,is_valid=!1,this.transaction(function(e){b&&(r=e.execute(d,[a]),is_valid=r.isValidRow(),val=is_valid?r.field(0):null,r.close()),(!b||is_valid)&&e.execute(sql,[a]).close(),b&&b.call(c||this,is_valid,val)})}}},whatwg_db:{size:204800,test:function(){try{var a="PersistJS Test",c="Persistent database test.";return window.openDatabase&&window.openDatabase(a,C.sql.version,c,b.whatwg_db.size)?!0:!1}catch(d){return!1}},methods:{transaction:function(a){this.db_created||this.db.transaction(function(a){a.executeSql(C.sql.create,[],function(){this.db_created=!0})},e),this.db.transaction(a)},init:function(){this.db=openDatabase(this.name,C.sql.version,this.o.about||"Persistent storage for "+this.name,this.o.size||b.whatwg_db.size)},get:function(a,b,c){var d=C.sql.get;b&&(c=c||this,this.transaction(function(e){e.executeSql(d,[a],function(a,d){d.rows.length>0?b.call(c,!0,d.rows.item(0).v):b.call(c,!1,null)})}))},set:function(a,b,c,d){var e=C.sql.remove,f=C.sql.set;return this.transaction(function(g){g.executeSql(e,[a],function(){g.executeSql(f,[a,b],function(){c&&c.call(d||this,!0,b)})})}),b},remove:function(a,b,c){var d=C.sql.get;sql=C.sql.remove,this.transaction(function(e){b?e.executeSql(d,[a],function(d,e){if(e.rows.length>0){var f=e.rows.item(0).v;d.executeSql(sql,[a],function(){b.call(c||this,!0,f)})}else b.call(c||this,!1,null)}):e.executeSql(sql,[a])})}}},globalstorage:{size:5242880,test:function(){try{return window.globalStorage?!0:!1}catch(a){return!1}},methods:{key:function(a){return c(this.name)+c(a)},init:function(){alert("domain = "+this.o.domain),this.store=globalStorage[this.o.domain]},get:function(a,b,c){a=this.key(a),b&&b.call(c||this,!0,this.store.getItem(a))},set:function(a,b,c,d){a=this.key(a),this.store.setItem(a,b),c&&c.call(d||this,!0,b)},remove:function(a,b,c){var d;a=this.key(a),d=this.store[a],this.store.removeItem(a),b&&b.call(c||this,null!==d,d)}}},localstorage:{size:-1,test:function(){try{return window.localStorage?!0:!1}catch(a){return!1}},methods:{key:function(a){return c(this.name)+c(a)},init:function(){this.store=localStorage},get:function(a,b,c){a=this.key(a),b&&b.call(c||this,!0,this.store.getItem(a))},set:function(a,b,c,d){a=this.key(a),this.store.setItem(a,b),c&&c.call(d||this,!0,b)},remove:function(a,b,c){var d;a=this.key(a),d=this.store.getItem(a),this.store.removeItem(a),b&&b.call(c||this,null!==d,d)}}},ie:{prefix:"_persist_data-",size:65536,test:function(){try{return window.ActiveXObject?!0:!1}catch(a){return!1}},make_userdata:function(a){var b=document.createElement("div");return b.id=a,b.style.display="none",b.addBehavior("#default#userdata"),document.body.appendChild(b),b},methods:{init:function(){var a=b.ie.prefix+c(this.name);this.el=b.ie.make_userdata(a),this.o.defer&&this.load()},get:function(a,b,d){var e;a=c(a),this.o.defer||this.load(),e=this.el.getAttribute(a),b&&b.call(d||this,e?!0:!1,e)},set:function(a,b,d,e){a=c(a),this.el.setAttribute(a,b),this.o.defer||this.save(),d&&d.call(e||this,!0,b)},remove:function(a,b,d){var e;a=c(a),this.o.defer||this.load(),e=this.el.getAttribute(a),this.el.removeAttribute(a),this.o.defer||this.save(),b&&b.call(d||this,e?!0:!1,e)},load:function(){this.el.load(c(this.name))},save:function(){this.el.save(c(this.name))}}},cookie:{delim:":",size:4e3,test:function(){try{return a.Cookie.enabled?!0:!1}catch(b){return!1}},methods:{key:function(a){return this.name+b.cookie.delim+a},get:function(a,b,c){var d;a=this.key(a),d=f.get(a),b&&b.call(c||this,null!=d,d)},set:function(a,b,c,d){a=this.key(a),f.set(a,b,this.o),c&&c.call(d||this,!0,b)},remove:function(a,b,c,d){var b;a=this.key(a),b=f.remove(a),c&&c.call(d||this,null!=b,b)}}},flash:{test:function(){try{if(!deconcept||!deconcept.SWFObjectUtil)return!1; -var a=deconcept.SWFObjectUtil.getPlayerVersion().major;return a>=8?!0:!1}catch(b){return!1}},methods:{init:function(){if(!b.flash.el){var a,c,d,e=C.flash;d=document.createElement("div"),d.id=e.div_id,document.body.appendChild(d),a=new deconcept.SWFObject(this.o.swf_path||e.path,e.id,e.size.w,e.size.h,"8");for(c in e.args)a.addVariable(c,e.args[c]);a.write(d),b.flash.el=document.getElementById(e.id)}this.el=b.flash.el},get:function(a,b,d){var e;a=c(a),e=this.el.get(this.name,a),b&&b.call(d||this,null!==e,e)},set:function(a,b,d,e){var f;a=c(a),f=this.el.set(this.name,a,b),d&&d.call(e||this,!0,b)},remove:function(a,b,d){var e;a=c(a),e=this.el.remove(this.name,a),b&&b.call(d||this,!0,e)}}}};var d=function(){var c,d,f,g,h=C.methods,i=C.search_order;for(c=0,d=h.length;d>c;c++)a.Store.prototype[h[c]]=e;for(a.type=null,a.size=-1,c=0,d=i.length;!a.type&&d>c;c++)if(f=b[i[c]],f.test()){a.type=i[c],a.size=f.size;for(g in f.methods)a.Store.prototype[g]=f.methods[g]}a._init=!0};return a={VERSION:g,type:null,size:0,add:function(a){b[a.id]=a,C.search_order=[a.id].concat(C.search_order),d()},remove:function(a){var c=h(C.search_order,a);0>c||(C.search_order.splice(c,1),delete b[a],d())},Cookie:f,Store:function(b,c){if(!C.name_re.exec(b))throw new Error("Invalid name");if(!a.type)throw new Error("No suitable storage found");c=c||{},this.name=b,c.domain=c.domain||location.host||"localhost",c.domain=c.domain.replace(/:\d+$/,""),this.o=c,c.expires=c.expires||730,c.path=c.path||"/",this.init()}},d(),a}(),"undefined"==typeof deconcept)var deconcept=new Object;"undefined"==typeof deconcept.util&&(deconcept.util=new Object),"undefined"==typeof deconcept.SWFObjectUtil&&(deconcept.SWFObjectUtil=new Object),deconcept.SWFObject=function(a,b,c,d,e,f,g,h,i,j){if(document.getElementById){this.DETECT_KEY=j?j:"detectflash",this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY),this.params=new Object,this.variables=new Object,this.attributes=new Array,a&&this.setAttribute("swf",a),b&&this.setAttribute("id",b),c&&this.setAttribute("width",c),d&&this.setAttribute("height",d),e&&this.setAttribute("version",new deconcept.PlayerVersion(e.toString().split("."))),this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion(),!window.opera&&document.all&&this.installedVer.major>7&&(deconcept.SWFObject.doPrepUnload=!0),f&&this.addParam("bgcolor",f);var k=g?g:"high";this.addParam("quality",k),this.setAttribute("useExpressInstall",!1),this.setAttribute("doExpressInstall",!1);var l=h?h:window.location;this.setAttribute("xiRedirectUrl",l),this.setAttribute("redirectUrl",""),i&&this.setAttribute("redirectUrl",i)}},deconcept.SWFObject.prototype={useExpressInstall:function(a){this.xiSWFPath=a?a:"expressinstall.swf",this.setAttribute("useExpressInstall",!0)},setAttribute:function(a,b){this.attributes[a]=b},getAttribute:function(a){return this.attributes[a]},addParam:function(a,b){this.params[a]=b},getParams:function(){return this.params},addVariable:function(a,b){this.variables[a]=b},getVariable:function(a){return this.variables[a]},getVariables:function(){return this.variables},getVariablePairs:function(){var a,b=new Array,c=this.getVariables();for(a in c)b.push(a+"="+c[a]);return b},getSWFHTML:function(){var a="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){this.getAttribute("doExpressInstall")&&(this.addVariable("MMplayerType","PlugIn"),this.setAttribute("swf",this.xiSWFPath)),a='0&&(a+='flashvars="'+d+'"'),a+="/>"}else{this.getAttribute("doExpressInstall")&&(this.addVariable("MMplayerType","ActiveX"),this.setAttribute("swf",this.xiSWFPath)),a='',a+='';var b=this.getParams();for(var c in b)a+='';var d=this.getVariablePairs().join("&");d.length>0&&(a+=''),a+=""}return a},write:function(a){if(this.getAttribute("useExpressInstall")){var b=new deconcept.PlayerVersion([6,0,65]);this.installedVer.versionIsValid(b)&&!this.installedVer.versionIsValid(this.getAttribute("version"))&&(this.setAttribute("doExpressInstall",!0),this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl"))),document.title=document.title.slice(0,47)+" - Flash Player Installation",this.addVariable("MMdoctitle",document.title))}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var c="string"==typeof a?document.getElementById(a):a;return c.innerHTML=this.getSWFHTML(),!0}return""!=this.getAttribute("redirectUrl")&&document.location.replace(this.getAttribute("redirectUrl")),!1}},deconcept.SWFObjectUtil.getPlayerVersion=function(){var a=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var b=navigator.plugins["Shockwave Flash"];b&&b.description&&(a=new deconcept.PlayerVersion(b.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split(".")))}else{try{var c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")}catch(d){try{var c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");a=new deconcept.PlayerVersion([6,0,21]),c.AllowScriptAccess="always"}catch(d){if(6==a.major)return a}try{c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(d){}}null!=c&&(a=new deconcept.PlayerVersion(c.GetVariable("$version").split(" ")[1].split(",")))}return a},deconcept.PlayerVersion=function(a){this.major=null!=a[0]?parseInt(a[0]):0,this.minor=null!=a[1]?parseInt(a[1]):0,this.rev=null!=a[2]?parseInt(a[2]):0},deconcept.PlayerVersion.prototype.versionIsValid=function(a){return this.majora.major?!0:this.minora.minor?!0:this.rev2?(e[0]=a[f-3],e[1]=a[f-2],e[2]=a[f-1]):2==f?(e[1]=a[0],e[2]=a[1]):1==f&&(e[2]=a[0]);for(var g=0,h=0;3>g;g++){var i=e[g],j=typeof i;!i||0!=h||"object"!=j&&"boolean"!=j?i&&"function"==j&&(h=0==h?1:h,d[h++]=i):d[h++]=i}if(null==d[0])d[0]=b?b:defaultargs.params;else{var k=d[0];k._defaults=[];for(var l in b)b.hasOwnProperty(l)&&"undefined"==typeof k[l]&&(k[l]=b[l],k._defaults.push(l))}d[1]=null==d[1]?defaultargs.success:d[1],d[2]=null==d[2]?defaultargs.failure:d[2],c(d[0],d[1],d[2])},eventSupported=function(a){var b=document.createElement("i");return a in b||b.setAttribute&&b.setAttribute(a,"return;")||!1},__is_ready=!1,__ready_list=[],__ready_bound=!1,boxprefix="/box/srv/1.1/";_getHostPrefix=function(){return $fh.app_props.host+boxprefix};var __ready=function(){if(!__is_ready&&(__is_ready=!0,__ready_list)){try{for(;__ready_list[0];)__ready_list.shift().apply(document,[])}finally{}__ready_list=null}},__bind_ready=function(){__ready_bound||(__ready_bound=!0,document.addEventListener?(document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,!1),__ready()},!1),window.addEventListener("load",__ready,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&(document.detachEvent("onreadystatechange",arguments.callee),__ready())}),window.attachEvent("onload",__ready),document.documentElement.doScroll&&window==window.top&&function(){if(!__is_ready){try{document.documentElement.doScroll("left")}catch(a){return void setTimeout(arguments.callee,0)}__ready()}}()))};__bind_ready();var _mapScriptLoaded="undefined"!=typeof google&&"undefined"!=typeof google.maps&&"undefined"!=typeof google.maps.Map,_mapLoadSuccessParameters=[],_mapScriptLoading=!1,_loadMapScript=function(){var a=document.createElement("script");a.type="text/javascript";var b=document.location.protocol;b="http:"===b||"https:"===b?b:"https:",a.src=b+"//maps.google.com/maps/api/js?sensor=true&callback=$fh._mapLoaded",document.body.appendChild(a)},audio_obj=null,audio_is_playing=!1;$fh.__dest__={send:function(a,b,c){c("send_nosupport")},notify:function(a,b,c){c("notify_nosupport")},contacts:function(a,b,c){c("contacts_nosupport")},acc:function(a,b,c){c("acc_nosupport")},geo:function(a,b,c){c("geo_nosupport")},cam:function(a,b,c){c("cam_nosupport")},device:function(a,b,c){c("device_nosupport")},listen:function(a,b,c){c("listen_nosupport")},handlers:function(a,b,c){c("handlers_no_support")},file:function(a,b,c){c("file_nosupport")},push:function(a,b,c){c("push_nosupport")},env:function(a,b){b({height:window.innerHeight,width:window.innerWidth})},data:function(a,b,c){if($fh._persist||($fh._persist=new Persist.Store("FH"+$fh.app_props.appid,{swf_path:"/static/c/start/swf/persist.swf"})),!a.key)return void c("data_nokey");var d={load:function(){$fh._persist.get(a.key,function(c,d){b(c?{key:a.key,val:d}:{key:a.key,val:null})})},save:function(){if(!a.val)return void c("data_noval");try{$fh._persist.set(a.key,a.val)}catch(d){return void c("data_error",{},a)}b()},remove:function(){$fh._persist.remove(a.key,function(c,d){b(c?{key:a.key,val:d}:{key:a.key,val:null})})}};d[a.act]?d[a.act]():c("data_badact",a)},log:function(a,b,c){"undefined"==typeof console?c("log_nosupport"):console.log(a.message)},ori:function(a,b,c){if("undefined"==typeof a.act||"listen"==a.act)eventSupported("onorientationchange")?window.addEventListener("orientationchange",b,!1):c("ori_nosupport",{},a);else if("set"==a.act){if(!a.value)return void c("ori_no_value",{},a);"portrait"==a.value?(document.getElementsByTagName("body")[0].style["-moz-transform"]="",document.getElementsByTagName("body")[0].style["-webkit-transform"]="",b({orientation:"portrait"})):(document.getElementsByTagName("body")[0].style["-moz-transform"]="rotate(90deg)",document.getElementsByTagName("body")[0].style["-webkit-transform"]="rotate(90deg)",b({orientation:"landscape"}))}else c("ori_badact",{},a)},map:function(a,b,c){if(!a.target)return void c("map_notarget",{},a);if(!a.lat)return void c("map_nolatitude",{},a);if(!a.lon)return void c("map_nologitude",{},a);var d=a.target;if("string"==typeof d){var e=null;if("undefined"!=typeof jQuery)try{var f=jQuery(d);f.length>0&&(e=f[0])}catch(g){e=null}null==e&&(e=document.getElementById(d)),d=e}else"object"==typeof d?1===d.nodeType&&"string"==typeof d.nodeName||(d=d[0]):d=null;if(!d)return void c("map_nocontainer",{},a);if(_mapScriptLoaded){var h={};h.zoom=a.zoom?a.zoom:8,h.center=new google.maps.LatLng(a.lat,a.lon),h.mapTypeId=google.maps.MapTypeId.ROADMAP;var i=new google.maps.Map(d,h);b({map:i})}else"function"==typeof b&&_mapLoadSuccessParameters.push({target:d,successFunction:b,mOptions:a}),$fh._mapLoaded=function(){_mapScriptLoaded=!0;for(var a=_mapLoadSuccessParameters.shift();"undefined"!=typeof a;){var b=a.mOptions,c={};c.zoom=b.zoom?b.zoom:8,c.center=new google.maps.LatLng(b.lat,b.lon),c.mapTypeId=google.maps.MapTypeId.ROADMAP;var d=new google.maps.Map(a.target,c);a.successFunction({map:d}),a=_mapLoadSuccessParameters.shift()}},_mapScriptLoading||(_mapScriptLoading=!0,_loadMapScript()),setTimeout(function(){_mapScriptLoaded||c("map_timeout",{},a)},2e4)},audio:function(a,b,c){if(null==!audio_obj&&"play"==a.act&&(!a.path||""==a.path))return void c("no_audio_path");var d={play:function(){if(null==audio_obj){if(audio_obj=document.createElement("audio"),!(audio_obj.play?!0:!1))return void c("audio_not_support");if(a.type){var e=audio_obj.canPlayType(a.type);if("no"==e||""==e)return void c("audio_type_not_supported")}audio_obj.src=a.path,a.controls&&(audio_obj.controls="controls"),a.autoplay&&(audio_obj.autoplay="autoplay"),a.loop&&(audio_obj.loop="loop"),document.body.appendChild(audio_obj),audio_obj.play(),audio_is_playing=!0,b()}else a.path&&a.path!=audio_obj.src?(audio_is_playing&&d.stop(!0),d.play()):audio_is_playing||(audio_obj.play(),audio_is_playing=!0,b())},pause:function(){null!=audio_obj&&audio_is_playing?("function"==typeof audio_obj.pause?audio_obj.pause():"function"==typeof audio_obj.stop&&audio_obj.stop(),audio_is_playing=!1,b()):c("no_audio_playing")},stop:function(a){null!=audio_obj?("function"==typeof audio_obj.stop?audio_obj.stop():"function"==typeof audio_obj.pause&&audio_obj.pause(),document.body.removeChild(audio_obj),audio_obj=null,audio_is_playing=!1,a||b()):c("no_audio")}};d[a.act]?d[a.act]():c("data_badact",a)},webview:function(a,b,c){c("webview_nosupport")},ready:function(a,b){__bind_ready(),__is_ready?b.apply(document,[]):__ready_list.push(b)}},$fh.send=function(){handleargs(arguments,{type:"email"},$fh.__dest__.send)},$fh.notify=function(){handleargs(arguments,{type:"vibrate"},$fh.__dest__.notify)},$fh.contacts=function(){handleargs(arguments,{act:"list"},$fh.__dest__.contacts)},$fh.acc=function(){handleargs(arguments,{act:"register",interval:0},$fh.__dest__.acc)},$fh.geo=function(){handleargs(arguments,{act:"register",interval:0},$fh.__dest__.geo)},$fh.cam=function(){handleargs(arguments,{act:"picture"},$fh.__dest__.cam)},$fh.data=function(){handleargs(arguments,{act:"load"},$fh.__dest__.data)},$fh.log=function(){handleargs(arguments,{message:"none"},$fh.__dest__.log)},$fh.device=function(){handleargs(arguments,{},$fh.__dest__.device)},$fh.listen=function(){handleargs(arguments,{act:"add"},$fh.__dest__.listen)},$fh.ori=function(){handleargs(arguments,{},$fh.__dest__.ori)},$fh.map=function(){handleargs(arguments,{},$fh.__dest__.map)},$fh.audio=function(){handleargs(arguments,{},$fh.__dest__.audio)},$fh.webview=function(){handleargs(arguments,{},$fh.__dest__.webview)},$fh.ready=function(){handleargs(arguments,{},$fh.__dest__.ready)},$fh.handlers=function(){handleargs(arguments,{type:"back"},$fh.__dest__.handlers)},$fh.file=function(){handleargs(arguments,{act:"upload"},$fh.__dest__.file)},$fh.push=function(){handleargs(arguments,{},$fh.__dest__.push)},$fh.env=function(){handleargs(arguments,{},function(a,b){$fh.__dest__.env({},function(a){a.application=$fh.app_props.appid,$fh._getDeviceId&&(a.uuid=$fh._getDeviceId()),a.agent=navigator.userAgent||"unknown",b(a)})})},$fh.device=function(){handleargs(arguments,{},function(){})},$fh.geoip=function(){handleargs(arguments,{act:"get"},function(a,b,c){if("get"==a.act){var d={instance:$fh.app_props.appid,domain:$fh.cloud_props.domain};$fh.__ajax({url:_getHostPrefix()+"act/wid/geoip/resolve",type:"POST",data:JSON.stringify(d),success:function(a){for(var c in a.geoip)a[c]=a.geoip[c];b(a)}})}else c("geoip_badact",a)})},$fh.web=function(){handleargs(arguments,{method:"GET"},function(a,b,c){a.url||c("bad_url"),$fh.__ajax(a.is_local?{url:a.url,type:"GET",dataType:"html",success:function(a){var c={};c.status=200,c.body=a,b(c)},error:function(){c()}}:{url:_getHostPrefix()+"act/wid/web",type:"POST",data:JSON.stringify(a),success:function(a){b(a)}})})},$fh.__webview_win=void 0,$fh.__dest__.webview=function(a,b,c){if("act"in a&&"open"!==a.act)"close"===a.act&&("undefined"!=typeof $fh.__webview_win&&($fh.__webview_win.close(),$fh.__webview_win=void 0),b("closed"));else{if(!a.url)return void c("no_url");{a.url}$fh.__webview_win=window.open(a.url,"_blank"),b("opened")}},("undefined"!=typeof window.PhoneGap||"undefined"!=typeof window.cordova)&&($fh._readyCallbacks=[],$fh._readyState=!1,$fh.__dest__.ready=function(a,b){if($fh._readyState)try{b()}catch(c){console.log("Error during $fh.ready. Skip. Error = "+c.message)}else $fh._readyCallbacks.push(b)}),$fh.__dest__.geo=function(a,b,c){if("undefined"!=typeof navigator.geolocation)if(a.act&&"register"!=a.act)"unregister"==a.act?($fh.__dest__._geoWatcher&&(navigator.geolocation.clearWatch($fh.__dest__._geoWatcher),$fh.__dest__._geoWatcher=void 0),b()):c("geo_badact",{},a);else{if($fh.__dest__._geoWatcher)return void c("geo_inuse",{},a);if(0==a.interval&&navigator.geolocation.getCurrentPosition(function(a){var c=a.coords,d={lon:c.longitude,lat:c.latitude,alt:c.altitude,acc:c.accuracy,head:c.heading,speed:c.speed,when:a.timestamp};b(d)},function(){c("error_geo",{},a)}),a.interval>0){var d=navigator.geolocation.watchPosition(function(a){var c=a.coords,d={lon:c.longitude,lat:c.latitude,alt:c.altitude,acc:c.accuracy,head:c.heading,speed:c.speed,when:a.timestamp};b(d)},function(){c("error_geo",{},a)},{frequency:a.interval});$fh.__dest__._geoWatcher=d}}else c("geo_nosupport",{},a)},$fh.__dest__.acc=function(a,b){b({x:4*Math.random()-2,y:4*Math.random()-2,z:4*Math.random()-2,when:(new Date).getTime()})},root.$fh=$fh}(this),function(){function a(a){function b(){return e}var c={},d={exports:{}};!function(){function a(a){var c=!1;return function(){if(c)throw new Error("Callback was already called.");c=!0,a.apply(b,arguments)}}var b,e,f={};b=this,null!=b&&(e=b.async),f.noConflict=function(){return b.async=e,f};var g=function(a,b){if(a.forEach)return a.forEach(b);for(var c=0;c=b.length&&d(null))}))})},f.forEach=f.each,f.eachSeries=function(a,b,c){if(c=c||function(){},!a.length)return c();var d=0,e=function(){b(a[d],function(b){b?(c(b),c=function(){}):(d+=1,d>=a.length?c(null):e())})};e()},f.forEachSeries=f.eachSeries,f.eachLimit=function(a,b,c,d){var e=k(b);e.apply(null,[a,c,d])},f.forEachLimit=f.eachLimit;var k=function(a){return function(b,c,d){if(d=d||function(){},!b.length||0>=a)return d();var e=0,f=0,g=0;!function h(){if(e>=b.length)return d();for(;a>g&&f=b.length?d():h())})}()}},l=function(a){return function(){var b=Array.prototype.slice.call(arguments);return a.apply(null,[f.each].concat(b))}},m=function(a,b){return function(){var c=Array.prototype.slice.call(arguments);return b.apply(null,[k(a)].concat(c))}},n=function(a){return function(){var b=Array.prototype.slice.call(arguments);return a.apply(null,[f.eachSeries].concat(b))}},o=function(a,b,c,d){var e=[];b=h(b,function(a,b){return{index:b,value:a}}),a(b,function(a,b){c(a.value,function(c,d){e[a.index]=d,b(c)})},function(a){d(a,e)})};f.map=l(o),f.mapSeries=n(o),f.mapLimit=function(a,b,c,d){return p(b)(a,c,d)};var p=function(a){return m(a,o)};f.reduce=function(a,b,c,d){f.eachSeries(a,function(a,d){c(b,a,function(a,c){b=c,d(a)})},function(a){d(a,b)})},f.inject=f.reduce,f.foldl=f.reduce,f.reduceRight=function(a,b,c,d){var e=h(a,function(a){return a}).reverse();f.reduce(e,b,c,d)},f.foldr=f.reduceRight;var q=function(a,b,c,d){var e=[];b=h(b,function(a,b){return{index:b,value:a}}),a(b,function(a,b){c(a.value,function(c){c&&e.push(a),b()})},function(){d(h(e.sort(function(a,b){return a.index-b.index}),function(a){return a.value}))})};f.filter=l(q),f.filterSeries=n(q),f.select=f.filter,f.selectSeries=f.filterSeries;var r=function(a,b,c,d){var e=[];b=h(b,function(a,b){return{index:b,value:a}}),a(b,function(a,b){c(a.value,function(c){c||e.push(a),b()})},function(){d(h(e.sort(function(a,b){return a.index-b.index}),function(a){return a.value}))})};f.reject=l(r),f.rejectSeries=n(r);var s=function(a,b,c,d){a(b,function(a,b){c(a,function(c){c?(d(a),d=function(){}):b()})},function(){d()})};f.detect=l(s),f.detectSeries=n(s),f.some=function(a,b,c){f.each(a,function(a,d){b(a,function(a){a&&(c(!0),c=function(){}),d()})},function(){c(!1)})},f.any=f.some,f.every=function(a,b,c){f.each(a,function(a,d){b(a,function(a){a||(c(!1),c=function(){}),d()})},function(){c(!0)})},f.all=f.every,f.sortBy=function(a,b,c){f.map(a,function(a,c){b(a,function(b,d){b?c(b):c(null,{value:a,criteria:d})})},function(a,b){if(a)return c(a);var d=function(a,b){var c=a.criteria,d=b.criteria;return d>c?-1:c>d?1:0};c(null,h(b.sort(d),function(a){return a.value}))})},f.auto=function(a,b){b=b||function(){};var c=j(a);if(!c.length)return b(null);var d={},e=[],h=function(a){e.unshift(a)},k=function(a){for(var b=0;bb;b++)a[b].apply(null,arguments)}])))};return e.memo=c,e.unmemoized=a,e},f.unmemoize=function(a){return function(){return(a.unmemoized||a).apply(null,arguments)}},f.times=function(a,b,c){for(var d=[],e=0;a>e;e++)d.push(e);return f.map(d,b,c)},f.timesSeries=function(a,b,c){for(var d=[],e=0;a>e;e++)d.push(e);return f.mapSeries(d,b,c)},f.compose=function(){var a=Array.prototype.reverse.call(arguments);return function(){var b=this,c=Array.prototype.slice.call(arguments),d=c.pop();f.reduce(a,c,function(a,c,d){c.apply(b,a.concat([function(){var a=arguments[0],b=Array.prototype.slice.call(arguments,1);d(a,b)}]))},function(a,c){d.apply(b,[a].concat(c))})}};var w=function(a,b){var c=function(){var c=this,d=Array.prototype.slice.call(arguments),e=d.pop();return a(b,function(a,b){a.apply(c,d.concat([b]))},e)};if(arguments.length>2){var d=Array.prototype.slice.call(arguments,2);return c.apply(this,d)}return c};f.applyEach=l(w),f.applyEachSeries=n(w),f.forever=function(a,b){function c(d){if(d){if(b)return b(d);throw d}a(c)}c()},"undefined"!=typeof c&&c.amd?c([],function(){return f}):"undefined"!=typeof d&&d.exports?d.exports=f:b.async=f}();var e=d.exports;return function(){function a(a,b,c){var d=parseInt(a,10);return!isNaN(d)&&d>=b&&c>=d}function c(b){var c=0;if("string"==typeof b){var d=b.split(":");valid=2===d.length||3===d.length,valid&&(valid=a(d[0],0,23),c+=60*parseInt(d[0],10)*60),valid&&(valid=a(d[1],0,59),c+=60*parseInt(d[1],10)),valid&&3===d.length&&(valid=a(d[2],0,59),c+=parseInt(d[2],10))}return c}function e(a,b,d,e){function f(a,b,c){var d=parseInt(b,10),e=parseInt(c,10);return isNaN(d)||isNaN(e)?!1:"is equal to"===a?d===e:"is less than"===a?e>d:"is greater than"===a?d>e:!1}var l=a.type,m=a.fieldOptions?a.fieldOptions:{},n=!0;if("is equal to"===e)n=f("is equal to",b,d);else if("is greater than"===e)n=f("is greater than",b,d);else if("is less than"===e)n=f("is less than",b,d);else if("is at"===e){if(n=!1,l===h)switch(m.definition.datetimeUnit){case i:try{n=new Date(new Date(b).toDateString()).getTime()==new Date(new Date(d).toDateString()).getTime()}catch(o){n=!1}break;case j:n=c(b)===c(d);break;case k:try{n=new Date(b).getTime()==new Date(d).getTime()}catch(o){n=!1}break;default:n=!1}}else if("is before"===e){if(n=!1,l===h)switch(m.definition.datetimeUnit){case i:try{n=new Date(new Date(b).toDateString()).getTime()new Date(new Date(d).toDateString()).getTime()}catch(o){n=!1}break;case j:n=c(b)>c(d);break;case k:try{n=new Date(b).getTime()>new Date(d).getTime()}catch(o){n=!1}break;default:n=!1}}else n="is"===e?l===g?b&&b.selections&&-1!==b.selections.indexOf(d):b===d:"is not"===e?l===g?b&&b.selections&&-1===b.selections.indexOf(d):b!==d:"contains"===e?-1!==b.indexOf(d):"does not contain"===e?-1===b.indexOf(d):"begins with"===e?b.substring(0,d.length)===d:"ends with"===e?b.substring(Math.max(0,b.length-d.length),b.length)===d:!1;return n}var f=b("async"),g="checkboxes",h="dateTime",i="date",j="time",k="datetime",l=function(b){function c(a){f.each(Y.pages,function(a,b){f.each(a.fields,function(b,c){return b.pageId=a._id,b.fieldOptions=b.fieldOptions?b.fieldOptions:{},b.fieldOptions.definition=b.fieldOptions.definition?b.fieldOptions.definition:{},b.fieldOptions.validation=b.fieldOptions.validation?b.fieldOptions.validation:{},Z[b._id]=b,b.required&&($[b._id]={field:b,submitted:!1,validated:!1}),c()},function(){return b()})},a)}function d(a){f.each(Y.fieldRules,function(a,b){f.each(a.ruleConditionalStatements,function(b,c){var d=b.sourceField;return ab[d]=ab[d]||[],ab[d].push(a),c()},function(){return bb[a.targetField]=bb[a.targetField]||[],bb[a.targetField].push(a),b()})},a)}function g(a){f.each(Y.pageRules,function(a,b){a._id;f.each(a.ruleConditionalStatements,function(b,c){var d=b.sourceField;return cb[d]=cb[d]||[],cb[d].push(a),c()},function(){return db[a.targetPage]=db[a.targetPage]||[],db[a.targetPage].push(a),b()})},a)}function h(a){_=JSON.parse(JSON.stringify($)),eb={},f.each(X.formFields,function(a,b){return a.fieldId?(eb[a.fieldId]=a,b()):b(new Error("No fieldId in this submission entry: "+util.inspect(a)))},a)}function l(a){return W?a():void f.parallel([c,d,g],function(b){return b?a(b):(W=!0,a())})}function m(a,b){l(function(c){return c?b(c):(X=a,void h(b))})}function n(a,b,c){return b&&b.formFields?void f.filter(b.formFields,function(b,c){return c(b.fieldId.toString()==a.fieldId.toString())},function(a){var b=null;return a&&a[0]&&a[0].fieldValues&&(b=a[0].fieldValues),c(void 0,b)}):c()}function o(a,b,c){"function"==typeof b&&(c=b,b=null),l(function(d){return d?c(d):void m(a,function(a){return a?c(a):void f.waterfall([function(a){return a(void 0,{validation:{valid:!0}})},function(a,c){p(a,b,c)},q],function(a,b){return a?c(a):c(void 0,b)})})})}function p(a,b,c){f.each(X.formFields,function(c,d){var e=c.fieldId,f=Z[e];n(c,b,function(b,g){return b?d(b):void u(c,f,g,function(b,c){return b?d(b):(c.valid||(a.validation.valid=!1,a.validation[e]=c),d())})})},function(b){return b?c(b):c(void 0,a)})}function q(a,b){f.each(Object.keys(_),function(b,c){var d={}; -return _[b].submitted?c():void U(b,!0,function(e,f){return e?c(e):(f&&(d.fieldId=b,d.valid=!1,d.fieldErrorMessage=["Required Field Not Submitted"],a.validation[b]=d,a.validation.valid=!1),c())})},function(c){return c?b(c):b(void 0,a)})}function r(a,b,c){l(function(d){return d?c(d):void m(b,function(b){if(b)return c(b);var d=eb[a],e=Z[a];u(d,e,null,function(b,d){if(b)return c(b);var e={validation:{}};return e.validation[a]=d,c(void 0,e)})})})}function s(a,b,c,d){function e(b,c){var d={errorMessages:[]};return b&&d.errorMessages.push(b),t(a,d,function(b,d){if(b)return c(b);var e={validation:{}};return e.validation[a]=d,c(void 0,e)})}"function"==typeof c&&(d=c,c=0),l(function(f){if(f)return d(f);var g=Z[a],h=!1;h=g.repeating&&g.fieldOptions&&g.fieldOptions.definition&&g.fieldOptions.definition.minRepeat?c0;return d?c(void 0,null):c(void 0,"No value submitted for field "+b.name)}function g(a,b){var c=0;if(a&&a.fieldValues&&a.fieldValues.length>0)for(var d=0;db.fieldOptions.definition.maxRepeat)return c(void 0,"Expected max of "+b.fieldOptions.definition.maxRepeat+" values for field "+b.name+" but got "+a)}else if(a>1)return c(void 0,"Should not have multiple values for non-repeating field");return c(void 0,null)}function i(a,b,c,d){w(b.type,function(e,g){return e?d(e):void f.map(a.fieldValues,function(a,d){return y(a)?d(void 0,null):void g(a,b,c,function(a){var c;return c=a?a.message||"Error during validation of field":null,_[b._id]&&(_[b._id].submitted=!0),d(void 0,c)})},function(a,b){return a?d(a):d(void 0,b)})})}"function"==typeof c&&(d=c,c=null),g(a,function(g,j){return g?d(g):void f.series({valuesSubmitted:f.apply(e,a,b),repeats:f.apply(h,j,b),values:f.apply(i,a,b,c)},function(a,b){if(a)return d(a);var c=[];return b.valuesSubmitted&&c.push(b.valuesSubmitted),b.repeats&&c.push(b.repeats),d(void 0,{fieldErrorMessage:c,errorMessages:b.values})})})}function A(a){var b,c,d,e="^",f="c".charCodeAt(0),g="n".charCodeAt(0),h=a.length;for(b=0;h>b;b+=1){switch(c=a.charCodeAt(b)){case f:d="[a-zA-Z0-9]";break;case g:d="[0-9]";break;default:var i=c.toString(16).toUpperCase();d="\\u"+("0000"+i).substr(-4)}e+=d}return e+"$"}function B(a,b){var c=new RegExp(b);return c.test(a)}function C(a,b,c){var d;return d="simple"===b?A(c):"regex"===b?c:A(c),B(a,d)}function D(a,b,c,d){if("string"!=typeof a)return d(new Error("Expected string but got "+typeof a));var e={};b&&b.fieldOptions&&b.fieldOptions.validation&&(e=b.fieldOptions.validation);var f=e.field_format_mode||"";f=f.trim();var g=e.field_format_string||"";return g=g.trim(),g&&g.length>0&&f&&f.length>0&&!C(a,f,g)?d(new Error("field value in incorrect format, expected format: "+g+" but submission value is: "+a)):b.fieldOptions&&b.fieldOptions.validation&&b.fieldOptions.validation.min&&a.lengthb.fieldOptions.validation.max?d(new Error("Expected maximum string length of "+b.fieldOptions.validation.max+" but submission is "+a.length+". Submitted val: "+a)):d()}function E(a,b,c,d){var e=a-0,f=e==a;return f?F(e,b,c,d):d(new Error("Expected numeric but got: "+a))}function F(a,b,c,d){return"number"!=typeof a?d(new Error("Expected number but got "+typeof a)):b.fieldOptions&&b.fieldOptions.validation&&b.fieldOptions.validation.min&&ab.fieldOptions.validation.max?d(new Error("Expected maximum Number "+b.fieldOptions.validation.max+" but submission is "+a+". Submitted number: "+a)):d()}function G(a,b,c,d){return"string"!=typeof a?d(new Error("Expected string but got "+typeof a)):null===a.match(/[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+\.[a-zA-Z]{2,4}/g)?d(new Error("Invalid email address format: "+a)):d()}function H(a,b,c,d){return"string"!=typeof a?d(new Error("Expected submission to be string but got "+typeof a)):b.fieldOptions.definition.options?void f.some(b.fieldOptions.definition.options,function(b,c){return c(b.label===a)},function(b){return b?d():d(new Error("Invalid option specified: "+a))}):d(new Error("No options exist for field "+b.name))}function I(a,b,c,d){var e;b&&b.fieldOptions&&b.fieldOptions.validation&&(e=b.fieldOptions.validation.min);var g;if(b&&b.fieldOptions&&b.fieldOptions.validation&&(g=b.fieldOptions.validation.max),e&&(null===a.selections||void 0===a.selections||a.selections.lengthg)return d(new Error("Expected a maximum number of selections "+g+" but got "+a.selections.length));var i=[];f.eachSeries(b.fieldOptions.definition.options,function(a,b){for(var c in a)i.push(a[c]);return b()},function(){f.eachSeries(a.selections,function(a,b){return"string"!=typeof a?b(new Error("Expected checkbox submission to be string but got "+typeof a)):-1===i.indexOf(a)?b(new Error("Checkbox Option "+a+" does not exist in the field.")):b()},d)})}function J(a,b,c,d){return a.lat&&a["long"]?isNaN(parseFloat(a.lat))||isNaN(parseFloat(a["long"]))?d(new Error("Invalid latitude and longitude values")):d():d(new Error("Invalid object for locationMap submission"))}function K(a,b,c,d){function e(a,b){if("string"!=typeof a.zone||0===a.zone.length)return b(new Error("Invalid zone definition for northings and eastings location. "+a.zone));var c=parseInt(a.eastings,10);if(isNaN(c))return b(new Error("Invalid eastings definition for northings and eastings location. "+a.eastings));var d=parseInt(a.northings,10);return isNaN(d)?b(new Error("Invalid northings definition for northings and eastings location. "+a.northings)):b()}return"latlong"===b.fieldOptions.definition.locationUnit?a.lat&&a["long"]?isNaN(parseFloat(a.lat))||isNaN(parseFloat(a["long"]))?d(new Error("Invalid latitude and longitude values")):d():d(new Error("Invalid object for latitude longitude submission")):a.zone&&a.eastings&&a.northings?e(a,d):d(new Error("Invalid object for northings easting submission. Zone, Eastings and Northings elemets are required"))}function L(a,b,c,d){P(a,b,c,function(e){return e?void N(a,b,c,function(e){return e?void O(a,b,c,function(a){return a?d(a):d()}):d()}):d()})}function M(a,b,c,d){a=a||{};var e=a.fieldOptions||{},f=e.definition||{},g=f.file_size||null;if(null!==g){var h=b[c],i=1;return h>1e3&&(i=h/1e3),console.log("Comparing File Size: ",g,h),h>1e3*g?d(new Error("File size is too large. File can be a maximum of "+g+"KB. Size of file selected: "+i+"KB")):d()}return d()}function N(a,b,c,d){if("object"!=typeof a)return d(new Error("Expected object but got "+typeof a));var e=[{keyName:"fileName",valueType:"string"},{keyName:"fileSize",valueType:"number"},{keyName:"fileType",valueType:"string"},{keyName:"fileUpdateTime",valueType:"number"},{keyName:"hashName",valueType:"string"}];f.each(e,function(b,c){var d=typeof a[b.keyName];return d!==b.valueType?c(new Error("Expected "+b.valueType+" but got "+d)):"fileName"===b.keyName&&a[b.keyName].length<=0?c(new Error("Expected value for "+b.keyName)):c()},function(e){return e?d(e):void M(b,a,"fileSize",function(b){return b?d(b):a.hashName.indexOf("filePlaceHolder")>-1?d():c&&c.hashName&&c.hashName.indexOf(a.hashName)>-1?d():d(new Error("Invalid file placeholder text"+a.hashName))})})}function O(a,b,c,d){if("function"!=typeof File)return d(new Error("Expected File object but got "+typeof a));var e=[{keyName:"name",valueType:"string"},{keyName:"size",valueType:"number"}];f.each(e,function(b,c){var d=typeof a[b.keyName];return d!==b.valueType?c(new Error("Expected "+b.valueType+" but got "+d)):"string"===d&&a[b.keyName].length<=0?c(new Error("Expected value for "+b.keyName)):"number"===d&&a[b.keyName]<=0?c(new Error("Expected > 0 value for "+b.keyName)):c()},function(c){return c?d(c):void M(b,a,"size",function(a){return a?d(a):d()})})}function P(a,b,c,d){return"string"!=typeof a?d(new Error("Expected base64 string but got "+typeof a)):a.length<=0?d(new Error("Expected base64 string but was empty")):d()}function Q(b,c,d,e){var f,g=!1,h=[];if("string"!=typeof b)return e(new Error("Expected string but got "+typeof b));switch(c.fieldOptions.definition.datetimeUnit){case i:h=b.split("/"),g=3===h.length,g&&(g=a(h[2],1,31)),g&&(g=a(h[1],1,12)),g&&(g=a(h[0],1e3,9999));try{f=g?new Date(h[3],h[1],h[0]):new Date(b),g="Invalid Date"!==f.toString()}catch(l){g=!1}return g?e():e(new Error("Invalid date value "+b+". Date format is YYYY/MM/DD"));case j:return h=b.split(":"),g=2===h.length||3===h.length,g&&(g=a(h[0],0,23)),g&&(g=a(h[1],0,59)),g&&3===h.length&&(g=a(h[2],0,59)),g?e():e(new Error("Invalid time value "+b+". Time format is HH:MM:SS"));case k:h=b.split(/[- :]/),g=6===h.length||5===h.length,g&&(g=a(h[2],1,31)),g&&(g=a(h[1],1,12)),g&&(g=a(h[0],1e3,9999)),g&&(g=a(h[3],0,23)),g&&(g=a(h[4],0,59)),g&&6===h.length?g=a(h[5],0,59):h[5]=0;try{f=g?new Date(h[0],h[1],h[2],h[3],h[4],h[5]):new Date(b),g="Invalid Date"!==f.toString()}catch(l){g=!1}return g?e():e(new Error("Invalid dateTime string "+b+". dateTime format is YYYY/MM/DD HH:MM:SS"));default:return e(new Error("Invalid dateTime fieldtype "+c.fieldOptions.definition.datetimeUnit))}}function R(a,b,c,d){return d(new Error("Should not submit section field: "+b.name))}function S(a,b){var c=!0;f.each(a,function(a,b){var d=[],g=[];f.each(a.ruleConditionalStatements,function(a,b){var c,f,h=Z[a.sourceField],i=!1,j=[];return eb[a.sourceField]&&eb[a.sourceField].fieldValues&&(j=eb[a.sourceField].fieldValues,c=a.restriction,f=a.sourceValue,i=e(h,j[0],f,c)),d.push({field:h,submissionValues:j,condition:c,testValue:f,passed:i}),i&&g.push(h),b()},function(e){function f(a,b,c){return"and"===a&&b.length==c.length||"or"===a&&b.length>0}return e&&b(e),c=f(a.ruleConditionalOperator,g,d)?"show"===a.type:"show"!==a.type,b()})},function(a){return a?b(a):b(void 0,c)})}function T(a,b){l(function(c){return c?b(c):ib(a)?S(db[a],b):b(void 0,!0)})}function U(a,b,c){l(function(d){if(d)return c(d);var e=Z[a];return a?void f.waterfall([function(a){return b?void T(e.pageId,a):a(void 0,!0)},function(b,c){return b?hb(a)?S(bb[a],c):c(void 0,!0):c(void 0,!1)}],c):c(new Error("Field does not exist in form"))})}function V(a,b){l(function(c){return c?b(c):void m(a,function(a){if(a)return b(a);var c={};f.parallel([function(a){c.fields={},f.eachSeries(Object.keys(bb),function(a,b){U(a,!1,function(d,e){return d?b(d):(c.fields[a]={targetId:a,action:e?"show":"hide"},b())})},a)},function(a){c.pages={},f.eachSeries(Object.keys(db),function(a,b){T(a,function(d,e){return d?b(d):(c.pages[a]={targetId:a,action:e?"show":"hide"},b())})},a)}],function(a){return a?b(a):b(void 0,{actions:c})})})})}var W,X,Y=b,Z={},$={},_={},ab={},bb={},cb={},db={},eb={},fb={text:D,textarea:D,number:E,emailAddress:G,dropdown:H,radio:H,checkboxes:I,location:K,locationMap:J,photo:N,signature:N,file:N,dateTime:Q,url:D,sectionBreak:R},gb={text:D,textarea:D,number:E,emailAddress:G,dropdown:H,radio:H,checkboxes:I,location:K,locationMap:J,photo:L,signature:L,file:L,dateTime:Q,url:D,sectionBreak:R},hb=function(a){return!!bb[a]},ib=function(a){return!!db[a]};return{validateForm:o,validateField:r,validateFieldValue:s,checkRules:V,validateFieldInternal:z,initSubmission:m,isFieldVisible:U,isConditionActive:e}};"undefined"!=typeof d&&d.exports&&(d.exports=l)}(),d.exports(a)}var b=function(a){function c(a,c){var d={updateForms:!0};if("undefined"==typeof c)c=a;else for(var e in a)d[e]=a[e];var f=d.config||{};b.config=b.models.config,b.config.init(f,function(a){a&&$fh.forms.log.e("Form config loading error: ",a),b.models.log.loadLocal(function(a){a&&console.error("Error loading config from local storage"),b.models.uploadManager.loadLocal(function(a){$fh.forms.log.d("Upload Manager loaded from memory."),a&&$fh.forms.log.e("Error loading upload manager from memory ",a),b.models.uploadManager.start(),$fh.forms.log.l("Refreshing Theme."),b.models.theme.refresh(!0,function(a){a&&$fh.forms.log.e("Error refreshing theme ",a),d.updateForms===!0?($fh.forms.log.l("Refreshing Forms."),b.models.forms.refresh(!0,function(a){a&&$fh.forms.log.e("Error refreshing forms: ",a),c()})):c()})})})})}return a.init=c,a}(b||{});b.utils=function(a){function b(){var a=-1===document.URL.indexOf("http://")&&-1===document.URL.indexOf("https://");return a?!0:!1}function c(a,b){if(b.constructor&&b.constructor===Function)for(var c in b.prototype)a.prototype[c]=b.prototype[c];else for(var d in b)a.prototype[d]=b[d]}function d(a){var b=new Date;return a?b.getTimezoneOffset():b}function e(a){var b=a.getProps(),c=b._id,e=b._type,f=d().getTime();return c&&e?c+"_"+e+"_"+f:c?c+"_"+f:e?e+"_"+f:f}function f(a,b){"undefined"!=typeof $fh&&$fh.hash?$fh.hash({algorithm:"MD5",text:a},function(a){a&&a.hashvalue?b(null,a.hashvalue):b("Crypto failed.")}):b("Crypto not found")}function g(a,b){$fh.forms.log.d("Sending mail: ",a),$fh.send(a,function(){b(null)},function(a){b(a)})}return a.extend=c,a.localId=e,a.md5=f,a.getTime=d,a.send=g,a.isPhoneGap=b,a}(b.utils||{}),b.utils=function(a){function c(){return o(),p}function d(a,b){if(!a instanceof File)throw"Only file object can be used for converting";var c=new FileReader;c.onloadend=function(a){var c=a.target.result;return b(null,c)},c.readAsDataURL(a)}function e(a){var c;if(b.utils.isPhoneGap())c=a;else{var d="text/plain";try{c=new Blob([a],{type:d})}catch(e){var f=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if("TypeError"===e.name&&f){var g=new f;g.append([a.buffer]),c=g.getBlob(d)}else c=a}}return c}function f(a,b,c){var d=null,f=0;if("object"==typeof b)if(b instanceof File)d=b,f=d.size;else if(b instanceof Blob)d=b,f=d.size;else{var g=JSON.stringify(b);d=e(g),f=d.size||d.length}else"string"==typeof b&&(d=e(b),f=d.size||d.length);m(a,f,{create:!0},function(a,b){a?c(a):b.createWriter(function(a){function b(a){return c(null,a)}function e(){a.onwriteend=b,a.write(d)}a.onwriteend=e,a.truncate(0)},function(a){console.error("fileEntry.createWriter Failed to create file write: "+a),c("Failed to create file write:"+a)})})}function g(a,b){m(a,0,{},function(a,c){return a?"NotFoundError"!==a.name&&1!==a.code?b(a):b(null,null):void c.remove(function(){b(null,null)},function(a){console.error("file remove fileEntry.remove failed "+a),b("Failed to remove file"+a)})})}function h(a,b){l(a,function(a,c){if(a)b(a);else{var d=new FileReader;d.onloadend=function(a){var c=a.target.result;try{c=decodeURIComponent(c)}catch(d){}return b(null,c)},d.readAsText(c)}})}function i(a,b){l(a,function(a,c){if(a)return b(a);var d=new FileReader;d.onloadend=function(a){var c=a.target.result;return b(null,c)},d.readAsDataURL(c)})}function j(a,b){l(a,function(a,c){if(a)return b(a);var d=c.type,e=new FileReader;e.onloadend=function(a){var c=a.target.result,e=new Blob([c],{type:d});b(null,e)},e.readAsArrayBuffer(c)})}function k(a,b){l(a,b)}function l(a,b){m(a,0,{},function(a,c){return a?b(a):void c.file(function(a){b(null,a)},function(a){console.error("Failed to get file:"+a),b(a)})})}function m(a,b,c,d){o(),q(r,b,function(e){e.root.getFile(a,c,function(a){d(null,a)},function(e){if("QuotaExceededError"===e.name||10===e.code){var f=1073741824;n(f,function(){m(a,b,c,d)})}else d(e)})},function(){console.error("Failed to requestFileSystem: "+a),d("Failed to requestFileSystem")})}function n(a,b){navigator.webkitPersistentStorage?navigator.webkitPersistentStorage.requestQuota(a,function(a){b(null,a)},function(a){b(a,0)}):b(null,a)}function o(){window.requestFileSystem?(q=window.requestFileSystem,p=!0):window.webkitRequestFileSystem?(q=window.webkitRequestFileSystem,p=!0):p=!1,window.LocalFileSystem?r=window.LocalFileSystem.PERSISTENT:window.PERSISTENT&&(r=window.PERSISTENT)}a.fileSystem={isFileSystemAvailable:c,save:f,remove:g,readAsText:h,readAsBlob:j,readAsBase64Encoded:i,readAsFile:k,fileToBase64:d};var p=!1,q=function(){console.error("No file system available")},r=1;return o(),a}(b.utils||{}),b.utils=function(a){function b(){return i(),m}function c(){return i(),l}function d(a,b){i(),h(a,b)}function e(){q&&(q.stop(),q=null)}function f(a,b){a=a||{},$fh.forms.log.d("Taking photo ",a,l);var c=a.targetWidth?a.targetWidth:$fh.forms.config.get("targetWidth",640),d=a.targetHeight?a.targetHeight:$fh.forms.config.get("targetHeight",480),e=a.quality?a.quality:$fh.forms.config.get("quality",50);a.targetWidth=c,a.targetHeight=d,a.quality=e,"undefined"==typeof a.sourceType&&"undefined"!=typeof Camera&&(a.sourceType=Camera.PictureSourceType.CAMERA),l?navigator.camera.getPicture(g(b),b,{quality:e,targetWidth:c,targetHeight:d,sourceType:a.sourceType,saveToPhotoAlbum:!1,destinationType:Camera.DestinationType.DATA_URL,encodingType:Camera.EncodingType.PNG}):m?k(a,b):b("Your device does not support camera.")}function g(a){return function(b){var c="data:image/png;base64,"+b;a(null,c)}}function h(a,b){$fh.forms.log.d("Taking photo _html5Camera",a,l);var c=a.targetWidth||$fh.forms.config.get("targetWidth"),d=a.targetHeight||$fh.forms.config.get("targetHeight");n.width=c,n.height=d,o.width=c,o.height=d,q?($fh.forms.log.e("Media device was not released by browser."),b("Media device occupied.")):navigator.getUserMedia({video:!0},function(a){n.src=window.URL.createObjectURL(a),q=a,b(null,n)},b)}function i(){$fh.forms.log.d("Checking env"),navigator.camera&&navigator.camera.getPicture?l=!0:j()?(m=!0,n=document.createElement("video"),n.autoplay="autoplay",o=document.createElement("canvas"),p=o.getContext("2d")):console.error("Cannot detect usable media API. Camera will not run properly on this device.")}function j(){return navigator.getUserMedia?!0:navigator.webkitGetUserMedia?(navigator.getUserMedia=navigator.webkitGetUserMedia,!0):navigator.mozGetUserMedia?(navigator.getUserMedia=navigator.mozGetUserMedia,!0):navigator.msGetUserMedia?(navigator.getUserMedia=navigator.msGetUserMedia,!0):!1}function k(a,b){if($fh.forms.log.d("Snapshot ",a),q){p.drawImage(n,0,0,a.targetWidth,a.targetHeight);var c=o.toDataURL("image/png");e(),b(null,c)}else $fh.forms.log.e("Media resource is not available"),b("Resource not available")}a.takePhoto=f,a.isPhoneGapCamAvailable=c,a.isHtml5CamAvailable=b,a.initHtml5Camera=d,a.cancelHtml5Camera=e;var l=!1,m=!1,n=null,o=null,p=null,q=null;return a}(b.utils||{}),b.web=function(a){return a.uploadFile=function(a,b,c){$fh.forms.log.d("Phonegap uploadFile ",a,b);var d=b.fullPath;if(!$fh.forms.config.isOnline())return $fh.forms.log.e("Phonegap uploadFile. Not Online.",a,b),c("No Internet Connection Available.");var e=function(b){$fh.forms.log.d("upload to url ",a," sucessful"),b.response=b.response||{},"string"==typeof b.response&&(b.response=JSON.parse(b.response)),c(null,b.response)},f=function(a){$fh.forms.log.e("An error uploading a file has occurred: Code = "+a.code),$fh.forms.log.d("upload error source "+a.source),$fh.forms.log.d("upload error target "+a.target),c(a)},g=new FileUploadOptions;g.fileName=b.name,g.mimeType=b.contentType?b.contentType:"application/octet-stream",g.httpMethod="https",g.chunkedMode=!0,g.fileKey="file",g.headers={Connection:"close"},$fh.forms.log.d("Beginning file upload ",a,g);var h=new FileTransfer;h.upload(d,encodeURI(a),e,f,g)},a.downloadFile=function(a,b,c){$fh.forms.log.d("Phonegap downloadFile ",a,b);var d=new FileTransfer;return $fh.forms.config.isOnline()?void appforms.utils.fileSystem.getBasePath(function(e,f){function g(a){return $fh.forms.log.d("File Download Completed Successfully. FilePath: "+a.fullPath),c(null,a.fullPath)}function h(a){return $fh.forms.log.e("Error downloading file "+b.fileName+" code: "+a.code),c("Error downloading file "+b.fileName+" code: "+a.code)}if(e)return $fh.forms.log.e("Error getting base path for file download: "+a),c(e);if(!b.fileName)return $fh.forms.log.e("No file name associated with the file to download"),c("No file name associated with the file to download");$fh.forms.log.d("File name for file "+b.fileName+" found. Starting download");var i=f+b.fileName;d.download(encodeURI(a),i,g,h,{headers:{Connection:"close"}})}):($fh.forms.log.e("Phonegap downloadFile. Not Online.",a,b),c("No Internet Connection Available."))},a}(b.web||{}),b.web.ajax=function(a){function b(){}function c(a,b){$fh.forms.log.d("Ajax get ",a),e({url:a,type:"GET",dataType:"json",success:function(c){$fh.forms.log.d("Ajax get",a,"Success"),b(null,c)},error:function(c,d,e){$fh.forms.log.e("Ajax get",a,"Fail",c,d,e),b(c)}})}function d(a,b,c){$fh.forms.log.d("Ajax post ",a,b);var d,f=!1;if("object"==typeof b)if(b instanceof File){f=!0,d=new FormData;var g=b.name;d.append(g,b),b=d}else b=JSON.stringify(b);var h={url:a,type:"POST",data:b,dataType:"json",success:function(b){$fh.forms.log.d("Ajax post ",a," Success"),c(null,b)},error:function(b,d,e){$fh.forms.log.e("Ajax post ",a," Fail ",b,d,e),c(b)}};f===!1&&(h.contentType="application/json"),e(h)}a="undefined"!=typeof $fh&&$fh.__ajax?$fh.__ajax:b,a.get=c,a.post=d;var e=a;return a}(b.web.ajax||{}),b.stores=function(a){function b(a){this.name=a}return a.Store=b,b.prototype.create=function(){throw"Create not implemented:"+this.name},b.prototype.read=function(){throw"Read not implemented:"+this.name},b.prototype.update=function(){throw"Update not implemented:"+this.name},b.prototype["delete"]=function(){throw"Delete not implemented:"+this.name},b.prototype.upsert=function(){throw"Upsert not implemented:"+this.name},a}(b.stores||{}),b.stores=function(a){function c(){b.stores.Store.call(this,"LocalStorage")}function d(){i()?f.apply({},arguments):e.apply({},arguments)}function e(a,b,c){return $fh&&$fh.data?void $fh.data(a,function(c){return"undefined"==typeof c&&(c={key:a.key,val:a.val}),"remove"===a.act.toLowerCase()?b(null,null):void b(null,c.val?c.val:null)},c):b()}function f(a,c,d){function e(a){return"undefined"!=typeof d?d(a,{}):void 0}function f(a,c){var d=b.config.get("appId","unknownAppId");a+=d,g.md5(a,function(b,d){b&&(d=a);var e=d+".txt";return"undefined"==typeof navigator.externalstorage?c(e):void navigator.externalstorage.enable(function(a){var b=e;return a.path&&(b=a.path,b.match(/\/$/)||(b+="/"),b+=e),e=b,c(e)},function(){return c(e)})})}function i(a,b){f(a,function(a){h.save(a,b,function(a){a?e(a):c(null,b)})})}function j(a){f(a,function(a){h.remove(a,function(a){a?"NotFoundError"===a.name||1===a.code?c(null,null):e(a):c(null,null)})})}function k(a){f(a,function(a){h.readAsText(a,function(a,b){a?"NotFoundError"===a.name||1===a.code?c(null,null):e(a):c(null,b)})})}return"undefined"==typeof a.act?k(a.key):"save"===a.act?i(a.key,a.val):"remove"===a.act?j(a.key):"load"===a.act?k(a.key):"undefined"!=typeof d?d("Action ["+a.act+"] is not defined",{}):void 0}var g=b.utils,h=g.fileSystem,i=function(){};return b.utils.extend(c,b.stores.Store),c.prototype.create=function(a,b){var c=g.localId(a);a.setLocalId(c),this.update(a,b)},c.prototype.read=function(a,b){if("offlineTest"===a.get("_type"))b(null,{});else{var c=a.getLocalId();null!=c?d({act:"load",key:c.toString()},b,b):b(null,null)}},c.prototype.update=function(a,b){var c=a.getLocalId(),e=a.getProps(),f=JSON.stringify(e);d({act:"save",key:c.toString(),val:f},b,b)},c.prototype["delete"]=function(a,b){var c=a.getLocalId();d({act:"remove",key:c.toString()},b,b)},c.prototype.upsert=function(a,b){var c=a.getLocalId();null===c?this.create(a,b):this.update(a,b)},c.prototype.switchFileSystem=function(a){i=function(){return a}},c.prototype.defaultStorage=function(){i=function(){return h.isFileSystemAvailable()}},i=function(){return h.isFileSystemAvailable()},a.localStorage=new c,a}(b.stores||{}),b.stores=function(a){function c(){e.call(this,"MBaaS")}function d(a){$fh.forms.log.d("_getUrl ",a);var c=a.get("_type"),d=b.config.get("cloudHost"),e=b.config.get("mbaasBaseUrl"),f=b.config.get("formUrls"),g="";f[c]?g=f[c]:$fh.forms.log.e("type not found to get url:"+c);var h=d+e+g,i={};switch(i.appId=b.config.get("appId"),c){case"config":i.appid=a.get("appId"),i.deviceId=a.get("deviceId");break;case"form":i.formId=a.get("_id");break;case"formSubmission":i.formId=a.getFormId();break;case"fileSubmission":i.submissionId=a.getSubmissionId(),i.hashName=a.getHashName(),i.fieldId=a.getFieldId();break;case"base64fileSubmission":i.submissionId=a.getSubmissionId(),i.hashName=a.getHashName(),i.fieldId=a.getFieldId();break;case"submissionStatus":i.submissionId=a.get("submissionId");break;case"completeSubmission":i.submissionId=a.get("submissionId");break;case"formSubmissionDownload":i.submissionId=a.getSubmissionId();break;case"fileSubmissionDownload":i.submissionId=a.getSubmissionId(),i.submissionId=a.getFileGroupId();break;case"offlineTest":return"http://127.0.0.1:8453"}for(var j in i)h=h.replace(":"+j,i[j]);return h}var e=b.stores.Store;return a.mBaaS=new c,b.utils.extend(c,e),c.prototype.checkStudio=function(){return b.config.get("studioMode")},c.prototype.create=function(a,c){var e=this;if(e.checkStudio())c("Studio mode not supported");else{var f=d(a);e.isFileAndPhoneGap(a)?b.web.uploadFile(f,a.getProps(),c):b.web.ajax.post(f,a.getProps(),c)}},c.prototype.isFileAndPhoneGap=function(a){var b=this;return b.isFileTransfer(a)&&b.isPhoneGap()},c.prototype.isFileTransfer=function(a){return"fileSubmission"===a.get("_type")||"base64fileSubmission"===a.get("_type")||"fileSubmissionDownload"===a.get("_type")},c.prototype.isPhoneGap=function(){return"undefined"!=typeof window.Phonegap||"undefined"!=typeof window.cordova},c.prototype.read=function(a,c){var e=this;if(this.checkStudio())c("Studio mode not supported");else if("offlineTest"===a.get("_type"))c("offlinetest. ignore");else{var f=d(a);if(e.isFileTransfer(a)&&e.isPhoneGap())b.web.downloadFile(f,a.getFileMetaData(),c);else{if(e.isFileTransfer(a))return c(null,a.getRemoteFileURL());b.web.ajax.get(f,c)}}},c.prototype.update=function(){},c.prototype["delete"]=function(){},c.prototype.completeSubmission=function(a,c){var e=d(a);b.web.ajax.post(e,{},c)},c.prototype.submissionStatus=function(a,c){var e=d(a);b.web.ajax.get(e,c)},a}(b.stores||{}),b.stores=function(a){function c(a,b){d.call(this,"DataAgent"),this.remoteStore=a,this.localStore=b}var d=b.stores.Store;return a.DataAgent=c,a.dataAgent=new c(b.stores.mBaaS,b.stores.localStorage),b.utils.extend(c,d),c.prototype.read=function(a,b){$fh.forms.log.d("DataAgent read ",a);var c=this;this.localStore.read(a,function(d,e){d||!e?($fh.forms.log.d("Error reading model from localStore ",a,d),c.refreshRead(a,b)):b(null,e,!1)})},c.prototype.refreshRead=function(a,b){$fh.forms.log.d("DataAgent refreshRead ",a);var c=this;this.remoteStore.read(a,function(d,e){d?($fh.forms.log.e("Error reading model from remoteStore ",a,d),b(d)):($fh.forms.log.d("Model refresh successfull from remoteStore ",a,e),a.fromJSON(e),c.localStore.upsert(a,function(){var a=Array.prototype.slice.call(arguments,0);a.push(!0),b.apply({},a)}))})},c.prototype.attemptRead=function(a,b){$fh.forms.log.d("DataAgent attemptRead ",a);var c=this;c.refreshRead(a,function(d){d?c.read(a,b):b.apply({},arguments)})},a}(b.stores||{}),b.models=function(a){function c(a){if(this.props={_id:null,_type:null,_ludid:null},this.utils=b.utils,this.events={},"undefined"!=typeof a)for(var c in a)this.props[c]=a[c];this.touch()}return c.prototype.on=function(a,b){this.events[a]||(this.events[a]=[]),this.events[a].indexOf(b)<0&&this.events[a].push(b)},c.prototype.off=function(a,b){this.events[a]&&this.events[a].indexOf(b)>=0&&this.events[a].splice(this.events[a].indexOf(b),1)},c.prototype.clearEvents=function(){this.events={}},c.prototype.emit=function(){var a=Array.prototype.slice.call(arguments,0),b=a.shift(),c=this.events[b];if(c&&c.length>0)for(var d=0;dc){$fh.forms.log.d("Submissions clearSentSubmission pruning sentSubmissions.length>maxSent"),d=d.sort(function(a,b){return a.submittedDatec;)e.push(d.pop());for(var f=e.length,g=0;g-1&&this.get("submissions").splice(c,1),this.saveLocal(b)},c.prototype.indexOf=function(a){$fh.forms.log.d("Submissions indexOf: ",a);for(var b=this.get("submissions"),c=0;c-1?!0:(this.set("status","error"),!1)},e.prototype.addComment=function(a,c){var d=b.utils.getTime(),e=d.getTime(),f={madeBy:"undefined"==typeof c?"":c.toString(),madeOn:d,value:a,timeStamp:e};return this.getComments().push(f),e},e.prototype.getComments=function(){return this.get("comments")},e.prototype.removeComment=function(a){for(var b=this.getComments(),c=0;c-1?c.tmpFields[d][f]=e:c.tmpFields[d].push(e),b(null,e))});else{var i=c.getInputValueObjectById(d);h.processInput(a,function(a,c){return a?b(a):(f>-1?i.fieldValues[f]=c:i.fieldValues.push(c),b(null,c))})}})},e.prototype.getInputValueByFieldId=function(a,b){var c=this.getInputValueObjectById(a).fieldValues;this.getForm(function(d,e){var f=e.getFieldModelById(a);f.convertSubmission(c,b)})},e.prototype.reset=function(){var a=this;a.clearLocalSubmissionFiles(function(){a.set("formFields",[])})},e.prototype.isDownloadSubmission=function(){return this.get("downloadSubmission")===!0},e.prototype.clearLocalSubmissionFiles=function(a){$fh.forms.log.d("In clearLocalSubmissionFiles");var c=this,d=this.getSubmissionFiles(),e="";e=c.isDownloadSubmission()?"fileName":"fileHash";for(var f in d)b.utils.fileSystem.remove(f[e],function(a){a&&$fh.forms.log.e("Error removing files from "+a)});a()},e.prototype.startInputTransaction=function(){this.transactionMode=!0,this.tmpFields={}},e.prototype.endInputTransaction=function(a){if(this.transactionMode=!1,a){var b=(this.get("formFields"),this.tmpFields);for(var c in b)for(var d=this.getInputValueObjectById(c),e=b[c],f=0;fb&&c.splice(b,1)},e.prototype.getInputValueObjectById=function(a){for(var b=this.get("formFields",[]),c=0;c-1&&d.splice(e,1),this.getTaskById(c,function(a,c){a?($fh.forms.log.e(a),b(a,c)):c?c.clearLocal(b):b(null,null)}),this.saveLocal(function(a){a&&$fh.forms.log.e(a)})}else b(null,null)},c.prototype.getTaskQueue=function(){return this.get("taskQueue",[])},c.prototype.start=function(){var a=this;this.stop(),this.timer=setInterval(function(){a.tick()},this.timerInterval)},c.prototype.stop=function(){this.timer&&(clearInterval(this.timer),this.timer=null)},c.prototype.push=function(a){this.get("taskQueue").push(a),this.saveLocal(function(a){a&&$fh.forms.log.e("Error saving local Upload manager",a)})},c.prototype.shift=function(){var a=this.get("taskQueue").shift();return this.saveLocal(function(a){a&&$fh.forms.log.e(a)}),a},c.prototype.rollTask=function(){this.push(this.shift())},c.prototype.tick=function(){if(this.sending){var a=b.utils.getTime(),c=a.getTime()-this.sendingStart.getTime();c>1e3*$fh.forms.config.get("timeout")&&($fh.forms.log.e("Uploading content timeout. it will try to reupload."),this.sending=!1,this.rollTask())}else if(this.hasTask()){this.sending=!0,this.sendingStart=b.utils.getTime();var d=this;this.getCurrentTask(function(a,b){a||!b?($fh.forms.log.e(a),d.sending=!1):b.isCompleted()||b.isError()?(d.shift(),d.sending=!1,d.saveLocal(function(a){a&&$fh.forms.log.e("Error saving upload manager: ",a)})):$fh.forms.config.isOnline()?b.uploadTick(function(a){a&&$fh.forms.log.e("Error on upload tick: ",a,b),d.sending=!1}):$fh.forms.log.d("Upload Manager: Tick: Not online.")})}else this.stop()},c.prototype.hasTask=function(){return this.get("taskQueue").length>0},c.prototype.getCurrentTask=function(a){var b=this.getTaskQueue()[0];b?this.getTaskById(b,a):a(null,null)},c.prototype.getTaskById=function(a,c){b.models.uploadTask.fromLocal(a,c)},a.uploadManager=new c,a}(b.models||{}),b.models=function(a){function c(a){d.call(this,{_type:"rule"}),this.fromJSON(a)}var d=b.models.Model;return b.utils.extend(c,d),c.prototype.getRelatedFieldId=function(){for(var a=this.getDefinition(),b=a.ruleConditionalStatements,c=[],d=0;df;f++)e+=b.fileSize;return c+e},e.prototype.getRemoteStore=function(){return b.stores.mBaaS},e.prototype.addFileTasks=function(a,b){var c=this;a.getFileInputValues(function(a,d){if(a)return $fh.forms.log.e("Error getting file Input values: "+a),b(a);for(var e=0;e0?e.resetUploadTask(f,function(){a()}):(e.increProgress(),a())}else d="Invalid submission status response.",a(d)})}function d(){a()}var e=this;e.isDownloadTask()?d():c()},e.prototype.resetUploadTask=function(a,b){var c,d=this.get("fileTasks"),e=[];for(c=0;c-1&&e.push(d[c]);var f=d.length-a.length-1,g=0;f>0&&(g=f),this.set("currentTask",g),this.set("fileTasks",e),this.saveLocal(b)},e.prototype.uploadFile=function(a){function c(){$fh.forms.log.d("processUploadFile for submissionId: "),g="base64"===h.contentType?new b.models.Base64FileSubmission(h):new b.models.FileSubmission(h),g.setSubmissionId(i),g.loadFile(function(c){return c?($fh.forms.log.e("Error loading file for upload: "+c),a(c)):void e.getRemoteStore().create(g,function(c,d){if(c)a(c);else if("ok"===d.status||200===d.status||"200"===d.status)h.updateDate=b.utils.getTime(),e.increProgress(),e.saveLocal(function(a){a&&$fh.forms.log.e("Error saving upload task"+a)}),e.emit("progress",e.getProgress()),a(null);else{var f="File upload failed for file: "+h.fileName;a(f)}})})}function d(){$fh.forms.log.d("processDownloadFile called"),g=new b.models.FileSubmissionDownload(h),e.getRemoteStore().read(g,function(b,c){return b?($fh.forms.log.e("Error downloading a file from remote: "+b),a(b)):($fh.forms.log.d("processDownloadFile called. Local File Path: "+c),void e.submissionModel(function(b,d){return b?($fh.forms.log.e("Error Loading submission model for processDownloadFile "+b),a(b)):void d.updateFileLocalURI(h,c,function(b){return b?($fh.forms.log.e("Error updating file local url for fileTask "+JSON.stringify(h)),a(b)):(e.increProgress(),e.saveLocal(function(a){a&&$fh.forms.log.e("Error saving download task")}),e.emit("progress",e.getProgress()),a())})}))})}var e=this,f=e.getCurrentTask();null===f&&(f=0,e.set("currentTask",f));var g,h=e.get("fileTasks",[])[f],i=e.get("submissionId");return h?i?void(e.isDownloadTask()?d():c()):($fh.forms.log.e("No submission id found when trying to transfer a file."),a("No submission Id found")):($fh.forms.log.e("No file task found when trying to transfer a file."),a("cannot find file task"))},e.prototype.isDownloadTask=function(){return"download"===this.get("submissionTransferType")},e.prototype.setRetryNeeded=function(a){null!=this.get("submissionId",null)?this.set("retryNeeded",a):(this.set("retryNeeded",!1),this.set("currentTask",null))},e.prototype.retryNeeded=function(){return this.get("retryNeeded")},e.prototype.uploadTick=function(a){function b(b){b?($fh.forms.log.d("Err, retrying transfer: "+c.getLocalId()),c.increRetryAttempts(),c.getRetryAttempts()<=$fh.forms.config.get("max_retries")?(c.setRetryNeeded(!0),c.saveLocal(function(b){b&&$fh.forms.log.e("Error saving upload taskL "+b),a()})):(c.setRetryNeeded(!0),c.resetRetryAttempts(),c.error(b,function(){a(b)}))):(c.setRetryNeeded(!1),c.saveLocal(function(a){a&&$fh.forms.log.e("Error saving upload task to local memory"+a)}),c.submissionModel(function(b,c){if(b)a(b);else{var d=c.get("status");"inprogress"!==d&&"submitted"!==d&&"downloaded"!==d?($fh.forms.log.e("Submission status is incorrect. Upload task should be started by submission object's upload method."+d),a("Submission status is incorrect. Upload task should be started by submission object's upload method.")):a()}}))}var c=this;this.isFormCompleted()?this.retryNeeded()?this.handleIncompleteSubmission(b):this.isFileCompleted()?this.isMBaaSCompleted()?this.isCompleted()?b(null,null):this.success(b):this.uploadComplete(b):this.uploadFile(b):this.uploadForm(b)},e.prototype.increProgress=function(){var a=this.getCurrentTask();null===a?a=0:a++,this.set("currentTask",a)},e.prototype.uploadComplete=function(a){function c(){$fh.forms.log.d("processDownloadComplete Called"),e.increProgress(),a(null)}function d(){$fh.forms.log.d("processUploadComplete Called");var c=e.getRemoteStore(),d=new b.models.FormSubmissionComplete(e);c.create(d,function(b,c){return c=c||{},"complete"!==c.status?e.handleCompletionError(b,c,a):(e.increProgress(),void a(null))})}$fh.forms.log.d("UploadComplete Called");var e=this,f=e.get("submissionId",null);return null===f?a("Failed to complete submission. Submission Id not found."):void(e.isDownloadTask()?c():d())},e.prototype.success=function(a){function b(){$fh.forms.log.d("processUploadSuccess Called"),d.submissionModel(function(b,c){return b?a(b):(c.set("submissionId",e),void c.submitted(a))})}function c(){$fh.forms.log.d("processDownloadSuccess Called"),d.submissionModel(function(b,c){return b?a(b):void c.downloaded(a)})}$fh.forms.log.d("Transfer Sucessful. Success Called.");var d=this,e=d.get("submissionId",null);d.set("completed",!0),d.saveLocal(function(a){a&&$fh.forms.log.e("Error Clearing Upload Task")}),d.isDownloadTask()?c():b()},e.prototype.error=function(a,b){this.set("error",a),this.saveLocal(function(a){a&&$fh.forms.log.e("Upload task save failed: "+a)}),this.submissionModel(function(c,d){c?b(c):(d.error(a,function(){}),b(a))})},e.prototype.isFormCompleted=function(){var a=this.getCurrentTask();return null===a?!1:!0},e.prototype.isFileCompleted=function(){var a=this.getCurrentTask();return null===a?!1:aa.get("fileTasks",[]).length?!0:!1}return!1},e.prototype.getProgress=function(){var a=this,b={formJSON:!1,currentFileIndex:0,totalFiles:a.get("fileTasks").length,totalSize:a.getTotalSize(),uploaded:a.getUploadedSize(),retryAttempts:a.getRetryAttempts(),submissionTransferType:a.get("submissionTransferType")},c=a.getCurrentTask();return null===c?b:(b.formJSON=!0,b.currentFileIndex=c,b)},e.prototype.refreshForm=function(a,c){var d=this.get("formId");new b.models.Form({formId:d,rawMode:!0,rawData:a},function(b){b&&$fh.forms.log.e(b),$fh.forms.log.l("successfully updated form the form with id "+a._id),c()})},e.prototype.submissionModel=function(a){b.models.submission.fromLocal(this.get("submissionLocalId"),function(b,c){b&&$fh.forms.log.e("Error getting submission model from local memory "+b),a(b,c)})},a}(b.models||{}),b.models=function(a){function c(){d.call(this,{_type:"theme",_ludid:"theme_object"})}var d=b.models.Model;return c.prototype.getCSS=function(){return this.get("css","")},b.utils.extend(c,d),a.theme=new c,a}(b.models||{}),b.models=function(a){function c(){d.call(this,{_type:"log",_ludid:"log"}),this.set("logs",[]),this.isWriting=!1,this.moreToWrite=!1}var d=b.models.Model;return b.utils.extend(c,d),c.prototype.info=function(a){if($fh.forms.config.get("logger")===!0){var b="",c=$fh.forms.config.get("log_level"),d=$fh.forms.config.get("log_levels"),e=this;if("string"==typeof a?(b=a,a=d.indexOf(a.toLowerCase())):a=0,c=isNaN(parseInt(c,10))?c:parseInt(c,10),a=isNaN(parseInt(a,10))?a:parseInt(a,10),a>c)return;var f=Array.prototype.splice.call(arguments,0),g=e.get("logs");f.shift();for(var h="";f.length>0;)h+=JSON.stringify(f.shift())+" ";if(g.push(e.wrap(h,b)),g.length>$fh.forms.config.get("log_line_limit")&&g.shift(),e.isWriting)e.moreToWrite=!0;else{var i=function(){e.moreToWrite&&(e.moreToWrite=!1,e.write(i))};e.write(i)}}},c.prototype.wrap=function(a,b){var c=new Date,d=c.toISOString();"object"==typeof a&&(a=JSON.stringify(a));var e=d+" "+b.toUpperCase()+" "+a;return e},c.prototype.getPolishedLogs=function(){for(var a=[],b=this.getLogs(),c=[{reg:/^.+\sERROR\s.*/,color:$fh.forms.config.get("color_error")||"#FF0000"},{reg:/^.+\sWARNING\s.*/,color:$fh.forms.config.get("color_warning")||"#FF9933"},{reg:/^.+\sLOG\s.*/,color:$fh.forms.config.get("color_log")||"#009900"},{reg:/^.+\sDEBUG\s.*/,color:$fh.forms.config.get("color_debug")||"#3366FF"},{reg:/^.+\sUNKNOWN\s.*/,color:$fh.forms.config.get("color_unknown")||"#000000"}],d=0;d"+e+"");break}}return a},c.prototype.write=function(a){var b=this;b.isWriting=!0,b.saveLocal(function(){b.isWriting=!1,a()})},c.prototype.e=function(){var a=Array.prototype.splice.call(arguments,0);a.unshift("error"),this.info.apply(this,a)},c.prototype.w=function(){var a=Array.prototype.splice.call(arguments,0);a.unshift("warning"),this.info.apply(this,a)},c.prototype.l=function(){var a=Array.prototype.splice.call(arguments,0);a.unshift("log"),this.info.apply(this,a)},c.prototype.d=function(){var a=Array.prototype.splice.call(arguments,0);a.unshift("debug"),this.info.apply(this,a)},c.prototype.getLogs=function(){return this.get("logs")},c.prototype.clearLogs=function(a){this.set("logs",[]),this.saveLocal(function(){a&&a()})},c.prototype.sendLogs=function(a){var c=$fh.forms.config.get("log_email"),d=b.config.getProps(),e=this.getLogs(),f={type:"email",to:c,subject:"App Forms App Logs",body:"Configuration:\n"+JSON.stringify(d)+"\n\nApp Logs:\n"+e.join("\n")};b.utils.send(f,a)},a.log=new c,b.log=a.log,a}(b.models||{}),b.api=function(a){function c(a,c){"function"==typeof a&&(c=a,a={}),a=a?a:{},c=c?c:k;var d=a.fromRemote;void 0===d&&(d=!1),b.models.forms.refresh(d,c)}function d(a,c){"function"==typeof a&&(c=a,a={}),a=a?a:{},c=c?c:k,new b.models.Form(a,c)}function e(a,c){"function"==typeof a&&(c=a,a={}),a=a?a:{},c=c?c:k;var d=b.models.theme;a.fromRemote||(a.fromRemote=!1),d.refresh(a.fromRemote,function(b,e){return b?c(b):null===e?c(new Error("No theme defined for this app")):a.css===!0?c(null,d.getCSS()):c(null,d)})}function f(a,c){"function"==typeof a&&(c=a,a={}),a=a?a:{},c=c?c:k;b.models.submissions;null===i?b.models.submissions.loadLocal(function(a){a?($fh.forms.log.e(a),c(a)):(i=b.models.submissions,c(null,i))}):c(null,i)}function g(a,b){return a?void a.submit(function(c){return c?b(c):void a.upload(b)}):b("Invalid submission object.")}function h(a,c){if(a=a?a:{},c=c?c:k,!a.submissionId)return $fh.forms.log.e("No submissionId passed to download a submission"),c("No submissionId passed to download a submission");var d=b.models.submissions.findMetaByRemoteId(a.submissionId);if(null===d){var e=new b.models.submission.newInstance(null,{submissionId:a.submissionId});e.on("error",function(b){return $fh.forms.log.e("Error downloading submission with id "+a.submissionId),e.clearEvents(),c(b)}),e.on("downloaded",function(){return $fh.forms.log.l("Download of submission with id "+a.submissionId+" completed successfully"),e.clearEvents(),c(null,e)}),e.download(function(a){return a?($fh.forms.log.e("Error queueing submission for download "+a),e.clearEvents(),c(a)):void 0})}else b.models.submissions.getSubmissionByMeta(d,c)}a.getForms=c,a.getForm=d,a.getTheme=e,a.submitForm=g,a.getSubmissions=f,a.downloadSubmission=h,a.init=b.init,a.log=b.models.log;var i=null,j=b.models.config,k=function(a){a=a?a:"",$fh.forms.log.w("Default Function Called "+a)},l={editAllowed:function(){var a=j.get("defaultConfigValues",{});return a.config_admin_user===!0},get:function(a){if(a){var b=j.get("userConfigValues",{}),c=j.get("defaultConfigValues",{});return b[a]?b[a]:c[a]}},getDeviceId:function(){return j.get("deviceId","Not Set")},set:function(a,b){var c=this;if(a&&b&&(c.editAllowed()||"max_sent_saved"===a)){var d=j.get("userConfigValues",{});d[a]=b,j.set("userConfigValues",d)}},getConfig:function(){var a=this,b=j.get("defaultConfigValues",{}),c=j.get("userConfigValues",{}),d={};if(a.editAllowed()){for(var e in b)d[e]=c[e]?c[e]:b[e];return d}return b},saveConfig:function(a){j.saveLocal(function(b){b?$fh.forms.log.e("Error saving a form config: ",b):$fh.forms.log.l("Form config saved sucessfully."),"function"==typeof a&&a()})},offline:function(){j.setOffline()},online:function(){j.setOnline()},isOnline:function(){return j.isOnline()}};return a.config=l,a}(b.api||{}),"undefined"==typeof $fh&&($fh={}),void 0===$fh.forms&&($fh.forms=b.api),b&&(b.RulesEngine=a)}(window||module.exports); \ No newline at end of file +},all:function(b){var c=this,d="SELECT * FROM "+this.record,e=[],f=this.fn(this.name,b)||void 0,g=function(a,b){if(0!=b.rows.length)for(var d=0,g=b.rows.length;g>d;d++){var h=JSON.parse(b.rows.item(d).value);h.key=b.rows.item(d).id,e.push(h)}f&&f.call(c,e)};return this.db.readTransaction(function(b){b.executeSql(d,[],g,a)}),this},remove:function(b,c){var d,e=this,f="DELETE FROM "+this.record+" WHERE id ",g=function(){c&&e.lambda(c).call(e)};return this.isArray(b)?(d=b,f+="IN ("+d.map(function(){return"?"}).join(",")+")"):(f+="= ?",d=[b]),d=d.map(function(a){return a.key?a.key:a}),this.db.transaction(function(b){b.executeSql(f,d,g,a)}),this},nuke:function(b){var c="DELETE FROM "+this.record,d=this,e=b?function(){d.lambda(b).call(d)}:function(){};return this.db.transaction(function(b){b.executeSql(c,[],e,a)}),this}}}()),f.adapter("html5-filesystem",function(a){var b=a.FileError,c=function(a){var c,d=!0;switch(a.code){case b.QUOTA_EXCEEDED_ERR:c="QUOTA_EXCEEDED_ERR";break;case b.NOT_FOUND_ERR:c="NOT_FOUND_ERR",d=!1;break;case b.SECURITY_ERR:c="SECURITY_ERR";break;case b.INVALID_MODIFICATION_ERR:c="INVALID_MODIFICATION_ERR";break;case b.INVALID_STATE_ERR:c="INVALID_STATE_ERR";break;default:c="Unknown Error"}console&&d&&console.error(a,c)},d=function(a,b,e){var f=e||[];a.readEntries(function(c){c.length?d(a,b,f.concat(Array.prototype.slice.call(c))):b&&b(f.map(function(a){return a.name}))},c)},e={},f=function(a,b){var c=e[a.name];c?b(c):setTimeout(function(){f(a,b)},10)},g=function(){var a=-1===document.URL.indexOf("http://")&&-1===document.URL.indexOf("https://");return a?!0:!1},h=function(a){var b;if(g())b=a;else{var c="application/json";try{b=new Blob([a],{type:c})}catch(d){var e=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if("TypeError"==d.name&&e){var f=new e;f.append([a.buffer]),b=f.getBlob(c)}else b=a}}return b};return{valid:function(){var b=a.requestFileSystem||a.webkitRequestFileSystem||a.moz_requestFileSystem;return!!b},init:function(b,d){function f(b){var c=a.requestFileSystem||a.webkitRequestFileSystem||a.moz_requestFileSystem,f=window.PERSISTENT;"undefined"!=typeof LocalFileSystem&&"undefined"!=typeof LocalFileSystem.PERSISTENT&&(f=LocalFileSystem.PERSISTENT),c(f,b,function(a){a.root.getDirectory(j,{create:!0},function(a){e[j]=a,d&&g.fn(g.name,d).call(g,g)},function(a){h(a)})},function(a){h(a)})}var g=this,h=function(a){c(a),d&&g.fn(g.name,d).call(g,g)},i=b.size||104857600,j=this.name;"undefined"!=typeof navigator.webkitPersistentStorage?navigator.webkitPersistentStorage.requestQuota(i,f,function(){logger.warn("User declined file storage"),h("User declined file storage")}):f(0)},keys:function(a){var b=this;return f(this,function(c){d(c.createReader(),function(c){a&&b.fn("keys",a).call(b,c)})}),this},save:function(a,b){var d=this,e=a.key||this.uuid();a.key=e;var g=function(a){c(a),b&&d.lambda(b).call(d)};return f(this,function(c){c.getFile(e,{create:!0},function(c){c.createWriter(function(c){c.onerror=g,c.onwriteend=function(){this.onwriteend=null,this.truncate(this.position),b&&d.lambda(b).call(d,a)};var e=JSON.stringify(a),f=h(e);c.write(f)},g)},g)}),this},batch:function(a,b){for(var c=this,d=[],e=0,f=a.length;f>e;e++)c.save(a[e],function(a){d.push(a),d.length===f&&b&&c.lambda(b).call(c,d)});return this},get:function(a,b){var d=this;if(this.isArray(a))for(var e=[],g=0,h=a.length;h>g;g++)d.get(a[g],function(a){a&&e.push(a),e.length===h&&b&&d.lambda(b).call(d,e)});else{var i=function(a){c(a),b&&d.lambda(b).call(d)};f(this,function(c){c.getFile(a,{create:!1},function(c){c.file(function(c){var e=new FileReader;e.onerror=i,e.onload=function(c){var e={};try{e=JSON.parse(c.target.result),e.key=a}catch(c){e={key:a}}b&&d.lambda(b).call(d,e)},e.readAsText(c)},i)},i)})}return this},exists:function(a,b){var c=this;return f(this,function(d){d.getFile(a,{create:!1},function(){b&&c.lambda(b).call(c,!0)},function(){b&&c.lambda(b).call(c,!1)})}),this},all:function(a){var b=this;return a&&this.keys(function(c){c.length?b.get(c,function(c){b.fn(b.name,a).call(b,c)}):b.fn(b.name,a).call(b,[])}),this},remove:function(a,b){var d=this,e=function(a){c(a),b&&d.lambda(b).call(d)};return f(this,function(c){c.getFile("string"==typeof a?a:a.key,{create:!1},function(a){a.remove(function(){b&&d.lambda(b).call(d)},e)},e)}),this},nuke:function(a){var b=this,c=0;return this.keys(function(d){if(d.length)for(var e=0,f=d.length;f>e;e++)b.remove(d[e],function(){c++,c===f&&a&&b.lambda(a).call(b)});else a&&b.lambda(a).call(b)}),this}}}(this)),f.adapter("memory",function(){var a={};return{valid:function(){return!0},init:function(b,c){a[this.name]=a[this.name]||{index:[],store:{}},this.index=a[this.name].index,this.store=a[this.name].store;var d=this.fn(this.name,c);return d&&d.call(this,this),this},keys:function(a){return this.fn("keys",a).call(this,this.index),this},save:function(a,b){var c=a.key||this.uuid();return this.exists(c,function(d){d||(a.key&&delete a.key,this.index.push(c)),this.store[c]=a,b&&(a.key=c,this.lambda(b).call(this,a))}),this},batch:function(a,b){for(var c=[],d=0,e=a.length;e>d;d++)this.save(a[d],function(a){c.push(a)});return b&&this.lambda(b).call(this,c),this},get:function(a,b){var c;if(this.isArray(a)){c=[];for(var d=0,e=a.length;e>d;d++)c.push(this.store[a[d]])}else c=this.store[a],c&&(c.key=a);return b&&this.lambda(b).call(this,c),this},exists:function(a,b){return this.lambda(b).call(this,!!this.store[a]),this},all:function(a){for(var b=[],c=0,d=this.index.length;d>c;c++){var e=this.store[this.index[c]];e.key=this.index[c],b.push(e)}return this.fn(this.name,a).call(this,b),this},remove:function(a,b){for(var c=this.isArray(a)?a:[a],d=0,e=c.length;e>d;d++){var f=c[d].key?c[d].key:c[d],g=this.indexOf(this.index,f);0>g||(delete this.store[f],this.index.splice(g,1))}return b&&this.lambda(b).call(this),this},nuke:function(b){return this.store=a[this.name].store={},this.index=a[this.name].index=[],b&&this.lambda(b).call(this),this}}}()),e("undefined"!=typeof f?f:window.Lawnchair)}.call(c,void 0,void 0,void 0,void 0,function(a){b.exports=a})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(_dereq_,module,exports){(function(global){__browserify_shim_require__=_dereq_,function browserifyShim(module,exports,_dereq_,define,browserify_shim__define__module__export__){var JSON;JSON||(JSON={}),function(){"use strict";function f(a){return 10>a?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g,h=gap,i=b[a];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(a)),"function"==typeof rep&&(i=rep.call(b,a,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";if(gap+=indent,g=[],"[object Array]"===Object.prototype.toString.apply(i)){for(f=i.length,c=0;f>c;c+=1)g[c]=str(c,i)||"null";return e=0===g.length?"[]":gap?"[\n"+gap+g.join(",\n"+gap)+"\n"+h+"]":"["+g.join(",")+"]",gap=h,e}if(rep&&"object"==typeof rep)for(f=rep.length,c=0;f>c;c+=1)"string"==typeof rep[c]&&(d=rep[c],e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));return e=0===g.length?"{}":gap?"{\n"+gap+g.join(",\n"+gap)+"\n"+h+"}":"{"+g.join(",")+"}",gap=h,e}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;"function"!=typeof JSON.stringify&&(JSON.stringify=function(a,b,c){var d;if(gap="",indent="","number"==typeof c)for(d=0;c>d;d+=1)indent+=" ";else"string"==typeof c&&(indent=c);if(rep=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return str("",{"":a})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&"object"==typeof e)for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),void 0!==d?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),browserify_shim__define__module__export__("undefined"!=typeof JSON?JSON:window.JSON)}.call(global,void 0,void 0,void 0,void 0,function(a){module.exports=a})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(a,b){function c(a,b,c){null!=a&&("number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))}function d(){return new c(null)}function e(a,b,c,d,e,f){for(;--f>=0;){var g=b*this[a++]+c[d]+e;e=Math.floor(g/67108864),c[d++]=67108863&g}return e}function f(a,b,c,d,e,f){for(var g=32767&b,h=b>>15;--f>=0;){var i=32767&this[a],j=this[a++]>>15,k=h*i+j*g;i=g*i+((32767&k)<<15)+c[d]+(1073741823&e),e=(i>>>30)+(k>>>15)+h*j+(e>>>30),c[d++]=1073741823&i}return e}function g(a,b,c,d,e,f){for(var g=16383&b,h=b>>14;--f>=0;){var i=16383&this[a],j=this[a++]>>14,k=h*i+j*g;i=g*i+((16383&k)<<14)+c[d]+e,e=(i>>28)+(k>>14)+h*j,c[d++]=268435455&i}return e}function h(a){return nb.charAt(a)}function i(a,b){var c=ob[a.charCodeAt(b)];return null==c?-1:c}function j(a){for(var b=this.t-1;b>=0;--b)a[b]=this[b];a.t=this.t,a.s=this.s}function k(a){this.t=1,this.s=0>a?-1:0,a>0?this[0]=a:-1>a?this[0]=a+DV:this.t=0}function l(a){var b=d();return b.fromInt(a),b}function m(a,b){var d;if(16==b)d=4;else if(8==b)d=3;else if(256==b)d=8;else if(2==b)d=1;else if(32==b)d=5;else{if(4!=b)return void this.fromRadix(a,b);d=2}this.t=0,this.s=0;for(var e=a.length,f=!1,g=0;--e>=0;){var h=8==d?255&a[e]:i(a,e);0>h?"-"==a.charAt(e)&&(f=!0):(f=!1,0==g?this[this.t++]=h:g+d>this.DB?(this[this.t-1]|=(h&(1<>this.DB-g):this[this.t-1]|=h<=this.DB&&(g-=this.DB))}8==d&&0!=(128&a[0])&&(this.s=-1,g>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==a;)--this.t}function o(a){if(this.s<0)return"-"+this.negate().toString(a);var b;if(16==a)b=4;else if(8==a)b=3;else if(2==a)b=1;else if(32==a)b=5;else{if(4!=a)return this.toRadix(a);b=2}var c,d=(1<0)for(i>i)>0&&(e=!0,f=h(c));g>=0;)b>i?(c=(this[g]&(1<>(i+=this.DB-b)):(c=this[g]>>(i-=b)&d,0>=i&&(i+=this.DB,--g)),c>0&&(e=!0),e&&(f+=h(c));return e?f:"0"}function p(){var a=d();return c.ZERO.subTo(this,a),a}function q(){return this.s<0?this.negate():this}function r(a){var b=this.s-a.s;if(0!=b)return b;var c=this.t;if(b=c-a.t,0!=b)return this.s<0?-b:b;for(;--c>=0;)if(0!=(b=this[c]-a[c]))return b;return 0}function s(a){var b,c=1;return 0!=(b=a>>>16)&&(a=b,c+=16),0!=(b=a>>8)&&(a=b,c+=8),0!=(b=a>>4)&&(a=b,c+=4),0!=(b=a>>2)&&(a=b,c+=2),0!=(b=a>>1)&&(a=b,c+=1),c}function t(){return this.t<=0?0:this.DB*(this.t-1)+s(this[this.t-1]^this.s&this.DM)}function u(a,b){var c;for(c=this.t-1;c>=0;--c)b[c+a]=this[c];for(c=a-1;c>=0;--c)b[c]=0;b.t=this.t+a,b.s=this.s}function v(a,b){for(var c=a;c=0;--c)b[c+g+1]=this[c]>>e|h,h=(this[c]&f)<=0;--c)b[c]=0;b[g]=h,b.t=this.t+g+1,b.s=this.s,b.clamp()}function x(a,b){b.s=this.s;var c=Math.floor(a/this.DB);if(c>=this.t)return void(b.t=0);var d=a%this.DB,e=this.DB-d,f=(1<>d;for(var g=c+1;g>d;d>0&&(b[this.t-c-1]|=(this.s&f)<c;)d+=this[c]-a[c],b[c++]=d&this.DM,d>>=this.DB;if(a.t>=this.DB;d+=this.s}else{for(d+=this.s;c>=this.DB;d-=a.s}b.s=0>d?-1:0,-1>d?b[c++]=this.DV+d:d>0&&(b[c++]=d),b.t=c,b.clamp()}function z(a,b){var d=this.abs(),e=a.abs(),f=d.t;for(b.t=f+e.t;--f>=0;)b[f]=0;for(f=0;f=0;)a[c]=0;for(c=0;c=b.DV&&(a[c+b.t]-=b.DV,a[c+b.t+1]=1)}a.t>0&&(a[a.t-1]+=b.am(c,b[c],a,2*c,0,1)),a.s=0,a.clamp()}function B(a,b,e){var f=a.abs();if(!(f.t<=0)){var g=this.abs();if(g.t0?(f.lShiftTo(k,h),g.lShiftTo(k,e)):(f.copyTo(h),g.copyTo(e));var l=h.t,m=h[l-1];if(0!=m){var n=m*(1<1?h[l-2]>>this.F2:0),o=this.FV/n,p=(1<=0&&(e[e.t++]=1,e.subTo(u,e)),c.ONE.dlShiftTo(l,u),u.subTo(h,h);h.t=0;){var v=e[--r]==m?this.DM:Math.floor(e[r]*o+(e[r-1]+q)*p);if((e[r]+=h.am(0,v,e,t,0,l))0&&e.rShiftTo(k,e),0>i&&c.ZERO.subTo(e,e)}}}function C(a){var b=d();return this.abs().divRemTo(a,null,b),this.s<0&&b.compareTo(c.ZERO)>0&&a.subTo(b,b),b}function D(a){this.m=a}function E(a){return a.s<0||a.compareTo(this.m)>=0?a.mod(this.m):a}function F(a){return a}function G(a){a.divRemTo(this.m,null,a)}function H(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function I(a,b){a.squareTo(b),this.reduce(b)}function J(){if(this.t<1)return 0;var a=this[0];if(0==(1&a))return 0;var b=3&a;return b=b*(2-(15&a)*b)&15,b=b*(2-(255&a)*b)&255,b=b*(2-((65535&a)*b&65535))&65535,b=b*(2-a*b%this.DV)%this.DV,b>0?this.DV-b:-b}function K(a){this.m=a,this.mp=a.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(b,b),b}function M(a){var b=d();return a.copyTo(b),this.reduce(b),b}function N(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var b=0;b>15)*this.mpl&this.um)<<15)&a.DM;for(c=b+this.m.t,a[c]+=this.m.am(0,d,a,b,0,this.m.t);a[c]>=a.DV;)a[c]-=a.DV,a[++c]++}a.clamp(),a.drShiftTo(this.m.t,a),a.compareTo(this.m)>=0&&a.subTo(this.m,a)}function O(a,b){a.squareTo(b),this.reduce(b)}function P(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function Q(){return 0==(this.t>0?1&this[0]:this.s)}function R(a,b){if(a>4294967295||1>a)return c.ONE;var e=d(),f=d(),g=b.convert(this),h=s(a)-1;for(g.copyTo(e);--h>=0;)if(b.sqrTo(e,f),(a&1<0)b.mulTo(f,g,e);else{var i=e;e=f,f=i}return b.revert(e)}function S(a,b){var c;return c=256>a||b.isEven()?new D(b):new K(b),this.exp(a,c)}function T(){this.i=0,this.j=0,this.S=new Array}function U(a){var b,c,d;for(b=0;256>b;++b)this.S[b]=b;for(c=0,b=0;256>b;++b)c=c+this.S[b]+a[b%a.length]&255,d=this.S[b],this.S[b]=this.S[c],this.S[c]=d;this.i=0,this.j=0}function V(){var a;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,a=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=a,this.S[a+this.S[this.i]&255]}function W(){return new T}function X(a){qb[rb++]^=255&a,qb[rb++]^=a>>8&255,qb[rb++]^=a>>16&255,qb[rb++]^=a>>24&255,rb>=sb&&(rb-=sb)}function Y(){X((new Date).getTime())}function Z(){if(null==pb){for(Y(),pb=W(),pb.init(qb),rb=0;rba?"0"+a.toString(16):a.toString(16)}function cb(a,b){if(b=0&&b>0;){var f=a.charCodeAt(e--);128>f?d[--b]=f:f>127&&2048>f?(d[--b]=63&f|128,d[--b]=f>>6|192):(d[--b]=63&f|128,d[--b]=f>>6&63|128,d[--b]=f>>12|224)}d[--b]=0;for(var g=new _,h=new Array;b>2;){for(h[0]=0;0==h[0];)g.nextBytes(h);d[--b]=h[0]}return d[--b]=2,d[--b]=0,new c(d)}function db(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function eb(a,b){null!=a&&null!=b&&a.length>0&&b.length>0?(this.n=ab(a,16),this.e=parseInt(b,16)):alert("Invalid RSA public key")}function fb(a){return a.modPowInt(this.e,this.n)}function gb(a){var b=cb(a,this.n.bitLength()+7>>3);if(null==b)return null;var c=this.doPublic(b);if(null==c)return null;var d=c.toString(16);return 0==(1&d.length)?d:"0"+d}var hb,ib=0xdeadbeefcafe,jb=15715070==(16777215&ib);jb&&"Microsoft Internet Explorer"==navigator.appName?(c.prototype.am=f,hb=30):jb&&"Netscape"!=navigator.appName?(c.prototype.am=e,hb=26):(c.prototype.am=g,hb=28),c.prototype.DB=hb,c.prototype.DM=(1<=mb;++mb)ob[lb++]=mb;for(lb="a".charCodeAt(0),mb=10;36>mb;++mb)ob[lb++]=mb;for(lb="A".charCodeAt(0),mb=10;36>mb;++mb)ob[lb++]=mb;D.prototype.convert=E,D.prototype.revert=F,D.prototype.reduce=G,D.prototype.mulTo=H,D.prototype.sqrTo=I,K.prototype.convert=L,K.prototype.revert=M,K.prototype.reduce=N,K.prototype.mulTo=P,K.prototype.sqrTo=O,c.prototype.copyTo=j,c.prototype.fromInt=k,c.prototype.fromString=m,c.prototype.clamp=n,c.prototype.dlShiftTo=u,c.prototype.drShiftTo=v,c.prototype.lShiftTo=w,c.prototype.rShiftTo=x,c.prototype.subTo=y,c.prototype.multiplyTo=z,c.prototype.squareTo=A,c.prototype.divRemTo=B,c.prototype.invDigit=J,c.prototype.isEven=Q,c.prototype.exp=R,c.prototype.toString=o,c.prototype.negate=p,c.prototype.abs=q,c.prototype.compareTo=r,c.prototype.bitLength=t,c.prototype.mod=C,c.prototype.modPowInt=S,c.ZERO=l(0),c.ONE=l(1),T.prototype.init=U,T.prototype.next=V;var pb,qb,rb,sb=256;if(null==qb){qb=new Array,rb=0;var tb;if("Netscape"==navigator.appName&&navigator.appVersion<"5"&&window.crypto){var ub=window.crypto.random(32);for(tb=0;tbrb;)tb=Math.floor(65536*Math.random()),qb[rb++]=tb>>>8,qb[rb++]=255&tb;rb=0,Y()}_.prototype.nextBytes=$,db.prototype.doPublic=fb,db.prototype.setPublic=eb,db.prototype.encrypt=gb,b.exports={SecureRandom:_,byte2Hex:bb,RSAKey:db}},{}],5:[function(a,b){function c(a,b){return m.isUndefined(b)?""+b:!m.isNumber(b)||!isNaN(b)&&isFinite(b)?m.isFunction(b)||m.isRegExp(b)?b.toString():b:b.toString()}function d(a,b){return m.isString(a)?a.length=0;d--)if(e[d]!=f[d])return!1;for(d=e.length-1;d>=0;d--)if(c=e[d],!h(a[c],b[c]))return!1;return!0}function k(a,b){return a&&b?"[object RegExp]"==Object.prototype.toString.call(b)?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function l(a,b,c,d){var e;m.isString(c)&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f(e,c,"Missing expected exception"+d),!a&&k(e,c)&&f(e,c,"Got unwanted exception"+d),a&&e&&c&&!k(e,c)||!a&&e)throw e}var m=a("util/"),n=Array.prototype.slice,o=Object.prototype.hasOwnProperty,p=b.exports=g;p.AssertionError=function(a){this.name="AssertionError",this.actual=a.actual,this.expected=a.expected,this.operator=a.operator,a.message?(this.message=a.message,this.generatedMessage=!1):(this.message=e(this),this.generatedMessage=!0);var b=a.stackStartFunction||f;if(Error.captureStackTrace)Error.captureStackTrace(this,b);else{var c=new Error;if(c.stack){var d=c.stack,g=b.name,h=d.indexOf("\n"+g);if(h>=0){var i=d.indexOf("\n",h+1);d=d.substring(i+1)}this.stack=d}}},m.inherits(p.AssertionError,Error),p.fail=f,p.ok=g,p.equal=function(a,b,c){a!=b&&f(a,b,c,"==",p.equal)},p.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",p.notEqual)},p.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",p.deepEqual)},p.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",p.notDeepEqual)},p.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",p.strictEqual)},p.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",p.notStrictEqual)},p.throws=function(){l.apply(this,[!0].concat(n.call(arguments)))},p.doesNotThrow=function(){l.apply(this,[!1].concat(n.call(arguments)))},p.ifError=function(a){if(a)throw a};var q=Object.keys||function(a){var b=[];for(var c in a)o.call(a,c)&&b.push(c);return b}},{"util/":7}],6:[function(a,b){b.exports=function(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.readUInt8}},{}],7:[function(a,b,c){(function(b,d){function e(a,b){var d={seen:[],stylize:g};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),p(b)?d.showHidden=b:b&&c._extend(d,b),v(d.showHidden)&&(d.showHidden=!1),v(d.depth)&&(d.depth=2),v(d.colors)&&(d.colors=!1),v(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=f),i(d,a,d.depth)}function f(a,b){var c=e.styles[b];return c?"["+e.colors[c][0]+"m"+a+"["+e.colors[c][1]+"m":a}function g(a){return a}function h(a){var b={};return a.forEach(function(a){b[a]=!0}),b}function i(a,b,d){if(a.customInspect&&b&&A(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d,a);return t(e)||(e=i(a,e,d)),e}var f=j(a,b);if(f)return f;var g=Object.keys(b),p=h(g);if(a.showHidden&&(g=Object.getOwnPropertyNames(b)),z(b)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return k(b);if(0===g.length){if(A(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(w(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(y(b))return a.stylize(Date.prototype.toString.call(b),"date");if(z(b))return k(b)}var r="",s=!1,u=["{","}"];if(o(b)&&(s=!0,u=["[","]"]),A(b)){var v=b.name?": "+b.name:"";r=" [Function"+v+"]"}if(w(b)&&(r=" "+RegExp.prototype.toString.call(b)),y(b)&&(r=" "+Date.prototype.toUTCString.call(b)),z(b)&&(r=" "+k(b)),0===g.length&&(!s||0==b.length))return u[0]+r+u[1];if(0>d)return w(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var x;return x=s?l(a,b,d,p,g):g.map(function(c){return m(a,b,d,p,c,s)}),a.seen.pop(),n(x,r,u)}function j(a,b){if(v(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return s(b)?a.stylize(""+b,"number"):p(b)?a.stylize(""+b,"boolean"):q(b)?a.stylize("null","null"):void 0}function k(a){return"["+Error.prototype.toString.call(a)+"]"}function l(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)f.push(F(b,String(g))?m(a,b,c,d,String(g),!0):"");return e.forEach(function(e){e.match(/^\d+$/)||f.push(m(a,b,c,d,e,!0))}),f}function m(a,b,c,d,e,f){var g,h,j;if(j=Object.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?h=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(h=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),h||(a.seen.indexOf(j.value)<0?(h=q(c)?i(a,j.value,null):i(a,j.value,c-1),h.indexOf("\n")>-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),v(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function n(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function o(a){return Array.isArray(a)}function p(a){return"boolean"==typeof a}function q(a){return null===a}function r(a){return null==a}function s(a){return"number"==typeof a}function t(a){return"string"==typeof a}function u(a){return"symbol"==typeof a}function v(a){return void 0===a}function w(a){return x(a)&&"[object RegExp]"===C(a)}function x(a){return"object"==typeof a&&null!==a}function y(a){return x(a)&&"[object Date]"===C(a)}function z(a){return x(a)&&("[object Error]"===C(a)||a instanceof Error)}function A(a){return"function"==typeof a}function B(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),J[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=/%[sdj%]/g;c.format=function(a){if(!t(a)){for(var b=[],c=0;c=f)return a;switch(a){case"%s":return String(d[c++]);case"%d":return Number(d[c++]);case"%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),h=d[c];f>c;h=d[++c])g+=q(h)||!x(h)?" "+h:" "+e(h);return g},c.deprecate=function(a,e){function f(){if(!g){if(b.throwDeprecation)throw new Error(e);b.traceDeprecation?console.trace(e):console.error(e),g=!0}return a.apply(this,arguments)}if(v(d.process))return function(){return c.deprecate(a,e).apply(this,arguments)};if(b.noDeprecation===!0)return a;var g=!1;return f};var H,I={};c.debuglog=function(a){if(v(H)&&(H=b.env.NODE_DEBUG||""),a=a.toUpperCase(),!I[a])if(new RegExp("\\b"+a+"\\b","i").test(H)){var d=b.pid;I[a]=function(){var b=c.format.apply(c,arguments);console.error("%s %d: %s",a,d,b)}}else I[a]=function(){};return I[a]},c.inspect=e,e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=o,c.isBoolean=p,c.isNull=q,c.isNullOrUndefined=r,c.isNumber=s,c.isString=t,c.isSymbol=u,c.isUndefined=v,c.isRegExp=w,c.isObject=x,c.isDate=y,c.isError=z,c.isFunction=A,c.isPrimitive=B,c.isBuffer=a("./support/isBuffer");var J=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=a("inherits"),c._extend=function(a,b){if(!b||!x(b))return a;for(var c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}}).call(this,a("/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":6,"/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,inherits:10}],8:[function(a,b){(function(c){function d(){}function e(){m.log.apply(m,arguments)}function f(){m.log.apply(m,arguments)}function g(){m.warn.apply(m,arguments)}function h(a){p[a]=Date.now()}function i(a){var b=p[a];if(!b)throw new Error("No such label: "+a);var c=Date.now()-b;m.log(a+": "+c+"ms")}function j(){var a=new Error;a.name="Trace",a.message=n.format.apply(null,arguments),m.error(a.stack)}function k(a){m.log(n.inspect(a)+"\n")}function l(a){if(!a){var b=o.call(arguments,1);l.ok(!1,n.format.apply(null,b))}}var m,n=a("util"),l=a("assert"),o=Array.prototype.slice,p={};m="undefined"!=typeof c&&c.console?c.console:"undefined"!=typeof window&&window.console?window.console:{};for(var q=[[d,"log"],[e,"info"],[f,"warn"],[g,"error"],[h,"time"],[i,"timeEnd"],[j,"trace"],[k,"dir"],[l,"assert"]],r=0;ra||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,h,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||f(this._events.error)&&!this._events.error.length))throw b=arguments[1],b instanceof Error?b:TypeError('Uncaught, unspecified "error" event.');if(c=this._events[a],g(c))return!1;if(d(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];c.apply(this,h)}else if(f(c)){for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];for(j=c.slice(),e=j.length,i=0;e>i;i++)j[i].apply(this,h)}return!0},c.prototype.addListener=function(a,b){var e;if(!d(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d(b.listener)?b.listener:b),this._events[a]?f(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,f(this._events[a])&&!this._events[a].warned){var e;e=g(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace()) +}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),e||(e=!0,b.apply(this,arguments))}if(!d(b))throw TypeError("listener must be a function");var e=!1;return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,g,h;if(!d(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],g=c.length,e=-1,c===b||d(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(f(c)){for(h=g;h-->0;)if(c[h]===b||c[h].listener&&c[h].listener===b){e=h;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d(a._events[b])?1:a._events[b].length:0}},{}],10:[function(a,b){b.exports="function"==typeof Object.create?function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],11:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],12:[function(a,b){b.exports=a(6)},{}],13:[function(a,b){b.exports=a(7)},{"./support/isBuffer":12,"/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,inherits:10}],14:[function(a,b){!function(a){var c="undefined";!function(a,c){"undefined"!=typeof b?b.exports=c():"function"==typeof define&&"object"==typeof define.amd?define(c):this[a]=c()}("log",function(){function b(b){return typeof console===c?l:console[b]===a?console.log!==a?d(console,"log"):l:d(console,b)}function d(b,c){var d=b[c];if(d.bind!==a)return b[c].bind(b);if(Function.prototype.bind===a)return e(d,b);try{return Function.prototype.bind.call(b[c],b)}catch(f){return e(d,b)}}function e(a,b){return function(){Function.prototype.apply.apply(a,[b,arguments])}}function f(a){for(var b=0;b=0&&d<=k.levels.SILENT){if(i(d),d===k.levels.SILENT)return void f(function(){return l});if(typeof console===c)return f(function(a){return function(){typeof console!==c&&(k.setLevel(d),k[a].apply(k,arguments))}}),"No console available for logging";f(function(a){return d<=k.levels[a.toUpperCase()]?b(a):l})}else{if("string"!=typeof d||k.levels[d.toUpperCase()]===a)throw"log.setLevel() called with invalid level: "+d;k.setLevel(k.levels[d.toUpperCase()])}},k.enableAll=function(){k.setLevel(k.levels.TRACE)},k.disableAll=function(){k.setLevel(k.levels.SILENT)},j(),k})}()},{}],15:[function(a,b){var c=Object.prototype.toString;b.exports=function(a){switch(c.call(a)){case"[object Function]":return"function";case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object String]":return"string"}if("object"==typeof a&&a&&"number"==typeof a.length)try{if("function"==typeof a.callee)return"arguments"}catch(b){if(b instanceof TypeError)return"arguments"}return null===a?"null":void 0===a?"undefined":a&&1===a.nodeType?"element":a===Object(a)?"object":typeof a}},{}],16:[function(a,b){var c=a("./modules/constants"),d=a("./modules/logger"),e=a("./modules/ajax"),f=a("./modules/events"),g=a("./modules/waitForCloud"),h=a("./modules/api_act"),i=a("./modules/api_auth"),j=a("./modules/api_sec"),k=a("./modules/api_hash"),l=a("./modules/sync-cli"),m=a("./modules/api_mbaas"),n=a("./modules/api_cloud"),o=a("./modules/fhparams"),p=a("./modules/appProps"),q=a("./modules/device"),r=function(a,b){f.addListener(a,b),a===c.INIT_EVENT&&(g.isReady()?b(null,{host:g.getCloudHostUrl()}):g.getInitError()&&b(g.getInitError()))},s=function(a,b){a===c.INIT_EVENT&&g.isReady()?b(null,{host:g.getCloudHostUrl()}):a===c.INIT_EVENT&&g.getInitError()?b(g.getInitError()):f.once(a,b)},t=function(a,b,c){d.warn("$fh.init will be deprecated soon"),g.ready(function(a,d){if(a){if("function"==typeof c)return c(a)}else"function"==typeof b&&b(d.host)})},u=window.$fh||{};u.init=t,u.act=h,u.auth=i,u.cloud=n,u.sec=j,u.hash=k,u.sync=l,u.ajax=u.__ajax=e,u.mbaas=m,u._getDeviceId=q.getDeviceId,u.fh_timeout=6e4,u.getCloudURL=function(){return g.getCloudHostUrl()},u.getFHParams=function(){return o.buildFHParams()},u.addListener=r,u.on=r,u.once=s;for(var v=["removeListener","removeAllListeners","setMaxListeners","listeners","emit"],w=0;w=0&&(a=!0),a}function m(a){var b=null;return window.XMLHttpRequest&&(b=new XMLHttpRequest),l()&&a===!0&&"undefined"!=typeof window.XDomainRequest&&(b=new v(new XDomainRequest)),"undefined"!=typeof Titanium&&(b=Titanium.Network.createHTTPClient({timeout:I.settings.timeout})),b}function n(a){return a&&(a==G?"html":a==F?"json":D.test(a)?"script":E.test(a)&&"xml")||"text"}function o(a,b){return(a+"&"+b).replace(/[&?]{1,2}/,"?")}function p(a){"object"===t(a.data)&&("function"==typeof a.data.append?a.formdata=!0:a.data=r(a.data)),!a.data||a.type&&"GET"!=a.type.toUpperCase()||(a.url=o(a.url,a.data))}function q(a,b,c,d){var e="array"===t(b);for(var f in b){var g=b[f];d&&(f=c?d:d+"["+(e?"":f)+"]"),!d&&e?a.add(g.name,g.value):(c?"array"===t(g):"object"===t(g))?q(a,g,c,f):a.add(f,g)}}function r(a,b){var c=[];return c.add=function(a,b){this.push(J(a)+"="+J(b))},q(c,a,b),c.join("&").replace("%20","+")}function s(a){var b=Array.prototype.slice;return b.call(arguments,1).forEach(function(b){for(z in b)void 0!==b[z]&&(a[z]=b[z])}),a}var t,u=a("./events"),v=a("./XDomainRequestWrapper"),w=a("./logger");try{t=a("type-of")}catch(x){var y=a;t=y("type")}var z,A,B=0,C=window.document,D=/^(?:text|application)\/javascript/i,E=/^(?:text|application)\/xml/i,F="application/json",G="text/html",H=/^\s*$/,I=b.exports=function(a){var b=s({},a||{});window&&window.$fh&&"number"==typeof window.$fh.fh_timeout&&(I.settings.timeout=window.$fh.fh_timeout);for(z in I.settings)void 0===b[z]&&(b[z]=I.settings[z]);e(b),b.crossDomain||(b.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(b.url)&&(RegExp.$1!=window.location.protocol||RegExp.$2!=window.location.host));var c=b.dataType,d=/=\?/.test(b.url);if("jsonp"==c||d)return d||(b.url=o(b.url,(b.jsonp?b.jsonp:"_callback")+"=?")),I.JSONP(b);b.url||(b.url=window.location.toString()),p(b);var f,j=b.accepts[c],l={},m=/^([\w-]+:)\/\//.test(b.url)?RegExp.$1:window.location.protocol,q=b.xhr(b.crossDomain);b.crossDomain||(l["X-Requested-With"]="XMLHttpRequest"),j&&(l.Accept=j,j.indexOf(",")>-1&&(j=j.split(",",2)[0]),q.overrideMimeType&&q.overrideMimeType(j)),(b.contentType||b.data&&!b.formdata&&"GET"!=b.type.toUpperCase())&&(l["Content-Type"]=b.contentType||"application/x-www-form-urlencoded"),b.headers=s(l,b.headers||{}),"undefined"!=typeof Titanium&&q.setOnerror(function(){f&&(clearTimeout(f),i(null,"error",q,b))}),q.onreadystatechange=function(){if(4==q.readyState){clearTimeout(f),f=void 0;var a,d=!1;if(b.tryJSONP&&0===q.status&&b.crossDomain&&!q.isTimeout&&"file:"!=m)return w.debug("retry ajax call with jsonp"),b.type="GET",b.dataType="jsonp",b.data="_jsonpdata="+b.data,I(b);if(q.status>=200&&q.status<300||304==q.status||0==q.status&&"file:"==m){c=c||n(q.getResponseHeader("content-type")),a=q.responseText,w.debug("ajax response :: status = "+q.status+" :: body = "+a);try{"script"==c?(1,eval)(a):"xml"==c?a=q.responseXML:"json"==c&&(a=H.test(a)?null:JSON.parse(a))}catch(e){d=e}d?(w.debug("ajax error",d),i(d,"parsererror",q,b)):h(a,q,b)}else i(null,"error",q,b)}};var r="async"in b?b.async:!0;w.debug("ajax call settings",b),q.open(b.type,b.url,r);for(A in b.headers)q.setRequestHeader(A,b.headers[A]);return g(q,b)===!1?(w.debug("ajax call is aborted due to ajaxBeforeSend"),q.abort(),!1):(b.timeout>0&&(f=setTimeout(function(){w.debug("ajax call timed out"),q.onreadystatechange=k,q.abort(),q.isTimeout=!0,i(null,"timeout",q,b)},b.timeout)),q.send(b.data?b.data:null),q)};I.active=0,I.JSONP=function(a){if(!("type"in a))return I(a);var b,c="jsonp"+ ++B,d=C.createElement("script"),e=function(){c in window&&(window[c]=k),j("abort",f,a)},f={abort:e},g=C.getElementsByTagName("head")[0]||C.documentElement;return a.error&&(d.onerror=function(){f.abort(),a.error()}),window[c]=function(d){clearTimeout(b),b=void 0,delete window[c],h(d,f,a)},p(a),d.src=a.url.replace(/=\?/,"="+c),g.insertBefore(d,g.firstChild),a.timeout>0&&(b=setTimeout(function(){f.abort(),j("timeout",f,a)},a.timeout)),f},I.settings={type:"GET",beforeSend:k,success:k,error:k,complete:k,context:null,global:!0,xhr:m,accepts:{script:"text/javascript, application/javascript",json:F,xml:"application/xml, text/xml",html:G,text:"text/plain"},crossDomain:!1},I.get=function(a,b){return I({url:a,success:b})},I.post=function(a,b,c,d){return"function"===t(b)&&(d=d||c,c=b,b=null),I({type:"POST",url:a,data:b,success:c,dataType:d})},I.getJSON=function(a,b){return I({url:a,success:b,dataType:"json"})};var J=encodeURIComponent},{"./XDomainRequestWrapper":17,"./events":30,"./logger":37,"type-of":15}],19:[function(a,b){function c(a,b,c){var d=e.getCloudHost(),k=d.getActUrl(a.act),l=a.req||{};return l=f.addFHParams(l),g({url:k,tryJSONP:!0,type:"POST",dataType:"json",data:h.stringify(l),contentType:"application/json",timeout:a.timeout||j.timeout,success:b,error:function(a,b,d){return i(c,a,b,d)}})}var d=a("./logger"),e=a("./waitForCloud"),f=a("./fhparams"),g=a("./ajax"),h=a("JSON"),i=a("./handleError"),j=a("./appProps");b.exports=function(a,b,f){return d.debug("act is called"),f||(f=function(a,b){d.debug(a+":"+h.stringify(b))}),a.act?void e.ready(function(e){return d.debug("Calling fhact now"),e?f(e.message,e):void c(a,b,f)}):f("act_no_action",{})}},{"./ajax":18,"./appProps":25,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],20:[function(a,b){var c=a("./logger"),d=a("./waitForCloud"),e=a("./fhparams"),f=a("./ajax"),g=a("JSON"),h=a("./handleError"),i=a("./device"),j=a("./constants"),k=a("./checkAuth"),l=a("./appProps");b.exports=function(a,b,m){return m||(m=function(a,b){c.debug(a+":"+g.stringify(b))}),a.policyId?a.clientToken?void d.ready(function(c){if(c)return m(c.message,c);var d={};d.policyId=a.policyId,d.clientToken=a.clientToken,a.endRedirectUrl&&(d.endRedirectUrl=a.endRedirectUrl,a.authCallback&&(d.endRedirectUrl+=(/\?/.test(d.endRedirectUrl)?"&":"?")+"_fhAuthCallback="+a.authCallback)),d.params={},a.params&&(d.params=a.params);var n=a.endRedirectUrl||"status=complete";d.device=i.getDeviceId();var o=l.getAppProps(),p=o.host+j.boxprefix+"admin/authpolicy/auth";d=e.addFHParams(d),f({url:p,type:"POST",tryJSONP:!0,data:g.stringify(d),dataType:"json",contentType:"application/json",timeout:a.timeout||o.timeout,success:function(a){k.handleAuthResponse(n,a,b,m)},error:function(a,b,c){h(m,a,b,c)}})}):m("auth_no_clientToken",{}):m("auth_no_policyId",{})}},{"./ajax":18,"./appProps":25,"./checkAuth":26,"./constants":27,"./device":29,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],21:[function(a,b){function c(a,b,c){var d=e.getCloudHost(),k=d.getCloudUrl(a.path),l=a.data||{};return l=f.addFHParams(l),g({url:k,type:a.method||"POST",dataType:a.dataType||"json",data:h.stringify(l),contentType:a.contentType||"application/json",timeout:a.timeout||j.timeout,success:b,error:function(a,b,d){return i(c,a,b,d)}})}var d=a("./logger"),e=a("./waitForCloud"),f=a("./fhparams"),g=a("./ajax"),h=a("JSON"),i=a("./handleError"),j=a("./appProps");b.exports=function(a,b,f){d.debug("cloud is called"),f||(f=function(a,b){d.debug(a+":"+h.stringify(b))}),e.ready(function(e){return d.debug("Calling fhact now"),e?f(e.message,e):void c(a,b,f)})}},{"./ajax":18,"./appProps":25,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],22:[function(a,b){var c=a("./security/hash");b.exports=function(a,b,d){var e={};"undefined"==typeof a.algorithm&&(a.algorithm="MD5"),e.act="hash",e.params=a,c(e,b,d)}},{"./security/hash":43}],23:[function(a,b){var c=a("./logger"),d=a("./waitForCloud"),e=a("./fhparams"),f=a("./ajax"),g=a("JSON"),h=a("./handleError"),i=(a("./constants"),a("./appProps"));b.exports=function(a,b,j){c.debug("mbaas is called."),j||(j=function(a,b){console.debug(a+":"+g.stringify(b))});var k=a.service,l=a.params;d.ready(function(m){if(c.debug("Calling mbaas now"),m)return j(m.message,m);var n=d.getCloudHost(),o=n.getMBAASUrl(k);return l=e.addFHParams(l),f({url:o,tryJSONP:!0,type:"POST",dataType:"json",data:g.stringify(l),contentType:"application/json",timeout:a.timeout||i.timeout,success:b,error:function(a,b,c){return h(j,a,b,c)}})})}},{"./ajax":18,"./appProps":25,"./constants":27,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],24:[function(a,b){var c=a("./security/aes-keygen"),d=a("./security/aes-node"),e=a("./security/rsa-node"),f=a("./security/hash");b.exports=function(a,b,g){return a.act?a.params?a.params.algorithm?(a.params.algorithm=a.params.algorithm.toLowerCase(),"hash"===a.act?f(a,b,g):"encrypt"===a.act?"aes"===a.params.algorithm?d.encrypt(a,b,g):"rsa"===a.params.algorithm?e.encrypt(a,b,g):g("encrypt_bad_algorithm:"+a.params.algorithm,{},a):"decrypt"===a.act?"aes"===a.params.algorithm?d.decrypt(a,b,g):g("decrypt_bad_algorithm:"+a.params.algorithm,{},a):"keygen"===a.act?"aes"===a.params.algorithm?c(a,b,g):g("keygen_bad_algorithm:"+a.params.algorithm,{},a):void 0):void g("no_params_algorithm",{},a):void g("no_params",{},a):void g("bad_act",{},a)}},{"./security/aes-keygen":41,"./security/aes-node":42,"./security/hash":43,"./security/rsa-node":44}],25:[function(a,b){var c=a("./constants"),d=a("./ajax"),e=a("./logger"),f=a("./queryMap"),g=null,h=function(a){var b=document.location.href,h=f(b),i="undefined"!=typeof h.url;if(i)return g={},g.local=!0,g.host=h.url.replace(/#.*?$/g,""),g.appid="000000000000000000000000",g.appkey="0000000000000000000000000000000000000000",g.projectid="000000000000000000000000",g.connectiontag="0.0.1",g.loglevel=h.loglevel,a(null,g);var j=h.fhconfig||c.config_js;d({url:j,dataType:"json",success:function(b){return e.debug("fhconfig = "+JSON.stringify(b)),null==b?window.fh_app_props?(g=window.fh_app_props,a(null,window.fh_app_props)):a(new Error("app_config_missing")):(g=b,void a(null,g))},error:function(){return window.fh_app_props?(g=window.fh_app_props,a(null,window.fh_app_props)):(e.error(c.config_js+" Not Found"),void a(new Error("app_config_missing")))}})},i=function(a){g=a},j=function(){return g};b.exports={load:h,getAppProps:j,setAppProps:i}},{"./ajax":18,"./constants":27,"./logger":37,"./queryMap":39}],26:[function(a,b){var c=a("./logger"),d=a("./queryMap"),e=a("JSON"),f=a("./fhparams"),g=function(a){if(/\_fhAuthCallback/.test(a)){var b=d(a);if(b){var c=b._fhAuthCallback;if(c)if(b.result&&"success"===b.result){var g={sessionToken:b.fh_auth_session,authResponse:e.parse(decodeURIComponent(decodeURIComponent(b.authResponse)))};f.setAuthSessionToken(b.fh_auth_session),window[c](null,g)}else window[c]({message:b.message})}}},h=function(a,b,g,h){if(b.status&&"ok"===b.status){var i=function(a){a.sessionToken&&f.setAuthSessionToken(a.sessionToken),g(a)};if(b.url){var j=null,k=function(b){if(b.indexOf(a)>-1){j&&j.close();var c=d(b);if(c)if(c.result&&"success"===c.result){var f={sessionToken:c.fh_auth_session,authResponse:e.parse(decodeURIComponent(decodeURIComponent(c.authResponse)))};i(f)}else h&&h("auth_failed",{message:c.message});else h&&h("auth_failed",{message:c.message})}};if(window.PhoneGap||window.cordova)if(window.plugins&&window.plugins.childBrowser)"function"==typeof window.plugins.childBrowser.showWebPage&&(window.plugins.childBrowser.onLocationChange=k,window.plugins.childBrowser.showWebPage(b.url),j=window.plugins.childBrowser);else try{j=window.open(b.url,"_blank","location=yes"),j.addEventListener("loadstart",function(a){k(a.url)})}catch(l){c.info("InAppBrowser plugin is not intalled."),i(b)}else document.location.href=b.url}else i(b)}else h&&h("auth_failed",b)};window.addEventListener?window.addEventListener("load",function(){g(window.location.href)},!1):window.attachEvent&&window.attachEvent("onload",function(){g(window.location.href)}),b.exports={handleAuthResponse:h}},{"./fhparams":31,"./logger":37,"./queryMap":39,JSON:3}],27:[function(a,b){b.exports={boxprefix:"/box/srv/1.1/",sdk_version:"2.0.17-alpha",config_js:"fhconfig.json",INIT_EVENT:"fhinit"}},{}],28:[function(a,b){b.exports={readCookieValue:function(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d1?b=f[1]:"undefined"!=typeof window.fh_destination_code?b=window.fh_destination_code:c.forEach(function(a){a.test.forEach(function(c){d.indexOf(c)>-1&&(b=a.destination)})}),null==b&&(b="web"),e.debug("destination = "+b),b}}},{"./cookies":28,"./logger":37,"./platformsMap":38,"./uuid":46}],30:[function(a,b){var c=a("events").EventEmitter,d=new c;d.setMaxListeners(0),b.exports=d},{events:9}],31:[function(a,b){var c=a("./device"),d=a("./sdkversion"),e=a("./appProps"),f=a("./logger"),g=null,h=null,i=function(){if(g)return g;var a={};a.cuid=c.getDeviceId(),a.cuidMap=c.getCuidMap(),a.destination=c.getDestination(),(window.device||navigator.device)&&(a.device=window.device||navigator.device),"undefined"!=typeof window.fh_app_version&&(a.app_version=fh_app_version),"undefined"!=typeof window.fh_project_version&&(a.project_version=fh_project_version),"undefined"!=typeof window.fh_project_app_version&&(a.project_app_version=fh_project_app_version),a.sdk_version=d(),h&&(a.sessionToken=h);var b=e.getAppProps();return b&&(a.appid=b.appid,a.appkey=b.appkey,a.projectid=b.projectid,a.analyticsTag=b.analyticsTag,a.connectiontag=b.connectiontag,b.init&&(a.init="string"==typeof b.init?JSON.parse(b.init):b.init)),g=a,f.debug("fhparams = ",g),a},j=function(a){var a=a||{};return a.__fh=i(),a},k=function(a){h=a};b.exports={buildFHParams:i,addFHParams:j,setAuthSessionToken:k}},{"./appProps":25,"./device":29,"./logger":37,"./sdkversion":40}],32:[function(a,b){var c=a("JSON");b.exports=function(a,b,d,e){var f,g=0;if(b)try{g=b.status;var h=c.parse(b.responseText);f=h.error||h.msg,f instanceof Array&&(f=f.join("\n"))}catch(i){f=b.responseText}a&&a(f,{status:g,message:d,error:e})}},{JSON:3}],33:[function(a,b){function c(a){var b=a;return"/"===b.charAt(b.length-1)&&(b=b.substring(0,b.length-1)),b}function d(a){var b=a;return b.length>1&&"/"===b.charAt(0)&&(b=b.substring(1,b.length)),b}function e(a){this.cloud_props=a,this.cloud_host=void 0,this.isLegacy=!1}var f=a("./constants"),g=a("./appProps");e.prototype.getHost=function(a){if(this.cloud_host)return this.cloud_host;var b,d;if(this.cloud_props&&this.cloud_props.hosts&&(b=this.cloud_props.hosts.url,"undefined"==typeof b)){var e=this.cloud_props.hosts.releaseCloudUrl;d=this.cloud_props.hosts.releaseCloudType,"undefined"!=typeof a&&a.indexOf("dev")>-1&&(e=this.cloud_props.hosts.debugCloudUrl,d=this.cloud_props.hosts.debugCloudType),b=e}return b=c(b),this.cloud_host=b,"fh"===d&&(this.isLegacy=!0),b},e.prototype.getActUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.isLegacy?this.cloud_host+f.boxprefix+"act/"+this.cloud_props.domain+"/"+b.appid+"/"+a+"/"+b.appid:this.cloud_host+"/cloud/"+a},e.prototype.getMBAASUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.cloud_host+"/mbaas/"+a},e.prototype.getCloudUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.cloud_host+"/"+d(a)},b.exports=e},{"./appProps":25,"./constants":27}],34:[function(a,b){var c=(a("./loadScript"),a("../../libs/generated/lawnchair")),d=a("./lawnchair-ext"),e=a("./constants"),f=a("./fhparams"),g=a("./ajax"),h=a("./handleError"),i=a("./logger"),j=a("JSON"),k=a("./security/hash"),l=a("./appProps"),m=function(a){l.load(function(b,c){return b?a(b):n(c,a)})},n=function(a,b){if(a.loglevel&&i.setLevel(a.loglevel),a.local){var l={domain:"local",firstTime:!1,hosts:{debugCloudType:"node",debugCloudUrl:a.host,releaseCloudType:"node",releaseCloudUrl:a.host,type:"cloud_nodejs",url:a.host},init:{trackId:"000000000000000000000000"},status:"ok"};return b(null,{cloud:l})}d.addAdapter(a,k);var m={name:"fh_init_storage",adapter:["dom","webkit-sqlite","window-name"],fail:function(a,b){var c="read/save from/to local storage failed msg:"+a+" err:"+b;return fail(c,{})}};"undefined"!=typeof Titanium&&(m.adapter=["titanium"]);var n=function(a,c,d,e){var k=f.buildFHParams();g({url:a,type:"POST",tryJSONP:!0,dataType:"json",contentType:"application/json",data:j.stringify(k),timeout:c.timeout,success:function(a){e&&e.save({key:"fh_init",value:a},function(){}),b&&b(null,{cloud:a})},error:function(a,c,e){var f="unknown";a&&(f=a.status+" - "+a.responseText),i.error("App init returned error : "+f),d?(i.info("Using cached host: "+j.stringify(d)),b&&b(null,{cloud:d})):(i.error("No cached host found. Init failed."),h(function(a,c){b&&b({error:c,message:a})},a,c,e))}})},o=null,p=a.host+e.boxprefix+"app/init";try{o=new c(m,function(){}),o.get("fh_init",function(b){var c=null;b&&null!==b.value&&"undefined"!=typeof b.value&&""!==b&&(b="string"==typeof b?j.parse(b):b,b.value="string"==typeof b.value?j.parse(b.value):b.value,a.init=b.value.init?b.value.init:"string"==typeof b.value?j.parse(b.value):b.value,b.value.hosts&&(c=b.value)),n(p,a,c,o)})}catch(q){n(p,a,null,null)}};b.exports={init:m,loadCloudProps:n}},{"../../libs/generated/lawnchair":2,"./ajax":18,"./appProps":25,"./constants":27,"./fhparams":31,"./handleError":32,"./lawnchair-ext":35,"./loadScript":36,"./logger":37,"./security/hash":43,JSON:3}],35:[function(a,b){var c=a("../../libs/generated/lawnchair"),d=function(a,b){function c(a){console&&console.log(a)}function d(d,e){d=a.appid+d,b({algorithm:"MD5",text:d},function(a){var b=a.hashvalue+".txt";return"undefined"==typeof navigator.externalstorage?(c("filenameForKey key="+d+" , Filename: "+b),e(b)):void navigator.externalstorage.enable(function(a){var c=b;return a.path&&(c=a.path,c.match(/\/$/)||(c+="/"),c+=b),b=c,e(b)},function(){return e(b)})})}var e=function(a,b){if(!console)throw a;console.log("error in file system adapter !",a,b)};return{valid:function(){return!!window.requestFileSystem},init:function(a,b){a&&"function"==typeof a.fail&&(e=a.fail),b&&this.fn(this.name,b).call(this,this)},keys:function(){throw"Currently not supported"},save:function(a,b){var c=a.key,f=a.val||a.value;d(c,function(a){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(a,{create:!0},function(a){a.createWriter(function(a){a.onwrite=function(){return b({key:c,val:f})},a.write(f)},function(){e("[save] Failed to create file writer")})},function(){e("[save] Failed to getFile")})},function(){e("[save] Failed to requestFileSystem")})})},batch:function(){throw"Currently not supported"},get:function(a,b){d(a,function(c){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(c,{},function(c){c.file(function(c){var d=new FileReader;d.onloadend=function(c){var d=c.target.result;try{d=decodeURIComponent(d)}catch(e){}return b({key:a,val:d})},d.readAsText(c)},function(){e("[load] Failed to getFile")})},function(){b({key:a,val:null})})},function(){e("[load] Failed to get fileSystem")})})},exists:function(a,b){d(a,function(a){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(c){c.root.getFile(a,{},function(){return b(!0)},function(){return b(!1)})})})},all:function(){throw"Currently not supported"},remove:function(a,b){d(a,function(c){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(c,{},function(c){c.remove(function(){return b({key:a,val:null})},function(){e("[remove] Failed to remove file")})},function(){e("[remove] Failed to getFile")})},function(){e("[remove] Failed to get fileSystem")})})},nuke:function(){throw"Currently not supported"}}},e=function(a,b){c.adapter("localFileStorage",d(a,b))};b.exports={addAdapter:e}},{"../../libs/generated/lawnchair":2}],36:[function(a,b){b.exports=function(a,b){var c,d=document.head||document.getElementsByTagName("head")[0]||document.documentElement;c=document.createElement("script"),c.async="async",c.src=a,c.type="text/javascript",c.onload=c.onreadystatechange=function(){(!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,d&&c.parentNode&&d.removeChild(c),c=void 0,b&&"function"==typeof b&&b())},d.insertBefore(c,d.firstChild)}},{}],37:[function(a,b){var c=(a("console"),a("loglevel"));c.setLevel("info"),b.exports=c},{console:8,loglevel:14}],38:[function(a,b){b.exports=[{destination:"ipad",test:["iPad"]},{destination:"iphone",test:["iPhone"]},{destination:"android",test:["Android"]},{destination:"blackberry",test:["BlackBerry","BB10","RIM Tablet OS"]},{destination:"windowsphone",test:["Windows Phone 8"]},{destination:"windowsphone7",test:["Windows Phone OS 7"]}]},{}],39:[function(a,b){b.exports=function(a){var b={},c=a.split("?");if(2===c.length){var d=c[1],e=d.split("&");b={};for(var f=0;f100&&(e/=8),"undefined"==typeof d?c("security library is not loaded."):b({algorithm:"AES",secretkey:f(e),iv:f(e)})};b.exports=g},{"../../../libs/rsa":4}],42:[function(a,b){var c=a("../../../libs/generated/crypto"),d=function(a,b,d){var e=["key","plaintext","iv"];if("aes"!==a.params.algorithm.toLowerCase())return d("encrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return d("no_params_"+g,{},a)}var h=c.AES.encrypt(a.params.plaintext,c.enc.Hex.parse(a.params.key),{iv:c.enc.Hex.parse(a.params.iv)});return cipher_text=c.enc.Hex.stringify(h.ciphertext),b({ciphertext:cipher_text})},e=function(a,b,d){var e=["key","ciphertext","iv"];if("aes"!==a.params.algorithm.toLowerCase())return d("decrypt_bad_algorithm",{},a); +for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return d("no_params_"+g,{},a)}var h=c.enc.Hex.parse(a.params.ciphertext),i=c.enc.Base64.stringify(h),j=c.AES.decrypt(i,c.enc.Hex.parse(a.params.key),{iv:c.enc.Hex.parse(a.params.iv)});return plain_text=j.toString(c.enc.Utf8),b({plaintext:plain_text})};b.exports={encrypt:d,decrypt:e}},{"../../../libs/generated/crypto":1}],43:[function(a,b){var c=a("../../../libs/generated/crypto"),d=function(a,b,d){if(!a.params.text)return void d("hash_no_text",{},a);var e;if("md5"===a.params.algorithm.toLowerCase())e=c.MD5(a.params.text).toString(c.enc.Hex);else if("sha1"===a.params.algorithm.toLowerCase())e=c.SHA1(a.params.text).toString(c.enc.Hex);else if("sha256"===a.params.algorithm.toLowerCase())e=c.SHA256(a.params.text).toString(c.enc.Hex);else{if("sha512"!==a.params.algorithm.toLowerCase())return d("hash_unsupported_algorithm: "+a.params.algorithm);e=c.SHA512(a.params.text).toString(c.enc.Hex)}return b({hashvalue:e})};b.exports=d},{"../../../libs/generated/crypto":1}],44:[function(a,b){var c=a("../../../libs/rsa"),d=c.RSAKey,e=function(a,b,c){var e=["modulu","plaintext"];if("rsa"!==a.params.algorithm.toLowerCase())return c("encrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return c("no_params_"+g,{},a)}var h=new d;h.setPublic(a.params.modulu,"10001");var i=a.params.plaintext;return cipher_text=h.encrypt(i),b({ciphertext:cipher_text})};b.exports={encrypt:e}},{"../../../libs/rsa":4}],45:[function(a,b){var c=a("JSON"),d=a("./api_act"),e=a("./api_cloud"),f=a("../../libs/generated/crypto"),g=a("../../libs/generated/lawnchair"),h={defaults:{sync_frequency:10,auto_sync_local_updates:!0,notify_client_storage_failed:!0,notify_sync_started:!0,notify_sync_complete:!0,notify_offline_update:!0,notify_collision_detected:!0,notify_remote_update_failed:!0,notify_local_update_applied:!0,notify_remote_update_applied:!0,notify_delta_received:!0,notify_record_delta_received:!0,notify_sync_failed:!0,do_console_log:!1,crashed_count_wait:10,resend_crashed_updates:!0,sync_active:!0,storage_strategy:"html5-filesystem",file_system_quota:61644800,has_custom_sync:null},notifications:{CLIENT_STORAGE_FAILED:"client_storage_failed",SYNC_STARTED:"sync_started",SYNC_COMPLETE:"sync_complete",OFFLINE_UPDATE:"offline_update",COLLISION_DETECTED:"collision_detected",REMOTE_UPDATE_FAILED:"remote_update_failed",REMOTE_UPDATE_APPLIED:"remote_update_applied",LOCAL_UPDATE_APPLIED:"local_update_applied",DELTA_RECEIVED:"delta_received",RECORD_DELTA_RECEIVED:"record_delta_received",SYNC_FAILED:"sync_failed"},datasets:{},config:void 0,notify_callback:void 0,init_is_called:!1,init:function(a){h.consoleLog("sync - init called"),h.config=c.parse(c.stringify(h.defaults));for(var b in a)h.config[b]=a[b];h.init_is_called||(h.init_is_called=!0,h.datasetMonitor())},notify:function(a){h.notify_callback=a},manage:function(a,b,d,e,f){h.consoleLog("manage - START");var b=b||{},g=function(g){h.consoleLog("doManage dataset :: initialised = "+g.initialised+" :: "+a+" :: "+c.stringify(b));var i=h.setOptions(b);g.query_params=d||g.query_params||{},g.meta_data=e||g.meta_data||{},g.config=i,g.syncRunning=!1,g.syncPending=!0,g.initialised=!0,"undefined"==typeof g.meta&&(g.meta={}),h.saveDataSet(a,function(){f&&f()})};h.getDataSet(a,function(a){h.consoleLog("manage - dataset already loaded"),g(a)},function(){h.consoleLog("manage - dataset not loaded... trying to load"),h.loadDataSet(a,function(b){h.consoleLog("manage - dataset loaded from local storage"),h.doNotify(a,null,h.notifications.LOCAL_UPDATE_APPLIED,"load"),g(b)},function(){h.consoleLog("manage - Creating new dataset for id "+a);var b={};b.data={},b.pending={},b.meta={},h.datasets[a]=b,g(b)})})},setOptions:function(a){h.config||(h.config=c.parse(c.stringify(h.defaults)));var b=c.parse(c.stringify(h.config)),d=c.parse(c.stringify(a));for(var e in d)b[e]=d[e];return b},list:function(a,b,d){h.getDataSet(a,function(a){if(a&&a.data){var e=c.parse(c.stringify(a.data));b(e)}else d&&d("no_data")},function(a,b){d&&d(a,b)})},create:function(a,b,c,d){return null==b&&d?d("null_data"):void h.addPendingObj(a,null,b,"create",c,d)},read:function(a,b,d,e){h.getDataSet(a,function(a){var f=a.data[b];if(f){var g=c.parse(c.stringify(f));d(g)}else e("unknown_uid")},function(a,b){e&&e(a,b)})},update:function(a,b,c,d,e){h.addPendingObj(a,b,c,"update",d,e)},"delete":function(a,b,c,d){h.addPendingObj(a,b,null,"delete",c,d)},getPending:function(a,b){h.getDataSet(a,function(a){var c;a&&(c=a.pending),b(c)},function(a){h.consoleLog(a)})},clearPending:function(a,b){h.getDataSet(a,function(c){c.pending={},h.saveDataSet(a,b)})},listCollisions:function(a,b,c){h.getDataSet(a,function(d){h.doCloudCall({dataset_id:a,req:{fn:"listCollisions",meta_data:d.meta_data}},b,c)},c)},removeCollision:function(a,b,c,d){h.getDataSet(a,function(e){h.doCloudCall({dataset_id:a,req:{fn:"removeCollision",hash:b,meta_data:e.meta_data}},c,d)})},isOnline:function(a){var b=!0;if("undefined"!=typeof navigator.onLine&&(b=navigator.onLine),b&&"undefined"!=typeof navigator.network&&"undefined"!=typeof navigator.network.connection){var c=navigator.network.connection.type;("none"===c||null===c)&&(b=!1)}return a(b)},doNotify:function(a,b,c,d){if(h.notify_callback&&h.config["notify_"+c]){var e={dataset_id:a,uid:b,code:c,message:d};setTimeout(function(){h.notify_callback(e)},0)}},getDataSet:function(a,b,c){var d=h.datasets[a];d?b(d):c&&c("unknown_dataset "+a,a)},getQueryParams:function(a,b,c){var d=h.datasets[a];d?b(d.query_params):c&&c("unknown_dataset "+a,a)},setQueryParams:function(a,b,c,d){var e=h.datasets[a];e?(e.query_params=b,h.saveDataSet(a),c&&c(e.query_params)):d&&d("unknown_dataset "+a,a)},getMetaData:function(a,b,c){var d=h.datasets[a];d?b(d.meta_data):c&&c("unknown_dataset "+a,a)},setMetaData:function(a,b,c,d){var e=h.datasets[a];e?(e.meta_data=b,h.saveDataSet(a),c&&c(e.meta_data)):d&&d("unknown_dataset "+a,a)},getConfig:function(a,b,c){var d=h.datasets[a];d?b(d.config):c&&c("unknown_dataset "+a,a)},setConfig:function(a,b,c,d){var e=h.datasets[a];if(e){var f=h.setOptions(b);e.config=f,h.saveDataSet(a),c&&c(e.config)}else d&&d("unknown_dataset "+a,a)},stopSync:function(a,b,c){h.setConfig(a,{sync_active:!1},function(){b&&b()},c)},startSync:function(a,b,c){h.setConfig(a,{sync_active:!0},function(){b&&b()},c)},doSync:function(a,b,c){var d=h.datasets[a];d?(d.syncPending=!0,h.saveDataSet(a),b&&b()):c&&c("unknown_dataset "+a,a)},forceSync:function(a,b,c){var d=h.datasets[a];d?(d.syncForced=!0,h.saveDataSet(a),b&&b()):c&&c("unknown_dataset "+a,a)},sortObject:function(a){if("object"!=typeof a||null===a)return a;var b=[];return Object.keys(a).sort().forEach(function(c){b.push({key:c,value:h.sortObject(a[c])})}),b},sortedStringify:function(a){var b="";try{b=c.stringify(h.sortObject(a))}catch(d){console.error("Error stringifying sorted object:"+d)}return b},generateHash:function(a){var b=f.SHA1(h.sortedStringify(a));return b.toString()},addPendingObj:function(a,b,d,e,f,g){function i(c){c.hash=h.generateHash(c),h.getDataSet(a,function(d){d.pending[c.hash]=c,h.updateDatasetFromLocal(d,c),h.config.auto_sync_local_updates&&(d.syncPending=!0),h.saveDataSet(a),h.doNotify(a,b,h.notifications.LOCAL_UPDATE_APPLIED,e),f(c)},function(a,b){g&&g(a,b)})}h.isOnline(function(c){c||h.doNotify(a,b,h.notifications.OFFLINE_UPDATE,e)});var j={};j.inFlight=!1,j.action=e,j.post=c.parse(c.stringify(d)),j.postHash=h.generateHash(j.post),j.timestamp=(new Date).getTime(),"create"===e?(j.uid=j.postHash,i(j)):h.read(a,b,function(a){j.uid=b,j.pre=a.data,j.preHash=h.generateHash(a.data),i(j)},function(a,b){g&&g(a,b)})},syncLoop:function(a){h.getDataSet(a,function(b){b.syncPending=!1,b.syncRunning=!0,b.syncLoopStart=(new Date).getTime(),h.doNotify(a,null,h.notifications.SYNC_STARTED,null),h.isOnline(function(d){d?h.checkHasCustomSync(a,function(){var d={};d.fn="sync",d.dataset_id=a,d.query_params=b.query_params,d.config=b.config,d.meta_data=b.meta_data,d.dataset_hash=b.hash,d.acknowledgements=b.acknowledgements||[];var e=b.pending,f=[];for(var g in e)e[g].inFlight||e[g].crashed||e[g].delayed||(e[g].inFlight=!0,e[g].inFlightDate=(new Date).getTime(),f.push(e[g]));d.pending=f,f.length>0&&h.consoleLog("Starting sync loop - global hash = "+b.hash+" :: params = "+c.stringify(d,null,2));try{h.doCloudCall({dataset_id:a,req:d},function(c){function d(c,d,f){if(c)for(var g in c)e=c[g],f.push(e),b.pending[g]&&b.pending[g].inFlight&&!b.pending[g].crashed&&(delete b.pending[g],h.doNotify(a,e.uid,d,e))}var e;if(h.updatePendingFromNewData(a,b,c),h.updateCrashedInFlightFromNewData(a,b,c),h.updateDelayedFromNewData(a,b,c),h.updateMetaFromNewData(a,b,c),h.updateNewDataFromInFlight(a,b,c),h.updateNewDataFromPending(a,b,c),c.records&&(b.data=c.records,b.hash=c.hash,h.doNotify(a,c.hash,h.notifications.DELTA_RECEIVED,"full dataset")),c.updates){var f=[];d(c.updates.applied,h.notifications.REMOTE_UPDATE_APPLIED,f),d(c.updates.failed,h.notifications.REMOTE_UPDATE_FAILED,f),d(c.updates.collisions,h.notifications.COLLISION_DETECTED,f),b.acknowledgements=f}!c.records&&c.hash&&c.hash!==b.hash?(h.consoleLog("Local dataset stale - syncing records :: local hash= "+b.hash+" - remoteHash="+c.hash),h.syncRecords(a)):(h.consoleLog("Local dataset up to date"),h.syncComplete(a,"online",h.notifications.SYNC_COMPLETE))},function(c,d){h.markInFlightAsCrashed(b),h.consoleLog("syncLoop failed : msg="+c+" :: err = "+d),h.syncComplete(a,c,h.notifications.SYNC_FAILED)})}catch(i){h.consoleLog("Error performing sync - "+i),h.syncComplete(a,i,h.notifications.SYNC_FAILED)}}):h.syncComplete(a,"offline",h.notifications.SYNC_FAILED)})})},syncRecords:function(a){h.getDataSet(a,function(b){var d=b.data||{},e={};for(var f in d){var g=f,i=d[f].hash;e[g]=i}var j={};j.fn="syncRecords",j.dataset_id=a,j.query_params=b.query_params,j.clientRecs=e,h.consoleLog("syncRecParams :: "+c.stringify(j)),h.doCloudCall({dataset_id:a,req:j},function(c){var e;if(c.create)for(e in c.create)d[e]={hash:c.create[e].hash,data:c.create[e].data},h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"create");if(c.update)for(e in c.update)d[e].hash=c.update[e].hash,d[e].data=c.update[e].data,h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"update");if(c["delete"])for(e in c["delete"])delete d[e],h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"delete");h.doNotify(a,c.hash,h.notifications.DELTA_RECEIVED,"partial dataset"),b.data=d,c.hash&&(b.hash=c.hash),h.syncComplete(a,"online",h.notifications.SYNC_COMPLETE)},function(b,c){h.consoleLog("syncRecords failed : msg="+b+" :: err="+c),h.syncComplete(a,b,h.notifications.SYNC_FAILED)})})},syncComplete:function(a,b,c){h.getDataSet(a,function(d){d.syncRunning=!1,d.syncLoopEnd=(new Date).getTime(),h.saveDataSet(a),h.doNotify(a,d.hash,c,b)})},checkDatasets:function(){for(var a in h.datasets)if(h.datasets.hasOwnProperty(a)){var b=h.datasets[a];if(!b.syncRunning&&(b.config.sync_active||b.syncForced)){var c=b.syncLoopStart,d=b.syncLoopEnd;if(b.syncForced)b.syncPending=!0;else if(null==c)h.consoleLog(a+" - Performing initial sync"),b.syncPending=!0;else if(null!=d){var e=(new Date).getTime()-d,f=1e3*b.config.sync_frequency;e>f&&(b.syncPending=!0)}b.syncPending&&(b.syncForced=!1,h.syncLoop(a))}}},checkHasCustomSync:function(a,b){var c=h.datasets[a];return c&&c.config?(h.consoleLog("dataset.config.has_custom_sync = "+c.config.has_custom_sync),null!=c.config.has_custom_sync?b():(h.consoleLog("starting check has custom sync"),void d({act:a,req:{fn:"sync"}},function(a){return h.consoleLog("check has_custom_sync - success - ",a),c.config.has_custom_sync=!0,b()},function(a,d){return h.consoleLog("check has_custom_sync - failure - ",d),d.status&&500===d.status?(h.consoleLog("check has_custom_sync - failed with 500, endpoint does exists"),c.config.has_custom_sync=!0):c.config.has_custom_sync=!1,b()}))):b()},doCloudCall:function(a,b,c){var f=!1,g=h.datasets[a.dataset_id];g&&g.config&&(f=g.config.has_custom_sync),1==f?d({act:a.dataset_id,req:a.req},function(a){b(a)},function(a,b){c(a,b)}):e({path:"/mbaas/sync/"+a.dataset_id,method:"post",data:a.req},function(a){b(a)},function(a,b){c(a,b)})},datasetMonitor:function(){h.checkDatasets(),setTimeout(function(){h.datasetMonitor()},500)},saveDataSet:function(a,b){var c=function(b,c){var d="save to local storage failed msg:"+b+" err:"+c;h.doNotify(a,null,h.notifications.CLIENT_STORAGE_FAILED,d),h.consoleLog(d)};h.getDataSet(a,function(d){g({fail:c,adapter:h.config.storage_strategy,size:h.config.file_system_quota},function(){this.save({key:"dataset_"+a,val:d},function(){return b?b():void 0})})})},loadDataSet:function(a,b,d){var e=function(b){var c="load from local storage failed msg:"+b;h.doNotify(a,null,h.notifications.CLIENT_STORAGE_FAILED,c),h.consoleLog(c)};g({fail:e,adapter:h.config.storage_strategy,size:h.config.file_system_quota},function(){this.get("dataset_"+a,function(e){if(e&&e.val){var f=e.val;if("string"==typeof f&&(f=c.parse(f)),f.initialised=!1,h.datasets[a]=f,h.consoleLog("load from local storage success for dataset_id :"+a),b)return b(f)}else if(d)return d()})})},updateDatasetFromLocal:function(a,b){var d,e,f=a.pending,g=b.uid;h.consoleLog("updating local dataset for uid "+g+" - action = "+b.action),a.meta[g]=a.meta[g]||{},"create"===b.action&&(a.data[g]&&(h.consoleLog("dataset already exists for uid in create :: "+c.stringify(a.data[g])),a.meta[g].fromPending&&(d=a.meta[g].pendingUid,delete f[d])),a.data[g]={}),"update"===b.action&&a.data[g]&&a.meta[g].fromPending&&(h.consoleLog("updating an existing pending record for dataset :: "+c.stringify(a.data[g])),d=a.meta[g].pendingUid,a.meta[g].previousPendingUid=d,e=f[d],e&&(e.inFlight?(h.consoleLog("existing in-inflight pending record = "+c.stringify(e)),b.delayed=!0,b.waiting=e.hash):(h.consoleLog("existing pre-flight pending record = "+c.stringify(e)),e.post=b.post,e.postHash=b.postHash,delete f[b.hash],b.hash=d))),"delete"===b.action&&a.data[g]&&(a.meta[g].fromPending&&(h.consoleLog("Deleting an existing pending record for dataset :: "+c.stringify(a.data[g])),d=a.meta[g].pendingUid,a.meta[g].previousPendingUid=d,e=f[d],e&&(e.inFlight?(h.consoleLog("existing in-inflight pending record = "+c.stringify(e)),b.delayed=!0,b.waiting=e.hash):(h.consoleLog("existing pending record = "+c.stringify(e)),"create"===e.action&&(delete f[b.hash],delete f[d]),"update"===e.action&&(b.pre=e.pre,b.preHash=e.preHash,b.inFlight=!1,delete f[d])))),delete a.data[g]),a.data[g]&&(a.data[g].data=b.post,a.data[g].hash=b.postHash,a.meta[g].fromPending=!0,a.meta[g].pendingUid=b.hash)},updatePendingFromNewData:function(a,b,d){var e,f=b.pending;if(f&&d.records)for(var g in f)if(f.hasOwnProperty(g)){var i=f[g];if(b.meta[i.uid]=b.meta[i.uid]||{},i.inFlight===!1){if(h.consoleLog("updatePendingFromNewData - Found Non inFlight record -> action="+i.action+" :: uid="+i.uid+" :: hash="+i.hash),"update"===i.action||"delete"===i.action)if(e=d.records[i.uid])h.consoleLog("updatePendingFromNewData - Updating pre values for existing pending record "+i.uid),i.pre=e.data,i.preHash=e.hash;else{var j=b.meta[i.uid].previousPendingUid,k=f[j];if(k&&d&&d.updates&&d.updates.applied&&d.updates.applied[k.hash]){var l=d.updates.applied[k.hash].uid;e=d.records[l],e&&(h.consoleLog("updatePendingFromNewData - Updating pre values for existing pending record which was previously a create "+i.uid+" ==> "+l),i.pre=e.data,i.preHash=e.hash,i.uid=l)}}"create"===i.action&&d&&d.updates&&d.updates.applied&&d.updates.applied[g]&&(h.consoleLog("updatePendingFromNewData - Found an update for a pending create "+c.stringify(d.updates.applied[g])),e=d.records[d.updates.applied[g].uid],e&&(h.consoleLog("updatePendingFromNewData - Changing pending create to an update based on new record "+c.stringify(e)),i.action="update",i.pre=e.data,i.preHash=e.hash,i.uid=d.updates.applied[g].uid))}}},updateNewDataFromInFlight:function(a,b,c){var d=b.pending;if(d&&c.records)for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];if(f.inFlight){var g=c&&c.updates&&c.updates.hashes&&c.updates.hashes[e]?!0:!1;if(h.consoleLog("updateNewDataFromInFlight - Found inflight pending Record - action = "+f.action+" :: hash = "+e+" :: updateReceivedForPending="+g),!g){var i=c.records[f.uid];if("update"===f.action&&i)i.data=f.post,i.hash=f.postHash;else if("delete"===f.action&&i)delete c.records[f.uid];else if("create"===f.action){h.consoleLog("updateNewDataFromInFlight - re adding pending create to incomming dataset");var j={data:f.post,hash:f.postHash};c.records[f.uid]=j}}}}},updateNewDataFromPending:function(a,b,c){var d=b.pending;if(d&&c.records)for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];if(f.inFlight===!1){h.consoleLog("updateNewDataFromPending - Found Non inFlight record -> action="+f.action+" :: uid="+f.uid+" :: hash="+f.hash);var g=c.records[f.uid];if("update"===f.action&&g)g.data=f.post,g.hash=f.postHash;else if("delete"===f.action&&g)delete c.records[f.uid];else if("create"===f.action){h.consoleLog("updateNewDataFromPending - re adding pending create to incomming dataset");var i={data:f.post,hash:f.postHash};c.records[f.uid]=i}}}},updateCrashedInFlightFromNewData:function(a,b,d){var e,f,g={applied:h.notifications.REMOTE_UPDATE_APPLIED,failed:h.notifications.REMOTE_UPDATE_FAILED,collisions:h.notifications.COLLISION_DETECTED},i=b.pending,j={};if(i){for(e in i)if(i.hasOwnProperty(e)&&(f=i[e],f.inFlight&&f.crashed))if(h.consoleLog("updateCrashedInFlightFromNewData - Found crashed inFlight pending record uid="+f.uid+" :: hash="+f.hash),d&&d.updates&&d.updates.hashes){var k=d.updates.hashes[e];k?(j[k.uid]=k,h.consoleLog("updateCrashedInFlightFromNewData - Resolving status for crashed inflight pending record "+c.stringify(k)),"failed"===k.type&&("create"===k.action?(h.consoleLog("updateCrashedInFlightFromNewData - Deleting failed create from dataset"),delete b.data[k.uid]):("update"===k.action||"delete"===k.action)&&(h.consoleLog("updateCrashedInFlightFromNewData - Reverting failed "+k.action+" in dataset"),b.data[k.uid]={data:f.pre,hash:f.preHash})),delete i[e],h.doNotify(a,k.uid,g[k.type],k)):f.crashedCount?f.crashedCount++:f.crashedCount=1}else f.crashedCount?f.crashedCount++:f.crashedCount=1;for(e in i)i.hasOwnProperty(e)&&(f=i[e],f.inFlight&&f.crashed&&f.crashedCount>b.config.crashed_count_wait&&(h.consoleLog("updateCrashedInFlightFromNewData - Crashed inflight pending record has reached crashed_count_wait limit : "+c.stringify(f)),b.config.resend_crashed_updates?(h.consoleLog("updateCrashedInFlightFromNewData - Retryig crashed inflight pending record"),f.crashed=!1,f.inFlight=!1):(h.consoleLog("updateCrashedInFlightFromNewData - Deleting crashed inflight pending record"),delete i[e])))}},updateDelayedFromNewData:function(a,b,d){var e,f,g=b.pending;if(g)for(e in g)if(g.hasOwnProperty(e)&&(f=g[e],f.delayed&&f.waiting&&(h.consoleLog("updateDelayedFromNewData - Found delayed pending record uid="+f.uid+" :: hash="+f.hash+" :: waiting="+f.waiting),d&&d.updates&&d.updates.hashes))){var i=d.updates.hashes[f.waiting];i&&(h.consoleLog("updateDelayedFromNewData - Waiting pending record is resolved rec="+c.stringify(i)),f.delayed=!1,f.waiting=void 0)}},updateMetaFromNewData:function(a,b,d){var e=b.meta;if(e&&d&&d.updates&&d.updates.hashes)for(var f in e)if(e.hasOwnProperty(f)){var g=e[f],i=g.pendingUid,j=g.previousPendingUid;h.consoleLog("updateMetaFromNewData - Found metadata with uid = "+f+" :: pendingHash = "+i+" :: previousPendingHash ="+j);var k=!0,l=!0;if(j){k=!1;var m=d.updates.hashes[j];m&&(h.consoleLog("updateMetaFromNewData - Found previousPendingUid in meta data resolved - resolved = "+c.stringify(m)),g.previousPendingUid=void 0,k=!0)}if(i){l=!1;var m=d.updates.hashes[i];m&&(h.consoleLog("updateMetaFromNewData - Found pendingUid in meta data resolved - resolved = "+c.stringify(m)),g.pendingUid=void 0,l=!0)}k&&l&&(h.consoleLog("updateMetaFromNewData - both previous and current pendings are resolved for meta data with uid "+f+". Delete it."),delete e[f])}},markInFlightAsCrashed:function(a){var b,c,d=a.pending;if(d){var e={};for(b in d)d.hasOwnProperty(b)&&(c=d[b],c.inFlight&&(h.consoleLog("Marking in flight pending record as crashed : "+b),c.crashed=!0,e[c.uid]=c))}},consoleLog:function(a){h.config.do_console_log&&console.log(a)}};!function(){h.config=h.defaults}(),b.exports={init:h.init,manage:h.manage,notify:h.notify,doList:h.list,doCreate:h.create,doRead:h.read,doUpdate:h.update,doDelete:h["delete"],listCollisions:h.listCollisions,removeCollision:h.removeCollision,getPending:h.getPending,clearPending:h.clearPending,getDataset:h.getDataSet,getQueryParams:h.getQueryParams,setQueryParams:h.setQueryParams,getMetaData:h.getMetaData,setMetaData:h.setMetaData,getConfig:h.getConfig,setConfig:h.setConfig,startSync:h.startSync,stopSync:h.stopSync,doSync:h.doSync,forceSync:h.forceSync,generateHash:h.generateHash,loadDataSet:h.loadDataSet,checkHasCustomSync:h.checkHasCustomSync}},{"../../libs/generated/crypto":1,"../../libs/generated/lawnchair":2,"./api_act":19,"./api_cloud":21,JSON:3}],46:[function(a,b){b.exports={createUUID:function(){for(var a=[],b="0123456789ABCDEF",c=0;32>c;c++)a[c]=b.substr(Math.floor(16*Math.random()),1);a[12]="4",a[16]=b.substr(3&a[16]|8,1);var d=a.join("");return d}}},{}],47:[function(a,b){var c,d=a("./initializer"),e=a("./events"),f=a("./hosts"),g=a("./constants"),h=a("./logger"),i=!1,j=!1,k=null,l=function(a){return j?a(null,{host:n()}):(e.once(g.INIT_EVENT,function(b,c){return a(b,c)}),void(i||(i=!0,d.init(function(a,b){return i=!1,a?(k=a,e.emit(g.INIT_EVENT,a)):(k=null,j=!0,c=new f(b.cloud),e.emit(g.INIT_EVENT,null,{host:n()}))}))))},m=function(){return c},n=function(){if("undefined"!=typeof c){var b=a("./appProps").getAppProps();return c.getHost(b.mode)}return void 0},o=function(){return j},p=function(){return k},q=function(){j=!1,i=!1,c=void 0,k=void 0,l(function(){})};l(function(a){a?"app_config_missing"!==a.message?h.error("Failed to initialise fh."):h.info("No fh config file"):h.info("fh cloud is ready")}),b.exports={ready:l,isReady:o,getCloudHost:m,getCloudHostUrl:n,getInitError:p,reset:q}},{"./appProps":25,"./constants":27,"./events":30,"./hosts":33,"./initializer":34,"./logger":37}]},{},[16])(16)}),function(root){if(!JSON)var JSON=function(){function f(a){return 10>a?"0"+a:a}function quote(a){return escapeable.test(a)?'"'+a.replace(escapeable,function(a){var b=meta[a];return"string"==typeof b?b:(b=a.charCodeAt(),"\\u00"+Math.floor(b/16).toString(16)+(b%16).toString(16))})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g,h=gap,i=b[a];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(a)),"function"==typeof rep&&(i=rep.call(b,a,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";if(gap+=indent,g=[],"number"==typeof i.length&&!i.propertyIsEnumerable("length")){for(f=i.length,c=0;f>c;c+=1)g[c]=str(c,i)||"null";return e=0===g.length?"[]":gap?"[\n"+gap+g.join(",\n"+gap)+"\n"+h+"]":"["+g.join(",")+"]",gap=h,e}if("object"==typeof rep)for(f=rep.length,c=0;f>c;c+=1)d=rep[c],"string"==typeof d&&(e=str(d,i,rep),e&&g.push(quote(d)+(gap?": ":":")+e));else for(d in i)e=str(d,i,rep),e&&g.push(quote(d)+(gap?": ":":")+e);return e=0===g.length?"{}":gap?"{\n"+gap+g.join(",\n"+gap)+"\n"+h+"}":"{"+g.join(",")+"}",gap=h,e}}Date.prototype.toJSON=function(){return this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z"};var escapeable=/["\\\x00-\x1f\x7f-\x9f]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;return{stringify:function(a,b,c){var d;if(gap="",indent="",c)if("number"==typeof c)for(d=0;c>d;d+=1)indent+=" ";else"string"==typeof c&&(indent=c);if(b){if("function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");rep=b}else rep=function(a,b){return Object.hasOwnProperty.call(this,a)?b:void 0};return str("",{"":a})},parse:function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&"object"==typeof e)for(c in e)Object.hasOwnProperty.call(e,c)&&(d=walk(e,c),void 0!==d?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;if(/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/bfnrtu]/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")},quote:quote}}();if(function(){if(!window.google||!google.gears){var a=null;if("undefined"!=typeof GearsFactory)a=new GearsFactory;else try{a=new ActiveXObject("Gears.Factory"),-1!=a.getBuildInfo().indexOf("ie_mobile")&&a.privateSetGlobalObject(this)}catch(b){"undefined"!=typeof navigator.mimeTypes&&navigator.mimeTypes["application/x-googlegears"]&&(a=document.createElement("object"),a.style.display="none",a.width=0,a.height=0,a.type="application/x-googlegears",document.documentElement.appendChild(a))}a&&(window.google||(google={}),google.gears||(google.gears={factory:a}))}}(),Persist=function(){var a,b,c,d,e,f,g="0.2.0";f=function(){var a,b="Thu, 01-Jan-1970 00:00:01 GMT",c=864e5,d=["expires","path","domain"],e=escape,f=unescape,g=document,h=function(){var a=new Date;return a.setTime(a.getTime()),a},j=function(a,b){var c,f,g,h=[],i=arguments.length>2?arguments[2]:{};for(h.push(e(a)+"="+e(b)),c=0;c2?arguments[2]:{},e=h(),f={};d.expires&&(d.expires*=c,f.expires=new Date(e.getTime()+d.expires),f.expires=f.expires.toGMTString());var k=["path","domain","secure"];for(i=0;ic?!1:!0},get:function(a){a=e(a);var b,c=g.cookie,d=c.indexOf(a+"="),h=d+a.length+1,i=c.substring(0,a.length);return!d&&a!=i||0>d?null:(b=c.indexOf(";",h),0>b&&(b=c.length),f(c.substring(h,b)))},remove:function(c){var d=a.get(c),e={expires:b};return g.cookie=j(c,"",e),d},keys:function(){var a,b,c=g.cookie,d=c.split("; "),e=[];for(a=0;ac;c++)if(a[c]==b)return c;return-1}}();e=function(){},c=function(a){return"PS"+a.replace(/_/g,"__").replace(/ /g,"_s")},C={search_order:["localstorage","whatwg_db","globalstorage","gears","ie","flash","cookie"],name_re:/^[a-z][a-z0-9_ -]+$/i,methods:["init","get","set","remove","load","save"],sql:{version:"1",create:"CREATE TABLE IF NOT EXISTS persist_data (k TEXT UNIQUE NOT NULL PRIMARY KEY, v TEXT NOT NULL)",get:"SELECT v FROM persist_data WHERE k = ?",set:"INSERT INTO persist_data(k, v) VALUES (?, ?)",remove:"DELETE FROM persist_data WHERE k = ?"},flash:{div_id:"_persist_flash_wrap",id:"_persist_flash",path:"persist.swf",size:{w:1,h:1},args:{autostart:!0}}},b={gears:{size:-1,test:function(){try{return window.google&&window.google.gears?!0:!1}catch(a){return!1}},methods:{transaction:function(a){var b=this.db;b.execute("BEGIN").close(),a.call(this,b),b.execute("COMMIT").close()},init:function(){var a;a=this.db=google.gears.factory.create("beta.database"),a.open(c(this.name)),a.execute(C.sql.create).close()},get:function(a,b,c){var d,e=C.sql.get;b&&this.transaction(function(f){var g,h;d=f.execute(e,[a]),g=d.isValidRow(),h=g?d.field(0):null,d.close(),b.call(c||this,g,h)})},set:function(a,b,c,d){var e=C.sql.remove,f=C.sql.set;this.transaction(function(g){g.execute(e,[a]).close(),g.execute(f,[a,b]).close(),c&&c.call(d||this,!0,b)})},remove:function(a,b,c){var d=C.sql.get;sql=C.sql.remove,val=null,is_valid=!1,this.transaction(function(e){b&&(r=e.execute(d,[a]),is_valid=r.isValidRow(),val=is_valid?r.field(0):null,r.close()),(!b||is_valid)&&e.execute(sql,[a]).close(),b&&b.call(c||this,is_valid,val)})}}},whatwg_db:{size:204800,test:function(){try{var a="PersistJS Test",c="Persistent database test.";return window.openDatabase&&window.openDatabase(a,C.sql.version,c,b.whatwg_db.size)?!0:!1}catch(d){return!1}},methods:{transaction:function(a){this.db_created||this.db.transaction(function(a){a.executeSql(C.sql.create,[],function(){this.db_created=!0})},e),this.db.transaction(a)},init:function(){this.db=openDatabase(this.name,C.sql.version,this.o.about||"Persistent storage for "+this.name,this.o.size||b.whatwg_db.size)},get:function(a,b,c){var d=C.sql.get;b&&(c=c||this,this.transaction(function(e){e.executeSql(d,[a],function(a,d){d.rows.length>0?b.call(c,!0,d.rows.item(0).v):b.call(c,!1,null)})}))},set:function(a,b,c,d){var e=C.sql.remove,f=C.sql.set;return this.transaction(function(g){g.executeSql(e,[a],function(){g.executeSql(f,[a,b],function(){c&&c.call(d||this,!0,b)})})}),b},remove:function(a,b,c){var d=C.sql.get;sql=C.sql.remove,this.transaction(function(e){b?e.executeSql(d,[a],function(d,e){if(e.rows.length>0){var f=e.rows.item(0).v;d.executeSql(sql,[a],function(){b.call(c||this,!0,f)})}else b.call(c||this,!1,null)}):e.executeSql(sql,[a])})}}},globalstorage:{size:5242880,test:function(){try{return window.globalStorage?!0:!1}catch(a){return!1}},methods:{key:function(a){return c(this.name)+c(a)},init:function(){alert("domain = "+this.o.domain),this.store=globalStorage[this.o.domain]},get:function(a,b,c){a=this.key(a),b&&b.call(c||this,!0,this.store.getItem(a))},set:function(a,b,c,d){a=this.key(a),this.store.setItem(a,b),c&&c.call(d||this,!0,b)},remove:function(a,b,c){var d;a=this.key(a),d=this.store[a],this.store.removeItem(a),b&&b.call(c||this,null!==d,d)}}},localstorage:{size:-1,test:function(){try{return window.localStorage?!0:!1}catch(a){return!1}},methods:{key:function(a){return c(this.name)+c(a)},init:function(){this.store=localStorage},get:function(a,b,c){a=this.key(a),b&&b.call(c||this,!0,this.store.getItem(a))},set:function(a,b,c,d){a=this.key(a),this.store.setItem(a,b),c&&c.call(d||this,!0,b)},remove:function(a,b,c){var d;a=this.key(a),d=this.store.getItem(a),this.store.removeItem(a),b&&b.call(c||this,null!==d,d)}}},ie:{prefix:"_persist_data-",size:65536,test:function(){try{return window.ActiveXObject?!0:!1}catch(a){return!1}},make_userdata:function(a){var b=document.createElement("div");return b.id=a,b.style.display="none",b.addBehavior("#default#userdata"),document.body.appendChild(b),b},methods:{init:function(){var a=b.ie.prefix+c(this.name);this.el=b.ie.make_userdata(a),this.o.defer&&this.load()},get:function(a,b,d){var e;a=c(a),this.o.defer||this.load(),e=this.el.getAttribute(a),b&&b.call(d||this,e?!0:!1,e)},set:function(a,b,d,e){a=c(a),this.el.setAttribute(a,b),this.o.defer||this.save(),d&&d.call(e||this,!0,b)},remove:function(a,b,d){var e;a=c(a),this.o.defer||this.load(),e=this.el.getAttribute(a),this.el.removeAttribute(a),this.o.defer||this.save(),b&&b.call(d||this,e?!0:!1,e)},load:function(){this.el.load(c(this.name))},save:function(){this.el.save(c(this.name))}}},cookie:{delim:":",size:4e3,test:function(){try{return a.Cookie.enabled?!0:!1}catch(b){return!1}},methods:{key:function(a){return this.name+b.cookie.delim+a},get:function(a,b,c){var d;a=this.key(a),d=f.get(a),b&&b.call(c||this,null!=d,d)},set:function(a,b,c,d){a=this.key(a),f.set(a,b,this.o),c&&c.call(d||this,!0,b)},remove:function(a,b,c,d){var b;a=this.key(a),b=f.remove(a),c&&c.call(d||this,null!=b,b)}}},flash:{test:function(){try{if(!deconcept||!deconcept.SWFObjectUtil)return!1;var a=deconcept.SWFObjectUtil.getPlayerVersion().major; +return a>=8?!0:!1}catch(b){return!1}},methods:{init:function(){if(!b.flash.el){var a,c,d,e=C.flash;d=document.createElement("div"),d.id=e.div_id,document.body.appendChild(d),a=new deconcept.SWFObject(this.o.swf_path||e.path,e.id,e.size.w,e.size.h,"8");for(c in e.args)a.addVariable(c,e.args[c]);a.write(d),b.flash.el=document.getElementById(e.id)}this.el=b.flash.el},get:function(a,b,d){var e;a=c(a),e=this.el.get(this.name,a),b&&b.call(d||this,null!==e,e)},set:function(a,b,d,e){var f;a=c(a),f=this.el.set(this.name,a,b),d&&d.call(e||this,!0,b)},remove:function(a,b,d){var e;a=c(a),e=this.el.remove(this.name,a),b&&b.call(d||this,!0,e)}}}};var d=function(){var c,d,f,g,h=C.methods,i=C.search_order;for(c=0,d=h.length;d>c;c++)a.Store.prototype[h[c]]=e;for(a.type=null,a.size=-1,c=0,d=i.length;!a.type&&d>c;c++)if(f=b[i[c]],f.test()){a.type=i[c],a.size=f.size;for(g in f.methods)a.Store.prototype[g]=f.methods[g]}a._init=!0};return a={VERSION:g,type:null,size:0,add:function(a){b[a.id]=a,C.search_order=[a.id].concat(C.search_order),d()},remove:function(a){var c=h(C.search_order,a);0>c||(C.search_order.splice(c,1),delete b[a],d())},Cookie:f,Store:function(b,c){if(!C.name_re.exec(b))throw new Error("Invalid name");if(!a.type)throw new Error("No suitable storage found");c=c||{},this.name=b,c.domain=c.domain||location.host||"localhost",c.domain=c.domain.replace(/:\d+$/,""),this.o=c,c.expires=c.expires||730,c.path=c.path||"/",this.init()}},d(),a}(),"undefined"==typeof deconcept)var deconcept=new Object;"undefined"==typeof deconcept.util&&(deconcept.util=new Object),"undefined"==typeof deconcept.SWFObjectUtil&&(deconcept.SWFObjectUtil=new Object),deconcept.SWFObject=function(a,b,c,d,e,f,g,h,i,j){if(document.getElementById){this.DETECT_KEY=j?j:"detectflash",this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY),this.params=new Object,this.variables=new Object,this.attributes=new Array,a&&this.setAttribute("swf",a),b&&this.setAttribute("id",b),c&&this.setAttribute("width",c),d&&this.setAttribute("height",d),e&&this.setAttribute("version",new deconcept.PlayerVersion(e.toString().split("."))),this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion(),!window.opera&&document.all&&this.installedVer.major>7&&(deconcept.SWFObject.doPrepUnload=!0),f&&this.addParam("bgcolor",f);var k=g?g:"high";this.addParam("quality",k),this.setAttribute("useExpressInstall",!1),this.setAttribute("doExpressInstall",!1);var l=h?h:window.location;this.setAttribute("xiRedirectUrl",l),this.setAttribute("redirectUrl",""),i&&this.setAttribute("redirectUrl",i)}},deconcept.SWFObject.prototype={useExpressInstall:function(a){this.xiSWFPath=a?a:"expressinstall.swf",this.setAttribute("useExpressInstall",!0)},setAttribute:function(a,b){this.attributes[a]=b},getAttribute:function(a){return this.attributes[a]},addParam:function(a,b){this.params[a]=b},getParams:function(){return this.params},addVariable:function(a,b){this.variables[a]=b},getVariable:function(a){return this.variables[a]},getVariables:function(){return this.variables},getVariablePairs:function(){var a,b=new Array,c=this.getVariables();for(a in c)b.push(a+"="+c[a]);return b},getSWFHTML:function(){var a="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){this.getAttribute("doExpressInstall")&&(this.addVariable("MMplayerType","PlugIn"),this.setAttribute("swf",this.xiSWFPath)),a='0&&(a+='flashvars="'+d+'"'),a+="/>"}else{this.getAttribute("doExpressInstall")&&(this.addVariable("MMplayerType","ActiveX"),this.setAttribute("swf",this.xiSWFPath)),a='',a+='';var b=this.getParams();for(var c in b)a+='';var d=this.getVariablePairs().join("&");d.length>0&&(a+=''),a+=""}return a},write:function(a){if(this.getAttribute("useExpressInstall")){var b=new deconcept.PlayerVersion([6,0,65]);this.installedVer.versionIsValid(b)&&!this.installedVer.versionIsValid(this.getAttribute("version"))&&(this.setAttribute("doExpressInstall",!0),this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl"))),document.title=document.title.slice(0,47)+" - Flash Player Installation",this.addVariable("MMdoctitle",document.title))}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var c="string"==typeof a?document.getElementById(a):a;return c.innerHTML=this.getSWFHTML(),!0}return""!=this.getAttribute("redirectUrl")&&document.location.replace(this.getAttribute("redirectUrl")),!1}},deconcept.SWFObjectUtil.getPlayerVersion=function(){var a=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var b=navigator.plugins["Shockwave Flash"];b&&b.description&&(a=new deconcept.PlayerVersion(b.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split(".")))}else{try{var c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")}catch(d){try{var c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");a=new deconcept.PlayerVersion([6,0,21]),c.AllowScriptAccess="always"}catch(d){if(6==a.major)return a}try{c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(d){}}null!=c&&(a=new deconcept.PlayerVersion(c.GetVariable("$version").split(" ")[1].split(",")))}return a},deconcept.PlayerVersion=function(a){this.major=null!=a[0]?parseInt(a[0]):0,this.minor=null!=a[1]?parseInt(a[1]):0,this.rev=null!=a[2]?parseInt(a[2]):0},deconcept.PlayerVersion.prototype.versionIsValid=function(a){return this.majora.major?!0:this.minora.minor?!0:this.rev2?(e[0]=a[f-3],e[1]=a[f-2],e[2]=a[f-1]):2==f?(e[1]=a[0],e[2]=a[1]):1==f&&(e[2]=a[0]);for(var g=0,h=0;3>g;g++){var i=e[g],j=typeof i;!i||0!=h||"object"!=j&&"boolean"!=j?i&&"function"==j&&(h=0==h?1:h,d[h++]=i):d[h++]=i}if(null==d[0])d[0]=b?b:defaultargs.params;else{var k=d[0];k._defaults=[];for(var l in b)b.hasOwnProperty(l)&&"undefined"==typeof k[l]&&(k[l]=b[l],k._defaults.push(l))}d[1]=null==d[1]?defaultargs.success:d[1],d[2]=null==d[2]?defaultargs.failure:d[2],c(d[0],d[1],d[2])},eventSupported=function(a){var b=document.createElement("i");return a in b||b.setAttribute&&b.setAttribute(a,"return;")||!1},__is_ready=!1,__ready_list=[],__ready_bound=!1,boxprefix="/box/srv/1.1/";_getHostPrefix=function(){return $fh.app_props.host+boxprefix};var __ready=function(){if(!__is_ready&&(__is_ready=!0,__ready_list)){try{for(;__ready_list[0];)__ready_list.shift().apply(document,[])}finally{}__ready_list=null}},__bind_ready=function(){__ready_bound||(__ready_bound=!0,document.addEventListener?(document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,!1),__ready()},!1),window.addEventListener("load",__ready,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&(document.detachEvent("onreadystatechange",arguments.callee),__ready())}),window.attachEvent("onload",__ready),document.documentElement.doScroll&&window==window.top&&function(){if(!__is_ready){try{document.documentElement.doScroll("left")}catch(a){return void setTimeout(arguments.callee,0)}__ready()}}()))};__bind_ready();var _mapScriptLoaded="undefined"!=typeof google&&"undefined"!=typeof google.maps&&"undefined"!=typeof google.maps.Map,_mapLoadSuccessParameters=[],_mapScriptLoading=!1,_loadMapScript=function(){var a=document.createElement("script");a.type="text/javascript";var b=document.location.protocol;b="http:"===b||"https:"===b?b:"https:",a.src=b+"//maps.google.com/maps/api/js?sensor=true&callback=$fh._mapLoaded",document.body.appendChild(a)},audio_obj=null,audio_is_playing=!1;$fh.__dest__={send:function(a,b,c){c("send_nosupport")},notify:function(a,b,c){c("notify_nosupport")},contacts:function(a,b,c){c("contacts_nosupport")},acc:function(a,b,c){c("acc_nosupport")},geo:function(a,b,c){c("geo_nosupport")},cam:function(a,b,c){c("cam_nosupport")},device:function(a,b,c){c("device_nosupport")},listen:function(a,b,c){c("listen_nosupport")},handlers:function(a,b,c){c("handlers_no_support")},file:function(a,b,c){c("file_nosupport")},push:function(a,b,c){c("push_nosupport")},env:function(a,b){b({height:window.innerHeight,width:window.innerWidth})},data:function(a,b,c){if($fh._persist||($fh._persist=new Persist.Store("FH"+$fh.app_props.appid,{swf_path:"/static/c/start/swf/persist.swf"})),!a.key)return void c("data_nokey");var d={load:function(){$fh._persist.get(a.key,function(c,d){b(c?{key:a.key,val:d}:{key:a.key,val:null})})},save:function(){if(!a.val)return void c("data_noval");try{$fh._persist.set(a.key,a.val)}catch(d){return void c("data_error",{},a)}b()},remove:function(){$fh._persist.remove(a.key,function(c,d){b(c?{key:a.key,val:d}:{key:a.key,val:null})})}};d[a.act]?d[a.act]():c("data_badact",a)},log:function(a,b,c){"undefined"==typeof console?c("log_nosupport"):console.log(a.message)},ori:function(a,b,c){if("undefined"==typeof a.act||"listen"==a.act)eventSupported("onorientationchange")?window.addEventListener("orientationchange",b,!1):c("ori_nosupport",{},a);else if("set"==a.act){if(!a.value)return void c("ori_no_value",{},a);"portrait"==a.value?(document.getElementsByTagName("body")[0].style["-moz-transform"]="",document.getElementsByTagName("body")[0].style["-webkit-transform"]="",b({orientation:"portrait"})):(document.getElementsByTagName("body")[0].style["-moz-transform"]="rotate(90deg)",document.getElementsByTagName("body")[0].style["-webkit-transform"]="rotate(90deg)",b({orientation:"landscape"}))}else c("ori_badact",{},a)},map:function(a,b,c){if(!a.target)return void c("map_notarget",{},a);if(!a.lat)return void c("map_nolatitude",{},a);if(!a.lon)return void c("map_nologitude",{},a);var d=a.target;if("string"==typeof d){var e=null;if("undefined"!=typeof jQuery)try{var f=jQuery(d);f.length>0&&(e=f[0])}catch(g){e=null}null==e&&(e=document.getElementById(d)),d=e}else"object"==typeof d?1===d.nodeType&&"string"==typeof d.nodeName||(d=d[0]):d=null;if(!d)return void c("map_nocontainer",{},a);if(_mapScriptLoaded){var h={};h.zoom=a.zoom?a.zoom:8,h.center=new google.maps.LatLng(a.lat,a.lon),h.mapTypeId=google.maps.MapTypeId.ROADMAP;var i=new google.maps.Map(d,h);b({map:i})}else"function"==typeof b&&_mapLoadSuccessParameters.push({target:d,successFunction:b,mOptions:a}),$fh._mapLoaded=function(){_mapScriptLoaded=!0;for(var a=_mapLoadSuccessParameters.shift();"undefined"!=typeof a;){var b=a.mOptions,c={};c.zoom=b.zoom?b.zoom:8,c.center=new google.maps.LatLng(b.lat,b.lon),c.mapTypeId=google.maps.MapTypeId.ROADMAP;var d=new google.maps.Map(a.target,c);a.successFunction({map:d}),a=_mapLoadSuccessParameters.shift()}},_mapScriptLoading||(_mapScriptLoading=!0,_loadMapScript()),setTimeout(function(){_mapScriptLoaded||c("map_timeout",{},a)},2e4)},audio:function(a,b,c){if(null==!audio_obj&&"play"==a.act&&(!a.path||""==a.path))return void c("no_audio_path");var d={play:function(){if(null==audio_obj){if(audio_obj=document.createElement("audio"),!(audio_obj.play?!0:!1))return void c("audio_not_support");if(a.type){var e=audio_obj.canPlayType(a.type);if("no"==e||""==e)return void c("audio_type_not_supported")}audio_obj.src=a.path,a.controls&&(audio_obj.controls="controls"),a.autoplay&&(audio_obj.autoplay="autoplay"),a.loop&&(audio_obj.loop="loop"),document.body.appendChild(audio_obj),audio_obj.play(),audio_is_playing=!0,b()}else a.path&&a.path!=audio_obj.src?(audio_is_playing&&d.stop(!0),d.play()):audio_is_playing||(audio_obj.play(),audio_is_playing=!0,b())},pause:function(){null!=audio_obj&&audio_is_playing?("function"==typeof audio_obj.pause?audio_obj.pause():"function"==typeof audio_obj.stop&&audio_obj.stop(),audio_is_playing=!1,b()):c("no_audio_playing")},stop:function(a){null!=audio_obj?("function"==typeof audio_obj.stop?audio_obj.stop():"function"==typeof audio_obj.pause&&audio_obj.pause(),document.body.removeChild(audio_obj),audio_obj=null,audio_is_playing=!1,a||b()):c("no_audio")}};d[a.act]?d[a.act]():c("data_badact",a)},webview:function(a,b,c){c("webview_nosupport")},ready:function(a,b){__bind_ready(),__is_ready?b.apply(document,[]):__ready_list.push(b)}},$fh.send=function(){handleargs(arguments,{type:"email"},$fh.__dest__.send)},$fh.notify=function(){handleargs(arguments,{type:"vibrate"},$fh.__dest__.notify)},$fh.contacts=function(){handleargs(arguments,{act:"list"},$fh.__dest__.contacts)},$fh.acc=function(){handleargs(arguments,{act:"register",interval:0},$fh.__dest__.acc)},$fh.geo=function(){handleargs(arguments,{act:"register",interval:0},$fh.__dest__.geo)},$fh.cam=function(){handleargs(arguments,{act:"picture"},$fh.__dest__.cam)},$fh.data=function(){handleargs(arguments,{act:"load"},$fh.__dest__.data)},$fh.log=function(){handleargs(arguments,{message:"none"},$fh.__dest__.log)},$fh.device=function(){handleargs(arguments,{},$fh.__dest__.device)},$fh.listen=function(){handleargs(arguments,{act:"add"},$fh.__dest__.listen)},$fh.ori=function(){handleargs(arguments,{},$fh.__dest__.ori)},$fh.map=function(){handleargs(arguments,{},$fh.__dest__.map)},$fh.audio=function(){handleargs(arguments,{},$fh.__dest__.audio)},$fh.webview=function(){handleargs(arguments,{},$fh.__dest__.webview)},$fh.ready=function(){handleargs(arguments,{},$fh.__dest__.ready)},$fh.handlers=function(){handleargs(arguments,{type:"back"},$fh.__dest__.handlers)},$fh.file=function(){handleargs(arguments,{act:"upload"},$fh.__dest__.file)},$fh.push=function(){handleargs(arguments,{},$fh.__dest__.push)},$fh.env=function(){handleargs(arguments,{},function(a,b){$fh.__dest__.env({},function(a){a.application=$fh.app_props.appid,$fh._getDeviceId&&(a.uuid=$fh._getDeviceId()),a.agent=navigator.userAgent||"unknown",b(a)})})},$fh.device=function(){handleargs(arguments,{},function(){})},$fh.geoip=function(){handleargs(arguments,{act:"get"},function(a,b,c){if("get"==a.act){var d={instance:$fh.app_props.appid,domain:$fh.cloud_props.domain};$fh.__ajax({url:_getHostPrefix()+"act/wid/geoip/resolve",type:"POST",data:JSON.stringify(d),success:function(a){for(var c in a.geoip)a[c]=a.geoip[c];b(a)}})}else c("geoip_badact",a)})},$fh.web=function(){handleargs(arguments,{method:"GET"},function(a,b,c){a.url||c("bad_url"),$fh.__ajax(a.is_local?{url:a.url,type:"GET",dataType:"html",success:function(a){var c={};c.status=200,c.body=a,b(c)},error:function(){c()}}:{url:_getHostPrefix()+"act/wid/web",type:"POST",data:JSON.stringify(a),success:function(a){b(a)}})})},$fh.__webview_win=void 0,$fh.__dest__.webview=function(a,b,c){if("act"in a&&"open"!==a.act)"close"===a.act&&("undefined"!=typeof $fh.__webview_win&&($fh.__webview_win.close(),$fh.__webview_win=void 0),b("closed"));else{if(!a.url)return void c("no_url");{a.url}$fh.__webview_win=window.open(a.url,"_blank"),b("opened")}},("undefined"!=typeof window.PhoneGap||"undefined"!=typeof window.cordova)&&($fh._readyCallbacks=[],$fh._readyState=!1,$fh.__dest__.ready=function(a,b){if($fh._readyState)try{b()}catch(c){console.log("Error during $fh.ready. Skip. Error = "+c.message)}else $fh._readyCallbacks.push(b)}),$fh.__dest__.geo=function(a,b,c){if("undefined"!=typeof navigator.geolocation)if(a.act&&"register"!=a.act)"unregister"==a.act?($fh.__dest__._geoWatcher&&(navigator.geolocation.clearWatch($fh.__dest__._geoWatcher),$fh.__dest__._geoWatcher=void 0),b()):c("geo_badact",{},a);else{if($fh.__dest__._geoWatcher)return void c("geo_inuse",{},a);if(0==a.interval&&navigator.geolocation.getCurrentPosition(function(a){var c=a.coords,d={lon:c.longitude,lat:c.latitude,alt:c.altitude,acc:c.accuracy,head:c.heading,speed:c.speed,when:a.timestamp};b(d)},function(){c("error_geo",{},a)}),a.interval>0){var d=navigator.geolocation.watchPosition(function(a){var c=a.coords,d={lon:c.longitude,lat:c.latitude,alt:c.altitude,acc:c.accuracy,head:c.heading,speed:c.speed,when:a.timestamp};b(d)},function(){c("error_geo",{},a)},{frequency:a.interval});$fh.__dest__._geoWatcher=d}}else c("geo_nosupport",{},a)},$fh.__dest__.acc=function(a,b){b({x:4*Math.random()-2,y:4*Math.random()-2,z:4*Math.random()-2,when:(new Date).getTime()})},root.$fh=$fh}(this),function(){function a(a){function b(){return e}var c={},d={exports:{}};!function(){function a(a){var c=!1;return function(){if(c)throw new Error("Callback was already called.");c=!0,a.apply(b,arguments)}}var b,e,f={};b=this,null!=b&&(e=b.async),f.noConflict=function(){return b.async=e,f};var g=function(a,b){if(a.forEach)return a.forEach(b);for(var c=0;c=b.length&&d(null))}))})},f.forEach=f.each,f.eachSeries=function(a,b,c){if(c=c||function(){},!a.length)return c();var d=0,e=function(){b(a[d],function(b){b?(c(b),c=function(){}):(d+=1,d>=a.length?c(null):e())})};e()},f.forEachSeries=f.eachSeries,f.eachLimit=function(a,b,c,d){var e=k(b);e.apply(null,[a,c,d])},f.forEachLimit=f.eachLimit;var k=function(a){return function(b,c,d){if(d=d||function(){},!b.length||0>=a)return d();var e=0,f=0,g=0;!function h(){if(e>=b.length)return d();for(;a>g&&f=b.length?d():h())})}()}},l=function(a){return function(){var b=Array.prototype.slice.call(arguments);return a.apply(null,[f.each].concat(b))}},m=function(a,b){return function(){var c=Array.prototype.slice.call(arguments);return b.apply(null,[k(a)].concat(c))}},n=function(a){return function(){var b=Array.prototype.slice.call(arguments);return a.apply(null,[f.eachSeries].concat(b))}},o=function(a,b,c,d){var e=[];b=h(b,function(a,b){return{index:b,value:a}}),a(b,function(a,b){c(a.value,function(c,d){e[a.index]=d,b(c)})},function(a){d(a,e)})};f.map=l(o),f.mapSeries=n(o),f.mapLimit=function(a,b,c,d){return p(b)(a,c,d)};var p=function(a){return m(a,o)};f.reduce=function(a,b,c,d){f.eachSeries(a,function(a,d){c(b,a,function(a,c){b=c,d(a)})},function(a){d(a,b)})},f.inject=f.reduce,f.foldl=f.reduce,f.reduceRight=function(a,b,c,d){var e=h(a,function(a){return a}).reverse();f.reduce(e,b,c,d)},f.foldr=f.reduceRight;var q=function(a,b,c,d){var e=[];b=h(b,function(a,b){return{index:b,value:a}}),a(b,function(a,b){c(a.value,function(c){c&&e.push(a),b()})},function(){d(h(e.sort(function(a,b){return a.index-b.index}),function(a){return a.value}))})};f.filter=l(q),f.filterSeries=n(q),f.select=f.filter,f.selectSeries=f.filterSeries;var r=function(a,b,c,d){var e=[];b=h(b,function(a,b){return{index:b,value:a}}),a(b,function(a,b){c(a.value,function(c){c||e.push(a),b()})},function(){d(h(e.sort(function(a,b){return a.index-b.index}),function(a){return a.value}))})};f.reject=l(r),f.rejectSeries=n(r);var s=function(a,b,c,d){a(b,function(a,b){c(a,function(c){c?(d(a),d=function(){}):b()})},function(){d()})};f.detect=l(s),f.detectSeries=n(s),f.some=function(a,b,c){f.each(a,function(a,d){b(a,function(a){a&&(c(!0),c=function(){}),d()})},function(){c(!1)})},f.any=f.some,f.every=function(a,b,c){f.each(a,function(a,d){b(a,function(a){a||(c(!1),c=function(){}),d()})},function(){c(!0)})},f.all=f.every,f.sortBy=function(a,b,c){f.map(a,function(a,c){b(a,function(b,d){b?c(b):c(null,{value:a,criteria:d})})},function(a,b){if(a)return c(a);var d=function(a,b){var c=a.criteria,d=b.criteria;return d>c?-1:c>d?1:0};c(null,h(b.sort(d),function(a){return a.value}))})},f.auto=function(a,b){b=b||function(){};var c=j(a);if(!c.length)return b(null);var d={},e=[],h=function(a){e.unshift(a)},k=function(a){for(var b=0;bb;b++)a[b].apply(null,arguments)}])))};return e.memo=c,e.unmemoized=a,e},f.unmemoize=function(a){return function(){return(a.unmemoized||a).apply(null,arguments)}},f.times=function(a,b,c){for(var d=[],e=0;a>e;e++)d.push(e);return f.map(d,b,c)},f.timesSeries=function(a,b,c){for(var d=[],e=0;a>e;e++)d.push(e);return f.mapSeries(d,b,c)},f.compose=function(){var a=Array.prototype.reverse.call(arguments);return function(){var b=this,c=Array.prototype.slice.call(arguments),d=c.pop();f.reduce(a,c,function(a,c,d){c.apply(b,a.concat([function(){var a=arguments[0],b=Array.prototype.slice.call(arguments,1);d(a,b)}]))},function(a,c){d.apply(b,[a].concat(c))})}};var w=function(a,b){var c=function(){var c=this,d=Array.prototype.slice.call(arguments),e=d.pop();return a(b,function(a,b){a.apply(c,d.concat([b]))},e)};if(arguments.length>2){var d=Array.prototype.slice.call(arguments,2);return c.apply(this,d)}return c};f.applyEach=l(w),f.applyEachSeries=n(w),f.forever=function(a,b){function c(d){if(d){if(b)return b(d);throw d}a(c)}c()},"undefined"!=typeof c&&c.amd?c([],function(){return f}):"undefined"!=typeof d&&d.exports?d.exports=f:b.async=f}();var e=d.exports;return function(){function a(a,b,c){var d=parseInt(a,10);return!isNaN(d)&&d>=b&&c>=d}function c(b){var c=0;if("string"==typeof b){var d=b.split(":");valid=2===d.length||3===d.length,valid&&(valid=a(d[0],0,23),c+=60*parseInt(d[0],10)*60),valid&&(valid=a(d[1],0,59),c+=60*parseInt(d[1],10)),valid&&3===d.length&&(valid=a(d[2],0,59),c+=parseInt(d[2],10))}return c}function e(a,b,d,e){function f(a,b,c){var d=parseInt(b,10),e=parseInt(c,10);return isNaN(d)||isNaN(e)?!1:"is equal to"===a?d===e:"is less than"===a?e>d:"is greater than"===a?d>e:!1}var l=a.type,m=a.fieldOptions?a.fieldOptions:{},n=!0;if("is equal to"===e)n=f("is equal to",b,d);else if("is greater than"===e)n=f("is greater than",b,d);else if("is less than"===e)n=f("is less than",b,d);else if("is at"===e){if(n=!1,l===h)switch(m.definition.datetimeUnit){case i:try{n=new Date(new Date(b).toDateString()).getTime()==new Date(new Date(d).toDateString()).getTime()}catch(o){n=!1}break;case j:n=c(b)===c(d);break;case k:try{n=new Date(b).getTime()==new Date(d).getTime()}catch(o){n=!1}break;default:n=!1}}else if("is before"===e){if(n=!1,l===h)switch(m.definition.datetimeUnit){case i:try{n=new Date(new Date(b).toDateString()).getTime()new Date(new Date(d).toDateString()).getTime()}catch(o){n=!1}break;case j:n=c(b)>c(d);break;case k:try{n=new Date(b).getTime()>new Date(d).getTime()}catch(o){n=!1}break;default:n=!1}}else n="is"===e?l===g?b&&b.selections&&-1!==b.selections.indexOf(d):b===d:"is not"===e?l===g?b&&b.selections&&-1===b.selections.indexOf(d):b!==d:"contains"===e?-1!==b.indexOf(d):"does not contain"===e?-1===b.indexOf(d):"begins with"===e?b.substring(0,d.length)===d:"ends with"===e?b.substring(Math.max(0,b.length-d.length),b.length)===d:!1;return n}var f=b("async"),g="checkboxes",h="dateTime",i="date",j="time",k="datetime",l=function(b){function c(a){f.each(Y.pages,function(a,b){f.each(a.fields,function(b,c){return b.pageId=a._id,b.fieldOptions=b.fieldOptions?b.fieldOptions:{},b.fieldOptions.definition=b.fieldOptions.definition?b.fieldOptions.definition:{},b.fieldOptions.validation=b.fieldOptions.validation?b.fieldOptions.validation:{},Z[b._id]=b,b.required&&($[b._id]={field:b,submitted:!1,validated:!1}),c()},function(){return b()})},a)}function d(a){f.each(Y.fieldRules,function(a,b){f.each(a.ruleConditionalStatements,function(b,c){var d=b.sourceField;return ab[d]=ab[d]||[],ab[d].push(a),c()},function(){return bb[a.targetField]=bb[a.targetField]||[],bb[a.targetField].push(a),b()})},a)}function g(a){f.each(Y.pageRules,function(a,b){a._id;f.each(a.ruleConditionalStatements,function(b,c){var d=b.sourceField;return cb[d]=cb[d]||[],cb[d].push(a),c()},function(){return db[a.targetPage]=db[a.targetPage]||[],db[a.targetPage].push(a),b()})},a)}function h(a){_=JSON.parse(JSON.stringify($)),eb={},f.each(X.formFields,function(a,b){return a.fieldId?(eb[a.fieldId]=a,b()):b(new Error("No fieldId in this submission entry: "+util.inspect(a)))},a)}function l(a){return W?a():void f.parallel([c,d,g],function(b){return b?a(b):(W=!0,a())})}function m(a,b){l(function(c){return c?b(c):(X=a,void h(b))})}function n(a,b,c){return b&&b.formFields?void f.filter(b.formFields,function(b,c){return c(b.fieldId.toString()==a.fieldId.toString())},function(a){var b=null;return a&&a[0]&&a[0].fieldValues&&(b=a[0].fieldValues),c(void 0,b)}):c()}function o(a,b,c){"function"==typeof b&&(c=b,b=null),l(function(d){return d?c(d):void m(a,function(a){return a?c(a):void f.waterfall([function(a){return a(void 0,{validation:{valid:!0}})},function(a,c){p(a,b,c)},q],function(a,b){return a?c(a):c(void 0,b)})})})}function p(a,b,c){f.each(X.formFields,function(c,d){var e=c.fieldId,f=Z[e];n(c,b,function(b,g){return b?d(b):void u(c,f,g,function(b,c){return b?d(b):(c.valid||(a.validation.valid=!1,a.validation[e]=c),d())})})},function(b){return b?c(b):c(void 0,a)})}function q(a,b){f.each(Object.keys(_),function(b,c){var d={};return _[b].submitted?c():void U(b,!0,function(e,f){return e?c(e):(f&&(d.fieldId=b,d.valid=!1,d.fieldErrorMessage=["Required Field Not Submitted"],a.validation[b]=d,a.validation.valid=!1),c()) +})},function(c){return c?b(c):b(void 0,a)})}function r(a,b,c){l(function(d){return d?c(d):void m(b,function(b){if(b)return c(b);var d=eb[a],e=Z[a];u(d,e,null,function(b,d){if(b)return c(b);var e={validation:{}};return e.validation[a]=d,c(void 0,e)})})})}function s(a,b,c,d){function e(b,c){var d={errorMessages:[]};return b&&d.errorMessages.push(b),t(a,d,function(b,d){if(b)return c(b);var e={validation:{}};return e.validation[a]=d,c(void 0,e)})}"function"==typeof c&&(d=c,c=0),l(function(f){if(f)return d(f);var g=Z[a],h=!1;h=g.repeating&&g.fieldOptions&&g.fieldOptions.definition&&g.fieldOptions.definition.minRepeat?c0;return d?c(void 0,null):c(void 0,"No value submitted for field "+b.name)}function g(a,b){var c=0;if(a&&a.fieldValues&&a.fieldValues.length>0)for(var d=0;db.fieldOptions.definition.maxRepeat)return c(void 0,"Expected max of "+b.fieldOptions.definition.maxRepeat+" values for field "+b.name+" but got "+a)}else if(a>1)return c(void 0,"Should not have multiple values for non-repeating field");return c(void 0,null)}function i(a,b,c,d){w(b.type,function(e,g){return e?d(e):void f.map(a.fieldValues,function(a,d){return y(a)?d(void 0,null):void g(a,b,c,function(a){var c;return c=a?a.message||"Error during validation of field":null,_[b._id]&&(_[b._id].submitted=!0),d(void 0,c)})},function(a,b){return a?d(a):d(void 0,b)})})}"function"==typeof c&&(d=c,c=null),g(a,function(g,j){return g?d(g):void f.series({valuesSubmitted:f.apply(e,a,b),repeats:f.apply(h,j,b),values:f.apply(i,a,b,c)},function(a,b){if(a)return d(a);var c=[];return b.valuesSubmitted&&c.push(b.valuesSubmitted),b.repeats&&c.push(b.repeats),d(void 0,{fieldErrorMessage:c,errorMessages:b.values})})})}function A(a){var b,c,d,e="^",f="c".charCodeAt(0),g="n".charCodeAt(0),h=a.length;for(b=0;h>b;b+=1){switch(c=a.charCodeAt(b)){case f:d="[a-zA-Z0-9]";break;case g:d="[0-9]";break;default:var i=c.toString(16).toUpperCase();d="\\u"+("0000"+i).substr(-4)}e+=d}return e+"$"}function B(a,b){var c=new RegExp(b);return c.test(a)}function C(a,b,c){var d;return d="simple"===b?A(c):"regex"===b?c:A(c),B(a,d)}function D(a,b,c,d){if("string"!=typeof a)return d(new Error("Expected string but got "+typeof a));var e={};b&&b.fieldOptions&&b.fieldOptions.validation&&(e=b.fieldOptions.validation);var f=e.field_format_mode||"";f=f.trim();var g=e.field_format_string||"";return g=g.trim(),g&&g.length>0&&f&&f.length>0&&!C(a,f,g)?d(new Error("field value in incorrect format, expected format: "+g+" but submission value is: "+a)):b.fieldOptions&&b.fieldOptions.validation&&b.fieldOptions.validation.min&&a.lengthb.fieldOptions.validation.max?d(new Error("Expected maximum string length of "+b.fieldOptions.validation.max+" but submission is "+a.length+". Submitted val: "+a)):d()}function E(a,b,c,d){var e=a-0,f=e==a;return f?F(e,b,c,d):d(new Error("Expected numeric but got: "+a))}function F(a,b,c,d){return"number"!=typeof a?d(new Error("Expected number but got "+typeof a)):b.fieldOptions&&b.fieldOptions.validation&&b.fieldOptions.validation.min&&ab.fieldOptions.validation.max?d(new Error("Expected maximum Number "+b.fieldOptions.validation.max+" but submission is "+a+". Submitted number: "+a)):d()}function G(a,b,c,d){return"string"!=typeof a?d(new Error("Expected string but got "+typeof a)):null===a.match(/[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+\.[a-zA-Z]{2,4}/g)?d(new Error("Invalid email address format: "+a)):d()}function H(a,b,c,d){return"string"!=typeof a?d(new Error("Expected submission to be string but got "+typeof a)):b.fieldOptions.definition.options?void f.some(b.fieldOptions.definition.options,function(b,c){return c(b.label===a)},function(b){return b?d():d(new Error("Invalid option specified: "+a))}):d(new Error("No options exist for field "+b.name))}function I(a,b,c,d){var e;b&&b.fieldOptions&&b.fieldOptions.validation&&(e=b.fieldOptions.validation.min);var g;if(b&&b.fieldOptions&&b.fieldOptions.validation&&(g=b.fieldOptions.validation.max),e&&(null===a.selections||void 0===a.selections||a.selections.lengthg)return d(new Error("Expected a maximum number of selections "+g+" but got "+a.selections.length));var i=[];f.eachSeries(b.fieldOptions.definition.options,function(a,b){for(var c in a)i.push(a[c]);return b()},function(){f.eachSeries(a.selections,function(a,b){return"string"!=typeof a?b(new Error("Expected checkbox submission to be string but got "+typeof a)):-1===i.indexOf(a)?b(new Error("Checkbox Option "+a+" does not exist in the field.")):b()},d)})}function J(a,b,c,d){return a.lat&&a["long"]?isNaN(parseFloat(a.lat))||isNaN(parseFloat(a["long"]))?d(new Error("Invalid latitude and longitude values")):d():d(new Error("Invalid object for locationMap submission"))}function K(a,b,c,d){function e(a,b){if("string"!=typeof a.zone||0===a.zone.length)return b(new Error("Invalid zone definition for northings and eastings location. "+a.zone));var c=parseInt(a.eastings,10);if(isNaN(c))return b(new Error("Invalid eastings definition for northings and eastings location. "+a.eastings));var d=parseInt(a.northings,10);return isNaN(d)?b(new Error("Invalid northings definition for northings and eastings location. "+a.northings)):b()}return"latlong"===b.fieldOptions.definition.locationUnit?a.lat&&a["long"]?isNaN(parseFloat(a.lat))||isNaN(parseFloat(a["long"]))?d(new Error("Invalid latitude and longitude values")):d():d(new Error("Invalid object for latitude longitude submission")):a.zone&&a.eastings&&a.northings?e(a,d):d(new Error("Invalid object for northings easting submission. Zone, Eastings and Northings elemets are required"))}function L(a,b,c,d){P(a,b,c,function(e){return e?void N(a,b,c,function(e){return e?void O(a,b,c,function(a){return a?d(a):d()}):d()}):d()})}function M(a,b,c,d){a=a||{};var e=a.fieldOptions||{},f=e.definition||{},g=f.file_size||null;if(null!==g){var h=b[c],i=1;return h>1e3&&(i=h/1e3),console.log("Comparing File Size: ",g,h),h>1e3*g?d(new Error("File size is too large. File can be a maximum of "+g+"KB. Size of file selected: "+i+"KB")):d()}return d()}function N(a,b,c,d){if("object"!=typeof a)return d(new Error("Expected object but got "+typeof a));var e=[{keyName:"fileName",valueType:"string"},{keyName:"fileSize",valueType:"number"},{keyName:"fileType",valueType:"string"},{keyName:"fileUpdateTime",valueType:"number"},{keyName:"hashName",valueType:"string"}];f.each(e,function(b,c){var d=typeof a[b.keyName];return d!==b.valueType?c(new Error("Expected "+b.valueType+" but got "+d)):"fileName"===b.keyName&&a[b.keyName].length<=0?c(new Error("Expected value for "+b.keyName)):c()},function(e){return e?d(e):void M(b,a,"fileSize",function(b){return b?d(b):a.hashName.indexOf("filePlaceHolder")>-1?d():c&&c.hashName&&c.hashName.indexOf(a.hashName)>-1?d():d(new Error("Invalid file placeholder text"+a.hashName))})})}function O(a,b,c,d){if("function"!=typeof File)return d(new Error("Expected File object but got "+typeof a));var e=[{keyName:"name",valueType:"string"},{keyName:"size",valueType:"number"}];f.each(e,function(b,c){var d=typeof a[b.keyName];return d!==b.valueType?c(new Error("Expected "+b.valueType+" but got "+d)):"string"===d&&a[b.keyName].length<=0?c(new Error("Expected value for "+b.keyName)):"number"===d&&a[b.keyName]<=0?c(new Error("Expected > 0 value for "+b.keyName)):c()},function(c){return c?d(c):void M(b,a,"size",function(a){return a?d(a):d()})})}function P(a,b,c,d){return"string"!=typeof a?d(new Error("Expected base64 string but got "+typeof a)):a.length<=0?d(new Error("Expected base64 string but was empty")):d()}function Q(b,c,d,e){var f,g=!1,h=[];if("string"!=typeof b)return e(new Error("Expected string but got "+typeof b));switch(c.fieldOptions.definition.datetimeUnit){case i:h=b.split("/"),g=3===h.length,g&&(g=a(h[2],1,31)),g&&(g=a(h[1],1,12)),g&&(g=a(h[0],1e3,9999));try{f=g?new Date(h[3],h[1],h[0]):new Date(b),g="Invalid Date"!==f.toString()}catch(l){g=!1}return g?e():e(new Error("Invalid date value "+b+". Date format is YYYY/MM/DD"));case j:return h=b.split(":"),g=2===h.length||3===h.length,g&&(g=a(h[0],0,23)),g&&(g=a(h[1],0,59)),g&&3===h.length&&(g=a(h[2],0,59)),g?e():e(new Error("Invalid time value "+b+". Time format is HH:MM:SS"));case k:h=b.split(/[- :]/),g=6===h.length||5===h.length,g&&(g=a(h[2],1,31)),g&&(g=a(h[1],1,12)),g&&(g=a(h[0],1e3,9999)),g&&(g=a(h[3],0,23)),g&&(g=a(h[4],0,59)),g&&6===h.length?g=a(h[5],0,59):h[5]=0;try{f=g?new Date(h[0],h[1],h[2],h[3],h[4],h[5]):new Date(b),g="Invalid Date"!==f.toString()}catch(l){g=!1}return g?e():e(new Error("Invalid dateTime string "+b+". dateTime format is YYYY/MM/DD HH:MM:SS"));default:return e(new Error("Invalid dateTime fieldtype "+c.fieldOptions.definition.datetimeUnit))}}function R(a,b,c,d){return d(new Error("Should not submit section field: "+b.name))}function S(a,b){var c=!0;f.each(a,function(a,b){var d=[],g=[];f.each(a.ruleConditionalStatements,function(a,b){var c,f,h=Z[a.sourceField],i=!1,j=[];return eb[a.sourceField]&&eb[a.sourceField].fieldValues&&(j=eb[a.sourceField].fieldValues,c=a.restriction,f=a.sourceValue,i=e(h,j[0],f,c)),d.push({field:h,submissionValues:j,condition:c,testValue:f,passed:i}),i&&g.push(h),b()},function(e){function f(a,b,c){return"and"===a&&b.length==c.length||"or"===a&&b.length>0}return e&&b(e),c=f(a.ruleConditionalOperator,g,d)?"show"===a.type:"show"!==a.type,b()})},function(a){return a?b(a):b(void 0,c)})}function T(a,b){l(function(c){return c?b(c):ib(a)?S(db[a],b):b(void 0,!0)})}function U(a,b,c){l(function(d){if(d)return c(d);var e=Z[a];return a?void f.waterfall([function(a){return b?void T(e.pageId,a):a(void 0,!0)},function(b,c){return b?hb(a)?S(bb[a],c):c(void 0,!0):c(void 0,!1)}],c):c(new Error("Field does not exist in form"))})}function V(a,b){l(function(c){return c?b(c):void m(a,function(a){if(a)return b(a);var c={};f.parallel([function(a){c.fields={},f.eachSeries(Object.keys(bb),function(a,b){U(a,!1,function(d,e){return d?b(d):(c.fields[a]={targetId:a,action:e?"show":"hide"},b())})},a)},function(a){c.pages={},f.eachSeries(Object.keys(db),function(a,b){T(a,function(d,e){return d?b(d):(c.pages[a]={targetId:a,action:e?"show":"hide"},b())})},a)}],function(a){return a?b(a):b(void 0,{actions:c})})})})}var W,X,Y=b,Z={},$={},_={},ab={},bb={},cb={},db={},eb={},fb={text:D,textarea:D,number:E,emailAddress:G,dropdown:H,radio:H,checkboxes:I,location:K,locationMap:J,photo:N,signature:N,file:N,dateTime:Q,url:D,sectionBreak:R},gb={text:D,textarea:D,number:E,emailAddress:G,dropdown:H,radio:H,checkboxes:I,location:K,locationMap:J,photo:L,signature:L,file:L,dateTime:Q,url:D,sectionBreak:R},hb=function(a){return!!bb[a]},ib=function(a){return!!db[a]};return{validateForm:o,validateField:r,validateFieldValue:s,checkRules:V,validateFieldInternal:z,initSubmission:m,isFieldVisible:U,isConditionActive:e}};"undefined"!=typeof d&&d.exports&&(d.exports=l)}(),d.exports(a)}var b=function(a){function c(a,c){var d={updateForms:!0};if("undefined"==typeof c)c=a;else for(var e in a)d[e]=a[e];var f=d.config||{};b.config=b.models.config,b.config.init(f,function(a){a&&$fh.forms.log.e("Form config loading error: ",a),b.models.log.loadLocal(function(a){a&&console.error("Error loading config from local storage"),b.models.uploadManager.loadLocal(function(a){$fh.forms.log.d("Upload Manager loaded from memory."),a&&$fh.forms.log.e("Error loading upload manager from memory ",a),b.models.uploadManager.start(),$fh.forms.log.l("Refreshing Theme."),b.models.theme.refresh(!0,function(a){a&&$fh.forms.log.e("Error refreshing theme ",a),d.updateForms===!0?($fh.forms.log.l("Refreshing Forms."),b.models.forms.refresh(!0,function(a){a&&$fh.forms.log.e("Error refreshing forms: ",a),c()})):c()})})})})}return a.init=c,a}(b||{});b.utils=function(a){function b(){var a=-1===document.URL.indexOf("http://")&&-1===document.URL.indexOf("https://");return a?!0:!1}function c(a,b){if(b.constructor&&b.constructor===Function)for(var c in b.prototype)a.prototype[c]=b.prototype[c];else for(var d in b)a.prototype[d]=b[d]}function d(a){var b=new Date;return a?b.getTimezoneOffset():b}function e(a){var b=a.getProps(),c=b._id,e=b._type,f=d().getTime();return c&&e?c+"_"+e+"_"+f:c?c+"_"+f:e?e+"_"+f:f}function f(a,b){"undefined"!=typeof $fh&&$fh.hash?$fh.hash({algorithm:"MD5",text:a},function(a){a&&a.hashvalue?b(null,a.hashvalue):b("Crypto failed.")}):b("Crypto not found")}function g(a,b){$fh.forms.log.d("Sending mail: ",a),$fh.send(a,function(){b(null)},function(a){b(a)})}return a.extend=c,a.localId=e,a.md5=f,a.getTime=d,a.send=g,a.isPhoneGap=b,a}(b.utils||{}),b.utils=function(a){function c(){return o(),p}function d(a,b){if(!a instanceof File)throw"Only file object can be used for converting";var c=new FileReader;c.onloadend=function(a){var c=a.target.result;return b(null,c)},c.readAsDataURL(a)}function e(a){var c;if(b.utils.isPhoneGap())c=a;else{var d="text/plain";try{c=new Blob([a],{type:d})}catch(e){var f=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if("TypeError"===e.name&&f){var g=new f;g.append([a.buffer]),c=g.getBlob(d)}else c=a}}return c}function f(a,b,c){var d=null,f=0;if("object"==typeof b)if(b instanceof File)d=b,f=d.size;else if(b instanceof Blob)d=b,f=d.size;else{var g=JSON.stringify(b);d=e(g),f=d.size||d.length}else"string"==typeof b&&(d=e(b),f=d.size||d.length);m(a,f,{create:!0},function(a,b){a?c(a):b.createWriter(function(a){function b(a){return c(null,a)}function e(){a.onwriteend=b,a.write(d)}a.onwriteend=e,a.truncate(0)},function(a){console.error("fileEntry.createWriter Failed to create file write: "+a),c("Failed to create file write:"+a)})})}function g(a,b){m(a,0,{},function(a,c){return a?"NotFoundError"!==a.name&&1!==a.code?b(a):b(null,null):void c.remove(function(){b(null,null)},function(a){console.error("file remove fileEntry.remove failed "+a),b("Failed to remove file"+a)})})}function h(a,b){l(a,function(a,c){if(a)b(a);else{var d=new FileReader;d.onloadend=function(a){var c=a.target.result;try{c=decodeURIComponent(c)}catch(d){}return b(null,c)},d.readAsText(c)}})}function i(a,b){l(a,function(a,c){if(a)return b(a);var d=new FileReader;d.onloadend=function(a){var c=a.target.result;return b(null,c)},d.readAsDataURL(c)})}function j(a,b){l(a,function(a,c){if(a)return b(a);var d=c.type,e=new FileReader;e.onloadend=function(a){var c=a.target.result,e=new Blob([c],{type:d});b(null,e)},e.readAsArrayBuffer(c)})}function k(a,b){l(a,b)}function l(a,b){m(a,0,{},function(a,c){return a?b(a):void c.file(function(a){b(null,a)},function(a){console.error("Failed to get file:"+a),b(a)})})}function m(a,b,c,d){o(),q(r,b,function(e){e.root.getFile(a,c,function(a){d(null,a)},function(e){if("QuotaExceededError"===e.name||10===e.code){var f=1073741824;n(f,function(){m(a,b,c,d)})}else d(e)})},function(){console.error("Failed to requestFileSystem: "+a),d("Failed to requestFileSystem")})}function n(a,b){navigator.webkitPersistentStorage?navigator.webkitPersistentStorage.requestQuota(a,function(a){b(null,a)},function(a){b(a,0)}):b(null,a)}function o(){window.requestFileSystem?(q=window.requestFileSystem,p=!0):window.webkitRequestFileSystem?(q=window.webkitRequestFileSystem,p=!0):p=!1,window.LocalFileSystem?r=window.LocalFileSystem.PERSISTENT:window.PERSISTENT&&(r=window.PERSISTENT)}a.fileSystem={isFileSystemAvailable:c,save:f,remove:g,readAsText:h,readAsBlob:j,readAsBase64Encoded:i,readAsFile:k,fileToBase64:d};var p=!1,q=function(){console.error("No file system available")},r=1;return o(),a}(b.utils||{}),b.utils=function(a){function b(){return i(),m}function c(){return i(),l}function d(a,b){i(),h(a,b)}function e(){q&&(q.stop(),q=null)}function f(a,b){a=a||{},$fh.forms.log.d("Taking photo ",a,l);var c=a.targetWidth?a.targetWidth:$fh.forms.config.get("targetWidth",640),d=a.targetHeight?a.targetHeight:$fh.forms.config.get("targetHeight",480),e=a.quality?a.quality:$fh.forms.config.get("quality",50);a.targetWidth=c,a.targetHeight=d,a.quality=e,"undefined"==typeof a.sourceType&&"undefined"!=typeof Camera&&(a.sourceType=Camera.PictureSourceType.CAMERA),l?navigator.camera.getPicture(g(b),b,{quality:e,targetWidth:c,targetHeight:d,sourceType:a.sourceType,saveToPhotoAlbum:!1,destinationType:Camera.DestinationType.DATA_URL,encodingType:Camera.EncodingType.PNG}):m?k(a,b):b("Your device does not support camera.")}function g(a){return function(b){var c="data:image/png;base64,"+b;a(null,c)}}function h(a,b){$fh.forms.log.d("Taking photo _html5Camera",a,l);var c=a.targetWidth||$fh.forms.config.get("targetWidth"),d=a.targetHeight||$fh.forms.config.get("targetHeight");n.width=c,n.height=d,o.width=c,o.height=d,q?($fh.forms.log.e("Media device was not released by browser."),b("Media device occupied.")):navigator.getUserMedia({video:!0},function(a){n.src=window.URL.createObjectURL(a),q=a,b(null,n)},b)}function i(){$fh.forms.log.d("Checking env"),navigator.camera&&navigator.camera.getPicture?l=!0:j()?(m=!0,n=document.createElement("video"),n.autoplay="autoplay",o=document.createElement("canvas"),p=o.getContext("2d")):console.error("Cannot detect usable media API. Camera will not run properly on this device.")}function j(){return navigator.getUserMedia?!0:navigator.webkitGetUserMedia?(navigator.getUserMedia=navigator.webkitGetUserMedia,!0):navigator.mozGetUserMedia?(navigator.getUserMedia=navigator.mozGetUserMedia,!0):navigator.msGetUserMedia?(navigator.getUserMedia=navigator.msGetUserMedia,!0):!1}function k(a,b){if($fh.forms.log.d("Snapshot ",a),q){p.drawImage(n,0,0,a.targetWidth,a.targetHeight);var c=o.toDataURL("image/png");e(),b(null,c)}else $fh.forms.log.e("Media resource is not available"),b("Resource not available")}a.takePhoto=f,a.isPhoneGapCamAvailable=c,a.isHtml5CamAvailable=b,a.initHtml5Camera=d,a.cancelHtml5Camera=e;var l=!1,m=!1,n=null,o=null,p=null,q=null;return a}(b.utils||{}),b.web=function(a){return a.uploadFile=function(a,b,c){$fh.forms.log.d("Phonegap uploadFile ",a,b);var d=b.fullPath;if(!$fh.forms.config.isOnline())return $fh.forms.log.e("Phonegap uploadFile. Not Online.",a,b),c("No Internet Connection Available.");var e=function(b){$fh.forms.log.d("upload to url ",a," sucessful"),b.response=b.response||{},"string"==typeof b.response&&(b.response=JSON.parse(b.response)),c(null,b.response)},f=function(a){$fh.forms.log.e("An error uploading a file has occurred: Code = "+a.code),$fh.forms.log.d("upload error source "+a.source),$fh.forms.log.d("upload error target "+a.target),c(a)},g=new FileUploadOptions;g.fileName=b.name,g.mimeType=b.contentType?b.contentType:"application/octet-stream",g.httpMethod="https",g.chunkedMode=!0,g.fileKey="file",g.headers={Connection:"close"},$fh.forms.log.d("Beginning file upload ",a,g);var h=new FileTransfer;h.upload(d,encodeURI(a),e,f,g)},a.downloadFile=function(a,b,c){$fh.forms.log.d("Phonegap downloadFile ",a,b);var d=new FileTransfer;return $fh.forms.config.isOnline()?void appforms.utils.fileSystem.getBasePath(function(e,f){function g(a){return $fh.forms.log.d("File Download Completed Successfully. FilePath: "+a.fullPath),c(null,a.fullPath)}function h(a){return $fh.forms.log.e("Error downloading file "+b.fileName+" code: "+a.code),c("Error downloading file "+b.fileName+" code: "+a.code)}if(e)return $fh.forms.log.e("Error getting base path for file download: "+a),c(e);if(!b.fileName)return $fh.forms.log.e("No file name associated with the file to download"),c("No file name associated with the file to download");$fh.forms.log.d("File name for file "+b.fileName+" found. Starting download");var i=f+b.fileName;d.download(encodeURI(a),i,g,h,{headers:{Connection:"close"}})}):($fh.forms.log.e("Phonegap downloadFile. Not Online.",a,b),c("No Internet Connection Available."))},a}(b.web||{}),b.web.ajax=function(a){function b(){}function c(a,b){$fh.forms.log.d("Ajax get ",a),e({url:a,type:"GET",dataType:"json",success:function(c){$fh.forms.log.d("Ajax get",a,"Success"),b(null,c)},error:function(c,d,e){$fh.forms.log.e("Ajax get",a,"Fail",c,d,e),b(c)}})}function d(a,b,c){$fh.forms.log.d("Ajax post ",a,b);var d,f=!1;if("object"==typeof b)if(b instanceof File){f=!0,d=new FormData;var g=b.name;d.append(g,b),b=d}else b=JSON.stringify(b);var h={url:a,type:"POST",data:b,dataType:"json",success:function(b){$fh.forms.log.d("Ajax post ",a," Success"),c(null,b)},error:function(b,d,e){$fh.forms.log.e("Ajax post ",a," Fail ",b,d,e),c(b)}};f===!1&&(h.contentType="application/json"),e(h)}a="undefined"!=typeof $fh&&$fh.__ajax?$fh.__ajax:b,a.get=c,a.post=d;var e=a;return a}(b.web.ajax||{}),b.stores=function(a){function b(a){this.name=a}return a.Store=b,b.prototype.create=function(){throw"Create not implemented:"+this.name},b.prototype.read=function(){throw"Read not implemented:"+this.name},b.prototype.update=function(){throw"Update not implemented:"+this.name},b.prototype["delete"]=function(){throw"Delete not implemented:"+this.name},b.prototype.upsert=function(){throw"Upsert not implemented:"+this.name},a}(b.stores||{}),b.stores=function(a){function c(){b.stores.Store.call(this,"LocalStorage")}function d(){i()?f.apply({},arguments):e.apply({},arguments)}function e(a,b,c){return $fh&&$fh.data?void $fh.data(a,function(c){return"undefined"==typeof c&&(c={key:a.key,val:a.val}),"remove"===a.act.toLowerCase()?b(null,null):void b(null,c.val?c.val:null)},c):b()}function f(a,c,d){function e(a){return"undefined"!=typeof d?d(a,{}):void 0}function f(a,c){var d=b.config.get("appId","unknownAppId");a+=d,g.md5(a,function(b,d){b&&(d=a);var e=d+".txt";return"undefined"==typeof navigator.externalstorage?c(e):void navigator.externalstorage.enable(function(a){var b=e;return a.path&&(b=a.path,b.match(/\/$/)||(b+="/"),b+=e),e=b,c(e)},function(){return c(e)})})}function i(a,b){f(a,function(a){h.save(a,b,function(a){a?e(a):c(null,b)})})}function j(a){f(a,function(a){h.remove(a,function(a){a?"NotFoundError"===a.name||1===a.code?c(null,null):e(a):c(null,null)})})}function k(a){f(a,function(a){h.readAsText(a,function(a,b){a?"NotFoundError"===a.name||1===a.code?c(null,null):e(a):c(null,b)})})}return"undefined"==typeof a.act?k(a.key):"save"===a.act?i(a.key,a.val):"remove"===a.act?j(a.key):"load"===a.act?k(a.key):"undefined"!=typeof d?d("Action ["+a.act+"] is not defined",{}):void 0}var g=b.utils,h=g.fileSystem,i=function(){};return b.utils.extend(c,b.stores.Store),c.prototype.create=function(a,b){var c=g.localId(a);a.setLocalId(c),this.update(a,b)},c.prototype.read=function(a,b){if("offlineTest"===a.get("_type"))b(null,{});else{var c=a.getLocalId();null!=c?d({act:"load",key:c.toString()},b,b):b(null,null)}},c.prototype.update=function(a,b){var c=a.getLocalId(),e=a.getProps(),f=JSON.stringify(e);d({act:"save",key:c.toString(),val:f},b,b)},c.prototype["delete"]=function(a,b){var c=a.getLocalId();d({act:"remove",key:c.toString()},b,b)},c.prototype.upsert=function(a,b){var c=a.getLocalId();null===c?this.create(a,b):this.update(a,b)},c.prototype.switchFileSystem=function(a){i=function(){return a}},c.prototype.defaultStorage=function(){i=function(){return h.isFileSystemAvailable()}},i=function(){return h.isFileSystemAvailable()},a.localStorage=new c,a}(b.stores||{}),b.stores=function(a){function c(){e.call(this,"MBaaS")}function d(a){$fh.forms.log.d("_getUrl ",a);var c=a.get("_type"),d=b.config.get("cloudHost"),e=b.config.get("mbaasBaseUrl"),f=b.config.get("formUrls"),g="";f[c]?g=f[c]:$fh.forms.log.e("type not found to get url:"+c);var h=d+e+g,i={};switch(i.appId=b.config.get("appId"),c){case"config":i.appid=a.get("appId"),i.deviceId=a.get("deviceId");break;case"form":i.formId=a.get("_id");break;case"formSubmission":i.formId=a.getFormId();break;case"fileSubmission":i.submissionId=a.getSubmissionId(),i.hashName=a.getHashName(),i.fieldId=a.getFieldId();break;case"base64fileSubmission":i.submissionId=a.getSubmissionId(),i.hashName=a.getHashName(),i.fieldId=a.getFieldId();break;case"submissionStatus":i.submissionId=a.get("submissionId");break;case"completeSubmission":i.submissionId=a.get("submissionId");break;case"formSubmissionDownload":i.submissionId=a.getSubmissionId();break;case"fileSubmissionDownload":i.submissionId=a.getSubmissionId(),i.submissionId=a.getFileGroupId();break;case"offlineTest":return"http://127.0.0.1:8453"}for(var j in i)h=h.replace(":"+j,i[j]);return h}var e=b.stores.Store;return a.mBaaS=new c,b.utils.extend(c,e),c.prototype.checkStudio=function(){return b.config.get("studioMode")},c.prototype.create=function(a,c){var e=this;if(e.checkStudio())c("Studio mode not supported");else{var f=d(a);e.isFileAndPhoneGap(a)?b.web.uploadFile(f,a.getProps(),c):b.web.ajax.post(f,a.getProps(),c)}},c.prototype.isFileAndPhoneGap=function(a){var b=this;return b.isFileTransfer(a)&&b.isPhoneGap()},c.prototype.isFileTransfer=function(a){return"fileSubmission"===a.get("_type")||"base64fileSubmission"===a.get("_type")||"fileSubmissionDownload"===a.get("_type")},c.prototype.isPhoneGap=function(){return"undefined"!=typeof window.Phonegap||"undefined"!=typeof window.cordova},c.prototype.read=function(a,c){var e=this;if(this.checkStudio())c("Studio mode not supported");else if("offlineTest"===a.get("_type"))c("offlinetest. ignore");else{var f=d(a);if(e.isFileTransfer(a)&&e.isPhoneGap())b.web.downloadFile(f,a.getFileMetaData(),c);else{if(e.isFileTransfer(a))return c(null,a.getRemoteFileURL());b.web.ajax.get(f,c)}}},c.prototype.update=function(){},c.prototype["delete"]=function(){},c.prototype.completeSubmission=function(a,c){var e=d(a);b.web.ajax.post(e,{},c)},c.prototype.submissionStatus=function(a,c){var e=d(a);b.web.ajax.get(e,c)},a}(b.stores||{}),b.stores=function(a){function c(a,b){d.call(this,"DataAgent"),this.remoteStore=a,this.localStore=b}var d=b.stores.Store;return a.DataAgent=c,a.dataAgent=new c(b.stores.mBaaS,b.stores.localStorage),b.utils.extend(c,d),c.prototype.read=function(a,b){$fh.forms.log.d("DataAgent read ",a);var c=this;this.localStore.read(a,function(d,e){d||!e?($fh.forms.log.d("Error reading model from localStore ",a,d),c.refreshRead(a,b)):b(null,e,!1)})},c.prototype.refreshRead=function(a,b){$fh.forms.log.d("DataAgent refreshRead ",a);var c=this;this.remoteStore.read(a,function(d,e){d?($fh.forms.log.e("Error reading model from remoteStore ",a,d),b(d)):($fh.forms.log.d("Model refresh successfull from remoteStore ",a,e),a.fromJSON(e),c.localStore.upsert(a,function(){var a=Array.prototype.slice.call(arguments,0);a.push(!0),b.apply({},a)}))})},c.prototype.attemptRead=function(a,b){$fh.forms.log.d("DataAgent attemptRead ",a);var c=this;c.refreshRead(a,function(d){d?c.read(a,b):b.apply({},arguments)})},a}(b.stores||{}),b.models=function(a){function c(a){if(this.props={_id:null,_type:null,_ludid:null},this.utils=b.utils,this.events={},"undefined"!=typeof a)for(var c in a)this.props[c]=a[c];this.touch()}return c.prototype.on=function(a,b){this.events[a]||(this.events[a]=[]),this.events[a].indexOf(b)<0&&this.events[a].push(b)},c.prototype.off=function(a,b){this.events[a]&&this.events[a].indexOf(b)>=0&&this.events[a].splice(this.events[a].indexOf(b),1)},c.prototype.clearEvents=function(){this.events={}},c.prototype.emit=function(){var a=Array.prototype.slice.call(arguments,0),b=a.shift(),c=this.events[b];if(c&&c.length>0)for(var d=0;dc){$fh.forms.log.d("Submissions clearSentSubmission pruning sentSubmissions.length>maxSent"),d=d.sort(function(a,b){return a.submittedDatec;)e.push(d.pop());for(var f=e.length,g=0;g-1&&this.get("submissions").splice(c,1),this.saveLocal(b)},c.prototype.indexOf=function(a){$fh.forms.log.d("Submissions indexOf: ",a);for(var b=this.get("submissions"),c=0;c-1?!0:(this.set("status","error"),!1)},e.prototype.addComment=function(a,c){var d=b.utils.getTime(),e=d.getTime(),f={madeBy:"undefined"==typeof c?"":c.toString(),madeOn:d,value:a,timeStamp:e};return this.getComments().push(f),e},e.prototype.getComments=function(){return this.get("comments")},e.prototype.removeComment=function(a){for(var b=this.getComments(),c=0;c-1?c.tmpFields[d][f]=e:c.tmpFields[d].push(e),b(null,e))});else{var i=c.getInputValueObjectById(d);h.processInput(a,function(a,c){return a?b(a):(f>-1?i.fieldValues[f]=c:i.fieldValues.push(c),b(null,c))})}})},e.prototype.getInputValueByFieldId=function(a,b){var c=this.getInputValueObjectById(a).fieldValues;this.getForm(function(d,e){var f=e.getFieldModelById(a);f.convertSubmission(c,b)})},e.prototype.reset=function(){var a=this;a.clearLocalSubmissionFiles(function(){a.set("formFields",[])})},e.prototype.isDownloadSubmission=function(){return this.get("downloadSubmission")===!0},e.prototype.clearLocalSubmissionFiles=function(a){$fh.forms.log.d("In clearLocalSubmissionFiles");var c=this,d=this.getSubmissionFiles(),e="";e=c.isDownloadSubmission()?"fileName":"fileHash";for(var f in d)b.utils.fileSystem.remove(f[e],function(a){a&&$fh.forms.log.e("Error removing files from "+a)});a()},e.prototype.startInputTransaction=function(){this.transactionMode=!0,this.tmpFields={}},e.prototype.endInputTransaction=function(a){if(this.transactionMode=!1,a){var b=(this.get("formFields"),this.tmpFields);for(var c in b)for(var d=this.getInputValueObjectById(c),e=b[c],f=0;fb&&c.splice(b,1)},e.prototype.getInputValueObjectById=function(a){for(var b=this.get("formFields",[]),c=0;c-1&&d.splice(e,1),this.getTaskById(c,function(a,c){a?($fh.forms.log.e(a),b(a,c)):c?c.clearLocal(b):b(null,null)}),this.saveLocal(function(a){a&&$fh.forms.log.e(a)})}else b(null,null)},c.prototype.getTaskQueue=function(){return this.get("taskQueue",[])},c.prototype.start=function(){var a=this;this.stop(),this.timer=setInterval(function(){a.tick()},this.timerInterval)},c.prototype.stop=function(){this.timer&&(clearInterval(this.timer),this.timer=null)},c.prototype.push=function(a){this.get("taskQueue").push(a),this.saveLocal(function(a){a&&$fh.forms.log.e("Error saving local Upload manager",a)})},c.prototype.shift=function(){var a=this.get("taskQueue").shift();return this.saveLocal(function(a){a&&$fh.forms.log.e(a)}),a},c.prototype.rollTask=function(){this.push(this.shift())},c.prototype.tick=function(){if(this.sending){var a=b.utils.getTime(),c=a.getTime()-this.sendingStart.getTime();c>1e3*$fh.forms.config.get("timeout")&&($fh.forms.log.e("Uploading content timeout. it will try to reupload."),this.sending=!1,this.rollTask())}else if(this.hasTask()){this.sending=!0,this.sendingStart=b.utils.getTime();var d=this;this.getCurrentTask(function(a,b){a||!b?($fh.forms.log.e(a),d.sending=!1):b.isCompleted()||b.isError()?(d.shift(),d.sending=!1,d.saveLocal(function(a){a&&$fh.forms.log.e("Error saving upload manager: ",a)})):$fh.forms.config.isOnline()?b.uploadTick(function(a){a&&$fh.forms.log.e("Error on upload tick: ",a,b),d.sending=!1}):$fh.forms.log.d("Upload Manager: Tick: Not online.")})}else this.stop()},c.prototype.hasTask=function(){return this.get("taskQueue").length>0},c.prototype.getCurrentTask=function(a){var b=this.getTaskQueue()[0];b?this.getTaskById(b,a):a(null,null)},c.prototype.getTaskById=function(a,c){b.models.uploadTask.fromLocal(a,c)},a.uploadManager=new c,a}(b.models||{}),b.models=function(a){function c(a){d.call(this,{_type:"rule"}),this.fromJSON(a)}var d=b.models.Model;return b.utils.extend(c,d),c.prototype.getRelatedFieldId=function(){for(var a=this.getDefinition(),b=a.ruleConditionalStatements,c=[],d=0;df;f++)e+=b.fileSize;return c+e},e.prototype.getRemoteStore=function(){return b.stores.mBaaS},e.prototype.addFileTasks=function(a,b){var c=this;a.getFileInputValues(function(a,d){if(a)return $fh.forms.log.e("Error getting file Input values: "+a),b(a);for(var e=0;e0?e.resetUploadTask(f,function(){a()}):(e.increProgress(),a())}else d="Invalid submission status response.",a(d)})}function d(){a()}var e=this;e.isDownloadTask()?d():c()},e.prototype.resetUploadTask=function(a,b){var c,d=this.get("fileTasks"),e=[];for(c=0;c-1&&e.push(d[c]);var f=d.length-a.length-1,g=0;f>0&&(g=f),this.set("currentTask",g),this.set("fileTasks",e),this.saveLocal(b)},e.prototype.uploadFile=function(a){function c(){$fh.forms.log.d("processUploadFile for submissionId: "),g="base64"===h.contentType?new b.models.Base64FileSubmission(h):new b.models.FileSubmission(h),g.setSubmissionId(i),g.loadFile(function(c){return c?($fh.forms.log.e("Error loading file for upload: "+c),a(c)):void e.getRemoteStore().create(g,function(c,d){if(c)a(c);else if("ok"===d.status||200===d.status||"200"===d.status)h.updateDate=b.utils.getTime(),e.increProgress(),e.saveLocal(function(a){a&&$fh.forms.log.e("Error saving upload task"+a)}),e.emit("progress",e.getProgress()),a(null);else{var f="File upload failed for file: "+h.fileName;a(f)}})})}function d(){$fh.forms.log.d("processDownloadFile called"),g=new b.models.FileSubmissionDownload(h),e.getRemoteStore().read(g,function(b,c){return b?($fh.forms.log.e("Error downloading a file from remote: "+b),a(b)):($fh.forms.log.d("processDownloadFile called. Local File Path: "+c),void e.submissionModel(function(b,d){return b?($fh.forms.log.e("Error Loading submission model for processDownloadFile "+b),a(b)):void d.updateFileLocalURI(h,c,function(b){return b?($fh.forms.log.e("Error updating file local url for fileTask "+JSON.stringify(h)),a(b)):(e.increProgress(),e.saveLocal(function(a){a&&$fh.forms.log.e("Error saving download task")}),e.emit("progress",e.getProgress()),a())})}))})}var e=this,f=e.getCurrentTask();null===f&&(f=0,e.set("currentTask",f));var g,h=e.get("fileTasks",[])[f],i=e.get("submissionId");return h?i?void(e.isDownloadTask()?d():c()):($fh.forms.log.e("No submission id found when trying to transfer a file."),a("No submission Id found")):($fh.forms.log.e("No file task found when trying to transfer a file."),a("cannot find file task"))},e.prototype.isDownloadTask=function(){return"download"===this.get("submissionTransferType")},e.prototype.setRetryNeeded=function(a){null!=this.get("submissionId",null)?this.set("retryNeeded",a):(this.set("retryNeeded",!1),this.set("currentTask",null))},e.prototype.retryNeeded=function(){return this.get("retryNeeded")},e.prototype.uploadTick=function(a){function b(b){b?($fh.forms.log.d("Err, retrying transfer: "+c.getLocalId()),c.increRetryAttempts(),c.getRetryAttempts()<=$fh.forms.config.get("max_retries")?(c.setRetryNeeded(!0),c.saveLocal(function(b){b&&$fh.forms.log.e("Error saving upload taskL "+b),a()})):(c.setRetryNeeded(!0),c.resetRetryAttempts(),c.error(b,function(){a(b)}))):(c.setRetryNeeded(!1),c.saveLocal(function(a){a&&$fh.forms.log.e("Error saving upload task to local memory"+a)}),c.submissionModel(function(b,c){if(b)a(b);else{var d=c.get("status");"inprogress"!==d&&"submitted"!==d&&"downloaded"!==d?($fh.forms.log.e("Submission status is incorrect. Upload task should be started by submission object's upload method."+d),a("Submission status is incorrect. Upload task should be started by submission object's upload method.")):a()}}))}var c=this;this.isFormCompleted()?this.retryNeeded()?this.handleIncompleteSubmission(b):this.isFileCompleted()?this.isMBaaSCompleted()?this.isCompleted()?b(null,null):this.success(b):this.uploadComplete(b):this.uploadFile(b):this.uploadForm(b)},e.prototype.increProgress=function(){var a=this.getCurrentTask();null===a?a=0:a++,this.set("currentTask",a)},e.prototype.uploadComplete=function(a){function c(){$fh.forms.log.d("processDownloadComplete Called"),e.increProgress(),a(null)}function d(){$fh.forms.log.d("processUploadComplete Called");var c=e.getRemoteStore(),d=new b.models.FormSubmissionComplete(e);c.create(d,function(b,c){return c=c||{},"complete"!==c.status?e.handleCompletionError(b,c,a):(e.increProgress(),void a(null))})}$fh.forms.log.d("UploadComplete Called");var e=this,f=e.get("submissionId",null);return null===f?a("Failed to complete submission. Submission Id not found."):void(e.isDownloadTask()?c():d())},e.prototype.success=function(a){function b(){$fh.forms.log.d("processUploadSuccess Called"),d.submissionModel(function(b,c){return b?a(b):(c.set("submissionId",e),void c.submitted(a))})}function c(){$fh.forms.log.d("processDownloadSuccess Called"),d.submissionModel(function(b,c){return b?a(b):void c.downloaded(a)})}$fh.forms.log.d("Transfer Sucessful. Success Called.");var d=this,e=d.get("submissionId",null);d.set("completed",!0),d.saveLocal(function(a){a&&$fh.forms.log.e("Error Clearing Upload Task")}),d.isDownloadTask()?c():b()},e.prototype.error=function(a,b){this.set("error",a),this.saveLocal(function(a){a&&$fh.forms.log.e("Upload task save failed: "+a)}),this.submissionModel(function(c,d){c?b(c):(d.error(a,function(){}),b(a))})},e.prototype.isFormCompleted=function(){var a=this.getCurrentTask();return null===a?!1:!0},e.prototype.isFileCompleted=function(){var a=this.getCurrentTask();return null===a?!1:aa.get("fileTasks",[]).length?!0:!1}return!1},e.prototype.getProgress=function(){var a=this,b={formJSON:!1,currentFileIndex:0,totalFiles:a.get("fileTasks").length,totalSize:a.getTotalSize(),uploaded:a.getUploadedSize(),retryAttempts:a.getRetryAttempts(),submissionTransferType:a.get("submissionTransferType")},c=a.getCurrentTask();return null===c?b:(b.formJSON=!0,b.currentFileIndex=c,b)},e.prototype.refreshForm=function(a,c){var d=this.get("formId");new b.models.Form({formId:d,rawMode:!0,rawData:a},function(b){b&&$fh.forms.log.e(b),$fh.forms.log.l("successfully updated form the form with id "+a._id),c()})},e.prototype.submissionModel=function(a){b.models.submission.fromLocal(this.get("submissionLocalId"),function(b,c){b&&$fh.forms.log.e("Error getting submission model from local memory "+b),a(b,c)})},a}(b.models||{}),b.models=function(a){function c(){d.call(this,{_type:"theme",_ludid:"theme_object"})}var d=b.models.Model;return c.prototype.getCSS=function(){return this.get("css","")},b.utils.extend(c,d),a.theme=new c,a}(b.models||{}),b.models=function(a){function c(){d.call(this,{_type:"log",_ludid:"log"}),this.set("logs",[]),this.isWriting=!1,this.moreToWrite=!1}var d=b.models.Model;return b.utils.extend(c,d),c.prototype.info=function(a){if($fh.forms.config.get("logger")===!0){var b="",c=$fh.forms.config.get("log_level"),d=$fh.forms.config.get("log_levels"),e=this;if("string"==typeof a?(b=a,a=d.indexOf(a.toLowerCase())):a=0,c=isNaN(parseInt(c,10))?c:parseInt(c,10),a=isNaN(parseInt(a,10))?a:parseInt(a,10),a>c)return;var f=Array.prototype.splice.call(arguments,0),g=e.get("logs");f.shift();for(var h="";f.length>0;)h+=JSON.stringify(f.shift())+" ";if(g.push(e.wrap(h,b)),g.length>$fh.forms.config.get("log_line_limit")&&g.shift(),e.isWriting)e.moreToWrite=!0;else{var i=function(){e.moreToWrite&&(e.moreToWrite=!1,e.write(i))};e.write(i)}}},c.prototype.wrap=function(a,b){var c=new Date,d=c.toISOString();"object"==typeof a&&(a=JSON.stringify(a));var e=d+" "+b.toUpperCase()+" "+a;return e},c.prototype.getPolishedLogs=function(){for(var a=[],b=this.getLogs(),c=[{reg:/^.+\sERROR\s.*/,color:$fh.forms.config.get("color_error")||"#FF0000"},{reg:/^.+\sWARNING\s.*/,color:$fh.forms.config.get("color_warning")||"#FF9933"},{reg:/^.+\sLOG\s.*/,color:$fh.forms.config.get("color_log")||"#009900"},{reg:/^.+\sDEBUG\s.*/,color:$fh.forms.config.get("color_debug")||"#3366FF"},{reg:/^.+\sUNKNOWN\s.*/,color:$fh.forms.config.get("color_unknown")||"#000000"}],d=0;d"+e+"");break}}return a},c.prototype.write=function(a){var b=this;b.isWriting=!0,b.saveLocal(function(){b.isWriting=!1,a()})},c.prototype.e=function(){var a=Array.prototype.splice.call(arguments,0);a.unshift("error"),this.info.apply(this,a)},c.prototype.w=function(){var a=Array.prototype.splice.call(arguments,0);a.unshift("warning"),this.info.apply(this,a)},c.prototype.l=function(){var a=Array.prototype.splice.call(arguments,0);a.unshift("log"),this.info.apply(this,a)},c.prototype.d=function(){var a=Array.prototype.splice.call(arguments,0);a.unshift("debug"),this.info.apply(this,a)},c.prototype.getLogs=function(){return this.get("logs")},c.prototype.clearLogs=function(a){this.set("logs",[]),this.saveLocal(function(){a&&a()})},c.prototype.sendLogs=function(a){var c=$fh.forms.config.get("log_email"),d=b.config.getProps(),e=this.getLogs(),f={type:"email",to:c,subject:"App Forms App Logs",body:"Configuration:\n"+JSON.stringify(d)+"\n\nApp Logs:\n"+e.join("\n")};b.utils.send(f,a)},a.log=new c,b.log=a.log,a}(b.models||{}),b.api=function(a){function c(a,c){"function"==typeof a&&(c=a,a={}),a=a?a:{},c=c?c:k;var d=a.fromRemote;void 0===d&&(d=!1),b.models.forms.refresh(d,c)}function d(a,c){"function"==typeof a&&(c=a,a={}),a=a?a:{},c=c?c:k,new b.models.Form(a,c)}function e(a,c){"function"==typeof a&&(c=a,a={}),a=a?a:{},c=c?c:k;var d=b.models.theme;a.fromRemote||(a.fromRemote=!1),d.refresh(a.fromRemote,function(b,e){return b?c(b):null===e?c(new Error("No theme defined for this app")):a.css===!0?c(null,d.getCSS()):c(null,d)})}function f(a,c){"function"==typeof a&&(c=a,a={}),a=a?a:{},c=c?c:k;b.models.submissions;null===i?b.models.submissions.loadLocal(function(a){a?($fh.forms.log.e(a),c(a)):(i=b.models.submissions,c(null,i))}):c(null,i)}function g(a,b){return a?void a.submit(function(c){return c?b(c):void a.upload(b)}):b("Invalid submission object.")}function h(a,c){if(a=a?a:{},c=c?c:k,!a.submissionId)return $fh.forms.log.e("No submissionId passed to download a submission"),c("No submissionId passed to download a submission");var d=b.models.submissions.findMetaByRemoteId(a.submissionId);if(null===d){var e=new b.models.submission.newInstance(null,{submissionId:a.submissionId});e.on("error",function(b){return $fh.forms.log.e("Error downloading submission with id "+a.submissionId),e.clearEvents(),c(b)}),e.on("downloaded",function(){return $fh.forms.log.l("Download of submission with id "+a.submissionId+" completed successfully"),e.clearEvents(),c(null,e)}),e.download(function(a){return a?($fh.forms.log.e("Error queueing submission for download "+a),e.clearEvents(),c(a)):void 0})}else b.models.submissions.getSubmissionByMeta(d,c)}a.getForms=c,a.getForm=d,a.getTheme=e,a.submitForm=g,a.getSubmissions=f,a.downloadSubmission=h,a.init=b.init,a.log=b.models.log;var i=null,j=b.models.config,k=function(a){a=a?a:"",$fh.forms.log.w("Default Function Called "+a)},l={editAllowed:function(){var a=j.get("defaultConfigValues",{});return a.config_admin_user===!0},get:function(a){if(a){var b=j.get("userConfigValues",{}),c=j.get("defaultConfigValues",{});return b[a]?b[a]:c[a]}},getDeviceId:function(){return j.get("deviceId","Not Set")},set:function(a,b){var c=this;if(a&&b&&(c.editAllowed()||"max_sent_saved"===a)){var d=j.get("userConfigValues",{});d[a]=b,j.set("userConfigValues",d)}},getConfig:function(){var a=this,b=j.get("defaultConfigValues",{}),c=j.get("userConfigValues",{}),d={};if(a.editAllowed()){for(var e in b)d[e]=c[e]?c[e]:b[e];return d}return b},saveConfig:function(a){j.saveLocal(function(b){b?$fh.forms.log.e("Error saving a form config: ",b):$fh.forms.log.l("Form config saved sucessfully."),"function"==typeof a&&a()})},offline:function(){j.setOffline()},online:function(){j.setOnline()},isOnline:function(){return j.isOnline()}};return a.config=l,a}(b.api||{}),"undefined"==typeof $fh&&($fh={}),void 0===$fh.forms&&($fh.forms=b.api),b&&(b.RulesEngine=a)}(window||module.exports); \ No newline at end of file diff --git a/feedhenry-titanium.js b/feedhenry-titanium.js index 2a5c81f9..ebc7cf7e 100644 --- a/feedhenry-titanium.js +++ b/feedhenry-titanium.js @@ -6902,8 +6902,8 @@ function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } -}).call(this,_dereq_("/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":6,"/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,"inherits":10}],8:[function(_dereq_,module,exports){ +}).call(this,_dereq_("/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./support/isBuffer":6,"/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,"inherits":10}],8:[function(_dereq_,module,exports){ (function (global){ /*global window, global*/ var util = _dereq_("util") @@ -7378,7 +7378,7 @@ process.chdir = function (dir) { module.exports=_dereq_(6) },{}],13:[function(_dereq_,module,exports){ module.exports=_dereq_(7) -},{"./support/isBuffer":12,"/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,"inherits":10}],14:[function(_dereq_,module,exports){ +},{"./support/isBuffer":12,"/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,"inherits":10}],14:[function(_dereq_,module,exports){ /* * loglevel - https://github.com/pimterry/loglevel * @@ -7578,35 +7578,35 @@ module.exports=_dereq_(7) })(); },{}],15:[function(_dereq_,module,exports){ -var toString = Object.prototype.toString - -module.exports = function(val){ - switch (toString.call(val)) { - case '[object Function]': return 'function' - case '[object Date]': return 'date' - case '[object RegExp]': return 'regexp' - case '[object Arguments]': return 'arguments' - case '[object Array]': return 'array' - case '[object String]': return 'string' - } - - if (typeof val == 'object' && val && typeof val.length == 'number') { - try { - if (typeof val.callee == 'function') return 'arguments'; - } catch (ex) { - if (ex instanceof TypeError) { - return 'arguments'; - } - } - } - - if (val === null) return 'null' - if (val === undefined) return 'undefined' - if (val && val.nodeType === 1) return 'element' - if (val === Object(val)) return 'object' - - return typeof val -} +var toString = Object.prototype.toString + +module.exports = function(val){ + switch (toString.call(val)) { + case '[object Function]': return 'function' + case '[object Date]': return 'date' + case '[object RegExp]': return 'regexp' + case '[object Arguments]': return 'arguments' + case '[object Array]': return 'array' + case '[object String]': return 'string' + } + + if (typeof val == 'object' && val && typeof val.length == 'number') { + try { + if (typeof val.callee == 'function') return 'arguments'; + } catch (ex) { + if (ex instanceof TypeError) { + return 'arguments'; + } + } + } + + if (val === null) return 'null' + if (val === undefined) return 'undefined' + if (val && val.nodeType === 1) return 'element' + if (val === Object(val)) return 'object' + + return typeof val +} },{}],16:[function(_dereq_,module,exports){ var constants = _dereq_("./modules/constants"); @@ -10816,7 +10816,9 @@ module.exports = { setAppProps: setAppProps }; -},{"../ajax":18,"../constants":26,"../logger":35,"../queryMap":37}],"RdeKcl":[function(_dereq_,module,exports){ +},{"../ajax":18,"../constants":26,"../logger":35,"../queryMap":37}],"./cookies":[function(_dereq_,module,exports){ +module.exports=_dereq_('RdeKcl'); +},{}],"RdeKcl":[function(_dereq_,module,exports){ module.exports = { readCookieValue : function (cookie_name) { if (typeof Titanium !== 'undefined'){ @@ -10831,8 +10833,6 @@ module.exports = { } } }; -},{}],"./cookies":[function(_dereq_,module,exports){ -module.exports=_dereq_('RdeKcl'); },{}],48:[function(_dereq_,module,exports){ module.exports = { createUUID : function () { diff --git a/feedhenry-titanium.min.js b/feedhenry-titanium.min.js index 6706ae18..c7b0686b 100644 --- a/feedhenry-titanium.min.js +++ b/feedhenry-titanium.min.js @@ -1,4 +1,4 @@ "undefined"!=typeof Titanium&&("undefined"==typeof window&&(window={top:{},location:{protocol:"",href:""}}),"undefined"==typeof document&&(document={location:{href:"",search:""}}),"undefined"==typeof navigator&&(navigator={userAgent:"Titanium"})),!function(a){if("object"==typeof exports)module.exports=a();else if("function"==typeof define&&define.amd)define(a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.feedhenry=a()}}(function(){var define,module,exports;return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gf;f++){var g=c[f>>>2]>>>24-f%4*8&255;b[d+f>>>2]|=g<<24-(d+f)%4*8}else if(c.length>65535)for(var f=0;e>f;f+=4)b[d+f>>>2]=c[f>>>2];else b.push.apply(b,c);return this.sigBytes+=e,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-c%4*8,b.length=a.ceil(c/4)},clone:function(){var a=e.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;b>d;d+=4)c.push(4294967296*a.random()|0);return new f.init(c,b)}}),g=c.enc={},h=g.Hex={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push((f>>>4).toString(16)),d.push((15&f).toString(16))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-d%8*4;return new f.init(c,b/2)}},i=g.Latin1={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push(String.fromCharCode(f))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-d%4*8;return new f.init(c,b)}},j=g.Utf8={stringify:function(a){try{return decodeURIComponent(escape(i.stringify(a)))}catch(b){throw new Error("Malformed UTF-8 data")}},parse:function(a){return i.parse(unescape(encodeURIComponent(a)))}},k=d.BufferedBlockAlgorithm=e.extend({reset:function(){this._data=new f.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,g=this.blockSize,h=4*g,i=e/h;i=b?a.ceil(i):a.max((0|i)-this._minBufferSize,0);var j=i*g,k=a.min(4*j,e);if(j){for(var l=0;j>l;l+=g)this._doProcessBlock(d,l);var m=d.splice(0,j);c.sigBytes-=k}return new f.init(m,k)},clone:function(){var a=e.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0}),l=(d.Hasher=k.extend({cfg:e.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){k.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){a&&this._append(a);var b=this._doFinalize();return b},blockSize:16,_createHelper:function(a){return function(b,c){return new a.init(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return new l.HMAC.init(a,c).finalize(b)}}}),c.algo={});return c}(Math);!function(){{var a=f,b=a.lib,c=b.WordArray,d=a.enc;d.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp();for(var e=[],f=0;c>f;f+=3)for(var g=b[f>>>2]>>>24-f%4*8&255,h=b[f+1>>>2]>>>24-(f+1)%4*8&255,i=b[f+2>>>2]>>>24-(f+2)%4*8&255,j=g<<16|h<<8|i,k=0;4>k&&c>f+.75*k;k++)e.push(d.charAt(j>>>6*(3-k)&63));var l=d.charAt(64);if(l)for(;e.length%4;)e.push(l);return e.join("")},parse:function(a){var b=a.length,d=this._map,e=d.charAt(64);if(e){var f=a.indexOf(e);-1!=f&&(b=f)}for(var g=[],h=0,i=0;b>i;i++)if(i%4){var j=d.indexOf(a.charAt(i-1))<>>6-i%4*2;g[h>>>2]|=(j|k)<<24-h%4*8,h++}return c.create(g,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}}(),f.lib.Cipher||function(a){var b=f,c=b.lib,d=c.Base,e=c.WordArray,g=c.BufferedBlockAlgorithm,h=b.enc,i=(h.Utf8,h.Base64),j=b.algo,k=j.EvpKDF,l=c.Cipher=g.extend({cfg:d.extend(),createEncryptor:function(a,b){return this.create(this._ENC_XFORM_MODE,a,b)},createDecryptor:function(a,b){return this.create(this._DEC_XFORM_MODE,a,b)},init:function(a,b,c){this.cfg=this.cfg.extend(c),this._xformMode=a,this._key=b,this.reset()},reset:function(){g.reset.call(this),this._doReset()},process:function(a){return this._append(a),this._process()},finalize:function(a){a&&this._append(a);var b=this._doFinalize();return b},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function a(a){return"string"==typeof a?x:u}return function(b){return{encrypt:function(c,d,e){return a(d).encrypt(b,c,d,e)},decrypt:function(c,d,e){return a(d).decrypt(b,c,d,e)}}}}()}),m=(c.StreamCipher=l.extend({_doFinalize:function(){var a=this._process(!0);return a},blockSize:1}),b.mode={}),n=c.BlockCipherMode=d.extend({createEncryptor:function(a,b){return this.Encryptor.create(a,b)},createDecryptor:function(a,b){return this.Decryptor.create(a,b)},init:function(a,b){this._cipher=a,this._iv=b}}),o=m.CBC=function(){function b(b,c,d){var e=this._iv;if(e){var f=e;this._iv=a}else var f=this._prevBlock;for(var g=0;d>g;g++)b[c+g]^=f[g]}var c=n.extend();return c.Encryptor=c.extend({processBlock:function(a,c){var d=this._cipher,e=d.blockSize;b.call(this,a,c,e),d.encryptBlock(a,c),this._prevBlock=a.slice(c,c+e)}}),c.Decryptor=c.extend({processBlock:function(a,c){var d=this._cipher,e=d.blockSize,f=a.slice(c,c+e);d.decryptBlock(a,c),b.call(this,a,c,e),this._prevBlock=f}}),c}(),p=b.pad={},q=p.Pkcs7={pad:function(a,b){for(var c=4*b,d=c-a.sigBytes%c,f=d<<24|d<<16|d<<8|d,g=[],h=0;d>h;h+=4)g.push(f);var i=e.create(g,d);a.concat(i)},unpad:function(a){var b=255&a.words[a.sigBytes-1>>>2];a.sigBytes-=b}},r=(c.BlockCipher=l.extend({cfg:l.cfg.extend({mode:o,padding:q}),reset:function(){l.reset.call(this);var a=this.cfg,b=a.iv,c=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var d=c.createEncryptor;else{var d=c.createDecryptor;this._minBufferSize=1}this._mode=d.call(c,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else{var b=this._process(!0);a.unpad(b)}return b},blockSize:4}),c.CipherParams=d.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}})),s=b.format={},t=s.OpenSSL={stringify:function(a){var b=a.ciphertext,c=a.salt;if(c)var d=e.create([1398893684,1701076831]).concat(c).concat(b);else var d=b;return d.toString(i)},parse:function(a){var b=i.parse(a),c=b.words;if(1398893684==c[0]&&1701076831==c[1]){var d=e.create(c.slice(2,4));c.splice(0,4),b.sigBytes-=16}return r.create({ciphertext:b,salt:d})}},u=c.SerializableCipher=d.extend({cfg:d.extend({format:t}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d),f=e.finalize(b),g=e.cfg;return r.create({ciphertext:f,key:c,iv:g.iv,algorithm:a,mode:g.mode,padding:g.padding,blockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){d=this.cfg.extend(d),b=this._parse(b,d.format);var e=a.createDecryptor(c,d).finalize(b.ciphertext);return e},_parse:function(a,b){return"string"==typeof a?b.parse(a,this):a}}),v=b.kdf={},w=v.OpenSSL={execute:function(a,b,c,d){d||(d=e.random(8));var f=k.create({keySize:b+c}).compute(a,d),g=e.create(f.words.slice(b),4*c);return f.sigBytes=4*b,r.create({key:f,iv:g,salt:d})}},x=c.PasswordBasedCipher=u.extend({cfg:u.cfg.extend({kdf:w}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=d.kdf.execute(c,a.keySize,a.ivSize);d.iv=e.iv;var f=u.encrypt.call(this,a,b,e.key,d);return f.mixIn(e),f},decrypt:function(a,b,c,d){d=this.cfg.extend(d),b=this._parse(b,d.format);var e=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=e.iv;var f=u.decrypt.call(this,a,b,e.key,d);return f}})}(),function(){var a=f,b=a.lib,c=b.BlockCipher,d=a.algo,e=[],g=[],h=[],i=[],j=[],k=[],l=[],m=[],n=[],o=[];!function(){for(var a=[],b=0;256>b;b++)a[b]=128>b?b<<1:b<<1^283;for(var c=0,d=0,b=0;256>b;b++){var f=d^d<<1^d<<2^d<<3^d<<4;f=f>>>8^255&f^99,e[c]=f,g[f]=c;var p=a[c],q=a[p],r=a[q],s=257*a[f]^16843008*f;h[c]=s<<24|s>>>8,i[c]=s<<16|s>>>16,j[c]=s<<8|s>>>24,k[c]=s;var s=16843009*r^65537*q^257*p^16843008*c;l[f]=s<<24|s>>>8,m[f]=s<<16|s>>>16,n[f]=s<<8|s>>>24,o[f]=s,c?(c=p^a[a[a[r^p]]],d^=a[a[d]]):c=d=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],q=d.AES=c.extend({_doReset:function(){for(var a=this._key,b=a.words,c=a.sigBytes/4,d=this._nRounds=c+6,f=4*(d+1),g=this._keySchedule=[],h=0;f>h;h++)if(c>h)g[h]=b[h];else{var i=g[h-1];h%c?c>6&&h%c==4&&(i=e[i>>>24]<<24|e[i>>>16&255]<<16|e[i>>>8&255]<<8|e[255&i]):(i=i<<8|i>>>24,i=e[i>>>24]<<24|e[i>>>16&255]<<16|e[i>>>8&255]<<8|e[255&i],i^=p[h/c|0]<<24),g[h]=g[h-c]^i}for(var j=this._invKeySchedule=[],k=0;f>k;k++){var h=f-k;if(k%4)var i=g[h];else var i=g[h-4];j[k]=4>k||4>=h?i:l[e[i>>>24]]^m[e[i>>>16&255]]^n[e[i>>>8&255]]^o[e[255&i]]}},encryptBlock:function(a,b){this._doCryptBlock(a,b,this._keySchedule,h,i,j,k,e)},decryptBlock:function(a,b){var c=a[b+1];a[b+1]=a[b+3],a[b+3]=c,this._doCryptBlock(a,b,this._invKeySchedule,l,m,n,o,g);var c=a[b+1];a[b+1]=a[b+3],a[b+3]=c},_doCryptBlock:function(a,b,c,d,e,f,g,h){for(var i=this._nRounds,j=a[b]^c[0],k=a[b+1]^c[1],l=a[b+2]^c[2],m=a[b+3]^c[3],n=4,o=1;i>o;o++){var p=d[j>>>24]^e[k>>>16&255]^f[l>>>8&255]^g[255&m]^c[n++],q=d[k>>>24]^e[l>>>16&255]^f[m>>>8&255]^g[255&j]^c[n++],r=d[l>>>24]^e[m>>>16&255]^f[j>>>8&255]^g[255&k]^c[n++],s=d[m>>>24]^e[j>>>16&255]^f[k>>>8&255]^g[255&l]^c[n++];j=p,k=q,l=r,m=s}var p=(h[j>>>24]<<24|h[k>>>16&255]<<16|h[l>>>8&255]<<8|h[255&m])^c[n++],q=(h[k>>>24]<<24|h[l>>>16&255]<<16|h[m>>>8&255]<<8|h[255&j])^c[n++],r=(h[l>>>24]<<24|h[m>>>16&255]<<16|h[j>>>8&255]<<8|h[255&k])^c[n++],s=(h[m>>>24]<<24|h[j>>>16&255]<<16|h[k>>>8&255]<<8|h[255&l])^c[n++];a[b]=p,a[b+1]=q,a[b+2]=r,a[b+3]=s},keySize:8});a.AES=c._createHelper(q)}(),function(a){function b(a,b,c,d,e,f,g){var h=a+(b&c|~b&d)+e+g;return(h<>>32-f)+b}function c(a,b,c,d,e,f,g){var h=a+(b&d|c&~d)+e+g;return(h<>>32-f)+b}function d(a,b,c,d,e,f,g){var h=a+(b^c^d)+e+g;return(h<>>32-f)+b}function e(a,b,c,d,e,f,g){var h=a+(c^(b|~d))+e+g;return(h<>>32-f)+b}var g=f,h=g.lib,i=h.WordArray,j=h.Hasher,k=g.algo,l=[];!function(){for(var b=0;64>b;b++)l[b]=4294967296*a.abs(a.sin(b+1))|0}();var m=k.MD5=j.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(a,f){for(var g=0;16>g;g++){var h=f+g,i=a[h];a[h]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var j=this._hash.words,k=a[f+0],m=a[f+1],n=a[f+2],o=a[f+3],p=a[f+4],q=a[f+5],r=a[f+6],s=a[f+7],t=a[f+8],u=a[f+9],v=a[f+10],w=a[f+11],x=a[f+12],y=a[f+13],z=a[f+14],A=a[f+15],B=j[0],C=j[1],D=j[2],E=j[3];B=b(B,C,D,E,k,7,l[0]),E=b(E,B,C,D,m,12,l[1]),D=b(D,E,B,C,n,17,l[2]),C=b(C,D,E,B,o,22,l[3]),B=b(B,C,D,E,p,7,l[4]),E=b(E,B,C,D,q,12,l[5]),D=b(D,E,B,C,r,17,l[6]),C=b(C,D,E,B,s,22,l[7]),B=b(B,C,D,E,t,7,l[8]),E=b(E,B,C,D,u,12,l[9]),D=b(D,E,B,C,v,17,l[10]),C=b(C,D,E,B,w,22,l[11]),B=b(B,C,D,E,x,7,l[12]),E=b(E,B,C,D,y,12,l[13]),D=b(D,E,B,C,z,17,l[14]),C=b(C,D,E,B,A,22,l[15]),B=c(B,C,D,E,m,5,l[16]),E=c(E,B,C,D,r,9,l[17]),D=c(D,E,B,C,w,14,l[18]),C=c(C,D,E,B,k,20,l[19]),B=c(B,C,D,E,q,5,l[20]),E=c(E,B,C,D,v,9,l[21]),D=c(D,E,B,C,A,14,l[22]),C=c(C,D,E,B,p,20,l[23]),B=c(B,C,D,E,u,5,l[24]),E=c(E,B,C,D,z,9,l[25]),D=c(D,E,B,C,o,14,l[26]),C=c(C,D,E,B,t,20,l[27]),B=c(B,C,D,E,y,5,l[28]),E=c(E,B,C,D,n,9,l[29]),D=c(D,E,B,C,s,14,l[30]),C=c(C,D,E,B,x,20,l[31]),B=d(B,C,D,E,q,4,l[32]),E=d(E,B,C,D,t,11,l[33]),D=d(D,E,B,C,w,16,l[34]),C=d(C,D,E,B,z,23,l[35]),B=d(B,C,D,E,m,4,l[36]),E=d(E,B,C,D,p,11,l[37]),D=d(D,E,B,C,s,16,l[38]),C=d(C,D,E,B,v,23,l[39]),B=d(B,C,D,E,y,4,l[40]),E=d(E,B,C,D,k,11,l[41]),D=d(D,E,B,C,o,16,l[42]),C=d(C,D,E,B,r,23,l[43]),B=d(B,C,D,E,u,4,l[44]),E=d(E,B,C,D,x,11,l[45]),D=d(D,E,B,C,A,16,l[46]),C=d(C,D,E,B,n,23,l[47]),B=e(B,C,D,E,k,6,l[48]),E=e(E,B,C,D,s,10,l[49]),D=e(D,E,B,C,z,15,l[50]),C=e(C,D,E,B,q,21,l[51]),B=e(B,C,D,E,x,6,l[52]),E=e(E,B,C,D,o,10,l[53]),D=e(D,E,B,C,v,15,l[54]),C=e(C,D,E,B,m,21,l[55]),B=e(B,C,D,E,t,6,l[56]),E=e(E,B,C,D,A,10,l[57]),D=e(D,E,B,C,r,15,l[58]),C=e(C,D,E,B,y,21,l[59]),B=e(B,C,D,E,p,6,l[60]),E=e(E,B,C,D,w,10,l[61]),D=e(D,E,B,C,n,15,l[62]),C=e(C,D,E,B,u,21,l[63]),j[0]=j[0]+B|0,j[1]=j[1]+C|0,j[2]=j[2]+D|0,j[3]=j[3]+E|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;c[e>>>5]|=128<<24-e%32;var f=a.floor(d/4294967296),g=d;c[(e+64>>>9<<4)+15]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),c[(e+64>>>9<<4)+14]=16711935&(g<<8|g>>>24)|4278255360&(g<<24|g>>>8),b.sigBytes=4*(c.length+1),this._process();for(var h=this._hash,i=h.words,j=0;4>j;j++){var k=i[j];i[j]=16711935&(k<<8|k>>>24)|4278255360&(k<<24|k>>>8)}return h},clone:function(){var a=j.clone.call(this);return a._hash=this._hash.clone(),a}});g.MD5=j._createHelper(m),g.HmacMD5=j._createHmacHelper(m)}(Math),function(){var a=f,b=a.lib,c=b.WordArray,d=b.Hasher,e=a.algo,g=[],h=e.SHA1=d.extend({_doReset:function(){this._hash=new c.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],h=c[3],i=c[4],j=0;80>j;j++){if(16>j)g[j]=0|a[b+j];else{var k=g[j-3]^g[j-8]^g[j-14]^g[j-16];g[j]=k<<1|k>>>31}var l=(d<<5|d>>>27)+i+g[j];l+=20>j?(e&f|~e&h)+1518500249:40>j?(e^f^h)+1859775393:60>j?(e&f|e&h|f&h)-1894007588:(e^f^h)-899497514,i=h,h=f,f=e<<30|e>>>2,e=d,d=l}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;return b[d>>>5]|=128<<24-d%32,b[(d+64>>>9<<4)+14]=Math.floor(c/4294967296),b[(d+64>>>9<<4)+15]=c,a.sigBytes=4*b.length,this._process(),this._hash},clone:function(){var a=d.clone.call(this);return a._hash=this._hash.clone(),a}});a.SHA1=d._createHelper(h),a.HmacSHA1=d._createHmacHelper(h)}(),function(a){{var b=f,c=b.lib,d=c.Base,e=c.WordArray,g=b.x64={};g.Word=d.extend({init:function(a,b){this.high=a,this.low=b}}),g.WordArray=d.extend({init:function(b,c){b=this.words=b||[],this.sigBytes=c!=a?c:8*b.length},toX32:function(){for(var a=this.words,b=a.length,c=[],d=0;b>d;d++){var f=a[d];c.push(f.high),c.push(f.low)}return e.create(c,this.sigBytes)},clone:function(){for(var a=d.clone.call(this),b=a.words=this.words.slice(0),c=b.length,e=0;c>e;e++)b[e]=b[e].clone();return a}})}}(),function(a){var b=f,c=b.lib,d=c.WordArray,e=c.Hasher,g=b.algo,h=[],i=[];!function(){function b(b){for(var c=a.sqrt(b),d=2;c>=d;d++)if(!(b%d))return!1;return!0}function c(a){return 4294967296*(a-(0|a))|0}for(var d=2,e=0;64>e;)b(d)&&(8>e&&(h[e]=c(a.pow(d,.5))),i[e]=c(a.pow(d,1/3)),e++),d++}();var j=[],k=g.SHA256=e.extend({_doReset:function(){this._hash=new d.init(h.slice(0))},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],k=c[5],l=c[6],m=c[7],n=0;64>n;n++){if(16>n)j[n]=0|a[b+n];else{var o=j[n-15],p=(o<<25|o>>>7)^(o<<14|o>>>18)^o>>>3,q=j[n-2],r=(q<<15|q>>>17)^(q<<13|q>>>19)^q>>>10;j[n]=p+j[n-7]+r+j[n-16]}var s=h&k^~h&l,t=d&e^d&f^e&f,u=(d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22),v=(h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25),w=m+v+s+i[n]+j[n],x=u+t;m=l,l=k,k=h,h=g+w|0,g=f,f=e,e=d,d=w+x|0}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+g|0,c[4]=c[4]+h|0,c[5]=c[5]+k|0,c[6]=c[6]+l|0,c[7]=c[7]+m|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;return c[e>>>5]|=128<<24-e%32,c[(e+64>>>9<<4)+14]=a.floor(d/4294967296),c[(e+64>>>9<<4)+15]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=e.clone.call(this);return a._hash=this._hash.clone(),a}});b.SHA256=e._createHelper(k),b.HmacSHA256=e._createHmacHelper(k)}(Math),function(){function a(){return g.create.apply(g,arguments)}var b=f,c=b.lib,d=c.Hasher,e=b.x64,g=e.Word,h=e.WordArray,i=b.algo,j=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],k=[];!function(){for(var b=0;80>b;b++)k[b]=a()}();var l=i.SHA512=d.extend({_doReset:function(){this._hash=new h.init([new g.init(1779033703,4089235720),new g.init(3144134277,2227873595),new g.init(1013904242,4271175723),new g.init(2773480762,1595750129),new g.init(1359893119,2917565137),new g.init(2600822924,725511199),new g.init(528734635,4215389547),new g.init(1541459225,327033209)])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],i=c[5],l=c[6],m=c[7],n=d.high,o=d.low,p=e.high,q=e.low,r=f.high,s=f.low,t=g.high,u=g.low,v=h.high,w=h.low,x=i.high,y=i.low,z=l.high,A=l.low,B=m.high,C=m.low,D=n,E=o,F=p,G=q,H=r,I=s,J=t,K=u,L=v,M=w,N=x,O=y,P=z,Q=A,R=B,S=C,T=0;80>T;T++){var U=k[T];if(16>T)var V=U.high=0|a[b+2*T],W=U.low=0|a[b+2*T+1];else{var X=k[T-15],Y=X.high,Z=X.low,$=(Y>>>1|Z<<31)^(Y>>>8|Z<<24)^Y>>>7,_=(Z>>>1|Y<<31)^(Z>>>8|Y<<24)^(Z>>>7|Y<<25),ab=k[T-2],bb=ab.high,cb=ab.low,db=(bb>>>19|cb<<13)^(bb<<3|cb>>>29)^bb>>>6,eb=(cb>>>19|bb<<13)^(cb<<3|bb>>>29)^(cb>>>6|bb<<26),fb=k[T-7],gb=fb.high,hb=fb.low,ib=k[T-16],jb=ib.high,kb=ib.low,W=_+hb,V=$+gb+(_>>>0>W>>>0?1:0),W=W+eb,V=V+db+(eb>>>0>W>>>0?1:0),W=W+kb,V=V+jb+(kb>>>0>W>>>0?1:0);U.high=V,U.low=W}var lb=L&N^~L&P,mb=M&O^~M&Q,nb=D&F^D&H^F&H,ob=E&G^E&I^G&I,pb=(D>>>28|E<<4)^(D<<30|E>>>2)^(D<<25|E>>>7),qb=(E>>>28|D<<4)^(E<<30|D>>>2)^(E<<25|D>>>7),rb=(L>>>14|M<<18)^(L>>>18|M<<14)^(L<<23|M>>>9),sb=(M>>>14|L<<18)^(M>>>18|L<<14)^(M<<23|L>>>9),tb=j[T],ub=tb.high,vb=tb.low,wb=S+sb,xb=R+rb+(S>>>0>wb>>>0?1:0),wb=wb+mb,xb=xb+lb+(mb>>>0>wb>>>0?1:0),wb=wb+vb,xb=xb+ub+(vb>>>0>wb>>>0?1:0),wb=wb+W,xb=xb+V+(W>>>0>wb>>>0?1:0),yb=qb+ob,zb=pb+nb+(qb>>>0>yb>>>0?1:0);R=P,S=Q,P=N,Q=O,N=L,O=M,M=K+wb|0,L=J+xb+(K>>>0>M>>>0?1:0)|0,J=H,K=I,H=F,I=G,F=D,G=E,E=wb+yb|0,D=xb+zb+(wb>>>0>E>>>0?1:0)|0}o=d.low=o+E,d.high=n+D+(E>>>0>o>>>0?1:0),q=e.low=q+G,e.high=p+F+(G>>>0>q>>>0?1:0),s=f.low=s+I,f.high=r+H+(I>>>0>s>>>0?1:0),u=g.low=u+K,g.high=t+J+(K>>>0>u>>>0?1:0),w=h.low=w+M,h.high=v+L+(M>>>0>w>>>0?1:0),y=i.low=y+O,i.high=x+N+(O>>>0>y>>>0?1:0),A=l.low=A+Q,l.high=z+P+(Q>>>0>A>>>0?1:0),C=m.low=C+S,m.high=B+R+(S>>>0>C>>>0?1:0)},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;b[d>>>5]|=128<<24-d%32,b[(d+128>>>10<<5)+30]=Math.floor(c/4294967296),b[(d+128>>>10<<5)+31]=c,a.sigBytes=4*b.length,this._process();var e=this._hash.toX32();return e},clone:function(){var a=d.clone.call(this);return a._hash=this._hash.clone(),a},blockSize:32});b.SHA512=d._createHelper(l),b.HmacSHA512=d._createHmacHelper(l)}(),function(a){var b=f,c=b.lib,d=c.WordArray,e=c.Hasher,g=b.x64,h=g.Word,i=b.algo,j=[],k=[],l=[];!function(){for(var a=1,b=0,c=0;24>c;c++){j[a+5*b]=(c+1)*(c+2)/2%64;var d=b%5,e=(2*a+3*b)%5;a=d,b=e}for(var a=0;5>a;a++)for(var b=0;5>b;b++)k[a+5*b]=b+(2*a+3*b)%5*5;for(var f=1,g=0;24>g;g++){for(var i=0,m=0,n=0;7>n;n++){if(1&f){var o=(1<o?m^=1<a;a++)m[a]=h.create()}();var n=i.SHA3=e.extend({cfg:e.cfg.extend({outputLength:512}),_doReset:function(){for(var a=this._state=[],b=0;25>b;b++)a[b]=new h.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(a,b){for(var c=this._state,d=this.blockSize/2,e=0;d>e;e++){var f=a[b+2*e],g=a[b+2*e+1];f=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),g=16711935&(g<<8|g>>>24)|4278255360&(g<<24|g>>>8);var h=c[e];h.high^=g,h.low^=f}for(var i=0;24>i;i++){for(var n=0;5>n;n++){for(var o=0,p=0,q=0;5>q;q++){var h=c[n+5*q];o^=h.high,p^=h.low}var r=m[n];r.high=o,r.low=p}for(var n=0;5>n;n++)for(var s=m[(n+4)%5],t=m[(n+1)%5],u=t.high,v=t.low,o=s.high^(u<<1|v>>>31),p=s.low^(v<<1|u>>>31),q=0;5>q;q++){var h=c[n+5*q];h.high^=o,h.low^=p}for(var w=1;25>w;w++){var h=c[w],x=h.high,y=h.low,z=j[w];if(32>z)var o=x<>>32-z,p=y<>>32-z;else var o=y<>>64-z,p=x<>>64-z;var A=m[k[w]];A.high=o,A.low=p}var B=m[0],C=c[0];B.high=C.high,B.low=C.low;for(var n=0;5>n;n++)for(var q=0;5>q;q++){var w=n+5*q,h=c[w],D=m[w],E=m[(n+1)%5+5*q],F=m[(n+2)%5+5*q];h.high=D.high^~E.high&F.high,h.low=D.low^~E.low&F.low}var h=c[0],G=l[i];h.high^=G.high,h.low^=G.low}},_doFinalize:function(){var b=this._data,c=b.words,e=(8*this._nDataBytes,8*b.sigBytes),f=32*this.blockSize;c[e>>>5]|=1<<24-e%32,c[(a.ceil((e+1)/f)*f>>>5)-1]|=128,b.sigBytes=4*c.length,this._process();for(var g=this._state,h=this.cfg.outputLength/8,i=h/8,j=[],k=0;i>k;k++){var l=g[k],m=l.high,n=l.low;m=16711935&(m<<8|m>>>24)|4278255360&(m<<24|m>>>8),n=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),j.push(n),j.push(m)}return new d.init(j,h)},clone:function(){for(var a=e.clone.call(this),b=a._state=this._state.slice(0),c=0;25>c;c++)b[c]=b[c].clone();return a}});b.SHA3=e._createHelper(n),b.HmacSHA3=e._createHmacHelper(n)}(Math),e("undefined"!=typeof f?f:window.CryptoJS)}.call(c,void 0,void 0,void 0,void 0,function(a){b.exports=a})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(a,b){(function(c){__browserify_shim_require__=a,function(a,b,c,d,e){var f=function(a,b){if(!(this instanceof f))return new f(a,b);if(!JSON)throw"JSON unavailable! Include http://www.json.org/json2.js to fix.";if(!(arguments.length<=2&&arguments.length>0))throw"Incorrect # of ctor args!";if(b="function"==typeof arguments[0]?arguments[0]:arguments[1],a="function"==typeof arguments[0]?{}:arguments[0],"function"!=typeof b)throw"No callback was provided";this.record=a.record||"record",this.name=a.name||"records";var c;if(a.adapter){"string"==typeof a.adapter&&(a.adapter=[a.adapter]);for(var d=0,e=a.adapter.length;e>d;d++){for(var g=f.adapters.length-1;g>=0&&(f.adapters[g].adapter!==a.adapter[d]||!(c=f.adapters[g].valid()?f.adapters[g]:void 0));g--);if(c)break}}else for(var g=0,h=f.adapters.length;h>g&&!(c=f.adapters[g].valid()?f.adapters[g]:void 0);g++);if(!c)throw"No valid adapter.";for(var d in c)this[d]=c[d];for(var g=0,h=f.plugins.length;h>g;g++)f.plugins[g].call(this);this.init(a,b)};f.adapters=[],f.adapter=function(a,b){b.adapter=a;var c="adapter valid init keys save batch get exists all remove nuke".split(" "),d=this.prototype.indexOf;for(var e in b)if(-1===d(c,e))throw"Invalid adapter! Nonstandard method: "+e;f.adapters.splice(0,0,b)},f.plugins=[],f.plugin=function(a){for(var b in a)"init"===b?f.plugins.push(a[b]):this.prototype[b]=a[b]},f.prototype={isArray:Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},indexOf:function(a,b,c,d){if(a.indexOf)return a.indexOf(b);for(c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},lambda:function(a){return this.fn(this.record,a)},fn:function(a,b){return"string"==typeof b?new Function(a,b):b},uuid:function(){var a=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()},each:function(a){var b=this.lambda(a);if(this.__results)for(var c=0,d=this.__results.length;d>c;c++)b.call(this,this.__results[c],c);else this.all(function(a){for(var c=0,d=a.length;d>c;c++)b.call(this,a[c],c)});return this}},f.adapter("window-name",function(){"undefined"==typeof window&&(window={top:{}});var a={};try{a=JSON.parse(window.top.name)}catch(b){}return{valid:function(){return"undefined"!=typeof window.top.name},init:function(b,c){return a[this.name]=a[this.name]||{index:[],store:{}},this.index=a[this.name].index,this.store=a[this.name].store,this.fn(this.name,c).call(this,this),this},keys:function(a){return this.fn("keys",a).call(this,this.index),this},save:function(b,c){var d=b.key||this.uuid();return this.exists(d,function(e){e||(b.key&&delete b.key,this.index.push(d)),this.store[d]=b;try{window.top.name=JSON.stringify(a)}catch(f){throw e||(this.index.pop(),delete this.store[d]),f}c&&(b.key=d,this.lambda(c).call(this,b))}),this},batch:function(a,b){for(var c=[],d=0,e=a.length;e>d;d++)this.save(a[d],function(a){c.push(a)});return b&&this.lambda(b).call(this,c),this},get:function(a,b){var c;if(this.isArray(a)){c=[];for(var d=0,e=a.length;e>d;d++)c.push(this.store[a[d]])}else c=this.store[a],c&&(c.key=a);return b&&this.lambda(b).call(this,c),this},exists:function(a,b){return this.lambda(b).call(this,!!this.store[a]),this},all:function(a){for(var b=[],c=0,d=this.index.length;d>c;c++){var e=this.store[this.index[c]];e.key=this.index[c],b.push(e)}return this.fn(this.name,a).call(this,b),this},remove:function(b,c){for(var d=this.isArray(b)?b:[b],e=0,f=d.length;f>e;e++){var g=d[e].key?d[e].key:d[e],h=this.indexOf(this.index,g);0>h||(delete this.store[g],this.index.splice(h,1))}return window.top.name=JSON.stringify(a),c&&this.lambda(c).call(this),this},nuke:function(b){return this.store=a[this.name].store={},this.index=a[this.name].index=[],window.top.name=JSON.stringify(a),b&&this.lambda(b).call(this),this}}}()),f.adapter("dom",function(){var a=null;try{a=window.localStorage}catch(b){}var c=function(b){return{key:b+"._index_",all:function(){var b=a.getItem(this.key);return b&&(b=JSON.parse(b)),null===b&&a.setItem(this.key,JSON.stringify([])),JSON.parse(a.getItem(this.key))},add:function(b){var c=this.all();c.push(b),a.setItem(this.key,JSON.stringify(c))},del:function(b){for(var c=this.all(),d=[],e=0,f=c.length;f>e;e++)c[e]!=b&&d.push(c[e]);a.setItem(this.key,JSON.stringify(d))},find:function(a){for(var b=this.all(),c=0,d=b.length;d>c;c++)if(a===b[c])return c;return!1}}};return{valid:function(){return!!a&&function(){var b=!0,c=Math.random();try{a.setItem(c,c)}catch(d){b=!1}return a.removeItem(c),b}()},init:function(a,b){this.indexer=c(this.name),b&&this.fn(this.name,b).call(this,this)},save:function(b,c){var d=b.key?this.name+"."+b.key:this.name+"."+this.uuid();return delete b.key,a.setItem(d,JSON.stringify(b)),this.indexer.find(d)===!1&&this.indexer.add(d),b.key=d.slice(this.name.length+1),c&&this.lambda(c).call(this,b),this},batch:function(a,b){for(var c=[],d=0,e=a.length;e>d;d++)this.save(a[d],function(a){c.push(a)});return b&&this.lambda(b).call(this,c),this},keys:function(a){if(a){var b=this.name,c=this.indexer.all(),d=[];if(Array.prototype.map)d=c.map(function(a){return a.replace(b+".","")});else for(var e in c)d.push(e.replace(b+".",""));this.fn("keys",a).call(this,d)}return this},get:function(b,c){if(this.isArray(b)){for(var d=[],e=0,f=b.length;f>e;e++){var g=this.name+"."+b[e],h=a.getItem(g);h&&(h=JSON.parse(h),h.key=b[e]),d.push(h)}c&&this.lambda(c).call(this,d)}else{var g=this.name+"."+b,h=a.getItem(g);h&&(h=JSON.parse(h),h.key=b),c&&this.lambda(c).call(this,h)}return this},exists:function(a,b){var c=this.indexer.find(this.name+"."+a)===!1?!1:!0;return this.lambda(b).call(this,c),this},all:function(b){for(var c,d,e=this.indexer.all(),f=[],g=0,h=e.length;h>g;g++)d=e[g],c=JSON.parse(a.getItem(d)),c.key=d.replace(this.name+".",""),f.push(c);return b&&this.fn(this.name,b).call(this,f),this},remove:function(b,c){var d=this;if(this.isArray(b)){var e,f=b.length,g=function(a){d.remove(b[a],function(){--f>0||c&&d.lambda(c).call(d)})};for(e=0;ec;c++)this.remove(b[c]);a&&this.lambda(a).call(this)}),this}}}()),f.adapter("webkit-sqlite",function(){var a=function(a,b){console&&console.log("error in sqlite adaptor!",a,b)},b=function(){return new Date};return{valid:function(){return!!window.openDatabase},init:function(b,c){var d=this,e=d.fn(d.name,c),f="CREATE TABLE IF NOT EXISTS "+this.record+" (id NVARCHAR(32) UNIQUE PRIMARY KEY, value TEXT, timestamp REAL)",g=function(){return e.call(d,d)};b&&"function"==typeof b.fail&&(a=b.fail),this.db=openDatabase(this.name,"1.0.0",this.name,65536),this.db.transaction(function(b){b.executeSql(f,[],g,a)})},keys:function(b){var c=this.lambda(b),d=this,e="SELECT id FROM "+this.record+" ORDER BY timestamp DESC";return this.db.readTransaction(function(b){var f=function(a,b){if(0==b.rows.length)c.call(d,[]);else{for(var e=[],f=0,g=b.rows.length;g>f;f++)e.push(b.rows.item(f).id);c.call(d,e)}};b.executeSql(e,[],f,a)}),this},save:function(c,d,e){var f=this;objs=(this.isArray(c)?c:[c]).map(function(a){return a.key||(a.key=f.uuid()),a}),ins="INSERT OR REPLACE INTO "+this.record+" (value, timestamp, id) VALUES (?,?,?)",win=function(){d&&f.lambda(d).call(f,f.isArray(c)?objs:objs[0])},e=e||function(){},insvals=[],ts=b();try{for(var g=0,h=objs.length;h>g;g++)insvals[g]=[JSON.stringify(objs[g]),ts,objs[g].key]}catch(i){throw a(i),i}return f.db.transaction(function(a){for(var b=0,c=objs.length;c>b;b++)a.executeSql(ins,insvals[b])},function(b,c){a(b,c)},win),this},batch:function(a,b){return this.save(a,b)},get:function(b,c){var d=this,e="",f=this.isArray(b)?b:[b];e="SELECT id, value FROM "+this.record+" WHERE id IN ("+f.map(function(){return"?"}).join(",")+")";var g=function(a,e){for(var g,h,i={},j=0,k=e.rows.length;k>j;j++)g=JSON.parse(e.rows.item(j).value),g.key=e.rows.item(j).id,i[g.key]=g;h=f.map(function(a){return i[a]}),d.isArray(b)||(h=h.length?h[0]:null),c&&d.lambda(c).call(d,h)};return this.db.readTransaction(function(b){b.executeSql(e,f,g,a) -}),this},exists:function(b,c){var d="SELECT * FROM "+this.record+" WHERE id = ?",e=this,f=function(a,b){c&&e.fn("exists",c).call(e,b.rows.length>0)};return this.db.readTransaction(function(c){c.executeSql(d,[b],f,a)}),this},all:function(b){var c=this,d="SELECT * FROM "+this.record,e=[],f=this.fn(this.name,b)||void 0,g=function(a,b){if(0!=b.rows.length)for(var d=0,g=b.rows.length;g>d;d++){var h=JSON.parse(b.rows.item(d).value);h.key=b.rows.item(d).id,e.push(h)}f&&f.call(c,e)};return this.db.readTransaction(function(b){b.executeSql(d,[],g,a)}),this},remove:function(b,c){var d,e=this,f="DELETE FROM "+this.record+" WHERE id ",g=function(){c&&e.lambda(c).call(e)};return this.isArray(b)?(d=b,f+="IN ("+d.map(function(){return"?"}).join(",")+")"):(f+="= ?",d=[b]),d=d.map(function(a){return a.key?a.key:a}),this.db.transaction(function(b){b.executeSql(f,d,g,a)}),this},nuke:function(b){var c="DELETE FROM "+this.record,d=this,e=b?function(){d.lambda(b).call(d)}:function(){};return this.db.transaction(function(b){b.executeSql(c,[],e,a)}),this}}}()),f.adapter("html5-filesystem",function(a){var b=a.FileError,c=function(a){var c,d=!0;switch(a.code){case b.QUOTA_EXCEEDED_ERR:c="QUOTA_EXCEEDED_ERR";break;case b.NOT_FOUND_ERR:c="NOT_FOUND_ERR",d=!1;break;case b.SECURITY_ERR:c="SECURITY_ERR";break;case b.INVALID_MODIFICATION_ERR:c="INVALID_MODIFICATION_ERR";break;case b.INVALID_STATE_ERR:c="INVALID_STATE_ERR";break;default:c="Unknown Error"}console&&d&&console.error(a,c)},d=function(a,b,e){var f=e||[];a.readEntries(function(c){c.length?d(a,b,f.concat(Array.prototype.slice.call(c))):b&&b(f.map(function(a){return a.name}))},c)},e={},f=function(a,b){var c=e[a.name];c?b(c):setTimeout(function(){f(a,b)},10)},g=function(){var a=-1===document.URL.indexOf("http://")&&-1===document.URL.indexOf("https://");return a?!0:!1},h=function(a){var b;if(g())b=a;else{var c="application/json";try{b=new Blob([a],{type:c})}catch(d){var e=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if("TypeError"==d.name&&e){var f=new e;f.append([a.buffer]),b=f.getBlob(c)}else b=a}}return b};return{valid:function(){var b=a.requestFileSystem||a.webkitRequestFileSystem||a.moz_requestFileSystem;return!!b},init:function(b,d){function f(b){var c=a.requestFileSystem||a.webkitRequestFileSystem||a.moz_requestFileSystem,f=window.PERSISTENT;"undefined"!=typeof LocalFileSystem&&"undefined"!=typeof LocalFileSystem.PERSISTENT&&(f=LocalFileSystem.PERSISTENT),c(f,b,function(a){a.root.getDirectory(j,{create:!0},function(a){e[j]=a,d&&g.fn(g.name,d).call(g,g)},function(a){h(a)})},function(a){h(a)})}var g=this,h=function(a){c(a),d&&g.fn(g.name,d).call(g,g)},i=b.size||104857600,j=this.name;"undefined"!=typeof navigator.webkitPersistentStorage?navigator.webkitPersistentStorage.requestQuota(i,f,function(){logger.warn("User declined file storage"),h("User declined file storage")}):f(0)},keys:function(a){var b=this;return f(this,function(c){d(c.createReader(),function(c){a&&b.fn("keys",a).call(b,c)})}),this},save:function(a,b){var d=this,e=a.key||this.uuid();a.key=e;var g=function(a){c(a),b&&d.lambda(b).call(d)};return f(this,function(c){c.getFile(e,{create:!0},function(c){c.createWriter(function(c){c.onerror=g,c.onwriteend=function(){this.onwriteend=null,this.truncate(this.position),b&&d.lambda(b).call(d,a)};var e=JSON.stringify(a),f=h(e);c.write(f)},g)},g)}),this},batch:function(a,b){for(var c=this,d=[],e=0,f=a.length;f>e;e++)c.save(a[e],function(a){d.push(a),d.length===f&&b&&c.lambda(b).call(c,d)});return this},get:function(a,b){var d=this;if(this.isArray(a))for(var e=[],g=0,h=a.length;h>g;g++)d.get(a[g],function(a){a&&e.push(a),e.length===h&&b&&d.lambda(b).call(d,e)});else{var i=function(a){c(a),b&&d.lambda(b).call(d)};f(this,function(c){c.getFile(a,{create:!1},function(c){c.file(function(c){var e=new FileReader;e.onerror=i,e.onload=function(c){var e={};try{e=JSON.parse(c.target.result),e.key=a}catch(c){e={key:a}}b&&d.lambda(b).call(d,e)},e.readAsText(c)},i)},i)})}return this},exists:function(a,b){var c=this;return f(this,function(d){d.getFile(a,{create:!1},function(){b&&c.lambda(b).call(c,!0)},function(){b&&c.lambda(b).call(c,!1)})}),this},all:function(a){var b=this;return a&&this.keys(function(c){c.length?b.get(c,function(c){b.fn(b.name,a).call(b,c)}):b.fn(b.name,a).call(b,[])}),this},remove:function(a,b){var d=this,e=function(a){c(a),b&&d.lambda(b).call(d)};return f(this,function(c){c.getFile("string"==typeof a?a:a.key,{create:!1},function(a){a.remove(function(){b&&d.lambda(b).call(d)},e)},e)}),this},nuke:function(a){var b=this,c=0;return this.keys(function(d){if(d.length)for(var e=0,f=d.length;f>e;e++)b.remove(d[e],function(){c++,c===f&&a&&b.lambda(a).call(b)});else a&&b.lambda(a).call(b)}),this}}}(this)),f.adapter("memory",function(){var a={};return{valid:function(){return!0},init:function(b,c){a[this.name]=a[this.name]||{index:[],store:{}},this.index=a[this.name].index,this.store=a[this.name].store;var d=this.fn(this.name,c);return d&&d.call(this,this),this},keys:function(a){return this.fn("keys",a).call(this,this.index),this},save:function(a,b){var c=a.key||this.uuid();return this.exists(c,function(d){d||(a.key&&delete a.key,this.index.push(c)),this.store[c]=a,b&&(a.key=c,this.lambda(b).call(this,a))}),this},batch:function(a,b){for(var c=[],d=0,e=a.length;e>d;d++)this.save(a[d],function(a){c.push(a)});return b&&this.lambda(b).call(this,c),this},get:function(a,b){var c;if(this.isArray(a)){c=[];for(var d=0,e=a.length;e>d;d++)c.push(this.store[a[d]])}else c=this.store[a],c&&(c.key=a);return b&&this.lambda(b).call(this,c),this},exists:function(a,b){return this.lambda(b).call(this,!!this.store[a]),this},all:function(a){for(var b=[],c=0,d=this.index.length;d>c;c++){var e=this.store[this.index[c]];e.key=this.index[c],b.push(e)}return this.fn(this.name,a).call(this,b),this},remove:function(a,b){for(var c=this.isArray(a)?a:[a],d=0,e=c.length;e>d;d++){var f=c[d].key?c[d].key:c[d],g=this.indexOf(this.index,f);0>g||(delete this.store[f],this.index.splice(g,1))}return b&&this.lambda(b).call(this),this},nuke:function(b){return this.store=a[this.name].store={},this.index=a[this.name].index=[],b&&this.lambda(b).call(this),this}}}()),f.adapter("titanium",function(){return{valid:function(){return"undefined"!=typeof Titanium},init:function(a,b){return b?this.fn("init",b).call(this):void 0},keys:function(a){return a?this.fn("keys",a).call(this,Titanium.App.Properties.listProperties()):this},save:function(a,b){var c=Titanium.App.Properties.setObject(a.key,a);return b?this.fn("save",b).call(this,c):this},batch:function(a,b){for(var c=this,d=[],e=0,f=a.length;f>e;e++)c.save(a[e],function(a){d.push(a),d.length===f&&b&&c.lambda(b).call(c,d)});return this},get:function(a,b){var c=this;if(!this.isArray(a))return this.fn("init",b).call(this,Titanium.App.Properties.getObject(a));for(var d=[],e=0,f=a.length;f>e;e++)c.get(a[e],function(a){a&&d.push(a),d.length===f&&b&&c.lambda(b).call(c,d)});return this},exists:function(a,b){return b?Titanium.App.Properties.getObject(a)?b(this,!0):b(this,!1):this},all:function(a){var b=this;return a&&this.keys(function(c){c.length?b.get(c,function(c){b.fn(b.name,a).call(b,c)}):b.fn(b.name,a).call(b,[])}),this},remove:function(a,b){return Titanium.App.Properties.removeProperty(a),b?this.fn("remove",b).call(this):this},nuke:function(){}}}(this)),e("undefined"!=typeof f?f:window.Lawnchair)}.call(c,void 0,void 0,void 0,void 0,function(a){b.exports=a})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(_dereq_,module,exports){(function(global){__browserify_shim_require__=_dereq_,function browserifyShim(module,exports,_dereq_,define,browserify_shim__define__module__export__){var JSON;JSON||(JSON={}),function(){"use strict";function f(a){return 10>a?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g,h=gap,i=b[a];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(a)),"function"==typeof rep&&(i=rep.call(b,a,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";if(gap+=indent,g=[],"[object Array]"===Object.prototype.toString.apply(i)){for(f=i.length,c=0;f>c;c+=1)g[c]=str(c,i)||"null";return e=0===g.length?"[]":gap?"[\n"+gap+g.join(",\n"+gap)+"\n"+h+"]":"["+g.join(",")+"]",gap=h,e}if(rep&&"object"==typeof rep)for(f=rep.length,c=0;f>c;c+=1)"string"==typeof rep[c]&&(d=rep[c],e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));return e=0===g.length?"{}":gap?"{\n"+gap+g.join(",\n"+gap)+"\n"+h+"}":"{"+g.join(",")+"}",gap=h,e}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;"function"!=typeof JSON.stringify&&(JSON.stringify=function(a,b,c){var d;if(gap="",indent="","number"==typeof c)for(d=0;c>d;d+=1)indent+=" ";else"string"==typeof c&&(indent=c);if(rep=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return str("",{"":a})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&"object"==typeof e)for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),void 0!==d?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),browserify_shim__define__module__export__("undefined"!=typeof JSON?JSON:window.JSON)}.call(global,void 0,void 0,void 0,void 0,function(a){module.exports=a})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(a,b){function c(a,b,c){null!=a&&("number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))}function d(){return new c(null)}function e(a,b,c,d,e,f){for(;--f>=0;){var g=b*this[a++]+c[d]+e;e=Math.floor(g/67108864),c[d++]=67108863&g}return e}function f(a,b,c,d,e,f){for(var g=32767&b,h=b>>15;--f>=0;){var i=32767&this[a],j=this[a++]>>15,k=h*i+j*g;i=g*i+((32767&k)<<15)+c[d]+(1073741823&e),e=(i>>>30)+(k>>>15)+h*j+(e>>>30),c[d++]=1073741823&i}return e}function g(a,b,c,d,e,f){for(var g=16383&b,h=b>>14;--f>=0;){var i=16383&this[a],j=this[a++]>>14,k=h*i+j*g;i=g*i+((16383&k)<<14)+c[d]+e,e=(i>>28)+(k>>14)+h*j,c[d++]=268435455&i}return e}function h(a){return nb.charAt(a)}function i(a,b){var c=ob[a.charCodeAt(b)];return null==c?-1:c}function j(a){for(var b=this.t-1;b>=0;--b)a[b]=this[b];a.t=this.t,a.s=this.s}function k(a){this.t=1,this.s=0>a?-1:0,a>0?this[0]=a:-1>a?this[0]=a+DV:this.t=0}function l(a){var b=d();return b.fromInt(a),b}function m(a,b){var d;if(16==b)d=4;else if(8==b)d=3;else if(256==b)d=8;else if(2==b)d=1;else if(32==b)d=5;else{if(4!=b)return void this.fromRadix(a,b);d=2}this.t=0,this.s=0;for(var e=a.length,f=!1,g=0;--e>=0;){var h=8==d?255&a[e]:i(a,e);0>h?"-"==a.charAt(e)&&(f=!0):(f=!1,0==g?this[this.t++]=h:g+d>this.DB?(this[this.t-1]|=(h&(1<>this.DB-g):this[this.t-1]|=h<=this.DB&&(g-=this.DB))}8==d&&0!=(128&a[0])&&(this.s=-1,g>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==a;)--this.t}function o(a){if(this.s<0)return"-"+this.negate().toString(a);var b;if(16==a)b=4;else if(8==a)b=3;else if(2==a)b=1;else if(32==a)b=5;else{if(4!=a)return this.toRadix(a);b=2}var c,d=(1<0)for(i>i)>0&&(e=!0,f=h(c));g>=0;)b>i?(c=(this[g]&(1<>(i+=this.DB-b)):(c=this[g]>>(i-=b)&d,0>=i&&(i+=this.DB,--g)),c>0&&(e=!0),e&&(f+=h(c));return e?f:"0"}function p(){var a=d();return c.ZERO.subTo(this,a),a}function q(){return this.s<0?this.negate():this}function r(a){var b=this.s-a.s;if(0!=b)return b;var c=this.t;if(b=c-a.t,0!=b)return this.s<0?-b:b;for(;--c>=0;)if(0!=(b=this[c]-a[c]))return b;return 0}function s(a){var b,c=1;return 0!=(b=a>>>16)&&(a=b,c+=16),0!=(b=a>>8)&&(a=b,c+=8),0!=(b=a>>4)&&(a=b,c+=4),0!=(b=a>>2)&&(a=b,c+=2),0!=(b=a>>1)&&(a=b,c+=1),c}function t(){return this.t<=0?0:this.DB*(this.t-1)+s(this[this.t-1]^this.s&this.DM)}function u(a,b){var c;for(c=this.t-1;c>=0;--c)b[c+a]=this[c];for(c=a-1;c>=0;--c)b[c]=0;b.t=this.t+a,b.s=this.s}function v(a,b){for(var c=a;c=0;--c)b[c+g+1]=this[c]>>e|h,h=(this[c]&f)<=0;--c)b[c]=0;b[g]=h,b.t=this.t+g+1,b.s=this.s,b.clamp()}function x(a,b){b.s=this.s;var c=Math.floor(a/this.DB);if(c>=this.t)return void(b.t=0);var d=a%this.DB,e=this.DB-d,f=(1<>d;for(var g=c+1;g>d;d>0&&(b[this.t-c-1]|=(this.s&f)<c;)d+=this[c]-a[c],b[c++]=d&this.DM,d>>=this.DB;if(a.t>=this.DB;d+=this.s}else{for(d+=this.s;c>=this.DB;d-=a.s}b.s=0>d?-1:0,-1>d?b[c++]=this.DV+d:d>0&&(b[c++]=d),b.t=c,b.clamp()}function z(a,b){var d=this.abs(),e=a.abs(),f=d.t;for(b.t=f+e.t;--f>=0;)b[f]=0;for(f=0;f=0;)a[c]=0;for(c=0;c=b.DV&&(a[c+b.t]-=b.DV,a[c+b.t+1]=1)}a.t>0&&(a[a.t-1]+=b.am(c,b[c],a,2*c,0,1)),a.s=0,a.clamp()}function B(a,b,e){var f=a.abs();if(!(f.t<=0)){var g=this.abs();if(g.t0?(f.lShiftTo(k,h),g.lShiftTo(k,e)):(f.copyTo(h),g.copyTo(e));var l=h.t,m=h[l-1];if(0!=m){var n=m*(1<1?h[l-2]>>this.F2:0),o=this.FV/n,p=(1<=0&&(e[e.t++]=1,e.subTo(u,e)),c.ONE.dlShiftTo(l,u),u.subTo(h,h);h.t=0;){var v=e[--r]==m?this.DM:Math.floor(e[r]*o+(e[r-1]+q)*p);if((e[r]+=h.am(0,v,e,t,0,l))0&&e.rShiftTo(k,e),0>i&&c.ZERO.subTo(e,e)}}}function C(a){var b=d();return this.abs().divRemTo(a,null,b),this.s<0&&b.compareTo(c.ZERO)>0&&a.subTo(b,b),b}function D(a){this.m=a}function E(a){return a.s<0||a.compareTo(this.m)>=0?a.mod(this.m):a}function F(a){return a}function G(a){a.divRemTo(this.m,null,a)}function H(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function I(a,b){a.squareTo(b),this.reduce(b)}function J(){if(this.t<1)return 0;var a=this[0];if(0==(1&a))return 0;var b=3&a;return b=b*(2-(15&a)*b)&15,b=b*(2-(255&a)*b)&255,b=b*(2-((65535&a)*b&65535))&65535,b=b*(2-a*b%this.DV)%this.DV,b>0?this.DV-b:-b}function K(a){this.m=a,this.mp=a.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(b,b),b}function M(a){var b=d();return a.copyTo(b),this.reduce(b),b}function N(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var b=0;b>15)*this.mpl&this.um)<<15)&a.DM;for(c=b+this.m.t,a[c]+=this.m.am(0,d,a,b,0,this.m.t);a[c]>=a.DV;)a[c]-=a.DV,a[++c]++}a.clamp(),a.drShiftTo(this.m.t,a),a.compareTo(this.m)>=0&&a.subTo(this.m,a)}function O(a,b){a.squareTo(b),this.reduce(b)}function P(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function Q(){return 0==(this.t>0?1&this[0]:this.s)}function R(a,b){if(a>4294967295||1>a)return c.ONE;var e=d(),f=d(),g=b.convert(this),h=s(a)-1;for(g.copyTo(e);--h>=0;)if(b.sqrTo(e,f),(a&1<0)b.mulTo(f,g,e);else{var i=e;e=f,f=i}return b.revert(e)}function S(a,b){var c;return c=256>a||b.isEven()?new D(b):new K(b),this.exp(a,c)}function T(){this.i=0,this.j=0,this.S=new Array}function U(a){var b,c,d;for(b=0;256>b;++b)this.S[b]=b;for(c=0,b=0;256>b;++b)c=c+this.S[b]+a[b%a.length]&255,d=this.S[b],this.S[b]=this.S[c],this.S[c]=d;this.i=0,this.j=0}function V(){var a;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,a=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=a,this.S[a+this.S[this.i]&255]}function W(){return new T}function X(a){qb[rb++]^=255&a,qb[rb++]^=a>>8&255,qb[rb++]^=a>>16&255,qb[rb++]^=a>>24&255,rb>=sb&&(rb-=sb)}function Y(){X((new Date).getTime())}function Z(){if(null==pb){for(Y(),pb=W(),pb.init(qb),rb=0;rba?"0"+a.toString(16):a.toString(16)}function cb(a,b){if(b=0&&b>0;){var f=a.charCodeAt(e--);128>f?d[--b]=f:f>127&&2048>f?(d[--b]=63&f|128,d[--b]=f>>6|192):(d[--b]=63&f|128,d[--b]=f>>6&63|128,d[--b]=f>>12|224)}d[--b]=0;for(var g=new _,h=new Array;b>2;){for(h[0]=0;0==h[0];)g.nextBytes(h);d[--b]=h[0]}return d[--b]=2,d[--b]=0,new c(d)}function db(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function eb(a,b){null!=a&&null!=b&&a.length>0&&b.length>0?(this.n=ab(a,16),this.e=parseInt(b,16)):alert("Invalid RSA public key")}function fb(a){return a.modPowInt(this.e,this.n)}function gb(a){var b=cb(a,this.n.bitLength()+7>>3);if(null==b)return null;var c=this.doPublic(b);if(null==c)return null;var d=c.toString(16);return 0==(1&d.length)?d:"0"+d}var hb,ib=0xdeadbeefcafe,jb=15715070==(16777215&ib);jb&&"Microsoft Internet Explorer"==navigator.appName?(c.prototype.am=f,hb=30):jb&&"Netscape"!=navigator.appName?(c.prototype.am=e,hb=26):(c.prototype.am=g,hb=28),c.prototype.DB=hb,c.prototype.DM=(1<=mb;++mb)ob[lb++]=mb;for(lb="a".charCodeAt(0),mb=10;36>mb;++mb)ob[lb++]=mb;for(lb="A".charCodeAt(0),mb=10;36>mb;++mb)ob[lb++]=mb;D.prototype.convert=E,D.prototype.revert=F,D.prototype.reduce=G,D.prototype.mulTo=H,D.prototype.sqrTo=I,K.prototype.convert=L,K.prototype.revert=M,K.prototype.reduce=N,K.prototype.mulTo=P,K.prototype.sqrTo=O,c.prototype.copyTo=j,c.prototype.fromInt=k,c.prototype.fromString=m,c.prototype.clamp=n,c.prototype.dlShiftTo=u,c.prototype.drShiftTo=v,c.prototype.lShiftTo=w,c.prototype.rShiftTo=x,c.prototype.subTo=y,c.prototype.multiplyTo=z,c.prototype.squareTo=A,c.prototype.divRemTo=B,c.prototype.invDigit=J,c.prototype.isEven=Q,c.prototype.exp=R,c.prototype.toString=o,c.prototype.negate=p,c.prototype.abs=q,c.prototype.compareTo=r,c.prototype.bitLength=t,c.prototype.mod=C,c.prototype.modPowInt=S,c.ZERO=l(0),c.ONE=l(1),T.prototype.init=U,T.prototype.next=V;var pb,qb,rb,sb=256;if(null==qb){qb=new Array,rb=0;var tb;if("Netscape"==navigator.appName&&navigator.appVersion<"5"&&window.crypto){var ub=window.crypto.random(32);for(tb=0;tbrb;)tb=Math.floor(65536*Math.random()),qb[rb++]=tb>>>8,qb[rb++]=255&tb;rb=0,Y()}_.prototype.nextBytes=$,db.prototype.doPublic=fb,db.prototype.setPublic=eb,db.prototype.encrypt=gb,b.exports={SecureRandom:_,byte2Hex:bb,RSAKey:db}},{}],5:[function(a,b){function c(a,b){return m.isUndefined(b)?""+b:!m.isNumber(b)||!isNaN(b)&&isFinite(b)?m.isFunction(b)||m.isRegExp(b)?b.toString():b:b.toString()}function d(a,b){return m.isString(a)?a.length=0;d--)if(e[d]!=f[d])return!1;for(d=e.length-1;d>=0;d--)if(c=e[d],!h(a[c],b[c]))return!1;return!0}function k(a,b){return a&&b?"[object RegExp]"==Object.prototype.toString.call(b)?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function l(a,b,c,d){var e;m.isString(c)&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f(e,c,"Missing expected exception"+d),!a&&k(e,c)&&f(e,c,"Got unwanted exception"+d),a&&e&&c&&!k(e,c)||!a&&e)throw e}var m=a("util/"),n=Array.prototype.slice,o=Object.prototype.hasOwnProperty,p=b.exports=g;p.AssertionError=function(a){this.name="AssertionError",this.actual=a.actual,this.expected=a.expected,this.operator=a.operator,a.message?(this.message=a.message,this.generatedMessage=!1):(this.message=e(this),this.generatedMessage=!0);var b=a.stackStartFunction||f;if(Error.captureStackTrace)Error.captureStackTrace(this,b);else{var c=new Error;if(c.stack){var d=c.stack,g=b.name,h=d.indexOf("\n"+g);if(h>=0){var i=d.indexOf("\n",h+1);d=d.substring(i+1)}this.stack=d}}},m.inherits(p.AssertionError,Error),p.fail=f,p.ok=g,p.equal=function(a,b,c){a!=b&&f(a,b,c,"==",p.equal)},p.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",p.notEqual)},p.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",p.deepEqual)},p.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",p.notDeepEqual)},p.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",p.strictEqual)},p.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",p.notStrictEqual)},p.throws=function(){l.apply(this,[!0].concat(n.call(arguments)))},p.doesNotThrow=function(){l.apply(this,[!1].concat(n.call(arguments)))},p.ifError=function(a){if(a)throw a};var q=Object.keys||function(a){var b=[];for(var c in a)o.call(a,c)&&b.push(c);return b}},{"util/":7}],6:[function(a,b){b.exports=function(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.readUInt8}},{}],7:[function(a,b,c){(function(b,d){function e(a,b){var d={seen:[],stylize:g};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),p(b)?d.showHidden=b:b&&c._extend(d,b),v(d.showHidden)&&(d.showHidden=!1),v(d.depth)&&(d.depth=2),v(d.colors)&&(d.colors=!1),v(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=f),i(d,a,d.depth)}function f(a,b){var c=e.styles[b];return c?"["+e.colors[c][0]+"m"+a+"["+e.colors[c][1]+"m":a}function g(a){return a}function h(a){var b={};return a.forEach(function(a){b[a]=!0}),b}function i(a,b,d){if(a.customInspect&&b&&A(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d,a);return t(e)||(e=i(a,e,d)),e}var f=j(a,b);if(f)return f;var g=Object.keys(b),p=h(g);if(a.showHidden&&(g=Object.getOwnPropertyNames(b)),z(b)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return k(b);if(0===g.length){if(A(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(w(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(y(b))return a.stylize(Date.prototype.toString.call(b),"date");if(z(b))return k(b)}var r="",s=!1,u=["{","}"];if(o(b)&&(s=!0,u=["[","]"]),A(b)){var v=b.name?": "+b.name:"";r=" [Function"+v+"]"}if(w(b)&&(r=" "+RegExp.prototype.toString.call(b)),y(b)&&(r=" "+Date.prototype.toUTCString.call(b)),z(b)&&(r=" "+k(b)),0===g.length&&(!s||0==b.length))return u[0]+r+u[1];if(0>d)return w(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var x;return x=s?l(a,b,d,p,g):g.map(function(c){return m(a,b,d,p,c,s)}),a.seen.pop(),n(x,r,u)}function j(a,b){if(v(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return s(b)?a.stylize(""+b,"number"):p(b)?a.stylize(""+b,"boolean"):q(b)?a.stylize("null","null"):void 0}function k(a){return"["+Error.prototype.toString.call(a)+"]"}function l(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)f.push(F(b,String(g))?m(a,b,c,d,String(g),!0):"");return e.forEach(function(e){e.match(/^\d+$/)||f.push(m(a,b,c,d,e,!0))}),f}function m(a,b,c,d,e,f){var g,h,j;if(j=Object.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?h=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(h=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),h||(a.seen.indexOf(j.value)<0?(h=q(c)?i(a,j.value,null):i(a,j.value,c-1),h.indexOf("\n")>-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),v(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function n(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function o(a){return Array.isArray(a)}function p(a){return"boolean"==typeof a}function q(a){return null===a}function r(a){return null==a}function s(a){return"number"==typeof a}function t(a){return"string"==typeof a}function u(a){return"symbol"==typeof a}function v(a){return void 0===a}function w(a){return x(a)&&"[object RegExp]"===C(a)}function x(a){return"object"==typeof a&&null!==a}function y(a){return x(a)&&"[object Date]"===C(a)}function z(a){return x(a)&&("[object Error]"===C(a)||a instanceof Error)}function A(a){return"function"==typeof a}function B(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),J[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=/%[sdj%]/g;c.format=function(a){if(!t(a)){for(var b=[],c=0;c=f)return a;switch(a){case"%s":return String(d[c++]);case"%d":return Number(d[c++]);case"%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),h=d[c];f>c;h=d[++c])g+=q(h)||!x(h)?" "+h:" "+e(h);return g},c.deprecate=function(a,e){function f(){if(!g){if(b.throwDeprecation)throw new Error(e);b.traceDeprecation?console.trace(e):console.error(e),g=!0}return a.apply(this,arguments)}if(v(d.process))return function(){return c.deprecate(a,e).apply(this,arguments)};if(b.noDeprecation===!0)return a;var g=!1;return f};var H,I={};c.debuglog=function(a){if(v(H)&&(H=b.env.NODE_DEBUG||""),a=a.toUpperCase(),!I[a])if(new RegExp("\\b"+a+"\\b","i").test(H)){var d=b.pid;I[a]=function(){var b=c.format.apply(c,arguments);console.error("%s %d: %s",a,d,b)}}else I[a]=function(){};return I[a]},c.inspect=e,e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=o,c.isBoolean=p,c.isNull=q,c.isNullOrUndefined=r,c.isNumber=s,c.isString=t,c.isSymbol=u,c.isUndefined=v,c.isRegExp=w,c.isObject=x,c.isDate=y,c.isError=z,c.isFunction=A,c.isPrimitive=B,c.isBuffer=a("./support/isBuffer");var J=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=a("inherits"),c._extend=function(a,b){if(!b||!x(b))return a;for(var c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}}).call(this,a("/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":6,"/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,inherits:10}],8:[function(a,b){(function(c){function d(){}function e(){m.log.apply(m,arguments)}function f(){m.log.apply(m,arguments)}function g(){m.warn.apply(m,arguments)}function h(a){p[a]=Date.now()}function i(a){var b=p[a];if(!b)throw new Error("No such label: "+a);var c=Date.now()-b;m.log(a+": "+c+"ms")}function j(){var a=new Error;a.name="Trace",a.message=n.format.apply(null,arguments),m.error(a.stack)}function k(a){m.log(n.inspect(a)+"\n")}function l(a){if(!a){var b=o.call(arguments,1);l.ok(!1,n.format.apply(null,b))}}var m,n=a("util"),l=a("assert"),o=Array.prototype.slice,p={};m="undefined"!=typeof c&&c.console?c.console:"undefined"!=typeof window&&window.console?window.console:{};for(var q=[[d,"log"],[e,"info"],[f,"warn"],[g,"error"],[h,"time"],[i,"timeEnd"],[j,"trace"],[k,"dir"],[l,"assert"]],r=0;ra||isNaN(a))throw TypeError("n must be a positive number"); -return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,h,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||f(this._events.error)&&!this._events.error.length))throw b=arguments[1],b instanceof Error?b:TypeError('Uncaught, unspecified "error" event.');if(c=this._events[a],g(c))return!1;if(d(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];c.apply(this,h)}else if(f(c)){for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];for(j=c.slice(),e=j.length,i=0;e>i;i++)j[i].apply(this,h)}return!0},c.prototype.addListener=function(a,b){var e;if(!d(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d(b.listener)?b.listener:b),this._events[a]?f(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,f(this._events[a])&&!this._events[a].warned){var e;e=g(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),e||(e=!0,b.apply(this,arguments))}if(!d(b))throw TypeError("listener must be a function");var e=!1;return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,g,h;if(!d(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],g=c.length,e=-1,c===b||d(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(f(c)){for(h=g;h-->0;)if(c[h]===b||c[h].listener&&c[h].listener===b){e=h;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d(a._events[b])?1:a._events[b].length:0}},{}],10:[function(a,b){b.exports="function"==typeof Object.create?function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],11:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],12:[function(a,b){b.exports=a(6)},{}],13:[function(a,b){b.exports=a(7)},{"./support/isBuffer":12,"/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,inherits:10}],14:[function(a,b){!function(a){var c="undefined";!function(a,c){"undefined"!=typeof b?b.exports=c():"function"==typeof define&&"object"==typeof define.amd?define(c):this[a]=c()}("log",function(){function b(b){return typeof console===c?l:console[b]===a?console.log!==a?d(console,"log"):l:d(console,b)}function d(b,c){var d=b[c];if(d.bind!==a)return b[c].bind(b);if(Function.prototype.bind===a)return e(d,b);try{return Function.prototype.bind.call(b[c],b)}catch(f){return e(d,b)}}function e(a,b){return function(){Function.prototype.apply.apply(a,[b,arguments])}}function f(a){for(var b=0;b=0&&d<=k.levels.SILENT){if(i(d),d===k.levels.SILENT)return void f(function(){return l});if(typeof console===c)return f(function(a){return function(){typeof console!==c&&(k.setLevel(d),k[a].apply(k,arguments))}}),"No console available for logging";f(function(a){return d<=k.levels[a.toUpperCase()]?b(a):l})}else{if("string"!=typeof d||k.levels[d.toUpperCase()]===a)throw"log.setLevel() called with invalid level: "+d;k.setLevel(k.levels[d.toUpperCase()])}},k.enableAll=function(){k.setLevel(k.levels.TRACE)},k.disableAll=function(){k.setLevel(k.levels.SILENT)},j(),k})}()},{}],15:[function(a,b){var c=Object.prototype.toString;b.exports=function(a){switch(c.call(a)){case"[object Function]":return"function";case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object String]":return"string"}if("object"==typeof a&&a&&"number"==typeof a.length)try{if("function"==typeof a.callee)return"arguments"}catch(b){if(b instanceof TypeError)return"arguments"}return null===a?"null":void 0===a?"undefined":a&&1===a.nodeType?"element":a===Object(a)?"object":typeof a}},{}],16:[function(a,b){var c=a("./modules/constants"),d=a("./modules/logger"),e=a("./modules/ajax"),f=a("./modules/events"),g=a("./modules/waitForCloud"),h=a("./modules/api_act"),i=a("./modules/api_auth"),j=a("./modules/api_sec"),k=a("./modules/api_hash"),l=a("./modules/sync-cli"),m=a("./modules/api_mbaas"),n=a("./modules/api_cloud"),o=a("./modules/fhparams"),p=a("./modules/appProps"),q=a("./modules/device"),r=function(a,b){f.addListener(a,b),a===c.INIT_EVENT&&(g.isReady()?b(null,{host:g.getCloudHostUrl()}):g.getInitError()&&b(g.getInitError()))},s=function(a,b){a===c.INIT_EVENT&&g.isReady()?b(null,{host:g.getCloudHostUrl()}):a===c.INIT_EVENT&&g.getInitError()?b(g.getInitError()):f.once(a,b)},t=function(a,b,c){d.warn("$fh.init will be deprecated soon"),g.ready(function(a,d){if(a){if("function"==typeof c)return c(a)}else"function"==typeof b&&b(d.host)})},u=window.$fh||{};u.init=t,u.act=h,u.auth=i,u.cloud=n,u.sec=j,u.hash=k,u.sync=l,u.ajax=u.__ajax=e,u.mbaas=m,u._getDeviceId=q.getDeviceId,u.fh_timeout=6e4,u.getCloudURL=function(){return g.getCloudHostUrl()},u.getFHParams=function(){return o.buildFHParams()},u.addListener=r,u.on=r,u.once=s;for(var v=["removeListener","removeAllListeners","setMaxListeners","listeners","emit"],w=0;w=0&&(a=!0),a}function m(a){var b=null;return window.XMLHttpRequest&&(b=new XMLHttpRequest),l()&&a===!0&&"undefined"!=typeof window.XDomainRequest&&(b=new v(new XDomainRequest)),"undefined"!=typeof Titanium&&(b=Titanium.Network.createHTTPClient({timeout:I.settings.timeout})),b}function n(a){return a&&(a==G?"html":a==F?"json":D.test(a)?"script":E.test(a)&&"xml")||"text"}function o(a,b){return(a+"&"+b).replace(/[&?]{1,2}/,"?")}function p(a){"object"===t(a.data)&&("function"==typeof a.data.append?a.formdata=!0:a.data=r(a.data)),!a.data||a.type&&"GET"!=a.type.toUpperCase()||(a.url=o(a.url,a.data))}function q(a,b,c,d){var e="array"===t(b);for(var f in b){var g=b[f];d&&(f=c?d:d+"["+(e?"":f)+"]"),!d&&e?a.add(g.name,g.value):(c?"array"===t(g):"object"===t(g))?q(a,g,c,f):a.add(f,g)}}function r(a,b){var c=[];return c.add=function(a,b){this.push(J(a)+"="+J(b))},q(c,a,b),c.join("&").replace("%20","+")}function s(a){var b=Array.prototype.slice;return b.call(arguments,1).forEach(function(b){for(z in b)void 0!==b[z]&&(a[z]=b[z])}),a}var t,u=a("./events"),v=a("./XDomainRequestWrapper"),w=a("./logger");try{t=a("type-of")}catch(x){var y=a;t=y("type")}var z,A,B=0,C=window.document,D=/^(?:text|application)\/javascript/i,E=/^(?:text|application)\/xml/i,F="application/json",G="text/html",H=/^\s*$/,I=b.exports=function(a){var b=s({},a||{});window&&window.$fh&&"number"==typeof window.$fh.fh_timeout&&(I.settings.timeout=window.$fh.fh_timeout);for(z in I.settings)void 0===b[z]&&(b[z]=I.settings[z]);e(b),b.crossDomain||(b.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(b.url)&&(RegExp.$1!=window.location.protocol||RegExp.$2!=window.location.host));var c=b.dataType,d=/=\?/.test(b.url);if("jsonp"==c||d)return d||(b.url=o(b.url,(b.jsonp?b.jsonp:"_callback")+"=?")),I.JSONP(b);b.url||(b.url=window.location.toString()),p(b);var f,j=b.accepts[c],l={},m=/^([\w-]+:)\/\//.test(b.url)?RegExp.$1:window.location.protocol,q=b.xhr(b.crossDomain);b.crossDomain||(l["X-Requested-With"]="XMLHttpRequest"),j&&(l.Accept=j,j.indexOf(",")>-1&&(j=j.split(",",2)[0]),q.overrideMimeType&&q.overrideMimeType(j)),(b.contentType||b.data&&!b.formdata&&"GET"!=b.type.toUpperCase())&&(l["Content-Type"]=b.contentType||"application/x-www-form-urlencoded"),b.headers=s(l,b.headers||{}),"undefined"!=typeof Titanium&&q.setOnerror(function(){f&&(clearTimeout(f),i(null,"error",q,b))}),q.onreadystatechange=function(){if(4==q.readyState){clearTimeout(f),f=void 0;var a,d=!1;if(b.tryJSONP&&0===q.status&&b.crossDomain&&!q.isTimeout&&"file:"!=m)return w.debug("retry ajax call with jsonp"),b.type="GET",b.dataType="jsonp",b.data="_jsonpdata="+b.data,I(b);if(q.status>=200&&q.status<300||304==q.status||0==q.status&&"file:"==m){c=c||n(q.getResponseHeader("content-type")),a=q.responseText,w.debug("ajax response :: status = "+q.status+" :: body = "+a);try{"script"==c?(1,eval)(a):"xml"==c?a=q.responseXML:"json"==c&&(a=H.test(a)?null:JSON.parse(a))}catch(e){d=e}d?(w.debug("ajax error",d),i(d,"parsererror",q,b)):h(a,q,b)}else i(null,"error",q,b)}};var r="async"in b?b.async:!0;w.debug("ajax call settings",b),q.open(b.type,b.url,r);for(A in b.headers)q.setRequestHeader(A,b.headers[A]);return g(q,b)===!1?(w.debug("ajax call is aborted due to ajaxBeforeSend"),q.abort(),!1):(b.timeout>0&&(f=setTimeout(function(){w.debug("ajax call timed out"),q.onreadystatechange=k,q.abort(),q.isTimeout=!0,i(null,"timeout",q,b)},b.timeout)),q.send(b.data?b.data:null),q)};I.active=0,I.JSONP=function(a){if(!("type"in a))return I(a);var b,c="jsonp"+ ++B,d=C.createElement("script"),e=function(){c in window&&(window[c]=k),j("abort",f,a)},f={abort:e},g=C.getElementsByTagName("head")[0]||C.documentElement;return a.error&&(d.onerror=function(){f.abort(),a.error()}),window[c]=function(d){clearTimeout(b),b=void 0,delete window[c],h(d,f,a)},p(a),d.src=a.url.replace(/=\?/,"="+c),g.insertBefore(d,g.firstChild),a.timeout>0&&(b=setTimeout(function(){f.abort(),j("timeout",f,a)},a.timeout)),f},I.settings={type:"GET",beforeSend:k,success:k,error:k,complete:k,context:null,global:!0,xhr:m,accepts:{script:"text/javascript, application/javascript",json:F,xml:"application/xml, text/xml",html:G,text:"text/plain"},crossDomain:!1},I.get=function(a,b){return I({url:a,success:b})},I.post=function(a,b,c,d){return"function"===t(b)&&(d=d||c,c=b,b=null),I({type:"POST",url:a,data:b,success:c,dataType:d})},I.getJSON=function(a,b){return I({url:a,success:b,dataType:"json"})};var J=encodeURIComponent},{"./XDomainRequestWrapper":17,"./events":28,"./logger":35,"type-of":15}],19:[function(a,b){function c(a,b,c){var d=e.getCloudHost(),k=d.getActUrl(a.act),l=a.req||{};return l=f.addFHParams(l),g({url:k,tryJSONP:!0,type:"POST",dataType:"json",data:h.stringify(l),contentType:"application/json",timeout:a.timeout||j.timeout,success:b,error:function(a,b,d){return i(c,a,b,d)}})}var d=a("./logger"),e=a("./waitForCloud"),f=a("./fhparams"),g=a("./ajax"),h=a("JSON"),i=a("./handleError"),j=a("./appProps");b.exports=function(a,b,f){return d.debug("act is called"),f||(f=function(a,b){d.debug(a+":"+h.stringify(b))}),a.act?void e.ready(function(e){return d.debug("Calling fhact now"),e?f(e.message,e):void c(a,b,f)}):f("act_no_action",{})}},{"./ajax":18,"./appProps":"zDENqi","./fhparams":29,"./handleError":30,"./logger":35,"./waitForCloud":49,JSON:3}],20:[function(a,b){var c=a("./logger"),d=a("./waitForCloud"),e=a("./fhparams"),f=a("./ajax"),g=a("JSON"),h=a("./handleError"),i=a("./device"),j=a("./constants"),k=a("./checkAuth"),l=a("./appProps");b.exports=function(a,b,m){return m||(m=function(a,b){c.debug(a+":"+g.stringify(b))}),a.policyId?a.clientToken?void d.ready(function(c){if(c)return m(c.message,c);var d={};d.policyId=a.policyId,d.clientToken=a.clientToken,a.endRedirectUrl&&(d.endRedirectUrl=a.endRedirectUrl,a.authCallback&&(d.endRedirectUrl+=(/\?/.test(d.endRedirectUrl)?"&":"?")+"_fhAuthCallback="+a.authCallback)),d.params={},a.params&&(d.params=a.params);var n=a.endRedirectUrl||"status=complete";d.device=i.getDeviceId();var o=l.getAppProps(),p=o.host+j.boxprefix+"admin/authpolicy/auth";d=e.addFHParams(d),f({url:p,type:"POST",tryJSONP:!0,data:g.stringify(d),dataType:"json",contentType:"application/json",timeout:a.timeout||o.timeout,success:function(a){k.handleAuthResponse(n,a,b,m)},error:function(a,b,c){h(m,a,b,c)}})}):m("auth_no_clientToken",{}):m("auth_no_policyId",{})}},{"./ajax":18,"./appProps":"zDENqi","./checkAuth":25,"./constants":26,"./device":27,"./fhparams":29,"./handleError":30,"./logger":35,"./waitForCloud":49,JSON:3}],21:[function(a,b){function c(a,b,c){var d=e.getCloudHost(),k=d.getCloudUrl(a.path),l=a.data||{};return l=f.addFHParams(l),g({url:k,type:a.method||"POST",dataType:a.dataType||"json",data:h.stringify(l),contentType:a.contentType||"application/json",timeout:a.timeout||j.timeout,success:b,error:function(a,b,d){return i(c,a,b,d)}})}var d=a("./logger"),e=a("./waitForCloud"),f=a("./fhparams"),g=a("./ajax"),h=a("JSON"),i=a("./handleError"),j=a("./appProps");b.exports=function(a,b,f){d.debug("cloud is called"),f||(f=function(a,b){d.debug(a+":"+h.stringify(b))}),e.ready(function(e){return d.debug("Calling fhact now"),e?f(e.message,e):void c(a,b,f)})}},{"./ajax":18,"./appProps":"zDENqi","./fhparams":29,"./handleError":30,"./logger":35,"./waitForCloud":49,JSON:3}],22:[function(a,b){var c=a("./security/hash");b.exports=function(a,b,d){var e={};"undefined"==typeof a.algorithm&&(a.algorithm="MD5"),e.act="hash",e.params=a,c(e,b,d)}},{"./security/hash":41}],23:[function(a,b){var c=a("./logger"),d=a("./waitForCloud"),e=a("./fhparams"),f=a("./ajax"),g=a("JSON"),h=a("./handleError"),i=(a("./constants"),a("./appProps"));b.exports=function(a,b,j){c.debug("mbaas is called."),j||(j=function(a,b){console.debug(a+":"+g.stringify(b))});var k=a.service,l=a.params;d.ready(function(m){if(c.debug("Calling mbaas now"),m)return j(m.message,m);var n=d.getCloudHost(),o=n.getMBAASUrl(k);return l=e.addFHParams(l),f({url:o,tryJSONP:!0,type:"POST",dataType:"json",data:g.stringify(l),contentType:"application/json",timeout:a.timeout||i.timeout,success:b,error:function(a,b,c){return h(j,a,b,c)}})})}},{"./ajax":18,"./appProps":"zDENqi","./constants":26,"./fhparams":29,"./handleError":30,"./logger":35,"./waitForCloud":49,JSON:3}],24:[function(a,b){var c=a("./security/aes-keygen"),d=a("./security/aes-node"),e=a("./security/rsa-node"),f=a("./security/hash");b.exports=function(a,b,g){return a.act?a.params?a.params.algorithm?(a.params.algorithm=a.params.algorithm.toLowerCase(),"hash"===a.act?f(a,b,g):"encrypt"===a.act?"aes"===a.params.algorithm?d.encrypt(a,b,g):"rsa"===a.params.algorithm?e.encrypt(a,b,g):g("encrypt_bad_algorithm:"+a.params.algorithm,{},a):"decrypt"===a.act?"aes"===a.params.algorithm?d.decrypt(a,b,g):g("decrypt_bad_algorithm:"+a.params.algorithm,{},a):"keygen"===a.act?"aes"===a.params.algorithm?c(a,b,g):g("keygen_bad_algorithm:"+a.params.algorithm,{},a):void 0):void g("no_params_algorithm",{},a):void g("no_params",{},a):void g("bad_act",{},a)}},{"./security/aes-keygen":39,"./security/aes-node":40,"./security/hash":41,"./security/rsa-node":42}],25:[function(a,b){var c=a("./logger"),d=a("./queryMap"),e=a("JSON"),f=a("./fhparams"),g=function(a){if(/\_fhAuthCallback/.test(a)){var b=d(a);if(b){var c=b._fhAuthCallback;if(c)if(b.result&&"success"===b.result){var g={sessionToken:b.fh_auth_session,authResponse:e.parse(decodeURIComponent(decodeURIComponent(b.authResponse)))};f.setAuthSessionToken(b.fh_auth_session),window[c](null,g)}else window[c]({message:b.message})}}},h=function(a,b,g,h){if(b.status&&"ok"===b.status){var i=function(a){a.sessionToken&&f.setAuthSessionToken(a.sessionToken),g(a)};if(b.url){var j=null,k=function(b){if(b.indexOf(a)>-1){j&&j.close();var c=d(b);if(c)if(c.result&&"success"===c.result){var f={sessionToken:c.fh_auth_session,authResponse:e.parse(decodeURIComponent(decodeURIComponent(c.authResponse)))};i(f)}else h&&h("auth_failed",{message:c.message});else h&&h("auth_failed",{message:c.message})}};if(window.PhoneGap||window.cordova)if(window.plugins&&window.plugins.childBrowser)"function"==typeof window.plugins.childBrowser.showWebPage&&(window.plugins.childBrowser.onLocationChange=k,window.plugins.childBrowser.showWebPage(b.url),j=window.plugins.childBrowser);else try{j=window.open(b.url,"_blank","location=yes"),j.addEventListener("loadstart",function(a){k(a.url)})}catch(l){c.info("InAppBrowser plugin is not intalled."),i(b)}else document.location.href=b.url}else i(b)}else h&&h("auth_failed",b)};window.addEventListener?window.addEventListener("load",function(){g(window.location.href)},!1):window.attachEvent&&window.attachEvent("onload",function(){g(window.location.href)}),b.exports={handleAuthResponse:h}},{"./fhparams":29,"./logger":35,"./queryMap":37,JSON:3}],26:[function(a,b){b.exports={boxprefix:"/box/srv/1.1/",sdk_version:"2.0.17-alpha",config_js:"fhconfig.json",INIT_EVENT:"fhinit"}},{}],27:[function(a,b){var c=a("./cookies"),d=a("./uuid"),e=a("./logger");b.exports={getDeviceId:function(){if("undefined"!=typeof window.fhdevice&&"undefined"!=typeof window.fhdevice.uuid)return window.fhdevice.uuid;if("undefined"!=typeof window.device&&"undefined"!=typeof window.device.uuid)return window.device.uuid;if("undefined"!=typeof navigator.device&&"undefined"!=typeof navigator.device.uuid)return navigator.device.uuid;var a="mock_uuid",b=c.readCookieValue(a);return null==b&&(b=d.createUUID(),c.createCookie(a,b)),b},getCuidMap:function(){return"undefined"!=typeof window.fhdevice&&"undefined"!=typeof window.fhdevice.cuidMap?window.fhdevice.cuidMap:"undefined"!=typeof window.device&&"undefined"!=typeof window.device.cuidMap?window.device.cuidMap:"undefined"!=typeof navigator.device&&"undefined"!=typeof navigator.device.cuidMap?navigator.device.cuidMap:null},getDestination:function(){var b=null,c=a("./platformsMap"),d=navigator.userAgent,f=document.location.search.split("fh_destination_code=");return f.length>1?b=f[1]:"undefined"!=typeof window.fh_destination_code?b=window.fh_destination_code:c.forEach(function(a){a.test.forEach(function(c){d.indexOf(c)>-1&&(b=a.destination)})}),null==b&&(b="web"),e.debug("destination = "+b),b}}},{"./cookies":"RdeKcl","./logger":35,"./platformsMap":36,"./uuid":48}],28:[function(a,b){var c=a("events").EventEmitter,d=new c;d.setMaxListeners(0),b.exports=d},{events:9}],29:[function(a,b){var c=a("./device"),d=a("./sdkversion"),e=a("./appProps"),f=a("./logger"),g=null,h=null,i=function(){if(g)return g;var a={};a.cuid=c.getDeviceId(),a.cuidMap=c.getCuidMap(),a.destination=c.getDestination(),(window.device||navigator.device)&&(a.device=window.device||navigator.device),"undefined"!=typeof window.fh_app_version&&(a.app_version=fh_app_version),"undefined"!=typeof window.fh_project_version&&(a.project_version=fh_project_version),"undefined"!=typeof window.fh_project_app_version&&(a.project_app_version=fh_project_app_version),a.sdk_version=d(),h&&(a.sessionToken=h);var b=e.getAppProps();return b&&(a.appid=b.appid,a.appkey=b.appkey,a.projectid=b.projectid,a.analyticsTag=b.analyticsTag,a.connectiontag=b.connectiontag,b.init&&(a.init="string"==typeof b.init?JSON.parse(b.init):b.init)),g=a,f.debug("fhparams = ",g),a},j=function(a){var a=a||{};return a.__fh=i(),a},k=function(a){h=a};b.exports={buildFHParams:i,addFHParams:j,setAuthSessionToken:k}},{"./appProps":"zDENqi","./device":27,"./logger":35,"./sdkversion":38}],30:[function(a,b){var c=a("JSON");b.exports=function(a,b,d,e){var f,g=0;if(b)try{g=b.status;var h=c.parse(b.responseText);f=h.error||h.msg,f instanceof Array&&(f=f.join("\n"))}catch(i){f=b.responseText}a&&a(f,{status:g,message:d,error:e})}},{JSON:3}],31:[function(a,b){function c(a){var b=a;return"/"===b.charAt(b.length-1)&&(b=b.substring(0,b.length-1)),b}function d(a){var b=a;return b.length>1&&"/"===b.charAt(0)&&(b=b.substring(1,b.length)),b}function e(a){this.cloud_props=a,this.cloud_host=void 0,this.isLegacy=!1}var f=a("./constants"),g=a("./appProps");e.prototype.getHost=function(a){if(this.cloud_host)return this.cloud_host;var b,d;if(this.cloud_props&&this.cloud_props.hosts&&(b=this.cloud_props.hosts.url,"undefined"==typeof b)){var e=this.cloud_props.hosts.releaseCloudUrl;d=this.cloud_props.hosts.releaseCloudType,"undefined"!=typeof a&&a.indexOf("dev")>-1&&(e=this.cloud_props.hosts.debugCloudUrl,d=this.cloud_props.hosts.debugCloudType),b=e}return b=c(b),this.cloud_host=b,"fh"===d&&(this.isLegacy=!0),b},e.prototype.getActUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.isLegacy?this.cloud_host+f.boxprefix+"act/"+this.cloud_props.domain+"/"+b.appid+"/"+a+"/"+b.appid:this.cloud_host+"/cloud/"+a},e.prototype.getMBAASUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.cloud_host+"/mbaas/"+a},e.prototype.getCloudUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.cloud_host+"/"+d(a)},b.exports=e},{"./appProps":"zDENqi","./constants":26}],32:[function(a,b){var c=(a("./loadScript"),a("../../libs/generated/lawnchair")),d=a("./lawnchair-ext"),e=a("./constants"),f=a("./fhparams"),g=a("./ajax"),h=a("./handleError"),i=a("./logger"),j=a("JSON"),k=a("./security/hash"),l=a("./appProps"),m=function(a){l.load(function(b,c){return b?a(b):n(c,a)})},n=function(a,b){if(a.loglevel&&i.setLevel(a.loglevel),a.local){var l={domain:"local",firstTime:!1,hosts:{debugCloudType:"node",debugCloudUrl:a.host,releaseCloudType:"node",releaseCloudUrl:a.host,type:"cloud_nodejs",url:a.host},init:{trackId:"000000000000000000000000"},status:"ok"};return b(null,{cloud:l})}d.addAdapter(a,k);var m={name:"fh_init_storage",adapter:["dom","webkit-sqlite","window-name"],fail:function(a,b){var c="read/save from/to local storage failed msg:"+a+" err:"+b;return fail(c,{})}};"undefined"!=typeof Titanium&&(m.adapter=["titanium"]);var n=function(a,c,d,e){var k=f.buildFHParams();g({url:a,type:"POST",tryJSONP:!0,dataType:"json",contentType:"application/json",data:j.stringify(k),timeout:c.timeout,success:function(a){e&&e.save({key:"fh_init",value:a},function(){}),b&&b(null,{cloud:a})},error:function(a,c,e){var f="unknown";a&&(f=a.status+" - "+a.responseText),i.error("App init returned error : "+f),d?(i.info("Using cached host: "+j.stringify(d)),b&&b(null,{cloud:d})):(i.error("No cached host found. Init failed."),h(function(a,c){b&&b({error:c,message:a})},a,c,e))}})},o=null,p=a.host+e.boxprefix+"app/init";try{o=new c(m,function(){}),o.get("fh_init",function(b){var c=null;b&&null!==b.value&&"undefined"!=typeof b.value&&""!==b&&(b="string"==typeof b?j.parse(b):b,b.value="string"==typeof b.value?j.parse(b.value):b.value,a.init=b.value.init?b.value.init:"string"==typeof b.value?j.parse(b.value):b.value,b.value.hosts&&(c=b.value)),n(p,a,c,o)})}catch(q){n(p,a,null,null)}};b.exports={init:m,loadCloudProps:n}},{"../../libs/generated/lawnchair":2,"./ajax":18,"./appProps":"zDENqi","./constants":26,"./fhparams":29,"./handleError":30,"./lawnchair-ext":33,"./loadScript":34,"./logger":35,"./security/hash":41,JSON:3}],33:[function(a,b){var c=a("../../libs/generated/lawnchair"),d=function(a,b){function c(a){console&&console.log(a)}function d(d,e){d=a.appid+d,b({algorithm:"MD5",text:d},function(a){var b=a.hashvalue+".txt";return"undefined"==typeof navigator.externalstorage?(c("filenameForKey key="+d+" , Filename: "+b),e(b)):void navigator.externalstorage.enable(function(a){var c=b;return a.path&&(c=a.path,c.match(/\/$/)||(c+="/"),c+=b),b=c,e(b)},function(){return e(b)})})}var e=function(a,b){if(!console)throw a;console.log("error in file system adapter !",a,b)};return{valid:function(){return!!window.requestFileSystem},init:function(a,b){a&&"function"==typeof a.fail&&(e=a.fail),b&&this.fn(this.name,b).call(this,this)},keys:function(){throw"Currently not supported"},save:function(a,b){var c=a.key,f=a.val||a.value;d(c,function(a){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(a,{create:!0},function(a){a.createWriter(function(a){a.onwrite=function(){return b({key:c,val:f})},a.write(f)},function(){e("[save] Failed to create file writer")})},function(){e("[save] Failed to getFile")})},function(){e("[save] Failed to requestFileSystem")})})},batch:function(){throw"Currently not supported"},get:function(a,b){d(a,function(c){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(c,{},function(c){c.file(function(c){var d=new FileReader;d.onloadend=function(c){var d=c.target.result;try{d=decodeURIComponent(d)}catch(e){}return b({key:a,val:d})},d.readAsText(c)},function(){e("[load] Failed to getFile")})},function(){b({key:a,val:null})})},function(){e("[load] Failed to get fileSystem")})})},exists:function(a,b){d(a,function(a){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(c){c.root.getFile(a,{},function(){return b(!0)},function(){return b(!1)})})})},all:function(){throw"Currently not supported"},remove:function(a,b){d(a,function(c){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(c,{},function(c){c.remove(function(){return b({key:a,val:null})},function(){e("[remove] Failed to remove file")})},function(){e("[remove] Failed to getFile")})},function(){e("[remove] Failed to get fileSystem")})})},nuke:function(){throw"Currently not supported"}}},e=function(a,b){c.adapter("localFileStorage",d(a,b))};b.exports={addAdapter:e}},{"../../libs/generated/lawnchair":2}],34:[function(a,b){b.exports=function(a,b){var c,d=document.head||document.getElementsByTagName("head")[0]||document.documentElement;c=document.createElement("script"),c.async="async",c.src=a,c.type="text/javascript",c.onload=c.onreadystatechange=function(){(!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,d&&c.parentNode&&d.removeChild(c),c=void 0,b&&"function"==typeof b&&b())},d.insertBefore(c,d.firstChild)}},{}],35:[function(a,b){var c=(a("console"),a("loglevel"));c.setLevel("info"),b.exports=c},{console:8,loglevel:14}],36:[function(a,b){b.exports=[{destination:"ipad",test:["iPad"]},{destination:"iphone",test:["iPhone"]},{destination:"android",test:["Android"]},{destination:"blackberry",test:["BlackBerry","BB10","RIM Tablet OS"]},{destination:"windowsphone",test:["Windows Phone 8"]},{destination:"windowsphone7",test:["Windows Phone OS 7"]}]},{}],37:[function(a,b){b.exports=function(a){var b={},c=a.split("?");if(2===c.length){var d=c[1],e=d.split("&");b={};for(var f=0;f100&&(e/=8),"undefined"==typeof d?c("security library is not loaded."):b({algorithm:"AES",secretkey:f(e),iv:f(e)})};b.exports=g},{"../../../libs/rsa":4}],40:[function(a,b){var c=a("../../../libs/generated/crypto"),d=function(a,b,d){var e=["key","plaintext","iv"];if("aes"!==a.params.algorithm.toLowerCase())return d("encrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return d("no_params_"+g,{},a)}var h=c.AES.encrypt(a.params.plaintext,c.enc.Hex.parse(a.params.key),{iv:c.enc.Hex.parse(a.params.iv)});return cipher_text=c.enc.Hex.stringify(h.ciphertext),b({ciphertext:cipher_text}) -},e=function(a,b,d){var e=["key","ciphertext","iv"];if("aes"!==a.params.algorithm.toLowerCase())return d("decrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return d("no_params_"+g,{},a)}var h=c.enc.Hex.parse(a.params.ciphertext),i=c.enc.Base64.stringify(h),j=c.AES.decrypt(i,c.enc.Hex.parse(a.params.key),{iv:c.enc.Hex.parse(a.params.iv)});return plain_text=j.toString(c.enc.Utf8),b({plaintext:plain_text})};b.exports={encrypt:d,decrypt:e}},{"../../../libs/generated/crypto":1}],41:[function(a,b){var c=a("../../../libs/generated/crypto"),d=function(a,b,d){if(!a.params.text)return void d("hash_no_text",{},a);var e;if("md5"===a.params.algorithm.toLowerCase())e=c.MD5(a.params.text).toString(c.enc.Hex);else if("sha1"===a.params.algorithm.toLowerCase())e=c.SHA1(a.params.text).toString(c.enc.Hex);else if("sha256"===a.params.algorithm.toLowerCase())e=c.SHA256(a.params.text).toString(c.enc.Hex);else{if("sha512"!==a.params.algorithm.toLowerCase())return d("hash_unsupported_algorithm: "+a.params.algorithm);e=c.SHA512(a.params.text).toString(c.enc.Hex)}return b({hashvalue:e})};b.exports=d},{"../../../libs/generated/crypto":1}],42:[function(a,b){var c=a("../../../libs/rsa"),d=c.RSAKey,e=function(a,b,c){var e=["modulu","plaintext"];if("rsa"!==a.params.algorithm.toLowerCase())return c("encrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return c("no_params_"+g,{},a)}var h=new d;h.setPublic(a.params.modulu,"10001");var i=a.params.plaintext;return cipher_text=h.encrypt(i),b({ciphertext:cipher_text})};b.exports={encrypt:e}},{"../../../libs/rsa":4}],43:[function(a,b){var c=a("JSON"),d=a("./api_act"),e=a("./api_cloud"),f=a("../../libs/generated/crypto"),g=a("../../libs/generated/lawnchair"),h={defaults:{sync_frequency:10,auto_sync_local_updates:!0,notify_client_storage_failed:!0,notify_sync_started:!0,notify_sync_complete:!0,notify_offline_update:!0,notify_collision_detected:!0,notify_remote_update_failed:!0,notify_local_update_applied:!0,notify_remote_update_applied:!0,notify_delta_received:!0,notify_record_delta_received:!0,notify_sync_failed:!0,do_console_log:!1,crashed_count_wait:10,resend_crashed_updates:!0,sync_active:!0,storage_strategy:"html5-filesystem",file_system_quota:61644800,has_custom_sync:null},notifications:{CLIENT_STORAGE_FAILED:"client_storage_failed",SYNC_STARTED:"sync_started",SYNC_COMPLETE:"sync_complete",OFFLINE_UPDATE:"offline_update",COLLISION_DETECTED:"collision_detected",REMOTE_UPDATE_FAILED:"remote_update_failed",REMOTE_UPDATE_APPLIED:"remote_update_applied",LOCAL_UPDATE_APPLIED:"local_update_applied",DELTA_RECEIVED:"delta_received",RECORD_DELTA_RECEIVED:"record_delta_received",SYNC_FAILED:"sync_failed"},datasets:{},config:void 0,notify_callback:void 0,init_is_called:!1,init:function(a){h.consoleLog("sync - init called"),h.config=c.parse(c.stringify(h.defaults));for(var b in a)h.config[b]=a[b];h.init_is_called||(h.init_is_called=!0,h.datasetMonitor())},notify:function(a){h.notify_callback=a},manage:function(a,b,d,e,f){h.consoleLog("manage - START");var b=b||{},g=function(g){h.consoleLog("doManage dataset :: initialised = "+g.initialised+" :: "+a+" :: "+c.stringify(b));var i=h.setOptions(b);g.query_params=d||g.query_params||{},g.meta_data=e||g.meta_data||{},g.config=i,g.syncRunning=!1,g.syncPending=!0,g.initialised=!0,"undefined"==typeof g.meta&&(g.meta={}),h.saveDataSet(a,function(){f&&f()})};h.getDataSet(a,function(a){h.consoleLog("manage - dataset already loaded"),g(a)},function(){h.consoleLog("manage - dataset not loaded... trying to load"),h.loadDataSet(a,function(b){h.consoleLog("manage - dataset loaded from local storage"),h.doNotify(a,null,h.notifications.LOCAL_UPDATE_APPLIED,"load"),g(b)},function(){h.consoleLog("manage - Creating new dataset for id "+a);var b={};b.data={},b.pending={},b.meta={},h.datasets[a]=b,g(b)})})},setOptions:function(a){h.config||(h.config=c.parse(c.stringify(h.defaults)));var b=c.parse(c.stringify(h.config)),d=c.parse(c.stringify(a));for(var e in d)b[e]=d[e];return b},list:function(a,b,d){h.getDataSet(a,function(a){if(a&&a.data){var e=c.parse(c.stringify(a.data));b(e)}else d&&d("no_data")},function(a,b){d&&d(a,b)})},create:function(a,b,c,d){return null==b&&d?d("null_data"):void h.addPendingObj(a,null,b,"create",c,d)},read:function(a,b,d,e){h.getDataSet(a,function(a){var f=a.data[b];if(f){var g=c.parse(c.stringify(f));d(g)}else e("unknown_uid")},function(a,b){e&&e(a,b)})},update:function(a,b,c,d,e){h.addPendingObj(a,b,c,"update",d,e)},"delete":function(a,b,c,d){h.addPendingObj(a,b,null,"delete",c,d)},getPending:function(a,b){h.getDataSet(a,function(a){var c;a&&(c=a.pending),b(c)},function(a){h.consoleLog(a)})},clearPending:function(a,b){h.getDataSet(a,function(c){c.pending={},h.saveDataSet(a,b)})},listCollisions:function(a,b,c){h.getDataSet(a,function(d){h.doCloudCall({dataset_id:a,req:{fn:"listCollisions",meta_data:d.meta_data}},b,c)},c)},removeCollision:function(a,b,c,d){h.getDataSet(a,function(e){h.doCloudCall({dataset_id:a,req:{fn:"removeCollision",hash:b,meta_data:e.meta_data}},c,d)})},isOnline:function(a){var b=!0;if("undefined"!=typeof navigator.onLine&&(b=navigator.onLine),b&&"undefined"!=typeof navigator.network&&"undefined"!=typeof navigator.network.connection){var c=navigator.network.connection.type;("none"===c||null===c)&&(b=!1)}return a(b)},doNotify:function(a,b,c,d){if(h.notify_callback&&h.config["notify_"+c]){var e={dataset_id:a,uid:b,code:c,message:d};setTimeout(function(){h.notify_callback(e)},0)}},getDataSet:function(a,b,c){var d=h.datasets[a];d?b(d):c&&c("unknown_dataset "+a,a)},getQueryParams:function(a,b,c){var d=h.datasets[a];d?b(d.query_params):c&&c("unknown_dataset "+a,a)},setQueryParams:function(a,b,c,d){var e=h.datasets[a];e?(e.query_params=b,h.saveDataSet(a),c&&c(e.query_params)):d&&d("unknown_dataset "+a,a)},getMetaData:function(a,b,c){var d=h.datasets[a];d?b(d.meta_data):c&&c("unknown_dataset "+a,a)},setMetaData:function(a,b,c,d){var e=h.datasets[a];e?(e.meta_data=b,h.saveDataSet(a),c&&c(e.meta_data)):d&&d("unknown_dataset "+a,a)},getConfig:function(a,b,c){var d=h.datasets[a];d?b(d.config):c&&c("unknown_dataset "+a,a)},setConfig:function(a,b,c,d){var e=h.datasets[a];if(e){var f=h.setOptions(b);e.config=f,h.saveDataSet(a),c&&c(e.config)}else d&&d("unknown_dataset "+a,a)},stopSync:function(a,b,c){h.setConfig(a,{sync_active:!1},function(){b&&b()},c)},startSync:function(a,b,c){h.setConfig(a,{sync_active:!0},function(){b&&b()},c)},doSync:function(a,b,c){var d=h.datasets[a];d?(d.syncPending=!0,h.saveDataSet(a),b&&b()):c&&c("unknown_dataset "+a,a)},forceSync:function(a,b,c){var d=h.datasets[a];d?(d.syncForced=!0,h.saveDataSet(a),b&&b()):c&&c("unknown_dataset "+a,a)},sortObject:function(a){if("object"!=typeof a||null===a)return a;var b=[];return Object.keys(a).sort().forEach(function(c){b.push({key:c,value:h.sortObject(a[c])})}),b},sortedStringify:function(a){var b="";try{b=c.stringify(h.sortObject(a))}catch(d){console.error("Error stringifying sorted object:"+d)}return b},generateHash:function(a){var b=f.SHA1(h.sortedStringify(a));return b.toString()},addPendingObj:function(a,b,d,e,f,g){function i(c){c.hash=h.generateHash(c),h.getDataSet(a,function(d){d.pending[c.hash]=c,h.updateDatasetFromLocal(d,c),h.config.auto_sync_local_updates&&(d.syncPending=!0),h.saveDataSet(a),h.doNotify(a,b,h.notifications.LOCAL_UPDATE_APPLIED,e),f(c)},function(a,b){g&&g(a,b)})}h.isOnline(function(c){c||h.doNotify(a,b,h.notifications.OFFLINE_UPDATE,e)});var j={};j.inFlight=!1,j.action=e,j.post=c.parse(c.stringify(d)),j.postHash=h.generateHash(j.post),j.timestamp=(new Date).getTime(),"create"===e?(j.uid=j.postHash,i(j)):h.read(a,b,function(a){j.uid=b,j.pre=a.data,j.preHash=h.generateHash(a.data),i(j)},function(a,b){g&&g(a,b)})},syncLoop:function(a){h.getDataSet(a,function(b){b.syncPending=!1,b.syncRunning=!0,b.syncLoopStart=(new Date).getTime(),h.doNotify(a,null,h.notifications.SYNC_STARTED,null),h.isOnline(function(d){d?h.checkHasCustomSync(a,function(){var d={};d.fn="sync",d.dataset_id=a,d.query_params=b.query_params,d.config=b.config,d.meta_data=b.meta_data,d.dataset_hash=b.hash,d.acknowledgements=b.acknowledgements||[];var e=b.pending,f=[];for(var g in e)e[g].inFlight||e[g].crashed||e[g].delayed||(e[g].inFlight=!0,e[g].inFlightDate=(new Date).getTime(),f.push(e[g]));d.pending=f,f.length>0&&h.consoleLog("Starting sync loop - global hash = "+b.hash+" :: params = "+c.stringify(d,null,2));try{h.doCloudCall({dataset_id:a,req:d},function(c){function d(c,d,f){if(c)for(var g in c)e=c[g],f.push(e),b.pending[g]&&b.pending[g].inFlight&&!b.pending[g].crashed&&(delete b.pending[g],h.doNotify(a,e.uid,d,e))}var e;if(h.updatePendingFromNewData(a,b,c),h.updateCrashedInFlightFromNewData(a,b,c),h.updateDelayedFromNewData(a,b,c),h.updateMetaFromNewData(a,b,c),h.updateNewDataFromInFlight(a,b,c),h.updateNewDataFromPending(a,b,c),c.records&&(b.data=c.records,b.hash=c.hash,h.doNotify(a,c.hash,h.notifications.DELTA_RECEIVED,"full dataset")),c.updates){var f=[];d(c.updates.applied,h.notifications.REMOTE_UPDATE_APPLIED,f),d(c.updates.failed,h.notifications.REMOTE_UPDATE_FAILED,f),d(c.updates.collisions,h.notifications.COLLISION_DETECTED,f),b.acknowledgements=f}!c.records&&c.hash&&c.hash!==b.hash?(h.consoleLog("Local dataset stale - syncing records :: local hash= "+b.hash+" - remoteHash="+c.hash),h.syncRecords(a)):(h.consoleLog("Local dataset up to date"),h.syncComplete(a,"online",h.notifications.SYNC_COMPLETE))},function(c,d){h.markInFlightAsCrashed(b),h.consoleLog("syncLoop failed : msg="+c+" :: err = "+d),h.syncComplete(a,c,h.notifications.SYNC_FAILED)})}catch(i){h.consoleLog("Error performing sync - "+i),h.syncComplete(a,i,h.notifications.SYNC_FAILED)}}):h.syncComplete(a,"offline",h.notifications.SYNC_FAILED)})})},syncRecords:function(a){h.getDataSet(a,function(b){var d=b.data||{},e={};for(var f in d){var g=f,i=d[f].hash;e[g]=i}var j={};j.fn="syncRecords",j.dataset_id=a,j.query_params=b.query_params,j.clientRecs=e,h.consoleLog("syncRecParams :: "+c.stringify(j)),h.doCloudCall({dataset_id:a,req:j},function(c){var e;if(c.create)for(e in c.create)d[e]={hash:c.create[e].hash,data:c.create[e].data},h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"create");if(c.update)for(e in c.update)d[e].hash=c.update[e].hash,d[e].data=c.update[e].data,h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"update");if(c["delete"])for(e in c["delete"])delete d[e],h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"delete");h.doNotify(a,c.hash,h.notifications.DELTA_RECEIVED,"partial dataset"),b.data=d,c.hash&&(b.hash=c.hash),h.syncComplete(a,"online",h.notifications.SYNC_COMPLETE)},function(b,c){h.consoleLog("syncRecords failed : msg="+b+" :: err="+c),h.syncComplete(a,b,h.notifications.SYNC_FAILED)})})},syncComplete:function(a,b,c){h.getDataSet(a,function(d){d.syncRunning=!1,d.syncLoopEnd=(new Date).getTime(),h.saveDataSet(a),h.doNotify(a,d.hash,c,b)})},checkDatasets:function(){for(var a in h.datasets)if(h.datasets.hasOwnProperty(a)){var b=h.datasets[a];if(!b.syncRunning&&(b.config.sync_active||b.syncForced)){var c=b.syncLoopStart,d=b.syncLoopEnd;if(b.syncForced)b.syncPending=!0;else if(null==c)h.consoleLog(a+" - Performing initial sync"),b.syncPending=!0;else if(null!=d){var e=(new Date).getTime()-d,f=1e3*b.config.sync_frequency;e>f&&(b.syncPending=!0)}b.syncPending&&(b.syncForced=!1,h.syncLoop(a))}}},checkHasCustomSync:function(a,b){var c=h.datasets[a];return c&&c.config?(h.consoleLog("dataset.config.has_custom_sync = "+c.config.has_custom_sync),null!=c.config.has_custom_sync?b():(h.consoleLog("starting check has custom sync"),void d({act:a,req:{fn:"sync"}},function(a){return h.consoleLog("check has_custom_sync - success - ",a),c.config.has_custom_sync=!0,b()},function(a,d){return h.consoleLog("check has_custom_sync - failure - ",d),d.status&&500===d.status?(h.consoleLog("check has_custom_sync - failed with 500, endpoint does exists"),c.config.has_custom_sync=!0):c.config.has_custom_sync=!1,b()}))):b()},doCloudCall:function(a,b,c){var f=!1,g=h.datasets[a.dataset_id];g&&g.config&&(f=g.config.has_custom_sync),1==f?d({act:a.dataset_id,req:a.req},function(a){b(a)},function(a,b){c(a,b)}):e({path:"/mbaas/sync/"+a.dataset_id,method:"post",data:a.req},function(a){b(a)},function(a,b){c(a,b)})},datasetMonitor:function(){h.checkDatasets(),setTimeout(function(){h.datasetMonitor()},500)},saveDataSet:function(a,b){var c=function(b,c){var d="save to local storage failed msg:"+b+" err:"+c;h.doNotify(a,null,h.notifications.CLIENT_STORAGE_FAILED,d),h.consoleLog(d)};h.getDataSet(a,function(d){g({fail:c,adapter:h.config.storage_strategy,size:h.config.file_system_quota},function(){this.save({key:"dataset_"+a,val:d},function(){return b?b():void 0})})})},loadDataSet:function(a,b,d){var e=function(b){var c="load from local storage failed msg:"+b;h.doNotify(a,null,h.notifications.CLIENT_STORAGE_FAILED,c),h.consoleLog(c)};g({fail:e,adapter:h.config.storage_strategy,size:h.config.file_system_quota},function(){this.get("dataset_"+a,function(e){if(e&&e.val){var f=e.val;if("string"==typeof f&&(f=c.parse(f)),f.initialised=!1,h.datasets[a]=f,h.consoleLog("load from local storage success for dataset_id :"+a),b)return b(f)}else if(d)return d()})})},updateDatasetFromLocal:function(a,b){var d,e,f=a.pending,g=b.uid;h.consoleLog("updating local dataset for uid "+g+" - action = "+b.action),a.meta[g]=a.meta[g]||{},"create"===b.action&&(a.data[g]&&(h.consoleLog("dataset already exists for uid in create :: "+c.stringify(a.data[g])),a.meta[g].fromPending&&(d=a.meta[g].pendingUid,delete f[d])),a.data[g]={}),"update"===b.action&&a.data[g]&&a.meta[g].fromPending&&(h.consoleLog("updating an existing pending record for dataset :: "+c.stringify(a.data[g])),d=a.meta[g].pendingUid,a.meta[g].previousPendingUid=d,e=f[d],e&&(e.inFlight?(h.consoleLog("existing in-inflight pending record = "+c.stringify(e)),b.delayed=!0,b.waiting=e.hash):(h.consoleLog("existing pre-flight pending record = "+c.stringify(e)),e.post=b.post,e.postHash=b.postHash,delete f[b.hash],b.hash=d))),"delete"===b.action&&a.data[g]&&(a.meta[g].fromPending&&(h.consoleLog("Deleting an existing pending record for dataset :: "+c.stringify(a.data[g])),d=a.meta[g].pendingUid,a.meta[g].previousPendingUid=d,e=f[d],e&&(e.inFlight?(h.consoleLog("existing in-inflight pending record = "+c.stringify(e)),b.delayed=!0,b.waiting=e.hash):(h.consoleLog("existing pending record = "+c.stringify(e)),"create"===e.action&&(delete f[b.hash],delete f[d]),"update"===e.action&&(b.pre=e.pre,b.preHash=e.preHash,b.inFlight=!1,delete f[d])))),delete a.data[g]),a.data[g]&&(a.data[g].data=b.post,a.data[g].hash=b.postHash,a.meta[g].fromPending=!0,a.meta[g].pendingUid=b.hash)},updatePendingFromNewData:function(a,b,d){var e,f=b.pending;if(f&&d.records)for(var g in f)if(f.hasOwnProperty(g)){var i=f[g];if(b.meta[i.uid]=b.meta[i.uid]||{},i.inFlight===!1){if(h.consoleLog("updatePendingFromNewData - Found Non inFlight record -> action="+i.action+" :: uid="+i.uid+" :: hash="+i.hash),"update"===i.action||"delete"===i.action)if(e=d.records[i.uid])h.consoleLog("updatePendingFromNewData - Updating pre values for existing pending record "+i.uid),i.pre=e.data,i.preHash=e.hash;else{var j=b.meta[i.uid].previousPendingUid,k=f[j];if(k&&d&&d.updates&&d.updates.applied&&d.updates.applied[k.hash]){var l=d.updates.applied[k.hash].uid;e=d.records[l],e&&(h.consoleLog("updatePendingFromNewData - Updating pre values for existing pending record which was previously a create "+i.uid+" ==> "+l),i.pre=e.data,i.preHash=e.hash,i.uid=l)}}"create"===i.action&&d&&d.updates&&d.updates.applied&&d.updates.applied[g]&&(h.consoleLog("updatePendingFromNewData - Found an update for a pending create "+c.stringify(d.updates.applied[g])),e=d.records[d.updates.applied[g].uid],e&&(h.consoleLog("updatePendingFromNewData - Changing pending create to an update based on new record "+c.stringify(e)),i.action="update",i.pre=e.data,i.preHash=e.hash,i.uid=d.updates.applied[g].uid))}}},updateNewDataFromInFlight:function(a,b,c){var d=b.pending;if(d&&c.records)for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];if(f.inFlight){var g=c&&c.updates&&c.updates.hashes&&c.updates.hashes[e]?!0:!1;if(h.consoleLog("updateNewDataFromInFlight - Found inflight pending Record - action = "+f.action+" :: hash = "+e+" :: updateReceivedForPending="+g),!g){var i=c.records[f.uid];if("update"===f.action&&i)i.data=f.post,i.hash=f.postHash;else if("delete"===f.action&&i)delete c.records[f.uid];else if("create"===f.action){h.consoleLog("updateNewDataFromInFlight - re adding pending create to incomming dataset");var j={data:f.post,hash:f.postHash};c.records[f.uid]=j}}}}},updateNewDataFromPending:function(a,b,c){var d=b.pending;if(d&&c.records)for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];if(f.inFlight===!1){h.consoleLog("updateNewDataFromPending - Found Non inFlight record -> action="+f.action+" :: uid="+f.uid+" :: hash="+f.hash);var g=c.records[f.uid];if("update"===f.action&&g)g.data=f.post,g.hash=f.postHash;else if("delete"===f.action&&g)delete c.records[f.uid];else if("create"===f.action){h.consoleLog("updateNewDataFromPending - re adding pending create to incomming dataset");var i={data:f.post,hash:f.postHash};c.records[f.uid]=i}}}},updateCrashedInFlightFromNewData:function(a,b,d){var e,f,g={applied:h.notifications.REMOTE_UPDATE_APPLIED,failed:h.notifications.REMOTE_UPDATE_FAILED,collisions:h.notifications.COLLISION_DETECTED},i=b.pending,j={};if(i){for(e in i)if(i.hasOwnProperty(e)&&(f=i[e],f.inFlight&&f.crashed))if(h.consoleLog("updateCrashedInFlightFromNewData - Found crashed inFlight pending record uid="+f.uid+" :: hash="+f.hash),d&&d.updates&&d.updates.hashes){var k=d.updates.hashes[e];k?(j[k.uid]=k,h.consoleLog("updateCrashedInFlightFromNewData - Resolving status for crashed inflight pending record "+c.stringify(k)),"failed"===k.type&&("create"===k.action?(h.consoleLog("updateCrashedInFlightFromNewData - Deleting failed create from dataset"),delete b.data[k.uid]):("update"===k.action||"delete"===k.action)&&(h.consoleLog("updateCrashedInFlightFromNewData - Reverting failed "+k.action+" in dataset"),b.data[k.uid]={data:f.pre,hash:f.preHash})),delete i[e],h.doNotify(a,k.uid,g[k.type],k)):f.crashedCount?f.crashedCount++:f.crashedCount=1}else f.crashedCount?f.crashedCount++:f.crashedCount=1;for(e in i)i.hasOwnProperty(e)&&(f=i[e],f.inFlight&&f.crashed&&f.crashedCount>b.config.crashed_count_wait&&(h.consoleLog("updateCrashedInFlightFromNewData - Crashed inflight pending record has reached crashed_count_wait limit : "+c.stringify(f)),b.config.resend_crashed_updates?(h.consoleLog("updateCrashedInFlightFromNewData - Retryig crashed inflight pending record"),f.crashed=!1,f.inFlight=!1):(h.consoleLog("updateCrashedInFlightFromNewData - Deleting crashed inflight pending record"),delete i[e])))}},updateDelayedFromNewData:function(a,b,d){var e,f,g=b.pending;if(g)for(e in g)if(g.hasOwnProperty(e)&&(f=g[e],f.delayed&&f.waiting&&(h.consoleLog("updateDelayedFromNewData - Found delayed pending record uid="+f.uid+" :: hash="+f.hash+" :: waiting="+f.waiting),d&&d.updates&&d.updates.hashes))){var i=d.updates.hashes[f.waiting];i&&(h.consoleLog("updateDelayedFromNewData - Waiting pending record is resolved rec="+c.stringify(i)),f.delayed=!1,f.waiting=void 0)}},updateMetaFromNewData:function(a,b,d){var e=b.meta;if(e&&d&&d.updates&&d.updates.hashes)for(var f in e)if(e.hasOwnProperty(f)){var g=e[f],i=g.pendingUid,j=g.previousPendingUid;h.consoleLog("updateMetaFromNewData - Found metadata with uid = "+f+" :: pendingHash = "+i+" :: previousPendingHash ="+j);var k=!0,l=!0;if(j){k=!1;var m=d.updates.hashes[j];m&&(h.consoleLog("updateMetaFromNewData - Found previousPendingUid in meta data resolved - resolved = "+c.stringify(m)),g.previousPendingUid=void 0,k=!0)}if(i){l=!1;var m=d.updates.hashes[i];m&&(h.consoleLog("updateMetaFromNewData - Found pendingUid in meta data resolved - resolved = "+c.stringify(m)),g.pendingUid=void 0,l=!0)}k&&l&&(h.consoleLog("updateMetaFromNewData - both previous and current pendings are resolved for meta data with uid "+f+". Delete it."),delete e[f])}},markInFlightAsCrashed:function(a){var b,c,d=a.pending;if(d){var e={};for(b in d)d.hasOwnProperty(b)&&(c=d[b],c.inFlight&&(h.consoleLog("Marking in flight pending record as crashed : "+b),c.crashed=!0,e[c.uid]=c))}},consoleLog:function(a){h.config.do_console_log&&console.log(a)}};!function(){h.config=h.defaults}(),b.exports={init:h.init,manage:h.manage,notify:h.notify,doList:h.list,doCreate:h.create,doRead:h.read,doUpdate:h.update,doDelete:h["delete"],listCollisions:h.listCollisions,removeCollision:h.removeCollision,getPending:h.getPending,clearPending:h.clearPending,getDataset:h.getDataSet,getQueryParams:h.getQueryParams,setQueryParams:h.setQueryParams,getMetaData:h.getMetaData,setMetaData:h.setMetaData,getConfig:h.getConfig,setConfig:h.setConfig,startSync:h.startSync,stopSync:h.stopSync,doSync:h.doSync,forceSync:h.forceSync,generateHash:h.generateHash,loadDataSet:h.loadDataSet,checkHasCustomSync:h.checkHasCustomSync}},{"../../libs/generated/crypto":1,"../../libs/generated/lawnchair":2,"./api_act":19,"./api_cloud":21,JSON:3}],"./modules/appProps":[function(a,b){b.exports=a("zDENqi")},{}],zDENqi:[function(_dereq_,module,exports){var consts=_dereq_("../constants"),ajax=_dereq_("../ajax"),logger=_dereq_("../logger"),qs=_dereq_("../queryMap"),app_props=null,load=function(cb){return app_props=eval('require("fhconfig")'),cb(null,app_props)},setAppProps=function(a){app_props=a},getAppProps=function(){return app_props};module.exports={load:load,getAppProps:getAppProps,setAppProps:setAppProps}},{"../ajax":18,"../constants":26,"../logger":35,"../queryMap":37}],RdeKcl:[function(a,b){b.exports={readCookieValue:function(a){return"undefined"!=typeof Titanium?Titanium.App.Properties.getObject(a):null},createCookie:function(a,b){return"undefined"!=typeof Titanium?Titanium.App.Properties.setObject(a,b):void 0}}},{}],"./cookies":[function(a,b){b.exports=a("RdeKcl")},{}],48:[function(a,b){b.exports={createUUID:function(){for(var a=[],b="0123456789ABCDEF",c=0;32>c;c++)a[c]=b.substr(Math.floor(16*Math.random()),1);a[12]="4",a[16]=b.substr(3&a[16]|8,1);var d=a.join("");return d}}},{}],49:[function(a,b){var c,d=a("./initializer"),e=a("./events"),f=a("./hosts"),g=a("./constants"),h=a("./logger"),i=!1,j=!1,k=null,l=function(a){return j?a(null,{host:n()}):(e.once(g.INIT_EVENT,function(b,c){return a(b,c)}),void(i||(i=!0,d.init(function(a,b){return i=!1,a?(k=a,e.emit(g.INIT_EVENT,a)):(k=null,j=!0,c=new f(b.cloud),e.emit(g.INIT_EVENT,null,{host:n()}))}))))},m=function(){return c},n=function(){if("undefined"!=typeof c){var b=a("./appProps").getAppProps();return c.getHost(b.mode)}return void 0},o=function(){return j},p=function(){return k},q=function(){j=!1,i=!1,c=void 0,k=void 0,l(function(){})};l(function(a){a?"app_config_missing"!==a.message?h.error("Failed to initialise fh."):h.info("No fh config file"):h.info("fh cloud is ready")}),b.exports={ready:l,isReady:o,getCloudHost:m,getCloudHostUrl:n,getInitError:p,reset:q}},{"./appProps":"zDENqi","./constants":26,"./events":28,"./hosts":31,"./initializer":32,"./logger":35}]},{},[16])(16)}); \ No newline at end of file +}),this},exists:function(b,c){var d="SELECT * FROM "+this.record+" WHERE id = ?",e=this,f=function(a,b){c&&e.fn("exists",c).call(e,b.rows.length>0)};return this.db.readTransaction(function(c){c.executeSql(d,[b],f,a)}),this},all:function(b){var c=this,d="SELECT * FROM "+this.record,e=[],f=this.fn(this.name,b)||void 0,g=function(a,b){if(0!=b.rows.length)for(var d=0,g=b.rows.length;g>d;d++){var h=JSON.parse(b.rows.item(d).value);h.key=b.rows.item(d).id,e.push(h)}f&&f.call(c,e)};return this.db.readTransaction(function(b){b.executeSql(d,[],g,a)}),this},remove:function(b,c){var d,e=this,f="DELETE FROM "+this.record+" WHERE id ",g=function(){c&&e.lambda(c).call(e)};return this.isArray(b)?(d=b,f+="IN ("+d.map(function(){return"?"}).join(",")+")"):(f+="= ?",d=[b]),d=d.map(function(a){return a.key?a.key:a}),this.db.transaction(function(b){b.executeSql(f,d,g,a)}),this},nuke:function(b){var c="DELETE FROM "+this.record,d=this,e=b?function(){d.lambda(b).call(d)}:function(){};return this.db.transaction(function(b){b.executeSql(c,[],e,a)}),this}}}()),f.adapter("html5-filesystem",function(a){var b=a.FileError,c=function(a){var c,d=!0;switch(a.code){case b.QUOTA_EXCEEDED_ERR:c="QUOTA_EXCEEDED_ERR";break;case b.NOT_FOUND_ERR:c="NOT_FOUND_ERR",d=!1;break;case b.SECURITY_ERR:c="SECURITY_ERR";break;case b.INVALID_MODIFICATION_ERR:c="INVALID_MODIFICATION_ERR";break;case b.INVALID_STATE_ERR:c="INVALID_STATE_ERR";break;default:c="Unknown Error"}console&&d&&console.error(a,c)},d=function(a,b,e){var f=e||[];a.readEntries(function(c){c.length?d(a,b,f.concat(Array.prototype.slice.call(c))):b&&b(f.map(function(a){return a.name}))},c)},e={},f=function(a,b){var c=e[a.name];c?b(c):setTimeout(function(){f(a,b)},10)},g=function(){var a=-1===document.URL.indexOf("http://")&&-1===document.URL.indexOf("https://");return a?!0:!1},h=function(a){var b;if(g())b=a;else{var c="application/json";try{b=new Blob([a],{type:c})}catch(d){var e=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if("TypeError"==d.name&&e){var f=new e;f.append([a.buffer]),b=f.getBlob(c)}else b=a}}return b};return{valid:function(){var b=a.requestFileSystem||a.webkitRequestFileSystem||a.moz_requestFileSystem;return!!b},init:function(b,d){function f(b){var c=a.requestFileSystem||a.webkitRequestFileSystem||a.moz_requestFileSystem,f=window.PERSISTENT;"undefined"!=typeof LocalFileSystem&&"undefined"!=typeof LocalFileSystem.PERSISTENT&&(f=LocalFileSystem.PERSISTENT),c(f,b,function(a){a.root.getDirectory(j,{create:!0},function(a){e[j]=a,d&&g.fn(g.name,d).call(g,g)},function(a){h(a)})},function(a){h(a)})}var g=this,h=function(a){c(a),d&&g.fn(g.name,d).call(g,g)},i=b.size||104857600,j=this.name;"undefined"!=typeof navigator.webkitPersistentStorage?navigator.webkitPersistentStorage.requestQuota(i,f,function(){logger.warn("User declined file storage"),h("User declined file storage")}):f(0)},keys:function(a){var b=this;return f(this,function(c){d(c.createReader(),function(c){a&&b.fn("keys",a).call(b,c)})}),this},save:function(a,b){var d=this,e=a.key||this.uuid();a.key=e;var g=function(a){c(a),b&&d.lambda(b).call(d)};return f(this,function(c){c.getFile(e,{create:!0},function(c){c.createWriter(function(c){c.onerror=g,c.onwriteend=function(){this.onwriteend=null,this.truncate(this.position),b&&d.lambda(b).call(d,a)};var e=JSON.stringify(a),f=h(e);c.write(f)},g)},g)}),this},batch:function(a,b){for(var c=this,d=[],e=0,f=a.length;f>e;e++)c.save(a[e],function(a){d.push(a),d.length===f&&b&&c.lambda(b).call(c,d)});return this},get:function(a,b){var d=this;if(this.isArray(a))for(var e=[],g=0,h=a.length;h>g;g++)d.get(a[g],function(a){a&&e.push(a),e.length===h&&b&&d.lambda(b).call(d,e)});else{var i=function(a){c(a),b&&d.lambda(b).call(d)};f(this,function(c){c.getFile(a,{create:!1},function(c){c.file(function(c){var e=new FileReader;e.onerror=i,e.onload=function(c){var e={};try{e=JSON.parse(c.target.result),e.key=a}catch(c){e={key:a}}b&&d.lambda(b).call(d,e)},e.readAsText(c)},i)},i)})}return this},exists:function(a,b){var c=this;return f(this,function(d){d.getFile(a,{create:!1},function(){b&&c.lambda(b).call(c,!0)},function(){b&&c.lambda(b).call(c,!1)})}),this},all:function(a){var b=this;return a&&this.keys(function(c){c.length?b.get(c,function(c){b.fn(b.name,a).call(b,c)}):b.fn(b.name,a).call(b,[])}),this},remove:function(a,b){var d=this,e=function(a){c(a),b&&d.lambda(b).call(d)};return f(this,function(c){c.getFile("string"==typeof a?a:a.key,{create:!1},function(a){a.remove(function(){b&&d.lambda(b).call(d)},e)},e)}),this},nuke:function(a){var b=this,c=0;return this.keys(function(d){if(d.length)for(var e=0,f=d.length;f>e;e++)b.remove(d[e],function(){c++,c===f&&a&&b.lambda(a).call(b)});else a&&b.lambda(a).call(b)}),this}}}(this)),f.adapter("memory",function(){var a={};return{valid:function(){return!0},init:function(b,c){a[this.name]=a[this.name]||{index:[],store:{}},this.index=a[this.name].index,this.store=a[this.name].store;var d=this.fn(this.name,c);return d&&d.call(this,this),this},keys:function(a){return this.fn("keys",a).call(this,this.index),this},save:function(a,b){var c=a.key||this.uuid();return this.exists(c,function(d){d||(a.key&&delete a.key,this.index.push(c)),this.store[c]=a,b&&(a.key=c,this.lambda(b).call(this,a))}),this},batch:function(a,b){for(var c=[],d=0,e=a.length;e>d;d++)this.save(a[d],function(a){c.push(a)});return b&&this.lambda(b).call(this,c),this},get:function(a,b){var c;if(this.isArray(a)){c=[];for(var d=0,e=a.length;e>d;d++)c.push(this.store[a[d]])}else c=this.store[a],c&&(c.key=a);return b&&this.lambda(b).call(this,c),this},exists:function(a,b){return this.lambda(b).call(this,!!this.store[a]),this},all:function(a){for(var b=[],c=0,d=this.index.length;d>c;c++){var e=this.store[this.index[c]];e.key=this.index[c],b.push(e)}return this.fn(this.name,a).call(this,b),this},remove:function(a,b){for(var c=this.isArray(a)?a:[a],d=0,e=c.length;e>d;d++){var f=c[d].key?c[d].key:c[d],g=this.indexOf(this.index,f);0>g||(delete this.store[f],this.index.splice(g,1))}return b&&this.lambda(b).call(this),this},nuke:function(b){return this.store=a[this.name].store={},this.index=a[this.name].index=[],b&&this.lambda(b).call(this),this}}}()),f.adapter("titanium",function(){return{valid:function(){return"undefined"!=typeof Titanium},init:function(a,b){return b?this.fn("init",b).call(this):void 0},keys:function(a){return a?this.fn("keys",a).call(this,Titanium.App.Properties.listProperties()):this},save:function(a,b){var c=Titanium.App.Properties.setObject(a.key,a);return b?this.fn("save",b).call(this,c):this},batch:function(a,b){for(var c=this,d=[],e=0,f=a.length;f>e;e++)c.save(a[e],function(a){d.push(a),d.length===f&&b&&c.lambda(b).call(c,d)});return this},get:function(a,b){var c=this;if(!this.isArray(a))return this.fn("init",b).call(this,Titanium.App.Properties.getObject(a));for(var d=[],e=0,f=a.length;f>e;e++)c.get(a[e],function(a){a&&d.push(a),d.length===f&&b&&c.lambda(b).call(c,d)});return this},exists:function(a,b){return b?Titanium.App.Properties.getObject(a)?b(this,!0):b(this,!1):this},all:function(a){var b=this;return a&&this.keys(function(c){c.length?b.get(c,function(c){b.fn(b.name,a).call(b,c)}):b.fn(b.name,a).call(b,[])}),this},remove:function(a,b){return Titanium.App.Properties.removeProperty(a),b?this.fn("remove",b).call(this):this},nuke:function(){}}}(this)),e("undefined"!=typeof f?f:window.Lawnchair)}.call(c,void 0,void 0,void 0,void 0,function(a){b.exports=a})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(_dereq_,module,exports){(function(global){__browserify_shim_require__=_dereq_,function browserifyShim(module,exports,_dereq_,define,browserify_shim__define__module__export__){var JSON;JSON||(JSON={}),function(){"use strict";function f(a){return 10>a?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g,h=gap,i=b[a];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(a)),"function"==typeof rep&&(i=rep.call(b,a,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";if(gap+=indent,g=[],"[object Array]"===Object.prototype.toString.apply(i)){for(f=i.length,c=0;f>c;c+=1)g[c]=str(c,i)||"null";return e=0===g.length?"[]":gap?"[\n"+gap+g.join(",\n"+gap)+"\n"+h+"]":"["+g.join(",")+"]",gap=h,e}if(rep&&"object"==typeof rep)for(f=rep.length,c=0;f>c;c+=1)"string"==typeof rep[c]&&(d=rep[c],e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));return e=0===g.length?"{}":gap?"{\n"+gap+g.join(",\n"+gap)+"\n"+h+"}":"{"+g.join(",")+"}",gap=h,e}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;"function"!=typeof JSON.stringify&&(JSON.stringify=function(a,b,c){var d;if(gap="",indent="","number"==typeof c)for(d=0;c>d;d+=1)indent+=" ";else"string"==typeof c&&(indent=c);if(rep=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return str("",{"":a})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&"object"==typeof e)for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),void 0!==d?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),browserify_shim__define__module__export__("undefined"!=typeof JSON?JSON:window.JSON)}.call(global,void 0,void 0,void 0,void 0,function(a){module.exports=a})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(a,b){function c(a,b,c){null!=a&&("number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))}function d(){return new c(null)}function e(a,b,c,d,e,f){for(;--f>=0;){var g=b*this[a++]+c[d]+e;e=Math.floor(g/67108864),c[d++]=67108863&g}return e}function f(a,b,c,d,e,f){for(var g=32767&b,h=b>>15;--f>=0;){var i=32767&this[a],j=this[a++]>>15,k=h*i+j*g;i=g*i+((32767&k)<<15)+c[d]+(1073741823&e),e=(i>>>30)+(k>>>15)+h*j+(e>>>30),c[d++]=1073741823&i}return e}function g(a,b,c,d,e,f){for(var g=16383&b,h=b>>14;--f>=0;){var i=16383&this[a],j=this[a++]>>14,k=h*i+j*g;i=g*i+((16383&k)<<14)+c[d]+e,e=(i>>28)+(k>>14)+h*j,c[d++]=268435455&i}return e}function h(a){return nb.charAt(a)}function i(a,b){var c=ob[a.charCodeAt(b)];return null==c?-1:c}function j(a){for(var b=this.t-1;b>=0;--b)a[b]=this[b];a.t=this.t,a.s=this.s}function k(a){this.t=1,this.s=0>a?-1:0,a>0?this[0]=a:-1>a?this[0]=a+DV:this.t=0}function l(a){var b=d();return b.fromInt(a),b}function m(a,b){var d;if(16==b)d=4;else if(8==b)d=3;else if(256==b)d=8;else if(2==b)d=1;else if(32==b)d=5;else{if(4!=b)return void this.fromRadix(a,b);d=2}this.t=0,this.s=0;for(var e=a.length,f=!1,g=0;--e>=0;){var h=8==d?255&a[e]:i(a,e);0>h?"-"==a.charAt(e)&&(f=!0):(f=!1,0==g?this[this.t++]=h:g+d>this.DB?(this[this.t-1]|=(h&(1<>this.DB-g):this[this.t-1]|=h<=this.DB&&(g-=this.DB))}8==d&&0!=(128&a[0])&&(this.s=-1,g>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==a;)--this.t}function o(a){if(this.s<0)return"-"+this.negate().toString(a);var b;if(16==a)b=4;else if(8==a)b=3;else if(2==a)b=1;else if(32==a)b=5;else{if(4!=a)return this.toRadix(a);b=2}var c,d=(1<0)for(i>i)>0&&(e=!0,f=h(c));g>=0;)b>i?(c=(this[g]&(1<>(i+=this.DB-b)):(c=this[g]>>(i-=b)&d,0>=i&&(i+=this.DB,--g)),c>0&&(e=!0),e&&(f+=h(c));return e?f:"0"}function p(){var a=d();return c.ZERO.subTo(this,a),a}function q(){return this.s<0?this.negate():this}function r(a){var b=this.s-a.s;if(0!=b)return b;var c=this.t;if(b=c-a.t,0!=b)return this.s<0?-b:b;for(;--c>=0;)if(0!=(b=this[c]-a[c]))return b;return 0}function s(a){var b,c=1;return 0!=(b=a>>>16)&&(a=b,c+=16),0!=(b=a>>8)&&(a=b,c+=8),0!=(b=a>>4)&&(a=b,c+=4),0!=(b=a>>2)&&(a=b,c+=2),0!=(b=a>>1)&&(a=b,c+=1),c}function t(){return this.t<=0?0:this.DB*(this.t-1)+s(this[this.t-1]^this.s&this.DM)}function u(a,b){var c;for(c=this.t-1;c>=0;--c)b[c+a]=this[c];for(c=a-1;c>=0;--c)b[c]=0;b.t=this.t+a,b.s=this.s}function v(a,b){for(var c=a;c=0;--c)b[c+g+1]=this[c]>>e|h,h=(this[c]&f)<=0;--c)b[c]=0;b[g]=h,b.t=this.t+g+1,b.s=this.s,b.clamp()}function x(a,b){b.s=this.s;var c=Math.floor(a/this.DB);if(c>=this.t)return void(b.t=0);var d=a%this.DB,e=this.DB-d,f=(1<>d;for(var g=c+1;g>d;d>0&&(b[this.t-c-1]|=(this.s&f)<c;)d+=this[c]-a[c],b[c++]=d&this.DM,d>>=this.DB;if(a.t>=this.DB;d+=this.s}else{for(d+=this.s;c>=this.DB;d-=a.s}b.s=0>d?-1:0,-1>d?b[c++]=this.DV+d:d>0&&(b[c++]=d),b.t=c,b.clamp()}function z(a,b){var d=this.abs(),e=a.abs(),f=d.t;for(b.t=f+e.t;--f>=0;)b[f]=0;for(f=0;f=0;)a[c]=0;for(c=0;c=b.DV&&(a[c+b.t]-=b.DV,a[c+b.t+1]=1)}a.t>0&&(a[a.t-1]+=b.am(c,b[c],a,2*c,0,1)),a.s=0,a.clamp()}function B(a,b,e){var f=a.abs();if(!(f.t<=0)){var g=this.abs();if(g.t0?(f.lShiftTo(k,h),g.lShiftTo(k,e)):(f.copyTo(h),g.copyTo(e));var l=h.t,m=h[l-1];if(0!=m){var n=m*(1<1?h[l-2]>>this.F2:0),o=this.FV/n,p=(1<=0&&(e[e.t++]=1,e.subTo(u,e)),c.ONE.dlShiftTo(l,u),u.subTo(h,h);h.t=0;){var v=e[--r]==m?this.DM:Math.floor(e[r]*o+(e[r-1]+q)*p);if((e[r]+=h.am(0,v,e,t,0,l))0&&e.rShiftTo(k,e),0>i&&c.ZERO.subTo(e,e)}}}function C(a){var b=d();return this.abs().divRemTo(a,null,b),this.s<0&&b.compareTo(c.ZERO)>0&&a.subTo(b,b),b}function D(a){this.m=a}function E(a){return a.s<0||a.compareTo(this.m)>=0?a.mod(this.m):a}function F(a){return a}function G(a){a.divRemTo(this.m,null,a)}function H(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function I(a,b){a.squareTo(b),this.reduce(b)}function J(){if(this.t<1)return 0;var a=this[0];if(0==(1&a))return 0;var b=3&a;return b=b*(2-(15&a)*b)&15,b=b*(2-(255&a)*b)&255,b=b*(2-((65535&a)*b&65535))&65535,b=b*(2-a*b%this.DV)%this.DV,b>0?this.DV-b:-b}function K(a){this.m=a,this.mp=a.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(b,b),b}function M(a){var b=d();return a.copyTo(b),this.reduce(b),b}function N(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var b=0;b>15)*this.mpl&this.um)<<15)&a.DM;for(c=b+this.m.t,a[c]+=this.m.am(0,d,a,b,0,this.m.t);a[c]>=a.DV;)a[c]-=a.DV,a[++c]++}a.clamp(),a.drShiftTo(this.m.t,a),a.compareTo(this.m)>=0&&a.subTo(this.m,a)}function O(a,b){a.squareTo(b),this.reduce(b)}function P(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function Q(){return 0==(this.t>0?1&this[0]:this.s)}function R(a,b){if(a>4294967295||1>a)return c.ONE;var e=d(),f=d(),g=b.convert(this),h=s(a)-1;for(g.copyTo(e);--h>=0;)if(b.sqrTo(e,f),(a&1<0)b.mulTo(f,g,e);else{var i=e;e=f,f=i}return b.revert(e)}function S(a,b){var c;return c=256>a||b.isEven()?new D(b):new K(b),this.exp(a,c)}function T(){this.i=0,this.j=0,this.S=new Array}function U(a){var b,c,d;for(b=0;256>b;++b)this.S[b]=b;for(c=0,b=0;256>b;++b)c=c+this.S[b]+a[b%a.length]&255,d=this.S[b],this.S[b]=this.S[c],this.S[c]=d;this.i=0,this.j=0}function V(){var a;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,a=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=a,this.S[a+this.S[this.i]&255]}function W(){return new T}function X(a){qb[rb++]^=255&a,qb[rb++]^=a>>8&255,qb[rb++]^=a>>16&255,qb[rb++]^=a>>24&255,rb>=sb&&(rb-=sb)}function Y(){X((new Date).getTime())}function Z(){if(null==pb){for(Y(),pb=W(),pb.init(qb),rb=0;rba?"0"+a.toString(16):a.toString(16)}function cb(a,b){if(b=0&&b>0;){var f=a.charCodeAt(e--);128>f?d[--b]=f:f>127&&2048>f?(d[--b]=63&f|128,d[--b]=f>>6|192):(d[--b]=63&f|128,d[--b]=f>>6&63|128,d[--b]=f>>12|224)}d[--b]=0;for(var g=new _,h=new Array;b>2;){for(h[0]=0;0==h[0];)g.nextBytes(h);d[--b]=h[0]}return d[--b]=2,d[--b]=0,new c(d)}function db(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function eb(a,b){null!=a&&null!=b&&a.length>0&&b.length>0?(this.n=ab(a,16),this.e=parseInt(b,16)):alert("Invalid RSA public key")}function fb(a){return a.modPowInt(this.e,this.n)}function gb(a){var b=cb(a,this.n.bitLength()+7>>3);if(null==b)return null;var c=this.doPublic(b);if(null==c)return null;var d=c.toString(16);return 0==(1&d.length)?d:"0"+d}var hb,ib=0xdeadbeefcafe,jb=15715070==(16777215&ib);jb&&"Microsoft Internet Explorer"==navigator.appName?(c.prototype.am=f,hb=30):jb&&"Netscape"!=navigator.appName?(c.prototype.am=e,hb=26):(c.prototype.am=g,hb=28),c.prototype.DB=hb,c.prototype.DM=(1<=mb;++mb)ob[lb++]=mb;for(lb="a".charCodeAt(0),mb=10;36>mb;++mb)ob[lb++]=mb;for(lb="A".charCodeAt(0),mb=10;36>mb;++mb)ob[lb++]=mb;D.prototype.convert=E,D.prototype.revert=F,D.prototype.reduce=G,D.prototype.mulTo=H,D.prototype.sqrTo=I,K.prototype.convert=L,K.prototype.revert=M,K.prototype.reduce=N,K.prototype.mulTo=P,K.prototype.sqrTo=O,c.prototype.copyTo=j,c.prototype.fromInt=k,c.prototype.fromString=m,c.prototype.clamp=n,c.prototype.dlShiftTo=u,c.prototype.drShiftTo=v,c.prototype.lShiftTo=w,c.prototype.rShiftTo=x,c.prototype.subTo=y,c.prototype.multiplyTo=z,c.prototype.squareTo=A,c.prototype.divRemTo=B,c.prototype.invDigit=J,c.prototype.isEven=Q,c.prototype.exp=R,c.prototype.toString=o,c.prototype.negate=p,c.prototype.abs=q,c.prototype.compareTo=r,c.prototype.bitLength=t,c.prototype.mod=C,c.prototype.modPowInt=S,c.ZERO=l(0),c.ONE=l(1),T.prototype.init=U,T.prototype.next=V;var pb,qb,rb,sb=256;if(null==qb){qb=new Array,rb=0;var tb;if("Netscape"==navigator.appName&&navigator.appVersion<"5"&&window.crypto){var ub=window.crypto.random(32);for(tb=0;tbrb;)tb=Math.floor(65536*Math.random()),qb[rb++]=tb>>>8,qb[rb++]=255&tb;rb=0,Y()}_.prototype.nextBytes=$,db.prototype.doPublic=fb,db.prototype.setPublic=eb,db.prototype.encrypt=gb,b.exports={SecureRandom:_,byte2Hex:bb,RSAKey:db}},{}],5:[function(a,b){function c(a,b){return m.isUndefined(b)?""+b:!m.isNumber(b)||!isNaN(b)&&isFinite(b)?m.isFunction(b)||m.isRegExp(b)?b.toString():b:b.toString()}function d(a,b){return m.isString(a)?a.length=0;d--)if(e[d]!=f[d])return!1;for(d=e.length-1;d>=0;d--)if(c=e[d],!h(a[c],b[c]))return!1;return!0}function k(a,b){return a&&b?"[object RegExp]"==Object.prototype.toString.call(b)?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function l(a,b,c,d){var e;m.isString(c)&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f(e,c,"Missing expected exception"+d),!a&&k(e,c)&&f(e,c,"Got unwanted exception"+d),a&&e&&c&&!k(e,c)||!a&&e)throw e}var m=a("util/"),n=Array.prototype.slice,o=Object.prototype.hasOwnProperty,p=b.exports=g;p.AssertionError=function(a){this.name="AssertionError",this.actual=a.actual,this.expected=a.expected,this.operator=a.operator,a.message?(this.message=a.message,this.generatedMessage=!1):(this.message=e(this),this.generatedMessage=!0);var b=a.stackStartFunction||f;if(Error.captureStackTrace)Error.captureStackTrace(this,b);else{var c=new Error;if(c.stack){var d=c.stack,g=b.name,h=d.indexOf("\n"+g);if(h>=0){var i=d.indexOf("\n",h+1);d=d.substring(i+1)}this.stack=d}}},m.inherits(p.AssertionError,Error),p.fail=f,p.ok=g,p.equal=function(a,b,c){a!=b&&f(a,b,c,"==",p.equal)},p.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",p.notEqual)},p.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",p.deepEqual)},p.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",p.notDeepEqual)},p.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",p.strictEqual)},p.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",p.notStrictEqual)},p.throws=function(){l.apply(this,[!0].concat(n.call(arguments)))},p.doesNotThrow=function(){l.apply(this,[!1].concat(n.call(arguments)))},p.ifError=function(a){if(a)throw a};var q=Object.keys||function(a){var b=[];for(var c in a)o.call(a,c)&&b.push(c);return b}},{"util/":7}],6:[function(a,b){b.exports=function(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.readUInt8}},{}],7:[function(a,b,c){(function(b,d){function e(a,b){var d={seen:[],stylize:g};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),p(b)?d.showHidden=b:b&&c._extend(d,b),v(d.showHidden)&&(d.showHidden=!1),v(d.depth)&&(d.depth=2),v(d.colors)&&(d.colors=!1),v(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=f),i(d,a,d.depth)}function f(a,b){var c=e.styles[b];return c?"["+e.colors[c][0]+"m"+a+"["+e.colors[c][1]+"m":a}function g(a){return a}function h(a){var b={};return a.forEach(function(a){b[a]=!0}),b}function i(a,b,d){if(a.customInspect&&b&&A(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d,a);return t(e)||(e=i(a,e,d)),e}var f=j(a,b);if(f)return f;var g=Object.keys(b),p=h(g);if(a.showHidden&&(g=Object.getOwnPropertyNames(b)),z(b)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return k(b);if(0===g.length){if(A(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(w(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(y(b))return a.stylize(Date.prototype.toString.call(b),"date");if(z(b))return k(b)}var r="",s=!1,u=["{","}"];if(o(b)&&(s=!0,u=["[","]"]),A(b)){var v=b.name?": "+b.name:"";r=" [Function"+v+"]"}if(w(b)&&(r=" "+RegExp.prototype.toString.call(b)),y(b)&&(r=" "+Date.prototype.toUTCString.call(b)),z(b)&&(r=" "+k(b)),0===g.length&&(!s||0==b.length))return u[0]+r+u[1];if(0>d)return w(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var x;return x=s?l(a,b,d,p,g):g.map(function(c){return m(a,b,d,p,c,s)}),a.seen.pop(),n(x,r,u)}function j(a,b){if(v(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return s(b)?a.stylize(""+b,"number"):p(b)?a.stylize(""+b,"boolean"):q(b)?a.stylize("null","null"):void 0}function k(a){return"["+Error.prototype.toString.call(a)+"]"}function l(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)f.push(F(b,String(g))?m(a,b,c,d,String(g),!0):"");return e.forEach(function(e){e.match(/^\d+$/)||f.push(m(a,b,c,d,e,!0))}),f}function m(a,b,c,d,e,f){var g,h,j;if(j=Object.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?h=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(h=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),h||(a.seen.indexOf(j.value)<0?(h=q(c)?i(a,j.value,null):i(a,j.value,c-1),h.indexOf("\n")>-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),v(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function n(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function o(a){return Array.isArray(a)}function p(a){return"boolean"==typeof a}function q(a){return null===a}function r(a){return null==a}function s(a){return"number"==typeof a}function t(a){return"string"==typeof a}function u(a){return"symbol"==typeof a}function v(a){return void 0===a}function w(a){return x(a)&&"[object RegExp]"===C(a)}function x(a){return"object"==typeof a&&null!==a}function y(a){return x(a)&&"[object Date]"===C(a)}function z(a){return x(a)&&("[object Error]"===C(a)||a instanceof Error)}function A(a){return"function"==typeof a}function B(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),J[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=/%[sdj%]/g;c.format=function(a){if(!t(a)){for(var b=[],c=0;c=f)return a;switch(a){case"%s":return String(d[c++]);case"%d":return Number(d[c++]);case"%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),h=d[c];f>c;h=d[++c])g+=q(h)||!x(h)?" "+h:" "+e(h);return g},c.deprecate=function(a,e){function f(){if(!g){if(b.throwDeprecation)throw new Error(e);b.traceDeprecation?console.trace(e):console.error(e),g=!0}return a.apply(this,arguments)}if(v(d.process))return function(){return c.deprecate(a,e).apply(this,arguments)};if(b.noDeprecation===!0)return a;var g=!1;return f};var H,I={};c.debuglog=function(a){if(v(H)&&(H=b.env.NODE_DEBUG||""),a=a.toUpperCase(),!I[a])if(new RegExp("\\b"+a+"\\b","i").test(H)){var d=b.pid;I[a]=function(){var b=c.format.apply(c,arguments);console.error("%s %d: %s",a,d,b)}}else I[a]=function(){};return I[a]},c.inspect=e,e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=o,c.isBoolean=p,c.isNull=q,c.isNullOrUndefined=r,c.isNumber=s,c.isString=t,c.isSymbol=u,c.isUndefined=v,c.isRegExp=w,c.isObject=x,c.isDate=y,c.isError=z,c.isFunction=A,c.isPrimitive=B,c.isBuffer=a("./support/isBuffer");var J=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=a("inherits"),c._extend=function(a,b){if(!b||!x(b))return a;for(var c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}}).call(this,a("/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":6,"/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,inherits:10}],8:[function(a,b){(function(c){function d(){}function e(){m.log.apply(m,arguments)}function f(){m.log.apply(m,arguments)}function g(){m.warn.apply(m,arguments)}function h(a){p[a]=Date.now()}function i(a){var b=p[a];if(!b)throw new Error("No such label: "+a);var c=Date.now()-b;m.log(a+": "+c+"ms")}function j(){var a=new Error;a.name="Trace",a.message=n.format.apply(null,arguments),m.error(a.stack)}function k(a){m.log(n.inspect(a)+"\n")}function l(a){if(!a){var b=o.call(arguments,1);l.ok(!1,n.format.apply(null,b))}}var m,n=a("util"),l=a("assert"),o=Array.prototype.slice,p={};m="undefined"!=typeof c&&c.console?c.console:"undefined"!=typeof window&&window.console?window.console:{};for(var q=[[d,"log"],[e,"info"],[f,"warn"],[g,"error"],[h,"time"],[i,"timeEnd"],[j,"trace"],[k,"dir"],[l,"assert"]],r=0;ra||isNaN(a))throw TypeError("n must be a positive number"); +return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,h,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||f(this._events.error)&&!this._events.error.length))throw b=arguments[1],b instanceof Error?b:TypeError('Uncaught, unspecified "error" event.');if(c=this._events[a],g(c))return!1;if(d(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];c.apply(this,h)}else if(f(c)){for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];for(j=c.slice(),e=j.length,i=0;e>i;i++)j[i].apply(this,h)}return!0},c.prototype.addListener=function(a,b){var e;if(!d(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d(b.listener)?b.listener:b),this._events[a]?f(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,f(this._events[a])&&!this._events[a].warned){var e;e=g(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),e||(e=!0,b.apply(this,arguments))}if(!d(b))throw TypeError("listener must be a function");var e=!1;return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,g,h;if(!d(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],g=c.length,e=-1,c===b||d(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(f(c)){for(h=g;h-->0;)if(c[h]===b||c[h].listener&&c[h].listener===b){e=h;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d(a._events[b])?1:a._events[b].length:0}},{}],10:[function(a,b){b.exports="function"==typeof Object.create?function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],11:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],12:[function(a,b){b.exports=a(6)},{}],13:[function(a,b){b.exports=a(7)},{"./support/isBuffer":12,"/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,inherits:10}],14:[function(a,b){!function(a){var c="undefined";!function(a,c){"undefined"!=typeof b?b.exports=c():"function"==typeof define&&"object"==typeof define.amd?define(c):this[a]=c()}("log",function(){function b(b){return typeof console===c?l:console[b]===a?console.log!==a?d(console,"log"):l:d(console,b)}function d(b,c){var d=b[c];if(d.bind!==a)return b[c].bind(b);if(Function.prototype.bind===a)return e(d,b);try{return Function.prototype.bind.call(b[c],b)}catch(f){return e(d,b)}}function e(a,b){return function(){Function.prototype.apply.apply(a,[b,arguments])}}function f(a){for(var b=0;b=0&&d<=k.levels.SILENT){if(i(d),d===k.levels.SILENT)return void f(function(){return l});if(typeof console===c)return f(function(a){return function(){typeof console!==c&&(k.setLevel(d),k[a].apply(k,arguments))}}),"No console available for logging";f(function(a){return d<=k.levels[a.toUpperCase()]?b(a):l})}else{if("string"!=typeof d||k.levels[d.toUpperCase()]===a)throw"log.setLevel() called with invalid level: "+d;k.setLevel(k.levels[d.toUpperCase()])}},k.enableAll=function(){k.setLevel(k.levels.TRACE)},k.disableAll=function(){k.setLevel(k.levels.SILENT)},j(),k})}()},{}],15:[function(a,b){var c=Object.prototype.toString;b.exports=function(a){switch(c.call(a)){case"[object Function]":return"function";case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object String]":return"string"}if("object"==typeof a&&a&&"number"==typeof a.length)try{if("function"==typeof a.callee)return"arguments"}catch(b){if(b instanceof TypeError)return"arguments"}return null===a?"null":void 0===a?"undefined":a&&1===a.nodeType?"element":a===Object(a)?"object":typeof a}},{}],16:[function(a,b){var c=a("./modules/constants"),d=a("./modules/logger"),e=a("./modules/ajax"),f=a("./modules/events"),g=a("./modules/waitForCloud"),h=a("./modules/api_act"),i=a("./modules/api_auth"),j=a("./modules/api_sec"),k=a("./modules/api_hash"),l=a("./modules/sync-cli"),m=a("./modules/api_mbaas"),n=a("./modules/api_cloud"),o=a("./modules/fhparams"),p=a("./modules/appProps"),q=a("./modules/device"),r=function(a,b){f.addListener(a,b),a===c.INIT_EVENT&&(g.isReady()?b(null,{host:g.getCloudHostUrl()}):g.getInitError()&&b(g.getInitError()))},s=function(a,b){a===c.INIT_EVENT&&g.isReady()?b(null,{host:g.getCloudHostUrl()}):a===c.INIT_EVENT&&g.getInitError()?b(g.getInitError()):f.once(a,b)},t=function(a,b,c){d.warn("$fh.init will be deprecated soon"),g.ready(function(a,d){if(a){if("function"==typeof c)return c(a)}else"function"==typeof b&&b(d.host)})},u=window.$fh||{};u.init=t,u.act=h,u.auth=i,u.cloud=n,u.sec=j,u.hash=k,u.sync=l,u.ajax=u.__ajax=e,u.mbaas=m,u._getDeviceId=q.getDeviceId,u.fh_timeout=6e4,u.getCloudURL=function(){return g.getCloudHostUrl()},u.getFHParams=function(){return o.buildFHParams()},u.addListener=r,u.on=r,u.once=s;for(var v=["removeListener","removeAllListeners","setMaxListeners","listeners","emit"],w=0;w=0&&(a=!0),a}function m(a){var b=null;return window.XMLHttpRequest&&(b=new XMLHttpRequest),l()&&a===!0&&"undefined"!=typeof window.XDomainRequest&&(b=new v(new XDomainRequest)),"undefined"!=typeof Titanium&&(b=Titanium.Network.createHTTPClient({timeout:I.settings.timeout})),b}function n(a){return a&&(a==G?"html":a==F?"json":D.test(a)?"script":E.test(a)&&"xml")||"text"}function o(a,b){return(a+"&"+b).replace(/[&?]{1,2}/,"?")}function p(a){"object"===t(a.data)&&("function"==typeof a.data.append?a.formdata=!0:a.data=r(a.data)),!a.data||a.type&&"GET"!=a.type.toUpperCase()||(a.url=o(a.url,a.data))}function q(a,b,c,d){var e="array"===t(b);for(var f in b){var g=b[f];d&&(f=c?d:d+"["+(e?"":f)+"]"),!d&&e?a.add(g.name,g.value):(c?"array"===t(g):"object"===t(g))?q(a,g,c,f):a.add(f,g)}}function r(a,b){var c=[];return c.add=function(a,b){this.push(J(a)+"="+J(b))},q(c,a,b),c.join("&").replace("%20","+")}function s(a){var b=Array.prototype.slice;return b.call(arguments,1).forEach(function(b){for(z in b)void 0!==b[z]&&(a[z]=b[z])}),a}var t,u=a("./events"),v=a("./XDomainRequestWrapper"),w=a("./logger");try{t=a("type-of")}catch(x){var y=a;t=y("type")}var z,A,B=0,C=window.document,D=/^(?:text|application)\/javascript/i,E=/^(?:text|application)\/xml/i,F="application/json",G="text/html",H=/^\s*$/,I=b.exports=function(a){var b=s({},a||{});window&&window.$fh&&"number"==typeof window.$fh.fh_timeout&&(I.settings.timeout=window.$fh.fh_timeout);for(z in I.settings)void 0===b[z]&&(b[z]=I.settings[z]);e(b),b.crossDomain||(b.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(b.url)&&(RegExp.$1!=window.location.protocol||RegExp.$2!=window.location.host));var c=b.dataType,d=/=\?/.test(b.url);if("jsonp"==c||d)return d||(b.url=o(b.url,(b.jsonp?b.jsonp:"_callback")+"=?")),I.JSONP(b);b.url||(b.url=window.location.toString()),p(b);var f,j=b.accepts[c],l={},m=/^([\w-]+:)\/\//.test(b.url)?RegExp.$1:window.location.protocol,q=b.xhr(b.crossDomain);b.crossDomain||(l["X-Requested-With"]="XMLHttpRequest"),j&&(l.Accept=j,j.indexOf(",")>-1&&(j=j.split(",",2)[0]),q.overrideMimeType&&q.overrideMimeType(j)),(b.contentType||b.data&&!b.formdata&&"GET"!=b.type.toUpperCase())&&(l["Content-Type"]=b.contentType||"application/x-www-form-urlencoded"),b.headers=s(l,b.headers||{}),"undefined"!=typeof Titanium&&q.setOnerror(function(){f&&(clearTimeout(f),i(null,"error",q,b))}),q.onreadystatechange=function(){if(4==q.readyState){clearTimeout(f),f=void 0;var a,d=!1;if(b.tryJSONP&&0===q.status&&b.crossDomain&&!q.isTimeout&&"file:"!=m)return w.debug("retry ajax call with jsonp"),b.type="GET",b.dataType="jsonp",b.data="_jsonpdata="+b.data,I(b);if(q.status>=200&&q.status<300||304==q.status||0==q.status&&"file:"==m){c=c||n(q.getResponseHeader("content-type")),a=q.responseText,w.debug("ajax response :: status = "+q.status+" :: body = "+a);try{"script"==c?(1,eval)(a):"xml"==c?a=q.responseXML:"json"==c&&(a=H.test(a)?null:JSON.parse(a))}catch(e){d=e}d?(w.debug("ajax error",d),i(d,"parsererror",q,b)):h(a,q,b)}else i(null,"error",q,b)}};var r="async"in b?b.async:!0;w.debug("ajax call settings",b),q.open(b.type,b.url,r);for(A in b.headers)q.setRequestHeader(A,b.headers[A]);return g(q,b)===!1?(w.debug("ajax call is aborted due to ajaxBeforeSend"),q.abort(),!1):(b.timeout>0&&(f=setTimeout(function(){w.debug("ajax call timed out"),q.onreadystatechange=k,q.abort(),q.isTimeout=!0,i(null,"timeout",q,b)},b.timeout)),q.send(b.data?b.data:null),q)};I.active=0,I.JSONP=function(a){if(!("type"in a))return I(a);var b,c="jsonp"+ ++B,d=C.createElement("script"),e=function(){c in window&&(window[c]=k),j("abort",f,a)},f={abort:e},g=C.getElementsByTagName("head")[0]||C.documentElement;return a.error&&(d.onerror=function(){f.abort(),a.error()}),window[c]=function(d){clearTimeout(b),b=void 0,delete window[c],h(d,f,a)},p(a),d.src=a.url.replace(/=\?/,"="+c),g.insertBefore(d,g.firstChild),a.timeout>0&&(b=setTimeout(function(){f.abort(),j("timeout",f,a)},a.timeout)),f},I.settings={type:"GET",beforeSend:k,success:k,error:k,complete:k,context:null,global:!0,xhr:m,accepts:{script:"text/javascript, application/javascript",json:F,xml:"application/xml, text/xml",html:G,text:"text/plain"},crossDomain:!1},I.get=function(a,b){return I({url:a,success:b})},I.post=function(a,b,c,d){return"function"===t(b)&&(d=d||c,c=b,b=null),I({type:"POST",url:a,data:b,success:c,dataType:d})},I.getJSON=function(a,b){return I({url:a,success:b,dataType:"json"})};var J=encodeURIComponent},{"./XDomainRequestWrapper":17,"./events":28,"./logger":35,"type-of":15}],19:[function(a,b){function c(a,b,c){var d=e.getCloudHost(),k=d.getActUrl(a.act),l=a.req||{};return l=f.addFHParams(l),g({url:k,tryJSONP:!0,type:"POST",dataType:"json",data:h.stringify(l),contentType:"application/json",timeout:a.timeout||j.timeout,success:b,error:function(a,b,d){return i(c,a,b,d)}})}var d=a("./logger"),e=a("./waitForCloud"),f=a("./fhparams"),g=a("./ajax"),h=a("JSON"),i=a("./handleError"),j=a("./appProps");b.exports=function(a,b,f){return d.debug("act is called"),f||(f=function(a,b){d.debug(a+":"+h.stringify(b))}),a.act?void e.ready(function(e){return d.debug("Calling fhact now"),e?f(e.message,e):void c(a,b,f)}):f("act_no_action",{})}},{"./ajax":18,"./appProps":"zDENqi","./fhparams":29,"./handleError":30,"./logger":35,"./waitForCloud":49,JSON:3}],20:[function(a,b){var c=a("./logger"),d=a("./waitForCloud"),e=a("./fhparams"),f=a("./ajax"),g=a("JSON"),h=a("./handleError"),i=a("./device"),j=a("./constants"),k=a("./checkAuth"),l=a("./appProps");b.exports=function(a,b,m){return m||(m=function(a,b){c.debug(a+":"+g.stringify(b))}),a.policyId?a.clientToken?void d.ready(function(c){if(c)return m(c.message,c);var d={};d.policyId=a.policyId,d.clientToken=a.clientToken,a.endRedirectUrl&&(d.endRedirectUrl=a.endRedirectUrl,a.authCallback&&(d.endRedirectUrl+=(/\?/.test(d.endRedirectUrl)?"&":"?")+"_fhAuthCallback="+a.authCallback)),d.params={},a.params&&(d.params=a.params);var n=a.endRedirectUrl||"status=complete";d.device=i.getDeviceId();var o=l.getAppProps(),p=o.host+j.boxprefix+"admin/authpolicy/auth";d=e.addFHParams(d),f({url:p,type:"POST",tryJSONP:!0,data:g.stringify(d),dataType:"json",contentType:"application/json",timeout:a.timeout||o.timeout,success:function(a){k.handleAuthResponse(n,a,b,m)},error:function(a,b,c){h(m,a,b,c)}})}):m("auth_no_clientToken",{}):m("auth_no_policyId",{})}},{"./ajax":18,"./appProps":"zDENqi","./checkAuth":25,"./constants":26,"./device":27,"./fhparams":29,"./handleError":30,"./logger":35,"./waitForCloud":49,JSON:3}],21:[function(a,b){function c(a,b,c){var d=e.getCloudHost(),k=d.getCloudUrl(a.path),l=a.data||{};return l=f.addFHParams(l),g({url:k,type:a.method||"POST",dataType:a.dataType||"json",data:h.stringify(l),contentType:a.contentType||"application/json",timeout:a.timeout||j.timeout,success:b,error:function(a,b,d){return i(c,a,b,d)}})}var d=a("./logger"),e=a("./waitForCloud"),f=a("./fhparams"),g=a("./ajax"),h=a("JSON"),i=a("./handleError"),j=a("./appProps");b.exports=function(a,b,f){d.debug("cloud is called"),f||(f=function(a,b){d.debug(a+":"+h.stringify(b))}),e.ready(function(e){return d.debug("Calling fhact now"),e?f(e.message,e):void c(a,b,f)})}},{"./ajax":18,"./appProps":"zDENqi","./fhparams":29,"./handleError":30,"./logger":35,"./waitForCloud":49,JSON:3}],22:[function(a,b){var c=a("./security/hash");b.exports=function(a,b,d){var e={};"undefined"==typeof a.algorithm&&(a.algorithm="MD5"),e.act="hash",e.params=a,c(e,b,d)}},{"./security/hash":41}],23:[function(a,b){var c=a("./logger"),d=a("./waitForCloud"),e=a("./fhparams"),f=a("./ajax"),g=a("JSON"),h=a("./handleError"),i=(a("./constants"),a("./appProps"));b.exports=function(a,b,j){c.debug("mbaas is called."),j||(j=function(a,b){console.debug(a+":"+g.stringify(b))});var k=a.service,l=a.params;d.ready(function(m){if(c.debug("Calling mbaas now"),m)return j(m.message,m);var n=d.getCloudHost(),o=n.getMBAASUrl(k);return l=e.addFHParams(l),f({url:o,tryJSONP:!0,type:"POST",dataType:"json",data:g.stringify(l),contentType:"application/json",timeout:a.timeout||i.timeout,success:b,error:function(a,b,c){return h(j,a,b,c)}})})}},{"./ajax":18,"./appProps":"zDENqi","./constants":26,"./fhparams":29,"./handleError":30,"./logger":35,"./waitForCloud":49,JSON:3}],24:[function(a,b){var c=a("./security/aes-keygen"),d=a("./security/aes-node"),e=a("./security/rsa-node"),f=a("./security/hash");b.exports=function(a,b,g){return a.act?a.params?a.params.algorithm?(a.params.algorithm=a.params.algorithm.toLowerCase(),"hash"===a.act?f(a,b,g):"encrypt"===a.act?"aes"===a.params.algorithm?d.encrypt(a,b,g):"rsa"===a.params.algorithm?e.encrypt(a,b,g):g("encrypt_bad_algorithm:"+a.params.algorithm,{},a):"decrypt"===a.act?"aes"===a.params.algorithm?d.decrypt(a,b,g):g("decrypt_bad_algorithm:"+a.params.algorithm,{},a):"keygen"===a.act?"aes"===a.params.algorithm?c(a,b,g):g("keygen_bad_algorithm:"+a.params.algorithm,{},a):void 0):void g("no_params_algorithm",{},a):void g("no_params",{},a):void g("bad_act",{},a)}},{"./security/aes-keygen":39,"./security/aes-node":40,"./security/hash":41,"./security/rsa-node":42}],25:[function(a,b){var c=a("./logger"),d=a("./queryMap"),e=a("JSON"),f=a("./fhparams"),g=function(a){if(/\_fhAuthCallback/.test(a)){var b=d(a);if(b){var c=b._fhAuthCallback;if(c)if(b.result&&"success"===b.result){var g={sessionToken:b.fh_auth_session,authResponse:e.parse(decodeURIComponent(decodeURIComponent(b.authResponse)))};f.setAuthSessionToken(b.fh_auth_session),window[c](null,g)}else window[c]({message:b.message})}}},h=function(a,b,g,h){if(b.status&&"ok"===b.status){var i=function(a){a.sessionToken&&f.setAuthSessionToken(a.sessionToken),g(a)};if(b.url){var j=null,k=function(b){if(b.indexOf(a)>-1){j&&j.close();var c=d(b);if(c)if(c.result&&"success"===c.result){var f={sessionToken:c.fh_auth_session,authResponse:e.parse(decodeURIComponent(decodeURIComponent(c.authResponse)))};i(f)}else h&&h("auth_failed",{message:c.message});else h&&h("auth_failed",{message:c.message})}};if(window.PhoneGap||window.cordova)if(window.plugins&&window.plugins.childBrowser)"function"==typeof window.plugins.childBrowser.showWebPage&&(window.plugins.childBrowser.onLocationChange=k,window.plugins.childBrowser.showWebPage(b.url),j=window.plugins.childBrowser);else try{j=window.open(b.url,"_blank","location=yes"),j.addEventListener("loadstart",function(a){k(a.url)})}catch(l){c.info("InAppBrowser plugin is not intalled."),i(b)}else document.location.href=b.url}else i(b)}else h&&h("auth_failed",b)};window.addEventListener?window.addEventListener("load",function(){g(window.location.href)},!1):window.attachEvent&&window.attachEvent("onload",function(){g(window.location.href)}),b.exports={handleAuthResponse:h}},{"./fhparams":29,"./logger":35,"./queryMap":37,JSON:3}],26:[function(a,b){b.exports={boxprefix:"/box/srv/1.1/",sdk_version:"2.0.17-alpha",config_js:"fhconfig.json",INIT_EVENT:"fhinit"}},{}],27:[function(a,b){var c=a("./cookies"),d=a("./uuid"),e=a("./logger");b.exports={getDeviceId:function(){if("undefined"!=typeof window.fhdevice&&"undefined"!=typeof window.fhdevice.uuid)return window.fhdevice.uuid;if("undefined"!=typeof window.device&&"undefined"!=typeof window.device.uuid)return window.device.uuid;if("undefined"!=typeof navigator.device&&"undefined"!=typeof navigator.device.uuid)return navigator.device.uuid;var a="mock_uuid",b=c.readCookieValue(a);return null==b&&(b=d.createUUID(),c.createCookie(a,b)),b},getCuidMap:function(){return"undefined"!=typeof window.fhdevice&&"undefined"!=typeof window.fhdevice.cuidMap?window.fhdevice.cuidMap:"undefined"!=typeof window.device&&"undefined"!=typeof window.device.cuidMap?window.device.cuidMap:"undefined"!=typeof navigator.device&&"undefined"!=typeof navigator.device.cuidMap?navigator.device.cuidMap:null},getDestination:function(){var b=null,c=a("./platformsMap"),d=navigator.userAgent,f=document.location.search.split("fh_destination_code=");return f.length>1?b=f[1]:"undefined"!=typeof window.fh_destination_code?b=window.fh_destination_code:c.forEach(function(a){a.test.forEach(function(c){d.indexOf(c)>-1&&(b=a.destination)})}),null==b&&(b="web"),e.debug("destination = "+b),b}}},{"./cookies":"RdeKcl","./logger":35,"./platformsMap":36,"./uuid":48}],28:[function(a,b){var c=a("events").EventEmitter,d=new c;d.setMaxListeners(0),b.exports=d},{events:9}],29:[function(a,b){var c=a("./device"),d=a("./sdkversion"),e=a("./appProps"),f=a("./logger"),g=null,h=null,i=function(){if(g)return g;var a={};a.cuid=c.getDeviceId(),a.cuidMap=c.getCuidMap(),a.destination=c.getDestination(),(window.device||navigator.device)&&(a.device=window.device||navigator.device),"undefined"!=typeof window.fh_app_version&&(a.app_version=fh_app_version),"undefined"!=typeof window.fh_project_version&&(a.project_version=fh_project_version),"undefined"!=typeof window.fh_project_app_version&&(a.project_app_version=fh_project_app_version),a.sdk_version=d(),h&&(a.sessionToken=h);var b=e.getAppProps();return b&&(a.appid=b.appid,a.appkey=b.appkey,a.projectid=b.projectid,a.analyticsTag=b.analyticsTag,a.connectiontag=b.connectiontag,b.init&&(a.init="string"==typeof b.init?JSON.parse(b.init):b.init)),g=a,f.debug("fhparams = ",g),a},j=function(a){var a=a||{};return a.__fh=i(),a},k=function(a){h=a};b.exports={buildFHParams:i,addFHParams:j,setAuthSessionToken:k}},{"./appProps":"zDENqi","./device":27,"./logger":35,"./sdkversion":38}],30:[function(a,b){var c=a("JSON");b.exports=function(a,b,d,e){var f,g=0;if(b)try{g=b.status;var h=c.parse(b.responseText);f=h.error||h.msg,f instanceof Array&&(f=f.join("\n"))}catch(i){f=b.responseText}a&&a(f,{status:g,message:d,error:e})}},{JSON:3}],31:[function(a,b){function c(a){var b=a;return"/"===b.charAt(b.length-1)&&(b=b.substring(0,b.length-1)),b}function d(a){var b=a;return b.length>1&&"/"===b.charAt(0)&&(b=b.substring(1,b.length)),b}function e(a){this.cloud_props=a,this.cloud_host=void 0,this.isLegacy=!1}var f=a("./constants"),g=a("./appProps");e.prototype.getHost=function(a){if(this.cloud_host)return this.cloud_host;var b,d;if(this.cloud_props&&this.cloud_props.hosts&&(b=this.cloud_props.hosts.url,"undefined"==typeof b)){var e=this.cloud_props.hosts.releaseCloudUrl;d=this.cloud_props.hosts.releaseCloudType,"undefined"!=typeof a&&a.indexOf("dev")>-1&&(e=this.cloud_props.hosts.debugCloudUrl,d=this.cloud_props.hosts.debugCloudType),b=e}return b=c(b),this.cloud_host=b,"fh"===d&&(this.isLegacy=!0),b},e.prototype.getActUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.isLegacy?this.cloud_host+f.boxprefix+"act/"+this.cloud_props.domain+"/"+b.appid+"/"+a+"/"+b.appid:this.cloud_host+"/cloud/"+a},e.prototype.getMBAASUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.cloud_host+"/mbaas/"+a},e.prototype.getCloudUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.cloud_host+"/"+d(a)},b.exports=e},{"./appProps":"zDENqi","./constants":26}],32:[function(a,b){var c=(a("./loadScript"),a("../../libs/generated/lawnchair")),d=a("./lawnchair-ext"),e=a("./constants"),f=a("./fhparams"),g=a("./ajax"),h=a("./handleError"),i=a("./logger"),j=a("JSON"),k=a("./security/hash"),l=a("./appProps"),m=function(a){l.load(function(b,c){return b?a(b):n(c,a)})},n=function(a,b){if(a.loglevel&&i.setLevel(a.loglevel),a.local){var l={domain:"local",firstTime:!1,hosts:{debugCloudType:"node",debugCloudUrl:a.host,releaseCloudType:"node",releaseCloudUrl:a.host,type:"cloud_nodejs",url:a.host},init:{trackId:"000000000000000000000000"},status:"ok"};return b(null,{cloud:l})}d.addAdapter(a,k);var m={name:"fh_init_storage",adapter:["dom","webkit-sqlite","window-name"],fail:function(a,b){var c="read/save from/to local storage failed msg:"+a+" err:"+b;return fail(c,{})}};"undefined"!=typeof Titanium&&(m.adapter=["titanium"]);var n=function(a,c,d,e){var k=f.buildFHParams();g({url:a,type:"POST",tryJSONP:!0,dataType:"json",contentType:"application/json",data:j.stringify(k),timeout:c.timeout,success:function(a){e&&e.save({key:"fh_init",value:a},function(){}),b&&b(null,{cloud:a})},error:function(a,c,e){var f="unknown";a&&(f=a.status+" - "+a.responseText),i.error("App init returned error : "+f),d?(i.info("Using cached host: "+j.stringify(d)),b&&b(null,{cloud:d})):(i.error("No cached host found. Init failed."),h(function(a,c){b&&b({error:c,message:a})},a,c,e))}})},o=null,p=a.host+e.boxprefix+"app/init";try{o=new c(m,function(){}),o.get("fh_init",function(b){var c=null;b&&null!==b.value&&"undefined"!=typeof b.value&&""!==b&&(b="string"==typeof b?j.parse(b):b,b.value="string"==typeof b.value?j.parse(b.value):b.value,a.init=b.value.init?b.value.init:"string"==typeof b.value?j.parse(b.value):b.value,b.value.hosts&&(c=b.value)),n(p,a,c,o)})}catch(q){n(p,a,null,null)}};b.exports={init:m,loadCloudProps:n}},{"../../libs/generated/lawnchair":2,"./ajax":18,"./appProps":"zDENqi","./constants":26,"./fhparams":29,"./handleError":30,"./lawnchair-ext":33,"./loadScript":34,"./logger":35,"./security/hash":41,JSON:3}],33:[function(a,b){var c=a("../../libs/generated/lawnchair"),d=function(a,b){function c(a){console&&console.log(a)}function d(d,e){d=a.appid+d,b({algorithm:"MD5",text:d},function(a){var b=a.hashvalue+".txt";return"undefined"==typeof navigator.externalstorage?(c("filenameForKey key="+d+" , Filename: "+b),e(b)):void navigator.externalstorage.enable(function(a){var c=b;return a.path&&(c=a.path,c.match(/\/$/)||(c+="/"),c+=b),b=c,e(b)},function(){return e(b)})})}var e=function(a,b){if(!console)throw a;console.log("error in file system adapter !",a,b)};return{valid:function(){return!!window.requestFileSystem},init:function(a,b){a&&"function"==typeof a.fail&&(e=a.fail),b&&this.fn(this.name,b).call(this,this)},keys:function(){throw"Currently not supported"},save:function(a,b){var c=a.key,f=a.val||a.value;d(c,function(a){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(a,{create:!0},function(a){a.createWriter(function(a){a.onwrite=function(){return b({key:c,val:f})},a.write(f)},function(){e("[save] Failed to create file writer")})},function(){e("[save] Failed to getFile")})},function(){e("[save] Failed to requestFileSystem")})})},batch:function(){throw"Currently not supported"},get:function(a,b){d(a,function(c){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(c,{},function(c){c.file(function(c){var d=new FileReader;d.onloadend=function(c){var d=c.target.result;try{d=decodeURIComponent(d)}catch(e){}return b({key:a,val:d})},d.readAsText(c)},function(){e("[load] Failed to getFile")})},function(){b({key:a,val:null})})},function(){e("[load] Failed to get fileSystem")})})},exists:function(a,b){d(a,function(a){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(c){c.root.getFile(a,{},function(){return b(!0)},function(){return b(!1)})})})},all:function(){throw"Currently not supported"},remove:function(a,b){d(a,function(c){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(c,{},function(c){c.remove(function(){return b({key:a,val:null})},function(){e("[remove] Failed to remove file")})},function(){e("[remove] Failed to getFile")})},function(){e("[remove] Failed to get fileSystem")})})},nuke:function(){throw"Currently not supported"}}},e=function(a,b){c.adapter("localFileStorage",d(a,b))};b.exports={addAdapter:e}},{"../../libs/generated/lawnchair":2}],34:[function(a,b){b.exports=function(a,b){var c,d=document.head||document.getElementsByTagName("head")[0]||document.documentElement;c=document.createElement("script"),c.async="async",c.src=a,c.type="text/javascript",c.onload=c.onreadystatechange=function(){(!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,d&&c.parentNode&&d.removeChild(c),c=void 0,b&&"function"==typeof b&&b())},d.insertBefore(c,d.firstChild)}},{}],35:[function(a,b){var c=(a("console"),a("loglevel"));c.setLevel("info"),b.exports=c},{console:8,loglevel:14}],36:[function(a,b){b.exports=[{destination:"ipad",test:["iPad"]},{destination:"iphone",test:["iPhone"]},{destination:"android",test:["Android"]},{destination:"blackberry",test:["BlackBerry","BB10","RIM Tablet OS"]},{destination:"windowsphone",test:["Windows Phone 8"]},{destination:"windowsphone7",test:["Windows Phone OS 7"]}]},{}],37:[function(a,b){b.exports=function(a){var b={},c=a.split("?");if(2===c.length){var d=c[1],e=d.split("&");b={};for(var f=0;f100&&(e/=8),"undefined"==typeof d?c("security library is not loaded."):b({algorithm:"AES",secretkey:f(e),iv:f(e)})};b.exports=g},{"../../../libs/rsa":4}],40:[function(a,b){var c=a("../../../libs/generated/crypto"),d=function(a,b,d){var e=["key","plaintext","iv"];if("aes"!==a.params.algorithm.toLowerCase())return d("encrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return d("no_params_"+g,{},a)}var h=c.AES.encrypt(a.params.plaintext,c.enc.Hex.parse(a.params.key),{iv:c.enc.Hex.parse(a.params.iv)});return cipher_text=c.enc.Hex.stringify(h.ciphertext),b({ciphertext:cipher_text})},e=function(a,b,d){var e=["key","ciphertext","iv"]; +if("aes"!==a.params.algorithm.toLowerCase())return d("decrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return d("no_params_"+g,{},a)}var h=c.enc.Hex.parse(a.params.ciphertext),i=c.enc.Base64.stringify(h),j=c.AES.decrypt(i,c.enc.Hex.parse(a.params.key),{iv:c.enc.Hex.parse(a.params.iv)});return plain_text=j.toString(c.enc.Utf8),b({plaintext:plain_text})};b.exports={encrypt:d,decrypt:e}},{"../../../libs/generated/crypto":1}],41:[function(a,b){var c=a("../../../libs/generated/crypto"),d=function(a,b,d){if(!a.params.text)return void d("hash_no_text",{},a);var e;if("md5"===a.params.algorithm.toLowerCase())e=c.MD5(a.params.text).toString(c.enc.Hex);else if("sha1"===a.params.algorithm.toLowerCase())e=c.SHA1(a.params.text).toString(c.enc.Hex);else if("sha256"===a.params.algorithm.toLowerCase())e=c.SHA256(a.params.text).toString(c.enc.Hex);else{if("sha512"!==a.params.algorithm.toLowerCase())return d("hash_unsupported_algorithm: "+a.params.algorithm);e=c.SHA512(a.params.text).toString(c.enc.Hex)}return b({hashvalue:e})};b.exports=d},{"../../../libs/generated/crypto":1}],42:[function(a,b){var c=a("../../../libs/rsa"),d=c.RSAKey,e=function(a,b,c){var e=["modulu","plaintext"];if("rsa"!==a.params.algorithm.toLowerCase())return c("encrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return c("no_params_"+g,{},a)}var h=new d;h.setPublic(a.params.modulu,"10001");var i=a.params.plaintext;return cipher_text=h.encrypt(i),b({ciphertext:cipher_text})};b.exports={encrypt:e}},{"../../../libs/rsa":4}],43:[function(a,b){var c=a("JSON"),d=a("./api_act"),e=a("./api_cloud"),f=a("../../libs/generated/crypto"),g=a("../../libs/generated/lawnchair"),h={defaults:{sync_frequency:10,auto_sync_local_updates:!0,notify_client_storage_failed:!0,notify_sync_started:!0,notify_sync_complete:!0,notify_offline_update:!0,notify_collision_detected:!0,notify_remote_update_failed:!0,notify_local_update_applied:!0,notify_remote_update_applied:!0,notify_delta_received:!0,notify_record_delta_received:!0,notify_sync_failed:!0,do_console_log:!1,crashed_count_wait:10,resend_crashed_updates:!0,sync_active:!0,storage_strategy:"html5-filesystem",file_system_quota:61644800,has_custom_sync:null},notifications:{CLIENT_STORAGE_FAILED:"client_storage_failed",SYNC_STARTED:"sync_started",SYNC_COMPLETE:"sync_complete",OFFLINE_UPDATE:"offline_update",COLLISION_DETECTED:"collision_detected",REMOTE_UPDATE_FAILED:"remote_update_failed",REMOTE_UPDATE_APPLIED:"remote_update_applied",LOCAL_UPDATE_APPLIED:"local_update_applied",DELTA_RECEIVED:"delta_received",RECORD_DELTA_RECEIVED:"record_delta_received",SYNC_FAILED:"sync_failed"},datasets:{},config:void 0,notify_callback:void 0,init_is_called:!1,init:function(a){h.consoleLog("sync - init called"),h.config=c.parse(c.stringify(h.defaults));for(var b in a)h.config[b]=a[b];h.init_is_called||(h.init_is_called=!0,h.datasetMonitor())},notify:function(a){h.notify_callback=a},manage:function(a,b,d,e,f){h.consoleLog("manage - START");var b=b||{},g=function(g){h.consoleLog("doManage dataset :: initialised = "+g.initialised+" :: "+a+" :: "+c.stringify(b));var i=h.setOptions(b);g.query_params=d||g.query_params||{},g.meta_data=e||g.meta_data||{},g.config=i,g.syncRunning=!1,g.syncPending=!0,g.initialised=!0,"undefined"==typeof g.meta&&(g.meta={}),h.saveDataSet(a,function(){f&&f()})};h.getDataSet(a,function(a){h.consoleLog("manage - dataset already loaded"),g(a)},function(){h.consoleLog("manage - dataset not loaded... trying to load"),h.loadDataSet(a,function(b){h.consoleLog("manage - dataset loaded from local storage"),h.doNotify(a,null,h.notifications.LOCAL_UPDATE_APPLIED,"load"),g(b)},function(){h.consoleLog("manage - Creating new dataset for id "+a);var b={};b.data={},b.pending={},b.meta={},h.datasets[a]=b,g(b)})})},setOptions:function(a){h.config||(h.config=c.parse(c.stringify(h.defaults)));var b=c.parse(c.stringify(h.config)),d=c.parse(c.stringify(a));for(var e in d)b[e]=d[e];return b},list:function(a,b,d){h.getDataSet(a,function(a){if(a&&a.data){var e=c.parse(c.stringify(a.data));b(e)}else d&&d("no_data")},function(a,b){d&&d(a,b)})},create:function(a,b,c,d){return null==b&&d?d("null_data"):void h.addPendingObj(a,null,b,"create",c,d)},read:function(a,b,d,e){h.getDataSet(a,function(a){var f=a.data[b];if(f){var g=c.parse(c.stringify(f));d(g)}else e("unknown_uid")},function(a,b){e&&e(a,b)})},update:function(a,b,c,d,e){h.addPendingObj(a,b,c,"update",d,e)},"delete":function(a,b,c,d){h.addPendingObj(a,b,null,"delete",c,d)},getPending:function(a,b){h.getDataSet(a,function(a){var c;a&&(c=a.pending),b(c)},function(a){h.consoleLog(a)})},clearPending:function(a,b){h.getDataSet(a,function(c){c.pending={},h.saveDataSet(a,b)})},listCollisions:function(a,b,c){h.getDataSet(a,function(d){h.doCloudCall({dataset_id:a,req:{fn:"listCollisions",meta_data:d.meta_data}},b,c)},c)},removeCollision:function(a,b,c,d){h.getDataSet(a,function(e){h.doCloudCall({dataset_id:a,req:{fn:"removeCollision",hash:b,meta_data:e.meta_data}},c,d)})},isOnline:function(a){var b=!0;if("undefined"!=typeof navigator.onLine&&(b=navigator.onLine),b&&"undefined"!=typeof navigator.network&&"undefined"!=typeof navigator.network.connection){var c=navigator.network.connection.type;("none"===c||null===c)&&(b=!1)}return a(b)},doNotify:function(a,b,c,d){if(h.notify_callback&&h.config["notify_"+c]){var e={dataset_id:a,uid:b,code:c,message:d};setTimeout(function(){h.notify_callback(e)},0)}},getDataSet:function(a,b,c){var d=h.datasets[a];d?b(d):c&&c("unknown_dataset "+a,a)},getQueryParams:function(a,b,c){var d=h.datasets[a];d?b(d.query_params):c&&c("unknown_dataset "+a,a)},setQueryParams:function(a,b,c,d){var e=h.datasets[a];e?(e.query_params=b,h.saveDataSet(a),c&&c(e.query_params)):d&&d("unknown_dataset "+a,a)},getMetaData:function(a,b,c){var d=h.datasets[a];d?b(d.meta_data):c&&c("unknown_dataset "+a,a)},setMetaData:function(a,b,c,d){var e=h.datasets[a];e?(e.meta_data=b,h.saveDataSet(a),c&&c(e.meta_data)):d&&d("unknown_dataset "+a,a)},getConfig:function(a,b,c){var d=h.datasets[a];d?b(d.config):c&&c("unknown_dataset "+a,a)},setConfig:function(a,b,c,d){var e=h.datasets[a];if(e){var f=h.setOptions(b);e.config=f,h.saveDataSet(a),c&&c(e.config)}else d&&d("unknown_dataset "+a,a)},stopSync:function(a,b,c){h.setConfig(a,{sync_active:!1},function(){b&&b()},c)},startSync:function(a,b,c){h.setConfig(a,{sync_active:!0},function(){b&&b()},c)},doSync:function(a,b,c){var d=h.datasets[a];d?(d.syncPending=!0,h.saveDataSet(a),b&&b()):c&&c("unknown_dataset "+a,a)},forceSync:function(a,b,c){var d=h.datasets[a];d?(d.syncForced=!0,h.saveDataSet(a),b&&b()):c&&c("unknown_dataset "+a,a)},sortObject:function(a){if("object"!=typeof a||null===a)return a;var b=[];return Object.keys(a).sort().forEach(function(c){b.push({key:c,value:h.sortObject(a[c])})}),b},sortedStringify:function(a){var b="";try{b=c.stringify(h.sortObject(a))}catch(d){console.error("Error stringifying sorted object:"+d)}return b},generateHash:function(a){var b=f.SHA1(h.sortedStringify(a));return b.toString()},addPendingObj:function(a,b,d,e,f,g){function i(c){c.hash=h.generateHash(c),h.getDataSet(a,function(d){d.pending[c.hash]=c,h.updateDatasetFromLocal(d,c),h.config.auto_sync_local_updates&&(d.syncPending=!0),h.saveDataSet(a),h.doNotify(a,b,h.notifications.LOCAL_UPDATE_APPLIED,e),f(c)},function(a,b){g&&g(a,b)})}h.isOnline(function(c){c||h.doNotify(a,b,h.notifications.OFFLINE_UPDATE,e)});var j={};j.inFlight=!1,j.action=e,j.post=c.parse(c.stringify(d)),j.postHash=h.generateHash(j.post),j.timestamp=(new Date).getTime(),"create"===e?(j.uid=j.postHash,i(j)):h.read(a,b,function(a){j.uid=b,j.pre=a.data,j.preHash=h.generateHash(a.data),i(j)},function(a,b){g&&g(a,b)})},syncLoop:function(a){h.getDataSet(a,function(b){b.syncPending=!1,b.syncRunning=!0,b.syncLoopStart=(new Date).getTime(),h.doNotify(a,null,h.notifications.SYNC_STARTED,null),h.isOnline(function(d){d?h.checkHasCustomSync(a,function(){var d={};d.fn="sync",d.dataset_id=a,d.query_params=b.query_params,d.config=b.config,d.meta_data=b.meta_data,d.dataset_hash=b.hash,d.acknowledgements=b.acknowledgements||[];var e=b.pending,f=[];for(var g in e)e[g].inFlight||e[g].crashed||e[g].delayed||(e[g].inFlight=!0,e[g].inFlightDate=(new Date).getTime(),f.push(e[g]));d.pending=f,f.length>0&&h.consoleLog("Starting sync loop - global hash = "+b.hash+" :: params = "+c.stringify(d,null,2));try{h.doCloudCall({dataset_id:a,req:d},function(c){function d(c,d,f){if(c)for(var g in c)e=c[g],f.push(e),b.pending[g]&&b.pending[g].inFlight&&!b.pending[g].crashed&&(delete b.pending[g],h.doNotify(a,e.uid,d,e))}var e;if(h.updatePendingFromNewData(a,b,c),h.updateCrashedInFlightFromNewData(a,b,c),h.updateDelayedFromNewData(a,b,c),h.updateMetaFromNewData(a,b,c),h.updateNewDataFromInFlight(a,b,c),h.updateNewDataFromPending(a,b,c),c.records&&(b.data=c.records,b.hash=c.hash,h.doNotify(a,c.hash,h.notifications.DELTA_RECEIVED,"full dataset")),c.updates){var f=[];d(c.updates.applied,h.notifications.REMOTE_UPDATE_APPLIED,f),d(c.updates.failed,h.notifications.REMOTE_UPDATE_FAILED,f),d(c.updates.collisions,h.notifications.COLLISION_DETECTED,f),b.acknowledgements=f}!c.records&&c.hash&&c.hash!==b.hash?(h.consoleLog("Local dataset stale - syncing records :: local hash= "+b.hash+" - remoteHash="+c.hash),h.syncRecords(a)):(h.consoleLog("Local dataset up to date"),h.syncComplete(a,"online",h.notifications.SYNC_COMPLETE))},function(c,d){h.markInFlightAsCrashed(b),h.consoleLog("syncLoop failed : msg="+c+" :: err = "+d),h.syncComplete(a,c,h.notifications.SYNC_FAILED)})}catch(i){h.consoleLog("Error performing sync - "+i),h.syncComplete(a,i,h.notifications.SYNC_FAILED)}}):h.syncComplete(a,"offline",h.notifications.SYNC_FAILED)})})},syncRecords:function(a){h.getDataSet(a,function(b){var d=b.data||{},e={};for(var f in d){var g=f,i=d[f].hash;e[g]=i}var j={};j.fn="syncRecords",j.dataset_id=a,j.query_params=b.query_params,j.clientRecs=e,h.consoleLog("syncRecParams :: "+c.stringify(j)),h.doCloudCall({dataset_id:a,req:j},function(c){var e;if(c.create)for(e in c.create)d[e]={hash:c.create[e].hash,data:c.create[e].data},h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"create");if(c.update)for(e in c.update)d[e].hash=c.update[e].hash,d[e].data=c.update[e].data,h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"update");if(c["delete"])for(e in c["delete"])delete d[e],h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"delete");h.doNotify(a,c.hash,h.notifications.DELTA_RECEIVED,"partial dataset"),b.data=d,c.hash&&(b.hash=c.hash),h.syncComplete(a,"online",h.notifications.SYNC_COMPLETE)},function(b,c){h.consoleLog("syncRecords failed : msg="+b+" :: err="+c),h.syncComplete(a,b,h.notifications.SYNC_FAILED)})})},syncComplete:function(a,b,c){h.getDataSet(a,function(d){d.syncRunning=!1,d.syncLoopEnd=(new Date).getTime(),h.saveDataSet(a),h.doNotify(a,d.hash,c,b)})},checkDatasets:function(){for(var a in h.datasets)if(h.datasets.hasOwnProperty(a)){var b=h.datasets[a];if(!b.syncRunning&&(b.config.sync_active||b.syncForced)){var c=b.syncLoopStart,d=b.syncLoopEnd;if(b.syncForced)b.syncPending=!0;else if(null==c)h.consoleLog(a+" - Performing initial sync"),b.syncPending=!0;else if(null!=d){var e=(new Date).getTime()-d,f=1e3*b.config.sync_frequency;e>f&&(b.syncPending=!0)}b.syncPending&&(b.syncForced=!1,h.syncLoop(a))}}},checkHasCustomSync:function(a,b){var c=h.datasets[a];return c&&c.config?(h.consoleLog("dataset.config.has_custom_sync = "+c.config.has_custom_sync),null!=c.config.has_custom_sync?b():(h.consoleLog("starting check has custom sync"),void d({act:a,req:{fn:"sync"}},function(a){return h.consoleLog("check has_custom_sync - success - ",a),c.config.has_custom_sync=!0,b()},function(a,d){return h.consoleLog("check has_custom_sync - failure - ",d),d.status&&500===d.status?(h.consoleLog("check has_custom_sync - failed with 500, endpoint does exists"),c.config.has_custom_sync=!0):c.config.has_custom_sync=!1,b()}))):b()},doCloudCall:function(a,b,c){var f=!1,g=h.datasets[a.dataset_id];g&&g.config&&(f=g.config.has_custom_sync),1==f?d({act:a.dataset_id,req:a.req},function(a){b(a)},function(a,b){c(a,b)}):e({path:"/mbaas/sync/"+a.dataset_id,method:"post",data:a.req},function(a){b(a)},function(a,b){c(a,b)})},datasetMonitor:function(){h.checkDatasets(),setTimeout(function(){h.datasetMonitor()},500)},saveDataSet:function(a,b){var c=function(b,c){var d="save to local storage failed msg:"+b+" err:"+c;h.doNotify(a,null,h.notifications.CLIENT_STORAGE_FAILED,d),h.consoleLog(d)};h.getDataSet(a,function(d){g({fail:c,adapter:h.config.storage_strategy,size:h.config.file_system_quota},function(){this.save({key:"dataset_"+a,val:d},function(){return b?b():void 0})})})},loadDataSet:function(a,b,d){var e=function(b){var c="load from local storage failed msg:"+b;h.doNotify(a,null,h.notifications.CLIENT_STORAGE_FAILED,c),h.consoleLog(c)};g({fail:e,adapter:h.config.storage_strategy,size:h.config.file_system_quota},function(){this.get("dataset_"+a,function(e){if(e&&e.val){var f=e.val;if("string"==typeof f&&(f=c.parse(f)),f.initialised=!1,h.datasets[a]=f,h.consoleLog("load from local storage success for dataset_id :"+a),b)return b(f)}else if(d)return d()})})},updateDatasetFromLocal:function(a,b){var d,e,f=a.pending,g=b.uid;h.consoleLog("updating local dataset for uid "+g+" - action = "+b.action),a.meta[g]=a.meta[g]||{},"create"===b.action&&(a.data[g]&&(h.consoleLog("dataset already exists for uid in create :: "+c.stringify(a.data[g])),a.meta[g].fromPending&&(d=a.meta[g].pendingUid,delete f[d])),a.data[g]={}),"update"===b.action&&a.data[g]&&a.meta[g].fromPending&&(h.consoleLog("updating an existing pending record for dataset :: "+c.stringify(a.data[g])),d=a.meta[g].pendingUid,a.meta[g].previousPendingUid=d,e=f[d],e&&(e.inFlight?(h.consoleLog("existing in-inflight pending record = "+c.stringify(e)),b.delayed=!0,b.waiting=e.hash):(h.consoleLog("existing pre-flight pending record = "+c.stringify(e)),e.post=b.post,e.postHash=b.postHash,delete f[b.hash],b.hash=d))),"delete"===b.action&&a.data[g]&&(a.meta[g].fromPending&&(h.consoleLog("Deleting an existing pending record for dataset :: "+c.stringify(a.data[g])),d=a.meta[g].pendingUid,a.meta[g].previousPendingUid=d,e=f[d],e&&(e.inFlight?(h.consoleLog("existing in-inflight pending record = "+c.stringify(e)),b.delayed=!0,b.waiting=e.hash):(h.consoleLog("existing pending record = "+c.stringify(e)),"create"===e.action&&(delete f[b.hash],delete f[d]),"update"===e.action&&(b.pre=e.pre,b.preHash=e.preHash,b.inFlight=!1,delete f[d])))),delete a.data[g]),a.data[g]&&(a.data[g].data=b.post,a.data[g].hash=b.postHash,a.meta[g].fromPending=!0,a.meta[g].pendingUid=b.hash)},updatePendingFromNewData:function(a,b,d){var e,f=b.pending;if(f&&d.records)for(var g in f)if(f.hasOwnProperty(g)){var i=f[g];if(b.meta[i.uid]=b.meta[i.uid]||{},i.inFlight===!1){if(h.consoleLog("updatePendingFromNewData - Found Non inFlight record -> action="+i.action+" :: uid="+i.uid+" :: hash="+i.hash),"update"===i.action||"delete"===i.action)if(e=d.records[i.uid])h.consoleLog("updatePendingFromNewData - Updating pre values for existing pending record "+i.uid),i.pre=e.data,i.preHash=e.hash;else{var j=b.meta[i.uid].previousPendingUid,k=f[j];if(k&&d&&d.updates&&d.updates.applied&&d.updates.applied[k.hash]){var l=d.updates.applied[k.hash].uid;e=d.records[l],e&&(h.consoleLog("updatePendingFromNewData - Updating pre values for existing pending record which was previously a create "+i.uid+" ==> "+l),i.pre=e.data,i.preHash=e.hash,i.uid=l)}}"create"===i.action&&d&&d.updates&&d.updates.applied&&d.updates.applied[g]&&(h.consoleLog("updatePendingFromNewData - Found an update for a pending create "+c.stringify(d.updates.applied[g])),e=d.records[d.updates.applied[g].uid],e&&(h.consoleLog("updatePendingFromNewData - Changing pending create to an update based on new record "+c.stringify(e)),i.action="update",i.pre=e.data,i.preHash=e.hash,i.uid=d.updates.applied[g].uid))}}},updateNewDataFromInFlight:function(a,b,c){var d=b.pending;if(d&&c.records)for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];if(f.inFlight){var g=c&&c.updates&&c.updates.hashes&&c.updates.hashes[e]?!0:!1;if(h.consoleLog("updateNewDataFromInFlight - Found inflight pending Record - action = "+f.action+" :: hash = "+e+" :: updateReceivedForPending="+g),!g){var i=c.records[f.uid];if("update"===f.action&&i)i.data=f.post,i.hash=f.postHash;else if("delete"===f.action&&i)delete c.records[f.uid];else if("create"===f.action){h.consoleLog("updateNewDataFromInFlight - re adding pending create to incomming dataset");var j={data:f.post,hash:f.postHash};c.records[f.uid]=j}}}}},updateNewDataFromPending:function(a,b,c){var d=b.pending;if(d&&c.records)for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];if(f.inFlight===!1){h.consoleLog("updateNewDataFromPending - Found Non inFlight record -> action="+f.action+" :: uid="+f.uid+" :: hash="+f.hash);var g=c.records[f.uid];if("update"===f.action&&g)g.data=f.post,g.hash=f.postHash;else if("delete"===f.action&&g)delete c.records[f.uid];else if("create"===f.action){h.consoleLog("updateNewDataFromPending - re adding pending create to incomming dataset");var i={data:f.post,hash:f.postHash};c.records[f.uid]=i}}}},updateCrashedInFlightFromNewData:function(a,b,d){var e,f,g={applied:h.notifications.REMOTE_UPDATE_APPLIED,failed:h.notifications.REMOTE_UPDATE_FAILED,collisions:h.notifications.COLLISION_DETECTED},i=b.pending,j={};if(i){for(e in i)if(i.hasOwnProperty(e)&&(f=i[e],f.inFlight&&f.crashed))if(h.consoleLog("updateCrashedInFlightFromNewData - Found crashed inFlight pending record uid="+f.uid+" :: hash="+f.hash),d&&d.updates&&d.updates.hashes){var k=d.updates.hashes[e];k?(j[k.uid]=k,h.consoleLog("updateCrashedInFlightFromNewData - Resolving status for crashed inflight pending record "+c.stringify(k)),"failed"===k.type&&("create"===k.action?(h.consoleLog("updateCrashedInFlightFromNewData - Deleting failed create from dataset"),delete b.data[k.uid]):("update"===k.action||"delete"===k.action)&&(h.consoleLog("updateCrashedInFlightFromNewData - Reverting failed "+k.action+" in dataset"),b.data[k.uid]={data:f.pre,hash:f.preHash})),delete i[e],h.doNotify(a,k.uid,g[k.type],k)):f.crashedCount?f.crashedCount++:f.crashedCount=1}else f.crashedCount?f.crashedCount++:f.crashedCount=1;for(e in i)i.hasOwnProperty(e)&&(f=i[e],f.inFlight&&f.crashed&&f.crashedCount>b.config.crashed_count_wait&&(h.consoleLog("updateCrashedInFlightFromNewData - Crashed inflight pending record has reached crashed_count_wait limit : "+c.stringify(f)),b.config.resend_crashed_updates?(h.consoleLog("updateCrashedInFlightFromNewData - Retryig crashed inflight pending record"),f.crashed=!1,f.inFlight=!1):(h.consoleLog("updateCrashedInFlightFromNewData - Deleting crashed inflight pending record"),delete i[e])))}},updateDelayedFromNewData:function(a,b,d){var e,f,g=b.pending;if(g)for(e in g)if(g.hasOwnProperty(e)&&(f=g[e],f.delayed&&f.waiting&&(h.consoleLog("updateDelayedFromNewData - Found delayed pending record uid="+f.uid+" :: hash="+f.hash+" :: waiting="+f.waiting),d&&d.updates&&d.updates.hashes))){var i=d.updates.hashes[f.waiting];i&&(h.consoleLog("updateDelayedFromNewData - Waiting pending record is resolved rec="+c.stringify(i)),f.delayed=!1,f.waiting=void 0)}},updateMetaFromNewData:function(a,b,d){var e=b.meta;if(e&&d&&d.updates&&d.updates.hashes)for(var f in e)if(e.hasOwnProperty(f)){var g=e[f],i=g.pendingUid,j=g.previousPendingUid;h.consoleLog("updateMetaFromNewData - Found metadata with uid = "+f+" :: pendingHash = "+i+" :: previousPendingHash ="+j);var k=!0,l=!0;if(j){k=!1;var m=d.updates.hashes[j];m&&(h.consoleLog("updateMetaFromNewData - Found previousPendingUid in meta data resolved - resolved = "+c.stringify(m)),g.previousPendingUid=void 0,k=!0)}if(i){l=!1;var m=d.updates.hashes[i];m&&(h.consoleLog("updateMetaFromNewData - Found pendingUid in meta data resolved - resolved = "+c.stringify(m)),g.pendingUid=void 0,l=!0)}k&&l&&(h.consoleLog("updateMetaFromNewData - both previous and current pendings are resolved for meta data with uid "+f+". Delete it."),delete e[f])}},markInFlightAsCrashed:function(a){var b,c,d=a.pending;if(d){var e={};for(b in d)d.hasOwnProperty(b)&&(c=d[b],c.inFlight&&(h.consoleLog("Marking in flight pending record as crashed : "+b),c.crashed=!0,e[c.uid]=c))}},consoleLog:function(a){h.config.do_console_log&&console.log(a)}};!function(){h.config=h.defaults}(),b.exports={init:h.init,manage:h.manage,notify:h.notify,doList:h.list,doCreate:h.create,doRead:h.read,doUpdate:h.update,doDelete:h["delete"],listCollisions:h.listCollisions,removeCollision:h.removeCollision,getPending:h.getPending,clearPending:h.clearPending,getDataset:h.getDataSet,getQueryParams:h.getQueryParams,setQueryParams:h.setQueryParams,getMetaData:h.getMetaData,setMetaData:h.setMetaData,getConfig:h.getConfig,setConfig:h.setConfig,startSync:h.startSync,stopSync:h.stopSync,doSync:h.doSync,forceSync:h.forceSync,generateHash:h.generateHash,loadDataSet:h.loadDataSet,checkHasCustomSync:h.checkHasCustomSync}},{"../../libs/generated/crypto":1,"../../libs/generated/lawnchair":2,"./api_act":19,"./api_cloud":21,JSON:3}],"./modules/appProps":[function(a,b){b.exports=a("zDENqi")},{}],zDENqi:[function(_dereq_,module,exports){var consts=_dereq_("../constants"),ajax=_dereq_("../ajax"),logger=_dereq_("../logger"),qs=_dereq_("../queryMap"),app_props=null,load=function(cb){return app_props=eval('require("fhconfig")'),cb(null,app_props)},setAppProps=function(a){app_props=a},getAppProps=function(){return app_props};module.exports={load:load,getAppProps:getAppProps,setAppProps:setAppProps}},{"../ajax":18,"../constants":26,"../logger":35,"../queryMap":37}],"./cookies":[function(a,b){b.exports=a("RdeKcl")},{}],RdeKcl:[function(a,b){b.exports={readCookieValue:function(a){return"undefined"!=typeof Titanium?Titanium.App.Properties.getObject(a):null},createCookie:function(a,b){return"undefined"!=typeof Titanium?Titanium.App.Properties.setObject(a,b):void 0}}},{}],48:[function(a,b){b.exports={createUUID:function(){for(var a=[],b="0123456789ABCDEF",c=0;32>c;c++)a[c]=b.substr(Math.floor(16*Math.random()),1);a[12]="4",a[16]=b.substr(3&a[16]|8,1);var d=a.join("");return d}}},{}],49:[function(a,b){var c,d=a("./initializer"),e=a("./events"),f=a("./hosts"),g=a("./constants"),h=a("./logger"),i=!1,j=!1,k=null,l=function(a){return j?a(null,{host:n()}):(e.once(g.INIT_EVENT,function(b,c){return a(b,c)}),void(i||(i=!0,d.init(function(a,b){return i=!1,a?(k=a,e.emit(g.INIT_EVENT,a)):(k=null,j=!0,c=new f(b.cloud),e.emit(g.INIT_EVENT,null,{host:n()}))}))))},m=function(){return c},n=function(){if("undefined"!=typeof c){var b=a("./appProps").getAppProps();return c.getHost(b.mode)}return void 0},o=function(){return j},p=function(){return k},q=function(){j=!1,i=!1,c=void 0,k=void 0,l(function(){})};l(function(a){a?"app_config_missing"!==a.message?h.error("Failed to initialise fh."):h.info("No fh config file"):h.info("fh cloud is ready")}),b.exports={ready:l,isReady:o,getCloudHost:m,getCloudHostUrl:n,getInitError:p,reset:q}},{"./appProps":"zDENqi","./constants":26,"./events":28,"./hosts":31,"./initializer":32,"./logger":35}]},{},[16])(16)}); \ No newline at end of file diff --git a/feedhenry.js b/feedhenry.js index 93acb7a5..ba022dbb 100644 --- a/feedhenry.js +++ b/feedhenry.js @@ -6777,8 +6777,8 @@ function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } -}).call(this,_dereq_("/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":6,"/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,"inherits":10}],8:[function(_dereq_,module,exports){ +}).call(this,_dereq_("/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./support/isBuffer":6,"/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,"inherits":10}],8:[function(_dereq_,module,exports){ (function (global){ /*global window, global*/ var util = _dereq_("util") @@ -7253,7 +7253,7 @@ process.chdir = function (dir) { module.exports=_dereq_(6) },{}],13:[function(_dereq_,module,exports){ module.exports=_dereq_(7) -},{"./support/isBuffer":12,"/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,"inherits":10}],14:[function(_dereq_,module,exports){ +},{"./support/isBuffer":12,"/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,"inherits":10}],14:[function(_dereq_,module,exports){ /* * loglevel - https://github.com/pimterry/loglevel * @@ -7453,35 +7453,35 @@ module.exports=_dereq_(7) })(); },{}],15:[function(_dereq_,module,exports){ -var toString = Object.prototype.toString - -module.exports = function(val){ - switch (toString.call(val)) { - case '[object Function]': return 'function' - case '[object Date]': return 'date' - case '[object RegExp]': return 'regexp' - case '[object Arguments]': return 'arguments' - case '[object Array]': return 'array' - case '[object String]': return 'string' - } - - if (typeof val == 'object' && val && typeof val.length == 'number') { - try { - if (typeof val.callee == 'function') return 'arguments'; - } catch (ex) { - if (ex instanceof TypeError) { - return 'arguments'; - } - } - } - - if (val === null) return 'null' - if (val === undefined) return 'undefined' - if (val && val.nodeType === 1) return 'element' - if (val === Object(val)) return 'object' - - return typeof val -} +var toString = Object.prototype.toString + +module.exports = function(val){ + switch (toString.call(val)) { + case '[object Function]': return 'function' + case '[object Date]': return 'date' + case '[object RegExp]': return 'regexp' + case '[object Arguments]': return 'arguments' + case '[object Array]': return 'array' + case '[object String]': return 'string' + } + + if (typeof val == 'object' && val && typeof val.length == 'number') { + try { + if (typeof val.callee == 'function') return 'arguments'; + } catch (ex) { + if (ex instanceof TypeError) { + return 'arguments'; + } + } + } + + if (val === null) return 'null' + if (val === undefined) return 'undefined' + if (val && val.nodeType === 1) return 'element' + if (val === Object(val)) return 'object' + + return typeof val +} },{}],16:[function(_dereq_,module,exports){ var constants = _dereq_("./modules/constants"); diff --git a/feedhenry.min.js b/feedhenry.min.js index 4c125495..b5f9a98a 100644 --- a/feedhenry.min.js +++ b/feedhenry.min.js @@ -1,4 +1,4 @@ !function(a){if("object"==typeof exports)module.exports=a();else if("function"==typeof define&&define.amd)define(a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.feedhenry=a()}}(function(){var define,module,exports;return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gf;f++){var g=c[f>>>2]>>>24-f%4*8&255;b[d+f>>>2]|=g<<24-(d+f)%4*8}else if(c.length>65535)for(var f=0;e>f;f+=4)b[d+f>>>2]=c[f>>>2];else b.push.apply(b,c);return this.sigBytes+=e,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-c%4*8,b.length=a.ceil(c/4)},clone:function(){var a=e.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;b>d;d+=4)c.push(4294967296*a.random()|0);return new f.init(c,b)}}),g=c.enc={},h=g.Hex={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push((f>>>4).toString(16)),d.push((15&f).toString(16))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-d%8*4;return new f.init(c,b/2)}},i=g.Latin1={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push(String.fromCharCode(f))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-d%4*8;return new f.init(c,b)}},j=g.Utf8={stringify:function(a){try{return decodeURIComponent(escape(i.stringify(a)))}catch(b){throw new Error("Malformed UTF-8 data")}},parse:function(a){return i.parse(unescape(encodeURIComponent(a)))}},k=d.BufferedBlockAlgorithm=e.extend({reset:function(){this._data=new f.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,g=this.blockSize,h=4*g,i=e/h;i=b?a.ceil(i):a.max((0|i)-this._minBufferSize,0);var j=i*g,k=a.min(4*j,e);if(j){for(var l=0;j>l;l+=g)this._doProcessBlock(d,l);var m=d.splice(0,j);c.sigBytes-=k}return new f.init(m,k)},clone:function(){var a=e.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0}),l=(d.Hasher=k.extend({cfg:e.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){k.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){a&&this._append(a);var b=this._doFinalize();return b},blockSize:16,_createHelper:function(a){return function(b,c){return new a.init(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return new l.HMAC.init(a,c).finalize(b)}}}),c.algo={});return c}(Math);!function(){{var a=f,b=a.lib,c=b.WordArray,d=a.enc;d.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp();for(var e=[],f=0;c>f;f+=3)for(var g=b[f>>>2]>>>24-f%4*8&255,h=b[f+1>>>2]>>>24-(f+1)%4*8&255,i=b[f+2>>>2]>>>24-(f+2)%4*8&255,j=g<<16|h<<8|i,k=0;4>k&&c>f+.75*k;k++)e.push(d.charAt(j>>>6*(3-k)&63));var l=d.charAt(64);if(l)for(;e.length%4;)e.push(l);return e.join("")},parse:function(a){var b=a.length,d=this._map,e=d.charAt(64);if(e){var f=a.indexOf(e);-1!=f&&(b=f)}for(var g=[],h=0,i=0;b>i;i++)if(i%4){var j=d.indexOf(a.charAt(i-1))<>>6-i%4*2;g[h>>>2]|=(j|k)<<24-h%4*8,h++}return c.create(g,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}}(),f.lib.Cipher||function(a){var b=f,c=b.lib,d=c.Base,e=c.WordArray,g=c.BufferedBlockAlgorithm,h=b.enc,i=(h.Utf8,h.Base64),j=b.algo,k=j.EvpKDF,l=c.Cipher=g.extend({cfg:d.extend(),createEncryptor:function(a,b){return this.create(this._ENC_XFORM_MODE,a,b)},createDecryptor:function(a,b){return this.create(this._DEC_XFORM_MODE,a,b)},init:function(a,b,c){this.cfg=this.cfg.extend(c),this._xformMode=a,this._key=b,this.reset()},reset:function(){g.reset.call(this),this._doReset()},process:function(a){return this._append(a),this._process()},finalize:function(a){a&&this._append(a);var b=this._doFinalize();return b},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function a(a){return"string"==typeof a?x:u}return function(b){return{encrypt:function(c,d,e){return a(d).encrypt(b,c,d,e)},decrypt:function(c,d,e){return a(d).decrypt(b,c,d,e)}}}}()}),m=(c.StreamCipher=l.extend({_doFinalize:function(){var a=this._process(!0);return a},blockSize:1}),b.mode={}),n=c.BlockCipherMode=d.extend({createEncryptor:function(a,b){return this.Encryptor.create(a,b)},createDecryptor:function(a,b){return this.Decryptor.create(a,b)},init:function(a,b){this._cipher=a,this._iv=b}}),o=m.CBC=function(){function b(b,c,d){var e=this._iv;if(e){var f=e;this._iv=a}else var f=this._prevBlock;for(var g=0;d>g;g++)b[c+g]^=f[g]}var c=n.extend();return c.Encryptor=c.extend({processBlock:function(a,c){var d=this._cipher,e=d.blockSize;b.call(this,a,c,e),d.encryptBlock(a,c),this._prevBlock=a.slice(c,c+e)}}),c.Decryptor=c.extend({processBlock:function(a,c){var d=this._cipher,e=d.blockSize,f=a.slice(c,c+e);d.decryptBlock(a,c),b.call(this,a,c,e),this._prevBlock=f}}),c}(),p=b.pad={},q=p.Pkcs7={pad:function(a,b){for(var c=4*b,d=c-a.sigBytes%c,f=d<<24|d<<16|d<<8|d,g=[],h=0;d>h;h+=4)g.push(f);var i=e.create(g,d);a.concat(i)},unpad:function(a){var b=255&a.words[a.sigBytes-1>>>2];a.sigBytes-=b}},r=(c.BlockCipher=l.extend({cfg:l.cfg.extend({mode:o,padding:q}),reset:function(){l.reset.call(this);var a=this.cfg,b=a.iv,c=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var d=c.createEncryptor;else{var d=c.createDecryptor;this._minBufferSize=1}this._mode=d.call(c,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else{var b=this._process(!0);a.unpad(b)}return b},blockSize:4}),c.CipherParams=d.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}})),s=b.format={},t=s.OpenSSL={stringify:function(a){var b=a.ciphertext,c=a.salt;if(c)var d=e.create([1398893684,1701076831]).concat(c).concat(b);else var d=b;return d.toString(i)},parse:function(a){var b=i.parse(a),c=b.words;if(1398893684==c[0]&&1701076831==c[1]){var d=e.create(c.slice(2,4));c.splice(0,4),b.sigBytes-=16}return r.create({ciphertext:b,salt:d})}},u=c.SerializableCipher=d.extend({cfg:d.extend({format:t}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d),f=e.finalize(b),g=e.cfg;return r.create({ciphertext:f,key:c,iv:g.iv,algorithm:a,mode:g.mode,padding:g.padding,blockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){d=this.cfg.extend(d),b=this._parse(b,d.format);var e=a.createDecryptor(c,d).finalize(b.ciphertext);return e},_parse:function(a,b){return"string"==typeof a?b.parse(a,this):a}}),v=b.kdf={},w=v.OpenSSL={execute:function(a,b,c,d){d||(d=e.random(8));var f=k.create({keySize:b+c}).compute(a,d),g=e.create(f.words.slice(b),4*c);return f.sigBytes=4*b,r.create({key:f,iv:g,salt:d})}},x=c.PasswordBasedCipher=u.extend({cfg:u.cfg.extend({kdf:w}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=d.kdf.execute(c,a.keySize,a.ivSize);d.iv=e.iv;var f=u.encrypt.call(this,a,b,e.key,d);return f.mixIn(e),f},decrypt:function(a,b,c,d){d=this.cfg.extend(d),b=this._parse(b,d.format);var e=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=e.iv;var f=u.decrypt.call(this,a,b,e.key,d);return f}})}(),function(){var a=f,b=a.lib,c=b.BlockCipher,d=a.algo,e=[],g=[],h=[],i=[],j=[],k=[],l=[],m=[],n=[],o=[];!function(){for(var a=[],b=0;256>b;b++)a[b]=128>b?b<<1:b<<1^283;for(var c=0,d=0,b=0;256>b;b++){var f=d^d<<1^d<<2^d<<3^d<<4;f=f>>>8^255&f^99,e[c]=f,g[f]=c;var p=a[c],q=a[p],r=a[q],s=257*a[f]^16843008*f;h[c]=s<<24|s>>>8,i[c]=s<<16|s>>>16,j[c]=s<<8|s>>>24,k[c]=s;var s=16843009*r^65537*q^257*p^16843008*c;l[f]=s<<24|s>>>8,m[f]=s<<16|s>>>16,n[f]=s<<8|s>>>24,o[f]=s,c?(c=p^a[a[a[r^p]]],d^=a[a[d]]):c=d=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],q=d.AES=c.extend({_doReset:function(){for(var a=this._key,b=a.words,c=a.sigBytes/4,d=this._nRounds=c+6,f=4*(d+1),g=this._keySchedule=[],h=0;f>h;h++)if(c>h)g[h]=b[h];else{var i=g[h-1];h%c?c>6&&h%c==4&&(i=e[i>>>24]<<24|e[i>>>16&255]<<16|e[i>>>8&255]<<8|e[255&i]):(i=i<<8|i>>>24,i=e[i>>>24]<<24|e[i>>>16&255]<<16|e[i>>>8&255]<<8|e[255&i],i^=p[h/c|0]<<24),g[h]=g[h-c]^i}for(var j=this._invKeySchedule=[],k=0;f>k;k++){var h=f-k;if(k%4)var i=g[h];else var i=g[h-4];j[k]=4>k||4>=h?i:l[e[i>>>24]]^m[e[i>>>16&255]]^n[e[i>>>8&255]]^o[e[255&i]]}},encryptBlock:function(a,b){this._doCryptBlock(a,b,this._keySchedule,h,i,j,k,e)},decryptBlock:function(a,b){var c=a[b+1];a[b+1]=a[b+3],a[b+3]=c,this._doCryptBlock(a,b,this._invKeySchedule,l,m,n,o,g);var c=a[b+1];a[b+1]=a[b+3],a[b+3]=c},_doCryptBlock:function(a,b,c,d,e,f,g,h){for(var i=this._nRounds,j=a[b]^c[0],k=a[b+1]^c[1],l=a[b+2]^c[2],m=a[b+3]^c[3],n=4,o=1;i>o;o++){var p=d[j>>>24]^e[k>>>16&255]^f[l>>>8&255]^g[255&m]^c[n++],q=d[k>>>24]^e[l>>>16&255]^f[m>>>8&255]^g[255&j]^c[n++],r=d[l>>>24]^e[m>>>16&255]^f[j>>>8&255]^g[255&k]^c[n++],s=d[m>>>24]^e[j>>>16&255]^f[k>>>8&255]^g[255&l]^c[n++];j=p,k=q,l=r,m=s}var p=(h[j>>>24]<<24|h[k>>>16&255]<<16|h[l>>>8&255]<<8|h[255&m])^c[n++],q=(h[k>>>24]<<24|h[l>>>16&255]<<16|h[m>>>8&255]<<8|h[255&j])^c[n++],r=(h[l>>>24]<<24|h[m>>>16&255]<<16|h[j>>>8&255]<<8|h[255&k])^c[n++],s=(h[m>>>24]<<24|h[j>>>16&255]<<16|h[k>>>8&255]<<8|h[255&l])^c[n++];a[b]=p,a[b+1]=q,a[b+2]=r,a[b+3]=s},keySize:8});a.AES=c._createHelper(q)}(),function(a){function b(a,b,c,d,e,f,g){var h=a+(b&c|~b&d)+e+g;return(h<>>32-f)+b}function c(a,b,c,d,e,f,g){var h=a+(b&d|c&~d)+e+g;return(h<>>32-f)+b}function d(a,b,c,d,e,f,g){var h=a+(b^c^d)+e+g;return(h<>>32-f)+b}function e(a,b,c,d,e,f,g){var h=a+(c^(b|~d))+e+g;return(h<>>32-f)+b}var g=f,h=g.lib,i=h.WordArray,j=h.Hasher,k=g.algo,l=[];!function(){for(var b=0;64>b;b++)l[b]=4294967296*a.abs(a.sin(b+1))|0}();var m=k.MD5=j.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(a,f){for(var g=0;16>g;g++){var h=f+g,i=a[h];a[h]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var j=this._hash.words,k=a[f+0],m=a[f+1],n=a[f+2],o=a[f+3],p=a[f+4],q=a[f+5],r=a[f+6],s=a[f+7],t=a[f+8],u=a[f+9],v=a[f+10],w=a[f+11],x=a[f+12],y=a[f+13],z=a[f+14],A=a[f+15],B=j[0],C=j[1],D=j[2],E=j[3];B=b(B,C,D,E,k,7,l[0]),E=b(E,B,C,D,m,12,l[1]),D=b(D,E,B,C,n,17,l[2]),C=b(C,D,E,B,o,22,l[3]),B=b(B,C,D,E,p,7,l[4]),E=b(E,B,C,D,q,12,l[5]),D=b(D,E,B,C,r,17,l[6]),C=b(C,D,E,B,s,22,l[7]),B=b(B,C,D,E,t,7,l[8]),E=b(E,B,C,D,u,12,l[9]),D=b(D,E,B,C,v,17,l[10]),C=b(C,D,E,B,w,22,l[11]),B=b(B,C,D,E,x,7,l[12]),E=b(E,B,C,D,y,12,l[13]),D=b(D,E,B,C,z,17,l[14]),C=b(C,D,E,B,A,22,l[15]),B=c(B,C,D,E,m,5,l[16]),E=c(E,B,C,D,r,9,l[17]),D=c(D,E,B,C,w,14,l[18]),C=c(C,D,E,B,k,20,l[19]),B=c(B,C,D,E,q,5,l[20]),E=c(E,B,C,D,v,9,l[21]),D=c(D,E,B,C,A,14,l[22]),C=c(C,D,E,B,p,20,l[23]),B=c(B,C,D,E,u,5,l[24]),E=c(E,B,C,D,z,9,l[25]),D=c(D,E,B,C,o,14,l[26]),C=c(C,D,E,B,t,20,l[27]),B=c(B,C,D,E,y,5,l[28]),E=c(E,B,C,D,n,9,l[29]),D=c(D,E,B,C,s,14,l[30]),C=c(C,D,E,B,x,20,l[31]),B=d(B,C,D,E,q,4,l[32]),E=d(E,B,C,D,t,11,l[33]),D=d(D,E,B,C,w,16,l[34]),C=d(C,D,E,B,z,23,l[35]),B=d(B,C,D,E,m,4,l[36]),E=d(E,B,C,D,p,11,l[37]),D=d(D,E,B,C,s,16,l[38]),C=d(C,D,E,B,v,23,l[39]),B=d(B,C,D,E,y,4,l[40]),E=d(E,B,C,D,k,11,l[41]),D=d(D,E,B,C,o,16,l[42]),C=d(C,D,E,B,r,23,l[43]),B=d(B,C,D,E,u,4,l[44]),E=d(E,B,C,D,x,11,l[45]),D=d(D,E,B,C,A,16,l[46]),C=d(C,D,E,B,n,23,l[47]),B=e(B,C,D,E,k,6,l[48]),E=e(E,B,C,D,s,10,l[49]),D=e(D,E,B,C,z,15,l[50]),C=e(C,D,E,B,q,21,l[51]),B=e(B,C,D,E,x,6,l[52]),E=e(E,B,C,D,o,10,l[53]),D=e(D,E,B,C,v,15,l[54]),C=e(C,D,E,B,m,21,l[55]),B=e(B,C,D,E,t,6,l[56]),E=e(E,B,C,D,A,10,l[57]),D=e(D,E,B,C,r,15,l[58]),C=e(C,D,E,B,y,21,l[59]),B=e(B,C,D,E,p,6,l[60]),E=e(E,B,C,D,w,10,l[61]),D=e(D,E,B,C,n,15,l[62]),C=e(C,D,E,B,u,21,l[63]),j[0]=j[0]+B|0,j[1]=j[1]+C|0,j[2]=j[2]+D|0,j[3]=j[3]+E|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;c[e>>>5]|=128<<24-e%32;var f=a.floor(d/4294967296),g=d;c[(e+64>>>9<<4)+15]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),c[(e+64>>>9<<4)+14]=16711935&(g<<8|g>>>24)|4278255360&(g<<24|g>>>8),b.sigBytes=4*(c.length+1),this._process();for(var h=this._hash,i=h.words,j=0;4>j;j++){var k=i[j];i[j]=16711935&(k<<8|k>>>24)|4278255360&(k<<24|k>>>8)}return h},clone:function(){var a=j.clone.call(this);return a._hash=this._hash.clone(),a}});g.MD5=j._createHelper(m),g.HmacMD5=j._createHmacHelper(m)}(Math),function(){var a=f,b=a.lib,c=b.WordArray,d=b.Hasher,e=a.algo,g=[],h=e.SHA1=d.extend({_doReset:function(){this._hash=new c.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],h=c[3],i=c[4],j=0;80>j;j++){if(16>j)g[j]=0|a[b+j];else{var k=g[j-3]^g[j-8]^g[j-14]^g[j-16];g[j]=k<<1|k>>>31}var l=(d<<5|d>>>27)+i+g[j];l+=20>j?(e&f|~e&h)+1518500249:40>j?(e^f^h)+1859775393:60>j?(e&f|e&h|f&h)-1894007588:(e^f^h)-899497514,i=h,h=f,f=e<<30|e>>>2,e=d,d=l}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;return b[d>>>5]|=128<<24-d%32,b[(d+64>>>9<<4)+14]=Math.floor(c/4294967296),b[(d+64>>>9<<4)+15]=c,a.sigBytes=4*b.length,this._process(),this._hash},clone:function(){var a=d.clone.call(this);return a._hash=this._hash.clone(),a}});a.SHA1=d._createHelper(h),a.HmacSHA1=d._createHmacHelper(h)}(),function(a){{var b=f,c=b.lib,d=c.Base,e=c.WordArray,g=b.x64={};g.Word=d.extend({init:function(a,b){this.high=a,this.low=b}}),g.WordArray=d.extend({init:function(b,c){b=this.words=b||[],this.sigBytes=c!=a?c:8*b.length},toX32:function(){for(var a=this.words,b=a.length,c=[],d=0;b>d;d++){var f=a[d];c.push(f.high),c.push(f.low)}return e.create(c,this.sigBytes)},clone:function(){for(var a=d.clone.call(this),b=a.words=this.words.slice(0),c=b.length,e=0;c>e;e++)b[e]=b[e].clone();return a}})}}(),function(a){var b=f,c=b.lib,d=c.WordArray,e=c.Hasher,g=b.algo,h=[],i=[];!function(){function b(b){for(var c=a.sqrt(b),d=2;c>=d;d++)if(!(b%d))return!1;return!0}function c(a){return 4294967296*(a-(0|a))|0}for(var d=2,e=0;64>e;)b(d)&&(8>e&&(h[e]=c(a.pow(d,.5))),i[e]=c(a.pow(d,1/3)),e++),d++}();var j=[],k=g.SHA256=e.extend({_doReset:function(){this._hash=new d.init(h.slice(0))},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],k=c[5],l=c[6],m=c[7],n=0;64>n;n++){if(16>n)j[n]=0|a[b+n];else{var o=j[n-15],p=(o<<25|o>>>7)^(o<<14|o>>>18)^o>>>3,q=j[n-2],r=(q<<15|q>>>17)^(q<<13|q>>>19)^q>>>10;j[n]=p+j[n-7]+r+j[n-16]}var s=h&k^~h&l,t=d&e^d&f^e&f,u=(d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22),v=(h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25),w=m+v+s+i[n]+j[n],x=u+t;m=l,l=k,k=h,h=g+w|0,g=f,f=e,e=d,d=w+x|0}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+g|0,c[4]=c[4]+h|0,c[5]=c[5]+k|0,c[6]=c[6]+l|0,c[7]=c[7]+m|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;return c[e>>>5]|=128<<24-e%32,c[(e+64>>>9<<4)+14]=a.floor(d/4294967296),c[(e+64>>>9<<4)+15]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=e.clone.call(this);return a._hash=this._hash.clone(),a}});b.SHA256=e._createHelper(k),b.HmacSHA256=e._createHmacHelper(k)}(Math),function(){function a(){return g.create.apply(g,arguments)}var b=f,c=b.lib,d=c.Hasher,e=b.x64,g=e.Word,h=e.WordArray,i=b.algo,j=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],k=[];!function(){for(var b=0;80>b;b++)k[b]=a()}();var l=i.SHA512=d.extend({_doReset:function(){this._hash=new h.init([new g.init(1779033703,4089235720),new g.init(3144134277,2227873595),new g.init(1013904242,4271175723),new g.init(2773480762,1595750129),new g.init(1359893119,2917565137),new g.init(2600822924,725511199),new g.init(528734635,4215389547),new g.init(1541459225,327033209)])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],i=c[5],l=c[6],m=c[7],n=d.high,o=d.low,p=e.high,q=e.low,r=f.high,s=f.low,t=g.high,u=g.low,v=h.high,w=h.low,x=i.high,y=i.low,z=l.high,A=l.low,B=m.high,C=m.low,D=n,E=o,F=p,G=q,H=r,I=s,J=t,K=u,L=v,M=w,N=x,O=y,P=z,Q=A,R=B,S=C,T=0;80>T;T++){var U=k[T];if(16>T)var V=U.high=0|a[b+2*T],W=U.low=0|a[b+2*T+1];else{var X=k[T-15],Y=X.high,Z=X.low,$=(Y>>>1|Z<<31)^(Y>>>8|Z<<24)^Y>>>7,_=(Z>>>1|Y<<31)^(Z>>>8|Y<<24)^(Z>>>7|Y<<25),ab=k[T-2],bb=ab.high,cb=ab.low,db=(bb>>>19|cb<<13)^(bb<<3|cb>>>29)^bb>>>6,eb=(cb>>>19|bb<<13)^(cb<<3|bb>>>29)^(cb>>>6|bb<<26),fb=k[T-7],gb=fb.high,hb=fb.low,ib=k[T-16],jb=ib.high,kb=ib.low,W=_+hb,V=$+gb+(_>>>0>W>>>0?1:0),W=W+eb,V=V+db+(eb>>>0>W>>>0?1:0),W=W+kb,V=V+jb+(kb>>>0>W>>>0?1:0);U.high=V,U.low=W}var lb=L&N^~L&P,mb=M&O^~M&Q,nb=D&F^D&H^F&H,ob=E&G^E&I^G&I,pb=(D>>>28|E<<4)^(D<<30|E>>>2)^(D<<25|E>>>7),qb=(E>>>28|D<<4)^(E<<30|D>>>2)^(E<<25|D>>>7),rb=(L>>>14|M<<18)^(L>>>18|M<<14)^(L<<23|M>>>9),sb=(M>>>14|L<<18)^(M>>>18|L<<14)^(M<<23|L>>>9),tb=j[T],ub=tb.high,vb=tb.low,wb=S+sb,xb=R+rb+(S>>>0>wb>>>0?1:0),wb=wb+mb,xb=xb+lb+(mb>>>0>wb>>>0?1:0),wb=wb+vb,xb=xb+ub+(vb>>>0>wb>>>0?1:0),wb=wb+W,xb=xb+V+(W>>>0>wb>>>0?1:0),yb=qb+ob,zb=pb+nb+(qb>>>0>yb>>>0?1:0);R=P,S=Q,P=N,Q=O,N=L,O=M,M=K+wb|0,L=J+xb+(K>>>0>M>>>0?1:0)|0,J=H,K=I,H=F,I=G,F=D,G=E,E=wb+yb|0,D=xb+zb+(wb>>>0>E>>>0?1:0)|0}o=d.low=o+E,d.high=n+D+(E>>>0>o>>>0?1:0),q=e.low=q+G,e.high=p+F+(G>>>0>q>>>0?1:0),s=f.low=s+I,f.high=r+H+(I>>>0>s>>>0?1:0),u=g.low=u+K,g.high=t+J+(K>>>0>u>>>0?1:0),w=h.low=w+M,h.high=v+L+(M>>>0>w>>>0?1:0),y=i.low=y+O,i.high=x+N+(O>>>0>y>>>0?1:0),A=l.low=A+Q,l.high=z+P+(Q>>>0>A>>>0?1:0),C=m.low=C+S,m.high=B+R+(S>>>0>C>>>0?1:0)},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;b[d>>>5]|=128<<24-d%32,b[(d+128>>>10<<5)+30]=Math.floor(c/4294967296),b[(d+128>>>10<<5)+31]=c,a.sigBytes=4*b.length,this._process();var e=this._hash.toX32();return e},clone:function(){var a=d.clone.call(this);return a._hash=this._hash.clone(),a},blockSize:32});b.SHA512=d._createHelper(l),b.HmacSHA512=d._createHmacHelper(l)}(),function(a){var b=f,c=b.lib,d=c.WordArray,e=c.Hasher,g=b.x64,h=g.Word,i=b.algo,j=[],k=[],l=[];!function(){for(var a=1,b=0,c=0;24>c;c++){j[a+5*b]=(c+1)*(c+2)/2%64;var d=b%5,e=(2*a+3*b)%5;a=d,b=e}for(var a=0;5>a;a++)for(var b=0;5>b;b++)k[a+5*b]=b+(2*a+3*b)%5*5;for(var f=1,g=0;24>g;g++){for(var i=0,m=0,n=0;7>n;n++){if(1&f){var o=(1<o?m^=1<a;a++)m[a]=h.create()}();var n=i.SHA3=e.extend({cfg:e.cfg.extend({outputLength:512}),_doReset:function(){for(var a=this._state=[],b=0;25>b;b++)a[b]=new h.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(a,b){for(var c=this._state,d=this.blockSize/2,e=0;d>e;e++){var f=a[b+2*e],g=a[b+2*e+1];f=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),g=16711935&(g<<8|g>>>24)|4278255360&(g<<24|g>>>8);var h=c[e];h.high^=g,h.low^=f}for(var i=0;24>i;i++){for(var n=0;5>n;n++){for(var o=0,p=0,q=0;5>q;q++){var h=c[n+5*q];o^=h.high,p^=h.low}var r=m[n];r.high=o,r.low=p}for(var n=0;5>n;n++)for(var s=m[(n+4)%5],t=m[(n+1)%5],u=t.high,v=t.low,o=s.high^(u<<1|v>>>31),p=s.low^(v<<1|u>>>31),q=0;5>q;q++){var h=c[n+5*q];h.high^=o,h.low^=p}for(var w=1;25>w;w++){var h=c[w],x=h.high,y=h.low,z=j[w];if(32>z)var o=x<>>32-z,p=y<>>32-z;else var o=y<>>64-z,p=x<>>64-z;var A=m[k[w]];A.high=o,A.low=p}var B=m[0],C=c[0];B.high=C.high,B.low=C.low;for(var n=0;5>n;n++)for(var q=0;5>q;q++){var w=n+5*q,h=c[w],D=m[w],E=m[(n+1)%5+5*q],F=m[(n+2)%5+5*q];h.high=D.high^~E.high&F.high,h.low=D.low^~E.low&F.low}var h=c[0],G=l[i];h.high^=G.high,h.low^=G.low}},_doFinalize:function(){var b=this._data,c=b.words,e=(8*this._nDataBytes,8*b.sigBytes),f=32*this.blockSize;c[e>>>5]|=1<<24-e%32,c[(a.ceil((e+1)/f)*f>>>5)-1]|=128,b.sigBytes=4*c.length,this._process();for(var g=this._state,h=this.cfg.outputLength/8,i=h/8,j=[],k=0;i>k;k++){var l=g[k],m=l.high,n=l.low;m=16711935&(m<<8|m>>>24)|4278255360&(m<<24|m>>>8),n=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),j.push(n),j.push(m)}return new d.init(j,h)},clone:function(){for(var a=e.clone.call(this),b=a._state=this._state.slice(0),c=0;25>c;c++)b[c]=b[c].clone();return a}});b.SHA3=e._createHelper(n),b.HmacSHA3=e._createHmacHelper(n)}(Math),e("undefined"!=typeof f?f:window.CryptoJS)}.call(c,void 0,void 0,void 0,void 0,function(a){b.exports=a})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(a,b){(function(c){__browserify_shim_require__=a,function(a,b,c,d,e){var f=function(a,b){if(!(this instanceof f))return new f(a,b);if(!JSON)throw"JSON unavailable! Include http://www.json.org/json2.js to fix.";if(!(arguments.length<=2&&arguments.length>0))throw"Incorrect # of ctor args!";if(b="function"==typeof arguments[0]?arguments[0]:arguments[1],a="function"==typeof arguments[0]?{}:arguments[0],"function"!=typeof b)throw"No callback was provided";this.record=a.record||"record",this.name=a.name||"records";var c;if(a.adapter){"string"==typeof a.adapter&&(a.adapter=[a.adapter]);for(var d=0,e=a.adapter.length;e>d;d++){for(var g=f.adapters.length-1;g>=0&&(f.adapters[g].adapter!==a.adapter[d]||!(c=f.adapters[g].valid()?f.adapters[g]:void 0));g--);if(c)break}}else for(var g=0,h=f.adapters.length;h>g&&!(c=f.adapters[g].valid()?f.adapters[g]:void 0);g++);if(!c)throw"No valid adapter.";for(var d in c)this[d]=c[d];for(var g=0,h=f.plugins.length;h>g;g++)f.plugins[g].call(this);this.init(a,b)};f.adapters=[],f.adapter=function(a,b){b.adapter=a;var c="adapter valid init keys save batch get exists all remove nuke".split(" "),d=this.prototype.indexOf;for(var e in b)if(-1===d(c,e))throw"Invalid adapter! Nonstandard method: "+e;f.adapters.splice(0,0,b)},f.plugins=[],f.plugin=function(a){for(var b in a)"init"===b?f.plugins.push(a[b]):this.prototype[b]=a[b]},f.prototype={isArray:Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},indexOf:function(a,b,c,d){if(a.indexOf)return a.indexOf(b);for(c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},lambda:function(a){return this.fn(this.record,a)},fn:function(a,b){return"string"==typeof b?new Function(a,b):b},uuid:function(){var a=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()},each:function(a){var b=this.lambda(a);if(this.__results)for(var c=0,d=this.__results.length;d>c;c++)b.call(this,this.__results[c],c);else this.all(function(a){for(var c=0,d=a.length;d>c;c++)b.call(this,a[c],c)});return this}},f.adapter("window-name",function(){"undefined"==typeof window&&(window={top:{}});var a={};try{a=JSON.parse(window.top.name)}catch(b){}return{valid:function(){return"undefined"!=typeof window.top.name},init:function(b,c){return a[this.name]=a[this.name]||{index:[],store:{}},this.index=a[this.name].index,this.store=a[this.name].store,this.fn(this.name,c).call(this,this),this},keys:function(a){return this.fn("keys",a).call(this,this.index),this},save:function(b,c){var d=b.key||this.uuid();return this.exists(d,function(e){e||(b.key&&delete b.key,this.index.push(d)),this.store[d]=b;try{window.top.name=JSON.stringify(a)}catch(f){throw e||(this.index.pop(),delete this.store[d]),f}c&&(b.key=d,this.lambda(c).call(this,b))}),this},batch:function(a,b){for(var c=[],d=0,e=a.length;e>d;d++)this.save(a[d],function(a){c.push(a)});return b&&this.lambda(b).call(this,c),this},get:function(a,b){var c;if(this.isArray(a)){c=[];for(var d=0,e=a.length;e>d;d++)c.push(this.store[a[d]])}else c=this.store[a],c&&(c.key=a);return b&&this.lambda(b).call(this,c),this},exists:function(a,b){return this.lambda(b).call(this,!!this.store[a]),this},all:function(a){for(var b=[],c=0,d=this.index.length;d>c;c++){var e=this.store[this.index[c]];e.key=this.index[c],b.push(e)}return this.fn(this.name,a).call(this,b),this},remove:function(b,c){for(var d=this.isArray(b)?b:[b],e=0,f=d.length;f>e;e++){var g=d[e].key?d[e].key:d[e],h=this.indexOf(this.index,g);0>h||(delete this.store[g],this.index.splice(h,1))}return window.top.name=JSON.stringify(a),c&&this.lambda(c).call(this),this},nuke:function(b){return this.store=a[this.name].store={},this.index=a[this.name].index=[],window.top.name=JSON.stringify(a),b&&this.lambda(b).call(this),this}}}()),f.adapter("dom",function(){var a=null;try{a=window.localStorage}catch(b){}var c=function(b){return{key:b+"._index_",all:function(){var b=a.getItem(this.key);return b&&(b=JSON.parse(b)),null===b&&a.setItem(this.key,JSON.stringify([])),JSON.parse(a.getItem(this.key))},add:function(b){var c=this.all();c.push(b),a.setItem(this.key,JSON.stringify(c))},del:function(b){for(var c=this.all(),d=[],e=0,f=c.length;f>e;e++)c[e]!=b&&d.push(c[e]);a.setItem(this.key,JSON.stringify(d))},find:function(a){for(var b=this.all(),c=0,d=b.length;d>c;c++)if(a===b[c])return c;return!1}}};return{valid:function(){return!!a&&function(){var b=!0,c=Math.random();try{a.setItem(c,c)}catch(d){b=!1}return a.removeItem(c),b}()},init:function(a,b){this.indexer=c(this.name),b&&this.fn(this.name,b).call(this,this)},save:function(b,c){var d=b.key?this.name+"."+b.key:this.name+"."+this.uuid();return delete b.key,a.setItem(d,JSON.stringify(b)),this.indexer.find(d)===!1&&this.indexer.add(d),b.key=d.slice(this.name.length+1),c&&this.lambda(c).call(this,b),this},batch:function(a,b){for(var c=[],d=0,e=a.length;e>d;d++)this.save(a[d],function(a){c.push(a)});return b&&this.lambda(b).call(this,c),this},keys:function(a){if(a){var b=this.name,c=this.indexer.all(),d=[];if(Array.prototype.map)d=c.map(function(a){return a.replace(b+".","")});else for(var e in c)d.push(e.replace(b+".",""));this.fn("keys",a).call(this,d)}return this},get:function(b,c){if(this.isArray(b)){for(var d=[],e=0,f=b.length;f>e;e++){var g=this.name+"."+b[e],h=a.getItem(g);h&&(h=JSON.parse(h),h.key=b[e]),d.push(h)}c&&this.lambda(c).call(this,d)}else{var g=this.name+"."+b,h=a.getItem(g);h&&(h=JSON.parse(h),h.key=b),c&&this.lambda(c).call(this,h)}return this},exists:function(a,b){var c=this.indexer.find(this.name+"."+a)===!1?!1:!0;return this.lambda(b).call(this,c),this},all:function(b){for(var c,d,e=this.indexer.all(),f=[],g=0,h=e.length;h>g;g++)d=e[g],c=JSON.parse(a.getItem(d)),c.key=d.replace(this.name+".",""),f.push(c);return b&&this.fn(this.name,b).call(this,f),this},remove:function(b,c){var d=this;if(this.isArray(b)){var e,f=b.length,g=function(a){d.remove(b[a],function(){--f>0||c&&d.lambda(c).call(d)})};for(e=0;ec;c++)this.remove(b[c]);a&&this.lambda(a).call(this)}),this}}}()),f.adapter("webkit-sqlite",function(){var a=function(a,b){console&&console.log("error in sqlite adaptor!",a,b)},b=function(){return new Date};return{valid:function(){return!!window.openDatabase},init:function(b,c){var d=this,e=d.fn(d.name,c),f="CREATE TABLE IF NOT EXISTS "+this.record+" (id NVARCHAR(32) UNIQUE PRIMARY KEY, value TEXT, timestamp REAL)",g=function(){return e.call(d,d)};b&&"function"==typeof b.fail&&(a=b.fail),this.db=openDatabase(this.name,"1.0.0",this.name,65536),this.db.transaction(function(b){b.executeSql(f,[],g,a)})},keys:function(b){var c=this.lambda(b),d=this,e="SELECT id FROM "+this.record+" ORDER BY timestamp DESC";return this.db.readTransaction(function(b){var f=function(a,b){if(0==b.rows.length)c.call(d,[]);else{for(var e=[],f=0,g=b.rows.length;g>f;f++)e.push(b.rows.item(f).id);c.call(d,e)}};b.executeSql(e,[],f,a)}),this},save:function(c,d,e){var f=this;objs=(this.isArray(c)?c:[c]).map(function(a){return a.key||(a.key=f.uuid()),a}),ins="INSERT OR REPLACE INTO "+this.record+" (value, timestamp, id) VALUES (?,?,?)",win=function(){d&&f.lambda(d).call(f,f.isArray(c)?objs:objs[0])},e=e||function(){},insvals=[],ts=b();try{for(var g=0,h=objs.length;h>g;g++)insvals[g]=[JSON.stringify(objs[g]),ts,objs[g].key]}catch(i){throw a(i),i}return f.db.transaction(function(a){for(var b=0,c=objs.length;c>b;b++)a.executeSql(ins,insvals[b])},function(b,c){a(b,c)},win),this},batch:function(a,b){return this.save(a,b)},get:function(b,c){var d=this,e="",f=this.isArray(b)?b:[b];e="SELECT id, value FROM "+this.record+" WHERE id IN ("+f.map(function(){return"?"}).join(",")+")";var g=function(a,e){for(var g,h,i={},j=0,k=e.rows.length;k>j;j++)g=JSON.parse(e.rows.item(j).value),g.key=e.rows.item(j).id,i[g.key]=g;h=f.map(function(a){return i[a]}),d.isArray(b)||(h=h.length?h[0]:null),c&&d.lambda(c).call(d,h)};return this.db.readTransaction(function(b){b.executeSql(e,f,g,a)}),this},exists:function(b,c){var d="SELECT * FROM "+this.record+" WHERE id = ?",e=this,f=function(a,b){c&&e.fn("exists",c).call(e,b.rows.length>0)};return this.db.readTransaction(function(c){c.executeSql(d,[b],f,a)}),this -},all:function(b){var c=this,d="SELECT * FROM "+this.record,e=[],f=this.fn(this.name,b)||void 0,g=function(a,b){if(0!=b.rows.length)for(var d=0,g=b.rows.length;g>d;d++){var h=JSON.parse(b.rows.item(d).value);h.key=b.rows.item(d).id,e.push(h)}f&&f.call(c,e)};return this.db.readTransaction(function(b){b.executeSql(d,[],g,a)}),this},remove:function(b,c){var d,e=this,f="DELETE FROM "+this.record+" WHERE id ",g=function(){c&&e.lambda(c).call(e)};return this.isArray(b)?(d=b,f+="IN ("+d.map(function(){return"?"}).join(",")+")"):(f+="= ?",d=[b]),d=d.map(function(a){return a.key?a.key:a}),this.db.transaction(function(b){b.executeSql(f,d,g,a)}),this},nuke:function(b){var c="DELETE FROM "+this.record,d=this,e=b?function(){d.lambda(b).call(d)}:function(){};return this.db.transaction(function(b){b.executeSql(c,[],e,a)}),this}}}()),f.adapter("html5-filesystem",function(a){var b=a.FileError,c=function(a){var c,d=!0;switch(a.code){case b.QUOTA_EXCEEDED_ERR:c="QUOTA_EXCEEDED_ERR";break;case b.NOT_FOUND_ERR:c="NOT_FOUND_ERR",d=!1;break;case b.SECURITY_ERR:c="SECURITY_ERR";break;case b.INVALID_MODIFICATION_ERR:c="INVALID_MODIFICATION_ERR";break;case b.INVALID_STATE_ERR:c="INVALID_STATE_ERR";break;default:c="Unknown Error"}console&&d&&console.error(a,c)},d=function(a,b,e){var f=e||[];a.readEntries(function(c){c.length?d(a,b,f.concat(Array.prototype.slice.call(c))):b&&b(f.map(function(a){return a.name}))},c)},e={},f=function(a,b){var c=e[a.name];c?b(c):setTimeout(function(){f(a,b)},10)},g=function(){var a=-1===document.URL.indexOf("http://")&&-1===document.URL.indexOf("https://");return a?!0:!1},h=function(a){var b;if(g())b=a;else{var c="application/json";try{b=new Blob([a],{type:c})}catch(d){var e=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if("TypeError"==d.name&&e){var f=new e;f.append([a.buffer]),b=f.getBlob(c)}else b=a}}return b};return{valid:function(){var b=a.requestFileSystem||a.webkitRequestFileSystem||a.moz_requestFileSystem;return!!b},init:function(b,d){function f(b){var c=a.requestFileSystem||a.webkitRequestFileSystem||a.moz_requestFileSystem,f=window.PERSISTENT;"undefined"!=typeof LocalFileSystem&&"undefined"!=typeof LocalFileSystem.PERSISTENT&&(f=LocalFileSystem.PERSISTENT),c(f,b,function(a){a.root.getDirectory(j,{create:!0},function(a){e[j]=a,d&&g.fn(g.name,d).call(g,g)},function(a){h(a)})},function(a){h(a)})}var g=this,h=function(a){c(a),d&&g.fn(g.name,d).call(g,g)},i=b.size||104857600,j=this.name;"undefined"!=typeof navigator.webkitPersistentStorage?navigator.webkitPersistentStorage.requestQuota(i,f,function(){logger.warn("User declined file storage"),h("User declined file storage")}):f(0)},keys:function(a){var b=this;return f(this,function(c){d(c.createReader(),function(c){a&&b.fn("keys",a).call(b,c)})}),this},save:function(a,b){var d=this,e=a.key||this.uuid();a.key=e;var g=function(a){c(a),b&&d.lambda(b).call(d)};return f(this,function(c){c.getFile(e,{create:!0},function(c){c.createWriter(function(c){c.onerror=g,c.onwriteend=function(){this.onwriteend=null,this.truncate(this.position),b&&d.lambda(b).call(d,a)};var e=JSON.stringify(a),f=h(e);c.write(f)},g)},g)}),this},batch:function(a,b){for(var c=this,d=[],e=0,f=a.length;f>e;e++)c.save(a[e],function(a){d.push(a),d.length===f&&b&&c.lambda(b).call(c,d)});return this},get:function(a,b){var d=this;if(this.isArray(a))for(var e=[],g=0,h=a.length;h>g;g++)d.get(a[g],function(a){a&&e.push(a),e.length===h&&b&&d.lambda(b).call(d,e)});else{var i=function(a){c(a),b&&d.lambda(b).call(d)};f(this,function(c){c.getFile(a,{create:!1},function(c){c.file(function(c){var e=new FileReader;e.onerror=i,e.onload=function(c){var e={};try{e=JSON.parse(c.target.result),e.key=a}catch(c){e={key:a}}b&&d.lambda(b).call(d,e)},e.readAsText(c)},i)},i)})}return this},exists:function(a,b){var c=this;return f(this,function(d){d.getFile(a,{create:!1},function(){b&&c.lambda(b).call(c,!0)},function(){b&&c.lambda(b).call(c,!1)})}),this},all:function(a){var b=this;return a&&this.keys(function(c){c.length?b.get(c,function(c){b.fn(b.name,a).call(b,c)}):b.fn(b.name,a).call(b,[])}),this},remove:function(a,b){var d=this,e=function(a){c(a),b&&d.lambda(b).call(d)};return f(this,function(c){c.getFile("string"==typeof a?a:a.key,{create:!1},function(a){a.remove(function(){b&&d.lambda(b).call(d)},e)},e)}),this},nuke:function(a){var b=this,c=0;return this.keys(function(d){if(d.length)for(var e=0,f=d.length;f>e;e++)b.remove(d[e],function(){c++,c===f&&a&&b.lambda(a).call(b)});else a&&b.lambda(a).call(b)}),this}}}(this)),f.adapter("memory",function(){var a={};return{valid:function(){return!0},init:function(b,c){a[this.name]=a[this.name]||{index:[],store:{}},this.index=a[this.name].index,this.store=a[this.name].store;var d=this.fn(this.name,c);return d&&d.call(this,this),this},keys:function(a){return this.fn("keys",a).call(this,this.index),this},save:function(a,b){var c=a.key||this.uuid();return this.exists(c,function(d){d||(a.key&&delete a.key,this.index.push(c)),this.store[c]=a,b&&(a.key=c,this.lambda(b).call(this,a))}),this},batch:function(a,b){for(var c=[],d=0,e=a.length;e>d;d++)this.save(a[d],function(a){c.push(a)});return b&&this.lambda(b).call(this,c),this},get:function(a,b){var c;if(this.isArray(a)){c=[];for(var d=0,e=a.length;e>d;d++)c.push(this.store[a[d]])}else c=this.store[a],c&&(c.key=a);return b&&this.lambda(b).call(this,c),this},exists:function(a,b){return this.lambda(b).call(this,!!this.store[a]),this},all:function(a){for(var b=[],c=0,d=this.index.length;d>c;c++){var e=this.store[this.index[c]];e.key=this.index[c],b.push(e)}return this.fn(this.name,a).call(this,b),this},remove:function(a,b){for(var c=this.isArray(a)?a:[a],d=0,e=c.length;e>d;d++){var f=c[d].key?c[d].key:c[d],g=this.indexOf(this.index,f);0>g||(delete this.store[f],this.index.splice(g,1))}return b&&this.lambda(b).call(this),this},nuke:function(b){return this.store=a[this.name].store={},this.index=a[this.name].index=[],b&&this.lambda(b).call(this),this}}}()),e("undefined"!=typeof f?f:window.Lawnchair)}.call(c,void 0,void 0,void 0,void 0,function(a){b.exports=a})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(_dereq_,module,exports){(function(global){__browserify_shim_require__=_dereq_,function browserifyShim(module,exports,_dereq_,define,browserify_shim__define__module__export__){var JSON;JSON||(JSON={}),function(){"use strict";function f(a){return 10>a?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g,h=gap,i=b[a];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(a)),"function"==typeof rep&&(i=rep.call(b,a,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";if(gap+=indent,g=[],"[object Array]"===Object.prototype.toString.apply(i)){for(f=i.length,c=0;f>c;c+=1)g[c]=str(c,i)||"null";return e=0===g.length?"[]":gap?"[\n"+gap+g.join(",\n"+gap)+"\n"+h+"]":"["+g.join(",")+"]",gap=h,e}if(rep&&"object"==typeof rep)for(f=rep.length,c=0;f>c;c+=1)"string"==typeof rep[c]&&(d=rep[c],e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));return e=0===g.length?"{}":gap?"{\n"+gap+g.join(",\n"+gap)+"\n"+h+"}":"{"+g.join(",")+"}",gap=h,e}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;"function"!=typeof JSON.stringify&&(JSON.stringify=function(a,b,c){var d;if(gap="",indent="","number"==typeof c)for(d=0;c>d;d+=1)indent+=" ";else"string"==typeof c&&(indent=c);if(rep=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return str("",{"":a})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&"object"==typeof e)for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),void 0!==d?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),browserify_shim__define__module__export__("undefined"!=typeof JSON?JSON:window.JSON)}.call(global,void 0,void 0,void 0,void 0,function(a){module.exports=a})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(a,b){function c(a,b,c){null!=a&&("number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))}function d(){return new c(null)}function e(a,b,c,d,e,f){for(;--f>=0;){var g=b*this[a++]+c[d]+e;e=Math.floor(g/67108864),c[d++]=67108863&g}return e}function f(a,b,c,d,e,f){for(var g=32767&b,h=b>>15;--f>=0;){var i=32767&this[a],j=this[a++]>>15,k=h*i+j*g;i=g*i+((32767&k)<<15)+c[d]+(1073741823&e),e=(i>>>30)+(k>>>15)+h*j+(e>>>30),c[d++]=1073741823&i}return e}function g(a,b,c,d,e,f){for(var g=16383&b,h=b>>14;--f>=0;){var i=16383&this[a],j=this[a++]>>14,k=h*i+j*g;i=g*i+((16383&k)<<14)+c[d]+e,e=(i>>28)+(k>>14)+h*j,c[d++]=268435455&i}return e}function h(a){return nb.charAt(a)}function i(a,b){var c=ob[a.charCodeAt(b)];return null==c?-1:c}function j(a){for(var b=this.t-1;b>=0;--b)a[b]=this[b];a.t=this.t,a.s=this.s}function k(a){this.t=1,this.s=0>a?-1:0,a>0?this[0]=a:-1>a?this[0]=a+DV:this.t=0}function l(a){var b=d();return b.fromInt(a),b}function m(a,b){var d;if(16==b)d=4;else if(8==b)d=3;else if(256==b)d=8;else if(2==b)d=1;else if(32==b)d=5;else{if(4!=b)return void this.fromRadix(a,b);d=2}this.t=0,this.s=0;for(var e=a.length,f=!1,g=0;--e>=0;){var h=8==d?255&a[e]:i(a,e);0>h?"-"==a.charAt(e)&&(f=!0):(f=!1,0==g?this[this.t++]=h:g+d>this.DB?(this[this.t-1]|=(h&(1<>this.DB-g):this[this.t-1]|=h<=this.DB&&(g-=this.DB))}8==d&&0!=(128&a[0])&&(this.s=-1,g>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==a;)--this.t}function o(a){if(this.s<0)return"-"+this.negate().toString(a);var b;if(16==a)b=4;else if(8==a)b=3;else if(2==a)b=1;else if(32==a)b=5;else{if(4!=a)return this.toRadix(a);b=2}var c,d=(1<0)for(i>i)>0&&(e=!0,f=h(c));g>=0;)b>i?(c=(this[g]&(1<>(i+=this.DB-b)):(c=this[g]>>(i-=b)&d,0>=i&&(i+=this.DB,--g)),c>0&&(e=!0),e&&(f+=h(c));return e?f:"0"}function p(){var a=d();return c.ZERO.subTo(this,a),a}function q(){return this.s<0?this.negate():this}function r(a){var b=this.s-a.s;if(0!=b)return b;var c=this.t;if(b=c-a.t,0!=b)return this.s<0?-b:b;for(;--c>=0;)if(0!=(b=this[c]-a[c]))return b;return 0}function s(a){var b,c=1;return 0!=(b=a>>>16)&&(a=b,c+=16),0!=(b=a>>8)&&(a=b,c+=8),0!=(b=a>>4)&&(a=b,c+=4),0!=(b=a>>2)&&(a=b,c+=2),0!=(b=a>>1)&&(a=b,c+=1),c}function t(){return this.t<=0?0:this.DB*(this.t-1)+s(this[this.t-1]^this.s&this.DM)}function u(a,b){var c;for(c=this.t-1;c>=0;--c)b[c+a]=this[c];for(c=a-1;c>=0;--c)b[c]=0;b.t=this.t+a,b.s=this.s}function v(a,b){for(var c=a;c=0;--c)b[c+g+1]=this[c]>>e|h,h=(this[c]&f)<=0;--c)b[c]=0;b[g]=h,b.t=this.t+g+1,b.s=this.s,b.clamp()}function x(a,b){b.s=this.s;var c=Math.floor(a/this.DB);if(c>=this.t)return void(b.t=0);var d=a%this.DB,e=this.DB-d,f=(1<>d;for(var g=c+1;g>d;d>0&&(b[this.t-c-1]|=(this.s&f)<c;)d+=this[c]-a[c],b[c++]=d&this.DM,d>>=this.DB;if(a.t>=this.DB;d+=this.s}else{for(d+=this.s;c>=this.DB;d-=a.s}b.s=0>d?-1:0,-1>d?b[c++]=this.DV+d:d>0&&(b[c++]=d),b.t=c,b.clamp()}function z(a,b){var d=this.abs(),e=a.abs(),f=d.t;for(b.t=f+e.t;--f>=0;)b[f]=0;for(f=0;f=0;)a[c]=0;for(c=0;c=b.DV&&(a[c+b.t]-=b.DV,a[c+b.t+1]=1)}a.t>0&&(a[a.t-1]+=b.am(c,b[c],a,2*c,0,1)),a.s=0,a.clamp()}function B(a,b,e){var f=a.abs();if(!(f.t<=0)){var g=this.abs();if(g.t0?(f.lShiftTo(k,h),g.lShiftTo(k,e)):(f.copyTo(h),g.copyTo(e));var l=h.t,m=h[l-1];if(0!=m){var n=m*(1<1?h[l-2]>>this.F2:0),o=this.FV/n,p=(1<=0&&(e[e.t++]=1,e.subTo(u,e)),c.ONE.dlShiftTo(l,u),u.subTo(h,h);h.t=0;){var v=e[--r]==m?this.DM:Math.floor(e[r]*o+(e[r-1]+q)*p);if((e[r]+=h.am(0,v,e,t,0,l))0&&e.rShiftTo(k,e),0>i&&c.ZERO.subTo(e,e)}}}function C(a){var b=d();return this.abs().divRemTo(a,null,b),this.s<0&&b.compareTo(c.ZERO)>0&&a.subTo(b,b),b}function D(a){this.m=a}function E(a){return a.s<0||a.compareTo(this.m)>=0?a.mod(this.m):a}function F(a){return a}function G(a){a.divRemTo(this.m,null,a)}function H(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function I(a,b){a.squareTo(b),this.reduce(b)}function J(){if(this.t<1)return 0;var a=this[0];if(0==(1&a))return 0;var b=3&a;return b=b*(2-(15&a)*b)&15,b=b*(2-(255&a)*b)&255,b=b*(2-((65535&a)*b&65535))&65535,b=b*(2-a*b%this.DV)%this.DV,b>0?this.DV-b:-b}function K(a){this.m=a,this.mp=a.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(b,b),b}function M(a){var b=d();return a.copyTo(b),this.reduce(b),b}function N(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var b=0;b>15)*this.mpl&this.um)<<15)&a.DM;for(c=b+this.m.t,a[c]+=this.m.am(0,d,a,b,0,this.m.t);a[c]>=a.DV;)a[c]-=a.DV,a[++c]++}a.clamp(),a.drShiftTo(this.m.t,a),a.compareTo(this.m)>=0&&a.subTo(this.m,a)}function O(a,b){a.squareTo(b),this.reduce(b)}function P(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function Q(){return 0==(this.t>0?1&this[0]:this.s)}function R(a,b){if(a>4294967295||1>a)return c.ONE;var e=d(),f=d(),g=b.convert(this),h=s(a)-1;for(g.copyTo(e);--h>=0;)if(b.sqrTo(e,f),(a&1<0)b.mulTo(f,g,e);else{var i=e;e=f,f=i}return b.revert(e)}function S(a,b){var c;return c=256>a||b.isEven()?new D(b):new K(b),this.exp(a,c)}function T(){this.i=0,this.j=0,this.S=new Array}function U(a){var b,c,d;for(b=0;256>b;++b)this.S[b]=b;for(c=0,b=0;256>b;++b)c=c+this.S[b]+a[b%a.length]&255,d=this.S[b],this.S[b]=this.S[c],this.S[c]=d;this.i=0,this.j=0}function V(){var a;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,a=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=a,this.S[a+this.S[this.i]&255]}function W(){return new T}function X(a){qb[rb++]^=255&a,qb[rb++]^=a>>8&255,qb[rb++]^=a>>16&255,qb[rb++]^=a>>24&255,rb>=sb&&(rb-=sb)}function Y(){X((new Date).getTime())}function Z(){if(null==pb){for(Y(),pb=W(),pb.init(qb),rb=0;rba?"0"+a.toString(16):a.toString(16)}function cb(a,b){if(b=0&&b>0;){var f=a.charCodeAt(e--);128>f?d[--b]=f:f>127&&2048>f?(d[--b]=63&f|128,d[--b]=f>>6|192):(d[--b]=63&f|128,d[--b]=f>>6&63|128,d[--b]=f>>12|224)}d[--b]=0;for(var g=new _,h=new Array;b>2;){for(h[0]=0;0==h[0];)g.nextBytes(h);d[--b]=h[0]}return d[--b]=2,d[--b]=0,new c(d)}function db(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function eb(a,b){null!=a&&null!=b&&a.length>0&&b.length>0?(this.n=ab(a,16),this.e=parseInt(b,16)):alert("Invalid RSA public key")}function fb(a){return a.modPowInt(this.e,this.n)}function gb(a){var b=cb(a,this.n.bitLength()+7>>3);if(null==b)return null;var c=this.doPublic(b);if(null==c)return null;var d=c.toString(16);return 0==(1&d.length)?d:"0"+d}var hb,ib=0xdeadbeefcafe,jb=15715070==(16777215&ib);jb&&"Microsoft Internet Explorer"==navigator.appName?(c.prototype.am=f,hb=30):jb&&"Netscape"!=navigator.appName?(c.prototype.am=e,hb=26):(c.prototype.am=g,hb=28),c.prototype.DB=hb,c.prototype.DM=(1<=mb;++mb)ob[lb++]=mb;for(lb="a".charCodeAt(0),mb=10;36>mb;++mb)ob[lb++]=mb;for(lb="A".charCodeAt(0),mb=10;36>mb;++mb)ob[lb++]=mb;D.prototype.convert=E,D.prototype.revert=F,D.prototype.reduce=G,D.prototype.mulTo=H,D.prototype.sqrTo=I,K.prototype.convert=L,K.prototype.revert=M,K.prototype.reduce=N,K.prototype.mulTo=P,K.prototype.sqrTo=O,c.prototype.copyTo=j,c.prototype.fromInt=k,c.prototype.fromString=m,c.prototype.clamp=n,c.prototype.dlShiftTo=u,c.prototype.drShiftTo=v,c.prototype.lShiftTo=w,c.prototype.rShiftTo=x,c.prototype.subTo=y,c.prototype.multiplyTo=z,c.prototype.squareTo=A,c.prototype.divRemTo=B,c.prototype.invDigit=J,c.prototype.isEven=Q,c.prototype.exp=R,c.prototype.toString=o,c.prototype.negate=p,c.prototype.abs=q,c.prototype.compareTo=r,c.prototype.bitLength=t,c.prototype.mod=C,c.prototype.modPowInt=S,c.ZERO=l(0),c.ONE=l(1),T.prototype.init=U,T.prototype.next=V;var pb,qb,rb,sb=256;if(null==qb){qb=new Array,rb=0;var tb;if("Netscape"==navigator.appName&&navigator.appVersion<"5"&&window.crypto){var ub=window.crypto.random(32);for(tb=0;tbrb;)tb=Math.floor(65536*Math.random()),qb[rb++]=tb>>>8,qb[rb++]=255&tb;rb=0,Y()}_.prototype.nextBytes=$,db.prototype.doPublic=fb,db.prototype.setPublic=eb,db.prototype.encrypt=gb,b.exports={SecureRandom:_,byte2Hex:bb,RSAKey:db}},{}],5:[function(a,b){function c(a,b){return m.isUndefined(b)?""+b:!m.isNumber(b)||!isNaN(b)&&isFinite(b)?m.isFunction(b)||m.isRegExp(b)?b.toString():b:b.toString()}function d(a,b){return m.isString(a)?a.length=0;d--)if(e[d]!=f[d])return!1;for(d=e.length-1;d>=0;d--)if(c=e[d],!h(a[c],b[c]))return!1;return!0}function k(a,b){return a&&b?"[object RegExp]"==Object.prototype.toString.call(b)?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function l(a,b,c,d){var e;m.isString(c)&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f(e,c,"Missing expected exception"+d),!a&&k(e,c)&&f(e,c,"Got unwanted exception"+d),a&&e&&c&&!k(e,c)||!a&&e)throw e}var m=a("util/"),n=Array.prototype.slice,o=Object.prototype.hasOwnProperty,p=b.exports=g;p.AssertionError=function(a){this.name="AssertionError",this.actual=a.actual,this.expected=a.expected,this.operator=a.operator,a.message?(this.message=a.message,this.generatedMessage=!1):(this.message=e(this),this.generatedMessage=!0);var b=a.stackStartFunction||f;if(Error.captureStackTrace)Error.captureStackTrace(this,b);else{var c=new Error;if(c.stack){var d=c.stack,g=b.name,h=d.indexOf("\n"+g);if(h>=0){var i=d.indexOf("\n",h+1);d=d.substring(i+1)}this.stack=d}}},m.inherits(p.AssertionError,Error),p.fail=f,p.ok=g,p.equal=function(a,b,c){a!=b&&f(a,b,c,"==",p.equal)},p.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",p.notEqual)},p.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",p.deepEqual)},p.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",p.notDeepEqual)},p.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",p.strictEqual)},p.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",p.notStrictEqual)},p.throws=function(){l.apply(this,[!0].concat(n.call(arguments)))},p.doesNotThrow=function(){l.apply(this,[!1].concat(n.call(arguments)))},p.ifError=function(a){if(a)throw a};var q=Object.keys||function(a){var b=[];for(var c in a)o.call(a,c)&&b.push(c);return b}},{"util/":7}],6:[function(a,b){b.exports=function(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.readUInt8}},{}],7:[function(a,b,c){(function(b,d){function e(a,b){var d={seen:[],stylize:g};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),p(b)?d.showHidden=b:b&&c._extend(d,b),v(d.showHidden)&&(d.showHidden=!1),v(d.depth)&&(d.depth=2),v(d.colors)&&(d.colors=!1),v(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=f),i(d,a,d.depth)}function f(a,b){var c=e.styles[b];return c?"["+e.colors[c][0]+"m"+a+"["+e.colors[c][1]+"m":a}function g(a){return a}function h(a){var b={};return a.forEach(function(a){b[a]=!0}),b}function i(a,b,d){if(a.customInspect&&b&&A(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d,a);return t(e)||(e=i(a,e,d)),e}var f=j(a,b);if(f)return f;var g=Object.keys(b),p=h(g);if(a.showHidden&&(g=Object.getOwnPropertyNames(b)),z(b)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return k(b);if(0===g.length){if(A(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(w(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(y(b))return a.stylize(Date.prototype.toString.call(b),"date");if(z(b))return k(b)}var r="",s=!1,u=["{","}"];if(o(b)&&(s=!0,u=["[","]"]),A(b)){var v=b.name?": "+b.name:"";r=" [Function"+v+"]"}if(w(b)&&(r=" "+RegExp.prototype.toString.call(b)),y(b)&&(r=" "+Date.prototype.toUTCString.call(b)),z(b)&&(r=" "+k(b)),0===g.length&&(!s||0==b.length))return u[0]+r+u[1];if(0>d)return w(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var x;return x=s?l(a,b,d,p,g):g.map(function(c){return m(a,b,d,p,c,s)}),a.seen.pop(),n(x,r,u)}function j(a,b){if(v(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return s(b)?a.stylize(""+b,"number"):p(b)?a.stylize(""+b,"boolean"):q(b)?a.stylize("null","null"):void 0}function k(a){return"["+Error.prototype.toString.call(a)+"]"}function l(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)f.push(F(b,String(g))?m(a,b,c,d,String(g),!0):"");return e.forEach(function(e){e.match(/^\d+$/)||f.push(m(a,b,c,d,e,!0))}),f}function m(a,b,c,d,e,f){var g,h,j;if(j=Object.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?h=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(h=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),h||(a.seen.indexOf(j.value)<0?(h=q(c)?i(a,j.value,null):i(a,j.value,c-1),h.indexOf("\n")>-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),v(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function n(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function o(a){return Array.isArray(a)}function p(a){return"boolean"==typeof a}function q(a){return null===a}function r(a){return null==a}function s(a){return"number"==typeof a}function t(a){return"string"==typeof a}function u(a){return"symbol"==typeof a}function v(a){return void 0===a}function w(a){return x(a)&&"[object RegExp]"===C(a)}function x(a){return"object"==typeof a&&null!==a}function y(a){return x(a)&&"[object Date]"===C(a)}function z(a){return x(a)&&("[object Error]"===C(a)||a instanceof Error)}function A(a){return"function"==typeof a}function B(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),J[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=/%[sdj%]/g;c.format=function(a){if(!t(a)){for(var b=[],c=0;c=f)return a;switch(a){case"%s":return String(d[c++]);case"%d":return Number(d[c++]);case"%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),h=d[c];f>c;h=d[++c])g+=q(h)||!x(h)?" "+h:" "+e(h);return g},c.deprecate=function(a,e){function f(){if(!g){if(b.throwDeprecation)throw new Error(e);b.traceDeprecation?console.trace(e):console.error(e),g=!0}return a.apply(this,arguments)}if(v(d.process))return function(){return c.deprecate(a,e).apply(this,arguments)};if(b.noDeprecation===!0)return a;var g=!1;return f};var H,I={};c.debuglog=function(a){if(v(H)&&(H=b.env.NODE_DEBUG||""),a=a.toUpperCase(),!I[a])if(new RegExp("\\b"+a+"\\b","i").test(H)){var d=b.pid;I[a]=function(){var b=c.format.apply(c,arguments);console.error("%s %d: %s",a,d,b)}}else I[a]=function(){};return I[a]},c.inspect=e,e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=o,c.isBoolean=p,c.isNull=q,c.isNullOrUndefined=r,c.isNumber=s,c.isString=t,c.isSymbol=u,c.isUndefined=v,c.isRegExp=w,c.isObject=x,c.isDate=y,c.isError=z,c.isFunction=A,c.isPrimitive=B,c.isBuffer=a("./support/isBuffer");var J=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=a("inherits"),c._extend=function(a,b){if(!b||!x(b))return a;for(var c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}}).call(this,a("/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":6,"/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,inherits:10}],8:[function(a,b){(function(c){function d(){}function e(){m.log.apply(m,arguments)}function f(){m.log.apply(m,arguments)}function g(){m.warn.apply(m,arguments)}function h(a){p[a]=Date.now()}function i(a){var b=p[a];if(!b)throw new Error("No such label: "+a);var c=Date.now()-b;m.log(a+": "+c+"ms")}function j(){var a=new Error;a.name="Trace",a.message=n.format.apply(null,arguments),m.error(a.stack)}function k(a){m.log(n.inspect(a)+"\n")}function l(a){if(!a){var b=o.call(arguments,1);l.ok(!1,n.format.apply(null,b))}}var m,n=a("util"),l=a("assert"),o=Array.prototype.slice,p={};m="undefined"!=typeof c&&c.console?c.console:"undefined"!=typeof window&&window.console?window.console:{};for(var q=[[d,"log"],[e,"info"],[f,"warn"],[g,"error"],[h,"time"],[i,"timeEnd"],[j,"trace"],[k,"dir"],[l,"assert"]],r=0;ra||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,h,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||f(this._events.error)&&!this._events.error.length))throw b=arguments[1],b instanceof Error?b:TypeError('Uncaught, unspecified "error" event.');if(c=this._events[a],g(c))return!1;if(d(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];c.apply(this,h)}else if(f(c)){for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];for(j=c.slice(),e=j.length,i=0;e>i;i++)j[i].apply(this,h)}return!0},c.prototype.addListener=function(a,b){var e;if(!d(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d(b.listener)?b.listener:b),this._events[a]?f(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,f(this._events[a])&&!this._events[a].warned){var e;e=g(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace()) -}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),e||(e=!0,b.apply(this,arguments))}if(!d(b))throw TypeError("listener must be a function");var e=!1;return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,g,h;if(!d(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],g=c.length,e=-1,c===b||d(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(f(c)){for(h=g;h-->0;)if(c[h]===b||c[h].listener&&c[h].listener===b){e=h;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d(a._events[b])?1:a._events[b].length:0}},{}],10:[function(a,b){b.exports="function"==typeof Object.create?function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],11:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],12:[function(a,b){b.exports=a(6)},{}],13:[function(a,b){b.exports=a(7)},{"./support/isBuffer":12,"/Users/ndonnelly/program_source_for_dev/fh-js-sdk/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,inherits:10}],14:[function(a,b){!function(a){var c="undefined";!function(a,c){"undefined"!=typeof b?b.exports=c():"function"==typeof define&&"object"==typeof define.amd?define(c):this[a]=c()}("log",function(){function b(b){return typeof console===c?l:console[b]===a?console.log!==a?d(console,"log"):l:d(console,b)}function d(b,c){var d=b[c];if(d.bind!==a)return b[c].bind(b);if(Function.prototype.bind===a)return e(d,b);try{return Function.prototype.bind.call(b[c],b)}catch(f){return e(d,b)}}function e(a,b){return function(){Function.prototype.apply.apply(a,[b,arguments])}}function f(a){for(var b=0;b=0&&d<=k.levels.SILENT){if(i(d),d===k.levels.SILENT)return void f(function(){return l});if(typeof console===c)return f(function(a){return function(){typeof console!==c&&(k.setLevel(d),k[a].apply(k,arguments))}}),"No console available for logging";f(function(a){return d<=k.levels[a.toUpperCase()]?b(a):l})}else{if("string"!=typeof d||k.levels[d.toUpperCase()]===a)throw"log.setLevel() called with invalid level: "+d;k.setLevel(k.levels[d.toUpperCase()])}},k.enableAll=function(){k.setLevel(k.levels.TRACE)},k.disableAll=function(){k.setLevel(k.levels.SILENT)},j(),k})}()},{}],15:[function(a,b){var c=Object.prototype.toString;b.exports=function(a){switch(c.call(a)){case"[object Function]":return"function";case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object String]":return"string"}if("object"==typeof a&&a&&"number"==typeof a.length)try{if("function"==typeof a.callee)return"arguments"}catch(b){if(b instanceof TypeError)return"arguments"}return null===a?"null":void 0===a?"undefined":a&&1===a.nodeType?"element":a===Object(a)?"object":typeof a}},{}],16:[function(a,b){var c=a("./modules/constants"),d=a("./modules/logger"),e=a("./modules/ajax"),f=a("./modules/events"),g=a("./modules/waitForCloud"),h=a("./modules/api_act"),i=a("./modules/api_auth"),j=a("./modules/api_sec"),k=a("./modules/api_hash"),l=a("./modules/sync-cli"),m=a("./modules/api_mbaas"),n=a("./modules/api_cloud"),o=a("./modules/fhparams"),p=a("./modules/appProps"),q=a("./modules/device"),r=function(a,b){f.addListener(a,b),a===c.INIT_EVENT&&(g.isReady()?b(null,{host:g.getCloudHostUrl()}):g.getInitError()&&b(g.getInitError()))},s=function(a,b){a===c.INIT_EVENT&&g.isReady()?b(null,{host:g.getCloudHostUrl()}):a===c.INIT_EVENT&&g.getInitError()?b(g.getInitError()):f.once(a,b)},t=function(a,b,c){d.warn("$fh.init will be deprecated soon"),g.ready(function(a,d){if(a){if("function"==typeof c)return c(a)}else"function"==typeof b&&b(d.host)})},u=window.$fh||{};u.init=t,u.act=h,u.auth=i,u.cloud=n,u.sec=j,u.hash=k,u.sync=l,u.ajax=u.__ajax=e,u.mbaas=m,u._getDeviceId=q.getDeviceId,u.fh_timeout=6e4,u.getCloudURL=function(){return g.getCloudHostUrl()},u.getFHParams=function(){return o.buildFHParams()},u.addListener=r,u.on=r,u.once=s;for(var v=["removeListener","removeAllListeners","setMaxListeners","listeners","emit"],w=0;w=0&&(a=!0),a}function m(a){var b=null;return window.XMLHttpRequest&&(b=new XMLHttpRequest),l()&&a===!0&&"undefined"!=typeof window.XDomainRequest&&(b=new v(new XDomainRequest)),"undefined"!=typeof Titanium&&(b=Titanium.Network.createHTTPClient({timeout:I.settings.timeout})),b}function n(a){return a&&(a==G?"html":a==F?"json":D.test(a)?"script":E.test(a)&&"xml")||"text"}function o(a,b){return(a+"&"+b).replace(/[&?]{1,2}/,"?")}function p(a){"object"===t(a.data)&&("function"==typeof a.data.append?a.formdata=!0:a.data=r(a.data)),!a.data||a.type&&"GET"!=a.type.toUpperCase()||(a.url=o(a.url,a.data))}function q(a,b,c,d){var e="array"===t(b);for(var f in b){var g=b[f];d&&(f=c?d:d+"["+(e?"":f)+"]"),!d&&e?a.add(g.name,g.value):(c?"array"===t(g):"object"===t(g))?q(a,g,c,f):a.add(f,g)}}function r(a,b){var c=[];return c.add=function(a,b){this.push(J(a)+"="+J(b))},q(c,a,b),c.join("&").replace("%20","+")}function s(a){var b=Array.prototype.slice;return b.call(arguments,1).forEach(function(b){for(z in b)void 0!==b[z]&&(a[z]=b[z])}),a}var t,u=a("./events"),v=a("./XDomainRequestWrapper"),w=a("./logger");try{t=a("type-of")}catch(x){var y=a;t=y("type")}var z,A,B=0,C=window.document,D=/^(?:text|application)\/javascript/i,E=/^(?:text|application)\/xml/i,F="application/json",G="text/html",H=/^\s*$/,I=b.exports=function(a){var b=s({},a||{});window&&window.$fh&&"number"==typeof window.$fh.fh_timeout&&(I.settings.timeout=window.$fh.fh_timeout);for(z in I.settings)void 0===b[z]&&(b[z]=I.settings[z]);e(b),b.crossDomain||(b.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(b.url)&&(RegExp.$1!=window.location.protocol||RegExp.$2!=window.location.host));var c=b.dataType,d=/=\?/.test(b.url);if("jsonp"==c||d)return d||(b.url=o(b.url,(b.jsonp?b.jsonp:"_callback")+"=?")),I.JSONP(b);b.url||(b.url=window.location.toString()),p(b);var f,j=b.accepts[c],l={},m=/^([\w-]+:)\/\//.test(b.url)?RegExp.$1:window.location.protocol,q=b.xhr(b.crossDomain);b.crossDomain||(l["X-Requested-With"]="XMLHttpRequest"),j&&(l.Accept=j,j.indexOf(",")>-1&&(j=j.split(",",2)[0]),q.overrideMimeType&&q.overrideMimeType(j)),(b.contentType||b.data&&!b.formdata&&"GET"!=b.type.toUpperCase())&&(l["Content-Type"]=b.contentType||"application/x-www-form-urlencoded"),b.headers=s(l,b.headers||{}),"undefined"!=typeof Titanium&&q.setOnerror(function(){f&&(clearTimeout(f),i(null,"error",q,b))}),q.onreadystatechange=function(){if(4==q.readyState){clearTimeout(f),f=void 0;var a,d=!1;if(b.tryJSONP&&0===q.status&&b.crossDomain&&!q.isTimeout&&"file:"!=m)return w.debug("retry ajax call with jsonp"),b.type="GET",b.dataType="jsonp",b.data="_jsonpdata="+b.data,I(b);if(q.status>=200&&q.status<300||304==q.status||0==q.status&&"file:"==m){c=c||n(q.getResponseHeader("content-type")),a=q.responseText,w.debug("ajax response :: status = "+q.status+" :: body = "+a);try{"script"==c?(1,eval)(a):"xml"==c?a=q.responseXML:"json"==c&&(a=H.test(a)?null:JSON.parse(a))}catch(e){d=e}d?(w.debug("ajax error",d),i(d,"parsererror",q,b)):h(a,q,b)}else i(null,"error",q,b)}};var r="async"in b?b.async:!0;w.debug("ajax call settings",b),q.open(b.type,b.url,r);for(A in b.headers)q.setRequestHeader(A,b.headers[A]);return g(q,b)===!1?(w.debug("ajax call is aborted due to ajaxBeforeSend"),q.abort(),!1):(b.timeout>0&&(f=setTimeout(function(){w.debug("ajax call timed out"),q.onreadystatechange=k,q.abort(),q.isTimeout=!0,i(null,"timeout",q,b)},b.timeout)),q.send(b.data?b.data:null),q)};I.active=0,I.JSONP=function(a){if(!("type"in a))return I(a);var b,c="jsonp"+ ++B,d=C.createElement("script"),e=function(){c in window&&(window[c]=k),j("abort",f,a)},f={abort:e},g=C.getElementsByTagName("head")[0]||C.documentElement;return a.error&&(d.onerror=function(){f.abort(),a.error()}),window[c]=function(d){clearTimeout(b),b=void 0,delete window[c],h(d,f,a)},p(a),d.src=a.url.replace(/=\?/,"="+c),g.insertBefore(d,g.firstChild),a.timeout>0&&(b=setTimeout(function(){f.abort(),j("timeout",f,a)},a.timeout)),f},I.settings={type:"GET",beforeSend:k,success:k,error:k,complete:k,context:null,global:!0,xhr:m,accepts:{script:"text/javascript, application/javascript",json:F,xml:"application/xml, text/xml",html:G,text:"text/plain"},crossDomain:!1},I.get=function(a,b){return I({url:a,success:b})},I.post=function(a,b,c,d){return"function"===t(b)&&(d=d||c,c=b,b=null),I({type:"POST",url:a,data:b,success:c,dataType:d})},I.getJSON=function(a,b){return I({url:a,success:b,dataType:"json"})};var J=encodeURIComponent},{"./XDomainRequestWrapper":17,"./events":30,"./logger":37,"type-of":15}],19:[function(a,b){function c(a,b,c){var d=e.getCloudHost(),k=d.getActUrl(a.act),l=a.req||{};return l=f.addFHParams(l),g({url:k,tryJSONP:!0,type:"POST",dataType:"json",data:h.stringify(l),contentType:"application/json",timeout:a.timeout||j.timeout,success:b,error:function(a,b,d){return i(c,a,b,d)}})}var d=a("./logger"),e=a("./waitForCloud"),f=a("./fhparams"),g=a("./ajax"),h=a("JSON"),i=a("./handleError"),j=a("./appProps");b.exports=function(a,b,f){return d.debug("act is called"),f||(f=function(a,b){d.debug(a+":"+h.stringify(b))}),a.act?void e.ready(function(e){return d.debug("Calling fhact now"),e?f(e.message,e):void c(a,b,f)}):f("act_no_action",{})}},{"./ajax":18,"./appProps":25,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],20:[function(a,b){var c=a("./logger"),d=a("./waitForCloud"),e=a("./fhparams"),f=a("./ajax"),g=a("JSON"),h=a("./handleError"),i=a("./device"),j=a("./constants"),k=a("./checkAuth"),l=a("./appProps");b.exports=function(a,b,m){return m||(m=function(a,b){c.debug(a+":"+g.stringify(b))}),a.policyId?a.clientToken?void d.ready(function(c){if(c)return m(c.message,c);var d={};d.policyId=a.policyId,d.clientToken=a.clientToken,a.endRedirectUrl&&(d.endRedirectUrl=a.endRedirectUrl,a.authCallback&&(d.endRedirectUrl+=(/\?/.test(d.endRedirectUrl)?"&":"?")+"_fhAuthCallback="+a.authCallback)),d.params={},a.params&&(d.params=a.params);var n=a.endRedirectUrl||"status=complete";d.device=i.getDeviceId();var o=l.getAppProps(),p=o.host+j.boxprefix+"admin/authpolicy/auth";d=e.addFHParams(d),f({url:p,type:"POST",tryJSONP:!0,data:g.stringify(d),dataType:"json",contentType:"application/json",timeout:a.timeout||o.timeout,success:function(a){k.handleAuthResponse(n,a,b,m)},error:function(a,b,c){h(m,a,b,c)}})}):m("auth_no_clientToken",{}):m("auth_no_policyId",{})}},{"./ajax":18,"./appProps":25,"./checkAuth":26,"./constants":27,"./device":29,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],21:[function(a,b){function c(a,b,c){var d=e.getCloudHost(),k=d.getCloudUrl(a.path),l=a.data||{};return l=f.addFHParams(l),g({url:k,type:a.method||"POST",dataType:a.dataType||"json",data:h.stringify(l),contentType:a.contentType||"application/json",timeout:a.timeout||j.timeout,success:b,error:function(a,b,d){return i(c,a,b,d)}})}var d=a("./logger"),e=a("./waitForCloud"),f=a("./fhparams"),g=a("./ajax"),h=a("JSON"),i=a("./handleError"),j=a("./appProps");b.exports=function(a,b,f){d.debug("cloud is called"),f||(f=function(a,b){d.debug(a+":"+h.stringify(b))}),e.ready(function(e){return d.debug("Calling fhact now"),e?f(e.message,e):void c(a,b,f)})}},{"./ajax":18,"./appProps":25,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],22:[function(a,b){var c=a("./security/hash");b.exports=function(a,b,d){var e={};"undefined"==typeof a.algorithm&&(a.algorithm="MD5"),e.act="hash",e.params=a,c(e,b,d)}},{"./security/hash":43}],23:[function(a,b){var c=a("./logger"),d=a("./waitForCloud"),e=a("./fhparams"),f=a("./ajax"),g=a("JSON"),h=a("./handleError"),i=(a("./constants"),a("./appProps"));b.exports=function(a,b,j){c.debug("mbaas is called."),j||(j=function(a,b){console.debug(a+":"+g.stringify(b))});var k=a.service,l=a.params;d.ready(function(m){if(c.debug("Calling mbaas now"),m)return j(m.message,m);var n=d.getCloudHost(),o=n.getMBAASUrl(k);return l=e.addFHParams(l),f({url:o,tryJSONP:!0,type:"POST",dataType:"json",data:g.stringify(l),contentType:"application/json",timeout:a.timeout||i.timeout,success:b,error:function(a,b,c){return h(j,a,b,c)}})})}},{"./ajax":18,"./appProps":25,"./constants":27,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],24:[function(a,b){var c=a("./security/aes-keygen"),d=a("./security/aes-node"),e=a("./security/rsa-node"),f=a("./security/hash");b.exports=function(a,b,g){return a.act?a.params?a.params.algorithm?(a.params.algorithm=a.params.algorithm.toLowerCase(),"hash"===a.act?f(a,b,g):"encrypt"===a.act?"aes"===a.params.algorithm?d.encrypt(a,b,g):"rsa"===a.params.algorithm?e.encrypt(a,b,g):g("encrypt_bad_algorithm:"+a.params.algorithm,{},a):"decrypt"===a.act?"aes"===a.params.algorithm?d.decrypt(a,b,g):g("decrypt_bad_algorithm:"+a.params.algorithm,{},a):"keygen"===a.act?"aes"===a.params.algorithm?c(a,b,g):g("keygen_bad_algorithm:"+a.params.algorithm,{},a):void 0):void g("no_params_algorithm",{},a):void g("no_params",{},a):void g("bad_act",{},a)}},{"./security/aes-keygen":41,"./security/aes-node":42,"./security/hash":43,"./security/rsa-node":44}],25:[function(a,b){var c=a("./constants"),d=a("./ajax"),e=a("./logger"),f=a("./queryMap"),g=null,h=function(a){var b=document.location.href,h=f(b),i="undefined"!=typeof h.url;if(i)return g={},g.local=!0,g.host=h.url.replace(/#.*?$/g,""),g.appid="000000000000000000000000",g.appkey="0000000000000000000000000000000000000000",g.projectid="000000000000000000000000",g.connectiontag="0.0.1",g.loglevel=h.loglevel,a(null,g);var j=h.fhconfig||c.config_js;d({url:j,dataType:"json",success:function(b){return e.debug("fhconfig = "+JSON.stringify(b)),null==b?window.fh_app_props?(g=window.fh_app_props,a(null,window.fh_app_props)):a(new Error("app_config_missing")):(g=b,void a(null,g))},error:function(){return window.fh_app_props?(g=window.fh_app_props,a(null,window.fh_app_props)):(e.error(c.config_js+" Not Found"),void a(new Error("app_config_missing")))}})},i=function(a){g=a},j=function(){return g};b.exports={load:h,getAppProps:j,setAppProps:i}},{"./ajax":18,"./constants":27,"./logger":37,"./queryMap":39}],26:[function(a,b){var c=a("./logger"),d=a("./queryMap"),e=a("JSON"),f=a("./fhparams"),g=function(a){if(/\_fhAuthCallback/.test(a)){var b=d(a);if(b){var c=b._fhAuthCallback;if(c)if(b.result&&"success"===b.result){var g={sessionToken:b.fh_auth_session,authResponse:e.parse(decodeURIComponent(decodeURIComponent(b.authResponse)))};f.setAuthSessionToken(b.fh_auth_session),window[c](null,g)}else window[c]({message:b.message})}}},h=function(a,b,g,h){if(b.status&&"ok"===b.status){var i=function(a){a.sessionToken&&f.setAuthSessionToken(a.sessionToken),g(a)};if(b.url){var j=null,k=function(b){if(b.indexOf(a)>-1){j&&j.close();var c=d(b);if(c)if(c.result&&"success"===c.result){var f={sessionToken:c.fh_auth_session,authResponse:e.parse(decodeURIComponent(decodeURIComponent(c.authResponse)))};i(f)}else h&&h("auth_failed",{message:c.message});else h&&h("auth_failed",{message:c.message})}};if(window.PhoneGap||window.cordova)if(window.plugins&&window.plugins.childBrowser)"function"==typeof window.plugins.childBrowser.showWebPage&&(window.plugins.childBrowser.onLocationChange=k,window.plugins.childBrowser.showWebPage(b.url),j=window.plugins.childBrowser);else try{j=window.open(b.url,"_blank","location=yes"),j.addEventListener("loadstart",function(a){k(a.url)})}catch(l){c.info("InAppBrowser plugin is not intalled."),i(b)}else document.location.href=b.url}else i(b)}else h&&h("auth_failed",b)};window.addEventListener?window.addEventListener("load",function(){g(window.location.href)},!1):window.attachEvent&&window.attachEvent("onload",function(){g(window.location.href)}),b.exports={handleAuthResponse:h}},{"./fhparams":31,"./logger":37,"./queryMap":39,JSON:3}],27:[function(a,b){b.exports={boxprefix:"/box/srv/1.1/",sdk_version:"2.0.17-alpha",config_js:"fhconfig.json",INIT_EVENT:"fhinit"}},{}],28:[function(a,b){b.exports={readCookieValue:function(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d1?b=f[1]:"undefined"!=typeof window.fh_destination_code?b=window.fh_destination_code:c.forEach(function(a){a.test.forEach(function(c){d.indexOf(c)>-1&&(b=a.destination)})}),null==b&&(b="web"),e.debug("destination = "+b),b}}},{"./cookies":28,"./logger":37,"./platformsMap":38,"./uuid":46}],30:[function(a,b){var c=a("events").EventEmitter,d=new c;d.setMaxListeners(0),b.exports=d},{events:9}],31:[function(a,b){var c=a("./device"),d=a("./sdkversion"),e=a("./appProps"),f=a("./logger"),g=null,h=null,i=function(){if(g)return g;var a={};a.cuid=c.getDeviceId(),a.cuidMap=c.getCuidMap(),a.destination=c.getDestination(),(window.device||navigator.device)&&(a.device=window.device||navigator.device),"undefined"!=typeof window.fh_app_version&&(a.app_version=fh_app_version),"undefined"!=typeof window.fh_project_version&&(a.project_version=fh_project_version),"undefined"!=typeof window.fh_project_app_version&&(a.project_app_version=fh_project_app_version),a.sdk_version=d(),h&&(a.sessionToken=h);var b=e.getAppProps();return b&&(a.appid=b.appid,a.appkey=b.appkey,a.projectid=b.projectid,a.analyticsTag=b.analyticsTag,a.connectiontag=b.connectiontag,b.init&&(a.init="string"==typeof b.init?JSON.parse(b.init):b.init)),g=a,f.debug("fhparams = ",g),a},j=function(a){var a=a||{};return a.__fh=i(),a},k=function(a){h=a};b.exports={buildFHParams:i,addFHParams:j,setAuthSessionToken:k}},{"./appProps":25,"./device":29,"./logger":37,"./sdkversion":40}],32:[function(a,b){var c=a("JSON");b.exports=function(a,b,d,e){var f,g=0;if(b)try{g=b.status;var h=c.parse(b.responseText);f=h.error||h.msg,f instanceof Array&&(f=f.join("\n"))}catch(i){f=b.responseText}a&&a(f,{status:g,message:d,error:e})}},{JSON:3}],33:[function(a,b){function c(a){var b=a;return"/"===b.charAt(b.length-1)&&(b=b.substring(0,b.length-1)),b}function d(a){var b=a;return b.length>1&&"/"===b.charAt(0)&&(b=b.substring(1,b.length)),b}function e(a){this.cloud_props=a,this.cloud_host=void 0,this.isLegacy=!1}var f=a("./constants"),g=a("./appProps");e.prototype.getHost=function(a){if(this.cloud_host)return this.cloud_host;var b,d;if(this.cloud_props&&this.cloud_props.hosts&&(b=this.cloud_props.hosts.url,"undefined"==typeof b)){var e=this.cloud_props.hosts.releaseCloudUrl;d=this.cloud_props.hosts.releaseCloudType,"undefined"!=typeof a&&a.indexOf("dev")>-1&&(e=this.cloud_props.hosts.debugCloudUrl,d=this.cloud_props.hosts.debugCloudType),b=e}return b=c(b),this.cloud_host=b,"fh"===d&&(this.isLegacy=!0),b},e.prototype.getActUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.isLegacy?this.cloud_host+f.boxprefix+"act/"+this.cloud_props.domain+"/"+b.appid+"/"+a+"/"+b.appid:this.cloud_host+"/cloud/"+a},e.prototype.getMBAASUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.cloud_host+"/mbaas/"+a},e.prototype.getCloudUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.cloud_host+"/"+d(a)},b.exports=e},{"./appProps":25,"./constants":27}],34:[function(a,b){var c=(a("./loadScript"),a("../../libs/generated/lawnchair")),d=a("./lawnchair-ext"),e=a("./constants"),f=a("./fhparams"),g=a("./ajax"),h=a("./handleError"),i=a("./logger"),j=a("JSON"),k=a("./security/hash"),l=a("./appProps"),m=function(a){l.load(function(b,c){return b?a(b):n(c,a)})},n=function(a,b){if(a.loglevel&&i.setLevel(a.loglevel),a.local){var l={domain:"local",firstTime:!1,hosts:{debugCloudType:"node",debugCloudUrl:a.host,releaseCloudType:"node",releaseCloudUrl:a.host,type:"cloud_nodejs",url:a.host},init:{trackId:"000000000000000000000000"},status:"ok"};return b(null,{cloud:l})}d.addAdapter(a,k);var m={name:"fh_init_storage",adapter:["dom","webkit-sqlite","window-name"],fail:function(a,b){var c="read/save from/to local storage failed msg:"+a+" err:"+b;return fail(c,{})}};"undefined"!=typeof Titanium&&(m.adapter=["titanium"]);var n=function(a,c,d,e){var k=f.buildFHParams();g({url:a,type:"POST",tryJSONP:!0,dataType:"json",contentType:"application/json",data:j.stringify(k),timeout:c.timeout,success:function(a){e&&e.save({key:"fh_init",value:a},function(){}),b&&b(null,{cloud:a})},error:function(a,c,e){var f="unknown";a&&(f=a.status+" - "+a.responseText),i.error("App init returned error : "+f),d?(i.info("Using cached host: "+j.stringify(d)),b&&b(null,{cloud:d})):(i.error("No cached host found. Init failed."),h(function(a,c){b&&b({error:c,message:a})},a,c,e))}})},o=null,p=a.host+e.boxprefix+"app/init";try{o=new c(m,function(){}),o.get("fh_init",function(b){var c=null;b&&null!==b.value&&"undefined"!=typeof b.value&&""!==b&&(b="string"==typeof b?j.parse(b):b,b.value="string"==typeof b.value?j.parse(b.value):b.value,a.init=b.value.init?b.value.init:"string"==typeof b.value?j.parse(b.value):b.value,b.value.hosts&&(c=b.value)),n(p,a,c,o)})}catch(q){n(p,a,null,null)}};b.exports={init:m,loadCloudProps:n}},{"../../libs/generated/lawnchair":2,"./ajax":18,"./appProps":25,"./constants":27,"./fhparams":31,"./handleError":32,"./lawnchair-ext":35,"./loadScript":36,"./logger":37,"./security/hash":43,JSON:3}],35:[function(a,b){var c=a("../../libs/generated/lawnchair"),d=function(a,b){function c(a){console&&console.log(a)}function d(d,e){d=a.appid+d,b({algorithm:"MD5",text:d},function(a){var b=a.hashvalue+".txt";return"undefined"==typeof navigator.externalstorage?(c("filenameForKey key="+d+" , Filename: "+b),e(b)):void navigator.externalstorage.enable(function(a){var c=b;return a.path&&(c=a.path,c.match(/\/$/)||(c+="/"),c+=b),b=c,e(b)},function(){return e(b)})})}var e=function(a,b){if(!console)throw a;console.log("error in file system adapter !",a,b)};return{valid:function(){return!!window.requestFileSystem},init:function(a,b){a&&"function"==typeof a.fail&&(e=a.fail),b&&this.fn(this.name,b).call(this,this)},keys:function(){throw"Currently not supported"},save:function(a,b){var c=a.key,f=a.val||a.value;d(c,function(a){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(a,{create:!0},function(a){a.createWriter(function(a){a.onwrite=function(){return b({key:c,val:f})},a.write(f)},function(){e("[save] Failed to create file writer")})},function(){e("[save] Failed to getFile")})},function(){e("[save] Failed to requestFileSystem")})})},batch:function(){throw"Currently not supported"},get:function(a,b){d(a,function(c){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(c,{},function(c){c.file(function(c){var d=new FileReader;d.onloadend=function(c){var d=c.target.result;try{d=decodeURIComponent(d)}catch(e){}return b({key:a,val:d})},d.readAsText(c)},function(){e("[load] Failed to getFile")})},function(){b({key:a,val:null})})},function(){e("[load] Failed to get fileSystem")})})},exists:function(a,b){d(a,function(a){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(c){c.root.getFile(a,{},function(){return b(!0)},function(){return b(!1)})})})},all:function(){throw"Currently not supported"},remove:function(a,b){d(a,function(c){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(c,{},function(c){c.remove(function(){return b({key:a,val:null})},function(){e("[remove] Failed to remove file")})},function(){e("[remove] Failed to getFile")})},function(){e("[remove] Failed to get fileSystem")})})},nuke:function(){throw"Currently not supported"}}},e=function(a,b){c.adapter("localFileStorage",d(a,b))};b.exports={addAdapter:e}},{"../../libs/generated/lawnchair":2}],36:[function(a,b){b.exports=function(a,b){var c,d=document.head||document.getElementsByTagName("head")[0]||document.documentElement;c=document.createElement("script"),c.async="async",c.src=a,c.type="text/javascript",c.onload=c.onreadystatechange=function(){(!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,d&&c.parentNode&&d.removeChild(c),c=void 0,b&&"function"==typeof b&&b())},d.insertBefore(c,d.firstChild)}},{}],37:[function(a,b){var c=(a("console"),a("loglevel"));c.setLevel("info"),b.exports=c},{console:8,loglevel:14}],38:[function(a,b){b.exports=[{destination:"ipad",test:["iPad"]},{destination:"iphone",test:["iPhone"]},{destination:"android",test:["Android"]},{destination:"blackberry",test:["BlackBerry","BB10","RIM Tablet OS"]},{destination:"windowsphone",test:["Windows Phone 8"]},{destination:"windowsphone7",test:["Windows Phone OS 7"]}]},{}],39:[function(a,b){b.exports=function(a){var b={},c=a.split("?");if(2===c.length){var d=c[1],e=d.split("&");b={};for(var f=0;f100&&(e/=8),"undefined"==typeof d?c("security library is not loaded."):b({algorithm:"AES",secretkey:f(e),iv:f(e)})};b.exports=g},{"../../../libs/rsa":4}],42:[function(a,b){var c=a("../../../libs/generated/crypto"),d=function(a,b,d){var e=["key","plaintext","iv"];if("aes"!==a.params.algorithm.toLowerCase())return d("encrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return d("no_params_"+g,{},a)}var h=c.AES.encrypt(a.params.plaintext,c.enc.Hex.parse(a.params.key),{iv:c.enc.Hex.parse(a.params.iv)});return cipher_text=c.enc.Hex.stringify(h.ciphertext),b({ciphertext:cipher_text})},e=function(a,b,d){var e=["key","ciphertext","iv"]; -if("aes"!==a.params.algorithm.toLowerCase())return d("decrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return d("no_params_"+g,{},a)}var h=c.enc.Hex.parse(a.params.ciphertext),i=c.enc.Base64.stringify(h),j=c.AES.decrypt(i,c.enc.Hex.parse(a.params.key),{iv:c.enc.Hex.parse(a.params.iv)});return plain_text=j.toString(c.enc.Utf8),b({plaintext:plain_text})};b.exports={encrypt:d,decrypt:e}},{"../../../libs/generated/crypto":1}],43:[function(a,b){var c=a("../../../libs/generated/crypto"),d=function(a,b,d){if(!a.params.text)return void d("hash_no_text",{},a);var e;if("md5"===a.params.algorithm.toLowerCase())e=c.MD5(a.params.text).toString(c.enc.Hex);else if("sha1"===a.params.algorithm.toLowerCase())e=c.SHA1(a.params.text).toString(c.enc.Hex);else if("sha256"===a.params.algorithm.toLowerCase())e=c.SHA256(a.params.text).toString(c.enc.Hex);else{if("sha512"!==a.params.algorithm.toLowerCase())return d("hash_unsupported_algorithm: "+a.params.algorithm);e=c.SHA512(a.params.text).toString(c.enc.Hex)}return b({hashvalue:e})};b.exports=d},{"../../../libs/generated/crypto":1}],44:[function(a,b){var c=a("../../../libs/rsa"),d=c.RSAKey,e=function(a,b,c){var e=["modulu","plaintext"];if("rsa"!==a.params.algorithm.toLowerCase())return c("encrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return c("no_params_"+g,{},a)}var h=new d;h.setPublic(a.params.modulu,"10001");var i=a.params.plaintext;return cipher_text=h.encrypt(i),b({ciphertext:cipher_text})};b.exports={encrypt:e}},{"../../../libs/rsa":4}],45:[function(a,b){var c=a("JSON"),d=a("./api_act"),e=a("./api_cloud"),f=a("../../libs/generated/crypto"),g=a("../../libs/generated/lawnchair"),h={defaults:{sync_frequency:10,auto_sync_local_updates:!0,notify_client_storage_failed:!0,notify_sync_started:!0,notify_sync_complete:!0,notify_offline_update:!0,notify_collision_detected:!0,notify_remote_update_failed:!0,notify_local_update_applied:!0,notify_remote_update_applied:!0,notify_delta_received:!0,notify_record_delta_received:!0,notify_sync_failed:!0,do_console_log:!1,crashed_count_wait:10,resend_crashed_updates:!0,sync_active:!0,storage_strategy:"html5-filesystem",file_system_quota:61644800,has_custom_sync:null},notifications:{CLIENT_STORAGE_FAILED:"client_storage_failed",SYNC_STARTED:"sync_started",SYNC_COMPLETE:"sync_complete",OFFLINE_UPDATE:"offline_update",COLLISION_DETECTED:"collision_detected",REMOTE_UPDATE_FAILED:"remote_update_failed",REMOTE_UPDATE_APPLIED:"remote_update_applied",LOCAL_UPDATE_APPLIED:"local_update_applied",DELTA_RECEIVED:"delta_received",RECORD_DELTA_RECEIVED:"record_delta_received",SYNC_FAILED:"sync_failed"},datasets:{},config:void 0,notify_callback:void 0,init_is_called:!1,init:function(a){h.consoleLog("sync - init called"),h.config=c.parse(c.stringify(h.defaults));for(var b in a)h.config[b]=a[b];h.init_is_called||(h.init_is_called=!0,h.datasetMonitor())},notify:function(a){h.notify_callback=a},manage:function(a,b,d,e,f){h.consoleLog("manage - START");var b=b||{},g=function(g){h.consoleLog("doManage dataset :: initialised = "+g.initialised+" :: "+a+" :: "+c.stringify(b));var i=h.setOptions(b);g.query_params=d||g.query_params||{},g.meta_data=e||g.meta_data||{},g.config=i,g.syncRunning=!1,g.syncPending=!0,g.initialised=!0,"undefined"==typeof g.meta&&(g.meta={}),h.saveDataSet(a,function(){f&&f()})};h.getDataSet(a,function(a){h.consoleLog("manage - dataset already loaded"),g(a)},function(){h.consoleLog("manage - dataset not loaded... trying to load"),h.loadDataSet(a,function(b){h.consoleLog("manage - dataset loaded from local storage"),h.doNotify(a,null,h.notifications.LOCAL_UPDATE_APPLIED,"load"),g(b)},function(){h.consoleLog("manage - Creating new dataset for id "+a);var b={};b.data={},b.pending={},b.meta={},h.datasets[a]=b,g(b)})})},setOptions:function(a){h.config||(h.config=c.parse(c.stringify(h.defaults)));var b=c.parse(c.stringify(h.config)),d=c.parse(c.stringify(a));for(var e in d)b[e]=d[e];return b},list:function(a,b,d){h.getDataSet(a,function(a){if(a&&a.data){var e=c.parse(c.stringify(a.data));b(e)}else d&&d("no_data")},function(a,b){d&&d(a,b)})},create:function(a,b,c,d){return null==b&&d?d("null_data"):void h.addPendingObj(a,null,b,"create",c,d)},read:function(a,b,d,e){h.getDataSet(a,function(a){var f=a.data[b];if(f){var g=c.parse(c.stringify(f));d(g)}else e("unknown_uid")},function(a,b){e&&e(a,b)})},update:function(a,b,c,d,e){h.addPendingObj(a,b,c,"update",d,e)},"delete":function(a,b,c,d){h.addPendingObj(a,b,null,"delete",c,d)},getPending:function(a,b){h.getDataSet(a,function(a){var c;a&&(c=a.pending),b(c)},function(a){h.consoleLog(a)})},clearPending:function(a,b){h.getDataSet(a,function(c){c.pending={},h.saveDataSet(a,b)})},listCollisions:function(a,b,c){h.getDataSet(a,function(d){h.doCloudCall({dataset_id:a,req:{fn:"listCollisions",meta_data:d.meta_data}},b,c)},c)},removeCollision:function(a,b,c,d){h.getDataSet(a,function(e){h.doCloudCall({dataset_id:a,req:{fn:"removeCollision",hash:b,meta_data:e.meta_data}},c,d)})},isOnline:function(a){var b=!0;if("undefined"!=typeof navigator.onLine&&(b=navigator.onLine),b&&"undefined"!=typeof navigator.network&&"undefined"!=typeof navigator.network.connection){var c=navigator.network.connection.type;("none"===c||null===c)&&(b=!1)}return a(b)},doNotify:function(a,b,c,d){if(h.notify_callback&&h.config["notify_"+c]){var e={dataset_id:a,uid:b,code:c,message:d};setTimeout(function(){h.notify_callback(e)},0)}},getDataSet:function(a,b,c){var d=h.datasets[a];d?b(d):c&&c("unknown_dataset "+a,a)},getQueryParams:function(a,b,c){var d=h.datasets[a];d?b(d.query_params):c&&c("unknown_dataset "+a,a)},setQueryParams:function(a,b,c,d){var e=h.datasets[a];e?(e.query_params=b,h.saveDataSet(a),c&&c(e.query_params)):d&&d("unknown_dataset "+a,a)},getMetaData:function(a,b,c){var d=h.datasets[a];d?b(d.meta_data):c&&c("unknown_dataset "+a,a)},setMetaData:function(a,b,c,d){var e=h.datasets[a];e?(e.meta_data=b,h.saveDataSet(a),c&&c(e.meta_data)):d&&d("unknown_dataset "+a,a)},getConfig:function(a,b,c){var d=h.datasets[a];d?b(d.config):c&&c("unknown_dataset "+a,a)},setConfig:function(a,b,c,d){var e=h.datasets[a];if(e){var f=h.setOptions(b);e.config=f,h.saveDataSet(a),c&&c(e.config)}else d&&d("unknown_dataset "+a,a)},stopSync:function(a,b,c){h.setConfig(a,{sync_active:!1},function(){b&&b()},c)},startSync:function(a,b,c){h.setConfig(a,{sync_active:!0},function(){b&&b()},c)},doSync:function(a,b,c){var d=h.datasets[a];d?(d.syncPending=!0,h.saveDataSet(a),b&&b()):c&&c("unknown_dataset "+a,a)},forceSync:function(a,b,c){var d=h.datasets[a];d?(d.syncForced=!0,h.saveDataSet(a),b&&b()):c&&c("unknown_dataset "+a,a)},sortObject:function(a){if("object"!=typeof a||null===a)return a;var b=[];return Object.keys(a).sort().forEach(function(c){b.push({key:c,value:h.sortObject(a[c])})}),b},sortedStringify:function(a){var b="";try{b=c.stringify(h.sortObject(a))}catch(d){console.error("Error stringifying sorted object:"+d)}return b},generateHash:function(a){var b=f.SHA1(h.sortedStringify(a));return b.toString()},addPendingObj:function(a,b,d,e,f,g){function i(c){c.hash=h.generateHash(c),h.getDataSet(a,function(d){d.pending[c.hash]=c,h.updateDatasetFromLocal(d,c),h.config.auto_sync_local_updates&&(d.syncPending=!0),h.saveDataSet(a),h.doNotify(a,b,h.notifications.LOCAL_UPDATE_APPLIED,e),f(c)},function(a,b){g&&g(a,b)})}h.isOnline(function(c){c||h.doNotify(a,b,h.notifications.OFFLINE_UPDATE,e)});var j={};j.inFlight=!1,j.action=e,j.post=c.parse(c.stringify(d)),j.postHash=h.generateHash(j.post),j.timestamp=(new Date).getTime(),"create"===e?(j.uid=j.postHash,i(j)):h.read(a,b,function(a){j.uid=b,j.pre=a.data,j.preHash=h.generateHash(a.data),i(j)},function(a,b){g&&g(a,b)})},syncLoop:function(a){h.getDataSet(a,function(b){b.syncPending=!1,b.syncRunning=!0,b.syncLoopStart=(new Date).getTime(),h.doNotify(a,null,h.notifications.SYNC_STARTED,null),h.isOnline(function(d){d?h.checkHasCustomSync(a,function(){var d={};d.fn="sync",d.dataset_id=a,d.query_params=b.query_params,d.config=b.config,d.meta_data=b.meta_data,d.dataset_hash=b.hash,d.acknowledgements=b.acknowledgements||[];var e=b.pending,f=[];for(var g in e)e[g].inFlight||e[g].crashed||e[g].delayed||(e[g].inFlight=!0,e[g].inFlightDate=(new Date).getTime(),f.push(e[g]));d.pending=f,f.length>0&&h.consoleLog("Starting sync loop - global hash = "+b.hash+" :: params = "+c.stringify(d,null,2));try{h.doCloudCall({dataset_id:a,req:d},function(c){function d(c,d,f){if(c)for(var g in c)e=c[g],f.push(e),b.pending[g]&&b.pending[g].inFlight&&!b.pending[g].crashed&&(delete b.pending[g],h.doNotify(a,e.uid,d,e))}var e;if(h.updatePendingFromNewData(a,b,c),h.updateCrashedInFlightFromNewData(a,b,c),h.updateDelayedFromNewData(a,b,c),h.updateMetaFromNewData(a,b,c),h.updateNewDataFromInFlight(a,b,c),h.updateNewDataFromPending(a,b,c),c.records&&(b.data=c.records,b.hash=c.hash,h.doNotify(a,c.hash,h.notifications.DELTA_RECEIVED,"full dataset")),c.updates){var f=[];d(c.updates.applied,h.notifications.REMOTE_UPDATE_APPLIED,f),d(c.updates.failed,h.notifications.REMOTE_UPDATE_FAILED,f),d(c.updates.collisions,h.notifications.COLLISION_DETECTED,f),b.acknowledgements=f}!c.records&&c.hash&&c.hash!==b.hash?(h.consoleLog("Local dataset stale - syncing records :: local hash= "+b.hash+" - remoteHash="+c.hash),h.syncRecords(a)):(h.consoleLog("Local dataset up to date"),h.syncComplete(a,"online",h.notifications.SYNC_COMPLETE))},function(c,d){h.markInFlightAsCrashed(b),h.consoleLog("syncLoop failed : msg="+c+" :: err = "+d),h.syncComplete(a,c,h.notifications.SYNC_FAILED)})}catch(i){h.consoleLog("Error performing sync - "+i),h.syncComplete(a,i,h.notifications.SYNC_FAILED)}}):h.syncComplete(a,"offline",h.notifications.SYNC_FAILED)})})},syncRecords:function(a){h.getDataSet(a,function(b){var d=b.data||{},e={};for(var f in d){var g=f,i=d[f].hash;e[g]=i}var j={};j.fn="syncRecords",j.dataset_id=a,j.query_params=b.query_params,j.clientRecs=e,h.consoleLog("syncRecParams :: "+c.stringify(j)),h.doCloudCall({dataset_id:a,req:j},function(c){var e;if(c.create)for(e in c.create)d[e]={hash:c.create[e].hash,data:c.create[e].data},h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"create");if(c.update)for(e in c.update)d[e].hash=c.update[e].hash,d[e].data=c.update[e].data,h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"update");if(c["delete"])for(e in c["delete"])delete d[e],h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"delete");h.doNotify(a,c.hash,h.notifications.DELTA_RECEIVED,"partial dataset"),b.data=d,c.hash&&(b.hash=c.hash),h.syncComplete(a,"online",h.notifications.SYNC_COMPLETE)},function(b,c){h.consoleLog("syncRecords failed : msg="+b+" :: err="+c),h.syncComplete(a,b,h.notifications.SYNC_FAILED)})})},syncComplete:function(a,b,c){h.getDataSet(a,function(d){d.syncRunning=!1,d.syncLoopEnd=(new Date).getTime(),h.saveDataSet(a),h.doNotify(a,d.hash,c,b)})},checkDatasets:function(){for(var a in h.datasets)if(h.datasets.hasOwnProperty(a)){var b=h.datasets[a];if(!b.syncRunning&&(b.config.sync_active||b.syncForced)){var c=b.syncLoopStart,d=b.syncLoopEnd;if(b.syncForced)b.syncPending=!0;else if(null==c)h.consoleLog(a+" - Performing initial sync"),b.syncPending=!0;else if(null!=d){var e=(new Date).getTime()-d,f=1e3*b.config.sync_frequency;e>f&&(b.syncPending=!0)}b.syncPending&&(b.syncForced=!1,h.syncLoop(a))}}},checkHasCustomSync:function(a,b){var c=h.datasets[a];return c&&c.config?(h.consoleLog("dataset.config.has_custom_sync = "+c.config.has_custom_sync),null!=c.config.has_custom_sync?b():(h.consoleLog("starting check has custom sync"),void d({act:a,req:{fn:"sync"}},function(a){return h.consoleLog("check has_custom_sync - success - ",a),c.config.has_custom_sync=!0,b()},function(a,d){return h.consoleLog("check has_custom_sync - failure - ",d),d.status&&500===d.status?(h.consoleLog("check has_custom_sync - failed with 500, endpoint does exists"),c.config.has_custom_sync=!0):c.config.has_custom_sync=!1,b()}))):b()},doCloudCall:function(a,b,c){var f=!1,g=h.datasets[a.dataset_id];g&&g.config&&(f=g.config.has_custom_sync),1==f?d({act:a.dataset_id,req:a.req},function(a){b(a)},function(a,b){c(a,b)}):e({path:"/mbaas/sync/"+a.dataset_id,method:"post",data:a.req},function(a){b(a)},function(a,b){c(a,b)})},datasetMonitor:function(){h.checkDatasets(),setTimeout(function(){h.datasetMonitor()},500)},saveDataSet:function(a,b){var c=function(b,c){var d="save to local storage failed msg:"+b+" err:"+c;h.doNotify(a,null,h.notifications.CLIENT_STORAGE_FAILED,d),h.consoleLog(d)};h.getDataSet(a,function(d){g({fail:c,adapter:h.config.storage_strategy,size:h.config.file_system_quota},function(){this.save({key:"dataset_"+a,val:d},function(){return b?b():void 0})})})},loadDataSet:function(a,b,d){var e=function(b){var c="load from local storage failed msg:"+b;h.doNotify(a,null,h.notifications.CLIENT_STORAGE_FAILED,c),h.consoleLog(c)};g({fail:e,adapter:h.config.storage_strategy,size:h.config.file_system_quota},function(){this.get("dataset_"+a,function(e){if(e&&e.val){var f=e.val;if("string"==typeof f&&(f=c.parse(f)),f.initialised=!1,h.datasets[a]=f,h.consoleLog("load from local storage success for dataset_id :"+a),b)return b(f)}else if(d)return d()})})},updateDatasetFromLocal:function(a,b){var d,e,f=a.pending,g=b.uid;h.consoleLog("updating local dataset for uid "+g+" - action = "+b.action),a.meta[g]=a.meta[g]||{},"create"===b.action&&(a.data[g]&&(h.consoleLog("dataset already exists for uid in create :: "+c.stringify(a.data[g])),a.meta[g].fromPending&&(d=a.meta[g].pendingUid,delete f[d])),a.data[g]={}),"update"===b.action&&a.data[g]&&a.meta[g].fromPending&&(h.consoleLog("updating an existing pending record for dataset :: "+c.stringify(a.data[g])),d=a.meta[g].pendingUid,a.meta[g].previousPendingUid=d,e=f[d],e&&(e.inFlight?(h.consoleLog("existing in-inflight pending record = "+c.stringify(e)),b.delayed=!0,b.waiting=e.hash):(h.consoleLog("existing pre-flight pending record = "+c.stringify(e)),e.post=b.post,e.postHash=b.postHash,delete f[b.hash],b.hash=d))),"delete"===b.action&&a.data[g]&&(a.meta[g].fromPending&&(h.consoleLog("Deleting an existing pending record for dataset :: "+c.stringify(a.data[g])),d=a.meta[g].pendingUid,a.meta[g].previousPendingUid=d,e=f[d],e&&(e.inFlight?(h.consoleLog("existing in-inflight pending record = "+c.stringify(e)),b.delayed=!0,b.waiting=e.hash):(h.consoleLog("existing pending record = "+c.stringify(e)),"create"===e.action&&(delete f[b.hash],delete f[d]),"update"===e.action&&(b.pre=e.pre,b.preHash=e.preHash,b.inFlight=!1,delete f[d])))),delete a.data[g]),a.data[g]&&(a.data[g].data=b.post,a.data[g].hash=b.postHash,a.meta[g].fromPending=!0,a.meta[g].pendingUid=b.hash)},updatePendingFromNewData:function(a,b,d){var e,f=b.pending;if(f&&d.records)for(var g in f)if(f.hasOwnProperty(g)){var i=f[g];if(b.meta[i.uid]=b.meta[i.uid]||{},i.inFlight===!1){if(h.consoleLog("updatePendingFromNewData - Found Non inFlight record -> action="+i.action+" :: uid="+i.uid+" :: hash="+i.hash),"update"===i.action||"delete"===i.action)if(e=d.records[i.uid])h.consoleLog("updatePendingFromNewData - Updating pre values for existing pending record "+i.uid),i.pre=e.data,i.preHash=e.hash;else{var j=b.meta[i.uid].previousPendingUid,k=f[j];if(k&&d&&d.updates&&d.updates.applied&&d.updates.applied[k.hash]){var l=d.updates.applied[k.hash].uid;e=d.records[l],e&&(h.consoleLog("updatePendingFromNewData - Updating pre values for existing pending record which was previously a create "+i.uid+" ==> "+l),i.pre=e.data,i.preHash=e.hash,i.uid=l)}}"create"===i.action&&d&&d.updates&&d.updates.applied&&d.updates.applied[g]&&(h.consoleLog("updatePendingFromNewData - Found an update for a pending create "+c.stringify(d.updates.applied[g])),e=d.records[d.updates.applied[g].uid],e&&(h.consoleLog("updatePendingFromNewData - Changing pending create to an update based on new record "+c.stringify(e)),i.action="update",i.pre=e.data,i.preHash=e.hash,i.uid=d.updates.applied[g].uid))}}},updateNewDataFromInFlight:function(a,b,c){var d=b.pending;if(d&&c.records)for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];if(f.inFlight){var g=c&&c.updates&&c.updates.hashes&&c.updates.hashes[e]?!0:!1;if(h.consoleLog("updateNewDataFromInFlight - Found inflight pending Record - action = "+f.action+" :: hash = "+e+" :: updateReceivedForPending="+g),!g){var i=c.records[f.uid];if("update"===f.action&&i)i.data=f.post,i.hash=f.postHash;else if("delete"===f.action&&i)delete c.records[f.uid];else if("create"===f.action){h.consoleLog("updateNewDataFromInFlight - re adding pending create to incomming dataset");var j={data:f.post,hash:f.postHash};c.records[f.uid]=j}}}}},updateNewDataFromPending:function(a,b,c){var d=b.pending;if(d&&c.records)for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];if(f.inFlight===!1){h.consoleLog("updateNewDataFromPending - Found Non inFlight record -> action="+f.action+" :: uid="+f.uid+" :: hash="+f.hash);var g=c.records[f.uid];if("update"===f.action&&g)g.data=f.post,g.hash=f.postHash;else if("delete"===f.action&&g)delete c.records[f.uid];else if("create"===f.action){h.consoleLog("updateNewDataFromPending - re adding pending create to incomming dataset");var i={data:f.post,hash:f.postHash};c.records[f.uid]=i}}}},updateCrashedInFlightFromNewData:function(a,b,d){var e,f,g={applied:h.notifications.REMOTE_UPDATE_APPLIED,failed:h.notifications.REMOTE_UPDATE_FAILED,collisions:h.notifications.COLLISION_DETECTED},i=b.pending,j={};if(i){for(e in i)if(i.hasOwnProperty(e)&&(f=i[e],f.inFlight&&f.crashed))if(h.consoleLog("updateCrashedInFlightFromNewData - Found crashed inFlight pending record uid="+f.uid+" :: hash="+f.hash),d&&d.updates&&d.updates.hashes){var k=d.updates.hashes[e];k?(j[k.uid]=k,h.consoleLog("updateCrashedInFlightFromNewData - Resolving status for crashed inflight pending record "+c.stringify(k)),"failed"===k.type&&("create"===k.action?(h.consoleLog("updateCrashedInFlightFromNewData - Deleting failed create from dataset"),delete b.data[k.uid]):("update"===k.action||"delete"===k.action)&&(h.consoleLog("updateCrashedInFlightFromNewData - Reverting failed "+k.action+" in dataset"),b.data[k.uid]={data:f.pre,hash:f.preHash})),delete i[e],h.doNotify(a,k.uid,g[k.type],k)):f.crashedCount?f.crashedCount++:f.crashedCount=1}else f.crashedCount?f.crashedCount++:f.crashedCount=1;for(e in i)i.hasOwnProperty(e)&&(f=i[e],f.inFlight&&f.crashed&&f.crashedCount>b.config.crashed_count_wait&&(h.consoleLog("updateCrashedInFlightFromNewData - Crashed inflight pending record has reached crashed_count_wait limit : "+c.stringify(f)),b.config.resend_crashed_updates?(h.consoleLog("updateCrashedInFlightFromNewData - Retryig crashed inflight pending record"),f.crashed=!1,f.inFlight=!1):(h.consoleLog("updateCrashedInFlightFromNewData - Deleting crashed inflight pending record"),delete i[e])))}},updateDelayedFromNewData:function(a,b,d){var e,f,g=b.pending;if(g)for(e in g)if(g.hasOwnProperty(e)&&(f=g[e],f.delayed&&f.waiting&&(h.consoleLog("updateDelayedFromNewData - Found delayed pending record uid="+f.uid+" :: hash="+f.hash+" :: waiting="+f.waiting),d&&d.updates&&d.updates.hashes))){var i=d.updates.hashes[f.waiting];i&&(h.consoleLog("updateDelayedFromNewData - Waiting pending record is resolved rec="+c.stringify(i)),f.delayed=!1,f.waiting=void 0)}},updateMetaFromNewData:function(a,b,d){var e=b.meta;if(e&&d&&d.updates&&d.updates.hashes)for(var f in e)if(e.hasOwnProperty(f)){var g=e[f],i=g.pendingUid,j=g.previousPendingUid;h.consoleLog("updateMetaFromNewData - Found metadata with uid = "+f+" :: pendingHash = "+i+" :: previousPendingHash ="+j);var k=!0,l=!0;if(j){k=!1;var m=d.updates.hashes[j];m&&(h.consoleLog("updateMetaFromNewData - Found previousPendingUid in meta data resolved - resolved = "+c.stringify(m)),g.previousPendingUid=void 0,k=!0)}if(i){l=!1;var m=d.updates.hashes[i];m&&(h.consoleLog("updateMetaFromNewData - Found pendingUid in meta data resolved - resolved = "+c.stringify(m)),g.pendingUid=void 0,l=!0)}k&&l&&(h.consoleLog("updateMetaFromNewData - both previous and current pendings are resolved for meta data with uid "+f+". Delete it."),delete e[f])}},markInFlightAsCrashed:function(a){var b,c,d=a.pending;if(d){var e={};for(b in d)d.hasOwnProperty(b)&&(c=d[b],c.inFlight&&(h.consoleLog("Marking in flight pending record as crashed : "+b),c.crashed=!0,e[c.uid]=c))}},consoleLog:function(a){h.config.do_console_log&&console.log(a)}};!function(){h.config=h.defaults}(),b.exports={init:h.init,manage:h.manage,notify:h.notify,doList:h.list,doCreate:h.create,doRead:h.read,doUpdate:h.update,doDelete:h["delete"],listCollisions:h.listCollisions,removeCollision:h.removeCollision,getPending:h.getPending,clearPending:h.clearPending,getDataset:h.getDataSet,getQueryParams:h.getQueryParams,setQueryParams:h.setQueryParams,getMetaData:h.getMetaData,setMetaData:h.setMetaData,getConfig:h.getConfig,setConfig:h.setConfig,startSync:h.startSync,stopSync:h.stopSync,doSync:h.doSync,forceSync:h.forceSync,generateHash:h.generateHash,loadDataSet:h.loadDataSet,checkHasCustomSync:h.checkHasCustomSync}},{"../../libs/generated/crypto":1,"../../libs/generated/lawnchair":2,"./api_act":19,"./api_cloud":21,JSON:3}],46:[function(a,b){b.exports={createUUID:function(){for(var a=[],b="0123456789ABCDEF",c=0;32>c;c++)a[c]=b.substr(Math.floor(16*Math.random()),1);a[12]="4",a[16]=b.substr(3&a[16]|8,1);var d=a.join("");return d}}},{}],47:[function(a,b){var c,d=a("./initializer"),e=a("./events"),f=a("./hosts"),g=a("./constants"),h=a("./logger"),i=!1,j=!1,k=null,l=function(a){return j?a(null,{host:n()}):(e.once(g.INIT_EVENT,function(b,c){return a(b,c)}),void(i||(i=!0,d.init(function(a,b){return i=!1,a?(k=a,e.emit(g.INIT_EVENT,a)):(k=null,j=!0,c=new f(b.cloud),e.emit(g.INIT_EVENT,null,{host:n()}))}))))},m=function(){return c},n=function(){if("undefined"!=typeof c){var b=a("./appProps").getAppProps();return c.getHost(b.mode)}return void 0},o=function(){return j},p=function(){return k},q=function(){j=!1,i=!1,c=void 0,k=void 0,l(function(){})};l(function(a){a?"app_config_missing"!==a.message?h.error("Failed to initialise fh."):h.info("No fh config file"):h.info("fh cloud is ready")}),b.exports={ready:l,isReady:o,getCloudHost:m,getCloudHostUrl:n,getInitError:p,reset:q}},{"./appProps":25,"./constants":27,"./events":30,"./hosts":33,"./initializer":34,"./logger":37}]},{},[16])(16)}); \ No newline at end of file +},all:function(b){var c=this,d="SELECT * FROM "+this.record,e=[],f=this.fn(this.name,b)||void 0,g=function(a,b){if(0!=b.rows.length)for(var d=0,g=b.rows.length;g>d;d++){var h=JSON.parse(b.rows.item(d).value);h.key=b.rows.item(d).id,e.push(h)}f&&f.call(c,e)};return this.db.readTransaction(function(b){b.executeSql(d,[],g,a)}),this},remove:function(b,c){var d,e=this,f="DELETE FROM "+this.record+" WHERE id ",g=function(){c&&e.lambda(c).call(e)};return this.isArray(b)?(d=b,f+="IN ("+d.map(function(){return"?"}).join(",")+")"):(f+="= ?",d=[b]),d=d.map(function(a){return a.key?a.key:a}),this.db.transaction(function(b){b.executeSql(f,d,g,a)}),this},nuke:function(b){var c="DELETE FROM "+this.record,d=this,e=b?function(){d.lambda(b).call(d)}:function(){};return this.db.transaction(function(b){b.executeSql(c,[],e,a)}),this}}}()),f.adapter("html5-filesystem",function(a){var b=a.FileError,c=function(a){var c,d=!0;switch(a.code){case b.QUOTA_EXCEEDED_ERR:c="QUOTA_EXCEEDED_ERR";break;case b.NOT_FOUND_ERR:c="NOT_FOUND_ERR",d=!1;break;case b.SECURITY_ERR:c="SECURITY_ERR";break;case b.INVALID_MODIFICATION_ERR:c="INVALID_MODIFICATION_ERR";break;case b.INVALID_STATE_ERR:c="INVALID_STATE_ERR";break;default:c="Unknown Error"}console&&d&&console.error(a,c)},d=function(a,b,e){var f=e||[];a.readEntries(function(c){c.length?d(a,b,f.concat(Array.prototype.slice.call(c))):b&&b(f.map(function(a){return a.name}))},c)},e={},f=function(a,b){var c=e[a.name];c?b(c):setTimeout(function(){f(a,b)},10)},g=function(){var a=-1===document.URL.indexOf("http://")&&-1===document.URL.indexOf("https://");return a?!0:!1},h=function(a){var b;if(g())b=a;else{var c="application/json";try{b=new Blob([a],{type:c})}catch(d){var e=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if("TypeError"==d.name&&e){var f=new e;f.append([a.buffer]),b=f.getBlob(c)}else b=a}}return b};return{valid:function(){var b=a.requestFileSystem||a.webkitRequestFileSystem||a.moz_requestFileSystem;return!!b},init:function(b,d){function f(b){var c=a.requestFileSystem||a.webkitRequestFileSystem||a.moz_requestFileSystem,f=window.PERSISTENT;"undefined"!=typeof LocalFileSystem&&"undefined"!=typeof LocalFileSystem.PERSISTENT&&(f=LocalFileSystem.PERSISTENT),c(f,b,function(a){a.root.getDirectory(j,{create:!0},function(a){e[j]=a,d&&g.fn(g.name,d).call(g,g)},function(a){h(a)})},function(a){h(a)})}var g=this,h=function(a){c(a),d&&g.fn(g.name,d).call(g,g)},i=b.size||104857600,j=this.name;"undefined"!=typeof navigator.webkitPersistentStorage?navigator.webkitPersistentStorage.requestQuota(i,f,function(){logger.warn("User declined file storage"),h("User declined file storage")}):f(0)},keys:function(a){var b=this;return f(this,function(c){d(c.createReader(),function(c){a&&b.fn("keys",a).call(b,c)})}),this},save:function(a,b){var d=this,e=a.key||this.uuid();a.key=e;var g=function(a){c(a),b&&d.lambda(b).call(d)};return f(this,function(c){c.getFile(e,{create:!0},function(c){c.createWriter(function(c){c.onerror=g,c.onwriteend=function(){this.onwriteend=null,this.truncate(this.position),b&&d.lambda(b).call(d,a)};var e=JSON.stringify(a),f=h(e);c.write(f)},g)},g)}),this},batch:function(a,b){for(var c=this,d=[],e=0,f=a.length;f>e;e++)c.save(a[e],function(a){d.push(a),d.length===f&&b&&c.lambda(b).call(c,d)});return this},get:function(a,b){var d=this;if(this.isArray(a))for(var e=[],g=0,h=a.length;h>g;g++)d.get(a[g],function(a){a&&e.push(a),e.length===h&&b&&d.lambda(b).call(d,e)});else{var i=function(a){c(a),b&&d.lambda(b).call(d)};f(this,function(c){c.getFile(a,{create:!1},function(c){c.file(function(c){var e=new FileReader;e.onerror=i,e.onload=function(c){var e={};try{e=JSON.parse(c.target.result),e.key=a}catch(c){e={key:a}}b&&d.lambda(b).call(d,e)},e.readAsText(c)},i)},i)})}return this},exists:function(a,b){var c=this;return f(this,function(d){d.getFile(a,{create:!1},function(){b&&c.lambda(b).call(c,!0)},function(){b&&c.lambda(b).call(c,!1)})}),this},all:function(a){var b=this;return a&&this.keys(function(c){c.length?b.get(c,function(c){b.fn(b.name,a).call(b,c)}):b.fn(b.name,a).call(b,[])}),this},remove:function(a,b){var d=this,e=function(a){c(a),b&&d.lambda(b).call(d)};return f(this,function(c){c.getFile("string"==typeof a?a:a.key,{create:!1},function(a){a.remove(function(){b&&d.lambda(b).call(d)},e)},e)}),this},nuke:function(a){var b=this,c=0;return this.keys(function(d){if(d.length)for(var e=0,f=d.length;f>e;e++)b.remove(d[e],function(){c++,c===f&&a&&b.lambda(a).call(b)});else a&&b.lambda(a).call(b)}),this}}}(this)),f.adapter("memory",function(){var a={};return{valid:function(){return!0},init:function(b,c){a[this.name]=a[this.name]||{index:[],store:{}},this.index=a[this.name].index,this.store=a[this.name].store;var d=this.fn(this.name,c);return d&&d.call(this,this),this},keys:function(a){return this.fn("keys",a).call(this,this.index),this},save:function(a,b){var c=a.key||this.uuid();return this.exists(c,function(d){d||(a.key&&delete a.key,this.index.push(c)),this.store[c]=a,b&&(a.key=c,this.lambda(b).call(this,a))}),this},batch:function(a,b){for(var c=[],d=0,e=a.length;e>d;d++)this.save(a[d],function(a){c.push(a)});return b&&this.lambda(b).call(this,c),this},get:function(a,b){var c;if(this.isArray(a)){c=[];for(var d=0,e=a.length;e>d;d++)c.push(this.store[a[d]])}else c=this.store[a],c&&(c.key=a);return b&&this.lambda(b).call(this,c),this},exists:function(a,b){return this.lambda(b).call(this,!!this.store[a]),this},all:function(a){for(var b=[],c=0,d=this.index.length;d>c;c++){var e=this.store[this.index[c]];e.key=this.index[c],b.push(e)}return this.fn(this.name,a).call(this,b),this},remove:function(a,b){for(var c=this.isArray(a)?a:[a],d=0,e=c.length;e>d;d++){var f=c[d].key?c[d].key:c[d],g=this.indexOf(this.index,f);0>g||(delete this.store[f],this.index.splice(g,1))}return b&&this.lambda(b).call(this),this},nuke:function(b){return this.store=a[this.name].store={},this.index=a[this.name].index=[],b&&this.lambda(b).call(this),this}}}()),e("undefined"!=typeof f?f:window.Lawnchair)}.call(c,void 0,void 0,void 0,void 0,function(a){b.exports=a})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(_dereq_,module,exports){(function(global){__browserify_shim_require__=_dereq_,function browserifyShim(module,exports,_dereq_,define,browserify_shim__define__module__export__){var JSON;JSON||(JSON={}),function(){"use strict";function f(a){return 10>a?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g,h=gap,i=b[a];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(a)),"function"==typeof rep&&(i=rep.call(b,a,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";if(gap+=indent,g=[],"[object Array]"===Object.prototype.toString.apply(i)){for(f=i.length,c=0;f>c;c+=1)g[c]=str(c,i)||"null";return e=0===g.length?"[]":gap?"[\n"+gap+g.join(",\n"+gap)+"\n"+h+"]":"["+g.join(",")+"]",gap=h,e}if(rep&&"object"==typeof rep)for(f=rep.length,c=0;f>c;c+=1)"string"==typeof rep[c]&&(d=rep[c],e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));return e=0===g.length?"{}":gap?"{\n"+gap+g.join(",\n"+gap)+"\n"+h+"}":"{"+g.join(",")+"}",gap=h,e}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;"function"!=typeof JSON.stringify&&(JSON.stringify=function(a,b,c){var d;if(gap="",indent="","number"==typeof c)for(d=0;c>d;d+=1)indent+=" ";else"string"==typeof c&&(indent=c);if(rep=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return str("",{"":a})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&"object"==typeof e)for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),void 0!==d?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),browserify_shim__define__module__export__("undefined"!=typeof JSON?JSON:window.JSON)}.call(global,void 0,void 0,void 0,void 0,function(a){module.exports=a})}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(a,b){function c(a,b,c){null!=a&&("number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))}function d(){return new c(null)}function e(a,b,c,d,e,f){for(;--f>=0;){var g=b*this[a++]+c[d]+e;e=Math.floor(g/67108864),c[d++]=67108863&g}return e}function f(a,b,c,d,e,f){for(var g=32767&b,h=b>>15;--f>=0;){var i=32767&this[a],j=this[a++]>>15,k=h*i+j*g;i=g*i+((32767&k)<<15)+c[d]+(1073741823&e),e=(i>>>30)+(k>>>15)+h*j+(e>>>30),c[d++]=1073741823&i}return e}function g(a,b,c,d,e,f){for(var g=16383&b,h=b>>14;--f>=0;){var i=16383&this[a],j=this[a++]>>14,k=h*i+j*g;i=g*i+((16383&k)<<14)+c[d]+e,e=(i>>28)+(k>>14)+h*j,c[d++]=268435455&i}return e}function h(a){return nb.charAt(a)}function i(a,b){var c=ob[a.charCodeAt(b)];return null==c?-1:c}function j(a){for(var b=this.t-1;b>=0;--b)a[b]=this[b];a.t=this.t,a.s=this.s}function k(a){this.t=1,this.s=0>a?-1:0,a>0?this[0]=a:-1>a?this[0]=a+DV:this.t=0}function l(a){var b=d();return b.fromInt(a),b}function m(a,b){var d;if(16==b)d=4;else if(8==b)d=3;else if(256==b)d=8;else if(2==b)d=1;else if(32==b)d=5;else{if(4!=b)return void this.fromRadix(a,b);d=2}this.t=0,this.s=0;for(var e=a.length,f=!1,g=0;--e>=0;){var h=8==d?255&a[e]:i(a,e);0>h?"-"==a.charAt(e)&&(f=!0):(f=!1,0==g?this[this.t++]=h:g+d>this.DB?(this[this.t-1]|=(h&(1<>this.DB-g):this[this.t-1]|=h<=this.DB&&(g-=this.DB))}8==d&&0!=(128&a[0])&&(this.s=-1,g>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==a;)--this.t}function o(a){if(this.s<0)return"-"+this.negate().toString(a);var b;if(16==a)b=4;else if(8==a)b=3;else if(2==a)b=1;else if(32==a)b=5;else{if(4!=a)return this.toRadix(a);b=2}var c,d=(1<0)for(i>i)>0&&(e=!0,f=h(c));g>=0;)b>i?(c=(this[g]&(1<>(i+=this.DB-b)):(c=this[g]>>(i-=b)&d,0>=i&&(i+=this.DB,--g)),c>0&&(e=!0),e&&(f+=h(c));return e?f:"0"}function p(){var a=d();return c.ZERO.subTo(this,a),a}function q(){return this.s<0?this.negate():this}function r(a){var b=this.s-a.s;if(0!=b)return b;var c=this.t;if(b=c-a.t,0!=b)return this.s<0?-b:b;for(;--c>=0;)if(0!=(b=this[c]-a[c]))return b;return 0}function s(a){var b,c=1;return 0!=(b=a>>>16)&&(a=b,c+=16),0!=(b=a>>8)&&(a=b,c+=8),0!=(b=a>>4)&&(a=b,c+=4),0!=(b=a>>2)&&(a=b,c+=2),0!=(b=a>>1)&&(a=b,c+=1),c}function t(){return this.t<=0?0:this.DB*(this.t-1)+s(this[this.t-1]^this.s&this.DM)}function u(a,b){var c;for(c=this.t-1;c>=0;--c)b[c+a]=this[c];for(c=a-1;c>=0;--c)b[c]=0;b.t=this.t+a,b.s=this.s}function v(a,b){for(var c=a;c=0;--c)b[c+g+1]=this[c]>>e|h,h=(this[c]&f)<=0;--c)b[c]=0;b[g]=h,b.t=this.t+g+1,b.s=this.s,b.clamp()}function x(a,b){b.s=this.s;var c=Math.floor(a/this.DB);if(c>=this.t)return void(b.t=0);var d=a%this.DB,e=this.DB-d,f=(1<>d;for(var g=c+1;g>d;d>0&&(b[this.t-c-1]|=(this.s&f)<c;)d+=this[c]-a[c],b[c++]=d&this.DM,d>>=this.DB;if(a.t>=this.DB;d+=this.s}else{for(d+=this.s;c>=this.DB;d-=a.s}b.s=0>d?-1:0,-1>d?b[c++]=this.DV+d:d>0&&(b[c++]=d),b.t=c,b.clamp()}function z(a,b){var d=this.abs(),e=a.abs(),f=d.t;for(b.t=f+e.t;--f>=0;)b[f]=0;for(f=0;f=0;)a[c]=0;for(c=0;c=b.DV&&(a[c+b.t]-=b.DV,a[c+b.t+1]=1)}a.t>0&&(a[a.t-1]+=b.am(c,b[c],a,2*c,0,1)),a.s=0,a.clamp()}function B(a,b,e){var f=a.abs();if(!(f.t<=0)){var g=this.abs();if(g.t0?(f.lShiftTo(k,h),g.lShiftTo(k,e)):(f.copyTo(h),g.copyTo(e));var l=h.t,m=h[l-1];if(0!=m){var n=m*(1<1?h[l-2]>>this.F2:0),o=this.FV/n,p=(1<=0&&(e[e.t++]=1,e.subTo(u,e)),c.ONE.dlShiftTo(l,u),u.subTo(h,h);h.t=0;){var v=e[--r]==m?this.DM:Math.floor(e[r]*o+(e[r-1]+q)*p);if((e[r]+=h.am(0,v,e,t,0,l))0&&e.rShiftTo(k,e),0>i&&c.ZERO.subTo(e,e)}}}function C(a){var b=d();return this.abs().divRemTo(a,null,b),this.s<0&&b.compareTo(c.ZERO)>0&&a.subTo(b,b),b}function D(a){this.m=a}function E(a){return a.s<0||a.compareTo(this.m)>=0?a.mod(this.m):a}function F(a){return a}function G(a){a.divRemTo(this.m,null,a)}function H(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function I(a,b){a.squareTo(b),this.reduce(b)}function J(){if(this.t<1)return 0;var a=this[0];if(0==(1&a))return 0;var b=3&a;return b=b*(2-(15&a)*b)&15,b=b*(2-(255&a)*b)&255,b=b*(2-((65535&a)*b&65535))&65535,b=b*(2-a*b%this.DV)%this.DV,b>0?this.DV-b:-b}function K(a){this.m=a,this.mp=a.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(b,b),b}function M(a){var b=d();return a.copyTo(b),this.reduce(b),b}function N(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var b=0;b>15)*this.mpl&this.um)<<15)&a.DM;for(c=b+this.m.t,a[c]+=this.m.am(0,d,a,b,0,this.m.t);a[c]>=a.DV;)a[c]-=a.DV,a[++c]++}a.clamp(),a.drShiftTo(this.m.t,a),a.compareTo(this.m)>=0&&a.subTo(this.m,a)}function O(a,b){a.squareTo(b),this.reduce(b)}function P(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function Q(){return 0==(this.t>0?1&this[0]:this.s)}function R(a,b){if(a>4294967295||1>a)return c.ONE;var e=d(),f=d(),g=b.convert(this),h=s(a)-1;for(g.copyTo(e);--h>=0;)if(b.sqrTo(e,f),(a&1<0)b.mulTo(f,g,e);else{var i=e;e=f,f=i}return b.revert(e)}function S(a,b){var c;return c=256>a||b.isEven()?new D(b):new K(b),this.exp(a,c)}function T(){this.i=0,this.j=0,this.S=new Array}function U(a){var b,c,d;for(b=0;256>b;++b)this.S[b]=b;for(c=0,b=0;256>b;++b)c=c+this.S[b]+a[b%a.length]&255,d=this.S[b],this.S[b]=this.S[c],this.S[c]=d;this.i=0,this.j=0}function V(){var a;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,a=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=a,this.S[a+this.S[this.i]&255]}function W(){return new T}function X(a){qb[rb++]^=255&a,qb[rb++]^=a>>8&255,qb[rb++]^=a>>16&255,qb[rb++]^=a>>24&255,rb>=sb&&(rb-=sb)}function Y(){X((new Date).getTime())}function Z(){if(null==pb){for(Y(),pb=W(),pb.init(qb),rb=0;rba?"0"+a.toString(16):a.toString(16)}function cb(a,b){if(b=0&&b>0;){var f=a.charCodeAt(e--);128>f?d[--b]=f:f>127&&2048>f?(d[--b]=63&f|128,d[--b]=f>>6|192):(d[--b]=63&f|128,d[--b]=f>>6&63|128,d[--b]=f>>12|224)}d[--b]=0;for(var g=new _,h=new Array;b>2;){for(h[0]=0;0==h[0];)g.nextBytes(h);d[--b]=h[0]}return d[--b]=2,d[--b]=0,new c(d)}function db(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function eb(a,b){null!=a&&null!=b&&a.length>0&&b.length>0?(this.n=ab(a,16),this.e=parseInt(b,16)):alert("Invalid RSA public key")}function fb(a){return a.modPowInt(this.e,this.n)}function gb(a){var b=cb(a,this.n.bitLength()+7>>3);if(null==b)return null;var c=this.doPublic(b);if(null==c)return null;var d=c.toString(16);return 0==(1&d.length)?d:"0"+d}var hb,ib=0xdeadbeefcafe,jb=15715070==(16777215&ib);jb&&"Microsoft Internet Explorer"==navigator.appName?(c.prototype.am=f,hb=30):jb&&"Netscape"!=navigator.appName?(c.prototype.am=e,hb=26):(c.prototype.am=g,hb=28),c.prototype.DB=hb,c.prototype.DM=(1<=mb;++mb)ob[lb++]=mb;for(lb="a".charCodeAt(0),mb=10;36>mb;++mb)ob[lb++]=mb;for(lb="A".charCodeAt(0),mb=10;36>mb;++mb)ob[lb++]=mb;D.prototype.convert=E,D.prototype.revert=F,D.prototype.reduce=G,D.prototype.mulTo=H,D.prototype.sqrTo=I,K.prototype.convert=L,K.prototype.revert=M,K.prototype.reduce=N,K.prototype.mulTo=P,K.prototype.sqrTo=O,c.prototype.copyTo=j,c.prototype.fromInt=k,c.prototype.fromString=m,c.prototype.clamp=n,c.prototype.dlShiftTo=u,c.prototype.drShiftTo=v,c.prototype.lShiftTo=w,c.prototype.rShiftTo=x,c.prototype.subTo=y,c.prototype.multiplyTo=z,c.prototype.squareTo=A,c.prototype.divRemTo=B,c.prototype.invDigit=J,c.prototype.isEven=Q,c.prototype.exp=R,c.prototype.toString=o,c.prototype.negate=p,c.prototype.abs=q,c.prototype.compareTo=r,c.prototype.bitLength=t,c.prototype.mod=C,c.prototype.modPowInt=S,c.ZERO=l(0),c.ONE=l(1),T.prototype.init=U,T.prototype.next=V;var pb,qb,rb,sb=256;if(null==qb){qb=new Array,rb=0;var tb;if("Netscape"==navigator.appName&&navigator.appVersion<"5"&&window.crypto){var ub=window.crypto.random(32);for(tb=0;tbrb;)tb=Math.floor(65536*Math.random()),qb[rb++]=tb>>>8,qb[rb++]=255&tb;rb=0,Y()}_.prototype.nextBytes=$,db.prototype.doPublic=fb,db.prototype.setPublic=eb,db.prototype.encrypt=gb,b.exports={SecureRandom:_,byte2Hex:bb,RSAKey:db}},{}],5:[function(a,b){function c(a,b){return m.isUndefined(b)?""+b:!m.isNumber(b)||!isNaN(b)&&isFinite(b)?m.isFunction(b)||m.isRegExp(b)?b.toString():b:b.toString()}function d(a,b){return m.isString(a)?a.length=0;d--)if(e[d]!=f[d])return!1;for(d=e.length-1;d>=0;d--)if(c=e[d],!h(a[c],b[c]))return!1;return!0}function k(a,b){return a&&b?"[object RegExp]"==Object.prototype.toString.call(b)?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function l(a,b,c,d){var e;m.isString(c)&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f(e,c,"Missing expected exception"+d),!a&&k(e,c)&&f(e,c,"Got unwanted exception"+d),a&&e&&c&&!k(e,c)||!a&&e)throw e}var m=a("util/"),n=Array.prototype.slice,o=Object.prototype.hasOwnProperty,p=b.exports=g;p.AssertionError=function(a){this.name="AssertionError",this.actual=a.actual,this.expected=a.expected,this.operator=a.operator,a.message?(this.message=a.message,this.generatedMessage=!1):(this.message=e(this),this.generatedMessage=!0);var b=a.stackStartFunction||f;if(Error.captureStackTrace)Error.captureStackTrace(this,b);else{var c=new Error;if(c.stack){var d=c.stack,g=b.name,h=d.indexOf("\n"+g);if(h>=0){var i=d.indexOf("\n",h+1);d=d.substring(i+1)}this.stack=d}}},m.inherits(p.AssertionError,Error),p.fail=f,p.ok=g,p.equal=function(a,b,c){a!=b&&f(a,b,c,"==",p.equal)},p.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",p.notEqual)},p.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",p.deepEqual)},p.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",p.notDeepEqual)},p.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",p.strictEqual)},p.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",p.notStrictEqual)},p.throws=function(){l.apply(this,[!0].concat(n.call(arguments)))},p.doesNotThrow=function(){l.apply(this,[!1].concat(n.call(arguments)))},p.ifError=function(a){if(a)throw a};var q=Object.keys||function(a){var b=[];for(var c in a)o.call(a,c)&&b.push(c);return b}},{"util/":7}],6:[function(a,b){b.exports=function(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.readUInt8}},{}],7:[function(a,b,c){(function(b,d){function e(a,b){var d={seen:[],stylize:g};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),p(b)?d.showHidden=b:b&&c._extend(d,b),v(d.showHidden)&&(d.showHidden=!1),v(d.depth)&&(d.depth=2),v(d.colors)&&(d.colors=!1),v(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=f),i(d,a,d.depth)}function f(a,b){var c=e.styles[b];return c?"["+e.colors[c][0]+"m"+a+"["+e.colors[c][1]+"m":a}function g(a){return a}function h(a){var b={};return a.forEach(function(a){b[a]=!0}),b}function i(a,b,d){if(a.customInspect&&b&&A(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d,a);return t(e)||(e=i(a,e,d)),e}var f=j(a,b);if(f)return f;var g=Object.keys(b),p=h(g);if(a.showHidden&&(g=Object.getOwnPropertyNames(b)),z(b)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return k(b);if(0===g.length){if(A(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(w(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(y(b))return a.stylize(Date.prototype.toString.call(b),"date");if(z(b))return k(b)}var r="",s=!1,u=["{","}"];if(o(b)&&(s=!0,u=["[","]"]),A(b)){var v=b.name?": "+b.name:"";r=" [Function"+v+"]"}if(w(b)&&(r=" "+RegExp.prototype.toString.call(b)),y(b)&&(r=" "+Date.prototype.toUTCString.call(b)),z(b)&&(r=" "+k(b)),0===g.length&&(!s||0==b.length))return u[0]+r+u[1];if(0>d)return w(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var x;return x=s?l(a,b,d,p,g):g.map(function(c){return m(a,b,d,p,c,s)}),a.seen.pop(),n(x,r,u)}function j(a,b){if(v(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return s(b)?a.stylize(""+b,"number"):p(b)?a.stylize(""+b,"boolean"):q(b)?a.stylize("null","null"):void 0}function k(a){return"["+Error.prototype.toString.call(a)+"]"}function l(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)f.push(F(b,String(g))?m(a,b,c,d,String(g),!0):"");return e.forEach(function(e){e.match(/^\d+$/)||f.push(m(a,b,c,d,e,!0))}),f}function m(a,b,c,d,e,f){var g,h,j;if(j=Object.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?h=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(h=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),h||(a.seen.indexOf(j.value)<0?(h=q(c)?i(a,j.value,null):i(a,j.value,c-1),h.indexOf("\n")>-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),v(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function n(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function o(a){return Array.isArray(a)}function p(a){return"boolean"==typeof a}function q(a){return null===a}function r(a){return null==a}function s(a){return"number"==typeof a}function t(a){return"string"==typeof a}function u(a){return"symbol"==typeof a}function v(a){return void 0===a}function w(a){return x(a)&&"[object RegExp]"===C(a)}function x(a){return"object"==typeof a&&null!==a}function y(a){return x(a)&&"[object Date]"===C(a)}function z(a){return x(a)&&("[object Error]"===C(a)||a instanceof Error)}function A(a){return"function"==typeof a}function B(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),J[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=/%[sdj%]/g;c.format=function(a){if(!t(a)){for(var b=[],c=0;c=f)return a;switch(a){case"%s":return String(d[c++]);case"%d":return Number(d[c++]);case"%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),h=d[c];f>c;h=d[++c])g+=q(h)||!x(h)?" "+h:" "+e(h);return g},c.deprecate=function(a,e){function f(){if(!g){if(b.throwDeprecation)throw new Error(e);b.traceDeprecation?console.trace(e):console.error(e),g=!0}return a.apply(this,arguments)}if(v(d.process))return function(){return c.deprecate(a,e).apply(this,arguments)};if(b.noDeprecation===!0)return a;var g=!1;return f};var H,I={};c.debuglog=function(a){if(v(H)&&(H=b.env.NODE_DEBUG||""),a=a.toUpperCase(),!I[a])if(new RegExp("\\b"+a+"\\b","i").test(H)){var d=b.pid;I[a]=function(){var b=c.format.apply(c,arguments);console.error("%s %d: %s",a,d,b)}}else I[a]=function(){};return I[a]},c.inspect=e,e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=o,c.isBoolean=p,c.isNull=q,c.isNullOrUndefined=r,c.isNumber=s,c.isString=t,c.isSymbol=u,c.isUndefined=v,c.isRegExp=w,c.isObject=x,c.isDate=y,c.isError=z,c.isFunction=A,c.isPrimitive=B,c.isBuffer=a("./support/isBuffer");var J=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=a("inherits"),c._extend=function(a,b){if(!b||!x(b))return a;for(var c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}}).call(this,a("/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":6,"/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,inherits:10}],8:[function(a,b){(function(c){function d(){}function e(){m.log.apply(m,arguments)}function f(){m.log.apply(m,arguments)}function g(){m.warn.apply(m,arguments)}function h(a){p[a]=Date.now()}function i(a){var b=p[a];if(!b)throw new Error("No such label: "+a);var c=Date.now()-b;m.log(a+": "+c+"ms")}function j(){var a=new Error;a.name="Trace",a.message=n.format.apply(null,arguments),m.error(a.stack)}function k(a){m.log(n.inspect(a)+"\n")}function l(a){if(!a){var b=o.call(arguments,1);l.ok(!1,n.format.apply(null,b))}}var m,n=a("util"),l=a("assert"),o=Array.prototype.slice,p={};m="undefined"!=typeof c&&c.console?c.console:"undefined"!=typeof window&&window.console?window.console:{};for(var q=[[d,"log"],[e,"info"],[f,"warn"],[g,"error"],[h,"time"],[i,"timeEnd"],[j,"trace"],[k,"dir"],[l,"assert"]],r=0;ra||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,h,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||f(this._events.error)&&!this._events.error.length))throw b=arguments[1],b instanceof Error?b:TypeError('Uncaught, unspecified "error" event.');if(c=this._events[a],g(c))return!1;if(d(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];c.apply(this,h)}else if(f(c)){for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];for(j=c.slice(),e=j.length,i=0;e>i;i++)j[i].apply(this,h)}return!0},c.prototype.addListener=function(a,b){var e;if(!d(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d(b.listener)?b.listener:b),this._events[a]?f(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,f(this._events[a])&&!this._events[a].warned){var e;e=g(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace()) +}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),e||(e=!0,b.apply(this,arguments))}if(!d(b))throw TypeError("listener must be a function");var e=!1;return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,g,h;if(!d(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],g=c.length,e=-1,c===b||d(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(f(c)){for(h=g;h-->0;)if(c[h]===b||c[h].listener&&c[h].listener===b){e=h;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d(a._events[b])?1:a._events[b].length:0}},{}],10:[function(a,b){b.exports="function"==typeof Object.create?function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],11:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],12:[function(a,b){b.exports=a(6)},{}],13:[function(a,b){b.exports=a(7)},{"./support/isBuffer":12,"/mnt/ebs1/workspace/fh-js-sdk_beta/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":11,inherits:10}],14:[function(a,b){!function(a){var c="undefined";!function(a,c){"undefined"!=typeof b?b.exports=c():"function"==typeof define&&"object"==typeof define.amd?define(c):this[a]=c()}("log",function(){function b(b){return typeof console===c?l:console[b]===a?console.log!==a?d(console,"log"):l:d(console,b)}function d(b,c){var d=b[c];if(d.bind!==a)return b[c].bind(b);if(Function.prototype.bind===a)return e(d,b);try{return Function.prototype.bind.call(b[c],b)}catch(f){return e(d,b)}}function e(a,b){return function(){Function.prototype.apply.apply(a,[b,arguments])}}function f(a){for(var b=0;b=0&&d<=k.levels.SILENT){if(i(d),d===k.levels.SILENT)return void f(function(){return l});if(typeof console===c)return f(function(a){return function(){typeof console!==c&&(k.setLevel(d),k[a].apply(k,arguments))}}),"No console available for logging";f(function(a){return d<=k.levels[a.toUpperCase()]?b(a):l})}else{if("string"!=typeof d||k.levels[d.toUpperCase()]===a)throw"log.setLevel() called with invalid level: "+d;k.setLevel(k.levels[d.toUpperCase()])}},k.enableAll=function(){k.setLevel(k.levels.TRACE)},k.disableAll=function(){k.setLevel(k.levels.SILENT)},j(),k})}()},{}],15:[function(a,b){var c=Object.prototype.toString;b.exports=function(a){switch(c.call(a)){case"[object Function]":return"function";case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object String]":return"string"}if("object"==typeof a&&a&&"number"==typeof a.length)try{if("function"==typeof a.callee)return"arguments"}catch(b){if(b instanceof TypeError)return"arguments"}return null===a?"null":void 0===a?"undefined":a&&1===a.nodeType?"element":a===Object(a)?"object":typeof a}},{}],16:[function(a,b){var c=a("./modules/constants"),d=a("./modules/logger"),e=a("./modules/ajax"),f=a("./modules/events"),g=a("./modules/waitForCloud"),h=a("./modules/api_act"),i=a("./modules/api_auth"),j=a("./modules/api_sec"),k=a("./modules/api_hash"),l=a("./modules/sync-cli"),m=a("./modules/api_mbaas"),n=a("./modules/api_cloud"),o=a("./modules/fhparams"),p=a("./modules/appProps"),q=a("./modules/device"),r=function(a,b){f.addListener(a,b),a===c.INIT_EVENT&&(g.isReady()?b(null,{host:g.getCloudHostUrl()}):g.getInitError()&&b(g.getInitError()))},s=function(a,b){a===c.INIT_EVENT&&g.isReady()?b(null,{host:g.getCloudHostUrl()}):a===c.INIT_EVENT&&g.getInitError()?b(g.getInitError()):f.once(a,b)},t=function(a,b,c){d.warn("$fh.init will be deprecated soon"),g.ready(function(a,d){if(a){if("function"==typeof c)return c(a)}else"function"==typeof b&&b(d.host)})},u=window.$fh||{};u.init=t,u.act=h,u.auth=i,u.cloud=n,u.sec=j,u.hash=k,u.sync=l,u.ajax=u.__ajax=e,u.mbaas=m,u._getDeviceId=q.getDeviceId,u.fh_timeout=6e4,u.getCloudURL=function(){return g.getCloudHostUrl()},u.getFHParams=function(){return o.buildFHParams()},u.addListener=r,u.on=r,u.once=s;for(var v=["removeListener","removeAllListeners","setMaxListeners","listeners","emit"],w=0;w=0&&(a=!0),a}function m(a){var b=null;return window.XMLHttpRequest&&(b=new XMLHttpRequest),l()&&a===!0&&"undefined"!=typeof window.XDomainRequest&&(b=new v(new XDomainRequest)),"undefined"!=typeof Titanium&&(b=Titanium.Network.createHTTPClient({timeout:I.settings.timeout})),b}function n(a){return a&&(a==G?"html":a==F?"json":D.test(a)?"script":E.test(a)&&"xml")||"text"}function o(a,b){return(a+"&"+b).replace(/[&?]{1,2}/,"?")}function p(a){"object"===t(a.data)&&("function"==typeof a.data.append?a.formdata=!0:a.data=r(a.data)),!a.data||a.type&&"GET"!=a.type.toUpperCase()||(a.url=o(a.url,a.data))}function q(a,b,c,d){var e="array"===t(b);for(var f in b){var g=b[f];d&&(f=c?d:d+"["+(e?"":f)+"]"),!d&&e?a.add(g.name,g.value):(c?"array"===t(g):"object"===t(g))?q(a,g,c,f):a.add(f,g)}}function r(a,b){var c=[];return c.add=function(a,b){this.push(J(a)+"="+J(b))},q(c,a,b),c.join("&").replace("%20","+")}function s(a){var b=Array.prototype.slice;return b.call(arguments,1).forEach(function(b){for(z in b)void 0!==b[z]&&(a[z]=b[z])}),a}var t,u=a("./events"),v=a("./XDomainRequestWrapper"),w=a("./logger");try{t=a("type-of")}catch(x){var y=a;t=y("type")}var z,A,B=0,C=window.document,D=/^(?:text|application)\/javascript/i,E=/^(?:text|application)\/xml/i,F="application/json",G="text/html",H=/^\s*$/,I=b.exports=function(a){var b=s({},a||{});window&&window.$fh&&"number"==typeof window.$fh.fh_timeout&&(I.settings.timeout=window.$fh.fh_timeout);for(z in I.settings)void 0===b[z]&&(b[z]=I.settings[z]);e(b),b.crossDomain||(b.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(b.url)&&(RegExp.$1!=window.location.protocol||RegExp.$2!=window.location.host));var c=b.dataType,d=/=\?/.test(b.url);if("jsonp"==c||d)return d||(b.url=o(b.url,(b.jsonp?b.jsonp:"_callback")+"=?")),I.JSONP(b);b.url||(b.url=window.location.toString()),p(b);var f,j=b.accepts[c],l={},m=/^([\w-]+:)\/\//.test(b.url)?RegExp.$1:window.location.protocol,q=b.xhr(b.crossDomain);b.crossDomain||(l["X-Requested-With"]="XMLHttpRequest"),j&&(l.Accept=j,j.indexOf(",")>-1&&(j=j.split(",",2)[0]),q.overrideMimeType&&q.overrideMimeType(j)),(b.contentType||b.data&&!b.formdata&&"GET"!=b.type.toUpperCase())&&(l["Content-Type"]=b.contentType||"application/x-www-form-urlencoded"),b.headers=s(l,b.headers||{}),"undefined"!=typeof Titanium&&q.setOnerror(function(){f&&(clearTimeout(f),i(null,"error",q,b))}),q.onreadystatechange=function(){if(4==q.readyState){clearTimeout(f),f=void 0;var a,d=!1;if(b.tryJSONP&&0===q.status&&b.crossDomain&&!q.isTimeout&&"file:"!=m)return w.debug("retry ajax call with jsonp"),b.type="GET",b.dataType="jsonp",b.data="_jsonpdata="+b.data,I(b);if(q.status>=200&&q.status<300||304==q.status||0==q.status&&"file:"==m){c=c||n(q.getResponseHeader("content-type")),a=q.responseText,w.debug("ajax response :: status = "+q.status+" :: body = "+a);try{"script"==c?(1,eval)(a):"xml"==c?a=q.responseXML:"json"==c&&(a=H.test(a)?null:JSON.parse(a))}catch(e){d=e}d?(w.debug("ajax error",d),i(d,"parsererror",q,b)):h(a,q,b)}else i(null,"error",q,b)}};var r="async"in b?b.async:!0;w.debug("ajax call settings",b),q.open(b.type,b.url,r);for(A in b.headers)q.setRequestHeader(A,b.headers[A]);return g(q,b)===!1?(w.debug("ajax call is aborted due to ajaxBeforeSend"),q.abort(),!1):(b.timeout>0&&(f=setTimeout(function(){w.debug("ajax call timed out"),q.onreadystatechange=k,q.abort(),q.isTimeout=!0,i(null,"timeout",q,b)},b.timeout)),q.send(b.data?b.data:null),q)};I.active=0,I.JSONP=function(a){if(!("type"in a))return I(a);var b,c="jsonp"+ ++B,d=C.createElement("script"),e=function(){c in window&&(window[c]=k),j("abort",f,a)},f={abort:e},g=C.getElementsByTagName("head")[0]||C.documentElement;return a.error&&(d.onerror=function(){f.abort(),a.error()}),window[c]=function(d){clearTimeout(b),b=void 0,delete window[c],h(d,f,a)},p(a),d.src=a.url.replace(/=\?/,"="+c),g.insertBefore(d,g.firstChild),a.timeout>0&&(b=setTimeout(function(){f.abort(),j("timeout",f,a)},a.timeout)),f},I.settings={type:"GET",beforeSend:k,success:k,error:k,complete:k,context:null,global:!0,xhr:m,accepts:{script:"text/javascript, application/javascript",json:F,xml:"application/xml, text/xml",html:G,text:"text/plain"},crossDomain:!1},I.get=function(a,b){return I({url:a,success:b})},I.post=function(a,b,c,d){return"function"===t(b)&&(d=d||c,c=b,b=null),I({type:"POST",url:a,data:b,success:c,dataType:d})},I.getJSON=function(a,b){return I({url:a,success:b,dataType:"json"})};var J=encodeURIComponent},{"./XDomainRequestWrapper":17,"./events":30,"./logger":37,"type-of":15}],19:[function(a,b){function c(a,b,c){var d=e.getCloudHost(),k=d.getActUrl(a.act),l=a.req||{};return l=f.addFHParams(l),g({url:k,tryJSONP:!0,type:"POST",dataType:"json",data:h.stringify(l),contentType:"application/json",timeout:a.timeout||j.timeout,success:b,error:function(a,b,d){return i(c,a,b,d)}})}var d=a("./logger"),e=a("./waitForCloud"),f=a("./fhparams"),g=a("./ajax"),h=a("JSON"),i=a("./handleError"),j=a("./appProps");b.exports=function(a,b,f){return d.debug("act is called"),f||(f=function(a,b){d.debug(a+":"+h.stringify(b))}),a.act?void e.ready(function(e){return d.debug("Calling fhact now"),e?f(e.message,e):void c(a,b,f)}):f("act_no_action",{})}},{"./ajax":18,"./appProps":25,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],20:[function(a,b){var c=a("./logger"),d=a("./waitForCloud"),e=a("./fhparams"),f=a("./ajax"),g=a("JSON"),h=a("./handleError"),i=a("./device"),j=a("./constants"),k=a("./checkAuth"),l=a("./appProps");b.exports=function(a,b,m){return m||(m=function(a,b){c.debug(a+":"+g.stringify(b))}),a.policyId?a.clientToken?void d.ready(function(c){if(c)return m(c.message,c);var d={};d.policyId=a.policyId,d.clientToken=a.clientToken,a.endRedirectUrl&&(d.endRedirectUrl=a.endRedirectUrl,a.authCallback&&(d.endRedirectUrl+=(/\?/.test(d.endRedirectUrl)?"&":"?")+"_fhAuthCallback="+a.authCallback)),d.params={},a.params&&(d.params=a.params);var n=a.endRedirectUrl||"status=complete";d.device=i.getDeviceId();var o=l.getAppProps(),p=o.host+j.boxprefix+"admin/authpolicy/auth";d=e.addFHParams(d),f({url:p,type:"POST",tryJSONP:!0,data:g.stringify(d),dataType:"json",contentType:"application/json",timeout:a.timeout||o.timeout,success:function(a){k.handleAuthResponse(n,a,b,m)},error:function(a,b,c){h(m,a,b,c)}})}):m("auth_no_clientToken",{}):m("auth_no_policyId",{})}},{"./ajax":18,"./appProps":25,"./checkAuth":26,"./constants":27,"./device":29,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],21:[function(a,b){function c(a,b,c){var d=e.getCloudHost(),k=d.getCloudUrl(a.path),l=a.data||{};return l=f.addFHParams(l),g({url:k,type:a.method||"POST",dataType:a.dataType||"json",data:h.stringify(l),contentType:a.contentType||"application/json",timeout:a.timeout||j.timeout,success:b,error:function(a,b,d){return i(c,a,b,d)}})}var d=a("./logger"),e=a("./waitForCloud"),f=a("./fhparams"),g=a("./ajax"),h=a("JSON"),i=a("./handleError"),j=a("./appProps");b.exports=function(a,b,f){d.debug("cloud is called"),f||(f=function(a,b){d.debug(a+":"+h.stringify(b))}),e.ready(function(e){return d.debug("Calling fhact now"),e?f(e.message,e):void c(a,b,f)})}},{"./ajax":18,"./appProps":25,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],22:[function(a,b){var c=a("./security/hash");b.exports=function(a,b,d){var e={};"undefined"==typeof a.algorithm&&(a.algorithm="MD5"),e.act="hash",e.params=a,c(e,b,d)}},{"./security/hash":43}],23:[function(a,b){var c=a("./logger"),d=a("./waitForCloud"),e=a("./fhparams"),f=a("./ajax"),g=a("JSON"),h=a("./handleError"),i=(a("./constants"),a("./appProps"));b.exports=function(a,b,j){c.debug("mbaas is called."),j||(j=function(a,b){console.debug(a+":"+g.stringify(b))});var k=a.service,l=a.params;d.ready(function(m){if(c.debug("Calling mbaas now"),m)return j(m.message,m);var n=d.getCloudHost(),o=n.getMBAASUrl(k);return l=e.addFHParams(l),f({url:o,tryJSONP:!0,type:"POST",dataType:"json",data:g.stringify(l),contentType:"application/json",timeout:a.timeout||i.timeout,success:b,error:function(a,b,c){return h(j,a,b,c)}})})}},{"./ajax":18,"./appProps":25,"./constants":27,"./fhparams":31,"./handleError":32,"./logger":37,"./waitForCloud":47,JSON:3}],24:[function(a,b){var c=a("./security/aes-keygen"),d=a("./security/aes-node"),e=a("./security/rsa-node"),f=a("./security/hash");b.exports=function(a,b,g){return a.act?a.params?a.params.algorithm?(a.params.algorithm=a.params.algorithm.toLowerCase(),"hash"===a.act?f(a,b,g):"encrypt"===a.act?"aes"===a.params.algorithm?d.encrypt(a,b,g):"rsa"===a.params.algorithm?e.encrypt(a,b,g):g("encrypt_bad_algorithm:"+a.params.algorithm,{},a):"decrypt"===a.act?"aes"===a.params.algorithm?d.decrypt(a,b,g):g("decrypt_bad_algorithm:"+a.params.algorithm,{},a):"keygen"===a.act?"aes"===a.params.algorithm?c(a,b,g):g("keygen_bad_algorithm:"+a.params.algorithm,{},a):void 0):void g("no_params_algorithm",{},a):void g("no_params",{},a):void g("bad_act",{},a)}},{"./security/aes-keygen":41,"./security/aes-node":42,"./security/hash":43,"./security/rsa-node":44}],25:[function(a,b){var c=a("./constants"),d=a("./ajax"),e=a("./logger"),f=a("./queryMap"),g=null,h=function(a){var b=document.location.href,h=f(b),i="undefined"!=typeof h.url;if(i)return g={},g.local=!0,g.host=h.url.replace(/#.*?$/g,""),g.appid="000000000000000000000000",g.appkey="0000000000000000000000000000000000000000",g.projectid="000000000000000000000000",g.connectiontag="0.0.1",g.loglevel=h.loglevel,a(null,g);var j=h.fhconfig||c.config_js;d({url:j,dataType:"json",success:function(b){return e.debug("fhconfig = "+JSON.stringify(b)),null==b?window.fh_app_props?(g=window.fh_app_props,a(null,window.fh_app_props)):a(new Error("app_config_missing")):(g=b,void a(null,g))},error:function(){return window.fh_app_props?(g=window.fh_app_props,a(null,window.fh_app_props)):(e.error(c.config_js+" Not Found"),void a(new Error("app_config_missing")))}})},i=function(a){g=a},j=function(){return g};b.exports={load:h,getAppProps:j,setAppProps:i}},{"./ajax":18,"./constants":27,"./logger":37,"./queryMap":39}],26:[function(a,b){var c=a("./logger"),d=a("./queryMap"),e=a("JSON"),f=a("./fhparams"),g=function(a){if(/\_fhAuthCallback/.test(a)){var b=d(a);if(b){var c=b._fhAuthCallback;if(c)if(b.result&&"success"===b.result){var g={sessionToken:b.fh_auth_session,authResponse:e.parse(decodeURIComponent(decodeURIComponent(b.authResponse)))};f.setAuthSessionToken(b.fh_auth_session),window[c](null,g)}else window[c]({message:b.message})}}},h=function(a,b,g,h){if(b.status&&"ok"===b.status){var i=function(a){a.sessionToken&&f.setAuthSessionToken(a.sessionToken),g(a)};if(b.url){var j=null,k=function(b){if(b.indexOf(a)>-1){j&&j.close();var c=d(b);if(c)if(c.result&&"success"===c.result){var f={sessionToken:c.fh_auth_session,authResponse:e.parse(decodeURIComponent(decodeURIComponent(c.authResponse)))};i(f)}else h&&h("auth_failed",{message:c.message});else h&&h("auth_failed",{message:c.message})}};if(window.PhoneGap||window.cordova)if(window.plugins&&window.plugins.childBrowser)"function"==typeof window.plugins.childBrowser.showWebPage&&(window.plugins.childBrowser.onLocationChange=k,window.plugins.childBrowser.showWebPage(b.url),j=window.plugins.childBrowser);else try{j=window.open(b.url,"_blank","location=yes"),j.addEventListener("loadstart",function(a){k(a.url)})}catch(l){c.info("InAppBrowser plugin is not intalled."),i(b)}else document.location.href=b.url}else i(b)}else h&&h("auth_failed",b)};window.addEventListener?window.addEventListener("load",function(){g(window.location.href)},!1):window.attachEvent&&window.attachEvent("onload",function(){g(window.location.href)}),b.exports={handleAuthResponse:h}},{"./fhparams":31,"./logger":37,"./queryMap":39,JSON:3}],27:[function(a,b){b.exports={boxprefix:"/box/srv/1.1/",sdk_version:"2.0.17-alpha",config_js:"fhconfig.json",INIT_EVENT:"fhinit"}},{}],28:[function(a,b){b.exports={readCookieValue:function(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d1?b=f[1]:"undefined"!=typeof window.fh_destination_code?b=window.fh_destination_code:c.forEach(function(a){a.test.forEach(function(c){d.indexOf(c)>-1&&(b=a.destination)})}),null==b&&(b="web"),e.debug("destination = "+b),b}}},{"./cookies":28,"./logger":37,"./platformsMap":38,"./uuid":46}],30:[function(a,b){var c=a("events").EventEmitter,d=new c;d.setMaxListeners(0),b.exports=d},{events:9}],31:[function(a,b){var c=a("./device"),d=a("./sdkversion"),e=a("./appProps"),f=a("./logger"),g=null,h=null,i=function(){if(g)return g;var a={};a.cuid=c.getDeviceId(),a.cuidMap=c.getCuidMap(),a.destination=c.getDestination(),(window.device||navigator.device)&&(a.device=window.device||navigator.device),"undefined"!=typeof window.fh_app_version&&(a.app_version=fh_app_version),"undefined"!=typeof window.fh_project_version&&(a.project_version=fh_project_version),"undefined"!=typeof window.fh_project_app_version&&(a.project_app_version=fh_project_app_version),a.sdk_version=d(),h&&(a.sessionToken=h);var b=e.getAppProps();return b&&(a.appid=b.appid,a.appkey=b.appkey,a.projectid=b.projectid,a.analyticsTag=b.analyticsTag,a.connectiontag=b.connectiontag,b.init&&(a.init="string"==typeof b.init?JSON.parse(b.init):b.init)),g=a,f.debug("fhparams = ",g),a},j=function(a){var a=a||{};return a.__fh=i(),a},k=function(a){h=a};b.exports={buildFHParams:i,addFHParams:j,setAuthSessionToken:k}},{"./appProps":25,"./device":29,"./logger":37,"./sdkversion":40}],32:[function(a,b){var c=a("JSON");b.exports=function(a,b,d,e){var f,g=0;if(b)try{g=b.status;var h=c.parse(b.responseText);f=h.error||h.msg,f instanceof Array&&(f=f.join("\n"))}catch(i){f=b.responseText}a&&a(f,{status:g,message:d,error:e})}},{JSON:3}],33:[function(a,b){function c(a){var b=a;return"/"===b.charAt(b.length-1)&&(b=b.substring(0,b.length-1)),b}function d(a){var b=a;return b.length>1&&"/"===b.charAt(0)&&(b=b.substring(1,b.length)),b}function e(a){this.cloud_props=a,this.cloud_host=void 0,this.isLegacy=!1}var f=a("./constants"),g=a("./appProps");e.prototype.getHost=function(a){if(this.cloud_host)return this.cloud_host;var b,d;if(this.cloud_props&&this.cloud_props.hosts&&(b=this.cloud_props.hosts.url,"undefined"==typeof b)){var e=this.cloud_props.hosts.releaseCloudUrl;d=this.cloud_props.hosts.releaseCloudType,"undefined"!=typeof a&&a.indexOf("dev")>-1&&(e=this.cloud_props.hosts.debugCloudUrl,d=this.cloud_props.hosts.debugCloudType),b=e}return b=c(b),this.cloud_host=b,"fh"===d&&(this.isLegacy=!0),b},e.prototype.getActUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.isLegacy?this.cloud_host+f.boxprefix+"act/"+this.cloud_props.domain+"/"+b.appid+"/"+a+"/"+b.appid:this.cloud_host+"/cloud/"+a},e.prototype.getMBAASUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.cloud_host+"/mbaas/"+a},e.prototype.getCloudUrl=function(a){var b=g.getAppProps()||{};return"undefined"==typeof this.cloud_host&&this.getHost(b.mode),this.cloud_host+"/"+d(a)},b.exports=e},{"./appProps":25,"./constants":27}],34:[function(a,b){var c=(a("./loadScript"),a("../../libs/generated/lawnchair")),d=a("./lawnchair-ext"),e=a("./constants"),f=a("./fhparams"),g=a("./ajax"),h=a("./handleError"),i=a("./logger"),j=a("JSON"),k=a("./security/hash"),l=a("./appProps"),m=function(a){l.load(function(b,c){return b?a(b):n(c,a)})},n=function(a,b){if(a.loglevel&&i.setLevel(a.loglevel),a.local){var l={domain:"local",firstTime:!1,hosts:{debugCloudType:"node",debugCloudUrl:a.host,releaseCloudType:"node",releaseCloudUrl:a.host,type:"cloud_nodejs",url:a.host},init:{trackId:"000000000000000000000000"},status:"ok"};return b(null,{cloud:l})}d.addAdapter(a,k);var m={name:"fh_init_storage",adapter:["dom","webkit-sqlite","window-name"],fail:function(a,b){var c="read/save from/to local storage failed msg:"+a+" err:"+b;return fail(c,{})}};"undefined"!=typeof Titanium&&(m.adapter=["titanium"]);var n=function(a,c,d,e){var k=f.buildFHParams();g({url:a,type:"POST",tryJSONP:!0,dataType:"json",contentType:"application/json",data:j.stringify(k),timeout:c.timeout,success:function(a){e&&e.save({key:"fh_init",value:a},function(){}),b&&b(null,{cloud:a})},error:function(a,c,e){var f="unknown";a&&(f=a.status+" - "+a.responseText),i.error("App init returned error : "+f),d?(i.info("Using cached host: "+j.stringify(d)),b&&b(null,{cloud:d})):(i.error("No cached host found. Init failed."),h(function(a,c){b&&b({error:c,message:a})},a,c,e))}})},o=null,p=a.host+e.boxprefix+"app/init";try{o=new c(m,function(){}),o.get("fh_init",function(b){var c=null;b&&null!==b.value&&"undefined"!=typeof b.value&&""!==b&&(b="string"==typeof b?j.parse(b):b,b.value="string"==typeof b.value?j.parse(b.value):b.value,a.init=b.value.init?b.value.init:"string"==typeof b.value?j.parse(b.value):b.value,b.value.hosts&&(c=b.value)),n(p,a,c,o)})}catch(q){n(p,a,null,null)}};b.exports={init:m,loadCloudProps:n}},{"../../libs/generated/lawnchair":2,"./ajax":18,"./appProps":25,"./constants":27,"./fhparams":31,"./handleError":32,"./lawnchair-ext":35,"./loadScript":36,"./logger":37,"./security/hash":43,JSON:3}],35:[function(a,b){var c=a("../../libs/generated/lawnchair"),d=function(a,b){function c(a){console&&console.log(a)}function d(d,e){d=a.appid+d,b({algorithm:"MD5",text:d},function(a){var b=a.hashvalue+".txt";return"undefined"==typeof navigator.externalstorage?(c("filenameForKey key="+d+" , Filename: "+b),e(b)):void navigator.externalstorage.enable(function(a){var c=b;return a.path&&(c=a.path,c.match(/\/$/)||(c+="/"),c+=b),b=c,e(b)},function(){return e(b)})})}var e=function(a,b){if(!console)throw a;console.log("error in file system adapter !",a,b)};return{valid:function(){return!!window.requestFileSystem},init:function(a,b){a&&"function"==typeof a.fail&&(e=a.fail),b&&this.fn(this.name,b).call(this,this)},keys:function(){throw"Currently not supported"},save:function(a,b){var c=a.key,f=a.val||a.value;d(c,function(a){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(a,{create:!0},function(a){a.createWriter(function(a){a.onwrite=function(){return b({key:c,val:f})},a.write(f)},function(){e("[save] Failed to create file writer")})},function(){e("[save] Failed to getFile")})},function(){e("[save] Failed to requestFileSystem")})})},batch:function(){throw"Currently not supported"},get:function(a,b){d(a,function(c){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(c,{},function(c){c.file(function(c){var d=new FileReader;d.onloadend=function(c){var d=c.target.result;try{d=decodeURIComponent(d)}catch(e){}return b({key:a,val:d})},d.readAsText(c)},function(){e("[load] Failed to getFile")})},function(){b({key:a,val:null})})},function(){e("[load] Failed to get fileSystem")})})},exists:function(a,b){d(a,function(a){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(c){c.root.getFile(a,{},function(){return b(!0)},function(){return b(!1)})})})},all:function(){throw"Currently not supported"},remove:function(a,b){d(a,function(c){window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(d){d.root.getFile(c,{},function(c){c.remove(function(){return b({key:a,val:null})},function(){e("[remove] Failed to remove file")})},function(){e("[remove] Failed to getFile")})},function(){e("[remove] Failed to get fileSystem")})})},nuke:function(){throw"Currently not supported"}}},e=function(a,b){c.adapter("localFileStorage",d(a,b))};b.exports={addAdapter:e}},{"../../libs/generated/lawnchair":2}],36:[function(a,b){b.exports=function(a,b){var c,d=document.head||document.getElementsByTagName("head")[0]||document.documentElement;c=document.createElement("script"),c.async="async",c.src=a,c.type="text/javascript",c.onload=c.onreadystatechange=function(){(!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,d&&c.parentNode&&d.removeChild(c),c=void 0,b&&"function"==typeof b&&b())},d.insertBefore(c,d.firstChild)}},{}],37:[function(a,b){var c=(a("console"),a("loglevel"));c.setLevel("info"),b.exports=c},{console:8,loglevel:14}],38:[function(a,b){b.exports=[{destination:"ipad",test:["iPad"]},{destination:"iphone",test:["iPhone"]},{destination:"android",test:["Android"]},{destination:"blackberry",test:["BlackBerry","BB10","RIM Tablet OS"]},{destination:"windowsphone",test:["Windows Phone 8"]},{destination:"windowsphone7",test:["Windows Phone OS 7"]}]},{}],39:[function(a,b){b.exports=function(a){var b={},c=a.split("?");if(2===c.length){var d=c[1],e=d.split("&");b={};for(var f=0;f100&&(e/=8),"undefined"==typeof d?c("security library is not loaded."):b({algorithm:"AES",secretkey:f(e),iv:f(e)})};b.exports=g},{"../../../libs/rsa":4}],42:[function(a,b){var c=a("../../../libs/generated/crypto"),d=function(a,b,d){var e=["key","plaintext","iv"];if("aes"!==a.params.algorithm.toLowerCase())return d("encrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return d("no_params_"+g,{},a)}var h=c.AES.encrypt(a.params.plaintext,c.enc.Hex.parse(a.params.key),{iv:c.enc.Hex.parse(a.params.iv)});return cipher_text=c.enc.Hex.stringify(h.ciphertext),b({ciphertext:cipher_text})},e=function(a,b,d){var e=["key","ciphertext","iv"];if("aes"!==a.params.algorithm.toLowerCase())return d("decrypt_bad_algorithm",{},a); +for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return d("no_params_"+g,{},a)}var h=c.enc.Hex.parse(a.params.ciphertext),i=c.enc.Base64.stringify(h),j=c.AES.decrypt(i,c.enc.Hex.parse(a.params.key),{iv:c.enc.Hex.parse(a.params.iv)});return plain_text=j.toString(c.enc.Utf8),b({plaintext:plain_text})};b.exports={encrypt:d,decrypt:e}},{"../../../libs/generated/crypto":1}],43:[function(a,b){var c=a("../../../libs/generated/crypto"),d=function(a,b,d){if(!a.params.text)return void d("hash_no_text",{},a);var e;if("md5"===a.params.algorithm.toLowerCase())e=c.MD5(a.params.text).toString(c.enc.Hex);else if("sha1"===a.params.algorithm.toLowerCase())e=c.SHA1(a.params.text).toString(c.enc.Hex);else if("sha256"===a.params.algorithm.toLowerCase())e=c.SHA256(a.params.text).toString(c.enc.Hex);else{if("sha512"!==a.params.algorithm.toLowerCase())return d("hash_unsupported_algorithm: "+a.params.algorithm);e=c.SHA512(a.params.text).toString(c.enc.Hex)}return b({hashvalue:e})};b.exports=d},{"../../../libs/generated/crypto":1}],44:[function(a,b){var c=a("../../../libs/rsa"),d=c.RSAKey,e=function(a,b,c){var e=["modulu","plaintext"];if("rsa"!==a.params.algorithm.toLowerCase())return c("encrypt_bad_algorithm",{},a);for(var f=0;e>f;f++){var g=e[f];if(!a.params[g])return c("no_params_"+g,{},a)}var h=new d;h.setPublic(a.params.modulu,"10001");var i=a.params.plaintext;return cipher_text=h.encrypt(i),b({ciphertext:cipher_text})};b.exports={encrypt:e}},{"../../../libs/rsa":4}],45:[function(a,b){var c=a("JSON"),d=a("./api_act"),e=a("./api_cloud"),f=a("../../libs/generated/crypto"),g=a("../../libs/generated/lawnchair"),h={defaults:{sync_frequency:10,auto_sync_local_updates:!0,notify_client_storage_failed:!0,notify_sync_started:!0,notify_sync_complete:!0,notify_offline_update:!0,notify_collision_detected:!0,notify_remote_update_failed:!0,notify_local_update_applied:!0,notify_remote_update_applied:!0,notify_delta_received:!0,notify_record_delta_received:!0,notify_sync_failed:!0,do_console_log:!1,crashed_count_wait:10,resend_crashed_updates:!0,sync_active:!0,storage_strategy:"html5-filesystem",file_system_quota:61644800,has_custom_sync:null},notifications:{CLIENT_STORAGE_FAILED:"client_storage_failed",SYNC_STARTED:"sync_started",SYNC_COMPLETE:"sync_complete",OFFLINE_UPDATE:"offline_update",COLLISION_DETECTED:"collision_detected",REMOTE_UPDATE_FAILED:"remote_update_failed",REMOTE_UPDATE_APPLIED:"remote_update_applied",LOCAL_UPDATE_APPLIED:"local_update_applied",DELTA_RECEIVED:"delta_received",RECORD_DELTA_RECEIVED:"record_delta_received",SYNC_FAILED:"sync_failed"},datasets:{},config:void 0,notify_callback:void 0,init_is_called:!1,init:function(a){h.consoleLog("sync - init called"),h.config=c.parse(c.stringify(h.defaults));for(var b in a)h.config[b]=a[b];h.init_is_called||(h.init_is_called=!0,h.datasetMonitor())},notify:function(a){h.notify_callback=a},manage:function(a,b,d,e,f){h.consoleLog("manage - START");var b=b||{},g=function(g){h.consoleLog("doManage dataset :: initialised = "+g.initialised+" :: "+a+" :: "+c.stringify(b));var i=h.setOptions(b);g.query_params=d||g.query_params||{},g.meta_data=e||g.meta_data||{},g.config=i,g.syncRunning=!1,g.syncPending=!0,g.initialised=!0,"undefined"==typeof g.meta&&(g.meta={}),h.saveDataSet(a,function(){f&&f()})};h.getDataSet(a,function(a){h.consoleLog("manage - dataset already loaded"),g(a)},function(){h.consoleLog("manage - dataset not loaded... trying to load"),h.loadDataSet(a,function(b){h.consoleLog("manage - dataset loaded from local storage"),h.doNotify(a,null,h.notifications.LOCAL_UPDATE_APPLIED,"load"),g(b)},function(){h.consoleLog("manage - Creating new dataset for id "+a);var b={};b.data={},b.pending={},b.meta={},h.datasets[a]=b,g(b)})})},setOptions:function(a){h.config||(h.config=c.parse(c.stringify(h.defaults)));var b=c.parse(c.stringify(h.config)),d=c.parse(c.stringify(a));for(var e in d)b[e]=d[e];return b},list:function(a,b,d){h.getDataSet(a,function(a){if(a&&a.data){var e=c.parse(c.stringify(a.data));b(e)}else d&&d("no_data")},function(a,b){d&&d(a,b)})},create:function(a,b,c,d){return null==b&&d?d("null_data"):void h.addPendingObj(a,null,b,"create",c,d)},read:function(a,b,d,e){h.getDataSet(a,function(a){var f=a.data[b];if(f){var g=c.parse(c.stringify(f));d(g)}else e("unknown_uid")},function(a,b){e&&e(a,b)})},update:function(a,b,c,d,e){h.addPendingObj(a,b,c,"update",d,e)},"delete":function(a,b,c,d){h.addPendingObj(a,b,null,"delete",c,d)},getPending:function(a,b){h.getDataSet(a,function(a){var c;a&&(c=a.pending),b(c)},function(a){h.consoleLog(a)})},clearPending:function(a,b){h.getDataSet(a,function(c){c.pending={},h.saveDataSet(a,b)})},listCollisions:function(a,b,c){h.getDataSet(a,function(d){h.doCloudCall({dataset_id:a,req:{fn:"listCollisions",meta_data:d.meta_data}},b,c)},c)},removeCollision:function(a,b,c,d){h.getDataSet(a,function(e){h.doCloudCall({dataset_id:a,req:{fn:"removeCollision",hash:b,meta_data:e.meta_data}},c,d)})},isOnline:function(a){var b=!0;if("undefined"!=typeof navigator.onLine&&(b=navigator.onLine),b&&"undefined"!=typeof navigator.network&&"undefined"!=typeof navigator.network.connection){var c=navigator.network.connection.type;("none"===c||null===c)&&(b=!1)}return a(b)},doNotify:function(a,b,c,d){if(h.notify_callback&&h.config["notify_"+c]){var e={dataset_id:a,uid:b,code:c,message:d};setTimeout(function(){h.notify_callback(e)},0)}},getDataSet:function(a,b,c){var d=h.datasets[a];d?b(d):c&&c("unknown_dataset "+a,a)},getQueryParams:function(a,b,c){var d=h.datasets[a];d?b(d.query_params):c&&c("unknown_dataset "+a,a)},setQueryParams:function(a,b,c,d){var e=h.datasets[a];e?(e.query_params=b,h.saveDataSet(a),c&&c(e.query_params)):d&&d("unknown_dataset "+a,a)},getMetaData:function(a,b,c){var d=h.datasets[a];d?b(d.meta_data):c&&c("unknown_dataset "+a,a)},setMetaData:function(a,b,c,d){var e=h.datasets[a];e?(e.meta_data=b,h.saveDataSet(a),c&&c(e.meta_data)):d&&d("unknown_dataset "+a,a)},getConfig:function(a,b,c){var d=h.datasets[a];d?b(d.config):c&&c("unknown_dataset "+a,a)},setConfig:function(a,b,c,d){var e=h.datasets[a];if(e){var f=h.setOptions(b);e.config=f,h.saveDataSet(a),c&&c(e.config)}else d&&d("unknown_dataset "+a,a)},stopSync:function(a,b,c){h.setConfig(a,{sync_active:!1},function(){b&&b()},c)},startSync:function(a,b,c){h.setConfig(a,{sync_active:!0},function(){b&&b()},c)},doSync:function(a,b,c){var d=h.datasets[a];d?(d.syncPending=!0,h.saveDataSet(a),b&&b()):c&&c("unknown_dataset "+a,a)},forceSync:function(a,b,c){var d=h.datasets[a];d?(d.syncForced=!0,h.saveDataSet(a),b&&b()):c&&c("unknown_dataset "+a,a)},sortObject:function(a){if("object"!=typeof a||null===a)return a;var b=[];return Object.keys(a).sort().forEach(function(c){b.push({key:c,value:h.sortObject(a[c])})}),b},sortedStringify:function(a){var b="";try{b=c.stringify(h.sortObject(a))}catch(d){console.error("Error stringifying sorted object:"+d)}return b},generateHash:function(a){var b=f.SHA1(h.sortedStringify(a));return b.toString()},addPendingObj:function(a,b,d,e,f,g){function i(c){c.hash=h.generateHash(c),h.getDataSet(a,function(d){d.pending[c.hash]=c,h.updateDatasetFromLocal(d,c),h.config.auto_sync_local_updates&&(d.syncPending=!0),h.saveDataSet(a),h.doNotify(a,b,h.notifications.LOCAL_UPDATE_APPLIED,e),f(c)},function(a,b){g&&g(a,b)})}h.isOnline(function(c){c||h.doNotify(a,b,h.notifications.OFFLINE_UPDATE,e)});var j={};j.inFlight=!1,j.action=e,j.post=c.parse(c.stringify(d)),j.postHash=h.generateHash(j.post),j.timestamp=(new Date).getTime(),"create"===e?(j.uid=j.postHash,i(j)):h.read(a,b,function(a){j.uid=b,j.pre=a.data,j.preHash=h.generateHash(a.data),i(j)},function(a,b){g&&g(a,b)})},syncLoop:function(a){h.getDataSet(a,function(b){b.syncPending=!1,b.syncRunning=!0,b.syncLoopStart=(new Date).getTime(),h.doNotify(a,null,h.notifications.SYNC_STARTED,null),h.isOnline(function(d){d?h.checkHasCustomSync(a,function(){var d={};d.fn="sync",d.dataset_id=a,d.query_params=b.query_params,d.config=b.config,d.meta_data=b.meta_data,d.dataset_hash=b.hash,d.acknowledgements=b.acknowledgements||[];var e=b.pending,f=[];for(var g in e)e[g].inFlight||e[g].crashed||e[g].delayed||(e[g].inFlight=!0,e[g].inFlightDate=(new Date).getTime(),f.push(e[g]));d.pending=f,f.length>0&&h.consoleLog("Starting sync loop - global hash = "+b.hash+" :: params = "+c.stringify(d,null,2));try{h.doCloudCall({dataset_id:a,req:d},function(c){function d(c,d,f){if(c)for(var g in c)e=c[g],f.push(e),b.pending[g]&&b.pending[g].inFlight&&!b.pending[g].crashed&&(delete b.pending[g],h.doNotify(a,e.uid,d,e))}var e;if(h.updatePendingFromNewData(a,b,c),h.updateCrashedInFlightFromNewData(a,b,c),h.updateDelayedFromNewData(a,b,c),h.updateMetaFromNewData(a,b,c),h.updateNewDataFromInFlight(a,b,c),h.updateNewDataFromPending(a,b,c),c.records&&(b.data=c.records,b.hash=c.hash,h.doNotify(a,c.hash,h.notifications.DELTA_RECEIVED,"full dataset")),c.updates){var f=[];d(c.updates.applied,h.notifications.REMOTE_UPDATE_APPLIED,f),d(c.updates.failed,h.notifications.REMOTE_UPDATE_FAILED,f),d(c.updates.collisions,h.notifications.COLLISION_DETECTED,f),b.acknowledgements=f}!c.records&&c.hash&&c.hash!==b.hash?(h.consoleLog("Local dataset stale - syncing records :: local hash= "+b.hash+" - remoteHash="+c.hash),h.syncRecords(a)):(h.consoleLog("Local dataset up to date"),h.syncComplete(a,"online",h.notifications.SYNC_COMPLETE))},function(c,d){h.markInFlightAsCrashed(b),h.consoleLog("syncLoop failed : msg="+c+" :: err = "+d),h.syncComplete(a,c,h.notifications.SYNC_FAILED)})}catch(i){h.consoleLog("Error performing sync - "+i),h.syncComplete(a,i,h.notifications.SYNC_FAILED)}}):h.syncComplete(a,"offline",h.notifications.SYNC_FAILED)})})},syncRecords:function(a){h.getDataSet(a,function(b){var d=b.data||{},e={};for(var f in d){var g=f,i=d[f].hash;e[g]=i}var j={};j.fn="syncRecords",j.dataset_id=a,j.query_params=b.query_params,j.clientRecs=e,h.consoleLog("syncRecParams :: "+c.stringify(j)),h.doCloudCall({dataset_id:a,req:j},function(c){var e;if(c.create)for(e in c.create)d[e]={hash:c.create[e].hash,data:c.create[e].data},h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"create");if(c.update)for(e in c.update)d[e].hash=c.update[e].hash,d[e].data=c.update[e].data,h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"update");if(c["delete"])for(e in c["delete"])delete d[e],h.doNotify(a,e,h.notifications.RECORD_DELTA_RECEIVED,"delete");h.doNotify(a,c.hash,h.notifications.DELTA_RECEIVED,"partial dataset"),b.data=d,c.hash&&(b.hash=c.hash),h.syncComplete(a,"online",h.notifications.SYNC_COMPLETE)},function(b,c){h.consoleLog("syncRecords failed : msg="+b+" :: err="+c),h.syncComplete(a,b,h.notifications.SYNC_FAILED)})})},syncComplete:function(a,b,c){h.getDataSet(a,function(d){d.syncRunning=!1,d.syncLoopEnd=(new Date).getTime(),h.saveDataSet(a),h.doNotify(a,d.hash,c,b)})},checkDatasets:function(){for(var a in h.datasets)if(h.datasets.hasOwnProperty(a)){var b=h.datasets[a];if(!b.syncRunning&&(b.config.sync_active||b.syncForced)){var c=b.syncLoopStart,d=b.syncLoopEnd;if(b.syncForced)b.syncPending=!0;else if(null==c)h.consoleLog(a+" - Performing initial sync"),b.syncPending=!0;else if(null!=d){var e=(new Date).getTime()-d,f=1e3*b.config.sync_frequency;e>f&&(b.syncPending=!0)}b.syncPending&&(b.syncForced=!1,h.syncLoop(a))}}},checkHasCustomSync:function(a,b){var c=h.datasets[a];return c&&c.config?(h.consoleLog("dataset.config.has_custom_sync = "+c.config.has_custom_sync),null!=c.config.has_custom_sync?b():(h.consoleLog("starting check has custom sync"),void d({act:a,req:{fn:"sync"}},function(a){return h.consoleLog("check has_custom_sync - success - ",a),c.config.has_custom_sync=!0,b()},function(a,d){return h.consoleLog("check has_custom_sync - failure - ",d),d.status&&500===d.status?(h.consoleLog("check has_custom_sync - failed with 500, endpoint does exists"),c.config.has_custom_sync=!0):c.config.has_custom_sync=!1,b()}))):b()},doCloudCall:function(a,b,c){var f=!1,g=h.datasets[a.dataset_id];g&&g.config&&(f=g.config.has_custom_sync),1==f?d({act:a.dataset_id,req:a.req},function(a){b(a)},function(a,b){c(a,b)}):e({path:"/mbaas/sync/"+a.dataset_id,method:"post",data:a.req},function(a){b(a)},function(a,b){c(a,b)})},datasetMonitor:function(){h.checkDatasets(),setTimeout(function(){h.datasetMonitor()},500)},saveDataSet:function(a,b){var c=function(b,c){var d="save to local storage failed msg:"+b+" err:"+c;h.doNotify(a,null,h.notifications.CLIENT_STORAGE_FAILED,d),h.consoleLog(d)};h.getDataSet(a,function(d){g({fail:c,adapter:h.config.storage_strategy,size:h.config.file_system_quota},function(){this.save({key:"dataset_"+a,val:d},function(){return b?b():void 0})})})},loadDataSet:function(a,b,d){var e=function(b){var c="load from local storage failed msg:"+b;h.doNotify(a,null,h.notifications.CLIENT_STORAGE_FAILED,c),h.consoleLog(c)};g({fail:e,adapter:h.config.storage_strategy,size:h.config.file_system_quota},function(){this.get("dataset_"+a,function(e){if(e&&e.val){var f=e.val;if("string"==typeof f&&(f=c.parse(f)),f.initialised=!1,h.datasets[a]=f,h.consoleLog("load from local storage success for dataset_id :"+a),b)return b(f)}else if(d)return d()})})},updateDatasetFromLocal:function(a,b){var d,e,f=a.pending,g=b.uid;h.consoleLog("updating local dataset for uid "+g+" - action = "+b.action),a.meta[g]=a.meta[g]||{},"create"===b.action&&(a.data[g]&&(h.consoleLog("dataset already exists for uid in create :: "+c.stringify(a.data[g])),a.meta[g].fromPending&&(d=a.meta[g].pendingUid,delete f[d])),a.data[g]={}),"update"===b.action&&a.data[g]&&a.meta[g].fromPending&&(h.consoleLog("updating an existing pending record for dataset :: "+c.stringify(a.data[g])),d=a.meta[g].pendingUid,a.meta[g].previousPendingUid=d,e=f[d],e&&(e.inFlight?(h.consoleLog("existing in-inflight pending record = "+c.stringify(e)),b.delayed=!0,b.waiting=e.hash):(h.consoleLog("existing pre-flight pending record = "+c.stringify(e)),e.post=b.post,e.postHash=b.postHash,delete f[b.hash],b.hash=d))),"delete"===b.action&&a.data[g]&&(a.meta[g].fromPending&&(h.consoleLog("Deleting an existing pending record for dataset :: "+c.stringify(a.data[g])),d=a.meta[g].pendingUid,a.meta[g].previousPendingUid=d,e=f[d],e&&(e.inFlight?(h.consoleLog("existing in-inflight pending record = "+c.stringify(e)),b.delayed=!0,b.waiting=e.hash):(h.consoleLog("existing pending record = "+c.stringify(e)),"create"===e.action&&(delete f[b.hash],delete f[d]),"update"===e.action&&(b.pre=e.pre,b.preHash=e.preHash,b.inFlight=!1,delete f[d])))),delete a.data[g]),a.data[g]&&(a.data[g].data=b.post,a.data[g].hash=b.postHash,a.meta[g].fromPending=!0,a.meta[g].pendingUid=b.hash)},updatePendingFromNewData:function(a,b,d){var e,f=b.pending;if(f&&d.records)for(var g in f)if(f.hasOwnProperty(g)){var i=f[g];if(b.meta[i.uid]=b.meta[i.uid]||{},i.inFlight===!1){if(h.consoleLog("updatePendingFromNewData - Found Non inFlight record -> action="+i.action+" :: uid="+i.uid+" :: hash="+i.hash),"update"===i.action||"delete"===i.action)if(e=d.records[i.uid])h.consoleLog("updatePendingFromNewData - Updating pre values for existing pending record "+i.uid),i.pre=e.data,i.preHash=e.hash;else{var j=b.meta[i.uid].previousPendingUid,k=f[j];if(k&&d&&d.updates&&d.updates.applied&&d.updates.applied[k.hash]){var l=d.updates.applied[k.hash].uid;e=d.records[l],e&&(h.consoleLog("updatePendingFromNewData - Updating pre values for existing pending record which was previously a create "+i.uid+" ==> "+l),i.pre=e.data,i.preHash=e.hash,i.uid=l)}}"create"===i.action&&d&&d.updates&&d.updates.applied&&d.updates.applied[g]&&(h.consoleLog("updatePendingFromNewData - Found an update for a pending create "+c.stringify(d.updates.applied[g])),e=d.records[d.updates.applied[g].uid],e&&(h.consoleLog("updatePendingFromNewData - Changing pending create to an update based on new record "+c.stringify(e)),i.action="update",i.pre=e.data,i.preHash=e.hash,i.uid=d.updates.applied[g].uid))}}},updateNewDataFromInFlight:function(a,b,c){var d=b.pending;if(d&&c.records)for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];if(f.inFlight){var g=c&&c.updates&&c.updates.hashes&&c.updates.hashes[e]?!0:!1;if(h.consoleLog("updateNewDataFromInFlight - Found inflight pending Record - action = "+f.action+" :: hash = "+e+" :: updateReceivedForPending="+g),!g){var i=c.records[f.uid];if("update"===f.action&&i)i.data=f.post,i.hash=f.postHash;else if("delete"===f.action&&i)delete c.records[f.uid];else if("create"===f.action){h.consoleLog("updateNewDataFromInFlight - re adding pending create to incomming dataset");var j={data:f.post,hash:f.postHash};c.records[f.uid]=j}}}}},updateNewDataFromPending:function(a,b,c){var d=b.pending;if(d&&c.records)for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];if(f.inFlight===!1){h.consoleLog("updateNewDataFromPending - Found Non inFlight record -> action="+f.action+" :: uid="+f.uid+" :: hash="+f.hash);var g=c.records[f.uid];if("update"===f.action&&g)g.data=f.post,g.hash=f.postHash;else if("delete"===f.action&&g)delete c.records[f.uid];else if("create"===f.action){h.consoleLog("updateNewDataFromPending - re adding pending create to incomming dataset");var i={data:f.post,hash:f.postHash};c.records[f.uid]=i}}}},updateCrashedInFlightFromNewData:function(a,b,d){var e,f,g={applied:h.notifications.REMOTE_UPDATE_APPLIED,failed:h.notifications.REMOTE_UPDATE_FAILED,collisions:h.notifications.COLLISION_DETECTED},i=b.pending,j={};if(i){for(e in i)if(i.hasOwnProperty(e)&&(f=i[e],f.inFlight&&f.crashed))if(h.consoleLog("updateCrashedInFlightFromNewData - Found crashed inFlight pending record uid="+f.uid+" :: hash="+f.hash),d&&d.updates&&d.updates.hashes){var k=d.updates.hashes[e];k?(j[k.uid]=k,h.consoleLog("updateCrashedInFlightFromNewData - Resolving status for crashed inflight pending record "+c.stringify(k)),"failed"===k.type&&("create"===k.action?(h.consoleLog("updateCrashedInFlightFromNewData - Deleting failed create from dataset"),delete b.data[k.uid]):("update"===k.action||"delete"===k.action)&&(h.consoleLog("updateCrashedInFlightFromNewData - Reverting failed "+k.action+" in dataset"),b.data[k.uid]={data:f.pre,hash:f.preHash})),delete i[e],h.doNotify(a,k.uid,g[k.type],k)):f.crashedCount?f.crashedCount++:f.crashedCount=1}else f.crashedCount?f.crashedCount++:f.crashedCount=1;for(e in i)i.hasOwnProperty(e)&&(f=i[e],f.inFlight&&f.crashed&&f.crashedCount>b.config.crashed_count_wait&&(h.consoleLog("updateCrashedInFlightFromNewData - Crashed inflight pending record has reached crashed_count_wait limit : "+c.stringify(f)),b.config.resend_crashed_updates?(h.consoleLog("updateCrashedInFlightFromNewData - Retryig crashed inflight pending record"),f.crashed=!1,f.inFlight=!1):(h.consoleLog("updateCrashedInFlightFromNewData - Deleting crashed inflight pending record"),delete i[e])))}},updateDelayedFromNewData:function(a,b,d){var e,f,g=b.pending;if(g)for(e in g)if(g.hasOwnProperty(e)&&(f=g[e],f.delayed&&f.waiting&&(h.consoleLog("updateDelayedFromNewData - Found delayed pending record uid="+f.uid+" :: hash="+f.hash+" :: waiting="+f.waiting),d&&d.updates&&d.updates.hashes))){var i=d.updates.hashes[f.waiting];i&&(h.consoleLog("updateDelayedFromNewData - Waiting pending record is resolved rec="+c.stringify(i)),f.delayed=!1,f.waiting=void 0)}},updateMetaFromNewData:function(a,b,d){var e=b.meta;if(e&&d&&d.updates&&d.updates.hashes)for(var f in e)if(e.hasOwnProperty(f)){var g=e[f],i=g.pendingUid,j=g.previousPendingUid;h.consoleLog("updateMetaFromNewData - Found metadata with uid = "+f+" :: pendingHash = "+i+" :: previousPendingHash ="+j);var k=!0,l=!0;if(j){k=!1;var m=d.updates.hashes[j];m&&(h.consoleLog("updateMetaFromNewData - Found previousPendingUid in meta data resolved - resolved = "+c.stringify(m)),g.previousPendingUid=void 0,k=!0)}if(i){l=!1;var m=d.updates.hashes[i];m&&(h.consoleLog("updateMetaFromNewData - Found pendingUid in meta data resolved - resolved = "+c.stringify(m)),g.pendingUid=void 0,l=!0)}k&&l&&(h.consoleLog("updateMetaFromNewData - both previous and current pendings are resolved for meta data with uid "+f+". Delete it."),delete e[f])}},markInFlightAsCrashed:function(a){var b,c,d=a.pending;if(d){var e={};for(b in d)d.hasOwnProperty(b)&&(c=d[b],c.inFlight&&(h.consoleLog("Marking in flight pending record as crashed : "+b),c.crashed=!0,e[c.uid]=c))}},consoleLog:function(a){h.config.do_console_log&&console.log(a)}};!function(){h.config=h.defaults}(),b.exports={init:h.init,manage:h.manage,notify:h.notify,doList:h.list,doCreate:h.create,doRead:h.read,doUpdate:h.update,doDelete:h["delete"],listCollisions:h.listCollisions,removeCollision:h.removeCollision,getPending:h.getPending,clearPending:h.clearPending,getDataset:h.getDataSet,getQueryParams:h.getQueryParams,setQueryParams:h.setQueryParams,getMetaData:h.getMetaData,setMetaData:h.setMetaData,getConfig:h.getConfig,setConfig:h.setConfig,startSync:h.startSync,stopSync:h.stopSync,doSync:h.doSync,forceSync:h.forceSync,generateHash:h.generateHash,loadDataSet:h.loadDataSet,checkHasCustomSync:h.checkHasCustomSync}},{"../../libs/generated/crypto":1,"../../libs/generated/lawnchair":2,"./api_act":19,"./api_cloud":21,JSON:3}],46:[function(a,b){b.exports={createUUID:function(){for(var a=[],b="0123456789ABCDEF",c=0;32>c;c++)a[c]=b.substr(Math.floor(16*Math.random()),1);a[12]="4",a[16]=b.substr(3&a[16]|8,1);var d=a.join("");return d}}},{}],47:[function(a,b){var c,d=a("./initializer"),e=a("./events"),f=a("./hosts"),g=a("./constants"),h=a("./logger"),i=!1,j=!1,k=null,l=function(a){return j?a(null,{host:n()}):(e.once(g.INIT_EVENT,function(b,c){return a(b,c)}),void(i||(i=!0,d.init(function(a,b){return i=!1,a?(k=a,e.emit(g.INIT_EVENT,a)):(k=null,j=!0,c=new f(b.cloud),e.emit(g.INIT_EVENT,null,{host:n()}))}))))},m=function(){return c},n=function(){if("undefined"!=typeof c){var b=a("./appProps").getAppProps();return c.getHost(b.mode)}return void 0},o=function(){return j},p=function(){return k},q=function(){j=!1,i=!1,c=void 0,k=void 0,l(function(){})};l(function(a){a?"app_config_missing"!==a.message?h.error("Failed to initialise fh."):h.info("No fh config file"):h.info("fh cloud is ready")}),b.exports={ready:l,isReady:o,getCloudHost:m,getCloudHostUrl:n,getInitError:p,reset:q}},{"./appProps":25,"./constants":27,"./events":30,"./hosts":33,"./initializer":34,"./logger":37}]},{},[16])(16)}); \ No newline at end of file diff --git a/fh-starter-project-latest.zip b/fh-starter-project-latest.zip index 8db7d851..deb25db0 100644 Binary files a/fh-starter-project-latest.zip and b/fh-starter-project-latest.zip differ