blocfeed 0.20.0 → 0.22.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/CHANGELOG.md CHANGED
@@ -1,5 +1,80 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.22.0 — 2026-05-07
4
+
5
+ ### New: hosted feedback iframe for non-React stacks
6
+
7
+ Script-tag installs can now render the full BlocFeed feedback panel
8
+ without bundling React. Add data-feedback="true" and a floating trigger
9
+ button appears; clicking it opens the panel hosted at
10
+ https://blocfeed.com/embed/<blocfeed_id>.
11
+
12
+ <script async
13
+ src="https://cdn.jsdelivr.net/npm/blocfeed@0/dist/script.js"
14
+ data-blocfeed-id="bf_xxx"
15
+ data-feedback="true"></script>
16
+
17
+ Customizable via data-feedback-color, data-feedback-label,
18
+ data-feedback-position. data-embed-origin overrides the default
19
+ https://blocfeed.com host (useful for self-hosted deployments and
20
+ local dev).
21
+
22
+ The parent script bridges screenshot capture for the iframe via
23
+ postMessage, dynamically importing html-to-image only when a screenshot
24
+ is actually requested. Voice feedback uses getUserMedia inside the
25
+ iframe (browser prompts for microphone access against blocfeed.com).
26
+
27
+ Element picker, video recording, and behavioral signal annotation
28
+ remain React-only — use blocfeed/passive or the React widget for those.
29
+
30
+ Customers who want to react to a successful submission (custom toast,
31
+ analytics call, etc.) can listen for the
32
+ `blocfeed-embed/submit-success` postMessage themselves; the parent
33
+ script only logs to the console in v1.
34
+
35
+ ---
36
+
37
+ ## 0.21.0 — 2026-05-07
38
+
39
+ ### New: tracking-only modes for non-React stacks
40
+
41
+ Two new ways to install BlocFeed when you only want session replay,
42
+ behavioral signals, and custom events — no feedback panel UI:
43
+
44
+ - **`blocfeed/passive` subpath export.** Import `<BlocFeedPassive />` (a
45
+ React component that renders nothing and installs the tracker on mount)
46
+ or `BlocFeed.init({...})` (vanilla JS, no React required). Tree-shakes
47
+ cleanly so the feedback panel and `framer-motion` don't reach the
48
+ customer's bundle.
49
+
50
+ - **IIFE script-tag bundle (`dist/script.js`, 65 KB gzipped).** Drop into
51
+ PHP, WordPress, Webflow, or any vanilla HTML page with one tag. All
52
+ configuration via `data-*` attributes; exposes `window.BlocFeed` for
53
+ runtime `track()` / `identify()` calls. Distributed via jsDelivr at
54
+ `https://cdn.jsdelivr.net/npm/blocfeed@0/dist/script.js`.
55
+
56
+ ```html
57
+ <script async
58
+ src="https://cdn.jsdelivr.net/npm/blocfeed@0/dist/script.js"
59
+ data-blocfeed-id="bf_xxx"
60
+ data-user-id="123"></script>
61
+ ```
62
+
63
+ Available data attributes: `data-blocfeed-id` (required),
64
+ `data-user-id`, `data-user-email`, `data-user-name`, `data-replay`,
65
+ `data-signals`, `data-mask` (`inputs` / `text` / `none`), `data-sample`
66
+ (0..1), `data-track-clicks`.
67
+
68
+ - Heartbeats from script-tag installs include `"script-tag"` in
69
+ `sdk_features` so the dashboard can distinguish them from React imports.
70
+
71
+ ### Internal
72
+
73
+ - `BehavioralTracker` accepts a new `extraSdkFeatures: string[]` option
74
+ used internally to tag the deployment surface in heartbeats.
75
+
76
+ ---
77
+
3
78
  ## 0.20.0 — 2026-05-07
4
79
 
5
80
  ### Signal accuracy
