UNPKG

@elastic/apm-rum

Version:
2 lines 60.2 kB
/*! For license information please see elastic-apm-opentracing.umd.min.js.LICENSE */ !function(n){var r={};function i(t){if(r[t])return r[t].exports;var e=r[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,i),e.l=!0,e.exports}i.m=n,i.c=r,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,n){t.exports=function(){"use strict";function c(t){return"function"==typeof t}var n=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},r=0,e=void 0,i=void 0,s=function(t,e){h[r]=t,h[r+1]=e,2===(r+=2)&&(i?i(p):y())},t="undefined"!=typeof window?window:void 0,o=t||{},a=o.MutationObserver||o.WebKitMutationObserver,u="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),f="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function d(){var t=setTimeout;return function(){return t(p,1)}}var h=new Array(1e3);function p(){for(var t=0;t<r;t+=2){var e=h[t],n=h[t+1];e(n),h[t]=void 0,h[t+1]=void 0}r=0}var l,v,g,m,y=void 0;function _(t,e){var n=this,r=new this.constructor(w);void 0===r[b]&&M(r);var i=n._state;if(i){var o=arguments[i-1];s(function(){return F(i,r,o,n._result)})}else A(n,r,t,e);return r}function S(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=new this(w);return L(e,t),e}y=u?function(){return process.nextTick(p)}:a?(v=0,g=new a(p),m=document.createTextNode(""),g.observe(m,{characterData:!0}),function(){m.data=v=++v%2}):f?((l=new MessageChannel).port1.onmessage=p,function(){return l.port2.postMessage(0)}):void 0===t?function(){try{var t=Function("return this")().require("vertx");return void 0===(e=t.runOnLoop||t.runOnContext)?d():function(){e(p)}}catch(t){return d()}}():d();var b=Math.random().toString(36).substring(2);function w(){}var T=void 0,E=1,x=2;function C(t,e,n,r){try{t.call(e,n,r)}catch(t){return t}}function O(t,e,n){var r,i,o,a;e.constructor===t.constructor&&n===_&&e.constructor.resolve===S?(o=t,(a=e)._state===E?I(o,a._result):a._state===x?N(o,a._result):A(a,void 0,function(t){return L(o,t)},function(t){return N(o,t)})):void 0===n?I(t,e):c(n)?(r=e,i=n,s(function(e){var n=!1,t=C(i,r,function(t){n||(n=!0,r!==t?L(e,t):I(e,t))},function(t){n||(n=!0,N(e,t))},e._label);!n&&t&&(n=!0,N(e,t))},t)):I(t,e)}function L(e,t){if(e===t)N(e,new TypeError("You cannot resolve a promise with itself"));else if(i=typeof(r=t),null===r||"object"!==i&&"function"!==i)I(e,t);else{var n=void 0;try{n=t.then}catch(t){return void N(e,t)}O(e,t,n)}var r,i}function k(t){t._onerror&&t._onerror(t._result),j(t)}function I(t,e){t._state===T&&(t._result=e,t._state=E,0!==t._subscribers.length&&s(j,t))}function N(t,e){t._state===T&&(t._state=x,t._result=e,s(k,t))}function A(t,e,n,r){var i=t._subscribers,o=i.length;t._onerror=null,i[o]=e,i[o+E]=n,i[o+x]=r,0===o&&t._state&&s(j,t)}function j(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r=void 0,i=void 0,o=t._result,a=0;a<e.length;a+=3)r=e[a],i=e[a+n],r?F(n,r,i,o):i(o);t._subscribers.length=0}}function F(t,e,n,r){var i=c(n),o=void 0,a=void 0,s=!0;if(i){try{o=n(r)}catch(t){s=!1,a=t}if(e===o)return void N(e,new TypeError("A promises callback cannot return that same promise."))}else o=r;e._state!==T||(i&&s?L(e,o):!1===s?N(e,a):t===E?I(e,o):t===x&&N(e,o))}var R=0;function M(t){t[b]=R++,t._state=void 0,t._result=void 0,t._subscribers=[]}var P=function(){function t(t,e){this._instanceConstructor=t,this.promise=new t(w),this.promise[b]||M(this.promise),n(e)?(this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?I(this.promise,this._result):(this.length=this.length||0,this._enumerate(e),0===this._remaining&&I(this.promise,this._result))):N(this.promise,new Error("Array Methods must be provided an Array"))}return t.prototype._enumerate=function(t){for(var e=0;this._state===T&&e<t.length;e++)this._eachEntry(t[e],e)},t.prototype._eachEntry=function(e,t){var n=this._instanceConstructor,r=n.resolve;if(r===S){var i=void 0,o=void 0,a=!1;try{i=e.then}catch(t){a=!0,o=t}if(i===_&&e._state!==T)this._settledAt(e._state,t,e._result);else if("function"!=typeof i)this._remaining--,this._result[t]=e;else if(n===H){var s=new n(w);a?N(s,o):O(s,e,i),this._willSettleAt(s,t)}else this._willSettleAt(new n(function(t){return t(e)}),t)}else this._willSettleAt(r(e),t)},t.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===T&&(this._remaining--,t===x?N(r,n):this._result[e]=n),0===this._remaining&&I(r,this._result)},t.prototype._willSettleAt=function(t,e){var n=this;A(t,void 0,function(t){return n._settledAt(E,e,t)},function(t){return n._settledAt(x,e,t)})},t}(),H=function(){function e(t){this[b]=R++,this._result=this._state=void 0,this._subscribers=[],w!==t&&("function"!=typeof t&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof e?function(e,t){try{t(function(t){L(e,t)},function(t){N(e,t)})}catch(t){N(e,t)}}(this,t):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return e.prototype.catch=function(t){return this.then(null,t)},e.prototype.finally=function(e){var n=this.constructor;return c(e)?this.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){throw t})}):this.then(e,e)},e}();return H.prototype.then=_,H.all=function(t){return new P(this,t).promise},H.race=function(i){var o=this;return n(i)?new o(function(t,e){for(var n=i.length,r=0;r<n;r++)o.resolve(i[r]).then(t,e)}):new o(function(t,e){return e(new TypeError("You must pass an array to race."))})},H.resolve=S,H.reject=function(t){var e=new this(w);return N(e,t),e},H._setScheduler=function(t){i=t},H._setAsap=function(t){s=t},H._asap=s,H.polyfill=function(){var t=void 0;if("undefined"!=typeof global)t=global;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var e=t.Promise;if(e){var n=null;try{n=Object.prototype.toString.call(e.resolve())}catch(t){}if("[object Promise]"===n&&!e.cast)return}t.Promise=H},H.Promise=H}()},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.FORMAT_BINARY="binary",e.FORMAT_TEXT_MAP="text_map",e.FORMAT_HTTP_HEADERS="http_headers",e.REFERENCE_CHILD_OF="child_of",e.REFERENCE_FOLLOWS_FROM="follows_from"},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(5),i=function(){function t(){}return t.prototype.context=function(){return this._context()},t.prototype.tracer=function(){return this._tracer()},t.prototype.setOperationName=function(t){return this._setOperationName(t),this},t.prototype.setBaggageItem=function(t,e){return this._setBaggageItem(t,e),this},t.prototype.getBaggageItem=function(t){return this._getBaggageItem(t)},t.prototype.setTag=function(t,e){return this._addTags(((n={})[t]=e,n)),this;var n},t.prototype.addTags=function(t){return this._addTags(t),this},t.prototype.log=function(t,e){return this._log(t,e),this},t.prototype.logEvent=function(t,e){return this._log({event:t,payload:e})},t.prototype.finish=function(t){this._finish(t)},t.prototype._context=function(){return r.spanContext},t.prototype._tracer=function(){return r.tracer},t.prototype._setOperationName=function(t){},t.prototype._setBaggageItem=function(t,e){},t.prototype._getBaggageItem=function(t){},t.prototype._addTags=function(t){},t.prototype._log=function(t,e){},t.prototype._finish=function(t){},t}();e.Span=i,e.default=i},function(t,e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var r=new Uint8Array(16);t.exports=function(){return n(r),r}}else{var i=new Array(16);t.exports=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),i[e]=t>>>((3&e)<<3)&255;return i}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(8),i=n(5),o=n(2),a=function(){function t(){}return t.prototype.startSpan=function(t,e){if(void 0===e&&(e={}),e.childOf){var n=r.childOf(e.childOf);e.references?e.references.push(n):e.references=[n],delete e.childOf}return this._startSpan(t,e)},t.prototype.inject=function(t,e,n){return t instanceof o.default&&(t=t.context()),this._inject(t,e,n)},t.prototype.extract=function(t,e){return this._extract(t,e)},t.prototype._startSpan=function(t,e){return i.span},t.prototype._inject=function(t,e,n){},t.prototype._extract=function(t,e){return i.spanContext},t}();e.Tracer=a,e.default=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(2),i=n(10),o=n(4);e.tracer=null,e.spanContext=null,e.span=null,e.initialize=function(){e.tracer=new o.default,e.span=new r.default,e.spanContext=new i.default}},function(n,r,i){var o,a,s;!function(t,e){"use strict";a=[i(7)],void 0===(s="function"==typeof(o=function(s){var n=/(^|@)\S+\:\d+/,r=/^\s*at .*(\S+\:\d+|\(native\))/m,i=/^(eval@)?(\[native code\])?$/;function o(t,e,n){if("function"==typeof Array.prototype.map)return t.map(e,n);for(var r=new Array(t.length),i=0;i<t.length;i++)r[i]=e.call(n,t[i]);return r}function a(t,e,n){if("function"==typeof Array.prototype.filter)return t.filter(e,n);for(var r=[],i=0;i<t.length;i++)e.call(n,t[i])&&r.push(t[i]);return r}return{parse:function(t){if(void 0!==t.stacktrace||void 0!==t["opera#sourceloc"])return this.parseOpera(t);if(t.stack&&t.stack.match(r))return this.parseV8OrIE(t);if(t.stack)return this.parseFFOrSafari(t);throw new Error("Cannot parse given Error object")},extractLocation:function(t){if(-1===t.indexOf(":"))return[t];var e=/(.+?)(?:\:(\d+))?(?:\:(\d+))?$/.exec(t.replace(/[\(\)]/g,""));return[e[1],e[2]||void 0,e[3]||void 0]},parseV8OrIE:function(t){var e=a(t.stack.split("\n"),function(t){return!!t.match(r)},this);return o(e,function(t){-1<t.indexOf("(eval ")&&(t=t.replace(/eval code/g,"eval").replace(/(\(eval at [^\()]*)|(\)\,.*$)/g,""));var e=t.replace(/^\s+/,"").replace(/\(eval code/g,"(").split(/\s+/).slice(1),n=this.extractLocation(e.pop()),r=e.join(" ")||void 0,i=-1<function(t,e){{if("function"==typeof Array.prototype.indexOf)return t.indexOf(e);for(var n=0;n<t.length;n++)if(t[n]===e)return n;return-1}}(["eval","<anonymous>"],n[0])?void 0:n[0];return new s(r,void 0,i,n[1],n[2],t)},this)},parseFFOrSafari:function(t){var e=a(t.stack.split("\n"),function(t){return!t.match(i)},this);return o(e,function(t){if(-1<t.indexOf(" > eval")&&(t=t.replace(/ line (\d+)(?: > eval line \d+)* > eval\:\d+\:\d+/g,":$1")),-1===t.indexOf("@")&&-1===t.indexOf(":"))return new s(t);var e=t.split("@"),n=this.extractLocation(e.pop()),r=e.join("@")||void 0;return new s(r,void 0,n[0],n[1],n[2],t)},this)},parseOpera:function(t){return!t.stacktrace||-1<t.message.indexOf("\n")&&t.message.split("\n").length>t.stacktrace.split("\n").length?this.parseOpera9(t):t.stack?this.parseOpera11(t):this.parseOpera10(t)},parseOpera9:function(t){for(var e=/Line (\d+).*script (?:in )?(\S+)/i,n=t.message.split("\n"),r=[],i=2,o=n.length;i<o;i+=2){var a=e.exec(n[i]);a&&r.push(new s(void 0,void 0,a[2],a[1],void 0,n[i]))}return r},parseOpera10:function(t){for(var e=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,n=t.stacktrace.split("\n"),r=[],i=0,o=n.length;i<o;i+=2){var a=e.exec(n[i]);a&&r.push(new s(a[3]||void 0,void 0,a[2],a[1],void 0,n[i]))}return r},parseOpera11:function(t){var e=a(t.stack.split("\n"),function(t){return!!t.match(n)&&!t.match(/^Error created at/)},this);return o(e,function(t){var e,n=t.split("@"),r=this.extractLocation(n.pop()),i=n.shift()||"",o=i.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^\)]*\)/g,"")||void 0;i.match(/\(([^\)]*)\)/)&&(e=i.replace(/^[^\(]+\(([^\)]*)\)$/,"$1"));var a=void 0===e||"[arguments not available]"===e?void 0:e.split(",");return new s(o,a,r[0],r[1],r[2],t)},this)}}})?o.apply(r,a):o)||(n.exports=s)}()},function(n,r,t){var i,o,a;!function(t,e){"use strict";o=[],void 0===(a="function"==typeof(i=function(){function e(t){return!isNaN(parseFloat(t))&&isFinite(t)}function t(t,e,n,r,i,o){void 0!==t&&this.setFunctionName(t),void 0!==e&&this.setArgs(e),void 0!==n&&this.setFileName(n),void 0!==r&&this.setLineNumber(r),void 0!==i&&this.setColumnNumber(i),void 0!==o&&this.setSource(o)}return t.prototype={getFunctionName:function(){return this.functionName},setFunctionName:function(t){this.functionName=String(t)},getArgs:function(){return this.args},setArgs:function(t){if("[object Array]"!==Object.prototype.toString.call(t))throw new TypeError("Args must be an Array");this.args=t},getFileName:function(){return this.fileName},setFileName:function(t){this.fileName=String(t)},getLineNumber:function(){return this.lineNumber},setLineNumber:function(t){if(!e(t))throw new TypeError("Line Number must be a Number");this.lineNumber=Number(t)},getColumnNumber:function(){return this.columnNumber},setColumnNumber:function(t){if(!e(t))throw new TypeError("Column Number must be a Number");this.columnNumber=Number(t)},getSource:function(){return this.source},setSource:function(t){this.source=String(t)},toString:function(){return(this.getFunctionName()||"{anonymous}")+"("+(this.getArgs()||[]).join(",")+")"+(this.getFileName()?"@"+this.getFileName():"")+(e(this.getLineNumber())?":"+this.getLineNumber():"")+(e(this.getColumnNumber())?":"+this.getColumnNumber():"")}},t})?i.apply(r,o):i)||(n.exports=a)}()},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(1),i=n(9),o=n(2);e.childOf=function(t){return t instanceof o.default&&(t=t.context()),new i.default(r.REFERENCE_CHILD_OF,t)},e.followsFrom=function(t){return t instanceof o.default&&(t=t.context()),new i.default(r.REFERENCE_FOLLOWS_FROM,t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(2),i=function(){function t(t,e){this._type=t,this._referencedContext=e instanceof r.default?e.context():e}return t.prototype.type=function(){return this._type},t.prototype.referencedContext=function(){return this._referencedContext},t}();e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){};e.SpanContext=r,e.default=r},function(t,e,n){"use strict";n.r(e);var r=n(3),o=n.n(r),i=[].slice;for(var a=[],s=0;s<256;++s)a[s]=(s+256).toString(16).substr(1);function c(t){if(t&&t.traceId&&t.id&&t.parentId){var e=t.sampled?"01":"00",n=t.sampled?t.id:t.parentId;return"00-"+t.traceId+"-"+n+"-"+e}}function p(e,t){var n=!1;return"string"==typeof t?n=e===t:Array.isArray(t)&&t.forEach(function(t){n||(n=p(e,t))}),n}function l(t){var e,n,r,i;return(e=o()(),r=n||0,[(i=a)[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]]].join("")).substr(0,t)}function u(){return"undefined"!=typeof window&&"function"==typeof Array.prototype.forEach&&"function"==typeof JSON.stringify&&"function"==typeof Function.bind&&window.performance&&"function"==typeof window.performance.now&&"withCredentials"in new window.XMLHttpRequest}function f(t,e,n){if(n&&t){var r=E(t);return e&&(e=String(e)),n[r]=e,n}}var d=["fetchStart","domainLookupStart","domainLookupEnd","connectStart","connectEnd","secureConnectionStart","requestStart","responseStart","responseEnd","domLoading","domInteractive","domContentLoadedEventStart","domContentLoadedEventEnd","domComplete","loadEventStart","loadEventEnd"];function h(){return window.performance.timing.fetchStart}function v(){return{page:{referer:document.referrer,url:window.location.href}}}function g(t){return t&&t.split("?")[0]}function m(t){return null!==t&&"object"==typeof t}function y(t,e,n){for(var r=0,i=e.length;r<i;++r){var o=e[r];if(m(o)||"function"==typeof o)for(var a=Object.keys(o),s=0,c=a.length;s<c;s++){var u=a[s],f=o[u];n&&m(f)?(m(t[u])||(t[u]=Array.isArray(f)?[]:{}),y(t[u],[f],!1)):t[u]=f}}return t}function _(){if("undefined"!=typeof document){var t=document.currentScript;return t||function(){if("undefined"!=typeof document)for(var t=document.getElementsByTagName("script"),e=0,n=t.length;e<n;e++){var r=t[e];if(0<r.src.indexOf("elastic"))return r}}()}}function S(t){return y(t,i.call(arguments,1),!1)}function b(t){return y(t,i.call(arguments,1),!0)}function w(t){return void 0===t}function T(){}function E(t){return t.replace(/[.*"]/g,"_")}function x(){var n,r,i,t=(n=window.performance.timing,r=n.fetchStart,i={},d.forEach(function(t){var e=n[t];e&&r<=e&&(i[t]=e-r)}),i),e=function(){var t={},e=window.performance;if("function"==typeof e.getEntriesByType){var n=e.getEntriesByType("paint");if(0<n.length)for(var r=e.timing,i=r.fetchStart-r.navigationStart,o=0;o<n.length;o++){var a=n[o],s=0<=i?a.startTime-i:a.startTime;t[a.name]=s}}return t}(),o={timeToFirstByte:t.responseStart,domInteractive:t.domInteractive,domComplete:t.domComplete};return e["first-contentful-paint"]&&(o.firstContentfulPaint=e["first-contentful-paint"]),{navigationTiming:t,agent:o}}function C(){return window.performance.now()}function O(t,e){return w(e)||w(t)?null:parseFloat(e-t)}var L={fetchInProgress:!1};function k(t){return"__apm_symbol__"+t}function I(t,e,n){for(var r=t;r&&!r.hasOwnProperty(e);)r=Object.getPrototypeOf(r);!r&&t[e]&&(r=t);var i,o,a,s,c=k(e);if(r&&!(i=r[c])){i=r[c]=r[e];var u=r&&Object.getOwnPropertyDescriptor(r,e);if(!(s=u)||!1!==s.writable&&("function"!=typeof s.get||void 0!==s.set)){var f=n(i,c,e);r[e]=function(){return f(this,arguments)},o=r[e],a=i,o[k("OriginalDelegate")]=a}}return i}var N=k("xhrIgnore"),A=k("xhrSync"),j=k("xhrURL"),F=k("xhrMethod"),R="schedule",M="invoke",P="clear",H="addEventListener",D="removeEventListener",B=["link","css","script","img","xmlhttprequest","fetch","beacon","iframe"],q=3e5,Q="page-load",U="Unknown",z=60,$=1024,V="transaction:end",X="config:change",Y="xmlhttprequest",J="fetch",W="history",Z=k("xhrTask"),G=k("xhrListener"),K=k("xhrScheduled");function tt(a){var t=XMLHttpRequest.prototype,s=t[H],c=t[D];if(!s){var e=window.XMLHttpRequestEventTarget;if(e){var n=e.prototype;s=n[H],c=n[D]}}var u="readystatechange";function f(t){t.state=M,t.ignore||a(M,t)}var r=I(t,"open",function(){return function(t,e){return t[F]=e[0],t[j]=e[1],t[A]=!1===e[2],r.apply(t,e)}}),d=I(t,"send",function(){return function(t,e){var n={source:Y,state:"",type:"macroTask",ignore:t[N],data:{target:t,method:t[F],sync:t[A],url:t[j],args:e,aborted:!1}},r=function(t){XMLHttpRequest[K]=!1,t.state=R,t.ignore||a(R,t);var e=t.data,n=e.target,r=n[G];s||(s=n[H],c=n[D]),r&&c.call(n,u,r);var i=n[G]=function(){n.readyState===n.DONE&&!e.aborted&&XMLHttpRequest[K]&&t.state===R&&f(t)};s.call(n,u,i),n[Z]||(n[Z]=t);var o=d.apply(n,e.args);return XMLHttpRequest[K]=!0,o}(n);return t[A]&&f(n),r}}),i=I(t,"abort",function(){return function(t,e){var n,r=t[Z];if(r&&"string"==typeof r.type){if(r.data&&r.data.aborted)return;(n=r).state=P,a(P,n),n.data.aborted=!0}return i.apply(t,e)}})}var et=n(0);function nt(s){if(window.fetch&&window.Request){var c=window.fetch;window.fetch=function(t,e){var i,n,o=this,r=arguments;if("string"==typeof t)i=new Request(t,e),n=t;else{if(!t)return c.apply(o,r);n=(i=t).url}var a={source:J,state:"",type:"macroTask",data:{target:i,method:i.method,sync:!1,url:n,args:r,aborted:!1}};return new et.Promise(function(e,n){var t,r;L.fetchInProgress=!0,(t=a).state=R,s(R,t);try{r=c.apply(o,[i])}catch(t){return n(t),a.data.error=t,u(a),void(L.fetchInProgress=!1)}r.then(function(t){e(t),et.Promise.resolve().then(function(){a.data.response=t,u(a)})},function(t){n(t),et.Promise.resolve().then(function(){a.data.error=t,u(a)})}),L.fetchInProgress=!1})}}function u(t){t.state=M,s(M,t)}}var rt=function(){function t(){this.observers={}}var e=t.prototype;return e.observe=function(e,n){var r=this;if("function"==typeof n)return this.observers[e]||(this.observers[e]=[]),this.observers[e].push(n),function(){var t=r.observers[e].indexOf(n);-1<t&&r.observers[e].splice(t,1)}},e.sendOnly=function(t,e){var n=this.observers[t];n&&n.forEach(function(t){try{t.apply(void 0,e)}catch(t){console.log(t,t.stack)}})},e.send=function(t,e){this.sendOnly(t+":before",e),this.sendOnly(t,e),this.sendOnly(t+":after",e)},t}(),it=new rt,ot=!1;function at(){return ot||(ot=!0,tt(function(t,e){it.send(Y,[t,e])}),nt(function(t,e){it.send(J,[t,e])}),function(r){if(window.history){var i=history.pushState;"function"==typeof i&&(history.pushState=function(t,e,n){r(M,{source:W,data:{state:t,title:e,url:n}}),i.apply(this,arguments)})}}(function(t,e){it.send(W,[t,e])})),it}var st=!1,ct=!1;var ut=n(6),ft=n.n(ut);function dt(t){var e=t.error,n=t.filename,r=t.lineno,i=t.colno,o=[];if(e)try{o=ft.a.parse(e)}catch(t){}return 0===o.length&&(o=[{fileName:n,lineNumber:r,columnNumber:i}]),o.map(function(t){return t.functionName&&(t.functionName=(e=t.functionName,e=1<(n=(e=(e=(e=1<(n=e.split("/")).length?["Object",n[n.length-1]].join("."):n[0]).replace(/.<$/gi,".<anonymous>")).replace(/^Anonymous function$/,"<anonymous>")).split(".")).length?n[n.length-1]:n[0])),t;var e,n}).map(function(t){var e=t.fileName,n=t.lineNumber,r=t.columnNumber,i=t.functionName,o=void 0===i?"<anonymous>":i;if(!e&&!n)return{};if(!r&&!n)return{};var a,s,c,u,f=(void 0===(a=e)&&(a=""),"<anonymous>"===a&&(a=""),a),d=(s=f,c=window.location.origin||window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:""),-1<s.indexOf(c)&&(s=s.replace(c+"/","")),s);return(u=f)&&0===window.location.href.indexOf(u)&&(d="(inline script)"),{abs_path:e,filename:d,function:o,lineno:n,colno:r}})}var ht={service:{name:[$,!0],version:!0,agent:{version:[$,!0]},environment:!0}},pt={"*":!0,headers:{"*":!0}},lt={user:{id:!0,email:!0,username:!0},tags:{"*":!0},http:{response:pt},response:pt},vt={name:[$,!0],type:[$,!0],id:[$,!0],trace_id:[$,!0],parent_id:[$,!0],transaction_id:[$,!0],subtype:!0,action:!0,context:lt},gt={name:!0,parent_id:!0,type:[$,!0],id:[$,!0],trace_id:[$,!0],span_count:{started:[$,!0]},context:lt},mt={id:[$,!0],trace_id:!0,transaction_id:!0,parent_id:!0,culprit:!0,exception:{type:!0},transaction:{type:!0},context:lt};function yt(t){return null==t||""===t||void 0===t}function _t(t,e,n){var r,i,o,a,s=(r=t[e],i=n[0],o=n[1],void 0===i&&(i=$),void 0===o&&(o=!1),void 0===a&&(a="N/A"),o&&yt(r)&&(r=a),"string"==typeof r?r.substring(0,i):r);yt(s)?delete t[e]:t[e]=s}function St(r,i,o){void 0===r&&(r={}),void 0===o&&(o=i);for(var a=Object.keys(r),s=[],t=function(t){var e=a[t],n=!0===r[e]?s:r[e];Array.isArray(n)?"*"===e?Object.keys(o).forEach(function(t){return _t(o,t,n)}):_t(o,e,n):St(n,i,o[e])},e=0;e<a.length;e++)t(e);return i}var bt=function(){function t(t,e,n){this._apmServer=t,this._configService=e,this._transactionService=n}var e=t.prototype;return e.createErrorDataModel=function(t){var e=dt(t),n=e.filter(function(t){var e=t.filename,n=t.lineno;return void 0!==e&&void 0!==n}),r="(inline script)",i=n[n.length-1];i&&i.filename&&(r=i.filename);var o=t.message,a=t.error,s=o,c="",u={};a&&"object"==typeof a&&(s=s||a.message,c=a.name,u=this._getErrorProperties(a)),c||s&&-1<s.indexOf(":")&&(c=s.split(":")[0]);var f=this._configService.get("context"),d=b({},v(),f,u),h={id:l(),culprit:r,exception:{message:s,stacktrace:n,type:c},context:d},p=this._transactionService.getCurrentTransaction();return p&&(h.trace_id=p.traceId,h.parent_id=p.id,h.transaction_id=p.id,h.transaction={type:p.type,sampled:p.sampled}),St(mt,h)},e.logErrorEvent=function(t,e){if(void 0!==t){var n=this.createErrorDataModel(t);if(void 0!==n.exception.message)return e?this._apmServer.sendErrors([n]):this._apmServer.addError(n)}},e.registerListeners=function(){var e=this;window.addEventListener("error",function(t){return e.logErrorEvent(t)}),window.addEventListener("unhandledrejection",function(t){return e.logPromiseEvent(t)})},e.logPromiseEvent=function(t){var e="Unhandled promise rejection: ",n=t.reason;null==n?this.logError(e+"<no reason specified>"):"string"==typeof n.message?this.logError({message:e+n.message,stack:n.stack?n.stack:null}):"object"!=typeof n&&this.logError(e+n)},e.logError=function(t){var e={};return"string"==typeof t?e.message=t:e.error=t,this.logErrorEvent(e)},e._getErrorProperties=function(n){var r={};return Object.keys(n).forEach(function(t){if("stack"!==t){var e=n[t];if(null!==e){switch(typeof e){case"function":return;case"object":if("function"!=typeof e.toISOString)return;e=e.toISOString()}r[t]=e}}}),r},t}(),wt=function(r){r.registerServiceCreator("ErrorLogging",function(){var t=r.getService("ApmServer"),e=r.getService("ConfigService"),n=r.getService("TransactionService");return new bt(t,e,n)})},Tt=[["#","hash"],["?","query"],["/","path"],["@","auth",1],[NaN,"host",void 0,1]],Et=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,xt=function(){function t(t){var e,n=this.extractProtocol(t||""),r=n.protocol,i=n.address,o=n.slashes,a=!r&&!o,s=this.getLocation(),c=Tt.slice();i=i.replace("\\","/"),o||(c[2]=[NaN,"path"]);for(var u=0;u<c.length;u++){var f=c[u],d=f[0],h=f[1];if("string"==typeof d){if(~(e=i.indexOf(d))){var p=f[2];if(p){var l=i.lastIndexOf(d);e=Math.max(e,l),this[h]=i.slice(0,e),i=i.slice(e+p)}else this[h]=i.slice(e),i=i.slice(0,e)}}else this[h]=i,i="";this[h]=this[h]||a&&f[3]&&s[h]||"",f[3]&&(this[h]=this[h].toLowerCase())}a&&"/"!==this.path.charAt(0)&&(this.path="/"+this.path),this.relative=a,this.protocol=r||s.protocol,this.origin=this.protocol&&this.host&&"file:"!==this.protocol?this.protocol+"//"+this.host:"null",this.href=this.toString()}var e=t.prototype;return e.toString=function(){var t=this.protocol;if(t+="//",this.auth){var e="[REDACTED]",n=this.auth.split(":");t+=(n[0]?e:"")+(n[1]?":"+e:"")+"@"}return t+=this.host,t+=this.path,t+=this.query,t+=this.hash},e.getLocation=function(){var t={};return"undefined"!=typeof window&&(t=window),t.location},e.extractProtocol=function(t){var e=Et.exec(t);return{protocol:e[1]?e[1].toLowerCase():"",slashes:!!e[2],address:e[3]}},t}(),Ct=function(){function t(t,e,n,r){this._apmServer=t,this._configService=e,this._logginService=n,this._transactionService=r}var e=t.prototype;return e.init=function(t){var n=this;void 0===t&&(t={}),this._configService.events.observe(V+":after",function(t){var e=n.createTransactionPayload(t);e&&n._apmServer.addTransaction(e)}),t[W]&&it.observe(W,this.getHistorySub()),t[Y]&&it.observe(Y,this.getXHRSub()),t[J]&&it.observe(J,this.getFetchSub())},e.getHistorySub=function(){var n=this._transactionService;return function(t,e){e.source===W&&t===M&&n.startTransaction(e.data.title,"route-change",{managed:!0,canReuse:!0})}},e.getXHRSub=function(){var n=this;return function(t,e){e.source!==Y||L.fetchInProgress||n.processAPICalls(t,e)}},e.getFetchSub=function(){var n=this;return function(t,e){e.source===J&&n.processAPICalls(t,e)}},e.processAPICalls=function(t,e){var n=this._configService,r=this._transactionService;if(t===R&&e.data){var i=new xt(e.data.url),o=e.data.method+" "+(i.relative?i.path:g(i.href)),a=r.startSpan(o,"external.http"),s=r.addTask();if(!a)return;var c=n.get("distributedTracing"),u=n.get("distributedTracingOrigins"),f=new xt(window.location.href),d=p(i.origin,f.origin)||p(i.origin,u),h=e.data.target;c&&d&&h&&this.injectDtHeader(a,h),a.addContext({http:{method:e.data.method,url:i.href}}),a.sync=e.data.sync,e.data.span=a,e.id=s}t===M&&e.data&&e.data.span&&(void 0!==e.data.target.status?e.data.span.addContext({http:{status_code:e.data.target.status}}):e.data.response&&e.data.span.addContext({http:{status_code:e.data.response.status}}),e.data.span.end()),t===M&&e.id&&r.removeTask(e.id)},e.injectDtHeader=function(t,e){var n,r=this._configService,i=r.get("distributedTracingHeaderName"),o=r.get("distributedTracingHeaderValueCallback")(t),a=/^[\da-f]{2}-[\da-f]{32}-[\da-f]{16}-[\da-f]{2}$/.test(n=o)&&"00000000000000000000000000000000"!==n.slice(3,35)&&"0000000000000000"!==n.slice(36,52);i&&o&&a&&("function"==typeof e.setRequestHeader?e.setRequestHeader(i,o):e.headers&&"function"==typeof e.headers.append?e.headers.append(i,o):e[i]=o)},e.extractDtHeader=function(t){var e=this._configService.get("distributedTracingHeaderName");if(t)return function(t){var e=/^([\da-f]{2})-([\da-f]{32})-([\da-f]{16})-([\da-f]{2})$/.exec(t);if(e){var n="00"!==e[4];return{traceId:e[2],id:e[3],sampled:n}}}(t[e])},e.setTransactionContext=function(t){var e=this._configService.get("context");e&&t.addContext(e)},e.filterTransaction=function(t){var e=this._configService.get("transactionDurationThreshold"),n=t.duration();if(!n)return!1;if(e<n)return!1;if(0===t.spans.length)return!1;t.sampled||t.resetSpans();var r=this._configService.get("browserResponsivenessInterval");if(this._configService.get("checkBrowserResponsiveness")&&t.options.checkBrowserResponsiveness){var i=this._configService.get("browserResponsivenessBuffer");if(!this.checkBrowserResponsiveness(t,r,i))return!1}return!0},e.adjustTransactionTime=function(t){var e=t.spans,n=function(t){for(var e=t[0],n=1;n<t.length;n++){var r=t[n];e._start>r._start&&(e=r)}return e}(e);n&&n._start<t._start&&(t._start=n._start);var r=function(t){for(var e=null,n=0;n<t.length;n++){var r=t[n];-1===String(r.type).indexOf("external")&&(!e||e._end<r._end)&&(e=r)}return e}(e);r&&r._end>t._end&&(t._end=r._end);for(var i=t._end,o=0;o<e.length;o++){var a=e[o];a._end>i&&(a._end=i,a.type+=".truncated"),a._start>i&&(a._start=i)}},e.prepareTransaction=function(e){if(e.spans.sort(function(t,e){return t._start-e._start}),this._configService.get("groupSimilarSpans")){var t=this._configService.get("similarSpanThreshold");e.spans=this.groupSmallContinuouslySimilarSpans(e,t)}e.spans=e.spans.filter(function(t){return 0<t.duration()&&t._start>=e._start&&t._end<=e._end}),this.setTransactionContext(e)},e.createTransactionDataModel=function(n){var t=this._configService.get("context"),r=n._start,e=n.spans.map(function(t){var e={id:t.id,transaction_id:n.id,parent_id:t.parentId||n.id,trace_id:n.traceId,name:t.name,type:t.type,subType:t.subType,action:t.action,sync:t.sync,start:t._start-r,duration:t.duration(),context:t.context};return St(vt,e)}),i=b({},t,n.context),o={id:n.id,trace_id:n.traceId,name:n.name,type:n.type,duration:n.duration(),spans:e,context:i,marks:n.marks,breakdown:n.breakdownTimings,span_count:{started:e.length},sampled:n.sampled};return St(gt,o)},e.createTransactionPayload=function(t){if(this.adjustTransactionTime(t),this.prepareTransaction(t),this.filterTransaction(t))return this.createTransactionDataModel(t)},e.convertTransactionsToServerModel=function(t){var e=this;return t.map(function(t){return e.createTransactionDataModel(t)})},e.groupSmallContinuouslySimilarSpans=function(o,a){var s=o.duration(),c=[],u=1;return o.spans.forEach(function(t,e){if(0===c.length)c.push(t);else{var n=c[c.length-1],r=n.type===t.type&&n.subType===t.subType&&n.action===t.action&&n.name===t.name&&t.duration()/s<a&&(t._start-n._end)/s<a,i=o.spans.length===e+1;r&&(u++,n._end=t._end),1<u&&(!r||i)&&(n.name=u+"x "+n.name,u=1),r||c.push(t)}}),c},e.checkBrowserResponsiveness=function(t,e,n){var r=t.browserResponsivenessCounter;if(void 0===e||void 0===r)return!0;var i=t.duration();return Math.floor(i/e)<=r+n},t}(),Ot=function(){function t(t,e,n){void 0===n&&(n={}),t||(t=U),e||(e="custom"),this.name=t,this.type=e,this.options=n,this.id=n.id||l(16),this.traceId=n.traceId,this.sampled=n.sampled,this.timestamp=n.timestamp,this._start=C(),this._end=void 0,this.ended=!1,this.onEnd=n.onEnd}var e=t.prototype;return e.ensureContext=function(){this.context||(this.context={})},e.addTags=function(t){console.warn("addTags deprecated, please use addLabels"),this.addLabels(t)},e.addLabels=function(e){this.ensureContext();var n=this.context;n.tags||(n.tags={}),Object.keys(e).forEach(function(t){return f(t,e[t],n.tags)})},e.addContext=function(t){t&&(this.ensureContext(),b(this.context,t))},e.end=function(){this.ended||(this.ended=!0,this._end=C(),this.callOnEnd())},e.callOnEnd=function(){"function"==typeof this.onEnd&&this.onEnd(this)},e.duration=function(){return O(this._start,this._end)},t}();var Lt=function(o){var t,e;function n(t,e,n){var r;if((r=o.call(this,t,e,n)||this).parentId=r.options.parentId,r.subType=void 0,r.action=void 0,-1!==r.type.indexOf(".")){var i=r.type.split(".",3);r.type=i[0],r.subType=i[1],r.action=i[2]}return r.sync=r.options.sync,r}return e=o,(t=n).prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e,n}(Ot),kt=[["fetchStart","responseEnd","Network"],["domLoading","domInteractive","DOM Processing"],["domInteractive","loadEventEnd","Page Render"]];function It(t){return{value:t}}function Nt(t,e){var n=e.details,r=e.count,i=void 0===r?1:r,o=e.duration;return{transaction:t,span:n,samples:{"span.self_time.count":It(i),"span.self_time.sum.us":It(o)}}}var At=function(i){var t,e;function n(t,e,n){var r;return(r=i.call(this,t,e,n)||this).traceId=l(),r.marks=void 0,r.spans=[],r._activeSpans={},r.nextAutoTaskId=1,r._scheduledTasks=[],r.captureTimings=!1,r.selfTime=null,r.breakdownTimings=[],r.childStart=0,r.childDuration=0,r.sampled=Math.random()<=r.options.transactionSampleRate,r}e=i,(t=n).prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e;var r=n.prototype;return r.addMarks=function(t){this.marks=b(this.marks||{},t)},r.mark=function(t){var e=E(t),n=C()-this._start,r={};r[e]=n,this.addMarks({custom:r})},r.canReuse=function(t){return void 0===t&&(t=5e3),!!this.options.canReuse&&!this.ended&&C()-this._start<t},r.redefine=function(t,e,n){t&&(this.name=t),e&&(this.type=e),n&&(this.options=S(this.options,n))},r.startSpan=function(t,e,n){var r=this;if(!this.ended){var i=S({},n);i.onEnd=function(t){r._onSpanEnd(t)},i.traceId=this.traceId,i.sampled=this.sampled,i.parentId||(i.parentId=this.id);var o=new Lt(t,e,i);return this._activeSpans[o.id]=o,1===Object.keys(this._activeSpans).length&&(this.childStart=o._start),o}},r.isFinished=function(){return 0===this._scheduledTasks.length},r.detectFinish=function(){this.isFinished()&&this.end()},r.end=function(){if(!this.ended){for(var t in this.ended=!0,this._end=C(),this._activeSpans){var e=this._activeSpans[t];e.type=e.type+".truncated",e.end()}this.selfTime=this.duration()-this.childDuration;var n=v();this.addContext(n),this.callOnEnd()}},r.captureBreakdown=function(){this.breakdownTimings=function(t,e){void 0===e&&(e=window.performance.timing);var s=[],n=t.duration(),r=t.name,i=t.type,o=t.sampled,c={name:r,type:i};if(s.push({transaction:c,samples:{"transaction.duration.count":It(1),"transaction.duration.sum.us":It(n),"transaction.breakdown.count":It(o?1:0)}}),!o)return s;if(i===Q&&e)for(var a=0;a<kt.length;a++){var u=kt[a],f=O(e[u[0]],e[u[1]]);0!==f&&null!=f&&s.push(Nt(c,{details:{type:u[2]},duration:f}))}else{var d=function(t){var e={},n=t.selfTime;e.app={count:1,duration:n};for(var r=t.spans,i=0;i<r.length;i++){var o=r[i],a=o.type,s=o.subType,c=o.duration();if(0!==c&&null!=c){var u=a;s&&(u+="."+s),e[u]||(e[u]={duration:0,count:0}),e[u].count++,e[u].duration+=c}}return e}(t);Object.keys(d).forEach(function(t){var e=t.split("."),n=e[0],r=e[1],i=d[t],o=i.duration,a=i.count;s.push(Nt(c,{details:{type:n,subtype:r},duration:o,count:a}))})}return s}(this)},r.addTask=function(t){if(void 0===t&&(t="task"+this.nextAutoTaskId++),-1==this._scheduledTasks.indexOf(t))return this._scheduledTasks.push(t),t},r.removeTask=function(t){var e=this._scheduledTasks.indexOf(t);-1<e&&this._scheduledTasks.splice(e,1),this.detectFinish()},r.resetSpans=function(){this.spans=[]},r._onSpanEnd=function(t){this.spans.push(t),delete this._activeSpans[t.id],0===Object.keys(this._activeSpans).length&&(this.childDuration+=t._end-this.childStart,this.childStart=0)},n}(Ot),jt=[["domainLookupStart","domainLookupEnd","Domain lookup"],["connectStart","connectEnd","Making a connection to the server"],["requestStart","responseEnd","Requesting and receiving the document"],["domLoading","domInteractive","Parsing the document, executing sync. scripts"],["domContentLoadedEventStart","domContentLoadedEventEnd",'Fire "DOMContentLoaded" event'],["loadEventStart","loadEventEnd",'Fire "load" event']];function Ft(t,e,n,r,i){return void 0===i&&(i=0),"number"==typeof t&&"number"==typeof e&&i<=t&&t<e&&n<=t-i&&e-i<=r&&e-t<q&&t-i<q&&e-i<q}function Rt(t){var e={transfer_size:t.transferSize,encoded_body_size:t.encodedBodySize,decoded_body_size:t.decodedBodySize},n=function(t){void 0===t&&(t=[]);for(var e=[],n=0;n<t.length;n++){var r=t[n],i=r.name,o=r.duration,a=r.description,s=i;a&&(s+=";desc="+a),o&&(s+=";dur="+o),e.push(s)}return e.join(", ")}(t.serverTiming);return n&&(e.headers={"server-timing":n}),e}function Mt(t){var e=t.name,n=t.initiatorType,r=t.startTime,i=t.responseEnd,o="resource";n&&(o+="."+n);var a=g(e),s=new Lt(a,o);return s.addContext({http:{url:e,response:Rt(t)}}),s._start=r,s.end(),s._end=i,s}function Pt(e){if(e.captureTimings){var t=window.performance,n=e._end;if(e.type===Q){if(e.marks&&e.marks.custom){var r=e.marks.custom;Object.keys(r).forEach(function(t){r[t]+=e._start})}e._start=0;var i=t.timing;(function(t,e,n,r){for(var i=[],o=0;o<jt.length;o++){var a=t[jt[o][0]],s=t[jt[o][1]];if(Ft(a,s,n,r,e)){var c=new Lt(jt[o][2],"hard-navigation.browser-timing");"requestStart"===jt[o][0]&&(c.pageResponse=!0),c._start=a-e,c.ended=!0,c._end=s-e,i.push(c)}}return i})(i,i.fetchStart,0,n).forEach(function(t){t.traceId=e.traceId,t.sampled=e.sampled,t.pageResponse&&e.options.pageLoadSpanId&&(t.id=e.options.pageLoadSpanId),e.spans.push(t)}),e.addMarks(x())}if("function"==typeof t.getEntriesByType){var o=e._start;if(function(t,e,n,r){for(var i=[],o=0;o<t.length;o++){var a=t[o],s=a.initiatorType,c=a.name,u=a.startTime,f=a.responseEnd;if("xmlhttprequest"!==s&&"fetch"!==s&&c)if(-1!==B.indexOf(s)){if(!Ft(u,f,n,r))continue;i.push(Mt(t[o]))}else{if(null!=s)continue;for(var d=!1,h=0;h<e.length;h++){var p=c.lastIndexOf(e[h]);if(-1<p&&p===c.length-e[h].length){d=!0;break}}!d&&Ft(u,f,n,r)&&i.push(Mt(t[o]))}}return i}(t.getEntriesByType("resource"),function(t){for(var e=t.spans,n=[],r=0;r<e.length;r++){var i=e[r];"external"===i.type&&"http"===i.subType||n.push(i.name.split(" ")[1])}return n}(e),o,n).forEach(function(t){return e.spans.push(t)}),function(t,e,n){for(var r=[],i=0;i<t.length;i++){var o=t[i],a=o.name,s=o.startTime,c=o.duration,u=s+c;if(!(c<=z)&&Ft(s,u,e,n)){var f=new Lt(a,"app");f._start=s,f.end(),f._end=u,r.push(f)}}return r}(t.getEntriesByType("measure"),o,n).forEach(function(t){return e.spans.push(t)}),e.type===Q){var a=t.getEntriesByType("navigation");a&&0<a.length&&(a=a[0],e.addContext({response:Rt(a)}))}}}}var Ht=function(){function t(t,e){this._config=e,this._logger=t,this.currentTransaction=void 0}var e=t.prototype;return e.ensureCurrentTransaction=function(t){t||(t=this.createOptions());var e=this.getCurrentTransaction();return e||(t.canReuse=!0,t.managed=!0,this.createTransaction(void 0,void 0,t))},e.getCurrentTransaction=function(){if(this.currentTransaction&&!this.currentTransaction.ended)return this.currentTransaction},e.setCurrentTransaction=function(t){this.currentTransaction=t},e.createTransaction=function(t,e,n){var r=new At(t,e,n);return this.setCurrentTransaction(r),n.checkBrowserResponsiveness&&this.startCounter(r),r},e.startCounter=function(t){t.browserResponsivenessCounter=0;var e=this._config.get("browserResponsivenessInterval");if(void 0!==e)var n=setInterval(function(){t.ended?window.clearInterval(n):t.browserResponsivenessCounter++},e)},e.createOptions=function(t){var e=this._config.config,n=S({transactionSampleRate:e.transactionSampleRate},t);return n.managed&&(n=S({pageLoadTraceId:e.pageLoadTraceId,pageLoadSampled:e.pageLoadSampled,pageLoadSpanId:e.pageLoadSpanId,pageLoadTransactionName:e.pageLoadTransactionName,checkBrowserResponsiveness:e.checkBrowserResponsiveness},n)),n},e.startManagedTransaction=function(t,e,n){var r=this.getCurrentTransaction();return r?r.canReuse()&&n.canReuse?r.redefine(t,void 0,n):(r.end(),r=this.createTransaction(t,e,n)):r=this.createTransaction(t,e,n),r.captureTimings=!0,e===Q&&(r.options.checkBrowserResponsiveness=!1,n.pageLoadTraceId&&(r.traceId=n.pageLoadTraceId),n.pageLoadSampled&&(r.sampled=n.pageLoadSampled),r.name===U&&n.pageLoadTransactionName&&(r.name=n.pageLoadTransactionName)),r},e.startTransaction=function(t,e,n){var r,i=this,o=this.createOptions(n);return(r=o.managed?this.startManagedTransaction(t,e,o):new At(t,e,o)).onEnd=function(){return i.handleTransactionEnd(r)},this._config.events.send("transaction:start",[r]),r},e.handleTransactionEnd=function(e){var n=this;return et.Promise.resolve().then(function(){if(!n.shouldIgnoreTransaction(e.name)){if(n._config.get("breakdownMetrics")&&e.captureBreakdown(),e.type===Q){var t=n._config.get("pageLoadTransactionName");e.name===U&&t&&(e.name=t)}Pt(e),n.add(e)}},function(t){0})},e.shouldIgnoreTransaction=function(t){var e=this._config.get("ignoreTransactions");if(e&&e.length)for(var n=0;n<e.length;n++){var r=e[n];if("function"==typeof r.test){if(r.test(t))return!0}else if(r===t)return!0}return!1},e.startSpan=function(t,e,n){var r=this.ensureCurrentTransaction();if(r)return r.startSpan(t,e,n)},e.add=function(t){this._config.events.send(V,[t])},e.addTask=function(t){var e=this.ensureCurrentTransaction();if(e){t=e.addTask(t);0}return t},e.removeTask=function(t){var e=this.getCurrentTransaction();e&&e.removeTask(t)},t}(),Dt=function(i){i.registerServiceCreator("TransactionService",function(){var t=i.getService("ConfigService"),e=i.getService("LoggingService");return new Ht(e,t)}),i.registerServiceCreator("PerformanceMonitoring",function(){var t=i.getService("ConfigService"),e=i.getService("LoggingService"),n=i.getService("ApmServer"),r=i.getService("TransactionService");return new Ct(n,t,e,r)})},Bt=function(){function t(t,e){e||(e={}),this.onFlush=t,this.items=[],this.queueLimit=e.queueLimit||-1,this.flushInterval=e.flushInterval||0,this.timeoutId=void 0}var e=t.prototype;return e._setTimer=function(){var t=this;this.timeoutId=setTimeout(function(){t.flush()},this.flushInterval)},e.flush=function(){this.onFlush(this.items),this._clear()},e._clear=function(){void 0!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=void 0),this.items=[]},e.add=function(t){this.items.push(t),-1!==this.queueLimit&&this.items.length>=this.queueLimit?this.flush():void 0===this.timeoutId&&this._setTimer()},t}();var qt=function(e,n,t){var r,i=t.context||this,o=t.limit,a=t.interval,s=t.countFn||function(){},c=0;return function(){var t="function"==typeof s&&s.apply(i,arguments);return"number"!=typeof t&&(t=1),c+=t,void 0===r&&(r=setTimeout(function(){r=void(c=0)},a)),o<c?"function"==typeof n?n.apply(i,arguments):void 0:e.apply(i,arguments)}},Qt=function(){function t(){}return t.stringify=function(t){return JSON.stringify(t)+"\n"},t}();function Ut(){return(Ut=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var zt=function(){function t(t,e){this._configService=t,this._loggingService=e,this.errorQueue=void 0,this.transactionQueue=void 0,this.throttleAddError=void 0,this.throttleAddTransaction=void 0,this.initialized=!1}var e=t.prototype;return e.init=function(){this.initialized||(this.initialized=!0,this.initErrorQueue(),this.initTransactionQueue())},e.createMetaData=function(){var t=this._configService,e={service:{name:t.get("serviceName"),version:t.get("serviceVersion"),agent:{name:"js-base",version:t.version},language:{name:"javascript"},environment:t.get("environment")}};return St(ht,e)},e._postJson=function(t,e){return this._makeHttpRequest("POST",t,{payload:e,headers:{"Content-Type":"application/x-ndjson"}})},e._constructError=function(t){var e=t.url,n=t.status,r=(t.responseText,e+" HTTP status: "+n);return new Error(r)},e._makeHttpRequest=function(e,o,t){var n=void 0===t?{timeout:1e4}:t,a=n.timeout,s=n.payload,c=n.headers;return new et.Promise(function(n,r){var i=new window.XMLHttpRequest;if(i[N]=!0,i.open(e,o,!0),i.timeout=a,c)for(var t in c)c.hasOwnProperty(t)&&i.setRequestHeader(t,c[t]);i.onreadystatechange=function(){if(4===i.readyState){var t=i.status,e=i.responseText;0===t||399<t&&t<600?r({url:o,status:t,responseText:e}):n(e)}},i.onerror=function(){var t=i.status,e=i.responseText;r({url:o,status:t,responseText:e})},i.send(s)})},e._createQueue=function(t){var e=this._configService.get("queueLimit"),n=this._configService.get("flushInterval");return new Bt(t,{queueLimit:e,flushInterval:n})},e.fetchConfig=function(t,e){var n=this,r=this._configService.get("serverUrl")+"/config/v1/agents";return t?(r+="?service.name="+t,e&&(r+="&service.environment="+e),this._makeHttpRequest("GET",r,{timeout:5e3}).then(function(t){return JSON.parse(t)}).catch(function(t){var e=n._constructError(t);return et.Promise.reject(e)})):et.Promise.reject("serviceName is required for fetching central config.")},e.initErrorQueue=function(){var n=this;this.errorQueue&&this.errorQueue.flush(),this.errorQueue=this._createQueue(function(t){var e=n.sendErrors(t);e&&e.catch(function(t){n._loggingService.warn("Failed sending errors!",n._constructError(t))})});var t=this._configService.get("errorThrottleLimit"),e=this._configService.get("errorThrottleInterval");this.throttleAddError=qt(this.errorQueue.add.bind(this.errorQueue),function(){return n._loggingService.warn("Dropped error due to throttling!")},{limit:t,interval:e})},e.initTransactionQueue=function(){var n=this;this.transactionQueue&&this.transactionQueue.flush(),this.transactionQueue=this._createQueue(function(t){var e=n.sendTransactions(t);e&&e.catch(function(t){n._loggingService.warn("Failed sending transactions!",n._constructError(t))})});var t=this._configService.get("transactionThrottleLimit"),e=this._configService.get("transactionThrottleInterval");this.throttleAddTransaction=qt(this.transactionQueue.add.bind(this.transactionQueue),function(){return n._loggingService.warn("Dropped transaction due to throttling!")},{limit:t,interval:e})},e.addError=function(t){this.errorQueue||this.initErrorQueue(),this.throttleAddError(t)},e.addTransaction=function(t){this.transactionQueue||this.initTransactionQueue(),this.throttleAddTransaction(t)},e.ndjsonErrors=function(t){return t.map(function(t){return Qt.stringify({error:t})})},e.ndjsonMetricsets=function(t){var e=Date.now();return t.map(function(t){return Qt.stringify({metricset:Ut({timestamp:e},t)})}).join("")},e.ndjsonTransactions=function(t){var r=this;return t.map(function(t){var e="";t.spans&&(e=t.spans.map(function(t){return Qt.stringify({span:t})}).join(""),delete t.spans);var n="";return t.breakdown&&(n=r.ndjsonMetricsets(t.breakdown),delete t.breakdown),Qt.stringify({transaction:t})+e+n})},e._send=function(t,e){if(void 0===t&&(t=[]),void 0===e&&(e="transaction"),0!==t.length){var n={service:this.createMetaData().service,data:t},r=this._configService.applyFilters(n);if(r){var i;if("errors"===e)i=this.ndjsonErrors(r.data);else{if("transaction"!==e)return void 0;i=this.ndjsonTransactions(r.data)}i.unshift(Qt.stringify({metadata:{service:r.service}}));var o=i.join(""),a=this._configService.getEndpointUrl();return this._postJson(a,o)}this._loggingService.warn("Dropped payload due to filtering!")}},e.sendTransactions=function(t){return this._send(t)},e.sendErrors=function(t){return this._send(t,"errors")},t}();var $t=function(){function t(){this.config={},this.defaults={serviceName:"",serviceVersion:"",environment:"",serverUrl:"http://localhost:8200",serverUrlPrefix:"/intake/v2/rum/events",active:!0,instrument:!0,disableInstrumentations:[],debug:!1,logLevel:"warn",breakdownMetrics:!1,browserResponsivenessInterval:500,browserResponsivenessBuffer:3,checkBrowserResponsiveness:!0,groupSimilarSpans:!0,similarSpanThreshold:.05,ignoreTransactions:[],errorThrottleLimit:20,errorThrottleInterval:3e4,transactionThrottleLimit:20,transactionThrottleInterval:3e4,transactionDurationThreshold:6e4,queueLimit:-1,flushInterval:500,distributedTracing:!0,distributedTracingOrigins:[],distributedTracingHeaderValueCallback:c,distributedTracingHeaderName:"elastic-apm-traceparent",pageLoadTraceId:"",pageLoadSpanId:"",pageLoadSampled:!1,pageLoadTransactionName:"",transactionSampleRate:1,centralConfig:!1,context:{}},this.events=new rt,this.filters=[],this.version=""}var e=t.prototype;return e.init=function(){var t=function(t){if(!t)return{};for(var e={},n=/^data-([\w-]+)$/,r=t.attributes,i=0;i<r.length;i++){var o=r[i];if(n.test(o.nodeName)){var a=o.nodeName.match(n)[1],s=a.split("-").map(function(t,e){return 0<e?t.charAt(0).toUpperCase()+t.substring(1):t}).join("");e[s]=o.value||o.nodeValue}}return e}(_());this.setConfig(t)},e.isActive=function(){return this.get("active")},e.setVersion=function(t){this.version=t},e.addFilter=function(t){if("function"!=typeof t)throw new Error("Argument to must be function");this.filters.push(t)},e.applyFilters=function(t){for(var e=0;e<this.filters.length;e++)if(!(t=this.filters[e](t)))return;return t},e.get=function(t){return t.split(".").reduce(function(t,e){return t&&t[e]},this.config)},e.getEndpointUrl=function(){return this.config.serverUrl+this.config.serverUrlPrefix},e.set=function(t,e){for(var n=t.split("."),r=n.length-1,i=this.config