@corbado/observe 1.15.0 → 1.15.2
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.
- package/CHANGELOG.md +24 -0
- package/dist/analysis/readers/password-manager-extensions.mjs +11 -1
- package/dist/analysis/version.mjs +1 -1
- package/dist/cdn/script.global.js +2 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/manifest/index.d.mts +48 -9
- package/dist/manifest/index.d.ts +48 -9
- package/dist/manifest/index.js +54 -48
- package/dist/manifest/index.mjs +54 -48
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";(()=>{var Lt=0;function P(){if(Lt===4294967295)throw new Error("Low-event capture sequence exhausted");return++Lt}function Rt(i,e){if(i==="passkey-login")switch(e){case"passkey-known-identifier":case"passkey-no-identifier":return"passkey-button";case"passkey-known-identifier-auto":case"passkey-no-identifier-auto":case"passkey-immediate":return"automatic"}else if(i==="passkey-enrollment")switch(e){case"manual":return"passkey-button";case"auto":case"conditional":return"automatic"}}var T=[];for(let i=0;i<256;++i)T.push((i+256).toString(16).slice(1));function _t(i,e=0){return(T[i[e+0]]+T[i[e+1]]+T[i[e+2]]+T[i[e+3]]+"-"+T[i[e+4]]+T[i[e+5]]+"-"+T[i[e+6]]+T[i[e+7]]+"-"+T[i[e+8]]+T[i[e+9]]+"-"+T[i[e+10]]+T[i[e+11]]+T[i[e+12]]+T[i[e+13]]+T[i[e+14]]+T[i[e+15]]).toLowerCase()}var dt,Ei=new Uint8Array(16);function ue(){if(!dt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");dt=crypto.getRandomValues.bind(crypto)}return dt(Ei)}var pt={};function Ci(i,e,t){let r;if(i)r=Dt(i.random??i.rng?.()??ue(),i.msecs,i.seq,e,t);else{let n=Date.now(),o=ue();ki(pt,n,o),r=Dt(o,pt.msecs,pt.seq,e,t)}return e??_t(r)}function ki(i,e,t){return i.msecs??=-1/0,i.seq??=0,e>i.msecs?(i.seq=t[6]<<23|t[7]<<16|t[8]<<8|t[9],i.msecs=e):(i.seq=i.seq+1|0,i.seq===0&&i.msecs++),i}function Dt(i,e,t,r,n=0){if(i.length<16)throw new Error("Random bytes length must be >= 16");if(!r)r=new Uint8Array(16),n=0;else if(n<0||n+16>r.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);return e??=Date.now(),t??=i[6]*127<<24|i[7]<<16|i[8]<<8|i[9],r[n++]=e/1099511627776&255,r[n++]=e/4294967296&255,r[n++]=e/16777216&255,r[n++]=e/65536&255,r[n++]=e/256&255,r[n++]=e&255,r[n++]=112|t>>>28&15,r[n++]=t>>>20&255,r[n++]=128|t>>>14&63,r[n++]=t>>>6&255,r[n++]=t<<2&255|i[10]&3,r[n++]=i[11],r[n++]=i[12],r[n++]=i[13],r[n++]=i[14],r[n++]=i[15],r}var S=Ci;function U(i){if(i!=null){if(i instanceof Error)return{name:i.name,message:i.message};if(typeof i=="string")return{message:i};if(typeof i=="object"){let e=i;if(typeof e.message=="string"||typeof e.code=="string")return{name:typeof e.name=="string"?e.name:void 0,message:typeof e.message=="string"?e.message:void 0,code:typeof e.code=="string"?e.code:void 0}}return{message:String(i)}}}var Oi=1500,h=class{constructor(e,t){this.tracker=e;this.operationName=t}startReference;captureSpecType;captureSessionId;lowFlushers=[];lowPrefillCapturers=[];lowEventSink(e,t){return{reserveCaptureSeq:P,enqueueLowEvent:r=>this.tracker.enqueueLowEvent({...r,captureSeq:r.captureSeq??P(),subflowStartEventId:this.startReference,sourceKind:e,fieldRole:t,initiator:r.initiator??(t?`input-${t}`:"unknown")},this.captureSessionId),flushKeepalive:()=>this.tracker.lowEventFlushKeepalive(),registerInputs:(r,n)=>this.tracker.getWindowObserver().registerInputs(r,()=>({subflowStartEventId:this.startReference,fieldRole:t,initiator:t?`input-${t}`:"unknown",sessionId:this.captureSessionId}),n),beginCeremony:r=>this.tracker.getWindowObserver().beginCeremony({subflowStartEventId:this.startReference,initiator:r??"unknown",sessionId:this.captureSessionId})}}createLowCollector(e){try{let t=e();return this.lowPrefillCapturers.push(r=>t.capturePrefill(r)),t}catch(t){this.tracker.getLogger().error("Failed to attach low-event collector",t);return}}registerLowFlusher(e){this.lowFlushers.push(e)}captureOptions(e,t=this.startReference,r=this.captureSessionId,n){if(!t&&!n)return e;let o={};return t&&(o.subflowStartEventId=e?.subflowStartEventId??t,o.captureSessionId=e?.captureSessionId??r),n&&(o.initiator=e?.initiator??n),Object.defineProperties({},{...Object.getOwnPropertyDescriptors(e??{}),...Object.getOwnPropertyDescriptors(o)})}get captureReference(){return this.startReference}get captureSession(){return this.captureSessionId}adoptCapture(e,t,r){this.startReference=e,this.captureSessionId=t,this.captureSpecType=r}subflowStart(e,t){try{for(let r of this.lowFlushers)try{r()}catch(n){this.tracker.getLogger().error("Failed to flush previous low-event context",n)}this.captureSpecType=e?.explicitSpecType,this.startReference=S(),this.captureSessionId=this.tracker.getSessionId(),this.tracker.trackSubflowStarted(this.operationName,e,this.captureOptions(t),this.startReference),this.captureInputPrefills(!0)}catch(r){this.tracker.getLogger().error("Failed to start low-event capture context",r)}}capturePrefill(){this.captureInputPrefills(!1)}captureInputPrefills(e){for(let t of this.lowPrefillCapturers)try{t(e)}catch(r){this.tracker.getLogger().error("Failed to capture input prefill",r)}}trigger(e,t){this.tracker.trackSubflowTrigger(this.operationName,e,this.captureOptions(t))}customStep(e){return this.defineStep(e)}subflowStepStarted(e,t,r,n){this.captureSpecType=t?.explicitSpecType??this.captureSpecType,this.tracker.trackSubflowStepStarted(this.operationName,e,t,this.captureOptions(r),n)}subflowStepFinished(e,t,r){(!r?.subflowStartEventId||r.subflowStartEventId===this.startReference)&&(this.captureSpecType=t?.explicitSpecType??this.captureSpecType),this.tracker.trackSubflowStepFinished(this.operationName,e,t,this.captureOptions(r))}subflowStepError(e,t,r){let n=t;try{let o=this.tracker.getSdkConfig().rawErrors?r?.rawError:void 0;if(o!==void 0){let s=this.tracker.rawErrors;s&&(n={...t,rawError:s(o,r?.rawErrorLimits)})}}catch{}this.tracker.trackSubflowStepError(this.operationName,e,n,this.captureOptions(r))}withWindowLowEvents(e,t){let r,n=s=>{s?.subflowStartEventId&&s.subflowStartEventId!==r||t.scheduleDisarm(Oi)},o=e;return{...e,start:(s,a)=>{r=a?.subflowStartEventId??this.startReference;let p=s?.explicitSpecType??this.captureSpecType,d=a?.initiator??Rt(this.operationName,p);t.arm(d,p==="passkey-cui"),o.start(s,d?{...a,initiator:d}:a)},finished:(s,a)=>{o.finished(s,a),n(a)},error:(s,a)=>{o.error(s,a),n(a)},errorTyped:(s,a)=>{o.errorTyped?.(s,a),n(a)}}}defineStep(e,t){let r,n,o,s=p=>this.captureOptions(p,r,n,o);return{start:(p,d)=>{r=this.startReference,n=this.captureSessionId,o=d?.initiator,this.subflowStepStarted(e,p,s(d),t)},finished:(p,d)=>{this.subflowStepFinished(e,p,s(d))},error:(p,d)=>{this.subflowStepError(e,{error:U(p)},s(d))},errorTyped:(p,d)=>{this.subflowStepError(e,p,s(d))}}}};function At(i,e){if(e.explicitSpecType!==void 0)try{i.getLogger().warn("Unsupported key operation spec type; omitting it")}catch{}}var fe=class extends h{prepare;sign;constructor(e,t={}){super(e,"key-signing"),this.prepare=this.defineStep("prepare"),this.sign=this.defineStep("sign"),this.subflowStart({actor:"system",explicitSpecType:At(e,t)})}},he=class extends h{prepare;postResponse;constructor(e,t={}){super(e,"key-registration"),this.prepare=this.defineStep("prepare"),this.postResponse=this.defineStep("post-response"),this.subflowStart({actor:"system",explicitSpecType:At(e,t)})}};var ct="cbo_sdk_config",Ht="cbo_sdk_config_cache",Bt="X-Corbado-Observe-Config";var w={flushIntervalMs:{min:100,max:6e4},retryMaxAttempts:{min:1,max:10},retryDelayMs:{min:50,max:12e4},sessionInactivityMs:{min:6e4,max:864e5},seqLockTimeoutMs:{min:0,max:250},deviceInfoCollectorTimeoutMs:{min:10,max:1e4},flushOnFlowTypeFinished:{maxEntries:20,maxNameLength:100},sourcePathQueryAllow:{maxEntries:50,maxKeyLength:64}},Ii=1800*1e3,b={version:"",flushIntervalMs:500,durableOutbox:!1,durableLowOutbox:!1,beaconKeepalive:!1,sessionContinuity:!1,sessionInactivityMs:Ii,seqLockTimeoutMs:50,tvc:!0,tph:!0,td:!0,tlf:!0,telemetry:!0,flushOnTelemetry:!1,flushOnFlowTypeFinished:[],deviceInfoCollectorTimeoutMs:1e3,deviceInfoTiming:!1,rawErrors:!0,pmd:!0,retry:{maxAttempts:1,baseDelayMs:0,maxDelayMs:0},aap:"",sourcePathQuery:"allowlist",sourcePathQueryAllow:[]};function M(i,e,t){return Math.min(Math.max(i,e),t)}function H(i,e){return typeof i=="number"&&Number.isFinite(i)?i:e}function F(i,e){return typeof i=="boolean"?i:e}function Mt(i,e){return typeof i=="string"?i:e}function xi(i){return Array.isArray(i)?i.filter(e=>typeof e=="string"&&e.length>0&&e.length<=w.flushOnFlowTypeFinished.maxNameLength).slice(0,w.flushOnFlowTypeFinished.maxEntries):[]}function Pi(i){return typeof i=="string"&&i.trim().toLowerCase()==="all"?"all":"allowlist"}function Fi(i){return Array.isArray(i)?i.filter(e=>typeof e=="string").map(e=>e.trim()).filter(e=>e.length>0&&e.length<=w.sourcePathQueryAllow.maxKeyLength).slice(0,w.sourcePathQueryAllow.maxEntries):[]}function q(i){if(!i||typeof i!="object")return null;let e=i;return typeof e.version!="string"||e.version===""?null:Nt(e)}function Nt(i){let e=i.retry&&typeof i.retry=="object"?i.retry:{},t=M(H(e.baseDelayMs,b.retry.baseDelayMs),w.retryDelayMs.min,w.retryDelayMs.max);return{version:Mt(i.version,""),flushIntervalMs:M(H(i.flushIntervalMs,b.flushIntervalMs),w.flushIntervalMs.min,w.flushIntervalMs.max),durableOutbox:i.durableOutbox===!0,durableLowOutbox:i.durableLowOutbox===!0,beaconKeepalive:i.beaconKeepalive===!0,sessionContinuity:i.sessionContinuity===!0,sessionInactivityMs:M(H(i.sessionInactivityMs,b.sessionInactivityMs),w.sessionInactivityMs.min,w.sessionInactivityMs.max),seqLockTimeoutMs:M(H(i.seqLockTimeoutMs,b.seqLockTimeoutMs),w.seqLockTimeoutMs.min,w.seqLockTimeoutMs.max),tvc:F(i.tvc,b.tvc),tph:F(i.tph,b.tph),td:F(i.td,b.td),tlf:F(i.tlf,b.tlf),telemetry:F(i.telemetry,b.telemetry),flushOnTelemetry:i.flushOnTelemetry===!0,flushOnFlowTypeFinished:xi(i.flushOnFlowTypeFinished),deviceInfoCollectorTimeoutMs:M(H(i.deviceInfoCollectorTimeoutMs,b.deviceInfoCollectorTimeoutMs),w.deviceInfoCollectorTimeoutMs.min,w.deviceInfoCollectorTimeoutMs.max),deviceInfoTiming:i.deviceInfoTiming===!0,rawErrors:F(i.rawErrors,b.rawErrors),pmd:F(i.pmd,b.pmd),aap:Mt(i.aap,""),sourcePathQuery:Pi(i.sourcePathQuery),sourcePathQueryAllow:Fi(i.sourcePathQueryAllow),retry:{maxAttempts:M(H(e.maxAttempts,b.retry.maxAttempts),w.retryMaxAttempts.min,w.retryMaxAttempts.max),baseDelayMs:t,maxDelayMs:M(H(e.maxDelayMs,b.retry.maxDelayMs),t,w.retryDelayMs.max)}}}function ge(i,e={}){let t=i??b,r=Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0)),n=Object.fromEntries(Object.entries(e.retry??{}).filter(([,s])=>s!==void 0)),o=Nt({...t,...r,retry:{...t.retry,...n}});return o.retry={...t.retry,...Object.fromEntries(Object.keys(n).map(s=>[s,o.retry[s]]))},o.retry.maxDelayMs=Math.max(o.retry.baseDelayMs,o.retry.maxDelayMs),o}var Li="static";function Ut(i,e){let t;try{t=JSON.parse(i)}catch{t=void 0}let r=!!t&&typeof t=="object"&&!Array.isArray(t),n=r?t:{};return{config:ge(void 0,{...n,version:typeof n.version=="string"&&n.version!==""?n.version:Li,...e!==void 0&&{pmd:e}}),valid:r}}function me(i){try{if(!i||typeof i!="object")return;let e=i,t=e.crossOriginSession,r=t&&typeof t=="object"&&typeof t.cookieDomain=="string"?t.cookieDomain:void 0;return{pmd:F(e.pmd,!1),privateMode:F(e.privateMode,!0),...r!==void 0&&{crossOriginSession:{cookieDomain:r}}}}catch{return}}function ye(i){let e=i.getItem(Ht),t=e&&typeof e=="object"?q(e.config):null;return t?{...e,config:t}:null}function qt(i){return ye(i)?.config??q(i.getItem(ct))}function Kt(i,e){i.setItem(Ht,e)}function Wt(i){try{return decodeURIComponent(i.replace(/\+/g," "))}catch{return i}}function Vt(i,e){let t=i.toLowerCase();return e.some(r=>{let n=r.toLowerCase();return n.endsWith("*")?t.startsWith(n.slice(0,-1)):t===n})}function $t(i,e,t){return e!=="allowlist"||i===""||i==="?"?i:`?${(i.startsWith("?")?i.slice(1):i).split("&").map(o=>{let s=o.indexOf("=");if(s===-1)return o;let a=o.slice(0,s);return o.slice(s+1)===""||Vt(Wt(a),t)?o:`${a}=*`}).join("&")}`}var Ri=/^[A-Za-z][A-Za-z0-9_.\-[\]]{0,63}$/;function Gt(i,e){return i===""||i==="?"?i:`?${(i.startsWith("?")?i.slice(1):i).split("&").map(n=>{if(n==="")return n;let o=n.indexOf("="),s=o===-1?n:n.slice(0,o),a=Wt(s);if(Vt(a,e))return n;if(o===-1)return"*";let p=Ri.test(a)?s:"*";return n.length===o+1?`${p}=`:`${p}=*`}).join("&")}`}function jt(i){let e=String(i??"").split("/").filter(t=>t!=="");return e.length===0?"/":"/"+e.map(()=>"*").join("/")}function O(i,e,t,r){return r===void 0?window.addEventListener(e,t):window.addEventListener(e,t,r),()=>window.removeEventListener(e,t)}function K(i){return document.visibilityState==="hidden"}function Qt(i){return document.readyState==="complete"}function zt(i,e,t){if(typeof __CBO_DATA_PAGE_STRICT__=="boolean"&&__CBO_DATA_PAGE_STRICT__)return`${jt(window.location.pathname)}${Gt(window.location.search,t)}`;let r=$t(window.location.search,e,t);return`${window.location.pathname}${r}`}function Yt(i){return{hostname:window.location.hostname,https:window.location.protocol==="https:"}}function Jt(i){return typeof navigator>"u"?"":navigator.userAgent??""}async function Xt(i){if(!(typeof navigator>"u"||!navigator.bluetooth))return await navigator.bluetooth.getAvailability()}async function Zt(i){if(!(typeof PublicKeyCredential>"u"||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable))return await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}async function er(i){if(!(typeof PublicKeyCredential>"u"||!PublicKeyCredential.isConditionalMediationAvailable))return await PublicKeyCredential.isConditionalMediationAvailable()}async function tr(i){if(typeof PublicKeyCredential>"u"||!PublicKeyCredential.getClientCapabilities)return;let e=await PublicKeyCredential.getClientCapabilities();return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,r.toString()]))}async function rr(i){if(typeof navigator>"u"||!navigator.userAgentData)return;let e=await navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]),t=e.platform,r=e.mobile,n=e.platformVersion,o=e.model||void 0;if(!(!t||r===void 0||!n))return{platform:t,mobile:r,platformVersion:n,model:o}}function ir(i){if(!(typeof navigator>"u"))return navigator.webdriver}function nr(i){if(!(typeof navigator>"u"||typeof navigator.maxTouchPoints!="number"))return navigator.maxTouchPoints}var ut=(i,e,t)=>{let r=!1,n,o=null,s=null,a=()=>{s!==null&&(clearTimeout(s),s=null);let d=o;r=!1,o=null,d!==null&&i({...n===void 0?{}:{captureSeq:n},lowType:e,ts:d,durationMs:Date.now()-d})};return{extend:()=>{if(!r){let d=t?.();r=!0,o=Date.now(),n=d}s!==null&&clearTimeout(s),s=setTimeout(a,150)},flush:a}};function or(i,e,t){let r=[],n=(s,a,p)=>{let d=l=>t(a,()=>p(l));s.addEventListener(a,d),r.push(()=>s.removeEventListener(a,d))};n(window,"blur",()=>e.blur()),n(window,"focus",()=>e.focus()),n(document,"visibilitychange",()=>e.visibilityChange(document.visibilityState==="hidden")),n(document,"focusout",s=>e.focusOut(s.target,!!s.relatedTarget)),n(document,"focusin",s=>e.focusIn(()=>s.composedPath())),n(document,"pointerdown",s=>e.pointerDown(s.target)),window.visualViewport&&(n(window.visualViewport,"resize",()=>e.viewportResize()),n(window.visualViewport,"scroll",()=>e.viewportScroll())),n(window,"pagehide",()=>e.pageHide());let o=window.navigation;return o&&n(o,"currententrychange",s=>{let a=s,p=a.from?.index,d=o.currentEntry?.index;a.navigationType==="traverse"&&typeof p=="number"&&typeof d=="number"&&p>=0&&d>=0&&d<p&&e.navigateBack()}),r}function sr(i){let e=[];for(let t=document.activeElement;t;t=t.shadowRoot?.activeElement??null)e.push(t);return e}function ar(i){let e=document.activeElement;return{active:e,idle:e===document.body||!e}}var _i,re=()=>_i??=S(),ve=class{constructor(e,t,r){this.logger=e;this.enqueue=t;this.flushKeepalive=r;typeof window>"u"||typeof document>"u"||(this.removers=or(0,{blur:()=>{this.flushInputs(),this.bracket=this.context(),this.emit({lowType:"window-blur",ts:Date.now()},this.bracket)},focus:()=>{this.flushInputs(),this.emit({lowType:"window-focus",ts:Date.now()},this.bracket??this.context()),this.bracket=void 0},visibilityChange:n=>{this.flushInputs(),this.emit({lowType:`document-visibilitychange-${n?"hidden":"visible"}`,ts:Date.now()})},focusOut:(n,o)=>{let s=this.findInput(n);this.lastBlur=s&&!o&&Date.now()-this.unrelatedPointerAt>250?{registration:s,ts:Date.now()}:void 0},focusIn:n=>{this.lastBlur=void 0;let o=this.inputFocusListeners.size>0&&n().find(s=>this.findInput(s));o&&this.notifyInputFocus(o)},pointerDown:n=>{this.findInput(n)?this.unrelatedPointerAt=-1/0:(this.lastBlur=void 0,this.unrelatedPointerAt=Date.now())},viewportResize:()=>this.extendViewport("resize"),viewportScroll:()=>this.extendViewport("scroll"),pageHide:()=>{this.flushInputs(),this.resize.flush(),this.scroll.flush(),this.flushKeepalive()},navigateBack:()=>{this.flushInputs(),this.emit({lowType:"window-navigate-back",ts:Date.now()})}},(n,o)=>{try{o()}catch(s){this.logger.error(`Failed to observe window ${n}`,s)}}))}inputs=new Set;inputFocusListeners=new Set;ceremonies=new Set;removers=[];lastBlur;bracket;unrelatedPointerAt=-1/0;destroyed=!1;viewportContext={};resize=ut(e=>this.emit(e,this.viewportContext.resize),"visualviewport-resize",P);scroll=ut(e=>this.emit(e,this.viewportContext.scroll),"visualviewport-scroll",P);registerInputs(e,t,r){if(this.destroyed)return()=>{};let n={fields:e,context:t,flush:r};if(this.inputs.add(n),this.inputFocusListeners.size>0&&typeof document<"u"){let o=sr(0),s=e.find(a=>o.includes(a));s&&this.notifyInputFocus(s)}return()=>{this.inputs.delete(n),this.lastBlur?.registration===n&&(this.lastBlur=void 0)}}beginCeremony(e){let t={context:e,settled:!1};this.destroyed||(this.flushInputs(),this.ceremonies.add(t));let r=()=>{t.timer&&clearTimeout(t.timer),this.ceremonies.delete(t),this.bracket===t.context&&(this.bracket=void 0)};return{settle:n=>{t.settled=!0,t.timer&&clearTimeout(t.timer),t.timer=setTimeout(r,n)},destroy:r}}onInputFocus(e){return this.destroyed?()=>{}:(this.inputFocusListeners.add(e),()=>this.inputFocusListeners.delete(e))}notifyInputFocus(e){for(let t of this.inputFocusListeners)try{t(e)}catch(r){this.logger.error("Failed to notify registered input focus",r)}}context(){let e=[...this.ceremonies].filter(o=>!o.settled);if(e.length===1)return e[0].context;if(e.length>1)return;let t=ar(0),r=this.findInput(t.active);if(r)return r.context();let n=this.lastBlur;if(n&&Date.now()-n.ts<=250&&t.idle)return n.registration.context()}findInput(e){return[...this.inputs].find(t=>t.fields.some(r=>r===e))}flushInputs(){for(let e of this.inputs)try{e.flush()}catch(t){this.logger.error("Failed to flush window input context",t)}}emit(e,t){if(this.destroyed)return;let{sessionId:r,...n}=t??{};this.enqueue({...e,...n,captureSeq:e.captureSeq??P(),sourceKind:"window",captureVersion:1,pageId:re()},r)}extendViewport(e){let t=this.context(),r=this.viewportContext[e];(r?.subflowStartEventId!==t?.subflowStartEventId||r?.fieldRole!==t?.fieldRole||r?.sessionId!==t?.sessionId)&&this[e].flush(),this.viewportContext[e]=t,this[e].extend()}destroy(){if(!this.destroyed){this.flushInputs(),this.resize.flush(),this.scroll.flush(),this.destroyed=!0;for(let e of this.removers)e();for(let e of this.ceremonies)e.timer&&clearTimeout(e.timer);this.ceremonies.clear(),this.inputs.clear(),this.inputFocusListeners.clear()}}};var Di=new Set;function lr(i){Di.add(i)}function Se(i,e,t){return fetch(e,t)}function dr(i){if(typeof navigator?.sendBeacon=="function")return(e,t)=>navigator.sendBeacon(e,t)}var Ai=6e4,Mi=6e4,be=class{constructor(e){this.options=e;lr(0)}async send(e,t){try{e.meta={...e.meta,sent:Date.now(),transport:"fetch"};let r=JSON.stringify(e),n=typeof AbortController<"u"?new AbortController:void 0,o=n?setTimeout(()=>n.abort(),Mi):void 0;try{let s={method:"POST",headers:{"Content-Type":"application/json",...this.options.headers,...t},body:r,keepalive:new Blob([r]).size<=Ai,...n?{signal:n.signal}:{}},a=await Se(0,this.options.url,s),p={statusCode:a.status,headers:{"retry-after":a.headers.get("Retry-After")}};if(a.headers.get("X-Corbado-Observe-Accepted")==="1"&&(p.deliveryAccepted=!0),a.status===200)try{let d=q(await a.json());d&&(p.config=d)}catch(d){this.options.logger.error("Failed to parse SDK config response",d),this.options.logger.reportTelemetry?.("error","failed to parse SDK config response")}return p}finally{o&&clearTimeout(o)}}catch(r){return this.options.logger.error("Failed to send event",r),{}}}sendBeacon(e){try{this.options.logger.debug(`Sending ${e.events.length} events via beacon`);let t=dr(0);if(!t)return!1;e.meta={...e.meta,sent:Date.now(),transport:"beacon"};let r=new Blob([JSON.stringify(e)],{type:"text/plain"});return t(this.options.url,r)}catch(t){return this.options.logger.error("Failed to send event via beacon",t),!1}}flush(e){return Promise.resolve(!0)}};function Te(i,e,t,r={}){let n=typeof navigator<"u"?navigator.locks:void 0;if(n?.request){let o=r.timeoutMs,s=o!==void 0&&typeof AbortController<"u"?new AbortController:null;if(o!==void 0&&!s)return Promise.resolve().then(t);try{let a=!1,p,d=()=>{p!==void 0&&(clearTimeout(p),p=void 0)},l=()=>(a=!0,d(),t()),c=s?n.request(e,{signal:s.signal},l):n.request(e,l);return s&&o!==void 0&&!a&&(p=setTimeout(()=>{p=void 0,s.abort();try{r.onTimeout?.()}catch{}},o)),c.catch(f=>{if(a)throw f;return t()}).finally(d)}catch{}}try{return Promise.resolve(t())}catch(o){return Promise.reject(o)}}function pr(i){return typeof navigator<"u"&&!!navigator.locks?.request}var Hi="cbo_outbox",ft="cbo_outbox",Bi=500,Ni=512*1024,Ui=10080*60*1e3;function qi(i){let e=i.event,t=typeof e.timestamp=="number"?e.timestamp:e.ts;if(typeof t=="number"&&Number.isFinite(t))return t;let r=/^([0-9a-f]{8})-?([0-9a-f]{4})-?7/i.exec(i.id);return r?parseInt(r[1]+r[2],16):void 0}function Ki(i){if(!i||typeof i!="object")return!1;let e=i;return typeof e.id=="string"&&e.id!==""&&typeof e.sessionId=="string"&&typeof e.flushAfter=="number"&&Number.isFinite(e.flushAfter)&&typeof e.attempts=="number"&&Number.isFinite(e.attempts)&&typeof e.event=="object"&&e.event!==null}var W=class{constructor(e,t,r=Bi,n=Ni,o=ft,s=Hi){this.storage=e;this.logger=t;this.maxEntries=r;this.maxSerializedLength=n;this.lockName=o;this.storageKey=s;this.entries=this.read(),typeof __CBO_DATA_RETENTION__=="boolean"&&__CBO_DATA_RETENTION__&&this.purgeExpired(Date.now())}entries=[];reportedMalformed=!1;purgeExpired(e){let t=n=>{let o=qi(n);return o!==void 0&&e-o>Ui};if(!this.entries.some(t))return;let r=this.entries.filter(t).length;this.entries=this.entries.filter(n=>!t(n)),this.logger.debug(`EventStore deleted ${r} entries past the retention limit`),this.mutate(n=>n.filter(o=>!t(o)))}read(){let e=this.storage.getItem(this.storageKey);if(!Array.isArray(e))return[];let t=e.filter(Ki);return t.length<e.length&&!this.reportedMalformed&&(this.reportedMalformed=!0,this.logger.error(`EventStore dropped ${e.length-t.length} malformed outbox entries`),this.logger.reportTelemetry?.("error","event store dropped malformed outbox entries")),t}mutate(e){return Te(0,this.lockName,()=>{try{let t=e(this.read());if(t.length>this.maxEntries){let r=t.length-this.maxEntries;t=t.slice(t.length-this.maxEntries),this.logger.error(`EventStore evicted ${r} oldest entries (cap ${this.maxEntries})`),this.logger.reportTelemetry?.("error","event store evicted entries (cap)")}t=this.enforceSizeBudget(t),this.entries=t,this.storage.setItem(this.storageKey,t)}catch(t){this.logger.error("Failed to mutate event store",t),this.logger.reportTelemetry?.("error","failed to mutate event store")}})}enforceSizeBudget(e){let t=e.map(o=>JSON.stringify(o).length),r=t.reduce((o,s)=>o+s,e.length+1),n=0;for(;r>this.maxSerializedLength&&n<e.length;)r-=t[n]+1,n++;return n===0?e:(this.logger.error(`EventStore evicted ${n} oldest entries (size budget ${this.maxSerializedLength})`),this.logger.reportTelemetry?.("error","event store evicted entries (size budget)"),e.slice(n))}add(e){return this.mutate(t=>t.some(r=>r.id===e.id)?t:[...t,e])}all(){return this.entries=this.read(),this.entries}getDue(e){return this.all().filter(t=>t.flushAfter<=e)}remove(e){if(e.length===0)return Promise.resolve();let t=new Set(e);return this.mutate(r=>r.filter(n=>!t.has(n.id)))}update(e){if(e.length===0)return Promise.resolve();let t=new Map(e.map(r=>[r.id,r]));return this.mutate(r=>r.map(n=>t.get(n.id)??n))}size(){return this.all().length}};var cr=6e4,ht=32e3;function ie(i){let e=0;for(let t=0;t<i.length;t++){let r=i.charCodeAt(t);r<128?e+=1:r<2048?e+=2:r>=55296&&r<=56319&&t+1<i.length?(e+=4,t++):e+=3}return e}var Wi=["cbo_visibility_change_debug","cbo_pagehide_debug"],we=class{constructor(e,t,r,n,o={},s){this.logger=e;this.transport=t;this.sessionId=r;this.sdk=n;this.storage=s;if(this.batchSize=o.batchSize||50,this.flushIntervalOverride=o.flushInterval,this.debug=o.debug??!1,this.requestConfig=o.requestConfig??!0,this.onConfigReceived=o.onConfigReceived,this.getDataPolicy=o.getDataPolicy,this.getCrossOriginSession=o.getCrossOriginSession,this.fixedData=o.fixedData===!0,this.beforeEventBatchSend=o.beforeEventBatchSend,this.standaloneDeviceInfo=o.standaloneDeviceInfo,this.config=o.config??b,this.priorityFlowTypes=new Set(this.config.flushOnFlowTypeFinished),this.outboxLockName=o.outboxLockName,this.config.durableOutbox&&this.storage&&(this.store=new W(this.storage,this.logger,void 0,void 0,this.outboxLockName),this.pending=this.store.all()),this.storage){for(let p of Wi)this.storage.removeItem(p);this.lowStore=new W(this.storage,this.logger,1e3,256*1024,`${this.outboxLockName??"cbo_outbox"}:lows`,"cbo_low_outbox_v1");let a=this.lowStore.all();this.lowPending=a.filter(p=>this.validPendingLow(p)),this.lowStore.remove(a.filter(p=>!this.validPendingLow(p)).map(p=>p.id))}this.setupLifecycleHooks(),(this.pending.length>0||this.lowPending.length>0)&&(this.dirtySinceSyncFlush=!0,this.scheduleFlush(0,"recovery"))}pending=[];lowsQueue=[];lowPending=[];lowStore;telemetryQueue=[];lane;timer=null;isFlushing=!1;flushingDone;destroyed=!1;dirtySinceSyncFlush=!1;onVisibilityChange=null;onPageHide=null;removeVisibilityChange=null;removePageHide=null;batchSize;flushIntervalOverride;debug;requestConfig;onConfigReceived;getDataPolicy;getCrossOriginSession;fixedData;beforeEventBatchSend;standaloneDeviceInfo;config;priorityFlowTypes;outboxLockName;store;configResolved=!1;setSessionId(e){this.sessionId=e}flushInterval(){return this.flushIntervalOverride??this.config.flushIntervalMs}enqueue(e,t=this.sessionId){try{let r={id:e.id,sessionId:t,flushAfter:0,attempts:0,event:e};this.pending.push(r),this.store?.add(r),this.scheduleAfterEnqueue(e)}catch(r){this.logger.error("Failed to enqueue event",r)}}enqueueLow(e,t=this.sessionId){try{let r={...e,id:e.id??S()};if(this.config.durableLowOutbox){let n={id:r.id,sessionId:t,event:r,attempts:0,flushAfter:0};this.lowPending.push(n),this.lowPending=this.lowPending.slice(-1e3),this.lowStore?.add(n)}else this.lowsQueue.push({sessionId:t,event:r});this.scheduleAfterEnqueue()}catch(r){this.logger.error("Failed to enqueue low event",r)}}notifyDeviceInfo(){try{this.dirtySinceSyncFlush=!0,this.scheduleFlush(this.flushInterval(),"timer")}catch(e){this.logger.error("Failed to schedule device info flush",e)}}enqueueTelemetry(e){try{if(!this.config.telemetry)return;this.telemetryQueue.push(e),this.dirtySinceSyncFlush=!0,this.config.flushOnTelemetry&&this.flush("telemetry")}catch(t){this.logger.error("Failed to enqueue telemetry",t)}}scheduleAfterEnqueue(e){if(this.dirtySinceSyncFlush=!0,e!==void 0&&this.isPriorityEvent(e)){this.flush("flow-finished");return}this.scheduleFlush(this.flushInterval(),"timer")}isPriorityEvent(e){if(e.type!=="predefined"||e.name!=="flow_finished"&&e.name!=="flow_auto_finished")return!1;let t=e.data?.flowName;return typeof t=="string"&&this.priorityFlowTypes.has(t)}scheduleFlush(e,t){this.destroyed||this.timer||(this.timer=setTimeout(()=>{this.timer=null,this.flush(t)},e))}clearTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null)}async flush(e="timer"){if(this.destroyed)return;if(this.isFlushing){if(e==="destroy"){await this.flushingDone;try{this.lane?.sendUnload(ht,e,!0,!1)}catch(r){this.logger.error("Unexpected error in queue flush",r)}}return}this.isFlushing=!0;let t;this.flushingDone=new Promise(r=>{t=r});try{for(this.clearTimer();;){let r=Date.now(),n=this.getDuePending(r),o=this.lowPending.filter(y=>y.flushAfter<=r),s=this.lane,a=e==="destroy"||!s?[]:s.items.filter(y=>y.flushAfter<=r),p=n.length===0&&o.length===0&&this.lowsQueue.length===0&&this.telemetryQueue.length===0&&a.length===0;if(p&&!this.hasStandaloneDeviceInfo())break;let d=n[0]?.sessionId??o[0]?.sessionId??this.lowsQueue[0]?.sessionId??a[0]?.sessionId??this.sessionId,l=n.filter(y=>y.sessionId===d).slice(0,this.batchSize),c=o.filter(y=>y.sessionId===d).slice(0,100),f=[...c.map(y=>y.event),...this.takeLows(d,100-c.length)];this.prepareEvents(l,e);let g=d===this.sessionId?this.takeTelemetry():[],u=d===this.sessionId?this.takeStandaloneDeviceInfo():void 0,m=s&&a.length>0?s.selectBatch(a,d):[],v={sessionId:d,events:l.map(y=>y.event),sdk:this.sdk};if(f.length>0&&(v.lows=f),g.length>0&&(v.telemetry=g),m.length>0&&(v.probes=m.map(y=>y.entry)),u&&(v.deviceInfo=u),p&&!u)break;this.attachBatchMeta(v,[...l,...c,...m],e),c.length&&(v.deliveryAck=!0);let E=this.shouldRequestConfig()?{[Bt]:this.config.version||"1"}:void 0,C=await this.transport.send(v,E).catch(y=>(this.logger.error("Unexpected error in queue flush",y),{}));if(v.deliveryAck&&C.statusCode&&C.statusCode>=200&&C.statusCode<300&&!C.deliveryAccepted&&(C={...C,statusCode:503}),this.requestConfig&&this.handleConfigResponse(C),this.handleLowSendResult(C,c,r),s?.handleResult(C,m,r),!this.handleSendResult(C,l,r))break}e==="destroy"&&this.lane?.sendUnload(ht,e,!0,!1)}catch(r){this.logger.error("Unexpected error in queue flush",r)}finally{this.isFlushing=!1,t(),this.flushingDone=void 0,this.rescheduleIfPending()}}attachBatchMeta(e,t,r){e.meta={...e.meta,flushReason:r};let n=this.readDataPolicy();n!==void 0&&(e.meta={...e.meta,dataPolicy:n}),this.config.version&&(e.meta={...e.meta,configVersion:this.config.version}),this.fixedData&&(e.meta={...e.meta,fixedData:!0});try{let s=this.getCrossOriginSession?.(e.sessionId);s&&(e.meta={...e.meta,crossOriginSession:s})}catch{}let o=t.reduce((s,a)=>Math.max(s,a.attempts),0);o>0&&(e.meta={...e.meta,retryCount:o})}prepareEvents(e,t){if(!(!this.beforeEventBatchSend||e.length===0))try{this.beforeEventBatchSend(e.map(r=>r.event),t)}catch(r){this.logger.error("Failed to prepare events for sending",r)}}readDataPolicy(){try{return this.getDataPolicy?.()}catch(e){this.logger.debug("Failed to read data policy for batch meta",e);return}}getDuePending(e){return this.pending.filter(t=>t.flushAfter<=e)}takeLows(e=this.sessionId,t=100){let r=this.lowsQueue.filter(o=>o.sessionId===e).slice(0,t),n=new Set(r);return this.lowsQueue=this.lowsQueue.filter(o=>!n.has(o)),r.map(o=>o.event)}validPendingLow(e){return typeof e.event?.lowType=="string"&&e.event.id===e.id&&Number.isFinite(e.event.ts)&&e.event.ts>Date.now()-7*864e5}removeLowEntries(e){let t=new Set(e);this.lowPending=this.lowPending.filter(r=>!t.has(r.id)),this.lowStore?.remove(e)}handleLowSendResult(e,t,r){let n=e.statusCode;if(n!==void 0&&n>=200&&n<300){e.deliveryAccepted?this.removeLowEntries(t.map(o=>o.id)):this.deferLowEntries(t,r);return}if(!this.isRetryable(n)){this.removeLowEntries(t.map(o=>o.id)),this.logger.reportTelemetry?.("error","low events rejected by ingestion");return}this.deferLowEntries(t,r,this.parseRetryAfter(e))}deferLowEntries(e,t,r=null){let n=[];for(let o of e){if(!this.validPendingLow(o)){n.push(o.id);continue}o.attempts=Math.min(o.attempts+1,16),o.flushAfter=t+Math.max(Math.min(6e4,1e3*2**Math.min(o.attempts,6)),this.backoffForAttempt(o.attempts,r))}this.removeLowEntries(n),this.lowStore?.update(e.filter(o=>!n.includes(o.id)))}hasStandaloneDeviceInfo(){try{return this.standaloneDeviceInfo?.has()??!1}catch(e){return this.logger.error("Failed to read device info for batch",e),!1}}takeStandaloneDeviceInfo(){try{return this.standaloneDeviceInfo?.take()}catch(e){this.logger.error("Failed to read device info for batch",e);return}}takeTelemetry(){let e=this.telemetryQueue;return this.telemetryQueue=[],e}shouldRequestConfig(){return this.requestConfig&&!this.configResolved}handleConfigResponse(e){let t=e.statusCode;typeof t=="number"&&t>=200&&t<300&&(this.configResolved=!0),e.config&&(this.config.version||this.updateConfig(e.config),this.onConfigReceived?.(e.config))}updateConfig(e){if(this.destroyed)return;let t=this.config.flushIntervalMs!==e.flushIntervalMs;if(this.config={...e,durableOutbox:this.config.durableOutbox||e.durableOutbox},this.priorityFlowTypes=new Set(e.flushOnFlowTypeFinished),e.durableLowOutbox&&this.lowsQueue.length){let n=this.lowsQueue;this.lowsQueue=[];for(let{event:o,sessionId:s}of n)this.enqueueLow(o,s)}let r=!1;if(this.config.durableOutbox&&this.storage&&!this.store){this.store=new W(this.storage,this.logger,void 0,void 0,this.outboxLockName);let n=new Set(this.pending.map(s=>s.id)),o=this.store.all().filter(s=>!n.has(s.id));for(let s of this.pending)this.store.add(s);this.pending=[...o,...this.pending],r=o.length>0}r?(this.dirtySinceSyncFlush=!0,this.clearTimer(),this.scheduleFlush(0,"recovery")):t&&(this.clearTimer(),this.rescheduleIfPending())}handleSendResult(e,t,r){let n=e.statusCode,o=typeof n=="number"&&n>=200&&n<300;if(t.length===0)return o;if(o)return this.removeEntries(t.map(l=>l.id)),!0;if(!this.isRetryable(n))return this.removeEntries(t.map(l=>l.id)),!1;let s=Math.max(1,this.config.retry.maxAttempts),a=this.parseRetryAfter(e),p=[],d=[];for(let l of t)l.attempts+=1,l.attempts>=s?p.push(l.id):(l.flushAfter=r+this.backoffForAttempt(l.attempts,a),d.push(l));return this.removeEntries(p),this.store?.update(d),!1}isRetryable(e){return e===void 0||e===408||e===429?!0:e>=500}backoffForAttempt(e,t){let r=this.config.retry,n=r.baseDelayMs*Math.pow(2,Math.max(0,e-1));r.maxDelayMs>0&&(n=Math.min(n,r.maxDelayMs));let o=Math.round(n/2+Math.random()*(n/2));return t!==null&&(o=Math.max(o,t)),o}parseRetryAfter(e){let t=e.headers?.["retry-after"];if(!t)return null;let r=Number(t);if(!Number.isNaN(r))return r*1e3;let n=Date.parse(t);return Number.isNaN(n)?null:Math.max(0,n-Date.now())}removeEntries(e){if(e.length===0)return;let t=new Set(e);this.pending=this.pending.filter(r=>!t.has(r.id)),this.store?.remove(e)}rescheduleIfPending(){try{if(this.destroyed||this.timer)return;let e=this.lane?this.lane.items:[];if(this.pending.length===0&&this.lowPending.length===0&&this.lowsQueue.length===0&&e.length===0)return;let t=Date.now();if(this.getDuePending(t).length>0||this.lowPending.some(n=>n.flushAfter<=t)||this.lowsQueue.length>0||e.some(n=>n.flushAfter<=t)){this.scheduleFlush(this.flushInterval(),"timer");return}let r=Math.min(...[...this.pending,...this.lowPending,...e].map(n=>n.flushAfter));this.scheduleFlush(Math.max(0,r-t),"backoff")}catch(e){this.logger.error("Failed to reschedule queue flush",e)}}setupLifecycleHooks(){typeof window>"u"||(this.onVisibilityChange=()=>{try{K(0)&&this.config.tvc&&this.flushSync("visibility-change")}catch(e){this.logger.error("Unexpected error in queue flushSync",e)}},this.onPageHide=()=>{try{this.config.tph&&this.flushSync("pagehide")}catch(e){this.logger.error("Unexpected error in queue flushSync",e)}},this.removeVisibilityChange=O(0,"visibilitychange",this.onVisibilityChange),this.removePageHide=O(0,"pagehide",this.onPageHide))}flushKeepalive(e="manual"){this.flushSync(e)}flushSync(e){let t=this.flushSyncEvents(e),r=this.lane;e==="pagehide"&&r&&r.items.length>0&&r.sendUnload(Math.min(cr-t,ht),e,!0,!0)}flushSyncEvents(e){if(!this.dirtySinceSyncFlush)return 0;let t=this.sessionId,r=this.pending.filter(l=>l.sessionId===t),n=r.slice(0,this.batchSize),o=this.lowPending.filter(l=>l.sessionId===t).slice(0,100),s=[...o.map(l=>l.event),...this.takeLows(t,100-o.length)];this.prepareEvents(n,e);let a=this.takeTelemetry(),p=this.takeStandaloneDeviceInfo();if(n.length===0&&s.length===0&&a.length===0&&!p)return this.dirtySinceSyncFlush=!1,0;let d={sessionId:t,events:n.map(l=>l.event),sdk:this.sdk};return s.length>0&&(d.lows=s),a.length>0&&(d.telemetry=a),p&&(d.deviceInfo=p),this.attachBatchMeta(d,[...n,...o],e),o.length&&(d.deliveryAck=!0),this.config.beaconKeepalive&&this.transport.sendBeacon?this.transport.sendBeacon(d)||this.transport.send(d):this.transport.send(d),this.config.durableOutbox||this.removeEntries(n.map(l=>l.id)),this.dirtySinceSyncFlush=!this.config.durableOutbox&&r.length>n.length,this.approximateSize(d)}approximateSize(e){try{return ie(JSON.stringify(e))}catch{return cr}}destroy(){try{this.destroyed=!0,this.clearTimer(),this.lane&&this.lane.drop(this.lane.items.slice()),typeof window<"u"&&(this.removeVisibilityChange&&this.removeVisibilityChange(),this.removePageHide&&this.removePageHide())}catch(e){this.logger.error("Failed to destroy queue lifecycle hooks",e)}}};var gt={d:(i,e)=>{for(var t in e)gt.o(e,t)&&!gt.o(i,t)&&Object.defineProperty(i,t,{enumerable:!0,get:e[t]})},o:(i,e)=>Object.prototype.hasOwnProperty.call(i,e)},mt={};gt.d(mt,{A:()=>Vi,k:()=>ur});var V=function(i,e,t,r){return new(t||(t=Promise))(function(n,o){function s(d){try{p(r.next(d))}catch(l){o(l)}}function a(d){try{p(r.throw(d))}catch(l){o(l)}}function p(d){var l;d.done?n(d.value):(l=d.value,l instanceof t?l:new t(function(c){c(l)})).then(s,a)}p((r=r.apply(i,e||[])).next())})},$=function(i,e){var t,r,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(p){return function(d){return(function(l){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(s=0)),s;)try{if(t=1,r&&(n=2&l[0]?r.return:l[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,l[1])).done)return n;switch(r=0,n&&(l=[2&l[0],n.value]),l[0]){case 0:case 1:n=l;break;case 4:return s.label++,{value:l[1],done:!1};case 5:s.label++,r=l[1],l=[0];continue;case 7:l=s.ops.pop(),s.trys.pop();continue;default:if(n=s.trys,!((n=n.length>0&&n[n.length-1])||l[0]!==6&&l[0]!==2)){s=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]<n[3])){s.label=l[1];break}if(l[0]===6&&s.label<n[1]){s.label=n[1],n=l;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(l);break}n[2]&&s.ops.pop(),s.trys.pop();continue}l=e.call(i,s)}catch(c){l=[6,c],r=0}finally{t=n=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}})([p,d])}}};function ur(){return V(this,void 0,Promise,function(){return $(this,function(i){switch(i.label){case 0:return[4,new Promise(function(e,t){var r="Unknown",n=!1;function o(l){n||(n=!0,e({isPrivate:l,browserName:r}))}function s(){var l=0,c=parseInt("-1");try{c.toFixed(c)}catch(f){l=f.message.length}return l}function a(){return V(this,void 0,void 0,function(){var l,c;return $(this,function(f){switch(f.label){case 0:return f.trys.push([0,2,,3]),[4,navigator.storage.getDirectory()];case 1:return f.sent(),o(!1),[3,3];case 2:return l=f.sent(),c=l instanceof Error&&typeof l.message=="string"?l.message:String(l),o(c.includes("unknown transient reason")),[3,3];case 3:return[2]}})})}function p(){var l;return V(this,void 0,Promise,function(){return $(this,function(c){switch(c.label){case 0:return typeof((l=navigator.storage)===null||l===void 0?void 0:l.getDirectory)!="function"?[3,2]:[4,a()];case 1:return c.sent(),[3,3];case 2:navigator.maxTouchPoints!==void 0?(function(){var f=String(Math.random());try{var g=indexedDB.open(f,1);g.onupgradeneeded=function(u){var m=u.target.result,v=function(E){o(E)};try{m.createObjectStore("t",{autoIncrement:!0}).put(new Blob),v(!1)}catch(E){(E instanceof Error&&typeof E.message=="string"?E.message:String(E)).includes("are not yet supported")?v(!0):v(!1)}finally{m.close(),indexedDB.deleteDatabase(f)}},g.onerror=function(){return o(!1)}}catch{o(!1)}})():(function(){var f=window.openDatabase,g=window.localStorage;try{f(null,null,null,null)}catch{return void o(!0)}try{g.setItem("test","1"),g.removeItem("test")}catch{return void o(!0)}o(!1)})(),c.label=3;case 3:return[2]}})})}function d(){var l;return V(this,void 0,Promise,function(){var c,f,g;return $(this,function(u){switch(u.label){case 0:if(typeof((l=navigator.storage)===null||l===void 0?void 0:l.getDirectory)!="function")return[3,5];u.label=1;case 1:return u.trys.push([1,3,,4]),[4,navigator.storage.getDirectory()];case 2:return u.sent(),o(!1),[3,4];case 3:return c=u.sent(),f=c instanceof Error&&typeof c.message=="string"?c.message:String(c),o(f.includes("Security error")),[2];case 4:return[3,6];case 5:(g=indexedDB.open("inPrivate")).onerror=function(m){if(g.error&&g.error.name==="InvalidStateError")return m.preventDefault(),void o(!0);o(!1)},g.onsuccess=function(){indexedDB.deleteDatabase("inPrivate"),o(!1)},u.label=6;case 6:return[2]}})})}(function(){return V(this,void 0,Promise,function(){return $(this,function(l){switch(l.label){case 0:return s()!==44&&s()!==43?[3,2]:(r="Safari",[4,p()]);case 1:return l.sent(),[3,6];case 2:return s()!==51?[3,3]:(c=navigator.userAgent,r=c.match(/Chrome/)?navigator.brave!==void 0?"Brave":c.match(/Edg/)?"Edge":c.match(/OPR/)?"Opera":"Chrome":"Chromium",(function(){var f=this,g="__di_"+Math.random().toString(36).slice(2),u=new Uint8Array(16384),m=indexedDB.open(g,1);m.onupgradeneeded=function(){m.result.createObjectStore("s")},m.onerror=function(){indexedDB.deleteDatabase(g),o(!1)},m.onsuccess=function(){var v=m.result,E=!1;try{var C=v.transaction("s","readwrite",{durability:"strict"});E=C.durability==="strict",C.abort()}catch{}if(!E)return v.close(),indexedDB.deleteDatabase(g),void o(!1);var y=function(Z){return new Promise(function(_,ee){var te=performance.now(),N=0,x=function(){if(N!==15){var A=v.transaction("s","readwrite",{durability:Z});A.objectStore("s").put(u,N),N++,A.oncomplete=x,A.onerror=A.onabort=function(){return ee(A.error)}}else _(performance.now()-te)};x()})};V(f,void 0,void 0,function(){var Z,_,ee,te,N;return $(this,function(x){switch(x.label){case 0:return Z=performance.now(),[4,y("relaxed")];case 1:return x.sent(),[4,y("strict")];case 2:x.sent(),_=[],ee=0,x.label=3;case 3:return ee<15?[4,y("relaxed")]:[3,7];case 4:return te=x.sent(),[4,y("strict")];case 5:if(N=x.sent(),_.push(te>0?N/te:1/0),_.length>=7&&performance.now()-Z>=1e3)return[3,7];x.label=6;case 6:return ee++,[3,3];case 7:return _.sort(function(A,wi){return A-wi}),v.close(),indexedDB.deleteDatabase(g),o(_[_.length>>1]<1.3),[2]}})}).catch(function(){v.close(),indexedDB.deleteDatabase(g),o(!1)})}})(),[3,6]);case 3:return s()!==25?[3,5]:(r="Firefox",[4,d()]);case 4:return l.sent(),[3,6];case 5:navigator.msSaveBlob!==void 0?(r="Internet Explorer",o(window.indexedDB===void 0)):t(new Error("detectIncognito cannot determine the browser")),l.label=6;case 6:return[2]}var c})})})().catch(t)})];case 1:return[2,i.sent()]}})})}var Vi=ur,fr=mt.A,fs=mt.k;async function hr(i){return(await fr()).isPrivate}var $i=300,ne=6e3,gr="cbo_pm",Gi=10080*60*1e3,mr="detectincognitojs@1.9.0",yr={timing:!1},yt="cbo_tab_id",vr={bluetoothAvailable:"bt",clientCapabilities:"cc",userVerifyingPlatformAuthenticatorAvailable:"uvpaa",conditionalMediationAvailable:"cm",javaScriptHighEntropy:"he",privateMode:"pm",webdriver:"wd",maxTouchPoints:"mtp"};function L(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Sr(i,e,t){return{field:i,source:e,error:{name:"TimeoutError",message:`Device info collection timed out after ${t}ms`}}}async function vt(i,e){let t;try{return await Promise.race([i.then(()=>!0,()=>!0),new Promise(r=>{t=setTimeout(()=>r(!1),Math.max(0,e))})])}finally{t&&clearTimeout(t)}}var Ee=class{constructor(e,t,r="localstorage",n,o=()=>yr,s,a=!0,p){this.logger=e;this.storage=t;this.storageSource=r;this.sessionStorage=n;this.settings=o;this.emitTelemetry=s;this.privateModeEnabled=a;this.deviceHandleMaxAgeMs=p}pagePrivateMode;privateModeDetectionStarted=!1;lastKnown={};async collect(e,t={}){try{let r=this.resolveSettings(),n=L(),o=this.getClientEnvHandle(),s={type:"web",clientEnvHandle:o.value,clientEnvHandleMeta:{timestamp:o.timestamp,source:o.source},tabId:this.getTabId()},a=typeof __CBO_DATA_PRIVATE_MODE__=="boolean"?__CBO_DATA_PRIVATE_MODE__:this.privateModeEnabled,p=a?this.knownPrivateMode(r.timing):void 0,d,l=a&&p===void 0&&!this.privateModeDetectionStarted?this.detectPrivateMode(r.timing).then(y=>{d=y}):void 0,c=this.startFastFields();await vt(Promise.all(c.map(y=>y.promise)),$i);let f=L()-n,g=t.refresh?this.lastKnown:{};r.timing&&this.reportFastTiming(f,c);let u=()=>d?.error?[d.error]:[];this.safePublish(e,this.buildInfo(s,c,d?d.value:p,g,u()),"fast");let m=c.filter(y=>!y.settled),v=l!==void 0&&d===void 0;if(m.length===0&&!v)return;let E=L();await Promise.all([vt(Promise.all(m.map(y=>y.promise)),ne-(E-n)),l]);let C=m.filter(y=>!y.settled).map(y=>Sr(y.field,y.source,ne));C.push(...u()),r.timing&&m.length>0&&this.reportLateTiming(L()-n,m),this.safePublish(e,this.buildInfo(s,c,d?d.value:p,g,C),"update")}catch(r){this.logger.error("Failed to collect device info",r)}}async getInfo(){let e;return await this.collect(t=>{e=t}),e??{}}startFastFields(){return[this.startField("bluetoothAvailable","navigator.bluetooth.getAvailability",()=>Xt(0)),this.startField("clientCapabilities","PublicKeyCredential.getClientCapabilities",()=>tr(0)),this.startField("userVerifyingPlatformAuthenticatorAvailable","PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable",()=>Zt(0)),this.startField("conditionalMediationAvailable","PublicKeyCredential.isConditionalMediationAvailable",()=>er(0)),this.startField("javaScriptHighEntropy","navigator.userAgentData.getHighEntropyValues",()=>rr(0)),this.startField("webdriver","navigator.webdriver",()=>ir(0)),this.startField("maxTouchPoints","navigator.maxTouchPoints",()=>nr(0))]}startField(e,t,r){let n=L(),o={field:e,source:t};return o.promise=Promise.resolve().then(r).then(s=>({field:e,value:s,durationMs:L()-n}),s=>(this.logger.error(`Failed to collect device info field "${e}"`,s),{field:e,durationMs:L()-n,error:{field:e,source:t,error:U(s)??{message:"Unknown error"}}})).then(s=>(o.settled=s,s)),o}buildInfo(e,t,r,n,o){let s={},a=[];for(let d of t)d.settled?(d.settled.error&&a.push(d.settled.error),s[d.field]=d.settled.value,this.remember(d.field,d.settled.value)):s[d.field]=n[d.field];s.privateMode=r,a.push(...o);let p={...e,data:{bluetoothAvailable:s.bluetoothAvailable,javaScriptHighEntropy:s.javaScriptHighEntropy,privateMode:s.privateMode,webdriver:s.webdriver,conditionalMediationAvailable:s.conditionalMediationAvailable,userVerifyingPlatformAuthenticatorAvailable:s.userVerifyingPlatformAuthenticatorAvailable,clientCapabilities:s.clientCapabilities,maxTouchPoints:s.maxTouchPoints}};return a.length>0&&(p.collectionErrors=a),p}remember(e,t){t!==void 0&&(this.lastKnown[e]=t)}safePublish(e,t,r){try{e(t,r)}catch(n){this.logger.error("Failed to publish device info",n)}}knownPrivateMode(e){if(this.pagePrivateMode!==void 0)return this.pagePrivateMode;let t=this.readPrivateModeCache();return t&&(this.pagePrivateMode=t.value,e&&this.reportTelemetry(`device info privateMode from cache, age ${Math.round((Date.now()-t.ts)/1e3)}s`)),this.pagePrivateMode}canCachePrivateMode(){return this.storageSource==="localstorage"}readPrivateModeCache(){if(this.canCachePrivateMode())try{let e=this.storage.getItem(gr);if(!e||typeof e!="object"||typeof e.value!="boolean"||typeof e.ts!="number"||e.dv!==mr)return;let t=Date.now()-e.ts;return t<0||t>=Gi?void 0:e}catch(e){this.logger.debug("Failed to read cached privateMode",e);return}}writePrivateModeCache(e){if(this.canCachePrivateMode())try{this.storage.setItem(gr,{value:e,ts:Date.now(),dv:mr})}catch(t){this.logger.error("Failed to cache privateMode",t)}}async detectPrivateMode(e){this.privateModeDetectionStarted=!0;let t="detectIncognito",r=L(),n=this.startField("privateMode",t,()=>typeof __CBO_DATA_PRIVATE_MODE__=="boolean"&&!__CBO_DATA_PRIVATE_MODE__?void 0:hr(0));if(!await vt(n.promise,ne)||!n.settled)return e&&this.reportTelemetry(`device info privateMode timed out after ${ne}ms`),{error:Sr("privateMode",t,ne)};if(e&&this.reportTelemetry(`device info privateMode detected in ${Math.round(L()-r)}ms`),n.settled.error)return{error:n.settled.error};let s=n.settled.value;return typeof s!="boolean"?{value:void 0}:(this.pagePrivateMode=s,this.writePrivateModeCache(s),{value:s})}resolveSettings(){try{return{timing:this.settings()?.timing===!0}}catch(e){return this.logger.error("Failed to resolve device info collector settings",e),yr}}reportFastTiming(e,t){let r=t.map(n=>`${vr[n.field]}=${Math.round(n.settled?.durationMs??e)}`).join(",");this.reportTelemetry(`device info collected in ${Math.round(e)}ms (${r})`)}reportLateTiming(e,t){let r=t.map(n=>`${vr[n.field]}=${n.settled?Math.round(n.settled.durationMs):"timeout"}`).join(",");this.reportTelemetry(`device info late fields done in ${Math.round(e)}ms (${r})`)}reportTelemetry(e){if(this.emitTelemetry)try{this.emitTelemetry("info",e)}catch(t){this.logger.error("Failed to report device info timing",t)}}getClientEnvHandle(){let e=this.storage.getItem("cbo_client_env_handle"),t=this.deviceHandleMaxAgeMs;if(e&&!(t!==void 0&&!(Date.now()-e.timestamp<=t)))return e;let r=S(),n={timestamp:Date.now(),source:this.storageSource,value:r};return this.storage.setItem("cbo_client_env_handle",n),n}getTabId(){if(!this.sessionStorage)return;let e=this.sessionStorage.getItem(yt);if(e)return e;let t=S();if(this.sessionStorage.setItem(yt,t),this.sessionStorage.getItem(yt)===t)return t}};function ji(){return typeof document<"u"&&K(0)}var Ce=class{constructor(e,t,r,n,o,s){this.logger=e;this.source=t;this.refreshInterval=r;this.attachInterval=n;this.diagnostics=o;this.onUndelivered=s}snapshot;snapshotPhase;publishedAt=0;version=0;deliveredVersion=0;refreshedAt=0;lastAttachedAt=null;eventsSeen=!1;refreshPromise;timer;destroyed=!1;start(){this.refresh()}getForEvent(){if(this.eventsSeen=!0,Date.now()-this.refreshedAt>=this.refreshInterval&&this.refresh(),!!this.snapshot){if(this.version!==this.deliveredVersion)return this.markDelivered("event");if(!(this.lastAttachedAt!==null&&Date.now()-this.lastAttachedAt<this.attachInterval))return this.lastAttachedAt=Date.now(),this.snapshot}}hasUndelivered(){return this.snapshot!==void 0&&this.version!==this.deliveredVersion}takeUndelivered(){if(this.hasUndelivered())return this.markDelivered("flush")}hasStandalone(){return this.eventsSeen&&this.hasUndelivered()}takeStandalone(){if(this.hasStandalone())return this.markDelivered("request")}destroy(){this.destroyed=!0,this.timer&&(clearTimeout(this.timer),this.timer=void 0)}markDelivered(e){return this.deliveredVersion=this.version,this.lastAttachedAt=Date.now(),this.snapshotPhase==="update"&&this.report(`device info update delivered via ${e} after ${Math.max(0,Date.now()-this.publishedAt)}ms`),this.snapshot}publish(e,t){if(t==="fast"&&(this.refreshedAt=Date.now()),!(this.snapshot&&JSON.stringify(this.snapshot)===JSON.stringify(e))&&(this.snapshot=e,this.snapshotPhase=t,this.publishedAt=Date.now(),this.version++,this.eventsSeen&&this.onUndelivered))try{this.onUndelivered()}catch(r){this.logger.error("Failed to announce undelivered device info",r)}}report(e){if(this.diagnostics)try{this.diagnostics.timing()&&this.diagnostics.emit("info",e)}catch(t){this.logger.error("Failed to report device info delivery",t)}}scheduleRefresh(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.refresh()},this.refreshInterval)}refresh(){if(this.refreshPromise)return this.refreshPromise;if(this.timer&&(clearTimeout(this.timer),this.timer=void 0),this.snapshot&&ji())return this.destroyed||this.scheduleRefresh(),Promise.resolve();let e=this.snapshot!==void 0;return this.refreshPromise=Promise.resolve().then(()=>this.source.collect((t,r)=>this.publish(t,r),{refresh:e})).catch(t=>this.logger.error("Failed to refresh device info",t)).finally(()=>{this.refreshPromise=void 0,this.destroyed||this.scheduleRefresh()}),this.refreshPromise}};function br(i){return{getItem:e=>localStorage.getItem(e),setItem:(e,t)=>localStorage.setItem(e,t),removeItem:e=>localStorage.removeItem(e)}}function Tr(i){return{getItem:e=>sessionStorage.getItem(e),setItem:(e,t)=>sessionStorage.setItem(e,t),removeItem:e=>sessionStorage.removeItem(e)}}function oe(i){return{read:()=>document.cookie,write:e=>{document.cookie=e}}}function R(i,e){return`${i}_${e}`}var ke=class{constructor(e,t){this.engine=e;this.namespace=t}getItem(e){return this.engine.getItem(R(e,this.namespace))}setItem(e,t){this.engine.setItem(R(e,this.namespace),t)}removeItem(e){this.engine.removeItem(R(e,this.namespace))}},Oe=class{constructor(e){this.logger=e}area=br(0);getItem(e){try{if(typeof localStorage>"u")return null;let t=this.area.getItem(e);return t?JSON.parse(t):null}catch(t){return this.logger.error(`LocalStorage.getItem failed for key "${e}"`,t),null}}setItem(e,t){try{if(typeof localStorage>"u")return;this.area.setItem(e,JSON.stringify(t))}catch(r){this.logger.error(`LocalStorage.setItem failed for key "${e}"`,r),this.logger.reportTelemetry?.("error",`localStorage.setItem failed: ${e}`)}}removeItem(e){try{if(typeof localStorage>"u")return;this.area.removeItem(e)}catch(t){this.logger.error(`LocalStorage.removeItem failed for key "${e}"`,t)}}},Ie=class{constructor(e,t){this.logger=e;this.domain=t}jar=oe(0);getItem(e){try{if(typeof document>"u")return null;let t=e+"=",r=this.jar.read().split(";");for(let n=0;n<r.length;n++){let o=r[n].trim();if(o.indexOf(t)===0){let s=o.substring(t.length);return JSON.parse(decodeURIComponent(s))}}return null}catch(t){return this.logger.error(`CookieStorage.getItem failed for key "${e}"`,t),null}}setItem(e,t){try{if(typeof document>"u")return;let r=`${e}=${encodeURIComponent(JSON.stringify(t))}; path=/; SameSite=Lax`;this.domain&&(r+=`; domain=${this.domain}`),this.jar.write(r)}catch(r){this.logger.error(`CookieStorage.setItem failed for key "${e}"`,r),this.logger.reportTelemetry?.("error",`cookie.setItem failed: ${e}`)}}removeItem(e){try{if(typeof document>"u")return;let t=`${e}=; Max-Age=-99999999; path=/`;this.domain&&(t+=`; domain=${this.domain}`),this.jar.write(t)}catch(t){this.logger.error(`CookieStorage.removeItem failed for key "${e}"`,t)}}},xe=class{constructor(e){this.logger=e}area=Tr(0);getItem(e){try{if(typeof sessionStorage>"u")return null;let t=this.area.getItem(e);return t?JSON.parse(t):null}catch(t){return this.logger.error(`SessionStorage.getItem failed for key "${e}"`,t),null}}setItem(e,t){try{if(typeof sessionStorage>"u")return;this.area.setItem(e,JSON.stringify(t))}catch(r){this.logger.error(`SessionStorage.setItem failed for key "${e}"`,r),this.logger.reportTelemetry?.("error",`sessionStorage.setItem failed: ${e}`)}}removeItem(e){try{if(typeof sessionStorage>"u")return;this.area.removeItem(e)}catch(t){this.logger.error(`SessionStorage.removeItem failed for key "${e}"`,t)}}};var Pe=1,Fe="cbo_storage_schema",Qi=["cbo_seq","cbo_sdk_config","cbo_experiments","cbo_client_env_handle","cbo_outbox","cbo_visibility_change_debug","cbo_pagehide_debug","cbo_session"],zi=["cbo_session_id","cbo_tab_id"],Yi=["cbo_client_env_handle"];function Le(i,e,t){return i.setItem(e,t),JSON.stringify(i.getItem(e))===JSON.stringify(t)}function St(i,e,t){let r=i.getItem(Fe);if(r!==null){if(r.version!==Pe||r.projectId!==e)return!1;if(r.complete===!0)return!0;if(r.complete!==!1)return!1}else{if(t.some(n=>i.getItem(R(n,e))!==null))return Le(i,Fe,{version:Pe,projectId:e,complete:!0});if(!Le(i,Fe,{version:Pe,projectId:e,complete:!1}))return!1}for(let n of t){let o=R(n,e);if(i.getItem(o)!==null)continue;let s=i.getItem(n);if(s!==null&&!Le(i,o,s))return!1}return Le(i,Fe,{version:Pe,projectId:e,complete:!0})}function wr(i,e,t,r,n){try{if(!St(e,i,Qi))return;St(t,i,zi),r&&St(r,i,Yi)}catch(o){n.error("Failed to migrate legacy Observe storage",o)}}var Ji=10*1e3,Xi=60*1e3,Zi=3600*1e3,en=300*1e3,Er=1440*60*1e3,tn=[1e3,3e3];function rn(i){let e=/(?:^|[\s,])max-age\s*=\s*"?(\d+)"?/i.exec(i?.get("Cache-Control")??"");if(!e)return Zi;let t=Number(i?.get("Age")??0),r=(Number(e[1])-(Number.isFinite(t)&&t>0?t:0))*1e3;return Math.min(Math.max(r,en),Er)}var Re=class{constructor(e,t,r){this.url=e;this.storage=t;this.logger=r;this.initialConfig=qt(t)??void 0,this.appliedVersion=this.initialConfig?.version}initialConfig;requestTimer;retryTimer;controller;removers=[];fetching=!1;stopped=!1;lastAttemptAt;appliedVersion;onConfig;start(e){this.stopped||this.onConfig||(this.onConfig=e,this.listen(),this.refresh())}listen(){if(typeof window>"u")return;let e=()=>{typeof document>"u"||K(0)||this.refresh()};this.removers.push(O(0,"visibilitychange",e),O(0,"pageshow",t=>{t.persisted&&this.refresh()}))}refresh(){try{if(this.stopped||this.fetching)return;let e=Date.now(),t=ye(this.storage),{fetchedAt:r,expiresAt:n}=t??{};if(t?.endpoint===this.url&&typeof r=="number"&&typeof n=="number"&&r>0&&n-r<=Er&&r<=e&&e<n){t.config.version!==this.appliedVersion&&(this.appliedVersion=t.config.version,this.onConfig?.(t.config));return}let o=this.lastAttemptAt===void 0?1/0:e-this.lastAttemptAt;if(o>=0&&o<Xi)return;this.lastAttemptAt=e,clearTimeout(this.retryTimer),this.fetchConfig()}catch(e){this.logger.error("Unexpected error in SDK config refresh",e)}}async fetchConfig(e=0){if(this.stopped||this.fetching)return;this.fetching=!0;let t=typeof AbortController<"u"?new AbortController:void 0;this.controller=t,this.requestTimer=t?setTimeout(()=>t.abort(),Ji):void 0;let r=!0;try{let n=await Se(0,this.url,{method:"GET",cache:"no-cache",...t?{signal:t.signal}:{}});if(!n.ok)throw r=(n.status===408||n.status===429||n.status>=500)&&!n.headers.has("Retry-After"),new Error(`SDK config request failed (${n.status})`);let o=await n.json();r=!1;let s=q(o);if(!s)throw new Error("Invalid SDK config response");if(this.stopped||t?.signal.aborted)return;let a=Date.now();Kt(this.storage,{endpoint:this.url,fetchedAt:a,expiresAt:a+rn(n.headers),config:s}),ye(this.storage)&&this.storage.removeItem(ct),this.appliedVersion=s.version,this.onConfig?.(s)}catch(n){if(!this.stopped){this.logger.error("Failed to fetch SDK config",n);let o=tn[e];(r&&!(n instanceof SyntaxError)||t?.signal.aborted)&&o!==void 0&&(this.retryTimer=setTimeout(()=>{this.fetchConfig(e+1)},o))}}finally{clearTimeout(this.requestTimer),this.requestTimer=void 0,this.controller=void 0,this.fetching=!1}}destroy(){this.stopped=!0,this.removers.splice(0).forEach(e=>e()),clearTimeout(this.requestTimer),clearTimeout(this.retryTimer),this.controller?.abort(),this.onConfig=void 0}};var nn=["ahrefsbot","ahrefssiteaudit","amazonbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","facebookexternal","petalbot","pinterest","screaming frog","yahoo! slurp","yandex","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google"];function Cr(i){if(!i)return!1;let e=i.toLowerCase();return nn.some(t=>e.includes(t))}var kr="@corbado/observe",Or="1.15.0";function Ir(i){let e=i.debug,t,r=(n,o)=>`[Corbado Observe SDK ${n}] ${o}`;return{reportTelemetry(n,o){if(t)try{t(n,o)}catch{}},setTelemetrySink(n){t=n},debug(n,...o){e&&console.log(r("DEBUG",n),...o)},info(n,...o){e&&console.log(r("INFO",n),...o)},warn(n,...o){e&&console.warn(r("WARN",n),...o)},error(n,...o){e&&console.error(r("ERROR",n),...o)},critical(n,...o){console.error(r("CRITICAL",n),...o)}}}var on="/inline/injected/webauthn-listeners.js",xr=/\/dashlane-(?:shadow-dom|top-layer)-page-script\.js/,sn=/-extension:\/\/[^/]+\/content-scripts\/passkey_proxy\/index\.js$/,an=/-extension:\/\/[^/]+\/content_scripts\/shadow-dom\/shadowAttachNotifier\.js:/,Pr=/-extension:\/\/[^/]+\/js\/nordpass-script\.js:/,ln=/-extension:\/\/[^/]+\/js\/passkeys\.js:/,dn=/["'`](?:keeper:shadow-root-attached|webauthn-(?:get|create)-request)["'`]/,pn=/Intercept cancelled for `(?:get|create)`|["'`](?:conditionalMediationAvailable|verifyingPlatformAuthenticatorAvailable)["'`]/,bt=()=>Object.keys(window._sentryDebugIds??{}),Tt=i=>{try{i()}catch(e){return String(e?.stack??"")}return""},Fr=()=>Tt(()=>Element.prototype.attachShadow.call(null,{mode:"open"})),cn=()=>{let i=Object.getOwnPropertyDescriptor(navigator.credentials??{},"get");if(!i?.get||!i.set||i.configurable)return!1;let e=()=>{},t=i.get.call({_get:e});return t===e||typeof t=="function"&&t===i.get.call({})&&!Function.prototype.toString.call(t).includes("[native code]")},wt=(...i)=>{let e=navigator.credentials;return e?i.map(t=>Object.getOwnPropertyDescriptor(e,t)?.value):[]},un=()=>[navigator.credentials?.get,...wt("get","_get")].some(i=>typeof i=="function"&&i.name==="getWebAuthnCredential"),fn=()=>{let i=document.documentElement,e=document.adoptedStyleSheets;if(!i||typeof i.getAnimations!="function"||typeof e?.push!="function"||i.getAnimations().length>0)return!1;let t=new CSSStyleSheet;t.replaceSync(":where(:root){animation:bitwardenfill 1s 1000s paused}"),e.push(t);try{let r=i.getAnimations().filter(n=>n.animationName==="bitwardenfill");return r.forEach(n=>n.cancel()),r.length>0}finally{let r=e.indexOf(t);r>=0&&e.splice(r,1)}},hn,gn=()=>hn??=fn(),mn=()=>{let i=typeof PublicKeyCredential>"u"?void 0:PublicKeyCredential;if(typeof i!="function"||!Object.prototype.hasOwnProperty.call(i,Symbol.hasInstance))return!1;let e=i[Symbol.hasInstance]({});return e instanceof Promise?(e.catch(()=>{}),!0):!1},yn=()=>{let i={get nodeType(){throw new Error("probe")}};return Tt(()=>MutationObserver.prototype.observe.call(null,i))},vn=()=>{let i=new Error("probe"),e=[],t={get nodeType(){return e.push("nodeType"),1},get ownerDocument(){throw e.push("ownerDocument"),i}};try{MutationObserver.prototype.observe.call(null,t)}catch(r){return r===i&&e.join()==="nodeType,ownerDocument"}return!1},Sn=()=>[Element.prototype.attachShadow,navigator.credentials?.get,navigator.credentials?.create,...wt("get","_get","create")].some(e=>typeof e=="function"&&dn.test(Function.prototype.toString.call(e))),bn=()=>{let i=document;for(;i;){if(i.querySelector("[data-lastpass-icon-root], [data-lastpass-root]"))return!0;i=i.activeElement?.shadowRoot}return!1},Tn=()=>{let i=typeof PublicKeyCredential>"u"?void 0:PublicKeyCredential;return[navigator.credentials?.get,...wt("get","_get"),i?.isConditionalMediationAvailable,i?._isConditionalMediationAvailable,i?.isUserVerifyingPlatformAuthenticatorAvailable,i?._isUserVerifyingPlatformAuthenticatorAvailable].some(t=>typeof t=="function"&&pn.test(Function.prototype.toString.call(t)))},wn=[{name:"1password",signal:"in-field button",signedIn:!0,test:()=>document.querySelector("com-1password-button")!==null},{name:"1password",signal:"credentials.get accessor",test:cn},{name:"1password",signal:"Sentry debug id",test:()=>bt().some(i=>i.includes(on))},{name:"bitwarden",signal:"passkey override",signedIn:!0,test:un},{name:"bitwarden",signal:"autofill keyframes",test:gn},{name:"dashlane",signal:"injected script tag",test:()=>document.querySelector('script[src*="-extension://"][src*="/dashlane-"][src$="-page-script.js"]')!==null},{name:"dashlane",signal:"PublicKeyCredential hasInstance trap",test:mn},{name:"dashlane",signal:"page script stack",test:()=>xr.test(Fr())||typeof HTMLDialogElement<"u"&&xr.test(Tt(()=>HTMLDialogElement.prototype.showModal.call(null)))},{name:"kaspersky",signal:"passkey proxy flag",test:()=>window.wasKPMKeyPassProxyInited===!0},{name:"kaspersky",signal:"injected script tag",test:()=>sn.test(document.querySelector('script[src*="/content-scripts/passkey_proxy/"]')?.src??"")},{name:"keeper",signal:"attachShadow stack",test:()=>an.test(Fr())},{name:"keeper",signal:"override source",test:Sn},{name:"keeper",signal:"field lock",test:()=>document.querySelector("[data-keeper-lock-id]")!==null},{name:"lastpass",signal:"passkey override",signedIn:!0,test:()=>typeof window.__nativeCredentialsGet=="function"},{name:"lastpass",signal:"icon root",test:bn},{name:"nordpass",signal:"observer proxy stack",test:()=>Pr.test(yn())},{name:"nordpass",signal:"observer read order",test:vn},{name:"nordpass",signal:"passkeys Sentry debug id",test:()=>bt().some(i=>ln.test(i))},{name:"nordpass",signal:"Sentry debug id",test:()=>bt().some(i=>Pr.test(i))},{name:"protonpass",signal:"WebAuthn override source",test:Tn},{name:"protonpass",signal:"field icon",test:()=>document.querySelector("[data-protonpass-role]")!==null}];function En(){return typeof window>"u"||typeof document>"u"?[]:wn.map(({name:i,signal:e,signedIn:t,test:r})=>{try{return{name:i,signal:e,signedIn:t,matched:r()}}catch(n){return{name:i,signal:e,signedIn:t,matched:!1,error:n}}})}function Cn(){let i=new Map;for(let{name:e,signedIn:t,matched:r}of En()){if(!r)continue;let n=i.get(e)??{name:e};t&&(n.signedIn=!0),i.set(e,n)}return[...i.values()]}function Lr(i){return Cn()}var Rr=3e3,kn=500,On=6,In=1e3,_e=class{constructor(e,t,r){this.logger=e;this.isEnabled=t;if(typeof window>"u"||typeof document>"u")return;if(this.sample(),Qt(0))this.sampleAfter(Rr);else{let o=()=>{this.sampleWhenIdle(),this.sampleAfter(Rr)};this.removers.push(O(0,"load",o,{once:!0}))}let n=r.onInputFocus(o=>{!this.isEnabled()||this.sampledFields.has(o)||(this.sampledFields.add(o),++this.focusSamples>=On&&n(),this.sampleAfter(kn))});this.removers.push(n)}detected=new Map;timers=new Set;idleCallbacks=new Set;sampledFields=new WeakSet;focusSamples=0;removers=[];destroyed=!1;reportedCounts=new Map;getDetected(){return[...this.detected.values()]}takeReport(e){if(!(!this.isEnabled()||this.detected.size<=(this.reportedCounts.get(e)??0)))return this.reportedCounts.set(e,this.detected.size),this.getDetected().map(({name:t})=>({name:t}))}destroy(){this.destroyed=!0;for(let e of this.removers)e();for(let e of this.timers)clearTimeout(e);this.timers.clear();for(let e of this.idleCallbacks)cancelIdleCallback(e);this.idleCallbacks.clear()}sampleAfter(e){let t=setTimeout(()=>{this.timers.delete(t),this.sampleWhenIdle()},e);this.timers.add(t)}sampleWhenIdle(){if(typeof requestIdleCallback!="function"){this.sample();return}let e=requestIdleCallback(()=>{this.idleCallbacks.delete(e),this.sample()},{timeout:In});this.idleCallbacks.add(e)}sample(){if(!(this.destroyed||!this.isEnabled()))try{let e=Lr(0);for(let t of e){let r=this.detected.get(t.name);(!r||t.signedIn&&!r.signedIn)&&this.detected.set(t.name,t)}}catch(e){this.logger.error("Failed to detect password manager extensions",e)}}};var se="cbo_session_id",G="cbo_session",I="cbo_seq",Et=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var Ct={name:kr,version:Or},xn=/^[0-9A-Za-z.+_-]{1,32}$/;function Pn(i,e){return i===void 0?Ct:typeof i=="string"&&xn.test(i)?{...Ct,integrationVersion:i}:(e.debug("Ignoring invalid integrationVersion (expected <= 32 chars of [0-9A-Za-z.+_-])"),Ct)}var _r="cbo_experiments",Dr="cbo_data_policy",Fn=255,Ln=/^[A-Za-z0-9_-]+$/,Rn=128,_n=256,Ar=1e3,Dn=50,An="cbo_seq",Mr=1e3,De=class i{constructor(e,t=[]){this.options=e;this.options.debug=e.debug??!1,this.logger=e.logger??Ir({debug:this.options.debug});let r=t.concat(Array.isArray(e.plugins)?e.plugins:[]),n=new Oe(this.logger),o=new xe(this.logger),s;this.eachPlugin(r,u=>{u.storage&&(s=u.storage(this.logger)||s)}),wr(e.projectId,n,o,s?.engine,this.logger);let a=e.projectId,p=u=>new ke(u,a);if(this.seqLockName=R(An,a),this.sessionStorage=p(o),this.persistentStorage=p(n),this.storage=p(s?.engine??n),this.configOverrides={...e.sdkConfig,...e.sdkConfig?.retry&&{retry:{...e.sdkConfig.retry}},...e.sdkConfig?.flushOnFlowTypeFinished&&{flushOnFlowTypeFinished:[...e.sdkConfig.flushOnFlowTypeFinished]},...e.sdkConfig?.sourcePathQueryAllow&&{sourcePathQueryAllow:[...e.sdkConfig.sourcePathQueryAllow]}},this.fixedData=me(e.fixedDataConfig),this.fixedData&&(this.configOverrides.pmd=this.fixedData.pmd),typeof __CBO_SDK_CONFIG__=="string"){let u=Ut(__CBO_SDK_CONFIG__,this.fixedData?.pmd);this.config=u.config,u.valid||this.logger.error("Invalid static SDK config: running the built-in defaults")}else{let u=Object.keys(b).every(v=>this.configOverrides[v]!==void 0)&&Object.keys(b.retry).every(v=>this.configOverrides.retry?.[v]!==void 0);u||(this.configManager=new Re(e.apiBaseUrl+(e.apiConfigPath??"/v1/observe/config")+"/"+e.projectId,this.persistentStorage,this.logger));let m=this.configManager?.initialConfig;this.config=ge(m,this.configOverrides),!u&&!m&&e.flushInterval!=null&&this.configOverrides.flushIntervalMs===void 0&&(this.config={...this.config,flushIntervalMs:e.flushInterval}),!u&&!m&&e.deviceInfoCollectorTimeout!=null&&this.configOverrides.deviceInfoCollectorTimeoutMs===void 0&&(this.config={...this.config,deviceInfoCollectorTimeoutMs:e.deviceInfoCollectorTimeout})}e.apiBaseUrl!==""&&(/^https?:\/\//.test(e.apiBaseUrl)||(this.logger.critical(`Invalid apiBaseUrl: URL must start with http:// or https:// (got: "${e.apiBaseUrl}")`),this.reportTelemetry("error","invalid apiBaseUrl: missing http(s) scheme")),e.apiBaseUrl.endsWith("/")&&(this.logger.critical(`Invalid apiBaseUrl: URL must not have a trailing slash (got: "${e.apiBaseUrl}")`),this.reportTelemetry("error","invalid apiBaseUrl: trailing slash")));let d=e.apiBaseUrl+(e.apiEventPath??"/v1/observe/events")+"/"+e.projectId;this.logger.debug(`Using API endpoint: ${d}`);let l=new be({logger:this.logger,url:d});this.eachPlugin(r,u=>{u.session&&(this.bridge=u.session(this)||this.bridge),u.rawErrors&&(this.rawErrors=u.rawErrors),typeof u.sourcePath=="function"&&(this.fixedSourcePath=u.sourcePath),u.eventTime&&(this.eventClock=u.eventTime),u.deviceHandleMaxAgeMs!==void 0&&(this.deviceHandleMaxAgeMs=u.deviceHandleMaxAgeMs)}),e.fixedDataConfig?.crossOriginSession&&!this.bridge&&this.logger.warn("fixedDataConfig.crossOriginSession is ignored without the crossOriginSession() plugin"),this.sessionId=this.resolveSession(),this.queue=new we(this.logger,l,this.sessionId,Pn(this.options.integrationVersion,this.logger),{debug:this.options.debug,config:this.config,requestConfig:!1,outboxLockName:R(ft,a),getDataPolicy:()=>this.dataPolicy,getCrossOriginSession:u=>this.bridge?.meta(u),fixedData:this.fixedData!==void 0||typeof __CBO_DATA_PMD__=="boolean"||typeof __CBO_DATA_PRIVATE_MODE__=="boolean",beforeEventBatchSend:u=>this.attachUndeliveredDeviceInfo(u),standaloneDeviceInfo:{has:()=>this.deviceInfoManager?.hasStandalone()??!1,take:()=>this.deviceInfoManager?.takeStandalone()}},this.persistentStorage),this.telemetryReady=!0,this.logger.setTelemetrySink?.((u,m)=>this.reportTelemetry(u,m));try{this.getWindowObserver()}catch(u){this.logger.error("Failed to attach page low-event observer",u)}if(typeof __CBO_DATA_PMD__=="boolean"?__CBO_DATA_PMD__:this.fixedData?.pmd!==!1)try{this.passwordManagerSampler=this.isTrackingBlocked()?void 0:new _e(this.logger,()=>typeof __CBO_DATA_PMD__=="boolean"?__CBO_DATA_PMD__:this.config.pmd,this.getWindowObserver())}catch(u){this.logger.error("Failed to start password manager detection",u)}let c=this.pendingSelfTelemetry;this.pendingSelfTelemetry=[];for(let u of c)this.telemetry(u.level,u.message);let f=new Ee(this.logger,this.storage,s?.source??"localstorage",this.sessionStorage,()=>({timing:this.config.deviceInfoTiming}),(u,m)=>this.telemetry(u,m),this.fixedData?.privateMode??!0,this.deviceHandleMaxAgeMs);this.deviceCollector=f;let g=e.deviceInfoDebounceTime??3e4;this.deviceInfoManager=new Ce(this.logger,f,Math.max(1,g),g,{timing:()=>this.config.deviceInfoTiming,emit:(u,m)=>this.telemetry(u,m)},()=>this.queue.notifyDeviceInfo()),this.deviceInfoManager.start(),this.experiments=this.loadPersistedExperiments(),e.experiments&&this.setExperiments(e.experiments),this.dataPolicy=this.loadPersistedDataPolicy(),e.dataPolicy!==void 0&&this.setDataPolicy(e.dataPolicy),this.configManager?.start(u=>this.handleConfig(u)),this.eachPlugin(r,u=>{u.setup&&u.setup(this)})}logger;queue;sessionId;storage;sessionStorage;persistentStorage;seqLockName;config;configManager;configOverrides;fixedData;deviceInfoManager;deviceCollector;eventTabId;seq=0;lastActivityWriteAt=0;experiments={};dataPolicy;telemetryReporting=!1;telemetryReady=!1;reportedTelemetryKeys=new Set;pendingSelfTelemetry=[];windowObserver;passwordManagerSampler;bridge;rawErrors;fixedSourcePath;eventClock;deviceHandleMaxAgeMs;getWindowObserver(){return this.windowObserver??=new ve(this.logger,(e,t)=>this.enqueueLowEvent(e,t),()=>this.lowEventFlushKeepalive())}eachPlugin(e,t){for(let r of e)try{r&&t(r)}catch(n){this.logger.error("Failed to install tracker plugin",n)}}isFullTracker(){return!1}handleConfig(e){let t=ge(e,this.configOverrides);t.sessionContinuity||=this.config.sessionContinuity,t.durableOutbox||=this.config.durableOutbox,this.config=t,this.queue.updateConfig(this.config)}getLogger(){return this.logger}applicationTag(){return this.options.applicationId?{applicationId:this.options.applicationId.toLowerCase()}:{}}setExperiments(e){try{if(!e||typeof e!="object")return;let t=!1;for(let[r,n]of Object.entries(e)){if(!i.isValidExperimentKey(r)||!i.isValidExperimentVariant(n)){this.logger.debug(`Ignoring invalid experiment assignment "${String(r)}"`);continue}this.experiments[r]!==n&&(this.experiments[r]=n,t=!0)}t&&this.persistExperiments()}catch(t){this.logger.error("Failed to set experiments",t)}}getExperiments(){return{...this.experiments}}getPersistentStorage(){return this.persistentStorage}getSdkConfig(){return Object.freeze({version:this.config.version,aap:this.config.aap,rawErrors:this.config.rawErrors})}setDataPolicy(e){try{if(!i.isValidDataPolicy(e)){this.logger.debug(`Ignoring invalid data policy code "${String(e)}"`);return}this.dataPolicy!==e&&(this.dataPolicy=e,this.persistDataPolicy())}catch(t){this.logger.error("Failed to set data policy",t)}}getDataPolicy(){return this.dataPolicy}static isValidDataPolicy(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=Fn}loadPersistedDataPolicy(){try{let e=this.persistentStorage.getItem(Dr);return i.isValidDataPolicy(e)?e:void 0}catch(e){this.logger.debug("Failed to load persisted data policy",e);return}}persistDataPolicy(){try{if(this.dataPolicy===void 0)return;this.persistentStorage.setItem(Dr,this.dataPolicy)}catch(e){this.logger.debug("Failed to persist data policy",e)}}static isValidExperimentKey(e){return typeof e=="string"&&e.length>0&&e.length<=Rn&&Ln.test(e)}static isValidExperimentVariant(e){return typeof e=="string"&&e.length>0&&e.length<=_n}loadPersistedExperiments(){try{let e=this.persistentStorage.getItem(_r);if(!e||typeof e!="object")return{};let t={};for(let[r,n]of Object.entries(e))i.isValidExperimentKey(r)&&i.isValidExperimentVariant(n)&&(t[r]=n);return t}catch(e){return this.logger.debug("Failed to load persisted experiments",e),{}}}persistExperiments(){try{this.persistentStorage.setItem(_r,this.experiments)}catch(e){this.logger.debug("Failed to persist experiments",e)}}resolveExperiments(e){let t={...this.experiments};if(e&&typeof e=="object")for(let[r,n]of Object.entries(e))i.isValidExperimentKey(r)&&i.isValidExperimentVariant(n)&&(t[r]=n);return Object.keys(t).length>0?t:void 0}isTrackingBlocked(){return typeof navigator>"u"?!1:Cr(Jt(0))}resolveSession(){return this.bridge?this.bridge.resolve():this.resolveSessionId()}resolveSessionId(){try{if(this.config.sessionContinuity)return this.getContinuitySessionId();let e=Date.now(),t=this.readPerTabSession();if(t&&e-t.lastActiveAt<this.perTabInactivityMs(t))return this.persistPerTabSession(t.id,e),this.seq=0,t.id;let r=S();return this.persistPerTabSession(r,e),this.seq=0,this.logger.debug("Created session id",r),r}catch(e){return this.logger.error("Failed to get session id",e),this.reportTelemetry("error","failed to get session id"),""}}getContinuitySessionId(){let e=Date.now(),t=this.persistentStorage.getItem(G);if(t?.id&&e-t.lastActiveAt<this.config.sessionInactivityMs)return this.persistContinuitySession(t.id,e),this.seq=this.persistentStorage.getItem(I)??0,t.id;if(!t?.id){let n=this.readPerTabSession();if(n&&e-n.lastActiveAt<this.config.sessionInactivityMs)return this.persistContinuitySession(n.id,e),this.persistentStorage.setItem(I,0),this.seq=0,this.logger.debug("Adopted per-tab session id as continuity session",n.id),n.id}let r=S();return this.persistContinuitySession(r,e),this.persistentStorage.setItem(I,0),this.seq=0,this.logger.debug("Created continuity session id",r),r}persistContinuitySession(e,t){this.lastActivityWriteAt=t,this.persistentStorage.setItem(G,{id:e,lastActiveAt:t})}readPerTabSession(){let e=this.sessionStorage.getItem(se);if(e){if(typeof e=="string")return Et.test(e)?{id:e,lastActiveAt:Date.now()}:void 0;if(typeof e.lastActiveAt=="number")return Et.test(e.id)?e:void 0}}persistPerTabSession(e,t){this.lastActivityWriteAt=t;let r=this.configOverrides.sessionInactivityMs!==void 0||this.config.version?this.config.sessionInactivityMs:this.readPerTabSession()?.inactivityMs;this.sessionStorage.setItem(se,{id:e,lastActiveAt:t,...r===void 0?{}:{inactivityMs:r}})}perTabInactivityMs(e){return this.configOverrides.sessionInactivityMs!==void 0?this.config.sessionInactivityMs:e.inactivityMs??this.config.sessionInactivityMs}nextSeq(){if(!this.config.sessionContinuity){let r=Date.now();this.sessionId&&r-this.lastActivityWriteAt>=Mr&&this.persistPerTabSession(this.sessionId,r);let n=this.bridge?this.bridge.claim(this.sessionId,this.seq,r):this.seq;return this.seq=n+1,n}let e=()=>{let r=Date.now(),n=this.persistentStorage.getItem(G),o=!1;if(!n?.id&&this.sessionId)this.persistContinuitySession(this.sessionId,r);else if(n?.id)r-this.lastActivityWriteAt>=Mr&&this.persistContinuitySession(n.id,r),n.id!==this.sessionId&&(this.sessionId=n.id,this.queue.setSessionId(n.id),o=!0);else{let p=S();this.persistContinuitySession(p,r),this.persistentStorage.setItem(I,0),this.sessionId=p,this.queue.setSessionId(p),this.seq=0,o=!0}let s=this.persistentStorage.getItem(I);o&&(this.seq=typeof s=="number"?s:0);let a=typeof s=="number"&&s>this.seq?s:this.seq;return this.bridge&&(a=this.bridge.claim(this.sessionId,a,r)),this.seq=a+1,this.persistentStorage.setItem(I,this.seq),a},t=this.config.seqLockTimeoutMs;return t===0||!pr(0)?e():Te(0,this.seqLockName,e,{timeoutMs:t,onTimeout:()=>{this.logger.warn(`Sequence Web Lock acquisition timed out after ${t}ms; using fallback`),this.reportTelemetry("info",`seq web lock timeout; using fallback, ${t}ms`)}})}resolveTrackingSourcePath(){if(!(typeof window>"u")){if(this.fixedSourcePath)try{let e=this.fixedSourcePath();return typeof e=="string"?e:void 0}catch{return}return zt(0,this.config.sourcePathQuery,this.config.sourcePathQueryAllow)}}resolveEventTabId(){return this.eventTabId===void 0&&(this.eventTabId=this.deviceCollector.getTabId()),this.eventTabId}trackSubflowStarted(e,t,r,n){let o={subflowType:e,...t};this.track("subflow_started",o,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{id:n,subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}trackSubflowTrigger(e,t,r){let n={subflowType:e,...t};this.track("subflow_trigger",n,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}trackSubflowStepStarted(e,t,r,n,o){let s={subflowType:e,stepName:t,stepData:r,identifier:n?.identifier,ignoreAsInteraction:o};this.track("subflow_step_started",s,n?.userReference,void 0,void 0,n?.explicitTimestamp,n?.experiments,{subflowStartEventId:n?.subflowStartEventId,sessionId:n?.captureSessionId,initiator:n?.initiator})}trackSubflowStepFinished(e,t,r,n){let o={subflowType:e,stepName:t,stepData:r,identifier:n?.identifier};this.track("subflow_step_finished",o,n?.userReference,void 0,void 0,n?.explicitTimestamp,n?.experiments,{subflowStartEventId:n?.subflowStartEventId,sessionId:n?.captureSessionId,initiator:n?.initiator})}trackSubflowStepError(e,t,r,n){let o={subflowType:e,stepName:t,stepData:r,identifier:n?.identifier};this.track("subflow_step_error",o,n?.userReference,void 0,void 0,n?.explicitTimestamp,n?.experiments,{subflowStartEventId:n?.subflowStartEventId,sessionId:n?.captureSessionId,initiator:n?.initiator})}async track(e,t,r,n,o,s,a,p){try{if(this.isTrackingBlocked()){this.logger.debug(`Skipping event "${e}" for blocked user agent.`);return}(e==="flow_finished"||e==="flow_auto_finished"||e==="flow_reset")&&this.windowObserver?.flushInputs();let d=this.eventClock?.(s)??s??Date.now(),l=p?.id??S(),c=p?.sessionId??this.sessionId,f=this.nextSeq(),g=typeof f=="number"?f:await f,u=this.resolveTrackingSourcePath(),m={type:"predefined",name:e,id:l,timestamp:d,seq:g,data:t,user:r,contexts:o,tags:n,experiments:this.resolveExperiments(a),meta:{captureVersion:1,pageId:re(),initiator:p?.initiator,trackingSourcePath:u??"",subflowStartEventId:p?.subflowStartEventId,tabId:this.resolveEventTabId()}},v=this.deviceInfoManager.getForEvent();v&&(m.deviceInfo=v),this.logger.debug(`Track: ${e}`,JSON.stringify(m,null,2));let E=this.passwordManagerSampler?.takeReport(c);E&&(m.passwordManagers=E),this.queue.enqueue(m,c)}catch(d){this.logger.error(`Failed to process event "${e}" before enqueue`,d),this.reportTelemetry("error",`failed to process event "${e}" before enqueue`)}}flowStarted(e,t,r,n,o){try{let s=S(),a=this.sessionId,p={...this.options.defaultTags,...this.applicationTag(),...t};return this.track("flow_started",e,void 0,p,n,o?.explicitTimestamp,r,{id:s,sessionId:a}),this.flowHandle(s,a)}catch(s){return this.logger.warn("Failed to start flow",s),{enrich:async()=>{}}}}flowDecided(e,t,r){this.track("flow_decided",e,void 0,t,void 0,void 0,r)}flowFinished(e,t,r){try{let{userId:n,identifier:o,...s}=e,a={userId:n,identifier:o},p=S(),d=this.sessionId;return this.track("flow_finished",s,a,t,void 0,void 0,r,{id:p,sessionId:d}),this.flowHandle(p,d)}catch(n){return this.logger.warn("Failed to finish flow",n),{enrich:async()=>{}}}}flowHandle(e,t){return{enrich:async r=>{try{await this.track("flow_enriched",{targetEventId:e},{...r},void 0,void 0,void 0,void 0,{sessionId:t})}catch(n){this.logger.warn("Failed to enrich flow",n)}}}}flowReset(e,t,r){this.track("flow_reset",e,void 0,t,void 0,void 0,r)}flowAutoFinished(e,t,r){let{userId:n,identifier:o,...s}=e,a={userId:n,identifier:o};this.track("flow_auto_finished",s,a,t,void 0,void 0,r)}authMethodsDecisionStarted(e,t,r,n){this.track("auth_method_decision_started",e,void 0,t,void 0,n?.explicitTimestamp,r)}authMethodsDecisionFinished(e,t,r){this.track("auth_method_decision_finished",e,void 0,t,void 0,void 0,r)}enqueueLowEvent(e,t){try{if(this.isTrackingBlocked()){this.logger.debug(`Skipping low event "${e.lowType}" for blocked user agent.`);return}this.queue.enqueueLow({...e,captureSeq:e.captureSeq??P(),captureVersion:1,pageId:e.pageId??re()},t)}catch(r){this.logger.error(`Failed to process low event "${e.lowType}" before enqueue`,r)}}telemetry(e,t){try{if(this.isTrackingBlocked()){this.logger.debug("Skipping telemetry for blocked user agent.");return}let r=typeof t=="string"?t:String(t);if(r.length===0)return;let n={id:S(),level:e,message:r.length>Ar?r.slice(0,Ar):r,ts:Date.now()};this.queue.enqueueTelemetry(n)}catch(r){this.logger.error("Failed to process telemetry before enqueue",r)}}attachUndeliveredDeviceInfo(e){try{let t=this.deviceInfoManager;if(!t?.hasUndelivered())return;let r=re(),n=e.find(o=>o.meta?.pageId===r&&!o.deviceInfo);n&&(n.deviceInfo=t.takeUndelivered())}catch(t){this.logger.error("Failed to attach device info to batch",t)}}reportTelemetry(e,t){if(!this.telemetryReporting){this.telemetryReporting=!0;try{if(this.reportedTelemetryKeys.has(t)||this.reportedTelemetryKeys.size>=Dn)return;if(this.reportedTelemetryKeys.add(t),!this.telemetryReady){this.pendingSelfTelemetry.push({level:e,message:t});return}this.telemetry(e,t)}catch{}finally{this.telemetryReporting=!1}}}flushKeepalive(e="manual"){try{this.queue.flushKeepalive(e)}catch(t){this.logger.error("Failed to flush queue keepalive",t)}}lowEventFlushKeepalive(){this.config.tlf&&this.flushKeepalive("low-event-teardown")}async destroy(){if(this.bridge?.stop(),this.configManager?.destroy(),this.passwordManagerSampler?.destroy(),this.windowObserver?.destroy(),this.deviceInfoManager.destroy(),this.config.td)try{await this.queue.flush("destroy")}catch(e){this.logger.error("Failed to flush queue during destroy",e)}this.queue.destroy()}getSessionId(){if(!this.sessionId){let e=this.resolveSession();e&&(this.sessionId=e,this.queue.setSessionId(e))}return this.sessionId||void 0}};var j=class{constructor(e,t){this.logger=e;this.sink=t}lease;destroyed=!1;arm(e,t=!1){if(this.disarm(),!(this.destroyed||t))try{this.lease=this.sink.beginCeremony?.(e)}catch(r){this.logger.error("Failed to register ceremony low-event context",r)}}scheduleDisarm(e){try{this.lease?.settle(e)}catch(t){this.logger.error("Failed to settle ceremony low-event context",t)}}disarm(){try{this.lease?.destroy()}catch(e){this.logger.error("Failed to release ceremony low-event context",e)}this.lease=void 0}destroy(){this.disarm(),this.destroyed=!0}};var Ae=class extends h{getOptions;ceremony;postResponse;lowEventTracker;constructor(e,t){super(e,"passkey-login"),this.lowEventTracker=new j(e.getLogger(),this.lowEventSink("ceremony")),this.registerLowFlusher(()=>this.lowEventTracker.disarm()),this.getOptions=this.defineStep("get-options"),this.ceremony=this.withWindowLowEvents(this.defineStep("ceremony"),this.lowEventTracker),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t?.explicitSpecType})}trigger(e,t){super.trigger(e,t)}destroy(){this.lowEventTracker.destroy()}};var Q=class{constructor(e,t,r,n){this.previousLength=e;this.pushLow=t;this.logger=r;this.reserveCaptureSeq=n}prefillSettled=!1;inputBatch=null;currentEffect="modify";ringEffect="modify";autofillTimestamps=[];autofillStreak=null;idleTimer=null;runSeq;markInputObserved(){this.prefillSettled=!0}observe(){this.runSeq!==void 0||this.inputBatch||this.autofillTimestamps.length>0||this.autofillStreak||(this.runSeq=this.reserveCaptureSeq?.())}takeSeq(){let e=this.runSeq;return this.runSeq=void 0,e??this.reserveCaptureSeq?.()}capturePrefill(e,t=!1){t&&(this.prefillSettled=!1),!this.prefillSettled&&(this.previousLength=e,e!==0&&(this.prefillSettled=!0,this.pushLow({lowType:"input-prefill",ts:Date.now(),initiator:"unknown"})))}flush(){this.cancelIdle(),this.flushInputBatch(),this.flushAutofillStreak()}cancelIdle(){this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=null}scheduleIdle(){this.cancelIdle(),this.idleTimer=setTimeout(()=>{this.idleTimer=null;try{this.flushInputBatch(!0),this.flushAutofillStreak()}catch(e){this.logger.error("Failed to flush idle input",e)}},3e3)}extendInputBatch(e,t=this.currentEffect){let r=this.inputBatch;if(!r){this.inputBatch={firstTimestamp:e,lastTimestamp:e,effect:t,captureSeq:this.takeSeq()};return}r.lastTimestamp=e}drainAutofillRingToBatch(){for(let e of this.autofillTimestamps)this.extendInputBatch(e,this.ringEffect);this.autofillTimestamps.length=0}flushInputBatch(e=!1){this.drainAutofillRingToBatch();let t=this.inputBatch;t&&(this.pushLow({...t.captureSeq===void 0?{}:{captureSeq:t.captureSeq},lowType:e?"input-idle":"input",ts:t.firstTimestamp,durationMs:t.lastTimestamp-t.firstTimestamp,inputEffect:t.effect}),this.inputBatch=null)}flushAutofillStreak(){let e=this.autofillStreak;e&&(this.pushLow({...e.captureSeq===void 0?{}:{captureSeq:e.captureSeq},lowType:"big-input-add",ts:e.firstTimestamp,durationMs:e.lastTimestamp-e.firstTimestamp,inputEffect:e.effect}),this.autofillStreak=null)}detectAutofillStreak(){let e=this.autofillTimestamps;if(e.length<5)return!1;let t=1/0,r=-1/0;for(let n=1;n<e.length;n++){let o=e[n]-e[n-1];if(o>80)return!1;o<t&&(t=o),o>r&&(r=o)}return r-t<=25}record(e,t=Date.now(),r=!1){this.observe(),this.markInputObserved(),this.scheduleIdle();let n=this.previousLength;this.currentEffect=e===0?"clear":n===0?"fill":"modify";let o=e-n;if(this.previousLength=e,e===0&&n>0){this.flush();let l=this.takeSeq();this.pushLow({...l===void 0?{}:{captureSeq:l},lowType:"input-clear",ts:t,inputEffect:"clear"});return}if(r){this.flushAutofillStreak(),this.drainAutofillRingToBatch(),this.extendInputBatch(t,this.currentEffect);return}if(o>=3){this.flushInputBatch(),this.flushAutofillStreak();let l=this.takeSeq();this.pushLow({...l===void 0?{}:{captureSeq:l},lowType:"big-input-add",ts:t,inputEffect:this.currentEffect});return}if(o<=-3){this.flushInputBatch(),this.flushAutofillStreak();let l=this.takeSeq();this.pushLow({...l===void 0?{}:{captureSeq:l},lowType:"big-input-rem",ts:t,inputEffect:this.currentEffect});return}let s=this.autofillStreak;if(s){if(o===1&&t-s.lastTimestamp<=80){s.lastTimestamp=t;return}this.flushAutofillStreak()}if(o!==1){this.drainAutofillRingToBatch(),this.extendInputBatch(t,this.currentEffect);return}let a=this.autofillTimestamps;if(a.length===0&&(this.ringEffect=this.currentEffect),a.push(t),a.length>5){let l=a.shift();this.extendInputBatch(l,this.ringEffect),this.ringEffect="modify"}if(!this.detectAutofillStreak())return;let p=a[0],d=a[a.length-1];a.length=0,this.flushInputBatch(),this.autofillStreak={firstTimestamp:p,captureSeq:this.takeSeq(),lastTimestamp:d,effect:this.ringEffect}}};var z=class{constructor(e,t,r,n,o){this.inputs=t;this.logger=r;this.changed=n;this.reserveCaptureSeq=o;for(let s of t)s.addEventListener("paste",this.onPaste,!0),s.addEventListener("beforeinput",this.onBeforeInput,!0)}lengthsBefore=null;applied=!1;timestamp=0;captureSeq;pasteEvent;timer=null;onPaste=e=>this.begin(e);onBeforeInput=e=>{e.inputType==="insertFromPaste"?this.begin(e):this.flush()};handlesInput(e){if(!this.lengthsBefore)return!1;let t=this.pasteEvent?.type==="paste"&&(this.pasteEvent.eventPhase??0)>0;return e.inputType==="insertFromPaste"||t?(this.applied=!0,!0):(this.clear(),!1)}get pending(){return this.lengthsBefore!==null}begin(e){if(!(!e.isTrusted||this.lengthsBefore))try{this.lengthsBefore=this.inputs.map(t=>t.value.length),this.applied=!1,this.pasteEvent=e,this.timestamp=Date.now(),this.captureSeq=this.reserveCaptureSeq?.(),this.timer=setTimeout(()=>this.flush(),0)}catch(t){this.logger.error("Failed to observe paste",t),this.clear()}}flush(){let e=this.lengthsBefore;if(!e)return;let t=this.timestamp,r=this.captureSeq,n=this.applied;this.clear();try{(n||this.inputs.some((s,a)=>s.value.length!==e[a]))&&this.changed(t,r)}catch(o){this.logger.error("Failed to finish paste observation",o)}}clear(){this.timer!==null&&clearTimeout(this.timer),this.timer=null,this.lengthsBefore=null,this.applied=!1,this.pasteEvent=void 0}destroy(){this.flush();for(let e of this.inputs)e.removeEventListener("paste",this.onPaste,!0),e.removeEventListener("beforeinput",this.onBeforeInput,!0)}};var Mn=["focus","blur","pointerdown","pointerup","click","input","keyup"];function Me(i,e,t,r,n=Mn){let o=[];for(let s of n){let a=Hn(s,t,r);a&&o.push([s,a])}for(let[s,a]of o)e.addEventListener(s,a);return()=>{for(let[s,a]of o)e.removeEventListener(s,a)}}function Hn(i,e,t){switch(i){case"focus":case"blur":{let r=e[i];return r&&(n=>t(i,()=>r(n.relatedTarget)))}case"pointerdown":case"pointerup":case"click":{let r=e[i];return r&&(()=>t(i,()=>r()))}case"input":{let r=e.input;return r&&(n=>t("input",()=>r(n.isComposing||n.inputType==="insertCompositionText",n)))}case"keyup":{let r=e.keyupEscape;return r&&(n=>t("keyup",()=>{n.key==="Escape"&&r()}))}}}function Hr(i,e){return e.type==="checkbox"||e.type==="radio"?e.checked?1:0:e.value.length}function Br(i,e){return e.reduce((t,r)=>t+r.value.length,0)}function He(i,e){let t=document.activeElement;return e.find(r=>r===t)}function ae(i){return Hr(0,i)}var k=class{constructor(e,t,r){this.logger=e;this.inputField=t;this.sink=r;this.changes=new Q(ae(t),this.pushLow,e,r.reserveCaptureSeq),this.pasteObserver=new z(0,[t],e,(n,o)=>{this.changes.flush(),this.changes.markInputObserved();let s=this.changes.previousLength;this.changes.previousLength=ae(t),this.pushLow({...o===void 0?{}:{captureSeq:o},lowType:"input-paste",ts:n,inputEffect:ae(t)===0?"clear":s===0?"fill":"modify"})},r.reserveCaptureSeq),this.unregisterInputs=r.registerInputs?.([t],()=>this.flushPending()),this.capturePrefill(),this.attach()}unregisterInputs;removeFieldListeners;removePageHide;changes;pasteObserver;destroyed=!1;destroy(){if(!this.destroyed){this.destroyed=!0;try{this.changes.flush(),this.unregisterInputs?.(),this.pasteObserver.destroy(),this.detach()}catch(e){this.logger.error("Failed to destroy LowEventInputTracker",e)}}}attach(){let e=this.inputField;this.removeFieldListeners=Me(0,e,{focus:()=>this.handleFocus(),blur:()=>this.handleBlur(),pointerdown:()=>this.enqueueNonInputEvent("pointerdown"),pointerup:()=>this.enqueueNonInputEvent("pointerup"),click:()=>this.enqueueNonInputEvent("click"),input:(t,r)=>this.handleInput(r,t),keyupEscape:()=>this.enqueueNonInputEvent("keyup-escape")},(t,r)=>{try{r()}catch(n){t==="input"?this.logger.error("Failed to observe input",n):this.logger.error(`Failed to handle low event "${t}"`,n)}}),typeof window<"u"&&(this.removePageHide=O(0,"pagehide",this.wrapHandler("pagehide",()=>this.flushForTeardown()))),typeof document<"u"&&He(0,[e])&&this.handleFocus()}detach(){this.removeFieldListeners?.(),typeof window<"u"&&this.removePageHide?.()}pushLow=e=>{this.sink.enqueueLowEvent(e)};capturePrefill(e=!1){this.destroyed||(this.flushPending(),this.changes.capturePrefill(ae(this.inputField),e))}flushPending(){this.pasteObserver.flush(),this.changes.flush()}enqueueNonInputEvent(e){this.changes.flush(),this.pushLow({lowType:e,ts:Date.now()})}handleFocus(){this.enqueueNonInputEvent("focus")}handleBlur(){this.pasteObserver.flush(),this.enqueueNonInputEvent("blur")}handleInput(e,t){this.pasteObserver.handlesInput(e)||this.changes.record(ae(this.inputField),Date.now(),t)}flushForTeardown(){this.pasteObserver.flush(),this.changes.flush(),this.sink.flushKeepalive()}wrapHandler(e,t){return()=>{try{t()}catch(r){this.logger.error(`Failed to handle low event "${e}"`,r)}}}};var Be=class{constructor(e,t,r){this.logger=e;this.sink=r;this.inputs=[...new Set(t)],this.changes=new Q(this.length(),o=>r.enqueueLowEvent(o),e,r.reserveCaptureSeq),this.paste=new z(0,this.inputs,e,(o,s)=>{this.cancelChange(),this.changes.flush(),this.changes.markInputObserved();let a=this.changes.previousLength;this.changes.previousLength=this.length(),r.enqueueLowEvent({...s===void 0?{}:{captureSeq:s},lowType:"input-paste",ts:o,inputEffect:this.length()===0?"clear":a===0?"fill":"modify"})},r.reserveCaptureSeq),this.unregisterInputs=r.registerInputs?.(this.inputs,()=>this.flushPending()),this.capturePrefill();let n=(o,s)=>this.safe(s);for(let o of this.inputs)this.listeners.push(Me(0,o,{input:(s,a)=>{this.paste.handlesInput(a)||(this.composing||=s,this.changeTimer===null&&(this.changeTime=Date.now(),this.changes.observe(),this.changeTimer=setTimeout(()=>this.safe(()=>this.flushChanges()),0)))},focus:s=>{this.contains(s)||this.emit("focus")},blur:s=>{this.contains(s)||(this.flushPending(),this.emit("blur"))},click:()=>this.emit("click"),pointerdown:()=>this.emit("pointerdown"),pointerup:()=>this.emit("pointerup"),keyupEscape:()=>this.emit("keyup-escape")},n,["input","focus","blur","click","pointerdown","pointerup","keyup"]));typeof window<"u"&&this.listeners.push(O(0,"pagehide",o=>this.safe(()=>{this.flushPending(),r.flushKeepalive()}))),typeof document<"u"&&He(0,this.inputs)&&this.emit("focus")}inputs;changes;paste;unregisterInputs;listeners=[];changeTimer=null;changeTime=0;composing=!1;destroyed=!1;contains(e){return this.inputs.some(t=>t===e)}length(){return Br(0,this.inputs)}safe(e){try{e()}catch(t){this.logger.error("Failed to observe grouped input",t)}}cancelChange(){this.changeTimer!==null&&clearTimeout(this.changeTimer),this.changeTimer=null}flushChanges(){this.changeTimer!==null&&(this.cancelChange(),this.paste.pending||this.changes.record(this.length(),this.changeTime,this.composing),this.composing=!1)}emit(e){this.flushChanges(),this.changes.flush(),this.sink.enqueueLowEvent({lowType:e,ts:Date.now()})}capturePrefill(e=!1){this.destroyed||(this.flushPending(),this.changes.capturePrefill(this.length(),e))}flushPending(){this.paste.flush(),this.flushChanges(),this.changes.flush()}destroy(){this.destroyed||(this.destroyed=!0,this.safe(()=>{this.flushPending(),this.paste.destroy(),this.unregisterInputs?.();for(let e of this.listeners)e()}))}};var D=class{constructor(e,t,r){this.logger=e;this.inputSink=t;this.groupSink=r}collector;fields=[];grouped=!1;destroyed=!1;prefillClaimed=!1;setFields(e,t=!0){try{if(this.destroyed)return;let r=[...new Set(e)];if(t===this.grouped&&r.length===this.fields.length&&r.every((s,a)=>s===this.fields[a])||(this.collector?.destroy(),this.collector=void 0,this.fields=[],this.grouped=t,r.length===0))return;let n=t?this.groupSink:this.inputSink,o={...n,enqueueLowEvent:s=>this.enqueue(n,s)};this.collector=t?new Be(this.logger,r,o):new k(this.logger,r[0],o),this.fields=r}catch(r){this.logger.error("Failed to bind OTP inputs",r)}}enqueue(e,t){if(t.lowType==="input-prefill"){if(this.prefillClaimed)return;this.prefillClaimed=!0}else["input","input-idle","input-clear","input-paste","big-input-paste","big-input-add","big-input-rem"].includes(t.lowType)&&(this.prefillClaimed=!0);e.enqueueLowEvent(t)}capturePrefill(e=!1){e&&(this.prefillClaimed=!1),this.collector?.capturePrefill(e)}flushPending(){this.collector?.flushPending()}destroy(){this.destroyed=!0,this.collector?.destroy(),this.collector=void 0,this.fields=[]}};var Ne=class extends h{lowEventTracker;send;postResponse;resend;constructor(e,t={}){super(e,"email-otp"),this.send=this.defineStep("send"),this.postResponse=this.defineStep("post-response"),this.resend=this.defineStep("resend"),this.subflowStart({explicitSpecType:t.explicitSpecType,emailDomain:t.emailDomain}),this.lowEventTracker=this.createLowCollector(()=>new D(e.getLogger(),this.lowEventSink("input","otp"),this.lowEventSink("input-group","otp"))),t.inputHtmlFields?.length?this.setInputFields(t.inputHtmlFields):t.inputHtmlField&&this.lowEventTracker?.setFields([t.inputHtmlField],!1),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending())}setInputFields(e){this.lowEventTracker?.setFields(e)}destroy(){this.lowEventTracker?.destroy()}};var Ue=class extends h{lowEventTracker;send;postResponse;resend;constructor(e,t={}){super(e,"sms-otp"),this.send=this.defineStep("send"),this.postResponse=this.defineStep("post-response"),this.resend=this.defineStep("resend"),this.subflowStart({explicitSpecType:t.explicitSpecType}),this.lowEventTracker=this.createLowCollector(()=>new D(e.getLogger(),this.lowEventSink("input","otp"),this.lowEventSink("input-group","otp"))),t.inputHtmlFields?.length?this.setInputFields(t.inputHtmlFields):t.inputHtmlField&&this.lowEventTracker?.setFields([t.inputHtmlField],!1),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending())}setInputFields(e){this.lowEventTracker?.setFields(e)}destroy(){this.lowEventTracker?.destroy()}};var le="cbo_email_link_starts";function kt(i,e){let t=i.getItem(le);if(!Array.isArray(t))return[];let r=t.filter(n=>!!n&&typeof n=="object"&&typeof n.transactionId=="string"&&typeof n.anchor=="string"&&typeof n.sessionId=="string"&&typeof n.startedAt=="number"&&e-n.startedAt<864e5);return typeof __CBO_DATA_RETENTION__=="boolean"&&__CBO_DATA_RETENTION__&&r.length<t.length&&(r.length===0?i.removeItem(le):i.setItem(le,r)),r}function Nr(i,e){if(i)try{let t=kt(i,e.startedAt).filter(r=>r.transactionId!==e.transactionId);t.push(e),i.setItem(le,t.slice(-10))}catch{}}function Ur(i,e,t=Date.now()){if(i)try{let r=kt(i,t);if(e.transactionId)return r.find(o=>o.transactionId===e.transactionId);let n=r.filter(o=>!o.continued&&(!e.specType||!o.specType||o.specType===e.specType));return n[n.length-1]}catch{return}}function qr(i,e){if(i)try{let t=kt(i,Date.now()).map(r=>r.transactionId===e?{...r,continued:!0}:r);i.setItem(le,t)}catch{}}var qe=class extends h{send;postResponse;resend;transactionId;constructor(e,t={}){super(e,"email-link"),this.send=this.defineStep("send"),this.postResponse=this.defineStep("post-response"),this.resend=this.defineStep("resend"),this.transactionId=t.transactionId||S(),this.subflowStart({explicitSpecType:t.explicitSpecType},{userReference:{crossEnvironmentTransactionIDStart:this.transactionId}});let r=this.captureReference,n=this.captureSession;r&&n&&Nr(e.getPersistentStorage(),{transactionId:this.transactionId,anchor:r,sessionId:n,specType:t.explicitSpecType,startedAt:Date.now()})}},Ke=class extends h{postResponse;resend;mode;continuationTracker;specType;createdAt=Date.now();transaction;started=!1;deferred=[];onPageHide=()=>this.flush();removePageHide;constructor(e,t={}){super(e,"email-link"),this.continuationTracker=e,this.specType=t.explicitSpecType,this.transaction=t.transactionId,this.postResponse=this.deferrable(this.defineStep("post-response"),!0),this.resend=this.deferrable(this.defineStep("resend"));let r=e.getPersistentStorage(),n=Ur(r,{transactionId:t.transactionId,specType:t.explicitSpecType});if(n&&n.sessionId===e.getSessionId()){this.mode="attached",this.transaction=t.transactionId??n.transactionId,this.adoptCapture(n.anchor,n.sessionId,n.specType??t.explicitSpecType),this.started=!0;return}this.mode="detached",this.transaction?this.startDetached(this.createdAt):typeof window<"u"&&(this.removePageHide=O(0,"pagehide",this.onPageHide))}get transactionId(){return this.transaction}setTransactionId(e){!e||this.transaction||(this.transaction=e,this.mode==="detached"&&!this.started&&this.startDetached(this.firstDeferredAt()))}flush(){this.mode==="detached"&&!this.started&&this.startDetached(this.firstDeferredAt())}destroy(){this.flush(),this.removePageHideListener()}firstDeferredAt(){return this.deferred[0]?.at??this.createdAt}startDetached(e){this.started=!0,this.removePageHideListener(),this.subflowStart({explicitSpecType:this.specType,continuation:!0},{explicitTimestamp:e,...this.transaction?{userReference:{crossEnvironmentTransactionIDFinish:this.transaction}}:{}});let t=this.deferred;this.deferred=[];for(let r of t)r.run(r.at);try{this.continuationTracker.flushKeepalive()}catch{}}removePageHideListener(){typeof window<"u"&&this.removePageHide?.()}deferrable(e,t=!1){let r=(n,o)=>{if(this.started){n(o?.explicitTimestamp??Date.now());return}this.deferred.push({at:o?.explicitTimestamp??Date.now(),run:n})};return{start:(n,o)=>r(s=>e.start(n,{...o,explicitTimestamp:s}),o),finished:(n,o)=>{r(s=>e.finished(n,{...o,explicitTimestamp:s}),o),t&&this.transaction&&qr(this.continuationTracker.getPersistentStorage(),this.transaction)},error:(n,o)=>r(s=>e.error(n,{...o,explicitTimestamp:s}),o)}}};var We=class extends h{getOptions;ceremony;postResponse;lowEventTracker;constructor(e,t){super(e,"passkey-enrollment"),this.lowEventTracker=new j(e.getLogger(),this.lowEventSink("ceremony")),this.registerLowFlusher(()=>this.lowEventTracker.disarm()),this.getOptions=this.defineStep("get-options"),this.ceremony=this.withWindowLowEvents(this.defineStep("ceremony"),this.lowEventTracker),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t?.explicitSpecType,...t?.ignoreAsInteraction?{ignoreAsInteraction:!0}:{}})}destroy(){this.lowEventTracker.destroy()}};var Ve=class extends h{userConfirmation;deletion;constructor(e,t={}){super(e,"passkey-deletion"),this.userConfirmation=this.defineStep("user-confirmation"),this.deletion=this.defineStep("deletion"),this.subflowStart({})}};var $e=class extends h{clientValidation;postResponse;cui;lowEventTracker;identifierLowEventTracker;constructor(e,t){super(e,"password-login"),this.clientValidation=this.defineStep("client-validation"),this.postResponse=this.defineStep("post-response"),this.cui={getOptions:this.defineStep("cui-get-options",!0),ceremony:this.defineStep("cui-ceremony"),postResponse:this.defineStep("cui-post-response")},this.subflowStart({explicitSpecType:t?.explicitSpecType}),t?.identifierInputHtmlField&&(this.identifierLowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.identifierInputHtmlField,this.lowEventSink("input","identifier"))),this.registerLowFlusher(()=>this.identifierLowEventTracker?.flushPending())),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","password"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}trigger(e,t){super.trigger(e,t)}destroy(){this.lowEventTracker?.destroy(),this.identifierLowEventTracker?.destroy()}};var Ge=class extends h{clientValidation;postResponse;lowEventTracker;constructor(e,t){super(e,"password-enrollment"),this.clientValidation=this.defineStep("client-validation"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t?.explicitSpecType}),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","password"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var je=class extends h{lowEventTracker;cui;provideIdentifier;constructor(e,t){super(e,"provide-identifier"),this.cui={trigger:(r,n)=>{this.trigger(r,n)},getOptions:this.defineStep("cui-get-options",!0),ceremony:this.defineStep("cui-ceremony"),postResponse:this.defineStep("cui-post-response")},this.provideIdentifier={trigger:(r,n)=>{this.trigger(r,n)},clientValidation:this.defineStep("pi-client-validation"),postResponse:this.defineStep("pi-post-response")},this.subflowStart({explicitSpecType:t?.explicitSpecType}),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","identifier"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var Qe=class extends h{getRedirectUrl;exchangeCode;constructor(e,t={}){super(e,"social-login"),this.getRedirectUrl=this.defineStep("get-redirect-url"),this.exchangeCode=this.defineStep("exchange-code"),this.subflowStart({explicitSpecType:t.explicitSpecType,entry:t.entry})}};var ze=class extends h{getRedirectUrl;exchangeCode;constructor(e,t={}){super(e,"sso-login"),this.getRedirectUrl=this.defineStep("get-redirect-url"),this.exchangeCode=this.defineStep("exchange-code");let{explicitSpecType:r,organizationDomain:n,actor:o}=Bn(t??{},e);this.subflowStart({explicitSpecType:r,organizationDomain:n,actor:o})}};function Bn(i,e){let t={...i},r=o=>{try{e.getLogger().warn(`SSO login: unsupported ${o}; omitted from telemetry`)}catch{}},n=t.organizationDomain;return n!==void 0&&(typeof n!="string"||n.includes("@")||n.length>253)&&(delete t.organizationDomain,r("organizationDomain")),t.actor!==void 0&&t.actor!=="user"&&t.actor!=="system"&&(delete t.actor,r("actor")),t}var Ye=class extends h{lowEventTracker;postResponse;constructor(e,t={}){super(e,"totp"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType}),this.lowEventTracker=this.createLowCollector(()=>new D(e.getLogger(),this.lowEventSink("input","otp"),this.lowEventSink("input-group","otp"))),t.inputHtmlFields?.length?this.setInputFields(t.inputHtmlFields):t.inputHtmlField&&this.lowEventTracker?.setFields([t.inputHtmlField],!1),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending())}setInputFields(e){this.lowEventTracker?.setFields(e)}destroy(){this.lowEventTracker?.destroy()}};var Je=class extends h{ceremony;retry;postResponse;constructor(e,t={}){super(e,"app-confirmation"),this.ceremony=this.defineStep("ceremony"),this.retry=this.defineStep("retry"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType})}};var Xe=class extends h{ceremony;postResponse;constructor(e,t={}){super(e,"captcha"),this.ceremony=this.defineStep("ceremony"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType})}};var Ze=class{constructor(e,t){this.logger=e;this.sink=t}trackers=new Map;destroyed=!1;setFields(e){if(this.destroyed)return;let t=new Set(e);for(let[r,n]of this.trackers)t.has(r)||(this.safe(()=>n.destroy()),this.trackers.delete(r));for(let r of t)this.trackers.has(r)||this.safe(()=>this.trackers.set(r,new k(this.logger,r,this.sink())))}capturePrefill(e=!1){for(let t of this.trackers.values())this.safe(()=>t.capturePrefill(e))}flushPending(){for(let e of this.trackers.values())this.safe(()=>e.flushPending())}destroy(){if(!this.destroyed){this.destroyed=!0;for(let e of this.trackers.values())this.safe(()=>e.destroy());this.trackers.clear()}}safe(e){try{e()}catch(t){this.logger.error("Form input binding failed",t)}}};var Ot=50,Nn=6e4,Un=40,qn=/^[A-Za-z0-9._-]+$/,et=class extends h{submit;skip;inputBinding;constructor(e,t){super(e,"form"),this.submit=this.defineStep("submit"),this.skip=this.defineStep("skip"),this.subflowStart(Wn(e,t),Kn(e,t)),this.inputBinding=this.createLowCollector(()=>new Ze(e.getLogger(),()=>this.lowEventSink("input","data"))),this.registerLowFlusher(()=>this.inputBinding?.flushPending()),t?.inputHtmlFields?.length&&this.setInputFields(t.inputHtmlFields)}setInputFields(e){this.inputBinding?.setFields(e)}destroy(){this.inputBinding?.destroy()}};function Kn(i,e){let t=e?.startedAt;if(t===void 0)return;let r=Date.now();if(typeof t!="number"||!Number.isFinite(t)||t>r||r-t>Nn){de(i,"Form: implausible startedAt ignored; using the current time");return}return{explicitTimestamp:t}}function Wn(i,e){let t={},r=e?.name;typeof r=="string"&&r.trim()!==""?t.name=r:de(i,"Form: missing name; the form will not be counted");let n=e?.fields;if(n===void 0)return t;if(!Array.isArray(n))return de(i,"Form: fields must be an array of field names; omitted from telemetry"),t;let o=n.filter(s=>typeof s=="string"&&s.length<=Un&&qn.test(s));return o.length<n.length&&de(i,"Form: unsupported field names omitted from telemetry"),o.length>Ot&&de(i,`Form: more than ${Ot} field names; the rest is omitted from telemetry`),o.length>0&&(t.fields=o.slice(0,Ot)),t}function de(i,e){try{i.getLogger().warn(e)}catch{}}function It(i,e,t){if(i===null||typeof i!="object")return i;try{let r={...i};r.purpose===void 0&&e.purpose!==void 0&&(r.purpose=e.purpose),r.storage===void 0&&e.storage!==void 0&&(r.storage=e.storage),r.trustName===void 0&&e.trustName!==void 0&&(r.trustName=e.trustName);for(let[n,o]of[["bindingReference",255],["trustName",128]])if(typeof r[n]=="string"&&[...r[n]].length>o){delete r[n];try{t.getLogger().debug(`Trusted device: omitted ${n} exceeding ${o} characters`)}catch{}}return r}catch{return i}}function tt(i,e,t){return{...i,start:(r,n)=>i.start(It(r,e,t),n),finished:(r,n)=>i.finished(It(r,e,t),n)}}var rt=class extends h{getOptions;ceremony;postResponse;constructor(e,t){super(e,"trusted-device-check"),t=Kr(t,e);let r={purpose:t.purpose,storage:t.storage,trustName:t.trustName};this.getOptions=this.checkStep("get-options",r,e),this.ceremony=this.checkStep("ceremony",r,e),this.postResponse=this.checkStep("post-response",r,e),this.subflowStart({explicitSpecType:t.explicitSpecType,actor:"system",ignoreAsInteraction:!0})}checkStep(e,t,r){let n=this.defineStep(e,!0);return{...tt(n,t,r),errorTyped:(o,s)=>{n.errorTyped(It({code:o?.code,error:U(o?.error)},t,r),s)}}}},it=class extends h{getOptions;ceremony;postResponse;constructor(e,t){super(e,"trusted-device-enrollment"),t=Kr(t,e);let r={purpose:t.purpose,storage:t.storage,trustName:t.trustName};this.getOptions=tt(this.defineStep("get-options"),r,e),this.ceremony=tt(this.defineStep("ceremony"),r,e),this.postResponse=tt(this.defineStep("post-response"),r,e),this.subflowStart({explicitSpecType:t.explicitSpecType})}};function Kr(i,e){let t={...i},r=n=>{try{e.getLogger().warn(`Trusted device: missing or unsupported ${n}; omitted from telemetry`)}catch{}};return t.purpose!=="additional-verification"&&t.purpose!=="mfa-exemption"&&(delete t.purpose,r("purpose")),["cookie","indexeddb","localstore","sessionstore"].includes(t.storage)||(delete t.storage,r("storage")),t}var nt=class extends h{clientValidation;postResponse;lowEventTracker;constructor(e,t={}){super(e,"provide-data"),this.clientValidation=this.defineStep("client-validation"),this.postResponse=this.defineStep("post-response");let{inputHtmlField:r,...n}=t;this.subflowStart(n),r&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),r,this.lowEventSink("input","data"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};function Wr(i){let e=S();return i.config.sessionContinuity?(i.persistContinuitySession(e,Date.now()),i.persistentStorage.setItem(I,0)):i.persistPerTabSession(e,Date.now()),i.sessionId=e,i.seq=0,i.queue.setSessionId(e),i.bridge?.reset(e),i.getLogger().debug(`Session reset: ${e}`),e}function Vr(i,e){i.track("flow_enriched",{match:{flowType:"*",at:"during"},expFol:!0},{...e})}function $r(i,e,t){let r=i.getLogger();try{if(!e||typeof e!="object"){r.warn("setFlowTags: ignoring non-object tags");return}let n={};for(let[s,a]of Object.entries(e)){if(s===""||typeof a!="string"){r.warn(`setFlowTags: ignoring invalid tag "${s}"`);continue}n[s]=a}if(Object.keys(n).length===0)return;let o={match:{flowType:t?.flowType??"*",at:"during"}};t?.expandToChildren!==void 0&&(o.expCh=t.expandToChildren),t?.expandToFollowing!==void 0&&(o.expFol=t.expandToFollowing),i.track("flow_enriched",o,void 0,n)}catch(n){r.warn("Failed to set flow tags",n)}}function Gr(i,e){try{Object.prototype.hasOwnProperty.call(i.experiments,e)&&(delete i.experiments[e],i.persistExperiments())}catch(t){i.getLogger().error("Failed to clear experiment",t)}}function jr(i){try{if(Object.keys(i.experiments).length===0)return;i.experiments={},i.persistExperiments()}catch(e){i.getLogger().error("Failed to clear experiments",e)}}function Qr(i,e,t,r){let{userId:n,identifier:o,crossEnvironmentTransactionID:s,...a}=e,p={userId:n,identifier:o,crossEnvironmentTransactionID:s},d={...i.options.defaultTags,...i.applicationTag(),...t};i.track("conversion",a,p,d,void 0,void 0,r)}function zr(i,e,t,r){i.track("auth_decision_started",e,void 0,t,void 0,void 0,r)}function Yr(i,e,t,r){i.track("auth_decision_finished",e,void 0,t,void 0,void 0,r)}function Jr(i,e,t,r){let n={subflowType:e,stepData:t};i.track("subflow_error",n,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}var Vn={maxStackFrames:{min:1,max:100,default:50},depth:{min:0,max:10,default:3},maxBreadth:{min:1,max:1e3,default:30},maxValueLength:{min:1,max:1e4,default:1024},maxCauseDepth:{min:0,max:10,default:3},maxBytes:{min:0,max:65536,default:32768}},$n=1024,J=class extends Error{},Gn=["name","message","code","errors","stack"],jn=/[^\x20-\x7E]/,X=i=>Object.prototype.toString.call(i).slice(8,-1),Qn=i=>i===null?"null":typeof i=="object"?X(i):typeof i,zn=i=>i instanceof Error||X(i)==="Error"||X(i)==="DOMException";function ei(i){return jn.test(i)?new TextEncoder().encode(i).byteLength:i.length}function Y(i,e){let t=Vn[i];return typeof e!="number"||!Number.isFinite(e)?t.default:Math.min(t.max,Math.max(t.min,Math.floor(e)))}function Xr(i={}){return{stack:i.stack===!0,maxStackFrames:Y("maxStackFrames",i.maxStackFrames),depth:Y("depth",i.depth),maxBreadth:Y("maxBreadth",i.maxBreadth),maxValueLength:Y("maxValueLength",i.maxValueLength),maxCauseDepth:Y("maxCauseDepth",i.maxCauseDepth),maxBytes:Y("maxBytes",i.maxBytes)}}function ti(i,e={}){if(i===void 0)return;let t=Xr(),r=n=>{let o=JSON.stringify(n);return o===void 0||ei(o)<=t.maxBytes};try{if(t=Xr(e),t.maxBytes===0)return;let n=B(Qn(i),1024);for(let s=t.depth;s>=0;s--){let a={limits:t,causeBudget:t.maxCauseDepth,seen:new Set,nodes:0,textBytes:0};try{let p={type:n,value:ot(i,s,a)};if(r(p))return p}catch(p){if(!(p instanceof J))throw p}}let o={type:n,truncated:!0};return r(o)?o:void 0}catch{let n={type:"unserializable"};return r(n)?n:void 0}}function pe(i,e){if(i.length>e.limits.maxBytes)throw new J;if(e.textBytes+=ei(JSON.stringify(i)),e.textBytes>e.limits.maxBytes)throw new J;return i}function ot(i,e,t){if(++t.nodes>$n)throw new J;let r=Yn(i,e,t);return typeof r=="string"?pe(r,t):r}function Yn(i,e,t){switch(typeof i){case"string":return B(i,t.limits.maxValueLength);case"number":return Number.isFinite(i)?i:String(i);case"boolean":case"undefined":return i;case"bigint":case"symbol":return B(String(i),t.limits.maxValueLength);case"function":return`[Function: ${i.name||"anonymous"}]`}if(i===null)return null;let r=i;if(t.seen.has(r))return"[Circular]";if(e<0)return`[${X(r)}]`;t.seen.add(r);try{return Jn(r,e,t)}finally{t.seen.delete(r)}}function B(i,e){return i.length>e?i.slice(0,e)+"\u2026":i}function Zr(i,e,t){let r=i.length>t;i=B(i,t);let n=i.split(`
|
|
1
|
+
"use strict";(()=>{var Lt=0;function P(){if(Lt===4294967295)throw new Error("Low-event capture sequence exhausted");return++Lt}function Rt(i,e){if(i==="passkey-login")switch(e){case"passkey-known-identifier":case"passkey-no-identifier":return"passkey-button";case"passkey-known-identifier-auto":case"passkey-no-identifier-auto":case"passkey-immediate":return"automatic"}else if(i==="passkey-enrollment")switch(e){case"manual":return"passkey-button";case"auto":case"conditional":return"automatic"}}var T=[];for(let i=0;i<256;++i)T.push((i+256).toString(16).slice(1));function _t(i,e=0){return(T[i[e+0]]+T[i[e+1]]+T[i[e+2]]+T[i[e+3]]+"-"+T[i[e+4]]+T[i[e+5]]+"-"+T[i[e+6]]+T[i[e+7]]+"-"+T[i[e+8]]+T[i[e+9]]+"-"+T[i[e+10]]+T[i[e+11]]+T[i[e+12]]+T[i[e+13]]+T[i[e+14]]+T[i[e+15]]).toLowerCase()}var dt,Ei=new Uint8Array(16);function ue(){if(!dt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");dt=crypto.getRandomValues.bind(crypto)}return dt(Ei)}var pt={};function Ci(i,e,t){let r;if(i)r=At(i.random??i.rng?.()??ue(),i.msecs,i.seq,e,t);else{let n=Date.now(),o=ue();ki(pt,n,o),r=At(o,pt.msecs,pt.seq,e,t)}return e??_t(r)}function ki(i,e,t){return i.msecs??=-1/0,i.seq??=0,e>i.msecs?(i.seq=t[6]<<23|t[7]<<16|t[8]<<8|t[9],i.msecs=e):(i.seq=i.seq+1|0,i.seq===0&&i.msecs++),i}function At(i,e,t,r,n=0){if(i.length<16)throw new Error("Random bytes length must be >= 16");if(!r)r=new Uint8Array(16),n=0;else if(n<0||n+16>r.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);return e??=Date.now(),t??=i[6]*127<<24|i[7]<<16|i[8]<<8|i[9],r[n++]=e/1099511627776&255,r[n++]=e/4294967296&255,r[n++]=e/16777216&255,r[n++]=e/65536&255,r[n++]=e/256&255,r[n++]=e&255,r[n++]=112|t>>>28&15,r[n++]=t>>>20&255,r[n++]=128|t>>>14&63,r[n++]=t>>>6&255,r[n++]=t<<2&255|i[10]&3,r[n++]=i[11],r[n++]=i[12],r[n++]=i[13],r[n++]=i[14],r[n++]=i[15],r}var S=Ci;function N(i){if(i!=null){if(i instanceof Error)return{name:i.name,message:i.message};if(typeof i=="string")return{message:i};if(typeof i=="object"){let e=i;if(typeof e.message=="string"||typeof e.code=="string")return{name:typeof e.name=="string"?e.name:void 0,message:typeof e.message=="string"?e.message:void 0,code:typeof e.code=="string"?e.code:void 0}}return{message:String(i)}}}var Oi=1500,h=class{constructor(e,t){this.tracker=e;this.operationName=t}startReference;captureSpecType;captureSessionId;lowFlushers=[];lowPrefillCapturers=[];lowEventSink(e,t){return{reserveCaptureSeq:P,enqueueLowEvent:r=>this.tracker.enqueueLowEvent({...r,captureSeq:r.captureSeq??P(),subflowStartEventId:this.startReference,sourceKind:e,fieldRole:t,initiator:r.initiator??(t?`input-${t}`:"unknown")},this.captureSessionId),flushKeepalive:()=>this.tracker.lowEventFlushKeepalive(),registerInputs:(r,n)=>this.tracker.getWindowObserver().registerInputs(r,()=>({subflowStartEventId:this.startReference,fieldRole:t,initiator:t?`input-${t}`:"unknown",sessionId:this.captureSessionId}),n),beginCeremony:r=>this.tracker.getWindowObserver().beginCeremony({subflowStartEventId:this.startReference,initiator:r??"unknown",sessionId:this.captureSessionId})}}createLowCollector(e){try{let t=e();return this.lowPrefillCapturers.push(r=>t.capturePrefill(r)),t}catch(t){this.tracker.getLogger().error("Failed to attach low-event collector",t);return}}registerLowFlusher(e){this.lowFlushers.push(e)}captureOptions(e,t=this.startReference,r=this.captureSessionId,n){if(!t&&!n)return e;let o={};return t&&(o.subflowStartEventId=e?.subflowStartEventId??t,o.captureSessionId=e?.captureSessionId??r),n&&(o.initiator=e?.initiator??n),Object.defineProperties({},{...Object.getOwnPropertyDescriptors(e??{}),...Object.getOwnPropertyDescriptors(o)})}get captureReference(){return this.startReference}get captureSession(){return this.captureSessionId}adoptCapture(e,t,r){this.startReference=e,this.captureSessionId=t,this.captureSpecType=r}subflowStart(e,t){try{for(let r of this.lowFlushers)try{r()}catch(n){this.tracker.getLogger().error("Failed to flush previous low-event context",n)}this.captureSpecType=e?.explicitSpecType,this.startReference=S(),this.captureSessionId=this.tracker.getSessionId(),this.tracker.trackSubflowStarted(this.operationName,e,this.captureOptions(t),this.startReference),this.captureInputPrefills(!0)}catch(r){this.tracker.getLogger().error("Failed to start low-event capture context",r)}}capturePrefill(){this.captureInputPrefills(!1)}captureInputPrefills(e){for(let t of this.lowPrefillCapturers)try{t(e)}catch(r){this.tracker.getLogger().error("Failed to capture input prefill",r)}}trigger(e,t){this.tracker.trackSubflowTrigger(this.operationName,e,this.captureOptions(t))}customStep(e){return this.defineStep(e)}subflowStepStarted(e,t,r,n){this.captureSpecType=t?.explicitSpecType??this.captureSpecType,this.tracker.trackSubflowStepStarted(this.operationName,e,t,this.captureOptions(r),n)}subflowStepFinished(e,t,r){(!r?.subflowStartEventId||r.subflowStartEventId===this.startReference)&&(this.captureSpecType=t?.explicitSpecType??this.captureSpecType),this.tracker.trackSubflowStepFinished(this.operationName,e,t,this.captureOptions(r))}subflowStepError(e,t,r){let n=t;try{let o=this.tracker.getSdkConfig().rawErrors?r?.rawError:void 0;if(o!==void 0){let s=this.tracker.rawErrors;s&&(n={...t,rawError:s(o,r?.rawErrorLimits)})}}catch{}this.tracker.trackSubflowStepError(this.operationName,e,n,this.captureOptions(r))}withWindowLowEvents(e,t){let r,n=s=>{s?.subflowStartEventId&&s.subflowStartEventId!==r||t.scheduleDisarm(Oi)},o=e;return{...e,start:(s,a)=>{r=a?.subflowStartEventId??this.startReference;let p=s?.explicitSpecType??this.captureSpecType,d=a?.initiator??Rt(this.operationName,p);t.arm(d,p==="passkey-cui"),o.start(s,d?{...a,initiator:d}:a)},finished:(s,a)=>{o.finished(s,a),n(a)},error:(s,a)=>{o.error(s,a),n(a)},errorTyped:(s,a)=>{o.errorTyped?.(s,a),n(a)}}}defineStep(e,t){let r,n,o,s=p=>this.captureOptions(p,r,n,o);return{start:(p,d)=>{r=this.startReference,n=this.captureSessionId,o=d?.initiator,this.subflowStepStarted(e,p,s(d),t)},finished:(p,d)=>{this.subflowStepFinished(e,p,s(d))},error:(p,d)=>{this.subflowStepError(e,{error:N(p)},s(d))},errorTyped:(p,d)=>{this.subflowStepError(e,p,s(d))}}}};function Dt(i,e){if(e.explicitSpecType!==void 0)try{i.getLogger().warn("Unsupported key operation spec type; omitting it")}catch{}}var fe=class extends h{prepare;sign;constructor(e,t={}){super(e,"key-signing"),this.prepare=this.defineStep("prepare"),this.sign=this.defineStep("sign"),this.subflowStart({actor:"system",explicitSpecType:Dt(e,t)})}},he=class extends h{prepare;postResponse;constructor(e,t={}){super(e,"key-registration"),this.prepare=this.defineStep("prepare"),this.postResponse=this.defineStep("post-response"),this.subflowStart({actor:"system",explicitSpecType:Dt(e,t)})}};var ct="cbo_sdk_config",Ht="cbo_sdk_config_cache",Bt="X-Corbado-Observe-Config";var w={flushIntervalMs:{min:100,max:6e4},retryMaxAttempts:{min:1,max:10},retryDelayMs:{min:50,max:12e4},sessionInactivityMs:{min:6e4,max:864e5},seqLockTimeoutMs:{min:0,max:250},deviceInfoCollectorTimeoutMs:{min:10,max:1e4},flushOnFlowTypeFinished:{maxEntries:20,maxNameLength:100},sourcePathQueryAllow:{maxEntries:50,maxKeyLength:64}},Ii=1800*1e3,b={version:"",flushIntervalMs:500,durableOutbox:!1,durableLowOutbox:!1,beaconKeepalive:!1,sessionContinuity:!1,sessionInactivityMs:Ii,seqLockTimeoutMs:50,tvc:!0,tph:!0,td:!0,tlf:!0,telemetry:!0,flushOnTelemetry:!1,flushOnFlowTypeFinished:[],deviceInfoCollectorTimeoutMs:1e3,deviceInfoTiming:!1,rawErrors:!0,pmd:!0,retry:{maxAttempts:1,baseDelayMs:0,maxDelayMs:0},aap:"",sourcePathQuery:"allowlist",sourcePathQueryAllow:[]};function M(i,e,t){return Math.min(Math.max(i,e),t)}function H(i,e){return typeof i=="number"&&Number.isFinite(i)?i:e}function F(i,e){return typeof i=="boolean"?i:e}function Mt(i,e){return typeof i=="string"?i:e}function xi(i){return Array.isArray(i)?i.filter(e=>typeof e=="string"&&e.length>0&&e.length<=w.flushOnFlowTypeFinished.maxNameLength).slice(0,w.flushOnFlowTypeFinished.maxEntries):[]}function Pi(i){return typeof i=="string"&&i.trim().toLowerCase()==="all"?"all":"allowlist"}function Fi(i){return Array.isArray(i)?i.filter(e=>typeof e=="string").map(e=>e.trim()).filter(e=>e.length>0&&e.length<=w.sourcePathQueryAllow.maxKeyLength).slice(0,w.sourcePathQueryAllow.maxEntries):[]}function q(i){if(!i||typeof i!="object")return null;let e=i;return typeof e.version!="string"||e.version===""?null:Ut(e)}function Ut(i){let e=i.retry&&typeof i.retry=="object"?i.retry:{},t=M(H(e.baseDelayMs,b.retry.baseDelayMs),w.retryDelayMs.min,w.retryDelayMs.max);return{version:Mt(i.version,""),flushIntervalMs:M(H(i.flushIntervalMs,b.flushIntervalMs),w.flushIntervalMs.min,w.flushIntervalMs.max),durableOutbox:i.durableOutbox===!0,durableLowOutbox:i.durableLowOutbox===!0,beaconKeepalive:i.beaconKeepalive===!0,sessionContinuity:i.sessionContinuity===!0,sessionInactivityMs:M(H(i.sessionInactivityMs,b.sessionInactivityMs),w.sessionInactivityMs.min,w.sessionInactivityMs.max),seqLockTimeoutMs:M(H(i.seqLockTimeoutMs,b.seqLockTimeoutMs),w.seqLockTimeoutMs.min,w.seqLockTimeoutMs.max),tvc:F(i.tvc,b.tvc),tph:F(i.tph,b.tph),td:F(i.td,b.td),tlf:F(i.tlf,b.tlf),telemetry:F(i.telemetry,b.telemetry),flushOnTelemetry:i.flushOnTelemetry===!0,flushOnFlowTypeFinished:xi(i.flushOnFlowTypeFinished),deviceInfoCollectorTimeoutMs:M(H(i.deviceInfoCollectorTimeoutMs,b.deviceInfoCollectorTimeoutMs),w.deviceInfoCollectorTimeoutMs.min,w.deviceInfoCollectorTimeoutMs.max),deviceInfoTiming:i.deviceInfoTiming===!0,rawErrors:F(i.rawErrors,b.rawErrors),pmd:F(i.pmd,b.pmd),aap:Mt(i.aap,""),sourcePathQuery:Pi(i.sourcePathQuery),sourcePathQueryAllow:Fi(i.sourcePathQueryAllow),retry:{maxAttempts:M(H(e.maxAttempts,b.retry.maxAttempts),w.retryMaxAttempts.min,w.retryMaxAttempts.max),baseDelayMs:t,maxDelayMs:M(H(e.maxDelayMs,b.retry.maxDelayMs),t,w.retryDelayMs.max)}}}function ge(i,e={}){let t=i??b,r=Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0)),n=Object.fromEntries(Object.entries(e.retry??{}).filter(([,s])=>s!==void 0)),o=Ut({...t,...r,retry:{...t.retry,...n}});return o.retry={...t.retry,...Object.fromEntries(Object.keys(n).map(s=>[s,o.retry[s]]))},o.retry.maxDelayMs=Math.max(o.retry.baseDelayMs,o.retry.maxDelayMs),o}var Li="static";function Nt(i,e){let t;try{t=JSON.parse(i)}catch{t=void 0}let r=!!t&&typeof t=="object"&&!Array.isArray(t),n=r?t:{};return{config:ge(void 0,{...n,version:typeof n.version=="string"&&n.version!==""?n.version:Li,...e!==void 0&&{pmd:e}}),valid:r}}function me(i){try{if(!i||typeof i!="object")return;let e=i,t=e.crossOriginSession,r=t&&typeof t=="object"&&typeof t.cookieDomain=="string"?t.cookieDomain:void 0;return{pmd:F(e.pmd,!1),privateMode:F(e.privateMode,!0),...r!==void 0&&{crossOriginSession:{cookieDomain:r}}}}catch{return}}function ye(i){let e=i.getItem(Ht),t=e&&typeof e=="object"?q(e.config):null;return t?{...e,config:t}:null}function qt(i){return ye(i)?.config??q(i.getItem(ct))}function Kt(i,e){i.setItem(Ht,e)}function Wt(i){try{return decodeURIComponent(i.replace(/\+/g," "))}catch{return i}}function Vt(i,e){let t=i.toLowerCase();return e.some(r=>{let n=r.toLowerCase();return n.endsWith("*")?t.startsWith(n.slice(0,-1)):t===n})}function $t(i,e,t){return e!=="allowlist"||i===""||i==="?"?i:`?${(i.startsWith("?")?i.slice(1):i).split("&").map(o=>{let s=o.indexOf("=");if(s===-1)return o;let a=o.slice(0,s);return o.slice(s+1)===""||Vt(Wt(a),t)?o:`${a}=*`}).join("&")}`}var Ri=/^[A-Za-z][A-Za-z0-9_.\-[\]]{0,63}$/;function Gt(i,e){return i===""||i==="?"?i:`?${(i.startsWith("?")?i.slice(1):i).split("&").map(n=>{if(n==="")return n;let o=n.indexOf("="),s=o===-1?n:n.slice(0,o),a=Wt(s);if(Vt(a,e))return n;if(o===-1)return"*";let p=Ri.test(a)?s:"*";return n.length===o+1?`${p}=`:`${p}=*`}).join("&")}`}function jt(i){let e=String(i??"").split("/").filter(t=>t!=="");return e.length===0?"/":"/"+e.map(()=>"*").join("/")}function O(i,e,t,r){return r===void 0?window.addEventListener(e,t):window.addEventListener(e,t,r),()=>window.removeEventListener(e,t)}function K(i){return document.visibilityState==="hidden"}function Qt(i){return document.readyState==="complete"}function zt(i,e,t){if(typeof __CBO_DATA_PAGE_STRICT__=="boolean"&&__CBO_DATA_PAGE_STRICT__)return`${jt(window.location.pathname)}${Gt(window.location.search,t)}`;let r=$t(window.location.search,e,t);return`${window.location.pathname}${r}`}function Yt(i){return{hostname:window.location.hostname,https:window.location.protocol==="https:"}}function Jt(i){return typeof navigator>"u"?"":navigator.userAgent??""}async function Xt(i){if(!(typeof navigator>"u"||!navigator.bluetooth))return await navigator.bluetooth.getAvailability()}async function Zt(i){if(!(typeof PublicKeyCredential>"u"||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable))return await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}async function er(i){if(!(typeof PublicKeyCredential>"u"||!PublicKeyCredential.isConditionalMediationAvailable))return await PublicKeyCredential.isConditionalMediationAvailable()}async function tr(i){if(typeof PublicKeyCredential>"u"||!PublicKeyCredential.getClientCapabilities)return;let e=await PublicKeyCredential.getClientCapabilities();return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,r.toString()]))}async function rr(i){if(typeof navigator>"u"||!navigator.userAgentData)return;let e=await navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]),t=e.platform,r=e.mobile,n=e.platformVersion,o=e.model||void 0;if(!(!t||r===void 0||!n))return{platform:t,mobile:r,platformVersion:n,model:o}}function ir(i){if(!(typeof navigator>"u"))return navigator.webdriver}function nr(i){if(!(typeof navigator>"u"||typeof navigator.maxTouchPoints!="number"))return navigator.maxTouchPoints}var ut=(i,e,t)=>{let r=!1,n,o=null,s=null,a=()=>{s!==null&&(clearTimeout(s),s=null);let d=o;r=!1,o=null,d!==null&&i({...n===void 0?{}:{captureSeq:n},lowType:e,ts:d,durationMs:Date.now()-d})};return{extend:()=>{if(!r){let d=t?.();r=!0,o=Date.now(),n=d}s!==null&&clearTimeout(s),s=setTimeout(a,150)},flush:a}};function or(i,e,t){let r=[],n=(s,a,p)=>{let d=l=>t(a,()=>p(l));s.addEventListener(a,d),r.push(()=>s.removeEventListener(a,d))};n(window,"blur",()=>e.blur()),n(window,"focus",()=>e.focus()),n(document,"visibilitychange",()=>e.visibilityChange(document.visibilityState==="hidden")),n(document,"focusout",s=>e.focusOut(s.target,!!s.relatedTarget)),n(document,"focusin",s=>e.focusIn(()=>s.composedPath())),n(document,"pointerdown",s=>e.pointerDown(s.target)),window.visualViewport&&(n(window.visualViewport,"resize",()=>e.viewportResize()),n(window.visualViewport,"scroll",()=>e.viewportScroll())),n(window,"pagehide",()=>e.pageHide());let o=window.navigation;return o&&n(o,"currententrychange",s=>{let a=s,p=a.from?.index,d=o.currentEntry?.index;a.navigationType==="traverse"&&typeof p=="number"&&typeof d=="number"&&p>=0&&d>=0&&d<p&&e.navigateBack()}),r}function sr(i){let e=[];for(let t=document.activeElement;t;t=t.shadowRoot?.activeElement??null)e.push(t);return e}function ar(i){let e=document.activeElement;return{active:e,idle:e===document.body||!e}}var _i,re=()=>_i??=S(),ve=class{constructor(e,t,r){this.logger=e;this.enqueue=t;this.flushKeepalive=r;typeof window>"u"||typeof document>"u"||(this.removers=or(0,{blur:()=>{this.flushInputs(),this.bracket=this.context(),this.emit({lowType:"window-blur",ts:Date.now()},this.bracket)},focus:()=>{this.flushInputs(),this.emit({lowType:"window-focus",ts:Date.now()},this.bracket??this.context()),this.bracket=void 0},visibilityChange:n=>{this.flushInputs(),this.emit({lowType:`document-visibilitychange-${n?"hidden":"visible"}`,ts:Date.now()})},focusOut:(n,o)=>{let s=this.findInput(n);this.lastBlur=s&&!o&&Date.now()-this.unrelatedPointerAt>250?{registration:s,ts:Date.now()}:void 0},focusIn:n=>{this.lastBlur=void 0;let o=this.inputFocusListeners.size>0&&n().find(s=>this.findInput(s));o&&this.notifyInputFocus(o)},pointerDown:n=>{this.findInput(n)?this.unrelatedPointerAt=-1/0:(this.lastBlur=void 0,this.unrelatedPointerAt=Date.now())},viewportResize:()=>this.extendViewport("resize"),viewportScroll:()=>this.extendViewport("scroll"),pageHide:()=>{this.flushInputs(),this.resize.flush(),this.scroll.flush(),this.flushKeepalive()},navigateBack:()=>{this.flushInputs(),this.emit({lowType:"window-navigate-back",ts:Date.now()})}},(n,o)=>{try{o()}catch(s){this.logger.error(`Failed to observe window ${n}`,s)}}))}inputs=new Set;inputFocusListeners=new Set;ceremonies=new Set;removers=[];lastBlur;bracket;unrelatedPointerAt=-1/0;destroyed=!1;viewportContext={};resize=ut(e=>this.emit(e,this.viewportContext.resize),"visualviewport-resize",P);scroll=ut(e=>this.emit(e,this.viewportContext.scroll),"visualviewport-scroll",P);registerInputs(e,t,r){if(this.destroyed)return()=>{};let n={fields:e,context:t,flush:r};if(this.inputs.add(n),this.inputFocusListeners.size>0&&typeof document<"u"){let o=sr(0),s=e.find(a=>o.includes(a));s&&this.notifyInputFocus(s)}return()=>{this.inputs.delete(n),this.lastBlur?.registration===n&&(this.lastBlur=void 0)}}beginCeremony(e){let t={context:e,settled:!1};this.destroyed||(this.flushInputs(),this.ceremonies.add(t));let r=()=>{t.timer&&clearTimeout(t.timer),this.ceremonies.delete(t),this.bracket===t.context&&(this.bracket=void 0)};return{settle:n=>{t.settled=!0,t.timer&&clearTimeout(t.timer),t.timer=setTimeout(r,n)},destroy:r}}onInputFocus(e){return this.destroyed?()=>{}:(this.inputFocusListeners.add(e),()=>this.inputFocusListeners.delete(e))}notifyInputFocus(e){for(let t of this.inputFocusListeners)try{t(e)}catch(r){this.logger.error("Failed to notify registered input focus",r)}}context(){let e=[...this.ceremonies].filter(o=>!o.settled);if(e.length===1)return e[0].context;if(e.length>1)return;let t=ar(0),r=this.findInput(t.active);if(r)return r.context();let n=this.lastBlur;if(n&&Date.now()-n.ts<=250&&t.idle)return n.registration.context()}findInput(e){return[...this.inputs].find(t=>t.fields.some(r=>r===e))}flushInputs(){for(let e of this.inputs)try{e.flush()}catch(t){this.logger.error("Failed to flush window input context",t)}}emit(e,t){if(this.destroyed)return;let{sessionId:r,...n}=t??{};this.enqueue({...e,...n,captureSeq:e.captureSeq??P(),sourceKind:"window",captureVersion:1,pageId:re()},r)}extendViewport(e){let t=this.context(),r=this.viewportContext[e];(r?.subflowStartEventId!==t?.subflowStartEventId||r?.fieldRole!==t?.fieldRole||r?.sessionId!==t?.sessionId)&&this[e].flush(),this.viewportContext[e]=t,this[e].extend()}destroy(){if(!this.destroyed){this.flushInputs(),this.resize.flush(),this.scroll.flush(),this.destroyed=!0;for(let e of this.removers)e();for(let e of this.ceremonies)e.timer&&clearTimeout(e.timer);this.ceremonies.clear(),this.inputs.clear(),this.inputFocusListeners.clear()}}};var Ai=new Set;function lr(i){Ai.add(i)}function Se(i,e,t){return fetch(e,t)}function dr(i){if(typeof navigator?.sendBeacon=="function")return(e,t)=>navigator.sendBeacon(e,t)}var Di=6e4,Mi=6e4,be=class{constructor(e){this.options=e;lr(0)}async send(e,t){try{e.meta={...e.meta,sent:Date.now(),transport:"fetch"};let r=JSON.stringify(e),n=typeof AbortController<"u"?new AbortController:void 0,o=n?setTimeout(()=>n.abort(),Mi):void 0;try{let s={method:"POST",headers:{"Content-Type":"application/json",...this.options.headers,...t},body:r,keepalive:new Blob([r]).size<=Di,...n?{signal:n.signal}:{}},a=await Se(0,this.options.url,s),p={statusCode:a.status,headers:{"retry-after":a.headers.get("Retry-After")}};if(a.headers.get("X-Corbado-Observe-Accepted")==="1"&&(p.deliveryAccepted=!0),a.status===200)try{let d=q(await a.json());d&&(p.config=d)}catch(d){this.options.logger.error("Failed to parse SDK config response",d),this.options.logger.reportTelemetry?.("error","failed to parse SDK config response")}return p}finally{o&&clearTimeout(o)}}catch(r){return this.options.logger.error("Failed to send event",r),{}}}sendBeacon(e){try{this.options.logger.debug(`Sending ${e.events.length} events via beacon`);let t=dr(0);if(!t)return!1;e.meta={...e.meta,sent:Date.now(),transport:"beacon"};let r=new Blob([JSON.stringify(e)],{type:"text/plain"});return t(this.options.url,r)}catch(t){return this.options.logger.error("Failed to send event via beacon",t),!1}}flush(e){return Promise.resolve(!0)}};function Te(i,e,t,r={}){let n=typeof navigator<"u"?navigator.locks:void 0;if(n?.request){let o=r.timeoutMs,s=o!==void 0&&typeof AbortController<"u"?new AbortController:null;if(o!==void 0&&!s)return Promise.resolve().then(t);try{let a=!1,p,d=()=>{p!==void 0&&(clearTimeout(p),p=void 0)},l=()=>(a=!0,d(),t()),c=s?n.request(e,{signal:s.signal},l):n.request(e,l);return s&&o!==void 0&&!a&&(p=setTimeout(()=>{p=void 0,s.abort();try{r.onTimeout?.()}catch{}},o)),c.catch(f=>{if(a)throw f;return t()}).finally(d)}catch{}}try{return Promise.resolve(t())}catch(o){return Promise.reject(o)}}function pr(i){return typeof navigator<"u"&&!!navigator.locks?.request}var Hi="cbo_outbox",ft="cbo_outbox",Bi=500,Ui=512*1024,Ni=10080*60*1e3;function qi(i){let e=i.event,t=typeof e.timestamp=="number"?e.timestamp:e.ts;if(typeof t=="number"&&Number.isFinite(t))return t;let r=/^([0-9a-f]{8})-?([0-9a-f]{4})-?7/i.exec(i.id);return r?parseInt(r[1]+r[2],16):void 0}function Ki(i){if(!i||typeof i!="object")return!1;let e=i;return typeof e.id=="string"&&e.id!==""&&typeof e.sessionId=="string"&&typeof e.flushAfter=="number"&&Number.isFinite(e.flushAfter)&&typeof e.attempts=="number"&&Number.isFinite(e.attempts)&&typeof e.event=="object"&&e.event!==null}var W=class{constructor(e,t,r=Bi,n=Ui,o=ft,s=Hi){this.storage=e;this.logger=t;this.maxEntries=r;this.maxSerializedLength=n;this.lockName=o;this.storageKey=s;this.entries=this.read(),typeof __CBO_DATA_RETENTION__=="boolean"&&__CBO_DATA_RETENTION__&&this.purgeExpired(Date.now())}entries=[];reportedMalformed=!1;purgeExpired(e){let t=n=>{let o=qi(n);return o!==void 0&&e-o>Ni};if(!this.entries.some(t))return;let r=this.entries.filter(t).length;this.entries=this.entries.filter(n=>!t(n)),this.logger.debug(`EventStore deleted ${r} entries past the retention limit`),this.mutate(n=>n.filter(o=>!t(o)))}read(){let e=this.storage.getItem(this.storageKey);if(!Array.isArray(e))return[];let t=e.filter(Ki);return t.length<e.length&&!this.reportedMalformed&&(this.reportedMalformed=!0,this.logger.error(`EventStore dropped ${e.length-t.length} malformed outbox entries`),this.logger.reportTelemetry?.("error","event store dropped malformed outbox entries")),t}mutate(e){return Te(0,this.lockName,()=>{try{let t=e(this.read());if(t.length>this.maxEntries){let r=t.length-this.maxEntries;t=t.slice(t.length-this.maxEntries),this.logger.error(`EventStore evicted ${r} oldest entries (cap ${this.maxEntries})`),this.logger.reportTelemetry?.("error","event store evicted entries (cap)")}t=this.enforceSizeBudget(t),this.entries=t,this.storage.setItem(this.storageKey,t)}catch(t){this.logger.error("Failed to mutate event store",t),this.logger.reportTelemetry?.("error","failed to mutate event store")}})}enforceSizeBudget(e){let t=e.map(o=>JSON.stringify(o).length),r=t.reduce((o,s)=>o+s,e.length+1),n=0;for(;r>this.maxSerializedLength&&n<e.length;)r-=t[n]+1,n++;return n===0?e:(this.logger.error(`EventStore evicted ${n} oldest entries (size budget ${this.maxSerializedLength})`),this.logger.reportTelemetry?.("error","event store evicted entries (size budget)"),e.slice(n))}add(e){return this.mutate(t=>t.some(r=>r.id===e.id)?t:[...t,e])}all(){return this.entries=this.read(),this.entries}getDue(e){return this.all().filter(t=>t.flushAfter<=e)}remove(e){if(e.length===0)return Promise.resolve();let t=new Set(e);return this.mutate(r=>r.filter(n=>!t.has(n.id)))}update(e){if(e.length===0)return Promise.resolve();let t=new Map(e.map(r=>[r.id,r]));return this.mutate(r=>r.map(n=>t.get(n.id)??n))}size(){return this.all().length}};var cr=6e4,ht=32e3;function ie(i){let e=0;for(let t=0;t<i.length;t++){let r=i.charCodeAt(t);r<128?e+=1:r<2048?e+=2:r>=55296&&r<=56319&&t+1<i.length?(e+=4,t++):e+=3}return e}var Wi=["cbo_visibility_change_debug","cbo_pagehide_debug"],we=class{constructor(e,t,r,n,o={},s){this.logger=e;this.transport=t;this.sessionId=r;this.sdk=n;this.storage=s;if(this.batchSize=o.batchSize||50,this.flushIntervalOverride=o.flushInterval,this.debug=o.debug??!1,this.requestConfig=o.requestConfig??!0,this.onConfigReceived=o.onConfigReceived,this.getDataPolicy=o.getDataPolicy,this.getCrossOriginSession=o.getCrossOriginSession,this.fixedData=o.fixedData===!0,this.beforeEventBatchSend=o.beforeEventBatchSend,this.standaloneDeviceInfo=o.standaloneDeviceInfo,this.config=o.config??b,this.priorityFlowTypes=new Set(this.config.flushOnFlowTypeFinished),this.outboxLockName=o.outboxLockName,this.config.durableOutbox&&this.storage&&(this.store=new W(this.storage,this.logger,void 0,void 0,this.outboxLockName),this.pending=this.store.all()),this.storage){for(let p of Wi)this.storage.removeItem(p);this.lowStore=new W(this.storage,this.logger,1e3,256*1024,`${this.outboxLockName??"cbo_outbox"}:lows`,"cbo_low_outbox_v1");let a=this.lowStore.all();this.lowPending=a.filter(p=>this.validPendingLow(p)),this.lowStore.remove(a.filter(p=>!this.validPendingLow(p)).map(p=>p.id))}this.setupLifecycleHooks(),(this.pending.length>0||this.lowPending.length>0)&&(this.dirtySinceSyncFlush=!0,this.scheduleFlush(0,"recovery"))}pending=[];lowsQueue=[];lowPending=[];lowStore;telemetryQueue=[];lane;timer=null;isFlushing=!1;flushingDone;destroyed=!1;dirtySinceSyncFlush=!1;onVisibilityChange=null;onPageHide=null;removeVisibilityChange=null;removePageHide=null;batchSize;flushIntervalOverride;debug;requestConfig;onConfigReceived;getDataPolicy;getCrossOriginSession;fixedData;beforeEventBatchSend;standaloneDeviceInfo;config;priorityFlowTypes;outboxLockName;store;configResolved=!1;setSessionId(e){this.sessionId=e}flushInterval(){return this.flushIntervalOverride??this.config.flushIntervalMs}enqueue(e,t=this.sessionId){try{let r={id:e.id,sessionId:t,flushAfter:0,attempts:0,event:e};this.pending.push(r),this.store?.add(r),this.scheduleAfterEnqueue(e)}catch(r){this.logger.error("Failed to enqueue event",r)}}enqueueLow(e,t=this.sessionId){try{let r={...e,id:e.id??S()};if(this.config.durableLowOutbox){let n={id:r.id,sessionId:t,event:r,attempts:0,flushAfter:0};this.lowPending.push(n),this.lowPending=this.lowPending.slice(-1e3),this.lowStore?.add(n)}else this.lowsQueue.push({sessionId:t,event:r});this.scheduleAfterEnqueue()}catch(r){this.logger.error("Failed to enqueue low event",r)}}notifyDeviceInfo(){try{this.dirtySinceSyncFlush=!0,this.scheduleFlush(this.flushInterval(),"timer")}catch(e){this.logger.error("Failed to schedule device info flush",e)}}enqueueTelemetry(e){try{if(!this.config.telemetry)return;this.telemetryQueue.push(e),this.dirtySinceSyncFlush=!0,this.config.flushOnTelemetry&&this.flush("telemetry")}catch(t){this.logger.error("Failed to enqueue telemetry",t)}}scheduleAfterEnqueue(e){if(this.dirtySinceSyncFlush=!0,e!==void 0&&this.isPriorityEvent(e)){this.flush("flow-finished");return}this.scheduleFlush(this.flushInterval(),"timer")}isPriorityEvent(e){if(e.type!=="predefined"||e.name!=="flow_finished"&&e.name!=="flow_auto_finished")return!1;let t=e.data?.flowName;return typeof t=="string"&&this.priorityFlowTypes.has(t)}scheduleFlush(e,t){this.destroyed||this.timer||(this.timer=setTimeout(()=>{this.timer=null,this.flush(t)},e))}clearTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null)}async flush(e="timer"){if(this.destroyed)return;if(this.isFlushing){if(e==="destroy"){await this.flushingDone;try{this.lane?.sendUnload(ht,e,!0,!1)}catch(r){this.logger.error("Unexpected error in queue flush",r)}}return}this.isFlushing=!0;let t;this.flushingDone=new Promise(r=>{t=r});try{for(this.clearTimer();;){let r=Date.now(),n=this.getDuePending(r),o=this.lowPending.filter(y=>y.flushAfter<=r),s=this.lane,a=e==="destroy"||!s?[]:s.items.filter(y=>y.flushAfter<=r),p=n.length===0&&o.length===0&&this.lowsQueue.length===0&&this.telemetryQueue.length===0&&a.length===0;if(p&&!this.hasStandaloneDeviceInfo())break;let d=n[0]?.sessionId??o[0]?.sessionId??this.lowsQueue[0]?.sessionId??a[0]?.sessionId??this.sessionId,l=n.filter(y=>y.sessionId===d).slice(0,this.batchSize),c=o.filter(y=>y.sessionId===d).slice(0,100),f=[...c.map(y=>y.event),...this.takeLows(d,100-c.length)];this.prepareEvents(l,e);let g=d===this.sessionId?this.takeTelemetry():[],u=d===this.sessionId?this.takeStandaloneDeviceInfo():void 0,m=s&&a.length>0?s.selectBatch(a,d):[],v={sessionId:d,events:l.map(y=>y.event),sdk:this.sdk};if(f.length>0&&(v.lows=f),g.length>0&&(v.telemetry=g),m.length>0&&(v.probes=m.map(y=>y.entry)),u&&(v.deviceInfo=u),p&&!u)break;this.attachBatchMeta(v,[...l,...c,...m],e),c.length&&(v.deliveryAck=!0);let E=this.shouldRequestConfig()?{[Bt]:this.config.version||"1"}:void 0,C=await this.transport.send(v,E).catch(y=>(this.logger.error("Unexpected error in queue flush",y),{}));if(v.deliveryAck&&C.statusCode&&C.statusCode>=200&&C.statusCode<300&&!C.deliveryAccepted&&(C={...C,statusCode:503}),this.requestConfig&&this.handleConfigResponse(C),this.handleLowSendResult(C,c,r),s?.handleResult(C,m,r),!this.handleSendResult(C,l,r))break}e==="destroy"&&this.lane?.sendUnload(ht,e,!0,!1)}catch(r){this.logger.error("Unexpected error in queue flush",r)}finally{this.isFlushing=!1,t(),this.flushingDone=void 0,this.rescheduleIfPending()}}attachBatchMeta(e,t,r){e.meta={...e.meta,flushReason:r};let n=this.readDataPolicy();n!==void 0&&(e.meta={...e.meta,dataPolicy:n}),this.config.version&&(e.meta={...e.meta,configVersion:this.config.version}),this.fixedData&&(e.meta={...e.meta,fixedData:!0});try{let s=this.getCrossOriginSession?.(e.sessionId);s&&(e.meta={...e.meta,crossOriginSession:s})}catch{}let o=t.reduce((s,a)=>Math.max(s,a.attempts),0);o>0&&(e.meta={...e.meta,retryCount:o})}prepareEvents(e,t){if(!(!this.beforeEventBatchSend||e.length===0))try{this.beforeEventBatchSend(e.map(r=>r.event),t)}catch(r){this.logger.error("Failed to prepare events for sending",r)}}readDataPolicy(){try{return this.getDataPolicy?.()}catch(e){this.logger.debug("Failed to read data policy for batch meta",e);return}}getDuePending(e){return this.pending.filter(t=>t.flushAfter<=e)}takeLows(e=this.sessionId,t=100){let r=this.lowsQueue.filter(o=>o.sessionId===e).slice(0,t),n=new Set(r);return this.lowsQueue=this.lowsQueue.filter(o=>!n.has(o)),r.map(o=>o.event)}validPendingLow(e){return typeof e.event?.lowType=="string"&&e.event.id===e.id&&Number.isFinite(e.event.ts)&&e.event.ts>Date.now()-7*864e5}removeLowEntries(e){let t=new Set(e);this.lowPending=this.lowPending.filter(r=>!t.has(r.id)),this.lowStore?.remove(e)}handleLowSendResult(e,t,r){let n=e.statusCode;if(n!==void 0&&n>=200&&n<300){e.deliveryAccepted?this.removeLowEntries(t.map(o=>o.id)):this.deferLowEntries(t,r);return}if(!this.isRetryable(n)){this.removeLowEntries(t.map(o=>o.id)),this.logger.reportTelemetry?.("error","low events rejected by ingestion");return}this.deferLowEntries(t,r,this.parseRetryAfter(e))}deferLowEntries(e,t,r=null){let n=[];for(let o of e){if(!this.validPendingLow(o)){n.push(o.id);continue}o.attempts=Math.min(o.attempts+1,16),o.flushAfter=t+Math.max(Math.min(6e4,1e3*2**Math.min(o.attempts,6)),this.backoffForAttempt(o.attempts,r))}this.removeLowEntries(n),this.lowStore?.update(e.filter(o=>!n.includes(o.id)))}hasStandaloneDeviceInfo(){try{return this.standaloneDeviceInfo?.has()??!1}catch(e){return this.logger.error("Failed to read device info for batch",e),!1}}takeStandaloneDeviceInfo(){try{return this.standaloneDeviceInfo?.take()}catch(e){this.logger.error("Failed to read device info for batch",e);return}}takeTelemetry(){let e=this.telemetryQueue;return this.telemetryQueue=[],e}shouldRequestConfig(){return this.requestConfig&&!this.configResolved}handleConfigResponse(e){let t=e.statusCode;typeof t=="number"&&t>=200&&t<300&&(this.configResolved=!0),e.config&&(this.config.version||this.updateConfig(e.config),this.onConfigReceived?.(e.config))}updateConfig(e){if(this.destroyed)return;let t=this.config.flushIntervalMs!==e.flushIntervalMs;if(this.config={...e,durableOutbox:this.config.durableOutbox||e.durableOutbox},this.priorityFlowTypes=new Set(e.flushOnFlowTypeFinished),e.durableLowOutbox&&this.lowsQueue.length){let n=this.lowsQueue;this.lowsQueue=[];for(let{event:o,sessionId:s}of n)this.enqueueLow(o,s)}let r=!1;if(this.config.durableOutbox&&this.storage&&!this.store){this.store=new W(this.storage,this.logger,void 0,void 0,this.outboxLockName);let n=new Set(this.pending.map(s=>s.id)),o=this.store.all().filter(s=>!n.has(s.id));for(let s of this.pending)this.store.add(s);this.pending=[...o,...this.pending],r=o.length>0}r?(this.dirtySinceSyncFlush=!0,this.clearTimer(),this.scheduleFlush(0,"recovery")):t&&(this.clearTimer(),this.rescheduleIfPending())}handleSendResult(e,t,r){let n=e.statusCode,o=typeof n=="number"&&n>=200&&n<300;if(t.length===0)return o;if(o)return this.removeEntries(t.map(l=>l.id)),!0;if(!this.isRetryable(n))return this.removeEntries(t.map(l=>l.id)),!1;let s=Math.max(1,this.config.retry.maxAttempts),a=this.parseRetryAfter(e),p=[],d=[];for(let l of t)l.attempts+=1,l.attempts>=s?p.push(l.id):(l.flushAfter=r+this.backoffForAttempt(l.attempts,a),d.push(l));return this.removeEntries(p),this.store?.update(d),!1}isRetryable(e){return e===void 0||e===408||e===429?!0:e>=500}backoffForAttempt(e,t){let r=this.config.retry,n=r.baseDelayMs*Math.pow(2,Math.max(0,e-1));r.maxDelayMs>0&&(n=Math.min(n,r.maxDelayMs));let o=Math.round(n/2+Math.random()*(n/2));return t!==null&&(o=Math.max(o,t)),o}parseRetryAfter(e){let t=e.headers?.["retry-after"];if(!t)return null;let r=Number(t);if(!Number.isNaN(r))return r*1e3;let n=Date.parse(t);return Number.isNaN(n)?null:Math.max(0,n-Date.now())}removeEntries(e){if(e.length===0)return;let t=new Set(e);this.pending=this.pending.filter(r=>!t.has(r.id)),this.store?.remove(e)}rescheduleIfPending(){try{if(this.destroyed||this.timer)return;let e=this.lane?this.lane.items:[];if(this.pending.length===0&&this.lowPending.length===0&&this.lowsQueue.length===0&&e.length===0)return;let t=Date.now();if(this.getDuePending(t).length>0||this.lowPending.some(n=>n.flushAfter<=t)||this.lowsQueue.length>0||e.some(n=>n.flushAfter<=t)){this.scheduleFlush(this.flushInterval(),"timer");return}let r=Math.min(...[...this.pending,...this.lowPending,...e].map(n=>n.flushAfter));this.scheduleFlush(Math.max(0,r-t),"backoff")}catch(e){this.logger.error("Failed to reschedule queue flush",e)}}setupLifecycleHooks(){typeof window>"u"||(this.onVisibilityChange=()=>{try{K(0)&&this.config.tvc&&this.flushSync("visibility-change")}catch(e){this.logger.error("Unexpected error in queue flushSync",e)}},this.onPageHide=()=>{try{this.config.tph&&this.flushSync("pagehide")}catch(e){this.logger.error("Unexpected error in queue flushSync",e)}},this.removeVisibilityChange=O(0,"visibilitychange",this.onVisibilityChange),this.removePageHide=O(0,"pagehide",this.onPageHide))}flushKeepalive(e="manual"){this.flushSync(e)}flushSync(e){let t=this.flushSyncEvents(e),r=this.lane;e==="pagehide"&&r&&r.items.length>0&&r.sendUnload(Math.min(cr-t,ht),e,!0,!0)}flushSyncEvents(e){if(!this.dirtySinceSyncFlush)return 0;let t=this.sessionId,r=this.pending.filter(l=>l.sessionId===t),n=r.slice(0,this.batchSize),o=this.lowPending.filter(l=>l.sessionId===t).slice(0,100),s=[...o.map(l=>l.event),...this.takeLows(t,100-o.length)];this.prepareEvents(n,e);let a=this.takeTelemetry(),p=this.takeStandaloneDeviceInfo();if(n.length===0&&s.length===0&&a.length===0&&!p)return this.dirtySinceSyncFlush=!1,0;let d={sessionId:t,events:n.map(l=>l.event),sdk:this.sdk};return s.length>0&&(d.lows=s),a.length>0&&(d.telemetry=a),p&&(d.deviceInfo=p),this.attachBatchMeta(d,[...n,...o],e),o.length&&(d.deliveryAck=!0),this.config.beaconKeepalive&&this.transport.sendBeacon?this.transport.sendBeacon(d)||this.transport.send(d):this.transport.send(d),this.config.durableOutbox||this.removeEntries(n.map(l=>l.id)),this.dirtySinceSyncFlush=!this.config.durableOutbox&&r.length>n.length,this.approximateSize(d)}approximateSize(e){try{return ie(JSON.stringify(e))}catch{return cr}}destroy(){try{this.destroyed=!0,this.clearTimer(),this.lane&&this.lane.drop(this.lane.items.slice()),typeof window<"u"&&(this.removeVisibilityChange&&this.removeVisibilityChange(),this.removePageHide&&this.removePageHide())}catch(e){this.logger.error("Failed to destroy queue lifecycle hooks",e)}}};var gt={d:(i,e)=>{for(var t in e)gt.o(e,t)&&!gt.o(i,t)&&Object.defineProperty(i,t,{enumerable:!0,get:e[t]})},o:(i,e)=>Object.prototype.hasOwnProperty.call(i,e)},mt={};gt.d(mt,{A:()=>Vi,k:()=>ur});var V=function(i,e,t,r){return new(t||(t=Promise))(function(n,o){function s(d){try{p(r.next(d))}catch(l){o(l)}}function a(d){try{p(r.throw(d))}catch(l){o(l)}}function p(d){var l;d.done?n(d.value):(l=d.value,l instanceof t?l:new t(function(c){c(l)})).then(s,a)}p((r=r.apply(i,e||[])).next())})},$=function(i,e){var t,r,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(p){return function(d){return(function(l){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(s=0)),s;)try{if(t=1,r&&(n=2&l[0]?r.return:l[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,l[1])).done)return n;switch(r=0,n&&(l=[2&l[0],n.value]),l[0]){case 0:case 1:n=l;break;case 4:return s.label++,{value:l[1],done:!1};case 5:s.label++,r=l[1],l=[0];continue;case 7:l=s.ops.pop(),s.trys.pop();continue;default:if(n=s.trys,!((n=n.length>0&&n[n.length-1])||l[0]!==6&&l[0]!==2)){s=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]<n[3])){s.label=l[1];break}if(l[0]===6&&s.label<n[1]){s.label=n[1],n=l;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(l);break}n[2]&&s.ops.pop(),s.trys.pop();continue}l=e.call(i,s)}catch(c){l=[6,c],r=0}finally{t=n=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}})([p,d])}}};function ur(){return V(this,void 0,Promise,function(){return $(this,function(i){switch(i.label){case 0:return[4,new Promise(function(e,t){var r="Unknown",n=!1;function o(l){n||(n=!0,e({isPrivate:l,browserName:r}))}function s(){var l=0,c=parseInt("-1");try{c.toFixed(c)}catch(f){l=f.message.length}return l}function a(){return V(this,void 0,void 0,function(){var l,c;return $(this,function(f){switch(f.label){case 0:return f.trys.push([0,2,,3]),[4,navigator.storage.getDirectory()];case 1:return f.sent(),o(!1),[3,3];case 2:return l=f.sent(),c=l instanceof Error&&typeof l.message=="string"?l.message:String(l),o(c.includes("unknown transient reason")),[3,3];case 3:return[2]}})})}function p(){var l;return V(this,void 0,Promise,function(){return $(this,function(c){switch(c.label){case 0:return typeof((l=navigator.storage)===null||l===void 0?void 0:l.getDirectory)!="function"?[3,2]:[4,a()];case 1:return c.sent(),[3,3];case 2:navigator.maxTouchPoints!==void 0?(function(){var f=String(Math.random());try{var g=indexedDB.open(f,1);g.onupgradeneeded=function(u){var m=u.target.result,v=function(E){o(E)};try{m.createObjectStore("t",{autoIncrement:!0}).put(new Blob),v(!1)}catch(E){(E instanceof Error&&typeof E.message=="string"?E.message:String(E)).includes("are not yet supported")?v(!0):v(!1)}finally{m.close(),indexedDB.deleteDatabase(f)}},g.onerror=function(){return o(!1)}}catch{o(!1)}})():(function(){var f=window.openDatabase,g=window.localStorage;try{f(null,null,null,null)}catch{return void o(!0)}try{g.setItem("test","1"),g.removeItem("test")}catch{return void o(!0)}o(!1)})(),c.label=3;case 3:return[2]}})})}function d(){var l;return V(this,void 0,Promise,function(){var c,f,g;return $(this,function(u){switch(u.label){case 0:if(typeof((l=navigator.storage)===null||l===void 0?void 0:l.getDirectory)!="function")return[3,5];u.label=1;case 1:return u.trys.push([1,3,,4]),[4,navigator.storage.getDirectory()];case 2:return u.sent(),o(!1),[3,4];case 3:return c=u.sent(),f=c instanceof Error&&typeof c.message=="string"?c.message:String(c),o(f.includes("Security error")),[2];case 4:return[3,6];case 5:(g=indexedDB.open("inPrivate")).onerror=function(m){if(g.error&&g.error.name==="InvalidStateError")return m.preventDefault(),void o(!0);o(!1)},g.onsuccess=function(){indexedDB.deleteDatabase("inPrivate"),o(!1)},u.label=6;case 6:return[2]}})})}(function(){return V(this,void 0,Promise,function(){return $(this,function(l){switch(l.label){case 0:return s()!==44&&s()!==43?[3,2]:(r="Safari",[4,p()]);case 1:return l.sent(),[3,6];case 2:return s()!==51?[3,3]:(c=navigator.userAgent,r=c.match(/Chrome/)?navigator.brave!==void 0?"Brave":c.match(/Edg/)?"Edge":c.match(/OPR/)?"Opera":"Chrome":"Chromium",(function(){var f=this,g="__di_"+Math.random().toString(36).slice(2),u=new Uint8Array(16384),m=indexedDB.open(g,1);m.onupgradeneeded=function(){m.result.createObjectStore("s")},m.onerror=function(){indexedDB.deleteDatabase(g),o(!1)},m.onsuccess=function(){var v=m.result,E=!1;try{var C=v.transaction("s","readwrite",{durability:"strict"});E=C.durability==="strict",C.abort()}catch{}if(!E)return v.close(),indexedDB.deleteDatabase(g),void o(!1);var y=function(Z){return new Promise(function(_,ee){var te=performance.now(),U=0,x=function(){if(U!==15){var D=v.transaction("s","readwrite",{durability:Z});D.objectStore("s").put(u,U),U++,D.oncomplete=x,D.onerror=D.onabort=function(){return ee(D.error)}}else _(performance.now()-te)};x()})};V(f,void 0,void 0,function(){var Z,_,ee,te,U;return $(this,function(x){switch(x.label){case 0:return Z=performance.now(),[4,y("relaxed")];case 1:return x.sent(),[4,y("strict")];case 2:x.sent(),_=[],ee=0,x.label=3;case 3:return ee<15?[4,y("relaxed")]:[3,7];case 4:return te=x.sent(),[4,y("strict")];case 5:if(U=x.sent(),_.push(te>0?U/te:1/0),_.length>=7&&performance.now()-Z>=1e3)return[3,7];x.label=6;case 6:return ee++,[3,3];case 7:return _.sort(function(D,wi){return D-wi}),v.close(),indexedDB.deleteDatabase(g),o(_[_.length>>1]<1.3),[2]}})}).catch(function(){v.close(),indexedDB.deleteDatabase(g),o(!1)})}})(),[3,6]);case 3:return s()!==25?[3,5]:(r="Firefox",[4,d()]);case 4:return l.sent(),[3,6];case 5:navigator.msSaveBlob!==void 0?(r="Internet Explorer",o(window.indexedDB===void 0)):t(new Error("detectIncognito cannot determine the browser")),l.label=6;case 6:return[2]}var c})})})().catch(t)})];case 1:return[2,i.sent()]}})})}var Vi=ur,fr=mt.A,gs=mt.k;async function hr(i){return(await fr()).isPrivate}var $i=300,ne=6e3,gr="cbo_pm",Gi=10080*60*1e3,mr="detectincognitojs@1.9.0",yr={timing:!1},yt="cbo_tab_id",vr={bluetoothAvailable:"bt",clientCapabilities:"cc",userVerifyingPlatformAuthenticatorAvailable:"uvpaa",conditionalMediationAvailable:"cm",javaScriptHighEntropy:"he",privateMode:"pm",webdriver:"wd",maxTouchPoints:"mtp"};function L(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Sr(i,e,t){return{field:i,source:e,error:{name:"TimeoutError",message:`Device info collection timed out after ${t}ms`}}}async function vt(i,e){let t;try{return await Promise.race([i.then(()=>!0,()=>!0),new Promise(r=>{t=setTimeout(()=>r(!1),Math.max(0,e))})])}finally{t&&clearTimeout(t)}}var Ee=class{constructor(e,t,r="localstorage",n,o=()=>yr,s,a=!0,p){this.logger=e;this.storage=t;this.storageSource=r;this.sessionStorage=n;this.settings=o;this.emitTelemetry=s;this.privateModeEnabled=a;this.deviceHandleMaxAgeMs=p}pagePrivateMode;privateModeDetectionStarted=!1;lastKnown={};async collect(e,t={}){try{let r=this.resolveSettings(),n=L(),o=this.getClientEnvHandle(),s={type:"web",clientEnvHandle:o.value,clientEnvHandleMeta:{timestamp:o.timestamp,source:o.source},tabId:this.getTabId()},a=typeof __CBO_DATA_PRIVATE_MODE__=="boolean"?__CBO_DATA_PRIVATE_MODE__:this.privateModeEnabled,p=a?this.knownPrivateMode(r.timing):void 0,d,l=a&&p===void 0&&!this.privateModeDetectionStarted?this.detectPrivateMode(r.timing).then(y=>{d=y}):void 0,c=this.startFastFields();await vt(Promise.all(c.map(y=>y.promise)),$i);let f=L()-n,g=t.refresh?this.lastKnown:{};r.timing&&this.reportFastTiming(f,c);let u=()=>d?.error?[d.error]:[];this.safePublish(e,this.buildInfo(s,c,d?d.value:p,g,u()),"fast");let m=c.filter(y=>!y.settled),v=l!==void 0&&d===void 0;if(m.length===0&&!v)return;let E=L();await Promise.all([vt(Promise.all(m.map(y=>y.promise)),ne-(E-n)),l]);let C=m.filter(y=>!y.settled).map(y=>Sr(y.field,y.source,ne));C.push(...u()),r.timing&&m.length>0&&this.reportLateTiming(L()-n,m),this.safePublish(e,this.buildInfo(s,c,d?d.value:p,g,C),"update")}catch(r){this.logger.error("Failed to collect device info",r)}}async getInfo(){let e;return await this.collect(t=>{e=t}),e??{}}startFastFields(){return[this.startField("bluetoothAvailable","navigator.bluetooth.getAvailability",()=>Xt(0)),this.startField("clientCapabilities","PublicKeyCredential.getClientCapabilities",()=>tr(0)),this.startField("userVerifyingPlatformAuthenticatorAvailable","PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable",()=>Zt(0)),this.startField("conditionalMediationAvailable","PublicKeyCredential.isConditionalMediationAvailable",()=>er(0)),this.startField("javaScriptHighEntropy","navigator.userAgentData.getHighEntropyValues",()=>rr(0)),this.startField("webdriver","navigator.webdriver",()=>ir(0)),this.startField("maxTouchPoints","navigator.maxTouchPoints",()=>nr(0))]}startField(e,t,r){let n=L(),o={field:e,source:t};return o.promise=Promise.resolve().then(r).then(s=>({field:e,value:s,durationMs:L()-n}),s=>(this.logger.error(`Failed to collect device info field "${e}"`,s),{field:e,durationMs:L()-n,error:{field:e,source:t,error:N(s)??{message:"Unknown error"}}})).then(s=>(o.settled=s,s)),o}buildInfo(e,t,r,n,o){let s={},a=[];for(let d of t)d.settled?(d.settled.error&&a.push(d.settled.error),s[d.field]=d.settled.value,this.remember(d.field,d.settled.value)):s[d.field]=n[d.field];s.privateMode=r,a.push(...o);let p={...e,data:{bluetoothAvailable:s.bluetoothAvailable,javaScriptHighEntropy:s.javaScriptHighEntropy,privateMode:s.privateMode,webdriver:s.webdriver,conditionalMediationAvailable:s.conditionalMediationAvailable,userVerifyingPlatformAuthenticatorAvailable:s.userVerifyingPlatformAuthenticatorAvailable,clientCapabilities:s.clientCapabilities,maxTouchPoints:s.maxTouchPoints}};return a.length>0&&(p.collectionErrors=a),p}remember(e,t){t!==void 0&&(this.lastKnown[e]=t)}safePublish(e,t,r){try{e(t,r)}catch(n){this.logger.error("Failed to publish device info",n)}}knownPrivateMode(e){if(this.pagePrivateMode!==void 0)return this.pagePrivateMode;let t=this.readPrivateModeCache();return t&&(this.pagePrivateMode=t.value,e&&this.reportTelemetry(`device info privateMode from cache, age ${Math.round((Date.now()-t.ts)/1e3)}s`)),this.pagePrivateMode}canCachePrivateMode(){return this.storageSource==="localstorage"}readPrivateModeCache(){if(this.canCachePrivateMode())try{let e=this.storage.getItem(gr);if(!e||typeof e!="object"||typeof e.value!="boolean"||typeof e.ts!="number"||e.dv!==mr)return;let t=Date.now()-e.ts;return t<0||t>=Gi?void 0:e}catch(e){this.logger.debug("Failed to read cached privateMode",e);return}}writePrivateModeCache(e){if(this.canCachePrivateMode())try{this.storage.setItem(gr,{value:e,ts:Date.now(),dv:mr})}catch(t){this.logger.error("Failed to cache privateMode",t)}}async detectPrivateMode(e){this.privateModeDetectionStarted=!0;let t="detectIncognito",r=L(),n=this.startField("privateMode",t,()=>typeof __CBO_DATA_PRIVATE_MODE__=="boolean"&&!__CBO_DATA_PRIVATE_MODE__?void 0:hr(0));if(!await vt(n.promise,ne)||!n.settled)return e&&this.reportTelemetry(`device info privateMode timed out after ${ne}ms`),{error:Sr("privateMode",t,ne)};if(e&&this.reportTelemetry(`device info privateMode detected in ${Math.round(L()-r)}ms`),n.settled.error)return{error:n.settled.error};let s=n.settled.value;return typeof s!="boolean"?{value:void 0}:(this.pagePrivateMode=s,this.writePrivateModeCache(s),{value:s})}resolveSettings(){try{return{timing:this.settings()?.timing===!0}}catch(e){return this.logger.error("Failed to resolve device info collector settings",e),yr}}reportFastTiming(e,t){let r=t.map(n=>`${vr[n.field]}=${Math.round(n.settled?.durationMs??e)}`).join(",");this.reportTelemetry(`device info collected in ${Math.round(e)}ms (${r})`)}reportLateTiming(e,t){let r=t.map(n=>`${vr[n.field]}=${n.settled?Math.round(n.settled.durationMs):"timeout"}`).join(",");this.reportTelemetry(`device info late fields done in ${Math.round(e)}ms (${r})`)}reportTelemetry(e){if(this.emitTelemetry)try{this.emitTelemetry("info",e)}catch(t){this.logger.error("Failed to report device info timing",t)}}getClientEnvHandle(){let e=this.storage.getItem("cbo_client_env_handle"),t=this.deviceHandleMaxAgeMs;if(e&&!(t!==void 0&&!(Date.now()-e.timestamp<=t)))return e;let r=S(),n={timestamp:Date.now(),source:this.storageSource,value:r};return this.storage.setItem("cbo_client_env_handle",n),n}getTabId(){if(!this.sessionStorage)return;let e=this.sessionStorage.getItem(yt);if(e)return e;let t=S();if(this.sessionStorage.setItem(yt,t),this.sessionStorage.getItem(yt)===t)return t}};function ji(){return typeof document<"u"&&K(0)}var Ce=class{constructor(e,t,r,n,o,s){this.logger=e;this.source=t;this.refreshInterval=r;this.attachInterval=n;this.diagnostics=o;this.onUndelivered=s}snapshot;snapshotPhase;publishedAt=0;version=0;deliveredVersion=0;refreshedAt=0;lastAttachedAt=null;eventsSeen=!1;refreshPromise;timer;destroyed=!1;start(){this.refresh()}getForEvent(){if(this.eventsSeen=!0,Date.now()-this.refreshedAt>=this.refreshInterval&&this.refresh(),!!this.snapshot){if(this.version!==this.deliveredVersion)return this.markDelivered("event");if(!(this.lastAttachedAt!==null&&Date.now()-this.lastAttachedAt<this.attachInterval))return this.lastAttachedAt=Date.now(),this.snapshot}}hasUndelivered(){return this.snapshot!==void 0&&this.version!==this.deliveredVersion}takeUndelivered(){if(this.hasUndelivered())return this.markDelivered("flush")}hasStandalone(){return this.eventsSeen&&this.hasUndelivered()}takeStandalone(){if(this.hasStandalone())return this.markDelivered("request")}destroy(){this.destroyed=!0,this.timer&&(clearTimeout(this.timer),this.timer=void 0)}markDelivered(e){return this.deliveredVersion=this.version,this.lastAttachedAt=Date.now(),this.snapshotPhase==="update"&&this.report(`device info update delivered via ${e} after ${Math.max(0,Date.now()-this.publishedAt)}ms`),this.snapshot}publish(e,t){if(t==="fast"&&(this.refreshedAt=Date.now()),!(this.snapshot&&JSON.stringify(this.snapshot)===JSON.stringify(e))&&(this.snapshot=e,this.snapshotPhase=t,this.publishedAt=Date.now(),this.version++,this.eventsSeen&&this.onUndelivered))try{this.onUndelivered()}catch(r){this.logger.error("Failed to announce undelivered device info",r)}}report(e){if(this.diagnostics)try{this.diagnostics.timing()&&this.diagnostics.emit("info",e)}catch(t){this.logger.error("Failed to report device info delivery",t)}}scheduleRefresh(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.refresh()},this.refreshInterval)}refresh(){if(this.refreshPromise)return this.refreshPromise;if(this.timer&&(clearTimeout(this.timer),this.timer=void 0),this.snapshot&&ji())return this.destroyed||this.scheduleRefresh(),Promise.resolve();let e=this.snapshot!==void 0;return this.refreshPromise=Promise.resolve().then(()=>this.source.collect((t,r)=>this.publish(t,r),{refresh:e})).catch(t=>this.logger.error("Failed to refresh device info",t)).finally(()=>{this.refreshPromise=void 0,this.destroyed||this.scheduleRefresh()}),this.refreshPromise}};function br(i){return{getItem:e=>localStorage.getItem(e),setItem:(e,t)=>localStorage.setItem(e,t),removeItem:e=>localStorage.removeItem(e)}}function Tr(i){return{getItem:e=>sessionStorage.getItem(e),setItem:(e,t)=>sessionStorage.setItem(e,t),removeItem:e=>sessionStorage.removeItem(e)}}function oe(i){return{read:()=>document.cookie,write:e=>{document.cookie=e}}}function R(i,e){return`${i}_${e}`}var ke=class{constructor(e,t){this.engine=e;this.namespace=t}getItem(e){return this.engine.getItem(R(e,this.namespace))}setItem(e,t){this.engine.setItem(R(e,this.namespace),t)}removeItem(e){this.engine.removeItem(R(e,this.namespace))}},Oe=class{constructor(e){this.logger=e}area=br(0);getItem(e){try{if(typeof localStorage>"u")return null;let t=this.area.getItem(e);return t?JSON.parse(t):null}catch(t){return this.logger.error(`LocalStorage.getItem failed for key "${e}"`,t),null}}setItem(e,t){try{if(typeof localStorage>"u")return;this.area.setItem(e,JSON.stringify(t))}catch(r){this.logger.error(`LocalStorage.setItem failed for key "${e}"`,r),this.logger.reportTelemetry?.("error",`localStorage.setItem failed: ${e}`)}}removeItem(e){try{if(typeof localStorage>"u")return;this.area.removeItem(e)}catch(t){this.logger.error(`LocalStorage.removeItem failed for key "${e}"`,t)}}},Ie=class{constructor(e,t){this.logger=e;this.domain=t}jar=oe(0);getItem(e){try{if(typeof document>"u")return null;let t=e+"=",r=this.jar.read().split(";");for(let n=0;n<r.length;n++){let o=r[n].trim();if(o.indexOf(t)===0){let s=o.substring(t.length);return JSON.parse(decodeURIComponent(s))}}return null}catch(t){return this.logger.error(`CookieStorage.getItem failed for key "${e}"`,t),null}}setItem(e,t){try{if(typeof document>"u")return;let r=`${e}=${encodeURIComponent(JSON.stringify(t))}; path=/; SameSite=Lax`;this.domain&&(r+=`; domain=${this.domain}`),this.jar.write(r)}catch(r){this.logger.error(`CookieStorage.setItem failed for key "${e}"`,r),this.logger.reportTelemetry?.("error",`cookie.setItem failed: ${e}`)}}removeItem(e){try{if(typeof document>"u")return;let t=`${e}=; Max-Age=-99999999; path=/`;this.domain&&(t+=`; domain=${this.domain}`),this.jar.write(t)}catch(t){this.logger.error(`CookieStorage.removeItem failed for key "${e}"`,t)}}},xe=class{constructor(e){this.logger=e}area=Tr(0);getItem(e){try{if(typeof sessionStorage>"u")return null;let t=this.area.getItem(e);return t?JSON.parse(t):null}catch(t){return this.logger.error(`SessionStorage.getItem failed for key "${e}"`,t),null}}setItem(e,t){try{if(typeof sessionStorage>"u")return;this.area.setItem(e,JSON.stringify(t))}catch(r){this.logger.error(`SessionStorage.setItem failed for key "${e}"`,r),this.logger.reportTelemetry?.("error",`sessionStorage.setItem failed: ${e}`)}}removeItem(e){try{if(typeof sessionStorage>"u")return;this.area.removeItem(e)}catch(t){this.logger.error(`SessionStorage.removeItem failed for key "${e}"`,t)}}};var Pe=1,Fe="cbo_storage_schema",Qi=["cbo_seq","cbo_sdk_config","cbo_experiments","cbo_client_env_handle","cbo_outbox","cbo_visibility_change_debug","cbo_pagehide_debug","cbo_session"],zi=["cbo_session_id","cbo_tab_id"],Yi=["cbo_client_env_handle"];function Le(i,e,t){return i.setItem(e,t),JSON.stringify(i.getItem(e))===JSON.stringify(t)}function St(i,e,t){let r=i.getItem(Fe);if(r!==null){if(r.version!==Pe||r.projectId!==e)return!1;if(r.complete===!0)return!0;if(r.complete!==!1)return!1}else{if(t.some(n=>i.getItem(R(n,e))!==null))return Le(i,Fe,{version:Pe,projectId:e,complete:!0});if(!Le(i,Fe,{version:Pe,projectId:e,complete:!1}))return!1}for(let n of t){let o=R(n,e);if(i.getItem(o)!==null)continue;let s=i.getItem(n);if(s!==null&&!Le(i,o,s))return!1}return Le(i,Fe,{version:Pe,projectId:e,complete:!0})}function wr(i,e,t,r,n){try{if(!St(e,i,Qi))return;St(t,i,zi),r&&St(r,i,Yi)}catch(o){n.error("Failed to migrate legacy Observe storage",o)}}var Ji=10*1e3,Xi=60*1e3,Zi=3600*1e3,en=300*1e3,Er=1440*60*1e3,tn=[1e3,3e3];function rn(i){let e=/(?:^|[\s,])max-age\s*=\s*"?(\d+)"?/i.exec(i?.get("Cache-Control")??"");if(!e)return Zi;let t=Number(i?.get("Age")??0),r=(Number(e[1])-(Number.isFinite(t)&&t>0?t:0))*1e3;return Math.min(Math.max(r,en),Er)}var Re=class{constructor(e,t,r){this.url=e;this.storage=t;this.logger=r;this.initialConfig=qt(t)??void 0,this.appliedVersion=this.initialConfig?.version}initialConfig;requestTimer;retryTimer;controller;removers=[];fetching=!1;stopped=!1;lastAttemptAt;appliedVersion;onConfig;start(e){this.stopped||this.onConfig||(this.onConfig=e,this.listen(),this.refresh())}listen(){if(typeof window>"u")return;let e=()=>{typeof document>"u"||K(0)||this.refresh()};this.removers.push(O(0,"visibilitychange",e),O(0,"pageshow",t=>{t.persisted&&this.refresh()}))}refresh(){try{if(this.stopped||this.fetching)return;let e=Date.now(),t=ye(this.storage),{fetchedAt:r,expiresAt:n}=t??{};if(t?.endpoint===this.url&&typeof r=="number"&&typeof n=="number"&&r>0&&n-r<=Er&&r<=e&&e<n){t.config.version!==this.appliedVersion&&(this.appliedVersion=t.config.version,this.onConfig?.(t.config));return}let o=this.lastAttemptAt===void 0?1/0:e-this.lastAttemptAt;if(o>=0&&o<Xi)return;this.lastAttemptAt=e,clearTimeout(this.retryTimer),this.fetchConfig()}catch(e){this.logger.error("Unexpected error in SDK config refresh",e)}}async fetchConfig(e=0){if(this.stopped||this.fetching)return;this.fetching=!0;let t=typeof AbortController<"u"?new AbortController:void 0;this.controller=t,this.requestTimer=t?setTimeout(()=>t.abort(),Ji):void 0;let r=!0;try{let n=await Se(0,this.url,{method:"GET",cache:"no-cache",...t?{signal:t.signal}:{}});if(!n.ok)throw r=(n.status===408||n.status===429||n.status>=500)&&!n.headers.has("Retry-After"),new Error(`SDK config request failed (${n.status})`);let o=await n.json();r=!1;let s=q(o);if(!s)throw new Error("Invalid SDK config response");if(this.stopped||t?.signal.aborted)return;let a=Date.now();Kt(this.storage,{endpoint:this.url,fetchedAt:a,expiresAt:a+rn(n.headers),config:s}),ye(this.storage)&&this.storage.removeItem(ct),this.appliedVersion=s.version,this.onConfig?.(s)}catch(n){if(!this.stopped){this.logger.error("Failed to fetch SDK config",n);let o=tn[e];(r&&!(n instanceof SyntaxError)||t?.signal.aborted)&&o!==void 0&&(this.retryTimer=setTimeout(()=>{this.fetchConfig(e+1)},o))}}finally{clearTimeout(this.requestTimer),this.requestTimer=void 0,this.controller=void 0,this.fetching=!1}}destroy(){this.stopped=!0,this.removers.splice(0).forEach(e=>e()),clearTimeout(this.requestTimer),clearTimeout(this.retryTimer),this.controller?.abort(),this.onConfig=void 0}};var nn=["ahrefsbot","ahrefssiteaudit","amazonbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","facebookexternal","petalbot","pinterest","screaming frog","yahoo! slurp","yandex","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google"];function Cr(i){if(!i)return!1;let e=i.toLowerCase();return nn.some(t=>e.includes(t))}var kr="@corbado/observe",Or="1.15.2";function Ir(i){let e=i.debug,t,r=(n,o)=>`[Corbado Observe SDK ${n}] ${o}`;return{reportTelemetry(n,o){if(t)try{t(n,o)}catch{}},setTelemetrySink(n){t=n},debug(n,...o){e&&console.log(r("DEBUG",n),...o)},info(n,...o){e&&console.log(r("INFO",n),...o)},warn(n,...o){e&&console.warn(r("WARN",n),...o)},error(n,...o){e&&console.error(r("ERROR",n),...o)},critical(n,...o){console.error(r("CRITICAL",n),...o)}}}var on="/inline/injected/webauthn-listeners.js",xr=/\/dashlane-(?:shadow-dom|top-layer)-page-script\.js/,sn=/-extension:\/\/[^/]+\/content-scripts\/passkey_proxy\/index\.js$/,an=/\bPromise\.all\s*\(\s*\[[\s\S]*?\.getIsPasskeyAvailable\s*\(/,ln=/-extension:\/\/[^/]+\/content_scripts\/shadow-dom\/shadowAttachNotifier\.js:/,Pr=/-extension:\/\/[^/]+\/js\/nordpass-script\.js:/,dn=/-extension:\/\/[^/]+\/js\/passkeys\.js:/,pn=/["'`](?:keeper:shadow-root-attached|webauthn-(?:get|create)-request)["'`]/,cn=/Intercept cancelled for `(?:get|create)`|["'`](?:conditionalMediationAvailable|verifyingPlatformAuthenticatorAvailable)["'`]/,bt=()=>Object.keys(window._sentryDebugIds??{}),Tt=i=>{try{i()}catch(e){return String(e?.stack??"")}return""},Fr=()=>Tt(()=>Element.prototype.attachShadow.call(null,{mode:"open"})),un=()=>{let i=Object.getOwnPropertyDescriptor(navigator.credentials??{},"get");if(!i?.get||!i.set||i.configurable)return!1;let e=()=>{},t=i.get.call({_get:e});return t===e||typeof t=="function"&&t===i.get.call({})&&!Function.prototype.toString.call(t).includes("[native code]")},wt=(...i)=>{let e=navigator.credentials;return e?i.map(t=>Object.getOwnPropertyDescriptor(e,t)?.value):[]},fn=()=>[navigator.credentials?.get,...wt("get","_get")].some(i=>typeof i=="function"&&i.name==="getWebAuthnCredential"),hn=()=>{let i=document.documentElement,e=document.adoptedStyleSheets;if(!i||typeof i.getAnimations!="function"||typeof e?.push!="function"||i.getAnimations().length>0)return!1;let t=new CSSStyleSheet;t.replaceSync(":where(:root){animation:bitwardenfill 1s 1000s paused}"),e.push(t);try{let r=i.getAnimations().filter(n=>n.animationName==="bitwardenfill");return r.forEach(n=>n.cancel()),r.length>0}finally{let r=e.indexOf(t);r>=0&&e.splice(r,1)}},gn,mn=()=>gn??=hn(),yn=()=>{let i=typeof PublicKeyCredential>"u"?void 0:PublicKeyCredential;if(typeof i!="function"||!Object.prototype.hasOwnProperty.call(i,Symbol.hasInstance))return!1;let e=i[Symbol.hasInstance]({});return e instanceof Promise?(e.catch(()=>{}),!0):!1},vn=()=>{let i={get nodeType(){throw new Error("probe")}};return Tt(()=>MutationObserver.prototype.observe.call(null,i))},Sn=()=>{let i=new Error("probe"),e=[],t={get nodeType(){return e.push("nodeType"),1},get ownerDocument(){throw e.push("ownerDocument"),i}};try{MutationObserver.prototype.observe.call(null,t)}catch(r){return r===i&&e.join()==="nodeType,ownerDocument"}return!1},bn=()=>[Element.prototype.attachShadow,navigator.credentials?.get,navigator.credentials?.create,...wt("get","_get","create")].some(e=>typeof e=="function"&&pn.test(Function.prototype.toString.call(e))),Tn=()=>{let i=typeof PublicKeyCredential>"u"?void 0:PublicKeyCredential;return[i?.isUserVerifyingPlatformAuthenticatorAvailable,i?._isUserVerifyingPlatformAuthenticatorAvailable].some(t=>typeof t=="function"&&an.test(Function.prototype.toString.call(t)))},wn=()=>{let i=document;for(;i;){if(i.querySelector("[data-lastpass-icon-root], [data-lastpass-root]"))return!0;i=i.activeElement?.shadowRoot}return!1},En=()=>{let i=typeof PublicKeyCredential>"u"?void 0:PublicKeyCredential;return[navigator.credentials?.get,...wt("get","_get"),i?.isConditionalMediationAvailable,i?._isConditionalMediationAvailable,i?.isUserVerifyingPlatformAuthenticatorAvailable,i?._isUserVerifyingPlatformAuthenticatorAvailable].some(t=>typeof t=="function"&&cn.test(Function.prototype.toString.call(t)))},Cn=[{name:"1password",signal:"in-field button",signedIn:!0,test:()=>document.querySelector("com-1password-button")!==null},{name:"1password",signal:"credentials.get accessor",test:un},{name:"1password",signal:"Sentry debug id",test:()=>bt().some(i=>i.includes(on))},{name:"bitwarden",signal:"passkey override",signedIn:!0,test:fn},{name:"bitwarden",signal:"autofill keyframes",test:mn},{name:"dashlane",signal:"injected script tag",test:()=>document.querySelector('script[src*="-extension://"][src*="/dashlane-"][src$="-page-script.js"]')!==null},{name:"dashlane",signal:"PublicKeyCredential hasInstance trap",test:yn},{name:"dashlane",signal:"page script stack",test:()=>xr.test(Fr())||typeof HTMLDialogElement<"u"&&xr.test(Tt(()=>HTMLDialogElement.prototype.showModal.call(null)))},{name:"kaspersky",signal:"passkey proxy flag",test:()=>window.wasKPMKeyPassProxyInited===!0},{name:"kaspersky",signal:"injected script tag",test:()=>sn.test(document.querySelector('script[src*="/content-scripts/passkey_proxy/"]')?.src??"")},{name:"kaspersky",signal:"WebAuthn override source",test:Tn},{name:"keeper",signal:"attachShadow stack",test:()=>ln.test(Fr())},{name:"keeper",signal:"override source",test:bn},{name:"keeper",signal:"field lock",test:()=>document.querySelector("[data-keeper-lock-id]")!==null},{name:"lastpass",signal:"passkey override",signedIn:!0,test:()=>typeof window.__nativeCredentialsGet=="function"},{name:"lastpass",signal:"icon root",test:wn},{name:"nordpass",signal:"observer proxy stack",test:()=>Pr.test(vn())},{name:"nordpass",signal:"observer read order",test:Sn},{name:"nordpass",signal:"passkeys Sentry debug id",test:()=>bt().some(i=>dn.test(i))},{name:"nordpass",signal:"Sentry debug id",test:()=>bt().some(i=>Pr.test(i))},{name:"protonpass",signal:"WebAuthn override source",test:En},{name:"protonpass",signal:"field icon",test:()=>document.querySelector("[data-protonpass-role]")!==null}];function kn(){return typeof window>"u"||typeof document>"u"?[]:Cn.map(({name:i,signal:e,signedIn:t,test:r})=>{try{return{name:i,signal:e,signedIn:t,matched:r()}}catch(n){return{name:i,signal:e,signedIn:t,matched:!1,error:n}}})}function On(){let i=new Map;for(let{name:e,signedIn:t,matched:r}of kn()){if(!r)continue;let n=i.get(e)??{name:e};t&&(n.signedIn=!0),i.set(e,n)}return[...i.values()]}function Lr(i){return On()}var Rr=3e3,In=500,xn=6,Pn=1e3,_e=class{constructor(e,t,r){this.logger=e;this.isEnabled=t;if(typeof window>"u"||typeof document>"u")return;if(this.sample(),Qt(0))this.sampleAfter(Rr);else{let o=()=>{this.sampleWhenIdle(),this.sampleAfter(Rr)};this.removers.push(O(0,"load",o,{once:!0}))}let n=r.onInputFocus(o=>{!this.isEnabled()||this.sampledFields.has(o)||(this.sampledFields.add(o),++this.focusSamples>=xn&&n(),this.sampleAfter(In))});this.removers.push(n)}detected=new Map;timers=new Set;idleCallbacks=new Set;sampledFields=new WeakSet;focusSamples=0;removers=[];destroyed=!1;reportedCounts=new Map;getDetected(){return[...this.detected.values()]}takeReport(e){if(!(!this.isEnabled()||this.detected.size<=(this.reportedCounts.get(e)??0)))return this.reportedCounts.set(e,this.detected.size),this.getDetected().map(({name:t})=>({name:t}))}destroy(){this.destroyed=!0;for(let e of this.removers)e();for(let e of this.timers)clearTimeout(e);this.timers.clear();for(let e of this.idleCallbacks)cancelIdleCallback(e);this.idleCallbacks.clear()}sampleAfter(e){let t=setTimeout(()=>{this.timers.delete(t),this.sampleWhenIdle()},e);this.timers.add(t)}sampleWhenIdle(){if(typeof requestIdleCallback!="function"){this.sample();return}let e=requestIdleCallback(()=>{this.idleCallbacks.delete(e),this.sample()},{timeout:Pn});this.idleCallbacks.add(e)}sample(){if(!(this.destroyed||!this.isEnabled()))try{let e=Lr(0);for(let t of e){let r=this.detected.get(t.name);(!r||t.signedIn&&!r.signedIn)&&this.detected.set(t.name,t)}}catch(e){this.logger.error("Failed to detect password manager extensions",e)}}};var se="cbo_session_id",G="cbo_session",I="cbo_seq",Et=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var Ct={name:kr,version:Or},Fn=/^[0-9A-Za-z.+_-]{1,32}$/;function Ln(i,e){return i===void 0?Ct:typeof i=="string"&&Fn.test(i)?{...Ct,integrationVersion:i}:(e.debug("Ignoring invalid integrationVersion (expected <= 32 chars of [0-9A-Za-z.+_-])"),Ct)}var _r="cbo_experiments",Ar="cbo_data_policy",Rn=255,_n=/^[A-Za-z0-9_-]+$/,An=128,Dn=256,Dr=1e3,Mn=50,Hn="cbo_seq",Mr=1e3,Ae=class i{constructor(e,t=[]){this.options=e;this.options.debug=e.debug??!1,this.logger=e.logger??Ir({debug:this.options.debug});let r=t.concat(Array.isArray(e.plugins)?e.plugins:[]),n=new Oe(this.logger),o=new xe(this.logger),s;this.eachPlugin(r,u=>{u.storage&&(s=u.storage(this.logger)||s)}),wr(e.projectId,n,o,s?.engine,this.logger);let a=e.projectId,p=u=>new ke(u,a);if(this.seqLockName=R(Hn,a),this.sessionStorage=p(o),this.persistentStorage=p(n),this.storage=p(s?.engine??n),this.configOverrides={...e.sdkConfig,...e.sdkConfig?.retry&&{retry:{...e.sdkConfig.retry}},...e.sdkConfig?.flushOnFlowTypeFinished&&{flushOnFlowTypeFinished:[...e.sdkConfig.flushOnFlowTypeFinished]},...e.sdkConfig?.sourcePathQueryAllow&&{sourcePathQueryAllow:[...e.sdkConfig.sourcePathQueryAllow]}},this.fixedData=me(e.fixedDataConfig),this.fixedData&&(this.configOverrides.pmd=this.fixedData.pmd),typeof __CBO_SDK_CONFIG__=="string"){let u=Nt(__CBO_SDK_CONFIG__,this.fixedData?.pmd);this.config=u.config,u.valid||this.logger.error("Invalid static SDK config: running the built-in defaults")}else{let u=Object.keys(b).every(v=>this.configOverrides[v]!==void 0)&&Object.keys(b.retry).every(v=>this.configOverrides.retry?.[v]!==void 0);u||(this.configManager=new Re(e.apiBaseUrl+(e.apiConfigPath??"/v1/observe/config")+"/"+e.projectId,this.persistentStorage,this.logger));let m=this.configManager?.initialConfig;this.config=ge(m,this.configOverrides),!u&&!m&&e.flushInterval!=null&&this.configOverrides.flushIntervalMs===void 0&&(this.config={...this.config,flushIntervalMs:e.flushInterval}),!u&&!m&&e.deviceInfoCollectorTimeout!=null&&this.configOverrides.deviceInfoCollectorTimeoutMs===void 0&&(this.config={...this.config,deviceInfoCollectorTimeoutMs:e.deviceInfoCollectorTimeout})}e.apiBaseUrl!==""&&(/^https?:\/\//.test(e.apiBaseUrl)||(this.logger.critical(`Invalid apiBaseUrl: URL must start with http:// or https:// (got: "${e.apiBaseUrl}")`),this.reportTelemetry("error","invalid apiBaseUrl: missing http(s) scheme")),e.apiBaseUrl.endsWith("/")&&(this.logger.critical(`Invalid apiBaseUrl: URL must not have a trailing slash (got: "${e.apiBaseUrl}")`),this.reportTelemetry("error","invalid apiBaseUrl: trailing slash")));let d=e.apiBaseUrl+(e.apiEventPath??"/v1/observe/events")+"/"+e.projectId;this.logger.debug(`Using API endpoint: ${d}`);let l=new be({logger:this.logger,url:d});this.eachPlugin(r,u=>{u.session&&(this.bridge=u.session(this)||this.bridge),u.rawErrors&&(this.rawErrors=u.rawErrors),typeof u.sourcePath=="function"&&(this.fixedSourcePath=u.sourcePath),u.eventTime&&(this.eventClock=u.eventTime),u.deviceHandleMaxAgeMs!==void 0&&(this.deviceHandleMaxAgeMs=u.deviceHandleMaxAgeMs)}),e.fixedDataConfig?.crossOriginSession&&!this.bridge&&this.logger.warn("fixedDataConfig.crossOriginSession is ignored without the crossOriginSession() plugin"),this.sessionId=this.resolveSession(),this.queue=new we(this.logger,l,this.sessionId,Ln(this.options.integrationVersion,this.logger),{debug:this.options.debug,config:this.config,requestConfig:!1,outboxLockName:R(ft,a),getDataPolicy:()=>this.dataPolicy,getCrossOriginSession:u=>this.bridge?.meta(u),fixedData:this.fixedData!==void 0||typeof __CBO_DATA_PMD__=="boolean"||typeof __CBO_DATA_PRIVATE_MODE__=="boolean",beforeEventBatchSend:u=>this.attachUndeliveredDeviceInfo(u),standaloneDeviceInfo:{has:()=>this.deviceInfoManager?.hasStandalone()??!1,take:()=>this.deviceInfoManager?.takeStandalone()}},this.persistentStorage),this.telemetryReady=!0,this.logger.setTelemetrySink?.((u,m)=>this.reportTelemetry(u,m));try{this.getWindowObserver()}catch(u){this.logger.error("Failed to attach page low-event observer",u)}if(typeof __CBO_DATA_PMD__=="boolean"?__CBO_DATA_PMD__:this.fixedData?.pmd!==!1)try{this.passwordManagerSampler=this.isTrackingBlocked()?void 0:new _e(this.logger,()=>typeof __CBO_DATA_PMD__=="boolean"?__CBO_DATA_PMD__:this.config.pmd,this.getWindowObserver())}catch(u){this.logger.error("Failed to start password manager detection",u)}let c=this.pendingSelfTelemetry;this.pendingSelfTelemetry=[];for(let u of c)this.telemetry(u.level,u.message);let f=new Ee(this.logger,this.storage,s?.source??"localstorage",this.sessionStorage,()=>({timing:this.config.deviceInfoTiming}),(u,m)=>this.telemetry(u,m),this.fixedData?.privateMode??!0,this.deviceHandleMaxAgeMs);this.deviceCollector=f;let g=e.deviceInfoDebounceTime??3e4;this.deviceInfoManager=new Ce(this.logger,f,Math.max(1,g),g,{timing:()=>this.config.deviceInfoTiming,emit:(u,m)=>this.telemetry(u,m)},()=>this.queue.notifyDeviceInfo()),this.deviceInfoManager.start(),this.experiments=this.loadPersistedExperiments(),e.experiments&&this.setExperiments(e.experiments),this.dataPolicy=this.loadPersistedDataPolicy(),e.dataPolicy!==void 0&&this.setDataPolicy(e.dataPolicy),this.configManager?.start(u=>this.handleConfig(u)),this.eachPlugin(r,u=>{u.setup&&u.setup(this)})}logger;queue;sessionId;storage;sessionStorage;persistentStorage;seqLockName;config;configManager;configOverrides;fixedData;deviceInfoManager;deviceCollector;eventTabId;seq=0;lastActivityWriteAt=0;experiments={};dataPolicy;telemetryReporting=!1;telemetryReady=!1;reportedTelemetryKeys=new Set;pendingSelfTelemetry=[];windowObserver;passwordManagerSampler;bridge;rawErrors;fixedSourcePath;eventClock;deviceHandleMaxAgeMs;getWindowObserver(){return this.windowObserver??=new ve(this.logger,(e,t)=>this.enqueueLowEvent(e,t),()=>this.lowEventFlushKeepalive())}eachPlugin(e,t){for(let r of e)try{r&&t(r)}catch(n){this.logger.error("Failed to install tracker plugin",n)}}isFullTracker(){return!1}handleConfig(e){let t=ge(e,this.configOverrides);t.sessionContinuity||=this.config.sessionContinuity,t.durableOutbox||=this.config.durableOutbox,this.config=t,this.queue.updateConfig(this.config)}getLogger(){return this.logger}applicationTag(){return this.options.applicationId?{applicationId:this.options.applicationId.toLowerCase()}:{}}setExperiments(e){try{if(!e||typeof e!="object")return;let t=!1;for(let[r,n]of Object.entries(e)){if(!i.isValidExperimentKey(r)||!i.isValidExperimentVariant(n)){this.logger.debug(`Ignoring invalid experiment assignment "${String(r)}"`);continue}this.experiments[r]!==n&&(this.experiments[r]=n,t=!0)}t&&this.persistExperiments()}catch(t){this.logger.error("Failed to set experiments",t)}}getExperiments(){return{...this.experiments}}getPersistentStorage(){return this.persistentStorage}getSdkConfig(){return Object.freeze({version:this.config.version,aap:this.config.aap,rawErrors:this.config.rawErrors})}setDataPolicy(e){try{if(!i.isValidDataPolicy(e)){this.logger.debug(`Ignoring invalid data policy code "${String(e)}"`);return}this.dataPolicy!==e&&(this.dataPolicy=e,this.persistDataPolicy())}catch(t){this.logger.error("Failed to set data policy",t)}}getDataPolicy(){return this.dataPolicy}static isValidDataPolicy(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=Rn}loadPersistedDataPolicy(){try{let e=this.persistentStorage.getItem(Ar);return i.isValidDataPolicy(e)?e:void 0}catch(e){this.logger.debug("Failed to load persisted data policy",e);return}}persistDataPolicy(){try{if(this.dataPolicy===void 0)return;this.persistentStorage.setItem(Ar,this.dataPolicy)}catch(e){this.logger.debug("Failed to persist data policy",e)}}static isValidExperimentKey(e){return typeof e=="string"&&e.length>0&&e.length<=An&&_n.test(e)}static isValidExperimentVariant(e){return typeof e=="string"&&e.length>0&&e.length<=Dn}loadPersistedExperiments(){try{let e=this.persistentStorage.getItem(_r);if(!e||typeof e!="object")return{};let t={};for(let[r,n]of Object.entries(e))i.isValidExperimentKey(r)&&i.isValidExperimentVariant(n)&&(t[r]=n);return t}catch(e){return this.logger.debug("Failed to load persisted experiments",e),{}}}persistExperiments(){try{this.persistentStorage.setItem(_r,this.experiments)}catch(e){this.logger.debug("Failed to persist experiments",e)}}resolveExperiments(e){let t={...this.experiments};if(e&&typeof e=="object")for(let[r,n]of Object.entries(e))i.isValidExperimentKey(r)&&i.isValidExperimentVariant(n)&&(t[r]=n);return Object.keys(t).length>0?t:void 0}isTrackingBlocked(){return typeof navigator>"u"?!1:Cr(Jt(0))}resolveSession(){return this.bridge?this.bridge.resolve():this.resolveSessionId()}resolveSessionId(){try{if(this.config.sessionContinuity)return this.getContinuitySessionId();let e=Date.now(),t=this.readPerTabSession();if(t&&e-t.lastActiveAt<this.perTabInactivityMs(t))return this.persistPerTabSession(t.id,e),this.seq=0,t.id;let r=S();return this.persistPerTabSession(r,e),this.seq=0,this.logger.debug("Created session id",r),r}catch(e){return this.logger.error("Failed to get session id",e),this.reportTelemetry("error","failed to get session id"),""}}getContinuitySessionId(){let e=Date.now(),t=this.persistentStorage.getItem(G);if(t?.id&&e-t.lastActiveAt<this.config.sessionInactivityMs)return this.persistContinuitySession(t.id,e),this.seq=this.persistentStorage.getItem(I)??0,t.id;if(!t?.id){let n=this.readPerTabSession();if(n&&e-n.lastActiveAt<this.config.sessionInactivityMs)return this.persistContinuitySession(n.id,e),this.persistentStorage.setItem(I,0),this.seq=0,this.logger.debug("Adopted per-tab session id as continuity session",n.id),n.id}let r=S();return this.persistContinuitySession(r,e),this.persistentStorage.setItem(I,0),this.seq=0,this.logger.debug("Created continuity session id",r),r}persistContinuitySession(e,t){this.lastActivityWriteAt=t,this.persistentStorage.setItem(G,{id:e,lastActiveAt:t})}readPerTabSession(){let e=this.sessionStorage.getItem(se);if(e){if(typeof e=="string")return Et.test(e)?{id:e,lastActiveAt:Date.now()}:void 0;if(typeof e.lastActiveAt=="number")return Et.test(e.id)?e:void 0}}persistPerTabSession(e,t){this.lastActivityWriteAt=t;let r=this.configOverrides.sessionInactivityMs!==void 0||this.config.version?this.config.sessionInactivityMs:this.readPerTabSession()?.inactivityMs;this.sessionStorage.setItem(se,{id:e,lastActiveAt:t,...r===void 0?{}:{inactivityMs:r}})}perTabInactivityMs(e){return this.configOverrides.sessionInactivityMs!==void 0?this.config.sessionInactivityMs:e.inactivityMs??this.config.sessionInactivityMs}nextSeq(){if(!this.config.sessionContinuity){let r=Date.now();this.sessionId&&r-this.lastActivityWriteAt>=Mr&&this.persistPerTabSession(this.sessionId,r);let n=this.bridge?this.bridge.claim(this.sessionId,this.seq,r):this.seq;return this.seq=n+1,n}let e=()=>{let r=Date.now(),n=this.persistentStorage.getItem(G),o=!1;if(!n?.id&&this.sessionId)this.persistContinuitySession(this.sessionId,r);else if(n?.id)r-this.lastActivityWriteAt>=Mr&&this.persistContinuitySession(n.id,r),n.id!==this.sessionId&&(this.sessionId=n.id,this.queue.setSessionId(n.id),o=!0);else{let p=S();this.persistContinuitySession(p,r),this.persistentStorage.setItem(I,0),this.sessionId=p,this.queue.setSessionId(p),this.seq=0,o=!0}let s=this.persistentStorage.getItem(I);o&&(this.seq=typeof s=="number"?s:0);let a=typeof s=="number"&&s>this.seq?s:this.seq;return this.bridge&&(a=this.bridge.claim(this.sessionId,a,r)),this.seq=a+1,this.persistentStorage.setItem(I,this.seq),a},t=this.config.seqLockTimeoutMs;return t===0||!pr(0)?e():Te(0,this.seqLockName,e,{timeoutMs:t,onTimeout:()=>{this.logger.warn(`Sequence Web Lock acquisition timed out after ${t}ms; using fallback`),this.reportTelemetry("info",`seq web lock timeout; using fallback, ${t}ms`)}})}resolveTrackingSourcePath(){if(!(typeof window>"u")){if(this.fixedSourcePath)try{let e=this.fixedSourcePath();return typeof e=="string"?e:void 0}catch{return}return zt(0,this.config.sourcePathQuery,this.config.sourcePathQueryAllow)}}resolveEventTabId(){return this.eventTabId===void 0&&(this.eventTabId=this.deviceCollector.getTabId()),this.eventTabId}trackSubflowStarted(e,t,r,n){let o={subflowType:e,...t};this.track("subflow_started",o,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{id:n,subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}trackSubflowTrigger(e,t,r){let n={subflowType:e,...t};this.track("subflow_trigger",n,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}trackSubflowStepStarted(e,t,r,n,o){let s={subflowType:e,stepName:t,stepData:r,identifier:n?.identifier,ignoreAsInteraction:o};this.track("subflow_step_started",s,n?.userReference,void 0,void 0,n?.explicitTimestamp,n?.experiments,{subflowStartEventId:n?.subflowStartEventId,sessionId:n?.captureSessionId,initiator:n?.initiator})}trackSubflowStepFinished(e,t,r,n){let o={subflowType:e,stepName:t,stepData:r,identifier:n?.identifier};this.track("subflow_step_finished",o,n?.userReference,void 0,void 0,n?.explicitTimestamp,n?.experiments,{subflowStartEventId:n?.subflowStartEventId,sessionId:n?.captureSessionId,initiator:n?.initiator})}trackSubflowStepError(e,t,r,n){let o={subflowType:e,stepName:t,stepData:r,identifier:n?.identifier};this.track("subflow_step_error",o,n?.userReference,void 0,void 0,n?.explicitTimestamp,n?.experiments,{subflowStartEventId:n?.subflowStartEventId,sessionId:n?.captureSessionId,initiator:n?.initiator})}async track(e,t,r,n,o,s,a,p){try{if(this.isTrackingBlocked()){this.logger.debug(`Skipping event "${e}" for blocked user agent.`);return}(e==="flow_finished"||e==="flow_auto_finished"||e==="flow_reset")&&this.windowObserver?.flushInputs();let d=this.eventClock?.(s)??s??Date.now(),l=p?.id??S(),c=p?.sessionId??this.sessionId,f=this.nextSeq(),g=typeof f=="number"?f:await f,u=this.resolveTrackingSourcePath(),m={type:"predefined",name:e,id:l,timestamp:d,seq:g,data:t,user:r,contexts:o,tags:n,experiments:this.resolveExperiments(a),meta:{captureVersion:1,pageId:re(),initiator:p?.initiator,trackingSourcePath:u??"",subflowStartEventId:p?.subflowStartEventId,tabId:this.resolveEventTabId()}},v=this.deviceInfoManager.getForEvent();v&&(m.deviceInfo=v),this.logger.debug(`Track: ${e}`,JSON.stringify(m,null,2));let E=this.passwordManagerSampler?.takeReport(c);E&&(m.passwordManagers=E),this.queue.enqueue(m,c)}catch(d){this.logger.error(`Failed to process event "${e}" before enqueue`,d),this.reportTelemetry("error",`failed to process event "${e}" before enqueue`)}}flowStarted(e,t,r,n,o){try{let s=S(),a=this.sessionId,p={...this.options.defaultTags,...this.applicationTag(),...t};return this.track("flow_started",e,void 0,p,n,o?.explicitTimestamp,r,{id:s,sessionId:a}),this.flowHandle(s,a)}catch(s){return this.logger.warn("Failed to start flow",s),{enrich:async()=>{}}}}flowDecided(e,t,r){this.track("flow_decided",e,void 0,t,void 0,void 0,r)}flowFinished(e,t,r){try{let{userId:n,identifier:o,...s}=e,a={userId:n,identifier:o},p=S(),d=this.sessionId;return this.track("flow_finished",s,a,t,void 0,void 0,r,{id:p,sessionId:d}),this.flowHandle(p,d)}catch(n){return this.logger.warn("Failed to finish flow",n),{enrich:async()=>{}}}}flowHandle(e,t){return{enrich:async r=>{try{await this.track("flow_enriched",{targetEventId:e},{...r},void 0,void 0,void 0,void 0,{sessionId:t})}catch(n){this.logger.warn("Failed to enrich flow",n)}}}}flowReset(e,t,r){this.track("flow_reset",e,void 0,t,void 0,void 0,r)}flowAutoFinished(e,t,r){let{userId:n,identifier:o,...s}=e,a={userId:n,identifier:o};this.track("flow_auto_finished",s,a,t,void 0,void 0,r)}authMethodsDecisionStarted(e,t,r,n){this.track("auth_method_decision_started",e,void 0,t,void 0,n?.explicitTimestamp,r)}authMethodsDecisionFinished(e,t,r){this.track("auth_method_decision_finished",e,void 0,t,void 0,void 0,r)}enqueueLowEvent(e,t){try{if(this.isTrackingBlocked()){this.logger.debug(`Skipping low event "${e.lowType}" for blocked user agent.`);return}this.queue.enqueueLow({...e,captureSeq:e.captureSeq??P(),captureVersion:1,pageId:e.pageId??re()},t)}catch(r){this.logger.error(`Failed to process low event "${e.lowType}" before enqueue`,r)}}telemetry(e,t){try{if(this.isTrackingBlocked()){this.logger.debug("Skipping telemetry for blocked user agent.");return}let r=typeof t=="string"?t:String(t);if(r.length===0)return;let n={id:S(),level:e,message:r.length>Dr?r.slice(0,Dr):r,ts:Date.now()};this.queue.enqueueTelemetry(n)}catch(r){this.logger.error("Failed to process telemetry before enqueue",r)}}attachUndeliveredDeviceInfo(e){try{let t=this.deviceInfoManager;if(!t?.hasUndelivered())return;let r=re(),n=e.find(o=>o.meta?.pageId===r&&!o.deviceInfo);n&&(n.deviceInfo=t.takeUndelivered())}catch(t){this.logger.error("Failed to attach device info to batch",t)}}reportTelemetry(e,t){if(!this.telemetryReporting){this.telemetryReporting=!0;try{if(this.reportedTelemetryKeys.has(t)||this.reportedTelemetryKeys.size>=Mn)return;if(this.reportedTelemetryKeys.add(t),!this.telemetryReady){this.pendingSelfTelemetry.push({level:e,message:t});return}this.telemetry(e,t)}catch{}finally{this.telemetryReporting=!1}}}flushKeepalive(e="manual"){try{this.queue.flushKeepalive(e)}catch(t){this.logger.error("Failed to flush queue keepalive",t)}}lowEventFlushKeepalive(){this.config.tlf&&this.flushKeepalive("low-event-teardown")}async destroy(){if(this.bridge?.stop(),this.configManager?.destroy(),this.passwordManagerSampler?.destroy(),this.windowObserver?.destroy(),this.deviceInfoManager.destroy(),this.config.td)try{await this.queue.flush("destroy")}catch(e){this.logger.error("Failed to flush queue during destroy",e)}this.queue.destroy()}getSessionId(){if(!this.sessionId){let e=this.resolveSession();e&&(this.sessionId=e,this.queue.setSessionId(e))}return this.sessionId||void 0}};var j=class{constructor(e,t){this.logger=e;this.sink=t}lease;destroyed=!1;arm(e,t=!1){if(this.disarm(),!(this.destroyed||t))try{this.lease=this.sink.beginCeremony?.(e)}catch(r){this.logger.error("Failed to register ceremony low-event context",r)}}scheduleDisarm(e){try{this.lease?.settle(e)}catch(t){this.logger.error("Failed to settle ceremony low-event context",t)}}disarm(){try{this.lease?.destroy()}catch(e){this.logger.error("Failed to release ceremony low-event context",e)}this.lease=void 0}destroy(){this.disarm(),this.destroyed=!0}};var De=class extends h{getOptions;ceremony;postResponse;lowEventTracker;constructor(e,t){super(e,"passkey-login"),this.lowEventTracker=new j(e.getLogger(),this.lowEventSink("ceremony")),this.registerLowFlusher(()=>this.lowEventTracker.disarm()),this.getOptions=this.defineStep("get-options"),this.ceremony=this.withWindowLowEvents(this.defineStep("ceremony"),this.lowEventTracker),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t?.explicitSpecType})}trigger(e,t){super.trigger(e,t)}destroy(){this.lowEventTracker.destroy()}};var Q=class{constructor(e,t,r,n){this.previousLength=e;this.pushLow=t;this.logger=r;this.reserveCaptureSeq=n}prefillSettled=!1;inputBatch=null;currentEffect="modify";ringEffect="modify";autofillTimestamps=[];autofillStreak=null;idleTimer=null;runSeq;markInputObserved(){this.prefillSettled=!0}observe(){this.runSeq!==void 0||this.inputBatch||this.autofillTimestamps.length>0||this.autofillStreak||(this.runSeq=this.reserveCaptureSeq?.())}takeSeq(){let e=this.runSeq;return this.runSeq=void 0,e??this.reserveCaptureSeq?.()}capturePrefill(e,t=!1){t&&(this.prefillSettled=!1),!this.prefillSettled&&(this.previousLength=e,e!==0&&(this.prefillSettled=!0,this.pushLow({lowType:"input-prefill",ts:Date.now(),initiator:"unknown"})))}flush(){this.cancelIdle(),this.flushInputBatch(),this.flushAutofillStreak()}cancelIdle(){this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=null}scheduleIdle(){this.cancelIdle(),this.idleTimer=setTimeout(()=>{this.idleTimer=null;try{this.flushInputBatch(!0),this.flushAutofillStreak()}catch(e){this.logger.error("Failed to flush idle input",e)}},3e3)}extendInputBatch(e,t=this.currentEffect){let r=this.inputBatch;if(!r){this.inputBatch={firstTimestamp:e,lastTimestamp:e,effect:t,captureSeq:this.takeSeq()};return}r.lastTimestamp=e}drainAutofillRingToBatch(){for(let e of this.autofillTimestamps)this.extendInputBatch(e,this.ringEffect);this.autofillTimestamps.length=0}flushInputBatch(e=!1){this.drainAutofillRingToBatch();let t=this.inputBatch;t&&(this.pushLow({...t.captureSeq===void 0?{}:{captureSeq:t.captureSeq},lowType:e?"input-idle":"input",ts:t.firstTimestamp,durationMs:t.lastTimestamp-t.firstTimestamp,inputEffect:t.effect}),this.inputBatch=null)}flushAutofillStreak(){let e=this.autofillStreak;e&&(this.pushLow({...e.captureSeq===void 0?{}:{captureSeq:e.captureSeq},lowType:"big-input-add",ts:e.firstTimestamp,durationMs:e.lastTimestamp-e.firstTimestamp,inputEffect:e.effect}),this.autofillStreak=null)}detectAutofillStreak(){let e=this.autofillTimestamps;if(e.length<5)return!1;let t=1/0,r=-1/0;for(let n=1;n<e.length;n++){let o=e[n]-e[n-1];if(o>80)return!1;o<t&&(t=o),o>r&&(r=o)}return r-t<=25}record(e,t=Date.now(),r=!1){this.observe(),this.markInputObserved(),this.scheduleIdle();let n=this.previousLength;this.currentEffect=e===0?"clear":n===0?"fill":"modify";let o=e-n;if(this.previousLength=e,e===0&&n>0){this.flush();let l=this.takeSeq();this.pushLow({...l===void 0?{}:{captureSeq:l},lowType:"input-clear",ts:t,inputEffect:"clear"});return}if(r){this.flushAutofillStreak(),this.drainAutofillRingToBatch(),this.extendInputBatch(t,this.currentEffect);return}if(o>=3){this.flushInputBatch(),this.flushAutofillStreak();let l=this.takeSeq();this.pushLow({...l===void 0?{}:{captureSeq:l},lowType:"big-input-add",ts:t,inputEffect:this.currentEffect});return}if(o<=-3){this.flushInputBatch(),this.flushAutofillStreak();let l=this.takeSeq();this.pushLow({...l===void 0?{}:{captureSeq:l},lowType:"big-input-rem",ts:t,inputEffect:this.currentEffect});return}let s=this.autofillStreak;if(s){if(o===1&&t-s.lastTimestamp<=80){s.lastTimestamp=t;return}this.flushAutofillStreak()}if(o!==1){this.drainAutofillRingToBatch(),this.extendInputBatch(t,this.currentEffect);return}let a=this.autofillTimestamps;if(a.length===0&&(this.ringEffect=this.currentEffect),a.push(t),a.length>5){let l=a.shift();this.extendInputBatch(l,this.ringEffect),this.ringEffect="modify"}if(!this.detectAutofillStreak())return;let p=a[0],d=a[a.length-1];a.length=0,this.flushInputBatch(),this.autofillStreak={firstTimestamp:p,captureSeq:this.takeSeq(),lastTimestamp:d,effect:this.ringEffect}}};var z=class{constructor(e,t,r,n,o){this.inputs=t;this.logger=r;this.changed=n;this.reserveCaptureSeq=o;for(let s of t)s.addEventListener("paste",this.onPaste,!0),s.addEventListener("beforeinput",this.onBeforeInput,!0)}lengthsBefore=null;applied=!1;timestamp=0;captureSeq;pasteEvent;timer=null;onPaste=e=>this.begin(e);onBeforeInput=e=>{e.inputType==="insertFromPaste"?this.begin(e):this.flush()};handlesInput(e){if(!this.lengthsBefore)return!1;let t=this.pasteEvent?.type==="paste"&&(this.pasteEvent.eventPhase??0)>0;return e.inputType==="insertFromPaste"||t?(this.applied=!0,!0):(this.clear(),!1)}get pending(){return this.lengthsBefore!==null}begin(e){if(!(!e.isTrusted||this.lengthsBefore))try{this.lengthsBefore=this.inputs.map(t=>t.value.length),this.applied=!1,this.pasteEvent=e,this.timestamp=Date.now(),this.captureSeq=this.reserveCaptureSeq?.(),this.timer=setTimeout(()=>this.flush(),0)}catch(t){this.logger.error("Failed to observe paste",t),this.clear()}}flush(){let e=this.lengthsBefore;if(!e)return;let t=this.timestamp,r=this.captureSeq,n=this.applied;this.clear();try{(n||this.inputs.some((s,a)=>s.value.length!==e[a]))&&this.changed(t,r)}catch(o){this.logger.error("Failed to finish paste observation",o)}}clear(){this.timer!==null&&clearTimeout(this.timer),this.timer=null,this.lengthsBefore=null,this.applied=!1,this.pasteEvent=void 0}destroy(){this.flush();for(let e of this.inputs)e.removeEventListener("paste",this.onPaste,!0),e.removeEventListener("beforeinput",this.onBeforeInput,!0)}};var Bn=["focus","blur","pointerdown","pointerup","click","input","keyup"];function Me(i,e,t,r,n=Bn){let o=[];for(let s of n){let a=Un(s,t,r);a&&o.push([s,a])}for(let[s,a]of o)e.addEventListener(s,a);return()=>{for(let[s,a]of o)e.removeEventListener(s,a)}}function Un(i,e,t){switch(i){case"focus":case"blur":{let r=e[i];return r&&(n=>t(i,()=>r(n.relatedTarget)))}case"pointerdown":case"pointerup":case"click":{let r=e[i];return r&&(()=>t(i,()=>r()))}case"input":{let r=e.input;return r&&(n=>t("input",()=>r(n.isComposing||n.inputType==="insertCompositionText",n)))}case"keyup":{let r=e.keyupEscape;return r&&(n=>t("keyup",()=>{n.key==="Escape"&&r()}))}}}function Hr(i,e){return e.type==="checkbox"||e.type==="radio"?e.checked?1:0:e.value.length}function Br(i,e){return e.reduce((t,r)=>t+r.value.length,0)}function He(i,e){let t=document.activeElement;return e.find(r=>r===t)}function ae(i){return Hr(0,i)}var k=class{constructor(e,t,r){this.logger=e;this.inputField=t;this.sink=r;this.changes=new Q(ae(t),this.pushLow,e,r.reserveCaptureSeq),this.pasteObserver=new z(0,[t],e,(n,o)=>{this.changes.flush(),this.changes.markInputObserved();let s=this.changes.previousLength;this.changes.previousLength=ae(t),this.pushLow({...o===void 0?{}:{captureSeq:o},lowType:"input-paste",ts:n,inputEffect:ae(t)===0?"clear":s===0?"fill":"modify"})},r.reserveCaptureSeq),this.unregisterInputs=r.registerInputs?.([t],()=>this.flushPending()),this.capturePrefill(),this.attach()}unregisterInputs;removeFieldListeners;removePageHide;changes;pasteObserver;destroyed=!1;destroy(){if(!this.destroyed){this.destroyed=!0;try{this.changes.flush(),this.unregisterInputs?.(),this.pasteObserver.destroy(),this.detach()}catch(e){this.logger.error("Failed to destroy LowEventInputTracker",e)}}}attach(){let e=this.inputField;this.removeFieldListeners=Me(0,e,{focus:()=>this.handleFocus(),blur:()=>this.handleBlur(),pointerdown:()=>this.enqueueNonInputEvent("pointerdown"),pointerup:()=>this.enqueueNonInputEvent("pointerup"),click:()=>this.enqueueNonInputEvent("click"),input:(t,r)=>this.handleInput(r,t),keyupEscape:()=>this.enqueueNonInputEvent("keyup-escape")},(t,r)=>{try{r()}catch(n){t==="input"?this.logger.error("Failed to observe input",n):this.logger.error(`Failed to handle low event "${t}"`,n)}}),typeof window<"u"&&(this.removePageHide=O(0,"pagehide",this.wrapHandler("pagehide",()=>this.flushForTeardown()))),typeof document<"u"&&He(0,[e])&&this.handleFocus()}detach(){this.removeFieldListeners?.(),typeof window<"u"&&this.removePageHide?.()}pushLow=e=>{this.sink.enqueueLowEvent(e)};capturePrefill(e=!1){this.destroyed||(this.flushPending(),this.changes.capturePrefill(ae(this.inputField),e))}flushPending(){this.pasteObserver.flush(),this.changes.flush()}enqueueNonInputEvent(e){this.changes.flush(),this.pushLow({lowType:e,ts:Date.now()})}handleFocus(){this.enqueueNonInputEvent("focus")}handleBlur(){this.pasteObserver.flush(),this.enqueueNonInputEvent("blur")}handleInput(e,t){this.pasteObserver.handlesInput(e)||this.changes.record(ae(this.inputField),Date.now(),t)}flushForTeardown(){this.pasteObserver.flush(),this.changes.flush(),this.sink.flushKeepalive()}wrapHandler(e,t){return()=>{try{t()}catch(r){this.logger.error(`Failed to handle low event "${e}"`,r)}}}};var Be=class{constructor(e,t,r){this.logger=e;this.sink=r;this.inputs=[...new Set(t)],this.changes=new Q(this.length(),o=>r.enqueueLowEvent(o),e,r.reserveCaptureSeq),this.paste=new z(0,this.inputs,e,(o,s)=>{this.cancelChange(),this.changes.flush(),this.changes.markInputObserved();let a=this.changes.previousLength;this.changes.previousLength=this.length(),r.enqueueLowEvent({...s===void 0?{}:{captureSeq:s},lowType:"input-paste",ts:o,inputEffect:this.length()===0?"clear":a===0?"fill":"modify"})},r.reserveCaptureSeq),this.unregisterInputs=r.registerInputs?.(this.inputs,()=>this.flushPending()),this.capturePrefill();let n=(o,s)=>this.safe(s);for(let o of this.inputs)this.listeners.push(Me(0,o,{input:(s,a)=>{this.paste.handlesInput(a)||(this.composing||=s,this.changeTimer===null&&(this.changeTime=Date.now(),this.changes.observe(),this.changeTimer=setTimeout(()=>this.safe(()=>this.flushChanges()),0)))},focus:s=>{this.contains(s)||this.emit("focus")},blur:s=>{this.contains(s)||(this.flushPending(),this.emit("blur"))},click:()=>this.emit("click"),pointerdown:()=>this.emit("pointerdown"),pointerup:()=>this.emit("pointerup"),keyupEscape:()=>this.emit("keyup-escape")},n,["input","focus","blur","click","pointerdown","pointerup","keyup"]));typeof window<"u"&&this.listeners.push(O(0,"pagehide",o=>this.safe(()=>{this.flushPending(),r.flushKeepalive()}))),typeof document<"u"&&He(0,this.inputs)&&this.emit("focus")}inputs;changes;paste;unregisterInputs;listeners=[];changeTimer=null;changeTime=0;composing=!1;destroyed=!1;contains(e){return this.inputs.some(t=>t===e)}length(){return Br(0,this.inputs)}safe(e){try{e()}catch(t){this.logger.error("Failed to observe grouped input",t)}}cancelChange(){this.changeTimer!==null&&clearTimeout(this.changeTimer),this.changeTimer=null}flushChanges(){this.changeTimer!==null&&(this.cancelChange(),this.paste.pending||this.changes.record(this.length(),this.changeTime,this.composing),this.composing=!1)}emit(e){this.flushChanges(),this.changes.flush(),this.sink.enqueueLowEvent({lowType:e,ts:Date.now()})}capturePrefill(e=!1){this.destroyed||(this.flushPending(),this.changes.capturePrefill(this.length(),e))}flushPending(){this.paste.flush(),this.flushChanges(),this.changes.flush()}destroy(){this.destroyed||(this.destroyed=!0,this.safe(()=>{this.flushPending(),this.paste.destroy(),this.unregisterInputs?.();for(let e of this.listeners)e()}))}};var A=class{constructor(e,t,r){this.logger=e;this.inputSink=t;this.groupSink=r}collector;fields=[];grouped=!1;destroyed=!1;prefillClaimed=!1;setFields(e,t=!0){try{if(this.destroyed)return;let r=[...new Set(e)];if(t===this.grouped&&r.length===this.fields.length&&r.every((s,a)=>s===this.fields[a])||(this.collector?.destroy(),this.collector=void 0,this.fields=[],this.grouped=t,r.length===0))return;let n=t?this.groupSink:this.inputSink,o={...n,enqueueLowEvent:s=>this.enqueue(n,s)};this.collector=t?new Be(this.logger,r,o):new k(this.logger,r[0],o),this.fields=r}catch(r){this.logger.error("Failed to bind OTP inputs",r)}}enqueue(e,t){if(t.lowType==="input-prefill"){if(this.prefillClaimed)return;this.prefillClaimed=!0}else["input","input-idle","input-clear","input-paste","big-input-paste","big-input-add","big-input-rem"].includes(t.lowType)&&(this.prefillClaimed=!0);e.enqueueLowEvent(t)}capturePrefill(e=!1){e&&(this.prefillClaimed=!1),this.collector?.capturePrefill(e)}flushPending(){this.collector?.flushPending()}destroy(){this.destroyed=!0,this.collector?.destroy(),this.collector=void 0,this.fields=[]}};var Ue=class extends h{lowEventTracker;send;postResponse;resend;constructor(e,t={}){super(e,"email-otp"),this.send=this.defineStep("send"),this.postResponse=this.defineStep("post-response"),this.resend=this.defineStep("resend"),this.subflowStart({explicitSpecType:t.explicitSpecType,emailDomain:t.emailDomain}),this.lowEventTracker=this.createLowCollector(()=>new A(e.getLogger(),this.lowEventSink("input","otp"),this.lowEventSink("input-group","otp"))),t.inputHtmlFields?.length?this.setInputFields(t.inputHtmlFields):t.inputHtmlField&&this.lowEventTracker?.setFields([t.inputHtmlField],!1),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending())}setInputFields(e){this.lowEventTracker?.setFields(e)}destroy(){this.lowEventTracker?.destroy()}};var Ne=class extends h{lowEventTracker;send;postResponse;resend;constructor(e,t={}){super(e,"sms-otp"),this.send=this.defineStep("send"),this.postResponse=this.defineStep("post-response"),this.resend=this.defineStep("resend"),this.subflowStart({explicitSpecType:t.explicitSpecType}),this.lowEventTracker=this.createLowCollector(()=>new A(e.getLogger(),this.lowEventSink("input","otp"),this.lowEventSink("input-group","otp"))),t.inputHtmlFields?.length?this.setInputFields(t.inputHtmlFields):t.inputHtmlField&&this.lowEventTracker?.setFields([t.inputHtmlField],!1),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending())}setInputFields(e){this.lowEventTracker?.setFields(e)}destroy(){this.lowEventTracker?.destroy()}};var le="cbo_email_link_starts";function kt(i,e){let t=i.getItem(le);if(!Array.isArray(t))return[];let r=t.filter(n=>!!n&&typeof n=="object"&&typeof n.transactionId=="string"&&typeof n.anchor=="string"&&typeof n.sessionId=="string"&&typeof n.startedAt=="number"&&e-n.startedAt<864e5);return typeof __CBO_DATA_RETENTION__=="boolean"&&__CBO_DATA_RETENTION__&&r.length<t.length&&(r.length===0?i.removeItem(le):i.setItem(le,r)),r}function Ur(i,e){if(i)try{let t=kt(i,e.startedAt).filter(r=>r.transactionId!==e.transactionId);t.push(e),i.setItem(le,t.slice(-10))}catch{}}function Nr(i,e,t=Date.now()){if(i)try{let r=kt(i,t);if(e.transactionId)return r.find(o=>o.transactionId===e.transactionId);let n=r.filter(o=>!o.continued&&(!e.specType||!o.specType||o.specType===e.specType));return n[n.length-1]}catch{return}}function qr(i,e){if(i)try{let t=kt(i,Date.now()).map(r=>r.transactionId===e?{...r,continued:!0}:r);i.setItem(le,t)}catch{}}var qe=class extends h{send;postResponse;resend;transactionId;constructor(e,t={}){super(e,"email-link"),this.send=this.defineStep("send"),this.postResponse=this.defineStep("post-response"),this.resend=this.defineStep("resend"),this.transactionId=t.transactionId||S(),this.subflowStart({explicitSpecType:t.explicitSpecType},{userReference:{crossEnvironmentTransactionIDStart:this.transactionId}});let r=this.captureReference,n=this.captureSession;r&&n&&Ur(e.getPersistentStorage(),{transactionId:this.transactionId,anchor:r,sessionId:n,specType:t.explicitSpecType,startedAt:Date.now()})}},Ke=class extends h{postResponse;resend;mode;continuationTracker;specType;createdAt=Date.now();transaction;started=!1;deferred=[];onPageHide=()=>this.flush();removePageHide;constructor(e,t={}){super(e,"email-link"),this.continuationTracker=e,this.specType=t.explicitSpecType,this.transaction=t.transactionId,this.postResponse=this.deferrable(this.defineStep("post-response"),!0),this.resend=this.deferrable(this.defineStep("resend"));let r=e.getPersistentStorage(),n=Nr(r,{transactionId:t.transactionId,specType:t.explicitSpecType});if(n&&n.sessionId===e.getSessionId()){this.mode="attached",this.transaction=t.transactionId??n.transactionId,this.adoptCapture(n.anchor,n.sessionId,n.specType??t.explicitSpecType),this.started=!0;return}this.mode="detached",this.transaction?this.startDetached(this.createdAt):typeof window<"u"&&(this.removePageHide=O(0,"pagehide",this.onPageHide))}get transactionId(){return this.transaction}setTransactionId(e){!e||this.transaction||(this.transaction=e,this.mode==="detached"&&!this.started&&this.startDetached(this.firstDeferredAt()))}flush(){this.mode==="detached"&&!this.started&&this.startDetached(this.firstDeferredAt())}destroy(){this.flush(),this.removePageHideListener()}firstDeferredAt(){return this.deferred[0]?.at??this.createdAt}startDetached(e){this.started=!0,this.removePageHideListener(),this.subflowStart({explicitSpecType:this.specType,continuation:!0},{explicitTimestamp:e,...this.transaction?{userReference:{crossEnvironmentTransactionIDFinish:this.transaction}}:{}});let t=this.deferred;this.deferred=[];for(let r of t)r.run(r.at);try{this.continuationTracker.flushKeepalive()}catch{}}removePageHideListener(){typeof window<"u"&&this.removePageHide?.()}deferrable(e,t=!1){let r=(n,o)=>{if(this.started){n(o?.explicitTimestamp??Date.now());return}this.deferred.push({at:o?.explicitTimestamp??Date.now(),run:n})};return{start:(n,o)=>r(s=>e.start(n,{...o,explicitTimestamp:s}),o),finished:(n,o)=>{r(s=>e.finished(n,{...o,explicitTimestamp:s}),o),t&&this.transaction&&qr(this.continuationTracker.getPersistentStorage(),this.transaction)},error:(n,o)=>r(s=>e.error(n,{...o,explicitTimestamp:s}),o)}}};var We=class extends h{getOptions;ceremony;postResponse;lowEventTracker;constructor(e,t){super(e,"passkey-enrollment"),this.lowEventTracker=new j(e.getLogger(),this.lowEventSink("ceremony")),this.registerLowFlusher(()=>this.lowEventTracker.disarm()),this.getOptions=this.defineStep("get-options"),this.ceremony=this.withWindowLowEvents(this.defineStep("ceremony"),this.lowEventTracker),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t?.explicitSpecType,...t?.ignoreAsInteraction?{ignoreAsInteraction:!0}:{}})}destroy(){this.lowEventTracker.destroy()}};var Ve=class extends h{userConfirmation;deletion;constructor(e,t={}){super(e,"passkey-deletion"),this.userConfirmation=this.defineStep("user-confirmation"),this.deletion=this.defineStep("deletion"),this.subflowStart({})}};var $e=class extends h{clientValidation;postResponse;cui;lowEventTracker;identifierLowEventTracker;constructor(e,t){super(e,"password-login"),this.clientValidation=this.defineStep("client-validation"),this.postResponse=this.defineStep("post-response"),this.cui={getOptions:this.defineStep("cui-get-options",!0),ceremony:this.defineStep("cui-ceremony"),postResponse:this.defineStep("cui-post-response")},this.subflowStart({explicitSpecType:t?.explicitSpecType}),t?.identifierInputHtmlField&&(this.identifierLowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.identifierInputHtmlField,this.lowEventSink("input","identifier"))),this.registerLowFlusher(()=>this.identifierLowEventTracker?.flushPending())),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","password"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}trigger(e,t){super.trigger(e,t)}destroy(){this.lowEventTracker?.destroy(),this.identifierLowEventTracker?.destroy()}};var Ge=class extends h{clientValidation;postResponse;lowEventTracker;constructor(e,t){super(e,"password-enrollment"),this.clientValidation=this.defineStep("client-validation"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t?.explicitSpecType}),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","password"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var je=class extends h{lowEventTracker;cui;provideIdentifier;constructor(e,t){super(e,"provide-identifier"),this.cui={trigger:(r,n)=>{this.trigger(r,n)},getOptions:this.defineStep("cui-get-options",!0),ceremony:this.defineStep("cui-ceremony"),postResponse:this.defineStep("cui-post-response")},this.provideIdentifier={trigger:(r,n)=>{this.trigger(r,n)},clientValidation:this.defineStep("pi-client-validation"),postResponse:this.defineStep("pi-post-response")},this.subflowStart({explicitSpecType:t?.explicitSpecType}),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","identifier"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var Qe=class extends h{getRedirectUrl;exchangeCode;constructor(e,t={}){super(e,"social-login"),this.getRedirectUrl=this.defineStep("get-redirect-url"),this.exchangeCode=this.defineStep("exchange-code"),this.subflowStart({explicitSpecType:t.explicitSpecType,entry:t.entry})}};var ze=class extends h{getRedirectUrl;exchangeCode;constructor(e,t={}){super(e,"sso-login"),this.getRedirectUrl=this.defineStep("get-redirect-url"),this.exchangeCode=this.defineStep("exchange-code");let{explicitSpecType:r,organizationDomain:n,actor:o}=Nn(t??{},e);this.subflowStart({explicitSpecType:r,organizationDomain:n,actor:o})}};function Nn(i,e){let t={...i},r=o=>{try{e.getLogger().warn(`SSO login: unsupported ${o}; omitted from telemetry`)}catch{}},n=t.organizationDomain;return n!==void 0&&(typeof n!="string"||n.includes("@")||n.length>253)&&(delete t.organizationDomain,r("organizationDomain")),t.actor!==void 0&&t.actor!=="user"&&t.actor!=="system"&&(delete t.actor,r("actor")),t}var Ye=class extends h{lowEventTracker;postResponse;constructor(e,t={}){super(e,"totp"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType}),this.lowEventTracker=this.createLowCollector(()=>new A(e.getLogger(),this.lowEventSink("input","otp"),this.lowEventSink("input-group","otp"))),t.inputHtmlFields?.length?this.setInputFields(t.inputHtmlFields):t.inputHtmlField&&this.lowEventTracker?.setFields([t.inputHtmlField],!1),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending())}setInputFields(e){this.lowEventTracker?.setFields(e)}destroy(){this.lowEventTracker?.destroy()}};var Je=class extends h{ceremony;retry;postResponse;constructor(e,t={}){super(e,"app-confirmation"),this.ceremony=this.defineStep("ceremony"),this.retry=this.defineStep("retry"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType})}};var Xe=class extends h{ceremony;postResponse;constructor(e,t={}){super(e,"captcha"),this.ceremony=this.defineStep("ceremony"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType})}};var Ze=class{constructor(e,t){this.logger=e;this.sink=t}trackers=new Map;destroyed=!1;setFields(e){if(this.destroyed)return;let t=new Set(e);for(let[r,n]of this.trackers)t.has(r)||(this.safe(()=>n.destroy()),this.trackers.delete(r));for(let r of t)this.trackers.has(r)||this.safe(()=>this.trackers.set(r,new k(this.logger,r,this.sink())))}capturePrefill(e=!1){for(let t of this.trackers.values())this.safe(()=>t.capturePrefill(e))}flushPending(){for(let e of this.trackers.values())this.safe(()=>e.flushPending())}destroy(){if(!this.destroyed){this.destroyed=!0;for(let e of this.trackers.values())this.safe(()=>e.destroy());this.trackers.clear()}}safe(e){try{e()}catch(t){this.logger.error("Form input binding failed",t)}}};var Ot=50,qn=6e4,Kn=40,Wn=/^[A-Za-z0-9._-]+$/,et=class extends h{submit;skip;inputBinding;constructor(e,t){super(e,"form"),this.submit=this.defineStep("submit"),this.skip=this.defineStep("skip"),this.subflowStart($n(e,t),Vn(e,t)),this.inputBinding=this.createLowCollector(()=>new Ze(e.getLogger(),()=>this.lowEventSink("input","data"))),this.registerLowFlusher(()=>this.inputBinding?.flushPending()),t?.inputHtmlFields?.length&&this.setInputFields(t.inputHtmlFields)}setInputFields(e){this.inputBinding?.setFields(e)}destroy(){this.inputBinding?.destroy()}};function Vn(i,e){let t=e?.startedAt;if(t===void 0)return;let r=Date.now();if(typeof t!="number"||!Number.isFinite(t)||t>r||r-t>qn){de(i,"Form: implausible startedAt ignored; using the current time");return}return{explicitTimestamp:t}}function $n(i,e){let t={},r=e?.name;typeof r=="string"&&r.trim()!==""?t.name=r:de(i,"Form: missing name; the form will not be counted");let n=e?.fields;if(n===void 0)return t;if(!Array.isArray(n))return de(i,"Form: fields must be an array of field names; omitted from telemetry"),t;let o=n.filter(s=>typeof s=="string"&&s.length<=Kn&&Wn.test(s));return o.length<n.length&&de(i,"Form: unsupported field names omitted from telemetry"),o.length>Ot&&de(i,`Form: more than ${Ot} field names; the rest is omitted from telemetry`),o.length>0&&(t.fields=o.slice(0,Ot)),t}function de(i,e){try{i.getLogger().warn(e)}catch{}}function It(i,e,t){if(i===null||typeof i!="object")return i;try{let r={...i};r.purpose===void 0&&e.purpose!==void 0&&(r.purpose=e.purpose),r.storage===void 0&&e.storage!==void 0&&(r.storage=e.storage),r.trustName===void 0&&e.trustName!==void 0&&(r.trustName=e.trustName);for(let[n,o]of[["bindingReference",255],["trustName",128]])if(typeof r[n]=="string"&&[...r[n]].length>o){delete r[n];try{t.getLogger().debug(`Trusted device: omitted ${n} exceeding ${o} characters`)}catch{}}return r}catch{return i}}function tt(i,e,t){return{...i,start:(r,n)=>i.start(It(r,e,t),n),finished:(r,n)=>i.finished(It(r,e,t),n)}}var rt=class extends h{getOptions;ceremony;postResponse;constructor(e,t){super(e,"trusted-device-check"),t=Kr(t,e);let r={purpose:t.purpose,storage:t.storage,trustName:t.trustName};this.getOptions=this.checkStep("get-options",r,e),this.ceremony=this.checkStep("ceremony",r,e),this.postResponse=this.checkStep("post-response",r,e),this.subflowStart({explicitSpecType:t.explicitSpecType,actor:"system",ignoreAsInteraction:!0})}checkStep(e,t,r){let n=this.defineStep(e,!0);return{...tt(n,t,r),errorTyped:(o,s)=>{n.errorTyped(It({code:o?.code,error:N(o?.error)},t,r),s)}}}},it=class extends h{getOptions;ceremony;postResponse;constructor(e,t){super(e,"trusted-device-enrollment"),t=Kr(t,e);let r={purpose:t.purpose,storage:t.storage,trustName:t.trustName};this.getOptions=tt(this.defineStep("get-options"),r,e),this.ceremony=tt(this.defineStep("ceremony"),r,e),this.postResponse=tt(this.defineStep("post-response"),r,e),this.subflowStart({explicitSpecType:t.explicitSpecType})}};function Kr(i,e){let t={...i},r=n=>{try{e.getLogger().warn(`Trusted device: missing or unsupported ${n}; omitted from telemetry`)}catch{}};return t.purpose!=="additional-verification"&&t.purpose!=="mfa-exemption"&&(delete t.purpose,r("purpose")),["cookie","indexeddb","localstore","sessionstore"].includes(t.storage)||(delete t.storage,r("storage")),t}var nt=class extends h{clientValidation;postResponse;lowEventTracker;constructor(e,t={}){super(e,"provide-data"),this.clientValidation=this.defineStep("client-validation"),this.postResponse=this.defineStep("post-response");let{inputHtmlField:r,...n}=t;this.subflowStart(n),r&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),r,this.lowEventSink("input","data"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};function Wr(i){let e=S();return i.config.sessionContinuity?(i.persistContinuitySession(e,Date.now()),i.persistentStorage.setItem(I,0)):i.persistPerTabSession(e,Date.now()),i.sessionId=e,i.seq=0,i.queue.setSessionId(e),i.bridge?.reset(e),i.getLogger().debug(`Session reset: ${e}`),e}function Vr(i,e){i.track("flow_enriched",{match:{flowType:"*",at:"during"},expFol:!0},{...e})}function $r(i,e,t){let r=i.getLogger();try{if(!e||typeof e!="object"){r.warn("setFlowTags: ignoring non-object tags");return}let n={};for(let[s,a]of Object.entries(e)){if(s===""||typeof a!="string"){r.warn(`setFlowTags: ignoring invalid tag "${s}"`);continue}n[s]=a}if(Object.keys(n).length===0)return;let o={match:{flowType:t?.flowType??"*",at:"during"}};t?.expandToChildren!==void 0&&(o.expCh=t.expandToChildren),t?.expandToFollowing!==void 0&&(o.expFol=t.expandToFollowing),i.track("flow_enriched",o,void 0,n)}catch(n){r.warn("Failed to set flow tags",n)}}function Gr(i,e){try{Object.prototype.hasOwnProperty.call(i.experiments,e)&&(delete i.experiments[e],i.persistExperiments())}catch(t){i.getLogger().error("Failed to clear experiment",t)}}function jr(i){try{if(Object.keys(i.experiments).length===0)return;i.experiments={},i.persistExperiments()}catch(e){i.getLogger().error("Failed to clear experiments",e)}}function Qr(i,e,t,r){let{userId:n,identifier:o,crossEnvironmentTransactionID:s,...a}=e,p={userId:n,identifier:o,crossEnvironmentTransactionID:s},d={...i.options.defaultTags,...i.applicationTag(),...t};i.track("conversion",a,p,d,void 0,void 0,r)}function zr(i,e,t,r){i.track("auth_decision_started",e,void 0,t,void 0,void 0,r)}function Yr(i,e,t,r){i.track("auth_decision_finished",e,void 0,t,void 0,void 0,r)}function Jr(i,e,t,r){let n={subflowType:e,stepData:t};i.track("subflow_error",n,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}var Gn={maxStackFrames:{min:1,max:100,default:50},depth:{min:0,max:10,default:3},maxBreadth:{min:1,max:1e3,default:30},maxValueLength:{min:1,max:1e4,default:1024},maxCauseDepth:{min:0,max:10,default:3},maxBytes:{min:0,max:65536,default:32768}},jn=1024,J=class extends Error{},Qn=["name","message","code","errors","stack"],zn=/[^\x20-\x7E]/,X=i=>Object.prototype.toString.call(i).slice(8,-1),Yn=i=>i===null?"null":typeof i=="object"?X(i):typeof i,Jn=i=>i instanceof Error||X(i)==="Error"||X(i)==="DOMException";function ei(i){return zn.test(i)?new TextEncoder().encode(i).byteLength:i.length}function Y(i,e){let t=Gn[i];return typeof e!="number"||!Number.isFinite(e)?t.default:Math.min(t.max,Math.max(t.min,Math.floor(e)))}function Xr(i={}){return{stack:i.stack===!0,maxStackFrames:Y("maxStackFrames",i.maxStackFrames),depth:Y("depth",i.depth),maxBreadth:Y("maxBreadth",i.maxBreadth),maxValueLength:Y("maxValueLength",i.maxValueLength),maxCauseDepth:Y("maxCauseDepth",i.maxCauseDepth),maxBytes:Y("maxBytes",i.maxBytes)}}function ti(i,e={}){if(i===void 0)return;let t=Xr(),r=n=>{let o=JSON.stringify(n);return o===void 0||ei(o)<=t.maxBytes};try{if(t=Xr(e),t.maxBytes===0)return;let n=B(Yn(i),1024);for(let s=t.depth;s>=0;s--){let a={limits:t,causeBudget:t.maxCauseDepth,seen:new Set,nodes:0,textBytes:0};try{let p={type:n,value:ot(i,s,a)};if(r(p))return p}catch(p){if(!(p instanceof J))throw p}}let o={type:n,truncated:!0};return r(o)?o:void 0}catch{let n={type:"unserializable"};return r(n)?n:void 0}}function pe(i,e){if(i.length>e.limits.maxBytes)throw new J;if(e.textBytes+=ei(JSON.stringify(i)),e.textBytes>e.limits.maxBytes)throw new J;return i}function ot(i,e,t){if(++t.nodes>jn)throw new J;let r=Xn(i,e,t);return typeof r=="string"?pe(r,t):r}function Xn(i,e,t){switch(typeof i){case"string":return B(i,t.limits.maxValueLength);case"number":return Number.isFinite(i)?i:String(i);case"boolean":case"undefined":return i;case"bigint":case"symbol":return B(String(i),t.limits.maxValueLength);case"function":return`[Function: ${i.name||"anonymous"}]`}if(i===null)return null;let r=i;if(t.seen.has(r))return"[Circular]";if(e<0)return`[${X(r)}]`;t.seen.add(r);try{return Zn(r,e,t)}finally{t.seen.delete(r)}}function B(i,e){return i.length>e?i.slice(0,e)+"\u2026":i}function Zr(i,e,t){let r=i.length>t;i=B(i,t);let n=i.split(`
|
|
2
2
|
`);if(n.length<=e+1)return B(i,t);let o=n.slice(0,e+1).join(`
|
|
3
3
|
`),s=r?"[truncated]":`[+${n.length-e-1} frames]`;return B(`${o}
|
|
4
|
-
${s}`,t)}function Jn(i,e,t){let{limits:r}=t,n=X(i),o=c=>ot(c,e-1,t);if(n==="Date")return Number.isNaN(i.getTime())?"[Invalid Date]":i.toISOString();if(n==="RegExp")return B(String(i),r.maxValueLength);if(n==="ArrayBuffer")return`[ArrayBuffer(${i.byteLength})]`;if(ArrayBuffer.isView(i))return`[${n}(${i.byteLength})]`;if(n==="Map"||n==="Set"){let c=i,f=[];for(let g of c){if(f.length===r.maxBreadth)break;f.push(o(g))}return c.size>f.length&&f.push(`[+${c.size-f.length} more]`),f}if(n==="Promise"||n==="WeakMap"||n==="WeakSet"||n==="Window")return`[${n}]`;if(typeof Node<"u"&&i instanceof Node)return`[${n}]`;if(Array.isArray(i)){let c=i.slice(0,r.maxBreadth).map(o);return i.length>r.maxBreadth&&c.push(`[+${i.length-r.maxBreadth} more]`),c}if(typeof Response<"u"&&i instanceof Response)return{status:o(i.status),statusText:o(i.statusText),url:o(i.url),redirected:o(i.redirected)};if(typeof Event<"u"&&i instanceof Event){let c=i,f={type:o(c.type)};for(let g of["message","filename","lineno","colno"])g in c&&(f[g]=o(c[g]));return"error"in c&&c.error!=null&&(f.error=o(c.error)),f}let s=Object.create(null),a=i,p=zn(i);if(p){for(let f of Gn){if(f==="stack"&&!r.stack)continue;let g=a[f];if(!(g==null||typeof g=="function")){if(f==="stack"){r.stack&&typeof g=="string"&&(s.stack=pe(Zr(g,r.maxStackFrames,r.maxValueLength),t));continue}s[f]=o(g)}}let c=a.cause;c!=null&&typeof c!="function"&&(s.cause=Xn(c,e-1,t))}let d=0,l=Object.keys(a);for(let c of l){if(c in s||c==="stack"&&!r.stack||p&&c==="cause")continue;if(++d>r.maxBreadth){s["\u2026"]=`[+${l.length-r.maxBreadth} keys]`;break}let f=a[c];typeof f!="function"&&(s[pe(c,t)]=c==="stack"&&typeof f=="string"?pe(Zr(f,r.maxStackFrames,r.maxValueLength),t):o(f))}return!p&&n!=="Object"&&d===0?`[${n}]`:s}function Xn(i,e,t){if(typeof i!="object"||i===null)return ot(i,e,t);if(t.causeBudget<=0)return pe(`[${X(i)}]`,t);t.causeBudget--;try{return ot(i,e,t)}finally{t.causeBudget++}}function ri(){return{rawErrors:ti}}var Zn=500,eo=512*1024,ii=200,ni=200*1024,to=16*1024;function oi(i){let e=i.lane;if(e)return e;let t=new xt(i);return i.lane=t,i.enqueueProbe=(r,n=i.sessionId)=>{try{i.destroyed||t.enqueue(r,n)}catch(o){i.logger.error("Failed to enqueue probe",o)}},i.droppedProbeCount=()=>t.dropped,t}var ro=32,xt=class{constructor(e){this.queue=e}items=[];bytes=0;dropped=0;pageId;seqs=new Map;enqueue(e,t){let r=JSON.stringify(e.payload);if(typeof r!="string"||ie(r)>to){this.dropped++;return}let n={...e,payload:JSON.parse(r)},o=ie(JSON.stringify(n));for(this.items.push({sessionId:t,entry:n,bytes:o,attempts:0,flushAfter:0}),this.bytes+=o;this.items.length>Zn||this.bytes>eo&&this.items.length>1;){let s=this.items.shift();this.bytes-=s.bytes,this.dropped++}this.queue.scheduleFlush(this.queue.flushInterval(),"timer")}selectBatch(e,t){return this.select(e,t,ii,ni)}select(e,t,r,n){let o=[],s=0;for(let a of e){if(o.length>=r)break;if(a.sessionId===t){if(s+a.bytes>n){o.length===0&&n>=ni&&o.push(a);break}s+=a.bytes,o.push(a)}}return o}remove(e){if(e.length===0)return;let t=new Set(e);this.items=this.items.filter(r=>!t.has(r));for(let r of e)this.bytes-=r.bytes}drop(e){this.remove(e),this.dropped+=e.length}handleResult(e,t,r){if(t.length===0)return;let n=this.queue,o=e.statusCode;if(typeof o=="number"&&o>=200&&o<300){this.remove(t);return}if(!n.isRetryable(o)){this.drop(t);return}let s=Math.max(1,n.config.retry.maxAttempts),a=n.parseRetryAfter(e),p=[];for(let d of t)d.attempts+=1,d.attempts>=s?p.push(d):d.flushAfter=r+n.backoffForAttempt(d.attempts,a);this.drop(p)}sendUnload(e,t,r,n){let o=this.queue,s=o.sessionId,a={sessionId:s,events:[],sdk:o.sdk,probes:[]};o.attachBatchMeta(a,[],t);let p=ie(JSON.stringify(a))+120,d=e>p?this.select(this.items,s,ii,e-p):[];if(d.length>0){a.probes=d.map(c=>c.entry),o.attachBatchMeta(a,d,t);let l=o.transport;n&&o.config.beaconKeepalive&&l.sendBeacon?l.sendBeacon(a):Promise.resolve(l.send(a)).catch(()=>{}),this.remove(d)}r&&this.drop(this.items.slice())}defaultPageId(){return this.pageId??=no()}nextSeq(e){let t=this.seqs.get(e)??0;if(this.seqs.delete(e),this.seqs.set(e,t+1),this.seqs.size>ro){let r=this.seqs.keys().next().value;r!==void 0&&this.seqs.delete(r)}return t}},io="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";function no(){let i=new Uint8Array(16);try{crypto.getRandomValues(i)}catch{for(let t=0;t<i.length;t++)i[t]=Math.floor(Math.random()*256)}let e="";for(let t=0;t<i.length;t++)e+=io[i[t]&63];return e}var oo=/^[a-z][a-z0-9_-]{0,31}$/,si=/^[A-Za-z0-9_-]{1,16}$/,so=64;function ai(){return{setup:i=>{oi(i.queue)}}}function li(i,e){let t=i.getLogger();try{if(i.isTrackingBlocked()){t.debug("Skipping probe for blocked user agent.");return}let r=i.queue,n=r.lane;if(!n){t.debug("Dropping probe: no probes() plugin.");return}if(!e||typeof e!="object"||typeof e.kind!="string"||!oo.test(e.kind)){t.debug("Dropping probe with an invalid kind.");return}let o=e.payload;if(!o||typeof o!="object"){t.debug(`Dropping probe "${e.kind}" without an object payload.`);return}let s=typeof e.pageId=="string"&&si.test(e.pageId)?e.pageId:n.defaultPageId(),a={id:S(),kind:e.kind,ts:typeof e.ts=="number"&&Number.isFinite(e.ts)?Math.round(e.ts):Date.now(),pageId:s,seq:n.nextSeq(s),payload:o};typeof e.cfg=="string"&&si.test(e.cfg)&&(a.cfg=e.cfg);let p=ao(e.ctx);p&&(a.ctx=p),r.enqueueProbe(a)}catch(r){t.error("Failed to process probe before enqueue",r)}}function ao(i){if(!i||typeof i!="object")return;let e={};for(let t of["state","flowType","step"]){let r=i[t];typeof r=="string"&&r.length>0&&(e[t]=r.slice(0,so))}return Object.keys(e).length>0?e:void 0}function di(i={}){let e=i?.cookieDomain;return{storage:t=>({engine:new Ie(t,e),source:"cookie"})}}var lo="cbo_xs",ui="1",po=20;var co=/^[A-Za-z0-9._~-]{1,128}$/,uo=1e3,fo=300*1e3,ho=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,go=/^[A-Za-z0-9_-]{1,64}$/,mo=/^[a-z0-9-]+(\.[a-z0-9-]+)+$/,pi=/^\d{1,15}$/,yo=1e9,ci=1e3,vo=1e5;function Pt(i){return typeof i=="string"&&co.test(i)}function So(i){let e=i.split("."),[t,r,n,o]=e;if(e.length<4||t!==ui||!r||!ho.test(r)||!n||!pi.test(n)||!o||!pi.test(o)||Number(o)>yo)return;let s=e.length>4?e.slice(4).join("."):void 0;if(!(s!==void 0&&!Pt(s)))return{sessionId:r.toLowerCase(),lastActiveAt:Number(n),seqMark:Number(o),...s!==void 0&&{context:s}}}function bo(i){let e=[ui,i.sessionId,String(Math.floor(i.lastActiveAt)),String(Math.floor(i.seqMark))];return i.context!==void 0&&e.push(i.context),e.join(".")}function To(i,e){let t=i.trim().toLowerCase().replace(/^\./,""),r=e.toLowerCase();if(mo.test(t))return r===t||r.endsWith(`.${t}`)?t:void 0}var st=class i{constructor(e,t,r,n,o){this.name=e;this.domain=t;this.jar=r;this.contextJar=n;this.deps=o}enabled=!0;reservedFor;reservedMark=0;highestSeen=0;lastWriteAt=0;context;static create(e){try{if(typeof document>"u"||typeof window>"u")return;if(!go.test(e.projectId)){e.logger.debug("Cross-origin session off: project id is not cookie-safe");return}let t=e.scope?e.scope():Yt(0);if(!t.https){e.logger.debug("Cross-origin session off: page is not served over HTTPS");return}let r=To(e.cookieDomain,t.hostname);if(!r){e.logger.warn(`Cross-origin session off: "${e.cookieDomain}" is not the page's domain or a parent of it`),e.report("info","cross-origin session: cookieDomain does not match the page");return}let n=e.jar??oe(0),o=e.jar??oe(0);return new i(`${lo}_${e.projectId}`,r,n,o,e)}catch(t){e.logger.error("Cross-origin session setup failed",t);return}}isEnabled(){return this.enabled}stop(){this.enabled=!1}boot(e,t=Date.now()){if(this.enabled)try{let r=this.read(this.jar,t),n=e.sessionId,o=!1;r&&r.sessionId!==n&&(!n||e.lastActiveAt<=0||r.lastActiveAt>e.lastActiveAt)&&(n=r.sessionId,o=!0);let s=o?r?.seqMark??0:e.seq;if(n){let a=this.sync(this.jar,r,n,s,t,!0,!1);s=a.seq,this.isStored(a.value)||(this.enabled=!1,this.deps.logger.debug("Cross-origin session off: the cookie could not be stored"),this.deps.report("info","cross-origin session: cookie not stored"))}return{sessionId:n,seq:s,adopted:o}}catch(r){this.enabled=!1,this.deps.logger.error("Cross-origin session boot failed",r),this.deps.report("error","cross-origin session: boot failed");return}}claim(e,t,r=Date.now()){if(!this.enabled||!e)return t;try{let n=this.read(this.jar,r);this.follow(e);let o=n?.sessionId===e,s=o?this.plausibleMark(n.seqMark,t):void 0;if(s!==void 0&&(this.highestSeen=Math.max(this.highestSeen,s)),n&&!o){if(t<this.reservedMark)return t;let p=Math.max(t,this.highestSeen)+ci;return this.reservedMark=p+ci,this.highestSeen=this.reservedMark,p}let a=t>=this.reservedMark||s!==void 0&&s>this.reservedMark;return!a&&r-this.lastWriteAt<uo?t:this.sync(this.jar,n,e,t,r,a,!1).seq}catch(n){return this.deps.logger.error("Cross-origin session cookie update failed",n),t}}reset(e,t=Date.now()){if(!(!this.enabled||!e))try{this.reservedFor=void 0,this.follow(e),this.sync(this.jar,this.read(this.jar,t),e,0,t,!0,!0)}catch(r){this.deps.logger.error("Cross-origin session cookie reset failed",r)}}setContext(e,t,r,n=Date.now()){if(!(!this.enabled||!e))try{let o=this.read(this.contextJar,n);return this.follow(e),this.context=r,this.sync(this.contextJar,o,e,t,n,t>=this.reservedMark,!0).seq}catch(o){this.deps.logger.error("Cross-origin session context update failed",o);return}}getContext(e,t=Date.now()){if(!(!this.enabled||!e)){try{let r=this.read(this.contextJar,t);if(r?.sessionId===e)return this.reservedFor===e&&(this.context=r.context),r.context}catch(r){this.deps.logger.error("Cross-origin session context read failed",r)}return this.reservedFor===e?this.context:void 0}}follow(e){this.reservedFor!==e&&(this.reservedFor=e,this.reservedMark=0,this.highestSeen=0,this.context=void 0)}plausibleMark(e,t){if(e-t>vo){this.deps.report("info","cross-origin session: implausible seq mark ignored");return}return e}sync(e,t,r,n,o,s,a){this.follow(r);let p=t?.sessionId===r,d=p?this.plausibleMark(t.seqMark,n):void 0;d!==void 0&&(this.highestSeen=Math.max(this.highestSeen,d)),p&&!a&&(this.context=t.context);let l=n,c;s?(l=Math.max(n,d??0,this.highestSeen),c=l+po):c=Math.max(this.reservedMark,this.highestSeen,n);let f=bo({sessionId:r,lastActiveAt:o,seqMark:c,...this.context!==void 0&&{context:this.context}});return this.write(e,f),s&&(this.reservedMark=c),this.highestSeen=Math.max(this.highestSeen,c),this.lastWriteAt=o,{seq:l,value:f}}maxAgeSeconds(){return Math.max(60,Math.ceil(this.deps.inactivityMs()/1e3))}write(e,t){e.write(`${this.name}=${t}; Domain=${this.domain}; Path=/; Max-Age=${this.maxAgeSeconds()}; SameSite=Lax; Secure`)}rawValues(e){let t=`${this.name}=`;return e.read().split(";").map(r=>r.trim()).filter(r=>r.startsWith(t)).map(r=>r.substring(t.length))}isStored(e){try{return this.rawValues(this.jar).includes(e)}catch{return!1}}read(e,t){let r=this.deps.inactivityMs(),n;for(let o of this.rawValues(e)){let s=So(o);s&&t-s.lastActiveAt<r&&s.lastActiveAt<=t+fo&&(!n||s.lastActiveAt>n.lastActiveAt)&&(n=s)}return n}};function fi(i){let e=i&&typeof i=="object"?i.cookieDomain:void 0;return{session:t=>typeof e=="string"?ce.create(t,e):void 0}}var ce=class i{constructor(e,t){this.tracker=e;this.cookie=t}adoptedId;static create(e,t){try{if(e.isTrackingBlocked())return;let r=st.create({projectId:e.options.projectId,cookieDomain:t,logger:e.getLogger(),inactivityMs:()=>e.config.sessionInactivityMs,report:(n,o)=>e.reportTelemetry(n,o)});return r?new i(e,r):void 0}catch(r){e.getLogger().error("Failed to set up the cross-origin session",r);return}}resolve(){let e=this.tracker,t=this.readLocalSessionActivity();return e.sessionId=e.resolveSessionId(),this.boot(t),e.sessionId}claim(e,t,r){return this.cookie.claim(e,t,r)}meta(e){if(this.cookie.isEnabled())return e&&e===this.adoptedId?"adopted":"own"}reset(e){this.cookie.reset(e)}stop(){this.cookie.stop()}localSeq(){let e=this.tracker;return e.config.sessionContinuity?Math.max(e.seq,e.persistentStorage.getItem(I)??0):e.seq}readLocalSessionActivity(){let e=this.tracker,t=new Map;try{let r=e.persistentStorage.getItem(G);r?.id&&typeof r.lastActiveAt=="number"&&t.set(r.id,r.lastActiveAt);let n=e.sessionStorage.getItem(se);n&&typeof n=="object"&&n.id&&typeof n.lastActiveAt=="number"&&t.set(n.id,Math.max(t.get(n.id)??0,n.lastActiveAt))}catch(r){e.getLogger().error("Failed to read local session activity",r)}return t}boot(e){let t=this.tracker;try{this.adoptedId=void 0;let r=Date.now(),n=t.config.sessionContinuity,o=t.sessionId,s=this.cookie.boot({sessionId:o,lastActiveAt:o&&e.get(o)||0,seq:this.localSeq()},r);if(!s||!s.sessionId)return;s.adopted&&(t.sessionId=s.sessionId,this.adoptedId=s.sessionId,n?t.persistContinuitySession(s.sessionId,r):t.persistPerTabSession(s.sessionId,r),t.getLogger().debug("Adopted cross-origin session id",s.sessionId)),t.seq=s.seq,n&&t.persistentStorage.setItem(I,s.seq)}catch(r){t.getLogger().error("Failed to apply the cross-origin session",r)}}};function hi(i,e){try{let t=i.bridge;if(!(t instanceof ce))return!1;let r=e==null||e===""?void 0:e;if(r!==void 0&&!Pt(r))return i.getLogger().debug("Ignoring invalid cross-origin context (expected <= 128 chars of [A-Za-z0-9._~-])"),!1;let n=t.cookie.setContext(i.sessionId,t.localSeq(),r);return n===void 0?!1:(n>i.seq&&(i.seq=n,i.config.sessionContinuity&&i.persistentStorage.setItem(I,n)),!0)}catch(t){return i.getLogger().error("Failed to set the cross-origin context",t),!1}}function gi(i){try{let e=i.bridge;return e instanceof ce?e.cookie.getContext(i.sessionId):void 0}catch(e){i.getLogger().error("Failed to read the cross-origin context",e);return}}function wo(i){let e=[ri(),ai()];i.storage==="cookie"&&e.push(di({cookieDomain:i.cookieDomain}));let t=me(i.fixedDataConfig)?.crossOriginSession;return t&&e.push(fi(t)),e}var at=class extends De{constructor(e){super(e,wo(e))}isFullTracker(){return!0}setExperiment(e,t){this.setExperiments({[e]:t})}clearExperiment(e){Gr(this,e)}clearExperiments(){jr(this)}trackSubflowError(e,t,r){Jr(this,e,t,r)}conversion(e,t,r){Qr(this,e,t,r)}setUser(e){Vr(this,e)}setFlowTags(e,t){$r(this,e,t)}authDecisionStarted(e,t,r){zr(this,e,t,r)}authDecisionFinished(e,t,r){Yr(this,e,t,r)}probe(e){li(this,e)}logInfo(e){this.telemetry("info",e)}logError(e){this.telemetry("error",e)}passkeyLoginFullOperation(e){return new Ae(this,e)}passkeyEnrollmentFullOperation(e){return new We(this,e)}passkeyDeletionOperationFull(e){return new Ve(this,e)}passwordLoginFullOperation(e){return new $e(this,e)}passwordEnrollmentFullOperation(e){return new Ge(this,e)}emailLinkOperationFull(e){return new qe(this,e)}continueEmailLinkOperation(e){return new Ke(this,e)}emailOtpOperationFull(e){return new Ne(this,e)}smsOtpOperationFull(e){return new Ue(this,e)}totpOperationFull(e){return new Ye(this,e)}provideIdentifierOperationFull(e){return new je(this,e)}provideDataOperationFull(e){return new nt(this,e)}formOperationFull(e){return new et(this,e)}socialLoginOperationFull(e){return new Qe(this,e)}ssoLoginOperationFull(e){return new ze(this,e)}appConfirmationOperationFull(e){return new Je(this,e)}keySigningOperationFull(e){return new fe(this,e)}keyRegistrationOperationFull(e){return new he(this,e)}captchaOperationFull(e){return new Xe(this,e)}trustedDeviceCheckOperationFull(e){return new rt(this,e)}trustedDeviceEnrollmentOperationFull(e){return new it(this,e)}setCrossOriginContext(e){return hi(this,e)}getCrossOriginContext(){return gi(this)}resetSession(){return Wr(this)}};function lt(i,e,t){let r=window.Corbado;r?.[e]&&(t(r[e]),delete window.Corbado[e])}function mi(i,e){window.Corbado=e}var Ft={};function yi(i,e="default"){Ft[e]=new at(i)}function vi(i="default"){if(!Ft[i])throw new Error(`Tracker ${i} not initialized (call Corbado.init() first)`);return Ft[i]}function Eo(i){for(let e of i)yi(e[0],e[1])}var Si={};function bi(i,e,t=[],r){let n=vi(i),o=n[e];if(typeof o!="function")return;let s=o.apply(n,t);r&&s&&typeof s=="object"&&(Si[r]=s)}function Ti(i,e,t=[]){let r=Si[i];if(!r)return;let n=e.split("."),o=r;for(let a=0;a<n.length-1;a++)if(o=o?.[n[a]],!o)return;let s=o[n[n.length-1]];typeof s=="function"&&s.apply(o,t)}function Co(i){for(let e of i)bi(e[0],e[1],Array.isArray(e[2])?e[2]:[],e[3])}function ko(i){for(let e of i)Ti(e[0],e[1],Array.isArray(e[2])?e[2]:[])}typeof window<"u"&&(lt(0,"IQ",Eo),lt(0,"MQ",Co),lt(0,"OQ",ko),mi(0,{init:yi,get:vi,__dispatchMethod:bi,__dispatchOp:Ti}));})();
|
|
4
|
+
${s}`,t)}function Zn(i,e,t){let{limits:r}=t,n=X(i),o=c=>ot(c,e-1,t);if(n==="Date")return Number.isNaN(i.getTime())?"[Invalid Date]":i.toISOString();if(n==="RegExp")return B(String(i),r.maxValueLength);if(n==="ArrayBuffer")return`[ArrayBuffer(${i.byteLength})]`;if(ArrayBuffer.isView(i))return`[${n}(${i.byteLength})]`;if(n==="Map"||n==="Set"){let c=i,f=[];for(let g of c){if(f.length===r.maxBreadth)break;f.push(o(g))}return c.size>f.length&&f.push(`[+${c.size-f.length} more]`),f}if(n==="Promise"||n==="WeakMap"||n==="WeakSet"||n==="Window")return`[${n}]`;if(typeof Node<"u"&&i instanceof Node)return`[${n}]`;if(Array.isArray(i)){let c=i.slice(0,r.maxBreadth).map(o);return i.length>r.maxBreadth&&c.push(`[+${i.length-r.maxBreadth} more]`),c}if(typeof Response<"u"&&i instanceof Response)return{status:o(i.status),statusText:o(i.statusText),url:o(i.url),redirected:o(i.redirected)};if(typeof Event<"u"&&i instanceof Event){let c=i,f={type:o(c.type)};for(let g of["message","filename","lineno","colno"])g in c&&(f[g]=o(c[g]));return"error"in c&&c.error!=null&&(f.error=o(c.error)),f}let s=Object.create(null),a=i,p=Jn(i);if(p){for(let f of Qn){if(f==="stack"&&!r.stack)continue;let g=a[f];if(!(g==null||typeof g=="function")){if(f==="stack"){r.stack&&typeof g=="string"&&(s.stack=pe(Zr(g,r.maxStackFrames,r.maxValueLength),t));continue}s[f]=o(g)}}let c=a.cause;c!=null&&typeof c!="function"&&(s.cause=eo(c,e-1,t))}let d=0,l=Object.keys(a);for(let c of l){if(c in s||c==="stack"&&!r.stack||p&&c==="cause")continue;if(++d>r.maxBreadth){s["\u2026"]=`[+${l.length-r.maxBreadth} keys]`;break}let f=a[c];typeof f!="function"&&(s[pe(c,t)]=c==="stack"&&typeof f=="string"?pe(Zr(f,r.maxStackFrames,r.maxValueLength),t):o(f))}return!p&&n!=="Object"&&d===0?`[${n}]`:s}function eo(i,e,t){if(typeof i!="object"||i===null)return ot(i,e,t);if(t.causeBudget<=0)return pe(`[${X(i)}]`,t);t.causeBudget--;try{return ot(i,e,t)}finally{t.causeBudget++}}function ri(){return{rawErrors:ti}}var to=500,ro=512*1024,ii=200,ni=200*1024,io=16*1024;function oi(i){let e=i.lane;if(e)return e;let t=new xt(i);return i.lane=t,i.enqueueProbe=(r,n=i.sessionId)=>{try{i.destroyed||t.enqueue(r,n)}catch(o){i.logger.error("Failed to enqueue probe",o)}},i.droppedProbeCount=()=>t.dropped,t}var no=32,xt=class{constructor(e){this.queue=e}items=[];bytes=0;dropped=0;pageId;seqs=new Map;enqueue(e,t){let r=JSON.stringify(e.payload);if(typeof r!="string"||ie(r)>io){this.dropped++;return}let n={...e,payload:JSON.parse(r)},o=ie(JSON.stringify(n));for(this.items.push({sessionId:t,entry:n,bytes:o,attempts:0,flushAfter:0}),this.bytes+=o;this.items.length>to||this.bytes>ro&&this.items.length>1;){let s=this.items.shift();this.bytes-=s.bytes,this.dropped++}this.queue.scheduleFlush(this.queue.flushInterval(),"timer")}selectBatch(e,t){return this.select(e,t,ii,ni)}select(e,t,r,n){let o=[],s=0;for(let a of e){if(o.length>=r)break;if(a.sessionId===t){if(s+a.bytes>n){o.length===0&&n>=ni&&o.push(a);break}s+=a.bytes,o.push(a)}}return o}remove(e){if(e.length===0)return;let t=new Set(e);this.items=this.items.filter(r=>!t.has(r));for(let r of e)this.bytes-=r.bytes}drop(e){this.remove(e),this.dropped+=e.length}handleResult(e,t,r){if(t.length===0)return;let n=this.queue,o=e.statusCode;if(typeof o=="number"&&o>=200&&o<300){this.remove(t);return}if(!n.isRetryable(o)){this.drop(t);return}let s=Math.max(1,n.config.retry.maxAttempts),a=n.parseRetryAfter(e),p=[];for(let d of t)d.attempts+=1,d.attempts>=s?p.push(d):d.flushAfter=r+n.backoffForAttempt(d.attempts,a);this.drop(p)}sendUnload(e,t,r,n){let o=this.queue,s=o.sessionId,a={sessionId:s,events:[],sdk:o.sdk,probes:[]};o.attachBatchMeta(a,[],t);let p=ie(JSON.stringify(a))+120,d=e>p?this.select(this.items,s,ii,e-p):[];if(d.length>0){a.probes=d.map(c=>c.entry),o.attachBatchMeta(a,d,t);let l=o.transport;n&&o.config.beaconKeepalive&&l.sendBeacon?l.sendBeacon(a):Promise.resolve(l.send(a)).catch(()=>{}),this.remove(d)}r&&this.drop(this.items.slice())}defaultPageId(){return this.pageId??=so()}nextSeq(e){let t=this.seqs.get(e)??0;if(this.seqs.delete(e),this.seqs.set(e,t+1),this.seqs.size>no){let r=this.seqs.keys().next().value;r!==void 0&&this.seqs.delete(r)}return t}},oo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";function so(){let i=new Uint8Array(16);try{crypto.getRandomValues(i)}catch{for(let t=0;t<i.length;t++)i[t]=Math.floor(Math.random()*256)}let e="";for(let t=0;t<i.length;t++)e+=oo[i[t]&63];return e}var ao=/^[a-z][a-z0-9_-]{0,31}$/,si=/^[A-Za-z0-9_-]{1,16}$/,lo=64;function ai(){return{setup:i=>{oi(i.queue)}}}function li(i,e){let t=i.getLogger();try{if(i.isTrackingBlocked()){t.debug("Skipping probe for blocked user agent.");return}let r=i.queue,n=r.lane;if(!n){t.debug("Dropping probe: no probes() plugin.");return}if(!e||typeof e!="object"||typeof e.kind!="string"||!ao.test(e.kind)){t.debug("Dropping probe with an invalid kind.");return}let o=e.payload;if(!o||typeof o!="object"){t.debug(`Dropping probe "${e.kind}" without an object payload.`);return}let s=typeof e.pageId=="string"&&si.test(e.pageId)?e.pageId:n.defaultPageId(),a={id:S(),kind:e.kind,ts:typeof e.ts=="number"&&Number.isFinite(e.ts)?Math.round(e.ts):Date.now(),pageId:s,seq:n.nextSeq(s),payload:o};typeof e.cfg=="string"&&si.test(e.cfg)&&(a.cfg=e.cfg);let p=po(e.ctx);p&&(a.ctx=p),r.enqueueProbe(a)}catch(r){t.error("Failed to process probe before enqueue",r)}}function po(i){if(!i||typeof i!="object")return;let e={};for(let t of["state","flowType","step"]){let r=i[t];typeof r=="string"&&r.length>0&&(e[t]=r.slice(0,lo))}return Object.keys(e).length>0?e:void 0}function di(i={}){let e=i?.cookieDomain;return{storage:t=>({engine:new Ie(t,e),source:"cookie"})}}var co="cbo_xs",ui="1",uo=20;var fo=/^[A-Za-z0-9._~-]{1,128}$/,ho=1e3,go=300*1e3,mo=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,yo=/^[A-Za-z0-9_-]{1,64}$/,vo=/^[a-z0-9-]+(\.[a-z0-9-]+)+$/,pi=/^\d{1,15}$/,So=1e9,ci=1e3,bo=1e5;function Pt(i){return typeof i=="string"&&fo.test(i)}function To(i){let e=i.split("."),[t,r,n,o]=e;if(e.length<4||t!==ui||!r||!mo.test(r)||!n||!pi.test(n)||!o||!pi.test(o)||Number(o)>So)return;let s=e.length>4?e.slice(4).join("."):void 0;if(!(s!==void 0&&!Pt(s)))return{sessionId:r.toLowerCase(),lastActiveAt:Number(n),seqMark:Number(o),...s!==void 0&&{context:s}}}function wo(i){let e=[ui,i.sessionId,String(Math.floor(i.lastActiveAt)),String(Math.floor(i.seqMark))];return i.context!==void 0&&e.push(i.context),e.join(".")}function Eo(i,e){let t=i.trim().toLowerCase().replace(/^\./,""),r=e.toLowerCase();if(vo.test(t))return r===t||r.endsWith(`.${t}`)?t:void 0}var st=class i{constructor(e,t,r,n,o){this.name=e;this.domain=t;this.jar=r;this.contextJar=n;this.deps=o}enabled=!0;reservedFor;reservedMark=0;highestSeen=0;lastWriteAt=0;context;static create(e){try{if(typeof document>"u"||typeof window>"u")return;if(!yo.test(e.projectId)){e.logger.debug("Cross-origin session off: project id is not cookie-safe");return}let t=e.scope?e.scope():Yt(0);if(!t.https){e.logger.debug("Cross-origin session off: page is not served over HTTPS");return}let r=Eo(e.cookieDomain,t.hostname);if(!r){e.logger.warn(`Cross-origin session off: "${e.cookieDomain}" is not the page's domain or a parent of it`),e.report("info","cross-origin session: cookieDomain does not match the page");return}let n=e.jar??oe(0),o=e.jar??oe(0);return new i(`${co}_${e.projectId}`,r,n,o,e)}catch(t){e.logger.error("Cross-origin session setup failed",t);return}}isEnabled(){return this.enabled}stop(){this.enabled=!1}boot(e,t=Date.now()){if(this.enabled)try{let r=this.read(this.jar,t),n=e.sessionId,o=!1;r&&r.sessionId!==n&&(!n||e.lastActiveAt<=0||r.lastActiveAt>e.lastActiveAt)&&(n=r.sessionId,o=!0);let s=o?r?.seqMark??0:e.seq;if(n){let a=this.sync(this.jar,r,n,s,t,!0,!1);s=a.seq,this.isStored(a.value)||(this.enabled=!1,this.deps.logger.debug("Cross-origin session off: the cookie could not be stored"),this.deps.report("info","cross-origin session: cookie not stored"))}return{sessionId:n,seq:s,adopted:o}}catch(r){this.enabled=!1,this.deps.logger.error("Cross-origin session boot failed",r),this.deps.report("error","cross-origin session: boot failed");return}}claim(e,t,r=Date.now()){if(!this.enabled||!e)return t;try{let n=this.read(this.jar,r);this.follow(e);let o=n?.sessionId===e,s=o?this.plausibleMark(n.seqMark,t):void 0;if(s!==void 0&&(this.highestSeen=Math.max(this.highestSeen,s)),n&&!o){if(t<this.reservedMark)return t;let p=Math.max(t,this.highestSeen)+ci;return this.reservedMark=p+ci,this.highestSeen=this.reservedMark,p}let a=t>=this.reservedMark||s!==void 0&&s>this.reservedMark;return!a&&r-this.lastWriteAt<ho?t:this.sync(this.jar,n,e,t,r,a,!1).seq}catch(n){return this.deps.logger.error("Cross-origin session cookie update failed",n),t}}reset(e,t=Date.now()){if(!(!this.enabled||!e))try{this.reservedFor=void 0,this.follow(e),this.sync(this.jar,this.read(this.jar,t),e,0,t,!0,!0)}catch(r){this.deps.logger.error("Cross-origin session cookie reset failed",r)}}setContext(e,t,r,n=Date.now()){if(!(!this.enabled||!e))try{let o=this.read(this.contextJar,n);return this.follow(e),this.context=r,this.sync(this.contextJar,o,e,t,n,t>=this.reservedMark,!0).seq}catch(o){this.deps.logger.error("Cross-origin session context update failed",o);return}}getContext(e,t=Date.now()){if(!(!this.enabled||!e)){try{let r=this.read(this.contextJar,t);if(r?.sessionId===e)return this.reservedFor===e&&(this.context=r.context),r.context}catch(r){this.deps.logger.error("Cross-origin session context read failed",r)}return this.reservedFor===e?this.context:void 0}}follow(e){this.reservedFor!==e&&(this.reservedFor=e,this.reservedMark=0,this.highestSeen=0,this.context=void 0)}plausibleMark(e,t){if(e-t>bo){this.deps.report("info","cross-origin session: implausible seq mark ignored");return}return e}sync(e,t,r,n,o,s,a){this.follow(r);let p=t?.sessionId===r,d=p?this.plausibleMark(t.seqMark,n):void 0;d!==void 0&&(this.highestSeen=Math.max(this.highestSeen,d)),p&&!a&&(this.context=t.context);let l=n,c;s?(l=Math.max(n,d??0,this.highestSeen),c=l+uo):c=Math.max(this.reservedMark,this.highestSeen,n);let f=wo({sessionId:r,lastActiveAt:o,seqMark:c,...this.context!==void 0&&{context:this.context}});return this.write(e,f),s&&(this.reservedMark=c),this.highestSeen=Math.max(this.highestSeen,c),this.lastWriteAt=o,{seq:l,value:f}}maxAgeSeconds(){return Math.max(60,Math.ceil(this.deps.inactivityMs()/1e3))}write(e,t){e.write(`${this.name}=${t}; Domain=${this.domain}; Path=/; Max-Age=${this.maxAgeSeconds()}; SameSite=Lax; Secure`)}rawValues(e){let t=`${this.name}=`;return e.read().split(";").map(r=>r.trim()).filter(r=>r.startsWith(t)).map(r=>r.substring(t.length))}isStored(e){try{return this.rawValues(this.jar).includes(e)}catch{return!1}}read(e,t){let r=this.deps.inactivityMs(),n;for(let o of this.rawValues(e)){let s=To(o);s&&t-s.lastActiveAt<r&&s.lastActiveAt<=t+go&&(!n||s.lastActiveAt>n.lastActiveAt)&&(n=s)}return n}};function fi(i){let e=i&&typeof i=="object"?i.cookieDomain:void 0;return{session:t=>typeof e=="string"?ce.create(t,e):void 0}}var ce=class i{constructor(e,t){this.tracker=e;this.cookie=t}adoptedId;static create(e,t){try{if(e.isTrackingBlocked())return;let r=st.create({projectId:e.options.projectId,cookieDomain:t,logger:e.getLogger(),inactivityMs:()=>e.config.sessionInactivityMs,report:(n,o)=>e.reportTelemetry(n,o)});return r?new i(e,r):void 0}catch(r){e.getLogger().error("Failed to set up the cross-origin session",r);return}}resolve(){let e=this.tracker,t=this.readLocalSessionActivity();return e.sessionId=e.resolveSessionId(),this.boot(t),e.sessionId}claim(e,t,r){return this.cookie.claim(e,t,r)}meta(e){if(this.cookie.isEnabled())return e&&e===this.adoptedId?"adopted":"own"}reset(e){this.cookie.reset(e)}stop(){this.cookie.stop()}localSeq(){let e=this.tracker;return e.config.sessionContinuity?Math.max(e.seq,e.persistentStorage.getItem(I)??0):e.seq}readLocalSessionActivity(){let e=this.tracker,t=new Map;try{let r=e.persistentStorage.getItem(G);r?.id&&typeof r.lastActiveAt=="number"&&t.set(r.id,r.lastActiveAt);let n=e.sessionStorage.getItem(se);n&&typeof n=="object"&&n.id&&typeof n.lastActiveAt=="number"&&t.set(n.id,Math.max(t.get(n.id)??0,n.lastActiveAt))}catch(r){e.getLogger().error("Failed to read local session activity",r)}return t}boot(e){let t=this.tracker;try{this.adoptedId=void 0;let r=Date.now(),n=t.config.sessionContinuity,o=t.sessionId,s=this.cookie.boot({sessionId:o,lastActiveAt:o&&e.get(o)||0,seq:this.localSeq()},r);if(!s||!s.sessionId)return;s.adopted&&(t.sessionId=s.sessionId,this.adoptedId=s.sessionId,n?t.persistContinuitySession(s.sessionId,r):t.persistPerTabSession(s.sessionId,r),t.getLogger().debug("Adopted cross-origin session id",s.sessionId)),t.seq=s.seq,n&&t.persistentStorage.setItem(I,s.seq)}catch(r){t.getLogger().error("Failed to apply the cross-origin session",r)}}};function hi(i,e){try{let t=i.bridge;if(!(t instanceof ce))return!1;let r=e==null||e===""?void 0:e;if(r!==void 0&&!Pt(r))return i.getLogger().debug("Ignoring invalid cross-origin context (expected <= 128 chars of [A-Za-z0-9._~-])"),!1;let n=t.cookie.setContext(i.sessionId,t.localSeq(),r);return n===void 0?!1:(n>i.seq&&(i.seq=n,i.config.sessionContinuity&&i.persistentStorage.setItem(I,n)),!0)}catch(t){return i.getLogger().error("Failed to set the cross-origin context",t),!1}}function gi(i){try{let e=i.bridge;return e instanceof ce?e.cookie.getContext(i.sessionId):void 0}catch(e){i.getLogger().error("Failed to read the cross-origin context",e);return}}function Co(i){let e=[ri(),ai()];i.storage==="cookie"&&e.push(di({cookieDomain:i.cookieDomain}));let t=me(i.fixedDataConfig)?.crossOriginSession;return t&&e.push(fi(t)),e}var at=class extends Ae{constructor(e){super(e,Co(e))}isFullTracker(){return!0}setExperiment(e,t){this.setExperiments({[e]:t})}clearExperiment(e){Gr(this,e)}clearExperiments(){jr(this)}trackSubflowError(e,t,r){Jr(this,e,t,r)}conversion(e,t,r){Qr(this,e,t,r)}setUser(e){Vr(this,e)}setFlowTags(e,t){$r(this,e,t)}authDecisionStarted(e,t,r){zr(this,e,t,r)}authDecisionFinished(e,t,r){Yr(this,e,t,r)}probe(e){li(this,e)}logInfo(e){this.telemetry("info",e)}logError(e){this.telemetry("error",e)}passkeyLoginFullOperation(e){return new De(this,e)}passkeyEnrollmentFullOperation(e){return new We(this,e)}passkeyDeletionOperationFull(e){return new Ve(this,e)}passwordLoginFullOperation(e){return new $e(this,e)}passwordEnrollmentFullOperation(e){return new Ge(this,e)}emailLinkOperationFull(e){return new qe(this,e)}continueEmailLinkOperation(e){return new Ke(this,e)}emailOtpOperationFull(e){return new Ue(this,e)}smsOtpOperationFull(e){return new Ne(this,e)}totpOperationFull(e){return new Ye(this,e)}provideIdentifierOperationFull(e){return new je(this,e)}provideDataOperationFull(e){return new nt(this,e)}formOperationFull(e){return new et(this,e)}socialLoginOperationFull(e){return new Qe(this,e)}ssoLoginOperationFull(e){return new ze(this,e)}appConfirmationOperationFull(e){return new Je(this,e)}keySigningOperationFull(e){return new fe(this,e)}keyRegistrationOperationFull(e){return new he(this,e)}captchaOperationFull(e){return new Xe(this,e)}trustedDeviceCheckOperationFull(e){return new rt(this,e)}trustedDeviceEnrollmentOperationFull(e){return new it(this,e)}setCrossOriginContext(e){return hi(this,e)}getCrossOriginContext(){return gi(this)}resetSession(){return Wr(this)}};function lt(i,e,t){let r=window.Corbado;r?.[e]&&(t(r[e]),delete window.Corbado[e])}function mi(i,e){window.Corbado=e}var Ft={};function yi(i,e="default"){Ft[e]=new at(i)}function vi(i="default"){if(!Ft[i])throw new Error(`Tracker ${i} not initialized (call Corbado.init() first)`);return Ft[i]}function ko(i){for(let e of i)yi(e[0],e[1])}var Si={};function bi(i,e,t=[],r){let n=vi(i),o=n[e];if(typeof o!="function")return;let s=o.apply(n,t);r&&s&&typeof s=="object"&&(Si[r]=s)}function Ti(i,e,t=[]){let r=Si[i];if(!r)return;let n=e.split("."),o=r;for(let a=0;a<n.length-1;a++)if(o=o?.[n[a]],!o)return;let s=o[n[n.length-1]];typeof s=="function"&&s.apply(o,t)}function Oo(i){for(let e of i)bi(e[0],e[1],Array.isArray(e[2])?e[2]:[],e[3])}function Io(i){for(let e of i)Ti(e[0],e[1],Array.isArray(e[2])?e[2]:[])}typeof window<"u"&&(lt(0,"IQ",ko),lt(0,"MQ",Oo),lt(0,"OQ",Io),mi(0,{init:yi,get:vi,__dispatchMethod:bi,__dispatchOp:Ti}));})();
|
|
5
5
|
/*! Bundled license information:
|
|
6
6
|
|
|
7
7
|
detectincognitojs/dist/detectIncognito.esm.js:
|