-
Notifications
You must be signed in to change notification settings - Fork 0
/
fhir-client-angularjs.min.js
3 lines (3 loc) · 80.8 KB
/
fhir-client-angularjs.min.js
1
2
3
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(a,b,c){if(!(this instanceof d))return new d(a,b,c);var e,f=typeof a;if("number"===f)e=a>0?a>>>0:0;else if("string"===f)"base64"===b&&(a=C(a)),e=d.byteLength(a,b);else{if("object"!==f||null===a)throw new Error("First argument needs to be a number, array or string.");"Buffer"===a.type&&E(a.data)&&(a=a.data),e=+a.length>0?Math.floor(+a.length):0}var g;T?g=d._augment(new Uint8Array(e)):(g=this,g.length=e,g._isBuffer=!0);var h;if(T&&"number"==typeof a.byteLength)g._set(a);else if(F(a))if(d.isBuffer(a))for(h=0;e>h;h++)g[h]=a.readUInt8(h);else for(h=0;e>h;h++)g[h]=(a[h]%256+256)%256;else if("string"===f)g.write(a,0,b);else if("number"===f&&!T&&!c)for(h=0;e>h;h++)g[h]=0;return g}function e(a,b,c,d){c=Number(c)||0;var e=a.length-c;d?(d=Number(d),d>e&&(d=e)):d=e;var f=b.length;Q(f%2===0,"Invalid hex string"),d>f/2&&(d=f/2);for(var g=0;d>g;g++){var h=parseInt(b.substr(2*g,2),16);Q(!isNaN(h),"Invalid hex string"),a[c+g]=h}return g}function f(a,b,c,d){var e=L(H(b),a,c,d);return e}function g(a,b,c,d){var e=L(I(b),a,c,d);return e}function h(a,b,c,d){return g(a,b,c,d)}function i(a,b,c,d){var e=L(K(b),a,c,d);return e}function j(a,b,c,d){var e=L(J(b),a,c,d);return e}function k(a,b,c){return 0===b&&c===a.length?R.fromByteArray(a):R.fromByteArray(a.slice(b,c))}function l(a,b,c){var d="",e="";c=Math.min(a.length,c);for(var f=b;c>f;f++)a[f]<=127?(d+=M(e)+String.fromCharCode(a[f]),e=""):e+="%"+a[f].toString(16);return d+M(e)}function m(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;c>e;e++)d+=String.fromCharCode(a[e]);return d}function n(a,b,c){return m(a,b,c)}function o(a,b,c){var d=a.length;(!b||0>b)&&(b=0),(!c||0>c||c>d)&&(c=d);for(var e="",f=b;c>f;f++)e+=G(a[f]);return e}function p(a,b,c){for(var d=a.slice(b,c),e="",f=0;f<d.length;f+=2)e+=String.fromCharCode(d[f]+256*d[f+1]);return e}function q(a,b,c,d){d||(Q("boolean"==typeof c,"missing or invalid endian"),Q(void 0!==b&&null!==b,"missing offset"),Q(b+1<a.length,"Trying to read beyond buffer length"));var e=a.length;if(!(b>=e)){var f;return c?(f=a[b],e>b+1&&(f|=a[b+1]<<8)):(f=a[b]<<8,e>b+1&&(f|=a[b+1])),f}}function r(a,b,c,d){d||(Q("boolean"==typeof c,"missing or invalid endian"),Q(void 0!==b&&null!==b,"missing offset"),Q(b+3<a.length,"Trying to read beyond buffer length"));var e=a.length;if(!(b>=e)){var f;return c?(e>b+2&&(f=a[b+2]<<16),e>b+1&&(f|=a[b+1]<<8),f|=a[b],e>b+3&&(f+=a[b+3]<<24>>>0)):(e>b+1&&(f=a[b+1]<<16),e>b+2&&(f|=a[b+2]<<8),e>b+3&&(f|=a[b+3]),f+=a[b]<<24>>>0),f}}function s(a,b,c,d){d||(Q("boolean"==typeof c,"missing or invalid endian"),Q(void 0!==b&&null!==b,"missing offset"),Q(b+1<a.length,"Trying to read beyond buffer length"));var e=a.length;if(!(b>=e)){var f=q(a,b,c,!0),g=32768&f;return g?-1*(65535-f+1):f}}function t(a,b,c,d){d||(Q("boolean"==typeof c,"missing or invalid endian"),Q(void 0!==b&&null!==b,"missing offset"),Q(b+3<a.length,"Trying to read beyond buffer length"));var e=a.length;if(!(b>=e)){var f=r(a,b,c,!0),g=2147483648&f;return g?-1*(4294967295-f+1):f}}function u(a,b,c,d){return d||(Q("boolean"==typeof c,"missing or invalid endian"),Q(b+3<a.length,"Trying to read beyond buffer length")),S.read(a,b,c,23,4)}function v(a,b,c,d){return d||(Q("boolean"==typeof c,"missing or invalid endian"),Q(b+7<a.length,"Trying to read beyond buffer length")),S.read(a,b,c,52,8)}function w(a,b,c,d,e){e||(Q(void 0!==b&&null!==b,"missing value"),Q("boolean"==typeof d,"missing or invalid endian"),Q(void 0!==c&&null!==c,"missing offset"),Q(c+1<a.length,"trying to write beyond buffer length"),N(b,65535));var f=a.length;if(!(c>=f)){for(var g=0,h=Math.min(f-c,2);h>g;g++)a[c+g]=(b&255<<8*(d?g:1-g))>>>8*(d?g:1-g);return c+2}}function x(a,b,c,d,e){e||(Q(void 0!==b&&null!==b,"missing value"),Q("boolean"==typeof d,"missing or invalid endian"),Q(void 0!==c&&null!==c,"missing offset"),Q(c+3<a.length,"trying to write beyond buffer length"),N(b,4294967295));var f=a.length;if(!(c>=f)){for(var g=0,h=Math.min(f-c,4);h>g;g++)a[c+g]=b>>>8*(d?g:3-g)&255;return c+4}}function y(a,b,c,d,e){e||(Q(void 0!==b&&null!==b,"missing value"),Q("boolean"==typeof d,"missing or invalid endian"),Q(void 0!==c&&null!==c,"missing offset"),Q(c+1<a.length,"Trying to write beyond buffer length"),O(b,32767,-32768));var f=a.length;if(!(c>=f))return b>=0?w(a,b,c,d,e):w(a,65535+b+1,c,d,e),c+2}function z(a,b,c,d,e){e||(Q(void 0!==b&&null!==b,"missing value"),Q("boolean"==typeof d,"missing or invalid endian"),Q(void 0!==c&&null!==c,"missing offset"),Q(c+3<a.length,"Trying to write beyond buffer length"),O(b,2147483647,-2147483648));var f=a.length;if(!(c>=f))return b>=0?x(a,b,c,d,e):x(a,4294967295+b+1,c,d,e),c+4}function A(a,b,c,d,e){e||(Q(void 0!==b&&null!==b,"missing value"),Q("boolean"==typeof d,"missing or invalid endian"),Q(void 0!==c&&null!==c,"missing offset"),Q(c+3<a.length,"Trying to write beyond buffer length"),P(b,3.4028234663852886e38,-3.4028234663852886e38));var f=a.length;if(!(c>=f))return S.write(a,b,c,d,23,4),c+4}function B(a,b,c,d,e){e||(Q(void 0!==b&&null!==b,"missing value"),Q("boolean"==typeof d,"missing or invalid endian"),Q(void 0!==c&&null!==c,"missing offset"),Q(c+7<a.length,"Trying to write beyond buffer length"),P(b,1.7976931348623157e308,-1.7976931348623157e308));var f=a.length;if(!(c>=f))return S.write(a,b,c,d,52,8),c+8}function C(a){for(a=D(a).replace(V,"");a.length%4!==0;)a+="=";return a}function D(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function E(a){return(Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)})(a)}function F(a){return E(a)||d.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length}function G(a){return 16>a?"0"+a.toString(16):a.toString(16)}function H(a){for(var b=[],c=0;c<a.length;c++){var d=a.charCodeAt(c);if(127>=d)b.push(d);else{var e=c;d>=55296&&57343>=d&&c++;for(var f=encodeURIComponent(a.slice(e,c+1)).substr(1).split("%"),g=0;g<f.length;g++)b.push(parseInt(f[g],16))}}return b}function I(a){for(var b=[],c=0;c<a.length;c++)b.push(255&a.charCodeAt(c));return b}function J(a){for(var b,c,d,e=[],f=0;f<a.length;f++)b=a.charCodeAt(f),c=b>>8,d=b%256,e.push(d),e.push(c);return e}function K(a){return R.toByteArray(a)}function L(a,b,c,d){for(var e=0;d>e&&!(e+c>=b.length||e>=a.length);e++)b[e+c]=a[e];return e}function M(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function N(a,b){Q("number"==typeof a,"cannot write a non-number as a number"),Q(a>=0,"specified a negative value for writing an unsigned value"),Q(b>=a,"value is larger than maximum value for type"),Q(Math.floor(a)===a,"value has a fractional component")}function O(a,b,c){Q("number"==typeof a,"cannot write a non-number as a number"),Q(b>=a,"value larger than maximum allowed value"),Q(a>=c,"value smaller than minimum allowed value"),Q(Math.floor(a)===a,"value has a fractional component")}function P(a,b,c){Q("number"==typeof a,"cannot write a non-number as a number"),Q(b>=a,"value larger than maximum allowed value"),Q(a>=c,"value smaller than minimum allowed value")}function Q(a,b){if(!a)throw new Error(b||"Failed assertion")}var R=a("base64-js"),S=a("ieee754");c.Buffer=d,c.SlowBuffer=d,c.INSPECT_MAX_BYTES=50,d.poolSize=8192;var T=function(){try{var a=new ArrayBuffer(0),b=new Uint8Array(a);return b.foo=function(){return 42},42===b.foo()&&"function"==typeof b.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(c){return!1}}();d.isEncoding=function(a){switch(String(a).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}},d.isBuffer=function(a){return!(null==a||!a._isBuffer)},d.byteLength=function(a,b){var c;switch(a=a.toString(),b||"utf8"){case"hex":c=a.length/2;break;case"utf8":case"utf-8":c=H(a).length;break;case"ascii":case"binary":case"raw":c=a.length;break;case"base64":c=K(a).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":c=2*a.length;break;default:throw new Error("Unknown encoding")}return c},d.concat=function(a,b){if(Q(E(a),"Usage: Buffer.concat(list[, length])"),0===a.length)return new d(0);if(1===a.length)return a[0];var c;if(void 0===b)for(b=0,c=0;c<a.length;c++)b+=a[c].length;var e=new d(b),f=0;for(c=0;c<a.length;c++){var g=a[c];g.copy(e,f),f+=g.length}return e},d.compare=function(a,b){Q(d.isBuffer(a)&&d.isBuffer(b),"Arguments must be Buffers");for(var c=a.length,e=b.length,f=0,g=Math.min(c,e);g>f&&a[f]===b[f];f++);return f!==g&&(c=a[f],e=b[f]),e>c?-1:c>e?1:0},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var k=d;d=b,b=c,c=k}b=Number(b)||0;var l=this.length-b;c?(c=Number(c),c>l&&(c=l)):c=l,d=String(d||"utf8").toLowerCase();var m;switch(d){case"hex":m=e(this,a,b,c);break;case"utf8":case"utf-8":m=f(this,a,b,c);break;case"ascii":m=g(this,a,b,c);break;case"binary":m=h(this,a,b,c);break;case"base64":m=i(this,a,b,c);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":m=j(this,a,b,c);break;default:throw new Error("Unknown encoding")}return m},d.prototype.toString=function(a,b,c){var d=this;if(a=String(a||"utf8").toLowerCase(),b=Number(b)||0,c=void 0===c?d.length:Number(c),c===b)return"";var e;switch(a){case"hex":e=o(d,b,c);break;case"utf8":case"utf-8":e=l(d,b,c);break;case"ascii":e=m(d,b,c);break;case"binary":e=n(d,b,c);break;case"base64":e=k(d,b,c);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":e=p(d,b,c);break;default:throw new Error("Unknown encoding")}return e},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},d.prototype.equals=function(a){return Q(d.isBuffer(a),"Argument must be a Buffer"),0===d.compare(this,a)},d.prototype.compare=function(a){return Q(d.isBuffer(a),"Argument must be a Buffer"),d.compare(this,a)},d.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||0===d||(d=this.length),b||(b=0),d!==c&&0!==a.length&&0!==e.length){Q(d>=c,"sourceEnd < sourceStart"),Q(b>=0&&b<a.length,"targetStart out of bounds"),Q(c>=0&&c<e.length,"sourceStart out of bounds"),Q(d>=0&&d<=e.length,"sourceEnd out of bounds"),d>this.length&&(d=this.length),a.length-b<d-c&&(d=a.length-b+c);var f=d-c;if(100>f||!T)for(var g=0;f>g;g++)a[g+b]=this[g+c];else a._set(this.subarray(c,c+f),b)}},d.prototype.slice=function(a,b){var c=this.length;if(a=~~a,b=void 0===b?c:~~b,0>a?(a+=c,0>a&&(a=0)):a>c&&(a=c),0>b?(b+=c,0>b&&(b=0)):b>c&&(b=c),a>b&&(b=a),T)return d._augment(this.subarray(a,b));for(var e=b-a,f=new d(e,void 0,!0),g=0;e>g;g++)f[g]=this[g+a];return f},d.prototype.get=function(a){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(a)},d.prototype.set=function(a,b){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(a,b)},d.prototype.readUInt8=function(a,b){return b||(Q(void 0!==a&&null!==a,"missing offset"),Q(a<this.length,"Trying to read beyond buffer length")),a>=this.length?void 0:this[a]},d.prototype.readUInt16LE=function(a,b){return q(this,a,!0,b)},d.prototype.readUInt16BE=function(a,b){return q(this,a,!1,b)},d.prototype.readUInt32LE=function(a,b){return r(this,a,!0,b)},d.prototype.readUInt32BE=function(a,b){return r(this,a,!1,b)},d.prototype.readInt8=function(a,b){if(b||(Q(void 0!==a&&null!==a,"missing offset"),Q(a<this.length,"Trying to read beyond buffer length")),!(a>=this.length)){var c=128&this[a];return c?-1*(255-this[a]+1):this[a]}},d.prototype.readInt16LE=function(a,b){return s(this,a,!0,b)},d.prototype.readInt16BE=function(a,b){return s(this,a,!1,b)},d.prototype.readInt32LE=function(a,b){return t(this,a,!0,b)},d.prototype.readInt32BE=function(a,b){return t(this,a,!1,b)},d.prototype.readFloatLE=function(a,b){return u(this,a,!0,b)},d.prototype.readFloatBE=function(a,b){return u(this,a,!1,b)},d.prototype.readDoubleLE=function(a,b){return v(this,a,!0,b)},d.prototype.readDoubleBE=function(a,b){return v(this,a,!1,b)},d.prototype.writeUInt8=function(a,b,c){return c||(Q(void 0!==a&&null!==a,"missing value"),Q(void 0!==b&&null!==b,"missing offset"),Q(b<this.length,"trying to write beyond buffer length"),N(a,255)),b>=this.length?void 0:(this[b]=a,b+1)},d.prototype.writeUInt16LE=function(a,b,c){return w(this,a,b,!0,c)},d.prototype.writeUInt16BE=function(a,b,c){return w(this,a,b,!1,c)},d.prototype.writeUInt32LE=function(a,b,c){return x(this,a,b,!0,c)},d.prototype.writeUInt32BE=function(a,b,c){return x(this,a,b,!1,c)},d.prototype.writeInt8=function(a,b,c){return c||(Q(void 0!==a&&null!==a,"missing value"),Q(void 0!==b&&null!==b,"missing offset"),Q(b<this.length,"Trying to write beyond buffer length"),O(a,127,-128)),b>=this.length?void 0:(a>=0?this.writeUInt8(a,b,c):this.writeUInt8(255+a+1,b,c),b+1)},d.prototype.writeInt16LE=function(a,b,c){return y(this,a,b,!0,c)},d.prototype.writeInt16BE=function(a,b,c){return y(this,a,b,!1,c)},d.prototype.writeInt32LE=function(a,b,c){return z(this,a,b,!0,c)},d.prototype.writeInt32BE=function(a,b,c){return z(this,a,b,!1,c)},d.prototype.writeFloatLE=function(a,b,c){return A(this,a,b,!0,c)},d.prototype.writeFloatBE=function(a,b,c){return A(this,a,b,!1,c)},d.prototype.writeDoubleLE=function(a,b,c){return B(this,a,b,!0,c)},d.prototype.writeDoubleBE=function(a,b,c){return B(this,a,b,!1,c)},d.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),Q(c>=b,"end < start"),c!==b&&0!==this.length){Q(b>=0&&b<this.length,"start out of bounds"),Q(c>=0&&c<=this.length,"end out of bounds");var d;if("number"==typeof a)for(d=b;c>d;d++)this[d]=a;else{var e=H(a.toString()),f=e.length;for(d=b;c>d;d++)this[d]=e[d%f]}return this}},d.prototype.inspect=function(){for(var a=[],b=this.length,d=0;b>d;d++)if(a[d]=G(this[d]),d===c.INSPECT_MAX_BYTES){a[d+1]="...";break}return"<Buffer "+a.join(" ")+">"},d.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(T)return new d(this).buffer;for(var a=new Uint8Array(this.length),b=0,c=a.length;c>b;b+=1)a[b]=this[b];return a.buffer}throw new Error("Buffer.toArrayBuffer not supported in this browser")};var U=d.prototype;d._augment=function(a){return a._isBuffer=!0,a._get=a.get,a._set=a.set,a.get=U.get,a.set=U.set,a.write=U.write,a.toString=U.toString,a.toLocaleString=U.toString,a.toJSON=U.toJSON,a.equals=U.equals,a.compare=U.compare,a.copy=U.copy,a.slice=U.slice,a.readUInt8=U.readUInt8,a.readUInt16LE=U.readUInt16LE,a.readUInt16BE=U.readUInt16BE,a.readUInt32LE=U.readUInt32LE,a.readUInt32BE=U.readUInt32BE,a.readInt8=U.readInt8,a.readInt16LE=U.readInt16LE,a.readInt16BE=U.readInt16BE,a.readInt32LE=U.readInt32LE,a.readInt32BE=U.readInt32BE,a.readFloatLE=U.readFloatLE,a.readFloatBE=U.readFloatBE,a.readDoubleLE=U.readDoubleLE,a.readDoubleBE=U.readDoubleBE,a.writeUInt8=U.writeUInt8,a.writeUInt16LE=U.writeUInt16LE,a.writeUInt16BE=U.writeUInt16BE,a.writeUInt32LE=U.writeUInt32LE,a.writeUInt32BE=U.writeUInt32BE,a.writeInt8=U.writeInt8,a.writeInt16LE=U.writeInt16LE,a.writeInt16BE=U.writeInt16BE,a.writeInt32LE=U.writeInt32LE,a.writeInt32BE=U.writeInt32BE,a.writeFloatLE=U.writeFloatLE,a.writeFloatBE=U.writeFloatBE,a.writeDoubleLE=U.writeDoubleLE,a.writeDoubleBE=U.writeDoubleBE,a.fill=U.fill,a.inspect=U.inspect,a.toArrayBuffer=U.toArrayBuffer,a};var V=/[^+\/0-9A-z]/g},{"base64-js":2,ieee754:3}],2:[function(a,b,c){var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(a){"use strict";function b(a){var b=a.charCodeAt(0);return b===g?62:b===h?63:i>b?-1:i+10>b?b-i+26+26:k+26>b?b-k:j+26>b?b-j+26:void 0}function c(a){function c(a){j[l++]=a}var d,e,g,h,i,j;if(a.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=a.length;i="="===a.charAt(k-2)?2:"="===a.charAt(k-1)?1:0,j=new f(3*a.length/4-i),g=i>0?a.length-4:a.length;var l=0;for(d=0,e=0;g>d;d+=4,e+=3)h=b(a.charAt(d))<<18|b(a.charAt(d+1))<<12|b(a.charAt(d+2))<<6|b(a.charAt(d+3)),c((16711680&h)>>16),c((65280&h)>>8),c(255&h);return 2===i?(h=b(a.charAt(d))<<2|b(a.charAt(d+1))>>4,c(255&h)):1===i&&(h=b(a.charAt(d))<<10|b(a.charAt(d+1))<<4|b(a.charAt(d+2))>>2,c(h>>8&255),c(255&h)),j}function e(a){function b(a){return d.charAt(a)}function c(a){return b(a>>18&63)+b(a>>12&63)+b(a>>6&63)+b(63&a)}var e,f,g,h=a.length%3,i="";for(e=0,g=a.length-h;g>e;e+=3)f=(a[e]<<16)+(a[e+1]<<8)+a[e+2],i+=c(f);switch(h){case 1:f=a[a.length-1],i+=b(f>>2),i+=b(f<<4&63),i+="==";break;case 2:f=(a[a.length-2]<<8)+a[a.length-1],i+=b(f>>10),i+=b(f>>4&63),i+=b(f<<2&63),i+="="}return i}var f="undefined"!=typeof Uint8Array?Uint8Array:Array,g="+".charCodeAt(0),h="/".charCodeAt(0),i="0".charCodeAt(0),j="a".charCodeAt(0),k="A".charCodeAt(0);a.toByteArray=c,a.fromByteArray=e}("undefined"==typeof c?this.base64js={}:c)},{}],3:[function(a,b,c){c.read=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<<h)-1,j=i>>1,k=-7,l=c?e-1:0,m=c?-1:1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?NaN:(n?-1:1)*(1/0);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.write=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<<j)-1,l=k>>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?0:f-1,o=d?1:-1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||b===1/0?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<<e|h,j+=e;j>0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],4:[function(a,b,c){(function(c){function d(a){return function(){var b=[],d={update:function(a,d){return c.isBuffer(a)||(a=new c(a,d)),b.push(a),this},digest:function(d){var e=c.concat(b),f=a(e);return b=null,d?f.toString(d):f}};return d}}var e=a("sha.js"),f=d(a("./md5")),g=d(a("ripemd160"));b.exports=function(a){return"md5"===a?new f:"rmd160"===a?new g:e(a)}}).call(this,a("buffer").Buffer)},{"./md5":8,buffer:1,ripemd160:9,"sha.js":11}],5:[function(a,b,c){(function(c){function d(a,b){if(!(this instanceof d))return new d(a,b);this._opad=i,this._alg=a,b=this._key=c.isBuffer(b)?b:new c(b),b.length>f?b=e(a).update(b).digest():b.length<f&&(b=c.concat([b,g],f));for(var h=this._ipad=new c(f),i=this._opad=new c(f),j=0;f>j;j++)h[j]=54^b[j],i[j]=92^b[j];this._hash=e(a).update(h)}var e=a("./create-hash"),f=64,g=new c(f);g.fill(0),b.exports=d,d.prototype.update=function(a,b){return this._hash.update(a,b),this},d.prototype.digest=function(a){var b=this._hash.digest();return e(this._alg).update(this._opad).update(b).digest(a)}}).call(this,a("buffer").Buffer)},{"./create-hash":4,buffer:1}],6:[function(a,b,c){(function(a){function c(b,c){if(b.length%f!==0){var d=b.length+(f-b.length%f);b=a.concat([b,g],d)}for(var e=[],h=c?b.readInt32BE:b.readInt32LE,i=0;i<b.length;i+=f)e.push(h.call(b,i));return e}function d(b,c,d){for(var e=new a(c),f=d?e.writeInt32BE:e.writeInt32LE,g=0;g<b.length;g++)f.call(e,b[g],4*g,!0);return e}function e(b,e,f,g){a.isBuffer(b)||(b=new a(b));var i=e(c(b,g),b.length*h);return d(i,f,g)}var f=4,g=new a(f);g.fill(0);var h=8;b.exports={hash:e}}).call(this,a("buffer").Buffer)},{buffer:1}],7:[function(a,b,c){(function(b){function d(){var a=[].slice.call(arguments).join(" ");throw new Error([a,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}function e(a,b){for(var c in a)b(a[c],c)}var f=a("./rng");c.createHash=a("./create-hash"),c.createHmac=a("./create-hmac"),c.randomBytes=function(a,c){if(!c||!c.call)return new b(f(a));try{c.call(this,void 0,new b(f(a)))}catch(d){c(d)}},c.getHashes=function(){return["sha1","sha256","md5","rmd160"]};var g=a("./pbkdf2")(c.createHmac);c.pbkdf2=g.pbkdf2,c.pbkdf2Sync=g.pbkdf2Sync,e(["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman"],function(a){c[a]=function(){d("sorry,",a,"is not implemented yet")}})}).call(this,a("buffer").Buffer)},{"./create-hash":4,"./create-hmac":5,"./pbkdf2":15,"./rng":16,buffer:1}],8:[function(a,b,c){function d(a,b){a[b>>5]|=128<<b%32,a[(b+64>>>9<<4)+14]=b;for(var c=1732584193,d=-271733879,e=-1732584194,k=271733878,l=0;l<a.length;l+=16){var m=c,n=d,o=e,p=k;c=f(c,d,e,k,a[l+0],7,-680876936),k=f(k,c,d,e,a[l+1],12,-389564586),e=f(e,k,c,d,a[l+2],17,606105819),d=f(d,e,k,c,a[l+3],22,-1044525330),c=f(c,d,e,k,a[l+4],7,-176418897),k=f(k,c,d,e,a[l+5],12,1200080426),e=f(e,k,c,d,a[l+6],17,-1473231341),d=f(d,e,k,c,a[l+7],22,-45705983),c=f(c,d,e,k,a[l+8],7,1770035416),k=f(k,c,d,e,a[l+9],12,-1958414417),e=f(e,k,c,d,a[l+10],17,-42063),d=f(d,e,k,c,a[l+11],22,-1990404162),c=f(c,d,e,k,a[l+12],7,1804603682),k=f(k,c,d,e,a[l+13],12,-40341101),e=f(e,k,c,d,a[l+14],17,-1502002290),d=f(d,e,k,c,a[l+15],22,1236535329),c=g(c,d,e,k,a[l+1],5,-165796510),k=g(k,c,d,e,a[l+6],9,-1069501632),e=g(e,k,c,d,a[l+11],14,643717713),d=g(d,e,k,c,a[l+0],20,-373897302),c=g(c,d,e,k,a[l+5],5,-701558691),k=g(k,c,d,e,a[l+10],9,38016083),e=g(e,k,c,d,a[l+15],14,-660478335),d=g(d,e,k,c,a[l+4],20,-405537848),c=g(c,d,e,k,a[l+9],5,568446438),k=g(k,c,d,e,a[l+14],9,-1019803690),e=g(e,k,c,d,a[l+3],14,-187363961),d=g(d,e,k,c,a[l+8],20,1163531501),c=g(c,d,e,k,a[l+13],5,-1444681467),k=g(k,c,d,e,a[l+2],9,-51403784),e=g(e,k,c,d,a[l+7],14,1735328473),d=g(d,e,k,c,a[l+12],20,-1926607734),c=h(c,d,e,k,a[l+5],4,-378558),k=h(k,c,d,e,a[l+8],11,-2022574463),e=h(e,k,c,d,a[l+11],16,1839030562),d=h(d,e,k,c,a[l+14],23,-35309556),c=h(c,d,e,k,a[l+1],4,-1530992060),k=h(k,c,d,e,a[l+4],11,1272893353),e=h(e,k,c,d,a[l+7],16,-155497632),d=h(d,e,k,c,a[l+10],23,-1094730640),c=h(c,d,e,k,a[l+13],4,681279174),k=h(k,c,d,e,a[l+0],11,-358537222),e=h(e,k,c,d,a[l+3],16,-722521979),d=h(d,e,k,c,a[l+6],23,76029189),c=h(c,d,e,k,a[l+9],4,-640364487),k=h(k,c,d,e,a[l+12],11,-421815835),e=h(e,k,c,d,a[l+15],16,530742520),d=h(d,e,k,c,a[l+2],23,-995338651),c=i(c,d,e,k,a[l+0],6,-198630844),k=i(k,c,d,e,a[l+7],10,1126891415),e=i(e,k,c,d,a[l+14],15,-1416354905),d=i(d,e,k,c,a[l+5],21,-57434055),c=i(c,d,e,k,a[l+12],6,1700485571),k=i(k,c,d,e,a[l+3],10,-1894986606),e=i(e,k,c,d,a[l+10],15,-1051523),d=i(d,e,k,c,a[l+1],21,-2054922799),c=i(c,d,e,k,a[l+8],6,1873313359),k=i(k,c,d,e,a[l+15],10,-30611744),e=i(e,k,c,d,a[l+6],15,-1560198380),d=i(d,e,k,c,a[l+13],21,1309151649),c=i(c,d,e,k,a[l+4],6,-145523070),k=i(k,c,d,e,a[l+11],10,-1120210379),e=i(e,k,c,d,a[l+2],15,718787259),d=i(d,e,k,c,a[l+9],21,-343485551),c=j(c,m),d=j(d,n),e=j(e,o),k=j(k,p)}return Array(c,d,e,k)}function e(a,b,c,d,e,f){return j(k(j(j(b,a),j(d,f)),e),c)}function f(a,b,c,d,f,g,h){return e(b&c|~b&d,a,b,f,g,h)}function g(a,b,c,d,f,g,h){return e(b&d|c&~d,a,b,f,g,h)}function h(a,b,c,d,f,g,h){return e(b^c^d,a,b,f,g,h)}function i(a,b,c,d,f,g,h){return e(c^(b|~d),a,b,f,g,h)}function j(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c}function k(a,b){return a<<b|a>>>32-b}var l=a("./helpers");b.exports=function(a){return l.hash(a,d,16)}},{"./helpers":6}],9:[function(a,b,c){(function(a){function c(a,b,c){return a^b^c}function d(a,b,c){return a&b|~a&c}function e(a,b,c){return(a|~b)^c}function f(a,b,c){return a&c|b&~c}function g(a,b,c){return a^(b|~c)}function h(a,b){return a<<b|a>>>32-b}function i(b){var c=[1732584193,4023233417,2562383102,271733878,3285377520];"string"==typeof b&&(b=new a(b,"utf8"));var d=p(b),e=8*b.length,f=8*b.length;d[e>>>5]|=128<<24-e%32,d[(e+64>>>9<<4)+14]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8);for(var g=0;g<d.length;g+=16)r(c,d,g);for(var g=0;5>g;g++){var h=c[g];c[g]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}var i=q(c);return new a(i)}b.exports=i;var j=[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],k=[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],l=[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],m=[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],n=[0,1518500249,1859775393,2400959708,2840853838],o=[1352829926,1548603684,1836072691,2053994217,0],p=function(a){for(var b=[],c=0,d=0;c<a.length;c++,d+=8)b[d>>>5]|=a[c]<<24-d%32;return b},q=function(a){for(var b=[],c=0;c<32*a.length;c+=8)b.push(a[c>>>5]>>>24-c%32&255);return b},r=function(a,b,i){for(var p=0;16>p;p++){var q=i+p,r=b[q];b[q]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var s,t,u,v,w,x,y,z,A,B;x=s=a[0],y=t=a[1],z=u=a[2],A=v=a[3],B=w=a[4];for(var C,p=0;80>p;p+=1)C=s+b[i+j[p]]|0,C+=16>p?c(t,u,v)+n[0]:32>p?d(t,u,v)+n[1]:48>p?e(t,u,v)+n[2]:64>p?f(t,u,v)+n[3]:g(t,u,v)+n[4],C=0|C,C=h(C,l[p]),C=C+w|0,s=w,w=v,v=h(u,10),u=t,t=C,C=x+b[i+k[p]]|0,C+=16>p?g(y,z,A)+o[0]:32>p?f(y,z,A)+o[1]:48>p?e(y,z,A)+o[2]:64>p?d(y,z,A)+o[3]:c(y,z,A)+o[4],C=0|C,C=h(C,m[p]),C=C+B|0,x=B,B=A,A=h(z,10),z=y,y=C;C=a[1]+u+A|0,a[1]=a[2]+v+B|0,a[2]=a[3]+w+x|0,a[3]=a[4]+s+y|0,a[4]=a[0]+t+z|0,a[0]=C}}).call(this,a("buffer").Buffer)},{buffer:1}],10:[function(a,b,c){var d=a("./util"),e=d.write,f=d.zeroFill;b.exports=function(a){function b(b,c){this._block=new a(b),this._finalSize=c,this._blockSize=b,this._len=0,this._s=0}function c(a,b){return null==b?a.byteLength||a.length:"ascii"==b||"binary"==b?a.length:"hex"==b?a.length/2:"base64"==b?a.length/3:void 0}return b.prototype.init=function(){this._s=0,this._len=0},b.prototype.update=function(b,d){var f,g=this._blockSize;d||"string"!=typeof b||(d="utf8"),d?("utf-8"===d&&(d="utf8"),("base64"===d||"utf8"===d)&&(b=new a(b,d),d=null),f=c(b,d)):f=b.byteLength||b.length;for(var h=this._len+=f,i=this._s=this._s||0,j=0,k=this._block;h>i;){var l=Math.min(f,j+g-i%g);e(k,b,d,i%g,j,l);var m=l-j;i+=m,j+=m,i%g||this._update(k)}return this._s=i,this},b.prototype.digest=function(a){var b=this._blockSize,c=this._finalSize,e=8*this._len,g=this._block,h=e%(8*b);g[this._len%b]=128,f(this._block,this._len%b+1),h>=8*c&&(this._update(this._block),d.zeroFill(this._block,0)),g.writeInt32BE(e,c+4);var i=this._update(this._block)||this._hash();return null==a?i:i.toString(a)},b.prototype._update=function(){throw new Error("_update must be implemented by subclass")},b}},{"./util":14}],11:[function(a,b,c){var c=b.exports=function(a){var b=c[a];if(!b)throw new Error(a+" is not supported (we accept pull requests)");return new b},d=a("buffer").Buffer,e=a("./hash")(d);c.sha=c.sha1=a("./sha1")(d,e),c.sha256=a("./sha256")(d,e)},{"./hash":10,"./sha1":12,"./sha256":13,buffer:1}],12:[function(a,b,c){b.exports=function(b,c){function d(){return p.length?p.pop().init():this instanceof d?(this._w=o,c.call(this,64,56),this._h=null,void this.init()):new d}function e(a,b,c,d){return 20>a?b&c|~b&d:40>a?b^c^d:60>a?b&c|b&d|c&d:b^c^d}function f(a){return 20>a?1518500249:40>a?1859775393:60>a?-1894007588:-899497514}function g(a,b){return a+b|0}function h(a,b){return a<<b|a>>>32-b}var i=a("util").inherits;i(d,c);var j=0,k=4,l=8,m=12,n=16,o=new Int32Array(80),p=[];d.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,c.prototype.init.call(this),this},d.prototype._POOL=p;new b(1)instanceof DataView;return d.prototype._update=function(a){var b,c,d,i,j,k,l,m,n,o,p=this._block;this._h;b=k=this._a,c=l=this._b,d=m=this._c,i=n=this._d,j=o=this._e;for(var q=this._w,r=0;80>r;r++){var s=q[r]=16>r?p.readInt32BE(4*r):h(q[r-3]^q[r-8]^q[r-14]^q[r-16],1),t=g(g(h(b,5),e(r,c,d,i)),g(g(j,s),f(r)));j=i,i=d,d=h(c,30),c=b,b=t}this._a=g(b,k),this._b=g(c,l),this._c=g(d,m),this._d=g(i,n),this._e=g(j,o)},d.prototype._hash=function(){p.length<100&&p.push(this);var a=new b(20);return a.writeInt32BE(0|this._a,j),a.writeInt32BE(0|this._b,k),a.writeInt32BE(0|this._c,l),a.writeInt32BE(0|this._d,m),a.writeInt32BE(0|this._e,n),a},d}},{util:35}],13:[function(a,b,c){var d=a("util").inherits;a("./util");b.exports=function(a,b){function c(){o.length,this.init(),this._w=n,b.call(this,64,56)}function e(a,b){return a>>>b|a<<32-b}function f(a,b){return a>>>b}function g(a,b,c){return a&b^~a&c}function h(a,b,c){return a&b^a&c^b&c}function i(a){return e(a,2)^e(a,13)^e(a,22)}function j(a){return e(a,6)^e(a,11)^e(a,25)}function k(a){return e(a,7)^e(a,18)^f(a,3)}function l(a){return e(a,17)^e(a,19)^f(a,10)}var m=[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];d(c,b);var n=new Array(64),o=[];c.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};return c.prototype._update=function(a){var b,c,d,e,f,n,o,p,q,r,s=this._block,t=this._w;b=0|this._a,c=0|this._b,d=0|this._c,e=0|this._d,f=0|this._e,n=0|this._f,o=0|this._g,p=0|this._h;for(var u=0;64>u;u++){var v=t[u]=16>u?s.readInt32BE(4*u):l(t[u-2])+t[u-7]+k(t[u-15])+t[u-16];q=p+j(f)+g(f,n,o)+m[u]+v,r=i(b)+h(b,c,d),p=o,o=n,n=f,f=e+q,e=d,d=c,c=b,b=q+r}this._a=b+this._a|0,this._b=c+this._b|0,this._c=d+this._c|0,this._d=e+this._d|0,this._e=f+this._e|0,this._f=n+this._f|0,this._g=o+this._g|0,this._h=p+this._h|0},c.prototype._hash=function(){o.length<10&&o.push(this);var b=new a(32);return b.writeInt32BE(this._a,0),b.writeInt32BE(this._b,4),b.writeInt32BE(this._c,8),b.writeInt32BE(this._d,12),b.writeInt32BE(this._e,16),b.writeInt32BE(this._f,20),b.writeInt32BE(this._g,24),b.writeInt32BE(this._h,28),b},c}},{"./util":14,util:35}],14:[function(a,b,c){function d(a,b,c,d,e,f,g){var h=f-e;if("ascii"===c||"binary"===c)for(var i=0;h>i;i++)a[d+i]=b.charCodeAt(i+e);else if(null==c)for(var i=0;h>i;i++)a[d+i]=b[i+e];else{if("hex"!==c)throw"base64"===c?new Error("base64 encoding not yet supported"):new Error(c+" encoding not yet supported");for(var i=0;h>i;i++){var j=e+i;a[d+i]=parseInt(b[2*j]+b[2*j+1],16)}}}function e(a,b){for(var c=b;c<a.length;c++)a[c]=0}c.write=d,c.zeroFill=e,c.toString=toString},{}],15:[function(a,b,c){(function(a){var c=64,d=new a(c);d.fill(0),b.exports=function(b,e){return e=e||{},e.pbkdf2=function(a,b,c,d,f){if("function"!=typeof f)throw new Error("No callback provided to pbkdf2");setTimeout(function(){f(null,e.pbkdf2Sync(a,b,c,d))})},e.pbkdf2Sync=function(e,f,g,h){if("number"!=typeof g)throw new TypeError("Iterations not a number");if(0>g)throw new TypeError("Bad iterations");if("number"!=typeof h)throw new TypeError("Key length not a number");if(0>h)throw new TypeError("Bad key length");var e=a.isBuffer(e)?e:new a(e);e.length>c?e=createHash(alg).update(e).digest():e.length<c&&(e=a.concat([e,d],c));var i,j,k,l=0,m=1,n=new a(4),o=new a(h);for(o.fill(0);h;){j=h>20?20:h,n[0]=m>>24&255,n[1]=m>>16&255,n[2]=m>>8&255,n[3]=255&m,i=b("sha1",e),i.update(f),i.update(n),k=i.digest(),
k.copy(o,l,0,j);for(var p=1;g>p;p++){i=b("sha1",e),i.update(k),k=i.digest();for(var q=0;j>q;q++)o[q]^=k[q]}h-=j,m++,l+=j}return o},e}}).call(this,a("buffer").Buffer)},{buffer:1}],16:[function(a,b,c){(function(a){!function(){b.exports=function(b){var c=new a(b);return crypto.getRandomValues(c),c}}()}).call(this,a("buffer").Buffer)},{buffer:1}],17:[function(a,b,c){function d(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function e(a){return"function"==typeof a}function f(a){return"number"==typeof a}function g(a){return"object"==typeof a&&null!==a}function h(a){return void 0===a}b.exports=d,d.EventEmitter=d,d.prototype._events=void 0,d.prototype._maxListeners=void 0,d.defaultMaxListeners=10,d.prototype.setMaxListeners=function(a){if(!f(a)||0>a||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},d.prototype.emit=function(a){var b,c,d,f,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||g(this._events.error)&&!this._events.error.length))throw b=arguments[1],b instanceof Error?b:TypeError('Uncaught, unspecified "error" event.');if(c=this._events[a],h(c))return!1;if(e(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(d=arguments.length,f=new Array(d-1),i=1;d>i;i++)f[i-1]=arguments[i];c.apply(this,f)}else if(g(c)){for(d=arguments.length,f=new Array(d-1),i=1;d>i;i++)f[i-1]=arguments[i];for(j=c.slice(),d=j.length,i=0;d>i;i++)j[i].apply(this,f)}return!0},d.prototype.addListener=function(a,b){var c;if(!e(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,e(b.listener)?b.listener:b),this._events[a]?g(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,g(this._events[a])&&!this._events[a].warned){var c;c=h(this._maxListeners)?d.defaultMaxListeners:this._maxListeners,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace())}return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){function c(){this.removeListener(a,c),d||(d=!0,b.apply(this,arguments))}if(!e(b))throw TypeError("listener must be a function");var d=!1;return c.listener=b,this.on(a,c),this},d.prototype.removeListener=function(a,b){var c,d,f,h;if(!e(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],f=c.length,d=-1,c===b||e(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(g(c)){for(h=f;h-- >0;)if(c[h]===b||c[h].listener&&c[h].listener===b){d=h;break}if(0>d)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(d,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},d.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],e(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},d.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?e(this._events[a])?[this._events[a]]:this._events[a].slice():[]},d.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?e(a._events[b])?1:a._events[b].length:0}},{}],18:[function(a,b,c){"function"==typeof Object.create?b.exports=function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:b.exports=function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],19:[function(a,b,c){b.exports=Array.isArray||function(a){return"[object Array]"==Object.prototype.toString.call(a)}},{}],20:[function(a,b,c){function d(){}var e=b.exports={};e.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),e.title="browser",e.browser=!0,e.env={},e.argv=[],e.on=d,e.addListener=d,e.once=d,e.off=d,e.removeListener=d,e.removeAllListeners=d,e.emit=d,e.binding=function(a){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(a){throw new Error("process.chdir is not supported")}},{}],21:[function(a,b,c){b.exports=a("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":22}],22:[function(a,b,c){(function(c){function d(a){return this instanceof d?(i.call(this,a),j.call(this,a),a&&a.readable===!1&&(this.readable=!1),a&&a.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,a&&a.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",e)):new d(a)}function e(){this.allowHalfOpen||this._writableState.ended||c.nextTick(this.end.bind(this))}function f(a,b){for(var c=0,d=a.length;d>c;c++)b(a[c],c)}b.exports=d;var g=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},h=a("core-util-is");h.inherits=a("inherits");var i=a("./_stream_readable"),j=a("./_stream_writable");h.inherits(d,i),f(g(j.prototype),function(a){d.prototype[a]||(d.prototype[a]=j.prototype[a])})}).call(this,a("_process"))},{"./_stream_readable":24,"./_stream_writable":26,_process:20,"core-util-is":27,inherits:18}],23:[function(a,b,c){function d(a){return this instanceof d?void e.call(this,a):new d(a)}b.exports=d;var e=a("./_stream_transform"),f=a("core-util-is");f.inherits=a("inherits"),f.inherits(d,e),d.prototype._transform=function(a,b,c){c(null,a)}},{"./_stream_transform":25,"core-util-is":27,inherits:18}],24:[function(a,b,c){(function(c){function d(b,c){b=b||{};var d=b.highWaterMark;this.highWaterMark=d||0===d?d:16384,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=!1,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.calledRead=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!b.objectMode,this.defaultEncoding=b.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,b.encoding&&(C||(C=a("string_decoder/").StringDecoder),this.decoder=new C(b.encoding),this.encoding=b.encoding)}function e(a){return this instanceof e?(this._readableState=new d(a,this),this.readable=!0,void A.call(this)):new e(a)}function f(a,b,c,d,e){var f=j(b,c);if(f)a.emit("error",f);else if(null===c||void 0===c)b.reading=!1,b.ended||k(a,b);else if(b.objectMode||c&&c.length>0)if(b.ended&&!e){var h=new Error("stream.push() after EOF");a.emit("error",h)}else if(b.endEmitted&&e){var h=new Error("stream.unshift() after end event");a.emit("error",h)}else!b.decoder||e||d||(c=b.decoder.write(c)),b.length+=b.objectMode?1:c.length,e?b.buffer.unshift(c):(b.reading=!1,b.buffer.push(c)),b.needReadable&&l(a),n(a,b);else e||(b.reading=!1);return g(b)}function g(a){return!a.ended&&(a.needReadable||a.length<a.highWaterMark||0===a.length)}function h(a){if(a>=D)a=D;else{a--;for(var b=1;32>b;b<<=1)a|=a>>b;a++}return a}function i(a,b){return 0===b.length&&b.ended?0:b.objectMode?0===a?0:1:null===a||isNaN(a)?b.flowing&&b.buffer.length?b.buffer[0].length:b.length:0>=a?0:(a>b.highWaterMark&&(b.highWaterMark=h(a)),a>b.length?b.ended?b.length:(b.needReadable=!0,0):a)}function j(a,b){var c=null;return y.isBuffer(b)||"string"==typeof b||null===b||void 0===b||a.objectMode||(c=new TypeError("Invalid non-string/buffer chunk")),c}function k(a,b){if(b.decoder&&!b.ended){var c=b.decoder.end();c&&c.length&&(b.buffer.push(c),b.length+=b.objectMode?1:c.length)}b.ended=!0,b.length>0?l(a):u(a)}function l(a){var b=a._readableState;b.needReadable=!1,b.emittedReadable||(b.emittedReadable=!0,b.sync?c.nextTick(function(){m(a)}):m(a))}function m(a){a.emit("readable")}function n(a,b){b.readingMore||(b.readingMore=!0,c.nextTick(function(){o(a,b)}))}function o(a,b){for(var c=b.length;!b.reading&&!b.flowing&&!b.ended&&b.length<b.highWaterMark&&(a.read(0),c!==b.length);)c=b.length;b.readingMore=!1}function p(a){return function(){var b=a._readableState;b.awaitDrain--,0===b.awaitDrain&&q(a)}}function q(a){function b(a,b,e){var f=a.write(c);!1===f&&d.awaitDrain++}var c,d=a._readableState;for(d.awaitDrain=0;d.pipesCount&&null!==(c=a.read());)if(1===d.pipesCount?b(d.pipes,0,null):v(d.pipes,b),a.emit("data",c),d.awaitDrain>0)return;return 0===d.pipesCount?(d.flowing=!1,void(z.listenerCount(a,"data")>0&&s(a))):void(d.ranOut=!0)}function r(){this._readableState.ranOut&&(this._readableState.ranOut=!1,q(this))}function s(a,b){var d=a._readableState;if(d.flowing)throw new Error("Cannot switch to old mode now.");var e=b||!1,f=!1;a.readable=!0,a.pipe=A.prototype.pipe,a.on=a.addListener=A.prototype.on,a.on("readable",function(){f=!0;for(var b;!e&&null!==(b=a.read());)a.emit("data",b);null===b&&(f=!1,a._readableState.needReadable=!0)}),a.pause=function(){e=!0,this.emit("pause")},a.resume=function(){e=!1,f?c.nextTick(function(){a.emit("readable")}):this.read(0),this.emit("resume")},a.emit("readable")}function t(a,b){var c,d=b.buffer,e=b.length,f=!!b.decoder,g=!!b.objectMode;if(0===d.length)return null;if(0===e)c=null;else if(g)c=d.shift();else if(!a||a>=e)c=f?d.join(""):y.concat(d,e),d.length=0;else if(a<d[0].length){var h=d[0];c=h.slice(0,a),d[0]=h.slice(a)}else if(a===d[0].length)c=d.shift();else{c=f?"":new y(a);for(var i=0,j=0,k=d.length;k>j&&a>i;j++){var h=d[0],l=Math.min(a-i,h.length);f?c+=h.slice(0,l):h.copy(c,i,0,l),l<h.length?d[0]=h.slice(l):d.shift(),i+=l}}return c}function u(a){var b=a._readableState;if(b.length>0)throw new Error("endReadable called on non-empty stream");!b.endEmitted&&b.calledRead&&(b.ended=!0,c.nextTick(function(){b.endEmitted||0!==b.length||(b.endEmitted=!0,a.readable=!1,a.emit("end"))}))}function v(a,b){for(var c=0,d=a.length;d>c;c++)b(a[c],c)}function w(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}b.exports=e;var x=a("isarray"),y=a("buffer").Buffer;e.ReadableState=d;var z=a("events").EventEmitter;z.listenerCount||(z.listenerCount=function(a,b){return a.listeners(b).length});var A=a("stream"),B=a("core-util-is");B.inherits=a("inherits");var C;B.inherits(e,A),e.prototype.push=function(a,b){var c=this._readableState;return"string"!=typeof a||c.objectMode||(b=b||c.defaultEncoding,b!==c.encoding&&(a=new y(a,b),b="")),f(this,c,a,b,!1)},e.prototype.unshift=function(a){var b=this._readableState;return f(this,b,a,"",!0)},e.prototype.setEncoding=function(b){C||(C=a("string_decoder/").StringDecoder),this._readableState.decoder=new C(b),this._readableState.encoding=b};var D=8388608;e.prototype.read=function(a){var b=this._readableState;b.calledRead=!0;var c,d=a;if(("number"!=typeof a||a>0)&&(b.emittedReadable=!1),0===a&&b.needReadable&&(b.length>=b.highWaterMark||b.ended))return l(this),null;if(a=i(a,b),0===a&&b.ended)return c=null,b.length>0&&b.decoder&&(c=t(a,b),b.length-=c.length),0===b.length&&u(this),c;var e=b.needReadable;return b.length-a<=b.highWaterMark&&(e=!0),(b.ended||b.reading)&&(e=!1),e&&(b.reading=!0,b.sync=!0,0===b.length&&(b.needReadable=!0),this._read(b.highWaterMark),b.sync=!1),e&&!b.reading&&(a=i(d,b)),c=a>0?t(a,b):null,null===c&&(b.needReadable=!0,a=0),b.length-=a,0!==b.length||b.ended||(b.needReadable=!0),b.ended&&!b.endEmitted&&0===b.length&&u(this),c},e.prototype._read=function(a){this.emit("error",new Error("not implemented"))},e.prototype.pipe=function(a,b){function d(a){a===k&&f()}function e(){a.end()}function f(){a.removeListener("close",h),a.removeListener("finish",i),a.removeListener("drain",o),a.removeListener("error",g),a.removeListener("unpipe",d),k.removeListener("end",e),k.removeListener("end",f),(!a._writableState||a._writableState.needDrain)&&o()}function g(b){j(),a.removeListener("error",g),0===z.listenerCount(a,"error")&&a.emit("error",b)}function h(){a.removeListener("finish",i),j()}function i(){a.removeListener("close",h),j()}function j(){k.unpipe(a)}var k=this,l=this._readableState;switch(l.pipesCount){case 0:l.pipes=a;break;case 1:l.pipes=[l.pipes,a];break;default:l.pipes.push(a)}l.pipesCount+=1;var m=(!b||b.end!==!1)&&a!==c.stdout&&a!==c.stderr,n=m?e:f;l.endEmitted?c.nextTick(n):k.once("end",n),a.on("unpipe",d);var o=p(k);return a.on("drain",o),a._events&&a._events.error?x(a._events.error)?a._events.error.unshift(g):a._events.error=[g,a._events.error]:a.on("error",g),a.once("close",h),a.once("finish",i),a.emit("pipe",k),l.flowing||(this.on("readable",r),l.flowing=!0,c.nextTick(function(){q(k)})),a},e.prototype.unpipe=function(a){var b=this._readableState;if(0===b.pipesCount)return this;if(1===b.pipesCount)return a&&a!==b.pipes?this:(a||(a=b.pipes),b.pipes=null,b.pipesCount=0,this.removeListener("readable",r),b.flowing=!1,a&&a.emit("unpipe",this),this);if(!a){var c=b.pipes,d=b.pipesCount;b.pipes=null,b.pipesCount=0,this.removeListener("readable",r),b.flowing=!1;for(var e=0;d>e;e++)c[e].emit("unpipe",this);return this}var e=w(b.pipes,a);return-1===e?this:(b.pipes.splice(e,1),b.pipesCount-=1,1===b.pipesCount&&(b.pipes=b.pipes[0]),a.emit("unpipe",this),this)},e.prototype.on=function(a,b){var c=A.prototype.on.call(this,a,b);if("data"!==a||this._readableState.flowing||s(this),"readable"===a&&this.readable){var d=this._readableState;d.readableListening||(d.readableListening=!0,d.emittedReadable=!1,d.needReadable=!0,d.reading?d.length&&l(this,d):this.read(0))}return c},e.prototype.addListener=e.prototype.on,e.prototype.resume=function(){s(this),this.read(0),this.emit("resume")},e.prototype.pause=function(){s(this,!0),this.emit("pause")},e.prototype.wrap=function(a){var b=this._readableState,c=!1,d=this;a.on("end",function(){if(b.decoder&&!b.ended){var a=b.decoder.end();a&&a.length&&d.push(a)}d.push(null)}),a.on("data",function(e){if(b.decoder&&(e=b.decoder.write(e)),(!b.objectMode||null!==e&&void 0!==e)&&(b.objectMode||e&&e.length)){var f=d.push(e);f||(c=!0,a.pause())}});for(var e in a)"function"==typeof a[e]&&"undefined"==typeof this[e]&&(this[e]=function(b){return function(){return a[b].apply(a,arguments)}}(e));var f=["error","close","destroy","pause","resume"];return v(f,function(b){a.on(b,d.emit.bind(d,b))}),d._read=function(b){c&&(c=!1,a.resume())},d},e._fromList=t}).call(this,a("_process"))},{_process:20,buffer:1,"core-util-is":27,events:17,inherits:18,isarray:19,stream:33,"string_decoder/":28}],25:[function(a,b,c){function d(a,b){this.afterTransform=function(a,c){return e(b,a,c)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function e(a,b,c){var d=a._transformState;d.transforming=!1;var e=d.writecb;if(!e)return a.emit("error",new Error("no writecb in Transform class"));d.writechunk=null,d.writecb=null,null!==c&&void 0!==c&&a.push(c),e&&e(b);var f=a._readableState;f.reading=!1,(f.needReadable||f.length<f.highWaterMark)&&a._read(f.highWaterMark)}function f(a){if(!(this instanceof f))return new f(a);h.call(this,a);var b=(this._transformState=new d(a,this),this);this._readableState.needReadable=!0,this._readableState.sync=!1,this.once("finish",function(){"function"==typeof this._flush?this._flush(function(a){g(b,a)}):g(b)})}function g(a,b){if(b)return a.emit("error",b);var c=a._writableState,d=(a._readableState,a._transformState);if(c.length)throw new Error("calling transform done when ws.length != 0");if(d.transforming)throw new Error("calling transform done when still transforming");return a.push(null)}b.exports=f;var h=a("./_stream_duplex"),i=a("core-util-is");i.inherits=a("inherits"),i.inherits(f,h),f.prototype.push=function(a,b){return this._transformState.needTransform=!1,h.prototype.push.call(this,a,b)},f.prototype._transform=function(a,b,c){throw new Error("not implemented")},f.prototype._write=function(a,b,c){var d=this._transformState;if(d.writecb=c,d.writechunk=a,d.writeencoding=b,!d.transforming){var e=this._readableState;(d.needTransform||e.needReadable||e.length<e.highWaterMark)&&this._read(e.highWaterMark)}},f.prototype._read=function(a){var b=this._transformState;null!==b.writechunk&&b.writecb&&!b.transforming?(b.transforming=!0,this._transform(b.writechunk,b.writeencoding,b.afterTransform)):b.needTransform=!0}},{"./_stream_duplex":22,"core-util-is":27,inherits:18}],26:[function(a,b,c){(function(c){function d(a,b,c){this.chunk=a,this.encoding=b,this.callback=c}function e(a,b){a=a||{};var c=a.highWaterMark;this.highWaterMark=c||0===c?c:16384,this.objectMode=!!a.objectMode,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var d=a.decodeStrings===!1;this.decodeStrings=!d,this.defaultEncoding=a.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){n(b,a)},this.writecb=null,this.writelen=0,this.buffer=[],this.errorEmitted=!1}function f(b){var c=a("./_stream_duplex");return this instanceof f||this instanceof c?(this._writableState=new e(b,this),this.writable=!0,void w.call(this)):new f(b)}function g(a,b,d){var e=new Error("write after end");a.emit("error",e),c.nextTick(function(){d(e)})}function h(a,b,d,e){var f=!0;if(!u.isBuffer(d)&&"string"!=typeof d&&null!==d&&void 0!==d&&!b.objectMode){var g=new TypeError("Invalid non-string/buffer chunk");a.emit("error",g),c.nextTick(function(){e(g)}),f=!1}return f}function i(a,b,c){return a.objectMode||a.decodeStrings===!1||"string"!=typeof b||(b=new u(b,c)),b}function j(a,b,c,e,f){c=i(b,c,e),u.isBuffer(c)&&(e="buffer");var g=b.objectMode?1:c.length;b.length+=g;var h=b.length<b.highWaterMark;return h||(b.needDrain=!0),b.writing?b.buffer.push(new d(c,e,f)):k(a,b,g,c,e,f),h}function k(a,b,c,d,e,f){b.writelen=c,b.writecb=f,b.writing=!0,b.sync=!0,a._write(d,e,b.onwrite),b.sync=!1}function l(a,b,d,e,f){d?c.nextTick(function(){f(e)}):f(e),a._writableState.errorEmitted=!0,a.emit("error",e)}function m(a){a.writing=!1,a.writecb=null,a.length-=a.writelen,a.writelen=0}function n(a,b){var d=a._writableState,e=d.sync,f=d.writecb;if(m(d),b)l(a,d,e,b,f);else{var g=r(a,d);g||d.bufferProcessing||!d.buffer.length||q(a,d),e?c.nextTick(function(){o(a,d,g,f)}):o(a,d,g,f)}}function o(a,b,c,d){c||p(a,b),d(),c&&s(a,b)}function p(a,b){0===b.length&&b.needDrain&&(b.needDrain=!1,a.emit("drain"))}function q(a,b){b.bufferProcessing=!0;for(var c=0;c<b.buffer.length;c++){var d=b.buffer[c],e=d.chunk,f=d.encoding,g=d.callback,h=b.objectMode?1:e.length;if(k(a,b,h,e,f,g),b.writing){c++;break}}b.bufferProcessing=!1,c<b.buffer.length?b.buffer=b.buffer.slice(c):b.buffer.length=0}function r(a,b){return b.ending&&0===b.length&&!b.finished&&!b.writing}function s(a,b){var c=r(a,b);return c&&(b.finished=!0,a.emit("finish")),c}function t(a,b,d){b.ending=!0,s(a,b),d&&(b.finished?c.nextTick(d):a.once("finish",d)),b.ended=!0}b.exports=f;var u=a("buffer").Buffer;f.WritableState=e;var v=a("core-util-is");v.inherits=a("inherits");var w=a("stream");v.inherits(f,w),f.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},f.prototype.write=function(a,b,c){var d=this._writableState,e=!1;return"function"==typeof b&&(c=b,b=null),u.isBuffer(a)?b="buffer":b||(b=d.defaultEncoding),"function"!=typeof c&&(c=function(){}),d.ended?g(this,d,c):h(this,d,a,c)&&(e=j(this,d,a,b,c)),e},f.prototype._write=function(a,b,c){c(new Error("not implemented"))},f.prototype.end=function(a,b,c){var d=this._writableState;"function"==typeof a?(c=a,a=null,b=null):"function"==typeof b&&(c=b,b=null),"undefined"!=typeof a&&null!==a&&this.write(a,b),d.ending||d.finished||t(this,d,c)}}).call(this,a("_process"))},{"./_stream_duplex":22,_process:20,buffer:1,"core-util-is":27,inherits:18,stream:33}],27:[function(a,b,c){(function(a){function b(a){return Array.isArray(a)}function d(a){return"boolean"==typeof a}function e(a){return null===a}function f(a){return null==a}function g(a){return"number"==typeof a}function h(a){return"string"==typeof a}function i(a){return"symbol"==typeof a}function j(a){return void 0===a}function k(a){return l(a)&&"[object RegExp]"===r(a)}function l(a){return"object"==typeof a&&null!==a}function m(a){return l(a)&&"[object Date]"===r(a)}function n(a){return l(a)&&("[object Error]"===r(a)||a instanceof Error)}function o(a){return"function"==typeof a}function p(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function q(b){return a.isBuffer(b)}function r(a){return Object.prototype.toString.call(a)}c.isArray=b,c.isBoolean=d,c.isNull=e,c.isNullOrUndefined=f,c.isNumber=g,c.isString=h,c.isSymbol=i,c.isUndefined=j,c.isRegExp=k,c.isObject=l,c.isDate=m,c.isError=n,c.isFunction=o,c.isPrimitive=p,c.isBuffer=q}).call(this,a("buffer").Buffer)},{buffer:1}],28:[function(a,b,c){function d(a){if(a&&!i(a))throw new Error("Unknown encoding: "+a)}function e(a){return a.toString(this.encoding)}function f(a){this.charReceived=a.length%2,this.charLength=this.charReceived?2:0}function g(a){this.charReceived=a.length%3,this.charLength=this.charReceived?3:0}var h=a("buffer").Buffer,i=h.isEncoding||function(a){switch(a&&a.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},j=c.StringDecoder=function(a){switch(this.encoding=(a||"utf8").toLowerCase().replace(/[-_]/,""),d(a),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=f;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=g;break;default:return void(this.write=e)}this.charBuffer=new h(6),this.charReceived=0,this.charLength=0};j.prototype.write=function(a){for(var b="";this.charLength;){var c=a.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:a.length;if(a.copy(this.charBuffer,this.charReceived,0,c),this.charReceived+=c,this.charReceived<this.charLength)return"";a=a.slice(c,a.length),b=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var d=b.charCodeAt(b.length-1);if(!(d>=55296&&56319>=d)){if(this.charReceived=this.charLength=0,0===a.length)return b;break}this.charLength+=this.surrogateSize,b=""}this.detectIncompleteChar(a);var e=a.length;this.charLength&&(a.copy(this.charBuffer,0,a.length-this.charReceived,e),e-=this.charReceived),b+=a.toString(this.encoding,0,e);var e=b.length-1,d=b.charCodeAt(e);if(d>=55296&&56319>=d){var f=this.surrogateSize;return this.charLength+=f,this.charReceived+=f,this.charBuffer.copy(this.charBuffer,f,0,f),a.copy(this.charBuffer,0,0,f),b.substring(0,e)}return b},j.prototype.detectIncompleteChar=function(a){for(var b=a.length>=3?3:a.length;b>0;b--){var c=a[a.length-b];if(1==b&&c>>5==6){this.charLength=2;break}if(2>=b&&c>>4==14){this.charLength=3;break}if(3>=b&&c>>3==30){this.charLength=4;break}}this.charReceived=b},j.prototype.end=function(a){var b="";if(a&&a.length&&(b=this.write(a)),this.charReceived){var c=this.charReceived,d=this.charBuffer,e=this.encoding;b+=d.slice(0,c).toString(e)}return b}},{buffer:1}],29:[function(a,b,c){b.exports=a("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":23}],30:[function(a,b,c){c=b.exports=a("./lib/_stream_readable.js"),c.Readable=c,c.Writable=a("./lib/_stream_writable.js"),c.Duplex=a("./lib/_stream_duplex.js"),c.Transform=a("./lib/_stream_transform.js"),c.PassThrough=a("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":22,"./lib/_stream_passthrough.js":23,"./lib/_stream_readable.js":24,"./lib/_stream_transform.js":25,"./lib/_stream_writable.js":26}],31:[function(a,b,c){b.exports=a("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":25}],32:[function(a,b,c){b.exports=a("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":26}],33:[function(a,b,c){function d(){e.call(this)}b.exports=d;var e=a("events").EventEmitter,f=a("inherits");f(d,e),d.Readable=a("readable-stream/readable.js"),d.Writable=a("readable-stream/writable.js"),d.Duplex=a("readable-stream/duplex.js"),d.Transform=a("readable-stream/transform.js"),d.PassThrough=a("readable-stream/passthrough.js"),d.Stream=d,d.prototype.pipe=function(a,b){function c(b){a.writable&&!1===a.write(b)&&j.pause&&j.pause()}function d(){j.readable&&j.resume&&j.resume()}function f(){k||(k=!0,a.end())}function g(){k||(k=!0,"function"==typeof a.destroy&&a.destroy())}function h(a){if(i(),0===e.listenerCount(this,"error"))throw a}function i(){j.removeListener("data",c),a.removeListener("drain",d),j.removeListener("end",f),j.removeListener("close",g),j.removeListener("error",h),a.removeListener("error",h),j.removeListener("end",i),j.removeListener("close",i),a.removeListener("close",i)}var j=this;j.on("data",c),a.on("drain",d),a._isStdio||b&&b.end===!1||(j.on("end",f),j.on("close",g));var k=!1;return j.on("error",h),a.on("error",h),j.on("end",i),j.on("close",i),a.on("close",i),a.emit("pipe",j),a}},{events:17,inherits:18,"readable-stream/duplex.js":21,"readable-stream/passthrough.js":29,"readable-stream/readable.js":30,"readable-stream/transform.js":31,"readable-stream/writable.js":32}],34:[function(a,b,c){b.exports=function(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.readUInt8}},{}],35:[function(a,b,c){(function(b,d){function e(a,b){var d={seen:[],stylize:g};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),p(b)?d.showHidden=b:b&&c._extend(d,b),v(d.showHidden)&&(d.showHidden=!1),v(d.depth)&&(d.depth=2),v(d.colors)&&(d.colors=!1),v(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=f),i(d,a,d.depth)}function f(a,b){var c=e.styles[b];return c?"["+e.colors[c][0]+"m"+a+"["+e.colors[c][1]+"m":a}function g(a,b){return a}function h(a){var b={};return a.forEach(function(a,c){b[a]=!0}),b}function i(a,b,d){if(a.customInspect&&b&&A(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d,a);return t(e)||(e=i(a,e,d)),e}var f=j(a,b);if(f)return f;var g=Object.keys(b),p=h(g);if(a.showHidden&&(g=Object.getOwnPropertyNames(b)),z(b)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return k(b);if(0===g.length){if(A(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(w(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(y(b))return a.stylize(Date.prototype.toString.call(b),"date");if(z(b))return k(b)}var r="",s=!1,u=["{","}"];if(o(b)&&(s=!0,u=["[","]"]),A(b)){var v=b.name?": "+b.name:"";r=" [Function"+v+"]"}if(w(b)&&(r=" "+RegExp.prototype.toString.call(b)),y(b)&&(r=" "+Date.prototype.toUTCString.call(b)),z(b)&&(r=" "+k(b)),0===g.length&&(!s||0==b.length))return u[0]+r+u[1];if(0>d)return w(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var x;return x=s?l(a,b,d,p,g):g.map(function(c){return m(a,b,d,p,c,s)}),a.seen.pop(),n(x,r,u)}function j(a,b){if(v(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return s(b)?a.stylize(""+b,"number"):p(b)?a.stylize(""+b,"boolean"):q(b)?a.stylize("null","null"):void 0}function k(a){return"["+Error.prototype.toString.call(a)+"]"}function l(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)F(b,String(g))?f.push(m(a,b,c,d,String(g),!0)):f.push("");return e.forEach(function(e){e.match(/^\d+$/)||f.push(m(a,b,c,d,e,!0))}),f}function m(a,b,c,d,e,f){var g,h,j;if(j=Object.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?h=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(h=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),h||(a.seen.indexOf(j.value)<0?(h=q(c)?i(a,j.value,null):i(a,j.value,c-1),h.indexOf("\n")>-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),v(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function n(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function o(a){return Array.isArray(a)}function p(a){return"boolean"==typeof a}function q(a){return null===a}function r(a){return null==a}function s(a){return"number"==typeof a}function t(a){return"string"==typeof a}function u(a){return"symbol"==typeof a}function v(a){return void 0===a}function w(a){return x(a)&&"[object RegExp]"===C(a)}function x(a){return"object"==typeof a&&null!==a}function y(a){return x(a)&&"[object Date]"===C(a)}function z(a){return x(a)&&("[object Error]"===C(a)||a instanceof Error)}function A(a){return"function"==typeof a}function B(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),J[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=/%[sdj%]/g;c.format=function(a){if(!t(a)){for(var b=[],c=0;c<arguments.length;c++)b.push(e(arguments[c]));return b.join(" ")}for(var c=1,d=arguments,f=d.length,g=String(a).replace(G,function(a){if("%%"===a)return"%";if(c>=f)return a;switch(a){case"%s":return String(d[c++]);case"%d":return Number(d[c++]);case"%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),h=d[c];f>c;h=d[++c])g+=q(h)||!x(h)?" "+h:" "+e(h);return g},c.deprecate=function(a,e){function f(){if(!g){if(b.throwDeprecation)throw new Error(e);b.traceDeprecation?console.trace(e):console.error(e),g=!0}return a.apply(this,arguments)}if(v(d.process))return function(){return c.deprecate(a,e).apply(this,arguments)};if(b.noDeprecation===!0)return a;var g=!1;return f};var H,I={};c.debuglog=function(a){if(v(H)&&(H=b.env.NODE_DEBUG||""),a=a.toUpperCase(),!I[a])if(new RegExp("\\b"+a+"\\b","i").test(H)){var d=b.pid;I[a]=function(){var b=c.format.apply(c,arguments);console.error("%s %d: %s",a,d,b)}}else I[a]=function(){};return I[a]},c.inspect=e,e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=o,c.isBoolean=p,c.isNull=q,c.isNullOrUndefined=r,c.isNumber=s,c.isString=t,c.isSymbol=u,c.isUndefined=v,c.isRegExp=w,c.isObject=x,c.isDate=y,c.isError=z,c.isFunction=A,c.isPrimitive=B,c.isBuffer=a("./support/isBuffer");var J=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=a("inherits"),c._extend=function(a,b){if(!b||!x(b))return a;
for(var c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":34,_process:20,inherits:18}],36:[function(a,b,c){(function(a){!function(){"use strict";function c(b){var c;return c=b instanceof a?b:new a(b.toString(),"binary"),c.toString("base64")}b.exports=c}()}).call(this,a("buffer").Buffer)},{buffer:1}],37:[function(a,b,c){(function(c){var d=a("jws");b.exports.decode=function(a){var b=d.decode(a,{json:!0});return b&&b.payload},b.exports.sign=function(a,b,c){c=c||{};var e="object"==typeof c.headers&&c.headers||{};if(e.typ="JWT",e.alg=c.algorithm||"HS256",c.header&&Object.keys(c.header).forEach(function(a){e[a]=c.header[a]}),c.noTimestamp||(a.iat=Math.floor(Date.now()/1e3)),c.expiresInMinutes){var f=60*c.expiresInMinutes;a.exp=a.iat+f}c.audience&&(a.aud=c.audience),c.issuer&&(a.iss=c.issuer),c.subject&&(a.sub=c.subject);var g=d.sign({header:e,payload:a,secret:b});return g},b.exports.verify=function(a,b,g,h){if("function"!=typeof g||h||(h=g,g={}),g||(g={}),h)var i=function(){var a=Array.prototype.slice.call(arguments,0);return c.nextTick(function(){h.apply(null,a)})};else var i=function(a,b){if(a)throw a;return b};if(!a)return i(new e("jwt must be provided"));var j=a.split(".");if(3!==j.length)return i(new e("jwt malformed"));if(""===j[2].trim()&&b)return i(new e("jwt signature is required"));var k;try{k=d.verify(a,b)}catch(l){return i(l)}if(!k)return i(new e("invalid signature"));var m;try{m=this.decode(a)}catch(n){return i(n)}if(m.exp&&Math.floor(Date.now()/1e3)>=m.exp)return i(new f("jwt expired",new Date(1e3*m.exp)));if(g.audience){var o=Array.isArray(g.audience)?g.audience:[g.audience],p=Array.isArray(m.aud)?m.aud:[m.aud],q=p.some(function(a){return-1!=o.indexOf(a)});if(!q)return i(new e("jwt audience invalid. expected: "+m.aud))}return g.issuer&&m.iss!==g.issuer?i(new e("jwt issuer invalid. expected: "+m.iss)):i(null,m)};var e=b.exports.JsonWebTokenError=function(a,b){Error.call(this,a),this.name="JsonWebTokenError",this.message=a,b&&(this.inner=b)};e.prototype=Object.create(Error.prototype),e.prototype.constructor=e;var f=b.exports.TokenExpiredError=function(a,b){e.call(this,a),this.name="TokenExpiredError",this.expiredAt=b};f.prototype=Object.create(e.prototype),f.prototype.constructor=f}).call(this,a("_process"))},{_process:20,jws:38}],38:[function(a,b,c){(function(b){function d(a){return"string"==typeof a?a:"number"==typeof a||t.isBuffer(a)?a.toString():JSON.stringify(a)}function e(a,b){var c=w(d(a)),e=w(d(b));return v.format("%s.%s",c,e)}function f(a){var b=a.header,c=a.payload,d=a.secret||a.privateKey,f=x(b.alg),g=e(b,c),h=f.sign(g,d);return v.format("%s.%s",g,h)}function g(a){return"[object Object]"===Object.prototype.toString.call(a)}function h(a){if(g(a))return a;try{return JSON.parse(a)}catch(b){return}}function i(a){var b=a.split(".",1)[0];return h(w.decode(b))}function j(a){return a.split(".",2).join(".")}function k(a){var b,c=i(a);if("object"!=typeof c)throw b=new Error("Invalid token: no header in signature '"+a+"'"),b.code="MISSING_HEADER",b.signature=a,b;if(!c.alg)throw b=new Error("Missing `alg` field in header for signature '"+a+"'"),b.code="MISSING_ALGORITHM",b.header=c,b.signature=a,b;return c.alg}function l(a){return a.split(".")[2]}function m(a){var b=a.split(".")[1];return w.decode(b)}function n(a){return z.test(a)&&i(a)?!0:!1}function o(a,b){a=d(a);var c=l(a),e=j(a),f=x(k(a));return f.verify(e,c,b)}function p(a,b){if(b=b||{},a=d(a),!n(a))return null;var c=i(a);if(!c)return null;var e=m(a);return("JWT"===c.typ||b.json)&&(e=JSON.parse(e)),{header:c,payload:e,signature:l(a)}}function q(a){var b=a.secret||a.privateKey||a.key,c=new s(b);this.readable=!0,this.header=a.header,this.secret=this.privateKey=this.key=c,this.payload=new s(a.payload),this.secret.once("close",function(){!this.payload.writable&&this.readable&&this.sign()}.bind(this)),this.payload.once("close",function(){!this.secret.writable&&this.readable&&this.sign()}.bind(this))}function r(a){a=a||{};var b=a.secret||a.publicKey||a.key,c=new s(b);this.readable=!0,this.secret=this.publicKey=this.key=c,this.signature=new s(a.signature),this.secret.once("close",function(){!this.signature.writable&&this.readable&&this.verify()}.bind(this)),this.signature.once("close",function(){!this.secret.writable&&this.readable&&this.verify()}.bind(this))}function s(a){return this.buffer=t(a||0),this.writable=!0,this.readable=!0,a?void("function"==typeof a.pipe?a.pipe(this):a.length&&(this.writable=!1,b.nextTick(function(){this.buffer=a,this.emit("end",a),this.readable=!1,this.emit("close")}.bind(this)))):this}var t=a("buffer").Buffer,u=a("stream"),v=a("util"),w=a("base64url"),x=a("jwa"),y=["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512"],z=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;v.inherits(q,u),q.prototype.sign=function(){var a=f({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer});return this.emit("done",a),this.emit("data",a),this.emit("end"),this.readable=!1,a},v.inherits(r,u),r.prototype.verify=function(){var a=o(this.signature.buffer,this.key.buffer),b=p(this.signature.buffer);return this.emit("done",a,b),this.emit("data",a),this.emit("end"),this.readable=!1,a},v.inherits(s,u),s.prototype.write=function(a){this.buffer=t.concat([this.buffer,t(a)]),this.emit("data",a)},s.prototype.end=function(a){a&&this.write(a),this.emit("end",a),this.emit("close"),this.writable=!1,this.readable=!1},c.ALGORITHMS=y,c.sign=f,c.verify=o,c.decode=p,c.isValid=n,c.createSign=function(a){return new q(a)},c.createVerify=function(a){return new r(a)}}).call(this,a("_process"))},{_process:20,base64url:39,buffer:1,jwa:40,stream:33,util:35}],39:[function(a,b,c){(function(a){function c(a){return a.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function d(b){a.isBuffer(b)&&(b=b.toString());var c=e(b).replace(/\-/g,"+").replace(/_/g,"/");return c}function e(b){var c=4,d=b.length,e=b.length%c;if(!e)return b;var f=d,g=c-e,h=d+g,i=a(h);for(i.write(b);g--;)i.write("=",f++);return i.toString()}function f(b,c){return a(d(b),"base64").toString(c)}function g(b){return c(a(b).toString("base64"))}function h(b){return a(d(b),"base64")}g.toBase64=d,g.fromBase64=c,g.decode=f,g.toBuffer=h,b.exports=g}).call(this,a("buffer").Buffer)},{buffer:1}],40:[function(a,b,c){(function(c){function d(a){var b=[].slice.call(arguments,1),c=o.format.bind(o,a).apply(null,b);return new TypeError(c)}function e(a){return c.isBuffer(a)||"string"==typeof a}function f(a){return e(a)||(a=JSON.stringify(a)),a}function g(a){return function(b,c){if(!e(c))throw d(q);b=f(b);var g=n.createHmac("SHA"+a,c),h=(g.update(b),g.digest("base64"));return m.fromBase64(h)}}function h(a){return function(b,c,d){var e=g(a)(b,d);return c===e}}function i(a){return function(b,c){if(!e(c))throw d(r);b=f(b);var g=n.createSign("RSA-SHA"+a),h=(g.update(b),g.sign(c,"base64"));return m.fromBase64(h)}}function j(a){return function(b,c,g){if(!e(g))throw d(r);b=f(b),c=m.toBase64(c);var h=n.createVerify("RSA-SHA"+a);return h.update(b),h.verify(g,c,"base64")}}function k(){return function(){return""}}function l(){return function(a,b){return""===b}}var m=a("base64url"),n=a("crypto"),o=a("util"),p='"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512" and "none".',q="secret must be a string or buffer",r="key must be a string or buffer";b.exports=function(a){var b={hs:g,rs:i,es:i,none:k},c={hs:h,rs:j,es:j,none:l},e=a.match(/(RS|ES|HS|none)(256|384|512)?/i);if(!e)throw d(p,a);var f=e[1].toLowerCase(),m=e[2];return{sign:b[f](m),verify:c[f](m)}}}).call(this,a("buffer").Buffer)},{base64url:39,buffer:1,crypto:7,util:35}],41:[function(a,b,c){(function(){var b=a("../client/entry");angular.module("ng-fhir",["ng"]),angular.module("ng-fhir").provider("$fhir",function(){var a;return a={$get:function(a,c){var d={http:a,defer:c.defer,fhirjs:fhir};return b(d)}}})}).call(this)},{"../client/entry":45}],42:[function(a,b,c){var d,e=b.exports={debug:!0};e.set=function(a){d=a},e.get=function(){return d}},{}],43:[function(a,b,c){(function(c){function d(a,b){void 0===b&&(b=!1);for(var c=location.search.substr(1),d=c.split("&"),e=[],f=0;f<d.length;f++){var g=d[f].split("=");g[0]===a&&e.push(decodeURIComponent(g[1]))}return b?e:0===e.length?null:e[0]}function e(a){return"/"===a.substr(-1)?a.substr(0,a.length-1):a}function f(){var a=sessionStorage.tokenResponse;return a&&(a=JSON.parse(a)),a}function g(a){a||(a=window.location.hash);var b=p.get().defer();return c.nextTick(function(){var c=a.match(/#(.*)/);c=c?c[1]:"",c=c.split(/&/);for(var d={},e=0;e<c.length;e++){var f=c[e].split(/=/);f[0].length>0&&f[1]&&(d[decodeURIComponent(f[0])]=decodeURIComponent(f[1]))}b.resolve(d)}),b.promise}function h(a){a||(a={code:d("code"),state:d("state")});var b=p.get().defer(),c=JSON.parse(sessionStorage[a.state]);window.history.replaceState&&t.settings.replaceBrowserHistory&&window.history.replaceState({},"",window.location.toString().replace(window.location.search,""));var e={code:a.code,grant_type:"authorization_code",redirect_uri:c.client.redirect_uri},f={};return c.client.secret?f.Authorization="Basic "+btoa(c.client.client_id+":"+c.client.secret):e.client_id=c.client.client_id,p.get().http({method:"POST",url:c.provider.oauth2.token_uri,data:e,headers:f}).then(function(c){for(var d in a)a.hasOwnProperty(d)&&(c[d]=a[d]);b.resolve(c)},function(){console.log("failed to exchange code for access_token",arguments),b.reject()}),b.promise}function i(a){a||(a={assertion:d("assertion"),state:d("state")});var b=p.get().defer(),c=JSON.parse(sessionStorage[a.state]);return window.history.replaceState&&t.settings.replaceBrowserHistory&&window.history.replaceState({},"",window.location.toString().replace(window.location.search,"")),p.get().http({method:"POST",url:c.provider.oauth2.token_uri,data:{assertion:a.assertion,grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",client_id:c.client.client_id,scope:c.client.scope}}).then(function(c){for(var d in a)a.hasOwnProperty(d)&&(c[d]=a[d]);b.resolve(c)},function(){console.log("failed to exchange jwt-bearer assertion for access_token",arguments),b.reject()}),b.promise}function j(){var a=p.get().defer();return c.nextTick(function(){a.resolve(f())}),a}function k(){var a=null,b=function(){},c=function(){};if(0===arguments.length)throw"Can't call 'ready' without arguments";if(1===arguments.length)b=arguments[0];else if(2===arguments.length)if("function"==typeof arguments[0])b=arguments[0],c=arguments[1];else{if("object"!=typeof arguments[0])throw"ready called with invalid arguments";a=arguments[0],b=arguments[1]}else{if(3!==arguments.length)throw"ready called with invalid arguments";a=arguments[0],b=arguments[1],c=arguments[2]}return{input:a,callback:b,errback:c}}function l(a,b,d,f){return n()?void c.nextTick(function(){o(a,d)}):b?(b.url=a,void c.nextTick(function(){d&&d(b)})):void p.get().http({method:"GET",url:e(a)+"/metadata"}).then(function(b){var c={name:"SMART on FHIR Testing Server",description:"Dev server for SMART on FHIR",url:a,oauth2:{registration_uri:null,authorize_uri:null,token_uri:null}};try{var e=b.rest[0].security.extension.filter(function(a){return"http://fhir-registry.smarthealthit.org/StructureDefinition/oauth-uris"===a.url});e[0].extension.forEach(function(a,b,d){"register"===a.url?c.oauth2.registration_uri=a.valueUri:"authorize"===a.url?c.oauth2.authorize_uri=a.valueUri:"token"===a.url&&(c.oauth2.token_uri=a.valueUri)})}catch(g){return f&&f(g)}d&&d(c)},function(){f&&f("Unable to fetch conformance statement")})}function m(a){return(window.location.protocol+"//"+window.location.host+window.location.pathname).match(/(.*\/)[^\/]*/)[1]+a}function n(){return d("fhirServiceUrl")&&!d("iss")}function o(a,b){b&&b({oauth2:null,url:a||d("fhirServiceUrl")})}var p=a("./adapter"),q=a("./client"),r=a("./guid"),s=a("jsonwebtoken"),t=b.exports={debug:!0};t.settings={replaceBrowserHistory:!0},t.ready=function(a,b,c){var e=k.apply(this,arguments),f=d("code")||e.input&&e.input.code,l=d("assertion")||e.input&&e.input.assertion,m=null;m=sessionStorage.tokenResponse?j():f?h(e.input):l?i(e.input):g(e.input),m.done(function(a){if(!a||!a.state)return e.errback("No 'state' parameter found in authorization response.");sessionStorage.tokenResponse=JSON.stringify(a);var b=JSON.parse(sessionStorage[a.state]);b.client.patient&&!a.patient&&(a.patient=b.client.patient);var c={serviceUrl:b.provider.url,patientId:a.patient};if(a.id_token){var d=a.id_token,f=s.decode(d);c.userId=f.profile}if(void 0===a.access_token)return e.errback("Failed to obtain access token.");var g=a.access_token;c.auth={type:"bearer",token:g};var h=s.decode(g);h.patient&&(c.patientId=h.patient);var i=q(c);i.state=JSON.parse(JSON.stringify(b)),i.tokenResponse=JSON.parse(JSON.stringify(a)),e.callback(i)}).fail(function(){e.errback("Failed to obtain access token.")})};t.authorize=function(a,b){b||(b=function(){console.log("Failed to discover authorization URL given",a)}),delete sessionStorage.tokenResponse,a.client||(a={client:a}),a.response_type||(a.response_type="code"),a.client.redirect_uri||(a.client.redirect_uri=m("")),a.client.redirect_uri.match(/:\/\//)||(a.client.redirect_uri=m(a.client.redirect_uri));var c=d("launch");c&&(a.client.scope.match(/launch/)||(a.client.scope+=" launch"),a.client.launch=c);var e=d("patientId");e&&(a.client.patient=e);var f=d("iss")||d("fhirServiceUrl");f&&(a.server||(a.server=f)),d("assertion")&&(a.assertion=d("assertion")),l(a.server,a.provider,function(b){a.provider=b;var c=a.client.state||r.newGuid(),d=a.client;if(null==a.provider.oauth2)return sessionStorage[c]=JSON.stringify(a),sessionStorage.tokenResponse=JSON.stringify({state:c}),void(window.location.href=d.redirect_uri+"#state="+encodeURIComponent(c));sessionStorage[c]=JSON.stringify(a),console.log("sending client reg",a.client);var e;e=a.assertion?d.redirect_uri+"?assertion="+encodeURIComponent(a.assertion)+"&state="+encodeURIComponent(c):a.provider.oauth2.authorize_uri+"?client_id="+encodeURIComponent(d.client_id)+"&response_type="+encodeURIComponent(a.response_type)+"&scope="+encodeURIComponent(d.scope)+"&redirect_uri="+encodeURIComponent(d.redirect_uri)+"&state="+encodeURIComponent(c)+"&aud="+encodeURIComponent(a.server),"undefined"!=typeof d.launch&&d.launch&&(e+="&launch="+encodeURIComponent(d.launch)),window.location.href=e},b)},t.resolveAuthType=function(a,b,c){p.get().http({method:"GET",url:e(a)+"/metadata"}).then(function(a){var c="none";try{"smart-on-fhir"===a.rest[0].security.service[0].coding[0].code.toLowerCase()&&(c="oauth2")}catch(d){}b&&b(c)},function(){c&&c("Unable to fetch conformance statement")})}}).call(this,a("_process"))},{"./adapter":42,"./client":44,"./guid":46,_process:20,jsonwebtoken:37}],44:[function(a,b,c){function d(){}function e(a){function b(a,b){return a.match(/^http/)?a:a.match(/^urn/)?a:("/"==a.charAt(0)&&(a=a.substr(1)),b.serviceUrl+"/"+a)}var c=new d,e=g.get().fhirjs,h=c.server={serviceUrl:a.serviceUrl,auth:a.auth||{type:"none"}},i={};"basic"===h.auth.type?i={user:h.auth.username,pass:h.auth.password}:"bearer"===h.auth.type&&(i={bearer:h.auth.token}),c.api=e({baseUrl:h.serviceUrl,auth:i}),a.patientId&&(c.patient={},c.patient.id=a.patientId,c.patient.api=e({baseUrl:h.serviceUrl,auth:i,patient:a.patientId}),c.patient.read=function(){return c.get({resource:"Patient"})});var j=c.patient?c.patient.api:c.api;if(c.userId=a.userId,h.auth=h.auth||{type:"none"},!c.server.serviceUrl||!c.server.serviceUrl.match(/https?:\/\/.+[^\/]$/))throw"Must supply a `server` propery whose `serviceUrl` begins with http(s) and does NOT include a trailing slash. E.g. `https://fhir.aws.af.cm/fhir`";return c.authenticated=function(a){if("none"===h.auth.type)return a;var b;return"basic"===h.auth.type?b="Basic "+f(h.auth.username+":"+h.auth.password):"bearer"===h.auth.type&&(b="Bearer "+h.auth.token),a.headers||(a.headers={}),a.headers.Authorization=b,a},c.get=function(a){var b=g.get().defer(),c={type:a.resource};return a.id&&(c.id=a.id),j.read(c).then(function(a){b.resolve(a.data)},function(){b.reject("Could not fetch "+a.resource+" "+a.id)}),b.promise},c.user={read:function(){var a=c.userId;return resource=a.split("/")[0],uid=a.split("/")[1],c.get({resource:resource,id:uid})}},c.getBinary=function(a){var b=g.get().defer();return g.get().http(c.authenticated({type:"GET",url:a,dataType:"blob"})).done(function(a){b.resolve(a)}).fail(function(){b.reject("Could not fetch "+a,arguments)}),b.promise},c.fetchBinary=function(a){var d=b(a,h);return c.getBinary(d)},c}var f=a("btoa"),g=a("./adapter");b.exports=e;var h=a("./utils");Object.keys(h).forEach(function(a){d.prototype[a]=h[a]})},{"./adapter":42,"./utils":47,btoa:36}],45:[function(a,b,c){var d=a("./client"),e=a("./bb-client"),f=a("./adapter");window.FHIR={client:d,oauth2:e},b.exports=f.set},{"./adapter":42,"./bb-client":43,"./client":44}],46:[function(a,b,c){var d="00000000-0000-0000-0000-000000000000",e=function(a,b,c){return a.length>=b?a:e(c+a,b,c||" ")},f=function(a){var b=a.toString(16);return e(b,4,"0")},g=function(){var a=new window.Uint16Array(8);return window.crypto.getRandomValues(a),[f(a[0])+f(a[1]),f(a[2]),f(a[3]),f(a[4]),f(a[5])+f(a[6])+f(a[7])].join("-")},h=function(){var a=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(b){var c=(a+16*Math.random())%16|0;return a=Math.floor(a/16),("x"===b?c:7&c|8).toString(16)})},i=function(){var a="undefined"!=typeof window.crypto,b=a&&"undefined"!=typeof window.crypto.getRandomValues;return a&&b?g():h()};b.exports={newGuid:i,empty:d}},{}],47:[function(a,b,c){function d(a){if("number"!=typeof a.value)throw"Found a non-numerical unit: "+a.value+" "+a.code}var e=b.exports={};e.byCodes=function(a,b){function c(){for(var a=[],b=0;b<arguments.length;b++){var c=d[arguments[b]];c&&[].push.apply(a,c)}return a}var d=e.byCode(a,b);return c},e.byCode=function(a,b){var c={};return Array.isArray(a)||(a=[a]),a.forEach(function(a){"Observation"===a.resourceType&&a[b].coding.forEach(function(b){c[b.code]=c[b.code]||[],c[b.code].push(a)})}),c},e.units={cm:function(a){if(d(a),"cm"==a.code)return a.value;if("m"==a.code)return 100*a.value;if("in"==a.code)return 2.54*a.value;if("[in_us]"==a.code)return 2.54*a.value;if("[in_i]"==a.code)return 2.54*a.value;throw"Unrecognized length unit: "+a.code},kg:function(a){if(d(a),"kg"==a.code)return a.value;if("g"==a.code)return a.value/1e3;if(a.code.match(/lb/))return a.value/2.20462;if(a.code.match(/oz/))return a.value/35.274;throw"Unrecognized weight unit: "+a.code},any:function(a){return d(a),a.value}}},{}]},{},[41]);