flusterduck 0.3.0 → 0.5.0

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