1import{T as c}from"./events-DHDfJdQY.js";import{h as v,g as b}from"./analyticsSession-Ao4cfm5O.js";const g="00000000-0000-0000-0000-000000000000",k=2e3,p=50;let T,i=[],u=null,f="",d=!1,h=!1;function C(){return v()&&b()||g}function M(e){T=e}function R(){return T}function S(){if(typeof window>"u"||typeof navigator>"u"||"webdriver"in navigator&&navigator.webdriver===!0||"__phantomas"in window||"__nightmare"in window||(!navigator.plugins||navigator.plugins.length===0)&&(!navigator.languages||navigator.languages.length===0))return!0;if("chrome"in window){const r=window.chrome;if(r&&!r.runtime&&!navigator.permissions)return!0}const e=navigator.userAgent.toLowerCase();return!!["bot","crawl","spider","scrape","headless","phantom","slurp","google page speed"].some(r=>e.includes(r))}function N(e){if(!e)return!0;const t=["email","phone","address","ssn","social_security","passport","license","credit_card","password","token","firstname","lastname","fullname","dob","birth_date","date_of_birth"];return!Object.keys(e).some(n=>t.includes(n.toLowerCase().replace(/[_-]/g,"")))}function w(e){var o;const n={reason_type:typeof e};
1if(e instanceof Error)n.name=e.name,n.message=(o=e.message)==null?void 0:o.slice(0,256),n.stack=e.stack?e.stack.split(` 2`).slice(0,12).join(` 3`).slice(0,1200):void 0;else if(typeof e=="object"&&e!==null&&("message"in e||"stack"in e)){const s=e;typeof s.name=="string"&&(n.name=s.name),typeof s.message=="string"&&(n.message=s.message.slice(0,256)),typeof s.stack=="string"&&(n.stack=s.stack.split(` 4`).slice(0,12).join(` 5`).slice(0,1200))}else typeof e=="string"&&(n.message=e.slice(0,256));return{context:(n.message??(typeof e=="string"?e:String(e))).slice(0,256),properties:n}}const y=/^(the operation was aborted|signal is aborted without reason)\.?$/i;function O(e){if(typeof e=="string")return y.test(e.trim());if(typeof e!="object"||e===null)return!1;const{name:t,message:r}=e;return t==="AbortError"?!0:typeof r=="string"&&y.test(r.trim())}async function m(){if(d||i.length===0)return;const e=[...i];i=[],d=!0,u&&(clearTimeout(u),u=null);try{const t=v(),r=C(),n=R(),a=e.map(s=>({eventType:s.eventType,severity:s.severity,sessionKey:r,userId:n,hasConsent:t,route:s.route,surface:s.surface,context:s.context,properties:s.properties})),o=await fetch("/api/events/log",{method:"POST",keepalive:!0,headers:{"content-type":"application/json"},body:JSON.stringify({events:a})});o.ok||console.warn("[tracking] Failed to send events:",o.status,o.statusText)}catch(t){console.warn("[tracking] Error sending events:",t)}finally{d=!1}}function A(){u&&clearTimeout(u),u=setTimeout(()=>{m()},k)}function l(e,t={}){if(typeof window>"u"||S())return;const r=e.trim().toLowerCase();if(r.includes(" ")){console.warn("[tracking] Invalid event type (contains spaces):",e,"- Use colons for hierarchy and underscores for spaces");return}if(!N(t.properties)){console.warn("[tracking] Rejected event with PII in properties:",e);return}const n=t.context?t.context.substring(0,256):void 0,a=t.route||f||window.location.pathname,o={eventType:r,severity:t.severity||"info",route:a,surface:t.surface,context:n,properties:t.properties,timestamp:Date.now()};i.push(o),i.length>p&&(i=i.slice(-p)),A()}function E(e,t={}){S()||l(e,{...t,severity:"error"})}function L(e){f!==e&&(f=e,i.length>0&&m())}function _(){m()}function X(e){typeof window>"u"||(f=e||window.location.pathname,window.addEventListener("beforeunload",()=>{i.length>0&&_()}),document.addEventListener("visibilitychange",()=>{document.hidden&&i.length>0&&_()}),h||(h=!0,window.addEventListener("error",t=>{const r=w(t.error??t.message);E(c.ERRORS.CLIENT_ERROR,{context:r.context,properties:{...r.properties,source:t.filename,line:t.lineno,column:t.colno,route:f||window.location.pathname}})}),window.addEventListener("unhandledrejection",t=>{const r=t.reason,n=w(r),a={context:n.context||"unhandledrejection",properties:{...n.properties,route:f||window.location.pathname}};if(O(r)){l(c.ERRORS.CLIENT_UNHANDLED_REJECTION,{...a,severity:"warn"});return}E(c.ERRORS.CLIENT_UNHANDLED_REJECTION,a)})))}function F(e,t=l){t(c.FORM.SUBMIT,{route:e.route,surface:e.surface,context:e.context,properties:{form_name:e.formName,field:e.field,reason:e.reason,...e.properties}})}function j(e,t=l){t(c.FORM.ERROR,{severity:"warn",route:e.route,surface:e.surface,context:e.context??e.reason,properties:{form_name:e.formName,field:e.field,reason:e.reason,...e.properties}})}function K(e,t=l){t(c.FORM.SUCCESS,{route:e.route,surface:e.surface,context:e.context,properties:{form_name:e.formName,field:e.field,reason:e.reason,...e.properties}})}export{F as a,l as b,E as c,K as d,_ as f,X as i,M as s,j as t,L as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.