flusterduck 0.2.0 → 0.4.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.
Files changed (34) hide show
  1. package/README.md +161 -0
  2. package/dist/d.global.js +1 -1
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.mjs +1 -1
  6. package/dist/posthog-trigger.d.ts +36 -0
  7. package/dist/queue.d.ts +5 -0
  8. package/dist/selector.d.ts +1 -0
  9. package/dist/signals/advanced-signals.d.ts +1 -0
  10. package/dist/signals/close-click-reversal.d.ts +3 -0
  11. package/dist/signals/close-click.d.ts +3 -0
  12. package/dist/signals/copy-frustration.d.ts +3 -0
  13. package/dist/signals/dead-click-trap-zone.d.ts +3 -0
  14. package/dist/signals/dead-click.d.ts +1 -0
  15. package/dist/signals/element-impression.d.ts +3 -0
  16. package/dist/signals/exit-intent.d.ts +3 -0
  17. package/dist/signals/filter-spiral.d.ts +3 -0
  18. package/dist/signals/form-validation-loop.d.ts +3 -0
  19. package/dist/signals/frustration-correlator.d.ts +4 -0
  20. package/dist/signals/help-hunt.d.ts +3 -0
  21. package/dist/signals/hover-dwell.d.ts +5 -0
  22. package/dist/signals/index.d.ts +21 -4
  23. package/dist/signals/input-correction.d.ts +3 -0
  24. package/dist/signals/keyboard-signals.d.ts +1 -1
  25. package/dist/signals/navigation-confusion.d.ts +4 -0
  26. package/dist/signals/paste-blocked.d.ts +2 -0
  27. package/dist/signals/performance-vitals.d.ts +3 -0
  28. package/dist/signals/rage-click.d.ts +1 -0
  29. package/dist/signals/scroll-hijack.d.ts +1 -0
  30. package/dist/signals/scroll-to-click-confusion.d.ts +3 -0
  31. package/dist/signals/speed-frustration.d.ts +1 -0
  32. package/dist/signals/text-select-frustration.d.ts +3 -0
  33. package/dist/types.d.ts +4 -0
  34. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var Ae=Object.defineProperty;var qn=Object.getOwnPropertyDescriptor;var jn=Object.getOwnPropertyNames;var Vn=Object.prototype.hasOwnProperty;var Yn=(e,t)=>{for(var n in t)Ae(e,n,{get:t[n],enumerable:!0})},Xn=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of jn(t))!Vn.call(e,r)&&r!==n&&Ae(e,r,{get:()=>t[r],enumerable:!(o=qn(t,r))||o.enumerable});return e};var $n=e=>Xn(Ae({},"__esModule",{value:!0}),e);var Br={};Yn(Br,{destroy:()=>Te,identify:()=>Un,init:()=>Tt,optOut:()=>zn,setConsent:()=>Hn,signal:()=>Fn,track:()=>Bn});module.exports=$n(Br);function S(e){return((...t)=>{try{return e(...t)}catch{}})}function d(e){return t=>{try{e(t)}catch{}}}var xe="_fd_s";var Wn=/^[0-9a-f]{32}$/;function At(e){if(e)return Mt();let t=Kn(xe);if(t&&Wn.test(t))return t;let n=Mt();return xt(xe,n,30),n}function ke(){xt(xe,"",-1)}function Mt(){let e=new Uint8Array(16);crypto.getRandomValues(e);let t="";for(let n of e)t+=n.toString(16).padStart(2,"0");return t}function Kn(e){let t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?.[1]?decodeURIComponent(t[1]):null}function xt(e,t,n){let o=new Date;o.setTime(o.getTime()+n*864e5);let r=location.protocol==="https:"?";Secure":"";document.cookie=`${e}=${encodeURIComponent(t)};path=/;expires=${o.toUTCString()};SameSite=Lax${r}`}var Qn=/^[:\d]|--|^(ember|react|ng-|__)/;function m(e){if(!e||e===document.documentElement)return"html";let t=e.getAttribute("data-fd");if(t)return`[data-fd="${Y(t)}"]`;if(e.id&&!Qn.test(e.id)&&e.id.length<64)return"#"+Y(e.id);let n=[],o=e,r=0;for(;o&&o!==document.body&&r<5;){let i=o.tagName.toLowerCase(),c=o.getAttribute("name"),s=o.getAttribute("role"),a=o.getAttribute("type");c&&c.length<64?i+=`[name="${Y(c)}"]`:s?i+=`[role="${Y(s)}"]`:a&&(i==="input"||i==="button")&&(i+=`[type="${Y(a)}"]`);let u=o.parentElement;if(u){let p=u.children,w=0,V=0;for(let O=0;O<p.length;O++){let Me=p[O];Me&&Me.tagName===o.tagName&&(w++,Me===o&&(V=w))}w>1&&(i+=`:nth-of-type(${V})`)}n.unshift(i);let f=n.join(" > ");try{if(document.querySelectorAll(f).length===1)return f}catch{}o=u,r++}return n.join(" > ")}function Y(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):e.replace(/([^\w-])/g,"\\$1")}function b(e,t){if(e.hasAttribute("data-fd-ignore")||e.closest("[data-fd-ignore]"))return!0;for(let n of t)try{if(e.matches(n)||e.closest(n))return!0}catch{}return!1}function Lt(e,t){if(t==="off")return null;if(t==="metadata")return Gn(e);let n=Jn(e);return n?{mode:"snapshot",...n}:null}function Gn(e){return{mode:"metadata",selector:m(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),attributes:{disabled:e.disabled===!0,required:e.required===!0,ariaDisabled:e.getAttribute("aria-disabled")==="true",ariaExpanded:kt(e.getAttribute("aria-expanded"),["true","false"]),ariaInvalid:kt(e.getAttribute("aria-invalid"),["true","false","grammar","spelling"]),type:Zn(e)}}}function Jn(e){try{let t=e.getBoundingClientRect(),n=getComputedStyle(e),o=e.parentElement,r=[];if(o)for(let c=0;c<o.children.length&&r.length<6;c++){let s=o.children[c];if(!s||s===e)continue;let a=s.getBoundingClientRect();r.push({selector:m(s),tag:s.tagName.toLowerCase(),box:{x:Math.round(a.x),y:Math.round(a.y),w:Math.round(a.width),h:Math.round(a.height)},interactive:to(s)})}let i=[];try{let c=e.getAnimations();for(let s of c)"animationName"in s&&i.push(s.animationName)}catch{}return{selector:m(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),parent:o?m(o):"",box:{x:Math.round(t.x),y:Math.round(t.y),w:Math.round(t.width),h:Math.round(t.height)},styles:{opacity:n.opacity,cursor:n.cursor,pointerEvents:n.pointerEvents,display:n.display,visibility:n.visibility,disabled:e.disabled===!0},inView:eo(t),animations:i,siblings:r}}catch{return null}}function kt(e,t){return e&&t.includes(e)?e:null}function Zn(e){let t=e.tagName.toLowerCase();if(t!=="input"&&t!=="button")return null;let n=e.getAttribute("type");return n&&/^[a-z0-9_-]{1,32}$/i.test(n)?n.toLowerCase():null}function eo(e){return e.top<window.innerHeight&&e.bottom>0&&e.left<window.innerWidth&&e.right>0}function to(e){let t=e.tagName;if(/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/.test(t))return!0;let n=e.getAttribute("role");return!!(n&&/^(button|link|tab|menuitem|checkbox|radio)$/.test(n))}var Rt=7e3,no=5e3,oo=1e4,Dt=50,Ct=100,ro=3,X=6e4,se="application/json",io="application/json; encoding=gzip",N=[],x=null,ae="",Ot=Rt,Nt=Dt,v=null,ce={domMode:"off",compression:"auto"},Le=!1,so=new Set(["sid","key","url","page","ua","vw","vh","segment","environment"]),ao=new Set(["click","move","scroll","keyboard","form_focus","form_blur","form_submit","touch","navigation","error","signal","pageview","custom_signal","performance","visibility","sdk_error"]),co=/(?:value|text|label|email|e-mail|name|phone|address|password|token|secret|cookie|session|jwt|auth|credential|card|cc|cvv|ssn)/i,uo=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,It=d(fo),Pt=S(()=>R());function Ft(e,t,n,o,r){ae=e,v=Object.assign(Object.create(null),t),ce={domMode:yo(r?.domMode),compression:Eo(r?.compression)},Ot=Math.max(no,Math.min(n??Rt,oo)),Nt=Math.max(5,Math.min(o??Dt,Ct)),document.addEventListener("visibilitychange",It),window.addEventListener("pagehide",Pt)}function l(e){N.length>=Ct||(N.push(e),N.length>=Nt?R():x||(x=setTimeout(R,Ot)))}function R(){lo()}async function lo(){if(Le||!N.length||!v)return;Le=!0,x&&(clearTimeout(x),x=null);let e=N;N=[];let t={v:1,sid:v.sid,key:v.key,url:v.url,page:v.page,ts:Date.now(),ua:v.ua,vw:v.vw,vh:v.vh,environment:v.environment,dom_mode:ce.domMode},n=e.map(r=>go(r,v.page,ce.domMode)),o=[];try{for(let r of n){let i=[...o,r];if(JSON.stringify({...t,events:i}).length>X)if(o.length>0)await _e({...t,events:o}),o=[r];else{let s={...t,events:[r]};JSON.stringify(s).length<=X&&await _e(s),o=[]}else o=i}o.length>0&&await _e({...t,events:o})}catch{}finally{Le=!1}}function Re(e){if(v)for(let t of Object.keys(e))so.has(t)&&(v[t]=e[t])}function Bt(){R(),document.removeEventListener("visibilitychange",It),window.removeEventListener("pagehide",Pt),x&&(clearTimeout(x),x=null)}function fo(){document.visibilityState==="hidden"&&R()}async function _e(e){let t=JSON.stringify(e),n=await mo(t,ce.compression);n&&Ut(n,0)}async function mo(e,t){let n=new TextEncoder().encode(e);if(n.byteLength>X)return null;if(t!=="off"){let r=await po(e);if(r&&r.byteLength<=X)return{beaconBody:new Blob([r],{type:io}),fetchBody:new Uint8Array(r),headers:{"Content-Type":se,"Content-Encoding":"gzip"}}}return{beaconBody:new Blob([n],{type:se}),fetchBody:e,headers:{"Content-Type":se}}}async function po(e){let t=globalThis.CompressionStream;if(typeof t!="function")return null;try{let n=ho(e);if(!n)return null;let o=new t("gzip"),i=n.pipeThrough(o).getReader(),c=[],s=0;for(;;){let f=await i.read();if(f.done)break;if(s+=f.value.byteLength,s>X)return null;let p=new Uint8Array(f.value.byteLength);p.set(f.value),c.push(p)}let a=new Uint8Array(s),u=0;for(let f of c)a.set(f,u),u+=f.byteLength;return a.buffer}catch{return null}}function ho(e){let t=new TextEncoder().encode(e),n=new Blob([t],{type:se});if(typeof n.stream=="function")return n.stream();let o=globalThis.ReadableStream;return typeof o!="function"?null:new o({start(r){r.enqueue(t),r.close()}})}function Ut(e,t){if(ae&&!(navigator.sendBeacon&&navigator.sendBeacon(ae,e.beaconBody)))try{fetch(ae,{method:"POST",body:e.fetchBody,headers:e.headers,keepalive:!0}).catch(()=>{t<ro&&setTimeout(()=>Ut(e,t+1),1e3*(t+1))})}catch{}}function go(e,t,n){let o=e.d??{},r=vo(e.t),i={type:r,ts:e.ts,page:typeof o.page=="string"?o.page.slice(0,2048):t},c=_t(o.el,o.element,o.target);if(r==="signal"){i.signal_type=_t(o.s,o.signal_type,o.name)?.slice(0,128),c&&(i.element=c.slice(0,2048));let a=c?bo(c,n):null;a&&(i.dom=a)}let s=wo(o);return Object.keys(s).length&&(i.metadata=s),i}function vo(e){return e==="pv"?"pageview":e==="sig"?"signal":ao.has(e)?e:"custom_signal"}function wo(e){let t=Object.create(null);for(let n of Object.keys(e)){if(["s","signal_type","name","el","element","target","dom","page","meta"].includes(n))continue;let o=ue(e[n],n);o!==void 0&&(t[n.slice(0,64)]=o)}if(e.meta&&typeof e.meta=="object"&&!Array.isArray(e.meta)){let n=ue(e.meta,"meta");n&&typeof n=="object"&&!Array.isArray(n)&&Object.assign(t,n)}return t}function ue(e,t="",n=0){if(!(n>4)&&!co.test(t)){if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string")return uo.test(e)?void 0:e.slice(0,500);if(Array.isArray(e))return e.slice(0,20).map(r=>ue(r,t,n+1)).filter(r=>r!==void 0);if(typeof e=="object"){let o=Object.create(null);for(let r of Object.keys(e).slice(0,40)){if(r==="__proto__"||r==="constructor"||r==="prototype")continue;let i=ue(e[r],r,n+1);i!==void 0&&(o[r.slice(0,64)]=i)}return o}}}function bo(e,t){if(t==="off")return null;try{let n=document.querySelector(e);return n?Lt(n,t):null}catch{return null}}function _t(...e){for(let t of e)if(typeof t=="string"&&t)return t}function yo(e){return e==="metadata"||e==="snapshot"?e:"off"}function Eo(e){return e==="off"?"off":"auto"}function Ht(e){let t=location.href;function n(){let s=location.href;s!==t&&(t=s,e(s,location.pathname))}let o=history.pushState,r=history.replaceState,i=function(...s){o.apply(this,s),n()},c=function(...s){r.apply(this,s),n()};return history.pushState=i,history.replaceState=c,window.addEventListener("popstate",n),window.addEventListener("hashchange",n),function(){history.pushState===i&&(history.pushState=o),history.replaceState===c&&(history.replaceState=r),window.removeEventListener("popstate",n),window.removeEventListener("hashchange",n)}}function De(e,t){for(let n of t){let o=To(n.pattern);if(o&&o.test(e))return n.label}return Mo(e)}var So=/^[a-zA-Z0-9/:._*\-]+$/;function To(e){if(e.length>200||!So.test(e))return null;let t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/:\w+/g,"[^/]+");try{return new RegExp("^"+t+"$")}catch{return null}}function Mo(e){return e.replace(/\/\d+/g,"/:id").replace(/\/[a-f0-9-]{36}/g,"/:id")}var Ao=[".carousel-arrow",".slick-arrow",".swiper-button-next",".swiper-button-prev","[data-carousel]",'button[aria-label*="next"]','button[aria-label*="prev"]','button[aria-label*="slide"]',".quantity-btn",".qty-btn",'input[type="number"]'],k=[],Ce=3,qt=2e3,zt=8,jt=[],Vt=d(xo);function Oe(e,t){Ce=e?.threshold??3,qt=e?.windowMs??2e3,jt=[...Ao,...t??[]],document.addEventListener("click",Vt,{capture:!0,passive:!0})}function Ne(){document.removeEventListener("click",Vt,{capture:!0,passive:!0}),k=[]}function xo(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||b(t,jt)||ko(t))return;let n=Date.now(),o=e.clientX,r=e.clientY;for(;k.length&&n-k[0].t>qt;)k.shift();if(k.push({t:n,x:o,y:r}),k.length<Ce)return;let i=k.slice(-Ce),c=i[0];for(let p=1;p<i.length;p++){let w=i[p],V=w.x-c.x,O=w.y-c.y;if(V*V+O*O>zt*zt)return}let s=c.t,u=(i[i.length-1].t-s)/1e3,f=u>0?i.length/u:i.length;l({t:"sig",ts:n,d:{s:"rage_click",el:m(t),cnt:i.length,vel:Math.round(f*10)/10}}),k=[]}function ko(e){let t=e.tagName;return!!(t==="VIDEO"||t==="AUDIO"||e.hasAttribute("ondblclick"))}var Lo=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,_o=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,Ro=/^(A|BUTTON|LABEL)$/,Yt=[],$=null,Do=5,Xt=d(Co),$t=d(Oo);function Co(e){$={x:e.clientX,y:e.clientY}}function Ie(e){Yt=e??[],document.addEventListener("mousedown",Xt,{capture:!0,passive:!0}),document.addEventListener("click",$t,{capture:!0,passive:!0})}function Pe(){document.removeEventListener("mousedown",Xt,{capture:!0}),document.removeEventListener("click",$t,{capture:!0}),$=null}function Oo(e){if(e.button!==0||e.detail===0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||b(t,Yt)||Po()||Fo(e)||No(t))return;let n=Io(t,e.clientX,e.clientY),o=n?Wt(e.clientX,e.clientY,n):-1;l({t:"sig",ts:Date.now(),d:{s:"dead_click",el:m(t),near:n?m(n):"",dist:Math.round(o)}})}function No(e){if(Lo.test(e.tagName))return!0;let t=e.getAttribute("role");if(t&&_o.test(t)||e.hasAttribute("contenteditable")||e.hasAttribute("tabindex")&&e.getAttribute("tabindex")!=="-1"||e.hasAttribute("onclick")||e.hasAttribute("onmousedown")||e.hasAttribute("onmouseup"))return!0;let n=e.parentElement;return!!(n&&Ro.test(n.tagName)||e.closest('a, button, [role="button"], label, [onclick]'))}function Io(e,t,n){let o=e;for(let r=0;r<5&&o;r++){let i=o.parentElement;if(!i)break;let c=i.querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]'),s=null,a=1/0;for(let u=0;u<c.length;u++){let f=c[u];if(!f||f===e)continue;let p=Wt(t,n,f);p<a&&(a=p,s=f)}if(s&&a<100)return s;o=i}return null}function Wt(e,t,n){let o=n.getBoundingClientRect(),r=Math.max(o.left,Math.min(e,o.right)),i=Math.max(o.top,Math.min(t,o.bottom)),c=e-r,s=t-i;return Math.sqrt(c*c+s*s)}function Po(){let e=window.getSelection();return e!==null&&e.toString().length>0}function Fo(e){if(!$)return!1;let t=e.clientX-$.x,n=e.clientY-$.y;return Math.sqrt(t*t+n*n)>Do}var h=null,Fe=3e3,Kt=[],Bo=/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/,Uo=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton)$/,Qt=d(Ho);function Be(e,t){Fe=e?.delayMs??3e3,Kt=t??[],document.addEventListener("click",Qt,{capture:!0,passive:!0})}function Ue(){document.removeEventListener("click",Qt,{capture:!0}),W()}function Ho(e){let t=e.target;if(!t||b(t,Kt))return;let n=t.getAttribute("role");if(!Bo.test(t.tagName)&&!(n&&Uo.test(n)))return;if(h){if(h.el===t||h.el.contains(t)){let a=Date.now()-h.ts;a>=Fe&&l({t:"sig",ts:Date.now(),d:{s:"speed_frustration",el:h.selector,delay:a}}),W();return}W()}let o=m(t),r=!1,i=new MutationObserver(a=>{for(let u of a){if(u.type==="childList"&&(u.addedNodes.length>0||u.removedNodes.length>0)){r=!0,W();return}if(u.type==="attributes"&&u.target instanceof Element&&(u.target===t||t.contains(u.target)||u.target.contains(t))){r=!0,W();return}}}),c=t.parentElement||document.body;i.observe(c,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-hidden","disabled"]});let s=setTimeout(()=>{!r&&h&&(h={...h,timeout:null})},Fe+500);h={el:t,selector:o,ts:Date.now(),observer:i,timeout:s}}function W(){h&&(h.observer.disconnect(),h.timeout&&clearTimeout(h.timeout),h=null)}var zo=100,Jt=800,Zt=2e3,qo=3,Gt=0,jo=16,le=0,de=0,K=0,Q=0,G=0,fe=0,He=0,D=[],I=null,en=d(Vo);function ze(e){Jt=e?.velocityThreshold??800,Zt=e?.windowMs??2e3,document.addEventListener("mousemove",en,{passive:!0})}function qe(){document.removeEventListener("mousemove",en),I&&clearTimeout(I),je()}function Vo(e){let t=Date.now();t-Gt<jo||(Gt=t,I&&clearTimeout(I),I=setTimeout(()=>je(),150),Yo(e.clientX,e.clientY,t))}function Yo(e,t,n){if(K===0){le=e,de=t,K=n,He=n;return}let o=(n-K)/1e3;if(o===0)return;let r=e-le,i=t-de;if(Math.abs(r)<2&&Math.abs(i)<2)return;let s=Math.sqrt(r*r+i*i)/o;D.length>=zo&&(D=D.slice(-50)),D.push(s);let a=Math.sign(r),u=Math.sign(i);if((Q!==0&&a!==0&&a!==Q||G!==0&&u!==0&&u!==G)&&fe++,Q=a||Q,G=u||G,le=e,de=t,K=n,n-He>Zt){if(fe>=qo){let f=D.reduce((p,w)=>p+w,0)/D.length;f>=Jt&&l({t:"sig",ts:n,d:{s:"thrash_cursor",vel:Math.round(f),rev:fe}})}je(),He=n}}function je(){fe=0,D=[],Q=0,G=0,K=0,le=0,de=0,I=null}var Xo=100,g=[],tn=3e4;function Ve(e){tn=e?.windowMs??3e4}function Ye(){g=[]}function Xe(e){let t=Date.now();try{let i=performance.getEntriesByType("navigation");if(i.length>0&&i[0].type==="back_forward")return}catch{}for(;g.length&&t-g[0].ts>tn;)g.shift();if(g.length>=Xo&&(g=g.slice(-50)),g.push({path:e,ts:t}),g.length<4)return;let n=e,o=!1,r=[];for(let i=0;i<g.length-1;i++)if(g[i].path===n){let c=g.slice(i,g.length),s=new Set(c.map(a=>a.path));if(s.size>=2){r.push(...Array.from(s)),o=!0;break}}o&&(l({t:"sig",ts:t,d:{s:"loop_nav",pages:r}}),g=[{path:e,ts:t}])}var $o=100,nn=1e4,Ke=.5,y=[],me=0,Qe=0,$e=!1,We=0,on=d(Wo);function Ge(e){nn=e?.windowMs??1e4,Ke=e?.depthThreshold??.5,window.addEventListener("scroll",on,{passive:!0})}function Je(){window.removeEventListener("scroll",on),y=[]}function Ze(){y=[],me=0,Qe=0}function Wo(){$e||($e=!0,requestAnimationFrame(()=>{$e=!1,Ko()}))}function Ko(){let e=Date.now(),t=window.scrollY;if(We=document.documentElement.scrollHeight-window.innerHeight,We<=0)return;let n=t/We,o=t>me?"down":"up";if(e-Qe<100){me=t;return}for(;y.length&&e-y[0].ts>nn;)y.shift();y.length>=$o&&(y=y.slice(-50)),y.push({depth:n,ts:e,direction:o}),me=t,Qe=e;let r=0,i=1,c=0,s=!1;for(let a=0;a<y.length;a++){let u=y[a].depth;u>r&&(r=u),u>=Ke&&(s=!0),s&&u<i&&(i=u),s&&i<.25&&u>=Ke&&(c++,s=!1,i=1)}c>=1&&(l({t:"sig",ts:e,d:{s:"scroll_bounce",depth:Math.round(r*100)/100,rev:c+1}}),y=[])}var Qo=["textarea",'[role="textbox"]',"[contenteditable]"],Z=new Map,L=new Set,C=null,et=0,rn=5e3,sn=[],an=d(Go),cn=d(Jo),un=d(Zo),ln=S(dn),J=null;function tt(e,t){rn=e?.pauseMs??5e3,sn=t??[],document.addEventListener("focusin",an,{capture:!0,passive:!0}),document.addEventListener("focusout",cn,{capture:!0,passive:!0}),document.addEventListener("submit",un,{capture:!0,passive:!0}),window.addEventListener("pagehide",ln),J=S(()=>{document.visibilityState==="hidden"&&dn()}),document.addEventListener("visibilitychange",J)}function nt(){document.removeEventListener("focusin",an,{capture:!0}),document.removeEventListener("focusout",cn,{capture:!0}),document.removeEventListener("submit",un,{capture:!0}),window.removeEventListener("pagehide",ln),J&&(document.removeEventListener("visibilitychange",J),J=null),Z.clear(),L.clear(),C=null}function ot(){Z.clear(),L.clear(),C=null,et=0}function Go(e){let t=e.target;if(!t||!fn(t)||b(t,sn)||er(t))return;Z.set(t,Date.now());let n=t.closest("form");n&&n!==C&&(C=n,et=n.querySelectorAll("input, select, textarea").length)}function Jo(e){let t=e.target;if(!t||!fn(t))return;let n=Z.get(t);if(Z.delete(t),n){let r=Date.now()-n;r>=rn&&l({t:"sig",ts:Date.now(),d:{s:"form_hesitation",el:m(t),pause:r}})}let o=t.getAttribute("name")||t.getAttribute("id")||m(t);tr(t)&&L.add(o)}function Zo(){L.clear(),C=null}function dn(){L.size>0&&C&&(l({t:"sig",ts:Date.now(),d:{s:"form_abandon",filled:L.size,total:et||L.size}}),L.clear(),C=null)}function fn(e){let t=e.tagName;return t==="INPUT"||t==="SELECT"||t==="TEXTAREA"}function er(e){if(e.tagName==="TEXTAREA")return!0;for(let t of Qo)try{if(e.matches(t))return!0}catch{return!1}return!1}function tr(e){return"value"in e?e.value.length>0:!1}var P=null,ee=null,mn=/flusterduck\.com|\/v1\/ingest/,hn=d(nr),gn=d(or);function rt(){window.addEventListener("error",hn),window.addEventListener("unhandledrejection",gn),rr()}function it(){window.removeEventListener("error",hn),window.removeEventListener("unhandledrejection",gn),ir()}function nr(e){l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"js_error",msg:st(e.message||"Unknown error",200),ep:"",status:0}})}function or(e){let t=e.reason instanceof Error?e.reason.message:String(e.reason??"");l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"unhandled_rejection",msg:st(t,200),ep:"",status:0}})}function rr(){P||(P=window.fetch,ee=function(t,n){let o;try{o=P.call(this,t,n)}catch(r){throw r}return o.then(r=>{try{if(r.status>=400){let i=typeof t=="string"?t:t instanceof URL?t.pathname:t.url;mn.test(i)||l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:`${r.status} ${r.statusText}`,ep:pn(i),status:r.status}})}}catch{}return r},r=>{try{let i=typeof t=="string"?t:t instanceof URL?t.href:t.url;mn.test(i)||l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:st(r instanceof Error?r.message:"Fetch failed",200),ep:typeof t=="string"?pn(t):"",status:0}})}catch{}throw r})},window.fetch=ee)}function ir(){P&&ee&&window.fetch===ee&&(window.fetch=P),P=null,ee=null}function pn(e){try{return new URL(e,location.origin).pathname}catch{let t=e.indexOf("?"),n=e.indexOf("#"),o=Math.min(t>=0?t:e.length,n>=0?n:e.length);return e.slice(0,o)||"/"}}function st(e,t){let n=e.length>t?e.slice(0,t):e;return n=n.replace(/(?:token|key|secret|password|auth|bearer|jwt|session|cookie|credential)[=:]\s*\S+/gi,"[REDACTED]"),n=n.replace(/https?:\/\/[^\s]*[?&][^\s]*/g,o=>{try{return new URL(o).origin+new URL(o).pathname}catch{return"[URL]"}}),n}var vn=[".carousel",".slider",".swiper","[data-swipeable]",".drawer"],sr=['[class*="map"]',"canvas",".gallery","[data-zoom]"],F=null,T=0,pe=0,te=0,wn=0,bn=null,yn=[],En=d(ar),Sn=d(cr),Tn=d(dr),Mn=d(mr),An=d(fr);function at(e){yn=e??[],document.addEventListener("touchstart",En,{passive:!0}),document.addEventListener("touchend",Sn,{passive:!0}),"ontouchstart"in window&&(document.addEventListener("gesturechange",Tn,{passive:!0}),window.addEventListener("orientationchange",Mn,{passive:!0})),window.visualViewport?.addEventListener("resize",An)}function ct(){document.removeEventListener("touchstart",En),document.removeEventListener("touchend",Sn),document.removeEventListener("gesturechange",Tn),window.removeEventListener("orientationchange",Mn),window.visualViewport?.removeEventListener("resize",An)}function ar(e){let t=e.touches[0];e.touches.length===1&&t&&(F={x:t.clientX,y:t.clientY,ts:Date.now()})}function cr(e){if(!F||e.changedTouches.length!==1)return;let t=e.changedTouches[0];if(!t)return;let n=t.clientX-F.x,o=t.clientY-F.y,r=Date.now()-F.ts,i=document.elementFromPoint(t.clientX,t.clientY);Math.abs(n)<10&&Math.abs(o)<10&&r<300&&i&&ur(i,t.clientX,t.clientY),r<500&&(Math.abs(n)>50||Math.abs(o)>50)&&lr(i,n,o),F=null}function ur(e,t,n){if(b(e,yn))return;let o=pr(e,t,n);if(!o)return;let r=o.getBoundingClientRect(),i=Math.max(r.left,Math.min(t,r.right)),c=Math.max(r.top,Math.min(n,r.bottom)),s=Math.sqrt((t-i)**2+(n-c)**2);if(s>0&&s<=20){let a=`${Math.round(r.width)}x${Math.round(r.height)}`;l({t:"sig",ts:Date.now(),d:{s:"tap_miss",el:m(o),dist:Math.round(s),size:a}})}}function lr(e,t,n){if(Math.abs(n)>Math.abs(t)||!e||vn.some(c=>{try{return e.matches(c)||e.closest(c)}catch{return!1}})||!vn.some(c=>{try{return document.querySelector(c)!==null}catch{return!1}}))return;let i=t>0?"right":"left";l({t:"sig",ts:Date.now(),d:{s:"swipe_miss",dir:i}})}function dr(){let e=Date.now();if(e-pe>3e4&&(T=0,pe=e),T++,T>=2){let t=document.activeElement||document.body;sr.some(o=>{try{return t.matches(o)||t.closest(o)}catch{return!1}})||l({t:"sig",ts:e,d:{s:"pinch_zoom",cnt:T}}),T=0}}function fr(){let e=window.visualViewport;if(e&&e.scale>1.1){let t=Date.now();t-pe>3e4&&(T=0,pe=t),T++,T>=2&&(l({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:T}}),T=0)}}function mr(){let e=Date.now(),t=screen.orientation?.type||"unknown";e-wn>3e4&&(te=0,wn=e),t!==bn&&(te++,bn=t),te>=3&&(l({t:"sig",ts:e,d:{s:"orientation_thrash",cnt:te}}),te=0)}function pr(e,t,n){let r=(e.parentElement||document.body).querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])'),i=null,c=21;for(let s=0;s<r.length;s++){let a=r[s];if(!a)continue;let u=a.getBoundingClientRect(),f=Math.max(u.left,Math.min(t,u.right)),p=Math.max(u.top,Math.min(n,u.bottom)),w=Math.sqrt((t-f)**2+(n-p)**2);w<c&&w>0&&(c=w,i=a)}return i}var E=[],B=null,A=0,ut=0,M=[],hr=10,gr=5e3,xn=5,vr=3e3,wr=15,br=5e3,kn=d(yr);function lt(){document.addEventListener("keydown",kn,{capture:!0,passive:!0})}function dt(){document.removeEventListener("keydown",kn,{capture:!0}),E=[],M=[],B=null}function yr(e){let t=Date.now(),n=e.target;n&&b(n,[])||(e.key==="Tab"?Er(t,n):e.key==="Escape"?Sr(t,e.target):(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight")&&Tr(t,e.target))}function Er(e,t){for(;E.length&&e-E[0].ts>gr;)E.shift();E.length>=50&&(E=E.slice(-25));let n=t?m(t):"";if(E.push({ts:e,el:n}),E.length>=hr){let r=E.map(i=>i.el).filter(Boolean);l({t:"sig",ts:e,d:{s:"tab_thrash",cnt:E.length,els:r}}),E=[]}if(!t)return;let o=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');o&&(o===B?e-ut<=vr?(A++,A>=xn&&(l({t:"sig",ts:e,d:{s:"focus_trap",container:m(o),attempts:A}}),A=0,B=null)):(ut=e,A=1):(B=o,ut=e,A=1))}function Sr(e,t){if(!t)return;let n=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');n&&n===B&&(A++,A>=xn&&(l({t:"sig",ts:e,d:{s:"focus_trap",container:m(n),attempts:A}}),A=0,B=null))}function Tr(e,t){if(!t)return;let n=t.closest('[role="listbox"]')||t.closest('[role="menu"]')||t.closest('[role="tree"]')||t.closest("select");if(!n)return;for(;M.length&&e-M[0].ts>br;)M.shift();M.length>=50&&(M=M.slice(-25)),M.push({ts:e,container:n});let o=M.filter(r=>r.container===n);o.length>=wr&&(l({t:"sig",ts:e,d:{s:"keyboard_nav_frustration",container:m(n),keys:o.length}}),M=[])}var U=0,he=0,ge=null,ft=0,ve=!1,Mr=4,Ar=3e3,Ln=d(xr);function mt(){window.addEventListener("scroll",Ln,{passive:!0})}function pt(){window.removeEventListener("scroll",Ln),U=0,he=0,ge=null,ft=0,ve=!1}function xr(){ve||(ve=!0,requestAnimationFrame(()=>{ve=!1,kr()}))}function kr(){let e=Date.now(),t=window.scrollY,n=t-he;if(Math.abs(n)<2){he=t;return}let o=n>0?"down":"up";ge&&o!==ge&&(e-ft>Ar&&(U=0,ft=e),U++,U>=Mr&&Math.abs(n)>100&&(l({t:"sig",ts:e,d:{s:"scroll_hijack",rev:U}}),U=0)),ge=o,he=t}var H=0,we=!1,_n=d(Lr),Rn=S(Dn),ne=null;function ht(){window.addEventListener("scroll",_n,{passive:!0}),window.addEventListener("pagehide",Rn),ne=S(()=>{document.visibilityState==="hidden"&&Dn()}),document.addEventListener("visibilitychange",ne)}function gt(){window.removeEventListener("scroll",_n),window.removeEventListener("pagehide",Rn),ne&&(document.removeEventListener("visibilitychange",ne),ne=null),H=0,we=!1}function vt(){H=0}function Lr(){we||(we=!0,requestAnimationFrame(()=>{we=!1;let e=document.documentElement.scrollHeight-window.innerHeight;if(e>0){let t=window.scrollY/e;t>H&&(H=t)}}))}function Dn(){H>.05&&l({t:"sig",ts:Date.now(),d:{s:"scroll_depth_abandon",depth:Math.round(H*100)/100}})}var Cn=1500,On=15e3,_r=5e3,Rr=.15,bt="",z=0,wt=0,oe=0,q=0,yt=0,be=null,ye=!1,Ee=d(Cr),Nn=d(Or),j=d(Dr);function Et(){ye||(ye=!0,yt=In(),re(),document.addEventListener("mouseenter",Ee,!0),document.addEventListener("mouseleave",Ee,!0),document.addEventListener("click",j,{capture:!0,passive:!0}),document.addEventListener("keydown",j,{capture:!0,passive:!0}),document.addEventListener("scroll",j,{passive:!0}),window.addEventListener("resize",Nn,{passive:!0}))}function St(){ye&&(ye=!1,document.removeEventListener("mouseenter",Ee,!0),document.removeEventListener("mouseleave",Ee,!0),document.removeEventListener("click",j,{capture:!0}),document.removeEventListener("keydown",j,{capture:!0}),document.removeEventListener("scroll",j),window.removeEventListener("resize",Nn),Pn(),bt="",z=0,q=0,oe=0)}function re(){Pn(),be=setTimeout(()=>{l({t:"sig",ts:Date.now(),d:{s:"user_confusion_idle",idle_ms:On}})},On)}function Dr(){re()}function Cr(e){let t=e.target;if(!t)return;let n=m(t),o=Date.now();(n!==bt||o-wt>Cn)&&(bt=n,wt=o,z=0),z+=1,!(z<4)&&(l({t:"sig",ts:o,d:{s:"thrash_hover",el:n,cnt:z,window_ms:Cn}}),z=0,wt=o)}function Or(){let e=Date.now(),t=In(),n=yt||t,o=Math.abs(t-n)/Math.max(n,1);yt=t,!(o<Rr)&&((!oe||e-oe>_r)&&(oe=e,q=0),q+=1,!(q<3)&&(l({t:"sig",ts:e,d:{s:"viewport_thrashing",cnt:q,area_delta:Math.round(o*1e3)/1e3}}),q=0,oe=e))}function In(){return Math.max(1,window.innerWidth*window.innerHeight)}function Pn(){be&&(clearTimeout(be),be=null)}var Nr="https://api.flusterduck.com/v1/ingest",_=!1,Se=null,ie=null;function Ir(e){if(e)try{let t=new URL(e),n=t.protocol==="http:"&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(t.hostname);return t.protocol!=="https:"&&!n?void 0:t.origin+t.pathname}catch{return}}function Tt(e){if(_||!e.key)return;if(e.key.startsWith("fd_sec_")){console.error("[flusterduck] Secret key detected in browser. Use a publishable key (fd_pub_) instead. Aborting.");return}if(!e.key.startsWith("fd_pub_"))return;if(e.respectDoNotTrack!==!1&&Pr()){ie=e;return}if(e.sampleRate!==void 0&&e.sampleRate<1&&Math.random()>e.sampleRate){ie=e;return}ie=e,_=!0;let t=At(e.cookieless??!1),n=Ir(e.endpoint)??Nr,o=De(location.pathname,e.pageRules??[]),r=Fr(e.domMode);Ft(n,{sid:t,key:e.key,url:location.origin+location.pathname,page:o,ua:navigator.userAgent.slice(0,200),vw:window.innerWidth,vh:window.innerHeight,segment:e.segment,environment:e.environment},e.batchInterval,e.batchMaxSize,{domMode:r,compression:e.compression});let i=document.referrer,c="";if(i)try{c=new URL(i).origin+new URL(i).pathname}catch{c=""}l({t:"pv",ts:Date.now(),d:{ref:c}});let s=e.ignoreElements??[],a=u=>e.signals?.[u]?.enabled!==!1;if(a("rageClick")&&Oe(e.signals?.rageClick,s),a("deadClick")&&Ie(s),a("speedFrustration")){let u=e.signals?.speedFrustration;Be(u?{delayMs:u.windowMs}:void 0,s)}if(e.trackMouse!==!1&&a("thrashCursor")&&ze(e.signals?.thrashCursor),a("loopNav")&&Ve(e.signals?.loopNav),a("scrollBounce")&&Ge(),e.trackForms!==!1&&(a("formHesitation")||a("formAbandon"))){let u=e.signals?.formHesitation;tt(u?{pauseMs:u.threshold}:void 0,s)}a("errorEncounter")&&rt(),("ontouchstart"in window||navigator.maxTouchPoints>0)&&at(s),(a("tabThrash")||a("focusTrap")||a("keyboardNavFrustration"))&&lt(),a("scrollHijack")&&mt(),a("scrollDepthAbandon")&&ht(),a("advancedHeuristics")&&Et(),Se=Ht(S((u,f)=>{R(),Ze(),ot(),vt(),re();let p=De(f,e.pageRules??[]);Re({page:p,url:u}),Xe(f),l({t:"pv",ts:Date.now(),d:{ref:""}})})),e.debug&&console.warn("[flusterduck] initialized",{sid:t.slice(0,6)+"...",endpoint:n,page:o})}function Fn(e,t){if(!_||typeof e!="string"||!e||e.length>128)return;let n;try{let r=t?.metadata??{};n=JSON.stringify(r)}catch{return}if(n.length>2048)return;let o=JSON.parse(n);l({t:"sig",ts:Date.now(),d:{s:e.slice(0,128),el:typeof t?.element=="string"?t.element.slice(0,256):"",meta:o,w:Math.max(0,Math.min(t?.weight??15,100))}})}function Bn(e,t={}){if(!_||typeof e!="string"||!/^[a-z0-9_.-]{1,120}$/i.test(e))return;let n;try{n=JSON.stringify(t??{})}catch{return}n.length>2048||l({t:"custom_signal",ts:Date.now(),d:{business_event:e.slice(0,120),meta:JSON.parse(n)}})}function Un(e){if(!_||!e||typeof e!="object")return;let t=Object.create(null),n=0;for(let o of Object.keys(e)){if(n>=20)break;o==="__proto__"||o==="constructor"||o==="prototype"||(t[o.slice(0,64)]=String(e[o]).slice(0,256),n++)}Re({segment:t})}function Hn(e){e&&ie&&!_?Tt(ie):e||(Te(),ke())}function zn(){Te(),ke()}function Te(){_&&(Ne(),Pe(),Ue(),qe(),Ye(),Je(),nt(),it(),ct(),dt(),pt(),gt(),St(),Bt(),Se&&(Se(),Se=null),_=!1)}function Pr(){return!!(navigator.doNotTrack==="1"||navigator.globalPrivacyControl)}function Fr(e){return e==="metadata"||e==="snapshot"?e:"off"}
1
+ "use strict";var bn=Object.defineProperty;var Na=Object.getOwnPropertyDescriptor;var Pa=Object.getOwnPropertyNames;var Ha=Object.prototype.hasOwnProperty;var Fa=(e,t)=>{for(var n in t)bn(e,n,{get:t[n],enumerable:!0})},Ba=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Pa(t))!Ha.call(e,o)&&o!==n&&bn(e,o,{get:()=>t[o],enumerable:!(r=Na(t,o))||r.enumerable});return e};var Wa=e=>Ba(bn({},"__esModule",{value:!0}),e);var nf={};Fa(nf,{destroy:()=>fn,destroyPostHogTrigger:()=>Aa,identify:()=>da,init:()=>Ho,initPostHogTrigger:()=>xa,optOut:()=>pa,setConsent:()=>fa,signal:()=>ca,track:()=>ua});module.exports=Wa(nf);function y(e){return((...t)=>{try{return e(...t)}catch{}})}function f(e){return t=>{try{e(t)}catch{}}}var yn="_fd_s";var Va=/^[0-9a-f]{32}$/;function $o(e){if(e)return Xo();let t=Ua(yn);if(t&&Va.test(t))return t;let n=Xo();return Yo(yn,n,30),n}function _n(){Yo(yn,"",-1)}function Xo(){let e=new Uint8Array(16);crypto.getRandomValues(e);let t="";for(let n of e)t+=n.toString(16).padStart(2,"0");return t}function Ua(e){let t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?.[1]?decodeURIComponent(t[1]):null}function Yo(e,t,n){let r=new Date;r.setTime(r.getTime()+n*864e5);let o=location.protocol==="https:"?";Secure":"";document.cookie=`${e}=${encodeURIComponent(t)};path=/;expires=${r.toUTCString()};SameSite=Lax${o}`}var qa=/^[:\d]|--|^(ember|react|ng-|__)/;function p(e){if(!e||e===document.documentElement)return"html";let t=e.getAttribute("data-fd");if(t)return`[data-fd="${Ne(t)}"]`;if(e.id&&!qa.test(e.id)&&e.id.length<64)return"#"+Ne(e.id);let n=[],r=e,o=0;for(;r&&r!==document.body&&o<5;){let i=r.tagName.toLowerCase(),s=r.getAttribute("name"),a=r.getAttribute("role"),c=r.getAttribute("type");s&&s.length<64?i+=`[name="${Ne(s)}"]`:a?i+=`[role="${Ne(a)}"]`:c&&(i==="input"||i==="button")&&(i+=`[type="${Ne(c)}"]`);let d=r.parentElement;if(d){let g=d.children,w=0,E=0;for(let b=0;b<g.length;b++){let m=g[b];m&&m.tagName===r.tagName&&(w++,m===r&&(E=w))}w>1&&(i+=`:nth-of-type(${E})`)}n.unshift(i);let l=n.join(" > ");try{if(document.querySelectorAll(l).length===1)return l}catch{}r=d,o++}return n.join(" > ")}function Ne(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):e.replace(/([^\w-])/g,"\\$1")}var Pe=60,za=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,Xa=/^(INPUT|TEXTAREA|SELECT)$/;function h(e){try{let t=e.getAttribute("aria-label");if(t)return t.trim().slice(0,Pe);if(!Xa.test(e.tagName)){let i=(e.textContent??"").trim().replace(/\s+/g," ").slice(0,Pe);if(i&&!za.test(i))return i}let n=e.getAttribute("placeholder");if(n)return n.trim().slice(0,Pe);let r=e.getAttribute("title");if(r)return r.trim().slice(0,Pe);let o=e.getAttribute("alt");return o?o.trim().slice(0,Pe):""}catch{return""}}function v(e,t){if(e.hasAttribute("data-fd-ignore")||e.closest("[data-fd-ignore]"))return!0;for(let n of t)try{if(e.matches(n)||e.closest(n))return!0}catch{}return!1}function Ko(e,t){if(t==="off")return null;if(t==="metadata")return $a(e);let n=Ya(e);return n?{mode:"snapshot",...n}:null}function $a(e){return{mode:"metadata",selector:p(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),attributes:{disabled:e.disabled===!0,required:e.required===!0,ariaDisabled:e.getAttribute("aria-disabled")==="true",ariaExpanded:jo(e.getAttribute("aria-expanded"),["true","false"]),ariaInvalid:jo(e.getAttribute("aria-invalid"),["true","false","grammar","spelling"]),type:ja(e)}}}function Ya(e){try{let t=e.getBoundingClientRect(),n=getComputedStyle(e),r=e.parentElement,o=[];if(r)for(let s=0;s<r.children.length&&o.length<6;s++){let a=r.children[s];if(!a||a===e)continue;let c=a.getBoundingClientRect();o.push({selector:p(a),tag:a.tagName.toLowerCase(),box:{x:Math.round(c.x),y:Math.round(c.y),w:Math.round(c.width),h:Math.round(c.height)},interactive:Ga(a)})}let i=[];try{let s=e.getAnimations();for(let a of s)"animationName"in a&&i.push(a.animationName)}catch{}return{selector:p(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),parent:r?p(r):"",box:{x:Math.round(t.x),y:Math.round(t.y),w:Math.round(t.width),h:Math.round(t.height)},styles:{opacity:n.opacity,cursor:n.cursor,pointerEvents:n.pointerEvents,display:n.display,visibility:n.visibility,disabled:e.disabled===!0},inView:Ka(t),animations:i,siblings:o}}catch{return null}}function jo(e,t){return e&&t.includes(e)?e:null}function ja(e){let t=e.tagName.toLowerCase();if(t!=="input"&&t!=="button")return null;let n=e.getAttribute("type");return n&&/^[a-z0-9_-]{1,32}$/i.test(n)?n.toLowerCase():null}function Ka(e){return e.top<window.innerHeight&&e.bottom>0&&e.left<window.innerWidth&&e.right>0}function Ga(e){let t=e.tagName;if(/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/.test(t))return!0;let n=e.getAttribute("role");return!!(n&&/^(button|link|tab|menuitem|checkbox|radio)$/.test(n))}var Zo=7e3,Za=500,Qa=1e4,Qo=50,Jo=100,Ja=3,He=6e4,Ct="application/json",el="application/json; encoding=gzip",ue=[],Z=null,ei="",ti=Zo,ni=Qo,S=null,Mt={domMode:"off",compression:"auto"},Sn=!1,Ln=null,Cn=!1;function Mn(e){Ln=e}var kt=new Set;function ri(e){return kt.add(e),()=>{kt.delete(e)}}function tl(e){if(e.t!=="sig"||!kt.size)return;let t=typeof e.d?.s=="string"?e.d.s:"";if(t)for(let n of kt)try{n(t,e.ts)}catch{}}function kn(e){Cn=e}var nl=new Set(["sid","key","url","page","ua","vw","vh","segment","environment"]),rl=new Set(["click","move","scroll","keyboard","form_focus","form_blur","form_submit","touch","navigation","error","signal","pageview","custom_signal","performance","visibility","sdk_error"]),ol=new Set(["value","text","label","email","name","phone","address","password","token","secret","cookie","session","jwt","auth","credential","card","cc","cvv","ssn"]);function il(e){return e.replace(/([a-z])([A-Z])/g,"$1\0$2").toLowerCase().split(/[\x00_\-.\s]+/).some(n=>ol.has(n))}var sl=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,oi=f(ll),ii=y(()=>ne());function si(e,t,n,r,o){ei=e,S=Object.assign(Object.create(null),t),Mt={domMode:hl(o?.domMode),compression:vl(o?.compression)},ti=Math.max(Za,Math.min(n??Zo,Qa)),ni=Math.max(1,Math.min(r??Qo,Jo)),document.addEventListener("visibilitychange",oi),window.addEventListener("pagehide",ii)}function u(e){Cn||ue.length>=Jo||(tl(e),ue.push(e),ue.length>=ni?ne():Z||(Z=setTimeout(ne,ti)))}function ne(){al()}async function al(){if(Sn||!ue.length||!S)return;Sn=!0,Z&&(clearTimeout(Z),Z=null);let e=ue;ue=[];let t={v:1,sid:S.sid,key:S.key,url:S.url,page:S.page,ts:Date.now(),ua:S.ua,vw:S.vw,vh:S.vh,environment:S.environment,...S.segment?{segment:S.segment}:{},dom_mode:Mt.domMode},n=e.map(o=>fl(o,S.page,Mt.domMode)),r=[];try{for(let o of n){let i=[...r,o];if(JSON.stringify({...t,events:i}).length>He)if(r.length>0)await Tn({...t,events:r}),r=[o];else{let a={...t,events:[o]};JSON.stringify(a).length<=He?await Tn(a):console.warn("[flusterduck] event dropped: serialized size exceeds limit. Reduce metadata payload size."),r=[]}else r=i}r.length>0&&await Tn({...t,events:r})}catch{}finally{Sn=!1}}function xn(e){if(S)for(let t of Object.keys(e))nl.has(t)&&(S[t]=e[t])}function ai(){ne(),Cn=!1,document.removeEventListener("visibilitychange",oi),window.removeEventListener("pagehide",ii),Z&&(clearTimeout(Z),Z=null)}function ll(){document.visibilityState==="hidden"&&ne()}async function Tn(e){let t=JSON.stringify(e),n=await cl(t,Mt.compression);n&&li(n,0)}async function cl(e,t){let n=new TextEncoder().encode(e);if(n.byteLength>He)return null;if(t!=="off"){let o=await ul(e);if(o&&o.byteLength<=He)return{beaconBody:new Blob([o],{type:el}),fetchBody:new Uint8Array(o),headers:{"Content-Type":Ct,"Content-Encoding":"gzip"}}}return{beaconBody:new Blob([n],{type:Ct}),fetchBody:e,headers:{"Content-Type":Ct}}}async function ul(e){let t=globalThis.CompressionStream;if(typeof t!="function")return null;try{let n=dl(e);if(!n)return null;let r=new t("gzip"),i=n.pipeThrough(r).getReader(),s=[],a=0;for(;;){let l=await i.read();if(l.done)break;if(a+=l.value.byteLength,a>He)return null;let g=new Uint8Array(l.value.byteLength);g.set(l.value),s.push(g)}let c=new Uint8Array(a),d=0;for(let l of s)c.set(l,d),d+=l.byteLength;return c.buffer}catch{return null}}function dl(e){let t=new TextEncoder().encode(e),n=new Blob([t],{type:Ct});if(typeof n.stream=="function")return n.stream();let r=globalThis.ReadableStream;return typeof r!="function"?null:new r({start(o){o.enqueue(t),o.close()}})}function li(e,t,n=ei){if(n&&!(navigator.sendBeacon&&navigator.sendBeacon(n,e.beaconBody)))try{fetch(n,{method:"POST",body:e.fetchBody,headers:e.headers,keepalive:!0}).catch(()=>{t<Ja&&setTimeout(()=>li(e,t+1,n),1e3*(t+1))})}catch{}}function fl(e,t,n){let r=e.d??{},o=pl(e.t),i={type:o,ts:e.ts,page:typeof r.page=="string"?r.page.slice(0,2048):t},s=Go(r.el,r.element,r.target);if(o==="signal"){i.signal_type=Go(r.s,r.signal_type,r.name)?.slice(0,128),s&&(i.element=s.slice(0,2048));let c=s?gl(s,n):null;c&&(i.dom=c),i.signal_type&&Ln&&Ln(i.signal_type)}let a=ml(r);return Object.keys(a).length&&(i.metadata=a),i}function pl(e){return e==="pv"?"pageview":e==="sig"?"signal":rl.has(e)?e:"custom_signal"}function ml(e){let t=Object.create(null);for(let n of Object.keys(e)){if(["s","signal_type","name","el","element","target","dom","page","meta"].includes(n))continue;let r=xt(e[n],n);r!==void 0&&(t[n.slice(0,64)]=r)}if(e.meta&&typeof e.meta=="object"&&!Array.isArray(e.meta)){let n=xt(e.meta,"meta");n&&typeof n=="object"&&!Array.isArray(n)&&Object.assign(t,n)}return t}function xt(e,t="",n=0){if(!(n>4)&&!il(t)){if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string")return sl.test(e)?void 0:e.slice(0,500);if(Array.isArray(e))return e.slice(0,20).map(o=>xt(o,t,n+1)).filter(o=>o!==void 0);if(typeof e=="object"){let r=Object.create(null);for(let o of Object.keys(e).slice(0,40)){if(o==="__proto__"||o==="constructor"||o==="prototype")continue;let i=xt(e[o],o,n+1);i!==void 0&&(r[o.slice(0,64)]=i)}return r}}}function gl(e,t){if(t==="off")return null;try{let n=document.querySelector(e);return n?Ko(n,t):null}catch{return null}}function Go(...e){for(let t of e)if(typeof t=="string"&&t)return t}function hl(e){return e==="metadata"||e==="snapshot"?e:"off"}function vl(e){return e==="off"?"off":"auto"}function ci(e){let t=location.href;function n(){let a=location.href;a!==t&&(t=a,e(a,location.pathname))}let r=history.pushState,o=history.replaceState,i=function(...a){r.apply(this,a),n()},s=function(...a){o.apply(this,a),n()};return history.pushState=i,history.replaceState=s,window.addEventListener("popstate",n),window.addEventListener("hashchange",n),function(){history.pushState===i&&(history.pushState=r),history.replaceState===s&&(history.replaceState=o),window.removeEventListener("popstate",n),window.removeEventListener("hashchange",n)}}function An(e,t){for(let n of t){let r=El(n.pattern);if(r&&r.test(e))return n.label}return bl(e)}var wl=/^[a-zA-Z0-9/:._*\-]+$/;function El(e){if(e.length>200||!wl.test(e))return null;let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/:\w+/g,"[^/]+");try{return new RegExp("^"+t+"$")}catch{return null}}function bl(e){return e.replace(/\/\d+/g,"/:id").replace(/\/[a-f0-9-]{36}/g,"/:id")}var yl=[".carousel-arrow",".slick-arrow",".swiper-button-next",".swiper-button-prev","[data-carousel]",'button[aria-label*="next"]','button[aria-label*="prev"]','button[aria-label*="slide"]',".quantity-btn",".qty-btn",'input[type="number"]'],B=[],ui=3,di=2e3,fi=24,At=fi,pi=[],de=[],mi=0,Dt=new Map,Rt=new Map,_l=1e4,It=!1,gi=f(Sl);function Dn(e,t){It||(It=!0,ui=e?.threshold??3,di=e?.windowMs??2e3,At=e?.radius&&e.radius>0?e.radius:fi,pi=[...yl,...t??[]],mi=Date.now(),B=[],de=[],Dt.clear(),Rt.clear(),document.addEventListener("click",gi,{capture:!0,passive:!0}))}function Rn(){It&&(It=!1,document.removeEventListener("click",gi,{capture:!0,passive:!0}),B=[],de=[],Dt.clear(),Rt.clear())}function Sl(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,pi)||Ml(t))return;let n=Date.now(),r=e.clientX,o=e.clientY;for(;B.length&&n-B[0].t>di;)B.shift();B.push({t:n,x:r,y:o});let i=Tl();if(B.length<i)return;let s=B.slice(-i);for(let M=0;M<s.length-1;M++)for(let Oe=M+1;Oe<s.length;Oe++){let St=s[M],Tt=s[Oe],Lt=Tt.x-St.x,ce=Tt.y-St.y;if(Lt*Lt+ce*ce>At*At)return}let a=s[0].t,d=(s[s.length-1].t-a)/1e3,l=d>0?s.length/d:s.length,g=(s.length-i)/i+l/10,w=Math.round(Math.min(1,g)*100)/100,E=Cl(s,i,l),b=p(t),m=h(t);de.push({selector:b,ts:n});let $=de.length,_t=Ll(n),Uo=Dt.get(b)??0,wn=Uo+1,qo=Rt.get(b)??0,Ia=qo>0&&n-qo<_l;Dt.set(b,wn),Rt.set(b,n);let zo=Uo>=1,Oa=(()=>{try{let M=t.getBoundingClientRect();if(M.width===0&&M.height===0)return null;let Oe=s.reduce((ce,En)=>ce+En.x,0)/s.length,St=s.reduce((ce,En)=>ce+En.y,0)/s.length,Tt=M.left+M.width/2,Lt=M.top+M.height/2;return{click_dx:Math.round(Oe-Tt),click_dy:Math.round(St-Lt),el_w:Math.round(M.width),el_h:Math.round(M.height)}}catch{return null}})();u({t:"sig",ts:n,d:{s:"rage_click",el:b,...m?{el_label:m}:{},cnt:s.length,vel:Math.round(l*10)/10,intensity:w,quality:E,burst_seq:$,burst_rate_per_min:_t,repeated_target:zo,hot_repeat:Ia,...Oa??{}}}),zo&&u({t:"sig",ts:n,d:{s:"rage_click_repeat_target",el:b,...m?{el_label:m}:{},total_hits:wn,burst_count:wn,burst_seq:$}}),B=B.slice(-(i-1))}function Tl(){return de.length>=3?2:ui}function Ll(e){let t=(e-mi)/6e4;return t<=0?0:Math.round(de.length/t*10)/10}function Cl(e,t,n){let r=e.length-t,o=Math.min(4,r/5*4),s=Math.min(4,n/10*4),a=2;if(e.length>=2){let d=0,l=0;for(let w=0;w<e.length-1;w++)for(let E=w+1;E<e.length;E++){let b=e[w],m=e[E],$=m.x-b.x,_t=m.y-b.y;d+=Math.sqrt($*$+_t*_t),l++}let g=d/l;a=Math.max(0,2-g/At*2)}let c=o+s+a;return Math.round(Math.min(10,Math.max(0,c)))}function Ml(e){let t=e.tagName;return!!(t==="VIDEO"||t==="AUDIO"||e.hasAttribute("ondblclick")||e.hasAttribute("data-dbl")||e.getAttribute("role")==="spinbutton")}var kl=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,xl=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,Al=/^(A|BUTTON|LABEL)$/,Dl=20,hi=[],fe=null,Rl=5,Ot=new Map,vi=f(Il),wi=f(Pl);function Il(e){fe={x:e.clientX,y:e.clientY}}function In(e){hi=e??[],document.addEventListener("mousedown",vi,{capture:!0,passive:!0}),document.addEventListener("click",wi,{capture:!0,passive:!0})}function On(){document.removeEventListener("mousedown",vi,{capture:!0}),document.removeEventListener("click",wi,{capture:!0}),fe=null,Ot.clear()}function Nn(){Ot.clear()}function Ol(e){try{return window.getComputedStyle(e).cursor.slice(0,Dl)}catch{return""}}function Nl(e){try{let t=window.getComputedStyle(e);return t.cursor==="pointer"&&t.pointerEvents!=="none"}catch{return!1}}function Pl(e){if(e.button!==0||e.detail===0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,hi)||Wl())return;let n=Vl(e);if(fe=null,n||Hl(t))return;let r=Fl(t,e.clientX,e.clientY),o=r?Ei(e.clientX,e.clientY,r):null,i=p(t),a=(Ot.get(i)??0)+1;Ot.set(i,a);let c=a>=2,d=Ol(t),l=Nl(t),g=h(t),w=r?h(r):"";u({t:"sig",ts:Date.now(),d:{s:"dead_click",el:i,...g?{el_label:g}:{},near:r?p(r):"",...w?{near_label:w}:{},dist:o?Math.round(o.dist):-1,...o?{click_dx:Math.round(o.dx),click_dy:Math.round(o.dy)}:{},cursor:d,...l?{looks_interactive:!0}:{},...c?{repeated:!0,repeat_cnt:a}:{}}})}function Hl(e){if(kl.test(e.tagName))return!0;let t=e.getAttribute("role");if(t&&xl.test(t)||e.hasAttribute("contenteditable")||e.hasAttribute("tabindex")&&e.getAttribute("tabindex")!=="-1"||e.hasAttribute("onclick")||e.hasAttribute("onmousedown")||e.hasAttribute("onmouseup"))return!0;let n=e.parentElement;return!!(n&&Al.test(n.tagName)||e.closest('a, button, [role="button"], label, [onclick]'))}function Fl(e,t,n){let r=e;for(let o=0;o<5&&r;o++){let i=r.parentElement;if(!i)break;let s=i.querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]'),a=null,c=1/0;for(let d=0;d<s.length;d++){let l=s[d];if(!l||l===e)continue;let g=Bl(t,n,l);g<c&&(c=g,a=l)}if(a&&c<100)return a;r=i}return null}function Ei(e,t,n){let r=n.getBoundingClientRect(),o=Math.max(r.left,Math.min(e,r.right)),i=Math.max(r.top,Math.min(t,r.bottom)),s=e-o,a=t-i;return{dist:Math.sqrt(s*s+a*a),dx:s,dy:a}}function Bl(e,t,n){return Ei(e,t,n).dist}function Wl(){let e=window.getSelection();return e!==null&&e.toString().length>0}function Vl(e){if(!fe)return!1;let t=e.clientX-fe.x,n=e.clientY-fe.y;return Math.sqrt(t*t+n*n)>Rl}var T=null,Pn=3e3,bi=[],Nt="click",Pt=0,Ul=/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/,ql=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton)$/,yi=f($l),_i=f(zl),Si=f(Xl);function Hn(e,t){Pn=e?.delayMs??3e3,bi=t??[],document.addEventListener("click",yi,{capture:!0,passive:!0}),document.addEventListener("keydown",_i,{capture:!0,passive:!0}),document.addEventListener("touchstart",Si,{capture:!0,passive:!0})}function Fn(){document.removeEventListener("click",yi,{capture:!0}),document.removeEventListener("keydown",_i,{capture:!0}),document.removeEventListener("touchstart",Si,{capture:!0}),pe()}function Bn(){pe()}function zl(e){e.target&&(e.key!=="Enter"&&e.key!==" "||(Nt="keydown",Pt=Date.now()))}function Xl(){Nt="touch",Pt=Date.now()}function $l(e){let t=e.target;if(!t||v(t,bi))return;let n=t.getAttribute("role");if(!Ul.test(t.tagName)&&!(n&&ql.test(n)))return;let r=Date.now();if(r-Pt>50&&(Nt="click",Pt=r),T){if(T.el===t||T.el.contains(t)){let d=r-T.ts;d>=Pn&&u({t:"sig",ts:r,d:{s:"speed_frustration",el:T.selector,delay:d,interaction_type:Nt,observed_delay_ms:d}}),pe();return}pe()}let o=p(t),i=!1,s=new MutationObserver(d=>{for(let l of d){if(l.type==="childList"&&(l.addedNodes.length>0||l.removedNodes.length>0)){i=!0,pe();return}if(l.type==="attributes"&&l.target instanceof Element&&(l.target===t||t.contains(l.target)||l.target.contains(t))){i=!0,pe();return}}}),a=t.parentElement||document.body;s.observe(a,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-hidden","disabled"]});let c=setTimeout(()=>{!i&&T&&(T.observer.disconnect(),T={...T,timeout:null})},Pn+500);T={el:t,selector:o,ts:r,observer:s,timeout:c}}function pe(){T&&(T.observer.disconnect(),T.timeout&&clearTimeout(T.timeout),T=null)}var Yl=100,jl=5,Ti=800,Li=2e3,Kl=3,Vn=0,Gl=16,Ht=0,Ft=0,Fe=0,Be=0,We=0,Bt=0,Wn=0,re=[],Un=0,me=null,Ci=f(Zl);function qn(e){Ti=e?.velocityThreshold??800,Li=e?.windowMs??2e3,document.addEventListener("mousemove",Ci,{passive:!0})}function zn(){document.removeEventListener("mousemove",Ci),me&&clearTimeout(me),Xn()}function Zl(e){let t=Date.now();t-Vn<Gl||(Vn=t,me&&clearTimeout(me),me=setTimeout(()=>Xn(),150),Ql(e.clientX,e.clientY,t))}function Ql(e,t,n){if(Fe===0){Ht=e,Ft=t,Fe=n,Wn=n;return}let r=(n-Fe)/1e3;if(r===0)return;let o=e-Ht,i=t-Ft;if(Math.abs(o)<2&&Math.abs(i)<2)return;let s=Math.sqrt(o*o+i*i),a=s/r;re.length>=Yl&&(re=re.slice(-50)),re.push(a),Un+=s;let c=Math.sign(o),d=Math.sign(i);if(s>=jl&&(Be!==0&&c!==0&&c!==Be||We!==0&&d!==0&&d!==We)&&Bt++,Be=c||Be,We=d||We,Ht=e,Ft=t,Fe=n,n-Wn>Li){if(Bt>=Kl){let l=re.reduce((g,w)=>g+w,0)/re.length;l>=Ti&&u({t:"sig",ts:n,d:{s:"thrash_cursor",vel:Math.round(l),rev:Bt,distance_px:Math.round(Un)}})}Xn(),Wn=n}}function Xn(){Bt=0,re=[],Un=0,Be=0,We=0,Fe=0,Ht=0,Ft=0,Vn=0,me=null}var Mi=100,ki=5,Jl=3,L=[],k=[],$n=3e4;function Yn(e){$n=e?.windowMs??3e4}function jn(){L=[],k=[]}function Kn(e){let t=Date.now(),n=e.indexOf("#"),r=n===-1?e:e.slice(0,n),o=n===-1?"":e.slice(n);for(;L.length&&t-L[0].ts>$n;)L.shift();for(;k.length&&t-k[0].ts>$n;)k.shift();if(L.length>=Mi&&(L=L.slice(-50)),k.length>=Mi&&(k=k.slice(-50)),L.push({path:e,ts:t}),o){k.push({path:e,ts:t});let a=k.filter(d=>{let l=d.path.indexOf("#");return(l===-1?d.path:d.path.slice(0,l))===r}),c=new Set(a.map(d=>{let l=d.path.indexOf("#");return l===-1?"":d.path.slice(l)}));if(c.size>=Jl&&a.length>c.size){let d=a.slice(-ki).map(l=>l.path);u({t:"sig",ts:t,d:{s:"loop_nav",loop_type:"hash",pages:Array.from(c).map(l=>r+l),path_sequence:d}}),k=k.filter(l=>{let g=l.path.indexOf("#");return(g===-1?l.path:l.path.slice(0,g))!==r});return}}if(L.length<4)return;let i=!1,s=[];for(let a=0;a<L.length-1;a++)if(L[a].path===e){let c=L.slice(a,L.length),d=new Set(c.map(l=>l.path));if(d.size>=2){s.push(...Array.from(d)),i=!0;break}}if(i){let a=L.slice(-ki).map(c=>c.path);u({t:"sig",ts:t,d:{s:"loop_nav",loop_type:"path",pages:s,path_sequence:a}}),L=[{path:e,ts:t}],k=k.filter(c=>{let d=c.path.indexOf("#");return(d===-1?c.path:c.path.slice(0,d))!==r})}}var ec=100,xi=1e4,Zn=.5,C=[],Wt=0,Qn=0,Ve=!1,Gn=0,Ai=f(tc);function Jn(e){xi=e?.windowMs??1e4,Zn=e?.depthThreshold??.5,window.addEventListener("scroll",Ai,{passive:!0})}function er(){window.removeEventListener("scroll",Ai),C=[],Ve=!1}function tr(){C=[],Wt=0,Qn=0,Ve=!1}function tc(){Ve||(Ve=!0,requestAnimationFrame(()=>{Ve=!1,nc()}))}function nc(){let e=Date.now(),t=window.scrollY;if(Gn=document.documentElement.scrollHeight-window.innerHeight,Gn<=0)return;let n=t/Gn,r=t>Wt?"down":"up";if(e-Qn<100){Wt=t;return}for(;C.length&&e-C[0].ts>xi;)C.shift();C.length>=ec&&(C=C.slice(-50)),C.push({depth:n,ts:e,direction:r}),Wt=t,Qn=e;let o=0,i=1,s=0,a=!1,c=0,d=0,l=0,g=1,w=0;for(let E=1;E<C.length;E++)C[E].direction!==C[E-1].direction&&w++;for(let E=0;E<C.length;E++){let b=C[E],m=b.depth;if(m>o&&(o=m),m>=Zn&&(a||(c=b.ts,l=m),a=!0),a&&m<i&&(i=m,d=b.ts,g=m),a&&i<.25&&m>=Zn){if(d-c<200){a=!1,i=1,c=b.ts,l=m;continue}s++,a=!1,i=1}}if(s>=1){let E=Math.max(d-c,1),b=Math.abs(l-g)*100,m=Math.round(b/E*1e3);u({t:"sig",ts:e,d:{s:"scroll_bounce",depth:Math.round(o*100)/100,rev:s+1,vel:m,dir_changes:w}}),C=[]}}var rc=["textarea",'[role="textbox"]',"[contenteditable]"],qe=new Map,ze=new Map,Y=new Set,oe=null,nr=0,Di=5e3,Ri=[],oc=50,Ii=f(ic),Oi=f(sc),Ni=f(ac),Pi=y(Hi),Ue=null;function rr(e,t){Di=e?.pauseMs??5e3,Ri=t??[],document.addEventListener("focusin",Ii,{capture:!0,passive:!0}),document.addEventListener("focusout",Oi,{capture:!0,passive:!0}),document.addEventListener("submit",Ni,{capture:!0,passive:!0}),window.addEventListener("pagehide",Pi),Ue=y(()=>{document.visibilityState==="hidden"&&Hi()}),document.addEventListener("visibilitychange",Ue)}function or(){document.removeEventListener("focusin",Ii,{capture:!0}),document.removeEventListener("focusout",Oi,{capture:!0}),document.removeEventListener("submit",Ni,{capture:!0}),window.removeEventListener("pagehide",Pi),Ue&&(document.removeEventListener("visibilitychange",Ue),Ue=null),qe.clear(),ze.clear(),Y.clear(),oe=null}function ir(){qe.clear(),ze.clear(),Y.clear(),oe=null,nr=0}function ic(e){let t=e.target;if(!t||!Fi(t)||v(t,Ri)||lc(t))return;let n=Date.now();qe.set(t,n),ze.set(t,n);let r=t.closest("form");r&&r!==oe&&(oe=r,nr=r.querySelectorAll("input, select, textarea").length)}function sc(e){let t=e.target;if(!t||!Fi(t))return;let n=qe.get(t),r=ze.get(t);qe.delete(t),ze.delete(t);let o=Date.now();if(!(r!==void 0&&o-r<oc)&&n!==void 0){let a=o-n;if(a>=Di){let c=h(t);u({t:"sig",ts:o,d:{s:"form_hesitation",el:p(t),...c?{el_label:c}:{},pause:a}})}}let s=t.getAttribute("name")||t.getAttribute("id")||p(t);cc(t)&&Y.add(s)}function ac(){Y.clear(),oe=null}function Hi(){if(Y.size>0&&oe){let e=nr||Y.size,t=Math.round(Y.size/e*100)/100;u({t:"sig",ts:Date.now(),d:{s:"form_abandon",filled:Y.size,total:e,field_count:e,completion_rate:t}}),Y.clear(),oe=null}}function Fi(e){let t=e.tagName;return t==="INPUT"||t==="SELECT"||t==="TEXTAREA"}function lc(e){if(e.tagName==="TEXTAREA")return!0;for(let t of rc)try{if(e.matches(t))return!0}catch{return!1}return!1}function cc(e){return"value"in e?e.value.length>0:!1}var ge=null,Xe=null,Bi=/flusterduck\.com|\/v1\/ingest/,Vi=f(fc),Ui=f(pc);function ar(){window.addEventListener("error",Vi),window.addEventListener("unhandledrejection",Ui),mc()}function lr(){window.removeEventListener("error",Vi),window.removeEventListener("unhandledrejection",Ui),gc()}var sr=/fetch|network|cors|timeout/i;function uc(e){return sr.test(e)?"network":"script"}function dc(e){if(e instanceof TypeError&&sr.test(e.message)||typeof Response<"u"&&e instanceof Response)return"network";let t=e instanceof Error?e.message:String(e??"");return sr.test(t)?"network":"unhandled_promise"}function fc(e){let t=e.message||"Unknown error";u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"js_error",msg:cr(t,200),ep:"",status:0,error_category:uc(t),url:location.pathname}})}function pc(e){let t=e.reason instanceof Error?e.reason.message:String(e.reason??"");u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"unhandled_rejection",msg:cr(t,200),ep:"",status:0,error_category:dc(e.reason),url:location.pathname}})}function mc(){ge||(ge=window.fetch,Xe=function(t,n){let r;try{r=ge.call(this,t,n)}catch(o){throw o}return r.then(o=>{try{if(o.status>=400){let i=typeof t=="string"?t:t instanceof URL?t.pathname:t.url;Bi.test(i)||u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:`${o.status} ${o.statusText}`,ep:Wi(i),status:o.status,error_category:"network",url:location.pathname}})}}catch{}return o},o=>{try{let i=typeof t=="string"?t:t instanceof URL?t.href:t.url;Bi.test(i)||u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:cr(o instanceof Error?o.message:"Fetch failed",200),ep:typeof t=="string"?Wi(t):"",status:0,error_category:"network",url:location.pathname}})}catch{}throw o})},window.fetch=Xe)}function gc(){ge&&Xe&&window.fetch===Xe&&(window.fetch=ge),ge=null,Xe=null}function Wi(e){try{return new URL(e,location.origin).pathname}catch{let t=e.indexOf("?"),n=e.indexOf("#"),r=Math.min(t>=0?t:e.length,n>=0?n:e.length);return e.slice(0,r)||"/"}}function cr(e,t){let n=e.length>t?e.slice(0,t):e;return n=n.replace(/(?:token|key|secret|password|auth|bearer|jwt|session|cookie|credential)[=:]\s*\S+/gi,"[REDACTED]"),n=n.replace(/https?:\/\/[^\s]*[?&][^\s]*/g,r=>{try{return new URL(r).origin+new URL(r).pathname}catch{return"[URL]"}}),n}var qi=[".carousel",".slider",".swiper","[data-swipeable]",".drawer"],hc=['[class*="map"]',"canvas",".gallery","[data-zoom]"],Q=null,ve=0,$e=1,I=0,Ye=0,je=0,he=0,ur=0,dr=null,zi=[],Xi=f(vc),$i=f(wc),Yi=f(yc),ji=f(Tc),Ki=f(_c);function fr(e){zi=e??[],document.addEventListener("touchstart",Xi,{passive:!0}),document.addEventListener("touchend",$i,{passive:!0}),"ontouchstart"in window&&(document.addEventListener("gesturechange",Yi,{passive:!0}),window.addEventListener("orientationchange",ji,{passive:!0})),window.visualViewport?.addEventListener("resize",Ki)}function pr(){document.removeEventListener("touchstart",Xi),document.removeEventListener("touchend",$i),document.removeEventListener("gesturechange",Yi),window.removeEventListener("orientationchange",ji),window.visualViewport?.removeEventListener("resize",Ki),Q=null,ve=0,$e=1,I=0,Ye=0,je=0,he=0,ur=0,dr=null}function Gi(e){let t=e[0],n=e[1];if(!t||!n)return 0;let r=t.clientX-n.clientX,o=t.clientY-n.clientY;return Math.sqrt(r*r+o*o)}function vc(e){let t=e.touches[0];e.touches.length===1&&t?(Q={x:t.clientX,y:t.clientY,ts:Date.now()},ve=0):e.touches.length===2&&(ve=Gi(e.touches),Q=null)}function wc(e){if(ve>0){let s=e.touches.length>=2?Gi(e.touches):(()=>{let a=e.changedTouches[0],c=e.changedTouches[1];if(!a||!c)return 0;let d=a.clientX-c.clientX,l=a.clientY-c.clientY;return Math.sqrt(d*d+l*l)})();s>0&&($e=Math.round(s/ve*100)/100),ve=0}if(!Q||e.changedTouches.length!==1)return;let t=e.changedTouches[0];if(!t)return;let n=t.clientX-Q.x,r=t.clientY-Q.y,o=Date.now()-Q.ts,i=document.elementFromPoint(t.clientX,t.clientY);Math.abs(n)<10&&Math.abs(r)<10&&o<300&&i&&Ec(i,t.clientX,t.clientY),o<500&&(Math.abs(n)>50||Math.abs(r)>50)&&bc(i,n,r),Q=null}function Ec(e,t,n){if(v(e,zi))return;let r=Lc(e,t,n);if(!r)return;let o=r.getBoundingClientRect(),i=Math.max(o.left,Math.min(t,o.right)),s=Math.max(o.top,Math.min(n,o.bottom)),a=Math.sqrt((t-i)**2+(n-s)**2);if(a>0&&a<=20){let c=`${Math.round(o.width)}x${Math.round(o.height)}`;u({t:"sig",ts:Date.now(),d:{s:"tap_miss",el:p(r),dist:Math.round(a),size:c}})}}function bc(e,t,n){if(Math.abs(n)>Math.abs(t)||!e||qi.some(s=>{try{return e.matches(s)||e.closest(s)}catch{return!1}})||!qi.some(s=>{try{return document.querySelector(s)!==null}catch{return!1}}))return;let i=t>0?"right":"left";u({t:"sig",ts:Date.now(),d:{s:"swipe_miss",dir:i}})}function yc(){let e=Date.now();if(e-Ye>3e4&&(I=0,Ye=e),I++,I>=2){let t=document.activeElement||document.body;!hc.some(r=>{try{return t.matches(r)||t.closest(r)}catch{return!1}})&&e-je>200&&(je=e,u({t:"sig",ts:e,d:{s:"pinch_zoom",cnt:I,pinch_scale:$e}})),I=0,$e=1}}function _c(){let e=window.visualViewport;if(e&&e.scale>1.1){let t=Date.now();if(t-Ye>3e4&&(I=0,Ye=t),I++,I>=2&&t-je>200){let n=Math.round(e.scale*100)/100;je=t,u({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:I,pinch_scale:n}}),I=0,$e=1}}}function Sc(){return window.innerWidth>window.innerHeight?"landscape":"portrait"}function Tc(){let e=Date.now(),t=screen.orientation?.type||"unknown";e-ur>3e4&&(he=0,ur=e),t!==dr&&(he++,dr=t),he>=3&&(u({t:"sig",ts:e,d:{s:"orientation_thrash",cnt:he,orientation:Sc()}}),he=0)}function Lc(e,t,n){let o=(e.parentElement||document.body).querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])'),i=null,s=21;for(let a=0;a<o.length;a++){let c=o[a];if(!c)continue;let d=c.getBoundingClientRect(),l=Math.max(d.left,Math.min(t,d.right)),g=Math.max(d.top,Math.min(n,d.bottom)),w=Math.sqrt((t-l)**2+(n-g)**2);w<s&&w>0&&(s=w,i=c)}return i}var x=[],we=null,A=0,Ee=0,V="",W=[],mr=[],Cc=10,Mc=5e3,Zi=5,Qi=3e3,kc=15,xc=5e3,Ji=f(Ac);function gr(e){mr=e??[],document.addEventListener("keydown",Ji,{capture:!0,passive:!0})}function hr(){document.removeEventListener("keydown",Ji,{capture:!0}),x=[],W=[],we=null,A=0,Ee=0,V="",mr=[]}function Ac(e){let t=Date.now(),n=e.target;n&&v(n,mr)||(e.key==="Tab"?Rc(t,n,e.shiftKey):e.key==="Escape"?Ic(t,e.target):(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight")&&Oc(t,e.target))}function Dc(e){let t=0;for(let n=1;n<e.length;n++)e[n].shift!==e[n-1].shift&&t++;return t}function Rc(e,t,n){for(;x.length&&e-x[0].ts>Mc;)x.shift();x.length>=50&&(x=x.slice(-25));let r=t?p(t):"";if(x.push({ts:e,el:r,shift:n}),x.length>=Cc){let i=x.map(a=>a.el).filter(Boolean),s=Dc(x);u({t:"sig",ts:e,d:{s:"tab_thrash",cnt:x.length,els:i,direction_changes:s}}),x=[]}if(!t)return;let o=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');if(o){let i=p(t);o===we?e-Ee<=Qi?(A++,V=i,A>=Zi&&(u({t:"sig",ts:e,d:{s:"focus_trap",container:p(o),attempts:A,trapped_element:V}}),A=0,V="",we=null)):(Ee=e,A=1,V=i):(we=o,Ee=e,A=1,V=i)}}function Ic(e,t){if(!t)return;let n=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');if(n&&n===we){if(e-Ee>Qi){Ee=e,A=1,V=p(t);return}A++,V=p(t),A>=Zi&&(u({t:"sig",ts:e,d:{s:"focus_trap",container:p(n),attempts:A,trapped_element:V}}),A=0,V="",we=null)}}function Oc(e,t){if(!t)return;let n=t.closest('[role="listbox"]')||t.closest('[role="menu"]')||t.closest('[role="tree"]')||t.closest("select");if(!n)return;for(;W.length&&e-W[0].ts>xc;)W.shift();W.length>=50&&(W=W.slice(-25)),W.push({ts:e,container:n});let r=W.filter(o=>o.container===n);r.length>=kc&&(u({t:"sig",ts:e,d:{s:"keyboard_nav_frustration",container:p(n),keys:r.length}}),W=[])}var be=0,Vt=0,Ut=null,vr=0,qt=!1,zt=0,wr=0,Nc=1e4,Pc=2,Hc=4,Fc=3e3,Ke=null,Xt=0,Bc=2e3,es=f(Uc),ts=f(Wc),ns=f(Vc);function Er(){window.addEventListener("wheel",ts,{passive:!0}),window.addEventListener("touchmove",ns,{passive:!0}),window.addEventListener("scroll",es,{passive:!0})}function br(){window.removeEventListener("wheel",ts),window.removeEventListener("touchmove",ns),window.removeEventListener("scroll",es),$t()}function $t(){be=0,Vt=0,Ut=null,vr=0,qt=!1,zt=0,wr=0,Ke=null,Xt=0}function Wc(){Ke="wheel",Xt=Date.now()}function Vc(){Ke="touch",Xt=Date.now()}function Uc(){qt||(qt=!0,requestAnimationFrame(()=>{qt=!1,qc()}))}function qc(){let e=Date.now(),t=window.scrollY,n=t-Vt;if(Math.abs(n)<2){Vt=t;return}let r=n>0?"down":"up";if(Ut&&r!==Ut&&(e-vr>Fc&&(be=0,vr=e),be++,be>=Hc&&Math.abs(n)>100)){let i=e-Xt,s=Ke!==null&&i<=Bc?Ke:"wheel";e-wr>Nc&&(zt=0,wr=e),zt++;let a=zt>=Pc;u({t:"sig",ts:e,d:{s:"scroll_hijack",rev:be,source:s,repeated:a}}),be=0}Ut=r,Vt=t}var ie=0,ye=0,Ge=!1,os=f(zc),Ze=null,Qe=null;function yr(){window.addEventListener("scroll",os,{passive:!0}),Qe=y(rs),window.addEventListener("pagehide",Qe),Ze=y(()=>{document.visibilityState==="hidden"&&rs()}),document.addEventListener("visibilitychange",Ze)}function _r(){window.removeEventListener("scroll",os),Qe&&(window.removeEventListener("pagehide",Qe),Qe=null),Ze&&(document.removeEventListener("visibilitychange",Ze),Ze=null),ie=0,ye=0,Ge=!1}function Sr(){ie=0,ye=0,Ge=!1}function zc(){Ge||(Ge=!0,requestAnimationFrame(()=>{Ge=!1;let e=document.documentElement.scrollHeight-window.innerHeight;if(e>0){let t=window.scrollY/e;t>ie&&(ie=t,ye===0&&(ye=Date.now()))}}))}function rs(){if(ie>.05){let e=Date.now(),t=ye>0?Math.max(0,e-ye):0;u({t:"sig",ts:e,d:{s:"scroll_depth_abandon",depth:Math.round(ie*100)/100,max_depth:Math.round(ie*100),dwell_ms:t}})}}var is=1500,ss=15e3,Xc=5e3,$c=.15,Tr="",_e=0,Yt=0,Je=0,Se=0,Lr=0,jt=null,Kt=0,Gt=!1,Zt=f(jc),as=f(Kc),Te=f(Yc);function Cr(){Gt||(Gt=!0,Lr=ls(),et(),document.addEventListener("mouseenter",Zt,!0),document.addEventListener("mouseleave",Zt,!0),document.addEventListener("click",Te,{capture:!0,passive:!0}),document.addEventListener("keydown",Te,{capture:!0,passive:!0}),document.addEventListener("scroll",Te,{passive:!0}),window.addEventListener("resize",as,{passive:!0}))}function Mr(){Gt&&(Gt=!1,document.removeEventListener("mouseenter",Zt,!0),document.removeEventListener("mouseleave",Zt,!0),document.removeEventListener("click",Te,{capture:!0}),document.removeEventListener("keydown",Te,{capture:!0}),document.removeEventListener("scroll",Te),window.removeEventListener("resize",as),cs(),Tr="",_e=0,Yt=0,Se=0,Je=0,Kt=0)}function et(){cs(),Kt+=1;let e=Kt;jt=setTimeout(()=>{u({t:"sig",ts:Date.now(),d:{s:"user_confusion_idle",idle_ms:ss,cycle:e}})},ss)}function kr(){Kt=0}function Yc(){et()}function jc(e){if(e.type!=="mouseenter")return;let t=e.target;if(!t)return;let n=p(t),r=Date.now();(n!==Tr||r-Yt>is)&&(Tr=n,Yt=r,_e=0),_e+=1,!(_e<4)&&(u({t:"sig",ts:r,d:{s:"thrash_hover",el:n,cnt:_e,window_ms:is}}),_e=0,Yt=r)}function Kc(){let e=Date.now(),t=ls(),n=Lr||t,r=Math.abs(t-n)/Math.max(n,1);Lr=t,!(r<$c)&&((!Je||e-Je>Xc)&&(Je=e,Se=0),Se+=1,!(Se<3)&&(u({t:"sig",ts:e,d:{s:"viewport_thrashing",cnt:Se,area_delta:Math.round(r*1e3)/1e3}}),Se=0,Je=e))}function ls(){return Math.max(1,window.innerWidth*window.innerHeight)}function cs(){jt&&(clearTimeout(jt),jt=null)}var us=6e4,Gc=3,Zc=["[data-help]","[data-tooltip]","[data-faq]","[aria-describedby]",'[aria-label*="help" i]','[aria-label*="support" i]','[title*="help" i]','a[href*="/help"]','a[href*="/faq"]','a[href*="/support"]','a[href*="help."]',"details > summary",'[role="tooltip"]'],Qc=/\b(help|faq|support|tooltip|hint|guide|explain|learn.?more)\b/i,U=[],ds=[],fs=f(Jc);function xr(e){ds=e??[],document.addEventListener("click",fs,{capture:!0,passive:!0})}function Ar(){document.removeEventListener("click",fs,{capture:!0}),U=[]}function Dr(){U=[]}function Jc(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,ds)||!eu(t))return;let n=Date.now();for(;U.length&&n-U[0].t>us;)U.shift();let r=p(t);if(U.push({t:n,el:r}),U.length<Gc)return;let o=new Set(U.map(s=>s.el)).size,i=h(t);u({t:"sig",ts:n,d:{s:"help_hunt",cnt:U.length,unique_els:o,el:r,...i?{el_label:i}:{},window_ms:us}}),U=[]}function eu(e){let t=e;for(let n=0;n<3&&t;n++){if(tu(t)||nu(t))return!0;t=t.parentElement}return!1}function tu(e){for(let t of Zc)try{if(e.matches(t))return!0}catch{}return!1}function nu(e){let t=e.id??"",n=e.className??"",r=typeof n=="string"?`${t} ${n}`:t;return Qc.test(r)}var ps=/^(close|dismiss|modal-close|dialog-close|sheet-close|drawer-close)$/i,ms=/\b(close|dismiss|no\s*thanks?|maybe\s*later|skip|got\s*it|hide\s*this|don.?t\s*show)\b/i,Qt=[],Jt=new Map,gs=[],hs=f(ru);function Rr(e){gs=e??[],document.addEventListener("click",hs,{capture:!0,passive:!0})}function Ir(){document.removeEventListener("click",hs,{capture:!0}),Qt=[],Jt.clear()}function Or(){Qt=[],Jt.clear()}function ru(e){if(e.button!==0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,gs)||!ou(t))return;let n=Date.now(),r=p(t),o=h(t);Qt.push({t:n,el:r});let s=(Jt.get(r)??0)+1;Jt.set(r,s);let a=Qt.length,c=(()=>{try{let d=t.getBoundingClientRect();return d.width===0&&d.height===0?null:{click_dx:Math.round(e.clientX-(d.left+d.width/2)),click_dy:Math.round(e.clientY-(d.top+d.height/2)),el_w:Math.round(d.width),el_h:Math.round(d.height)}}catch{return null}})();u({t:"sig",ts:n,d:{s:"close_click",el:r,...o?{el_label:o}:{},session_cnt:a,element_cnt:s,repeated:s>1,container:su(t),...c??{}}})}function ou(e){let t=e;for(let n=0;n<4&&t;n++){if(iu(t))return!0;t=t.parentElement}return!1}function iu(e){let t=e.getAttribute("data-dismiss")??"",n=e.getAttribute("data-close")??"";if(t||n)return!0;let r=e.getAttribute("aria-label")??e.getAttribute("title")??"";if(r&&ms.test(r))return!0;let o=e.id??"",i=typeof e.className=="string"?e.className:"";if(ps.test(o)||ps.test(i))return!0;let s=(e.textContent??"").trim().slice(0,60);if(s&&ms.test(s))return!0;if(e.tagName==="BUTTON"&&e.closest('[role="dialog"], [role="alertdialog"], dialog, .modal, .drawer, .sheet, .overlay, .popup, [data-modal], [data-dialog]')){let c=(e.textContent??"").trim();if(c==="\xD7"||c==="\u2715"||c==="\u2717"||c==="X"||c==="x")return!0}return!1}function su(e){let t=[['[role="dialog"], dialog',"dialog"],['[role="alertdialog"]',"alert_dialog"],[".modal, [data-modal]","modal"],[".drawer, [data-drawer], .sheet, [data-sheet]","drawer"],[".toast, [data-toast], .notification, [data-notification]","toast"],['.banner, [data-banner], [role="banner"]',"banner"],[".cookie, [data-cookie], .consent, [data-consent]","consent"],[".popup, [data-popup], .overlay, [data-overlay]","popup"]];for(let[n,r]of t)try{if(e.closest(n))return r}catch{}return"unknown"}var au=1500,O=null,vs=[],ws=f(lu),Es=f(cu),bs=f(uu);function Nr(e){vs=e??[],document.addEventListener("click",ws,{capture:!0,passive:!0}),document.addEventListener("keydown",Es,{capture:!0,passive:!0}),window.addEventListener("popstate",bs)}function Pr(){document.removeEventListener("click",ws,{capture:!0}),document.removeEventListener("keydown",Es,{capture:!0}),window.removeEventListener("popstate",bs),O=null}function Hr(){O=null}function lu(e){if(e.button!==0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(t&&!v(t,vs)){if(du(t)){O=null;return}O={el:p(t),label:h(t),t:Date.now()}}}function cu(e){e.key==="Escape"&&ys("escape")}function uu(){ys("back_nav")}function ys(e){if(!O)return;let t=Date.now()-O.t;if(t>au){O=null;return}u({t:"sig",ts:Date.now(),d:{s:"close_click_reversal",reversal:e,el:O.el,...O.label?{el_label:O.label}:{},elapsed_ms:t}}),O=null}function du(e){return e.tagName==="A"?!0:e.closest('a, [role="link"], nav')!==null}var _s=1e4,fu=3,pu=/^(checkbox|radio)$/,Ss=/^(checkbox|radio|switch|tab|option|menuitemcheckbox|menuitemradio)$/,tt=new Map,Fr=[],Ts=f(mu),Ls=f(gu);function Br(e){Fr=e??[],document.addEventListener("change",Ts,{capture:!0,passive:!0}),document.addEventListener("click",Ls,{capture:!0,passive:!0})}function Wr(){document.removeEventListener("change",Ts,{capture:!0}),document.removeEventListener("click",Ls,{capture:!0}),tt.clear()}function Vr(){tt.clear()}function mu(e){let t=e.target;t&&(v(t,Fr)||hu(t)&&Cs(t))}function gu(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,Fr))return;let n=t.getAttribute("role")??"";Ss.test(n)&&t.tagName!=="INPUT"&&Cs(t)}function Cs(e){let t=p(e),n=Date.now(),r=tt.get(t);for(r||(r=[],tt.set(t,r));r.length&&n-r[0].t>_s;)r.shift();if(r.push({t:n}),r.length<fu)return;let o=h(e);u({t:"sig",ts:n,d:{s:"filter_spiral",el:t,...o?{el_label:o}:{},cnt:r.length,window_ms:_s}}),tt.delete(t)}function hu(e){return e.tagName==="SELECT"?!0:e.tagName==="INPUT"?pu.test(e.type??""):Ss.test(e.getAttribute("role")??"")}var Ms=15e3,vu=3,j=[],ks=f(wu);function Ur(){document.addEventListener("copy",ks,{capture:!0,passive:!0})}function qr(){document.removeEventListener("copy",ks,{capture:!0}),j=[]}function zr(){j=[]}function wu(e){let t=e.target;if(t){let o=t.tagName;if(o==="INPUT"||o==="TEXTAREA"||t.isContentEditable)return}let n=window.getSelection();if(!n||n.toString().length<2)return;let r=Date.now();for(;j.length&&r-j[0].t>Ms;)j.shift();j.push({t:r}),!(j.length<vu)&&(u({t:"sig",ts:r,d:{s:"copy_frustration",cnt:j.length,window_ms:Ms}}),j=[])}var xs=15e3,Eu=4,bu=5,yu=500,_u=2e3,D=[],en=0,nt=null,se=null;function Xr(){nt=y(Tu),se=y(Su),document.addEventListener("selectionchange",nt),document.addEventListener("copy",se,{capture:!0,passive:!0}),document.addEventListener("cut",se,{capture:!0,passive:!0})}function $r(){nt&&(document.removeEventListener("selectionchange",nt),nt=null),se&&(document.removeEventListener("copy",se,{capture:!0}),document.removeEventListener("cut",se,{capture:!0}),se=null),D=[],en=0}function Yr(){D=[],en=0}function Su(){en=Date.now(),D=[]}function Tu(){let e=window.getSelection();if(!e||e.isCollapsed||e.toString().length<bu)return;let n=e.anchorNode?.parentElement;if(n){let i=n.tagName;if(i==="INPUT"||i==="TEXTAREA"||n.isContentEditable)return}let r=Date.now();if(r-en<_u)return;for(;D.length&&r-D[0].t>xs;)D.shift();let o=D[D.length-1];o&&r-o.t<yu||(D.push({t:r}),!(D.length<Eu)&&(u({t:"sig",ts:r,d:{s:"text_select_frustration",cnt:D.length,window_ms:xs}}),D=[]))}var jr=6e4,Lu=20,Ds="_fd_sess",Cu={rage_click:25,dead_click:15,speed_frustration:20,thrash_cursor:10,loop_nav:20,scroll_bounce:12,form_hesitation:10,form_abandon:25,error_encounter:30,user_confusion_idle:15,thrash_hover:8,viewport_thrashing:10,scroll_depth_abandon:15,scroll_hijack:12,tab_thrash:15,focus_trap:20,help_hunt:18,close_click:12,close_click_reversal:20,filter_spiral:15,copy_frustration:12,text_select_frustration:10},Mu=10,As={low:1,medium:2,high:3,critical:4},q=[],Le=null,nn=!1,Me=new Map,Ce={totalSignals:0,pagesWithFrustration:0},Kr="",rt=null,ot=null,it=null,st=null;function tn(e){nn&&Rs(e,Date.now())}function ku(){try{let e=sessionStorage.getItem(Ds);if(e){let t=JSON.parse(e);Ce={totalSignals:typeof t.totalSignals=="number"?t.totalSignals:0,pagesWithFrustration:typeof t.pagesWithFrustration=="number"?t.pagesWithFrustration:0}}}catch{}}function xu(){try{sessionStorage.setItem(Ds,JSON.stringify(Ce))}catch{}}function Au(){let e=[],n=Date.now()-jr,r=[];for(let[o,i]of Me.entries())for(let s of i)s>=n&&r.push({type:o,ts:s});r.sort((o,i)=>o.ts-i.ts);for(let o=0;o<r.length;o++)if(r[o].type==="rage_click"){for(let i=o+1;i<r.length;i++)if(r[i].type==="form_validation_loop"&&r[i].ts-r[o].ts<=3e4){e.push("rage_then_form_loop");break}}for(let o=0;o<r.length;o++)if(r[o].type==="dead_click")for(let i=o+1;i<r.length;i++){let s=r[i].type;if((s==="popstate"||s==="hashchange")&&r[i].ts-r[o].ts<=1e4){e.push("dead_then_bail");break}}for(let o=0;o<r.length;o++)if(r[o].type==="form_validation_loop"){for(let i=o+1;i<r.length;i++)if((r[i].type==="visibilitychange"||r[i].type==="pagehide")&&r[i].ts-r[o].ts<=2e4){e.push("form_loop_then_abandon");break}}return e}function Rs(e,t){Me.has(e)||Me.set(e,[]);let n=Me.get(e);n.push(t),n.length>Lu&&n.shift()}function Du(e){let t=e-jr,n=0;for(;n<q.length&&q[n].ts<t;)n++;n>0&&(q=q.slice(n))}function Ru(){let e=new Map,t=0;for(let n of q)e.set(n.type,(e.get(n.type)??0)+1),t+=Cu[n.type]??Mu;return{distinctTypes:new Set(e.keys()),totalWeight:t,typeCounts:e}}function Is(e){let t="",n=0;for(let[r,o]of e)(o>n||o===n&&r<t)&&(t=r,n=o);return{type:t,count:n}}function Iu(e,t,n){return Is(n).count>=3&&e>=3?"critical":e>=4&&t>=70?"high":e>=3&&t>=40?"medium":e>=2&&t>=20?"low":null}function Ou(e,t,n,r){let o=Is(r),i=Au();u({t:"sig",ts:Date.now(),d:{s:"frustration_burst",level:e,page:Kr||void 0,distinct_types:t.size,total_weight:n,signals:Array.from(t).sort(),window_ms:jr,dominant:o.type,repeat_count:o.count,sequences:i,session_total_signals:Ce.totalSignals,session_pages_with_frustration:Ce.pagesWithFrustration}}),Ce.totalSignals+=q.length,Ce.pagesWithFrustration+=1,xu()}function Nu(e){if(!nn||e==="frustration_burst")return;let t=Date.now();Du(t),q.length===0&&(Le=null),q.push({type:e,ts:t}),Rs(e,t);let{distinctTypes:n,totalWeight:r,typeCounts:o}=Ru(),i=Iu(n.size,r,o);i&&(Le!==null&&As[i]<=As[Le]||(Le=i,Ou(i,n,r,o)))}function Gr(e){Kr=e}function Zr(e){q=[],Le=null,nn=!0,Me=new Map,Kr=e??"",ku(),Mn(Nu),rt=()=>tn("popstate"),ot=()=>tn("hashchange"),it=()=>{document.visibilityState==="hidden"&&tn("visibilitychange")},st=()=>tn("pagehide"),window.addEventListener("popstate",rt),window.addEventListener("hashchange",ot),document.addEventListener("visibilitychange",it),window.addEventListener("pagehide",st)}function Qr(){nn=!1,q=[],Le=null,Me=new Map,Mn(null),rt&&(window.removeEventListener("popstate",rt),rt=null),ot&&(window.removeEventListener("hashchange",ot),ot=null),it&&(document.removeEventListener("visibilitychange",it),it=null),st&&(window.removeEventListener("pagehide",st),st=null)}var Pu=8,Jr=3e4,eo=5,Hu=5e3,N=[],J="",at=!1,Os=f(Bu),Ns=f(Wu);function to(){N=[],at=!1,J=location.pathname+location.search+location.hash,window.addEventListener("popstate",Os),window.addEventListener("hashchange",Ns)}function no(){window.removeEventListener("popstate",Os),window.removeEventListener("hashchange",Ns),N=[],at=!1,J=""}function ro(){N=[],at=!1,J=location.pathname+location.search+location.hash}function lt(e){let t=Date.now();if(J&&J!==e){let n=N[N.length-1];n&&n.path===J&&n.leftAt===null&&(n.leftAt=t)}for(;N.length&&t-N[0].ts>Jr;)N.shift();e!==J&&(N.push({path:e,ts:t,leftAt:null}),J=e),!(N.length<eo)&&(at||Fu(t))}function Fu(e){let t=N.filter(l=>e-l.ts<=Jr),n=t.filter(l=>l.leftAt!==null),r=new Set(t.map(l=>l.path));if(r.size<eo||n.length===0||n.some(l=>l.leftAt-l.ts>=Hu)||new Set(n.map(l=>l.path)).size<eo)return;let s=n.map(l=>l.leftAt-l.ts),a=Math.round(s.reduce((l,g)=>l+g,0)/s.length),c=Math.max(...s),d=t.map(l=>l.path).slice(-Pu);at=!0,u({t:"sig",ts:e,d:{s:"navigation_confusion",page_count:r.size,window_ms:Jr,avg_dwell_ms:a,pages:d,max_dwell_ms:c}})}function Bu(){let e=location.pathname+location.search+location.hash;lt(e)}function Wu(){let e=location.pathname+location.search+location.hash;lt(e)}var Vu=.3,Ps=3e3,K=[],ct=!1,ae="none",le=0,ut=0,dt=0,P=!1,Hs=f(Uu),Fs=f(zu);function oo(){K=[],ae="none",le=0,ut=0,dt=0,P=!1,ct=!1,window.addEventListener("scroll",Hs,{passive:!0}),window.addEventListener("click",Fs,{capture:!0})}function io(){window.removeEventListener("scroll",Hs),window.removeEventListener("click",Fs,{capture:!0}),rn()}function rn(){K=[],ae="none",le=0,ut=0,dt=0,P=!1,ct=!1}function Uu(){ct||(ct=!0,requestAnimationFrame(qu))}function qu(){ct=!1;let e=Date.now(),t=window.scrollY,n=window.innerHeight,r=K[K.length-1];if(r&&e-r.ts<50||(K.push({y:t,ts:e}),K.length>60&&(K=K.slice(-40)),!r))return;let o=t-r.y;if(Math.abs(o)<2)return;if((o>0?"down":"up")==="down"){ae!=="down"&&P&&(P=!1),t>le&&(le=t),ae="down";return}if(P&&e-dt>Ps&&(P=!1),ae==="down"){let s=le-t,a=n*Vu;s>=a&&!P&&(ut=t,dt=e,P=!0)}ae="up"}function zu(e){if(!P)return;let t=Date.now();if(t-dt>Ps){P=!1;return}if(window.scrollY+e.clientY>ut+window.innerHeight*.1)return;let r=window.innerHeight,o=Math.round(le-ut),i=Math.round(o/r*100),s=e.target instanceof Element?e.target:null,a=s?p(s):"",c=s?h(s):"";P=!1,le=window.scrollY,ae="none",K=[],u({t:"sig",ts:t,d:{s:"scroll_to_click_confusion",reversal_depth_px:o,click_el:a,...c?{click_el_label:c}:{},scroll_back_pct:i}})}var Xu=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,$u=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,Yu=/^(A|BUTTON|LABEL)$/,ju=3,Bs=9e4,Ku=5,ft=new Map,Ws=[],pt=null,Gu=5,Vs=f(Zu),Us=f(rd);function Zu(e){pt={x:e.clientX,y:e.clientY}}function so(e){Ws=e??[],document.addEventListener("mousedown",Vs,{capture:!0,passive:!0}),document.addEventListener("click",Us,{capture:!0,passive:!0})}function ao(){document.removeEventListener("mousedown",Vs,{capture:!0}),document.removeEventListener("click",Us,{capture:!0}),pt=null,ft.clear()}function lo(){ft.clear()}function Qu(e,t){let n=Math.min(3,Math.floor(e/window.innerWidth*4));return{row:Math.min(3,Math.floor(t/window.innerHeight*4)),col:n}}function Ju(e,t){return e*4+t}function ed(e){if(Xu.test(e.tagName))return!0;let t=e.getAttribute("role");if(t&&$u.test(t)||e.hasAttribute("contenteditable")||e.hasAttribute("tabindex")&&e.getAttribute("tabindex")!=="-1"||e.hasAttribute("onclick")||e.hasAttribute("onmousedown")||e.hasAttribute("onmouseup"))return!0;let n=e.parentElement;return!!(n&&Yu.test(n.tagName)||e.closest('a, button, [role="button"], label, [onclick]'))}function td(){let e=window.getSelection();return e!==null&&e.toString().length>0}function nd(e){if(!pt)return!1;let t=e.clientX-pt.x,n=e.clientY-pt.y;return Math.sqrt(t*t+n*n)>Gu}function rd(e){if(e.button!==0||e.detail===0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,Ws)||td()||nd(e)||ed(t))return;let{row:n,col:r}=Qu(e.clientX,e.clientY),o=Ju(n,r),i=Date.now(),s=p(t),c=(ft.get(o)??[]).filter(d=>i-d.ts<Bs);if(c.push({ts:i,selector:s}),ft.set(o,c),c.length>=ju){let d=new Map;for(let m of c)d.set(m.selector,(d.get(m.selector)??0)+1);let l="",g=0;for(let[m,$]of d)$>g&&(g=$,l=m);let w=new Set,E=[];for(let m of c)if(!w.has(m.selector)&&(w.add(m.selector),E.push(m.selector),E.length>=Ku))break;let b=(()=>{try{let m=l?document.querySelector(l):null;return m?h(m):""}catch{return""}})();u({t:"sig",ts:i,d:{s:"dead_click_trap_zone",zone_row:n,zone_col:r,cnt:c.length,dominant_el:l,...b?{dominant_el_label:b}:{},elements:E,window_ms:Bs}}),ft.set(o,[])}}var co=3,ke=12e4,_=new Map,sn=[],mt=null,qs=f(ld),on=f(cd);function fo(e){sn=e??[],document.addEventListener("invalid",qs,{capture:!0,passive:!0}),document.addEventListener("input",on,{capture:!0,passive:!0}),document.addEventListener("change",on,{capture:!0,passive:!0}),mt=new MutationObserver(ud),mt.observe(document.body,{subtree:!0,attributeFilter:["aria-invalid"],attributes:!0,attributeOldValue:!0})}function po(){document.removeEventListener("invalid",qs,{capture:!0}),document.removeEventListener("input",on,{capture:!0}),document.removeEventListener("change",on,{capture:!0}),mt&&(mt.disconnect(),mt=null);for(let e of _.values())ee(e);_.clear()}function mo(){for(let e of _.values())ee(e);_.clear()}function uo(e){let t=e.tagName.toLowerCase();return t==="select"?"select":t==="textarea"?"textarea":t==="input"?e.type||"text":t}function go(e){let t=e.getAttribute("aria-invalid");if(t==="true"||t==="")return!0;if("validity"in e){let n=e;if(n.validity&&!n.validity.valid)return!0}try{return e.matches(":invalid")}catch{return!1}}function an(e){let t=e.tagName;return t==="INPUT"||t==="SELECT"||t==="TEXTAREA"}function od(e){for(let[t,n]of _)e-n.lastTs>ke&&(ee(n),_.delete(t))}function ee(e){e.el.removeEventListener("input",e.inputHandler),e.el.removeEventListener("change",e.changeHandler)}function id(e){return f(t=>{$s(e)})}function sd(e){return f(t=>{$s(e)})}function zs(e,t){let n=id(t),r=sd(t);e.addEventListener("input",n,{passive:!0}),e.addEventListener("change",r,{passive:!0});let o={cycles:0,lastTs:Date.now(),phase:"invalid",inputHandler:n,changeHandler:r,el:e};return _.set(t,o),o}function Xs(e){if(!an(e)||v(e,sn))return;let t=Date.now();od(t);let n=p(e),r=_.get(n);if(!r){zs(e,n);return}let o=r.lastTs;r.lastTs=t,r.phase==="edited"?(r.cycles+=1,r.phase="invalid",r.cycles>=co&&(u({t:"sig",ts:t,d:{s:"form_validation_loop",el:n,...h(e)?{el_label:h(e)}:{},cycles:r.cycles,window_ms:ke,field_type:uo(e)}}),ee(r),_.delete(n))):r.phase==="invalid"&&t-o>500&&(r.cycles+=1,r.cycles>=co&&(u({t:"sig",ts:t,d:{s:"form_validation_loop",el:n,...h(e)?{el_label:h(e)}:{},cycles:r.cycles,window_ms:ke,field_type:uo(e)}}),ee(r),_.delete(n)))}function ad(e){if(!an(e))return;let t=Date.now(),n=p(e),r=_.get(n);if(r){if(t-r.lastTs>ke){ee(r),_.delete(n);return}r.phase==="invalid"&&(r.phase="edited",r.lastTs=t)}}function $s(e){let t=Date.now(),n=_.get(e);if(n){if(t-n.lastTs>ke){ee(n),_.delete(e);return}if(n.lastTs=t,go(n.el)){n.cycles+=1,n.cycles>=co&&(u({t:"sig",ts:t,d:{s:"form_validation_loop",el:e,...h(n.el)?{el_label:h(n.el)}:{},cycles:n.cycles,window_ms:ke,field_type:uo(n.el)}}),ee(n),_.delete(e));return}n.phase==="invalid"&&(n.phase="edited")}}function ld(e){let t=e.target;t&&Xs(t)}function cd(e){let t=e.target;if(!t||!an(t)||v(t,sn))return;let n=p(t);_.has(n)||go(t)&&zs(t,n)}function ud(e){for(let t of e){if(t.type!=="attributes"||t.attributeName!=="aria-invalid")continue;let n=t.target;if(!an(n)||v(n,sn))continue;let r=t.oldValue,o=r==="true"||r==="",i=go(n);i&&!o?Xs(n):!i&&o&&ad(n)}}var xe=null,gt=null,vo=[],Ys=0,ht=new Map;function wo(e){vo=e?.length?e:["[data-fd-impression]"],Ys=Date.now(),!(typeof IntersectionObserver>"u")&&(xe=new IntersectionObserver(y(fd),{threshold:[0,.5,1]}),js(),gt=new MutationObserver(y(dd)),gt.observe(document.body,{childList:!0,subtree:!0}))}function Eo(){xe&&(xe.disconnect(),xe=null),gt&&(gt.disconnect(),gt=null),ht.clear()}function bo(){ht.clear(),xe&&js()}function js(){for(let e of vo)try{let t=document.querySelectorAll(e);for(let n=0;n<t.length;n++)ho(t[n])}catch{}}function ho(e){ht.has(e)||(ht.set(e,{firstSeenTs:0,emitted:!1}),xe.observe(e))}function dd(e){for(let t of e)for(let n=0;n<t.addedNodes.length;n++){let r=t.addedNodes[n];if(r instanceof Element)for(let o of vo)try{r.matches(o)&&ho(r);let i=r.querySelectorAll(o);for(let s=0;s<i.length;s++)ho(i[s])}catch{}}}function fd(e){let t=Date.now();for(let n of e){let r=ht.get(n.target);if(!(!r||r.emitted)&&n.isIntersecting&&n.intersectionRatio>=.5){r.firstSeenTs||(r.firstSeenTs=t),r.emitted=!0;let o=n.boundingClientRect,i=n.rootBounds?.height??window.innerHeight,s=o.top<i*.5?"above_fold":"below_fold",a=p(n.target),c=h(n.target);u({t:"sig",ts:t,d:{s:"element_impression",el:a,...c?{el_label:c}:{},visible_pct:Math.round(n.intersectionRatio*100),time_to_visible_ms:Math.round(t-Ys),viewport_position:s}})}}}var pd=2,md=3,gd=6e4,vt=new Map,Ks=[],Gs=f(hd);function yo(e){Ks=e??[],document.addEventListener("input",Gs,{capture:!0,passive:!0})}function _o(){document.removeEventListener("input",Gs,{capture:!0}),vt.clear()}function So(){vt.clear()}function hd(e){let t=e.target;if(!t||!vd(t)||v(t,Ks))return;let n=Date.now(),r=t.value??"",o=p(t),i=vt.get(o);if(!i){vt.set(o,{lastValue:r,cycles:0,phase:"typing",lastTs:n});return}if(n-i.lastTs>gd){i.lastValue=r,i.cycles=0,i.phase="typing",i.lastTs=n;return}i.lastTs=n;let s=i.lastValue.length-r.length;if(i.phase==="typing"&&s>=md)i.phase="deleted";else if(i.phase==="deleted"&&r.length>i.lastValue.length&&(i.cycles++,i.phase="typing",i.cycles>=pd)){let a=h(t);u({t:"sig",ts:n,d:{s:"input_correction",el:o,...a?{el_label:a}:{},cycles:i.cycles,field_type:wd(t)}}),vt.delete(o);return}i.lastValue=r}function vd(e){if(e.tagName==="TEXTAREA")return!0;if(e.tagName==="INPUT"){let t=e.type?.toLowerCase()??"text";return/^(text|email|search|url|tel|number|password)$/.test(t)}return!1}function wd(e){return e.tagName==="TEXTAREA"?"textarea":e.type?.toLowerCase()||"text"}var Zs=2e3,Ed=3e4,z=null,Qs=Zs,Js=[],ln=new Map,ea=f(bd),ta=f(yd),na=f(wt);function To(e,t){Qs=e?.dwellMs??Zs,Js=t??[],document.addEventListener("mouseover",ea,{passive:!0}),document.addEventListener("mouseout",ta,{passive:!0}),document.addEventListener("click",na,{capture:!0,passive:!0})}function Lo(){document.removeEventListener("mouseover",ea),document.removeEventListener("mouseout",ta),document.removeEventListener("click",na,{capture:!0}),wt(),ln.clear()}function Co(){wt(),ln.clear()}function bd(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,Js)||!_d(t))return;let n=p(t);if(z?.selector===n)return;wt();let r=Date.now();if(r-(ln.get(n)??0)<Ed)return;let o=r,i=setTimeout(()=>{let s=Date.now(),a=h(t);ln.set(n,s),z=null,u({t:"sig",ts:s,d:{s:"hover_dwell",el:n,...a?{el_label:a}:{},dwell_ms:Math.round(s-o)}})},Qs);z={el:t,selector:n,startTs:o,timer:i}}function yd(e){if(!z)return;let t=e.target;if(t!==z.el&&!z.el.contains(t))return;let n=e.relatedTarget;n&&z.el.contains(n)||wt()}function wt(){z&&(clearTimeout(z.timer),z=null)}function _d(e){let t=e.tagName;if(/^(A|BUTTON|SELECT)$/.test(t))return!0;let n=e.getAttribute("role")??"";if(/^(button|link|tab|menuitem|option|checkbox|radio)$/.test(n))return!0;try{let r=window.getComputedStyle(e);return r.cursor==="pointer"&&r.pointerEvents!=="none"}catch{return!1}}var Sd=20,Td=500,Ld=3e3,Cd=6e4,cn=0,un=0,X=null,ra=y(Md);function Mo(){cn=Date.now(),un=0,document.addEventListener("mouseleave",ra)}function ko(){document.removeEventListener("mouseleave",ra),X&&(clearTimeout(X),X=null)}function xo(){cn=Date.now(),un=0,X&&(clearTimeout(X),X=null)}function Md(e){if(e.clientY>Sd)return;let t=Date.now();t-cn<Ld||t-un<Cd||(X&&clearTimeout(X),X=setTimeout(y(()=>{let n=Date.now();un=n,X=null,u({t:"sig",ts:n,d:{s:"exit_intent",method:"top_chrome",time_on_page_ms:Math.round(n-cn)}})}),Td))}var kd=2500,xd=4e3,oa=200,Ad=500,Dd=.1,Rd=.25,De=null,Re=null,G=null,Ae=0;function Ao(e,t,n){return e<=t?"good":e<=n?"needs_improvement":"poor"}function Do(){if(!(typeof PerformanceObserver>"u")){try{De=new PerformanceObserver(y(e=>{let t=e.getEntries(),n=t[t.length-1];if(!n)return;let r=Math.round(n.startTime);u({t:"sig",ts:Date.now(),d:{s:"lcp",value_ms:r,rating:Ao(r,kd,xd)}})})),De.observe({type:"largest-contentful-paint",buffered:!0})}catch{De=null}try{Re=new PerformanceObserver(y(e=>{for(let t of e.getEntries()){let n=t;if(!n.interactionId)continue;let r=Math.round(n.duration);r<oa||u({t:"sig",ts:Date.now(),d:{s:"slow_interaction",value_ms:r,rating:Ao(r,oa,Ad)}})}})),Re.observe({type:"event",buffered:!1,durationThreshold:200})}catch{Re=null}try{G=new PerformanceObserver(y(e=>{for(let t of e.getEntries()){let n=t;n.hadRecentInput||(Ae+=n.value)}})),G.observe({type:"layout-shift",buffered:!0})}catch{G=null}}}function ia(){if(G){if(G.disconnect(),G=null,Ae>0){let e=Math.round(Ae*1e3)/1e3;u({t:"sig",ts:Date.now(),d:{s:"cls",value:e,rating:Ao(Ae,Dd,Rd)}})}Ae=0}}function Ro(){De&&(De.disconnect(),De=null),Re&&(Re.disconnect(),Re=null),ia()}function Io(){if(ia(),!(typeof PerformanceObserver>"u"))try{G=new PerformanceObserver(y(e=>{for(let t of e.getEntries()){let n=t;n.hadRecentInput||(Ae+=n.value)}})),G.observe({type:"layout-shift",buffered:!1})}catch{G=null}}var sa=[],aa=f(Id);function Oo(e){sa=e??[],document.addEventListener("paste",aa,{capture:!0,passive:!0})}function No(){document.removeEventListener("paste",aa,{capture:!0})}function Id(e){let t=e.target;if(!t||!Od(t)||v(t,sa))return;let n=t.value??"";setTimeout(()=>{if((t.value??"")!==n)return;let o=p(t),i=h(t);u({t:"sig",ts:Date.now(),d:{s:"paste_blocked",el:o,...i?{el_label:i}:{},field_type:Nd(t)}})},100)}function Od(e){if(e.tagName==="TEXTAREA")return!0;if(e.tagName==="INPUT"){let t=e.type?.toLowerCase()??"text";return/^(text|email|search|url|tel|number|password)$/.test(t)}return!1}function Nd(e){return e.tagName==="TEXTAREA"?"textarea":e.type?.toLowerCase()||"text"}var Pd="https://api.flusterduck.com/v1/ingest",te=!1,dn=null,Ie=null,Et="__flusterduck_instance__",Po=`fd_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;function Hd(){let e=window;return e[Et]&&e[Et]!==Po?(console.warn("[flusterduck] Another SDK instance is already active on this page. Skipping init to avoid double tracking. Load the SDK either via npm or via the script tag, not both."),!1):(e[Et]=Po,!0)}function Fd(){let e=window;e[Et]===Po&&delete e[Et]}var bt=[];function Bd(e,t,n){let r=i=>e.signals?.[i]?.enabled!==!1,o=e.trackForms!==!1;return[{when:()=>r("rageClick"),start:()=>Dn(e.signals?.rageClick,t),stop:Rn},{when:()=>r("deadClick"),start:()=>In(t),stop:On,reset:Nn},{when:()=>r("speedFrustration"),start:()=>{let i=e.signals?.speedFrustration;Hn(i?{delayMs:i.windowMs}:void 0,t)},stop:Fn,reset:Bn},{when:()=>e.trackMouse!==!1&&r("thrashCursor"),start:()=>{let i=e.signals?.thrashCursor;qn(i?{velocityThreshold:i.threshold,windowMs:i.windowMs}:void 0)},stop:zn},{when:()=>r("loopNav"),start:()=>Yn(e.signals?.loopNav),stop:jn},{when:()=>r("scrollBounce"),start:Jn,stop:er,reset:tr},{when:()=>o&&(r("formHesitation")||r("formAbandon")),start:()=>{let i=e.signals?.formHesitation;rr(i?{pauseMs:i.threshold}:void 0,t)},stop:or,reset:ir},{when:()=>o&&r("formValidationLoop"),start:()=>fo(t),stop:po,reset:mo},{when:()=>r("errorEncounter"),start:ar,stop:lr},{when:()=>"ontouchstart"in window||navigator.maxTouchPoints>0,start:()=>fr(t),stop:pr},{when:()=>r("tabThrash")||r("focusTrap")||r("keyboardNavFrustration"),start:()=>gr(t),stop:hr},{when:()=>r("scrollHijack"),start:Er,stop:br,reset:$t},{when:()=>r("scrollDepthAbandon"),start:yr,stop:_r,reset:Sr},{when:()=>r("advancedHeuristics"),start:Cr,stop:Mr,reset:()=>{et(),kr()}},{when:()=>r("helpHunt"),start:()=>xr(t),stop:Ar,reset:Dr},{when:()=>r("closeClick"),start:()=>Rr(t),stop:Ir,reset:Or},{when:()=>r("closeClickReversal"),start:()=>Nr(t),stop:Pr,reset:Hr},{when:()=>r("filterSpiral"),start:()=>Br(t),stop:Wr,reset:Vr},{when:()=>r("copyFrustration"),start:Ur,stop:qr,reset:zr},{when:()=>r("textSelectFrustration"),start:Xr,stop:$r,reset:Yr},{when:()=>r("deadClickTrapZone"),start:()=>so(t),stop:ao,reset:lo},{when:()=>!0,start:()=>Zr(n),stop:Qr},{when:()=>r("navigationConfusion"),start:to,stop:no,reset:ro},{when:()=>r("scrollToClickConfusion"),start:oo,stop:io,reset:rn},{when:()=>r("elementImpression"),start:()=>wo(e.elementImpressionSelectors),stop:Eo,reset:bo},{when:()=>o&&r("inputCorrection"),start:()=>yo(t),stop:_o,reset:So},{when:()=>o&&r("pasteBlocked"),start:()=>Oo(t),stop:No},{when:()=>r("hoverDwell"),start:()=>{let i=e.signals?.hoverDwell;To(i?.threshold?{dwellMs:i.threshold}:void 0,t)},stop:Lo,reset:Co},{when:()=>r("exitIntent"),start:Mo,stop:ko,reset:xo},{when:()=>r("performanceVitals"),start:Do,stop:Ro,reset:Io}]}function Wd(e){if(e)try{let t=new URL(e),n=t.protocol==="http:"&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(t.hostname);return t.protocol!=="https:"&&!n?void 0:t.origin+t.pathname}catch{return}}function Ho(e){if(te||!e.key)return;if(e.key.startsWith("fd_sec_")){console.error("[flusterduck] Secret key detected in browser. Use a publishable key (fd_pub_) instead. Aborting.");return}if(!e.key.startsWith("fd_pub_"))return;if(e.respectDoNotTrack!==!1&&Vd()){Ie=e;return}if(e.sampleRate!==void 0&&e.sampleRate<1&&Math.random()>e.sampleRate){Ie=e;return}if(!Hd()){Ie=e;return}Ie=e,te=!0;let t=$o(e.cookieless??!1),n=Wd(e.endpoint)??Pd,r=An(location.pathname,e.pageRules??[]),o=Ud(e.domMode);si(n,{sid:t,key:e.key,url:location.origin+location.pathname,page:r,ua:navigator.userAgent.slice(0,200),vw:window.innerWidth,vh:window.innerHeight,segment:e.segment,environment:e.environment},e.batchInterval,e.batchMaxSize,{domMode:o,compression:e.compression});let i=la(location.pathname,e.ignorePages??[]);i&&kn(!0);let s=document.referrer,a="";if(s)try{a=new URL(s).origin+new URL(s).pathname}catch{a=""}i||u({t:"pv",ts:Date.now(),d:{ref:a}});let c=e.ignoreElements??[];bt=[];for(let d of Bd(e,c,r))d.when()&&(d.start(),bt.push({stop:d.stop,reset:d.reset}));dn=ci(y((d,l)=>{ne();for(let E of bt)E.reset?.();lt(l),Gr(l);let g=An(l,e.pageRules??[]),w=la(l,e.ignorePages??[]);kn(w),xn({page:g,url:d}),Kn(l),w||u({t:"pv",ts:Date.now(),d:{ref:""}})})),e.debug&&console.warn("[flusterduck] initialized",{sid:t.slice(0,6)+"...",endpoint:n,page:r})}function ca(e,t){if(!te||typeof e!="string"||!e||e.length>128)return;let n;try{let o=t?.metadata??{};n=JSON.stringify(o)}catch{return}if(n.length>2048)return;let r=JSON.parse(n);u({t:"sig",ts:Date.now(),d:{s:e.slice(0,128),el:typeof t?.element=="string"?t.element.slice(0,256):"",meta:r,w:Math.max(0,Math.min(t?.weight??15,100))}})}function ua(e,t={}){if(!te||typeof e!="string"||!/^[a-z0-9_.-]{1,120}$/i.test(e))return;let n;try{n=JSON.stringify(t??{})}catch{return}n.length>2048||u({t:"custom_signal",ts:Date.now(),d:{business_event:e.slice(0,120),meta:JSON.parse(n)}})}function da(e){if(!te||!e||typeof e!="object")return;let t=Object.create(null),n=0;for(let r of Object.keys(e)){if(n>=20)break;r==="__proto__"||r==="constructor"||r==="prototype"||(t[r.slice(0,64)]=String(e[r]).slice(0,256),n++)}xn({segment:t})}function fa(e){e&&Ie&&!te?Ho(Ie):e||(fn(),_n())}function pa(){fn(),_n()}function fn(){if(te){for(let e of bt)e.stop();bt=[],ai(),dn&&(dn(),dn=null),Fd(),te=!1}}function Vd(){return!!(navigator.doNotTrack==="1"||navigator.globalPrivacyControl)}function Ud(e){return e==="metadata"||e==="snapshot"?e:"off"}function la(e,t){for(let n of t)if(n){if(n.endsWith("*")){if(e.startsWith(n.slice(0,-1)))return!0}else if(n.startsWith("*")){if(e.endsWith(n.slice(1)))return!0}else if(e===n)return!0}return!1}var va=.1,wa=.01,Ea=3e4,ba=50,ya=1e4,qd=500,zd=3e4,Xd=6e4,ma=10,$d=new Set(["$rageclick","$dead_click","$exception","$identify","$create_alias","$groupidentify","$survey_sent","$survey_dismissed","$feature_flag_called"]),Yd=/(sign(ed)?[\s_-]?up|check(ed)?[\s_-]?out|purchase|subscri|payment|paid|upgrade|convert|trial|onboard.*complete|order[\s_-]?(placed|completed))/i,jd=/^\$\$?(heatmap|scroll)/,_a=["rage_click","rage_click_repeat_target","dead_click","error_encounter","form_validation_loop","thrash_cursor"],hn=!1,pn=null,mn=null,yt=null,H=null,gn=null,Sa=va,Ta=wa,La=new Set,Ca=new Set(_a),Ma=Ea,Wo=ba,ka=ya,R=[],vn=0,F=[];function ga(e,t){return e===void 0||Number.isNaN(e)?t:Math.max(0,Math.min(e,1))}function xa(e){hn||(hn=!0,Sa=ga(e?.baselineSampleRate,va),Ta=ga(e?.scrollSampleRate,wa),La=new Set(e?.conversionEvents??[]),Ca=new Set(e?.criticalSignals?.length?e.criticalSignals:_a),Ma=e?.bufferWindowMs&&e.bufferWindowMs>0?e.bufferWindowMs:Ea,Wo=e?.bufferMaxEvents&&e.bufferMaxEvents>0?e.bufferMaxEvents:ba,ka=e?.boostWindowMs&&e.boostWindowMs>0?e.boostWindowMs:ya,R=[],vn=0,F=[],mn=ri(tf),ha()||(pn=setInterval(()=>{ha()&&Vo()},qd),setTimeout(()=>Vo(),zd)))}function Aa(){hn&&(hn=!1,Vo(),mn&&(mn(),mn=null),yt&&gn&&yt.capture.__fd_wrapped&&(yt.capture=gn),yt=null,H=null,gn=null,R=[],F=[],vn=0)}function Vo(){pn&&(clearInterval(pn),pn=null)}function ha(){try{let e=window.posthog;if(!e||typeof e.capture!="function"||e.__loaded!==!0)return!1;if(e.capture.__fd_wrapped)return!0;gn=e.capture,H=e.capture.bind(e);let n=(r,o,i)=>{try{return Gd(r,o,i)}catch{return H?H(r,o,i):void 0}};return n.__fd_wrapped=!0,e.capture=n,yt=e,!0}catch{return!1}}function Kd(e){return $d.has(e)?"critical":La.has(e)||Yd.test(e)?"conversion":jd.test(e)?"scroll":"baseline"}function Gd(e,t,n){if(!H)return;if(typeof e!="string"||!e)return H(e,t,n);let r=Date.now(),o=Kd(e);if(o==="critical"||o==="conversion")return H(e,Bo(t,r),n);if(r<vn)return H(e,{...Bo(t,r),fd_boosted:!0},n);if(Zd(o==="scroll"?Ta:Sa))return H(e,Bo(t,r),n);ef({name:e,properties:t,ts:r})}function Zd(e){if(e>=1)return!0;if(e<=0)return!1;let t=Qd();return t?Jd(t)%1e4/1e4<e:Math.random()<e}var Fo="";function Qd(){try{let e=window.posthog;if(e?.get_distinct_id){let t=e.get_distinct_id();if(typeof t=="string"&&t)return t}}catch{}return Fo||(Fo=Math.random().toString(36).slice(2)),Fo}function Jd(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function Bo(e,t){return Ra(t),F.length?{...e,fd_recent_signals:F.map(n=>n.name),fd_signal_count:F.length}:e??{}}function ef(e){R.push(e),Da(e.ts)}function Da(e){let t=e-Ma;for(;R.length&&R[0].ts<t;)R.shift();R.length>Wo&&(R=R.slice(-Wo))}function Ra(e){let t=e-Xd;F=F.filter(n=>n.ts>=t),F.length>ma&&(F=F.slice(-ma))}function tf(e,t){if(F.push({name:e,ts:t}),Ra(t),!Ca.has(e)||(vn=t+ka,!H||!R.length))return;Da(t);let n=R;R=[];for(let r of n)try{H(r.name,{...r.properties,fd_recovered:!0,fd_recovered_reason:e,fd_original_ts:r.ts},{timestamp:new Date(r.ts)})}catch{}}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export { init, signal, track, identify, setConsent, optOut, destroy } from './core';
2
+ export { initPostHogTrigger, destroyPostHogTrigger } from './posthog-trigger';
3
+ export type { PostHogTriggerOptions } from './posthog-trigger';
2
4
  export type { Config, SDKEvent, SnapshotData } from './types';
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- function S(e){return((...t)=>{try{return e(...t)}catch{}})}function d(e){return t=>{try{e(t)}catch{}}}var Me="_fd_s";var Pn=/^[0-9a-f]{32}$/;function Tt(e){if(e)return St();let t=Fn(Me);if(t&&Pn.test(t))return t;let n=St();return Mt(Me,n,30),n}function Ae(){Mt(Me,"",-1)}function St(){let e=new Uint8Array(16);crypto.getRandomValues(e);let t="";for(let n of e)t+=n.toString(16).padStart(2,"0");return t}function Fn(e){let t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?.[1]?decodeURIComponent(t[1]):null}function Mt(e,t,n){let o=new Date;o.setTime(o.getTime()+n*864e5);let r=location.protocol==="https:"?";Secure":"";document.cookie=`${e}=${encodeURIComponent(t)};path=/;expires=${o.toUTCString()};SameSite=Lax${r}`}var Bn=/^[:\d]|--|^(ember|react|ng-|__)/;function m(e){if(!e||e===document.documentElement)return"html";let t=e.getAttribute("data-fd");if(t)return`[data-fd="${Y(t)}"]`;if(e.id&&!Bn.test(e.id)&&e.id.length<64)return"#"+Y(e.id);let n=[],o=e,r=0;for(;o&&o!==document.body&&r<5;){let i=o.tagName.toLowerCase(),c=o.getAttribute("name"),s=o.getAttribute("role"),a=o.getAttribute("type");c&&c.length<64?i+=`[name="${Y(c)}"]`:s?i+=`[role="${Y(s)}"]`:a&&(i==="input"||i==="button")&&(i+=`[type="${Y(a)}"]`);let u=o.parentElement;if(u){let p=u.children,w=0,V=0;for(let O=0;O<p.length;O++){let Te=p[O];Te&&Te.tagName===o.tagName&&(w++,Te===o&&(V=w))}w>1&&(i+=`:nth-of-type(${V})`)}n.unshift(i);let f=n.join(" > ");try{if(document.querySelectorAll(f).length===1)return f}catch{}o=u,r++}return n.join(" > ")}function Y(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):e.replace(/([^\w-])/g,"\\$1")}function b(e,t){if(e.hasAttribute("data-fd-ignore")||e.closest("[data-fd-ignore]"))return!0;for(let n of t)try{if(e.matches(n)||e.closest(n))return!0}catch{}return!1}function xt(e,t){if(t==="off")return null;if(t==="metadata")return Un(e);let n=Hn(e);return n?{mode:"snapshot",...n}:null}function Un(e){return{mode:"metadata",selector:m(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),attributes:{disabled:e.disabled===!0,required:e.required===!0,ariaDisabled:e.getAttribute("aria-disabled")==="true",ariaExpanded:At(e.getAttribute("aria-expanded"),["true","false"]),ariaInvalid:At(e.getAttribute("aria-invalid"),["true","false","grammar","spelling"]),type:zn(e)}}}function Hn(e){try{let t=e.getBoundingClientRect(),n=getComputedStyle(e),o=e.parentElement,r=[];if(o)for(let c=0;c<o.children.length&&r.length<6;c++){let s=o.children[c];if(!s||s===e)continue;let a=s.getBoundingClientRect();r.push({selector:m(s),tag:s.tagName.toLowerCase(),box:{x:Math.round(a.x),y:Math.round(a.y),w:Math.round(a.width),h:Math.round(a.height)},interactive:jn(s)})}let i=[];try{let c=e.getAnimations();for(let s of c)"animationName"in s&&i.push(s.animationName)}catch{}return{selector:m(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),parent:o?m(o):"",box:{x:Math.round(t.x),y:Math.round(t.y),w:Math.round(t.width),h:Math.round(t.height)},styles:{opacity:n.opacity,cursor:n.cursor,pointerEvents:n.pointerEvents,display:n.display,visibility:n.visibility,disabled:e.disabled===!0},inView:qn(t),animations:i,siblings:r}}catch{return null}}function At(e,t){return e&&t.includes(e)?e:null}function zn(e){let t=e.tagName.toLowerCase();if(t!=="input"&&t!=="button")return null;let n=e.getAttribute("type");return n&&/^[a-z0-9_-]{1,32}$/i.test(n)?n.toLowerCase():null}function qn(e){return e.top<window.innerHeight&&e.bottom>0&&e.left<window.innerWidth&&e.right>0}function jn(e){let t=e.tagName;if(/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/.test(t))return!0;let n=e.getAttribute("role");return!!(n&&/^(button|link|tab|menuitem|checkbox|radio)$/.test(n))}var Lt=7e3,Vn=5e3,Yn=1e4,_t=50,Rt=100,Xn=3,X=6e4,se="application/json",$n="application/json; encoding=gzip",N=[],x=null,ae="",Dt=Lt,Ct=_t,v=null,ce={domMode:"off",compression:"auto"},xe=!1,Wn=new Set(["sid","key","url","page","ua","vw","vh","segment","environment"]),Kn=new Set(["click","move","scroll","keyboard","form_focus","form_blur","form_submit","touch","navigation","error","signal","pageview","custom_signal","performance","visibility","sdk_error"]),Qn=/(?:value|text|label|email|e-mail|name|phone|address|password|token|secret|cookie|session|jwt|auth|credential|card|cc|cvv|ssn)/i,Gn=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,Ot=d(Zn),Nt=S(()=>R());function It(e,t,n,o,r){ae=e,v=Object.assign(Object.create(null),t),ce={domMode:ao(r?.domMode),compression:co(r?.compression)},Dt=Math.max(Vn,Math.min(n??Lt,Yn)),Ct=Math.max(5,Math.min(o??_t,Rt)),document.addEventListener("visibilitychange",Ot),window.addEventListener("pagehide",Nt)}function l(e){N.length>=Rt||(N.push(e),N.length>=Ct?R():x||(x=setTimeout(R,Dt)))}function R(){Jn()}async function Jn(){if(xe||!N.length||!v)return;xe=!0,x&&(clearTimeout(x),x=null);let e=N;N=[];let t={v:1,sid:v.sid,key:v.key,url:v.url,page:v.page,ts:Date.now(),ua:v.ua,vw:v.vw,vh:v.vh,environment:v.environment,dom_mode:ce.domMode},n=e.map(r=>oo(r,v.page,ce.domMode)),o=[];try{for(let r of n){let i=[...o,r];if(JSON.stringify({...t,events:i}).length>X)if(o.length>0)await ke({...t,events:o}),o=[r];else{let s={...t,events:[r]};JSON.stringify(s).length<=X&&await ke(s),o=[]}else o=i}o.length>0&&await ke({...t,events:o})}catch{}finally{xe=!1}}function Le(e){if(v)for(let t of Object.keys(e))Wn.has(t)&&(v[t]=e[t])}function Pt(){R(),document.removeEventListener("visibilitychange",Ot),window.removeEventListener("pagehide",Nt),x&&(clearTimeout(x),x=null)}function Zn(){document.visibilityState==="hidden"&&R()}async function ke(e){let t=JSON.stringify(e),n=await eo(t,ce.compression);n&&Ft(n,0)}async function eo(e,t){let n=new TextEncoder().encode(e);if(n.byteLength>X)return null;if(t!=="off"){let r=await to(e);if(r&&r.byteLength<=X)return{beaconBody:new Blob([r],{type:$n}),fetchBody:new Uint8Array(r),headers:{"Content-Type":se,"Content-Encoding":"gzip"}}}return{beaconBody:new Blob([n],{type:se}),fetchBody:e,headers:{"Content-Type":se}}}async function to(e){let t=globalThis.CompressionStream;if(typeof t!="function")return null;try{let n=no(e);if(!n)return null;let o=new t("gzip"),i=n.pipeThrough(o).getReader(),c=[],s=0;for(;;){let f=await i.read();if(f.done)break;if(s+=f.value.byteLength,s>X)return null;let p=new Uint8Array(f.value.byteLength);p.set(f.value),c.push(p)}let a=new Uint8Array(s),u=0;for(let f of c)a.set(f,u),u+=f.byteLength;return a.buffer}catch{return null}}function no(e){let t=new TextEncoder().encode(e),n=new Blob([t],{type:se});if(typeof n.stream=="function")return n.stream();let o=globalThis.ReadableStream;return typeof o!="function"?null:new o({start(r){r.enqueue(t),r.close()}})}function Ft(e,t){if(ae&&!(navigator.sendBeacon&&navigator.sendBeacon(ae,e.beaconBody)))try{fetch(ae,{method:"POST",body:e.fetchBody,headers:e.headers,keepalive:!0}).catch(()=>{t<Xn&&setTimeout(()=>Ft(e,t+1),1e3*(t+1))})}catch{}}function oo(e,t,n){let o=e.d??{},r=ro(e.t),i={type:r,ts:e.ts,page:typeof o.page=="string"?o.page.slice(0,2048):t},c=kt(o.el,o.element,o.target);if(r==="signal"){i.signal_type=kt(o.s,o.signal_type,o.name)?.slice(0,128),c&&(i.element=c.slice(0,2048));let a=c?so(c,n):null;a&&(i.dom=a)}let s=io(o);return Object.keys(s).length&&(i.metadata=s),i}function ro(e){return e==="pv"?"pageview":e==="sig"?"signal":Kn.has(e)?e:"custom_signal"}function io(e){let t=Object.create(null);for(let n of Object.keys(e)){if(["s","signal_type","name","el","element","target","dom","page","meta"].includes(n))continue;let o=ue(e[n],n);o!==void 0&&(t[n.slice(0,64)]=o)}if(e.meta&&typeof e.meta=="object"&&!Array.isArray(e.meta)){let n=ue(e.meta,"meta");n&&typeof n=="object"&&!Array.isArray(n)&&Object.assign(t,n)}return t}function ue(e,t="",n=0){if(!(n>4)&&!Qn.test(t)){if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string")return Gn.test(e)?void 0:e.slice(0,500);if(Array.isArray(e))return e.slice(0,20).map(r=>ue(r,t,n+1)).filter(r=>r!==void 0);if(typeof e=="object"){let o=Object.create(null);for(let r of Object.keys(e).slice(0,40)){if(r==="__proto__"||r==="constructor"||r==="prototype")continue;let i=ue(e[r],r,n+1);i!==void 0&&(o[r.slice(0,64)]=i)}return o}}}function so(e,t){if(t==="off")return null;try{let n=document.querySelector(e);return n?xt(n,t):null}catch{return null}}function kt(...e){for(let t of e)if(typeof t=="string"&&t)return t}function ao(e){return e==="metadata"||e==="snapshot"?e:"off"}function co(e){return e==="off"?"off":"auto"}function Bt(e){let t=location.href;function n(){let s=location.href;s!==t&&(t=s,e(s,location.pathname))}let o=history.pushState,r=history.replaceState,i=function(...s){o.apply(this,s),n()},c=function(...s){r.apply(this,s),n()};return history.pushState=i,history.replaceState=c,window.addEventListener("popstate",n),window.addEventListener("hashchange",n),function(){history.pushState===i&&(history.pushState=o),history.replaceState===c&&(history.replaceState=r),window.removeEventListener("popstate",n),window.removeEventListener("hashchange",n)}}function _e(e,t){for(let n of t){let o=lo(n.pattern);if(o&&o.test(e))return n.label}return fo(e)}var uo=/^[a-zA-Z0-9/:._*\-]+$/;function lo(e){if(e.length>200||!uo.test(e))return null;let t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/:\w+/g,"[^/]+");try{return new RegExp("^"+t+"$")}catch{return null}}function fo(e){return e.replace(/\/\d+/g,"/:id").replace(/\/[a-f0-9-]{36}/g,"/:id")}var mo=[".carousel-arrow",".slick-arrow",".swiper-button-next",".swiper-button-prev","[data-carousel]",'button[aria-label*="next"]','button[aria-label*="prev"]','button[aria-label*="slide"]',".quantity-btn",".qty-btn",'input[type="number"]'],k=[],Re=3,Ht=2e3,Ut=8,zt=[],qt=d(po);function De(e,t){Re=e?.threshold??3,Ht=e?.windowMs??2e3,zt=[...mo,...t??[]],document.addEventListener("click",qt,{capture:!0,passive:!0})}function Ce(){document.removeEventListener("click",qt,{capture:!0,passive:!0}),k=[]}function po(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||b(t,zt)||ho(t))return;let n=Date.now(),o=e.clientX,r=e.clientY;for(;k.length&&n-k[0].t>Ht;)k.shift();if(k.push({t:n,x:o,y:r}),k.length<Re)return;let i=k.slice(-Re),c=i[0];for(let p=1;p<i.length;p++){let w=i[p],V=w.x-c.x,O=w.y-c.y;if(V*V+O*O>Ut*Ut)return}let s=c.t,u=(i[i.length-1].t-s)/1e3,f=u>0?i.length/u:i.length;l({t:"sig",ts:n,d:{s:"rage_click",el:m(t),cnt:i.length,vel:Math.round(f*10)/10}}),k=[]}function ho(e){let t=e.tagName;return!!(t==="VIDEO"||t==="AUDIO"||e.hasAttribute("ondblclick"))}var go=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,vo=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,wo=/^(A|BUTTON|LABEL)$/,jt=[],$=null,bo=5,Vt=d(yo),Yt=d(Eo);function yo(e){$={x:e.clientX,y:e.clientY}}function Oe(e){jt=e??[],document.addEventListener("mousedown",Vt,{capture:!0,passive:!0}),document.addEventListener("click",Yt,{capture:!0,passive:!0})}function Ne(){document.removeEventListener("mousedown",Vt,{capture:!0}),document.removeEventListener("click",Yt,{capture:!0}),$=null}function Eo(e){if(e.button!==0||e.detail===0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||b(t,jt)||Mo()||Ao(e)||So(t))return;let n=To(t,e.clientX,e.clientY),o=n?Xt(e.clientX,e.clientY,n):-1;l({t:"sig",ts:Date.now(),d:{s:"dead_click",el:m(t),near:n?m(n):"",dist:Math.round(o)}})}function So(e){if(go.test(e.tagName))return!0;let t=e.getAttribute("role");if(t&&vo.test(t)||e.hasAttribute("contenteditable")||e.hasAttribute("tabindex")&&e.getAttribute("tabindex")!=="-1"||e.hasAttribute("onclick")||e.hasAttribute("onmousedown")||e.hasAttribute("onmouseup"))return!0;let n=e.parentElement;return!!(n&&wo.test(n.tagName)||e.closest('a, button, [role="button"], label, [onclick]'))}function To(e,t,n){let o=e;for(let r=0;r<5&&o;r++){let i=o.parentElement;if(!i)break;let c=i.querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]'),s=null,a=1/0;for(let u=0;u<c.length;u++){let f=c[u];if(!f||f===e)continue;let p=Xt(t,n,f);p<a&&(a=p,s=f)}if(s&&a<100)return s;o=i}return null}function Xt(e,t,n){let o=n.getBoundingClientRect(),r=Math.max(o.left,Math.min(e,o.right)),i=Math.max(o.top,Math.min(t,o.bottom)),c=e-r,s=t-i;return Math.sqrt(c*c+s*s)}function Mo(){let e=window.getSelection();return e!==null&&e.toString().length>0}function Ao(e){if(!$)return!1;let t=e.clientX-$.x,n=e.clientY-$.y;return Math.sqrt(t*t+n*n)>bo}var h=null,Ie=3e3,$t=[],xo=/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/,ko=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton)$/,Wt=d(Lo);function Pe(e,t){Ie=e?.delayMs??3e3,$t=t??[],document.addEventListener("click",Wt,{capture:!0,passive:!0})}function Fe(){document.removeEventListener("click",Wt,{capture:!0}),W()}function Lo(e){let t=e.target;if(!t||b(t,$t))return;let n=t.getAttribute("role");if(!xo.test(t.tagName)&&!(n&&ko.test(n)))return;if(h){if(h.el===t||h.el.contains(t)){let a=Date.now()-h.ts;a>=Ie&&l({t:"sig",ts:Date.now(),d:{s:"speed_frustration",el:h.selector,delay:a}}),W();return}W()}let o=m(t),r=!1,i=new MutationObserver(a=>{for(let u of a){if(u.type==="childList"&&(u.addedNodes.length>0||u.removedNodes.length>0)){r=!0,W();return}if(u.type==="attributes"&&u.target instanceof Element&&(u.target===t||t.contains(u.target)||u.target.contains(t))){r=!0,W();return}}}),c=t.parentElement||document.body;i.observe(c,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-hidden","disabled"]});let s=setTimeout(()=>{!r&&h&&(h={...h,timeout:null})},Ie+500);h={el:t,selector:o,ts:Date.now(),observer:i,timeout:s}}function W(){h&&(h.observer.disconnect(),h.timeout&&clearTimeout(h.timeout),h=null)}var _o=100,Qt=800,Gt=2e3,Ro=3,Kt=0,Do=16,le=0,de=0,K=0,Q=0,G=0,fe=0,Be=0,D=[],I=null,Jt=d(Co);function Ue(e){Qt=e?.velocityThreshold??800,Gt=e?.windowMs??2e3,document.addEventListener("mousemove",Jt,{passive:!0})}function He(){document.removeEventListener("mousemove",Jt),I&&clearTimeout(I),ze()}function Co(e){let t=Date.now();t-Kt<Do||(Kt=t,I&&clearTimeout(I),I=setTimeout(()=>ze(),150),Oo(e.clientX,e.clientY,t))}function Oo(e,t,n){if(K===0){le=e,de=t,K=n,Be=n;return}let o=(n-K)/1e3;if(o===0)return;let r=e-le,i=t-de;if(Math.abs(r)<2&&Math.abs(i)<2)return;let s=Math.sqrt(r*r+i*i)/o;D.length>=_o&&(D=D.slice(-50)),D.push(s);let a=Math.sign(r),u=Math.sign(i);if((Q!==0&&a!==0&&a!==Q||G!==0&&u!==0&&u!==G)&&fe++,Q=a||Q,G=u||G,le=e,de=t,K=n,n-Be>Gt){if(fe>=Ro){let f=D.reduce((p,w)=>p+w,0)/D.length;f>=Qt&&l({t:"sig",ts:n,d:{s:"thrash_cursor",vel:Math.round(f),rev:fe}})}ze(),Be=n}}function ze(){fe=0,D=[],Q=0,G=0,K=0,le=0,de=0,I=null}var No=100,g=[],Zt=3e4;function qe(e){Zt=e?.windowMs??3e4}function je(){g=[]}function Ve(e){let t=Date.now();try{let i=performance.getEntriesByType("navigation");if(i.length>0&&i[0].type==="back_forward")return}catch{}for(;g.length&&t-g[0].ts>Zt;)g.shift();if(g.length>=No&&(g=g.slice(-50)),g.push({path:e,ts:t}),g.length<4)return;let n=e,o=!1,r=[];for(let i=0;i<g.length-1;i++)if(g[i].path===n){let c=g.slice(i,g.length),s=new Set(c.map(a=>a.path));if(s.size>=2){r.push(...Array.from(s)),o=!0;break}}o&&(l({t:"sig",ts:t,d:{s:"loop_nav",pages:r}}),g=[{path:e,ts:t}])}var Io=100,en=1e4,$e=.5,y=[],me=0,We=0,Ye=!1,Xe=0,tn=d(Po);function Ke(e){en=e?.windowMs??1e4,$e=e?.depthThreshold??.5,window.addEventListener("scroll",tn,{passive:!0})}function Qe(){window.removeEventListener("scroll",tn),y=[]}function Ge(){y=[],me=0,We=0}function Po(){Ye||(Ye=!0,requestAnimationFrame(()=>{Ye=!1,Fo()}))}function Fo(){let e=Date.now(),t=window.scrollY;if(Xe=document.documentElement.scrollHeight-window.innerHeight,Xe<=0)return;let n=t/Xe,o=t>me?"down":"up";if(e-We<100){me=t;return}for(;y.length&&e-y[0].ts>en;)y.shift();y.length>=Io&&(y=y.slice(-50)),y.push({depth:n,ts:e,direction:o}),me=t,We=e;let r=0,i=1,c=0,s=!1;for(let a=0;a<y.length;a++){let u=y[a].depth;u>r&&(r=u),u>=$e&&(s=!0),s&&u<i&&(i=u),s&&i<.25&&u>=$e&&(c++,s=!1,i=1)}c>=1&&(l({t:"sig",ts:e,d:{s:"scroll_bounce",depth:Math.round(r*100)/100,rev:c+1}}),y=[])}var Bo=["textarea",'[role="textbox"]',"[contenteditable]"],Z=new Map,L=new Set,C=null,Je=0,nn=5e3,on=[],rn=d(Uo),sn=d(Ho),an=d(zo),cn=S(un),J=null;function Ze(e,t){nn=e?.pauseMs??5e3,on=t??[],document.addEventListener("focusin",rn,{capture:!0,passive:!0}),document.addEventListener("focusout",sn,{capture:!0,passive:!0}),document.addEventListener("submit",an,{capture:!0,passive:!0}),window.addEventListener("pagehide",cn),J=S(()=>{document.visibilityState==="hidden"&&un()}),document.addEventListener("visibilitychange",J)}function et(){document.removeEventListener("focusin",rn,{capture:!0}),document.removeEventListener("focusout",sn,{capture:!0}),document.removeEventListener("submit",an,{capture:!0}),window.removeEventListener("pagehide",cn),J&&(document.removeEventListener("visibilitychange",J),J=null),Z.clear(),L.clear(),C=null}function tt(){Z.clear(),L.clear(),C=null,Je=0}function Uo(e){let t=e.target;if(!t||!ln(t)||b(t,on)||qo(t))return;Z.set(t,Date.now());let n=t.closest("form");n&&n!==C&&(C=n,Je=n.querySelectorAll("input, select, textarea").length)}function Ho(e){let t=e.target;if(!t||!ln(t))return;let n=Z.get(t);if(Z.delete(t),n){let r=Date.now()-n;r>=nn&&l({t:"sig",ts:Date.now(),d:{s:"form_hesitation",el:m(t),pause:r}})}let o=t.getAttribute("name")||t.getAttribute("id")||m(t);jo(t)&&L.add(o)}function zo(){L.clear(),C=null}function un(){L.size>0&&C&&(l({t:"sig",ts:Date.now(),d:{s:"form_abandon",filled:L.size,total:Je||L.size}}),L.clear(),C=null)}function ln(e){let t=e.tagName;return t==="INPUT"||t==="SELECT"||t==="TEXTAREA"}function qo(e){if(e.tagName==="TEXTAREA")return!0;for(let t of Bo)try{if(e.matches(t))return!0}catch{return!1}return!1}function jo(e){return"value"in e?e.value.length>0:!1}var P=null,ee=null,dn=/flusterduck\.com|\/v1\/ingest/,mn=d(Vo),pn=d(Yo);function nt(){window.addEventListener("error",mn),window.addEventListener("unhandledrejection",pn),Xo()}function ot(){window.removeEventListener("error",mn),window.removeEventListener("unhandledrejection",pn),$o()}function Vo(e){l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"js_error",msg:rt(e.message||"Unknown error",200),ep:"",status:0}})}function Yo(e){let t=e.reason instanceof Error?e.reason.message:String(e.reason??"");l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"unhandled_rejection",msg:rt(t,200),ep:"",status:0}})}function Xo(){P||(P=window.fetch,ee=function(t,n){let o;try{o=P.call(this,t,n)}catch(r){throw r}return o.then(r=>{try{if(r.status>=400){let i=typeof t=="string"?t:t instanceof URL?t.pathname:t.url;dn.test(i)||l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:`${r.status} ${r.statusText}`,ep:fn(i),status:r.status}})}}catch{}return r},r=>{try{let i=typeof t=="string"?t:t instanceof URL?t.href:t.url;dn.test(i)||l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:rt(r instanceof Error?r.message:"Fetch failed",200),ep:typeof t=="string"?fn(t):"",status:0}})}catch{}throw r})},window.fetch=ee)}function $o(){P&&ee&&window.fetch===ee&&(window.fetch=P),P=null,ee=null}function fn(e){try{return new URL(e,location.origin).pathname}catch{let t=e.indexOf("?"),n=e.indexOf("#"),o=Math.min(t>=0?t:e.length,n>=0?n:e.length);return e.slice(0,o)||"/"}}function rt(e,t){let n=e.length>t?e.slice(0,t):e;return n=n.replace(/(?:token|key|secret|password|auth|bearer|jwt|session|cookie|credential)[=:]\s*\S+/gi,"[REDACTED]"),n=n.replace(/https?:\/\/[^\s]*[?&][^\s]*/g,o=>{try{return new URL(o).origin+new URL(o).pathname}catch{return"[URL]"}}),n}var hn=[".carousel",".slider",".swiper","[data-swipeable]",".drawer"],Wo=['[class*="map"]',"canvas",".gallery","[data-zoom]"],F=null,T=0,pe=0,te=0,gn=0,vn=null,wn=[],bn=d(Ko),yn=d(Qo),En=d(Zo),Sn=d(tr),Tn=d(er);function it(e){wn=e??[],document.addEventListener("touchstart",bn,{passive:!0}),document.addEventListener("touchend",yn,{passive:!0}),"ontouchstart"in window&&(document.addEventListener("gesturechange",En,{passive:!0}),window.addEventListener("orientationchange",Sn,{passive:!0})),window.visualViewport?.addEventListener("resize",Tn)}function st(){document.removeEventListener("touchstart",bn),document.removeEventListener("touchend",yn),document.removeEventListener("gesturechange",En),window.removeEventListener("orientationchange",Sn),window.visualViewport?.removeEventListener("resize",Tn)}function Ko(e){let t=e.touches[0];e.touches.length===1&&t&&(F={x:t.clientX,y:t.clientY,ts:Date.now()})}function Qo(e){if(!F||e.changedTouches.length!==1)return;let t=e.changedTouches[0];if(!t)return;let n=t.clientX-F.x,o=t.clientY-F.y,r=Date.now()-F.ts,i=document.elementFromPoint(t.clientX,t.clientY);Math.abs(n)<10&&Math.abs(o)<10&&r<300&&i&&Go(i,t.clientX,t.clientY),r<500&&(Math.abs(n)>50||Math.abs(o)>50)&&Jo(i,n,o),F=null}function Go(e,t,n){if(b(e,wn))return;let o=nr(e,t,n);if(!o)return;let r=o.getBoundingClientRect(),i=Math.max(r.left,Math.min(t,r.right)),c=Math.max(r.top,Math.min(n,r.bottom)),s=Math.sqrt((t-i)**2+(n-c)**2);if(s>0&&s<=20){let a=`${Math.round(r.width)}x${Math.round(r.height)}`;l({t:"sig",ts:Date.now(),d:{s:"tap_miss",el:m(o),dist:Math.round(s),size:a}})}}function Jo(e,t,n){if(Math.abs(n)>Math.abs(t)||!e||hn.some(c=>{try{return e.matches(c)||e.closest(c)}catch{return!1}})||!hn.some(c=>{try{return document.querySelector(c)!==null}catch{return!1}}))return;let i=t>0?"right":"left";l({t:"sig",ts:Date.now(),d:{s:"swipe_miss",dir:i}})}function Zo(){let e=Date.now();if(e-pe>3e4&&(T=0,pe=e),T++,T>=2){let t=document.activeElement||document.body;Wo.some(o=>{try{return t.matches(o)||t.closest(o)}catch{return!1}})||l({t:"sig",ts:e,d:{s:"pinch_zoom",cnt:T}}),T=0}}function er(){let e=window.visualViewport;if(e&&e.scale>1.1){let t=Date.now();t-pe>3e4&&(T=0,pe=t),T++,T>=2&&(l({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:T}}),T=0)}}function tr(){let e=Date.now(),t=screen.orientation?.type||"unknown";e-gn>3e4&&(te=0,gn=e),t!==vn&&(te++,vn=t),te>=3&&(l({t:"sig",ts:e,d:{s:"orientation_thrash",cnt:te}}),te=0)}function nr(e,t,n){let r=(e.parentElement||document.body).querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])'),i=null,c=21;for(let s=0;s<r.length;s++){let a=r[s];if(!a)continue;let u=a.getBoundingClientRect(),f=Math.max(u.left,Math.min(t,u.right)),p=Math.max(u.top,Math.min(n,u.bottom)),w=Math.sqrt((t-f)**2+(n-p)**2);w<c&&w>0&&(c=w,i=a)}return i}var E=[],B=null,A=0,at=0,M=[],or=10,rr=5e3,Mn=5,ir=3e3,sr=15,ar=5e3,An=d(cr);function ct(){document.addEventListener("keydown",An,{capture:!0,passive:!0})}function ut(){document.removeEventListener("keydown",An,{capture:!0}),E=[],M=[],B=null}function cr(e){let t=Date.now(),n=e.target;n&&b(n,[])||(e.key==="Tab"?ur(t,n):e.key==="Escape"?lr(t,e.target):(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight")&&dr(t,e.target))}function ur(e,t){for(;E.length&&e-E[0].ts>rr;)E.shift();E.length>=50&&(E=E.slice(-25));let n=t?m(t):"";if(E.push({ts:e,el:n}),E.length>=or){let r=E.map(i=>i.el).filter(Boolean);l({t:"sig",ts:e,d:{s:"tab_thrash",cnt:E.length,els:r}}),E=[]}if(!t)return;let o=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');o&&(o===B?e-at<=ir?(A++,A>=Mn&&(l({t:"sig",ts:e,d:{s:"focus_trap",container:m(o),attempts:A}}),A=0,B=null)):(at=e,A=1):(B=o,at=e,A=1))}function lr(e,t){if(!t)return;let n=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');n&&n===B&&(A++,A>=Mn&&(l({t:"sig",ts:e,d:{s:"focus_trap",container:m(n),attempts:A}}),A=0,B=null))}function dr(e,t){if(!t)return;let n=t.closest('[role="listbox"]')||t.closest('[role="menu"]')||t.closest('[role="tree"]')||t.closest("select");if(!n)return;for(;M.length&&e-M[0].ts>ar;)M.shift();M.length>=50&&(M=M.slice(-25)),M.push({ts:e,container:n});let o=M.filter(r=>r.container===n);o.length>=sr&&(l({t:"sig",ts:e,d:{s:"keyboard_nav_frustration",container:m(n),keys:o.length}}),M=[])}var U=0,he=0,ge=null,lt=0,ve=!1,fr=4,mr=3e3,xn=d(pr);function dt(){window.addEventListener("scroll",xn,{passive:!0})}function ft(){window.removeEventListener("scroll",xn),U=0,he=0,ge=null,lt=0,ve=!1}function pr(){ve||(ve=!0,requestAnimationFrame(()=>{ve=!1,hr()}))}function hr(){let e=Date.now(),t=window.scrollY,n=t-he;if(Math.abs(n)<2){he=t;return}let o=n>0?"down":"up";ge&&o!==ge&&(e-lt>mr&&(U=0,lt=e),U++,U>=fr&&Math.abs(n)>100&&(l({t:"sig",ts:e,d:{s:"scroll_hijack",rev:U}}),U=0)),ge=o,he=t}var H=0,we=!1,kn=d(gr),Ln=S(_n),ne=null;function mt(){window.addEventListener("scroll",kn,{passive:!0}),window.addEventListener("pagehide",Ln),ne=S(()=>{document.visibilityState==="hidden"&&_n()}),document.addEventListener("visibilitychange",ne)}function pt(){window.removeEventListener("scroll",kn),window.removeEventListener("pagehide",Ln),ne&&(document.removeEventListener("visibilitychange",ne),ne=null),H=0,we=!1}function ht(){H=0}function gr(){we||(we=!0,requestAnimationFrame(()=>{we=!1;let e=document.documentElement.scrollHeight-window.innerHeight;if(e>0){let t=window.scrollY/e;t>H&&(H=t)}}))}function _n(){H>.05&&l({t:"sig",ts:Date.now(),d:{s:"scroll_depth_abandon",depth:Math.round(H*100)/100}})}var Rn=1500,Dn=15e3,vr=5e3,wr=.15,vt="",z=0,gt=0,oe=0,q=0,wt=0,be=null,ye=!1,Ee=d(yr),Cn=d(Er),j=d(br);function bt(){ye||(ye=!0,wt=On(),re(),document.addEventListener("mouseenter",Ee,!0),document.addEventListener("mouseleave",Ee,!0),document.addEventListener("click",j,{capture:!0,passive:!0}),document.addEventListener("keydown",j,{capture:!0,passive:!0}),document.addEventListener("scroll",j,{passive:!0}),window.addEventListener("resize",Cn,{passive:!0}))}function yt(){ye&&(ye=!1,document.removeEventListener("mouseenter",Ee,!0),document.removeEventListener("mouseleave",Ee,!0),document.removeEventListener("click",j,{capture:!0}),document.removeEventListener("keydown",j,{capture:!0}),document.removeEventListener("scroll",j),window.removeEventListener("resize",Cn),Nn(),vt="",z=0,q=0,oe=0)}function re(){Nn(),be=setTimeout(()=>{l({t:"sig",ts:Date.now(),d:{s:"user_confusion_idle",idle_ms:Dn}})},Dn)}function br(){re()}function yr(e){let t=e.target;if(!t)return;let n=m(t),o=Date.now();(n!==vt||o-gt>Rn)&&(vt=n,gt=o,z=0),z+=1,!(z<4)&&(l({t:"sig",ts:o,d:{s:"thrash_hover",el:n,cnt:z,window_ms:Rn}}),z=0,gt=o)}function Er(){let e=Date.now(),t=On(),n=wt||t,o=Math.abs(t-n)/Math.max(n,1);wt=t,!(o<wr)&&((!oe||e-oe>vr)&&(oe=e,q=0),q+=1,!(q<3)&&(l({t:"sig",ts:e,d:{s:"viewport_thrashing",cnt:q,area_delta:Math.round(o*1e3)/1e3}}),q=0,oe=e))}function On(){return Math.max(1,window.innerWidth*window.innerHeight)}function Nn(){be&&(clearTimeout(be),be=null)}var Sr="https://api.flusterduck.com/v1/ingest",_=!1,Se=null,ie=null;function Tr(e){if(e)try{let t=new URL(e),n=t.protocol==="http:"&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(t.hostname);return t.protocol!=="https:"&&!n?void 0:t.origin+t.pathname}catch{return}}function In(e){if(_||!e.key)return;if(e.key.startsWith("fd_sec_")){console.error("[flusterduck] Secret key detected in browser. Use a publishable key (fd_pub_) instead. Aborting.");return}if(!e.key.startsWith("fd_pub_"))return;if(e.respectDoNotTrack!==!1&&_r()){ie=e;return}if(e.sampleRate!==void 0&&e.sampleRate<1&&Math.random()>e.sampleRate){ie=e;return}ie=e,_=!0;let t=Tt(e.cookieless??!1),n=Tr(e.endpoint)??Sr,o=_e(location.pathname,e.pageRules??[]),r=Rr(e.domMode);It(n,{sid:t,key:e.key,url:location.origin+location.pathname,page:o,ua:navigator.userAgent.slice(0,200),vw:window.innerWidth,vh:window.innerHeight,segment:e.segment,environment:e.environment},e.batchInterval,e.batchMaxSize,{domMode:r,compression:e.compression});let i=document.referrer,c="";if(i)try{c=new URL(i).origin+new URL(i).pathname}catch{c=""}l({t:"pv",ts:Date.now(),d:{ref:c}});let s=e.ignoreElements??[],a=u=>e.signals?.[u]?.enabled!==!1;if(a("rageClick")&&De(e.signals?.rageClick,s),a("deadClick")&&Oe(s),a("speedFrustration")){let u=e.signals?.speedFrustration;Pe(u?{delayMs:u.windowMs}:void 0,s)}if(e.trackMouse!==!1&&a("thrashCursor")&&Ue(e.signals?.thrashCursor),a("loopNav")&&qe(e.signals?.loopNav),a("scrollBounce")&&Ke(),e.trackForms!==!1&&(a("formHesitation")||a("formAbandon"))){let u=e.signals?.formHesitation;Ze(u?{pauseMs:u.threshold}:void 0,s)}a("errorEncounter")&&nt(),("ontouchstart"in window||navigator.maxTouchPoints>0)&&it(s),(a("tabThrash")||a("focusTrap")||a("keyboardNavFrustration"))&&ct(),a("scrollHijack")&&dt(),a("scrollDepthAbandon")&&mt(),a("advancedHeuristics")&&bt(),Se=Bt(S((u,f)=>{R(),Ge(),tt(),ht(),re();let p=_e(f,e.pageRules??[]);Le({page:p,url:u}),Ve(f),l({t:"pv",ts:Date.now(),d:{ref:""}})})),e.debug&&console.warn("[flusterduck] initialized",{sid:t.slice(0,6)+"...",endpoint:n,page:o})}function Mr(e,t){if(!_||typeof e!="string"||!e||e.length>128)return;let n;try{let r=t?.metadata??{};n=JSON.stringify(r)}catch{return}if(n.length>2048)return;let o=JSON.parse(n);l({t:"sig",ts:Date.now(),d:{s:e.slice(0,128),el:typeof t?.element=="string"?t.element.slice(0,256):"",meta:o,w:Math.max(0,Math.min(t?.weight??15,100))}})}function Ar(e,t={}){if(!_||typeof e!="string"||!/^[a-z0-9_.-]{1,120}$/i.test(e))return;let n;try{n=JSON.stringify(t??{})}catch{return}n.length>2048||l({t:"custom_signal",ts:Date.now(),d:{business_event:e.slice(0,120),meta:JSON.parse(n)}})}function xr(e){if(!_||!e||typeof e!="object")return;let t=Object.create(null),n=0;for(let o of Object.keys(e)){if(n>=20)break;o==="__proto__"||o==="constructor"||o==="prototype"||(t[o.slice(0,64)]=String(e[o]).slice(0,256),n++)}Le({segment:t})}function kr(e){e&&ie&&!_?In(ie):e||(Et(),Ae())}function Lr(){Et(),Ae()}function Et(){_&&(Ce(),Ne(),Fe(),He(),je(),Qe(),et(),ot(),st(),ut(),ft(),pt(),yt(),Pt(),Se&&(Se(),Se=null),_=!1)}function _r(){return!!(navigator.doNotTrack==="1"||navigator.globalPrivacyControl)}function Rr(e){return e==="metadata"||e==="snapshot"?e:"off"}export{Et as destroy,xr as identify,In as init,Lr as optOut,kr as setConsent,Mr as signal,Ar as track};
1
+ function y(e){return((...t)=>{try{return e(...t)}catch{}})}function f(e){return t=>{try{e(t)}catch{}}}var En="_fd_s";var Ma=/^[0-9a-f]{32}$/;function zo(e){if(e)return qo();let t=ka(En);if(t&&Ma.test(t))return t;let n=qo();return Xo(En,n,30),n}function bn(){Xo(En,"",-1)}function qo(){let e=new Uint8Array(16);crypto.getRandomValues(e);let t="";for(let n of e)t+=n.toString(16).padStart(2,"0");return t}function ka(e){let t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?.[1]?decodeURIComponent(t[1]):null}function Xo(e,t,n){let r=new Date;r.setTime(r.getTime()+n*864e5);let o=location.protocol==="https:"?";Secure":"";document.cookie=`${e}=${encodeURIComponent(t)};path=/;expires=${r.toUTCString()};SameSite=Lax${o}`}var xa=/^[:\d]|--|^(ember|react|ng-|__)/;function p(e){if(!e||e===document.documentElement)return"html";let t=e.getAttribute("data-fd");if(t)return`[data-fd="${Ne(t)}"]`;if(e.id&&!xa.test(e.id)&&e.id.length<64)return"#"+Ne(e.id);let n=[],r=e,o=0;for(;r&&r!==document.body&&o<5;){let i=r.tagName.toLowerCase(),s=r.getAttribute("name"),a=r.getAttribute("role"),c=r.getAttribute("type");s&&s.length<64?i+=`[name="${Ne(s)}"]`:a?i+=`[role="${Ne(a)}"]`:c&&(i==="input"||i==="button")&&(i+=`[type="${Ne(c)}"]`);let d=r.parentElement;if(d){let g=d.children,w=0,E=0;for(let b=0;b<g.length;b++){let m=g[b];m&&m.tagName===r.tagName&&(w++,m===r&&(E=w))}w>1&&(i+=`:nth-of-type(${E})`)}n.unshift(i);let l=n.join(" > ");try{if(document.querySelectorAll(l).length===1)return l}catch{}r=d,o++}return n.join(" > ")}function Ne(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):e.replace(/([^\w-])/g,"\\$1")}var Pe=60,Aa=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,Da=/^(INPUT|TEXTAREA|SELECT)$/;function h(e){try{let t=e.getAttribute("aria-label");if(t)return t.trim().slice(0,Pe);if(!Da.test(e.tagName)){let i=(e.textContent??"").trim().replace(/\s+/g," ").slice(0,Pe);if(i&&!Aa.test(i))return i}let n=e.getAttribute("placeholder");if(n)return n.trim().slice(0,Pe);let r=e.getAttribute("title");if(r)return r.trim().slice(0,Pe);let o=e.getAttribute("alt");return o?o.trim().slice(0,Pe):""}catch{return""}}function v(e,t){if(e.hasAttribute("data-fd-ignore")||e.closest("[data-fd-ignore]"))return!0;for(let n of t)try{if(e.matches(n)||e.closest(n))return!0}catch{}return!1}function Yo(e,t){if(t==="off")return null;if(t==="metadata")return Ra(e);let n=Ia(e);return n?{mode:"snapshot",...n}:null}function Ra(e){return{mode:"metadata",selector:p(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),attributes:{disabled:e.disabled===!0,required:e.required===!0,ariaDisabled:e.getAttribute("aria-disabled")==="true",ariaExpanded:$o(e.getAttribute("aria-expanded"),["true","false"]),ariaInvalid:$o(e.getAttribute("aria-invalid"),["true","false","grammar","spelling"]),type:Oa(e)}}}function Ia(e){try{let t=e.getBoundingClientRect(),n=getComputedStyle(e),r=e.parentElement,o=[];if(r)for(let s=0;s<r.children.length&&o.length<6;s++){let a=r.children[s];if(!a||a===e)continue;let c=a.getBoundingClientRect();o.push({selector:p(a),tag:a.tagName.toLowerCase(),box:{x:Math.round(c.x),y:Math.round(c.y),w:Math.round(c.width),h:Math.round(c.height)},interactive:Pa(a)})}let i=[];try{let s=e.getAnimations();for(let a of s)"animationName"in a&&i.push(a.animationName)}catch{}return{selector:p(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),parent:r?p(r):"",box:{x:Math.round(t.x),y:Math.round(t.y),w:Math.round(t.width),h:Math.round(t.height)},styles:{opacity:n.opacity,cursor:n.cursor,pointerEvents:n.pointerEvents,display:n.display,visibility:n.visibility,disabled:e.disabled===!0},inView:Na(t),animations:i,siblings:o}}catch{return null}}function $o(e,t){return e&&t.includes(e)?e:null}function Oa(e){let t=e.tagName.toLowerCase();if(t!=="input"&&t!=="button")return null;let n=e.getAttribute("type");return n&&/^[a-z0-9_-]{1,32}$/i.test(n)?n.toLowerCase():null}function Na(e){return e.top<window.innerHeight&&e.bottom>0&&e.left<window.innerWidth&&e.right>0}function Pa(e){let t=e.tagName;if(/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/.test(t))return!0;let n=e.getAttribute("role");return!!(n&&/^(button|link|tab|menuitem|checkbox|radio)$/.test(n))}var Ko=7e3,Ha=500,Fa=1e4,Go=50,Zo=100,Ba=3,He=6e4,Ct="application/json",Wa="application/json; encoding=gzip",ue=[],Z=null,Qo="",Jo=Ko,ei=Go,S=null,Mt={domMode:"off",compression:"auto"},yn=!1,Sn=null,Tn=!1;function Ln(e){Sn=e}var kt=new Set;function ti(e){return kt.add(e),()=>{kt.delete(e)}}function Va(e){if(e.t!=="sig"||!kt.size)return;let t=typeof e.d?.s=="string"?e.d.s:"";if(t)for(let n of kt)try{n(t,e.ts)}catch{}}function Cn(e){Tn=e}var Ua=new Set(["sid","key","url","page","ua","vw","vh","segment","environment"]),qa=new Set(["click","move","scroll","keyboard","form_focus","form_blur","form_submit","touch","navigation","error","signal","pageview","custom_signal","performance","visibility","sdk_error"]),za=new Set(["value","text","label","email","name","phone","address","password","token","secret","cookie","session","jwt","auth","credential","card","cc","cvv","ssn"]);function Xa(e){return e.replace(/([a-z])([A-Z])/g,"$1\0$2").toLowerCase().split(/[\x00_\-.\s]+/).some(n=>za.has(n))}var $a=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,ni=f(ja),ri=y(()=>ne());function oi(e,t,n,r,o){Qo=e,S=Object.assign(Object.create(null),t),Mt={domMode:nl(o?.domMode),compression:rl(o?.compression)},Jo=Math.max(Ha,Math.min(n??Ko,Fa)),ei=Math.max(1,Math.min(r??Go,Zo)),document.addEventListener("visibilitychange",ni),window.addEventListener("pagehide",ri)}function u(e){Tn||ue.length>=Zo||(Va(e),ue.push(e),ue.length>=ei?ne():Z||(Z=setTimeout(ne,Jo)))}function ne(){Ya()}async function Ya(){if(yn||!ue.length||!S)return;yn=!0,Z&&(clearTimeout(Z),Z=null);let e=ue;ue=[];let t={v:1,sid:S.sid,key:S.key,url:S.url,page:S.page,ts:Date.now(),ua:S.ua,vw:S.vw,vh:S.vh,environment:S.environment,...S.segment?{segment:S.segment}:{},dom_mode:Mt.domMode},n=e.map(o=>Qa(o,S.page,Mt.domMode)),r=[];try{for(let o of n){let i=[...r,o];if(JSON.stringify({...t,events:i}).length>He)if(r.length>0)await _n({...t,events:r}),r=[o];else{let a={...t,events:[o]};JSON.stringify(a).length<=He?await _n(a):console.warn("[flusterduck] event dropped: serialized size exceeds limit. Reduce metadata payload size."),r=[]}else r=i}r.length>0&&await _n({...t,events:r})}catch{}finally{yn=!1}}function Mn(e){if(S)for(let t of Object.keys(e))Ua.has(t)&&(S[t]=e[t])}function ii(){ne(),Tn=!1,document.removeEventListener("visibilitychange",ni),window.removeEventListener("pagehide",ri),Z&&(clearTimeout(Z),Z=null)}function ja(){document.visibilityState==="hidden"&&ne()}async function _n(e){let t=JSON.stringify(e),n=await Ka(t,Mt.compression);n&&si(n,0)}async function Ka(e,t){let n=new TextEncoder().encode(e);if(n.byteLength>He)return null;if(t!=="off"){let o=await Ga(e);if(o&&o.byteLength<=He)return{beaconBody:new Blob([o],{type:Wa}),fetchBody:new Uint8Array(o),headers:{"Content-Type":Ct,"Content-Encoding":"gzip"}}}return{beaconBody:new Blob([n],{type:Ct}),fetchBody:e,headers:{"Content-Type":Ct}}}async function Ga(e){let t=globalThis.CompressionStream;if(typeof t!="function")return null;try{let n=Za(e);if(!n)return null;let r=new t("gzip"),i=n.pipeThrough(r).getReader(),s=[],a=0;for(;;){let l=await i.read();if(l.done)break;if(a+=l.value.byteLength,a>He)return null;let g=new Uint8Array(l.value.byteLength);g.set(l.value),s.push(g)}let c=new Uint8Array(a),d=0;for(let l of s)c.set(l,d),d+=l.byteLength;return c.buffer}catch{return null}}function Za(e){let t=new TextEncoder().encode(e),n=new Blob([t],{type:Ct});if(typeof n.stream=="function")return n.stream();let r=globalThis.ReadableStream;return typeof r!="function"?null:new r({start(o){o.enqueue(t),o.close()}})}function si(e,t,n=Qo){if(n&&!(navigator.sendBeacon&&navigator.sendBeacon(n,e.beaconBody)))try{fetch(n,{method:"POST",body:e.fetchBody,headers:e.headers,keepalive:!0}).catch(()=>{t<Ba&&setTimeout(()=>si(e,t+1,n),1e3*(t+1))})}catch{}}function Qa(e,t,n){let r=e.d??{},o=Ja(e.t),i={type:o,ts:e.ts,page:typeof r.page=="string"?r.page.slice(0,2048):t},s=jo(r.el,r.element,r.target);if(o==="signal"){i.signal_type=jo(r.s,r.signal_type,r.name)?.slice(0,128),s&&(i.element=s.slice(0,2048));let c=s?tl(s,n):null;c&&(i.dom=c),i.signal_type&&Sn&&Sn(i.signal_type)}let a=el(r);return Object.keys(a).length&&(i.metadata=a),i}function Ja(e){return e==="pv"?"pageview":e==="sig"?"signal":qa.has(e)?e:"custom_signal"}function el(e){let t=Object.create(null);for(let n of Object.keys(e)){if(["s","signal_type","name","el","element","target","dom","page","meta"].includes(n))continue;let r=xt(e[n],n);r!==void 0&&(t[n.slice(0,64)]=r)}if(e.meta&&typeof e.meta=="object"&&!Array.isArray(e.meta)){let n=xt(e.meta,"meta");n&&typeof n=="object"&&!Array.isArray(n)&&Object.assign(t,n)}return t}function xt(e,t="",n=0){if(!(n>4)&&!Xa(t)){if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string")return $a.test(e)?void 0:e.slice(0,500);if(Array.isArray(e))return e.slice(0,20).map(o=>xt(o,t,n+1)).filter(o=>o!==void 0);if(typeof e=="object"){let r=Object.create(null);for(let o of Object.keys(e).slice(0,40)){if(o==="__proto__"||o==="constructor"||o==="prototype")continue;let i=xt(e[o],o,n+1);i!==void 0&&(r[o.slice(0,64)]=i)}return r}}}function tl(e,t){if(t==="off")return null;try{let n=document.querySelector(e);return n?Yo(n,t):null}catch{return null}}function jo(...e){for(let t of e)if(typeof t=="string"&&t)return t}function nl(e){return e==="metadata"||e==="snapshot"?e:"off"}function rl(e){return e==="off"?"off":"auto"}function ai(e){let t=location.href;function n(){let a=location.href;a!==t&&(t=a,e(a,location.pathname))}let r=history.pushState,o=history.replaceState,i=function(...a){r.apply(this,a),n()},s=function(...a){o.apply(this,a),n()};return history.pushState=i,history.replaceState=s,window.addEventListener("popstate",n),window.addEventListener("hashchange",n),function(){history.pushState===i&&(history.pushState=r),history.replaceState===s&&(history.replaceState=o),window.removeEventListener("popstate",n),window.removeEventListener("hashchange",n)}}function kn(e,t){for(let n of t){let r=il(n.pattern);if(r&&r.test(e))return n.label}return sl(e)}var ol=/^[a-zA-Z0-9/:._*\-]+$/;function il(e){if(e.length>200||!ol.test(e))return null;let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/:\w+/g,"[^/]+");try{return new RegExp("^"+t+"$")}catch{return null}}function sl(e){return e.replace(/\/\d+/g,"/:id").replace(/\/[a-f0-9-]{36}/g,"/:id")}var al=[".carousel-arrow",".slick-arrow",".swiper-button-next",".swiper-button-prev","[data-carousel]",'button[aria-label*="next"]','button[aria-label*="prev"]','button[aria-label*="slide"]',".quantity-btn",".qty-btn",'input[type="number"]'],B=[],li=3,ci=2e3,ui=24,At=ui,di=[],de=[],fi=0,Dt=new Map,Rt=new Map,ll=1e4,It=!1,pi=f(cl);function xn(e,t){It||(It=!0,li=e?.threshold??3,ci=e?.windowMs??2e3,At=e?.radius&&e.radius>0?e.radius:ui,di=[...al,...t??[]],fi=Date.now(),B=[],de=[],Dt.clear(),Rt.clear(),document.addEventListener("click",pi,{capture:!0,passive:!0}))}function An(){It&&(It=!1,document.removeEventListener("click",pi,{capture:!0,passive:!0}),B=[],de=[],Dt.clear(),Rt.clear())}function cl(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,di)||pl(t))return;let n=Date.now(),r=e.clientX,o=e.clientY;for(;B.length&&n-B[0].t>ci;)B.shift();B.push({t:n,x:r,y:o});let i=ul();if(B.length<i)return;let s=B.slice(-i);for(let M=0;M<s.length-1;M++)for(let Oe=M+1;Oe<s.length;Oe++){let St=s[M],Tt=s[Oe],Lt=Tt.x-St.x,ce=Tt.y-St.y;if(Lt*Lt+ce*ce>At*At)return}let a=s[0].t,d=(s[s.length-1].t-a)/1e3,l=d>0?s.length/d:s.length,g=(s.length-i)/i+l/10,w=Math.round(Math.min(1,g)*100)/100,E=fl(s,i,l),b=p(t),m=h(t);de.push({selector:b,ts:n});let $=de.length,_t=dl(n),Wo=Dt.get(b)??0,vn=Wo+1,Vo=Rt.get(b)??0,La=Vo>0&&n-Vo<ll;Dt.set(b,vn),Rt.set(b,n);let Uo=Wo>=1,Ca=(()=>{try{let M=t.getBoundingClientRect();if(M.width===0&&M.height===0)return null;let Oe=s.reduce((ce,wn)=>ce+wn.x,0)/s.length,St=s.reduce((ce,wn)=>ce+wn.y,0)/s.length,Tt=M.left+M.width/2,Lt=M.top+M.height/2;return{click_dx:Math.round(Oe-Tt),click_dy:Math.round(St-Lt),el_w:Math.round(M.width),el_h:Math.round(M.height)}}catch{return null}})();u({t:"sig",ts:n,d:{s:"rage_click",el:b,...m?{el_label:m}:{},cnt:s.length,vel:Math.round(l*10)/10,intensity:w,quality:E,burst_seq:$,burst_rate_per_min:_t,repeated_target:Uo,hot_repeat:La,...Ca??{}}}),Uo&&u({t:"sig",ts:n,d:{s:"rage_click_repeat_target",el:b,...m?{el_label:m}:{},total_hits:vn,burst_count:vn,burst_seq:$}}),B=B.slice(-(i-1))}function ul(){return de.length>=3?2:li}function dl(e){let t=(e-fi)/6e4;return t<=0?0:Math.round(de.length/t*10)/10}function fl(e,t,n){let r=e.length-t,o=Math.min(4,r/5*4),s=Math.min(4,n/10*4),a=2;if(e.length>=2){let d=0,l=0;for(let w=0;w<e.length-1;w++)for(let E=w+1;E<e.length;E++){let b=e[w],m=e[E],$=m.x-b.x,_t=m.y-b.y;d+=Math.sqrt($*$+_t*_t),l++}let g=d/l;a=Math.max(0,2-g/At*2)}let c=o+s+a;return Math.round(Math.min(10,Math.max(0,c)))}function pl(e){let t=e.tagName;return!!(t==="VIDEO"||t==="AUDIO"||e.hasAttribute("ondblclick")||e.hasAttribute("data-dbl")||e.getAttribute("role")==="spinbutton")}var ml=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,gl=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,hl=/^(A|BUTTON|LABEL)$/,vl=20,mi=[],fe=null,wl=5,Ot=new Map,gi=f(El),hi=f(_l);function El(e){fe={x:e.clientX,y:e.clientY}}function Dn(e){mi=e??[],document.addEventListener("mousedown",gi,{capture:!0,passive:!0}),document.addEventListener("click",hi,{capture:!0,passive:!0})}function Rn(){document.removeEventListener("mousedown",gi,{capture:!0}),document.removeEventListener("click",hi,{capture:!0}),fe=null,Ot.clear()}function In(){Ot.clear()}function bl(e){try{return window.getComputedStyle(e).cursor.slice(0,vl)}catch{return""}}function yl(e){try{let t=window.getComputedStyle(e);return t.cursor==="pointer"&&t.pointerEvents!=="none"}catch{return!1}}function _l(e){if(e.button!==0||e.detail===0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,mi)||Cl())return;let n=Ml(e);if(fe=null,n||Sl(t))return;let r=Tl(t,e.clientX,e.clientY),o=r?vi(e.clientX,e.clientY,r):null,i=p(t),a=(Ot.get(i)??0)+1;Ot.set(i,a);let c=a>=2,d=bl(t),l=yl(t),g=h(t),w=r?h(r):"";u({t:"sig",ts:Date.now(),d:{s:"dead_click",el:i,...g?{el_label:g}:{},near:r?p(r):"",...w?{near_label:w}:{},dist:o?Math.round(o.dist):-1,...o?{click_dx:Math.round(o.dx),click_dy:Math.round(o.dy)}:{},cursor:d,...l?{looks_interactive:!0}:{},...c?{repeated:!0,repeat_cnt:a}:{}}})}function Sl(e){if(ml.test(e.tagName))return!0;let t=e.getAttribute("role");if(t&&gl.test(t)||e.hasAttribute("contenteditable")||e.hasAttribute("tabindex")&&e.getAttribute("tabindex")!=="-1"||e.hasAttribute("onclick")||e.hasAttribute("onmousedown")||e.hasAttribute("onmouseup"))return!0;let n=e.parentElement;return!!(n&&hl.test(n.tagName)||e.closest('a, button, [role="button"], label, [onclick]'))}function Tl(e,t,n){let r=e;for(let o=0;o<5&&r;o++){let i=r.parentElement;if(!i)break;let s=i.querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]'),a=null,c=1/0;for(let d=0;d<s.length;d++){let l=s[d];if(!l||l===e)continue;let g=Ll(t,n,l);g<c&&(c=g,a=l)}if(a&&c<100)return a;r=i}return null}function vi(e,t,n){let r=n.getBoundingClientRect(),o=Math.max(r.left,Math.min(e,r.right)),i=Math.max(r.top,Math.min(t,r.bottom)),s=e-o,a=t-i;return{dist:Math.sqrt(s*s+a*a),dx:s,dy:a}}function Ll(e,t,n){return vi(e,t,n).dist}function Cl(){let e=window.getSelection();return e!==null&&e.toString().length>0}function Ml(e){if(!fe)return!1;let t=e.clientX-fe.x,n=e.clientY-fe.y;return Math.sqrt(t*t+n*n)>wl}var T=null,On=3e3,wi=[],Nt="click",Pt=0,kl=/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/,xl=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton)$/,Ei=f(Rl),bi=f(Al),yi=f(Dl);function Nn(e,t){On=e?.delayMs??3e3,wi=t??[],document.addEventListener("click",Ei,{capture:!0,passive:!0}),document.addEventListener("keydown",bi,{capture:!0,passive:!0}),document.addEventListener("touchstart",yi,{capture:!0,passive:!0})}function Pn(){document.removeEventListener("click",Ei,{capture:!0}),document.removeEventListener("keydown",bi,{capture:!0}),document.removeEventListener("touchstart",yi,{capture:!0}),pe()}function Hn(){pe()}function Al(e){e.target&&(e.key!=="Enter"&&e.key!==" "||(Nt="keydown",Pt=Date.now()))}function Dl(){Nt="touch",Pt=Date.now()}function Rl(e){let t=e.target;if(!t||v(t,wi))return;let n=t.getAttribute("role");if(!kl.test(t.tagName)&&!(n&&xl.test(n)))return;let r=Date.now();if(r-Pt>50&&(Nt="click",Pt=r),T){if(T.el===t||T.el.contains(t)){let d=r-T.ts;d>=On&&u({t:"sig",ts:r,d:{s:"speed_frustration",el:T.selector,delay:d,interaction_type:Nt,observed_delay_ms:d}}),pe();return}pe()}let o=p(t),i=!1,s=new MutationObserver(d=>{for(let l of d){if(l.type==="childList"&&(l.addedNodes.length>0||l.removedNodes.length>0)){i=!0,pe();return}if(l.type==="attributes"&&l.target instanceof Element&&(l.target===t||t.contains(l.target)||l.target.contains(t))){i=!0,pe();return}}}),a=t.parentElement||document.body;s.observe(a,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-hidden","disabled"]});let c=setTimeout(()=>{!i&&T&&(T.observer.disconnect(),T={...T,timeout:null})},On+500);T={el:t,selector:o,ts:r,observer:s,timeout:c}}function pe(){T&&(T.observer.disconnect(),T.timeout&&clearTimeout(T.timeout),T=null)}var Il=100,Ol=5,_i=800,Si=2e3,Nl=3,Bn=0,Pl=16,Ht=0,Ft=0,Fe=0,Be=0,We=0,Bt=0,Fn=0,re=[],Wn=0,me=null,Ti=f(Hl);function Vn(e){_i=e?.velocityThreshold??800,Si=e?.windowMs??2e3,document.addEventListener("mousemove",Ti,{passive:!0})}function Un(){document.removeEventListener("mousemove",Ti),me&&clearTimeout(me),qn()}function Hl(e){let t=Date.now();t-Bn<Pl||(Bn=t,me&&clearTimeout(me),me=setTimeout(()=>qn(),150),Fl(e.clientX,e.clientY,t))}function Fl(e,t,n){if(Fe===0){Ht=e,Ft=t,Fe=n,Fn=n;return}let r=(n-Fe)/1e3;if(r===0)return;let o=e-Ht,i=t-Ft;if(Math.abs(o)<2&&Math.abs(i)<2)return;let s=Math.sqrt(o*o+i*i),a=s/r;re.length>=Il&&(re=re.slice(-50)),re.push(a),Wn+=s;let c=Math.sign(o),d=Math.sign(i);if(s>=Ol&&(Be!==0&&c!==0&&c!==Be||We!==0&&d!==0&&d!==We)&&Bt++,Be=c||Be,We=d||We,Ht=e,Ft=t,Fe=n,n-Fn>Si){if(Bt>=Nl){let l=re.reduce((g,w)=>g+w,0)/re.length;l>=_i&&u({t:"sig",ts:n,d:{s:"thrash_cursor",vel:Math.round(l),rev:Bt,distance_px:Math.round(Wn)}})}qn(),Fn=n}}function qn(){Bt=0,re=[],Wn=0,Be=0,We=0,Fe=0,Ht=0,Ft=0,Bn=0,me=null}var Li=100,Ci=5,Bl=3,L=[],k=[],zn=3e4;function Xn(e){zn=e?.windowMs??3e4}function $n(){L=[],k=[]}function Yn(e){let t=Date.now(),n=e.indexOf("#"),r=n===-1?e:e.slice(0,n),o=n===-1?"":e.slice(n);for(;L.length&&t-L[0].ts>zn;)L.shift();for(;k.length&&t-k[0].ts>zn;)k.shift();if(L.length>=Li&&(L=L.slice(-50)),k.length>=Li&&(k=k.slice(-50)),L.push({path:e,ts:t}),o){k.push({path:e,ts:t});let a=k.filter(d=>{let l=d.path.indexOf("#");return(l===-1?d.path:d.path.slice(0,l))===r}),c=new Set(a.map(d=>{let l=d.path.indexOf("#");return l===-1?"":d.path.slice(l)}));if(c.size>=Bl&&a.length>c.size){let d=a.slice(-Ci).map(l=>l.path);u({t:"sig",ts:t,d:{s:"loop_nav",loop_type:"hash",pages:Array.from(c).map(l=>r+l),path_sequence:d}}),k=k.filter(l=>{let g=l.path.indexOf("#");return(g===-1?l.path:l.path.slice(0,g))!==r});return}}if(L.length<4)return;let i=!1,s=[];for(let a=0;a<L.length-1;a++)if(L[a].path===e){let c=L.slice(a,L.length),d=new Set(c.map(l=>l.path));if(d.size>=2){s.push(...Array.from(d)),i=!0;break}}if(i){let a=L.slice(-Ci).map(c=>c.path);u({t:"sig",ts:t,d:{s:"loop_nav",loop_type:"path",pages:s,path_sequence:a}}),L=[{path:e,ts:t}],k=k.filter(c=>{let d=c.path.indexOf("#");return(d===-1?c.path:c.path.slice(0,d))!==r})}}var Wl=100,Mi=1e4,Kn=.5,C=[],Wt=0,Gn=0,Ve=!1,jn=0,ki=f(Vl);function Zn(e){Mi=e?.windowMs??1e4,Kn=e?.depthThreshold??.5,window.addEventListener("scroll",ki,{passive:!0})}function Qn(){window.removeEventListener("scroll",ki),C=[],Ve=!1}function Jn(){C=[],Wt=0,Gn=0,Ve=!1}function Vl(){Ve||(Ve=!0,requestAnimationFrame(()=>{Ve=!1,Ul()}))}function Ul(){let e=Date.now(),t=window.scrollY;if(jn=document.documentElement.scrollHeight-window.innerHeight,jn<=0)return;let n=t/jn,r=t>Wt?"down":"up";if(e-Gn<100){Wt=t;return}for(;C.length&&e-C[0].ts>Mi;)C.shift();C.length>=Wl&&(C=C.slice(-50)),C.push({depth:n,ts:e,direction:r}),Wt=t,Gn=e;let o=0,i=1,s=0,a=!1,c=0,d=0,l=0,g=1,w=0;for(let E=1;E<C.length;E++)C[E].direction!==C[E-1].direction&&w++;for(let E=0;E<C.length;E++){let b=C[E],m=b.depth;if(m>o&&(o=m),m>=Kn&&(a||(c=b.ts,l=m),a=!0),a&&m<i&&(i=m,d=b.ts,g=m),a&&i<.25&&m>=Kn){if(d-c<200){a=!1,i=1,c=b.ts,l=m;continue}s++,a=!1,i=1}}if(s>=1){let E=Math.max(d-c,1),b=Math.abs(l-g)*100,m=Math.round(b/E*1e3);u({t:"sig",ts:e,d:{s:"scroll_bounce",depth:Math.round(o*100)/100,rev:s+1,vel:m,dir_changes:w}}),C=[]}}var ql=["textarea",'[role="textbox"]',"[contenteditable]"],qe=new Map,ze=new Map,Y=new Set,oe=null,er=0,xi=5e3,Ai=[],zl=50,Di=f(Xl),Ri=f($l),Ii=f(Yl),Oi=y(Ni),Ue=null;function tr(e,t){xi=e?.pauseMs??5e3,Ai=t??[],document.addEventListener("focusin",Di,{capture:!0,passive:!0}),document.addEventListener("focusout",Ri,{capture:!0,passive:!0}),document.addEventListener("submit",Ii,{capture:!0,passive:!0}),window.addEventListener("pagehide",Oi),Ue=y(()=>{document.visibilityState==="hidden"&&Ni()}),document.addEventListener("visibilitychange",Ue)}function nr(){document.removeEventListener("focusin",Di,{capture:!0}),document.removeEventListener("focusout",Ri,{capture:!0}),document.removeEventListener("submit",Ii,{capture:!0}),window.removeEventListener("pagehide",Oi),Ue&&(document.removeEventListener("visibilitychange",Ue),Ue=null),qe.clear(),ze.clear(),Y.clear(),oe=null}function rr(){qe.clear(),ze.clear(),Y.clear(),oe=null,er=0}function Xl(e){let t=e.target;if(!t||!Pi(t)||v(t,Ai)||jl(t))return;let n=Date.now();qe.set(t,n),ze.set(t,n);let r=t.closest("form");r&&r!==oe&&(oe=r,er=r.querySelectorAll("input, select, textarea").length)}function $l(e){let t=e.target;if(!t||!Pi(t))return;let n=qe.get(t),r=ze.get(t);qe.delete(t),ze.delete(t);let o=Date.now();if(!(r!==void 0&&o-r<zl)&&n!==void 0){let a=o-n;if(a>=xi){let c=h(t);u({t:"sig",ts:o,d:{s:"form_hesitation",el:p(t),...c?{el_label:c}:{},pause:a}})}}let s=t.getAttribute("name")||t.getAttribute("id")||p(t);Kl(t)&&Y.add(s)}function Yl(){Y.clear(),oe=null}function Ni(){if(Y.size>0&&oe){let e=er||Y.size,t=Math.round(Y.size/e*100)/100;u({t:"sig",ts:Date.now(),d:{s:"form_abandon",filled:Y.size,total:e,field_count:e,completion_rate:t}}),Y.clear(),oe=null}}function Pi(e){let t=e.tagName;return t==="INPUT"||t==="SELECT"||t==="TEXTAREA"}function jl(e){if(e.tagName==="TEXTAREA")return!0;for(let t of ql)try{if(e.matches(t))return!0}catch{return!1}return!1}function Kl(e){return"value"in e?e.value.length>0:!1}var ge=null,Xe=null,Hi=/flusterduck\.com|\/v1\/ingest/,Bi=f(Ql),Wi=f(Jl);function ir(){window.addEventListener("error",Bi),window.addEventListener("unhandledrejection",Wi),ec()}function sr(){window.removeEventListener("error",Bi),window.removeEventListener("unhandledrejection",Wi),tc()}var or=/fetch|network|cors|timeout/i;function Gl(e){return or.test(e)?"network":"script"}function Zl(e){if(e instanceof TypeError&&or.test(e.message)||typeof Response<"u"&&e instanceof Response)return"network";let t=e instanceof Error?e.message:String(e??"");return or.test(t)?"network":"unhandled_promise"}function Ql(e){let t=e.message||"Unknown error";u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"js_error",msg:ar(t,200),ep:"",status:0,error_category:Gl(t),url:location.pathname}})}function Jl(e){let t=e.reason instanceof Error?e.reason.message:String(e.reason??"");u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"unhandled_rejection",msg:ar(t,200),ep:"",status:0,error_category:Zl(e.reason),url:location.pathname}})}function ec(){ge||(ge=window.fetch,Xe=function(t,n){let r;try{r=ge.call(this,t,n)}catch(o){throw o}return r.then(o=>{try{if(o.status>=400){let i=typeof t=="string"?t:t instanceof URL?t.pathname:t.url;Hi.test(i)||u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:`${o.status} ${o.statusText}`,ep:Fi(i),status:o.status,error_category:"network",url:location.pathname}})}}catch{}return o},o=>{try{let i=typeof t=="string"?t:t instanceof URL?t.href:t.url;Hi.test(i)||u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:ar(o instanceof Error?o.message:"Fetch failed",200),ep:typeof t=="string"?Fi(t):"",status:0,error_category:"network",url:location.pathname}})}catch{}throw o})},window.fetch=Xe)}function tc(){ge&&Xe&&window.fetch===Xe&&(window.fetch=ge),ge=null,Xe=null}function Fi(e){try{return new URL(e,location.origin).pathname}catch{let t=e.indexOf("?"),n=e.indexOf("#"),r=Math.min(t>=0?t:e.length,n>=0?n:e.length);return e.slice(0,r)||"/"}}function ar(e,t){let n=e.length>t?e.slice(0,t):e;return n=n.replace(/(?:token|key|secret|password|auth|bearer|jwt|session|cookie|credential)[=:]\s*\S+/gi,"[REDACTED]"),n=n.replace(/https?:\/\/[^\s]*[?&][^\s]*/g,r=>{try{return new URL(r).origin+new URL(r).pathname}catch{return"[URL]"}}),n}var Vi=[".carousel",".slider",".swiper","[data-swipeable]",".drawer"],nc=['[class*="map"]',"canvas",".gallery","[data-zoom]"],Q=null,ve=0,$e=1,I=0,Ye=0,je=0,he=0,lr=0,cr=null,Ui=[],qi=f(rc),zi=f(oc),Xi=f(ac),$i=f(uc),Yi=f(lc);function ur(e){Ui=e??[],document.addEventListener("touchstart",qi,{passive:!0}),document.addEventListener("touchend",zi,{passive:!0}),"ontouchstart"in window&&(document.addEventListener("gesturechange",Xi,{passive:!0}),window.addEventListener("orientationchange",$i,{passive:!0})),window.visualViewport?.addEventListener("resize",Yi)}function dr(){document.removeEventListener("touchstart",qi),document.removeEventListener("touchend",zi),document.removeEventListener("gesturechange",Xi),window.removeEventListener("orientationchange",$i),window.visualViewport?.removeEventListener("resize",Yi),Q=null,ve=0,$e=1,I=0,Ye=0,je=0,he=0,lr=0,cr=null}function ji(e){let t=e[0],n=e[1];if(!t||!n)return 0;let r=t.clientX-n.clientX,o=t.clientY-n.clientY;return Math.sqrt(r*r+o*o)}function rc(e){let t=e.touches[0];e.touches.length===1&&t?(Q={x:t.clientX,y:t.clientY,ts:Date.now()},ve=0):e.touches.length===2&&(ve=ji(e.touches),Q=null)}function oc(e){if(ve>0){let s=e.touches.length>=2?ji(e.touches):(()=>{let a=e.changedTouches[0],c=e.changedTouches[1];if(!a||!c)return 0;let d=a.clientX-c.clientX,l=a.clientY-c.clientY;return Math.sqrt(d*d+l*l)})();s>0&&($e=Math.round(s/ve*100)/100),ve=0}if(!Q||e.changedTouches.length!==1)return;let t=e.changedTouches[0];if(!t)return;let n=t.clientX-Q.x,r=t.clientY-Q.y,o=Date.now()-Q.ts,i=document.elementFromPoint(t.clientX,t.clientY);Math.abs(n)<10&&Math.abs(r)<10&&o<300&&i&&ic(i,t.clientX,t.clientY),o<500&&(Math.abs(n)>50||Math.abs(r)>50)&&sc(i,n,r),Q=null}function ic(e,t,n){if(v(e,Ui))return;let r=dc(e,t,n);if(!r)return;let o=r.getBoundingClientRect(),i=Math.max(o.left,Math.min(t,o.right)),s=Math.max(o.top,Math.min(n,o.bottom)),a=Math.sqrt((t-i)**2+(n-s)**2);if(a>0&&a<=20){let c=`${Math.round(o.width)}x${Math.round(o.height)}`;u({t:"sig",ts:Date.now(),d:{s:"tap_miss",el:p(r),dist:Math.round(a),size:c}})}}function sc(e,t,n){if(Math.abs(n)>Math.abs(t)||!e||Vi.some(s=>{try{return e.matches(s)||e.closest(s)}catch{return!1}})||!Vi.some(s=>{try{return document.querySelector(s)!==null}catch{return!1}}))return;let i=t>0?"right":"left";u({t:"sig",ts:Date.now(),d:{s:"swipe_miss",dir:i}})}function ac(){let e=Date.now();if(e-Ye>3e4&&(I=0,Ye=e),I++,I>=2){let t=document.activeElement||document.body;!nc.some(r=>{try{return t.matches(r)||t.closest(r)}catch{return!1}})&&e-je>200&&(je=e,u({t:"sig",ts:e,d:{s:"pinch_zoom",cnt:I,pinch_scale:$e}})),I=0,$e=1}}function lc(){let e=window.visualViewport;if(e&&e.scale>1.1){let t=Date.now();if(t-Ye>3e4&&(I=0,Ye=t),I++,I>=2&&t-je>200){let n=Math.round(e.scale*100)/100;je=t,u({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:I,pinch_scale:n}}),I=0,$e=1}}}function cc(){return window.innerWidth>window.innerHeight?"landscape":"portrait"}function uc(){let e=Date.now(),t=screen.orientation?.type||"unknown";e-lr>3e4&&(he=0,lr=e),t!==cr&&(he++,cr=t),he>=3&&(u({t:"sig",ts:e,d:{s:"orientation_thrash",cnt:he,orientation:cc()}}),he=0)}function dc(e,t,n){let o=(e.parentElement||document.body).querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])'),i=null,s=21;for(let a=0;a<o.length;a++){let c=o[a];if(!c)continue;let d=c.getBoundingClientRect(),l=Math.max(d.left,Math.min(t,d.right)),g=Math.max(d.top,Math.min(n,d.bottom)),w=Math.sqrt((t-l)**2+(n-g)**2);w<s&&w>0&&(s=w,i=c)}return i}var x=[],we=null,A=0,Ee=0,V="",W=[],fr=[],fc=10,pc=5e3,Ki=5,Gi=3e3,mc=15,gc=5e3,Zi=f(hc);function pr(e){fr=e??[],document.addEventListener("keydown",Zi,{capture:!0,passive:!0})}function mr(){document.removeEventListener("keydown",Zi,{capture:!0}),x=[],W=[],we=null,A=0,Ee=0,V="",fr=[]}function hc(e){let t=Date.now(),n=e.target;n&&v(n,fr)||(e.key==="Tab"?wc(t,n,e.shiftKey):e.key==="Escape"?Ec(t,e.target):(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight")&&bc(t,e.target))}function vc(e){let t=0;for(let n=1;n<e.length;n++)e[n].shift!==e[n-1].shift&&t++;return t}function wc(e,t,n){for(;x.length&&e-x[0].ts>pc;)x.shift();x.length>=50&&(x=x.slice(-25));let r=t?p(t):"";if(x.push({ts:e,el:r,shift:n}),x.length>=fc){let i=x.map(a=>a.el).filter(Boolean),s=vc(x);u({t:"sig",ts:e,d:{s:"tab_thrash",cnt:x.length,els:i,direction_changes:s}}),x=[]}if(!t)return;let o=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');if(o){let i=p(t);o===we?e-Ee<=Gi?(A++,V=i,A>=Ki&&(u({t:"sig",ts:e,d:{s:"focus_trap",container:p(o),attempts:A,trapped_element:V}}),A=0,V="",we=null)):(Ee=e,A=1,V=i):(we=o,Ee=e,A=1,V=i)}}function Ec(e,t){if(!t)return;let n=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');if(n&&n===we){if(e-Ee>Gi){Ee=e,A=1,V=p(t);return}A++,V=p(t),A>=Ki&&(u({t:"sig",ts:e,d:{s:"focus_trap",container:p(n),attempts:A,trapped_element:V}}),A=0,V="",we=null)}}function bc(e,t){if(!t)return;let n=t.closest('[role="listbox"]')||t.closest('[role="menu"]')||t.closest('[role="tree"]')||t.closest("select");if(!n)return;for(;W.length&&e-W[0].ts>gc;)W.shift();W.length>=50&&(W=W.slice(-25)),W.push({ts:e,container:n});let r=W.filter(o=>o.container===n);r.length>=mc&&(u({t:"sig",ts:e,d:{s:"keyboard_nav_frustration",container:p(n),keys:r.length}}),W=[])}var be=0,Vt=0,Ut=null,gr=0,qt=!1,zt=0,hr=0,yc=1e4,_c=2,Sc=4,Tc=3e3,Ke=null,Xt=0,Lc=2e3,Qi=f(kc),Ji=f(Cc),es=f(Mc);function vr(){window.addEventListener("wheel",Ji,{passive:!0}),window.addEventListener("touchmove",es,{passive:!0}),window.addEventListener("scroll",Qi,{passive:!0})}function wr(){window.removeEventListener("wheel",Ji),window.removeEventListener("touchmove",es),window.removeEventListener("scroll",Qi),$t()}function $t(){be=0,Vt=0,Ut=null,gr=0,qt=!1,zt=0,hr=0,Ke=null,Xt=0}function Cc(){Ke="wheel",Xt=Date.now()}function Mc(){Ke="touch",Xt=Date.now()}function kc(){qt||(qt=!0,requestAnimationFrame(()=>{qt=!1,xc()}))}function xc(){let e=Date.now(),t=window.scrollY,n=t-Vt;if(Math.abs(n)<2){Vt=t;return}let r=n>0?"down":"up";if(Ut&&r!==Ut&&(e-gr>Tc&&(be=0,gr=e),be++,be>=Sc&&Math.abs(n)>100)){let i=e-Xt,s=Ke!==null&&i<=Lc?Ke:"wheel";e-hr>yc&&(zt=0,hr=e),zt++;let a=zt>=_c;u({t:"sig",ts:e,d:{s:"scroll_hijack",rev:be,source:s,repeated:a}}),be=0}Ut=r,Vt=t}var ie=0,ye=0,Ge=!1,ns=f(Ac),Ze=null,Qe=null;function Er(){window.addEventListener("scroll",ns,{passive:!0}),Qe=y(ts),window.addEventListener("pagehide",Qe),Ze=y(()=>{document.visibilityState==="hidden"&&ts()}),document.addEventListener("visibilitychange",Ze)}function br(){window.removeEventListener("scroll",ns),Qe&&(window.removeEventListener("pagehide",Qe),Qe=null),Ze&&(document.removeEventListener("visibilitychange",Ze),Ze=null),ie=0,ye=0,Ge=!1}function yr(){ie=0,ye=0,Ge=!1}function Ac(){Ge||(Ge=!0,requestAnimationFrame(()=>{Ge=!1;let e=document.documentElement.scrollHeight-window.innerHeight;if(e>0){let t=window.scrollY/e;t>ie&&(ie=t,ye===0&&(ye=Date.now()))}}))}function ts(){if(ie>.05){let e=Date.now(),t=ye>0?Math.max(0,e-ye):0;u({t:"sig",ts:e,d:{s:"scroll_depth_abandon",depth:Math.round(ie*100)/100,max_depth:Math.round(ie*100),dwell_ms:t}})}}var rs=1500,os=15e3,Dc=5e3,Rc=.15,_r="",_e=0,Yt=0,Je=0,Se=0,Sr=0,jt=null,Kt=0,Gt=!1,Zt=f(Oc),is=f(Nc),Te=f(Ic);function Tr(){Gt||(Gt=!0,Sr=ss(),et(),document.addEventListener("mouseenter",Zt,!0),document.addEventListener("mouseleave",Zt,!0),document.addEventListener("click",Te,{capture:!0,passive:!0}),document.addEventListener("keydown",Te,{capture:!0,passive:!0}),document.addEventListener("scroll",Te,{passive:!0}),window.addEventListener("resize",is,{passive:!0}))}function Lr(){Gt&&(Gt=!1,document.removeEventListener("mouseenter",Zt,!0),document.removeEventListener("mouseleave",Zt,!0),document.removeEventListener("click",Te,{capture:!0}),document.removeEventListener("keydown",Te,{capture:!0}),document.removeEventListener("scroll",Te),window.removeEventListener("resize",is),as(),_r="",_e=0,Yt=0,Se=0,Je=0,Kt=0)}function et(){as(),Kt+=1;let e=Kt;jt=setTimeout(()=>{u({t:"sig",ts:Date.now(),d:{s:"user_confusion_idle",idle_ms:os,cycle:e}})},os)}function Cr(){Kt=0}function Ic(){et()}function Oc(e){if(e.type!=="mouseenter")return;let t=e.target;if(!t)return;let n=p(t),r=Date.now();(n!==_r||r-Yt>rs)&&(_r=n,Yt=r,_e=0),_e+=1,!(_e<4)&&(u({t:"sig",ts:r,d:{s:"thrash_hover",el:n,cnt:_e,window_ms:rs}}),_e=0,Yt=r)}function Nc(){let e=Date.now(),t=ss(),n=Sr||t,r=Math.abs(t-n)/Math.max(n,1);Sr=t,!(r<Rc)&&((!Je||e-Je>Dc)&&(Je=e,Se=0),Se+=1,!(Se<3)&&(u({t:"sig",ts:e,d:{s:"viewport_thrashing",cnt:Se,area_delta:Math.round(r*1e3)/1e3}}),Se=0,Je=e))}function ss(){return Math.max(1,window.innerWidth*window.innerHeight)}function as(){jt&&(clearTimeout(jt),jt=null)}var ls=6e4,Pc=3,Hc=["[data-help]","[data-tooltip]","[data-faq]","[aria-describedby]",'[aria-label*="help" i]','[aria-label*="support" i]','[title*="help" i]','a[href*="/help"]','a[href*="/faq"]','a[href*="/support"]','a[href*="help."]',"details > summary",'[role="tooltip"]'],Fc=/\b(help|faq|support|tooltip|hint|guide|explain|learn.?more)\b/i,U=[],cs=[],us=f(Bc);function Mr(e){cs=e??[],document.addEventListener("click",us,{capture:!0,passive:!0})}function kr(){document.removeEventListener("click",us,{capture:!0}),U=[]}function xr(){U=[]}function Bc(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,cs)||!Wc(t))return;let n=Date.now();for(;U.length&&n-U[0].t>ls;)U.shift();let r=p(t);if(U.push({t:n,el:r}),U.length<Pc)return;let o=new Set(U.map(s=>s.el)).size,i=h(t);u({t:"sig",ts:n,d:{s:"help_hunt",cnt:U.length,unique_els:o,el:r,...i?{el_label:i}:{},window_ms:ls}}),U=[]}function Wc(e){let t=e;for(let n=0;n<3&&t;n++){if(Vc(t)||Uc(t))return!0;t=t.parentElement}return!1}function Vc(e){for(let t of Hc)try{if(e.matches(t))return!0}catch{}return!1}function Uc(e){let t=e.id??"",n=e.className??"",r=typeof n=="string"?`${t} ${n}`:t;return Fc.test(r)}var ds=/^(close|dismiss|modal-close|dialog-close|sheet-close|drawer-close)$/i,fs=/\b(close|dismiss|no\s*thanks?|maybe\s*later|skip|got\s*it|hide\s*this|don.?t\s*show)\b/i,Qt=[],Jt=new Map,ps=[],ms=f(qc);function Ar(e){ps=e??[],document.addEventListener("click",ms,{capture:!0,passive:!0})}function Dr(){document.removeEventListener("click",ms,{capture:!0}),Qt=[],Jt.clear()}function Rr(){Qt=[],Jt.clear()}function qc(e){if(e.button!==0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,ps)||!zc(t))return;let n=Date.now(),r=p(t),o=h(t);Qt.push({t:n,el:r});let s=(Jt.get(r)??0)+1;Jt.set(r,s);let a=Qt.length,c=(()=>{try{let d=t.getBoundingClientRect();return d.width===0&&d.height===0?null:{click_dx:Math.round(e.clientX-(d.left+d.width/2)),click_dy:Math.round(e.clientY-(d.top+d.height/2)),el_w:Math.round(d.width),el_h:Math.round(d.height)}}catch{return null}})();u({t:"sig",ts:n,d:{s:"close_click",el:r,...o?{el_label:o}:{},session_cnt:a,element_cnt:s,repeated:s>1,container:$c(t),...c??{}}})}function zc(e){let t=e;for(let n=0;n<4&&t;n++){if(Xc(t))return!0;t=t.parentElement}return!1}function Xc(e){let t=e.getAttribute("data-dismiss")??"",n=e.getAttribute("data-close")??"";if(t||n)return!0;let r=e.getAttribute("aria-label")??e.getAttribute("title")??"";if(r&&fs.test(r))return!0;let o=e.id??"",i=typeof e.className=="string"?e.className:"";if(ds.test(o)||ds.test(i))return!0;let s=(e.textContent??"").trim().slice(0,60);if(s&&fs.test(s))return!0;if(e.tagName==="BUTTON"&&e.closest('[role="dialog"], [role="alertdialog"], dialog, .modal, .drawer, .sheet, .overlay, .popup, [data-modal], [data-dialog]')){let c=(e.textContent??"").trim();if(c==="\xD7"||c==="\u2715"||c==="\u2717"||c==="X"||c==="x")return!0}return!1}function $c(e){let t=[['[role="dialog"], dialog',"dialog"],['[role="alertdialog"]',"alert_dialog"],[".modal, [data-modal]","modal"],[".drawer, [data-drawer], .sheet, [data-sheet]","drawer"],[".toast, [data-toast], .notification, [data-notification]","toast"],['.banner, [data-banner], [role="banner"]',"banner"],[".cookie, [data-cookie], .consent, [data-consent]","consent"],[".popup, [data-popup], .overlay, [data-overlay]","popup"]];for(let[n,r]of t)try{if(e.closest(n))return r}catch{}return"unknown"}var Yc=1500,O=null,gs=[],hs=f(jc),vs=f(Kc),ws=f(Gc);function Ir(e){gs=e??[],document.addEventListener("click",hs,{capture:!0,passive:!0}),document.addEventListener("keydown",vs,{capture:!0,passive:!0}),window.addEventListener("popstate",ws)}function Or(){document.removeEventListener("click",hs,{capture:!0}),document.removeEventListener("keydown",vs,{capture:!0}),window.removeEventListener("popstate",ws),O=null}function Nr(){O=null}function jc(e){if(e.button!==0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(t&&!v(t,gs)){if(Zc(t)){O=null;return}O={el:p(t),label:h(t),t:Date.now()}}}function Kc(e){e.key==="Escape"&&Es("escape")}function Gc(){Es("back_nav")}function Es(e){if(!O)return;let t=Date.now()-O.t;if(t>Yc){O=null;return}u({t:"sig",ts:Date.now(),d:{s:"close_click_reversal",reversal:e,el:O.el,...O.label?{el_label:O.label}:{},elapsed_ms:t}}),O=null}function Zc(e){return e.tagName==="A"?!0:e.closest('a, [role="link"], nav')!==null}var bs=1e4,Qc=3,Jc=/^(checkbox|radio)$/,ys=/^(checkbox|radio|switch|tab|option|menuitemcheckbox|menuitemradio)$/,tt=new Map,Pr=[],_s=f(eu),Ss=f(tu);function Hr(e){Pr=e??[],document.addEventListener("change",_s,{capture:!0,passive:!0}),document.addEventListener("click",Ss,{capture:!0,passive:!0})}function Fr(){document.removeEventListener("change",_s,{capture:!0}),document.removeEventListener("click",Ss,{capture:!0}),tt.clear()}function Br(){tt.clear()}function eu(e){let t=e.target;t&&(v(t,Pr)||nu(t)&&Ts(t))}function tu(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,Pr))return;let n=t.getAttribute("role")??"";ys.test(n)&&t.tagName!=="INPUT"&&Ts(t)}function Ts(e){let t=p(e),n=Date.now(),r=tt.get(t);for(r||(r=[],tt.set(t,r));r.length&&n-r[0].t>bs;)r.shift();if(r.push({t:n}),r.length<Qc)return;let o=h(e);u({t:"sig",ts:n,d:{s:"filter_spiral",el:t,...o?{el_label:o}:{},cnt:r.length,window_ms:bs}}),tt.delete(t)}function nu(e){return e.tagName==="SELECT"?!0:e.tagName==="INPUT"?Jc.test(e.type??""):ys.test(e.getAttribute("role")??"")}var Ls=15e3,ru=3,j=[],Cs=f(ou);function Wr(){document.addEventListener("copy",Cs,{capture:!0,passive:!0})}function Vr(){document.removeEventListener("copy",Cs,{capture:!0}),j=[]}function Ur(){j=[]}function ou(e){let t=e.target;if(t){let o=t.tagName;if(o==="INPUT"||o==="TEXTAREA"||t.isContentEditable)return}let n=window.getSelection();if(!n||n.toString().length<2)return;let r=Date.now();for(;j.length&&r-j[0].t>Ls;)j.shift();j.push({t:r}),!(j.length<ru)&&(u({t:"sig",ts:r,d:{s:"copy_frustration",cnt:j.length,window_ms:Ls}}),j=[])}var Ms=15e3,iu=4,su=5,au=500,lu=2e3,D=[],en=0,nt=null,se=null;function qr(){nt=y(uu),se=y(cu),document.addEventListener("selectionchange",nt),document.addEventListener("copy",se,{capture:!0,passive:!0}),document.addEventListener("cut",se,{capture:!0,passive:!0})}function zr(){nt&&(document.removeEventListener("selectionchange",nt),nt=null),se&&(document.removeEventListener("copy",se,{capture:!0}),document.removeEventListener("cut",se,{capture:!0}),se=null),D=[],en=0}function Xr(){D=[],en=0}function cu(){en=Date.now(),D=[]}function uu(){let e=window.getSelection();if(!e||e.isCollapsed||e.toString().length<su)return;let n=e.anchorNode?.parentElement;if(n){let i=n.tagName;if(i==="INPUT"||i==="TEXTAREA"||n.isContentEditable)return}let r=Date.now();if(r-en<lu)return;for(;D.length&&r-D[0].t>Ms;)D.shift();let o=D[D.length-1];o&&r-o.t<au||(D.push({t:r}),!(D.length<iu)&&(u({t:"sig",ts:r,d:{s:"text_select_frustration",cnt:D.length,window_ms:Ms}}),D=[]))}var $r=6e4,du=20,xs="_fd_sess",fu={rage_click:25,dead_click:15,speed_frustration:20,thrash_cursor:10,loop_nav:20,scroll_bounce:12,form_hesitation:10,form_abandon:25,error_encounter:30,user_confusion_idle:15,thrash_hover:8,viewport_thrashing:10,scroll_depth_abandon:15,scroll_hijack:12,tab_thrash:15,focus_trap:20,help_hunt:18,close_click:12,close_click_reversal:20,filter_spiral:15,copy_frustration:12,text_select_frustration:10},pu=10,ks={low:1,medium:2,high:3,critical:4},q=[],Le=null,nn=!1,Me=new Map,Ce={totalSignals:0,pagesWithFrustration:0},Yr="",rt=null,ot=null,it=null,st=null;function tn(e){nn&&As(e,Date.now())}function mu(){try{let e=sessionStorage.getItem(xs);if(e){let t=JSON.parse(e);Ce={totalSignals:typeof t.totalSignals=="number"?t.totalSignals:0,pagesWithFrustration:typeof t.pagesWithFrustration=="number"?t.pagesWithFrustration:0}}}catch{}}function gu(){try{sessionStorage.setItem(xs,JSON.stringify(Ce))}catch{}}function hu(){let e=[],n=Date.now()-$r,r=[];for(let[o,i]of Me.entries())for(let s of i)s>=n&&r.push({type:o,ts:s});r.sort((o,i)=>o.ts-i.ts);for(let o=0;o<r.length;o++)if(r[o].type==="rage_click"){for(let i=o+1;i<r.length;i++)if(r[i].type==="form_validation_loop"&&r[i].ts-r[o].ts<=3e4){e.push("rage_then_form_loop");break}}for(let o=0;o<r.length;o++)if(r[o].type==="dead_click")for(let i=o+1;i<r.length;i++){let s=r[i].type;if((s==="popstate"||s==="hashchange")&&r[i].ts-r[o].ts<=1e4){e.push("dead_then_bail");break}}for(let o=0;o<r.length;o++)if(r[o].type==="form_validation_loop"){for(let i=o+1;i<r.length;i++)if((r[i].type==="visibilitychange"||r[i].type==="pagehide")&&r[i].ts-r[o].ts<=2e4){e.push("form_loop_then_abandon");break}}return e}function As(e,t){Me.has(e)||Me.set(e,[]);let n=Me.get(e);n.push(t),n.length>du&&n.shift()}function vu(e){let t=e-$r,n=0;for(;n<q.length&&q[n].ts<t;)n++;n>0&&(q=q.slice(n))}function wu(){let e=new Map,t=0;for(let n of q)e.set(n.type,(e.get(n.type)??0)+1),t+=fu[n.type]??pu;return{distinctTypes:new Set(e.keys()),totalWeight:t,typeCounts:e}}function Ds(e){let t="",n=0;for(let[r,o]of e)(o>n||o===n&&r<t)&&(t=r,n=o);return{type:t,count:n}}function Eu(e,t,n){return Ds(n).count>=3&&e>=3?"critical":e>=4&&t>=70?"high":e>=3&&t>=40?"medium":e>=2&&t>=20?"low":null}function bu(e,t,n,r){let o=Ds(r),i=hu();u({t:"sig",ts:Date.now(),d:{s:"frustration_burst",level:e,page:Yr||void 0,distinct_types:t.size,total_weight:n,signals:Array.from(t).sort(),window_ms:$r,dominant:o.type,repeat_count:o.count,sequences:i,session_total_signals:Ce.totalSignals,session_pages_with_frustration:Ce.pagesWithFrustration}}),Ce.totalSignals+=q.length,Ce.pagesWithFrustration+=1,gu()}function yu(e){if(!nn||e==="frustration_burst")return;let t=Date.now();vu(t),q.length===0&&(Le=null),q.push({type:e,ts:t}),As(e,t);let{distinctTypes:n,totalWeight:r,typeCounts:o}=wu(),i=Eu(n.size,r,o);i&&(Le!==null&&ks[i]<=ks[Le]||(Le=i,bu(i,n,r,o)))}function jr(e){Yr=e}function Kr(e){q=[],Le=null,nn=!0,Me=new Map,Yr=e??"",mu(),Ln(yu),rt=()=>tn("popstate"),ot=()=>tn("hashchange"),it=()=>{document.visibilityState==="hidden"&&tn("visibilitychange")},st=()=>tn("pagehide"),window.addEventListener("popstate",rt),window.addEventListener("hashchange",ot),document.addEventListener("visibilitychange",it),window.addEventListener("pagehide",st)}function Gr(){nn=!1,q=[],Le=null,Me=new Map,Ln(null),rt&&(window.removeEventListener("popstate",rt),rt=null),ot&&(window.removeEventListener("hashchange",ot),ot=null),it&&(document.removeEventListener("visibilitychange",it),it=null),st&&(window.removeEventListener("pagehide",st),st=null)}var _u=8,Zr=3e4,Qr=5,Su=5e3,N=[],J="",at=!1,Rs=f(Lu),Is=f(Cu);function Jr(){N=[],at=!1,J=location.pathname+location.search+location.hash,window.addEventListener("popstate",Rs),window.addEventListener("hashchange",Is)}function eo(){window.removeEventListener("popstate",Rs),window.removeEventListener("hashchange",Is),N=[],at=!1,J=""}function to(){N=[],at=!1,J=location.pathname+location.search+location.hash}function lt(e){let t=Date.now();if(J&&J!==e){let n=N[N.length-1];n&&n.path===J&&n.leftAt===null&&(n.leftAt=t)}for(;N.length&&t-N[0].ts>Zr;)N.shift();e!==J&&(N.push({path:e,ts:t,leftAt:null}),J=e),!(N.length<Qr)&&(at||Tu(t))}function Tu(e){let t=N.filter(l=>e-l.ts<=Zr),n=t.filter(l=>l.leftAt!==null),r=new Set(t.map(l=>l.path));if(r.size<Qr||n.length===0||n.some(l=>l.leftAt-l.ts>=Su)||new Set(n.map(l=>l.path)).size<Qr)return;let s=n.map(l=>l.leftAt-l.ts),a=Math.round(s.reduce((l,g)=>l+g,0)/s.length),c=Math.max(...s),d=t.map(l=>l.path).slice(-_u);at=!0,u({t:"sig",ts:e,d:{s:"navigation_confusion",page_count:r.size,window_ms:Zr,avg_dwell_ms:a,pages:d,max_dwell_ms:c}})}function Lu(){let e=location.pathname+location.search+location.hash;lt(e)}function Cu(){let e=location.pathname+location.search+location.hash;lt(e)}var Mu=.3,Os=3e3,K=[],ct=!1,ae="none",le=0,ut=0,dt=0,P=!1,Ns=f(ku),Ps=f(Au);function no(){K=[],ae="none",le=0,ut=0,dt=0,P=!1,ct=!1,window.addEventListener("scroll",Ns,{passive:!0}),window.addEventListener("click",Ps,{capture:!0})}function ro(){window.removeEventListener("scroll",Ns),window.removeEventListener("click",Ps,{capture:!0}),rn()}function rn(){K=[],ae="none",le=0,ut=0,dt=0,P=!1,ct=!1}function ku(){ct||(ct=!0,requestAnimationFrame(xu))}function xu(){ct=!1;let e=Date.now(),t=window.scrollY,n=window.innerHeight,r=K[K.length-1];if(r&&e-r.ts<50||(K.push({y:t,ts:e}),K.length>60&&(K=K.slice(-40)),!r))return;let o=t-r.y;if(Math.abs(o)<2)return;if((o>0?"down":"up")==="down"){ae!=="down"&&P&&(P=!1),t>le&&(le=t),ae="down";return}if(P&&e-dt>Os&&(P=!1),ae==="down"){let s=le-t,a=n*Mu;s>=a&&!P&&(ut=t,dt=e,P=!0)}ae="up"}function Au(e){if(!P)return;let t=Date.now();if(t-dt>Os){P=!1;return}if(window.scrollY+e.clientY>ut+window.innerHeight*.1)return;let r=window.innerHeight,o=Math.round(le-ut),i=Math.round(o/r*100),s=e.target instanceof Element?e.target:null,a=s?p(s):"",c=s?h(s):"";P=!1,le=window.scrollY,ae="none",K=[],u({t:"sig",ts:t,d:{s:"scroll_to_click_confusion",reversal_depth_px:o,click_el:a,...c?{click_el_label:c}:{},scroll_back_pct:i}})}var Du=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,Ru=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,Iu=/^(A|BUTTON|LABEL)$/,Ou=3,Hs=9e4,Nu=5,ft=new Map,Fs=[],pt=null,Pu=5,Bs=f(Hu),Ws=f(qu);function Hu(e){pt={x:e.clientX,y:e.clientY}}function oo(e){Fs=e??[],document.addEventListener("mousedown",Bs,{capture:!0,passive:!0}),document.addEventListener("click",Ws,{capture:!0,passive:!0})}function io(){document.removeEventListener("mousedown",Bs,{capture:!0}),document.removeEventListener("click",Ws,{capture:!0}),pt=null,ft.clear()}function so(){ft.clear()}function Fu(e,t){let n=Math.min(3,Math.floor(e/window.innerWidth*4));return{row:Math.min(3,Math.floor(t/window.innerHeight*4)),col:n}}function Bu(e,t){return e*4+t}function Wu(e){if(Du.test(e.tagName))return!0;let t=e.getAttribute("role");if(t&&Ru.test(t)||e.hasAttribute("contenteditable")||e.hasAttribute("tabindex")&&e.getAttribute("tabindex")!=="-1"||e.hasAttribute("onclick")||e.hasAttribute("onmousedown")||e.hasAttribute("onmouseup"))return!0;let n=e.parentElement;return!!(n&&Iu.test(n.tagName)||e.closest('a, button, [role="button"], label, [onclick]'))}function Vu(){let e=window.getSelection();return e!==null&&e.toString().length>0}function Uu(e){if(!pt)return!1;let t=e.clientX-pt.x,n=e.clientY-pt.y;return Math.sqrt(t*t+n*n)>Pu}function qu(e){if(e.button!==0||e.detail===0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,Fs)||Vu()||Uu(e)||Wu(t))return;let{row:n,col:r}=Fu(e.clientX,e.clientY),o=Bu(n,r),i=Date.now(),s=p(t),c=(ft.get(o)??[]).filter(d=>i-d.ts<Hs);if(c.push({ts:i,selector:s}),ft.set(o,c),c.length>=Ou){let d=new Map;for(let m of c)d.set(m.selector,(d.get(m.selector)??0)+1);let l="",g=0;for(let[m,$]of d)$>g&&(g=$,l=m);let w=new Set,E=[];for(let m of c)if(!w.has(m.selector)&&(w.add(m.selector),E.push(m.selector),E.length>=Nu))break;let b=(()=>{try{let m=l?document.querySelector(l):null;return m?h(m):""}catch{return""}})();u({t:"sig",ts:i,d:{s:"dead_click_trap_zone",zone_row:n,zone_col:r,cnt:c.length,dominant_el:l,...b?{dominant_el_label:b}:{},elements:E,window_ms:Hs}}),ft.set(o,[])}}var ao=3,ke=12e4,_=new Map,sn=[],mt=null,Vs=f(ju),on=f(Ku);function co(e){sn=e??[],document.addEventListener("invalid",Vs,{capture:!0,passive:!0}),document.addEventListener("input",on,{capture:!0,passive:!0}),document.addEventListener("change",on,{capture:!0,passive:!0}),mt=new MutationObserver(Gu),mt.observe(document.body,{subtree:!0,attributeFilter:["aria-invalid"],attributes:!0,attributeOldValue:!0})}function uo(){document.removeEventListener("invalid",Vs,{capture:!0}),document.removeEventListener("input",on,{capture:!0}),document.removeEventListener("change",on,{capture:!0}),mt&&(mt.disconnect(),mt=null);for(let e of _.values())ee(e);_.clear()}function fo(){for(let e of _.values())ee(e);_.clear()}function lo(e){let t=e.tagName.toLowerCase();return t==="select"?"select":t==="textarea"?"textarea":t==="input"?e.type||"text":t}function po(e){let t=e.getAttribute("aria-invalid");if(t==="true"||t==="")return!0;if("validity"in e){let n=e;if(n.validity&&!n.validity.valid)return!0}try{return e.matches(":invalid")}catch{return!1}}function an(e){let t=e.tagName;return t==="INPUT"||t==="SELECT"||t==="TEXTAREA"}function zu(e){for(let[t,n]of _)e-n.lastTs>ke&&(ee(n),_.delete(t))}function ee(e){e.el.removeEventListener("input",e.inputHandler),e.el.removeEventListener("change",e.changeHandler)}function Xu(e){return f(t=>{zs(e)})}function $u(e){return f(t=>{zs(e)})}function Us(e,t){let n=Xu(t),r=$u(t);e.addEventListener("input",n,{passive:!0}),e.addEventListener("change",r,{passive:!0});let o={cycles:0,lastTs:Date.now(),phase:"invalid",inputHandler:n,changeHandler:r,el:e};return _.set(t,o),o}function qs(e){if(!an(e)||v(e,sn))return;let t=Date.now();zu(t);let n=p(e),r=_.get(n);if(!r){Us(e,n);return}let o=r.lastTs;r.lastTs=t,r.phase==="edited"?(r.cycles+=1,r.phase="invalid",r.cycles>=ao&&(u({t:"sig",ts:t,d:{s:"form_validation_loop",el:n,...h(e)?{el_label:h(e)}:{},cycles:r.cycles,window_ms:ke,field_type:lo(e)}}),ee(r),_.delete(n))):r.phase==="invalid"&&t-o>500&&(r.cycles+=1,r.cycles>=ao&&(u({t:"sig",ts:t,d:{s:"form_validation_loop",el:n,...h(e)?{el_label:h(e)}:{},cycles:r.cycles,window_ms:ke,field_type:lo(e)}}),ee(r),_.delete(n)))}function Yu(e){if(!an(e))return;let t=Date.now(),n=p(e),r=_.get(n);if(r){if(t-r.lastTs>ke){ee(r),_.delete(n);return}r.phase==="invalid"&&(r.phase="edited",r.lastTs=t)}}function zs(e){let t=Date.now(),n=_.get(e);if(n){if(t-n.lastTs>ke){ee(n),_.delete(e);return}if(n.lastTs=t,po(n.el)){n.cycles+=1,n.cycles>=ao&&(u({t:"sig",ts:t,d:{s:"form_validation_loop",el:e,...h(n.el)?{el_label:h(n.el)}:{},cycles:n.cycles,window_ms:ke,field_type:lo(n.el)}}),ee(n),_.delete(e));return}n.phase==="invalid"&&(n.phase="edited")}}function ju(e){let t=e.target;t&&qs(t)}function Ku(e){let t=e.target;if(!t||!an(t)||v(t,sn))return;let n=p(t);_.has(n)||po(t)&&Us(t,n)}function Gu(e){for(let t of e){if(t.type!=="attributes"||t.attributeName!=="aria-invalid")continue;let n=t.target;if(!an(n)||v(n,sn))continue;let r=t.oldValue,o=r==="true"||r==="",i=po(n);i&&!o?qs(n):!i&&o&&Yu(n)}}var xe=null,gt=null,go=[],Xs=0,ht=new Map;function ho(e){go=e?.length?e:["[data-fd-impression]"],Xs=Date.now(),!(typeof IntersectionObserver>"u")&&(xe=new IntersectionObserver(y(Qu),{threshold:[0,.5,1]}),$s(),gt=new MutationObserver(y(Zu)),gt.observe(document.body,{childList:!0,subtree:!0}))}function vo(){xe&&(xe.disconnect(),xe=null),gt&&(gt.disconnect(),gt=null),ht.clear()}function wo(){ht.clear(),xe&&$s()}function $s(){for(let e of go)try{let t=document.querySelectorAll(e);for(let n=0;n<t.length;n++)mo(t[n])}catch{}}function mo(e){ht.has(e)||(ht.set(e,{firstSeenTs:0,emitted:!1}),xe.observe(e))}function Zu(e){for(let t of e)for(let n=0;n<t.addedNodes.length;n++){let r=t.addedNodes[n];if(r instanceof Element)for(let o of go)try{r.matches(o)&&mo(r);let i=r.querySelectorAll(o);for(let s=0;s<i.length;s++)mo(i[s])}catch{}}}function Qu(e){let t=Date.now();for(let n of e){let r=ht.get(n.target);if(!(!r||r.emitted)&&n.isIntersecting&&n.intersectionRatio>=.5){r.firstSeenTs||(r.firstSeenTs=t),r.emitted=!0;let o=n.boundingClientRect,i=n.rootBounds?.height??window.innerHeight,s=o.top<i*.5?"above_fold":"below_fold",a=p(n.target),c=h(n.target);u({t:"sig",ts:t,d:{s:"element_impression",el:a,...c?{el_label:c}:{},visible_pct:Math.round(n.intersectionRatio*100),time_to_visible_ms:Math.round(t-Xs),viewport_position:s}})}}}var Ju=2,ed=3,td=6e4,vt=new Map,Ys=[],js=f(nd);function Eo(e){Ys=e??[],document.addEventListener("input",js,{capture:!0,passive:!0})}function bo(){document.removeEventListener("input",js,{capture:!0}),vt.clear()}function yo(){vt.clear()}function nd(e){let t=e.target;if(!t||!rd(t)||v(t,Ys))return;let n=Date.now(),r=t.value??"",o=p(t),i=vt.get(o);if(!i){vt.set(o,{lastValue:r,cycles:0,phase:"typing",lastTs:n});return}if(n-i.lastTs>td){i.lastValue=r,i.cycles=0,i.phase="typing",i.lastTs=n;return}i.lastTs=n;let s=i.lastValue.length-r.length;if(i.phase==="typing"&&s>=ed)i.phase="deleted";else if(i.phase==="deleted"&&r.length>i.lastValue.length&&(i.cycles++,i.phase="typing",i.cycles>=Ju)){let a=h(t);u({t:"sig",ts:n,d:{s:"input_correction",el:o,...a?{el_label:a}:{},cycles:i.cycles,field_type:od(t)}}),vt.delete(o);return}i.lastValue=r}function rd(e){if(e.tagName==="TEXTAREA")return!0;if(e.tagName==="INPUT"){let t=e.type?.toLowerCase()??"text";return/^(text|email|search|url|tel|number|password)$/.test(t)}return!1}function od(e){return e.tagName==="TEXTAREA"?"textarea":e.type?.toLowerCase()||"text"}var Ks=2e3,id=3e4,z=null,Gs=Ks,Zs=[],ln=new Map,Qs=f(sd),Js=f(ad),ea=f(wt);function _o(e,t){Gs=e?.dwellMs??Ks,Zs=t??[],document.addEventListener("mouseover",Qs,{passive:!0}),document.addEventListener("mouseout",Js,{passive:!0}),document.addEventListener("click",ea,{capture:!0,passive:!0})}function So(){document.removeEventListener("mouseover",Qs),document.removeEventListener("mouseout",Js),document.removeEventListener("click",ea,{capture:!0}),wt(),ln.clear()}function To(){wt(),ln.clear()}function sd(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,Zs)||!ld(t))return;let n=p(t);if(z?.selector===n)return;wt();let r=Date.now();if(r-(ln.get(n)??0)<id)return;let o=r,i=setTimeout(()=>{let s=Date.now(),a=h(t);ln.set(n,s),z=null,u({t:"sig",ts:s,d:{s:"hover_dwell",el:n,...a?{el_label:a}:{},dwell_ms:Math.round(s-o)}})},Gs);z={el:t,selector:n,startTs:o,timer:i}}function ad(e){if(!z)return;let t=e.target;if(t!==z.el&&!z.el.contains(t))return;let n=e.relatedTarget;n&&z.el.contains(n)||wt()}function wt(){z&&(clearTimeout(z.timer),z=null)}function ld(e){let t=e.tagName;if(/^(A|BUTTON|SELECT)$/.test(t))return!0;let n=e.getAttribute("role")??"";if(/^(button|link|tab|menuitem|option|checkbox|radio)$/.test(n))return!0;try{let r=window.getComputedStyle(e);return r.cursor==="pointer"&&r.pointerEvents!=="none"}catch{return!1}}var cd=20,ud=500,dd=3e3,fd=6e4,cn=0,un=0,X=null,ta=y(pd);function Lo(){cn=Date.now(),un=0,document.addEventListener("mouseleave",ta)}function Co(){document.removeEventListener("mouseleave",ta),X&&(clearTimeout(X),X=null)}function Mo(){cn=Date.now(),un=0,X&&(clearTimeout(X),X=null)}function pd(e){if(e.clientY>cd)return;let t=Date.now();t-cn<dd||t-un<fd||(X&&clearTimeout(X),X=setTimeout(y(()=>{let n=Date.now();un=n,X=null,u({t:"sig",ts:n,d:{s:"exit_intent",method:"top_chrome",time_on_page_ms:Math.round(n-cn)}})}),ud))}var md=2500,gd=4e3,na=200,hd=500,vd=.1,wd=.25,De=null,Re=null,G=null,Ae=0;function ko(e,t,n){return e<=t?"good":e<=n?"needs_improvement":"poor"}function xo(){if(!(typeof PerformanceObserver>"u")){try{De=new PerformanceObserver(y(e=>{let t=e.getEntries(),n=t[t.length-1];if(!n)return;let r=Math.round(n.startTime);u({t:"sig",ts:Date.now(),d:{s:"lcp",value_ms:r,rating:ko(r,md,gd)}})})),De.observe({type:"largest-contentful-paint",buffered:!0})}catch{De=null}try{Re=new PerformanceObserver(y(e=>{for(let t of e.getEntries()){let n=t;if(!n.interactionId)continue;let r=Math.round(n.duration);r<na||u({t:"sig",ts:Date.now(),d:{s:"slow_interaction",value_ms:r,rating:ko(r,na,hd)}})}})),Re.observe({type:"event",buffered:!1,durationThreshold:200})}catch{Re=null}try{G=new PerformanceObserver(y(e=>{for(let t of e.getEntries()){let n=t;n.hadRecentInput||(Ae+=n.value)}})),G.observe({type:"layout-shift",buffered:!0})}catch{G=null}}}function ra(){if(G){if(G.disconnect(),G=null,Ae>0){let e=Math.round(Ae*1e3)/1e3;u({t:"sig",ts:Date.now(),d:{s:"cls",value:e,rating:ko(Ae,vd,wd)}})}Ae=0}}function Ao(){De&&(De.disconnect(),De=null),Re&&(Re.disconnect(),Re=null),ra()}function Do(){if(ra(),!(typeof PerformanceObserver>"u"))try{G=new PerformanceObserver(y(e=>{for(let t of e.getEntries()){let n=t;n.hadRecentInput||(Ae+=n.value)}})),G.observe({type:"layout-shift",buffered:!1})}catch{G=null}}var oa=[],ia=f(Ed);function Ro(e){oa=e??[],document.addEventListener("paste",ia,{capture:!0,passive:!0})}function Io(){document.removeEventListener("paste",ia,{capture:!0})}function Ed(e){let t=e.target;if(!t||!bd(t)||v(t,oa))return;let n=t.value??"";setTimeout(()=>{if((t.value??"")!==n)return;let o=p(t),i=h(t);u({t:"sig",ts:Date.now(),d:{s:"paste_blocked",el:o,...i?{el_label:i}:{},field_type:yd(t)}})},100)}function bd(e){if(e.tagName==="TEXTAREA")return!0;if(e.tagName==="INPUT"){let t=e.type?.toLowerCase()??"text";return/^(text|email|search|url|tel|number|password)$/.test(t)}return!1}function yd(e){return e.tagName==="TEXTAREA"?"textarea":e.type?.toLowerCase()||"text"}var _d="https://api.flusterduck.com/v1/ingest",te=!1,dn=null,Ie=null,Et="__flusterduck_instance__",Oo=`fd_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;function Sd(){let e=window;return e[Et]&&e[Et]!==Oo?(console.warn("[flusterduck] Another SDK instance is already active on this page. Skipping init to avoid double tracking. Load the SDK either via npm or via the script tag, not both."),!1):(e[Et]=Oo,!0)}function Td(){let e=window;e[Et]===Oo&&delete e[Et]}var bt=[];function Ld(e,t,n){let r=i=>e.signals?.[i]?.enabled!==!1,o=e.trackForms!==!1;return[{when:()=>r("rageClick"),start:()=>xn(e.signals?.rageClick,t),stop:An},{when:()=>r("deadClick"),start:()=>Dn(t),stop:Rn,reset:In},{when:()=>r("speedFrustration"),start:()=>{let i=e.signals?.speedFrustration;Nn(i?{delayMs:i.windowMs}:void 0,t)},stop:Pn,reset:Hn},{when:()=>e.trackMouse!==!1&&r("thrashCursor"),start:()=>{let i=e.signals?.thrashCursor;Vn(i?{velocityThreshold:i.threshold,windowMs:i.windowMs}:void 0)},stop:Un},{when:()=>r("loopNav"),start:()=>Xn(e.signals?.loopNav),stop:$n},{when:()=>r("scrollBounce"),start:Zn,stop:Qn,reset:Jn},{when:()=>o&&(r("formHesitation")||r("formAbandon")),start:()=>{let i=e.signals?.formHesitation;tr(i?{pauseMs:i.threshold}:void 0,t)},stop:nr,reset:rr},{when:()=>o&&r("formValidationLoop"),start:()=>co(t),stop:uo,reset:fo},{when:()=>r("errorEncounter"),start:ir,stop:sr},{when:()=>"ontouchstart"in window||navigator.maxTouchPoints>0,start:()=>ur(t),stop:dr},{when:()=>r("tabThrash")||r("focusTrap")||r("keyboardNavFrustration"),start:()=>pr(t),stop:mr},{when:()=>r("scrollHijack"),start:vr,stop:wr,reset:$t},{when:()=>r("scrollDepthAbandon"),start:Er,stop:br,reset:yr},{when:()=>r("advancedHeuristics"),start:Tr,stop:Lr,reset:()=>{et(),Cr()}},{when:()=>r("helpHunt"),start:()=>Mr(t),stop:kr,reset:xr},{when:()=>r("closeClick"),start:()=>Ar(t),stop:Dr,reset:Rr},{when:()=>r("closeClickReversal"),start:()=>Ir(t),stop:Or,reset:Nr},{when:()=>r("filterSpiral"),start:()=>Hr(t),stop:Fr,reset:Br},{when:()=>r("copyFrustration"),start:Wr,stop:Vr,reset:Ur},{when:()=>r("textSelectFrustration"),start:qr,stop:zr,reset:Xr},{when:()=>r("deadClickTrapZone"),start:()=>oo(t),stop:io,reset:so},{when:()=>!0,start:()=>Kr(n),stop:Gr},{when:()=>r("navigationConfusion"),start:Jr,stop:eo,reset:to},{when:()=>r("scrollToClickConfusion"),start:no,stop:ro,reset:rn},{when:()=>r("elementImpression"),start:()=>ho(e.elementImpressionSelectors),stop:vo,reset:wo},{when:()=>o&&r("inputCorrection"),start:()=>Eo(t),stop:bo,reset:yo},{when:()=>o&&r("pasteBlocked"),start:()=>Ro(t),stop:Io},{when:()=>r("hoverDwell"),start:()=>{let i=e.signals?.hoverDwell;_o(i?.threshold?{dwellMs:i.threshold}:void 0,t)},stop:So,reset:To},{when:()=>r("exitIntent"),start:Lo,stop:Co,reset:Mo},{when:()=>r("performanceVitals"),start:xo,stop:Ao,reset:Do}]}function Cd(e){if(e)try{let t=new URL(e),n=t.protocol==="http:"&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(t.hostname);return t.protocol!=="https:"&&!n?void 0:t.origin+t.pathname}catch{return}}function aa(e){if(te||!e.key)return;if(e.key.startsWith("fd_sec_")){console.error("[flusterduck] Secret key detected in browser. Use a publishable key (fd_pub_) instead. Aborting.");return}if(!e.key.startsWith("fd_pub_"))return;if(e.respectDoNotTrack!==!1&&Rd()){Ie=e;return}if(e.sampleRate!==void 0&&e.sampleRate<1&&Math.random()>e.sampleRate){Ie=e;return}if(!Sd()){Ie=e;return}Ie=e,te=!0;let t=zo(e.cookieless??!1),n=Cd(e.endpoint)??_d,r=kn(location.pathname,e.pageRules??[]),o=Id(e.domMode);oi(n,{sid:t,key:e.key,url:location.origin+location.pathname,page:r,ua:navigator.userAgent.slice(0,200),vw:window.innerWidth,vh:window.innerHeight,segment:e.segment,environment:e.environment},e.batchInterval,e.batchMaxSize,{domMode:o,compression:e.compression});let i=sa(location.pathname,e.ignorePages??[]);i&&Cn(!0);let s=document.referrer,a="";if(s)try{a=new URL(s).origin+new URL(s).pathname}catch{a=""}i||u({t:"pv",ts:Date.now(),d:{ref:a}});let c=e.ignoreElements??[];bt=[];for(let d of Ld(e,c,r))d.when()&&(d.start(),bt.push({stop:d.stop,reset:d.reset}));dn=ai(y((d,l)=>{ne();for(let E of bt)E.reset?.();lt(l),jr(l);let g=kn(l,e.pageRules??[]),w=sa(l,e.ignorePages??[]);Cn(w),Mn({page:g,url:d}),Yn(l),w||u({t:"pv",ts:Date.now(),d:{ref:""}})})),e.debug&&console.warn("[flusterduck] initialized",{sid:t.slice(0,6)+"...",endpoint:n,page:r})}function Md(e,t){if(!te||typeof e!="string"||!e||e.length>128)return;let n;try{let o=t?.metadata??{};n=JSON.stringify(o)}catch{return}if(n.length>2048)return;let r=JSON.parse(n);u({t:"sig",ts:Date.now(),d:{s:e.slice(0,128),el:typeof t?.element=="string"?t.element.slice(0,256):"",meta:r,w:Math.max(0,Math.min(t?.weight??15,100))}})}function kd(e,t={}){if(!te||typeof e!="string"||!/^[a-z0-9_.-]{1,120}$/i.test(e))return;let n;try{n=JSON.stringify(t??{})}catch{return}n.length>2048||u({t:"custom_signal",ts:Date.now(),d:{business_event:e.slice(0,120),meta:JSON.parse(n)}})}function xd(e){if(!te||!e||typeof e!="object")return;let t=Object.create(null),n=0;for(let r of Object.keys(e)){if(n>=20)break;r==="__proto__"||r==="constructor"||r==="prototype"||(t[r.slice(0,64)]=String(e[r]).slice(0,256),n++)}Mn({segment:t})}function Ad(e){e&&Ie&&!te?aa(Ie):e||(No(),bn())}function Dd(){No(),bn()}function No(){if(te){for(let e of bt)e.stop();bt=[],ii(),dn&&(dn(),dn=null),Td(),te=!1}}function Rd(){return!!(navigator.doNotTrack==="1"||navigator.globalPrivacyControl)}function Id(e){return e==="metadata"||e==="snapshot"?e:"off"}function sa(e,t){for(let n of t)if(n){if(n.endsWith("*")){if(e.startsWith(n.slice(0,-1)))return!0}else if(n.startsWith("*")){if(e.endsWith(n.slice(1)))return!0}else if(e===n)return!0}return!1}var da=.1,fa=.01,pa=3e4,ma=50,ga=1e4,Od=500,Nd=3e4,Pd=6e4,la=10,Hd=new Set(["$rageclick","$dead_click","$exception","$identify","$create_alias","$groupidentify","$survey_sent","$survey_dismissed","$feature_flag_called"]),Fd=/(sign(ed)?[\s_-]?up|check(ed)?[\s_-]?out|purchase|subscri|payment|paid|upgrade|convert|trial|onboard.*complete|order[\s_-]?(placed|completed))/i,Bd=/^\$\$?(heatmap|scroll)/,ha=["rage_click","rage_click_repeat_target","dead_click","error_encounter","form_validation_loop","thrash_cursor"],gn=!1,fn=null,pn=null,yt=null,H=null,mn=null,va=da,wa=fa,Ea=new Set,ba=new Set(ha),ya=pa,Fo=ma,_a=ga,R=[],hn=0,F=[];function ca(e,t){return e===void 0||Number.isNaN(e)?t:Math.max(0,Math.min(e,1))}function Wd(e){gn||(gn=!0,va=ca(e?.baselineSampleRate,da),wa=ca(e?.scrollSampleRate,fa),Ea=new Set(e?.conversionEvents??[]),ba=new Set(e?.criticalSignals?.length?e.criticalSignals:ha),ya=e?.bufferWindowMs&&e.bufferWindowMs>0?e.bufferWindowMs:pa,Fo=e?.bufferMaxEvents&&e.bufferMaxEvents>0?e.bufferMaxEvents:ma,_a=e?.boostWindowMs&&e.boostWindowMs>0?e.boostWindowMs:ga,R=[],hn=0,F=[],pn=ti(jd),ua()||(fn=setInterval(()=>{ua()&&Bo()},Od),setTimeout(()=>Bo(),Nd)))}function Vd(){gn&&(gn=!1,Bo(),pn&&(pn(),pn=null),yt&&mn&&yt.capture.__fd_wrapped&&(yt.capture=mn),yt=null,H=null,mn=null,R=[],F=[],hn=0)}function Bo(){fn&&(clearInterval(fn),fn=null)}function ua(){try{let e=window.posthog;if(!e||typeof e.capture!="function"||e.__loaded!==!0)return!1;if(e.capture.__fd_wrapped)return!0;mn=e.capture,H=e.capture.bind(e);let n=(r,o,i)=>{try{return qd(r,o,i)}catch{return H?H(r,o,i):void 0}};return n.__fd_wrapped=!0,e.capture=n,yt=e,!0}catch{return!1}}function Ud(e){return Hd.has(e)?"critical":Ea.has(e)||Fd.test(e)?"conversion":Bd.test(e)?"scroll":"baseline"}function qd(e,t,n){if(!H)return;if(typeof e!="string"||!e)return H(e,t,n);let r=Date.now(),o=Ud(e);if(o==="critical"||o==="conversion")return H(e,Ho(t,r),n);if(r<hn)return H(e,{...Ho(t,r),fd_boosted:!0},n);if(zd(o==="scroll"?wa:va))return H(e,Ho(t,r),n);Yd({name:e,properties:t,ts:r})}function zd(e){if(e>=1)return!0;if(e<=0)return!1;let t=Xd();return t?$d(t)%1e4/1e4<e:Math.random()<e}var Po="";function Xd(){try{let e=window.posthog;if(e?.get_distinct_id){let t=e.get_distinct_id();if(typeof t=="string"&&t)return t}}catch{}return Po||(Po=Math.random().toString(36).slice(2)),Po}function $d(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function Ho(e,t){return Ta(t),F.length?{...e,fd_recent_signals:F.map(n=>n.name),fd_signal_count:F.length}:e??{}}function Yd(e){R.push(e),Sa(e.ts)}function Sa(e){let t=e-ya;for(;R.length&&R[0].ts<t;)R.shift();R.length>Fo&&(R=R.slice(-Fo))}function Ta(e){let t=e-Pd;F=F.filter(n=>n.ts>=t),F.length>la&&(F=F.slice(-la))}function jd(e,t){if(F.push({name:e,ts:t}),Ta(t),!ba.has(e)||(hn=t+_a,!H||!R.length))return;Sa(t);let n=R;R=[];for(let r of n)try{H(r.name,{...r.properties,fd_recovered:!0,fd_recovered_reason:e,fd_original_ts:r.ts},{timestamp:new Date(r.ts)})}catch{}}export{No as destroy,Vd as destroyPostHogTrigger,xd as identify,aa as init,Wd as initPostHogTrigger,Dd as optOut,Ad as setConsent,Md as signal,kd as track};
@@ -0,0 +1,36 @@
1
+ type CaptureFn = (eventName: string, properties?: Record<string, unknown>, options?: Record<string, unknown>) => unknown;
2
+ interface PostHogLike {
3
+ capture: CaptureFn;
4
+ get_distinct_id?: () => string;
5
+ __loaded?: boolean;
6
+ }
7
+ declare global {
8
+ interface Window {
9
+ posthog?: PostHogLike;
10
+ }
11
+ }
12
+ export interface PostHogTriggerOptions {
13
+ /** Keep rate for tier P2 (general events, pageviews). Default 0.1. */
14
+ baselineSampleRate?: number;
15
+ /** Keep rate for tier P3 (scroll and heatmap noise). Default 0.01. */
16
+ scrollSampleRate?: number;
17
+ /**
18
+ * PostHog event names that always pass (tier P1 conversions), in addition
19
+ * to the built-in conversion pattern match. Example: ['plan_upgraded'].
20
+ */
21
+ conversionEvents?: string[];
22
+ /**
23
+ * Flusterduck signal names that trigger retroactive capture and the boost
24
+ * window. Defaults to the high-confidence frustration set.
25
+ */
26
+ criticalSignals?: string[];
27
+ /** How far back the retroactive buffer reaches, in ms. Default 30000. */
28
+ bufferWindowMs?: number;
29
+ /** Max events held in the retroactive buffer. Default 50. */
30
+ bufferMaxEvents?: number;
31
+ /** How long after a signal everything is captured, in ms. Default 10000. */
32
+ boostWindowMs?: number;
33
+ }
34
+ export declare function initPostHogTrigger(opts?: PostHogTriggerOptions): void;
35
+ export declare function destroyPostHogTrigger(): void;
36
+ export {};
package/dist/queue.d.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import type { SDKEvent, QueueMeta, QueueOptions } from './types';
2
+ export declare function setCorrelatorHook(fn: ((signalType: string) => void) | null): void;
3
+ type SignalListener = (signalType: string, ts: number) => void;
4
+ export declare function subscribeSignals(fn: SignalListener): () => void;
5
+ export declare function setQueuePaused(val: boolean): void;
2
6
  export declare function initQueue(ep: string, meta: QueueMeta, interval?: number, maxSize?: number, options?: QueueOptions): void;
3
7
  export declare function enqueue(event: SDKEvent): void;
4
8
  export declare function flush(): void;
5
9
  export declare function updateMeta(updates: Partial<QueueMeta>): void;
6
10
  export declare function destroyQueue(): void;
11
+ export {};