@sprig-technologies/sprig-browser 2.30.1 → 2.30.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var K=Object.defineProperty,B=(e,t,s)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,a=(e,t,s)=>(B(e,typeof t!="symbol"?t+"":t,s),s),A=(e=>(e.Closed="close.click",e.Complete="survey.completed",e.FeedbackClosed="feedback.closed",e.PageChange="page.change",e.API="api",e.Override="override",e))(A||{}),D=(e=>(e.ReplayCapture="replay.capture",e.FeedbackButtonLoaded="feedback.button.loaded",e.SDKReady="sdk.ready",e.SurveyAppeared="survey.appeared",e.SurveyClosed="survey.closed",e.SurveyDimensions="survey.dimensions",e.SurveyFadingOut="survey.fadingOut",e.SurveyHeight="survey.height",e.SurveyPresented="survey.presented",e.SurveyLifeCycle="survey.lifeCycle",e.SurveyWidth="survey.width",e.SurveyWillClose="survey.willClose",e.SurveyWillPresent="survey.will.present",e.CloseSurveyOnOverlayClick="close.survey.overlayClick",e.VisitorIDUpdated="visitor.id.updated",e.QuestionAnswered="question.answered",e))(D||{});const G={FEEDBACK_BUTTON_LOADED:"feedback.button.loaded",SDK_READY:"sdk.ready",SURVEY_APPEARED:"survey.appeared",SURVEY_CLOSED:"survey.closed",SURVEY_DIMENSIONS:"survey.dimensions",SURVEY_FADING_OUT:"survey.fadingOut",SURVEY_HEIGHT:"survey.height",SURVEY_WIDTH:"survey.width",SURVEY_PRESENTED:"survey.presented",SURVEY_LIFE_CYCLE:"survey.lifeCycle",SURVEY_WILL_CLOSE:"survey.willClose",SURVEY_WILL_PRESENT:"survey.will.present",QUESTION_ANSWERED:"question.answered",REPLAY_CAPTURE:"replay.capture",CLOSE_SURVEY_ON_OVERLAY_CLICK:"close.survey.overlayClick",VISITOR_ID_UPDATED:"visitor.id.updated",DATA:{DISMISS_REASONS:{API:"api",CLOSED:"close.click",COMPLETE:"survey.completed",PAGE_CHANGE:"page.change",OVERRIDE:"override"},SURVEY_ID:"survey.id"}};let g;const z=new Uint8Array(16);function Q(){if(!g&&(g=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!g))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return g(z)}const n=[];for(let e=0;e<256;++e)n.push((e+256).toString(16).slice(1));function X(e,t=0){return n[e[t+0]]+n[e[t+1]]+n[e[t+2]]+n[e[t+3]]+"-"+n[e[t+4]]+n[e[t+5]]+"-"+n[e[t+6]]+n[e[t+7]]+"-"+n[e[t+8]]+n[e[t+9]]+"-"+n[e[t+10]]+n[e[t+11]]+n[e[t+12]]+n[e[t+13]]+n[e[t+14]]+n[e[t+15]]}const Z=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),U={randomUUID:Z};function ee(e,t,s){if(U.randomUUID&&!t&&!e)return U.randomUUID();e=e||{};const r=e.random||(e.rng||Q)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,X(r)}var te=class extends Error{constructor(e,t,s){super(`Possible EventEmitter memory leak detected. ${s} ${t.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=e,this.type=t,this.count=s,this.name="MaxListenersExceededWarning"}},k=class{static listenerCount(e,t){return e.listenerCount(t)}constructor(){this.events=new Map,this.maxListeners=k.defaultMaxListeners,this.hasWarnedAboutPotentialMemoryLeak=!1}_emitInternalEvent(e,t,s){this.emit(e,t,s)}_getListeners(e){return Array.prototype.concat.apply([],this.events.get(e))||[]}_removeListener(e,t){const s=e.indexOf(t);return s>-1&&e.splice(s,1),[]}_wrapOnceListener(e,t){const s=(...r)=>(this.removeListener(e,s),t.apply(this,r));return Object.defineProperty(s,"name",{value:t.name}),s}setMaxListeners(e){return this.maxListeners=e,this}getMaxListeners(){return this.maxListeners}eventNames(){return Array.from(this.events.keys())}emit(e,...t){const s=this._getListeners(e);return s.forEach(r=>{r.apply(this,t)}),s.length>0}addListener(e,t){this._emitInternalEvent("newListener",e,t);const s=this._getListeners(e).concat(t);if(this.events.set(e,s),this.maxListeners>0&&this.listenerCount(e)>this.maxListeners&&!this.hasWarnedAboutPotentialMemoryLeak){this.hasWarnedAboutPotentialMemoryLeak=!0;const r=new te(this,e,this.listenerCount(e));console.warn(r)}return this}on(e,t){return this.addListener(e,t)}once(e,t){return this.addListener(e,this._wrapOnceListener(e,t))}prependListener(e,t){const s=this._getListeners(e);if(s.length>0){const r=[t].concat(s);this.events.set(e,r)}else this.events.set(e,s.concat(t));return this}prependOnceListener(e,t){return this.prependListener(e,this._wrapOnceListener(e,t))}removeListener(e,t){const s=this._getListeners(e);return s.length>0&&(this._removeListener(s,t),this.events.set(e,s),this._emitInternalEvent("removeListener",e,t)),this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){return e?this.events.delete(e):this.events.clear(),this}listeners(e){return Array.from(this._getListeners(e))}listenerCount(e){return this._getListeners(e).length}rawListeners(e){return this.listeners(e)}},C=k;C.defaultMaxListeners=10;const se=new C,w=e=>new Promise(t=>{setTimeout(()=>{t()},e)}),re=({"userleap-platform":e})=>e!=="web";class x{constructor(t){a(this,"storage"),a(this,"tempStorage",{}),a(this,"isStorageAvailable"),this.storage=window[t],this.isStorageAvailable=this.checkIfStorageAvailable()}checkIfStorageAvailable(){try{const t="__storage_test__";return this.storage.setItem(t,t),this.storage.removeItem(t),!0}catch{return!1}}setItem(t,s){this.isStorageAvailable?this.storage.setItem(t,s):this.tempStorage[t]=s}getItem(t){return this.isStorageAvailable?this.storage.getItem(t):this.tempStorage[t]}removeItem(t){this.isStorageAvailable?this.storage.removeItem(t):delete this.tempStorage[t]}clear(){this.isStorageAvailable?this.storage.clear():this.tempStorage={}}}const ne=new x("sessionStorage"),ie=new x("localStorage");class oe{constructor(t){a(this,"payload"),a(this,"promise"),a(this,"reject",()=>{}),a(this,"resolve",()=>{}),this.payload=t,this.promise=new Promise((s,r)=>{this.reject=r,this.resolve=s})}resolveRequest(t){this.resolve(t)}}const I={replay:null},ae=e=>{I.replay=e},le=()=>{const e=[];return I.replay&&e.push("replay"),e.join(",")},ce={RATELIMIT_RESET_DEFAULT:10};let T=!1,P="",_=!1,M=!1,E=[];const ue=e=>e._config&&e._config.installationMethod?e._config.installationMethod:e._gtm?"web-gtm":e._segment?"web-segment":"web-snippet",N=e=>{var t;(t=e?.blockedURI)!=null&&t.includes(window.UserLeap._API_URL)&&(M=!0,console.warn(`[Sprig] ${e.blockedURI} is blocked by Content-Security-Policy`),document.removeEventListener("securitypolicyviolation",N))},V=(e="")=>{T=!0,P=e};function de(e={}){const t={"Content-Type":"application/json","userleap-platform":"web","x-ul-sdk-version":"2.30.1","x-ul-installation-method":ue(e),"sprig-modules":le()};if(e.envId&&(t["x-ul-environment-id"]=e.envId),e.token&&(t.Authorization="Bearer "+e.token),e.userId&&(t["x-ul-user-id"]=e.userId),e.visitorId&&(t["x-ul-visitor-id"]=e.visitorId),e.partnerAnonymousId&&(t["x-ul-anonymous-id"]=e.partnerAnonymousId),e.mobileHeadersJSON){const s=JSON.parse(e.mobileHeadersJSON);Object.assign(t,s)}return e.locale&&(t["accept-language"]=e.locale),window.previewMode&&(t["x-ul-preview-mode"]="1"),t}const W=async({shouldDropOnRateLimit:e,...t})=>{if(e)return{status:429};{const s=new oe(t);return E.push(s),s.promise}},p=async(e,t)=>{const{retries:s=0,shouldDropOnRateLimit:r=!1,shouldRetryRequest:m=!1,...l}=t,c={url:e,options:l,retries:s,shouldDropOnRateLimit:r};if(_&&!m)return W(c);const h={ok:!1,reportError:!1};if(T)return console.info(`UserLeap - ${P}`),h;try{const o=await fetch(e,l);if(o.status===429)if(!_&&!r||m){_=!0;const i=o.headers.has("ratelimit-reset")?Number(o.headers.get("ratelimit-reset")):ce.RATELIMIT_RESET_DEFAULT;return await w(i*1e3),p(e,{...l,shouldDropOnRateLimit:r,shouldRetryRequest:!0})}else return W(c);if(_=!1,E.length&&(E.map(i=>{const y=i.payload;p(y.url,{...y.options,retries:y.retries,shouldDropOnRateLimit:y.shouldDropOnRateLimit}).then(J=>{i.resolveRequest(J)})}),E=[]),o.ok){if(o.status===249)return V(),h;const i=await o.text();try{return i&&i!=="OK"&&(o.json=JSON.parse(i)),o}catch{return{ok:!1,reportError:!1,error:new Error(`failed parsing response json for ${e} - ${i}`)}}}return o}catch(o){const i=s+1;return i>5||M?{ok:!1,reportError:!1,error:o}:(await w(Math.pow(2,s)*1e3),p(e,{...l,retries:i}))}},u={Error:1,Warn:2,Info:3,Debug:4};let b=1e3,f=u.Debug,d=[];const he=e=>{const t=Object.entries(u).find(s=>s[1]===e);return t?.[0]??""},pe=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),ve=(e,t)=>`${pe(t)}:${e}`,me=()=>{d=d.filter(e=>e.level<=f)},ye=()=>{d.length>b&&d.shift()},S=(e,t)=>{e>f||(d.push({level:e,line:ve(t,new Date)}),ye())},Y=e=>{S(u.Debug,e)},ge=e=>{S(u.Info,e)},j=e=>{S(u.Warn,e)},_e=e=>{S(u.Error,e)},Ee=()=>d.map(e=>e.line),fe=()=>new TextEncoder().encode(Ee().join(`
1
+ var K=Object.defineProperty,B=(e,t,s)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,a=(e,t,s)=>(B(e,typeof t!="symbol"?t+"":t,s),s),A=(e=>(e.Closed="close.click",e.Complete="survey.completed",e.FeedbackClosed="feedback.closed",e.PageChange="page.change",e.API="api",e.Override="override",e))(A||{}),D=(e=>(e.ReplayCapture="replay.capture",e.FeedbackButtonLoaded="feedback.button.loaded",e.SDKReady="sdk.ready",e.SurveyAppeared="survey.appeared",e.SurveyClosed="survey.closed",e.SurveyDimensions="survey.dimensions",e.SurveyFadingOut="survey.fadingOut",e.SurveyHeight="survey.height",e.SurveyPresented="survey.presented",e.SurveyLifeCycle="survey.lifeCycle",e.SurveyWidth="survey.width",e.SurveyWillClose="survey.willClose",e.SurveyWillPresent="survey.will.present",e.CloseSurveyOnOverlayClick="close.survey.overlayClick",e.VisitorIDUpdated="visitor.id.updated",e.QuestionAnswered="question.answered",e))(D||{});const G={FEEDBACK_BUTTON_LOADED:"feedback.button.loaded",SDK_READY:"sdk.ready",SURVEY_APPEARED:"survey.appeared",SURVEY_CLOSED:"survey.closed",SURVEY_DIMENSIONS:"survey.dimensions",SURVEY_FADING_OUT:"survey.fadingOut",SURVEY_HEIGHT:"survey.height",SURVEY_WIDTH:"survey.width",SURVEY_PRESENTED:"survey.presented",SURVEY_LIFE_CYCLE:"survey.lifeCycle",SURVEY_WILL_CLOSE:"survey.willClose",SURVEY_WILL_PRESENT:"survey.will.present",QUESTION_ANSWERED:"question.answered",REPLAY_CAPTURE:"replay.capture",CLOSE_SURVEY_ON_OVERLAY_CLICK:"close.survey.overlayClick",VISITOR_ID_UPDATED:"visitor.id.updated",DATA:{DISMISS_REASONS:{API:"api",CLOSED:"close.click",COMPLETE:"survey.completed",PAGE_CHANGE:"page.change",OVERRIDE:"override"},SURVEY_ID:"survey.id"}};let g;const z=new Uint8Array(16);function Q(){if(!g&&(g=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!g))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return g(z)}const n=[];for(let e=0;e<256;++e)n.push((e+256).toString(16).slice(1));function X(e,t=0){return n[e[t+0]]+n[e[t+1]]+n[e[t+2]]+n[e[t+3]]+"-"+n[e[t+4]]+n[e[t+5]]+"-"+n[e[t+6]]+n[e[t+7]]+"-"+n[e[t+8]]+n[e[t+9]]+"-"+n[e[t+10]]+n[e[t+11]]+n[e[t+12]]+n[e[t+13]]+n[e[t+14]]+n[e[t+15]]}const Z=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),U={randomUUID:Z};function ee(e,t,s){if(U.randomUUID&&!t&&!e)return U.randomUUID();e=e||{};const r=e.random||(e.rng||Q)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,X(r)}var te=class extends Error{constructor(e,t,s){super(`Possible EventEmitter memory leak detected. ${s} ${t.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=e,this.type=t,this.count=s,this.name="MaxListenersExceededWarning"}},k=class{static listenerCount(e,t){return e.listenerCount(t)}constructor(){this.events=new Map,this.maxListeners=k.defaultMaxListeners,this.hasWarnedAboutPotentialMemoryLeak=!1}_emitInternalEvent(e,t,s){this.emit(e,t,s)}_getListeners(e){return Array.prototype.concat.apply([],this.events.get(e))||[]}_removeListener(e,t){const s=e.indexOf(t);return s>-1&&e.splice(s,1),[]}_wrapOnceListener(e,t){const s=(...r)=>(this.removeListener(e,s),t.apply(this,r));return Object.defineProperty(s,"name",{value:t.name}),s}setMaxListeners(e){return this.maxListeners=e,this}getMaxListeners(){return this.maxListeners}eventNames(){return Array.from(this.events.keys())}emit(e,...t){const s=this._getListeners(e);return s.forEach(r=>{r.apply(this,t)}),s.length>0}addListener(e,t){this._emitInternalEvent("newListener",e,t);const s=this._getListeners(e).concat(t);if(this.events.set(e,s),this.maxListeners>0&&this.listenerCount(e)>this.maxListeners&&!this.hasWarnedAboutPotentialMemoryLeak){this.hasWarnedAboutPotentialMemoryLeak=!0;const r=new te(this,e,this.listenerCount(e));console.warn(r)}return this}on(e,t){return this.addListener(e,t)}once(e,t){return this.addListener(e,this._wrapOnceListener(e,t))}prependListener(e,t){const s=this._getListeners(e);if(s.length>0){const r=[t].concat(s);this.events.set(e,r)}else this.events.set(e,s.concat(t));return this}prependOnceListener(e,t){return this.prependListener(e,this._wrapOnceListener(e,t))}removeListener(e,t){const s=this._getListeners(e);return s.length>0&&(this._removeListener(s,t),this.events.set(e,s),this._emitInternalEvent("removeListener",e,t)),this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){return e?this.events.delete(e):this.events.clear(),this}listeners(e){return Array.from(this._getListeners(e))}listenerCount(e){return this._getListeners(e).length}rawListeners(e){return this.listeners(e)}},C=k;C.defaultMaxListeners=10;const se=new C,w=e=>new Promise(t=>{setTimeout(()=>{t()},e)}),re=({"userleap-platform":e})=>e!=="web";class x{constructor(t){a(this,"storage"),a(this,"tempStorage",{}),a(this,"isStorageAvailable"),this.storage=window[t],this.isStorageAvailable=this.checkIfStorageAvailable()}checkIfStorageAvailable(){try{const t="__storage_test__";return this.storage.setItem(t,t),this.storage.removeItem(t),!0}catch{return!1}}setItem(t,s){this.isStorageAvailable?this.storage.setItem(t,s):this.tempStorage[t]=s}getItem(t){return this.isStorageAvailable?this.storage.getItem(t):this.tempStorage[t]}removeItem(t){this.isStorageAvailable?this.storage.removeItem(t):delete this.tempStorage[t]}clear(){this.isStorageAvailable?this.storage.clear():this.tempStorage={}}}const ne=new x("sessionStorage"),ie=new x("localStorage");class oe{constructor(t){a(this,"payload"),a(this,"promise"),a(this,"reject",()=>{}),a(this,"resolve",()=>{}),this.payload=t,this.promise=new Promise((s,r)=>{this.reject=r,this.resolve=s})}resolveRequest(t){this.resolve(t)}}const I={replay:null},ae=e=>{I.replay=e},le=()=>{const e=[];return I.replay&&e.push("replay"),e.join(",")},ce={RATELIMIT_RESET_DEFAULT:10};let T=!1,P="",_=!1,M=!1,E=[];const ue=e=>e._config&&e._config.installationMethod?e._config.installationMethod:e._gtm?"web-gtm":e._segment?"web-segment":"web-snippet",N=e=>{var t;(t=e?.blockedURI)!=null&&t.includes(window.UserLeap._API_URL)&&(M=!0,console.warn(`[Sprig] ${e.blockedURI} is blocked by Content-Security-Policy`),document.removeEventListener("securitypolicyviolation",N))},V=(e="")=>{T=!0,P=e};function de(e={}){const t={"Content-Type":"application/json","userleap-platform":"web","x-ul-sdk-version":"2.30.3","x-ul-installation-method":ue(e),"sprig-modules":le()};if(e.envId&&(t["x-ul-environment-id"]=e.envId),e.token&&(t.Authorization="Bearer "+e.token),e.userId&&(t["x-ul-user-id"]=e.userId),e.visitorId&&(t["x-ul-visitor-id"]=e.visitorId),e.partnerAnonymousId&&(t["x-ul-anonymous-id"]=e.partnerAnonymousId),e.mobileHeadersJSON){const s=JSON.parse(e.mobileHeadersJSON);Object.assign(t,s)}return e.locale&&(t["accept-language"]=e.locale),window.previewMode&&(t["x-ul-preview-mode"]="1"),t}const W=async({shouldDropOnRateLimit:e,...t})=>{if(e)return{status:429};{const s=new oe(t);return E.push(s),s.promise}},p=async(e,t)=>{const{retries:s=0,shouldDropOnRateLimit:r=!1,shouldRetryRequest:m=!1,...l}=t,c={url:e,options:l,retries:s,shouldDropOnRateLimit:r};if(_&&!m)return W(c);const h={ok:!1,reportError:!1};if(T)return console.info(`UserLeap - ${P}`),h;try{const o=await fetch(e,l);if(o.status===429)if(!_&&!r||m){_=!0;const i=o.headers.has("ratelimit-reset")?Number(o.headers.get("ratelimit-reset")):ce.RATELIMIT_RESET_DEFAULT;return await w(i*1e3),p(e,{...l,shouldDropOnRateLimit:r,shouldRetryRequest:!0})}else return W(c);if(_=!1,E.length&&(E.map(i=>{const y=i.payload;p(y.url,{...y.options,retries:y.retries,shouldDropOnRateLimit:y.shouldDropOnRateLimit}).then(J=>{i.resolveRequest(J)})}),E=[]),o.ok){if(o.status===249)return V(),h;const i=await o.text();try{return i&&i!=="OK"&&(o.json=JSON.parse(i)),o}catch{return{ok:!1,reportError:!1,error:new Error(`failed parsing response json for ${e} - ${i}`)}}}return o}catch(o){const i=s+1;return i>5||M?{ok:!1,reportError:!1,error:o}:(await w(Math.pow(2,s)*1e3),p(e,{...l,retries:i}))}},u={Error:1,Warn:2,Info:3,Debug:4};let b=1e3,f=u.Debug,d=[];const he=e=>{const t=Object.entries(u).find(s=>s[1]===e);return t?.[0]??""},pe=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),ve=(e,t)=>`${pe(t)}:${e}`,me=()=>{d=d.filter(e=>e.level<=f)},ye=()=>{d.length>b&&d.shift()},S=(e,t)=>{e>f||(d.push({level:e,line:ve(t,new Date)}),ye())},Y=e=>{S(u.Debug,e)},ge=e=>{S(u.Info,e)},j=e=>{S(u.Warn,e)},_e=e=>{S(u.Error,e)},Ee=()=>d.map(e=>e.line),fe=()=>new TextEncoder().encode(Ee().join(`
2
2
  `)),Se=async e=>{if(!e)return;const t=fe();return p(e,{body:t,method:"PUT"})},Le=(e,t)=>{e!==void 0&&(b=e),t!==void 0&&(f=t),Y(`Initializing logger with limit of ${b} lines and ${he(f)} level`),me()},$=Object.freeze({contains:(e,t)=>t.includes(e),notContains:(e,t)=>!t.includes(e),exactly:(e,t)=>t===e,notExactly:(e,t)=>t!==e,startsWith:(e,t)=>t.startsWith(e),endsWith:(e,t)=>t.endsWith(e),regex:(e,t)=>new RegExp(e).test(t),legacy:(e,t)=>new RegExp(e,"i").test(t)});function F(e,t){const{matchType:s,pattern:r}=e,m=s?$[s]:$.legacy;let l=!1;try{l=m(r,t)}catch(c){const h=`[Sprig] (ERR-445) Failed to check url match with pattern ${r}`;c instanceof Error&&(console.warn(h,c),c.stack=JSON.stringify(e),window.UserLeap.reportError(h,c))}return l}const we=e=>{const{pageUrlEvents:t}=window.UserLeap._config,s=t?.find(r=>r.id===e);return s?F(s,window.location.href):!1};let q=!0,R=!1;const Ie=()=>q=!1,be=()=>R=!0,Re=["sdk_event_queue_latency_seconds","sdk_replay_add_event_batch_seconds","sdk_replay_cleanup_seconds","sdk_replay_compression_seconds","sdk_replay_get_events_between_seconds","sdk_replay_snapshot_seconds"];let v={},O;class Oe{constructor(t){a(this,"_values",[]),a(this,"_isWebMetric"),this.name=t,this._isWebMetric=Re.includes(this.name)}report(t){if(q&&this._values.push({time:Date.now(),value:t}),R||!this._isWebMetric)return;const s=this.findExceededThreshold(t);s&&O&&O(t,s)}collect(){const t=this._values;return this._values=[],t}findExceededThreshold(t){const s=v[this.name];if(s)return s.find(r=>this.valueExceedsThreshold(t,r))}valueExceedsThreshold(t,s){return s.type==="max"?t>s.value:s.type==="min"?t<s.value:!1}}const Ae=(e,t)=>{v={},R=!1,e?.forEach(s=>{var r;s.metric in v||(v[s.metric]=[]),(r=v[s.metric])==null||r.push(s)}),O=t},L={},H=e=>{const t=new Oe(e);return L[e]=t,t},De=(e,t)=>{let s=L[e];return s||(s=H(e)),s.report(t)},Ue=async e=>{const t=Object.values(L).map(s=>({name:s.name,values:s.collect()}));if(t.some(s=>s.values.length))try{await e(JSON.stringify(t))}catch(s){j(`Error posting metrics: ${s}`)}},ke=({reportingIntervalSeconds:e,postMetrics:t})=>{e?setInterval(()=>{Ue(t)},e*1e3):Ie()};export{A as D,G as E,L as P,D as S,ne as a,De as b,we as c,Y as d,_e as e,se as f,ae as g,de as h,ge as i,re as j,Ae as k,ie as l,I as m,ke as n,be as o,Le as p,N as q,H as r,p as s,V as t,Se as u,ee as v,j as w,F as x,w as y};
@@ -1,2 +1,2 @@
1
- "use strict";var J=Object.defineProperty;var K=(e,t,r)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var a=(e,t,r)=>(K(e,typeof t!="symbol"?t+"":t,r),r);var O=(e=>(e.Closed="close.click",e.Complete="survey.completed",e.FeedbackClosed="feedback.closed",e.PageChange="page.change",e.API="api",e.Override="override",e))(O||{}),U=(e=>(e.ReplayCapture="replay.capture",e.FeedbackButtonLoaded="feedback.button.loaded",e.SDKReady="sdk.ready",e.SurveyAppeared="survey.appeared",e.SurveyClosed="survey.closed",e.SurveyDimensions="survey.dimensions",e.SurveyFadingOut="survey.fadingOut",e.SurveyHeight="survey.height",e.SurveyPresented="survey.presented",e.SurveyLifeCycle="survey.lifeCycle",e.SurveyWidth="survey.width",e.SurveyWillClose="survey.willClose",e.SurveyWillPresent="survey.will.present",e.CloseSurveyOnOverlayClick="close.survey.overlayClick",e.VisitorIDUpdated="visitor.id.updated",e.QuestionAnswered="question.answered",e))(U||{});const G={FEEDBACK_BUTTON_LOADED:"feedback.button.loaded",SDK_READY:"sdk.ready",SURVEY_APPEARED:"survey.appeared",SURVEY_CLOSED:"survey.closed",SURVEY_DIMENSIONS:"survey.dimensions",SURVEY_FADING_OUT:"survey.fadingOut",SURVEY_HEIGHT:"survey.height",SURVEY_WIDTH:"survey.width",SURVEY_PRESENTED:"survey.presented",SURVEY_LIFE_CYCLE:"survey.lifeCycle",SURVEY_WILL_CLOSE:"survey.willClose",SURVEY_WILL_PRESENT:"survey.will.present",QUESTION_ANSWERED:"question.answered",REPLAY_CAPTURE:"replay.capture",CLOSE_SURVEY_ON_OVERLAY_CLICK:"close.survey.overlayClick",VISITOR_ID_UPDATED:"visitor.id.updated",DATA:{DISMISS_REASONS:{API:"api",CLOSED:"close.click",COMPLETE:"survey.completed",PAGE_CHANGE:"page.change",OVERRIDE:"override"},SURVEY_ID:"survey.id"}};let g;const Q=new Uint8Array(16);function z(){if(!g&&(g=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!g))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return g(Q)}const n=[];for(let e=0;e<256;++e)n.push((e+256).toString(16).slice(1));function X(e,t=0){return n[e[t+0]]+n[e[t+1]]+n[e[t+2]]+n[e[t+3]]+"-"+n[e[t+4]]+n[e[t+5]]+"-"+n[e[t+6]]+n[e[t+7]]+"-"+n[e[t+8]]+n[e[t+9]]+"-"+n[e[t+10]]+n[e[t+11]]+n[e[t+12]]+n[e[t+13]]+n[e[t+14]]+n[e[t+15]]}const Z=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),A={randomUUID:Z};function ee(e,t,r){if(A.randomUUID&&!t&&!e)return A.randomUUID();e=e||{};const s=e.random||(e.rng||z)();return s[6]=s[6]&15|64,s[8]=s[8]&63|128,X(s)}var te=class extends Error{constructor(e,t,r){super(`Possible EventEmitter memory leak detected. ${r} ${t.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=e,this.type=t,this.count=r,this.name="MaxListenersExceededWarning"}},x=class{static listenerCount(e,t){return e.listenerCount(t)}constructor(){this.events=new Map,this.maxListeners=x.defaultMaxListeners,this.hasWarnedAboutPotentialMemoryLeak=!1}_emitInternalEvent(e,t,r){this.emit(e,t,r)}_getListeners(e){return Array.prototype.concat.apply([],this.events.get(e))||[]}_removeListener(e,t){const r=e.indexOf(t);return r>-1&&e.splice(r,1),[]}_wrapOnceListener(e,t){const r=(...s)=>(this.removeListener(e,r),t.apply(this,s));return Object.defineProperty(r,"name",{value:t.name}),r}setMaxListeners(e){return this.maxListeners=e,this}getMaxListeners(){return this.maxListeners}eventNames(){return Array.from(this.events.keys())}emit(e,...t){const r=this._getListeners(e);return r.forEach(s=>{s.apply(this,t)}),r.length>0}addListener(e,t){this._emitInternalEvent("newListener",e,t);const r=this._getListeners(e).concat(t);if(this.events.set(e,r),this.maxListeners>0&&this.listenerCount(e)>this.maxListeners&&!this.hasWarnedAboutPotentialMemoryLeak){this.hasWarnedAboutPotentialMemoryLeak=!0;const s=new te(this,e,this.listenerCount(e));console.warn(s)}return this}on(e,t){return this.addListener(e,t)}once(e,t){return this.addListener(e,this._wrapOnceListener(e,t))}prependListener(e,t){const r=this._getListeners(e);if(r.length>0){const s=[t].concat(r);this.events.set(e,s)}else this.events.set(e,r.concat(t));return this}prependOnceListener(e,t){return this.prependListener(e,this._wrapOnceListener(e,t))}removeListener(e,t){const r=this._getListeners(e);return r.length>0&&(this._removeListener(r,t),this.events.set(e,r),this._emitInternalEvent("removeListener",e,t)),this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){return e?this.events.delete(e):this.events.clear(),this}listeners(e){return Array.from(this._getListeners(e))}listenerCount(e){return this._getListeners(e).length}rawListeners(e){return this.listeners(e)}},D=x;D.defaultMaxListeners=10;const re=new D,R=e=>new Promise(t=>{setTimeout(()=>{t()},e)}),se=({"userleap-platform":e})=>e!=="web";class M{constructor(t){a(this,"storage");a(this,"tempStorage",{});a(this,"isStorageAvailable");this.storage=window[t],this.isStorageAvailable=this.checkIfStorageAvailable()}checkIfStorageAvailable(){try{const t="__storage_test__";return this.storage.setItem(t,t),this.storage.removeItem(t),!0}catch{return!1}}setItem(t,r){this.isStorageAvailable?this.storage.setItem(t,r):this.tempStorage[t]=r}getItem(t){return this.isStorageAvailable?this.storage.getItem(t):this.tempStorage[t]}removeItem(t){this.isStorageAvailable?this.storage.removeItem(t):delete this.tempStorage[t]}clear(){this.isStorageAvailable?this.storage.clear():this.tempStorage={}}}const ne=new M("sessionStorage"),ie=new M("localStorage");class oe{constructor(t){a(this,"payload");a(this,"promise");a(this,"reject",()=>{});a(this,"resolve",()=>{});this.payload=t,this.promise=new Promise((r,s)=>{this.reject=s,this.resolve=r})}resolveRequest(t){this.resolve(t)}}const S={replay:null},ae=e=>{S.replay=e},le=()=>{const e=[];return S.replay&&e.push("replay"),e.join(",")},ce={RATELIMIT_RESET_DEFAULT:10};let P=!1,V="",_=!1,H=!1,L=[];const ue=e=>e._config&&e._config.installationMethod?e._config.installationMethod:e._gtm?"web-gtm":e._segment?"web-segment":"web-snippet",W=e=>{var t;(t=e==null?void 0:e.blockedURI)!=null&&t.includes(window.UserLeap._API_URL)&&(H=!0,console.warn(`[Sprig] ${e.blockedURI} is blocked by Content-Security-Policy`),document.removeEventListener("securitypolicyviolation",W))},Y=(e="")=>{P=!0,V=e};function de(e={}){const t={"Content-Type":"application/json","userleap-platform":"web","x-ul-sdk-version":"2.30.1","x-ul-installation-method":ue(e),"sprig-modules":le()};if(e.envId&&(t["x-ul-environment-id"]=e.envId),e.token&&(t.Authorization="Bearer "+e.token),e.userId&&(t["x-ul-user-id"]=e.userId),e.visitorId&&(t["x-ul-visitor-id"]=e.visitorId),e.partnerAnonymousId&&(t["x-ul-anonymous-id"]=e.partnerAnonymousId),e.mobileHeadersJSON){const r=JSON.parse(e.mobileHeadersJSON);Object.assign(t,r)}return e.locale&&(t["accept-language"]=e.locale),window.previewMode&&(t["x-ul-preview-mode"]="1"),t}const T=async({shouldDropOnRateLimit:e,...t})=>{if(e)return{status:429};{const r=new oe(t);return L.push(r),r.promise}},m=async(e,t)=>{const{retries:r=0,shouldDropOnRateLimit:s=!1,shouldRetryRequest:y=!1,...l}=t,c={url:e,options:l,retries:r,shouldDropOnRateLimit:s};if(_&&!y)return T(c);const p={ok:!1,reportError:!1};if(P)return console.info(`UserLeap - ${V}`),p;try{const i=await fetch(e,l);if(i.status===429)if(!_&&!s||y){_=!0;const u=i.headers.has("ratelimit-reset")?Number(i.headers.get("ratelimit-reset")):ce.RATELIMIT_RESET_DEFAULT;return await R(u*1e3),m(e,{...l,shouldDropOnRateLimit:s,shouldRetryRequest:!0})}else return T(c);if(_=!1,L.length&&(L.map(o=>{const u=o.payload;m(u.url,{...u.options,retries:u.retries,shouldDropOnRateLimit:u.shouldDropOnRateLimit}).then(B=>{o.resolveRequest(B)})}),L=[]),i.ok){if(i.status===249)return Y(),p;const o=await i.text();try{return o&&o!=="OK"&&(i.json=JSON.parse(o)),i}catch{return{ok:!1,reportError:!1,error:new Error(`failed parsing response json for ${e} - ${o}`)}}}return i}catch(i){const o=r+1;return o>5||H?{ok:!1,reportError:!1,error:i}:(await R(Math.pow(2,r)*1e3),m(e,{...l,retries:o}))}},h={Error:1,Warn:2,Info:3,Debug:4};let b=1e3,v=h.Debug,d=[];const he=e=>{const t=Object.entries(h).find(r=>r[1]===e);return(t==null?void 0:t[0])??""},pe=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),fe=(e,t)=>`${pe(t)}:${e}`,me=()=>{d=d.filter(e=>e.level<=v)},ye=()=>{d.length>b&&d.shift()},E=(e,t)=>{e>v||(d.push({level:e,line:fe(t,new Date)}),ye())},q=e=>{E(h.Debug,e)},ge=e=>{E(h.Info,e)},N=e=>{E(h.Warn,e)},_e=e=>{E(h.Error,e)},Le=()=>d.map(e=>e.line),ve=()=>new TextEncoder().encode(Le().join(`
1
+ "use strict";var J=Object.defineProperty;var K=(e,t,r)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var a=(e,t,r)=>(K(e,typeof t!="symbol"?t+"":t,r),r);var O=(e=>(e.Closed="close.click",e.Complete="survey.completed",e.FeedbackClosed="feedback.closed",e.PageChange="page.change",e.API="api",e.Override="override",e))(O||{}),U=(e=>(e.ReplayCapture="replay.capture",e.FeedbackButtonLoaded="feedback.button.loaded",e.SDKReady="sdk.ready",e.SurveyAppeared="survey.appeared",e.SurveyClosed="survey.closed",e.SurveyDimensions="survey.dimensions",e.SurveyFadingOut="survey.fadingOut",e.SurveyHeight="survey.height",e.SurveyPresented="survey.presented",e.SurveyLifeCycle="survey.lifeCycle",e.SurveyWidth="survey.width",e.SurveyWillClose="survey.willClose",e.SurveyWillPresent="survey.will.present",e.CloseSurveyOnOverlayClick="close.survey.overlayClick",e.VisitorIDUpdated="visitor.id.updated",e.QuestionAnswered="question.answered",e))(U||{});const G={FEEDBACK_BUTTON_LOADED:"feedback.button.loaded",SDK_READY:"sdk.ready",SURVEY_APPEARED:"survey.appeared",SURVEY_CLOSED:"survey.closed",SURVEY_DIMENSIONS:"survey.dimensions",SURVEY_FADING_OUT:"survey.fadingOut",SURVEY_HEIGHT:"survey.height",SURVEY_WIDTH:"survey.width",SURVEY_PRESENTED:"survey.presented",SURVEY_LIFE_CYCLE:"survey.lifeCycle",SURVEY_WILL_CLOSE:"survey.willClose",SURVEY_WILL_PRESENT:"survey.will.present",QUESTION_ANSWERED:"question.answered",REPLAY_CAPTURE:"replay.capture",CLOSE_SURVEY_ON_OVERLAY_CLICK:"close.survey.overlayClick",VISITOR_ID_UPDATED:"visitor.id.updated",DATA:{DISMISS_REASONS:{API:"api",CLOSED:"close.click",COMPLETE:"survey.completed",PAGE_CHANGE:"page.change",OVERRIDE:"override"},SURVEY_ID:"survey.id"}};let g;const Q=new Uint8Array(16);function z(){if(!g&&(g=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!g))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return g(Q)}const n=[];for(let e=0;e<256;++e)n.push((e+256).toString(16).slice(1));function X(e,t=0){return n[e[t+0]]+n[e[t+1]]+n[e[t+2]]+n[e[t+3]]+"-"+n[e[t+4]]+n[e[t+5]]+"-"+n[e[t+6]]+n[e[t+7]]+"-"+n[e[t+8]]+n[e[t+9]]+"-"+n[e[t+10]]+n[e[t+11]]+n[e[t+12]]+n[e[t+13]]+n[e[t+14]]+n[e[t+15]]}const Z=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),A={randomUUID:Z};function ee(e,t,r){if(A.randomUUID&&!t&&!e)return A.randomUUID();e=e||{};const s=e.random||(e.rng||z)();return s[6]=s[6]&15|64,s[8]=s[8]&63|128,X(s)}var te=class extends Error{constructor(e,t,r){super(`Possible EventEmitter memory leak detected. ${r} ${t.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=e,this.type=t,this.count=r,this.name="MaxListenersExceededWarning"}},x=class{static listenerCount(e,t){return e.listenerCount(t)}constructor(){this.events=new Map,this.maxListeners=x.defaultMaxListeners,this.hasWarnedAboutPotentialMemoryLeak=!1}_emitInternalEvent(e,t,r){this.emit(e,t,r)}_getListeners(e){return Array.prototype.concat.apply([],this.events.get(e))||[]}_removeListener(e,t){const r=e.indexOf(t);return r>-1&&e.splice(r,1),[]}_wrapOnceListener(e,t){const r=(...s)=>(this.removeListener(e,r),t.apply(this,s));return Object.defineProperty(r,"name",{value:t.name}),r}setMaxListeners(e){return this.maxListeners=e,this}getMaxListeners(){return this.maxListeners}eventNames(){return Array.from(this.events.keys())}emit(e,...t){const r=this._getListeners(e);return r.forEach(s=>{s.apply(this,t)}),r.length>0}addListener(e,t){this._emitInternalEvent("newListener",e,t);const r=this._getListeners(e).concat(t);if(this.events.set(e,r),this.maxListeners>0&&this.listenerCount(e)>this.maxListeners&&!this.hasWarnedAboutPotentialMemoryLeak){this.hasWarnedAboutPotentialMemoryLeak=!0;const s=new te(this,e,this.listenerCount(e));console.warn(s)}return this}on(e,t){return this.addListener(e,t)}once(e,t){return this.addListener(e,this._wrapOnceListener(e,t))}prependListener(e,t){const r=this._getListeners(e);if(r.length>0){const s=[t].concat(r);this.events.set(e,s)}else this.events.set(e,r.concat(t));return this}prependOnceListener(e,t){return this.prependListener(e,this._wrapOnceListener(e,t))}removeListener(e,t){const r=this._getListeners(e);return r.length>0&&(this._removeListener(r,t),this.events.set(e,r),this._emitInternalEvent("removeListener",e,t)),this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){return e?this.events.delete(e):this.events.clear(),this}listeners(e){return Array.from(this._getListeners(e))}listenerCount(e){return this._getListeners(e).length}rawListeners(e){return this.listeners(e)}},D=x;D.defaultMaxListeners=10;const re=new D,R=e=>new Promise(t=>{setTimeout(()=>{t()},e)}),se=({"userleap-platform":e})=>e!=="web";class M{constructor(t){a(this,"storage");a(this,"tempStorage",{});a(this,"isStorageAvailable");this.storage=window[t],this.isStorageAvailable=this.checkIfStorageAvailable()}checkIfStorageAvailable(){try{const t="__storage_test__";return this.storage.setItem(t,t),this.storage.removeItem(t),!0}catch{return!1}}setItem(t,r){this.isStorageAvailable?this.storage.setItem(t,r):this.tempStorage[t]=r}getItem(t){return this.isStorageAvailable?this.storage.getItem(t):this.tempStorage[t]}removeItem(t){this.isStorageAvailable?this.storage.removeItem(t):delete this.tempStorage[t]}clear(){this.isStorageAvailable?this.storage.clear():this.tempStorage={}}}const ne=new M("sessionStorage"),ie=new M("localStorage");class oe{constructor(t){a(this,"payload");a(this,"promise");a(this,"reject",()=>{});a(this,"resolve",()=>{});this.payload=t,this.promise=new Promise((r,s)=>{this.reject=s,this.resolve=r})}resolveRequest(t){this.resolve(t)}}const S={replay:null},ae=e=>{S.replay=e},le=()=>{const e=[];return S.replay&&e.push("replay"),e.join(",")},ce={RATELIMIT_RESET_DEFAULT:10};let P=!1,V="",_=!1,H=!1,L=[];const ue=e=>e._config&&e._config.installationMethod?e._config.installationMethod:e._gtm?"web-gtm":e._segment?"web-segment":"web-snippet",W=e=>{var t;(t=e==null?void 0:e.blockedURI)!=null&&t.includes(window.UserLeap._API_URL)&&(H=!0,console.warn(`[Sprig] ${e.blockedURI} is blocked by Content-Security-Policy`),document.removeEventListener("securitypolicyviolation",W))},Y=(e="")=>{P=!0,V=e};function de(e={}){const t={"Content-Type":"application/json","userleap-platform":"web","x-ul-sdk-version":"2.30.3","x-ul-installation-method":ue(e),"sprig-modules":le()};if(e.envId&&(t["x-ul-environment-id"]=e.envId),e.token&&(t.Authorization="Bearer "+e.token),e.userId&&(t["x-ul-user-id"]=e.userId),e.visitorId&&(t["x-ul-visitor-id"]=e.visitorId),e.partnerAnonymousId&&(t["x-ul-anonymous-id"]=e.partnerAnonymousId),e.mobileHeadersJSON){const r=JSON.parse(e.mobileHeadersJSON);Object.assign(t,r)}return e.locale&&(t["accept-language"]=e.locale),window.previewMode&&(t["x-ul-preview-mode"]="1"),t}const T=async({shouldDropOnRateLimit:e,...t})=>{if(e)return{status:429};{const r=new oe(t);return L.push(r),r.promise}},m=async(e,t)=>{const{retries:r=0,shouldDropOnRateLimit:s=!1,shouldRetryRequest:y=!1,...l}=t,c={url:e,options:l,retries:r,shouldDropOnRateLimit:s};if(_&&!y)return T(c);const p={ok:!1,reportError:!1};if(P)return console.info(`UserLeap - ${V}`),p;try{const i=await fetch(e,l);if(i.status===429)if(!_&&!s||y){_=!0;const u=i.headers.has("ratelimit-reset")?Number(i.headers.get("ratelimit-reset")):ce.RATELIMIT_RESET_DEFAULT;return await R(u*1e3),m(e,{...l,shouldDropOnRateLimit:s,shouldRetryRequest:!0})}else return T(c);if(_=!1,L.length&&(L.map(o=>{const u=o.payload;m(u.url,{...u.options,retries:u.retries,shouldDropOnRateLimit:u.shouldDropOnRateLimit}).then(B=>{o.resolveRequest(B)})}),L=[]),i.ok){if(i.status===249)return Y(),p;const o=await i.text();try{return o&&o!=="OK"&&(i.json=JSON.parse(o)),i}catch{return{ok:!1,reportError:!1,error:new Error(`failed parsing response json for ${e} - ${o}`)}}}return i}catch(i){const o=r+1;return o>5||H?{ok:!1,reportError:!1,error:i}:(await R(Math.pow(2,r)*1e3),m(e,{...l,retries:o}))}},h={Error:1,Warn:2,Info:3,Debug:4};let b=1e3,v=h.Debug,d=[];const he=e=>{const t=Object.entries(h).find(r=>r[1]===e);return(t==null?void 0:t[0])??""},pe=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),fe=(e,t)=>`${pe(t)}:${e}`,me=()=>{d=d.filter(e=>e.level<=v)},ye=()=>{d.length>b&&d.shift()},E=(e,t)=>{e>v||(d.push({level:e,line:fe(t,new Date)}),ye())},q=e=>{E(h.Debug,e)},ge=e=>{E(h.Info,e)},N=e=>{E(h.Warn,e)},_e=e=>{E(h.Error,e)},Le=()=>d.map(e=>e.line),ve=()=>new TextEncoder().encode(Le().join(`
2
2
  `)),Ee=async e=>{if(!e)return;const t=ve();return m(e,{body:t,method:"PUT"})},we=(e,t)=>{e!==void 0&&(b=e),t!==void 0&&(v=t),q(`Initializing logger with limit of ${b} lines and ${he(v)} level`),me()},C=Object.freeze({contains:(e,t)=>t.includes(e),notContains:(e,t)=>!t.includes(e),exactly:(e,t)=>t===e,notExactly:(e,t)=>t!==e,startsWith:(e,t)=>t.startsWith(e),endsWith:(e,t)=>t.endsWith(e),regex:(e,t)=>new RegExp(e).test(t),legacy:(e,t)=>new RegExp(e,"i").test(t)});function j(e,t){const{matchType:r,pattern:s}=e,y=r?C[r]:C.legacy;let l=!1;try{l=y(s,t)}catch(c){const p=`[Sprig] (ERR-445) Failed to check url match with pattern ${s}`;c instanceof Error&&(console.warn(p,c),c.stack=JSON.stringify(e),window.UserLeap.reportError(p,c))}return l}const Re=e=>{const{pageUrlEvents:t}=window.UserLeap._config,r=t==null?void 0:t.find(s=>s.id===e);return r?j(r,window.location.href):!1};let F=!0,k=!1;const be=()=>F=!1,Ie=()=>k=!0,Se=["sdk_event_queue_latency_seconds","sdk_replay_add_event_batch_seconds","sdk_replay_cleanup_seconds","sdk_replay_compression_seconds","sdk_replay_get_events_between_seconds","sdk_replay_snapshot_seconds"];let f={},I;class ke{constructor(t){a(this,"_values",[]);a(this,"_isWebMetric");this.name=t,this._isWebMetric=Se.includes(this.name)}report(t){if(F&&this._values.push({time:Date.now(),value:t}),k||!this._isWebMetric)return;const r=this.findExceededThreshold(t);r&&I&&I(t,r)}collect(){const t=this._values;return this._values=[],t}findExceededThreshold(t){const r=f[this.name];if(r)return r.find(s=>this.valueExceedsThreshold(t,s))}valueExceedsThreshold(t,r){return r.type==="max"?t>r.value:r.type==="min"?t<r.value:!1}}const Ae=(e,t)=>{f={},k=!1,e==null||e.forEach(r=>{var s;r.metric in f||(f[r.metric]=[]),(s=f[r.metric])==null||s.push(r)}),I=t},w={},$=e=>{const t=new ke(e);return w[e]=t,t},Te=(e,t)=>{let r=w[e];return r||(r=$(e)),r.report(t)},Ce=async e=>{const t=Object.values(w).map(r=>({name:r.name,values:r.collect()}));if(t.some(r=>r.values.length))try{await e(JSON.stringify(t))}catch(r){N(`Error posting metrics: ${r}`)}},Oe=({reportingIntervalSeconds:e,postMetrics:t})=>{e?setInterval(()=>{Ce(t)},e*1e3):be()};exports.DismissReason=O;exports.EVENTS=G;exports.PerformanceMetrics=w;exports.SprigEvent=U;exports.checkUrlMatch=j;exports.checkUrlStillMatching=Re;exports.configureLogger=we;exports.cspViolationHandler=W;exports.debug=q;exports.delay=R;exports.disableThresholdChecking=Ie;exports.error=_e;exports.eventEmitter=re;exports.getHttpHeaders=de;exports.info=ge;exports.initPerformanceReporting=Oe;exports.killNetworkRequests=Y;exports.localStorageHelper=ie;exports.modules=S;exports.registerMetric=$;exports.registerReplay=ae;exports.registerThresholds=Ae;exports.reportAndRegister=Te;exports.sessionStorageHelper=ne;exports.shouldDirectEmbed=se;exports.sprigFetch=m;exports.uploadLogfile=Ee;exports.v4=ee;exports.warn=N;