@@ -1,4 +1,4 @@
1
- 'use strict';var react=require('react'),rrweb=require('rrweb'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),framerMotion=require('framer-motion');function T(){return typeof window<"u"&&typeof document<"u"}function Wt(e){let t=globalThis.CSS;return typeof t?.escape=="function"?t.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>{let o=n.codePointAt(0);return o===void 0?"":`\\${o.toString(16)} `})}function Ce(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Ho(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function Uo(e){return e.replace(/\s+/g," ").trim()}function re(e,t=140){let n=e.textContent;if(!n)return;let o=Uo(n);if(o)return o.length<=t?o:`${o.slice(0,t-1)}\u2026`}function zo(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var ut=["data-testid","data-test-id","data-test","data-qa","data-cy"],dt="data-blocfeed-component";function le(e){let t=e.closest(`[${dt}]`);if(!t)return;let o=t.getAttribute(dt)?.trim();return o||void 0}function we(e,t=5){let n=[],o=e,r=0;for(;o&&r<t*4;){let i=le(o);if(i&&n[n.length-1]!==i&&(n.push(i),n.length>=t))break;o=o.parentElement,r++;}return n}function xe(e,t=4){let n=e,o=0;for(;n&&o<t;){let i=n.getAttribute(dt)?.trim();if(i)return `bf:component:${i}`;for(let a of ut){let m=n.getAttribute(a)?.trim();if(m)return `bf:testid:${m}`}let s=n.getAttribute("id")?.trim();if(s&&!/^\d/.test(s))return `bf:id:${s}`;n=n.parentElement,o+=1;}return null}function Vo(e){for(let t of ut){let n=e.closest(`[${t}]`);if(!n)continue;let r=n.getAttribute(t)?.trim();if(r)return r}}function qt(e){try{let t=e,n=Object.getOwnPropertyNames(t);for(let o of n)if(o.startsWith("__reactFiber$")||o.startsWith("__reactInternalInstance$")){let r=t[o];if(r&&typeof r=="object")return r}}catch{}return null}function pe(e){if(e.length<=1||e.length===2&&e[0]===e[0].toLowerCase()||e.startsWith("__")&&e.endsWith("__"))return true;let t=e[0];return t>="a"&&t<="z"}function Te(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!pe(t.name))return t.name}}function X(e){if(e&&typeof e!="string"){if(typeof e=="function"){let t=e;return typeof t.displayName=="string"&&t.displayName?t.displayName:typeof t.name=="string"&&t.name?t.name:void 0}if(typeof e=="object"){let t=e,n=t.displayName;if(typeof n=="string"&&n)return n;let o=t.render;if(typeof o=="function"){let i=o;if(typeof i.displayName=="string"&&i.displayName)return i.displayName;if(typeof i.name=="string"&&i.name)return i.name}let r=t.type;return X(r)}}}function ft(e){let t=qt(e);if(!t)return;let n=Te(t._debugInfo);if(n)return n;let o=t._debugOwner!==void 0;if(o){let a=t._debugOwner;for(let l=0;a&&l<50;l+=1){let m=Te(a._debugInfo);if(m)return m;let b=X(a.type)??X(a.elementType);if(b&&!pe(b))return b;a=a._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let a=t._owner;for(let l=0;a&&l<50;l+=1){let m=Te(a._debugInfo);if(m)return m;let b=X(a.type)??X(a.elementType);if(b&&!pe(b))return b;a=a._owner;}}let i=t,c=o?80:25;for(let a=0;i&&a<c;a+=1){let l=Te(i._debugInfo);if(l)return l;let m=X(i.type)??X(i.elementType);if(m&&!pe(m))return m;i=i.return;}let s=e.parentElement;for(let a=0;s&&a<15;a+=1){let l=qt(s);if(l){let m=Te(l._debugInfo);if(m)return m;let b=X(l.type)??X(l.elementType);if(b&&!pe(b))return b;if(l._debugOwner){let d=X(l._debugOwner.type)??X(l._debugOwner.elementType);if(d&&!pe(d))return d}if(l._owner&&l._owner!==l._debugOwner){let d=X(l._owner.type)??X(l._owner.elementType);if(d&&!pe(d))return d}}s=s.parentElement;}}function Wo(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${Wt(n)}`;for(let o of ut){let r=e.getAttribute(o);if(r)return `${t}[${o}="${Wt(r)}"]`}return `${t}:nth-of-type(${zo(e)})`}function me(e,t=10){let n=[],o=e;for(;o&&n.length<t;){let r=Wo(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}var qo=new Set(["button","link","tab","menuitem"]);function Kt(e){if(e.tagName==="BUTTON")return e.disabled?null:"button";if(e.tagName==="A"||e.tagName==="a"){let n=e.getAttribute("href")?.trim();return !n||n==="#"||n.toLowerCase().startsWith("javascript:")?null:"link"}let t=e.getAttribute("role");if(t&&qo.has(t))return "role";try{if(window.getComputedStyle(e).cursor==="pointer")return "cursor_pointer"}catch{}return null}function $t(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function pt(e,t){if(!e||$t(e,t.ignoreSelectors))return null;let n=e;for(;n;){if($t(n,t.ignoreSelectors))return null;if(t.isSelectable?t.isSelectable(n):$o(n))return n;n=n.parentElement;}return null}function Ue(e,t){if(t.length===0)return false;for(let n of t)try{if(e.matches(n)||e.closest(n))return !0}catch{}return false}function $o(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function Xt(e){let t=e.getBoundingClientRect(),n={selector:me(e),tagName:e.tagName.toLowerCase(),rect:Ce(t),pageRect:Ho(t)},o=e.getAttribute("id");o&&(n.id=o);let r=e.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=re(e);i&&(n.textSnippet=i);let c=le(e)??ft(e);c&&(n.componentName=c);let s=Vo(e);return s&&(n.testId=s),n}function Ko(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function k(e,t,n){let o={kind:e,message:Ko(t)};return n&&(o.detail=n),o}var mt=null;async function jt(){return mt||(mt=import('html-to-image')),mt}async function Xo(e){return await new Promise((t,n)=>{let o=new Image;o.onload=()=>t({width:o.naturalWidth,height:o.naturalHeight}),o.onerror=()=>n(new Error("Failed to load generated screenshot")),o.src=e;})}async function Yt(e,t){let{width:n,height:o}=await Xo(e);return {dataUrl:e,mime:t,width:n,height:o}}function Ee(e){if(e?.aborted)throw new Error("Aborted")}function Gt(){return {async captureElement(e,t){if(!T())throw new Error("captureElement can only run in the browser");Ee(t.signal);let n=await jt();Ee(t.signal);let o=t.mime==="image/jpeg"?await n.toJpeg(e,{quality:t.quality??.92,pixelRatio:t.pixelRatio}):await n.toPng(e,{pixelRatio:t.pixelRatio});return Ee(t.signal),await Yt(o,t.mime)},async captureFullPage(e){if(!T())throw new Error("captureFullPage can only run in the browser");Ee(e.signal);let t=document.documentElement,n=Math.max(t.scrollWidth,t.clientWidth),o=Math.max(t.scrollHeight,t.clientHeight),r=Math.min(1,e.maxDimension/Math.max(n,o)),i=Math.max(1,Math.round(n*r)),c=Math.max(1,Math.round(o*r)),s=await jt();Ee(e.signal);let a=e.mime==="image/jpeg"?await s.toJpeg(t,{width:i,height:c,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await s.toPng(t,{width:i,height:c,pixelRatio:e.pixelRatio});return Ee(e.signal),await Yt(a,e.mime)}}}var jo=12e3,Yo=2048,Go=.92;function Jt(){return Date.now()}function Jo(e){return new Promise((t,n)=>{let o=()=>n(new Error("Aborted"));if(e.aborted){o();return}e.addEventListener("abort",o,{once:true});})}async function Qt(e,t,n){let o=new Promise((i,c)=>{let s=setTimeout(()=>c(new Error("Timeout")),t);typeof s.unref=="function"&&s.unref();}),r=[e,o];return n&&r.push(Jo(n)),await Promise.race(r)}function Qo(e){if(!T())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function Zo(e){return !!(e?.element||e?.fullPage)}function Zt(e){let t={mime:e.mime,pixelRatio:e.pixelRatio,maxDimension:e.maxDimension};return e.includeQuality&&(t.quality=e.quality),e.signal&&(t.signal=e.signal),t}async function en(e){let{selectionElement:t,capture:n,signal:o}=e;if(!T()||!Zo(n))return;let r=Jt(),i=[],c=n?.timeoutMs??jo,s=n?.maxDimension??Yo,a=n?.mime??"image/png",l=n?.quality??Go,m=n?.adapter??Gt(),b={},d=Qo(n);if(n?.element&&t)try{let p=t.getBoundingClientRect(),f=Math.min(1,s/Math.max(p.width,p.height)),g=Math.min(d,d*f),v=await Qt(Promise.resolve(m.captureElement(t,{...Zt({mime:a,quality:l,pixelRatio:g,maxDimension:s,includeQuality:a==="image/jpeg",...o?{signal:o}:{}})})),c,o);b.element=v;}catch(p){if(o?.aborted)throw p;i.push(k("capture_failed",p,{target:"element"}));}if(n?.fullPage)try{let p=await Qt(Promise.resolve(m.captureFullPage(Zt({mime:a,quality:l,pixelRatio:d,maxDimension:s,includeQuality:a==="image/jpeg",...o?{signal:o}:{}}))),c,o);b.fullPage=p;}catch(p){if(o?.aborted)throw p;i.push(k("capture_failed",p,{target:"fullPage"}));}let h=Jt(),u={startedAt:r,finishedAt:h,durationMs:Math.max(0,h-r)};return i.length>0&&(u.errors=i),{...b,diagnostics:u}}function er(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function tr(){return T()?{url:window.location.href,title:document.title,referrer:document.referrer||void 0,userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,viewport:{width:window.innerWidth,height:window.innerHeight},screen:{width:window.screen.width,height:window.screen.height},scroll:{x:window.scrollX,y:window.scrollY},devicePixelRatio:window.devicePixelRatio||1,timezone:er()}:{}}function nr(e){if(!e)return {};let t={};return e.id&&(t.userId=e.id),e.email&&(t.userEmail=e.email),e.name&&(t.userName=e.name),t}async function tn(e){let{config:t,context:n,user:o}=e;if(t?.enabled===false)return {};let r={...tr(),...nr(o)},i=t?.enrich;if(!i)return r;try{let c=await i(n);return {...r,...c}}catch(c){let s=k("unknown",c);return {...r,blocfeedMetadataError:s.message}}}var Re="blocfeed-queue",or=50;function gt(){if(!T())return [];try{let e=localStorage.getItem(Re);if(!e)return [];let t=JSON.parse(e);if(Array.isArray(t))return t;console.warn("[BlocFeed] offline queue was corrupt (non-array) \u2014 resetting");try{localStorage.removeItem(Re);}catch{}return []}catch(e){console.warn("[BlocFeed] offline queue could not be read \u2014 resetting",e);try{localStorage.removeItem(Re);}catch{}return []}}function bt(e){if(T())try{e.length===0?localStorage.removeItem(Re):localStorage.setItem(Re,JSON.stringify(e));}catch(t){let n=t instanceof DOMException?t.name:"";console.warn(`[BlocFeed] failed to persist offline queue${n?` (${n})`:""} \u2014 feedback may be lost if page is closed`);}}function rr(e){let t={...e};if(t.screenshots){let n={...t.screenshots};n.element&&(n.element={...n.element,dataUrl:""}),n.fullPage&&(n.fullPage={...n.fullPage,dataUrl:""}),t.screenshots=n;}return delete t.video,t}function ht(e){let t=gt(),n=rr(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>or;)t.shift();bt(t);}function nn(){let e=gt();return e.length===0?[]:(bt([]),e.map(t=>t.payload))}function za(){bt([]);}function on(){return gt().length}function vt(e){let t=null,n=null,o=(...r)=>{n=r,t===null&&(t=requestAnimationFrame(()=>{if(t=null,!n)return;let i=n;n=null,e(...i);}));};return o.cancel=()=>{t!==null&&cancelAnimationFrame(t),t=null,n=null;},o}function ze(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function Ve(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function rn(e,t){if(!T())throw new Error("BlocFeed picker can only run in a browser environment.");let n=e.ignoreSelectors,o=e.isSelectable,r={};n&&n.length>0&&(r.ignoreSelectors=n),o&&(r.isSelectable=o);let i=null,c=null,s=(u,p=false)=>{if(!u){i=null,c=null,t.onHover(null);return}let f=Ce(u.getBoundingClientRect()),g=`${Math.round(f.x)}:${Math.round(f.y)}:${Math.round(f.width)}:${Math.round(f.height)}`;!p&&u===i&&g===c||(i=u,c=g,t.onHover({element:u,rect:f}));},a=vt(u=>{if(ze(u.target))return;let p=document.elementFromPoint(u.clientX,u.clientY),f=pt(p,r);s(f);}),l=vt(()=>{i&&s(i,true);}),m=u=>{ze(u.target)||(Ve(u),u.pointerType==="mouse"&&u.preventDefault());},b=u=>{ze(u.target)||(Ve(u),u.pointerType==="mouse"&&u.preventDefault());},d=u=>{if(ze(u.target))return;Ve(u),u.preventDefault();let p=document.elementFromPoint(u.clientX,u.clientY),f=pt(p,r);f&&t.onSelect({element:f,descriptor:Xt(f)});},h=u=>{u.key==="Escape"&&(Ve(u),u.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",a,{capture:true,passive:true}),window.addEventListener("pointerdown",m,{capture:true}),window.addEventListener("pointerup",b,{capture:true}),window.addEventListener("click",d,{capture:true}),window.addEventListener("keydown",h,{capture:true}),window.addEventListener("scroll",l,{capture:true,passive:true}),window.addEventListener("resize",l,{passive:true}),{stop(){window.removeEventListener("pointermove",a,{capture:true}),window.removeEventListener("pointerdown",m,{capture:true}),window.removeEventListener("pointerup",b,{capture:true}),window.removeEventListener("click",d,{capture:true}),window.removeEventListener("keydown",h,{capture:true}),window.removeEventListener("scroll",l,{capture:true}),window.removeEventListener("resize",l),a.cancel(),l.cancel(),t.onHover(null);}}}var ir=200,Pe=[],an=0,We=false;function sn(e){let t=e.target;if(!(t instanceof Element)||t.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-an,path:window.location.pathname,tagName:t.tagName.toLowerCase()},o=re(t,100);o&&(n.textSnippet=o);let r=le(t)??ft(t);r&&(n.componentName=r),Pe.length<ir&&Pe.push(n);}var cn={capture:true,passive:true};function ln(){We||!T()||(We=true,Pe=[],an=Date.now(),document.addEventListener("click",sn,cn));}function dn(){We&&(We=false,document.removeEventListener("click",sn,cn));}function yt(){return [...Pe]}function ar(){Pe=[];}var sr=3e4,cr=25e5,un="video/webm",lr=250,dr=1e3,ur=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function fn(){if(typeof MediaRecorder>"u")return null;for(let e of ur)if(MediaRecorder.isTypeSupported(e))return e;return null}function wt(){return !T()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:fn()!==null}async function xt(e){let{config:t,signal:n}=e;if(!T()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw k("recording_failed",new Error("Screen recording is not supported in this browser"));let o=fn();if(!o)throw k("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw k("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(f){let g=f instanceof DOMException&&f.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw k("recording_failed",new Error(g))}if(n?.aborted)throw r.getTracks().forEach(f=>f.stop()),k("aborted",new Error("Recording aborted after permission"));let i=t?.maxDurationMs??sr,c=t?.videoBitsPerSecond??cr,s=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:c}),a=[],l=[],m=0,b=null,d=null,h=false,u=()=>{dn(),b!==null&&(clearInterval(b),b=null),d!==null&&(clearTimeout(d),d=null),r.getTracks().forEach(f=>f.stop());},p=new Promise((f,g)=>{s.ondataavailable=C=>{C.data.size>0&&a.push(C.data);},s.onstop=()=>{if(h)return;h=true,u();let C=Date.now()-m,_=new Blob(a,{type:un}),E=URL.createObjectURL(_);f({mime:un,blobUrl:E,blob:_,durationMs:C,sizeBytes:_.size});},s.onerror=()=>{h||(h=true,u(),g(k("recording_failed",new Error("MediaRecorder error"))));};let v=r.getVideoTracks()[0];if(v&&v.addEventListener("ended",()=>{s.state!=="inactive"&&s.stop();}),n){let C=()=>{h||(h=true,s.state!=="inactive"&&s.stop(),u(),g(k("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",C,{once:true});}});return s.start(dr),ln(),m=Date.now(),b=setInterval(()=>{let f=Date.now()-m;for(let g of l)g(f);},lr),d=setTimeout(()=>{!h&&s.state!=="inactive"&&s.stop();},i),{result:p,stop(){!h&&s.state!=="inactive"&&s.stop();},onTick(f){l.push(f);},abort(){h||(h=true,s.state!=="inactive"&&s.stop(),u());}}}var fr=6e4,pn="audio/webm",pr=250,mr=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function mn(){if(typeof MediaRecorder>"u")return null;for(let e of mr)if(MediaRecorder.isTypeSupported(e))return e;return null}function Et(){return !T()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:mn()!==null}async function kt(e){let{config:t,signal:n}=e;if(!T()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw k("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=mn();if(!o)throw k("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw k("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(p){let f=p instanceof DOMException&&p.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw k("recording_failed",new Error(f))}if(n?.aborted)throw r.getTracks().forEach(p=>p.stop()),k("aborted",new Error("Voice recording aborted after permission"));let i=t?.maxDurationMs??fr,c=new MediaRecorder(r,{mimeType:o}),s=[],a=[],l=0,m=null,b=null,d=false,h=()=>{m!==null&&(clearInterval(m),m=null),b!==null&&(clearTimeout(b),b=null),r.getTracks().forEach(p=>p.stop());},u=new Promise((p,f)=>{if(c.ondataavailable=g=>{g.data.size>0&&s.push(g.data);},c.onstop=()=>{if(d)return;d=true,h();let g=Date.now()-l,v=new Blob(s,{type:pn});p({blob:v,mime:pn,durationMs:g});},c.onerror=()=>{d||(d=true,h(),f(k("recording_failed",new Error("MediaRecorder error"))));},n){let g=()=>{d||(d=true,c.state!=="inactive"&&c.stop(),h(),f(k("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",g,{once:true});}});return c.start(1e3),l=Date.now(),m=setInterval(()=>{let p=Date.now()-l;for(let f of a)f(p);},pr),b=setTimeout(()=>{b=null,!d&&c.state!=="inactive"&&c.stop();},i),{result:u,stop(){!d&&c.state!=="inactive"&&c.stop();},onTick(p){a.push(p);},abort(){d||(d=true,c.state!=="inactive"&&c.stop(),h());}}}var gr=12e3,br=2,hr=500,vr=2e3,St="https://blocfeed.com/api/feedback",yr="https://blocfeed.com/api/feedback/voice",gn=0,vn="blocfeed-viewer-token",yn="blocfeed-my-feedback-url";function wr(){try{return localStorage.getItem(vn)}catch{return null}}function _t(){try{return localStorage.getItem(yn)}catch{return null}}function xr(e,t){try{localStorage.setItem(vn,e),t&&localStorage.setItem(yn,t);}catch{}}function bn(e,t){return new Promise((n,o)=>{if(t?.aborted){o(new Error("Aborted"));return}let r=setTimeout(n,e),i=()=>{clearTimeout(r),o(new Error("Aborted"));};t?.addEventListener("abort",i,{once:true});})}function Er(e){return e>=500&&e<=599}function kr(e){let[t,n]=e.split(",",2);if(!t||!n)throw new Error("Invalid data URL");let r=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(n),c=new Uint8Array(i.length);for(let s=0;s<i.length;s+=1)c[s]=i.charCodeAt(s);return new Blob([c],{type:r})}function Sr(e){let t={},n={},o={...e};if(o.screenshots){let r={},i={...o.screenshots};i.element&&(t.element=i.element.dataUrl,r.element={mime:i.element.mime,width:i.element.width,height:i.element.height},i.element={...i.element,dataUrl:""}),i.fullPage&&(t.fullPage=i.fullPage.dataUrl,r.fullPage={mime:i.fullPage.mime,width:i.fullPage.width,height:i.fullPage.height},i.fullPage={...i.fullPage,dataUrl:""}),o.screenshots=i,(r.element||r.fullPage)&&(o.screenshot_intent=r);}return o.video&&(n.blob=o.video.blob,o.video_intent={mime:o.video.mime,durationMs:o.video.durationMs,sizeBytes:o.video.sizeBytes},delete o.video),{lean:o,extracted:t,extractedVideo:n}}async function hn(e,t,n){let o=kr(t);await fetch(e,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function _r(e){let{feedbackId:t,extracted:n,screenshots:o,signal:r}=e,i={};n.element&&o?.element&&(i.element={dataUrl:n.element,mime:o.element.mime,width:o.element.width,height:o.element.height}),n.fullPage&&o?.fullPage&&(i.fullPage={dataUrl:n.fullPage,mime:o.fullPage.mime,width:o.fullPage.width,height:o.fullPage.height}),Object.keys(i).length!==0&&await fetch(`${St}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function Tr(e){await fetch(`${St}/${e.feedbackId}/video`,{method:"POST",body:e.blob,headers:{"content-type":e.blob.type},...e.signal?{signal:e.signal}:{}});}async function wn(e){let{signal:t,transport:n}=e;if(Date.now()-gn<vr)return {ok:false,error:k("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??gr,i=n?.maxAttempts??br,c=n?.backoffMs??hr,s=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),a=!!e.payload.video?.blob,l=s||a,{lean:m,extracted:b,extractedVideo:d}=l?Sr(e.payload):{lean:e.payload,extracted:{},extractedVideo:{}},h=wr();h&&(m.viewer_token=h);let u={...b,...e.screenshotDataUrls};for(let p=1;p<=i;p+=1){let f=new AbortController,g=setTimeout(()=>f.abort(),r),v=()=>f.abort();t&&t.addEventListener("abort",v,{once:true});try{let C=await fetch(St,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(m),signal:f.signal});if(C.ok){gn=Date.now();let E;try{E=await C.json();}catch{}if(E?.viewer_token&&xr(E.viewer_token,E.my_feedback_url),(u.element||u.fullPage)&&E){let B=E.upload_urls;if(B){let M=[];u.element&&B.element&&M.push(hn(B.element,u.element,t)),u.fullPage&&B.fullPage&&M.push(hn(B.fullPage,u.fullPage,t));try{await Promise.all(M);}catch{}}else if(E.feedback_id)try{await _r({feedbackId:E.feedback_id,extracted:u,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}if(d.blob&&E){let B=E.upload_urls;if(B?.video)try{await fetch(B.video,{method:"PUT",body:d.blob,headers:{"content-type":d.blob.type},...t?{signal:t}:{}});}catch{}else if(E.feedback_id)try{await Tr({feedbackId:E.feedback_id,blob:d.blob,...t?{signal:t}:{}});}catch{}}let H={ok:!0,status:C.status};return E&&(H.apiResponse=E),H}if(p<i&&Er(C.status)){let E=.85+Math.random()*.3,z=Math.round(c*2**(p-1)*E);await bn(z,t);continue}let _=`HTTP ${C.status}`;try{let E=await C.json();E?.error&&(_=E.error);}catch{}return {ok:!1,status:C.status,error:k("api_failed",new Error(_))}}catch(C){if(f.signal.aborted||t?.aborted)return {ok:false,error:k("aborted",C)};if(p<i){let _=.85+Math.random()*.3,E=Math.round(c*2**(p-1)*_);await bn(E,t);continue}return {ok:false,error:k("api_failed",C)}}finally{clearTimeout(g),t&&t.removeEventListener("abort",v);}}return {ok:false,error:k("api_failed",new Error("Failed"))}}async function xn(e){let{blob:t,mime:n,blocfeedId:o,signal:r}=e,i=await fetch(yr,{method:"POST",headers:{"Content-Type":n,"X-Blocfeed-Id":o},body:t,...r?{signal:r}:{}});if(!i.ok){let s=await i.json().catch(()=>({error:"Unknown error"}));throw k("api_failed",new Error(s?.error??`Voice API returned ${i.status}`))}let c=await i.json();return {text:c.text??"",warning:c.warning}}async function Tt(e){let{signal:t,transport:n}=e,o={ok:false};try{let r={payload:e.payload,...t?{signal:t}:{},...n?{transport:n}:{}};o.api=await wn(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:k("api_failed",r)},o.ok=false;}return {payload:e.payload,result:o}}var Cr={enabled:true,sampling:1,ignoreSelectors:["[data-blocfeed-ui]","[data-blocfeed-ignore]"],rageClick:{enabled:true,threshold:3,windowMs:1e3,streakIdleMs:1500},httpFail:{enabled:true,statusCodes:[400,401,403,404,408,409,422,429,500,502,503,504],ignoreUrls:["/api/behavioral-events","/api/feedback"],treatJsonErrorAsFail:false},redirectLoop:{enabled:true,threshold:3,windowMs:2e3},formDataLoss:{enabled:true},deadClick:{enabled:true,observationWindowMs:300,rateLimitPerSelector:5}};function En(e){let t=Cr;return {enabled:e?.enabled??t.enabled,sampling:e?.sampling??t.sampling,ignoreSelectors:e?.ignoreSelectors??t.ignoreSelectors,rageClick:{...t.rageClick,...e?.rageClick??{}},httpFail:{...t.httpFail,...e?.httpFail??{}},redirectLoop:{...t.redirectLoop,...e?.redirectLoop??{}},formDataLoss:{...t.formDataLoss,...e?.formDataLoss??{}},deadClick:{...t.deadClick,...e?.deadClick??{}}}}function kn(e){let t=[];async function n(){if(t.length===0)return;let r=t.splice(0,50);try{await fetch(e.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-blocfeed-id":e.blocfeedId},body:JSON.stringify({events:r}),keepalive:!0});}catch{}}function o(){if(t.length===0)return;if(typeof navigator>"u"||typeof navigator.sendBeacon!="function"){n();return}let r=t.splice(0,50),i=new Blob([JSON.stringify({events:r})],{type:"application/json"}),c=`${e.endpoint}?_bfid=${encodeURIComponent(e.blocfeedId)}`;try{navigator.sendBeacon(c,i);}catch{}}return {enqueue(r){t.push(r);},flush:n,flushBeacon:o,size(){return t.length}}}var Sn="bf_behavioral_session",qe=null;function D(){try{let e=sessionStorage.getItem(Sn);if(e)return e;let t=_n();return sessionStorage.setItem(Sn,t),t}catch{return qe||(qe=_n(),qe)}}function _n(){let e=Math.random().toString(36).slice(2,10).padEnd(8,"0");return `bf_${Date.now()}_${e}`}function $e(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return Math.abs(t)}function Tn(e,t){if(!e.rageClick.enabled)return ()=>{};let{threshold:n,windowMs:o,streakIdleMs:r}=e.rageClick,i=new Map;function c(b){let d=b.target,h=d?Rr(d):false,u=d?re(d,200)??null:null,p=d?d.tagName.toLowerCase():"",f=d&&d.id||null,g=d?le(d)??null:null,v=d?we(d,5):[];return {session_id:D(),event_type:"rage_click",page_url:typeof window>"u"?"":window.location.href,selector:b.selector,element_text:u,event_data:{click_count:b.timestamps.length,window_ms:o,final:true,...h?{disabled:true}:{},tag_name:p,...f?{element_id:f}:{},...g?{component_name:g}:{},...v.length>0?{parent_components:v}:{}},created_at:new Date().toISOString(),stable_key:b.stableKey}}function s(b){let d=i.get(b);d&&(d.idleTimer&&(clearTimeout(d.idleTimer),d.idleTimer=null),d.reached&&t(c(d)),i.delete(b));}function a(b){let d=i.get(b);d&&(d.idleTimer&&clearTimeout(d.idleTimer),d.idleTimer=setTimeout(()=>{s(b);},r));}function l(b){try{let d=b.target;if(!d||!(d instanceof Element)||Ue(d,e.ignoreSelectors))return;let h=me(d,4);if(!h)return;let u=xe(d),p=u??h,f=Date.now(),g=i.get(p);g?(g.target=d,g.selector=h):(g={selector:h,stableKey:u,timestamps:[],reached:!1,idleTimer:null,target:d},i.set(p,g)),g.reached||(g.timestamps=g.timestamps.filter(v=>f-v<=o)),g.timestamps.push(f),a(p),!g.reached&&g.timestamps.length>=n&&(g.reached=!0);}catch{}}function m(){for(let b of Array.from(i.keys()))s(b);}return document.addEventListener("click",l,{capture:true,passive:true}),typeof window<"u"&&window.addEventListener("pagehide",m),()=>{document.removeEventListener("click",l,{capture:true}),typeof window<"u"&&window.removeEventListener("pagehide",m);for(let b of i.values())b.idleTimer&&clearTimeout(b.idleTimer);i.clear();}}function Rr(e){if(e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true")return true;try{if(window.getComputedStyle(e).pointerEvents==="none")return !0}catch{}return false}var Cn=0,Rn=null,Xe=null,je=[],Pr=1500;function Br(){function e(t){try{let n=t.target;if(!n)return;let o=n.closest('button[type="submit"], input[type="submit"], [data-blocfeed-submit]');if(!o)return;Cn=Date.now();let r=o.closest("form");Rn=(r?me(r,3):"")||null,Xe=re(o,100)??null,je=we(o,5);}catch{}}return document.addEventListener("click",e,{capture:true,passive:true}),()=>document.removeEventListener("click",e,{capture:true})}function Pn(e,t){if(!e.httpFail.enabled)return ()=>{};let{statusCodes:n,ignoreUrls:o,treatJsonErrorAsFail:r}=e.httpFail,i=new Set(n),c=Br(),s=globalThis.fetch,a=async(d,h)=>{let u=typeof d=="string"?d:d instanceof URL?d.toString():d.url,p=(h?.method??d.method??"GET").toUpperCase(),f;try{f=await s.call(globalThis,d,h);}catch(g){try{if(!Ke(u,o)){let v=g&&typeof g=="object"&&g.name==="AbortError"?"abort":"network";t(b(0,u,p,v));}}catch{}throw g}try{if(!Ke(u,o)&&i.has(f.status))t(b(f.status,u,p));else if(r&&!Ke(u,o)&&f.status>=200&&f.status<300){let g=f.headers.get("content-type")??"";(g.includes("application/json")||g.includes("+json"))&&f.clone().json().then(v=>{if(Fr(v))try{t(b(f.status,u,p,"json_error"));}catch{}}).catch(()=>{});}}catch{}return f};globalThis.fetch=a;let l=XMLHttpRequest.prototype.open,m=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(d,h,...u){return this.__bf_url=h,this.__bf_method=d.toUpperCase(),l.call(this,d,h,...u)},XMLHttpRequest.prototype.send=function(d){let h=()=>{try{let u=this.__bf_url??"",p=this.__bf_method??"GET";!Ke(u,o)&&i.has(this.status)&&t(b(this.status,u,p));}catch{}};return this.__bf_handler=h,this.addEventListener("loadend",h),m.call(this,d??null)},()=>{globalThis.fetch=s,XMLHttpRequest.prototype.open=l,XMLHttpRequest.prototype.send=m,c(),Xe=null,je=[];};function b(d,h,u,p){let g=Date.now()-Cn<Pr;return {session_id:D(),event_type:"error",page_url:typeof window>"u"?"":window.location.href,selector:null,element_text:null,event_data:{http_status:d,request_url:h,method:u,...p?{error_kind:p}:{},form_selector:g?Rn:null,...g&&Xe?{button_text:Xe}:{},...g&&je.length>0?{parent_components:je}:{}},created_at:new Date().toISOString(),stable_key:null}}}function Fr(e){if(!e||typeof e!="object")return false;let t=e;return t.ok===false||t.success===false||"error"in t&&t.error!=null&&t.error!==false}function Ke(e,t){if(t.length===0)return false;for(let n of t)if(e.includes(n))return true;return false}var Ar=3e4;function Bn(e,t){if(!e.redirectLoop.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let{threshold:n,windowMs:o}=e.redirectLoop,r=new Map,i=new Map,c=history.pushState,s=history.replaceState;function a(m){try{let b=Date.now(),d=i.get(m)??0;if(b<d)return;let u=(r.get(m)??[]).filter(p=>b-p<=o);if(u.push(b),r.set(m,u),u.length>=n){let p={session_id:D(),event_type:"thrashing",page_url:window.location.href,selector:null,element_text:null,event_data:{count:u.length,url:m,window_ms:o},created_at:new Date().toISOString(),stable_key:null};t(p),i.set(m,b+Ar),r.set(m,[]);}}catch{}}function l(){let m=window.location.pathname+window.location.search;a(m);}return history.pushState=function(...m){let b=c.apply(this,m);return l(),b},history.replaceState=function(...m){let b=s.apply(this,m);return l(),b},window.addEventListener("popstate",l),()=>{history.pushState=c,history.replaceState=s,window.removeEventListener("popstate",l);}}var Mr=6e4;function Fn(e,t){if(!e.formDataLoss.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let n=new Set,o=new Map,r=new Map,i=new Map;function c(p){let f=p.closest("form");return f?f.id?`#${f.id}`:"form":null}function s(){let p=0;for(let f of o.values())p+=f;return p}function a(p){n.delete(p),o.delete(p),i.delete(p);}function l(p){try{let f=p.target;if(!f||!(f instanceof HTMLInputElement||f instanceof HTMLTextAreaElement||f instanceof HTMLSelectElement))return;let g=c(f);if(!g)return;n.add(g),o.set(g,(o.get(g)??0)+1);let v=f.closest("form");v&&i.set(g,v);}catch{}}function m(p){try{let f=p.target;if(!f||!(f instanceof HTMLFormElement))return;let g=f.id?`#${f.id}`:"form";r.set(g,Date.now()),a(g);}catch{}}function b(p){try{let f=p.target;if(!f||!(f instanceof HTMLFormElement))return;let g=f.id?`#${f.id}`:"form";a(g);}catch{}}function d(p){if(n.size===0)return;let f=Array.from(n),g=f[0]??null,v=g?i.get(g)??null:null,C=v?xe(v):null,_={session_id:D(),event_type:"form_abandonment",page_url:window.location.href,selector:g,element_text:null,event_data:{cause:p,field_count:s(),forms:f},created_at:new Date().toISOString(),stable_key:C};t(_);}function h(p){if(!p.persisted||n.size===0)return;let f=Date.now();for(let[,g]of r)if(f-g<Mr)return;d("bfcache_restore");}function u(){d("beforeunload_after_edit");}return document.addEventListener("input",l,{capture:true,passive:true}),document.addEventListener("submit",m,{capture:true}),document.addEventListener("reset",b,{capture:true}),window.addEventListener("pageshow",h),window.addEventListener("beforeunload",u),()=>{document.removeEventListener("input",l,{capture:true}),document.removeEventListener("submit",m,{capture:true}),document.removeEventListener("reset",b,{capture:true}),window.removeEventListener("pageshow",h),window.removeEventListener("beforeunload",u);}}function Ir(){let e={urlChangeCount:0,networkCount:0,filePickerCount:0,uninstall:()=>{}},t=history.pushState,n=history.replaceState;history.pushState=function(...s){return e.urlChangeCount+=1,t.apply(this,s)},history.replaceState=function(...s){return e.urlChangeCount+=1,n.apply(this,s)};let o=()=>{e.urlChangeCount+=1;};window.addEventListener("popstate",o);let r=globalThis.fetch;if(r){let s=(a,l)=>(e.networkCount+=1,r.call(globalThis,a,l));globalThis.fetch=s;}let i=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(s,a,...l){return e.networkCount+=1,i.call(this,s,a,...l)};let c=HTMLInputElement.prototype.click;return HTMLInputElement.prototype.click=function(){return this.type==="file"&&(e.filePickerCount+=1),c.call(this)},e.uninstall=()=>{history.pushState=t,history.replaceState=n,window.removeEventListener("popstate",o),r&&(globalThis.fetch=r),XMLHttpRequest.prototype.open=i,HTMLInputElement.prototype.click=c;},e}function An(e,t){if(!e.deadClick.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let{observationWindowMs:n,rateLimitPerSelector:o}=e.deadClick,r=new Map,i=Ir();function c(s){try{let a=s.target;if(!a||!(a instanceof Element)||s.button!==0||s.metaKey||s.ctrlKey||s.altKey||s.shiftKey||Ue(a,e.ignoreSelectors)||a.closest("label"))return;if(a instanceof HTMLInputElement){let M=a.type;if(M==="checkbox"||M==="radio"||M==="file")return}if(a instanceof HTMLSelectElement||a.closest("a[target='_blank'], a[download]")||a.closest('[contenteditable="true"]'))return;try{let M=window.getSelection();if(M&&M.toString().length>0)return}catch{}let l=Kt(a);if(!l)return;let m=me(a,4);if(!m)return;let b=xe(a),d=b??m,h=i.urlChangeCount,u=i.networkCount,p=i.filePickerCount,f=new Date().toISOString(),g=re(a,200)??null,v=a.tagName.toLowerCase(),C=a.id||null,_=le(a)??null,E=we(a,5),z=Lr(a),H=0,B=null;if(z){B=new MutationObserver(()=>{H+=1;});try{B.observe(z,{childList:!0,attributes:!0,characterData:!0,subtree:!0});}catch{B=null;}}setTimeout(()=>{if(B)try{B.disconnect();}catch{}if(H>0||i.urlChangeCount!==h||i.networkCount!==u||i.filePickerCount!==p)return;let M=r.get(d)??0;if(M>=o)return;r.set(d,M+1);let se={session_id:D(),event_type:"dead_click",page_url:typeof window>"u"?"":window.location.href,selector:m,element_text:g,event_data:{tag_name:v,...C?{element_id:C}:{},..._?{component_name:_}:{},...E.length>0?{parent_components:E}:{},clickable_reason:l},created_at:f,stable_key:b};t(se);},n);}catch{}}return document.addEventListener("click",c,{capture:true,passive:true}),()=>{document.removeEventListener("click",c,{capture:true}),i.uninstall();}}function Lr(e){let t=e.closest('button, a, form, [role="button"]');return t||e.parentElement}var Dr="https://blocfeed.com/api/replay-events";function Mn(e){if(!e.config.enabled)return ()=>{};if(typeof window>"u")return ()=>{};if(typeof globalThis.matchMedia>"u")return ()=>{};let t=D();if($e(t)%100/100>=e.config.sampling)return ()=>{};let o=Date.now(),r=e.config.endpoint??Dr,i=[],c=0,s=false,a=false,l=null,m=`bf_replay_chunkseq_${t}`,b=`bf_replay_pauses_${t}`,d=0,h=0;try{let y=sessionStorage.getItem(m);y&&(d=parseInt(y,10)||0);let S=sessionStorage.getItem(b);S&&(h=parseInt(S,10)||0);}catch{}let u=(y=false)=>{if(i.length===0)return;let S=y?Hr(i):i;i=[],c=0;let L=d++;try{sessionStorage.setItem(m,String(d));}catch{}Ur({blocfeedId:e.blocfeedId,sessionId:t,sessionStartedAtMs:o,chunkSeq:L,events:S,endpoint:r,useBeacon:y,pauseCount:h});},p=setInterval(()=>{s||u();},e.config.flushIntervalMs),f=setTimeout(()=>{u(),ue();},e.config.maxDurationMs),g=null,v=()=>{g&&clearTimeout(g),g=setTimeout(()=>{M();},e.config.inactivityTimeoutMs);},C=()=>{u(true);};window.addEventListener("pagehide",C);let _=e.config.masking,E={emit(y){s||(i.push(y),c+=Or(y),v(),c>=e.config.flushSizeBytes&&u());},recordCanvas:false,sampling:{mousemove:50}};_.maskAllInputs!==void 0&&(E.maskAllInputs=_.maskAllInputs),_.maskTextSelector!==void 0&&(E.maskTextSelector=_.maskTextSelector),_.maskTextClass!==void 0&&(E.maskTextClass=_.maskTextClass),_.blockSelector!==void 0&&(E.blockSelector=_.blockSelector);let z=null,H=()=>{z&&(document.removeEventListener("pointerdown",z,true),document.removeEventListener("keydown",z,true),z=null);};function B(){l=rrweb.record(E)??null;}function M(){if(s||a)return;a=true,h++;try{sessionStorage.setItem(b,String(h));}catch{}if(u(),l){try{l();}catch{}l=null;}g&&(clearTimeout(g),g=null);let y=()=>{H(),se();};z=y,document.addEventListener("pointerdown",y,{capture:true,once:true}),document.addEventListener("keydown",y,{capture:true,once:true});}function se(){s||!a||(a=false,B(),v());}v(),B();function ue(){if(!s&&(s=true,clearInterval(p),clearTimeout(f),g&&clearTimeout(g),H(),window.removeEventListener("pagehide",C),l)){try{l();}catch{}l=null;}}return ue}function Or(e){try{return JSON.stringify(e).length}catch{return 1024}}function Hr(e){let n=JSON.stringify(e);if(n.length<=6e4)return e;let o=[...e];for(;o.length>1;)if(o.shift(),n=JSON.stringify(o),n.length<=6e4)return o;return o}async function Ur(e){let t=JSON.stringify({blocfeed_id:e.blocfeedId,session_id:e.sessionId,session_started_at_ms:e.sessionStartedAtMs,chunk_seq:e.chunkSeq,pause_count:e.pauseCount,events:e.events,page_url:typeof window<"u"?window.location.href:"",user_agent:typeof navigator<"u"?navigator.userAgent:""});if(e.useBeacon&&typeof navigator<"u"&&typeof navigator.sendBeacon=="function")try{let o=new Blob([t],{type:"application/json"});navigator.sendBeacon(e.endpoint,o);return}catch{}let n=!!e.useBeacon;try{await fetch(e.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:t,...n?{keepalive:!0}:{}});}catch{}}var zr={enabled:true,endpoint:null,maxDurationMs:144e5,flushIntervalMs:3e4,flushSizeBytes:1048576,inactivityTimeoutMs:18e5,sampling:1,masking:{maskAllInputs:true,maskTextSelector:"[data-blocfeed-mask]",maskTextClass:"blocfeed-mask",blockSelector:"[data-blocfeed-block]"}};function In(e){let t=zr;return {enabled:e?.enabled??t.enabled,endpoint:e?.endpoint??t.endpoint,maxDurationMs:e?.maxDurationMs??t.maxDurationMs,flushIntervalMs:e?.flushIntervalMs??t.flushIntervalMs,flushSizeBytes:e?.flushSizeBytes??t.flushSizeBytes,inactivityTimeoutMs:e?.inactivityTimeoutMs??t.inactivityTimeoutMs,sampling:e?.sampling??t.sampling,masking:{...t.masking,...e?.masking??{}}}}var Vr="https://blocfeed.com/api/events/track",Wr=5e3,qr=50,$r=1024,Je="blocfeed-events-queue",Ln=500,Nn=100,Kr=/^[a-z][a-z0-9_]{0,127}$/,Dn=50,On=1024,Hn;function Un(e){Hn=e;}function Xr(e){if(typeof e!="string"||!Kr.test(e))throw new Error(`[BlocFeed] track(): event_name "${e}" must match /^[a-z][a-z0-9_]{0,127}$/ (lowercase, start with a letter, only [a-z0-9_], \u2264128 chars).`)}function jr(e){if(e===void 0)return {};if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("[BlocFeed] track(): properties must be a plain object.");let t=Object.keys(e);if(t.length>Dn)throw new Error(`[BlocFeed] track(): properties has ${t.length} keys, max ${Dn}.`);for(let o of t){let r=e[o];if(r!==null&&typeof r!="string"&&typeof r!="number"&&typeof r!="boolean")throw new Error(`[BlocFeed] track(): property "${o}" has unsupported type "${typeof r}". Allowed: string | number | boolean | null.`)}let n;try{n=JSON.stringify(e);}catch(o){throw new Error(`[BlocFeed] track(): properties is not JSON-serializable (${o.message}).`)}if(n.length>On)throw new Error(`[BlocFeed] track(): properties serialized to ${n.length} bytes, max ${On}. Server allows 8192 bytes \u2014 the client cap is defensive; trim down or split the event.`);return e}function Ct(){if(typeof localStorage>"u")return [];try{let e=localStorage.getItem(Je);if(!e)return [];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{try{localStorage.removeItem(Je);}catch{}return []}}function Rt(e){if(!(typeof localStorage>"u"))try{if(e.length===0)localStorage.removeItem(Je);else {let t=e.length>Ln?e.slice(e.length-Ln):e;localStorage.setItem(Je,JSON.stringify(t));}}catch{}}var Y=null;function Yr(){if(Y)return Y;if(typeof window>"u")return null;let e=Gr();return e?(Y={blocfeedId:e,endpoint:Vr,events:[],bytes:0,flushTimer:null,pageHideHandler:null,visibilityHandler:null},Y.flushTimer=setInterval(()=>{Ge(false);},Wr),Y.pageHideHandler=()=>{Ge(true);},Y.visibilityHandler=()=>{document.visibilityState==="hidden"&&Ge(true);},window.addEventListener("pagehide",Y.pageHideHandler),document.addEventListener("visibilitychange",Y.visibilityHandler),Y):null}function Gr(){try{let t=window.__blocfeed_id__;return typeof t=="string"&&t.length>0?t:null}catch{return null}}function ke(e){try{window.__blocfeed_id__=e;}catch{}Y&&(Y.blocfeedId=e);}function Be(e,t,n){Xr(e);let o=jr(t),r=n?.occurredAt?ti(n.occurredAt):new Date().toISOString(),i={event_name:e,properties:o,occurred_at:r},c=n?.sessionId??Qr();c&&(i.session_id=c);let s=n?.userId??Hn;s&&(i.user_id=s);let a=n?.pageUrl??Zr();a&&(i.page_url=a);let l=ei();l&&(i.user_agent=l);let m=Yr();if(!m){let b=Ct();b.push(i),Rt(b);return}m.events.push(i),m.bytes+=Jr(i),(m.events.length>=qr||m.bytes>=$r)&&Ge(false);}async function Ge(e){let t=Y;if(!t)return;let o=Ct().concat(t.events);if(t.events=[],t.bytes=0,Rt([]),o.length!==0)for(let r=0;r<o.length;r+=Nn){let i=o.slice(r,r+Nn),c=JSON.stringify({blocfeed_id:t.blocfeedId,events:i});if(e&&ni())try{let s=new Blob([c],{type:"application/json"});navigator.sendBeacon(t.endpoint,s)||Ye(i);continue}catch{Ye(i);continue}try{(await fetch(t.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:c})).ok||Ye(i);}catch{Ye(i);}}}function Ye(e){let t=Ct();Rt(t.concat(e));}function Jr(e){try{return JSON.stringify(e).length}catch{return 256}}function Qr(){try{return D()}catch{return}}function Zr(){try{return typeof window<"u"?window.location.href:void 0}catch{return}}function ei(){try{return typeof navigator<"u"?navigator.userAgent:void 0}catch{return}}function ti(e){return e instanceof Date?e.toISOString():new Date(e).toISOString()}function ni(){return typeof navigator<"u"&&typeof navigator.sendBeacon=="function"}var oi="https://blocfeed.com/api/heartbeat",ri=300*1e3;function zn(e){if(typeof window>"u")return ()=>{};if(typeof globalThis.matchMedia>"u")return ()=>{};let t=e.endpoint??oi,n=e.intervalMs??ri,o=e.features??["replay","behavioral","customEvents"],r=s=>{try{let a=JSON.stringify({blocfeed_id:e.blocfeedId,session_id:ii(),version:e.version,page_url:typeof window<"u"?window.location.href:"",user_agent:typeof navigator<"u"?navigator.userAgent:"",sdk_features:o}),l={method:"POST",headers:{"Content-Type":"application/json"},body:a};s&&(l.keepalive=!0),fetch(t,l).catch(()=>{});}catch{}};try{r(!1);}catch{}let i=null;try{i=setInterval(()=>{try{r(!1);}catch{}},n);}catch{i=null;}let c=()=>{try{r(!0);}catch{}};try{window.addEventListener("pagehide",c);}catch{}return function(){try{i&&clearInterval(i);}catch{}i=null;try{window.removeEventListener("pagehide",c);}catch{}}}function ii(){try{return D()}catch{return ""}}var ai=5e3,Fe=class{constructor(t){this.submitter=null;this.detectorUninstallers=[];this.flushTimer=null;this.pageHideHandler=null;this.installed=false;this.opts=t,this.resolved=En(t.config);}install(){if(this.installed||!this.resolved.enabled)return;let t=()=>{try{let s=D();return $e(s)%100/100<this.resolved.sampling}catch{return false}};if(!(this.opts.passiveSampler??t)())return;ke(this.opts.blocfeedId);let o=this.opts.endpoint??"https://blocfeed.com/api/behavioral-events";this.submitter=this.opts.submitter??kn({endpoint:o,blocfeedId:this.opts.blocfeedId});let r=s=>{this.submitter?.enqueue(s);};this.detectorUninstallers.push(Tn(this.resolved,r)),this.detectorUninstallers.push(Pn(this.resolved,r)),this.detectorUninstallers.push(Bn(this.resolved,r)),this.detectorUninstallers.push(Fn(this.resolved,r)),this.detectorUninstallers.push(An(this.resolved,r));let i=In(this.opts.config?.sessionReplay);this.detectorUninstallers.push(Mn({blocfeedId:this.opts.blocfeedId,config:i}));let c=["behavioral","customEvents"];i.enabled&&c.unshift("replay"),this.detectorUninstallers.push(zn({blocfeedId:this.opts.blocfeedId,version:Vn,features:c})),this.flushTimer=setInterval(()=>{this.submitter?.flush();},ai),this.pageHideHandler=()=>{this.submitter?.flushBeacon();},typeof window<"u"&&window.addEventListener("pagehide",this.pageHideHandler),this.installed=true;}uninstall(){if(this.installed){for(let t of [...this.detectorUninstallers].reverse())try{t();}catch{}this.detectorUninstallers=[],this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.pageHideHandler&&typeof window<"u"&&(window.removeEventListener("pagehide",this.pageHideHandler),this.pageHideHandler=null);try{this.submitter?.flush();}catch{}this.submitter=null,this.installed=false;}}};var si=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function ci(e){let t=[...si,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function Wn(){return {phase:"idle"}}function li(e){if(e.ok)return false;let t=e.api;return t?t.status&&t.status>=400&&t.status<500||t.error?.kind==="aborted"||t.error?.kind==="configuration"?false:!t.ok:true}function qn(e){let t=e,n=new Fe({blocfeedId:t.blocfeed_id??"",...t.behavioral!==void 0?{config:t.behavioral}:{}});n.install();let o=Wn(),r=new Set,i=new Set,c=null,s=null,a=null,l=null,m=0,b=null,d=null,h=null,u=null,p=false,f=()=>{for(let y of r)y(o);},g=y=>{for(let S of i)S(y);},v=y=>{o=y,f();},C=()=>{m+=1,l?.abort(),l=null;},_=()=>{c?.stop(),c=null,g(null),a!==null&&T()&&(document.documentElement.style.cursor=a,a=null);},E=()=>{if(h){try{URL.revokeObjectURL(h.blobUrl);}catch{}h=null;}},z=()=>{d&&(d.abort(),d=null),E();},H=null,B=()=>{u&&(u.abort(),u=null),H&&(H.abort(),H=null);},M=()=>{C(),_(),z(),B(),s=null,v(Wn());},se=()=>{if(!T())return;_(),s=null;let y=ci(t.picker);a=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",v({phase:"picking"}),c=rn(y,{onHover:g,onSelect:({element:S,descriptor:L})=>{s=S,_(),v({phase:"review",selection:L});},onCancel:()=>{M();}});},ue=()=>{let y=nn();if(y.length!==0)for(let S of y)Tt({payload:S,...t.transport?{transport:t.transport}:{}}).catch(()=>{ht(S);});};if(T()){setTimeout(ue,1e3);let y=()=>ue();window.addEventListener("online",y),b=()=>window.removeEventListener("online",y);}return {getState:()=>o,getConfig:()=>t,subscribe(y){return r.add(y),()=>r.delete(y)},subscribeHover(y){return i.add(y),()=>i.delete(y)},start(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||o.phase!=="picking"&&se();},stop(){M();},clearSelection(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||se();},setConfig(y){t=y;},async submit(y,S){if(!T()){let F=k("configuration",new Error("BlocFeed submit can only run in the browser"));return v({phase:"error",lastError:F}),{ok:false}}let L=t.blocfeed_id?.trim?.()??"";if(!L){let A={phase:"error",lastError:k("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return o.selection&&(A.selection=o.selection),v(A),{ok:false}}if(p)return {ok:false};if(o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording")return {ok:false};p=true;let N=m+1;m=N,l?.abort(),l=new AbortController;let I=l.signal,R=o.selection,G=S?.capture?{...t.capture,...S.capture}:t.capture,te=!!(G?.element||G?.fullPage),ce={phase:te?"capturing":"submitting"};R&&(ce.selection=R),v(ce);try{let F=te?await en({selectionElement:s,capture:G,signal:I}):void 0;if(I.aborted||m!==N)return {ok:!1};let A={phase:"submitting"};R&&(A.selection=R),F&&(A.capture=F),v(A);let U={};R&&(U.selection=R),F&&(U.capture=F);let ne=await tn({config:t.metadata,context:U,...t.user?{user:t.user}:{}}),Q={version:1,createdAt:new Date().toISOString(),blocfeed_id:L,message:y,metadata:ne};S?.category&&(Q.category=S.category),t.user&&(Q.user=t.user),R&&(Q.selection=R),F&&(Q.screenshots=F),h&&(Q.video=h);let{result:j}=await Tt({payload:Q,signal:I,...t.transport?{transport:t.transport}:{}});if(I.aborted||m!==N)return j;if(j.ok){E(),s=null;let oe={phase:"success",lastSubmit:j};return R&&(oe.selection=R),F&&(oe.capture=F),v(oe),j}li(j)&&ht(Q);let lt=j.api?.error??k("unknown",new Error("Submission failed")),ye={phase:"error",lastSubmit:j,lastError:lt};return R&&(ye.selection=R),F&&(ye.capture=F),v(ye),j}catch(F){if(I.aborted||m!==N)return {ok:false};let U={phase:"error",lastError:I.aborted?k("aborted",F):k("unknown",F)};return R&&(U.selection=R),v(U),{ok:false}}finally{p=false,m===N&&(l=null);}},async startRecording(){if(o.phase!=="review"||!t.recording?.enabled||u||d)return;let y=o.selection,S={phase:"recording",recordingElapsedMs:0};y&&(S.selection=y),v(S);try{let L={config:t.recording};l&&(L.signal=l.signal);let N=await xt(L);d=N,N.onTick(G=>{if(o.phase==="recording"){let te={phase:"recording",recordingElapsedMs:G};y&&(te.selection=y),v(te);}});let I=await N.result;d=null,h=I;let R={phase:"review",video:I};y&&(R.selection=y),v(R);}catch(L){d=null;let I={phase:"review",lastError:L?.kind?L:k("recording_failed",L)};y&&(I.selection=y),v(I);}},stopRecording(){o.phase!=="recording"||!d||d.stop();},removeVideo(){E();let y=o.selection,S={phase:"review"};y&&(S.selection=y),v(S);},async startVoice(){if(o.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",o.phase,'(expected "review")');return}let y=t.voice;if(!y?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}if(d){console.warn("[BlocFeed] startVoice: ignored \u2014 a screen recording is already in progress");return}B();let S=o.selection,L={phase:"review",voiceRecording:true,voiceElapsedMs:0};S&&(L.selection=S),h&&(L.video=h),v(L);try{let N={config:y};l&&(N.signal=l.signal);let I=await kt(N);u=I,I.onTick(U=>{let ne={phase:"review",voiceRecording:!0,voiceElapsedMs:U};S&&(ne.selection=S),h&&(ne.video=h),v(ne);});let R=await I.result;u=null;let G={phase:"review",voiceRecording:!1,voiceTranscribing:!0};S&&(G.selection=S),h&&(G.video=h),v(G),H=new AbortController;let te={blob:R.blob,mime:R.mime,blocfeedId:t.blocfeed_id,signal:H.signal},{text:He,warning:ce}=await xn(te);H=null;let F={phase:"review",voiceRecording:!1,voiceTranscribing:!1};S&&(F.selection=S),h&&(F.video=h),v(F);let A={text:He};return ce&&(A.warning=ce),A}catch(N){B();let I=N?.kind?N:k("recording_failed",N);console.warn("[BlocFeed] Voice error:",I.message);let R={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:I};S&&(R.selection=S),h&&(R.video=h),v(R);return}},stopVoice(){u&&u.stop();},__unsafeGetSelectedElement(){return s},destroy(){n.uninstall(),M(),r.clear(),i.clear(),b?.(),b=null;}}}var Qe=react.createContext(null);function Pt(e){let t=react.useMemo(()=>qn({...e.config??{},blocfeed_id:e.blocfeed_id}),[]);react.useEffect(()=>{ke(e.blocfeed_id);},[e.blocfeed_id]);let[n,o]=react.useState(()=>t.getState());return react.useEffect(()=>t.subscribe(o),[t]),react.useEffect(()=>t.setConfig({...e.config??{},blocfeed_id:e.blocfeed_id}),[t,e.config,e.blocfeed_id]),react.useEffect(()=>()=>t.destroy(),[t]),jsxRuntime.jsx(Qe.Provider,{value:{controller:t,state:n},children:e.children})}var $n="blocfeed-styles-v1",mi=`
1
+ 'use strict';var react=require('react'),rrweb=require('rrweb'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),framerMotion=require('framer-motion');function T(){return typeof window<"u"&&typeof document<"u"}function Wt(e){let t=globalThis.CSS;return typeof t?.escape=="function"?t.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>{let o=n.codePointAt(0);return o===void 0?"":`\\${o.toString(16)} `})}function Ce(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Ho(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function Uo(e){return e.replace(/\s+/g," ").trim()}function re(e,t=140){let n=e.textContent;if(!n)return;let o=Uo(n);if(o)return o.length<=t?o:`${o.slice(0,t-1)}\u2026`}function zo(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var ut=["data-testid","data-test-id","data-test","data-qa","data-cy"],dt="data-blocfeed-component";function le(e){let t=e.closest(`[${dt}]`);if(!t)return;let o=t.getAttribute(dt)?.trim();return o||void 0}function we(e,t=5){let n=[],o=e,r=0;for(;o&&r<t*4;){let i=le(o);if(i&&n[n.length-1]!==i&&(n.push(i),n.length>=t))break;o=o.parentElement,r++;}return n}function xe(e,t=4){let n=e,o=0;for(;n&&o<t;){let i=n.getAttribute(dt)?.trim();if(i)return `bf:component:${i}`;for(let a of ut){let m=n.getAttribute(a)?.trim();if(m)return `bf:testid:${m}`}let s=n.getAttribute("id")?.trim();if(s&&!/^\d/.test(s))return `bf:id:${s}`;n=n.parentElement,o+=1;}return null}function Vo(e){for(let t of ut){let n=e.closest(`[${t}]`);if(!n)continue;let r=n.getAttribute(t)?.trim();if(r)return r}}function qt(e){try{let t=e,n=Object.getOwnPropertyNames(t);for(let o of n)if(o.startsWith("__reactFiber$")||o.startsWith("__reactInternalInstance$")){let r=t[o];if(r&&typeof r=="object")return r}}catch{}return null}function pe(e){if(e.length<=1||e.length===2&&e[0]===e[0].toLowerCase()||e.startsWith("__")&&e.endsWith("__"))return true;let t=e[0];return t>="a"&&t<="z"}function Te(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!pe(t.name))return t.name}}function X(e){if(e&&typeof e!="string"){if(typeof e=="function"){let t=e;return typeof t.displayName=="string"&&t.displayName?t.displayName:typeof t.name=="string"&&t.name?t.name:void 0}if(typeof e=="object"){let t=e,n=t.displayName;if(typeof n=="string"&&n)return n;let o=t.render;if(typeof o=="function"){let i=o;if(typeof i.displayName=="string"&&i.displayName)return i.displayName;if(typeof i.name=="string"&&i.name)return i.name}let r=t.type;return X(r)}}}function ft(e){let t=qt(e);if(!t)return;let n=Te(t._debugInfo);if(n)return n;let o=t._debugOwner!==void 0;if(o){let a=t._debugOwner;for(let l=0;a&&l<50;l+=1){let m=Te(a._debugInfo);if(m)return m;let b=X(a.type)??X(a.elementType);if(b&&!pe(b))return b;a=a._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let a=t._owner;for(let l=0;a&&l<50;l+=1){let m=Te(a._debugInfo);if(m)return m;let b=X(a.type)??X(a.elementType);if(b&&!pe(b))return b;a=a._owner;}}let i=t,c=o?80:25;for(let a=0;i&&a<c;a+=1){let l=Te(i._debugInfo);if(l)return l;let m=X(i.type)??X(i.elementType);if(m&&!pe(m))return m;i=i.return;}let s=e.parentElement;for(let a=0;s&&a<15;a+=1){let l=qt(s);if(l){let m=Te(l._debugInfo);if(m)return m;let b=X(l.type)??X(l.elementType);if(b&&!pe(b))return b;if(l._debugOwner){let d=X(l._debugOwner.type)??X(l._debugOwner.elementType);if(d&&!pe(d))return d}if(l._owner&&l._owner!==l._debugOwner){let d=X(l._owner.type)??X(l._owner.elementType);if(d&&!pe(d))return d}}s=s.parentElement;}}function Wo(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${Wt(n)}`;for(let o of ut){let r=e.getAttribute(o);if(r)return `${t}[${o}="${Wt(r)}"]`}return `${t}:nth-of-type(${zo(e)})`}function me(e,t=10){let n=[],o=e;for(;o&&n.length<t;){let r=Wo(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}var qo=new Set(["button","link","tab","menuitem"]);function Kt(e){if(e.tagName==="BUTTON")return e.disabled?null:"button";if(e.tagName==="A"||e.tagName==="a"){let n=e.getAttribute("href")?.trim();return !n||n==="#"||n.toLowerCase().startsWith("javascript:")?null:"link"}let t=e.getAttribute("role");if(t&&qo.has(t))return "role";try{if(window.getComputedStyle(e).cursor==="pointer")return "cursor_pointer"}catch{}return null}function $t(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function pt(e,t){if(!e||$t(e,t.ignoreSelectors))return null;let n=e;for(;n;){if($t(n,t.ignoreSelectors))return null;if(t.isSelectable?t.isSelectable(n):$o(n))return n;n=n.parentElement;}return null}function Ue(e,t){if(t.length===0)return false;for(let n of t)try{if(e.matches(n)||e.closest(n))return !0}catch{}return false}function $o(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function Xt(e){let t=e.getBoundingClientRect(),n={selector:me(e),tagName:e.tagName.toLowerCase(),rect:Ce(t),pageRect:Ho(t)},o=e.getAttribute("id");o&&(n.id=o);let r=e.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=re(e);i&&(n.textSnippet=i);let c=le(e)??ft(e);c&&(n.componentName=c);let s=Vo(e);return s&&(n.testId=s),n}function Ko(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function k(e,t,n){let o={kind:e,message:Ko(t)};return n&&(o.detail=n),o}var mt=null;async function jt(){return mt||(mt=import('html-to-image')),mt}async function Xo(e){return await new Promise((t,n)=>{let o=new Image;o.onload=()=>t({width:o.naturalWidth,height:o.naturalHeight}),o.onerror=()=>n(new Error("Failed to load generated screenshot")),o.src=e;})}async function Yt(e,t){let{width:n,height:o}=await Xo(e);return {dataUrl:e,mime:t,width:n,height:o}}function Ee(e){if(e?.aborted)throw new Error("Aborted")}function Gt(){return {async captureElement(e,t){if(!T())throw new Error("captureElement can only run in the browser");Ee(t.signal);let n=await jt();Ee(t.signal);let o=t.mime==="image/jpeg"?await n.toJpeg(e,{quality:t.quality??.92,pixelRatio:t.pixelRatio}):await n.toPng(e,{pixelRatio:t.pixelRatio});return Ee(t.signal),await Yt(o,t.mime)},async captureFullPage(e){if(!T())throw new Error("captureFullPage can only run in the browser");Ee(e.signal);let t=document.documentElement,n=Math.max(t.scrollWidth,t.clientWidth),o=Math.max(t.scrollHeight,t.clientHeight),r=Math.min(1,e.maxDimension/Math.max(n,o)),i=Math.max(1,Math.round(n*r)),c=Math.max(1,Math.round(o*r)),s=await jt();Ee(e.signal);let a=e.mime==="image/jpeg"?await s.toJpeg(t,{width:i,height:c,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await s.toPng(t,{width:i,height:c,pixelRatio:e.pixelRatio});return Ee(e.signal),await Yt(a,e.mime)}}}var jo=12e3,Yo=2048,Go=.92;function Jt(){return Date.now()}function Jo(e){return new Promise((t,n)=>{let o=()=>n(new Error("Aborted"));if(e.aborted){o();return}e.addEventListener("abort",o,{once:true});})}async function Qt(e,t,n){let o=new Promise((i,c)=>{let s=setTimeout(()=>c(new Error("Timeout")),t);typeof s.unref=="function"&&s.unref();}),r=[e,o];return n&&r.push(Jo(n)),await Promise.race(r)}function Qo(e){if(!T())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function Zo(e){return !!(e?.element||e?.fullPage)}function Zt(e){let t={mime:e.mime,pixelRatio:e.pixelRatio,maxDimension:e.maxDimension};return e.includeQuality&&(t.quality=e.quality),e.signal&&(t.signal=e.signal),t}async function en(e){let{selectionElement:t,capture:n,signal:o}=e;if(!T()||!Zo(n))return;let r=Jt(),i=[],c=n?.timeoutMs??jo,s=n?.maxDimension??Yo,a=n?.mime??"image/png",l=n?.quality??Go,m=n?.adapter??Gt(),b={},d=Qo(n);if(n?.element&&t)try{let p=t.getBoundingClientRect(),f=Math.min(1,s/Math.max(p.width,p.height)),g=Math.min(d,d*f),v=await Qt(Promise.resolve(m.captureElement(t,{...Zt({mime:a,quality:l,pixelRatio:g,maxDimension:s,includeQuality:a==="image/jpeg",...o?{signal:o}:{}})})),c,o);b.element=v;}catch(p){if(o?.aborted)throw p;i.push(k("capture_failed",p,{target:"element"}));}if(n?.fullPage)try{let p=await Qt(Promise.resolve(m.captureFullPage(Zt({mime:a,quality:l,pixelRatio:d,maxDimension:s,includeQuality:a==="image/jpeg",...o?{signal:o}:{}}))),c,o);b.fullPage=p;}catch(p){if(o?.aborted)throw p;i.push(k("capture_failed",p,{target:"fullPage"}));}let h=Jt(),u={startedAt:r,finishedAt:h,durationMs:Math.max(0,h-r)};return i.length>0&&(u.errors=i),{...b,diagnostics:u}}function er(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function tr(){return T()?{url:window.location.href,title:document.title,referrer:document.referrer||void 0,userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,viewport:{width:window.innerWidth,height:window.innerHeight},screen:{width:window.screen.width,height:window.screen.height},scroll:{x:window.scrollX,y:window.scrollY},devicePixelRatio:window.devicePixelRatio||1,timezone:er()}:{}}function nr(e){if(!e)return {};let t={};return e.id&&(t.userId=e.id),e.email&&(t.userEmail=e.email),e.name&&(t.userName=e.name),t}async function tn(e){let{config:t,context:n,user:o}=e;if(t?.enabled===false)return {};let r={...tr(),...nr(o)},i=t?.enrich;if(!i)return r;try{let c=await i(n);return {...r,...c}}catch(c){let s=k("unknown",c);return {...r,blocfeedMetadataError:s.message}}}var Re="blocfeed-queue",or=50;function gt(){if(!T())return [];try{let e=localStorage.getItem(Re);if(!e)return [];let t=JSON.parse(e);if(Array.isArray(t))return t;console.warn("[BlocFeed] offline queue was corrupt (non-array) \u2014 resetting");try{localStorage.removeItem(Re);}catch{}return []}catch(e){console.warn("[BlocFeed] offline queue could not be read \u2014 resetting",e);try{localStorage.removeItem(Re);}catch{}return []}}function bt(e){if(T())try{e.length===0?localStorage.removeItem(Re):localStorage.setItem(Re,JSON.stringify(e));}catch(t){let n=t instanceof DOMException?t.name:"";console.warn(`[BlocFeed] failed to persist offline queue${n?` (${n})`:""} \u2014 feedback may be lost if page is closed`);}}function rr(e){let t={...e};if(t.screenshots){let n={...t.screenshots};n.element&&(n.element={...n.element,dataUrl:""}),n.fullPage&&(n.fullPage={...n.fullPage,dataUrl:""}),t.screenshots=n;}return delete t.video,t}function ht(e){let t=gt(),n=rr(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>or;)t.shift();bt(t);}function nn(){let e=gt();return e.length===0?[]:(bt([]),e.map(t=>t.payload))}function za(){bt([]);}function on(){return gt().length}function vt(e){let t=null,n=null,o=(...r)=>{n=r,t===null&&(t=requestAnimationFrame(()=>{if(t=null,!n)return;let i=n;n=null,e(...i);}));};return o.cancel=()=>{t!==null&&cancelAnimationFrame(t),t=null,n=null;},o}function ze(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function Ve(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function rn(e,t){if(!T())throw new Error("BlocFeed picker can only run in a browser environment.");let n=e.ignoreSelectors,o=e.isSelectable,r={};n&&n.length>0&&(r.ignoreSelectors=n),o&&(r.isSelectable=o);let i=null,c=null,s=(u,p=false)=>{if(!u){i=null,c=null,t.onHover(null);return}let f=Ce(u.getBoundingClientRect()),g=`${Math.round(f.x)}:${Math.round(f.y)}:${Math.round(f.width)}:${Math.round(f.height)}`;!p&&u===i&&g===c||(i=u,c=g,t.onHover({element:u,rect:f}));},a=vt(u=>{if(ze(u.target))return;let p=document.elementFromPoint(u.clientX,u.clientY),f=pt(p,r);s(f);}),l=vt(()=>{i&&s(i,true);}),m=u=>{ze(u.target)||(Ve(u),u.pointerType==="mouse"&&u.preventDefault());},b=u=>{ze(u.target)||(Ve(u),u.pointerType==="mouse"&&u.preventDefault());},d=u=>{if(ze(u.target))return;Ve(u),u.preventDefault();let p=document.elementFromPoint(u.clientX,u.clientY),f=pt(p,r);f&&t.onSelect({element:f,descriptor:Xt(f)});},h=u=>{u.key==="Escape"&&(Ve(u),u.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",a,{capture:true,passive:true}),window.addEventListener("pointerdown",m,{capture:true}),window.addEventListener("pointerup",b,{capture:true}),window.addEventListener("click",d,{capture:true}),window.addEventListener("keydown",h,{capture:true}),window.addEventListener("scroll",l,{capture:true,passive:true}),window.addEventListener("resize",l,{passive:true}),{stop(){window.removeEventListener("pointermove",a,{capture:true}),window.removeEventListener("pointerdown",m,{capture:true}),window.removeEventListener("pointerup",b,{capture:true}),window.removeEventListener("click",d,{capture:true}),window.removeEventListener("keydown",h,{capture:true}),window.removeEventListener("scroll",l,{capture:true}),window.removeEventListener("resize",l),a.cancel(),l.cancel(),t.onHover(null);}}}var ir=200,Pe=[],an=0,We=false;function sn(e){let t=e.target;if(!(t instanceof Element)||t.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-an,path:window.location.pathname,tagName:t.tagName.toLowerCase()},o=re(t,100);o&&(n.textSnippet=o);let r=le(t)??ft(t);r&&(n.componentName=r),Pe.length<ir&&Pe.push(n);}var cn={capture:true,passive:true};function ln(){We||!T()||(We=true,Pe=[],an=Date.now(),document.addEventListener("click",sn,cn));}function dn(){We&&(We=false,document.removeEventListener("click",sn,cn));}function yt(){return [...Pe]}function ar(){Pe=[];}var sr=3e4,cr=25e5,un="video/webm",lr=250,dr=1e3,ur=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function fn(){if(typeof MediaRecorder>"u")return null;for(let e of ur)if(MediaRecorder.isTypeSupported(e))return e;return null}function wt(){return !T()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:fn()!==null}async function xt(e){let{config:t,signal:n}=e;if(!T()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw k("recording_failed",new Error("Screen recording is not supported in this browser"));let o=fn();if(!o)throw k("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw k("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(f){let g=f instanceof DOMException&&f.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw k("recording_failed",new Error(g))}if(n?.aborted)throw r.getTracks().forEach(f=>f.stop()),k("aborted",new Error("Recording aborted after permission"));let i=t?.maxDurationMs??sr,c=t?.videoBitsPerSecond??cr,s=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:c}),a=[],l=[],m=0,b=null,d=null,h=false,u=()=>{dn(),b!==null&&(clearInterval(b),b=null),d!==null&&(clearTimeout(d),d=null),r.getTracks().forEach(f=>f.stop());},p=new Promise((f,g)=>{s.ondataavailable=C=>{C.data.size>0&&a.push(C.data);},s.onstop=()=>{if(h)return;h=true,u();let C=Date.now()-m,_=new Blob(a,{type:un}),E=URL.createObjectURL(_);f({mime:un,blobUrl:E,blob:_,durationMs:C,sizeBytes:_.size});},s.onerror=()=>{h||(h=true,u(),g(k("recording_failed",new Error("MediaRecorder error"))));};let v=r.getVideoTracks()[0];if(v&&v.addEventListener("ended",()=>{s.state!=="inactive"&&s.stop();}),n){let C=()=>{h||(h=true,s.state!=="inactive"&&s.stop(),u(),g(k("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",C,{once:true});}});return s.start(dr),ln(),m=Date.now(),b=setInterval(()=>{let f=Date.now()-m;for(let g of l)g(f);},lr),d=setTimeout(()=>{!h&&s.state!=="inactive"&&s.stop();},i),{result:p,stop(){!h&&s.state!=="inactive"&&s.stop();},onTick(f){l.push(f);},abort(){h||(h=true,s.state!=="inactive"&&s.stop(),u());}}}var fr=6e4,pn="audio/webm",pr=250,mr=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function mn(){if(typeof MediaRecorder>"u")return null;for(let e of mr)if(MediaRecorder.isTypeSupported(e))return e;return null}function Et(){return !T()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:mn()!==null}async function kt(e){let{config:t,signal:n}=e;if(!T()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw k("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=mn();if(!o)throw k("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw k("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(p){let f=p instanceof DOMException&&p.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw k("recording_failed",new Error(f))}if(n?.aborted)throw r.getTracks().forEach(p=>p.stop()),k("aborted",new Error("Voice recording aborted after permission"));let i=t?.maxDurationMs??fr,c=new MediaRecorder(r,{mimeType:o}),s=[],a=[],l=0,m=null,b=null,d=false,h=()=>{m!==null&&(clearInterval(m),m=null),b!==null&&(clearTimeout(b),b=null),r.getTracks().forEach(p=>p.stop());},u=new Promise((p,f)=>{if(c.ondataavailable=g=>{g.data.size>0&&s.push(g.data);},c.onstop=()=>{if(d)return;d=true,h();let g=Date.now()-l,v=new Blob(s,{type:pn});p({blob:v,mime:pn,durationMs:g});},c.onerror=()=>{d||(d=true,h(),f(k("recording_failed",new Error("MediaRecorder error"))));},n){let g=()=>{d||(d=true,c.state!=="inactive"&&c.stop(),h(),f(k("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",g,{once:true});}});return c.start(1e3),l=Date.now(),m=setInterval(()=>{let p=Date.now()-l;for(let f of a)f(p);},pr),b=setTimeout(()=>{b=null,!d&&c.state!=="inactive"&&c.stop();},i),{result:u,stop(){!d&&c.state!=="inactive"&&c.stop();},onTick(p){a.push(p);},abort(){d||(d=true,c.state!=="inactive"&&c.stop(),h());}}}var gr=12e3,br=2,hr=500,vr=2e3,St="https://blocfeed.com/api/feedback",yr="https://blocfeed.com/api/feedback/voice",gn=0,vn="blocfeed-viewer-token",yn="blocfeed-my-feedback-url";function wr(){try{return localStorage.getItem(vn)}catch{return null}}function _t(){try{return localStorage.getItem(yn)}catch{return null}}function xr(e,t){try{localStorage.setItem(vn,e),t&&localStorage.setItem(yn,t);}catch{}}function bn(e,t){return new Promise((n,o)=>{if(t?.aborted){o(new Error("Aborted"));return}let r=setTimeout(n,e),i=()=>{clearTimeout(r),o(new Error("Aborted"));};t?.addEventListener("abort",i,{once:true});})}function Er(e){return e>=500&&e<=599}function kr(e){let[t,n]=e.split(",",2);if(!t||!n)throw new Error("Invalid data URL");let r=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(n),c=new Uint8Array(i.length);for(let s=0;s<i.length;s+=1)c[s]=i.charCodeAt(s);return new Blob([c],{type:r})}function Sr(e){let t={},n={},o={...e};if(o.screenshots){let r={},i={...o.screenshots};i.element&&(t.element=i.element.dataUrl,r.element={mime:i.element.mime,width:i.element.width,height:i.element.height},i.element={...i.element,dataUrl:""}),i.fullPage&&(t.fullPage=i.fullPage.dataUrl,r.fullPage={mime:i.fullPage.mime,width:i.fullPage.width,height:i.fullPage.height},i.fullPage={...i.fullPage,dataUrl:""}),o.screenshots=i,(r.element||r.fullPage)&&(o.screenshot_intent=r);}return o.video&&(n.blob=o.video.blob,o.video_intent={mime:o.video.mime,durationMs:o.video.durationMs,sizeBytes:o.video.sizeBytes},delete o.video),{lean:o,extracted:t,extractedVideo:n}}async function hn(e,t,n){let o=kr(t);await fetch(e,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function _r(e){let{feedbackId:t,extracted:n,screenshots:o,signal:r}=e,i={};n.element&&o?.element&&(i.element={dataUrl:n.element,mime:o.element.mime,width:o.element.width,height:o.element.height}),n.fullPage&&o?.fullPage&&(i.fullPage={dataUrl:n.fullPage,mime:o.fullPage.mime,width:o.fullPage.width,height:o.fullPage.height}),Object.keys(i).length!==0&&await fetch(`${St}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function Tr(e){await fetch(`${St}/${e.feedbackId}/video`,{method:"POST",body:e.blob,headers:{"content-type":e.blob.type},...e.signal?{signal:e.signal}:{}});}async function wn(e){let{signal:t,transport:n}=e;if(Date.now()-gn<vr)return {ok:false,error:k("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??gr,i=n?.maxAttempts??br,c=n?.backoffMs??hr,s=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),a=!!e.payload.video?.blob,l=s||a,{lean:m,extracted:b,extractedVideo:d}=l?Sr(e.payload):{lean:e.payload,extracted:{},extractedVideo:{}},h=wr();h&&(m.viewer_token=h);let u={...b,...e.screenshotDataUrls};for(let p=1;p<=i;p+=1){let f=new AbortController,g=setTimeout(()=>f.abort(),r),v=()=>f.abort();t&&t.addEventListener("abort",v,{once:true});try{let C=await fetch(St,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(m),signal:f.signal});if(C.ok){gn=Date.now();let E;try{E=await C.json();}catch{}if(E?.viewer_token&&xr(E.viewer_token,E.my_feedback_url),(u.element||u.fullPage)&&E){let F=E.upload_urls;if(F){let M=[];u.element&&F.element&&M.push(hn(F.element,u.element,t)),u.fullPage&&F.fullPage&&M.push(hn(F.fullPage,u.fullPage,t));try{await Promise.all(M);}catch{}}else if(E.feedback_id)try{await _r({feedbackId:E.feedback_id,extracted:u,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}if(d.blob&&E){let F=E.upload_urls;if(F?.video)try{await fetch(F.video,{method:"PUT",body:d.blob,headers:{"content-type":d.blob.type},...t?{signal:t}:{}});}catch{}else if(E.feedback_id)try{await Tr({feedbackId:E.feedback_id,blob:d.blob,...t?{signal:t}:{}});}catch{}}let H={ok:!0,status:C.status};return E&&(H.apiResponse=E),H}if(p<i&&Er(C.status)){let E=.85+Math.random()*.3,z=Math.round(c*2**(p-1)*E);await bn(z,t);continue}let _=`HTTP ${C.status}`;try{let E=await C.json();E?.error&&(_=E.error);}catch{}return {ok:!1,status:C.status,error:k("api_failed",new Error(_))}}catch(C){if(f.signal.aborted||t?.aborted)return {ok:false,error:k("aborted",C)};if(p<i){let _=.85+Math.random()*.3,E=Math.round(c*2**(p-1)*_);await bn(E,t);continue}return {ok:false,error:k("api_failed",C)}}finally{clearTimeout(g),t&&t.removeEventListener("abort",v);}}return {ok:false,error:k("api_failed",new Error("Failed"))}}async function xn(e){let{blob:t,mime:n,blocfeedId:o,signal:r}=e,i=await fetch(yr,{method:"POST",headers:{"Content-Type":n,"X-Blocfeed-Id":o},body:t,...r?{signal:r}:{}});if(!i.ok){let s=await i.json().catch(()=>({error:"Unknown error"}));throw k("api_failed",new Error(s?.error??`Voice API returned ${i.status}`))}let c=await i.json();return {text:c.text??"",warning:c.warning}}async function Tt(e){let{signal:t,transport:n}=e,o={ok:false};try{let r={payload:e.payload,...t?{signal:t}:{},...n?{transport:n}:{}};o.api=await wn(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:k("api_failed",r)},o.ok=false;}return {payload:e.payload,result:o}}var Cr={enabled:true,sampling:1,ignoreSelectors:["[data-blocfeed-ui]","[data-blocfeed-ignore]"],rageClick:{enabled:true,threshold:3,windowMs:1e3,streakIdleMs:1500},httpFail:{enabled:true,statusCodes:[400,401,403,404,408,409,422,429,500,502,503,504],ignoreUrls:["/api/behavioral-events","/api/feedback"],treatJsonErrorAsFail:false},redirectLoop:{enabled:true,threshold:3,windowMs:2e3},formDataLoss:{enabled:true},deadClick:{enabled:true,observationWindowMs:300,rateLimitPerSelector:5}};function En(e){let t=Cr;return {enabled:e?.enabled??t.enabled,sampling:e?.sampling??t.sampling,ignoreSelectors:e?.ignoreSelectors??t.ignoreSelectors,rageClick:{...t.rageClick,...e?.rageClick??{}},httpFail:{...t.httpFail,...e?.httpFail??{}},redirectLoop:{...t.redirectLoop,...e?.redirectLoop??{}},formDataLoss:{...t.formDataLoss,...e?.formDataLoss??{}},deadClick:{...t.deadClick,...e?.deadClick??{}}}}function kn(e){let t=[];async function n(){if(t.length===0)return;let r=t.splice(0,50);try{await fetch(e.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-blocfeed-id":e.blocfeedId},body:JSON.stringify({events:r}),keepalive:!0});}catch{}}function o(){if(t.length===0)return;if(typeof navigator>"u"||typeof navigator.sendBeacon!="function"){n();return}let r=t.splice(0,50),i=new Blob([JSON.stringify({events:r})],{type:"application/json"}),c=`${e.endpoint}?_bfid=${encodeURIComponent(e.blocfeedId)}`;try{navigator.sendBeacon(c,i);}catch{}}return {enqueue(r){t.push(r);},flush:n,flushBeacon:o,size(){return t.length}}}var Sn="bf_behavioral_session",qe=null;function D(){try{let e=sessionStorage.getItem(Sn);if(e)return e;let t=_n();return sessionStorage.setItem(Sn,t),t}catch{return qe||(qe=_n(),qe)}}function _n(){let e=Math.random().toString(36).slice(2,10).padEnd(8,"0");return `bf_${Date.now()}_${e}`}function $e(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return Math.abs(t)}function Tn(e,t){if(!e.rageClick.enabled)return ()=>{};let{threshold:n,windowMs:o,streakIdleMs:r}=e.rageClick,i=new Map;function c(b){let d=b.target,h=d?Rr(d):false,u=d?re(d,200)??null:null,p=d?d.tagName.toLowerCase():"",f=d&&d.id||null,g=d?le(d)??null:null,v=d?we(d,5):[];return {session_id:D(),event_type:"rage_click",page_url:typeof window>"u"?"":window.location.href,selector:b.selector,element_text:u,event_data:{click_count:b.timestamps.length,window_ms:o,final:true,...h?{disabled:true}:{},tag_name:p,...f?{element_id:f}:{},...g?{component_name:g}:{},...v.length>0?{parent_components:v}:{}},created_at:new Date().toISOString(),stable_key:b.stableKey}}function s(b){let d=i.get(b);d&&(d.idleTimer&&(clearTimeout(d.idleTimer),d.idleTimer=null),d.reached&&t(c(d)),i.delete(b));}function a(b){let d=i.get(b);d&&(d.idleTimer&&clearTimeout(d.idleTimer),d.idleTimer=setTimeout(()=>{s(b);},r));}function l(b){try{let d=b.target;if(!d||!(d instanceof Element)||Ue(d,e.ignoreSelectors))return;let h=me(d,4);if(!h)return;let u=xe(d),p=u??h,f=Date.now(),g=i.get(p);g?(g.target=d,g.selector=h):(g={selector:h,stableKey:u,timestamps:[],reached:!1,idleTimer:null,target:d},i.set(p,g)),g.reached||(g.timestamps=g.timestamps.filter(v=>f-v<=o)),g.timestamps.push(f),a(p),!g.reached&&g.timestamps.length>=n&&(g.reached=!0);}catch{}}function m(){for(let b of Array.from(i.keys()))s(b);}return document.addEventListener("click",l,{capture:true,passive:true}),typeof window<"u"&&window.addEventListener("pagehide",m),()=>{document.removeEventListener("click",l,{capture:true}),typeof window<"u"&&window.removeEventListener("pagehide",m);for(let b of i.values())b.idleTimer&&clearTimeout(b.idleTimer);i.clear();}}function Rr(e){if(e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true")return true;try{if(window.getComputedStyle(e).pointerEvents==="none")return !0}catch{}return false}var Cn=0,Rn=null,Xe=null,je=[],Pr=1500;function Fr(){function e(t){try{let n=t.target;if(!n)return;let o=n.closest('button[type="submit"], input[type="submit"], [data-blocfeed-submit]');if(!o)return;Cn=Date.now();let r=o.closest("form");Rn=(r?me(r,3):"")||null,Xe=re(o,100)??null,je=we(o,5);}catch{}}return document.addEventListener("click",e,{capture:true,passive:true}),()=>document.removeEventListener("click",e,{capture:true})}function Pn(e,t){if(!e.httpFail.enabled)return ()=>{};let{statusCodes:n,ignoreUrls:o,treatJsonErrorAsFail:r}=e.httpFail,i=new Set(n),c=Fr(),s=globalThis.fetch,a=async(d,h)=>{let u=typeof d=="string"?d:d instanceof URL?d.toString():d.url,p=(h?.method??d.method??"GET").toUpperCase(),f;try{f=await s.call(globalThis,d,h);}catch(g){try{if(!Ke(u,o)){let v=g&&typeof g=="object"&&g.name==="AbortError"?"abort":"network";t(b(0,u,p,v));}}catch{}throw g}try{if(!Ke(u,o)&&i.has(f.status))t(b(f.status,u,p));else if(r&&!Ke(u,o)&&f.status>=200&&f.status<300){let g=f.headers.get("content-type")??"";(g.includes("application/json")||g.includes("+json"))&&f.clone().json().then(v=>{if(Br(v))try{t(b(f.status,u,p,"json_error"));}catch{}}).catch(()=>{});}}catch{}return f};globalThis.fetch=a;let l=XMLHttpRequest.prototype.open,m=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(d,h,...u){return this.__bf_url=h,this.__bf_method=d.toUpperCase(),l.call(this,d,h,...u)},XMLHttpRequest.prototype.send=function(d){let h=()=>{try{let u=this.__bf_url??"",p=this.__bf_method??"GET";!Ke(u,o)&&i.has(this.status)&&t(b(this.status,u,p));}catch{}};return this.__bf_handler=h,this.addEventListener("loadend",h),m.call(this,d??null)},()=>{globalThis.fetch=s,XMLHttpRequest.prototype.open=l,XMLHttpRequest.prototype.send=m,c(),Xe=null,je=[];};function b(d,h,u,p){let g=Date.now()-Cn<Pr;return {session_id:D(),event_type:"error",page_url:typeof window>"u"?"":window.location.href,selector:null,element_text:null,event_data:{http_status:d,request_url:h,method:u,...p?{error_kind:p}:{},form_selector:g?Rn:null,...g&&Xe?{button_text:Xe}:{},...g&&je.length>0?{parent_components:je}:{}},created_at:new Date().toISOString(),stable_key:null}}}function Br(e){if(!e||typeof e!="object")return false;let t=e;return t.ok===false||t.success===false||"error"in t&&t.error!=null&&t.error!==false}function Ke(e,t){if(t.length===0)return false;for(let n of t)if(e.includes(n))return true;return false}var Ar=3e4;function Fn(e,t){if(!e.redirectLoop.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let{threshold:n,windowMs:o}=e.redirectLoop,r=new Map,i=new Map,c=history.pushState,s=history.replaceState;function a(m){try{let b=Date.now(),d=i.get(m)??0;if(b<d)return;let u=(r.get(m)??[]).filter(p=>b-p<=o);if(u.push(b),r.set(m,u),u.length>=n){let p={session_id:D(),event_type:"thrashing",page_url:window.location.href,selector:null,element_text:null,event_data:{count:u.length,url:m,window_ms:o},created_at:new Date().toISOString(),stable_key:null};t(p),i.set(m,b+Ar),r.set(m,[]);}}catch{}}function l(){let m=window.location.pathname+window.location.search;a(m);}return history.pushState=function(...m){let b=c.apply(this,m);return l(),b},history.replaceState=function(...m){let b=s.apply(this,m);return l(),b},window.addEventListener("popstate",l),()=>{history.pushState=c,history.replaceState=s,window.removeEventListener("popstate",l);}}var Mr=6e4;function Bn(e,t){if(!e.formDataLoss.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let n=new Set,o=new Map,r=new Map,i=new Map;function c(p){let f=p.closest("form");return f?f.id?`#${f.id}`:"form":null}function s(){let p=0;for(let f of o.values())p+=f;return p}function a(p){n.delete(p),o.delete(p),i.delete(p);}function l(p){try{let f=p.target;if(!f||!(f instanceof HTMLInputElement||f instanceof HTMLTextAreaElement||f instanceof HTMLSelectElement))return;let g=c(f);if(!g)return;n.add(g),o.set(g,(o.get(g)??0)+1);let v=f.closest("form");v&&i.set(g,v);}catch{}}function m(p){try{let f=p.target;if(!f||!(f instanceof HTMLFormElement))return;let g=f.id?`#${f.id}`:"form";r.set(g,Date.now()),a(g);}catch{}}function b(p){try{let f=p.target;if(!f||!(f instanceof HTMLFormElement))return;let g=f.id?`#${f.id}`:"form";a(g);}catch{}}function d(p){if(n.size===0)return;let f=Array.from(n),g=f[0]??null,v=g?i.get(g)??null:null,C=v?xe(v):null,_={session_id:D(),event_type:"form_abandonment",page_url:window.location.href,selector:g,element_text:null,event_data:{cause:p,field_count:s(),forms:f},created_at:new Date().toISOString(),stable_key:C};t(_);}function h(p){if(!p.persisted||n.size===0)return;let f=Date.now();for(let[,g]of r)if(f-g<Mr)return;d("bfcache_restore");}function u(){d("beforeunload_after_edit");}return document.addEventListener("input",l,{capture:true,passive:true}),document.addEventListener("submit",m,{capture:true}),document.addEventListener("reset",b,{capture:true}),window.addEventListener("pageshow",h),window.addEventListener("beforeunload",u),()=>{document.removeEventListener("input",l,{capture:true}),document.removeEventListener("submit",m,{capture:true}),document.removeEventListener("reset",b,{capture:true}),window.removeEventListener("pageshow",h),window.removeEventListener("beforeunload",u);}}function Ir(){let e={urlChangeCount:0,networkCount:0,filePickerCount:0,uninstall:()=>{}},t=history.pushState,n=history.replaceState;history.pushState=function(...s){return e.urlChangeCount+=1,t.apply(this,s)},history.replaceState=function(...s){return e.urlChangeCount+=1,n.apply(this,s)};let o=()=>{e.urlChangeCount+=1;};window.addEventListener("popstate",o);let r=globalThis.fetch;if(r){let s=(a,l)=>(e.networkCount+=1,r.call(globalThis,a,l));globalThis.fetch=s;}let i=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(s,a,...l){return e.networkCount+=1,i.call(this,s,a,...l)};let c=HTMLInputElement.prototype.click;return HTMLInputElement.prototype.click=function(){return this.type==="file"&&(e.filePickerCount+=1),c.call(this)},e.uninstall=()=>{history.pushState=t,history.replaceState=n,window.removeEventListener("popstate",o),r&&(globalThis.fetch=r),XMLHttpRequest.prototype.open=i,HTMLInputElement.prototype.click=c;},e}function An(e,t){if(!e.deadClick.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let{observationWindowMs:n,rateLimitPerSelector:o}=e.deadClick,r=new Map,i=Ir();function c(s){try{let a=s.target;if(!a||!(a instanceof Element)||s.button!==0||s.metaKey||s.ctrlKey||s.altKey||s.shiftKey||Ue(a,e.ignoreSelectors)||a.closest("label"))return;if(a instanceof HTMLInputElement){let M=a.type;if(M==="checkbox"||M==="radio"||M==="file")return}if(a instanceof HTMLSelectElement||a.closest("a[target='_blank'], a[download]")||a.closest('[contenteditable="true"]'))return;try{let M=window.getSelection();if(M&&M.toString().length>0)return}catch{}let l=Kt(a);if(!l)return;let m=me(a,4);if(!m)return;let b=xe(a),d=b??m,h=i.urlChangeCount,u=i.networkCount,p=i.filePickerCount,f=new Date().toISOString(),g=re(a,200)??null,v=a.tagName.toLowerCase(),C=a.id||null,_=le(a)??null,E=we(a,5),z=Lr(a),H=0,F=null;if(z){F=new MutationObserver(()=>{H+=1;});try{F.observe(z,{childList:!0,attributes:!0,characterData:!0,subtree:!0});}catch{F=null;}}setTimeout(()=>{if(F)try{F.disconnect();}catch{}if(H>0||i.urlChangeCount!==h||i.networkCount!==u||i.filePickerCount!==p)return;let M=r.get(d)??0;if(M>=o)return;r.set(d,M+1);let se={session_id:D(),event_type:"dead_click",page_url:typeof window>"u"?"":window.location.href,selector:m,element_text:g,event_data:{tag_name:v,...C?{element_id:C}:{},..._?{component_name:_}:{},...E.length>0?{parent_components:E}:{},clickable_reason:l},created_at:f,stable_key:b};t(se);},n);}catch{}}return document.addEventListener("click",c,{capture:true,passive:true}),()=>{document.removeEventListener("click",c,{capture:true}),i.uninstall();}}function Lr(e){let t=e.closest('button, a, form, [role="button"]');return t||e.parentElement}var Dr="https://blocfeed.com/api/replay-events";function Mn(e){if(!e.config.enabled)return ()=>{};if(typeof window>"u")return ()=>{};if(typeof globalThis.matchMedia>"u")return ()=>{};let t=D();if($e(t)%100/100>=e.config.sampling)return ()=>{};let o=Date.now(),r=e.config.endpoint??Dr,i=[],c=0,s=false,a=false,l=null,m=`bf_replay_chunkseq_${t}`,b=`bf_replay_pauses_${t}`,d=0,h=0;try{let y=sessionStorage.getItem(m);y&&(d=parseInt(y,10)||0);let S=sessionStorage.getItem(b);S&&(h=parseInt(S,10)||0);}catch{}let u=(y=false)=>{if(i.length===0)return;let S=y?Hr(i):i;i=[],c=0;let L=d++;try{sessionStorage.setItem(m,String(d));}catch{}Ur({blocfeedId:e.blocfeedId,sessionId:t,sessionStartedAtMs:o,chunkSeq:L,events:S,endpoint:r,useBeacon:y,pauseCount:h});},p=setInterval(()=>{s||u();},e.config.flushIntervalMs),f=setTimeout(()=>{u(),ue();},e.config.maxDurationMs),g=null,v=()=>{g&&clearTimeout(g),g=setTimeout(()=>{M();},e.config.inactivityTimeoutMs);},C=()=>{u(true);};window.addEventListener("pagehide",C);let _=e.config.masking,E={emit(y){s||(i.push(y),c+=Or(y),v(),c>=e.config.flushSizeBytes&&u());},recordCanvas:false,sampling:{mousemove:50}};_.maskAllInputs!==void 0&&(E.maskAllInputs=_.maskAllInputs),_.maskTextSelector!==void 0&&(E.maskTextSelector=_.maskTextSelector),_.maskTextClass!==void 0&&(E.maskTextClass=_.maskTextClass),_.blockSelector!==void 0&&(E.blockSelector=_.blockSelector);let z=null,H=()=>{z&&(document.removeEventListener("pointerdown",z,true),document.removeEventListener("keydown",z,true),z=null);};function F(){l=rrweb.record(E)??null;}function M(){if(s||a)return;a=true,h++;try{sessionStorage.setItem(b,String(h));}catch{}if(u(),l){try{l();}catch{}l=null;}g&&(clearTimeout(g),g=null);let y=()=>{H(),se();};z=y,document.addEventListener("pointerdown",y,{capture:true,once:true}),document.addEventListener("keydown",y,{capture:true,once:true});}function se(){s||!a||(a=false,F(),v());}v(),F();function ue(){if(!s&&(s=true,clearInterval(p),clearTimeout(f),g&&clearTimeout(g),H(),window.removeEventListener("pagehide",C),l)){try{l();}catch{}l=null;}}return ue}function Or(e){try{return JSON.stringify(e).length}catch{return 1024}}function Hr(e){let n=JSON.stringify(e);if(n.length<=6e4)return e;let o=[...e];for(;o.length>1;)if(o.shift(),n=JSON.stringify(o),n.length<=6e4)return o;return o}async function Ur(e){let t=JSON.stringify({blocfeed_id:e.blocfeedId,session_id:e.sessionId,session_started_at_ms:e.sessionStartedAtMs,chunk_seq:e.chunkSeq,pause_count:e.pauseCount,events:e.events,page_url:typeof window<"u"?window.location.href:"",user_agent:typeof navigator<"u"?navigator.userAgent:""});if(e.useBeacon&&typeof navigator<"u"&&typeof navigator.sendBeacon=="function")try{let o=new Blob([t],{type:"application/json"});navigator.sendBeacon(e.endpoint,o);return}catch{}let n=!!e.useBeacon;try{await fetch(e.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:t,...n?{keepalive:!0}:{}});}catch{}}var zr={enabled:true,endpoint:null,maxDurationMs:144e5,flushIntervalMs:3e4,flushSizeBytes:1048576,inactivityTimeoutMs:18e5,sampling:1,masking:{maskAllInputs:true,maskTextSelector:"[data-blocfeed-mask]",maskTextClass:"blocfeed-mask",blockSelector:"[data-blocfeed-block]"}};function In(e){let t=zr;return {enabled:e?.enabled??t.enabled,endpoint:e?.endpoint??t.endpoint,maxDurationMs:e?.maxDurationMs??t.maxDurationMs,flushIntervalMs:e?.flushIntervalMs??t.flushIntervalMs,flushSizeBytes:e?.flushSizeBytes??t.flushSizeBytes,inactivityTimeoutMs:e?.inactivityTimeoutMs??t.inactivityTimeoutMs,sampling:e?.sampling??t.sampling,masking:{...t.masking,...e?.masking??{}}}}var Vr="https://blocfeed.com/api/events/track",Wr=5e3,qr=50,$r=1024,Je="blocfeed-events-queue",Ln=500,Nn=100,Kr=/^[a-z][a-z0-9_]{0,127}$/,Dn=50,On=1024,Hn;function Un(e){Hn=e;}function Xr(e){if(typeof e!="string"||!Kr.test(e))throw new Error(`[BlocFeed] track(): event_name "${e}" must match /^[a-z][a-z0-9_]{0,127}$/ (lowercase, start with a letter, only [a-z0-9_], \u2264128 chars).`)}function jr(e){if(e===void 0)return {};if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("[BlocFeed] track(): properties must be a plain object.");let t=Object.keys(e);if(t.length>Dn)throw new Error(`[BlocFeed] track(): properties has ${t.length} keys, max ${Dn}.`);for(let o of t){let r=e[o];if(r!==null&&typeof r!="string"&&typeof r!="number"&&typeof r!="boolean")throw new Error(`[BlocFeed] track(): property "${o}" has unsupported type "${typeof r}". Allowed: string | number | boolean | null.`)}let n;try{n=JSON.stringify(e);}catch(o){throw new Error(`[BlocFeed] track(): properties is not JSON-serializable (${o.message}).`)}if(n.length>On)throw new Error(`[BlocFeed] track(): properties serialized to ${n.length} bytes, max ${On}. Server allows 8192 bytes \u2014 the client cap is defensive; trim down or split the event.`);return e}function Ct(){if(typeof localStorage>"u")return [];try{let e=localStorage.getItem(Je);if(!e)return [];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{try{localStorage.removeItem(Je);}catch{}return []}}function Rt(e){if(!(typeof localStorage>"u"))try{if(e.length===0)localStorage.removeItem(Je);else {let t=e.length>Ln?e.slice(e.length-Ln):e;localStorage.setItem(Je,JSON.stringify(t));}}catch{}}var Y=null;function Yr(){if(Y)return Y;if(typeof window>"u")return null;let e=Gr();return e?(Y={blocfeedId:e,endpoint:Vr,events:[],bytes:0,flushTimer:null,pageHideHandler:null,visibilityHandler:null},Y.flushTimer=setInterval(()=>{Ge(false);},Wr),Y.pageHideHandler=()=>{Ge(true);},Y.visibilityHandler=()=>{document.visibilityState==="hidden"&&Ge(true);},window.addEventListener("pagehide",Y.pageHideHandler),document.addEventListener("visibilitychange",Y.visibilityHandler),Y):null}function Gr(){try{let t=window.__blocfeed_id__;return typeof t=="string"&&t.length>0?t:null}catch{return null}}function ke(e){try{window.__blocfeed_id__=e;}catch{}Y&&(Y.blocfeedId=e);}function Fe(e,t,n){Xr(e);let o=jr(t),r=n?.occurredAt?ti(n.occurredAt):new Date().toISOString(),i={event_name:e,properties:o,occurred_at:r},c=n?.sessionId??Qr();c&&(i.session_id=c);let s=n?.userId??Hn;s&&(i.user_id=s);let a=n?.pageUrl??Zr();a&&(i.page_url=a);let l=ei();l&&(i.user_agent=l);let m=Yr();if(!m){let b=Ct();b.push(i),Rt(b);return}m.events.push(i),m.bytes+=Jr(i),(m.events.length>=qr||m.bytes>=$r)&&Ge(false);}async function Ge(e){let t=Y;if(!t)return;let o=Ct().concat(t.events);if(t.events=[],t.bytes=0,Rt([]),o.length!==0)for(let r=0;r<o.length;r+=Nn){let i=o.slice(r,r+Nn),c=JSON.stringify({blocfeed_id:t.blocfeedId,events:i});if(e&&ni())try{let s=new Blob([c],{type:"application/json"});navigator.sendBeacon(t.endpoint,s)||Ye(i);continue}catch{Ye(i);continue}try{(await fetch(t.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:c})).ok||Ye(i);}catch{Ye(i);}}}function Ye(e){let t=Ct();Rt(t.concat(e));}function Jr(e){try{return JSON.stringify(e).length}catch{return 256}}function Qr(){try{return D()}catch{return}}function Zr(){try{return typeof window<"u"?window.location.href:void 0}catch{return}}function ei(){try{return typeof navigator<"u"?navigator.userAgent:void 0}catch{return}}function ti(e){return e instanceof Date?e.toISOString():new Date(e).toISOString()}function ni(){return typeof navigator<"u"&&typeof navigator.sendBeacon=="function"}var oi="https://blocfeed.com/api/heartbeat",ri=300*1e3;function zn(e){if(typeof window>"u")return ()=>{};if(typeof globalThis.matchMedia>"u")return ()=>{};let t=e.endpoint??oi,n=e.intervalMs??ri,o=e.features??["replay","behavioral","customEvents"],r=s=>{try{let a=JSON.stringify({blocfeed_id:e.blocfeedId,session_id:ii(),version:e.version,page_url:typeof window<"u"?window.location.href:"",user_agent:typeof navigator<"u"?navigator.userAgent:"",sdk_features:o}),l={method:"POST",headers:{"Content-Type":"application/json"},body:a};s&&(l.keepalive=!0),fetch(t,l).catch(()=>{});}catch{}};try{r(!1);}catch{}let i=null;try{i=setInterval(()=>{try{r(!1);}catch{}},n);}catch{i=null;}let c=()=>{try{r(!0);}catch{}};try{window.addEventListener("pagehide",c);}catch{}return function(){try{i&&clearInterval(i);}catch{}i=null;try{window.removeEventListener("pagehide",c);}catch{}}}function ii(){try{return D()}catch{return ""}}var ai=5e3,Be=class{constructor(t){this.submitter=null;this.detectorUninstallers=[];this.flushTimer=null;this.pageHideHandler=null;this.installed=false;this.opts=t,this.resolved=En(t.config);}install(){if(this.installed||!this.resolved.enabled)return;let t=()=>{try{let s=D();return $e(s)%100/100<this.resolved.sampling}catch{return false}};if(!(this.opts.passiveSampler??t)())return;ke(this.opts.blocfeedId);let o=this.opts.endpoint??"https://blocfeed.com/api/behavioral-events";this.submitter=this.opts.submitter??kn({endpoint:o,blocfeedId:this.opts.blocfeedId});let r=s=>{this.submitter?.enqueue(s);};this.detectorUninstallers.push(Tn(this.resolved,r)),this.detectorUninstallers.push(Pn(this.resolved,r)),this.detectorUninstallers.push(Fn(this.resolved,r)),this.detectorUninstallers.push(Bn(this.resolved,r)),this.detectorUninstallers.push(An(this.resolved,r));let i=In(this.opts.config?.sessionReplay);this.detectorUninstallers.push(Mn({blocfeedId:this.opts.blocfeedId,config:i}));let c=["behavioral","customEvents"];if(i.enabled&&c.unshift("replay"),this.opts.extraSdkFeatures)for(let s of this.opts.extraSdkFeatures)c.push(s);this.detectorUninstallers.push(zn({blocfeedId:this.opts.blocfeedId,version:Vn,features:c})),this.flushTimer=setInterval(()=>{this.submitter?.flush();},ai),this.pageHideHandler=()=>{this.submitter?.flushBeacon();},typeof window<"u"&&window.addEventListener("pagehide",this.pageHideHandler),this.installed=true;}uninstall(){if(this.installed){for(let t of [...this.detectorUninstallers].reverse())try{t();}catch{}this.detectorUninstallers=[],this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.pageHideHandler&&typeof window<"u"&&(window.removeEventListener("pagehide",this.pageHideHandler),this.pageHideHandler=null);try{this.submitter?.flush();}catch{}this.submitter=null,this.installed=false;}}};var si=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function ci(e){let t=[...si,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function Wn(){return {phase:"idle"}}function li(e){if(e.ok)return false;let t=e.api;return t?t.status&&t.status>=400&&t.status<500||t.error?.kind==="aborted"||t.error?.kind==="configuration"?false:!t.ok:true}function qn(e){let t=e,n=new Be({blocfeedId:t.blocfeed_id??"",...t.behavioral!==void 0?{config:t.behavioral}:{}});n.install();let o=Wn(),r=new Set,i=new Set,c=null,s=null,a=null,l=null,m=0,b=null,d=null,h=null,u=null,p=false,f=()=>{for(let y of r)y(o);},g=y=>{for(let S of i)S(y);},v=y=>{o=y,f();},C=()=>{m+=1,l?.abort(),l=null;},_=()=>{c?.stop(),c=null,g(null),a!==null&&T()&&(document.documentElement.style.cursor=a,a=null);},E=()=>{if(h){try{URL.revokeObjectURL(h.blobUrl);}catch{}h=null;}},z=()=>{d&&(d.abort(),d=null),E();},H=null,F=()=>{u&&(u.abort(),u=null),H&&(H.abort(),H=null);},M=()=>{C(),_(),z(),F(),s=null,v(Wn());},se=()=>{if(!T())return;_(),s=null;let y=ci(t.picker);a=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",v({phase:"picking"}),c=rn(y,{onHover:g,onSelect:({element:S,descriptor:L})=>{s=S,_(),v({phase:"review",selection:L});},onCancel:()=>{M();}});},ue=()=>{let y=nn();if(y.length!==0)for(let S of y)Tt({payload:S,...t.transport?{transport:t.transport}:{}}).catch(()=>{ht(S);});};if(T()){setTimeout(ue,1e3);let y=()=>ue();window.addEventListener("online",y),b=()=>window.removeEventListener("online",y);}return {getState:()=>o,getConfig:()=>t,subscribe(y){return r.add(y),()=>r.delete(y)},subscribeHover(y){return i.add(y),()=>i.delete(y)},start(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||o.phase!=="picking"&&se();},stop(){M();},clearSelection(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||se();},setConfig(y){t=y;},async submit(y,S){if(!T()){let B=k("configuration",new Error("BlocFeed submit can only run in the browser"));return v({phase:"error",lastError:B}),{ok:false}}let L=t.blocfeed_id?.trim?.()??"";if(!L){let A={phase:"error",lastError:k("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return o.selection&&(A.selection=o.selection),v(A),{ok:false}}if(p)return {ok:false};if(o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording")return {ok:false};p=true;let N=m+1;m=N,l?.abort(),l=new AbortController;let I=l.signal,R=o.selection,G=S?.capture?{...t.capture,...S.capture}:t.capture,te=!!(G?.element||G?.fullPage),ce={phase:te?"capturing":"submitting"};R&&(ce.selection=R),v(ce);try{let B=te?await en({selectionElement:s,capture:G,signal:I}):void 0;if(I.aborted||m!==N)return {ok:!1};let A={phase:"submitting"};R&&(A.selection=R),B&&(A.capture=B),v(A);let U={};R&&(U.selection=R),B&&(U.capture=B);let ne=await tn({config:t.metadata,context:U,...t.user?{user:t.user}:{}}),Q={version:1,createdAt:new Date().toISOString(),blocfeed_id:L,message:y,metadata:ne};S?.category&&(Q.category=S.category),t.user&&(Q.user=t.user),R&&(Q.selection=R),B&&(Q.screenshots=B),h&&(Q.video=h);let{result:j}=await Tt({payload:Q,signal:I,...t.transport?{transport:t.transport}:{}});if(I.aborted||m!==N)return j;if(j.ok){E(),s=null;let oe={phase:"success",lastSubmit:j};return R&&(oe.selection=R),B&&(oe.capture=B),v(oe),j}li(j)&&ht(Q);let lt=j.api?.error??k("unknown",new Error("Submission failed")),ye={phase:"error",lastSubmit:j,lastError:lt};return R&&(ye.selection=R),B&&(ye.capture=B),v(ye),j}catch(B){if(I.aborted||m!==N)return {ok:false};let U={phase:"error",lastError:I.aborted?k("aborted",B):k("unknown",B)};return R&&(U.selection=R),v(U),{ok:false}}finally{p=false,m===N&&(l=null);}},async startRecording(){if(o.phase!=="review"||!t.recording?.enabled||u||d)return;let y=o.selection,S={phase:"recording",recordingElapsedMs:0};y&&(S.selection=y),v(S);try{let L={config:t.recording};l&&(L.signal=l.signal);let N=await xt(L);d=N,N.onTick(G=>{if(o.phase==="recording"){let te={phase:"recording",recordingElapsedMs:G};y&&(te.selection=y),v(te);}});let I=await N.result;d=null,h=I;let R={phase:"review",video:I};y&&(R.selection=y),v(R);}catch(L){d=null;let I={phase:"review",lastError:L?.kind?L:k("recording_failed",L)};y&&(I.selection=y),v(I);}},stopRecording(){o.phase!=="recording"||!d||d.stop();},removeVideo(){E();let y=o.selection,S={phase:"review"};y&&(S.selection=y),v(S);},async startVoice(){if(o.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",o.phase,'(expected "review")');return}let y=t.voice;if(!y?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}if(d){console.warn("[BlocFeed] startVoice: ignored \u2014 a screen recording is already in progress");return}F();let S=o.selection,L={phase:"review",voiceRecording:true,voiceElapsedMs:0};S&&(L.selection=S),h&&(L.video=h),v(L);try{let N={config:y};l&&(N.signal=l.signal);let I=await kt(N);u=I,I.onTick(U=>{let ne={phase:"review",voiceRecording:!0,voiceElapsedMs:U};S&&(ne.selection=S),h&&(ne.video=h),v(ne);});let R=await I.result;u=null;let G={phase:"review",voiceRecording:!1,voiceTranscribing:!0};S&&(G.selection=S),h&&(G.video=h),v(G),H=new AbortController;let te={blob:R.blob,mime:R.mime,blocfeedId:t.blocfeed_id,signal:H.signal},{text:He,warning:ce}=await xn(te);H=null;let B={phase:"review",voiceRecording:!1,voiceTranscribing:!1};S&&(B.selection=S),h&&(B.video=h),v(B);let A={text:He};return ce&&(A.warning=ce),A}catch(N){F();let I=N?.kind?N:k("recording_failed",N);console.warn("[BlocFeed] Voice error:",I.message);let R={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:I};S&&(R.selection=S),h&&(R.video=h),v(R);return}},stopVoice(){u&&u.stop();},__unsafeGetSelectedElement(){return s},destroy(){n.uninstall(),M(),r.clear(),i.clear(),b?.(),b=null;}}}var Qe=react.createContext(null);function Pt(e){let t=react.useMemo(()=>qn({...e.config??{},blocfeed_id:e.blocfeed_id}),[]);react.useEffect(()=>{ke(e.blocfeed_id);},[e.blocfeed_id]);let[n,o]=react.useState(()=>t.getState());return react.useEffect(()=>t.subscribe(o),[t]),react.useEffect(()=>t.setConfig({...e.config??{},blocfeed_id:e.blocfeed_id}),[t,e.config,e.blocfeed_id]),react.useEffect(()=>()=>t.destroy(),[t]),jsxRuntime.jsx(Qe.Provider,{value:{controller:t,state:n},children:e.children})}var $n="blocfeed-styles-v1",mi=`
2
2
  :where([data-blocfeed-ui-root]),
3
3
  :where([data-blocfeed-ui-root]) * {
4
4
  box-sizing: border-box;
@@ -880,5 +880,5 @@
880
880
  animation: none;
881
881
  }
882
882
  }
883
- `;function Kn(){if(!T()||document.getElementById($n))return;let e=document.createElement("style");e.id=$n,e.textContent=mi,document.head.appendChild(e);}var Ae=[],Me=[],Xn=20,jn=15,et=[],Yn=typeof console<"u"?{log:console.log?.bind(console),warn:console.warn?.bind(console),error:console.error?.bind(console),info:console.info?.bind(console),debug:console.debug?.bind(console)}:{},tt=typeof globalThis<"u"&&typeof globalThis.fetch=="function"?globalThis.fetch:void 0,nt=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.open:void 0,ot=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.send:void 0,Ft=new Set,At=false,Mt=false,rt=false,gi=["blocfeed.com","google-analytics.com","googletagmanager.com","analytics.google.com","googleads.g.doubleclick.net","googlesyndication.com","googleadservices.com","google.com/pagead","google.com/ads","facebook.net","facebook.com/tr","connect.facebook.net","graph.facebook.com","api.mixpanel.com","api-js.mixpanel.com","api.amplitude.com","api2.amplitude.com","api.segment.io","cdn.segment.com","vars.hotjar.com","in.hotjar.com","script.hotjar.com","heapanalytics.com","fullstory.com/s/fs.js","rs.fullstory.com","app.posthog.com","us.posthog.com","eu.posthog.com","api-iam.intercom.io","widget.intercom.io","sentry.io/api","browser.sentry-cdn.com","browser-intake-datadoghq.com","clarity.ms","js.hs-analytics.net","api.hubapi.com","forms.hubspot.com","plausible.io/api","client.crisp.chat","js.driftt.com","r.logrocket.com","app.pendo.io","events.launchdarkly.com","app.launchdarkly.com","grammarly.com","gnar.grammarly.com","capi.grammarly.com","api.languagetool.org","api.languagetoolplus.com","fonts.googleapis.com","fonts.gstatic.com","cdn.cookielaw.org","consent.cookiebot.com","js.stripe.com","api.stripe.com/v1/tokens","google.com/recaptcha","hcaptcha.com","bam.nr-data.net","rec.smartlook.com","o2.mouseflow.com","api.luckyorange.com","static.zdassets.com","ekr.zdassets.com"];function bi(e){if(e instanceof Error)return e.name&&e.name!=="Error"?`${e.name}: ${e.message}`:e.message||String(e);if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function hi(e,t){let n=t.map(bi).join(" "),o=t.find(i=>i instanceof Error),r={level:e,message:n.slice(0,2e3),timestamp:Date.now()};for(o?.stack&&(r.stack=o.stack.slice(0,2e3)),Ae.push(r);Ae.length>Xn;)Ae.shift();}function Bt(e){let t=e.url.toLowerCase();for(let n of et)if(t.includes(n))return;for(Me.push(e);Me.length>jn;)Me.shift();}function Gn(e={}){if(rt||!T())return;rt=true,Xn=e.consoleLimit??20,jn=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?et=t.map(n=>n.toLowerCase()):et=[...gi],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let o of n){let r=Yn[o];r&&(Ft.add(o),console[o]=(...i)=>{hi(o,i),r.apply(console,i);});}}if(e.network!==false&&tt){let n=tt;At=true,window.fetch=async function(r,i){let c=typeof r=="string"?r:r instanceof URL?r.toString():r.url,s=(i?.method??"GET").toUpperCase(),a=Date.now();try{let l=await n.call(window,r,i);return l.ok||Bt({url:c.slice(0,500),method:s,status:l.status,statusText:l.statusText,timestamp:a,durationMs:Date.now()-a}),l}catch(l){throw Bt({url:c.slice(0,500),method:s,status:0,statusText:l instanceof Error?l.message:"Network error",timestamp:a,durationMs:Date.now()-a}),l}};}if(e.network!==false&&nt&&ot){let n=nt,o=ot;Mt=true,XMLHttpRequest.prototype.open=function(r,i,...c){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...c])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",c=this.__bf_url||"",s=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let a={url:c.slice(0,500),method:i,status:this.status,timestamp:s,durationMs:Date.now()-s};this.statusText&&(a.statusText=this.statusText),Bt(a);}},{once:true}),o.apply(this,r)};}}function Jn(){if(rt){for(let e of Ft){let t=Yn[e];t&&(console[e]=t);}Ft.clear(),At&&tt&&(window.fetch=tt,At=false),Mt&&nt&&ot&&(XMLHttpRequest.prototype.open=nt,XMLHttpRequest.prototype.send=ot,Mt=false),et=[],rt=false;}}function Qn(){return {consoleLogs:[...Ae],networkErrors:[...Me]}}function xc(){Ae=[],Me=[];}var vi=[{name:"supabase_service_role_key",pattern:/SUPABASE_SERVICE_ROLE_KEY["'=:\s]{1,8}[A-Za-z0-9_.=-]{30,400}/},{name:"supabase_db_password",pattern:/SUPABASE_DB_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"postgres_password",pattern:/POSTGRES_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"database_url_with_creds",pattern:/(?:postgres|postgresql|mysql|mongodb|redis|amqp):\/\/[^:\s"']{1,100}:[^@\s"']{1,200}@/},{name:"aws_access_key",pattern:/AKIA[0-9A-Z]{16}/},{name:"aws_secret_key",pattern:/AWS_SECRET_ACCESS_KEY["'=:\s]{1,8}[A-Za-z0-9/+=]{30,200}/},{name:"aws_session_token",pattern:/AWS_SESSION_TOKEN["'=:\s]{1,8}[A-Za-z0-9/+=]{30,600}/},{name:"stripe_secret_key",pattern:/sk_live_[a-zA-Z0-9]{10,200}/},{name:"stripe_secret_key_test",pattern:/sk_test_[a-zA-Z0-9]{10,200}/},{name:"stripe_restricted_key",pattern:/rk_(?:live|test)_[a-zA-Z0-9]{10,200}/},{name:"github_pat",pattern:/ghp_[A-Za-z0-9_]{36,100}/},{name:"github_oauth",pattern:/gho_[A-Za-z0-9_]{36,100}/},{name:"github_user_token",pattern:/ghu_[A-Za-z0-9_]{36,100}/},{name:"github_server_token",pattern:/ghs_[A-Za-z0-9_]{36,100}/},{name:"github_fine_grained",pattern:/github_pat_[A-Za-z0-9_]{22,200}/},{name:"openai_api_key",pattern:/sk-[a-zA-Z0-9]{20,200}(?![a-zA-Z0-9_])/},{name:"anthropic_api_key",pattern:/sk-ant-[a-zA-Z0-9\-_]{20,200}/},{name:"private_key",pattern:/-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----/},{name:"sendgrid_api_key",pattern:/SG\.[a-zA-Z0-9_-]{22,100}\.[a-zA-Z0-9_-]{22,100}/},{name:"twilio_auth_token",pattern:/TWILIO_AUTH_TOKEN["'=:\s]{1,8}[a-f0-9]{32}/},{name:"generic_secret_key",pattern:/[A-Z_]{2,60}_SECRET_KEY["'=:\s]{1,8}[^\s"']{8,200}/},{name:"generic_secret",pattern:/[A-Z_]{2,60}_SECRET["'=:\s]{1,8}[^\s"']{8,200}/},{name:"generic_password",pattern:/[A-Z_]{2,60}_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"generic_private_key_var",pattern:/[A-Z_]{2,60}_PRIVATE_KEY["'=:\s]{1,8}[^\s"']{8,400}/}],ge=[],Lt=0,It=false;function yi(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function wi(e,t,n,o){if(ge.some(c=>c.rule===e&&c.source===t))return;let i={rule:e,source:t,hint:yi(n),timestamp:Date.now()};o&&(i.location=o),ge.push(i);}function Ie(e,t,n,o){for(let{name:r,pattern:i}of n){let c=i.exec(e);c&&wi(r,t,c[0],o);}}function xi(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);Ie(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);Ie(n,"hydration",e,"__NUXT__");}}catch{}}function Ei(e){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&Ie(r,"scripts",e,`inline-script[${o}]`);});}catch{}}function ki(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let o=n.getAttribute("content"),r=n.getAttribute("name")||n.getAttribute("property")||"";o&&o.length>10&&Ie(o,"meta",e,r?`meta[${r}]`:void 0);});}catch{}}function Si(e){try{document.querySelectorAll("[data-api-key], [data-secret], [data-token], [data-password]").forEach(n=>{let o=n.attributes;for(let r=0;r<o.length;r++){let i=o[r];i.name.startsWith("data-")&&i.value.length>10&&Ie(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function Zn(e={}){if(It||!T()||(It=true,e.secretScan===false))return;let t=[...vi,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{Lt=Date.now(),n.includes("hydration")&&xi(t),n.includes("scripts")&&Ei(t),n.includes("meta")&&ki(t),n.includes("dom")&&Si(t);let o=e.notify??"both";ge.length>0&&(o==="console"||o==="both")&&console.warn(`[BlocFeed Security] Found ${ge.length} potential secret(s) exposed in client code:`,ge.map(r=>`${r.rule} (${r.source}${r.location?`: ${r.location}`:""})`));},100);}function Nt(){return {findings:[...ge],scannedAt:Lt}}function Sc(){ge=[],Lt=0,It=false;}var eo={triggerLabel:"Feedback",panelTitle:"Feedback",hintText:"Click an element to attach your feedback. Press Esc to cancel.",cancelButton:"Cancel",rePickButton:"Re-pick",closeButton:"Close",textareaPlaceholder:"What's happening? What did you expect?",screenshotElement:"Screenshot element",screenshotFullPage:"Full page",capturingText:"Capturing screenshots\u2026",submittingText:"Submitting\u2026",successText:"Sent. Thank you!",toastText:"Feedback sent",sendButton:"Send",categoryBug:"Bug",categoryFeature:"Feature",categoryUx:"UX",categoryGeneral:"General",recordButton:"Record",stopRecordButton:"Stop",recordingText:"Recording\u2026",recordingDeniedText:"Screen share was denied",videoPreviewLabel:"Video attached",removeVideoButton:"Remove",voiceButton:"Voice",voiceStopButton:"Stop",voiceRecordingText:"Recording\u2026",voiceTranscribingText:"Transcribing\u2026",voiceDeniedText:"Microphone access was denied",voiceErrorText:"Voice transcription failed. Please type instead.",voiceEmptyText:"No speech detected. Try again or type instead."};function to(e){return e?{...eo,...e}:eo}function Dt(){let e=react.useContext(Qe);if(!e)throw new Error("useBlocFeed must be used within a <BlocFeedProvider />");return {state:e.state,controller:e.controller,start:e.controller.start,stop:e.controller.stop,clearSelection:e.controller.clearSelection,submit:e.controller.submit,startRecording:e.controller.startRecording,stopRecording:e.controller.stopRecording,removeVideo:e.controller.removeVideo,track:Be}}function q(e){switch(e){case "bottom-left":return "bf-trigger bf-trigger-bl";case "top-right":return "bf-trigger bf-trigger-tr";case "top-left":return "bf-trigger bf-trigger-tl";default:return "bf-trigger"}}function O({size:e=14}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M20 6L9 17l-5-5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function no({size:e=14}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M21 11.5a8.38 8.38 0 01-.9 3.8 8.5 8.5 0 01-7.6 4.7 8.38 8.38 0 01-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 01-.9-3.8 8.5 8.5 0 014.7-7.6 8.38 8.38 0 013.8-.9h.5a8.48 8.48 0 018 8v.5z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function oo({size:e=16}){return jsxRuntime.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[jsxRuntime.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M22 6l-10 7L2 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function io({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){return n?jsxRuntime.jsxs("button",{className:q(e),type:"button",onClick:t,"aria-label":o,children:[i?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-dot","aria-hidden":"true"}),o]}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]}):null}function V(){let[e,t]=react.useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return react.useEffect(()=>{let n=window.matchMedia("(prefers-reduced-motion: reduce)"),o=r=>t(r.matches);return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[]),e}var Fi={duration:.18,ease:"easeOut"},Ai={duration:0};function so({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),a=V(),l=a?Ai:Fi;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:q(e),type:"button",onClick:t,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:l,whileTap:{scale:.92},style:{overflow:"hidden"},children:i?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:l,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",animate:a?{}:{scale:c?1:[1,1.2,1],boxShadow:c?"0 0 0 4px rgba(99, 102, 241, 0.18)":["0 0 0 4px rgba(99, 102, 241, 0.18)","0 0 0 8px rgba(99, 102, 241, 0.28)","0 0 0 4px rgba(99, 102, 241, 0.18)"]},transition:c||a?l:{duration:2,repeat:1/0,ease:"easeInOut"}}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:c&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:l,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"dot")})}var Ni={duration:.18,ease:"easeOut"},lo={duration:0};function fo({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),a=V(),l=a?lo:Ni;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsxs(framerMotion.motion.div,{className:q(e),initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{y:8,opacity:0},transition:l,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),style:{background:"transparent",border:"none",boxShadow:"none",padding:0},children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:c&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:a?0:4},animate:{opacity:1,y:0},exit:{opacity:0,y:a?0:4},transition:l,style:{position:"absolute",bottom:"calc(100% + 8px)",left:"50%",transform:"translateX(-50%)",padding:"6px 12px",borderRadius:"8px",background:"var(--bf-panel-bg)",border:"1px solid var(--bf-border)",boxShadow:"var(--bf-shadow)",whiteSpace:"nowrap",fontSize:"12px",color:"var(--bf-panel-fg)",pointerEvents:"none"},children:o},"tooltip")}),jsxRuntime.jsxs(framerMotion.motion.button,{type:"button",onClick:t,"aria-label":o,style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"40px",borderRadius:"50%",border:"1px solid var(--bf-border)",background:"var(--bf-panel-bg)",color:"var(--bf-panel-fg)",boxShadow:"var(--bf-shadow)",cursor:"pointer",padding:0},animate:a?{}:{y:[0,-3,0]},transition:a?lo:{y:{duration:3,repeat:1/0,ease:"easeInOut"}},whileHover:{scale:1.1,borderColor:"var(--bf-accent)"},whileTap:{scale:.9},children:[i?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:l,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:16})},"success"):jsxRuntime.jsx(no,{size:16}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${r} queued`,children:r})]})]},"bubble")})}var Hi={duration:.2,ease:"easeOut"},Ui={duration:0};function mo(e){return e==="bottom-left"||e==="top-left"}function zi(e){return `bf-trigger-edge ${mo(e)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function go({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),a=mo(e),l=V(),m=l?Ui:Hi;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:zi(e),type:"button",onClick:t,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-label":o,initial:{opacity:0,width:0},animate:{opacity:1,width:c?140:22,height:c?40:90},exit:{width:0,opacity:0},transition:m,whileTap:{scale:.97},style:{top:"50%",translateY:"-50%"},children:i?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:m,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(framerMotion.motion.span,{animate:{rotate:l||c?0:a?-90:90,opacity:c?1:.6},transition:m,style:{display:"flex",alignItems:"center",gap:"8px",whiteSpace:"nowrap",fontSize:"12px",letterSpacing:"0.5px",textTransform:"uppercase"},children:[c&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:{duration:.12},style:{width:"6px",height:"6px",borderRadius:"50%",background:"var(--bf-accent)",flexShrink:0}}),o]}),jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",animate:{opacity:c?1:0},transition:{duration:.12},style:{position:"absolute",top:0,bottom:0,[a?"left":"right"]:0,width:"2px",background:"var(--bf-accent)"}}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"edge-tab")})}var qi={duration:.18,ease:"easeOut"},$i={duration:0};function ho({delay:e,hovered:t,reduced:n}){return n?null:jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",width:"10px",height:"10px",borderRadius:"50%",border:"2px solid var(--bf-accent)",pointerEvents:"none"},animate:t?{scale:1,opacity:0}:{scale:[1,1.8],opacity:[.5,0]},transition:t?{duration:.15}:{duration:2,repeat:1/0,delay:e,ease:"easeOut"}})}function yo({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),a=V(),l=a?$i:qi;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:q(e),type:"button",onClick:t,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:l,whileTap:{scale:.92},style:{overflow:"hidden"},children:i?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:l,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsxRuntime.jsx(ho,{delay:0,hovered:c,reduced:a}),jsxRuntime.jsx(ho,{delay:.7,hovered:c,reduced:a}),jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",style:{position:"relative",zIndex:1}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:c&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:l,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"pulse-ring")})}var Yi={duration:.18,ease:"easeOut"},Gi={duration:0};function Ji(e){switch(e){case "bottom-left":return "bf-trigger-minimal bf-trigger-bl";case "top-right":return "bf-trigger-minimal bf-trigger-tr";case "top-left":return "bf-trigger-minimal bf-trigger-tl";default:return "bf-trigger-minimal"}}function Eo({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),a=V(),l=a?Gi:Yi;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsxs(framerMotion.motion.button,{className:Ji(e),type:"button",onClick:t,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-label":o,initial:{opacity:0,y:a?0:5},animate:{opacity:c?1:.65,y:0},exit:{opacity:0,y:a?0:5},transition:l,whileTap:{scale:.95},children:[i?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:o}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${r} queued`,children:r})]}),!a&&jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",bottom:4,left:4,right:4,height:"2px",background:"var(--bf-accent)",borderRadius:"1px",transformOrigin:"left"},initial:false,animate:{scaleX:c?1:0},transition:l})]},"minimal")})}var ea={duration:.18,ease:"easeOut"},ta={duration:0};function So({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),a=V(),l=a?ta:ea;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:q(e),type:"button",onClick:t,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:l,whileTap:{scale:.9},style:{overflow:"hidden"},children:i?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:l,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{style:{display:"inline-flex",flexShrink:0},animate:a?{}:c?{scale:1.2,rotate:0}:{rotate:[-5,5,-5]},transition:c||a?l:{duration:3,repeat:1/0,ease:"easeInOut"},children:jsxRuntime.jsx(oo,{size:16})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:c&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:a?0:-8},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-8},transition:l,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"icon-pop")})}var ia={duration:.18,ease:"easeOut"},aa={duration:0};function Co({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),a=V(),l=a?aa:ia;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:q(e),type:"button",onClick:t,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:l,whileTap:{scale:.92},style:{overflow:"hidden"},children:i?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:l,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{width:"10px",height:"10px",borderRadius:"50%",background:"var(--bf-accent)",position:"relative",zIndex:1},animate:a?{}:{opacity:c?1:[.5,1,.5],boxShadow:c?"0 0 8px 2px var(--bf-accent)":["0 0 4px 1px var(--bf-accent)","0 0 12px 4px var(--bf-accent)","0 0 4px 1px var(--bf-accent)"]},transition:c||a?l:{duration:2,repeat:1/0,ease:"easeInOut"}}),!c&&!a&&jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",width:"18px",height:"2px",background:"linear-gradient(90deg, var(--bf-accent), transparent)",transformOrigin:"left center",left:"5px",top:"4px"},animate:{rotate:[0,360]},transition:{duration:4,repeat:1/0,ease:"linear"}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:c&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:l,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"beacon")})}var ua={duration:.18,ease:"easeOut"},fa={duration:0};function Fo({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),[a,l]=react.useState(0),m=V(),b=m?fa:ua,d=react.useRef(null);react.useEffect(()=>{if(d.current&&(clearInterval(d.current),d.current=null),!n||c||m){l(c||m?o.length:0);return}let u=8,p=o.length*2+u*2,f=0;return d.current=setInterval(()=>{f=(f+1)%p,f<=o.length?l(f):f<=o.length+u?l(o.length):f<=o.length*2+u?l(o.length*2+u-f):l(0);},100),()=>{d.current&&(clearInterval(d.current),d.current=null);}},[n,c,m,o]);let h=o.slice(0,a);return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:q(e),type:"button",onClick:t,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-label":o,initial:{opacity:0,y:m?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:m?0:5},transition:b,whileTap:{scale:.95},style:{minWidth:"44px"},children:i?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:b,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-dot","aria-hidden":"true"}),jsxRuntime.jsxs("span",{style:{whiteSpace:"nowrap",minWidth:"1ch"},children:[h,jsxRuntime.jsx("span",{className:"bf-cursor","aria-hidden":"true"})]}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"typewriter")})}function Ao(e){switch(e){case "dot":return so;case "bubble":return fo;case "edge-tab":return go;case "pulse-ring":return yo;case "minimal":return Eo;case "icon-pop":return So;case "beacon":return Co;case "typewriter":return Fo;default:return io}}function Mo(e,t,n){return Math.max(t,Math.min(n,e))}function ha(e,t,n="bottom-right"){let r=window.innerWidth,i=window.innerHeight,c;c=Mo(e.x,12,Math.max(12,r-t-12));let s=e.y+e.height+12,a=Math.max(12,e.y-240);return {top:s+240<=i?s:a,left:c}}function va(e){let{rect:t}=e,n={left:`${t.x}px`,top:`${t.y}px`,width:`${Math.max(0,t.width)}px`,height:`${Math.max(0,t.height)}px`};return jsxRuntime.jsx("div",{className:"bf-highlight",style:n,"aria-hidden":"true"})}function ya(e){let t=react.useRef(null);return react.useEffect(()=>{if(!e||!t.current)return;let n=t.current,o=n.querySelector(".bf-textarea");o?.focus();let r=c=>{if(c.key!=="Tab")return;let s=n.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(s.length===0)return;let a=s[0],l=s[s.length-1];c.shiftKey&&document.activeElement===a?(c.preventDefault(),l.focus()):!c.shiftKey&&document.activeElement===l&&(c.preventDefault(),a.focus());},i=c=>{let s=c.target;s&&(n.contains(s)||(c.stopImmediatePropagation(),o?.focus()));};return document.addEventListener("keydown",r,{capture:true}),document.addEventListener("focusin",i,{capture:true}),()=>{document.removeEventListener("keydown",r,{capture:true}),document.removeEventListener("focusin",i,{capture:true});}},[e]),t}function wa(e,t){return e?typeof e=="function"?e(t):e.some(n=>n.endsWith("*")?t.startsWith(n.slice(0,-1)):t===n):true}var Ut=new Set,Io=false;function xa(){if(Io||typeof window>"u")return;Io=true;let e=history.pushState,t=history.replaceState,n=()=>{for(let o of Ut)o();};history.pushState=function(...o){e.apply(this,o),setTimeout(n,0);},history.replaceState=function(...o){t.apply(this,o),setTimeout(n,0);};}function Ea(e){let[t,n]=react.useState(()=>typeof window<"u"?window.location.pathname:"/");return react.useEffect(()=>{if(typeof window>"u")return;let o=()=>n(window.location.pathname);return window.addEventListener("popstate",o),xa(),Ut.add(o),()=>{window.removeEventListener("popstate",o),Ut.delete(o);}},[]),wa(e,t)}function ka(e){let[t,n]=react.useState(()=>!e||e==="dark"?"dark":e==="light"?"light":typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return react.useEffect(()=>{if(e!=="auto"){n(e==="light"?"light":"dark");return}let o=window.matchMedia("(prefers-color-scheme: dark)"),r=i=>n(i.matches?"dark":"light");return n(o.matches?"dark":"light"),o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[e]),t}var Sa=["bug","feature","ux","general"],_a={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function Oe(e){let t=Math.floor(e/1e3),n=Math.floor(t/60),o=t%60;return `${n}:${String(o).padStart(2,"0")}`}function Ta(e){return e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ca(e){let{state:t,controller:n,start:o,stop:r,clearSelection:i,submit:c}=Dt(),s=e.config.ui?.position,a=to(e.config.ui?.strings),l=e.config.ui?.branding!==false,[m,b]=react.useState(null),[d,h]=react.useState(""),[u,p]=react.useState(e.config.capture?.element??true),[f,g]=react.useState(e.config.capture?.fullPage??false),[v,C]=react.useState(null),[_,E]=react.useState(void 0),z=e.config.ui?.categories??Sa,H=e.config.recording?.enabled===true&&wt(),B=e.config.recording?.maxDurationMs??3e4,M=n.getConfig().voice,se=M?.enabled===true&&Et(),ue=M?.maxDurationMs??6e4,[y,S]=react.useState(false),[L,N]=react.useState(0);react.useEffect(()=>{let w=window.setTimeout(()=>{let W=Nt();N(W.findings.length);},500);return ()=>window.clearTimeout(w)},[]),react.useImperativeHandle(e.handleRef,()=>({open:o,close:r,submit:w=>c(w),startRecording:()=>n.startRecording(),stopRecording:()=>n.stopRecording(),get isOpen(){return t.phase!=="idle"}}),[o,r,c,n,t.phase]);let I=t.phase==="review"||t.phase==="capturing"||t.phase==="submitting"||t.phase==="error"||t.phase==="success",R=ya(I),[G,te]=react.useState(0);react.useEffect(()=>{t.phase==="idle"&&te(on());},[t.phase]);let[He,ce]=react.useState(false),F=react.useRef(t.phase);react.useEffect(()=>{if(F.current==="success"&&t.phase==="idle"){ce(true);let w=window.setTimeout(()=>ce(false),1500);return ()=>window.clearTimeout(w)}F.current=t.phase;},[t.phase]),react.useEffect(()=>{let w=e.config.ui?.shortcut;if(!w)return;let W=w.toLowerCase().split("+").map(ee=>ee.trim()),Z=W[W.length-1]||"",fe=new Set(W.slice(0,-1)),Vt=ee=>{let Oo=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(fe.has("mod")){if(Oo?!ee.metaKey:!ee.ctrlKey)return}else if(fe.has("ctrl")&&!ee.ctrlKey||(fe.has("meta")||fe.has("cmd"))&&!ee.metaKey)return;fe.has("shift")&&!ee.shiftKey||(fe.has("alt")||fe.has("option"))&&!ee.altKey||ee.key.toLowerCase()===Z&&(ee.preventDefault(),t.phase==="idle"?o():r());};return document.addEventListener("keydown",Vt),()=>document.removeEventListener("keydown",Vt)},[e.config.ui?.shortcut,t.phase,o,r]),react.useEffect(()=>n.subscribeHover(b),[n]),react.useEffect(()=>{let w=n.__unsafeGetSelectedElement();if(!w||t.phase==="idle"||t.phase==="picking"){C(null);return}let W=()=>{C(Ce(w.getBoundingClientRect()));};W();let Z=()=>W();return window.addEventListener("scroll",Z,{capture:true,passive:true}),window.addEventListener("resize",Z,{passive:true}),()=>{window.removeEventListener("scroll",Z,{capture:true}),window.removeEventListener("resize",Z);}},[n,t.phase,t.selection?.selector]),react.useEffect(()=>{t.phase==="review"&&(h(""),p(e.config.capture?.element??true),g(e.config.capture?.fullPage??false),E(void 0),oe(null));},[t.phase,t.selection?.selector,e.config.capture?.element,e.config.capture?.fullPage]),react.useEffect(()=>{if(t.phase!=="success")return;let w=window.setTimeout(()=>r(),1200);return ()=>window.clearTimeout(w)},[t.phase,r]);let A=t.phase==="capturing"||t.phase==="submitting",U=t.phase==="picking"?m?.rect??null:v??t.selection?.rect??null,ne=react.useMemo(()=>U?ha(U,360,s):null,[U?.x,U?.y,U?.width,U?.height,s]),Q=t.lastError?.message,j=react.useCallback(()=>{let w={capture:{element:u,fullPage:f}};_&&(w.category=_),c(d,w);},[c,d,u,f,_]),lt=react.useCallback(w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&d.trim().length>0&&!A&&(w.preventDefault(),j());},[j,d,A]),[ye,oe]=react.useState(null),No=react.useCallback(async()=>{if(t.voiceRecording){n.stopVoice();return}oe(null);let w=await n.startVoice();if(w?.text)h(W=>W?W+" "+w.text:w.text);else if(w?.warning)oe(a.voiceEmptyText);else if(!w){let W=n.getState().lastError;if(W){let Z=W.message?.toLowerCase()??"";Z.includes("denied")||Z.includes("permission")||Z.includes("not allowed")?oe(a.voiceDeniedText):oe(a.voiceErrorText);}}},[t.voiceRecording,n,a]),Do=Ao(e.config.ui?.triggerStyle);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Do,{position:s,onClick:()=>o(),isVisible:t.phase==="idle",label:e.config.ui?.triggerLabel??a.triggerLabel,queueCount:G,showSuccess:He}),t.phase!=="idle"&&t.phase!=="recording"&&jsxRuntime.jsxs("div",{className:"bf-overlay",role:"presentation",children:[t.phase!=="picking"&&jsxRuntime.jsx("div",{className:"bf-blocker",role:"presentation",onClick:()=>r()}),U&&jsxRuntime.jsx(va,{rect:U}),t.phase==="picking"&&jsxRuntime.jsxs("div",{className:"bf-hint",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("p",{id:"bf-hint-text",children:a.hintText}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),"aria-label":a.cancelButton,children:a.cancelButton})]}),I&&ne&&jsxRuntime.jsxs("div",{ref:R,className:"bf-panel",style:{left:ne.left,top:ne.top},role:"dialog","aria-modal":"true","aria-label":"Feedback form",children:[jsxRuntime.jsxs("div",{className:"bf-panelHeader",children:[jsxRuntime.jsx("div",{className:"bf-title",id:"bf-panel-title",children:a.panelTitle}),jsxRuntime.jsxs("div",{className:"bf-row",style:{justifyContent:"flex-end"},children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>i(),disabled:A,"aria-label":a.rePickButton,children:a.rePickButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),disabled:A,"aria-label":a.closeButton,children:a.closeButton})]})]}),jsxRuntime.jsxs("div",{className:"bf-panelBody",children:[jsxRuntime.jsx("textarea",{className:"bf-textarea",placeholder:a.textareaPlaceholder,value:d,onChange:w=>h(w.target.value),onKeyDown:lt,disabled:A,"aria-label":a.panelTitle}),z.length>0&&jsxRuntime.jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:z.map(w=>jsxRuntime.jsx("button",{type:"button",className:`bf-pill${_===w?" bf-pill-active":""}`,onClick:()=>E(_===w?void 0:w),disabled:A,children:a[_a[w]]},w))}),jsxRuntime.jsxs("div",{className:"bf-row",role:"group","aria-label":a.screenshotElement,children:[jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:u,onChange:w=>p(w.target.checked),disabled:A}),a.screenshotElement]}),jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:f,onChange:w=>g(w.target.checked),disabled:A}),a.screenshotFullPage]})]}),se&&t.phase==="review"&&!t.voiceTranscribing&&jsxRuntime.jsx("button",{type:"button",className:`bf-voice-btn${t.voiceRecording?" bf-voice-btn-active":""}`,onClick:No,disabled:A,"aria-label":t.voiceRecording?a.voiceStopButton:a.voiceButton,children:t.voiceRecording?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-rec-dot bf-rec-dot-pulse","aria-hidden":"true"}),a.voiceRecordingText," ",Oe(t.voiceElapsedMs??0)," / ",Oe(ue)," \u2014 ",a.voiceStopButton]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{className:"bf-mic-icon",viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[jsxRuntime.jsx("rect",{x:"9",y:"1",width:"6",height:"11",rx:"3"}),jsxRuntime.jsx("path",{d:"M19 10v1a7 7 0 0 1-14 0v-1"}),jsxRuntime.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),jsxRuntime.jsx("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]}),a.voiceButton]})}),t.voiceTranscribing&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),a.voiceTranscribingText]}),ye&&!t.voiceRecording&&!t.voiceTranscribing&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:ye}),H&&t.phase==="review"&&!t.video&&jsxRuntime.jsxs("button",{type:"button",className:"bf-record-btn",onClick:()=>n.startRecording(),disabled:A,"aria-label":a.recordButton,children:[jsxRuntime.jsx("span",{className:"bf-rec-dot","aria-hidden":"true"}),a.recordButton]}),t.video&&t.phase==="review"&&jsxRuntime.jsxs("div",{className:"bf-video-preview",children:[jsxRuntime.jsx("video",{src:t.video.blobUrl,controls:true,muted:true,playsInline:true}),jsxRuntime.jsx("button",{type:"button",className:"bf-video-remove",onClick:()=>n.removeVideo(),"aria-label":a.removeVideoButton,children:"\xD7"}),jsxRuntime.jsxs("div",{className:"bf-video-meta",children:[a.videoPreviewLabel," (",Oe(t.video.durationMs),", ",Ta(t.video.sizeBytes),")"]})]}),t.phase==="capturing"&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),a.capturingText]}),t.phase==="submitting"&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),a.submittingText]}),t.phase==="success"&&jsxRuntime.jsx("div",{className:"bf-status",role:"status","aria-live":"polite",children:a.successText}),t.phase==="error"&&Q&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:Q}),jsxRuntime.jsxs("div",{className:"bf-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),disabled:A,"aria-label":a.cancelButton,children:a.cancelButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:j,disabled:A||d.trim().length===0,"aria-label":a.sendButton,children:a.sendButton})]})]}),l&&jsxRuntime.jsxs("div",{className:"bf-watermark",children:[(()=>{let w=_t();return w?jsxRuntime.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"bf-my-feedback-link",children:"View my feedback"}):null})(),jsxRuntime.jsx("a",{href:"https://blocfeed.com",target:"_blank",rel:"noopener noreferrer",children:"Powered by BlocFeed"})]})]})]}),t.phase==="recording"&&jsxRuntime.jsxs("div",{className:`bf-recording-bar bf-pos-${s}`,role:"status","aria-live":"polite","data-blocfeed-ui":"true",children:[jsxRuntime.jsx("span",{className:"bf-rec-dot bf-rec-dot-pulse","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"bf-recording-bar-timer",children:[a.recordingText," ",Oe(t.recordingElapsedMs??0)," / ",Oe(B)]}),jsxRuntime.jsx("button",{type:"button",className:"bf-recording-bar-stop",onClick:()=>n.stopRecording(),"aria-label":a.stopRecordButton,children:a.stopRecordButton})]}),t.phase==="success"&&jsxRuntime.jsxs("div",{className:"bf-toast",role:"status","aria-live":"polite",children:[a.toastText,(()=>{let w=_t();return w?jsxRuntime.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"bf-toast-link",children:"View my feedback"}):null})()]}),L>0&&!y&&jsxRuntime.jsxs("div",{className:"bf-security-banner",role:"alert",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-security-banner-dismiss",onClick:()=>S(true),"aria-label":"Dismiss",children:"\xD7"}),jsxRuntime.jsx("strong",{children:"Security Warning"}),L," potential secret",L>1?"s":""," exposed in client code. Check your environment variables."]})]})}var Ra=react.forwardRef(function(t,n){let o={...t.config??{},blocfeed_id:t.blocfeed_id},[r,i]=react.useState(null),c=Ea(o.ui?.showOn),s=ka(o.ui?.theme?.mode),a=!!o.diagnostics;react.useEffect(()=>{if(a)return Gn(o.diagnostics),()=>Jn()},[a]);let l=!!o.security;react.useEffect(()=>{l&&Zn(o.security);},[l]);let m=react.useRef(t.config?.metadata?.enrich);m.current=t.config?.metadata?.enrich;let b=react.useMemo(()=>{if(t.config)return {...t.config,metadata:{...t.config.metadata,enrich:async d=>{let h=m.current,u=h?await h(d):{},p=Qn(),f=Nt(),g=yt();return {...u,...p.consoleLogs.length>0?{_consoleLogs:p.consoleLogs}:{},...p.networkErrors.length>0?{_networkErrors:p.networkErrors}:{},...f.findings.length>0?{_securityFindings:f.findings}:{},...g.length>0?{_clickEvents:g}:{}}}}}},[]);return react.useEffect(()=>{Kn();let d=document.createElement("div");d.setAttribute("data-blocfeed-ui-root","true"),d.setAttribute("data-blocfeed-ui","true"),d.setAttribute("data-bf-theme",s);let h=o.ui?.zIndex;typeof h=="number"&&d.style.setProperty("--bf-z",String(h));let u=o.ui?.theme;u&&(u.accentColor&&d.style.setProperty("--bf-accent",u.accentColor),u.panelBackground&&d.style.setProperty("--bf-panel-bg",u.panelBackground),u.panelForeground&&d.style.setProperty("--bf-panel-fg",u.panelForeground),u.fontFamily&&d.style.setProperty("--bf-font",u.fontFamily));let p=g=>g.stopPropagation(),f=["pointerdown","pointerup","mousedown","mouseup","click","touchstart","touchend"];for(let g of f)d.addEventListener(g,p);try{document.body.appendChild(d);}catch{return}return i(d),()=>{for(let g of f)d.removeEventListener(g,p);d.remove(),i(null);}},[o.ui?.zIndex,o.ui?.theme?.accentColor,o.ui?.theme?.panelBackground,o.ui?.theme?.panelForeground,o.ui?.theme?.fontFamily,s]),!c||!r?null:reactDom.createPortal(jsxRuntime.jsx(Pt,{blocfeed_id:o.blocfeed_id,...b?{config:b}:{},children:jsxRuntime.jsx(Ca,{config:o,handleRef:n})}),r)});var Vn="0.20.0",pd={init(e){ke(e);},identify(e){Un(e);},track:Be};
884
- exports.A=Nt;exports.B=Sc;exports.C=Dt;exports.D=Ra;exports.E=Vn;exports.F=pd;exports.a=T;exports.b=Gt;exports.c=en;exports.d=tn;exports.e=ht;exports.f=nn;exports.g=za;exports.h=on;exports.i=yt;exports.j=ar;exports.k=wt;exports.l=xt;exports.m=Et;exports.n=kt;exports.o=wr;exports.p=_t;exports.q=xn;exports.r=Be;exports.s=Fe;exports.t=qn;exports.u=Pt;exports.v=Gn;exports.w=Jn;exports.x=Qn;exports.y=xc;exports.z=Zn;
883
+ `;function Kn(){if(!T()||document.getElementById($n))return;let e=document.createElement("style");e.id=$n,e.textContent=mi,document.head.appendChild(e);}var Ae=[],Me=[],Xn=20,jn=15,et=[],Yn=typeof console<"u"?{log:console.log?.bind(console),warn:console.warn?.bind(console),error:console.error?.bind(console),info:console.info?.bind(console),debug:console.debug?.bind(console)}:{},tt=typeof globalThis<"u"&&typeof globalThis.fetch=="function"?globalThis.fetch:void 0,nt=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.open:void 0,ot=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.send:void 0,Bt=new Set,At=false,Mt=false,rt=false,gi=["blocfeed.com","google-analytics.com","googletagmanager.com","analytics.google.com","googleads.g.doubleclick.net","googlesyndication.com","googleadservices.com","google.com/pagead","google.com/ads","facebook.net","facebook.com/tr","connect.facebook.net","graph.facebook.com","api.mixpanel.com","api-js.mixpanel.com","api.amplitude.com","api2.amplitude.com","api.segment.io","cdn.segment.com","vars.hotjar.com","in.hotjar.com","script.hotjar.com","heapanalytics.com","fullstory.com/s/fs.js","rs.fullstory.com","app.posthog.com","us.posthog.com","eu.posthog.com","api-iam.intercom.io","widget.intercom.io","sentry.io/api","browser.sentry-cdn.com","browser-intake-datadoghq.com","clarity.ms","js.hs-analytics.net","api.hubapi.com","forms.hubspot.com","plausible.io/api","client.crisp.chat","js.driftt.com","r.logrocket.com","app.pendo.io","events.launchdarkly.com","app.launchdarkly.com","grammarly.com","gnar.grammarly.com","capi.grammarly.com","api.languagetool.org","api.languagetoolplus.com","fonts.googleapis.com","fonts.gstatic.com","cdn.cookielaw.org","consent.cookiebot.com","js.stripe.com","api.stripe.com/v1/tokens","google.com/recaptcha","hcaptcha.com","bam.nr-data.net","rec.smartlook.com","o2.mouseflow.com","api.luckyorange.com","static.zdassets.com","ekr.zdassets.com"];function bi(e){if(e instanceof Error)return e.name&&e.name!=="Error"?`${e.name}: ${e.message}`:e.message||String(e);if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function hi(e,t){let n=t.map(bi).join(" "),o=t.find(i=>i instanceof Error),r={level:e,message:n.slice(0,2e3),timestamp:Date.now()};for(o?.stack&&(r.stack=o.stack.slice(0,2e3)),Ae.push(r);Ae.length>Xn;)Ae.shift();}function Ft(e){let t=e.url.toLowerCase();for(let n of et)if(t.includes(n))return;for(Me.push(e);Me.length>jn;)Me.shift();}function Gn(e={}){if(rt||!T())return;rt=true,Xn=e.consoleLimit??20,jn=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?et=t.map(n=>n.toLowerCase()):et=[...gi],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let o of n){let r=Yn[o];r&&(Bt.add(o),console[o]=(...i)=>{hi(o,i),r.apply(console,i);});}}if(e.network!==false&&tt){let n=tt;At=true,window.fetch=async function(r,i){let c=typeof r=="string"?r:r instanceof URL?r.toString():r.url,s=(i?.method??"GET").toUpperCase(),a=Date.now();try{let l=await n.call(window,r,i);return l.ok||Ft({url:c.slice(0,500),method:s,status:l.status,statusText:l.statusText,timestamp:a,durationMs:Date.now()-a}),l}catch(l){throw Ft({url:c.slice(0,500),method:s,status:0,statusText:l instanceof Error?l.message:"Network error",timestamp:a,durationMs:Date.now()-a}),l}};}if(e.network!==false&&nt&&ot){let n=nt,o=ot;Mt=true,XMLHttpRequest.prototype.open=function(r,i,...c){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...c])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",c=this.__bf_url||"",s=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let a={url:c.slice(0,500),method:i,status:this.status,timestamp:s,durationMs:Date.now()-s};this.statusText&&(a.statusText=this.statusText),Ft(a);}},{once:true}),o.apply(this,r)};}}function Jn(){if(rt){for(let e of Bt){let t=Yn[e];t&&(console[e]=t);}Bt.clear(),At&&tt&&(window.fetch=tt,At=false),Mt&&nt&&ot&&(XMLHttpRequest.prototype.open=nt,XMLHttpRequest.prototype.send=ot,Mt=false),et=[],rt=false;}}function Qn(){return {consoleLogs:[...Ae],networkErrors:[...Me]}}function xc(){Ae=[],Me=[];}var vi=[{name:"supabase_service_role_key",pattern:/SUPABASE_SERVICE_ROLE_KEY["'=:\s]{1,8}[A-Za-z0-9_.=-]{30,400}/},{name:"supabase_db_password",pattern:/SUPABASE_DB_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"postgres_password",pattern:/POSTGRES_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"database_url_with_creds",pattern:/(?:postgres|postgresql|mysql|mongodb|redis|amqp):\/\/[^:\s"']{1,100}:[^@\s"']{1,200}@/},{name:"aws_access_key",pattern:/AKIA[0-9A-Z]{16}/},{name:"aws_secret_key",pattern:/AWS_SECRET_ACCESS_KEY["'=:\s]{1,8}[A-Za-z0-9/+=]{30,200}/},{name:"aws_session_token",pattern:/AWS_SESSION_TOKEN["'=:\s]{1,8}[A-Za-z0-9/+=]{30,600}/},{name:"stripe_secret_key",pattern:/sk_live_[a-zA-Z0-9]{10,200}/},{name:"stripe_secret_key_test",pattern:/sk_test_[a-zA-Z0-9]{10,200}/},{name:"stripe_restricted_key",pattern:/rk_(?:live|test)_[a-zA-Z0-9]{10,200}/},{name:"github_pat",pattern:/ghp_[A-Za-z0-9_]{36,100}/},{name:"github_oauth",pattern:/gho_[A-Za-z0-9_]{36,100}/},{name:"github_user_token",pattern:/ghu_[A-Za-z0-9_]{36,100}/},{name:"github_server_token",pattern:/ghs_[A-Za-z0-9_]{36,100}/},{name:"github_fine_grained",pattern:/github_pat_[A-Za-z0-9_]{22,200}/},{name:"openai_api_key",pattern:/sk-[a-zA-Z0-9]{20,200}(?![a-zA-Z0-9_])/},{name:"anthropic_api_key",pattern:/sk-ant-[a-zA-Z0-9\-_]{20,200}/},{name:"private_key",pattern:/-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----/},{name:"sendgrid_api_key",pattern:/SG\.[a-zA-Z0-9_-]{22,100}\.[a-zA-Z0-9_-]{22,100}/},{name:"twilio_auth_token",pattern:/TWILIO_AUTH_TOKEN["'=:\s]{1,8}[a-f0-9]{32}/},{name:"generic_secret_key",pattern:/[A-Z_]{2,60}_SECRET_KEY["'=:\s]{1,8}[^\s"']{8,200}/},{name:"generic_secret",pattern:/[A-Z_]{2,60}_SECRET["'=:\s]{1,8}[^\s"']{8,200}/},{name:"generic_password",pattern:/[A-Z_]{2,60}_PASSWORD["'=:\s]{1,8}[^\s"']{6,200}/},{name:"generic_private_key_var",pattern:/[A-Z_]{2,60}_PRIVATE_KEY["'=:\s]{1,8}[^\s"']{8,400}/}],ge=[],Lt=0,It=false;function yi(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function wi(e,t,n,o){if(ge.some(c=>c.rule===e&&c.source===t))return;let i={rule:e,source:t,hint:yi(n),timestamp:Date.now()};o&&(i.location=o),ge.push(i);}function Ie(e,t,n,o){for(let{name:r,pattern:i}of n){let c=i.exec(e);c&&wi(r,t,c[0],o);}}function xi(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);Ie(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);Ie(n,"hydration",e,"__NUXT__");}}catch{}}function Ei(e){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&Ie(r,"scripts",e,`inline-script[${o}]`);});}catch{}}function ki(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let o=n.getAttribute("content"),r=n.getAttribute("name")||n.getAttribute("property")||"";o&&o.length>10&&Ie(o,"meta",e,r?`meta[${r}]`:void 0);});}catch{}}function Si(e){try{document.querySelectorAll("[data-api-key], [data-secret], [data-token], [data-password]").forEach(n=>{let o=n.attributes;for(let r=0;r<o.length;r++){let i=o[r];i.name.startsWith("data-")&&i.value.length>10&&Ie(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function Zn(e={}){if(It||!T()||(It=true,e.secretScan===false))return;let t=[...vi,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{Lt=Date.now(),n.includes("hydration")&&xi(t),n.includes("scripts")&&Ei(t),n.includes("meta")&&ki(t),n.includes("dom")&&Si(t);let o=e.notify??"both";ge.length>0&&(o==="console"||o==="both")&&console.warn(`[BlocFeed Security] Found ${ge.length} potential secret(s) exposed in client code:`,ge.map(r=>`${r.rule} (${r.source}${r.location?`: ${r.location}`:""})`));},100);}function Nt(){return {findings:[...ge],scannedAt:Lt}}function Sc(){ge=[],Lt=0,It=false;}var eo={triggerLabel:"Feedback",panelTitle:"Feedback",hintText:"Click an element to attach your feedback. Press Esc to cancel.",cancelButton:"Cancel",rePickButton:"Re-pick",closeButton:"Close",textareaPlaceholder:"What's happening? What did you expect?",screenshotElement:"Screenshot element",screenshotFullPage:"Full page",capturingText:"Capturing screenshots\u2026",submittingText:"Submitting\u2026",successText:"Sent. Thank you!",toastText:"Feedback sent",sendButton:"Send",categoryBug:"Bug",categoryFeature:"Feature",categoryUx:"UX",categoryGeneral:"General",recordButton:"Record",stopRecordButton:"Stop",recordingText:"Recording\u2026",recordingDeniedText:"Screen share was denied",videoPreviewLabel:"Video attached",removeVideoButton:"Remove",voiceButton:"Voice",voiceStopButton:"Stop",voiceRecordingText:"Recording\u2026",voiceTranscribingText:"Transcribing\u2026",voiceDeniedText:"Microphone access was denied",voiceErrorText:"Voice transcription failed. Please type instead.",voiceEmptyText:"No speech detected. Try again or type instead."};function to(e){return e?{...eo,...e}:eo}function Dt(){let e=react.useContext(Qe);if(!e)throw new Error("useBlocFeed must be used within a <BlocFeedProvider />");return {state:e.state,controller:e.controller,start:e.controller.start,stop:e.controller.stop,clearSelection:e.controller.clearSelection,submit:e.controller.submit,startRecording:e.controller.startRecording,stopRecording:e.controller.stopRecording,removeVideo:e.controller.removeVideo,track:Fe}}function q(e){switch(e){case "bottom-left":return "bf-trigger bf-trigger-bl";case "top-right":return "bf-trigger bf-trigger-tr";case "top-left":return "bf-trigger bf-trigger-tl";default:return "bf-trigger"}}function O({size:e=14}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M20 6L9 17l-5-5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function no({size:e=14}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M21 11.5a8.38 8.38 0 01-.9 3.8 8.5 8.5 0 01-7.6 4.7 8.38 8.38 0 01-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 01-.9-3.8 8.5 8.5 0 014.7-7.6 8.38 8.38 0 013.8-.9h.5a8.48 8.48 0 018 8v.5z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function oo({size:e=16}){return jsxRuntime.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[jsxRuntime.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M22 6l-10 7L2 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function io({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){return n?jsxRuntime.jsxs("button",{className:q(e),type:"button",onClick:t,"aria-label":o,children:[i?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-dot","aria-hidden":"true"}),o]}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]}):null}function V(){let[e,t]=react.useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return react.useEffect(()=>{let n=window.matchMedia("(prefers-reduced-motion: reduce)"),o=r=>t(r.matches);return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[]),e}var Bi={duration:.18,ease:"easeOut"},Ai={duration:0};function so({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),a=V(),l=a?Ai:Bi;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:q(e),type:"button",onClick:t,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:l,whileTap:{scale:.92},style:{overflow:"hidden"},children:i?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:l,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",animate:a?{}:{scale:c?1:[1,1.2,1],boxShadow:c?"0 0 0 4px rgba(99, 102, 241, 0.18)":["0 0 0 4px rgba(99, 102, 241, 0.18)","0 0 0 8px rgba(99, 102, 241, 0.28)","0 0 0 4px rgba(99, 102, 241, 0.18)"]},transition:c||a?l:{duration:2,repeat:1/0,ease:"easeInOut"}}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:c&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:l,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"dot")})}var Ni={duration:.18,ease:"easeOut"},lo={duration:0};function fo({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),a=V(),l=a?lo:Ni;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsxs(framerMotion.motion.div,{className:q(e),initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{y:8,opacity:0},transition:l,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),style:{background:"transparent",border:"none",boxShadow:"none",padding:0},children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:c&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:a?0:4},animate:{opacity:1,y:0},exit:{opacity:0,y:a?0:4},transition:l,style:{position:"absolute",bottom:"calc(100% + 8px)",left:"50%",transform:"translateX(-50%)",padding:"6px 12px",borderRadius:"8px",background:"var(--bf-panel-bg)",border:"1px solid var(--bf-border)",boxShadow:"var(--bf-shadow)",whiteSpace:"nowrap",fontSize:"12px",color:"var(--bf-panel-fg)",pointerEvents:"none"},children:o},"tooltip")}),jsxRuntime.jsxs(framerMotion.motion.button,{type:"button",onClick:t,"aria-label":o,style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"40px",borderRadius:"50%",border:"1px solid var(--bf-border)",background:"var(--bf-panel-bg)",color:"var(--bf-panel-fg)",boxShadow:"var(--bf-shadow)",cursor:"pointer",padding:0},animate:a?{}:{y:[0,-3,0]},transition:a?lo:{y:{duration:3,repeat:1/0,ease:"easeInOut"}},whileHover:{scale:1.1,borderColor:"var(--bf-accent)"},whileTap:{scale:.9},children:[i?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:l,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:16})},"success"):jsxRuntime.jsx(no,{size:16}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${r} queued`,children:r})]})]},"bubble")})}var Hi={duration:.2,ease:"easeOut"},Ui={duration:0};function mo(e){return e==="bottom-left"||e==="top-left"}function zi(e){return `bf-trigger-edge ${mo(e)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function go({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),a=mo(e),l=V(),m=l?Ui:Hi;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:zi(e),type:"button",onClick:t,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-label":o,initial:{opacity:0,width:0},animate:{opacity:1,width:c?140:22,height:c?40:90},exit:{width:0,opacity:0},transition:m,whileTap:{scale:.97},style:{top:"50%",translateY:"-50%"},children:i?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:m,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(framerMotion.motion.span,{animate:{rotate:l||c?0:a?-90:90,opacity:c?1:.6},transition:m,style:{display:"flex",alignItems:"center",gap:"8px",whiteSpace:"nowrap",fontSize:"12px",letterSpacing:"0.5px",textTransform:"uppercase"},children:[c&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:{duration:.12},style:{width:"6px",height:"6px",borderRadius:"50%",background:"var(--bf-accent)",flexShrink:0}}),o]}),jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",animate:{opacity:c?1:0},transition:{duration:.12},style:{position:"absolute",top:0,bottom:0,[a?"left":"right"]:0,width:"2px",background:"var(--bf-accent)"}}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"edge-tab")})}var qi={duration:.18,ease:"easeOut"},$i={duration:0};function ho({delay:e,hovered:t,reduced:n}){return n?null:jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",width:"10px",height:"10px",borderRadius:"50%",border:"2px solid var(--bf-accent)",pointerEvents:"none"},animate:t?{scale:1,opacity:0}:{scale:[1,1.8],opacity:[.5,0]},transition:t?{duration:.15}:{duration:2,repeat:1/0,delay:e,ease:"easeOut"}})}function yo({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),a=V(),l=a?$i:qi;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:q(e),type:"button",onClick:t,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:l,whileTap:{scale:.92},style:{overflow:"hidden"},children:i?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:l,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsxRuntime.jsx(ho,{delay:0,hovered:c,reduced:a}),jsxRuntime.jsx(ho,{delay:.7,hovered:c,reduced:a}),jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",style:{position:"relative",zIndex:1}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:c&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:l,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"pulse-ring")})}var Yi={duration:.18,ease:"easeOut"},Gi={duration:0};function Ji(e){switch(e){case "bottom-left":return "bf-trigger-minimal bf-trigger-bl";case "top-right":return "bf-trigger-minimal bf-trigger-tr";case "top-left":return "bf-trigger-minimal bf-trigger-tl";default:return "bf-trigger-minimal"}}function Eo({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),a=V(),l=a?Gi:Yi;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsxs(framerMotion.motion.button,{className:Ji(e),type:"button",onClick:t,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-label":o,initial:{opacity:0,y:a?0:5},animate:{opacity:c?1:.65,y:0},exit:{opacity:0,y:a?0:5},transition:l,whileTap:{scale:.95},children:[i?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:o}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${r} queued`,children:r})]}),!a&&jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",bottom:4,left:4,right:4,height:"2px",background:"var(--bf-accent)",borderRadius:"1px",transformOrigin:"left"},initial:false,animate:{scaleX:c?1:0},transition:l})]},"minimal")})}var ea={duration:.18,ease:"easeOut"},ta={duration:0};function So({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),a=V(),l=a?ta:ea;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:q(e),type:"button",onClick:t,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:l,whileTap:{scale:.9},style:{overflow:"hidden"},children:i?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:l,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{style:{display:"inline-flex",flexShrink:0},animate:a?{}:c?{scale:1.2,rotate:0}:{rotate:[-5,5,-5]},transition:c||a?l:{duration:3,repeat:1/0,ease:"easeInOut"},children:jsxRuntime.jsx(oo,{size:16})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:c&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:a?0:-8},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-8},transition:l,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"icon-pop")})}var ia={duration:.18,ease:"easeOut"},aa={duration:0};function Co({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),a=V(),l=a?aa:ia;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:q(e),type:"button",onClick:t,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:l,whileTap:{scale:.92},style:{overflow:"hidden"},children:i?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:l,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{width:"10px",height:"10px",borderRadius:"50%",background:"var(--bf-accent)",position:"relative",zIndex:1},animate:a?{}:{opacity:c?1:[.5,1,.5],boxShadow:c?"0 0 8px 2px var(--bf-accent)":["0 0 4px 1px var(--bf-accent)","0 0 12px 4px var(--bf-accent)","0 0 4px 1px var(--bf-accent)"]},transition:c||a?l:{duration:2,repeat:1/0,ease:"easeInOut"}}),!c&&!a&&jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",width:"18px",height:"2px",background:"linear-gradient(90deg, var(--bf-accent), transparent)",transformOrigin:"left center",left:"5px",top:"4px"},animate:{rotate:[0,360]},transition:{duration:4,repeat:1/0,ease:"linear"}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:c&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:l,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"beacon")})}var ua={duration:.18,ease:"easeOut"},fa={duration:0};function Bo({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:i}){let[c,s]=react.useState(false),[a,l]=react.useState(0),m=V(),b=m?fa:ua,d=react.useRef(null);react.useEffect(()=>{if(d.current&&(clearInterval(d.current),d.current=null),!n||c||m){l(c||m?o.length:0);return}let u=8,p=o.length*2+u*2,f=0;return d.current=setInterval(()=>{f=(f+1)%p,f<=o.length?l(f):f<=o.length+u?l(o.length):f<=o.length*2+u?l(o.length*2+u-f):l(0);},100),()=>{d.current&&(clearInterval(d.current),d.current=null);}},[n,c,m,o]);let h=o.slice(0,a);return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:q(e),type:"button",onClick:t,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-label":o,initial:{opacity:0,y:m?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:m?0:5},transition:b,whileTap:{scale:.95},style:{minWidth:"44px"},children:i?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:b,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(O,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-dot","aria-hidden":"true"}),jsxRuntime.jsxs("span",{style:{whiteSpace:"nowrap",minWidth:"1ch"},children:[h,jsxRuntime.jsx("span",{className:"bf-cursor","aria-hidden":"true"})]}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"typewriter")})}function Ao(e){switch(e){case "dot":return so;case "bubble":return fo;case "edge-tab":return go;case "pulse-ring":return yo;case "minimal":return Eo;case "icon-pop":return So;case "beacon":return Co;case "typewriter":return Bo;default:return io}}function Mo(e,t,n){return Math.max(t,Math.min(n,e))}function ha(e,t,n="bottom-right"){let r=window.innerWidth,i=window.innerHeight,c;c=Mo(e.x,12,Math.max(12,r-t-12));let s=e.y+e.height+12,a=Math.max(12,e.y-240);return {top:s+240<=i?s:a,left:c}}function va(e){let{rect:t}=e,n={left:`${t.x}px`,top:`${t.y}px`,width:`${Math.max(0,t.width)}px`,height:`${Math.max(0,t.height)}px`};return jsxRuntime.jsx("div",{className:"bf-highlight",style:n,"aria-hidden":"true"})}function ya(e){let t=react.useRef(null);return react.useEffect(()=>{if(!e||!t.current)return;let n=t.current,o=n.querySelector(".bf-textarea");o?.focus();let r=c=>{if(c.key!=="Tab")return;let s=n.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(s.length===0)return;let a=s[0],l=s[s.length-1];c.shiftKey&&document.activeElement===a?(c.preventDefault(),l.focus()):!c.shiftKey&&document.activeElement===l&&(c.preventDefault(),a.focus());},i=c=>{let s=c.target;s&&(n.contains(s)||(c.stopImmediatePropagation(),o?.focus()));};return document.addEventListener("keydown",r,{capture:true}),document.addEventListener("focusin",i,{capture:true}),()=>{document.removeEventListener("keydown",r,{capture:true}),document.removeEventListener("focusin",i,{capture:true});}},[e]),t}function wa(e,t){return e?typeof e=="function"?e(t):e.some(n=>n.endsWith("*")?t.startsWith(n.slice(0,-1)):t===n):true}var Ut=new Set,Io=false;function xa(){if(Io||typeof window>"u")return;Io=true;let e=history.pushState,t=history.replaceState,n=()=>{for(let o of Ut)o();};history.pushState=function(...o){e.apply(this,o),setTimeout(n,0);},history.replaceState=function(...o){t.apply(this,o),setTimeout(n,0);};}function Ea(e){let[t,n]=react.useState(()=>typeof window<"u"?window.location.pathname:"/");return react.useEffect(()=>{if(typeof window>"u")return;let o=()=>n(window.location.pathname);return window.addEventListener("popstate",o),xa(),Ut.add(o),()=>{window.removeEventListener("popstate",o),Ut.delete(o);}},[]),wa(e,t)}function ka(e){let[t,n]=react.useState(()=>!e||e==="dark"?"dark":e==="light"?"light":typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return react.useEffect(()=>{if(e!=="auto"){n(e==="light"?"light":"dark");return}let o=window.matchMedia("(prefers-color-scheme: dark)"),r=i=>n(i.matches?"dark":"light");return n(o.matches?"dark":"light"),o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[e]),t}var Sa=["bug","feature","ux","general"],_a={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function Oe(e){let t=Math.floor(e/1e3),n=Math.floor(t/60),o=t%60;return `${n}:${String(o).padStart(2,"0")}`}function Ta(e){return e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ca(e){let{state:t,controller:n,start:o,stop:r,clearSelection:i,submit:c}=Dt(),s=e.config.ui?.position,a=to(e.config.ui?.strings),l=e.config.ui?.branding!==false,[m,b]=react.useState(null),[d,h]=react.useState(""),[u,p]=react.useState(e.config.capture?.element??true),[f,g]=react.useState(e.config.capture?.fullPage??false),[v,C]=react.useState(null),[_,E]=react.useState(void 0),z=e.config.ui?.categories??Sa,H=e.config.recording?.enabled===true&&wt(),F=e.config.recording?.maxDurationMs??3e4,M=n.getConfig().voice,se=M?.enabled===true&&Et(),ue=M?.maxDurationMs??6e4,[y,S]=react.useState(false),[L,N]=react.useState(0);react.useEffect(()=>{let w=window.setTimeout(()=>{let W=Nt();N(W.findings.length);},500);return ()=>window.clearTimeout(w)},[]),react.useImperativeHandle(e.handleRef,()=>({open:o,close:r,submit:w=>c(w),startRecording:()=>n.startRecording(),stopRecording:()=>n.stopRecording(),get isOpen(){return t.phase!=="idle"}}),[o,r,c,n,t.phase]);let I=t.phase==="review"||t.phase==="capturing"||t.phase==="submitting"||t.phase==="error"||t.phase==="success",R=ya(I),[G,te]=react.useState(0);react.useEffect(()=>{t.phase==="idle"&&te(on());},[t.phase]);let[He,ce]=react.useState(false),B=react.useRef(t.phase);react.useEffect(()=>{if(B.current==="success"&&t.phase==="idle"){ce(true);let w=window.setTimeout(()=>ce(false),1500);return ()=>window.clearTimeout(w)}B.current=t.phase;},[t.phase]),react.useEffect(()=>{let w=e.config.ui?.shortcut;if(!w)return;let W=w.toLowerCase().split("+").map(ee=>ee.trim()),Z=W[W.length-1]||"",fe=new Set(W.slice(0,-1)),Vt=ee=>{let Oo=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(fe.has("mod")){if(Oo?!ee.metaKey:!ee.ctrlKey)return}else if(fe.has("ctrl")&&!ee.ctrlKey||(fe.has("meta")||fe.has("cmd"))&&!ee.metaKey)return;fe.has("shift")&&!ee.shiftKey||(fe.has("alt")||fe.has("option"))&&!ee.altKey||ee.key.toLowerCase()===Z&&(ee.preventDefault(),t.phase==="idle"?o():r());};return document.addEventListener("keydown",Vt),()=>document.removeEventListener("keydown",Vt)},[e.config.ui?.shortcut,t.phase,o,r]),react.useEffect(()=>n.subscribeHover(b),[n]),react.useEffect(()=>{let w=n.__unsafeGetSelectedElement();if(!w||t.phase==="idle"||t.phase==="picking"){C(null);return}let W=()=>{C(Ce(w.getBoundingClientRect()));};W();let Z=()=>W();return window.addEventListener("scroll",Z,{capture:true,passive:true}),window.addEventListener("resize",Z,{passive:true}),()=>{window.removeEventListener("scroll",Z,{capture:true}),window.removeEventListener("resize",Z);}},[n,t.phase,t.selection?.selector]),react.useEffect(()=>{t.phase==="review"&&(h(""),p(e.config.capture?.element??true),g(e.config.capture?.fullPage??false),E(void 0),oe(null));},[t.phase,t.selection?.selector,e.config.capture?.element,e.config.capture?.fullPage]),react.useEffect(()=>{if(t.phase!=="success")return;let w=window.setTimeout(()=>r(),1200);return ()=>window.clearTimeout(w)},[t.phase,r]);let A=t.phase==="capturing"||t.phase==="submitting",U=t.phase==="picking"?m?.rect??null:v??t.selection?.rect??null,ne=react.useMemo(()=>U?ha(U,360,s):null,[U?.x,U?.y,U?.width,U?.height,s]),Q=t.lastError?.message,j=react.useCallback(()=>{let w={capture:{element:u,fullPage:f}};_&&(w.category=_),c(d,w);},[c,d,u,f,_]),lt=react.useCallback(w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&d.trim().length>0&&!A&&(w.preventDefault(),j());},[j,d,A]),[ye,oe]=react.useState(null),No=react.useCallback(async()=>{if(t.voiceRecording){n.stopVoice();return}oe(null);let w=await n.startVoice();if(w?.text)h(W=>W?W+" "+w.text:w.text);else if(w?.warning)oe(a.voiceEmptyText);else if(!w){let W=n.getState().lastError;if(W){let Z=W.message?.toLowerCase()??"";Z.includes("denied")||Z.includes("permission")||Z.includes("not allowed")?oe(a.voiceDeniedText):oe(a.voiceErrorText);}}},[t.voiceRecording,n,a]),Do=Ao(e.config.ui?.triggerStyle);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Do,{position:s,onClick:()=>o(),isVisible:t.phase==="idle",label:e.config.ui?.triggerLabel??a.triggerLabel,queueCount:G,showSuccess:He}),t.phase!=="idle"&&t.phase!=="recording"&&jsxRuntime.jsxs("div",{className:"bf-overlay",role:"presentation",children:[t.phase!=="picking"&&jsxRuntime.jsx("div",{className:"bf-blocker",role:"presentation",onClick:()=>r()}),U&&jsxRuntime.jsx(va,{rect:U}),t.phase==="picking"&&jsxRuntime.jsxs("div",{className:"bf-hint",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("p",{id:"bf-hint-text",children:a.hintText}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),"aria-label":a.cancelButton,children:a.cancelButton})]}),I&&ne&&jsxRuntime.jsxs("div",{ref:R,className:"bf-panel",style:{left:ne.left,top:ne.top},role:"dialog","aria-modal":"true","aria-label":"Feedback form",children:[jsxRuntime.jsxs("div",{className:"bf-panelHeader",children:[jsxRuntime.jsx("div",{className:"bf-title",id:"bf-panel-title",children:a.panelTitle}),jsxRuntime.jsxs("div",{className:"bf-row",style:{justifyContent:"flex-end"},children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>i(),disabled:A,"aria-label":a.rePickButton,children:a.rePickButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),disabled:A,"aria-label":a.closeButton,children:a.closeButton})]})]}),jsxRuntime.jsxs("div",{className:"bf-panelBody",children:[jsxRuntime.jsx("textarea",{className:"bf-textarea",placeholder:a.textareaPlaceholder,value:d,onChange:w=>h(w.target.value),onKeyDown:lt,disabled:A,"aria-label":a.panelTitle}),z.length>0&&jsxRuntime.jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:z.map(w=>jsxRuntime.jsx("button",{type:"button",className:`bf-pill${_===w?" bf-pill-active":""}`,onClick:()=>E(_===w?void 0:w),disabled:A,children:a[_a[w]]},w))}),jsxRuntime.jsxs("div",{className:"bf-row",role:"group","aria-label":a.screenshotElement,children:[jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:u,onChange:w=>p(w.target.checked),disabled:A}),a.screenshotElement]}),jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:f,onChange:w=>g(w.target.checked),disabled:A}),a.screenshotFullPage]})]}),se&&t.phase==="review"&&!t.voiceTranscribing&&jsxRuntime.jsx("button",{type:"button",className:`bf-voice-btn${t.voiceRecording?" bf-voice-btn-active":""}`,onClick:No,disabled:A,"aria-label":t.voiceRecording?a.voiceStopButton:a.voiceButton,children:t.voiceRecording?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-rec-dot bf-rec-dot-pulse","aria-hidden":"true"}),a.voiceRecordingText," ",Oe(t.voiceElapsedMs??0)," / ",Oe(ue)," \u2014 ",a.voiceStopButton]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("svg",{className:"bf-mic-icon",viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[jsxRuntime.jsx("rect",{x:"9",y:"1",width:"6",height:"11",rx:"3"}),jsxRuntime.jsx("path",{d:"M19 10v1a7 7 0 0 1-14 0v-1"}),jsxRuntime.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),jsxRuntime.jsx("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]}),a.voiceButton]})}),t.voiceTranscribing&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),a.voiceTranscribingText]}),ye&&!t.voiceRecording&&!t.voiceTranscribing&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:ye}),H&&t.phase==="review"&&!t.video&&jsxRuntime.jsxs("button",{type:"button",className:"bf-record-btn",onClick:()=>n.startRecording(),disabled:A,"aria-label":a.recordButton,children:[jsxRuntime.jsx("span",{className:"bf-rec-dot","aria-hidden":"true"}),a.recordButton]}),t.video&&t.phase==="review"&&jsxRuntime.jsxs("div",{className:"bf-video-preview",children:[jsxRuntime.jsx("video",{src:t.video.blobUrl,controls:true,muted:true,playsInline:true}),jsxRuntime.jsx("button",{type:"button",className:"bf-video-remove",onClick:()=>n.removeVideo(),"aria-label":a.removeVideoButton,children:"\xD7"}),jsxRuntime.jsxs("div",{className:"bf-video-meta",children:[a.videoPreviewLabel," (",Oe(t.video.durationMs),", ",Ta(t.video.sizeBytes),")"]})]}),t.phase==="capturing"&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),a.capturingText]}),t.phase==="submitting"&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),a.submittingText]}),t.phase==="success"&&jsxRuntime.jsx("div",{className:"bf-status",role:"status","aria-live":"polite",children:a.successText}),t.phase==="error"&&Q&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:Q}),jsxRuntime.jsxs("div",{className:"bf-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),disabled:A,"aria-label":a.cancelButton,children:a.cancelButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:j,disabled:A||d.trim().length===0,"aria-label":a.sendButton,children:a.sendButton})]})]}),l&&jsxRuntime.jsxs("div",{className:"bf-watermark",children:[(()=>{let w=_t();return w?jsxRuntime.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"bf-my-feedback-link",children:"View my feedback"}):null})(),jsxRuntime.jsx("a",{href:"https://blocfeed.com",target:"_blank",rel:"noopener noreferrer",children:"Powered by BlocFeed"})]})]})]}),t.phase==="recording"&&jsxRuntime.jsxs("div",{className:`bf-recording-bar bf-pos-${s}`,role:"status","aria-live":"polite","data-blocfeed-ui":"true",children:[jsxRuntime.jsx("span",{className:"bf-rec-dot bf-rec-dot-pulse","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"bf-recording-bar-timer",children:[a.recordingText," ",Oe(t.recordingElapsedMs??0)," / ",Oe(F)]}),jsxRuntime.jsx("button",{type:"button",className:"bf-recording-bar-stop",onClick:()=>n.stopRecording(),"aria-label":a.stopRecordButton,children:a.stopRecordButton})]}),t.phase==="success"&&jsxRuntime.jsxs("div",{className:"bf-toast",role:"status","aria-live":"polite",children:[a.toastText,(()=>{let w=_t();return w?jsxRuntime.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"bf-toast-link",children:"View my feedback"}):null})()]}),L>0&&!y&&jsxRuntime.jsxs("div",{className:"bf-security-banner",role:"alert",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-security-banner-dismiss",onClick:()=>S(true),"aria-label":"Dismiss",children:"\xD7"}),jsxRuntime.jsx("strong",{children:"Security Warning"}),L," potential secret",L>1?"s":""," exposed in client code. Check your environment variables."]})]})}var Ra=react.forwardRef(function(t,n){let o={...t.config??{},blocfeed_id:t.blocfeed_id},[r,i]=react.useState(null),c=Ea(o.ui?.showOn),s=ka(o.ui?.theme?.mode),a=!!o.diagnostics;react.useEffect(()=>{if(a)return Gn(o.diagnostics),()=>Jn()},[a]);let l=!!o.security;react.useEffect(()=>{l&&Zn(o.security);},[l]);let m=react.useRef(t.config?.metadata?.enrich);m.current=t.config?.metadata?.enrich;let b=react.useMemo(()=>{if(t.config)return {...t.config,metadata:{...t.config.metadata,enrich:async d=>{let h=m.current,u=h?await h(d):{},p=Qn(),f=Nt(),g=yt();return {...u,...p.consoleLogs.length>0?{_consoleLogs:p.consoleLogs}:{},...p.networkErrors.length>0?{_networkErrors:p.networkErrors}:{},...f.findings.length>0?{_securityFindings:f.findings}:{},...g.length>0?{_clickEvents:g}:{}}}}}},[]);return react.useEffect(()=>{Kn();let d=document.createElement("div");d.setAttribute("data-blocfeed-ui-root","true"),d.setAttribute("data-blocfeed-ui","true"),d.setAttribute("data-bf-theme",s);let h=o.ui?.zIndex;typeof h=="number"&&d.style.setProperty("--bf-z",String(h));let u=o.ui?.theme;u&&(u.accentColor&&d.style.setProperty("--bf-accent",u.accentColor),u.panelBackground&&d.style.setProperty("--bf-panel-bg",u.panelBackground),u.panelForeground&&d.style.setProperty("--bf-panel-fg",u.panelForeground),u.fontFamily&&d.style.setProperty("--bf-font",u.fontFamily));let p=g=>g.stopPropagation(),f=["pointerdown","pointerup","mousedown","mouseup","click","touchstart","touchend"];for(let g of f)d.addEventListener(g,p);try{document.body.appendChild(d);}catch{return}return i(d),()=>{for(let g of f)d.removeEventListener(g,p);d.remove(),i(null);}},[o.ui?.zIndex,o.ui?.theme?.accentColor,o.ui?.theme?.panelBackground,o.ui?.theme?.panelForeground,o.ui?.theme?.fontFamily,s]),!c||!r?null:reactDom.createPortal(jsxRuntime.jsx(Pt,{blocfeed_id:o.blocfeed_id,...b?{config:b}:{},children:jsxRuntime.jsx(Ca,{config:o,handleRef:n})}),r)});var Vn="0.22.0",pd={init(e){ke(e);},identify(e){Un(e);},track:Fe};
884
+ exports.A=Zn;exports.B=Nt;exports.C=Sc;exports.D=Dt;exports.E=Ra;exports.F=Vn;exports.G=pd;exports.a=T;exports.b=Gt;exports.c=en;exports.d=tn;exports.e=ht;exports.f=nn;exports.g=za;exports.h=on;exports.i=yt;exports.j=ar;exports.k=wt;exports.l=xt;exports.m=Et;exports.n=kt;exports.o=wr;exports.p=_t;exports.q=xn;exports.r=Un;exports.s=Fe;exports.t=Be;exports.u=qn;exports.v=Pt;exports.w=Gn;exports.x=Jn;exports.y=Qn;exports.z=xc;