/**
 * Skipped minification because the original files appears to be already minified.
 * Original file: /npm/@embrace-io/web-sdk@2.26.0/dist/embrace-web-sdk.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";window.EmbraceWebSdk=window.EmbraceWebSdk||(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let t=`1.9.1`,n=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function r(e){let t=new Set([e]),r=new Set,i=e.match(n);if(!i)return()=>!1;let a={major:+i[1],minor:+i[2],patch:+i[3],prerelease:i[4]};if(a.prerelease!=null)return function(t){return t===e};function o(e){return r.add(e),!1}function s(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(r.has(e))return!1;let i=e.match(n);if(!i)return o(e);let c={major:+i[1],minor:+i[2],patch:+i[3],prerelease:i[4]};return c.prerelease!=null||a.major!==c.major?o(e):a.major===0?a.minor===c.minor&&a.patch<=c.patch?s(e):o(e):a.minor<=c.minor?s(e):o(e)}}let i=r(t),a=t.split(`.`)[0],o=Symbol.for(`opentelemetry.js.api.${a}`),s=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{};function c(e,n,r,i=!1){var a;let c=s[o]=(a=s[o])==null?{version:t}:a;if(!i&&c[e]){let t=Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);return r.error(t.stack||t.message),!1}if(c.version!==`1.9.1`){let n=Error(`@opentelemetry/api: Registration of version v${c.version} for ${e} does not match previously registered API v${t}`);return r.error(n.stack||n.message),!1}return c[e]=n,r.debug(`@opentelemetry/api: Registered a global for ${e} v${t}.`),!0}function l(e){var t,n;let r=(t=s[o])==null?void 0:t.version;if(!(!r||!i(r)))return(n=s[o])==null?void 0:n[e]}function u(e,n){n.debug(`@opentelemetry/api: Unregistering a global for ${e} v${t}.`);let r=s[o];r&&delete r[e]}var d=class{constructor(e){this._namespace=e.namespace||`DiagComponentLogger`}debug(...e){return f(`debug`,this._namespace,e)}error(...e){return f(`error`,this._namespace,e)}info(...e){return f(`info`,this._namespace,e)}warn(...e){return f(`warn`,this._namespace,e)}verbose(...e){return f(`verbose`,this._namespace,e)}};function f(e,t,n){let r=l(`diag`);if(r)return r[e](t,...n)}var p;(function(e){e[e.NONE=0]=`NONE`,e[e.ERROR=30]=`ERROR`,e[e.WARN=50]=`WARN`,e[e.INFO=60]=`INFO`,e[e.DEBUG=70]=`DEBUG`,e[e.VERBOSE=80]=`VERBOSE`,e[e.ALL=9999]=`ALL`})(p||(p={}));function m(e,t){e<p.NONE?e=p.NONE:e>p.ALL&&(e=p.ALL),t=t||{};function n(n,r){let i=t[n];return typeof i==`function`&&e>=r?i.bind(t):function(){}}return{error:n(`error`,p.ERROR),warn:n(`warn`,p.WARN),info:n(`info`,p.INFO),debug:n(`debug`,p.DEBUG),verbose:n(`verbose`,p.VERBOSE)}}var h=class e{static instance(){return this._instance||(this._instance=new e),this._instance}constructor(){function e(e){return function(...t){let n=l(`diag`);if(n)return n[e](...t)}}let t=this;t.setLogger=(e,n={logLevel:p.INFO})=>{var r,i,a;if(e===t){let e=Error(`Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation`);return t.error((r=e.stack)==null?e.message:r),!1}typeof n==`number`&&(n={logLevel:n});let o=l(`diag`),s=m((i=n.logLevel)==null?p.INFO:i,e);if(o&&!n.suppressOverrideMessage){let e=(a=Error().stack)==null?`<failed to generate stacktrace>`:a;o.warn(`Current logger will be overwritten from ${e}`),s.warn(`Current logger will overwrite one already registered from ${e}`)}return c(`diag`,s,t,!0)},t.disable=()=>{u(`diag`,t)},t.createComponentLogger=e=>new d(e),t.verbose=e(`verbose`),t.debug=e(`debug`),t.info=e(`info`),t.warn=e(`warn`),t.error=e(`error`)}},g=class e{constructor(e){this._entries=e?new Map(e):new Map}getEntry(e){let t=this._entries.get(e);if(t)return Object.assign({},t)}getAllEntries(){return Array.from(this._entries.entries())}setEntry(t,n){let r=new e(this._entries);return r._entries.set(t,n),r}removeEntry(t){let n=new e(this._entries);return n._entries.delete(t),n}removeEntries(...t){let n=new e(this._entries);for(let e of t)n._entries.delete(e);return n}clear(){return new e}};let ee=Symbol(`BaggageEntryMetadata`),_=h.instance();function te(e={}){return new g(new Map(Object.entries(e)))}function v(e){return typeof e!=`string`&&(_.error(`Cannot create baggage metadata from unknown type: ${typeof e}`),e=``),{__TYPE__:ee,toString(){return e}}}function y(e){return Symbol.for(e)}let b=new class e{constructor(t){let n=this;n._currentContext=t?new Map(t):new Map,n.getValue=e=>n._currentContext.get(e),n.setValue=(t,r)=>{let i=new e(n._currentContext);return i._currentContext.set(t,r),i},n.deleteValue=t=>{let r=new e(n._currentContext);return r._currentContext.delete(t),r}}},ne=[{n:`error`,c:`error`},{n:`warn`,c:`warn`},{n:`info`,c:`info`},{n:`debug`,c:`debug`},{n:`verbose`,c:`trace`}],re={};if(typeof console<`u`)for(let e of[`error`,`warn`,`info`,`debug`,`trace`,`log`])typeof console[e]==`function`&&(re[e]=console[e]);var ie=class{constructor(){function e(e){return function(...t){let n=re[e];if(typeof n!=`function`&&(n=re.log),typeof n!=`function`&&console&&(n=console[e],typeof n!=`function`&&(n=console.log)),typeof n==`function`)return n.apply(console,t)}}for(let t=0;t<ne.length;t++)this[ne[t].n]=e(ne[t].c)}},ae=class{constructor(){}createGauge(e,t){return _e}createHistogram(e,t){return ve}createCounter(e,t){return ge}createUpDownCounter(e,t){return ye}createObservableGauge(e,t){return x}createObservableCounter(e,t){return be}createObservableUpDownCounter(e,t){return xe}addBatchObservableCallback(e,t){}removeBatchObservableCallback(e){}},oe=class{},se=class extends oe{add(e,t){}},ce=class extends oe{add(e,t){}},le=class extends oe{record(e,t){}},ue=class extends oe{record(e,t){}},de=class{addCallback(e){}removeCallback(e){}},fe=class extends de{},pe=class extends de{},me=class extends de{};let he=new ae,ge=new se,_e=new le,ve=new ue,ye=new ce,be=new fe,x=new pe,xe=new me;function Se(){return he}let Ce={get(e,t){if(e!=null)return e[t]},keys(e){return e==null?[]:Object.keys(e)}},we={set(e,t,n){e!=null&&(e[t]=n)}};var Te=class{active(){return b}with(e,t,n,...r){return t.call(n,...r)}bind(e,t){return t}enable(){return this}disable(){return this}};let Ee=`context`,De=new Te;var Oe=class e{constructor(){}static getInstance(){return this._instance||(this._instance=new e),this._instance}setGlobalContextManager(e){return c(Ee,e,h.instance())}active(){return this._getContextManager().active()}with(e,t,n,...r){return this._getContextManager().with(e,t,n,...r)}bind(e,t){return this._getContextManager().bind(e,t)}_getContextManager(){return l(Ee)||De}disable(){this._getContextManager().disable(),u(Ee,h.instance())}},S;(function(e){e[e.NONE=0]=`NONE`,e[e.SAMPLED=1]=`SAMPLED`})(S||(S={}));let ke={traceId:`00000000000000000000000000000000`,spanId:`0000000000000000`,traceFlags:S.NONE};var Ae=class{constructor(e=ke){this._spanContext=e}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}addEvent(e,t){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}};let je=y(`OpenTelemetry Context Key SPAN`);function Me(e){return e.getValue(je)||void 0}function Ne(){return Me(Oe.getInstance().active())}function Pe(e,t){return e.setValue(je,t)}function Fe(e){return e.deleteValue(je)}function Ie(e,t){return Pe(e,new Ae(t))}function Le(e){var t;return(t=Me(e))==null?void 0:t.spanContext()}let Re=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function ze(e,t){if(typeof e!=`string`||e.length!==t)return!1;let n=0;for(let t=0;t<e.length;t+=4)n+=(Re[e.charCodeAt(t)]|0)+(Re[e.charCodeAt(t+1)]|0)+(Re[e.charCodeAt(t+2)]|0)+(Re[e.charCodeAt(t+3)]|0);return n===t}function Be(e){return ze(e,32)&&e!==`00000000000000000000000000000000`}function Ve(e){return ze(e,16)&&e!==`0000000000000000`}function He(e){return Be(e.traceId)&&Ve(e.spanId)}function Ue(e){return new Ae(e)}let We=Oe.getInstance();var Ge=class{startSpan(e,t,n=We.active()){if(t!=null&&t.root)return new Ae;let r=n&&Le(n);return Ke(r)&&He(r)?new Ae(r):new Ae}startActiveSpan(e,t,n,r){let i,a,o;if(arguments.length<2)return;arguments.length===2?o=t:arguments.length===3?(i=t,o=n):(i=t,a=n,o=r);let s=a==null?We.active():a,c=this.startSpan(e,i,s),l=Pe(s,c);return We.with(l,o,void 0,c)}};function Ke(e){return typeof e==`object`&&!!e&&`spanId`in e&&typeof e.spanId==`string`&&`traceId`in e&&typeof e.traceId==`string`&&`traceFlags`in e&&typeof e.traceFlags==`number`}let qe=new Ge;var Je=class{constructor(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}startSpan(e,t,n){return this._getTracer().startSpan(e,t,n)}startActiveSpan(e,t,n,r){let i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)}_getTracer(){if(this._delegate)return this._delegate;let e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):qe}};let Ye=new class{getTracer(e,t,n){return new Ge}};var Xe=class{getTracer(e,t,n){var r;return(r=this.getDelegateTracer(e,t,n))==null?new Je(this,e,t,n):r}getDelegate(){var e;return(e=this._delegate)==null?Ye:e}setDelegate(e){this._delegate=e}getDelegateTracer(e,t,n){var r;return(r=this._delegate)==null?void 0:r.getTracer(e,t,n)}},Ze;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(Ze||(Ze={}));var Qe;(function(e){e[e.INTERNAL=0]=`INTERNAL`,e[e.SERVER=1]=`SERVER`,e[e.CLIENT=2]=`CLIENT`,e[e.PRODUCER=3]=`PRODUCER`,e[e.CONSUMER=4]=`CONSUMER`})(Qe||(Qe={}));var C;(function(e){e[e.UNSET=0]=`UNSET`,e[e.OK=1]=`OK`,e[e.ERROR=2]=`ERROR`})(C||(C={}));let w=Oe.getInstance(),T=h.instance(),$e=new class{getMeter(e,t,n){return he}},et=`metrics`,tt=class e{constructor(){}static getInstance(){return this._instance||(this._instance=new e),this._instance}setGlobalMeterProvider(e){return c(et,e,h.instance())}getMeterProvider(){return l(et)||$e}getMeter(e,t,n){return this.getMeterProvider().getMeter(e,t,n)}disable(){u(et,h.instance())}}.getInstance();var nt=class{inject(e,t){}extract(e,t){return e}fields(){return[]}};let rt=y(`OpenTelemetry Baggage Key`);function it(e){return e.getValue(rt)||void 0}function at(){return it(Oe.getInstance().active())}function ot(e,t){return e.setValue(rt,t)}function st(e){return e.deleteValue(rt)}let ct=`propagation`,lt=new nt,E=class e{constructor(){this.createBaggage=te,this.getBaggage=it,this.getActiveBaggage=at,this.setBaggage=ot,this.deleteBaggage=st}static getInstance(){return this._instance||(this._instance=new e),this._instance}setGlobalPropagator(e){return c(ct,e,h.instance())}inject(e,t,n=we){return this._getGlobalPropagator().inject(e,t,n)}extract(e,t,n=Ce){return this._getGlobalPropagator().extract(e,t,n)}fields(){return this._getGlobalPropagator().fields()}disable(){u(ct,h.instance())}_getGlobalPropagator(){return l(ct)||lt}}.getInstance(),ut=`trace`,D=class e{constructor(){this._proxyTracerProvider=new Xe,this.wrapSpanContext=Ue,this.isSpanContextValid=He,this.deleteSpan=Fe,this.getSpan=Me,this.getActiveSpan=Ne,this.getSpanContext=Le,this.setSpan=Pe,this.setSpanContext=Ie}static getInstance(){return this._instance||(this._instance=new e),this._instance}setGlobalTracerProvider(e){let t=c(ut,this._proxyTracerProvider,h.instance());return t&&this._proxyTracerProvider.setDelegate(e),t}getTracerProvider(){return l(ut)||this._proxyTracerProvider}getTracer(e,t){return this.getTracerProvider().getTracer(e,t)}disable(){u(ut,h.instance()),this._proxyTracerProvider=new Xe}}.getInstance(),dt=({diag:e,value:t,defaultValue:n,min:r,max:i})=>t===void 0?n:Number.isFinite(t)?t<r||t>i?(e==null||e.warn(`value (${t.toString()}) is outside the allowed range [${r.toString()}, ${i.toString()}]; falling back to default (${n.toString()}).`),n):t:(e==null||e.warn(`value is not a finite number; falling back to default (${n.toString()}).`),n);function ft(e,t,n,r=new Set){return new Proxy(e,{get(e,i,a){let o=Reflect.get(e,i,a);return typeof o!=`function`||r.has(i)?o:(...r)=>{try{return o.apply(e,r)}catch(e){let a=e instanceof Error?e.message:`Unknown error`;n.error(`${String(i)}: ${a}`);let o=t[i];return typeof o==`function`?o.apply(t,r):void 0}}}})}let pt=new Uint8Array(16),mt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`).toUpperCase()),ht=()=>{crypto.getRandomValues(pt);let e=``;for(let t=0;t<16;t++)e+=mt[pt[t]];return e},gt=()=>`embracev2-${Date.now()}-${Math.floor(Math.random()*(9e12-1))+0xe8d4a51000}`,_t=(e,t,n)=>{let r=e.getItem(t),i=r?parseInt(r,10):0;return Number.isNaN(i)&&(n.warn(`Non-numeric value stored at ${t} (${String(r)}); resetting counter.`),i=0),i++,e.setItem(t,i.toString()),i},vt=e=>{let t=e.nodeName;return e.nodeType===1?t.toLowerCase():t.toUpperCase().replace(/^#/,``)},yt=e=>{let t=``;try{for(;(e==null?void 0:e.nodeType)!==9;){let n=e,r=n.id?`#${n.id}`:[vt(n),...Array.from(n.classList).sort()].join(`.`);if(t.length+r.length>99)return t||r;if(t=t?`${r}>${t}`:r,n.id)break;e=n.parentNode}}catch(e){}return t},O=`emb.type`,bt=`emb.state`,xt=`emb.js_file_bundle_ids`,St=`browser.url.full`,Ct=`app.surface.name`,wt=`app.surface.id`,Tt=`app.surface.label`,Et=`emb.session_part_id`,Dt=`emb.user_session_id`,Ot=`emb.user_session_previous_id`,kt=e=>e.visibilityState===`visible`?`foreground`:`background`,At=globalThis,jt=(e,t)=>!t||t<=0||t>100?!1:t>=Mt(e),Mt=e=>{if(e.length<6)return 0;let t=e.slice(-6),n=Math.pow(16,6)-1;return parseInt(t,16)/n*100},Nt=(e=document)=>{var t,n;let r=e.defaultView;if(!r)return null;let i=e.scrollingElement,a=i==null?e.documentElement:i;if(!a)return null;let o=a.scrollHeight,s=a.scrollWidth,c=(t=i==null?void 0:i.clientHeight)==null?r.innerHeight:t,l=(n=i==null?void 0:i.clientWidth)==null?r.innerWidth:n;return!o||!s||!c||!l?null:{documentHeight:o,documentWidth:s,scrollableHeight:Math.max(0,o-c),viewportHeight:c,viewportWidth:l}};function Pt(e){"@babel/helpers - typeof";return Pt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Pt(e)}function Ft(e,t){if(Pt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Pt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function It(e){var t=Ft(e,`string`);return Pt(t)==`symbol`?t:t+``}function k(e,t,n){return(t=It(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Lt=class{constructor({namespace:e,storage:t,diag:n}){k(this,`_diag`,void 0),k(this,`_keyPrefix`,void 0),k(this,`_storage`,void 0),k(this,`_writeDisabled`,!1),this._diag=n==null?T.createComponentLogger({namespace:`NamespacedStorage`}):n,this._keyPrefix=e?`${e}__`:``,this._storage=t}keys(){let e;try{e=this._storage.length}catch(e){return this._diag.warn(`failed to read storage length`,String(e)),[]}let t=[];for(let n=0;n<e;n++)try{let e=this._storage.key(n);if(e===null)continue;this._keyPrefix?e.startsWith(this._keyPrefix)&&t.push(e.substring(this._keyPrefix.length)):t.push(e)}catch(e){this._diag.warn(`failed to read storage key at index ${n.toString()}`,String(e))}return t}get length(){return this.keys().length}clear(){let e=!0;for(let t of this.keys())this._safeRemove(this._keyName(t))||(e=!1);return e}getItem(e){try{return this._storage.getItem(this._keyName(e))}catch(t){return this._diag.warn(`failed to read ${e}`,String(t)),null}}key(e){var t;return(t=this.keys()[e])==null?null:t}removeItem(e){return this._safeRemove(this._keyName(e))}setItem(e,t){if(this._writeDisabled)return!1;try{return this._storage.setItem(this._keyName(e),t),!0}catch(e){return this._disableWrites(e),!1}}_keyName(e){return`${this._keyPrefix}${e}`}_safeRemove(e){try{return this._storage.removeItem(e),!0}catch(t){return this._diag.warn(`failed to remove ${e}`,String(t)),!1}}_disableWrites(e){if(this._writeDisabled)return;this._writeDisabled=!0;let t=e instanceof Error?e.name:`UnknownError`;this._diag.error(`writes disabled after failure; continuing in-memory only`,t)}};let Rt=({diag:e,featureManager:t,registerGlobally:n,propagator:r,defaultInstrumentationConfig:i})=>{var a;if(!t.isNetworkSpanForwardingEnabled())return!1;let o=[];return n||o.push("Network span forwarding cannot be used when `registerGlobally` is set to false. Turning off network span forwarding."),r&&o.push("Network span forwarding cannot be used alongside a custom `propagator`. Turning off network span forwarding."),i!=null&&(a=i.omit)!=null&&a.has(`@opentelemetry/instrumentation-xml-http-request`)&&i.omit.has(`@opentelemetry/instrumentation-fetch`)&&o.push(`Network span forwarding cannot be used when both '@opentelemetry/instrumentation-xml-http-request' and '@opentelemetry/instrumentation-fetch' are omitted. Turning off network span forwarding.`),o.forEach(t=>{e.warn(t)}),o.length===0},zt;function Bt(e){zt=e}var Vt=class{constructor(e=window.performance){k(this,`_clock`,void 0),k(this,`navigationEntry`,null),k(this,`epochMillisFromOrigin`,e=>this._clock.timeOrigin+e),k(this,`getNowMillis`,()=>this.epochMillisFromOrigin(this._clock.now())),k(this,`getZeroTime`,()=>{var e;return Math.max(this._clock.timeOrigin+this._getNavigationActivationStart(),(e=zt)==null?0:e)}),k(this,`millisFromZeroTime`,e=>Math.max(0,e-(this.getZeroTime()-this._clock.timeOrigin))),this._clock=e}_getNavigationEntry(){var e,t,n;if(this.navigationEntry)return this.navigationEntry;let[r]=(e=(t=(n=this._clock).getEntriesByType)==null?void 0:t.call(n,`navigation`))==null?[]:e;return r?(this.navigationEntry=r,this.navigationEntry):null}_getNavigationActivationStart(){var e;let t=this._getNavigationEntry();return(e=t==null?void 0:t.activationStart)==null?0:e}};function Ht(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function Ut(e,t){if(e==null)return{};var n,r,i=Ht(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Wt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function A(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Wt(Object(n),!0).forEach(function(t){k(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}let Gt=[`diag`];function Kt(e){var t,n;return typeof PerformanceObserver<`u`&&(t=(n=PerformanceObserver.supportedEntryTypes)==null?void 0:n.includes(e))!=null&&t}function qt(e,t,n){let r=n==null?{}:n,{diag:i}=r,a=Ut(r,Gt);if(!Kt(e))return i==null||i.debug(`${e} not supported, skipping observer`),null;try{let n=new PerformanceObserver(n=>{for(let r of n.getEntries())try{t(r)}catch(t){i==null||i.error(`error processing ${e} entry`,t)}});return n.observe(A({type:e,buffered:!0},a)),n}catch(e){return null}}let Jt=`error.type`,Yt=`exception.message`,Xt=`exception.stacktrace`,Zt=`exception.type`,Qt=`http.request.method`,$t=`http.request.method_original`,en=`http.response.status_code`,tn=`server.address`,nn=`server.port`,rn=`service.name`,an=`telemetry.sdk.language`,on=`telemetry.sdk.name`,sn=`telemetry.sdk.version`,j=`url.full`,cn=`user_agent.original`,ln=`Soft Navigation`,un=`emb.soft_navigation.source`,dn=`emb.soft_navigation.interaction_id`,fn=`emb.soft_navigation.start_time`,pn=`emb.soft_navigation.duration`,mn={performanceObserver:`performance_observer`,polyfill:`polyfill`},hn=e=>{if(e.attributes[`http.request.method`]&&typeof e.attributes[`http.response.status_code`]==`number`){let t=e.attributes[j];return typeof t==`string`&&t.includes(`://`)}return!1},gn=e=>e.attributes[O]===`ux.session_part`,_n=e=>e.attributes[un]!==void 0,vn=(e,t=1e3)=>{let n=!1;return(...r)=>{n||(e(...r),setTimeout(()=>{n=!1},t),n=!0)}};var yn=class{logException(e,t){}message(e,t,n){}};let bn=new yn;var xn=class{constructor(){k(this,`_delegate`,void 0)}getDelegate(){var e;return(e=this._delegate)==null?bn:e}setDelegate(e){this._delegate=e}logException(e,t){this.getDelegate().logException(e,t)}message(e,t,n){this.getDelegate().message(e,t,n)}};let Sn=new yn,Cn=new Set([`setDelegate`,`getDelegate`]);var wn=class e{static getInstance(){if(!e._instance){let t=new xn,n=ft(t,Sn,T.createComponentLogger({namespace:`LogAPI`}),Cn);e._instance=Object.assign(n,{setGlobalLogManager(e){t.setDelegate(e)},getLogManager(){return t}})}return e._instance}static resetInstance(){e._instance=void 0}};k(wn,`_instance`,void 0);let Tn=wn.getInstance();var En=class{setCurrentRoute(e){}getCurrentRoute(){return null}getCurrentPageId(){return``}setPageLabel(e){}getPageLabel(){return null}clearCurrentRoute(){}addRouteChangedListener(e){return()=>{}}};let Dn=new En;var On=class{constructor(){k(this,`_delegate`,void 0)}getDelegate(){var e;return(e=this._delegate)==null?Dn:e}setDelegate(e){this._delegate=e}setCurrentRoute(e){this.getDelegate().setCurrentRoute(e)}getCurrentRoute(){return this.getDelegate().getCurrentRoute()}getCurrentPageId(){return this.getDelegate().getCurrentPageId()}setPageLabel(e){this.getDelegate().setPageLabel(e)}getPageLabel(){return this.getDelegate().getPageLabel()}clearCurrentRoute(){this.getDelegate().clearCurrentRoute()}addRouteChangedListener(e){return this.getDelegate().addRouteChangedListener(e)}};let kn=new En,An=new Set([`setDelegate`,`getDelegate`]);var jn=class e{static getInstance(){if(!e._instance){let t=new On,n=ft(t,kn,T.createComponentLogger({namespace:`PageAPI`}),An);e._instance=Object.assign(n,{setGlobalPageManager(e){t.setDelegate(e)},getPageManager(){return t}})}return e._instance}static resetInstance(){e._instance=void 0}};k(jn,`_instance`,void 0);let Mn=jn.getInstance();var Nn=class{constructor(){k(this,`getSessionId`,()=>null),k(this,`getPreviousSessionId`,()=>null)}addBreadcrumb(e){}addProperty(e,t,n){}removeProperty(e){}endSessionSpan(){}currentSessionAsReadableSpan(){return null}getSessionSpan(){return null}getSessionStartTime(){return null}startSessionSpan(){}addSessionStartedListener(e){return()=>{}}addSessionEndedListener(e){return()=>{}}getUserSessionId(){return null}getPreviousUserSessionId(){return null}getUserSessionStartTime(){return null}getUserSessionAttributes(){return null}getSessionPartProperties(){return{}}endUserSession(){}getSessionPartId(){return null}getSessionPartIdAt(e){return null}getSessionPartSpan(){return null}startSessionPartInternal(e){}endSessionPartInternal(e){}rolloverSessionPartInternal(e){}incrSessionPartCountForKey(e){}incrNextSessionPartCountForKey(e){}addSessionPartStartedListener(e){return()=>{}}addSessionPartEndedListener(e){return()=>{}}setTracerProvider(){}};let Pn=new Nn;var Fn=class{constructor(){k(this,`_delegate`,void 0)}getDelegate(){var e;return(e=this._delegate)==null?Pn:e}setDelegate(e){this._delegate=e}addBreadcrumb(e){this.getDelegate().addBreadcrumb(e)}addProperty(e,t,n){this.getDelegate().addProperty(e,t,n)}removeProperty(e){this.getDelegate().removeProperty(e)}endSessionSpan(){this.getDelegate().endSessionSpan()}currentSessionAsReadableSpan(e){return this.getDelegate().currentSessionAsReadableSpan(e)}getSessionId(){return this.getDelegate().getSessionId()}getPreviousSessionId(){return null}getSessionSpan(){return this.getDelegate().getSessionSpan()}getSessionStartTime(){return this.getDelegate().getSessionStartTime()}startSessionSpan(e){}addSessionStartedListener(e){return()=>{}}addSessionEndedListener(e){return()=>{}}getUserSessionId(){return this.getDelegate().getUserSessionId()}getPreviousUserSessionId(){return this.getDelegate().getPreviousUserSessionId()}getUserSessionStartTime(){return this.getDelegate().getUserSessionStartTime()}endUserSession(){this.getDelegate().endUserSession()}getUserSessionAttributes(){return this.getDelegate().getUserSessionAttributes()}getSessionPartProperties(){return this.getDelegate().getSessionPartProperties()}getSessionPartId(){return this.getDelegate().getSessionPartId()}getSessionPartIdAt(e){return this.getDelegate().getSessionPartIdAt(e)}getSessionPartSpan(){return this.getDelegate().getSessionPartSpan()}startSessionPartInternal(e){this.getDelegate().startSessionPartInternal(e)}endSessionPartInternal(e){this.getDelegate().endSessionPartInternal(e)}rolloverSessionPartInternal(e){this.getDelegate().rolloverSessionPartInternal(e)}incrSessionPartCountForKey(e){this.getDelegate().incrSessionPartCountForKey(e)}incrNextSessionPartCountForKey(e){this.getDelegate().incrNextSessionPartCountForKey(e)}addSessionPartStartedListener(e){return this.getDelegate().addSessionPartStartedListener(e)}addSessionPartEndedListener(e){return this.getDelegate().addSessionPartEndedListener(e)}setTracerProvider(e){this.getDelegate().setTracerProvider(e)}};let In=new Nn,Ln=new Set([`setDelegate`,`getDelegate`]);var Rn=class e{static getInstance(){if(!e._instance){let t=new Fn,n=ft(t,In,T.createComponentLogger({namespace:`SessionAPI`}),Ln);e._instance=Object.assign(n,{setGlobalUserSessionManager(e){t.setDelegate(e)},getUserSessionManager(){return t}})}return e._instance}static resetInstance(){e._instance=void 0}};k(Rn,`_instance`,void 0);let zn=Rn.getInstance();var Bn=class{constructor(e=ke){k(this,`_spanContext`,void 0),k(this,`attributes`,{}),this._spanContext=e}fail(e){}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}removeAttribute(e){return this}addEvent(e,t,n){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}},Vn=class{startSpan(e,t){return new Bn}setSpan(e,t){return b}getSpan(e){}};let Hn=new Vn;var Un=class{constructor(){k(this,`_delegate`,void 0)}getDelegate(){var e;return(e=this._delegate)==null?Hn:e}setDelegate(e){this._delegate=e}startSpan(e,t,n){return this.getDelegate().startSpan(e,t,n)}setSpan(e,t){return this.getDelegate().setSpan(e,t)}getSpan(e){return this.getDelegate().getSpan(e)}};let Wn=new Vn,Gn=new Set([`setDelegate`,`getDelegate`]);var Kn=class e{static getInstance(){if(!e._instance){let t=new Un,n=ft(t,Wn,T.createComponentLogger({namespace:`TraceAPI`}),Gn);e._instance=Object.assign(n,{setGlobalTraceManager(e){t.setDelegate(e)},getTraceManager(){return t}})}return e._instance}static resetInstance(){e._instance=void 0}};k(Kn,`_instance`,void 0);let qn=Kn.getInstance();var Jn=class{getEmbraceUserId(){return``}getUserId(){return null}setUserId(){}clearUserId(){}};let Yn=new Jn;var Xn=class{constructor(){k(this,`_delegate`,void 0)}getDelegate(){var e;return(e=this._delegate)==null?Yn:e}setDelegate(e){this._delegate=e}getEmbraceUserId(){return this.getDelegate().getEmbraceUserId()}getUserId(){return this.getDelegate().getUserId()}setUserId(e){this.getDelegate().setUserId(e)}clearUserId(){this.getDelegate().clearUserId()}};let Zn=new Jn,Qn=new Set([`setDelegate`,`getDelegate`]);var $n=class e{static getInstance(){if(!e._instance){let t=new Xn,n=ft(t,Zn,T.createComponentLogger({namespace:`UserAPI`}),Qn);e._instance=Object.assign(n,{setGlobalUserManager(e){t.setDelegate(e)},getUserManager(){return t}})}return e._instance}static resetInstance(){e._instance=void 0}};k($n,`_instance`,void 0);let er=$n.getInstance(),tr={pageLabel:Tt};var M;(function(e){e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TRACE=1]=`TRACE`,e[e.TRACE2=2]=`TRACE2`,e[e.TRACE3=3]=`TRACE3`,e[e.TRACE4=4]=`TRACE4`,e[e.DEBUG=5]=`DEBUG`,e[e.DEBUG2=6]=`DEBUG2`,e[e.DEBUG3=7]=`DEBUG3`,e[e.DEBUG4=8]=`DEBUG4`,e[e.INFO=9]=`INFO`,e[e.INFO2=10]=`INFO2`,e[e.INFO3=11]=`INFO3`,e[e.INFO4=12]=`INFO4`,e[e.WARN=13]=`WARN`,e[e.WARN2=14]=`WARN2`,e[e.WARN3=15]=`WARN3`,e[e.WARN4=16]=`WARN4`,e[e.ERROR=17]=`ERROR`,e[e.ERROR2=18]=`ERROR2`,e[e.ERROR3=19]=`ERROR3`,e[e.ERROR4=20]=`ERROR4`,e[e.FATAL=21]=`FATAL`,e[e.FATAL2=22]=`FATAL2`,e[e.FATAL3=23]=`FATAL3`,e[e.FATAL4=24]=`FATAL4`})(M||(M={}));var nr=class{emit(e){}enabled(){return!1}};let rr=new nr;function ir(){return rr}let ar=Symbol.for(`io.opentelemetry.js.api.logs`),or=globalThis;function sr(e,t,n){return r=>r===e?t:n}let cr=new class{getLogger(e,t,n){return new nr}};var lr=class{constructor(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):rr}},ur=class{getLogger(e,t,n){var r;return(r=this._getDelegateLogger(e,t,n))==null?new lr(this,e,t,n):r}_getDelegate(){var e;return(e=this._delegate)==null?cr:e}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,t,n){var r;return(r=this._delegate)==null?void 0:r.getLogger(e,t,n)}};let dr=class e{constructor(){this._proxyLoggerProvider=new ur}static getInstance(){return this._instance||(this._instance=new e),this._instance}setGlobalLoggerProvider(e){return or[ar]?this.getLoggerProvider():(or[ar]=sr(1,e,cr),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,t;return(t=(e=or[ar])==null?void 0:e.call(or,1))==null?this._proxyLoggerProvider:t}getLogger(e,t,n){return this.getLoggerProvider().getLogger(e,t,n)}disable(){delete or[ar],this._proxyLoggerProvider=new ur}}.getInstance();function fr(e,t,n,r){for(let i=0,a=e.length;i<a;i++){let a=e[i];t&&a.setTracerProvider(t),n&&a.setMeterProvider(n),r&&a.setLoggerProvider&&a.setLoggerProvider(r),a.getConfig().enabled||a.enable()}}function pr(e){e.forEach(e=>e.disable())}function mr(e){var t,n;let r=e.tracerProvider||D.getTracerProvider(),i=e.meterProvider||tt.getMeterProvider(),a=e.loggerProvider||dr.getLoggerProvider(),o=(t=(n=e.instrumentations)==null?void 0:n.flat())==null?[]:t;return fr(o,r,i,a),()=>{pr(o)}}let N=console.error.bind(console);function hr(e,t,n){let r=!!e[t]&&Object.prototype.propertyIsEnumerable.call(e,t);Object.defineProperty(e,t,{configurable:!0,enumerable:r,writable:!0,value:n})}let gr=(e,t,n)=>{if(!e||!e[t]){N(`no original function `+String(t)+` to wrap`);return}if(!n){N(`no wrapper function`),N(Error().stack);return}let r=e[t];if(typeof r!=`function`||typeof n!=`function`){N(`original object and wrapper must be functions`);return}let i=n(r,t);return hr(i,`__original`,r),hr(i,`__unwrap`,()=>{e[t]===i&&hr(e,t,r)}),hr(i,`__wrapped`,!0),hr(e,t,i),i},_r=(e,t,n)=>{if(e)Array.isArray(e)||(e=[e]);else{N(`must provide one or more modules to patch`),N(Error().stack);return}if(!(t&&Array.isArray(t))){N(`must provide one or more functions to wrap on modules`);return}e.forEach(e=>{t.forEach(t=>{gr(e,t,n)})})},vr=(e,t)=>{if(!e||!e[t]){N(`no function to unwrap.`),N(Error().stack);return}let n=e[t];if(!n.__unwrap)N(`no original to unwrap to -- has `+String(t)+` already been unwrapped?`);else{n.__unwrap();return}},yr=(e,t)=>{if(e)Array.isArray(e)||(e=[e]);else{N(`must provide one or more modules to patch`),N(Error().stack);return}if(!(t&&Array.isArray(t))){N(`must provide one or more functions to unwrap on modules`);return}e.forEach(e=>{t.forEach(t=>{vr(e,t)})})};var br=class{constructor(e,t,n){k(this,`_config`,{}),k(this,`_tracer`,void 0),k(this,`_meter`,void 0),k(this,`_logger`,void 0),k(this,`_diag`,void 0),k(this,`instrumentationName`,void 0),k(this,`instrumentationVersion`,void 0),k(this,`_wrap`,gr),k(this,`_unwrap`,vr),k(this,`_massWrap`,_r),k(this,`_massUnwrap`,yr),this.instrumentationName=e,this.instrumentationVersion=t,this.setConfig(n),this._diag=T.createComponentLogger({namespace:e}),this._tracer=D.getTracer(e,t),this._meter=tt.getMeter(e,t),this._logger=dr.getLogger(e,t),this._updateMetricInstruments()}get meter(){return this._meter}setMeterProvider(e){this._meter=e.getMeter(this.instrumentationName,this.instrumentationVersion),this._updateMetricInstruments()}get logger(){return this._logger}setLoggerProvider(e){this._logger=e.getLogger(this.instrumentationName,this.instrumentationVersion)}getModuleDefinitions(){var e;let t=(e=this.init())==null?[]:e;return Array.isArray(t)?t:[t]}_updateMetricInstruments(){}getConfig(){return this._config}setConfig(e){this._config=A({enabled:!0},e)}setTracerProvider(e){this._tracer=e.getTracer(this.instrumentationName,this.instrumentationVersion)}get tracer(){return this._tracer}_runSpanCustomizationHook(e,t,n,r){if(e)try{e(n,r)}catch(e){this._diag.error(`Error running span customization hook due to exception in handler`,{triggerName:t},e)}}},xr=class extends br{constructor(e,t,n){super(e,t,n),this._config.enabled&&this.enable()}};function Sr(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function P(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){Sr(a,r,i,o,s,`next`,e)}function s(e){Sr(a,r,i,o,s,`throw`,e)}o(void 0)})}}function Cr(e,t,n){let r,i;try{i=e()}catch(e){r=e}finally{if(t(r,i),r&&!n)throw r;return i}}let wr=y(`OpenTelemetry SDK Context Key SUPPRESS_TRACING`);function Tr(e){return e.setValue(wr,!0)}function Er(e){return e.getValue(wr)===!0}let Dr=`baggage`;function Or(e){return e.reduce((e,t)=>{let n=`${e}${e===``?``:`,`}${t}`;return n.length>8192?e:n},``)}function kr(e){return e.getAllEntries().map(([e,t])=>{let n=`${encodeURIComponent(e)}=${encodeURIComponent(t.value)}`;return t.metadata!==void 0&&(n+=`;`+t.metadata.toString()),n})}function Ar(e){if(!e)return;let t=e.indexOf(`;`),n=t===-1?e:e.substring(0,t),r=n.indexOf(`=`);if(r<=0)return;let i=n.substring(0,r).trim(),a=n.substring(r+1).trim();if(!i||!a)return;let o,s;try{o=decodeURIComponent(i),s=decodeURIComponent(a)}catch(e){return}let c;return t!==-1&&t<e.length-1&&(c=v(e.substring(t+1))),{key:o,value:s,metadata:c}}function jr(e,t,n,r){let i=0;for(;i<e.length&&n<180;){let a=e.indexOf(`,`,i),o=a===-1?e.length:a,s=o-i;if(s<=4096){let a=Ar(e.substring(i,o));if(a){let e=(n===0?0:1)+s;if(r+e>8192)break;t[a.key]=a.metadata?{value:a.value,metadata:a.metadata}:{value:a.value},n++,r+=e}}if(a===-1)break;i=a+1}return[n,r]}var Mr=class{inject(e,t,n){let r=E.getBaggage(e);if(!r||Er(e))return;let i=Or(kr(r).filter(e=>e.length<=4096).slice(0,180));i.length>0&&n.set(t,Dr,i)}extract(e,t,n){let r=n.get(t,Dr);if(!r)return e;let i={},a=0,o=0;if(Array.isArray(r))for(let e=0;e<r.length;e++)[a,o]=jr(r[e],i,a,o);else[a]=jr(r,i,a,o);return a===0?e:E.setBaggage(e,E.createBaggage(i))}fields(){return[Dr]}};function Nr(e){let t={};if(typeof e!=`object`||!e)return t;for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(!Pr(n)){T.warn(`Invalid attribute key: ${n}`);continue}let r=e[n];if(!Fr(r)){T.warn(`Invalid attribute value set for key: ${n}`);continue}t[n]=Array.isArray(r)?r.slice():r}return t}function Pr(e){return typeof e==`string`&&e!==``}function Fr(e){return e==null?!0:Array.isArray(e)?Ir(e):Lr(typeof e)}function Ir(e){let t;for(let n of e){if(n==null)continue;let e=typeof n;if(e!==t){if(!t){if(Lr(e)){t=e;continue}return!1}return!1}}return!0}function Lr(e){switch(e){case`number`:case`boolean`:case`string`:return!0}return!1}function Rr(){return e=>{T.error(zr(e))}}function zr(e){return typeof e==`string`?e:JSON.stringify(Br(e))}function Br(e){let t={},n=e;for(;n!==null;)Object.getOwnPropertyNames(n).forEach(e=>{if(t[e])return;let r=n[e];r&&(t[e]=String(r))}),n=Object.getPrototypeOf(n);return t}let Vr=Rr();function F(e){try{Vr(e)}catch(e){}}let Hr={[on]:`opentelemetry`,"process.runtime.name":`browser`,[an]:`webjs`,[sn]:`2.10.0`},I=performance,Ur=Math.pow(10,6),Wr=Math.pow(10,9);function L(e){let t=e/1e3;return[Math.trunc(t),Math.round(e%1e3*Ur)]}function R(e){return Xr(L(I.timeOrigin),L(typeof e==`number`?e:I.now()))}function Gr(e){if(Jr(e))return e;if(typeof e==`number`)return e<I.timeOrigin/2?R(e):L(e);if(e instanceof Date)return L(e.getTime());throw TypeError(`Invalid input type`)}function Kr(e,t){let n=t[0]-e[0],r=t[1]-e[1];return r<0&&(--n,r+=Wr),[n,r]}function z(e){return e[0]*Wr+e[1]}function qr(e){return e[0]*1e3+e[1]/1e6}function Jr(e){return Array.isArray(e)&&e.length===2&&typeof e[0]==`number`&&typeof e[1]==`number`}function Yr(e){return Jr(e)||typeof e==`number`||e instanceof Date}function Xr(e,t){let n=[e[0]+t[0],e[1]+t[1]];return n[1]>=Wr&&(n[1]-=Wr,n[0]+=1),n}var B;(function(e){e[e.SUCCESS=0]=`SUCCESS`,e[e.FAILED=1]=`FAILED`})(B||(B={}));var Zr=class{constructor(e={}){var t;k(this,`_propagators`,void 0),k(this,`_fields`,void 0),this._propagators=(t=e.propagators)==null?[]:t;let n=new Set;for(let e of this._propagators){let t=typeof e.fields==`function`?e.fields():[];for(let e of t)n.add(e)}this._fields=Array.from(n)}inject(e,t,n){for(let r of this._propagators)try{r.inject(e,t,n)}catch(e){T.warn(`Failed to inject with ${r.constructor.name}. Err: ${e.message}`)}}extract(e,t,n){return this._propagators.reduce((e,r)=>{try{return r.extract(e,t,n)}catch(e){T.warn(`Failed to extract with ${r.constructor.name}. Err: ${e.message}`)}return e},e)}fields(){return this._fields.slice()}};let Qr=`[_0-9a-z-*/]`,$r=RegExp(`^(?:${`[a-z]${Qr}{0,255}`}|${`[a-z0-9]${Qr}{0,240}@[a-z]${Qr}{0,13}`})$`),ei=/^[ -~]{0,255}[!-~]$/,ti=/,|=/;function ni(e){return $r.test(e)}function ri(e){return ei.test(e)&&!ti.test(e)}var ii=class e{constructor(e){k(this,`_length`,void 0),k(this,`_rawTraceState`,void 0),k(this,`_internalState`,void 0),this._rawTraceState=typeof e==`string`?e:``,this._length=this._rawTraceState.length}set(e,t){if(!ni(e)||!ri(t))return this;let n=this._getState(),r=n.get(e),i=this._length;if(i+=typeof r==`string`?t.length-r.length:e.length+t.length+(n.size>0?2:1),i>512)return this;let a=new Map(n);return a.delete(e),a.set(e,t),this._fromState(a,i)}unset(e){let t=this._getState(),n=t.get(e);if(typeof n!=`string`)return this;let r=this._length-(e.length+n.length+1);t.size>1&&--r;let i=new Map(t);return i.delete(e),this._fromState(i,r)}get(e){return this._getState().get(e)}serialize(){let e=``,t=0;for(let n of this._getState())t>0&&(e=`,`+e),e=`${n[0]}=${n[1]}`+e,t++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(`,`),t=new Map,n=0;for(let r of e){let e=r.trim(),i=e.indexOf(`=`);if(i===-1)continue;let a=e.slice(0,i),o=e.slice(i+1);if(!ni(a)||!ri(o))continue;let s=n+e.length+ +(t.size>0);if(!(s>512)&&(t.set(a,o),n=s,t.size>=32))break}return this._length=n,this._internalState=new Map(Array.from(t.entries()).reverse()),this._internalState}_fromState(t,n){let r=Object.create(e.prototype);return r._internalState=t,r._length=n,r}};let ai=`traceparent`,oi=`tracestate`,si=RegExp(`^\\s?((?!ff)[\\da-f]{2})-((?![0]{32})[\\da-f]{32})-((?![0]{16})[\\da-f]{16})-([\\da-f]{2})(-.*)?\\s?$`);function ci(e){let t=si.exec(e);return!t||t[1]===`00`&&t[5]?null:{traceId:t[2],spanId:t[3],traceFlags:parseInt(t[4],16)}}var li=class{inject(e,t,n){let r=D.getSpanContext(e);if(!r||Er(e)||!He(r))return;let i=`00-${r.traceId}-${r.spanId}-0${Number(r.traceFlags||S.NONE).toString(16)}`;n.set(t,ai,i),r.traceState&&n.set(t,oi,r.traceState.serialize())}extract(e,t,n){let r=n.get(t,ai);if(!r)return e;let i=Array.isArray(r)?r[0]:r;if(typeof i!=`string`)return e;let a=ci(i);if(!a)return e;a.isRemote=!0;let o=n.get(t,oi);if(o){let e=Array.isArray(o)?o.join(`,`):o;a.traceState=new ii(typeof e==`string`?e:void 0)}return D.setSpanContext(e,a)}fields(){return[ai,oi]}};let ui=Function.prototype.toString,di=ui.call(Object),fi=Object.getPrototypeOf,pi=Object.prototype,mi=pi.hasOwnProperty,hi=Symbol?Symbol.toStringTag:void 0,gi=pi.toString;function _i(e){if(!vi(e)||yi(e)!==`[object Object]`)return!1;let t=fi(e);if(t===null)return!0;let n=mi.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&ui.call(n)===di}function vi(e){return typeof e==`object`&&!!e}function yi(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:hi&&hi in Object(e)?bi(e):xi(e)}function bi(e){let t=mi.call(e,hi),n=e[hi],r=!1;try{e[hi]=void 0,r=!0}catch(e){}let i=gi.call(e);return r&&(t?e[hi]=n:delete e[hi]),i}function xi(e){return gi.call(e)}function Si(...e){let t=e.shift(),n=new WeakMap;for(;e.length>0;)t=wi(t,e.shift(),0,n);return t}function Ci(e){return Ei(e)?e.slice():e}function wi(e,t,n=0,r){let i;if(!(n>20)){if(n++,ki(e)||ki(t)||Di(t))i=Ci(t);else if(Ei(e)){if(i=e.slice(),Ei(t))for(let e=0,n=t.length;e<n;e++)i.push(Ci(t[e]));else if(Oi(t)){let e=Object.keys(t);for(let n=0,r=e.length;n<r;n++){let r=e[n];r!==`__proto__`&&r!==`constructor`&&r!==`prototype`&&(i[r]=Ci(t[r]))}}}else if(Oi(e)){if(Oi(t)){if(!Ai(e,t))return t;i=Object.assign({},e);let a=Object.keys(t);for(let o=0,s=a.length;o<s;o++){let s=a[o];if(s===`__proto__`||s===`constructor`||s===`prototype`)continue;let c=t[s];if(ki(c))c===void 0?delete i[s]:i[s]=c;else{let a=i[s],o=c;if(Ti(e,s,r)||Ti(t,s,r))delete i[s];else{if(Oi(a)&&Oi(o)){let n=r.get(a)||[],i=r.get(o)||[];n.push({obj:e,key:s}),i.push({obj:t,key:s}),r.set(a,n),r.set(o,i)}i[s]=wi(i[s],c,n,r)}}}}else i=t}return i}}function Ti(e,t,n){let r=n.get(e[t])||[];for(let n=0,i=r.length;n<i;n++){let i=r[n];if(i.key===t&&i.obj===e)return!0}return!1}function Ei(e){return Array.isArray(e)}function Di(e){return typeof e==`function`}function Oi(e){return!ki(e)&&!Ei(e)&&!Di(e)&&typeof e==`object`}function ki(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e===void 0||e instanceof Date||e instanceof RegExp||e===null}function Ai(e,t){return!(!_i(e)||!_i(t))}var ji=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function Mi(e,t){let n,r=new Promise(function(e,r){n=setTimeout(function(){r(new ji(`Operation timed out.`))},t)});return Promise.race([e,r]).then(e=>(clearTimeout(n),e),e=>{throw clearTimeout(n),e})}function Ni(e,t){return typeof t==`string`?e===t:!!e.match(t)}function Pi(e,t){if(!t)return!1;for(let n of t)if(Ni(e,n))return!0;return!1}var Fi=class{constructor(){k(this,`_promise`,void 0),k(this,`_resolve`,void 0),k(this,`_reject`,void 0),this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}},Ii=class{constructor(e,t){k(this,`_isCalled`,!1),k(this,`_deferred`,new Fi),k(this,`_callback`,void 0),k(this,`_that`,void 0),this._callback=e,this._that=t}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(e=>this._deferred.resolve(e),e=>this._deferred.reject(e))}catch(e){this._deferred.reject(e)}}return this._deferred.promise}};function Li(e,t){return new Promise(n=>{w.with(Tr(w.active()),()=>{e.export(t,n)})})}let Ri={_export:Li},zi;function Bi(){if(zi===void 0)try{let e=globalThis.process.argv0;zi=e?`unknown_service:${e}`:`unknown_service`}catch(e){zi=`unknown_service`}return zi}let Vi=e=>typeof e==`object`&&!!e&&typeof e.then==`function`;var Hi=class e{static FromAttributeList(t,n){let r=new e({},n);return r._rawAttributes=Ki(t),r._asyncAttributesPending=t.filter(([e,t])=>Vi(t)).length>0,r}constructor(e,t){var n;k(this,`_rawAttributes`,void 0),k(this,`_asyncAttributesPending`,!1),k(this,`_schemaUrl`,void 0),k(this,`_memoizedAttributes`,void 0);let r=(n=e.attributes)==null?{}:n;this._rawAttributes=Object.entries(r).map(([e,t])=>(Vi(t)&&(this._asyncAttributesPending=!0),[e,t])),this._rawAttributes=Ki(this._rawAttributes),this._schemaUrl=qi(t==null?void 0:t.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}waitForAsyncAttributes(){var e=this;return P(function*(){if(e.asyncAttributesPending){for(let t=0;t<e._rawAttributes.length;t++){let[n,r]=e._rawAttributes[t];e._rawAttributes[t]=[n,Vi(r)?yield r:r]}e._asyncAttributesPending=!1}})()}get attributes(){if(this.asyncAttributesPending&&T.error(`Accessing resource attributes before async attributes settled`),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[t,n]of this._rawAttributes){if(Vi(n)){T.debug(`Unsettled resource attribute ${t} skipped`);continue}n!=null&&(e[t]!=null||(e[t]=n))}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(t){if(t==null)return this;let n=Ji(this,t),r=n?{schemaUrl:n}:void 0;return e.FromAttributeList([...t.getRawAttributes(),...this.getRawAttributes()],r)}};function Ui(e,t){return Hi.FromAttributeList(Object.entries(e),t)}function Wi(){return Ui({})}function Gi(){return Ui({[rn]:Bi(),[an]:Hr[an],[on]:Hr[on],[sn]:Hr[sn]})}function Ki(e){return e.map(([e,t])=>Vi(t)?[e,t.catch(t=>{T.debug(`promise rejection for resource attribute: %s - %s`,e,t)})]:[e,t])}function qi(e){if(typeof e==`string`||e===void 0)return e;T.warn(`Schema URL must be string or undefined, got %s. Schema URL will be ignored.`,e)}function Ji(e,t){let n=e==null?void 0:e.schemaUrl,r=t==null?void 0:t.schemaUrl,i=n===void 0||n===``,a=r===void 0||r===``;if(i)return r;if(a||n===r)return n;T.warn(`Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.`,n,r)}function Yi(e){return Xi(e,new WeakSet)}function Xi(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e instanceof Uint8Array)return!0;if(typeof e==`object`){if(t.has(e))return!1;if(t.add(e),Array.isArray(e)){for(let n of e)if(!Xi(n,t))return!1;return!0}let n=e;if(n.constructor!==Object&&n.constructor!==void 0)return!1;for(let e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&!Xi(n[e],t))return!1;return!0}return!1}var V;(function(e){e[e.DROP_INVALID=0]=`DROP_INVALID`,e[e.DROP_LIMIT_REACHED=1]=`DROP_LIMIT_REACHED`,e[e.ADD_NEW=2]=`ADD_NEW`,e[e.ADD_OVERWRITE_EXISTING=3]=`ADD_OVERWRITE_EXISTING`})(V||(V={}));function Zi(e,t,n,r,i){if(r.length===0)return T.warn(`Invalid attribute key: ${r}`),V.DROP_INVALID;if(!Yi(i))return T.warn(`Invalid attribute value set for key: ${r}`),V.DROP_INVALID;let a=!Object.prototype.hasOwnProperty.call(e,r);return a&&n>=t.attributeCountLimit?V.DROP_LIMIT_REACHED:(e[r]=Qi(i,t.attributeValueLengthLimit),a?V.ADD_NEW:V.ADD_OVERWRITE_EXISTING)}function Qi(e,t){if(t<=0)return T.warn(`Attribute value limit must be positive, got ${t}`),e;if(e==null)return e;if(typeof e==`string`)return e.length<=t?e:e.substring(0,t);if(e instanceof Uint8Array)return e;if(Array.isArray(e))return e.map(e=>Qi(e,t));if(typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=Qi(i,t);return n}return e}function $i(e,t){if(t==null)return{};let n={},r=0,i=0;for(let[a,o]of Object.entries(t)){let t=Zi(n,e,r,a,o);t===V.ADD_NEW?r+=1:(t===V.DROP_INVALID||t===V.DROP_LIMIT_REACHED)&&(i+=1)}return{attributes:r>0?n:void 0,droppedAttributesCount:i}}var ea=class{get hrTime(){return this._hrTime}set hrTime(e){this._isLogRecordReadonly()||(this._hrTime=e)}get hrTimeObserved(){return this._hrTimeObserved}set hrTimeObserved(e){this._isLogRecordReadonly()||(this._hrTimeObserved=e)}get spanContext(){return this._spanContext}set spanContext(e){this._isLogRecordReadonly()||(this._spanContext=e)}set severityText(e){this._isLogRecordReadonly()||(this._severityText=e)}get severityText(){return this._severityText}set severityNumber(e){this._isLogRecordReadonly()||(this._severityNumber=e)}get severityNumber(){return this._severityNumber}set body(e){this._isLogRecordReadonly()||(this._body=e)}get body(){return this._body}get eventName(){return this._eventName}set eventName(e){this._isLogRecordReadonly()||(this._eventName=e)}get droppedAttributesCount(){return this._droppedAttributesCount}constructor(e,t,n){k(this,`resource`,void 0),k(this,`instrumentationScope`,void 0),k(this,`attributes`,{}),k(this,`_hrTime`,void 0),k(this,`_hrTimeObserved`,void 0),k(this,`_spanContext`,void 0),k(this,`_severityText`,void 0),k(this,`_severityNumber`,void 0),k(this,`_body`,void 0),k(this,`_eventName`,void 0),k(this,`_attributesCount`,0),k(this,`_droppedAttributesCount`,0),k(this,`_isReadonly`,!1),k(this,`_logRecordLimits`,void 0);let{timestamp:r,observedTimestamp:i,eventName:a,severityNumber:o,severityText:s,body:c,attributes:l={},exception:u,context:d}=n,f=Date.now();if(this._hrTime=Gr(r==null?f:r),this._hrTimeObserved=Gr(i==null?f:i),d){let e=D.getSpanContext(d);e&&He(e)&&(this._spanContext=e)}this.severityNumber=o,this.severityText=s,this.body=c,this.resource=e.resource,this.instrumentationScope=t,this._logRecordLimits=e.logRecordLimits,this._eventName=a,this.setAttributes(l),u!=null&&this._setException(u)}setAttribute(e,t){if(this._isLogRecordReadonly())return this;let n=Zi(this.attributes,this._logRecordLimits,this._attributesCount,e,t);return n===V.DROP_LIMIT_REACHED?(this._droppedAttributesCount++,this._droppedAttributesCount===1&&T.warn(`Dropping extra attributes.`)):n===V.ADD_NEW&&this._attributesCount++,this}setAttributes(e){for(let[t,n]of Object.entries(e))this.setAttribute(t,n);return this}setBody(e){return this.body=e,this}setEventName(e){return this.eventName=e,this}setSeverityNumber(e){return this.severityNumber=e,this}setSeverityText(e){return this.severityText=e,this}_makeReadonly(){this._isReadonly=!0}_setException(e){let t=!1;if(typeof e==`string`||typeof e==`number`)Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(Yt,String(e)),t=!0;else if(e&&typeof e==`object`){let n=e;n.code?(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(Zt,n.code.toString()),t=!0):n.name&&(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(Zt,n.name),t=!0),n.message&&(Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(Yt,n.message),t=!0),n.stack&&(Object.hasOwn(this.attributes,`exception.stacktrace`)||this.setAttribute(Xt,n.stack),t=!0)}t||T.warn(`Failed to record an exception ${e}`)}_isLogRecordReadonly(){return this._isReadonly&&T.warn(`Can not execute the operation on emitted log record`),this._isReadonly}},ta=class{constructor(e,t){k(this,`_instrumentationScope`,void 0),k(this,`_sharedState`,void 0),k(this,`_loggerConfig`,void 0),this._instrumentationScope=e,this._sharedState=t,this._loggerConfig=this._sharedState.getLoggerConfig(this._instrumentationScope)}emit(e){let t=e.context||w.active();if(!this.enabled(e))return;let n=new ea(this._sharedState,this._instrumentationScope,A({context:t},e));this._sharedState.loggerMetrics.emitLog(),this._sharedState.activeProcessor.onEmit(n,t),n._makeReadonly()}enabled(e){if(this._sharedState.hasShutdown)return!1;let t=this._loggerConfig;if(t.disabled)return!1;let n=e==null?void 0:e.severityNumber;if(typeof n==`number`&&n!==M.UNSPECIFIED&&n<t.minimumSeverity)return!1;let r=(e==null?void 0:e.context)||w.active();if(t.traceBased){let e=D.getSpanContext(r);if(e&&He(e)&&(e.traceFlags&S.SAMPLED)!==S.SAMPLED)return!1}let i={context:r,instrumentationScope:this._instrumentationScope,severityNumber:e==null?void 0:e.severityNumber,eventName:e==null?void 0:e.eventName};for(let e of this._sharedState.processors)if(!e.enabled||e.enabled(i))return!0;return!1}},na=class{forceFlush(){return Promise.resolve()}onEmit(e,t){}shutdown(){return Promise.resolve()}enabled(e){return!1}},ra=class{constructor(e){k(this,`processors`,void 0),this.processors=e}forceFlush(e){var t=this;return P(function*(){var n;let r=(n=e==null?void 0:e.timeoutMillis)==null?3e4:n;yield Promise.all(t.processors.map(e=>Mi(e.forceFlush(),r)))})()}onEmit(e,t){this.processors.forEach(n=>n.onEmit(e,t))}shutdown(){var e=this;return P(function*(){yield Promise.all(e.processors.map(e=>e.shutdown()))})()}enabled(e){for(let t of this.processors)if(!t.enabled||t.enabled(e))return!0;return!1}};function ia(e){if(e===void 0)return[`u`,null];if(e===null)return[`n`,null];let t=typeof e;return t===`string`?[`s`,e]:t===`boolean`?[`b`,e]:t===`number`?Number.isNaN(e)?[`nan`,null]:e===1/0?[`inf`,null]:e===-1/0?[`-inf`,null]:Object.is(e,-0)?[`n0`,null]:[`d`,e]:e instanceof Uint8Array?[`bytes`,Array.from(e)]:Array.isArray(e)?[`arr`,e.map(ia)]:[`map`,Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,ia(t)])]}function aa(e){var t;return JSON.stringify([e.name,e.version||``,e.schemaUrl||``,ia(e.attributes),(t=e.droppedAttributesCount)==null?0:t])}let oa=`error.type`;var sa=class{constructor(e){k(this,`createdLogs`,void 0),this.createdLogs=e.createCounter(`otel.sdk.log.created`,{unit:`{log_record}`,description:`The number of logs submitted to enabled SDK Loggers.`})}emitLog(){this.createdLogs.add(1)}};let ca={disabled:!1,minimumSeverity:M.UNSPECIFIED,traceBased:!1},la=()=>A({},ca);var ua=class{constructor(e,t,n,r,i){k(this,`loggers`,new Map),k(this,`activeProcessor`,void 0),k(this,`registeredLogRecordProcessors`,[]),k(this,`resource`,void 0),k(this,`logRecordLimits`,void 0),k(this,`processors`,void 0),k(this,`loggerMetrics`,void 0),k(this,`hasShutdown`,!1),k(this,`_loggerConfigurator`,void 0),k(this,`_loggerConfigs`,new Map),this.resource=e,this.logRecordLimits=t,this.processors=n,n.length>0?(this.registeredLogRecordProcessors=n,this.activeProcessor=new ra(this.registeredLogRecordProcessors)):this.activeProcessor=new na,this._loggerConfigurator=r==null?la:r;let a=i?i.getMeter(`@opentelemetry/sdk-logs`,`0.221.0`):Se();this.loggerMetrics=new sa(a)}getLoggerConfig(e){let t=aa(e),n=this._loggerConfigs.get(t);return n||(n=this._loggerConfigurator(e),this._loggerConfigs.set(t,n),n)}},da=class{constructor(e={}){var t,n,r,i,a,o,s;k(this,`_shutdownOnce`,void 0),k(this,`_sharedState`,void 0);let c={resource:(t=e.resource)==null?Gi():t,logRecordLimits:{attributeCountLimit:(n=(r=e.logRecordLimits)==null?void 0:r.attributeCountLimit)==null?128:n,attributeValueLengthLimit:(i=(a=e.logRecordLimits)==null?void 0:a.attributeValueLengthLimit)==null?1/0:i},loggerConfigurator:(o=e.loggerConfigurator)==null?la:o,processors:(s=e.processors)==null?[]:s,meterProvider:e.meterProvider};this._sharedState=new ua(c.resource,c.logRecordLimits,c.processors,c.loggerConfigurator,c.meterProvider),this._shutdownOnce=new Ii(this._shutdown,this)}getLogger(e,t,n){if(this._shutdownOnce.isCalled)return T.warn(`A shutdown LoggerProvider cannot provide a Logger`),ir();e||T.warn(`Logger requested without instrumentation scope name.`);let r=A({name:e||`unknown`,version:t,schemaUrl:n==null?void 0:n.schemaUrl},$i(this._sharedState.logRecordLimits,n==null?void 0:n.attributes)),i=aa(r);return this._sharedState.loggers.has(i)||this._sharedState.loggers.set(i,new ta(r,this._sharedState)),this._sharedState.loggers.get(i)}forceFlush(e){return this._shutdownOnce.isCalled?(T.warn(`invalid attempt to force flush after LoggerProvider shutdown`),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush(e)}shutdown(){return this._shutdownOnce.isCalled?(T.warn(`shutdown may only be called once per LoggerProvider`),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.hasShutdown=!0,this._sharedState.activeProcessor.shutdown()}};let fa=new Map;var pa=class{constructor(e,t,n){var r;k(this,`processedLogs`,void 0),k(this,`queueSize`,void 0),k(this,`queueSizeCallback`,void 0),k(this,`standardAttrs`,void 0),k(this,`droppedAttrs`,void 0);let i=(r=fa.get(e))==null?0:r;if(fa.set(e,i+1),this.standardAttrs={"otel.component.type":e,"otel.component.name":`${e}/${i}`},this.droppedAttrs=A(A({},this.standardAttrs),{},{[oa]:`queue_full`}),this.processedLogs=t.createCounter(`otel.sdk.processor.log.processed`,{unit:`{log_record}`,description:`The number of log records for which the processing has finished, either successful or failed.`}),n){let{capacity:e,getQueueSize:r}=n;t.createUpDownCounter(`otel.sdk.processor.log.queue.capacity`,{unit:`{log_record}`,description:`The maximum number of log records the queue of a given instance of an SDK log processor can hold.`}).add(e,this.standardAttrs),this.queueSize=t.createObservableUpDownCounter(`otel.sdk.processor.log.queue.size`,{unit:`{log_record}`,description:`The number of log records in the queue of a given instance of an SDK log processor.`}),this.queueSizeCallback=e=>e.observe(r(),this.standardAttrs),this.queueSize.addCallback(this.queueSizeCallback)}}dropLogs(e){this.processedLogs.add(e,this.droppedAttrs)}finishLogs(e,t){if(!t){this.processedLogs.add(e,this.standardAttrs);return}let n=A(A({},this.standardAttrs),{},{[oa]:t.name});this.processedLogs.add(e,n)}shutdown(){this.queueSize&&this.queueSizeCallback&&this.queueSize.removeCallback(this.queueSizeCallback)}};function ma(e){return ha.apply(this,arguments)}function ha(){return ha=P(function*(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];r.resource.asyncAttributesPending&&r.resource.waitForAsyncAttributes&&t.push(r.resource.waitForAsyncAttributes())}t!=null&&t.length>0&&(yield Promise.all(t))}),ha.apply(this,arguments)}var ga=class{constructor(e,t,n,r){k(this,`_exportCompleted`,void 0),k(this,`_exportScheduledPromise`,void 0),k(this,`_metrics`,void 0),k(this,`_exportScheduledResolve`,void 0),this._exportScheduledPromise=new Promise(e=>{this._exportScheduledResolve=e}),this._exportCompleted=this._executeExport(e,t,n),this._metrics=r}get exportCompleted(){return this._exportCompleted}get exportScheduled(){return this._exportScheduledPromise}_executeExport(e,t,n){var r=this;return P(function*(){try{yield ma(t),yield w.with(Tr(w.active()),P(function*(){return r._exportWithTimeout(e,t,n)}))}catch(e){F(e),r._exportScheduledResolve()}})()}_exportWithTimeout(e,t,n){var r=this;return P(function*(){return new Promise((i,a)=>{let o=setTimeout(()=>{a(Error(`Timeout`))},n);e.export(t,e=>{if(r._metrics.finishLogs(t.length,e.error),clearTimeout(o),e.code===B.SUCCESS)i();else{var n;a((n=e.error)==null?Error(`BatchLogRecordProcessor: log record export failed`):n)}}),r._exportScheduledResolve()})})()}},_a=class{constructor(e){var t,n,r,i;k(this,`_maxExportBatchSize`,void 0),k(this,`_maxQueueSize`,void 0),k(this,`_scheduledDelayMillis`,void 0),k(this,`_exportTimeoutMillis`,void 0),k(this,`_exporter`,void 0),k(this,`_metrics`,void 0),k(this,`_currentExport`,null),k(this,`_finishedLogRecords`,[]),k(this,`_timer`,void 0),k(this,`_shutdownOnce`,void 0),k(this,`_flushing`,!1),this._exporter=e.exporter,this._maxExportBatchSize=(t=e.maxExportBatchSize)==null?512:t,this._maxQueueSize=(n=e.maxQueueSize)==null?2048:n,this._scheduledDelayMillis=(r=e.scheduledDelayMillis)==null?1e3:r,this._exportTimeoutMillis=(i=e.exportTimeoutMillis)==null?3e4:i,this._shutdownOnce=new Ii(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(T.warn(`BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize);let a=e!=null&&e.selfObsMeterProvider?e.selfObsMeterProvider.getMeter(`@opentelemetry/sdk-logs`):Se();this._metrics=new pa(`batching_log_processor`,a,{capacity:this._maxQueueSize,getQueueSize:()=>this._finishedLogRecords.length})}onEmit(e){this._shutdownOnce.isCalled||this._addToBuffer(e)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}_addToBuffer(e){if(this._finishedLogRecords.length>=this._maxQueueSize){this._metrics.dropLogs(1);return}this._finishedLogRecords.push(e),this._maybeStartTimer()}shutdown(){return this._shutdownOnce.call()}_shutdown(){var e=this;return P(function*(){e.onShutdown(),yield e._flushAll(),e._metrics.shutdown(),yield e._exporter.shutdown()})()}_flushAll(){var e=this;return P(function*(){if(e._flushing)return;e._flushing=!0;let t=e._finishedLogRecords;e._finishedLogRecords=[],e._clearTimer();let n=e._currentExport;for(n!==null&&(yield e._exporter.forceFlush(),yield n.exportCompleted,e._currentExport=null);t.length>0;){let n;t.length<=e._maxExportBatchSize?(n=t,t=[]):n=t.splice(0,e._maxExportBatchSize);let r=new ga(e._exporter,n,e._exportTimeoutMillis,e._metrics);e._currentExport=r;try{yield r.exportScheduled,yield e._exporter.forceFlush(),yield r.exportCompleted}catch(e){F(e)}finally{e._currentExport=null}}e._flushing=!1,e._maybeStartTimer()})()}_extractBatch(){if(this._finishedLogRecords.length===0)return null;if(this._finishedLogRecords.length<=this._maxExportBatchSize){let e=this._finishedLogRecords;return this._finishedLogRecords=[],e}return this._finishedLogRecords.splice(0,this._maxExportBatchSize)}_exportOneBatch(){this._clearTimer();let e=this._extractBatch();if(e===null)return;let t=new ga(this._exporter,e,this._exportTimeoutMillis,this._metrics);this._currentExport=t,t.exportCompleted.then(()=>{this._currentExport=null,this._maybeStartTimer()}).catch(e=>{this._currentExport=null,F(e),this._maybeStartTimer()})}_maybeStartTimer(){if(!this._shutdownOnce.isCalled&&!this._flushing&&this._finishedLogRecords.length!==0&&this._currentExport===null){if(this._finishedLogRecords.length>=this._maxExportBatchSize){this._exportOneBatch();return}this._timer===void 0&&(this._timer=setTimeout(()=>{this._timer=void 0,this._exportOneBatch()},this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}},va=class extends _a{constructor(e){super(e),k(this,`_visibilityChangeListener`,void 0),k(this,`_pageHideListener`,void 0),this._onInit(e)}onShutdown(){typeof document>`u`||(this._visibilityChangeListener&&document.removeEventListener(`visibilitychange`,this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener(`pagehide`,this._pageHideListener))}_onInit(e){e.disableAutoFlushOnDocumentHide===!0||typeof document>`u`||(this._visibilityChangeListener=()=>{document.visibilityState===`hidden`&&this.forceFlush()},this._pageHideListener=()=>{this.forceFlush()},document.addEventListener(`visibilitychange`,this._visibilityChangeListener),document.addEventListener(`pagehide`,this._pageHideListener))}};let ya=Symbol.for(`nodejs.util.inspect.custom`);function ba(e){let t={};for(let[n,r]of e.getRawAttributes())typeof(r==null?void 0:r.then)!=`function`&&r!=null&&(t[n]!=null||(t[n]=r));return t}function xa(e,t,n,r,i){if(typeof n==`number`&&n<0){let t=`[${e}]`;return r!=null&&r.stylize?r.stylize(t,`special`):t}return typeof i!=`function`||!r?t:`${e} ${i(t,A(A({},r),{},{depth:r.depth==null?r.depth:r.depth-1}))}`}var Sa=class{constructor(e){var t,n;k(this,`_spanContext`,void 0),k(this,`kind`,void 0),k(this,`parentSpanContext`,void 0),k(this,`attributes`,{}),k(this,`links`,[]),k(this,`events`,[]),k(this,`startTime`,void 0),k(this,`resource`,void 0),k(this,`instrumentationScope`,void 0),k(this,`_droppedAttributesCount`,0),k(this,`_droppedEventsCount`,0),k(this,`_droppedLinksCount`,0),k(this,`_attributesCount`,0),k(this,`name`,void 0),k(this,`status`,{code:C.UNSET}),k(this,`endTime`,[0,0]),k(this,`_ended`,!1),k(this,`_duration`,[-1,-1]),k(this,`_spanProcessor`,void 0),k(this,`_spanLimits`,void 0),k(this,`_attributeValueLengthLimit`,void 0),k(this,`_recordEndMetrics`,void 0),k(this,`_performanceStartTime`,void 0),k(this,`_performanceOffset`,void 0),k(this,`_startTimeProvided`,void 0);let r=Date.now();if(this._spanContext=e.spanContext,this._performanceStartTime=I.now(),this._performanceOffset=r-(this._performanceStartTime+I.timeOrigin),this._startTimeProvided=e.startTime!=null,this._spanLimits=e.spanLimits,this._attributeValueLengthLimit=(t=this._spanLimits.attributeValueLengthLimit)==null?0:t,this._spanProcessor=e.spanProcessor,this.name=e.name,this.parentSpanContext=e.parentSpanContext,this.kind=e.kind,e.links)for(let t of e.links)this.addLink(t);this.startTime=this._getTime((n=e.startTime)==null?r:n),this.resource=e.resource,this.instrumentationScope=e.scope,this._recordEndMetrics=e.recordEndMetrics,e.attributes!=null&&this.setAttributes(e.attributes),this._spanProcessor.onStart(this,e.context)}spanContext(){return this._spanContext}setAttribute(e,t){if(t==null||this._isSpanEnded())return this;if(e.length===0)return T.warn(`Invalid attribute key: ${e}`),this;if(!Fr(t))return T.warn(`Invalid attribute value set for key: ${e}`),this;let{attributeCountLimit:n}=this._spanLimits,r=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n!==void 0&&this._attributesCount>=n&&r?(this._droppedAttributesCount++,this):(this.attributes[e]=this._truncateToSize(t),r&&this._attributesCount++,this)}setAttributes(e){for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.setAttribute(t,e[t]);return this}addEvent(e,t,n){if(this._isSpanEnded())return this;let{eventCountLimit:r}=this._spanLimits;if(r===0)return T.warn(`No events allowed.`),this._droppedEventsCount++,this;r!==void 0&&this.events.length>=r&&(this._droppedEventsCount===0&&T.debug(`Dropping extra events.`),this.events.shift(),this._droppedEventsCount++),Yr(t)&&(Yr(n)||(n=t),t=void 0);let i=Nr(t),{attributePerEventCountLimit:a}=this._spanLimits,o={},s=0,c=0;for(let e in i){if(!Object.prototype.hasOwnProperty.call(i,e))continue;let t=i[e];if(a!==void 0&&c>=a){s++;continue}o[e]=this._truncateToSize(t),c++}return this.events.push({name:e,attributes:o,time:this._getTime(n),droppedAttributesCount:s}),this}addLink(e){if(this._isSpanEnded())return this;let{linkCountLimit:t}=this._spanLimits;if(t===0)return this._droppedLinksCount++,this;t!==void 0&&this.links.length>=t&&(this._droppedLinksCount===0&&T.debug(`Dropping extra links.`),this.links.shift(),this._droppedLinksCount++);let{attributePerLinkCountLimit:n}=this._spanLimits,r=Nr(e.attributes),i={},a=0,o=0;for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e))continue;let t=r[e];if(n!==void 0&&o>=n){a++;continue}i[e]=this._truncateToSize(t),o++}let s={context:e.context};return o>0&&(s.attributes=i),a>0&&(s.droppedAttributesCount=a),this.links.push(s),this}addLinks(e){for(let t of e)this.addLink(t);return this}setStatus(e){if(this._isSpanEnded()||e.code===C.UNSET||this.status.code===C.OK)return this;let t={code:e.code};return e.code===C.ERROR&&(typeof e.message==`string`?t.message=e.message:e.message!=null&&T.warn(`Dropping invalid status.message of type '${typeof e.message}', expected 'string'`)),this.status=t,this}updateName(e){return this._isSpanEnded()||(this.name=e),this}end(e){var t;if(this._isSpanEnded()){T.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);return}this.endTime=this._getTime(e),this._duration=Kr(this.startTime,this.endTime),this._duration[0]<0&&(T.warn(`Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.`,this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&T.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._droppedLinksCount>0&&T.warn(`Dropped ${this._droppedLinksCount} links because linkCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),(t=this._recordEndMetrics)==null||t.call(this),this._ended=!0,this._spanProcessor.onEnd(this)}_getTime(e){if(typeof e==`number`&&e<=I.now())return R(e+this._performanceOffset);if(typeof e==`number`)return L(e);if(e instanceof Date)return L(e.getTime());if(Jr(e))return e;if(this._startTimeProvided)return L(Date.now());let t=I.now()-this._performanceStartTime;return Xr(this.startTime,L(t))}isRecording(){return this._ended===!1}recordException(e,t){let n={};typeof e==`string`?n[Yt]=e:e&&(e.code?n[Zt]=e.code.toString():e.name&&(n[Zt]=e.name),e.message&&(n[Yt]=e.message),e.stack&&(n[Xt]=e.stack)),n[`exception.type`]||n[`exception.message`]?this.addEvent(`exception`,n,t):T.warn(`Failed to record an exception ${e}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){let e=Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);T.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,e)}return this._ended}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_truncateToSize(e){let t=this._attributeValueLengthLimit;return t<=0?(T.warn(`Attribute value limit must be positive, got ${t}`),e):typeof e==`string`?this._truncateToLimitUtil(e,t):Array.isArray(e)?e.map(e=>typeof e==`string`?this._truncateToLimitUtil(e,t):e):e}[ya](e,t,n){return xa(`SpanImpl`,{name:this.name,kind:this.kind,spanContext:this._spanContext,parentSpanContext:this.parentSpanContext,status:this.status,startTime:this.startTime,endTime:this.endTime,duration:this._duration,ended:this._ended,attributes:this.attributes,events:this.events,links:this.links,droppedAttributesCount:this._droppedAttributesCount,droppedEventsCount:this._droppedEventsCount,droppedLinksCount:this._droppedLinksCount,instrumentationScope:this.instrumentationScope,resource:{attributes:ba(this.resource)}},e,t,n)}},H;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(H||(H={}));let Ca=`otel.span.sampling_result`;var wa=class{constructor(e){k(this,`startedSpans`,void 0),k(this,`liveSpans`,void 0),this.startedSpans=e.createCounter(`otel.sdk.span.started`,{unit:`{span}`,description:`The number of created spans.`}),this.liveSpans=e.createUpDownCounter(`otel.sdk.span.live`,{unit:`{span}`,description:`The number of currently live spans.`})}startSpan(e,t){let n=Ea(t);if(this.startedSpans.add(1,{"otel.span.parent.origin":Ta(e),[Ca]:n}),t===H.NOT_RECORD)return()=>{};let r={[Ca]:n};return this.liveSpans.add(1,r),()=>{this.liveSpans.add(-1,r)}}};function Ta(e){return e?e.isRemote?`remote`:`local`:`none`}function Ea(e){switch(e){case H.RECORD_AND_SAMPLED:return`RECORD_AND_SAMPLE`;case H.RECORD:return`RECORD_ONLY`;case H.NOT_RECORD:return`DROP`}}var Da=class{constructor(e,t){k(this,`_sampler`,void 0),k(this,`_spanLimits`,void 0),k(this,`_idGenerator`,void 0),k(this,`instrumentationScope`,void 0),k(this,`_resource`,void 0),k(this,`_spanProcessor`,void 0),k(this,`_tracerMetrics`,void 0),this.instrumentationScope=e,this._sampler=t.sampler,this._spanLimits=t.spanLimits,this._resource=t.resource,this._idGenerator=t.idGenerator,this._spanProcessor=t.spanProcessor;let n=t.meterProvider.getMeter(`@opentelemetry/sdk-trace`,`2.10.0`);this._tracerMetrics=new wa(n)}startSpan(e,t={},n=w.active()){var r,i,a;t.root&&(n=D.deleteSpan(n));let o=D.getSpan(n);if(Er(n))return T.debug(`Instrumentation suppressed, returning Noop Span`),D.wrapSpanContext(ke);let s=o==null?void 0:o.spanContext(),c=this._idGenerator.generateSpanId(),l,u,d;!s||!D.isSpanContextValid(s)?u=this._idGenerator.generateTraceId():(u=s.traceId,d=s.traceState,l=s);let f=(r=t.kind)==null?Qe.INTERNAL:r,p=((i=t.links)==null?[]:i).map(e=>({context:e.context,attributes:Nr(e.attributes)})),m=Nr(t.attributes),h=this._sampler.shouldSample(n,u,e,f,m,p),g=this._tracerMetrics.startSpan(s,h.decision);d=(a=h.traceState)==null?d:a;let ee=h.decision===Ze.RECORD_AND_SAMPLED?S.SAMPLED:S.NONE,_={traceId:u,spanId:c,traceFlags:ee,traceState:d};if(h.decision===Ze.NOT_RECORD)return T.debug(`Recording is off, propagating context in a non-recording span`),D.wrapSpanContext(_);let te=Nr(Object.assign(m,h.attributes));return new Sa({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:_,name:e,kind:f,links:p,parentSpanContext:l,attributes:te,startTime:t.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits,recordEndMetrics:g})}startActiveSpan(e,t,n,r){var i;let a,o,s;if(arguments.length<2)return;arguments.length===2?s=t:arguments.length===3?(a=t,s=n):(a=t,o=n,s=r);let c=(i=o)==null?w.active():i,l=this.startSpan(e,a,c),u=D.setSpan(c,l);return w.with(u,s,void 0,l)}[ya](e,t,n){return xa(`Tracer`,{instrumentationScope:this.instrumentationScope,resource:{attributes:ba(this._resource)},spanLimits:this._spanLimits},e,t,n)}},Oa=class{constructor(e){k(this,`_spanProcessors`,void 0),this._spanProcessors=e}forceFlush(){let e=[];for(let t of this._spanProcessors)e.push(t.forceFlush());return new Promise(t=>{Promise.all(e).then(()=>{t()}).catch(e=>{F(e||Error(`MultiSpanProcessor: forceFlush failed`)),t()})})}onStart(e,t){for(let n of this._spanProcessors)n.onStart(e,t)}onEnding(e){for(let t of this._spanProcessors)t.onEnding&&t.onEnding(e)}onEnd(e){for(let t of this._spanProcessors)t.onEnd(e)}shutdown(){let e=[];for(let t of this._spanProcessors)e.push(t.shutdown());return new Promise((t,n)=>{Promise.all(e).then(()=>{t()},n)})}},ka=class{shouldSample(){return{decision:H.NOT_RECORD}}toString(){return`AlwaysOffSampler`}},Aa=class{shouldSample(){return{decision:H.RECORD_AND_SAMPLED}}toString(){return`AlwaysOnSampler`}},ja=class{constructor(e){var t,n,r,i;k(this,`_root`,void 0),k(this,`_remoteParentSampled`,void 0),k(this,`_remoteParentNotSampled`,void 0),k(this,`_localParentSampled`,void 0),k(this,`_localParentNotSampled`,void 0),this._root=e.root,this._root||(F(Error(`ParentBasedSampler must have a root sampler configured`)),this._root=new Aa),this._remoteParentSampled=(t=e.remoteParentSampled)==null?new Aa:t,this._remoteParentNotSampled=(n=e.remoteParentNotSampled)==null?new ka:n,this._localParentSampled=(r=e.localParentSampled)==null?new Aa:r,this._localParentNotSampled=(i=e.localParentNotSampled)==null?new ka:i}shouldSample(e,t,n,r,i,a){let o=D.getSpanContext(e);return!o||!He(o)?this._root.shouldSample(e,t,n,r,i,a):o.isRemote?o.traceFlags&S.SAMPLED?this._remoteParentSampled.shouldSample(e,t,n,r,i,a):this._remoteParentNotSampled.shouldSample(e,t,n,r,i,a):o.traceFlags&S.SAMPLED?this._localParentSampled.shouldSample(e,t,n,r,i,a):this._localParentNotSampled.shouldSample(e,t,n,r,i,a)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}};let Ma=new Map;var Na=class{constructor(e,t,n){var r;k(this,`processedSpans`,void 0),k(this,`queueSize`,void 0),k(this,`queueSizeCallback`,void 0),k(this,`standardAttrs`,void 0),k(this,`droppedAttrs`,void 0);let i=(r=Ma.get(e))==null?0:r;if(Ma.set(e,i+1),this.standardAttrs={"otel.component.type":e,"otel.component.name":`${e}/${i}`},this.droppedAttrs=A(A({},this.standardAttrs),{},{[Jt]:`queue_full`}),this.processedSpans=t.createCounter(`otel.sdk.processor.span.processed`,{unit:`{span}`,description:`The number of spans for which the processing has finished, either successful or failed.`}),n){let{capacity:e,getQueueSize:r}=n;t.createUpDownCounter(`otel.sdk.processor.span.queue.capacity`,{unit:`{span}`,description:`The maximum number of spans the queue of a given instance of an SDK span processor can hold.`}).add(e,this.standardAttrs),this.queueSize=t.createObservableUpDownCounter(`otel.sdk.processor.span.queue.size`,{unit:`{span}`,description:`The number of spans in the queue of a given instance of an SDK span processor.`}),this.queueSizeCallback=e=>e.observe(r(),this.standardAttrs),this.queueSize.addCallback(this.queueSizeCallback)}}dropSpans(e){this.processedSpans.add(e,this.droppedAttrs)}finishSpans(e,t){if(!t){this.processedSpans.add(e,this.standardAttrs);return}let n=A(A({},this.standardAttrs),{},{[Jt]:t.name});this.processedSpans.add(e,n)}shutdown(){this.queueSize&&this.queueSizeCallback&&this.queueSize.removeCallback(this.queueSizeCallback)}},Pa=class{constructor(e){var t,n,r,i;k(this,`_maxExportBatchSize`,void 0),k(this,`_maxQueueSize`,void 0),k(this,`_scheduledDelayMillis`,void 0),k(this,`_exportTimeoutMillis`,void 0),k(this,`_exporter`,void 0),k(this,`_metrics`,void 0),k(this,`_isExporting`,!1),k(this,`_finishedSpans`,[]),k(this,`_timer`,void 0),k(this,`_shutdownOnce`,void 0),k(this,`_droppedSpansCount`,0),this._exporter=e.exporter,this._maxExportBatchSize=(t=e.maxExportBatchSize)==null?512:t,this._maxQueueSize=(n=e.maxQueueSize)==null?2048:n,this._scheduledDelayMillis=(r=e.scheduledDelayMillis)==null?5e3:r,this._exportTimeoutMillis=(i=e.exportTimeoutMillis)==null?3e4:i,this._shutdownOnce=new Ii(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(T.warn(`BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize);let a=e.selfObsMeterProvider?e.selfObsMeterProvider.getMeter(`@opentelemetry/sdk-trace`):Se();this._metrics=new Na(`batching_span_processor`,a,{capacity:this._maxQueueSize,getQueueSize:()=>this._finishedSpans.length})}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}onStart(e,t){}onEnd(e){this._shutdownOnce.isCalled||(e.spanContext().traceFlags&S.SAMPLED)!==0&&this._addToBuffer(e)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>this.onShutdown()).then(()=>this._flushAll()).then(()=>(this._metrics.shutdown(),this._exporter.shutdown()))}_addToBuffer(e){if(this._finishedSpans.length>=this._maxQueueSize){this._droppedSpansCount===0&&T.debug(`maxQueueSize reached, dropping spans`),this._droppedSpansCount++,this._metrics.dropSpans(1);return}this._droppedSpansCount>0&&(T.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0),this._finishedSpans.push(e),this._maybeStartTimer()}_flushAll(){return new Promise((e,t)=>{let n=[],r=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);for(let e=0,t=r;e<t;e++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{e()}).catch(t)})}_flushOneBatch(){return this._clearTimer(),this._finishedSpans.length===0?Promise.resolve():new Promise((e,t)=>{let n=setTimeout(()=>{t(Error(`Timeout`))},this._exportTimeoutMillis);w.with(Tr(w.active()),()=>{let r;this._finishedSpans.length<=this._maxExportBatchSize?(r=this._finishedSpans,this._finishedSpans=[]):r=this._finishedSpans.splice(0,this._maxExportBatchSize);let i=()=>this._exporter.export(r,i=>{if(clearTimeout(n),this._metrics.finishSpans(r.length,i.error),i.code===B.SUCCESS)e();else{var a;t((a=i.error)==null?Error(`BatchSpanProcessor: span export failed`):a)}}),a=null;for(let e=0,t=r.length;e<t;e++){let t=r[e];t.resource.asyncAttributesPending&&t.resource.waitForAsyncAttributes&&(a!=null||(a=[]),a.push(t.resource.waitForAsyncAttributes()))}a===null?i():Promise.all(a).then(i,e=>{F(e),t(e)})})})}_maybeStartTimer(){if(this._isExporting)return;let e=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{this._isExporting=!1,this._finishedSpans.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(e=>{this._isExporting=!1,F(e)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return e();this._timer===void 0&&(this._timer=setTimeout(()=>e(),this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}},Fa=class extends Pa{constructor(e){super(e),k(this,`_visibilityChangeListener`,void 0),k(this,`_pageHideListener`,void 0),this.onInit(e)}onInit(e){e.disableAutoFlushOnDocumentHide!==!0&&typeof document<`u`&&(this._visibilityChangeListener=()=>{document.visibilityState===`hidden`&&this.forceFlush().catch(e=>{F(e)})},this._pageHideListener=()=>{this.forceFlush().catch(e=>{F(e)})},document.addEventListener(`visibilitychange`,this._visibilityChangeListener),document.addEventListener(`pagehide`,this._pageHideListener))}onShutdown(){typeof document<`u`&&(this._visibilityChangeListener&&document.removeEventListener(`visibilitychange`,this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener(`pagehide`,this._pageHideListener))}};let Ia=new Uint8Array(16),La=new Uint8Array(8),Ra=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function za(e){for(let t=0;t<e.length;t++)e[t]=Math.random()*256>>>0;for(let t=0;t<e.length;t++)if(e[t]>0)return;e[e.length-1]=1}function Ba(e){let t=``;for(let n=0;n<e.length;n++)t+=Ra[e[n]];return t}var Va=class{generateTraceId(){return za(Ia),Ba(Ia)}generateSpanId(){return za(La),Ba(La)}},Ha;(function(e){e[e.resolved=0]=`resolved`,e[e.timeout=1]=`timeout`,e[e.error=2]=`error`,e[e.unresolved=3]=`unresolved`})(Ha||(Ha={}));var Ua=class{constructor(e={}){var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,ee;k(this,`_resource`,void 0),k(this,`_activeSpanProcessor`,void 0),k(this,`_forceFlushTimeoutMillis`,void 0),k(this,`_tracerOptions`,void 0),k(this,`_tracers`,new Map),this._forceFlushTimeoutMillis=(t=e.forceFlushTimeoutMillis)==null?3e4:t,this._resource=(n=e.resource)==null?Gi():n;let _=(r=e.spanProcessors)==null?[]:r;this._activeSpanProcessor=new Oa(_),this._tracerOptions={resource:this._resource,sampler:(i=e.sampler)==null?new ja({root:new Aa}):i,spanLimits:{attributeCountLimit:(a=(o=e.spanLimits)==null?void 0:o.attributeCountLimit)==null?128:a,attributeValueLengthLimit:(s=(c=e.spanLimits)==null?void 0:c.attributeValueLengthLimit)==null?1/0:s,eventCountLimit:(l=(u=e.spanLimits)==null?void 0:u.eventCountLimit)==null?128:l,linkCountLimit:(d=(f=e.spanLimits)==null?void 0:f.linkCountLimit)==null?128:d,attributePerEventCountLimit:(p=(m=e.spanLimits)==null?void 0:m.attributePerEventCountLimit)==null?128:p,attributePerLinkCountLimit:(h=(g=e.spanLimits)==null?void 0:g.attributePerLinkCountLimit)==null?128:h},idGenerator:e.idGenerator||new Va,spanProcessor:this._activeSpanProcessor,meterProvider:(ee=e.meterProvider)==null?{getMeter(){return Se()}}:ee}}getTracer(e,t,n){let r=`${e}@${t||``}:${(n==null?void 0:n.schemaUrl)||``}`;return this._tracers.has(r)||this._tracers.set(r,new Da({name:e,version:t,schemaUrl:n==null?void 0:n.schemaUrl},this._tracerOptions)),this._tracers.get(r)}forceFlush(){let e=this._forceFlushTimeoutMillis,t=this._activeSpanProcessor._spanProcessors.map(t=>new Promise(n=>{let r,i=setTimeout(()=>{n(Error(`Span processor did not completed within timeout period of ${e} ms`)),r=Ha.timeout},e);t.forceFlush().then(()=>{clearTimeout(i),r!==Ha.timeout&&(r=Ha.resolved,n(r))}).catch(e=>{clearTimeout(i),r=Ha.error,n(e)})}));return new Promise((e,n)=>{Promise.all(t).then(t=>{let r=t.filter(e=>e!==Ha.resolved);r.length>0?n(r):e()}).catch(e=>n([e]))})}shutdown(){return this._activeSpanProcessor.shutdown()}[ya](e,t,n){let r=this._activeSpanProcessor._spanProcessors;return xa(`TracerProvider`,{resource:{attributes:ba(this._resource)},tracers:Array.from(this._tracers.keys()),spanProcessors:r.map(e=>{var t,n;return(t=(n=e.constructor)==null?void 0:n.name)==null?`SpanProcessor`:t})},e,t,n)}},Wa=class{constructor(e=0){k(this,`_ratio`,void 0),k(this,`_upperBound`,void 0),this._ratio=this._normalize(e),this._upperBound=this._ratio===1?4294967296:Math.floor(this._ratio*4294967295)}shouldSample(e,t){return{decision:Be(t)&&this._accumulate(t)<this._upperBound?H.RECORD_AND_SAMPLED:H.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(e){return typeof e!=`number`||isNaN(e)?0:e>=1?1:e<=0?0:e}_accumulate(e){let t=0;for(let n=0;n<32;n+=8){let r=0;for(let t=0;t<8;t++){let i=e.charCodeAt(n+t),a=i<58?i-48:i<71?i-55:i-87;r=r<<4|a}t=(t^r)>>>0}return t}},U;(function(e){e.AlwaysOff=`always_off`,e.AlwaysOn=`always_on`,e.ParentBasedAlwaysOff=`parentbased_always_off`,e.ParentBasedAlwaysOn=`parentbased_always_on`,e.ParentBasedTraceIdRatio=`parentbased_traceidratio`,e.TraceIdRatio=`traceidratio`})(U||(U={}));function Ga(){var e,t,n,r,i,a,o,s;return{sampler:Ka(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:(e=void 0)==null?1/0:e,attributeCountLimit:(t=void 0)==null?128:t},spanLimits:{attributeValueLengthLimit:(n=void 0)==null?1/0:n,attributeCountLimit:(r=void 0)==null?128:r,linkCountLimit:(i=void 0)==null?128:i,eventCountLimit:(a=void 0)==null?128:a,attributePerEventCountLimit:(o=void 0)==null?128:o,attributePerLinkCountLimit:(s=void 0)==null?128:s}}}function Ka(){var e;let t=(e=void 0)==null?U.ParentBasedAlwaysOn:e;switch(t){case U.AlwaysOn:return new Aa;case U.AlwaysOff:return new ka;case U.ParentBasedAlwaysOn:return new ja({root:new Aa});case U.ParentBasedAlwaysOff:return new ja({root:new ka});case U.TraceIdRatio:return new Wa(qa());case U.ParentBasedTraceIdRatio:return new ja({root:new Wa(qa())});default:return T.error(`OTEL_TRACES_SAMPLER value "${t}" invalid, defaulting to "${U.ParentBasedAlwaysOn}".`),new ja({root:new Aa})}}function qa(){return T.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to 1.`),1}function Ja(e){var t,n,r,i,a,o,s,c,l,u,d,f;let p=Object.assign({},e.spanLimits);return p.attributeCountLimit=(t=(n=(r=(i=(a=e.spanLimits)==null?void 0:a.attributeCountLimit)==null?(o=e.generalLimits)==null?void 0:o.attributeCountLimit:i)==null?void 0:r)==null?void 0:n)==null?128:t,p.attributeValueLengthLimit=(s=(c=(l=(u=(d=e.spanLimits)==null?void 0:d.attributeValueLengthLimit)==null?(f=e.generalLimits)==null?void 0:f.attributeValueLengthLimit:u)==null?void 0:l)==null?void 0:c)==null?1/0:s,Object.assign({},e,{spanLimits:p})}var Ya=class extends Ua{constructor(e={}){let t=Si({},Ga(),Ja(e));delete t.generalLimits,super(t)}},Xa=class{constructor(){k(this,`_enabled`,!1),k(this,`_currentContext`,b)}_bindFunction(e=b,t){let n=this,r=function(...r){return n.with(e,()=>t.apply(this,r))};return Object.defineProperty(r,"length",{enumerable:!1,configurable:!0,writable:!1,value:t.length}),r}active(){return this._currentContext}bind(e,t){return e===void 0&&(e=this.active()),typeof t==`function`?this._bindFunction(e,t):t}disable(){return this._currentContext=b,this._enabled=!1,this}enable(){return this._enabled?this:(this._enabled=!0,this._currentContext=b,this)}with(e,t,n,...r){let i=this._currentContext;this._currentContext=e||b;try{return t.call(n,...r)}finally{this._currentContext=i}}};function Za(e){if(e!==null){if(e===void 0){let e=new Xa;e.enable(),w.setGlobalContextManager(e);return}e.enable(),w.setGlobalContextManager(e)}}function Qa(e){if(e!==null){if(e===void 0){E.setGlobalPropagator(new Zr({propagators:[new li,new Mr]}));return}E.setGlobalPropagator(e)}}var $a=class extends Ya{constructor(e={}){super(e)}register(e={}){D.setGlobalTracerProvider(this),Qa(e.propagator),Za(e.contextManager)}},W;(function(e){e.CONNECT_END=`connectEnd`,e.CONNECT_START=`connectStart`,e.DECODED_BODY_SIZE=`decodedBodySize`,e.DOM_COMPLETE=`domComplete`,e.DOM_CONTENT_LOADED_EVENT_END=`domContentLoadedEventEnd`,e.DOM_CONTENT_LOADED_EVENT_START=`domContentLoadedEventStart`,e.DOM_INTERACTIVE=`domInteractive`,e.DOMAIN_LOOKUP_END=`domainLookupEnd`,e.DOMAIN_LOOKUP_START=`domainLookupStart`,e.ENCODED_BODY_SIZE=`encodedBodySize`,e.FETCH_START=`fetchStart`,e.LOAD_EVENT_END=`loadEventEnd`,e.LOAD_EVENT_START=`loadEventStart`,e.NAVIGATION_START=`navigationStart`,e.REDIRECT_END=`redirectEnd`,e.REDIRECT_START=`redirectStart`,e.REQUEST_START=`requestStart`,e.RESPONSE_END=`responseEnd`,e.RESPONSE_START=`responseStart`,e.SECURE_CONNECTION_START=`secureConnectionStart`,e.START_TIME=`startTime`,e.UNLOAD_EVENT_END=`unloadEventEnd`,e.UNLOAD_EVENT_START=`unloadEventStart`})(W||(W={}));let eo;function to(){return eo||(eo=document.createElement(`a`)),eo}function no(e,t){return t in e}function G(e,t,n,r=!0){if(no(n,t)&&typeof n[t]==`number`&&!(r&&n[t]===0))return e.addEvent(t,n[t])}function ro(e,t,n=!1,r,i){if(r===void 0&&(r=t[W.START_TIME]!==0),n||(G(e,W.FETCH_START,t,r),G(e,W.DOMAIN_LOOKUP_START,t,r),G(e,W.DOMAIN_LOOKUP_END,t,r),G(e,W.CONNECT_START,t,r),G(e,W.SECURE_CONNECTION_START,t,r),G(e,W.CONNECT_END,t,r),G(e,W.REQUEST_START,t,r),G(e,W.RESPONSE_START,t,r),G(e,W.RESPONSE_END,t,r)),!i){let n=t[W.ENCODED_BODY_SIZE];n!==void 0&&e.setAttribute(`http.response_content_length`,n);let r=t[W.DECODED_BODY_SIZE];r!==void 0&&n!==r&&e.setAttribute(`http.response_content_length_uncompressed`,r)}}function io(e){return e.slice().sort((e,t)=>{let n=e[W.FETCH_START],r=t[W.FETCH_START];return n>r?1:n<r?-1:0})}function ao(){return typeof location<`u`?location.origin:void 0}function oo(e,t,n,r,i=new WeakSet,a){let o=K(e);e=o.toString();let s=co(e,t,n,r,i,a);if(s.length===0)return{mainRequest:void 0};if(s.length===1)return{mainRequest:s[0]};let c=io(s);if(o.origin!==ao()&&c.length>1){let e=c[0],t=so(c,e[W.RESPONSE_END],n),r=e[W.RESPONSE_END];return t[W.FETCH_START]<r&&(t=e,e=void 0),{corsPreFlightRequest:e,mainRequest:t}}return{mainRequest:s[0]}}function so(e,t,n){let r=z(n),i=z(Gr(t)),a=e[1],o,s=e.length;for(let t=1;t<s;t++){let n=e[t],s=z(Gr(n[W.FETCH_START])),c=r-z(Gr(n[W.RESPONSE_END]));s>=i&&(!o||c<o)&&(o=c,a=n)}return a}function co(e,t,n,r,i,a){let o=z(t),s=z(n),c=r.filter(t=>{let n=z(Gr(t[W.FETCH_START])),r=z(Gr(t[W.RESPONSE_END]));return t.initiatorType.toLowerCase()===(a||`xmlhttprequest`)&&t.name===e&&n>=o&&r<=s});return c.length>0&&(c=c.filter(e=>!i.has(e))),c}function K(e){if(typeof URL==`function`)return new URL(e,typeof document<`u`?document.baseURI:typeof location<`u`?location.href:void 0);let t=to();return t.href=e,t}function lo(e,t){let n=t||[];return(typeof n==`string`||n instanceof RegExp)&&(n=[n]),K(e).origin===ao()||n.some(t=>Ni(e,t))}let uo={compression:`gzip`,keepalive:!0,concurrencyLimit:5,timeoutMillis:3e4},fo=(e,t)=>({"X-EM-AID":e,"X-EM-DID":t}),po=(e,t)=>t||`https://a-${e}.data.emb-api.com`,mo={name:`span`,countItems:e=>e.length},ho={name:`log`,countItems:e=>e.length},go=`1.9.1`,_o=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function vo(e){let t=new Set([e]),n=new Set,r=e.match(_o);if(!r)return()=>!1;let i={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(i.prerelease!=null)return function(t){return t===e};function a(e){return n.add(e),!1}function o(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(n.has(e))return!1;let r=e.match(_o);if(!r)return a(e);let s={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};return s.prerelease!=null||i.major!==s.major?a(e):i.major===0?i.minor===s.minor&&i.patch<=s.patch?o(e):a(e):i.minor<=s.minor?o(e):a(e)}}let yo=vo(go),bo=go.split(`.`)[0],xo=Symbol.for(`opentelemetry.js.api.${bo}`),So=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{};function Co(e,t,n,r=!1){var i;let a=So[xo]=(i=So[xo])==null?{version:go}:i;if(!r&&a[e]){let t=Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);return n.error(t.stack||t.message),!1}if(a.version!==`1.9.1`){let t=Error(`@opentelemetry/api: Registration of version v${a.version} for ${e} does not match previously registered API v${go}`);return n.error(t.stack||t.message),!1}return a[e]=t,n.debug(`@opentelemetry/api: Registered a global for ${e} v${go}.`),!0}function wo(e){var t,n;let r=(t=So[xo])==null?void 0:t.version;if(!(!r||!yo(r)))return(n=So[xo])==null?void 0:n[e]}function To(e,t){t.debug(`@opentelemetry/api: Unregistering a global for ${e} v${go}.`);let n=So[xo];n&&delete n[e]}var Eo=class{constructor(e){this._namespace=e.namespace||`DiagComponentLogger`}debug(...e){return Do(`debug`,this._namespace,e)}error(...e){return Do(`error`,this._namespace,e)}info(...e){return Do(`info`,this._namespace,e)}warn(...e){return Do(`warn`,this._namespace,e)}verbose(...e){return Do(`verbose`,this._namespace,e)}};function Do(e,t,n){let r=wo(`diag`);if(r)return r[e](t,...n)}var q;(function(e){e[e.NONE=0]=`NONE`,e[e.ERROR=30]=`ERROR`,e[e.WARN=50]=`WARN`,e[e.INFO=60]=`INFO`,e[e.DEBUG=70]=`DEBUG`,e[e.VERBOSE=80]=`VERBOSE`,e[e.ALL=9999]=`ALL`})(q||(q={}));function Oo(e,t){e<q.NONE?e=q.NONE:e>q.ALL&&(e=q.ALL),t=t||{};function n(n,r){let i=t[n];return typeof i==`function`&&e>=r?i.bind(t):function(){}}return{error:n(`error`,q.ERROR),warn:n(`warn`,q.WARN),info:n(`info`,q.INFO),debug:n(`debug`,q.DEBUG),verbose:n(`verbose`,q.VERBOSE)}}let ko=class e{static instance(){return this._instance||(this._instance=new e),this._instance}constructor(){function e(e){return function(...t){let n=wo(`diag`);if(n)return n[e](...t)}}let t=this;t.setLogger=(e,n={logLevel:q.INFO})=>{var r,i,a;if(e===t){let e=Error(`Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation`);return t.error((r=e.stack)==null?e.message:r),!1}typeof n==`number`&&(n={logLevel:n});let o=wo(`diag`),s=Oo((i=n.logLevel)==null?q.INFO:i,e);if(o&&!n.suppressOverrideMessage){let e=(a=Error().stack)==null?`<failed to generate stacktrace>`:a;o.warn(`Current logger will be overwritten from ${e}`),s.warn(`Current logger will overwrite one already registered from ${e}`)}return Co(`diag`,s,t,!0)},t.disable=()=>{To(`diag`,t)},t.createComponentLogger=e=>new Eo(e),t.verbose=e(`verbose`),t.debug=e(`debug`),t.info=e(`info`),t.warn=e(`warn`),t.error=e(`error`)}}.instance(),Ao=Math.pow(10,9);function jo(e){return e[0]*Ao+e[1]}function Mo(e,t){let n={attributes:Po(e.attributes,t),droppedAttributesCount:0},r=e.schemaUrl;return r&&r!==``&&(n.schemaUrl=r),n}function No(e,t){let n={name:e.name,version:e.version};if(e.attributes&&Object.keys(e.attributes).length>0){var r;n.attributes=Po(e.attributes,t),n.droppedAttributesCount=(r=e.droppedAttributesCount)==null?0:r}return n}function Po(e,t){return Object.keys(e).map(n=>Fo(n,e[n],t))}function Fo(e,t,n){return{key:e,value:Io(t,n)}}function Io(e,t){let n=typeof e;if(n===`string`)return{stringValue:e};if(n===`number`)return Number.isInteger(e)?{intValue:e}:{doubleValue:e};if(n===`boolean`)return{boolValue:e};if(e instanceof Uint8Array)return{bytesValue:t.encodeUint8Array(e)};if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=Io(e[r],t);return{arrayValue:{values:n}}}if(n===`object`&&e!=null){let n=Object.keys(e),r=Array(n.length);for(let i=0;i<n.length;i++)r[i]={key:n[i],value:Io(e[n[i]],t)};return{kvlistValue:{values:r}}}return{}}function Lo(e,t){return{resourceLogs:zo(e,t)}}function Ro(e){let t=new Map;for(let n of e){let{resource:e,instrumentationScope:r}=n,i=t.get(e);i||(i=new Map,t.set(e,i));let a=i.get(r);a||(a=[],i.set(r,a)),a.push(n)}return t}function zo(e,t){let n=Ro(e);return Array.from(n,([e,n])=>{let r=Mo(e,t);return{resource:r,scopeLogs:Array.from(n,([,e])=>({scope:No(e[0].instrumentationScope,t),logRecords:e.map(e=>Bo(e,t)),schemaUrl:e[0].instrumentationScope.schemaUrl})),schemaUrl:r.schemaUrl}})}function Bo(e,t){var n,r,i;return{timeUnixNano:t.encodeHrTime(e.hrTime),observedTimeUnixNano:t.encodeHrTime(e.hrTimeObserved),severityNumber:Vo(e.severityNumber),severityText:e.severityText,body:Io(e.body,t),eventName:e.eventName,attributes:Po(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,flags:(n=e.spanContext)==null?void 0:n.traceFlags,traceId:t.encodeOptionalSpanContext((r=e.spanContext)==null?void 0:r.traceId),spanId:t.encodeOptionalSpanContext((i=e.spanContext)==null?void 0:i.spanId)}}function Vo(e){return e}function Ho(e){let t=BigInt(1e9);return BigInt(Math.trunc(e[0]))*t+BigInt(Math.trunc(e[1]))}function Uo(e){return Ho(e).toString()}let Wo=typeof BigInt<`u`?Uo:jo;function Go(e){return e}let Ko={encodeHrTime:Wo,encodeSpanContext:Go,encodeOptionalSpanContext:Go,encodeUint8Array:e=>{if(typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=String.fromCharCode(e[n]);return btoa(t.join(``))}},qo={serializeRequest:e=>{let t=Lo(e,Ko);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return ko.warn(`Failed to parse logs export response: ${e.message}. Returning empty response`),{}}}};function Jo(e,t){let n=e&255|256;return t&&(n|=512),n}function Yo(e,t){var n,r,i,a;let o=e.spanContext(),s=e.status,c=(n=e.parentSpanContext)!=null&&n.spanId?t.encodeSpanContext((r=e.parentSpanContext)==null?void 0:r.spanId):void 0;return{traceId:t.encodeSpanContext(o.traceId),spanId:t.encodeSpanContext(o.spanId),parentSpanId:c,traceState:(i=o.traceState)==null?void 0:i.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:Po(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(e=>Zo(e,t)),droppedEventsCount:e.droppedEventsCount,status:{code:s.code,message:s.message},links:e.links.map(e=>Xo(e,t)),droppedLinksCount:e.droppedLinksCount,flags:Jo(o.traceFlags,(a=e.parentSpanContext)==null?void 0:a.isRemote)}}function Xo(e,t){var n;return{attributes:e.attributes?Po(e.attributes,t):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:(n=e.context.traceState)==null?void 0:n.serialize(),droppedAttributesCount:e.droppedAttributesCount||0,flags:Jo(e.context.traceFlags,e.context.isRemote)}}function Zo(e,t){return{attributes:e.attributes?Po(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function Qo(e,t){return{resourceSpans:es(e,t)}}function $o(e){let t=new Map;for(let n of e){let e=t.get(n.resource);e||(e=new Map,t.set(n.resource,e));let r=`${n.instrumentationScope.name}@${n.instrumentationScope.version||``}:${n.instrumentationScope.schemaUrl||``}`,i=e.get(r);i||(i=[],e.set(r,i)),i.push(n)}return t}function es(e,t){let n=$o(e),r=[],i=n.entries(),a=i.next();for(;!a.done;){let[e,n]=a.value,o=[],s=n.values(),c=s.next();for(;!c.done;){let e=c.value;if(e.length>0){let n=e.map(e=>Yo(e,t));o.push({scope:No(e[0].instrumentationScope,t),spans:n,schemaUrl:e[0].instrumentationScope.schemaUrl})}c=s.next()}let l=Mo(e,t),u={resource:l,scopeSpans:o,schemaUrl:l.schemaUrl};r.push(u),a=i.next()}return r}let ts={serializeRequest:e=>{let t=Qo(e,Ko);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return ko.warn(`Failed to parse trace export response: ${e.message}. Returning empty response`),{}}}};var ns=class{constructor(e){this._delegate=e}export(e,t){this._delegate.export(e,t)}forceFlush(){return this._delegate.forceFlush()}shutdown(){return this._delegate.shutdown()}},rs=class extends Error{constructor(e,t,n){super(e),k(this,`code`,void 0),k(this,`name`,`OTLPExporterError`),k(this,`data`,void 0),this.data=n,this.code=t}},is=class{constructor(e){k(this,`_concurrencyLimit`,void 0),k(this,`_sendingPromises`,[]),this._concurrencyLimit=e}pushPromise(e){if(this.hasReachedLimit())throw Error(`Concurrency Limit reached`);this._sendingPromises.push(e);let t=()=>{let t=this._sendingPromises.indexOf(e);this._sendingPromises.splice(t,1)};e.then(t,t)}hasReachedLimit(){return this._sendingPromises.length>=this._concurrencyLimit}awaitAll(){var e=this;return P(function*(){yield Promise.all(e._sendingPromises)})()}};function as(e){return new is(e.concurrencyLimit)}function os(e){return Object.prototype.hasOwnProperty.call(e,`partialSuccess`)}function ss(){return{handleResponse(e){e==null||!os(e)||e.partialSuccess==null||Object.keys(e.partialSuccess).length===0||T.warn(`Received Partial Success response:`,JSON.stringify(e.partialSuccess))}}}var cs=class{constructor(e,t,n,r,i,a){k(this,`_metrics`,void 0),k(this,`_diagLogger`,void 0),k(this,`_transport`,void 0),k(this,`_serializer`,void 0),k(this,`_responseHandler`,void 0),k(this,`_promiseQueue`,void 0),k(this,`_timeout`,void 0),this._transport=e,this._serializer=t,this._responseHandler=n,this._promiseQueue=r,this._timeout=a,this._diagLogger=T.createComponentLogger({namespace:`OTLPExportDelegate`}),this._metrics=i}export(e,t){if(this._diagLogger.debug(`items to be sent`,e),this._promiseQueue.hasReachedLimit()){t({code:B.FAILED,error:Error(`Concurrent export limit reached`)});return}let n=this._serializer.serializeRequest(e);if(n==null){t({code:B.FAILED,error:Error(`Nothing to send`)});return}let r=this._metrics.startExport(e);this._promiseQueue.pushPromise(this._transport.send(n,this._timeout).then(e=>{if(e.status===`success`){if(r(void 0),e.data!=null)try{this._responseHandler.handleResponse(this._serializer.deserializeResponse(e.data))}catch(t){this._diagLogger.warn(`Export succeeded but could not deserialize response - is the response specification compliant?`,t,e.data)}t({code:B.SUCCESS});return}if(e.status===`failure`&&e.error){r(e.error),t({code:B.FAILED,error:e.error});return}if(e.status===`retryable`){var n;r(`export_max_retries`),t({code:B.FAILED,error:(n=e.error)==null?new rs(`Export failed with retryable status`):n})}else r(`export_failed`),t({code:B.FAILED,error:new rs(`Export failed with unknown error`)})},e=>{r(e),t({code:B.FAILED,error:e})}))}forceFlush(){return this._promiseQueue.awaitAll()}setMetrics(e){this._metrics=e}shutdown(){var e=this;return P(function*(){e._diagLogger.debug(`shutdown started`),yield e.forceFlush(),e._transport.shutdown()})()}};function ls(e,t){return new cs(e.transport,e.serializer,ss(),e.promiseHandler,e.metrics,t.timeout)}function us(e,t,n,r){return ls({transport:r,serializer:t,promiseHandler:as(e),metrics:n},{timeout:e.timeoutMillis})}let ds=new Map;var fs=class{constructor(e){var t;k(this,`inflight`,void 0),k(this,`exported`,void 0),k(this,`duration`,void 0),k(this,`standardAttrs`,void 0),k(this,`responseAttributesFromError`,void 0),k(this,`helper`,void 0);let{componentType:n,metricsHelper:r,meterProvider:i,url:a,responseAttributesFromError:o}=e;this.responseAttributesFromError=o;let s=i?i.getMeter(`@opentelemetry/otlp-exporter`,`0.221.0`):Se(),c=(t=ds.get(n))==null?0:t;if(ds.set(n,c+1),this.standardAttrs={"otel.component.type":n,"otel.component.name":`${n}/${c}`},a){let e=a;a.includes(`://`)||(e=`http://${a}`);try{let t=new URL(e);this.standardAttrs[`server.address`]=t.hostname;let n;t.port?n=Number(t.port):t.protocol===`http:`?n=80:t.protocol===`https:`&&(n=443),typeof n==`number`&&(this.standardAttrs[`server.port`]=n)}catch(e){}}this.helper=r,this.inflight=s.createUpDownCounter(`otel.sdk.exporter.${this.helper.name}.inflight`,{unit:`{${this.helper.name}}`,description:`The number of ${this.helper.name}s which were passed to the exporter, but that have not been exported yet (neither successful, nor failed).`}),this.exported=s.createCounter(`otel.sdk.exporter.${this.helper.name}.exported`,{unit:`{${this.helper.name}}`,description:`The number of ${this.helper.name}s for which the export has finished, either successful or failed.`}),this.duration=s.createHistogram(`otel.sdk.exporter.operation.duration`,{unit:`s`,description:`The duration of exporting a batch of telemetry records.`,advice:{explicitBucketBoundaries:[]}})}startExport(e){let t=this.helper.countItems(e),n=R();return this.inflight.add(t,this.standardAttrs),e=>{let r=R();this.inflight.add(-t,this.standardAttrs);let i=e?A(A({},this.standardAttrs),{},{"error.type":e instanceof Error?e.name:`export_failed`}):this.standardAttrs;this.exported.add(t,i);let a=A(A({},i),this.responseAttributesFromError(e)),o=qr(Kr(n,r))/1e3;this.duration.record(o,a)}}};let ps=49152,ms=0,hs=0;var gs=class e{constructor(e){this._config=e}static _compressRequest(e){return P(function*(){let t=new CompressionStream(`gzip`),n=t.writable.getWriter();n.write(e),n.close();let r=[],i=t.readable.getReader(),a=!1;for(;!a;){let e=yield i.read();e.value&&r.push(e.value),a=e.done}let o=new Uint8Array(r.reduce((e,t)=>e+t.length,0)),s=0;for(let e of r)o.set(e,s),s+=e.length;return o})()}send(e,t){return this._asyncSend(e,t)}shutdown(){}_asyncSend(t,n){var r=this;return P(function*(){let i=t,a=A({"Content-Type":`application/json`},r._config.headers),o,s;if(`timeout`in AbortSignal)o=AbortSignal.timeout(n);else{let e=new AbortController;o=e.signal,s=setTimeout(()=>{e.abort(new DOMException(`TimeoutError`,`TimeoutError`))},n)}let c=!1;try{if(r._config.compression===`gzip`){try{i=yield e._compressRequest(t)}catch(e){let t=e instanceof Error?e:Error(String(e));return T.warn(`Fetch transport gzip compression failed: ${t.message}`),{status:`failure`,error:t}}a[`Content-Encoding`]=`gzip`,a[`Content-Length`]=i.length.toString()}let n=ms+i.byteLength>ps;if(c=!n&&!(hs>=9),c)ms+=i.byteLength,hs++;else{let e=n?`inflight bytes (${ms} + ${i.byteLength}) would exceed ${ps}B budget`:`concurrent count (${hs}) at limit of 9`;T.debug(`Sending without keepalive: ${e}`)}let s=yield fetch(r._config.url,{method:`POST`,keepalive:c,headers:a,body:i,signal:o});if(s.ok)return{status:`success`};let l=Error(`${s.status} Fetch request failed`),u=`Fetch transport received HTTP ${s.status} (keepalive=${c})`;return s.status>=500?(T.debug(u),{status:`retryable`,error:l}):(T.warn(u),{status:`failure`,error:l})}catch(e){let t=e instanceof Error?e:Error(String(e)),n=t instanceof TypeError||t instanceof DOMException&&t.name===`TimeoutError`,r=`Fetch transport failed (keepalive=${c}): ${t.message}`;return n?T.debug(r):T.warn(r),{status:n?`retryable`:`failure`,error:t}}finally{s!==void 0&&clearTimeout(s),c&&(ms-=i.byteLength,hs--)}})()}};let _s=e=>new gs(e),vs=()=>Math.random()*40-20;var ys=class{constructor(e,t=new Vt){this._transport=e,this._perf=t}send(e,t){var n=this;return P(function*(){let r=n._perf.getNowMillis()+t,i=yield n._transport.send(e,t),a=5,o=1e3;for(;i.status===`retryable`&&a>0;){var s;a--;let t=Math.max(Math.min(o,5e3)+vs(),0);o*=1.5;let c=(s=i.retryInMillis)==null?t:s,l=r-n._perf.getNowMillis();if(c>l)return i;i=yield n._retry(e,l,c)}return i})()}shutdown(){this._transport.shutdown()}_retry(e,t,n){return new Promise((r,i)=>{setTimeout(()=>{this._transport.send(e,t).then(r,i)},n)})}};let bs=e=>{var t;return new ys(e.transport,(t=e.perf)==null?new Vt:t)},xs=(e,t,n,r)=>us(e,t,new fs({componentType:n,metricsHelper:r,url:e.url,meterProvider:void 0,responseAttributesFromError:()=>({})}),bs({transport:_s(e)}));var Ss=class extends ns{constructor(e){super(xs(e,qo,`otlp_http_log_exporter`,ho))}};let Cs=(e,t)=>`${po(e,t)}/v2/logs`;var ws=class extends Ss{constructor({appID:e,userID:t,embraceDataURL:n}){super(A(A({},uo),{},{headers:fo(e,t),url:Cs(e,n)}))}},Ts=class extends ns{constructor(e){super(xs(A(A({},e),{},{compression:`gzip`}),ts,`otlp_http_span_exporter`,mo))}};let Es=(e,t)=>`${po(e,t)}/v2/spans`;var Ds=class extends Ts{constructor({appID:e,userID:t,embraceDataURL:n}){super(A(A({},uo),{},{headers:fo(e,t),url:Es(e,n)}))}};let Os={samplingPct:100,networkSpansForwardingThreshold:0},ks=`embrace_remote_config`,As=(e,{osVersion:t,appVersion:n,deviceId:r},i)=>`${i||`https://a-${e}.config.emb-api.com`}/v2/config?appId=${e}&osVersion=${t}&appVersion=${n}&deviceId=${r}`,js=e=>{var t,n,r;let i={samplingPct:e.threshold};return e.network_span_forwarding!==void 0&&(i.networkSpansForwardingThreshold=e.network_span_forwarding.pct_enabled),((t=e.user_session)==null?void 0:t.max_duration_seconds)!==void 0&&(i.userSessionMaxDurationSeconds=e.user_session.max_duration_seconds),((n=e.user_session)==null?void 0:n.inactivity_timeout_seconds)!==void 0&&(i.userSessionInactivityTimeoutSeconds=e.user_session.inactivity_timeout_seconds),((r=e.user_session)==null?void 0:r.web_foreground_inactivity_timeout_seconds)!==void 0&&(i.userSessionForegroundInactivityTimeoutSeconds=e.user_session.web_foreground_inactivity_timeout_seconds),i};var Ms=class{constructor({appID:e,appVersion:t,deviceId:n,diag:r=T.createComponentLogger({namespace:`embrace-config-manager`}),storage:i,defaultConfig:a={},embraceConfigURL:o}){k(this,`_remoteConfigURL`,null),k(this,`_diag`,void 0),k(this,`_storage`,void 0),k(this,`_baseConfig`,void 0),k(this,`_sdkConfig`,void 0),k(this,`_etag`,null),e&&t&&n&&(this._remoteConfigURL=As(e,{appVersion:t,deviceId:n,osVersion:`1`},o)),this._diag=r,this._storage=i;let s=this._getRemoteConfigFromStorage();s&&(this._etag=s.etag),this._baseConfig=A(A({},Os),a),this._sdkConfig=A(A({},this._baseConfig),s?js(s.config):{})}setConfig(e){this._sdkConfig=A(A({},this._sdkConfig),e)}getConfig(){return this._sdkConfig}refreshRemoteConfig(){var e=this;return P(function*(){if(e._remoteConfigURL)try{let t=yield e._fetchRemoteConfig(e._remoteConfigURL);if(!t){e._diag.debug(`No changes in remote config, skipping update`);return}let[n,r]=t;e._storage.setItem(ks,JSON.stringify({config:n,etag:r})),e._sdkConfig=A(A({},e._baseConfig),js(n)),e._etag=r}catch(t){e._diag.warn(`Failed to refresh remote config: ${t instanceof Error?t.message:String(t)}`)}})()}_getRemoteConfigFromStorage(){let e=this._storage.getItem(ks);if(!e)return null;try{return JSON.parse(e)}catch(e){return this._diag.warn(`Failed to parse remote config from storage: ${e instanceof Error?e.message:String(e)}`),null}}_fetchRemoteConfig(e){var t=this;return P(function*(){let n=yield fetch(e,{headers:t._etag?{"If-None-Match":t._etag}:{}}),r=n.headers.get(`etag`);return n.status===304?null:n.ok?[yield n.json(),r]:(t._diag.warn(`Failed to fetch remote config from ${e}: ${n.statusText}`),null)})()}};let Ns={maxAllowed:{error_log:500,warning_log:200,info_log:100,exception:500,breadcrumb:100,session_property:100,span:1e3,network_request:1e4,user_timing_mark:200,user_timing_measure:100,element_timing:100,server_timing:50,soft_navigation:100},maxLength:{error_log:128,warning_log:128,info_log:128,exception:1024,breadcrumb:256,session_property_key:128,session_property_value:256,log_attribute_key:128,log_attribute_value:256,exception_attribute_key:128,exception_attribute_value:256},maxAttributes:{error_log:50,warning_log:50,info_log:50,exception:50}},Ps={info:`info_log`,warning:`warning_log`,error:`error_log`};var Fs=class{constructor({diag:e,maxAllowed:t,maxLength:n,maxAttributes:r}){k(this,`_diag`,void 0),k(this,`_diagnosticCounts`,{}),k(this,`_currentCount`,{exception:0,error_log:0,warning_log:0,info_log:0,breadcrumb:0,session_property:0,span:0,network_request:0,user_timing_mark:0,user_timing_measure:0,element_timing:0,server_timing:0,soft_navigation:0}),k(this,`_maxAllowed`,void 0),k(this,`_maxLength`,void 0),k(this,`_maxAttributes`,void 0),this._diag=e==null?T.createComponentLogger({namespace:`EmbraceLimitManager`}):e,this._maxAllowed=t,this._maxLength=n,this._maxAttributes=r}_dropIfMaxReached(e){return this._currentCount[e]>=this._maxAllowed[e]?(this._diag.warn(`disallowing ${e} because the maximum number of ${this._maxAllowed[e].toString()} has already been reached for this session`),this._incrDiagnosticCount(e,`drop`),!0):(this._currentCount[e]=(this._currentCount[e]||0)+1,!1)}truncateString(e,t){return t.length>this._maxLength[e]?(this._diag.warn(`truncating ${e} because it is longer than ${this._maxLength[e].toString()} characters: "${t}"`),this._incrDiagnosticCount(e,`truncate_string`),t.substring(0,this._maxLength[e])):t}_truncateAttributes(e,t,n,r){let i=Object.keys(t);i.length>this._maxAttributes[e]&&(this._diag.warn(`truncating ${e} attributes because there are more than ${this._maxAttributes[e].toString()} set`),this._incrDiagnosticCount(e,`truncate_attributes`));let a={};for(let s=0;s<Math.min(i.length,this._maxAttributes[e]);s++){var o;let e=this.truncateString(n,i[s]);a[e]=this.truncateString(r,((o=t[i[s]])==null?void 0:o.toString())||``)}return a}limitUserTimingEntry(e){let t=e===`mark`?`user_timing_mark`:`user_timing_measure`;return this._dropIfMaxReached(t)}limitElementTimingEntry(){return this._dropIfMaxReached(`element_timing`)}limitServerTimingEntry(){return this._dropIfMaxReached(`server_timing`)}limitSoftNavigationEntry(){return this._dropIfMaxReached(`soft_navigation`)}limitBreadcrumb(e){return this._dropIfMaxReached(`breadcrumb`)?`dropped`:{name:this.truncateString(`breadcrumb`,e)}}limitException(e,t){return this._dropIfMaxReached(`exception`)?`dropped`:{message:this.truncateString(`exception`,e),attributes:this._truncateAttributes(`exception`,t,`exception_attribute_key`,`exception_attribute_value`)}}limitLog(e,t,n){let r=Ps[t];return this._dropIfMaxReached(r)?`dropped`:{message:this.truncateString(r,e),attributes:this._truncateAttributes(r,n,`log_attribute_key`,`log_attribute_value`)}}limitUserSessionProperty(e,t){return this._dropIfMaxReached(`session_property`)?`dropped`:{key:this.truncateString(`session_property_key`,e),value:this.truncateString(`session_property_value`,t)}}dropReadableSpan(e){let t=e.attributes[`emb.type`]===`perf.network_request`?`network_request`:`span`;return this._dropIfMaxReached(t)}reset(){this._diagnosticCounts={},this._currentCount={exception:0,error_log:0,warning_log:0,info_log:0,breadcrumb:0,session_property:0,span:0,network_request:0,user_timing_mark:0,user_timing_measure:0,element_timing:0,server_timing:0,soft_navigation:0}}_incrDiagnosticCount(e,t){let n=`emb.app.applied_limit.${e}.${t}.count`;this._diagnosticCounts[n]=(this._diagnosticCounts[n]||0)+1}getDiagnosticCounts(){return this._diagnosticCounts}};let Is=()=>JSON.stringify(At._EmbraceFileBundleIDs||{});var Ls=class e{constructor({diag:e,perf:t,userSessionManager:n,limitManager:r,loggerProvider:i,visibilityDoc:a,storage:o}){k(this,`_diag`,void 0),k(this,`_perf`,void 0),k(this,`_logger`,void 0),k(this,`_userSessionManager`,void 0),k(this,`_limitManager`,void 0),k(this,`_visibilityDoc`,void 0),k(this,`_storage`,void 0);let s=i==null?dr:i;this._diag=e==null?T.createComponentLogger({namespace:`EmbraceLogManager`}):e,this._perf=t,this._logger=s.getLogger(`embrace-web-sdk-logs`),this._userSessionManager=n,this._limitManager=r,this._visibilityDoc=a,this._storage=o}_validateAttributes(e){return Object.prototype.toString.call(e)===`[object Object]`?e:(this._diag.warn(`attributes must be a plain object`,e),{})}static _logSeverityToSeverityNumber(e){switch(e){case`info`:return M.INFO;case`warning`:return M.WARN;default:return M.ERROR}}logException(t,{handled:n=!0,attributes:r={},timestamp:i=this._perf.getNowMillis(),handler:a=`manual`}={}){var o;let s=this._validateAttributes(r);n||this._userSessionManager.incrSessionPartCountForKey(`emb.unhandled_exceptions_count`);let c=(t==null||(o=t.constructor)==null?void 0:o.name)||typeof t,l=``,u=c,d=``,f=``;if(t instanceof Error)l=String(t.message||``).trim(),u=t.name||``,d=t.stack||``,f=t.cause?`present`:``;else if(t&&typeof t==`object`)try{l=JSON.stringify(t)}catch(e){l=String(t).trim()}else l=String(t).trim();let p=this._limitManager.limitException(l,s);p!==`dropped`&&this._logger.emit({timestamp:i,severityNumber:M.ERROR,severityText:`ERROR`,body:p.message,attributes:A(A({},p.attributes),{},{[O]:`sys.exception`,"emb.exception_handling":e._exceptionHandlingType(n,a),"emb.exception_cause":f,[Zt]:c,"exception.name":u,[Yt]:p.message,[Xt]:d,[xt]:Is(),[bt]:kt(this._visibilityDoc),"emb.exception_number":_t(this._storage,`embrace_exception_number`,this._diag)})})}message(e,t,{attributes:n={},includeStacktrace:r=!0,stacktrace:i}={}){if(typeof e!=`string`||!e.trim()){this._diag.warn(`Message must be a non-empty string`);return}if(![`info`,`warning`,`error`].includes(t)){this._diag.warn(`Severity must be info, warning, or error`);return}let a=this._validateAttributes(n);t===`error`&&this._userSessionManager.incrSessionPartCountForKey(`emb.error_log_count`);let o=``;t!==`info`&&(typeof i==`string`?o=i:r&&(o=Error().stack||``)),this._logMessage({message:e.trim(),severity:t,timestamp:this._perf.getNowMillis(),attributes:a,stack:o})}_logMessage({message:t,severity:n,timestamp:r,attributes:i={},stack:a}){let o=this._limitManager.limitLog(t,n,i);o!==`dropped`&&this._logger.emit({timestamp:r,severityNumber:e._logSeverityToSeverityNumber(n),severityText:n.toUpperCase(),body:o.message,attributes:A(A(A({},o.attributes),{},{[O]:`sys.log`},a?{"emb.stacktrace.js":a,[xt]:Is()}:{}),{},{[bt]:kt(this._visibilityDoc)})})}static _exceptionHandlingType(e,t){return e?`handled`:t===`global_exception`?`unhandled_error`:t===`promise_rejection`?`unhandled_rejection`:`unhandled`}},Rs=class{constructor({useDocumentTitleAsPageLabel:e=!0,titleDocument:t=window.document,diag:n,navigationHost:r=window,userSessionManager:i,perf:a=new Vt}={}){var o;k(this,`_currentRoute`,null),k(this,`_currentPageId`,null),k(this,`_pageLabel`,null),k(this,`_titleDocument`,void 0),k(this,`_useDocumentTitleAsPageLabel`,void 0),k(this,`_routeChangedListeners`,[]),k(this,`_diag`,void 0),k(this,`_navigationHost`,void 0),k(this,`_userSessionManager`,void 0),k(this,`_perf`,void 0),k(this,`getCurrentPageId`,()=>this._currentPageId),k(this,`getCurrentRoute`,()=>this._currentRoute),k(this,`setPageLabel`,e=>{this._pageLabel=e}),k(this,`getPageLabel`,()=>this._pageLabel||(!this._useDocumentTitleAsPageLabel||!this._titleDocument?null:this._titleDocument.title)),k(this,`setCurrentRoute`,e=>{(!this._currentRoute||this._currentRoute.url!==e.url)&&(this._currentPageId=ht()),this._currentRoute=e,this._pageLabel=e.label?e.label:null;for(let t of this._routeChangedListeners)try{t(e)}catch(e){this._diag.warn(`Error while executing route changed listener`,e)}}),k(this,`clearCurrentRoute`,()=>{this._currentRoute=null,this._currentPageId=null,this._pageLabel=null}),k(this,`addRouteChangedListener`,e=>(this._routeChangedListeners.push(e),()=>{let t=this._routeChangedListeners.indexOf(e);t!==-1&&this._routeChangedListeners.splice(t,1)})),k(this,`_onSoftNavigation`,e=>{var t;e.from.url!==this._navigationHost.location.href&&(Bt(this._perf.epochMillisFromOrigin(e.timeStamp)),(t=this._userSessionManager)==null||t.rolloverSessionPartInternal({endReason:`web_soft_navigation`,startReason:`web_soft_navigation`}),this._setInitialRouteFromCurrentLocation())}),k(this,`_setInitialRouteFromCurrentLocation`,()=>{let e=this._navigationHost.location.pathname;this.setCurrentRoute({path:e,url:e})}),this._useDocumentTitleAsPageLabel=e,this._titleDocument=t,this._diag=n==null?T.createComponentLogger({namespace:`EmbracePageManager`}):n,this._navigationHost=r,this._userSessionManager=i,this._perf=a,(o=this._navigationHost.navigation)==null||o.addEventListener(`currententrychange`,this._onSoftNavigation),this._setInitialRouteFromCurrentLocation()}},zs=class{constructor({dynamicConfigManager:e,deviceId:t,blockNetworkSpanForwarding:n}){k(this,`_dynamicConfigManager`,void 0),k(this,`_deviceId`,void 0),k(this,`_blockNetworkSpanForwarding`,void 0),this._dynamicConfigManager=e,this._deviceId=t,this._blockNetworkSpanForwarding=n}isSDKEnabled(){let e=this._dynamicConfigManager.getConfig();return jt(this._deviceId,e.samplingPct)}isNetworkSpanForwardingEnabled(){if(this._blockNetworkSpanForwarding)return!1;let e=this._dynamicConfigManager.getConfig();return jt(this._deviceId,e.networkSpansForwardingThreshold)}},Bs=class{constructor(e){k(this,`_span`,void 0),this._span=e}get attributes(){return this._span.attributes}addEvent(e,t,n){return this._span.addEvent(e,t,n),this}addLink(e){return this._span.addLink(e),this}addLinks(e){return this._span.addLinks(e),this}end(e){this._span.end(e)}isRecording(){return this._span.isRecording()}recordException(e,t){this._span.recordException(e,t)}setAttribute(e,t){return this._span.setAttribute(e,t),this}setAttributes(e){return this._span.setAttributes(e),this}removeAttribute(e){let t=this._span.attributes,{[e]:n}=t,r=Ut(t,[e].map(It));return this._span.attributes=r,this}setStatus(e){return this._span.setStatus(e),this}spanContext(){return this._span.spanContext()}updateName(e){return this._span.updateName(e),this}fail(e={code:`failure`}){e.code&&this._span.setAttribute(`emb.error_code`,e.code.toUpperCase()),this._span.end(e.endTime)}},Vs=class{constructor({tracerProvider:e}={}){k(this,`_tracer`,void 0),k(this,`setSpan`,D.setSpan);let t=e==null?D:e;this._tracer=t.getTracer(`embrace-web-sdk-traces`)}startSpan(e,t={},n){t.attributes=t.attributes?t.attributes:{},t.attributes[O]=`perf`;let r=t.parentSpan?D.setSpan(w.active(),t.parentSpan):n;return new Bs(this._tracer.startSpan(e,t,r))}getSpan(e){let t=D.getSpan(e);if(t)return new Bs(t)}};let Hs=`embrace_user_id`,Us=`embrace_external_user_id`,Ws=e=>typeof e==`string`&&e.length===32;var Gs=class{constructor({diag:e,storage:t}){k(this,`_diag`,void 0),k(this,`_storage`,void 0),k(this,`_embraceUserId`,null),this._diag=e==null?T.createComponentLogger({namespace:`EmbraceUserManager`}):e,this._storage=t,this._initialSetup()}getEmbraceUserId(){return this._embraceUserId||this._generateNewEmbraceUserId()}setEmbraceUserId(e){this._embraceUserId=e,this._storage.setItem(Hs,e)}clearEmbraceUserId(){this._embraceUserId=null,this._storage.removeItem(Hs)}_initialSetup(){let e=this._storage.getItem(Hs);e?Ws(e)?this._embraceUserId=e:(this._diag.warn(`Invalid embrace user id, generating a new one`),this.clearEmbraceUserId()):this._diag.debug(`No existing user found in storage, creating a new one`),this._embraceUserId||(this._embraceUserId=this._generateNewEmbraceUserId())}_generateNewEmbraceUserId(){let e=ht();return this.setEmbraceUserId(e),e}getUserId(){return this._storage.getItem(Us)}setUserId(e){this._storage.setItem(Us,e)}clearUserId(){this._storage.removeItem(Us)}};let Ks=`embrace_user_session_state`,qs=`embrace_permanent_properties`,Js=`embrace_last_end_user_session_ts`,Ys=new Set([`user_session_ended`,`web_foreground_inactivity`]),Xs=1800,Zs=1800,Qs=[`keydown`,`mousedown`,`mousemove`,`scroll`],$s=e=>e.visibilityState===`visible`&&e.hasFocus(),ec=({target:e,visibilityDoc:t,activityEvents:n,onActivity:r,onVisibilityChange:i,onFocus:a,onBlur:o})=>{var s;for(let t of n)e.addEventListener(t,r);(s=t.addEventListener)==null||s.call(t,`visibilitychange`,i),e.addEventListener(`focus`,a),e.addEventListener(`blur`,o)},tc=({target:e,visibilityDoc:t,activityEvents:n,onActivity:r,onVisibilityChange:i,onFocus:a,onBlur:o})=>{var s;for(let t of n)e.removeEventListener(t,r);(s=t.removeEventListener)==null||s.call(t,`visibilitychange`,i),e.removeEventListener(`focus`,a),e.removeEventListener(`blur`,o)},nc=(e,t)=>t<e.userSessionStartTs||t>=e.userSessionMaxEndTs||e.inactivityDeadlineTs!==null&&t>=e.inactivityDeadlineTs,rc=({now:e,previousUserSessionId:t,userSessionMaxDurationSeconds:n,userSessionInactivityTimeoutSeconds:r,userSessionForegroundInactivityTimeoutSeconds:i,userSessionNumber:a})=>({schemaVersion:1,userSessionId:ht(),previousUserSessionId:t,userSessionStartTs:e,userSessionMaxEndTs:e+n*1e3,userSessionNumber:a,userSessionPartIndex:0,userSessionMaxDurationSeconds:n,userSessionInactivityTimeoutSeconds:r,userSessionForegroundInactivityTimeoutSeconds:i,inactivityDeadlineTs:null,userSessionProperties:{}}),ic=e=>typeof e==`object`&&!!e&&e.schemaVersion===1,ac=(e,t)=>{let n=e.getItem(Ks);if(!n)return null;try{let e=JSON.parse(n);if(!ic(e))throw Error(`stored user session state failed structural validation`);return e}catch(n){return t.error(`User session state in storage is corrupt; discarding it`,n),e.removeItem(Ks),null}},oc=(e,t)=>{let n=e.getItem(qs);if(!n)return{};try{let e=JSON.parse(n);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`permanent properties blob is not a plain object`);let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return t}catch(n){return t.error(`Permanent properties in storage are corrupt; discarding`,n),e.removeItem(qs),{}}},sc=(e,t)=>Object.keys(t).length===0?e.removeItem(qs):e.setItem(qs,JSON.stringify(t));var cc=class{constructor({dynamicConfigManager:e,diag:t,perf:n,visibilityDoc:r,storage:i,limitManager:a,target:o=window,activityThrottleMs:s=3e4,activityEvents:c=Qs}){k(this,`_state`,null),k(this,`_previousUserSessionId`,null),k(this,`_maxDurationTimeout`,null),k(this,`_permanentProperties`,{}),k(this,`_hasStoredState`,!1),k(this,`_activeSessionPartId`,null),k(this,`_sessionPartHistory`,[]),k(this,`_currentSessionPartNumber`,null),k(this,`_sessionPartSpan`,null),k(this,`_activeSessionPartCounts`,null),k(this,`_coldStart`,!0),k(this,`_nextSessionPartCounts`,{}),k(this,`_sdkStartupDuration`,0),k(this,`_sessionPartStartedListeners`,[]),k(this,`_sessionPartEndedListeners`,[]),k(this,`_tracer`,void 0),k(this,`_diag`,void 0),k(this,`_perf`,void 0),k(this,`_storage`,void 0),k(this,`_visibilityDoc`,void 0),k(this,`_limitManager`,void 0),k(this,`_dynamicConfigManager`,void 0),k(this,`_target`,void 0),k(this,`_activityEvents`,void 0),k(this,`_onActivityThrottled`,void 0),k(this,`_sessionPartInactivityTimer`,null),k(this,`_onActivity`,()=>{try{if(!$s(this._visibilityDoc))return;if(this._activeSessionPartId===null){this.startSessionPartInternal({reason:`web_activity`});return}this._startSessionPartInactivityTimer()}catch(e){this._diag.warn(`Error handling activity event`,e)}}),k(this,`_onVisibilityChange`,()=>{this._handleEngagementTransition(`visibilitychange`)}),k(this,`_onFocus`,()=>{this._handleEngagementTransition(`focus`)}),k(this,`_onBlur`,()=>{this._handleEngagementTransition(`blur`)}),k(this,`_onSessionPartInactivity`,()=>{this._sessionPartInactivityTimer=null;try{if(this._activeSessionPartId===null)return;this._diag.debug(`inactivity timer fired; ending current part and user session`),this.endSessionPartInternal({reason:`web_foreground_inactivity`,userSessionEndReason:`inactivity`})}catch(e){this._diag.warn(`Error handling inactivity timer`,e)}}),this._diag=t==null?T.createComponentLogger({namespace:`EmbraceUserSessionManager`}):t,this._perf=n,this._visibilityDoc=r,this._storage=i,this._limitManager=a,this._dynamicConfigManager=e,this._permanentProperties=oc(this._storage,this._diag),this._tracer=D.getTracer(`embrace-web-sdk-session-parts`),this._target=o,this._activityEvents=c,this._onActivityThrottled=vn(this._onActivity,s)}_resolveUserSessionDurations(){let e=this._dynamicConfigManager.getConfig(),t=dt({diag:this._diag,value:e.userSessionMaxDurationSeconds,defaultValue:43200,min:3600,max:86400}),n=dt({diag:this._diag,value:e.userSessionInactivityTimeoutSeconds,defaultValue:Xs,min:30,max:86400}),r=dt({diag:this._diag,value:e.userSessionForegroundInactivityTimeoutSeconds,defaultValue:Zs,min:30,max:86400}),i=n<=t,a=r<=t;return i||this._diag.warn(`userSessionInactivityTimeoutSeconds (${n.toString()}s) exceeds userSessionMaxDurationSeconds (${t.toString()}s); falling back to default inactivity timeout (1800s).`),a||this._diag.warn(`userSessionForegroundInactivityTimeoutSeconds (${r.toString()}s) exceeds userSessionMaxDurationSeconds (${t.toString()}s); falling back to default foreground inactivity timeout (1800s).`),{userSessionMaxDurationSeconds:t,userSessionInactivityTimeoutSeconds:i?n:Xs,userSessionForegroundInactivityTimeoutSeconds:a?r:Zs}}setTracerProvider(e){this._tracer=e.getTracer(`embrace-web-sdk-session-parts`),ec({target:this._target,visibilityDoc:this._visibilityDoc,activityEvents:this._activityEvents,onActivity:this._onActivityThrottled,onVisibilityChange:this._onVisibilityChange,onFocus:this._onFocus,onBlur:this._onBlur});let{state:t,created:n}=this._loadOrCreateUserSessionState(this._perf.getNowMillis());this._state=t,n&&this._storeState()}recordSDKStartupDuration(e){this._sdkStartupDuration=Math.ceil(e)}getUserSessionId(){var e,t;return(e=(t=this._state)==null?void 0:t.userSessionId)==null?null:e}getPreviousUserSessionId(){var e,t;return(e=(t=this._state)==null?void 0:t.previousUserSessionId)==null?this._previousUserSessionId:e}getUserSessionStartTime(){var e,t;return(e=(t=this._state)==null?void 0:t.userSessionStartTs)==null?null:e}getUserSessionAttributes(){var e,t;if(!this._state)return null;let n=(e=this.getPreviousUserSessionId())==null?``:e;return{[Dt]:this._state.userSessionId,[Ot]:n,"emb.user_session_number":this._state.userSessionNumber,"emb.user_session_part_index":this._state.userSessionPartIndex,"emb.session_part_number":(t=this._currentSessionPartNumber)==null?0:t,"emb.user_session_start_ts":this._state.userSessionStartTs,"emb.user_session_max_duration_seconds":this._state.userSessionMaxDurationSeconds,"emb.user_session_inactivity_timeout_seconds":this._state.userSessionInactivityTimeoutSeconds,"emb.user_session_foreground_inactivity_timeout_seconds":this._state.userSessionForegroundInactivityTimeoutSeconds}}endUserSession(){if(!this._state){this._diag.debug(`Trying to end user session, but there is no active session. This is a no-op.`);return}let e=this._perf.getNowMillis(),t=this._storage.getItem(Js),n=t===null?NaN:Number(t);if(Number.isFinite(n)&&e-n<5e3){this._diag.warn(`endUserSession called within cooldown period, ignoring.`);return}this._rolloverUserSession(`manual`),this._storage.setItem(Js,String(e))}getSessionPartId(){return this._activeSessionPartId}getSessionPartIdAt(e){for(let t=this._sessionPartHistory.length-1;t>=0;t--)if(this._sessionPartHistory[t].startTimeEpochMillis<=e)return this._sessionPartHistory[t].id;return this.getSessionPartId()}getSessionPartSpan(){return this._sessionPartSpan}startSessionPartInternal({reason:e,timestamp:t}){if(this._sessionPartSpan){this._diag.warn(`startSessionPartInternal called while a part is active (reason: ${e}); ignoring`);return}if(kt(this._visibilityDoc)===`background`||!this._visibilityDoc.hasFocus()){this._diag.debug(`skipping session part start (reason: ${e}) because the tab is not engaged`);return}let n=ht(),r=this._nextSessionPartCounts;this._beginUserSessionForPartStart();let i=A(A({},this.getUserSessionAttributes()),{},{[O]:`ux.session_part`,[bt]:`foreground`,[Et]:n,"emb.session_part_start_reason":e,"emb.cold_start":this._coldStart},r);this._activeSessionPartId=n;let a;try{a=new Bs(this._tracer.startSpan(`emb-session-part`,{attributes:i,startTime:t}))}catch(e){this._activeSessionPartId=null,this._diag.error(`Error starting session part span`,e);return}this._activeSessionPartCounts={},this._nextSessionPartCounts={},this._sessionPartSpan=a,this._sessionPartHistory.push({id:n,startTimeEpochMillis:t==null?this._perf.getNowMillis():t}),this._startSessionPartInactivityTimer(),this._fireListeners(this._sessionPartStartedListeners,`started`,{reason:e})}endSessionPartInternal({reason:e,userSessionEndReason:t,timestamp:n}){if(!this._sessionPartSpan){this._diag.debug(`trying to end a session part, but there is no session part in progress. This is a no-op.`);return}this._clearSessionPartInactivityTimer();let r=Ys.has(e),i=this._perf.getNowMillis(),a=n==null?i:n,o=this._sessionPartSpan;try{let n=A(A(A({"emb.session_part_end_reason":e},this._activeSessionPartCounts),this._limitManager.getDiagnosticCounts()),{},{"emb.sdk_startup_duration":this._sdkStartupDuration});this._coldStart&&(n[`emb.page_load`]=this._visibilityDoc.readyState===`complete`),r&&(n[`emb.is_final_session_part`]=1,t&&(n[`emb.user_session_termination_reason`]=t));let i={};for(let[e,t]of Object.entries(this.getSessionPartProperties()))i[`emb.properties.`+e]=t;try{o.setAttributes(A(A({},i),n))}catch(e){this._diag.warn(`Error setting end attributes on session part span; ending span without them`,e)}}finally{this._fireListeners(this._sessionPartEndedListeners,`ended`,void 0);try{o.end(a)}catch(e){this._diag.warn(`Error ending session part span`,e)}this._sessionPartSpan=null,this._coldStart=!1,this._activeSessionPartId=null,this._activeSessionPartCounts=null,this._currentSessionPartNumber=null,this._limitManager.reset()}if(r){var s,c;this._previousUserSessionId=(s=(c=this._state)==null?void 0:c.userSessionId)==null?null:s,this._state=null,this._storage.removeItem(Ks),this._clearMaxDurationTimer(),this._sessionPartHistory=[]}else this._continueUserSessionAfterPartEnd(i)}addBreadcrumb(e){if(!this._sessionPartSpan){this._diag.debug(`trying to add breadcrumb, but there is no session part in progress. This is a no-op.`);return}let t=this._limitManager.limitBreadcrumb(e);t!==`dropped`&&this._sessionPartSpan.addEvent(`emb-breadcrumb`,{message:t.name},this._perf.getNowMillis())}addProperty(e,t,n){let r=this._limitManager.limitUserSessionProperty(e,t);if(r===`dropped`)return;let i=r.key,a=r.value;if((n==null?void 0:n.lifespan)===`permanent`){let e=A(A({},this._permanentProperties),{},{[i]:a});if(!sc(this._storage,e)){this._diag.warn(`Storage unavailable; rejecting permanent property write.`);return}this._permanentProperties=e,this._removeFromUserSessionProperties(i);return}let{state:o}=this._loadOrCreateUserSessionState(this._perf.getNowMillis());this._state=A(A({},o),{},{userSessionProperties:A(A({},o.userSessionProperties),{},{[i]:a})}),this._storeState()||(this._state=o,this._diag.warn(`Storage unavailable; rejecting user-session property write.`))}removeProperty(e){let t=this._limitManager.truncateString(`session_property_key`,e);this._removeFromPermanentProperties(t),this._removeFromUserSessionProperties(t)}getSessionPartProperties(){var e,t;return A(A({},this._permanentProperties),(e=(t=this._state)==null?void 0:t.userSessionProperties)==null?{}:e)}incrSessionPartCountForKey(e){if(!this._sessionPartSpan||!this._activeSessionPartCounts){this._diag.debug(`trying to increment a count for the active session part, but there is no session part in progress. This is a no-op.`);return}this._activeSessionPartCounts[e]=(this._activeSessionPartCounts[e]||0)+1}incrNextSessionPartCountForKey(e){this._nextSessionPartCounts[e]=(this._nextSessionPartCounts[e]||0)+1}addSessionPartStartedListener(e){return this._addListener(this._sessionPartStartedListeners,e)}addSessionPartEndedListener(e){return this._addListener(this._sessionPartEndedListeners,e)}getSessionId(){return this.getUserSessionId()}getPreviousSessionId(){return null}getSessionStartTime(){return this.getUserSessionStartTime()}endSessionSpan(){this.endUserSession()}startSessionSpan(){}getSessionSpan(){return this.getSessionPartSpan()}currentSessionAsReadableSpan(){return null}addSessionStartedListener(e){return()=>{}}addSessionEndedListener(e){return()=>{}}_loadOrCreateUserSessionState(e){let t=ac(this._storage,this._diag);!t&&!this._hasStoredState&&this._state&&(t=this._state);let n=!1;if(!t||nc(t,e)){t&&(this._previousUserSessionId=t.userSessionId);let r=_t(this._storage,`embrace_user_session_number`,this._diag);this._coldStart||this._dynamicConfigManager.refreshRemoteConfig();let{userSessionMaxDurationSeconds:i,userSessionInactivityTimeoutSeconds:a,userSessionForegroundInactivityTimeoutSeconds:o}=this._resolveUserSessionDurations();t=rc({now:e,previousUserSessionId:this._previousUserSessionId,userSessionMaxDurationSeconds:i,userSessionInactivityTimeoutSeconds:a,userSessionForegroundInactivityTimeoutSeconds:o,userSessionNumber:r}),n=!0}return(n||this._maxDurationTimeout===null)&&this._setupMaxDurationTimer(t,e),{state:t,created:n}}_beginUserSessionForPartStart(){let e=this._perf.getNowMillis(),{state:t}=this._loadOrCreateUserSessionState(e);this._currentSessionPartNumber=_t(this._storage,`embrace_session_part_number`,this._diag),this._state=A(A({},t),{},{userSessionPartIndex:t.userSessionPartIndex+1,inactivityDeadlineTs:null}),this._storeState()}_continueUserSessionAfterPartEnd(e){if(!this._state){this._clearMaxDurationTimer();return}if(this._hasStoredState&&this._storage.getItem(`embrace_user_session_state`)===null){this._previousUserSessionId=this._state.userSessionId,this._state=null,this._clearMaxDurationTimer();return}this._state=A(A({},this._state),{},{inactivityDeadlineTs:e+this._state.userSessionInactivityTimeoutSeconds*1e3}),this._storeState()}_rolloverUserSession(e){var t,n;if(this._sessionPartSpan){let t=this._perf.getNowMillis();this.endSessionPartInternal({reason:`user_session_ended`,userSessionEndReason:e,timestamp:t}),this.startSessionPartInternal({reason:`user_session_rollover`,timestamp:t});return}this._previousUserSessionId=(t=(n=this._state)==null?void 0:n.userSessionId)==null?null:t,this._state=null,this._storage.removeItem(Ks),this._clearMaxDurationTimer()}rolloverSessionPartInternal({endReason:e,startReason:t,timestamp:n}){if(!this._sessionPartSpan)return;let r=n==null?this._perf.getNowMillis():n;this.endSessionPartInternal({reason:e,timestamp:r}),this.startSessionPartInternal({reason:t,timestamp:r})}_setupMaxDurationTimer(e,t){this._clearMaxDurationTimer();let n=e.userSessionMaxEndTs-t;n<=0||(this._maxDurationTimeout=setTimeout(()=>{this._maxDurationTimeout=null,this._rolloverUserSession(`max_duration_reached`)},n))}_clearMaxDurationTimer(){this._maxDurationTimeout!==null&&(clearTimeout(this._maxDurationTimeout),this._maxDurationTimeout=null)}_shutdown(){tc({target:this._target,visibilityDoc:this._visibilityDoc,activityEvents:this._activityEvents,onActivity:this._onActivityThrottled,onVisibilityChange:this._onVisibilityChange,onFocus:this._onFocus,onBlur:this._onBlur}),this._clearSessionPartInactivityTimer(),this._clearMaxDurationTimer()}_handleEngagementTransition(e){try{let t=$s(this._visibilityDoc),n=this._activeSessionPartId!==null;if(!t&&n){this._diag.debug(`tab disengaged via ${e}; ending current part`),this.endSessionPartInternal({reason:`background`});return}if(t&&!n){this._diag.debug(`tab engaged via ${e}; starting new part`),this.startSessionPartInternal({reason:`foreground`});return}t&&n&&this._startSessionPartInactivityTimer()}catch(e){this._diag.warn(`Error handling engagement change`,e)}}_startSessionPartInactivityTimer(){this._clearSessionPartInactivityTimer(),this._state&&(this._sessionPartInactivityTimer=setTimeout(this._onSessionPartInactivity,this._state.userSessionForegroundInactivityTimeoutSeconds*1e3))}_clearSessionPartInactivityTimer(){this._sessionPartInactivityTimer!==null&&(clearTimeout(this._sessionPartInactivityTimer),this._sessionPartInactivityTimer=null)}_addListener(e,t){return e.push(t),()=>{let n=e.indexOf(t);n!==-1&&e.splice(n,1)}}_fireListeners(e,t,n){for(let r of e)try{r(n)}catch(e){this._diag.warn(`Error while executing session part ${t} listener`,e)}}_storeState(){if(!this._state)return!1;let e=this._storage.setItem(Ks,JSON.stringify(this._state));return e&&(this._hasStoredState=!0),e}_removeFromPermanentProperties(e){if(!(e in this._permanentProperties))return;let t=A({},this._permanentProperties);delete t[e],this._permanentProperties=t,sc(this._storage,t)}_removeFromUserSessionProperties(e){if(!this._state||!(e in this._state.userSessionProperties))return;let t=A({},this._state.userSessionProperties);delete t[e],this._state=A(A({},this._state),{},{userSessionProperties:t}),this._storeState()}},lc=class{constructor({urlDocument:e=window.document}={}){k(this,`_urlDocument`,void 0),this._urlDocument=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){e.attributes[`browser.url.full`]||e.setAttribute(St,this._urlDocument.URL)}shutdown(){return Promise.resolve(void 0)}},uc=class{constructor({urlDocument:e=window.document}={}){k(this,`_urlDocument`,void 0),this._urlDocument=e}forceFlush(){return Promise.resolve(void 0)}onEnding(e){e.attributes[`browser.url.full`]||(e.attributes[St]=this._urlDocument.URL)}onStart(){}onEnd(){}shutdown(){return Promise.resolve(void 0)}},dc=class{constructor({urlDocument:e=window.document}={}){k(this,`_urlDocument`,void 0),this._urlDocument=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){e.attributes[`emb.type`]||e.setAttribute(O,`sys.log`),e.attributes[`url.full`]||e.setAttribute(j,this._urlDocument.URL)}shutdown(){return Promise.resolve(void 0)}},fc=class{forceFlush(){return Promise.resolve(void 0)}onEnding(e){hn(e)&&(e.attributes[O]=`perf.network_request`)}onStart(){}onEnd(){}shutdown(){return Promise.resolve(void 0)}};let pc=(e,t)=>`emb.${t===`current`?`export_failed`:`previous_export_failed`}.${e}`;var mc=class{constructor({exporter:e,limitManager:t,userSessionManager:n,diag:r=T.createComponentLogger({namespace:`EmbraceSessionPartBatchedSpanProcessor`})}){k(this,`_shutdownOnce`,void 0),k(this,`_pendingSpans`,[]),k(this,`_exporter`,void 0),k(this,`_limitManager`,void 0),k(this,`_userSessionManager`,void 0),k(this,`_diag`,void 0),k(this,`_shutdown`,()=>this._exporter.shutdown()),this._diag=r,this._exporter=e,this._shutdownOnce=new Ii(this._shutdown,this),this._limitManager=t,this._userSessionManager=n}forceFlush(){return this._diag.debug(`forceFlush called for EmbraceSessionPartBatchedSpanProcessor. This is a no op`),Promise.resolve(void 0)}onEnd(e){if(this._shutdownOnce.isCalled){this._diag.debug(`span ended after processor shutdown. Ignoring span.`);return}if(gn(e))this._diag.debug(`session part span ended. Exporting all pending spans.`),this._exportSpans([e,...this._pendingSpans]),this._pendingSpans=[];else{if(this._diag.debug(`non-session-part span ended. Adding to pending spans queue.`),this._limitManager.dropReadableSpan(e))return;this._pendingSpans.push(e)}}_exportSpans(e){Ri._export(this._exporter,e).then(e=>{if(e.code===B.FAILED){var t;let n=((t=e.error)==null?void 0:t.message)||`unknown error`,r=`unknown`;n===`Concurrent export limit reached`?r=`concurrent_limit`:n===`Fetch request errored`&&(r=`fetch_error`),this._userSessionManager.incrSessionPartCountForKey(pc(r,`current`)),this._userSessionManager.incrNextSessionPartCountForKey(pc(r,`previous`)),this._diag.error(`spans failed to export: ${n}`)}}).catch(e=>{let t=`unknown error`;e&&e instanceof Error?t=e.message:typeof e==`string`&&(t=e),this._userSessionManager.incrSessionPartCountForKey(pc(`unknown`,`current`)),this._userSessionManager.incrNextSessionPartCountForKey(pc(`unknown`,`previous`)),this._diag.error(`spans failed to export: ${t}`)})}onStart(){}shutdown(){return this._shutdownOnce.call()}},hc=class{constructor({attributeScrubbers:e}){k(this,`_attributeScrubbers`,void 0),this._attributeScrubbers=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){this._attributeScrubbers.forEach(t=>{let n=e.attributes[t.key];n&&typeof n==`string`&&e.setAttribute(t.key,t.scrub(n))})}shutdown(){return Promise.resolve(void 0)}},gc=class{constructor({pageManager:e}){k(this,`_pageManager`,void 0),this._pageManager=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){if(!e.attributes[`app.surface.name`]||!e.attributes[`app.surface.id`]){let t=this._pageManager.getCurrentRoute();t&&(e.setAttribute(Ct,t.path),e.setAttribute(wt,this._pageManager.getCurrentPageId()))}let t=this._pageManager.getPageLabel();t&&!e.attributes[`app.surface.label`]&&e.setAttribute(Tt,t)}shutdown(){return Promise.resolve(void 0)}},_c=class{constructor({pageManager:e}){k(this,`_pageManager`,void 0),this._pageManager=e}forceFlush(){return Promise.resolve(void 0)}onEnding(e){if(!e.attributes[`app.surface.name`]||!e.attributes[`app.surface.id`]){let t=this._pageManager.getCurrentRoute(),n=this._pageManager.getCurrentPageId();t&&n&&(e.attributes[Ct]=t.path,e.attributes[wt]=n)}let t=this._pageManager.getPageLabel();t&&!e.attributes[`app.surface.label`]&&(e.attributes[Tt]=t)}onStart(){}onEnd(){}shutdown(){return Promise.resolve(void 0)}};let vc=`log.record.uid`,yc=`user.id`;var bc=class{constructor({buffer:e}){k(this,`_buffer`,void 0),this._buffer=e}onEmit(e){try{let t=e.attributes[vc];typeof t==`string`&&t.length>0&&this._buffer.record({kind:`log`,id:t,startTime:qr(e.hrTime),type:e.attributes[O]})}catch(e){T.error(`failed to record log for signal correlation`,e)}}forceFlush(){return Promise.resolve(void 0)}shutdown(){return Promise.resolve(void 0)}},xc=class{constructor({buffer:e}){k(this,`_buffer`,void 0),this._buffer=e}forceFlush(){return Promise.resolve(void 0)}onStart(e){try{if(_n(e)||gn(e))return;this._buffer.record({kind:`span`,id:e.spanContext().spanId,startTime:qr(e.startTime),type:e.attributes[O]})}catch(e){T.error(`failed to record span for correlation`,e)}}onEnd(){}shutdown(){return Promise.resolve(void 0)}},Sc=class{constructor({attributeScrubbers:e}){k(this,`_attributeScrubbers`,void 0),this._attributeScrubbers=e}forceFlush(){return Promise.resolve(void 0)}onEnding(e){this._attributeScrubbers.forEach(t=>{let n=e.attributes[t.key];n&&typeof n==`string`&&(e.attributes[t.key]=t.scrub(n))})}onStart(){}onEnd(){}shutdown(){return Promise.resolve(void 0)}},Cc=class{constructor({userManager:e}){k(this,`_userManager`,void 0),this._userManager=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){this._userManager.getUserId()&&e.setAttributes({[yc]:this._userManager.getUserId()})}shutdown(){return Promise.resolve(void 0)}},wc=class{constructor({userSessionManager:e}){k(this,`_userSessionManager`,void 0),this._userSessionManager=e}forceFlush(){return Promise.resolve(void 0)}onEmit(e){var t,n,r,i,a,o;let s=(t=(n=e.attributes[`emb.user_session_id`])==null?this._userSessionManager.getUserSessionId():n)==null?``:t,c=(r=(i=e.attributes[`emb.user_session_previous_id`])==null?this._userSessionManager.getPreviousUserSessionId():i)==null?``:r,l=(a=(o=e.attributes[`emb.session_part_id`])==null?this._userSessionManager.getSessionPartId():o)==null?``:a;e.setAttributes({[vc]:ht(),[Dt]:s,[Ot]:c,[Et]:l})}shutdown(){return Promise.resolve(void 0)}},Tc=class{constructor({userManager:e}){k(this,`_userManager`,void 0),this._userManager=e}forceFlush(){return Promise.resolve(void 0)}onEnding(e){let t=this._userManager.getUserId();t&&(e.attributes[yc]=t)}onStart(){}onEnd(){}shutdown(){return Promise.resolve(void 0)}},Ec=class{constructor({maxAgeMillis:e=6e4,maxEntries:t=4096}={}){k(this,`_maxAgeMillis`,void 0),k(this,`_maxEntries`,void 0),k(this,`_entries`,[]),k(this,`_latestStartTime`,0),this._maxAgeMillis=e,this._maxEntries=t}record(e){this._entries.push(e),e.startTime>this._latestStartTime&&(this._latestStartTime=e.startTime),this._evict()}collectWindow(e,t){let n=this._entries.filter(n=>n.startTime>=e&&n.startTime<=t),r=n.filter(e=>e.kind===`span`),i=n.filter(e=>e.kind===`log`);return{spanIds:r.map(e=>e.id),spanTypes:r.map(e=>{var t;return(t=e.type)==null?``:t}),logIds:i.map(e=>e.id),logTypes:i.map(e=>{var t;return(t=e.type)==null?``:t})}}_evict(){let e=this._latestStartTime-this._maxAgeMillis;for(;this._entries.length>0&&this._entries[0].startTime<e;)this._entries.shift();for(;this._entries.length>this._maxEntries;)this._entries.shift()}},Dc=class extends li{inject(e,t,n){super.inject(e,t,n);let r=D.getSpan(e);if(r){let e=t instanceof Headers?t.get(`traceparent`):Ce.get(t,`traceparent`);e&&r.setAttribute(`emb.w3c_traceparent`,e)}}};let Oc=`2.26.0`,kc=`embrace-web-sdk`,Ac=`embrace_app_instance_id`,jc=(e,t)=>{let n=e.getItem(Ac);if(n)return n;t.debug(`No existing app instance ID found in session storage, creating a new one`);let r=ht();return e.setItem(Ac,r),r},Mc=()=>Ui({[rn]:kc}),Nc=({diagLogger:e,appVersion:t,tabStorage:n})=>Ui({[on]:kc,app_version:t,app_framework:1,sdk_version:Oc,[sn]:Oc,sdk_simple_version:1,sdk_platform:`web`,[an]:`webjs`,"emb.app_instance_id":jc(n,e),[cn]:window.navigator.userAgent,screen_resolution:`${window.screen.width}x${window.screen.height}`}),Pc=/\/\/(.+):(.+)@(.+)\//,Fc=[`AWSAccessKeyId`,`Signature`,`sig`,"`X-Goog-Signature",`password`,`auth`,`pw`,`token`],Ic=({value:e,queryParamRegex:t,scrubPath:n,scrubQuery:r})=>{let i=e;return n&&(i=i.replace(Pc,`//REDACTED:REDACTED@$3/`)),r&&(i=i.replaceAll(t,`$1$2=REDACTED`)),i},Lc=e=>{let t=[...Fc,...e||[]],n=RegExp(`(^|&|\\?)(${t.join(`|`)})=[^&]+`,`g`);return[{key:j,scrub:e=>Ic({value:e,queryParamRegex:n,scrubPath:!0,scrubQuery:!0})},{key:`url.path`,scrub:e=>Ic({value:e,queryParamRegex:n,scrubPath:!0,scrubQuery:!1})},{key:`url.query`,scrub:e=>Ic({value:e,queryParamRegex:n,scrubPath:!1,scrubQuery:!0})}]},Rc=new class{constructor({diagLogger:e=T.createComponentLogger({namespace:`embrace-registry`})}={}){k(this,`_sdk`,null),k(this,`_diag`,void 0),k(this,`register`,e=>{this._sdk!==null&&this._diag.warn(`previously registered sdk will be overwritten`),this._sdk=e}),k(this,`clear`,()=>{this._sdk===null&&this._diag.warn(`sdk already cleared, this is a no-op`),this._sdk=null}),k(this,`registered`,()=>this._sdk),this._diag=e}},zc=T.createComponentLogger({namespace:`@opentelemetry/opentelemetry-instrumentation-fetch/utils`});function Bc(...e){if(e[0]instanceof URL||typeof e[0]==`string`){let t=e[1];if(!(t!=null&&t.body))return Promise.resolve();if(t.body instanceof ReadableStream){let{body:e,length:n}=Vc(t.body);return t.body=e,n}return Promise.resolve(Uc(t.body))}{let t=e[0];return t!=null&&t.body?t.clone().text().then(e=>Gc(e)):Promise.resolve()}}function Vc(e){if(!e.pipeThrough)return zc.warn(`Platform has ReadableStream but not pipeThrough!`),{body:e,length:Promise.resolve(void 0)};let t=0,n,r=new Promise(e=>{n=e}),i=new TransformStream({start(){},transform(e,n){return P(function*(){let r=yield e;t+=r.byteLength,n.enqueue(e)})()},flush(){n(t)}});return{body:e.pipeThrough(i),length:r}}function Hc(e){return typeof Document<`u`&&e instanceof Document}function Uc(e){if(Hc(e))return new XMLSerializer().serializeToString(document).length;if(typeof e==`string`)return Gc(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return Kc(e);if(e instanceof URLSearchParams)return Gc(e.toString());if(e.byteLength!==void 0)return e.byteLength;zc.warn(`unknown body type`)}let Wc=new TextEncoder;function Gc(e){return Wc.encode(e).byteLength}function Kc(e){let t=0;for(let[n,r]of e.entries())t+=n.length,r instanceof Blob?t+=r.size:t+=r.length;return t}function qc(e){let t=Xc(),n=e.toUpperCase();return n in t?n:`_OTHER`}let Jc={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0},Yc;function Xc(){return Yc===void 0&&(Yc=Jc),Yc}let Zc={"https:":`443`,"http:":`80`};function Qc(e){let t=Number(e.port||Zc[e.protocol]);if(t&&!isNaN(t))return t}let $c=`0.221.0`,el=typeof PerformanceObserver<`u`;var tl=class extends xr{constructor(e={}){super(`@opentelemetry/instrumentation-fetch`,$c,e),k(this,`component`,`fetch`),k(this,`version`,$c),k(this,`moduleName`,this.component),k(this,`_usedResources`,new WeakSet),k(this,`_tasksCount`,0)}init(){}_addChildSpan(e,t){let n=this.tracer.startSpan(`CORS Preflight`,{startTime:t[W.FETCH_START]},D.setSpan(w.active(),e));ro(n,t,this.getConfig().ignoreNetworkEvents,void 0,!0),n.end(t[W.RESPONSE_END])}_addFinalSpanAttributes(e,t){let n=K(t.url);e.setAttribute(en,t.status),e.setAttribute(tn,n.hostname);let r=Qc(n);r&&e.setAttribute(nn,r)}_addHeaders(e,t){if(!lo(t,this.getConfig().propagateTraceHeaderCorsUrls)){let e={};E.inject(w.active(),e),Object.keys(e).length>0&&this._diag.debug(`headers inject skipped due to CORS policy`);return}if(e instanceof Request)E.inject(w.active(),e.headers,{set:(e,t,n)=>e.set(t,typeof n==`string`?n:String(n))});else{let t=new Headers(e.headers);E.inject(w.active(),t,{set:(e,t,n)=>e.set(t,typeof n==`string`?n:String(n))}),e.headers=t}}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(performance.clearResourceTimings(),this._usedResources=new WeakSet)}_createSpan(e,t={}){if(Pi(e,this.getConfig().ignoreUrls)){this._diag.debug(`ignoring span as url matches ignored url`);return}let n={},r=t.method,i=qc(t.method||`GET`),a=i;return n[Qt]=i,i!==r&&(n[$t]=r),n[j]=e,this.tracer.startSpan(a,{kind:Qe.CLIENT,attributes:n})}_findResourceAndAddNetworkEvents(e,t,n){let r=t.entries;if(!r.length){if(!performance.getEntriesByType)return;r=performance.getEntriesByType(`resource`)}let i=oo(t.spanUrl,t.startTime,n,r,this._usedResources,`fetch`);if(i.mainRequest){let t=i.mainRequest;this._markResourceAsUsed(t);let n=i.corsPreFlightRequest;n&&(this._addChildSpan(e,n),this._markResourceAsUsed(n)),ro(e,t,this.getConfig().ignoreNetworkEvents,void 0,!0)}}_markResourceAsUsed(e){this._usedResources.add(e)}_endSpan(e,t,n){let r=L(Date.now()),i=R();this._addFinalSpanAttributes(e,n),n.status>=400&&(e.setStatus({code:C.ERROR}),e.setAttribute(Jt,String(n.status))),setTimeout(()=>{var n;(n=t.observer)==null||n.disconnect(),this._findResourceAndAddNetworkEvents(e,t,i),this._tasksCount--,this._clearResources(),e.end(r)},300)}_patchConstructor(){return e=>{let t=this;return function(...n){if(!t._isEnabled)return e.apply(this,n);let r=this,i=K(n[0]instanceof Request?n[0].url:String(n[0])).href,a;a=n[0]instanceof Request?n[1]==null?n[0]:new Request(n[0],n[1]):n[1]||{};let o=t._createSpan(i,a);if(!o)return e.apply(this,n);let s=t._prepareSpanData(i);t.getConfig().measureRequestSize&&Bc(...n).then(e=>{e&&o.setAttribute(`http.request.body.size`,e)}).catch(e=>{t._diag.warn(`getFetchBodyLength`,e)});function c(e,n){t._applyAttributesAfterFetch(e,a,n),t._endSpan(e,s,{status:n.status||0,statusText:n.message,url:i})}function l(e,n){t._applyAttributesAfterFetch(e,a,n),n.status>=200&&n.status<400?t._endSpan(e,s,n):t._endSpan(e,s,{status:n.status,statusText:n.statusText,url:i})}function u(e,n){try{let t=n.clone().body;if(t){let r=t.getReader(),i=()=>{r.read().then(({done:t})=>{t?l(e,n):i()},t=>{c(e,t)})};i()}else l(e,n)}catch(n){t._diag.error(`Failed to read fetch response body`,n),t._endSpan(e,s,{status:0,url:i})}return n}function d(e,n){try{c(e,n)}catch(r){t._diag.error(`Failed to end span on fetch error`,r),t._endSpan(e,s,{status:n.status||0,url:i})}throw n}return w.with(D.setSpan(w.active(),o),()=>(t._callRequestHook(o,a),t._addHeaders(a,i),t._tasksCount++,e.apply(r,a instanceof Request?[a]:[i,a]).then(u.bind(r,o),d.bind(r,o))))}}}_applyAttributesAfterFetch(e,t,n){let r=this.getConfig().applyCustomAttributesOnSpan;r&&Cr(()=>r(e,t,n),e=>{e&&this._diag.error(`applyCustomAttributesOnSpan`,e)},!0)}_callRequestHook(e,t){let n=this.getConfig().requestHook;n&&Cr(()=>n(e,t),e=>{e&&this._diag.error(`requestHook`,e)},!0)}_prepareSpanData(e){let t=R(),n=[];if(typeof PerformanceObserver!=`function`)return{entries:n,startTime:t,spanUrl:e};let r=new PerformanceObserver(t=>{t.getEntries().forEach(t=>{t.initiatorType===`fetch`&&t.name===e&&n.push(t)})});return r.observe({entryTypes:[`resource`]}),{entries:n,observer:r,startTime:t,spanUrl:e}}enable(){if(!el){this._diag.warn(`this instrumentation is intended for web usage only, it does not instrument server-side fetch()`);return}if(!this._isEnabled){if(this._isFetchPatched){this._diag.debug(`fetch constructor already patched`),this._isEnabled=!0;return}try{this._wrap(globalThis,`fetch`,this._patchConstructor()),this._isFetchPatched=!0,this._isEnabled=!0}catch(e){this._diag.warn(`Failed to patch globalThis.fetch; instrumentation will not be enabled. Another script may have locked globalThis.fetch via Object.defineProperty.`,e)}}}disable(){el&&this._isEnabled&&(this._isEnabled=!1,this._usedResources=new WeakSet)}},J;(function(e){e.METHOD_OPEN=`open`,e.METHOD_SEND=`send`,e.EVENT_ABORT=`abort`,e.EVENT_ERROR=`error`,e.EVENT_LOAD=`loaded`,e.EVENT_TIMEOUT=`timeout`})(J||(J={}));let nl=T.createComponentLogger({namespace:`@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils`});function rl(e){return typeof Document<`u`&&e instanceof Document}function il(e){if(rl(e))return new XMLSerializer().serializeToString(document).length;if(typeof e==`string`)return ol(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return sl(e);if(e instanceof URLSearchParams)return ol(e.toString());if(e.byteLength!==void 0)return e.byteLength;nl.warn(`unknown body type`)}let al=new TextEncoder;function ol(e){return al.encode(e).byteLength}function sl(e){let t=0;for(let[n,r]of e.entries())t+=n.length,r instanceof Blob?t+=r.size:t+=r.length;return t}function cl(e){let t=dl(),n=e.toUpperCase();return n in t?n:`_OTHER`}let ll={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0},ul;function dl(){return ul===void 0&&(ul=ll),ul}let fl={"https:":`443`,"http:":`80`};function pl(e){let t=Number(e.port||fl[e.protocol]);if(t&&!isNaN(t))return t}let ml=`0.221.0`;var hl=class extends xr{constructor(e={}){super(`@opentelemetry/instrumentation-xml-http-request`,ml,e),k(this,`component`,`xml-http-request`),k(this,`version`,ml),k(this,`moduleName`,this.component),k(this,`_tasksCount`,0),k(this,`_xhrMem`,new WeakMap),k(this,`_usedResources`,new WeakSet)}init(){}_addHeaders(e,t){let n=K(t).href;if(!lo(n,this.getConfig().propagateTraceHeaderCorsUrls)){let e={};E.inject(w.active(),e),Object.keys(e).length>0&&this._diag.debug(`headers inject skipped due to CORS policy`);return}let r={};E.inject(w.active(),r),Object.keys(r).forEach(t=>{e.setRequestHeader(t,String(r[t]))})}_addChildSpan(e,t){w.with(D.setSpan(w.active(),e),()=>{let e=this.tracer.startSpan(`CORS Preflight`,{startTime:t[W.FETCH_START]});ro(e,t,this.getConfig().ignoreNetworkEvents,void 0,!0),e.end(t[W.RESPONSE_END])})}_addFinalSpanAttributes(e,t){t.status&&e.setAttribute(en,t.status)}_applyAttributesAfterXHR(e,t){let n=this.getConfig().applyCustomAttributesOnSpan;typeof n==`function`&&Cr(()=>n(e,t),e=>{e&&this._diag.error(`applyCustomAttributesOnSpan`,e)},!0)}_addResourceObserver(e,t){let n=this._xhrMem.get(e);!n||typeof PerformanceObserver!=`function`||typeof PerformanceResourceTiming!=`function`||(n.createdResources={observer:new PerformanceObserver(e=>{let r=e.getEntries(),i=K(t);r.forEach(e=>{e.initiatorType===`xmlhttprequest`&&e.name===i.href&&n.createdResources&&n.createdResources.entries.push(e)})}),entries:[]},n.createdResources.observer.observe({entryTypes:[`resource`]}))}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(I.clearResourceTimings(),this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}_findResourceAndAddNetworkEvents(e,t,n,r,i){if(!n||!r||!i||!e.createdResources)return;let a=e.createdResources.entries;(!a||!a.length)&&(a=I.getEntriesByType(`resource`));let o=oo(K(n).href,r,i,a,this._usedResources);if(o.mainRequest){let e=o.mainRequest;this._markResourceAsUsed(e);let n=o.corsPreFlightRequest;n&&(this._addChildSpan(t,n),this._markResourceAsUsed(n)),ro(t,e,this.getConfig().ignoreNetworkEvents,void 0,!0)}}_cleanPreviousSpanInformation(e){let t=this._xhrMem.get(e);if(t){let n=t.callbackToRemoveEvents;n&&n(),this._xhrMem.delete(e)}}_createSpan(e,t,n){let r=K(t);if(Pi(r.href,this.getConfig().ignoreUrls)){this._diag.debug(`ignoring span as url matches ignored url`);return}let i={},a=n,o=cl(n),s=o;i[Qt]=o,o!==a&&(i[$t]=a),i[j]=r.toString(),i[tn]=r.hostname;let c=pl(r);c&&(i[nn]=c);let l=this.tracer.startSpan(s,{kind:Qe.CLIENT,attributes:i});return l.addEvent(J.METHOD_OPEN),this._cleanPreviousSpanInformation(e),this._xhrMem.set(e,{span:l,spanUrl:t}),l}_markResourceAsUsed(e){this._usedResources.add(e)}_patchOpen(){return e=>{let t=this;return function(...n){if(!t._isEnabled)return e.apply(this,n);let r=n[0],i=n[1];return t._createSpan(this,i,r),e.apply(this,n)}}}_patchSend(){let e=this;function t(t,n,r,i){let a=n.callbackToRemoveEvents;typeof a==`function`&&a();let{span:o,spanUrl:s,sendStartTime:c}=n;o&&(e._findResourceAndAddNetworkEvents(n,o,s,c,r),o.addEvent(t,i),e._addFinalSpanAttributes(o,n),o.end(i),e._tasksCount--),e._clearResources()}function n(n,r,i,a){let o=e._xhrMem.get(r);if(!o)return;if(o.status=r.status,o.statusText=r.statusText,e._xhrMem.delete(r),o.span){let t=o.span;e._applyAttributesAfterXHR(t,r),i?a&&(t.setStatus({code:C.ERROR,message:a}),t.setAttribute(Jt,a)):o.status&&o.status>=400&&(t.setStatus({code:C.ERROR}),t.setAttribute(Jt,String(o.status)))}let s=R(),c=Date.now();setTimeout(()=>{t(n,o,s,c)},300)}function r(){n(J.EVENT_ERROR,this,!0,`error`)}function i(){n(J.EVENT_ABORT,this,!1)}function a(){n(J.EVENT_TIMEOUT,this,!0,`timeout`)}function o(){this.status<299?n(J.EVENT_LOAD,this,!1):n(J.EVENT_ERROR,this,!1)}function s(t){t.removeEventListener(`abort`,i),t.removeEventListener(`error`,r),t.removeEventListener(`load`,o),t.removeEventListener(`timeout`,a);let n=e._xhrMem.get(t);n&&(n.callbackToRemoveEvents=void 0)}return t=>function(...n){if(!e._isEnabled)return t.apply(this,n);let c=e._xhrMem.get(this);if(!c)return t.apply(this,n);let l=c.span,u=c.spanUrl;if(l&&u){if(e.getConfig().measureRequestSize&&n!=null&&n[0]){let e=n[0],t=il(e);t!==void 0&&l.setAttribute(`http.request.body.size`,t)}w.with(D.setSpan(w.active(),l),()=>{e._tasksCount++,c.sendStartTime=R(),l.addEvent(J.METHOD_SEND),this.addEventListener(`abort`,i),this.addEventListener(`error`,r),this.addEventListener(`load`,o),this.addEventListener(`timeout`,a),c.callbackToRemoveEvents=()=>{s(this),c.createdResources&&c.createdResources.observer.disconnect()},e._addHeaders(this,u),e._addResourceObserver(this,u)})}return t.apply(this,n)}}enable(){if(!this._isEnabled){if(this._isXhrPatched){this._diag.debug(`reactivating existing patch on`,this.moduleName,this.version),this._isEnabled=!0;return}try{this._diag.debug(`applying patch to`,this.moduleName,this.version),this._wrap(XMLHttpRequest.prototype,`open`,this._patchOpen()),this._wrap(XMLHttpRequest.prototype,`send`,this._patchSend()),this._isXhrPatched=!0,this._isEnabled=!0}catch(e){this._unwrap(XMLHttpRequest.prototype,`open`),this._unwrap(XMLHttpRequest.prototype,`send`),this._diag.warn(`Failed to patch globalThis.XMLHttpRequest; instrumentation will not be enabled. Another script may have locked globalThis.XMLHttpRequest via Object.defineProperty.`,e)}}}disable(){this._isEnabled&&(this._isEnabled=!1,this._tasksCount=0,this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}},gl=class{constructor(e,t,n){this.instrumentationName=e,this.instrumentationVersion=t,k(this,`_config`,{}),k(this,`_diag`,void 0),k(this,`_tracer`,void 0),k(this,`_meter`,void 0),k(this,`_logger`,void 0),this.setConfig(n),this._diag=T.createComponentLogger({namespace:e}),this._tracer=D.getTracer(e,t),this._meter=tt.getMeter(e,t),this._logger=dr.getLogger(e,t),this._updateMetricInstruments()}get tracer(){return this._tracer}get meter(){return this._meter}get logger(){return this._logger}getModuleDefinitions(){var e;let t=(e=this.init())==null?[]:e;return Array.isArray(t)?t:[t]}getConfig(){return this._config}setConfig(e){this._config=A({enabled:!0},e)}setLoggerProvider(e){this._logger=e.getLogger(this.instrumentationName,this.instrumentationVersion)}setMeterProvider(e){this._meter=e.getMeter(this.instrumentationName,this.instrumentationVersion),this._updateMetricInstruments()}setTracerProvider(e){this._tracer=e.getTracer(this.instrumentationName,this.instrumentationVersion)}_updateMetricInstruments(){}_runSpanCustomizationHook(e,t,n,r){if(e)try{e(n,r)}catch(e){this._diag.error(`Error running span customization hook due to exception in handler`,{triggerName:t},e)}}},Y=class extends gl{constructor({instrumentationName:e,instrumentationVersion:t,config:n,diag:r,perf:i,limitManager:a}){super(e,t,n),k(this,`_userSessionManager`,void 0),k(this,`_logManager`,void 0),k(this,`_perf`,void 0),k(this,`_limitManager`,void 0),k(this,`_isEnabled`,!1),k(this,`_removeSessionPartListeners`,{}),k(this,`_sessionPartListeners`,{}),r&&(this._diag=r),this._perf=i==null?new Vt:i,this._limitManager=a,this._userSessionManager=zn.getUserSessionManager(),this._logManager=Tn.getLogManager()}get userSessionManager(){return this._userSessionManager}get logManager(){return this._logManager}get perf(){return this._perf}get limitManager(){return this._limitManager}setLimitManager(e){this._limitManager=e}init(){}setLogManager(e){this._logManager=e}setUserSessionManager(e){this._userSessionManager=e,this._registerSessionPartListeners()}setSessionPartListeners(e){this._sessionPartListeners=e,this._registerSessionPartListeners()}unregisterSessionPartListeners(){this._removeSessionPartListeners.start&&this._removeSessionPartListeners.start(),this._removeSessionPartListeners.end&&this._removeSessionPartListeners.end(),this._removeSessionPartListeners={}}_registerSessionPartListeners(){this._isEnabled&&this.userSessionManager&&(this.unregisterSessionPartListeners(),this._sessionPartListeners.start&&(this._removeSessionPartListeners.start=this.userSessionManager.addSessionPartStartedListener(e=>{var t,n;return(t=(n=this._sessionPartListeners).start)==null?void 0:t.call(n,e)})),this._sessionPartListeners.end&&(this._removeSessionPartListeners.end=this.userSessionManager.addSessionPartEndedListener(()=>{var e,t;return(e=(t=this._sessionPartListeners).end)==null?void 0:e.call(t)})))}disable(){this._isEnabled&&(this._isEnabled=!1,this.onDisable(),this.unregisterSessionPartListeners())}enable(){this._isEnabled||(this._isEnabled=!0,this.onEnable())}};let _l=()=>{let e={},t=window.performance.getEntriesByType(`navigation`)[0];return Object.values(W).forEach(n=>{if(no(t,n)){let r=t[n];typeof r==`number`&&(e[n]=r)}}),e},vl={"first-paint":`firstPaint`,"first-contentful-paint":`firstContentfulPaint`},yl=(e,t)=>{window.performance.getEntriesByType(`paint`).forEach(({name:n,startTime:r})=>{no(vl,n)&&e.addEvent(vl[n],t.epochMillisFromOrigin(r))})};var bl=class extends Y{constructor({diag:e,perf:t,enabled:n,applyCustomAttributesOnSpan:r,ignorePerformancePaintEvents:i=!1,ignoreNetworkEvents:a=!1}={}){super({instrumentationName:`DocumentLoadInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{enabled:n,applyCustomAttributesOnSpan:r,ignorePerformancePaintEvents:i,ignoreNetworkEvents:a}}),k(this,`_onDocumentLoaded`,void 0),k(this,`_performanceCollected`,!1),this._onDocumentLoaded=()=>{window.setTimeout(()=>{this._collectPerformance()},0)},this._config.enabled&&this.enable()}init(){this._diag.debug(`Initializing document load instrumentation`)}_addResourcesSpans(e){performance.getEntriesByType(`resource`).forEach(t=>{this._initResourceSpan(t,e)})}_collectPerformance(){if(this._performanceCollected)return;this._performanceCollected=!0;let e=Array.from(document.getElementsByTagName(`meta`)).find(e=>e.getAttribute(`name`)===ai),t=_l(),n=(e==null?void 0:e.content)||``;w.with(E.extract(b,{traceparent:n}),()=>{var e;let n=this._startSpan(`documentLoad`,W.FETCH_START,t);n&&(w.with(D.setSpan(w.active(),n),()=>{let e=this._startSpan(`documentFetch`,W.FETCH_START,t);e&&(e.setAttribute(j,location.href),w.with(D.setSpan(w.active(),e),()=>{var n;ro(e,t,this.getConfig().ignoreNetworkEvents),this._addCustomAttributesOnSpan(e,(n=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:n.documentFetch),this._endSpan(e,W.RESPONSE_END,t)}))}),n.setAttribute(O,`ux.document_load`),n.setAttribute(j,location.href),n.setAttribute(cn,navigator.userAgent),this._addResourcesSpans(n),this.getConfig().ignoreNetworkEvents||(G(n,W.FETCH_START,t),G(n,W.UNLOAD_EVENT_START,t),G(n,W.UNLOAD_EVENT_END,t),G(n,W.DOM_INTERACTIVE,t),G(n,W.DOM_CONTENT_LOADED_EVENT_START,t),G(n,W.DOM_CONTENT_LOADED_EVENT_END,t),G(n,W.DOM_COMPLETE,t),G(n,W.LOAD_EVENT_START,t),G(n,W.LOAD_EVENT_END,t)),this.getConfig().ignorePerformancePaintEvents||yl(n,this.perf),this._addCustomAttributesOnSpan(n,(e=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:e.documentLoad),this._endSpan(n,W.LOAD_EVENT_END,t))})}_endSpan(e,t,n){e&&(no(n,t)&&typeof n[t]==`number`?e.end(this.perf.epochMillisFromOrigin(n[t])):e.end())}_initResourceSpan(e,t){var n;let r=this._startSpan(`resourceFetch`,W.FETCH_START,e,t);r&&(r.setAttribute(O,`ux.resource_fetch`),r.setAttribute(j,e.name),ro(r,e,this.getConfig().ignoreNetworkEvents),e.deliveryType&&r.setAttribute(`http.response.delivery_type`,e.deliveryType),e.initiatorType&&r.setAttribute(`http.request.initiator_type`,e.initiatorType),e.renderBlockingStatus&&r.setAttribute(`http.request.render_blocking_status`,e.renderBlockingStatus),e.responseStatus&&r.setAttribute(en,e.responseStatus),typeof e.encodedBodySize==`number`&&e.encodedBodySize>=0&&r.setAttribute(`http.response.body.size`,e.encodedBodySize),typeof e.transferSize==`number`&&e.transferSize>=0&&r.setAttribute(`http.response.size`,e.transferSize),typeof e.decodedBodySize==`number`&&e.decodedBodySize>=0&&r.setAttribute(`http.response.decoded_body_size`,e.decodedBodySize),this._addResourceDiagnosticAttributes(r,e),this._addCustomAttributesOnResourceSpan(r,e,(n=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:n.resourceFetch),this._endSpan(r,W.RESPONSE_END,e))}_startSpan(e,t,n,r){if(no(n,t)&&typeof n[t]==`number`)return this.tracer.startSpan(e,{startTime:this.perf.epochMillisFromOrigin(n[t])},r?D.setSpan(w.active(),r):void 0)}_waitForPageLoad(){window.document.readyState===`complete`?this._onDocumentLoaded():window.addEventListener(`load`,this._onDocumentLoaded)}_addCustomAttributesOnSpan(e,t){t&&Cr(()=>{t(e)},e=>{e&&this._diag.error(`addCustomAttributesOnSpan`,e)},!0)}_addCustomAttributesOnResourceSpan(e,t,n){n&&Cr(()=>{n(e,t)},e=>{e&&this._diag.error(`addCustomAttributesOnResourceSpan`,e)},!0)}_hasNoSizeData(e){let t=typeof e.transferSize==`number`?e.transferSize:0,n=typeof e.decodedBodySize==`number`?e.decodedBodySize:0,r=typeof e.encodedBodySize==`number`?e.encodedBodySize:0;return t===0&&n===0&&r===0}_hasTimingData(e){let t=typeof e.fetchStart==`number`?e.fetchStart:0,n=typeof e.responseEnd==`number`?e.responseEnd:0;return t>0&&n>0}_isCorsRestricted(e){return this._hasNoSizeData(e)&&this._hasTimingData(e)}_isFetchIncomplete(e){let t=typeof e.fetchStart==`number`?e.fetchStart:0,n=typeof e.responseEnd==`number`?e.responseEnd:0;return this._hasNoSizeData(e)&&t>0&&n===0}_isFetchPrevented(e){let t=typeof e.fetchStart==`number`?e.fetchStart:0;return this._hasNoSizeData(e)&&t===0}_isCacheValidated(e){let t=typeof e.transferSize==`number`?e.transferSize:0,n=typeof e.deliveryType==`string`?e.deliveryType:``;return t===300&&n!==`cache`}_addResourceDiagnosticAttributes(e,t){this._isCorsRestricted(t)?e.setAttribute(`http.response.cors_opaque`,!0):this._isFetchIncomplete(t)?e.setAttribute(`http.request.incomplete`,!0):this._isFetchPrevented(t)&&e.setAttribute(`http.request.prevented`,!0),this._isCacheValidated(t)&&e.setAttribute(`http.response.cache_revalidated`,!0)}onEnable(){window.removeEventListener(`load`,this._onDocumentLoaded),this._waitForPageLoad()}onDisable(){window.removeEventListener(`load`,this._onDocumentLoaded)}},xl=class extends Y{constructor({diag:e,perf:t,rootNode:n,emptyCheckDelayMs:r=500}){super({instrumentationName:`EmptyRootInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),k(this,`_observer`,void 0),k(this,`_emptyCheckDelayMs`,void 0),k(this,`_rootNode`,void 0),this._rootNode=n,this._emptyCheckDelayMs=r,this._observer=new MutationObserver((e,t)=>{this._observerCallback(e)}),this._config.enabled&&this.enable()}enable(){this._rootNode?super.enable():this._diag.warn(`supplied root node was null, this instrumentation won't be enabled`)}onDisable(){this._observer.disconnect()}onEnable(){this._rootNode&&this._observer.observe(this._rootNode,{childList:!0})}_observerCallback(e){let t=!1,n=!1;for(let r of e)r.target===this._rootNode&&(r.removedNodes.length>0&&(t=!0),r.addedNodes.length>0&&(n=!0));t&&!n&&(this._diag.debug(`root node had child nodes removed without new ones being added, checking if it's empty in ${this._emptyCheckDelayMs}ms`),window.setTimeout(()=>{this._checkForEmptyRootNode()},this._emptyCheckDelayMs))}_checkForEmptyRootNode(){var e;if(((e=this._rootNode)==null?void 0:e.childNodes.length)===0){this._diag.debug(`root node was found to be empty`);let e=this.userSessionManager.getSessionPartSpan();e?e.addEvent(`empty-root-node`,{"emb.type":`ux.empty_root_node`}):this._diag.debug(`no active session found to emit event on`)}}};let Sl=(e,t)=>{let n=e.nodeName.toLowerCase(),r=t.substring(0,30),i=t.length>30?`...`:``;return`<${n}${e.className?` class="${e.className}"`:``}>${r}${i}</${n}>`};var Cl=class extends Y{constructor({diag:e,perf:t,shouldTrack:n,innerTextForElement:r}={}){super({instrumentationName:`ClicksInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),k(this,`_onClickHandler`,void 0),this._onClickHandler=e=>{let t=e.target;if(t instanceof HTMLElement&&!t.hasAttribute(`disabled`)&&!(n&&!n(t)))try{let n=this.userSessionManager.getSessionPartSpan();n&&n.addEvent(`click`,{"emb.type":`ux.tap`,"view.name":Sl(t,r?r(t):t.innerText),"tap.coords":`${e.x.toString()},${e.y.toString()}`},this.perf.epochMillisFromOrigin(e.timeStamp))}catch(e){this._diag.error(`failed to create new user interaction span event`,e)}},this._config.enabled&&this.enable()}onDisable(){document.removeEventListener(`click`,this._onClickHandler)}onEnable(){document.addEventListener(`click`,this._onClickHandler)}},wl=class extends Y{constructor({diag:e,perf:t,limitManager:n}={}){super({instrumentationName:`ElementTimingInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,limitManager:n,config:{}}),k(this,`_observer`,null),this._config.enabled&&this.enable()}enable(){Kt(`element`)?super.enable():this._diag.debug(`element not supported, skipping`)}onEnable(){if(this._observer&&this._observer.disconnect(),this._observer=qt(`element`,e=>this._processEntry(e),{diag:this._diag}),!this._observer){this._isEnabled=!1,this._diag.error(`failed to enable`);return}}onDisable(){this._observer&&(this._observer.disconnect(),this._observer=null)}_processEntry(e){var t,n;if(!this._isEnabled||(t=this.limitManager)!=null&&t.limitElementTimingEntry())return;let r=this.tracer.startSpan(e.identifier,{startTime:this.perf.getZeroTime(),attributes:{[O]:`ux.element_timing`,"emb.element_timing.identifier":e.identifier,"emb.element_timing.element":(n=e.element)==null||(n=n.tagName)==null?void 0:n.toLowerCase(),"emb.element_timing.render_time":this.perf.millisFromZeroTime(e.renderTime),"emb.element_timing.load_time":this.perf.millisFromZeroTime(e.loadTime),"emb.element_timing.start_time":this.perf.millisFromZeroTime(e.startTime),"emb.element_timing.url":e.url,"emb.element_timing.natural_width":e.naturalWidth,"emb.element_timing.natural_height":e.naturalHeight}});e.loadTime>0&&r.addEvent(`load`,this.perf.epochMillisFromOrigin(e.loadTime)),r.end(this.perf.epochMillisFromOrigin(e.startTime))}},Tl=class extends Y{constructor({diag:e,perf:t}={}){super({instrumentationName:`GlobalExceptionInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),k(this,`_onErrorHandler`,void 0),k(this,`_onUnhandledRejectionHandler`,void 0),this._onErrorHandler=e=>{this.logManager.logException(e.error||e.message,{handled:!1,timestamp:this.perf.epochMillisFromOrigin(e.timeStamp),handler:`global_exception`})},this._onUnhandledRejectionHandler=e=>{this.logManager.logException(e.reason,{handled:!1,timestamp:this.perf.epochMillisFromOrigin(e.timeStamp),handler:`promise_rejection`})},this._config.enabled&&this.enable()}onDisable(){window.removeEventListener(`error`,this._onErrorHandler),window.removeEventListener(`unhandledrejection`,this._onUnhandledRejectionHandler)}onEnable(){window.addEventListener(`error`,this._onErrorHandler),window.addEventListener(`unhandledrejection`,this._onUnhandledRejectionHandler)}},El=class extends Y{constructor({diag:e,perf:t}={}){super({instrumentationName:`FirstInteractionInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),k(this,`_onClick`,void 0),k(this,`_onKeyDown`,void 0),k(this,`_onScroll`,void 0),k(this,`_listenersAttached`,!1),this._onClick=e=>{this._handle({interactionType:e.pointerType===`touch`?`tap`:`click`,target:e.target instanceof Element?e.target:null,timestamp:e.timeStamp,x:e.clientX,y:e.clientY})},this._onKeyDown=e=>{this._handle({interactionType:`keypress`,target:e.target instanceof Element?e.target:null,timestamp:e.timeStamp})},this._onScroll=e=>{this._handle({interactionType:`scroll`,target:null,timestamp:e.timeStamp})},this._config.enabled&&this.enable()}onEnable(){this._attachListeners(),this.setSessionPartListeners({start:()=>{this._attachListeners()}})}onDisable(){this._detachListeners()}_handle(e){if(this._listenersAttached){this._detachListeners();try{this._emit(e)}catch(e){this._diag.error(`failed to process first-interaction candidate`,e)}}}_attachListeners(){if(this._listenersAttached)return;let e={capture:!0,passive:!0};document.addEventListener(`click`,this._onClick,e),document.addEventListener(`keydown`,this._onKeyDown,e),document.addEventListener(`scroll`,this._onScroll,e),this._listenersAttached=!0}_detachListeners(){if(!this._listenersAttached)return;let e={capture:!0};document.removeEventListener(`click`,this._onClick,e),document.removeEventListener(`keydown`,this._onKeyDown,e),document.removeEventListener(`scroll`,this._onScroll,e),this._listenersAttached=!1}_emit(e){let t=`document`,n=``;e.interactionType!==`scroll`&&e.target&&(t=e.target.tagName.toLowerCase(),n=yt(e.target));let r={[O]:`emb.otel_log`,"first_interaction.interaction_type":e.interactionType,"first_interaction.element_type":t,"first_interaction.element_selector":n,"first_interaction.time":this.perf.millisFromZeroTime(e.timestamp)};e.x!==void 0&&e.y!==void 0&&(r[`first_interaction.x`]=e.x,r[`first_interaction.y`]=e.y),this.logger.emit({timestamp:this.perf.epochMillisFromOrigin(e.timestamp),eventName:`first-interaction`,severityNumber:M.INFO,attributes:r})}},Dl=class extends Y{constructor({diag:e,perf:t}={}){super({instrumentationName:`LoafInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),k(this,`_observer`,null),k(this,`_isFirstEntry`,!0),k(this,`_totalDuration`,0),k(this,`_workDuration`,0),k(this,`_styleLayoutDuration`,0),k(this,`_count`,0),k(this,`_longestDuration`,0),k(this,`_longestDurationExcludingFirst`,0),k(this,`_totalBlockingDuration`,0),k(this,`_scriptSummaries`,new Map),this._config.enabled&&this.enable()}enable(){Kt(`long-animation-frame`)?super.enable():this._diag.debug(`long-animation-frame not supported, skipping`)}onEnable(){if(this._observer&&this._observer.disconnect(),this._observer=qt(`long-animation-frame`,e=>this._processEntry(e),{diag:this._diag}),!this._observer){this._isEnabled=!1,this._diag.error(`failed to enable`);return}this.setSessionPartListeners({end:()=>{try{this._flushReport()}catch(e){this._diag.error(`error flushing report`,e)}}})}onDisable(){this._resetAccumulators(),this._observer&&(this._observer.disconnect(),this._observer=null)}_processEntry(e){if(this._isEnabled){this._count++,this._totalDuration+=e.duration,this._workDuration+=e.renderStart?e.renderStart-e.startTime:e.duration,e.styleAndLayoutStart&&(this._styleLayoutDuration+=Math.max(0,e.startTime+e.duration-e.styleAndLayoutStart)),this._longestDuration=Math.max(this._longestDuration,e.duration),this._isFirstEntry&&this._count===1?this._isFirstEntry=!1:(this._longestDurationExcludingFirst=Math.max(this._longestDurationExcludingFirst,e.duration),e.firstUIEventTimestamp===0&&(this._totalBlockingDuration+=e.blockingDuration));try{for(let t of e.scripts){let e=t.sourceURL||`(inline)`;e.length>2048&&(e=`${e.substring(0,2048)}...`);let n=this._scriptSummaries.get(e);n?(n.totalDuration+=t.duration,n.styleAndLayoutDuration+=t.forcedStyleAndLayoutDuration,n.count++):this._scriptSummaries.set(e,{totalDuration:t.duration,styleAndLayoutDuration:t.forcedStyleAndLayoutDuration,count:1})}}catch(e){this._diag.error(`error processing scripts for entry`,e)}}}_flushReport(){if(this._count===0)return;let e;e=this._totalBlockingDuration<=200?`good`:this._totalBlockingDuration<=600?`needs-improvement`:`poor`;let t={[O]:`ux.web_vital`,"browser.web_vital.id":gt(),"browser.web_vital.name":`tbd`,"browser.web_vital.value":Math.round(this._totalBlockingDuration),"browser.web_vital.rating":e,"emb.tbd.loaf_total_duration":Math.round(this._totalDuration),"emb.tbd.loaf_work_duration":Math.round(this._workDuration),"emb.tbd.loaf_style_and_layout_duration":Math.round(this._styleLayoutDuration),"emb.tbd.loaf_count":this._count,"emb.tbd.loaf_longest_duration":Math.round(this._longestDuration),"emb.tbd.loaf_longest_duration_excluding_first":Math.round(this._longestDurationExcludingFirst)};try{this.logger.emit({eventName:`emb-loaf-report`,severityNumber:M.INFO,attributes:t})}catch(e){this._diag.error(`error emitting loaf report`,e)}try{if(this._scriptSummaries.size>0){let e=[...this._scriptSummaries].sort((e,t)=>t[1].totalDuration-e[1].totalDuration).slice(0,250).map(([e,t])=>[e,{total_duration:Math.round(t.totalDuration),style_and_layout_duration:Math.round(t.styleAndLayoutDuration),count:t.count}]);this.logger.emit({eventName:`emb-loaf-scripts`,severityNumber:M.INFO,body:JSON.stringify(Object.fromEntries(e)),attributes:{[O]:`ux.loaf_scripts`}})}}catch(e){this._diag.error(`error emitting loaf script summary`,e)}this._resetAccumulators()}_resetAccumulators(){this._totalDuration=0,this._workDuration=0,this._styleLayoutDuration=0,this._count=0,this._longestDuration=0,this._longestDurationExcludingFirst=0,this._totalBlockingDuration=0,this._scriptSummaries=new Map}},Ol=class extends Y{constructor({diag:e,perf:t}={}){super({instrumentationName:`MaxScrollDepthInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),k(this,`_onScrollHandler`,void 0),k(this,`_hasScrolled`,!1),k(this,`_maxScrollY`,0),this._onScrollHandler=()=>{try{let e=window.scrollY;e>this._maxScrollY&&(this._maxScrollY=e),this._hasScrolled=!0}catch(e){this._diag.error(`failed to process scroll`,e)}},this._config.enabled&&this.enable()}onEnable(){window.addEventListener(`scroll`,this._onScrollHandler,{passive:!0}),this.setSessionPartListeners({end:()=>{try{this._emit()}catch(e){this._diag.error(`failed to emit max-scroll-depth log`,e)}}})}onDisable(){window.removeEventListener(`scroll`,this._onScrollHandler)}_emit(){this._maxScrollY=Math.max(this._maxScrollY,window.scrollY);let e=Nt();this.logger.emit({eventName:`max-scroll-depth`,severityNumber:M.INFO,attributes:A({[O]:`emb.otel_log`,"max_scroll_depth.pixels":this._maxScrollY,"max_scroll_depth.did_scroll":this._hasScrolled},e?{"max_scroll_depth.percent":this._scrollPercent(e),"max_scroll_depth.document_height":e.documentHeight}:{})}),this._hasScrolled=!1,this._maxScrollY=Math.max(0,window.scrollY)}_scrollPercent({scrollableHeight:e}){return e===0?0:Math.min(100,Math.round(this._maxScrollY/e*100))}};let kl=/\([^()]+\)/g;var Al=class extends Y{constructor({diag:e,shouldCleanupPathOptionsFromRouteName:t=!0,pageManager:n}){super({instrumentationName:`NavigationInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,config:{}}),k(this,`_shouldCleanupPathOptionsFromRouteName`,!0),k(this,`_pageManager`,void 0),k(this,`_currentRouteSpan`,null),k(this,`_currentRouteSpanUrl`,null),k(this,`_currentRouteSpanPath`,null),k(this,`_onRouteChanged`,e=>{if(this._config.enabled){if(this._currentRouteSpan&&this._currentRouteSpanUrl===e.url){this._currentRouteSpanPath!==e.path&&this._renameCurrentRouteSpan(e.path);return}this._endRouteSpan(),this._startRouteSpan(e)}}),k(this,`_startRouteSpan`,e=>{this._diag.debug(`Starting route span for url: ${e.url}`);let t=this._cleanPath(e.path);return this._currentRouteSpan=this.tracer.startSpan(t,{startTime:this.perf.getNowMillis(),attributes:{[O]:`ux.surface`,[Ct]:t,[wt]:this._pageManager.getCurrentPageId()||void 0}}),this._currentRouteSpanUrl=e.url,this._currentRouteSpanPath=e.path,this._currentRouteSpan}),k(this,`_endRouteSpan`,()=>{if(this._currentRouteSpan){var e;this._diag.debug(`Ending route span for url: ${(e=this._currentRouteSpanUrl)==null?`unknown`:e}`),this._currentRouteSpan.end(this.perf.getNowMillis()),this._currentRouteSpan=null,this._currentRouteSpanUrl=null,this._currentRouteSpanPath=null}}),k(this,`_renameCurrentRouteSpan`,e=>{var t,n;let r=this._cleanPath(e);this._diag.debug(`Resolved route span path to: ${r}`),(t=this._currentRouteSpan)==null||t.updateName(r),(n=this._currentRouteSpan)==null||n.setAttribute(`app.surface.name`,r),this._currentRouteSpanPath=e}),k(this,`_cleanPath`,e=>this._shouldCleanupPathOptionsFromRouteName?e.replace(kl,``):e),k(this,`_onSessionPartEnded`,()=>{this._currentRouteSpan&&(this._diag.debug(`Session ended, ending route span.`),this._endRouteSpan())}),k(this,`_onSessionPartStarted`,({reason:e})=>{if(e===`web_soft_navigation`)return;let t=this._pageManager.getCurrentRoute();t&&this._onRouteChanged(t)}),k(this,`onEnable`,()=>{this.setConfig({enabled:!0}),this.setSessionPartListeners({start:this._onSessionPartStarted,end:this._onSessionPartEnded}),this._diag.debug(`NavigationInstrumentation enabled, listening for navigation events.`)}),k(this,`onDisable`,()=>{this._endRouteSpan(),this.setConfig({enabled:!1}),this._diag.debug(`NavigationInstrumentation disabled, stopped listening for navigation events.`)}),this._shouldCleanupPathOptionsFromRouteName=t,this._pageManager=n==null?Mn.getPageManager():n,this._pageManager.addRouteChangedListener(this._onRouteChanged),this._config.enabled&&this.enable();let r=this._pageManager.getCurrentRoute();r&&this._onRouteChanged(r)}},jl=class extends Y{constructor({diag:e,perf:t}={}){super({instrumentationName:`RageClickInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,config:{}}),k(this,`_onClickHandler`,void 0),k(this,`_eventWindow`,null),this._onClickHandler=e=>{try{this._handleClick(e)}catch(e){this._diag.error(`failed to process rage-click candidate`,e)}},this._config.enabled&&this.enable()}onDisable(){document.removeEventListener(`click`,this._onClickHandler),this._flush()}onEnable(){document.addEventListener(`click`,this._onClickHandler)}_handleClick(e){if(!(e.target instanceof Element))return;let t=e.target,n=e instanceof PointerEvent&&e.pointerType===`touch`?`tap`:`click`;if(this._eventWindow===null){this._eventWindow={target:t,x:e.clientX,y:e.clientY,count:1,interactionType:n,timestamp:e.timeStamp,timeoutId:window.setTimeout(()=>{try{this._flush()}catch(e){this._diag.error(`failed to emit rage-click log`,e)}},500)};return}let r=t===this._eventWindow.target,i=Math.abs(e.clientX-this._eventWindow.x),a=Math.abs(e.clientY-this._eventWindow.y);(r||i<=50&&a<=50)&&(this._eventWindow.count+=1)}_flush(){if(this._eventWindow===null)return;let e=this._eventWindow;window.clearTimeout(e.timeoutId),this._eventWindow=null,!(e.count<3)&&this.logger.emit({timestamp:this.perf.epochMillisFromOrigin(e.timestamp),eventName:`rage-click`,severityNumber:M.INFO,attributes:{[O]:`emb.otel_log`,"rage_click.element_type":e.target.tagName.toLowerCase(),"rage_click.element_selector":yt(e.target),"rage_click.x":e.x,"rage_click.y":e.y,"rage_click.count":e.count,"rage_click.interaction_type":e.interactionType}})}},Ml=class extends Y{constructor({diag:e,perf:t,limitManager:n}={}){super({instrumentationName:`ServerTimingInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,limitManager:n,config:{}}),k(this,`_onLoad`,void 0),k(this,`_performanceCollected`,!1),this._onLoad=()=>{this._readServerTiming()},this._config.enabled&&this.enable()}onEnable(){if(window.removeEventListener(`load`,this._onLoad),window.document.readyState===`complete`){this._readServerTiming();return}window.addEventListener(`load`,this._onLoad)}onDisable(){window.removeEventListener(`load`,this._onLoad)}_readServerTiming(){var e;if(this._performanceCollected)return;this._performanceCollected=!0;let t=(e=performance.getEntriesByType(`navigation`)[0])==null?void 0:e.serverTiming;if(t!=null&&t.length)for(let e of t){var n;if((n=this.limitManager)!=null&&n.limitServerTimingEntry())return;this.logger.emit({eventName:`emb-server-timing`,severityNumber:M.INFO,attributes:{[O]:`ux.server_timing`,"emb.server_timing.name":e.name,"emb.server_timing.duration":e.duration,"emb.server_timing.description":e.description}})}}};function Nl(e,t){return t.startTime<=e&&e<=t.startTime+t.duration?t:null}var Pl=class extends Y{constructor({diag:e,perf:t,limitManager:n,navigationHost:r=window,signalBuffer:i}={}){super({instrumentationName:`SoftNavigationPerformanceInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,limitManager:n,config:{}}),k(this,`_observer`,null),k(this,`_eventObserver`,null),k(this,`_pendingNavigations`,[]),k(this,`_usePolyfill`,!1),k(this,`_navigationHost`,void 0),k(this,`_signalBuffer`,void 0),k(this,`_handleCurrentEntryChange`,e=>{var t;let n=(t=this._navigationHost.navigation)==null||(t=t.currentEntry)==null?void 0:t.url;if(!n){this._diag.debug(`currententrychange fired with no URL, skipping`);return}this._pendingNavigations.push({timestamp:e.timeStamp,url:n})}),this._navigationHost=r,this._signalBuffer=i,this._config.enabled&&this.enable()}enable(){Kt(`soft-navigation`)?(this._usePolyfill=!1,super.enable()):this._navigationHost.navigation&&Kt(`event`)?(this._usePolyfill=!0,super.enable()):this._diag.debug(`soft-navigation and navigation API not supported, skipping`)}onEnable(){this._usePolyfill?this._enablePolyfill():this._enableNative()}_enableNative(){if(this._observer&&this._observer.disconnect(),this._observer=qt(`soft-navigation`,e=>this._processEntry(e),{diag:this._diag}),!this._observer){this._isEnabled=!1,this._diag.error(`failed to enable`);return}}_enablePolyfill(){this._eventObserver&&this._eventObserver.disconnect();let e=this._navigationHost.navigation;if(e.addEventListener(`currententrychange`,this._handleCurrentEntryChange),this._eventObserver=qt(`event`,e=>this._processClickEntry(e),{diag:this._diag,durationThreshold:16}),!this._eventObserver){e.removeEventListener(`currententrychange`,this._handleCurrentEntryChange),this._isEnabled=!1,this._diag.error(`failed to enable polyfill`);return}}onDisable(){var e;this._observer&&(this._observer.disconnect(),this._observer=null),this._eventObserver&&(this._eventObserver.disconnect(),this._eventObserver=null),(e=this._navigationHost.navigation)==null||e.removeEventListener(`currententrychange`,this._handleCurrentEntryChange),this._pendingNavigations.length=0}_correlationAttributes(e,t){if(!this._signalBuffer)return{};let{spanIds:n,spanTypes:r,logIds:i,logTypes:a}=this._signalBuffer.collectWindow(e,t);return{"emb.soft_navigation.span_ids":n,"emb.soft_navigation.span_id_types":r,"emb.soft_navigation.log_ids":i,"emb.soft_navigation.log_id_types":a}}_processEntry(e){var t;if(!this._isEnabled||(t=this.limitManager)!=null&&t.limitSoftNavigationEntry())return;let n=this.perf.epochMillisFromOrigin(e.startTime),r=this.perf.epochMillisFromOrigin(e.startTime+e.duration);this.tracer.startSpan(ln,{startTime:n,attributes:A({[St]:e.name,[un]:mn.performanceObserver,"emb.soft_navigation.navigation_id":e.navigationId,[dn]:e.interactionId,[fn]:this.perf.millisFromZeroTime(e.startTime),[pn]:e.duration,"emb.soft_navigation.paint_time":e.paintTime==null?void 0:this.perf.millisFromZeroTime(e.paintTime),"emb.soft_navigation.presentation_time":e.presentationTime==null?void 0:this.perf.millisFromZeroTime(e.presentationTime)},this._correlationAttributes(n,r))}).end(r)}_processClickEntry(e){if(!this._isEnabled||e.name!==`click`)return;this._pendingNavigations=this._pendingNavigations.filter(({timestamp:t})=>e.startTime-t<6e4);let t=this._pendingNavigations.findIndex(({timestamp:t})=>Nl(t,e)!==null);if(t===-1)return;let[n]=this._pendingNavigations.splice(t,1);this._emitPolyfillSpan(e,n.timestamp,n.url)}_emitPolyfillSpan(e,t,n){var r;if(!this._isEnabled||(r=this.limitManager)!=null&&r.limitSoftNavigationEntry())return;let i=this.perf.epochMillisFromOrigin(e.startTime),a=this.perf.epochMillisFromOrigin(t);this.tracer.startSpan(ln,{startTime:i,attributes:A({[St]:n,[un]:mn.polyfill,[fn]:this.perf.millisFromZeroTime(e.startTime),[pn]:t-e.startTime,[dn]:e.interactionId===0?void 0:e.interactionId},this._correlationAttributes(i,a))}).end(a)}};let Fl=`emb.user_timing.start_time`,Il=`emb.user_timing.duration`,Ll=`emb.user_timing.entry_type`;var Rl=class extends Y{constructor({diag:e,perf:t,limitManager:n,allowedEntries:r}={}){super({instrumentationName:`UserTimingInstrumentation`,instrumentationVersion:`1.0.0`,diag:e,perf:t,limitManager:n,config:{}}),k(this,`_markObserver`,null),k(this,`_measureObserver`,null),k(this,`_seenEntries`,new Set),k(this,`_allowedEntries`,void 0),this._allowedEntries=r,this._config.enabled&&this.enable()}onEnable(){this._seenEntries=new Set,this._markObserver&&this._markObserver.disconnect(),this._measureObserver&&this._measureObserver.disconnect(),this._markObserver=qt(`mark`,this._processEntry.bind(this),{diag:this._diag}),this._markObserver||this._diag.error(`failed to enable mark observer`),this._measureObserver=qt(`measure`,e=>this._processEntry(e),{diag:this._diag}),this._measureObserver||this._diag.error(`failed to enable measure observer`),!this._markObserver&&!this._measureObserver&&(this._isEnabled=!1)}onDisable(){this._markObserver&&(this._markObserver.disconnect(),this._markObserver=null),this._measureObserver&&(this._measureObserver.disconnect(),this._measureObserver=null),this._seenEntries=new Set}_processEntry(e){var t;if(!this._isEnabled||this._allowedEntries!==void 0&&!(Array.isArray(this._allowedEntries)?this._allowedEntries.includes(e.name):this._allowedEntries(e)))return;let n=`${location.href}::${e.name}`;if(this._seenEntries.has(n)||(this._seenEntries.add(n),(t=this.limitManager)!=null&&t.limitUserTimingEntry(e.entryType)))return;if(e.entryType===`measure`){let t=e.detail;this.tracer.startSpan(e.name,{startTime:this.perf.epochMillisFromOrigin(e.startTime),attributes:A({[O]:`ux.user_timing`,"emb.instrumentation":`user_timing`,[Ll]:e.entryType,[Fl]:this.perf.millisFromZeroTime(e.startTime),[Il]:e.duration},t!=null&&{"emb.user_timing.detail":JSON.stringify(t)})}).end(this.perf.epochMillisFromOrigin(e.startTime+e.duration));return}let r=e.detail,i=r==null?void 0:JSON.stringify(r);this.logger.emit({timestamp:this.perf.epochMillisFromOrigin(e.startTime),eventName:`emb-user-timing`,severityNumber:M.INFO,attributes:{[O]:`ux.user_timing`,"emb.user_timing.name":e.name,[Fl]:this.perf.millisFromZeroTime(e.startTime),[Il]:e.duration,[Ll]:e.entryType},body:i})}};let zl=`emb.web_vital.attribution.`;var Bl=class{constructor(){k(this,`t`,void 0),k(this,`o`,0),k(this,`i`,[])}l(e){var t;if(e.hadRecentInput)return;let n=this.i[0],r=this.i.at(-1);this.o&&n&&r&&e.startTime-r.startTime<1e3&&e.startTime-n.startTime<5e3?(this.o+=e.value,this.i.push(e)):(this.o=e.value,this.i=[e]),(t=this.t)==null||t.call(this,e)}};let Vl=()=>{let e=performance.getEntriesByType(`navigation`)[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},Hl=e=>{if(document.readyState===`loading`)return`loading`;let t=Vl();if(t){if(e<t.domInteractive)return`loading`;if(t.domContentLoadedEventStart===0||e<t.domContentLoadedEventStart)return`dom-interactive`;if(t.domComplete===0||e<t.domComplete)return`dom-content-loaded`}return`complete`},Ul=e=>{let t=e.nodeName;return e.nodeType===1?t.toLowerCase():t.toUpperCase().replace(/^#/,``)},Wl=e=>{let t=``;try{for(;(e==null?void 0:e.nodeType)!==9;){var n;let r=e,i=r.id?`#`+r.id:[Ul(r),...Array.from((n=r.classList)==null?[]:n).sort()].join(`.`);if(t.length+i.length>99)return t||i;if(t=t?i+`>`+t:i,r.id)break;e=r.parentNode}}catch(e){}return t},Gl=new WeakMap;function X(e,t){let n=Gl.get(t);return n||(n=new WeakMap,Gl.set(t,n)),n.get(e)||n.set(e,new t),n.get(e)}let Kl=-1,ql=()=>Kl,Jl=e=>{addEventListener(`pageshow`,t=>{t.persisted&&(Kl=t.timeStamp,e(t))},!0)},Z=(e,t,n,r)=>{let i,a;return o=>{var s;t.value>=0&&(o||r)&&(a=t.value-((s=i)==null?0:s),(a||i===void 0)&&(i=t.value,t.delta=a,t.rating=((e,t)=>e>t[1]?`poor`:e>t[0]?`needs-improvement`:`good`)(t.value,n),e(t)))}},Yl=e=>{requestAnimationFrame(()=>requestAnimationFrame(e))},Xl=()=>{var e,t;return(e=(t=Vl())==null?void 0:t.activationStart)==null?0:e},Zl=-1,Ql=new Set,$l=()=>document.visibilityState!==`hidden`||document.prerendering?1/0:0,eu=e=>{if(document.visibilityState===`hidden`){if(e.type===`visibilitychange`)for(let e of Ql)e();isFinite(Zl)||(Zl=e.type===`visibilitychange`?e.timeStamp:0,removeEventListener(`prerenderingchange`,eu,!0))}},tu=(e=!1)=>{if(e&&(Zl=1/0),Zl<0){var t;let e=Xl(),n=document.prerendering||(t=globalThis.performance.getEntriesByType(`visibility-state`).find(t=>t.name===`hidden`&&t.startTime>=e))==null?void 0:t.startTime;Zl=n==null?$l():n,addEventListener(`visibilitychange`,eu,!0),addEventListener(`prerenderingchange`,eu,!0),Jl(()=>{setTimeout(()=>{Zl=$l()})})}return{get firstHiddenTime(){return Zl},onHidden(e){Ql.add(e)}}},Q=(e,t=-1,n,r=0,i,a,o)=>{let s=Vl(),c=(s==null?void 0:s.navigationId)||0,l=`navigate`;return n?l=n:ql()>=0?l=`back-forward-cache`:s&&(document.prerendering||Xl()>0?l=`prerender`:document.wasDiscarded?l=`restore`:s.type&&(l=s.type.replace(/_/g,`-`))),{name:e,value:t,rating:`good`,delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+0xe8d4a51000}`,navigationType:l,navigationId:r||c,navigationInteractionId:i,navigationURL:a||(s==null?void 0:s.name),navigationStartTime:o||0}},$=(e,t,n={})=>{try{let r=e.filter(e=>PerformanceObserver.supportedEntryTypes.includes(e));if(r.length>0){let e=new PerformanceObserver(e=>{queueMicrotask(()=>{let n=e.getEntries();r.length>1&&n.sort((e,t)=>e.startTime+e.duration-(t.startTime+t.duration)),t(n)})});for(let t of r)e.observe(A({type:t,buffered:!0},n));return e}}catch(e){}},nu=e=>{var t,n;return((t=globalThis.PerformanceObserver)==null?void 0:t.supportedEntryTypes.includes(`soft-navigation`))&&typeof((n=globalThis.PerformanceSoftNavigation)==null||(n=n.prototype)==null?void 0:n.getLargestInteractionContentfulPaint)==`function`&&e&&e.reportSoftNavs},ru=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){let t=e.keys().next().value;t!==void 0&&e.delete(t)}},iu=e=>{let t=!1;return()=>{t||(e(),t=!0)}};var au=class{constructor(){k(this,`u`,void 0)}};let ou=e=>{document.prerendering?addEventListener(`prerenderingchange`,e,!0):e()},su=[1800,3e3],cu=(e,t={})=>{let n=nu(t);ou(()=>{let r=X(t,au),i=tu(),a,o=Q(`FCP`),s=$([`paint`],e=>{for(let t of e)t.name===`first-contentful-paint`&&(s.disconnect(),t.startTime<i.firstHiddenTime&&(o.value=Math.max(t.startTime-Xl(),0),o.entries.push(t),o.navigationId=t.navigationId||o.navigationId,a(!0)))});s&&(a=Z(e,o,su,t.reportAllChanges),Jl(n=>{o=Q(`FCP`,-1,`back-forward-cache`,o.navigationId,o.navigationInteractionId,o.navigationURL,ql()),a=Z(e,o,su,t.reportAllChanges),Yl(()=>{o.value=performance.now()-n.timeStamp,a(!0)})})),n&&$([`soft-navigation`],n=>{n.forEach(n=>{r.u&&n.navigationId&&ru(r.u,n);let i=Math.max((n.presentationTime||n.paintTime||0)-n.startTime,0);o=Q(`FCP`,i,`soft-navigation`,n.navigationId,n.interactionId,n.name,n.startTime),a=Z(e,o,su,t.reportAllChanges),a(!0)})},t)})},lu=[.1,.25],uu=e=>e.find(e=>{var t;return((t=e.node)==null?void 0:t.nodeType)===1})||e[0],du=(e,t={})=>{let n=X(t=Object.assign({},t),Bl),r=new WeakMap;n.t=e=>{var n;if(e!=null&&(n=e.sources)!=null&&n.length){let n=uu(e.sources),o=n==null?void 0:n.node;if(o){var i,a;let e=(i=(a=t.generateTarget)==null?void 0:a.call(t,o))==null?Wl(o):i;r.set(n,e)}}},((e,t={})=>{let n=tu();cu(iu(()=>{let r,i=Q(`CLS`,0),a=X(t,Bl),o=(n,o,s,c,l)=>{i=Q(`CLS`,0,n,o,s,c,l),a.o=0,r=Z(e,i,lu,t.reportAllChanges)},s=(e=!1)=>{a.o>i.value&&(i.value=a.o,i.entries=a.i),r(e)},c=e=>{s(!0),o(`soft-navigation`,e.navigationId,e.interactionId,e.name,e.startTime)},l=e=>{for(let t of e)t.entryType===`soft-navigation`?c(t):a.l(t);s()},u=[`layout-shift`];nu(t)&&u.push(`soft-navigation`);let d=$(u,l);d&&(r=Z(e,i,lu,t.reportAllChanges),n.onHidden(()=>{l(d.takeRecords()),r(!0)}),Jl(()=>{o(`back-forward-cache`,i.navigationId,i.navigationInteractionId,i.navigationURL,ql()),Yl(r)}),setTimeout(r))}))})(t=>{e((e=>{let t={};if(e.entries.length){var n;let i=e.entries.reduce((e,t)=>e.value>t.value?e:t);if(i!=null&&(n=i.sources)!=null&&n.length){let e=uu(i.sources);e&&(t={largestShiftTarget:r.get(e),largestShiftTime:i.startTime,largestShiftValue:i.value,largestShiftSource:e,largestShiftEntry:i,loadState:Hl(i.startTime)})}}return Object.assign(e,{attribution:t})})(t))},t)},fu=(e,t={})=>{let n=X(t=Object.assign({},t),au);nu(t)&&(n.u=new Map),cu(t=>{e((e=>{let t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:Hl(ql())};if(e.navigationType!==`soft-navigation`){if(e.entries.length){let n=Vl(),r=e.entries.at(-1);if(n){let i=n.responseStart,a=n.activationStart||0,o=Math.max(0,i-a);t={timeToFirstByte:o,firstByteToFCP:e.value-o,loadState:Hl(e.entries[0].startTime),navigationEntry:n,fcpEntry:r}}}}else{var r;let i=(r=n.u)==null?void 0:r.get(e.navigationId);i&&(t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:`complete`,navigationEntry:i})}return Object.assign(e,{attribution:t})})(t))},t)},pu=0,mu=1/0,hu=0,gu=e=>{for(let t of e)t.interactionId&&(mu=Math.min(mu,t.interactionId),hu=Math.max(hu,t.interactionId),pu=hu?(hu-mu)/7+1:0)},_u,vu=()=>{var e;return _u?pu:(e=performance.interactionCount)==null?0:e},yu=()=>{`interactionCount`in performance||_u||(_u=$([`event`],gu,{durationThreshold:0}))},bu=0;var xu=class{constructor(){k(this,`h`,[]),k(this,`v`,new Map),k(this,`p`,void 0),k(this,`m`,void 0)}M(){bu=vu(),this.h.length=0,this.v.clear()}T(e){let t=vu()-bu,n=Math.min(this.h.length-1,Math.floor(t/50));return!t||n!==-1||e!==`soft-navigation`&&e!==`back-forward-cache`?this.h[n]:{D:8,id:-1,entries:[]}}l(e){var t;if((t=this.p)==null||t.call(this,e),!e.interactionId&&e.entryType!==`first-input`)return;let n=this.h.at(-1),r=this.v.get(e.interactionId);if(r||this.h.length<10||e.duration>n.D){var i;if(r?e.duration>r.D?(r.entries=[e],r.D=e.duration):e.duration===r.D&&e.startTime===r.entries[0].startTime&&r.entries.push(e):(r={id:e.interactionId,entries:[e],D:e.duration},this.v.set(r.id,r),this.h.push(r)),this.h.sort((e,t)=>t.D-e.D),this.h.length>10){let e=this.h.splice(10);for(let t of e)this.v.delete(t.id)}(i=this.m)==null||i.call(this,r)}}};let Su=e=>{let t=`requestIdleCallback`in globalThis?1e3:0,n=globalThis.requestIdleCallback||setTimeout,r=globalThis.cancelIdleCallback||clearTimeout;if(document.visibilityState===`hidden`)e();else{let i=iu(e),a=-1,o=()=>{r(a),i()};addEventListener(`visibilitychange`,o,{once:!0,capture:!0}),a=n(()=>{removeEventListener(`visibilitychange`,o,{capture:!0}),i()},{timeout:t})}},Cu=[200,500],wu=(e,t={})=>{let n=X(t=Object.assign({},t),xu),r=[],i=[],a=0,o=new WeakMap,s=new WeakMap,c=!1,l=()=>{c||(Su(u),c=!0)},u=()=>{let e=new Set(n.h.map(e=>o.get(e.entries[0]))),t=i.length-10;i=i.filter((n,r)=>r>=t||e.has(n));let s=new Set;for(let e of i){let t=d(e.startTime,e.processingEnd);for(let e of t)s.add(e)}r=r.filter(e=>e.startTime>a||s.has(e)),c=!1};n.p=e=>{let n=e.startTime+e.duration,r;a=Math.max(a,e.processingEnd);for(let a=i.length-1;a>=0;a--){let o=i[a];if(Math.abs(n-o.renderTime)<=8){r=o,r.startTime=Math.min(e.startTime,r.startTime),r.processingStart=Math.min(e.processingStart,r.processingStart),r.processingEnd=Math.max(e.processingEnd,r.processingEnd),t.includeProcessedEventEntries&&r.entries.push(e);break}}r||(r={startTime:e.startTime,processingStart:e.processingStart,processingEnd:e.processingEnd,renderTime:n,entries:t.includeProcessedEventEntries?[e]:[]},i.push(r)),(e.interactionId||e.entryType===`first-input`)&&o.set(e,r),l()},n.m=e=>{if(!s.get(e)){var n;let o=(n=e.entries.find(e=>e.target))==null?void 0:n.target;if(o){var r,i;let n=(r=(i=t.generateTarget)==null?void 0:i.call(t,o))==null?Wl(o):r;s.set(e,n)}else{var a;let t=(a=e.entries.find(e=>e.targetSelector))==null?void 0:a.targetSelector;t&&s.set(e,t)}}};let d=(e,t)=>{let n=[];for(let i of r)if(!(i.startTime+i.duration<e)){if(i.startTime>t)break;n.push(i)}return n},f=e=>{if(e.entries.length===0){let t=e.navigationStartTime||0,n={processedEventEntries:[],longAnimationFrameEntries:[],inputDelay:0,processingDuration:0,presentationDelay:e.value,loadState:Hl(t)};return Object.assign(e,{attribution:n})}let t=e.entries[0],r=o.get(t),i=r.processingStart,a=Math.max(t.startTime+t.duration,i),c=Math.min(r.processingEnd,a),l=r.entries.sort((e,t)=>e.processingStart-t.processingStart),u=d(t.startTime,c),f=n.v.get(t.interactionId),p={interactionTarget:s.get(f),interactionType:t.name.startsWith(`key`)?`keyboard`:`pointer`,interactionTime:t.startTime,nextPaintTime:a,processedEventEntries:l,longAnimationFrameEntries:u,inputDelay:i-t.startTime,processingDuration:c-i,presentationDelay:a-c,loadState:Hl(t.startTime),longestScript:void 0,totalScriptDuration:void 0,totalStyleAndLayoutDuration:void 0,totalPaintDuration:void 0,totalUnattributedDuration:void 0};return(e=>{var t;let n=e.interactionTime,r=e.nextPaintTime;if(!((t=e.longAnimationFrameEntries)!=null&&t.length)||!n||!r)return;let i=e.inputDelay,a=e.processingDuration,o,s,c=0,l=0,u=0,d=0;for(let t of e.longAnimationFrameEntries){l=l+t.startTime+t.duration-t.styleAndLayoutStart;for(let e of t.scripts){let t=e.startTime+e.duration;if(t<n)continue;let r=t-Math.max(n,e.startTime),u=e.duration?r/e.duration*e.forcedStyleAndLayoutDuration:0;c+=r-u,l+=u,r>d&&(s=e.startTime<n+i?`input-delay`:e.startTime>=n+i+a?`presentation-delay`:`processing-duration`,o=e,d=r)}}let f=e.longAnimationFrameEntries.at(-1),p=f?f.startTime+f.duration:0;p>=n+i+a&&(u=r-p),o&&s&&(e.longestScript={entry:o,subpart:s,intersectingDuration:d}),e.totalScriptDuration=c,e.totalStyleAndLayoutDuration=l,e.totalPaintDuration=u,e.totalUnattributedDuration=r-n-c-l-u})(p),Object.assign(e,{attribution:p})};$([`long-animation-frame`],e=>{r=r.concat(e),l()},t),((e,t={})=>{if(!globalThis.PerformanceEventTiming||!(`interactionId`in PerformanceEventTiming.prototype))return;let n=tu();ou(()=>{var r;yu();let i,a=Q(`INP`),o=X(t,xu),s=(n,r,s,c,l)=>{o.M(),a=Q(`INP`,-1,n,r,s,c,l),i=Z(e,a,Cu,t.reportAllChanges)},c=()=>{let e=o.T(a.navigationType);e&&e.D!==a.value&&(a.value=e.D,a.entries=e.entries,i())},l=e=>{c(),i(!0),s(`soft-navigation`,e.navigationId,e.interactionId,e.name,e.startTime)},u=(e,t=!1)=>{Su(()=>{for(let t of e)t.entryType===`soft-navigation`?l(t):o.l(t);c(),t&&i(!0)})},d=[`event`,`first-input`];nu(t)&&d.push(`soft-navigation`);let f=$(d,u,A(A({},t),{},{durationThreshold:(r=t.durationThreshold)==null?40:r}));i=Z(e,a,Cu,t.reportAllChanges),f&&(n.onHidden(()=>{u(f.takeRecords(),!0)}),Jl(()=>{s(`back-forward-cache`,a.navigationId,a.navigationInteractionId,a.navigationURL,ql())}))})})(t=>{e(f(t))},t)};var Tu=class{constructor(){k(this,`p`,void 0),k(this,`u`,void 0)}l(e){var t;(t=this.p)==null||t.call(this,e)}};let Eu=[2500,4e3],Du=50,Ou=[];$([`resource`],e=>{for(let t of e)Ou.push(t),Ou.length>Du&&Ou.shift()});let ku=(e,t={})=>{(t=Object.assign({},t)).resourceBufferSize!=null&&(Du=t.resourceBufferSize);let n=X(t,Tu),r=new WeakMap;nu(t)&&(n.u=new Map),n.p=e=>{let n=e.element;if(n){var i,a;let o=(i=(a=t.generateTarget)==null?void 0:a.call(t,n))==null?Wl(n):i;r.set(e,o)}else e.id&&r.set(e,`#${e.id}`)},((e,t={})=>{let n=!1,r=nu(t);ou(()=>{let i,a=tu(),o=Q(`LCP`),s=X(t,Tu),c=(r,s,c,l,u)=>{o=Q(`LCP`,-1,r,s,c,l,u),i=Z(e,o,Eu,t.reportAllChanges),n=!1,r===`soft-navigation`&&(a=tu(!0))},l=e=>{var t;s.u&&e.navigationId&&ru(s.u,e),n||i(!0),c(`soft-navigation`,e.navigationId,e.interactionId,e.name,e.startTime);let r=(t=e.getLargestInteractionContentfulPaint)==null?void 0:t.call(e);r&&u([r])},u=e=>{t.reportAllChanges||r||(e=e.slice(-1));for(let t of e){if(!t)continue;if(t.entryType===`soft-navigation`){l(t);continue}let e=0,r=[],c=t.startTime;if(t.entryType===`largest-contentful-paint`)e=Math.max(t.startTime-Xl(),0),s.l(t),r=[t];else if(t.entryType===`interaction-contentful-paint`){var n;let i=t;if(!o.navigationId||`interactionId`in i&&i.interactionId!=o.navigationInteractionId)continue;c=((n=i.largestContentfulPaint)==null?void 0:n.renderTime)||0,e=Math.max(c-t.startTime,0),i.largestContentfulPaint&&(s.l(i.largestContentfulPaint),r=[i.largestContentfulPaint])}c<a.firstHiddenTime&&(o.value=e,o.entries=r,i())}},d=[`largest-contentful-paint`];r&&d.push(`interaction-contentful-paint`,`soft-navigation`);let f=$(d,u);if(f){i=Z(e,o,Eu,t.reportAllChanges);let a=[`keydown`,`click`,`visibilitychange`],s=e=>{if(e.isTrusted&&!n){let e=o.id;Su(()=>{if(!n){if(!r){f.disconnect();for(let e of a)removeEventListener(e,s,{capture:!0})}e===o.id&&(n=!0,i(!0))}})}};for(let e of a)addEventListener(e,s,{capture:!0});Jl(r=>{c(`back-forward-cache`,o.navigationId,o.navigationInteractionId,o.navigationURL,ql()),i=Z(e,o,Eu,t.reportAllChanges),Yl(()=>{o.value=performance.now()-r.timeStamp,n=!0,i(!0)})})}})})(t=>{e((e=>{let t={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:e.value};if(e.entries.length){var i,a,o;let s=e.entries.at(-1),c=s.url&&(Ou.findLast(e=>e.name===s.url)||performance.getEntriesByType(`resource`).findLast(e=>e.name===s.url)),l;t.target=r.get(s),t.lcpEntry=s,s.url&&(t.url=s.url),c&&(t.lcpResourceEntry=c);let u=0,d=0;if(e.navigationType===`soft-navigation`?(u=e.navigationStartTime||0,l=(o=n.u)==null?void 0:o.get(e.navigationId)):(l=Vl(),u=(i=l==null?void 0:l.activationStart)==null?0:i,d=(a=l==null?void 0:l.responseStart)==null?0:a),l){let n=Math.max(0,d-u),r=Math.max(n,c?(c.requestStart||c.startTime)-u:0),i=Math.min(e.value,Math.max(r,c?c.responseEnd-u:0));t=A(A({},t),{},{timeToFirstByte:n,resourceLoadDelay:r-n,resourceLoadDuration:i-r,elementRenderDelay:e.value-i,navigationEntry:l})}}return Object.assign(e,{attribution:t})})(t))},t)},Au=[800,1800],ju=e=>{document.prerendering?ou(()=>ju(e)):document.readyState===`complete`?setTimeout(e):addEventListener(`load`,()=>ju(e),!0)},Mu=(e,t={})=>{((e,t={})=>{let n=nu(t),r=Q(`TTFB`),i=Z(e,r,Au,t.reportAllChanges);ju(()=>{let a=Vl();if(a){let o=a.responseStart;r.value=Math.max(o-Xl(),0),r.entries=[a],i(!0),Jl(()=>{r=Q(`TTFB`,0,`back-forward-cache`,r.navigationId,r.navigationInteractionId,r.navigationURL,ql()),i=Z(e,r,Au,t.reportAllChanges),i(!0)}),n&&$([`soft-navigation`],n=>{n.forEach(n=>{n.navigationId&&(r=Q(`TTFB`,0,`soft-navigation`,n.navigationId,n.interactionId,n.name,n.startTime),r.entries=[n],i=Z(e,r,Au,t.reportAllChanges),i(!0))})},t)}})})(t=>{e((e=>{let t=e.entries[0],n={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0,navigationEntry:t};if(e.entries.length&&t instanceof PerformanceNavigationTiming){let r=t.activationStart||0,i=Math.max((t.workerStart||t.fetchStart||0)-r,0),a=Math.max(t.domainLookupStart-r,0),o=Math.max(t.connectStart-r,0),s=Math.max(t.connectEnd-r,0);n={waitingDuration:i,cacheDuration:a-i,dnsDuration:o-a,connectionDuration:s-o,requestDuration:e.value-s,navigationEntry:t}}return Object.assign(e,{attribution:n})})(t))},t)},Nu=[`CLS`,`INP`,`LCP`,`FCP`,`TTFB`],Pu={CLS:du,FCP:fu,LCP:ku,INP:wu,TTFB:Mu,FID:void 0},Fu=[`diag`,`perf`,`listeners`,`urlDocument`,`urlAttribution`,`includeRawAttribution`,`reportSoftNavs`,`pageManager`,`applyCustomLogRecordData`],Iu=e=>Math.round(Math.max(0,e)),Lu=e=>{var t,n,r,i;return{x:Math.round((t=e==null?void 0:e.x)==null?0:t),y:Math.round((n=e==null?void 0:e.y)==null?0:n),width:Math.round((r=e==null?void 0:e.width)==null?0:r),height:Math.round((i=e==null?void 0:e.height)==null?0:i)}},Ru=e=>{let t=typeof e;return t===`number`||t===`string`||t===`boolean`},zu=(e,t)=>{let n={},r=e.attribution;try{if(r.longAnimationFrameEntries.length>0){let e=new Map;for(let t of r.longAnimationFrameEntries)for(let n of t.scripts){let t=n.sourceURL||`(inline)`;t.length>2048&&(t=`${t.substring(0,2048)}...`);let r=e.get(t);r?(r.totalDuration+=n.duration,r.styleAndLayoutDuration+=n.forcedStyleAndLayoutDuration,r.count++):e.set(t,{totalDuration:n.duration,styleAndLayoutDuration:n.forcedStyleAndLayoutDuration,count:1})}e.size>0&&(n[`${zl}loaf_scripts`]=JSON.stringify(Object.fromEntries([...e].sort((e,t)=>t[1].totalDuration-e[1].totalDuration).slice(0,250).map(([e,t])=>[e,{total_duration:Math.round(t.totalDuration),style_and_layout_duration:Math.round(t.styleAndLayoutDuration),count:t.count}]))))}}catch(e){t.error(`error building loaf scripts for INP`,e)}return n},Bu=(e,t)=>{let n={};try{let t=e.entries;if(t.length>0){let e=t.slice(0,50).map(e=>{var t;let n=e.sources[0];return{selector:yt((t=n==null?void 0:n.node)==null?null:t),startRect:Lu(n==null?void 0:n.previousRect),endRect:Lu(n==null?void 0:n.currentRect)}}),r=zl;n[`${r}clsLayoutShifts`]=JSON.stringify(e),t.length>50&&(n[`${r}clsLayoutShiftsDroppedCount`]=t.length-50)}}catch(e){t.error(`error building CLS layout shifts`,e)}return n},Vu=(e,t)=>{let n={};try{var r,i;let t=(r=e.entries.find(e=>e.target))==null?void 0:r.target,a=t==null||(i=t.tagName)==null?void 0:i.toLowerCase();a&&(n[`${zl}element_type`]=a)}catch(e){t.error(`error building INP element type attribution`,e)}return n},Hu=(e,t)=>{let n={},r=e.attribution.navigationEntry;if(r)try{var i;let e=Iu(r.redirectEnd-r.redirectStart),t=Iu(r.domainLookupEnd-r.domainLookupStart),a=Iu(r.secureConnectionStart>0?r.secureConnectionStart-r.connectStart:r.connectEnd-r.connectStart),o=Iu(r.secureConnectionStart>0?r.connectEnd-r.secureConnectionStart:0),s=Math.max((i=r.finalResponseHeadersStart)==null?0:i,r.responseStart),c=Iu(s-r.requestStart),l=Math.round(r.responseEnd-r.startTime),u=Iu(l-e-t-a-o-c),d=zl;n[`${d}redirect`]=e,n[`${d}domainLookup`]=t,n[`${d}tcpConnection`]=a,n[`${d}tlsNegotiation`]=o,n[`${d}serverResponse`]=c,n[`${d}unattributed`]=u}catch(e){t.error(`error computing TTFB timing breakdown`,e)}else t.debug(`TTFB navigationEntry unavailable, skipping timing breakdown`);return n},Uu=(e,t)=>{let n={};try{var r;let t=(r=e.attribution.lcpEntry)==null?void 0:r.element;if(t){let e=t.tagName.toLowerCase(),r=JSON.stringify(Lu(t.getBoundingClientRect())),i=zl;n[`${i}elementType`]=e,n[`${i}elementBoundingRect`]=r}}catch(e){t.error(`error building LCP element attribution`,e)}return n};var Wu=class extends Y{constructor(e={}){let{diag:t,perf:n,listeners:r=Pu,urlDocument:i,urlAttribution:a=!0,includeRawAttribution:o=!0,reportSoftNavs:s=!0,pageManager:c,applyCustomLogRecordData:l}=e,u=Ut(e,Fu);super({instrumentationName:`WebVitalsInstrumentation`,instrumentationVersion:`1.0.0`,diag:t,perf:n,config:u}),k(this,`_listeners`,void 0),k(this,`_urlDocument`,void 0),k(this,`_urlAttribution`,void 0),k(this,`_includeRawAttribution`,void 0),k(this,`_softNavsActive`,void 0),k(this,`_pageManager`,void 0),k(this,`_attributedPage`,{INP:void 0,LCP:void 0,CLS:void 0,FCP:void 0,TTFB:void 0}),k(this,`_largestShiftTargetForCLS`,null),k(this,`_clsMetricId`,void 0),k(this,`_applyCustomLogRecordData`,void 0),k(this,`_listenersRegistered`,!1),this._listeners=r,this._urlDocument=i==null?window.document:i,this._urlAttribution=a,this._includeRawAttribution=o,this._softNavsActive=s&&Kt(`soft-navigation`),this._pageManager=c==null?Mn.getPageManager():c,this._applyCustomLogRecordData=l,this._config.enabled!==!1&&this.enable()}onDisable(){this._diag.debug(`WebVitalsInstrumentation disabled, pausing emission`)}enable(){typeof PerformanceObserver<`u`?super.enable():this._diag.debug(`PerformanceObserver not supported, web vitals will not be collected`)}onEnable(){if(this._listenersRegistered){this._diag.debug(`WebVitalsInstrumentation listeners already registered, resuming emission`);return}this._listenersRegistered=!0,Nu.forEach(e=>{var t,n;let r=e!==`TTFB`&&this._softNavsActive;if(this._urlAttribution){var i,a;(i=(a=this._listeners)[e])==null||i.call(a,e=>{if(this._isEnabled){if(e.name===`CLS`){let t=e,n=t.attribution.largestShiftTarget;this._clsMetricId===t.id?this._largestShiftTargetForCLS!==n&&(this._largestShiftTargetForCLS=n,this._attributedPage.CLS=this._currentAttributedPage()):(this._clsMetricId=t.id,this._largestShiftTargetForCLS=n,this._attributedPage.CLS=this._currentAttributedPage())}else this._attributedPage[e.name]=this._currentAttributedPage()}},{reportAllChanges:!0,reportSoftNavs:r})}(t=(n=this._listeners)[e])==null||t.call(n,e=>{this._isEnabled&&this._emitWebVital(e)},{reportSoftNavs:r})})}_currentAttributedPage(){var e,t,n;return{fullURL:this._urlDocument.URL,path:(e=this._pageManager.getCurrentRoute())==null?void 0:e.path,pageID:(t=this._pageManager.getCurrentPageId())==null?void 0:t,label:(n=this._pageManager.getPageLabel())==null?void 0:n}}_getTimeForMetric(e){var t;if(e.name===`INP`&&e.attribution.interactionTime!==void 0)return this.perf.epochMillisFromOrigin(e.attribution.interactionTime);if(e.name===`CLS`){let t=e.entries.length>0?Math.min(...e.entries.map(e=>e.startTime)):e.attribution.largestShiftTime;if(t!==void 0)return this.perf.epochMillisFromOrigin(t)}if(e.name===`TTFB`)return this.perf.getZeroTime();let n=(t=e.entries[e.entries.length-1])==null?void 0:t.startTime;return n===void 0?this.perf.getNowMillis():this.perf.epochMillisFromOrigin(n)}_emitWebVital(e){let t=this._attributedPage[e.name],n=this._getTimeForMetric(e),r=this.userSessionManager.getSessionPartIdAt(n),i={eventName:`browser.web_vital`,severityNumber:M.INFO,attributes:A(A(A(A(A(A(A(A(A({[O]:`ux.web_vital`,"browser.web_vital.name":e.name.toLowerCase(),"browser.web_vital.value":e.value,"browser.web_vital.delta":e.delta,"browser.web_vital.rating":e.rating,"browser.web_vital.id":e.id,"browser.web_vital.navigation_type":e.navigationType},e.navigationId===void 0?{}:{"browser.web_vital.navigation_id":e.navigationId}),e.navigationInteractionId===void 0?{}:{"browser.web_vital.interaction_id":e.navigationInteractionId}),r===null?{}:{[Et]:r}),t?{[St]:e.navigationURL!=null&&(e.navigationType===`soft-navigation`||this._softNavsActive)?e.navigationURL:t.fullURL,[Ct]:t.path,[wt]:t.pageID,[Tt]:t.label}:{}),e.name===`INP`?zu(e,this._diag):{}),e.name===`INP`?Vu(e,this._diag):{}),e.name===`TTFB`?Hu(e,this._diag):{}),e.name===`CLS`?Bu(e,this._diag):{}),e.name===`LCP`?Uu(e,this._diag):{}),body:this._includeRawAttribution&&e.attribution!=null?JSON.stringify(Object.fromEntries(Object.entries(e.attribution).filter(([,e])=>Ru(e)))):void 0,timestamp:L(n)};this._applyCustomLogRecordData&&Cr(()=>{var e;return(e=this._applyCustomLogRecordData)==null?void 0:e.call(this,i)},e=>{e&&this._diag.error(`applyCustomLogRecordData hook failed`,e)},!0),this.logger.emit(i)}};let Gu=(e={},{logManager:t,userSessionManager:n,pageManager:r,limitManager:i,signalBuffer:a})=>{var o,s,c,l,u,d,f,p,m,h,g,ee,_,te;let v=[];if((o=e.omit)!=null&&o.has(`exception`)||v.push(new Tl(e.exception)),(s=e.omit)!=null&&s.has(`click`)||v.push(new Cl(e.click)),(c=e.omit)!=null&&c.has(`rage-click`)||v.push(new jl(e[`rage-click`])),(l=e.omit)!=null&&l.has(`max-scroll-depth`)||v.push(new Ol(e[`max-scroll-depth`])),(u=e.omit)!=null&&u.has(`first-interaction`)||v.push(new El(e[`first-interaction`])),(d=e.omit)!=null&&d.has(`web-vital`)||v.push(new Wu(A(A({},e[`web-vital`]),{},{pageManager:r}))),(f=e.omit)!=null&&f.has(`loaf`)||v.push(new Dl(A({},e.loaf))),(p=e.omit)!=null&&p.has(`user-timing`)||v.push(new Rl(e[`user-timing`])),(m=e.omit)!=null&&m.has(`element-timing`)||v.push(new wl(A({limitManager:i},e[`element-timing`]))),(h=e.omit)!=null&&h.has(`soft-navigation-performance`)||v.push(new Pl(A({limitManager:i,signalBuffer:a},e[`soft-navigation-performance`]))),(g=e.omit)!=null&&g.has(`document-load`)||v.push(new bl(e[`document-load`])),v.push(new Al(A({pageManager:r},e.navigation))),(ee=e.omit)!=null&&ee.has(`server-timing`)||v.push(new Ml(A({limitManager:i},e[`server-timing`]))),!((_=e.omit)!=null&&_.has(`@opentelemetry/instrumentation-fetch`))){var y,b,ne,re;v.push(new tl(A(A({},e[`@opentelemetry/instrumentation-fetch`]),{},{ignoreUrls:[...(y=(b=e.network)==null?void 0:b.ignoreUrls)==null?[]:y,...(ne=(re=e[`@opentelemetry/instrumentation-fetch`])==null?void 0:re.ignoreUrls)==null?[]:ne]})))}if(!((te=e.omit)!=null&&te.has(`@opentelemetry/instrumentation-xml-http-request`))){var ie,ae,oe,se;v.push(new hl(A(A({},e[`@opentelemetry/instrumentation-xml-http-request`]),{},{ignoreUrls:[...(ie=(ae=e.network)==null?void 0:ae.ignoreUrls)==null?[]:ie,...(oe=(se=e[`@opentelemetry/instrumentation-xml-http-request`])==null?void 0:se.ignoreUrls)==null?[]:oe]})))}e[`empty-root`]&&v.push(new xl(A({},e[`empty-root`])));for(let e of v)e instanceof Y&&(n&&e.setUserSessionManager(n),t&&e.setLogManager(t),i&&e.setLimitManager(i));return v},Ku=e=>{if(e!==void 0){if(typeof e!=`string`)throw Error(`appID must be a string, or omitted if not using Embrace. Received ${String(e)}`);if(e.length!==5)throw Error(`appID should be 5 characters long, or omitted if not using Embrace. Received "${e}"`);return e}},qu=e=>{if(e===void 0)return`EmbIOAppVersionX.X.X`;if(typeof e!=`string`)throw Error(`if appVersion is specified, it must be a string. Received ${String(e)}`);let t=e.trim();if(t===``)throw Error(`if appVersion is specified, it cannot be an empty string.`);return t},Ju=({appID:e,appVersion:t,resource:n=Wi(),spanExporters:r=[],logExporters:i=[],spanProcessors:a=[],propagator:o=null,defaultInstrumentationConfig:s,instrumentations:c=[],contextManager:l=null,logProcessors:u=[],attributeScrubbers:d=[],enableDefaultAttributeScrubbing:f=!0,additionalQueryParamsToScrub:m=[],logLevel:h=p.ERROR,embraceDataURL:g,embraceConfigURL:ee,diagLogger:_=T.createComponentLogger({namespace:`embrace-sdk`}),dynamicSDKConfigManager:te,dynamicSDKConfig:v,registerGlobally:y=!0,blockNetworkSpanForwarding:b=!1,restrictedProtocols:ne=new Set([`file:`]),useDocumentTitleAsPageLabel:re=!0}={})=>{try{var ae;if(y){let e=Rc.registered();if(e!==null)return _.warn(`SDK has already been successfully initialized, skipping this invocation of initSDK`),e}if(T.setLogger(new ie,{logLevel:h}),typeof window>`u`)return _.warn(`browser not detected, skipping initialization`),!1;let p=new Vt,oe=p.getNowMillis();window.addEventListener(`pageshow`,e=>Bt(p.epochMillisFromOrigin(e.timeStamp)));let se=Ku(e),ce=qu(t),le=se!==void 0;if(!le&&!i.length&&!r.length)throw Error(`when appID is omitted, at least one logExporter or spanExporter must be set`);if(ne.has(window.location.protocol))throw Error(`not initializing due to restricted protocol: ${window.location.protocol}`);if(le&&typeof CompressionStream>`u`)throw Error(`CompressionStream is not supported in this browser and required for data compression.`);let ue=e==null?void 0:e,de=new Lt({namespace:ue,storage:window.localStorage,diag:_}),fe=new Lt({namespace:ue,storage:window.sessionStorage,diag:_}),pe=Mc().merge(n).merge(Nc({diagLogger:_,appVersion:ce,tabStorage:fe})),me=Yu({registerGlobally:y,sdkLocalStorage:de}),he=me.getEmbraceUserId();if(le&&!he)throw Error(`userID is required when using Embrace exporter`);let ge=te==null?new Ms({appID:se,appVersion:ce,embraceConfigURL:ee,defaultConfig:v,deviceId:he,storage:de}):te;ge.refreshRemoteConfig();let _e=new zs({dynamicConfigManager:ge,deviceId:he,blockNetworkSpanForwarding:b});if(!_e.isSDKEnabled())return _.debug(`SDK is disabled, skipping initialization.`),!1;let ve=Rt({featureManager:_e,diag:_,registerGlobally:y,defaultInstrumentationConfig:s,propagator:o}),ye=new Fs(Ns),be=[...f?Lc(m):[],...d],x=Xu({limitManager:ye,perf:p,registerGlobally:y,sdkLocalStorage:de,visibilityDoc:window.document,dynamicConfigManager:ge}),xe,Se;le&&(xe=new mc({exporter:new Ds({appID:se,embraceDataURL:g,userID:he}),limitManager:ye,userSessionManager:x}),Se=new va({exporter:new ws({appID:se,embraceDataURL:g,userID:he})}));let Ce=$u({useDocumentTitleAsPageLabel:re,registerGlobally:y,userSessionManager:x,perf:p}),we=s!=null&&(ae=s.omit)!=null&&ae.has(`soft-navigation-performance`)?void 0:new Ec,{tracerProvider:Te,embraceTraceManager:Ee}=Zu({resource:pe,userManager:me,spanExporters:r,spanProcessors:a,propagator:ve?new Dc:o,contextManager:l,attributeScrubbers:be,registerGlobally:y,embraceSpanProcessor:xe,pageManager:Ce,signalBuffer:we});x.setTracerProvider(Te),x.startSessionPartInternal({reason:`init`});let{loggerProvider:De,embraceLogManager:Oe}=Qu({resource:pe,userManager:me,logExporters:i,logProcessors:u,userSessionManager:x,limitManager:ye,attributeScrubbers:be,perf:p,registerGlobally:y,embraceLogProcessor:Se,sdkLocalStorage:de,pageManager:Ce,visibilityDoc:window.document,signalBuffer:we});mr(y?{instrumentations:[Gu(s,{pageManager:Ce,limitManager:ye,signalBuffer:we}),...c]}:{tracerProvider:Te,loggerProvider:De,instrumentations:[Gu(s,{logManager:Oe,userSessionManager:x,pageManager:Ce,limitManager:ye,signalBuffer:we}),...c]}),_.info(`successfully initialized the SDK`);let S={setDynamicConfig:e=>{ge.setConfig(e)},flush:function(){var e=P(function*(){yield Te.forceFlush(),yield De.forceFlush()});return function(){return e.apply(this,arguments)}}(),log:Oe,trace:Ee,session:x,user:me,page:Ce};return y&&Rc.register(S),x.recordSDKStartupDuration(p.getNowMillis()-oe),S}catch(e){let t=e instanceof Error?e.message:`Unknown error.`;return _.error(`failed to initialize the SDK: ${t}`),!1}},Yu=({registerGlobally:e,sdkLocalStorage:t})=>{let n=new Gs({storage:t});return e&&er.setGlobalUserManager(n),n},Xu=({limitManager:e,perf:t,registerGlobally:n,sdkLocalStorage:r,visibilityDoc:i,dynamicConfigManager:a})=>{let o=new cc({limitManager:e,perf:t,storage:r,visibilityDoc:i,dynamicConfigManager:a});return n&&zn.setGlobalUserSessionManager(o),o},Zu=({resource:e,userManager:t,spanExporters:n,spanProcessors:r=[],propagator:i=null,contextManager:a=null,attributeScrubbers:o,registerGlobally:s,embraceSpanProcessor:c,pageManager:l,signalBuffer:u})=>{let d=[...r,new uc,new fc,new Tc({userManager:t}),new _c({pageManager:l}),new Sc({attributeScrubbers:o}),...u?[new xc({buffer:u})]:[]];n==null||n.forEach(e=>{d.push(new Fa({exporter:e}))}),c&&d.push(c);let f=new $a({resource:e,spanProcessors:d,spanLimits:{attributeCountLimit:Ns.maxAllowed.session_property*2,eventCountLimit:Ns.maxAllowed.breadcrumb*2}}),p=new Vs({tracerProvider:s?void 0:f});return s&&(qn.setGlobalTraceManager(p),f.register({contextManager:a||new Xa,propagator:i})),{tracerProvider:f,embraceTraceManager:p}},Qu=({resource:e,userManager:t,logExporters:n,logProcessors:r,userSessionManager:i,limitManager:a,attributeScrubbers:o,perf:s,registerGlobally:c,embraceLogProcessor:l,sdkLocalStorage:u,pageManager:d,visibilityDoc:f,signalBuffer:p})=>{let m=[...r,new wc({userSessionManager:i}),new lc,new dc,new Cc({userManager:t}),new hc({attributeScrubbers:o}),new gc({pageManager:d}),...p?[new bc({buffer:p})]:[]];n==null||n.forEach(e=>{m.push(new va({exporter:e}))}),l&&m.push(l);let h=new da({resource:e,processors:m}),g=new Ls({userSessionManager:i,limitManager:a,loggerProvider:c?void 0:h,perf:s,storage:u,visibilityDoc:f});return c&&(dr.setGlobalLoggerProvider(h),Tn.setGlobalLogManager(g)),{loggerProvider:h,embraceLogManager:g}},$u=({useDocumentTitleAsPageLabel:e,registerGlobally:t,userSessionManager:n,perf:r})=>{let i=new Rs({useDocumentTitleAsPageLabel:e,userSessionManager:n,perf:r});return t&&Mn.setGlobalPageManager(i),i};return Object.defineProperty(e,"DiagLogLevel",{enumerable:!0,get:function(){return p}}),e.attributes=tr,e.initSDK=Ju,e.log=Tn,e.page=Mn,e.session=zn,e.trace=qn,e.user=er,e})({});
//# sourceMappingURL=embrace-web-sdk.js.map