flusterduck 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,23 @@
1
+ PROPRIETARY LICENSE FOR FLUSTERDUCK
2
+
3
+ Copyright (c) 2026 Creayo
4
+
5
+ 1. DEFINITIONS
6
+ "Software" refers to the Flusterduck source code, compiled binaries, SDKs, libraries, and documentation.
7
+ "Package" refers to the officially distributed compiled artifacts (e.g., via NPM).
8
+
9
+ 2. USAGE GRANT
10
+ Subject to the terms of this License, Creayo hereby grants you a non-exclusive, worldwide, royalty-free license to use, incorporate, and bundle the compiled Packages into your own applications for any purpose, including commercial use.
11
+
12
+ 3. SOURCE CODE RESTRICTIONS
13
+ You are strictly prohibited from:
14
+ a) Copying, modifying, or distributing the Software's original source code.
15
+ b) Reverse engineering, decompiling, or disassembling the Software or any of its components.
16
+ c) Creating derivative works based on the Software's source code.
17
+ d) Removing or altering any copyright notices or branding from the Software.
18
+
19
+ 4. OWNERSHIP
20
+ Creayo retains all rights, title, and interest in and to the Software, including all intellectual property rights.
21
+
22
+ 5. DISCLAIMER OF WARRANTY
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/dist/core.d.ts CHANGED
@@ -6,6 +6,7 @@ export declare function signal(name: string, data?: {
6
6
  metadata?: Record<string, unknown>;
7
7
  weight?: number;
8
8
  }): void;
9
+ export declare function track(name: string, metadata?: Record<string, unknown>): void;
9
10
  export declare function identify(segment: Record<string, string>): void;
10
11
  export declare function setConsent(consented: boolean): void;
11
12
  export declare function optOut(): void;
