Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zipkin

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zipkin - npm Package Compare versions

Comparing version 0.18.0 to 0.18.1

2

dist/zipkin.min.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Zipkin={})}(this,function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var r=0;e.length>r;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var c={get type(){return"None"},get present(){return!1},map:function(){return this},ifPresent:function(){},flatMap:function(){return this},getOrElse:function(t){return t instanceof Function?t():t},equals:function(t){return t===this},toString:function(){return"None"}},h=function(){function t(e){r(this,t),this.value=e}return o(t,[{key:"map",value:function(e){return new t(e(this.value))}},{key:"ifPresent",value:function(t){t(this.value)}},{key:"flatMap",value:function(t){return t(this.value)}},{key:"getOrElse",value:function(){return this.value}},{key:"equals",value:function(e){return e instanceof t&&e.value===this.value}},{key:"toString",value:function(){return"Some(".concat(this.value,")")}},{key:"type",get:function(){return"Some"}},{key:"present",get:function(){return!0}}]),t}();function f(t){return t instanceof h||c.equals(t)}var p={Some:h,None:c,isOptional:f,verifyIsOptional:function(t){if(null==t)throw Error("Error: data is not Optional - it's null");if(!f(t))throw Error("Error: data (".concat(t,") is not an Option!"));if(f(t.value))throw Error("Error: data (".concat(t.value,") is wrapped in Option twice"))},verifyIsNotOptional:function(t){if(f(t))throw Error("Error: data (".concat(t,") is an Option!"))},fromNullable:function(t){return null==t?c:new h(t)}},l="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function d(){throw Error("setTimeout has not been defined")}function v(){throw Error("clearTimeout has not been defined")}var m=d,g=v;function y(t){if(m===setTimeout)return setTimeout(t,0);if((m===d||!m)&&setTimeout)return m=setTimeout,setTimeout(t,0);try{return m(t,0)}catch(e){try{return m.call(null,t,0)}catch(e){return m.call(this,t,0)}}}"function"==typeof l.setTimeout&&(m=setTimeout),"function"==typeof l.clearTimeout&&(g=clearTimeout);var w,I=[],E=!1,b=-1;function S(){E&&w&&(E=!1,w.length?I=w.concat(I):b=-1,I.length&&A())}function A(){if(!E){var t=y(S);E=!0;for(var e=I.length;e;){for(w=I,I=[];++b<e;)w&&w[b].run();b=-1,e=I.length}w=null,E=!1,function(t){if(g===clearTimeout)return clearTimeout(t);if((g===v||!g)&&clearTimeout)return g=clearTimeout,clearTimeout(t);try{g(t)}catch(e){try{return g.call(null,t)}catch(e){return g.call(this,t)}}}(t)}}function R(t,e){this.fun=t,this.array=e}R.prototype.run=function(){this.fun.apply(null,this.array)};function T(){}var _=T,k=T,O=T,P=T,C=T,N=T,U=T;var B=l.performance||{},x=B.now||B.mozNow||B.msNow||B.oNow||B.webkitNow||function(){return(new Date).getTime()};var L=new Date;var M,j={nextTick:function(t){var e=Array(arguments.length-1);if(arguments.length>1)for(var r=1;arguments.length>r;r++)e[r-1]=arguments[r];I.push(new R(t,e)),1!==I.length||E||y(A)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:_,addListener:k,once:O,off:P,removeListener:C,removeAllListeners:N,emit:U,binding:function(t){throw Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(t){throw Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(t){var e=.001*x.call(B),r=Math.floor(e),n=Math.floor(e%1*1e9);return t&&(r-=t[0],0>(n-=t[1])&&(r--,n+=1e9)),[r,n]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-L)/1e3}};function D(){return"/tmp"}var Y={EOL:"\n",tmpdir:D,tmpDir:D,networkInterfaces:function(){},getNetworkInterfaces:function(){},release:function(){return void 0!==l.navigator?l.navigator.appVersion:""},type:function(){return"Browser"},cpus:function(){return[]},totalmem:function(){return Number.MAX_VALUE},freemem:function(){return Number.MAX_VALUE},uptime:function(){return 0},loadavg:function(){return[]},hostname:function(){return void 0!==l.location?l.location.hostname:""},endianness:function(){if(void 0===M){var t=new ArrayBuffer(2),e=new Uint8Array(t),r=new Uint16Array(t);if(e[0]=1,e[1]=2,258===r[0])M="BE";else{if(513!==r[0])throw Error("unable to figure out endianess");M="LE"}}return M}};function q(t,e){for(var r in t)for(var n=t[r].length-1;n>=0;n--){var o=t[r][n];if(!o.internal&&o.family===e&&("IPv4"===e||0===o.scopeid))return o.address}return"IPv4"===e?"127.0.0.1":"::1"}function F(t,e){var r={};for(var n in t)n===e&&(r[n]=t[n]);return r}function z(t){var e=Y.networkInterfaces();return t&&(e=F(e,t)),q(e,"IPv4")}z.ipv4=z,z.ipv6=function(t){var e=Y.networkInterfaces();return t&&(e=F(e,t)),q(e,"IPv6")};var K=z,H=function(){function t(e){r(this,t),this.addr=e}return o(t,[{key:"ipv4",value:function(){var t=this.toInt();if(t&&0!==t)return this.addr}},{key:"toInt",value:function(){var t=this.addr.split(".");return t[0]<<24|t[1]<<16|t[2]<<8|t[3]}},{key:"toString",value:function(){return"InetAddress(".concat(this.addr,")")}}]),t}();H.getLocalAddress=function(){return"object"===(void 0===j?"undefined":e(j))&&"function"==typeof j.on?new H(K.ipv4()):new H("127.0.0.1")};var V=H,J=function(){function t(){r(this,t)}return o(t,[{key:"toString",value:function(){return"".concat(this.annotationType,"()")}}]),t}(),X=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),Z=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),$=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),G=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),Q=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),W=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),tt=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),et=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}();function rt(t){this.name=t}rt.prototype.toString=function(){return'LocalOperationStart("'.concat(this.name,'")')};var nt=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}();function ot(t){this.message=t}function it(t){this.serviceName=t}function at(t){this.name=t}function st(t){var e=t.port;this.host=t.host,this.port=e}function ut(t){var e=t.host,r=t.port;this.serviceName=t.serviceName,this.host=e||void 0,this.port=r||0}function ct(t){var e=t.port;this.host=t.host||V.getLocalAddress(),this.port=e||0}function ht(t){var e=t.host,r=t.port;this.serviceName=t.serviceName,this.host=e,this.port=r}function ft(t,e){this.key=t,this.value=e}ot.prototype.toString=function(){return'Message("'.concat(this.message,'")')},it.prototype.toString=function(){return'ServiceName("'.concat(this.serviceName,'")')},at.prototype.toString=function(){return'Rpc("'.concat(this.name,'")')},st.prototype.toString=function(){return'ClientAddr(host="'.concat(this.host,'", port=').concat(this.port,")")},ut.prototype.toString=function(){return'ServerAddr(serviceName="'.concat(this.serviceName,'", host="').concat(this.host,'", port=').concat(this.port,")")},ct.prototype.toString=function(){return'LocalAddr(host="'.concat(""+this.host,'", port=').concat(this.port,")")},ht.prototype.toString=function(){return'MessageAddr(serviceName="'.concat(this.serviceName,'", host="').concat(this.host,'", port=').concat(this.port,")")},ft.prototype.toString=function(){return"BinaryAnnotation(".concat(this.key,'="').concat(this.value,'")')};var pt={ClientSend:X,ClientRecv:Z,ServerSend:$,ServerRecv:G,ProducerStart:Q,ProducerStop:W,ConsumerStart:tt,ConsumerStop:et,MessageAddr:ht,Message:ot,ServiceName:it,Rpc:at,ClientAddr:st,ServerAddr:ut,LocalAddr:ct,BinaryAnnotation:ft,LocalOperationStart:rt,LocalOperationStop:nt};Object.keys(pt).forEach(function(t){pt[t].prototype.annotationType=t});var lt=pt,dt=p.Some,vt=function(){function t(e){r(this,t),this.evaluator=e}return o(t,[{key:"shouldSample",value:function(t){var e=this,r=t.sampled.getOrElse(function(){return e.evaluator(t)});return new dt(r)}},{key:"toString",value:function(){return"Sampler(".concat(""+this.evaluator,")")}}]),t}();function mt(t){return!1}function gt(t){return!0}mt.toString=function(){return"never sample"},gt.toString=function(){return"always sample"};var yt={Sampler:vt,CountingSampler:function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return r(this,e),u(this,a(e).call(this,function(t){if(t>0){if(1>t){var e=0,r=parseInt(1/t),n=function(t){var n=0==(e%=r);return e++,n};return n.toString=function(){return"countingSampler: sampleRate=".concat(t)},n}return gt}return mt}(1>t?t:1)))}return i(e,vt),e}(),neverSample:mt,alwaysSample:gt},wt=function(){function t(e){var n=e.traceId,o=e.timestamp,i=e.annotation;r(this,t),this.traceId=n,this.timestamp=o,this.annotation=i}return o(t,[{key:"toString",value:function(){return"Record(traceId=".concat(""+this.traceId,", annotation=").concat(""+this.annotation,")")}}]),t}(),It=p.Some,Et=p.None,bt=p.verifyIsOptional,St=p.verifyIsNotOptional,At=function(){function t(e){r(this,t);var n=e.traceId,o=void 0===n?Et:n,i=e.parentId,a=void 0===i?Et:i,s=e.spanId,u=e.sampled,c=void 0===u?Et:u,h=e.flags,f=void 0===h?0:h;bt(o),bt(a),St(s),bt(c),this._traceId=o,this._parentId=a,this._spanId=s,this._sampled=c,this._flags=f}return o(t,[{key:"isDebug",value:function(){return 1==(1&this._flags)}},{key:"toString",value:function(){return"TraceId(spanId=".concat(""+this.spanId)+", parentId=".concat(""+this.parentId)+", traceId=".concat(""+this.traceId,")")}},{key:"spanId",get:function(){return this._spanId}},{key:"parentId",get:function(){return this._parentId.getOrElse(this.spanId)}},{key:"traceId",get:function(){return this._traceId.getOrElse(this.parentId)}},{key:"sampled",get:function(){return this.isDebug()?new It(!0):this._sampled}},{key:"flags",get:function(){return this._flags}}]),t}();var Rt=function(){for(var t="",e=0;16>e;e++)t+="0123456789abcdef"[Math.floor(16*Math.random())];return t},Tt=void 0!==j&&j.hrtime;var _t={now:Tt?function(t,e){if(t&&e){var r=j.hrtime(e);return t+Math.floor(1e6*r[0]+r[1]/1e3)}return 1e3*Date.now()}:function(){return 1e3*Date.now()},hrtime:Tt?function(){return j.hrtime()}:function(){}};function kt(t){var e=t.ipv4,r=t.port;this.setServiceName(t.serviceName),this.setIpv4(e),this.setPort(r)}function Ot(t,e){this.timestamp=t,this.value=""+e}function Pt(t){var e=this;this.traceId=t.traceId,t._parentId.ifPresent(function(t){e.parentId=t}),this.id=t.spanId,this.name=void 0,this.kind=void 0,this.timestamp=void 0,this.duration=void 0,this.localEndpoint=void 0,this.remoteEndpoint=void 0,this.annotations=[],this.tags={},this.debug=t.isDebug(),this.shared=!1}kt.prototype.setServiceName=function(t){this.serviceName=t?t.toLocaleLowerCase():void 0},kt.prototype.setIpv4=function(t){this.ipv4=t},kt.prototype.setPort=function(t){this.port=t||void 0},kt.prototype.isEmpty=function(){return void 0===this.serviceName&&void 0===this.ipv4&&void 0===this.port},Ot.prototype.toString=function(){return'Annotation(value="'.concat(this.value,'")')},Pt.prototype.setName=function(t){this.name=t?t.toLocaleLowerCase():void 0},Pt.prototype.setKind=function(t){this.kind=t},Pt.prototype.setTimestamp=function(t){this.timestamp=t},Pt.prototype.setDuration=function(t){void 0!==t&&(this.duration=Math.max(t,1))},Pt.prototype.setLocalEndpoint=function(t){this.localEndpoint=t&&!t.isEmpty()?t:void 0},Pt.prototype.setRemoteEndpoint=function(t){this.remoteEndpoint=t&&!t.isEmpty()?t:void 0},Pt.prototype.addAnnotation=function(t,e){this.annotations.push(new Ot(t,e))},Pt.prototype.putTag=function(t,e){this.tags[t]=""+e},Pt.prototype.setDebug=function(t){this.debug=t},Pt.prototype.setShared=function(t){this.shared=t},Pt.prototype.toString=function(){var t=this.annotations.map(function(t){return""+t}).join(", ");return"Span(id=".concat(this.traceId,", annotations=[").concat(t,"])")};var Ct={Endpoint:kt,Span:Pt},Nt=function(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then};var Ut=p.None,Bt=p.Some,xt=p.fromNullable,Lt=yt.Sampler,Mt=yt.alwaysSample,jt=_t.now,Dt=_t.hrtime,Yt=Ct.Endpoint;function qt(t){throw Error("Tracer: Missing required argument ".concat(t,"."))}var Ft=function(){function t(e){var n=e.ctxImpl,o=void 0===n?qt("ctxImpl"):n,i=e.recorder,a=void 0===i?qt("recorder"):i,s=e.sampler,u=void 0===s?new Lt(Mt):s,c=e.traceId128Bit,h=void 0!==c&&c,f=e.supportsJoin,p=void 0===f||f,l=e.localServiceName,d=e.localEndpoint,v=e.log,m=void 0===v?console:v,g=e.defaultTags;r(this,t),this.log=m,this.recorder=a,this.sampler=u,this.traceId128Bit=h,this.supportsJoin=p,this._localEndpoint=d||new Yt({serviceName:l||"unknown"}),this._ctxImpl=o,this._defaultTraceId=this.createRootId(),this._startTimestamp=jt(),this._startTick=Dt(),this.recorder.setDefaultTags&&this.recorder.setDefaultTags(g)}return o(t,[{key:"scoped",value:function(t){return this._ctxImpl.scoped(t)}},{key:"letId",value:function(t,e){return this._ctxImpl.letContext(t,e)}},{key:"createRootId",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ut,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=Rt(),n=this.traceId128Bit?new Bt(Rt()+r):Ut,o=new At({traceId:n,parentId:Ut,spanId:r,sampled:t,flags:e?1:0});return t===Ut&&(o._sampled=this.sampler.shouldSample(o)),o}},{key:"createChildId",value:function(){var t=xt(this._ctxImpl.getContext()),e=new At({traceId:t.map(function(t){return t.traceId}),parentId:t.map(function(t){return t.spanId}),spanId:Rt(),sampled:t.flatMap(function(t){return t.sampled}),flags:t.map(function(t){return t.flags}).getOrElse(0)});return!1===e.sampled.present&&(e._sampled=this.sampler.shouldSample(e)),e}},{key:"local",value:function(t,e){var r=this;if("function"!=typeof e)throw Error("you must pass a function");return this.scoped(function(){var n,o=r.createChildId();r.setId(o),r.recordServiceName(r._localEndpoint.serviceName),r.recordAnnotation(new lt.LocalOperationStart(t));try{n=e()}catch(t){throw r.recordBinary("error",t.message?t.message:""+t),r.recordAnnotation(new lt.LocalOperationStop),t}if(!Nt(n))return r.recordAnnotation(new lt.LocalOperationStop),n;if(!o.sampled.getOrElse(!1))return n;var i=function(t){return r.recorder.record(new wt({traceId:o,timestamp:jt(r._startTimestamp,r._startTick),annotation:t}))};return n.then(function(t){return i(new lt.LocalOperationStop),t}).catch(function(t){throw i(new lt.BinaryAnnotation("error",t.message?t.message:""+t)),i(new lt.LocalOperationStop),t})})}},{key:"join",value:function(t){var e=this;if(!(t instanceof At))throw Error("Must be valid TraceId instance");return t._sampled===Ut&&(t._sampled=this.sampler.shouldSample(t)),this.supportsJoin?t:this.letId(t,function(){return e.createChildId()})}},{key:"setId",value:function(t){this._ctxImpl.setContext(t)}},{key:"recordAnnotation",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:jt(this._startTimestamp,this._startTick);this.id.sampled.ifPresent(function(n){n&&e.recorder.record(new wt({traceId:e.id,timestamp:r,annotation:t}))})}},{key:"recordMessage",value:function(t){this.recordAnnotation(new lt.Message(t))}},{key:"recordServiceName",value:function(t){this.recordAnnotation(new lt.ServiceName(t))}},{key:"recordRpc",value:function(t){this.recordAnnotation(new lt.Rpc(t))}},{key:"recordClientAddr",value:function(t){this.recordAnnotation(new lt.ClientAddr(t))}},{key:"recordServerAddr",value:function(t){this.recordAnnotation(new lt.ServerAddr(t))}},{key:"recordLocalAddr",value:function(t){this.recordAnnotation(new lt.LocalAddr(t))}},{key:"recordBinary",value:function(t,e){this.recordAnnotation(new lt.BinaryAnnotation(t,e))}},{key:"writeIdToConsole",value:function(t){this.log.info("".concat(t,": ").concat(""+this.id))}},{key:"setTags",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var e in t)t.hasOwnProperty(e)&&this.recordBinary(e,t[e])}},{key:"id",get:function(){return this._ctxImpl.getContext()||this._defaultTraceId}},{key:"localEndpoint",get:function(){return this._localEndpoint}}]),t}(),zt=function(){function t(){r(this,t),this.currentCtx=null}return o(t,[{key:"setContext",value:function(t){this.currentCtx=t}},{key:"getContext",value:function(){return this.currentCtx}},{key:"scoped",value:function(t){var e=this.currentCtx,r=t();return this.currentCtx=e,r}},{key:"letContext",value:function(t,e){var r=this;return this.scoped(function(){return r.setContext(t),e()})}}]),t}(),Kt={TraceId:"X-B3-TraceId",SpanId:"X-B3-SpanId",ParentSpanId:"X-B3-ParentSpanId",Sampled:"X-B3-Sampled",Flags:"X-B3-Flags"},Ht=_t.now,Vt=_t.hrtime,Jt=Ct.Span,Xt=Ct.Endpoint,Zt=6e7,$t=Symbol("defaultTags"),Gt=function(){function t(e){r(this,t),this.traceId=e,this.startTimestamp=Ht(),this.startTick=Vt(),this.delegate=new Jt(e),this.localEndpoint=new Xt({})}return o(t,[{key:"finish",value:function(){this.endTimestamp||(this.endTimestamp=Ht(this.startTimestamp,this.startTick))}}],[{key:"create",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new t(e);for(var o in r)r.hasOwnProperty(o)&&n.delegate.putTag(o,r[o]);return n}}]),t}(),Qt=function(){function t(e){var n=this,o=e.logger,i=e.timeout,a=void 0===i?Zt:i;r(this,t),this.logger=o,this.timeout=a,this.partialSpans=new Map,this[$t]={};var s=setInterval(function(){n.partialSpans.forEach(function(t,e){n._timedOut(t)&&n._writeSpan(e)})},1e3);s.unref&&s.unref()}return o(t,[{key:"_writeSpan",value:function(t){var e=this.partialSpans.get(t);if(void 0!==e){this.partialSpans.delete(t);var r=e.delegate;r.setLocalEndpoint(e.localEndpoint),e.endTimestamp&&(r.setTimestamp(e.startTimestamp),r.setDuration(e.endTimestamp-e.startTimestamp)),this.logger.logSpan(r)}}},{key:"_updateSpanMap",value:function(t,e){var r;e(r=this.partialSpans.has(t)?this.partialSpans.get(t):Gt.create(t,this[$t])),r.endTimestamp?this._writeSpan(t):this.partialSpans.set(t,r)}},{key:"_timedOut",value:function(t){return t.startTimestamp+this.timeout<Ht()}},{key:"record",value:function(t){var e=t.traceId;this._updateSpanMap(e,function(r){switch(t.annotation.annotationType){case"ClientSend":r.delegate.setKind("CLIENT");break;case"ClientRecv":r.finish(),r.delegate.setKind("CLIENT");break;case"ServerSend":r.finish(),r.delegate.setKind("SERVER");break;case"ServerRecv":r.delegate.setShared(e.parentId!==e.spanId),r.delegate.setKind("CLIENT");break;case"ProducerStart":r.delegate.setKind("PRODUCER");break;case"ProducerStop":r.finish(),r.delegate.setKind("PRODUCER");break;case"ConsumerStart":r.delegate.setKind("CONSUMER");break;case"ConsumerStop":r.finish(),r.delegate.setKind("CONSUMER");break;case"MessageAddr":r.delegate.setRemoteEndpoint(new Xt({serviceName:t.annotation.serviceName,ipv4:t.annotation.host&&t.annotation.host.ipv4(),port:t.annotation.port}));break;case"LocalOperationStart":r.delegate.setName(t.annotation.name);break;case"LocalOperationStop":r.finish();break;case"Message":r.delegate.addAnnotation(t.timestamp,t.annotation.message);break;case"Rpc":r.delegate.setName(t.annotation.name);break;case"ServiceName":r.localEndpoint.setServiceName(t.annotation.serviceName);break;case"BinaryAnnotation":r.delegate.putTag(t.annotation.key,t.annotation.value);break;case"LocalAddr":r.localEndpoint.setIpv4(t.annotation.host&&t.annotation.host.ipv4()),r.localEndpoint.setPort(t.annotation.port);break;case"ServerAddr":r.delegate.setKind("CLIENT"),r.delegate.setRemoteEndpoint(new Xt({serviceName:t.annotation.serviceName,ipv4:t.annotation.host&&t.annotation.host.ipv4(),port:t.annotation.port}))}})}},{key:"setDefaultTags",value:function(t){this[$t]=t}},{key:"toString",value:function(){return"BatchRecorder()"}}]),t}(),Wt=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:console.log;r(this,t),this.logger=e}return o(t,[{key:"record",value:function(t){var e=t.traceId,r=e.parentId,n=e.traceId;this.logger("Record at (spanId=".concat(e.spanId,", parentId=").concat(r,", ")+"traceId=".concat(n,"): ").concat(""+t.annotation))}},{key:"toString",value:function(){return"consoleTracer"}}]),t}(),te=2147483647,ee=36,re=1,ne=26,oe=38,ie=700,ae=72,se=128,ue="-",ce=/[^\x20-\x7E]/,he=/[\x2E\u3002\uFF0E\uFF61]/g,fe={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},pe=ee-re,le=Math.floor,de=String.fromCharCode;function ve(t){throw new RangeError(fe[t])}function me(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function ge(t,e,r){var n=0;for(t=r?le(t/ie):t>>1,t+=le(t/e);t>pe*ne>>1;n+=ee)t=le(t/pe);return le(n+(pe+1)*t/(t+oe))}function ye(t){return function(t,e){var r=t.split("@"),n="";r.length>1&&(n=r[0]+"@",t=r[1]);var o=function(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}((t=t.replace(he,".")).split("."),e).join(".");return n+o}(t,function(t){return ce.test(t)?"xn--"+function(t){var e,r,n,o,i,a,s,u,c,h,f,p,l,d,v,m=[];for(p=(t=function(t){for(var e,r,n=[],o=0,i=t.length;i>o;)55296>(e=t.charCodeAt(o++))||e>56319||o>=i?n.push(e):56320==(64512&(r=t.charCodeAt(o++)))?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),o--);return n}(t)).length,e=se,r=0,i=ae,a=0;p>a;++a)128>(f=t[a])&&m.push(de(f));for(n=o=m.length,o&&m.push(ue);p>n;){for(s=te,a=0;p>a;++a)(f=t[a])>=e&&s>f&&(s=f);for(s-e>le((te-r)/(l=n+1))&&ve("overflow"),r+=(s-e)*l,e=s,a=0;p>a;++a)if(e>(f=t[a])&&++r>te&&ve("overflow"),f==e){for(u=r,c=ee;(h=c>i?i+ne>c?c-i:ne:re)<=u;c+=ee)m.push(de(me(h+(v=u-h)%(d=ee-h),0))),u=le(v/d);m.push(de(me(u,0))),i=ge(r,l,n==o),r=0,++n}++r,++e}return m.join("")}(t):t})}var we=[],Ie=[],Ee="undefined"!=typeof Uint8Array?Uint8Array:Array,be=!1;function Se(){be=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;64>e;++e)we[e]=t[e],Ie[t.charCodeAt(e)]=e;Ie[45]=62,Ie[95]=63}function Ae(t,e,r){for(var n,o=[],i=e;r>i;i+=3)o.push(we[(n=(t[i]<<16)+(t[i+1]<<8)+t[i+2])>>18&63]+we[n>>12&63]+we[n>>6&63]+we[63&n]);return o.join("")}function Re(t){var e;be||Se();for(var r=t.length,n=r%3,o="",i=[],a=0,s=r-n;s>a;a+=16383)i.push(Ae(t,a,a+16383>s?s:a+16383));return 1===n?(o+=we[(e=t[r-1])>>2],o+=we[e<<4&63],o+="=="):2===n&&(o+=we[(e=(t[r-2]<<8)+t[r-1])>>10],o+=we[e>>4&63],o+=we[e<<2&63],o+="="),i.push(o),i.join("")}function Te(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<<s)-1,c=u>>1,h=-7,f=r?o-1:0,p=r?-1:1,l=t[e+f];for(f+=p,i=l&(1<<-h)-1,l>>=-h,h+=s;h>0;i=256*i+t[e+f],f+=p,h-=8);for(a=i&(1<<-h)-1,i>>=-h,h+=n;h>0;a=256*a+t[e+f],f+=p,h-=8);if(0===i)i=1-c;else{if(i===u)return a?NaN:1/0*(l?-1:1);a+=Math.pow(2,n),i-=c}return(l?-1:1)*a*Math.pow(2,i-n)}function _e(t,e,r,n,o,i){var a,s,u,c=8*i-o-1,h=(1<<c)-1,f=h>>1,p=23===o?5.960464477539062e-8:0,l=n?0:i-1,d=n?1:-1,v=0>e||0===e&&0>1/e?1:0;for(isNaN(e=Math.abs(e))||e===1/0?(s=isNaN(e)?1:0,a=h):(1>e*(u=Math.pow(2,-(a=Math.floor(Math.log(e)/Math.LN2))))&&(a--,u*=2),2>(e+=1>a+f?p*Math.pow(2,1-f):p/u)*u||(a++,u/=2),h>a+f?1>a+f?(s=e*Math.pow(2,f-1)*Math.pow(2,o),a=0):(s=(e*u-1)*Math.pow(2,o),a+=f):(s=0,a=h));o>=8;t[r+l]=255&s,l+=d,s/=256,o-=8);for(a=a<<o|s,c+=o;c>0;t[r+l]=255&a,l+=d,a/=256,c-=8);t[r+l-d]|=128*v}var ke={}.toString,Oe=Array.isArray||function(t){return"[object Array]"==ke.call(t)};function Pe(){return Ne.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ce(t,e){if(Pe()<e)throw new RangeError("Invalid typed array length");return Ne.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=Ne.prototype:(null===t&&(t=new Ne(e)),t.length=e),t}function Ne(t,e,r){if(!(Ne.TYPED_ARRAY_SUPPORT||this instanceof Ne))return new Ne(t,e,r);if("number"==typeof t){if("string"==typeof e)throw Error("If encoding is specified then the first argument must be a string");return xe(this,t)}return Ue(this,t,e,r)}function Ue(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(0>r||r>e.byteLength)throw new RangeError("'offset' is out of bounds");if(r+(n||0)>e.byteLength)throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);Ne.TYPED_ARRAY_SUPPORT?(t=e).__proto__=Ne.prototype:t=Le(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!Ne.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|De(e,r),o=(t=Ce(t,n)).write(e,r);o!==n&&(t=t.slice(0,o));return t}(t,e,r):function(t,e){if(je(e)){var r=0|Me(e.length);return 0===(t=Ce(t,r)).length?t:(e.copy(t,0,0,r),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?Ce(t,0):Le(t,e);if("Buffer"===e.type&&Oe(e.data))return Le(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function Be(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(0>t)throw new RangeError('"size" argument must not be negative')}function xe(t,e){if(Be(e),t=Ce(t,0>e?0:0|Me(e)),!Ne.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;++r)t[r]=0;return t}function Le(t,e){var r=0>e.length?0:0|Me(e.length);t=Ce(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function Me(t){if(t>=Pe())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Pe().toString(16)+" bytes");return 0|t}function je(t){return!(null==t||!t._isBuffer)}function De(t,e){if(je(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return fr(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return pr(t).length;default:if(n)return fr(t).length;e=(""+e).toLowerCase(),n=!0}}function Ye(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function qe(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:-2147483648>r&&(r=-2147483648),isNaN(r=+r)&&(r=o?0:t.length-1),0>r&&(r=t.length+r),t.length>r){if(0>r){if(!o)return-1;r=0}}else{if(o)return-1;r=t.length-1}if("string"==typeof e&&(e=Ne.from(e,n)),je(e))return 0===e.length?-1:Fe(t,e,r,n,o);if("number"==typeof e)return e&=255,Ne.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Fe(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function Fe(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=(n+"").toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(2>t.length||2>e.length)return-1;a=2,s/=2,u/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var h=-1;for(i=r;s>i;i++)if(c(t,i)===c(e,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===u)return h*a}else-1!==h&&(i-=i-h),h=-1}else for(r+u>s&&(r=s-u),i=r;i>=0;i--){for(var f=!0,p=0;u>p;p++)if(c(t,i+p)!==c(e,p)){f=!1;break}if(f)return i}return-1}function ze(t,e,r,n){var o=t.length-(r=+r||0);n?(n=+n)>o&&(n=o):n=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var a=0;n>a;++a){var s=parseInt(e.substr(2*a,2),16);if(isNaN(s))return a;t[r+a]=s}return a}function Ke(t,e,r,n){return lr(fr(e,t.length-r),t,r,n)}function He(t,e,r,n){return lr(function(t){for(var e=[],r=0;t.length>r;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function Ve(t,e,r,n){return He(t,e,r,n)}function Je(t,e,r,n){return lr(pr(e),t,r,n)}function Xe(t,e,r,n){return lr(function(t,e){for(var r,n,o=[],i=0;t.length>i&&0<=(e-=2);++i)r=t.charCodeAt(i),n=r>>8,o.push(r%256),o.push(n);return o}(e,t.length-r),t,r,n)}function Ze(t,e,r){return Re(0===e&&r===t.length?t:t.slice(e,r))}function $e(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;r>o;){var i,a,s,u,c=t[o],h=null,f=c>239?4:c>223?3:c>191?2:1;if(r>=o+f)switch(f){case 1:128>c&&(h=c);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(h=u);break;case 3:a=t[o+2],128==(192&(i=t[o+1]))&&128==(192&a)&&(u=(15&c)<<12|(63&i)<<6|63&a)>2047&&(55296>u||u>57343)&&(h=u);break;case 4:a=t[o+2],s=t[o+3],128==(192&(i=t[o+1]))&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&1114112>u&&(h=u)}null===h?(h=65533,f=1):h>65535&&(n.push((h-=65536)>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=f}return function(t){var e=t.length;if(Ge>=e)return String.fromCharCode.apply(String,t);var r="",n=0;for(;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Ge));return r}(n)}Ne.TYPED_ARRAY_SUPPORT=void 0===l.TYPED_ARRAY_SUPPORT||l.TYPED_ARRAY_SUPPORT,Ne.poolSize=8192,Ne._augment=function(t){return t.__proto__=Ne.prototype,t},Ne.from=function(t,e,r){return Ue(null,t,e,r)},Ne.TYPED_ARRAY_SUPPORT&&(Ne.prototype.__proto__=Uint8Array.prototype,Ne.__proto__=Uint8Array),Ne.alloc=function(t,e,r){return function(t,e,r,n){return Be(e),e>0&&void 0!==r?"string"==typeof n?Ce(t,e).fill(r,n):Ce(t,e).fill(r):Ce(t,e)}(null,t,e,r)},Ne.allocUnsafe=function(t){return xe(null,t)},Ne.allocUnsafeSlow=function(t){return xe(null,t)},Ne.isBuffer=function(t){return null!=t&&(!!t._isBuffer||dr(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&dr(t.slice(0,0))}(t))},Ne.compare=function(t,e){if(!je(t)||!je(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);i>o;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return n>r?-1:r>n?1:0},Ne.isEncoding=function(t){switch((t+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Ne.concat=function(t,e){if(!Oe(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return Ne.alloc(0);var r;if(void 0===e)for(e=0,r=0;t.length>r;++r)e+=t[r].length;var n=Ne.allocUnsafe(e),o=0;for(r=0;t.length>r;++r){var i=t[r];if(!je(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},Ne.byteLength=De,Ne.prototype._isBuffer=!0,Ne.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;t>e;e+=2)Ye(this,e,e+1);return this},Ne.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;t>e;e+=4)Ye(this,e,e+3),Ye(this,e+1,e+2);return this},Ne.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;t>e;e+=8)Ye(this,e,e+7),Ye(this,e+1,e+6),Ye(this,e+2,e+5),Ye(this,e+3,e+4);return this},Ne.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?$e(this,0,t):function(t,e,r){var n=!1;if((void 0===e||0>e)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),0>=r)return"";if((e>>>=0)>=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return tr(this,e,r);case"utf8":case"utf-8":return $e(this,e,r);case"ascii":return Qe(this,e,r);case"latin1":case"binary":return We(this,e,r);case"base64":return Ze(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return er(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},Ne.prototype.equals=function(t){if(!je(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Ne.compare(this,t)},Ne.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},Ne.prototype.compare=function(t,e,r,n,o){if(!je(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),0>e||r>t.length||0>n||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(i,a),u=this.slice(n,o),c=t.slice(e,r),h=0;s>h;++h)if(u[h]!==c[h]){i=u[h],a=c[h];break}return a>i?-1:i>a?1:0},Ne.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},Ne.prototype.indexOf=function(t,e,r){return qe(this,t,e,r,!0)},Ne.prototype.lastIndexOf=function(t,e,r){return qe(this,t,e,r,!1)},Ne.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return ze(this,t,e,r);case"utf8":case"utf-8":return Ke(this,t,e,r);case"ascii":return He(this,t,e,r);case"latin1":case"binary":return Ve(this,t,e,r);case"base64":return Je(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Xe(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},Ne.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Ge=4096;function Qe(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;r>o;++o)n+=String.fromCharCode(127&t[o]);return n}function We(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;r>o;++o)n+=String.fromCharCode(t[o]);return n}function tr(t,e,r){var n=t.length;e&&e>=0||(e=0),(!r||0>r||r>n)&&(r=n);for(var o="",i=e;r>i;++i)o+=hr(t[i]);return o}function er(t,e,r){for(var n=t.slice(e,r),o="",i=0;n.length>i;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function rr(t,e,r){if(t%1!=0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function nr(t,e,r,n,o,i){if(!je(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||i>e)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function or(t,e,r,n){0>e&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);i>o;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function ir(t,e,r,n){0>e&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);i>o;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function ar(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("Index out of range")}function sr(t,e,r,n,o){return o||ar(t,0,r,4),_e(t,e,r,n,23,4),r+4}function ur(t,e,r,n,o){return o||ar(t,0,r,8),_e(t,e,r,n,52,8),r+8}Ne.prototype.slice=function(t,e){var r,n=this.length;if(0>(t=~~t)?0>(t+=n)&&(t=0):t>n&&(t=n),0>(e=void 0===e?n:~~e)?0>(e+=n)&&(e=0):e>n&&(e=n),t>e&&(e=t),Ne.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=Ne.prototype;else{var o=e-t;r=new Ne(o,void 0);for(var i=0;o>i;++i)r[i]=this[i+t]}return r},Ne.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},Ne.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},Ne.prototype.readUInt8=function(t,e){return e||rr(t,1,this.length),this[t]},Ne.prototype.readUInt16LE=function(t,e){return e||rr(t,2,this.length),this[t]|this[t+1]<<8},Ne.prototype.readUInt16BE=function(t,e){return e||rr(t,2,this.length),this[t]<<8|this[t+1]},Ne.prototype.readUInt32LE=function(t,e){return e||rr(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Ne.prototype.readUInt32BE=function(t,e){return e||rr(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Ne.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return(o*=128)>n||(n-=Math.pow(2,8*e)),n},Ne.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return(o*=128)>i||(i-=Math.pow(2,8*e)),i},Ne.prototype.readInt8=function(t,e){return e||rr(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Ne.prototype.readInt16LE=function(t,e){e||rr(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Ne.prototype.readInt16BE=function(t,e){e||rr(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Ne.prototype.readInt32LE=function(t,e){return e||rr(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Ne.prototype.readInt32BE=function(t,e){return e||rr(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Ne.prototype.readFloatLE=function(t,e){return e||rr(t,4,this.length),Te(this,t,!0,23,4)},Ne.prototype.readFloatBE=function(t,e){return e||rr(t,4,this.length),Te(this,t,!1,23,4)},Ne.prototype.readDoubleLE=function(t,e){return e||rr(t,8,this.length),Te(this,t,!0,52,8)},Ne.prototype.readDoubleBE=function(t,e){return e||rr(t,8,this.length),Te(this,t,!1,52,8)},Ne.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||nr(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},Ne.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||nr(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},Ne.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,1,255,0),Ne.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},Ne.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,2,65535,0),Ne.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):or(this,t,e,!0),e+2},Ne.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,2,65535,0),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):or(this,t,e,!1),e+2},Ne.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,4,4294967295,0),Ne.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):ir(this,t,e,!0),e+4},Ne.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,4,4294967295,0),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):ir(this,t,e,!1),e+4},Ne.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);nr(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i<r&&(a*=256);)0>t&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},Ne.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);nr(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)0>t&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},Ne.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,1,127,-128),Ne.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},Ne.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,2,32767,-32768),Ne.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):or(this,t,e,!0),e+2},Ne.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,2,32767,-32768),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):or(this,t,e,!1),e+2},Ne.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,4,2147483647,-2147483648),Ne.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):ir(this,t,e,!0),e+4},Ne.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):ir(this,t,e,!1),e+4},Ne.prototype.writeFloatLE=function(t,e,r){return sr(this,t,e,!0,r)},Ne.prototype.writeFloatBE=function(t,e,r){return sr(this,t,e,!1,r)},Ne.prototype.writeDoubleLE=function(t,e,r){return ur(this,t,e,!0,r)},Ne.prototype.writeDoubleBE=function(t,e,r){return ur(this,t,e,!1,r)},Ne.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),t.length>e||(e=t.length),e||(e=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),n-r>t.length-e&&(n=t.length-e+r);var o,i=n-r;if(this===t&&e>r&&n>e)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(1e3>i||!Ne.TYPED_ARRAY_SUPPORT)for(o=0;i>o;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},Ne.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);256>o&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Ne.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(0>e||e>this.length||r>this.length)throw new RangeError("Out of range index");if(e>=r)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;r>i;++i)this[i]=t;else{var a=je(t)?t:fr(""+new Ne(t,n)),s=a.length;for(i=0;r-e>i;++i)this[i+e]=a[i%s]}return this};var cr=/[^+\/0-9A-Za-z-_]/g;function hr(t){return 16>t?"0"+t.toString(16):t.toString(16)}function fr(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],a=0;n>a;++a){if((r=t.charCodeAt(a))>55295&&57344>r){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(56320>r){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,128>r){if(0>(e-=1))break;i.push(r)}else if(2048>r){if(0>(e-=2))break;i.push(r>>6|192,63&r|128)}else if(65536>r){if(0>(e-=3))break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(r>=1114112)throw Error("Invalid code point");if(0>(e-=4))break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function pr(t){return function(t){var e,r,n,o,i,a;be||Se();var s=t.length;if(s%4>0)throw Error("Invalid string. Length must be a multiple of 4");a=new Ee(3*s/4-(i="="===t[s-2]?2:"="===t[s-1]?1:0)),n=i>0?s-4:s;var u=0;for(e=0,r=0;n>e;e+=4,r+=3)o=Ie[t.charCodeAt(e)]<<18|Ie[t.charCodeAt(e+1)]<<12|Ie[t.charCodeAt(e+2)]<<6|Ie[t.charCodeAt(e+3)],a[u++]=o>>16&255,a[u++]=o>>8&255,a[u++]=255&o;return 2===i?(o=Ie[t.charCodeAt(e)]<<2|Ie[t.charCodeAt(e+1)]>>4,a[u++]=255&o):1===i&&(o=Ie[t.charCodeAt(e)]<<10|Ie[t.charCodeAt(e+1)]<<4|Ie[t.charCodeAt(e+2)]>>2,a[u++]=o>>8&255,a[u++]=255&o),a}(function(t){if(2>(t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(cr,"")).length)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function lr(t,e,r,n){for(var o=0;n>o&&(o+r<e.length&&o<t.length);++o)e[o+r]=t[o];return o}function dr(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function vr(t){return null===t}function mr(t){return"string"==typeof t}function gr(t){return"object"==typeof t&&null!==t}function yr(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var wr=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function Ir(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}}function Er(t,e){if(t.map)return t.map(e);for(var r=[],n=0;t.length>n;n++)r.push(e(t[n],n));return r}var br=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return e};function Sr(t,e,r,n){r=r||"=";var o={};if("string"!=typeof t||0===t.length)return o;var i=/\+/g;t=t.split(e=e||"&");var a=1e3;n&&"number"==typeof n.maxKeys&&(a=n.maxKeys);var s=t.length;a>0&&s>a&&(s=a);for(var u=0;s>u;++u){var c,h,f,p,l=t[u].replace(i,"%20"),d=l.indexOf(r);0>d?(c=l,h=""):(c=l.substr(0,d),h=l.substr(d+1)),f=decodeURIComponent(c),p=decodeURIComponent(h),yr(o,f)?wr(o[f])?o[f].push(p):o[f]=[o[f],p]:o[f]=p}return o}var Ar={parse:Dr,resolve:function(t,e){return Dr(t,!1,!0).resolve(e)},resolveObject:function(t,e){return t?Dr(t,!1,!0).resolveObject(e):e},format:function(t){mr(t)&&(t=Yr({},t));return qr(t)},Url:Rr};function Rr(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var Tr=/^([a-z0-9.+-]+:)/i,_r=/:[0-9]*$/,kr=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Or=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),Pr=["'"].concat(Or),Cr=["%","/","?",";","#"].concat(Pr),Nr=["/","?","#"],Ur=255,Br=/^[+a-z0-9A-Z_-]{0,63}$/,xr=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Lr={javascript:!0,"javascript:":!0},Mr={javascript:!0,"javascript:":!0},jr={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function Dr(t,e,r){if(t&&gr(t)&&t instanceof Rr)return t;var n=new Rr;return n.parse(t,e,r),n}function Yr(t,e,r,n){if(!mr(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),i=-1!==o&&o<e.indexOf("#")?"?":"#",a=e.split(i);a[0]=a[0].replace(/\\/g,"/");var s=e=a.join(i);if(s=s.trim(),!n&&1===e.split("#").length){var u=kr.exec(s);if(u)return t.path=s,t.href=s,t.pathname=u[1],u[2]?(t.search=u[2],t.query=r?Sr(t.search.substr(1)):t.search.substr(1)):r&&(t.search="",t.query={}),t}var c,h,f,p=Tr.exec(s);if(p){var l=(p=p[0]).toLowerCase();t.protocol=l,s=s.substr(p.length)}if(n||p||s.match(/^\/\/[^@\/]+@[^@\/]+/)){var d="//"===s.substr(0,2);!d||p&&Mr[p]||(s=s.substr(2),t.slashes=!0)}if(!Mr[p]&&(d||p&&!jr[p])){var v,m,g=-1;for(c=0;Nr.length>c;c++)-1===(h=s.indexOf(Nr[c]))||-1!==g&&h>=g||(g=h);for(-1!==(m=-1===g?s.lastIndexOf("@"):s.lastIndexOf("@",g))&&(v=s.slice(0,m),s=s.slice(m+1),t.auth=decodeURIComponent(v)),g=-1,c=0;Cr.length>c;c++)-1===(h=s.indexOf(Cr[c]))||-1!==g&&h>=g||(g=h);-1===g&&(g=s.length),t.host=s.slice(0,g),s=s.slice(g),Fr(t),t.hostname=t.hostname||"";var y="["===t.hostname[0]&&"]"===t.hostname[t.hostname.length-1];if(!y){var w=t.hostname.split(/\./);for(c=0,f=w.length;f>c;c++){var I=w[c];if(I&&!I.match(Br)){for(var E="",b=0,S=I.length;S>b;b++)I.charCodeAt(b)>127?E+="x":E+=I[b];if(!E.match(Br)){var A=w.slice(0,c),R=w.slice(c+1),T=I.match(xr);T&&(A.push(T[1]),R.unshift(T[2])),R.length&&(s="/"+R.join(".")+s),t.hostname=A.join(".");break}}}}t.hostname=t.hostname.length>Ur?"":t.hostname.toLowerCase(),y||(t.hostname=ye(t.hostname)),t.host=(t.hostname||"")+(t.port?":"+t.port:""),t.href+=t.host,y&&(t.hostname=t.hostname.substr(1,t.hostname.length-2),"/"!==s[0]&&(s="/"+s))}if(!Lr[l])for(c=0,f=Pr.length;f>c;c++){var _=Pr[c];if(-1!==s.indexOf(_)){var k=encodeURIComponent(_);k===_&&(k=escape(_)),s=s.split(_).join(k)}}var O=s.indexOf("#");-1!==O&&(t.hash=s.substr(O),s=s.slice(0,O));var P=s.indexOf("?");(-1!==P?(t.search=s.substr(P),t.query=s.substr(P+1),r&&(t.query=Sr(t.query)),s=s.slice(0,P)):r&&(t.search="",t.query={}),s&&(t.pathname=s),jr[l]&&t.hostname&&!t.pathname&&(t.pathname="/"),t.pathname||t.search)&&(t.path=(t.pathname||"")+(t.search||""));return t.href=qr(t),t}function qr(t){var e=t.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var r,n,o,i,a=t.protocol||"",s=t.pathname||"",u=t.hash||"",c=!1,h="";t.host?c=e+t.host:t.hostname&&(c=e+(-1===t.hostname.indexOf(":")?t.hostname:"["+this.hostname+"]"),t.port&&(c+=":"+t.port)),t.query&&gr(t.query)&&Object.keys(t.query).length&&(n=n||"&",o=o||"=",null===(r=t.query)&&(r=void 0),h="object"==typeof r?Er(br(r),function(t){var e=encodeURIComponent(Ir(t))+o;return wr(r[t])?Er(r[t],function(t){return e+encodeURIComponent(Ir(t))}).join(n):e+encodeURIComponent(Ir(r[t]))}).join(n):i?encodeURIComponent(Ir(i))+o+encodeURIComponent(Ir(r)):"");var f=t.search||h&&"?"+h||"";return a&&":"!==a.substr(-1)&&(a+=":"),t.slashes||(!a||jr[a])&&!1!==c?(c="//"+(c||""),s&&"/"!==s.charAt(0)&&(s="/"+s)):c||(c=""),u&&"#"!==u.charAt(0)&&(u="#"+u),f&&"?"!==f.charAt(0)&&(f="?"+f),a+c+(s=s.replace(/[?#]/g,function(t){return encodeURIComponent(t)}))+(f=f.replace("#","%23"))+u}function Fr(t){var e=t.host,r=_r.exec(e);r&&(":"!==(r=r[0])&&(t.port=r.substr(1)),e=e.substr(0,e.length-r.length)),e&&(t.hostname=e)}Rr.prototype.parse=function(t,e,r){return Yr(this,t,e,r)},Rr.prototype.format=function(){return qr(this)},Rr.prototype.resolve=function(t){return this.resolveObject(Dr(t,!1,!0)).format()},Rr.prototype.resolveObject=function(t){if(mr(t)){var e=new Rr;e.parse(t,!1,!0),t=e}for(var r,n=new Rr,o=Object.keys(this),i=0;o.length>i;i++){var a=o[i];n[a]=this[a]}if(n.hash=t.hash,""===t.href)return n.href=n.format(),n;if(t.slashes&&!t.protocol){for(var s=Object.keys(t),u=0;s.length>u;u++){var c=s[u];"protocol"!==c&&(n[c]=t[c])}return jr[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(t.protocol&&t.protocol!==n.protocol){if(!jr[t.protocol]){for(var h=Object.keys(t),f=0;h.length>f;f++){var p=h[f];n[p]=t[p]}return n.href=n.format(),n}if(n.protocol=t.protocol,t.host||Mr[t.protocol])n.pathname=t.pathname;else{for(r=(t.pathname||"").split("/");r.length&&!(t.host=r.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==r[0]&&r.unshift(""),2>r.length&&r.unshift(""),n.pathname=r.join("/")}if(n.search=t.search,n.query=t.query,n.host=t.host||"",n.auth=t.auth,n.hostname=t.hostname||t.host,n.port=t.port,n.pathname||n.search)n.path=(n.pathname||"")+(n.search||"");return n.slashes=n.slashes||t.slashes,n.href=n.format(),n}var l,d=n.pathname&&"/"===n.pathname.charAt(0),v=t.host||t.pathname&&"/"===t.pathname.charAt(0),m=v||d||n.host&&t.pathname,g=m,y=n.pathname&&n.pathname.split("/")||[],w=n.protocol&&!jr[n.protocol];if(r=t.pathname&&t.pathname.split("/")||[],w&&(n.hostname="",n.port=null,n.host&&(""===y[0]?y[0]=n.host:y.unshift(n.host)),n.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===r[0]?r[0]=t.host:r.unshift(t.host)),t.host=null),m=m&&(""===r[0]||""===y[0])),v)n.host=t.host||""===t.host?t.host:n.host,n.hostname=t.hostname||""===t.hostname?t.hostname:n.hostname,n.search=t.search,n.query=t.query,y=r;else if(r.length)y||(y=[]),y.pop(),y=y.concat(r),n.search=t.search,n.query=t.query;else if(null!=t.search)return w&&(n.hostname=n.host=y.shift(),(l=!(!n.host||0>=n.host.indexOf("@"))&&n.host.split("@"))&&(n.auth=l.shift(),n.host=n.hostname=l.shift())),n.search=t.search,n.query=t.query,vr(n.pathname)&&vr(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!y.length)return n.pathname=null,n.path=n.search?"/"+n.search:null,n.href=n.format(),n;for(var I=y.slice(-1)[0],E=(n.host||t.host||y.length>1)&&("."===I||".."===I)||""===I,b=0,S=y.length;S>=0;S--)"."===(I=y[S])?y.splice(S,1):".."===I?(y.splice(S,1),b++):b&&(y.splice(S,1),b--);if(!m&&!g)for(;b--;b)y.unshift("..");!m||""===y[0]||y[0]&&"/"===y[0].charAt(0)||y.unshift(""),E&&"/"!==y.join("/").substr(-1)&&y.push("");var A=""===y[0]||y[0]&&"/"===y[0].charAt(0);return w&&(n.hostname=n.host=A?"":y.length?y.shift():"",(l=!(!n.host||0>=n.host.indexOf("@"))&&n.host.split("@"))&&(n.auth=l.shift(),n.host=n.hostname=l.shift())),(m=m||n.host&&y.length)&&!A&&y.unshift(""),y.length?n.pathname=y.join("/"):(n.pathname=null,n.path=null),vr(n.pathname)&&vr(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=t.auth||n.auth,n.slashes=n.slashes||t.slashes,n.href=n.format(),n},Rr.prototype.parseHost=function(){return Fr(this)};var zr=function(t){var e=Ar.parse(t);return{host:e.hostname,path:e.pathname}},Kr=p.Some,Hr=p.None;function Vr(t){return"1"===t||"true"===t}function Jr(t){try{return new Kr(parseInt(t))}catch(t){return Hr}}function Xr(t){throw Error("HttpServerInstrumentation: Missing required argument ".concat(t,"."))}var Zr={addZipkinHeaders:function(t,e){var r=function(t,e){var r=t.headers||{};return r[Kt.TraceId]=e.traceId,r[Kt.SpanId]=e.spanId,e._parentId.ifPresent(function(t){r[Kt.ParentSpanId]=t}),e.sampled.ifPresent(function(t){r[Kt.Sampled]=t?"1":"0"}),e.isDebug()&&(r[Kt.Flags]="1"),r}(t,e);return Object.assign({},t,{headers:r})}};var $r={HttpServer:function(){function t(e){var n=e.tracer,o=void 0===n?Xr("tracer"):n,i=e.serviceName,a=void 0===i?o.localEndpoint.serviceName:i,s=e.host,u=e.port,c=void 0===u?Xr("port"):u;r(this,t),this.tracer=o,this.serviceName=a,this.host=s&&new V(s),this.port=c}return o(t,[{key:"_createIdFromHeaders",value:function(t){if(function(t){return t(Kt.TraceId)!==Hr&&t(Kt.SpanId)!==Hr}(t)){var e=t(Kt.SpanId).map(function(e){var r=t(Kt.TraceId),n=t(Kt.ParentSpanId),o=t(Kt.Sampled),i=t(Kt.Flags).flatMap(Jr).getOrElse(0);return new At({traceId:r,parentId:n,spanId:e,sampled:o.map(Vr),flags:i})});return new Kr(this.tracer.join(e.getOrElse()))}if(t(Kt.Flags)!==Hr||t(Kt.Sampled)!==Hr){var r=t(Kt.Sampled)===Hr?Hr:t(Kt.Sampled).map(Vr),n=t(Kt.Flags).flatMap(Jr).getOrElse(0);return new Kr(this.tracer.createRootId(r,1===n))}return new Kr(this.tracer.createRootId())}},{key:"recordRequest",value:function(t,e,r){var n=this;this._createIdFromHeaders(r).ifPresent(function(t){return n.tracer.setId(t)});var o=this.tracer.id,i=zr(e).path;return this.tracer.recordServiceName(this.serviceName),this.tracer.recordRpc(t.toUpperCase()),this.tracer.recordBinary("http.path",i),this.tracer.recordAnnotation(new lt.ServerRecv),this.tracer.recordAnnotation(new lt.LocalAddr({host:this.host,port:this.port})),o}},{key:"recordResponse",value:function(t,e,r){this.tracer.setId(t),this.tracer.recordBinary("http.status_code",""+e),r?this.tracer.recordBinary("error",""+r):(200>e||e>399)&&this.tracer.recordBinary("error",""+e),this.tracer.recordAnnotation(new lt.ServerSend)}}]),t}(),HttpClient:function(){function t(e){var n=e.tracer,o=void 0===n?function(t){throw Error("HttpClientInstrumentation: Missing required argument ".concat(t,"."))}("tracer"):n,i=e.serviceName,a=void 0===i?o.localEndpoint.serviceName:i,s=e.remoteServiceName;r(this,t),this.tracer=o,this.serviceName=a,this.remoteServiceName=s}return o(t,[{key:"recordRequest",value:function(t,e,r){this.tracer.setId(this.tracer.createChildId());var n=this.tracer.id,o=zr(e).path;return this.tracer.recordServiceName(this.serviceName),this.tracer.recordRpc(r.toUpperCase()),this.tracer.recordBinary("http.path",o),this.tracer.recordAnnotation(new lt.ClientSend),this.remoteServiceName&&this.tracer.recordAnnotation(new lt.ServerAddr({serviceName:this.remoteServiceName})),Zr.addZipkinHeaders(t,n)}},{key:"recordResponse",value:function(t,e){this.tracer.setId(t),this.tracer.recordBinary("http.status_code",""+e),(200>e||e>399)&&this.tracer.recordBinary("error",""+e),this.tracer.recordAnnotation(new lt.ClientRecv)}},{key:"recordError",value:function(t,e){this.tracer.setId(t),this.tracer.recordBinary("error",""+e),this.tracer.recordAnnotation(new lt.ClientRecv)}}]),t}()};function Gr(t){if(void 0!==t){var e={serviceName:t.serviceName||""};return t.ipv4&&(e.ipv4=t.ipv4),t.port&&(e.port=t.port),e}}var Qr={JSON_V1:{encode:function(t){return function(t){var e={traceId:t.traceId};t.parentId&&(e.parentId=t.parentId),e.id=t.id,e.name=t.name||"",t.shared||(e.timestamp=t.timestamp,e.duration=t.duration);var r,n,o,i=Gr(t.localEndpoint);switch(t.kind){case"CLIENT":r=t.timestamp?"cs":void 0,n="cr",o="sa";break;case"SERVER":r=t.timestamp?"sr":void 0,n="ss",o="ca";break;case"PRODUCER":r=t.timestamp?"ms":void 0,n="ws",o="ma";break;case"CONSUMER":t.timestamp&&t.duration?(r="wr",n="mr"):t.timestamp&&(r="mr"),o="ma"}(t.annotations.length>0||r)&&(e.annotations=t.annotations.map(function(t){return function(t,e){return{value:t.value,timestamp:t.timestamp,endpoint:e}}(t,i)})),r&&(e.annotations.push({value:r,timestamp:t.timestamp,endpoint:i}),t.duration&&e.annotations.push({value:n,timestamp:t.timestamp+t.duration,endpoint:i}));var a=Object.keys(t.tags);if((a.length>0||t.remoteEndpoint)&&(e.binaryAnnotations=a.map(function(e){return{key:e,value:t.tags[e],endpoint:i}})),t.remoteEndpoint){var s={key:o,value:!0,endpoint:Gr(t.remoteEndpoint)};e.binaryAnnotations.push(s)}return t.debug&&(e.debug=!0),JSON.stringify(e)}(t)}},JSON_V2:{encode:function(t){return function(t){var e={traceId:t.traceId};return t.parentId&&(e.parentId=t.parentId),e.id=t.id,t.name&&(e.name=t.name),t.kind&&(e.kind=t.kind),t.timestamp&&(e.timestamp=t.timestamp),t.duration&&(e.duration=t.duration),t.localEndpoint&&(e.localEndpoint=t.localEndpoint),t.remoteEndpoint&&(e.remoteEndpoint=t.remoteEndpoint),t.annotations.length>0&&(e.annotations=t.annotations),Object.keys(t.tags).length>0&&(e.tags=t.tags),t.debug&&(e.debug=!0),t.shared&&(e.shared=!0),JSON.stringify(e)}(t)}}};t.option=p,t.Annotation=lt,t.Tracer=Ft,t.createNoopTracer=function(){var t=new zt;return new Ft({recorder:{record:function(){}},ctxImpl:t})},t.randomTraceId=Rt,t.sampler=yt,t.TraceId=At,t.HttpHeaders=Kt,t.InetAddress=V,t.BatchRecorder=Qt,t.ConsoleRecorder=Wt,t.ExplicitContext=zt,t.Instrumentation=$r,t.Request=Zr,t.jsonEncoder=Qr,t.model=Ct,t.parseRequestUrl=zr,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Zipkin={})}(this,function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var r=0;e.length>r;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var c={get type(){return"None"},get present(){return!1},map:function(){return this},ifPresent:function(){},flatMap:function(){return this},getOrElse:function(t){return t instanceof Function?t():t},equals:function(t){return t===this},toString:function(){return"None"}},h=function(){function t(e){r(this,t),this.value=e}return o(t,[{key:"map",value:function(e){return new t(e(this.value))}},{key:"ifPresent",value:function(t){t(this.value)}},{key:"flatMap",value:function(t){return t(this.value)}},{key:"getOrElse",value:function(){return this.value}},{key:"equals",value:function(e){return e instanceof t&&e.value===this.value}},{key:"toString",value:function(){return"Some(".concat(this.value,")")}},{key:"type",get:function(){return"Some"}},{key:"present",get:function(){return!0}}]),t}();function f(t){return t instanceof h||c.equals(t)}var p={Some:h,None:c,isOptional:f,verifyIsOptional:function(t){if(null==t)throw Error("Error: data is not Optional - it's null");if(!f(t))throw Error("Error: data (".concat(t,") is not an Option!"));if(f(t.value))throw Error("Error: data (".concat(t.value,") is wrapped in Option twice"))},verifyIsNotOptional:function(t){if(f(t))throw Error("Error: data (".concat(t,") is an Option!"))},fromNullable:function(t){return null==t?c:new h(t)}},l="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function d(){throw Error("setTimeout has not been defined")}function v(){throw Error("clearTimeout has not been defined")}var m=d,g=v;function y(t){if(m===setTimeout)return setTimeout(t,0);if((m===d||!m)&&setTimeout)return m=setTimeout,setTimeout(t,0);try{return m(t,0)}catch(e){try{return m.call(null,t,0)}catch(e){return m.call(this,t,0)}}}"function"==typeof l.setTimeout&&(m=setTimeout),"function"==typeof l.clearTimeout&&(g=clearTimeout);var w,I=[],E=!1,b=-1;function S(){E&&w&&(E=!1,w.length?I=w.concat(I):b=-1,I.length&&A())}function A(){if(!E){var t=y(S);E=!0;for(var e=I.length;e;){for(w=I,I=[];++b<e;)w&&w[b].run();b=-1,e=I.length}w=null,E=!1,function(t){if(g===clearTimeout)return clearTimeout(t);if((g===v||!g)&&clearTimeout)return g=clearTimeout,clearTimeout(t);try{g(t)}catch(e){try{return g.call(null,t)}catch(e){return g.call(this,t)}}}(t)}}function R(t,e){this.fun=t,this.array=e}R.prototype.run=function(){this.fun.apply(null,this.array)};function T(){}var _=T,k=T,O=T,P=T,C=T,N=T,U=T;var B=l.performance||{},x=B.now||B.mozNow||B.msNow||B.oNow||B.webkitNow||function(){return(new Date).getTime()};var L=new Date;var M,j={nextTick:function(t){var e=Array(arguments.length-1);if(arguments.length>1)for(var r=1;arguments.length>r;r++)e[r-1]=arguments[r];I.push(new R(t,e)),1!==I.length||E||y(A)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:_,addListener:k,once:O,off:P,removeListener:C,removeAllListeners:N,emit:U,binding:function(t){throw Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(t){throw Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(t){var e=.001*x.call(B),r=Math.floor(e),n=Math.floor(e%1*1e9);return t&&(r-=t[0],0>(n-=t[1])&&(r--,n+=1e9)),[r,n]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-L)/1e3}};function D(){return"/tmp"}var Y={EOL:"\n",tmpdir:D,tmpDir:D,networkInterfaces:function(){},getNetworkInterfaces:function(){},release:function(){return void 0!==l.navigator?l.navigator.appVersion:""},type:function(){return"Browser"},cpus:function(){return[]},totalmem:function(){return Number.MAX_VALUE},freemem:function(){return Number.MAX_VALUE},uptime:function(){return 0},loadavg:function(){return[]},hostname:function(){return void 0!==l.location?l.location.hostname:""},endianness:function(){if(void 0===M){var t=new ArrayBuffer(2),e=new Uint8Array(t),r=new Uint16Array(t);if(e[0]=1,e[1]=2,258===r[0])M="BE";else{if(513!==r[0])throw Error("unable to figure out endianess");M="LE"}}return M}};function q(t,e){for(var r in t)for(var n=t[r].length-1;n>=0;n--){var o=t[r][n];if(!o.internal&&o.family===e&&("IPv4"===e||0===o.scopeid))return o.address}return"IPv4"===e?"127.0.0.1":"::1"}function F(t,e){var r={};for(var n in t)n===e&&(r[n]=t[n]);return r}function z(t){var e=Y.networkInterfaces();return t&&(e=F(e,t)),q(e,"IPv4")}z.ipv4=z,z.ipv6=function(t){var e=Y.networkInterfaces();return t&&(e=F(e,t)),q(e,"IPv6")};var K=z,H=function(){function t(e){r(this,t),this.addr=e}return o(t,[{key:"ipv4",value:function(){var t=this.toInt();if(t&&0!==t)return this.addr}},{key:"toInt",value:function(){var t=this.addr.split(".");return t[0]<<24|t[1]<<16|t[2]<<8|t[3]}},{key:"toString",value:function(){return"InetAddress(".concat(this.addr,")")}}]),t}();H.getLocalAddress=function(){return"object"===(void 0===j?"undefined":e(j))&&"function"==typeof j.on?new H(K.ipv4()):new H("127.0.0.1")};var V=H,J=function(){function t(){r(this,t)}return o(t,[{key:"toString",value:function(){return"".concat(this.annotationType,"()")}}]),t}(),X=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),Z=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),$=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),G=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),Q=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),W=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),tt=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),et=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}();function rt(t){this.name=t}rt.prototype.toString=function(){return'LocalOperationStart("'.concat(this.name,'")')};var nt=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}();function ot(t){this.message=t}function it(t){this.serviceName=t}function at(t){this.name=t}function st(t){var e=t.port;this.host=t.host,this.port=e}function ut(t){var e=t.host,r=t.port;this.serviceName=t.serviceName,this.host=e||void 0,this.port=r||0}function ct(t){var e=t.port;this.host=t.host||V.getLocalAddress(),this.port=e||0}function ht(t){var e=t.host,r=t.port;this.serviceName=t.serviceName,this.host=e,this.port=r}function ft(t,e){this.key=t,this.value=e}ot.prototype.toString=function(){return'Message("'.concat(this.message,'")')},it.prototype.toString=function(){return'ServiceName("'.concat(this.serviceName,'")')},at.prototype.toString=function(){return'Rpc("'.concat(this.name,'")')},st.prototype.toString=function(){return'ClientAddr(host="'.concat(this.host,'", port=').concat(this.port,")")},ut.prototype.toString=function(){return'ServerAddr(serviceName="'.concat(this.serviceName,'", host="').concat(this.host,'", port=').concat(this.port,")")},ct.prototype.toString=function(){return'LocalAddr(host="'.concat(""+this.host,'", port=').concat(this.port,")")},ht.prototype.toString=function(){return'MessageAddr(serviceName="'.concat(this.serviceName,'", host="').concat(this.host,'", port=').concat(this.port,")")},ft.prototype.toString=function(){return"BinaryAnnotation(".concat(this.key,'="').concat(this.value,'")')};var pt={ClientSend:X,ClientRecv:Z,ServerSend:$,ServerRecv:G,ProducerStart:Q,ProducerStop:W,ConsumerStart:tt,ConsumerStop:et,MessageAddr:ht,Message:ot,ServiceName:it,Rpc:at,ClientAddr:st,ServerAddr:ut,LocalAddr:ct,BinaryAnnotation:ft,LocalOperationStart:rt,LocalOperationStop:nt};Object.keys(pt).forEach(function(t){pt[t].prototype.annotationType=t});var lt=pt,dt=p.Some,vt=function(){function t(e){r(this,t),this.evaluator=e}return o(t,[{key:"shouldSample",value:function(t){var e=this,r=t.sampled.getOrElse(function(){return e.evaluator(t)});return new dt(r)}},{key:"toString",value:function(){return"Sampler(".concat(""+this.evaluator,")")}}]),t}();function mt(t){return!1}function gt(t){return!0}mt.toString=function(){return"never sample"},gt.toString=function(){return"always sample"};var yt={Sampler:vt,CountingSampler:function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return r(this,e),u(this,a(e).call(this,function(t){if(t>0){if(1>t){var e=0,r=parseInt(1/t),n=function(t){var n=0==(e%=r);return e++,n};return n.toString=function(){return"countingSampler: sampleRate=".concat(t)},n}return gt}return mt}(1>t?t:1)))}return i(e,vt),e}(),neverSample:mt,alwaysSample:gt},wt=function(){function t(e){var n=e.traceId,o=e.timestamp,i=e.annotation;r(this,t),this.traceId=n,this.timestamp=o,this.annotation=i}return o(t,[{key:"toString",value:function(){return"Record(traceId=".concat(""+this.traceId,", annotation=").concat(""+this.annotation,")")}}]),t}(),It=p.Some,Et=p.None,bt=p.verifyIsOptional,St=p.verifyIsNotOptional,At=function(){function t(e){r(this,t);var n=e.traceId,o=void 0===n?Et:n,i=e.parentId,a=void 0===i?Et:i,s=e.spanId,u=e.sampled,c=void 0===u?Et:u,h=e.flags,f=void 0===h?0:h;bt(o),bt(a),St(s),bt(c),this._traceId=o,this._parentId=a,this._spanId=s,this._sampled=c,this._flags=f}return o(t,[{key:"isDebug",value:function(){return 1==(1&this._flags)}},{key:"toString",value:function(){return"TraceId(spanId=".concat(""+this.spanId)+", parentId=".concat(""+this.parentId)+", traceId=".concat(""+this.traceId,")")}},{key:"spanId",get:function(){return this._spanId}},{key:"parentId",get:function(){return this._parentId.getOrElse(this.spanId)}},{key:"traceId",get:function(){return this._traceId.getOrElse(this.parentId)}},{key:"sampled",get:function(){return this.isDebug()?new It(!0):this._sampled}},{key:"flags",get:function(){return this._flags}}]),t}();var Rt=function(){for(var t="",e=0;16>e;e++)t+="0123456789abcdef"[Math.floor(16*Math.random())];return t},Tt=void 0!==j&&j.hrtime;var _t={now:Tt?function(t,e){if(t&&e){var r=j.hrtime(e);return t+Math.floor(1e6*r[0]+r[1]/1e3)}return 1e3*Date.now()}:function(){return 1e3*Date.now()},hrtime:Tt?function(){return j.hrtime()}:function(){}};function kt(t){var e=t.ipv4,r=t.port;this.setServiceName(t.serviceName),this.setIpv4(e),this.setPort(r)}function Ot(t,e){this.timestamp=t,this.value=""+e}function Pt(t){var e=this;this.traceId=t.traceId,t._parentId.ifPresent(function(t){e.parentId=t}),this.id=t.spanId,this.name=void 0,this.kind=void 0,this.timestamp=void 0,this.duration=void 0,this.localEndpoint=void 0,this.remoteEndpoint=void 0,this.annotations=[],this.tags={},this.debug=t.isDebug(),this.shared=!1}kt.prototype.setServiceName=function(t){this.serviceName=t?t.toLocaleLowerCase():void 0},kt.prototype.setIpv4=function(t){this.ipv4=t},kt.prototype.setPort=function(t){this.port=t||void 0},kt.prototype.isEmpty=function(){return void 0===this.serviceName&&void 0===this.ipv4&&void 0===this.port},Ot.prototype.toString=function(){return'Annotation(value="'.concat(this.value,'")')},Pt.prototype.setName=function(t){this.name=t?t.toLocaleLowerCase():void 0},Pt.prototype.setKind=function(t){this.kind=t},Pt.prototype.setTimestamp=function(t){this.timestamp=t},Pt.prototype.setDuration=function(t){void 0!==t&&(this.duration=Math.max(t,1))},Pt.prototype.setLocalEndpoint=function(t){this.localEndpoint=t&&!t.isEmpty()?t:void 0},Pt.prototype.setRemoteEndpoint=function(t){this.remoteEndpoint=t&&!t.isEmpty()?t:void 0},Pt.prototype.addAnnotation=function(t,e){this.annotations.push(new Ot(t,e))},Pt.prototype.putTag=function(t,e){this.tags[t]=""+e},Pt.prototype.setDebug=function(t){this.debug=t},Pt.prototype.setShared=function(t){this.shared=t},Pt.prototype.toString=function(){var t=this.annotations.map(function(t){return""+t}).join(", ");return"Span(id=".concat(this.traceId,", annotations=[").concat(t,"])")};var Ct={Endpoint:kt,Span:Pt},Nt=function(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then};var Ut=p.None,Bt=p.Some,xt=p.fromNullable,Lt=yt.Sampler,Mt=yt.alwaysSample,jt=_t.now,Dt=_t.hrtime,Yt=Ct.Endpoint;function qt(t){throw Error("Tracer: Missing required argument ".concat(t,"."))}var Ft=function(){function t(e){var n=e.ctxImpl,o=void 0===n?qt("ctxImpl"):n,i=e.recorder,a=void 0===i?qt("recorder"):i,s=e.sampler,u=void 0===s?new Lt(Mt):s,c=e.traceId128Bit,h=void 0!==c&&c,f=e.supportsJoin,p=void 0===f||f,l=e.localServiceName,d=e.localEndpoint,v=e.log,m=void 0===v?console:v,g=e.defaultTags;r(this,t),this.log=m,this.recorder=a,this.sampler=u,this.traceId128Bit=h,this.supportsJoin=p,this._localEndpoint=d||new Yt({serviceName:l||"unknown"}),this._ctxImpl=o,this._defaultTraceId=this.createRootId(),this._startTimestamp=jt(),this._startTick=Dt(),this.recorder.setDefaultTags&&this.recorder.setDefaultTags(g)}return o(t,[{key:"scoped",value:function(t){return this._ctxImpl.scoped(t)}},{key:"letId",value:function(t,e){return this._ctxImpl.letContext(t,e)}},{key:"createRootId",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ut,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=Rt(),n=this.traceId128Bit?new Bt(Rt()+r):Ut,o=new At({traceId:n,parentId:Ut,spanId:r,sampled:t,flags:e?1:0});return t===Ut&&(o._sampled=this.sampler.shouldSample(o)),o}},{key:"createChildId",value:function(){var t=xt(this._ctxImpl.getContext()),e=new At({traceId:t.map(function(t){return t.traceId}),parentId:t.map(function(t){return t.spanId}),spanId:Rt(),sampled:t.flatMap(function(t){return t.sampled}),flags:t.map(function(t){return t.flags}).getOrElse(0)});return!1===e.sampled.present&&(e._sampled=this.sampler.shouldSample(e)),e}},{key:"local",value:function(t,e){var r=this;if("function"!=typeof e)throw Error("you must pass a function");return this.scoped(function(){var n,o=r.createChildId();r.setId(o),r.recordServiceName(r._localEndpoint.serviceName),r.recordAnnotation(new lt.LocalOperationStart(t));try{n=e()}catch(t){throw r.recordBinary("error",t.message?t.message:""+t),r.recordAnnotation(new lt.LocalOperationStop),t}if(!Nt(n))return r.recordAnnotation(new lt.LocalOperationStop),n;if(!o.sampled.getOrElse(!1))return n;var i=function(t){return r.recorder.record(new wt({traceId:o,timestamp:jt(r._startTimestamp,r._startTick),annotation:t}))};return n.then(function(t){return i(new lt.LocalOperationStop),t}).catch(function(t){throw i(new lt.BinaryAnnotation("error",t.message?t.message:""+t)),i(new lt.LocalOperationStop),t})})}},{key:"join",value:function(t){var e=this;if(!(t instanceof At))throw Error("Must be valid TraceId instance");return t._sampled===Ut&&(t._sampled=this.sampler.shouldSample(t)),this.supportsJoin?t:this.letId(t,function(){return e.createChildId()})}},{key:"setId",value:function(t){this._ctxImpl.setContext(t)}},{key:"recordAnnotation",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:jt(this._startTimestamp,this._startTick);this.id.sampled.ifPresent(function(n){n&&e.recorder.record(new wt({traceId:e.id,timestamp:r,annotation:t}))})}},{key:"recordMessage",value:function(t){this.recordAnnotation(new lt.Message(t))}},{key:"recordServiceName",value:function(t){this.recordAnnotation(new lt.ServiceName(t))}},{key:"recordRpc",value:function(t){this.recordAnnotation(new lt.Rpc(t))}},{key:"recordClientAddr",value:function(t){this.recordAnnotation(new lt.ClientAddr(t))}},{key:"recordServerAddr",value:function(t){this.recordAnnotation(new lt.ServerAddr(t))}},{key:"recordLocalAddr",value:function(t){this.recordAnnotation(new lt.LocalAddr(t))}},{key:"recordBinary",value:function(t,e){this.recordAnnotation(new lt.BinaryAnnotation(t,e))}},{key:"writeIdToConsole",value:function(t){this.log.info("".concat(t,": ").concat(""+this.id))}},{key:"setTags",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var e in t)t.hasOwnProperty(e)&&this.recordBinary(e,t[e])}},{key:"id",get:function(){return this._ctxImpl.getContext()||this._defaultTraceId}},{key:"localEndpoint",get:function(){return this._localEndpoint}}]),t}(),zt=function(){function t(){r(this,t),this.currentCtx=null}return o(t,[{key:"setContext",value:function(t){this.currentCtx=t}},{key:"getContext",value:function(){return this.currentCtx}},{key:"scoped",value:function(t){var e=this.currentCtx,r=t();return this.currentCtx=e,r}},{key:"letContext",value:function(t,e){var r=this;return this.scoped(function(){return r.setContext(t),e()})}}]),t}(),Kt={TraceId:"X-B3-TraceId",SpanId:"X-B3-SpanId",ParentSpanId:"X-B3-ParentSpanId",Sampled:"X-B3-Sampled",Flags:"X-B3-Flags"},Ht=_t.now,Vt=_t.hrtime,Jt=Ct.Span,Xt=Ct.Endpoint,Zt=6e7,$t=Symbol("defaultTags"),Gt=function(){function t(e){r(this,t),this.traceId=e,this.startTimestamp=Ht(),this.startTick=Vt(),this.delegate=new Jt(e),this.localEndpoint=new Xt({})}return o(t,[{key:"finish",value:function(){this.endTimestamp||(this.endTimestamp=Ht(this.startTimestamp,this.startTick))}}],[{key:"create",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new t(e);for(var o in r)r.hasOwnProperty(o)&&n.delegate.putTag(o,r[o]);return n}}]),t}(),Qt=function(){function t(e){var n=this,o=e.logger,i=e.timeout,a=void 0===i?Zt:i;r(this,t),this.logger=o,this.timeout=a,this.partialSpans=new Map,this[$t]={};var s=setInterval(function(){n.partialSpans.forEach(function(t,e){n._timedOut(t)&&n._writeSpan(e)})},1e3);s.unref&&s.unref()}return o(t,[{key:"_writeSpan",value:function(t){var e=this.partialSpans.get(t);if(void 0!==e){this.partialSpans.delete(t);var r=e.delegate;r.setLocalEndpoint(e.localEndpoint),e.endTimestamp&&(r.setTimestamp(e.startTimestamp),r.setDuration(e.endTimestamp-e.startTimestamp)),this.logger.logSpan(r)}}},{key:"_updateSpanMap",value:function(t,e){var r;e(r=this.partialSpans.has(t)?this.partialSpans.get(t):Gt.create(t,this[$t])),r.endTimestamp?this._writeSpan(t):this.partialSpans.set(t,r)}},{key:"_timedOut",value:function(t){return t.startTimestamp+this.timeout<Ht()}},{key:"record",value:function(t){var e=t.traceId;this._updateSpanMap(e,function(r){switch(t.annotation.annotationType){case"ClientSend":r.delegate.setKind("CLIENT");break;case"ClientRecv":r.finish(),r.delegate.setKind("CLIENT");break;case"ServerSend":r.finish(),r.delegate.setKind("SERVER");break;case"ServerRecv":r.delegate.setShared(e.parentId!==e.spanId),r.delegate.setKind("CLIENT");break;case"ProducerStart":r.delegate.setKind("PRODUCER");break;case"ProducerStop":r.finish(),r.delegate.setKind("PRODUCER");break;case"ConsumerStart":r.delegate.setKind("CONSUMER");break;case"ConsumerStop":r.finish(),r.delegate.setKind("CONSUMER");break;case"MessageAddr":r.delegate.setRemoteEndpoint(new Xt({serviceName:t.annotation.serviceName,ipv4:t.annotation.host&&t.annotation.host.ipv4(),port:t.annotation.port}));break;case"LocalOperationStart":r.delegate.setName(t.annotation.name);break;case"LocalOperationStop":r.finish();break;case"Message":r.delegate.addAnnotation(t.timestamp,t.annotation.message);break;case"Rpc":r.delegate.setName(t.annotation.name);break;case"ServiceName":r.localEndpoint.setServiceName(t.annotation.serviceName);break;case"BinaryAnnotation":r.delegate.putTag(t.annotation.key,t.annotation.value);break;case"LocalAddr":r.localEndpoint.setIpv4(t.annotation.host&&t.annotation.host.ipv4()),r.localEndpoint.setPort(t.annotation.port);break;case"ServerAddr":r.delegate.setKind("CLIENT"),r.delegate.setRemoteEndpoint(new Xt({serviceName:t.annotation.serviceName,ipv4:t.annotation.host&&t.annotation.host.ipv4(),port:t.annotation.port}))}})}},{key:"setDefaultTags",value:function(t){this[$t]=t}},{key:"toString",value:function(){return"BatchRecorder()"}}]),t}(),Wt=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:console.log;r(this,t),this.logger=e}return o(t,[{key:"record",value:function(t){var e=t.traceId,r=e.spanId,n=e.parentId,o=e.traceId;this.logger("Record at (timestamp=".concat(t.timestamp,", spanId=").concat(r,", parentId=").concat(n,", ")+"traceId=".concat(o,"): ").concat(""+t.annotation))}},{key:"toString",value:function(){return"consoleTracer"}}]),t}(),te=2147483647,ee=36,re=1,ne=26,oe=38,ie=700,ae=72,se=128,ue="-",ce=/[^\x20-\x7E]/,he=/[\x2E\u3002\uFF0E\uFF61]/g,fe={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},pe=ee-re,le=Math.floor,de=String.fromCharCode;function ve(t){throw new RangeError(fe[t])}function me(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function ge(t,e,r){var n=0;for(t=r?le(t/ie):t>>1,t+=le(t/e);t>pe*ne>>1;n+=ee)t=le(t/pe);return le(n+(pe+1)*t/(t+oe))}function ye(t){return function(t,e){var r=t.split("@"),n="";r.length>1&&(n=r[0]+"@",t=r[1]);var o=function(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}((t=t.replace(he,".")).split("."),e).join(".");return n+o}(t,function(t){return ce.test(t)?"xn--"+function(t){var e,r,n,o,i,a,s,u,c,h,f,p,l,d,v,m=[];for(p=(t=function(t){for(var e,r,n=[],o=0,i=t.length;i>o;)55296>(e=t.charCodeAt(o++))||e>56319||o>=i?n.push(e):56320==(64512&(r=t.charCodeAt(o++)))?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),o--);return n}(t)).length,e=se,r=0,i=ae,a=0;p>a;++a)128>(f=t[a])&&m.push(de(f));for(n=o=m.length,o&&m.push(ue);p>n;){for(s=te,a=0;p>a;++a)(f=t[a])>=e&&s>f&&(s=f);for(s-e>le((te-r)/(l=n+1))&&ve("overflow"),r+=(s-e)*l,e=s,a=0;p>a;++a)if(e>(f=t[a])&&++r>te&&ve("overflow"),f==e){for(u=r,c=ee;(h=c>i?i+ne>c?c-i:ne:re)<=u;c+=ee)m.push(de(me(h+(v=u-h)%(d=ee-h),0))),u=le(v/d);m.push(de(me(u,0))),i=ge(r,l,n==o),r=0,++n}++r,++e}return m.join("")}(t):t})}var we=[],Ie=[],Ee="undefined"!=typeof Uint8Array?Uint8Array:Array,be=!1;function Se(){be=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;64>e;++e)we[e]=t[e],Ie[t.charCodeAt(e)]=e;Ie[45]=62,Ie[95]=63}function Ae(t,e,r){for(var n,o=[],i=e;r>i;i+=3)o.push(we[(n=(t[i]<<16)+(t[i+1]<<8)+t[i+2])>>18&63]+we[n>>12&63]+we[n>>6&63]+we[63&n]);return o.join("")}function Re(t){var e;be||Se();for(var r=t.length,n=r%3,o="",i=[],a=0,s=r-n;s>a;a+=16383)i.push(Ae(t,a,a+16383>s?s:a+16383));return 1===n?(o+=we[(e=t[r-1])>>2],o+=we[e<<4&63],o+="=="):2===n&&(o+=we[(e=(t[r-2]<<8)+t[r-1])>>10],o+=we[e>>4&63],o+=we[e<<2&63],o+="="),i.push(o),i.join("")}function Te(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<<s)-1,c=u>>1,h=-7,f=r?o-1:0,p=r?-1:1,l=t[e+f];for(f+=p,i=l&(1<<-h)-1,l>>=-h,h+=s;h>0;i=256*i+t[e+f],f+=p,h-=8);for(a=i&(1<<-h)-1,i>>=-h,h+=n;h>0;a=256*a+t[e+f],f+=p,h-=8);if(0===i)i=1-c;else{if(i===u)return a?NaN:1/0*(l?-1:1);a+=Math.pow(2,n),i-=c}return(l?-1:1)*a*Math.pow(2,i-n)}function _e(t,e,r,n,o,i){var a,s,u,c=8*i-o-1,h=(1<<c)-1,f=h>>1,p=23===o?5.960464477539062e-8:0,l=n?0:i-1,d=n?1:-1,v=0>e||0===e&&0>1/e?1:0;for(isNaN(e=Math.abs(e))||e===1/0?(s=isNaN(e)?1:0,a=h):(1>e*(u=Math.pow(2,-(a=Math.floor(Math.log(e)/Math.LN2))))&&(a--,u*=2),2>(e+=1>a+f?p*Math.pow(2,1-f):p/u)*u||(a++,u/=2),h>a+f?1>a+f?(s=e*Math.pow(2,f-1)*Math.pow(2,o),a=0):(s=(e*u-1)*Math.pow(2,o),a+=f):(s=0,a=h));o>=8;t[r+l]=255&s,l+=d,s/=256,o-=8);for(a=a<<o|s,c+=o;c>0;t[r+l]=255&a,l+=d,a/=256,c-=8);t[r+l-d]|=128*v}var ke={}.toString,Oe=Array.isArray||function(t){return"[object Array]"==ke.call(t)};function Pe(){return Ne.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ce(t,e){if(Pe()<e)throw new RangeError("Invalid typed array length");return Ne.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=Ne.prototype:(null===t&&(t=new Ne(e)),t.length=e),t}function Ne(t,e,r){if(!(Ne.TYPED_ARRAY_SUPPORT||this instanceof Ne))return new Ne(t,e,r);if("number"==typeof t){if("string"==typeof e)throw Error("If encoding is specified then the first argument must be a string");return xe(this,t)}return Ue(this,t,e,r)}function Ue(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(0>r||r>e.byteLength)throw new RangeError("'offset' is out of bounds");if(r+(n||0)>e.byteLength)throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);Ne.TYPED_ARRAY_SUPPORT?(t=e).__proto__=Ne.prototype:t=Le(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!Ne.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|De(e,r),o=(t=Ce(t,n)).write(e,r);o!==n&&(t=t.slice(0,o));return t}(t,e,r):function(t,e){if(je(e)){var r=0|Me(e.length);return 0===(t=Ce(t,r)).length?t:(e.copy(t,0,0,r),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?Ce(t,0):Le(t,e);if("Buffer"===e.type&&Oe(e.data))return Le(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function Be(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(0>t)throw new RangeError('"size" argument must not be negative')}function xe(t,e){if(Be(e),t=Ce(t,0>e?0:0|Me(e)),!Ne.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;++r)t[r]=0;return t}function Le(t,e){var r=0>e.length?0:0|Me(e.length);t=Ce(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function Me(t){if(t>=Pe())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Pe().toString(16)+" bytes");return 0|t}function je(t){return!(null==t||!t._isBuffer)}function De(t,e){if(je(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return fr(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return pr(t).length;default:if(n)return fr(t).length;e=(""+e).toLowerCase(),n=!0}}function Ye(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function qe(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:-2147483648>r&&(r=-2147483648),isNaN(r=+r)&&(r=o?0:t.length-1),0>r&&(r=t.length+r),t.length>r){if(0>r){if(!o)return-1;r=0}}else{if(o)return-1;r=t.length-1}if("string"==typeof e&&(e=Ne.from(e,n)),je(e))return 0===e.length?-1:Fe(t,e,r,n,o);if("number"==typeof e)return e&=255,Ne.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Fe(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function Fe(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=(n+"").toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(2>t.length||2>e.length)return-1;a=2,s/=2,u/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var h=-1;for(i=r;s>i;i++)if(c(t,i)===c(e,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===u)return h*a}else-1!==h&&(i-=i-h),h=-1}else for(r+u>s&&(r=s-u),i=r;i>=0;i--){for(var f=!0,p=0;u>p;p++)if(c(t,i+p)!==c(e,p)){f=!1;break}if(f)return i}return-1}function ze(t,e,r,n){var o=t.length-(r=+r||0);n?(n=+n)>o&&(n=o):n=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var a=0;n>a;++a){var s=parseInt(e.substr(2*a,2),16);if(isNaN(s))return a;t[r+a]=s}return a}function Ke(t,e,r,n){return lr(fr(e,t.length-r),t,r,n)}function He(t,e,r,n){return lr(function(t){for(var e=[],r=0;t.length>r;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function Ve(t,e,r,n){return He(t,e,r,n)}function Je(t,e,r,n){return lr(pr(e),t,r,n)}function Xe(t,e,r,n){return lr(function(t,e){for(var r,n,o=[],i=0;t.length>i&&0<=(e-=2);++i)r=t.charCodeAt(i),n=r>>8,o.push(r%256),o.push(n);return o}(e,t.length-r),t,r,n)}function Ze(t,e,r){return Re(0===e&&r===t.length?t:t.slice(e,r))}function $e(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;r>o;){var i,a,s,u,c=t[o],h=null,f=c>239?4:c>223?3:c>191?2:1;if(r>=o+f)switch(f){case 1:128>c&&(h=c);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(h=u);break;case 3:a=t[o+2],128==(192&(i=t[o+1]))&&128==(192&a)&&(u=(15&c)<<12|(63&i)<<6|63&a)>2047&&(55296>u||u>57343)&&(h=u);break;case 4:a=t[o+2],s=t[o+3],128==(192&(i=t[o+1]))&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&1114112>u&&(h=u)}null===h?(h=65533,f=1):h>65535&&(n.push((h-=65536)>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=f}return function(t){var e=t.length;if(Ge>=e)return String.fromCharCode.apply(String,t);var r="",n=0;for(;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Ge));return r}(n)}Ne.TYPED_ARRAY_SUPPORT=void 0===l.TYPED_ARRAY_SUPPORT||l.TYPED_ARRAY_SUPPORT,Ne.poolSize=8192,Ne._augment=function(t){return t.__proto__=Ne.prototype,t},Ne.from=function(t,e,r){return Ue(null,t,e,r)},Ne.TYPED_ARRAY_SUPPORT&&(Ne.prototype.__proto__=Uint8Array.prototype,Ne.__proto__=Uint8Array),Ne.alloc=function(t,e,r){return function(t,e,r,n){return Be(e),e>0&&void 0!==r?"string"==typeof n?Ce(t,e).fill(r,n):Ce(t,e).fill(r):Ce(t,e)}(null,t,e,r)},Ne.allocUnsafe=function(t){return xe(null,t)},Ne.allocUnsafeSlow=function(t){return xe(null,t)},Ne.isBuffer=function(t){return null!=t&&(!!t._isBuffer||dr(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&dr(t.slice(0,0))}(t))},Ne.compare=function(t,e){if(!je(t)||!je(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);i>o;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return n>r?-1:r>n?1:0},Ne.isEncoding=function(t){switch((t+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Ne.concat=function(t,e){if(!Oe(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return Ne.alloc(0);var r;if(void 0===e)for(e=0,r=0;t.length>r;++r)e+=t[r].length;var n=Ne.allocUnsafe(e),o=0;for(r=0;t.length>r;++r){var i=t[r];if(!je(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},Ne.byteLength=De,Ne.prototype._isBuffer=!0,Ne.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;t>e;e+=2)Ye(this,e,e+1);return this},Ne.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;t>e;e+=4)Ye(this,e,e+3),Ye(this,e+1,e+2);return this},Ne.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;t>e;e+=8)Ye(this,e,e+7),Ye(this,e+1,e+6),Ye(this,e+2,e+5),Ye(this,e+3,e+4);return this},Ne.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?$e(this,0,t):function(t,e,r){var n=!1;if((void 0===e||0>e)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),0>=r)return"";if((e>>>=0)>=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return tr(this,e,r);case"utf8":case"utf-8":return $e(this,e,r);case"ascii":return Qe(this,e,r);case"latin1":case"binary":return We(this,e,r);case"base64":return Ze(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return er(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},Ne.prototype.equals=function(t){if(!je(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Ne.compare(this,t)},Ne.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},Ne.prototype.compare=function(t,e,r,n,o){if(!je(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),0>e||r>t.length||0>n||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(i,a),u=this.slice(n,o),c=t.slice(e,r),h=0;s>h;++h)if(u[h]!==c[h]){i=u[h],a=c[h];break}return a>i?-1:i>a?1:0},Ne.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},Ne.prototype.indexOf=function(t,e,r){return qe(this,t,e,r,!0)},Ne.prototype.lastIndexOf=function(t,e,r){return qe(this,t,e,r,!1)},Ne.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return ze(this,t,e,r);case"utf8":case"utf-8":return Ke(this,t,e,r);case"ascii":return He(this,t,e,r);case"latin1":case"binary":return Ve(this,t,e,r);case"base64":return Je(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Xe(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},Ne.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Ge=4096;function Qe(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;r>o;++o)n+=String.fromCharCode(127&t[o]);return n}function We(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;r>o;++o)n+=String.fromCharCode(t[o]);return n}function tr(t,e,r){var n=t.length;e&&e>=0||(e=0),(!r||0>r||r>n)&&(r=n);for(var o="",i=e;r>i;++i)o+=hr(t[i]);return o}function er(t,e,r){for(var n=t.slice(e,r),o="",i=0;n.length>i;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function rr(t,e,r){if(t%1!=0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function nr(t,e,r,n,o,i){if(!je(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||i>e)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function or(t,e,r,n){0>e&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);i>o;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function ir(t,e,r,n){0>e&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);i>o;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function ar(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("Index out of range")}function sr(t,e,r,n,o){return o||ar(t,0,r,4),_e(t,e,r,n,23,4),r+4}function ur(t,e,r,n,o){return o||ar(t,0,r,8),_e(t,e,r,n,52,8),r+8}Ne.prototype.slice=function(t,e){var r,n=this.length;if(0>(t=~~t)?0>(t+=n)&&(t=0):t>n&&(t=n),0>(e=void 0===e?n:~~e)?0>(e+=n)&&(e=0):e>n&&(e=n),t>e&&(e=t),Ne.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=Ne.prototype;else{var o=e-t;r=new Ne(o,void 0);for(var i=0;o>i;++i)r[i]=this[i+t]}return r},Ne.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},Ne.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},Ne.prototype.readUInt8=function(t,e){return e||rr(t,1,this.length),this[t]},Ne.prototype.readUInt16LE=function(t,e){return e||rr(t,2,this.length),this[t]|this[t+1]<<8},Ne.prototype.readUInt16BE=function(t,e){return e||rr(t,2,this.length),this[t]<<8|this[t+1]},Ne.prototype.readUInt32LE=function(t,e){return e||rr(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Ne.prototype.readUInt32BE=function(t,e){return e||rr(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Ne.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return(o*=128)>n||(n-=Math.pow(2,8*e)),n},Ne.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return(o*=128)>i||(i-=Math.pow(2,8*e)),i},Ne.prototype.readInt8=function(t,e){return e||rr(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Ne.prototype.readInt16LE=function(t,e){e||rr(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Ne.prototype.readInt16BE=function(t,e){e||rr(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Ne.prototype.readInt32LE=function(t,e){return e||rr(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Ne.prototype.readInt32BE=function(t,e){return e||rr(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Ne.prototype.readFloatLE=function(t,e){return e||rr(t,4,this.length),Te(this,t,!0,23,4)},Ne.prototype.readFloatBE=function(t,e){return e||rr(t,4,this.length),Te(this,t,!1,23,4)},Ne.prototype.readDoubleLE=function(t,e){return e||rr(t,8,this.length),Te(this,t,!0,52,8)},Ne.prototype.readDoubleBE=function(t,e){return e||rr(t,8,this.length),Te(this,t,!1,52,8)},Ne.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||nr(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},Ne.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||nr(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},Ne.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,1,255,0),Ne.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},Ne.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,2,65535,0),Ne.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):or(this,t,e,!0),e+2},Ne.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,2,65535,0),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):or(this,t,e,!1),e+2},Ne.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,4,4294967295,0),Ne.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):ir(this,t,e,!0),e+4},Ne.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,4,4294967295,0),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):ir(this,t,e,!1),e+4},Ne.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);nr(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i<r&&(a*=256);)0>t&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},Ne.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);nr(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)0>t&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},Ne.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,1,127,-128),Ne.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},Ne.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,2,32767,-32768),Ne.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):or(this,t,e,!0),e+2},Ne.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,2,32767,-32768),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):or(this,t,e,!1),e+2},Ne.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,4,2147483647,-2147483648),Ne.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):ir(this,t,e,!0),e+4},Ne.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):ir(this,t,e,!1),e+4},Ne.prototype.writeFloatLE=function(t,e,r){return sr(this,t,e,!0,r)},Ne.prototype.writeFloatBE=function(t,e,r){return sr(this,t,e,!1,r)},Ne.prototype.writeDoubleLE=function(t,e,r){return ur(this,t,e,!0,r)},Ne.prototype.writeDoubleBE=function(t,e,r){return ur(this,t,e,!1,r)},Ne.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),t.length>e||(e=t.length),e||(e=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),n-r>t.length-e&&(n=t.length-e+r);var o,i=n-r;if(this===t&&e>r&&n>e)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(1e3>i||!Ne.TYPED_ARRAY_SUPPORT)for(o=0;i>o;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},Ne.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);256>o&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Ne.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(0>e||e>this.length||r>this.length)throw new RangeError("Out of range index");if(e>=r)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;r>i;++i)this[i]=t;else{var a=je(t)?t:fr(""+new Ne(t,n)),s=a.length;for(i=0;r-e>i;++i)this[i+e]=a[i%s]}return this};var cr=/[^+\/0-9A-Za-z-_]/g;function hr(t){return 16>t?"0"+t.toString(16):t.toString(16)}function fr(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],a=0;n>a;++a){if((r=t.charCodeAt(a))>55295&&57344>r){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(56320>r){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,128>r){if(0>(e-=1))break;i.push(r)}else if(2048>r){if(0>(e-=2))break;i.push(r>>6|192,63&r|128)}else if(65536>r){if(0>(e-=3))break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(r>=1114112)throw Error("Invalid code point");if(0>(e-=4))break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function pr(t){return function(t){var e,r,n,o,i,a;be||Se();var s=t.length;if(s%4>0)throw Error("Invalid string. Length must be a multiple of 4");a=new Ee(3*s/4-(i="="===t[s-2]?2:"="===t[s-1]?1:0)),n=i>0?s-4:s;var u=0;for(e=0,r=0;n>e;e+=4,r+=3)o=Ie[t.charCodeAt(e)]<<18|Ie[t.charCodeAt(e+1)]<<12|Ie[t.charCodeAt(e+2)]<<6|Ie[t.charCodeAt(e+3)],a[u++]=o>>16&255,a[u++]=o>>8&255,a[u++]=255&o;return 2===i?(o=Ie[t.charCodeAt(e)]<<2|Ie[t.charCodeAt(e+1)]>>4,a[u++]=255&o):1===i&&(o=Ie[t.charCodeAt(e)]<<10|Ie[t.charCodeAt(e+1)]<<4|Ie[t.charCodeAt(e+2)]>>2,a[u++]=o>>8&255,a[u++]=255&o),a}(function(t){if(2>(t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(cr,"")).length)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function lr(t,e,r,n){for(var o=0;n>o&&(o+r<e.length&&o<t.length);++o)e[o+r]=t[o];return o}function dr(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function vr(t){return null===t}function mr(t){return"string"==typeof t}function gr(t){return"object"==typeof t&&null!==t}function yr(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var wr=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function Ir(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}}function Er(t,e){if(t.map)return t.map(e);for(var r=[],n=0;t.length>n;n++)r.push(e(t[n],n));return r}var br=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return e};function Sr(t,e,r,n){r=r||"=";var o={};if("string"!=typeof t||0===t.length)return o;var i=/\+/g;t=t.split(e=e||"&");var a=1e3;n&&"number"==typeof n.maxKeys&&(a=n.maxKeys);var s=t.length;a>0&&s>a&&(s=a);for(var u=0;s>u;++u){var c,h,f,p,l=t[u].replace(i,"%20"),d=l.indexOf(r);0>d?(c=l,h=""):(c=l.substr(0,d),h=l.substr(d+1)),f=decodeURIComponent(c),p=decodeURIComponent(h),yr(o,f)?wr(o[f])?o[f].push(p):o[f]=[o[f],p]:o[f]=p}return o}var Ar={parse:Dr,resolve:function(t,e){return Dr(t,!1,!0).resolve(e)},resolveObject:function(t,e){return t?Dr(t,!1,!0).resolveObject(e):e},format:function(t){mr(t)&&(t=Yr({},t));return qr(t)},Url:Rr};function Rr(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var Tr=/^([a-z0-9.+-]+:)/i,_r=/:[0-9]*$/,kr=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Or=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),Pr=["'"].concat(Or),Cr=["%","/","?",";","#"].concat(Pr),Nr=["/","?","#"],Ur=255,Br=/^[+a-z0-9A-Z_-]{0,63}$/,xr=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Lr={javascript:!0,"javascript:":!0},Mr={javascript:!0,"javascript:":!0},jr={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function Dr(t,e,r){if(t&&gr(t)&&t instanceof Rr)return t;var n=new Rr;return n.parse(t,e,r),n}function Yr(t,e,r,n){if(!mr(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),i=-1!==o&&o<e.indexOf("#")?"?":"#",a=e.split(i);a[0]=a[0].replace(/\\/g,"/");var s=e=a.join(i);if(s=s.trim(),!n&&1===e.split("#").length){var u=kr.exec(s);if(u)return t.path=s,t.href=s,t.pathname=u[1],u[2]?(t.search=u[2],t.query=r?Sr(t.search.substr(1)):t.search.substr(1)):r&&(t.search="",t.query={}),t}var c,h,f,p=Tr.exec(s);if(p){var l=(p=p[0]).toLowerCase();t.protocol=l,s=s.substr(p.length)}if(n||p||s.match(/^\/\/[^@\/]+@[^@\/]+/)){var d="//"===s.substr(0,2);!d||p&&Mr[p]||(s=s.substr(2),t.slashes=!0)}if(!Mr[p]&&(d||p&&!jr[p])){var v,m,g=-1;for(c=0;Nr.length>c;c++)-1===(h=s.indexOf(Nr[c]))||-1!==g&&h>=g||(g=h);for(-1!==(m=-1===g?s.lastIndexOf("@"):s.lastIndexOf("@",g))&&(v=s.slice(0,m),s=s.slice(m+1),t.auth=decodeURIComponent(v)),g=-1,c=0;Cr.length>c;c++)-1===(h=s.indexOf(Cr[c]))||-1!==g&&h>=g||(g=h);-1===g&&(g=s.length),t.host=s.slice(0,g),s=s.slice(g),Fr(t),t.hostname=t.hostname||"";var y="["===t.hostname[0]&&"]"===t.hostname[t.hostname.length-1];if(!y){var w=t.hostname.split(/\./);for(c=0,f=w.length;f>c;c++){var I=w[c];if(I&&!I.match(Br)){for(var E="",b=0,S=I.length;S>b;b++)I.charCodeAt(b)>127?E+="x":E+=I[b];if(!E.match(Br)){var A=w.slice(0,c),R=w.slice(c+1),T=I.match(xr);T&&(A.push(T[1]),R.unshift(T[2])),R.length&&(s="/"+R.join(".")+s),t.hostname=A.join(".");break}}}}t.hostname=t.hostname.length>Ur?"":t.hostname.toLowerCase(),y||(t.hostname=ye(t.hostname)),t.host=(t.hostname||"")+(t.port?":"+t.port:""),t.href+=t.host,y&&(t.hostname=t.hostname.substr(1,t.hostname.length-2),"/"!==s[0]&&(s="/"+s))}if(!Lr[l])for(c=0,f=Pr.length;f>c;c++){var _=Pr[c];if(-1!==s.indexOf(_)){var k=encodeURIComponent(_);k===_&&(k=escape(_)),s=s.split(_).join(k)}}var O=s.indexOf("#");-1!==O&&(t.hash=s.substr(O),s=s.slice(0,O));var P=s.indexOf("?");(-1!==P?(t.search=s.substr(P),t.query=s.substr(P+1),r&&(t.query=Sr(t.query)),s=s.slice(0,P)):r&&(t.search="",t.query={}),s&&(t.pathname=s),jr[l]&&t.hostname&&!t.pathname&&(t.pathname="/"),t.pathname||t.search)&&(t.path=(t.pathname||"")+(t.search||""));return t.href=qr(t),t}function qr(t){var e=t.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var r,n,o,i,a=t.protocol||"",s=t.pathname||"",u=t.hash||"",c=!1,h="";t.host?c=e+t.host:t.hostname&&(c=e+(-1===t.hostname.indexOf(":")?t.hostname:"["+this.hostname+"]"),t.port&&(c+=":"+t.port)),t.query&&gr(t.query)&&Object.keys(t.query).length&&(n=n||"&",o=o||"=",null===(r=t.query)&&(r=void 0),h="object"==typeof r?Er(br(r),function(t){var e=encodeURIComponent(Ir(t))+o;return wr(r[t])?Er(r[t],function(t){return e+encodeURIComponent(Ir(t))}).join(n):e+encodeURIComponent(Ir(r[t]))}).join(n):i?encodeURIComponent(Ir(i))+o+encodeURIComponent(Ir(r)):"");var f=t.search||h&&"?"+h||"";return a&&":"!==a.substr(-1)&&(a+=":"),t.slashes||(!a||jr[a])&&!1!==c?(c="//"+(c||""),s&&"/"!==s.charAt(0)&&(s="/"+s)):c||(c=""),u&&"#"!==u.charAt(0)&&(u="#"+u),f&&"?"!==f.charAt(0)&&(f="?"+f),a+c+(s=s.replace(/[?#]/g,function(t){return encodeURIComponent(t)}))+(f=f.replace("#","%23"))+u}function Fr(t){var e=t.host,r=_r.exec(e);r&&(":"!==(r=r[0])&&(t.port=r.substr(1)),e=e.substr(0,e.length-r.length)),e&&(t.hostname=e)}Rr.prototype.parse=function(t,e,r){return Yr(this,t,e,r)},Rr.prototype.format=function(){return qr(this)},Rr.prototype.resolve=function(t){return this.resolveObject(Dr(t,!1,!0)).format()},Rr.prototype.resolveObject=function(t){if(mr(t)){var e=new Rr;e.parse(t,!1,!0),t=e}for(var r,n=new Rr,o=Object.keys(this),i=0;o.length>i;i++){var a=o[i];n[a]=this[a]}if(n.hash=t.hash,""===t.href)return n.href=n.format(),n;if(t.slashes&&!t.protocol){for(var s=Object.keys(t),u=0;s.length>u;u++){var c=s[u];"protocol"!==c&&(n[c]=t[c])}return jr[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(t.protocol&&t.protocol!==n.protocol){if(!jr[t.protocol]){for(var h=Object.keys(t),f=0;h.length>f;f++){var p=h[f];n[p]=t[p]}return n.href=n.format(),n}if(n.protocol=t.protocol,t.host||Mr[t.protocol])n.pathname=t.pathname;else{for(r=(t.pathname||"").split("/");r.length&&!(t.host=r.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==r[0]&&r.unshift(""),2>r.length&&r.unshift(""),n.pathname=r.join("/")}if(n.search=t.search,n.query=t.query,n.host=t.host||"",n.auth=t.auth,n.hostname=t.hostname||t.host,n.port=t.port,n.pathname||n.search)n.path=(n.pathname||"")+(n.search||"");return n.slashes=n.slashes||t.slashes,n.href=n.format(),n}var l,d=n.pathname&&"/"===n.pathname.charAt(0),v=t.host||t.pathname&&"/"===t.pathname.charAt(0),m=v||d||n.host&&t.pathname,g=m,y=n.pathname&&n.pathname.split("/")||[],w=n.protocol&&!jr[n.protocol];if(r=t.pathname&&t.pathname.split("/")||[],w&&(n.hostname="",n.port=null,n.host&&(""===y[0]?y[0]=n.host:y.unshift(n.host)),n.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===r[0]?r[0]=t.host:r.unshift(t.host)),t.host=null),m=m&&(""===r[0]||""===y[0])),v)n.host=t.host||""===t.host?t.host:n.host,n.hostname=t.hostname||""===t.hostname?t.hostname:n.hostname,n.search=t.search,n.query=t.query,y=r;else if(r.length)y||(y=[]),y.pop(),y=y.concat(r),n.search=t.search,n.query=t.query;else if(null!=t.search)return w&&(n.hostname=n.host=y.shift(),(l=!(!n.host||0>=n.host.indexOf("@"))&&n.host.split("@"))&&(n.auth=l.shift(),n.host=n.hostname=l.shift())),n.search=t.search,n.query=t.query,vr(n.pathname)&&vr(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!y.length)return n.pathname=null,n.path=n.search?"/"+n.search:null,n.href=n.format(),n;for(var I=y.slice(-1)[0],E=(n.host||t.host||y.length>1)&&("."===I||".."===I)||""===I,b=0,S=y.length;S>=0;S--)"."===(I=y[S])?y.splice(S,1):".."===I?(y.splice(S,1),b++):b&&(y.splice(S,1),b--);if(!m&&!g)for(;b--;b)y.unshift("..");!m||""===y[0]||y[0]&&"/"===y[0].charAt(0)||y.unshift(""),E&&"/"!==y.join("/").substr(-1)&&y.push("");var A=""===y[0]||y[0]&&"/"===y[0].charAt(0);return w&&(n.hostname=n.host=A?"":y.length?y.shift():"",(l=!(!n.host||0>=n.host.indexOf("@"))&&n.host.split("@"))&&(n.auth=l.shift(),n.host=n.hostname=l.shift())),(m=m||n.host&&y.length)&&!A&&y.unshift(""),y.length?n.pathname=y.join("/"):(n.pathname=null,n.path=null),vr(n.pathname)&&vr(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=t.auth||n.auth,n.slashes=n.slashes||t.slashes,n.href=n.format(),n},Rr.prototype.parseHost=function(){return Fr(this)};var zr=function(t){var e=Ar.parse(t);return{host:e.hostname,path:e.pathname}},Kr=p.Some,Hr=p.None;function Vr(t){return"1"===t||"true"===t}function Jr(t){try{return new Kr(parseInt(t))}catch(t){return Hr}}function Xr(t){throw Error("HttpServerInstrumentation: Missing required argument ".concat(t,"."))}var Zr={addZipkinHeaders:function(t,e){var r=function(t,e){var r=t.headers||{};return r[Kt.TraceId]=e.traceId,r[Kt.SpanId]=e.spanId,e._parentId.ifPresent(function(t){r[Kt.ParentSpanId]=t}),e.sampled.ifPresent(function(t){r[Kt.Sampled]=t?"1":"0"}),e.isDebug()&&(r[Kt.Flags]="1"),r}(t,e);return Object.assign({},t,{headers:r})}};var $r={HttpServer:function(){function t(e){var n=e.tracer,o=void 0===n?Xr("tracer"):n,i=e.serviceName,a=void 0===i?o.localEndpoint.serviceName:i,s=e.host,u=e.port,c=void 0===u?Xr("port"):u;r(this,t),this.tracer=o,this.serviceName=a,this.host=s&&new V(s),this.port=c}return o(t,[{key:"_createIdFromHeaders",value:function(t){if(function(t){return t(Kt.TraceId)!==Hr&&t(Kt.SpanId)!==Hr}(t)){var e=t(Kt.SpanId).map(function(e){var r=t(Kt.TraceId),n=t(Kt.ParentSpanId),o=t(Kt.Sampled),i=t(Kt.Flags).flatMap(Jr).getOrElse(0);return new At({traceId:r,parentId:n,spanId:e,sampled:o.map(Vr),flags:i})});return new Kr(this.tracer.join(e.getOrElse()))}if(t(Kt.Flags)!==Hr||t(Kt.Sampled)!==Hr){var r=t(Kt.Sampled)===Hr?Hr:t(Kt.Sampled).map(Vr),n=t(Kt.Flags).flatMap(Jr).getOrElse(0);return new Kr(this.tracer.createRootId(r,1===n))}return new Kr(this.tracer.createRootId())}},{key:"recordRequest",value:function(t,e,r){var n=this;this._createIdFromHeaders(r).ifPresent(function(t){return n.tracer.setId(t)});var o=this.tracer.id,i=zr(e).path;return this.tracer.recordServiceName(this.serviceName),this.tracer.recordRpc(t.toUpperCase()),this.tracer.recordBinary("http.path",i),this.tracer.recordAnnotation(new lt.ServerRecv),this.tracer.recordAnnotation(new lt.LocalAddr({host:this.host,port:this.port})),o}},{key:"recordResponse",value:function(t,e,r){this.tracer.setId(t),this.tracer.recordBinary("http.status_code",""+e),r?this.tracer.recordBinary("error",""+r):(200>e||e>399)&&this.tracer.recordBinary("error",""+e),this.tracer.recordAnnotation(new lt.ServerSend)}}]),t}(),HttpClient:function(){function t(e){var n=e.tracer,o=void 0===n?function(t){throw Error("HttpClientInstrumentation: Missing required argument ".concat(t,"."))}("tracer"):n,i=e.serviceName,a=void 0===i?o.localEndpoint.serviceName:i,s=e.remoteServiceName;r(this,t),this.tracer=o,this.serviceName=a,this.remoteServiceName=s}return o(t,[{key:"recordRequest",value:function(t,e,r){this.tracer.setId(this.tracer.createChildId());var n=this.tracer.id,o=zr(e).path;return this.tracer.recordServiceName(this.serviceName),this.tracer.recordRpc(r.toUpperCase()),this.tracer.recordBinary("http.path",o),this.tracer.recordAnnotation(new lt.ClientSend),this.remoteServiceName&&this.tracer.recordAnnotation(new lt.ServerAddr({serviceName:this.remoteServiceName})),Zr.addZipkinHeaders(t,n)}},{key:"recordResponse",value:function(t,e){this.tracer.setId(t),this.tracer.recordBinary("http.status_code",""+e),(200>e||e>399)&&this.tracer.recordBinary("error",""+e),this.tracer.recordAnnotation(new lt.ClientRecv)}},{key:"recordError",value:function(t,e){this.tracer.setId(t),this.tracer.recordBinary("error",""+e),this.tracer.recordAnnotation(new lt.ClientRecv)}}]),t}()};function Gr(t){if(void 0!==t){var e={serviceName:t.serviceName||""};return t.ipv4&&(e.ipv4=t.ipv4),t.port&&(e.port=t.port),e}}var Qr={JSON_V1:{encode:function(t){return function(t){var e={traceId:t.traceId};t.parentId&&(e.parentId=t.parentId),e.id=t.id,e.name=t.name||"",t.shared||(e.timestamp=t.timestamp,e.duration=t.duration);var r,n,o,i=Gr(t.localEndpoint);switch(t.kind){case"CLIENT":r=t.timestamp?"cs":void 0,n="cr",o="sa";break;case"SERVER":r=t.timestamp?"sr":void 0,n="ss",o="ca";break;case"PRODUCER":r=t.timestamp?"ms":void 0,n="ws",o="ma";break;case"CONSUMER":t.timestamp&&t.duration?(r="wr",n="mr"):t.timestamp&&(r="mr"),o="ma"}(t.annotations.length>0||r)&&(e.annotations=t.annotations.map(function(t){return function(t,e){return{value:t.value,timestamp:t.timestamp,endpoint:e}}(t,i)})),r&&(e.annotations.push({value:r,timestamp:t.timestamp,endpoint:i}),t.duration&&e.annotations.push({value:n,timestamp:t.timestamp+t.duration,endpoint:i}));var a=Object.keys(t.tags);if((a.length>0||t.remoteEndpoint)&&(e.binaryAnnotations=a.map(function(e){return{key:e,value:t.tags[e],endpoint:i}})),t.remoteEndpoint){var s={key:o,value:!0,endpoint:Gr(t.remoteEndpoint)};e.binaryAnnotations.push(s)}return t.debug&&(e.debug=!0),JSON.stringify(e)}(t)}},JSON_V2:{encode:function(t){return function(t){var e={traceId:t.traceId};return t.parentId&&(e.parentId=t.parentId),e.id=t.id,t.name&&(e.name=t.name),t.kind&&(e.kind=t.kind),t.timestamp&&(e.timestamp=t.timestamp),t.duration&&(e.duration=t.duration),t.localEndpoint&&(e.localEndpoint=t.localEndpoint),t.remoteEndpoint&&(e.remoteEndpoint=t.remoteEndpoint),t.annotations.length>0&&(e.annotations=t.annotations),Object.keys(t.tags).length>0&&(e.tags=t.tags),t.debug&&(e.debug=!0),t.shared&&(e.shared=!0),JSON.stringify(e)}(t)}}};t.option=p,t.Annotation=lt,t.Tracer=Ft,t.createNoopTracer=function(){var t=new zt;return new Ft({recorder:{record:function(){}},ctxImpl:t})},t.randomTraceId=Rt,t.sampler=yt,t.TraceId=At,t.HttpHeaders=Kt,t.InetAddress=V,t.BatchRecorder=Qt,t.ConsoleRecorder=Wt,t.ExplicitContext=zt,t.Instrumentation=$r,t.Request=Zr,t.jsonEncoder=Qr,t.model=Ct,t.parseRequestUrl=zr,Object.defineProperty(t,"__esModule",{value:!0})});

@@ -1604,3 +1604,3 @@ import os from 'os';

traceId = _rec$traceId.traceId;
this.logger("Record at (spanId=".concat(spanId, ", parentId=").concat(parentId, ", ") + "traceId=".concat(traceId, "): ").concat(rec.annotation.toString()));
this.logger("Record at (timestamp=".concat(rec.timestamp, ", spanId=").concat(spanId, ", parentId=").concat(parentId, ", ") + "traceId=".concat(traceId, "): ").concat(rec.annotation.toString()));
}

@@ -1607,0 +1607,0 @@ }, {

@@ -1610,3 +1610,3 @@ 'use strict';

traceId = _rec$traceId.traceId;
this.logger("Record at (spanId=".concat(spanId, ", parentId=").concat(parentId, ", ") + "traceId=".concat(traceId, "): ").concat(rec.annotation.toString()));
this.logger("Record at (timestamp=".concat(rec.timestamp, ", spanId=").concat(spanId, ", parentId=").concat(parentId, ", ") + "traceId=".concat(traceId, "): ").concat(rec.annotation.toString()));
}

@@ -1613,0 +1613,0 @@ }, {

{
"name": "zipkin",
"version": "0.18.0",
"version": "0.18.1",
"description": "The core tracer for Zipkin JS",

@@ -39,3 +39,3 @@ "main": "lib/index.js",

},
"gitHead": "1e5085e1edf4413bbfac9c257b352f761f276918"
"gitHead": "7de397fb8e3fc8213a62e9be44077d3854dde137"
}

@@ -13,3 +13,3 @@ /**

this.logger(
`Record at (spanId=${spanId}, parentId=${parentId}, ` +
`Record at (timestamp=${rec.timestamp}, spanId=${spanId}, parentId=${parentId}, ` +
`traceId=${traceId}): ${rec.annotation.toString()}`

@@ -16,0 +16,0 @@ );

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc