@corbado/autocapture 1.1.0 → 1.2.0

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/probe.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var De=Object.defineProperty;var An=Object.getOwnPropertyDescriptor;var Rn=Object.getOwnPropertyNames;var Pn=Object.prototype.hasOwnProperty;var Tn=(t,e,n)=>e in t?De(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var $n=(t,e)=>{for(var n in e)De(t,n,{get:e[n],enumerable:!0})},xn=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Rn(e))!Pn.call(t,o)&&o!==n&&De(t,o,{get:()=>e[o],enumerable:!(r=An(e,o))||r.enumerable});return t};var Ln=t=>xn(De({},"__esModule",{value:!0}),t);var M=(t,e,n)=>Tn(t,typeof e!="symbol"?e+"":e,n);var ro={};$n(ro,{ProbeTaint:()=>ke,applyGuards:()=>Fe,createProbeTaint:()=>Ft,probeConfigHash:()=>Ge,probeConfigSchema:()=>nn,startProbes:()=>Sn,validateProbeConfig:()=>Ze});module.exports=Ln(ro);var Mn={log:()=>{}};function ye(t){return t?{log:(...e)=>{try{let n=t.log(...e);if(n&&(typeof n=="object"||typeof n=="function"))try{Promise.resolve(n).catch(()=>{})}catch{}}catch{}}}:Mn}var Rt=Symbol.for("corbado.autocapture.installed");function be(t){try{return typeof t=="function"&&Object.prototype.hasOwnProperty.call(t,Rt)}catch{return!1}}function we(t,e){var r,o;let n=e;try{Object.defineProperty(t,Rt,{value:e,configurable:!0})}catch{}try{Object.defineProperty(t,"name",{value:(r=n.name)!=null?r:"",configurable:!0})}catch{}try{Object.defineProperty(t,"length",{value:(o=n.length)!=null?o:0,configurable:!0})}catch{}return t}function oe(){return{mode:"unavailable",disconnect:()=>{}}}function tt(t,e){return!!t&&"value"in t&&"value"in e&&t.value===e.value&&t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable}function Ee(t,e,n,r,o,s=String(e)){try{let i=Object.getOwnPropertyDescriptor(t,e);tt(i,{...r,value:n})&&Object.defineProperty(t,e,r)}catch(i){o.log(`${s} restoration skipped`,i)}}function Ce(t,e,n){let r=ye(t);return o=>{try{let s=n(o);if(s&&(typeof s=="object"||typeof s=="function"))try{Promise.resolve(s).catch(i=>r.log(`${e} listener failed`,i))}catch(i){r.log(`${e} listener failed`,i)}}catch(s){r.log(`${e} listener failed`,s)}}}function $t(t){let e=t.onNavigate;if(typeof e!="function")throw new TypeError("captureNavigation requires an onNavigate callback");let n=ye(t.logger),r,o,s,i,a,u;try{if(r=window,o=r==null?void 0:r.history,!r||!o)return n.log("navigation capture unavailable: window/history missing"),oe();if(a=Pt(o,"pushState"),u=Pt(o,"replaceState"),!a||!u)return n.log("navigation capture unavailable: history method descriptors missing"),oe();if(s=a.descriptor.value,i=u.descriptor.value,typeof s!="function"||typeof i!="function")return n.log("navigation capture unavailable: history methods missing"),oe();if(typeof r.addEventListener!="function"||typeof r.removeEventListener!="function")return n.log("navigation capture unavailable: window event methods missing"),oe()}catch(T){return n.log("navigation capture unavailable: history inspection failed",T),oe()}if(be(s)||be(i))return n.log("navigation capture unavailable: an equivalent capture is already active"),oe();let c=!1,f=()=>({path:r.location.pathname,search:r.location.search,hash:r.location.hash}),d;try{d=f()}catch(T){return n.log("navigation capture unavailable: location inspection failed",T),oe()}let l=Ce(n,"navigation",T=>{if(c)return e(T)}),p=T=>{if(c)try{let U=f();if(U.path===d.path&&U.search===d.search&&U.hash===d.hash)return;d=U,l({...U,source:T})}catch(U){n.log("navigation observation failed",U)}},y={pushState(...T){let U=Reflect.apply(s,this,T);return p("push"),U}}.pushState,k={replaceState(...T){let U=Reflect.apply(i,this,T);return p("replace"),U}}.replaceState;we(y,s),we(k,i);let R=()=>p("pop"),x=()=>p("hash");try{if(Tt(a,y),Tt(u,k),o.pushState!==y||o.replaceState!==k)throw new Error("history method replacement did not take effect");r.addEventListener("popstate",R),r.addEventListener("hashchange",x),c=!0}catch(T){return c=!1,Be(r,"popstate",R,n),Be(r,"hashchange",x,n),He(u,k,n),He(a,y,n),n.log("navigation capture unavailable: history methods are not writable",T),e=()=>{},l=()=>{},n=ye(),oe()}return{mode:"standard",disconnect:()=>{c=!1,e=()=>{},Be(r,"popstate",R,n),Be(r,"hashchange",x,n),He(a,y,n),He(u,k,n),l=()=>{},n=ye()}}}function Pt(t,e){let n=t;for(;n;){let r=Object.getOwnPropertyDescriptor(n,e);if(r)return!("value"in r)||typeof r.value!="function"?null:{owner:n,key:e,descriptor:r};n=Object.getPrototypeOf(n)}return null}function Tt(t,e){if(t.descriptor.writable!==!0)throw new TypeError(`${t.key} is not writable`);let n=Object.getOwnPropertyDescriptor(t.owner,t.key);if(!tt(n,t.descriptor))throw new Error(`${t.key} changed during installation`);Object.defineProperty(t.owner,t.key,{...t.descriptor,value:e})}function He(t,e,n){Ee(t.owner,t.key,e,t.descriptor,n,`navigation ${t.key}`)}function Be(t,e,n,r){try{t.removeEventListener(e,n)}catch(o){r.log(`navigation ${e} listener removal skipped`,o)}}var xt=0;function Lt(){return xt+=1,`network-${xt}`}function On(t,e){let n=t.responseType;if(n===""||n==="text")return e(t.responseText);if(n==="json"){let r=t.response;return r==null?void 0:e(r)}}var Cn=500,Mt=Symbol("body-read-timeout");function Ot(t){return/event-stream|octet-stream/i.test(t)?!1:/json|text|urlencoded/i.test(t)}async function Ct(t,e){let n=t.body;if(!n)return;let r=n.getReader(),o;try{let s=new Promise(u=>{o=setTimeout(()=>u(Mt),Cn)}),i=new TextDecoder,a=[];for(;;){let u=await Promise.race([r.read(),s]);if(u===Mt){e.log("body omitted: read timed out"),r.cancel().catch(()=>{});return}if(u.done)break;a.push(i.decode(u.value,{stream:!0}))}return a.push(i.decode()),a.join("")}catch{r.cancel().catch(()=>{});return}finally{o!==void 0&&clearTimeout(o)}}function nt(t){var e;(e=t==null?void 0:t.body)==null||e.cancel().catch(()=>{})}function It(t){var T,U,F;let{onExchange:e,onRequest:n,match:r}=t;if(typeof e!="function"||typeof r!="function")throw new TypeError("captureNetwork requires onExchange and match callbacks");let o=ye(t.logger),s=(T=t.transports)!=null?T:["xhr","fetch"],i=(U=t.bodyCapture)==null?void 0:U.request,a=(F=t.bodyCapture)==null?void 0:F.response,u=typeof i=="function",c=typeof a=="function",f=!1,d=Ce(o,"network",E=>{if(f)return e(E)}),l=Ce(o,"network request",E=>{if(f)return n==null?void 0:n(E)}),p=(E,I,$)=>{if(typeof $=="function")try{return $(E,I)}catch(C){o.log("body projection failed",C);return}},y=(E,I)=>{try{let $=typeof document!="undefined"?document.baseURI:void 0,C=new URL(String(E),$);return r(C,I)===!0?{url:C.href,path:C.pathname}:void 0}catch{return}},k=()=>{if(typeof XMLHttpRequest=="undefined")return o.log("xhr capture unavailable: XMLHttpRequest missing"),null;let E=XMLHttpRequest.prototype,I=Object.getOwnPropertyDescriptor(E,"open"),$=Object.getOwnPropertyDescriptor(E,"send");if(!I||!("value"in I)||typeof I.value!="function"||!$||!("value"in $)||typeof $.value!="function")return o.log("xhr capture unavailable: XMLHttpRequest methods missing"),null;let C=I.value,q=$.value;if(be(C)||be(q))return o.log("xhr capture unavailable: an equivalent capture is already active"),null;let V=new WeakMap,P=new Set,D=!1,_={open(...H){var N;let b=Reflect.apply(C,this,H);if(!f||!D)return b;try{let h=V.get(this);h&&(h.reported=!0,(N=h.cleanupListeners)==null||N.call(h));let m=String(H[0]).toUpperCase(),g=y(H[1],m);g?V.set(this,{method:m,url:g.url,path:g.path,reported:!1}):V.delete(this)}catch(h){o.log("xhr open observation failed",h)}return b}}.open,Y={send(...H){let b=f&&D?V.get(this):void 0;if(!b||b.reported||b.cleanupListeners)return Reflect.apply(q,this,H);let N=()=>{},h=!1;try{b.requestId=Lt();let g={direction:"request",transport:"xhr",method:b.method,url:b.url,path:b.path};b.requestBody=u&&typeof H[0]=="string"?p(H[0],g,i):void 0;let A=()=>{b.outcome===void 0&&(b.outcome="abort")},L=()=>{b.outcome===void 0&&(b.outcome="timeout")},v=()=>{b.outcome===void 0&&(b.outcome="error")},S=()=>{var Q;N();try{if(!f||!D||b.reported||!b.requestId)return;b.reported=!0;let w={direction:"response",transport:"xhr",method:b.method,url:b.url,path:b.path},W=this.status,K={requestId:b.requestId,transport:"xhr",method:b.method,url:b.url,path:b.path,status:W,ok:W>=200&&W<300,outcome:(Q=b.outcome)!=null?Q:"load",durationMs:b.startedAt!==void 0?Date.now()-b.startedAt:void 0,responseUrl:this.responseURL||void 0,requestBody:b.requestBody,responseBody:c?On(this,ge=>p(ge,w,a)):void 0};b.requestEmitted?d(K):b.pendingExchange=K}catch(w){o.log("xhr exchange observation failed",w)}finally{V.get(this)===b&&V.delete(this)}},O=()=>{try{this.readyState===XMLHttpRequest.DONE&&this.status!==0&&S()}catch(Q){o.log("xhr ready-state observation failed",Q)}},z=()=>S();N=()=>{for(let[Q,w]of[["readystatechange",O],["abort",A],["timeout",L],["error",v],["loadend",z]])this.removeEventListener(Q,w);b.cleanupListeners===N&&(b.cleanupListeners=void 0),P.delete(N)},this.addEventListener("readystatechange",O),this.addEventListener("abort",A),this.addEventListener("timeout",L),this.addEventListener("error",v),this.addEventListener("loadend",z),b.cleanupListeners=N,P.add(N),b.startedAt=Date.now(),h=!0}catch(g){o.log("xhr send observation failed",g),N()}let m;try{m=Reflect.apply(q,this,H)}catch(g){throw N(),g}if(h&&b.requestId!==void 0&&b.startedAt!==void 0){b.requestEmitted=!0,l({requestId:b.requestId,transport:"xhr",method:b.method,url:b.url,path:b.path,startedAt:b.startedAt,requestBody:b.requestBody});let g=b.pendingExchange;b.pendingExchange=void 0,g&&d(g)}return m}}.send;return we(_,C),we(Y,q),I.writable!==!0||$.writable!==!0?(o.log("xhr capture unavailable: XMLHttpRequest methods are not writable"),null):(Object.defineProperty(E,"open",{...I,value:_}),Object.defineProperty(E,"send",{...$,value:Y}),D=!0,()=>{D=!1;for(let H of[...P])H();Ee(E,"open",_,I,o),Ee(E,"send",Y,$,o)})},R=()=>{let E=globalThis,I=Object.getOwnPropertyDescriptor(E,"fetch");if(!I||!("value"in I))return o.log("fetch capture unavailable: fetch is not an own data property"),null;let $=I.value;if(typeof $!="function")return o.log("fetch capture unavailable: fetch missing"),null;if(be($))return o.log("fetch capture unavailable: an equivalent capture is already active"),null;let C=!1,q=async(P,D,_,Y)=>{try{if(!f||!C){nt(_);return}let[H,b]=await Promise.all([Y!=null?Y:Promise.resolve(void 0),_?Ct(_,o):Promise.resolve(void 0)]);if(!f||!C)return;let N={direction:"request",transport:"fetch",method:P.method,url:P.url,path:P.path},h={...N,direction:"response"},m=P.requestBody;m===void 0&&H!==void 0&&(m=p(H,N,i));let g=b!==void 0?p(b,h,a):void 0;d({requestId:P.requestId,transport:"fetch",method:P.method,url:P.url,path:P.path,status:D.status,ok:D.ok,outcome:"load",durationMs:Date.now()-P.startedAt,responseUrl:D.url||void 0,requestBody:m,responseBody:g})}catch(H){o.log("fetch exchange observation failed",H)}},V={fetch(...P){var m,g,A,L;let D;try{let v=P[0],S=P[1];if(f&&C&&u&&typeof Request!="undefined"&&v instanceof Request&&(S==null?void 0:S.body)===void 0&&v.body){let O=String((m=S==null?void 0:S.method)!=null?m:v.method).toUpperCase(),z=(g=v.headers.get("content-type"))!=null?g:"";y(v.url,O)&&Ot(z)&&(D=v.clone())}}catch(v){o.log("fetch observation failed",v)}let _,Y=Date.now();try{_=Reflect.apply($,this,P)}catch(v){throw nt(D),v}let H,b;try{if(f&&C){let v=P[0],S=P[1],O=typeof Request!="undefined"&&v instanceof Request,z=String((A=S==null?void 0:S.method)!=null?A:O?v.method:"GET").toUpperCase(),Q=O?v.url:v,w=y(Q,z);w&&(H={requestId:Lt(),method:z,url:w.url,path:w.path,startedAt:Y},b=(L=S==null?void 0:S.signal)!=null?L:O?v.signal:void 0,u&&typeof(S==null?void 0:S.body)=="string"&&(H.requestBody=p(S.body,{direction:"request",transport:"fetch",method:z,url:w.url,path:w.path},i)))}}catch(v){o.log("fetch observation failed",v)}if(!H)return nt(D),_;let N=H;l({requestId:N.requestId,transport:"fetch",method:N.method,url:N.url,path:N.path,startedAt:N.startedAt,requestBody:N.requestBody});let h=D?Ct(D,o):void 0;return _.then(v=>{var O;let S;try{if(f&&C&&c){let z=(O=v.headers.get("content-type"))!=null?O:"";Ot(z)&&v.body&&(S=v.clone())}}catch{}q(N,v,S,h)},v=>{try{if(!f||!C)return;let S=(b==null?void 0:b.aborted)===!0||(v==null?void 0:v.name)==="AbortError"||typeof DOMException!="undefined"&&v instanceof DOMException&&v.code===DOMException.ABORT_ERR;d({requestId:N.requestId,transport:"fetch",method:N.method,url:N.url,path:N.path,status:0,ok:!1,outcome:S?"abort":"error",durationMs:Date.now()-N.startedAt})}catch(S){o.log("fetch failure observation failed",S)}}),_}}.fetch;return we(V,$),I.writable!==!0?(o.log("fetch capture unavailable: fetch is not writable"),null):(Object.defineProperty(E,"fetch",{...I,value:V}),C=!0,()=>{C=!1,Ee(E,"fetch",V,I,o)})},x=[];if(s.includes("xhr")){let E=k();E&&x.push(E)}if(s.includes("fetch")){let E=R();E&&x.push(E)}return x.length===0?oe():(f=!0,{mode:"standard",disconnect:()=>{f=!1;for(let E of x.splice(0))E()}})}var Nt="1.1.0";function Ae(t,e=2166136261){let n=e>>>0;for(let r=0;r<t.length;r++)n^=t.charCodeAt(r),n=Math.imul(n,16777619);return n>>>0}function Re(t){return Ae(t).toString(36).padStart(7,"0")+Ae(t,1540483477).toString(36).padStart(7,"0")}function jt(t){return JSON.stringify(rt(t))}function rt(t){if(Array.isArray(t))return t.map(rt);if(t&&typeof t=="object"){let e={};for(let n of Object.keys(t).sort())e[n]=rt(t[n]);return e}return t}function In(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);r<128?e+=1:r<2048?e+=2:r>=55296&&r<=56319&&n+1<t.length?(e+=4,n++):e+=3}return e}function fe(t){try{let e=JSON.stringify(t);return e===void 0?0:In(e)}catch{return 1/0}}var re=t=>t.toLowerCase().replace(/[-_\s]/g,""),_e=new Map;function Nn(t){let e=_e.get(t);if(!e){let n=t.split("").map(r=>r==="*"?".*":r==="?"?".":r.replace(/[.+^${}()|[\]\\/]/g,"\\$&")).join("");e=new RegExp(`^${n}$`,"i"),_e.size>500&&_e.clear(),_e.set(t,e)}return e}function X(t,e){if(t===void 0)return!0;let n=typeof t=="string"?[t]:t;for(let r of n)if(Nn(r).test(e))return!0;return!1}var Pe=t=>t===void 0?[]:Array.isArray(t)?t:[t];function ot(t){let e=new Uint8Array(t);try{let n=typeof crypto!="undefined"?crypto:void 0;if(n&&typeof n.getRandomValues=="function")return n.getRandomValues(e),e}catch{}for(let n=0;n<t;n++)e[n]=Math.floor(Math.random()*256);return e}var jn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";function st(t){let e=ot(t),n="";for(let r=0;r<t;r++)n+=jn[e[r]&63];return n}function j(t){try{return t()}catch{return}}function se(t){let e=t.trim();if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))try{return JSON.parse(e)}catch{return}}function le(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Z(t){try{return t.getAttribute("id")||void 0}catch{return}}function Ie(t){var n;let e=(n=t.getAttribute("action"))!=null?n:"";try{return new URL(e,document.baseURI).href}catch{return e}}function Ue(t){return(t.getAttribute("method")||"get").toLowerCase()}function qt(t){var u,c,f,d;let e=(u=t==null?void 0:t.userAgent)!=null?u:"",n=t==null?void 0:t.userAgentData,r=((c=n==null?void 0:n.brands)!=null?c:[]).map(l=>l.brand.toLowerCase()),o="other";r.some(l=>l.includes("edge"))?o="edge":r.some(l=>l.includes("opera"))?o="opera":/SamsungBrowser\//.test(e)?o="samsung":/Edg(e|A|iOS)?\//.test(e)?o="edge":/OPR\/|Opera/.test(e)?o="opera":/Firefox\/|FxiOS\//.test(e)?o="firefox":r.some(l=>l.includes("chrome")||l.includes("chromium"))||/Chrome\/|CriOS\//.test(e)?o="chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&(o="safari");let s=((f=n==null?void 0:n.platform)!=null?f:"").toLowerCase(),i="other";s==="android"||/Android/.test(e)?i="android":/iPhone|iPad|iPod/.test(e)||/Macintosh/.test(e)&&((d=t==null?void 0:t.maxTouchPoints)!=null?d:0)>1?i="ios":s==="windows"||/Windows/.test(e)?i="windows":s==="chrome os"||s==="chromeos"||/CrOS/.test(e)?i="chromeos":s==="macos"||/Macintosh|Mac OS X/.test(e)?i="macos":(s==="linux"||/Linux/.test(e))&&(i="linux");let a="desktop";return/iPad|Tablet/.test(e)||i==="android"&&!/Mobile/.test(e)||i==="ios"&&/Macintosh/.test(e)?a="tablet":((n==null?void 0:n.mobile)===!0||/Mobi|iPhone|iPod/.test(e))&&(a="mobile"),{browser:o,os:i,device:a}}function qn(t,e,n){return t===void 0||t>=1?!0:t<=0?!1:(e?Ae(`${n}:${e}`)/4294967296:Math.random())<t}function Dn(t,e){if(!t)return!1;let n=/^\d{4}-\d{2}-\d{2}$/.test(t)?Date.parse(`${t}T23:59:59.999Z`):Date.parse(t);return!Number.isFinite(n)||e>n}function Dt(t,e){var n;if(t){if(t.projects&&!t.projects.includes(e.projectId))return"projects";if(Dn(t.until,e.now))return"until";if(t.browser&&!t.browser.includes(e.client.browser))return"browser";if(t.os&&!t.os.includes(e.client.os))return"os";if(t.device&&!t.device.includes(e.client.device))return"device";if(t.integrationVersion&&!X(t.integrationVersion,(n=e.integrationVersion)!=null?n:""))return"integrationVersion";if(!qn(t.sample,e.sessionId,e.salt))return"sample"}}function Ht(t,e){if(!t)return"match";let n=!1;for(let[r,o]of Object.entries(t)){let s=e==null?void 0:e[r];if(s==null||s===""){n=!0;continue}if(!o.includes("*")&&!o.includes(String(s)))return"mismatch"}return n?"unknown":"match"}var Hn=new Set(["drop","presence","length"]),Bn=/(^|\s)(current-password|new-password|one-time-code|cc-[a-z-]+)(\s|$)/i,_n=/(password|passwd|passcode|^pwd$|^otp|otp$|onetime|^pin$|^cvv|^cvc|^ssn$|securitycode|verificationcode)/;function at(t){try{let e=t.value;return typeof e=="string"?e:""}catch{return""}}function zt(t){var e,n,r;try{let o=t;if(t.tagName==="INPUT"&&(o.type||"").toLowerCase()==="password")return!0;let s=(e=t.getAttribute("autocomplete"))!=null?e:"";if(Bn.test(s))return!0;for(let a of[o.name,t.id])if(a&&_n.test(re(a)))return!0;let i=(n=o.form)!=null?n:t.closest("form");if(i){for(let a of Array.from(i.querySelectorAll("input[autocomplete]")).slice(0,50))if(/(^|\s)webauthn(\s|$)/i.test((r=a.getAttribute("autocomplete"))!=null?r:""))return!0}return!1}catch{return!0}}function ze(t,e,n){let r=zt(t)&&!Hn.has(e.method)?{method:"length"}:e;return n(at(t),r)}function ut(t){return at(t).length}var Bt=6,Un=4096,zn=400,ke=class{constructor(){M(this,"base1");M(this,"base2");M(this,"byLength",new Map);M(this,"order",[]);let e=ot(8),n=r=>(e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3])>>>0;this.base1=(n(0)|65537)>>>0,this.base2=(n(4)|65537)>>>0}get size(){return this.order.length}add(e){if(typeof e!="string"||e.length<Bt||e.length>Un)return;let n=new Set([e]);try{n.add(encodeURIComponent(e))}catch{}try{n.add(new URLSearchParams({v:e}).toString().slice(2))}catch{}n.add(JSON.stringify(e).slice(1,-1));for(let r of n)this.addOne(r)}addOne(e){var o;let n=this.fingerprint(e,0,e.length),r=this.byLength.get(e.length);if(r||this.byLength.set(e.length,r=new Set),!r.has(n))for(r.add(n),this.order.push([e.length,n]);this.order.length>zn;){let[s,i]=this.order.shift();(o=this.byLength.get(s))==null||o.delete(i)}}fingerprint(e,n,r){let o=0,s=0;for(let i=n;i<n+r;i++){let a=e.charCodeAt(i);o=Math.imul(o,this.base1)+a>>>0,s=Math.imul(s,this.base2)+a>>>0}return`${o}:${s}`}scrub(e){if(this.order.length===0||e.length<Bt)return e;let n=[];for(let[i,a]of this.byLength){if(a.size===0||i>e.length)continue;let u=1,c=1;for(let l=0;l<i-1;l++)u=Math.imul(u,this.base1)>>>0,c=Math.imul(c,this.base2)>>>0;let f=0,d=0;for(let l=0;l<i;l++){let p=e.charCodeAt(l);f=Math.imul(f,this.base1)+p>>>0,d=Math.imul(d,this.base2)+p>>>0}for(let l=0;;l++){a.has(`${f}:${d}`)&&n.push([l,l+i]);let p=l+i;if(p>=e.length)break;let y=e.charCodeAt(l),k=e.charCodeAt(p);f=Math.imul(f-Math.imul(y,u)>>>0,this.base1)+k>>>0,d=Math.imul(d-Math.imul(y,c)>>>0,this.base2)+k>>>0}}if(n.length===0)return e;n.sort((i,a)=>i[0]-a[0]||a[1]-i[1]);let r="",o=0,s=0;for(;s<n.length;){let[i,a]=n[s];for(s++;s<n.length&&n[s][0]<a;)a=Math.max(a,n[s][1]),s++;i<o&&(i=o),r+=e.slice(o,i)+`<tainted:${a-i}>`,o=a}return r+e.slice(o)}};function Ft(t=[]){let e=new ke;for(let n of t)e.add(n);return e}var Fn=new Set(["challenge","id","rawId","userHandle","signature","clientDataJSON","authenticatorData","attestationObject","publicKey"].map(re));function Vt(t,e){if(!e||typeof e!="object")return;let n=e;for(let r of["requestOptionsJson","creationOptionsJson","credentialJson"]){let o=n[r];if(typeof o!="string")continue;t.add(o);let s;try{s=JSON.parse(o)}catch{continue}let i=0,a=(u,c,f)=>{if(!(f>8||++i>500)){if(typeof u=="string"){Fn.has(re(c))&&t.add(u);return}if(Array.isArray(u)){for(let d of u.slice(0,50))a(d,c,f+1);return}if(u&&typeof u=="object")for(let[d,l]of Object.entries(u))a(l,d,f+1)}};a(s,"",0)}}function Kt(t,e){if(e)try{let n=Array.from(e.querySelectorAll("input, textarea")).slice(0,200),r=0;for(let o of n){if(r>=30)break;zt(o)&&(r++,t.add(at(o)))}}catch{}}function Jt(t,e){for(let n of e.split(";").slice(0,100)){let r=n.indexOf("=");if(r<0)continue;let o=n.slice(r+1).trim();t.add(o);try{let s=decodeURIComponent(o);s!==o&&t.add(s)}catch{}}}function Xt(t,e){if(typeof e!="string")return;t.add(e);let n=e.trim().split(/\s+/);n.length>1&&t.add(n.slice(1).join(" "))}var Vn=new Set(["password","passwd","pwd","passphrase","clientDataJSON","authenticatorData","signature","attestationObject","userHandle","authorization","proxyAuthorization","cookie","setCookie","privateKey","clientSecret"].map(re));function pe(t){let e=re(t);return Vn.has(e)||e.includes("password")}var Kn=/eyJ0eXBlIjoid2ViYXV0aG4u[A-Za-z0-9_\-+/=]*/gi,Jn=/eyJ[A-Za-z0-9_-]{16,}(?:\.[A-Za-z0-9_-]*){0,4}/gi,Xn=/("|\\")(password|passwd|pwd|clientDataJSON|authenticatorData|signature|attestationObject|userHandle|authorization)\1(\s*:\s*)\1(?!<)((?:(?!\1)[^\\]|\\.)*?)\1/gi,Wn=/(^|[?&;\s,])(password|passwd|pwd)=([^&\s;,]+)/gi,Zn=/\b(Bearer|Basic)\s+([A-Za-z0-9._~+/=-]{8,})/g,Gn=/\b((?:proxy-)?authorization)(\s*[:=]\s*|"\s*:\s*")((?:Bearer|Basic|Digest|Token|Negotiate)\s+)?(?!<)([^\s,;"&]+)/gi;function ct(t){return t.replace(Gn,(e,n,r,o,s)=>`${n}${r}${o!=null?o:""}<redacted:${s.length}>`)}var Yn=/\d(?:[ -]?\d){12,}/g,Qn=/[A-Za-z0-9_\-+/]{24,}={0,2}/g;function er(t){let e=0,n=!1;for(let r=t.length-1;r>=0;r--){let o=t.charCodeAt(r)-48;n&&(o*=2,o>9&&(o-=9)),e+=o,n=!n}return e%10===0}function Wt(t){for(let e=13;e<=Math.min(19,t.length);e++)for(let n=0;n+e<=t.length;n++)if(er(t.slice(n,n+e)))return!0;return!1}function tr(t){var r;let e=new Map;for(let o of t)e.set(o,((r=e.get(o))!=null?r:0)+1);let n=0;for(let o of e.values()){let s=o/t.length;n-=s*Math.log2(s)}return n}function _t(t){return t.length>=24&&/\d/.test(t)&&/[A-Za-z]/.test(t)&&tr(t)>=3}var nr=/^([A-Za-z][a-z]*(?:[-_.][A-Za-z]+)*|v\d{1,2}|\d{1,5}|)$/;function rr(t){if(!t.includes("/"))return!1;let e=t.split("/");return e.filter(r=>nr.test(r)).length*2>=e.length}function or(t){return rr(t)?t.split("/").map(e=>_t(e)?`<tok:${e.length}>`:e).join("/"):_t(t)?`<tok:${t.length}>`:t}function Ut(t,e){let n=e?e.scrub(t):t;return n=ct(n),n=n.replace(Xn,(r,o,s,i,a)=>`${o}${s}${o}${i}${o}<redacted:${a.length}>${o}`),n=n.replace(Wn,(r,o,s,i)=>i.startsWith("<")?r:`${o}${s}=<redacted:${i.length}>`),n=n.replace(Zn,(r,o,s)=>`${o} <redacted:${s.length}>`),n=n.replace(Kn,r=>`<webauthn:${r.length}>`),n=n.replace(Jn,r=>`<jwt:${r.length}>`),n=n.replace(Yn,r=>{let o=r.replace(/[ -]/g,"");return o.length>19?`<digits:${o.length}>`:Wt(o)?`<card:${o.length}>`:r}),n=n.replace(Qn,or),n}function sr(t){if(!Number.isFinite(t))return null;if(!Number.isInteger(t))return t;let e=String(Math.abs(t));return e.length>=13&&Wt(e)?`<card:${e.length}>`:t}function ir(t){return t==null||typeof t=="boolean"?t:typeof t=="string"?ar.test(t)?t:`<redacted:${t.length}>`:typeof t=="number"?"<redacted:num>":"<redacted:obj>"}var ar=/^<[a-z]+(?::[A-Za-z0-9.]{1,12})?>$/,ur=24;function it(t,e,n){if(n>ur)return"<deep>";if(t===null||typeof t=="boolean")return t;if(typeof t=="string")return Ut(t,e);if(typeof t=="number")return sr(t);if(Array.isArray(t))return t.map(r=>{let o=it(r,e,n+1);return o===void 0?null:o});if(typeof t=="object"){let r={};for(let[o,s]of Object.entries(t)){let i=Ut(o,e),a=pe(o)?ir(s):it(s,e,n+1);a!==void 0&&(r[i]=a)}return r}}function Fe(t,e){try{return it(t,e!=null?e:void 0,0)}catch{return}}var Zt=2e3;function Te(t){if(typeof t=="string"&&t.length<=3e5){let e=se(t);if(e!==void 0)return e}return t}function cr(t,e){let n=[Te(t)];for(;n.length&&e.length<Zt;){let r=n.shift();if(r===null||typeof r!="object")continue;Array.isArray(r)||e.push(r);let o=Array.isArray(r)?r:Object.values(r);for(let s of o.slice(0,200)){let i=Te(s);i!==null&&typeof i=="object"&&n.push(i)}}}function Ve(t,e){let n=[Te(t)];for(let r of e.split(".").filter(Boolean)){let o=[];if(r==="**"){for(let u of n)cr(u,o);n=o;continue}let s=r.endsWith("[]"),i=s?r.slice(0,-2):r,a=u=>{let c=i===""?u:le(u)?Te(u[i]):void 0;if(c!==void 0)if(s){if(Array.isArray(c))for(let f of c.slice(0,200))o.push(Te(f))}else o.push(c)};for(let u of n){if(o.length>=Zt)break;if(Array.isArray(u)&&i!=="")for(let c of u.slice(0,200))a(Te(c));else a(u)}n=o}return n}function $e(t,e){return Ve(t,e)[0]}function Ke(t,e){if(!e)return!0;for(let[n,r]of Object.entries(e)){let o=Array.isArray(r)?r:[r];if(!Ve(t,n).some(i=>i!=null&&o.includes(String(i))))return!1}return!0}function Gt(t){return t==null?0:Array.isArray(t)?t.length:typeof t=="object"?Object.keys(t).length:1}var dr=/^[^\s@]{1,64}@[^\s@]+\.[^\s@]{2,}$/,fr=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,lr=/^[a-z][a-z0-9+.-]*:\/\/\S+$/i,pr=/^\d{4}-\d{2}-\d{2}([T ][\d:.]+(Z|[+-]\d{2}:?\d{2})?)?$/,hr=/^\+?[\d\s().-]{7,20}$/;function J(t){if(t==="")return"";let e=t.length;return/^eyJ/i.test(t)&&e>20?`<jwt:${e}>`:dr.test(t)?"<email>":fr.test(t)?"<uuid>":lr.test(t)?"<url>":pr.test(t)?"<date>":/^\d+$/.test(t)?`<digits:${e}>`:hr.test(t)&&/\d{3}/.test(t)?"<phone>":/^(true|false|null|undefined)$/i.test(t)?`<${t.toLowerCase()}>`:/^[A-Za-z]+$/.test(t)?`<alpha:${e}>`:/^[0-9a-f]+$/i.test(t)&&e>=8?`<hex:${e}>`:/^[A-Za-z0-9]+$/.test(t)?`<alnum:${e}>`:/^[A-Za-z0-9_-]+$/.test(t)?`<id:${e}>`:/^[A-Za-z0-9+/]+={0,2}$/.test(t)&&e>=16?`<b64:${e}>`:/\s/.test(t.trim())?`<text:${t.trim().split(/\s+/).length}w>`:`<str:${e}>`}function ue(t){return t==null||typeof t=="boolean"?t:typeof t=="number"?Number.isFinite(t)&&Number.isInteger(t)?`<int:${String(Math.abs(t)).length}>`:"<num>":typeof t=="string"?J(t):Array.isArray(t)?`<arr:${t.length}>`:typeof t=="object"?`<obj:${Object.keys(t).length}>`:`<${typeof t}>`}function me(t){return t===null?"null":Array.isArray(t)?"array":typeof t}function dt(t,e=0){let n=Math.max(0,Math.min(e,t.length));return t.slice(0,n)+t.slice(n).replace(/[0-9]/g,"9").replace(/[A-Za-zÀ-ɏ]/g,"a")}function Yt(t,e=0,n=0){let r=Math.max(0,e),o=Math.max(0,n);return r+o>=t.length?"*".repeat(t.length):t.slice(0,r)+"*".repeat(t.length-r-o)+t.slice(t.length-o)}var mr=/^[A-Za-zÀ-ɏͰ-ϿЀ-ӿ]+(?:['’_.-][A-Za-zÀ-ɏͰ-ϿЀ-ӿ]+)*$/;function Je(t){return t.length<=40&&mr.test(t)}var ie=Symbol("probe.drop"),gr=new Set(["otp","passcode","onetimepassword","onetimecode","securitycode","verificationcode","smscode","pin","cvv","cvc","answer","answers","securityanswer","useranswer","ssn","taxid","tin","socialsecuritynumber","token","accesstoken","idtoken","refreshtoken","sessiontoken","authtoken","bearer","apikey","ticket","codeverifier","secret","samlresponse","samlrequest","wresult","csrf","xsrf","csrftoken","xsrftoken","sessionid","deviceid","publickey","keypair","challenge","credential","assertion"].map(re)),yr=/(password|passwd|token|secret|^otp|otp$|answer|ssn|ticket|cookie|credential)/,br=/^[A-Za-z0-9_-]{16,}$/,ft=3e5,lt=4e3,wr=12,pt=100,Qt=200,kr=new Set(["drop","presence","length","hash"]),ht=/^<[a-z]+(?::[^<>\s]{0,24})?>$/,vr=/<[a-z]+(?::[^<>\s]{0,24})?>/,Sr=/(<[a-z]+(?::[^<>\s]{0,24})?>)/,Er=/(^|[^A-Za-z0-9_%]|%[0-9A-Fa-f]{2})([A-Za-z_][A-Za-z0-9_.-]{0,40})(\s*[:=]\s*|%3D|%3A)((?:(?!%26|%2C|%20|%23|%3B|%7C)[^\s&"',;#<>|])+)/gi;function xe(t){let e=re(t);return gr.has(e)||yr.test(e)}function Ar(t,e){return/^[A-Za-z_$][\w$.:-]{0,63}$/.test(t)&&!/\d{5,}/.test(t)||/^\d{1,4}$/.test(t)?t:`<key${e}:${J(t).replace(/[<>]/g,"")}>`}function Xe(t){return t.split("/").map(e=>{if(e==="")return e;let n=e;try{n=decodeURIComponent(e)}catch{}return Je(n)||/^v\d{1,2}(\.\d{1,2})?$/i.test(n)||/^\d{1,3}$/.test(n)||/^[A-Za-z][A-Za-z0-9_-]{0,40}(\.[A-Za-z0-9_-]{1,40}){0,3}\.[a-z0-9]{1,6}$/i.test(n)&&!/\d{6,}/.test(n)||/^[a-z]+[-_][a-z0-9]{1,3}$/i.test(n)?e:J(n)}).join("/")}var We=class{constructor(e,n){this.rules=e;this.salt=n}ruleFor(e,n,r){for(let o of this.rules)if(this.matches(o,e,n,r))return o}matches(e,n,r,o){if(e.surface!==void 0&&!Pe(e.surface).includes(n.surface)||e.part!==void 0&&e.part!==n.part||e.host!==void 0&&(n.host===void 0||!X(e.host,n.host))||e.path!==void 0&&(n.path===void 0||!X(e.path,n.path)))return!1;if(e.selector!==void 0){if(!n.el)return!1;try{if(!n.el.closest(e.selector))return!1}catch{return!1}}return e.key!==void 0?r===void 0?!1:Pe(e.key).some(s=>Rr(s,r,o!=null?o:r)):!0}method(e,n,r,o=""){var s;switch(n.method){case"drop":return ie;case"presence":return e==null?e:e===""||Array.isArray(e)&&e.length===0?"<empty>":"<set>";case"length":return e==null?e:typeof e=="string"?`<len:${e.length}>`:Array.isArray(e)?`<len:${e.length}>`:typeof e=="object"?`<len:${Object.keys(e).length}>`:`<len:${String(e).length}>`;case"hash":return e==null?e:`<h:${Re(this.salt+(typeof e=="string"?e:JSON.stringify(e)))}>`;case"shape":return typeof e=="string"?dt(e,n.keepPrefix):typeof e=="number"?dt(String(e),n.keepPrefix):typeof e=="object"&&e!==null?this.tree(e,r,"shape",o):e;case"mask":return typeof e=="string"||typeof e=="number"?Yt(String(e),n.keepStart,n.keepEnd):ue(e);case"enum":return e==null||typeof e=="boolean"?e:typeof e=="string"||typeof e=="number"?((s=n.values)!=null?s:[]).includes(String(e))?e:ue(e):ue(e);case"clear":return this.leaf(e,r,o,n);default:return this.leaf(e,r,o,void 0)}}leaf(e,n,r,o){if(typeof e=="string"){if(e.length>ft)return`<len:${e.length}>`;let s=se(e);return s!==void 0&&typeof s=="object"&&s!==null?this.tree(s,n,"values",r,o):/^https?:\/\/\S+$/i.test(e)?this.url(e,n,"values",o):/\s/.test(e.trim())?this.text(e,n,"values",o):o?e:J(e)}return e!==null&&typeof e=="object"?this.tree(e,n,"values",r,o):o?e:ue(e)}keyed(e,n,r,o,s){if(pe(e))return this.method(n,{method:"length"},r);let i=this.ruleFor(r,e,o);return i?this.method(n,i,r,o):xe(e)?this.method(n,{method:"length"},r):re(e)==="code"&&typeof n=="string"&&br.test(n)?this.method(n,{method:"length"},r):this.leaf(n,r,o,s)}tree(e,n,r,o="",s,i=0){var a;if(i>wr)return"<deep>";if(Array.isArray(e)){let u=(a=o.split(".").pop())!=null?a:"",c=[];for(let f of e.slice(0,pt)){let d=f!==null&&typeof f=="object"?this.tree(f,n,r,o,s,i+1):this.scalar(u,f,n,r,o,s);d!==ie&&c.push(d)}return e.length>pt&&c.push(`<more:${e.length-pt}>`),c}if(le(e)){let u={},c=typeof e.type=="string"&&"value"in e?e.type:void 0,f=0;for(let[d,l]of Object.entries(e)){if(f>=Qt){u["<more>"]=Object.keys(e).length-Qt;break}let p=c!==void 0&&d==="value"?c:d,y=o?`${o}.${p}`:p,k,R=r==="values"?this.hasKeyRule(p,n,y):!!this.restrictiveRule(p,n,y,r);l!==null&&typeof l=="object"&&!R?k=pe(p)?this.method(l,{method:"length"},n):this.tree(l,n,r,y,s,i+1):k=this.scalar(p,l,n,r,y,s),k!==ie&&(u[Ar(d,f)]=k),f++}return u}return this.scalar("",e,n,r,o,s)}hasKeyRule(e,n,r){var o;return pe(e)||xe(e)||((o=this.ruleFor(n,e,r))==null?void 0:o.key)!==void 0}restrictiveRule(e,n,r,o){if(!e)return;let s=this.ruleFor(n,e,r);if(!(!s||s.key===void 0))return s.method==="drop"||o==="shape"&&kr.has(s.method)?s:void 0}scalar(e,n,r,o,s,i){if(o!=="values"){let u=this.restrictiveRule(e,r,s,o);if(u)return this.method(n,u,r,s)}if(o==="inventory")return me(n);if(o==="shape"){if(e&&(pe(e)||xe(e)))return this.method(n,{method:"length"},r);if(typeof n=="string"){let u=n.length<=ft?se(n):void 0;if(u!==void 0&&typeof u=="object"&&u!==null)return this.tree(u,r,"shape",s)}return ue(n)}if(e)return this.keyed(e,n,r,s,i);let a=this.ruleFor(r);return a?this.method(n,a,r,s):this.leaf(n,r,s,i)}text(e,n,r,o){if(r==="inventory"||r==="shape")return J(e);if(!o){let i=this.ruleFor(n);if(i){if(i.method==="class")return J(e);let a=this.method(e,i,n);if(a===ie)return"";if(i.method!=="clear")return typeof a=="string"?a:JSON.stringify(a);o=i}}let s=ct(e).replace(Er,(i,a,u,c,f)=>{if(ht.test(f))return i;let d;if(pe(u))d=`<redacted:${f.length}>`;else{let l=this.ruleFor(n,u,u);l&&l.key!==void 0?d=this.method(f,l,n,u):xe(u)&&(d=`<redacted:${f.length}>`)}return d===void 0?i:`${a}${u}${c}${d===ie?"<dropped>":String(d)}`});return o?s:s.replace(/\S+/g,i=>this.token(i,n))}token(e,n,r=0){var u,c,f,d;if(ht.test(e))return e;if(vr.test(e))return e.split(Sr).map((l,p)=>p%2===1||l===""?l:this.token(l,n,r)).join("");let o=(c=(u=/^[([{"'“‘|<]+/.exec(e))==null?void 0:u[0])!=null?c:"",s=(d=(f=/[)\]}"'”’,.;:=!?|>/]+$/.exec(e.slice(o.length)))==null?void 0:f[0])!=null?d:"",i=e.slice(o.length,e.length-s.length);if(i===""||ht.test(i)||Je(i)||/^\d{1,3}$/.test(i))return e;if(/^https?:\/\//i.test(i))return o+this.url(i,n,"values")+s;let a=r===0?/[:=]/.exec(i):null;if(a&&a.index>0&&a.index<i.length-1){let l=i.slice(0,a.index),p=i.slice(a.index+1);return o+this.token(l,n,1)+a[0]+this.token(p,n,1)+s}return o+J(i)+s}url(e,n,r,o){var f;let s;try{s=new URL(e,typeof location!="undefined"?location.href:void 0)}catch{return r==="inventory"?"<url>":J(e)}let i={...n,host:s.hostname,path:s.pathname,part:(f=n.part)!=null?f:"url"},a=`${s.protocol}//${s.host}${Xe(s.pathname)}`;if(r==="inventory")return a;let u=d=>{let l=[];return new URLSearchParams(d).forEach((p,y)=>{if(l.length>=60)return;let k=/^[\w.[\]-]{1,64}$/.test(y)?y:J(y),R;if(r==="shape"){let x=this.restrictiveRule(y,i,y,r);R=x?this.method(p,x,i,y):pe(y)||xe(y)?`<len:${p.length}>`:ue(p)}else R=this.keyed(y,p,i,y,o);R!==ie&&l.push(`${k}=${typeof R=="string"?R:JSON.stringify(R)}`)}),l.join("&")};s.search.length>1&&(a+=`?${u(s.search.slice(1))}`);let c=s.hash.slice(1);if(c)if(c.startsWith("/")){let d=c.indexOf("?");a+=`#${Xe(d<0?c:c.slice(0,d))}${d<0?"":`?${u(c.slice(d+1))}`}`}else c.includes("=")?a+=`#${u(c)}`:a+=`#${Je(c)?c:J(c)}`;return a}body(e,n,r){try{if(e==null)return;if(r==="inventory")return{type:me(e)};if(typeof e=="string"){if(e.length>ft)return{len:e.length,skipped:"size"};let o=se(e);if(o!==void 0)return this.tree(o,n,r);if(Pr(e))return{form:this.tree(en(new URLSearchParams(e)),n,r)};if(r==="shape")return{text:J(e)};let s=e.length>lt?e.slice(0,lt):e,i=Tr(s),a=/^\s*</.test(i)?i.replace(/</g," <").replace(/>/g,"> "):i;return{text:this.text(a,n,r).trim(),...e.length>lt?{len:e.length}:{}}}if(typeof URLSearchParams!="undefined"&&e instanceof URLSearchParams)return{form:this.tree(en(e),n,r)};if(typeof FormData!="undefined"&&e instanceof FormData){let o={};return e.forEach((s,i)=>{o[i]=typeof s=="string"?s:`<file:${s.size}>`}),{formData:this.tree(o,n,r)}}return typeof Blob!="undefined"&&e instanceof Blob?{blob:e.size}:typeof ArrayBuffer!="undefined"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))?{bytes:e.byteLength}:typeof e=="object"?this.tree(e,n,r):this.scalar("",e,n,r,"")}catch{return{error:"redact-failed"}}}};function Rr(t,e,n){return t.includes(".")?X(t,n)||X(`*.${t}`,n):t.includes("*")||t.includes("?")?X(t,e):re(t)===re(e)}function Pr(t){return/^[^\s<>{}=&]+=[^\s<>]*(&[^\s<>{}=&]+=[^\s<>]*)*$/.test(t.trim())}function en(t){let e={};return t.forEach((n,r)=>{r in e?e[r]=[].concat(e[r],n):e[r]=n}),e}function Tr(t){let e=n=>pe(n)||xe(n);return t.replace(/(<input\b[^>]*\bname\s*=\s*["']?([\w.-]+)["']?[^>]*\bvalue\s*=\s*)(["'])([^"'>]*)\3/gi,(n,r,o,s,i)=>e(o)?`${r}${s}<redacted:${i.length}>${s}`:n).replace(/(<input\b[^>]*\bvalue\s*=\s*)(["'])([^"'>]*)\2([^>]*\bname\s*=\s*["']?([\w.-]+)["']?)/gi,(n,r,o,s,i,a)=>e(a)?`${r}${o}<redacted:${s.length}>${o}${i}`:n)}var $r={enum:["off","inventory","shape","values"]},xr={enum:["drop","presence","length","class","shape","hash","mask","enum","clear"]},te={type:"array",items:{type:"string",minLength:1,maxLength:200},maxItems:100},Le={anyOf:[{type:"string",minLength:1,maxLength:200},te]},tn={type:"object",maxProperties:20,additionalProperties:{anyOf:[{type:"string",maxLength:200},te]}},gt={values:te,keepPrefix:{type:"integer",minimum:0,maximum:64},keepStart:{type:"integer",minimum:0,maximum:64},keepEnd:{type:"integer",minimum:0,maximum:64}},G=(t={})=>({anyOf:[{$ref:"#/$defs/level"},{type:"object",required:["level"],additionalProperties:!1,properties:{level:{$ref:"#/$defs/level"},...t}}]}),Lr=["page","ui","act","nav","res","store","net","form","err","console","dl","msg","glob","cev"],ve={type:"string",minLength:1,maxLength:200,pattern:"^[^\\s]+$"},mt={type:"object",required:["path"],additionalProperties:!1,properties:{path:ve,as:{type:"string",minLength:1,maxLength:64},method:{$ref:"#/$defs/method"},...gt}},yt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://corbado.com/schemas/autocapture/probe-config-v1.json",title:"Corbado autocapture probe config (v1)",type:"object",required:["v"],additionalProperties:!1,properties:{v:{const:1},name:{type:"string",maxLength:120},when:{$ref:"#/$defs/when"},trigger:{$ref:"#/$defs/trigger"},surfaces:{type:"object",additionalProperties:!1,properties:{page:G(),ui:G({maxViews:{type:"integer",minimum:1,maximum:100}}),act:G(),nav:G(),res:G({hosts:te,everyMs:{type:"integer",minimum:1e3,maximum:6e5}}),store:G(),net:G({hosts:te,excludeHosts:te,paths:te,methods:{type:"array",items:{type:"string",pattern:"^[A-Z]{3,10}$"},maxItems:10},bodies:{type:"boolean"}}),form:G(),err:G(),console:G({levels:{type:"array",items:{enum:["error","warn","info","log","debug"]},maxItems:5}}),dl:G(),msg:G(),glob:G(),cev:G()}},rules:{type:"array",maxItems:200,items:{$ref:"#/$defs/rule"}},actions:{type:"array",maxItems:50,items:{$ref:"#/$defs/action"}},budgets:{type:"object",additionalProperties:!1,properties:{items:{type:"integer",minimum:1,maximum:2e3},bytes:{type:"integer",minimum:1e3,maximum:2e6},perKind:{type:"object",maxProperties:40,additionalProperties:{type:"integer",minimum:0,maximum:2e3}}}}},$defs:{level:$r,method:xr,surfaceName:{enum:Lr},when:{type:"object",additionalProperties:!1,properties:{projects:te,until:{type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}([T ].+)?$"},sample:{type:"number",minimum:0,maximum:1},browser:{type:"array",items:{enum:["chrome","edge","safari","firefox","samsung","opera","other"]}},os:{type:"array",items:{enum:["windows","macos","ios","android","linux","chromeos","other"]}},device:{type:"array",items:{enum:["desktop","mobile","tablet"]}},path:te,state:te,tags:{type:"object",maxProperties:10,additionalProperties:te},integrationVersion:te}},netMatch:{type:"object",additionalProperties:!1,properties:{host:Le,path:Le,method:Le,status:{anyOf:[{enum:["ok","error"]},{type:"array",items:{type:"integer",minimum:0,maximum:999}}]},body:tn,response:tn}},match:{type:"object",additionalProperties:!1,minProperties:1,properties:{net:{$ref:"#/$defs/netMatch"},selector:{type:"string",minLength:1,maxLength:300},click:{type:"string",minLength:1,maxLength:300},submit:{anyOf:[{const:!0},{type:"string",minLength:1,maxLength:300}]},signal:{type:"string",minLength:1,maxLength:64},state:{type:"string",minLength:1,maxLength:64},error:{const:!0}}},trigger:{type:"object",required:["on"],additionalProperties:!1,properties:{on:{type:"array",minItems:1,maxItems:20,items:{$ref:"#/$defs/match"}},buffer:{type:"integer",minimum:1,maximum:2e3},bufferBytes:{type:"integer",minimum:1e3,maximum:2e6},streamMs:{type:"integer",minimum:0,maximum:36e5}}},rule:{type:"object",required:["method"],additionalProperties:!1,properties:{surface:{anyOf:[{$ref:"#/$defs/surfaceName"},{type:"array",items:{$ref:"#/$defs/surfaceName"}}]},host:Le,path:Le,key:Le,selector:{type:"string",minLength:1,maxLength:300},part:{enum:["url","request","response"]},method:{$ref:"#/$defs/method"},...gt}},action:{oneOf:[{type:"object",required:["type","name","on"],additionalProperties:!1,properties:{type:{const:"snapshot"},name:{type:"string",pattern:"^[A-Za-z0-9_.-]{1,64}$"},on:{$ref:"#/$defs/match"},fields:{type:"array",maxItems:30,items:{type:"object",required:["selector"],additionalProperties:!1,properties:{selector:{type:"string",minLength:1,maxLength:300},as:{type:"string",minLength:1,maxLength:64},method:{$ref:"#/$defs/method"},...gt}}},texts:{type:"array",maxItems:20,items:{type:"string",minLength:1,maxLength:300}},request:{type:"array",maxItems:30,items:mt},response:{type:"array",maxItems:30,items:mt},max:{type:"integer",minimum:1,maximum:200}}},{type:"object",required:["type","name","learn","resolve"],additionalProperties:!1,properties:{type:{const:"correlate"},name:{type:"string",pattern:"^[A-Za-z0-9_.-]{1,64}$"},kind:{type:"string",pattern:"^[a-z][a-z0-9_-]{0,31}$"},learn:{type:"object",required:["net","items","key","value"],additionalProperties:!1,properties:{net:{$ref:"#/$defs/netMatch"},from:{enum:["request","response"]},items:ve,key:ve,value:ve,method:{$ref:"#/$defs/method"},values:te,count:{type:"array",maxItems:10,items:ve}}},resolve:{type:"object",required:["net","key"],additionalProperties:!1,properties:{net:{$ref:"#/$defs/netMatch"},from:{enum:["request","response"]},key:{anyOf:[ve,{type:"array",minItems:1,maxItems:10,items:ve}]},fields:{type:"array",maxItems:20,items:mt}}},max:{type:"integer",minimum:1,maximum:500}}},{type:"object",required:["type","name","on"],additionalProperties:!1,properties:{type:{const:"count"},name:{type:"string",pattern:"^[A-Za-z0-9_.-]{1,64}$"},on:{$ref:"#/$defs/match"}}}]}}},nn=yt;function Mr(t){var n;let e=t.replace(/^#\/\$defs\//,"");return(n=yt.$defs[e])!=null?n:{}}function Or(t,e){switch(t){case"object":return!!e&&typeof e=="object"&&!Array.isArray(e);case"array":return Array.isArray(e);case"string":return typeof e=="string";case"integer":return typeof e=="number"&&Number.isInteger(e);case"number":return typeof e=="number"&&Number.isFinite(e);case"boolean":return typeof e=="boolean";default:return!1}}function Se(t,e,n,r){var o,s;if(!(r.length>50)){if(typeof t.$ref=="string")return Se(Mr(t.$ref),e,n,r);if(Array.isArray(t.anyOf)){for(let i of t.anyOf){let a=[];if(Se(i,e,n,a),a.length===0)return}r.push(`${n}: does not match any allowed form`);return}if(Array.isArray(t.oneOf)){let i=t.oneOf,a=e&&typeof e=="object"?e.type:void 0,u=i.find(c=>{var f,d;return((d=(f=c.properties)==null?void 0:f.type)==null?void 0:d.const)===a});if(!u){let c=i.map(f=>f.properties.type.const).join(", ");r.push(`${n}.type: must be one of ${c}`);return}return Se(u,e,n,r)}if("const"in t&&e!==t.const){r.push(`${n}: must be ${JSON.stringify(t.const)}`);return}if(Array.isArray(t.enum)&&!t.enum.includes(e)){r.push(`${n}: must be one of ${t.enum.join(", ")}`);return}if(typeof t.type=="string"&&!Or(t.type,e)){r.push(`${n}: must be ${t.type}`);return}if(typeof e=="string"&&(typeof t.minLength=="number"&&e.length<t.minLength&&r.push(`${n}: too short`),typeof t.maxLength=="number"&&e.length>t.maxLength&&r.push(`${n}: too long`),typeof t.pattern=="string"&&!new RegExp(t.pattern).test(e)&&r.push(`${n}: invalid format`)),typeof e=="number"&&(typeof t.minimum=="number"&&e<t.minimum&&r.push(`${n}: must be \u2265 ${t.minimum}`),typeof t.maximum=="number"&&e>t.maximum&&r.push(`${n}: must be \u2264 ${t.maximum}`)),Array.isArray(e)&&(typeof t.minItems=="number"&&e.length<t.minItems&&r.push(`${n}: too few items`),typeof t.maxItems=="number"&&e.length>t.maxItems&&r.push(`${n}: too many items`),t.items&&e.forEach((i,a)=>Se(t.items,i,`${n}[${a}]`,r))),e&&typeof e=="object"&&!Array.isArray(e)){let i=e,a=(o=t.properties)!=null?o:{},u=Object.keys(i);typeof t.minProperties=="number"&&u.length<t.minProperties&&r.push(`${n}: must not be empty`),typeof t.maxProperties=="number"&&u.length>t.maxProperties&&r.push(`${n}: too many properties`);for(let c of(s=t.required)!=null?s:[])c in i||r.push(`${n}.${c}: required`);for(let c of u)a[c]?Se(a[c],i[c],`${n}.${c}`,r):t.additionalProperties===!1?r.push(`${n}.${c}: unknown property`):t.additionalProperties&&typeof t.additionalProperties=="object"&&Se(t.additionalProperties,i[c],`${n}.${c}`,r)}}}function Cr(t){if(typeof document=="undefined")return!1;try{return document.createDocumentFragment().querySelector(t),!1}catch{return!0}}function Ir(t,e){var i,a,u,c,f;let n=(i=t.when)==null?void 0:i.until;n!==void 0&&!Number.isFinite(Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(n)?`${n}T00:00:00Z`:n))&&e.push("$.when.until: not a valid date");let r=[];((a=t.rules)!=null?a:[]).forEach((d,l)=>{var p;r.push([`$.rules[${l}].selector`,d.selector]),d.method==="enum"&&!((p=d.values)!=null&&p.length)&&e.push(`$.rules[${l}].values: required for method enum`)});let o=[];((c=(u=t.trigger)==null?void 0:u.on)!=null?c:[]).forEach((d,l)=>o.push([`$.trigger.on[${l}]`,d]));let s=new Set;((f=t.actions)!=null?f:[]).forEach((d,l)=>{var y,k;let p=`${d.type}:${d.name}`;s.has(p)&&e.push(`$.actions[${l}].name: duplicate ${d.type} name`),s.add(p),(d.type==="snapshot"||d.type==="count")&&o.push([`$.actions[${l}].on`,d.on]),d.type==="snapshot"&&(((y=d.fields)!=null?y:[]).forEach((R,x)=>r.push([`$.actions[${l}].fields[${x}].selector`,R.selector])),((k=d.texts)!=null?k:[]).forEach((R,x)=>r.push([`$.actions[${l}].texts[${x}]`,R])))});for(let[d,l]of o)l&&(r.push([`${d}.selector`,l.selector],[`${d}.click`,l.click]),typeof l.submit=="string"&&r.push([`${d}.submit`,l.submit]));for(let[d,l]of r)l!==void 0&&Cr(l)&&e.push(`${d}: invalid CSS selector`)}function Ze(t){let e=[];try{Se(yt,t,"$",e),e.length===0&&Ir(t,e)}catch(n){e.push(`$: validation failed (${String(n)})`)}return{ok:e.length===0,errors:e}}function Ge(t){try{return Re(jt(t)).slice(0,16)}catch{return"invalid"}}var ce=()=>{},bt=/(^|\.)corbado\.(io|com|cloud)$/i,Ne=t=>{let e=t;return()=>e-- >0};function sn(t){var n,r;let e=t.level("page");if(e!=="off")try{let o=(r=(n=performance.getEntriesByType)==null?void 0:n.call(performance,"navigation"))==null?void 0:r[0],s=t.scope("page");t.emit("page",{url:t.redactor.url(location.href,s,e),ref:document.referrer?t.redactor.url(document.referrer,s,e==="values"?"values":"inventory"):"",title:e==="inventory"?void 0:t.redactor.text(document.title,s,e),nav:o?{type:o.type,redirects:o.redirectCount,status:o.responseStatus,ttfb:Math.round(o.responseStart),dcl:Math.round(o.domContentLoadedEventEnd),size:o.transferSize}:void 0,vw:typeof innerWidth=="number"?innerWidth:void 0,vh:typeof innerHeight=="number"?innerHeight:void 0,lang:typeof navigator!="undefined"?navigator.language:void 0,tz:Intl.DateTimeFormat().resolvedOptions().timeZone})}catch{}}function an(t,e,n){let r=t.level("res");if(r==="off")return{flush:ce,dispose:ce};let o=0,s=()=>{var a;try{let u=(a=performance.getEntriesByType)==null?void 0:a.call(performance,"resource");if(!u||u.length<=o)return;let c=u.slice(o);o=u.length;let f=c.filter(d=>{try{let l=new URL(d.name).hostname;return!bt.test(l)&&(!e||X(e,l))}catch{return!e}}).map(d=>[t.redactor.url(d.name,t.scope("res"),r),d.initiatorType,Math.round(d.startTime),Math.round(d.duration),d.transferSize,d.responseStatus]);for(let d=0;d<f.length;d+=40)t.emit("res",{rows:f.slice(d,d+40)})}catch{}},i=setInterval(s,Math.max(1e3,n));return{flush:s,dispose:()=>clearInterval(i)}}function un(t){let e=t.level("store");if(e!=="off")try{let n=t.scope("store"),r=s=>{var i;try{if(!s)return[];let a=Array.from({length:Math.min(s.length,200)},(c,f)=>{var d;return(d=s.key(f))!=null?d:""});if(e==="inventory")return a;let u={};for(let c of a){let f=(i=s.getItem(c))!=null?i:"";if(e==="shape"){let d=se(f);u[c]=d!==void 0?t.redactor.tree(d,n,"shape"):ue(f)}else{let d=t.redactor.tree({[c]:f},n,"values");c in d&&(u[c]=d[c])}}return u}catch{return["<blocked>"]}},o=[];try{o=document.cookie.split(";").map(s=>{var i;return((i=s.split("=")[0])!=null?i:"").trim()}).filter(Boolean).slice(0,100)}catch{}t.emit("store",{ls:r(rn("localStorage")),ss:r(rn("sessionStorage")),ck:o})}catch{}}function rn(t){try{return window[t]}catch{return}}function cn(t){let e=t.level("form");if(e!=="off")try{let n=Array.from(document.forms).slice(0,10).map(r=>({id:Z(r),name:r.getAttribute("name")||void 0,action:t.redactor.url(Ie(r),t.scope("form",r),e),method:Ue(r),fields:Array.from(r.elements).slice(0,40).map(o=>{let s=o,i=s.getAttribute("name")||Z(s)||"";if(!i||s.type==="submit"||s.type==="button")return;if(e==="inventory")return[i,s.type];let a=t.scope("form",o),u=t.redactor.ruleFor(a,i,i);if((u==null?void 0:u.method)==="drop")return;let f=ze(o,e==="values"&&u?u:{method:"class"},(d,l)=>{let p=t.redactor.method(d,l,a,i);return p===ie?void 0:p});return[i,s.type,f]}).filter(Boolean)}));n.length&&t.emit("form",{forms:n})}catch{}}function dn(t){let e=t.level("err"),n=Ne(50),r=()=>t.scope("err"),o=u=>typeof u=="string"?e==="values"?t.redactor.text(u.slice(0,500),r(),"values"):J(u):void 0,s=u=>typeof u=="string"&&e==="values"?u.split(`
1
+ "use strict";var De=Object.defineProperty;var An=Object.getOwnPropertyDescriptor;var Rn=Object.getOwnPropertyNames;var Pn=Object.prototype.hasOwnProperty;var Tn=(t,e,n)=>e in t?De(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var $n=(t,e)=>{for(var n in e)De(t,n,{get:e[n],enumerable:!0})},xn=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Rn(e))!Pn.call(t,o)&&o!==n&&De(t,o,{get:()=>e[o],enumerable:!(r=An(e,o))||r.enumerable});return t};var Ln=t=>xn(De({},"__esModule",{value:!0}),t);var M=(t,e,n)=>Tn(t,typeof e!="symbol"?e+"":e,n);var ro={};$n(ro,{ProbeTaint:()=>ke,applyGuards:()=>Fe,createProbeTaint:()=>Ft,probeConfigHash:()=>Ge,probeConfigSchema:()=>nn,startProbes:()=>Sn,validateProbeConfig:()=>Ze});module.exports=Ln(ro);var Mn={log:()=>{}};function ye(t){return t?{log:(...e)=>{try{let n=t.log(...e);if(n&&(typeof n=="object"||typeof n=="function"))try{Promise.resolve(n).catch(()=>{})}catch{}}catch{}}}:Mn}var Rt=Symbol.for("corbado.autocapture.installed");function be(t){try{return typeof t=="function"&&Object.prototype.hasOwnProperty.call(t,Rt)}catch{return!1}}function we(t,e){var r,o;let n=e;try{Object.defineProperty(t,Rt,{value:e,configurable:!0})}catch{}try{Object.defineProperty(t,"name",{value:(r=n.name)!=null?r:"",configurable:!0})}catch{}try{Object.defineProperty(t,"length",{value:(o=n.length)!=null?o:0,configurable:!0})}catch{}return t}function oe(){return{mode:"unavailable",disconnect:()=>{}}}function tt(t,e){return!!t&&"value"in t&&"value"in e&&t.value===e.value&&t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable}function Ee(t,e,n,r,o,s=String(e)){try{let i=Object.getOwnPropertyDescriptor(t,e);tt(i,{...r,value:n})&&Object.defineProperty(t,e,r)}catch(i){o.log(`${s} restoration skipped`,i)}}function Ce(t,e,n){let r=ye(t);return o=>{try{let s=n(o);if(s&&(typeof s=="object"||typeof s=="function"))try{Promise.resolve(s).catch(i=>r.log(`${e} listener failed`,i))}catch(i){r.log(`${e} listener failed`,i)}}catch(s){r.log(`${e} listener failed`,s)}}}function $t(t){let e=t.onNavigate;if(typeof e!="function")throw new TypeError("captureNavigation requires an onNavigate callback");let n=ye(t.logger),r,o,s,i,a,u;try{if(r=window,o=r==null?void 0:r.history,!r||!o)return n.log("navigation capture unavailable: window/history missing"),oe();if(a=Pt(o,"pushState"),u=Pt(o,"replaceState"),!a||!u)return n.log("navigation capture unavailable: history method descriptors missing"),oe();if(s=a.descriptor.value,i=u.descriptor.value,typeof s!="function"||typeof i!="function")return n.log("navigation capture unavailable: history methods missing"),oe();if(typeof r.addEventListener!="function"||typeof r.removeEventListener!="function")return n.log("navigation capture unavailable: window event methods missing"),oe()}catch(T){return n.log("navigation capture unavailable: history inspection failed",T),oe()}if(be(s)||be(i))return n.log("navigation capture unavailable: an equivalent capture is already active"),oe();let c=!1,f=()=>({path:r.location.pathname,search:r.location.search,hash:r.location.hash}),d;try{d=f()}catch(T){return n.log("navigation capture unavailable: location inspection failed",T),oe()}let l=Ce(n,"navigation",T=>{if(c)return e(T)}),p=T=>{if(c)try{let U=f();if(U.path===d.path&&U.search===d.search&&U.hash===d.hash)return;d=U,l({...U,source:T})}catch(U){n.log("navigation observation failed",U)}},y={pushState(...T){let U=Reflect.apply(s,this,T);return p("push"),U}}.pushState,k={replaceState(...T){let U=Reflect.apply(i,this,T);return p("replace"),U}}.replaceState;we(y,s),we(k,i);let R=()=>p("pop"),x=()=>p("hash");try{if(Tt(a,y),Tt(u,k),o.pushState!==y||o.replaceState!==k)throw new Error("history method replacement did not take effect");r.addEventListener("popstate",R),r.addEventListener("hashchange",x),c=!0}catch(T){return c=!1,Be(r,"popstate",R,n),Be(r,"hashchange",x,n),He(u,k,n),He(a,y,n),n.log("navigation capture unavailable: history methods are not writable",T),e=()=>{},l=()=>{},n=ye(),oe()}return{mode:"standard",disconnect:()=>{c=!1,e=()=>{},Be(r,"popstate",R,n),Be(r,"hashchange",x,n),He(a,y,n),He(u,k,n),l=()=>{},n=ye()}}}function Pt(t,e){let n=t;for(;n;){let r=Object.getOwnPropertyDescriptor(n,e);if(r)return!("value"in r)||typeof r.value!="function"?null:{owner:n,key:e,descriptor:r};n=Object.getPrototypeOf(n)}return null}function Tt(t,e){if(t.descriptor.writable!==!0)throw new TypeError(`${t.key} is not writable`);let n=Object.getOwnPropertyDescriptor(t.owner,t.key);if(!tt(n,t.descriptor))throw new Error(`${t.key} changed during installation`);Object.defineProperty(t.owner,t.key,{...t.descriptor,value:e})}function He(t,e,n){Ee(t.owner,t.key,e,t.descriptor,n,`navigation ${t.key}`)}function Be(t,e,n,r){try{t.removeEventListener(e,n)}catch(o){r.log(`navigation ${e} listener removal skipped`,o)}}var xt=0;function Lt(){return xt+=1,`network-${xt}`}function On(t,e){let n=t.responseType;if(n===""||n==="text")return e(t.responseText);if(n==="json"){let r=t.response;return r==null?void 0:e(r)}}var Cn=500,Mt=Symbol("body-read-timeout");function Ot(t){return/event-stream|octet-stream/i.test(t)?!1:/json|text|urlencoded/i.test(t)}async function Ct(t,e){let n=t.body;if(!n)return;let r=n.getReader(),o;try{let s=new Promise(u=>{o=setTimeout(()=>u(Mt),Cn)}),i=new TextDecoder,a=[];for(;;){let u=await Promise.race([r.read(),s]);if(u===Mt){e.log("body omitted: read timed out"),r.cancel().catch(()=>{});return}if(u.done)break;a.push(i.decode(u.value,{stream:!0}))}return a.push(i.decode()),a.join("")}catch{r.cancel().catch(()=>{});return}finally{o!==void 0&&clearTimeout(o)}}function nt(t){var e;(e=t==null?void 0:t.body)==null||e.cancel().catch(()=>{})}function It(t){var T,U,F;let{onExchange:e,onRequest:n,match:r}=t;if(typeof e!="function"||typeof r!="function")throw new TypeError("captureNetwork requires onExchange and match callbacks");let o=ye(t.logger),s=(T=t.transports)!=null?T:["xhr","fetch"],i=(U=t.bodyCapture)==null?void 0:U.request,a=(F=t.bodyCapture)==null?void 0:F.response,u=typeof i=="function",c=typeof a=="function",f=!1,d=Ce(o,"network",E=>{if(f)return e(E)}),l=Ce(o,"network request",E=>{if(f)return n==null?void 0:n(E)}),p=(E,I,$)=>{if(typeof $=="function")try{return $(E,I)}catch(C){o.log("body projection failed",C);return}},y=(E,I)=>{try{let $=typeof document!="undefined"?document.baseURI:void 0,C=new URL(String(E),$);return r(C,I)===!0?{url:C.href,path:C.pathname}:void 0}catch{return}},k=()=>{if(typeof XMLHttpRequest=="undefined")return o.log("xhr capture unavailable: XMLHttpRequest missing"),null;let E=XMLHttpRequest.prototype,I=Object.getOwnPropertyDescriptor(E,"open"),$=Object.getOwnPropertyDescriptor(E,"send");if(!I||!("value"in I)||typeof I.value!="function"||!$||!("value"in $)||typeof $.value!="function")return o.log("xhr capture unavailable: XMLHttpRequest methods missing"),null;let C=I.value,q=$.value;if(be(C)||be(q))return o.log("xhr capture unavailable: an equivalent capture is already active"),null;let V=new WeakMap,P=new Set,D=!1,_={open(...H){var N;let b=Reflect.apply(C,this,H);if(!f||!D)return b;try{let h=V.get(this);h&&(h.reported=!0,(N=h.cleanupListeners)==null||N.call(h));let m=String(H[0]).toUpperCase(),g=y(H[1],m);g?V.set(this,{method:m,url:g.url,path:g.path,reported:!1}):V.delete(this)}catch(h){o.log("xhr open observation failed",h)}return b}}.open,Y={send(...H){let b=f&&D?V.get(this):void 0;if(!b||b.reported||b.cleanupListeners)return Reflect.apply(q,this,H);let N=()=>{},h=!1;try{b.requestId=Lt();let g={direction:"request",transport:"xhr",method:b.method,url:b.url,path:b.path};b.requestBody=u&&typeof H[0]=="string"?p(H[0],g,i):void 0;let A=()=>{b.outcome===void 0&&(b.outcome="abort")},L=()=>{b.outcome===void 0&&(b.outcome="timeout")},v=()=>{b.outcome===void 0&&(b.outcome="error")},S=()=>{var Q;N();try{if(!f||!D||b.reported||!b.requestId)return;b.reported=!0;let w={direction:"response",transport:"xhr",method:b.method,url:b.url,path:b.path},W=this.status,K={requestId:b.requestId,transport:"xhr",method:b.method,url:b.url,path:b.path,status:W,ok:W>=200&&W<300,outcome:(Q=b.outcome)!=null?Q:"load",durationMs:b.startedAt!==void 0?Date.now()-b.startedAt:void 0,responseUrl:this.responseURL||void 0,requestBody:b.requestBody,responseBody:c?On(this,ge=>p(ge,w,a)):void 0};b.requestEmitted?d(K):b.pendingExchange=K}catch(w){o.log("xhr exchange observation failed",w)}finally{V.get(this)===b&&V.delete(this)}},O=()=>{try{this.readyState===XMLHttpRequest.DONE&&this.status!==0&&S()}catch(Q){o.log("xhr ready-state observation failed",Q)}},z=()=>S();N=()=>{for(let[Q,w]of[["readystatechange",O],["abort",A],["timeout",L],["error",v],["loadend",z]])this.removeEventListener(Q,w);b.cleanupListeners===N&&(b.cleanupListeners=void 0),P.delete(N)},this.addEventListener("readystatechange",O),this.addEventListener("abort",A),this.addEventListener("timeout",L),this.addEventListener("error",v),this.addEventListener("loadend",z),b.cleanupListeners=N,P.add(N),b.startedAt=Date.now(),h=!0}catch(g){o.log("xhr send observation failed",g),N()}let m;try{m=Reflect.apply(q,this,H)}catch(g){throw N(),g}if(h&&b.requestId!==void 0&&b.startedAt!==void 0){b.requestEmitted=!0,l({requestId:b.requestId,transport:"xhr",method:b.method,url:b.url,path:b.path,startedAt:b.startedAt,requestBody:b.requestBody});let g=b.pendingExchange;b.pendingExchange=void 0,g&&d(g)}return m}}.send;return we(_,C),we(Y,q),I.writable!==!0||$.writable!==!0?(o.log("xhr capture unavailable: XMLHttpRequest methods are not writable"),null):(Object.defineProperty(E,"open",{...I,value:_}),Object.defineProperty(E,"send",{...$,value:Y}),D=!0,()=>{D=!1;for(let H of[...P])H();Ee(E,"open",_,I,o),Ee(E,"send",Y,$,o)})},R=()=>{let E=globalThis,I=Object.getOwnPropertyDescriptor(E,"fetch");if(!I||!("value"in I))return o.log("fetch capture unavailable: fetch is not an own data property"),null;let $=I.value;if(typeof $!="function")return o.log("fetch capture unavailable: fetch missing"),null;if(be($))return o.log("fetch capture unavailable: an equivalent capture is already active"),null;let C=!1,q=async(P,D,_,Y)=>{try{if(!f||!C){nt(_);return}let[H,b]=await Promise.all([Y!=null?Y:Promise.resolve(void 0),_?Ct(_,o):Promise.resolve(void 0)]);if(!f||!C)return;let N={direction:"request",transport:"fetch",method:P.method,url:P.url,path:P.path},h={...N,direction:"response"},m=P.requestBody;m===void 0&&H!==void 0&&(m=p(H,N,i));let g=b!==void 0?p(b,h,a):void 0;d({requestId:P.requestId,transport:"fetch",method:P.method,url:P.url,path:P.path,status:D.status,ok:D.ok,outcome:"load",durationMs:Date.now()-P.startedAt,responseUrl:D.url||void 0,requestBody:m,responseBody:g})}catch(H){o.log("fetch exchange observation failed",H)}},V={fetch(...P){var m,g,A,L;let D;try{let v=P[0],S=P[1];if(f&&C&&u&&typeof Request!="undefined"&&v instanceof Request&&(S==null?void 0:S.body)===void 0&&v.body){let O=String((m=S==null?void 0:S.method)!=null?m:v.method).toUpperCase(),z=(g=v.headers.get("content-type"))!=null?g:"";y(v.url,O)&&Ot(z)&&(D=v.clone())}}catch(v){o.log("fetch observation failed",v)}let _,Y=Date.now();try{_=Reflect.apply($,this,P)}catch(v){throw nt(D),v}let H,b;try{if(f&&C){let v=P[0],S=P[1],O=typeof Request!="undefined"&&v instanceof Request,z=String((A=S==null?void 0:S.method)!=null?A:O?v.method:"GET").toUpperCase(),Q=O?v.url:v,w=y(Q,z);w&&(H={requestId:Lt(),method:z,url:w.url,path:w.path,startedAt:Y},b=(L=S==null?void 0:S.signal)!=null?L:O?v.signal:void 0,u&&typeof(S==null?void 0:S.body)=="string"&&(H.requestBody=p(S.body,{direction:"request",transport:"fetch",method:z,url:w.url,path:w.path},i)))}}catch(v){o.log("fetch observation failed",v)}if(!H)return nt(D),_;let N=H;l({requestId:N.requestId,transport:"fetch",method:N.method,url:N.url,path:N.path,startedAt:N.startedAt,requestBody:N.requestBody});let h=D?Ct(D,o):void 0;return _.then(v=>{var O;let S;try{if(f&&C&&c){let z=(O=v.headers.get("content-type"))!=null?O:"";Ot(z)&&v.body&&(S=v.clone())}}catch{}q(N,v,S,h)},v=>{try{if(!f||!C)return;let S=(b==null?void 0:b.aborted)===!0||(v==null?void 0:v.name)==="AbortError"||typeof DOMException!="undefined"&&v instanceof DOMException&&v.code===DOMException.ABORT_ERR;d({requestId:N.requestId,transport:"fetch",method:N.method,url:N.url,path:N.path,status:0,ok:!1,outcome:S?"abort":"error",durationMs:Date.now()-N.startedAt})}catch(S){o.log("fetch failure observation failed",S)}}),_}}.fetch;return we(V,$),I.writable!==!0?(o.log("fetch capture unavailable: fetch is not writable"),null):(Object.defineProperty(E,"fetch",{...I,value:V}),C=!0,()=>{C=!1,Ee(E,"fetch",V,I,o)})},x=[];if(s.includes("xhr")){let E=k();E&&x.push(E)}if(s.includes("fetch")){let E=R();E&&x.push(E)}return x.length===0?oe():(f=!0,{mode:"standard",disconnect:()=>{f=!1;for(let E of x.splice(0))E()}})}var Nt="1.2.0";function Ae(t,e=2166136261){let n=e>>>0;for(let r=0;r<t.length;r++)n^=t.charCodeAt(r),n=Math.imul(n,16777619);return n>>>0}function Re(t){return Ae(t).toString(36).padStart(7,"0")+Ae(t,1540483477).toString(36).padStart(7,"0")}function jt(t){return JSON.stringify(rt(t))}function rt(t){if(Array.isArray(t))return t.map(rt);if(t&&typeof t=="object"){let e={};for(let n of Object.keys(t).sort())e[n]=rt(t[n]);return e}return t}function In(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);r<128?e+=1:r<2048?e+=2:r>=55296&&r<=56319&&n+1<t.length?(e+=4,n++):e+=3}return e}function fe(t){try{let e=JSON.stringify(t);return e===void 0?0:In(e)}catch{return 1/0}}var re=t=>t.toLowerCase().replace(/[-_\s]/g,""),_e=new Map;function Nn(t){let e=_e.get(t);if(!e){let n=t.split("").map(r=>r==="*"?".*":r==="?"?".":r.replace(/[.+^${}()|[\]\\/]/g,"\\$&")).join("");e=new RegExp(`^${n}$`,"i"),_e.size>500&&_e.clear(),_e.set(t,e)}return e}function X(t,e){if(t===void 0)return!0;let n=typeof t=="string"?[t]:t;for(let r of n)if(Nn(r).test(e))return!0;return!1}var Pe=t=>t===void 0?[]:Array.isArray(t)?t:[t];function ot(t){let e=new Uint8Array(t);try{let n=typeof crypto!="undefined"?crypto:void 0;if(n&&typeof n.getRandomValues=="function")return n.getRandomValues(e),e}catch{}for(let n=0;n<t;n++)e[n]=Math.floor(Math.random()*256);return e}var jn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";function st(t){let e=ot(t),n="";for(let r=0;r<t;r++)n+=jn[e[r]&63];return n}function j(t){try{return t()}catch{return}}function se(t){let e=t.trim();if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))try{return JSON.parse(e)}catch{return}}function le(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Z(t){try{return t.getAttribute("id")||void 0}catch{return}}function Ie(t){var n;let e=(n=t.getAttribute("action"))!=null?n:"";try{return new URL(e,document.baseURI).href}catch{return e}}function Ue(t){return(t.getAttribute("method")||"get").toLowerCase()}function qt(t){var u,c,f,d;let e=(u=t==null?void 0:t.userAgent)!=null?u:"",n=t==null?void 0:t.userAgentData,r=((c=n==null?void 0:n.brands)!=null?c:[]).map(l=>l.brand.toLowerCase()),o="other";r.some(l=>l.includes("edge"))?o="edge":r.some(l=>l.includes("opera"))?o="opera":/SamsungBrowser\//.test(e)?o="samsung":/Edg(e|A|iOS)?\//.test(e)?o="edge":/OPR\/|Opera/.test(e)?o="opera":/Firefox\/|FxiOS\//.test(e)?o="firefox":r.some(l=>l.includes("chrome")||l.includes("chromium"))||/Chrome\/|CriOS\//.test(e)?o="chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&(o="safari");let s=((f=n==null?void 0:n.platform)!=null?f:"").toLowerCase(),i="other";s==="android"||/Android/.test(e)?i="android":/iPhone|iPad|iPod/.test(e)||/Macintosh/.test(e)&&((d=t==null?void 0:t.maxTouchPoints)!=null?d:0)>1?i="ios":s==="windows"||/Windows/.test(e)?i="windows":s==="chrome os"||s==="chromeos"||/CrOS/.test(e)?i="chromeos":s==="macos"||/Macintosh|Mac OS X/.test(e)?i="macos":(s==="linux"||/Linux/.test(e))&&(i="linux");let a="desktop";return/iPad|Tablet/.test(e)||i==="android"&&!/Mobile/.test(e)||i==="ios"&&/Macintosh/.test(e)?a="tablet":((n==null?void 0:n.mobile)===!0||/Mobi|iPhone|iPod/.test(e))&&(a="mobile"),{browser:o,os:i,device:a}}function qn(t,e,n){return t===void 0||t>=1?!0:t<=0?!1:(e?Ae(`${n}:${e}`)/4294967296:Math.random())<t}function Dn(t,e){if(!t)return!1;let n=/^\d{4}-\d{2}-\d{2}$/.test(t)?Date.parse(`${t}T23:59:59.999Z`):Date.parse(t);return!Number.isFinite(n)||e>n}function Dt(t,e){var n;if(t){if(t.projects&&!t.projects.includes(e.projectId))return"projects";if(Dn(t.until,e.now))return"until";if(t.browser&&!t.browser.includes(e.client.browser))return"browser";if(t.os&&!t.os.includes(e.client.os))return"os";if(t.device&&!t.device.includes(e.client.device))return"device";if(t.integrationVersion&&!X(t.integrationVersion,(n=e.integrationVersion)!=null?n:""))return"integrationVersion";if(!qn(t.sample,e.sessionId,e.salt))return"sample"}}function Ht(t,e){if(!t)return"match";let n=!1;for(let[r,o]of Object.entries(t)){let s=e==null?void 0:e[r];if(s==null||s===""){n=!0;continue}if(!o.includes("*")&&!o.includes(String(s)))return"mismatch"}return n?"unknown":"match"}var Hn=new Set(["drop","presence","length"]),Bn=/(^|\s)(current-password|new-password|one-time-code|cc-[a-z-]+)(\s|$)/i,_n=/(password|passwd|passcode|^pwd$|^otp|otp$|onetime|^pin$|^cvv|^cvc|^ssn$|securitycode|verificationcode)/;function at(t){try{let e=t.value;return typeof e=="string"?e:""}catch{return""}}function zt(t){var e,n,r;try{let o=t;if(t.tagName==="INPUT"&&(o.type||"").toLowerCase()==="password")return!0;let s=(e=t.getAttribute("autocomplete"))!=null?e:"";if(Bn.test(s))return!0;for(let a of[o.name,t.id])if(a&&_n.test(re(a)))return!0;let i=(n=o.form)!=null?n:t.closest("form");if(i){for(let a of Array.from(i.querySelectorAll("input[autocomplete]")).slice(0,50))if(/(^|\s)webauthn(\s|$)/i.test((r=a.getAttribute("autocomplete"))!=null?r:""))return!0}return!1}catch{return!0}}function ze(t,e,n){let r=zt(t)&&!Hn.has(e.method)?{method:"length"}:e;return n(at(t),r)}function ut(t){return at(t).length}var Bt=6,Un=4096,zn=400,ke=class{constructor(){M(this,"base1");M(this,"base2");M(this,"byLength",new Map);M(this,"order",[]);let e=ot(8),n=r=>(e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3])>>>0;this.base1=(n(0)|65537)>>>0,this.base2=(n(4)|65537)>>>0}get size(){return this.order.length}add(e){if(typeof e!="string"||e.length<Bt||e.length>Un)return;let n=new Set([e]);try{n.add(encodeURIComponent(e))}catch{}try{n.add(new URLSearchParams({v:e}).toString().slice(2))}catch{}n.add(JSON.stringify(e).slice(1,-1));for(let r of n)this.addOne(r)}addOne(e){var o;let n=this.fingerprint(e,0,e.length),r=this.byLength.get(e.length);if(r||this.byLength.set(e.length,r=new Set),!r.has(n))for(r.add(n),this.order.push([e.length,n]);this.order.length>zn;){let[s,i]=this.order.shift();(o=this.byLength.get(s))==null||o.delete(i)}}fingerprint(e,n,r){let o=0,s=0;for(let i=n;i<n+r;i++){let a=e.charCodeAt(i);o=Math.imul(o,this.base1)+a>>>0,s=Math.imul(s,this.base2)+a>>>0}return`${o}:${s}`}scrub(e){if(this.order.length===0||e.length<Bt)return e;let n=[];for(let[i,a]of this.byLength){if(a.size===0||i>e.length)continue;let u=1,c=1;for(let l=0;l<i-1;l++)u=Math.imul(u,this.base1)>>>0,c=Math.imul(c,this.base2)>>>0;let f=0,d=0;for(let l=0;l<i;l++){let p=e.charCodeAt(l);f=Math.imul(f,this.base1)+p>>>0,d=Math.imul(d,this.base2)+p>>>0}for(let l=0;;l++){a.has(`${f}:${d}`)&&n.push([l,l+i]);let p=l+i;if(p>=e.length)break;let y=e.charCodeAt(l),k=e.charCodeAt(p);f=Math.imul(f-Math.imul(y,u)>>>0,this.base1)+k>>>0,d=Math.imul(d-Math.imul(y,c)>>>0,this.base2)+k>>>0}}if(n.length===0)return e;n.sort((i,a)=>i[0]-a[0]||a[1]-i[1]);let r="",o=0,s=0;for(;s<n.length;){let[i,a]=n[s];for(s++;s<n.length&&n[s][0]<a;)a=Math.max(a,n[s][1]),s++;i<o&&(i=o),r+=e.slice(o,i)+`<tainted:${a-i}>`,o=a}return r+e.slice(o)}};function Ft(t=[]){let e=new ke;for(let n of t)e.add(n);return e}var Fn=new Set(["challenge","id","rawId","userHandle","signature","clientDataJSON","authenticatorData","attestationObject","publicKey"].map(re));function Vt(t,e){if(!e||typeof e!="object")return;let n=e;for(let r of["requestOptionsJson","creationOptionsJson","credentialJson"]){let o=n[r];if(typeof o!="string")continue;t.add(o);let s;try{s=JSON.parse(o)}catch{continue}let i=0,a=(u,c,f)=>{if(!(f>8||++i>500)){if(typeof u=="string"){Fn.has(re(c))&&t.add(u);return}if(Array.isArray(u)){for(let d of u.slice(0,50))a(d,c,f+1);return}if(u&&typeof u=="object")for(let[d,l]of Object.entries(u))a(l,d,f+1)}};a(s,"",0)}}function Kt(t,e){if(e)try{let n=Array.from(e.querySelectorAll("input, textarea")).slice(0,200),r=0;for(let o of n){if(r>=30)break;zt(o)&&(r++,t.add(at(o)))}}catch{}}function Jt(t,e){for(let n of e.split(";").slice(0,100)){let r=n.indexOf("=");if(r<0)continue;let o=n.slice(r+1).trim();t.add(o);try{let s=decodeURIComponent(o);s!==o&&t.add(s)}catch{}}}function Xt(t,e){if(typeof e!="string")return;t.add(e);let n=e.trim().split(/\s+/);n.length>1&&t.add(n.slice(1).join(" "))}var Vn=new Set(["password","passwd","pwd","passphrase","clientDataJSON","authenticatorData","signature","attestationObject","userHandle","authorization","proxyAuthorization","cookie","setCookie","privateKey","clientSecret"].map(re));function pe(t){let e=re(t);return Vn.has(e)||e.includes("password")}var Kn=/eyJ0eXBlIjoid2ViYXV0aG4u[A-Za-z0-9_\-+/=]*/gi,Jn=/eyJ[A-Za-z0-9_-]{16,}(?:\.[A-Za-z0-9_-]*){0,4}/gi,Xn=/("|\\")(password|passwd|pwd|clientDataJSON|authenticatorData|signature|attestationObject|userHandle|authorization)\1(\s*:\s*)\1(?!<)((?:(?!\1)[^\\]|\\.)*?)\1/gi,Wn=/(^|[?&;\s,])(password|passwd|pwd)=([^&\s;,]+)/gi,Zn=/\b(Bearer|Basic)\s+([A-Za-z0-9._~+/=-]{8,})/g,Gn=/\b((?:proxy-)?authorization)(\s*[:=]\s*|"\s*:\s*")((?:Bearer|Basic|Digest|Token|Negotiate)\s+)?(?!<)([^\s,;"&]+)/gi;function ct(t){return t.replace(Gn,(e,n,r,o,s)=>`${n}${r}${o!=null?o:""}<redacted:${s.length}>`)}var Yn=/\d(?:[ -]?\d){12,}/g,Qn=/[A-Za-z0-9_\-+/]{24,}={0,2}/g;function er(t){let e=0,n=!1;for(let r=t.length-1;r>=0;r--){let o=t.charCodeAt(r)-48;n&&(o*=2,o>9&&(o-=9)),e+=o,n=!n}return e%10===0}function Wt(t){for(let e=13;e<=Math.min(19,t.length);e++)for(let n=0;n+e<=t.length;n++)if(er(t.slice(n,n+e)))return!0;return!1}function tr(t){var r;let e=new Map;for(let o of t)e.set(o,((r=e.get(o))!=null?r:0)+1);let n=0;for(let o of e.values()){let s=o/t.length;n-=s*Math.log2(s)}return n}function _t(t){return t.length>=24&&/\d/.test(t)&&/[A-Za-z]/.test(t)&&tr(t)>=3}var nr=/^([A-Za-z][a-z]*(?:[-_.][A-Za-z]+)*|v\d{1,2}|\d{1,5}|)$/;function rr(t){if(!t.includes("/"))return!1;let e=t.split("/");return e.filter(r=>nr.test(r)).length*2>=e.length}function or(t){return rr(t)?t.split("/").map(e=>_t(e)?`<tok:${e.length}>`:e).join("/"):_t(t)?`<tok:${t.length}>`:t}function Ut(t,e){let n=e?e.scrub(t):t;return n=ct(n),n=n.replace(Xn,(r,o,s,i,a)=>`${o}${s}${o}${i}${o}<redacted:${a.length}>${o}`),n=n.replace(Wn,(r,o,s,i)=>i.startsWith("<")?r:`${o}${s}=<redacted:${i.length}>`),n=n.replace(Zn,(r,o,s)=>`${o} <redacted:${s.length}>`),n=n.replace(Kn,r=>`<webauthn:${r.length}>`),n=n.replace(Jn,r=>`<jwt:${r.length}>`),n=n.replace(Yn,r=>{let o=r.replace(/[ -]/g,"");return o.length>19?`<digits:${o.length}>`:Wt(o)?`<card:${o.length}>`:r}),n=n.replace(Qn,or),n}function sr(t){if(!Number.isFinite(t))return null;if(!Number.isInteger(t))return t;let e=String(Math.abs(t));return e.length>=13&&Wt(e)?`<card:${e.length}>`:t}function ir(t){return t==null||typeof t=="boolean"?t:typeof t=="string"?ar.test(t)?t:`<redacted:${t.length}>`:typeof t=="number"?"<redacted:num>":"<redacted:obj>"}var ar=/^<[a-z]+(?::[A-Za-z0-9.]{1,12})?>$/,ur=24;function it(t,e,n){if(n>ur)return"<deep>";if(t===null||typeof t=="boolean")return t;if(typeof t=="string")return Ut(t,e);if(typeof t=="number")return sr(t);if(Array.isArray(t))return t.map(r=>{let o=it(r,e,n+1);return o===void 0?null:o});if(typeof t=="object"){let r={};for(let[o,s]of Object.entries(t)){let i=Ut(o,e),a=pe(o)?ir(s):it(s,e,n+1);a!==void 0&&(r[i]=a)}return r}}function Fe(t,e){try{return it(t,e!=null?e:void 0,0)}catch{return}}var Zt=2e3;function Te(t){if(typeof t=="string"&&t.length<=3e5){let e=se(t);if(e!==void 0)return e}return t}function cr(t,e){let n=[Te(t)];for(;n.length&&e.length<Zt;){let r=n.shift();if(r===null||typeof r!="object")continue;Array.isArray(r)||e.push(r);let o=Array.isArray(r)?r:Object.values(r);for(let s of o.slice(0,200)){let i=Te(s);i!==null&&typeof i=="object"&&n.push(i)}}}function Ve(t,e){let n=[Te(t)];for(let r of e.split(".").filter(Boolean)){let o=[];if(r==="**"){for(let u of n)cr(u,o);n=o;continue}let s=r.endsWith("[]"),i=s?r.slice(0,-2):r,a=u=>{let c=i===""?u:le(u)?Te(u[i]):void 0;if(c!==void 0)if(s){if(Array.isArray(c))for(let f of c.slice(0,200))o.push(Te(f))}else o.push(c)};for(let u of n){if(o.length>=Zt)break;if(Array.isArray(u)&&i!=="")for(let c of u.slice(0,200))a(Te(c));else a(u)}n=o}return n}function $e(t,e){return Ve(t,e)[0]}function Ke(t,e){if(!e)return!0;for(let[n,r]of Object.entries(e)){let o=Array.isArray(r)?r:[r];if(!Ve(t,n).some(i=>i!=null&&o.includes(String(i))))return!1}return!0}function Gt(t){return t==null?0:Array.isArray(t)?t.length:typeof t=="object"?Object.keys(t).length:1}var dr=/^[^\s@]{1,64}@[^\s@]+\.[^\s@]{2,}$/,fr=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,lr=/^[a-z][a-z0-9+.-]*:\/\/\S+$/i,pr=/^\d{4}-\d{2}-\d{2}([T ][\d:.]+(Z|[+-]\d{2}:?\d{2})?)?$/,hr=/^\+?[\d\s().-]{7,20}$/;function J(t){if(t==="")return"";let e=t.length;return/^eyJ/i.test(t)&&e>20?`<jwt:${e}>`:dr.test(t)?"<email>":fr.test(t)?"<uuid>":lr.test(t)?"<url>":pr.test(t)?"<date>":/^\d+$/.test(t)?`<digits:${e}>`:hr.test(t)&&/\d{3}/.test(t)?"<phone>":/^(true|false|null|undefined)$/i.test(t)?`<${t.toLowerCase()}>`:/^[A-Za-z]+$/.test(t)?`<alpha:${e}>`:/^[0-9a-f]+$/i.test(t)&&e>=8?`<hex:${e}>`:/^[A-Za-z0-9]+$/.test(t)?`<alnum:${e}>`:/^[A-Za-z0-9_-]+$/.test(t)?`<id:${e}>`:/^[A-Za-z0-9+/]+={0,2}$/.test(t)&&e>=16?`<b64:${e}>`:/\s/.test(t.trim())?`<text:${t.trim().split(/\s+/).length}w>`:`<str:${e}>`}function ue(t){return t==null||typeof t=="boolean"?t:typeof t=="number"?Number.isFinite(t)&&Number.isInteger(t)?`<int:${String(Math.abs(t)).length}>`:"<num>":typeof t=="string"?J(t):Array.isArray(t)?`<arr:${t.length}>`:typeof t=="object"?`<obj:${Object.keys(t).length}>`:`<${typeof t}>`}function me(t){return t===null?"null":Array.isArray(t)?"array":typeof t}function dt(t,e=0){let n=Math.max(0,Math.min(e,t.length));return t.slice(0,n)+t.slice(n).replace(/[0-9]/g,"9").replace(/[A-Za-zÀ-ɏ]/g,"a")}function Yt(t,e=0,n=0){let r=Math.max(0,e),o=Math.max(0,n);return r+o>=t.length?"*".repeat(t.length):t.slice(0,r)+"*".repeat(t.length-r-o)+t.slice(t.length-o)}var mr=/^[A-Za-zÀ-ɏͰ-ϿЀ-ӿ]+(?:['’_.-][A-Za-zÀ-ɏͰ-ϿЀ-ӿ]+)*$/;function Je(t){return t.length<=40&&mr.test(t)}var ie=Symbol("probe.drop"),gr=new Set(["otp","passcode","onetimepassword","onetimecode","securitycode","verificationcode","smscode","pin","cvv","cvc","answer","answers","securityanswer","useranswer","ssn","taxid","tin","socialsecuritynumber","token","accesstoken","idtoken","refreshtoken","sessiontoken","authtoken","bearer","apikey","ticket","codeverifier","secret","samlresponse","samlrequest","wresult","csrf","xsrf","csrftoken","xsrftoken","sessionid","deviceid","publickey","keypair","challenge","credential","assertion"].map(re)),yr=/(password|passwd|token|secret|^otp|otp$|answer|ssn|ticket|cookie|credential)/,br=/^[A-Za-z0-9_-]{16,}$/,ft=3e5,lt=4e3,wr=12,pt=100,Qt=200,kr=new Set(["drop","presence","length","hash"]),ht=/^<[a-z]+(?::[^<>\s]{0,24})?>$/,vr=/<[a-z]+(?::[^<>\s]{0,24})?>/,Sr=/(<[a-z]+(?::[^<>\s]{0,24})?>)/,Er=/(^|[^A-Za-z0-9_%]|%[0-9A-Fa-f]{2})([A-Za-z_][A-Za-z0-9_.-]{0,40})(\s*[:=]\s*|%3D|%3A)((?:(?!%26|%2C|%20|%23|%3B|%7C)[^\s&"',;#<>|])+)/gi;function xe(t){let e=re(t);return gr.has(e)||yr.test(e)}function Ar(t,e){return/^[A-Za-z_$][\w$.:-]{0,63}$/.test(t)&&!/\d{5,}/.test(t)||/^\d{1,4}$/.test(t)?t:`<key${e}:${J(t).replace(/[<>]/g,"")}>`}function Xe(t){return t.split("/").map(e=>{if(e==="")return e;let n=e;try{n=decodeURIComponent(e)}catch{}return Je(n)||/^v\d{1,2}(\.\d{1,2})?$/i.test(n)||/^\d{1,3}$/.test(n)||/^[A-Za-z][A-Za-z0-9_-]{0,40}(\.[A-Za-z0-9_-]{1,40}){0,3}\.[a-z0-9]{1,6}$/i.test(n)&&!/\d{6,}/.test(n)||/^[a-z]+[-_][a-z0-9]{1,3}$/i.test(n)?e:J(n)}).join("/")}var We=class{constructor(e,n){this.rules=e;this.salt=n}ruleFor(e,n,r){for(let o of this.rules)if(this.matches(o,e,n,r))return o}matches(e,n,r,o){if(e.surface!==void 0&&!Pe(e.surface).includes(n.surface)||e.part!==void 0&&e.part!==n.part||e.host!==void 0&&(n.host===void 0||!X(e.host,n.host))||e.path!==void 0&&(n.path===void 0||!X(e.path,n.path)))return!1;if(e.selector!==void 0){if(!n.el)return!1;try{if(!n.el.closest(e.selector))return!1}catch{return!1}}return e.key!==void 0?r===void 0?!1:Pe(e.key).some(s=>Rr(s,r,o!=null?o:r)):!0}method(e,n,r,o=""){var s;switch(n.method){case"drop":return ie;case"presence":return e==null?e:e===""||Array.isArray(e)&&e.length===0?"<empty>":"<set>";case"length":return e==null?e:typeof e=="string"?`<len:${e.length}>`:Array.isArray(e)?`<len:${e.length}>`:typeof e=="object"?`<len:${Object.keys(e).length}>`:`<len:${String(e).length}>`;case"hash":return e==null?e:`<h:${Re(this.salt+(typeof e=="string"?e:JSON.stringify(e)))}>`;case"shape":return typeof e=="string"?dt(e,n.keepPrefix):typeof e=="number"?dt(String(e),n.keepPrefix):typeof e=="object"&&e!==null?this.tree(e,r,"shape",o):e;case"mask":return typeof e=="string"||typeof e=="number"?Yt(String(e),n.keepStart,n.keepEnd):ue(e);case"enum":return e==null||typeof e=="boolean"?e:typeof e=="string"||typeof e=="number"?((s=n.values)!=null?s:[]).includes(String(e))?e:ue(e):ue(e);case"clear":return this.leaf(e,r,o,n);default:return this.leaf(e,r,o,void 0)}}leaf(e,n,r,o){if(typeof e=="string"){if(e.length>ft)return`<len:${e.length}>`;let s=se(e);return s!==void 0&&typeof s=="object"&&s!==null?this.tree(s,n,"values",r,o):/^https?:\/\/\S+$/i.test(e)?this.url(e,n,"values",o):/\s/.test(e.trim())?this.text(e,n,"values",o):o?e:J(e)}return e!==null&&typeof e=="object"?this.tree(e,n,"values",r,o):o?e:ue(e)}keyed(e,n,r,o,s){if(pe(e))return this.method(n,{method:"length"},r);let i=this.ruleFor(r,e,o);return i?this.method(n,i,r,o):xe(e)?this.method(n,{method:"length"},r):re(e)==="code"&&typeof n=="string"&&br.test(n)?this.method(n,{method:"length"},r):this.leaf(n,r,o,s)}tree(e,n,r,o="",s,i=0){var a;if(i>wr)return"<deep>";if(Array.isArray(e)){let u=(a=o.split(".").pop())!=null?a:"",c=[];for(let f of e.slice(0,pt)){let d=f!==null&&typeof f=="object"?this.tree(f,n,r,o,s,i+1):this.scalar(u,f,n,r,o,s);d!==ie&&c.push(d)}return e.length>pt&&c.push(`<more:${e.length-pt}>`),c}if(le(e)){let u={},c=typeof e.type=="string"&&"value"in e?e.type:void 0,f=0;for(let[d,l]of Object.entries(e)){if(f>=Qt){u["<more>"]=Object.keys(e).length-Qt;break}let p=c!==void 0&&d==="value"?c:d,y=o?`${o}.${p}`:p,k,R=r==="values"?this.hasKeyRule(p,n,y):!!this.restrictiveRule(p,n,y,r);l!==null&&typeof l=="object"&&!R?k=pe(p)?this.method(l,{method:"length"},n):this.tree(l,n,r,y,s,i+1):k=this.scalar(p,l,n,r,y,s),k!==ie&&(u[Ar(d,f)]=k),f++}return u}return this.scalar("",e,n,r,o,s)}hasKeyRule(e,n,r){var o;return pe(e)||xe(e)||((o=this.ruleFor(n,e,r))==null?void 0:o.key)!==void 0}restrictiveRule(e,n,r,o){if(!e)return;let s=this.ruleFor(n,e,r);if(!(!s||s.key===void 0))return s.method==="drop"||o==="shape"&&kr.has(s.method)?s:void 0}scalar(e,n,r,o,s,i){if(o!=="values"){let u=this.restrictiveRule(e,r,s,o);if(u)return this.method(n,u,r,s)}if(o==="inventory")return me(n);if(o==="shape"){if(e&&(pe(e)||xe(e)))return this.method(n,{method:"length"},r);if(typeof n=="string"){let u=n.length<=ft?se(n):void 0;if(u!==void 0&&typeof u=="object"&&u!==null)return this.tree(u,r,"shape",s)}return ue(n)}if(e)return this.keyed(e,n,r,s,i);let a=this.ruleFor(r);return a?this.method(n,a,r,s):this.leaf(n,r,s,i)}text(e,n,r,o){if(r==="inventory"||r==="shape")return J(e);if(!o){let i=this.ruleFor(n);if(i){if(i.method==="class")return J(e);let a=this.method(e,i,n);if(a===ie)return"";if(i.method!=="clear")return typeof a=="string"?a:JSON.stringify(a);o=i}}let s=ct(e).replace(Er,(i,a,u,c,f)=>{if(ht.test(f))return i;let d;if(pe(u))d=`<redacted:${f.length}>`;else{let l=this.ruleFor(n,u,u);l&&l.key!==void 0?d=this.method(f,l,n,u):xe(u)&&(d=`<redacted:${f.length}>`)}return d===void 0?i:`${a}${u}${c}${d===ie?"<dropped>":String(d)}`});return o?s:s.replace(/\S+/g,i=>this.token(i,n))}token(e,n,r=0){var u,c,f,d;if(ht.test(e))return e;if(vr.test(e))return e.split(Sr).map((l,p)=>p%2===1||l===""?l:this.token(l,n,r)).join("");let o=(c=(u=/^[([{"'“‘|<]+/.exec(e))==null?void 0:u[0])!=null?c:"",s=(d=(f=/[)\]}"'”’,.;:=!?|>/]+$/.exec(e.slice(o.length)))==null?void 0:f[0])!=null?d:"",i=e.slice(o.length,e.length-s.length);if(i===""||ht.test(i)||Je(i)||/^\d{1,3}$/.test(i))return e;if(/^https?:\/\//i.test(i))return o+this.url(i,n,"values")+s;let a=r===0?/[:=]/.exec(i):null;if(a&&a.index>0&&a.index<i.length-1){let l=i.slice(0,a.index),p=i.slice(a.index+1);return o+this.token(l,n,1)+a[0]+this.token(p,n,1)+s}return o+J(i)+s}url(e,n,r,o){var f;let s;try{s=new URL(e,typeof location!="undefined"?location.href:void 0)}catch{return r==="inventory"?"<url>":J(e)}let i={...n,host:s.hostname,path:s.pathname,part:(f=n.part)!=null?f:"url"},a=`${s.protocol}//${s.host}${Xe(s.pathname)}`;if(r==="inventory")return a;let u=d=>{let l=[];return new URLSearchParams(d).forEach((p,y)=>{if(l.length>=60)return;let k=/^[\w.[\]-]{1,64}$/.test(y)?y:J(y),R;if(r==="shape"){let x=this.restrictiveRule(y,i,y,r);R=x?this.method(p,x,i,y):pe(y)||xe(y)?`<len:${p.length}>`:ue(p)}else R=this.keyed(y,p,i,y,o);R!==ie&&l.push(`${k}=${typeof R=="string"?R:JSON.stringify(R)}`)}),l.join("&")};s.search.length>1&&(a+=`?${u(s.search.slice(1))}`);let c=s.hash.slice(1);if(c)if(c.startsWith("/")){let d=c.indexOf("?");a+=`#${Xe(d<0?c:c.slice(0,d))}${d<0?"":`?${u(c.slice(d+1))}`}`}else c.includes("=")?a+=`#${u(c)}`:a+=`#${Je(c)?c:J(c)}`;return a}body(e,n,r){try{if(e==null)return;if(r==="inventory")return{type:me(e)};if(typeof e=="string"){if(e.length>ft)return{len:e.length,skipped:"size"};let o=se(e);if(o!==void 0)return this.tree(o,n,r);if(Pr(e))return{form:this.tree(en(new URLSearchParams(e)),n,r)};if(r==="shape")return{text:J(e)};let s=e.length>lt?e.slice(0,lt):e,i=Tr(s),a=/^\s*</.test(i)?i.replace(/</g," <").replace(/>/g,"> "):i;return{text:this.text(a,n,r).trim(),...e.length>lt?{len:e.length}:{}}}if(typeof URLSearchParams!="undefined"&&e instanceof URLSearchParams)return{form:this.tree(en(e),n,r)};if(typeof FormData!="undefined"&&e instanceof FormData){let o={};return e.forEach((s,i)=>{o[i]=typeof s=="string"?s:`<file:${s.size}>`}),{formData:this.tree(o,n,r)}}return typeof Blob!="undefined"&&e instanceof Blob?{blob:e.size}:typeof ArrayBuffer!="undefined"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))?{bytes:e.byteLength}:typeof e=="object"?this.tree(e,n,r):this.scalar("",e,n,r,"")}catch{return{error:"redact-failed"}}}};function Rr(t,e,n){return t.includes(".")?X(t,n)||X(`*.${t}`,n):t.includes("*")||t.includes("?")?X(t,e):re(t)===re(e)}function Pr(t){return/^[^\s<>{}=&]+=[^\s<>]*(&[^\s<>{}=&]+=[^\s<>]*)*$/.test(t.trim())}function en(t){let e={};return t.forEach((n,r)=>{r in e?e[r]=[].concat(e[r],n):e[r]=n}),e}function Tr(t){let e=n=>pe(n)||xe(n);return t.replace(/(<input\b[^>]*\bname\s*=\s*["']?([\w.-]+)["']?[^>]*\bvalue\s*=\s*)(["'])([^"'>]*)\3/gi,(n,r,o,s,i)=>e(o)?`${r}${s}<redacted:${i.length}>${s}`:n).replace(/(<input\b[^>]*\bvalue\s*=\s*)(["'])([^"'>]*)\2([^>]*\bname\s*=\s*["']?([\w.-]+)["']?)/gi,(n,r,o,s,i,a)=>e(a)?`${r}${o}<redacted:${s.length}>${o}${i}`:n)}var $r={enum:["off","inventory","shape","values"]},xr={enum:["drop","presence","length","class","shape","hash","mask","enum","clear"]},te={type:"array",items:{type:"string",minLength:1,maxLength:200},maxItems:100},Le={anyOf:[{type:"string",minLength:1,maxLength:200},te]},tn={type:"object",maxProperties:20,additionalProperties:{anyOf:[{type:"string",maxLength:200},te]}},gt={values:te,keepPrefix:{type:"integer",minimum:0,maximum:64},keepStart:{type:"integer",minimum:0,maximum:64},keepEnd:{type:"integer",minimum:0,maximum:64}},G=(t={})=>({anyOf:[{$ref:"#/$defs/level"},{type:"object",required:["level"],additionalProperties:!1,properties:{level:{$ref:"#/$defs/level"},...t}}]}),Lr=["page","ui","act","nav","res","store","net","form","err","console","dl","msg","glob","cev"],ve={type:"string",minLength:1,maxLength:200,pattern:"^[^\\s]+$"},mt={type:"object",required:["path"],additionalProperties:!1,properties:{path:ve,as:{type:"string",minLength:1,maxLength:64},method:{$ref:"#/$defs/method"},...gt}},yt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://corbado.com/schemas/autocapture/probe-config-v1.json",title:"Corbado autocapture probe config (v1)",type:"object",required:["v"],additionalProperties:!1,properties:{v:{const:1},name:{type:"string",maxLength:120},when:{$ref:"#/$defs/when"},trigger:{$ref:"#/$defs/trigger"},surfaces:{type:"object",additionalProperties:!1,properties:{page:G(),ui:G({maxViews:{type:"integer",minimum:1,maximum:100}}),act:G(),nav:G(),res:G({hosts:te,everyMs:{type:"integer",minimum:1e3,maximum:6e5}}),store:G(),net:G({hosts:te,excludeHosts:te,paths:te,methods:{type:"array",items:{type:"string",pattern:"^[A-Z]{3,10}$"},maxItems:10},bodies:{type:"boolean"}}),form:G(),err:G(),console:G({levels:{type:"array",items:{enum:["error","warn","info","log","debug"]},maxItems:5}}),dl:G(),msg:G(),glob:G(),cev:G()}},rules:{type:"array",maxItems:200,items:{$ref:"#/$defs/rule"}},actions:{type:"array",maxItems:50,items:{$ref:"#/$defs/action"}},budgets:{type:"object",additionalProperties:!1,properties:{items:{type:"integer",minimum:1,maximum:2e3},bytes:{type:"integer",minimum:1e3,maximum:2e6},perKind:{type:"object",maxProperties:40,additionalProperties:{type:"integer",minimum:0,maximum:2e3}}}}},$defs:{level:$r,method:xr,surfaceName:{enum:Lr},when:{type:"object",additionalProperties:!1,properties:{projects:te,until:{type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}([T ].+)?$"},sample:{type:"number",minimum:0,maximum:1},browser:{type:"array",items:{enum:["chrome","edge","safari","firefox","samsung","opera","other"]}},os:{type:"array",items:{enum:["windows","macos","ios","android","linux","chromeos","other"]}},device:{type:"array",items:{enum:["desktop","mobile","tablet"]}},path:te,state:te,tags:{type:"object",maxProperties:10,additionalProperties:te},integrationVersion:te}},netMatch:{type:"object",additionalProperties:!1,properties:{host:Le,path:Le,method:Le,status:{anyOf:[{enum:["ok","error"]},{type:"array",items:{type:"integer",minimum:0,maximum:999}}]},body:tn,response:tn}},match:{type:"object",additionalProperties:!1,minProperties:1,properties:{net:{$ref:"#/$defs/netMatch"},selector:{type:"string",minLength:1,maxLength:300},click:{type:"string",minLength:1,maxLength:300},submit:{anyOf:[{const:!0},{type:"string",minLength:1,maxLength:300}]},signal:{type:"string",minLength:1,maxLength:64},state:{type:"string",minLength:1,maxLength:64},error:{const:!0}}},trigger:{type:"object",required:["on"],additionalProperties:!1,properties:{on:{type:"array",minItems:1,maxItems:20,items:{$ref:"#/$defs/match"}},buffer:{type:"integer",minimum:1,maximum:2e3},bufferBytes:{type:"integer",minimum:1e3,maximum:2e6},streamMs:{type:"integer",minimum:0,maximum:36e5}}},rule:{type:"object",required:["method"],additionalProperties:!1,properties:{surface:{anyOf:[{$ref:"#/$defs/surfaceName"},{type:"array",items:{$ref:"#/$defs/surfaceName"}}]},host:Le,path:Le,key:Le,selector:{type:"string",minLength:1,maxLength:300},part:{enum:["url","request","response"]},method:{$ref:"#/$defs/method"},...gt}},action:{oneOf:[{type:"object",required:["type","name","on"],additionalProperties:!1,properties:{type:{const:"snapshot"},name:{type:"string",pattern:"^[A-Za-z0-9_.-]{1,64}$"},on:{$ref:"#/$defs/match"},fields:{type:"array",maxItems:30,items:{type:"object",required:["selector"],additionalProperties:!1,properties:{selector:{type:"string",minLength:1,maxLength:300},as:{type:"string",minLength:1,maxLength:64},method:{$ref:"#/$defs/method"},...gt}}},texts:{type:"array",maxItems:20,items:{type:"string",minLength:1,maxLength:300}},request:{type:"array",maxItems:30,items:mt},response:{type:"array",maxItems:30,items:mt},max:{type:"integer",minimum:1,maximum:200}}},{type:"object",required:["type","name","learn","resolve"],additionalProperties:!1,properties:{type:{const:"correlate"},name:{type:"string",pattern:"^[A-Za-z0-9_.-]{1,64}$"},kind:{type:"string",pattern:"^[a-z][a-z0-9_-]{0,31}$"},learn:{type:"object",required:["net","items","key","value"],additionalProperties:!1,properties:{net:{$ref:"#/$defs/netMatch"},from:{enum:["request","response"]},items:ve,key:ve,value:ve,method:{$ref:"#/$defs/method"},values:te,count:{type:"array",maxItems:10,items:ve}}},resolve:{type:"object",required:["net","key"],additionalProperties:!1,properties:{net:{$ref:"#/$defs/netMatch"},from:{enum:["request","response"]},key:{anyOf:[ve,{type:"array",minItems:1,maxItems:10,items:ve}]},fields:{type:"array",maxItems:20,items:mt}}},max:{type:"integer",minimum:1,maximum:500}}},{type:"object",required:["type","name","on"],additionalProperties:!1,properties:{type:{const:"count"},name:{type:"string",pattern:"^[A-Za-z0-9_.-]{1,64}$"},on:{$ref:"#/$defs/match"}}}]}}},nn=yt;function Mr(t){var n;let e=t.replace(/^#\/\$defs\//,"");return(n=yt.$defs[e])!=null?n:{}}function Or(t,e){switch(t){case"object":return!!e&&typeof e=="object"&&!Array.isArray(e);case"array":return Array.isArray(e);case"string":return typeof e=="string";case"integer":return typeof e=="number"&&Number.isInteger(e);case"number":return typeof e=="number"&&Number.isFinite(e);case"boolean":return typeof e=="boolean";default:return!1}}function Se(t,e,n,r){var o,s;if(!(r.length>50)){if(typeof t.$ref=="string")return Se(Mr(t.$ref),e,n,r);if(Array.isArray(t.anyOf)){for(let i of t.anyOf){let a=[];if(Se(i,e,n,a),a.length===0)return}r.push(`${n}: does not match any allowed form`);return}if(Array.isArray(t.oneOf)){let i=t.oneOf,a=e&&typeof e=="object"?e.type:void 0,u=i.find(c=>{var f,d;return((d=(f=c.properties)==null?void 0:f.type)==null?void 0:d.const)===a});if(!u){let c=i.map(f=>f.properties.type.const).join(", ");r.push(`${n}.type: must be one of ${c}`);return}return Se(u,e,n,r)}if("const"in t&&e!==t.const){r.push(`${n}: must be ${JSON.stringify(t.const)}`);return}if(Array.isArray(t.enum)&&!t.enum.includes(e)){r.push(`${n}: must be one of ${t.enum.join(", ")}`);return}if(typeof t.type=="string"&&!Or(t.type,e)){r.push(`${n}: must be ${t.type}`);return}if(typeof e=="string"&&(typeof t.minLength=="number"&&e.length<t.minLength&&r.push(`${n}: too short`),typeof t.maxLength=="number"&&e.length>t.maxLength&&r.push(`${n}: too long`),typeof t.pattern=="string"&&!new RegExp(t.pattern).test(e)&&r.push(`${n}: invalid format`)),typeof e=="number"&&(typeof t.minimum=="number"&&e<t.minimum&&r.push(`${n}: must be \u2265 ${t.minimum}`),typeof t.maximum=="number"&&e>t.maximum&&r.push(`${n}: must be \u2264 ${t.maximum}`)),Array.isArray(e)&&(typeof t.minItems=="number"&&e.length<t.minItems&&r.push(`${n}: too few items`),typeof t.maxItems=="number"&&e.length>t.maxItems&&r.push(`${n}: too many items`),t.items&&e.forEach((i,a)=>Se(t.items,i,`${n}[${a}]`,r))),e&&typeof e=="object"&&!Array.isArray(e)){let i=e,a=(o=t.properties)!=null?o:{},u=Object.keys(i);typeof t.minProperties=="number"&&u.length<t.minProperties&&r.push(`${n}: must not be empty`),typeof t.maxProperties=="number"&&u.length>t.maxProperties&&r.push(`${n}: too many properties`);for(let c of(s=t.required)!=null?s:[])c in i||r.push(`${n}.${c}: required`);for(let c of u)a[c]?Se(a[c],i[c],`${n}.${c}`,r):t.additionalProperties===!1?r.push(`${n}.${c}: unknown property`):t.additionalProperties&&typeof t.additionalProperties=="object"&&Se(t.additionalProperties,i[c],`${n}.${c}`,r)}}}function Cr(t){if(typeof document=="undefined")return!1;try{return document.createDocumentFragment().querySelector(t),!1}catch{return!0}}function Ir(t,e){var i,a,u,c,f;let n=(i=t.when)==null?void 0:i.until;n!==void 0&&!Number.isFinite(Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(n)?`${n}T00:00:00Z`:n))&&e.push("$.when.until: not a valid date");let r=[];((a=t.rules)!=null?a:[]).forEach((d,l)=>{var p;r.push([`$.rules[${l}].selector`,d.selector]),d.method==="enum"&&!((p=d.values)!=null&&p.length)&&e.push(`$.rules[${l}].values: required for method enum`)});let o=[];((c=(u=t.trigger)==null?void 0:u.on)!=null?c:[]).forEach((d,l)=>o.push([`$.trigger.on[${l}]`,d]));let s=new Set;((f=t.actions)!=null?f:[]).forEach((d,l)=>{var y,k;let p=`${d.type}:${d.name}`;s.has(p)&&e.push(`$.actions[${l}].name: duplicate ${d.type} name`),s.add(p),(d.type==="snapshot"||d.type==="count")&&o.push([`$.actions[${l}].on`,d.on]),d.type==="snapshot"&&(((y=d.fields)!=null?y:[]).forEach((R,x)=>r.push([`$.actions[${l}].fields[${x}].selector`,R.selector])),((k=d.texts)!=null?k:[]).forEach((R,x)=>r.push([`$.actions[${l}].texts[${x}]`,R])))});for(let[d,l]of o)l&&(r.push([`${d}.selector`,l.selector],[`${d}.click`,l.click]),typeof l.submit=="string"&&r.push([`${d}.submit`,l.submit]));for(let[d,l]of r)l!==void 0&&Cr(l)&&e.push(`${d}: invalid CSS selector`)}function Ze(t){let e=[];try{Se(yt,t,"$",e),e.length===0&&Ir(t,e)}catch(n){e.push(`$: validation failed (${String(n)})`)}return{ok:e.length===0,errors:e}}function Ge(t){try{return Re(jt(t)).slice(0,16)}catch{return"invalid"}}var ce=()=>{},bt=/(^|\.)corbado\.(io|com|cloud)$/i,Ne=t=>{let e=t;return()=>e-- >0};function sn(t){var n,r;let e=t.level("page");if(e!=="off")try{let o=(r=(n=performance.getEntriesByType)==null?void 0:n.call(performance,"navigation"))==null?void 0:r[0],s=t.scope("page");t.emit("page",{url:t.redactor.url(location.href,s,e),ref:document.referrer?t.redactor.url(document.referrer,s,e==="values"?"values":"inventory"):"",title:e==="inventory"?void 0:t.redactor.text(document.title,s,e),nav:o?{type:o.type,redirects:o.redirectCount,status:o.responseStatus,ttfb:Math.round(o.responseStart),dcl:Math.round(o.domContentLoadedEventEnd),size:o.transferSize}:void 0,vw:typeof innerWidth=="number"?innerWidth:void 0,vh:typeof innerHeight=="number"?innerHeight:void 0,lang:typeof navigator!="undefined"?navigator.language:void 0,tz:Intl.DateTimeFormat().resolvedOptions().timeZone})}catch{}}function an(t,e,n){let r=t.level("res");if(r==="off")return{flush:ce,dispose:ce};let o=0,s=()=>{var a;try{let u=(a=performance.getEntriesByType)==null?void 0:a.call(performance,"resource");if(!u||u.length<=o)return;let c=u.slice(o);o=u.length;let f=c.filter(d=>{try{let l=new URL(d.name).hostname;return!bt.test(l)&&(!e||X(e,l))}catch{return!e}}).map(d=>[t.redactor.url(d.name,t.scope("res"),r),d.initiatorType,Math.round(d.startTime),Math.round(d.duration),d.transferSize,d.responseStatus]);for(let d=0;d<f.length;d+=40)t.emit("res",{rows:f.slice(d,d+40)})}catch{}},i=setInterval(s,Math.max(1e3,n));return{flush:s,dispose:()=>clearInterval(i)}}function un(t){let e=t.level("store");if(e!=="off")try{let n=t.scope("store"),r=s=>{var i;try{if(!s)return[];let a=Array.from({length:Math.min(s.length,200)},(c,f)=>{var d;return(d=s.key(f))!=null?d:""});if(e==="inventory")return a;let u={};for(let c of a){let f=(i=s.getItem(c))!=null?i:"";if(e==="shape"){let d=se(f);u[c]=d!==void 0?t.redactor.tree(d,n,"shape"):ue(f)}else{let d=t.redactor.tree({[c]:f},n,"values");c in d&&(u[c]=d[c])}}return u}catch{return["<blocked>"]}},o=[];try{o=document.cookie.split(";").map(s=>{var i;return((i=s.split("=")[0])!=null?i:"").trim()}).filter(Boolean).slice(0,100)}catch{}t.emit("store",{ls:r(rn("localStorage")),ss:r(rn("sessionStorage")),ck:o})}catch{}}function rn(t){try{return window[t]}catch{return}}function cn(t){let e=t.level("form");if(e!=="off")try{let n=Array.from(document.forms).slice(0,10).map(r=>({id:Z(r),name:r.getAttribute("name")||void 0,action:t.redactor.url(Ie(r),t.scope("form",r),e),method:Ue(r),fields:Array.from(r.elements).slice(0,40).map(o=>{let s=o,i=s.getAttribute("name")||Z(s)||"";if(!i||s.type==="submit"||s.type==="button")return;if(e==="inventory")return[i,s.type];let a=t.scope("form",o),u=t.redactor.ruleFor(a,i,i);if((u==null?void 0:u.method)==="drop")return;let f=ze(o,e==="values"&&u?u:{method:"class"},(d,l)=>{let p=t.redactor.method(d,l,a,i);return p===ie?void 0:p});return[i,s.type,f]}).filter(Boolean)}));n.length&&t.emit("form",{forms:n})}catch{}}function dn(t){let e=t.level("err"),n=Ne(50),r=()=>t.scope("err"),o=u=>typeof u=="string"?e==="values"?t.redactor.text(u.slice(0,500),r(),"values"):J(u):void 0,s=u=>typeof u=="string"&&e==="values"?u.split(`
2
2
  `).slice(1,6).map(c=>c.replace(/https?:\/\/[^\s)]+/g,f=>t.redactor.url(f,r(),"values")).trim().slice(0,300)):void 0,i=u=>{var c,f,d;try{if((c=t.onError)==null||c.call(t),e==="off"||!n())return;let l=u.target;if(l&&l!==window&&l instanceof Element){let y=l.src||l.href||"";t.emit("err",{t:"res",tag:l.tagName.toLowerCase(),url:y?t.redactor.url(y,r(),e):void 0});return}let p=u;t.emit("err",{t:"js",name:p.error&&typeof p.error=="object"&&String((f=p.error.name)!=null?f:"")||void 0,msg:e==="inventory"?void 0:o(p.message),src:p.filename?t.redactor.url(p.filename,r(),e):void 0,line:p.lineno,col:p.colno,stack:s((d=p.error)==null?void 0:d.stack)})}catch{}},a=u=>{var c;try{if((c=t.onError)==null||c.call(t),e==="off"||!n())return;let f=u.reason;t.emit("err",{t:"rej",name:f&&typeof f=="object"&&typeof f.name=="string"?f.name:me(f),msg:e==="inventory"?void 0:o(f&&typeof f=="object"?f.message:f),stack:s(f&&typeof f=="object"?f.stack:void 0)})}catch{}};try{window.addEventListener("error",i,!0),window.addEventListener("unhandledrejection",a)}catch{return ce}return()=>{try{window.removeEventListener("error",i,!0),window.removeEventListener("unhandledrejection",a)}catch{}}}function fn(t,e){let n=t.level("console");if(n==="off"||typeof console=="undefined")return ce;let r=Ne(50),o=[],s=!1;for(let i of e)try{let a=console,u=a[i];if(typeof u!="function")continue;let c=function(...f){let d=u.apply(this,f);if(!s){s=!0;try{r()&&t.emit("console",{lvl:i,args:Nr(t,f,n)})}catch{}finally{s=!1}}return d};a[i]=c,o.push(()=>{a[i]===c&&(a[i]=u)})}catch{}return()=>o.forEach(i=>i())}function Nr(t,e,n){let r=t.scope("console");return e.slice(0,5).map(o=>{if(n==="inventory")return me(o);if(o instanceof Error)return{name:o.name,msg:n==="values"?t.redactor.text(o.message.slice(0,500),r,"values"):J(o.message)};if(typeof o=="string")return n==="values"?t.redactor.text(o.slice(0,1e3),r,"values"):J(o);if(o&&typeof o=="object")try{return t.redactor.tree(JSON.parse(JSON.stringify(o)),r,n)}catch{return"<unserializable>"}return n==="values"?t.redactor.tree(o,r,"values"):ue(o)})}function ln(t){let e=t.level("dl");if(e==="off")return ce;let n=Ne(100),r=()=>t.scope("dl"),o=u=>{try{let c=JSON.parse(JSON.stringify(u!=null?u:null));return e==="inventory"&&le(c)?Object.keys(c).slice(0,40):t.redactor.tree(c,r(),e)}catch{return"<unserializable>"}},s,i=()=>{try{if(s)return;let u=window.dataLayer;if(!Array.isArray(u))return;for(let d of u.slice(0,30))n()&&t.emit("dl",{src:"initial",e:o(d)});let c=u.push,f=function(...d){let l=c.apply(this,d);try{for(let p of d)n()&&t.emit("dl",{src:"push",e:o(p)})}catch{}return l};u.push=f,s={dl:u,original:c,wrapper:f}}catch{}};i();let a=[setTimeout(i,2e3),setTimeout(i,8e3)];return()=>{a.forEach(clearTimeout);try{s&&s.dl.push===s.wrapper&&(s.dl.push=s.original)}catch{}}}function pn(t){let e=t.level("msg");if(e==="off")return ce;let n=Ne(100),r=o=>{var s;try{if(!n())return;let i=o.source===window?"self":o.source===window.parent?"parent":o.source?"frame":"other",a;if(typeof o.data=="string"){let u=se(o.data);a=u!==void 0?t.redactor.tree(u,t.scope("msg"),e):e==="values"?t.redactor.text(o.data.slice(0,1e3),t.scope("msg"),"values"):J(o.data)}else try{a=t.redactor.tree(JSON.parse(JSON.stringify((s=o.data)!=null?s:null)),t.scope("msg"),e)}catch{a=me(o.data)}t.emit("msg",{origin:o.origin,src:i,data:a})}catch{}};try{window.addEventListener("message",r)}catch{return ce}return()=>{try{window.removeEventListener("message",r)}catch{}}}var jr=/\{\s*\[native code\]\s*\}\s*$/;function hn(t){let e=t.level("glob");if(e!=="off")try{let n=[];for(let r of Object.keys(window).slice(0,2e3)){if(n.length>=300)break;if(/^\d+$/.test(r)||/^on[a-z]+$/.test(r))continue;let o;try{o=window[r]}catch{continue}if(typeof o=="function"){if(jr.test(Function.prototype.toString.call(o)))continue;n.push([r,"function"]);continue}if(o&&typeof o=="object"){let s=Object.prototype.toString.call(o);if(s!=="[object Object]"&&s!=="[object Array]")continue;let i=e==="inventory"||Array.isArray(o)?void 0:Object.keys(o).slice(0,20);n.push(i?[r,Array.isArray(o)?"array":"object",i]:[r,Array.isArray(o)?"array":"object"]);continue}n.push([r,me(o)])}t.emit("glob",{names:n})}catch{}}var on=/^[a-z]+$/;function mn(t){let e=t.level("cev");if(e==="off"||typeof EventTarget=="undefined")return ce;let n=Ne(100),r=new Map,o=EventTarget.prototype,s=o.dispatchEvent;if(typeof s!="function")return ce;let i=!1,a=function(u){var c,f;if(!i){i=!0;try{let d=typeof CustomEvent!="undefined"&&u instanceof CustomEvent;if((d||!on.test(u.type))&&n()){let l=((c=r.get(u.type))!=null?c:0)+1;if(r.set(u.type,l),l<=10){let p=this instanceof Element?`${this.tagName.toLowerCase()}${Z(this)?`#${Z(this)}`:""}`:this===window?"window":this===document?"document":"other",y;if(d&&e!=="inventory")try{y=t.redactor.tree(JSON.parse(JSON.stringify((f=u.detail)!=null?f:null)),t.scope("cev"),e)}catch{y="<unserializable>"}t.emit("cev",{type:on.test(u.type)||/^[\w:.-]{1,64}$/.test(u.type)?u.type:`<h:${Re(u.type)}>`,target:p,n:l,detail:y})}}}catch{}finally{i=!1}}return s.call(this,u)};try{o.dispatchEvent=a}catch{return ce}return()=>{try{o.dispatchEvent===a&&(o.dispatchEvent=s)}catch{}}}var qr=1500,Dr=4e4,Hr=400,Br=400,_r=2e3,Ye=200,de=120,gn=20,Ur=150,zr=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","SVG","HEAD","META","LINK","IFRAME","CANVAS","VIDEO","AUDIO","IMG","PICTURE","OBJECT"]),Fr=new Set(["H1","H2","H3","H4","H5","H6","P","LABEL","LEGEND","DT","DD","TH","CAPTION","FIGCAPTION"]),Vr=/^(button|radio|tab|link|checkbox|switch|menuitem|menuitemradio|menuitemcheckbox|option)$/,Kr=/(error|banner|alert)/i,Jr='button,a[href],input,select,textarea,summary,label,[role=button],[role=radio],[role=tab],[role=link],[role=checkbox],[role=switch],[role=menuitem],[role=option],[tabindex]:not([tabindex="-1"]),[onclick]',yn=(t,e)=>(t!=null?t:"").replace(/\s+/g," ").trim().slice(0,e);function wt(t){try{let e=Array.from(t.classList).filter(n=>!/^(ng|cdk)-/.test(n)).slice(0,2).join(" ");return e?e.slice(0,60):void 0}catch{return}}function he(t){let e={};for(let[n,r]of Object.entries(t))r!==void 0&&r!==!1&&r!==""&&(e[n]=r);return e}var kt=t=>t.tagName==="INPUT"&&t.type!=="hidden"||t.tagName==="SELECT"||t.tagName==="TEXTAREA",bn=t=>{var n;let e="";for(let r of Array.from(t.childNodes))r.nodeType===3&&(e+=` ${(n=r.nodeValue)!=null?n:""}`);return e};function wn(t){let{emit:e,redactor:n}=t,r=(h,m,g,A,L=Ye)=>{let v=yn(g,L);return!v||m==="inventory"||m==="off"?void 0:m==="shape"?J(v):n.text(v,t.scope(h,A),"values")||void 0},o=(h,m,g=Ye)=>r("ui",t.ui,h,m,g),s=(h,m,g=Ye)=>r("act",t.act,h,m,g),i=(h,m,g)=>n.url(g,t.scope(h),m),a=(h,m)=>{let g=n.ruleFor(t.scope(h,m));return!!g&&g.selector!==void 0&&g.method==="drop"};function u(h){try{if(h.getAttribute("aria-hidden")==="true"||h.hidden)return 0;let m=h.checkVisibility;if(typeof m=="function")return m.call(h,{checkVisibilityCSS:!0})?h.getClientRects().length?1:0:getComputedStyle(h).display==="contents"?2:0;let g=getComputedStyle(h);return g.display==="none"?0:g.display==="contents"?2:g.visibility==="hidden"?0:1}catch{return 1}}function c(h){var g,A,L;let m=[];try{let v=h.labels;if(v)for(let O of Array.from(v))m.push((g=O.textContent)!=null?g:"");if(!m.length){let O=h.closest("label");O&&m.push((A=O.textContent)!=null?A:"")}let S=h.getAttribute("aria-labelledby");if(S)for(let O of S.split(/\s+/).slice(0,4)){let z=O?document.getElementById(O):null;z&&m.push((L=z.textContent)!=null?L:"")}}catch{}return m.join(" ")}function f(h,m,g){var S,O;let A=(z,Q=de)=>r(m,g,z,h,Q),L=h.tagName==="INPUT"&&/^(submit|button|reset|image)$/.test(h.type),v=h;return he({k:"btn",tag:h.tagName.toLowerCase(),role:(S=h.getAttribute("role"))!=null?S:void 0,x:A(L?h.getAttribute("value"):h.textContent),al:A((O=h.getAttribute("aria-label"))!=null?O:h.getAttribute("title")),id:Z(h),c:wt(h),href:h.tagName==="A"&&v.getAttribute("href")?i(m,g,v.href):void 0,dis:h.disabled===!0||h.getAttribute("aria-disabled")==="true",sel:h.getAttribute("aria-checked")==="true"||h.getAttribute("aria-selected")==="true"||h.getAttribute("aria-pressed")==="true"})}function d(h){var L,v;let m=h.tagName.toLowerCase(),g=h,A={k:m==="select"?"sel":"in",tag:m,ty:m==="input"?g.type:void 0,nm:g.name||void 0,id:Z(h),ac:(L=h.getAttribute("autocomplete"))!=null?L:void 0,ph:o(h.getAttribute("placeholder"),h,de),lb:o(c(h),h,de),al:o(h.getAttribute("aria-label"),h,de),req:g.required===!0,ml:g.maxLength>0?g.maxLength:void 0,im:(v=h.getAttribute("inputmode"))!=null?v:void 0,dis:g.disabled===!0,ro:g.readOnly===!0,inv:h.getAttribute("aria-invalid")==="true"};if(m==="select"){let S=h;t.ui!=="inventory"?A.opts=Array.from(S.options).slice(0,30).map(O=>{var z;return(z=o(O.textContent,h,60))!=null?z:""}):A.nopts=S.options.length,A.si=S.selectedIndex}else if(g.type==="checkbox"||g.type==="radio")A.chk=g.checked?1:0;else{let S=ut(h);t.ui!=="inventory"&&(A.len=S),A.empty=S===0?1:0}return he(A)}function l(h){let m=h.tagName;if(m==="BUTTON"||m==="SUMMARY")return!0;if(m==="A")return h.hasAttribute("href");if(m==="INPUT")return/^(submit|button|reset|image)$/.test(h.type);let g=h.getAttribute("role");if(g&&Vr.test(g))return!0;let A=h.getAttribute("tabindex");if(A!==null&&Number(A)>=0){if(h.hasAttribute("onclick"))return!0;try{return getComputedStyle(h).cursor==="pointer"}catch{return!1}}return h.hasAttribute("onclick")}function p(){var O,z,Q;let h=[],m=0,g=!1,A=0,L=w=>{if(g)return;let W=JSON.stringify(w).length+1;if(m+W>Dr){g=!0;return}m+=W,h.push(w)},v=[],S=(w,W,K)=>{let ge=w.children;for(let ee=ge.length-1;ee>=0;ee--){let B=ge[ee];B&&v.push([B,W,K])}let ne=w.shadowRoot;if(ne){let ee=ne.children;for(let B=ee.length-1;B>=0;B--){let ae=ee[B];ae&&v.push([ae,W,K])}}};for(document.body&&S(document.body,!1,void 0);v.length&&!g;){if(++A>qr){g=!0;break}let[w,W,K]=v.pop();if(zr.has(w.tagName.toUpperCase())||w.tagName==="INPUT"&&w.type==="hidden")continue;let ge=u(w);if(ge===0||a("ui",w))continue;if(ge===2){S(w,W,K);continue}let ne=w.tagName,ee=w.getAttribute("role");if(ne==="FIELDSET"||ee==="radiogroup"||ee==="group"){let B=ne==="FIELDSET"?(O=w.querySelector(":scope > legend"))==null?void 0:O.textContent:null,ae={entry:he({k:"grp",tag:ne.toLowerCase(),id:Z(w),lg:(z=o(B,w,de))!=null?z:o(c(w),w,de),al:o(w.getAttribute("aria-label"),w,de)}),opts:[]};ae.entry.opts=ae.opts,L(ae.entry),S(w,W,ae);continue}if(!(ne==="LEGEND"&&K)){if(kt(w)){let B=w;K&&(B.type==="radio"||B.type==="checkbox")?K.opts.length<gn&&K.opts.push(he({lb:o(c(w),w,de),nm:B.name||void 0,id:Z(w),ty:B.type,chk:B.checked?1:0,dis:B.disabled===!0})):L(d(w));continue}if(l(w)){let B=f(w,"ui",t.ui);K&&(ee==="radio"||ee==="checkbox")?K.opts.length<gn&&K.opts.push(B):L(B),S(w,!0,K);continue}if(ne==="FORM"){let B=w;L(he({k:"form",id:Z(w),nm:(Q=w.getAttribute("name"))!=null?Q:void 0,m:w.getAttribute("method")?Ue(B):void 0,a:w.getAttribute("action")?i("ui",t.ui,Ie(B)):void 0})),S(w,W,K);continue}if(!W){let B=ee==="alert"||ee==="status"||Kr.test(typeof w.className=="string"?w.className:"");if(ne==="LABEL"&&w.control){S(w,!0,K);continue}if(B||Fr.has(ne)){let qe=yn(w.textContent,Ye),En=o(qe,w);qe&&L(he({k:B?"alert":ne.toLowerCase(),x:En,w:t.ui==="inventory"?qe.split(" ").length:void 0,id:B?Z(w):void 0,c:B?wt(w):void 0})),S(w,qe?!0:W,K);continue}let ae=o(bn(w),w);ae&&L(he({k:"tx",tag:ne.toLowerCase(),x:ae}))}S(w,W,K)}}return{entries:h,cut:g}}let y="",k=0,R=0,x=0,T=!1,U=!1,F,E=0,I=()=>{try{return Xe(location.pathname)}catch{return""}};function $(h){try{if(F=void 0,E=0,T||R>=t.maxViews||x>=Hr||!document.body)return;x++;let{entries:m,cut:g}=p(),A=I(),L=o(document.title,void 0,de),v=Ae(JSON.stringify([A,L,m],(O,z)=>O==="len"||O==="empty"?void 0:z)).toString(36),S=U;if(U=!1,v===y){S&&e("ui-same",{h:v,r:A,why:h});return}y=v,k=t.now(),R++,e("ui",he({v:R,h:v,why:h,r:A,t:L,cut:g,els:m}))}catch{}}function C(h){try{if(T||t.ui==="off"||R>=t.maxViews)return;let m=t.now();E||(E=m),F&&clearTimeout(F);let g=Math.min(Br,Math.max(0,E+_r-m));F=setTimeout(()=>$(h),g)}catch{}}let q,V=()=>{try{if(t.ui==="off"||!document.body||q||typeof MutationObserver=="undefined")return;q=new MutationObserver(h=>{try{h.some(g=>{var A;return!/^(SCRIPT|STYLE|LINK|META)$/.test((A=g.target.nodeName)!=null?A:"")})&&C("dom")}catch{}}),q.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["class","style","hidden","disabled","aria-hidden","aria-expanded","aria-checked","aria-selected","aria-invalid","open"]}),C("load")}catch{}},P=()=>V();t.ui!=="off"&&(document.body?V():document.addEventListener("DOMContentLoaded",P));let D=0,_=h=>{t.act==="off"||T||D>=Ur||(D++,e("act",he({...h,vh:y||void 0,dt:k?t.now()-k:void 0})))},Y=h=>{let m=h instanceof Element?h:void 0;return m&&kt(m)?m:void 0},H=h=>{let m=h;return{tag:h.tagName.toLowerCase(),ty:h.tagName==="INPUT"?m.type:void 0,nm:m.name||void 0,id:Z(h),lb:s(c(h),h,de)}},b=h=>m=>{try{if(t.act==="off")return;let g=m.target instanceof Element?m.target:void 0;if(g&&a("act",g))return;h(m)}catch{}};return{click:b(h=>{let m=h.target;if(!m||!(m instanceof Element))return;let g=m.closest(Jr);if(g&&kt(g)){let A=g;_({e:"click",k:"field",...H(g),chk:A.type==="checkbox"||A.type==="radio"?A.checked?1:0:void 0})}else _(g?{e:"click",...f(g,"act",t.act),k:g.tagName==="LABEL"?"label":"btn"}:{e:"click",k:"none",tag:m.tagName.toLowerCase(),id:Z(m),c:wt(m),x:s(bn(m),m,80)})}),focusIn:b(h=>{let m=Y(h.target);m&&_({e:"fin",...H(m)})}),focusOut:b(h=>{let m=Y(h.target);if(!m)return;let g=m,L=!(g.type==="checkbox"||g.type==="radio")&&m.tagName!=="SELECT"&&t.act!=="inventory"?ut(m):void 0;_({e:"fout",...H(m),len:L})}),submit:b(h=>{var g;let m=h.target;!m||m.tagName!=="FORM"||_({e:"submit",id:Z(m),nm:(g=m.getAttribute("name"))!=null?g:void 0,a:m.getAttribute("action")?i("act",t.act,Ie(m)):void 0})}),change:b(h=>{var A;let m=Y(h.target);if(!m)return;let g=m;if(m.tagName==="SELECT"){let L=m;_({e:"chg",...H(m),si:L.selectedIndex,ot:s((A=L.options[L.selectedIndex])==null?void 0:A.textContent,m,60)})}else(g.type==="checkbox"||g.type==="radio")&&_({e:"chg",...H(m),chk:g.checked?1:0})}),onRoute(){U=!0,E=0,C("nav")},onHide(){T=!0,F&&clearTimeout(F),F=void 0},dispose(){T=!0;try{F&&clearTimeout(F),q==null||q.disconnect(),document.removeEventListener("DOMContentLoaded",P)}catch{}}}}var je=Symbol.for("corbado.autocapture.probe"),At=16e3,kn=["page","ui","act","nav","res","store","net","form","err","console","dl","msg","glob","cev"],Xr={meta:5,page:5,ui:40,"ui-same":40,act:150,nav:50,res:40,store:5,net:150,"net-body":150,form:10,err:50,console:50,dl:100,msg:100,glob:2,cev:100,snapshot:50,corr:100,count:20},Wr=400,Zr=4e5,Gr=["els","rows","forms","names","args","fields"],Yr=250;function Me(t,e,n){return{mode:t,hash:e,reason:n,signal(){},disconnect(){}}}function Qr(t){return typeof t=="string"?t:t&&typeof t=="object"&&typeof t.level=="string"?t.level:"off"}function Sn(t,e){var r,o;let n=(r=j(()=>Ge(t)))!=null?r:"invalid";try{if(!Ze(t).ok)return Me("off",n,"invalid-config");if(!e||typeof e.sink!="function")return Me("off",n,"no-sink");if(typeof window=="undefined"||typeof document=="undefined")return Me("unavailable",n,"no-page");let i=window;if(i[je])return Me("unavailable",n,"already-running");let a=()=>{var d;return(d=j(()=>{var l;return(l=e.now)==null?void 0:l.call(e)}))!=null?d:Date.now()},u=(o=j(()=>{var d;return(d=e.sessionId)==null?void 0:d.call(e)}))!=null?o:void 0,c=Dt(t.when,{projectId:e.projectId,now:a(),sessionId:u,salt:n,client:qt(typeof navigator!="undefined"?navigator:void 0),integrationVersion:e.integrationVersion});if(c)return Me("off",n,`condition:${c}`);let f=new vt(t,e,n,a);return i[je]=f,f.start(),{mode:"active",hash:n,signal:d=>f.signal(d),disconnect:()=>{f.dispose(),i[je]===f&&delete i[je]}}}catch{try{delete window[je]}catch{}return Me("unavailable",n,"error")}}var vt=class{constructor(e,n,r,o){this.config=e;this.deps=n;this.hash=r;this.now=o;M(this,"pageId",st(12));M(this,"redactor");M(this,"taint",new ke);M(this,"levels",{});M(this,"disposers",[]);M(this,"disposed",!1);M(this,"items",0);M(this,"bytes",0);M(this,"perKind",new Map);M(this,"dropped",{budget:0,guard:0,size:0,cond:0,buffer:0});M(this,"buffer",[]);M(this,"bufferBytes",0);M(this,"streamingUntil",0);M(this,"tags");M(this,"netMatchers",[]);M(this,"netIds",new Map);M(this,"counts",new Map);M(this,"countsEmitted","");M(this,"snapshotsTaken",new Map);M(this,"corrState",new Map);M(this,"ui");M(this,"res");M(this,"lastTaintRefresh",0);M(this,"lastState");M(this,"hidden",!1);var i,a,u,c,f,d;this.redactor=new We((i=e.rules)!=null?i:[],st(16));for(let l of kn)this.levels[l]=Qr((a=e.surfaces)==null?void 0:a[l]);this.tags=(u=e.when)!=null&&u.tags?"unknown":"match";let s=l=>{l&&!this.netIds.has(l)&&(this.netIds.set(l,this.netMatchers.length),this.netMatchers.push(l))};for(let l of(f=(c=e.trigger)==null?void 0:c.on)!=null?f:[])s(l.net);for(let l of(d=e.actions)!=null?d:[])l.type==="correlate"?(s(l.learn.net),s(l.resolve.net)):s(l.on.net)}start(){var o;let e=s=>{var i,a;return le((i=this.config.surfaces)==null?void 0:i[s])?(a=this.config.surfaces)==null?void 0:a[s]:void 0};this.emit("meta",{v:Nt,lv:Object.fromEntries(kn.filter(s=>this.levels[s]!=="off").map(s=>[s,this.levels[s]])),trig:this.config.trigger?1:void 0,tags:(o=this.config.when)!=null&&o.tags?1:void 0});let n={level:s=>this.levels[s],emit:(s,i)=>this.emit(s,i),redactor:this.redactor,scope:(s,i)=>this.scope(s,i),now:this.now,onError:()=>this.dispatch({t:"error"})},r=s=>j(s);r(()=>this.refreshTaint(!0)),r(()=>sn(n)),r(()=>{var s,i;this.ui=wn({ui:this.levels.ui,act:this.levels.act,maxViews:(i=(s=e("ui"))==null?void 0:s.maxViews)!=null?i:30,emit:(a,u)=>this.emit(a,u),redactor:this.redactor,scope:(a,u)=>this.scope(a,u),now:this.now}),this.disposers.push(()=>{var a;return(a=this.ui)==null?void 0:a.dispose()})}),r(()=>this.installDomListeners()),r(()=>this.installNetwork(e("net"))),r(()=>this.installNavigation()),r(()=>{var i;let s=(i=this.deps.webauthn)==null?void 0:i.subscribe(a=>j(()=>Vt(this.taint,a)));typeof s=="function"&&this.disposers.push(s)}),r(()=>{var i;let s=e("res");this.res=an(n,s==null?void 0:s.hosts,(i=s==null?void 0:s.everyMs)!=null?i:5e3),this.disposers.push(this.res.dispose)}),r(()=>{(this.levels.err!=="off"||this.hasMatcher(s=>s.error===!0))&&this.disposers.push(dn(n))}),r(()=>{var s,i;return this.disposers.push(fn(n,(i=(s=e("console"))==null?void 0:s.levels)!=null?i:["error","warn"]))}),r(()=>this.disposers.push(ln(n))),r(()=>this.disposers.push(pn(n))),r(()=>this.disposers.push(mn(n))),r(()=>{let s=[setTimeout(()=>j(()=>un(n)),3e3),setTimeout(()=>j(()=>hn(n)),3e3)];this.disposers.push(()=>s.forEach(clearTimeout))}),r(()=>this.installSelectorWatch()),r(()=>this.installStateWatch()),r(()=>this.installHide(n))}dispose(){if(!this.disposed){this.disposed=!0;for(let e of this.disposers.splice(0))j(e);this.buffer=[],this.bufferBytes=0}}signal(e){j(()=>{typeof e=="string"&&e&&this.dispatch({t:"signal",name:e.slice(0,64)})})}hasMatcher(e){var r,o,s;let n=[...(o=(r=this.config.trigger)==null?void 0:r.on)!=null?o:[]];for(let i of(s=this.config.actions)!=null?s:[])i.type!=="correlate"&&n.push(i.on);return n.some(e)}scope(e,n){let r,o;try{r=location.hostname,o=location.pathname}catch{}return{surface:e,host:r,path:o,el:n}}context(){let e=j(()=>{var r,o;return(o=(r=this.deps).context)==null?void 0:o.call(r)});if(!e||typeof e!="object")return;let n={};for(let r of["state","flowType","step"]){let o=e[r];typeof o=="string"&&o&&(n[r]=o.slice(0,64))}return Object.keys(n).length?n:void 0}refreshTaint(e=!1){let n=this.now();!e&&n-this.lastTaintRefresh<Yr||(this.lastTaintRefresh=n,Kt(this.taint,document),j(()=>Jt(this.taint,document.cookie)))}emit(e,n){var r;try{if(this.disposed)return;let o=this.config.when;if(o!=null&&o.path&&!X(o.path,(r=j(()=>location.pathname))!=null?r:"")){this.dropped.cond++;return}let s=this.context();if(o!=null&&o.state&&!(s!=null&&s.state&&o.state.includes(s.state))){this.dropped.cond++;return}this.refreshTaint();let i=Fe(n,this.taint);if(i==null||typeof i!="object"){this.dropped.guard++;return}let a=this.now();for(let u of no(e,i)){if(!u){this.dropped.size++;continue}this.route({kind:u.kind,payload:u.payload,ts:a,ctx:s,bytes:fe(u.payload)})}}catch{this.dropped.guard++}}route(e){var r,o;if(this.tags==="unknown"&&this.checkTags(),this.tags==="mismatch"||this.disposed)return;let n=this.config.trigger;if(this.tags==="unknown"||n&&this.now()>this.streamingUntil){this.buffer.push(e),this.bufferBytes+=e.bytes;let s=(r=n==null?void 0:n.buffer)!=null?r:300,i=(o=n==null?void 0:n.bufferBytes)!=null?o:3e5;for(;this.buffer.length>s||this.bufferBytes>i;){let a=this.buffer.shift();this.bufferBytes-=a.bytes,this.dropped.buffer++}return}this.deliver(e)}checkTags(){var n,r;let e=Ht((n=this.config.when)==null?void 0:n.tags,(r=j(()=>{var o,s;return(s=(o=this.deps).tags)==null?void 0:s.call(o)}))!=null?r:void 0);if(e!==this.tags){if(this.tags=e,e==="mismatch"){this.buffer=[],this.bufferBytes=0,this.dispose();return}e==="match"&&(!this.config.trigger||this.now()<=this.streamingUntil)&&this.flushBuffer()}}flushBuffer(){let e=this.buffer;this.buffer=[],this.bufferBytes=0;for(let n of e)this.deliver(n)}fireTrigger(){var e,n;this.streamingUntil=this.now()+((n=(e=this.config.trigger)==null?void 0:e.streamMs)!=null?n:3e4),this.tags==="unknown"&&this.checkTags(),this.tags==="match"&&this.flushBuffer()}deliver(e){var s,i,a,u,c,f;let n=this.config.budgets,r=(a=(i=(s=n==null?void 0:n.perKind)==null?void 0:s[e.kind])!=null?i:Xr[e.kind])!=null?a:50,o=(u=this.perKind.get(e.kind))!=null?u:0;if(this.items>=((c=n==null?void 0:n.items)!=null?c:Wr)||this.bytes+e.bytes>((f=n==null?void 0:n.bytes)!=null?f:Zr)||o>=r){this.dropped.budget++;return}this.items++,this.bytes+=e.bytes,this.perKind.set(e.kind,o+1),j(()=>this.deps.sink({kind:e.kind,payload:e.payload,pageId:this.pageId,cfg:this.hash,...e.ctx?{ctx:e.ctx}:{},ts:e.ts}))}dispatch(e){var n,r,o;try{if(this.disposed)return;for(let s of(r=(n=this.config.trigger)==null?void 0:n.on)!=null?r:[])if(this.matches(s,e)){this.fireTrigger();break}((o=this.config.actions)!=null?o:[]).forEach((s,i)=>{var a;s.type==="correlate"||!this.matches(s.on,e)||(s.type==="count"?this.counts.set(s.name,((a=this.counts.get(s.name))!=null?a:0)+1):this.snapshot(s,i,e))})}catch{}}matches(e,n){var r,o,s,i;switch(n.t){case"net":{let a=e.net;if(!a)return!1;let u=n.x;if(!Oe(a,u.url,u.method))return!1;if(a.status!==void 0){let f=u.outcome!=="load"||u.status===0||u.status>=400;if(a.status==="ok"&&f||a.status==="error"&&!f||Array.isArray(a.status)&&!a.status.includes(u.status))return!1}let c=this.netIds.get(a);return!(a.body&&!((o=(r=n.req)==null?void 0:r.hits)!=null&&o.includes(c))||a.response&&!((i=(s=n.res)==null?void 0:s.hits)!=null&&i.includes(c)))}case"click":return!!e.click&&!!j(()=>n.el.closest(e.click));case"submit":return e.submit===!0||typeof e.submit=="string"&&!!j(()=>n.form.matches(e.submit));case"selector":return e.selector===n.sel;case"signal":return e.signal===n.name;case"state":return e.state===n.state;case"error":return e.error===!0}}snapshot(e,n,r){var i,a,u,c,f,d,l,p;let o=(i=this.snapshotsTaken.get(n))!=null?i:0;if(o>=((a=e.max)!=null?a:20))return;this.snapshotsTaken.set(n,o+1),this.refreshTaint(!0);let s={name:e.name,on:r.t};if((u=e.fields)!=null&&u.length&&(s.fields=e.fields.map(y=>this.snapshotField(y))),(c=e.texts)!=null&&c.length&&(s.texts=e.texts.map(y=>{var R;let k=(R=j(()=>Array.from(document.querySelectorAll(y)).slice(0,5)))!=null?R:[];return{sel:y,x:k.map(x=>this.redactor.text(St(x.textContent,300),this.scope("form",x),"values")).filter(Boolean)}})),r.t==="net"){let y=(d=(f=r.req)==null?void 0:f.snap)==null?void 0:d[n],k=(p=(l=r.res)==null?void 0:l.snap)==null?void 0:p[n];y&&(s.req=y),k&&(s.res=k),s.s=r.x.status}this.emit("snapshot",s)}snapshotField(e){var c,f,d;let n=j(()=>document.querySelector(e.selector)),r={as:(c=e.as)!=null?c:e.selector,found:!!n};if(!n)return r;let o=this.scope("form",n),s={method:(f=e.method)!=null?f:"class",values:e.values,keepPrefix:e.keepPrefix,keepStart:e.keepStart,keepEnd:e.keepEnd},i=ze(n,s,(l,p)=>{let y=this.redactor.method(l,p,o);return y===ie?void 0:y});i!==void 0&&(r.v=i);let a=n.validity;if(a){let l=["valueMissing","typeMismatch","patternMismatch","tooShort","tooLong","rangeUnderflow","rangeOverflow","stepMismatch","badInput","customError"].filter(p=>a[p]);l.length&&(r.valid=l)}if(n.getAttribute("aria-invalid")==="true"&&(r.inv=1),n.tagName==="SELECT"){let l=n;r.si=l.selectedIndex;let p=(d=l.options[l.selectedIndex])==null?void 0:d.textContent;p&&(r.opt=this.redactor.text(St(p,100),o,"values"))}let u=to(n);return u&&(r.err=this.redactor.text(u,o,"values")),r}netSurfaceWants(e,n,r){return!(this.levels.net==="off"||bt.test(e.hostname)||e.pathname.startsWith("/v1/observe/")||r!=null&&r.hosts&&!X(r.hosts,e.hostname)||r!=null&&r.excludeHosts&&X(r.excludeHosts,e.hostname)||r!=null&&r.paths&&!X(r.paths,e.pathname)||r!=null&&r.methods&&!r.methods.includes(n))}installNetwork(e){var d,l;if(this.levels.net==="off"&&this.netMatchers.length===0)return;let n=p=>j(()=>new URL(p,location.href)),r=this.levels.net,o=r!=="inventory"&&(e==null?void 0:e.bodies)!==!1,s=((d=this.config.actions)!=null?d:[]).map((p,y)=>[p,y]).filter(p=>p[0].type==="correlate"),i=((l=this.config.actions)!=null?l:[]).map((p,y)=>[p,y]).filter(p=>p[0].type==="snapshot"&&!!p[0].on.net),a=p=>(y,k)=>{var R,x,T,U;try{if(this.disposed)return;let F=n(k.url);if(!F)return;let E={},I,$=!1,C=()=>($||($=!0,I=eo(y)),I);o&&this.netSurfaceWants(F,k.method,e)&&(E.b=this.redactor.body(y,{surface:"net",host:F.hostname,path:F.pathname,part:p},r)),this.netMatchers.forEach((q,V)=>{var D;let P=p==="request"?q.body:q.response;P&&Oe(q,k.url,k.method)&&Ke(C(),P)&&((D=E.hits)!=null?D:E.hits=[]).push(V)});for(let[q,V]of s){let P=q.learn;((R=P.from)!=null?R:"response")===p&&Oe(P.net,k.url,k.method)&&Ke(C(),p==="request"?P.net.body:P.net.response)&&this.learn(q,V,C());let D=q.resolve;if(((x=D.from)!=null?x:"request")===p&&Oe(D.net,k.url,k.method)&&Ke(C(),p==="request"?D.net.body:D.net.response)){let _=this.resolve(q,V,C(),F);_&&(((T=E.corr)!=null?T:E.corr={})[V]=_)}}for(let[q,V]of i){let P=p==="request"?q.request:q.response;P!=null&&P.length&&Oe(q.on.net,k.url,k.method)&&(((U=E.snap)!=null?U:E.snap={})[V]=this.picks(P,C(),{surface:"net",host:F.hostname,path:F.pathname,part:p}))}return Object.keys(E).length?E:void 0}catch{return}},u=(p,y)=>{var k,R,x,T;for(let[U,F]of Object.entries((k=y==null?void 0:y.corr)!=null?k:{})){let E=Number(U),I=((R=this.config.actions)!=null?R:[])[E],$=this.corrState.get(E);!I||!$||$.emitted.has(p)||$.n>=((x=I.max)!=null?x:50)||($.emitted.add(p),$.emitted.size>500&&$.emitted.clear(),$.n++,this.emit((T=I.kind)!=null?T:"corr",{name:I.name,...F,n:$.n,...$.offered?{offered:$.offered}:{}}))}},c={id:"probe",match:(p,y)=>{try{return this.disposed?!1:this.netSurfaceWants(p,y,e)||this.netMatchers.some(k=>Oe(k,p.href,y))}catch{return!1}},projectRequest:a("request"),projectResponse:a("response"),onRequest:p=>{j(()=>u(p.requestId,p.requestBody))},onExchange:p=>{try{if(this.disposed)return;let y=p.requestBody,k=p.responseBody,R=p.requestHeaders;R&&j(()=>{var T;return Xt(this.taint,(T=R.authorization)!=null?T:R.Authorization)});let x=n(p.url);if(x&&this.netSurfaceWants(x,p.method,e)){let T={surface:"net",host:x.hostname,path:x.pathname,part:"url"};this.emit("net",{m:p.method,url:this.redactor.url(p.url,T,r),rurl:p.responseUrl&&p.responseUrl!==p.url?this.redactor.url(p.responseUrl,T,r):void 0,s:p.status,o:p.outcome,d:p.durationMs!==void 0?Math.round(p.durationMs):void 0,tr:p.transport,rq:y==null?void 0:y.b,rs:k==null?void 0:k.b})}u(p.requestId,y),u(p.requestId,k),this.dispatch({t:"net",x:p,req:y,res:k})}catch{}}};if(this.deps.network){let p=this.deps.network.subscribe(c);typeof p=="function"&&this.disposers.push(p);return}let f=It({match:c.match,bodyCapture:{request:(p,y)=>c.projectRequest(p,y),response:(p,y)=>c.projectResponse(p,y)},onRequest:c.onRequest,onExchange:c.onExchange});this.disposers.push(()=>f.disconnect())}learn(e,n,r){var c,f;let o=e.learn,s=Ve(r,o.items).slice(0,50);if(!s.length)return;let i=(c=this.corrState.get(n))!=null?c:{map:new Map,n:0,emitted:new Set};this.corrState.set(n,i),i.map.clear();let a={method:(f=o.method)!=null?f:o.values?"enum":"class",values:o.values},u={surface:"net"};i.offered=s.map(d=>{var k;let l=$e(d,o.key),p=$e(d,o.value);(typeof l=="string"||typeof l=="number")&&i.map.size<200&&i.map.set(String(l),p);let y={value:this.methodValue(p,a,u)};for(let R of(k=o.count)!=null?k:[])y[R]=Gt($e(d,R));return y})}resolve(e,n,r,o){var d,l,p;let s=(d=this.corrState.get(n))!=null?d:{map:new Map,n:0,emitted:new Set};this.corrState.set(n,s);let i;for(let y of Pe(e.resolve.key)){let k=$e(r,y);if(typeof k=="string"||typeof k=="number"){i=String(k);break}}let a=e.learn,u={method:(l=a.method)!=null?l:a.values?"enum":"class",values:a.values},c=i!==void 0&&s.map.has(i),f={value:c?this.methodValue(s.map.get(i),u,{surface:"net"}):"unknown",known:c};return(p=e.resolve.fields)!=null&&p.length&&(f.fields=this.picks(e.resolve.fields,r,{surface:"net",host:o.hostname,path:o.pathname,part:"request"})),f}picks(e,n,r){var s,i;let o={};for(let a of e){let u={method:(s=a.method)!=null?s:"class",values:a.values,keepPrefix:a.keepPrefix,keepStart:a.keepStart,keepEnd:a.keepEnd},c=this.methodValue($e(n,a.path),u,r);c!==void 0&&(o[(i=a.as)!=null?i:a.path]=c)}return o}methodValue(e,n,r){if(e===void 0)return;let o=this.redactor.method(e,n,r);return o===ie?void 0:o}installNavigation(){if(this.levels.nav==="off"&&this.levels.ui==="off")return;let e=r=>{var o;try{if(this.disposed)return;this.levels.nav!=="off"&&this.emit("nav",{src:r.source,url:this.redactor.url(r.path+r.search+r.hash,this.scope("nav"),this.levels.nav)}),(o=this.ui)==null||o.onRoute()}catch{}};if(this.deps.navigation){let r=this.deps.navigation.subscribe(e);typeof r=="function"&&this.disposers.push(r);return}let n=$t({onNavigate:e});this.disposers.push(()=>n.disconnect())}installDomListeners(){let e={capture:!0,passive:!0},n=[["click",r=>{var o;(o=this.ui)==null||o.click(r),r.target instanceof Element&&this.dispatch({t:"click",el:r.target})}],["focusin",r=>{var o;return(o=this.ui)==null?void 0:o.focusIn(r)}],["focusout",r=>{var o;this.refreshTaint(!0),(o=this.ui)==null||o.focusOut(r)}],["change",r=>{var o;this.refreshTaint(!0),(o=this.ui)==null||o.change(r)}],["submit",r=>{var o;this.refreshTaint(!0),(o=this.ui)==null||o.submit(r),r.target instanceof Element&&this.dispatch({t:"submit",form:r.target})}]];for(let[r,o]of n){let s=i=>{try{this.disposed||o(i)}catch{}};try{document.addEventListener(r,s,e),this.disposers.push(()=>document.removeEventListener(r,s,e))}catch{}}}installSelectorWatch(){var i,a,u;let e=new Set;for(let c of[...(a=(i=this.config.trigger)==null?void 0:i.on)!=null?a:[],...((u=this.config.actions)!=null?u:[]).flatMap(f=>f.type==="correlate"?[]:[f.on])])c.selector&&e.add(c.selector);if(!e.size||typeof MutationObserver=="undefined")return;let n=new Map,r=()=>{for(let c of e){let f=j(()=>document.querySelector(c)),d=!!f&&!f.hidden&&f.getAttribute("aria-hidden")!=="true";d&&!n.get(c)&&this.dispatch({t:"selector",sel:c}),n.set(c,d)}},o,s=new MutationObserver(()=>{o||(o=setTimeout(()=>{o=void 0,j(r)},200))});s.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","aria-hidden","class","style"]}),j(r),this.disposers.push(()=>{s.disconnect(),o&&clearTimeout(o)})}installStateWatch(){var r;let e=(r=this.config.when)!=null&&r.tags?setInterval(()=>{this.tags==="unknown"&&j(()=>this.checkTags())},2e3):void 0;if(e&&this.disposers.push(()=>clearInterval(e)),!this.hasMatcher(o=>o.state!==void 0)||!this.deps.context)return;let n=setInterval(()=>{j(()=>{var s;let o=(s=this.context())==null?void 0:s.state;o&&o!==this.lastState&&this.dispatch({t:"state",state:o}),this.lastState=o})},500);this.disposers.push(()=>clearInterval(n))}installHide(e){let n=()=>{if(!this.counts.size)return;let i=Object.fromEntries(this.counts),a=JSON.stringify(i);a!==this.countsEmitted&&(this.countsEmitted=a,this.emit("count",{counts:i}))},r=()=>{try{if(document.visibilityState!=="hidden"||this.disposed)return;n()}catch{}},o=()=>{var i,a;try{if(this.disposed||this.hidden)return;this.hidden=!0,(i=this.ui)==null||i.onHide(),cn(e),(a=this.res)==null||a.flush(),n();let u=Object.fromEntries(Object.entries(this.dropped).filter(([,c])=>c>0));(Object.keys(u).length||this.buffer.length)&&this.emit("meta",{end:1,items:this.items,dropped:u,buffered:this.buffer.length}),this.buffer=[],this.bufferBytes=0}catch{}},s=i=>{i.persisted&&(this.hidden=!1)};try{document.addEventListener("visibilitychange",r,!0),window.addEventListener("pagehide",o,!0),window.addEventListener("pageshow",s,!0),this.disposers.push(()=>{document.removeEventListener("visibilitychange",r,!0),window.removeEventListener("pagehide",o,!0),window.removeEventListener("pageshow",s,!0)})}catch{}}},St=(t,e)=>(t!=null?t:"").replace(/\s+/g," ").trim().slice(0,e);function Oe(t,e,n){let r;try{r=new URL(e,typeof location!="undefined"?location.href:void 0)}catch{return!1}return!(t.host!==void 0&&!X(t.host,r.hostname)||t.path!==void 0&&!X(t.path,r.pathname)||t.method!==void 0&&!Pe(t.method).some(o=>o.toUpperCase()===n.toUpperCase()))}function eo(t){try{if(typeof t=="string"){if(t.length>3e5)return;let e=se(t);if(e!==void 0)return e;if(/^[^\s<>{}=&]+=[^\s<>]*(&[^\s<>{}=&]+=[^\s<>]*)*$/.test(t.trim())){let n={};return new URLSearchParams(t).forEach((r,o)=>n[o]=r),n}return}if(typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams){let e={};return t.forEach((n,r)=>e[r]=n),e}if(typeof FormData!="undefined"&&t instanceof FormData){let e={};return t.forEach((n,r)=>e[r]=typeof n=="string"?n:void 0),e}return t&&typeof t=="object"&&!(typeof Blob!="undefined"&&t instanceof Blob)&&!(t instanceof ArrayBuffer)&&!ArrayBuffer.isView(t)?t:void 0}catch{return}}function to(t){var e,n;try{let r=`${(e=t.getAttribute("aria-describedby"))!=null?e:""} ${(n=t.getAttribute("aria-errormessage"))!=null?n:""}`.trim(),o=[];for(let i of r.split(/\s+/).filter(Boolean).slice(0,4)){let a=document.getElementById(i);a!=null&&a.textContent&&o.push(a.textContent)}if(!o.length){let i=t.parentElement;for(let a=0;a<3&&i&&!o.length;a++,i=i.parentElement){let u=i.querySelector('[role=alert], [aria-live], .error, [class*="error"], [class*="invalid"]');u&&u!==t&&u.textContent&&o.push(u.textContent)}}return St(o.join(" "),200)||void 0}catch{return}}function no(t,e){if(fe(e)<=At)return[{kind:t,payload:e}];if(Array.isArray(e))return vn(e,{},void 0).map(r=>r?{kind:t,payload:r}:void 0);for(let r of Gr){let o=e[r];if(Array.isArray(o)&&o.length>1){let s={...e};return delete s[r],vn(o,s,r).map(i=>i?{kind:t,payload:i}:void 0)}}if(t==="net"&&(e.rq!==void 0||e.rs!==void 0)){let r=Math.random().toString(36).slice(2,10),o={...e,rid:r},s=[];for(let a of["rq","rs"]){if(o[a]===void 0)continue;let u=o[a];o[a]="<split>";let c=Qe({rid:r,dir:a,body:u});s.push(c?{kind:"net-body",payload:c}:void 0)}let i=Qe(o);return[i?{kind:t,payload:i}:void 0,...s]}let n=Qe(e);return[n?{kind:t,payload:n}:void 0]}function vn(t,e,n){let r=fe(e)+60,o=At-r,s=[],i=[],a=2;for(let u of t){let c=u,f=fe(c)+1;if(f>o){if(c=Qe(c,o),c===void 0)continue;f=fe(c)+1}a+f>o&&i.length&&(s.push(i),i=[],a=2),i.push(c),a+=f}return i.length&&s.push(i),s.map((u,c)=>n===void 0?u:{...e,part:c+1,parts:s.length,[n]:u})}function et(t,e){if(typeof t=="string")return t.length>e?`<cut:${t.length}>`:t;if(Array.isArray(t))return t.map(n=>et(n,e));if(le(t)){let n={};for(let[r,o]of Object.entries(t))n[r]=et(o,e);return n}return t}function Et(t,e){if(t===null||typeof t!="object")return t;if(e<=0)return Array.isArray(t)?`<cut:arr${t.length}>`:"<cut:obj>";if(Array.isArray(t))return t.map(r=>Et(r,e-1));let n={};for(let[r,o]of Object.entries(t))n[r]=Et(o,e-1);return n}function Qe(t,e=At){if(fe(t)<=e)return t;for(let r of[4096,1024,256,64]){let o=et(t,r);if(fe(o)<=e)return o}let n=et(t,64);for(let r=6;r>=1;r--){let o=Et(n,r);if(fe(o)<=e)return o;n=o}}0&&(module.exports={ProbeTaint,applyGuards,createProbeTaint,probeConfigHash,probeConfigSchema,startProbes,validateProbeConfig});
package/dist/probe.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{f as Ke,g as Ze,h as Ye}from"./chunk-7E5QDUX5.mjs";import{A as st,B as ot,a as Ee,b as Se,c as Qe,d as Q,e as z,f as $e,g as Ie,h as w,i as ne,j as re,k as H,l as he,m as Pe,n as Ae,o as Oe,p as Ne,q as Rt,r as et,s as tt,t as nt,u as rt,v as je,w as se,x as He,y as ge,z as ye}from"./chunk-WY3VIPYX.mjs";import{a as S}from"./chunk-JR557W27.mjs";function it(t){var u,c,p,d;let e=(u=t==null?void 0:t.userAgent)!=null?u:"",r=t==null?void 0:t.userAgentData,n=((c=r==null?void 0:r.brands)!=null?c:[]).map(m=>m.brand.toLowerCase()),s="other";n.some(m=>m.includes("edge"))?s="edge":n.some(m=>m.includes("opera"))?s="opera":/SamsungBrowser\//.test(e)?s="samsung":/Edg(e|A|iOS)?\//.test(e)?s="edge":/OPR\/|Opera/.test(e)?s="opera":/Firefox\/|FxiOS\//.test(e)?s="firefox":n.some(m=>m.includes("chrome")||m.includes("chromium"))||/Chrome\/|CriOS\//.test(e)?s="chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&(s="safari");let o=((p=r==null?void 0:r.platform)!=null?p:"").toLowerCase(),i="other";o==="android"||/Android/.test(e)?i="android":/iPhone|iPad|iPod/.test(e)||/Macintosh/.test(e)&&((d=t==null?void 0:t.maxTouchPoints)!=null?d:0)>1?i="ios":o==="windows"||/Windows/.test(e)?i="windows":o==="chrome os"||o==="chromeos"||/CrOS/.test(e)?i="chromeos":o==="macos"||/Macintosh|Mac OS X/.test(e)?i="macos":(o==="linux"||/Linux/.test(e))&&(i="linux");let a="desktop";return/iPad|Tablet/.test(e)||i==="android"&&!/Mobile/.test(e)||i==="ios"&&/Macintosh/.test(e)?a="tablet":((r==null?void 0:r.mobile)===!0||/Mobi|iPhone|iPod/.test(e))&&(a="mobile"),{browser:s,os:i,device:a}}function $t(t,e,r){return t===void 0||t>=1?!0:t<=0?!1:(e?Ee(`${r}:${e}`)/4294967296:Math.random())<t}function It(t,e){if(!t)return!1;let r=/^\d{4}-\d{2}-\d{2}$/.test(t)?Date.parse(`${t}T23:59:59.999Z`):Date.parse(t);return!Number.isFinite(r)||e>r}function at(t,e){var r;if(t){if(t.projects&&!t.projects.includes(e.projectId))return"projects";if(It(t.until,e.now))return"until";if(t.browser&&!t.browser.includes(e.client.browser))return"browser";if(t.os&&!t.os.includes(e.client.os))return"os";if(t.device&&!t.device.includes(e.client.device))return"device";if(t.integrationVersion&&!z(t.integrationVersion,(r=e.integrationVersion)!=null?r:""))return"integrationVersion";if(!$t(t.sample,e.sessionId,e.salt))return"sample"}}function ut(t,e){if(!t)return"match";let r=!1;for(let[n,s]of Object.entries(t)){let o=e==null?void 0:e[n];if(o==null||o===""){r=!0;continue}if(!s.includes("*")&&!s.includes(String(o)))return"mismatch"}return r?"unknown":"match"}var ct=2e3;function ae(t){if(typeof t=="string"&&t.length<=3e5){let e=ne(t);if(e!==void 0)return e}return t}function Ot(t,e){let r=[ae(t)];for(;r.length&&e.length<ct;){let n=r.shift();if(n===null||typeof n!="object")continue;Array.isArray(n)||e.push(n);let s=Array.isArray(n)?n:Object.values(n);for(let o of s.slice(0,200)){let i=ae(o);i!==null&&typeof i=="object"&&r.push(i)}}}function Le(t,e){let r=[ae(t)];for(let n of e.split(".").filter(Boolean)){let s=[];if(n==="**"){for(let u of r)Ot(u,s);r=s;continue}let o=n.endsWith("[]"),i=o?n.slice(0,-2):n,a=u=>{let c=i===""?u:re(u)?ae(u[i]):void 0;if(c!==void 0)if(o){if(Array.isArray(c))for(let p of c.slice(0,200))s.push(ae(p))}else s.push(c)};for(let u of r){if(s.length>=ct)break;if(Array.isArray(u)&&i!=="")for(let c of u.slice(0,200))a(ae(c));else a(u)}r=s}return r}function ue(t,e){return Le(t,e)[0]}function Te(t,e){if(!e)return!0;for(let[r,n]of Object.entries(e)){let s=Array.isArray(n)?n:[n];if(!Le(t,r).some(i=>i!=null&&s.includes(String(i))))return!1}return!0}function ft(t){return t==null?0:Array.isArray(t)?t.length:typeof t=="object"?Object.keys(t).length:1}var Nt={enum:["off","inventory","shape","values"]},jt={enum:["drop","presence","length","class","shape","hash","mask","enum","clear"]},B={type:"array",items:{type:"string",minLength:1,maxLength:200},maxItems:100},ce={anyOf:[{type:"string",minLength:1,maxLength:200},B]},dt={type:"object",maxProperties:20,additionalProperties:{anyOf:[{type:"string",maxLength:200},B]}},qe={values:B,keepPrefix:{type:"integer",minimum:0,maximum:64},keepStart:{type:"integer",minimum:0,maximum:64},keepEnd:{type:"integer",minimum:0,maximum:64}},D=(t={})=>({anyOf:[{$ref:"#/$defs/level"},{type:"object",required:["level"],additionalProperties:!1,properties:{level:{$ref:"#/$defs/level"},...t}}]}),Ht=["page","ui","act","nav","res","store","net","form","err","console","dl","msg","glob","cev"],oe={type:"string",minLength:1,maxLength:200,pattern:"^[^\\s]+$"},De={type:"object",required:["path"],additionalProperties:!1,properties:{path:oe,as:{type:"string",minLength:1,maxLength:64},method:{$ref:"#/$defs/method"},...qe}},Be={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://corbado.com/schemas/autocapture/probe-config-v1.json",title:"Corbado autocapture probe config (v1)",type:"object",required:["v"],additionalProperties:!1,properties:{v:{const:1},name:{type:"string",maxLength:120},when:{$ref:"#/$defs/when"},trigger:{$ref:"#/$defs/trigger"},surfaces:{type:"object",additionalProperties:!1,properties:{page:D(),ui:D({maxViews:{type:"integer",minimum:1,maximum:100}}),act:D(),nav:D(),res:D({hosts:B,everyMs:{type:"integer",minimum:1e3,maximum:6e5}}),store:D(),net:D({hosts:B,excludeHosts:B,paths:B,methods:{type:"array",items:{type:"string",pattern:"^[A-Z]{3,10}$"},maxItems:10},bodies:{type:"boolean"}}),form:D(),err:D(),console:D({levels:{type:"array",items:{enum:["error","warn","info","log","debug"]},maxItems:5}}),dl:D(),msg:D(),glob:D(),cev:D()}},rules:{type:"array",maxItems:200,items:{$ref:"#/$defs/rule"}},actions:{type:"array",maxItems:50,items:{$ref:"#/$defs/action"}},budgets:{type:"object",additionalProperties:!1,properties:{items:{type:"integer",minimum:1,maximum:2e3},bytes:{type:"integer",minimum:1e3,maximum:2e6},perKind:{type:"object",maxProperties:40,additionalProperties:{type:"integer",minimum:0,maximum:2e3}}}}},$defs:{level:Nt,method:jt,surfaceName:{enum:Ht},when:{type:"object",additionalProperties:!1,properties:{projects:B,until:{type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}([T ].+)?$"},sample:{type:"number",minimum:0,maximum:1},browser:{type:"array",items:{enum:["chrome","edge","safari","firefox","samsung","opera","other"]}},os:{type:"array",items:{enum:["windows","macos","ios","android","linux","chromeos","other"]}},device:{type:"array",items:{enum:["desktop","mobile","tablet"]}},path:B,state:B,tags:{type:"object",maxProperties:10,additionalProperties:B},integrationVersion:B}},netMatch:{type:"object",additionalProperties:!1,properties:{host:ce,path:ce,method:ce,status:{anyOf:[{enum:["ok","error"]},{type:"array",items:{type:"integer",minimum:0,maximum:999}}]},body:dt,response:dt}},match:{type:"object",additionalProperties:!1,minProperties:1,properties:{net:{$ref:"#/$defs/netMatch"},selector:{type:"string",minLength:1,maxLength:300},click:{type:"string",minLength:1,maxLength:300},submit:{anyOf:[{const:!0},{type:"string",minLength:1,maxLength:300}]},signal:{type:"string",minLength:1,maxLength:64},state:{type:"string",minLength:1,maxLength:64},error:{const:!0}}},trigger:{type:"object",required:["on"],additionalProperties:!1,properties:{on:{type:"array",minItems:1,maxItems:20,items:{$ref:"#/$defs/match"}},buffer:{type:"integer",minimum:1,maximum:2e3},bufferBytes:{type:"integer",minimum:1e3,maximum:2e6},streamMs:{type:"integer",minimum:0,maximum:36e5}}},rule:{type:"object",required:["method"],additionalProperties:!1,properties:{surface:{anyOf:[{$ref:"#/$defs/surfaceName"},{type:"array",items:{$ref:"#/$defs/surfaceName"}}]},host:ce,path:ce,key:ce,selector:{type:"string",minLength:1,maxLength:300},part:{enum:["url","request","response"]},method:{$ref:"#/$defs/method"},...qe}},action:{oneOf:[{type:"object",required:["type","name","on"],additionalProperties:!1,properties:{type:{const:"snapshot"},name:{type:"string",pattern:"^[A-Za-z0-9_.-]{1,64}$"},on:{$ref:"#/$defs/match"},fields:{type:"array",maxItems:30,items:{type:"object",required:["selector"],additionalProperties:!1,properties:{selector:{type:"string",minLength:1,maxLength:300},as:{type:"string",minLength:1,maxLength:64},method:{$ref:"#/$defs/method"},...qe}}},texts:{type:"array",maxItems:20,items:{type:"string",minLength:1,maxLength:300}},request:{type:"array",maxItems:30,items:De},response:{type:"array",maxItems:30,items:De},max:{type:"integer",minimum:1,maximum:200}}},{type:"object",required:["type","name","learn","resolve"],additionalProperties:!1,properties:{type:{const:"correlate"},name:{type:"string",pattern:"^[A-Za-z0-9_.-]{1,64}$"},kind:{type:"string",pattern:"^[a-z][a-z0-9_-]{0,31}$"},learn:{type:"object",required:["net","items","key","value"],additionalProperties:!1,properties:{net:{$ref:"#/$defs/netMatch"},from:{enum:["request","response"]},items:oe,key:oe,value:oe,method:{$ref:"#/$defs/method"},values:B,count:{type:"array",maxItems:10,items:oe}}},resolve:{type:"object",required:["net","key"],additionalProperties:!1,properties:{net:{$ref:"#/$defs/netMatch"},from:{enum:["request","response"]},key:{anyOf:[oe,{type:"array",minItems:1,maxItems:10,items:oe}]},fields:{type:"array",maxItems:20,items:De}}},max:{type:"integer",minimum:1,maximum:500}}},{type:"object",required:["type","name","on"],additionalProperties:!1,properties:{type:{const:"count"},name:{type:"string",pattern:"^[A-Za-z0-9_.-]{1,64}$"},on:{$ref:"#/$defs/match"}}}]}}},Dt=Be;function qt(t){var r;let e=t.replace(/^#\/\$defs\//,"");return(r=Be.$defs[e])!=null?r:{}}function Bt(t,e){switch(t){case"object":return!!e&&typeof e=="object"&&!Array.isArray(e);case"array":return Array.isArray(e);case"string":return typeof e=="string";case"integer":return typeof e=="number"&&Number.isInteger(e);case"number":return typeof e=="number"&&Number.isFinite(e);case"boolean":return typeof e=="boolean";default:return!1}}function ie(t,e,r,n){var s,o;if(!(n.length>50)){if(typeof t.$ref=="string")return ie(qt(t.$ref),e,r,n);if(Array.isArray(t.anyOf)){for(let i of t.anyOf){let a=[];if(ie(i,e,r,a),a.length===0)return}n.push(`${r}: does not match any allowed form`);return}if(Array.isArray(t.oneOf)){let i=t.oneOf,a=e&&typeof e=="object"?e.type:void 0,u=i.find(c=>{var p,d;return((d=(p=c.properties)==null?void 0:p.type)==null?void 0:d.const)===a});if(!u){let c=i.map(p=>p.properties.type.const).join(", ");n.push(`${r}.type: must be one of ${c}`);return}return ie(u,e,r,n)}if("const"in t&&e!==t.const){n.push(`${r}: must be ${JSON.stringify(t.const)}`);return}if(Array.isArray(t.enum)&&!t.enum.includes(e)){n.push(`${r}: must be one of ${t.enum.join(", ")}`);return}if(typeof t.type=="string"&&!Bt(t.type,e)){n.push(`${r}: must be ${t.type}`);return}if(typeof e=="string"&&(typeof t.minLength=="number"&&e.length<t.minLength&&n.push(`${r}: too short`),typeof t.maxLength=="number"&&e.length>t.maxLength&&n.push(`${r}: too long`),typeof t.pattern=="string"&&!new RegExp(t.pattern).test(e)&&n.push(`${r}: invalid format`)),typeof e=="number"&&(typeof t.minimum=="number"&&e<t.minimum&&n.push(`${r}: must be \u2265 ${t.minimum}`),typeof t.maximum=="number"&&e>t.maximum&&n.push(`${r}: must be \u2264 ${t.maximum}`)),Array.isArray(e)&&(typeof t.minItems=="number"&&e.length<t.minItems&&n.push(`${r}: too few items`),typeof t.maxItems=="number"&&e.length>t.maxItems&&n.push(`${r}: too many items`),t.items&&e.forEach((i,a)=>ie(t.items,i,`${r}[${a}]`,n))),e&&typeof e=="object"&&!Array.isArray(e)){let i=e,a=(s=t.properties)!=null?s:{},u=Object.keys(i);typeof t.minProperties=="number"&&u.length<t.minProperties&&n.push(`${r}: must not be empty`),typeof t.maxProperties=="number"&&u.length>t.maxProperties&&n.push(`${r}: too many properties`);for(let c of(o=t.required)!=null?o:[])c in i||n.push(`${r}.${c}: required`);for(let c of u)a[c]?ie(a[c],i[c],`${r}.${c}`,n):t.additionalProperties===!1?n.push(`${r}.${c}: unknown property`):t.additionalProperties&&typeof t.additionalProperties=="object"&&ie(t.additionalProperties,i[c],`${r}.${c}`,n)}}}function Ut(t){if(typeof document=="undefined")return!1;try{return document.createDocumentFragment().querySelector(t),!1}catch{return!0}}function _t(t,e){var i,a,u,c,p;let r=(i=t.when)==null?void 0:i.until;r!==void 0&&!Number.isFinite(Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(r)?`${r}T00:00:00Z`:r))&&e.push("$.when.until: not a valid date");let n=[];((a=t.rules)!=null?a:[]).forEach((d,m)=>{var l;n.push([`$.rules[${m}].selector`,d.selector]),d.method==="enum"&&!((l=d.values)!=null&&l.length)&&e.push(`$.rules[${m}].values: required for method enum`)});let s=[];((c=(u=t.trigger)==null?void 0:u.on)!=null?c:[]).forEach((d,m)=>s.push([`$.trigger.on[${m}]`,d]));let o=new Set;((p=t.actions)!=null?p:[]).forEach((d,m)=>{var y,k;let l=`${d.type}:${d.name}`;o.has(l)&&e.push(`$.actions[${m}].name: duplicate ${d.type} name`),o.add(l),(d.type==="snapshot"||d.type==="count")&&s.push([`$.actions[${m}].on`,d.on]),d.type==="snapshot"&&(((y=d.fields)!=null?y:[]).forEach((A,C)=>n.push([`$.actions[${m}].fields[${C}].selector`,A.selector])),((k=d.texts)!=null?k:[]).forEach((A,C)=>n.push([`$.actions[${m}].texts[${C}]`,A])))});for(let[d,m]of s)m&&(n.push([`${d}.selector`,m.selector],[`${d}.click`,m.click]),typeof m.submit=="string"&&n.push([`${d}.submit`,m.submit]));for(let[d,m]of n)m!==void 0&&Ut(m)&&e.push(`${d}: invalid CSS selector`)}function Ue(t){let e=[];try{ie(Be,t,"$",e),e.length===0&&_t(t,e)}catch(r){e.push(`$: validation failed (${String(r)})`)}return{ok:e.length===0,errors:e}}function _e(t){try{return Se(Qe(t)).slice(0,16)}catch{return"invalid"}}var K=()=>{},Fe=/(^|\.)corbado\.(io|com|cloud)$/i,be=t=>{let e=t;return()=>e-- >0};function mt(t){var r,n;let e=t.level("page");if(e!=="off")try{let s=(n=(r=performance.getEntriesByType)==null?void 0:r.call(performance,"navigation"))==null?void 0:n[0],o=t.scope("page");t.emit("page",{url:t.redactor.url(location.href,o,e),ref:document.referrer?t.redactor.url(document.referrer,o,e==="values"?"values":"inventory"):"",title:e==="inventory"?void 0:t.redactor.text(document.title,o,e),nav:s?{type:s.type,redirects:s.redirectCount,status:s.responseStatus,ttfb:Math.round(s.responseStart),dcl:Math.round(s.domContentLoadedEventEnd),size:s.transferSize}:void 0,vw:typeof innerWidth=="number"?innerWidth:void 0,vh:typeof innerHeight=="number"?innerHeight:void 0,lang:typeof navigator!="undefined"?navigator.language:void 0,tz:Intl.DateTimeFormat().resolvedOptions().timeZone})}catch{}}function ht(t,e,r){let n=t.level("res");if(n==="off")return{flush:K,dispose:K};let s=0,o=()=>{var a;try{let u=(a=performance.getEntriesByType)==null?void 0:a.call(performance,"resource");if(!u||u.length<=s)return;let c=u.slice(s);s=u.length;let p=c.filter(d=>{try{let m=new URL(d.name).hostname;return!Fe.test(m)&&(!e||z(e,m))}catch{return!e}}).map(d=>[t.redactor.url(d.name,t.scope("res"),n),d.initiatorType,Math.round(d.startTime),Math.round(d.duration),d.transferSize,d.responseStatus]);for(let d=0;d<p.length;d+=40)t.emit("res",{rows:p.slice(d,d+40)})}catch{}},i=setInterval(o,Math.max(1e3,r));return{flush:o,dispose:()=>clearInterval(i)}}function gt(t){let e=t.level("store");if(e!=="off")try{let r=t.scope("store"),n=o=>{var i;try{if(!o)return[];let a=Array.from({length:Math.min(o.length,200)},(c,p)=>{var d;return(d=o.key(p))!=null?d:""});if(e==="inventory")return a;let u={};for(let c of a){let p=(i=o.getItem(c))!=null?i:"";if(e==="shape"){let d=ne(p);u[c]=d!==void 0?t.redactor.tree(d,r,"shape"):He(p)}else{let d=t.redactor.tree({[c]:p},r,"values");c in d&&(u[c]=d[c])}}return u}catch{return["<blocked>"]}},s=[];try{s=document.cookie.split(";").map(o=>{var i;return((i=o.split("=")[0])!=null?i:"").trim()}).filter(Boolean).slice(0,100)}catch{}t.emit("store",{ls:n(lt("localStorage")),ss:n(lt("sessionStorage")),ck:s})}catch{}}function lt(t){try{return window[t]}catch{return}}function yt(t){let e=t.level("form");if(e!=="off")try{let r=Array.from(document.forms).slice(0,10).map(n=>({id:H(n),name:n.getAttribute("name")||void 0,action:t.redactor.url(he(n),t.scope("form",n),e),method:Pe(n),fields:Array.from(n.elements).slice(0,40).map(s=>{let o=s,i=o.getAttribute("name")||H(o)||"";if(!i||o.type==="submit"||o.type==="button")return;if(e==="inventory")return[i,o.type];let a=t.scope("form",s),u=t.redactor.ruleFor(a,i,i);if((u==null?void 0:u.method)==="drop")return;let p=Ae(s,e==="values"&&u?u:{method:"class"},(d,m)=>{let l=t.redactor.method(d,m,a,i);return l===ye?void 0:l});return[i,o.type,p]}).filter(Boolean)}));r.length&&t.emit("form",{forms:r})}catch{}}function bt(t){let e=t.level("err"),r=be(50),n=()=>t.scope("err"),s=u=>typeof u=="string"?e==="values"?t.redactor.text(u.slice(0,500),n(),"values"):se(u):void 0,o=u=>typeof u=="string"&&e==="values"?u.split(`
1
+ import{f as Ke,g as Ze,h as Ye}from"./chunk-GWLL2VST.mjs";import{A as st,B as ot,a as Ee,b as Se,c as Qe,d as Q,e as z,f as $e,g as Ie,h as w,i as ne,j as re,k as H,l as he,m as Pe,n as Ae,o as Oe,p as Ne,q as Rt,r as et,s as tt,t as nt,u as rt,v as je,w as se,x as He,y as ge,z as ye}from"./chunk-WY3VIPYX.mjs";import{a as S}from"./chunk-JR557W27.mjs";function it(t){var u,c,p,d;let e=(u=t==null?void 0:t.userAgent)!=null?u:"",r=t==null?void 0:t.userAgentData,n=((c=r==null?void 0:r.brands)!=null?c:[]).map(m=>m.brand.toLowerCase()),s="other";n.some(m=>m.includes("edge"))?s="edge":n.some(m=>m.includes("opera"))?s="opera":/SamsungBrowser\//.test(e)?s="samsung":/Edg(e|A|iOS)?\//.test(e)?s="edge":/OPR\/|Opera/.test(e)?s="opera":/Firefox\/|FxiOS\//.test(e)?s="firefox":n.some(m=>m.includes("chrome")||m.includes("chromium"))||/Chrome\/|CriOS\//.test(e)?s="chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&(s="safari");let o=((p=r==null?void 0:r.platform)!=null?p:"").toLowerCase(),i="other";o==="android"||/Android/.test(e)?i="android":/iPhone|iPad|iPod/.test(e)||/Macintosh/.test(e)&&((d=t==null?void 0:t.maxTouchPoints)!=null?d:0)>1?i="ios":o==="windows"||/Windows/.test(e)?i="windows":o==="chrome os"||o==="chromeos"||/CrOS/.test(e)?i="chromeos":o==="macos"||/Macintosh|Mac OS X/.test(e)?i="macos":(o==="linux"||/Linux/.test(e))&&(i="linux");let a="desktop";return/iPad|Tablet/.test(e)||i==="android"&&!/Mobile/.test(e)||i==="ios"&&/Macintosh/.test(e)?a="tablet":((r==null?void 0:r.mobile)===!0||/Mobi|iPhone|iPod/.test(e))&&(a="mobile"),{browser:s,os:i,device:a}}function $t(t,e,r){return t===void 0||t>=1?!0:t<=0?!1:(e?Ee(`${r}:${e}`)/4294967296:Math.random())<t}function It(t,e){if(!t)return!1;let r=/^\d{4}-\d{2}-\d{2}$/.test(t)?Date.parse(`${t}T23:59:59.999Z`):Date.parse(t);return!Number.isFinite(r)||e>r}function at(t,e){var r;if(t){if(t.projects&&!t.projects.includes(e.projectId))return"projects";if(It(t.until,e.now))return"until";if(t.browser&&!t.browser.includes(e.client.browser))return"browser";if(t.os&&!t.os.includes(e.client.os))return"os";if(t.device&&!t.device.includes(e.client.device))return"device";if(t.integrationVersion&&!z(t.integrationVersion,(r=e.integrationVersion)!=null?r:""))return"integrationVersion";if(!$t(t.sample,e.sessionId,e.salt))return"sample"}}function ut(t,e){if(!t)return"match";let r=!1;for(let[n,s]of Object.entries(t)){let o=e==null?void 0:e[n];if(o==null||o===""){r=!0;continue}if(!s.includes("*")&&!s.includes(String(o)))return"mismatch"}return r?"unknown":"match"}var ct=2e3;function ae(t){if(typeof t=="string"&&t.length<=3e5){let e=ne(t);if(e!==void 0)return e}return t}function Ot(t,e){let r=[ae(t)];for(;r.length&&e.length<ct;){let n=r.shift();if(n===null||typeof n!="object")continue;Array.isArray(n)||e.push(n);let s=Array.isArray(n)?n:Object.values(n);for(let o of s.slice(0,200)){let i=ae(o);i!==null&&typeof i=="object"&&r.push(i)}}}function Le(t,e){let r=[ae(t)];for(let n of e.split(".").filter(Boolean)){let s=[];if(n==="**"){for(let u of r)Ot(u,s);r=s;continue}let o=n.endsWith("[]"),i=o?n.slice(0,-2):n,a=u=>{let c=i===""?u:re(u)?ae(u[i]):void 0;if(c!==void 0)if(o){if(Array.isArray(c))for(let p of c.slice(0,200))s.push(ae(p))}else s.push(c)};for(let u of r){if(s.length>=ct)break;if(Array.isArray(u)&&i!=="")for(let c of u.slice(0,200))a(ae(c));else a(u)}r=s}return r}function ue(t,e){return Le(t,e)[0]}function Te(t,e){if(!e)return!0;for(let[r,n]of Object.entries(e)){let s=Array.isArray(n)?n:[n];if(!Le(t,r).some(i=>i!=null&&s.includes(String(i))))return!1}return!0}function ft(t){return t==null?0:Array.isArray(t)?t.length:typeof t=="object"?Object.keys(t).length:1}var Nt={enum:["off","inventory","shape","values"]},jt={enum:["drop","presence","length","class","shape","hash","mask","enum","clear"]},B={type:"array",items:{type:"string",minLength:1,maxLength:200},maxItems:100},ce={anyOf:[{type:"string",minLength:1,maxLength:200},B]},dt={type:"object",maxProperties:20,additionalProperties:{anyOf:[{type:"string",maxLength:200},B]}},qe={values:B,keepPrefix:{type:"integer",minimum:0,maximum:64},keepStart:{type:"integer",minimum:0,maximum:64},keepEnd:{type:"integer",minimum:0,maximum:64}},D=(t={})=>({anyOf:[{$ref:"#/$defs/level"},{type:"object",required:["level"],additionalProperties:!1,properties:{level:{$ref:"#/$defs/level"},...t}}]}),Ht=["page","ui","act","nav","res","store","net","form","err","console","dl","msg","glob","cev"],oe={type:"string",minLength:1,maxLength:200,pattern:"^[^\\s]+$"},De={type:"object",required:["path"],additionalProperties:!1,properties:{path:oe,as:{type:"string",minLength:1,maxLength:64},method:{$ref:"#/$defs/method"},...qe}},Be={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://corbado.com/schemas/autocapture/probe-config-v1.json",title:"Corbado autocapture probe config (v1)",type:"object",required:["v"],additionalProperties:!1,properties:{v:{const:1},name:{type:"string",maxLength:120},when:{$ref:"#/$defs/when"},trigger:{$ref:"#/$defs/trigger"},surfaces:{type:"object",additionalProperties:!1,properties:{page:D(),ui:D({maxViews:{type:"integer",minimum:1,maximum:100}}),act:D(),nav:D(),res:D({hosts:B,everyMs:{type:"integer",minimum:1e3,maximum:6e5}}),store:D(),net:D({hosts:B,excludeHosts:B,paths:B,methods:{type:"array",items:{type:"string",pattern:"^[A-Z]{3,10}$"},maxItems:10},bodies:{type:"boolean"}}),form:D(),err:D(),console:D({levels:{type:"array",items:{enum:["error","warn","info","log","debug"]},maxItems:5}}),dl:D(),msg:D(),glob:D(),cev:D()}},rules:{type:"array",maxItems:200,items:{$ref:"#/$defs/rule"}},actions:{type:"array",maxItems:50,items:{$ref:"#/$defs/action"}},budgets:{type:"object",additionalProperties:!1,properties:{items:{type:"integer",minimum:1,maximum:2e3},bytes:{type:"integer",minimum:1e3,maximum:2e6},perKind:{type:"object",maxProperties:40,additionalProperties:{type:"integer",minimum:0,maximum:2e3}}}}},$defs:{level:Nt,method:jt,surfaceName:{enum:Ht},when:{type:"object",additionalProperties:!1,properties:{projects:B,until:{type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}([T ].+)?$"},sample:{type:"number",minimum:0,maximum:1},browser:{type:"array",items:{enum:["chrome","edge","safari","firefox","samsung","opera","other"]}},os:{type:"array",items:{enum:["windows","macos","ios","android","linux","chromeos","other"]}},device:{type:"array",items:{enum:["desktop","mobile","tablet"]}},path:B,state:B,tags:{type:"object",maxProperties:10,additionalProperties:B},integrationVersion:B}},netMatch:{type:"object",additionalProperties:!1,properties:{host:ce,path:ce,method:ce,status:{anyOf:[{enum:["ok","error"]},{type:"array",items:{type:"integer",minimum:0,maximum:999}}]},body:dt,response:dt}},match:{type:"object",additionalProperties:!1,minProperties:1,properties:{net:{$ref:"#/$defs/netMatch"},selector:{type:"string",minLength:1,maxLength:300},click:{type:"string",minLength:1,maxLength:300},submit:{anyOf:[{const:!0},{type:"string",minLength:1,maxLength:300}]},signal:{type:"string",minLength:1,maxLength:64},state:{type:"string",minLength:1,maxLength:64},error:{const:!0}}},trigger:{type:"object",required:["on"],additionalProperties:!1,properties:{on:{type:"array",minItems:1,maxItems:20,items:{$ref:"#/$defs/match"}},buffer:{type:"integer",minimum:1,maximum:2e3},bufferBytes:{type:"integer",minimum:1e3,maximum:2e6},streamMs:{type:"integer",minimum:0,maximum:36e5}}},rule:{type:"object",required:["method"],additionalProperties:!1,properties:{surface:{anyOf:[{$ref:"#/$defs/surfaceName"},{type:"array",items:{$ref:"#/$defs/surfaceName"}}]},host:ce,path:ce,key:ce,selector:{type:"string",minLength:1,maxLength:300},part:{enum:["url","request","response"]},method:{$ref:"#/$defs/method"},...qe}},action:{oneOf:[{type:"object",required:["type","name","on"],additionalProperties:!1,properties:{type:{const:"snapshot"},name:{type:"string",pattern:"^[A-Za-z0-9_.-]{1,64}$"},on:{$ref:"#/$defs/match"},fields:{type:"array",maxItems:30,items:{type:"object",required:["selector"],additionalProperties:!1,properties:{selector:{type:"string",minLength:1,maxLength:300},as:{type:"string",minLength:1,maxLength:64},method:{$ref:"#/$defs/method"},...qe}}},texts:{type:"array",maxItems:20,items:{type:"string",minLength:1,maxLength:300}},request:{type:"array",maxItems:30,items:De},response:{type:"array",maxItems:30,items:De},max:{type:"integer",minimum:1,maximum:200}}},{type:"object",required:["type","name","learn","resolve"],additionalProperties:!1,properties:{type:{const:"correlate"},name:{type:"string",pattern:"^[A-Za-z0-9_.-]{1,64}$"},kind:{type:"string",pattern:"^[a-z][a-z0-9_-]{0,31}$"},learn:{type:"object",required:["net","items","key","value"],additionalProperties:!1,properties:{net:{$ref:"#/$defs/netMatch"},from:{enum:["request","response"]},items:oe,key:oe,value:oe,method:{$ref:"#/$defs/method"},values:B,count:{type:"array",maxItems:10,items:oe}}},resolve:{type:"object",required:["net","key"],additionalProperties:!1,properties:{net:{$ref:"#/$defs/netMatch"},from:{enum:["request","response"]},key:{anyOf:[oe,{type:"array",minItems:1,maxItems:10,items:oe}]},fields:{type:"array",maxItems:20,items:De}}},max:{type:"integer",minimum:1,maximum:500}}},{type:"object",required:["type","name","on"],additionalProperties:!1,properties:{type:{const:"count"},name:{type:"string",pattern:"^[A-Za-z0-9_.-]{1,64}$"},on:{$ref:"#/$defs/match"}}}]}}},Dt=Be;function qt(t){var r;let e=t.replace(/^#\/\$defs\//,"");return(r=Be.$defs[e])!=null?r:{}}function Bt(t,e){switch(t){case"object":return!!e&&typeof e=="object"&&!Array.isArray(e);case"array":return Array.isArray(e);case"string":return typeof e=="string";case"integer":return typeof e=="number"&&Number.isInteger(e);case"number":return typeof e=="number"&&Number.isFinite(e);case"boolean":return typeof e=="boolean";default:return!1}}function ie(t,e,r,n){var s,o;if(!(n.length>50)){if(typeof t.$ref=="string")return ie(qt(t.$ref),e,r,n);if(Array.isArray(t.anyOf)){for(let i of t.anyOf){let a=[];if(ie(i,e,r,a),a.length===0)return}n.push(`${r}: does not match any allowed form`);return}if(Array.isArray(t.oneOf)){let i=t.oneOf,a=e&&typeof e=="object"?e.type:void 0,u=i.find(c=>{var p,d;return((d=(p=c.properties)==null?void 0:p.type)==null?void 0:d.const)===a});if(!u){let c=i.map(p=>p.properties.type.const).join(", ");n.push(`${r}.type: must be one of ${c}`);return}return ie(u,e,r,n)}if("const"in t&&e!==t.const){n.push(`${r}: must be ${JSON.stringify(t.const)}`);return}if(Array.isArray(t.enum)&&!t.enum.includes(e)){n.push(`${r}: must be one of ${t.enum.join(", ")}`);return}if(typeof t.type=="string"&&!Bt(t.type,e)){n.push(`${r}: must be ${t.type}`);return}if(typeof e=="string"&&(typeof t.minLength=="number"&&e.length<t.minLength&&n.push(`${r}: too short`),typeof t.maxLength=="number"&&e.length>t.maxLength&&n.push(`${r}: too long`),typeof t.pattern=="string"&&!new RegExp(t.pattern).test(e)&&n.push(`${r}: invalid format`)),typeof e=="number"&&(typeof t.minimum=="number"&&e<t.minimum&&n.push(`${r}: must be \u2265 ${t.minimum}`),typeof t.maximum=="number"&&e>t.maximum&&n.push(`${r}: must be \u2264 ${t.maximum}`)),Array.isArray(e)&&(typeof t.minItems=="number"&&e.length<t.minItems&&n.push(`${r}: too few items`),typeof t.maxItems=="number"&&e.length>t.maxItems&&n.push(`${r}: too many items`),t.items&&e.forEach((i,a)=>ie(t.items,i,`${r}[${a}]`,n))),e&&typeof e=="object"&&!Array.isArray(e)){let i=e,a=(s=t.properties)!=null?s:{},u=Object.keys(i);typeof t.minProperties=="number"&&u.length<t.minProperties&&n.push(`${r}: must not be empty`),typeof t.maxProperties=="number"&&u.length>t.maxProperties&&n.push(`${r}: too many properties`);for(let c of(o=t.required)!=null?o:[])c in i||n.push(`${r}.${c}: required`);for(let c of u)a[c]?ie(a[c],i[c],`${r}.${c}`,n):t.additionalProperties===!1?n.push(`${r}.${c}: unknown property`):t.additionalProperties&&typeof t.additionalProperties=="object"&&ie(t.additionalProperties,i[c],`${r}.${c}`,n)}}}function Ut(t){if(typeof document=="undefined")return!1;try{return document.createDocumentFragment().querySelector(t),!1}catch{return!0}}function _t(t,e){var i,a,u,c,p;let r=(i=t.when)==null?void 0:i.until;r!==void 0&&!Number.isFinite(Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(r)?`${r}T00:00:00Z`:r))&&e.push("$.when.until: not a valid date");let n=[];((a=t.rules)!=null?a:[]).forEach((d,m)=>{var l;n.push([`$.rules[${m}].selector`,d.selector]),d.method==="enum"&&!((l=d.values)!=null&&l.length)&&e.push(`$.rules[${m}].values: required for method enum`)});let s=[];((c=(u=t.trigger)==null?void 0:u.on)!=null?c:[]).forEach((d,m)=>s.push([`$.trigger.on[${m}]`,d]));let o=new Set;((p=t.actions)!=null?p:[]).forEach((d,m)=>{var y,k;let l=`${d.type}:${d.name}`;o.has(l)&&e.push(`$.actions[${m}].name: duplicate ${d.type} name`),o.add(l),(d.type==="snapshot"||d.type==="count")&&s.push([`$.actions[${m}].on`,d.on]),d.type==="snapshot"&&(((y=d.fields)!=null?y:[]).forEach((A,C)=>n.push([`$.actions[${m}].fields[${C}].selector`,A.selector])),((k=d.texts)!=null?k:[]).forEach((A,C)=>n.push([`$.actions[${m}].texts[${C}]`,A])))});for(let[d,m]of s)m&&(n.push([`${d}.selector`,m.selector],[`${d}.click`,m.click]),typeof m.submit=="string"&&n.push([`${d}.submit`,m.submit]));for(let[d,m]of n)m!==void 0&&Ut(m)&&e.push(`${d}: invalid CSS selector`)}function Ue(t){let e=[];try{ie(Be,t,"$",e),e.length===0&&_t(t,e)}catch(r){e.push(`$: validation failed (${String(r)})`)}return{ok:e.length===0,errors:e}}function _e(t){try{return Se(Qe(t)).slice(0,16)}catch{return"invalid"}}var K=()=>{},Fe=/(^|\.)corbado\.(io|com|cloud)$/i,be=t=>{let e=t;return()=>e-- >0};function mt(t){var r,n;let e=t.level("page");if(e!=="off")try{let s=(n=(r=performance.getEntriesByType)==null?void 0:r.call(performance,"navigation"))==null?void 0:n[0],o=t.scope("page");t.emit("page",{url:t.redactor.url(location.href,o,e),ref:document.referrer?t.redactor.url(document.referrer,o,e==="values"?"values":"inventory"):"",title:e==="inventory"?void 0:t.redactor.text(document.title,o,e),nav:s?{type:s.type,redirects:s.redirectCount,status:s.responseStatus,ttfb:Math.round(s.responseStart),dcl:Math.round(s.domContentLoadedEventEnd),size:s.transferSize}:void 0,vw:typeof innerWidth=="number"?innerWidth:void 0,vh:typeof innerHeight=="number"?innerHeight:void 0,lang:typeof navigator!="undefined"?navigator.language:void 0,tz:Intl.DateTimeFormat().resolvedOptions().timeZone})}catch{}}function ht(t,e,r){let n=t.level("res");if(n==="off")return{flush:K,dispose:K};let s=0,o=()=>{var a;try{let u=(a=performance.getEntriesByType)==null?void 0:a.call(performance,"resource");if(!u||u.length<=s)return;let c=u.slice(s);s=u.length;let p=c.filter(d=>{try{let m=new URL(d.name).hostname;return!Fe.test(m)&&(!e||z(e,m))}catch{return!e}}).map(d=>[t.redactor.url(d.name,t.scope("res"),n),d.initiatorType,Math.round(d.startTime),Math.round(d.duration),d.transferSize,d.responseStatus]);for(let d=0;d<p.length;d+=40)t.emit("res",{rows:p.slice(d,d+40)})}catch{}},i=setInterval(o,Math.max(1e3,r));return{flush:o,dispose:()=>clearInterval(i)}}function gt(t){let e=t.level("store");if(e!=="off")try{let r=t.scope("store"),n=o=>{var i;try{if(!o)return[];let a=Array.from({length:Math.min(o.length,200)},(c,p)=>{var d;return(d=o.key(p))!=null?d:""});if(e==="inventory")return a;let u={};for(let c of a){let p=(i=o.getItem(c))!=null?i:"";if(e==="shape"){let d=ne(p);u[c]=d!==void 0?t.redactor.tree(d,r,"shape"):He(p)}else{let d=t.redactor.tree({[c]:p},r,"values");c in d&&(u[c]=d[c])}}return u}catch{return["<blocked>"]}},s=[];try{s=document.cookie.split(";").map(o=>{var i;return((i=o.split("=")[0])!=null?i:"").trim()}).filter(Boolean).slice(0,100)}catch{}t.emit("store",{ls:n(lt("localStorage")),ss:n(lt("sessionStorage")),ck:s})}catch{}}function lt(t){try{return window[t]}catch{return}}function yt(t){let e=t.level("form");if(e!=="off")try{let r=Array.from(document.forms).slice(0,10).map(n=>({id:H(n),name:n.getAttribute("name")||void 0,action:t.redactor.url(he(n),t.scope("form",n),e),method:Pe(n),fields:Array.from(n.elements).slice(0,40).map(s=>{let o=s,i=o.getAttribute("name")||H(o)||"";if(!i||o.type==="submit"||o.type==="button")return;if(e==="inventory")return[i,o.type];let a=t.scope("form",s),u=t.redactor.ruleFor(a,i,i);if((u==null?void 0:u.method)==="drop")return;let p=Ae(s,e==="values"&&u?u:{method:"class"},(d,m)=>{let l=t.redactor.method(d,m,a,i);return l===ye?void 0:l});return[i,o.type,p]}).filter(Boolean)}));r.length&&t.emit("form",{forms:r})}catch{}}function bt(t){let e=t.level("err"),r=be(50),n=()=>t.scope("err"),s=u=>typeof u=="string"?e==="values"?t.redactor.text(u.slice(0,500),n(),"values"):se(u):void 0,o=u=>typeof u=="string"&&e==="values"?u.split(`
2
2
  `).slice(1,6).map(c=>c.replace(/https?:\/\/[^\s)]+/g,p=>t.redactor.url(p,n(),"values")).trim().slice(0,300)):void 0,i=u=>{var c,p,d;try{if((c=t.onError)==null||c.call(t),e==="off"||!r())return;let m=u.target;if(m&&m!==window&&m instanceof Element){let y=m.src||m.href||"";t.emit("err",{t:"res",tag:m.tagName.toLowerCase(),url:y?t.redactor.url(y,n(),e):void 0});return}let l=u;t.emit("err",{t:"js",name:l.error&&typeof l.error=="object"&&String((p=l.error.name)!=null?p:"")||void 0,msg:e==="inventory"?void 0:s(l.message),src:l.filename?t.redactor.url(l.filename,n(),e):void 0,line:l.lineno,col:l.colno,stack:o((d=l.error)==null?void 0:d.stack)})}catch{}},a=u=>{var c;try{if((c=t.onError)==null||c.call(t),e==="off"||!r())return;let p=u.reason;t.emit("err",{t:"rej",name:p&&typeof p=="object"&&typeof p.name=="string"?p.name:ge(p),msg:e==="inventory"?void 0:s(p&&typeof p=="object"?p.message:p),stack:o(p&&typeof p=="object"?p.stack:void 0)})}catch{}};try{window.addEventListener("error",i,!0),window.addEventListener("unhandledrejection",a)}catch{return K}return()=>{try{window.removeEventListener("error",i,!0),window.removeEventListener("unhandledrejection",a)}catch{}}}function kt(t,e){let r=t.level("console");if(r==="off"||typeof console=="undefined")return K;let n=be(50),s=[],o=!1;for(let i of e)try{let a=console,u=a[i];if(typeof u!="function")continue;let c=function(...p){let d=u.apply(this,p);if(!o){o=!0;try{n()&&t.emit("console",{lvl:i,args:Ft(t,p,r)})}catch{}finally{o=!1}}return d};a[i]=c,s.push(()=>{a[i]===c&&(a[i]=u)})}catch{}return()=>s.forEach(i=>i())}function Ft(t,e,r){let n=t.scope("console");return e.slice(0,5).map(s=>{if(r==="inventory")return ge(s);if(s instanceof Error)return{name:s.name,msg:r==="values"?t.redactor.text(s.message.slice(0,500),n,"values"):se(s.message)};if(typeof s=="string")return r==="values"?t.redactor.text(s.slice(0,1e3),n,"values"):se(s);if(s&&typeof s=="object")try{return t.redactor.tree(JSON.parse(JSON.stringify(s)),n,r)}catch{return"<unserializable>"}return r==="values"?t.redactor.tree(s,n,"values"):He(s)})}function vt(t){let e=t.level("dl");if(e==="off")return K;let r=be(100),n=()=>t.scope("dl"),s=u=>{try{let c=JSON.parse(JSON.stringify(u!=null?u:null));return e==="inventory"&&re(c)?Object.keys(c).slice(0,40):t.redactor.tree(c,n(),e)}catch{return"<unserializable>"}},o,i=()=>{try{if(o)return;let u=window.dataLayer;if(!Array.isArray(u))return;for(let d of u.slice(0,30))r()&&t.emit("dl",{src:"initial",e:s(d)});let c=u.push,p=function(...d){let m=c.apply(this,d);try{for(let l of d)r()&&t.emit("dl",{src:"push",e:s(l)})}catch{}return m};u.push=p,o={dl:u,original:c,wrapper:p}}catch{}};i();let a=[setTimeout(i,2e3),setTimeout(i,8e3)];return()=>{a.forEach(clearTimeout);try{o&&o.dl.push===o.wrapper&&(o.dl.push=o.original)}catch{}}}function wt(t){let e=t.level("msg");if(e==="off")return K;let r=be(100),n=s=>{var o;try{if(!r())return;let i=s.source===window?"self":s.source===window.parent?"parent":s.source?"frame":"other",a;if(typeof s.data=="string"){let u=ne(s.data);a=u!==void 0?t.redactor.tree(u,t.scope("msg"),e):e==="values"?t.redactor.text(s.data.slice(0,1e3),t.scope("msg"),"values"):se(s.data)}else try{a=t.redactor.tree(JSON.parse(JSON.stringify((o=s.data)!=null?o:null)),t.scope("msg"),e)}catch{a=ge(s.data)}t.emit("msg",{origin:s.origin,src:i,data:a})}catch{}};try{window.addEventListener("message",n)}catch{return K}return()=>{try{window.removeEventListener("message",n)}catch{}}}var Vt=/\{\s*\[native code\]\s*\}\s*$/;function Et(t){let e=t.level("glob");if(e!=="off")try{let r=[];for(let n of Object.keys(window).slice(0,2e3)){if(r.length>=300)break;if(/^\d+$/.test(n)||/^on[a-z]+$/.test(n))continue;let s;try{s=window[n]}catch{continue}if(typeof s=="function"){if(Vt.test(Function.prototype.toString.call(s)))continue;r.push([n,"function"]);continue}if(s&&typeof s=="object"){let o=Object.prototype.toString.call(s);if(o!=="[object Object]"&&o!=="[object Array]")continue;let i=e==="inventory"||Array.isArray(s)?void 0:Object.keys(s).slice(0,20);r.push(i?[n,Array.isArray(s)?"array":"object",i]:[n,Array.isArray(s)?"array":"object"]);continue}r.push([n,ge(s)])}t.emit("glob",{names:r})}catch{}}var pt=/^[a-z]+$/;function St(t){let e=t.level("cev");if(e==="off"||typeof EventTarget=="undefined")return K;let r=be(100),n=new Map,s=EventTarget.prototype,o=s.dispatchEvent;if(typeof o!="function")return K;let i=!1,a=function(u){var c,p;if(!i){i=!0;try{let d=typeof CustomEvent!="undefined"&&u instanceof CustomEvent;if((d||!pt.test(u.type))&&r()){let m=((c=n.get(u.type))!=null?c:0)+1;if(n.set(u.type,m),m<=10){let l=this instanceof Element?`${this.tagName.toLowerCase()}${H(this)?`#${H(this)}`:""}`:this===window?"window":this===document?"document":"other",y;if(d&&e!=="inventory")try{y=t.redactor.tree(JSON.parse(JSON.stringify((p=u.detail)!=null?p:null)),t.scope("cev"),e)}catch{y="<unserializable>"}t.emit("cev",{type:pt.test(u.type)||/^[\w:.-]{1,64}$/.test(u.type)?u.type:`<h:${Se(u.type)}>`,target:l,n:m,detail:y})}}}catch{}finally{i=!1}}return o.call(this,u)};try{s.dispatchEvent=a}catch{return K}return()=>{try{s.dispatchEvent===a&&(s.dispatchEvent=o)}catch{}}}var zt=1500,Wt=4e4,Gt=400,Jt=400,Xt=2e3,xe=200,Z=120,Pt=20,Kt=150,Zt=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","SVG","HEAD","META","LINK","IFRAME","CANVAS","VIDEO","AUDIO","IMG","PICTURE","OBJECT"]),Yt=new Set(["H1","H2","H3","H4","H5","H6","P","LABEL","LEGEND","DT","DD","TH","CAPTION","FIGCAPTION"]),Qt=/^(button|radio|tab|link|checkbox|switch|menuitem|menuitemradio|menuitemcheckbox|option)$/,en=/(error|banner|alert)/i,tn='button,a[href],input,select,textarea,summary,label,[role=button],[role=radio],[role=tab],[role=link],[role=checkbox],[role=switch],[role=menuitem],[role=option],[tabindex]:not([tabindex="-1"]),[onclick]',At=(t,e)=>(t!=null?t:"").replace(/\s+/g," ").trim().slice(0,e);function Ve(t){try{let e=Array.from(t.classList).filter(r=>!/^(ng|cdk)-/.test(r)).slice(0,2).join(" ");return e?e.slice(0,60):void 0}catch{return}}function ee(t){let e={};for(let[r,n]of Object.entries(t))n!==void 0&&n!==!1&&n!==""&&(e[r]=n);return e}var ze=t=>t.tagName==="INPUT"&&t.type!=="hidden"||t.tagName==="SELECT"||t.tagName==="TEXTAREA",Lt=t=>{var r;let e="";for(let n of Array.from(t.childNodes))n.nodeType===3&&(e+=` ${(r=n.nodeValue)!=null?r:""}`);return e};function Tt(t){let{emit:e,redactor:r}=t,n=(f,h,g,v,P=xe)=>{let T=At(g,P);return!T||h==="inventory"||h==="off"?void 0:h==="shape"?se(T):r.text(T,t.scope(f,v),"values")||void 0},s=(f,h,g=xe)=>n("ui",t.ui,f,h,g),o=(f,h,g=xe)=>n("act",t.act,f,h,g),i=(f,h,g)=>r.url(g,t.scope(f),h),a=(f,h)=>{let g=r.ruleFor(t.scope(f,h));return!!g&&g.selector!==void 0&&g.method==="drop"};function u(f){try{if(f.getAttribute("aria-hidden")==="true"||f.hidden)return 0;let h=f.checkVisibility;if(typeof h=="function")return h.call(f,{checkVisibilityCSS:!0})?f.getClientRects().length?1:0:getComputedStyle(f).display==="contents"?2:0;let g=getComputedStyle(f);return g.display==="none"?0:g.display==="contents"?2:g.visibility==="hidden"?0:1}catch{return 1}}function c(f){var g,v,P;let h=[];try{let T=f.labels;if(T)for(let $ of Array.from(T))h.push((g=$.textContent)!=null?g:"");if(!h.length){let $=f.closest("label");$&&h.push((v=$.textContent)!=null?v:"")}let L=f.getAttribute("aria-labelledby");if(L)for(let $ of L.split(/\s+/).slice(0,4)){let U=$?document.getElementById($):null;U&&h.push((P=U.textContent)!=null?P:"")}}catch{}return h.join(" ")}function p(f,h,g){var L,$;let v=(U,ve=Z)=>n(h,g,U,f,ve),P=f.tagName==="INPUT"&&/^(submit|button|reset|image)$/.test(f.type),T=f;return ee({k:"btn",tag:f.tagName.toLowerCase(),role:(L=f.getAttribute("role"))!=null?L:void 0,x:v(P?f.getAttribute("value"):f.textContent),al:v(($=f.getAttribute("aria-label"))!=null?$:f.getAttribute("title")),id:H(f),c:Ve(f),href:f.tagName==="A"&&T.getAttribute("href")?i(h,g,T.href):void 0,dis:f.disabled===!0||f.getAttribute("aria-disabled")==="true",sel:f.getAttribute("aria-checked")==="true"||f.getAttribute("aria-selected")==="true"||f.getAttribute("aria-pressed")==="true"})}function d(f){var P,T;let h=f.tagName.toLowerCase(),g=f,v={k:h==="select"?"sel":"in",tag:h,ty:h==="input"?g.type:void 0,nm:g.name||void 0,id:H(f),ac:(P=f.getAttribute("autocomplete"))!=null?P:void 0,ph:s(f.getAttribute("placeholder"),f,Z),lb:s(c(f),f,Z),al:s(f.getAttribute("aria-label"),f,Z),req:g.required===!0,ml:g.maxLength>0?g.maxLength:void 0,im:(T=f.getAttribute("inputmode"))!=null?T:void 0,dis:g.disabled===!0,ro:g.readOnly===!0,inv:f.getAttribute("aria-invalid")==="true"};if(h==="select"){let L=f;t.ui!=="inventory"?v.opts=Array.from(L.options).slice(0,30).map($=>{var U;return(U=s($.textContent,f,60))!=null?U:""}):v.nopts=L.options.length,v.si=L.selectedIndex}else if(g.type==="checkbox"||g.type==="radio")v.chk=g.checked?1:0;else{let L=Oe(f);t.ui!=="inventory"&&(v.len=L),v.empty=L===0?1:0}return ee(v)}function m(f){let h=f.tagName;if(h==="BUTTON"||h==="SUMMARY")return!0;if(h==="A")return f.hasAttribute("href");if(h==="INPUT")return/^(submit|button|reset|image)$/.test(f.type);let g=f.getAttribute("role");if(g&&Qt.test(g))return!0;let v=f.getAttribute("tabindex");if(v!==null&&Number(v)>=0){if(f.hasAttribute("onclick"))return!0;try{return getComputedStyle(f).cursor==="pointer"}catch{return!1}}return f.hasAttribute("onclick")}function l(){var $,U,ve;let f=[],h=0,g=!1,v=0,P=b=>{if(g)return;let _=JSON.stringify(b).length+1;if(h+_>Wt){g=!0;return}h+=_,f.push(b)},T=[],L=(b,_,O)=>{let me=b.children;for(let q=me.length-1;q>=0;q--){let E=me[q];E&&T.push([E,_,O])}let F=b.shadowRoot;if(F){let q=F.children;for(let E=q.length-1;E>=0;E--){let X=q[E];X&&T.push([X,_,O])}}};for(document.body&&L(document.body,!1,void 0);T.length&&!g;){if(++v>zt){g=!0;break}let[b,_,O]=T.pop();if(Zt.has(b.tagName.toUpperCase())||b.tagName==="INPUT"&&b.type==="hidden")continue;let me=u(b);if(me===0||a("ui",b))continue;if(me===2){L(b,_,O);continue}let F=b.tagName,q=b.getAttribute("role");if(F==="FIELDSET"||q==="radiogroup"||q==="group"){let E=F==="FIELDSET"?($=b.querySelector(":scope > legend"))==null?void 0:$.textContent:null,X={entry:ee({k:"grp",tag:F.toLowerCase(),id:H(b),lg:(U=s(E,b,Z))!=null?U:s(c(b),b,Z),al:s(b.getAttribute("aria-label"),b,Z)}),opts:[]};X.entry.opts=X.opts,P(X.entry),L(b,_,X);continue}if(!(F==="LEGEND"&&O)){if(ze(b)){let E=b;O&&(E.type==="radio"||E.type==="checkbox")?O.opts.length<Pt&&O.opts.push(ee({lb:s(c(b),b,Z),nm:E.name||void 0,id:H(b),ty:E.type,chk:E.checked?1:0,dis:E.disabled===!0})):P(d(b));continue}if(m(b)){let E=p(b,"ui",t.ui);O&&(q==="radio"||q==="checkbox")?O.opts.length<Pt&&O.opts.push(E):P(E),L(b,!0,O);continue}if(F==="FORM"){let E=b;P(ee({k:"form",id:H(b),nm:(ve=b.getAttribute("name"))!=null?ve:void 0,m:b.getAttribute("method")?Pe(E):void 0,a:b.getAttribute("action")?i("ui",t.ui,he(E)):void 0})),L(b,_,O);continue}if(!_){let E=q==="alert"||q==="status"||en.test(typeof b.className=="string"?b.className:"");if(F==="LABEL"&&b.control){L(b,!0,O);continue}if(E||Yt.has(F)){let we=At(b.textContent,xe),Mt=s(we,b);we&&P(ee({k:E?"alert":F.toLowerCase(),x:Mt,w:t.ui==="inventory"?we.split(" ").length:void 0,id:E?H(b):void 0,c:E?Ve(b):void 0})),L(b,we?!0:_,O);continue}let X=s(Lt(b),b);X&&P(ee({k:"tx",tag:F.toLowerCase(),x:X}))}L(b,_,O)}}return{entries:f,cut:g}}let y="",k=0,A=0,C=0,I=!1,te=!1,M,x=0,Y=()=>{try{return st(location.pathname)}catch{return""}};function N(f){try{if(M=void 0,x=0,I||A>=t.maxViews||C>=Gt||!document.body)return;C++;let{entries:h,cut:g}=l(),v=Y(),P=s(document.title,void 0,Z),T=Ee(JSON.stringify([v,P,h],($,U)=>$==="len"||$==="empty"?void 0:U)).toString(36),L=te;if(te=!1,T===y){L&&e("ui-same",{h:T,r:v,why:f});return}y=T,k=t.now(),A++,e("ui",ee({v:A,h:T,why:f,r:v,t:P,cut:g,els:h}))}catch{}}function W(f){try{if(I||t.ui==="off"||A>=t.maxViews)return;let h=t.now();x||(x=h),M&&clearTimeout(M);let g=Math.min(Jt,Math.max(0,x+Xt-h));M=setTimeout(()=>N(f),g)}catch{}}let R,G=()=>{try{if(t.ui==="off"||!document.body||R||typeof MutationObserver=="undefined")return;R=new MutationObserver(f=>{try{f.some(g=>{var v;return!/^(SCRIPT|STYLE|LINK|META)$/.test((v=g.target.nodeName)!=null?v:"")})&&W("dom")}catch{}}),R.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["class","style","hidden","disabled","aria-hidden","aria-expanded","aria-checked","aria-selected","aria-invalid","open"]}),W("load")}catch{}},j=()=>G();t.ui!=="off"&&(document.body?G():document.addEventListener("DOMContentLoaded",j));let J=0,V=f=>{t.act==="off"||I||J>=Kt||(J++,e("act",ee({...f,vh:y||void 0,dt:k?t.now()-k:void 0})))},Re=f=>{let h=f instanceof Element?f:void 0;return h&&ze(h)?h:void 0},le=f=>{let h=f;return{tag:f.tagName.toLowerCase(),ty:f.tagName==="INPUT"?h.type:void 0,nm:h.name||void 0,id:H(f),lb:o(c(f),f,Z)}},pe=f=>h=>{try{if(t.act==="off")return;let g=h.target instanceof Element?h.target:void 0;if(g&&a("act",g))return;f(h)}catch{}};return{click:pe(f=>{let h=f.target;if(!h||!(h instanceof Element))return;let g=h.closest(tn);if(g&&ze(g)){let v=g;V({e:"click",k:"field",...le(g),chk:v.type==="checkbox"||v.type==="radio"?v.checked?1:0:void 0})}else V(g?{e:"click",...p(g,"act",t.act),k:g.tagName==="LABEL"?"label":"btn"}:{e:"click",k:"none",tag:h.tagName.toLowerCase(),id:H(h),c:Ve(h),x:o(Lt(h),h,80)})}),focusIn:pe(f=>{let h=Re(f.target);h&&V({e:"fin",...le(h)})}),focusOut:pe(f=>{let h=Re(f.target);if(!h)return;let g=h,P=!(g.type==="checkbox"||g.type==="radio")&&h.tagName!=="SELECT"&&t.act!=="inventory"?Oe(h):void 0;V({e:"fout",...le(h),len:P})}),submit:pe(f=>{var g;let h=f.target;!h||h.tagName!=="FORM"||V({e:"submit",id:H(h),nm:(g=h.getAttribute("name"))!=null?g:void 0,a:h.getAttribute("action")?i("act",t.act,he(h)):void 0})}),change:pe(f=>{var v;let h=Re(f.target);if(!h)return;let g=h;if(h.tagName==="SELECT"){let P=h;V({e:"chg",...le(h),si:P.selectedIndex,ot:o((v=P.options[P.selectedIndex])==null?void 0:v.textContent,h,60)})}else(g.type==="checkbox"||g.type==="radio")&&V({e:"chg",...le(h),chk:g.checked?1:0})}),onRoute(){te=!0,x=0,W("nav")},onHide(){I=!0,M&&clearTimeout(M),M=void 0},dispose(){I=!0;try{M&&clearTimeout(M),R==null||R.disconnect(),document.removeEventListener("DOMContentLoaded",j)}catch{}}}}var ke=Symbol.for("corbado.autocapture.probe"),Xe=16e3,xt=["page","ui","act","nav","res","store","net","form","err","console","dl","msg","glob","cev"],nn={meta:5,page:5,ui:40,"ui-same":40,act:150,nav:50,res:40,store:5,net:150,"net-body":150,form:10,err:50,console:50,dl:100,msg:100,glob:2,cev:100,snapshot:50,corr:100,count:20},rn=400,sn=4e5,on=["els","rows","forms","names","args","fields"],an=250;function fe(t,e,r){return{mode:t,hash:e,reason:r,signal(){},disconnect(){}}}function un(t){return typeof t=="string"?t:t&&typeof t=="object"&&typeof t.level=="string"?t.level:"off"}function cn(t,e){var n,s;let r=(n=w(()=>_e(t)))!=null?n:"invalid";try{if(!Ue(t).ok)return fe("off",r,"invalid-config");if(!e||typeof e.sink!="function")return fe("off",r,"no-sink");if(typeof window=="undefined"||typeof document=="undefined")return fe("unavailable",r,"no-page");let i=window;if(i[ke])return fe("unavailable",r,"already-running");let a=()=>{var d;return(d=w(()=>{var m;return(m=e.now)==null?void 0:m.call(e)}))!=null?d:Date.now()},u=(s=w(()=>{var d;return(d=e.sessionId)==null?void 0:d.call(e)}))!=null?s:void 0,c=at(t.when,{projectId:e.projectId,now:a(),sessionId:u,salt:r,client:it(typeof navigator!="undefined"?navigator:void 0),integrationVersion:e.integrationVersion});if(c)return fe("off",r,`condition:${c}`);let p=new We(t,e,r,a);return i[ke]=p,p.start(),{mode:"active",hash:r,signal:d=>p.signal(d),disconnect:()=>{p.dispose(),i[ke]===p&&delete i[ke]}}}catch{try{delete window[ke]}catch{}return fe("unavailable",r,"error")}}var We=class{constructor(e,r,n,s){this.config=e;this.deps=r;this.hash=n;this.now=s;S(this,"pageId",Ie(12));S(this,"redactor");S(this,"taint",new Ne);S(this,"levels",{});S(this,"disposers",[]);S(this,"disposed",!1);S(this,"items",0);S(this,"bytes",0);S(this,"perKind",new Map);S(this,"dropped",{budget:0,guard:0,size:0,cond:0,buffer:0});S(this,"buffer",[]);S(this,"bufferBytes",0);S(this,"streamingUntil",0);S(this,"tags");S(this,"netMatchers",[]);S(this,"netIds",new Map);S(this,"counts",new Map);S(this,"countsEmitted","");S(this,"snapshotsTaken",new Map);S(this,"corrState",new Map);S(this,"ui");S(this,"res");S(this,"lastTaintRefresh",0);S(this,"lastState");S(this,"hidden",!1);var i,a,u,c,p,d;this.redactor=new ot((i=e.rules)!=null?i:[],Ie(16));for(let m of xt)this.levels[m]=un((a=e.surfaces)==null?void 0:a[m]);this.tags=(u=e.when)!=null&&u.tags?"unknown":"match";let o=m=>{m&&!this.netIds.has(m)&&(this.netIds.set(m,this.netMatchers.length),this.netMatchers.push(m))};for(let m of(p=(c=e.trigger)==null?void 0:c.on)!=null?p:[])o(m.net);for(let m of(d=e.actions)!=null?d:[])m.type==="correlate"?(o(m.learn.net),o(m.resolve.net)):o(m.on.net)}start(){var s;let e=o=>{var i,a;return re((i=this.config.surfaces)==null?void 0:i[o])?(a=this.config.surfaces)==null?void 0:a[o]:void 0};this.emit("meta",{v:Ye,lv:Object.fromEntries(xt.filter(o=>this.levels[o]!=="off").map(o=>[o,this.levels[o]])),trig:this.config.trigger?1:void 0,tags:(s=this.config.when)!=null&&s.tags?1:void 0});let r={level:o=>this.levels[o],emit:(o,i)=>this.emit(o,i),redactor:this.redactor,scope:(o,i)=>this.scope(o,i),now:this.now,onError:()=>this.dispatch({t:"error"})},n=o=>w(o);n(()=>this.refreshTaint(!0)),n(()=>mt(r)),n(()=>{var o,i;this.ui=Tt({ui:this.levels.ui,act:this.levels.act,maxViews:(i=(o=e("ui"))==null?void 0:o.maxViews)!=null?i:30,emit:(a,u)=>this.emit(a,u),redactor:this.redactor,scope:(a,u)=>this.scope(a,u),now:this.now}),this.disposers.push(()=>{var a;return(a=this.ui)==null?void 0:a.dispose()})}),n(()=>this.installDomListeners()),n(()=>this.installNetwork(e("net"))),n(()=>this.installNavigation()),n(()=>{var i;let o=(i=this.deps.webauthn)==null?void 0:i.subscribe(a=>w(()=>et(this.taint,a)));typeof o=="function"&&this.disposers.push(o)}),n(()=>{var i;let o=e("res");this.res=ht(r,o==null?void 0:o.hosts,(i=o==null?void 0:o.everyMs)!=null?i:5e3),this.disposers.push(this.res.dispose)}),n(()=>{(this.levels.err!=="off"||this.hasMatcher(o=>o.error===!0))&&this.disposers.push(bt(r))}),n(()=>{var o,i;return this.disposers.push(kt(r,(i=(o=e("console"))==null?void 0:o.levels)!=null?i:["error","warn"]))}),n(()=>this.disposers.push(vt(r))),n(()=>this.disposers.push(wt(r))),n(()=>this.disposers.push(St(r))),n(()=>{let o=[setTimeout(()=>w(()=>gt(r)),3e3),setTimeout(()=>w(()=>Et(r)),3e3)];this.disposers.push(()=>o.forEach(clearTimeout))}),n(()=>this.installSelectorWatch()),n(()=>this.installStateWatch()),n(()=>this.installHide(r))}dispose(){if(!this.disposed){this.disposed=!0;for(let e of this.disposers.splice(0))w(e);this.buffer=[],this.bufferBytes=0}}signal(e){w(()=>{typeof e=="string"&&e&&this.dispatch({t:"signal",name:e.slice(0,64)})})}hasMatcher(e){var n,s,o;let r=[...(s=(n=this.config.trigger)==null?void 0:n.on)!=null?s:[]];for(let i of(o=this.config.actions)!=null?o:[])i.type!=="correlate"&&r.push(i.on);return r.some(e)}scope(e,r){let n,s;try{n=location.hostname,s=location.pathname}catch{}return{surface:e,host:n,path:s,el:r}}context(){let e=w(()=>{var n,s;return(s=(n=this.deps).context)==null?void 0:s.call(n)});if(!e||typeof e!="object")return;let r={};for(let n of["state","flowType","step"]){let s=e[n];typeof s=="string"&&s&&(r[n]=s.slice(0,64))}return Object.keys(r).length?r:void 0}refreshTaint(e=!1){let r=this.now();!e&&r-this.lastTaintRefresh<an||(this.lastTaintRefresh=r,tt(this.taint,document),w(()=>nt(this.taint,document.cookie)))}emit(e,r){var n;try{if(this.disposed)return;let s=this.config.when;if(s!=null&&s.path&&!z(s.path,(n=w(()=>location.pathname))!=null?n:"")){this.dropped.cond++;return}let o=this.context();if(s!=null&&s.state&&!(o!=null&&o.state&&s.state.includes(o.state))){this.dropped.cond++;return}this.refreshTaint();let i=je(r,this.taint);if(i==null||typeof i!="object"){this.dropped.guard++;return}let a=this.now();for(let u of ln(e,i)){if(!u){this.dropped.size++;continue}this.route({kind:u.kind,payload:u.payload,ts:a,ctx:o,bytes:Q(u.payload)})}}catch{this.dropped.guard++}}route(e){var n,s;if(this.tags==="unknown"&&this.checkTags(),this.tags==="mismatch"||this.disposed)return;let r=this.config.trigger;if(this.tags==="unknown"||r&&this.now()>this.streamingUntil){this.buffer.push(e),this.bufferBytes+=e.bytes;let o=(n=r==null?void 0:r.buffer)!=null?n:300,i=(s=r==null?void 0:r.bufferBytes)!=null?s:3e5;for(;this.buffer.length>o||this.bufferBytes>i;){let a=this.buffer.shift();this.bufferBytes-=a.bytes,this.dropped.buffer++}return}this.deliver(e)}checkTags(){var r,n;let e=ut((r=this.config.when)==null?void 0:r.tags,(n=w(()=>{var s,o;return(o=(s=this.deps).tags)==null?void 0:o.call(s)}))!=null?n:void 0);if(e!==this.tags){if(this.tags=e,e==="mismatch"){this.buffer=[],this.bufferBytes=0,this.dispose();return}e==="match"&&(!this.config.trigger||this.now()<=this.streamingUntil)&&this.flushBuffer()}}flushBuffer(){let e=this.buffer;this.buffer=[],this.bufferBytes=0;for(let r of e)this.deliver(r)}fireTrigger(){var e,r;this.streamingUntil=this.now()+((r=(e=this.config.trigger)==null?void 0:e.streamMs)!=null?r:3e4),this.tags==="unknown"&&this.checkTags(),this.tags==="match"&&this.flushBuffer()}deliver(e){var o,i,a,u,c,p;let r=this.config.budgets,n=(a=(i=(o=r==null?void 0:r.perKind)==null?void 0:o[e.kind])!=null?i:nn[e.kind])!=null?a:50,s=(u=this.perKind.get(e.kind))!=null?u:0;if(this.items>=((c=r==null?void 0:r.items)!=null?c:rn)||this.bytes+e.bytes>((p=r==null?void 0:r.bytes)!=null?p:sn)||s>=n){this.dropped.budget++;return}this.items++,this.bytes+=e.bytes,this.perKind.set(e.kind,s+1),w(()=>this.deps.sink({kind:e.kind,payload:e.payload,pageId:this.pageId,cfg:this.hash,...e.ctx?{ctx:e.ctx}:{},ts:e.ts}))}dispatch(e){var r,n,s;try{if(this.disposed)return;for(let o of(n=(r=this.config.trigger)==null?void 0:r.on)!=null?n:[])if(this.matches(o,e)){this.fireTrigger();break}((s=this.config.actions)!=null?s:[]).forEach((o,i)=>{var a;o.type==="correlate"||!this.matches(o.on,e)||(o.type==="count"?this.counts.set(o.name,((a=this.counts.get(o.name))!=null?a:0)+1):this.snapshot(o,i,e))})}catch{}}matches(e,r){var n,s,o,i;switch(r.t){case"net":{let a=e.net;if(!a)return!1;let u=r.x;if(!de(a,u.url,u.method))return!1;if(a.status!==void 0){let p=u.outcome!=="load"||u.status===0||u.status>=400;if(a.status==="ok"&&p||a.status==="error"&&!p||Array.isArray(a.status)&&!a.status.includes(u.status))return!1}let c=this.netIds.get(a);return!(a.body&&!((s=(n=r.req)==null?void 0:n.hits)!=null&&s.includes(c))||a.response&&!((i=(o=r.res)==null?void 0:o.hits)!=null&&i.includes(c)))}case"click":return!!e.click&&!!w(()=>r.el.closest(e.click));case"submit":return e.submit===!0||typeof e.submit=="string"&&!!w(()=>r.form.matches(e.submit));case"selector":return e.selector===r.sel;case"signal":return e.signal===r.name;case"state":return e.state===r.state;case"error":return e.error===!0}}snapshot(e,r,n){var i,a,u,c,p,d,m,l;let s=(i=this.snapshotsTaken.get(r))!=null?i:0;if(s>=((a=e.max)!=null?a:20))return;this.snapshotsTaken.set(r,s+1),this.refreshTaint(!0);let o={name:e.name,on:n.t};if((u=e.fields)!=null&&u.length&&(o.fields=e.fields.map(y=>this.snapshotField(y))),(c=e.texts)!=null&&c.length&&(o.texts=e.texts.map(y=>{var A;let k=(A=w(()=>Array.from(document.querySelectorAll(y)).slice(0,5)))!=null?A:[];return{sel:y,x:k.map(C=>this.redactor.text(Ge(C.textContent,300),this.scope("form",C),"values")).filter(Boolean)}})),n.t==="net"){let y=(d=(p=n.req)==null?void 0:p.snap)==null?void 0:d[r],k=(l=(m=n.res)==null?void 0:m.snap)==null?void 0:l[r];y&&(o.req=y),k&&(o.res=k),o.s=n.x.status}this.emit("snapshot",o)}snapshotField(e){var c,p,d;let r=w(()=>document.querySelector(e.selector)),n={as:(c=e.as)!=null?c:e.selector,found:!!r};if(!r)return n;let s=this.scope("form",r),o={method:(p=e.method)!=null?p:"class",values:e.values,keepPrefix:e.keepPrefix,keepStart:e.keepStart,keepEnd:e.keepEnd},i=Ae(r,o,(m,l)=>{let y=this.redactor.method(m,l,s);return y===ye?void 0:y});i!==void 0&&(n.v=i);let a=r.validity;if(a){let m=["valueMissing","typeMismatch","patternMismatch","tooShort","tooLong","rangeUnderflow","rangeOverflow","stepMismatch","badInput","customError"].filter(l=>a[l]);m.length&&(n.valid=m)}if(r.getAttribute("aria-invalid")==="true"&&(n.inv=1),r.tagName==="SELECT"){let m=r;n.si=m.selectedIndex;let l=(d=m.options[m.selectedIndex])==null?void 0:d.textContent;l&&(n.opt=this.redactor.text(Ge(l,100),s,"values"))}let u=dn(r);return u&&(n.err=this.redactor.text(u,s,"values")),n}netSurfaceWants(e,r,n){return!(this.levels.net==="off"||Fe.test(e.hostname)||e.pathname.startsWith("/v1/observe/")||n!=null&&n.hosts&&!z(n.hosts,e.hostname)||n!=null&&n.excludeHosts&&z(n.excludeHosts,e.hostname)||n!=null&&n.paths&&!z(n.paths,e.pathname)||n!=null&&n.methods&&!n.methods.includes(r))}installNetwork(e){var d,m;if(this.levels.net==="off"&&this.netMatchers.length===0)return;let r=l=>w(()=>new URL(l,location.href)),n=this.levels.net,s=n!=="inventory"&&(e==null?void 0:e.bodies)!==!1,o=((d=this.config.actions)!=null?d:[]).map((l,y)=>[l,y]).filter(l=>l[0].type==="correlate"),i=((m=this.config.actions)!=null?m:[]).map((l,y)=>[l,y]).filter(l=>l[0].type==="snapshot"&&!!l[0].on.net),a=l=>(y,k)=>{var A,C,I,te;try{if(this.disposed)return;let M=r(k.url);if(!M)return;let x={},Y,N=!1,W=()=>(N||(N=!0,Y=fn(y)),Y);s&&this.netSurfaceWants(M,k.method,e)&&(x.b=this.redactor.body(y,{surface:"net",host:M.hostname,path:M.pathname,part:l},n)),this.netMatchers.forEach((R,G)=>{var J;let j=l==="request"?R.body:R.response;j&&de(R,k.url,k.method)&&Te(W(),j)&&((J=x.hits)!=null?J:x.hits=[]).push(G)});for(let[R,G]of o){let j=R.learn;((A=j.from)!=null?A:"response")===l&&de(j.net,k.url,k.method)&&Te(W(),l==="request"?j.net.body:j.net.response)&&this.learn(R,G,W());let J=R.resolve;if(((C=J.from)!=null?C:"request")===l&&de(J.net,k.url,k.method)&&Te(W(),l==="request"?J.net.body:J.net.response)){let V=this.resolve(R,G,W(),M);V&&(((I=x.corr)!=null?I:x.corr={})[G]=V)}}for(let[R,G]of i){let j=l==="request"?R.request:R.response;j!=null&&j.length&&de(R.on.net,k.url,k.method)&&(((te=x.snap)!=null?te:x.snap={})[G]=this.picks(j,W(),{surface:"net",host:M.hostname,path:M.pathname,part:l}))}return Object.keys(x).length?x:void 0}catch{return}},u=(l,y)=>{var k,A,C,I;for(let[te,M]of Object.entries((k=y==null?void 0:y.corr)!=null?k:{})){let x=Number(te),Y=((A=this.config.actions)!=null?A:[])[x],N=this.corrState.get(x);!Y||!N||N.emitted.has(l)||N.n>=((C=Y.max)!=null?C:50)||(N.emitted.add(l),N.emitted.size>500&&N.emitted.clear(),N.n++,this.emit((I=Y.kind)!=null?I:"corr",{name:Y.name,...M,n:N.n,...N.offered?{offered:N.offered}:{}}))}},c={id:"probe",match:(l,y)=>{try{return this.disposed?!1:this.netSurfaceWants(l,y,e)||this.netMatchers.some(k=>de(k,l.href,y))}catch{return!1}},projectRequest:a("request"),projectResponse:a("response"),onRequest:l=>{w(()=>u(l.requestId,l.requestBody))},onExchange:l=>{try{if(this.disposed)return;let y=l.requestBody,k=l.responseBody,A=l.requestHeaders;A&&w(()=>{var I;return rt(this.taint,(I=A.authorization)!=null?I:A.Authorization)});let C=r(l.url);if(C&&this.netSurfaceWants(C,l.method,e)){let I={surface:"net",host:C.hostname,path:C.pathname,part:"url"};this.emit("net",{m:l.method,url:this.redactor.url(l.url,I,n),rurl:l.responseUrl&&l.responseUrl!==l.url?this.redactor.url(l.responseUrl,I,n):void 0,s:l.status,o:l.outcome,d:l.durationMs!==void 0?Math.round(l.durationMs):void 0,tr:l.transport,rq:y==null?void 0:y.b,rs:k==null?void 0:k.b})}u(l.requestId,y),u(l.requestId,k),this.dispatch({t:"net",x:l,req:y,res:k})}catch{}}};if(this.deps.network){let l=this.deps.network.subscribe(c);typeof l=="function"&&this.disposers.push(l);return}let p=Ke({match:c.match,bodyCapture:{request:(l,y)=>c.projectRequest(l,y),response:(l,y)=>c.projectResponse(l,y)},onRequest:c.onRequest,onExchange:c.onExchange});this.disposers.push(()=>p.disconnect())}learn(e,r,n){var c,p;let s=e.learn,o=Le(n,s.items).slice(0,50);if(!o.length)return;let i=(c=this.corrState.get(r))!=null?c:{map:new Map,n:0,emitted:new Set};this.corrState.set(r,i),i.map.clear();let a={method:(p=s.method)!=null?p:s.values?"enum":"class",values:s.values},u={surface:"net"};i.offered=o.map(d=>{var k;let m=ue(d,s.key),l=ue(d,s.value);(typeof m=="string"||typeof m=="number")&&i.map.size<200&&i.map.set(String(m),l);let y={value:this.methodValue(l,a,u)};for(let A of(k=s.count)!=null?k:[])y[A]=ft(ue(d,A));return y})}resolve(e,r,n,s){var d,m,l;let o=(d=this.corrState.get(r))!=null?d:{map:new Map,n:0,emitted:new Set};this.corrState.set(r,o);let i;for(let y of $e(e.resolve.key)){let k=ue(n,y);if(typeof k=="string"||typeof k=="number"){i=String(k);break}}let a=e.learn,u={method:(m=a.method)!=null?m:a.values?"enum":"class",values:a.values},c=i!==void 0&&o.map.has(i),p={value:c?this.methodValue(o.map.get(i),u,{surface:"net"}):"unknown",known:c};return(l=e.resolve.fields)!=null&&l.length&&(p.fields=this.picks(e.resolve.fields,n,{surface:"net",host:s.hostname,path:s.pathname,part:"request"})),p}picks(e,r,n){var o,i;let s={};for(let a of e){let u={method:(o=a.method)!=null?o:"class",values:a.values,keepPrefix:a.keepPrefix,keepStart:a.keepStart,keepEnd:a.keepEnd},c=this.methodValue(ue(r,a.path),u,n);c!==void 0&&(s[(i=a.as)!=null?i:a.path]=c)}return s}methodValue(e,r,n){if(e===void 0)return;let s=this.redactor.method(e,r,n);return s===ye?void 0:s}installNavigation(){if(this.levels.nav==="off"&&this.levels.ui==="off")return;let e=n=>{var s;try{if(this.disposed)return;this.levels.nav!=="off"&&this.emit("nav",{src:n.source,url:this.redactor.url(n.path+n.search+n.hash,this.scope("nav"),this.levels.nav)}),(s=this.ui)==null||s.onRoute()}catch{}};if(this.deps.navigation){let n=this.deps.navigation.subscribe(e);typeof n=="function"&&this.disposers.push(n);return}let r=Ze({onNavigate:e});this.disposers.push(()=>r.disconnect())}installDomListeners(){let e={capture:!0,passive:!0},r=[["click",n=>{var s;(s=this.ui)==null||s.click(n),n.target instanceof Element&&this.dispatch({t:"click",el:n.target})}],["focusin",n=>{var s;return(s=this.ui)==null?void 0:s.focusIn(n)}],["focusout",n=>{var s;this.refreshTaint(!0),(s=this.ui)==null||s.focusOut(n)}],["change",n=>{var s;this.refreshTaint(!0),(s=this.ui)==null||s.change(n)}],["submit",n=>{var s;this.refreshTaint(!0),(s=this.ui)==null||s.submit(n),n.target instanceof Element&&this.dispatch({t:"submit",form:n.target})}]];for(let[n,s]of r){let o=i=>{try{this.disposed||s(i)}catch{}};try{document.addEventListener(n,o,e),this.disposers.push(()=>document.removeEventListener(n,o,e))}catch{}}}installSelectorWatch(){var i,a,u;let e=new Set;for(let c of[...(a=(i=this.config.trigger)==null?void 0:i.on)!=null?a:[],...((u=this.config.actions)!=null?u:[]).flatMap(p=>p.type==="correlate"?[]:[p.on])])c.selector&&e.add(c.selector);if(!e.size||typeof MutationObserver=="undefined")return;let r=new Map,n=()=>{for(let c of e){let p=w(()=>document.querySelector(c)),d=!!p&&!p.hidden&&p.getAttribute("aria-hidden")!=="true";d&&!r.get(c)&&this.dispatch({t:"selector",sel:c}),r.set(c,d)}},s,o=new MutationObserver(()=>{s||(s=setTimeout(()=>{s=void 0,w(n)},200))});o.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","aria-hidden","class","style"]}),w(n),this.disposers.push(()=>{o.disconnect(),s&&clearTimeout(s)})}installStateWatch(){var n;let e=(n=this.config.when)!=null&&n.tags?setInterval(()=>{this.tags==="unknown"&&w(()=>this.checkTags())},2e3):void 0;if(e&&this.disposers.push(()=>clearInterval(e)),!this.hasMatcher(s=>s.state!==void 0)||!this.deps.context)return;let r=setInterval(()=>{w(()=>{var o;let s=(o=this.context())==null?void 0:o.state;s&&s!==this.lastState&&this.dispatch({t:"state",state:s}),this.lastState=s})},500);this.disposers.push(()=>clearInterval(r))}installHide(e){let r=()=>{if(!this.counts.size)return;let i=Object.fromEntries(this.counts),a=JSON.stringify(i);a!==this.countsEmitted&&(this.countsEmitted=a,this.emit("count",{counts:i}))},n=()=>{try{if(document.visibilityState!=="hidden"||this.disposed)return;r()}catch{}},s=()=>{var i,a;try{if(this.disposed||this.hidden)return;this.hidden=!0,(i=this.ui)==null||i.onHide(),yt(e),(a=this.res)==null||a.flush(),r();let u=Object.fromEntries(Object.entries(this.dropped).filter(([,c])=>c>0));(Object.keys(u).length||this.buffer.length)&&this.emit("meta",{end:1,items:this.items,dropped:u,buffered:this.buffer.length}),this.buffer=[],this.bufferBytes=0}catch{}},o=i=>{i.persisted&&(this.hidden=!1)};try{document.addEventListener("visibilitychange",n,!0),window.addEventListener("pagehide",s,!0),window.addEventListener("pageshow",o,!0),this.disposers.push(()=>{document.removeEventListener("visibilitychange",n,!0),window.removeEventListener("pagehide",s,!0),window.removeEventListener("pageshow",o,!0)})}catch{}}},Ge=(t,e)=>(t!=null?t:"").replace(/\s+/g," ").trim().slice(0,e);function de(t,e,r){let n;try{n=new URL(e,typeof location!="undefined"?location.href:void 0)}catch{return!1}return!(t.host!==void 0&&!z(t.host,n.hostname)||t.path!==void 0&&!z(t.path,n.pathname)||t.method!==void 0&&!$e(t.method).some(s=>s.toUpperCase()===r.toUpperCase()))}function fn(t){try{if(typeof t=="string"){if(t.length>3e5)return;let e=ne(t);if(e!==void 0)return e;if(/^[^\s<>{}=&]+=[^\s<>]*(&[^\s<>{}=&]+=[^\s<>]*)*$/.test(t.trim())){let r={};return new URLSearchParams(t).forEach((n,s)=>r[s]=n),r}return}if(typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams){let e={};return t.forEach((r,n)=>e[n]=r),e}if(typeof FormData!="undefined"&&t instanceof FormData){let e={};return t.forEach((r,n)=>e[n]=typeof r=="string"?r:void 0),e}return t&&typeof t=="object"&&!(typeof Blob!="undefined"&&t instanceof Blob)&&!(t instanceof ArrayBuffer)&&!ArrayBuffer.isView(t)?t:void 0}catch{return}}function dn(t){var e,r;try{let n=`${(e=t.getAttribute("aria-describedby"))!=null?e:""} ${(r=t.getAttribute("aria-errormessage"))!=null?r:""}`.trim(),s=[];for(let i of n.split(/\s+/).filter(Boolean).slice(0,4)){let a=document.getElementById(i);a!=null&&a.textContent&&s.push(a.textContent)}if(!s.length){let i=t.parentElement;for(let a=0;a<3&&i&&!s.length;a++,i=i.parentElement){let u=i.querySelector('[role=alert], [aria-live], .error, [class*="error"], [class*="invalid"]');u&&u!==t&&u.textContent&&s.push(u.textContent)}}return Ge(s.join(" "),200)||void 0}catch{return}}function ln(t,e){if(Q(e)<=Xe)return[{kind:t,payload:e}];if(Array.isArray(e))return Ct(e,{},void 0).map(n=>n?{kind:t,payload:n}:void 0);for(let n of on){let s=e[n];if(Array.isArray(s)&&s.length>1){let o={...e};return delete o[n],Ct(s,o,n).map(i=>i?{kind:t,payload:i}:void 0)}}if(t==="net"&&(e.rq!==void 0||e.rs!==void 0)){let n=Math.random().toString(36).slice(2,10),s={...e,rid:n},o=[];for(let a of["rq","rs"]){if(s[a]===void 0)continue;let u=s[a];s[a]="<split>";let c=Ce({rid:n,dir:a,body:u});o.push(c?{kind:"net-body",payload:c}:void 0)}let i=Ce(s);return[i?{kind:t,payload:i}:void 0,...o]}let r=Ce(e);return[r?{kind:t,payload:r}:void 0]}function Ct(t,e,r){let n=Q(e)+60,s=Xe-n,o=[],i=[],a=2;for(let u of t){let c=u,p=Q(c)+1;if(p>s){if(c=Ce(c,s),c===void 0)continue;p=Q(c)+1}a+p>s&&i.length&&(o.push(i),i=[],a=2),i.push(c),a+=p}return i.length&&o.push(i),o.map((u,c)=>r===void 0?u:{...e,part:c+1,parts:o.length,[r]:u})}function Me(t,e){if(typeof t=="string")return t.length>e?`<cut:${t.length}>`:t;if(Array.isArray(t))return t.map(r=>Me(r,e));if(re(t)){let r={};for(let[n,s]of Object.entries(t))r[n]=Me(s,e);return r}return t}function Je(t,e){if(t===null||typeof t!="object")return t;if(e<=0)return Array.isArray(t)?`<cut:arr${t.length}>`:"<cut:obj>";if(Array.isArray(t))return t.map(n=>Je(n,e-1));let r={};for(let[n,s]of Object.entries(t))r[n]=Je(s,e-1);return r}function Ce(t,e=Xe){if(Q(t)<=e)return t;for(let n of[4096,1024,256,64]){let s=Me(t,n);if(Q(s)<=e)return s}let r=Me(t,64);for(let n=6;n>=1;n--){let s=Je(r,n);if(Q(s)<=e)return s;r=s}}export{Ne as ProbeTaint,je as applyGuards,Rt as createProbeTaint,_e as probeConfigHash,Dt as probeConfigSchema,cn as startProbes,Ue as validateProbeConfig};