package/dist/d.global.js CHANGED
@@ -1 +1 @@
1
- "use strict";(()=>{function t(t){return(...e)=>{try{return t(...e)}catch{}}}function e(t){return e=>{try{t(e)}catch{}}}var n="_fd_s",o=/^[0-9a-f]{32}$/;function r(){s(n,"",-1)}function i(){const t=new Uint8Array(16);crypto.getRandomValues(t);let e="";for(const n of t)e+=n.toString(16).padStart(2,"0");return e}function s(t,e,n){const o=new Date;o.setTime(o.getTime()+864e5*n);const r="https:"===location.protocol?";Secure":"";document.cookie=`${t}=${encodeURIComponent(e)};path=/;expires=${o.toUTCString()};SameSite=Lax${r}`}var a=/^[:\d]|--|^(ember|react|ng-|__)/;function c(t){if(!t||t===document.documentElement)return"html";const e=t.getAttribute("data-fd");if(e)return`[data-fd="${u(e)}"]`;if(t.id&&!a.test(t.id)&&t.id.length<64)return"#"+u(t.id);const n=[];let o=t,r=0;for(;o&&o!==document.body&&r<5;){let t=o.tagName.toLowerCase();const e=o.getAttribute("name"),i=o.getAttribute("role"),s=o.getAttribute("type");e&&e.length<64?t+=`[name="${u(e)}"]`:i?t+=`[role="${u(i)}"]`:!s||"input"!==t&&"button"!==t||(t+=`[type="${u(s)}"]`);const a=o.parentElement;if(a){const e=a.children;let n=0,r=0;for(let t=0;t<e.length;t++){const i=e[t];i&&i.tagName===o.tagName&&(n++,i===o&&(r=n))}n>1&&(t+=`:nth-of-type(${r})`)}n.unshift(t);const c=n.join(" > ");try{if(1===document.querySelectorAll(c).length)return c}catch(t){}o=a,r++}return n.join(" > ")}function u(t){return"undefined"!=typeof CSS&&CSS.escape?CSS.escape(t):t.replace(/([^\w-])/g,"\\$1")}function l(t,e){if(t.hasAttribute("data-fd-ignore"))return!0;if(t.closest("[data-fd-ignore]"))return!0;for(const n of e)try{if(t.matches(n)||t.closest(n))return!0}catch(t){}return!1}function d(t,e){return t&&e.includes(t)?t:null}function f(t){const e=t.tagName.toLowerCase();if("input"!==e&&"button"!==e)return null;const n=t.getAttribute("type");return n&&/^[a-z0-9_-]{1,32}$/i.test(n)?n.toLowerCase():null}function h(t){return t.top<window.innerHeight&&t.bottom>0&&t.left<window.innerWidth&&t.right>0}function p(t){if(/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/.test(t.tagName))return!0;const e=t.getAttribute("role");return!(!e||!/^(button|link|tab|menuitem|checkbox|radio)$/.test(e))}var m=[],w=null,b="",g=3e3,y=50,v=null,M={domMode:"off"},_=!1,k=new Set(["sid","key","url","page","ua","vw","vh","segment","environment"]),D=new Set(["click","move","scroll","keyboard","form_focus","form_blur","form_submit","touch","navigation","error","signal","pageview","custom_signal","performance","visibility","sdk_error"]),T=/(?:value|text|label|email|e-mail|name|phone|address|password|token|secret|cookie|session|jwt|auth|credential|card|cc|cvv|ssn)/i,A=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,x=e(()=>{"hidden"===document.visibilityState&&S()}),E=t(()=>S());function j(t){m.length>=50||(m.push(t),m.length>=y?S():w||(w=setTimeout(S,g)))}function S(){if(_)return;if(!m.length||!v)return;_=!0,w&&(clearTimeout(w),w=null);const t=m;m=[];const e={v:1,sid:v.sid,key:v.key,url:v.url,page:v.page,ts:Date.now(),ua:v.ua,vw:v.vw,vh:v.vh,environment:v.environment,dom_mode:M.domMode,events:t.map(t=>((t,e,n)=>{const o=t.d??{},r=(t=>"pv"===t?"pageview":"sig"===t?"signal":D.has(t)?t:"custom_signal")(t.t),i={type:r,ts:t.ts,page:"string"==typeof o.page?o.page.slice(0,2048):e},s=R(o.el,o.element,o.target);if("signal"===r){i.signal_type=R(o.s,o.signal_type,o.name)?.slice(0,128),s&&(i.element=s.slice(0,2048));const t=s?((t,e)=>{if("off"===e)return null;try{const n=document.querySelector(t);return n?((t,e)=>{if("off"===e)return null;if("metadata"===e)return(t=>({mode:"metadata",selector:c(t),tag:t.tagName.toLowerCase(),role:t.getAttribute("role"),attributes:{disabled:!0===t.disabled,required:!0===t.required,ariaDisabled:"true"===t.getAttribute("aria-disabled"),ariaExpanded:d(t.getAttribute("aria-expanded"),["true","false"]),ariaInvalid:d(t.getAttribute("aria-invalid"),["true","false","grammar","spelling"]),type:f(t)}}))(t);const n=(t=>{try{const e=t.getBoundingClientRect(),n=getComputedStyle(t),o=t.parentElement,r=[];if(o)for(let e=0;e<o.children.length&&r.length<6;e++){const n=o.children[e];if(!n||n===t)continue;const i=n.getBoundingClientRect();r.push({selector:c(n),tag:n.tagName.toLowerCase(),box:{x:Math.round(i.x),y:Math.round(i.y),w:Math.round(i.width),h:Math.round(i.height)},interactive:p(n)})}const i=[];try{const e=t.getAnimations();for(const t of e)"animationName"in t&&i.push(t.animationName)}catch{}return{selector:c(t),tag:t.tagName.toLowerCase(),role:t.getAttribute("role"),parent:o?c(o):"",box:{x:Math.round(e.x),y:Math.round(e.y),w:Math.round(e.width),h:Math.round(e.height)},styles:{opacity:n.opacity,cursor:n.cursor,pointerEvents:n.pointerEvents,display:n.display,visibility:n.visibility,disabled:!0===t.disabled},inView:h(e),animations:i,siblings:r}}catch{return null}})(t);return n?{mode:"snapshot",...n}:null})(n,e):null}catch{return null}})(s,n):null;t&&(i.dom=t)}const a=(t=>{const e=Object.create(null);for(const n of Object.keys(t)){if(["s","signal_type","name","el","element","target","dom","page","meta"].includes(n))continue;const o=U(t[n],n);void 0!==o&&(e[n.slice(0,64)]=o)}if(t.meta&&"object"==typeof t.meta&&!Array.isArray(t.meta)){const n=U(t.meta,"meta");n&&"object"==typeof n&&!Array.isArray(n)&&Object.assign(e,n)}return e})(o);return Object.keys(a).length&&(i.metadata=a),i})(t,v.page,M.domMode))};try{const t=JSON.stringify(e);t.length<=65536&&O(t,0)}catch{}_=!1}function $(t){if(v)for(const e of Object.keys(t))k.has(e)&&(v[e]=t[e])}function O(t,e){if(b){if(navigator.sendBeacon){const e=new Blob([t],{type:"application/json"});if(navigator.sendBeacon(b,e))return}try{fetch(b,{method:"POST",body:t,headers:{"Content-Type":"application/json"},keepalive:!0}).catch(()=>{e<3&&setTimeout(()=>O(t,e+1),1e3*(e+1))})}catch{}}}function U(t,e="",n=0){if(!(n>4||T.test(e))){if(null===t||"boolean"==typeof t)return t;if("number"==typeof t)return Number.isFinite(t)?t:void 0;if("string"==typeof t){if(A.test(t))return;return t.slice(0,500)}if(Array.isArray(t))return t.slice(0,20).map(t=>U(t,e,n+1)).filter(t=>void 0!==t);if("object"==typeof t){const e=Object.create(null);for(const o of Object.keys(t).slice(0,40)){if("__proto__"===o||"constructor"===o||"prototype"===o)continue;const r=U(t[o],o,n+1);void 0!==r&&(e[o.slice(0,64)]=r)}return e}}}function R(...t){for(const e of t)if("string"==typeof e&&e)return e}function L(t,e){for(const n of e){const e=C(n.pattern);if(e&&e.test(t))return n.label}return(t=>t.replace(/\/\d+/g,"/:id").replace(/\/[a-f0-9-]{36}/g,"/:id"))(t)}var N=/^[a-zA-Z0-9/:._*\-]+$/;function C(t){if(t.length>200)return null;if(!N.test(t))return null;const e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/:\w+/g,"[^/]+");try{return new RegExp("^"+e+"$")}catch{return null}}var I=[".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"]'],z=[],B=3,F=2e3,q=[],P=e(t=>{const e=t.target;if(!e)return;if(l(e,q))return;if((t=>{const e=t.tagName;return"VIDEO"===e||"AUDIO"===e||!!t.hasAttribute("ondblclick")})(e))return;const n=Date.now(),o=t.clientX,r=t.clientY;for(;z.length&&n-z[0].t>F;)z.shift();if(z.push({t:n,x:o,y:r,el:e}),z.length<B)return;const i=z.slice(-B),s=i[0];for(let t=1;t<i.length;t++){const e=i[t],n=e.x-s.x,o=e.y-s.y;if(n*n+o*o>64)return}const a=(i[i.length-1].t-s.t)/1e3,u=a>0?i.length/a:i.length;j({t:"sig",ts:n,d:{s:"rage_click",el:c(e),cnt:i.length,vel:Math.round(10*u)/10}}),z=[]}),X=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,J=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,Z=/^(A|BUTTON|LABEL)$/,H=[],V=null,Y=e(t=>{V={x:t.clientX,y:t.clientY}}),G=e(t=>{if(0!==t.button)return;if(0===t.detail)return;const e=t.target;if(!e)return;if(l(e,H))return;if((()=>{const t=window.getSelection();return null!==t&&t.toString().length>0})())return;if((t=>{if(!V)return!1;const e=t.clientX-V.x,n=t.clientY-V.y;return Math.sqrt(e*e+n*n)>5})(t))return;if((t=>{if(X.test(t.tagName))return!0;const e=t.getAttribute("role");if(e&&J.test(e))return!0;if(t.hasAttribute("contenteditable"))return!0;if(t.hasAttribute("tabindex")&&"-1"!==t.getAttribute("tabindex"))return!0;if(t.hasAttribute("onclick")||t.hasAttribute("onmousedown")||t.hasAttribute("onmouseup"))return!0;const n=t.parentElement;if(n&&Z.test(n.tagName))return!0;if(t.closest('a, button, [role="button"], label, [onclick]'))return!0;try{if("pointer"===getComputedStyle(t).cursor)return!0}catch{return!1}return!1})(e))return;const n=((t,e,n)=>{const o=t.parentElement;if(!o)return null;const r=o.querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]');let i=null,s=1/0;for(let t=0;t<r.length;t++){const o=r[t];if(!o)continue;const a=K(e,n,o);a<s&&(s=a,i=o)}return i})(e,t.clientX,t.clientY),o=n?K(t.clientX,t.clientY,n):-1;j({t:"sig",ts:Date.now(),d:{s:"dead_click",el:c(e),near:n?c(n):"",dist:Math.round(o)}})});function K(t,e,n){const o=n.getBoundingClientRect(),r=t-Math.max(o.left,Math.min(t,o.right)),i=e-Math.max(o.top,Math.min(e,o.bottom));return Math.sqrt(r*r+i*i)}var Q=null,W=3e3,tt=[],et=/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/,nt=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton)$/,ot=e(t=>{const e=t.target;if(!e)return;if(l(e,tt))return;const n=e.getAttribute("role");if(!(et.test(e.tagName)||n&&nt.test(n)))return;if(Q){if(Q.el===e||Q.el.contains(e)){const t=Date.now()-Q.ts;return t>=W&&j({t:"sig",ts:Date.now(),d:{s:"speed_frustration",el:Q.selector,delay:t}}),void rt()}rt()}const o=c(e);let r=!1;const i=new MutationObserver(t=>{for(const n of t){if("childList"===n.type&&(n.addedNodes.length>0||n.removedNodes.length>0))return r=!0,void rt();if("attributes"===n.type&&n.target instanceof Element&&(n.target===e||e.contains(n.target)||n.target.contains(e)))return r=!0,void rt()}}),s=e.parentElement||document.body;i.observe(s,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-hidden","disabled"]});const a=setTimeout(()=>{!r&&Q&&(Q={...Q,timeout:null})},W+500);Q={el:e,selector:o,ts:Date.now(),observer:i,timeout:a}});function rt(){Q&&(Q.observer.disconnect(),Q.timeout&&clearTimeout(Q.timeout),Q=null)}var it=800,st=2e3,at=0,ct=0,ut=0,lt=0,dt=0,ft=0,ht=0,pt=0,mt=[],wt=e(t=>{const e=Date.now();e-at<50||(at=e,((t,e,n)=>{if(0===lt)return ct=t,ut=e,lt=n,void(pt=n);const o=(n-lt)/1e3;if(0===o)return;const r=t-ct,i=e-ut,s=Math.sqrt(r*r+i*i)/o;mt.length>=100&&(mt=mt.slice(-50)),mt.push(s);const a=Math.sign(r),c=Math.sign(i);if((0!==dt&&0!==a&&a!==dt||0!==ft&&0!==c&&c!==ft)&&ht++,dt=a||dt,ft=c||ft,ct=t,ut=e,lt=n,n-pt>st){if(ht>=3){const t=mt.reduce((t,e)=>t+e,0)/mt.length;t>=it&&j({t:"sig",ts:n,d:{s:"thrash_cursor",vel:Math.round(t),rev:ht}})}bt(),pt=n}})(t.clientX,t.clientY,e))});function bt(){ht=0,mt=[],dt=0,ft=0,lt=0,ct=0,ut=0}var gt=[],yt=3e4,vt=1e4,Mt=.5,_t=[],kt=0,Dt=0,Tt=!1,At=0,xt=e(()=>{Tt||(Tt=!0,requestAnimationFrame(()=>{Tt=!1,(()=>{const t=Date.now(),e=window.scrollY;if((At=document.documentElement.scrollHeight-window.innerHeight)<=0)return;const n=e/At,o=e>kt?"down":"up";if(t-Dt<100)return void(kt=e);for(;_t.length&&t-_t[0].ts>vt;)_t.shift();_t.length>=100&&(_t=_t.slice(-50)),_t.push({depth:n,ts:t,direction:o}),kt=e,Dt=t;let r=0,i=1,s=0,a=!1;for(let t=0;t<_t.length;t++){const e=_t[t].depth;e>r&&(r=e),e>=Mt&&(a=!0),a&&e<i&&(i=e),a&&i<.25&&e>=Mt&&(s++,a=!1,i=1)}s>=1&&(j({t:"sig",ts:t,d:{s:"scroll_bounce",depth:Math.round(100*r)/100,rev:s+1}}),_t=[])})()}))}),Et=["textarea",'[role="textbox"]',"[contenteditable]"],jt=new Map,St=new Set,$t=null,Ot=0,Ut=5e3,Rt=[],Lt=e(t=>{const e=t.target;if(!e||!Ft(e))return;if(l(e,Rt))return;if((t=>{if("TEXTAREA"===t.tagName)return!0;for(const e of Et)try{if(t.matches(e))return!0}catch{return!1}return!1})(e))return;jt.set(e,Date.now());const n=e.closest("form");n&&n!==$t&&($t=n,Ot=n.querySelectorAll("input, select, textarea").length)}),Nt=e(t=>{const e=t.target;if(!e||!Ft(e))return;const n=jt.get(e);if(jt.delete(e),n){const t=Date.now()-n;t>=Ut&&j({t:"sig",ts:Date.now(),d:{s:"form_hesitation",el:c(e),pause:t}})}const o=e.getAttribute("name")||e.getAttribute("id")||c(e);(t=>"value"in t&&t.value.length>0)(e)&&St.add(o)}),Ct=e(()=>{St.clear(),$t=null}),It=t(Bt),zt=null;function Bt(){St.size>0&&$t&&(j({t:"sig",ts:Date.now(),d:{s:"form_abandon",filled:St.size,total:Ot||St.size}}),St.clear(),$t=null)}function Ft(t){const e=t.tagName;return"INPUT"===e||"SELECT"===e||"TEXTAREA"===e}var qt=null,Pt=null,Xt=/flusterduck\.com|\/v1\/ingest/,Jt=e(t=>{j({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"js_error",msg:Vt(t.message||"Unknown error",200),ep:"",status:0}})}),Zt=e(t=>{const e=t.reason instanceof Error?t.reason.message:String(t.reason??"");j({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"unhandled_rejection",msg:Vt(e,200),ep:"",status:0}})});function Ht(t){try{return new URL(t,location.origin).pathname}catch{const e=t.indexOf("?"),n=t.indexOf("#"),o=Math.min(e>=0?e:t.length,n>=0?n:t.length);return t.slice(0,o)||"/"}}function Vt(t,e){let n=t.length>e?t.slice(0,e):t;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,t=>{try{return new URL(t).origin+new URL(t).pathname}catch{return"[URL]"}}),n}var Yt=[".carousel",".slider",".swiper","[data-swipeable]",".drawer"],Gt=['[class*="map"]',"canvas",".gallery","[data-zoom]"],Kt=null,Qt=0,Wt=0,te=0,ee=0,ne=null,oe=[],re=e(t=>{const e=t.touches[0];1===t.touches.length&&e&&(Kt={x:e.clientX,y:e.clientY,ts:Date.now()})}),ie=e(t=>{if(!Kt)return;if(1!==t.changedTouches.length)return;const e=t.changedTouches[0];if(!e)return;const n=e.clientX-Kt.x,o=e.clientY-Kt.y,r=Date.now()-Kt.ts,i=document.elementFromPoint(e.clientX,e.clientY);Math.abs(n)<10&&Math.abs(o)<10&&r<300&&i&&((t,e,n)=>{if(l(t,oe))return;const o=((t,e,n)=>{const o=(t.parentElement||document.body).querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])');let r=null,i=21;for(let t=0;t<o.length;t++){const s=o[t];if(!s)continue;const a=s.getBoundingClientRect(),c=Math.max(a.left,Math.min(e,a.right)),u=Math.max(a.top,Math.min(n,a.bottom)),l=Math.sqrt((e-c)**2+(n-u)**2);l<i&&l>0&&(i=l,r=s)}return r})(t,e,n);if(!o)return;const r=o.getBoundingClientRect(),i=Math.max(r.left,Math.min(e,r.right)),s=Math.max(r.top,Math.min(n,r.bottom)),a=Math.sqrt((e-i)**2+(n-s)**2);if(a>0&&a<=20){const t=`${Math.round(r.width)}x${Math.round(r.height)}`;j({t:"sig",ts:Date.now(),d:{s:"tap_miss",el:c(o),dist:Math.round(a),size:t}})}})(i,e.clientX,e.clientY),r<500&&(Math.abs(n)>50||Math.abs(o)>50)&&((t,e,n)=>{if(Math.abs(n)>Math.abs(e))return;if(!t)return;if(Yt.some(e=>{try{return t.matches(e)||t.closest(e)}catch{return!1}}))return;if(!Yt.some(t=>{try{return null!==document.querySelector(t)}catch{return!1}}))return;const o=e>0?"right":"left";j({t:"sig",ts:Date.now(),d:{s:"swipe_miss",dir:o}})})(i,n,o),Kt=null}),se=e(()=>{const t=Date.now();if(t-Wt>3e4&&(Qt=0,Wt=t),++Qt>=2){const e=document.activeElement||document.body;Gt.some(t=>{try{return e.matches(t)||e.closest(t)}catch{return!1}})||j({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:Qt}}),Qt=0}}),ae=e(()=>{const t=Date.now(),e=screen.orientation?.type||"unknown";t-ee>3e4&&(te=0,ee=t),e!==ne&&(te++,ne=e),te>=3&&(j({t:"sig",ts:t,d:{s:"orientation_thrash",cnt:te}}),te=0)}),ce=e(()=>{const t=window.visualViewport;if(t&&t.scale>1.1){const t=Date.now();t-Wt>3e4&&(Qt=0,Wt=t),++Qt>=2&&(j({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:Qt}}),Qt=0)}}),ue=[],le=null,de=0,fe=0,he=[],pe=e(t=>{const e=Date.now(),n=t.target;n&&l(n,[])||("Tab"===t.key?((t,e)=>{for(;ue.length&&t-ue[0].ts>5e3;)ue.shift();ue.length>=50&&(ue=ue.slice(-25));const n=e?c(e):"";if(ue.push({ts:t,el:n}),ue.length>=10){const e=ue.map(t=>t.el).filter(Boolean);j({t:"sig",ts:t,d:{s:"tab_thrash",cnt:ue.length,els:e}}),ue=[]}if(!e)return;const o=e.closest('[role="dialog"]')||e.closest('[role="menu"]')||e.closest(".modal")||e.closest('[aria-modal="true"]');o&&(o===le?t-fe<=3e3?++de>=5&&(j({t:"sig",ts:t,d:{s:"focus_trap",container:c(o),attempts:de}}),de=0,le=null):(fe=t,de=1):(le=o,fe=t,de=1))})(e,n):"Escape"===t.key?((t,e)=>{if(!e)return;const n=e.closest('[role="dialog"]')||e.closest('[role="menu"]')||e.closest(".modal")||e.closest('[aria-modal="true"]');n&&n===le&&++de>=5&&(j({t:"sig",ts:t,d:{s:"focus_trap",container:c(n),attempts:de}}),de=0,le=null)})(e,t.target):"ArrowDown"!==t.key&&"ArrowUp"!==t.key&&"ArrowLeft"!==t.key&&"ArrowRight"!==t.key||((t,e)=>{if(!e)return;const n=e.closest('[role="listbox"]')||e.closest('[role="menu"]')||e.closest('[role="tree"]')||e.closest("select");if(!n)return;for(;he.length&&t-he[0].ts>5e3;)he.shift();he.length>=50&&(he=he.slice(-25)),he.push({ts:t,container:n});const o=he.filter(t=>t.container===n);o.length>=15&&(j({t:"sig",ts:t,d:{s:"keyboard_nav_frustration",container:c(n),keys:o.length}}),he=[])})(e,t.target))}),me=0,we=0,be=null,ge=0,ye=!1,ve=e(()=>{ye||(ye=!0,requestAnimationFrame(()=>{ye=!1,(()=>{const t=Date.now(),e=window.scrollY,n=e-we;if(Math.abs(n)<2)return void(we=e);const o=n>0?"down":"up";be&&o!==be&&(t-ge>3e3&&(me=0,ge=t),++me>=4)&&Math.abs(n)>100&&(j({t:"sig",ts:t,d:{s:"scroll_hijack",rev:me}}),me=0),be=o,we=e})()}))}),Me=0,_e=!1,ke=e(()=>{_e||(_e=!0,requestAnimationFrame(()=>{_e=!1;const t=document.documentElement.scrollHeight-window.innerHeight;if(t>0){const e=window.scrollY/t;e>Me&&(Me=e)}}))}),De=t(Ae),Te=null;function Ae(){Me>.05&&j({t:"sig",ts:Date.now(),d:{s:"scroll_depth_abandon",depth:Math.round(100*Me)/100}})}var xe=!1,Ee=null,je=null;function Se(e){if(xe)return;if(!e.key)return;if(e.key.startsWith("fd_sec_"))return;if(!e.key.startsWith("fd_pub_"))return;if(!1!==e.respectDoNotTrack&&("1"===navigator.doNotTrack||navigator.globalPrivacyControl))return;if(void 0!==e.sampleRate&&e.sampleRate<1&&Math.random()>e.sampleRate)return;je=e,xe=!0;const r=(t=>{if(t)return i();const e=(()=>{const t=document.cookie.match(new RegExp("(?:^|; )_fd_s=([^;]*)"));return t?.[1]?decodeURIComponent(t[1]):null})();if(e&&o.test(e))return e;const r=i();return s(n,r,30),r})(e.cookieless??!1),a=(t=>{if(t)try{const e=new URL(t),n="http:"===e.protocol&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(e.hostname);if("https:"!==e.protocol&&!n)return;return e.origin+e.pathname}catch{return}})(e.endpoint)??"https://api.flusterduck.com/v1/ingest",c=L(location.pathname,e.pageRules??[]),u="metadata"===(l=e.domMode)||"snapshot"===l?l:"off";var l;((t,e,n,o,r)=>{var i;b=t,v=Object.assign(Object.create(null),e),M={domMode:(i=r?.domMode,"metadata"===i||"snapshot"===i?i:"off")},g=Math.max(1e3,Math.min(n??3e3,3e4)),y=Math.max(5,Math.min(o??50,50)),document.addEventListener("visibilitychange",x),window.addEventListener("pagehide",E)})(a,{sid:r,key:e.key,url:location.origin+location.pathname,page:c,ua:navigator.userAgent.slice(0,200),vw:window.innerWidth,vh:window.innerHeight,segment:e.segment,environment:e.environment},e.batchInterval,e.batchMaxSize,{domMode:u});const d=document.referrer;let f="";if(d)try{f=new URL(d).origin+new URL(d).pathname}catch{f=""}j({t:"pv",ts:Date.now(),d:{ref:f}});const h=e.ignoreElements??[],p=t=>{const n=e.signals?.[t];return!1!==n?.enabled};if(p("rageClick")&&((t,e)=>{B=t?.threshold??3,F=t?.windowMs??2e3,q=[...I,...e??[]],document.addEventListener("click",P,{capture:!0,passive:!0})})(e.signals?.rageClick,h),p("deadClick")&&(t=>{H=t??[],document.addEventListener("mousedown",Y,{capture:!0,passive:!0}),document.addEventListener("click",G,{capture:!0,passive:!0})})(h),p("speedFrustration")){const t=e.signals?.speedFrustration;((t,e)=>{W=t?.delayMs??3e3,tt=e??[],document.addEventListener("click",ot,{capture:!0,passive:!0})})(t?{delayMs:t.windowMs}:void 0,h)}var m;if(!1!==e.trackMouse&&p("thrashCursor")&&(m=e.signals?.thrashCursor,it=m?.velocityThreshold??800,st=m?.windowMs??2e3,document.addEventListener("mousemove",wt,{passive:!0})),p("loopNav")&&(t=>{yt=t?.windowMs??3e4})(e.signals?.loopNav),p("scrollBounce")&&(vt=1e4,Mt=.5,window.addEventListener("scroll",xt,{passive:!0})),!1!==e.trackForms&&(p("formHesitation")||p("formAbandon"))){const n=e.signals?.formHesitation;((e,n)=>{Ut=e?.pauseMs??5e3,Rt=n??[],document.addEventListener("focusin",Lt,{capture:!0,passive:!0}),document.addEventListener("focusout",Nt,{capture:!0,passive:!0}),document.addEventListener("submit",Ct,{capture:!0,passive:!0}),window.addEventListener("pagehide",It),zt=t(()=>{"hidden"===document.visibilityState&&Bt()}),document.addEventListener("visibilitychange",zt)})(n?{pauseMs:n.threshold}:void 0,h)}p("errorEncounter")&&(window.addEventListener("error",Jt),window.addEventListener("unhandledrejection",Zt),qt||(qt=window.fetch,Pt=function(t,e){let n;try{n=qt.call(this,t,e)}catch(t){throw t}return n.then(e=>{try{if(e.status>=400){const n="string"==typeof t?t:t instanceof URL?t.pathname:t.url;Xt.test(n)||j({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:`${e.status} ${e.statusText}`,ep:Ht(n),status:e.status}})}}catch{}return e},e=>{try{const n="string"==typeof t?t:t instanceof URL?t.href:t.url;Xt.test(n)||j({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:Vt(e instanceof Error?e.message:"Fetch failed",200),ep:"string"==typeof t?Ht(t):"",status:0}})}catch{}throw e})},window.fetch=Pt)),("ontouchstart"in window||navigator.maxTouchPoints>0)&&(t=>{oe=t??[],document.addEventListener("touchstart",re,{passive:!0}),document.addEventListener("touchend",ie,{passive:!0}),"ontouchstart"in window&&(document.addEventListener("gesturechange",se,{passive:!0}),window.addEventListener("orientationchange",ae,{passive:!0})),window.visualViewport?.addEventListener("resize",ce)})(h),(p("tabThrash")||p("focusTrap")||p("keyboardNavFrustration"))&&document.addEventListener("keydown",pe,{capture:!0,passive:!0}),p("scrollHijack")&&window.addEventListener("scroll",ve,{passive:!0}),p("scrollDepthAbandon")&&(window.addEventListener("scroll",ke,{passive:!0}),window.addEventListener("pagehide",De),Te=t(()=>{"hidden"===document.visibilityState&&Ae()}),document.addEventListener("visibilitychange",Te)),Ee=function(t){let e=location.href;function n(){const n=location.href;n!==e&&(e=n,t(n,location.pathname))}const o=history.pushState,r=history.replaceState,i=function(...t){o.apply(this,t),n()},s=function(...t){r.apply(this,t),n()};return history.pushState=i,history.replaceState=s,window.addEventListener("popstate",n),window.addEventListener("hashchange",n),()=>{history.pushState===i&&(history.pushState=o),history.replaceState===s&&(history.replaceState=r),window.removeEventListener("popstate",n),window.removeEventListener("hashchange",n)}}(t((t,n)=>{S(),_t=[],kt=0,Dt=0,jt.clear(),St.clear(),$t=null,Ot=0,Me=0,$({page:L(n,e.pageRules??[]),url:t}),(t=>{const e=Date.now();for(;gt.length&&e-gt[0].ts>yt;)gt.shift();if(gt.length>=100&&(gt=gt.slice(-50)),gt.push({path:t,ts:e}),gt.length<4)return;const n=t;let o=!1;const r=[];for(let t=gt.length-2;t>=1;t--)if(gt[t-1].path===n){const e=gt.slice(t-1,gt.length);for(const t of e)r.includes(t.path)||r.push(t.path);o=!0;break}o&&r.length>=2&&(j({t:"sig",ts:e,d:{s:"loop_nav",pages:r}}),gt=[{path:t,ts:e}])})(n),j({t:"pv",ts:Date.now(),d:{ref:""}})}))}function $e(t,e){if(!xe)return;if("string"!=typeof t||!t||t.length>128)return;let n;try{n=JSON.stringify(e?.metadata??{})}catch{return}if(n.length>2048)return;const o=JSON.parse(n);j({t:"sig",ts:Date.now(),d:{s:"custom",name:t.slice(0,128),el:"string"==typeof e?.element?e.element.slice(0,256):"",meta:o,w:Math.max(0,Math.min(e?.weight??15,100))}})}function Oe(t){if(!xe)return;if(!t||"object"!=typeof t)return;const e=Object.create(null);let n=0;for(const o of Object.keys(t)){if(n>=20)break;"__proto__"!==o&&"constructor"!==o&&"prototype"!==o&&(e[o.slice(0,64)]=String(t[o]).slice(0,256),n++)}$({segment:e})}function Ue(t){t&&je&&!xe?Se(je):t||(Le(),r())}function Re(){Le(),r()}function Le(){xe&&(document.removeEventListener("click",P,{capture:!0}),z=[],document.removeEventListener("mousedown",Y,{capture:!0}),document.removeEventListener("click",G,{capture:!0}),V=null,document.removeEventListener("click",ot,{capture:!0}),rt(),document.removeEventListener("mousemove",wt),bt(),gt=[],window.removeEventListener("scroll",xt),_t=[],document.removeEventListener("focusin",Lt,{capture:!0}),document.removeEventListener("focusout",Nt,{capture:!0}),document.removeEventListener("submit",Ct,{capture:!0}),window.removeEventListener("pagehide",It),zt&&(document.removeEventListener("visibilitychange",zt),zt=null),jt.clear(),St.clear(),$t=null,window.removeEventListener("error",Jt),window.removeEventListener("unhandledrejection",Zt),qt&&Pt&&window.fetch===Pt&&(window.fetch=qt),qt=null,Pt=null,document.removeEventListener("touchstart",re),document.removeEventListener("touchend",ie),document.removeEventListener("gesturechange",se),window.removeEventListener("orientationchange",ae),window.visualViewport?.removeEventListener("resize",ce),document.removeEventListener("keydown",pe,{capture:!0}),ue=[],he=[],le=null,window.removeEventListener("scroll",ve),me=0,we=0,be=null,ge=0,ye=!1,window.removeEventListener("scroll",ke),window.removeEventListener("pagehide",De),Te&&(document.removeEventListener("visibilitychange",Te),Te=null),Me=0,_e=!1,S(),document.removeEventListener("visibilitychange",x),window.removeEventListener("pagehide",E),w&&(clearTimeout(w),w=null),Ee&&(Ee(),Ee=null),xe=!1)}function Ne(t){if(t)try{const e=new URL(t),n="http:"===e.protocol&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(e.hostname);if("https:"!==e.protocol&&!n)return;return e.origin+e.pathname}catch{return}}(()=>{try{const t=window;if(t.flusterduck)return;const e=document.currentScript;if(!e)return;const n=e.getAttribute("data-key");if(!n)return;const o={key:n,environment:e.getAttribute("data-env")||void 0,endpoint:Ne(e.getAttribute("data-endpoint")),debug:"true"===e.getAttribute("data-debug"),cookieless:"true"===e.getAttribute("data-cookieless"),respectDoNotTrack:"false"!==e.getAttribute("data-dnt")},r=e.getAttribute("data-dom-mode");"metadata"!==r&&"snapshot"!==r||(o.domMode=r);const i=e.getAttribute("data-sample");if(i){const t=parseFloat(i);isNaN(t)||(o.sampleRate=Math.max(0,Math.min(t,1)))}const s=e.getAttribute("data-segment");if(s&&s.length<2048)try{const t=JSON.parse(s);if(t&&"object"==typeof t&&!Array.isArray(t)){const e=Object.create(null);for(const n of Object.keys(t))"__proto__"!==n&&"constructor"!==n&&"prototype"!==n&&(e[n]=String(t[n]));o.segment=e}}catch{}Se(o),t.flusterduck=Object.freeze({init:Se,signal:$e,identify:Oe,setConsent:Ue,optOut:Re,destroy:Le})}catch{}})()})();
1
+ "use strict";(()=>{function t(t){return(...e)=>{try{return t(...e)}catch{}}}function e(t){return e=>{try{t(e)}catch{}}}var n="_fd_s",o=/^[0-9a-f]{32}$/;function r(){s(n,"",-1)}function i(){const t=new Uint8Array(16);crypto.getRandomValues(t);let e="";for(const n of t)e+=n.toString(16).padStart(2,"0");return e}function s(t,e,n){const o=new Date;o.setTime(o.getTime()+864e5*n);const r="https:"===location.protocol?";Secure":"";document.cookie=`${t}=${encodeURIComponent(e)};path=/;expires=${o.toUTCString()};SameSite=Lax${r}`}var a=/^[:\d]|--|^(ember|react|ng-|__)/;function c(t){if(!t||t===document.documentElement)return"html";const e=t.getAttribute("data-fd");if(e)return`[data-fd="${u(e)}"]`;if(t.id&&!a.test(t.id)&&t.id.length<64)return"#"+u(t.id);const n=[];let o=t,r=0;for(;o&&o!==document.body&&r<5;){let t=o.tagName.toLowerCase();const e=o.getAttribute("name"),i=o.getAttribute("role"),s=o.getAttribute("type");e&&e.length<64?t+=`[name="${u(e)}"]`:i?t+=`[role="${u(i)}"]`:!s||"input"!==t&&"button"!==t||(t+=`[type="${u(s)}"]`);const a=o.parentElement;if(a){const e=a.children;let n=0,r=0;for(let t=0;t<e.length;t++){const i=e[t];i&&i.tagName===o.tagName&&(n++,i===o&&(r=n))}n>1&&(t+=`:nth-of-type(${r})`)}n.unshift(t);const c=n.join(" > ");try{if(1===document.querySelectorAll(c).length)return c}catch(t){}o=a,r++}return n.join(" > ")}function u(t){return"undefined"!=typeof CSS&&CSS.escape?CSS.escape(t):t.replace(/([^\w-])/g,"\\$1")}function l(t,e){if(t.hasAttribute("data-fd-ignore"))return!0;if(t.closest("[data-fd-ignore]"))return!0;for(const n of e)try{if(t.matches(n)||t.closest(n))return!0}catch(t){}return!1}function d(t,e){return t&&e.includes(t)?t:null}function f(t){const e=t.tagName.toLowerCase();if("input"!==e&&"button"!==e)return null;const n=t.getAttribute("type");return n&&/^[a-z0-9_-]{1,32}$/i.test(n)?n.toLowerCase():null}function p(t){return t.top<window.innerHeight&&t.bottom>0&&t.left<window.innerWidth&&t.right>0}function h(t){if(/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/.test(t.tagName))return!0;const e=t.getAttribute("role");return!(!e||!/^(button|link|tab|menuitem|checkbox|radio)$/.test(e))}var m=6e4,w="application/json",y=[],g=null,b="",v=7e3,_=50,M=null,k={domMode:"off",compression:"auto"},T=!1,D=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"]),x=/(?:value|text|label|email|e-mail|name|phone|address|password|token|secret|cookie|session|jwt|auth|credential|card|cc|cvv|ssn)/i,E=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,S=e(()=>{"hidden"===document.visibilityState&&j()}),O=t(()=>j());function $(t){y.length>=100||(y.push(t),y.length>=_?j():g||(g=setTimeout(j,v)))}function j(){(async()=>{if(T)return;if(!y.length||!M)return;T=!0,g&&(clearTimeout(g),g=null);const t=y;y=[];const e={v:1,sid:M.sid,key:M.key,url:M.url,page:M.page,ts:Date.now(),ua:M.ua,vw:M.vw,vh:M.vh,environment:M.environment,dom_mode:k.domMode},n=t.map(t=>((t,e,n)=>{const o=t.d??{},r=(t=>"pv"===t?"pageview":"sig"===t?"signal":A.has(t)?t:"custom_signal")(t.t),i={type:r,ts:t.ts,page:"string"==typeof o.page?o.page.slice(0,2048):e},s=C(o.el,o.element,o.target);if("signal"===r){i.signal_type=C(o.s,o.signal_type,o.name)?.slice(0,128),s&&(i.element=s.slice(0,2048));const t=s?((t,e)=>{if("off"===e)return null;try{const n=document.querySelector(t);return n?((t,e)=>{if("off"===e)return null;if("metadata"===e)return(t=>({mode:"metadata",selector:c(t),tag:t.tagName.toLowerCase(),role:t.getAttribute("role"),attributes:{disabled:!0===t.disabled,required:!0===t.required,ariaDisabled:"true"===t.getAttribute("aria-disabled"),ariaExpanded:d(t.getAttribute("aria-expanded"),["true","false"]),ariaInvalid:d(t.getAttribute("aria-invalid"),["true","false","grammar","spelling"]),type:f(t)}}))(t);const n=(t=>{try{const e=t.getBoundingClientRect(),n=getComputedStyle(t),o=t.parentElement,r=[];if(o)for(let e=0;e<o.children.length&&r.length<6;e++){const n=o.children[e];if(!n||n===t)continue;const i=n.getBoundingClientRect();r.push({selector:c(n),tag:n.tagName.toLowerCase(),box:{x:Math.round(i.x),y:Math.round(i.y),w:Math.round(i.width),h:Math.round(i.height)},interactive:h(n)})}const i=[];try{const e=t.getAnimations();for(const t of e)"animationName"in t&&i.push(t.animationName)}catch{}return{selector:c(t),tag:t.tagName.toLowerCase(),role:t.getAttribute("role"),parent:o?c(o):"",box:{x:Math.round(e.x),y:Math.round(e.y),w:Math.round(e.width),h:Math.round(e.height)},styles:{opacity:n.opacity,cursor:n.cursor,pointerEvents:n.pointerEvents,display:n.display,visibility:n.visibility,disabled:!0===t.disabled},inView:p(e),animations:i,siblings:r}}catch{return null}})(t);return n?{mode:"snapshot",...n}:null})(n,e):null}catch{return null}})(s,n):null;t&&(i.dom=t)}const a=(t=>{const e=Object.create(null);for(const n of Object.keys(t)){if(["s","signal_type","name","el","element","target","dom","page","meta"].includes(n))continue;const o=L(t[n],n);void 0!==o&&(e[n.slice(0,64)]=o)}if(t.meta&&"object"==typeof t.meta&&!Array.isArray(t.meta)){const n=L(t.meta,"meta");n&&"object"==typeof n&&!Array.isArray(n)&&Object.assign(e,n)}return e})(o);return Object.keys(a).length&&(i.metadata=a),i})(t,M.page,k.domMode));let o=[];try{for(const t of n){const n=[...o,t];if(JSON.stringify({...e,events:n}).length>m)if(o.length>0)await N({...e,events:o}),o=[t];else{const n={...e,events:[t]};JSON.stringify(n).length<=m&&await N(n),o=[]}else o=n}o.length>0&&await N({...e,events:o})}catch{}finally{T=!1}})()}function U(t){if(M)for(const e of Object.keys(t))D.has(e)&&(M[e]=t[e])}async function N(t){const e=JSON.stringify(t),n=await(async(t,e)=>{const n=(new TextEncoder).encode(t);if(n.byteLength>m)return null;if("off"!==e){const e=await(async t=>{const e=globalThis.CompressionStream;if("function"!=typeof e)return null;try{const n=(t=>{const e=(new TextEncoder).encode(t),n=new Blob([e],{type:w});if("function"==typeof n.stream)return n.stream();const o=globalThis.ReadableStream;return"function"!=typeof o?null:new o({start(t){t.enqueue(e),t.close()}})})(t);if(!n)return null;const o=new e("gzip"),r=n.pipeThrough(o).getReader(),i=[];let s=0;for(;;){const t=await r.read();if(t.done)break;if(s+=t.value.byteLength,s>m)return null;const e=new Uint8Array(t.value.byteLength);e.set(t.value),i.push(e)}const a=new Uint8Array(s);let c=0;for(const t of i)a.set(t,c),c+=t.byteLength;return a.buffer}catch{return null}})(t);if(e&&e.byteLength<=m)return{beaconBody:new Blob([e],{type:"application/json; encoding=gzip"}),fetchBody:new Uint8Array(e),headers:{"Content-Type":w,"Content-Encoding":"gzip"}}}return{beaconBody:new Blob([n],{type:w}),fetchBody:t,headers:{"Content-Type":w}}})(e,k.compression);n&&R(n,0)}function R(t,e){if(b){if(navigator.sendBeacon&&navigator.sendBeacon(b,t.beaconBody))return;try{fetch(b,{method:"POST",body:t.fetchBody,headers:t.headers,keepalive:!0}).catch(()=>{e<3&&setTimeout(()=>R(t,e+1),1e3*(e+1))})}catch{}}}function L(t,e="",n=0){if(!(n>4||x.test(e))){if(null===t||"boolean"==typeof t)return t;if("number"==typeof t)return Number.isFinite(t)?t:void 0;if("string"==typeof t){if(E.test(t))return;return t.slice(0,500)}if(Array.isArray(t))return t.slice(0,20).map(t=>L(t,e,n+1)).filter(t=>void 0!==t);if("object"==typeof t){const e=Object.create(null);for(const o of Object.keys(t).slice(0,40)){if("__proto__"===o||"constructor"===o||"prototype"===o)continue;const r=L(t[o],o,n+1);void 0!==r&&(e[o.slice(0,64)]=r)}return e}}}function C(...t){for(const e of t)if("string"==typeof e&&e)return e}function z(t){return"off"===t?"off":"auto"}function B(t,e){for(const n of e){const e=F(n.pattern);if(e&&e.test(t))return n.label}return(t=>t.replace(/\/\d+/g,"/:id").replace(/\/[a-f0-9-]{36}/g,"/:id"))(t)}var I=/^[a-zA-Z0-9/:._*\-]+$/;function F(t){if(t.length>200)return null;if(!I.test(t))return null;const e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/:\w+/g,"[^/]+");try{return new RegExp("^"+e+"$")}catch{return null}}var J=[".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"]'],q=[],P=3,X=2e3,Z=[],H=e(t=>{const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(l(e,Z))return;if((t=>{const e=t.tagName;return"VIDEO"===e||"AUDIO"===e||!!t.hasAttribute("ondblclick")})(e))return;const n=Date.now(),o=t.clientX,r=t.clientY;for(;q.length&&n-q[0].t>X;)q.shift();if(q.push({t:n,x:o,y:r}),q.length<P)return;const i=q.slice(-P),s=i[0];for(let t=1;t<i.length;t++){const e=i[t],n=e.x-s.x,o=e.y-s.y;if(n*n+o*o>64)return}const a=(i[i.length-1].t-s.t)/1e3,u=a>0?i.length/a:i.length;$({t:"sig",ts:n,d:{s:"rage_click",el:c(e),cnt:i.length,vel:Math.round(10*u)/10}}),q=[]}),V=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,Y=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,G=/^(A|BUTTON|LABEL)$/,K=[],Q=null,W=e(t=>{Q={x:t.clientX,y:t.clientY}}),tt=e(t=>{if(0!==t.button)return;if(0===t.detail)return;const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(l(e,K))return;if((()=>{const t=window.getSelection();return null!==t&&t.toString().length>0})())return;if((t=>{if(!Q)return!1;const e=t.clientX-Q.x,n=t.clientY-Q.y;return Math.sqrt(e*e+n*n)>5})(t))return;if((t=>{if(V.test(t.tagName))return!0;const e=t.getAttribute("role");if(e&&Y.test(e))return!0;if(t.hasAttribute("contenteditable"))return!0;if(t.hasAttribute("tabindex")&&"-1"!==t.getAttribute("tabindex"))return!0;if(t.hasAttribute("onclick")||t.hasAttribute("onmousedown")||t.hasAttribute("onmouseup"))return!0;const n=t.parentElement;return!(!n||!G.test(n.tagName))||!!t.closest('a, button, [role="button"], label, [onclick]')})(e))return;const n=((t,e,n)=>{let o=t;for(let r=0;r<5&&o;r++){const r=o.parentElement;if(!r)break;const i=r.querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]');let s=null,a=1/0;for(let o=0;o<i.length;o++){const r=i[o];if(!r||r===t)continue;const c=et(e,n,r);c<a&&(a=c,s=r)}if(s&&a<100)return s;o=r}return null})(e,t.clientX,t.clientY),o=n?et(t.clientX,t.clientY,n):-1;$({t:"sig",ts:Date.now(),d:{s:"dead_click",el:c(e),near:n?c(n):"",dist:Math.round(o)}})});function et(t,e,n){const o=n.getBoundingClientRect(),r=t-Math.max(o.left,Math.min(t,o.right)),i=e-Math.max(o.top,Math.min(e,o.bottom));return Math.sqrt(r*r+i*i)}var nt=null,ot=3e3,rt=[],it=/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/,st=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton)$/,at=e(t=>{const e=t.target;if(!e)return;if(l(e,rt))return;const n=e.getAttribute("role");if(!(it.test(e.tagName)||n&&st.test(n)))return;if(nt){if(nt.el===e||nt.el.contains(e)){const t=Date.now()-nt.ts;return t>=ot&&$({t:"sig",ts:Date.now(),d:{s:"speed_frustration",el:nt.selector,delay:t}}),void ct()}ct()}const o=c(e);let r=!1;const i=new MutationObserver(t=>{for(const n of t){if("childList"===n.type&&(n.addedNodes.length>0||n.removedNodes.length>0))return r=!0,void ct();if("attributes"===n.type&&n.target instanceof Element&&(n.target===e||e.contains(n.target)||n.target.contains(e)))return r=!0,void ct()}}),s=e.parentElement||document.body;i.observe(s,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-hidden","disabled"]});const a=setTimeout(()=>{!r&&nt&&(nt={...nt,timeout:null})},ot+500);nt={el:e,selector:o,ts:Date.now(),observer:i,timeout:a}});function ct(){nt&&(nt.observer.disconnect(),nt.timeout&&clearTimeout(nt.timeout),nt=null)}var ut=800,lt=2e3,dt=0,ft=0,pt=0,ht=0,mt=0,wt=0,yt=0,gt=0,bt=[],vt=null,_t=e(t=>{const e=Date.now();e-dt<16||(dt=e,vt&&clearTimeout(vt),vt=setTimeout(()=>Mt(),150),((t,e,n)=>{if(0===ht)return ft=t,pt=e,ht=n,void(gt=n);const o=(n-ht)/1e3;if(0===o)return;const r=t-ft,i=e-pt;if(Math.abs(r)<2&&Math.abs(i)<2)return;const s=Math.sqrt(r*r+i*i)/o;bt.length>=100&&(bt=bt.slice(-50)),bt.push(s);const a=Math.sign(r),c=Math.sign(i);if((0!==mt&&0!==a&&a!==mt||0!==wt&&0!==c&&c!==wt)&&yt++,mt=a||mt,wt=c||wt,ft=t,pt=e,ht=n,n-gt>lt){if(yt>=3){const t=bt.reduce((t,e)=>t+e,0)/bt.length;t>=ut&&$({t:"sig",ts:n,d:{s:"thrash_cursor",vel:Math.round(t),rev:yt}})}Mt(),gt=n}})(t.clientX,t.clientY,e))});function Mt(){yt=0,bt=[],mt=0,wt=0,ht=0,ft=0,pt=0,vt=null}var kt=[],Tt=3e4,Dt=1e4,At=.5,xt=[],Et=0,St=0,Ot=!1,$t=0,jt=e(()=>{Ot||(Ot=!0,requestAnimationFrame(()=>{Ot=!1,(()=>{const t=Date.now(),e=window.scrollY;if(($t=document.documentElement.scrollHeight-window.innerHeight)<=0)return;const n=e/$t,o=e>Et?"down":"up";if(t-St<100)return void(Et=e);for(;xt.length&&t-xt[0].ts>Dt;)xt.shift();xt.length>=100&&(xt=xt.slice(-50)),xt.push({depth:n,ts:t,direction:o}),Et=e,St=t;let r=0,i=1,s=0,a=!1;for(let t=0;t<xt.length;t++){const e=xt[t].depth;e>r&&(r=e),e>=At&&(a=!0),a&&e<i&&(i=e),a&&i<.25&&e>=At&&(s++,a=!1,i=1)}s>=1&&($({t:"sig",ts:t,d:{s:"scroll_bounce",depth:Math.round(100*r)/100,rev:s+1}}),xt=[])})()}))}),Ut=["textarea",'[role="textbox"]',"[contenteditable]"],Nt=new Map,Rt=new Set,Lt=null,Ct=0,zt=5e3,Bt=[],It=e(t=>{const e=t.target;if(!e||!Zt(e))return;if(l(e,Bt))return;if((t=>{if("TEXTAREA"===t.tagName)return!0;for(const e of Ut)try{if(t.matches(e))return!0}catch{return!1}return!1})(e))return;Nt.set(e,Date.now());const n=e.closest("form");n&&n!==Lt&&(Lt=n,Ct=n.querySelectorAll("input, select, textarea").length)}),Ft=e(t=>{const e=t.target;if(!e||!Zt(e))return;const n=Nt.get(e);if(Nt.delete(e),n){const t=Date.now()-n;t>=zt&&$({t:"sig",ts:Date.now(),d:{s:"form_hesitation",el:c(e),pause:t}})}const o=e.getAttribute("name")||e.getAttribute("id")||c(e);(t=>"value"in t&&t.value.length>0)(e)&&Rt.add(o)}),Jt=e(()=>{Rt.clear(),Lt=null}),qt=t(Xt),Pt=null;function Xt(){Rt.size>0&&Lt&&($({t:"sig",ts:Date.now(),d:{s:"form_abandon",filled:Rt.size,total:Ct||Rt.size}}),Rt.clear(),Lt=null)}function Zt(t){const e=t.tagName;return"INPUT"===e||"SELECT"===e||"TEXTAREA"===e}var Ht=null,Vt=null,Yt=/flusterduck\.com|\/v1\/ingest/,Gt=e(t=>{$({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"js_error",msg:Wt(t.message||"Unknown error",200),ep:"",status:0}})}),Kt=e(t=>{const e=t.reason instanceof Error?t.reason.message:String(t.reason??"");$({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"unhandled_rejection",msg:Wt(e,200),ep:"",status:0}})});function Qt(t){try{return new URL(t,location.origin).pathname}catch{const e=t.indexOf("?"),n=t.indexOf("#"),o=Math.min(e>=0?e:t.length,n>=0?n:t.length);return t.slice(0,o)||"/"}}function Wt(t,e){let n=t.length>e?t.slice(0,e):t;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,t=>{try{return new URL(t).origin+new URL(t).pathname}catch{return"[URL]"}}),n}var te=[".carousel",".slider",".swiper","[data-swipeable]",".drawer"],ee=['[class*="map"]',"canvas",".gallery","[data-zoom]"],ne=null,oe=0,re=0,ie=0,se=0,ae=null,ce=[],ue=e(t=>{const e=t.touches[0];1===t.touches.length&&e&&(ne={x:e.clientX,y:e.clientY,ts:Date.now()})}),le=e(t=>{if(!ne)return;if(1!==t.changedTouches.length)return;const e=t.changedTouches[0];if(!e)return;const n=e.clientX-ne.x,o=e.clientY-ne.y,r=Date.now()-ne.ts,i=document.elementFromPoint(e.clientX,e.clientY);Math.abs(n)<10&&Math.abs(o)<10&&r<300&&i&&((t,e,n)=>{if(l(t,ce))return;const o=((t,e,n)=>{const o=(t.parentElement||document.body).querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])');let r=null,i=21;for(let t=0;t<o.length;t++){const s=o[t];if(!s)continue;const a=s.getBoundingClientRect(),c=Math.max(a.left,Math.min(e,a.right)),u=Math.max(a.top,Math.min(n,a.bottom)),l=Math.sqrt((e-c)**2+(n-u)**2);l<i&&l>0&&(i=l,r=s)}return r})(t,e,n);if(!o)return;const r=o.getBoundingClientRect(),i=Math.max(r.left,Math.min(e,r.right)),s=Math.max(r.top,Math.min(n,r.bottom)),a=Math.sqrt((e-i)**2+(n-s)**2);if(a>0&&a<=20){const t=`${Math.round(r.width)}x${Math.round(r.height)}`;$({t:"sig",ts:Date.now(),d:{s:"tap_miss",el:c(o),dist:Math.round(a),size:t}})}})(i,e.clientX,e.clientY),r<500&&(Math.abs(n)>50||Math.abs(o)>50)&&((t,e,n)=>{if(Math.abs(n)>Math.abs(e))return;if(!t)return;if(te.some(e=>{try{return t.matches(e)||t.closest(e)}catch{return!1}}))return;if(!te.some(t=>{try{return null!==document.querySelector(t)}catch{return!1}}))return;const o=e>0?"right":"left";$({t:"sig",ts:Date.now(),d:{s:"swipe_miss",dir:o}})})(i,n,o),ne=null}),de=e(()=>{const t=Date.now();if(t-re>3e4&&(oe=0,re=t),++oe>=2){const e=document.activeElement||document.body;ee.some(t=>{try{return e.matches(t)||e.closest(t)}catch{return!1}})||$({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:oe}}),oe=0}}),fe=e(()=>{const t=Date.now(),e=screen.orientation?.type||"unknown";t-se>3e4&&(ie=0,se=t),e!==ae&&(ie++,ae=e),ie>=3&&($({t:"sig",ts:t,d:{s:"orientation_thrash",cnt:ie}}),ie=0)}),pe=e(()=>{const t=window.visualViewport;if(t&&t.scale>1.1){const t=Date.now();t-re>3e4&&(oe=0,re=t),++oe>=2&&($({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:oe}}),oe=0)}}),he=[],me=null,we=0,ye=0,ge=[],be=e(t=>{const e=Date.now(),n=t.target;n&&l(n,[])||("Tab"===t.key?((t,e)=>{for(;he.length&&t-he[0].ts>5e3;)he.shift();he.length>=50&&(he=he.slice(-25));const n=e?c(e):"";if(he.push({ts:t,el:n}),he.length>=10){const e=he.map(t=>t.el).filter(Boolean);$({t:"sig",ts:t,d:{s:"tab_thrash",cnt:he.length,els:e}}),he=[]}if(!e)return;const o=e.closest('[role="dialog"]')||e.closest('[role="menu"]')||e.closest(".modal")||e.closest('[aria-modal="true"]');o&&(o===me?t-ye<=3e3?++we>=5&&($({t:"sig",ts:t,d:{s:"focus_trap",container:c(o),attempts:we}}),we=0,me=null):(ye=t,we=1):(me=o,ye=t,we=1))})(e,n):"Escape"===t.key?((t,e)=>{if(!e)return;const n=e.closest('[role="dialog"]')||e.closest('[role="menu"]')||e.closest(".modal")||e.closest('[aria-modal="true"]');n&&n===me&&++we>=5&&($({t:"sig",ts:t,d:{s:"focus_trap",container:c(n),attempts:we}}),we=0,me=null)})(e,t.target):"ArrowDown"!==t.key&&"ArrowUp"!==t.key&&"ArrowLeft"!==t.key&&"ArrowRight"!==t.key||((t,e)=>{if(!e)return;const n=e.closest('[role="listbox"]')||e.closest('[role="menu"]')||e.closest('[role="tree"]')||e.closest("select");if(!n)return;for(;ge.length&&t-ge[0].ts>5e3;)ge.shift();ge.length>=50&&(ge=ge.slice(-25)),ge.push({ts:t,container:n});const o=ge.filter(t=>t.container===n);o.length>=15&&($({t:"sig",ts:t,d:{s:"keyboard_nav_frustration",container:c(n),keys:o.length}}),ge=[])})(e,t.target))}),ve=0,_e=0,Me=null,ke=0,Te=!1,De=e(()=>{Te||(Te=!0,requestAnimationFrame(()=>{Te=!1,(()=>{const t=Date.now(),e=window.scrollY,n=e-_e;if(Math.abs(n)<2)return void(_e=e);const o=n>0?"down":"up";Me&&o!==Me&&(t-ke>3e3&&(ve=0,ke=t),++ve>=4)&&Math.abs(n)>100&&($({t:"sig",ts:t,d:{s:"scroll_hijack",rev:ve}}),ve=0),Me=o,_e=e})()}))}),Ae=0,xe=!1,Ee=e(()=>{xe||(xe=!0,requestAnimationFrame(()=>{xe=!1;const t=document.documentElement.scrollHeight-window.innerHeight;if(t>0){const e=window.scrollY/t;e>Ae&&(Ae=e)}}))}),Se=t($e),Oe=null;function $e(){Ae>.05&&$({t:"sig",ts:Date.now(),d:{s:"scroll_depth_abandon",depth:Math.round(100*Ae)/100}})}var je="",Ue=0,Ne=0,Re=0,Le=0,Ce=0,ze=null,Be=!1,Ie=e(t=>{const e=t.target;if(!e)return;const n=c(e),o=Date.now();(n!==je||o-Ne>1500)&&(je=n,Ne=o,Ue=0),(Ue+=1)<4||($({t:"sig",ts:o,d:{s:"thrash_hover",el:n,cnt:Ue,window_ms:1500}}),Ue=0,Ne=o)}),Fe=e(()=>{const t=Date.now(),e=Pe(),n=Ce||e,o=Math.abs(e-n)/Math.max(n,1);Ce=e,o<.15||((!Re||t-Re>5e3)&&(Re=t,Le=0),(Le+=1)<3||($({t:"sig",ts:t,d:{s:"viewport_thrashing",cnt:Le,area_delta:Math.round(1e3*o)/1e3}}),Le=0,Re=t))}),Je=e(()=>{qe()});function qe(){Xe(),ze=setTimeout(()=>{$({t:"sig",ts:Date.now(),d:{s:"user_confusion_idle",idle_ms:15e3}})},15e3)}function Pe(){return Math.max(1,window.innerWidth*window.innerHeight)}function Xe(){ze&&(clearTimeout(ze),ze=null)}var Ze=!1,He=null,Ve=null;function Ye(e){if(Ze)return;if(!e.key)return;if(e.key.startsWith("fd_sec_"))return;if(!e.key.startsWith("fd_pub_"))return;if(!1!==e.respectDoNotTrack&&("1"===navigator.doNotTrack||navigator.globalPrivacyControl))return void(Ve=e);if(void 0!==e.sampleRate&&e.sampleRate<1&&Math.random()>e.sampleRate)return void(Ve=e);Ve=e,Ze=!0;const r=(t=>{if(t)return i();const e=(()=>{const t=document.cookie.match(new RegExp("(?:^|; )_fd_s=([^;]*)"));return t?.[1]?decodeURIComponent(t[1]):null})();if(e&&o.test(e))return e;const r=i();return s(n,r,30),r})(e.cookieless??!1),a=(t=>{if(t)try{const e=new URL(t),n="http:"===e.protocol&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(e.hostname);if("https:"!==e.protocol&&!n)return;return e.origin+e.pathname}catch{return}})(e.endpoint)??"https://api.flusterduck.com/v1/ingest",c=B(location.pathname,e.pageRules??[]),u="metadata"===(l=e.domMode)||"snapshot"===l?l:"off";var l;((t,e,n,o,r)=>{var i;b=t,M=Object.assign(Object.create(null),e),k={domMode:(i=r?.domMode,"metadata"===i||"snapshot"===i?i:"off"),compression:z(r?.compression)},v=Math.max(5e3,Math.min(n??7e3,1e4)),_=Math.max(5,Math.min(o??50,100)),document.addEventListener("visibilitychange",S),window.addEventListener("pagehide",O)})(a,{sid:r,key:e.key,url:location.origin+location.pathname,page:c,ua:navigator.userAgent.slice(0,200),vw:window.innerWidth,vh:window.innerHeight,segment:e.segment,environment:e.environment},e.batchInterval,e.batchMaxSize,{domMode:u,compression:e.compression});const d=document.referrer;let f="";if(d)try{f=new URL(d).origin+new URL(d).pathname}catch{f=""}$({t:"pv",ts:Date.now(),d:{ref:f}});const p=e.ignoreElements??[],h=t=>{const n=e.signals?.[t];return!1!==n?.enabled};if(h("rageClick")&&((t,e)=>{P=t?.threshold??3,X=t?.windowMs??2e3,Z=[...J,...e??[]],document.addEventListener("click",H,{capture:!0,passive:!0})})(e.signals?.rageClick,p),h("deadClick")&&(t=>{K=t??[],document.addEventListener("mousedown",W,{capture:!0,passive:!0}),document.addEventListener("click",tt,{capture:!0,passive:!0})})(p),h("speedFrustration")){const t=e.signals?.speedFrustration;((t,e)=>{ot=t?.delayMs??3e3,rt=e??[],document.addEventListener("click",at,{capture:!0,passive:!0})})(t?{delayMs:t.windowMs}:void 0,p)}var m;if(!1!==e.trackMouse&&h("thrashCursor")&&(m=e.signals?.thrashCursor,ut=m?.velocityThreshold??800,lt=m?.windowMs??2e3,document.addEventListener("mousemove",_t,{passive:!0})),h("loopNav")&&(t=>{Tt=t?.windowMs??3e4})(e.signals?.loopNav),h("scrollBounce")&&(Dt=1e4,At=.5,window.addEventListener("scroll",jt,{passive:!0})),!1!==e.trackForms&&(h("formHesitation")||h("formAbandon"))){const n=e.signals?.formHesitation;((e,n)=>{zt=e?.pauseMs??5e3,Bt=n??[],document.addEventListener("focusin",It,{capture:!0,passive:!0}),document.addEventListener("focusout",Ft,{capture:!0,passive:!0}),document.addEventListener("submit",Jt,{capture:!0,passive:!0}),window.addEventListener("pagehide",qt),Pt=t(()=>{"hidden"===document.visibilityState&&Xt()}),document.addEventListener("visibilitychange",Pt)})(n?{pauseMs:n.threshold}:void 0,p)}h("errorEncounter")&&(window.addEventListener("error",Gt),window.addEventListener("unhandledrejection",Kt),Ht||(Ht=window.fetch,Vt=function(t,e){let n;try{n=Ht.call(this,t,e)}catch(t){throw t}return n.then(e=>{try{if(e.status>=400){const n="string"==typeof t?t:t instanceof URL?t.pathname:t.url;Yt.test(n)||$({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:`${e.status} ${e.statusText}`,ep:Qt(n),status:e.status}})}}catch{}return e},e=>{try{const n="string"==typeof t?t:t instanceof URL?t.href:t.url;Yt.test(n)||$({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:Wt(e instanceof Error?e.message:"Fetch failed",200),ep:"string"==typeof t?Qt(t):"",status:0}})}catch{}throw e})},window.fetch=Vt)),("ontouchstart"in window||navigator.maxTouchPoints>0)&&(t=>{ce=t??[],document.addEventListener("touchstart",ue,{passive:!0}),document.addEventListener("touchend",le,{passive:!0}),"ontouchstart"in window&&(document.addEventListener("gesturechange",de,{passive:!0}),window.addEventListener("orientationchange",fe,{passive:!0})),window.visualViewport?.addEventListener("resize",pe)})(p),(h("tabThrash")||h("focusTrap")||h("keyboardNavFrustration"))&&document.addEventListener("keydown",be,{capture:!0,passive:!0}),h("scrollHijack")&&window.addEventListener("scroll",De,{passive:!0}),h("scrollDepthAbandon")&&(window.addEventListener("scroll",Ee,{passive:!0}),window.addEventListener("pagehide",Se),Oe=t(()=>{"hidden"===document.visibilityState&&$e()}),document.addEventListener("visibilitychange",Oe)),h("advancedHeuristics")&&(Be||(Be=!0,Ce=Pe(),qe(),document.addEventListener("mouseenter",Ie,!0),document.addEventListener("mouseleave",Ie,!0),document.addEventListener("click",Je,{capture:!0,passive:!0}),document.addEventListener("keydown",Je,{capture:!0,passive:!0}),document.addEventListener("scroll",Je,{passive:!0}),window.addEventListener("resize",Fe,{passive:!0}))),He=function(t){let e=location.href;function n(){const n=location.href;n!==e&&(e=n,t(n,location.pathname))}const o=history.pushState,r=history.replaceState,i=function(...t){o.apply(this,t),n()},s=function(...t){r.apply(this,t),n()};return history.pushState=i,history.replaceState=s,window.addEventListener("popstate",n),window.addEventListener("hashchange",n),()=>{history.pushState===i&&(history.pushState=o),history.replaceState===s&&(history.replaceState=r),window.removeEventListener("popstate",n),window.removeEventListener("hashchange",n)}}(t((t,n)=>{j(),xt=[],Et=0,St=0,Nt.clear(),Rt.clear(),Lt=null,Ct=0,Ae=0,qe(),U({page:B(n,e.pageRules??[]),url:t}),(t=>{const e=Date.now();try{const t=performance.getEntriesByType("navigation");if(t.length>0&&"back_forward"===t[0].type)return}catch{}for(;kt.length&&e-kt[0].ts>Tt;)kt.shift();if(kt.length>=100&&(kt=kt.slice(-50)),kt.push({path:t,ts:e}),kt.length<4)return;const n=t;let o=!1;const r=[];for(let t=0;t<kt.length-1;t++)if(kt[t].path===n){const e=kt.slice(t,kt.length),n=new Set(e.map(t=>t.path));if(n.size>=2){r.push(...Array.from(n)),o=!0;break}}o&&($({t:"sig",ts:e,d:{s:"loop_nav",pages:r}}),kt=[{path:t,ts:e}])})(n),$({t:"pv",ts:Date.now(),d:{ref:""}})}))}function Ge(t,e){if(!Ze)return;if("string"!=typeof t||!t||t.length>128)return;let n;try{n=JSON.stringify(e?.metadata??{})}catch{return}if(n.length>2048)return;const o=JSON.parse(n);$({t:"sig",ts:Date.now(),d:{s:t.slice(0,128),el:"string"==typeof e?.element?e.element.slice(0,256):"",meta:o,w:Math.max(0,Math.min(e?.weight??15,100))}})}function Ke(t,e={}){if(!Ze)return;if("string"!=typeof t||!/^[a-z0-9_.-]{1,120}$/i.test(t))return;let n;try{n=JSON.stringify(e??{})}catch{return}n.length>2048||$({t:"custom_signal",ts:Date.now(),d:{business_event:t.slice(0,120),meta:JSON.parse(n)}})}function Qe(t){if(!Ze)return;if(!t||"object"!=typeof t)return;const e=Object.create(null);let n=0;for(const o of Object.keys(t)){if(n>=20)break;"__proto__"!==o&&"constructor"!==o&&"prototype"!==o&&(e[o.slice(0,64)]=String(t[o]).slice(0,256),n++)}U({segment:e})}function We(t){t&&Ve&&!Ze?Ye(Ve):t||(en(),r())}function tn(){en(),r()}function en(){Ze&&(document.removeEventListener("click",H,{capture:!0,passive:!0}),q=[],document.removeEventListener("mousedown",W,{capture:!0}),document.removeEventListener("click",tt,{capture:!0}),Q=null,document.removeEventListener("click",at,{capture:!0}),ct(),document.removeEventListener("mousemove",_t),vt&&clearTimeout(vt),Mt(),kt=[],window.removeEventListener("scroll",jt),xt=[],document.removeEventListener("focusin",It,{capture:!0}),document.removeEventListener("focusout",Ft,{capture:!0}),document.removeEventListener("submit",Jt,{capture:!0}),window.removeEventListener("pagehide",qt),Pt&&(document.removeEventListener("visibilitychange",Pt),Pt=null),Nt.clear(),Rt.clear(),Lt=null,window.removeEventListener("error",Gt),window.removeEventListener("unhandledrejection",Kt),Ht&&Vt&&window.fetch===Vt&&(window.fetch=Ht),Ht=null,Vt=null,document.removeEventListener("touchstart",ue),document.removeEventListener("touchend",le),document.removeEventListener("gesturechange",de),window.removeEventListener("orientationchange",fe),window.visualViewport?.removeEventListener("resize",pe),document.removeEventListener("keydown",be,{capture:!0}),he=[],ge=[],me=null,window.removeEventListener("scroll",De),ve=0,_e=0,Me=null,ke=0,Te=!1,window.removeEventListener("scroll",Ee),window.removeEventListener("pagehide",Se),Oe&&(document.removeEventListener("visibilitychange",Oe),Oe=null),Ae=0,xe=!1,Be&&(Be=!1,document.removeEventListener("mouseenter",Ie,!0),document.removeEventListener("mouseleave",Ie,!0),document.removeEventListener("click",Je,{capture:!0}),document.removeEventListener("keydown",Je,{capture:!0}),document.removeEventListener("scroll",Je),window.removeEventListener("resize",Fe),Xe(),je="",Ue=0,Le=0,Re=0),j(),document.removeEventListener("visibilitychange",S),window.removeEventListener("pagehide",O),g&&(clearTimeout(g),g=null),He&&(He(),He=null),Ze=!1)}function nn(t){if(t)try{const e=new URL(t),n="http:"===e.protocol&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(e.hostname);if("https:"!==e.protocol&&!n)return;return e.origin+e.pathname}catch{return}}(()=>{try{const t=window;if(t.flusterduck)return;const e=document.currentScript;if(!e)return;const n=e.getAttribute("data-key");if(!n)return;const o={key:n,environment:e.getAttribute("data-env")||void 0,endpoint:nn(e.getAttribute("data-endpoint")),debug:"true"===e.getAttribute("data-debug"),cookieless:"true"===e.getAttribute("data-cookieless"),respectDoNotTrack:"false"!==e.getAttribute("data-dnt")},r=e.getAttribute("data-dom-mode");"metadata"!==r&&"snapshot"!==r||(o.domMode=r),"off"===e.getAttribute("data-compression")&&(o.compression="off");const i=e.getAttribute("data-sample");if(i){const t=parseFloat(i);isNaN(t)||(o.sampleRate=Math.max(0,Math.min(t,1)))}const s=e.getAttribute("data-segment");if(s&&s.length<2048)try{const t=JSON.parse(s);if(t&&"object"==typeof t&&!Array.isArray(t)){const e=Object.create(null);for(const n of Object.keys(t))"__proto__"!==n&&"constructor"!==n&&"prototype"!==n&&(e[n]=String(t[n]));o.segment=e}}catch{}Ye(o),t.flusterduck=Object.freeze({init:Ye,signal:Ge,track:Ke,identify:Qe,setConsent:We,optOut:tn,destroy:en})}catch{}})()})();
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var fe=Object.defineProperty;var wn=Object.getOwnPropertyDescriptor;var En=Object.getOwnPropertyNames;var yn=Object.prototype.hasOwnProperty;var Sn=(e,t)=>{for(var n in t)fe(e,n,{get:t[n],enumerable:!0})},Mn=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of En(t))!yn.call(e,r)&&r!==n&&fe(e,r,{get:()=>t[r],enumerable:!(o=wn(t,r))||o.enumerable});return e};var Tn=e=>Mn(fe({},"__esModule",{value:!0}),e);var or={};Sn(or,{destroy:()=>ue,identify:()=>gn,init:()=>it,optOut:()=>bn,setConsent:()=>vn,signal:()=>hn});module.exports=Tn(or);function S(e){return(...t)=>{try{return e(...t)}catch{}}}function d(e){return t=>{try{e(t)}catch{}}}var me="_fd_s";var xn=/^[0-9a-f]{32}$/;function at(e){if(e)return st();let t=An(me);if(t&&xn.test(t))return t;let n=st();return ct(me,n,30),n}function pe(){ct(me,"",-1)}function st(){let e=new Uint8Array(16);crypto.getRandomValues(e);let t="";for(let n of e)t+=n.toString(16).padStart(2,"0");return t}function An(e){let t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?.[1]?decodeURIComponent(t[1]):null}function ct(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 kn=/^[:\d]|--|^(ember|react|ng-|__)/;function f(e){if(!e||e===document.documentElement)return"html";let t=e.getAttribute("data-fd");if(t)return`[data-fd="${q(t)}"]`;if(e.id&&!kn.test(e.id)&&e.id.length<64)return"#"+q(e.id);let n=[],o=e,r=0;for(;o&&o!==document.body&&r<5;){let i=o.tagName.toLowerCase(),a=o.getAttribute("name"),s=o.getAttribute("role"),c=o.getAttribute("type");a&&a.length<64?i+=`[name="${q(a)}"]`:s?i+=`[role="${q(s)}"]`:c&&(i==="input"||i==="button")&&(i+=`[type="${q(c)}"]`);let l=o.parentElement;if(l){let g=l.children,b=0,j=0;for(let O=0;O<g.length;O++){let de=g[O];de&&de.tagName===o.tagName&&(b++,de===o&&(j=b))}b>1&&(i+=`:nth-of-type(${j})`)}n.unshift(i);let h=n.join(" > ");try{if(document.querySelectorAll(h).length===1)return h}catch{}o=l,r++}return n.join(" > ")}function q(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):e.replace(/([^\w-])/g,"\\$1")}function w(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 ut(e,t){if(t==="off")return null;if(t==="metadata")return Ln(e);let n=Dn(e);return n?{mode:"snapshot",...n}:null}function Ln(e){return{mode:"metadata",selector:f(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:lt(e.getAttribute("aria-expanded"),["true","false"]),ariaInvalid:lt(e.getAttribute("aria-invalid"),["true","false","grammar","spelling"]),type:Rn(e)}}}function Dn(e){try{let t=e.getBoundingClientRect(),n=getComputedStyle(e),o=e.parentElement,r=[];if(o)for(let a=0;a<o.children.length&&r.length<6;a++){let s=o.children[a];if(!s||s===e)continue;let c=s.getBoundingClientRect();r.push({selector:f(s),tag:s.tagName.toLowerCase(),box:{x:Math.round(c.x),y:Math.round(c.y),w:Math.round(c.width),h:Math.round(c.height)},interactive:Cn(s)})}let i=[];try{let a=e.getAnimations();for(let s of a)"animationName"in s&&i.push(s.animationName)}catch{}return{selector:f(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),parent:o?f(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:_n(t),animations:i,siblings:r}}catch{return null}}function lt(e,t){return e&&t.includes(e)?e:null}function Rn(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 _n(e){return e.top<window.innerHeight&&e.bottom>0&&e.left<window.innerWidth&&e.right>0}function Cn(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 ft=3e3,mt=50,pt=50,On=3,Nn=65536,N=[],A=null,Z="",ht=ft,gt=mt,v=null,ge={domMode:"off"},he=!1,In=new Set(["sid","key","url","page","ua","vw","vh","segment","environment"]),Fn=new Set(["click","move","scroll","keyboard","form_focus","form_blur","form_submit","touch","navigation","error","signal","pageview","custom_signal","performance","visibility","sdk_error"]),Pn=/(?:value|text|label|email|e-mail|name|phone|address|password|token|secret|cookie|session|jwt|auth|credential|card|cc|cvv|ssn)/i,Un=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,vt=d(Hn),bt=S(()=>D());function wt(e,t,n,o,r){Z=e,v=Object.assign(Object.create(null),t),ge={domMode:Xn(r?.domMode)},ht=Math.max(1e3,Math.min(n??ft,3e4)),gt=Math.max(5,Math.min(o??mt,pt)),document.addEventListener("visibilitychange",vt),window.addEventListener("pagehide",bt)}function u(e){N.length>=pt||(N.push(e),N.length>=gt?D():A||(A=setTimeout(D,ht)))}function D(){if(he||!N.length||!v)return;he=!0,A&&(clearTimeout(A),A=null);let e=N;N=[];let t={v:1,sid:v.sid,key:v.key,url:v.url,page:v.page,ts:Date.now(),ua:v.ua,vw:v.vw,vh:v.vh,environment:v.environment,dom_mode:ge.domMode,events:e.map(n=>jn(n,v.page,ge.domMode))};try{let n=JSON.stringify(t);n.length<=Nn&&yt(n,0)}catch{}he=!1}function ve(e){if(v)for(let t of Object.keys(e))In.has(t)&&(v[t]=e[t])}function Et(){D(),document.removeEventListener("visibilitychange",vt),window.removeEventListener("pagehide",bt),A&&(clearTimeout(A),A=null)}function Hn(){document.visibilityState==="hidden"&&D()}function yt(e,t){if(Z){if(navigator.sendBeacon){let n=new Blob([e],{type:"application/json"});if(navigator.sendBeacon(Z,n))return}try{fetch(Z,{method:"POST",body:e,headers:{"Content-Type":"application/json"},keepalive:!0}).catch(()=>{t<On&&setTimeout(()=>yt(e,t+1),1e3*(t+1))})}catch{}}}function jn(e,t,n){let o=e.d??{},r=qn(e.t),i={type:r,ts:e.ts,page:typeof o.page=="string"?o.page.slice(0,2048):t},a=dt(o.el,o.element,o.target);if(r==="signal"){i.signal_type=dt(o.s,o.signal_type,o.name)?.slice(0,128),a&&(i.element=a.slice(0,2048));let c=a?Vn(a,n):null;c&&(i.dom=c)}let s=Bn(o);return Object.keys(s).length&&(i.metadata=s),i}function qn(e){return e==="pv"?"pageview":e==="sig"?"signal":Fn.has(e)?e:"custom_signal"}function Bn(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=J(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=J(e.meta,"meta");n&&typeof n=="object"&&!Array.isArray(n)&&Object.assign(t,n)}return t}function J(e,t="",n=0){if(!(n>4)&&!Pn.test(t)){if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string")return Un.test(e)?void 0:e.slice(0,500);if(Array.isArray(e))return e.slice(0,20).map(r=>J(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=J(e[r],r,n+1);i!==void 0&&(o[r.slice(0,64)]=i)}return o}}}function Vn(e,t){if(t==="off")return null;try{let n=document.querySelector(e);return n?ut(n,t):null}catch{return null}}function dt(...e){for(let t of e)if(typeof t=="string"&&t)return t}function Xn(e){return e==="metadata"||e==="snapshot"?e:"off"}function St(e){let t=location.href;function n(){let s=location.href;s!==t&&(t=s,e(s,location.pathname))}let o=history.pushState,r=history.replaceState,i=function(...s){o.apply(this,s),n()},a=function(...s){r.apply(this,s),n()};return history.pushState=i,history.replaceState=a,window.addEventListener("popstate",n),window.addEventListener("hashchange",n),function(){history.pushState===i&&(history.pushState=o),history.replaceState===a&&(history.replaceState=r),window.removeEventListener("popstate",n),window.removeEventListener("hashchange",n)}}function be(e,t){for(let n of t){let o=$n(n.pattern);if(o&&o.test(e))return n.label}return zn(e)}var Yn=/^[a-zA-Z0-9/:._*\-]+$/;function $n(e){if(e.length>200||!Yn.test(e))return null;let t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/:\w+/g,"[^/]+");try{return new RegExp("^"+t+"$")}catch{return null}}function zn(e){return e.replace(/\/\d+/g,"/:id").replace(/\/[a-f0-9-]{36}/g,"/:id")}var Kn=[".carousel-arrow",".slick-arrow",".swiper-button-next",".swiper-button-prev","[data-carousel]",'button[aria-label*="next"]','button[aria-label*="prev"]','button[aria-label*="slide"]',".quantity-btn",".qty-btn",'input[type="number"]'],k=[],we=3,Tt=2e3,Mt=8,xt=[],At=d(Wn);function Ee(e,t){we=e?.threshold??3,Tt=e?.windowMs??2e3,xt=[...Kn,...t??[]],document.addEventListener("click",At,{capture:!0,passive:!0})}function ye(){document.removeEventListener("click",At,{capture:!0}),k=[]}function Wn(e){let t=e.target;if(!t||w(t,xt)||Qn(t))return;let n=Date.now(),o=e.clientX,r=e.clientY;for(;k.length&&n-k[0].t>Tt;)k.shift();if(k.push({t:n,x:o,y:r,el:t}),k.length<we)return;let i=k.slice(-we),a=i[0];for(let g=1;g<i.length;g++){let b=i[g],j=b.x-a.x,O=b.y-a.y;if(j*j+O*O>Mt*Mt)return}let s=a.t,l=(i[i.length-1].t-s)/1e3,h=l>0?i.length/l:i.length;u({t:"sig",ts:n,d:{s:"rage_click",el:f(t),cnt:i.length,vel:Math.round(h*10)/10}}),k=[]}function Qn(e){let t=e.tagName;return!!(t==="VIDEO"||t==="AUDIO"||e.hasAttribute("ondblclick"))}var Gn=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,Zn=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,Jn=/^(A|BUTTON|LABEL)$/,kt=[],B=null,eo=5,Lt=d(to),Dt=d(no);function to(e){B={x:e.clientX,y:e.clientY}}function Se(e){kt=e??[],document.addEventListener("mousedown",Lt,{capture:!0,passive:!0}),document.addEventListener("click",Dt,{capture:!0,passive:!0})}function Me(){document.removeEventListener("mousedown",Lt,{capture:!0}),document.removeEventListener("click",Dt,{capture:!0}),B=null}function no(e){if(e.button!==0||e.detail===0)return;let t=e.target;if(!t||w(t,kt)||io()||so(e)||oo(t))return;let n=ro(t,e.clientX,e.clientY),o=n?Rt(e.clientX,e.clientY,n):-1;u({t:"sig",ts:Date.now(),d:{s:"dead_click",el:f(t),near:n?f(n):"",dist:Math.round(o)}})}function oo(e){if(Gn.test(e.tagName))return!0;let t=e.getAttribute("role");if(t&&Zn.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;if(n&&Jn.test(n.tagName)||e.closest('a, button, [role="button"], label, [onclick]'))return!0;try{if(getComputedStyle(e).cursor==="pointer")return!0}catch{return!1}return!1}function ro(e,t,n){let o=e.parentElement;if(!o)return null;let r=o.querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]'),i=null,a=1/0;for(let s=0;s<r.length;s++){let c=r[s];if(!c)continue;let l=Rt(t,n,c);l<a&&(a=l,i=c)}return i}function Rt(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)),a=e-r,s=t-i;return Math.sqrt(a*a+s*s)}function io(){let e=window.getSelection();return e!==null&&e.toString().length>0}function so(e){if(!B)return!1;let t=e.clientX-B.x,n=e.clientY-B.y;return Math.sqrt(t*t+n*n)>eo}var m=null,Te=3e3,_t=[],ao=/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/,co=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton)$/,Ct=d(lo);function xe(e,t){Te=e?.delayMs??3e3,_t=t??[],document.addEventListener("click",Ct,{capture:!0,passive:!0})}function Ae(){document.removeEventListener("click",Ct,{capture:!0}),V()}function lo(e){let t=e.target;if(!t||w(t,_t))return;let n=t.getAttribute("role");if(!ao.test(t.tagName)&&!(n&&co.test(n)))return;if(m){if(m.el===t||m.el.contains(t)){let c=Date.now()-m.ts;c>=Te&&u({t:"sig",ts:Date.now(),d:{s:"speed_frustration",el:m.selector,delay:c}}),V();return}V()}let o=f(t),r=!1,i=new MutationObserver(c=>{for(let l of c){if(l.type==="childList"&&(l.addedNodes.length>0||l.removedNodes.length>0)){r=!0,V();return}if(l.type==="attributes"&&l.target instanceof Element&&(l.target===t||t.contains(l.target)||l.target.contains(t))){r=!0,V();return}}}),a=t.parentElement||document.body;i.observe(a,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-hidden","disabled"]});let s=setTimeout(()=>{!r&&m&&(m={...m,timeout:null})},Te+500);m={el:t,selector:o,ts:Date.now(),observer:i,timeout:s}}function V(){m&&(m.observer.disconnect(),m.timeout&&clearTimeout(m.timeout),m=null)}var uo=100,Nt=800,It=2e3,fo=3,Ot=0,mo=50,ee=0,te=0,X=0,Y=0,$=0,ne=0,ke=0,R=[],Ft=d(po);function Le(e){Nt=e?.velocityThreshold??800,It=e?.windowMs??2e3,document.addEventListener("mousemove",Ft,{passive:!0})}function De(){document.removeEventListener("mousemove",Ft),Pt()}function po(e){let t=Date.now();t-Ot<mo||(Ot=t,ho(e.clientX,e.clientY,t))}function ho(e,t,n){if(X===0){ee=e,te=t,X=n,ke=n;return}let o=(n-X)/1e3;if(o===0)return;let r=e-ee,i=t-te,s=Math.sqrt(r*r+i*i)/o;R.length>=uo&&(R=R.slice(-50)),R.push(s);let c=Math.sign(r),l=Math.sign(i);if((Y!==0&&c!==0&&c!==Y||$!==0&&l!==0&&l!==$)&&ne++,Y=c||Y,$=l||$,ee=e,te=t,X=n,n-ke>It){if(ne>=fo){let h=R.reduce((g,b)=>g+b,0)/R.length;h>=Nt&&u({t:"sig",ts:n,d:{s:"thrash_cursor",vel:Math.round(h),rev:ne}})}Pt(),ke=n}}function Pt(){ne=0,R=[],Y=0,$=0,X=0,ee=0,te=0}var go=100,p=[],Ut=3e4;function Re(e){Ut=e?.windowMs??3e4}function _e(){p=[]}function Ce(e){let t=Date.now();for(;p.length&&t-p[0].ts>Ut;)p.shift();if(p.length>=go&&(p=p.slice(-50)),p.push({path:e,ts:t}),p.length<4)return;let n=e,o=!1,r=[];for(let i=p.length-2;i>=1;i--)if(p[i-1].path===n){let a=p.slice(i-1,p.length);for(let s of a)r.includes(s.path)||r.push(s.path);o=!0;break}o&&r.length>=2&&(u({t:"sig",ts:t,d:{s:"loop_nav",pages:r}}),p=[{path:e,ts:t}])}var vo=100,Ht=1e4,Ie=.5,E=[],oe=0,Fe=0,Oe=!1,Ne=0,jt=d(bo);function Pe(e){Ht=e?.windowMs??1e4,Ie=e?.depthThreshold??.5,window.addEventListener("scroll",jt,{passive:!0})}function Ue(){window.removeEventListener("scroll",jt),E=[]}function He(){E=[],oe=0,Fe=0}function bo(){Oe||(Oe=!0,requestAnimationFrame(()=>{Oe=!1,wo()}))}function wo(){let e=Date.now(),t=window.scrollY;if(Ne=document.documentElement.scrollHeight-window.innerHeight,Ne<=0)return;let n=t/Ne,o=t>oe?"down":"up";if(e-Fe<100){oe=t;return}for(;E.length&&e-E[0].ts>Ht;)E.shift();E.length>=vo&&(E=E.slice(-50)),E.push({depth:n,ts:e,direction:o}),oe=t,Fe=e;let r=0,i=1,a=0,s=!1;for(let c=0;c<E.length;c++){let l=E[c].depth;l>r&&(r=l),l>=Ie&&(s=!0),s&&l<i&&(i=l),s&&i<.25&&l>=Ie&&(a++,s=!1,i=1)}a>=1&&(u({t:"sig",ts:e,d:{s:"scroll_bounce",depth:Math.round(r*100)/100,rev:a+1}}),E=[])}var Eo=["textarea",'[role="textbox"]',"[contenteditable]"],K=new Map,L=new Set,_=null,je=0,qt=5e3,Bt=[],Vt=d(yo),Xt=d(So),Yt=d(Mo),$t=S(zt),z=null;function qe(e,t){qt=e?.pauseMs??5e3,Bt=t??[],document.addEventListener("focusin",Vt,{capture:!0,passive:!0}),document.addEventListener("focusout",Xt,{capture:!0,passive:!0}),document.addEventListener("submit",Yt,{capture:!0,passive:!0}),window.addEventListener("pagehide",$t),z=S(()=>{document.visibilityState==="hidden"&&zt()}),document.addEventListener("visibilitychange",z)}function Be(){document.removeEventListener("focusin",Vt,{capture:!0}),document.removeEventListener("focusout",Xt,{capture:!0}),document.removeEventListener("submit",Yt,{capture:!0}),window.removeEventListener("pagehide",$t),z&&(document.removeEventListener("visibilitychange",z),z=null),K.clear(),L.clear(),_=null}function Ve(){K.clear(),L.clear(),_=null,je=0}function yo(e){let t=e.target;if(!t||!Kt(t)||w(t,Bt)||To(t))return;K.set(t,Date.now());let n=t.closest("form");n&&n!==_&&(_=n,je=n.querySelectorAll("input, select, textarea").length)}function So(e){let t=e.target;if(!t||!Kt(t))return;let n=K.get(t);if(K.delete(t),n){let r=Date.now()-n;r>=qt&&u({t:"sig",ts:Date.now(),d:{s:"form_hesitation",el:f(t),pause:r}})}let o=t.getAttribute("name")||t.getAttribute("id")||f(t);xo(t)&&L.add(o)}function Mo(){L.clear(),_=null}function zt(){L.size>0&&_&&(u({t:"sig",ts:Date.now(),d:{s:"form_abandon",filled:L.size,total:je||L.size}}),L.clear(),_=null)}function Kt(e){let t=e.tagName;return t==="INPUT"||t==="SELECT"||t==="TEXTAREA"}function To(e){if(e.tagName==="TEXTAREA")return!0;for(let t of Eo)try{if(e.matches(t))return!0}catch{return!1}return!1}function xo(e){return"value"in e?e.value.length>0:!1}var I=null,W=null,Wt=/flusterduck\.com|\/v1\/ingest/,Gt=d(Ao),Zt=d(ko);function Xe(){window.addEventListener("error",Gt),window.addEventListener("unhandledrejection",Zt),Lo()}function Ye(){window.removeEventListener("error",Gt),window.removeEventListener("unhandledrejection",Zt),Do()}function Ao(e){u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"js_error",msg:$e(e.message||"Unknown error",200),ep:"",status:0}})}function ko(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:$e(t,200),ep:"",status:0}})}function Lo(){I||(I=window.fetch,W=function(t,n){let o;try{o=I.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;Wt.test(i)||u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:`${r.status} ${r.statusText}`,ep:Qt(i),status:r.status}})}}catch{}return r},r=>{try{let i=typeof t=="string"?t:t instanceof URL?t.href:t.url;Wt.test(i)||u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:$e(r instanceof Error?r.message:"Fetch failed",200),ep:typeof t=="string"?Qt(t):"",status:0}})}catch{}throw r})},window.fetch=W)}function Do(){I&&W&&window.fetch===W&&(window.fetch=I),I=null,W=null}function Qt(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 $e(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 Jt=[".carousel",".slider",".swiper","[data-swipeable]",".drawer"],Ro=['[class*="map"]',"canvas",".gallery","[data-zoom]"],F=null,M=0,re=0,Q=0,en=0,tn=null,nn=[],on=d(_o),rn=d(Co),sn=d(Io),an=d(Po),cn=d(Fo);function ze(e){nn=e??[],document.addEventListener("touchstart",on,{passive:!0}),document.addEventListener("touchend",rn,{passive:!0}),"ontouchstart"in window&&(document.addEventListener("gesturechange",sn,{passive:!0}),window.addEventListener("orientationchange",an,{passive:!0})),window.visualViewport?.addEventListener("resize",cn)}function Ke(){document.removeEventListener("touchstart",on),document.removeEventListener("touchend",rn),document.removeEventListener("gesturechange",sn),window.removeEventListener("orientationchange",an),window.visualViewport?.removeEventListener("resize",cn)}function _o(e){let t=e.touches[0];e.touches.length===1&&t&&(F={x:t.clientX,y:t.clientY,ts:Date.now()})}function Co(e){if(!F||e.changedTouches.length!==1)return;let t=e.changedTouches[0];if(!t)return;let n=t.clientX-F.x,o=t.clientY-F.y,r=Date.now()-F.ts,i=document.elementFromPoint(t.clientX,t.clientY);Math.abs(n)<10&&Math.abs(o)<10&&r<300&&i&&Oo(i,t.clientX,t.clientY),r<500&&(Math.abs(n)>50||Math.abs(o)>50)&&No(i,n,o),F=null}function Oo(e,t,n){if(w(e,nn))return;let o=Uo(e,t,n);if(!o)return;let r=o.getBoundingClientRect(),i=Math.max(r.left,Math.min(t,r.right)),a=Math.max(r.top,Math.min(n,r.bottom)),s=Math.sqrt((t-i)**2+(n-a)**2);if(s>0&&s<=20){let c=`${Math.round(r.width)}x${Math.round(r.height)}`;u({t:"sig",ts:Date.now(),d:{s:"tap_miss",el:f(o),dist:Math.round(s),size:c}})}}function No(e,t,n){if(Math.abs(n)>Math.abs(t)||!e||Jt.some(a=>{try{return e.matches(a)||e.closest(a)}catch{return!1}})||!Jt.some(a=>{try{return document.querySelector(a)!==null}catch{return!1}}))return;let i=t>0?"right":"left";u({t:"sig",ts:Date.now(),d:{s:"swipe_miss",dir:i}})}function Io(){let e=Date.now();if(e-re>3e4&&(M=0,re=e),M++,M>=2){let t=document.activeElement||document.body;Ro.some(o=>{try{return t.matches(o)||t.closest(o)}catch{return!1}})||u({t:"sig",ts:e,d:{s:"pinch_zoom",cnt:M}}),M=0}}function Fo(){let e=window.visualViewport;if(e&&e.scale>1.1){let t=Date.now();t-re>3e4&&(M=0,re=t),M++,M>=2&&(u({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:M}}),M=0)}}function Po(){let e=Date.now(),t=screen.orientation?.type||"unknown";e-en>3e4&&(Q=0,en=e),t!==tn&&(Q++,tn=t),Q>=3&&(u({t:"sig",ts:e,d:{s:"orientation_thrash",cnt:Q}}),Q=0)}function Uo(e,t,n){let r=(e.parentElement||document.body).querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])'),i=null,a=21;for(let s=0;s<r.length;s++){let c=r[s];if(!c)continue;let l=c.getBoundingClientRect(),h=Math.max(l.left,Math.min(t,l.right)),g=Math.max(l.top,Math.min(n,l.bottom)),b=Math.sqrt((t-h)**2+(n-g)**2);b<a&&b>0&&(a=b,i=c)}return i}var y=[],P=null,x=0,We=0,T=[],Ho=10,jo=5e3,ln=5,qo=3e3,Bo=15,Vo=5e3,un=d(Xo);function Qe(){document.addEventListener("keydown",un,{capture:!0,passive:!0})}function Ge(){document.removeEventListener("keydown",un,{capture:!0}),y=[],T=[],P=null}function Xo(e){let t=Date.now(),n=e.target;n&&w(n,[])||(e.key==="Tab"?Yo(t,n):e.key==="Escape"?$o(t,e.target):(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight")&&zo(t,e.target))}function Yo(e,t){for(;y.length&&e-y[0].ts>jo;)y.shift();y.length>=50&&(y=y.slice(-25));let n=t?f(t):"";if(y.push({ts:e,el:n}),y.length>=Ho){let r=y.map(i=>i.el).filter(Boolean);u({t:"sig",ts:e,d:{s:"tab_thrash",cnt:y.length,els:r}}),y=[]}if(!t)return;let o=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');o&&(o===P?e-We<=qo?(x++,x>=ln&&(u({t:"sig",ts:e,d:{s:"focus_trap",container:f(o),attempts:x}}),x=0,P=null)):(We=e,x=1):(P=o,We=e,x=1))}function $o(e,t){if(!t)return;let n=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');n&&n===P&&(x++,x>=ln&&(u({t:"sig",ts:e,d:{s:"focus_trap",container:f(n),attempts:x}}),x=0,P=null))}function zo(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(;T.length&&e-T[0].ts>Vo;)T.shift();T.length>=50&&(T=T.slice(-25)),T.push({ts:e,container:n});let o=T.filter(r=>r.container===n);o.length>=Bo&&(u({t:"sig",ts:e,d:{s:"keyboard_nav_frustration",container:f(n),keys:o.length}}),T=[])}var U=0,ie=0,se=null,Ze=0,ae=!1,Ko=4,Wo=3e3,dn=d(Qo);function Je(){window.addEventListener("scroll",dn,{passive:!0})}function et(){window.removeEventListener("scroll",dn),U=0,ie=0,se=null,Ze=0,ae=!1}function Qo(){ae||(ae=!0,requestAnimationFrame(()=>{ae=!1,Go()}))}function Go(){let e=Date.now(),t=window.scrollY,n=t-ie;if(Math.abs(n)<2){ie=t;return}let o=n>0?"down":"up";se&&o!==se&&(e-Ze>Wo&&(U=0,Ze=e),U++,U>=Ko&&Math.abs(n)>100&&(u({t:"sig",ts:e,d:{s:"scroll_hijack",rev:U}}),U=0)),se=o,ie=t}var H=0,ce=!1,fn=d(Zo),mn=S(pn),G=null;function tt(){window.addEventListener("scroll",fn,{passive:!0}),window.addEventListener("pagehide",mn),G=S(()=>{document.visibilityState==="hidden"&&pn()}),document.addEventListener("visibilitychange",G)}function nt(){window.removeEventListener("scroll",fn),window.removeEventListener("pagehide",mn),G&&(document.removeEventListener("visibilitychange",G),G=null),H=0,ce=!1}function ot(){H=0}function Zo(){ce||(ce=!0,requestAnimationFrame(()=>{ce=!1;let e=document.documentElement.scrollHeight-window.innerHeight;if(e>0){let t=window.scrollY/e;t>H&&(H=t)}}))}function pn(){H>.05&&u({t:"sig",ts:Date.now(),d:{s:"scroll_depth_abandon",depth:Math.round(H*100)/100}})}var Jo="https://api.flusterduck.com/v1/ingest",C=!1,le=null,rt=null;function er(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 it(e){if(C||!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_")||e.respectDoNotTrack!==!1&&tr()||e.sampleRate!==void 0&&e.sampleRate<1&&Math.random()>e.sampleRate)return;rt=e,C=!0;let t=at(e.cookieless??!1),n=er(e.endpoint)??Jo,o=be(location.pathname,e.pageRules??[]),r=nr(e.domMode);wt(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});let i=document.referrer,a="";if(i)try{a=new URL(i).origin+new URL(i).pathname}catch{a=""}u({t:"pv",ts:Date.now(),d:{ref:a}});let s=e.ignoreElements??[],c=l=>e.signals?.[l]?.enabled!==!1;if(c("rageClick")&&Ee(e.signals?.rageClick,s),c("deadClick")&&Se(s),c("speedFrustration")){let l=e.signals?.speedFrustration;xe(l?{delayMs:l.windowMs}:void 0,s)}if(e.trackMouse!==!1&&c("thrashCursor")&&Le(e.signals?.thrashCursor),c("loopNav")&&Re(e.signals?.loopNav),c("scrollBounce")&&Pe(),e.trackForms!==!1&&(c("formHesitation")||c("formAbandon"))){let l=e.signals?.formHesitation;qe(l?{pauseMs:l.threshold}:void 0,s)}c("errorEncounter")&&Xe(),("ontouchstart"in window||navigator.maxTouchPoints>0)&&ze(s),(c("tabThrash")||c("focusTrap")||c("keyboardNavFrustration"))&&Qe(),c("scrollHijack")&&Je(),c("scrollDepthAbandon")&&tt(),le=St(S((l,h)=>{D(),He(),Ve(),ot();let g=be(h,e.pageRules??[]);ve({page:g,url:l}),Ce(h),u({t:"pv",ts:Date.now(),d:{ref:""}})})),e.debug&&console.warn("[flusterduck] initialized",{sid:t.slice(0,6)+"...",endpoint:n,page:o})}function hn(e,t){if(!C||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);u({t:"sig",ts:Date.now(),d:{s:"custom",name: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 gn(e){if(!C||!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++)}ve({segment:t})}function vn(e){e&&rt&&!C?it(rt):e||(ue(),pe())}function bn(){ue(),pe()}function ue(){C&&(ye(),Me(),Ae(),De(),_e(),Ue(),Be(),Ye(),Ke(),Ge(),et(),nt(),Et(),le&&(le(),le=null),C=!1)}function tr(){return!!(navigator.doNotTrack==="1"||navigator.globalPrivacyControl)}function nr(e){return e==="metadata"||e==="snapshot"?e:"off"}
1
+ "use strict";var Ae=Object.defineProperty;var qn=Object.getOwnPropertyDescriptor;var jn=Object.getOwnPropertyNames;var Vn=Object.prototype.hasOwnProperty;var Yn=(e,t)=>{for(var n in t)Ae(e,n,{get:t[n],enumerable:!0})},Xn=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of jn(t))!Vn.call(e,r)&&r!==n&&Ae(e,r,{get:()=>t[r],enumerable:!(o=qn(t,r))||o.enumerable});return e};var $n=e=>Xn(Ae({},"__esModule",{value:!0}),e);var Br={};Yn(Br,{destroy:()=>Te,identify:()=>Un,init:()=>Tt,optOut:()=>zn,setConsent:()=>Hn,signal:()=>Fn,track:()=>Bn});module.exports=$n(Br);function S(e){return((...t)=>{try{return e(...t)}catch{}})}function d(e){return t=>{try{e(t)}catch{}}}var xe="_fd_s";var Wn=/^[0-9a-f]{32}$/;function At(e){if(e)return Mt();let t=Kn(xe);if(t&&Wn.test(t))return t;let n=Mt();return xt(xe,n,30),n}function ke(){xt(xe,"",-1)}function Mt(){let e=new Uint8Array(16);crypto.getRandomValues(e);let t="";for(let n of e)t+=n.toString(16).padStart(2,"0");return t}function Kn(e){let t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?.[1]?decodeURIComponent(t[1]):null}function xt(e,t,n){let o=new Date;o.setTime(o.getTime()+n*864e5);let r=location.protocol==="https:"?";Secure":"";document.cookie=`${e}=${encodeURIComponent(t)};path=/;expires=${o.toUTCString()};SameSite=Lax${r}`}var Qn=/^[:\d]|--|^(ember|react|ng-|__)/;function m(e){if(!e||e===document.documentElement)return"html";let t=e.getAttribute("data-fd");if(t)return`[data-fd="${Y(t)}"]`;if(e.id&&!Qn.test(e.id)&&e.id.length<64)return"#"+Y(e.id);let n=[],o=e,r=0;for(;o&&o!==document.body&&r<5;){let i=o.tagName.toLowerCase(),c=o.getAttribute("name"),s=o.getAttribute("role"),a=o.getAttribute("type");c&&c.length<64?i+=`[name="${Y(c)}"]`:s?i+=`[role="${Y(s)}"]`:a&&(i==="input"||i==="button")&&(i+=`[type="${Y(a)}"]`);let u=o.parentElement;if(u){let p=u.children,w=0,V=0;for(let O=0;O<p.length;O++){let Me=p[O];Me&&Me.tagName===o.tagName&&(w++,Me===o&&(V=w))}w>1&&(i+=`:nth-of-type(${V})`)}n.unshift(i);let f=n.join(" > ");try{if(document.querySelectorAll(f).length===1)return f}catch{}o=u,r++}return n.join(" > ")}function Y(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):e.replace(/([^\w-])/g,"\\$1")}function b(e,t){if(e.hasAttribute("data-fd-ignore")||e.closest("[data-fd-ignore]"))return!0;for(let n of t)try{if(e.matches(n)||e.closest(n))return!0}catch{}return!1}function Lt(e,t){if(t==="off")return null;if(t==="metadata")return Gn(e);let n=Jn(e);return n?{mode:"snapshot",...n}:null}function Gn(e){return{mode:"metadata",selector:m(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),attributes:{disabled:e.disabled===!0,required:e.required===!0,ariaDisabled:e.getAttribute("aria-disabled")==="true",ariaExpanded:kt(e.getAttribute("aria-expanded"),["true","false"]),ariaInvalid:kt(e.getAttribute("aria-invalid"),["true","false","grammar","spelling"]),type:Zn(e)}}}function Jn(e){try{let t=e.getBoundingClientRect(),n=getComputedStyle(e),o=e.parentElement,r=[];if(o)for(let c=0;c<o.children.length&&r.length<6;c++){let s=o.children[c];if(!s||s===e)continue;let a=s.getBoundingClientRect();r.push({selector:m(s),tag:s.tagName.toLowerCase(),box:{x:Math.round(a.x),y:Math.round(a.y),w:Math.round(a.width),h:Math.round(a.height)},interactive:to(s)})}let i=[];try{let c=e.getAnimations();for(let s of c)"animationName"in s&&i.push(s.animationName)}catch{}return{selector:m(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),parent:o?m(o):"",box:{x:Math.round(t.x),y:Math.round(t.y),w:Math.round(t.width),h:Math.round(t.height)},styles:{opacity:n.opacity,cursor:n.cursor,pointerEvents:n.pointerEvents,display:n.display,visibility:n.visibility,disabled:e.disabled===!0},inView:eo(t),animations:i,siblings:r}}catch{return null}}function kt(e,t){return e&&t.includes(e)?e:null}function Zn(e){let t=e.tagName.toLowerCase();if(t!=="input"&&t!=="button")return null;let n=e.getAttribute("type");return n&&/^[a-z0-9_-]{1,32}$/i.test(n)?n.toLowerCase():null}function eo(e){return e.top<window.innerHeight&&e.bottom>0&&e.left<window.innerWidth&&e.right>0}function to(e){let t=e.tagName;if(/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/.test(t))return!0;let n=e.getAttribute("role");return!!(n&&/^(button|link|tab|menuitem|checkbox|radio)$/.test(n))}var Rt=7e3,no=5e3,oo=1e4,Dt=50,Ct=100,ro=3,X=6e4,se="application/json",io="application/json; encoding=gzip",N=[],x=null,ae="",Ot=Rt,Nt=Dt,v=null,ce={domMode:"off",compression:"auto"},Le=!1,so=new Set(["sid","key","url","page","ua","vw","vh","segment","environment"]),ao=new Set(["click","move","scroll","keyboard","form_focus","form_blur","form_submit","touch","navigation","error","signal","pageview","custom_signal","performance","visibility","sdk_error"]),co=/(?:value|text|label|email|e-mail|name|phone|address|password|token|secret|cookie|session|jwt|auth|credential|card|cc|cvv|ssn)/i,uo=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,It=d(fo),Pt=S(()=>R());function Ft(e,t,n,o,r){ae=e,v=Object.assign(Object.create(null),t),ce={domMode:yo(r?.domMode),compression:Eo(r?.compression)},Ot=Math.max(no,Math.min(n??Rt,oo)),Nt=Math.max(5,Math.min(o??Dt,Ct)),document.addEventListener("visibilitychange",It),window.addEventListener("pagehide",Pt)}function l(e){N.length>=Ct||(N.push(e),N.length>=Nt?R():x||(x=setTimeout(R,Ot)))}function R(){lo()}async function lo(){if(Le||!N.length||!v)return;Le=!0,x&&(clearTimeout(x),x=null);let e=N;N=[];let t={v:1,sid:v.sid,key:v.key,url:v.url,page:v.page,ts:Date.now(),ua:v.ua,vw:v.vw,vh:v.vh,environment:v.environment,dom_mode:ce.domMode},n=e.map(r=>go(r,v.page,ce.domMode)),o=[];try{for(let r of n){let i=[...o,r];if(JSON.stringify({...t,events:i}).length>X)if(o.length>0)await _e({...t,events:o}),o=[r];else{let s={...t,events:[r]};JSON.stringify(s).length<=X&&await _e(s),o=[]}else o=i}o.length>0&&await _e({...t,events:o})}catch{}finally{Le=!1}}function Re(e){if(v)for(let t of Object.keys(e))so.has(t)&&(v[t]=e[t])}function Bt(){R(),document.removeEventListener("visibilitychange",It),window.removeEventListener("pagehide",Pt),x&&(clearTimeout(x),x=null)}function fo(){document.visibilityState==="hidden"&&R()}async function _e(e){let t=JSON.stringify(e),n=await mo(t,ce.compression);n&&Ut(n,0)}async function mo(e,t){let n=new TextEncoder().encode(e);if(n.byteLength>X)return null;if(t!=="off"){let r=await po(e);if(r&&r.byteLength<=X)return{beaconBody:new Blob([r],{type:io}),fetchBody:new Uint8Array(r),headers:{"Content-Type":se,"Content-Encoding":"gzip"}}}return{beaconBody:new Blob([n],{type:se}),fetchBody:e,headers:{"Content-Type":se}}}async function po(e){let t=globalThis.CompressionStream;if(typeof t!="function")return null;try{let n=ho(e);if(!n)return null;let o=new t("gzip"),i=n.pipeThrough(o).getReader(),c=[],s=0;for(;;){let f=await i.read();if(f.done)break;if(s+=f.value.byteLength,s>X)return null;let p=new Uint8Array(f.value.byteLength);p.set(f.value),c.push(p)}let a=new Uint8Array(s),u=0;for(let f of c)a.set(f,u),u+=f.byteLength;return a.buffer}catch{return null}}function ho(e){let t=new TextEncoder().encode(e),n=new Blob([t],{type:se});if(typeof n.stream=="function")return n.stream();let o=globalThis.ReadableStream;return typeof o!="function"?null:new o({start(r){r.enqueue(t),r.close()}})}function Ut(e,t){if(ae&&!(navigator.sendBeacon&&navigator.sendBeacon(ae,e.beaconBody)))try{fetch(ae,{method:"POST",body:e.fetchBody,headers:e.headers,keepalive:!0}).catch(()=>{t<ro&&setTimeout(()=>Ut(e,t+1),1e3*(t+1))})}catch{}}function go(e,t,n){let o=e.d??{},r=vo(e.t),i={type:r,ts:e.ts,page:typeof o.page=="string"?o.page.slice(0,2048):t},c=_t(o.el,o.element,o.target);if(r==="signal"){i.signal_type=_t(o.s,o.signal_type,o.name)?.slice(0,128),c&&(i.element=c.slice(0,2048));let a=c?bo(c,n):null;a&&(i.dom=a)}let s=wo(o);return Object.keys(s).length&&(i.metadata=s),i}function vo(e){return e==="pv"?"pageview":e==="sig"?"signal":ao.has(e)?e:"custom_signal"}function wo(e){let t=Object.create(null);for(let n of Object.keys(e)){if(["s","signal_type","name","el","element","target","dom","page","meta"].includes(n))continue;let o=ue(e[n],n);o!==void 0&&(t[n.slice(0,64)]=o)}if(e.meta&&typeof e.meta=="object"&&!Array.isArray(e.meta)){let n=ue(e.meta,"meta");n&&typeof n=="object"&&!Array.isArray(n)&&Object.assign(t,n)}return t}function ue(e,t="",n=0){if(!(n>4)&&!co.test(t)){if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string")return uo.test(e)?void 0:e.slice(0,500);if(Array.isArray(e))return e.slice(0,20).map(r=>ue(r,t,n+1)).filter(r=>r!==void 0);if(typeof e=="object"){let o=Object.create(null);for(let r of Object.keys(e).slice(0,40)){if(r==="__proto__"||r==="constructor"||r==="prototype")continue;let i=ue(e[r],r,n+1);i!==void 0&&(o[r.slice(0,64)]=i)}return o}}}function bo(e,t){if(t==="off")return null;try{let n=document.querySelector(e);return n?Lt(n,t):null}catch{return null}}function _t(...e){for(let t of e)if(typeof t=="string"&&t)return t}function yo(e){return e==="metadata"||e==="snapshot"?e:"off"}function Eo(e){return e==="off"?"off":"auto"}function Ht(e){let t=location.href;function n(){let s=location.href;s!==t&&(t=s,e(s,location.pathname))}let o=history.pushState,r=history.replaceState,i=function(...s){o.apply(this,s),n()},c=function(...s){r.apply(this,s),n()};return history.pushState=i,history.replaceState=c,window.addEventListener("popstate",n),window.addEventListener("hashchange",n),function(){history.pushState===i&&(history.pushState=o),history.replaceState===c&&(history.replaceState=r),window.removeEventListener("popstate",n),window.removeEventListener("hashchange",n)}}function De(e,t){for(let n of t){let o=To(n.pattern);if(o&&o.test(e))return n.label}return Mo(e)}var So=/^[a-zA-Z0-9/:._*\-]+$/;function To(e){if(e.length>200||!So.test(e))return null;let t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/:\w+/g,"[^/]+");try{return new RegExp("^"+t+"$")}catch{return null}}function Mo(e){return e.replace(/\/\d+/g,"/:id").replace(/\/[a-f0-9-]{36}/g,"/:id")}var Ao=[".carousel-arrow",".slick-arrow",".swiper-button-next",".swiper-button-prev","[data-carousel]",'button[aria-label*="next"]','button[aria-label*="prev"]','button[aria-label*="slide"]',".quantity-btn",".qty-btn",'input[type="number"]'],k=[],Ce=3,qt=2e3,zt=8,jt=[],Vt=d(xo);function Oe(e,t){Ce=e?.threshold??3,qt=e?.windowMs??2e3,jt=[...Ao,...t??[]],document.addEventListener("click",Vt,{capture:!0,passive:!0})}function Ne(){document.removeEventListener("click",Vt,{capture:!0,passive:!0}),k=[]}function xo(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||b(t,jt)||ko(t))return;let n=Date.now(),o=e.clientX,r=e.clientY;for(;k.length&&n-k[0].t>qt;)k.shift();if(k.push({t:n,x:o,y:r}),k.length<Ce)return;let i=k.slice(-Ce),c=i[0];for(let p=1;p<i.length;p++){let w=i[p],V=w.x-c.x,O=w.y-c.y;if(V*V+O*O>zt*zt)return}let s=c.t,u=(i[i.length-1].t-s)/1e3,f=u>0?i.length/u:i.length;l({t:"sig",ts:n,d:{s:"rage_click",el:m(t),cnt:i.length,vel:Math.round(f*10)/10}}),k=[]}function ko(e){let t=e.tagName;return!!(t==="VIDEO"||t==="AUDIO"||e.hasAttribute("ondblclick"))}var Lo=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,_o=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,Ro=/^(A|BUTTON|LABEL)$/,Yt=[],$=null,Do=5,Xt=d(Co),$t=d(Oo);function Co(e){$={x:e.clientX,y:e.clientY}}function Ie(e){Yt=e??[],document.addEventListener("mousedown",Xt,{capture:!0,passive:!0}),document.addEventListener("click",$t,{capture:!0,passive:!0})}function Pe(){document.removeEventListener("mousedown",Xt,{capture:!0}),document.removeEventListener("click",$t,{capture:!0}),$=null}function Oo(e){if(e.button!==0||e.detail===0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||b(t,Yt)||Po()||Fo(e)||No(t))return;let n=Io(t,e.clientX,e.clientY),o=n?Wt(e.clientX,e.clientY,n):-1;l({t:"sig",ts:Date.now(),d:{s:"dead_click",el:m(t),near:n?m(n):"",dist:Math.round(o)}})}function No(e){if(Lo.test(e.tagName))return!0;let t=e.getAttribute("role");if(t&&_o.test(t)||e.hasAttribute("contenteditable")||e.hasAttribute("tabindex")&&e.getAttribute("tabindex")!=="-1"||e.hasAttribute("onclick")||e.hasAttribute("onmousedown")||e.hasAttribute("onmouseup"))return!0;let n=e.parentElement;return!!(n&&Ro.test(n.tagName)||e.closest('a, button, [role="button"], label, [onclick]'))}function Io(e,t,n){let o=e;for(let r=0;r<5&&o;r++){let i=o.parentElement;if(!i)break;let c=i.querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]'),s=null,a=1/0;for(let u=0;u<c.length;u++){let f=c[u];if(!f||f===e)continue;let p=Wt(t,n,f);p<a&&(a=p,s=f)}if(s&&a<100)return s;o=i}return null}function Wt(e,t,n){let o=n.getBoundingClientRect(),r=Math.max(o.left,Math.min(e,o.right)),i=Math.max(o.top,Math.min(t,o.bottom)),c=e-r,s=t-i;return Math.sqrt(c*c+s*s)}function Po(){let e=window.getSelection();return e!==null&&e.toString().length>0}function Fo(e){if(!$)return!1;let t=e.clientX-$.x,n=e.clientY-$.y;return Math.sqrt(t*t+n*n)>Do}var h=null,Fe=3e3,Kt=[],Bo=/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/,Uo=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton)$/,Qt=d(Ho);function Be(e,t){Fe=e?.delayMs??3e3,Kt=t??[],document.addEventListener("click",Qt,{capture:!0,passive:!0})}function Ue(){document.removeEventListener("click",Qt,{capture:!0}),W()}function Ho(e){let t=e.target;if(!t||b(t,Kt))return;let n=t.getAttribute("role");if(!Bo.test(t.tagName)&&!(n&&Uo.test(n)))return;if(h){if(h.el===t||h.el.contains(t)){let a=Date.now()-h.ts;a>=Fe&&l({t:"sig",ts:Date.now(),d:{s:"speed_frustration",el:h.selector,delay:a}}),W();return}W()}let o=m(t),r=!1,i=new MutationObserver(a=>{for(let u of a){if(u.type==="childList"&&(u.addedNodes.length>0||u.removedNodes.length>0)){r=!0,W();return}if(u.type==="attributes"&&u.target instanceof Element&&(u.target===t||t.contains(u.target)||u.target.contains(t))){r=!0,W();return}}}),c=t.parentElement||document.body;i.observe(c,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-hidden","disabled"]});let s=setTimeout(()=>{!r&&h&&(h={...h,timeout:null})},Fe+500);h={el:t,selector:o,ts:Date.now(),observer:i,timeout:s}}function W(){h&&(h.observer.disconnect(),h.timeout&&clearTimeout(h.timeout),h=null)}var zo=100,Jt=800,Zt=2e3,qo=3,Gt=0,jo=16,le=0,de=0,K=0,Q=0,G=0,fe=0,He=0,D=[],I=null,en=d(Vo);function ze(e){Jt=e?.velocityThreshold??800,Zt=e?.windowMs??2e3,document.addEventListener("mousemove",en,{passive:!0})}function qe(){document.removeEventListener("mousemove",en),I&&clearTimeout(I),je()}function Vo(e){let t=Date.now();t-Gt<jo||(Gt=t,I&&clearTimeout(I),I=setTimeout(()=>je(),150),Yo(e.clientX,e.clientY,t))}function Yo(e,t,n){if(K===0){le=e,de=t,K=n,He=n;return}let o=(n-K)/1e3;if(o===0)return;let r=e-le,i=t-de;if(Math.abs(r)<2&&Math.abs(i)<2)return;let s=Math.sqrt(r*r+i*i)/o;D.length>=zo&&(D=D.slice(-50)),D.push(s);let a=Math.sign(r),u=Math.sign(i);if((Q!==0&&a!==0&&a!==Q||G!==0&&u!==0&&u!==G)&&fe++,Q=a||Q,G=u||G,le=e,de=t,K=n,n-He>Zt){if(fe>=qo){let f=D.reduce((p,w)=>p+w,0)/D.length;f>=Jt&&l({t:"sig",ts:n,d:{s:"thrash_cursor",vel:Math.round(f),rev:fe}})}je(),He=n}}function je(){fe=0,D=[],Q=0,G=0,K=0,le=0,de=0,I=null}var Xo=100,g=[],tn=3e4;function Ve(e){tn=e?.windowMs??3e4}function Ye(){g=[]}function Xe(e){let t=Date.now();try{let i=performance.getEntriesByType("navigation");if(i.length>0&&i[0].type==="back_forward")return}catch{}for(;g.length&&t-g[0].ts>tn;)g.shift();if(g.length>=Xo&&(g=g.slice(-50)),g.push({path:e,ts:t}),g.length<4)return;let n=e,o=!1,r=[];for(let i=0;i<g.length-1;i++)if(g[i].path===n){let c=g.slice(i,g.length),s=new Set(c.map(a=>a.path));if(s.size>=2){r.push(...Array.from(s)),o=!0;break}}o&&(l({t:"sig",ts:t,d:{s:"loop_nav",pages:r}}),g=[{path:e,ts:t}])}var $o=100,nn=1e4,Ke=.5,y=[],me=0,Qe=0,$e=!1,We=0,on=d(Wo);function Ge(e){nn=e?.windowMs??1e4,Ke=e?.depthThreshold??.5,window.addEventListener("scroll",on,{passive:!0})}function Je(){window.removeEventListener("scroll",on),y=[]}function Ze(){y=[],me=0,Qe=0}function Wo(){$e||($e=!0,requestAnimationFrame(()=>{$e=!1,Ko()}))}function Ko(){let e=Date.now(),t=window.scrollY;if(We=document.documentElement.scrollHeight-window.innerHeight,We<=0)return;let n=t/We,o=t>me?"down":"up";if(e-Qe<100){me=t;return}for(;y.length&&e-y[0].ts>nn;)y.shift();y.length>=$o&&(y=y.slice(-50)),y.push({depth:n,ts:e,direction:o}),me=t,Qe=e;let r=0,i=1,c=0,s=!1;for(let a=0;a<y.length;a++){let u=y[a].depth;u>r&&(r=u),u>=Ke&&(s=!0),s&&u<i&&(i=u),s&&i<.25&&u>=Ke&&(c++,s=!1,i=1)}c>=1&&(l({t:"sig",ts:e,d:{s:"scroll_bounce",depth:Math.round(r*100)/100,rev:c+1}}),y=[])}var Qo=["textarea",'[role="textbox"]',"[contenteditable]"],Z=new Map,L=new Set,C=null,et=0,rn=5e3,sn=[],an=d(Go),cn=d(Jo),un=d(Zo),ln=S(dn),J=null;function tt(e,t){rn=e?.pauseMs??5e3,sn=t??[],document.addEventListener("focusin",an,{capture:!0,passive:!0}),document.addEventListener("focusout",cn,{capture:!0,passive:!0}),document.addEventListener("submit",un,{capture:!0,passive:!0}),window.addEventListener("pagehide",ln),J=S(()=>{document.visibilityState==="hidden"&&dn()}),document.addEventListener("visibilitychange",J)}function nt(){document.removeEventListener("focusin",an,{capture:!0}),document.removeEventListener("focusout",cn,{capture:!0}),document.removeEventListener("submit",un,{capture:!0}),window.removeEventListener("pagehide",ln),J&&(document.removeEventListener("visibilitychange",J),J=null),Z.clear(),L.clear(),C=null}function ot(){Z.clear(),L.clear(),C=null,et=0}function Go(e){let t=e.target;if(!t||!fn(t)||b(t,sn)||er(t))return;Z.set(t,Date.now());let n=t.closest("form");n&&n!==C&&(C=n,et=n.querySelectorAll("input, select, textarea").length)}function Jo(e){let t=e.target;if(!t||!fn(t))return;let n=Z.get(t);if(Z.delete(t),n){let r=Date.now()-n;r>=rn&&l({t:"sig",ts:Date.now(),d:{s:"form_hesitation",el:m(t),pause:r}})}let o=t.getAttribute("name")||t.getAttribute("id")||m(t);tr(t)&&L.add(o)}function Zo(){L.clear(),C=null}function dn(){L.size>0&&C&&(l({t:"sig",ts:Date.now(),d:{s:"form_abandon",filled:L.size,total:et||L.size}}),L.clear(),C=null)}function fn(e){let t=e.tagName;return t==="INPUT"||t==="SELECT"||t==="TEXTAREA"}function er(e){if(e.tagName==="TEXTAREA")return!0;for(let t of Qo)try{if(e.matches(t))return!0}catch{return!1}return!1}function tr(e){return"value"in e?e.value.length>0:!1}var P=null,ee=null,mn=/flusterduck\.com|\/v1\/ingest/,hn=d(nr),gn=d(or);function rt(){window.addEventListener("error",hn),window.addEventListener("unhandledrejection",gn),rr()}function it(){window.removeEventListener("error",hn),window.removeEventListener("unhandledrejection",gn),ir()}function nr(e){l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"js_error",msg:st(e.message||"Unknown error",200),ep:"",status:0}})}function or(e){let t=e.reason instanceof Error?e.reason.message:String(e.reason??"");l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"unhandled_rejection",msg:st(t,200),ep:"",status:0}})}function rr(){P||(P=window.fetch,ee=function(t,n){let o;try{o=P.call(this,t,n)}catch(r){throw r}return o.then(r=>{try{if(r.status>=400){let i=typeof t=="string"?t:t instanceof URL?t.pathname:t.url;mn.test(i)||l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:`${r.status} ${r.statusText}`,ep:pn(i),status:r.status}})}}catch{}return r},r=>{try{let i=typeof t=="string"?t:t instanceof URL?t.href:t.url;mn.test(i)||l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:st(r instanceof Error?r.message:"Fetch failed",200),ep:typeof t=="string"?pn(t):"",status:0}})}catch{}throw r})},window.fetch=ee)}function ir(){P&&ee&&window.fetch===ee&&(window.fetch=P),P=null,ee=null}function pn(e){try{return new URL(e,location.origin).pathname}catch{let t=e.indexOf("?"),n=e.indexOf("#"),o=Math.min(t>=0?t:e.length,n>=0?n:e.length);return e.slice(0,o)||"/"}}function st(e,t){let n=e.length>t?e.slice(0,t):e;return n=n.replace(/(?:token|key|secret|password|auth|bearer|jwt|session|cookie|credential)[=:]\s*\S+/gi,"[REDACTED]"),n=n.replace(/https?:\/\/[^\s]*[?&][^\s]*/g,o=>{try{return new URL(o).origin+new URL(o).pathname}catch{return"[URL]"}}),n}var vn=[".carousel",".slider",".swiper","[data-swipeable]",".drawer"],sr=['[class*="map"]',"canvas",".gallery","[data-zoom]"],F=null,T=0,pe=0,te=0,wn=0,bn=null,yn=[],En=d(ar),Sn=d(cr),Tn=d(dr),Mn=d(mr),An=d(fr);function at(e){yn=e??[],document.addEventListener("touchstart",En,{passive:!0}),document.addEventListener("touchend",Sn,{passive:!0}),"ontouchstart"in window&&(document.addEventListener("gesturechange",Tn,{passive:!0}),window.addEventListener("orientationchange",Mn,{passive:!0})),window.visualViewport?.addEventListener("resize",An)}function ct(){document.removeEventListener("touchstart",En),document.removeEventListener("touchend",Sn),document.removeEventListener("gesturechange",Tn),window.removeEventListener("orientationchange",Mn),window.visualViewport?.removeEventListener("resize",An)}function ar(e){let t=e.touches[0];e.touches.length===1&&t&&(F={x:t.clientX,y:t.clientY,ts:Date.now()})}function cr(e){if(!F||e.changedTouches.length!==1)return;let t=e.changedTouches[0];if(!t)return;let n=t.clientX-F.x,o=t.clientY-F.y,r=Date.now()-F.ts,i=document.elementFromPoint(t.clientX,t.clientY);Math.abs(n)<10&&Math.abs(o)<10&&r<300&&i&&ur(i,t.clientX,t.clientY),r<500&&(Math.abs(n)>50||Math.abs(o)>50)&&lr(i,n,o),F=null}function ur(e,t,n){if(b(e,yn))return;let o=pr(e,t,n);if(!o)return;let r=o.getBoundingClientRect(),i=Math.max(r.left,Math.min(t,r.right)),c=Math.max(r.top,Math.min(n,r.bottom)),s=Math.sqrt((t-i)**2+(n-c)**2);if(s>0&&s<=20){let a=`${Math.round(r.width)}x${Math.round(r.height)}`;l({t:"sig",ts:Date.now(),d:{s:"tap_miss",el:m(o),dist:Math.round(s),size:a}})}}function lr(e,t,n){if(Math.abs(n)>Math.abs(t)||!e||vn.some(c=>{try{return e.matches(c)||e.closest(c)}catch{return!1}})||!vn.some(c=>{try{return document.querySelector(c)!==null}catch{return!1}}))return;let i=t>0?"right":"left";l({t:"sig",ts:Date.now(),d:{s:"swipe_miss",dir:i}})}function dr(){let e=Date.now();if(e-pe>3e4&&(T=0,pe=e),T++,T>=2){let t=document.activeElement||document.body;sr.some(o=>{try{return t.matches(o)||t.closest(o)}catch{return!1}})||l({t:"sig",ts:e,d:{s:"pinch_zoom",cnt:T}}),T=0}}function fr(){let e=window.visualViewport;if(e&&e.scale>1.1){let t=Date.now();t-pe>3e4&&(T=0,pe=t),T++,T>=2&&(l({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:T}}),T=0)}}function mr(){let e=Date.now(),t=screen.orientation?.type||"unknown";e-wn>3e4&&(te=0,wn=e),t!==bn&&(te++,bn=t),te>=3&&(l({t:"sig",ts:e,d:{s:"orientation_thrash",cnt:te}}),te=0)}function pr(e,t,n){let r=(e.parentElement||document.body).querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])'),i=null,c=21;for(let s=0;s<r.length;s++){let a=r[s];if(!a)continue;let u=a.getBoundingClientRect(),f=Math.max(u.left,Math.min(t,u.right)),p=Math.max(u.top,Math.min(n,u.bottom)),w=Math.sqrt((t-f)**2+(n-p)**2);w<c&&w>0&&(c=w,i=a)}return i}var E=[],B=null,A=0,ut=0,M=[],hr=10,gr=5e3,xn=5,vr=3e3,wr=15,br=5e3,kn=d(yr);function lt(){document.addEventListener("keydown",kn,{capture:!0,passive:!0})}function dt(){document.removeEventListener("keydown",kn,{capture:!0}),E=[],M=[],B=null}function yr(e){let t=Date.now(),n=e.target;n&&b(n,[])||(e.key==="Tab"?Er(t,n):e.key==="Escape"?Sr(t,e.target):(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight")&&Tr(t,e.target))}function Er(e,t){for(;E.length&&e-E[0].ts>gr;)E.shift();E.length>=50&&(E=E.slice(-25));let n=t?m(t):"";if(E.push({ts:e,el:n}),E.length>=hr){let r=E.map(i=>i.el).filter(Boolean);l({t:"sig",ts:e,d:{s:"tab_thrash",cnt:E.length,els:r}}),E=[]}if(!t)return;let o=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');o&&(o===B?e-ut<=vr?(A++,A>=xn&&(l({t:"sig",ts:e,d:{s:"focus_trap",container:m(o),attempts:A}}),A=0,B=null)):(ut=e,A=1):(B=o,ut=e,A=1))}function Sr(e,t){if(!t)return;let n=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');n&&n===B&&(A++,A>=xn&&(l({t:"sig",ts:e,d:{s:"focus_trap",container:m(n),attempts:A}}),A=0,B=null))}function Tr(e,t){if(!t)return;let n=t.closest('[role="listbox"]')||t.closest('[role="menu"]')||t.closest('[role="tree"]')||t.closest("select");if(!n)return;for(;M.length&&e-M[0].ts>br;)M.shift();M.length>=50&&(M=M.slice(-25)),M.push({ts:e,container:n});let o=M.filter(r=>r.container===n);o.length>=wr&&(l({t:"sig",ts:e,d:{s:"keyboard_nav_frustration",container:m(n),keys:o.length}}),M=[])}var U=0,he=0,ge=null,ft=0,ve=!1,Mr=4,Ar=3e3,Ln=d(xr);function mt(){window.addEventListener("scroll",Ln,{passive:!0})}function pt(){window.removeEventListener("scroll",Ln),U=0,he=0,ge=null,ft=0,ve=!1}function xr(){ve||(ve=!0,requestAnimationFrame(()=>{ve=!1,kr()}))}function kr(){let e=Date.now(),t=window.scrollY,n=t-he;if(Math.abs(n)<2){he=t;return}let o=n>0?"down":"up";ge&&o!==ge&&(e-ft>Ar&&(U=0,ft=e),U++,U>=Mr&&Math.abs(n)>100&&(l({t:"sig",ts:e,d:{s:"scroll_hijack",rev:U}}),U=0)),ge=o,he=t}var H=0,we=!1,_n=d(Lr),Rn=S(Dn),ne=null;function ht(){window.addEventListener("scroll",_n,{passive:!0}),window.addEventListener("pagehide",Rn),ne=S(()=>{document.visibilityState==="hidden"&&Dn()}),document.addEventListener("visibilitychange",ne)}function gt(){window.removeEventListener("scroll",_n),window.removeEventListener("pagehide",Rn),ne&&(document.removeEventListener("visibilitychange",ne),ne=null),H=0,we=!1}function vt(){H=0}function Lr(){we||(we=!0,requestAnimationFrame(()=>{we=!1;let e=document.documentElement.scrollHeight-window.innerHeight;if(e>0){let t=window.scrollY/e;t>H&&(H=t)}}))}function Dn(){H>.05&&l({t:"sig",ts:Date.now(),d:{s:"scroll_depth_abandon",depth:Math.round(H*100)/100}})}var Cn=1500,On=15e3,_r=5e3,Rr=.15,bt="",z=0,wt=0,oe=0,q=0,yt=0,be=null,ye=!1,Ee=d(Cr),Nn=d(Or),j=d(Dr);function Et(){ye||(ye=!0,yt=In(),re(),document.addEventListener("mouseenter",Ee,!0),document.addEventListener("mouseleave",Ee,!0),document.addEventListener("click",j,{capture:!0,passive:!0}),document.addEventListener("keydown",j,{capture:!0,passive:!0}),document.addEventListener("scroll",j,{passive:!0}),window.addEventListener("resize",Nn,{passive:!0}))}function St(){ye&&(ye=!1,document.removeEventListener("mouseenter",Ee,!0),document.removeEventListener("mouseleave",Ee,!0),document.removeEventListener("click",j,{capture:!0}),document.removeEventListener("keydown",j,{capture:!0}),document.removeEventListener("scroll",j),window.removeEventListener("resize",Nn),Pn(),bt="",z=0,q=0,oe=0)}function re(){Pn(),be=setTimeout(()=>{l({t:"sig",ts:Date.now(),d:{s:"user_confusion_idle",idle_ms:On}})},On)}function Dr(){re()}function Cr(e){let t=e.target;if(!t)return;let n=m(t),o=Date.now();(n!==bt||o-wt>Cn)&&(bt=n,wt=o,z=0),z+=1,!(z<4)&&(l({t:"sig",ts:o,d:{s:"thrash_hover",el:n,cnt:z,window_ms:Cn}}),z=0,wt=o)}function Or(){let e=Date.now(),t=In(),n=yt||t,o=Math.abs(t-n)/Math.max(n,1);yt=t,!(o<Rr)&&((!oe||e-oe>_r)&&(oe=e,q=0),q+=1,!(q<3)&&(l({t:"sig",ts:e,d:{s:"viewport_thrashing",cnt:q,area_delta:Math.round(o*1e3)/1e3}}),q=0,oe=e))}function In(){return Math.max(1,window.innerWidth*window.innerHeight)}function Pn(){be&&(clearTimeout(be),be=null)}var Nr="https://api.flusterduck.com/v1/ingest",_=!1,Se=null,ie=null;function Ir(e){if(e)try{let t=new URL(e),n=t.protocol==="http:"&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(t.hostname);return t.protocol!=="https:"&&!n?void 0:t.origin+t.pathname}catch{return}}function Tt(e){if(_||!e.key)return;if(e.key.startsWith("fd_sec_")){console.error("[flusterduck] Secret key detected in browser. Use a publishable key (fd_pub_) instead. Aborting.");return}if(!e.key.startsWith("fd_pub_"))return;if(e.respectDoNotTrack!==!1&&Pr()){ie=e;return}if(e.sampleRate!==void 0&&e.sampleRate<1&&Math.random()>e.sampleRate){ie=e;return}ie=e,_=!0;let t=At(e.cookieless??!1),n=Ir(e.endpoint)??Nr,o=De(location.pathname,e.pageRules??[]),r=Fr(e.domMode);Ft(n,{sid:t,key:e.key,url:location.origin+location.pathname,page:o,ua:navigator.userAgent.slice(0,200),vw:window.innerWidth,vh:window.innerHeight,segment:e.segment,environment:e.environment},e.batchInterval,e.batchMaxSize,{domMode:r,compression:e.compression});let i=document.referrer,c="";if(i)try{c=new URL(i).origin+new URL(i).pathname}catch{c=""}l({t:"pv",ts:Date.now(),d:{ref:c}});let s=e.ignoreElements??[],a=u=>e.signals?.[u]?.enabled!==!1;if(a("rageClick")&&Oe(e.signals?.rageClick,s),a("deadClick")&&Ie(s),a("speedFrustration")){let u=e.signals?.speedFrustration;Be(u?{delayMs:u.windowMs}:void 0,s)}if(e.trackMouse!==!1&&a("thrashCursor")&&ze(e.signals?.thrashCursor),a("loopNav")&&Ve(e.signals?.loopNav),a("scrollBounce")&&Ge(),e.trackForms!==!1&&(a("formHesitation")||a("formAbandon"))){let u=e.signals?.formHesitation;tt(u?{pauseMs:u.threshold}:void 0,s)}a("errorEncounter")&&rt(),("ontouchstart"in window||navigator.maxTouchPoints>0)&&at(s),(a("tabThrash")||a("focusTrap")||a("keyboardNavFrustration"))&&lt(),a("scrollHijack")&&mt(),a("scrollDepthAbandon")&&ht(),a("advancedHeuristics")&&Et(),Se=Ht(S((u,f)=>{R(),Ze(),ot(),vt(),re();let p=De(f,e.pageRules??[]);Re({page:p,url:u}),Xe(f),l({t:"pv",ts:Date.now(),d:{ref:""}})})),e.debug&&console.warn("[flusterduck] initialized",{sid:t.slice(0,6)+"...",endpoint:n,page:o})}function Fn(e,t){if(!_||typeof e!="string"||!e||e.length>128)return;let n;try{let r=t?.metadata??{};n=JSON.stringify(r)}catch{return}if(n.length>2048)return;let o=JSON.parse(n);l({t:"sig",ts:Date.now(),d:{s:e.slice(0,128),el:typeof t?.element=="string"?t.element.slice(0,256):"",meta:o,w:Math.max(0,Math.min(t?.weight??15,100))}})}function Bn(e,t={}){if(!_||typeof e!="string"||!/^[a-z0-9_.-]{1,120}$/i.test(e))return;let n;try{n=JSON.stringify(t??{})}catch{return}n.length>2048||l({t:"custom_signal",ts:Date.now(),d:{business_event:e.slice(0,120),meta:JSON.parse(n)}})}function Un(e){if(!_||!e||typeof e!="object")return;let t=Object.create(null),n=0;for(let o of Object.keys(e)){if(n>=20)break;o==="__proto__"||o==="constructor"||o==="prototype"||(t[o.slice(0,64)]=String(e[o]).slice(0,256),n++)}Re({segment:t})}function Hn(e){e&&ie&&!_?Tt(ie):e||(Te(),ke())}function zn(){Te(),ke()}function Te(){_&&(Ne(),Pe(),Ue(),qe(),Ye(),Je(),nt(),it(),ct(),dt(),pt(),gt(),St(),Bt(),Se&&(Se(),Se=null),_=!1)}function Pr(){return!!(navigator.doNotTrack==="1"||navigator.globalPrivacyControl)}function Fr(e){return e==="metadata"||e==="snapshot"?e:"off"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { init, signal, identify, setConsent, optOut, destroy } from './core';
1
+ export { init, signal, track, identify, setConsent, optOut, destroy } from './core';
2
2
  export type { Config, SDKEvent, SnapshotData } from './types';
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- function S(e){return(...t)=>{try{return e(...t)}catch{}}}function d(e){return t=>{try{e(t)}catch{}}}var de="_fd_s";var pn=/^[0-9a-f]{32}$/;function it(e){if(e)return rt();let t=hn(de);if(t&&pn.test(t))return t;let n=rt();return st(de,n,30),n}function fe(){st(de,"",-1)}function rt(){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 hn(e){let t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?.[1]?decodeURIComponent(t[1]):null}function st(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 gn=/^[:\d]|--|^(ember|react|ng-|__)/;function f(e){if(!e||e===document.documentElement)return"html";let t=e.getAttribute("data-fd");if(t)return`[data-fd="${q(t)}"]`;if(e.id&&!gn.test(e.id)&&e.id.length<64)return"#"+q(e.id);let n=[],o=e,r=0;for(;o&&o!==document.body&&r<5;){let i=o.tagName.toLowerCase(),a=o.getAttribute("name"),s=o.getAttribute("role"),c=o.getAttribute("type");a&&a.length<64?i+=`[name="${q(a)}"]`:s?i+=`[role="${q(s)}"]`:c&&(i==="input"||i==="button")&&(i+=`[type="${q(c)}"]`);let l=o.parentElement;if(l){let g=l.children,b=0,j=0;for(let O=0;O<g.length;O++){let ue=g[O];ue&&ue.tagName===o.tagName&&(b++,ue===o&&(j=b))}b>1&&(i+=`:nth-of-type(${j})`)}n.unshift(i);let h=n.join(" > ");try{if(document.querySelectorAll(h).length===1)return h}catch{}o=l,r++}return n.join(" > ")}function q(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):e.replace(/([^\w-])/g,"\\$1")}function w(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 ct(e,t){if(t==="off")return null;if(t==="metadata")return vn(e);let n=bn(e);return n?{mode:"snapshot",...n}:null}function vn(e){return{mode:"metadata",selector:f(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),attributes:{disabled:e.disabled===!0,required:e.required===!0,ariaDisabled:e.getAttribute("aria-disabled")==="true",ariaExpanded:at(e.getAttribute("aria-expanded"),["true","false"]),ariaInvalid:at(e.getAttribute("aria-invalid"),["true","false","grammar","spelling"]),type:wn(e)}}}function bn(e){try{let t=e.getBoundingClientRect(),n=getComputedStyle(e),o=e.parentElement,r=[];if(o)for(let a=0;a<o.children.length&&r.length<6;a++){let s=o.children[a];if(!s||s===e)continue;let c=s.getBoundingClientRect();r.push({selector:f(s),tag:s.tagName.toLowerCase(),box:{x:Math.round(c.x),y:Math.round(c.y),w:Math.round(c.width),h:Math.round(c.height)},interactive:yn(s)})}let i=[];try{let a=e.getAnimations();for(let s of a)"animationName"in s&&i.push(s.animationName)}catch{}return{selector:f(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),parent:o?f(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:En(t),animations:i,siblings:r}}catch{return null}}function at(e,t){return e&&t.includes(e)?e:null}function wn(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 En(e){return e.top<window.innerHeight&&e.bottom>0&&e.left<window.innerWidth&&e.right>0}function yn(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 ut=3e3,dt=50,ft=50,Sn=3,Mn=65536,N=[],A=null,Z="",mt=ut,pt=dt,v=null,pe={domMode:"off"},me=!1,Tn=new Set(["sid","key","url","page","ua","vw","vh","segment","environment"]),xn=new Set(["click","move","scroll","keyboard","form_focus","form_blur","form_submit","touch","navigation","error","signal","pageview","custom_signal","performance","visibility","sdk_error"]),An=/(?:value|text|label|email|e-mail|name|phone|address|password|token|secret|cookie|session|jwt|auth|credential|card|cc|cvv|ssn)/i,kn=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,ht=d(Ln),gt=S(()=>D());function vt(e,t,n,o,r){Z=e,v=Object.assign(Object.create(null),t),pe={domMode:On(r?.domMode)},mt=Math.max(1e3,Math.min(n??ut,3e4)),pt=Math.max(5,Math.min(o??dt,ft)),document.addEventListener("visibilitychange",ht),window.addEventListener("pagehide",gt)}function u(e){N.length>=ft||(N.push(e),N.length>=pt?D():A||(A=setTimeout(D,mt)))}function D(){if(me||!N.length||!v)return;me=!0,A&&(clearTimeout(A),A=null);let e=N;N=[];let t={v:1,sid:v.sid,key:v.key,url:v.url,page:v.page,ts:Date.now(),ua:v.ua,vw:v.vw,vh:v.vh,environment:v.environment,dom_mode:pe.domMode,events:e.map(n=>Dn(n,v.page,pe.domMode))};try{let n=JSON.stringify(t);n.length<=Mn&&wt(n,0)}catch{}me=!1}function he(e){if(v)for(let t of Object.keys(e))Tn.has(t)&&(v[t]=e[t])}function bt(){D(),document.removeEventListener("visibilitychange",ht),window.removeEventListener("pagehide",gt),A&&(clearTimeout(A),A=null)}function Ln(){document.visibilityState==="hidden"&&D()}function wt(e,t){if(Z){if(navigator.sendBeacon){let n=new Blob([e],{type:"application/json"});if(navigator.sendBeacon(Z,n))return}try{fetch(Z,{method:"POST",body:e,headers:{"Content-Type":"application/json"},keepalive:!0}).catch(()=>{t<Sn&&setTimeout(()=>wt(e,t+1),1e3*(t+1))})}catch{}}}function Dn(e,t,n){let o=e.d??{},r=Rn(e.t),i={type:r,ts:e.ts,page:typeof o.page=="string"?o.page.slice(0,2048):t},a=lt(o.el,o.element,o.target);if(r==="signal"){i.signal_type=lt(o.s,o.signal_type,o.name)?.slice(0,128),a&&(i.element=a.slice(0,2048));let c=a?Cn(a,n):null;c&&(i.dom=c)}let s=_n(o);return Object.keys(s).length&&(i.metadata=s),i}function Rn(e){return e==="pv"?"pageview":e==="sig"?"signal":xn.has(e)?e:"custom_signal"}function _n(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=J(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=J(e.meta,"meta");n&&typeof n=="object"&&!Array.isArray(n)&&Object.assign(t,n)}return t}function J(e,t="",n=0){if(!(n>4)&&!An.test(t)){if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string")return kn.test(e)?void 0:e.slice(0,500);if(Array.isArray(e))return e.slice(0,20).map(r=>J(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=J(e[r],r,n+1);i!==void 0&&(o[r.slice(0,64)]=i)}return o}}}function Cn(e,t){if(t==="off")return null;try{let n=document.querySelector(e);return n?ct(n,t):null}catch{return null}}function lt(...e){for(let t of e)if(typeof t=="string"&&t)return t}function On(e){return e==="metadata"||e==="snapshot"?e:"off"}function Et(e){let t=location.href;function n(){let s=location.href;s!==t&&(t=s,e(s,location.pathname))}let o=history.pushState,r=history.replaceState,i=function(...s){o.apply(this,s),n()},a=function(...s){r.apply(this,s),n()};return history.pushState=i,history.replaceState=a,window.addEventListener("popstate",n),window.addEventListener("hashchange",n),function(){history.pushState===i&&(history.pushState=o),history.replaceState===a&&(history.replaceState=r),window.removeEventListener("popstate",n),window.removeEventListener("hashchange",n)}}function ge(e,t){for(let n of t){let o=In(n.pattern);if(o&&o.test(e))return n.label}return Fn(e)}var Nn=/^[a-zA-Z0-9/:._*\-]+$/;function In(e){if(e.length>200||!Nn.test(e))return null;let t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/:\w+/g,"[^/]+");try{return new RegExp("^"+t+"$")}catch{return null}}function Fn(e){return e.replace(/\/\d+/g,"/:id").replace(/\/[a-f0-9-]{36}/g,"/:id")}var Pn=[".carousel-arrow",".slick-arrow",".swiper-button-next",".swiper-button-prev","[data-carousel]",'button[aria-label*="next"]','button[aria-label*="prev"]','button[aria-label*="slide"]',".quantity-btn",".qty-btn",'input[type="number"]'],k=[],ve=3,St=2e3,yt=8,Mt=[],Tt=d(Un);function be(e,t){ve=e?.threshold??3,St=e?.windowMs??2e3,Mt=[...Pn,...t??[]],document.addEventListener("click",Tt,{capture:!0,passive:!0})}function we(){document.removeEventListener("click",Tt,{capture:!0}),k=[]}function Un(e){let t=e.target;if(!t||w(t,Mt)||Hn(t))return;let n=Date.now(),o=e.clientX,r=e.clientY;for(;k.length&&n-k[0].t>St;)k.shift();if(k.push({t:n,x:o,y:r,el:t}),k.length<ve)return;let i=k.slice(-ve),a=i[0];for(let g=1;g<i.length;g++){let b=i[g],j=b.x-a.x,O=b.y-a.y;if(j*j+O*O>yt*yt)return}let s=a.t,l=(i[i.length-1].t-s)/1e3,h=l>0?i.length/l:i.length;u({t:"sig",ts:n,d:{s:"rage_click",el:f(t),cnt:i.length,vel:Math.round(h*10)/10}}),k=[]}function Hn(e){let t=e.tagName;return!!(t==="VIDEO"||t==="AUDIO"||e.hasAttribute("ondblclick"))}var jn=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,qn=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,Bn=/^(A|BUTTON|LABEL)$/,xt=[],B=null,Vn=5,At=d(Xn),kt=d(Yn);function Xn(e){B={x:e.clientX,y:e.clientY}}function Ee(e){xt=e??[],document.addEventListener("mousedown",At,{capture:!0,passive:!0}),document.addEventListener("click",kt,{capture:!0,passive:!0})}function ye(){document.removeEventListener("mousedown",At,{capture:!0}),document.removeEventListener("click",kt,{capture:!0}),B=null}function Yn(e){if(e.button!==0||e.detail===0)return;let t=e.target;if(!t||w(t,xt)||Kn()||Wn(e)||$n(t))return;let n=zn(t,e.clientX,e.clientY),o=n?Lt(e.clientX,e.clientY,n):-1;u({t:"sig",ts:Date.now(),d:{s:"dead_click",el:f(t),near:n?f(n):"",dist:Math.round(o)}})}function $n(e){if(jn.test(e.tagName))return!0;let t=e.getAttribute("role");if(t&&qn.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;if(n&&Bn.test(n.tagName)||e.closest('a, button, [role="button"], label, [onclick]'))return!0;try{if(getComputedStyle(e).cursor==="pointer")return!0}catch{return!1}return!1}function zn(e,t,n){let o=e.parentElement;if(!o)return null;let r=o.querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]'),i=null,a=1/0;for(let s=0;s<r.length;s++){let c=r[s];if(!c)continue;let l=Lt(t,n,c);l<a&&(a=l,i=c)}return i}function Lt(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)),a=e-r,s=t-i;return Math.sqrt(a*a+s*s)}function Kn(){let e=window.getSelection();return e!==null&&e.toString().length>0}function Wn(e){if(!B)return!1;let t=e.clientX-B.x,n=e.clientY-B.y;return Math.sqrt(t*t+n*n)>Vn}var m=null,Se=3e3,Dt=[],Qn=/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/,Gn=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton)$/,Rt=d(Zn);function Me(e,t){Se=e?.delayMs??3e3,Dt=t??[],document.addEventListener("click",Rt,{capture:!0,passive:!0})}function Te(){document.removeEventListener("click",Rt,{capture:!0}),V()}function Zn(e){let t=e.target;if(!t||w(t,Dt))return;let n=t.getAttribute("role");if(!Qn.test(t.tagName)&&!(n&&Gn.test(n)))return;if(m){if(m.el===t||m.el.contains(t)){let c=Date.now()-m.ts;c>=Se&&u({t:"sig",ts:Date.now(),d:{s:"speed_frustration",el:m.selector,delay:c}}),V();return}V()}let o=f(t),r=!1,i=new MutationObserver(c=>{for(let l of c){if(l.type==="childList"&&(l.addedNodes.length>0||l.removedNodes.length>0)){r=!0,V();return}if(l.type==="attributes"&&l.target instanceof Element&&(l.target===t||t.contains(l.target)||l.target.contains(t))){r=!0,V();return}}}),a=t.parentElement||document.body;i.observe(a,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-hidden","disabled"]});let s=setTimeout(()=>{!r&&m&&(m={...m,timeout:null})},Se+500);m={el:t,selector:o,ts:Date.now(),observer:i,timeout:s}}function V(){m&&(m.observer.disconnect(),m.timeout&&clearTimeout(m.timeout),m=null)}var Jn=100,Ct=800,Ot=2e3,eo=3,_t=0,to=50,ee=0,te=0,X=0,Y=0,$=0,ne=0,xe=0,R=[],Nt=d(no);function Ae(e){Ct=e?.velocityThreshold??800,Ot=e?.windowMs??2e3,document.addEventListener("mousemove",Nt,{passive:!0})}function ke(){document.removeEventListener("mousemove",Nt),It()}function no(e){let t=Date.now();t-_t<to||(_t=t,oo(e.clientX,e.clientY,t))}function oo(e,t,n){if(X===0){ee=e,te=t,X=n,xe=n;return}let o=(n-X)/1e3;if(o===0)return;let r=e-ee,i=t-te,s=Math.sqrt(r*r+i*i)/o;R.length>=Jn&&(R=R.slice(-50)),R.push(s);let c=Math.sign(r),l=Math.sign(i);if((Y!==0&&c!==0&&c!==Y||$!==0&&l!==0&&l!==$)&&ne++,Y=c||Y,$=l||$,ee=e,te=t,X=n,n-xe>Ot){if(ne>=eo){let h=R.reduce((g,b)=>g+b,0)/R.length;h>=Ct&&u({t:"sig",ts:n,d:{s:"thrash_cursor",vel:Math.round(h),rev:ne}})}It(),xe=n}}function It(){ne=0,R=[],Y=0,$=0,X=0,ee=0,te=0}var ro=100,p=[],Ft=3e4;function Le(e){Ft=e?.windowMs??3e4}function De(){p=[]}function Re(e){let t=Date.now();for(;p.length&&t-p[0].ts>Ft;)p.shift();if(p.length>=ro&&(p=p.slice(-50)),p.push({path:e,ts:t}),p.length<4)return;let n=e,o=!1,r=[];for(let i=p.length-2;i>=1;i--)if(p[i-1].path===n){let a=p.slice(i-1,p.length);for(let s of a)r.includes(s.path)||r.push(s.path);o=!0;break}o&&r.length>=2&&(u({t:"sig",ts:t,d:{s:"loop_nav",pages:r}}),p=[{path:e,ts:t}])}var io=100,Pt=1e4,Oe=.5,E=[],oe=0,Ne=0,_e=!1,Ce=0,Ut=d(so);function Ie(e){Pt=e?.windowMs??1e4,Oe=e?.depthThreshold??.5,window.addEventListener("scroll",Ut,{passive:!0})}function Fe(){window.removeEventListener("scroll",Ut),E=[]}function Pe(){E=[],oe=0,Ne=0}function so(){_e||(_e=!0,requestAnimationFrame(()=>{_e=!1,ao()}))}function ao(){let e=Date.now(),t=window.scrollY;if(Ce=document.documentElement.scrollHeight-window.innerHeight,Ce<=0)return;let n=t/Ce,o=t>oe?"down":"up";if(e-Ne<100){oe=t;return}for(;E.length&&e-E[0].ts>Pt;)E.shift();E.length>=io&&(E=E.slice(-50)),E.push({depth:n,ts:e,direction:o}),oe=t,Ne=e;let r=0,i=1,a=0,s=!1;for(let c=0;c<E.length;c++){let l=E[c].depth;l>r&&(r=l),l>=Oe&&(s=!0),s&&l<i&&(i=l),s&&i<.25&&l>=Oe&&(a++,s=!1,i=1)}a>=1&&(u({t:"sig",ts:e,d:{s:"scroll_bounce",depth:Math.round(r*100)/100,rev:a+1}}),E=[])}var co=["textarea",'[role="textbox"]',"[contenteditable]"],K=new Map,L=new Set,_=null,Ue=0,Ht=5e3,jt=[],qt=d(lo),Bt=d(uo),Vt=d(fo),Xt=S(Yt),z=null;function He(e,t){Ht=e?.pauseMs??5e3,jt=t??[],document.addEventListener("focusin",qt,{capture:!0,passive:!0}),document.addEventListener("focusout",Bt,{capture:!0,passive:!0}),document.addEventListener("submit",Vt,{capture:!0,passive:!0}),window.addEventListener("pagehide",Xt),z=S(()=>{document.visibilityState==="hidden"&&Yt()}),document.addEventListener("visibilitychange",z)}function je(){document.removeEventListener("focusin",qt,{capture:!0}),document.removeEventListener("focusout",Bt,{capture:!0}),document.removeEventListener("submit",Vt,{capture:!0}),window.removeEventListener("pagehide",Xt),z&&(document.removeEventListener("visibilitychange",z),z=null),K.clear(),L.clear(),_=null}function qe(){K.clear(),L.clear(),_=null,Ue=0}function lo(e){let t=e.target;if(!t||!$t(t)||w(t,jt)||mo(t))return;K.set(t,Date.now());let n=t.closest("form");n&&n!==_&&(_=n,Ue=n.querySelectorAll("input, select, textarea").length)}function uo(e){let t=e.target;if(!t||!$t(t))return;let n=K.get(t);if(K.delete(t),n){let r=Date.now()-n;r>=Ht&&u({t:"sig",ts:Date.now(),d:{s:"form_hesitation",el:f(t),pause:r}})}let o=t.getAttribute("name")||t.getAttribute("id")||f(t);po(t)&&L.add(o)}function fo(){L.clear(),_=null}function Yt(){L.size>0&&_&&(u({t:"sig",ts:Date.now(),d:{s:"form_abandon",filled:L.size,total:Ue||L.size}}),L.clear(),_=null)}function $t(e){let t=e.tagName;return t==="INPUT"||t==="SELECT"||t==="TEXTAREA"}function mo(e){if(e.tagName==="TEXTAREA")return!0;for(let t of co)try{if(e.matches(t))return!0}catch{return!1}return!1}function po(e){return"value"in e?e.value.length>0:!1}var I=null,W=null,zt=/flusterduck\.com|\/v1\/ingest/,Wt=d(ho),Qt=d(go);function Be(){window.addEventListener("error",Wt),window.addEventListener("unhandledrejection",Qt),vo()}function Ve(){window.removeEventListener("error",Wt),window.removeEventListener("unhandledrejection",Qt),bo()}function ho(e){u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"js_error",msg:Xe(e.message||"Unknown error",200),ep:"",status:0}})}function go(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:Xe(t,200),ep:"",status:0}})}function vo(){I||(I=window.fetch,W=function(t,n){let o;try{o=I.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;zt.test(i)||u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:`${r.status} ${r.statusText}`,ep:Kt(i),status:r.status}})}}catch{}return r},r=>{try{let i=typeof t=="string"?t:t instanceof URL?t.href:t.url;zt.test(i)||u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:Xe(r instanceof Error?r.message:"Fetch failed",200),ep:typeof t=="string"?Kt(t):"",status:0}})}catch{}throw r})},window.fetch=W)}function bo(){I&&W&&window.fetch===W&&(window.fetch=I),I=null,W=null}function Kt(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 Xe(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 Gt=[".carousel",".slider",".swiper","[data-swipeable]",".drawer"],wo=['[class*="map"]',"canvas",".gallery","[data-zoom]"],F=null,M=0,re=0,Q=0,Zt=0,Jt=null,en=[],tn=d(Eo),nn=d(yo),on=d(To),rn=d(Ao),sn=d(xo);function Ye(e){en=e??[],document.addEventListener("touchstart",tn,{passive:!0}),document.addEventListener("touchend",nn,{passive:!0}),"ontouchstart"in window&&(document.addEventListener("gesturechange",on,{passive:!0}),window.addEventListener("orientationchange",rn,{passive:!0})),window.visualViewport?.addEventListener("resize",sn)}function $e(){document.removeEventListener("touchstart",tn),document.removeEventListener("touchend",nn),document.removeEventListener("gesturechange",on),window.removeEventListener("orientationchange",rn),window.visualViewport?.removeEventListener("resize",sn)}function Eo(e){let t=e.touches[0];e.touches.length===1&&t&&(F={x:t.clientX,y:t.clientY,ts:Date.now()})}function yo(e){if(!F||e.changedTouches.length!==1)return;let t=e.changedTouches[0];if(!t)return;let n=t.clientX-F.x,o=t.clientY-F.y,r=Date.now()-F.ts,i=document.elementFromPoint(t.clientX,t.clientY);Math.abs(n)<10&&Math.abs(o)<10&&r<300&&i&&So(i,t.clientX,t.clientY),r<500&&(Math.abs(n)>50||Math.abs(o)>50)&&Mo(i,n,o),F=null}function So(e,t,n){if(w(e,en))return;let o=ko(e,t,n);if(!o)return;let r=o.getBoundingClientRect(),i=Math.max(r.left,Math.min(t,r.right)),a=Math.max(r.top,Math.min(n,r.bottom)),s=Math.sqrt((t-i)**2+(n-a)**2);if(s>0&&s<=20){let c=`${Math.round(r.width)}x${Math.round(r.height)}`;u({t:"sig",ts:Date.now(),d:{s:"tap_miss",el:f(o),dist:Math.round(s),size:c}})}}function Mo(e,t,n){if(Math.abs(n)>Math.abs(t)||!e||Gt.some(a=>{try{return e.matches(a)||e.closest(a)}catch{return!1}})||!Gt.some(a=>{try{return document.querySelector(a)!==null}catch{return!1}}))return;let i=t>0?"right":"left";u({t:"sig",ts:Date.now(),d:{s:"swipe_miss",dir:i}})}function To(){let e=Date.now();if(e-re>3e4&&(M=0,re=e),M++,M>=2){let t=document.activeElement||document.body;wo.some(o=>{try{return t.matches(o)||t.closest(o)}catch{return!1}})||u({t:"sig",ts:e,d:{s:"pinch_zoom",cnt:M}}),M=0}}function xo(){let e=window.visualViewport;if(e&&e.scale>1.1){let t=Date.now();t-re>3e4&&(M=0,re=t),M++,M>=2&&(u({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:M}}),M=0)}}function Ao(){let e=Date.now(),t=screen.orientation?.type||"unknown";e-Zt>3e4&&(Q=0,Zt=e),t!==Jt&&(Q++,Jt=t),Q>=3&&(u({t:"sig",ts:e,d:{s:"orientation_thrash",cnt:Q}}),Q=0)}function ko(e,t,n){let r=(e.parentElement||document.body).querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])'),i=null,a=21;for(let s=0;s<r.length;s++){let c=r[s];if(!c)continue;let l=c.getBoundingClientRect(),h=Math.max(l.left,Math.min(t,l.right)),g=Math.max(l.top,Math.min(n,l.bottom)),b=Math.sqrt((t-h)**2+(n-g)**2);b<a&&b>0&&(a=b,i=c)}return i}var y=[],P=null,x=0,ze=0,T=[],Lo=10,Do=5e3,an=5,Ro=3e3,_o=15,Co=5e3,cn=d(Oo);function Ke(){document.addEventListener("keydown",cn,{capture:!0,passive:!0})}function We(){document.removeEventListener("keydown",cn,{capture:!0}),y=[],T=[],P=null}function Oo(e){let t=Date.now(),n=e.target;n&&w(n,[])||(e.key==="Tab"?No(t,n):e.key==="Escape"?Io(t,e.target):(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight")&&Fo(t,e.target))}function No(e,t){for(;y.length&&e-y[0].ts>Do;)y.shift();y.length>=50&&(y=y.slice(-25));let n=t?f(t):"";if(y.push({ts:e,el:n}),y.length>=Lo){let r=y.map(i=>i.el).filter(Boolean);u({t:"sig",ts:e,d:{s:"tab_thrash",cnt:y.length,els:r}}),y=[]}if(!t)return;let o=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');o&&(o===P?e-ze<=Ro?(x++,x>=an&&(u({t:"sig",ts:e,d:{s:"focus_trap",container:f(o),attempts:x}}),x=0,P=null)):(ze=e,x=1):(P=o,ze=e,x=1))}function Io(e,t){if(!t)return;let n=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');n&&n===P&&(x++,x>=an&&(u({t:"sig",ts:e,d:{s:"focus_trap",container:f(n),attempts:x}}),x=0,P=null))}function Fo(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(;T.length&&e-T[0].ts>Co;)T.shift();T.length>=50&&(T=T.slice(-25)),T.push({ts:e,container:n});let o=T.filter(r=>r.container===n);o.length>=_o&&(u({t:"sig",ts:e,d:{s:"keyboard_nav_frustration",container:f(n),keys:o.length}}),T=[])}var U=0,ie=0,se=null,Qe=0,ae=!1,Po=4,Uo=3e3,ln=d(Ho);function Ge(){window.addEventListener("scroll",ln,{passive:!0})}function Ze(){window.removeEventListener("scroll",ln),U=0,ie=0,se=null,Qe=0,ae=!1}function Ho(){ae||(ae=!0,requestAnimationFrame(()=>{ae=!1,jo()}))}function jo(){let e=Date.now(),t=window.scrollY,n=t-ie;if(Math.abs(n)<2){ie=t;return}let o=n>0?"down":"up";se&&o!==se&&(e-Qe>Uo&&(U=0,Qe=e),U++,U>=Po&&Math.abs(n)>100&&(u({t:"sig",ts:e,d:{s:"scroll_hijack",rev:U}}),U=0)),se=o,ie=t}var H=0,ce=!1,un=d(qo),dn=S(fn),G=null;function Je(){window.addEventListener("scroll",un,{passive:!0}),window.addEventListener("pagehide",dn),G=S(()=>{document.visibilityState==="hidden"&&fn()}),document.addEventListener("visibilitychange",G)}function et(){window.removeEventListener("scroll",un),window.removeEventListener("pagehide",dn),G&&(document.removeEventListener("visibilitychange",G),G=null),H=0,ce=!1}function tt(){H=0}function qo(){ce||(ce=!0,requestAnimationFrame(()=>{ce=!1;let e=document.documentElement.scrollHeight-window.innerHeight;if(e>0){let t=window.scrollY/e;t>H&&(H=t)}}))}function fn(){H>.05&&u({t:"sig",ts:Date.now(),d:{s:"scroll_depth_abandon",depth:Math.round(H*100)/100}})}var Bo="https://api.flusterduck.com/v1/ingest",C=!1,le=null,nt=null;function Vo(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 mn(e){if(C||!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_")||e.respectDoNotTrack!==!1&&Ko()||e.sampleRate!==void 0&&e.sampleRate<1&&Math.random()>e.sampleRate)return;nt=e,C=!0;let t=it(e.cookieless??!1),n=Vo(e.endpoint)??Bo,o=ge(location.pathname,e.pageRules??[]),r=Wo(e.domMode);vt(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});let i=document.referrer,a="";if(i)try{a=new URL(i).origin+new URL(i).pathname}catch{a=""}u({t:"pv",ts:Date.now(),d:{ref:a}});let s=e.ignoreElements??[],c=l=>e.signals?.[l]?.enabled!==!1;if(c("rageClick")&&be(e.signals?.rageClick,s),c("deadClick")&&Ee(s),c("speedFrustration")){let l=e.signals?.speedFrustration;Me(l?{delayMs:l.windowMs}:void 0,s)}if(e.trackMouse!==!1&&c("thrashCursor")&&Ae(e.signals?.thrashCursor),c("loopNav")&&Le(e.signals?.loopNav),c("scrollBounce")&&Ie(),e.trackForms!==!1&&(c("formHesitation")||c("formAbandon"))){let l=e.signals?.formHesitation;He(l?{pauseMs:l.threshold}:void 0,s)}c("errorEncounter")&&Be(),("ontouchstart"in window||navigator.maxTouchPoints>0)&&Ye(s),(c("tabThrash")||c("focusTrap")||c("keyboardNavFrustration"))&&Ke(),c("scrollHijack")&&Ge(),c("scrollDepthAbandon")&&Je(),le=Et(S((l,h)=>{D(),Pe(),qe(),tt();let g=ge(h,e.pageRules??[]);he({page:g,url:l}),Re(h),u({t:"pv",ts:Date.now(),d:{ref:""}})})),e.debug&&console.warn("[flusterduck] initialized",{sid:t.slice(0,6)+"...",endpoint:n,page:o})}function Xo(e,t){if(!C||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);u({t:"sig",ts:Date.now(),d:{s:"custom",name: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 Yo(e){if(!C||!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++)}he({segment:t})}function $o(e){e&&nt&&!C?mn(nt):e||(ot(),fe())}function zo(){ot(),fe()}function ot(){C&&(we(),ye(),Te(),ke(),De(),Fe(),je(),Ve(),$e(),We(),Ze(),et(),bt(),le&&(le(),le=null),C=!1)}function Ko(){return!!(navigator.doNotTrack==="1"||navigator.globalPrivacyControl)}function Wo(e){return e==="metadata"||e==="snapshot"?e:"off"}export{ot as destroy,Yo as identify,mn as init,zo as optOut,$o as setConsent,Xo as signal};
1
+ function S(e){return((...t)=>{try{return e(...t)}catch{}})}function d(e){return t=>{try{e(t)}catch{}}}var Me="_fd_s";var Pn=/^[0-9a-f]{32}$/;function Tt(e){if(e)return St();let t=Fn(Me);if(t&&Pn.test(t))return t;let n=St();return Mt(Me,n,30),n}function Ae(){Mt(Me,"",-1)}function St(){let e=new Uint8Array(16);crypto.getRandomValues(e);let t="";for(let n of e)t+=n.toString(16).padStart(2,"0");return t}function Fn(e){let t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?.[1]?decodeURIComponent(t[1]):null}function Mt(e,t,n){let o=new Date;o.setTime(o.getTime()+n*864e5);let r=location.protocol==="https:"?";Secure":"";document.cookie=`${e}=${encodeURIComponent(t)};path=/;expires=${o.toUTCString()};SameSite=Lax${r}`}var Bn=/^[:\d]|--|^(ember|react|ng-|__)/;function m(e){if(!e||e===document.documentElement)return"html";let t=e.getAttribute("data-fd");if(t)return`[data-fd="${Y(t)}"]`;if(e.id&&!Bn.test(e.id)&&e.id.length<64)return"#"+Y(e.id);let n=[],o=e,r=0;for(;o&&o!==document.body&&r<5;){let i=o.tagName.toLowerCase(),c=o.getAttribute("name"),s=o.getAttribute("role"),a=o.getAttribute("type");c&&c.length<64?i+=`[name="${Y(c)}"]`:s?i+=`[role="${Y(s)}"]`:a&&(i==="input"||i==="button")&&(i+=`[type="${Y(a)}"]`);let u=o.parentElement;if(u){let p=u.children,w=0,V=0;for(let O=0;O<p.length;O++){let Te=p[O];Te&&Te.tagName===o.tagName&&(w++,Te===o&&(V=w))}w>1&&(i+=`:nth-of-type(${V})`)}n.unshift(i);let f=n.join(" > ");try{if(document.querySelectorAll(f).length===1)return f}catch{}o=u,r++}return n.join(" > ")}function Y(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):e.replace(/([^\w-])/g,"\\$1")}function b(e,t){if(e.hasAttribute("data-fd-ignore")||e.closest("[data-fd-ignore]"))return!0;for(let n of t)try{if(e.matches(n)||e.closest(n))return!0}catch{}return!1}function xt(e,t){if(t==="off")return null;if(t==="metadata")return Un(e);let n=Hn(e);return n?{mode:"snapshot",...n}:null}function Un(e){return{mode:"metadata",selector:m(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),attributes:{disabled:e.disabled===!0,required:e.required===!0,ariaDisabled:e.getAttribute("aria-disabled")==="true",ariaExpanded:At(e.getAttribute("aria-expanded"),["true","false"]),ariaInvalid:At(e.getAttribute("aria-invalid"),["true","false","grammar","spelling"]),type:zn(e)}}}function Hn(e){try{let t=e.getBoundingClientRect(),n=getComputedStyle(e),o=e.parentElement,r=[];if(o)for(let c=0;c<o.children.length&&r.length<6;c++){let s=o.children[c];if(!s||s===e)continue;let a=s.getBoundingClientRect();r.push({selector:m(s),tag:s.tagName.toLowerCase(),box:{x:Math.round(a.x),y:Math.round(a.y),w:Math.round(a.width),h:Math.round(a.height)},interactive:jn(s)})}let i=[];try{let c=e.getAnimations();for(let s of c)"animationName"in s&&i.push(s.animationName)}catch{}return{selector:m(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),parent:o?m(o):"",box:{x:Math.round(t.x),y:Math.round(t.y),w:Math.round(t.width),h:Math.round(t.height)},styles:{opacity:n.opacity,cursor:n.cursor,pointerEvents:n.pointerEvents,display:n.display,visibility:n.visibility,disabled:e.disabled===!0},inView:qn(t),animations:i,siblings:r}}catch{return null}}function At(e,t){return e&&t.includes(e)?e:null}function zn(e){let t=e.tagName.toLowerCase();if(t!=="input"&&t!=="button")return null;let n=e.getAttribute("type");return n&&/^[a-z0-9_-]{1,32}$/i.test(n)?n.toLowerCase():null}function qn(e){return e.top<window.innerHeight&&e.bottom>0&&e.left<window.innerWidth&&e.right>0}function jn(e){let t=e.tagName;if(/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/.test(t))return!0;let n=e.getAttribute("role");return!!(n&&/^(button|link|tab|menuitem|checkbox|radio)$/.test(n))}var Lt=7e3,Vn=5e3,Yn=1e4,_t=50,Rt=100,Xn=3,X=6e4,se="application/json",$n="application/json; encoding=gzip",N=[],x=null,ae="",Dt=Lt,Ct=_t,v=null,ce={domMode:"off",compression:"auto"},xe=!1,Wn=new Set(["sid","key","url","page","ua","vw","vh","segment","environment"]),Kn=new Set(["click","move","scroll","keyboard","form_focus","form_blur","form_submit","touch","navigation","error","signal","pageview","custom_signal","performance","visibility","sdk_error"]),Qn=/(?:value|text|label|email|e-mail|name|phone|address|password|token|secret|cookie|session|jwt|auth|credential|card|cc|cvv|ssn)/i,Gn=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,Ot=d(Zn),Nt=S(()=>R());function It(e,t,n,o,r){ae=e,v=Object.assign(Object.create(null),t),ce={domMode:ao(r?.domMode),compression:co(r?.compression)},Dt=Math.max(Vn,Math.min(n??Lt,Yn)),Ct=Math.max(5,Math.min(o??_t,Rt)),document.addEventListener("visibilitychange",Ot),window.addEventListener("pagehide",Nt)}function l(e){N.length>=Rt||(N.push(e),N.length>=Ct?R():x||(x=setTimeout(R,Dt)))}function R(){Jn()}async function Jn(){if(xe||!N.length||!v)return;xe=!0,x&&(clearTimeout(x),x=null);let e=N;N=[];let t={v:1,sid:v.sid,key:v.key,url:v.url,page:v.page,ts:Date.now(),ua:v.ua,vw:v.vw,vh:v.vh,environment:v.environment,dom_mode:ce.domMode},n=e.map(r=>oo(r,v.page,ce.domMode)),o=[];try{for(let r of n){let i=[...o,r];if(JSON.stringify({...t,events:i}).length>X)if(o.length>0)await ke({...t,events:o}),o=[r];else{let s={...t,events:[r]};JSON.stringify(s).length<=X&&await ke(s),o=[]}else o=i}o.length>0&&await ke({...t,events:o})}catch{}finally{xe=!1}}function Le(e){if(v)for(let t of Object.keys(e))Wn.has(t)&&(v[t]=e[t])}function Pt(){R(),document.removeEventListener("visibilitychange",Ot),window.removeEventListener("pagehide",Nt),x&&(clearTimeout(x),x=null)}function Zn(){document.visibilityState==="hidden"&&R()}async function ke(e){let t=JSON.stringify(e),n=await eo(t,ce.compression);n&&Ft(n,0)}async function eo(e,t){let n=new TextEncoder().encode(e);if(n.byteLength>X)return null;if(t!=="off"){let r=await to(e);if(r&&r.byteLength<=X)return{beaconBody:new Blob([r],{type:$n}),fetchBody:new Uint8Array(r),headers:{"Content-Type":se,"Content-Encoding":"gzip"}}}return{beaconBody:new Blob([n],{type:se}),fetchBody:e,headers:{"Content-Type":se}}}async function to(e){let t=globalThis.CompressionStream;if(typeof t!="function")return null;try{let n=no(e);if(!n)return null;let o=new t("gzip"),i=n.pipeThrough(o).getReader(),c=[],s=0;for(;;){let f=await i.read();if(f.done)break;if(s+=f.value.byteLength,s>X)return null;let p=new Uint8Array(f.value.byteLength);p.set(f.value),c.push(p)}let a=new Uint8Array(s),u=0;for(let f of c)a.set(f,u),u+=f.byteLength;return a.buffer}catch{return null}}function no(e){let t=new TextEncoder().encode(e),n=new Blob([t],{type:se});if(typeof n.stream=="function")return n.stream();let o=globalThis.ReadableStream;return typeof o!="function"?null:new o({start(r){r.enqueue(t),r.close()}})}function Ft(e,t){if(ae&&!(navigator.sendBeacon&&navigator.sendBeacon(ae,e.beaconBody)))try{fetch(ae,{method:"POST",body:e.fetchBody,headers:e.headers,keepalive:!0}).catch(()=>{t<Xn&&setTimeout(()=>Ft(e,t+1),1e3*(t+1))})}catch{}}function oo(e,t,n){let o=e.d??{},r=ro(e.t),i={type:r,ts:e.ts,page:typeof o.page=="string"?o.page.slice(0,2048):t},c=kt(o.el,o.element,o.target);if(r==="signal"){i.signal_type=kt(o.s,o.signal_type,o.name)?.slice(0,128),c&&(i.element=c.slice(0,2048));let a=c?so(c,n):null;a&&(i.dom=a)}let s=io(o);return Object.keys(s).length&&(i.metadata=s),i}function ro(e){return e==="pv"?"pageview":e==="sig"?"signal":Kn.has(e)?e:"custom_signal"}function io(e){let t=Object.create(null);for(let n of Object.keys(e)){if(["s","signal_type","name","el","element","target","dom","page","meta"].includes(n))continue;let o=ue(e[n],n);o!==void 0&&(t[n.slice(0,64)]=o)}if(e.meta&&typeof e.meta=="object"&&!Array.isArray(e.meta)){let n=ue(e.meta,"meta");n&&typeof n=="object"&&!Array.isArray(n)&&Object.assign(t,n)}return t}function ue(e,t="",n=0){if(!(n>4)&&!Qn.test(t)){if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string")return Gn.test(e)?void 0:e.slice(0,500);if(Array.isArray(e))return e.slice(0,20).map(r=>ue(r,t,n+1)).filter(r=>r!==void 0);if(typeof e=="object"){let o=Object.create(null);for(let r of Object.keys(e).slice(0,40)){if(r==="__proto__"||r==="constructor"||r==="prototype")continue;let i=ue(e[r],r,n+1);i!==void 0&&(o[r.slice(0,64)]=i)}return o}}}function so(e,t){if(t==="off")return null;try{let n=document.querySelector(e);return n?xt(n,t):null}catch{return null}}function kt(...e){for(let t of e)if(typeof t=="string"&&t)return t}function ao(e){return e==="metadata"||e==="snapshot"?e:"off"}function co(e){return e==="off"?"off":"auto"}function Bt(e){let t=location.href;function n(){let s=location.href;s!==t&&(t=s,e(s,location.pathname))}let o=history.pushState,r=history.replaceState,i=function(...s){o.apply(this,s),n()},c=function(...s){r.apply(this,s),n()};return history.pushState=i,history.replaceState=c,window.addEventListener("popstate",n),window.addEventListener("hashchange",n),function(){history.pushState===i&&(history.pushState=o),history.replaceState===c&&(history.replaceState=r),window.removeEventListener("popstate",n),window.removeEventListener("hashchange",n)}}function _e(e,t){for(let n of t){let o=lo(n.pattern);if(o&&o.test(e))return n.label}return fo(e)}var uo=/^[a-zA-Z0-9/:._*\-]+$/;function lo(e){if(e.length>200||!uo.test(e))return null;let t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/:\w+/g,"[^/]+");try{return new RegExp("^"+t+"$")}catch{return null}}function fo(e){return e.replace(/\/\d+/g,"/:id").replace(/\/[a-f0-9-]{36}/g,"/:id")}var mo=[".carousel-arrow",".slick-arrow",".swiper-button-next",".swiper-button-prev","[data-carousel]",'button[aria-label*="next"]','button[aria-label*="prev"]','button[aria-label*="slide"]',".quantity-btn",".qty-btn",'input[type="number"]'],k=[],Re=3,Ht=2e3,Ut=8,zt=[],qt=d(po);function De(e,t){Re=e?.threshold??3,Ht=e?.windowMs??2e3,zt=[...mo,...t??[]],document.addEventListener("click",qt,{capture:!0,passive:!0})}function Ce(){document.removeEventListener("click",qt,{capture:!0,passive:!0}),k=[]}function po(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||b(t,zt)||ho(t))return;let n=Date.now(),o=e.clientX,r=e.clientY;for(;k.length&&n-k[0].t>Ht;)k.shift();if(k.push({t:n,x:o,y:r}),k.length<Re)return;let i=k.slice(-Re),c=i[0];for(let p=1;p<i.length;p++){let w=i[p],V=w.x-c.x,O=w.y-c.y;if(V*V+O*O>Ut*Ut)return}let s=c.t,u=(i[i.length-1].t-s)/1e3,f=u>0?i.length/u:i.length;l({t:"sig",ts:n,d:{s:"rage_click",el:m(t),cnt:i.length,vel:Math.round(f*10)/10}}),k=[]}function ho(e){let t=e.tagName;return!!(t==="VIDEO"||t==="AUDIO"||e.hasAttribute("ondblclick"))}var go=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,vo=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,wo=/^(A|BUTTON|LABEL)$/,jt=[],$=null,bo=5,Vt=d(yo),Yt=d(Eo);function yo(e){$={x:e.clientX,y:e.clientY}}function Oe(e){jt=e??[],document.addEventListener("mousedown",Vt,{capture:!0,passive:!0}),document.addEventListener("click",Yt,{capture:!0,passive:!0})}function Ne(){document.removeEventListener("mousedown",Vt,{capture:!0}),document.removeEventListener("click",Yt,{capture:!0}),$=null}function Eo(e){if(e.button!==0||e.detail===0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||b(t,jt)||Mo()||Ao(e)||So(t))return;let n=To(t,e.clientX,e.clientY),o=n?Xt(e.clientX,e.clientY,n):-1;l({t:"sig",ts:Date.now(),d:{s:"dead_click",el:m(t),near:n?m(n):"",dist:Math.round(o)}})}function So(e){if(go.test(e.tagName))return!0;let t=e.getAttribute("role");if(t&&vo.test(t)||e.hasAttribute("contenteditable")||e.hasAttribute("tabindex")&&e.getAttribute("tabindex")!=="-1"||e.hasAttribute("onclick")||e.hasAttribute("onmousedown")||e.hasAttribute("onmouseup"))return!0;let n=e.parentElement;return!!(n&&wo.test(n.tagName)||e.closest('a, button, [role="button"], label, [onclick]'))}function To(e,t,n){let o=e;for(let r=0;r<5&&o;r++){let i=o.parentElement;if(!i)break;let c=i.querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]'),s=null,a=1/0;for(let u=0;u<c.length;u++){let f=c[u];if(!f||f===e)continue;let p=Xt(t,n,f);p<a&&(a=p,s=f)}if(s&&a<100)return s;o=i}return null}function Xt(e,t,n){let o=n.getBoundingClientRect(),r=Math.max(o.left,Math.min(e,o.right)),i=Math.max(o.top,Math.min(t,o.bottom)),c=e-r,s=t-i;return Math.sqrt(c*c+s*s)}function Mo(){let e=window.getSelection();return e!==null&&e.toString().length>0}function Ao(e){if(!$)return!1;let t=e.clientX-$.x,n=e.clientY-$.y;return Math.sqrt(t*t+n*n)>bo}var h=null,Ie=3e3,$t=[],xo=/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/,ko=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton)$/,Wt=d(Lo);function Pe(e,t){Ie=e?.delayMs??3e3,$t=t??[],document.addEventListener("click",Wt,{capture:!0,passive:!0})}function Fe(){document.removeEventListener("click",Wt,{capture:!0}),W()}function Lo(e){let t=e.target;if(!t||b(t,$t))return;let n=t.getAttribute("role");if(!xo.test(t.tagName)&&!(n&&ko.test(n)))return;if(h){if(h.el===t||h.el.contains(t)){let a=Date.now()-h.ts;a>=Ie&&l({t:"sig",ts:Date.now(),d:{s:"speed_frustration",el:h.selector,delay:a}}),W();return}W()}let o=m(t),r=!1,i=new MutationObserver(a=>{for(let u of a){if(u.type==="childList"&&(u.addedNodes.length>0||u.removedNodes.length>0)){r=!0,W();return}if(u.type==="attributes"&&u.target instanceof Element&&(u.target===t||t.contains(u.target)||u.target.contains(t))){r=!0,W();return}}}),c=t.parentElement||document.body;i.observe(c,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-hidden","disabled"]});let s=setTimeout(()=>{!r&&h&&(h={...h,timeout:null})},Ie+500);h={el:t,selector:o,ts:Date.now(),observer:i,timeout:s}}function W(){h&&(h.observer.disconnect(),h.timeout&&clearTimeout(h.timeout),h=null)}var _o=100,Qt=800,Gt=2e3,Ro=3,Kt=0,Do=16,le=0,de=0,K=0,Q=0,G=0,fe=0,Be=0,D=[],I=null,Jt=d(Co);function Ue(e){Qt=e?.velocityThreshold??800,Gt=e?.windowMs??2e3,document.addEventListener("mousemove",Jt,{passive:!0})}function He(){document.removeEventListener("mousemove",Jt),I&&clearTimeout(I),ze()}function Co(e){let t=Date.now();t-Kt<Do||(Kt=t,I&&clearTimeout(I),I=setTimeout(()=>ze(),150),Oo(e.clientX,e.clientY,t))}function Oo(e,t,n){if(K===0){le=e,de=t,K=n,Be=n;return}let o=(n-K)/1e3;if(o===0)return;let r=e-le,i=t-de;if(Math.abs(r)<2&&Math.abs(i)<2)return;let s=Math.sqrt(r*r+i*i)/o;D.length>=_o&&(D=D.slice(-50)),D.push(s);let a=Math.sign(r),u=Math.sign(i);if((Q!==0&&a!==0&&a!==Q||G!==0&&u!==0&&u!==G)&&fe++,Q=a||Q,G=u||G,le=e,de=t,K=n,n-Be>Gt){if(fe>=Ro){let f=D.reduce((p,w)=>p+w,0)/D.length;f>=Qt&&l({t:"sig",ts:n,d:{s:"thrash_cursor",vel:Math.round(f),rev:fe}})}ze(),Be=n}}function ze(){fe=0,D=[],Q=0,G=0,K=0,le=0,de=0,I=null}var No=100,g=[],Zt=3e4;function qe(e){Zt=e?.windowMs??3e4}function je(){g=[]}function Ve(e){let t=Date.now();try{let i=performance.getEntriesByType("navigation");if(i.length>0&&i[0].type==="back_forward")return}catch{}for(;g.length&&t-g[0].ts>Zt;)g.shift();if(g.length>=No&&(g=g.slice(-50)),g.push({path:e,ts:t}),g.length<4)return;let n=e,o=!1,r=[];for(let i=0;i<g.length-1;i++)if(g[i].path===n){let c=g.slice(i,g.length),s=new Set(c.map(a=>a.path));if(s.size>=2){r.push(...Array.from(s)),o=!0;break}}o&&(l({t:"sig",ts:t,d:{s:"loop_nav",pages:r}}),g=[{path:e,ts:t}])}var Io=100,en=1e4,$e=.5,y=[],me=0,We=0,Ye=!1,Xe=0,tn=d(Po);function Ke(e){en=e?.windowMs??1e4,$e=e?.depthThreshold??.5,window.addEventListener("scroll",tn,{passive:!0})}function Qe(){window.removeEventListener("scroll",tn),y=[]}function Ge(){y=[],me=0,We=0}function Po(){Ye||(Ye=!0,requestAnimationFrame(()=>{Ye=!1,Fo()}))}function Fo(){let e=Date.now(),t=window.scrollY;if(Xe=document.documentElement.scrollHeight-window.innerHeight,Xe<=0)return;let n=t/Xe,o=t>me?"down":"up";if(e-We<100){me=t;return}for(;y.length&&e-y[0].ts>en;)y.shift();y.length>=Io&&(y=y.slice(-50)),y.push({depth:n,ts:e,direction:o}),me=t,We=e;let r=0,i=1,c=0,s=!1;for(let a=0;a<y.length;a++){let u=y[a].depth;u>r&&(r=u),u>=$e&&(s=!0),s&&u<i&&(i=u),s&&i<.25&&u>=$e&&(c++,s=!1,i=1)}c>=1&&(l({t:"sig",ts:e,d:{s:"scroll_bounce",depth:Math.round(r*100)/100,rev:c+1}}),y=[])}var Bo=["textarea",'[role="textbox"]',"[contenteditable]"],Z=new Map,L=new Set,C=null,Je=0,nn=5e3,on=[],rn=d(Uo),sn=d(Ho),an=d(zo),cn=S(un),J=null;function Ze(e,t){nn=e?.pauseMs??5e3,on=t??[],document.addEventListener("focusin",rn,{capture:!0,passive:!0}),document.addEventListener("focusout",sn,{capture:!0,passive:!0}),document.addEventListener("submit",an,{capture:!0,passive:!0}),window.addEventListener("pagehide",cn),J=S(()=>{document.visibilityState==="hidden"&&un()}),document.addEventListener("visibilitychange",J)}function et(){document.removeEventListener("focusin",rn,{capture:!0}),document.removeEventListener("focusout",sn,{capture:!0}),document.removeEventListener("submit",an,{capture:!0}),window.removeEventListener("pagehide",cn),J&&(document.removeEventListener("visibilitychange",J),J=null),Z.clear(),L.clear(),C=null}function tt(){Z.clear(),L.clear(),C=null,Je=0}function Uo(e){let t=e.target;if(!t||!ln(t)||b(t,on)||qo(t))return;Z.set(t,Date.now());let n=t.closest("form");n&&n!==C&&(C=n,Je=n.querySelectorAll("input, select, textarea").length)}function Ho(e){let t=e.target;if(!t||!ln(t))return;let n=Z.get(t);if(Z.delete(t),n){let r=Date.now()-n;r>=nn&&l({t:"sig",ts:Date.now(),d:{s:"form_hesitation",el:m(t),pause:r}})}let o=t.getAttribute("name")||t.getAttribute("id")||m(t);jo(t)&&L.add(o)}function zo(){L.clear(),C=null}function un(){L.size>0&&C&&(l({t:"sig",ts:Date.now(),d:{s:"form_abandon",filled:L.size,total:Je||L.size}}),L.clear(),C=null)}function ln(e){let t=e.tagName;return t==="INPUT"||t==="SELECT"||t==="TEXTAREA"}function qo(e){if(e.tagName==="TEXTAREA")return!0;for(let t of Bo)try{if(e.matches(t))return!0}catch{return!1}return!1}function jo(e){return"value"in e?e.value.length>0:!1}var P=null,ee=null,dn=/flusterduck\.com|\/v1\/ingest/,mn=d(Vo),pn=d(Yo);function nt(){window.addEventListener("error",mn),window.addEventListener("unhandledrejection",pn),Xo()}function ot(){window.removeEventListener("error",mn),window.removeEventListener("unhandledrejection",pn),$o()}function Vo(e){l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"js_error",msg:rt(e.message||"Unknown error",200),ep:"",status:0}})}function Yo(e){let t=e.reason instanceof Error?e.reason.message:String(e.reason??"");l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"unhandled_rejection",msg:rt(t,200),ep:"",status:0}})}function Xo(){P||(P=window.fetch,ee=function(t,n){let o;try{o=P.call(this,t,n)}catch(r){throw r}return o.then(r=>{try{if(r.status>=400){let i=typeof t=="string"?t:t instanceof URL?t.pathname:t.url;dn.test(i)||l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:`${r.status} ${r.statusText}`,ep:fn(i),status:r.status}})}}catch{}return r},r=>{try{let i=typeof t=="string"?t:t instanceof URL?t.href:t.url;dn.test(i)||l({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:rt(r instanceof Error?r.message:"Fetch failed",200),ep:typeof t=="string"?fn(t):"",status:0}})}catch{}throw r})},window.fetch=ee)}function $o(){P&&ee&&window.fetch===ee&&(window.fetch=P),P=null,ee=null}function fn(e){try{return new URL(e,location.origin).pathname}catch{let t=e.indexOf("?"),n=e.indexOf("#"),o=Math.min(t>=0?t:e.length,n>=0?n:e.length);return e.slice(0,o)||"/"}}function rt(e,t){let n=e.length>t?e.slice(0,t):e;return n=n.replace(/(?:token|key|secret|password|auth|bearer|jwt|session|cookie|credential)[=:]\s*\S+/gi,"[REDACTED]"),n=n.replace(/https?:\/\/[^\s]*[?&][^\s]*/g,o=>{try{return new URL(o).origin+new URL(o).pathname}catch{return"[URL]"}}),n}var hn=[".carousel",".slider",".swiper","[data-swipeable]",".drawer"],Wo=['[class*="map"]',"canvas",".gallery","[data-zoom]"],F=null,T=0,pe=0,te=0,gn=0,vn=null,wn=[],bn=d(Ko),yn=d(Qo),En=d(Zo),Sn=d(tr),Tn=d(er);function it(e){wn=e??[],document.addEventListener("touchstart",bn,{passive:!0}),document.addEventListener("touchend",yn,{passive:!0}),"ontouchstart"in window&&(document.addEventListener("gesturechange",En,{passive:!0}),window.addEventListener("orientationchange",Sn,{passive:!0})),window.visualViewport?.addEventListener("resize",Tn)}function st(){document.removeEventListener("touchstart",bn),document.removeEventListener("touchend",yn),document.removeEventListener("gesturechange",En),window.removeEventListener("orientationchange",Sn),window.visualViewport?.removeEventListener("resize",Tn)}function Ko(e){let t=e.touches[0];e.touches.length===1&&t&&(F={x:t.clientX,y:t.clientY,ts:Date.now()})}function Qo(e){if(!F||e.changedTouches.length!==1)return;let t=e.changedTouches[0];if(!t)return;let n=t.clientX-F.x,o=t.clientY-F.y,r=Date.now()-F.ts,i=document.elementFromPoint(t.clientX,t.clientY);Math.abs(n)<10&&Math.abs(o)<10&&r<300&&i&&Go(i,t.clientX,t.clientY),r<500&&(Math.abs(n)>50||Math.abs(o)>50)&&Jo(i,n,o),F=null}function Go(e,t,n){if(b(e,wn))return;let o=nr(e,t,n);if(!o)return;let r=o.getBoundingClientRect(),i=Math.max(r.left,Math.min(t,r.right)),c=Math.max(r.top,Math.min(n,r.bottom)),s=Math.sqrt((t-i)**2+(n-c)**2);if(s>0&&s<=20){let a=`${Math.round(r.width)}x${Math.round(r.height)}`;l({t:"sig",ts:Date.now(),d:{s:"tap_miss",el:m(o),dist:Math.round(s),size:a}})}}function Jo(e,t,n){if(Math.abs(n)>Math.abs(t)||!e||hn.some(c=>{try{return e.matches(c)||e.closest(c)}catch{return!1}})||!hn.some(c=>{try{return document.querySelector(c)!==null}catch{return!1}}))return;let i=t>0?"right":"left";l({t:"sig",ts:Date.now(),d:{s:"swipe_miss",dir:i}})}function Zo(){let e=Date.now();if(e-pe>3e4&&(T=0,pe=e),T++,T>=2){let t=document.activeElement||document.body;Wo.some(o=>{try{return t.matches(o)||t.closest(o)}catch{return!1}})||l({t:"sig",ts:e,d:{s:"pinch_zoom",cnt:T}}),T=0}}function er(){let e=window.visualViewport;if(e&&e.scale>1.1){let t=Date.now();t-pe>3e4&&(T=0,pe=t),T++,T>=2&&(l({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:T}}),T=0)}}function tr(){let e=Date.now(),t=screen.orientation?.type||"unknown";e-gn>3e4&&(te=0,gn=e),t!==vn&&(te++,vn=t),te>=3&&(l({t:"sig",ts:e,d:{s:"orientation_thrash",cnt:te}}),te=0)}function nr(e,t,n){let r=(e.parentElement||document.body).querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])'),i=null,c=21;for(let s=0;s<r.length;s++){let a=r[s];if(!a)continue;let u=a.getBoundingClientRect(),f=Math.max(u.left,Math.min(t,u.right)),p=Math.max(u.top,Math.min(n,u.bottom)),w=Math.sqrt((t-f)**2+(n-p)**2);w<c&&w>0&&(c=w,i=a)}return i}var E=[],B=null,A=0,at=0,M=[],or=10,rr=5e3,Mn=5,ir=3e3,sr=15,ar=5e3,An=d(cr);function ct(){document.addEventListener("keydown",An,{capture:!0,passive:!0})}function ut(){document.removeEventListener("keydown",An,{capture:!0}),E=[],M=[],B=null}function cr(e){let t=Date.now(),n=e.target;n&&b(n,[])||(e.key==="Tab"?ur(t,n):e.key==="Escape"?lr(t,e.target):(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight")&&dr(t,e.target))}function ur(e,t){for(;E.length&&e-E[0].ts>rr;)E.shift();E.length>=50&&(E=E.slice(-25));let n=t?m(t):"";if(E.push({ts:e,el:n}),E.length>=or){let r=E.map(i=>i.el).filter(Boolean);l({t:"sig",ts:e,d:{s:"tab_thrash",cnt:E.length,els:r}}),E=[]}if(!t)return;let o=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');o&&(o===B?e-at<=ir?(A++,A>=Mn&&(l({t:"sig",ts:e,d:{s:"focus_trap",container:m(o),attempts:A}}),A=0,B=null)):(at=e,A=1):(B=o,at=e,A=1))}function lr(e,t){if(!t)return;let n=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');n&&n===B&&(A++,A>=Mn&&(l({t:"sig",ts:e,d:{s:"focus_trap",container:m(n),attempts:A}}),A=0,B=null))}function dr(e,t){if(!t)return;let n=t.closest('[role="listbox"]')||t.closest('[role="menu"]')||t.closest('[role="tree"]')||t.closest("select");if(!n)return;for(;M.length&&e-M[0].ts>ar;)M.shift();M.length>=50&&(M=M.slice(-25)),M.push({ts:e,container:n});let o=M.filter(r=>r.container===n);o.length>=sr&&(l({t:"sig",ts:e,d:{s:"keyboard_nav_frustration",container:m(n),keys:o.length}}),M=[])}var U=0,he=0,ge=null,lt=0,ve=!1,fr=4,mr=3e3,xn=d(pr);function dt(){window.addEventListener("scroll",xn,{passive:!0})}function ft(){window.removeEventListener("scroll",xn),U=0,he=0,ge=null,lt=0,ve=!1}function pr(){ve||(ve=!0,requestAnimationFrame(()=>{ve=!1,hr()}))}function hr(){let e=Date.now(),t=window.scrollY,n=t-he;if(Math.abs(n)<2){he=t;return}let o=n>0?"down":"up";ge&&o!==ge&&(e-lt>mr&&(U=0,lt=e),U++,U>=fr&&Math.abs(n)>100&&(l({t:"sig",ts:e,d:{s:"scroll_hijack",rev:U}}),U=0)),ge=o,he=t}var H=0,we=!1,kn=d(gr),Ln=S(_n),ne=null;function mt(){window.addEventListener("scroll",kn,{passive:!0}),window.addEventListener("pagehide",Ln),ne=S(()=>{document.visibilityState==="hidden"&&_n()}),document.addEventListener("visibilitychange",ne)}function pt(){window.removeEventListener("scroll",kn),window.removeEventListener("pagehide",Ln),ne&&(document.removeEventListener("visibilitychange",ne),ne=null),H=0,we=!1}function ht(){H=0}function gr(){we||(we=!0,requestAnimationFrame(()=>{we=!1;let e=document.documentElement.scrollHeight-window.innerHeight;if(e>0){let t=window.scrollY/e;t>H&&(H=t)}}))}function _n(){H>.05&&l({t:"sig",ts:Date.now(),d:{s:"scroll_depth_abandon",depth:Math.round(H*100)/100}})}var Rn=1500,Dn=15e3,vr=5e3,wr=.15,vt="",z=0,gt=0,oe=0,q=0,wt=0,be=null,ye=!1,Ee=d(yr),Cn=d(Er),j=d(br);function bt(){ye||(ye=!0,wt=On(),re(),document.addEventListener("mouseenter",Ee,!0),document.addEventListener("mouseleave",Ee,!0),document.addEventListener("click",j,{capture:!0,passive:!0}),document.addEventListener("keydown",j,{capture:!0,passive:!0}),document.addEventListener("scroll",j,{passive:!0}),window.addEventListener("resize",Cn,{passive:!0}))}function yt(){ye&&(ye=!1,document.removeEventListener("mouseenter",Ee,!0),document.removeEventListener("mouseleave",Ee,!0),document.removeEventListener("click",j,{capture:!0}),document.removeEventListener("keydown",j,{capture:!0}),document.removeEventListener("scroll",j),window.removeEventListener("resize",Cn),Nn(),vt="",z=0,q=0,oe=0)}function re(){Nn(),be=setTimeout(()=>{l({t:"sig",ts:Date.now(),d:{s:"user_confusion_idle",idle_ms:Dn}})},Dn)}function br(){re()}function yr(e){let t=e.target;if(!t)return;let n=m(t),o=Date.now();(n!==vt||o-gt>Rn)&&(vt=n,gt=o,z=0),z+=1,!(z<4)&&(l({t:"sig",ts:o,d:{s:"thrash_hover",el:n,cnt:z,window_ms:Rn}}),z=0,gt=o)}function Er(){let e=Date.now(),t=On(),n=wt||t,o=Math.abs(t-n)/Math.max(n,1);wt=t,!(o<wr)&&((!oe||e-oe>vr)&&(oe=e,q=0),q+=1,!(q<3)&&(l({t:"sig",ts:e,d:{s:"viewport_thrashing",cnt:q,area_delta:Math.round(o*1e3)/1e3}}),q=0,oe=e))}function On(){return Math.max(1,window.innerWidth*window.innerHeight)}function Nn(){be&&(clearTimeout(be),be=null)}var Sr="https://api.flusterduck.com/v1/ingest",_=!1,Se=null,ie=null;function Tr(e){if(e)try{let t=new URL(e),n=t.protocol==="http:"&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(t.hostname);return t.protocol!=="https:"&&!n?void 0:t.origin+t.pathname}catch{return}}function In(e){if(_||!e.key)return;if(e.key.startsWith("fd_sec_")){console.error("[flusterduck] Secret key detected in browser. Use a publishable key (fd_pub_) instead. Aborting.");return}if(!e.key.startsWith("fd_pub_"))return;if(e.respectDoNotTrack!==!1&&_r()){ie=e;return}if(e.sampleRate!==void 0&&e.sampleRate<1&&Math.random()>e.sampleRate){ie=e;return}ie=e,_=!0;let t=Tt(e.cookieless??!1),n=Tr(e.endpoint)??Sr,o=_e(location.pathname,e.pageRules??[]),r=Rr(e.domMode);It(n,{sid:t,key:e.key,url:location.origin+location.pathname,page:o,ua:navigator.userAgent.slice(0,200),vw:window.innerWidth,vh:window.innerHeight,segment:e.segment,environment:e.environment},e.batchInterval,e.batchMaxSize,{domMode:r,compression:e.compression});let i=document.referrer,c="";if(i)try{c=new URL(i).origin+new URL(i).pathname}catch{c=""}l({t:"pv",ts:Date.now(),d:{ref:c}});let s=e.ignoreElements??[],a=u=>e.signals?.[u]?.enabled!==!1;if(a("rageClick")&&De(e.signals?.rageClick,s),a("deadClick")&&Oe(s),a("speedFrustration")){let u=e.signals?.speedFrustration;Pe(u?{delayMs:u.windowMs}:void 0,s)}if(e.trackMouse!==!1&&a("thrashCursor")&&Ue(e.signals?.thrashCursor),a("loopNav")&&qe(e.signals?.loopNav),a("scrollBounce")&&Ke(),e.trackForms!==!1&&(a("formHesitation")||a("formAbandon"))){let u=e.signals?.formHesitation;Ze(u?{pauseMs:u.threshold}:void 0,s)}a("errorEncounter")&&nt(),("ontouchstart"in window||navigator.maxTouchPoints>0)&&it(s),(a("tabThrash")||a("focusTrap")||a("keyboardNavFrustration"))&&ct(),a("scrollHijack")&&dt(),a("scrollDepthAbandon")&&mt(),a("advancedHeuristics")&&bt(),Se=Bt(S((u,f)=>{R(),Ge(),tt(),ht(),re();let p=_e(f,e.pageRules??[]);Le({page:p,url:u}),Ve(f),l({t:"pv",ts:Date.now(),d:{ref:""}})})),e.debug&&console.warn("[flusterduck] initialized",{sid:t.slice(0,6)+"...",endpoint:n,page:o})}function Mr(e,t){if(!_||typeof e!="string"||!e||e.length>128)return;let n;try{let r=t?.metadata??{};n=JSON.stringify(r)}catch{return}if(n.length>2048)return;let o=JSON.parse(n);l({t:"sig",ts:Date.now(),d:{s:e.slice(0,128),el:typeof t?.element=="string"?t.element.slice(0,256):"",meta:o,w:Math.max(0,Math.min(t?.weight??15,100))}})}function Ar(e,t={}){if(!_||typeof e!="string"||!/^[a-z0-9_.-]{1,120}$/i.test(e))return;let n;try{n=JSON.stringify(t??{})}catch{return}n.length>2048||l({t:"custom_signal",ts:Date.now(),d:{business_event:e.slice(0,120),meta:JSON.parse(n)}})}function xr(e){if(!_||!e||typeof e!="object")return;let t=Object.create(null),n=0;for(let o of Object.keys(e)){if(n>=20)break;o==="__proto__"||o==="constructor"||o==="prototype"||(t[o.slice(0,64)]=String(e[o]).slice(0,256),n++)}Le({segment:t})}function kr(e){e&&ie&&!_?In(ie):e||(Et(),Ae())}function Lr(){Et(),Ae()}function Et(){_&&(Ce(),Ne(),Fe(),He(),je(),Qe(),et(),ot(),st(),ut(),ft(),pt(),yt(),Pt(),Se&&(Se(),Se=null),_=!1)}function _r(){return!!(navigator.doNotTrack==="1"||navigator.globalPrivacyControl)}function Rr(e){return e==="metadata"||e==="snapshot"?e:"off"}export{Et as destroy,xr as identify,In as init,Lr as optOut,kr as setConsent,Mr as signal,Ar as track};
@@ -0,0 +1,3 @@
1
+ export declare function initAdvancedSignals(): void;
2
+ export declare function destroyAdvancedSignals(): void;
3
+ export declare function resetAdvancedSignals(): void;
@@ -10,3 +10,4 @@ export { initMobileSignals, destroyMobileSignals } from './mobile-signals';
10
10
  export { initKeyboardSignals, destroyKeyboardSignals, } from './keyboard-signals';
11
11
  export { initScrollHijack, destroyScrollHijack } from './scroll-hijack';
12
12
  export { initScrollDepthAbandon, destroyScrollDepthAbandon, resetScrollDepthAbandon, } from './scroll-depth-abandon';
13
+ export { initAdvancedSignals, destroyAdvancedSignals, resetAdvancedSignals, } from './advanced-signals';
package/dist/types.d.ts CHANGED
@@ -17,6 +17,7 @@ export interface Config {
17
17
  debug?: boolean;
18
18
  batchInterval?: number;
19
19
  batchMaxSize?: number;
20
+ compression?: CompressionMode;
20
21
  ignoreElements?: string[];
21
22
  ignorePages?: string[];
22
23
  }
@@ -31,6 +32,7 @@ export interface SDKEvent {
31
32
  d?: Record<string, unknown>;
32
33
  }
33
34
  export type DOMMode = 'off' | 'metadata' | 'snapshot';
35
+ export type CompressionMode = 'auto' | 'off';
34
36
  export interface Batch {
35
37
  v: 1;
36
38
  sid: string;
@@ -58,6 +60,7 @@ export interface QueueMeta {
58
60
  }
59
61
  export interface QueueOptions {
60
62
  domMode?: DOMMode;
63
+ compression?: CompressionMode;
61
64
  }
62
65
  export interface IngestEvent {
63
66
  type: string;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "flusterduck",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Lightweight UX confusion monitoring SDK",
5
- "license": "UNLICENSED",
5
+ "license": "SEE LICENSE IN LICENSE.md",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.mjs",
@@ -19,18 +19,19 @@
19
19
  "jsdelivr": "dist/d.global.js",
20
20
  "sideEffects": false,
21
21
  "files": [
22
- "dist"
22
+ "dist",
23
+ "LICENSE.md"
23
24
  ],
24
25
  "publishConfig": {
25
26
  "access": "public"
26
27
  },
27
28
  "devDependencies": {
28
- "esbuild": "0.24.2",
29
+ "esbuild": "0.28.0",
30
+ "jsdom": "25.0.1",
29
31
  "terser": "5.46.1",
30
32
  "typescript": "5.9.3",
31
- "vitest": "2.1.9",
32
- "jsdom": "25.0.1",
33
- "@flusterduck/tsconfig": "0.0.0"
33
+ "vitest": "4.1.8",
34
+ "@flusterduck/tsconfig": "0.2.0"
34
35
  },
35
36
  "scripts": {
36
37
  "build": "node build.mjs",