@corbado/observe 1.4.0 → 1.5.1
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/dist/cdn/script.global.js +36 -5
- package/dist/index.d.mts +35 -18
- package/dist/index.d.ts +35 -18
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/package.json +2 -2
|
@@ -1,13 +1,44 @@
|
|
|
1
|
-
"use strict";(()=>{var ct=0;function
|
|
2
|
-
`);if(
|
|
3
|
-
`),s=
|
|
4
|
-
${s}`,t)}function vr(n,e,t){let{limits:r}=t,i=B(n),o=u=>ee(u,e-1,t);if(i==="Date")return Number.isNaN(n.getTime())?"[Invalid Date]":n.toISOString();if(i==="RegExp")return L(String(n),r.maxValueLength);if(i==="ArrayBuffer")return`[ArrayBuffer(${n.byteLength})]`;if(ArrayBuffer.isView(n))return`[${i}(${n.byteLength})]`;if(i==="Map"||i==="Set"){let u=n,c=[];for(let f of u){if(c.length===r.maxBreadth)break;c.push(o(f))}return u.size>c.length&&c.push(`[+${u.size-c.length} more]`),c}if(i==="Promise"||i==="WeakMap"||i==="WeakSet"||i==="Window")return`[${i}]`;if(typeof Node<"u"&&n instanceof Node)return`[${i}]`;if(Array.isArray(n)){let u=n.slice(0,r.maxBreadth).map(o);return n.length>r.maxBreadth&&u.push(`[+${n.length-r.maxBreadth} more]`),u}if(typeof Response<"u"&&n instanceof Response)return{status:o(n.status),statusText:o(n.statusText),url:o(n.url),redirected:o(n.redirected)};if(typeof Event<"u"&&n instanceof Event){let u=n,c={type:o(u.type)};for(let f of["message","filename","lineno","colno"])f in u&&(c[f]=o(u[f]));return"error"in u&&u.error!=null&&(c.error=o(u.error)),c}let s=Object.create(null),a=n,l=mr(n);if(l){for(let c of hr){if(c==="stack"&&!r.stack)continue;let f=a[c];if(!(f==null||typeof f=="function")){if(c==="stack"){r.stack&&typeof f=="string"&&(s.stack=j(yt(f,r.maxStackFrames,r.maxValueLength),t));continue}s[c]=o(f)}}let u=a.cause;u!=null&&typeof u!="function"&&(s.cause=Sr(u,e-1,t))}let d=0,p=Object.keys(a);for(let u of p){if(u in s||u==="stack"&&!r.stack||l&&u==="cause")continue;if(++d>r.maxBreadth){s["\u2026"]=`[+${p.length-r.maxBreadth} keys]`;break}let c=a[u];typeof c!="function"&&(s[j(u,t)]=u==="stack"&&typeof c=="string"?j(yt(c,r.maxStackFrames,r.maxValueLength),t):o(c))}return!l&&i!=="Object"&&d===0?`[${i}]`:s}function Sr(n,e,t){if(typeof n!="object"||n===null)return ee(n,e,t);if(t.causeBudget<=0)return j(`[${B(n)}]`,t);t.causeBudget--;try{return ee(n,e,t)}finally{t.causeBudget++}}var br=1500,g=class{constructor(e,t){this.tracker=e;this.operationName=t}startReference;captureSpecType;captureSessionId;lowFlushers=[];lowPrefillCapturers=[];lowEventSink(e,t){return{reserveCaptureSeq:k,enqueueLowEvent:r=>this.tracker.enqueueLowEvent({...r,captureSeq:r.captureSeq??k(),subflowStartEventId:this.startReference,sourceKind:e,fieldRole:t,initiator:r.initiator??(t?`input-${t}`:"unknown")},this.captureSessionId),flushKeepalive:()=>this.tracker.lowEventFlushKeepalive(),registerInputs:(r,i)=>this.tracker.getWindowObserver().registerInputs(r,()=>({subflowStartEventId:this.startReference,fieldRole:t,initiator:t?`input-${t}`:"unknown",sessionId:this.captureSessionId}),i),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,i){if(!t&&!i)return e;let o={};return t&&(o.subflowStartEventId=e?.subflowStartEventId??t,o.captureSessionId=e?.captureSessionId??r),i&&(o.initiator=e?.initiator??i),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(i){this.tracker.getLogger().error("Failed to flush previous low-event context",i)}this.captureSpecType=e?.explicitSpecType,this.startReference=v(),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,i){this.captureSpecType=t?.explicitSpecType??this.captureSpecType,this.tracker.trackSubflowStepStarted(this.operationName,e,t,this.captureOptions(r),i)}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 i=t;try{let o=this.tracker.getSdkConfig().rawErrors?r?.rawError:void 0;o!==void 0&&(i={...t,rawError:St(o,r?.rawErrorLimits)})}catch{}this.tracker.trackSubflowStepError(this.operationName,e,i,this.captureOptions(r))}withWindowLowEvents(e,t){let r,i=s=>{s?.subflowStartEventId&&s.subflowStartEventId!==r||t.scheduleDisarm(br)},o=e;return{...e,start:(s,a)=>{r=a?.subflowStartEventId??this.startReference;let l=s?.explicitSpecType??this.captureSpecType,d=a?.initiator??ht(this.operationName,l);t.arm(d,l==="passkey-cui"),o.start(s,d?{...a,initiator:d}:a)},finished:(s,a)=>{o.finished(s,a),i(a)},error:(s,a)=>{o.error(s,a),i(a)},errorTyped:(s,a)=>{o.errorTyped?.(s,a),i(a)}}}defineStep(e,t){let r,i,o,s=l=>this.captureOptions(l,r,i,o);return{start:(l,d)=>{r=this.startReference,i=this.captureSessionId,o=d?.initiator,this.subflowStepStarted(e,l,s(d),t)},finished:(l,d)=>{this.subflowStepFinished(e,l,s(d))},error:(l,d)=>{this.subflowStepError(e,{error:D(l)},s(d))},errorTyped:(l,d)=>{this.subflowStepError(e,l,s(d))}}}};function bt(n,e){if(e.explicitSpecType!==void 0)try{n.getLogger().warn("Unsupported key operation spec type; omitting it")}catch{}}var te=class extends g{prepare;sign;constructor(e,t={}){super(e,"key-signing"),this.prepare=this.defineStep("prepare"),this.sign=this.defineStep("sign"),this.subflowStart({actor:"system",explicitSpecType:bt(e,t)})}},re=class extends g{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:bt(e,t)})}};function wr(n){try{return decodeURIComponent(n.replace(/\+/g," "))}catch{return n}}function Tr(n,e){let t=n.toLowerCase();return e.some(r=>{let i=r.toLowerCase();return i.endsWith("*")?t.startsWith(i.slice(0,-1)):t===i})}function wt(n,e,t){return e!=="allowlist"||n===""||n==="?"?n:`?${(n.startsWith("?")?n.slice(1):n).split("&").map(o=>{let s=o.indexOf("=");if(s===-1)return o;let a=o.slice(0,s);return o.slice(s+1)===""||Tr(wr(a),t)?o:`${a}=*`}).join("&")}`}var Ve=(n,e,t)=>{let r=!1,i,o=null,s=null,a=()=>{s!==null&&(window.clearTimeout(s),s=null);let d=o;r=!1,o=null,d!==null&&n({...i===void 0?{}:{captureSeq:i},lowType:e,ts:d,durationMs:Date.now()-d})};return{extend:()=>{if(!r){let d=t?.();r=!0,o=Date.now(),i=d}s!==null&&window.clearTimeout(s),s=window.setTimeout(a,150)},flush:a}};var Er,ne=()=>Er??=v(),xr=()=>{let n=[];for(let e=document.activeElement;e;e=e.shadowRoot?.activeElement??null)n.push(e);return n},ie=class{constructor(e,t,r){this.logger=e;this.enqueue=t;this.flushKeepalive=r;typeof window>"u"||typeof document>"u"||(this.listen(window,"blur",()=>{this.flushInputs(),this.bracket=this.context(),this.emit({lowType:"window-blur",ts:Date.now()},this.bracket)}),this.listen(window,"focus",()=>{this.flushInputs(),this.emit({lowType:"window-focus",ts:Date.now()},this.bracket??this.context()),this.bracket=void 0}),this.listen(document,"visibilitychange",()=>{this.flushInputs(),this.emit({lowType:`document-visibilitychange-${document.visibilityState==="hidden"?"hidden":"visible"}`,ts:Date.now()})}),this.listen(document,"focusout",i=>{let o=this.findInput(i.target);this.lastBlur=o&&!i.relatedTarget&&Date.now()-this.unrelatedPointerAt>250?{registration:o,ts:Date.now()}:void 0}),this.listen(document,"focusin",i=>{this.lastBlur=void 0;let o=this.inputFocusListeners.size>0&&i.composedPath().find(s=>this.findInput(s));o&&this.notifyInputFocus(o)}),this.listen(document,"pointerdown",i=>{this.findInput(i.target)?this.unrelatedPointerAt=-1/0:(this.lastBlur=void 0,this.unrelatedPointerAt=Date.now())}),window.visualViewport&&(this.listen(window.visualViewport,"resize",()=>this.extendViewport("resize")),this.listen(window.visualViewport,"scroll",()=>this.extendViewport("scroll"))),this.listen(window,"pagehide",()=>{this.flushInputs(),this.resize.flush(),this.scroll.flush(),this.flushKeepalive()}),this.observeNavigation())}inputs=new Set;inputFocusListeners=new Set;ceremonies=new Set;removers=[];lastBlur;bracket;unrelatedPointerAt=-1/0;destroyed=!1;viewportContext={};resize=Ve(e=>this.emit(e,this.viewportContext.resize),"visualviewport-resize",k);scroll=Ve(e=>this.emit(e,this.viewportContext.scroll),"visualviewport-scroll",k);registerInputs(e,t,r){if(this.destroyed)return()=>{};let i={fields:e,context:t,flush:r};if(this.inputs.add(i),this.inputFocusListeners.size>0&&typeof document<"u"){let o=xr(),s=e.find(a=>o.includes(a));s&&this.notifyInputFocus(s)}return()=>{this.inputs.delete(i),this.lastBlur?.registration===i&&(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:i=>{t.settled=!0,t.timer&&clearTimeout(t.timer),t.timer=setTimeout(r,i)},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(i=>!i.settled);if(e.length===1)return e[0].context;if(e.length>1)return;let t=this.findInput(document.activeElement);if(t)return t.context();let r=this.lastBlur;if(r&&Date.now()-r.ts<=250&&(document.activeElement===document.body||!document.activeElement))return r.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,...i}=t??{};this.enqueue({...e,...i,captureSeq:e.captureSeq??k(),sourceKind:"window",captureVersion:1,pageId:ne()},r)}listen(e,t,r){let i=o=>{try{r(o)}catch(s){this.logger.error(`Failed to observe window ${t}`,s)}};e.addEventListener(t,i),this.removers.push(()=>e.removeEventListener(t,i))}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()}observeNavigation(){let e=window.navigation;e&&this.listen(e,"currententrychange",t=>{let r=t,i=r.from?.index,o=e.currentEntry?.index;r.navigationType==="traverse"&&typeof i=="number"&&typeof o=="number"&&i>=0&&o>=0&&o<i&&(this.flushInputs(),this.emit({lowType:"window-navigate-back",ts:Date.now()}))})}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 Et="cbo_sdk_config",xt="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}},kr=1800*1e3,S={version:"",flushIntervalMs:500,durableOutbox:!1,durableLowOutbox:!1,beaconKeepalive:!1,sessionContinuity:!1,sessionInactivityMs:kr,seqLockTimeoutMs:50,tvc:!0,tph:!0,td:!0,tlf:!0,telemetry:!0,flushOnTelemetry:!1,flushOnFlowTypeFinished:[],deviceInfoCollectorTimeoutMs:1e3,deviceInfoTiming:!1,rawErrors:!0,pmd:!1,retry:{maxAttempts:1,baseDelayMs:0,maxDelayMs:0},aap:"",sourcePathQuery:"allowlist",sourcePathQueryAllow:[]};function R(n,e,t){return Math.min(Math.max(n,e),t)}function F(n,e){return typeof n=="number"&&Number.isFinite(n)?n:e}function N(n,e){return typeof n=="boolean"?n:e}function Tt(n,e){return typeof n=="string"?n:e}function Ir(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"&&e.length>0&&e.length<=w.flushOnFlowTypeFinished.maxNameLength).slice(0,w.flushOnFlowTypeFinished.maxEntries):[]}function Cr(n){return typeof n=="string"&&n.trim().toLowerCase()==="all"?"all":"allowlist"}function Or(n){return Array.isArray(n)?n.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 Y(n){if(!n||typeof n!="object")return null;let e=n;return typeof e.version!="string"||e.version===""?null:kt(e)}function kt(n){let e=n.retry&&typeof n.retry=="object"?n.retry:{},t=R(F(e.baseDelayMs,S.retry.baseDelayMs),w.retryDelayMs.min,w.retryDelayMs.max);return{version:Tt(n.version,""),flushIntervalMs:R(F(n.flushIntervalMs,S.flushIntervalMs),w.flushIntervalMs.min,w.flushIntervalMs.max),durableOutbox:n.durableOutbox===!0,durableLowOutbox:n.durableLowOutbox===!0,beaconKeepalive:n.beaconKeepalive===!0,sessionContinuity:n.sessionContinuity===!0,sessionInactivityMs:R(F(n.sessionInactivityMs,S.sessionInactivityMs),w.sessionInactivityMs.min,w.sessionInactivityMs.max),seqLockTimeoutMs:R(F(n.seqLockTimeoutMs,S.seqLockTimeoutMs),w.seqLockTimeoutMs.min,w.seqLockTimeoutMs.max),tvc:N(n.tvc,S.tvc),tph:N(n.tph,S.tph),td:N(n.td,S.td),tlf:N(n.tlf,S.tlf),telemetry:N(n.telemetry,S.telemetry),flushOnTelemetry:n.flushOnTelemetry===!0,flushOnFlowTypeFinished:Ir(n.flushOnFlowTypeFinished),deviceInfoCollectorTimeoutMs:R(F(n.deviceInfoCollectorTimeoutMs,S.deviceInfoCollectorTimeoutMs),w.deviceInfoCollectorTimeoutMs.min,w.deviceInfoCollectorTimeoutMs.max),deviceInfoTiming:n.deviceInfoTiming===!0,rawErrors:N(n.rawErrors,S.rawErrors),pmd:n.pmd===!0,aap:Tt(n.aap,""),sourcePathQuery:Cr(n.sourcePathQuery),sourcePathQueryAllow:Or(n.sourcePathQueryAllow),retry:{maxAttempts:R(F(e.maxAttempts,S.retry.maxAttempts),w.retryMaxAttempts.min,w.retryMaxAttempts.max),baseDelayMs:t,maxDelayMs:R(F(e.maxDelayMs,S.retry.maxDelayMs),t,w.retryDelayMs.max)}}}function Qe(n,e={}){let t=n??S,r=Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0)),i=Object.fromEntries(Object.entries(e.retry??{}).filter(([,s])=>s!==void 0)),o=kt({...t,...r,retry:{...t.retry,...i}});return o.retry={...t.retry,...Object.fromEntries(Object.keys(i).map(s=>[s,o.retry[s]]))},o.retry.maxDelayMs=Math.max(o.retry.baseDelayMs,o.retry.maxDelayMs),o}function It(n){return Y(n.getItem(Et))}function Ct(n,e){n.setItem(Et,e)}var Pr=6e4,Lr=6e4,oe=class{constructor(e){this.options=e}async send(e,t){try{e.meta={...e.meta,sent:Date.now(),transport:"fetch"};let r=JSON.stringify(e),i=typeof AbortController<"u"?new AbortController:void 0,o=i?setTimeout(()=>i.abort(),Lr):void 0;try{let s={method:"POST",headers:{"Content-Type":"application/json",...this.options.headers,...t},body:r,keepalive:new Blob([r]).size<=Pr,...i?{signal:i.signal}:{}},a=await fetch(this.options.url,s),l={statusCode:a.status,headers:{"retry-after":a.headers.get("Retry-After")}};if(a.headers.get("X-Corbado-Observe-Accepted")==="1"&&(l.deliveryAccepted=!0),a.status===200)try{let d=Y(await a.json());d&&(l.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 l}finally{o&&clearTimeout(o)}}catch(r){return this.options.logger.error("Failed to send event",r),{}}}sendBeacon(e){try{if(this.options.logger.debug(`Sending ${e.events.length} events via beacon`),typeof navigator?.sendBeacon!="function")return!1;e.meta={...e.meta,sent:Date.now(),transport:"beacon"};let t=new Blob([JSON.stringify(e)],{type:"text/plain"});return navigator.sendBeacon(this.options.url,t)}catch(t){return this.options.logger.error("Failed to send event via beacon",t),!1}}flush(e){return Promise.resolve(!0)}};function se(n,e,t={}){let r=typeof navigator<"u"?navigator.locks:void 0;if(r?.request){let i=t.timeoutMs,o=i!==void 0&&typeof AbortController<"u"?new AbortController:null;if(i!==void 0&&!o)return Promise.resolve().then(e);try{let s=!1,a,l=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},d=()=>(s=!0,l(),e()),p=o?r.request(n,{signal:o.signal},d):r.request(n,d);return o&&i!==void 0&&!s&&(a=setTimeout(()=>{a=void 0,o.abort();try{t.onTimeout?.()}catch{}},i)),p.catch(u=>{if(s)throw u;return e()}).finally(l)}catch{}}try{return Promise.resolve(e())}catch(i){return Promise.reject(i)}}var Rr="cbo_outbox",$e="cbo_outbox",Fr=500,Ar=512*1024;function _r(n){if(!n||typeof n!="object")return!1;let e=n;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 U=class{constructor(e,t,r=Fr,i=Ar,o=$e,s=Rr){this.storage=e;this.logger=t;this.maxEntries=r;this.maxSerializedLength=i;this.lockName=o;this.storageKey=s;this.entries=this.read()}entries=[];reportedMalformed=!1;read(){let e=this.storage.getItem(this.storageKey);if(!Array.isArray(e))return[];let t=e.filter(_r);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 se(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),i=0;for(;r>this.maxSerializedLength&&i<e.length;)r-=t[i]+1,i++;return i===0?e:(this.logger.error(`EventStore evicted ${i} oldest entries (size budget ${this.maxSerializedLength})`),this.logger.reportTelemetry?.("error","event store evicted entries (size budget)"),e.slice(i))}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(i=>!t.has(i.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(i=>t.get(i.id)??i))}size(){return this.all().length}};var Mr=500,Hr=512*1024,Ot=200,Pt=200*1024,Br=16*1024,Lt=6e4,Ge=32e3;function ae(n){let e=0;for(let t=0;t<n.length;t++){let r=n.charCodeAt(t);r<128?e+=1:r<2048?e+=2:r>=55296&&r<=56319&&t+1<n.length?(e+=4,t++):e+=3}return e}var le=class{constructor(e,t,r,i,o={},s){this.logger=e;this.transport=t;this.sessionId=r;this.sdk=i;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.config=o.config??S,this.priorityFlowTypes=new Set(this.config.flushOnFlowTypeFinished),this.outboxLockName=o.outboxLockName,this.config.durableOutbox&&this.storage&&(this.store=new U(this.storage,this.logger,void 0,void 0,this.outboxLockName),this.pending=this.store.all()),this.storage){this.lowStore=new U(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(l=>this.validPendingLow(l)),this.lowStore.remove(a.filter(l=>!this.validPendingLow(l)).map(l=>l.id))}this.setupLifecycleHooks(),(this.pending.length>0||this.lowPending.length>0)&&(this.dirtySinceSyncFlush=!0,this.scheduleFlush(0,"recovery"))}pending=[];lowsQueue=[];lowPending=[];lowStore;telemetryQueue=[];probeQueue=[];probeBytes=0;probesDropped=0;timer=null;isFlushing=!1;flushingDone;destroyed=!1;dirtySinceSyncFlush=!1;onVisibilityChange=null;onPageHide=null;batchSize;flushIntervalOverride;debug;requestConfig;onConfigReceived;getDataPolicy;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??v()};if(this.config.durableLowOutbox){let i={id:r.id,sessionId:t,event:r,attempts:0,flushAfter:0};this.lowPending.push(i),this.lowPending=this.lowPending.slice(-1e3),this.lowStore?.add(i)}else this.lowsQueue.push({sessionId:t,event:r});this.scheduleAfterEnqueue()}catch(r){this.logger.error("Failed to enqueue low event",r)}}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)}}enqueueProbe(e,t=this.sessionId){try{if(this.destroyed)return;let r=JSON.stringify(e.payload);if(typeof r!="string"||ae(r)>Br){this.probesDropped++;return}let i={...e,payload:JSON.parse(r)},o=ae(JSON.stringify(i));for(this.probeQueue.push({sessionId:t,entry:i,bytes:o,attempts:0,flushAfter:0}),this.probeBytes+=o;this.probeQueue.length>Mr||this.probeBytes>Hr&&this.probeQueue.length>1;){let s=this.probeQueue.shift();this.probeBytes-=s.bytes,this.probesDropped++}this.scheduleFlush(this.flushInterval(),"timer")}catch(r){this.logger.error("Failed to enqueue probe",r)}}droppedProbeCount(){return this.probesDropped}dueProbes(e){return this.probeQueue.filter(t=>t.flushAfter<=e)}selectProbes(e,t,r,i){let o=[],s=0;for(let a of e){if(o.length>=r)break;if(a.sessionId===t){if(s+a.bytes>i){o.length===0&&i>=Pt&&o.push(a);break}s+=a.bytes,o.push(a)}}return o}removeProbes(e){if(e.length===0)return;let t=new Set(e);this.probeQueue=this.probeQueue.filter(r=>!t.has(r));for(let r of e)this.probeBytes-=r.bytes}dropProbes(e){this.removeProbes(e),this.probesDropped+=e.length}handleProbeSendResult(e,t,r){if(t.length===0)return;let i=e.statusCode;if(typeof i=="number"&&i>=200&&i<300){this.removeProbes(t);return}if(!this.isRetryable(i)){this.dropProbes(t);return}let o=Math.max(1,this.config.retry.maxAttempts),s=this.parseRetryAfter(e),a=[];for(let l of t)l.attempts+=1,l.attempts>=o?a.push(l):l.flushAfter=r+this.backoffForAttempt(l.attempts,s);this.dropProbes(a)}sendUnloadProbes(e,t,r,i){let o=this.sessionId,s={sessionId:o,events:[],sdk:this.sdk,probes:[]};this.attachBatchMeta(s,[],t);let a=ae(JSON.stringify(s))+120,l=e>a?this.selectProbes(this.probeQueue,o,Ot,e-a):[];l.length>0&&(s.probes=l.map(d=>d.entry),this.attachBatchMeta(s,l,t),i&&this.config.beaconKeepalive&&this.transport.sendBeacon?this.transport.sendBeacon(s):Promise.resolve(this.transport.send(s)).catch(()=>{}),this.removeProbes(l)),r&&this.dropProbes(this.probeQueue.slice())}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.sendUnloadProbes(Ge,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(),i=this.getDuePending(r),o=this.lowPending.filter(m=>m.flushAfter<=r),s=e==="destroy"?[]:this.dueProbes(r);if(i.length===0&&o.length===0&&this.lowsQueue.length===0&&this.telemetryQueue.length===0&&s.length===0)break;let a=i[0]?.sessionId??o[0]?.sessionId??this.lowsQueue[0]?.sessionId??s[0]?.sessionId??this.sessionId,l=i.filter(m=>m.sessionId===a).slice(0,this.batchSize),d=o.filter(m=>m.sessionId===a).slice(0,100),p=[...d.map(m=>m.event),...this.takeLows(a,100-d.length)],u=a===this.sessionId?this.takeTelemetry():[],c=this.selectProbes(s,a,Ot,Pt),f={sessionId:a,events:l.map(m=>m.event),sdk:this.sdk};p.length>0&&(f.lows=p),u.length>0&&(f.telemetry=u),c.length>0&&(f.probes=c.map(m=>m.entry)),this.attachBatchMeta(f,[...l,...d,...c],e),d.length&&(f.deliveryAck=!0);let y=this.shouldRequestConfig()?{[xt]:this.config.version||"1"}:void 0,h=await this.transport.send(f,y).catch(m=>(this.logger.error("Unexpected error in queue flush",m),{}));if(f.deliveryAck&&h.statusCode&&h.statusCode>=200&&h.statusCode<300&&!h.deliveryAccepted&&(h={...h,statusCode:503}),this.requestConfig&&this.handleConfigResponse(h),this.handleLowSendResult(h,d,r),this.handleProbeSendResult(h,c,r),!this.handleSendResult(h,l,r))break}e==="destroy"&&this.sendUnloadProbes(Ge,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 i=this.readDataPolicy();i!==void 0&&(e.meta={...e.meta,dataPolicy:i}),this.config.version&&(e.meta={...e.meta,configVersion:this.config.version});let o=t.reduce((s,a)=>Math.max(s,a.attempts),0);o>0&&(e.meta={...e.meta,retryCount:o})}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),i=new Set(r);return this.lowsQueue=this.lowsQueue.filter(o=>!i.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 i=e.statusCode;if(i!==void 0&&i>=200&&i<300){e.deliveryAccepted?this.removeLowEntries(t.map(o=>o.id)):this.deferLowEntries(t,r);return}if(!this.isRetryable(i)){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 i=[];for(let o of e){if(!this.validPendingLow(o)){i.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(i),this.lowStore?.update(e.filter(o=>!i.includes(o.id)))}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 i=this.lowsQueue;this.lowsQueue=[];for(let{event:o,sessionId:s}of i)this.enqueueLow(o,s)}let r=!1;if(this.config.durableOutbox&&this.storage&&!this.store){this.store=new U(this.storage,this.logger,void 0,void 0,this.outboxLockName);let i=new Set(this.pending.map(s=>s.id)),o=this.store.all().filter(s=>!i.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 i=e.statusCode,o=typeof i=="number"&&i>=200&&i<300;if(t.length===0)return o;if(o)return this.removeEntries(t.map(p=>p.id)),!0;if(!this.isRetryable(i))return this.removeEntries(t.map(p=>p.id)),!1;let s=Math.max(1,this.config.retry.maxAttempts),a=this.parseRetryAfter(e),l=[],d=[];for(let p of t)p.attempts+=1,p.attempts>=s?l.push(p.id):(p.flushAfter=r+this.backoffForAttempt(p.attempts,a),d.push(p));return this.removeEntries(l),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,i=r.baseDelayMs*Math.pow(2,Math.max(0,e-1));r.maxDelayMs>0&&(i=Math.min(i,r.maxDelayMs));let o=Math.round(i/2+Math.random()*(i/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 i=Date.parse(t);return Number.isNaN(i)?null:Math.max(0,i-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||this.pending.length===0&&this.lowPending.length===0&&this.lowsQueue.length===0&&this.probeQueue.length===0)return;let e=Date.now();if(this.getDuePending(e).length>0||this.lowPending.some(r=>r.flushAfter<=e)||this.lowsQueue.length>0||this.probeQueue.some(r=>r.flushAfter<=e)){this.scheduleFlush(this.flushInterval(),"timer");return}let t=Math.min(...[...this.pending,...this.lowPending,...this.probeQueue].map(r=>r.flushAfter));this.scheduleFlush(Math.max(0,t-e),"backoff")}catch(e){this.logger.error("Failed to reschedule queue flush",e)}}setupLifecycleHooks(){typeof window>"u"||(this.onVisibilityChange=()=>{try{this.writeLifecycleDebugOutput("cbo_visibility_change_debug"),document.visibilityState==="hidden"&&this.config.tvc&&this.flushSync("visibility-change")}catch(e){this.logger.error("Unexpected error in queue flushSync",e)}},this.onPageHide=()=>{try{this.writeLifecycleDebugOutput("cbo_pagehide_debug"),this.config.tph&&this.flushSync("pagehide")}catch(e){this.logger.error("Unexpected error in queue flushSync",e)}},window.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("pagehide",this.onPageHide))}writeLifecycleDebugOutput(e){if(!this.debug||!this.storage)return;let t={last_executed:Date.now(),url:window.location.href};this.storage.setItem(e,t)}flushKeepalive(e="manual"){this.flushSync(e)}flushSync(e){let t=this.flushSyncEvents(e);e==="pagehide"&&this.probeQueue.length>0&&this.sendUnloadProbes(Math.min(Lt-t,Ge),e,!0,!0)}flushSyncEvents(e){if(!this.dirtySinceSyncFlush)return 0;let t=this.sessionId,r=this.pending.filter(d=>d.sessionId===t),i=r.slice(0,this.batchSize),o=this.lowPending.filter(d=>d.sessionId===t).slice(0,100),s=[...o.map(d=>d.event),...this.takeLows(t,100-o.length)],a=this.takeTelemetry();if(i.length===0&&s.length===0&&a.length===0)return this.dirtySinceSyncFlush=!1,0;let l={sessionId:t,events:i.map(d=>d.event),sdk:this.sdk};return s.length>0&&(l.lows=s),a.length>0&&(l.telemetry=a),this.attachBatchMeta(l,[...i,...o],e),o.length&&(l.deliveryAck=!0),this.config.beaconKeepalive&&this.transport.sendBeacon?this.transport.sendBeacon(l)||this.transport.send(l):this.transport.send(l),this.config.durableOutbox||this.removeEntries(i.map(d=>d.id)),this.dirtySinceSyncFlush=!this.config.durableOutbox&&r.length>i.length,this.approximateSize(l)}approximateSize(e){try{return ae(JSON.stringify(e))}catch{return Lt}}destroy(){try{this.destroyed=!0,this.clearTimer(),this.dropProbes(this.probeQueue.slice()),typeof window<"u"&&(this.onVisibilityChange&&window.removeEventListener("visibilitychange",this.onVisibilityChange),this.onPageHide&&window.removeEventListener("pagehide",this.onPageHide))}catch(e){this.logger.error("Failed to destroy queue lifecycle hooks",e)}}};var We={d:(n,e)=>{for(var t in e)We.o(e,t)&&!We.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:e[t]})},o:(n,e)=>Object.prototype.hasOwnProperty.call(n,e)},ze={};We.d(ze,{A:()=>Nr,k:()=>je});var q=function(n,e,t,r){return new(t||(t=Promise))(function(i,o){function s(d){try{l(r.next(d))}catch(p){o(p)}}function a(d){try{l(r.throw(d))}catch(p){o(p)}}function l(d){var p;d.done?i(d.value):(p=d.value,p instanceof t?p:new t(function(u){u(p)})).then(s,a)}l((r=r.apply(n,e||[])).next())})},K=function(n,e){var t,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[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(l){return function(d){return(function(p){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,p[0]&&(s=0)),s;)try{if(t=1,r&&(i=2&p[0]?r.return:p[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,p[1])).done)return i;switch(r=0,i&&(p=[2&p[0],i.value]),p[0]){case 0:case 1:i=p;break;case 4:return s.label++,{value:p[1],done:!1};case 5:s.label++,r=p[1],p=[0];continue;case 7:p=s.ops.pop(),s.trys.pop();continue;default:if(i=s.trys,!((i=i.length>0&&i[i.length-1])||p[0]!==6&&p[0]!==2)){s=0;continue}if(p[0]===3&&(!i||p[1]>i[0]&&p[1]<i[3])){s.label=p[1];break}if(p[0]===6&&s.label<i[1]){s.label=i[1],i=p;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(p);break}i[2]&&s.ops.pop(),s.trys.pop();continue}p=e.call(n,s)}catch(u){p=[6,u],r=0}finally{t=i=0}if(5&p[0])throw p[1];return{value:p[0]?p[1]:void 0,done:!0}})([l,d])}}};function je(){return q(this,void 0,Promise,function(){return K(this,function(n){switch(n.label){case 0:return[4,new Promise(function(e,t){var r="Unknown",i=!1;function o(p){i||(i=!0,e({isPrivate:p,browserName:r}))}function s(){var p=0,u=parseInt("-1");try{u.toFixed(u)}catch(c){p=c.message.length}return p}function a(){return q(this,void 0,void 0,function(){var p,u;return K(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),[4,navigator.storage.getDirectory()];case 1:return c.sent(),o(!1),[3,3];case 2:return p=c.sent(),u=p instanceof Error&&typeof p.message=="string"?p.message:String(p),o(u.includes("unknown transient reason")),[3,3];case 3:return[2]}})})}function l(){var p;return q(this,void 0,Promise,function(){return K(this,function(u){switch(u.label){case 0:return typeof((p=navigator.storage)===null||p===void 0?void 0:p.getDirectory)!="function"?[3,2]:[4,a()];case 1:return u.sent(),[3,3];case 2:navigator.maxTouchPoints!==void 0?(function(){var c=String(Math.random());try{var f=indexedDB.open(c,1);f.onupgradeneeded=function(y){var h=y.target.result,m=function(E){o(E)};try{h.createObjectStore("t",{autoIncrement:!0}).put(new Blob),m(!1)}catch(E){(E instanceof Error&&typeof E.message=="string"?E.message:String(E)).includes("are not yet supported")?m(!0):m(!1)}finally{h.close(),indexedDB.deleteDatabase(c)}},f.onerror=function(){return o(!1)}}catch{o(!1)}})():(function(){var c=window.openDatabase,f=window.localStorage;try{c(null,null,null,null)}catch{return void o(!0)}try{f.setItem("test","1"),f.removeItem("test")}catch{return void o(!0)}o(!1)})(),u.label=3;case 3:return[2]}})})}function d(){var p;return q(this,void 0,Promise,function(){var u,c,f;return K(this,function(y){switch(y.label){case 0:if(typeof((p=navigator.storage)===null||p===void 0?void 0:p.getDirectory)!="function")return[3,5];y.label=1;case 1:return y.trys.push([1,3,,4]),[4,navigator.storage.getDirectory()];case 2:return y.sent(),o(!1),[3,4];case 3:return u=y.sent(),c=u instanceof Error&&typeof u.message=="string"?u.message:String(u),o(c.includes("Security error")),[2];case 4:return[3,6];case 5:(f=indexedDB.open("inPrivate")).onerror=function(h){f.error&&f.error.name==="InvalidStateError"&&h.preventDefault(),o(!0)},f.onsuccess=function(){indexedDB.deleteDatabase("inPrivate"),o(!1)},y.label=6;case 6:return[2]}})})}(function(){return q(this,void 0,Promise,function(){return K(this,function(p){switch(p.label){case 0:return s()!==44&&s()!==43?[3,2]:(r="Safari",[4,l()]);case 1:return p.sent(),[3,6];case 2:return s()!==51?[3,3]:(u=navigator.userAgent,r=u.match(/Chrome/)?navigator.brave!==void 0?"Brave":u.match(/Edg/)?"Edge":u.match(/OPR/)?"Opera":"Chrome":"Chromium",(function(){var c=this,f="__di_"+Math.random().toString(36).slice(2),y=new Uint8Array(16384),h=indexedDB.open(f,1);h.onupgradeneeded=function(){h.result.createObjectStore("s")},h.onerror=function(){indexedDB.deleteDatabase(f),o(!1)},h.onsuccess=function(){var m=h.result,E=!1;try{var ut=m.transaction("s","readwrite",{durability:"strict"});E=ut.durability==="strict",ut.abort()}catch{}if(!E)return m.close(),indexedDB.deleteDatabase(f),void o(!1);var J=function(G){return new Promise(function(C,W){var z=performance.now(),_=0,x=function(){if(_!==15){var P=m.transaction("s","readwrite",{durability:G});P.objectStore("s").put(y,_),_++,P.oncomplete=x,P.onerror=P.onabort=function(){return W(P.error)}}else C(performance.now()-z)};x()})};q(c,void 0,void 0,function(){var G,C,W,z,_;return K(this,function(x){switch(x.label){case 0:return G=performance.now(),[4,J("relaxed")];case 1:return x.sent(),[4,J("strict")];case 2:x.sent(),C=[],W=0,x.label=3;case 3:return W<15?[4,J("relaxed")]:[3,7];case 4:return z=x.sent(),[4,J("strict")];case 5:if(_=x.sent(),C.push(z>0?_/z:1/0),C.length>=7&&performance.now()-G>=1e3)return[3,7];x.label=6;case 6:return W++,[3,3];case 7:return C.sort(function(P,ar){return P-ar}),m.close(),indexedDB.deleteDatabase(f),o(C[C.length>>1]<1.3),[2]}})}).catch(function(){m.close(),indexedDB.deleteDatabase(f),o(!1)})}})(),[3,6]);case 3:return s()!==25?[3,5]:(r="Firefox",[4,d()]);case 4:return p.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")),p.label=6;case 6:return[2]}var u})})})().catch(t)})];case 1:return[2,n.sent()]}})})}typeof window<"u"&&(window.detectIncognito=je);var Nr=je,Rt=ze.A,On=ze.k;var Ye={collectorTimeoutMs:1e3,timing:!1},Xe="cbo_tab_id",qr={bluetoothAvailable:"bt",clientCapabilities:"cc",userVerifyingPlatformAuthenticatorAvailable:"uvpaa",conditionalMediationAvailable:"cm",javaScriptHighEntropy:"he",privateMode:"pm",webdriver:"wd",maxTouchPoints:"mtp"};function X(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}var pe=class{constructor(e,t,r="localstorage",i,o=()=>Ye,s){this.logger=e;this.storage=t;this.storageSource=r;this.sessionStorage=i;this.settings=o;this.emitTelemetry=s}async getInfo(){try{let e=this.resolveSettings(),t=X(),r=this.getClientEnvHandle(),i=await Promise.all([this.collectField("bluetoothAvailable","navigator.bluetooth.getAvailability",()=>this.isBluetoothAvailable(),e.collectorTimeoutMs),this.collectField("clientCapabilities","PublicKeyCredential.getClientCapabilities",()=>this.getClientCapabilities(),e.collectorTimeoutMs),this.collectField("userVerifyingPlatformAuthenticatorAvailable","PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable",()=>this.getUserVerifyingPlatformAuthenticatorAvailable(),e.collectorTimeoutMs),this.collectField("conditionalMediationAvailable","PublicKeyCredential.isConditionalMediationAvailable",()=>this.isConditionalMediationAvailable(),e.collectorTimeoutMs),this.collectField("javaScriptHighEntropy","navigator.userAgentData.getHighEntropyValues",()=>this.getJavaScriptHighEntropy(),e.collectorTimeoutMs),this.collectField("privateMode","detectIncognito",()=>this.isPrivateMode(),e.collectorTimeoutMs),this.collectField("webdriver","navigator.webdriver",()=>this.getWebdriver(),e.collectorTimeoutMs),this.collectField("maxTouchPoints","navigator.maxTouchPoints",()=>this.getMaxTouchPoints(),e.collectorTimeoutMs)]),o=X()-t;e.timing&&this.reportTiming(o,i);let[s,a,l,d,p,u,c,f]=i,y=i.flatMap(m=>m.error?[m.error]:[]),h={type:"web",clientEnvHandle:r.value,clientEnvHandleMeta:{timestamp:r.timestamp,source:r.source},tabId:this.getTabId(),data:{bluetoothAvailable:s.value,javaScriptHighEntropy:p.value,privateMode:u.value,webdriver:c.value,conditionalMediationAvailable:d.value,userVerifyingPlatformAuthenticatorAvailable:l.value,clientCapabilities:a.value,maxTouchPoints:f.value}};return y.length>0&&(h.collectionErrors=y),h}catch(e){return this.logger.error("Failed to collect device info",e),{}}}async collectField(e,t,r,i){let o,s=X();try{let a=await Promise.race([Promise.resolve().then(r),new Promise((l,d)=>{o=setTimeout(()=>{let p=new Error(`Device info collection timed out after ${i}ms`);p.name="TimeoutError",d(p)},i)})]);return{field:e,value:a,durationMs:X()-s}}catch(a){return this.logger.error(`Failed to collect device info field "${e}"`,a),{field:e,durationMs:X()-s,error:{field:e,source:t,error:D(a)??{message:"Unknown error"}}}}finally{o&&clearTimeout(o)}}resolveSettings(){try{let e=this.settings(),t=e?.collectorTimeoutMs;return{collectorTimeoutMs:typeof t=="number"&&Number.isFinite(t)&&t>0?t:Ye.collectorTimeoutMs,timing:e?.timing===!0}}catch(e){return this.logger.error("Failed to resolve device info collector settings",e),Ye}}reportTiming(e,t){if(this.emitTelemetry)try{let r=t.map(i=>`${qr[i.field]??i.field}=${Math.round(i.durationMs)}`).join(",");this.emitTelemetry("info",`device info collected in ${Math.round(e)}ms (${r})`)}catch(r){this.logger.error("Failed to report device info timing",r)}}static getOsAndBrowserInfo(){return{osName:this.getOsName(),browserName:this.getBrowserName()}}static getUserAgent(){return typeof navigator>"u"?"":navigator.userAgent??""}static getOsName(){let e=this.getUserAgent();return e.includes("iOS")?"iOS":e.includes("Android")?"Android":e.includes("Windows")?"Windows":e.includes("Macintosh")?"macOS":e.includes("Linux")?"Linux":e.includes("ChromeOS")?"ChromeOS":"other"}static getBrowserName(){let e=this.getUserAgent();return e.includes("Chrome")?"Chrome":e.includes("Firefox")?"Firefox":e.includes("Safari")?"Safari":e.includes("Edge")?"Edge":e.includes("Opera")?"Opera":e.includes("IE")?"IE":"other"}async isBluetoothAvailable(){if(!(typeof navigator>"u"||!navigator.bluetooth))return await navigator.bluetooth.getAvailability()}async getUserVerifyingPlatformAuthenticatorAvailable(){if(!(typeof PublicKeyCredential>"u"||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable))return await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}async isConditionalMediationAvailable(){if(!(typeof PublicKeyCredential>"u"||!PublicKeyCredential.isConditionalMediationAvailable))return await PublicKeyCredential.isConditionalMediationAvailable()}async getClientCapabilities(){if(typeof PublicKeyCredential>"u"||!PublicKeyCredential.getClientCapabilities)return;let e=await PublicKeyCredential.getClientCapabilities();return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,r.toString()]))}getClientEnvHandle(){let e=this.storage.getItem("cbo_client_env_handle");if(e)return e;let t=v(),r={timestamp:Date.now(),source:this.storageSource,value:t};return this.storage.setItem("cbo_client_env_handle",r),r}getTabId(){if(!this.sessionStorage)return;let e=this.sessionStorage.getItem(Xe);if(e)return e;let t=v();if(this.sessionStorage.setItem(Xe,t),this.sessionStorage.getItem(Xe)===t)return t}async getJavaScriptHighEntropy(){if(typeof navigator>"u"||!navigator.userAgentData)return;let e=await navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]),t=e.platform,r=e.mobile,i=e.platformVersion,o=e.model||void 0;if(!(!t||r===void 0||!i))return{platform:t,mobile:r,platformVersion:i,model:o}}async isPrivateMode(){return(await Rt()).isPrivate}getWebdriver(){if(!(typeof navigator>"u"))return navigator.webdriver}getMaxTouchPoints(){if(!(typeof navigator>"u"||typeof navigator.maxTouchPoints!="number"))return navigator.maxTouchPoints}};var de=class{constructor(e,t,r,i){this.logger=e;this.source=t;this.refreshInterval=r;this.attachInterval=i}snapshot;refreshedAt=0;lastAttachedAt=null;refreshPromise;timer;destroyed=!1;start(){this.refresh()}getForEvent(){if(Date.now()-this.refreshedAt>=this.refreshInterval&&this.refresh(),!!this.snapshot&&!(this.lastAttachedAt!==null&&Date.now()-this.lastAttachedAt<this.attachInterval))return this.lastAttachedAt=Date.now(),this.snapshot}destroy(){this.destroyed=!0,this.timer&&(clearTimeout(this.timer),this.timer=void 0)}refresh(){return this.refreshPromise?this.refreshPromise:(this.timer&&(clearTimeout(this.timer),this.timer=void 0),this.refreshPromise=Promise.resolve().then(()=>this.source.getInfo()).then(e=>{this.snapshot=e,this.refreshedAt=Date.now()}).catch(e=>this.logger.error("Failed to refresh device info",e)).finally(()=>{this.refreshPromise=void 0,this.destroyed||(this.timer=setTimeout(()=>{this.refresh()},this.refreshInterval))}),this.refreshPromise)}};function I(n,e){return`${n}_${e}`}var ue=class{constructor(e,t){this.engine=e;this.namespace=t}getItem(e){return this.engine.getItem(I(e,this.namespace))}setItem(e,t){this.engine.setItem(I(e,this.namespace),t)}removeItem(e){this.engine.removeItem(I(e,this.namespace))}},ce=class{constructor(e){this.logger=e}getItem(e){try{if(typeof localStorage>"u")return null;let t=localStorage.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;localStorage.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;localStorage.removeItem(e)}catch(t){this.logger.error(`LocalStorage.removeItem failed for key "${e}"`,t)}}},he=class{constructor(e,t){this.logger=e;this.domain=t}getItem(e){try{if(typeof document>"u")return null;let t=e+"=",r=document.cookie.split(";");for(let i=0;i<r.length;i++){let o=r[i].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}`),document.cookie=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}`),document.cookie=t}catch(t){this.logger.error(`CookieStorage.removeItem failed for key "${e}"`,t)}}},fe=class{constructor(e){this.logger=e}getItem(e){try{if(typeof sessionStorage>"u")return null;let t=sessionStorage.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;sessionStorage.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;sessionStorage.removeItem(e)}catch(t){this.logger.error(`SessionStorage.removeItem failed for key "${e}"`,t)}}};var ge=1,me="cbo_storage_schema",Kr=["cbo_seq","cbo_sdk_config","cbo_experiments","cbo_client_env_handle","cbo_outbox","cbo_visibility_change_debug","cbo_pagehide_debug","cbo_session"],Vr=["cbo_session_id","cbo_tab_id"],Qr=["cbo_client_env_handle"];function ye(n,e,t){return n.setItem(e,t),JSON.stringify(n.getItem(e))===JSON.stringify(t)}function Je(n,e,t){let r=n.getItem(me);if(r!==null){if(r.version!==ge||r.projectId!==e)return!1;if(r.complete===!0)return!0;if(r.complete!==!1)return!1}else{if(t.some(i=>n.getItem(I(i,e))!==null))return ye(n,me,{version:ge,projectId:e,complete:!0});if(!ye(n,me,{version:ge,projectId:e,complete:!1}))return!1}for(let i of t){let o=I(i,e);if(n.getItem(o)!==null)continue;let s=n.getItem(i);if(s!==null&&!ye(n,o,s))return!1}return ye(n,me,{version:ge,projectId:e,complete:!0})}function Ft(n,e,t,r,i){try{if(!Je(e,n,Kr))return;Je(t,n,Vr),r&&Je(r,n,Qr)}catch(o){i.error("Failed to migrate legacy Observe storage",o)}}var $r=10*1e3,Gr=600*1e3,Wr=[1e3,3e3],ve=class{constructor(e,t,r){this.url=e;this.storage=t;this.logger=r;this.initialConfig=It(t)??void 0}initialConfig;refreshTimer;requestTimer;retryTimer;controller;fetching=!1;stopped=!1;onConfig;start(e){this.stopped||this.onConfig||(this.onConfig=e,this.fetchConfig())}async fetchConfig(e=0){if(this.stopped||this.fetching)return;e===0&&(clearTimeout(this.refreshTimer),clearTimeout(this.retryTimer),this.refreshTimer=setTimeout(()=>{this.fetchConfig()},Gr)),this.fetching=!0;let t=typeof AbortController<"u"?new AbortController:void 0;this.controller=t,this.requestTimer=t?setTimeout(()=>t.abort(),$r):void 0;let r=!0;try{let i=await fetch(this.url,{method:"GET",cache:"no-store",...t?{signal:t.signal}:{}});if(!i.ok)throw r=(i.status===408||i.status===429||i.status>=500)&&!i.headers.has("Retry-After"),new Error(`SDK config request failed (${i.status})`);let o=await i.json();r=!1;let s=Y(o);if(!s)throw new Error("Invalid SDK config response");if(this.stopped||t?.signal.aborted)return;Ct(this.storage,s),this.onConfig?.(s)}catch(i){if(!this.stopped){this.logger.error("Failed to fetch SDK config",i);let o=Wr[e];(r&&!(i 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,clearTimeout(this.refreshTimer),clearTimeout(this.requestTimer),clearTimeout(this.retryTimer),this.controller?.abort(),this.onConfig=void 0}};var V=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 Se=class extends g{getOptions;ceremony;postResponse;lowEventTracker;constructor(e,t){super(e,"passkey-login"),this.lowEventTracker=new V(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,i){this.previousLength=e;this.pushLow=t;this.logger=r;this.reserveCaptureSeq=i}prefillSettled=!1;inputBatch=null;currentEffect="modify";ringEffect="modify";autofillTimestamps=[];autofillStreak=null;idleTimer=null;markInputObserved(){this.prefillSettled=!0}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,r){let i=this.inputBatch;if(!i){this.inputBatch={firstTimestamp:e,lastTimestamp:e,effect:t,captureSeq:r};return}i.lastTimestamp=e}drainAutofillRingToBatch(){for(let e of this.autofillTimestamps)this.extendInputBatch(e.ts,this.ringEffect,e.captureSeq);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 i=1;i<e.length;i++){let o=e[i].ts-e[i-1].ts;if(o>80)return!1;o<t&&(t=o),o>r&&(r=o)}return r-t<=25}record(e,t=Date.now(),r=!1,i=this.reserveCaptureSeq?.()){this.markInputObserved(),this.scheduleIdle();let o=this.previousLength;this.currentEffect=e===0?"clear":o===0?"fill":"modify";let s=e-o;if(this.previousLength=e,e===0&&o>0){this.flush(),this.pushLow({...i===void 0?{}:{captureSeq:i},lowType:"input-clear",ts:t,inputEffect:"clear"});return}if(r){this.flushAutofillStreak(),this.drainAutofillRingToBatch(),this.extendInputBatch(t,this.currentEffect,i);return}if(s>=3){this.flushInputBatch(),this.flushAutofillStreak(),this.pushLow({...i===void 0?{}:{captureSeq:i},lowType:"big-input-add",ts:t,inputEffect:this.currentEffect});return}if(s<=-3){this.flushInputBatch(),this.flushAutofillStreak(),this.pushLow({...i===void 0?{}:{captureSeq:i},lowType:"big-input-rem",ts:t,inputEffect:this.currentEffect});return}let a=this.autofillStreak;if(a){if(s===1&&t-a.lastTimestamp<=80){a.lastTimestamp=t;return}this.flushAutofillStreak()}if(s!==1){this.drainAutofillRingToBatch(),this.extendInputBatch(t,this.currentEffect,i);return}let l=this.autofillTimestamps;if(l.length===0&&(this.ringEffect=this.currentEffect),l.push({ts:t,captureSeq:i}),l.length>5){let u=l.shift();this.extendInputBatch(u.ts,this.ringEffect,u.captureSeq),this.ringEffect="modify"}if(!this.detectAutofillStreak())return;let d=l[0],p=l[l.length-1];l.length=0,this.flushInputBatch(),this.autofillStreak={firstTimestamp:d.ts,captureSeq:d.captureSeq,lastTimestamp:p.ts,effect:this.ringEffect}}};var $=class{constructor(e,t,r,i){this.inputs=e;this.logger=t;this.changed=r;this.reserveCaptureSeq=i;for(let o of e)o.addEventListener("paste",this.onPaste,!0),o.addEventListener("beforeinput",this.onBeforeInput,!0)}before=null;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.before)return!1;let t=this.pasteEvent?.type==="paste"&&(this.pasteEvent.eventPhase??0)>0;return e.inputType==="insertFromPaste"||t?!0:(this.clear(),!1)}get pending(){return this.before!==null}begin(e){if(!(!e.isTrusted||this.before))try{this.before=this.inputs.map(t=>t.value),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.before;if(!e)return;let t=this.timestamp,r=this.captureSeq;this.clear();try{let i=0,o=!1;this.inputs.forEach((s,a)=>{let l=e[a],d=s.value;if(l===d)return;o=!0;let p=0;for(;p<l.length&&p<d.length&&l[p]===d[p];)p++;let u=0;for(;u<l.length-p&&u<d.length-p&&l[l.length-u-1]===d[d.length-u-1];)u++;i+=d.length-p-u}),o&&this.changed(t,i,r)}catch(i){this.logger.error("Failed to finish paste observation",i)}}clear(){this.timer!==null&&clearTimeout(this.timer),this.timer=null,this.before=null,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 zr=[{query:"com-1password-button",eventType:"pa-1"},{query:"com-1password-menu",eventType:"pa-2"},{query:"com-1password-notification",eventType:"pa-3"}],jr="[data-lastpass-root], [data-lp], [data-lpignore], [data-lpfieldtype]",At="pa-4",Yr='[popover="manual"]',Xr=400,Jr=20,Ze="pa-5",et="pa-6",tt=(n,e)=>{try{return Array.from(n.querySelectorAll(e))}catch{return[]}},_t=n=>{if(n.getAttribute("popover")!=="manual")return!1;let e=n.getAttribute("style")??"";return!(e.length<Xr||!/z-index:\s*2147483647\b/i.test(e)||!/position:\s*fixed\b/i.test(e)||!/display:\s*block\b/i.test(e)||(e.match(/initial\s*!important/gi)?.length??0)<Jr)},Zr=n=>{if(_t(n)||n.getAttribute("popover")!=="manual")return!1;let e=n.getAttribute("style")??"";return!(!/z-index:\s*2147483647\b/i.test(e)||!/position:\s*fixed\b/i.test(e)||!/backdrop-filter:\s*[^;]*blur\(\s*20px\s*\)/i.test(e)||!/background-color:\s*rgba\(\s*35\s*,\s*35\s*,\s*35\s*,/i.test(e))},ei=n=>{n(document);for(let e of Array.from(document.querySelectorAll("*"))){let t=e.shadowRoot;t&&n(t)}},Dt=()=>{let n=new Set;return typeof document>"u"||ei(e=>{for(let t of zr)n.has(t.eventType)||tt(e,t.query).length>0&&n.add(t.eventType);if(!n.has(At)&&tt(e,jr).length>0&&n.add(At),!n.has(Ze)||!n.has(et))for(let t of tt(e,Yr)){if(!n.has(Ze)&&_t(t)){n.add(Ze);continue}!n.has(et)&&Zr(t)&&n.add(et)}}),n};var ti=500,ri=250,T=class{constructor(e,t,r){this.logger=e;this.inputField=t;this.sink=r;this.changes=new Q(t.value.length,this.pushLow,e,r.reserveCaptureSeq),this.pasteObserver=new $([t],e,(i,o,s)=>{this.changes.flush(),this.changes.markInputObserved();let a=this.changes.previousLength;this.changes.previousLength=t.value.length,this.pushLow({...s===void 0?{}:{captureSeq:s},lowType:"input-paste",ts:i,inputEffect:t.value.length===0?"clear":a===0?"fill":"modify"})},r.reserveCaptureSeq),this.boundHandlers={focus:this.wrapHandler("focus",()=>this.handleFocus()),blur:this.wrapHandler("blur",()=>this.handleBlur()),pointerdown:this.wrapHandler("pointerdown",()=>this.enqueueNonInputEvent("pointerdown")),pointerup:this.wrapHandler("pointerup",()=>this.enqueueNonInputEvent("pointerup")),click:this.wrapHandler("click",()=>this.enqueueNonInputEvent("click")),input:i=>{try{this.handleInput(i)}catch(o){this.logger.error("Failed to observe input",o)}},keyup:this.wrapKeyboardHandler("keyup",i=>this.handleKeyUp(i)),pageHide:this.wrapHandler("pagehide",()=>this.flushForTeardown())},this.unregisterInputs=r.registerInputs?.([t],()=>this.flushPending()),this.capturePrefill(),this.attach()}unregisterInputs;changes;pasteObserver;emittedSignals=new Set;firstFocusHandled=!1;mountProbeTimer=null;focusProbeTimer=null;destroyed=!1;boundHandlers;destroy(){if(!this.destroyed){this.destroyed=!0;try{this.mountProbeTimer!==null&&(clearTimeout(this.mountProbeTimer),this.mountProbeTimer=null),this.focusProbeTimer!==null&&(clearTimeout(this.focusProbeTimer),this.focusProbeTimer=null),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;e.addEventListener("focus",this.boundHandlers.focus),e.addEventListener("blur",this.boundHandlers.blur),e.addEventListener("pointerdown",this.boundHandlers.pointerdown),e.addEventListener("pointerup",this.boundHandlers.pointerup),e.addEventListener("click",this.boundHandlers.click),e.addEventListener("input",this.boundHandlers.input),e.addEventListener("keyup",this.boundHandlers.keyup),typeof window<"u"&&window.addEventListener("pagehide",this.boundHandlers.pageHide),typeof document<"u"&&document.activeElement===e&&this.handleFocus(),typeof window<"u"&&(this.mountProbeTimer=setTimeout(()=>this.runEnvProbe(),ti))}detach(){let e=this.inputField;e.removeEventListener("focus",this.boundHandlers.focus),e.removeEventListener("blur",this.boundHandlers.blur),e.removeEventListener("pointerdown",this.boundHandlers.pointerdown),e.removeEventListener("pointerup",this.boundHandlers.pointerup),e.removeEventListener("click",this.boundHandlers.click),e.removeEventListener("input",this.boundHandlers.input),e.removeEventListener("keyup",this.boundHandlers.keyup),typeof window<"u"&&window.removeEventListener("pagehide",this.boundHandlers.pageHide)}pushLow=e=>{this.sink.enqueueLowEvent(e)};runEnvProbe(){try{let e=Dt(),t=Date.now();for(let r of e)this.emittedSignals.has(r)||(this.emittedSignals.add(r),this.pushLow({lowType:r,ts:t}))}catch(e){this.logger.error("Failed to run input env probe",e)}}scheduleFocusProbe(){this.firstFocusHandled||(this.firstFocusHandled=!0,this.focusProbeTimer=setTimeout(()=>this.runEnvProbe(),ri))}capturePrefill(e=!1){this.destroyed||(this.flushPending(),this.changes.capturePrefill(this.inputField.value.length,e))}flushPending(){this.pasteObserver.flush(),this.changes.flush()}enqueueNonInputEvent(e){this.changes.flush(),this.pushLow({lowType:e,ts:Date.now()})}handleFocus(){this.scheduleFocusProbe(),this.enqueueNonInputEvent("focus")}handleBlur(){this.pasteObserver.flush(),this.enqueueNonInputEvent("blur")}handleInput(e){this.pasteObserver.handlesInput(e)||this.changes.record(this.inputField.value.length,Date.now(),e.isComposing||e.inputType==="insertCompositionText")}handleKeyUp(e){e.key==="Escape"&&this.enqueueNonInputEvent("keyup-escape")}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)}}}wrapKeyboardHandler(e,t){return r=>{try{t(r)}catch(i){this.logger.error(`Failed to handle low event "${e}"`,i)}}}};var be=class{constructor(e,t,r){this.logger=e;this.sink=r;this.inputs=[...new Set(t)],this.changes=new Q(this.length(),i=>r.enqueueLowEvent(i),e,r.reserveCaptureSeq),this.paste=new $(this.inputs,e,(i,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:i,inputEffect:this.length()===0?"clear":a===0?"fill":"modify"})},r.reserveCaptureSeq),this.unregisterInputs=r.registerInputs?.(this.inputs,()=>this.flushPending()),this.capturePrefill();for(let i of this.inputs){this.listen(i,"input",o=>{this.paste.handlesInput(o)||(this.composing||=o.isComposing||o.inputType==="insertCompositionText",this.changeTimer===null&&(this.changeTime=Date.now(),this.changeSeq=r.reserveCaptureSeq?.(),this.changeTimer=setTimeout(()=>this.safe(()=>this.flushChanges()),0)))}),this.listen(i,"focus",o=>{this.contains(o.relatedTarget)||this.emit("focus")}),this.listen(i,"blur",o=>{this.contains(o.relatedTarget)||(this.flushPending(),this.emit("blur"))});for(let o of["click","pointerdown","pointerup"])this.listen(i,o,()=>this.emit(o));this.listen(i,"keyup",o=>{o.key==="Escape"&&this.emit("keyup-escape")})}typeof window<"u"&&this.listen(window,"pagehide",()=>{this.flushPending(),r.flushKeepalive()}),typeof document<"u"&&this.contains(document.activeElement)&&this.emit("focus")}inputs;changes;paste;unregisterInputs;listeners=[];changeTimer=null;changeTime=0;changeSeq;composing=!1;destroyed=!1;contains(e){return this.inputs.some(t=>t===e)}length(){return this.inputs.reduce((e,t)=>e+t.value.length,0)}safe(e){try{e()}catch(t){this.logger.error("Failed to observe grouped input",t)}}listen(e,t,r){let i=o=>this.safe(()=>r(o));e.addEventListener(t,i),this.listeners.push(()=>e.removeEventListener(t,i))}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.changeSeq),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 O=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 i=t?this.groupSink:this.inputSink,o={...i,enqueueLowEvent:s=>this.enqueue(i,s)};this.collector=t?new be(this.logger,r,o):new T(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 we=class extends g{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 O(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 Te=class extends g{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 O(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 ii=["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 Mt(n){if(!n)return!1;let e=n.toLowerCase();return ii.some(t=>e.includes(t))}var Ht="@corbado/observe",Bt="1.4.0";var rt="cbo_email_link_starts";function it(n,e){let t=n.getItem(rt);return Array.isArray(t)?t.filter(r=>!!r&&typeof r=="object"&&typeof r.transactionId=="string"&&typeof r.anchor=="string"&&typeof r.sessionId=="string"&&typeof r.startedAt=="number"&&e-r.startedAt<864e5):[]}function Nt(n,e){if(n)try{let t=it(n,e.startedAt).filter(r=>r.transactionId!==e.transactionId);t.push(e),n.setItem(rt,t.slice(-10))}catch{}}function Ut(n,e,t=Date.now()){if(n)try{let r=it(n,t);if(e.transactionId)return r.find(o=>o.transactionId===e.transactionId);let i=r.filter(o=>!o.continued&&(!e.specType||!o.specType||o.specType===e.specType));return i[i.length-1]}catch{return}}function qt(n,e){if(n)try{let t=it(n,Date.now()).map(r=>r.transactionId===e?{...r,continued:!0}:r);n.setItem(rt,t)}catch{}}var Ee=class extends g{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||v(),this.subflowStart({explicitSpecType:t.explicitSpecType},{userReference:{crossEnvironmentTransactionIDStart:this.transactionId}});let r=this.captureReference,i=this.captureSession;r&&i&&Nt(e.getPersistentStorage(),{transactionId:this.transactionId,anchor:r,sessionId:i,specType:t.explicitSpecType,startedAt:Date.now()})}},xe=class extends g{postResponse;resend;mode;continuationTracker;specType;createdAt=Date.now();transaction;started=!1;deferred=[];onPageHide=()=>this.flush();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(),i=Ut(r,{transactionId:t.transactionId,specType:t.explicitSpecType});if(i&&i.sessionId===e.getSessionId()){this.mode="attached",this.transaction=t.transactionId??i.transactionId,this.adoptCapture(i.anchor,i.sessionId,i.specType??t.explicitSpecType),this.started=!0;return}this.mode="detached",this.transaction?this.startDetached(this.createdAt):typeof window<"u"&&window.addEventListener("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"&&window.removeEventListener("pagehide",this.onPageHide)}deferrable(e,t=!1){let r=(i,o)=>{if(this.started){i(o?.explicitTimestamp??Date.now());return}this.deferred.push({at:o?.explicitTimestamp??Date.now(),run:i})};return{start:(i,o)=>r(s=>e.start(i,{...o,explicitTimestamp:s}),o),finished:(i,o)=>{r(s=>e.finished(i,{...o,explicitTimestamp:s}),o),t&&this.transaction&&qt(this.continuationTracker.getPersistentStorage(),this.transaction)},error:(i,o)=>r(s=>e.error(i,{...o,explicitTimestamp:s}),o)}}};var ke=class extends g{getOptions;ceremony;postResponse;lowEventTracker;constructor(e,t){super(e,"passkey-enrollment"),this.lowEventTracker=new V(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()}};function Kt(n){let e=n.debug,t,r=(i,o)=>`[Corbado Observe SDK ${i}] ${o}`;return{reportTelemetry(i,o){if(t)try{t(i,o)}catch{}},setTelemetrySink(i){t=i},debug(i,...o){e&&console.log(r("DEBUG",i),...o)},info(i,...o){e&&console.log(r("INFO",i),...o)},warn(i,...o){e&&console.warn(r("WARN",i),...o)},error(i,...o){e&&console.error(r("ERROR",i),...o)},critical(i,...o){console.error(r("CRITICAL",i),...o)}}}var Ie=class extends g{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 T(e.getLogger(),t.identifierInputHtmlField,this.lowEventSink("input","identifier"))),this.registerLowFlusher(()=>this.identifierLowEventTracker?.flushPending())),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new T(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 Ce=class extends g{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 T(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","password"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var Oe=class extends g{lowEventTracker;cui;provideIdentifier;constructor(e,t){super(e,"provide-identifier"),this.cui={trigger:(r,i)=>{this.trigger(r,i)},getOptions:this.defineStep("cui-get-options",!0),ceremony:this.defineStep("cui-ceremony"),postResponse:this.defineStep("cui-post-response")},this.provideIdentifier={trigger:(r,i)=>{this.trigger(r,i)},clientValidation:this.defineStep("pi-client-validation"),postResponse:this.defineStep("pi-post-response")},this.subflowStart({explicitSpecType:t?.explicitSpecType}),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new T(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","identifier"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var Pe=class extends g{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})}};var Le=class extends g{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:i,actor:o}=ni(t??{},e);this.subflowStart({explicitSpecType:r,organizationDomain:i,actor:o})}};function ni(n,e){let t={...n},r=o=>{try{e.getLogger().warn(`SSO login: unsupported ${o}; omitted from telemetry`)}catch{}},i=t.organizationDomain;return i!==void 0&&(typeof i!="string"||i.includes("@")||i.length>253)&&(delete t.organizationDomain,r("organizationDomain")),t.actor!==void 0&&t.actor!=="user"&&t.actor!=="system"&&(delete t.actor,r("actor")),t}var Re=class extends g{lowEventTracker;postResponse;constructor(e,t={}){super(e,"totp"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType}),this.lowEventTracker=this.createLowCollector(()=>new O(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 Fe=class extends g{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 Ae=class extends g{ceremony;postResponse;constructor(e,t={}){super(e,"captcha"),this.ceremony=this.defineStep("ceremony"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType})}};function nt(n,e,t){if(n===null||typeof n!="object")return n;try{let r={...n};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[i,o]of[["bindingReference",255],["trustName",128]])if(typeof r[i]=="string"&&[...r[i]].length>o){delete r[i];try{t.getLogger().debug(`Trusted device: omitted ${i} exceeding ${o} characters`)}catch{}}return r}catch{return n}}function _e(n,e,t){return{...n,start:(r,i)=>n.start(nt(r,e,t),i),finished:(r,i)=>n.finished(nt(r,e,t),i)}}var De=class extends g{getOptions;ceremony;postResponse;constructor(e,t){super(e,"trusted-device-check"),t=Vt(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 i=this.defineStep(e,!0);return{..._e(i,t,r),errorTyped:(o,s)=>{i.errorTyped(nt({code:o?.code,error:D(o?.error)},t,r),s)}}}},Me=class extends g{getOptions;ceremony;postResponse;constructor(e,t){super(e,"trusted-device-enrollment"),t=Vt(t,e);let r={purpose:t.purpose,storage:t.storage,trustName:t.trustName};this.getOptions=_e(this.defineStep("get-options"),r,e),this.ceremony=_e(this.defineStep("ceremony"),r,e),this.postResponse=_e(this.defineStep("post-response"),r,e),this.subflowStart({explicitSpecType:t.explicitSpecType})}};function Vt(n,e){let t={...n},r=i=>{try{e.getLogger().warn(`Trusted device: missing or unsupported ${i}; 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 He=class extends g{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,...i}=t;this.subflowStart(i),r&&(this.lowEventTracker=this.createLowCollector(()=>new T(e.getLogger(),r,this.lowEventSink("input","data"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var Be=String.raw`-extension://[^/]+`,oi="/inline/injected/webauthn-listeners.js",Qt=/\/dashlane-(?:shadow-dom|top-layer)-page-script\.js/,si=new RegExp(`${Be}/content-scripts/passkey_proxy/index\\.js$`),ai=new RegExp(`${Be}/content_scripts/shadow-dom/shadowAttachNotifier\\.js:`),$t=new RegExp(`${Be}/js/nordpass-script\\.js:`),li=new RegExp(`${Be}/js/passkeys\\.js:`),pi=/["'`](?:keeper:shadow-root-attached|webauthn-(?:get|create)-request)["'`]/,di=/Intercept cancelled for `(?:get|create)`|["'`](?:conditionalMediationAvailable|verifyingPlatformAuthenticatorAvailable)["'`]/,ot=()=>Object.keys(window._sentryDebugIds??{}),st=n=>{try{n()}catch(e){return String(e?.stack??"")}return""},Gt=()=>st(()=>Element.prototype.attachShadow.call(null,{mode:"open"})),ui=()=>{let n=Object.getOwnPropertyDescriptor(navigator.credentials??{},"get");if(!n?.get||!n.set||n.configurable)return!1;let e=()=>{},t=n.get.call({_get:e});return t===e||typeof t=="function"&&t===n.get.call({})&&!Function.prototype.toString.call(t).includes("[native code]")},at=(...n)=>{let e=navigator.credentials;return e?n.map(t=>Object.getOwnPropertyDescriptor(e,t)?.value):[]},ci=()=>[navigator.credentials?.get,...at("get","_get")].some(n=>typeof n=="function"&&n.name==="getWebAuthnCredential"),hi=()=>{let n=document.documentElement,e=document.adoptedStyleSheets;if(!n||typeof n.getAnimations!="function"||typeof e?.push!="function"||n.getAnimations().length>0)return!1;let t=new CSSStyleSheet;t.replaceSync(":where(:root){animation:bitwardenfill 1s 1000s paused}"),e.push(t);try{let r=n.getAnimations().filter(i=>i.animationName==="bitwardenfill");return r.forEach(i=>i.cancel()),r.length>0}finally{let r=e.indexOf(t);r>=0&&e.splice(r,1)}},fi,gi=()=>fi??=hi(),mi=()=>{let n=typeof PublicKeyCredential>"u"?void 0:PublicKeyCredential;if(typeof n!="function"||!Object.prototype.hasOwnProperty.call(n,Symbol.hasInstance))return!1;let e=n[Symbol.hasInstance]({});return e instanceof Promise?(e.catch(()=>{}),!0):!1},yi=()=>{let n={get nodeType(){throw new Error("probe")}};return st(()=>MutationObserver.prototype.observe.call(null,n))},vi=()=>{let n=new Error("probe"),e=[],t={get nodeType(){return e.push("nodeType"),1},get ownerDocument(){throw e.push("ownerDocument"),n}};try{MutationObserver.prototype.observe.call(null,t)}catch(r){return r===n&&e.join()==="nodeType,ownerDocument"}return!1},Si=()=>[Element.prototype.attachShadow,navigator.credentials?.get,navigator.credentials?.create,...at("get","_get","create")].some(e=>typeof e=="function"&&pi.test(Function.prototype.toString.call(e))),bi=()=>{let n=document;for(;n;){if(n.querySelector("[data-lastpass-icon-root], [data-lastpass-root]"))return!0;n=n.activeElement?.shadowRoot}return!1},wi=()=>{let n=typeof PublicKeyCredential>"u"?void 0:PublicKeyCredential;return[navigator.credentials?.get,...at("get","_get"),n?.isConditionalMediationAvailable,n?._isConditionalMediationAvailable,n?.isUserVerifyingPlatformAuthenticatorAvailable,n?._isUserVerifyingPlatformAuthenticatorAvailable].some(t=>typeof t=="function"&&di.test(Function.prototype.toString.call(t)))},Ti=[{name:"1password",signal:"in-field button",signedIn:!0,test:()=>document.querySelector("com-1password-button")!==null},{name:"1password",signal:"credentials.get accessor",test:ui},{name:"1password",signal:"Sentry debug id",test:()=>ot().some(n=>n.includes(oi))},{name:"bitwarden",signal:"passkey override",signedIn:!0,test:ci},{name:"bitwarden",signal:"autofill keyframes",test:gi},{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:mi},{name:"dashlane",signal:"page script stack",test:()=>Qt.test(Gt())||typeof HTMLDialogElement<"u"&&Qt.test(st(()=>HTMLDialogElement.prototype.showModal.call(null)))},{name:"kaspersky",signal:"passkey proxy flag",test:()=>window.wasKPMKeyPassProxyInited===!0},{name:"kaspersky",signal:"injected script tag",test:()=>si.test(document.querySelector('script[src*="/content-scripts/passkey_proxy/"]')?.src??"")},{name:"keeper",signal:"attachShadow stack",test:()=>ai.test(Gt())},{name:"keeper",signal:"override source",test:Si},{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:bi},{name:"nordpass",signal:"observer proxy stack",test:()=>$t.test(yi())},{name:"nordpass",signal:"observer read order",test:vi},{name:"nordpass",signal:"passkeys Sentry debug id",test:()=>ot().some(n=>li.test(n))},{name:"nordpass",signal:"Sentry debug id",test:()=>ot().some(n=>$t.test(n))},{name:"protonpass",signal:"WebAuthn override source",test:wi},{name:"protonpass",signal:"field icon",test:()=>document.querySelector("[data-protonpass-role]")!==null}];function Ei(){return typeof window>"u"||typeof document>"u"?[]:Ti.map(({name:n,signal:e,signedIn:t,test:r})=>{try{return{name:n,signal:e,signedIn:t,matched:r()}}catch(i){return{name:n,signal:e,signedIn:t,matched:!1,error:i}}})}function Wt(){let n=new Map;for(let{name:e,signedIn:t,matched:r}of Ei()){if(!r)continue;let i=n.get(e)??{name:e};t&&(i.signedIn=!0),n.set(e,i)}return[...n.values()]}var zt=3e3,xi=500,ki=6,Ii=1e3,Ne=class{constructor(e,t,r){this.logger=e;this.isEnabled=t;if(typeof window>"u"||typeof document>"u")return;if(this.sample(),document.readyState==="complete")this.sampleAfter(zt);else{let o=()=>{this.sampleWhenIdle(),this.sampleAfter(zt)};window.addEventListener("load",o,{once:!0}),this.removers.push(()=>window.removeEventListener("load",o))}let i=r.onInputFocus(o=>{!this.isEnabled()||this.sampledFields.has(o)||(this.sampledFields.add(o),++this.focusSamples>=ki&&i(),this.sampleAfter(xi))});this.removers.push(i)}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:Ii});this.idleCallbacks.add(e)}sample(){if(!(this.destroyed||!this.isEnabled()))try{for(let e of Wt()){let t=this.detected.get(e.name);(!t||e.signedIn&&!t.signedIn)&&this.detected.set(e.name,e)}}catch(e){this.logger.error("Failed to detect password manager extensions",e)}}};var lt={name:Ht,version:Bt},Ci=/^[0-9A-Za-z.+_-]{1,32}$/;function Oi(n,e){return n===void 0?lt:typeof n=="string"&&Ci.test(n)?{...lt,integrationVersion:n}:(e.debug("Ignoring invalid integrationVersion (expected <= 32 chars of [0-9A-Za-z.+_-])"),lt)}var jt="cbo_session_id",pt="cbo_session",A="cbo_seq",Yt="cbo_experiments",Xt="cbo_data_policy",Pi=255,Li=/^[A-Za-z0-9_-]+$/,Ri=128,Fi=256,Jt=1e3,Ai=/^[a-z][a-z0-9_-]{0,31}$/,Zt=/^[A-Za-z0-9_-]{1,16}$/,_i=64,Di=32,Mi=50,Hi="cbo_seq",er=1e3,tr=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Ue=class n{constructor(e){this.options=e;this.options.debug=e.debug??!1,this.logger=e.logger??Kt({debug:this.options.debug});let t=new ce(this.logger),r=new fe(this.logger),i=e.storage==="cookie",o=i?new he(this.logger,e.cookieDomain):void 0;Ft(e.projectId,t,r,o,this.logger);let s=e.projectId,a=h=>new ue(h,s);this.seqLockName=I(Hi,s),this.sessionStorage=a(r),this.persistentStorage=a(t),this.storage=a(o??t),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]}};let l=Object.keys(S).every(h=>this.configOverrides[h]!==void 0)&&Object.keys(S.retry).every(h=>this.configOverrides.retry?.[h]!==void 0);l||(this.configManager=new ve(e.apiBaseUrl+(e.apiConfigPath??"/v1/observe/config")+"/"+e.projectId,this.persistentStorage,this.logger));let d=this.configManager?.initialConfig;this.config=Qe(d,this.configOverrides),!l&&!d&&e.flushInterval!=null&&this.configOverrides.flushIntervalMs===void 0&&(this.config={...this.config,flushIntervalMs:e.flushInterval}),!l&&!d&&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 p=e.apiBaseUrl+(e.apiEventPath??"/v1/observe/events")+"/"+e.projectId;this.logger.debug(`Using API endpoint: ${p}`);let u=new oe({logger:this.logger,url:p});this.sessionId=this.resolveSessionId(),this.queue=new le(this.logger,u,this.sessionId,Oi(this.options.integrationVersion,this.logger),{debug:this.options.debug,config:this.config,requestConfig:!1,outboxLockName:I($e,s),getDataPolicy:()=>this.dataPolicy},this.persistentStorage),this.telemetryReady=!0,this.logger.setTelemetrySink?.((h,m)=>this.reportTelemetry(h,m));try{this.getWindowObserver()}catch(h){this.logger.error("Failed to attach page low-event observer",h)}try{this.passwordManagerSampler=this.isTrackingBlocked()?void 0:new Ne(this.logger,()=>this.config.pmd,this.getWindowObserver())}catch(h){this.logger.error("Failed to start password manager detection",h)}let c=this.pendingSelfTelemetry;this.pendingSelfTelemetry=[];for(let h of c)this.telemetry(h.level,h.message);let f=new pe(this.logger,this.storage,i?"cookie":"localstorage",this.sessionStorage,()=>({collectorTimeoutMs:this.config.deviceInfoCollectorTimeoutMs,timing:this.config.deviceInfoTiming}),(h,m)=>this.telemetry(h,m));this.deviceCollector=f;let y=e.deviceInfoDebounceTime??3e4;this.deviceInfoManager=new de(this.logger,f,Math.max(1,y),y),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(h=>this.handleConfig(h))}logger;queue;sessionId;storage;sessionStorage;persistentStorage;seqLockName;config;configManager;configOverrides;deviceInfoManager;deviceCollector;eventTabId;seq=0;lastActivityWriteAt=0;experiments={};dataPolicy;telemetryReporting=!1;telemetryReady=!1;reportedTelemetryKeys=new Set;pendingSelfTelemetry=[];probePageId;probeSeqs=new Map;windowObserver;passwordManagerSampler;getWindowObserver(){return this.windowObserver??=new ie(this.logger,(e,t)=>this.enqueueLowEvent(e,t),()=>this.lowEventFlushKeepalive())}handleConfig(e){let t=Qe(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()}:{}}setExperiment(e,t){this.setExperiments({[e]:t})}setExperiments(e){try{if(!e||typeof e!="object")return;let t=!1;for(let[r,i]of Object.entries(e)){if(!n.isValidExperimentKey(r)||!n.isValidExperimentVariant(i)){this.logger.debug(`Ignoring invalid experiment assignment "${String(r)}"`);continue}this.experiments[r]!==i&&(this.experiments[r]=i,t=!0)}t&&this.persistExperiments()}catch(t){this.logger.error("Failed to set experiments",t)}}clearExperiment(e){try{Object.prototype.hasOwnProperty.call(this.experiments,e)&&(delete this.experiments[e],this.persistExperiments())}catch(t){this.logger.error("Failed to clear experiment",t)}}clearExperiments(){try{if(Object.keys(this.experiments).length===0)return;this.experiments={},this.persistExperiments()}catch(e){this.logger.error("Failed to clear experiments",e)}}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(!n.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<=Pi}loadPersistedDataPolicy(){try{let e=this.persistentStorage.getItem(Xt);return n.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(Xt,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<=Ri&&Li.test(e)}static isValidExperimentVariant(e){return typeof e=="string"&&e.length>0&&e.length<=Fi}loadPersistedExperiments(){try{let e=this.persistentStorage.getItem(Yt);if(!e||typeof e!="object")return{};let t={};for(let[r,i]of Object.entries(e))n.isValidExperimentKey(r)&&n.isValidExperimentVariant(i)&&(t[r]=i);return t}catch(e){return this.logger.debug("Failed to load persisted experiments",e),{}}}persistExperiments(){try{this.persistentStorage.setItem(Yt,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,i]of Object.entries(e))n.isValidExperimentKey(r)&&n.isValidExperimentVariant(i)&&(t[r]=i);return Object.keys(t).length>0?t:void 0}isTrackingBlocked(){return typeof navigator>"u"?!1:Mt(navigator.userAgent)}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=v();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(pt);if(t?.id&&e-t.lastActiveAt<this.config.sessionInactivityMs)return this.persistContinuitySession(t.id,e),this.seq=this.persistentStorage.getItem(A)??0,t.id;if(!t?.id){let i=this.readPerTabSession();if(i&&e-i.lastActiveAt<this.config.sessionInactivityMs)return this.persistContinuitySession(i.id,e),this.persistentStorage.setItem(A,0),this.seq=0,this.logger.debug("Adopted per-tab session id as continuity session",i.id),i.id}let r=v();return this.persistContinuitySession(r,e),this.persistentStorage.setItem(A,0),this.seq=0,this.logger.debug("Created continuity session id",r),r}persistContinuitySession(e,t){this.lastActivityWriteAt=t,this.persistentStorage.setItem(pt,{id:e,lastActiveAt:t})}readPerTabSession(){let e=this.sessionStorage.getItem(jt);if(e){if(typeof e=="string")return tr.test(e)?{id:e,lastActiveAt:Date.now()}:void 0;if(typeof e.lastActiveAt=="number")return tr.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(jt,{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();return this.sessionId&&r-this.lastActivityWriteAt>=er&&this.persistPerTabSession(this.sessionId,r),this.seq++}let e=()=>{let r=Date.now(),i=this.persistentStorage.getItem(pt),o=!1;if(!i?.id&&this.sessionId)this.persistContinuitySession(this.sessionId,r);else if(i?.id)r-this.lastActivityWriteAt>=er&&this.persistContinuitySession(i.id,r),i.id!==this.sessionId&&(this.sessionId=i.id,this.queue.setSessionId(i.id),o=!0);else{let l=v();this.persistContinuitySession(l,r),this.persistentStorage.setItem(A,0),this.sessionId=l,this.queue.setSessionId(l),this.seq=0,o=!0}let s=this.persistentStorage.getItem(A);o&&(this.seq=typeof s=="number"?s:0);let a=typeof s=="number"&&s>this.seq?s:this.seq;return this.seq=a+1,this.persistentStorage.setItem(A,this.seq),a},t=this.config.seqLockTimeoutMs;return t===0||typeof navigator>"u"||!navigator.locks?.request?e():se(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")return;let e=wt(window.location.search,this.config.sourcePathQuery,this.config.sourcePathQueryAllow);return`${window.location.pathname}${e}`}resolveEventTabId(){return this.eventTabId===void 0&&(this.eventTabId=this.deviceCollector.getTabId()),this.eventTabId}trackSubflowStarted(e,t,r,i){let o={subflowType:e,...t};this.track("subflow_started",o,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{id:i,subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}trackSubflowTrigger(e,t,r){let i={subflowType:e,...t};this.track("subflow_trigger",i,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}trackSubflowStepStarted(e,t,r,i,o){let s={subflowType:e,stepName:t,stepData:r,identifier:i?.identifier,ignoreAsInteraction:o};this.track("subflow_step_started",s,i?.userReference,void 0,void 0,i?.explicitTimestamp,i?.experiments,{subflowStartEventId:i?.subflowStartEventId,sessionId:i?.captureSessionId,initiator:i?.initiator})}trackSubflowStepFinished(e,t,r,i){let o={subflowType:e,stepName:t,stepData:r,identifier:i?.identifier};this.track("subflow_step_finished",o,i?.userReference,void 0,void 0,i?.explicitTimestamp,i?.experiments,{subflowStartEventId:i?.subflowStartEventId,sessionId:i?.captureSessionId,initiator:i?.initiator})}trackSubflowStepError(e,t,r,i){let o={subflowType:e,stepName:t,stepData:r,identifier:i?.identifier};this.track("subflow_step_error",o,i?.userReference,void 0,void 0,i?.explicitTimestamp,i?.experiments,{subflowStartEventId:i?.subflowStartEventId,sessionId:i?.captureSessionId,initiator:i?.initiator})}trackSubflowError(e,t,r){let i={subflowType:e,stepData:t};this.track("subflow_error",i,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}async track(e,t,r,i,o,s,a,l){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=s??Date.now(),p=l?.id??v(),u=l?.sessionId??this.sessionId,c=this.nextSeq(),f=typeof c=="number"?c:await c,y=this.resolveTrackingSourcePath(),h={type:"predefined",name:e,id:p,timestamp:d,seq:f,data:t,user:r,contexts:o,tags:i,experiments:this.resolveExperiments(a),meta:{captureVersion:1,pageId:ne(),initiator:l?.initiator,trackingSourcePath:y??"",subflowStartEventId:l?.subflowStartEventId,tabId:this.resolveEventTabId()}},m=this.deviceInfoManager.getForEvent();m&&(h.deviceInfo=m),this.logger.debug(`Track: ${e}`,JSON.stringify(h,null,2));let E=this.passwordManagerSampler?.takeReport(u);E&&(h.passwordManagers=E),this.queue.enqueue(h,u)}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,i){try{let o=v(),s=this.sessionId,a={...this.options.defaultTags,...this.applicationTag(),...t};return this.track("flow_started",e,void 0,a,i,void 0,r,{id:o,sessionId:s}),this.flowHandle(o,s)}catch(o){return this.logger.warn("Failed to start flow",o),{enrich:async()=>{}}}}flowDecided(e,t,r){this.track("flow_decided",e,void 0,t,void 0,void 0,r)}conversion(e,t,r){let{userId:i,identifier:o,crossEnvironmentTransactionID:s,...a}=e,l={userId:i,identifier:o,crossEnvironmentTransactionID:s},d={...this.options.defaultTags,...this.applicationTag(),...t};this.track("conversion",a,l,d,void 0,void 0,r)}flowFinished(e,t,r){try{let{userId:i,identifier:o,...s}=e,a={userId:i,identifier:o},l=v(),d=this.sessionId;return this.track("flow_finished",s,a,t,void 0,void 0,r,{id:l,sessionId:d}),this.flowHandle(l,d)}catch(i){return this.logger.warn("Failed to finish flow",i),{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(i){this.logger.warn("Failed to enrich flow",i)}}}}flowReset(e,t,r){this.track("flow_reset",e,void 0,t,void 0,void 0,r)}flowAutoFinished(e,t,r){let{userId:i,identifier:o,...s}=e,a={userId:i,identifier:o};this.track("flow_auto_finished",s,a,t,void 0,void 0,r)}setUser(e){this.track("flow_enriched",{match:{flowType:"*",at:"during"},expFol:!0},{...e})}setFlowTags(e,t){try{if(!e||typeof e!="object"){this.logger.warn("setFlowTags: ignoring non-object tags");return}let r={};for(let[o,s]of Object.entries(e)){if(o===""||typeof s!="string"){this.logger.warn(`setFlowTags: ignoring invalid tag "${o}"`);continue}r[o]=s}if(Object.keys(r).length===0)return;let i={match:{flowType:t?.flowType??"*",at:"during"}};t?.expandToChildren!==void 0&&(i.expCh=t.expandToChildren),t?.expandToFollowing!==void 0&&(i.expFol=t.expandToFollowing),this.track("flow_enriched",i,void 0,r)}catch(r){this.logger.warn("Failed to set flow tags",r)}}authMethodsDecisionStarted(e,t,r,i){this.track("auth_method_decision_started",e,void 0,t,void 0,i?.explicitTimestamp,r)}authMethodsDecisionFinished(e,t,r){this.track("auth_method_decision_finished",e,void 0,t,void 0,void 0,r)}authDecisionStarted(e,t,r){this.track("auth_decision_started",e,void 0,t,void 0,void 0,r)}authDecisionFinished(e,t,r){this.track("auth_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??k(),captureVersion:1,pageId:e.pageId??ne()},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 i={id:v(),level:e,message:r.length>Jt?r.slice(0,Jt):r,ts:Date.now()};this.queue.enqueueTelemetry(i)}catch(r){this.logger.error("Failed to process telemetry before enqueue",r)}}probe(e){try{if(this.isTrackingBlocked()){this.logger.debug("Skipping probe for blocked user agent.");return}if(!e||typeof e!="object"||typeof e.kind!="string"||!Ai.test(e.kind)){this.logger.debug("Dropping probe with an invalid kind.");return}let t=e.payload;if(!t||typeof t!="object"){this.logger.debug(`Dropping probe "${e.kind}" without an object payload.`);return}let r=typeof e.pageId=="string"&&Zt.test(e.pageId)?e.pageId:this.defaultProbePageId(),i={id:v(),kind:e.kind,ts:typeof e.ts=="number"&&Number.isFinite(e.ts)?Math.round(e.ts):Date.now(),pageId:r,seq:this.nextProbeSeq(r),payload:t};typeof e.cfg=="string"&&Zt.test(e.cfg)&&(i.cfg=e.cfg);let o=Ui(e.ctx);o&&(i.ctx=o),this.queue.enqueueProbe(i)}catch(t){this.logger.error("Failed to process probe before enqueue",t)}}defaultProbePageId(){return this.probePageId??=Ni()}nextProbeSeq(e){let t=this.probeSeqs.get(e)??0;if(this.probeSeqs.delete(e),this.probeSeqs.set(e,t+1),this.probeSeqs.size>Di){let r=this.probeSeqs.keys().next().value;r!==void 0&&this.probeSeqs.delete(r)}return t}logInfo(e){this.telemetry("info",e)}logError(e){this.telemetry("error",e)}reportTelemetry(e,t){if(!this.telemetryReporting){this.telemetryReporting=!0;try{if(this.reportedTelemetryKeys.has(t)||this.reportedTelemetryKeys.size>=Mi)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")}passkeyLoginFullOperation(e){return new Se(this,e)}passkeyEnrollmentFullOperation(e){return new ke(this,e)}passwordLoginFullOperation(e){return new Ie(this,e)}passwordEnrollmentFullOperation(e){return new Ce(this,e)}emailLinkOperationFull(e){return new Ee(this,e)}continueEmailLinkOperation(e){return new xe(this,e)}emailOtpOperationFull(e){return new we(this,e)}smsOtpOperationFull(e){return new Te(this,e)}totpOperationFull(e){return new Re(this,e)}provideIdentifierOperationFull(e){return new Oe(this,e)}provideDataOperationFull(e){return new He(this,e)}socialLoginOperationFull(e){return new Pe(this,e)}ssoLoginOperationFull(e){return new Le(this,e)}appConfirmationOperationFull(e){return new Fe(this,e)}keySigningOperationFull(e){return new te(this,e)}keyRegistrationOperationFull(e){return new re(this,e)}captchaOperationFull(e){return new Ae(this,e)}trustedDeviceCheckOperationFull(e){return new De(this,e)}trustedDeviceEnrollmentOperationFull(e){return new Me(this,e)}async destroy(){if(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.resolveSessionId();e&&(this.sessionId=e,this.queue.setSessionId(e))}return this.sessionId||void 0}resetSession(){let e=v();return this.config.sessionContinuity?(this.persistContinuitySession(e,Date.now()),this.persistentStorage.setItem(A,0)):this.persistPerTabSession(e,Date.now()),this.sessionId=e,this.seq=0,this.queue.setSessionId(e),this.logger.debug(`Session reset: ${e}`),e}},Bi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";function Ni(){let n=new Uint8Array(16);try{globalThis.crypto.getRandomValues(n)}catch{for(let t=0;t<n.length;t++)n[t]=Math.floor(Math.random()*256)}let e="";for(let t=0;t<n.length;t++)e+=Bi[n[t]&63];return e}function Ui(n){if(!n||typeof n!="object")return;let e={};for(let t of["state","flowType","step"]){let r=n[t];typeof r=="string"&&r.length>0&&(e[t]=r.slice(0,_i))}return Object.keys(e).length>0?e:void 0}var dt={};function rr(n,e="default"){dt[e]=new Ue(n)}function ir(n="default"){if(!dt[n])throw new Error(`Tracker ${n} not initialized (call Corbado.init() first)`);return dt[n]}function qi(n){for(let e of n)rr(e[0],e[1])}var nr={};function or(n,e,t=[],r){let i=ir(n),o=i[e];if(typeof o!="function")return;let s=o.apply(i,t);r&&s&&typeof s=="object"&&(nr[r]=s)}function sr(n,e,t=[]){let r=nr[n];if(!r)return;let i=e.split("."),o=r;for(let a=0;a<i.length-1;a++)if(o=o?.[i[a]],!o)return;let s=o[i[i.length-1]];typeof s=="function"&&s.apply(o,t)}function Ki(n){for(let e of n)or(e[0],e[1],Array.isArray(e[2])?e[2]:[],e[3])}function Vi(n){for(let e of n)sr(e[0],e[1],Array.isArray(e[2])?e[2]:[])}typeof window<"u"&&(window.Corbado?.IQ&&(qi(window.Corbado.IQ),delete window.Corbado.IQ),window.Corbado?.MQ&&(Ki(window.Corbado.MQ),delete window.Corbado.MQ),window.Corbado?.OQ&&(Vi(window.Corbado.OQ),delete window.Corbado.OQ),window.Corbado={init:rr,get:ir,__dispatchMethod:or,__dispatchOp:sr});})();
|
|
1
|
+
"use strict";(()=>{var ct=0;function x(){if(ct===4294967295)throw new Error("Low-event capture sequence exhausted");return++ct}function ht(n,e){if(n==="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(n==="passkey-enrollment")switch(e){case"manual":return"passkey-button";case"auto":case"conditional":return"automatic"}}var S=[];for(let n=0;n<256;++n)S.push((n+256).toString(16).slice(1));function ft(n,e=0){return(S[n[e+0]]+S[n[e+1]]+S[n[e+2]]+S[n[e+3]]+"-"+S[n[e+4]]+S[n[e+5]]+"-"+S[n[e+6]]+S[n[e+7]]+"-"+S[n[e+8]]+S[n[e+9]]+"-"+S[n[e+10]]+S[n[e+11]]+S[n[e+12]]+S[n[e+13]]+S[n[e+14]]+S[n[e+15]]).toLowerCase()}var Ve,fi=new Uint8Array(16);function ie(){if(!Ve){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ve=crypto.getRandomValues.bind(crypto)}return Ve(fi)}var $e={};function gi(n,e,t){let i;if(n)i=gt(n.random??n.rng?.()??ie(),n.msecs,n.seq,e,t);else{let r=Date.now(),o=ie();mi($e,r,o),i=gt(o,$e.msecs,$e.seq,e,t)}return e??ft(i)}function mi(n,e,t){return n.msecs??=-1/0,n.seq??=0,e>n.msecs?(n.seq=t[6]<<23|t[7]<<16|t[8]<<8|t[9],n.msecs=e):(n.seq=n.seq+1|0,n.seq===0&&n.msecs++),n}function gt(n,e,t,i,r=0){if(n.length<16)throw new Error("Random bytes length must be >= 16");if(!i)i=new Uint8Array(16),r=0;else if(r<0||r+16>i.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);return e??=Date.now(),t??=n[6]*127<<24|n[7]<<16|n[8]<<8|n[9],i[r++]=e/1099511627776&255,i[r++]=e/4294967296&255,i[r++]=e/16777216&255,i[r++]=e/65536&255,i[r++]=e/256&255,i[r++]=e&255,i[r++]=112|t>>>28&15,i[r++]=t>>>20&255,i[r++]=128|t>>>14&63,i[r++]=t>>>6&255,i[r++]=t<<2&255|n[10]&3,i[r++]=n[11],i[r++]=n[12],i[r++]=n[13],i[r++]=n[14],i[r++]=n[15],i}var v=gi;function H(n){if(n!=null){if(n instanceof Error)return{name:n.name,message:n.message};if(typeof n=="string")return{message:n};if(typeof n=="object"){let e=n;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(n)}}}var yi={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}},vi=1024,N=class extends Error{},bi=["name","message","code","errors","stack"],Si=/[^\x20-\x7E]/,U=n=>Object.prototype.toString.call(n).slice(8,-1),wi=n=>n===null?"null":typeof n=="object"?U(n):typeof n,Ti=n=>n instanceof Error||U(n)==="Error"||U(n)==="DOMException";function vt(n){return Si.test(n)?new TextEncoder().encode(n).byteLength:n.length}function B(n,e){let t=yi[n];return typeof e!="number"||!Number.isFinite(e)?t.default:Math.min(t.max,Math.max(t.min,Math.floor(e)))}function mt(n={}){return{stack:n.stack===!0,maxStackFrames:B("maxStackFrames",n.maxStackFrames),depth:B("depth",n.depth),maxBreadth:B("maxBreadth",n.maxBreadth),maxValueLength:B("maxValueLength",n.maxValueLength),maxCauseDepth:B("maxCauseDepth",n.maxCauseDepth),maxBytes:B("maxBytes",n.maxBytes)}}function bt(n,e={}){if(n===void 0)return;let t=mt(),i=r=>{let o=JSON.stringify(r);return o===void 0||vt(o)<=t.maxBytes};try{if(t=mt(e),t.maxBytes===0)return;let r=F(wi(n),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 l={type:r,value:re(n,s,a)};if(i(l))return l}catch(l){if(!(l instanceof N))throw l}}let o={type:r,truncated:!0};return i(o)?o:void 0}catch{let r={type:"unserializable"};return i(r)?r:void 0}}function X(n,e){if(n.length>e.limits.maxBytes)throw new N;if(e.textBytes+=vt(JSON.stringify(n)),e.textBytes>e.limits.maxBytes)throw new N;return n}function re(n,e,t){if(++t.nodes>vi)throw new N;let i=Ei(n,e,t);return typeof i=="string"?X(i,t):i}function Ei(n,e,t){switch(typeof n){case"string":return F(n,t.limits.maxValueLength);case"number":return Number.isFinite(n)?n:String(n);case"boolean":case"undefined":return n;case"bigint":case"symbol":return F(String(n),t.limits.maxValueLength);case"function":return`[Function: ${n.name||"anonymous"}]`}if(n===null)return null;let i=n;if(t.seen.has(i))return"[Circular]";if(e<0)return`[${U(i)}]`;t.seen.add(i);try{return Ii(i,e,t)}finally{t.seen.delete(i)}}function F(n,e){return n.length>e?n.slice(0,e)+"\u2026":n}function yt(n,e,t){let i=n.length>t;n=F(n,t);let r=n.split(`
|
|
2
|
+
`);if(r.length<=e+1)return F(n,t);let o=r.slice(0,e+1).join(`
|
|
3
|
+
`),s=i?"[truncated]":`[+${r.length-e-1} frames]`;return F(`${o}
|
|
4
|
+
${s}`,t)}function Ii(n,e,t){let{limits:i}=t,r=U(n),o=u=>re(u,e-1,t);if(r==="Date")return Number.isNaN(n.getTime())?"[Invalid Date]":n.toISOString();if(r==="RegExp")return F(String(n),i.maxValueLength);if(r==="ArrayBuffer")return`[ArrayBuffer(${n.byteLength})]`;if(ArrayBuffer.isView(n))return`[${r}(${n.byteLength})]`;if(r==="Map"||r==="Set"){let u=n,c=[];for(let f of u){if(c.length===i.maxBreadth)break;c.push(o(f))}return u.size>c.length&&c.push(`[+${u.size-c.length} more]`),c}if(r==="Promise"||r==="WeakMap"||r==="WeakSet"||r==="Window")return`[${r}]`;if(typeof Node<"u"&&n instanceof Node)return`[${r}]`;if(Array.isArray(n)){let u=n.slice(0,i.maxBreadth).map(o);return n.length>i.maxBreadth&&u.push(`[+${n.length-i.maxBreadth} more]`),u}if(typeof Response<"u"&&n instanceof Response)return{status:o(n.status),statusText:o(n.statusText),url:o(n.url),redirected:o(n.redirected)};if(typeof Event<"u"&&n instanceof Event){let u=n,c={type:o(u.type)};for(let f of["message","filename","lineno","colno"])f in u&&(c[f]=o(u[f]));return"error"in u&&u.error!=null&&(c.error=o(u.error)),c}let s=Object.create(null),a=n,l=Ti(n);if(l){for(let c of bi){if(c==="stack"&&!i.stack)continue;let f=a[c];if(!(f==null||typeof f=="function")){if(c==="stack"){i.stack&&typeof f=="string"&&(s.stack=X(yt(f,i.maxStackFrames,i.maxValueLength),t));continue}s[c]=o(f)}}let u=a.cause;u!=null&&typeof u!="function"&&(s.cause=ki(u,e-1,t))}let d=0,p=Object.keys(a);for(let u of p){if(u in s||u==="stack"&&!i.stack||l&&u==="cause")continue;if(++d>i.maxBreadth){s["\u2026"]=`[+${p.length-i.maxBreadth} keys]`;break}let c=a[u];typeof c!="function"&&(s[X(u,t)]=u==="stack"&&typeof c=="string"?X(yt(c,i.maxStackFrames,i.maxValueLength),t):o(c))}return!l&&r!=="Object"&&d===0?`[${r}]`:s}function ki(n,e,t){if(typeof n!="object"||n===null)return re(n,e,t);if(t.causeBudget<=0)return X(`[${U(n)}]`,t);t.causeBudget--;try{return re(n,e,t)}finally{t.causeBudget++}}var xi=1500,g=class{constructor(e,t){this.tracker=e;this.operationName=t}startReference;captureSpecType;captureSessionId;lowFlushers=[];lowPrefillCapturers=[];lowEventSink(e,t){return{reserveCaptureSeq:x,enqueueLowEvent:i=>this.tracker.enqueueLowEvent({...i,captureSeq:i.captureSeq??x(),subflowStartEventId:this.startReference,sourceKind:e,fieldRole:t,initiator:i.initiator??(t?`input-${t}`:"unknown")},this.captureSessionId),flushKeepalive:()=>this.tracker.lowEventFlushKeepalive(),registerInputs:(i,r)=>this.tracker.getWindowObserver().registerInputs(i,()=>({subflowStartEventId:this.startReference,fieldRole:t,initiator:t?`input-${t}`:"unknown",sessionId:this.captureSessionId}),r),beginCeremony:i=>this.tracker.getWindowObserver().beginCeremony({subflowStartEventId:this.startReference,initiator:i??"unknown",sessionId:this.captureSessionId})}}createLowCollector(e){try{let t=e();return this.lowPrefillCapturers.push(i=>t.capturePrefill(i)),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,i=this.captureSessionId,r){if(!t&&!r)return e;let o={};return t&&(o.subflowStartEventId=e?.subflowStartEventId??t,o.captureSessionId=e?.captureSessionId??i),r&&(o.initiator=e?.initiator??r),Object.defineProperties({},{...Object.getOwnPropertyDescriptors(e??{}),...Object.getOwnPropertyDescriptors(o)})}get captureReference(){return this.startReference}get captureSession(){return this.captureSessionId}adoptCapture(e,t,i){this.startReference=e,this.captureSessionId=t,this.captureSpecType=i}subflowStart(e,t){try{for(let i of this.lowFlushers)try{i()}catch(r){this.tracker.getLogger().error("Failed to flush previous low-event context",r)}this.captureSpecType=e?.explicitSpecType,this.startReference=v(),this.captureSessionId=this.tracker.getSessionId(),this.tracker.trackSubflowStarted(this.operationName,e,this.captureOptions(t),this.startReference),this.captureInputPrefills(!0)}catch(i){this.tracker.getLogger().error("Failed to start low-event capture context",i)}}capturePrefill(){this.captureInputPrefills(!1)}captureInputPrefills(e){for(let t of this.lowPrefillCapturers)try{t(e)}catch(i){this.tracker.getLogger().error("Failed to capture input prefill",i)}}trigger(e,t){this.tracker.trackSubflowTrigger(this.operationName,e,this.captureOptions(t))}customStep(e){return this.defineStep(e)}subflowStepStarted(e,t,i,r){this.captureSpecType=t?.explicitSpecType??this.captureSpecType,this.tracker.trackSubflowStepStarted(this.operationName,e,t,this.captureOptions(i),r)}subflowStepFinished(e,t,i){(!i?.subflowStartEventId||i.subflowStartEventId===this.startReference)&&(this.captureSpecType=t?.explicitSpecType??this.captureSpecType),this.tracker.trackSubflowStepFinished(this.operationName,e,t,this.captureOptions(i))}subflowStepError(e,t,i){let r=t;try{let o=this.tracker.getSdkConfig().rawErrors?i?.rawError:void 0;o!==void 0&&(r={...t,rawError:bt(o,i?.rawErrorLimits)})}catch{}this.tracker.trackSubflowStepError(this.operationName,e,r,this.captureOptions(i))}withWindowLowEvents(e,t){let i,r=s=>{s?.subflowStartEventId&&s.subflowStartEventId!==i||t.scheduleDisarm(xi)},o=e;return{...e,start:(s,a)=>{i=a?.subflowStartEventId??this.startReference;let l=s?.explicitSpecType??this.captureSpecType,d=a?.initiator??ht(this.operationName,l);t.arm(d,l==="passkey-cui"),o.start(s,d?{...a,initiator:d}:a)},finished:(s,a)=>{o.finished(s,a),r(a)},error:(s,a)=>{o.error(s,a),r(a)},errorTyped:(s,a)=>{o.errorTyped?.(s,a),r(a)}}}defineStep(e,t){let i,r,o,s=l=>this.captureOptions(l,i,r,o);return{start:(l,d)=>{i=this.startReference,r=this.captureSessionId,o=d?.initiator,this.subflowStepStarted(e,l,s(d),t)},finished:(l,d)=>{this.subflowStepFinished(e,l,s(d))},error:(l,d)=>{this.subflowStepError(e,{error:H(l)},s(d))},errorTyped:(l,d)=>{this.subflowStepError(e,l,s(d))}}}};function St(n,e){if(e.explicitSpecType!==void 0)try{n.getLogger().warn("Unsupported key operation spec type; omitting it")}catch{}}var ne=class extends g{prepare;sign;constructor(e,t={}){super(e,"key-signing"),this.prepare=this.defineStep("prepare"),this.sign=this.defineStep("sign"),this.subflowStart({actor:"system",explicitSpecType:St(e,t)})}},oe=class extends g{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:St(e,t)})}};function Ci(n){try{return decodeURIComponent(n.replace(/\+/g," "))}catch{return n}}function Pi(n,e){let t=n.toLowerCase();return e.some(i=>{let r=i.toLowerCase();return r.endsWith("*")?t.startsWith(r.slice(0,-1)):t===r})}function wt(n,e,t){return e!=="allowlist"||n===""||n==="?"?n:`?${(n.startsWith("?")?n.slice(1):n).split("&").map(o=>{let s=o.indexOf("=");if(s===-1)return o;let a=o.slice(0,s);return o.slice(s+1)===""||Pi(Ci(a),t)?o:`${a}=*`}).join("&")}`}var Qe=(n,e,t)=>{let i=!1,r,o=null,s=null,a=()=>{s!==null&&(window.clearTimeout(s),s=null);let d=o;i=!1,o=null,d!==null&&n({...r===void 0?{}:{captureSeq:r},lowType:e,ts:d,durationMs:Date.now()-d})};return{extend:()=>{if(!i){let d=t?.();i=!0,o=Date.now(),r=d}s!==null&&window.clearTimeout(s),s=window.setTimeout(a,150)},flush:a}};var Oi,J=()=>Oi??=v(),Li=()=>{let n=[];for(let e=document.activeElement;e;e=e.shadowRoot?.activeElement??null)n.push(e);return n},se=class{constructor(e,t,i){this.logger=e;this.enqueue=t;this.flushKeepalive=i;typeof window>"u"||typeof document>"u"||(this.listen(window,"blur",()=>{this.flushInputs(),this.bracket=this.context(),this.emit({lowType:"window-blur",ts:Date.now()},this.bracket)}),this.listen(window,"focus",()=>{this.flushInputs(),this.emit({lowType:"window-focus",ts:Date.now()},this.bracket??this.context()),this.bracket=void 0}),this.listen(document,"visibilitychange",()=>{this.flushInputs(),this.emit({lowType:`document-visibilitychange-${document.visibilityState==="hidden"?"hidden":"visible"}`,ts:Date.now()})}),this.listen(document,"focusout",r=>{let o=this.findInput(r.target);this.lastBlur=o&&!r.relatedTarget&&Date.now()-this.unrelatedPointerAt>250?{registration:o,ts:Date.now()}:void 0}),this.listen(document,"focusin",r=>{this.lastBlur=void 0;let o=this.inputFocusListeners.size>0&&r.composedPath().find(s=>this.findInput(s));o&&this.notifyInputFocus(o)}),this.listen(document,"pointerdown",r=>{this.findInput(r.target)?this.unrelatedPointerAt=-1/0:(this.lastBlur=void 0,this.unrelatedPointerAt=Date.now())}),window.visualViewport&&(this.listen(window.visualViewport,"resize",()=>this.extendViewport("resize")),this.listen(window.visualViewport,"scroll",()=>this.extendViewport("scroll"))),this.listen(window,"pagehide",()=>{this.flushInputs(),this.resize.flush(),this.scroll.flush(),this.flushKeepalive()}),this.observeNavigation())}inputs=new Set;inputFocusListeners=new Set;ceremonies=new Set;removers=[];lastBlur;bracket;unrelatedPointerAt=-1/0;destroyed=!1;viewportContext={};resize=Qe(e=>this.emit(e,this.viewportContext.resize),"visualviewport-resize",x);scroll=Qe(e=>this.emit(e,this.viewportContext.scroll),"visualviewport-scroll",x);registerInputs(e,t,i){if(this.destroyed)return()=>{};let r={fields:e,context:t,flush:i};if(this.inputs.add(r),this.inputFocusListeners.size>0&&typeof document<"u"){let o=Li(),s=e.find(a=>o.includes(a));s&&this.notifyInputFocus(s)}return()=>{this.inputs.delete(r),this.lastBlur?.registration===r&&(this.lastBlur=void 0)}}beginCeremony(e){let t={context:e,settled:!1};this.destroyed||(this.flushInputs(),this.ceremonies.add(t));let i=()=>{t.timer&&clearTimeout(t.timer),this.ceremonies.delete(t),this.bracket===t.context&&(this.bracket=void 0)};return{settle:r=>{t.settled=!0,t.timer&&clearTimeout(t.timer),t.timer=setTimeout(i,r)},destroy:i}}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(i){this.logger.error("Failed to notify registered input focus",i)}}context(){let e=[...this.ceremonies].filter(r=>!r.settled);if(e.length===1)return e[0].context;if(e.length>1)return;let t=this.findInput(document.activeElement);if(t)return t.context();let i=this.lastBlur;if(i&&Date.now()-i.ts<=250&&(document.activeElement===document.body||!document.activeElement))return i.registration.context()}findInput(e){return[...this.inputs].find(t=>t.fields.some(i=>i===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:i,...r}=t??{};this.enqueue({...e,...r,captureSeq:e.captureSeq??x(),sourceKind:"window",captureVersion:1,pageId:J()},i)}listen(e,t,i){let r=o=>{try{i(o)}catch(s){this.logger.error(`Failed to observe window ${t}`,s)}};e.addEventListener(t,r),this.removers.push(()=>e.removeEventListener(t,r))}extendViewport(e){let t=this.context(),i=this.viewportContext[e];(i?.subflowStartEventId!==t?.subflowStartEventId||i?.fieldRole!==t?.fieldRole||i?.sessionId!==t?.sessionId)&&this[e].flush(),this.viewportContext[e]=t,this[e].extend()}observeNavigation(){let e=window.navigation;e&&this.listen(e,"currententrychange",t=>{let i=t,r=i.from?.index,o=e.currentEntry?.index;i.navigationType==="traverse"&&typeof r=="number"&&typeof o=="number"&&r>=0&&o>=0&&o<r&&(this.flushInputs(),this.emit({lowType:"window-navigate-back",ts:Date.now()}))})}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 Et="cbo_sdk_config",It="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}},Ri=1800*1e3,b={version:"",flushIntervalMs:500,durableOutbox:!1,durableLowOutbox:!1,beaconKeepalive:!1,sessionContinuity:!1,sessionInactivityMs:Ri,seqLockTimeoutMs:50,tvc:!0,tph:!0,td:!0,tlf:!0,telemetry:!0,flushOnTelemetry:!1,flushOnFlowTypeFinished:[],deviceInfoCollectorTimeoutMs:1e3,deviceInfoTiming:!1,rawErrors:!0,pmd:!1,retry:{maxAttempts:1,baseDelayMs:0,maxDelayMs:0},aap:"",sourcePathQuery:"allowlist",sourcePathQueryAllow:[]};function D(n,e,t){return Math.min(Math.max(n,e),t)}function A(n,e){return typeof n=="number"&&Number.isFinite(n)?n:e}function q(n,e){return typeof n=="boolean"?n:e}function Tt(n,e){return typeof n=="string"?n:e}function Fi(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"&&e.length>0&&e.length<=w.flushOnFlowTypeFinished.maxNameLength).slice(0,w.flushOnFlowTypeFinished.maxEntries):[]}function Di(n){return typeof n=="string"&&n.trim().toLowerCase()==="all"?"all":"allowlist"}function Ai(n){return Array.isArray(n)?n.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 Z(n){if(!n||typeof n!="object")return null;let e=n;return typeof e.version!="string"||e.version===""?null:kt(e)}function kt(n){let e=n.retry&&typeof n.retry=="object"?n.retry:{},t=D(A(e.baseDelayMs,b.retry.baseDelayMs),w.retryDelayMs.min,w.retryDelayMs.max);return{version:Tt(n.version,""),flushIntervalMs:D(A(n.flushIntervalMs,b.flushIntervalMs),w.flushIntervalMs.min,w.flushIntervalMs.max),durableOutbox:n.durableOutbox===!0,durableLowOutbox:n.durableLowOutbox===!0,beaconKeepalive:n.beaconKeepalive===!0,sessionContinuity:n.sessionContinuity===!0,sessionInactivityMs:D(A(n.sessionInactivityMs,b.sessionInactivityMs),w.sessionInactivityMs.min,w.sessionInactivityMs.max),seqLockTimeoutMs:D(A(n.seqLockTimeoutMs,b.seqLockTimeoutMs),w.seqLockTimeoutMs.min,w.seqLockTimeoutMs.max),tvc:q(n.tvc,b.tvc),tph:q(n.tph,b.tph),td:q(n.td,b.td),tlf:q(n.tlf,b.tlf),telemetry:q(n.telemetry,b.telemetry),flushOnTelemetry:n.flushOnTelemetry===!0,flushOnFlowTypeFinished:Fi(n.flushOnFlowTypeFinished),deviceInfoCollectorTimeoutMs:D(A(n.deviceInfoCollectorTimeoutMs,b.deviceInfoCollectorTimeoutMs),w.deviceInfoCollectorTimeoutMs.min,w.deviceInfoCollectorTimeoutMs.max),deviceInfoTiming:n.deviceInfoTiming===!0,rawErrors:q(n.rawErrors,b.rawErrors),pmd:n.pmd===!0,aap:Tt(n.aap,""),sourcePathQuery:Di(n.sourcePathQuery),sourcePathQueryAllow:Ai(n.sourcePathQueryAllow),retry:{maxAttempts:D(A(e.maxAttempts,b.retry.maxAttempts),w.retryMaxAttempts.min,w.retryMaxAttempts.max),baseDelayMs:t,maxDelayMs:D(A(e.maxDelayMs,b.retry.maxDelayMs),t,w.retryDelayMs.max)}}}function Ge(n,e={}){let t=n??b,i=Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0)),r=Object.fromEntries(Object.entries(e.retry??{}).filter(([,s])=>s!==void 0)),o=kt({...t,...i,retry:{...t.retry,...r}});return o.retry={...t.retry,...Object.fromEntries(Object.keys(r).map(s=>[s,o.retry[s]]))},o.retry.maxDelayMs=Math.max(o.retry.baseDelayMs,o.retry.maxDelayMs),o}function xt(n){return Z(n.getItem(Et))}function Ct(n,e){n.setItem(Et,e)}var Mi=6e4,_i=6e4,ae=class{constructor(e){this.options=e}async send(e,t){try{e.meta={...e.meta,sent:Date.now(),transport:"fetch"};let i=JSON.stringify(e),r=typeof AbortController<"u"?new AbortController:void 0,o=r?setTimeout(()=>r.abort(),_i):void 0;try{let s={method:"POST",headers:{"Content-Type":"application/json",...this.options.headers,...t},body:i,keepalive:new Blob([i]).size<=Mi,...r?{signal:r.signal}:{}},a=await fetch(this.options.url,s),l={statusCode:a.status,headers:{"retry-after":a.headers.get("Retry-After")}};if(a.headers.get("X-Corbado-Observe-Accepted")==="1"&&(l.deliveryAccepted=!0),a.status===200)try{let d=Z(await a.json());d&&(l.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 l}finally{o&&clearTimeout(o)}}catch(i){return this.options.logger.error("Failed to send event",i),{}}}sendBeacon(e){try{if(this.options.logger.debug(`Sending ${e.events.length} events via beacon`),typeof navigator?.sendBeacon!="function")return!1;e.meta={...e.meta,sent:Date.now(),transport:"beacon"};let t=new Blob([JSON.stringify(e)],{type:"text/plain"});return navigator.sendBeacon(this.options.url,t)}catch(t){return this.options.logger.error("Failed to send event via beacon",t),!1}}flush(e){return Promise.resolve(!0)}};function le(n,e,t={}){let i=typeof navigator<"u"?navigator.locks:void 0;if(i?.request){let r=t.timeoutMs,o=r!==void 0&&typeof AbortController<"u"?new AbortController:null;if(r!==void 0&&!o)return Promise.resolve().then(e);try{let s=!1,a,l=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},d=()=>(s=!0,l(),e()),p=o?i.request(n,{signal:o.signal},d):i.request(n,d);return o&&r!==void 0&&!s&&(a=setTimeout(()=>{a=void 0,o.abort();try{t.onTimeout?.()}catch{}},r)),p.catch(u=>{if(s)throw u;return e()}).finally(l)}catch{}}try{return Promise.resolve(e())}catch(r){return Promise.reject(r)}}var Hi="cbo_outbox",We="cbo_outbox",Bi=500,Ni=512*1024;function Ui(n){if(!n||typeof n!="object")return!1;let e=n;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 K=class{constructor(e,t,i=Bi,r=Ni,o=We,s=Hi){this.storage=e;this.logger=t;this.maxEntries=i;this.maxSerializedLength=r;this.lockName=o;this.storageKey=s;this.entries=this.read()}entries=[];reportedMalformed=!1;read(){let e=this.storage.getItem(this.storageKey);if(!Array.isArray(e))return[];let t=e.filter(Ui);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 le(this.lockName,()=>{try{let t=e(this.read());if(t.length>this.maxEntries){let i=t.length-this.maxEntries;t=t.slice(t.length-this.maxEntries),this.logger.error(`EventStore evicted ${i} 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),i=t.reduce((o,s)=>o+s,e.length+1),r=0;for(;i>this.maxSerializedLength&&r<e.length;)i-=t[r]+1,r++;return r===0?e:(this.logger.error(`EventStore evicted ${r} oldest entries (size budget ${this.maxSerializedLength})`),this.logger.reportTelemetry?.("error","event store evicted entries (size budget)"),e.slice(r))}add(e){return this.mutate(t=>t.some(i=>i.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(i=>i.filter(r=>!t.has(r.id)))}update(e){if(e.length===0)return Promise.resolve();let t=new Map(e.map(i=>[i.id,i]));return this.mutate(i=>i.map(r=>t.get(r.id)??r))}size(){return this.all().length}};var Ki=500,Vi=512*1024,Pt=200,Ot=200*1024,$i=16*1024,Lt=6e4,ze=32e3;function pe(n){let e=0;for(let t=0;t<n.length;t++){let i=n.charCodeAt(t);i<128?e+=1:i<2048?e+=2:i>=55296&&i<=56319&&t+1<n.length?(e+=4,t++):e+=3}return e}var de=class{constructor(e,t,i,r,o={},s){this.logger=e;this.transport=t;this.sessionId=i;this.sdk=r;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.beforeEventBatchSend=o.beforeEventBatchSend,this.config=o.config??b,this.priorityFlowTypes=new Set(this.config.flushOnFlowTypeFinished),this.outboxLockName=o.outboxLockName,this.config.durableOutbox&&this.storage&&(this.store=new K(this.storage,this.logger,void 0,void 0,this.outboxLockName),this.pending=this.store.all()),this.storage){this.lowStore=new K(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(l=>this.validPendingLow(l)),this.lowStore.remove(a.filter(l=>!this.validPendingLow(l)).map(l=>l.id))}this.setupLifecycleHooks(),(this.pending.length>0||this.lowPending.length>0)&&(this.dirtySinceSyncFlush=!0,this.scheduleFlush(0,"recovery"))}pending=[];lowsQueue=[];lowPending=[];lowStore;telemetryQueue=[];probeQueue=[];probeBytes=0;probesDropped=0;timer=null;isFlushing=!1;flushingDone;destroyed=!1;dirtySinceSyncFlush=!1;onVisibilityChange=null;onPageHide=null;batchSize;flushIntervalOverride;debug;requestConfig;onConfigReceived;getDataPolicy;beforeEventBatchSend;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 i={id:e.id,sessionId:t,flushAfter:0,attempts:0,event:e};this.pending.push(i),this.store?.add(i),this.scheduleAfterEnqueue(e)}catch(i){this.logger.error("Failed to enqueue event",i)}}enqueueLow(e,t=this.sessionId){try{let i={...e,id:e.id??v()};if(this.config.durableLowOutbox){let r={id:i.id,sessionId:t,event:i,attempts:0,flushAfter:0};this.lowPending.push(r),this.lowPending=this.lowPending.slice(-1e3),this.lowStore?.add(r)}else this.lowsQueue.push({sessionId:t,event:i});this.scheduleAfterEnqueue()}catch(i){this.logger.error("Failed to enqueue low event",i)}}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)}}enqueueProbe(e,t=this.sessionId){try{if(this.destroyed)return;let i=JSON.stringify(e.payload);if(typeof i!="string"||pe(i)>$i){this.probesDropped++;return}let r={...e,payload:JSON.parse(i)},o=pe(JSON.stringify(r));for(this.probeQueue.push({sessionId:t,entry:r,bytes:o,attempts:0,flushAfter:0}),this.probeBytes+=o;this.probeQueue.length>Ki||this.probeBytes>Vi&&this.probeQueue.length>1;){let s=this.probeQueue.shift();this.probeBytes-=s.bytes,this.probesDropped++}this.scheduleFlush(this.flushInterval(),"timer")}catch(i){this.logger.error("Failed to enqueue probe",i)}}droppedProbeCount(){return this.probesDropped}dueProbes(e){return this.probeQueue.filter(t=>t.flushAfter<=e)}selectProbes(e,t,i,r){let o=[],s=0;for(let a of e){if(o.length>=i)break;if(a.sessionId===t){if(s+a.bytes>r){o.length===0&&r>=Ot&&o.push(a);break}s+=a.bytes,o.push(a)}}return o}removeProbes(e){if(e.length===0)return;let t=new Set(e);this.probeQueue=this.probeQueue.filter(i=>!t.has(i));for(let i of e)this.probeBytes-=i.bytes}dropProbes(e){this.removeProbes(e),this.probesDropped+=e.length}handleProbeSendResult(e,t,i){if(t.length===0)return;let r=e.statusCode;if(typeof r=="number"&&r>=200&&r<300){this.removeProbes(t);return}if(!this.isRetryable(r)){this.dropProbes(t);return}let o=Math.max(1,this.config.retry.maxAttempts),s=this.parseRetryAfter(e),a=[];for(let l of t)l.attempts+=1,l.attempts>=o?a.push(l):l.flushAfter=i+this.backoffForAttempt(l.attempts,s);this.dropProbes(a)}sendUnloadProbes(e,t,i,r){let o=this.sessionId,s={sessionId:o,events:[],sdk:this.sdk,probes:[]};this.attachBatchMeta(s,[],t);let a=pe(JSON.stringify(s))+120,l=e>a?this.selectProbes(this.probeQueue,o,Pt,e-a):[];l.length>0&&(s.probes=l.map(d=>d.entry),this.attachBatchMeta(s,l,t),r&&this.config.beaconKeepalive&&this.transport.sendBeacon?this.transport.sendBeacon(s):Promise.resolve(this.transport.send(s)).catch(()=>{}),this.removeProbes(l)),i&&this.dropProbes(this.probeQueue.slice())}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.sendUnloadProbes(ze,e,!0,!1)}catch(i){this.logger.error("Unexpected error in queue flush",i)}}return}this.isFlushing=!0;let t;this.flushingDone=new Promise(i=>{t=i});try{for(this.clearTimer();;){let i=Date.now(),r=this.getDuePending(i),o=this.lowPending.filter(m=>m.flushAfter<=i),s=e==="destroy"?[]:this.dueProbes(i);if(r.length===0&&o.length===0&&this.lowsQueue.length===0&&this.telemetryQueue.length===0&&s.length===0)break;let a=r[0]?.sessionId??o[0]?.sessionId??this.lowsQueue[0]?.sessionId??s[0]?.sessionId??this.sessionId,l=r.filter(m=>m.sessionId===a).slice(0,this.batchSize),d=o.filter(m=>m.sessionId===a).slice(0,100),p=[...d.map(m=>m.event),...this.takeLows(a,100-d.length)];this.prepareEvents(l,e);let u=a===this.sessionId?this.takeTelemetry():[],c=this.selectProbes(s,a,Pt,Ot),f={sessionId:a,events:l.map(m=>m.event),sdk:this.sdk};p.length>0&&(f.lows=p),u.length>0&&(f.telemetry=u),c.length>0&&(f.probes=c.map(m=>m.entry)),this.attachBatchMeta(f,[...l,...d,...c],e),d.length&&(f.deliveryAck=!0);let y=this.shouldRequestConfig()?{[It]:this.config.version||"1"}:void 0,h=await this.transport.send(f,y).catch(m=>(this.logger.error("Unexpected error in queue flush",m),{}));if(f.deliveryAck&&h.statusCode&&h.statusCode>=200&&h.statusCode<300&&!h.deliveryAccepted&&(h={...h,statusCode:503}),this.requestConfig&&this.handleConfigResponse(h),this.handleLowSendResult(h,d,i),this.handleProbeSendResult(h,c,i),!this.handleSendResult(h,l,i))break}e==="destroy"&&this.sendUnloadProbes(ze,e,!0,!1)}catch(i){this.logger.error("Unexpected error in queue flush",i)}finally{this.isFlushing=!1,t(),this.flushingDone=void 0,this.rescheduleIfPending()}}attachBatchMeta(e,t,i){e.meta={...e.meta,flushReason:i};let r=this.readDataPolicy();r!==void 0&&(e.meta={...e.meta,dataPolicy:r}),this.config.version&&(e.meta={...e.meta,configVersion:this.config.version});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(i=>i.event),t)}catch(i){this.logger.error("Failed to prepare events for sending",i)}}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 i=this.lowsQueue.filter(o=>o.sessionId===e).slice(0,t),r=new Set(i);return this.lowsQueue=this.lowsQueue.filter(o=>!r.has(o)),i.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(i=>!t.has(i.id)),this.lowStore?.remove(e)}handleLowSendResult(e,t,i){let r=e.statusCode;if(r!==void 0&&r>=200&&r<300){e.deliveryAccepted?this.removeLowEntries(t.map(o=>o.id)):this.deferLowEntries(t,i);return}if(!this.isRetryable(r)){this.removeLowEntries(t.map(o=>o.id)),this.logger.reportTelemetry?.("error","low events rejected by ingestion");return}this.deferLowEntries(t,i,this.parseRetryAfter(e))}deferLowEntries(e,t,i=null){let r=[];for(let o of e){if(!this.validPendingLow(o)){r.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,i))}this.removeLowEntries(r),this.lowStore?.update(e.filter(o=>!r.includes(o.id)))}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 r=this.lowsQueue;this.lowsQueue=[];for(let{event:o,sessionId:s}of r)this.enqueueLow(o,s)}let i=!1;if(this.config.durableOutbox&&this.storage&&!this.store){this.store=new K(this.storage,this.logger,void 0,void 0,this.outboxLockName);let r=new Set(this.pending.map(s=>s.id)),o=this.store.all().filter(s=>!r.has(s.id));for(let s of this.pending)this.store.add(s);this.pending=[...o,...this.pending],i=o.length>0}i?(this.dirtySinceSyncFlush=!0,this.clearTimer(),this.scheduleFlush(0,"recovery")):t&&(this.clearTimer(),this.rescheduleIfPending())}handleSendResult(e,t,i){let r=e.statusCode,o=typeof r=="number"&&r>=200&&r<300;if(t.length===0)return o;if(o)return this.removeEntries(t.map(p=>p.id)),!0;if(!this.isRetryable(r))return this.removeEntries(t.map(p=>p.id)),!1;let s=Math.max(1,this.config.retry.maxAttempts),a=this.parseRetryAfter(e),l=[],d=[];for(let p of t)p.attempts+=1,p.attempts>=s?l.push(p.id):(p.flushAfter=i+this.backoffForAttempt(p.attempts,a),d.push(p));return this.removeEntries(l),this.store?.update(d),!1}isRetryable(e){return e===void 0||e===408||e===429?!0:e>=500}backoffForAttempt(e,t){let i=this.config.retry,r=i.baseDelayMs*Math.pow(2,Math.max(0,e-1));i.maxDelayMs>0&&(r=Math.min(r,i.maxDelayMs));let o=Math.round(r/2+Math.random()*(r/2));return t!==null&&(o=Math.max(o,t)),o}parseRetryAfter(e){let t=e.headers?.["retry-after"];if(!t)return null;let i=Number(t);if(!Number.isNaN(i))return i*1e3;let r=Date.parse(t);return Number.isNaN(r)?null:Math.max(0,r-Date.now())}removeEntries(e){if(e.length===0)return;let t=new Set(e);this.pending=this.pending.filter(i=>!t.has(i.id)),this.store?.remove(e)}rescheduleIfPending(){try{if(this.destroyed||this.timer||this.pending.length===0&&this.lowPending.length===0&&this.lowsQueue.length===0&&this.probeQueue.length===0)return;let e=Date.now();if(this.getDuePending(e).length>0||this.lowPending.some(i=>i.flushAfter<=e)||this.lowsQueue.length>0||this.probeQueue.some(i=>i.flushAfter<=e)){this.scheduleFlush(this.flushInterval(),"timer");return}let t=Math.min(...[...this.pending,...this.lowPending,...this.probeQueue].map(i=>i.flushAfter));this.scheduleFlush(Math.max(0,t-e),"backoff")}catch(e){this.logger.error("Failed to reschedule queue flush",e)}}setupLifecycleHooks(){typeof window>"u"||(this.onVisibilityChange=()=>{try{this.writeLifecycleDebugOutput("cbo_visibility_change_debug"),document.visibilityState==="hidden"&&this.config.tvc&&this.flushSync("visibility-change")}catch(e){this.logger.error("Unexpected error in queue flushSync",e)}},this.onPageHide=()=>{try{this.writeLifecycleDebugOutput("cbo_pagehide_debug"),this.config.tph&&this.flushSync("pagehide")}catch(e){this.logger.error("Unexpected error in queue flushSync",e)}},window.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("pagehide",this.onPageHide))}writeLifecycleDebugOutput(e){if(!this.debug||!this.storage)return;let t={last_executed:Date.now(),url:window.location.href};this.storage.setItem(e,t)}flushKeepalive(e="manual"){this.flushSync(e)}flushSync(e){let t=this.flushSyncEvents(e);e==="pagehide"&&this.probeQueue.length>0&&this.sendUnloadProbes(Math.min(Lt-t,ze),e,!0,!0)}flushSyncEvents(e){if(!this.dirtySinceSyncFlush)return 0;let t=this.sessionId,i=this.pending.filter(d=>d.sessionId===t),r=i.slice(0,this.batchSize),o=this.lowPending.filter(d=>d.sessionId===t).slice(0,100),s=[...o.map(d=>d.event),...this.takeLows(t,100-o.length)];this.prepareEvents(r,e);let a=this.takeTelemetry();if(r.length===0&&s.length===0&&a.length===0)return this.dirtySinceSyncFlush=!1,0;let l={sessionId:t,events:r.map(d=>d.event),sdk:this.sdk};return s.length>0&&(l.lows=s),a.length>0&&(l.telemetry=a),this.attachBatchMeta(l,[...r,...o],e),o.length&&(l.deliveryAck=!0),this.config.beaconKeepalive&&this.transport.sendBeacon?this.transport.sendBeacon(l)||this.transport.send(l):this.transport.send(l),this.config.durableOutbox||this.removeEntries(r.map(d=>d.id)),this.dirtySinceSyncFlush=!this.config.durableOutbox&&i.length>r.length,this.approximateSize(l)}approximateSize(e){try{return pe(JSON.stringify(e))}catch{return Lt}}destroy(){try{this.destroyed=!0,this.clearTimer(),this.dropProbes(this.probeQueue.slice()),typeof window<"u"&&(this.onVisibilityChange&&window.removeEventListener("visibilitychange",this.onVisibilityChange),this.onPageHide&&window.removeEventListener("pagehide",this.onPageHide))}catch(e){this.logger.error("Failed to destroy queue lifecycle hooks",e)}}};var je={d:(n,e)=>{for(var t in e)je.o(e,t)&&!je.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:e[t]})},o:(n,e)=>Object.prototype.hasOwnProperty.call(n,e)},Ye={};je.d(Ye,{A:()=>Qi,k:()=>Rt});var V=function(n,e,t,i){return new(t||(t=Promise))(function(r,o){function s(d){try{l(i.next(d))}catch(p){o(p)}}function a(d){try{l(i.throw(d))}catch(p){o(p)}}function l(d){var p;d.done?r(d.value):(p=d.value,p instanceof t?p:new t(function(u){u(p)})).then(s,a)}l((i=i.apply(n,e||[])).next())})},$=function(n,e){var t,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[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(l){return function(d){return(function(p){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,p[0]&&(s=0)),s;)try{if(t=1,i&&(r=2&p[0]?i.return:p[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,p[1])).done)return r;switch(i=0,r&&(p=[2&p[0],r.value]),p[0]){case 0:case 1:r=p;break;case 4:return s.label++,{value:p[1],done:!1};case 5:s.label++,i=p[1],p=[0];continue;case 7:p=s.ops.pop(),s.trys.pop();continue;default:if(r=s.trys,!((r=r.length>0&&r[r.length-1])||p[0]!==6&&p[0]!==2)){s=0;continue}if(p[0]===3&&(!r||p[1]>r[0]&&p[1]<r[3])){s.label=p[1];break}if(p[0]===6&&s.label<r[1]){s.label=r[1],r=p;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(p);break}r[2]&&s.ops.pop(),s.trys.pop();continue}p=e.call(n,s)}catch(u){p=[6,u],i=0}finally{t=r=0}if(5&p[0])throw p[1];return{value:p[0]?p[1]:void 0,done:!0}})([l,d])}}};function Rt(){return V(this,void 0,Promise,function(){return $(this,function(n){switch(n.label){case 0:return[4,new Promise(function(e,t){var i="Unknown",r=!1;function o(p){r||(r=!0,e({isPrivate:p,browserName:i}))}function s(){var p=0,u=parseInt("-1");try{u.toFixed(u)}catch(c){p=c.message.length}return p}function a(){return V(this,void 0,void 0,function(){var p,u;return $(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),[4,navigator.storage.getDirectory()];case 1:return c.sent(),o(!1),[3,3];case 2:return p=c.sent(),u=p instanceof Error&&typeof p.message=="string"?p.message:String(p),o(u.includes("unknown transient reason")),[3,3];case 3:return[2]}})})}function l(){var p;return V(this,void 0,Promise,function(){return $(this,function(u){switch(u.label){case 0:return typeof((p=navigator.storage)===null||p===void 0?void 0:p.getDirectory)!="function"?[3,2]:[4,a()];case 1:return u.sent(),[3,3];case 2:navigator.maxTouchPoints!==void 0?(function(){var c=String(Math.random());try{var f=indexedDB.open(c,1);f.onupgradeneeded=function(y){var h=y.target.result,m=function(T){o(T)};try{h.createObjectStore("t",{autoIncrement:!0}).put(new Blob),m(!1)}catch(T){(T instanceof Error&&typeof T.message=="string"?T.message:String(T)).includes("are not yet supported")?m(!0):m(!1)}finally{h.close(),indexedDB.deleteDatabase(c)}},f.onerror=function(){return o(!1)}}catch{o(!1)}})():(function(){var c=window.openDatabase,f=window.localStorage;try{c(null,null,null,null)}catch{return void o(!0)}try{f.setItem("test","1"),f.removeItem("test")}catch{return void o(!0)}o(!1)})(),u.label=3;case 3:return[2]}})})}function d(){var p;return V(this,void 0,Promise,function(){var u,c,f;return $(this,function(y){switch(y.label){case 0:if(typeof((p=navigator.storage)===null||p===void 0?void 0:p.getDirectory)!="function")return[3,5];y.label=1;case 1:return y.trys.push([1,3,,4]),[4,navigator.storage.getDirectory()];case 2:return y.sent(),o(!1),[3,4];case 3:return u=y.sent(),c=u instanceof Error&&typeof u.message=="string"?u.message:String(u),o(c.includes("Security error")),[2];case 4:return[3,6];case 5:(f=indexedDB.open("inPrivate")).onerror=function(h){if(f.error&&f.error.name==="InvalidStateError")return h.preventDefault(),void o(!0);o(!1)},f.onsuccess=function(){indexedDB.deleteDatabase("inPrivate"),o(!1)},y.label=6;case 6:return[2]}})})}(function(){return V(this,void 0,Promise,function(){return $(this,function(p){switch(p.label){case 0:return s()!==44&&s()!==43?[3,2]:(i="Safari",[4,l()]);case 1:return p.sent(),[3,6];case 2:return s()!==51?[3,3]:(u=navigator.userAgent,i=u.match(/Chrome/)?navigator.brave!==void 0?"Brave":u.match(/Edg/)?"Edge":u.match(/OPR/)?"Opera":"Chrome":"Chromium",(function(){var c=this,f="__di_"+Math.random().toString(36).slice(2),y=new Uint8Array(16384),h=indexedDB.open(f,1);h.onupgradeneeded=function(){h.result.createObjectStore("s")},h.onerror=function(){indexedDB.deleteDatabase(f),o(!1)},h.onsuccess=function(){var m=h.result,T=!1;try{var E=m.transaction("s","readwrite",{durability:"strict"});T=E.durability==="strict",E.abort()}catch{}if(!T)return m.close(),indexedDB.deleteDatabase(f),void o(!1);var te=function(z){return new Promise(function(O,j){var Y=performance.now(),_=0,k=function(){if(_!==15){var R=m.transaction("s","readwrite",{durability:z});R.objectStore("s").put(y,_),_++,R.oncomplete=k,R.onerror=R.onabort=function(){return j(R.error)}}else O(performance.now()-Y)};k()})};V(c,void 0,void 0,function(){var z,O,j,Y,_;return $(this,function(k){switch(k.label){case 0:return z=performance.now(),[4,te("relaxed")];case 1:return k.sent(),[4,te("strict")];case 2:k.sent(),O=[],j=0,k.label=3;case 3:return j<15?[4,te("relaxed")]:[3,7];case 4:return Y=k.sent(),[4,te("strict")];case 5:if(_=k.sent(),O.push(Y>0?_/Y:1/0),O.length>=7&&performance.now()-z>=1e3)return[3,7];k.label=6;case 6:return j++,[3,3];case 7:return O.sort(function(R,hi){return R-hi}),m.close(),indexedDB.deleteDatabase(f),o(O[O.length>>1]<1.3),[2]}})}).catch(function(){m.close(),indexedDB.deleteDatabase(f),o(!1)})}})(),[3,6]);case 3:return s()!==25?[3,5]:(i="Firefox",[4,d()]);case 4:return p.sent(),[3,6];case 5:navigator.msSaveBlob!==void 0?(i="Internet Explorer",o(window.indexedDB===void 0)):t(new Error("detectIncognito cannot determine the browser")),p.label=6;case 6:return[2]}var u})})})().catch(t)})];case 1:return[2,n.sent()]}})})}var Qi=Rt,Ft=Ye.A,Mn=Ye.k;var Gi=300,ee=6e3,Dt="cbo_pm",Wi=10080*60*1e3,At="detectincognitojs@1.9.0",Mt={timing:!1},Xe="cbo_tab_id",_t={bluetoothAvailable:"bt",clientCapabilities:"cc",userVerifyingPlatformAuthenticatorAvailable:"uvpaa",conditionalMediationAvailable:"cm",javaScriptHighEntropy:"he",privateMode:"pm",webdriver:"wd",maxTouchPoints:"mtp"};function C(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Ht(n,e,t){return{field:n,source:e,error:{name:"TimeoutError",message:`Device info collection timed out after ${t}ms`}}}async function Je(n,e){let t;try{return await Promise.race([n.then(()=>!0,()=>!0),new Promise(i=>{t=setTimeout(()=>i(!1),Math.max(0,e))})])}finally{t&&clearTimeout(t)}}var ue=class{constructor(e,t,i="localstorage",r,o=()=>Mt,s){this.logger=e;this.storage=t;this.storageSource=i;this.sessionStorage=r;this.settings=o;this.emitTelemetry=s}pagePrivateMode;privateModeDetectionStarted=!1;lastKnown={};async collect(e,t={}){try{let i=this.resolveSettings(),r=C(),o=this.getClientEnvHandle(),s={type:"web",clientEnvHandle:o.value,clientEnvHandleMeta:{timestamp:o.timestamp,source:o.source},tabId:this.getTabId()},a=this.knownPrivateMode(i.timing),l,d=a===void 0&&!this.privateModeDetectionStarted?this.detectPrivateMode(i.timing).then(E=>{l=E}):void 0,p=this.startFastFields();await Je(Promise.all(p.map(E=>E.promise)),Gi);let u=C()-r,c=t.refresh?this.lastKnown:{};i.timing&&this.reportFastTiming(u,p);let f=()=>l?.error?[l.error]:[];this.safePublish(e,this.buildInfo(s,p,l?l.value:a,c,f()),"fast");let y=p.filter(E=>!E.settled),h=d!==void 0&&l===void 0;if(y.length===0&&!h)return;let m=C();await Promise.all([Je(Promise.all(y.map(E=>E.promise)),ee-(m-r)),d]);let T=y.filter(E=>!E.settled).map(E=>Ht(E.field,E.source,ee));T.push(...f()),i.timing&&y.length>0&&this.reportLateTiming(C()-r,y),this.safePublish(e,this.buildInfo(s,p,l?l.value:a,c,T),"update")}catch(i){this.logger.error("Failed to collect device info",i)}}async getInfo(){let e;return await this.collect(t=>{e=t}),e??{}}startFastFields(){return[this.startField("bluetoothAvailable","navigator.bluetooth.getAvailability",()=>this.isBluetoothAvailable()),this.startField("clientCapabilities","PublicKeyCredential.getClientCapabilities",()=>this.getClientCapabilities()),this.startField("userVerifyingPlatformAuthenticatorAvailable","PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable",()=>this.getUserVerifyingPlatformAuthenticatorAvailable()),this.startField("conditionalMediationAvailable","PublicKeyCredential.isConditionalMediationAvailable",()=>this.isConditionalMediationAvailable()),this.startField("javaScriptHighEntropy","navigator.userAgentData.getHighEntropyValues",()=>this.getJavaScriptHighEntropy()),this.startField("webdriver","navigator.webdriver",()=>this.getWebdriver()),this.startField("maxTouchPoints","navigator.maxTouchPoints",()=>this.getMaxTouchPoints())]}startField(e,t,i){let r=C(),o={field:e,source:t};return o.promise=Promise.resolve().then(i).then(s=>({field:e,value:s,durationMs:C()-r}),s=>(this.logger.error(`Failed to collect device info field "${e}"`,s),{field:e,durationMs:C()-r,error:{field:e,source:t,error:H(s)??{message:"Unknown error"}}})).then(s=>(o.settled=s,s)),o}buildInfo(e,t,i,r,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]=r[d.field];s.privateMode=i,a.push(...o);let l={...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&&(l.collectionErrors=a),l}remember(e,t){t!==void 0&&(this.lastKnown[e]=t)}safePublish(e,t,i){try{e(t,i)}catch(r){this.logger.error("Failed to publish device info",r)}}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(Dt);if(!e||typeof e!="object"||typeof e.value!="boolean"||typeof e.ts!="number"||e.dv!==At)return;let t=Date.now()-e.ts;return t<0||t>=Wi?void 0:e}catch(e){this.logger.debug("Failed to read cached privateMode",e);return}}writePrivateModeCache(e){if(this.canCachePrivateMode())try{this.storage.setItem(Dt,{value:e,ts:Date.now(),dv:At})}catch(t){this.logger.error("Failed to cache privateMode",t)}}async detectPrivateMode(e){this.privateModeDetectionStarted=!0;let t="detectIncognito",i=C(),r=this.startField("privateMode",t,()=>this.isPrivateMode());if(!await Je(r.promise,ee)||!r.settled)return e&&this.reportTelemetry(`device info privateMode timed out after ${ee}ms`),{error:Ht("privateMode",t,ee)};if(e&&this.reportTelemetry(`device info privateMode detected in ${Math.round(C()-i)}ms`),r.settled.error)return{error:r.settled.error};let s=r.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),Mt}}reportFastTiming(e,t){let i=t.map(r=>`${_t[r.field]}=${Math.round(r.settled?.durationMs??e)}`).join(",");this.reportTelemetry(`device info collected in ${Math.round(e)}ms (${i})`)}reportLateTiming(e,t){let i=t.map(r=>`${_t[r.field]}=${r.settled?Math.round(r.settled.durationMs):"timeout"}`).join(",");this.reportTelemetry(`device info late fields done in ${Math.round(e)}ms (${i})`)}reportTelemetry(e){if(this.emitTelemetry)try{this.emitTelemetry("info",e)}catch(t){this.logger.error("Failed to report device info timing",t)}}static getOsAndBrowserInfo(){return{osName:this.getOsName(),browserName:this.getBrowserName()}}static getUserAgent(){return typeof navigator>"u"?"":navigator.userAgent??""}static getOsName(){let e=this.getUserAgent();return e.includes("iOS")?"iOS":e.includes("Android")?"Android":e.includes("Windows")?"Windows":e.includes("Macintosh")?"macOS":e.includes("Linux")?"Linux":e.includes("ChromeOS")?"ChromeOS":"other"}static getBrowserName(){let e=this.getUserAgent();return e.includes("Chrome")?"Chrome":e.includes("Firefox")?"Firefox":e.includes("Safari")?"Safari":e.includes("Edge")?"Edge":e.includes("Opera")?"Opera":e.includes("IE")?"IE":"other"}async isBluetoothAvailable(){if(!(typeof navigator>"u"||!navigator.bluetooth))return await navigator.bluetooth.getAvailability()}async getUserVerifyingPlatformAuthenticatorAvailable(){if(!(typeof PublicKeyCredential>"u"||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable))return await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}async isConditionalMediationAvailable(){if(!(typeof PublicKeyCredential>"u"||!PublicKeyCredential.isConditionalMediationAvailable))return await PublicKeyCredential.isConditionalMediationAvailable()}async getClientCapabilities(){if(typeof PublicKeyCredential>"u"||!PublicKeyCredential.getClientCapabilities)return;let e=await PublicKeyCredential.getClientCapabilities();return Object.fromEntries(Object.entries(e).map(([t,i])=>[t,i.toString()]))}getClientEnvHandle(){let e=this.storage.getItem("cbo_client_env_handle");if(e)return e;let t=v(),i={timestamp:Date.now(),source:this.storageSource,value:t};return this.storage.setItem("cbo_client_env_handle",i),i}getTabId(){if(!this.sessionStorage)return;let e=this.sessionStorage.getItem(Xe);if(e)return e;let t=v();if(this.sessionStorage.setItem(Xe,t),this.sessionStorage.getItem(Xe)===t)return t}async getJavaScriptHighEntropy(){if(typeof navigator>"u"||!navigator.userAgentData)return;let e=await navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]),t=e.platform,i=e.mobile,r=e.platformVersion,o=e.model||void 0;if(!(!t||i===void 0||!r))return{platform:t,mobile:i,platformVersion:r,model:o}}async isPrivateMode(){return(await Ft()).isPrivate}getWebdriver(){if(!(typeof navigator>"u"))return navigator.webdriver}getMaxTouchPoints(){if(!(typeof navigator>"u"||typeof navigator.maxTouchPoints!="number"))return navigator.maxTouchPoints}};function zi(){return typeof document<"u"&&document.visibilityState==="hidden"}var ce=class{constructor(e,t,i,r,o){this.logger=e;this.source=t;this.refreshInterval=i;this.attachInterval=r;this.diagnostics=o}snapshot;snapshotPhase;publishedAt=0;version=0;deliveredVersion=0;reportedUndeliveredVersion=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")}reportUndelivered(e){!this.eventsSeen||!this.hasUndelivered()||this.reportedUndeliveredVersion===this.version||(this.reportedUndeliveredVersion=this.version,this.report(`device info ${this.snapshotPhase} snapshot undelivered at ${e}`))}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){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++)}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&&zi())return this.destroyed||this.scheduleRefresh(),Promise.resolve();let e=this.snapshot!==void 0;return this.refreshPromise=Promise.resolve().then(()=>this.source.collect((t,i)=>this.publish(t,i),{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 P(n,e){return`${n}_${e}`}var he=class{constructor(e,t){this.engine=e;this.namespace=t}getItem(e){return this.engine.getItem(P(e,this.namespace))}setItem(e,t){this.engine.setItem(P(e,this.namespace),t)}removeItem(e){this.engine.removeItem(P(e,this.namespace))}},fe=class{constructor(e){this.logger=e}getItem(e){try{if(typeof localStorage>"u")return null;let t=localStorage.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;localStorage.setItem(e,JSON.stringify(t))}catch(i){this.logger.error(`LocalStorage.setItem failed for key "${e}"`,i),this.logger.reportTelemetry?.("error",`localStorage.setItem failed: ${e}`)}}removeItem(e){try{if(typeof localStorage>"u")return;localStorage.removeItem(e)}catch(t){this.logger.error(`LocalStorage.removeItem failed for key "${e}"`,t)}}},ge=class{constructor(e,t){this.logger=e;this.domain=t}getItem(e){try{if(typeof document>"u")return null;let t=e+"=",i=document.cookie.split(";");for(let r=0;r<i.length;r++){let o=i[r].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 i=`${e}=${encodeURIComponent(JSON.stringify(t))}; path=/; SameSite=Lax`;this.domain&&(i+=`; domain=${this.domain}`),document.cookie=i}catch(i){this.logger.error(`CookieStorage.setItem failed for key "${e}"`,i),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}`),document.cookie=t}catch(t){this.logger.error(`CookieStorage.removeItem failed for key "${e}"`,t)}}},me=class{constructor(e){this.logger=e}getItem(e){try{if(typeof sessionStorage>"u")return null;let t=sessionStorage.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;sessionStorage.setItem(e,JSON.stringify(t))}catch(i){this.logger.error(`SessionStorage.setItem failed for key "${e}"`,i),this.logger.reportTelemetry?.("error",`sessionStorage.setItem failed: ${e}`)}}removeItem(e){try{if(typeof sessionStorage>"u")return;sessionStorage.removeItem(e)}catch(t){this.logger.error(`SessionStorage.removeItem failed for key "${e}"`,t)}}};var ye=1,ve="cbo_storage_schema",ji=["cbo_seq","cbo_sdk_config","cbo_experiments","cbo_client_env_handle","cbo_outbox","cbo_visibility_change_debug","cbo_pagehide_debug","cbo_session"],Yi=["cbo_session_id","cbo_tab_id"],Xi=["cbo_client_env_handle"];function be(n,e,t){return n.setItem(e,t),JSON.stringify(n.getItem(e))===JSON.stringify(t)}function Ze(n,e,t){let i=n.getItem(ve);if(i!==null){if(i.version!==ye||i.projectId!==e)return!1;if(i.complete===!0)return!0;if(i.complete!==!1)return!1}else{if(t.some(r=>n.getItem(P(r,e))!==null))return be(n,ve,{version:ye,projectId:e,complete:!0});if(!be(n,ve,{version:ye,projectId:e,complete:!1}))return!1}for(let r of t){let o=P(r,e);if(n.getItem(o)!==null)continue;let s=n.getItem(r);if(s!==null&&!be(n,o,s))return!1}return be(n,ve,{version:ye,projectId:e,complete:!0})}function Bt(n,e,t,i,r){try{if(!Ze(e,n,ji))return;Ze(t,n,Yi),i&&Ze(i,n,Xi)}catch(o){r.error("Failed to migrate legacy Observe storage",o)}}var Ji=10*1e3,Zi=600*1e3,er=[1e3,3e3],Se=class{constructor(e,t,i){this.url=e;this.storage=t;this.logger=i;this.initialConfig=xt(t)??void 0}initialConfig;refreshTimer;requestTimer;retryTimer;controller;fetching=!1;stopped=!1;onConfig;start(e){this.stopped||this.onConfig||(this.onConfig=e,this.fetchConfig())}async fetchConfig(e=0){if(this.stopped||this.fetching)return;e===0&&(clearTimeout(this.refreshTimer),clearTimeout(this.retryTimer),this.refreshTimer=setTimeout(()=>{this.fetchConfig()},Zi)),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 i=!0;try{let r=await fetch(this.url,{method:"GET",cache:"no-store",...t?{signal:t.signal}:{}});if(!r.ok)throw i=(r.status===408||r.status===429||r.status>=500)&&!r.headers.has("Retry-After"),new Error(`SDK config request failed (${r.status})`);let o=await r.json();i=!1;let s=Z(o);if(!s)throw new Error("Invalid SDK config response");if(this.stopped||t?.signal.aborted)return;Ct(this.storage,s),this.onConfig?.(s)}catch(r){if(!this.stopped){this.logger.error("Failed to fetch SDK config",r);let o=er[e];(i&&!(r 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,clearTimeout(this.refreshTimer),clearTimeout(this.requestTimer),clearTimeout(this.retryTimer),this.controller?.abort(),this.onConfig=void 0}};var Q=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(i){this.logger.error("Failed to register ceremony low-event context",i)}}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 we=class extends g{getOptions;ceremony;postResponse;lowEventTracker;constructor(e,t){super(e,"passkey-login"),this.lowEventTracker=new Q(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 G=class{constructor(e,t,i,r){this.previousLength=e;this.pushLow=t;this.logger=i;this.reserveCaptureSeq=r}prefillSettled=!1;inputBatch=null;currentEffect="modify";ringEffect="modify";autofillTimestamps=[];autofillStreak=null;idleTimer=null;markInputObserved(){this.prefillSettled=!0}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,i){let r=this.inputBatch;if(!r){this.inputBatch={firstTimestamp:e,lastTimestamp:e,effect:t,captureSeq:i};return}r.lastTimestamp=e}drainAutofillRingToBatch(){for(let e of this.autofillTimestamps)this.extendInputBatch(e.ts,this.ringEffect,e.captureSeq);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,i=-1/0;for(let r=1;r<e.length;r++){let o=e[r].ts-e[r-1].ts;if(o>80)return!1;o<t&&(t=o),o>i&&(i=o)}return i-t<=25}record(e,t=Date.now(),i=!1,r=this.reserveCaptureSeq?.()){this.markInputObserved(),this.scheduleIdle();let o=this.previousLength;this.currentEffect=e===0?"clear":o===0?"fill":"modify";let s=e-o;if(this.previousLength=e,e===0&&o>0){this.flush(),this.pushLow({...r===void 0?{}:{captureSeq:r},lowType:"input-clear",ts:t,inputEffect:"clear"});return}if(i){this.flushAutofillStreak(),this.drainAutofillRingToBatch(),this.extendInputBatch(t,this.currentEffect,r);return}if(s>=3){this.flushInputBatch(),this.flushAutofillStreak(),this.pushLow({...r===void 0?{}:{captureSeq:r},lowType:"big-input-add",ts:t,inputEffect:this.currentEffect});return}if(s<=-3){this.flushInputBatch(),this.flushAutofillStreak(),this.pushLow({...r===void 0?{}:{captureSeq:r},lowType:"big-input-rem",ts:t,inputEffect:this.currentEffect});return}let a=this.autofillStreak;if(a){if(s===1&&t-a.lastTimestamp<=80){a.lastTimestamp=t;return}this.flushAutofillStreak()}if(s!==1){this.drainAutofillRingToBatch(),this.extendInputBatch(t,this.currentEffect,r);return}let l=this.autofillTimestamps;if(l.length===0&&(this.ringEffect=this.currentEffect),l.push({ts:t,captureSeq:r}),l.length>5){let u=l.shift();this.extendInputBatch(u.ts,this.ringEffect,u.captureSeq),this.ringEffect="modify"}if(!this.detectAutofillStreak())return;let d=l[0],p=l[l.length-1];l.length=0,this.flushInputBatch(),this.autofillStreak={firstTimestamp:d.ts,captureSeq:d.captureSeq,lastTimestamp:p.ts,effect:this.ringEffect}}};var W=class{constructor(e,t,i,r){this.inputs=e;this.logger=t;this.changed=i;this.reserveCaptureSeq=r;for(let o of e)o.addEventListener("paste",this.onPaste,!0),o.addEventListener("beforeinput",this.onBeforeInput,!0)}before=null;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.before)return!1;let t=this.pasteEvent?.type==="paste"&&(this.pasteEvent.eventPhase??0)>0;return e.inputType==="insertFromPaste"||t?!0:(this.clear(),!1)}get pending(){return this.before!==null}begin(e){if(!(!e.isTrusted||this.before))try{this.before=this.inputs.map(t=>t.value),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.before;if(!e)return;let t=this.timestamp,i=this.captureSeq;this.clear();try{let r=0,o=!1;this.inputs.forEach((s,a)=>{let l=e[a],d=s.value;if(l===d)return;o=!0;let p=0;for(;p<l.length&&p<d.length&&l[p]===d[p];)p++;let u=0;for(;u<l.length-p&&u<d.length-p&&l[l.length-u-1]===d[d.length-u-1];)u++;r+=d.length-p-u}),o&&this.changed(t,r,i)}catch(r){this.logger.error("Failed to finish paste observation",r)}}clear(){this.timer!==null&&clearTimeout(this.timer),this.timer=null,this.before=null,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 tr=[{query:"com-1password-button",eventType:"pa-1"},{query:"com-1password-menu",eventType:"pa-2"},{query:"com-1password-notification",eventType:"pa-3"}],ir="[data-lastpass-root], [data-lp], [data-lpignore], [data-lpfieldtype]",Nt="pa-4",rr='[popover="manual"]',nr=400,or=20,et="pa-5",tt="pa-6",it=(n,e)=>{try{return Array.from(n.querySelectorAll(e))}catch{return[]}},Ut=n=>{if(n.getAttribute("popover")!=="manual")return!1;let e=n.getAttribute("style")??"";return!(e.length<nr||!/z-index:\s*2147483647\b/i.test(e)||!/position:\s*fixed\b/i.test(e)||!/display:\s*block\b/i.test(e)||(e.match(/initial\s*!important/gi)?.length??0)<or)},sr=n=>{if(Ut(n)||n.getAttribute("popover")!=="manual")return!1;let e=n.getAttribute("style")??"";return!(!/z-index:\s*2147483647\b/i.test(e)||!/position:\s*fixed\b/i.test(e)||!/backdrop-filter:\s*[^;]*blur\(\s*20px\s*\)/i.test(e)||!/background-color:\s*rgba\(\s*35\s*,\s*35\s*,\s*35\s*,/i.test(e))},ar=n=>{n(document);for(let e of Array.from(document.querySelectorAll("*"))){let t=e.shadowRoot;t&&n(t)}},qt=()=>{let n=new Set;return typeof document>"u"||ar(e=>{for(let t of tr)n.has(t.eventType)||it(e,t.query).length>0&&n.add(t.eventType);if(!n.has(Nt)&&it(e,ir).length>0&&n.add(Nt),!n.has(et)||!n.has(tt))for(let t of it(e,rr)){if(!n.has(et)&&Ut(t)){n.add(et);continue}!n.has(tt)&&sr(t)&&n.add(tt)}}),n};var lr=500,pr=250,I=class{constructor(e,t,i){this.logger=e;this.inputField=t;this.sink=i;this.changes=new G(t.value.length,this.pushLow,e,i.reserveCaptureSeq),this.pasteObserver=new W([t],e,(r,o,s)=>{this.changes.flush(),this.changes.markInputObserved();let a=this.changes.previousLength;this.changes.previousLength=t.value.length,this.pushLow({...s===void 0?{}:{captureSeq:s},lowType:"input-paste",ts:r,inputEffect:t.value.length===0?"clear":a===0?"fill":"modify"})},i.reserveCaptureSeq),this.boundHandlers={focus:this.wrapHandler("focus",()=>this.handleFocus()),blur:this.wrapHandler("blur",()=>this.handleBlur()),pointerdown:this.wrapHandler("pointerdown",()=>this.enqueueNonInputEvent("pointerdown")),pointerup:this.wrapHandler("pointerup",()=>this.enqueueNonInputEvent("pointerup")),click:this.wrapHandler("click",()=>this.enqueueNonInputEvent("click")),input:r=>{try{this.handleInput(r)}catch(o){this.logger.error("Failed to observe input",o)}},keyup:this.wrapKeyboardHandler("keyup",r=>this.handleKeyUp(r)),pageHide:this.wrapHandler("pagehide",()=>this.flushForTeardown())},this.unregisterInputs=i.registerInputs?.([t],()=>this.flushPending()),this.capturePrefill(),this.attach()}unregisterInputs;changes;pasteObserver;emittedSignals=new Set;firstFocusHandled=!1;mountProbeTimer=null;focusProbeTimer=null;destroyed=!1;boundHandlers;destroy(){if(!this.destroyed){this.destroyed=!0;try{this.mountProbeTimer!==null&&(clearTimeout(this.mountProbeTimer),this.mountProbeTimer=null),this.focusProbeTimer!==null&&(clearTimeout(this.focusProbeTimer),this.focusProbeTimer=null),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;e.addEventListener("focus",this.boundHandlers.focus),e.addEventListener("blur",this.boundHandlers.blur),e.addEventListener("pointerdown",this.boundHandlers.pointerdown),e.addEventListener("pointerup",this.boundHandlers.pointerup),e.addEventListener("click",this.boundHandlers.click),e.addEventListener("input",this.boundHandlers.input),e.addEventListener("keyup",this.boundHandlers.keyup),typeof window<"u"&&window.addEventListener("pagehide",this.boundHandlers.pageHide),typeof document<"u"&&document.activeElement===e&&this.handleFocus(),typeof window<"u"&&(this.mountProbeTimer=setTimeout(()=>this.runEnvProbe(),lr))}detach(){let e=this.inputField;e.removeEventListener("focus",this.boundHandlers.focus),e.removeEventListener("blur",this.boundHandlers.blur),e.removeEventListener("pointerdown",this.boundHandlers.pointerdown),e.removeEventListener("pointerup",this.boundHandlers.pointerup),e.removeEventListener("click",this.boundHandlers.click),e.removeEventListener("input",this.boundHandlers.input),e.removeEventListener("keyup",this.boundHandlers.keyup),typeof window<"u"&&window.removeEventListener("pagehide",this.boundHandlers.pageHide)}pushLow=e=>{this.sink.enqueueLowEvent(e)};runEnvProbe(){try{let e=qt(),t=Date.now();for(let i of e)this.emittedSignals.has(i)||(this.emittedSignals.add(i),this.pushLow({lowType:i,ts:t}))}catch(e){this.logger.error("Failed to run input env probe",e)}}scheduleFocusProbe(){this.firstFocusHandled||(this.firstFocusHandled=!0,this.focusProbeTimer=setTimeout(()=>this.runEnvProbe(),pr))}capturePrefill(e=!1){this.destroyed||(this.flushPending(),this.changes.capturePrefill(this.inputField.value.length,e))}flushPending(){this.pasteObserver.flush(),this.changes.flush()}enqueueNonInputEvent(e){this.changes.flush(),this.pushLow({lowType:e,ts:Date.now()})}handleFocus(){this.scheduleFocusProbe(),this.enqueueNonInputEvent("focus")}handleBlur(){this.pasteObserver.flush(),this.enqueueNonInputEvent("blur")}handleInput(e){this.pasteObserver.handlesInput(e)||this.changes.record(this.inputField.value.length,Date.now(),e.isComposing||e.inputType==="insertCompositionText")}handleKeyUp(e){e.key==="Escape"&&this.enqueueNonInputEvent("keyup-escape")}flushForTeardown(){this.pasteObserver.flush(),this.changes.flush(),this.sink.flushKeepalive()}wrapHandler(e,t){return()=>{try{t()}catch(i){this.logger.error(`Failed to handle low event "${e}"`,i)}}}wrapKeyboardHandler(e,t){return i=>{try{t(i)}catch(r){this.logger.error(`Failed to handle low event "${e}"`,r)}}}};var Te=class{constructor(e,t,i){this.logger=e;this.sink=i;this.inputs=[...new Set(t)],this.changes=new G(this.length(),r=>i.enqueueLowEvent(r),e,i.reserveCaptureSeq),this.paste=new W(this.inputs,e,(r,o,s)=>{this.cancelChange(),this.changes.flush(),this.changes.markInputObserved();let a=this.changes.previousLength;this.changes.previousLength=this.length(),i.enqueueLowEvent({...s===void 0?{}:{captureSeq:s},lowType:"input-paste",ts:r,inputEffect:this.length()===0?"clear":a===0?"fill":"modify"})},i.reserveCaptureSeq),this.unregisterInputs=i.registerInputs?.(this.inputs,()=>this.flushPending()),this.capturePrefill();for(let r of this.inputs){this.listen(r,"input",o=>{this.paste.handlesInput(o)||(this.composing||=o.isComposing||o.inputType==="insertCompositionText",this.changeTimer===null&&(this.changeTime=Date.now(),this.changeSeq=i.reserveCaptureSeq?.(),this.changeTimer=setTimeout(()=>this.safe(()=>this.flushChanges()),0)))}),this.listen(r,"focus",o=>{this.contains(o.relatedTarget)||this.emit("focus")}),this.listen(r,"blur",o=>{this.contains(o.relatedTarget)||(this.flushPending(),this.emit("blur"))});for(let o of["click","pointerdown","pointerup"])this.listen(r,o,()=>this.emit(o));this.listen(r,"keyup",o=>{o.key==="Escape"&&this.emit("keyup-escape")})}typeof window<"u"&&this.listen(window,"pagehide",()=>{this.flushPending(),i.flushKeepalive()}),typeof document<"u"&&this.contains(document.activeElement)&&this.emit("focus")}inputs;changes;paste;unregisterInputs;listeners=[];changeTimer=null;changeTime=0;changeSeq;composing=!1;destroyed=!1;contains(e){return this.inputs.some(t=>t===e)}length(){return this.inputs.reduce((e,t)=>e+t.value.length,0)}safe(e){try{e()}catch(t){this.logger.error("Failed to observe grouped input",t)}}listen(e,t,i){let r=o=>this.safe(()=>i(o));e.addEventListener(t,r),this.listeners.push(()=>e.removeEventListener(t,r))}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.changeSeq),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 L=class{constructor(e,t,i){this.logger=e;this.inputSink=t;this.groupSink=i}collector;fields=[];grouped=!1;destroyed=!1;prefillClaimed=!1;setFields(e,t=!0){try{if(this.destroyed)return;let i=[...new Set(e)];if(t===this.grouped&&i.length===this.fields.length&&i.every((s,a)=>s===this.fields[a])||(this.collector?.destroy(),this.collector=void 0,this.fields=[],this.grouped=t,i.length===0))return;let r=t?this.groupSink:this.inputSink,o={...r,enqueueLowEvent:s=>this.enqueue(r,s)};this.collector=t?new Te(this.logger,i,o):new I(this.logger,i[0],o),this.fields=i}catch(i){this.logger.error("Failed to bind OTP inputs",i)}}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 Ee=class extends g{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 L(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 Ie=class extends g{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 L(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 dr=["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 Kt(n){if(!n)return!1;let e=n.toLowerCase();return dr.some(t=>e.includes(t))}var Vt="@corbado/observe",$t="1.5.1";var rt="cbo_email_link_starts";function nt(n,e){let t=n.getItem(rt);return Array.isArray(t)?t.filter(i=>!!i&&typeof i=="object"&&typeof i.transactionId=="string"&&typeof i.anchor=="string"&&typeof i.sessionId=="string"&&typeof i.startedAt=="number"&&e-i.startedAt<864e5):[]}function Qt(n,e){if(n)try{let t=nt(n,e.startedAt).filter(i=>i.transactionId!==e.transactionId);t.push(e),n.setItem(rt,t.slice(-10))}catch{}}function Gt(n,e,t=Date.now()){if(n)try{let i=nt(n,t);if(e.transactionId)return i.find(o=>o.transactionId===e.transactionId);let r=i.filter(o=>!o.continued&&(!e.specType||!o.specType||o.specType===e.specType));return r[r.length-1]}catch{return}}function Wt(n,e){if(n)try{let t=nt(n,Date.now()).map(i=>i.transactionId===e?{...i,continued:!0}:i);n.setItem(rt,t)}catch{}}var ke=class extends g{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||v(),this.subflowStart({explicitSpecType:t.explicitSpecType},{userReference:{crossEnvironmentTransactionIDStart:this.transactionId}});let i=this.captureReference,r=this.captureSession;i&&r&&Qt(e.getPersistentStorage(),{transactionId:this.transactionId,anchor:i,sessionId:r,specType:t.explicitSpecType,startedAt:Date.now()})}},xe=class extends g{postResponse;resend;mode;continuationTracker;specType;createdAt=Date.now();transaction;started=!1;deferred=[];onPageHide=()=>this.flush();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 i=e.getPersistentStorage(),r=Gt(i,{transactionId:t.transactionId,specType:t.explicitSpecType});if(r&&r.sessionId===e.getSessionId()){this.mode="attached",this.transaction=t.transactionId??r.transactionId,this.adoptCapture(r.anchor,r.sessionId,r.specType??t.explicitSpecType),this.started=!0;return}this.mode="detached",this.transaction?this.startDetached(this.createdAt):typeof window<"u"&&window.addEventListener("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 i of t)i.run(i.at);try{this.continuationTracker.flushKeepalive()}catch{}}removePageHideListener(){typeof window<"u"&&window.removeEventListener("pagehide",this.onPageHide)}deferrable(e,t=!1){let i=(r,o)=>{if(this.started){r(o?.explicitTimestamp??Date.now());return}this.deferred.push({at:o?.explicitTimestamp??Date.now(),run:r})};return{start:(r,o)=>i(s=>e.start(r,{...o,explicitTimestamp:s}),o),finished:(r,o)=>{i(s=>e.finished(r,{...o,explicitTimestamp:s}),o),t&&this.transaction&&Wt(this.continuationTracker.getPersistentStorage(),this.transaction)},error:(r,o)=>i(s=>e.error(r,{...o,explicitTimestamp:s}),o)}}};var Ce=class extends g{getOptions;ceremony;postResponse;lowEventTracker;constructor(e,t){super(e,"passkey-enrollment"),this.lowEventTracker=new Q(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()}};function zt(n){let e=n.debug,t,i=(r,o)=>`[Corbado Observe SDK ${r}] ${o}`;return{reportTelemetry(r,o){if(t)try{t(r,o)}catch{}},setTelemetrySink(r){t=r},debug(r,...o){e&&console.log(i("DEBUG",r),...o)},info(r,...o){e&&console.log(i("INFO",r),...o)},warn(r,...o){e&&console.warn(i("WARN",r),...o)},error(r,...o){e&&console.error(i("ERROR",r),...o)},critical(r,...o){console.error(i("CRITICAL",r),...o)}}}var Pe=class extends g{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 I(e.getLogger(),t.identifierInputHtmlField,this.lowEventSink("input","identifier"))),this.registerLowFlusher(()=>this.identifierLowEventTracker?.flushPending())),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new I(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 Oe=class extends g{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 I(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","password"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var Le=class extends g{lowEventTracker;cui;provideIdentifier;constructor(e,t){super(e,"provide-identifier"),this.cui={trigger:(i,r)=>{this.trigger(i,r)},getOptions:this.defineStep("cui-get-options",!0),ceremony:this.defineStep("cui-ceremony"),postResponse:this.defineStep("cui-post-response")},this.provideIdentifier={trigger:(i,r)=>{this.trigger(i,r)},clientValidation:this.defineStep("pi-client-validation"),postResponse:this.defineStep("pi-post-response")},this.subflowStart({explicitSpecType:t?.explicitSpecType}),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new I(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","identifier"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var Re=class extends g{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})}};var Fe=class extends g{getRedirectUrl;exchangeCode;constructor(e,t={}){super(e,"sso-login"),this.getRedirectUrl=this.defineStep("get-redirect-url"),this.exchangeCode=this.defineStep("exchange-code");let{explicitSpecType:i,organizationDomain:r,actor:o}=ur(t??{},e);this.subflowStart({explicitSpecType:i,organizationDomain:r,actor:o})}};function ur(n,e){let t={...n},i=o=>{try{e.getLogger().warn(`SSO login: unsupported ${o}; omitted from telemetry`)}catch{}},r=t.organizationDomain;return r!==void 0&&(typeof r!="string"||r.includes("@")||r.length>253)&&(delete t.organizationDomain,i("organizationDomain")),t.actor!==void 0&&t.actor!=="user"&&t.actor!=="system"&&(delete t.actor,i("actor")),t}var De=class extends g{lowEventTracker;postResponse;constructor(e,t={}){super(e,"totp"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType}),this.lowEventTracker=this.createLowCollector(()=>new L(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 Ae=class extends g{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 Me=class extends g{ceremony;postResponse;constructor(e,t={}){super(e,"captcha"),this.ceremony=this.defineStep("ceremony"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType})}};function ot(n,e,t){if(n===null||typeof n!="object")return n;try{let i={...n};i.purpose===void 0&&e.purpose!==void 0&&(i.purpose=e.purpose),i.storage===void 0&&e.storage!==void 0&&(i.storage=e.storage),i.trustName===void 0&&e.trustName!==void 0&&(i.trustName=e.trustName);for(let[r,o]of[["bindingReference",255],["trustName",128]])if(typeof i[r]=="string"&&[...i[r]].length>o){delete i[r];try{t.getLogger().debug(`Trusted device: omitted ${r} exceeding ${o} characters`)}catch{}}return i}catch{return n}}function _e(n,e,t){return{...n,start:(i,r)=>n.start(ot(i,e,t),r),finished:(i,r)=>n.finished(ot(i,e,t),r)}}var He=class extends g{getOptions;ceremony;postResponse;constructor(e,t){super(e,"trusted-device-check"),t=jt(t,e);let i={purpose:t.purpose,storage:t.storage,trustName:t.trustName};this.getOptions=this.checkStep("get-options",i,e),this.ceremony=this.checkStep("ceremony",i,e),this.postResponse=this.checkStep("post-response",i,e),this.subflowStart({explicitSpecType:t.explicitSpecType,actor:"system",ignoreAsInteraction:!0})}checkStep(e,t,i){let r=this.defineStep(e,!0);return{..._e(r,t,i),errorTyped:(o,s)=>{r.errorTyped(ot({code:o?.code,error:H(o?.error)},t,i),s)}}}},Be=class extends g{getOptions;ceremony;postResponse;constructor(e,t){super(e,"trusted-device-enrollment"),t=jt(t,e);let i={purpose:t.purpose,storage:t.storage,trustName:t.trustName};this.getOptions=_e(this.defineStep("get-options"),i,e),this.ceremony=_e(this.defineStep("ceremony"),i,e),this.postResponse=_e(this.defineStep("post-response"),i,e),this.subflowStart({explicitSpecType:t.explicitSpecType})}};function jt(n,e){let t={...n},i=r=>{try{e.getLogger().warn(`Trusted device: missing or unsupported ${r}; omitted from telemetry`)}catch{}};return t.purpose!=="additional-verification"&&t.purpose!=="mfa-exemption"&&(delete t.purpose,i("purpose")),["cookie","indexeddb","localstore","sessionstore"].includes(t.storage)||(delete t.storage,i("storage")),t}var Ne=class extends g{clientValidation;postResponse;lowEventTracker;constructor(e,t={}){super(e,"provide-data"),this.clientValidation=this.defineStep("client-validation"),this.postResponse=this.defineStep("post-response");let{inputHtmlField:i,...r}=t;this.subflowStart(r),i&&(this.lowEventTracker=this.createLowCollector(()=>new I(e.getLogger(),i,this.lowEventSink("input","data"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var Ue=String.raw`-extension://[^/]+`,cr="/inline/injected/webauthn-listeners.js",Yt=/\/dashlane-(?:shadow-dom|top-layer)-page-script\.js/,hr=new RegExp(`${Ue}/content-scripts/passkey_proxy/index\\.js$`),fr=new RegExp(`${Ue}/content_scripts/shadow-dom/shadowAttachNotifier\\.js:`),Xt=new RegExp(`${Ue}/js/nordpass-script\\.js:`),gr=new RegExp(`${Ue}/js/passkeys\\.js:`),mr=/["'`](?:keeper:shadow-root-attached|webauthn-(?:get|create)-request)["'`]/,yr=/Intercept cancelled for `(?:get|create)`|["'`](?:conditionalMediationAvailable|verifyingPlatformAuthenticatorAvailable)["'`]/,st=()=>Object.keys(window._sentryDebugIds??{}),at=n=>{try{n()}catch(e){return String(e?.stack??"")}return""},Jt=()=>at(()=>Element.prototype.attachShadow.call(null,{mode:"open"})),vr=()=>{let n=Object.getOwnPropertyDescriptor(navigator.credentials??{},"get");if(!n?.get||!n.set||n.configurable)return!1;let e=()=>{},t=n.get.call({_get:e});return t===e||typeof t=="function"&&t===n.get.call({})&&!Function.prototype.toString.call(t).includes("[native code]")},lt=(...n)=>{let e=navigator.credentials;return e?n.map(t=>Object.getOwnPropertyDescriptor(e,t)?.value):[]},br=()=>[navigator.credentials?.get,...lt("get","_get")].some(n=>typeof n=="function"&&n.name==="getWebAuthnCredential"),Sr=()=>{let n=document.documentElement,e=document.adoptedStyleSheets;if(!n||typeof n.getAnimations!="function"||typeof e?.push!="function"||n.getAnimations().length>0)return!1;let t=new CSSStyleSheet;t.replaceSync(":where(:root){animation:bitwardenfill 1s 1000s paused}"),e.push(t);try{let i=n.getAnimations().filter(r=>r.animationName==="bitwardenfill");return i.forEach(r=>r.cancel()),i.length>0}finally{let i=e.indexOf(t);i>=0&&e.splice(i,1)}},wr,Tr=()=>wr??=Sr(),Er=()=>{let n=typeof PublicKeyCredential>"u"?void 0:PublicKeyCredential;if(typeof n!="function"||!Object.prototype.hasOwnProperty.call(n,Symbol.hasInstance))return!1;let e=n[Symbol.hasInstance]({});return e instanceof Promise?(e.catch(()=>{}),!0):!1},Ir=()=>{let n={get nodeType(){throw new Error("probe")}};return at(()=>MutationObserver.prototype.observe.call(null,n))},kr=()=>{let n=new Error("probe"),e=[],t={get nodeType(){return e.push("nodeType"),1},get ownerDocument(){throw e.push("ownerDocument"),n}};try{MutationObserver.prototype.observe.call(null,t)}catch(i){return i===n&&e.join()==="nodeType,ownerDocument"}return!1},xr=()=>[Element.prototype.attachShadow,navigator.credentials?.get,navigator.credentials?.create,...lt("get","_get","create")].some(e=>typeof e=="function"&&mr.test(Function.prototype.toString.call(e))),Cr=()=>{let n=document;for(;n;){if(n.querySelector("[data-lastpass-icon-root], [data-lastpass-root]"))return!0;n=n.activeElement?.shadowRoot}return!1},Pr=()=>{let n=typeof PublicKeyCredential>"u"?void 0:PublicKeyCredential;return[navigator.credentials?.get,...lt("get","_get"),n?.isConditionalMediationAvailable,n?._isConditionalMediationAvailable,n?.isUserVerifyingPlatformAuthenticatorAvailable,n?._isUserVerifyingPlatformAuthenticatorAvailable].some(t=>typeof t=="function"&&yr.test(Function.prototype.toString.call(t)))},Or=[{name:"1password",signal:"in-field button",signedIn:!0,test:()=>document.querySelector("com-1password-button")!==null},{name:"1password",signal:"credentials.get accessor",test:vr},{name:"1password",signal:"Sentry debug id",test:()=>st().some(n=>n.includes(cr))},{name:"bitwarden",signal:"passkey override",signedIn:!0,test:br},{name:"bitwarden",signal:"autofill keyframes",test:Tr},{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:Er},{name:"dashlane",signal:"page script stack",test:()=>Yt.test(Jt())||typeof HTMLDialogElement<"u"&&Yt.test(at(()=>HTMLDialogElement.prototype.showModal.call(null)))},{name:"kaspersky",signal:"passkey proxy flag",test:()=>window.wasKPMKeyPassProxyInited===!0},{name:"kaspersky",signal:"injected script tag",test:()=>hr.test(document.querySelector('script[src*="/content-scripts/passkey_proxy/"]')?.src??"")},{name:"keeper",signal:"attachShadow stack",test:()=>fr.test(Jt())},{name:"keeper",signal:"override source",test:xr},{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:Cr},{name:"nordpass",signal:"observer proxy stack",test:()=>Xt.test(Ir())},{name:"nordpass",signal:"observer read order",test:kr},{name:"nordpass",signal:"passkeys Sentry debug id",test:()=>st().some(n=>gr.test(n))},{name:"nordpass",signal:"Sentry debug id",test:()=>st().some(n=>Xt.test(n))},{name:"protonpass",signal:"WebAuthn override source",test:Pr},{name:"protonpass",signal:"field icon",test:()=>document.querySelector("[data-protonpass-role]")!==null}];function Lr(){return typeof window>"u"||typeof document>"u"?[]:Or.map(({name:n,signal:e,signedIn:t,test:i})=>{try{return{name:n,signal:e,signedIn:t,matched:i()}}catch(r){return{name:n,signal:e,signedIn:t,matched:!1,error:r}}})}function Zt(){let n=new Map;for(let{name:e,signedIn:t,matched:i}of Lr()){if(!i)continue;let r=n.get(e)??{name:e};t&&(r.signedIn=!0),n.set(e,r)}return[...n.values()]}var ei=3e3,Rr=500,Fr=6,Dr=1e3,qe=class{constructor(e,t,i){this.logger=e;this.isEnabled=t;if(typeof window>"u"||typeof document>"u")return;if(this.sample(),document.readyState==="complete")this.sampleAfter(ei);else{let o=()=>{this.sampleWhenIdle(),this.sampleAfter(ei)};window.addEventListener("load",o,{once:!0}),this.removers.push(()=>window.removeEventListener("load",o))}let r=i.onInputFocus(o=>{!this.isEnabled()||this.sampledFields.has(o)||(this.sampledFields.add(o),++this.focusSamples>=Fr&&r(),this.sampleAfter(Rr))});this.removers.push(r)}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:Dr});this.idleCallbacks.add(e)}sample(){if(!(this.destroyed||!this.isEnabled()))try{for(let e of Zt()){let t=this.detected.get(e.name);(!t||e.signedIn&&!t.signedIn)&&this.detected.set(e.name,e)}}catch(e){this.logger.error("Failed to detect password manager extensions",e)}}};var pt={name:Vt,version:$t},Ar=/^[0-9A-Za-z.+_-]{1,32}$/;function Mr(n,e){return n===void 0?pt:typeof n=="string"&&Ar.test(n)?{...pt,integrationVersion:n}:(e.debug("Ignoring invalid integrationVersion (expected <= 32 chars of [0-9A-Za-z.+_-])"),pt)}var ti="cbo_session_id",dt="cbo_session",M="cbo_seq",ii="cbo_experiments",ri="cbo_data_policy",_r=255,Hr=/^[A-Za-z0-9_-]+$/,Br=128,Nr=256,ni=1e3,Ur=/^[a-z][a-z0-9_-]{0,31}$/,oi=/^[A-Za-z0-9_-]{1,16}$/,qr=64,Kr=32,Vr=50,$r="cbo_seq",si=1e3,ai=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Ke=class n{constructor(e){this.options=e;this.options.debug=e.debug??!1,this.logger=e.logger??zt({debug:this.options.debug});let t=new fe(this.logger),i=new me(this.logger),r=e.storage==="cookie",o=r?new ge(this.logger,e.cookieDomain):void 0;Bt(e.projectId,t,i,o,this.logger);let s=e.projectId,a=h=>new he(h,s);this.seqLockName=P($r,s),this.sessionStorage=a(i),this.persistentStorage=a(t),this.storage=a(o??t),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]}};let l=Object.keys(b).every(h=>this.configOverrides[h]!==void 0)&&Object.keys(b.retry).every(h=>this.configOverrides.retry?.[h]!==void 0);l||(this.configManager=new Se(e.apiBaseUrl+(e.apiConfigPath??"/v1/observe/config")+"/"+e.projectId,this.persistentStorage,this.logger));let d=this.configManager?.initialConfig;this.config=Ge(d,this.configOverrides),!l&&!d&&e.flushInterval!=null&&this.configOverrides.flushIntervalMs===void 0&&(this.config={...this.config,flushIntervalMs:e.flushInterval}),!l&&!d&&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 p=e.apiBaseUrl+(e.apiEventPath??"/v1/observe/events")+"/"+e.projectId;this.logger.debug(`Using API endpoint: ${p}`);let u=new ae({logger:this.logger,url:p});this.sessionId=this.resolveSessionId(),this.queue=new de(this.logger,u,this.sessionId,Mr(this.options.integrationVersion,this.logger),{debug:this.options.debug,config:this.config,requestConfig:!1,outboxLockName:P(We,s),getDataPolicy:()=>this.dataPolicy,beforeEventBatchSend:(h,m)=>this.attachUndeliveredDeviceInfo(h,m)},this.persistentStorage),this.telemetryReady=!0,this.logger.setTelemetrySink?.((h,m)=>this.reportTelemetry(h,m));try{this.getWindowObserver()}catch(h){this.logger.error("Failed to attach page low-event observer",h)}try{this.passwordManagerSampler=this.isTrackingBlocked()?void 0:new qe(this.logger,()=>this.config.pmd,this.getWindowObserver())}catch(h){this.logger.error("Failed to start password manager detection",h)}let c=this.pendingSelfTelemetry;this.pendingSelfTelemetry=[];for(let h of c)this.telemetry(h.level,h.message);let f=new ue(this.logger,this.storage,r?"cookie":"localstorage",this.sessionStorage,()=>({timing:this.config.deviceInfoTiming}),(h,m)=>this.telemetry(h,m));this.deviceCollector=f;let y=e.deviceInfoDebounceTime??3e4;this.deviceInfoManager=new ce(this.logger,f,Math.max(1,y),y,{timing:()=>this.config.deviceInfoTiming,emit:(h,m)=>this.telemetry(h,m)}),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(h=>this.handleConfig(h))}logger;queue;sessionId;storage;sessionStorage;persistentStorage;seqLockName;config;configManager;configOverrides;deviceInfoManager;deviceCollector;eventTabId;seq=0;lastActivityWriteAt=0;experiments={};dataPolicy;telemetryReporting=!1;telemetryReady=!1;reportedTelemetryKeys=new Set;pendingSelfTelemetry=[];probePageId;probeSeqs=new Map;windowObserver;passwordManagerSampler;getWindowObserver(){return this.windowObserver??=new se(this.logger,(e,t)=>this.enqueueLowEvent(e,t),()=>this.lowEventFlushKeepalive())}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()}:{}}setExperiment(e,t){this.setExperiments({[e]:t})}setExperiments(e){try{if(!e||typeof e!="object")return;let t=!1;for(let[i,r]of Object.entries(e)){if(!n.isValidExperimentKey(i)||!n.isValidExperimentVariant(r)){this.logger.debug(`Ignoring invalid experiment assignment "${String(i)}"`);continue}this.experiments[i]!==r&&(this.experiments[i]=r,t=!0)}t&&this.persistExperiments()}catch(t){this.logger.error("Failed to set experiments",t)}}clearExperiment(e){try{Object.prototype.hasOwnProperty.call(this.experiments,e)&&(delete this.experiments[e],this.persistExperiments())}catch(t){this.logger.error("Failed to clear experiment",t)}}clearExperiments(){try{if(Object.keys(this.experiments).length===0)return;this.experiments={},this.persistExperiments()}catch(e){this.logger.error("Failed to clear experiments",e)}}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(!n.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<=_r}loadPersistedDataPolicy(){try{let e=this.persistentStorage.getItem(ri);return n.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(ri,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<=Br&&Hr.test(e)}static isValidExperimentVariant(e){return typeof e=="string"&&e.length>0&&e.length<=Nr}loadPersistedExperiments(){try{let e=this.persistentStorage.getItem(ii);if(!e||typeof e!="object")return{};let t={};for(let[i,r]of Object.entries(e))n.isValidExperimentKey(i)&&n.isValidExperimentVariant(r)&&(t[i]=r);return t}catch(e){return this.logger.debug("Failed to load persisted experiments",e),{}}}persistExperiments(){try{this.persistentStorage.setItem(ii,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[i,r]of Object.entries(e))n.isValidExperimentKey(i)&&n.isValidExperimentVariant(r)&&(t[i]=r);return Object.keys(t).length>0?t:void 0}isTrackingBlocked(){return typeof navigator>"u"?!1:Kt(navigator.userAgent)}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 i=v();return this.persistPerTabSession(i,e),this.seq=0,this.logger.debug("Created session id",i),i}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(dt);if(t?.id&&e-t.lastActiveAt<this.config.sessionInactivityMs)return this.persistContinuitySession(t.id,e),this.seq=this.persistentStorage.getItem(M)??0,t.id;if(!t?.id){let r=this.readPerTabSession();if(r&&e-r.lastActiveAt<this.config.sessionInactivityMs)return this.persistContinuitySession(r.id,e),this.persistentStorage.setItem(M,0),this.seq=0,this.logger.debug("Adopted per-tab session id as continuity session",r.id),r.id}let i=v();return this.persistContinuitySession(i,e),this.persistentStorage.setItem(M,0),this.seq=0,this.logger.debug("Created continuity session id",i),i}persistContinuitySession(e,t){this.lastActivityWriteAt=t,this.persistentStorage.setItem(dt,{id:e,lastActiveAt:t})}readPerTabSession(){let e=this.sessionStorage.getItem(ti);if(e){if(typeof e=="string")return ai.test(e)?{id:e,lastActiveAt:Date.now()}:void 0;if(typeof e.lastActiveAt=="number")return ai.test(e.id)?e:void 0}}persistPerTabSession(e,t){this.lastActivityWriteAt=t;let i=this.configOverrides.sessionInactivityMs!==void 0||this.config.version?this.config.sessionInactivityMs:this.readPerTabSession()?.inactivityMs;this.sessionStorage.setItem(ti,{id:e,lastActiveAt:t,...i===void 0?{}:{inactivityMs:i}})}perTabInactivityMs(e){return this.configOverrides.sessionInactivityMs!==void 0?this.config.sessionInactivityMs:e.inactivityMs??this.config.sessionInactivityMs}nextSeq(){if(!this.config.sessionContinuity){let i=Date.now();return this.sessionId&&i-this.lastActivityWriteAt>=si&&this.persistPerTabSession(this.sessionId,i),this.seq++}let e=()=>{let i=Date.now(),r=this.persistentStorage.getItem(dt),o=!1;if(!r?.id&&this.sessionId)this.persistContinuitySession(this.sessionId,i);else if(r?.id)i-this.lastActivityWriteAt>=si&&this.persistContinuitySession(r.id,i),r.id!==this.sessionId&&(this.sessionId=r.id,this.queue.setSessionId(r.id),o=!0);else{let l=v();this.persistContinuitySession(l,i),this.persistentStorage.setItem(M,0),this.sessionId=l,this.queue.setSessionId(l),this.seq=0,o=!0}let s=this.persistentStorage.getItem(M);o&&(this.seq=typeof s=="number"?s:0);let a=typeof s=="number"&&s>this.seq?s:this.seq;return this.seq=a+1,this.persistentStorage.setItem(M,this.seq),a},t=this.config.seqLockTimeoutMs;return t===0||typeof navigator>"u"||!navigator.locks?.request?e():le(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")return;let e=wt(window.location.search,this.config.sourcePathQuery,this.config.sourcePathQueryAllow);return`${window.location.pathname}${e}`}resolveEventTabId(){return this.eventTabId===void 0&&(this.eventTabId=this.deviceCollector.getTabId()),this.eventTabId}trackSubflowStarted(e,t,i,r){let o={subflowType:e,...t};this.track("subflow_started",o,i?.userReference,void 0,void 0,i?.explicitTimestamp,i?.experiments,{id:r,subflowStartEventId:i?.subflowStartEventId,sessionId:i?.captureSessionId,initiator:i?.initiator})}trackSubflowTrigger(e,t,i){let r={subflowType:e,...t};this.track("subflow_trigger",r,i?.userReference,void 0,void 0,i?.explicitTimestamp,i?.experiments,{subflowStartEventId:i?.subflowStartEventId,sessionId:i?.captureSessionId,initiator:i?.initiator})}trackSubflowStepStarted(e,t,i,r,o){let s={subflowType:e,stepName:t,stepData:i,identifier:r?.identifier,ignoreAsInteraction:o};this.track("subflow_step_started",s,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}trackSubflowStepFinished(e,t,i,r){let o={subflowType:e,stepName:t,stepData:i,identifier:r?.identifier};this.track("subflow_step_finished",o,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}trackSubflowStepError(e,t,i,r){let o={subflowType:e,stepName:t,stepData:i,identifier:r?.identifier};this.track("subflow_step_error",o,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}trackSubflowError(e,t,i){let r={subflowType:e,stepData:t};this.track("subflow_error",r,i?.userReference,void 0,void 0,i?.explicitTimestamp,i?.experiments,{subflowStartEventId:i?.subflowStartEventId,sessionId:i?.captureSessionId,initiator:i?.initiator})}async track(e,t,i,r,o,s,a,l){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=s??Date.now(),p=l?.id??v(),u=l?.sessionId??this.sessionId,c=this.nextSeq(),f=typeof c=="number"?c:await c,y=this.resolveTrackingSourcePath(),h={type:"predefined",name:e,id:p,timestamp:d,seq:f,data:t,user:i,contexts:o,tags:r,experiments:this.resolveExperiments(a),meta:{captureVersion:1,pageId:J(),initiator:l?.initiator,trackingSourcePath:y??"",subflowStartEventId:l?.subflowStartEventId,tabId:this.resolveEventTabId()}},m=this.deviceInfoManager.getForEvent();m&&(h.deviceInfo=m),this.logger.debug(`Track: ${e}`,JSON.stringify(h,null,2));let T=this.passwordManagerSampler?.takeReport(u);T&&(h.passwordManagers=T),this.queue.enqueue(h,u)}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,i,r){try{let o=v(),s=this.sessionId,a={...this.options.defaultTags,...this.applicationTag(),...t};return this.track("flow_started",e,void 0,a,r,void 0,i,{id:o,sessionId:s}),this.flowHandle(o,s)}catch(o){return this.logger.warn("Failed to start flow",o),{enrich:async()=>{}}}}flowDecided(e,t,i){this.track("flow_decided",e,void 0,t,void 0,void 0,i)}conversion(e,t,i){let{userId:r,identifier:o,crossEnvironmentTransactionID:s,...a}=e,l={userId:r,identifier:o,crossEnvironmentTransactionID:s},d={...this.options.defaultTags,...this.applicationTag(),...t};this.track("conversion",a,l,d,void 0,void 0,i)}flowFinished(e,t,i){try{let{userId:r,identifier:o,...s}=e,a={userId:r,identifier:o},l=v(),d=this.sessionId;return this.track("flow_finished",s,a,t,void 0,void 0,i,{id:l,sessionId:d}),this.flowHandle(l,d)}catch(r){return this.logger.warn("Failed to finish flow",r),{enrich:async()=>{}}}}flowHandle(e,t){return{enrich:async i=>{try{await this.track("flow_enriched",{targetEventId:e},{...i},void 0,void 0,void 0,void 0,{sessionId:t})}catch(r){this.logger.warn("Failed to enrich flow",r)}}}}flowReset(e,t,i){this.track("flow_reset",e,void 0,t,void 0,void 0,i)}flowAutoFinished(e,t,i){let{userId:r,identifier:o,...s}=e,a={userId:r,identifier:o};this.track("flow_auto_finished",s,a,t,void 0,void 0,i)}setUser(e){this.track("flow_enriched",{match:{flowType:"*",at:"during"},expFol:!0},{...e})}setFlowTags(e,t){try{if(!e||typeof e!="object"){this.logger.warn("setFlowTags: ignoring non-object tags");return}let i={};for(let[o,s]of Object.entries(e)){if(o===""||typeof s!="string"){this.logger.warn(`setFlowTags: ignoring invalid tag "${o}"`);continue}i[o]=s}if(Object.keys(i).length===0)return;let r={match:{flowType:t?.flowType??"*",at:"during"}};t?.expandToChildren!==void 0&&(r.expCh=t.expandToChildren),t?.expandToFollowing!==void 0&&(r.expFol=t.expandToFollowing),this.track("flow_enriched",r,void 0,i)}catch(i){this.logger.warn("Failed to set flow tags",i)}}authMethodsDecisionStarted(e,t,i,r){this.track("auth_method_decision_started",e,void 0,t,void 0,r?.explicitTimestamp,i)}authMethodsDecisionFinished(e,t,i){this.track("auth_method_decision_finished",e,void 0,t,void 0,void 0,i)}authDecisionStarted(e,t,i){this.track("auth_decision_started",e,void 0,t,void 0,void 0,i)}authDecisionFinished(e,t,i){this.track("auth_decision_finished",e,void 0,t,void 0,void 0,i)}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??x(),captureVersion:1,pageId:e.pageId??J()},t)}catch(i){this.logger.error(`Failed to process low event "${e.lowType}" before enqueue`,i)}}telemetry(e,t){try{if(this.isTrackingBlocked()){this.logger.debug("Skipping telemetry for blocked user agent.");return}let i=typeof t=="string"?t:String(t);if(i.length===0)return;let r={id:v(),level:e,message:i.length>ni?i.slice(0,ni):i,ts:Date.now()};this.queue.enqueueTelemetry(r)}catch(i){this.logger.error("Failed to process telemetry before enqueue",i)}}probe(e){try{if(this.isTrackingBlocked()){this.logger.debug("Skipping probe for blocked user agent.");return}if(!e||typeof e!="object"||typeof e.kind!="string"||!Ur.test(e.kind)){this.logger.debug("Dropping probe with an invalid kind.");return}let t=e.payload;if(!t||typeof t!="object"){this.logger.debug(`Dropping probe "${e.kind}" without an object payload.`);return}let i=typeof e.pageId=="string"&&oi.test(e.pageId)?e.pageId:this.defaultProbePageId(),r={id:v(),kind:e.kind,ts:typeof e.ts=="number"&&Number.isFinite(e.ts)?Math.round(e.ts):Date.now(),pageId:i,seq:this.nextProbeSeq(i),payload:t};typeof e.cfg=="string"&&oi.test(e.cfg)&&(r.cfg=e.cfg);let o=Wr(e.ctx);o&&(r.ctx=o),this.queue.enqueueProbe(r)}catch(t){this.logger.error("Failed to process probe before enqueue",t)}}defaultProbePageId(){return this.probePageId??=Gr()}nextProbeSeq(e){let t=this.probeSeqs.get(e)??0;if(this.probeSeqs.delete(e),this.probeSeqs.set(e,t+1),this.probeSeqs.size>Kr){let i=this.probeSeqs.keys().next().value;i!==void 0&&this.probeSeqs.delete(i)}return t}logInfo(e){this.telemetry("info",e)}logError(e){this.telemetry("error",e)}attachUndeliveredDeviceInfo(e,t){try{let i=this.deviceInfoManager;if(!i?.hasUndelivered())return;let r=J(),o=e.find(s=>s.meta?.pageId===r&&!s.deviceInfo);if(o){o.deviceInfo=i.takeUndelivered();return}(t==="pagehide"||t==="destroy")&&i.reportUndelivered(t)}catch(i){this.logger.error("Failed to attach device info to batch",i)}}reportTelemetry(e,t){if(!this.telemetryReporting){this.telemetryReporting=!0;try{if(this.reportedTelemetryKeys.has(t)||this.reportedTelemetryKeys.size>=Vr)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")}passkeyLoginFullOperation(e){return new we(this,e)}passkeyEnrollmentFullOperation(e){return new Ce(this,e)}passwordLoginFullOperation(e){return new Pe(this,e)}passwordEnrollmentFullOperation(e){return new Oe(this,e)}emailLinkOperationFull(e){return new ke(this,e)}continueEmailLinkOperation(e){return new xe(this,e)}emailOtpOperationFull(e){return new Ee(this,e)}smsOtpOperationFull(e){return new Ie(this,e)}totpOperationFull(e){return new De(this,e)}provideIdentifierOperationFull(e){return new Le(this,e)}provideDataOperationFull(e){return new Ne(this,e)}socialLoginOperationFull(e){return new Re(this,e)}ssoLoginOperationFull(e){return new Fe(this,e)}appConfirmationOperationFull(e){return new Ae(this,e)}keySigningOperationFull(e){return new ne(this,e)}keyRegistrationOperationFull(e){return new oe(this,e)}captchaOperationFull(e){return new Me(this,e)}trustedDeviceCheckOperationFull(e){return new He(this,e)}trustedDeviceEnrollmentOperationFull(e){return new Be(this,e)}async destroy(){if(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.resolveSessionId();e&&(this.sessionId=e,this.queue.setSessionId(e))}return this.sessionId||void 0}resetSession(){let e=v();return this.config.sessionContinuity?(this.persistContinuitySession(e,Date.now()),this.persistentStorage.setItem(M,0)):this.persistPerTabSession(e,Date.now()),this.sessionId=e,this.seq=0,this.queue.setSessionId(e),this.logger.debug(`Session reset: ${e}`),e}},Qr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";function Gr(){let n=new Uint8Array(16);try{globalThis.crypto.getRandomValues(n)}catch{for(let t=0;t<n.length;t++)n[t]=Math.floor(Math.random()*256)}let e="";for(let t=0;t<n.length;t++)e+=Qr[n[t]&63];return e}function Wr(n){if(!n||typeof n!="object")return;let e={};for(let t of["state","flowType","step"]){let i=n[t];typeof i=="string"&&i.length>0&&(e[t]=i.slice(0,qr))}return Object.keys(e).length>0?e:void 0}var ut={};function li(n,e="default"){ut[e]=new Ke(n)}function pi(n="default"){if(!ut[n])throw new Error(`Tracker ${n} not initialized (call Corbado.init() first)`);return ut[n]}function zr(n){for(let e of n)li(e[0],e[1])}var di={};function ui(n,e,t=[],i){let r=pi(n),o=r[e];if(typeof o!="function")return;let s=o.apply(r,t);i&&s&&typeof s=="object"&&(di[i]=s)}function ci(n,e,t=[]){let i=di[n];if(!i)return;let r=e.split("."),o=i;for(let a=0;a<r.length-1;a++)if(o=o?.[r[a]],!o)return;let s=o[r[r.length-1]];typeof s=="function"&&s.apply(o,t)}function jr(n){for(let e of n)ui(e[0],e[1],Array.isArray(e[2])?e[2]:[],e[3])}function Yr(n){for(let e of n)ci(e[0],e[1],Array.isArray(e[2])?e[2]:[])}typeof window<"u"&&(window.Corbado?.IQ&&(zr(window.Corbado.IQ),delete window.Corbado.IQ),window.Corbado?.MQ&&(jr(window.Corbado.MQ),delete window.Corbado.MQ),window.Corbado?.OQ&&(Yr(window.Corbado.OQ),delete window.Corbado.OQ),window.Corbado={init:li,get:pi,__dispatchMethod:ui,__dispatchOp:ci});})();
|
|
5
5
|
/*! Bundled license information:
|
|
6
6
|
|
|
7
7
|
detectincognitojs/dist/detectIncognito.esm.js:
|
|
8
8
|
(*!
|
|
9
9
|
*
|
|
10
|
-
* detectIncognito v1.
|
|
10
|
+
* detectIncognito v1.9.0
|
|
11
|
+
*
|
|
12
|
+
* https://github.com/Joe12387/detectIncognito
|
|
13
|
+
*
|
|
14
|
+
* MIT License
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) 2021 - 2026 Joe Rutkowski <Joe@dreggle.com>
|
|
17
|
+
*
|
|
18
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
19
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
20
|
+
* in the Software without restriction, including without limitation the rights
|
|
21
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
22
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
23
|
+
* furnished to do so, subject to the following conditions:
|
|
24
|
+
*
|
|
25
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
26
|
+
* copies or substantial portions of the Software.
|
|
27
|
+
*
|
|
28
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
29
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
30
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
31
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
32
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
33
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
34
|
+
* SOFTWARE.
|
|
35
|
+
*
|
|
36
|
+
* Please keep this comment intact in order to properly abide by the MIT License.
|
|
37
|
+
*
|
|
38
|
+
**)
|
|
39
|
+
(*!
|
|
40
|
+
*
|
|
41
|
+
* detectIncognito v1.8.1
|
|
11
42
|
*
|
|
12
43
|
* https://github.com/Joe12387/detectIncognito
|
|
13
44
|
*
|