diff --git a/README.md b/README.md index 96d86d0..d5a3a1d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +> # :warning: Alpha version. Don't use in production. + + stellar-wallet-js-sdk ===================== @@ -101,7 +104,12 @@ a user. ```js var key = StellarWallet.util.generateTotpKey(); -var uri = StellarWallet.util.generateTotpUri(key); +var uri = StellarWallet.util.generateTotpUri(key, { + // Your organization name + issuer: 'Stellar Development Foundation', + // Account name + accountName: 'bob@stellar.org' +}); ``` ### Wallet object diff --git a/bower.json b/bower.json index ce69514..005d578 100644 --- a/bower.json +++ b/bower.json @@ -4,5 +4,11 @@ "private": false, "main": "build/stellar-wallet.js", "dependencies": {}, - "devDependencies": {} + "devDependencies": {}, + "ignore": [ + "/lib", + "/test", + "/index.js", + "/gulpfile.js" + ] } \ No newline at end of file diff --git a/build/stellar-wallet.js b/build/stellar-wallet.js index 0884bbf..e292a56 100644 --- a/build/stellar-wallet.js +++ b/build/stellar-wallet.js @@ -1,8 +1,19711 @@ -var StellarWallet=function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";t.exports=r(1)},function(t,e,r){"use strict";function n(t){var e=new a(t);return u.resolve(e)}var i=(r(9),r(2)),u=r(14),o=r(4),s=r(5),a=r(3);t.exports={createWallet:function(t){return o.createWallet(t).then(n)},getWallet:function(t){return o.login(t).then(n)},errors:i,util:{generateRandomTotpKey:s.generateRandomTotpKey,generateTotpUri:s.generateTotpUri}}},function(t,e,r){"use strict";var n=r(15);Error.subclass=function(t){var e=function(e){this.name=t,this.message=e||""};return e.subclass=this.subclass,n.inherits(e,this),e},Error.prototype.setCode=function(t){return this.code=t,this},Error.prototype.setData=function(t){return this.data=t,this};var i=t.exports;i.NotInitialized=Error.subclass("NotInitialized"),i.Forbidden=Error.subclass("Forbidden"),i.WalletNotFound=Error.subclass("WalletNotFound"),i.DataCorrupt=Error.subclass("DataCorrupt"),i.InvalidField=Error.subclass("InvalidField"),i.MissingField=Error.subclass("MissingField"),i.TotpCodeRequired=Error.subclass("TotpCodeRequired"),i.InvalidTotpCode=Error.subclass("InvalidTotpCode"),i.ConnectionError=Error.subclass("ConnectionError"),i.UnknownError=Error.subclass("UnknownError")},function(t,e,r){"use strict";function n(t){var e=this,r=["server","username","rawWalletId","rawMainData","rawKeychainData","rawPrivateKey","lockVersion"];if(i.each(r,function(r){e[r]=t[r]}),i.isEmpty(this.server))throw new u.MissingField("server parameter is required.");this.server=this.server.replace(/\/+$/g,""),this.walletId=o.codec.base64.fromBits(this.rawWalletId)}var i=r(9),u=(r(7),r(2)),o=r(8),s=r(4);n.prototype.getServer=function(){return this.server},n.prototype.getUsername=function(){return this.username},n.prototype.getMainData=function(){return this.rawMainData},n.prototype.getKeychainData=function(){return this.rawKeychainData},n.prototype.setupTotp=function(t){return t=i.extend(t,i.pick(this,["server","username","walletId","totpKey","totpCode","lockVersion","rawPrivateKey"])),s.setupTotp(t)},t.exports=n},function(t,e,r){"use strict";var n=r(9),i=r(16),u=r(14);t.exports={};var o=["login","create_wallet","setup_totp","delete_wallet"];n.each(o,function(e){t.exports[i(e)]=function(t){return u.resolve(t).then(r(6)("./"+e))}})},function(t,e,r){function n(){var t=u.randomBytes(10);return o.encode(t).toString().replace(/=/g,"")}function i(t){return"otpauth://totp/Stellar:username/stellar-client?secret="+t+"&issuer=Stellar+Development+Foundation"}var u=r(17),o=r(20);t.exports={generateRandomTotpKey:n,generateTotpUri:i}},function(t,e,r){function n(t){return r(i(t))}function i(t){return u[t]||function(){throw new Error("Cannot find module '"+t+"'.")}()}var u={"./create_wallet":10,"./create_wallet.js":10,"./delete_wallet":11,"./delete_wallet.js":11,"./index":4,"./index.js":4,"./login":12,"./login.js":12,"./setup_totp":13,"./setup_totp.js":13};n.keys=function(){return Object.keys(u)},n.resolve=i,t.exports=n,n.id=6},function(t,e,r){(function(e){"use strict";function n(t){return new e(t).toString("base64")}function i(t){return new e(t,"base64").toString()}function u(t,e){return function(r){var n=p.util.decodeUTF8(JSON.stringify(r._data)),i=p.sign.detached(n,e);i=p.util.encodeBase64(i),r.set("Authorization",'STELLAR-WALLET-V2 wallet-id="'+t+'", signature="'+i+'"')}}function o(t){return function(e){var r=f.createHash(t);return r.update(e).digest("hex")}}function s(t){return function(e){var r=new d.misc.hmac(e,d.hash.sha256);return r.encrypt(t)}}function a(t,e){var r="aes",i="gcm",u=new d.cipher[r](e),o=d.random.randomWords(3),s=d.mode[i].encrypt(u,d.codec.utf8String.toBits(t),o);return t=JSON.stringify({IV:d.codec.base64.fromBits(o),cipherText:d.codec.base64.fromBits(s),cipherName:r,modeName:i}),n(t)}function c(t,e){var r,n,u,o;try{var s=JSON.parse(i(t));n=d.codec.base64.toBits(s.IV),r=d.codec.base64.toBits(s.cipherText),u=s.cipherName,o=s.modeName}catch(a){new h.DataCorrupt}var c=new d.cipher[u](e),l=d.mode[o].decrypt(c,r,n);return d.codec.utf8String.fromBits(l)}function l(e,r,n,i){var u=t.exports.sha256(e+r);return d.misc.scrypt(n,u,i.n,i.r,i.p,i.bits)}var f=r(21),h=r(2),p=r(17),d=r(8);t.exports={calculateMasterKey:l,decryptData:c,deriveWalletId:s("CONST_W"),deriveWalletKey:s("CONST_KW"),encryptData:a,sha1:o("sha1"),sha256:o("sha256"),signRequest:u}}).call(e,r(22).Buffer)},function(t,e,r){var n=r(24);r(23).extendSjcl(n),t.exports=n},function(t,e,r){var n;(function(t,i){(function(){function u(t,e,r){for(var n=(r||0)-1,i=t?t.length:0;++n-1?0:-1:t?0:-1}function s(t){var e=this.cache,r=typeof t;if("boolean"==r||null==t)e[t]=!0;else{"number"!=r&&"string"!=r&&(r="object");var n="number"==r?t:F+t,i=e[r]||(e[r]={});"object"==r?(i[n]||(i[n]=[])).push(t):i[n]=!0}}function a(t){return t.charCodeAt(0)}function c(t,e){for(var r=t.criteria,n=e.criteria,i=-1,u=r.length;++is||"undefined"==typeof o)return 1;if(s>o||"undefined"==typeof s)return-1}}return t.index-e.index}function l(t){var e=-1,r=t.length,n=t[0],i=t[r/2|0],u=t[r-1];if(n&&"object"==typeof n&&i&&"object"==typeof i&&u&&"object"==typeof u)return!1;var o=p();o["false"]=o["null"]=o["true"]=o.undefined=!1;var a=p();for(a.array=t,a.cache=o,a.push=s;++ei?0:i);++n=C&&n===u,a=[];if(s){var c=l(e);c?(n=o,e=c):s=!1}for(;++r-1:void 0});return i.pop(),u.pop(),m&&(v(i),v(u)),o}function se(t,e,r,n,i){(fi(e)?nr:Ci)(e,function(e,u){var o,s,a=e,c=t[u];if(e&&((s=fi(e))||Bi(e))){for(var l=n.length;l--;)if(o=n[l]==e){c=i[l];break}if(!o){var f;r&&(a=r(c,e),(f="undefined"!=typeof a)&&(c=a)),f||(c=s?fi(c)?c:[]:Bi(c)?c:{}),n.push(e),i.push(c),f||se(c,e,r,n,i)}}else r&&(a=r(c,e),"undefined"==typeof a&&(a=e)),"undefined"!=typeof a&&(c=a);t[u]=c})}function ae(t,e){return t+Nn(ui()*(e-t+1))}function le(t,e,r){var n=-1,i=ve(),s=t?t.length:0,a=[],c=!e&&s>=C&&i===u,f=r||c?h():a;if(c){var p=l(f);i=o,f=p}for(;++n3&&"function"==typeof e[r-2])var n=b(e[--r-1],e[r--],2);else r>2&&"function"==typeof e[r-1]&&(n=e[--r]);for(var i=g(arguments,1,r),u=-1,o=h(),s=h();++ur?ri(0,u+r):r)||0,fi(t)?o=i(t,e,r)>-1:"number"==typeof u?o=(He(t)?t.indexOf(e,r):i(t,e,r))>-1:wi(t,function(t){return++n>=r?!(o=t===e):void 0}),o}function Ze(t,r,n){var i=!0;if(r=e.createCallback(r,n,3),fi(t))for(var u=-1,o=t.length;++uu&&(u=c)}else r=null==r&&He(t)?a:e.createCallback(r,n,3),wi(t,function(t,e,n){var o=r(t,e,n);o>i&&(i=o,u=t)});return u}function ar(t,r,n){var i=1/0,u=i;if("function"!=typeof r&&n&&n[r]===t&&(r=null),null==r&&fi(t))for(var o=-1,s=t.length;++oc&&(u=c)}else r=null==r&&He(t)?a:e.createCallback(r,n,3),wi(t,function(t,e,n){var o=r(t,e,n);i>o&&(i=o,u=t)});return u}function cr(t,r,n,i){var u=arguments.length<3;if(r=e.createCallback(r,i,4),fi(t)){var o=-1,s=t.length;for(u&&(n=t[++o]);++or?ri(0,n+r):r||0}else if(r){var i=Rr(t,e);return t[i]===e?i:-1}return u(t,e,r)}function Cr(t,r,n){var i=0,u=t?t.length:0;if("number"!=typeof r&&null!=r){var o=u;for(r=e.createCallback(r,n,3);o--&&r(t[o],o,t);)i++}else i=null==r||n?1:r||i;return g(t,0,ni(ri(0,u-i),u))}function Br(){for(var t=[],e=-1,r=arguments.length,n=h(),i=ve(),s=i===u,a=h();++e=C&&l(e?t[e]:a)))}var f=t[0],p=-1,d=f?f.length:0,g=[];t:for(;++pr?ri(0,n+r):ni(r,n-1))+1);n--;)if(t[n]===e)return n;return-1}function xr(t){for(var e=arguments,r=0,n=e.length,i=t?t.length:0;++ru;){var s=u+o>>>1;n(t[s])1?arguments:arguments[0],e=-1,r=t?sr(ji(t,"length")):0,n=wn(0>r?0:r);++e2?he(t,17,g(arguments,2),null,e):he(t,1,null,null,e)}function Hr(t){for(var e=arguments.length>1?ie(arguments,!0,!1,1):De(t),r=-1,n=e.length;++r2?he(e,19,g(arguments,2),null,t):he(e,3,null,null,t)}function Kr(){for(var t=arguments,e=t.length;e--;)if(!Oe(t[e]))throw new Tn;return function(){for(var e=arguments,r=t.length;r--;)e=[t[r].apply(this,e)];return e[0]}}function qr(t,e){return e="number"==typeof e?e:+e||t.length,he(t,4,null,null,null,e)}function Yr(t,e,r){var n,i,u,o,s,a,c,l=0,f=!1,h=!0;if(!Oe(t))throw new Tn;if(e=ri(0,e)||0,r===!0){var p=!0;h=!1}else Ue(r)&&(p=r.leading,f="maxWait"in r&&(ri(e,r.maxWait)||0),h="trailing"in r?r.trailing:h);var d=function(){var r=e-(Pi()-o);if(0>=r){i&&zn(i);var f=c;i=a=c=m,f&&(l=Pi(),u=t.apply(s,n),a||i||(n=s=null))}else a=$n(d,r)},v=function(){a&&zn(a),i=a=c=m,(h||f!==e)&&(l=Pi(),u=t.apply(s,n),a||i||(n=s=null))};return function(){if(n=arguments,o=Pi(),s=this,c=h&&(a||!p),f===!1)var r=p&&!a;else{i||p||(l=o);var y=f-(o-l),g=0>=y;g?(i&&(i=zn(i)),l=o,u=t.apply(s,n)):i||(i=$n(v,y))}return g&&a?a=zn(a):a||e===f||(a=$n(d,e)),r&&(g=!0,u=t.apply(s,n)),!g||a||i||(n=s=null),u}}function $r(t){if(!Oe(t))throw new Tn;var e=g(arguments,1);return $n(function(){t.apply(m,e)},1)}function Wr(t,e){if(!Oe(t))throw new Tn;var r=g(arguments,2);return $n(function(){t.apply(m,r)},e)}function Gr(t,e){if(!Oe(t))throw new Tn;var r=function(){var n=r.cache,i=e?e.apply(this,arguments):F+arguments[0];return Kn.call(n,i)?n[i]:n[i]=t.apply(this,arguments)};return r.cache={},r}function Jr(t){var e,r;if(!Oe(t))throw new Tn;return function(){return e?r:(e=!0,r=t.apply(this,arguments),t=null,r)}}function Xr(t){return he(t,16,g(arguments,1))}function Qr(t){return he(t,32,null,g(arguments,1))}function Zr(t,e,r){var n=!0,i=!0;if(!Oe(t))throw new Tn;return r===!1?n=!1:Ue(r)&&(n="leading"in r?r.leading:n,i="trailing"in r?r.trailing:i),te.leading=n,te.maxWait=e,te.trailing=i,Yr(t,e,te)}function tn(t,e){return he(e,16,[t])}function en(t){return function(){return t}}function rn(t,e,r){var n=typeof t;if(null==t||"function"==n)return b(t,e,r);if("object"!=n)return cn(t);var i=pi(t),u=i[0],o=t[u];return 1!=i.length||o!==o||Ue(o)?function(e){for(var r=i.length,n=!1;r--&&(n=oe(e[i[r]],t[i[r]],null,!0)););return n}:function(t){var e=t[u];return o===e&&(0!==o||1/o==1/e)}}function nn(t){return null==t?"":jn(t).replace(bi,de)}function un(t){return t}function on(t,n,i){var u=!0,o=n&&De(n);n&&(i||o.length)||(null==i&&(i=n),s=r,n=t,t=e,o=De(n)),i===!1?u=!1:Ue(i)&&"chain"in i&&(u=i.chain);var s=t,a=Oe(s);nr(o,function(e){var r=t[e]=n[e];a&&(s.prototype[e]=function(){var e=this.__chain__,n=this.__wrapped__,i=[n];qn.apply(i,arguments);var o=r.apply(t,i);if(u||e){if(n===o&&Ue(o))return this;o=new s(o),o.__chain__=e}return o})})}function sn(){return t._=On,this}function an(){}function cn(t){return function(e){return e[t]}}function ln(t,e,r){var n=null==t,i=null==e;if(null==r&&("boolean"==typeof t&&i?(r=t,t=1):i||"boolean"!=typeof e||(r=e,i=!0)),n&&i&&(e=1),t=+t||0,i?(e=t,t=0):e=+e||0,r||t%1||e%1){var u=ui();return ni(t+u*(e-t+parseFloat("1e-"+((u+"").length-1))),e)}return ae(t,e)}function fn(t,e){if(t){var r=t[e];return Oe(r)?t[e]():r}}function hn(t,r,n){var i=e.templateSettings;t=jn(t||""),n=Ei({},n,i);var u,o=Ei({},n.imports,i.imports),s=pi(o),a=Je(o),c=0,l=n.interpolate||U,h="__p += '",p=xn((n.escape||U).source+"|"+l.source+"|"+(l===I?P:U).source+"|"+(n.evaluate||U).source+"|$","g");t.replace(p,function(e,r,n,i,o,s){return n||(n=i),h+=t.slice(c,s).replace(M,f),r&&(h+="' +\n__e("+r+") +\n'"),o&&(u=!0,h+="';\n"+o+";\n__p += '"),n&&(h+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),c=s+e.length,e}),h+="';\n";var d=n.variable,v=d;v||(d="obj",h="with ("+d+") {\n"+h+"\n}\n"),h=(u?h.replace(x,""):h).replace(j,"$1").replace(T,"$1;"),h="function("+d+") {\n"+(v?"":d+" || ("+d+" = {});\n")+"var __t, __p = '', __e = _.escape"+(u?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var y="\n/*\n//# sourceURL="+(n.sourceURL||"/lodash/template/source["+H++ +"]")+"\n*/";try{var g=Cn(s,"return "+h+y).apply(m,a)}catch(_){throw _.source=h,_}return r?g(r):(g.source=h,g)}function pn(t,e,r){t=(t=+t)>-1?t:0;var n=-1,i=wn(t);for(e=b(e,r,1);++n/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:I,variable:"",imports:{_:e}};var ci=function(t){var e="var index, iterable = "+t.firstArg+", result = "+t.init+";\nif (!iterable) return result;\n"+t.top+";";t.array?(e+="\nvar length = iterable.length; index = -1;\nif ("+t.array+") { ",ai.unindexedChars&&(e+="\n if (isString(iterable)) {\n iterable = iterable.split('')\n } "),e+="\n while (++index < length) {\n "+t.loop+";\n }\n}\nelse { "):ai.nonEnumArgs&&(e+="\n var length = iterable.length; index = -1;\n if (length && isArguments(iterable)) {\n while (++index < length) {\n index += '';\n "+t.loop+";\n }\n } else { "),ai.enumPrototypes&&(e+="\n var skipProto = typeof iterable == 'function';\n "),ai.enumErrorProps&&(e+="\n var skipErrorProps = iterable === errorProto || iterable instanceof Error;\n ");var r=[];if(ai.enumPrototypes&&r.push('!(skipProto && index == "prototype")'),ai.enumErrorProps&&r.push('!(skipErrorProps && (index == "message" || index == "name"))'),t.useHas&&t.keys)e+="\n var ownIndex = -1,\n ownProps = objectTypes[typeof iterable] && keys(iterable),\n length = ownProps ? ownProps.length : 0;\n\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n",r.length&&(e+=" if ("+r.join(" && ")+") {\n "),e+=t.loop+"; ",r.length&&(e+="\n }"),e+="\n } ";else if(e+="\n for (index in iterable) {\n",t.useHas&&r.push("hasOwnProperty.call(iterable, index)"),r.length&&(e+=" if ("+r.join(" && ")+") {\n "),e+=t.loop+"; ",r.length&&(e+="\n }"),e+="\n } ",ai.nonEnumShadows){for(e+="\n\n if (iterable !== objectProto) {\n var ctor = iterable.constructor,\n isProto = iterable === (ctor && ctor.prototype),\n className = iterable === stringProto ? stringClass : iterable === errorProto ? errorClass : toString.call(iterable),\n nonEnum = nonEnumProps[className];\n ",k=0;7>k;k++)e+="\n index = '"+t.shadowedProps[k]+"';\n if ((!(isProto && nonEnum[index]) && hasOwnProperty.call(iterable, index))",t.useHas||(e+=" || (!nonEnum[index] && iterable[index] !== objectProto[index])"),e+=") {\n "+t.loop+";\n } ";e+="\n } "}return(t.array||ai.nonEnumArgs)&&(e+="\n}"),e+=t.bottom+";\nreturn result"};Xn||(s=function(){function e(){}return function(r){if(Ue(r)){e.prototype=r;var n=new e;e.prototype=null}return n||t.Object()}}());var li=Jn?function(t,e){ee.value=e,Jn(t,"__bindData__",ee)}:an;ai.argsClass||(me=function(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Kn.call(t,"callee")&&!Yn.call(t,"callee")||!1});var fi=Qn||function(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Un.call(t)==K||!1},hi=pe({args:"object",init:"[]",top:"if (!(objectTypes[typeof object])) return result",loop:"result.push(index)"}),pi=ei?function(t){return Ue(t)?ai.enumPrototypes&&"function"==typeof t||ai.nonEnumArgs&&t.length&&me(t)?hi(t):ei(t):[]}:hi,di={args:"collection, callback, thisArg",top:"callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3)",array:"typeof length == 'number'",keys:pi,loop:"if (callback(iterable[index], index, collection) === false) return result"},vi={args:"object, source, guard",top:"var args = arguments,\n argsIndex = 0,\n argsLength = typeof guard == 'number' ? 2 : args.length;\nwhile (++argsIndex < argsLength) {\n iterable = args[argsIndex];\n if (iterable && objectTypes[typeof iterable]) {",keys:pi,loop:"if (typeof result[index] == 'undefined') result[index] = iterable[index]",bottom:" }\n}"},yi={top:"if (!objectTypes[typeof iterable]) return result;\n"+di.top,array:!1},gi={"&":"&","<":"<",">":">",'"':""","'":"'"},_i=xe(gi),mi=xn("("+pi(_i).join("|")+")","g"),bi=xn("["+pi(gi).join("")+"]","g"),wi=pe(di),Ai=pe(vi,{top:vi.top.replace(";",";\nif (argsLength > 3 && typeof args[argsLength - 2] == 'function') {\n var callback = baseCreateCallback(args[--argsLength - 1], args[argsLength--], 2);\n} else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') {\n callback = args[--argsLength];\n}"),loop:"result[index] = callback ? callback(result[index], iterable[index]) : iterable[index]"}),Ei=pe(vi),Fi=pe(di,yi,{useHas:!1}),Ci=pe(di,yi); -Oe(/x/)&&(Oe=function(t){return"function"==typeof t&&Un.call(t)==W});var Bi=Vn?function(t){if(!t||Un.call(t)!=J||!ai.argsClass&&me(t))return!1;var e=t.valueOf,r=ye(e)&&(r=Vn(e))&&Vn(r);return r?t==r||Vn(t)==r:ge(t)}:ge,Di=fe(function(t,e,r){Kn.call(t,r)?t[r]++:t[r]=1}),ki=fe(function(t,e,r){(Kn.call(t,r)?t[r]:t[r]=[]).push(e)}),xi=fe(function(t,e,r){t[r]=e}),ji=or,Ti=tr,Pi=ye(Pi=En.now)&&Pi||function(){return(new En).getTime()},Ri=8==ii(D+"08")?ii:function(t,e){return ii(He(t)?t.replace(O,""):t,e||0)};return e.after=zr,e.assign=Ai,e.at=Xe,e.bind=Nr,e.bindAll=Hr,e.bindKey=Vr,e.chain=yn,e.compact=_r,e.compose=Kr,e.constant=en,e.countBy=Di,e.create=Ae,e.createCallback=rn,e.curry=qr,e.debounce=Yr,e.defaults=Ei,e.defer=$r,e.delay=Wr,e.difference=mr,e.filter=tr,e.flatten=Er,e.forEach=nr,e.forEachRight=ir,e.forIn=Fi,e.forInRight=Ce,e.forOwn=Ci,e.forOwnRight=Be,e.functions=De,e.groupBy=ki,e.indexBy=xi,e.initial=Cr,e.intersection=Br,e.invert=xe,e.invoke=ur,e.keys=pi,e.map=or,e.mapValues=Ke,e.max=sr,e.memoize=Gr,e.merge=qe,e.min=ar,e.omit=Ye,e.once=Jr,e.pairs=$e,e.partial=Xr,e.partialRight=Qr,e.pick=We,e.pluck=ji,e.property=cn,e.pull=xr,e.range=jr,e.reject=fr,e.remove=Tr,e.rest=Pr,e.shuffle=pr,e.sortBy=yr,e.tap=gn,e.throttle=Zr,e.times=pn,e.toArray=gr,e.transform=Ge,e.union=Sr,e.uniq=Ir,e.values=Je,e.where=Ti,e.without=Or,e.wrap=tn,e.xor=Ur,e.zip=Lr,e.zipObject=Mr,e.collect=or,e.drop=Pr,e.each=nr,e.eachRight=ir,e.extend=Ai,e.methods=De,e.object=Mr,e.select=tr,e.tail=Pr,e.unique=Ir,e.unzip=Lr,on(e),e.clone=be,e.cloneDeep=we,e.contains=Qe,e.escape=nn,e.every=Ze,e.find=er,e.findIndex=br,e.findKey=Ee,e.findLast=rr,e.findLastIndex=wr,e.findLastKey=Fe,e.has=ke,e.identity=un,e.indexOf=Fr,e.isArguments=me,e.isArray=fi,e.isBoolean=je,e.isDate=Te,e.isElement=Pe,e.isEmpty=Re,e.isEqual=Se,e.isFinite=Ie,e.isFunction=Oe,e.isNaN=Le,e.isNull=Me,e.isNumber=ze,e.isObject=Ue,e.isPlainObject=Bi,e.isRegExp=Ne,e.isString=He,e.isUndefined=Ve,e.lastIndexOf=kr,e.mixin=on,e.noConflict=sn,e.noop=an,e.now=Pi,e.parseInt=Ri,e.random=ln,e.reduce=cr,e.reduceRight=lr,e.result=fn,e.runInContext=_,e.size=dr,e.some=vr,e.sortedIndex=Rr,e.template=hn,e.unescape=dn,e.uniqueId=vn,e.all=Ze,e.any=vr,e.detect=er,e.findWhere=er,e.foldl=cr,e.foldr=lr,e.include=Qe,e.inject=cr,on(function(){var t={};return Ci(e,function(r,n){e.prototype[n]||(t[n]=r)}),t}(),!1),e.first=Ar,e.last=Dr,e.sample=hr,e.take=Ar,e.head=Ar,Ci(e,function(t,n){var i="sample"!==n;e.prototype[n]||(e.prototype[n]=function(e,n){var u=this.__chain__,o=t(this.__wrapped__,e,n);return u||null!=e&&(!n||i&&"function"==typeof e)?new r(o,u):o})}),e.VERSION="2.4.1",e.prototype.chain=_n,e.prototype.toString=mn,e.prototype.value=bn,e.prototype.valueOf=bn,wi(["join","pop","shift"],function(t){var n=Pn[t];e.prototype[t]=function(){var t=this.__chain__,e=n.apply(this.__wrapped__,arguments);return t?new r(e,t):e}}),wi(["push","reverse","sort","unshift"],function(t){var r=Pn[t];e.prototype[t]=function(){return r.apply(this.__wrapped__,arguments),this}}),wi(["concat","slice","splice"],function(t){var n=Pn[t];e.prototype[t]=function(){return new r(n.apply(this.__wrapped__,arguments),this.__chain__)}}),ai.spliceObjects||wi(["pop","shift","splice"],function(t){var n=Pn[t],i="splice"==t;e.prototype[t]=function(){var t=this.__chain__,e=this.__wrapped__,u=n.apply(e,arguments);return 0===e.length&&delete e[0],t||i?new r(u,t):u}}),e}var m,b=[],w=[],A=0,E={},F=+new Date+"",C=75,B=40,D=" \f \n\r\u2028\u2029 ᠎              ",x=/\b__p \+= '';/g,j=/\b(__p \+=) '' \+/g,T=/(__e\(.*?\)|\b__t\)) \+\n'';/g,P=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,R=/\w*$/,S=/^\s*function[ \n\r\t]+\w/,I=/<%=([\s\S]+?)%>/g,O=RegExp("^["+D+"]*0+(?=.$)"),U=/($^)/,L=/\bthis\b/,M=/['\n\r\t\u2028\u2029\\]/g,z=["Array","Boolean","Date","Error","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setTimeout"],N=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],H=0,V="[object Arguments]",K="[object Array]",q="[object Boolean]",Y="[object Date]",$="[object Error]",W="[object Function]",G="[object Number]",J="[object Object]",X="[object RegExp]",Q="[object String]",Z={};Z[W]=!1,Z[V]=Z[K]=Z[q]=Z[Y]=Z[G]=Z[J]=Z[X]=Z[Q]=!0;var te={leading:!1,maxWait:0,trailing:!1},ee={configurable:!1,enumerable:!1,value:null,writable:!1},re={args:"",array:null,bottom:"",firstArg:"",init:"",keys:null,loop:"",shadowedProps:null,support:null,top:"",useHas:!1},ne={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},ie={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},ue=ne[typeof window]&&window||this,oe=ne[typeof e]&&e&&!e.nodeType&&e,se=ne[typeof t]&&t&&!t.nodeType&&t,ae=(se&&se.exports===oe&&oe,ne[typeof i]&&i);!ae||ae.global!==ae&&ae.window!==ae||(ue=ae);var ce=_();ue._=ce,n=function(){return ce}.call(e,r,e,t),!(n!==m&&(t.exports=n))}).call(this)}).call(e,r(26)(t),function(){return this}())},function(t,e,r){"use strict";function n(t){return p.resolve(t).then(y.present("server")).then(y.present("username")).then(y.present("password")).then(y.present("privateKey")).then(y.present("mainData")).then(y.present("keychainData"))}function i(t){if(c.isObject(t.kdfParams))return p.resolve(t);var e=p.pending();return d.get(t.server+"/kdf_params").end(function(r,n){r?e.reject(new f.ConnectionError):(t.kdfParams=n.body,e.resolve(t))}),e.promise}function u(t){return g=t.kdfParams,t.kdfParams=JSON.stringify(t.kdfParams),c.every(c.pick(t,["mainData","keychainData"]),c.isString)?p.resolve(t):p.reject(new f.InvalidField("mainData and keychainData must be strings."))}function o(t){var e=h.util.decodeBase64(t.privateKey),r=h.sign.keyPair.fromSecretKey(e);return t.publicKey=h.util.encodeBase64(r.publicKey),t.rawPrivateKey=e,p.resolve(t)}function s(t){var e=h.util.encodeBase64(h.randomBytes(16)),r=l.calculateMasterKey(e,t.username,t.password,g),n=l.deriveWalletId(r),i=l.deriveWalletKey(r);return t.salt=e,t.rawWalletId=n,t.walletId=v.codec.base64.fromBits(n),t.rawMainData=t.mainData,t.mainData=l.encryptData(t.mainData,i),t.mainDataHash=l.sha1(t.mainData),t.rawKeychainData=t.keychainData,t.keychainData=l.encryptData(t.keychainData,i),t.keychainDataHash=l.sha1(t.keychainData),p.resolve(t)}function a(t){var e=p.pending();return d.post(t.server+"/wallets/create").type("json").send(c.pick(t,["username","walletId","salt","publicKey","mainData","mainDataHash","keychainData","keychainDataHash","kdfParams"])).end(function(r,n){if(r)e.reject(new f.ConnectionError);else if("success"!==n.body.status)e.reject(new f.UnknownError(JSON.stringify(n.body)));else{var i=c.pick(t,["server","username","rawWalletId","rawMainData","rawKeychainData","rawPrivateKey"]);i.lockVersion=0,e.resolve(i)}}),e.promise}var c=r(9),l=r(7),f=r(2),h=r(17),p=r(14),d=r(64),v=r(8),y=r(18);t.exports=function(t){return p.resolve(t).then(n).then(i).then(u).then(o).then(s).then(a)};var g},function(t,e,r){"use strict";var n=r(2),i=r(14),u=r(64),o=r(7).signRequest;t.exports=function(t){var e=i.pending();return u.post(config.get("server")+"/wallets/delete").send({username:t.username,walletId:t.walletId,n:t.n}).use(o).end(function(t,r){t?e.reject(new n.ConnectionError):"fail"===r.body.status?"not_found"==r.body.code?e.reject(new n.WalletNotFound):e.reject(new n.UnknownError):e.resolve(r.body)}),e.promise}},function(t,e,r){"use strict";function n(t){return d.resolve(t).then(g.present("server")).then(g.present("username")).then(g.present("password")).then(g.present("privateKey"))}function i(t){return t.rawPrivateKey=p.util.decodeBase64(t.privateKey),d.resolve(t)}function u(t){var e=d.pending();return v.post(t.server+"/wallets/show_login_params").type("json").send({username:t.username}).end(function(r,n){r?e.reject(new h.ConnectionError):"fail"===n.body.status?"not_found"==n.body.code?e.reject(new h.WalletNotFound):"forbidden"==n.body.code?e.reject(new h.Forbidden):e.reject(new h.UnknownError(JSON.stringify(n.body))):(t.salt=n.body.salt,t.kdfParams=JSON.parse(n.body.kdfParams),t.totpRequired=n.body.totpRequired,e.resolve(t))}),e.promise}function o(t){return t.totpRequired&&l.isEmpty(t.totpCode)?d.reject(new h.TotpCodeRequired):d.resolve(t)}function s(t){var e=f.calculateMasterKey(t.salt,t.username,t.password,t.kdfParams),r=f.deriveWalletId(e);return t.rawWalletId=r,t.walletId=y.codec.base64.fromBits(r),t.rawWalletKey=f.deriveWalletKey(e),d.resolve(t)}function a(t){var e=d.pending(),r={username:t.username,walletId:t.walletId};return t.totpRequired&&(r.totpCode=t.totpCode),v.post(t.server+"/wallets/show").type("json").send(r).end(function(r,n){r?e.reject(new h.ConnectionError):"fail"===n.body.status?e.reject(new h.UnknownError):(t=l.extend(t,l.pick(n.body,["lockVersion","mainData","keychainData"])),e.resolve(t))}),e.promise}function c(t){var e=l.pick(t,["server","username","rawWalletId","rawMainData","rawKeychainData","lockVersion","rawPrivateKey"]);return e.rawMainData=f.decryptData(t.mainData,t.rawWalletKey),e.rawKeychainData=f.decryptData(t.keychainData,t.rawWalletKey),d.resolve(e)}var l=r(9),f=r(7),h=r(2),p=r(17),d=r(14),v=r(64),y=r(8),g=r(18);t.exports=function(t){return d.resolve(t).then(n).then(i).then(u).then(o).then(s).then(a).then(c)}},function(t,e,r){"use strict";function n(t){return l.resolve(t).then(h.present("server")).then(h.present("username")).then(h.present("walletId")).then(h.present("rawPrivateKey")).then(h.present("totpKey")).then(h.present("totpCode")).then(h.number("lockVersion"))}function i(t){return t.totpKey=s.decode(t.totpKey),t.totpKey=t.totpKey.toString("base64"),l.resolve(t)}function u(t){var e=l.pending();return f.post(t.server+"/totp/enable").type("json").send(o.pick(t,["walletId","lockVersion","totpKey","totpCode"])).use(a.signRequest(t.walletId,t.rawPrivateKey)).end(function(t,r){t?e.reject(new c.ConnectionError):"success"===r.body.status?e.resolve():"invalid_totp_code"===r.body.code?e.reject(new c.InvalidTotpCode):e.reject(new c.UnknownError(JSON.stringify(r.body)))}),e.promise}var o=r(9),s=r(20),a=r(7),c=r(2),l=r(14),f=r(64),h=r(18);t.exports=function(t){return l.resolve(t).then(n).then(i).then(u)}},function(t,e,r){"use strict";var n=r(19)();t.exports=n},function(t,e,r){(function(t,n){function i(t,r){var n={seen:[],stylize:o};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),v(r)?n.showHidden=r:r&&e._extend(n,r),w(n.showHidden)&&(n.showHidden=!1),w(n.depth)&&(n.depth=2),w(n.colors)&&(n.colors=!1),w(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),a(n,t,n.depth)}function u(t,e){var r=i.styles[e];return r?"["+i.colors[r][0]+"m"+t+"["+i.colors[r][1]+"m":t}function o(t){return t}function s(t){var e={};return t.forEach(function(t){e[t]=!0}),e}function a(t,r,n){if(t.customInspect&&r&&B(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return m(i)||(i=a(t,i,n)),i}var u=c(t,r);if(u)return u;var o=Object.keys(r),v=s(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(r)),C(r)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return l(r);if(0===o.length){if(B(r)){var y=r.name?": "+r.name:"";return t.stylize("[Function"+y+"]","special")}if(A(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(F(r))return t.stylize(Date.prototype.toString.call(r),"date");if(C(r))return l(r)}var g="",_=!1,b=["{","}"];if(d(r)&&(_=!0,b=["[","]"]),B(r)){var w=r.name?": "+r.name:"";g=" [Function"+w+"]"}if(A(r)&&(g=" "+RegExp.prototype.toString.call(r)),F(r)&&(g=" "+Date.prototype.toUTCString.call(r)),C(r)&&(g=" "+l(r)),0===o.length&&(!_||0==r.length))return b[0]+g+b[1];if(0>n)return A(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special");t.seen.push(r);var E;return E=_?f(t,r,n,v,o):o.map(function(e){return h(t,r,n,v,e,_)}),t.seen.pop(),p(E,g,b)}function c(t,e){if(w(e))return t.stylize("undefined","undefined");if(m(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return _(e)?t.stylize(""+e,"number"):v(e)?t.stylize(""+e,"boolean"):y(e)?t.stylize("null","null"):void 0}function l(t){return"["+Error.prototype.toString.call(t)+"]"}function f(t,e,r,n,i){for(var u=[],o=0,s=e.length;s>o;++o)T(e,String(o))?u.push(h(t,e,r,n,String(o),!0)):u.push("");return i.forEach(function(i){i.match(/^\d+$/)||u.push(h(t,e,r,n,i,!0))}),u}function h(t,e,r,n,i,u){var o,s,c;if(c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]},c.get?s=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(s=t.stylize("[Setter]","special")),T(n,i)||(o="["+i+"]"),s||(t.seen.indexOf(c.value)<0?(s=y(r)?a(t,c.value,null):a(t,c.value,r-1),s.indexOf("\n")>-1&&(s=u?s.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+s.split("\n").map(function(t){return" "+t}).join("\n"))):s=t.stylize("[Circular]","special")),w(o)){if(u&&i.match(/^\d+$/))return s;o=JSON.stringify(""+i),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+s}function p(t,e,r){var n=0,i=t.reduce(function(t,e){return n++,e.indexOf("\n")>=0&&n++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}function d(t){return Array.isArray(t)}function v(t){return"boolean"==typeof t}function y(t){return null===t}function g(t){return null==t}function _(t){return"number"==typeof t}function m(t){return"string"==typeof t}function b(t){return"symbol"==typeof t}function w(t){return void 0===t}function A(t){return E(t)&&"[object RegExp]"===k(t)}function E(t){return"object"==typeof t&&null!==t}function F(t){return E(t)&&"[object Date]"===k(t)}function C(t){return E(t)&&("[object Error]"===k(t)||t instanceof Error)}function B(t){return"function"==typeof t}function D(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function k(t){return Object.prototype.toString.call(t)}function x(t){return 10>t?"0"+t.toString(10):t.toString(10)}function j(){var t=new Date,e=[x(t.getHours()),x(t.getMinutes()),x(t.getSeconds())].join(":");return[t.getDate(),I[t.getMonth()],e].join(" ")}function T(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var P=/%[sdj%]/g;e.format=function(t){if(!m(t)){for(var e=[],r=0;r=u)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return t}}),s=n[r];u>r;s=n[++r])o+=y(s)||!E(s)?" "+s:" "+i(s);return o},e.deprecate=function(r,i){function u(){if(!o){if(n.throwDeprecation)throw new Error(i);n.traceDeprecation?console.trace(i):console.error(i),o=!0}return r.apply(this,arguments)}if(w(t.process))return function(){return e.deprecate(r,i).apply(this,arguments)};if(n.noDeprecation===!0)return r;var o=!1;return u};var R,S={};e.debuglog=function(t){if(w(R)&&(R=n.env.NODE_DEBUG||""),t=t.toUpperCase(),!S[t])if(new RegExp("\\b"+t+"\\b","i").test(R)){var r=n.pid;S[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,r,n)}}else S[t]=function(){};return S[t]},e.inspect=i,i.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]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=d,e.isBoolean=v,e.isNull=y,e.isNullOrUndefined=g,e.isNumber=_,e.isString=m,e.isSymbol=b,e.isUndefined=w,e.isRegExp=A,e.isObject=E,e.isDate=F,e.isError=C,e.isFunction=B,e.isPrimitive=D,e.isBuffer=r(25);var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];e.log=function(){console.log("%s - %s",j(),e.format.apply(e,arguments))},e.inherits=r(63),e._extend=function(t,e){if(!e||!E(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(e,function(){return this}(),r(57))},function(t,e,r){var n=r(65);t.exports=function(t){return n(t).replace(/(\d) (?=\d)/g,"$1_").replace(/ (\w)/g,function(t,e){return e.toUpperCase()})}},function(t,e,r){(function(e){!function(t){"use strict";function n(t,e){return t<>>32-e}function i(t,e){var r=255&t[e+3];return r=r<<8|255&t[e+2],r=r<<8|255&t[e+1],r<<8|255&t[e+0]}function u(t,e){var r=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3],n=t[e+4]<<24|t[e+5]<<16|t[e+6]<<8|t[e+7];return new de(r,n)}function o(t,e,r){var n;for(n=0;4>n;n++)t[e+n]=255&r,r>>>=8}function s(t,e,r){t[e]=r.hi>>24&255,t[e+1]=r.hi>>16&255,t[e+2]=r.hi>>8&255,t[e+3]=255&r.hi,t[e+4]=r.lo>>24&255,t[e+5]=r.lo>>16&255,t[e+6]=r.lo>>8&255,t[e+7]=255&r.lo}function a(t,e,r,n,i){var u,o=0;for(u=0;i>u;u++)o|=t[e+u]^r[n+u];return(1&o-1>>>8)-1}function c(t,e,r,n){return a(t,e,r,n,16)}function l(t,e,r,n){return a(t,e,r,n,32)}function f(t,e,r,u,s){var a,c,l,f=new Uint32Array(16),h=new Uint32Array(16),p=new Uint32Array(16),d=new Uint32Array(4);for(a=0;4>a;a++)h[5*a]=i(u,4*a),h[1+a]=i(r,4*a),h[6+a]=i(e,4*a),h[11+a]=i(r,16+4*a);for(a=0;16>a;a++)p[a]=h[a];for(a=0;20>a;a++){for(c=0;4>c;c++){for(l=0;4>l;l++)d[l]=h[(5*c+4*l)%16];for(d[1]^=n(d[0]+d[3]|0,7),d[2]^=n(d[1]+d[0]|0,9),d[3]^=n(d[2]+d[1]|0,13),d[0]^=n(d[3]+d[2]|0,18),l=0;4>l;l++)f[4*c+(c+l)%4]=d[l]}for(l=0;16>l;l++)h[l]=f[l]}if(s){for(a=0;16>a;a++)h[a]=h[a]+p[a]|0;for(a=0;4>a;a++)h[5*a]=h[5*a]-i(u,4*a)|0,h[6+a]=h[6+a]-i(e,4*a)|0;for(a=0;4>a;a++)o(t,4*a,h[5*a]),o(t,16+4*a,h[6+a])}else for(a=0;16>a;a++)o(t,4*a,h[a]+p[a]|0)}function h(t,e,r,n){return f(t,e,r,n,!1),0}function p(t,e,r,n){return f(t,e,r,n,!0),0}function d(t,e,r,n,i,u,o){var s,a,c=new Uint8Array(16),l=new Uint8Array(64);if(!i)return 0;for(a=0;16>a;a++)c[a]=0;for(a=0;8>a;a++)c[a]=u[a];for(;i>=64;){for(h(l,c,o,De),a=0;64>a;a++)t[e+a]=(r?r[n+a]:0)^l[a];for(s=1,a=8;16>a;a++)s=s+(255&c[a])|0,c[a]=255&s,s>>>=8;i-=64,e+=64,r&&(n+=64)}if(i>0)for(h(l,c,o,De),a=0;i>a;a++)t[e+a]=(r?r[n+a]:0)^l[a];return 0}function v(t,e,r,n,i){return d(t,e,null,0,r,n,i)}function y(t,e,r,n,i){var u=new Uint8Array(32);return p(u,n,i,De),v(t,e,r,n.subarray(16),u)}function g(t,e,r,n,i,u,o){var s=new Uint8Array(32);return p(s,u,o,De),d(t,e,r,n,i,u.subarray(16),s)}function _(t,e){var r,n=0;for(r=0;17>r;r++)n=n+(t[r]+e[r]|0)|0,t[r]=255&n,n>>>=8}function m(t,e,r,n,i,u){var o,s,a,c,l=new Uint32Array(17),f=new Uint32Array(17),h=new Uint32Array(17),p=new Uint32Array(17),d=new Uint32Array(17);for(a=0;17>a;a++)f[a]=h[a]=0;for(a=0;16>a;a++)f[a]=u[a];for(f[3]&=15,f[4]&=252,f[7]&=15,f[8]&=252,f[11]&=15,f[12]&=252,f[15]&=15;i>0;){for(a=0;17>a;a++)p[a]=0;for(a=0;16>a&&i>a;++a)p[a]=r[n+a];for(p[a]=1,n+=a,i-=a,_(h,p),s=0;17>s;s++)for(l[s]=0,a=0;17>a;a++)l[s]=l[s]+h[a]*(s>=a?f[s-a]:320*f[s+17-a]|0)|0|0;for(s=0;17>s;s++)h[s]=l[s];for(c=0,a=0;16>a;a++)c=c+h[a]|0,h[a]=255&c,c>>>=8;for(c=c+h[16]|0,h[16]=3&c,c=5*(c>>>2)|0,a=0;16>a;a++)c=c+h[a]|0,h[a]=255&c,c>>>=8;c=c+h[16]|0,h[16]=c}for(a=0;17>a;a++)d[a]=h[a];for(_(h,ke),o=0|-(h[16]>>>7),a=0;17>a;a++)h[a]^=o&(d[a]^h[a]);for(a=0;16>a;a++)p[a]=u[a+16];for(p[16]=0,_(h,p),a=0;16>a;a++)t[e+a]=h[a];return 0}function b(t,e,r,n,i,u){var o=new Uint8Array(16);return m(o,0,r,n,i,u),c(t,e,o,0)}function w(t,e,r,n,i){var u;if(32>r)return-1;for(g(t,0,e,0,r,n,i),m(t,16,t,32,r-32,t),u=0;16>u;u++)t[u]=0;return 0}function A(t,e,r,n,i){var u,o=new Uint8Array(32);if(32>r)return-1;if(y(o,0,32,n,i),0!==b(e,16,e,32,r-32,o))return-1;for(g(t,0,e,0,r,n,i),u=0;32>u;u++)t[u]=0;return 0}function E(t,e){var r;for(r=0;16>r;r++)t[r]=0|e[r]}function F(t){var e,r;for(r=0;16>r;r++)t[r]+=65536,e=Math.floor(t[r]/65536),t[(r+1)*(15>r?1:0)]+=e-1+37*(e-1)*(15===r?1:0),t[r]-=65536*e}function C(t,e,r){for(var n,i=~(r-1),u=0;16>u;u++)n=i&(t[u]^e[u]),t[u]^=n,e[u]^=n}function B(t,e){var r,n,i,u=ve(),o=ve();for(r=0;16>r;r++)o[r]=e[r];for(F(o),F(o),F(o),n=0;2>n;n++){for(u[0]=o[0]-65517,r=1;15>r;r++)u[r]=o[r]-65535-(u[r-1]>>16&1),u[r-1]&=65535;u[15]=o[15]-32767-(u[14]>>16&1),i=u[15]>>16&1,u[14]&=65535,C(o,u,1-i)}for(r=0;16>r;r++)t[2*r]=255&o[r],t[2*r+1]=o[r]>>8}function D(t,e){var r=new Uint8Array(32),n=new Uint8Array(32);return B(r,t),B(n,e),l(r,0,n,0)}function k(t){var e=new Uint8Array(32);return B(e,t),1&e[0]}function x(t,e){var r;for(r=0;16>r;r++)t[r]=e[2*r]+(e[2*r+1]<<8);t[15]&=32767}function j(t,e,r){var n;for(n=0;16>n;n++)t[n]=e[n]+r[n]|0}function T(t,e,r){var n;for(n=0;16>n;n++)t[n]=e[n]-r[n]|0}function P(t,e,r){var n,i,u=new Float64Array(31);for(n=0;31>n;n++)u[n]=0;for(n=0;16>n;n++)for(i=0;16>i;i++)u[n+i]+=e[n]*r[i];for(n=0;15>n;n++)u[n]+=38*u[n+16];for(n=0;16>n;n++)t[n]=u[n];F(t),F(t)}function R(t,e){P(t,e,e)}function S(t,e){var r,n=ve();for(r=0;16>r;r++)n[r]=e[r];for(r=253;r>=0;r--)R(n,n),2!==r&&4!==r&&P(n,n,e);for(r=0;16>r;r++)t[r]=n[r]}function I(t,e){var r,n=ve();for(r=0;16>r;r++)n[r]=e[r];for(r=250;r>=0;r--)R(n,n),1!==r&&P(n,n,e);for(r=0;16>r;r++)t[r]=n[r]}function O(t,e,r){var n,i,u=new Uint8Array(32),o=new Float64Array(80),s=ve(),a=ve(),c=ve(),l=ve(),f=ve(),h=ve();for(i=0;31>i;i++)u[i]=e[i];for(u[31]=127&e[31]|64,u[0]&=248,x(o,r),i=0;16>i;i++)a[i]=o[i],l[i]=s[i]=c[i]=0;for(s[0]=l[0]=1,i=254;i>=0;--i)n=u[i>>>3]>>>(7&i)&1,C(s,a,n),C(c,l,n),j(f,s,c),T(s,s,c),j(c,a,l),T(a,a,l),R(l,f),R(h,s),P(s,c,s),P(c,a,f),j(f,s,c),T(s,s,c),R(a,s),T(c,l,h),P(s,c,we),j(s,s,l),P(c,c,s),P(s,l,h),P(l,a,o),R(a,f),C(s,a,n),C(c,l,n);for(i=0;16>i;i++)o[i+16]=s[i],o[i+32]=c[i],o[i+48]=a[i],o[i+64]=l[i];var p=o.subarray(32),d=o.subarray(16);return S(p,p),P(d,d,p),B(t,d),0}function U(t,e){return O(t,e,_e)}function L(t,e){return ye(e,32),U(t,e)}function M(t,e,r){var n=new Uint8Array(32);return O(n,r,e),p(t,ge,n,De)}function z(t,e,r,n,i,u){var o=new Uint8Array(32);return M(o,i,u),xe(t,e,r,n,o)}function N(t,e,r,n,i,u){var o=new Uint8Array(32);return M(o,i,u),je(t,e,r,n,o)}function H(){var t,e,r,n=0,i=0,u=0,o=0,s=65535;for(r=0;r>>16,u+=e&s,o+=e>>>16;return i+=n>>>16,u+=i>>>16,o+=u>>>16,new de(u&s|o<<16,n&s|i<<16)}function V(t,e){return new de(t.hi>>>e,t.lo>>>e|t.hi<<32-e)}function K(){var t,e=0,r=0;for(t=0;te?(r=t.hi>>>e|t.lo<>>e|t.hi<e&&(r=t.lo>>>e|t.hi<>>e|t.lo<i;i++)a[i]=l[i]=u(t,8*i);for(var h=0;r>=128;){for(i=0;16>i;i++)f[i]=u(e,8*i+h);for(i=0;80>i;i++){for(o=0;8>o;o++)c[o]=l[o];for(n=H(l[7],G(l[4]),Y(l[4],l[5],l[6]),Te[i],f[i%16]),c[7]=H(n,W(l[0]),$(l[0],l[1],l[2])),c[3]=H(c[3],n),o=0;8>o;o++)l[(o+1)%8]=c[o];if(i%16===15)for(o=0;16>o;o++)f[o]=H(f[o],f[(o+9)%16],J(f[(o+1)%16]),X(f[(o+14)%16]))}for(i=0;8>i;i++)l[i]=H(l[i],a[i]),a[i]=l[i];h+=128,r-=128}for(i=0;8>i;i++)s(t,8*i,a[i]);return r}function Z(t,e,r){var n,i=new Uint8Array(64),u=new Uint8Array(256),o=r;for(n=0;64>n;n++)i[n]=Pe[n];for(Q(i,e,r),r%=128,n=0;256>n;n++)u[n]=0;for(n=0;r>n;n++)u[n]=e[o-r+n];for(u[r]=128,r=256-128*(112>r?1:0),u[r-9]=0,s(u,r-8,new de(o/536870912|0,o<<3)),Q(i,u,r),n=0;64>n;n++)t[n]=i[n];return 0}function te(t,e){var r=ve(),n=ve(),i=ve(),u=ve(),o=ve(),s=ve(),a=ve(),c=ve(),l=ve();T(r,t[1],t[0]),T(l,e[1],e[0]),P(r,r,l),j(n,t[0],t[1]),j(l,e[0],e[1]),P(n,n,l),P(i,t[3],e[3]),P(i,i,Ee),P(u,t[2],e[2]),j(u,u,u),T(o,n,r),T(s,u,i),j(a,u,i),j(c,n,r),P(t[0],o,s),P(t[1],c,a),P(t[2],a,s),P(t[3],o,c)}function ee(t,e,r){var n;for(n=0;4>n;n++)C(t[n],e[n],r)}function re(t,e){var r=ve(),n=ve(),i=ve();S(i,e[2]),P(r,e[0],i),P(n,e[1],i),B(t,n),t[31]^=k(r)<<7}function ne(t,e,r){var n,i;for(E(t[0],me),E(t[1],be),E(t[2],be),E(t[3],me),i=255;i>=0;--i)n=r[i/8|0]>>(7&i)&1,ee(t,e,n),te(e,t),te(t,t),ee(t,e,n)}function ie(t,e){var r=[ve(),ve(),ve(),ve()];E(r[0],Fe),E(r[1],Ce),E(r[2],be),P(r[3],Fe,Ce),ne(t,r,e)}function ue(t,e,r){var n,i=new Uint8Array(64),u=[ve(),ve(),ve(),ve()];for(r||ye(e,32),Z(i,e,32),i[0]&=248,i[31]&=127,i[31]|=64,ie(u,i),re(t,u),n=0;32>n;n++)e[n+32]=t[n];return 0}function oe(t,e){var r,n,i,u;for(n=63;n>=32;--n){for(r=0,i=n-32,u=n-12;u>i;++i)e[i]+=r-16*e[n]*Re[i-(n-32)],r=e[i]+128>>8,e[i]-=256*r;e[i]+=r,e[n]=0}for(r=0,i=0;32>i;i++)e[i]+=r-(e[31]>>4)*Re[i],r=e[i]>>8,e[i]&=255;for(i=0;32>i;i++)e[i]-=r*Re[i];for(n=0;32>n;n++)e[n+1]+=e[n]>>8,t[n]=255&e[n]}function se(t){var e,r=new Float64Array(64);for(e=0;64>e;e++)r[e]=t[e];for(e=0;64>e;e++)t[e]=0;oe(t,r)}function ae(t,e,r,n){var i,u,o=new Uint8Array(64),s=new Uint8Array(64),a=new Uint8Array(64),c=new Float64Array(64),l=[ve(),ve(),ve(),ve()];Z(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64;var f=r+64;for(i=0;r>i;i++)t[64+i]=e[i];for(i=0;32>i;i++)t[32+i]=o[32+i];for(Z(a,t.subarray(32),r+32),se(a),ie(l,a),re(t,l),i=32;64>i;i++)t[i]=n[i];for(Z(s,t,r+64),se(s),i=0;64>i;i++)c[i]=0;for(i=0;32>i;i++)c[i]=a[i];for(i=0;32>i;i++)for(u=0;32>u;u++)c[i+u]+=s[i]*o[u];return oe(t.subarray(32),c),f}function ce(t,e){var r=ve(),n=ve(),i=ve(),u=ve(),o=ve(),s=ve(),a=ve();return E(t[2],be),x(t[1],e),R(i,t[1]),P(u,i,Ae),T(i,i,t[2]),j(u,t[2],u),R(o,u),R(s,o),P(a,s,o),P(r,a,i),P(r,r,u),I(r,r),P(r,r,i),P(r,r,u),P(r,r,u),P(t[0],r,u),R(n,t[0]),P(n,n,u),D(n,i)&&P(t[0],t[0],Be),R(n,t[0]),P(n,n,u),D(n,i)?-1:(k(t[0])===e[31]>>7&&T(t[0],me,t[0]),P(t[3],t[0],t[1]),0)}function le(t,e,r,n){var i,u,o=new Uint8Array(32),s=new Uint8Array(64),a=[ve(),ve(),ve(),ve()],c=[ve(),ve(),ve(),ve()];if(u=-1,64>r)return-1;if(ce(c,n))return-1;for(i=0;r>i;i++)t[i]=e[i];for(i=0;32>i;i++)t[i+32]=n[i];if(Z(s,t,r),se(s),ne(a,c,s),ie(c,e.subarray(32)),te(a,c),re(o,a),r-=64,l(e,0,o,0)){for(i=0;r>i;i++)t[i]=0;return-1}for(i=0;r>i;i++)t[i]=e[i+64];return u=r}function fe(t,e){if(t.length!==Se)throw new Error("bad key size");if(e.length!==Ie)throw new Error("bad nonce size")}function he(t,e){if(t.length!==ze)throw new Error("bad public key size");if(e.length!==Ne)throw new Error("bad secret key size")}function pe(){for(var t,e={}.toString,r=0;rr;r++)n.push(String.fromCharCode(t[r]));return btoa(n.join(""))},t.util.decodeBase64=function(t){if("undefined"==typeof atob)return new Uint8Array(Array.prototype.slice.call(new e(t,"base64"),0));var r,n=atob(t),i=new Uint8Array(n.length); -for(r=0;rn)return null;for(var i=new Uint8Array(n),u=0;un;n++)i[n]=e[n];for(n=0;n=0},t.sign.keyPair=function(){var t=new Uint8Array($e),e=new Uint8Array(We);return ue(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(pe(t),t.length!==We)throw new Error("bad secret key size");var e,r=new Uint8Array($e);for(e=0;32>e;e++)r[e]=t[32+e];return{publicKey:r,secretKey:t}},t.sign.keyPair.fromSeed=function(t){if(pe(t),t.length!==Ge)throw new Error("bad seed size");for(var e=new Uint8Array($e),r=new Uint8Array(We),n=0;32>n;n++)r[n]=t[n];return ue(e,r,!0),{publicKey:e,secretKey:r}},t.sign.publicKeyLength=$e,t.sign.secretKeyLength=We,t.sign.seedLength=Ge,t.sign.signatureLength=Ye,t.hash=function(t){pe(t);var e=new Uint8Array(Je);return Z(e,t,t.length),e},t.hash.hashLength=Je,t.verify=function(t,e){return pe(t,e),0===t.length||0===e.length?!1:t.length!==e.length?!1:0===a(t,0,e,0,t.length)?!0:!1},t.setPRNG=function(t){ye=t},function(){var e;"undefined"!=typeof window?(window.crypto&&window.crypto.getRandomValues?e=window.crypto:window.msCrypto&&window.msCrypto.getRandomValues&&(e=window.msCrypto),e&&t.setPRNG(function(t,r){var n,i=new Uint8Array(r);for(e.getRandomValues(i),n=0;r>n;n++)t[n]=i[n]})):(e=r(21),e&&t.setPRNG(function(t,r){var n,i=e.randomBytes(r);for(n=0;r>n;n++)t[n]=i[n]}))}()}("undefined"!=typeof t&&t.exports?t.exports:window.nacl=window.nacl||{})}).call(e,r(22).Buffer)},function(t,e,r){var n=r(9),i=r(2),u=r(14),o=t.exports;o.present=function(t){return function(e){if(n.isEmpty(e[t])){var r=new i.MissingField(t+" is blank");return r.field=t,u.reject(r)}return u.resolve(e)}},o.number=function(t){return function(e){if(n.isNumber(e[t]))return u.resolve(e);var r=new i.InvalidField(t+" is not a number");return r.field=t,u.reject(r)}}},function(t,e,r){(function(e){"use strict";function n(t){try{Promise===t&&(Promise=i)}catch(e){}return t}var i;"undefined"!=typeof Promise&&(i=Promise),t.exports=function(){function t(e){if("function"!=typeof e)throw new A("the promise constructor requires a resolver function");if(this.constructor!==t)throw new A("the promise constructor cannot be invoked directly");this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,this._settledValue=void 0,this._boundTo=void 0,e!==a&&this._resolveFromResolver(e)}function i(t){return t[0]}var u=r(27),o=r(28),s=r(29),a=function(){},c={},l={e:null},f=r(30)(t,a),h=r(31)(t,a,f),p=r(32)(),d=r(33)(l),v=r(34),y=u.isArray,g=u.errorObj,_=u.tryCatch1,m=u.tryCatch2,b=u.tryCatchApply,w=s.RangeError,A=s.TypeError,E=s.CancellationError,F=s.TimeoutError,C=s.OperationalError,B=s.originatesFromRejection,D=s.markAsOriginatingFromRejection,k=s.canAttach,x=u.thrower,j=r(35)(t),T=function(){return new A("circular promise resolution chain")};t.prototype.bind=function(e){var r=f(e,void 0),n=new t(a);if(r instanceof t){var u=r.then(function(t){n._setBoundTo(t)}),o=t.all([this,u]).then(i);n._follow(o)}else n._follow(this),n._setBoundTo(e);return n._propagateFrom(this,3),n},t.prototype.toString=function(){return"[object Promise]"},t.prototype.caught=t.prototype["catch"]=function(e){var r=arguments.length;if(r>1){var n,i=new Array(r-1),u=0;for(n=0;r-1>n;++n){var o=arguments[n];if("function"!=typeof o){var s=new A("A catch filter must be an error constructor or a filter function");return this._attachExtraTrace(s),t.reject(s)}i[u++]=o}i.length=u,e=arguments[n],this._resetTrace();var a=new d(i,e,this);return this._then(void 0,a.doFilter,void 0,a,void 0)}return this._then(void 0,e,void 0,void 0,void 0)},t.prototype.then=function(t,e,r){return this._then(t,e,r,void 0,void 0)},t.prototype.done=function(t,e,r){var n=this._then(t,e,r,void 0,void 0);n._setIsFinal()},t.prototype.spread=function(t,e){return this._then(t,e,void 0,c,void 0)},t.prototype.isCancellable=function(){return!this.isResolved()&&this._cancellable()},t.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this._settledValue,t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this._settledValue,t.isRejected=!0),t},t.prototype.all=function(){return new h(this).promise()},t.is=function(e){return e instanceof t},t.all=function(t){return new h(t).promise()},t.prototype.error=function(t){return this.caught(B,t)},t.prototype._resolveFromSyncValue=function(e){if(e===g)this._cleanValues(),this._setRejected(),this._settledValue=e.e,this._ensurePossibleRejectionHandled();else{var r=f(e,void 0);r instanceof t?this._follow(r):(this._cleanValues(),this._setFulfilled(),this._settledValue=e)}},t.method=function(e){if("function"!=typeof e)throw new A("fn must be a function");return function(){var r;switch(arguments.length){case 0:r=_(e,this,void 0);break;case 1:r=_(e,this,arguments[0]);break;case 2:r=m(e,this,arguments[0],arguments[1]);break;default:for(var n=arguments.length,i=new Array(n),u=0;n>u;++u)i[u]=arguments[u];r=b(e,i,this)}var o=new t(a);return o._setTrace(void 0),o._resolveFromSyncValue(r),o}},t.attempt=t["try"]=function(e,r,n){if("function"!=typeof e)return j("fn must be a function");var i=y(r)?b(e,r,n):_(e,n,r),u=new t(a);return u._setTrace(void 0),u._resolveFromSyncValue(i),u},t.defer=t.pending=function(){var e=new t(a);return e._setTrace(void 0),new v(e)},t.bind=function(e){var r=f(e,void 0),n=new t(a);if(n._setTrace(void 0),r instanceof t){var i=r.then(function(t){n._setBoundTo(t)});n._follow(i)}else n._setBoundTo(e),n._setFulfilled();return n},t.cast=function(e){var r=f(e,void 0);if(!(r instanceof t)){var n=r;r=new t(a),r._setTrace(void 0),r._setFulfilled(),r._cleanValues(),r._settledValue=n}return r},t.resolve=t.fulfilled=t.cast,t.reject=t.rejected=function(e){var r=new t(a);if(r._setTrace(void 0),D(e),r._cleanValues(),r._setRejected(),r._settledValue=e,!k(e)){var n=new Error(e+"");r._setCarriedStackTrace(n)}return r._ensurePossibleRejectionHandled(),r},t.onPossiblyUnhandledRejection=function(t){p.possiblyUnhandledRejection="function"==typeof t?t:void 0};var P;t.onUnhandledRejectionHandled=function(t){P="function"==typeof t?t:void 0};var R=!1||!("undefined"==typeof e||"string"!=typeof e.execPath||"object"!=typeof e.env||!e.env.BLUEBIRD_DEBUG&&"development"!==e.env.NODE_ENV);t.longStackTraces=function(){if(o.haveItemsQueued()&&R===!1)throw new Error("cannot enable long stack traces after promises have been created");R=p.isSupported()},t.hasLongStackTraces=function(){return R&&p.isSupported()},t.prototype._then=function(e,r,n,i,u){var s=void 0!==u,c=s?u:new t(a);if(!s){if(R){var l=this._peekContext()===this._traceParent;c._traceParent=l?this._traceParent:this}c._propagateFrom(this,7)}var f=this._addCallbacks(e,r,n,c,i);return this.isResolved()&&o.invoke(this._queueSettleAt,this,f),c},t.prototype._length=function(){return 262143&this._bitField},t.prototype._isFollowingOrFulfilledOrRejected=function(){return(939524096&this._bitField)>0},t.prototype._isFollowing=function(){return 536870912===(536870912&this._bitField)},t.prototype._setLength=function(t){this._bitField=-262144&this._bitField|262143&t},t.prototype._setFulfilled=function(){this._bitField=268435456|this._bitField},t.prototype._setRejected=function(){this._bitField=134217728|this._bitField},t.prototype._setFollowing=function(){this._bitField=536870912|this._bitField},t.prototype._setIsFinal=function(){this._bitField=33554432|this._bitField},t.prototype._isFinal=function(){return(33554432&this._bitField)>0},t.prototype._cancellable=function(){return(67108864&this._bitField)>0},t.prototype._setCancellable=function(){this._bitField=67108864|this._bitField},t.prototype._unsetCancellable=function(){this._bitField=-67108865&this._bitField},t.prototype._setRejectionIsUnhandled=function(){this._bitField=2097152|this._bitField},t.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-2097153&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},t.prototype._isRejectionUnhandled=function(){return(2097152&this._bitField)>0},t.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=524288|this._bitField},t.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-524289&this._bitField},t.prototype._isUnhandledRejectionNotified=function(){return(524288&this._bitField)>0},t.prototype._setCarriedStackTrace=function(t){this._bitField=1048576|this._bitField,this._fulfillmentHandler0=t},t.prototype._unsetCarriedStackTrace=function(){this._bitField=-1048577&this._bitField,this._fulfillmentHandler0=void 0},t.prototype._isCarryingStackTrace=function(){return(1048576&this._bitField)>0},t.prototype._getCarriedStackTrace=function(){return this._isCarryingStackTrace()?this._fulfillmentHandler0:void 0},t.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[(t<<2)+t-5+4];return this._isBound()&&void 0===e?this._boundTo:e},t.prototype._promiseAt=function(t){return 0===t?this._promise0:this[(t<<2)+t-5+3]},t.prototype._fulfillmentHandlerAt=function(t){return 0===t?this._fulfillmentHandler0:this[(t<<2)+t-5+0]},t.prototype._rejectionHandlerAt=function(t){return 0===t?this._rejectionHandler0:this[(t<<2)+t-5+1]},t.prototype._addCallbacks=function(t,e,r,n,i){var u=this._length();if(u>=262138&&(u=0,this._setLength(0)),0===u)this._promise0=n,void 0!==i&&(this._receiver0=i),"function"!=typeof t||this._isCarryingStackTrace()||(this._fulfillmentHandler0=t),"function"==typeof e&&(this._rejectionHandler0=e),"function"==typeof r&&(this._progressHandler0=r);else{var o=(u<<2)+u-5;this[o+3]=n,this[o+4]=i,this[o+0]="function"==typeof t?t:void 0,this[o+1]="function"==typeof e?e:void 0,this[o+2]="function"==typeof r?r:void 0}return this._setLength(u+1),u},t.prototype._setProxyHandlers=function(t,e){var r=this._length();if(r>=262138&&(r=0,this._setLength(0)),0===r)this._promise0=e,this._receiver0=t;else{var n=(r<<2)+r-5;this[n+3]=e,this[n+4]=t,this[n+0]=this[n+1]=this[n+2]=void 0}this._setLength(r+1)},t.prototype._proxyPromiseArray=function(t,e){this._setProxyHandlers(t,e)},t.prototype._proxyPromise=function(t){t._setProxied(),this._setProxyHandlers(t,-15)},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=8388608|this._bitField,this._boundTo=t):this._bitField=-8388609&this._bitField},t.prototype._isBound=function(){return 8388608===(8388608&this._bitField)},t.prototype._resolveFromResolver=function(t){function e(t){n._tryFollow(t)||n._fulfill(t)}function r(t){var e=k(t)?t:new Error(t+"");n._attachExtraTrace(e),D(t),n._reject(t,e===t?void 0:e)}var n=this;this._setTrace(void 0),this._pushContext();var i=m(t,void 0,e,r);if(this._popContext(),void 0!==i&&i===g){var u=i.e,o=k(u)?u:new Error(u+"");n._reject(u,o)}},t.prototype._spreadSlowCase=function(t,e,r,n){var i=new h(r).promise(),u=i._then(function(){return t.apply(n,arguments)},void 0,void 0,c,void 0);e._follow(u)},t.prototype._callSpread=function(e,r,n){var i=this._boundTo;if(y(n))for(var u=0,o=n.length;o>u;++u)if(f(n[u],void 0)instanceof t)return this._spreadSlowCase(e,r,n,i),void 0;return r._pushContext(),b(e,n,i)},t.prototype._callHandler=function(t,e,r,n){var i;return e!==c||this.isRejected()?(r._pushContext(),i=_(t,e,n)):i=this._callSpread(t,r,n),r._popContext(),i},t.prototype._settlePromiseFromHandler=function(e,r,n,i){if(!(i instanceof t))return e.call(r,n,i),void 0;var u=this._callHandler(e,r,i,n);if(!i._isFollowing())if(u===g||u===i||u===l){var o=u===i?T():u.e,s=k(o)?o:new Error(o+"");u!==l&&i._attachExtraTrace(s),i._rejectUnchecked(o,s)}else{var a=f(u,i);if(a instanceof t){if(a.isRejected()&&!a._isCarryingStackTrace()&&!k(a._settledValue)){var s=new Error(a._settledValue+"");i._attachExtraTrace(s),a._setCarriedStackTrace(s)}i._follow(a),i._propagateFrom(a,1)}else i._fulfillUnchecked(u)}},t.prototype._follow=function(t){this._setFollowing(),t.isPending()?(this._propagateFrom(t,1),t._proxyPromise(this)):t.isFulfilled()?this._fulfillUnchecked(t._settledValue):this._rejectUnchecked(t._settledValue,t._getCarriedStackTrace()),t._isRejectionUnhandled()&&t._unsetRejectionIsUnhandled(),R&&null==t._traceParent&&(t._traceParent=this)},t.prototype._tryFollow=function(e){if(this._isFollowingOrFulfilledOrRejected()||e===this)return!1;var r=f(e,void 0);return r instanceof t?(this._follow(r),!0):!1},t.prototype._resetTrace=function(){R&&(this._trace=new p(void 0===this._peekContext()))},t.prototype._setTrace=function(t){if(R){var e=this._peekContext();this._traceParent=e;var r=void 0===e;this._trace=void 0!==t&&t._traceParent===e?t._trace:new p(r)}return this},t.prototype._attachExtraTrace=function(t){if(R){var e=this,r=t.stack;r="string"==typeof r?r.split("\n"):[],p.protectErrorMessageNewlines(r);for(var n=1,i=1;null!=e&&null!=e._trace;)r=p.combine(r,e._trace.stack.split("\n")),e=e._traceParent,i++;var u=Error.stackTraceLimit||10,o=(u+n)*i,s=r.length;s>o&&(r.length=o),s>0&&(r[0]=r[0].split("\x00").join("\n")),t.stack=r.length<=n?"(No stack trace)":r.join("\n")}},t.prototype._cleanValues=function(){this._cancellable()&&(this._cancellationParent=void 0)},t.prototype._propagateFrom=function(t,e){(1&e)>0&&t._cancellable()&&(this._setCancellable(),this._cancellationParent=t),(4&e)>0&&this._setBoundTo(t._boundTo),(2&e)>0&&this._setTrace(t)},t.prototype._fulfill=function(t){this._isFollowingOrFulfilledOrRejected()||this._fulfillUnchecked(t)},t.prototype._reject=function(t,e){this._isFollowingOrFulfilledOrRejected()||this._rejectUnchecked(t,e)},t.prototype._settlePromiseAt=function(e){var r=this.isFulfilled()?this._fulfillmentHandlerAt(e):this._rejectionHandlerAt(e),n=this._settledValue,i=this._receiverAt(e),u=this._promiseAt(e);if("function"==typeof r)this._settlePromiseFromHandler(r,i,n,u);else{var o=!1,s=this.isFulfilled();void 0!==i&&(i instanceof t&&i._isProxied()?(i._unsetProxied(),s?i._fulfillUnchecked(n):i._rejectUnchecked(n,this._getCarriedStackTrace()),o=!0):i instanceof h&&(s?i._promiseFulfilled(n,u):i._promiseRejected(n,u),o=!0)),o||(s?u._fulfill(n):u._reject(n,this._getCarriedStackTrace()))}e>=4&&this._queueGC()},t.prototype._isProxied=function(){return 4194304===(4194304&this._bitField)},t.prototype._setProxied=function(){this._bitField=4194304|this._bitField},t.prototype._unsetProxied=function(){this._bitField=-4194305&this._bitField},t.prototype._isGcQueued=function(){return-1073741824===(-1073741824&this._bitField)},t.prototype._setGcQueued=function(){this._bitField=-1073741824|this._bitField},t.prototype._unsetGcQueued=function(){this._bitField=1073741823&this._bitField},t.prototype._queueGC=function(){this._isGcQueued()||(this._setGcQueued(),o.invokeLater(this._gc,this,void 0))},t.prototype._gc=function(){for(var t=5*this._length()-5,e=0;t>e;e++)delete this[e];this._clearFirstHandlerData(),this._setLength(0),this._unsetGcQueued()},t.prototype._clearFirstHandlerData=function(){this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0},t.prototype._queueSettleAt=function(t){this._isRejectionUnhandled()&&this._unsetRejectionIsUnhandled(),o.invoke(this._settlePromiseAt,this,t)},t.prototype._fulfillUnchecked=function(t){if(this.isPending()){if(t===this){var e=T();return this._attachExtraTrace(e),this._rejectUnchecked(e,void 0)}this._cleanValues(),this._setFulfilled(),this._settledValue=t;var r=this._length();r>0&&o.invoke(this._settlePromises,this,r)}},t.prototype._rejectUncheckedCheckError=function(t){var e=k(t)?t:new Error(t+"");this._rejectUnchecked(t,e===t?void 0:e)},t.prototype._rejectUnchecked=function(t,e){if(this.isPending()){if(t===this){var r=T();return this._attachExtraTrace(r),this._rejectUnchecked(r)}if(this._cleanValues(),this._setRejected(),this._settledValue=t,this._isFinal())return o.invokeLater(x,void 0,void 0===e?t:e),void 0;var n=this._length();void 0!==e&&this._setCarriedStackTrace(e),n>0?o.invoke(this._rejectPromises,this,null):this._ensurePossibleRejectionHandled()}},t.prototype._rejectPromises=function(){this._settlePromises(),this._unsetCarriedStackTrace()},t.prototype._settlePromises=function(){for(var t=this._length(),e=0;t>e;e++)this._settlePromiseAt(e)},t.prototype._ensurePossibleRejectionHandled=function(){this._setRejectionIsUnhandled(),void 0!==p.possiblyUnhandledRejection&&o.invokeLater(this._notifyUnhandledRejection,this,void 0)},t.prototype._notifyUnhandledRejectionIsHandled=function(){"function"==typeof P&&o.invokeLater(P,void 0,this)},t.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue,e=this._getCarriedStackTrace();this._setUnhandledRejectionIsNotified(),void 0!==e&&(this._unsetCarriedStackTrace(),t=e),"function"==typeof p.possiblyUnhandledRejection&&p.possiblyUnhandledRejection(t,this)}};var S=[];return t.prototype._peekContext=function(){var t=S.length-1;return t>=0?S[t]:void 0},t.prototype._pushContext=function(){R&&S.push(this)},t.prototype._popContext=function(){R&&S.pop()},t.noConflict=function(){return n(t)},t.setScheduler=function(t){if("function"!=typeof t)throw new A("fn must be a function");o._schedule=t},p.isSupported()||(t.longStackTraces=function(){},R=!1),t._makeSelfResolutionError=T,r(36)(t,l,f),r(37)(t),r(38)(t),r(39)(t,h,f,a),t.RangeError=w,t.CancellationError=E,t.TimeoutError=F,t.TypeError=A,t.OperationalError=C,t.RejectionError=C,t.AggregateError=s.AggregateError,u.toFastProperties(t),u.toFastProperties(t.prototype),t.Promise=t,r(40)(t,a,f),r(41)(t,a,f),r(42)(t),r(43)(t,j,a,f),r(44)(t,h,j,f,a),r(45)(t),r(46)(t,a),r(47)(t,h,f),r(48)(t,h,j,f,a),r(49)(t,h),r(50)(t,h,j),r(51)(t,h),r(52)(t,a),r(53)(t,a),r(54)(t,h),r(55)(t,a),r(56)(t,j,f),t.prototype=t.prototype,t}}).call(e,r(57))},function(t,e,r){var n=r(58);e.encode=n.encode,e.decode=n.decode},function(t,e,r){(function(t){function n(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}function i(t,e){for(var r in t)e(t[r],r)}var u=r(59);e.createHash=r(60),e.createHmac=r(61),e.randomBytes=function(e,r){if(!r||!r.call)return new t(u(e));try{r.call(this,void 0,new t(u(e)))}catch(n){r(n)}},e.getHashes=function(){return["sha1","sha256","sha512","md5","rmd160"]};var o=r(62)(e);e.pbkdf2=o.pbkdf2,e.pbkdf2Sync=o.pbkdf2Sync,i(["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman"],function(t){e[t]=function(){n("sorry,",t,"is not implemented yet")}})}).call(e,r(22).Buffer)},function(t,e,r){(function(t){function t(e,r,n){if(!(this instanceof t))return new t(e,r,n);var i,u=typeof e;if("number"===u)i=e>0?e>>>0:0;else if("string"===u)"base64"===r&&(e=A(e)),i=t.byteLength(e,r);else{if("object"!==u||null===e)throw new TypeError("must start with number, buffer, array or string");"Buffer"===e.type&&S(e.data)&&(e=e.data),i=+e.length>0?Math.floor(+e.length):0}if(this.length>I)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I.toString(16)+" bytes");var o;t.TYPED_ARRAY_SUPPORT?o=t._augment(new Uint8Array(i)):(o=this,o.length=i,o._isBuffer=!0);var s;if(t.TYPED_ARRAY_SUPPORT&&"number"==typeof e.byteLength)o._set(e);else if(F(e))if(t.isBuffer(e))for(s=0;i>s;s++)o[s]=e.readUInt8(s);else for(s=0;i>s;s++)o[s]=(e[s]%256+256)%256;else if("string"===u)o.write(e,0,r);else if("number"===u&&!t.TYPED_ARRAY_SUPPORT&&!n)for(s=0;i>s;s++)o[s]=0;return o}function n(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var u=e.length;if(u%2!==0)throw new Error("Invalid hex string");n>u/2&&(n=u/2);for(var o=0;n>o;o++){var s=parseInt(e.substr(2*o,2),16);if(isNaN(s))throw new Error("Invalid hex string");t[r+o]=s}return o}function i(t,e,r,n){var i=j(B(e),t,r,n);return i}function u(t,e,r,n){var i=j(D(e),t,r,n);return i}function o(t,e,r,n){return u(t,e,r,n)}function s(t,e,r,n){var i=j(x(e),t,r,n);return i}function a(t,e,r,n){var i=j(k(e),t,r,n);return i}function c(t,e,r){return 0===e&&r===t.length?P.fromByteArray(t):P.fromByteArray(t.slice(e,r))}function l(t,e,r){var n="",i="";r=Math.min(t.length,r);for(var u=e;r>u;u++)t[u]<=127?(n+=T(i)+String.fromCharCode(t[u]),i=""):i+="%"+t[u].toString(16);return n+T(i)}function f(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function h(t,e,r){return f(t,e,r)}function p(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",u=e;r>u;u++)i+=C(t[u]);return i}function d(t,e,r){for(var n=t.slice(e,r),i="",u=0;ut)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function y(e,r,n,i,u,o){if(!t.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(r>u||o>r)throw new TypeError("value is out of bounds");if(n+i>e.length)throw new TypeError("index out of range")}function g(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,u=Math.min(t.length-r,2);u>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function _(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,u=Math.min(t.length-r,4);u>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function m(t,e,r,n,i,u){if(e>i||u>e)throw new TypeError("value is out of bounds");if(r+n>t.length)throw new TypeError("index out of range")}function b(t,e,r,n,i){return i||m(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),R.write(t,e,r,n,23,4),r+4}function w(t,e,r,n,i){return i||m(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),R.write(t,e,r,n,52,8),r+8}function A(t){for(t=E(t).replace(U,"");t.length%4!==0;)t+="=";return t}function E(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function F(e){return S(e)||t.isBuffer(e)||e&&"object"==typeof e&&"number"==typeof e.length}function C(t){return 16>t?"0"+t.toString(16):t.toString(16)}function B(t){for(var e=[],r=0;r=n)e.push(n);else{var i=r;n>=55296&&57343>=n&&r++;for(var u=encodeURIComponent(t.slice(i,r+1)).substr(1).split("%"),o=0;o>8,n=e%256,i.push(n),i.push(r);return i}function x(t){return P.toByteArray(t)}function j(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}function T(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}var P=r(72),R=r(70),S=r(71);e.Buffer=t,e.SlowBuffer=t,e.INSPECT_MAX_BYTES=50,t.poolSize=8192;var I=1073741823;t.TYPED_ARRAY_SUPPORT=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(r){return!1}}(),t.isBuffer=function(t){return!(null==t||!t._isBuffer)},t.compare=function(e,r){if(!t.isBuffer(e)||!t.isBuffer(r))throw new TypeError("Arguments must be Buffers");for(var n=e.length,i=r.length,u=0,o=Math.min(n,i);o>u&&e[u]===r[u];u++);return u!==o&&(n=e[u],i=r[u]),i>n?-1:n>i?1:0},t.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},t.concat=function(e,r){if(!S(e))throw new TypeError("Usage: Buffer.concat(list[, length])");if(0===e.length)return new t(0);if(1===e.length)return e[0];var n;if(void 0===r)for(r=0,n=0;n>>1;break;case"utf8":case"utf-8":r=B(t).length;break;case"base64":r=x(t).length;break;default:r=t.length}return r},t.prototype.length=void 0,t.prototype.parent=void 0,t.prototype.toString=function(t,e,r){var n=!1;if(e>>>=0,r=void 0===r||1/0===r?this.length:r>>>0,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return p(this,e,r);case"utf8":case"utf-8":return l(this,e,r);case"ascii":return f(this,e,r);case"binary":return h(this,e,r);case"base64":return c(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}},t.prototype.equals=function(e){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");return 0===t.compare(this,e)},t.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},t.prototype.compare=function(e){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");return t.compare(this,e)},t.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},t.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},t.prototype.write=function(t,e,r,c){if(isFinite(e))isFinite(r)||(c=r,r=void 0);else{var l=c;c=e,e=r,r=l}e=Number(e)||0;var f=this.length-e;r?(r=Number(r),r>f&&(r=f)):r=f,c=String(c||"utf8").toLowerCase();var h;switch(c){case"hex":h=n(this,t,e,r);break;case"utf8":case"utf-8":h=i(this,t,e,r);break;case"ascii":h=u(this,t,e,r);break;case"binary":h=o(this,t,e,r);break;case"base64":h=s(this,t,e,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":h=a(this,t,e,r);break;default:throw new TypeError("Unknown encoding: "+c)}return h},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},t.prototype.slice=function(e,r){var n=this.length;if(e=~~e,r=void 0===r?n:~~r,0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),0>r?(r+=n,0>r&&(r=0)):r>n&&(r=n),e>r&&(r=e),t.TYPED_ARRAY_SUPPORT)return t._augment(this.subarray(e,r));for(var i=r-e,u=new t(i,void 0,!0),o=0;i>o;o++)u[o]=this[o+e];return u},t.prototype.readUInt8=function(t,e){return e||v(t,1,this.length),this[t]},t.prototype.readUInt16LE=function(t,e){return e||v(t,2,this.length),this[t]|this[t+1]<<8},t.prototype.readUInt16BE=function(t,e){return e||v(t,2,this.length),this[t]<<8|this[t+1]},t.prototype.readUInt32LE=function(t,e){return e||v(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},t.prototype.readUInt32BE=function(t,e){return e||v(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},t.prototype.readInt8=function(t,e){return e||v(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},t.prototype.readInt16LE=function(t,e){e||v(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt16BE=function(t,e){e||v(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt32LE=function(t,e){return e||v(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},t.prototype.readInt32BE=function(t,e){return e||v(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},t.prototype.readFloatLE=function(t,e){return e||v(t,4,this.length),R.read(this,t,!0,23,4)},t.prototype.readFloatBE=function(t,e){return e||v(t,4,this.length),R.read(this,t,!1,23,4)},t.prototype.readDoubleLE=function(t,e){return e||v(t,8,this.length),R.read(this,t,!0,52,8)},t.prototype.readDoubleBE=function(t,e){return e||v(t,8,this.length),R.read(this,t,!1,52,8)},t.prototype.writeUInt8=function(e,r,n){return e=+e,r>>>=0,n||y(this,e,r,1,255,0),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[r]=e,r+1},t.prototype.writeUInt16LE=function(e,r,n){return e=+e,r>>>=0,n||y(this,e,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e,this[r+1]=e>>>8):g(this,e,r,!0),r+2},t.prototype.writeUInt16BE=function(e,r,n){return e=+e,r>>>=0,n||y(this,e,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=e):g(this,e,r,!1),r+2},t.prototype.writeUInt32LE=function(e,r,n){return e=+e,r>>>=0,n||y(this,e,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e):_(this,e,r,!0),r+4},t.prototype.writeUInt32BE=function(e,r,n){return e=+e,r>>>=0,n||y(this,e,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e):_(this,e,r,!1),r+4},t.prototype.writeInt8=function(e,r,n){return e=+e,r>>>=0,n||y(this,e,r,1,127,-128),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[r]=e,r+1},t.prototype.writeInt16LE=function(e,r,n){return e=+e,r>>>=0,n||y(this,e,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=e,this[r+1]=e>>>8):g(this,e,r,!0),r+2},t.prototype.writeInt16BE=function(e,r,n){return e=+e,r>>>=0,n||y(this,e,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=e):g(this,e,r,!1),r+2},t.prototype.writeInt32LE=function(e,r,n){return e=+e,r>>>=0,n||y(this,e,r,4,2147483647,-2147483648),t.TYPED_ARRAY_SUPPORT?(this[r]=e,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24):_(this,e,r,!0),r+4},t.prototype.writeInt32BE=function(e,r,n){return e=+e,r>>>=0,n||y(this,e,r,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e):_(this,e,r,!1),r+4},t.prototype.writeFloatLE=function(t,e,r){return b(this,t,e,!0,r)},t.prototype.writeFloatBE=function(t,e,r){return b(this,t,e,!1,r)},t.prototype.writeDoubleLE=function(t,e,r){return w(this,t,e,!0,r) -},t.prototype.writeDoubleBE=function(t,e,r){return w(this,t,e,!1,r)},t.prototype.copy=function(e,r,n,i){var u=this;if(n||(n=0),i||0===i||(i=this.length),r||(r=0),i!==n&&0!==e.length&&0!==u.length){if(n>i)throw new TypeError("sourceEnd < sourceStart");if(0>r||r>=e.length)throw new TypeError("targetStart out of bounds");if(0>n||n>=u.length)throw new TypeError("sourceStart out of bounds");if(0>i||i>u.length)throw new TypeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-ro||!t.TYPED_ARRAY_SUPPORT)for(var s=0;o>s;s++)e[s+r]=this[s+n];else e._set(this.subarray(n,n+o),r)}},t.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),e>r)throw new TypeError("end < start");if(r!==e&&0!==this.length){if(0>e||e>=this.length)throw new TypeError("start out of bounds");if(0>r||r>this.length)throw new TypeError("end out of bounds");var n;if("number"==typeof t)for(n=e;r>n;n++)this[n]=t;else{var i=B(t.toString()),u=i.length;for(n=e;r>n;n++)this[n]=i[n%u]}return this}},t.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(t.TYPED_ARRAY_SUPPORT)return new t(this).buffer;for(var e=new Uint8Array(this.length),r=0,n=e.length;n>r;r+=1)e[r]=this[r];return e.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var O=t.prototype;t._augment=function(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=O.get,t.set=O.set,t.write=O.write,t.toString=O.toString,t.toLocaleString=O.toString,t.toJSON=O.toJSON,t.equals=O.equals,t.compare=O.compare,t.copy=O.copy,t.slice=O.slice,t.readUInt8=O.readUInt8,t.readUInt16LE=O.readUInt16LE,t.readUInt16BE=O.readUInt16BE,t.readUInt32LE=O.readUInt32LE,t.readUInt32BE=O.readUInt32BE,t.readInt8=O.readInt8,t.readInt16LE=O.readInt16LE,t.readInt16BE=O.readInt16BE,t.readInt32LE=O.readInt32LE,t.readInt32BE=O.readInt32BE,t.readFloatLE=O.readFloatLE,t.readFloatBE=O.readFloatBE,t.readDoubleLE=O.readDoubleLE,t.readDoubleBE=O.readDoubleBE,t.writeUInt8=O.writeUInt8,t.writeUInt16LE=O.writeUInt16LE,t.writeUInt16BE=O.writeUInt16BE,t.writeUInt32LE=O.writeUInt32LE,t.writeUInt32BE=O.writeUInt32BE,t.writeInt8=O.writeInt8,t.writeInt16LE=O.writeInt16LE,t.writeInt16BE=O.writeInt16BE,t.writeInt32LE=O.writeInt32LE,t.writeInt32BE=O.writeInt32BE,t.writeFloatLE=O.writeFloatLE,t.writeFloatBE=O.writeFloatBE,t.writeDoubleLE=O.writeDoubleLE,t.writeDoubleBE=O.writeDoubleBE,t.fill=O.fill,t.inspect=O.inspect,t.toArrayBuffer=O.toArrayBuffer,t};var U=/[^+\/0-9A-z]/g}).call(e,r(22).Buffer)},function(t,e,r){var n=r(24),i=function(t,e,r,i,u,o){function s(t){var e=255&t,r=t>>>8&255,n=t>>>16&255,i=t>>>24&255;return e<<24|r<<16|n<<8|i}function a(){if(i*u>=Math.pow(2,30))throw"The parameters r, p must satisfy r * p < 2^30";if(2>r||r&r-1!=0)throw"The parameter N must be a power of 2.";if(SIZE_MAX=Math.pow(2,32)-1,r>SIZE_MAX/128/i)throw"N too big.";if(i>SIZE_MAX/128/u)throw"r too big."}function c(t,e,r,i,u,o){B=n.misc.pbkdf2(t,e,1,128*u*i*8);for(var s=[],a=[],c=0;u>c;c++)d(B,128*c*i,i,r,s,a);return n.misc.pbkdf2(t,B,1,8*o)}function l(t){function e(t,e){return t<>>32-e}for(var r=[],n=0;16>n;n++)r[n]=s(t[n]);for(var i=[],n=0;16>n;n++)i[n]=0|r[n];for(n=8;n>0;n-=2)i[4]^=e(i[0]+i[12],7),i[8]^=e(i[4]+i[0],9),i[12]^=e(i[8]+i[4],13),i[0]^=e(i[12]+i[8],18),i[9]^=e(i[5]+i[1],7),i[13]^=e(i[9]+i[5],9),i[1]^=e(i[13]+i[9],13),i[5]^=e(i[1]+i[13],18),i[14]^=e(i[10]+i[6],7),i[2]^=e(i[14]+i[10],9),i[6]^=e(i[2]+i[14],13),i[10]^=e(i[6]+i[2],18),i[3]^=e(i[15]+i[11],7),i[7]^=e(i[3]+i[15],9),i[11]^=e(i[7]+i[3],13),i[15]^=e(i[11]+i[7],18),i[1]^=e(i[0]+i[3],7),i[2]^=e(i[1]+i[0],9),i[3]^=e(i[2]+i[1],13),i[0]^=e(i[3]+i[2],18),i[6]^=e(i[5]+i[4],7),i[7]^=e(i[6]+i[5],9),i[4]^=e(i[7]+i[6],13),i[5]^=e(i[4]+i[7],18),i[11]^=e(i[10]+i[9],7),i[8]^=e(i[11]+i[10],9),i[9]^=e(i[8]+i[11],13),i[10]^=e(i[9]+i[8],18),i[12]^=e(i[15]+i[14],7),i[13]^=e(i[12]+i[15],9),i[14]^=e(i[13]+i[12],13),i[15]^=e(i[14]+i[13],18);for(var n=0;16>n;n++)r[n]=r[n]+i[n]|0;for(var n=0;16>n;n++)t[n]=s(r[n]);return t}function f(t,e,r,n,i){i/=4,e/=4,n/=4;for(var u=0;i>u;u++)r[n+u]^=0|t[e+u]}function h(t,e,r,n,i){i/=4,e/=4,n/=4;for(var u=0;i>u;u++)r[n+u]=0|t[e+u]}function p(t,e,r,n){X=[];var i;for(h(t,e+64*(2*n-1),X,0,64),i=0;2*n>i;i++)f(t,64*i,X,0,64),l(X),h(X,0,t,r+64*i,64);for(i=0;n>i;i++)h(t,r+2*i*64,t,e+64*i,64);for(i=0;n>i;i++)h(t,r+64*(2*i+1),t,e+64*(i+n),64)}function d(t,e,r,n,i,u){var o,s=0,a=128*r;for(h(t,e,u,s,a),o=0;n>o;o++)h(u,s,i,o*a,a),p(u,s,a,r);for(o=0;n>o;o++){var c=v(u,s,r)&n-1;f(i,c*a,u,s,a),p(u,s,a,r)}h(u,s,t,e,a)}function v(t,e,r){return e+=64*(2*r-1),s(t[e/4])}return a(),c(t,e,r,i,u,o)};t.exports={extendSjcl:function(t){t.misc.scrypt=i}}},function(t,e,r){function n(t){throw t}function i(t,e,r){4!==e.length&&n(new d.exception.invalid("invalid aes block size"));var i=t.b[r],u=e[0]^i[0],o=e[r?3:1]^i[1],s=e[2]^i[2];e=e[r?1:3]^i[3];var a,c,l,f,h=i.length/4-2,p=4,v=[0,0,0,0];a=t.p[r],t=a[0];var y=a[1],g=a[2],_=a[3],m=a[4];for(f=0;h>f;f++)a=t[u>>>24]^y[o>>16&255]^g[s>>8&255]^_[255&e]^i[p],c=t[o>>>24]^y[s>>16&255]^g[e>>8&255]^_[255&u]^i[p+1],l=t[s>>>24]^y[e>>16&255]^g[u>>8&255]^_[255&o]^i[p+2],e=t[e>>>24]^y[u>>16&255]^g[o>>8&255]^_[255&s]^i[p+3],p+=4,u=a,o=c,s=l;for(f=0;4>f;f++)v[r?3&-f:f]=m[u>>>24]<<24^m[o>>16&255]<<16^m[s>>8&255]<<8^m[255&e]^i[p++],a=u,u=o,o=s,s=e,e=a;return v}function u(t,e){var r,n=d.random.D[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;re&&(t.l[e]=t.l[e]+1|0,!t.l[e]);e++);return t.F.encrypt(t.l)}function c(t,e){return function(){e.apply(t,arguments)}}var l,f,h=void 0,p=!1,d={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};"undefined"!=typeof t&&t.exports&&(t.exports=d),!(l=[],f=function(){return d}.apply(e,l),void 0!==f&&(t.exports=f)),d.cipher.aes=function(t){this.p[0][0][0]||this.u();var e,r,i,u,o=this.p[0][4],s=this.p[1];e=t.length;var a=1;for(4!==e&&6!==e&&8!==e&&n(new d.exception.invalid("invalid aes key size")),this.b=[i=t.slice(0),u=[]],t=e;4*e+28>t;t++)r=i[t-1],(0===t%e||8===e&&4===t%e)&&(r=o[r>>>24]<<24^o[r>>16&255]<<16^o[r>>8&255]<<8^o[255&r],0===t%e&&(r=r<<8^r>>>24^a<<24,a=a<<1^283*(a>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],u[e]=4>=t||4>e?r:s[0][o[r>>>24]]^s[1][o[r>>16&255]]^s[2][o[r>>8&255]]^s[3][o[255&r]]},d.cipher.aes.prototype={encrypt:function(t){return i(this,t,0)},decrypt:function(t){return i(this,t,1)},p:[[[],[],[],[],[]],[[],[],[],[],[]]],u:function(){var t,e,r,n,i,u,o,s=this.p[0],a=this.p[1],c=s[4],l=a[4],f=[],h=[];for(t=0;256>t;t++)h[(f[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!c[e];e^=n||1,r=h[r]||1)for(u=r^r<<1^r<<2^r<<3^r<<4,u=u>>8^255&u^99,c[e]=u,l[u]=e,i=f[t=f[n=f[e]]],o=16843009*i^65537*t^257*n^16843008*e,i=257*f[u]^16843008*u,t=0;4>t;t++)s[t][e]=i=i<<24^i>>>8,a[t][u]=o=o<<24^o>>>8;for(t=0;5>t;t++)s[t]=s[t].slice(0),a[t]=a[t].slice(0)}},d.bitArray={bitSlice:function(t,e,r){return t=d.bitArray.R(t.slice(e/32),32-(31&e)).slice(1),r===h?t:d.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<0&&e&&(t[r-1]=d.bitArray.partial(e,t[r-1]&2147483648>>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(d.bitArray.bitLength(t)!==d.bitArray.bitLength(e))return p;var r,n=0;for(r=0;r=32;e-=32)n.push(r),r=0;if(0===e)return n.concat(t);for(i=0;i>>e),r=t[i]<<32-e;return i=t.length?t[t.length-1]:0,t=d.bitArray.getPartial(i),n.push(d.bitArray.partial(e+t&31,e+t>32?r:n.pop(),1)),n},q:function(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]},byteswapM:function(t){var e,r;for(e=0;e>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},d.codec.utf8String={fromBits:function(t){var e,r,n="",i=d.bitArray.bitLength(t);for(e=0;i/8>e;e++)0===(3&e)&&(r=t[e/4]),n+=String.fromCharCode(r>>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],n=0;for(e=0;e>>i)>>>26),6>i?(o=t[r]<<6-i,i+=26,r++):(o<<=6,i-=6);for(;3&n.length&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,i,u=[],o=0,s=d.codec.base64.M,a=0;for(e&&(s=s.substr(0,62)+"-_"),r=0;ri&&n(new d.exception.invalid("this isn't base64!")),o>26?(o-=26,u.push(a^i>>>o),a=i<<32-o):(o+=6,a^=i<<32-o);return 56&o&&u.push(d.bitArray.partial(56&o,a,1)),u}},d.codec.base64url={fromBits:function(t){return d.codec.base64.fromBits(t,1,1)},toBits:function(t){return d.codec.base64.toBits(t,1)}},d.hash.sha256=function(t){this.b[0]||this.u(),t?(this.e=t.e.slice(0),this.c=t.c.slice(0),this.a=t.a):this.reset()},d.hash.sha256.hash=function(t){return(new d.hash.sha256).update(t).finalize()},d.hash.sha256.prototype={blockSize:512,reset:function(){return this.e=this.i.slice(0),this.c=[],this.a=0,this},update:function(t){"string"==typeof t&&(t=d.codec.utf8String.toBits(t));var e,r=this.c=d.bitArray.concat(this.c,t);for(e=this.a,t=this.a=e+d.bitArray.bitLength(t),e=512+e&-512;t>=e;e+=512)this.h(r.splice(0,16));return this},finalize:function(){var t,e=this.c,r=this.e,e=d.bitArray.concat(e,[d.bitArray.partial(1,1)]);for(t=e.length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.a/4294967296)),e.push(0|this.a);e.length;)this.h(e.splice(0,16));return this.reset(),r},i:[],b:[],u:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}var e,r=0,n=2;t:for(;64>r;n++){for(e=2;n>=e*e;e++)if(0===n%e)continue t;8>r&&(this.i[r]=t(Math.pow(n,.5))),this.b[r]=t(Math.pow(n,1/3)),r++}},h:function(t){var e,r,n=t.slice(0),i=this.e,u=this.b,o=i[0],s=i[1],a=i[2],c=i[3],l=i[4],f=i[5],h=i[6],p=i[7];for(t=0;64>t;t++)16>t?e=n[t]:(e=n[t+1&15],r=n[t+14&15],e=n[15&t]=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+n[15&t]+n[t+9&15]|0),e=e+p+(l>>>6^l>>>11^l>>>25^l<<26^l<<21^l<<7)+(h^l&(f^h))+u[t],p=h,h=f,f=l,l=c+e|0,c=a,a=s,s=o,o=e+(s&a^c&(s^a))+(s>>>2^s>>>13^s>>>22^s<<30^s<<19^s<<10)|0;i[0]=i[0]+o|0,i[1]=i[1]+s|0,i[2]=i[2]+a|0,i[3]=i[3]+c|0,i[4]=i[4]+l|0,i[5]=i[5]+f|0,i[6]=i[6]+h|0,i[7]=i[7]+p|0}},d.mode.ccm={name:"ccm",encrypt:function(t,e,r,i,u){var o,s=e.slice(0),a=d.bitArray,c=a.bitLength(r)/8,l=a.bitLength(s)/8;for(u=u||64,i=i||[],7>c&&n(new d.exception.invalid("ccm: iv must be at least 7 bytes")),o=2;4>o&&l>>>8*o;o++);return 15-c>o&&(o=15-c),r=a.clamp(r,8*(15-o)),e=d.mode.ccm.O(t,e,r,i,u,o),s=d.mode.ccm.t(t,s,r,e,u,o),a.concat(s.data,s.tag)},decrypt:function(t,e,r,i,u){u=u||64,i=i||[];var o=d.bitArray,s=o.bitLength(r)/8,a=o.bitLength(e),c=o.clamp(e,a-u),l=o.bitSlice(e,a-u),a=(a-u)/8;for(7>s&&n(new d.exception.invalid("ccm: iv must be at least 7 bytes")),e=2;4>e&&a>>>8*e;e++);return 15-s>e&&(e=15-s),r=o.clamp(r,8*(15-e)),c=d.mode.ccm.t(t,c,r,l,u,e),t=d.mode.ccm.O(t,c.data,r,i,u,e),o.equal(c.tag,t)||n(new d.exception.corrupt("ccm: tag doesn't match")),c.data},O:function(t,e,r,i,u,o){var s=[],a=d.bitArray,c=a.q;if(u/=8,(u%2||4>u||u>16)&&n(new d.exception.invalid("ccm: invalid tag length")),(4294967295=r?s=[a.partial(16,r)]:4294967295>=r&&(s=a.concat([a.partial(16,65534)],[r])),s=a.concat(s,i),i=0;io;o+=4)r[3]++,i=t.encrypt(r),e[o]^=i[0],e[o+1]^=i[1],e[o+2]^=i[2],e[o+3]^=i[3];return{tag:n,data:s.clamp(e,c)}}},d.mode.ocb2={name:"ocb2",encrypt:function(t,e,r,i,u,o){128!==d.bitArray.bitLength(r)&&n(new d.exception.invalid("ocb iv must be 128 bits"));var s,a=d.mode.ocb2.K,c=d.bitArray,l=c.q,f=[0,0,0,0];r=a(t.encrypt(r));var h,p=[];for(i=i||[],u=u||64,s=0;s+4r+4;r+=4)s=f(p,t.decrypt(f(p,e.slice(r,r+4)))),h=f(h,s),y=y.concat(s),p=c(p);return a=v-32*r,s=t.encrypt(f(p,[0,0,0,a])),s=f(s,l.clamp(e.slice(r),a).concat([0,0,0])),h=f(h,s),h=t.encrypt(f(h,f(p,c(p)))),i.length&&(h=f(h,o?i:d.mode.ocb2.pmac(t,i))),l.equal(l.clamp(h,u),l.bitSlice(e,v))||n(new d.exception.corrupt("ocb: tag doesn't match")),y.concat(l.clamp(s,a))},pmac:function(t,e){var r,n=d.mode.ocb2.K,i=d.bitArray,u=i.q,o=[0,0,0,0],s=t.encrypt([0,0,0,0]),s=u(s,n(n(s)));for(r=0;r+4i.bitLength(r)&&(s=u(s,n(s)),r=i.concat(r,[-2147483648,0,0,0])),o=u(o,r),t.encrypt(u(n(u(s,n(s))),o))},K:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},d.mode.gcm={name:"gcm",encrypt:function(t,e,r,n,i){var u=e.slice(0);return e=d.bitArray,n=n||[],t=d.mode.gcm.t(!0,t,u,n,r,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,u){var o=e.slice(0),s=d.bitArray,a=s.bitLength(o);return u=u||128,i=i||[],a>=u?(e=s.bitSlice(o,a-u),o=s.bitSlice(o,0,a-u)):(e=o,o=[]),t=d.mode.gcm.t(p,t,o,i,r,u),s.equal(t.tag,e)||n(new d.exception.corrupt("gcm: tag doesn't match")),t.data},ba:function(t,e){var r,n,i,u,o,s=d.bitArray.q;for(i=[0,0,0,0],u=e.slice(0),r=0;128>r;r++){for((n=0!==(t[Math.floor(r/32)]&1<<31-r%32))&&(i=s(i,u)),o=0!==(1&u[3]),n=3;n>0;n--)u[n]=u[n]>>>1|(1&u[n-1])<<31;u[0]>>>=1,o&&(u[0]^=-520093696)}return i},m:function(t,e,r){var n,i=r.length;for(e=e.slice(0),n=0;i>n;n+=4)e[0]^=4294967295&r[n],e[1]^=4294967295&r[n+1],e[2]^=4294967295&r[n+2],e[3]^=4294967295&r[n+3],e=d.mode.gcm.ba(e,t);return e},t:function(t,e,r,n,i,u){var o,s,a,c,l,f,h,p,v=d.bitArray;for(f=r.length,h=v.bitLength(r),p=v.bitLength(n),s=v.bitLength(i),o=e.encrypt([0,0,0,0]),96===s?(i=i.slice(0),i=v.concat(i,[1])):(i=d.mode.gcm.m(o,[0,0,0,0],i),i=d.mode.gcm.m(o,i,[0,0,Math.floor(s/4294967296),4294967295&s])),s=d.mode.gcm.m(o,[0,0,0,0],n),l=i.slice(0),n=s.slice(0),t||(n=d.mode.gcm.m(o,s,r)),c=0;f>c;c+=4)l[3]++,a=e.encrypt(l),r[c]^=a[0],r[c+1]^=a[1],r[c+2]^=a[2],r[c+3]^=a[3];return r=v.clamp(r,h),t&&(n=d.mode.gcm.m(o,s,r)),t=[Math.floor(p/4294967296),4294967295&p,Math.floor(h/4294967296),4294967295&h],n=d.mode.gcm.m(o,n,t),a=e.encrypt(i),n[0]^=a[0],n[1]^=a[1],n[2]^=a[2],n[3]^=a[3],{tag:v.bitSlice(n,0,u),data:r}}},d.misc.hmac=function(t,e){this.P=e=e||d.hash.sha256;var r,n=[[],[]],i=e.prototype.blockSize/32;for(this.s=[new e,new e],t.length>i&&(t=e.hash(t)),r=0;i>r;r++)n[0][r]=909522486^t[r],n[1][r]=1549556828^t[r];this.s[0].update(n[0]),this.s[1].update(n[1]),this.J=new e(this.s[0])},d.misc.hmac.prototype.encrypt=d.misc.hmac.prototype.mac=function(t){return this.T&&n(new d.exception.invalid("encrypt on already updated hmac called!")),this.update(t),this.digest(t)},d.misc.hmac.prototype.reset=function(){this.J=new this.P(this.s[0]),this.T=p},d.misc.hmac.prototype.update=function(t){this.T=!0,this.J.update(t)},d.misc.hmac.prototype.digest=function(){var t=this.J.finalize(),t=new this.P(this.s[1]).update(t).finalize();return this.reset(),t},d.misc.pbkdf2=function(t,e,r,i,u){r=r||1e3,(0>i||0>r)&&n(d.exception.invalid("invalid params to pbkdf2")),"string"==typeof t&&(t=d.codec.utf8String.toBits(t)),"string"==typeof e&&(e=d.codec.utf8String.toBits(e)),u=u||d.misc.hmac,t=new u(t);var o,s,a,c,l=[],f=d.bitArray;for(c=1;32*l.length<(i||1);c++){for(u=o=t.encrypt(f.concat(e,[c])),s=1;r>s;s++)for(o=t.encrypt(o),a=0;ao;o++)u.push(4294967296*Math.random()|0);for(o=0;o=1<this.o&&(this.o=c),this.I++,this.b=d.hash.sha256.hash(this.b.concat(u)),this.F=new d.cipher.aes(this.b),r=0;4>r&&(this.l[r]=this.l[r]+1|0,!this.l[r]);r++);}for(r=0;t>r;r+=4)0===(r+1)%this.V&&s(this),u=a(this),i.push(u[0],u[1],u[2],u[3]);return s(this),i.slice(0,t)},setDefaultParanoia:function(t,e){0===t&&"Setting paranoia=0 will ruin your security; use it only for testing"!==e&&n("Setting paranoia=0 will ruin your security; use it only for testing"),this.G=t},addEntropy:function(t,e,r){r=r||"user";var i,o,s=(new Date).valueOf(),a=this.A[r],c=this.isReady(),l=0;switch(i=this.N[r],i===h&&(i=this.N[r]=this.Z++),a===h&&(a=this.A[r]=0),this.A[r]=(this.A[r]+1)%this.g.length,typeof t){case"number":e===h&&(e=1),this.g[a].update([i,this.H++,1,e,s,1,0|t]);break;case"object":if(r=Object.prototype.toString.call(t),"[object Uint32Array]"===r){for(o=[],r=0;r0;)e++,o>>>=1;this.g[a].update([i,this.H++,2,e,s,t.length].concat(t))}break;case"string":e===h&&(e=t.length),this.g[a].update([i,this.H++,3,e,s,t.length]),this.g[a].update(t);break;default:l=1}l&&n(new d.exception.bug("random: addEntropy only supports number, array of numbers or string")),this.n[a]+=e,this.j+=e,c===this.r&&(this.isReady()!==this.r&&u("seeded",Math.max(this.o,this.j)),u("progress",this.getProgress()))},isReady:function(t){return t=this.L[t!==h?t:this.G],this.o&&this.o>=t?this.n[0]>this.U&&(new Date).valueOf()>this.Q?this.C|this.B:this.B:this.j>=t?this.C|this.r:this.r},getProgress:function(t){return t=this.L[t?t:this.G],this.o>=t?1:this.j>t?1:this.j/t},startCollectors:function(){this.w||(this.d={loadTimeCollector:c(this,this.fa),mouseCollector:c(this,this.ga),keyboardCollector:c(this,this.da),accelerometerCollector:c(this,this.X)},window.addEventListener?(window.addEventListener("load",this.d.loadTimeCollector,p),window.addEventListener("mousemove",this.d.mouseCollector,p),window.addEventListener("keypress",this.d.keyboardCollector,p),window.addEventListener("devicemotion",this.d.accelerometerCollector,p)):document.attachEvent?(document.attachEvent("onload",this.d.loadTimeCollector),document.attachEvent("onmousemove",this.d.mouseCollector),document.attachEvent("keypress",this.d.keyboardCollector)):n(new d.exception.bug("can't attach event")),this.w=!0)},stopCollectors:function(){this.w&&(window.removeEventListener?(window.removeEventListener("load",this.d.loadTimeCollector,p),window.removeEventListener("mousemove",this.d.mouseCollector,p),window.removeEventListener("keypress",this.d.keyboardCollector,p),window.removeEventListener("devicemotion",this.d.accelerometerCollector,p)):document.detachEvent&&(document.detachEvent("onload",this.d.loadTimeCollector),document.detachEvent("onmousemove",this.d.mouseCollector),document.detachEvent("keypress",this.d.keyboardCollector)),this.w=p)},addEventListener:function(t,e){this.D[t][this.Y++]=e},removeEventListener:function(t,e){var r,n,i=this.D[t],u=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&u.push(n);for(r=0;r=s.iter||64!==s.ts&&96!==s.ts&&128!==s.ts||128!==s.ks&&192!==s.ks&&256!==s.ks||2>s.iv.length||4=e.iter||64!==e.ts&&96!==e.ts&&128!==e.ts||128!==e.ks&&192!==e.ks&&256!==e.ks||!e.iv||2>e.iv.length||4=this.limbs.length?0:this.limbs[t]},greaterEquals:function(t){"number"==typeof t&&(t=new this.f(t));var e,r,n,i=0,u=0;for(e=Math.max(this.limbs.length,t.limbs.length)-1;e>=0;e--)r=this.getLimb(e),n=t.getLimb(e),u|=n-r&~i,i|=r-n&~u;return(u|~i)>>>31},toString:function(){this.fullReduce();var t,e,r="",n=this.limbs;for(t=0;te.length;)e="0"+e;r=e+r}return"0x"+r},addM:function(t){"object"!=typeof t&&(t=new this.f(t));var e=this.limbs,r=t.limbs;for(t=e.length;t>n;return r&&u.push(r),this},halveM:function(){var t,e,r=0,n=this.radix,i=this.limbs;for(t=i.length-1;t>=0;t--)e=i[t],i[t]=e+r>>1,r=(1&e)<0;n--)t.halveM(),r.greaterEquals(t)&&r.subM(t).normalize();return r.trim()},inverseMod:function(t){var e,r=new d.bn(1),i=new d.bn(0),u=new d.bn(this),o=new d.bn(t),s=1;1&t.limbs[0]||n(new d.exception.invalid("inverseMod: p must be odd"));do for(1&u.limbs[0]&&(u.greaterEquals(o)||(e=u,u=o,o=e,e=r,r=i,i=e),u.subM(o),u.normalize(),r.greaterEquals(i)||r.addM(t),r.subM(i)),u.halveM(),1&r.limbs[0]&&r.addM(t),r.normalize(),r.halveM(),e=s=0;ee;e++){for(r=n[e],t=0;o>t;t++)a[e+t]+=r*i[t];--c||(c=this.maxMul,s.cnormalize())}return s.cnormalize().reduce()},square:function(){return this.mul(this)},power:function(t){"number"==typeof t?t=[t]:t.limbs!==h&&(t=t.normalize().limbs);var e,r,n=new this.f(1),i=this;for(e=0;et||0!==r&&-1!==r;t++)r=(u[t]||0)+r,e=u[t]=r&s,r=(r-e)*i;return-1===r&&(u[t-1]-=n),this},cnormalize:function(){var t,e,r=0,n=this.ipv,i=this.limbs,u=i.length,o=this.radixMask;for(t=0;u-1>t;t++)r=i[t]+r,e=i[t]=r&o,r=(r-e)*n;return i[t]+=r,this},toBits:function(t){this.fullReduce(),t=t||this.exponent||this.bitLength();var e=Math.floor((t-1)/24),r=d.bitArray,n=[r.partial((t+7&-8)%this.radix||this.radix,this.getLimb(e))];for(e--;e>=0;e--)n=r.concat(n,[r.partial(Math.min(this.radix,t),this.getLimb(e))]),t-=this.radix;return n},bitLength:function(){this.fullReduce();for(var t=this.radix*(this.limbs.length-1),e=this.limbs[this.limbs.length-1];e;e>>>=1)t++;return t+7&-8}},d.bn.fromBits=function(t){var e=new this,r=[],n=d.bitArray,i=this.prototype,u=Math.min(this.bitLength||4294967296,n.bitLength(t)),o=u%i.radix||i.radix;for(r[0]=n.extract(t,0,o);u>o;o+=i.radix)r.unshift(n.extract(t,o,i.radix));return e.limbs=r,e},d.bn.prototype.ipv=1/(d.bn.prototype.placeVal=Math.pow(2,d.bn.prototype.radix)),d.bn.prototype.radixMask=(1<i;){for(r=u.pop(),n=u.length,e=0;s>e;e++)u[n+o[e]]-=a[e]*r;t--,t||(u.push(0),this.cnormalize(),t=this.minOffset)}return this.cnormalize(),this},u.S=-1===u.fullMask?u.reduce:function(){var t,e,r=this.limbs,n=r.length-1;if(this.reduce(),n===this.modOffset-1){for(e=r[n]&this.fullMask,r[n]-=e,t=0;tr[i-1]&&(r[i-1]+=4294967296);while(Math.floor(r[i-1]/u)===Math.floor(4294967296/u));for(r[i-1]%=u,n=0;i-1>n;n++)r[n]&=t.radixMask;if(o.limbs=r,!o.greaterEquals(t))return o}},d.codec.bytes={fromBits:function(t){var e,r,n=[],i=d.bitArray.bitLength(t);for(e=0;i/8>e;e++)0===(3&e)&&(r=t[e/4]),n.push(r>>>24),r<<=8;return n},toBits:function(t){var e,r=[],n=0;for(e=0;e=e;e+=1024)this.h(r.splice(0,32));return this},finalize:function(){var t,e=this.c,r=this.e,e=d.bitArray.concat(e,[d.bitArray.partial(1,1)]);for(t=e.length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.a/4294967296)),e.push(0|this.a);e.length;)this.h(e.splice(0,32));return this.reset(),r},i:[],ca:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],ea:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],u:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}var r,n=0,i=2;t:for(;80>n;i++){for(r=2;i>=r*r;r++)if(0===i%r)continue t;8>n&&(this.i[2*n]=t(Math.pow(i,.5)),this.i[2*n+1]=e(Math.pow(i,.5))<<24|this.ca[n]),this.b[2*n]=t(Math.pow(i,1/3)),this.b[2*n+1]=e(Math.pow(i,1/3))<<24|this.ea[n],n++}},h:function(t){var e,r,n=t.slice(0),i=this.e,u=this.b,o=i[0],s=i[1],a=i[2],c=i[3],l=i[4],f=i[5],h=i[6],p=i[7],d=i[8],v=i[9],y=i[10],g=i[11],_=i[12],m=i[13],b=i[14],w=i[15],A=o,E=s,F=a,C=c,B=l,D=f,k=h,x=p,j=d,T=v,P=y,R=g,S=_,I=m,O=b,U=w;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)];var L=n[2*(t-15)+1];e=(L<<31|r>>>1)^(L<<24|r>>>8)^r>>>7;var M=(r<<31|L>>>1)^(r<<24|L>>>8)^(r<<25|L>>>7);r=n[2*(t-2)];var z=n[2*(t-2)+1],L=(z<<13|r>>>19)^(r<<3|z>>>29)^r>>>6,z=(r<<13|z>>>19)^(z<<3|r>>>29)^(r<<26|z>>>6),N=n[2*(t-7)],H=n[2*(t-16)],V=n[2*(t-16)+1];r=M+n[2*(t-7)+1],e=e+N+(M>>>0>r>>>0?1:0),r+=z,e+=L+(z>>>0>r>>>0?1:0),r+=V,e+=H+(V>>>0>r>>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;var N=j&P^~j&S,K=T&R^~T&I,z=A&F^A&B^F&B,q=E&C^E&D^C&D,H=(E<<4|A>>>28)^(A<<30|E>>>2)^(A<<25|E>>>7),V=(A<<4|E>>>28)^(E<<30|A>>>2)^(E<<25|A>>>7),Y=u[2*t],$=u[2*t+1],L=U+((j<<18|T>>>14)^(j<<14|T>>>18)^(T<<23|j>>>9)),M=O+((T<<18|j>>>14)^(T<<14|j>>>18)^(j<<23|T>>>9))+(U>>>0>L>>>0?1:0),L=L+K,M=M+(N+(K>>>0>L>>>0?1:0)),L=L+$,M=M+(Y+($>>>0>L>>>0?1:0)),L=L+r|0,M=M+(e+(r>>>0>L>>>0?1:0));r=V+q,e=H+z+(V>>>0>r>>>0?1:0),O=S,U=I,S=P,I=R,P=j,R=T,T=x+L|0,j=k+M+(x>>>0>T>>>0?1:0)|0,k=B,x=D,B=F,D=C,F=A,C=E,E=L+r|0,A=M+e+(L>>>0>E>>>0?1:0)|0}s=i[1]=s+E|0,i[0]=o+A+(E>>>0>s>>>0?1:0)|0,c=i[3]=c+C|0,i[2]=a+F+(C>>>0>c>>>0?1:0)|0,f=i[5]=f+D|0,i[4]=l+B+(D>>>0>f>>>0?1:0)|0,p=i[7]=p+x|0,i[6]=h+k+(x>>>0>p>>>0?1:0)|0,v=i[9]=v+T|0,i[8]=d+j+(T>>>0>v>>>0?1:0)|0,g=i[11]=g+R|0,i[10]=y+P+(R>>>0>g>>>0?1:0)|0,m=i[13]=m+I|0,i[12]=_+S+(I>>>0>m>>>0?1:0)|0,w=i[15]=w+U|0,i[14]=b+O+(U>>>0>w>>>0?1:0)|0}},d.hash.sha1=function(t){t?(this.e=t.e.slice(0),this.c=t.c.slice(0),this.a=t.a):this.reset()},d.hash.sha1.hash=function(t){return(new d.hash.sha1).update(t).finalize()},d.hash.sha1.prototype={blockSize:512,reset:function(){return this.e=this.i.slice(0),this.c=[],this.a=0,this},update:function(t){"string"==typeof t&&(t=d.codec.utf8String.toBits(t));var e,r=this.c=d.bitArray.concat(this.c,t);for(e=this.a,t=this.a=e+d.bitArray.bitLength(t),e=this.blockSize+e&-this.blockSize;t>=e;e+=this.blockSize)this.h(r.splice(0,16));return this},finalize:function(){var t,e=this.c,r=this.e,e=d.bitArray.concat(e,[d.bitArray.partial(1,1)]);for(t=e.length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.a/4294967296)),e.push(0|this.a);e.length;)this.h(e.splice(0,16));return this.reset(),r},i:[1732584193,4023233417,2562383102,271733878,3285377520],b:[1518500249,1859775393,2400959708,3395469782],h:function(t){var e,r,n,i,u,o,s=t.slice(0),a=this.e;for(r=a[0],n=a[1],i=a[2],u=a[3],o=a[4],t=0;79>=t;t++)t>=16&&(s[t]=(s[t-3]^s[t-8]^s[t-14]^s[t-16])<<1|(s[t-3]^s[t-8]^s[t-14]^s[t-16])>>>31),e=19>=t?n&i|~n&u:39>=t?n^i^u:59>=t?n&i|n&u|i&u:79>=t?n^i^u:h,e=(r<<5|r>>>27)+e+o+s[t]+this.b[Math.floor(t/20)]|0,o=u,u=i,i=n<<30|n>>>2,n=r,r=e;a[0]=a[0]+r|0,a[1]=a[1]+n|0,a[2]=a[2]+i|0,a[3]=a[3]+u|0,a[4]=a[4]+o|0}}},function(t){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e,r){"use strict";function n(t,e,r){try{return t.call(e,r)}catch(n){return E.e=n,E}}function i(t,e,r,n){try{return t.call(e,r,n)}catch(i){return E.e=i,E}}function u(t,e,r,n,i){try{return t.call(e,r,n,i)}catch(u){return E.e=u,E}}function o(t,e,r,n,i,u){try{return t.call(e,r,n,i,u)}catch(o){return E.e=o,E}}function s(t,e,r){try{return t.apply(r,e)}catch(n){return E.e=n,E}}function a(t){return"string"==typeof t?t:""+t}function c(t){return null==t||t===!0||t===!1||"string"==typeof t||"number"==typeof t}function l(t){return!c(t)}function f(t){return c(t)?new Error(a(t)):t}function h(t,e){var r,n=t.length,i=new Array(n+1);for(r=0;n>r;++r)i[r]=t[r];return i[r]=e,i}function p(t,e,r){if(!b.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var n=Object.getOwnPropertyDescriptor(t,e);return null!=n?null==n.get&&null==n.set?n.value:r:void 0}function d(t,e,r){if(c(t))return t;var n={value:r,configurable:!0,enumerable:!1,writable:!0};return b.defineProperty(t,e,n),t}function v(t){throw t}function y(t){try{if("function"==typeof t){var e=b.keys(t.prototype);return e.length>0&&!(1===e.length&&"constructor"===e[0])}return!1}catch(r){return!1}}function g(t){function e(){}return e.prototype=t,e}function _(t){return D.test(t)}function m(t,e,r){for(var n=new Array(t),i=0;t>i;++i)n[i]=e+i+r;return n}var b=r(66),w=function(){try{var t={};return b.defineProperty(t,"f",{get:function(){return 3}}),3===t.f}catch(e){return!1}}(),A="undefined"==typeof navigator,E={e:{}},F=function(t,e){function r(){this.constructor=t,this.constructor$=e;for(var r in e.prototype)n.call(e.prototype,r)&&"$"!==r.charAt(r.length-1)&&(this[r+"$"]=e.prototype[r])}var n={}.hasOwnProperty;return r.prototype=e.prototype,t.prototype=new r,t.prototype},C=function(){return"string"!==this}.call("string"),B=function(){return b.isES5?function(t,e){for(var r=[],n=Object.create(null),i=Object(e).includeHidden?Object.getOwnPropertyNames:Object.keys;null!=t;){var u;try{u=i(t)}catch(o){return r}for(var s=0;s0},n.prototype.invokeLater=function(t,e,r){void 0===a||null==a.domain||t.domain||(t=a.domain.bind(t)),this._lateBuffer.push(t,e,r),this._queueTick()},n.prototype.invoke=function(t,e,r){void 0===a||null==a.domain||t.domain||(t=a.domain.bind(t));var n=this._functionBuffer;n.push(t,e,r),this._length=n.length(),this._queueTick()},n.prototype._consumeFunctionBuffer=function(){for(var t=this._functionBuffer;t.length()>0;){var e=t.shift(),r=t.shift(),n=t.shift();e.call(r,n)}this._reset(),this._consumeLateBuffer()},n.prototype._consumeLateBuffer=function(){for(var t=this._lateBuffer;t.length()>0;){var e=t.shift(),r=t.shift(),n=t.shift(),i=s(e,r,n);if(i===o){if(this._queueTick(),null==e.domain)throw i.e;e.domain.emit("error",i.e)}}},n.prototype._queueTick=function(){this._isTickUsed||(this._schedule(this.consumeFunctionBuffer),this._isTickUsed=!0)},n.prototype._reset=function(){this._isTickUsed=!1,this._length=0},t.exports=new n}).call(e,r(57))},function(t,e,r){"use strict";function n(t){try{d(t,"isOperational",!0)}catch(e){}}function i(t){return null==t?!1:t instanceof a||t.isOperational===!0}function u(t){return t instanceof Error}function o(t){return u(t)}function s(t,e){function r(n){return this instanceof r?(this.message="string"==typeof n?n:e,this.name=t,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),void 0):new r(n)}return p(r,Error),r}function a(t){this.name="OperationalError",this.message=t,this.cause=t,this.isOperational=!0,t instanceof Error?(this.message=t.message,this.stack=t.stack):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}var c,l,f=r(66).freeze,h=r(27),p=h.inherits,d=h.notEnumerableProp,v=s("CancellationError","cancellation error"),y=s("TimeoutError","timeout error"),g=s("AggregateError","aggregate error");try{c=TypeError,l=RangeError}catch(_){c=s("TypeError","type error"),l=s("RangeError","range error")}for(var m="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),b=0;bp;++p){var d=n(u[p],void 0);d instanceof t?d.isPending()?d._proxyPromiseArray(this,p):(d._unsetRejectionIsUnhandled(),h=!0):h=!0,f[p]=d}this._values=f,this._length=l,h&&this._scanDirectValues(s)},u.prototype._settlePromiseAt=function(e){var r=this._values[e];r instanceof t?r.isFulfilled()?this._promiseFulfilled(r._settledValue,e):r.isRejected()&&this._promiseRejected(r._settledValue,e):this._promiseFulfilled(r,e)},u.prototype._scanDirectValues=function(t){for(var e=0;t>e&&!this._isResolved();++e)this._settlePromiseAt(e)},u.prototype._isResolved=function(){return null===this._values},u.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},u.prototype.__hardReject__=u.prototype._reject=function(t){this._values=null;var e=o(t)?t:new Error(t+"");this._promise._attachExtraTrace(e),this._promise._reject(t,e)},u.prototype._promiseProgressed=function(t,e){this._isResolved()||this._promise._progress({index:e,value:t})},u.prototype._promiseFulfilled=function(t,e){if(!this._isResolved()){this._values[e]=t;var r=++this._totalResolved;r>=this._length&&this._resolve(this._values)}},u.prototype._promiseRejected=function(t){this._isResolved()||(this._totalResolved++,this._reject(t))},u.prototype.shouldCopyValues=function(){return!0},u.prototype.getActualLength=function(t){return t},u}},function(t,e,r){"use strict";t.exports=function(){function t(t){var r;if("function"==typeof t)r="[function "+(t.name||"anonymous")+"]";else{r=t.toString();var n=/\[object [a-zA-Z0-9$_]+\]/;if(n.test(r))try{var i=JSON.stringify(t);r=i}catch(u){}0===r.length&&(r="(empty array)")}return"(<"+e(r)+">, no stack trace)"}function e(t){var e=41;return t.length=0;--n){var i=e[n];if(t[r]!==i)break;t.pop(),r--}t.push("From previous event:");for(var u=t.concat(e),a=[],n=0,c=u.length;c>n;++n)o.test(u[n])&&s.test(u[n])||n>0&&!s.test(u[n])&&"From previous event:"!==u[n]||a.push(u[n]);return a},n.protectErrorMessageNewlines=function(t){for(var e=0;e=e)){for(var r=[],n=0;e>n;++n)r.push(t.shift());t.unshift(r.join("\x00"))}},n.isSupported=function(){return"function"==typeof c};var c=function l(){if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){s=/^\s*at\s*/,a=function(e,r){return"string"==typeof e?e:void 0!==r.name&&void 0!==r.message?r.name+". "+r.message:t(r)};var e=Error.captureStackTrace;return function(t,r){e(t,r)}}var r=new Error;if("string"==typeof r.stack&&"function"==typeof"".startsWith&&r.stack.startsWith("stackDetection@")&&"stackDetection"===l.name){u(Error,"stackTraceLimit",{writable:!0,enumerable:!1,configurable:!1,value:25}),s=/@/;var n=/[@\n]/;return a=function(e,r){return"string"==typeof e?r.name+". "+r.message+"\n"+e:void 0!==r.name&&void 0!==r.message?r.name+". "+r.message:t(r)},function(t){for(var e=(new Error).stack,r=e.split(n),i=r.length,u="",o=0;i>o;o+=2)u+=r[o],u+="@",u+=r[o+1],u+="\n";t.stack=u}}return a=function(e,r){return"string"==typeof e?e:"object"!=typeof r&&"function"!=typeof r||void 0===r.name||void 0===r.message?t(r):r.name+". "+r.message},null}();return n}},function(t,e,r){"use strict";t.exports=function(t){function e(t,e,r){this._instances=t,this._callback=e,this._promise=r}function n(t,e){var r={},n=o(t,r,e);if(n===s)return n;var i=a(r);return i.length?(s.e=new c("Catch filter must inherit from Error or be a simple predicate function"),s):n}var i=r(27),u=r(29),o=i.tryCatch1,s=i.errorObj,a=r(66).keys,c=u.TypeError;return e.prototype.doFilter=function(e){for(var r=this._callback,i=this._promise,a=i._boundTo,c=0,l=this._instances.length;l>c;++c){var f=this._instances[c],h=f===Error||null!=f&&f.prototype instanceof Error;if(h&&e instanceof f){var p=o(r,a,e);return p===s?(t.e=p.e,t):p}if("function"==typeof f&&!h){var d=n(f,e);if(d===s){var v=u.canAttach(s.e)?s.e:new Error(s.e+"");this._promise._attachExtraTrace(v),e=s.e;break}if(d){var p=o(r,a,e);return p===s?(t.e=p.e,t):p}}}return t.e=e,t},e}},function(t,e,r){"use strict";function n(t){return t instanceof Error&&d.getPrototypeOf(t)===Error.prototype}function i(t){var e;return e=n(t)?new f(t):t,c.markAsOriginatingFromRejection(e),e}function u(t){function e(e,r){if(null!==t){if(e){var n=i(a(e));t._attachExtraTrace(n),t._reject(n)}else if(arguments.length>2){for(var u=arguments.length,o=new Array(u-1),s=1;u>s;++s)o[s-1]=arguments[s];t._fulfill(o)}else t._fulfill(r);t=null}}return e}var o,s=r(27),a=s.maybeWrapAsError,c=r(29),l=c.TimeoutError,f=c.OperationalError,h=r(28),p=s.haveGetters,d=r(66);if(o=p?function(t){this.promise=t}:function(t){this.promise=t,this.asCallback=u(t),this.callback=this.asCallback},p){var v={get:function(){return u(this.promise)}};d.defineProperty(o.prototype,"asCallback",v),d.defineProperty(o.prototype,"callback",v)}o._nodebackForPromise=u,o.prototype.toString=function(){return"[object PromiseResolver]"},o.prototype.resolve=o.prototype.fulfill=function(t){if(!(this instanceof o))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.");var e=this.promise;e._tryFollow(t)||h.invoke(e._fulfill,e,t)},o.prototype.reject=function(t){if(!(this instanceof o))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.");var e=this.promise;c.markAsOriginatingFromRejection(t);var r=c.canAttach(t)?t:new Error(t+"");e._attachExtraTrace(r),h.invoke(e._reject,e,t),r!==t&&h.invoke(this._setCarriedStackTrace,this,r)},o.prototype.progress=function(t){if(!(this instanceof o))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.");h.invoke(this.promise._progress,this.promise,t)},o.prototype.cancel=function(){h.invoke(this.promise.cancel,this.promise,void 0)},o.prototype.timeout=function(){this.reject(new l("timeout"))},o.prototype.isResolved=function(){return this.promise.isResolved()},o.prototype.toJSON=function(){return this.promise.toJSON()},o.prototype._setCarriedStackTrace=function(t){this.promise.isRejected()&&this.promise._setCarriedStackTrace(t)},t.exports=o},function(t,e,r){"use strict";t.exports=function(t){function e(e){var r=new n(e),i=t.rejected(r),u=i._peekContext();return null!=u&&u._attachExtraTrace(r),i}var n=r(29).TypeError;return e}},function(t,e,r){"use strict";t.exports=function(t,e,n){function i(){return this}function u(){throw this}function o(t){return function(){return t}}function s(t){return function(){throw t}}function a(t,e,r){var n;return n=h&&p(e)?r?o(e):s(e):r?i:u,t._then(n,d,void 0,e,void 0)}function c(r){var i=this.promise,u=this.handler,o=i._isBound()?u.call(i._boundTo):u();if(void 0!==o){var s=n(o,void 0);if(s instanceof t)return a(s,r,i.isFulfilled())}return i.isRejected()?(e.e=r,e):r}function l(e){var r=this.promise,i=this.handler,u=r._isBound()?i.call(r._boundTo,e):i(e);if(void 0!==u){var o=n(u,void 0);if(o instanceof t)return a(o,e,!0)}return e}var f=r(27),h=f.wrapsPrimitiveReceiver,p=f.isPrimitive,d=f.thrower;t.prototype._passThroughHandler=function(t,e){if("function"!=typeof t)return this.then();var r={promise:this,handler:t};return this._then(e?c:l,e?c:void 0,void 0,r,void 0)},t.prototype.lastly=t.prototype["finally"]=function(t){return this._passThroughHandler(t,!0)},t.prototype.tap=function(t){return this._passThroughHandler(t,!1)}}},function(t,e,r){"use strict";var n=r(27),i=n.isPrimitive,u=n.wrapsPrimitiveReceiver;t.exports=function(t){var e=function(){return this},r=function(){throw this},n=function(t,e){return 1===e?function(){throw t}:2===e?function(){return t}:void 0};t.prototype["return"]=t.prototype.thenReturn=function(t){return u&&i(t)?this._then(n(t,2),void 0,void 0,void 0,void 0):this._then(e,void 0,void 0,t,void 0)},t.prototype["throw"]=t.prototype.thenThrow=function(t){return u&&i(t)?this._then(n(t,1),void 0,void 0,void 0,void 0):this._then(r,void 0,void 0,t,void 0)}}},function(t){"use strict";t.exports=function(t){function e(t){void 0!==t?(this._bitField=t._bitField,this._settledValue=t.isResolved()?t._settledValue:void 0):(this._bitField=0,this._settledValue=void 0)}e.prototype.isFulfilled=t.prototype.isFulfilled=function(){return(268435456&this._bitField)>0},e.prototype.isRejected=t.prototype.isRejected=function(){return(134217728&this._bitField)>0},e.prototype.isPending=t.prototype.isPending=function(){return 0===(402653184&this._bitField)},e.prototype.value=t.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise");return this._settledValue},e.prototype.error=e.prototype.reason=t.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise");return this._settledValue},e.prototype.isResolved=t.prototype.isResolved=function(){return(402653184&this._bitField)>0},t.PromiseInspection=e}},function(t,e,r){"use strict";t.exports=function(t,e,n,i){var u=r(27),o=u.canEvaluate,s=u.tryCatch1,a=u.errorObj;if(o){for(var c=function(t){return new Function("value","holder"," \n 'use strict'; \n holder.pIndex = value; \n holder.checkFulfillment(this); \n ".replace(/Index/g,t))},l=function(t){for(var e=[],r=1;t>=r;++r)e.push("holder.p"+r);return new Function("holder"," \n 'use strict'; \n var callback = holder.fn; \n return callback(values); \n ".replace(/values/g,e.join(", ")))},f=[],h=[void 0],p=1;5>=p;++p)f.push(c(p)),h.push(l(p));var d=function(t,e){this.p1=this.p2=this.p3=this.p4=this.p5=null,this.fn=e,this.total=t,this.now=0};d.prototype.callers=h,d.prototype.checkFulfillment=function(t){var e=this.now;e++;var r=this.total;if(e>=r){var n=this.callers[r],i=s(n,void 0,this);i===a?t._rejectUnchecked(i.e):t._tryFollow(i)||t._fulfillUnchecked(i)}else this.now=e}}t.join=function(){var r,u=arguments.length-1;if(u>0&&"function"==typeof arguments[u]&&(r=arguments[u],6>u&&o)){var s=new t(i);s._setTrace(void 0);for(var a=new d(u,r),c=s._reject,l=f,h=0;u>h;++h){var p=n(arguments[h],void 0);p instanceof t?p.isPending()?p._then(l[h],c,void 0,s,a):p.isFulfilled()?l[h].call(s,p._settledValue,a):(s._reject(p._settledValue),p._unsetRejectionIsUnhandled()):l[h].call(s,p,a)}return s}for(var v=arguments.length,y=new Array(v),g=0;v>g;++g)y[g]=arguments[g];var s=new e(y).promise();return void 0!==r?s.spread(r):s}}},function(t,e,r){"use strict";var n=function(t,e){var r=arguments.length,n=arguments[2],i=arguments[3],u=r>=5?arguments[4]:void 0;setTimeout(function(){t(n,i,u)},0|e)};t.exports=function(t,e,i){var u=(r(27),r(29)),o=(r(35)(t),t.TimeoutError),s=function(t,e,r){if(t.isPending()){"string"!=typeof e&&(e="operation timed out after "+r+" ms");var n=new o(e);u.markAsOriginatingFromRejection(n),t._attachExtraTrace(n),t._cancel(n)}},a=function(t,e){e._fulfill(t)},c=t.delay=function(r,u){void 0===u&&(u=r,r=void 0),u=+u;var o=i(r,void 0),s=new t(e);return o instanceof t?(s._propagateFrom(o,7),s._follow(o),s.then(function(e){return t.delay(e,u)})):(s._setTrace(void 0),n(a,u,r,s),s)};t.prototype.delay=function(t){return c(this,t)},t.prototype.timeout=function(r,i){r=+r;var u=new t(e);return u._propagateFrom(this,7),u._follow(this),n(s,r,u,i,r),u.cancellable()}}},function(t,e,r){"use strict";t.exports=function(t,e,n){function i(r,i){var c=n(r,void 0);if(c instanceof t)return s(c);if(!o(r))return u("expecting an array, a promise or a thenable");var l=new t(e);void 0!==i?l._propagateFrom(i,7):l._setTrace(void 0);for(var f=l._fulfill,h=l._reject,p=0,d=r.length;d>p;++p){var v=r[p];(void 0!==v||a.call(r,p))&&t.cast(v)._then(f,h,void 0,l,null)}return l}var u=r(35)(t),o=r(27).isArray,s=function(t){return t.then(function(e){return i(e,t)})},a={}.hasOwnProperty;t.race=function(t){return i(t,void 0)},t.prototype.race=function(){return i(this,void 0)}}},function(t,e,r){"use strict";var n=Object.create;if(n){var i=n(null),u=n(null);i[" size"]=u[" size"]=0}t.exports=function(t){function e(t){return new Function("obj"," \n 'use strict' \n var len = this.length; \n switch(len) { \n case 1: return obj.methodName(this[0]); \n case 2: return obj.methodName(this[0], this[1]); \n case 3: return obj.methodName(this[0], this[1], this[2]); \n case 0: return obj.methodName(); \n default: return obj.methodName.apply(obj, this); \n } \n ".replace(/methodName/g,t))}function n(t){return new Function("obj"," \n 'use strict'; \n return obj.propertyName; \n ".replace("propertyName",t))}function o(t,e,r){var n=r[t];if("function"!=typeof n){if(!d(t))return null;if(n=e(t),r[t]=n,r[" size"]++,r[" size"]>512){for(var i=Object.keys(r),u=0;256>u;++u)delete r[i[u]];r[" size"]=i.length-256}}return n}function s(t){return o(t,e,i)}function a(t){return o(t,n,u)}function c(t){return t[this.pop()].apply(t,this)}function l(t){return t[this]}function f(t){return t[this]}var h=r(27),p=h.canEvaluate,d=h.isIdentifier;t.prototype.call=function(t){for(var e=arguments.length,r=new Array(e-1),n=1;e>n;++n)r[n-1]=arguments[n];if(p){var i=s(t);if(null!==i)return this._then(i,void 0,void 0,r,void 0)}return r.push(t),this._then(c,void 0,void 0,r,void 0)},t.prototype.get=function(t){var e,r="number"==typeof t;if(r)e=f;else if(p){var n=a(t);e=null!==n?n:l}else e=l;return this._then(e,void 0,void 0,t,void 0)}}},function(t,e,r){"use strict";t.exports=function(t,e,n,i){function u(e,r){for(var n=f,o=t,s=r.length,a=0;s>a;++a){var c=h(r[a],void 0,e);if(c===n)return o.reject(n.e);var l=i(c,u);if(l instanceof o)return l}return null}function o(e,r,i){var u=this._promise=new t(n);u._setTrace(void 0),this._generatorFunction=e,this._receiver=r,this._generator=void 0,this._yieldHandlers="function"==typeof i?[i].concat(p):p}var s=r(29),a=s.TypeError,c=r(27).deprecated,l=r(27),f=l.errorObj,h=l.tryCatch1,p=[];o.prototype.promise=function(){return this._promise},o.prototype._run=function(){this._generator=this._generatorFunction.call(this._receiver),this._receiver=this._generatorFunction=void 0,this._next(void 0)},o.prototype._continue=function(e){if(e===f){this._generator=void 0;var r=s.canAttach(e.e)?e.e:new Error(e.e+"");return this._promise._attachExtraTrace(r),this._promise._reject(e.e,r),void 0}var n=e.value;if(e.done===!0)this._generator=void 0,this._promise._tryFollow(n)||this._promise._fulfill(n);else{var o=i(n,void 0);if(!(o instanceof t)&&(o=u(o,this._yieldHandlers),null===o))return this._throw(new a("A value was yielded that could not be treated as a promise")),void 0;o._then(this._next,this._throw,void 0,this,null)}},o.prototype._throw=function(t){s.canAttach(t)&&this._promise._attachExtraTrace(t),this._continue(h(this._generator["throw"],this._generator,t))},o.prototype._next=function(t){this._continue(h(this._generator.next,this._generator,t)) -},t.coroutine=function(t,e){if("function"!=typeof t)throw new a("generatorFunction must be a function");var r=Object(e).yieldHandler,n=o;return function(){var e=t.apply(this,arguments),i=new n(void 0,void 0,r);return i._generator=e,i._next(void 0),i.promise()}},t.coroutine.addYieldHandler=function(t){if("function"!=typeof t)throw new a("fn must be a function");p.push(t)},t.spawn=function(r){if(c("Promise.spawn is deprecated. Use Promise.coroutine instead."),"function"!=typeof r)return e("generatorFunction must be a function");var n=new o(r,this),i=n.promise();return n._run(t.spawn),i}}},function(t,e,r){"use strict";t.exports=function(t,e,n,i,u){function o(t,e,r,n){this.constructor$(t),this._callback=e,this._preservedValues=n===u?new Array(this.length()):null,this._limit=r,this._inFlight=0,this._queue=r>=1?[]:h,this._init$(void 0,-2)}function s(t,e,r,n){var i="object"==typeof r&&null!==r?r.concurrency:0;return i="number"==typeof i&&isFinite(i)&&i>=1?i:0,new o(t,e,i,n)}var a=r(27),c=a.tryCatch3,l=a.errorObj,f={},h=[];a.inherits(o,e),o.prototype._init=function(){},o.prototype._promiseFulfilled=function(e,r){var n=this._values;if(null!==n){var u=this.length(),o=this._preservedValues,s=this._limit;if(n[r]===f){if(n[r]=e,s>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return}else{if(s>=1&&this._inFlight>=s)return n[r]=e,this._queue.push(r),void 0;null!==o&&(o[r]=e);var a=this._callback,h=this._promise._boundTo,p=c(a,h,e,r,u);if(p===l)return this._reject(p.e);var d=i(p,void 0);if(d instanceof t){if(d.isPending())return s>=1&&this._inFlight++,n[r]=f,d._proxyPromiseArray(this,r);if(!d.isFulfilled())return d._unsetRejectionIsUnhandled(),this._reject(d.reason());p=d.value()}n[r]=p}var v=++this._totalResolved;v>=u&&(null!==o?this._filter(n,o):this._resolve(n))}},o.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,r=this._values;t.length>0&&this._inFlightu;++u)t[u]&&(n[i++]=e[u]);n.length=i,this._resolve(n)},o.prototype.preservedValues=function(){return this._preservedValues},t.prototype.map=function(t,e){return"function"!=typeof t?n("fn must be a function"):s(this,t,e,null).promise()},t.map=function(t,e,r,i){return"function"!=typeof e?n("fn must be a function"):s(t,e,r,i).promise()}}},function(t,e,r){"use strict";t.exports=function(t){function e(t){throw t}function n(t,r){if(!o.isArray(t))return i(t,r);var n=o.tryCatchApply(this,[null].concat(t),r);n===l&&s.invokeLater(e,void 0,n.e)}function i(t,r){var n=this,i=void 0===t?c(n,r,null):a(n,r,null,t);i===l&&s.invokeLater(e,void 0,i.e)}function u(t,r){var n=this,i=c(n,r,t);i===l&&s.invokeLater(e,void 0,i.e)}var o=r(27),s=r(28),a=o.tryCatch2,c=o.tryCatch1,l=o.errorObj;t.prototype.nodeify=function(t,e){if("function"==typeof t){var r=i;void 0!==e&&Object(e).spread&&(r=n),this._then(r,u,void 0,t,this._boundTo)}return this}}},function(t,e,r){"use strict";t.exports=function(t,e){function n(t){return t.replace(/([$])/,"\\$")}function i(t){try{return t.__isPromisified__===!0}catch(e){return!1}}function u(t,e,r){var n=_.getDataPropertyOrDefault(t,e+r,B);return n?i(n):!1}function o(t,e,r){for(var n=0;n=r;--n)n!==t&&e.push(n);for(var n=t+1;5>=n;++n)e.push(n);return e}function c(t){return _.filledRange(t,"arguments[","]")}function l(t){return _.filledRange(t,"_arg","")}function f(t){return"number"==typeof t.length?Math.max(Math.min(t.length,1024),0):0}function h(t){return _.isIdentifier(t)?"."+t:"['"+t.replace(/(['\\])/g,"\\$1")+"']"}function p(r,n,i,u,o){function s(t){var e,i=c(t).join(", "),u=t>0?", ":"";return e="string"==typeof r?" \n this.method(args, fn); \n break; \n ".replace(".method",h(r)):n===g?" \n callback.call(this, args, fn); \n break; \n ":void 0!==n?" \n callback.call(receiver, args, fn); \n break; \n ":" \n callback(args, fn); \n break; \n ",e.replace("args",i).replace(", ",u)}function p(){for(var t="",e=0;ea;a+=2){var l=o[a],f=o[a+1],h=l+e;t[h]=i===D?D(l,g,l,f,e):i(f)}return _.toFastProperties(t),t}function y(t,e){return D(t,e,void 0,t)}var g={},_=r(27),m=r(34)._nodebackForPromise,b=_.withAppended,w=_.maybeWrapAsError,A=_.canEvaluate,E=r(29).TypeError,F="Async",C=function(t,e){return _.isIdentifier(t)&&"_"!==t.charAt(0)&&!_.isClass(e)},B={__isPromisified__:!0},D=A?p:d;t.promisify=function(t,e){if("function"!=typeof t)throw new E("fn must be a function");return i(t)?t:y(t,arguments.length<2?g:e)},t.promisifyAll=function(t,e){if("function"!=typeof t&&"object"!=typeof t)throw new E("the target of promisifyAll must be an object or a function");e=Object(e);var r=e.suffix;"string"!=typeof r&&(r=F);var n=e.filter;"function"!=typeof n&&(n=C);var i=e.promisifier;if("function"!=typeof i&&(i=D),!_.isIdentifier(r))throw new RangeError("suffix must be a valid identifier");for(var u=_.inheritedDataKeys(t,{includeHidden:!0}),o=0;oi;++i){var u=e[i];n[i]=t[u],n[i+r]=u}this.constructor$(n)}function u(e){var r,u=n(e,void 0);return a(u)?(r=u instanceof t?u._then(t.props,void 0,void 0,void 0,void 0):new i(u).promise(),u instanceof t&&r._propagateFrom(u,4),r):s("cannot await properties of a non-object")}var o=r(27),s=r(35)(t),a=o.isObject,c=r(66);o.inherits(i,e),i.prototype._init=function(){this._init$(void 0,-3)},i.prototype._promiseFulfilled=function(t,e){if(!this._isResolved()){this._values[e]=t;var r=++this._totalResolved;if(r>=this._length){for(var n={},i=this.length(),u=0,o=this.length();o>u;++u)n[this._values[u+i]]=this._values[u];this._resolve(n)}}},i.prototype._promiseProgressed=function(t,e){this._isResolved()||this._promise._progress({key:this._values[e+this.length()],value:t})},i.prototype.shouldCopyValues=function(){return!1},i.prototype.getActualLength=function(t){return t>>1},t.prototype.props=function(){return u(this)},t.props=function(t){return u(t)}}},function(t,e,r){"use strict";t.exports=function(t,e,n,i,u){function o(e,r,n,o){this.constructor$(e),this._preservedValues=o===u?[]:null,this._zerothIsAccum=void 0===n,this._gotAccum=!1,this._reducingIndex=this._zerothIsAccum?1:0,this._valuesPhase=void 0;var s=i(n,void 0),a=!1,c=s instanceof t;c&&(s.isPending()?s._proxyPromiseArray(this,-1):s.isFulfilled()?(n=s.value(),this._gotAccum=!0):(s._unsetRejectionIsUnhandled(),this._reject(s.reason()),a=!0)),c||this._zerothIsAccum||(this._gotAccum=!0),this._callback=r,this._accum=n,a||this._init$(void 0,-5)}function s(t,e,r,i){if("function"!=typeof e)return n("fn must be a function");var u=new o(t,e,r,i);return u.promise()}var a=r(27),c=a.tryCatch4,l=a.tryCatch3,f=a.errorObj;a.inherits(o,e),o.prototype._init=function(){},o.prototype._resolveEmptyArray=function(){(this._gotAccum||this._zerothIsAccum)&&this._resolve(null!==this._preservedValues?[]:this._accum)},o.prototype._promiseFulfilled=function(e,r){var n=this._values;if(null!==n){var u,o=this.length(),s=this._preservedValues,a=null!==s,h=this._gotAccum,p=this._valuesPhase;if(!p)for(p=this._valuesPhase=Array(o),u=0;o>u;++u)p[u]=0;if(u=p[r],0===r&&this._zerothIsAccum?(h||(this._accum=e,this._gotAccum=h=!0),p[r]=0===u?1:2):-1===r?h||(this._accum=e,this._gotAccum=h=!0):0===u?p[r]=1:(p[r]=2,h&&(this._accum=e)),h){for(var d,v=this._callback,y=this._promise._boundTo,g=this._reducingIndex;o>g;++g)if(u=p[g],2!==u){if(1!==u)return;if(e=n[g],e instanceof t){if(!e.isFulfilled())return e.isPending()?void 0:(e._unsetRejectionIsUnhandled(),this._reject(e.reason()));e=e._settledValue}if(a?(s.push(e),d=l(v,y,e,g,o)):d=c(v,y,this._accum,e,g,o),d===f)return this._reject(d.e);var _=i(d,void 0);if(_ instanceof t){if(_.isPending())return p[g]=4,_._proxyPromiseArray(this,g);if(!_.isFulfilled())return _._unsetRejectionIsUnhandled(),this._reject(_.reason());d=_.value()}this._reducingIndex=g+1,this._accum=d}else this._reducingIndex=g+1;this._reducingIndex=this._length&&this._resolve(this._values)},n.prototype._promiseFulfilled=function(t,e){if(!this._isResolved()){var r=new i;r._bitField=268435456,r._settledValue=t,this._promiseResolved(e,r)}},n.prototype._promiseRejected=function(t,e){if(!this._isResolved()){var r=new i;r._bitField=134217728,r._settledValue=t,this._promiseResolved(e,r)}},t.settle=function(t){return new n(t).promise()},t.prototype.settle=function(){return new n(this).promise()}}},function(t,e,r){"use strict";t.exports=function(t,e,n){function i(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function u(t,e){if((0|e)!==e||0>e)return n("expecting a positive integer");var r=new i(t),u=r.promise();return u.isRejected()?u:(r.setHowMany(e),r.init(),u)}var o=r(27),s=r(29).RangeError,a=r(29).AggregateError,c=o.isArray;o.inherits(i,e),i.prototype._init=function(){if(this._initialized){if(0===this._howMany)return this._resolve([]),void 0;this._init$(void 0,-5);var t=c(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}},i.prototype.init=function(){this._initialized=!0,this._init()},i.prototype.setUnwrap=function(){this._unwrap=!0},i.prototype.howMany=function(){return this._howMany},i.prototype.setHowMany=function(t){this._isResolved()||(this._howMany=t)},i.prototype._promiseFulfilled=function(t){this._isResolved()||(this._addFulfilled(t),this._fulfilled()===this.howMany()&&(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values)))},i.prototype._promiseRejected=function(t){if(!this._isResolved()&&(this._addRejected(t),this.howMany()>this._canPossiblyFulfill())){for(var e=new a,r=this.length();ro;o++){var s=this._progressHandlerAt(o),a=this._promiseAt(o);if(a instanceof t)"function"==typeof s?i.invoke(this._doProgressWith,this,{handler:s,promise:a,receiver:this._receiverAt(o),value:r}):i.invoke(u,a,r);else{var c=this._receiverAt(o);"function"==typeof s?s.call(c,r,a):c instanceof t&&c._isProxied()?c._progressUnchecked(r):c instanceof e&&c._promiseProgressed(r,a)}}}}},function(t,e,r){"use strict";t.exports=function(t,e){var n=r(29),i=n.canAttach,u=r(28),o=n.CancellationError;t.prototype._cancel=function(t){if(!this.isCancellable())return this;for(var e,r=this;void 0!==(e=r._cancellationParent)&&e.isCancellable();)r=e;r._attachExtraTrace(t),r._rejectUnchecked(t)},t.prototype.cancel=function(t){return this.isCancellable()?(t=void 0!==t?i(t)?t:new Error(t+""):new o,u.invokeLater(this._cancel,this,t),this):this},t.prototype.cancellable=function(){return this._cancellable()?this:(this._setCancellable(),this._cancellationParent=void 0,this)},t.prototype.uncancellable=function(){var r=new t(e);return r._propagateFrom(this,6),r._follow(this),r._unsetCancellable(),r},t.prototype.fork=function(t,e,r){var n=this._then(t,e,r,void 0,void 0);return n._setCancellable(),n._cancellationParent=void 0,n}}},function(t){"use strict";t.exports=function(t,e){var r=t.map;t.prototype.filter=function(t,n){return r(this,t,n,e)},t.filter=function(t,n,i){return r(t,n,i,e)}}},function(t){"use strict";t.exports=function(t){function e(t){var e=new r(t),n=e.promise();return n.isRejected()?n:(e.setHowMany(1),e.setUnwrap(),e.init(),n)}var r=t._SomePromiseArray;t.any=function(t){return e(t)},t.prototype.any=function(){return e(this)}}},function(t){"use strict";t.exports=function(t,e){var r=t.reduce;t.prototype.each=function(t){return r(this,t,null,e)},t.each=function(t,n){return r(t,n,null,e)}}},function(t,e,r){"use strict";t.exports=function(t,e,n){function i(e){for(var r=e.length,n=0;r>n;++n){var i=e[n];if(i.isRejected())return t.reject(i.error());e[n]=i.value()}return e}function u(t){setTimeout(function(){throw t},0)}function o(t){var e=n(t,void 0);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}function s(e,r){function i(){if(s>=a)return c.resolve();var l=o(e[s++]);if(l instanceof t&&l._isDisposable()){try{l=n(l._getDisposer().tryDispose(r),void 0)}catch(f){return u(f)}if(l instanceof t)return l._then(i,u,null,null,null)}i()}var s=0,a=e.length,c=t.defer();return i(),c.promise}function a(t){var e=new d;return e._settledValue=t,e._bitField=268435456,s(this,e).thenReturn(t)}function c(t){var e=new d;return e._settledValue=t,e._bitField=134217728,s(this,e).thenThrow(t)}function l(t,e){this._data=t,this._promise=e}function f(t,e){this.constructor$(t,e)}var h=r(29).TypeError,p=r(27).inherits,d=t.PromiseInspection;l.prototype.data=function(){return this._data},l.prototype.promise=function(){return this._promise},l.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():null},l.prototype.tryDispose=function(t){var e=this.resource(),r=null!==e?this.doDispose(e,t):null;return this._promise._unsetDisposable(),this._data=this._promise=null,r},l.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},p(f,l),f.prototype.doDispose=function(t,e){var r=this.data();return r.call(t,t,e)},t.using=function(){var r=arguments.length;if(2>r)return e("you must pass at least 2 arguments to Promise.using");var n=arguments[r-1];if("function"!=typeof n)return e("fn must be a function");r--;for(var u=new Array(r),o=0;r>o;++o){var s=arguments[o];if(l.isDisposer(s)){var f=s;s=s.promise(),s._setDisposable(f)}u[o]=s}return t.settle(u).then(i).spread(n)._then(a,c,void 0,u,void 0)},t.prototype._setDisposable=function(t){this._bitField=262144|this._bitField,this._disposer=t},t.prototype._isDisposable=function(){return(262144&this._bitField)>0},t.prototype._getDisposer=function(){return this._disposer},t.prototype._unsetDisposable=function(){this._bitField=-262145&this._bitField,this._disposer=void 0},t.prototype.disposer=function(t){if("function"==typeof t)return new f(t,this);throw new h}}},function(t){function e(){}var r=t.exports={};r.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var r=[];return window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),r.length>0)){var n=r.shift();n()}},!0),function(t){r.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=e,r.addListener=e,r.once=e,r.off=e,r.removeListener=e,r.removeAllListeners=e,r.emit=e,r.binding=function(){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw new Error("process.chdir is not supported")}},function(t,e,r){(function(t){function r(t){var e=Math.floor(t.length/5);return t.length%5==0?e:e+1}var n="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",i=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];e.encode=function(e){var i=0,u=0,o=0,s=0,a=new t(8*r(e));for(t.isBuffer(e)||(e=new t(e));i3?(s=c&255>>o,o=(o+5)%8,s=s<>8-o,i++):(s=c>>8-(o+5)&31,o=(o+5)%8,0==o&&i++),a[u]=n.charCodeAt(s),u++}for(i=u;i=n?(n=(n+5)%8,0==n?(r|=u,s[o]=r,o++,r=0):r|=255&u<<8-n):(n=(n+5)%8,r|=255&u>>>n,s[o]=r,o++,r=255&u<<8-n)}return s.slice(0,o)}}).call(e,r(22).Buffer)},function(t,e,r){(function(e,n){!function(){var i=("undefined"==typeof window?e:window)||{};_crypto=i.crypto||i.msCrypto||r(21),t.exports=function(t){if(_crypto.getRandomValues){var e=new n(t);return _crypto.getRandomValues(e),e}if(_crypto.randomBytes)return _crypto.randomBytes(t);throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}}()}).call(e,function(){return this}(),r(22).Buffer)},function(t,e,r){(function(e){function n(t){return function(){var r=[],n={update:function(t,n){return e.isBuffer(t)||(t=new e(t,n)),r.push(t),this},digest:function(n){var i=e.concat(r),u=t(i);return r=null,n?u.toString(n):u}};return n}}var i=r(76),u=n(r(69)),o=n(r(81));t.exports=function(t){return"md5"===t?new u:"rmd160"===t?new o:i(t)}}).call(e,r(22).Buffer)},function(t,e,r){(function(e){function n(t,r){if(!(this instanceof n))return new n(t,r);this._opad=a,this._alg=t;var o="sha512"===t?128:64;r=this._key=e.isBuffer(r)?r:new e(r),r.length>o?r=i(t).update(r).digest():r.lengthc;c++)s[c]=54^r[c],a[c]=92^r[c];this._hash=i(t).update(s)}var i=r(60),u=new e(128);u.fill(0),t.exports=n,n.prototype.update=function(t,e){return this._hash.update(t,e),this},n.prototype.digest=function(t){var e=this._hash.digest();return i(this._alg).update(this._opad).update(e).digest(t)}}).call(e,r(22).Buffer)},function(t,e,r){var n=r(77).__pbkdf2Export;t.exports=function(t,e){e=e||{};var r=n(t);return e.pbkdf2=r.pbkdf2,e.pbkdf2Sync=r.pbkdf2Sync,e}},function(t){t.exports="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e,r){function n(){}function i(t){var e={}.toString.call(t);switch(e){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}function u(){if(g.XMLHttpRequest&&("file:"!=g.location.protocol||!g.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}return!1}function o(t){return t===Object(t)}function s(t){if(!o(t))return t;var e=[];for(var r in t)null!=t[r]&&e.push(encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e.join("&")}function a(t){for(var e,r,n={},i=t.split("&"),u=0,o=i.length;o>u;++u)r=i[u],e=r.split("="),n[decodeURIComponent(e[0])]=decodeURIComponent(e[1]);return n}function c(t){var e,r,n,i,u=t.split(/\r?\n/),o={};u.pop();for(var s=0,a=u.length;a>s;++s)r=u[s],e=r.indexOf(":"),n=r.slice(0,e).toLowerCase(),i=_(r.slice(e+1)),o[n]=i;return o}function l(t){return t.split(/ *; */).shift()}function f(t){return y(t.split(/ *; */),function(t,e){var r=e.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(t[n]=i),t},{})}function h(t,e){e=e||{},this.req=t,this.xhr=this.req.xhr,this.text=this.xhr.responseText,this.setStatusProperties(this.xhr.status),this.header=this.headers=c(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this.parseBody(this.text):null}function p(t,e){var r=this;v.call(this),this._query=this._query||[],this.method=t,this.url=e,this.header={},this._header={},this.on("end",function(){try{var e=new h(r);"HEAD"==t&&(e.text=null),r.callback(null,e)}catch(n){var i=new Error("Parser is unable to parse the response");i.parse=!0,i.original=n,r.callback(i)}})}function d(t,e){return"function"==typeof e?new p("GET",t).end(e):1==arguments.length?new p("GET",t):new p(t,e)}var v=r(79),y=r(80),g="undefined"==typeof window?this:window,_="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};d.serializeObject=s,d.parseString=a,d.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},d.serialize={"application/x-www-form-urlencoded":s,"application/json":JSON.stringify},d.parse={"application/x-www-form-urlencoded":a,"application/json":JSON.parse},h.prototype.get=function(t){return this.header[t.toLowerCase()]},h.prototype.setHeaderProperties=function(){var t=this.header["content-type"]||"";this.type=l(t);var e=f(t);for(var r in e)this[r]=e[r]},h.prototype.parseBody=function(t){var e=d.parse[this.type];return e&&t&&t.length?e(t):null},h.prototype.setStatusProperties=function(t){var e=t/100|0;this.status=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.clientError=4==e,this.serverError=5==e,this.error=4==e||5==e?this.toError():!1,this.accepted=202==t,this.noContent=204==t||1223==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.notFound=404==t,this.forbidden=403==t},h.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,n="cannot "+e+" "+r+" ("+this.status+")",i=new Error(n);return i.status=this.status,i.method=e,i.url=r,i},d.Response=h,v(p.prototype),p.prototype.use=function(t){return t(this),this},p.prototype.timeout=function(t){return this._timeout=t,this},p.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},p.prototype.abort=function(){return this.aborted?void 0:(this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this)},p.prototype.set=function(t,e){if(o(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},p.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},p.prototype.getHeader=function(t){return this._header[t.toLowerCase()]},p.prototype.type=function(t){return this.set("Content-Type",d.types[t]||t),this},p.prototype.accept=function(t){return this.set("Accept",d.types[t]||t),this},p.prototype.auth=function(t,e){var r=btoa(t+":"+e);return this.set("Authorization","Basic "+r),this},p.prototype.query=function(t){return"string"!=typeof t&&(t=s(t)),t&&this._query.push(t),this},p.prototype.field=function(t,e){return this._formData||(this._formData=new FormData),this._formData.append(t,e),this},p.prototype.attach=function(t,e,r){return this._formData||(this._formData=new FormData),this._formData.append(t,e,r),this},p.prototype.send=function(t){var e=o(t),r=this.getHeader("Content-Type");if(e&&o(this._data))for(var n in t)this._data[n]=t[n];else"string"==typeof t?(r||this.type("form"),r=this.getHeader("Content-Type"),this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return e?(r||this.type("json"),this):this},p.prototype.callback=function(t,e){var r=this._callback;return 2==r.length?r(t,e):t?this.emit("error",t):(r(e),void 0)},p.prototype.crossDomainError=function(){var t=new Error("Origin is not allowed by Access-Control-Allow-Origin");t.crossDomain=!0,this.callback(t)},p.prototype.timeoutError=function(){var t=this._timeout,e=new Error("timeout of "+t+"ms exceeded");e.timeout=t,this.callback(e)},p.prototype.withCredentials=function(){return this._withCredentials=!0,this},p.prototype.end=function(t){var e=this,r=this.xhr=u(),o=this._query.join("&"),s=this._timeout,a=this._formData||this._data;if(this._callback=t||n,r.onreadystatechange=function(){return 4==r.readyState?0==r.status?e.aborted?e.timeoutError():e.crossDomainError():(e.emit("end"),void 0):void 0},r.upload&&(r.upload.onprogress=function(t){t.percent=t.loaded/t.total*100,e.emit("progress",t)}),s&&!this._timer&&(this._timer=setTimeout(function(){e.abort()},s)),o&&(o=d.serializeObject(o),this.url+=~this.url.indexOf("?")?"&"+o:"?"+o),r.open(this.method,this.url,!0),this._withCredentials&&(r.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof a&&!i(a)){var c=d.serialize[this.getHeader("Content-Type")];c&&(a=c(a))}for(var l in this.header)null!=this.header[l]&&r.setRequestHeader(l,this.header[l]);return this.emit("request",this),r.send(a),this},d.Request=p,d.get=function(t,e,r){var n=d("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},d.head=function(t,e,r){var n=d("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},d.del=function(t,e){var r=d("DELETE",t);return e&&r.end(e),r},d.patch=function(t,e,r){var n=d("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},d.post=function(t,e,r){var n=d("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},d.put=function(t,e,r){var n=d("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},t.exports=d},function(t,e,r){var n=r(73),i=r(74),u=r(75);t.exports=function(t){return null==t?"":String(t).replace(i,"$1 $2").replace(u,"$1 $2").replace(n," ").replace(/^ | $/g,"").toLowerCase()}},function(t){var e=function(){"use strict";return void 0===this}();if(e)t.exports={freeze:Object.freeze,defineProperty:Object.defineProperty,keys:Object.keys,getPrototypeOf:Object.getPrototypeOf,isArray:Array.isArray,isES5:e}; -else{var r={}.hasOwnProperty,n={}.toString,i={}.constructor.prototype,u=function(t){var e=[];for(var n in t)r.call(t,n)&&e.push(n);return e},o=function(t,e,r){return t[e]=r.value,t},s=function(t){return t},a=function(t){try{return Object(t).constructor.prototype}catch(e){return i}},c=function(t){try{return"[object Array]"===n.call(t)}catch(e){return!1}};t.exports={isArray:c,keys:u,defineProperty:o,freeze:s,getPrototypeOf:a,isES5:e}}},function(t,e,r){(function(e){"use strict";var r,n;if("object"==typeof e&&"string"==typeof e.version)r=function(t){e.nextTick(t)};else if("undefined"!=typeof MutationObserver&&(n=MutationObserver)||"undefined"!=typeof WebKitMutationObserver&&(n=WebKitMutationObserver))r=function(){var t=document.createElement("div"),e=void 0,r=new n(function(){var t=e;e=void 0,t()});return r.observe(t,{attributes:!0}),function(r){e=r,t.classList.toggle("foo")}}();else{if("undefined"==typeof setTimeout)throw new Error("no async scheduler available");r=function(t){setTimeout(t,0)}}t.exports=r}).call(e,r(57))},function(t){"use strict";function e(t,e,r,n,i){for(var u=0;i>u;++u)r[u+n]=t[u+e]}function r(t){this._capacity=t,this._length=0,this._front=0,this._makeCapacity()}r.prototype._willBeOverCapacity=function(t){return this._capacitye;++e)this[e]=void 0},r.prototype._checkCapacity=function(t){this._capacity=r+u)e(i,r,this,0,u);else{var o=u-(r+u&n-1);e(i,r,this,0,o),e(i,0,this,o,u-o)}},t.exports=r},function(t,e,r){function n(t,e){t[e>>5]|=128<>>9<<4)+14]=e;for(var r=1732584193,n=-271733879,i=-1732584194,l=271733878,f=0;f>16)+(e>>16)+(r>>16);return n<<16|65535&r}function l(t,e){return t<>>32-e}var f=r(78);t.exports=function(t){return f.hash(t,n,16)}},function(t,e){e.read=function(t,e,r,n,i){var u,o,s=8*i-n-1,a=(1<>1,l=-7,f=r?i-1:0,h=r?-1:1,p=t[e+f];for(f+=h,u=p&(1<<-l)-1,p>>=-l,l+=s;l>0;u=256*u+t[e+f],f+=h,l-=8);for(o=u&(1<<-l)-1,u>>=-l,l+=n;l>0;o=256*o+t[e+f],f+=h,l-=8);if(0===u)u=1-c;else{if(u===a)return o?0/0:1/0*(p?-1:1);o+=Math.pow(2,n),u-=c}return(p?-1:1)*o*Math.pow(2,u-n)},e.write=function(t,e,r,n,i,u){var o,s,a,c=8*u-i-1,l=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:u-1,d=n?1:-1,v=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(s=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-o))<1&&(o--,a*=2),e+=o+f>=1?h/a:h*Math.pow(2,1-f),e*a>=2&&(o++,a/=2),o+f>=l?(s=0,o=l):o+f>=1?(s=(e*a-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(o=o<0;t[r+p]=255&o,p+=d,o/=256,c-=8);t[r+p-d]|=128*v}},function(t){var e=Array.isArray,r=Object.prototype.toString;t.exports=e||function(t){return!!t&&"[object Array]"==r.call(t)}},function(t,e){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===o?62:e===s?63:a>e?-1:a+10>e?e-a+26+26:l+26>e?e-l:c+26>e?e-c+26:void 0}function n(t){function r(t){c[f++]=t}var n,i,o,s,a,c;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var l=t.length;a="="===t.charAt(l-2)?2:"="===t.charAt(l-1)?1:0,c=new u(3*t.length/4-a),o=a>0?t.length-4:t.length;var f=0;for(n=0,i=0;o>n;n+=4,i+=3)s=e(t.charAt(n))<<18|e(t.charAt(n+1))<<12|e(t.charAt(n+2))<<6|e(t.charAt(n+3)),r((16711680&s)>>16),r((65280&s)>>8),r(255&s);return 2===a?(s=e(t.charAt(n))<<2|e(t.charAt(n+1))>>4,r(255&s)):1===a&&(s=e(t.charAt(n))<<10|e(t.charAt(n+1))<<4|e(t.charAt(n+2))>>2,r(s>>8&255),r(255&s)),c}function i(t){function e(t){return r.charAt(t)}function n(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var i,u,o,s=t.length%3,a="";for(i=0,o=t.length-s;o>i;i+=3)u=(t[i]<<16)+(t[i+1]<<8)+t[i+2],a+=n(u);switch(s){case 1:u=t[t.length-1],a+=e(u>>2),a+=e(u<<4&63),a+="==";break;case 2:u=(t[t.length-2]<<8)+t[t.length-1],a+=e(u>>10),a+=e(u>>4&63),a+=e(u<<2&63),a+="="}return a}var u="undefined"!=typeof Uint8Array?Uint8Array:Array,o="+".charCodeAt(0),s="/".charCodeAt(0),a="0".charCodeAt(0),c="a".charCodeAt(0),l="A".charCodeAt(0);t.toByteArray=n,t.fromByteArray=i}("undefined"==typeof e?this.base64js={}:e)},function(t){t.exports=/[^\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC\u0030-\u0039\u00B2\u00B3\u00B9\u00BC-\u00BE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D66-\u0D75\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]+/g},function(t){t.exports=/([\u0061-\u007A\u00B5\u00DF-\u00F6\u00F8-\u00FF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC\u01DD\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u0373\u0377\u037B-\u037D\u0390\u03AC-\u03CE\u03D0\u03D1\u03D5-\u03D7\u03D9\u03DB\u03DD\u03DF\u03E1\u03E3\u03E5\u03E7\u03E9\u03EB\u03ED\u03EF-\u03F3\u03F5\u03F8\u03FB\u03FC\u0430-\u045F\u0461\u0463\u0465\u0467\u0469\u046B\u046D\u046F\u0471\u0473\u0475\u0477\u0479\u047B\u047D\u047F\u0481\u048B\u048D\u048F\u0491\u0493\u0495\u0497\u0499\u049B\u049D\u049F\u04A1\u04A3\u04A5\u04A7\u04A9\u04AB\u04AD\u04AF\u04B1\u04B3\u04B5\u04B7\u04B9\u04BB\u04BD\u04BF\u04C2\u04C4\u04C6\u04C8\u04CA\u04CC\u04CE\u04CF\u04D1\u04D3\u04D5\u04D7\u04D9\u04DB\u04DD\u04DF\u04E1\u04E3\u04E5\u04E7\u04E9\u04EB\u04ED\u04EF\u04F1\u04F3\u04F5\u04F7\u04F9\u04FB\u04FD\u04FF\u0501\u0503\u0505\u0507\u0509\u050B\u050D\u050F\u0511\u0513\u0515\u0517\u0519\u051B\u051D\u051F\u0521\u0523\u0525\u0527\u0561-\u0587\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E01\u1E03\u1E05\u1E07\u1E09\u1E0B\u1E0D\u1E0F\u1E11\u1E13\u1E15\u1E17\u1E19\u1E1B\u1E1D\u1E1F\u1E21\u1E23\u1E25\u1E27\u1E29\u1E2B\u1E2D\u1E2F\u1E31\u1E33\u1E35\u1E37\u1E39\u1E3B\u1E3D\u1E3F\u1E41\u1E43\u1E45\u1E47\u1E49\u1E4B\u1E4D\u1E4F\u1E51\u1E53\u1E55\u1E57\u1E59\u1E5B\u1E5D\u1E5F\u1E61\u1E63\u1E65\u1E67\u1E69\u1E6B\u1E6D\u1E6F\u1E71\u1E73\u1E75\u1E77\u1E79\u1E7B\u1E7D\u1E7F\u1E81\u1E83\u1E85\u1E87\u1E89\u1E8B\u1E8D\u1E8F\u1E91\u1E93\u1E95-\u1E9D\u1E9F\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u1EB9\u1EBB\u1EBD\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1EC9\u1ECB\u1ECD\u1ECF\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3\u1EE5\u1EE7\u1EE9\u1EEB\u1EED\u1EEF\u1EF1\u1EF3\u1EF5\u1EF7\u1EF9\u1EFB\u1EFD\u1EFF-\u1F07\u1F10-\u1F15\u1F20-\u1F27\u1F30-\u1F37\u1F40-\u1F45\u1F50-\u1F57\u1F60-\u1F67\u1F70-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6\u1FB7\u1FBE\u1FC2-\u1FC4\u1FC6\u1FC7\u1FD0-\u1FD3\u1FD6\u1FD7\u1FE0-\u1FE7\u1FF2-\u1FF4\u1FF6\u1FF7\u210A\u210E\u210F\u2113\u212F\u2134\u2139\u213C\u213D\u2146-\u2149\u214E\u2184\u2C30-\u2C5E\u2C61\u2C65\u2C66\u2C68\u2C6A\u2C6C\u2C71\u2C73\u2C74\u2C76-\u2C7B\u2C81\u2C83\u2C85\u2C87\u2C89\u2C8B\u2C8D\u2C8F\u2C91\u2C93\u2C95\u2C97\u2C99\u2C9B\u2C9D\u2C9F\u2CA1\u2CA3\u2CA5\u2CA7\u2CA9\u2CAB\u2CAD\u2CAF\u2CB1\u2CB3\u2CB5\u2CB7\u2CB9\u2CBB\u2CBD\u2CBF\u2CC1\u2CC3\u2CC5\u2CC7\u2CC9\u2CCB\u2CCD\u2CCF\u2CD1\u2CD3\u2CD5\u2CD7\u2CD9\u2CDB\u2CDD\u2CDF\u2CE1\u2CE3\u2CE4\u2CEC\u2CEE\u2CF3\u2D00-\u2D25\u2D27\u2D2D\uA641\uA643\uA645\uA647\uA649\uA64B\uA64D\uA64F\uA651\uA653\uA655\uA657\uA659\uA65B\uA65D\uA65F\uA661\uA663\uA665\uA667\uA669\uA66B\uA66D\uA681\uA683\uA685\uA687\uA689\uA68B\uA68D\uA68F\uA691\uA693\uA695\uA697\uA723\uA725\uA727\uA729\uA72B\uA72D\uA72F-\uA731\uA733\uA735\uA737\uA739\uA73B\uA73D\uA73F\uA741\uA743\uA745\uA747\uA749\uA74B\uA74D\uA74F\uA751\uA753\uA755\uA757\uA759\uA75B\uA75D\uA75F\uA761\uA763\uA765\uA767\uA769\uA76B\uA76D\uA76F\uA771-\uA778\uA77A\uA77C\uA77F\uA781\uA783\uA785\uA787\uA78C\uA78E\uA791\uA793\uA7A1\uA7A3\uA7A5\uA7A7\uA7A9\uA7FA\uFB00-\uFB06\uFB13-\uFB17\uFF41-\uFF5A])([\u0041-\u005A\u00C0-\u00D6\u00D8-\u00DE\u0100\u0102\u0104\u0106\u0108\u010A\u010C\u010E\u0110\u0112\u0114\u0116\u0118\u011A\u011C\u011E\u0120\u0122\u0124\u0126\u0128\u012A\u012C\u012E\u0130\u0132\u0134\u0136\u0139\u013B\u013D\u013F\u0141\u0143\u0145\u0147\u014A\u014C\u014E\u0150\u0152\u0154\u0156\u0158\u015A\u015C\u015E\u0160\u0162\u0164\u0166\u0168\u016A\u016C\u016E\u0170\u0172\u0174\u0176\u0178\u0179\u017B\u017D\u0181\u0182\u0184\u0186\u0187\u0189-\u018B\u018E-\u0191\u0193\u0194\u0196-\u0198\u019C\u019D\u019F\u01A0\u01A2\u01A4\u01A6\u01A7\u01A9\u01AC\u01AE\u01AF\u01B1-\u01B3\u01B5\u01B7\u01B8\u01BC\u01C4\u01C7\u01CA\u01CD\u01CF\u01D1\u01D3\u01D5\u01D7\u01D9\u01DB\u01DE\u01E0\u01E2\u01E4\u01E6\u01E8\u01EA\u01EC\u01EE\u01F1\u01F4\u01F6-\u01F8\u01FA\u01FC\u01FE\u0200\u0202\u0204\u0206\u0208\u020A\u020C\u020E\u0210\u0212\u0214\u0216\u0218\u021A\u021C\u021E\u0220\u0222\u0224\u0226\u0228\u022A\u022C\u022E\u0230\u0232\u023A\u023B\u023D\u023E\u0241\u0243-\u0246\u0248\u024A\u024C\u024E\u0370\u0372\u0376\u0386\u0388-\u038A\u038C\u038E\u038F\u0391-\u03A1\u03A3-\u03AB\u03CF\u03D2-\u03D4\u03D8\u03DA\u03DC\u03DE\u03E0\u03E2\u03E4\u03E6\u03E8\u03EA\u03EC\u03EE\u03F4\u03F7\u03F9\u03FA\u03FD-\u042F\u0460\u0462\u0464\u0466\u0468\u046A\u046C\u046E\u0470\u0472\u0474\u0476\u0478\u047A\u047C\u047E\u0480\u048A\u048C\u048E\u0490\u0492\u0494\u0496\u0498\u049A\u049C\u049E\u04A0\u04A2\u04A4\u04A6\u04A8\u04AA\u04AC\u04AE\u04B0\u04B2\u04B4\u04B6\u04B8\u04BA\u04BC\u04BE\u04C0\u04C1\u04C3\u04C5\u04C7\u04C9\u04CB\u04CD\u04D0\u04D2\u04D4\u04D6\u04D8\u04DA\u04DC\u04DE\u04E0\u04E2\u04E4\u04E6\u04E8\u04EA\u04EC\u04EE\u04F0\u04F2\u04F4\u04F6\u04F8\u04FA\u04FC\u04FE\u0500\u0502\u0504\u0506\u0508\u050A\u050C\u050E\u0510\u0512\u0514\u0516\u0518\u051A\u051C\u051E\u0520\u0522\u0524\u0526\u0531-\u0556\u10A0-\u10C5\u10C7\u10CD\u1E00\u1E02\u1E04\u1E06\u1E08\u1E0A\u1E0C\u1E0E\u1E10\u1E12\u1E14\u1E16\u1E18\u1E1A\u1E1C\u1E1E\u1E20\u1E22\u1E24\u1E26\u1E28\u1E2A\u1E2C\u1E2E\u1E30\u1E32\u1E34\u1E36\u1E38\u1E3A\u1E3C\u1E3E\u1E40\u1E42\u1E44\u1E46\u1E48\u1E4A\u1E4C\u1E4E\u1E50\u1E52\u1E54\u1E56\u1E58\u1E5A\u1E5C\u1E5E\u1E60\u1E62\u1E64\u1E66\u1E68\u1E6A\u1E6C\u1E6E\u1E70\u1E72\u1E74\u1E76\u1E78\u1E7A\u1E7C\u1E7E\u1E80\u1E82\u1E84\u1E86\u1E88\u1E8A\u1E8C\u1E8E\u1E90\u1E92\u1E94\u1E9E\u1EA0\u1EA2\u1EA4\u1EA6\u1EA8\u1EAA\u1EAC\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u1EB8\u1EBA\u1EBC\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6\u1EC8\u1ECA\u1ECC\u1ECE\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2\u1EE4\u1EE6\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0\u1EF2\u1EF4\u1EF6\u1EF8\u1EFA\u1EFC\u1EFE\u1F08-\u1F0F\u1F18-\u1F1D\u1F28-\u1F2F\u1F38-\u1F3F\u1F48-\u1F4D\u1F59\u1F5B\u1F5D\u1F5F\u1F68-\u1F6F\u1FB8-\u1FBB\u1FC8-\u1FCB\u1FD8-\u1FDB\u1FE8-\u1FEC\u1FF8-\u1FFB\u2102\u2107\u210B-\u210D\u2110-\u2112\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u2130-\u2133\u213E\u213F\u2145\u2183\u2C00-\u2C2E\u2C60\u2C62-\u2C64\u2C67\u2C69\u2C6B\u2C6D-\u2C70\u2C72\u2C75\u2C7E-\u2C80\u2C82\u2C84\u2C86\u2C88\u2C8A\u2C8C\u2C8E\u2C90\u2C92\u2C94\u2C96\u2C98\u2C9A\u2C9C\u2C9E\u2CA0\u2CA2\u2CA4\u2CA6\u2CA8\u2CAA\u2CAC\u2CAE\u2CB0\u2CB2\u2CB4\u2CB6\u2CB8\u2CBA\u2CBC\u2CBE\u2CC0\u2CC2\u2CC4\u2CC6\u2CC8\u2CCA\u2CCC\u2CCE\u2CD0\u2CD2\u2CD4\u2CD6\u2CD8\u2CDA\u2CDC\u2CDE\u2CE0\u2CE2\u2CEB\u2CED\u2CF2\uA640\uA642\uA644\uA646\uA648\uA64A\uA64C\uA64E\uA650\uA652\uA654\uA656\uA658\uA65A\uA65C\uA65E\uA660\uA662\uA664\uA666\uA668\uA66A\uA66C\uA680\uA682\uA684\uA686\uA688\uA68A\uA68C\uA68E\uA690\uA692\uA694\uA696\uA722\uA724\uA726\uA728\uA72A\uA72C\uA72E\uA732\uA734\uA736\uA738\uA73A\uA73C\uA73E\uA740\uA742\uA744\uA746\uA748\uA74A\uA74C\uA74E\uA750\uA752\uA754\uA756\uA758\uA75A\uA75C\uA75E\uA760\uA762\uA764\uA766\uA768\uA76A\uA76C\uA76E\uA779\uA77B\uA77D\uA77E\uA780\uA782\uA784\uA786\uA78B\uA78D\uA790\uA792\uA7A0\uA7A2\uA7A4\uA7A6\uA7A8\uA7AA\uFF21-\uFF3A\u0030-\u0039\u00B2\u00B3\u00B9\u00BC-\u00BE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D66-\u0D75\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19])/g},function(t){t.exports=/([\u0030-\u0039\u00B2\u00B3\u00B9\u00BC-\u00BE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D66-\u0D75\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19])([^\u0030-\u0039\u00B2\u00B3\u00B9\u00BC-\u00BE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D66-\u0D75\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19])/g},function(t,e,r){var e=t.exports=function(t){var r=e[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r},n=r(22).Buffer,i=r(82)(n);e.sha1=r(83)(n,i),e.sha256=r(84)(n,i),e.sha512=r(85)(n,i)},function(t,e,r){var n=r(21),i=r(86),u=i(n);t.exports={pbkdf2:u.pbkdf2,pbkdf2Sync:u.pbkdf2Sync,__pbkdf2Export:i}},function(t,e,r){(function(e){function r(t,r){if(t.length%u!==0){var n=t.length+(u-t.length%u);t=e.concat([t,o],n)}for(var i=[],s=r?t.readInt32BE:t.readInt32LE,a=0;an;++n)r[n].apply(this,e)}return this},e.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},e.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t){t.exports=function(t,e,r){for(var n=0,i=t.length,u=3==arguments.length?r:t[n++];i>n;)u=e.call(null,u,t[n],++n,t);return u}},function(t,e,r){(function(e){function r(t,e,r){return t^e^r}function n(t,e,r){return t&e|~t&r}function i(t,e,r){return(t|~e)^r}function u(t,e,r){return t&r|e&~r}function o(t,e,r){return t^(e|~r)}function s(t,e){return t<>>32-e}function a(t){var r=[1732584193,4023233417,2562383102,271733878,3285377520];"string"==typeof t&&(t=new e(t,"utf8"));var n=v(t),i=8*t.length,u=8*t.length;n[i>>>5]|=128<<24-i%32,n[(i+64>>>9<<4)+14]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8);for(var o=0;oo;o++){var s=r[o];r[o]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var a=y(r);return new e(a)}t.exports=a;var c=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],l=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],f=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],h=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],p=[0,1518500249,1859775393,2400959708,2840853838],d=[1352829926,1548603684,1836072691,2053994217,0],v=function(t){for(var e=[],r=0,n=0;r>>5]|=t[r]<<24-n%32;return e},y=function(t){for(var e=[],r=0;r<32*t.length;r+=8)e.push(t[r>>>5]>>>24-r%32&255);return e},g=function(t,e,a){for(var v=0;16>v;v++){var y=a+v,g=e[y];e[y]=16711935&(g<<8|g>>>24)|4278255360&(g<<24|g>>>8)}var _,m,b,w,A,E,F,C,B,D;E=_=t[0],F=m=t[1],C=b=t[2],B=w=t[3],D=A=t[4];for(var k,v=0;80>v;v+=1)k=_+e[a+c[v]]|0,k+=16>v?r(m,b,w)+p[0]:32>v?n(m,b,w)+p[1]:48>v?i(m,b,w)+p[2]:64>v?u(m,b,w)+p[3]:o(m,b,w)+p[4],k=0|k,k=s(k,f[v]),k=k+A|0,_=A,A=w,w=s(b,10),b=m,m=k,k=E+e[a+l[v]]|0,k+=16>v?o(F,C,B)+d[0]:32>v?u(F,C,B)+d[1]:48>v?i(F,C,B)+d[2]:64>v?n(F,C,B)+d[3]:r(F,C,B)+d[4],k=0|k,k=s(k,h[v]),k=k+D|0,E=D,D=B,B=s(C,10),C=F,F=k;k=t[1]+b+B|0,t[1]=t[2]+w+D|0,t[2]=t[3]+A+E|0,t[3]=t[4]+_+F|0,t[4]=t[0]+m+C|0,t[0]=k}}).call(e,r(22).Buffer)},function(t){t.exports=function(t){function e(e,r){this._block=new t(e),this._finalSize=r,this._blockSize=e,this._len=0,this._s=0}return e.prototype.init=function(){this._s=0,this._len=0},e.prototype.update=function(e,r){"string"==typeof e&&(r=r||"utf8",e=new t(e,r));for(var n=this._len+=e.length,i=this._s=this._s||0,u=0,o=this._block;n>i;){for(var s=Math.min(e.length,u+this._blockSize-i%this._blockSize),a=s-u,c=0;a>c;c++)o[i%this._blockSize+c]=e[c+u];i+=a,u+=a,i%this._blockSize===0&&this._update(o)}return this._s=i,this},e.prototype.digest=function(t){var e=8*this._len;this._block[this._len%this._blockSize]=128,this._block.fill(0,this._len%this._blockSize+1),e%(8*this._blockSize)>=8*this._finalSize&&(this._update(this._block),this._block.fill(0)),this._block.writeInt32BE(e,this._blockSize-4);var r=this._update(this._block)||this._hash();return t?r.toString(t):r},e.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e}},function(t,e,r){var n=r(15).inherits;t.exports=function(t,e){function r(){return d.length?d.pop().init():this instanceof r?(this._w=p,e.call(this,64,56),this._h=null,this.init(),void 0):new r}function i(t,e,r,n){return 20>t?e&r|~e&n:40>t?e^r^n:60>t?e&r|e&n|r&n:e^r^n}function u(t){return 20>t?1518500249:40>t?1859775393:60>t?-1894007588:-899497514}function o(t,e){return t+e|0}function s(t,e){return t<>>32-e}var a=0,c=4,l=8,f=12,h=16,p=new("undefined"==typeof Int32Array?Array:Int32Array)(80),d=[];return n(r,e),r.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,e.prototype.init.call(this),this},r.prototype._POOL=d,r.prototype._update=function(t){var e,r,n,a,c,l,f,h,p,d;e=l=this._a,r=f=this._b,n=h=this._c,a=p=this._d,c=d=this._e;for(var v=this._w,y=0;80>y;y++){var g=v[y]=16>y?t.readInt32BE(4*y):s(v[y-3]^v[y-8]^v[y-14]^v[y-16],1),_=o(o(s(e,5),i(y,r,n,a)),o(o(c,g),u(y)));c=a,a=n,n=s(r,30),r=e,e=_}this._a=o(e,l),this._b=o(r,f),this._c=o(n,h),this._d=o(a,p),this._e=o(c,d)},r.prototype._hash=function(){d.length<100&&d.push(this);var e=new t(20);return e.writeInt32BE(0|this._a,a),e.writeInt32BE(0|this._b,c),e.writeInt32BE(0|this._c,l),e.writeInt32BE(0|this._d,f),e.writeInt32BE(0|this._e,h),e},r}},function(t,e,r){var n=r(15).inherits;t.exports=function(t,e){function r(){this.init(),this._w=p,e.call(this,64,56)}function i(t,e){return t>>>e|t<<32-e}function u(t,e){return t>>>e}function o(t,e,r){return t&e^~t&r}function s(t,e,r){return t&e^t&r^e&r}function a(t){return i(t,2)^i(t,13)^i(t,22)}function c(t){return i(t,6)^i(t,11)^i(t,25)}function l(t){return i(t,7)^i(t,18)^u(t,3)}function f(t){return i(t,17)^i(t,19)^u(t,10)}var h=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],p=new Array(64);return n(r,e),r.prototype.init=function(){return this._a=1779033703,this._b=-1150833019,this._c=1013904242,this._d=-1521486534,this._e=1359893119,this._f=-1694144372,this._g=528734635,this._h=1541459225,this._len=this._s=0,this},r.prototype._update=function(t){var e,r,n,i,u,p,d,v,y,g,_=this._w;e=0|this._a,r=0|this._b,n=0|this._c,i=0|this._d,u=0|this._e,p=0|this._f,d=0|this._g,v=0|this._h;for(var m=0;64>m;m++){var b=_[m]=16>m?t.readInt32BE(4*m):f(_[m-2])+_[m-7]+l(_[m-15])+_[m-16];y=v+c(u)+o(u,p,d)+h[m]+b,g=a(e)+s(e,r,n),v=d,d=p,p=u,u=i+y,i=n,n=r,r=e,e=y+g}this._a=e+this._a|0,this._b=r+this._b|0,this._c=n+this._c|0,this._d=i+this._d|0,this._e=u+this._e|0,this._f=p+this._f|0,this._g=d+this._g|0,this._h=v+this._h|0},r.prototype._hash=function(){var e=new t(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},r}},function(t,e,r){var n=r(15).inherits;t.exports=function(t,e){function r(){this.init(),this._w=a,e.call(this,128,112)}function i(t,e,r){return t>>>r|e<<32-r}function u(t,e,r){return t&e^~t&r}function o(t,e,r){return t&e^t&r^e&r -}var s=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);return n(r,e),r.prototype.init=function(){return this._a=1779033703,this._b=-1150833019,this._c=1013904242,this._d=-1521486534,this._e=1359893119,this._f=-1694144372,this._g=528734635,this._h=1541459225,this._al=-205731576,this._bl=-2067093701,this._cl=-23791573,this._dl=1595750129,this._el=-1377402159,this._fl=725511199,this._gl=-79577749,this._hl=327033209,this._len=this._s=0,this},r.prototype._update=function(t){var e,r,n,a,c,l,f,h,p,d,v,y,g,_,m,b,w=this._w;e=0|this._a,r=0|this._b,n=0|this._c,a=0|this._d,c=0|this._e,l=0|this._f,f=0|this._g,h=0|this._h,p=0|this._al,d=0|this._bl,v=0|this._cl,y=0|this._dl,g=0|this._el,_=0|this._fl,m=0|this._gl,b=0|this._hl;for(var A=0;80>A;A++){var E,F,C=2*A;if(16>A)E=w[C]=t.readInt32BE(4*C),F=w[C+1]=t.readInt32BE(4*C+4);else{var B=w[C-30],D=w[C-30+1],k=i(B,D,1)^i(B,D,8)^B>>>7,x=i(D,B,1)^i(D,B,8)^i(D,B,7);B=w[C-4],D=w[C-4+1];var j=i(B,D,19)^i(D,B,29)^B>>>6,T=i(D,B,19)^i(B,D,29)^i(D,B,6),P=w[C-14],R=w[C-14+1],S=w[C-32],I=w[C-32+1];F=x+R,E=k+P+(x>>>0>F>>>0?1:0),F+=T,E=E+j+(T>>>0>F>>>0?1:0),F+=I,E=E+S+(I>>>0>F>>>0?1:0),w[C]=E,w[C+1]=F}var O=o(e,r,n),U=o(p,d,v),L=i(e,p,28)^i(p,e,2)^i(p,e,7),M=i(p,e,28)^i(e,p,2)^i(e,p,7),z=i(c,g,14)^i(c,g,18)^i(g,c,9),N=i(g,c,14)^i(g,c,18)^i(c,g,9),H=s[C],V=s[C+1],K=u(c,l,f),q=u(g,_,m),Y=b+N,$=h+z+(b>>>0>Y>>>0?1:0);Y+=q,$=$+K+(q>>>0>Y>>>0?1:0),Y+=V,$=$+H+(V>>>0>Y>>>0?1:0),Y+=F,$=$+E+(F>>>0>Y>>>0?1:0);var W=M+U,G=L+O+(M>>>0>W>>>0?1:0);h=f,b=m,f=l,m=_,l=c,_=g,g=y+Y|0,c=a+$+(y>>>0>g>>>0?1:0)|0,a=n,y=v,n=r,v=d,r=e,d=p,p=Y+W|0,e=$+G+(Y>>>0>p>>>0?1:0)|0}this._al=this._al+p|0,this._bl=this._bl+d|0,this._cl=this._cl+v|0,this._dl=this._dl+y|0,this._el=this._el+g|0,this._fl=this._fl+_|0,this._gl=this._gl+m|0,this._hl=this._hl+b|0,this._a=this._a+e+(this._al>>>0

>>0?1:0)|0,this._b=this._b+r+(this._bl>>>0>>0?1:0)|0,this._c=this._c+n+(this._cl>>>0>>0?1:0)|0,this._d=this._d+a+(this._dl>>>0>>0?1:0)|0,this._e=this._e+c+(this._el>>>0>>0?1:0)|0,this._f=this._f+l+(this._fl>>>0<_>>>0?1:0)|0,this._g=this._g+f+(this._gl>>>0>>0?1:0)|0,this._h=this._h+h+(this._hl>>>0>>0?1:0)|0},r.prototype._hash=function(){function e(t,e,n){r.writeInt32BE(t,n),r.writeInt32BE(e,n+4)}var r=new t(64);return e(this._a,this._al,0),e(this._b,this._bl,8),e(this._c,this._cl,16),e(this._d,this._dl,24),e(this._e,this._el,32),e(this._f,this._fl,40),e(this._g,this._gl,48),e(this._h,this._hl,56),r},r}},function(t,e,r){(function(e){t.exports=function(t){function r(t,e,r,i,u,o){if("function"==typeof u&&(o=u,u=void 0),"function"!=typeof o)throw new Error("No callback provided to pbkdf2");setTimeout(function(){var s;try{s=n(t,e,r,i,u)}catch(a){return o(a)}o(void 0,s)})}function n(r,n,i,u,o){if("number"!=typeof i)throw new TypeError("Iterations not a number");if(0>i)throw new TypeError("Bad iterations");if("number"!=typeof u)throw new TypeError("Key length not a number");if(0>u)throw new TypeError("Bad key length");o=o||"sha1",e.isBuffer(r)||(r=new e(r)),e.isBuffer(n)||(n=new e(n));var s,a,c,l=1,f=new e(u),h=new e(n.length+4);n.copy(h,0,0,n.length);for(var p=1;l>=p;p++){h.writeUInt32BE(p,n.length);var d=t.createHmac(o,r).update(h).digest();if(!s&&(s=d.length,c=new e(s),l=Math.ceil(u/s),a=u-(l-1)*s,u>(Math.pow(2,32)-1)*s))throw new TypeError("keylen exceeds maximum length");d.copy(c,0,0,s);for(var v=1;i>v;v++){d=t.createHmac(o,r).update(d).digest();for(var y=0;s>y;y++)c[y]^=d[y]}var g=(p-1)*s,_=p==l?a:s;c.copy(f,g,0,_)}return f}return{pbkdf2:r,pbkdf2Sync:n}}}).call(e,r(22).Buffer)}]); \ No newline at end of file +var StellarWallet = +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + module.exports = __webpack_require__(1); + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _ = __webpack_require__(8); + var errors = __webpack_require__(2); + var Promise = __webpack_require__(9); + var protocol = __webpack_require__(4); + var totp = __webpack_require__(5); + var Wallet = __webpack_require__(3); + + function createWalletObject(initData) { + var wallet = new Wallet(initData); + return Promise.resolve(wallet); + } + + module.exports = { + createWallet: function(params) { + return protocol.createWallet(params) + .then(createWalletObject); + }, + getWallet: function(params) { + return protocol.login(params) + .then(createWalletObject); + }, + errors: errors, + util: { + generateRandomTotpKey: totp.generateRandomTotpKey, + generateTotpUri: totp.generateTotpUri + } + }; + + + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var util = __webpack_require__(10); + + Error.subclass = function(errorName) { + var newError = function(message) { + this.name = errorName; + this.message = (message || ""); + }; + + newError.subclass = this.subclass; + util.inherits(newError, this); + + return newError; + }; + + Error.prototype.setCode = function(code) { + this.code = code; + return this; + } + + Error.prototype.setData = function(data) { + this.data = data; + return this; + } + + var errors = module.exports; + + errors.NotInitialized = Error.subclass('NotInitialized'); + + errors.Forbidden = Error.subclass('Forbidden'); + errors.WalletNotFound = Error.subclass('WalletNotFound'); + errors.DataCorrupt = Error.subclass('DataCorrupt'); + errors.InvalidField = Error.subclass('InvalidField'); + errors.MissingField = Error.subclass('MissingField'); + errors.TotpCodeRequired = Error.subclass('TotpCodeRequired'); + errors.InvalidTotpCode = Error.subclass('InvalidTotpCode'); + errors.ConnectionError = Error.subclass('ConnectionError'); + errors.UnknownError = Error.subclass('UnknownError'); + + +/***/ }, +/* 3 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _ = __webpack_require__(8); + var crypto = __webpack_require__(6); + var errors = __webpack_require__(2); + var sjcl = __webpack_require__(7); + var protocol = __webpack_require__(4); + + function Wallet(params) { + var self = this; + var properties = [ + 'server', + 'username', + 'rawWalletId', + 'rawMainData', + 'rawKeychainData', + 'rawPrivateKey', + 'lockVersion' + ]; + + _.each(properties, function(param) { + self[param] = params[param]; + }); + + if (_.isEmpty(this.server)) { + throw new errors.MissingField('server parameter is required.'); + } + + // rtrim / + this.server = this.server.replace(/\/+$/g,''); + this.walletId = sjcl.codec.base64.fromBits(this.rawWalletId); + } + + Wallet.prototype.getServer = function() { + return this.server; + }; + + Wallet.prototype.getUsername = function() { + return this.username; + }; + + Wallet.prototype.getMainData = function() { + return this.rawMainData; + }; + + Wallet.prototype.getKeychainData = function() { + return this.rawKeychainData; + }; + + Wallet.prototype.setupTotp = function(params) { + params = _.extend(params, _.pick(this, [ + 'server', + 'username', + 'walletId', + 'totpKey', + 'totpCode', + 'lockVersion', + 'rawPrivateKey' + ])); + return protocol.setupTotp(params); + }; + + module.exports = Wallet; + +/***/ }, +/* 4 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _ = __webpack_require__(8); + var camelCase = __webpack_require__(26); + var Promise = __webpack_require__(9); + + module.exports = {}; + + // Add protocol methods + var protocolMethods = ['login', 'create_wallet', 'setup_totp', 'delete_wallet']; + _.each(protocolMethods, function(method) { + module.exports[camelCase(method)] = function(params) { + return Promise.resolve(params) + .then(__webpack_require__(11)("./"+method)); + } + }); + +/***/ }, +/* 5 */ +/***/ function(module, exports, __webpack_require__) { + + var nacl = __webpack_require__(17); + var base32 = __webpack_require__(24); + + function generateRandomTotpKey() { + var key = nacl.randomBytes(10); + // Google Authenticator doesn't like ='s in the end + return base32.encode(key).toString().replace(/=/g,''); + + } + + function generateTotpUri(key) { + return 'otpauth://totp/Stellar:'+ + 'username'+ + '/stellar-client?secret='+key+'&issuer=Stellar+Development+Foundation'; + } + + module.exports = { + generateRandomTotpKey: generateRandomTotpKey, + generateTotpUri: generateTotpUri + }; + +/***/ }, +/* 6 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict'; + + var crypto = __webpack_require__(18); + var errors = __webpack_require__(2); + var nacl = __webpack_require__(17); + var sjcl = __webpack_require__(7); + + module.exports = { + calculateMasterKey: calculateMasterKey, + decryptData: decryptData, + deriveWalletId: generateDeriveFromKeyFunction('CONST_W'), + deriveWalletKey: generateDeriveFromKeyFunction('CONST_KW'), + encryptData: encryptData, + sha1: makeHasher('sha1'), + sha256: makeHasher('sha256'), + signRequest: signRequest + }; + + function base64Encode(str) { + return (new Buffer(str)).toString('base64'); + } + function base64Decode(str) { + return (new Buffer(str, 'base64')).toString(); + } + + function signRequest(walletId, rawPrivateKey) { + return function(request) { + var serializedData = nacl.util.decodeUTF8(JSON.stringify(request._data)); + var signature = nacl.sign.detached(serializedData, rawPrivateKey); + signature = nacl.util.encodeBase64(signature); + request.set('Authorization', 'STELLAR-WALLET-V2 wallet-id="'+walletId+'", signature="'+signature+'"'); + } + } + + function makeHasher(algo) { + return function(value) { + var hasher = crypto.createHash(algo); + return hasher.update(value).digest("hex"); + }; + } + + function generateDeriveFromKeyFunction(token) { + return function(masterKey) { + var hmac = new sjcl.misc.hmac(masterKey, sjcl.hash.sha256); + return hmac.encrypt(token); + }; + } + + function encryptData(data, key) { + var cipherName = 'aes'; + var modeName = 'gcm'; + + var cipher = new sjcl.cipher[cipherName](key); + var rawIV = sjcl.random.randomWords(3); + var encryptedData = sjcl.mode[modeName].encrypt( + cipher, + sjcl.codec.utf8String.toBits(data), + rawIV + ); + + data = JSON.stringify({ + IV: sjcl.codec.base64.fromBits(rawIV), + cipherText: sjcl.codec.base64.fromBits(encryptedData), + cipherName: cipherName, + modeName: modeName + }); + + return base64Encode(data); + } + + function decryptData(encryptedData, key) { + var rawCipherText, rawIV, cipherName, modeName; + + try { + var resultObject = JSON.parse(base64Decode(encryptedData)); + rawIV = sjcl.codec.base64.toBits(resultObject.IV); + rawCipherText = sjcl.codec.base64.toBits(resultObject.cipherText); + cipherName = resultObject.cipherName; + modeName = resultObject.modeName; + } catch(e) { + new errors.DataCorrupt(); + } + + var cipher = new sjcl.cipher[cipherName](key); + var rawData = sjcl.mode[modeName].decrypt(cipher, rawCipherText, rawIV); + return sjcl.codec.utf8String.fromBits(rawData); + } + + function calculateMasterKey(s0, username, password, kdfParams) { + var salt = module.exports.sha256(s0+username); + + return sjcl.misc.scrypt( + password, + salt, + kdfParams.n, + kdfParams.r, + kdfParams.p, + kdfParams.bits + ); + } + + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(19).Buffer)) + +/***/ }, +/* 7 */ +/***/ function(module, exports, __webpack_require__) { + + var sjcl = __webpack_require__(22); + __webpack_require__(20).extendSjcl(sjcl); + module.exports = sjcl; + +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module, global) {/** + * @license + * Lo-Dash 2.4.1 (Custom Build) + * Build: `lodash -o ./dist/lodash.compat.js` + * Copyright 2012-2013 The Dojo Foundation + * Based on Underscore.js 1.5.2 + * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ + ;(function() { + + /** Used as a safe reference for `undefined` in pre ES5 environments */ + var undefined; + + /** Used to pool arrays and objects used internally */ + var arrayPool = [], + objectPool = []; + + /** Used to generate unique IDs */ + var idCounter = 0; + + /** Used internally to indicate various things */ + var indicatorObject = {}; + + /** Used to prefix keys to avoid issues with `__proto__` and properties on `Object.prototype` */ + var keyPrefix = +new Date + ''; + + /** Used as the size when optimizations are enabled for large arrays */ + var largeArraySize = 75; + + /** Used as the max size of the `arrayPool` and `objectPool` */ + var maxPoolSize = 40; + + /** Used to detect and test whitespace */ + var whitespace = ( + // whitespace + ' \t\x0B\f\xA0\ufeff' + + + // line terminators + '\n\r\u2028\u2029' + + + // unicode category "Zs" space separators + '\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000' + ); + + /** Used to match empty string literals in compiled template source */ + var reEmptyStringLeading = /\b__p \+= '';/g, + reEmptyStringMiddle = /\b(__p \+=) '' \+/g, + reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; + + /** + * Used to match ES6 template delimiters + * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-string-literals + */ + var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; + + /** Used to match regexp flags from their coerced string values */ + var reFlags = /\w*$/; + + /** Used to detected named functions */ + var reFuncName = /^\s*function[ \n\r\t]+\w/; + + /** Used to match "interpolate" template delimiters */ + var reInterpolate = /<%=([\s\S]+?)%>/g; + + /** Used to match leading whitespace and zeros to be removed */ + var reLeadingSpacesAndZeros = RegExp('^[' + whitespace + ']*0+(?=.$)'); + + /** Used to ensure capturing order of template delimiters */ + var reNoMatch = /($^)/; + + /** Used to detect functions containing a `this` reference */ + var reThis = /\bthis\b/; + + /** Used to match unescaped characters in compiled string literals */ + var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g; + + /** Used to assign default `context` object properties */ + var contextProps = [ + 'Array', 'Boolean', 'Date', 'Error', 'Function', 'Math', 'Number', 'Object', + 'RegExp', 'String', '_', 'attachEvent', 'clearTimeout', 'isFinite', 'isNaN', + 'parseInt', 'setTimeout' + ]; + + /** Used to fix the JScript [[DontEnum]] bug */ + var shadowedProps = [ + 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', + 'toLocaleString', 'toString', 'valueOf' + ]; + + /** Used to make template sourceURLs easier to identify */ + var templateCounter = 0; + + /** `Object#toString` result shortcuts */ + var argsClass = '[object Arguments]', + arrayClass = '[object Array]', + boolClass = '[object Boolean]', + dateClass = '[object Date]', + errorClass = '[object Error]', + funcClass = '[object Function]', + numberClass = '[object Number]', + objectClass = '[object Object]', + regexpClass = '[object RegExp]', + stringClass = '[object String]'; + + /** Used to identify object classifications that `_.clone` supports */ + var cloneableClasses = {}; + cloneableClasses[funcClass] = false; + cloneableClasses[argsClass] = cloneableClasses[arrayClass] = + cloneableClasses[boolClass] = cloneableClasses[dateClass] = + cloneableClasses[numberClass] = cloneableClasses[objectClass] = + cloneableClasses[regexpClass] = cloneableClasses[stringClass] = true; + + /** Used as an internal `_.debounce` options object */ + var debounceOptions = { + 'leading': false, + 'maxWait': 0, + 'trailing': false + }; + + /** Used as the property descriptor for `__bindData__` */ + var descriptor = { + 'configurable': false, + 'enumerable': false, + 'value': null, + 'writable': false + }; + + /** Used as the data object for `iteratorTemplate` */ + var iteratorData = { + 'args': '', + 'array': null, + 'bottom': '', + 'firstArg': '', + 'init': '', + 'keys': null, + 'loop': '', + 'shadowedProps': null, + 'support': null, + 'top': '', + 'useHas': false + }; + + /** Used to determine if values are of the language type Object */ + var objectTypes = { + 'boolean': false, + 'function': true, + 'object': true, + 'number': false, + 'string': false, + 'undefined': false + }; + + /** Used to escape characters for inclusion in compiled string literals */ + var stringEscapes = { + '\\': '\\', + "'": "'", + '\n': 'n', + '\r': 'r', + '\t': 't', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; + + /** Used as a reference to the global object */ + var root = (objectTypes[typeof window] && window) || this; + + /** Detect free variable `exports` */ + var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; + + /** Detect free variable `module` */ + var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; + + /** Detect the popular CommonJS extension `module.exports` */ + var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; + + /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */ + var freeGlobal = objectTypes[typeof global] && global; + if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) { + root = freeGlobal; + } + + /*--------------------------------------------------------------------------*/ + + /** + * The base implementation of `_.indexOf` without support for binary searches + * or `fromIndex` constraints. + * + * @private + * @param {Array} array The array to search. + * @param {*} value The value to search for. + * @param {number} [fromIndex=0] The index to search from. + * @returns {number} Returns the index of the matched value or `-1`. + */ + function baseIndexOf(array, value, fromIndex) { + var index = (fromIndex || 0) - 1, + length = array ? array.length : 0; + + while (++index < length) { + if (array[index] === value) { + return index; + } + } + return -1; + } + + /** + * An implementation of `_.contains` for cache objects that mimics the return + * signature of `_.indexOf` by returning `0` if the value is found, else `-1`. + * + * @private + * @param {Object} cache The cache object to inspect. + * @param {*} value The value to search for. + * @returns {number} Returns `0` if `value` is found, else `-1`. + */ + function cacheIndexOf(cache, value) { + var type = typeof value; + cache = cache.cache; + + if (type == 'boolean' || value == null) { + return cache[value] ? 0 : -1; + } + if (type != 'number' && type != 'string') { + type = 'object'; + } + var key = type == 'number' ? value : keyPrefix + value; + cache = (cache = cache[type]) && cache[key]; + + return type == 'object' + ? (cache && baseIndexOf(cache, value) > -1 ? 0 : -1) + : (cache ? 0 : -1); + } + + /** + * Adds a given value to the corresponding cache object. + * + * @private + * @param {*} value The value to add to the cache. + */ + function cachePush(value) { + var cache = this.cache, + type = typeof value; + + if (type == 'boolean' || value == null) { + cache[value] = true; + } else { + if (type != 'number' && type != 'string') { + type = 'object'; + } + var key = type == 'number' ? value : keyPrefix + value, + typeCache = cache[type] || (cache[type] = {}); + + if (type == 'object') { + (typeCache[key] || (typeCache[key] = [])).push(value); + } else { + typeCache[key] = true; + } + } + } + + /** + * Used by `_.max` and `_.min` as the default callback when a given + * collection is a string value. + * + * @private + * @param {string} value The character to inspect. + * @returns {number} Returns the code unit of given character. + */ + function charAtCallback(value) { + return value.charCodeAt(0); + } + + /** + * Used by `sortBy` to compare transformed `collection` elements, stable sorting + * them in ascending order. + * + * @private + * @param {Object} a The object to compare to `b`. + * @param {Object} b The object to compare to `a`. + * @returns {number} Returns the sort order indicator of `1` or `-1`. + */ + function compareAscending(a, b) { + var ac = a.criteria, + bc = b.criteria, + index = -1, + length = ac.length; + + while (++index < length) { + var value = ac[index], + other = bc[index]; + + if (value !== other) { + if (value > other || typeof value == 'undefined') { + return 1; + } + if (value < other || typeof other == 'undefined') { + return -1; + } + } + } + // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications + // that causes it, under certain circumstances, to return the same value for + // `a` and `b`. See https://github.com/jashkenas/underscore/pull/1247 + // + // This also ensures a stable sort in V8 and other engines. + // See http://code.google.com/p/v8/issues/detail?id=90 + return a.index - b.index; + } + + /** + * Creates a cache object to optimize linear searches of large arrays. + * + * @private + * @param {Array} [array=[]] The array to search. + * @returns {null|Object} Returns the cache object or `null` if caching should not be used. + */ + function createCache(array) { + var index = -1, + length = array.length, + first = array[0], + mid = array[(length / 2) | 0], + last = array[length - 1]; + + if (first && typeof first == 'object' && + mid && typeof mid == 'object' && last && typeof last == 'object') { + return false; + } + var cache = getObject(); + cache['false'] = cache['null'] = cache['true'] = cache['undefined'] = false; + + var result = getObject(); + result.array = array; + result.cache = cache; + result.push = cachePush; + + while (++index < length) { + result.push(array[index]); + } + return result; + } + + /** + * Used by `template` to escape characters for inclusion in compiled + * string literals. + * + * @private + * @param {string} match The matched character to escape. + * @returns {string} Returns the escaped character. + */ + function escapeStringChar(match) { + return '\\' + stringEscapes[match]; + } + + /** + * Gets an array from the array pool or creates a new one if the pool is empty. + * + * @private + * @returns {Array} The array from the pool. + */ + function getArray() { + return arrayPool.pop() || []; + } + + /** + * Gets an object from the object pool or creates a new one if the pool is empty. + * + * @private + * @returns {Object} The object from the pool. + */ + function getObject() { + return objectPool.pop() || { + 'array': null, + 'cache': null, + 'criteria': null, + 'false': false, + 'index': 0, + 'null': false, + 'number': null, + 'object': null, + 'push': null, + 'string': null, + 'true': false, + 'undefined': false, + 'value': null + }; + } + + /** + * Checks if `value` is a DOM node in IE < 9. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is a DOM node, else `false`. + */ + function isNode(value) { + // IE < 9 presents DOM nodes as `Object` objects except they have `toString` + // methods that are `typeof` "string" and still can coerce nodes to strings + return typeof value.toString != 'function' && typeof (value + '') == 'string'; + } + + /** + * Releases the given array back to the array pool. + * + * @private + * @param {Array} [array] The array to release. + */ + function releaseArray(array) { + array.length = 0; + if (arrayPool.length < maxPoolSize) { + arrayPool.push(array); + } + } + + /** + * Releases the given object back to the object pool. + * + * @private + * @param {Object} [object] The object to release. + */ + function releaseObject(object) { + var cache = object.cache; + if (cache) { + releaseObject(cache); + } + object.array = object.cache = object.criteria = object.object = object.number = object.string = object.value = null; + if (objectPool.length < maxPoolSize) { + objectPool.push(object); + } + } + + /** + * Slices the `collection` from the `start` index up to, but not including, + * the `end` index. + * + * Note: This function is used instead of `Array#slice` to support node lists + * in IE < 9 and to ensure dense arrays are returned. + * + * @private + * @param {Array|Object|string} collection The collection to slice. + * @param {number} start The start index. + * @param {number} end The end index. + * @returns {Array} Returns the new array. + */ + function slice(array, start, end) { + start || (start = 0); + if (typeof end == 'undefined') { + end = array ? array.length : 0; + } + var index = -1, + length = end - start || 0, + result = Array(length < 0 ? 0 : length); + + while (++index < length) { + result[index] = array[start + index]; + } + return result; + } + + /*--------------------------------------------------------------------------*/ + + /** + * Create a new `lodash` function using the given context object. + * + * @static + * @memberOf _ + * @category Utilities + * @param {Object} [context=root] The context object. + * @returns {Function} Returns the `lodash` function. + */ + function runInContext(context) { + // Avoid issues with some ES3 environments that attempt to use values, named + // after built-in constructors like `Object`, for the creation of literals. + // ES5 clears this up by stating that literals must use built-in constructors. + // See http://es5.github.io/#x11.1.5. + context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root; + + /** Native constructor references */ + var Array = context.Array, + Boolean = context.Boolean, + Date = context.Date, + Error = context.Error, + Function = context.Function, + Math = context.Math, + Number = context.Number, + Object = context.Object, + RegExp = context.RegExp, + String = context.String, + TypeError = context.TypeError; + + /** + * Used for `Array` method references. + * + * Normally `Array.prototype` would suffice, however, using an array literal + * avoids issues in Narwhal. + */ + var arrayRef = []; + + /** Used for native method references */ + var errorProto = Error.prototype, + objectProto = Object.prototype, + stringProto = String.prototype; + + /** Used to restore the original `_` reference in `noConflict` */ + var oldDash = context._; + + /** Used to resolve the internal [[Class]] of values */ + var toString = objectProto.toString; + + /** Used to detect if a method is native */ + var reNative = RegExp('^' + + String(toString) + .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + .replace(/toString| for [^\]]+/g, '.*?') + '$' + ); + + /** Native method shortcuts */ + var ceil = Math.ceil, + clearTimeout = context.clearTimeout, + floor = Math.floor, + fnToString = Function.prototype.toString, + getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf, + hasOwnProperty = objectProto.hasOwnProperty, + push = arrayRef.push, + propertyIsEnumerable = objectProto.propertyIsEnumerable, + setTimeout = context.setTimeout, + splice = arrayRef.splice, + unshift = arrayRef.unshift; + + /** Used to set meta data on functions */ + var defineProperty = (function() { + // IE 8 only accepts DOM elements + try { + var o = {}, + func = isNative(func = Object.defineProperty) && func, + result = func(o, o, o) && func; + } catch(e) { } + return result; + }()); + + /* Native method shortcuts for methods with the same name as other `lodash` methods */ + var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, + nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, + nativeIsFinite = context.isFinite, + nativeIsNaN = context.isNaN, + nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys, + nativeMax = Math.max, + nativeMin = Math.min, + nativeParseInt = context.parseInt, + nativeRandom = Math.random; + + /** Used to lookup a built-in constructor by [[Class]] */ + var ctorByClass = {}; + ctorByClass[arrayClass] = Array; + ctorByClass[boolClass] = Boolean; + ctorByClass[dateClass] = Date; + ctorByClass[funcClass] = Function; + ctorByClass[objectClass] = Object; + ctorByClass[numberClass] = Number; + ctorByClass[regexpClass] = RegExp; + ctorByClass[stringClass] = String; + + /** Used to avoid iterating non-enumerable properties in IE < 9 */ + var nonEnumProps = {}; + nonEnumProps[arrayClass] = nonEnumProps[dateClass] = nonEnumProps[numberClass] = { 'constructor': true, 'toLocaleString': true, 'toString': true, 'valueOf': true }; + nonEnumProps[boolClass] = nonEnumProps[stringClass] = { 'constructor': true, 'toString': true, 'valueOf': true }; + nonEnumProps[errorClass] = nonEnumProps[funcClass] = nonEnumProps[regexpClass] = { 'constructor': true, 'toString': true }; + nonEnumProps[objectClass] = { 'constructor': true }; + + (function() { + var length = shadowedProps.length; + while (length--) { + var key = shadowedProps[length]; + for (var className in nonEnumProps) { + if (hasOwnProperty.call(nonEnumProps, className) && !hasOwnProperty.call(nonEnumProps[className], key)) { + nonEnumProps[className][key] = false; + } + } + } + }()); + + /*--------------------------------------------------------------------------*/ + + /** + * Creates a `lodash` object which wraps the given value to enable intuitive + * method chaining. + * + * In addition to Lo-Dash methods, wrappers also have the following `Array` methods: + * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, + * and `unshift` + * + * Chaining is supported in custom builds as long as the `value` method is + * implicitly or explicitly included in the build. + * + * The chainable wrapper functions are: + * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, + * `compose`, `concat`, `countBy`, `create`, `createCallback`, `curry`, + * `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, + * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, + * `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, + * `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, + * `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `pull`, `push`, + * `range`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, + * `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `transform`, + * `union`, `uniq`, `unshift`, `unzip`, `values`, `where`, `without`, `wrap`, + * and `zip` + * + * The non-chainable wrapper functions are: + * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `findIndex`, + * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `has`, `identity`, + * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, + * `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, + * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, + * `lastIndexOf`, `mixin`, `noConflict`, `parseInt`, `pop`, `random`, `reduce`, + * `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `runInContext`, + * `template`, `unescape`, `uniqueId`, and `value` + * + * The wrapper functions `first` and `last` return wrapped values when `n` is + * provided, otherwise they return unwrapped values. + * + * Explicit chaining can be enabled by using the `_.chain` method. + * + * @name _ + * @constructor + * @category Chaining + * @param {*} value The value to wrap in a `lodash` instance. + * @returns {Object} Returns a `lodash` instance. + * @example + * + * var wrapped = _([1, 2, 3]); + * + * // returns an unwrapped value + * wrapped.reduce(function(sum, num) { + * return sum + num; + * }); + * // => 6 + * + * // returns a wrapped value + * var squares = wrapped.map(function(num) { + * return num * num; + * }); + * + * _.isArray(squares); + * // => false + * + * _.isArray(squares.value()); + * // => true + */ + function lodash(value) { + // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor + return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__')) + ? value + : new lodashWrapper(value); + } + + /** + * A fast path for creating `lodash` wrapper objects. + * + * @private + * @param {*} value The value to wrap in a `lodash` instance. + * @param {boolean} chainAll A flag to enable chaining for all methods + * @returns {Object} Returns a `lodash` instance. + */ + function lodashWrapper(value, chainAll) { + this.__chain__ = !!chainAll; + this.__wrapped__ = value; + } + // ensure `new lodashWrapper` is an instance of `lodash` + lodashWrapper.prototype = lodash.prototype; + + /** + * An object used to flag environments features. + * + * @static + * @memberOf _ + * @type Object + */ + var support = lodash.support = {}; + + (function() { + var ctor = function() { this.x = 1; }, + object = { '0': 1, 'length': 1 }, + props = []; + + ctor.prototype = { 'valueOf': 1, 'y': 1 }; + for (var key in new ctor) { props.push(key); } + for (key in arguments) { } + + /** + * Detect if an `arguments` object's [[Class]] is resolvable (all but Firefox < 4, IE < 9). + * + * @memberOf _.support + * @type boolean + */ + support.argsClass = toString.call(arguments) == argsClass; + + /** + * Detect if `arguments` objects are `Object` objects (all but Narwhal and Opera < 10.5). + * + * @memberOf _.support + * @type boolean + */ + support.argsObject = arguments.constructor == Object && !(arguments instanceof Array); + + /** + * Detect if `name` or `message` properties of `Error.prototype` are + * enumerable by default. (IE < 9, Safari < 5.1) + * + * @memberOf _.support + * @type boolean + */ + support.enumErrorProps = propertyIsEnumerable.call(errorProto, 'message') || propertyIsEnumerable.call(errorProto, 'name'); + + /** + * Detect if `prototype` properties are enumerable by default. + * + * Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1 + * (if the prototype or a property on the prototype has been set) + * incorrectly sets a function's `prototype` property [[Enumerable]] + * value to `true`. + * + * @memberOf _.support + * @type boolean + */ + support.enumPrototypes = propertyIsEnumerable.call(ctor, 'prototype'); + + /** + * Detect if functions can be decompiled by `Function#toString` + * (all but PS3 and older Opera mobile browsers & avoided in Windows 8 apps). + * + * @memberOf _.support + * @type boolean + */ + support.funcDecomp = !isNative(context.WinRTError) && reThis.test(runInContext); + + /** + * Detect if `Function#name` is supported (all but IE). + * + * @memberOf _.support + * @type boolean + */ + support.funcNames = typeof Function.name == 'string'; + + /** + * Detect if `arguments` object indexes are non-enumerable + * (Firefox < 4, IE < 9, PhantomJS, Safari < 5.1). + * + * @memberOf _.support + * @type boolean + */ + support.nonEnumArgs = key != 0; + + /** + * Detect if properties shadowing those on `Object.prototype` are non-enumerable. + * + * In IE < 9 an objects own properties, shadowing non-enumerable ones, are + * made non-enumerable as well (a.k.a the JScript [[DontEnum]] bug). + * + * @memberOf _.support + * @type boolean + */ + support.nonEnumShadows = !/valueOf/.test(props); + + /** + * Detect if own properties are iterated after inherited properties (all but IE < 9). + * + * @memberOf _.support + * @type boolean + */ + support.ownLast = props[0] != 'x'; + + /** + * Detect if `Array#shift` and `Array#splice` augment array-like objects correctly. + * + * Firefox < 10, IE compatibility mode, and IE < 9 have buggy Array `shift()` + * and `splice()` functions that fail to remove the last element, `value[0]`, + * of array-like objects even though the `length` property is set to `0`. + * The `shift()` method is buggy in IE 8 compatibility mode, while `splice()` + * is buggy regardless of mode in IE < 9 and buggy in compatibility mode in IE 9. + * + * @memberOf _.support + * @type boolean + */ + support.spliceObjects = (arrayRef.splice.call(object, 0, 1), !object[0]); + + /** + * Detect lack of support for accessing string characters by index. + * + * IE < 8 can't access characters by index and IE 8 can only access + * characters by index on string literals. + * + * @memberOf _.support + * @type boolean + */ + support.unindexedChars = ('x'[0] + Object('x')[0]) != 'xx'; + + /** + * Detect if a DOM node's [[Class]] is resolvable (all but IE < 9) + * and that the JS engine errors when attempting to coerce an object to + * a string without a `toString` function. + * + * @memberOf _.support + * @type boolean + */ + try { + support.nodeClass = !(toString.call(document) == objectClass && !({ 'toString': 0 } + '')); + } catch(e) { + support.nodeClass = true; + } + }(1)); + + /** + * By default, the template delimiters used by Lo-Dash are similar to those in + * embedded Ruby (ERB). Change the following template settings to use alternative + * delimiters. + * + * @static + * @memberOf _ + * @type Object + */ + lodash.templateSettings = { + + /** + * Used to detect `data` property values to be HTML-escaped. + * + * @memberOf _.templateSettings + * @type RegExp + */ + 'escape': /<%-([\s\S]+?)%>/g, + + /** + * Used to detect code to be evaluated. + * + * @memberOf _.templateSettings + * @type RegExp + */ + 'evaluate': /<%([\s\S]+?)%>/g, + + /** + * Used to detect `data` property values to inject. + * + * @memberOf _.templateSettings + * @type RegExp + */ + 'interpolate': reInterpolate, + + /** + * Used to reference the data object in the template text. + * + * @memberOf _.templateSettings + * @type string + */ + 'variable': '', + + /** + * Used to import variables into the compiled template. + * + * @memberOf _.templateSettings + * @type Object + */ + 'imports': { + + /** + * A reference to the `lodash` function. + * + * @memberOf _.templateSettings.imports + * @type Function + */ + '_': lodash + } + }; + + /*--------------------------------------------------------------------------*/ + + /** + * The template used to create iterator functions. + * + * @private + * @param {Object} data The data object used to populate the text. + * @returns {string} Returns the interpolated text. + */ + var iteratorTemplate = function(obj) { + + var __p = 'var index, iterable = ' + + (obj.firstArg) + + ', result = ' + + (obj.init) + + ';\nif (!iterable) return result;\n' + + (obj.top) + + ';'; + if (obj.array) { + __p += '\nvar length = iterable.length; index = -1;\nif (' + + (obj.array) + + ') { '; + if (support.unindexedChars) { + __p += '\n if (isString(iterable)) {\n iterable = iterable.split(\'\')\n } '; + } + __p += '\n while (++index < length) {\n ' + + (obj.loop) + + ';\n }\n}\nelse { '; + } else if (support.nonEnumArgs) { + __p += '\n var length = iterable.length; index = -1;\n if (length && isArguments(iterable)) {\n while (++index < length) {\n index += \'\';\n ' + + (obj.loop) + + ';\n }\n } else { '; + } + + if (support.enumPrototypes) { + __p += '\n var skipProto = typeof iterable == \'function\';\n '; + } + + if (support.enumErrorProps) { + __p += '\n var skipErrorProps = iterable === errorProto || iterable instanceof Error;\n '; + } + + var conditions = []; if (support.enumPrototypes) { conditions.push('!(skipProto && index == "prototype")'); } if (support.enumErrorProps) { conditions.push('!(skipErrorProps && (index == "message" || index == "name"))'); } + + if (obj.useHas && obj.keys) { + __p += '\n var ownIndex = -1,\n ownProps = objectTypes[typeof iterable] && keys(iterable),\n length = ownProps ? ownProps.length : 0;\n\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n'; + if (conditions.length) { + __p += ' if (' + + (conditions.join(' && ')) + + ') {\n '; + } + __p += + (obj.loop) + + '; '; + if (conditions.length) { + __p += '\n }'; + } + __p += '\n } '; + } else { + __p += '\n for (index in iterable) {\n'; + if (obj.useHas) { conditions.push("hasOwnProperty.call(iterable, index)"); } if (conditions.length) { + __p += ' if (' + + (conditions.join(' && ')) + + ') {\n '; + } + __p += + (obj.loop) + + '; '; + if (conditions.length) { + __p += '\n }'; + } + __p += '\n } '; + if (support.nonEnumShadows) { + __p += '\n\n if (iterable !== objectProto) {\n var ctor = iterable.constructor,\n isProto = iterable === (ctor && ctor.prototype),\n className = iterable === stringProto ? stringClass : iterable === errorProto ? errorClass : toString.call(iterable),\n nonEnum = nonEnumProps[className];\n '; + for (k = 0; k < 7; k++) { + __p += '\n index = \'' + + (obj.shadowedProps[k]) + + '\';\n if ((!(isProto && nonEnum[index]) && hasOwnProperty.call(iterable, index))'; + if (!obj.useHas) { + __p += ' || (!nonEnum[index] && iterable[index] !== objectProto[index])'; + } + __p += ') {\n ' + + (obj.loop) + + ';\n } '; + } + __p += '\n } '; + } + + } + + if (obj.array || support.nonEnumArgs) { + __p += '\n}'; + } + __p += + (obj.bottom) + + ';\nreturn result'; + + return __p + }; + + /*--------------------------------------------------------------------------*/ + + /** + * The base implementation of `_.bind` that creates the bound function and + * sets its meta data. + * + * @private + * @param {Array} bindData The bind data array. + * @returns {Function} Returns the new bound function. + */ + function baseBind(bindData) { + var func = bindData[0], + partialArgs = bindData[2], + thisArg = bindData[4]; + + function bound() { + // `Function#bind` spec + // http://es5.github.io/#x15.3.4.5 + if (partialArgs) { + // avoid `arguments` object deoptimizations by using `slice` instead + // of `Array.prototype.slice.call` and not assigning `arguments` to a + // variable as a ternary expression + var args = slice(partialArgs); + push.apply(args, arguments); + } + // mimic the constructor's `return` behavior + // http://es5.github.io/#x13.2.2 + if (this instanceof bound) { + // ensure `new bound` is an instance of `func` + var thisBinding = baseCreate(func.prototype), + result = func.apply(thisBinding, args || arguments); + return isObject(result) ? result : thisBinding; + } + return func.apply(thisArg, args || arguments); + } + setBindData(bound, bindData); + return bound; + } + + /** + * The base implementation of `_.clone` without argument juggling or support + * for `thisArg` binding. + * + * @private + * @param {*} value The value to clone. + * @param {boolean} [isDeep=false] Specify a deep clone. + * @param {Function} [callback] The function to customize cloning values. + * @param {Array} [stackA=[]] Tracks traversed source objects. + * @param {Array} [stackB=[]] Associates clones with source counterparts. + * @returns {*} Returns the cloned value. + */ + function baseClone(value, isDeep, callback, stackA, stackB) { + if (callback) { + var result = callback(value); + if (typeof result != 'undefined') { + return result; + } + } + // inspect [[Class]] + var isObj = isObject(value); + if (isObj) { + var className = toString.call(value); + if (!cloneableClasses[className] || (!support.nodeClass && isNode(value))) { + return value; + } + var ctor = ctorByClass[className]; + switch (className) { + case boolClass: + case dateClass: + return new ctor(+value); + + case numberClass: + case stringClass: + return new ctor(value); + + case regexpClass: + result = ctor(value.source, reFlags.exec(value)); + result.lastIndex = value.lastIndex; + return result; + } + } else { + return value; + } + var isArr = isArray(value); + if (isDeep) { + // check for circular references and return corresponding clone + var initedStack = !stackA; + stackA || (stackA = getArray()); + stackB || (stackB = getArray()); + + var length = stackA.length; + while (length--) { + if (stackA[length] == value) { + return stackB[length]; + } + } + result = isArr ? ctor(value.length) : {}; + } + else { + result = isArr ? slice(value) : assign({}, value); + } + // add array properties assigned by `RegExp#exec` + if (isArr) { + if (hasOwnProperty.call(value, 'index')) { + result.index = value.index; + } + if (hasOwnProperty.call(value, 'input')) { + result.input = value.input; + } + } + // exit for shallow clone + if (!isDeep) { + return result; + } + // add the source value to the stack of traversed objects + // and associate it with its clone + stackA.push(value); + stackB.push(result); + + // recursively populate clone (susceptible to call stack limits) + (isArr ? baseEach : forOwn)(value, function(objValue, key) { + result[key] = baseClone(objValue, isDeep, callback, stackA, stackB); + }); + + if (initedStack) { + releaseArray(stackA); + releaseArray(stackB); + } + return result; + } + + /** + * The base implementation of `_.create` without support for assigning + * properties to the created object. + * + * @private + * @param {Object} prototype The object to inherit from. + * @returns {Object} Returns the new object. + */ + function baseCreate(prototype, properties) { + return isObject(prototype) ? nativeCreate(prototype) : {}; + } + // fallback for browsers without `Object.create` + if (!nativeCreate) { + baseCreate = (function() { + function Object() {} + return function(prototype) { + if (isObject(prototype)) { + Object.prototype = prototype; + var result = new Object; + Object.prototype = null; + } + return result || context.Object(); + }; + }()); + } + + /** + * The base implementation of `_.createCallback` without support for creating + * "_.pluck" or "_.where" style callbacks. + * + * @private + * @param {*} [func=identity] The value to convert to a callback. + * @param {*} [thisArg] The `this` binding of the created callback. + * @param {number} [argCount] The number of arguments the callback accepts. + * @returns {Function} Returns a callback function. + */ + function baseCreateCallback(func, thisArg, argCount) { + if (typeof func != 'function') { + return identity; + } + // exit early for no `thisArg` or already bound by `Function#bind` + if (typeof thisArg == 'undefined' || !('prototype' in func)) { + return func; + } + var bindData = func.__bindData__; + if (typeof bindData == 'undefined') { + if (support.funcNames) { + bindData = !func.name; + } + bindData = bindData || !support.funcDecomp; + if (!bindData) { + var source = fnToString.call(func); + if (!support.funcNames) { + bindData = !reFuncName.test(source); + } + if (!bindData) { + // checks if `func` references the `this` keyword and stores the result + bindData = reThis.test(source); + setBindData(func, bindData); + } + } + } + // exit early if there are no `this` references or `func` is bound + if (bindData === false || (bindData !== true && bindData[1] & 1)) { + return func; + } + switch (argCount) { + case 1: return function(value) { + return func.call(thisArg, value); + }; + case 2: return function(a, b) { + return func.call(thisArg, a, b); + }; + case 3: return function(value, index, collection) { + return func.call(thisArg, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(thisArg, accumulator, value, index, collection); + }; + } + return bind(func, thisArg); + } + + /** + * The base implementation of `createWrapper` that creates the wrapper and + * sets its meta data. + * + * @private + * @param {Array} bindData The bind data array. + * @returns {Function} Returns the new function. + */ + function baseCreateWrapper(bindData) { + var func = bindData[0], + bitmask = bindData[1], + partialArgs = bindData[2], + partialRightArgs = bindData[3], + thisArg = bindData[4], + arity = bindData[5]; + + var isBind = bitmask & 1, + isBindKey = bitmask & 2, + isCurry = bitmask & 4, + isCurryBound = bitmask & 8, + key = func; + + function bound() { + var thisBinding = isBind ? thisArg : this; + if (partialArgs) { + var args = slice(partialArgs); + push.apply(args, arguments); + } + if (partialRightArgs || isCurry) { + args || (args = slice(arguments)); + if (partialRightArgs) { + push.apply(args, partialRightArgs); + } + if (isCurry && args.length < arity) { + bitmask |= 16 & ~32; + return baseCreateWrapper([func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity]); + } + } + args || (args = arguments); + if (isBindKey) { + func = thisBinding[key]; + } + if (this instanceof bound) { + thisBinding = baseCreate(func.prototype); + var result = func.apply(thisBinding, args); + return isObject(result) ? result : thisBinding; + } + return func.apply(thisBinding, args); + } + setBindData(bound, bindData); + return bound; + } + + /** + * The base implementation of `_.difference` that accepts a single array + * of values to exclude. + * + * @private + * @param {Array} array The array to process. + * @param {Array} [values] The array of values to exclude. + * @returns {Array} Returns a new array of filtered values. + */ + function baseDifference(array, values) { + var index = -1, + indexOf = getIndexOf(), + length = array ? array.length : 0, + isLarge = length >= largeArraySize && indexOf === baseIndexOf, + result = []; + + if (isLarge) { + var cache = createCache(values); + if (cache) { + indexOf = cacheIndexOf; + values = cache; + } else { + isLarge = false; + } + } + while (++index < length) { + var value = array[index]; + if (indexOf(values, value) < 0) { + result.push(value); + } + } + if (isLarge) { + releaseObject(values); + } + return result; + } + + /** + * The base implementation of `_.flatten` without support for callback + * shorthands or `thisArg` binding. + * + * @private + * @param {Array} array The array to flatten. + * @param {boolean} [isShallow=false] A flag to restrict flattening to a single level. + * @param {boolean} [isStrict=false] A flag to restrict flattening to arrays and `arguments` objects. + * @param {number} [fromIndex=0] The index to start from. + * @returns {Array} Returns a new flattened array. + */ + function baseFlatten(array, isShallow, isStrict, fromIndex) { + var index = (fromIndex || 0) - 1, + length = array ? array.length : 0, + result = []; + + while (++index < length) { + var value = array[index]; + + if (value && typeof value == 'object' && typeof value.length == 'number' + && (isArray(value) || isArguments(value))) { + // recursively flatten arrays (susceptible to call stack limits) + if (!isShallow) { + value = baseFlatten(value, isShallow, isStrict); + } + var valIndex = -1, + valLength = value.length, + resIndex = result.length; + + result.length += valLength; + while (++valIndex < valLength) { + result[resIndex++] = value[valIndex]; + } + } else if (!isStrict) { + result.push(value); + } + } + return result; + } + + /** + * The base implementation of `_.isEqual`, without support for `thisArg` binding, + * that allows partial "_.where" style comparisons. + * + * @private + * @param {*} a The value to compare. + * @param {*} b The other value to compare. + * @param {Function} [callback] The function to customize comparing values. + * @param {Function} [isWhere=false] A flag to indicate performing partial comparisons. + * @param {Array} [stackA=[]] Tracks traversed `a` objects. + * @param {Array} [stackB=[]] Tracks traversed `b` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ + function baseIsEqual(a, b, callback, isWhere, stackA, stackB) { + // used to indicate that when comparing objects, `a` has at least the properties of `b` + if (callback) { + var result = callback(a, b); + if (typeof result != 'undefined') { + return !!result; + } + } + // exit early for identical values + if (a === b) { + // treat `+0` vs. `-0` as not equal + return a !== 0 || (1 / a == 1 / b); + } + var type = typeof a, + otherType = typeof b; + + // exit early for unlike primitive values + if (a === a && + !(a && objectTypes[type]) && + !(b && objectTypes[otherType])) { + return false; + } + // exit early for `null` and `undefined` avoiding ES3's Function#call behavior + // http://es5.github.io/#x15.3.4.4 + if (a == null || b == null) { + return a === b; + } + // compare [[Class]] names + var className = toString.call(a), + otherClass = toString.call(b); + + if (className == argsClass) { + className = objectClass; + } + if (otherClass == argsClass) { + otherClass = objectClass; + } + if (className != otherClass) { + return false; + } + switch (className) { + case boolClass: + case dateClass: + // coerce dates and booleans to numbers, dates to milliseconds and booleans + // to `1` or `0` treating invalid dates coerced to `NaN` as not equal + return +a == +b; + + case numberClass: + // treat `NaN` vs. `NaN` as equal + return (a != +a) + ? b != +b + // but treat `+0` vs. `-0` as not equal + : (a == 0 ? (1 / a == 1 / b) : a == +b); + + case regexpClass: + case stringClass: + // coerce regexes to strings (http://es5.github.io/#x15.10.6.4) + // treat string primitives and their corresponding object instances as equal + return a == String(b); + } + var isArr = className == arrayClass; + if (!isArr) { + // unwrap any `lodash` wrapped values + var aWrapped = hasOwnProperty.call(a, '__wrapped__'), + bWrapped = hasOwnProperty.call(b, '__wrapped__'); + + if (aWrapped || bWrapped) { + return baseIsEqual(aWrapped ? a.__wrapped__ : a, bWrapped ? b.__wrapped__ : b, callback, isWhere, stackA, stackB); + } + // exit for functions and DOM nodes + if (className != objectClass || (!support.nodeClass && (isNode(a) || isNode(b)))) { + return false; + } + // in older versions of Opera, `arguments` objects have `Array` constructors + var ctorA = !support.argsObject && isArguments(a) ? Object : a.constructor, + ctorB = !support.argsObject && isArguments(b) ? Object : b.constructor; + + // non `Object` object instances with different constructors are not equal + if (ctorA != ctorB && + !(isFunction(ctorA) && ctorA instanceof ctorA && isFunction(ctorB) && ctorB instanceof ctorB) && + ('constructor' in a && 'constructor' in b) + ) { + return false; + } + } + // assume cyclic structures are equal + // the algorithm for detecting cyclic structures is adapted from ES 5.1 + // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3) + var initedStack = !stackA; + stackA || (stackA = getArray()); + stackB || (stackB = getArray()); + + var length = stackA.length; + while (length--) { + if (stackA[length] == a) { + return stackB[length] == b; + } + } + var size = 0; + result = true; + + // add `a` and `b` to the stack of traversed objects + stackA.push(a); + stackB.push(b); + + // recursively compare objects and arrays (susceptible to call stack limits) + if (isArr) { + // compare lengths to determine if a deep comparison is necessary + length = a.length; + size = b.length; + result = size == length; + + if (result || isWhere) { + // deep compare the contents, ignoring non-numeric properties + while (size--) { + var index = length, + value = b[size]; + + if (isWhere) { + while (index--) { + if ((result = baseIsEqual(a[index], value, callback, isWhere, stackA, stackB))) { + break; + } + } + } else if (!(result = baseIsEqual(a[size], value, callback, isWhere, stackA, stackB))) { + break; + } + } + } + } + else { + // deep compare objects using `forIn`, instead of `forOwn`, to avoid `Object.keys` + // which, in this case, is more costly + forIn(b, function(value, key, b) { + if (hasOwnProperty.call(b, key)) { + // count the number of properties. + size++; + // deep compare each property value. + return (result = hasOwnProperty.call(a, key) && baseIsEqual(a[key], value, callback, isWhere, stackA, stackB)); + } + }); + + if (result && !isWhere) { + // ensure both objects have the same number of properties + forIn(a, function(value, key, a) { + if (hasOwnProperty.call(a, key)) { + // `size` will be `-1` if `a` has more properties than `b` + return (result = --size > -1); + } + }); + } + } + stackA.pop(); + stackB.pop(); + + if (initedStack) { + releaseArray(stackA); + releaseArray(stackB); + } + return result; + } + + /** + * The base implementation of `_.merge` without argument juggling or support + * for `thisArg` binding. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {Function} [callback] The function to customize merging properties. + * @param {Array} [stackA=[]] Tracks traversed source objects. + * @param {Array} [stackB=[]] Associates values with source counterparts. + */ + function baseMerge(object, source, callback, stackA, stackB) { + (isArray(source) ? forEach : forOwn)(source, function(source, key) { + var found, + isArr, + result = source, + value = object[key]; + + if (source && ((isArr = isArray(source)) || isPlainObject(source))) { + // avoid merging previously merged cyclic sources + var stackLength = stackA.length; + while (stackLength--) { + if ((found = stackA[stackLength] == source)) { + value = stackB[stackLength]; + break; + } + } + if (!found) { + var isShallow; + if (callback) { + result = callback(value, source); + if ((isShallow = typeof result != 'undefined')) { + value = result; + } + } + if (!isShallow) { + value = isArr + ? (isArray(value) ? value : []) + : (isPlainObject(value) ? value : {}); + } + // add `source` and associated `value` to the stack of traversed objects + stackA.push(source); + stackB.push(value); + + // recursively merge objects and arrays (susceptible to call stack limits) + if (!isShallow) { + baseMerge(value, source, callback, stackA, stackB); + } + } + } + else { + if (callback) { + result = callback(value, source); + if (typeof result == 'undefined') { + result = source; + } + } + if (typeof result != 'undefined') { + value = result; + } + } + object[key] = value; + }); + } + + /** + * The base implementation of `_.random` without argument juggling or support + * for returning floating-point numbers. + * + * @private + * @param {number} min The minimum possible value. + * @param {number} max The maximum possible value. + * @returns {number} Returns a random number. + */ + function baseRandom(min, max) { + return min + floor(nativeRandom() * (max - min + 1)); + } + + /** + * The base implementation of `_.uniq` without support for callback shorthands + * or `thisArg` binding. + * + * @private + * @param {Array} array The array to process. + * @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted. + * @param {Function} [callback] The function called per iteration. + * @returns {Array} Returns a duplicate-value-free array. + */ + function baseUniq(array, isSorted, callback) { + var index = -1, + indexOf = getIndexOf(), + length = array ? array.length : 0, + result = []; + + var isLarge = !isSorted && length >= largeArraySize && indexOf === baseIndexOf, + seen = (callback || isLarge) ? getArray() : result; + + if (isLarge) { + var cache = createCache(seen); + indexOf = cacheIndexOf; + seen = cache; + } + while (++index < length) { + var value = array[index], + computed = callback ? callback(value, index, array) : value; + + if (isSorted + ? !index || seen[seen.length - 1] !== computed + : indexOf(seen, computed) < 0 + ) { + if (callback || isLarge) { + seen.push(computed); + } + result.push(value); + } + } + if (isLarge) { + releaseArray(seen.array); + releaseObject(seen); + } else if (callback) { + releaseArray(seen); + } + return result; + } + + /** + * Creates a function that aggregates a collection, creating an object composed + * of keys generated from the results of running each element of the collection + * through a callback. The given `setter` function sets the keys and values + * of the composed object. + * + * @private + * @param {Function} setter The setter function. + * @returns {Function} Returns the new aggregator function. + */ + function createAggregator(setter) { + return function(collection, callback, thisArg) { + var result = {}; + callback = lodash.createCallback(callback, thisArg, 3); + + if (isArray(collection)) { + var index = -1, + length = collection.length; + + while (++index < length) { + var value = collection[index]; + setter(result, value, callback(value, index, collection), collection); + } + } else { + baseEach(collection, function(value, key, collection) { + setter(result, value, callback(value, key, collection), collection); + }); + } + return result; + }; + } + + /** + * Creates a function that, when called, either curries or invokes `func` + * with an optional `this` binding and partially applied arguments. + * + * @private + * @param {Function|string} func The function or method name to reference. + * @param {number} bitmask The bitmask of method flags to compose. + * The bitmask may be composed of the following flags: + * 1 - `_.bind` + * 2 - `_.bindKey` + * 4 - `_.curry` + * 8 - `_.curry` (bound) + * 16 - `_.partial` + * 32 - `_.partialRight` + * @param {Array} [partialArgs] An array of arguments to prepend to those + * provided to the new function. + * @param {Array} [partialRightArgs] An array of arguments to append to those + * provided to the new function. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new function. + */ + function createWrapper(func, bitmask, partialArgs, partialRightArgs, thisArg, arity) { + var isBind = bitmask & 1, + isBindKey = bitmask & 2, + isCurry = bitmask & 4, + isCurryBound = bitmask & 8, + isPartial = bitmask & 16, + isPartialRight = bitmask & 32; + + if (!isBindKey && !isFunction(func)) { + throw new TypeError; + } + if (isPartial && !partialArgs.length) { + bitmask &= ~16; + isPartial = partialArgs = false; + } + if (isPartialRight && !partialRightArgs.length) { + bitmask &= ~32; + isPartialRight = partialRightArgs = false; + } + var bindData = func && func.__bindData__; + if (bindData && bindData !== true) { + // clone `bindData` + bindData = slice(bindData); + if (bindData[2]) { + bindData[2] = slice(bindData[2]); + } + if (bindData[3]) { + bindData[3] = slice(bindData[3]); + } + // set `thisBinding` is not previously bound + if (isBind && !(bindData[1] & 1)) { + bindData[4] = thisArg; + } + // set if previously bound but not currently (subsequent curried functions) + if (!isBind && bindData[1] & 1) { + bitmask |= 8; + } + // set curried arity if not yet set + if (isCurry && !(bindData[1] & 4)) { + bindData[5] = arity; + } + // append partial left arguments + if (isPartial) { + push.apply(bindData[2] || (bindData[2] = []), partialArgs); + } + // append partial right arguments + if (isPartialRight) { + unshift.apply(bindData[3] || (bindData[3] = []), partialRightArgs); + } + // merge flags + bindData[1] |= bitmask; + return createWrapper.apply(null, bindData); + } + // fast path for `_.bind` + var creater = (bitmask == 1 || bitmask === 17) ? baseBind : baseCreateWrapper; + return creater([func, bitmask, partialArgs, partialRightArgs, thisArg, arity]); + } + + /** + * Creates compiled iteration functions. + * + * @private + * @param {...Object} [options] The compile options object(s). + * @param {string} [options.array] Code to determine if the iterable is an array or array-like. + * @param {boolean} [options.useHas] Specify using `hasOwnProperty` checks in the object loop. + * @param {Function} [options.keys] A reference to `_.keys` for use in own property iteration. + * @param {string} [options.args] A comma separated string of iteration function arguments. + * @param {string} [options.top] Code to execute before the iteration branches. + * @param {string} [options.loop] Code to execute in the object loop. + * @param {string} [options.bottom] Code to execute after the iteration branches. + * @returns {Function} Returns the compiled function. + */ + function createIterator() { + // data properties + iteratorData.shadowedProps = shadowedProps; + + // iterator options + iteratorData.array = iteratorData.bottom = iteratorData.loop = iteratorData.top = ''; + iteratorData.init = 'iterable'; + iteratorData.useHas = true; + + // merge options into a template data object + for (var object, index = 0; object = arguments[index]; index++) { + for (var key in object) { + iteratorData[key] = object[key]; + } + } + var args = iteratorData.args; + iteratorData.firstArg = /^[^,]+/.exec(args)[0]; + + // create the function factory + var factory = Function( + 'baseCreateCallback, errorClass, errorProto, hasOwnProperty, ' + + 'indicatorObject, isArguments, isArray, isString, keys, objectProto, ' + + 'objectTypes, nonEnumProps, stringClass, stringProto, toString', + 'return function(' + args + ') {\n' + iteratorTemplate(iteratorData) + '\n}' + ); + + // return the compiled function + return factory( + baseCreateCallback, errorClass, errorProto, hasOwnProperty, + indicatorObject, isArguments, isArray, isString, iteratorData.keys, objectProto, + objectTypes, nonEnumProps, stringClass, stringProto, toString + ); + } + + /** + * Used by `escape` to convert characters to HTML entities. + * + * @private + * @param {string} match The matched character to escape. + * @returns {string} Returns the escaped character. + */ + function escapeHtmlChar(match) { + return htmlEscapes[match]; + } + + /** + * Gets the appropriate "indexOf" function. If the `_.indexOf` method is + * customized, this method returns the custom method, otherwise it returns + * the `baseIndexOf` function. + * + * @private + * @returns {Function} Returns the "indexOf" function. + */ + function getIndexOf() { + var result = (result = lodash.indexOf) === indexOf ? baseIndexOf : result; + return result; + } + + /** + * Checks if `value` is a native function. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is a native function, else `false`. + */ + function isNative(value) { + return typeof value == 'function' && reNative.test(value); + } + + /** + * Sets `this` binding data on a given function. + * + * @private + * @param {Function} func The function to set data on. + * @param {Array} value The data array to set. + */ + var setBindData = !defineProperty ? noop : function(func, value) { + descriptor.value = value; + defineProperty(func, '__bindData__', descriptor); + }; + + /** + * A fallback implementation of `isPlainObject` which checks if a given value + * is an object created by the `Object` constructor, assuming objects created + * by the `Object` constructor have no inherited enumerable properties and that + * there are no `Object.prototype` extensions. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + */ + function shimIsPlainObject(value) { + var ctor, + result; + + // avoid non Object objects, `arguments` objects, and DOM elements + if (!(value && toString.call(value) == objectClass) || + (ctor = value.constructor, isFunction(ctor) && !(ctor instanceof ctor)) || + (!support.argsClass && isArguments(value)) || + (!support.nodeClass && isNode(value))) { + return false; + } + // IE < 9 iterates inherited properties before own properties. If the first + // iterated property is an object's own property then there are no inherited + // enumerable properties. + if (support.ownLast) { + forIn(value, function(value, key, object) { + result = hasOwnProperty.call(object, key); + return false; + }); + return result !== false; + } + // In most environments an object's own properties are iterated before + // its inherited properties. If the last iterated property is an object's + // own property then there are no inherited enumerable properties. + forIn(value, function(value, key) { + result = key; + }); + return typeof result == 'undefined' || hasOwnProperty.call(value, result); + } + + /** + * Used by `unescape` to convert HTML entities to characters. + * + * @private + * @param {string} match The matched character to unescape. + * @returns {string} Returns the unescaped character. + */ + function unescapeHtmlChar(match) { + return htmlUnescapes[match]; + } + + /*--------------------------------------------------------------------------*/ + + /** + * Checks if `value` is an `arguments` object. + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is an `arguments` object, else `false`. + * @example + * + * (function() { return _.isArguments(arguments); })(1, 2, 3); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ + function isArguments(value) { + return value && typeof value == 'object' && typeof value.length == 'number' && + toString.call(value) == argsClass || false; + } + // fallback for browsers that can't detect `arguments` objects by [[Class]] + if (!support.argsClass) { + isArguments = function(value) { + return value && typeof value == 'object' && typeof value.length == 'number' && + hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee') || false; + }; + } + + /** + * Checks if `value` is an array. + * + * @static + * @memberOf _ + * @type Function + * @category Objects + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is an array, else `false`. + * @example + * + * (function() { return _.isArray(arguments); })(); + * // => false + * + * _.isArray([1, 2, 3]); + * // => true + */ + var isArray = nativeIsArray || function(value) { + return value && typeof value == 'object' && typeof value.length == 'number' && + toString.call(value) == arrayClass || false; + }; + + /** + * A fallback implementation of `Object.keys` which produces an array of the + * given object's own enumerable property names. + * + * @private + * @type Function + * @param {Object} object The object to inspect. + * @returns {Array} Returns an array of property names. + */ + var shimKeys = createIterator({ + 'args': 'object', + 'init': '[]', + 'top': 'if (!(objectTypes[typeof object])) return result', + 'loop': 'result.push(index)' + }); + + /** + * Creates an array composed of the own enumerable property names of an object. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to inspect. + * @returns {Array} Returns an array of property names. + * @example + * + * _.keys({ 'one': 1, 'two': 2, 'three': 3 }); + * // => ['one', 'two', 'three'] (property order is not guaranteed across environments) + */ + var keys = !nativeKeys ? shimKeys : function(object) { + if (!isObject(object)) { + return []; + } + if ((support.enumPrototypes && typeof object == 'function') || + (support.nonEnumArgs && object.length && isArguments(object))) { + return shimKeys(object); + } + return nativeKeys(object); + }; + + /** Reusable iterator options shared by `each`, `forIn`, and `forOwn` */ + var eachIteratorOptions = { + 'args': 'collection, callback, thisArg', + 'top': "callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3)", + 'array': "typeof length == 'number'", + 'keys': keys, + 'loop': 'if (callback(iterable[index], index, collection) === false) return result' + }; + + /** Reusable iterator options for `assign` and `defaults` */ + var defaultsIteratorOptions = { + 'args': 'object, source, guard', + 'top': + 'var args = arguments,\n' + + ' argsIndex = 0,\n' + + " argsLength = typeof guard == 'number' ? 2 : args.length;\n" + + 'while (++argsIndex < argsLength) {\n' + + ' iterable = args[argsIndex];\n' + + ' if (iterable && objectTypes[typeof iterable]) {', + 'keys': keys, + 'loop': "if (typeof result[index] == 'undefined') result[index] = iterable[index]", + 'bottom': ' }\n}' + }; + + /** Reusable iterator options for `forIn` and `forOwn` */ + var forOwnIteratorOptions = { + 'top': 'if (!objectTypes[typeof iterable]) return result;\n' + eachIteratorOptions.top, + 'array': false + }; + + /** + * Used to convert characters to HTML entities: + * + * Though the `>` character is escaped for symmetry, characters like `>` and `/` + * don't require escaping in HTML and have no special meaning unless they're part + * of a tag or an unquoted attribute value. + * http://mathiasbynens.be/notes/ambiguous-ampersands (under "semi-related fun fact") + */ + var htmlEscapes = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' + }; + + /** Used to convert HTML entities to characters */ + var htmlUnescapes = invert(htmlEscapes); + + /** Used to match HTML entities and HTML characters */ + var reEscapedHtml = RegExp('(' + keys(htmlUnescapes).join('|') + ')', 'g'), + reUnescapedHtml = RegExp('[' + keys(htmlEscapes).join('') + ']', 'g'); + + /** + * A function compiled to iterate `arguments` objects, arrays, objects, and + * strings consistenly across environments, executing the callback for each + * element in the collection. The callback is bound to `thisArg` and invoked + * with three arguments; (value, index|key, collection). Callbacks may exit + * iteration early by explicitly returning `false`. + * + * @private + * @type Function + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Array|Object|string} Returns `collection`. + */ + var baseEach = createIterator(eachIteratorOptions); + + /*--------------------------------------------------------------------------*/ + + /** + * Assigns own enumerable properties of source object(s) to the destination + * object. Subsequent sources will overwrite property assignments of previous + * sources. If a callback is provided it will be executed to produce the + * assigned values. The callback is bound to `thisArg` and invoked with two + * arguments; (objectValue, sourceValue). + * + * @static + * @memberOf _ + * @type Function + * @alias extend + * @category Objects + * @param {Object} object The destination object. + * @param {...Object} [source] The source objects. + * @param {Function} [callback] The function to customize assigning values. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns the destination object. + * @example + * + * _.assign({ 'name': 'fred' }, { 'employer': 'slate' }); + * // => { 'name': 'fred', 'employer': 'slate' } + * + * var defaults = _.partialRight(_.assign, function(a, b) { + * return typeof a == 'undefined' ? b : a; + * }); + * + * var object = { 'name': 'barney' }; + * defaults(object, { 'name': 'fred', 'employer': 'slate' }); + * // => { 'name': 'barney', 'employer': 'slate' } + */ + var assign = createIterator(defaultsIteratorOptions, { + 'top': + defaultsIteratorOptions.top.replace(';', + ';\n' + + "if (argsLength > 3 && typeof args[argsLength - 2] == 'function') {\n" + + ' var callback = baseCreateCallback(args[--argsLength - 1], args[argsLength--], 2);\n' + + "} else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') {\n" + + ' callback = args[--argsLength];\n' + + '}' + ), + 'loop': 'result[index] = callback ? callback(result[index], iterable[index]) : iterable[index]' + }); + + /** + * Creates a clone of `value`. If `isDeep` is `true` nested objects will also + * be cloned, otherwise they will be assigned by reference. If a callback + * is provided it will be executed to produce the cloned values. If the + * callback returns `undefined` cloning will be handled by the method instead. + * The callback is bound to `thisArg` and invoked with one argument; (value). + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to clone. + * @param {boolean} [isDeep=false] Specify a deep clone. + * @param {Function} [callback] The function to customize cloning values. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {*} Returns the cloned value. + * @example + * + * var characters = [ + * { 'name': 'barney', 'age': 36 }, + * { 'name': 'fred', 'age': 40 } + * ]; + * + * var shallow = _.clone(characters); + * shallow[0] === characters[0]; + * // => true + * + * var deep = _.clone(characters, true); + * deep[0] === characters[0]; + * // => false + * + * _.mixin({ + * 'clone': _.partialRight(_.clone, function(value) { + * return _.isElement(value) ? value.cloneNode(false) : undefined; + * }) + * }); + * + * var clone = _.clone(document.body); + * clone.childNodes.length; + * // => 0 + */ + function clone(value, isDeep, callback, thisArg) { + // allows working with "Collections" methods without using their `index` + // and `collection` arguments for `isDeep` and `callback` + if (typeof isDeep != 'boolean' && isDeep != null) { + thisArg = callback; + callback = isDeep; + isDeep = false; + } + return baseClone(value, isDeep, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 1)); + } + + /** + * Creates a deep clone of `value`. If a callback is provided it will be + * executed to produce the cloned values. If the callback returns `undefined` + * cloning will be handled by the method instead. The callback is bound to + * `thisArg` and invoked with one argument; (value). + * + * Note: This method is loosely based on the structured clone algorithm. Functions + * and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and + * objects created by constructors other than `Object` are cloned to plain `Object` objects. + * See http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm. + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to deep clone. + * @param {Function} [callback] The function to customize cloning values. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {*} Returns the deep cloned value. + * @example + * + * var characters = [ + * { 'name': 'barney', 'age': 36 }, + * { 'name': 'fred', 'age': 40 } + * ]; + * + * var deep = _.cloneDeep(characters); + * deep[0] === characters[0]; + * // => false + * + * var view = { + * 'label': 'docs', + * 'node': element + * }; + * + * var clone = _.cloneDeep(view, function(value) { + * return _.isElement(value) ? value.cloneNode(true) : undefined; + * }); + * + * clone.node == view.node; + * // => false + */ + function cloneDeep(value, callback, thisArg) { + return baseClone(value, true, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 1)); + } + + /** + * Creates an object that inherits from the given `prototype` object. If a + * `properties` object is provided its own enumerable properties are assigned + * to the created object. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} prototype The object to inherit from. + * @param {Object} [properties] The properties to assign to the object. + * @returns {Object} Returns the new object. + * @example + * + * function Shape() { + * this.x = 0; + * this.y = 0; + * } + * + * function Circle() { + * Shape.call(this); + * } + * + * Circle.prototype = _.create(Shape.prototype, { 'constructor': Circle }); + * + * var circle = new Circle; + * circle instanceof Circle; + * // => true + * + * circle instanceof Shape; + * // => true + */ + function create(prototype, properties) { + var result = baseCreate(prototype); + return properties ? assign(result, properties) : result; + } + + /** + * Assigns own enumerable properties of source object(s) to the destination + * object for all destination properties that resolve to `undefined`. Once a + * property is set, additional defaults of the same property will be ignored. + * + * @static + * @memberOf _ + * @type Function + * @category Objects + * @param {Object} object The destination object. + * @param {...Object} [source] The source objects. + * @param- {Object} [guard] Allows working with `_.reduce` without using its + * `key` and `object` arguments as sources. + * @returns {Object} Returns the destination object. + * @example + * + * var object = { 'name': 'barney' }; + * _.defaults(object, { 'name': 'fred', 'employer': 'slate' }); + * // => { 'name': 'barney', 'employer': 'slate' } + */ + var defaults = createIterator(defaultsIteratorOptions); + + /** + * This method is like `_.findIndex` except that it returns the key of the + * first element that passes the callback check, instead of the element itself. + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to search. + * @param {Function|Object|string} [callback=identity] The function called per + * iteration. If a property name or object is provided it will be used to + * create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {string|undefined} Returns the key of the found element, else `undefined`. + * @example + * + * var characters = { + * 'barney': { 'age': 36, 'blocked': false }, + * 'fred': { 'age': 40, 'blocked': true }, + * 'pebbles': { 'age': 1, 'blocked': false } + * }; + * + * _.findKey(characters, function(chr) { + * return chr.age < 40; + * }); + * // => 'barney' (property order is not guaranteed across environments) + * + * // using "_.where" callback shorthand + * _.findKey(characters, { 'age': 1 }); + * // => 'pebbles' + * + * // using "_.pluck" callback shorthand + * _.findKey(characters, 'blocked'); + * // => 'fred' + */ + function findKey(object, callback, thisArg) { + var result; + callback = lodash.createCallback(callback, thisArg, 3); + forOwn(object, function(value, key, object) { + if (callback(value, key, object)) { + result = key; + return false; + } + }); + return result; + } + + /** + * This method is like `_.findKey` except that it iterates over elements + * of a `collection` in the opposite order. + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to search. + * @param {Function|Object|string} [callback=identity] The function called per + * iteration. If a property name or object is provided it will be used to + * create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {string|undefined} Returns the key of the found element, else `undefined`. + * @example + * + * var characters = { + * 'barney': { 'age': 36, 'blocked': true }, + * 'fred': { 'age': 40, 'blocked': false }, + * 'pebbles': { 'age': 1, 'blocked': true } + * }; + * + * _.findLastKey(characters, function(chr) { + * return chr.age < 40; + * }); + * // => returns `pebbles`, assuming `_.findKey` returns `barney` + * + * // using "_.where" callback shorthand + * _.findLastKey(characters, { 'age': 40 }); + * // => 'fred' + * + * // using "_.pluck" callback shorthand + * _.findLastKey(characters, 'blocked'); + * // => 'pebbles' + */ + function findLastKey(object, callback, thisArg) { + var result; + callback = lodash.createCallback(callback, thisArg, 3); + forOwnRight(object, function(value, key, object) { + if (callback(value, key, object)) { + result = key; + return false; + } + }); + return result; + } + + /** + * Iterates over own and inherited enumerable properties of an object, + * executing the callback for each property. The callback is bound to `thisArg` + * and invoked with three arguments; (value, key, object). Callbacks may exit + * iteration early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @type Function + * @category Objects + * @param {Object} object The object to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns `object`. + * @example + * + * function Shape() { + * this.x = 0; + * this.y = 0; + * } + * + * Shape.prototype.move = function(x, y) { + * this.x += x; + * this.y += y; + * }; + * + * _.forIn(new Shape, function(value, key) { + * console.log(key); + * }); + * // => logs 'x', 'y', and 'move' (property order is not guaranteed across environments) + */ + var forIn = createIterator(eachIteratorOptions, forOwnIteratorOptions, { + 'useHas': false + }); + + /** + * This method is like `_.forIn` except that it iterates over elements + * of a `collection` in the opposite order. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns `object`. + * @example + * + * function Shape() { + * this.x = 0; + * this.y = 0; + * } + * + * Shape.prototype.move = function(x, y) { + * this.x += x; + * this.y += y; + * }; + * + * _.forInRight(new Shape, function(value, key) { + * console.log(key); + * }); + * // => logs 'move', 'y', and 'x' assuming `_.forIn ` logs 'x', 'y', and 'move' + */ + function forInRight(object, callback, thisArg) { + var pairs = []; + + forIn(object, function(value, key) { + pairs.push(key, value); + }); + + var length = pairs.length; + callback = baseCreateCallback(callback, thisArg, 3); + while (length--) { + if (callback(pairs[length--], pairs[length], object) === false) { + break; + } + } + return object; + } + + /** + * Iterates over own enumerable properties of an object, executing the callback + * for each property. The callback is bound to `thisArg` and invoked with three + * arguments; (value, key, object). Callbacks may exit iteration early by + * explicitly returning `false`. + * + * @static + * @memberOf _ + * @type Function + * @category Objects + * @param {Object} object The object to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns `object`. + * @example + * + * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + * console.log(key); + * }); + * // => logs '0', '1', and 'length' (property order is not guaranteed across environments) + */ + var forOwn = createIterator(eachIteratorOptions, forOwnIteratorOptions); + + /** + * This method is like `_.forOwn` except that it iterates over elements + * of a `collection` in the opposite order. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns `object`. + * @example + * + * _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + * console.log(key); + * }); + * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' + */ + function forOwnRight(object, callback, thisArg) { + var props = keys(object), + length = props.length; + + callback = baseCreateCallback(callback, thisArg, 3); + while (length--) { + var key = props[length]; + if (callback(object[key], key, object) === false) { + break; + } + } + return object; + } + + /** + * Creates a sorted array of property names of all enumerable properties, + * own and inherited, of `object` that have function values. + * + * @static + * @memberOf _ + * @alias methods + * @category Objects + * @param {Object} object The object to inspect. + * @returns {Array} Returns an array of property names that have function values. + * @example + * + * _.functions(_); + * // => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...] + */ + function functions(object) { + var result = []; + forIn(object, function(value, key) { + if (isFunction(value)) { + result.push(key); + } + }); + return result.sort(); + } + + /** + * Checks if the specified property name exists as a direct property of `object`, + * instead of an inherited property. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to inspect. + * @param {string} key The name of the property to check. + * @returns {boolean} Returns `true` if key is a direct property, else `false`. + * @example + * + * _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); + * // => true + */ + function has(object, key) { + return object ? hasOwnProperty.call(object, key) : false; + } + + /** + * Creates an object composed of the inverted keys and values of the given object. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to invert. + * @returns {Object} Returns the created inverted object. + * @example + * + * _.invert({ 'first': 'fred', 'second': 'barney' }); + * // => { 'fred': 'first', 'barney': 'second' } + */ + function invert(object) { + var index = -1, + props = keys(object), + length = props.length, + result = {}; + + while (++index < length) { + var key = props[index]; + result[object[key]] = key; + } + return result; + } + + /** + * Checks if `value` is a boolean value. + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is a boolean value, else `false`. + * @example + * + * _.isBoolean(null); + * // => false + */ + function isBoolean(value) { + return value === true || value === false || + value && typeof value == 'object' && toString.call(value) == boolClass || false; + } + + /** + * Checks if `value` is a date. + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is a date, else `false`. + * @example + * + * _.isDate(new Date); + * // => true + */ + function isDate(value) { + return value && typeof value == 'object' && toString.call(value) == dateClass || false; + } + + /** + * Checks if `value` is a DOM element. + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is a DOM element, else `false`. + * @example + * + * _.isElement(document.body); + * // => true + */ + function isElement(value) { + return value && value.nodeType === 1 || false; + } + + /** + * Checks if `value` is empty. Arrays, strings, or `arguments` objects with a + * length of `0` and objects with no own enumerable properties are considered + * "empty". + * + * @static + * @memberOf _ + * @category Objects + * @param {Array|Object|string} value The value to inspect. + * @returns {boolean} Returns `true` if the `value` is empty, else `false`. + * @example + * + * _.isEmpty([1, 2, 3]); + * // => false + * + * _.isEmpty({}); + * // => true + * + * _.isEmpty(''); + * // => true + */ + function isEmpty(value) { + var result = true; + if (!value) { + return result; + } + var className = toString.call(value), + length = value.length; + + if ((className == arrayClass || className == stringClass || + (support.argsClass ? className == argsClass : isArguments(value))) || + (className == objectClass && typeof length == 'number' && isFunction(value.splice))) { + return !length; + } + forOwn(value, function() { + return (result = false); + }); + return result; + } + + /** + * Performs a deep comparison between two values to determine if they are + * equivalent to each other. If a callback is provided it will be executed + * to compare values. If the callback returns `undefined` comparisons will + * be handled by the method instead. The callback is bound to `thisArg` and + * invoked with two arguments; (a, b). + * + * @static + * @memberOf _ + * @category Objects + * @param {*} a The value to compare. + * @param {*} b The other value to compare. + * @param {Function} [callback] The function to customize comparing values. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'name': 'fred' }; + * var copy = { 'name': 'fred' }; + * + * object == copy; + * // => false + * + * _.isEqual(object, copy); + * // => true + * + * var words = ['hello', 'goodbye']; + * var otherWords = ['hi', 'goodbye']; + * + * _.isEqual(words, otherWords, function(a, b) { + * var reGreet = /^(?:hello|hi)$/i, + * aGreet = _.isString(a) && reGreet.test(a), + * bGreet = _.isString(b) && reGreet.test(b); + * + * return (aGreet || bGreet) ? (aGreet == bGreet) : undefined; + * }); + * // => true + */ + function isEqual(a, b, callback, thisArg) { + return baseIsEqual(a, b, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 2)); + } + + /** + * Checks if `value` is, or can be coerced to, a finite number. + * + * Note: This is not the same as native `isFinite` which will return true for + * booleans and empty strings. See http://es5.github.io/#x15.1.2.5. + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is finite, else `false`. + * @example + * + * _.isFinite(-101); + * // => true + * + * _.isFinite('10'); + * // => true + * + * _.isFinite(true); + * // => false + * + * _.isFinite(''); + * // => false + * + * _.isFinite(Infinity); + * // => false + */ + function isFinite(value) { + return nativeIsFinite(value) && !nativeIsNaN(parseFloat(value)); + } + + /** + * Checks if `value` is a function. + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + */ + function isFunction(value) { + return typeof value == 'function'; + } + // fallback for older versions of Chrome and Safari + if (isFunction(/x/)) { + isFunction = function(value) { + return typeof value == 'function' && toString.call(value) == funcClass; + }; + } + + /** + * Checks if `value` is the language type of Object. + * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(1); + * // => false + */ + function isObject(value) { + // check if the value is the ECMAScript language type of Object + // http://es5.github.io/#x8 + // and avoid a V8 bug + // http://code.google.com/p/v8/issues/detail?id=2291 + return !!(value && objectTypes[typeof value]); + } + + /** + * Checks if `value` is `NaN`. + * + * Note: This is not the same as native `isNaN` which will return `true` for + * `undefined` and other non-numeric values. See http://es5.github.io/#x15.1.2.4. + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is `NaN`, else `false`. + * @example + * + * _.isNaN(NaN); + * // => true + * + * _.isNaN(new Number(NaN)); + * // => true + * + * isNaN(undefined); + * // => true + * + * _.isNaN(undefined); + * // => false + */ + function isNaN(value) { + // `NaN` as a primitive is the only value that is not equal to itself + // (perform the [[Class]] check first to avoid errors with some host objects in IE) + return isNumber(value) && value != +value; + } + + /** + * Checks if `value` is `null`. + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is `null`, else `false`. + * @example + * + * _.isNull(null); + * // => true + * + * _.isNull(undefined); + * // => false + */ + function isNull(value) { + return value === null; + } + + /** + * Checks if `value` is a number. + * + * Note: `NaN` is considered a number. See http://es5.github.io/#x8.5. + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is a number, else `false`. + * @example + * + * _.isNumber(8.4 * 5); + * // => true + */ + function isNumber(value) { + return typeof value == 'number' || + value && typeof value == 'object' && toString.call(value) == numberClass || false; + } + + /** + * Checks if `value` is an object created by the `Object` constructor. + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + * @example + * + * function Shape() { + * this.x = 0; + * this.y = 0; + * } + * + * _.isPlainObject(new Shape); + * // => false + * + * _.isPlainObject([1, 2, 3]); + * // => false + * + * _.isPlainObject({ 'x': 0, 'y': 0 }); + * // => true + */ + var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) { + if (!(value && toString.call(value) == objectClass) || (!support.argsClass && isArguments(value))) { + return false; + } + var valueOf = value.valueOf, + objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto); + + return objProto + ? (value == objProto || getPrototypeOf(value) == objProto) + : shimIsPlainObject(value); + }; + + /** + * Checks if `value` is a regular expression. + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is a regular expression, else `false`. + * @example + * + * _.isRegExp(/fred/); + * // => true + */ + function isRegExp(value) { + return value && objectTypes[typeof value] && toString.call(value) == regexpClass || false; + } + + /** + * Checks if `value` is a string. + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is a string, else `false`. + * @example + * + * _.isString('fred'); + * // => true + */ + function isString(value) { + return typeof value == 'string' || + value && typeof value == 'object' && toString.call(value) == stringClass || false; + } + + /** + * Checks if `value` is `undefined`. + * + * @static + * @memberOf _ + * @category Objects + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if the `value` is `undefined`, else `false`. + * @example + * + * _.isUndefined(void 0); + * // => true + */ + function isUndefined(value) { + return typeof value == 'undefined'; + } + + /** + * Creates an object with the same keys as `object` and values generated by + * running each own enumerable property of `object` through the callback. + * The callback is bound to `thisArg` and invoked with three arguments; + * (value, key, object). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to iterate over. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a new object with values of the results of each `callback` execution. + * @example + * + * _.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(num) { return num * 3; }); + * // => { 'a': 3, 'b': 6, 'c': 9 } + * + * var characters = { + * 'fred': { 'name': 'fred', 'age': 40 }, + * 'pebbles': { 'name': 'pebbles', 'age': 1 } + * }; + * + * // using "_.pluck" callback shorthand + * _.mapValues(characters, 'age'); + * // => { 'fred': 40, 'pebbles': 1 } + */ + function mapValues(object, callback, thisArg) { + var result = {}; + callback = lodash.createCallback(callback, thisArg, 3); + + forOwn(object, function(value, key, object) { + result[key] = callback(value, key, object); + }); + return result; + } + + /** + * Recursively merges own enumerable properties of the source object(s), that + * don't resolve to `undefined` into the destination object. Subsequent sources + * will overwrite property assignments of previous sources. If a callback is + * provided it will be executed to produce the merged values of the destination + * and source properties. If the callback returns `undefined` merging will + * be handled by the method instead. The callback is bound to `thisArg` and + * invoked with two arguments; (objectValue, sourceValue). + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The destination object. + * @param {...Object} [source] The source objects. + * @param {Function} [callback] The function to customize merging properties. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns the destination object. + * @example + * + * var names = { + * 'characters': [ + * { 'name': 'barney' }, + * { 'name': 'fred' } + * ] + * }; + * + * var ages = { + * 'characters': [ + * { 'age': 36 }, + * { 'age': 40 } + * ] + * }; + * + * _.merge(names, ages); + * // => { 'characters': [{ 'name': 'barney', 'age': 36 }, { 'name': 'fred', 'age': 40 }] } + * + * var food = { + * 'fruits': ['apple'], + * 'vegetables': ['beet'] + * }; + * + * var otherFood = { + * 'fruits': ['banana'], + * 'vegetables': ['carrot'] + * }; + * + * _.merge(food, otherFood, function(a, b) { + * return _.isArray(a) ? a.concat(b) : undefined; + * }); + * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot] } + */ + function merge(object) { + var args = arguments, + length = 2; + + if (!isObject(object)) { + return object; + } + // allows working with `_.reduce` and `_.reduceRight` without using + // their `index` and `collection` arguments + if (typeof args[2] != 'number') { + length = args.length; + } + if (length > 3 && typeof args[length - 2] == 'function') { + var callback = baseCreateCallback(args[--length - 1], args[length--], 2); + } else if (length > 2 && typeof args[length - 1] == 'function') { + callback = args[--length]; + } + var sources = slice(arguments, 1, length), + index = -1, + stackA = getArray(), + stackB = getArray(); + + while (++index < length) { + baseMerge(object, sources[index], callback, stackA, stackB); + } + releaseArray(stackA); + releaseArray(stackB); + return object; + } + + /** + * Creates a shallow clone of `object` excluding the specified properties. + * Property names may be specified as individual arguments or as arrays of + * property names. If a callback is provided it will be executed for each + * property of `object` omitting the properties the callback returns truey + * for. The callback is bound to `thisArg` and invoked with three arguments; + * (value, key, object). + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The source object. + * @param {Function|...string|string[]} [callback] The properties to omit or the + * function called per iteration. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns an object without the omitted properties. + * @example + * + * _.omit({ 'name': 'fred', 'age': 40 }, 'age'); + * // => { 'name': 'fred' } + * + * _.omit({ 'name': 'fred', 'age': 40 }, function(value) { + * return typeof value == 'number'; + * }); + * // => { 'name': 'fred' } + */ + function omit(object, callback, thisArg) { + var result = {}; + if (typeof callback != 'function') { + var props = []; + forIn(object, function(value, key) { + props.push(key); + }); + props = baseDifference(props, baseFlatten(arguments, true, false, 1)); + + var index = -1, + length = props.length; + + while (++index < length) { + var key = props[index]; + result[key] = object[key]; + } + } else { + callback = lodash.createCallback(callback, thisArg, 3); + forIn(object, function(value, key, object) { + if (!callback(value, key, object)) { + result[key] = value; + } + }); + } + return result; + } + + /** + * Creates a two dimensional array of an object's key-value pairs, + * i.e. `[[key1, value1], [key2, value2]]`. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to inspect. + * @returns {Array} Returns new array of key-value pairs. + * @example + * + * _.pairs({ 'barney': 36, 'fred': 40 }); + * // => [['barney', 36], ['fred', 40]] (property order is not guaranteed across environments) + */ + function pairs(object) { + var index = -1, + props = keys(object), + length = props.length, + result = Array(length); + + while (++index < length) { + var key = props[index]; + result[index] = [key, object[key]]; + } + return result; + } + + /** + * Creates a shallow clone of `object` composed of the specified properties. + * Property names may be specified as individual arguments or as arrays of + * property names. If a callback is provided it will be executed for each + * property of `object` picking the properties the callback returns truey + * for. The callback is bound to `thisArg` and invoked with three arguments; + * (value, key, object). + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The source object. + * @param {Function|...string|string[]} [callback] The function called per + * iteration or property names to pick, specified as individual property + * names or arrays of property names. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns an object composed of the picked properties. + * @example + * + * _.pick({ 'name': 'fred', '_userid': 'fred1' }, 'name'); + * // => { 'name': 'fred' } + * + * _.pick({ 'name': 'fred', '_userid': 'fred1' }, function(value, key) { + * return key.charAt(0) != '_'; + * }); + * // => { 'name': 'fred' } + */ + function pick(object, callback, thisArg) { + var result = {}; + if (typeof callback != 'function') { + var index = -1, + props = baseFlatten(arguments, true, false, 1), + length = isObject(object) ? props.length : 0; + + while (++index < length) { + var key = props[index]; + if (key in object) { + result[key] = object[key]; + } + } + } else { + callback = lodash.createCallback(callback, thisArg, 3); + forIn(object, function(value, key, object) { + if (callback(value, key, object)) { + result[key] = value; + } + }); + } + return result; + } + + /** + * An alternative to `_.reduce` this method transforms `object` to a new + * `accumulator` object which is the result of running each of its own + * enumerable properties through a callback, with each callback execution + * potentially mutating the `accumulator` object. The callback is bound to + * `thisArg` and invoked with four arguments; (accumulator, value, key, object). + * Callbacks may exit iteration early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @category Objects + * @param {Array|Object} object The object to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {*} [accumulator] The custom accumulator value. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {*} Returns the accumulated value. + * @example + * + * var squares = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(result, num) { + * num *= num; + * if (num % 2) { + * return result.push(num) < 3; + * } + * }); + * // => [1, 9, 25] + * + * var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { + * result[key] = num * 3; + * }); + * // => { 'a': 3, 'b': 6, 'c': 9 } + */ + function transform(object, callback, accumulator, thisArg) { + var isArr = isArray(object); + if (accumulator == null) { + if (isArr) { + accumulator = []; + } else { + var ctor = object && object.constructor, + proto = ctor && ctor.prototype; + + accumulator = baseCreate(proto); + } + } + if (callback) { + callback = lodash.createCallback(callback, thisArg, 4); + (isArr ? baseEach : forOwn)(object, function(value, index, object) { + return callback(accumulator, value, index, object); + }); + } + return accumulator; + } + + /** + * Creates an array composed of the own enumerable property values of `object`. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to inspect. + * @returns {Array} Returns an array of property values. + * @example + * + * _.values({ 'one': 1, 'two': 2, 'three': 3 }); + * // => [1, 2, 3] (property order is not guaranteed across environments) + */ + function values(object) { + var index = -1, + props = keys(object), + length = props.length, + result = Array(length); + + while (++index < length) { + result[index] = object[props[index]]; + } + return result; + } + + /*--------------------------------------------------------------------------*/ + + /** + * Creates an array of elements from the specified indexes, or keys, of the + * `collection`. Indexes may be specified as individual arguments or as arrays + * of indexes. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {...(number|number[]|string|string[])} [index] The indexes of `collection` + * to retrieve, specified as individual indexes or arrays of indexes. + * @returns {Array} Returns a new array of elements corresponding to the + * provided indexes. + * @example + * + * _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]); + * // => ['a', 'c', 'e'] + * + * _.at(['fred', 'barney', 'pebbles'], 0, 2); + * // => ['fred', 'pebbles'] + */ + function at(collection) { + var args = arguments, + index = -1, + props = baseFlatten(args, true, false, 1), + length = (args[2] && args[2][args[1]] === collection) ? 1 : props.length, + result = Array(length); + + if (support.unindexedChars && isString(collection)) { + collection = collection.split(''); + } + while(++index < length) { + result[index] = collection[props[index]]; + } + return result; + } + + /** + * Checks if a given value is present in a collection using strict equality + * for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the + * offset from the end of the collection. + * + * @static + * @memberOf _ + * @alias include + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {*} target The value to check for. + * @param {number} [fromIndex=0] The index to search from. + * @returns {boolean} Returns `true` if the `target` element is found, else `false`. + * @example + * + * _.contains([1, 2, 3], 1); + * // => true + * + * _.contains([1, 2, 3], 1, 2); + * // => false + * + * _.contains({ 'name': 'fred', 'age': 40 }, 'fred'); + * // => true + * + * _.contains('pebbles', 'eb'); + * // => true + */ + function contains(collection, target, fromIndex) { + var index = -1, + indexOf = getIndexOf(), + length = collection ? collection.length : 0, + result = false; + + fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex) || 0; + if (isArray(collection)) { + result = indexOf(collection, target, fromIndex) > -1; + } else if (typeof length == 'number') { + result = (isString(collection) ? collection.indexOf(target, fromIndex) : indexOf(collection, target, fromIndex)) > -1; + } else { + baseEach(collection, function(value) { + if (++index >= fromIndex) { + return !(result = value === target); + } + }); + } + return result; + } + + /** + * Creates an object composed of keys generated from the results of running + * each element of `collection` through the callback. The corresponding value + * of each key is the number of times the key was returned by the callback. + * The callback is bound to `thisArg` and invoked with three arguments; + * (value, index|key, collection). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); + * // => { '4': 1, '6': 2 } + * + * _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); + * // => { '4': 1, '6': 2 } + * + * _.countBy(['one', 'two', 'three'], 'length'); + * // => { '3': 2, '5': 1 } + */ + var countBy = createAggregator(function(result, value, key) { + (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1); + }); + + /** + * Checks if the given callback returns truey value for **all** elements of + * a collection. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index|key, collection). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @alias all + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {boolean} Returns `true` if all elements passed the callback check, + * else `false`. + * @example + * + * _.every([true, 1, null, 'yes']); + * // => false + * + * var characters = [ + * { 'name': 'barney', 'age': 36 }, + * { 'name': 'fred', 'age': 40 } + * ]; + * + * // using "_.pluck" callback shorthand + * _.every(characters, 'age'); + * // => true + * + * // using "_.where" callback shorthand + * _.every(characters, { 'age': 36 }); + * // => false + */ + function every(collection, callback, thisArg) { + var result = true; + callback = lodash.createCallback(callback, thisArg, 3); + + if (isArray(collection)) { + var index = -1, + length = collection.length; + + while (++index < length) { + if (!(result = !!callback(collection[index], index, collection))) { + break; + } + } + } else { + baseEach(collection, function(value, index, collection) { + return (result = !!callback(value, index, collection)); + }); + } + return result; + } + + /** + * Iterates over elements of a collection, returning an array of all elements + * the callback returns truey for. The callback is bound to `thisArg` and + * invoked with three arguments; (value, index|key, collection). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @alias select + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a new array of elements that passed the callback check. + * @example + * + * var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); + * // => [2, 4, 6] + * + * var characters = [ + * { 'name': 'barney', 'age': 36, 'blocked': false }, + * { 'name': 'fred', 'age': 40, 'blocked': true } + * ]; + * + * // using "_.pluck" callback shorthand + * _.filter(characters, 'blocked'); + * // => [{ 'name': 'fred', 'age': 40, 'blocked': true }] + * + * // using "_.where" callback shorthand + * _.filter(characters, { 'age': 36 }); + * // => [{ 'name': 'barney', 'age': 36, 'blocked': false }] + */ + function filter(collection, callback, thisArg) { + var result = []; + callback = lodash.createCallback(callback, thisArg, 3); + + if (isArray(collection)) { + var index = -1, + length = collection.length; + + while (++index < length) { + var value = collection[index]; + if (callback(value, index, collection)) { + result.push(value); + } + } + } else { + baseEach(collection, function(value, index, collection) { + if (callback(value, index, collection)) { + result.push(value); + } + }); + } + return result; + } + + /** + * Iterates over elements of a collection, returning the first element that + * the callback returns truey for. The callback is bound to `thisArg` and + * invoked with three arguments; (value, index|key, collection). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @alias detect, findWhere + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {*} Returns the found element, else `undefined`. + * @example + * + * var characters = [ + * { 'name': 'barney', 'age': 36, 'blocked': false }, + * { 'name': 'fred', 'age': 40, 'blocked': true }, + * { 'name': 'pebbles', 'age': 1, 'blocked': false } + * ]; + * + * _.find(characters, function(chr) { + * return chr.age < 40; + * }); + * // => { 'name': 'barney', 'age': 36, 'blocked': false } + * + * // using "_.where" callback shorthand + * _.find(characters, { 'age': 1 }); + * // => { 'name': 'pebbles', 'age': 1, 'blocked': false } + * + * // using "_.pluck" callback shorthand + * _.find(characters, 'blocked'); + * // => { 'name': 'fred', 'age': 40, 'blocked': true } + */ + function find(collection, callback, thisArg) { + callback = lodash.createCallback(callback, thisArg, 3); + + if (isArray(collection)) { + var index = -1, + length = collection.length; + + while (++index < length) { + var value = collection[index]; + if (callback(value, index, collection)) { + return value; + } + } + } else { + var result; + baseEach(collection, function(value, index, collection) { + if (callback(value, index, collection)) { + result = value; + return false; + } + }); + return result; + } + } + + /** + * This method is like `_.find` except that it iterates over elements + * of a `collection` from right to left. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {*} Returns the found element, else `undefined`. + * @example + * + * _.findLast([1, 2, 3, 4], function(num) { + * return num % 2 == 1; + * }); + * // => 3 + */ + function findLast(collection, callback, thisArg) { + var result; + callback = lodash.createCallback(callback, thisArg, 3); + forEachRight(collection, function(value, index, collection) { + if (callback(value, index, collection)) { + result = value; + return false; + } + }); + return result; + } + + /** + * Iterates over elements of a collection, executing the callback for each + * element. The callback is bound to `thisArg` and invoked with three arguments; + * (value, index|key, collection). Callbacks may exit iteration early by + * explicitly returning `false`. + * + * Note: As with other "Collections" methods, objects with a `length` property + * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn` + * may be used for object iteration. + * + * @static + * @memberOf _ + * @alias each + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Array|Object|string} Returns `collection`. + * @example + * + * _([1, 2, 3]).forEach(function(num) { console.log(num); }).join(','); + * // => logs each number and returns '1,2,3' + * + * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); + * // => logs each number and returns the object (property order is not guaranteed across environments) + */ + function forEach(collection, callback, thisArg) { + if (callback && typeof thisArg == 'undefined' && isArray(collection)) { + var index = -1, + length = collection.length; + + while (++index < length) { + if (callback(collection[index], index, collection) === false) { + break; + } + } + } else { + baseEach(collection, callback, thisArg); + } + return collection; + } + + /** + * This method is like `_.forEach` except that it iterates over elements + * of a `collection` from right to left. + * + * @static + * @memberOf _ + * @alias eachRight + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Array|Object|string} Returns `collection`. + * @example + * + * _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(','); + * // => logs each number from right to left and returns '3,2,1' + */ + function forEachRight(collection, callback, thisArg) { + var iterable = collection, + length = collection ? collection.length : 0; + + callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); + if (isArray(collection)) { + while (length--) { + if (callback(collection[length], length, collection) === false) { + break; + } + } + } else { + if (typeof length != 'number') { + var props = keys(collection); + length = props.length; + } else if (support.unindexedChars && isString(collection)) { + iterable = collection.split(''); + } + baseEach(collection, function(value, key, collection) { + key = props ? props[--length] : --length; + return callback(iterable[key], key, collection); + }); + } + return collection; + } + + /** + * Creates an object composed of keys generated from the results of running + * each element of a collection through the callback. The corresponding value + * of each key is an array of the elements responsible for generating the key. + * The callback is bound to `thisArg` and invoked with three arguments; + * (value, index|key, collection). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false` + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); + * // => { '4': [4.2], '6': [6.1, 6.4] } + * + * _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); + * // => { '4': [4.2], '6': [6.1, 6.4] } + * + * // using "_.pluck" callback shorthand + * _.groupBy(['one', 'two', 'three'], 'length'); + * // => { '3': ['one', 'two'], '5': ['three'] } + */ + var groupBy = createAggregator(function(result, value, key) { + (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value); + }); + + /** + * Creates an object composed of keys generated from the results of running + * each element of the collection through the given callback. The corresponding + * value of each key is the last element responsible for generating the key. + * The callback is bound to `thisArg` and invoked with three arguments; + * (value, index|key, collection). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * var keys = [ + * { 'dir': 'left', 'code': 97 }, + * { 'dir': 'right', 'code': 100 } + * ]; + * + * _.indexBy(keys, 'dir'); + * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } + * + * _.indexBy(keys, function(key) { return String.fromCharCode(key.code); }); + * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } + * + * _.indexBy(characters, function(key) { this.fromCharCode(key.code); }, String); + * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } + */ + var indexBy = createAggregator(function(result, value, key) { + result[key] = value; + }); + + /** + * Invokes the method named by `methodName` on each element in the `collection` + * returning an array of the results of each invoked method. Additional arguments + * will be provided to each invoked method. If `methodName` is a function it + * will be invoked for, and `this` bound to, each element in the `collection`. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|string} methodName The name of the method to invoke or + * the function invoked per iteration. + * @param {...*} [arg] Arguments to invoke the method with. + * @returns {Array} Returns a new array of the results of each invoked method. + * @example + * + * _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); + * // => [[1, 5, 7], [1, 2, 3]] + * + * _.invoke([123, 456], String.prototype.split, ''); + * // => [['1', '2', '3'], ['4', '5', '6']] + */ + function invoke(collection, methodName) { + var args = slice(arguments, 2), + index = -1, + isFunc = typeof methodName == 'function', + length = collection ? collection.length : 0, + result = Array(typeof length == 'number' ? length : 0); + + forEach(collection, function(value) { + result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args); + }); + return result; + } + + /** + * Creates an array of values by running each element in the collection + * through the callback. The callback is bound to `thisArg` and invoked with + * three arguments; (value, index|key, collection). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @alias collect + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a new array of the results of each `callback` execution. + * @example + * + * _.map([1, 2, 3], function(num) { return num * 3; }); + * // => [3, 6, 9] + * + * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); + * // => [3, 6, 9] (property order is not guaranteed across environments) + * + * var characters = [ + * { 'name': 'barney', 'age': 36 }, + * { 'name': 'fred', 'age': 40 } + * ]; + * + * // using "_.pluck" callback shorthand + * _.map(characters, 'name'); + * // => ['barney', 'fred'] + */ + function map(collection, callback, thisArg) { + var index = -1, + length = collection ? collection.length : 0, + result = Array(typeof length == 'number' ? length : 0); + + callback = lodash.createCallback(callback, thisArg, 3); + if (isArray(collection)) { + while (++index < length) { + result[index] = callback(collection[index], index, collection); + } + } else { + baseEach(collection, function(value, key, collection) { + result[++index] = callback(value, key, collection); + }); + } + return result; + } + + /** + * Retrieves the maximum value of a collection. If the collection is empty or + * falsey `-Infinity` is returned. If a callback is provided it will be executed + * for each value in the collection to generate the criterion by which the value + * is ranked. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index, collection). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {*} Returns the maximum value. + * @example + * + * _.max([4, 2, 8, 6]); + * // => 8 + * + * var characters = [ + * { 'name': 'barney', 'age': 36 }, + * { 'name': 'fred', 'age': 40 } + * ]; + * + * _.max(characters, function(chr) { return chr.age; }); + * // => { 'name': 'fred', 'age': 40 }; + * + * // using "_.pluck" callback shorthand + * _.max(characters, 'age'); + * // => { 'name': 'fred', 'age': 40 }; + */ + function max(collection, callback, thisArg) { + var computed = -Infinity, + result = computed; + + // allows working with functions like `_.map` without using + // their `index` argument as a callback + if (typeof callback != 'function' && thisArg && thisArg[callback] === collection) { + callback = null; + } + if (callback == null && isArray(collection)) { + var index = -1, + length = collection.length; + + while (++index < length) { + var value = collection[index]; + if (value > result) { + result = value; + } + } + } else { + callback = (callback == null && isString(collection)) + ? charAtCallback + : lodash.createCallback(callback, thisArg, 3); + + baseEach(collection, function(value, index, collection) { + var current = callback(value, index, collection); + if (current > computed) { + computed = current; + result = value; + } + }); + } + return result; + } + + /** + * Retrieves the minimum value of a collection. If the collection is empty or + * falsey `Infinity` is returned. If a callback is provided it will be executed + * for each value in the collection to generate the criterion by which the value + * is ranked. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index, collection). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {*} Returns the minimum value. + * @example + * + * _.min([4, 2, 8, 6]); + * // => 2 + * + * var characters = [ + * { 'name': 'barney', 'age': 36 }, + * { 'name': 'fred', 'age': 40 } + * ]; + * + * _.min(characters, function(chr) { return chr.age; }); + * // => { 'name': 'barney', 'age': 36 }; + * + * // using "_.pluck" callback shorthand + * _.min(characters, 'age'); + * // => { 'name': 'barney', 'age': 36 }; + */ + function min(collection, callback, thisArg) { + var computed = Infinity, + result = computed; + + // allows working with functions like `_.map` without using + // their `index` argument as a callback + if (typeof callback != 'function' && thisArg && thisArg[callback] === collection) { + callback = null; + } + if (callback == null && isArray(collection)) { + var index = -1, + length = collection.length; + + while (++index < length) { + var value = collection[index]; + if (value < result) { + result = value; + } + } + } else { + callback = (callback == null && isString(collection)) + ? charAtCallback + : lodash.createCallback(callback, thisArg, 3); + + baseEach(collection, function(value, index, collection) { + var current = callback(value, index, collection); + if (current < computed) { + computed = current; + result = value; + } + }); + } + return result; + } + + /** + * Retrieves the value of a specified property from all elements in the collection. + * + * @static + * @memberOf _ + * @type Function + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {string} property The name of the property to pluck. + * @returns {Array} Returns a new array of property values. + * @example + * + * var characters = [ + * { 'name': 'barney', 'age': 36 }, + * { 'name': 'fred', 'age': 40 } + * ]; + * + * _.pluck(characters, 'name'); + * // => ['barney', 'fred'] + */ + var pluck = map; + + /** + * Reduces a collection to a value which is the accumulated result of running + * each element in the collection through the callback, where each successive + * callback execution consumes the return value of the previous execution. If + * `accumulator` is not provided the first element of the collection will be + * used as the initial `accumulator` value. The callback is bound to `thisArg` + * and invoked with four arguments; (accumulator, value, index|key, collection). + * + * @static + * @memberOf _ + * @alias foldl, inject + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {*} [accumulator] Initial value of the accumulator. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {*} Returns the accumulated value. + * @example + * + * var sum = _.reduce([1, 2, 3], function(sum, num) { + * return sum + num; + * }); + * // => 6 + * + * var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { + * result[key] = num * 3; + * return result; + * }, {}); + * // => { 'a': 3, 'b': 6, 'c': 9 } + */ + function reduce(collection, callback, accumulator, thisArg) { + var noaccum = arguments.length < 3; + callback = lodash.createCallback(callback, thisArg, 4); + + if (isArray(collection)) { + var index = -1, + length = collection.length; + + if (noaccum) { + accumulator = collection[++index]; + } + while (++index < length) { + accumulator = callback(accumulator, collection[index], index, collection); + } + } else { + baseEach(collection, function(value, index, collection) { + accumulator = noaccum + ? (noaccum = false, value) + : callback(accumulator, value, index, collection) + }); + } + return accumulator; + } + + /** + * This method is like `_.reduce` except that it iterates over elements + * of a `collection` from right to left. + * + * @static + * @memberOf _ + * @alias foldr + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {*} [accumulator] Initial value of the accumulator. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {*} Returns the accumulated value. + * @example + * + * var list = [[0, 1], [2, 3], [4, 5]]; + * var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); + * // => [4, 5, 2, 3, 0, 1] + */ + function reduceRight(collection, callback, accumulator, thisArg) { + var noaccum = arguments.length < 3; + callback = lodash.createCallback(callback, thisArg, 4); + forEachRight(collection, function(value, index, collection) { + accumulator = noaccum + ? (noaccum = false, value) + : callback(accumulator, value, index, collection); + }); + return accumulator; + } + + /** + * The opposite of `_.filter` this method returns the elements of a + * collection that the callback does **not** return truey for. + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a new array of elements that failed the callback check. + * @example + * + * var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); + * // => [1, 3, 5] + * + * var characters = [ + * { 'name': 'barney', 'age': 36, 'blocked': false }, + * { 'name': 'fred', 'age': 40, 'blocked': true } + * ]; + * + * // using "_.pluck" callback shorthand + * _.reject(characters, 'blocked'); + * // => [{ 'name': 'barney', 'age': 36, 'blocked': false }] + * + * // using "_.where" callback shorthand + * _.reject(characters, { 'age': 36 }); + * // => [{ 'name': 'fred', 'age': 40, 'blocked': true }] + */ + function reject(collection, callback, thisArg) { + callback = lodash.createCallback(callback, thisArg, 3); + return filter(collection, function(value, index, collection) { + return !callback(value, index, collection); + }); + } + + /** + * Retrieves a random element or `n` random elements from a collection. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to sample. + * @param {number} [n] The number of elements to sample. + * @param- {Object} [guard] Allows working with functions like `_.map` + * without using their `index` arguments as `n`. + * @returns {Array} Returns the random sample(s) of `collection`. + * @example + * + * _.sample([1, 2, 3, 4]); + * // => 2 + * + * _.sample([1, 2, 3, 4], 2); + * // => [3, 1] + */ + function sample(collection, n, guard) { + if (collection && typeof collection.length != 'number') { + collection = values(collection); + } else if (support.unindexedChars && isString(collection)) { + collection = collection.split(''); + } + if (n == null || guard) { + return collection ? collection[baseRandom(0, collection.length - 1)] : undefined; + } + var result = shuffle(collection); + result.length = nativeMin(nativeMax(0, n), result.length); + return result; + } + + /** + * Creates an array of shuffled values, using a version of the Fisher-Yates + * shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to shuffle. + * @returns {Array} Returns a new shuffled collection. + * @example + * + * _.shuffle([1, 2, 3, 4, 5, 6]); + * // => [4, 1, 6, 3, 5, 2] + */ + function shuffle(collection) { + var index = -1, + length = collection ? collection.length : 0, + result = Array(typeof length == 'number' ? length : 0); + + forEach(collection, function(value) { + var rand = baseRandom(0, ++index); + result[index] = result[rand]; + result[rand] = value; + }); + return result; + } + + /** + * Gets the size of the `collection` by returning `collection.length` for arrays + * and array-like objects or the number of own enumerable properties for objects. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to inspect. + * @returns {number} Returns `collection.length` or number of own enumerable properties. + * @example + * + * _.size([1, 2]); + * // => 2 + * + * _.size({ 'one': 1, 'two': 2, 'three': 3 }); + * // => 3 + * + * _.size('pebbles'); + * // => 7 + */ + function size(collection) { + var length = collection ? collection.length : 0; + return typeof length == 'number' ? length : keys(collection).length; + } + + /** + * Checks if the callback returns a truey value for **any** element of a + * collection. The function returns as soon as it finds a passing value and + * does not iterate over the entire collection. The callback is bound to + * `thisArg` and invoked with three arguments; (value, index|key, collection). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @alias any + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {boolean} Returns `true` if any element passed the callback check, + * else `false`. + * @example + * + * _.some([null, 0, 'yes', false], Boolean); + * // => true + * + * var characters = [ + * { 'name': 'barney', 'age': 36, 'blocked': false }, + * { 'name': 'fred', 'age': 40, 'blocked': true } + * ]; + * + * // using "_.pluck" callback shorthand + * _.some(characters, 'blocked'); + * // => true + * + * // using "_.where" callback shorthand + * _.some(characters, { 'age': 1 }); + * // => false + */ + function some(collection, callback, thisArg) { + var result; + callback = lodash.createCallback(callback, thisArg, 3); + + if (isArray(collection)) { + var index = -1, + length = collection.length; + + while (++index < length) { + if ((result = callback(collection[index], index, collection))) { + break; + } + } + } else { + baseEach(collection, function(value, index, collection) { + return !(result = callback(value, index, collection)); + }); + } + return !!result; + } + + /** + * Creates an array of elements, sorted in ascending order by the results of + * running each element in a collection through the callback. This method + * performs a stable sort, that is, it will preserve the original sort order + * of equal elements. The callback is bound to `thisArg` and invoked with + * three arguments; (value, index|key, collection). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an array of property names is provided for `callback` the collection + * will be sorted by each property value. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a new array of sorted elements. + * @example + * + * _.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); + * // => [3, 1, 2] + * + * _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); + * // => [3, 1, 2] + * + * var characters = [ + * { 'name': 'barney', 'age': 36 }, + * { 'name': 'fred', 'age': 40 }, + * { 'name': 'barney', 'age': 26 }, + * { 'name': 'fred', 'age': 30 } + * ]; + * + * // using "_.pluck" callback shorthand + * _.map(_.sortBy(characters, 'age'), _.values); + * // => [['barney', 26], ['fred', 30], ['barney', 36], ['fred', 40]] + * + * // sorting by multiple properties + * _.map(_.sortBy(characters, ['name', 'age']), _.values); + * // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] + */ + function sortBy(collection, callback, thisArg) { + var index = -1, + isArr = isArray(callback), + length = collection ? collection.length : 0, + result = Array(typeof length == 'number' ? length : 0); + + if (!isArr) { + callback = lodash.createCallback(callback, thisArg, 3); + } + forEach(collection, function(value, key, collection) { + var object = result[++index] = getObject(); + if (isArr) { + object.criteria = map(callback, function(key) { return value[key]; }); + } else { + (object.criteria = getArray())[0] = callback(value, key, collection); + } + object.index = index; + object.value = value; + }); + + length = result.length; + result.sort(compareAscending); + while (length--) { + var object = result[length]; + result[length] = object.value; + if (!isArr) { + releaseArray(object.criteria); + } + releaseObject(object); + } + return result; + } + + /** + * Converts the `collection` to an array. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to convert. + * @returns {Array} Returns the new converted array. + * @example + * + * (function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); + * // => [2, 3, 4] + */ + function toArray(collection) { + if (collection && typeof collection.length == 'number') { + return (support.unindexedChars && isString(collection)) + ? collection.split('') + : slice(collection); + } + return values(collection); + } + + /** + * Performs a deep comparison of each element in a `collection` to the given + * `properties` object, returning an array of all elements that have equivalent + * property values. + * + * @static + * @memberOf _ + * @type Function + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Object} props The object of property values to filter by. + * @returns {Array} Returns a new array of elements that have the given properties. + * @example + * + * var characters = [ + * { 'name': 'barney', 'age': 36, 'pets': ['hoppy'] }, + * { 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] } + * ]; + * + * _.where(characters, { 'age': 36 }); + * // => [{ 'name': 'barney', 'age': 36, 'pets': ['hoppy'] }] + * + * _.where(characters, { 'pets': ['dino'] }); + * // => [{ 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }] + */ + var where = filter; + + /*--------------------------------------------------------------------------*/ + + /** + * Creates an array with all falsey values removed. The values `false`, `null`, + * `0`, `""`, `undefined`, and `NaN` are all falsey. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to compact. + * @returns {Array} Returns a new array of filtered values. + * @example + * + * _.compact([0, 1, false, 2, '', 3]); + * // => [1, 2, 3] + */ + function compact(array) { + var index = -1, + length = array ? array.length : 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (value) { + result.push(value); + } + } + return result; + } + + /** + * Creates an array excluding all values of the provided arrays using strict + * equality for comparisons, i.e. `===`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to process. + * @param {...Array} [values] The arrays of values to exclude. + * @returns {Array} Returns a new array of filtered values. + * @example + * + * _.difference([1, 2, 3, 4, 5], [5, 2, 10]); + * // => [1, 3, 4] + */ + function difference(array) { + return baseDifference(array, baseFlatten(arguments, true, true, 1)); + } + + /** + * This method is like `_.find` except that it returns the index of the first + * element that passes the callback check, instead of the element itself. + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to search. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {number} Returns the index of the found element, else `-1`. + * @example + * + * var characters = [ + * { 'name': 'barney', 'age': 36, 'blocked': false }, + * { 'name': 'fred', 'age': 40, 'blocked': true }, + * { 'name': 'pebbles', 'age': 1, 'blocked': false } + * ]; + * + * _.findIndex(characters, function(chr) { + * return chr.age < 20; + * }); + * // => 2 + * + * // using "_.where" callback shorthand + * _.findIndex(characters, { 'age': 36 }); + * // => 0 + * + * // using "_.pluck" callback shorthand + * _.findIndex(characters, 'blocked'); + * // => 1 + */ + function findIndex(array, callback, thisArg) { + var index = -1, + length = array ? array.length : 0; + + callback = lodash.createCallback(callback, thisArg, 3); + while (++index < length) { + if (callback(array[index], index, array)) { + return index; + } + } + return -1; + } + + /** + * This method is like `_.findIndex` except that it iterates over elements + * of a `collection` from right to left. + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to search. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {number} Returns the index of the found element, else `-1`. + * @example + * + * var characters = [ + * { 'name': 'barney', 'age': 36, 'blocked': true }, + * { 'name': 'fred', 'age': 40, 'blocked': false }, + * { 'name': 'pebbles', 'age': 1, 'blocked': true } + * ]; + * + * _.findLastIndex(characters, function(chr) { + * return chr.age > 30; + * }); + * // => 1 + * + * // using "_.where" callback shorthand + * _.findLastIndex(characters, { 'age': 36 }); + * // => 0 + * + * // using "_.pluck" callback shorthand + * _.findLastIndex(characters, 'blocked'); + * // => 2 + */ + function findLastIndex(array, callback, thisArg) { + var length = array ? array.length : 0; + callback = lodash.createCallback(callback, thisArg, 3); + while (length--) { + if (callback(array[length], length, array)) { + return length; + } + } + return -1; + } + + /** + * Gets the first element or first `n` elements of an array. If a callback + * is provided elements at the beginning of the array are returned as long + * as the callback returns truey. The callback is bound to `thisArg` and + * invoked with three arguments; (value, index, array). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @alias head, take + * @category Arrays + * @param {Array} array The array to query. + * @param {Function|Object|number|string} [callback] The function called + * per element or the number of elements to return. If a property name or + * object is provided it will be used to create a "_.pluck" or "_.where" + * style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {*} Returns the first element(s) of `array`. + * @example + * + * _.first([1, 2, 3]); + * // => 1 + * + * _.first([1, 2, 3], 2); + * // => [1, 2] + * + * _.first([1, 2, 3], function(num) { + * return num < 3; + * }); + * // => [1, 2] + * + * var characters = [ + * { 'name': 'barney', 'blocked': true, 'employer': 'slate' }, + * { 'name': 'fred', 'blocked': false, 'employer': 'slate' }, + * { 'name': 'pebbles', 'blocked': true, 'employer': 'na' } + * ]; + * + * // using "_.pluck" callback shorthand + * _.first(characters, 'blocked'); + * // => [{ 'name': 'barney', 'blocked': true, 'employer': 'slate' }] + * + * // using "_.where" callback shorthand + * _.pluck(_.first(characters, { 'employer': 'slate' }), 'name'); + * // => ['barney', 'fred'] + */ + function first(array, callback, thisArg) { + var n = 0, + length = array ? array.length : 0; + + if (typeof callback != 'number' && callback != null) { + var index = -1; + callback = lodash.createCallback(callback, thisArg, 3); + while (++index < length && callback(array[index], index, array)) { + n++; + } + } else { + n = callback; + if (n == null || thisArg) { + return array ? array[0] : undefined; + } + } + return slice(array, 0, nativeMin(nativeMax(0, n), length)); + } + + /** + * Flattens a nested array (the nesting can be to any depth). If `isShallow` + * is truey, the array will only be flattened a single level. If a callback + * is provided each element of the array is passed through the callback before + * flattening. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index, array). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to flatten. + * @param {boolean} [isShallow=false] A flag to restrict flattening to a single level. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a new flattened array. + * @example + * + * _.flatten([1, [2], [3, [[4]]]]); + * // => [1, 2, 3, 4]; + * + * _.flatten([1, [2], [3, [[4]]]], true); + * // => [1, 2, 3, [[4]]]; + * + * var characters = [ + * { 'name': 'barney', 'age': 30, 'pets': ['hoppy'] }, + * { 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] } + * ]; + * + * // using "_.pluck" callback shorthand + * _.flatten(characters, 'pets'); + * // => ['hoppy', 'baby puss', 'dino'] + */ + function flatten(array, isShallow, callback, thisArg) { + // juggle arguments + if (typeof isShallow != 'boolean' && isShallow != null) { + thisArg = callback; + callback = (typeof isShallow != 'function' && thisArg && thisArg[isShallow] === array) ? null : isShallow; + isShallow = false; + } + if (callback != null) { + array = map(array, callback, thisArg); + } + return baseFlatten(array, isShallow); + } + + /** + * Gets the index at which the first occurrence of `value` is found using + * strict equality for comparisons, i.e. `===`. If the array is already sorted + * providing `true` for `fromIndex` will run a faster binary search. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to search. + * @param {*} value The value to search for. + * @param {boolean|number} [fromIndex=0] The index to search from or `true` + * to perform a binary search on a sorted array. + * @returns {number} Returns the index of the matched value or `-1`. + * @example + * + * _.indexOf([1, 2, 3, 1, 2, 3], 2); + * // => 1 + * + * _.indexOf([1, 2, 3, 1, 2, 3], 2, 3); + * // => 4 + * + * _.indexOf([1, 1, 2, 2, 3, 3], 2, true); + * // => 2 + */ + function indexOf(array, value, fromIndex) { + if (typeof fromIndex == 'number') { + var length = array ? array.length : 0; + fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex || 0); + } else if (fromIndex) { + var index = sortedIndex(array, value); + return array[index] === value ? index : -1; + } + return baseIndexOf(array, value, fromIndex); + } + + /** + * Gets all but the last element or last `n` elements of an array. If a + * callback is provided elements at the end of the array are excluded from + * the result as long as the callback returns truey. The callback is bound + * to `thisArg` and invoked with three arguments; (value, index, array). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to query. + * @param {Function|Object|number|string} [callback=1] The function called + * per element or the number of elements to exclude. If a property name or + * object is provided it will be used to create a "_.pluck" or "_.where" + * style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a slice of `array`. + * @example + * + * _.initial([1, 2, 3]); + * // => [1, 2] + * + * _.initial([1, 2, 3], 2); + * // => [1] + * + * _.initial([1, 2, 3], function(num) { + * return num > 1; + * }); + * // => [1] + * + * var characters = [ + * { 'name': 'barney', 'blocked': false, 'employer': 'slate' }, + * { 'name': 'fred', 'blocked': true, 'employer': 'slate' }, + * { 'name': 'pebbles', 'blocked': true, 'employer': 'na' } + * ]; + * + * // using "_.pluck" callback shorthand + * _.initial(characters, 'blocked'); + * // => [{ 'name': 'barney', 'blocked': false, 'employer': 'slate' }] + * + * // using "_.where" callback shorthand + * _.pluck(_.initial(characters, { 'employer': 'na' }), 'name'); + * // => ['barney', 'fred'] + */ + function initial(array, callback, thisArg) { + var n = 0, + length = array ? array.length : 0; + + if (typeof callback != 'number' && callback != null) { + var index = length; + callback = lodash.createCallback(callback, thisArg, 3); + while (index-- && callback(array[index], index, array)) { + n++; + } + } else { + n = (callback == null || thisArg) ? 1 : callback || n; + } + return slice(array, 0, nativeMin(nativeMax(0, length - n), length)); + } + + /** + * Creates an array of unique values present in all provided arrays using + * strict equality for comparisons, i.e. `===`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {...Array} [array] The arrays to inspect. + * @returns {Array} Returns an array of shared values. + * @example + * + * _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]); + * // => [1, 2] + */ + function intersection() { + var args = [], + argsIndex = -1, + argsLength = arguments.length, + caches = getArray(), + indexOf = getIndexOf(), + trustIndexOf = indexOf === baseIndexOf, + seen = getArray(); + + while (++argsIndex < argsLength) { + var value = arguments[argsIndex]; + if (isArray(value) || isArguments(value)) { + args.push(value); + caches.push(trustIndexOf && value.length >= largeArraySize && + createCache(argsIndex ? args[argsIndex] : seen)); + } + } + var array = args[0], + index = -1, + length = array ? array.length : 0, + result = []; + + outer: + while (++index < length) { + var cache = caches[0]; + value = array[index]; + + if ((cache ? cacheIndexOf(cache, value) : indexOf(seen, value)) < 0) { + argsIndex = argsLength; + (cache || seen).push(value); + while (--argsIndex) { + cache = caches[argsIndex]; + if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value)) < 0) { + continue outer; + } + } + result.push(value); + } + } + while (argsLength--) { + cache = caches[argsLength]; + if (cache) { + releaseObject(cache); + } + } + releaseArray(caches); + releaseArray(seen); + return result; + } + + /** + * Gets the last element or last `n` elements of an array. If a callback is + * provided elements at the end of the array are returned as long as the + * callback returns truey. The callback is bound to `thisArg` and invoked + * with three arguments; (value, index, array). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to query. + * @param {Function|Object|number|string} [callback] The function called + * per element or the number of elements to return. If a property name or + * object is provided it will be used to create a "_.pluck" or "_.where" + * style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {*} Returns the last element(s) of `array`. + * @example + * + * _.last([1, 2, 3]); + * // => 3 + * + * _.last([1, 2, 3], 2); + * // => [2, 3] + * + * _.last([1, 2, 3], function(num) { + * return num > 1; + * }); + * // => [2, 3] + * + * var characters = [ + * { 'name': 'barney', 'blocked': false, 'employer': 'slate' }, + * { 'name': 'fred', 'blocked': true, 'employer': 'slate' }, + * { 'name': 'pebbles', 'blocked': true, 'employer': 'na' } + * ]; + * + * // using "_.pluck" callback shorthand + * _.pluck(_.last(characters, 'blocked'), 'name'); + * // => ['fred', 'pebbles'] + * + * // using "_.where" callback shorthand + * _.last(characters, { 'employer': 'na' }); + * // => [{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }] + */ + function last(array, callback, thisArg) { + var n = 0, + length = array ? array.length : 0; + + if (typeof callback != 'number' && callback != null) { + var index = length; + callback = lodash.createCallback(callback, thisArg, 3); + while (index-- && callback(array[index], index, array)) { + n++; + } + } else { + n = callback; + if (n == null || thisArg) { + return array ? array[length - 1] : undefined; + } + } + return slice(array, nativeMax(0, length - n)); + } + + /** + * Gets the index at which the last occurrence of `value` is found using strict + * equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used + * as the offset from the end of the collection. + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to search. + * @param {*} value The value to search for. + * @param {number} [fromIndex=array.length-1] The index to search from. + * @returns {number} Returns the index of the matched value or `-1`. + * @example + * + * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); + * // => 4 + * + * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); + * // => 1 + */ + function lastIndexOf(array, value, fromIndex) { + var index = array ? array.length : 0; + if (typeof fromIndex == 'number') { + index = (fromIndex < 0 ? nativeMax(0, index + fromIndex) : nativeMin(fromIndex, index - 1)) + 1; + } + while (index--) { + if (array[index] === value) { + return index; + } + } + return -1; + } + + /** + * Removes all provided values from the given array using strict equality for + * comparisons, i.e. `===`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to modify. + * @param {...*} [value] The values to remove. + * @returns {Array} Returns `array`. + * @example + * + * var array = [1, 2, 3, 1, 2, 3]; + * _.pull(array, 2, 3); + * console.log(array); + * // => [1, 1] + */ + function pull(array) { + var args = arguments, + argsIndex = 0, + argsLength = args.length, + length = array ? array.length : 0; + + while (++argsIndex < argsLength) { + var index = -1, + value = args[argsIndex]; + while (++index < length) { + if (array[index] === value) { + splice.call(array, index--, 1); + length--; + } + } + } + return array; + } + + /** + * Creates an array of numbers (positive and/or negative) progressing from + * `start` up to but not including `end`. If `start` is less than `stop` a + * zero-length range is created unless a negative `step` is specified. + * + * @static + * @memberOf _ + * @category Arrays + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @param {number} [step=1] The value to increment or decrement by. + * @returns {Array} Returns a new range array. + * @example + * + * _.range(4); + * // => [0, 1, 2, 3] + * + * _.range(1, 5); + * // => [1, 2, 3, 4] + * + * _.range(0, 20, 5); + * // => [0, 5, 10, 15] + * + * _.range(0, -4, -1); + * // => [0, -1, -2, -3] + * + * _.range(1, 4, 0); + * // => [1, 1, 1] + * + * _.range(0); + * // => [] + */ + function range(start, end, step) { + start = +start || 0; + step = typeof step == 'number' ? step : (+step || 1); + + if (end == null) { + end = start; + start = 0; + } + // use `Array(length)` so engines like Chakra and V8 avoid slower modes + // http://youtu.be/XAqIpGU8ZZk#t=17m25s + var index = -1, + length = nativeMax(0, ceil((end - start) / (step || 1))), + result = Array(length); + + while (++index < length) { + result[index] = start; + start += step; + } + return result; + } + + /** + * Removes all elements from an array that the callback returns truey for + * and returns an array of removed elements. The callback is bound to `thisArg` + * and invoked with three arguments; (value, index, array). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to modify. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a new array of removed elements. + * @example + * + * var array = [1, 2, 3, 4, 5, 6]; + * var evens = _.remove(array, function(num) { return num % 2 == 0; }); + * + * console.log(array); + * // => [1, 3, 5] + * + * console.log(evens); + * // => [2, 4, 6] + */ + function remove(array, callback, thisArg) { + var index = -1, + length = array ? array.length : 0, + result = []; + + callback = lodash.createCallback(callback, thisArg, 3); + while (++index < length) { + var value = array[index]; + if (callback(value, index, array)) { + result.push(value); + splice.call(array, index--, 1); + length--; + } + } + return result; + } + + /** + * The opposite of `_.initial` this method gets all but the first element or + * first `n` elements of an array. If a callback function is provided elements + * at the beginning of the array are excluded from the result as long as the + * callback returns truey. The callback is bound to `thisArg` and invoked + * with three arguments; (value, index, array). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @alias drop, tail + * @category Arrays + * @param {Array} array The array to query. + * @param {Function|Object|number|string} [callback=1] The function called + * per element or the number of elements to exclude. If a property name or + * object is provided it will be used to create a "_.pluck" or "_.where" + * style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a slice of `array`. + * @example + * + * _.rest([1, 2, 3]); + * // => [2, 3] + * + * _.rest([1, 2, 3], 2); + * // => [3] + * + * _.rest([1, 2, 3], function(num) { + * return num < 3; + * }); + * // => [3] + * + * var characters = [ + * { 'name': 'barney', 'blocked': true, 'employer': 'slate' }, + * { 'name': 'fred', 'blocked': false, 'employer': 'slate' }, + * { 'name': 'pebbles', 'blocked': true, 'employer': 'na' } + * ]; + * + * // using "_.pluck" callback shorthand + * _.pluck(_.rest(characters, 'blocked'), 'name'); + * // => ['fred', 'pebbles'] + * + * // using "_.where" callback shorthand + * _.rest(characters, { 'employer': 'slate' }); + * // => [{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }] + */ + function rest(array, callback, thisArg) { + if (typeof callback != 'number' && callback != null) { + var n = 0, + index = -1, + length = array ? array.length : 0; + + callback = lodash.createCallback(callback, thisArg, 3); + while (++index < length && callback(array[index], index, array)) { + n++; + } + } else { + n = (callback == null || thisArg) ? 1 : nativeMax(0, callback); + } + return slice(array, n); + } + + /** + * Uses a binary search to determine the smallest index at which a value + * should be inserted into a given sorted array in order to maintain the sort + * order of the array. If a callback is provided it will be executed for + * `value` and each element of `array` to compute their sort ranking. The + * callback is bound to `thisArg` and invoked with one argument; (value). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to inspect. + * @param {*} value The value to evaluate. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + * @example + * + * _.sortedIndex([20, 30, 50], 40); + * // => 2 + * + * // using "_.pluck" callback shorthand + * _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); + * // => 2 + * + * var dict = { + * 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } + * }; + * + * _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { + * return dict.wordToNumber[word]; + * }); + * // => 2 + * + * _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { + * return this.wordToNumber[word]; + * }, dict); + * // => 2 + */ + function sortedIndex(array, value, callback, thisArg) { + var low = 0, + high = array ? array.length : low; + + // explicitly reference `identity` for better inlining in Firefox + callback = callback ? lodash.createCallback(callback, thisArg, 1) : identity; + value = callback(value); + + while (low < high) { + var mid = (low + high) >>> 1; + (callback(array[mid]) < value) + ? low = mid + 1 + : high = mid; + } + return low; + } + + /** + * Creates an array of unique values, in order, of the provided arrays using + * strict equality for comparisons, i.e. `===`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {...Array} [array] The arrays to inspect. + * @returns {Array} Returns an array of combined values. + * @example + * + * _.union([1, 2, 3], [5, 2, 1, 4], [2, 1]); + * // => [1, 2, 3, 5, 4] + */ + function union() { + return baseUniq(baseFlatten(arguments, true, true)); + } + + /** + * Creates a duplicate-value-free version of an array using strict equality + * for comparisons, i.e. `===`. If the array is sorted, providing + * `true` for `isSorted` will use a faster algorithm. If a callback is provided + * each element of `array` is passed through the callback before uniqueness + * is computed. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index, array). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @alias unique + * @category Arrays + * @param {Array} array The array to process. + * @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Array} Returns a duplicate-value-free array. + * @example + * + * _.uniq([1, 2, 1, 3, 1]); + * // => [1, 2, 3] + * + * _.uniq([1, 1, 2, 2, 3], true); + * // => [1, 2, 3] + * + * _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); }); + * // => ['A', 'b', 'C'] + * + * _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); + * // => [1, 2.5, 3] + * + * // using "_.pluck" callback shorthand + * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 1 }, { 'x': 2 }] + */ + function uniq(array, isSorted, callback, thisArg) { + // juggle arguments + if (typeof isSorted != 'boolean' && isSorted != null) { + thisArg = callback; + callback = (typeof isSorted != 'function' && thisArg && thisArg[isSorted] === array) ? null : isSorted; + isSorted = false; + } + if (callback != null) { + callback = lodash.createCallback(callback, thisArg, 3); + } + return baseUniq(array, isSorted, callback); + } + + /** + * Creates an array excluding all provided values using strict equality for + * comparisons, i.e. `===`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to filter. + * @param {...*} [value] The values to exclude. + * @returns {Array} Returns a new array of filtered values. + * @example + * + * _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); + * // => [2, 3, 4] + */ + function without(array) { + return baseDifference(array, slice(arguments, 1)); + } + + /** + * Creates an array that is the symmetric difference of the provided arrays. + * See http://en.wikipedia.org/wiki/Symmetric_difference. + * + * @static + * @memberOf _ + * @category Arrays + * @param {...Array} [array] The arrays to inspect. + * @returns {Array} Returns an array of values. + * @example + * + * _.xor([1, 2, 3], [5, 2, 1, 4]); + * // => [3, 5, 4] + * + * _.xor([1, 2, 5], [2, 3, 5], [3, 4, 5]); + * // => [1, 4, 5] + */ + function xor() { + var index = -1, + length = arguments.length; + + while (++index < length) { + var array = arguments[index]; + if (isArray(array) || isArguments(array)) { + var result = result + ? baseUniq(baseDifference(result, array).concat(baseDifference(array, result))) + : array; + } + } + return result || []; + } + + /** + * Creates an array of grouped elements, the first of which contains the first + * elements of the given arrays, the second of which contains the second + * elements of the given arrays, and so on. + * + * @static + * @memberOf _ + * @alias unzip + * @category Arrays + * @param {...Array} [array] Arrays to process. + * @returns {Array} Returns a new array of grouped elements. + * @example + * + * _.zip(['fred', 'barney'], [30, 40], [true, false]); + * // => [['fred', 30, true], ['barney', 40, false]] + */ + function zip() { + var array = arguments.length > 1 ? arguments : arguments[0], + index = -1, + length = array ? max(pluck(array, 'length')) : 0, + result = Array(length < 0 ? 0 : length); + + while (++index < length) { + result[index] = pluck(array, index); + } + return result; + } + + /** + * Creates an object composed from arrays of `keys` and `values`. Provide + * either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]` + * or two arrays, one of `keys` and one of corresponding `values`. + * + * @static + * @memberOf _ + * @alias object + * @category Arrays + * @param {Array} keys The array of keys. + * @param {Array} [values=[]] The array of values. + * @returns {Object} Returns an object composed of the given keys and + * corresponding values. + * @example + * + * _.zipObject(['fred', 'barney'], [30, 40]); + * // => { 'fred': 30, 'barney': 40 } + */ + function zipObject(keys, values) { + var index = -1, + length = keys ? keys.length : 0, + result = {}; + + if (!values && length && !isArray(keys[0])) { + values = []; + } + while (++index < length) { + var key = keys[index]; + if (values) { + result[key] = values[index]; + } else if (key) { + result[key[0]] = key[1]; + } + } + return result; + } + + /*--------------------------------------------------------------------------*/ + + /** + * Creates a function that executes `func`, with the `this` binding and + * arguments of the created function, only after being called `n` times. + * + * @static + * @memberOf _ + * @category Functions + * @param {number} n The number of times the function must be called before + * `func` is executed. + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * var saves = ['profile', 'settings']; + * + * var done = _.after(saves.length, function() { + * console.log('Done saving!'); + * }); + * + * _.forEach(saves, function(type) { + * asyncSave({ 'type': type, 'complete': done }); + * }); + * // => logs 'Done saving!', after all saves have completed + */ + function after(n, func) { + if (!isFunction(func)) { + throw new TypeError; + } + return function() { + if (--n < 1) { + return func.apply(this, arguments); + } + }; + } + + /** + * Creates a function that, when called, invokes `func` with the `this` + * binding of `thisArg` and prepends any additional `bind` arguments to those + * provided to the bound function. + * + * @static + * @memberOf _ + * @category Functions + * @param {Function} func The function to bind. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {...*} [arg] Arguments to be partially applied. + * @returns {Function} Returns the new bound function. + * @example + * + * var func = function(greeting) { + * return greeting + ' ' + this.name; + * }; + * + * func = _.bind(func, { 'name': 'fred' }, 'hi'); + * func(); + * // => 'hi fred' + */ + function bind(func, thisArg) { + return arguments.length > 2 + ? createWrapper(func, 17, slice(arguments, 2), null, thisArg) + : createWrapper(func, 1, null, null, thisArg); + } + + /** + * Binds methods of an object to the object itself, overwriting the existing + * method. Method names may be specified as individual arguments or as arrays + * of method names. If no method names are provided all the function properties + * of `object` will be bound. + * + * @static + * @memberOf _ + * @category Functions + * @param {Object} object The object to bind and assign the bound methods to. + * @param {...string} [methodName] The object method names to + * bind, specified as individual method names or arrays of method names. + * @returns {Object} Returns `object`. + * @example + * + * var view = { + * 'label': 'docs', + * 'onClick': function() { console.log('clicked ' + this.label); } + * }; + * + * _.bindAll(view); + * jQuery('#docs').on('click', view.onClick); + * // => logs 'clicked docs', when the button is clicked + */ + function bindAll(object) { + var funcs = arguments.length > 1 ? baseFlatten(arguments, true, false, 1) : functions(object), + index = -1, + length = funcs.length; + + while (++index < length) { + var key = funcs[index]; + object[key] = createWrapper(object[key], 1, null, null, object); + } + return object; + } + + /** + * Creates a function that, when called, invokes the method at `object[key]` + * and prepends any additional `bindKey` arguments to those provided to the bound + * function. This method differs from `_.bind` by allowing bound functions to + * reference methods that will be redefined or don't yet exist. + * See http://michaux.ca/articles/lazy-function-definition-pattern. + * + * @static + * @memberOf _ + * @category Functions + * @param {Object} object The object the method belongs to. + * @param {string} key The key of the method. + * @param {...*} [arg] Arguments to be partially applied. + * @returns {Function} Returns the new bound function. + * @example + * + * var object = { + * 'name': 'fred', + * 'greet': function(greeting) { + * return greeting + ' ' + this.name; + * } + * }; + * + * var func = _.bindKey(object, 'greet', 'hi'); + * func(); + * // => 'hi fred' + * + * object.greet = function(greeting) { + * return greeting + 'ya ' + this.name + '!'; + * }; + * + * func(); + * // => 'hiya fred!' + */ + function bindKey(object, key) { + return arguments.length > 2 + ? createWrapper(key, 19, slice(arguments, 2), null, object) + : createWrapper(key, 3, null, null, object); + } + + /** + * Creates a function that is the composition of the provided functions, + * where each function consumes the return value of the function that follows. + * For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. + * Each function is executed with the `this` binding of the composed function. + * + * @static + * @memberOf _ + * @category Functions + * @param {...Function} [func] Functions to compose. + * @returns {Function} Returns the new composed function. + * @example + * + * var realNameMap = { + * 'pebbles': 'penelope' + * }; + * + * var format = function(name) { + * name = realNameMap[name.toLowerCase()] || name; + * return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); + * }; + * + * var greet = function(formatted) { + * return 'Hiya ' + formatted + '!'; + * }; + * + * var welcome = _.compose(greet, format); + * welcome('pebbles'); + * // => 'Hiya Penelope!' + */ + function compose() { + var funcs = arguments, + length = funcs.length; + + while (length--) { + if (!isFunction(funcs[length])) { + throw new TypeError; + } + } + return function() { + var args = arguments, + length = funcs.length; + + while (length--) { + args = [funcs[length].apply(this, args)]; + } + return args[0]; + }; + } + + /** + * Creates a function which accepts one or more arguments of `func` that when + * invoked either executes `func` returning its result, if all `func` arguments + * have been provided, or returns a function that accepts one or more of the + * remaining `func` arguments, and so on. The arity of `func` can be specified + * if `func.length` is not sufficient. + * + * @static + * @memberOf _ + * @category Functions + * @param {Function} func The function to curry. + * @param {number} [arity=func.length] The arity of `func`. + * @returns {Function} Returns the new curried function. + * @example + * + * var curried = _.curry(function(a, b, c) { + * console.log(a + b + c); + * }); + * + * curried(1)(2)(3); + * // => 6 + * + * curried(1, 2)(3); + * // => 6 + * + * curried(1, 2, 3); + * // => 6 + */ + function curry(func, arity) { + arity = typeof arity == 'number' ? arity : (+arity || func.length); + return createWrapper(func, 4, null, null, null, arity); + } + + /** + * Creates a function that will delay the execution of `func` until after + * `wait` milliseconds have elapsed since the last time it was invoked. + * Provide an options object to indicate that `func` should be invoked on + * the leading and/or trailing edge of the `wait` timeout. Subsequent calls + * to the debounced function will return the result of the last `func` call. + * + * Note: If `leading` and `trailing` options are `true` `func` will be called + * on the trailing edge of the timeout only if the the debounced function is + * invoked more than once during the `wait` timeout. + * + * @static + * @memberOf _ + * @category Functions + * @param {Function} func The function to debounce. + * @param {number} wait The number of milliseconds to delay. + * @param {Object} [options] The options object. + * @param {boolean} [options.leading=false] Specify execution on the leading edge of the timeout. + * @param {number} [options.maxWait] The maximum time `func` is allowed to be delayed before it's called. + * @param {boolean} [options.trailing=true] Specify execution on the trailing edge of the timeout. + * @returns {Function} Returns the new debounced function. + * @example + * + * // avoid costly calculations while the window size is in flux + * var lazyLayout = _.debounce(calculateLayout, 150); + * jQuery(window).on('resize', lazyLayout); + * + * // execute `sendMail` when the click event is fired, debouncing subsequent calls + * jQuery('#postbox').on('click', _.debounce(sendMail, 300, { + * 'leading': true, + * 'trailing': false + * }); + * + * // ensure `batchLog` is executed once after 1 second of debounced calls + * var source = new EventSource('/stream'); + * source.addEventListener('message', _.debounce(batchLog, 250, { + * 'maxWait': 1000 + * }, false); + */ + function debounce(func, wait, options) { + var args, + maxTimeoutId, + result, + stamp, + thisArg, + timeoutId, + trailingCall, + lastCalled = 0, + maxWait = false, + trailing = true; + + if (!isFunction(func)) { + throw new TypeError; + } + wait = nativeMax(0, wait) || 0; + if (options === true) { + var leading = true; + trailing = false; + } else if (isObject(options)) { + leading = options.leading; + maxWait = 'maxWait' in options && (nativeMax(wait, options.maxWait) || 0); + trailing = 'trailing' in options ? options.trailing : trailing; + } + var delayed = function() { + var remaining = wait - (now() - stamp); + if (remaining <= 0) { + if (maxTimeoutId) { + clearTimeout(maxTimeoutId); + } + var isCalled = trailingCall; + maxTimeoutId = timeoutId = trailingCall = undefined; + if (isCalled) { + lastCalled = now(); + result = func.apply(thisArg, args); + if (!timeoutId && !maxTimeoutId) { + args = thisArg = null; + } + } + } else { + timeoutId = setTimeout(delayed, remaining); + } + }; + + var maxDelayed = function() { + if (timeoutId) { + clearTimeout(timeoutId); + } + maxTimeoutId = timeoutId = trailingCall = undefined; + if (trailing || (maxWait !== wait)) { + lastCalled = now(); + result = func.apply(thisArg, args); + if (!timeoutId && !maxTimeoutId) { + args = thisArg = null; + } + } + }; + + return function() { + args = arguments; + stamp = now(); + thisArg = this; + trailingCall = trailing && (timeoutId || !leading); + + if (maxWait === false) { + var leadingCall = leading && !timeoutId; + } else { + if (!maxTimeoutId && !leading) { + lastCalled = stamp; + } + var remaining = maxWait - (stamp - lastCalled), + isCalled = remaining <= 0; + + if (isCalled) { + if (maxTimeoutId) { + maxTimeoutId = clearTimeout(maxTimeoutId); + } + lastCalled = stamp; + result = func.apply(thisArg, args); + } + else if (!maxTimeoutId) { + maxTimeoutId = setTimeout(maxDelayed, remaining); + } + } + if (isCalled && timeoutId) { + timeoutId = clearTimeout(timeoutId); + } + else if (!timeoutId && wait !== maxWait) { + timeoutId = setTimeout(delayed, wait); + } + if (leadingCall) { + isCalled = true; + result = func.apply(thisArg, args); + } + if (isCalled && !timeoutId && !maxTimeoutId) { + args = thisArg = null; + } + return result; + }; + } + + /** + * Defers executing the `func` function until the current call stack has cleared. + * Additional arguments will be provided to `func` when it is invoked. + * + * @static + * @memberOf _ + * @category Functions + * @param {Function} func The function to defer. + * @param {...*} [arg] Arguments to invoke the function with. + * @returns {number} Returns the timer id. + * @example + * + * _.defer(function(text) { console.log(text); }, 'deferred'); + * // logs 'deferred' after one or more milliseconds + */ + function defer(func) { + if (!isFunction(func)) { + throw new TypeError; + } + var args = slice(arguments, 1); + return setTimeout(function() { func.apply(undefined, args); }, 1); + } + + /** + * Executes the `func` function after `wait` milliseconds. Additional arguments + * will be provided to `func` when it is invoked. + * + * @static + * @memberOf _ + * @category Functions + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay execution. + * @param {...*} [arg] Arguments to invoke the function with. + * @returns {number} Returns the timer id. + * @example + * + * _.delay(function(text) { console.log(text); }, 1000, 'later'); + * // => logs 'later' after one second + */ + function delay(func, wait) { + if (!isFunction(func)) { + throw new TypeError; + } + var args = slice(arguments, 2); + return setTimeout(function() { func.apply(undefined, args); }, wait); + } + + /** + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided it will be used to determine the cache key for storing the result + * based on the arguments provided to the memoized function. By default, the + * first argument provided to the memoized function is used as the cache key. + * The `func` is executed with the `this` binding of the memoized function. + * The result cache is exposed as the `cache` property on the memoized function. + * + * @static + * @memberOf _ + * @category Functions + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] A function used to resolve the cache key. + * @returns {Function} Returns the new memoizing function. + * @example + * + * var fibonacci = _.memoize(function(n) { + * return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); + * }); + * + * fibonacci(9) + * // => 34 + * + * var data = { + * 'fred': { 'name': 'fred', 'age': 40 }, + * 'pebbles': { 'name': 'pebbles', 'age': 1 } + * }; + * + * // modifying the result cache + * var get = _.memoize(function(name) { return data[name]; }, _.identity); + * get('pebbles'); + * // => { 'name': 'pebbles', 'age': 1 } + * + * get.cache.pebbles.name = 'penelope'; + * get('pebbles'); + * // => { 'name': 'penelope', 'age': 1 } + */ + function memoize(func, resolver) { + if (!isFunction(func)) { + throw new TypeError; + } + var memoized = function() { + var cache = memoized.cache, + key = resolver ? resolver.apply(this, arguments) : keyPrefix + arguments[0]; + + return hasOwnProperty.call(cache, key) + ? cache[key] + : (cache[key] = func.apply(this, arguments)); + } + memoized.cache = {}; + return memoized; + } + + /** + * Creates a function that is restricted to execute `func` once. Repeat calls to + * the function will return the value of the first call. The `func` is executed + * with the `this` binding of the created function. + * + * @static + * @memberOf _ + * @category Functions + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * var initialize = _.once(createApplication); + * initialize(); + * initialize(); + * // `initialize` executes `createApplication` once + */ + function once(func) { + var ran, + result; + + if (!isFunction(func)) { + throw new TypeError; + } + return function() { + if (ran) { + return result; + } + ran = true; + result = func.apply(this, arguments); + + // clear the `func` variable so the function may be garbage collected + func = null; + return result; + }; + } + + /** + * Creates a function that, when called, invokes `func` with any additional + * `partial` arguments prepended to those provided to the new function. This + * method is similar to `_.bind` except it does **not** alter the `this` binding. + * + * @static + * @memberOf _ + * @category Functions + * @param {Function} func The function to partially apply arguments to. + * @param {...*} [arg] Arguments to be partially applied. + * @returns {Function} Returns the new partially applied function. + * @example + * + * var greet = function(greeting, name) { return greeting + ' ' + name; }; + * var hi = _.partial(greet, 'hi'); + * hi('fred'); + * // => 'hi fred' + */ + function partial(func) { + return createWrapper(func, 16, slice(arguments, 1)); + } + + /** + * This method is like `_.partial` except that `partial` arguments are + * appended to those provided to the new function. + * + * @static + * @memberOf _ + * @category Functions + * @param {Function} func The function to partially apply arguments to. + * @param {...*} [arg] Arguments to be partially applied. + * @returns {Function} Returns the new partially applied function. + * @example + * + * var defaultsDeep = _.partialRight(_.merge, _.defaults); + * + * var options = { + * 'variable': 'data', + * 'imports': { 'jq': $ } + * }; + * + * defaultsDeep(options, _.templateSettings); + * + * options.variable + * // => 'data' + * + * options.imports + * // => { '_': _, 'jq': $ } + */ + function partialRight(func) { + return createWrapper(func, 32, null, slice(arguments, 1)); + } + + /** + * Creates a function that, when executed, will only call the `func` function + * at most once per every `wait` milliseconds. Provide an options object to + * indicate that `func` should be invoked on the leading and/or trailing edge + * of the `wait` timeout. Subsequent calls to the throttled function will + * return the result of the last `func` call. + * + * Note: If `leading` and `trailing` options are `true` `func` will be called + * on the trailing edge of the timeout only if the the throttled function is + * invoked more than once during the `wait` timeout. + * + * @static + * @memberOf _ + * @category Functions + * @param {Function} func The function to throttle. + * @param {number} wait The number of milliseconds to throttle executions to. + * @param {Object} [options] The options object. + * @param {boolean} [options.leading=true] Specify execution on the leading edge of the timeout. + * @param {boolean} [options.trailing=true] Specify execution on the trailing edge of the timeout. + * @returns {Function} Returns the new throttled function. + * @example + * + * // avoid excessively updating the position while scrolling + * var throttled = _.throttle(updatePosition, 100); + * jQuery(window).on('scroll', throttled); + * + * // execute `renewToken` when the click event is fired, but not more than once every 5 minutes + * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { + * 'trailing': false + * })); + */ + function throttle(func, wait, options) { + var leading = true, + trailing = true; + + if (!isFunction(func)) { + throw new TypeError; + } + if (options === false) { + leading = false; + } else if (isObject(options)) { + leading = 'leading' in options ? options.leading : leading; + trailing = 'trailing' in options ? options.trailing : trailing; + } + debounceOptions.leading = leading; + debounceOptions.maxWait = wait; + debounceOptions.trailing = trailing; + + return debounce(func, wait, debounceOptions); + } + + /** + * Creates a function that provides `value` to the wrapper function as its + * first argument. Additional arguments provided to the function are appended + * to those provided to the wrapper function. The wrapper is executed with + * the `this` binding of the created function. + * + * @static + * @memberOf _ + * @category Functions + * @param {*} value The value to wrap. + * @param {Function} wrapper The wrapper function. + * @returns {Function} Returns the new function. + * @example + * + * var p = _.wrap(_.escape, function(func, text) { + * return '

' + func(text) + '

'; + * }); + * + * p('Fred, Wilma, & Pebbles'); + * // => '

Fred, Wilma, & Pebbles

' + */ + function wrap(value, wrapper) { + return createWrapper(wrapper, 16, [value]); + } + + /*--------------------------------------------------------------------------*/ + + /** + * Creates a function that returns `value`. + * + * @static + * @memberOf _ + * @category Utilities + * @param {*} value The value to return from the new function. + * @returns {Function} Returns the new function. + * @example + * + * var object = { 'name': 'fred' }; + * var getter = _.constant(object); + * getter() === object; + * // => true + */ + function constant(value) { + return function() { + return value; + }; + } + + /** + * Produces a callback bound to an optional `thisArg`. If `func` is a property + * name the created callback will return the property value for a given element. + * If `func` is an object the created callback will return `true` for elements + * that contain the equivalent object properties, otherwise it will return `false`. + * + * @static + * @memberOf _ + * @category Utilities + * @param {*} [func=identity] The value to convert to a callback. + * @param {*} [thisArg] The `this` binding of the created callback. + * @param {number} [argCount] The number of arguments the callback accepts. + * @returns {Function} Returns a callback function. + * @example + * + * var characters = [ + * { 'name': 'barney', 'age': 36 }, + * { 'name': 'fred', 'age': 40 } + * ]; + * + * // wrap to create custom callback shorthands + * _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) { + * var match = /^(.+?)__([gl]t)(.+)$/.exec(callback); + * return !match ? func(callback, thisArg) : function(object) { + * return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3]; + * }; + * }); + * + * _.filter(characters, 'age__gt38'); + * // => [{ 'name': 'fred', 'age': 40 }] + */ + function createCallback(func, thisArg, argCount) { + var type = typeof func; + if (func == null || type == 'function') { + return baseCreateCallback(func, thisArg, argCount); + } + // handle "_.pluck" style callback shorthands + if (type != 'object') { + return property(func); + } + var props = keys(func), + key = props[0], + a = func[key]; + + // handle "_.where" style callback shorthands + if (props.length == 1 && a === a && !isObject(a)) { + // fast path the common case of providing an object with a single + // property containing a primitive value + return function(object) { + var b = object[key]; + return a === b && (a !== 0 || (1 / a == 1 / b)); + }; + } + return function(object) { + var length = props.length, + result = false; + + while (length--) { + if (!(result = baseIsEqual(object[props[length]], func[props[length]], null, true))) { + break; + } + } + return result; + }; + } + + /** + * Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their + * corresponding HTML entities. + * + * @static + * @memberOf _ + * @category Utilities + * @param {string} string The string to escape. + * @returns {string} Returns the escaped string. + * @example + * + * _.escape('Fred, Wilma, & Pebbles'); + * // => 'Fred, Wilma, & Pebbles' + */ + function escape(string) { + return string == null ? '' : String(string).replace(reUnescapedHtml, escapeHtmlChar); + } + + /** + * This method returns the first argument provided to it. + * + * @static + * @memberOf _ + * @category Utilities + * @param {*} value Any value. + * @returns {*} Returns `value`. + * @example + * + * var object = { 'name': 'fred' }; + * _.identity(object) === object; + * // => true + */ + function identity(value) { + return value; + } + + /** + * Adds function properties of a source object to the destination object. + * If `object` is a function methods will be added to its prototype as well. + * + * @static + * @memberOf _ + * @category Utilities + * @param {Function|Object} [object=lodash] object The destination object. + * @param {Object} source The object of functions to add. + * @param {Object} [options] The options object. + * @param {boolean} [options.chain=true] Specify whether the functions added are chainable. + * @example + * + * function capitalize(string) { + * return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); + * } + * + * _.mixin({ 'capitalize': capitalize }); + * _.capitalize('fred'); + * // => 'Fred' + * + * _('fred').capitalize().value(); + * // => 'Fred' + * + * _.mixin({ 'capitalize': capitalize }, { 'chain': false }); + * _('fred').capitalize(); + * // => 'Fred' + */ + function mixin(object, source, options) { + var chain = true, + methodNames = source && functions(source); + + if (!source || (!options && !methodNames.length)) { + if (options == null) { + options = source; + } + ctor = lodashWrapper; + source = object; + object = lodash; + methodNames = functions(source); + } + if (options === false) { + chain = false; + } else if (isObject(options) && 'chain' in options) { + chain = options.chain; + } + var ctor = object, + isFunc = isFunction(ctor); + + forEach(methodNames, function(methodName) { + var func = object[methodName] = source[methodName]; + if (isFunc) { + ctor.prototype[methodName] = function() { + var chainAll = this.__chain__, + value = this.__wrapped__, + args = [value]; + + push.apply(args, arguments); + var result = func.apply(object, args); + if (chain || chainAll) { + if (value === result && isObject(result)) { + return this; + } + result = new ctor(result); + result.__chain__ = chainAll; + } + return result; + }; + } + }); + } + + /** + * Reverts the '_' variable to its previous value and returns a reference to + * the `lodash` function. + * + * @static + * @memberOf _ + * @category Utilities + * @returns {Function} Returns the `lodash` function. + * @example + * + * var lodash = _.noConflict(); + */ + function noConflict() { + context._ = oldDash; + return this; + } + + /** + * A no-operation function. + * + * @static + * @memberOf _ + * @category Utilities + * @example + * + * var object = { 'name': 'fred' }; + * _.noop(object) === undefined; + * // => true + */ + function noop() { + // no operation performed + } + + /** + * Gets the number of milliseconds that have elapsed since the Unix epoch + * (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @category Utilities + * @example + * + * var stamp = _.now(); + * _.defer(function() { console.log(_.now() - stamp); }); + * // => logs the number of milliseconds it took for the deferred function to be called + */ + var now = isNative(now = Date.now) && now || function() { + return new Date().getTime(); + }; + + /** + * Converts the given value into an integer of the specified radix. + * If `radix` is `undefined` or `0` a `radix` of `10` is used unless the + * `value` is a hexadecimal, in which case a `radix` of `16` is used. + * + * Note: This method avoids differences in native ES3 and ES5 `parseInt` + * implementations. See http://es5.github.io/#E. + * + * @static + * @memberOf _ + * @category Utilities + * @param {string} value The value to parse. + * @param {number} [radix] The radix used to interpret the value to parse. + * @returns {number} Returns the new integer value. + * @example + * + * _.parseInt('08'); + * // => 8 + */ + var parseInt = nativeParseInt(whitespace + '08') == 8 ? nativeParseInt : function(value, radix) { + // Firefox < 21 and Opera < 15 follow the ES3 specified implementation of `parseInt` + return nativeParseInt(isString(value) ? value.replace(reLeadingSpacesAndZeros, '') : value, radix || 0); + }; + + /** + * Creates a "_.pluck" style function, which returns the `key` value of a + * given object. + * + * @static + * @memberOf _ + * @category Utilities + * @param {string} key The name of the property to retrieve. + * @returns {Function} Returns the new function. + * @example + * + * var characters = [ + * { 'name': 'fred', 'age': 40 }, + * { 'name': 'barney', 'age': 36 } + * ]; + * + * var getName = _.property('name'); + * + * _.map(characters, getName); + * // => ['barney', 'fred'] + * + * _.sortBy(characters, getName); + * // => [{ 'name': 'barney', 'age': 36 }, { 'name': 'fred', 'age': 40 }] + */ + function property(key) { + return function(object) { + return object[key]; + }; + } + + /** + * Produces a random number between `min` and `max` (inclusive). If only one + * argument is provided a number between `0` and the given number will be + * returned. If `floating` is truey or either `min` or `max` are floats a + * floating-point number will be returned instead of an integer. + * + * @static + * @memberOf _ + * @category Utilities + * @param {number} [min=0] The minimum possible value. + * @param {number} [max=1] The maximum possible value. + * @param {boolean} [floating=false] Specify returning a floating-point number. + * @returns {number} Returns a random number. + * @example + * + * _.random(0, 5); + * // => an integer between 0 and 5 + * + * _.random(5); + * // => also an integer between 0 and 5 + * + * _.random(5, true); + * // => a floating-point number between 0 and 5 + * + * _.random(1.2, 5.2); + * // => a floating-point number between 1.2 and 5.2 + */ + function random(min, max, floating) { + var noMin = min == null, + noMax = max == null; + + if (floating == null) { + if (typeof min == 'boolean' && noMax) { + floating = min; + min = 1; + } + else if (!noMax && typeof max == 'boolean') { + floating = max; + noMax = true; + } + } + if (noMin && noMax) { + max = 1; + } + min = +min || 0; + if (noMax) { + max = min; + min = 0; + } else { + max = +max || 0; + } + if (floating || min % 1 || max % 1) { + var rand = nativeRandom(); + return nativeMin(min + (rand * (max - min + parseFloat('1e-' + ((rand +'').length - 1)))), max); + } + return baseRandom(min, max); + } + + /** + * Resolves the value of property `key` on `object`. If `key` is a function + * it will be invoked with the `this` binding of `object` and its result returned, + * else the property value is returned. If `object` is falsey then `undefined` + * is returned. + * + * @static + * @memberOf _ + * @category Utilities + * @param {Object} object The object to inspect. + * @param {string} key The name of the property to resolve. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { + * 'cheese': 'crumpets', + * 'stuff': function() { + * return 'nonsense'; + * } + * }; + * + * _.result(object, 'cheese'); + * // => 'crumpets' + * + * _.result(object, 'stuff'); + * // => 'nonsense' + */ + function result(object, key) { + if (object) { + var value = object[key]; + return isFunction(value) ? object[key]() : value; + } + } + + /** + * A micro-templating method that handles arbitrary delimiters, preserves + * whitespace, and correctly escapes quotes within interpolated code. + * + * Note: In the development build, `_.template` utilizes sourceURLs for easier + * debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl + * + * For more information on precompiling templates see: + * http://lodash.com/custom-builds + * + * For more information on Chrome extension sandboxes see: + * http://developer.chrome.com/stable/extensions/sandboxingEval.html + * + * @static + * @memberOf _ + * @category Utilities + * @param {string} text The template text. + * @param {Object} data The data object used to populate the text. + * @param {Object} [options] The options object. + * @param {RegExp} [options.escape] The "escape" delimiter. + * @param {RegExp} [options.evaluate] The "evaluate" delimiter. + * @param {Object} [options.imports] An object to import into the template as local variables. + * @param {RegExp} [options.interpolate] The "interpolate" delimiter. + * @param {string} [sourceURL] The sourceURL of the template's compiled source. + * @param {string} [variable] The data object variable name. + * @returns {Function|string} Returns a compiled function when no `data` object + * is given, else it returns the interpolated text. + * @example + * + * // using the "interpolate" delimiter to create a compiled template + * var compiled = _.template('hello <%= name %>'); + * compiled({ 'name': 'fred' }); + * // => 'hello fred' + * + * // using the "escape" delimiter to escape HTML in data property values + * _.template('<%- value %>', { 'value': '