!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.qevents=e():t.qevents=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t["default"]}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s="./shared/qevents/main.js")}({"./shared/Class.js":function(t,e){function r(t,e){function r(){if(i||(t.call(c),n(h,e,a),i=!0,e=null),this!==c){var r=this.__init__;r&&r.apply(this,arguments)}}var i,a=s.prototype=t.prototype,h=new s;return r.prototype=h,r.extend=o,h.constructor=r,r}function n(t,e,r){for(var n in e)e.hasOwnProperty(n)&&(t[n]=r?i(n,e,r):e[n])}function i(t,e,r){var n=e[t],i=r[t];return"function"==typeof n&&"function"==typeof i&&n!==i&&a.test(n)?function(){var e=this._super;this._super=r[t];try{return n.apply(this,arguments)}finally{this._super=e}}:n}function o(t){return r(this,t)}var a=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/,s=function(){},c={};e.Class=o.call(function(){},{})},"./shared/email_normalizer.js":function(t,e){e.normalizeEmail=function(t){var e=/@(.*mail\.facebook\.com|quora\.com)/,r=/\+.*?@/,n="@gmail.com".length;return t=t.toLowerCase(),-1!=t.indexOf("+")&&-1==t.search(e)&&(t=t.replace(r,"@")),t.endsWith("@gmail.com")&&(t=t.slice(0,-n).replace(/\./g,"")+"@gmail.com"),t}},"./shared/hash_email.js":function(t,e,r){var n=r("./third_party/sjcl.js");e.validateEmail=function(t){return/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(t)},e.validateSHA256=function(t){return/^[a-z0-9]{64}$/i.test(t)},e.sha256HexDigest=function(t){var e=n.hash.sha256.hash(t);return n.codec.hex.fromBits(e)}},"./shared/polyfills/array.js":function(t,e){var r=function(t,e,r){"function"==typeof Object.defineProperty?Object.defineProperty(t,e,{configurable:!0,value:r,writable:!0,enumerable:!1}):t[e]=r};if(!Array.prototype.every){var n=function(t,e){"use strict";var r,n;if(null===this)throw new TypeError("this is null or not defined");var i=Object(this),o=i.length>>>0;if("function"!=typeof t)throw new TypeError;for(arguments.length>1&&(r=e),n=0;n>>0,n=arguments.length>=2?arguments[1]:void 0,i=0;i>>0;if(0===i)return-1;var o=+e||0;if(Math.abs(o)===Infinity&&(o=0),o>=i)return-1;for(r=Math.max(o>=0?o:i-Math.abs(o),0);r>>0;if("function"!=typeof t)throw new TypeError(t+" is not a function");for(arguments.length>1&&(r=e),n=0;n>>0;if("function"!=typeof t)throw new TypeError(t+" is not a function");for(arguments.length>1&&(r=e),n=new Array(a),i=0;i>>0;if("function"!=typeof t)throw new TypeError;for(var n=[],i=arguments.length>=2?arguments[1]:void 0,o=0;o>>0,i=0;if(2==arguments.length)e=arguments[1];else{for(;i=n)throw new TypeError("Reduce of empty array with no initial value");e=r[i++]}for(;i>>0;if(0===i)return-1;for(e=i-1,arguments.length>1&&(e=Number(arguments[1]),e!=e?e=0:0!==e&&e!=1/0&&e!=-1/0&&(e=(e>0||-1)*Math.floor(Math.abs(e)))),r=e>=0?Math.min(e,i-1):i-Math.abs(e);r>=0;r--)if(r in n&&n[r]===t)return r;return-1};r(Array.prototype,"lastIndexOf",u)}if(!Array.prototype.includes){var l=function(t){"use strict";if(null==this)throw new TypeError("Array.prototype.includes called on null or undefined");var e=Object(this),r=parseInt(e.length,10)||0;if(0===r)return!1;var n,i=parseInt(arguments[1],10)||0;i>=0?n=i:(n=r+i)<0&&(n=0);for(var o;nr.length)&&(e=r.length),e-=t.length;var n=r.indexOf(t,e);return-1!==n&&n===e}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.substr(e,t.length)===t}),String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}),String.prototype.includes||(String.prototype.includes=function(t,e){"use strict";return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)})},"./shared/qevents/main.js":function(t,e,r){r("./shared/polyfills/string.js"),r("./shared/polyfills/array.js"),r("./shared/polyfills/function.js"),r("./shared/polyfills/object.js"),r("./shared/polyfills/date.js"),r("./shared/qevents/pixel.js").init(),r("./shared/qevents/queue.js").flush()},"./shared/qevents/pixel.js":function(t,e,r){function n(){try{var t=o("ia_share_url");if(null!==t)return t}catch(t){}try{return ia_document!==undefined&&ia_document.shareURL}catch(t){return}}function i(t){var e,r=[];for(var n in t)e=t[n],a(n)&&s(e)&&r.push(n+"="+encodeURIComponent(e));return r.join("&")}function o(t){var e=null,r=[];return window.location.search.substr(1).split("&").forEach(function(n){r=n.split("="),r[0]===t&&(e=decodeURIComponent(r[1]))}),e}function a(t){return"string"==typeof t}function s(t){return"string"==typeof t||!isNaN(Number(t))}function c(){function t(t,e){var r=window.history[t];window.history[t]=function(){var t=r.apply(this,arguments);return e.apply(this,arguments),t}}window.history.pushState&&window.history.replaceState&&(t("pushState",h),t("replaceState",h),window.addEventListener("popstate",h,!1))}function h(){!0!==window.qp.disablePushState&&e.quoraPixelHelper("track","ViewContent")}var u,l=r("./shared/Class.js").Class,f=r("./shared/email_normalizer.js"),d=r("./shared/hash_email.js"),p=r("./shared/qevents/timer.js").PixelTimer,y=l.extend({__init__:function(t,e){if("string"!=typeof t)throw new Error("Quora Pixel Error: The second argument passed to qp is invalid.");this.uuid=t,this.email=this._getEmailFromPassback(e),this.eventSource=this._getEventSourceFromPassback(e),this.lastViewContentUrl=""},track:function(t,r){if("string"!=typeof t)throw new Error("Quora Pixel Error: The second argument passed to qp is invalid.");var n,i,o=this._getIsFBIAUrl(),a=this._getValueFromPassback(r),s=this._getEventIdFromPassback(r),c=this._getUrl();if(this._shouldTrack(t,c)){n=this._getMetadata(t,c,o,a,undefined,undefined,s),i=this._getPixelUrl(n);var h="ViewContent"!==t&&"DwellTime"!==t;e.firePixel(i,h)}},trackDwellTime:function(t,r){if("number"!=typeof t)throw new Error("Quora Pixel Error: Invalid dwell time.");var n,i,o=this._getUrl();n=this._getMetadata("DwellTime",o,undefined,undefined,t,r,undefined),i=this._getPixelUrl(n),e.firePixel(i,!1)},_shouldTrack:function(t,e){return("ViewContent"!=t||e!=this.lastViewContentUrl)&&("DwellTime"!=t&&("ViewContent"==t&&(this.lastViewContentUrl=e),!0))},_getMetadata:function(t,e,r,n,i,o,a){var s={j:1,u:e,tag:t,ts:(new Date).getTime()};return r&&(s.fbia=1),n!==undefined&&(s.v=n),this.email!==undefined&&(s.em=this.email),this.eventSource!==undefined&&(s.i=this.eventSource),"DwellTime"===t&&i!==undefined&&(s.dwt=i),o!==undefined&&(s.ive=o),a!==undefined&&(s.evid=a),s},_getValueFromPassback:function(t){var e;if(t!==undefined&&null!==t&&t.value!==undefined&&"number"!=typeof(e=t.value)&&"string"!=typeof e)throw new Error("Quora Pixel Error: The third argument passed to qp is invalid.");return e},_getEventIdFromPassback:function(t){var e;return t!==undefined&&null!==t&&t.event_id!==undefined&&(e=t.event_id),e},_getEmailFromPassback:function(t){var e;if(t!==undefined&&null!==t)if(t.email!==undefined){if("string"!=typeof(e=f.normalizeEmail(t.email))||!d.validateEmail(e))throw new Error("Quora Pixel Error: The third argument passed to qp is invalid.");e=d.sha256HexDigest(e)}else if(t.hashed_email!==undefined&&("string"!=typeof(e=t.hashed_email)||!d.validateSHA256(e)))throw new Error("Quora Pixel Error: The third argument passed to qp is invalid.");return e},_getEventSourceFromPassback:function(t){var e;if(t!==undefined&&null!==t&&t.event_source!==undefined&&"string"!=typeof(e=t.event_source))throw new Error("Quora Pixel Error: The event source argument passed to qp is invalid.");return e},_getUrl:function(){var t=n();return t||(t=window.location.href),t},_getIsFBIAUrl:function(){return Boolean(n())},_getPixelUrl:function(t){return this._getBasePixelUrl()+this.uuid+"/pixel?"+i(t)},_getBasePixelUrl:function(){return"https://q.quora.com/_/ad/"}}),m=l.extend({__init__:function(){this.uuidToPixel={}},installPixel:function(t,e){if(this.uuidToPixel[t]===undefined){var r=new y(t,e);this.uuidToPixel[t]=r}},track:function(t,e){var r=Object.keys(this.uuidToPixel);if(!r.length)throw new Error("Quora Pixel Error: Base pixel code is not installed properly.");for(var n=0;n0&&t(n,e),a=undefined}}function o(){"undefined"!=typeof document.msHidden?(s="msHidden",c="msvisibilitychange"):"undefined"!=typeof document.webkitHidden?(s="webkitHidden",c="webkitvisibilitychange"):"undefined"!=typeof document.mozHidden?(s="mozHidden",c="mozvisibilitychange"):(s="hidden",c="visibilitychange")}var a,s,c,h=r("./shared/Class.js").Class;e.PixelTimer=h.extend({__init__:function(t){o(),document.addEventListener(c,function(){"visible"===document[s]||!1===document[s]?n():"hidden"!==document[s]&&!0!==document[s]||i(t,s)}),window.addEventListener("pageshow",function(t){n()}),window.addEventListener("pagehide",function(e){i(t,"pagehide")}),window.addEventListener("blur",function(){i(t,"blur")}),window.addEventListener("focus",function(){n()})}})},"./third_party/sjcl.js":function(t,e){/*! SJCL is open. You can use, modify and redistribute it under a BSD license or under the GNU GPL, version 2.0. --------------------------------------------------------------------- http://opensource.org/licenses/BSD-2-Clause Copyright (c) 2009-2015, Emily Stark, Mike Hamburg and Dan Boneh at Stanford University. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------- http://opensource.org/licenses/GPL-2.0 The Stanford Javascript Crypto Library (hosted here on GitHub) is a project by the Stanford Computer Security Lab to build a secure, powerful, fast, small, easy-to-use, cross-browser library for cryptography in Javascript. Copyright (c) 2009-2015, Emily Stark, Mike Hamburg and Dan Boneh at Stanford University. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ "use strict";function r(t,e,r){if(4!==e.length)throw new h.exception.invalid("invalid aes block size");var n=t.b[r],i=e[0]^n[0],o=e[r?3:1]^n[1],a=e[2]^n[2];e=e[r?1:3]^n[3];var s,c,u,l,f=n.length/4-2,d=4,p=[0,0,0,0];s=t.s[r],t=s[0];var y=s[1],m=s[2],g=s[3],v=s[4];for(l=0;l>>24]^y[o>>16&255]^m[a>>8&255]^g[255&e]^n[d],c=t[o>>>24]^y[a>>16&255]^m[e>>8&255]^g[255&i]^n[d+1],u=t[a>>>24]^y[e>>16&255]^m[i>>8&255]^g[255&o]^n[d+2],e=t[e>>>24]^y[i>>16&255]^m[o>>8&255]^g[255&a]^n[d+3],d+=4,i=s,o=c,a=u;for(l=0;4>l;l++)p[r?3&-l:l]=v[i>>>24]<<24^v[o>>16&255]<<16^v[a>>8&255]<<8^v[255&e]^n[d++],s=i,i=o,o=a,a=e,e=s;return p}function n(t,e){var r,n,i,o=t.F,a=t.b,s=o[0],c=o[1],h=o[2],u=o[3],l=o[4],f=o[5],d=o[6],p=o[7];for(r=0;64>r;r++)16>r?n=e[r]:(n=e[r+1&15],i=e[r+14&15],n=e[15&r]=(n>>>7^n>>>18^n>>>3^n<<25^n<<14)+(i>>>17^i>>>19^i>>>10^i<<15^i<<13)+e[15&r]+e[r+9&15]|0),n=n+p+(l>>>6^l>>>11^l>>>25^l<<26^l<<21^l<<7)+(d^l&(f^d))+a[r],p=d,d=f,f=l,l=u+n|0,u=h,h=c,c=s,s=n+(c&h^u&(c^h))+(c>>>2^c>>>13^c>>>22^c<<30^c<<19^c<<10)|0;o[0]=o[0]+s|0,o[1]=o[1]+c|0,o[2]=o[2]+h|0,o[3]=o[3]+u|0,o[4]=o[4]+l|0,o[5]=o[5]+f|0,o[6]=o[6]+d|0,o[7]=o[7]+p|0}function i(t,e){var r,n=h.random.K[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;re&&(t.h[e]=t.h[e]+1|0,!t.h[e]);e++);return t.L.encrypt(t.h)}function c(t,e){return function(){e.apply(t,arguments)}}var h={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}}};h.cipher.aes=function(t){this.s[0][0][0]||this.O();var e,r,n,i,o=this.s[0][4],a=this.s[1];e=t.length;var s=1;if(4!==e&&6!==e&&8!==e)throw new h.exception.invalid("invalid aes key size");for(this.b=[n=t.slice(0),i=[]],t=e;t<4*e+28;t++)r=n[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^s<<24,s=s<<1^283*(s>>7))),n[t]=n[t-e]^r;for(e=0;t;e++,t--)r=n[3&e?t:t-4],i[e]=4>=t||4>e?r:a[0][o[r>>>24]]^a[1][o[r>>16&255]]^a[2][o[r>>8&255]]^a[3][o[255&r]]},h.cipher.aes.prototype={encrypt:function(t){return r(this,t,0)},decrypt:function(t){return r(this,t,1)},s:[[[],[],[],[],[]],[[],[],[],[],[]]],O:function(){var t,e,r,n,i,o,a,s=this.s[0],c=this.s[1],h=s[4],u=c[4],l=[],f=[];for(t=0;256>t;t++)f[(l[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!h[e];e^=n||1,r=f[r]||1)for(o=r^r<<1^r<<2^r<<3^r<<4,o=o>>8^255&o^99,h[e]=o,u[o]=e,i=l[t=l[n=l[e]]],a=16843009*i^65537*t^257*n^16843008*e,i=257*l[o]^16843008*o,t=0;4>t;t++)s[t][e]=i=i<<24^i>>>8,c[t][o]=a=a<<24^a>>>8;for(t=0;5>t;t++)s[t]=s[t].slice(0),c[t]=c[t].slice(0)}},h.bitArray={bitSlice:function(t,e,r){return t=h.bitArray.$(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:h.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<>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(h.bitArray.bitLength(t)!==h.bitArray.bitLength(e))return!1;var r,n=0;for(r=0;r>>e),r=t[i]<<32-e;return i=t.length?t[t.length-1]:0,t=h.bitArray.getPartial(i),n.push(h.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},h.codec.utf8String={fromBits:function(t){var e,r,n="",i=h.bitArray.bitLength(t);for(e=0;e>>8>>>8>>>8),r<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],n=0;for(e=0;e>>a)>>>i),a(n=u.indexOf(t.charAt(r)))){if(!e)try{return h.codec.base32hex.toBits(t)}catch(t){}throw new h.exception.invalid("this isn't "+f+"!")}c>a?(c-=a,s.push(l^n>>>c),l=n<>>i)>>>26),6>i?(a=t[r]<<6-i,i+=26,r++):(a<<=6,i-=6);for(;3&n.length&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,n,i=[],o=0,a=h.codec.base64.B,s=0;for(e&&(a=a.substr(0,62)+"-_"),r=0;r(n=a.indexOf(t.charAt(r))))throw new h.exception.invalid("this isn't base64!");26>>o),s=n<<32-o):(o+=6,s^=n<<32-o)}return 56&o&&i.push(h.bitArray.partial(56&o,s,1)),i}},h.codec.base64url={fromBits:function(t){return h.codec.base64.fromBits(t,1,1)},toBits:function(t){return h.codec.base64.toBits(t,1)}},h.hash.sha256=function(t){this.b[0]||this.O(),t?(this.F=t.F.slice(0),this.A=t.A.slice(0),this.l=t.l):this.reset()},h.hash.sha256.hash=function(t){return(new h.hash.sha256).update(t).finalize()},h.hash.sha256.prototype={blockSize:512,reset:function(){return this.F=this.Y.slice(0),this.A=[],this.l=0,this},update:function(t){"string"==typeof t&&(t=h.codec.utf8String.toBits(t));var e,r=this.A=h.bitArray.concat(this.A,t);if(e=this.l,9007199254740991<(t=this.l=e+h.bitArray.bitLength(t)))throw new h.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var i=new Uint32Array(r),o=0;for(e=512+e-(512+e&511);e<=t;e+=512)n(this,i.subarray(16*o,16*(o+1))),o+=1;r.splice(0,16*o)}else for(e=512+e-(512+e&511);e<=t;e+=512)n(this,r.splice(0,16));return this},finalize:function(){var t,e=this.A,r=this.F,e=h.bitArray.concat(e,[h.bitArray.partial(1,1)]);for(t=e.length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.l/4294967296)),e.push(0|this.l);e.length;)n(this,e.splice(0,16));return this.reset(),r},Y:[],b:[],O:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}for(var e,r,n=0,i=2;64>n;i++){for(r=!0,e=2;e*e<=i;e++)if(0==i%e){r=!1;break}r&&(8>n&&(this.Y[n]=t(Math.pow(i,.5))),this.b[n]=t(Math.pow(i,1/3)),n++)}}},h.mode.ccm={name:"ccm",G:[],listenProgress:function(t){h.mode.ccm.G.push(t)},unListenProgress:function(t){-1<(t=h.mode.ccm.G.indexOf(t))&&h.mode.ccm.G.splice(t,1)},fa:function(t){var e,r=h.mode.ccm.G.slice();for(e=0;ec)throw new h.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&u>>>8*o;o++);return o<15-c&&(o=15-c),r=s.clamp(r,8*(15-o)),e=h.mode.ccm.V(t,e,r,n,i,o),a=h.mode.ccm.C(t,a,r,e,i,o),s.concat(a.data,a.tag)},decrypt:function(t,e,r,n,i){i=i||64,n=n||[];var o=h.bitArray,a=o.bitLength(r)/8,s=o.bitLength(e),c=o.clamp(e,s-i),u=o.bitSlice(e,s-i),s=(s-i)/8;if(7>a)throw new h.exception.invalid("ccm: iv must be at least 7 bytes");for(e=2;4>e&&s>>>8*e;e++);if(e<15-a&&(e=15-a),r=o.clamp(r,8*(15-e)),c=h.mode.ccm.C(t,c,r,u,i,e),t=h.mode.ccm.V(t,c.data,r,n,i,e),!o.equal(c.tag,t))throw new h.exception.corrupt("ccm: tag doesn't match");return c.data},na:function(t,e,r,n,i,o){var a=[],s=h.bitArray,c=s.i;if(n=[s.partial(8,(e.length?64:0)|n-2<<2|o-1)],n=s.concat(n,r),n[3]|=i,n=t.encrypt(n),e.length)for(r=s.bitLength(e)/8,65279>=r?a=[s.partial(16,r)]:4294967295>=r&&(a=s.concat([s.partial(16,65534)],[r])),a=s.concat(a,e),e=0;ei||16l&&(h.mode.ccm.fa(a/c),l+=f),r[3]++,i=t.encrypt(r),e[a]^=i[0],e[a+1]^=i[1],e[a+2]^=i[2],e[a+3]^=i[3];return{tag:n,data:s.clamp(e,u)}}},h.mode.ocb2={name:"ocb2",encrypt:function(t,e,r,n,i,o){if(128!==h.bitArray.bitLength(r))throw new h.exception.invalid("ocb iv must be 128 bits");var a,s=h.mode.ocb2.S,c=h.bitArray,u=c.i,l=[0,0,0,0];r=s(t.encrypt(r));var f,d=[];for(n=n||[],i=i||64,a=0;a+4i.bitLength(r)&&(s=o(s,n(s)),r=i.concat(r,[-2147483648,0,0,0])),a=o(a,r),t.encrypt(o(n(o(s,n(s))),a))},S: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)]}},h.mode.gcm={name:"gcm",encrypt:function(t,e,r,n,i){var o=e.slice(0);return e=h.bitArray,n=n||[],t=h.mode.gcm.C(!0,t,o,n,r,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,n,i){var o=e.slice(0),a=h.bitArray,s=a.bitLength(o);if(i=i||128,n=n||[],i<=s?(e=a.bitSlice(o,s-i),o=a.bitSlice(o,0,s-i)):(e=o,o=[]),t=h.mode.gcm.C(!1,t,o,n,r,i),!a.equal(t.tag,e))throw new h.exception.corrupt("gcm: tag doesn't match");return t.data},ka:function(t,e){var r,n,i,o,a,s=h.bitArray.i;for(i=[0,0,0,0],o=e.slice(0),r=0;128>r;r++){for((n=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(i=s(i,o)),a=0!=(1&o[3]),n=3;0>>1|(1&o[n-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},j:function(t,e,r){var n,i=r.length;for(e=e.slice(0),n=0;ni&&(t=e.hash(t)),r=0;rn||0>r)throw new h.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=h.codec.utf8String.toBits(t)),"string"==typeof e&&(e=h.codec.utf8String.toBits(e)),i=i||h.misc.hmac,t=new i(t);var o,a,s,c,u=[],l=h.bitArray;for(c=1;32*u.length<(n||1);c++){for(i=o=t.encrypt(l.concat(e,[c])),a=1;ao;o++)i.push(4294967296*Math.random()|0);for(o=0;o=1<this.o&&(this.o=c),this.P++,this.b=h.hash.sha256.hash(this.b.concat(i)),this.L=new h.cipher.aes(this.b),r=0;4>r&&(this.h[r]=this.h[r]+1|0,!this.h[r]);r++);}for(r=0;r>>=1;this.c[s].update([n,this.N++,2,e,a,t.length].concat(t))}break;case"string":void 0===e&&(e=t.length),this.c[s].update([n,this.N++,3,e,a,t.length]),this.c[s].update(t);break;default:u=1}if(u)throw new h.exception.bug("random: addEntropy only supports number, array of numbers or string");this.m[s]+=e,this.f+=e,c===this.u&&(this.isReady()!==this.u&&i("seeded",Math.max(this.o,this.f)),i("progress",this.getProgress()))},isReady:function(t){return t=this.T[void 0!==t?t:this.M],this.o&&this.o>=t?this.m[0]>this.ba&&(new Date).valueOf()>this.Z?this.J|this.I:this.I:this.f>=t?this.J|this.u:this.u},getProgress:function(t){return t=this.T[t||this.M],this.o>=t?1:this.f>t?1:this.f/t},startCollectors:function(){if(!this.D){if(this.a={loadTimeCollector:c(this,this.ma),mouseCollector:c(this,this.oa),keyboardCollector:c(this,this.la),accelerometerCollector:c(this,this.ea),touchCollector:c(this,this.qa)},window.addEventListener)window.addEventListener("load",this.a.loadTimeCollector,!1),window.addEventListener("mousemove",this.a.mouseCollector,!1),window.addEventListener("keypress",this.a.keyboardCollector,!1),window.addEventListener("devicemotion",this.a.accelerometerCollector,!1),window.addEventListener("touchmove",this.a.touchCollector,!1);else{if(!document.attachEvent)throw new h.exception.bug("can't attach event");document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)}this.D=!0}},stopCollectors:function(){this.D&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,!1),window.removeEventListener("mousemove",this.a.mouseCollector,!1),window.removeEventListener("keypress",this.a.keyboardCollector,!1),window.removeEventListener("devicemotion",this.a.accelerometerCollector,!1),window.removeEventListener("touchmove",this.a.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.D=!1)},addEventListener:function(t,e){this.K[t][this.ga++]=e},removeEventListener:function(t,e){var r,n,i=this.K[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;r=a.iter||64!==a.ts&&96!==a.ts&&128!==a.ts||128!==a.ks&&192!==a.ks&&256!==a.ks||2>a.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