blocfeed 0.17.3 → 0.18.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 +10 -0
- package/dist/chunk-FBLTAHNW.cjs +2 -0
- package/dist/chunk-GNKDVHVD.js +2 -0
- package/dist/engine.cjs +1 -1
- package/dist/engine.js +1 -1
- package/dist/main.cjs +3 -3
- package/dist/main.d.cts +60 -1
- package/dist/main.d.ts +60 -1
- package/dist/main.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-4VWH5ZG6.cjs +0 -2
- package/dist/chunk-CS63UWFR.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.18.0 — 2026-04-30
|
|
4
|
+
|
|
5
|
+
- **feat:** new `track(name, properties?, options?)` API on `BlocFeedApi` and exported as `BlocFeed.track()` for non-React usage. Send custom events to BlocFeed for funnels, conversion tracking, and segment filters.
|
|
6
|
+
- Buffered + flushed periodically (every 5s OR 50 events OR 1 KB OR pagehide)
|
|
7
|
+
- Auto-attaches page_url, user_agent, current session_id, identified user_id
|
|
8
|
+
- Client-side validation: event_name `/^[a-z][a-z0-9_]{0,127}$/`, ≤50 properties keys, ≤1 KB serialized
|
|
9
|
+
- Offline queue (localStorage-backed, capped at 500 events)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
3
13
|
## 0.17.3 — 2026-04-28
|
|
4
14
|
|
|
5
15
|
### Added
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var rrweb=require('rrweb');function _(){return typeof window<"u"&&typeof document<"u"}function We(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 Se(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Zt(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function Gt(e){return e.replace(/\s+/g," ").trim()}function O(e,t=140){let n=e.textContent;if(!n)return;let o=Gt(n);if(o)return o.length<=t?o:`${o.slice(0,t-1)}\u2026`}function Jt(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var Ze=["data-testid","data-test-id","data-test","data-qa","data-cy"],je="data-blocfeed-component";function V(e){let t=e.closest(`[${je}]`);if(!t)return;let o=t.getAttribute(je)?.trim();return o||void 0}function Y(e,t=5){let n=[],o=e,r=0;for(;o&&r<t*4;){let i=V(o);if(i&&n[n.length-1]!==i&&(n.push(i),n.length>=t))break;o=o.parentElement,r++;}return n}function Qt(e){for(let t of Ze){let n=e.closest(`[${t}]`);if(!n)continue;let r=n.getAttribute(t)?.trim();if(r)return r}}function Ke(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 W(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 Q(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!W(t.name))return t.name}}function F(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 F(r)}}}function ke(e){let t=Ke(e);if(!t)return;let n=Q(t._debugInfo);if(n)return n;let o=t._debugOwner!==void 0;if(o){let a=t._debugOwner;for(let c=0;a&&c<50;c+=1){let u=Q(a._debugInfo);if(u)return u;let d=F(a.type)??F(a.elementType);if(d&&!W(d))return d;a=a._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let a=t._owner;for(let c=0;a&&c<50;c+=1){let u=Q(a._debugInfo);if(u)return u;let d=F(a.type)??F(a.elementType);if(d&&!W(d))return d;a=a._owner;}}let i=t,l=o?80:25;for(let a=0;i&&a<l;a+=1){let c=Q(i._debugInfo);if(c)return c;let u=F(i.type)??F(i.elementType);if(u&&!W(u))return u;i=i.return;}let s=e.parentElement;for(let a=0;s&&a<15;a+=1){let c=Ke(s);if(c){let u=Q(c._debugInfo);if(u)return u;let d=F(c.type)??F(c.elementType);if(d&&!W(d))return d;if(c._debugOwner){let p=F(c._debugOwner.type)??F(c._debugOwner.elementType);if(p&&!W(p))return p}if(c._owner&&c._owner!==c._debugOwner){let p=F(c._owner.type)??F(c._owner.elementType);if(p&&!W(p))return p}}s=s.parentElement;}}function en(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${We(n)}`;for(let o of Ze){let r=e.getAttribute(o);if(r)return `${t}[${o}="${We(r)}"]`}return `${t}:nth-of-type(${Jt(e)})`}function j(e,t=10){let n=[],o=e;for(;o&&n.length<t;){let r=en(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}var tn=new Set(["button","link","tab","menuitem"]);function Ge(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&&tn.has(t))return "role";try{if(window.getComputedStyle(e).cursor==="pointer")return "cursor_pointer"}catch{}return null}function Ye(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function Te(e,t){if(!e||Ye(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(Ye(n,t.ignoreSelectors))return null;if(t.isSelectable?t.isSelectable(n):nn(n))return n;n=n.parentElement;}return null}function ie(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 nn(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function Je(e){let t=e.getBoundingClientRect(),n={selector:j(e),tagName:e.tagName.toLowerCase(),rect:Se(t),pageRect:Zt(t)},o=e.getAttribute("id");o&&(n.id=o);let r=e.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=O(e);i&&(n.textSnippet=i);let l=V(e)??ke(e);l&&(n.componentName=l);let s=Qt(e);return s&&(n.testId=s),n}var Ce=null;async function Qe(){return Ce||(Ce=import('html-to-image')),Ce}async function on(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 et(e,t){let{width:n,height:o}=await on(e);return {dataUrl:e,mime:t,width:n,height:o}}function Z(e){if(e?.aborted)throw new Error("Aborted")}function tt(){return {async captureElement(e,t){if(!_())throw new Error("captureElement can only run in the browser");Z(t.signal);let n=await Qe();Z(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 Z(t.signal),await et(o,t.mime)},async captureFullPage(e){if(!_())throw new Error("captureFullPage can only run in the browser");Z(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)),l=Math.max(1,Math.round(o*r)),s=await Qe();Z(e.signal);let a=e.mime==="image/jpeg"?await s.toJpeg(t,{width:i,height:l,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await s.toPng(t,{width:i,height:l,pixelRatio:e.pixelRatio});return Z(e.signal),await et(a,e.mime)}}}function rn(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function w(e,t,n){let o={kind:e,message:rn(t)};return n&&(o.detail=n),o}var sn=12e3,an=2048,cn=.92;function nt(){return Date.now()}function ln(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 ot(e,t,n){let o=new Promise((i,l)=>{let s=setTimeout(()=>l(new Error("Timeout")),t);typeof s.unref=="function"&&s.unref();}),r=[e,o];return n&&r.push(ln(n)),await Promise.race(r)}function un(e){if(!_())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function dn(e){return !!(e?.element||e?.fullPage)}function rt(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 it(e){let{selectionElement:t,capture:n,signal:o}=e;if(!_()||!dn(n))return;let r=nt(),i=[],l=n?.timeoutMs??sn,s=n?.maxDimension??an,a=n?.mime??"image/png",c=n?.quality??cn,u=n?.adapter??tt(),d={},p=un(n);if(n?.element&&t)try{let m=t.getBoundingClientRect(),h=Math.min(1,s/Math.max(m.width,m.height)),E=Math.min(p,p*h),b=await ot(Promise.resolve(u.captureElement(t,{...rt({mime:a,quality:c,pixelRatio:E,maxDimension:s,includeQuality:a==="image/jpeg",...o?{signal:o}:{}})})),l,o);d.element=b;}catch(m){if(o?.aborted)throw m;i.push(w("capture_failed",m,{target:"element"}));}if(n?.fullPage)try{let m=await ot(Promise.resolve(u.captureFullPage(rt({mime:a,quality:c,pixelRatio:p,maxDimension:s,includeQuality:a==="image/jpeg",...o?{signal:o}:{}}))),l,o);d.fullPage=m;}catch(m){if(o?.aborted)throw m;i.push(w("capture_failed",m,{target:"fullPage"}));}let g=nt(),f={startedAt:r,finishedAt:g,durationMs:Math.max(0,g-r)};return i.length>0&&(f.errors=i),{...d,diagnostics:f}}function fn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function pn(){return _()?{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:fn()}:{}}function mn(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 st(e){let{config:t,context:n,user:o}=e;if(t?.enabled===false)return {};let r={...pn(),...mn(o)},i=t?.enrich;if(!i)return r;try{let l=await i(n);return {...r,...l}}catch(l){let s=w("unknown",l);return {...r,blocfeedMetadataError:s.message}}}var ee="blocfeed-queue",gn=50;function Re(){if(!_())return [];try{let e=localStorage.getItem(ee);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(ee);}catch{}return []}catch(e){console.warn("[BlocFeed] offline queue could not be read \u2014 resetting",e);try{localStorage.removeItem(ee);}catch{}return []}}function Ae(e){if(_())try{e.length===0?localStorage.removeItem(ee):localStorage.setItem(ee,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 hn(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 xe(e){let t=Re(),n=hn(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>gn;)t.shift();Ae(t);}function at(){let e=Re();return e.length===0?[]:(Ae([]),e.map(t=>t.payload))}function zo(){Ae([]);}function Xo(){return Re().length}var bn=200,te=[],ct=0,se=false;function lt(e){let t=e.target;if(!(t instanceof Element)||t.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-ct,path:window.location.pathname,tagName:t.tagName.toLowerCase()},o=O(t,100);o&&(n.textSnippet=o);let r=V(t)??ke(t);r&&(n.componentName=r),te.length<bn&&te.push(n);}var ut={capture:true,passive:true};function dt(){se||!_()||(se=true,te=[],ct=Date.now(),document.addEventListener("click",lt,ut));}function ft(){se&&(se=false,document.removeEventListener("click",lt,ut));}function yn(){return [...te]}function vn(){te=[];}var wn=3e4,En=25e5,pt="video/webm",_n=250,Sn=1e3,kn=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function mt(){if(typeof MediaRecorder>"u")return null;for(let e of kn)if(MediaRecorder.isTypeSupported(e))return e;return null}function Tn(){return !_()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:mt()!==null}async function Ie(e){let{config:t,signal:n}=e;if(!_()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw w("recording_failed",new Error("Screen recording is not supported in this browser"));let o=mt();if(!o)throw w("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw w("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(h){let E=h instanceof DOMException&&h.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw w("recording_failed",new Error(E))}if(n?.aborted)throw r.getTracks().forEach(h=>h.stop()),w("aborted",new Error("Recording aborted after permission"));let i=t?.maxDurationMs??wn,l=t?.videoBitsPerSecond??En,s=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:l}),a=[],c=[],u=0,d=null,p=null,g=false,f=()=>{ft(),d!==null&&(clearInterval(d),d=null),p!==null&&(clearTimeout(p),p=null),r.getTracks().forEach(h=>h.stop());},m=new Promise((h,E)=>{s.ondataavailable=k=>{k.data.size>0&&a.push(k.data);},s.onstop=()=>{if(g)return;g=true,f();let k=Date.now()-u,T=new Blob(a,{type:pt}),y=URL.createObjectURL(T);h({mime:pt,blobUrl:y,blob:T,durationMs:k,sizeBytes:T.size});},s.onerror=()=>{g||(g=true,f(),E(w("recording_failed",new Error("MediaRecorder error"))));};let b=r.getVideoTracks()[0];if(b&&b.addEventListener("ended",()=>{s.state!=="inactive"&&s.stop();}),n){let k=()=>{g||(g=true,s.state!=="inactive"&&s.stop(),f(),E(w("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",k,{once:true});}});return s.start(Sn),dt(),u=Date.now(),d=setInterval(()=>{let h=Date.now()-u;for(let E of c)E(h);},_n),p=setTimeout(()=>{!g&&s.state!=="inactive"&&s.stop();},i),{result:m,stop(){!g&&s.state!=="inactive"&&s.stop();},onTick(h){c.push(h);},abort(){g||(g=true,s.state!=="inactive"&&s.stop(),f());}}}var Cn=6e4,gt="audio/webm",Rn=250,An=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function ht(){if(typeof MediaRecorder>"u")return null;for(let e of An)if(MediaRecorder.isTypeSupported(e))return e;return null}function xn(){return !_()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:ht()!==null}async function Me(e){let{config:t,signal:n}=e;if(!_()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw w("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=ht();if(!o)throw w("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw w("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(m){let h=m instanceof DOMException&&m.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw w("recording_failed",new Error(h))}if(n?.aborted)throw r.getTracks().forEach(m=>m.stop()),w("aborted",new Error("Voice recording aborted after permission"));let i=t?.maxDurationMs??Cn,l=new MediaRecorder(r,{mimeType:o}),s=[],a=[],c=0,u=null,d=null,p=false,g=()=>{u!==null&&(clearInterval(u),u=null),d!==null&&(clearTimeout(d),d=null),r.getTracks().forEach(m=>m.stop());},f=new Promise((m,h)=>{if(l.ondataavailable=E=>{E.data.size>0&&s.push(E.data);},l.onstop=()=>{if(p)return;p=true,g();let E=Date.now()-c,b=new Blob(s,{type:gt});m({blob:b,mime:gt,durationMs:E});},l.onerror=()=>{p||(p=true,g(),h(w("recording_failed",new Error("MediaRecorder error"))));},n){let E=()=>{p||(p=true,l.state!=="inactive"&&l.stop(),g(),h(w("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",E,{once:true});}});return l.start(1e3),c=Date.now(),u=setInterval(()=>{let m=Date.now()-c;for(let h of a)h(m);},Rn),d=setTimeout(()=>{d=null,!p&&l.state!=="inactive"&&l.stop();},i),{result:f,stop(){!p&&l.state!=="inactive"&&l.stop();},onTick(m){a.push(m);},abort(){p||(p=true,l.state!=="inactive"&&l.stop(),g());}}}var In=12e3,Mn=2,Fn=500,Pn=2e3,Fe="https://blocfeed.com/api/feedback",Bn="https://blocfeed.com/api/feedback/voice",bt=0,wt="blocfeed-viewer-token",Et="blocfeed-my-feedback-url";function Ln(){try{return localStorage.getItem(wt)}catch{return null}}function ar(){try{return localStorage.getItem(Et)}catch{return null}}function Dn(e,t){try{localStorage.setItem(wt,e),t&&localStorage.setItem(Et,t);}catch{}}function yt(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 Nn(e){return e>=500&&e<=599}function On(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),l=new Uint8Array(i.length);for(let s=0;s<i.length;s+=1)l[s]=i.charCodeAt(s);return new Blob([l],{type:r})}function Hn(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 vt(e,t,n){let o=On(t);await fetch(e,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function Un(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(`${Fe}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function qn(e){await fetch(`${Fe}/${e.feedbackId}/video`,{method:"POST",body:e.blob,headers:{"content-type":e.blob.type},...e.signal?{signal:e.signal}:{}});}async function _t(e){let{signal:t,transport:n}=e;if(Date.now()-bt<Pn)return {ok:false,error:w("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??In,i=n?.maxAttempts??Mn,l=n?.backoffMs??Fn,s=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),a=!!e.payload.video?.blob,c=s||a,{lean:u,extracted:d,extractedVideo:p}=c?Hn(e.payload):{lean:e.payload,extracted:{},extractedVideo:{}},g=Ln();g&&(u.viewer_token=g);let f={...d,...e.screenshotDataUrls};for(let m=1;m<=i;m+=1){let h=new AbortController,E=setTimeout(()=>h.abort(),r),b=()=>h.abort();t&&t.addEventListener("abort",b,{once:true});try{let k=await fetch(Fe,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(u),signal:h.signal});if(k.ok){bt=Date.now();let y;try{y=await k.json();}catch{}if(y?.viewer_token&&Dn(y.viewer_token,y.my_feedback_url),(f.element||f.fullPage)&&y){let P=y.upload_urls;if(P){let z=[];f.element&&P.element&&z.push(vt(P.element,f.element,t)),f.fullPage&&P.fullPage&&z.push(vt(P.fullPage,f.fullPage,t));try{await Promise.all(z);}catch{}}else if(y.feedback_id)try{await Un({feedbackId:y.feedback_id,extracted:f,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}if(p.blob&&y){let P=y.upload_urls;if(P?.video)try{await fetch(P.video,{method:"PUT",body:p.blob,headers:{"content-type":p.blob.type},...t?{signal:t}:{}});}catch{}else if(y.feedback_id)try{await qn({feedbackId:y.feedback_id,blob:p.blob,...t?{signal:t}:{}});}catch{}}let D={ok:!0,status:k.status};return y&&(D.apiResponse=y),D}if(m<i&&Nn(k.status)){let y=.85+Math.random()*.3,H=Math.round(l*2**(m-1)*y);await yt(H,t);continue}let T=`HTTP ${k.status}`;try{let y=await k.json();y?.error&&(T=y.error);}catch{}return {ok:!1,status:k.status,error:w("api_failed",new Error(T))}}catch(k){if(h.signal.aborted||t?.aborted)return {ok:false,error:w("aborted",k)};if(m<i){let T=.85+Math.random()*.3,y=Math.round(l*2**(m-1)*T);await yt(y,t);continue}return {ok:false,error:w("api_failed",k)}}finally{clearTimeout(E),t&&t.removeEventListener("abort",b);}}return {ok:false,error:w("api_failed",new Error("Failed"))}}async function St(e){let{blob:t,mime:n,blocfeedId:o,signal:r}=e,i=await fetch(Bn,{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 w("api_failed",new Error(s?.error??`Voice API returned ${i.status}`))}let l=await i.json();return {text:l.text??"",warning:l.warning}}var kt="bf_behavioral_session",ae=null;function M(){try{let e=sessionStorage.getItem(kt);if(e)return e;let t=Tt();return sessionStorage.setItem(kt,t),t}catch{return ae||(ae=Tt(),ae)}}function Tt(){let e=Math.random().toString(36).slice(2,10).padEnd(8,"0");return `bf_${Date.now()}_${e}`}var Vn="https://blocfeed.com/api/events/track",zn=5e3,Xn=50,$n=1024,ue="blocfeed-events-queue",Ct=500,Rt=100,Wn=/^[a-z][a-z0-9_]{0,127}$/,At=50,xt=1024,It;function dr(e){It=e;}function jn(e){if(typeof e!="string"||!Wn.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 Kn(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>At)throw new Error(`[BlocFeed] track(): properties has ${t.length} keys, max ${At}.`);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>xt)throw new Error(`[BlocFeed] track(): properties serialized to ${n.length} bytes, max ${xt}. Server allows 8192 bytes \u2014 the client cap is defensive; trim down or split the event.`);return e}function Pe(){if(typeof localStorage>"u")return [];try{let e=localStorage.getItem(ue);if(!e)return [];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{try{localStorage.removeItem(ue);}catch{}return []}}function Be(e){if(!(typeof localStorage>"u"))try{if(e.length===0)localStorage.removeItem(ue);else {let t=e.length>Ct?e.slice(e.length-Ct):e;localStorage.setItem(ue,JSON.stringify(t));}}catch{}}var B=null;function Yn(){if(B)return B;if(typeof window>"u")return null;let e=Zn();return e?(B={blocfeedId:e,endpoint:Vn,events:[],bytes:0,flushTimer:null,pageHideHandler:null,visibilityHandler:null},B.flushTimer=setInterval(()=>{le(false);},zn),B.pageHideHandler=()=>{le(true);},B.visibilityHandler=()=>{document.visibilityState==="hidden"&&le(true);},window.addEventListener("pagehide",B.pageHideHandler),document.addEventListener("visibilitychange",B.visibilityHandler),B):null}function Zn(){try{let t=window.__blocfeed_id__;return typeof t=="string"&&t.length>0?t:null}catch{return null}}function Mt(e){try{window.__blocfeed_id__=e;}catch{}B&&(B.blocfeedId=e);}function fr(e,t,n){jn(e);let o=Kn(t),r=n?.occurredAt?to(n.occurredAt):new Date().toISOString(),i={event_name:e,properties:o,occurred_at:r},l=n?.sessionId??Jn();l&&(i.session_id=l);let s=n?.userId??It;s&&(i.user_id=s);let a=n?.pageUrl??Qn();a&&(i.page_url=a);let c=eo();c&&(i.user_agent=c);let u=Yn();if(!u){let d=Pe();d.push(i),Be(d);return}u.events.push(i),u.bytes+=Gn(i),(u.events.length>=Xn||u.bytes>=$n)&&le(false);}async function le(e){let t=B;if(!t)return;let o=Pe().concat(t.events);if(t.events=[],t.bytes=0,Be([]),o.length!==0)for(let r=0;r<o.length;r+=Rt){let i=o.slice(r,r+Rt),l=JSON.stringify({blocfeed_id:t.blocfeedId,events:i});if(e&&no())try{let s=new Blob([l],{type:"application/json"});navigator.sendBeacon(t.endpoint,s)||ce(i);continue}catch{ce(i);continue}try{(await fetch(t.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:l})).ok||ce(i);}catch{ce(i);}}}function ce(e){let t=Pe();Be(t.concat(e));}function Gn(e){try{return JSON.stringify(e).length}catch{return 256}}function Jn(){try{return M()}catch{return}}function Qn(){try{return typeof window<"u"?window.location.href:void 0}catch{return}}function eo(){try{return typeof navigator<"u"?navigator.userAgent:void 0}catch{return}}function to(e){return e instanceof Date?e.toISOString():new Date(e).toISOString()}function no(){return typeof navigator<"u"&&typeof navigator.sendBeacon=="function"}var oo={enabled:true,sampling:1,ignoreSelectors:["[data-blocfeed-ui]","[data-blocfeed-ignore]"],rageClick:{enabled:true,threshold:3,windowMs:1e3},httpFail:{enabled:true,statusCodes:[400,401,403,422,500,502,503,504],ignoreUrls:["/api/behavioral-events","/api/feedback"]},redirectLoop:{enabled:true,threshold:3,windowMs:2e3},formDataLoss:{enabled:true},deadClick:{enabled:true,observationWindowMs:300,rateLimitPerSelector:5}};function Ft(e){let t=oo;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 Pt(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"}),l=`${e.endpoint}?_bfid=${encodeURIComponent(e.blocfeedId)}`;try{navigator.sendBeacon(l,i);}catch{}}return {enqueue(r){t.push(r);},flush:n,flushBeacon:o,size(){return t.length}}}function Bt(e,t){if(!e.rageClick.enabled)return ()=>{};let{threshold:n,windowMs:o}=e.rageClick,r=new Map;function i(l){try{let s=l.target;if(!s||!(s instanceof Element)||ie(s,e.ignoreSelectors))return;let a=j(s,4);if(!a)return;let c=Date.now(),d=(r.get(a)??[]).filter(p=>c-p<=o);if(d.push(c),r.set(a,d),d.length>=n){let p=ro(s),g=O(s,200)??null,f=s.tagName.toLowerCase(),m=s.id||null,h=V(s)??null,E=Y(s,5),b={session_id:M(),event_type:"rage_click",page_url:typeof window>"u"?"":window.location.href,selector:a,element_text:g,event_data:{click_count:d.length,window_ms:o,...p?{disabled:!0}:{},tag_name:f,...m?{element_id:m}:{},...h?{component_name:h}:{},...E.length>0?{parent_components:E}:{}},created_at:new Date().toISOString()};t(b),r.set(a,[]);}}catch{}}return document.addEventListener("click",i,{capture:true,passive:true}),()=>document.removeEventListener("click",i,{capture:true})}function ro(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 Dt=0,Nt=null,de=null,fe=[],io=1500;function so(){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;Dt=Date.now();let r=o.closest("form");Nt=(r?j(r,3):"")||null,de=O(o,100)??null,fe=Y(o,5);}catch{}}return document.addEventListener("click",e,{capture:true,passive:true}),()=>document.removeEventListener("click",e,{capture:true})}function Ot(e,t){if(!e.httpFail.enabled)return ()=>{};let{statusCodes:n,ignoreUrls:o}=e.httpFail,r=new Set(n),i=so(),l=globalThis.fetch,s=async(d,p)=>{let g=typeof d=="string"?d:d instanceof URL?d.toString():d.url,f=(p?.method??d.method??"GET").toUpperCase(),m=await l.call(globalThis,d,p);try{!Lt(g,o)&&r.has(m.status)&&t(u(m.status,g,f));}catch{}return m};globalThis.fetch=s;let a=XMLHttpRequest.prototype.open,c=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(d,p,...g){return this.__bf_url=p,this.__bf_method=d.toUpperCase(),a.call(this,d,p,...g)},XMLHttpRequest.prototype.send=function(d){let p=()=>{try{let g=this.__bf_url??"",f=this.__bf_method??"GET";!Lt(g,o)&&r.has(this.status)&&t(u(this.status,g,f));}catch{}};return this.__bf_handler=p,this.addEventListener("loadend",p),c.call(this,d??null)},()=>{globalThis.fetch=l,XMLHttpRequest.prototype.open=a,XMLHttpRequest.prototype.send=c,i(),de=null,fe=[];};function u(d,p,g){let m=Date.now()-Dt<io;return {session_id:M(),event_type:"error",page_url:typeof window>"u"?"":window.location.href,selector:null,element_text:null,event_data:{http_status:d,request_url:p,method:g,form_selector:m?Nt:null,...m&&de?{button_text:de}:{},...m&&fe.length>0?{parent_components:fe}:{}},created_at:new Date().toISOString()}}}function Lt(e,t){if(t.length===0)return false;for(let n of t)if(e.includes(n))return true;return false}var ao=3e4;function Ht(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,l=history.pushState,s=history.replaceState;function a(u){try{let d=Date.now(),p=i.get(u)??0;if(d<p)return;let f=(r.get(u)??[]).filter(m=>d-m<=o);if(f.push(d),r.set(u,f),f.length>=n){let m={session_id:M(),event_type:"thrashing",page_url:window.location.href,selector:null,element_text:null,event_data:{count:f.length,url:u,window_ms:o},created_at:new Date().toISOString()};t(m),i.set(u,d+ao),r.set(u,[]);}}catch{}}function c(){let u=window.location.pathname+window.location.search;a(u);}return history.pushState=function(...u){let d=l.apply(this,u);return c(),d},history.replaceState=function(...u){let d=s.apply(this,u);return c(),d},window.addEventListener("popstate",c),()=>{history.pushState=l,history.replaceState=s,window.removeEventListener("popstate",c);}}function Ut(e,t){if(!e.formDataLoss.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let n=new Set,o=0;function r(c){let u=c.closest("form");return u?u.id?`#${u.id}`:"form":null}function i(c){try{let u=c.target;if(!u||!(u instanceof HTMLInputElement||u instanceof HTMLTextAreaElement||u instanceof HTMLSelectElement))return;let d=r(u);if(!d)return;n.has(d)||n.add(d),o++;}catch{}}function l(c){if(n.size===0)return;let u=Array.from(n),d={session_id:M(),event_type:"form_abandonment",page_url:window.location.href,selector:u[0]??null,element_text:null,event_data:{cause:c,field_count:o,forms:u},created_at:new Date().toISOString()};t(d);}function s(c){c.persisted&&l("bfcache_restore");}function a(){l("beforeunload_after_edit");}return document.addEventListener("input",i,{capture:true,passive:true}),window.addEventListener("pageshow",s),window.addEventListener("beforeunload",a),()=>{document.removeEventListener("input",i,{capture:true}),window.removeEventListener("pageshow",s),window.removeEventListener("beforeunload",a);}}function co(){let e={domMutationCount:0,urlChangeCount:0,networkCount:0,filePickerCount:0,uninstall:()=>{}},t=new MutationObserver(()=>{e.domMutationCount+=1;});t.observe(document.body,{childList:true,attributes:true,characterData:true,subtree:true});let n=history.pushState,o=history.replaceState;history.pushState=function(...a){return e.urlChangeCount+=1,n.apply(this,a)},history.replaceState=function(...a){return e.urlChangeCount+=1,o.apply(this,a)};let r=()=>{e.urlChangeCount+=1;};window.addEventListener("popstate",r);let i=globalThis.fetch;if(i){let a=(c,u)=>(e.networkCount+=1,i.call(globalThis,c,u));globalThis.fetch=a;}let l=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(a,c,...u){return e.networkCount+=1,l.call(this,a,c,...u)};let s=HTMLInputElement.prototype.click;return HTMLInputElement.prototype.click=function(){return this.type==="file"&&(e.filePickerCount+=1),s.call(this)},e.uninstall=()=>{t.disconnect(),history.pushState=n,history.replaceState=o,window.removeEventListener("popstate",r),i&&(globalThis.fetch=i),XMLHttpRequest.prototype.open=l,HTMLInputElement.prototype.click=s;},e}function qt(e,t){if(!e.deadClick.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let{observationWindowMs:n,rateLimitPerSelector:o}=e.deadClick,r=new Map,i=co();function l(s){try{let a=s.target;if(!a||!(a instanceof Element)||s.button!==0||s.metaKey||s.ctrlKey||s.altKey||s.shiftKey||ie(a,e.ignoreSelectors)||a.closest("label"))return;if(a instanceof HTMLInputElement){let y=a.type;if(y==="checkbox"||y==="radio"||y==="file")return}if(a instanceof HTMLSelectElement||a.closest("a[target='_blank'], a[download]")||a.closest('[contenteditable="true"]'))return;try{let y=window.getSelection();if(y&&y.toString().length>0)return}catch{}let c=Ge(a);if(!c)return;let u=j(a,4);if(!u)return;let d=i.domMutationCount,p=i.urlChangeCount,g=i.networkCount,f=i.filePickerCount,m=new Date().toISOString(),h=O(a,200)??null,E=a.tagName.toLowerCase(),b=a.id||null,k=V(a)??null,T=Y(a,5);setTimeout(()=>{if(i.domMutationCount!==d||i.urlChangeCount!==p||i.networkCount!==g||i.filePickerCount!==f)return;let y=r.get(u)??0;if(y>=o)return;r.set(u,y+1);let H={session_id:M(),event_type:"dead_click",page_url:typeof window>"u"?"":window.location.href,selector:u,element_text:h,event_data:{tag_name:E,...b?{element_id:b}:{},...k?{component_name:k}:{},...T.length>0?{parent_components:T}:{},clickable_reason:c},created_at:m};t(H);},n);}catch{}}return document.addEventListener("click",l,{capture:true,passive:true}),()=>{document.removeEventListener("click",l,{capture:true}),i.uninstall();}}var uo="https://blocfeed.com/api/replay-events";function Vt(e){if(!e.config.enabled)return ()=>{};if(typeof window>"u")return ()=>{};if(typeof globalThis.matchMedia>"u")return ()=>{};let t=M();if(po(t)%100/100>=e.config.sampling)return ()=>{};let o=Date.now(),r=e.config.endpoint??uo,i=[],l=0,s=false,a=null,c=`bf_replay_chunkseq_${t}`,u=0;try{let T=sessionStorage.getItem(c);T&&(u=parseInt(T,10)||0);}catch{}let d=(T=false)=>{if(i.length===0)return;let y=T?mo(i):i;i=[],l=0;let H=u++;try{sessionStorage.setItem(c,String(u));}catch{}go({blocfeedId:e.blocfeedId,sessionId:t,sessionStartedAtMs:o,chunkSeq:H,events:y,endpoint:r,useBeacon:T});},p=setInterval(()=>{s||d();},e.config.flushIntervalMs),g=setTimeout(()=>{d(),k();},e.config.maxDurationMs),f=null,m=()=>{f&&clearTimeout(f),f=setTimeout(()=>{d(),k();},e.config.inactivityTimeoutMs);};m();let h=()=>{d(true);};window.addEventListener("pagehide",h);let E=e.config.masking,b={emit(T){s||(i.push(T),l+=fo(T),m(),l>=e.config.flushSizeBytes&&d());},recordCanvas:false,sampling:{mousemove:50}};E.maskAllInputs!==void 0&&(b.maskAllInputs=E.maskAllInputs),E.maskTextSelector!==void 0&&(b.maskTextSelector=E.maskTextSelector),E.maskTextClass!==void 0&&(b.maskTextClass=E.maskTextClass),E.blockSelector!==void 0&&(b.blockSelector=E.blockSelector),a=rrweb.record(b)??null;function k(){if(!s&&(s=true,clearInterval(p),clearTimeout(g),f&&clearTimeout(f),window.removeEventListener("pagehide",h),a))try{a();}catch{}}return k}function fo(e){try{return JSON.stringify(e).length}catch{return 1024}}function po(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return Math.abs(t)}function mo(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 go(e){let t=JSON.stringify({blocfeed_id:e.blocfeedId,session_id:e.sessionId,session_started_at_ms:e.sessionStartedAtMs,chunk_seq:e.chunkSeq,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 ho={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 zt(e){let t=ho;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 bo=5e3,pe=class{constructor(t){this.submitter=null;this.detectorUninstallers=[];this.flushTimer=null;this.pageHideHandler=null;this.installed=false;this.opts=t,this.resolved=Ft(t.config);}install(){if(this.installed||!this.resolved.enabled||!(this.opts.passiveSampler??(()=>Math.random()<this.resolved.sampling))())return;Mt(this.opts.blocfeedId);let n=this.opts.endpoint??"https://blocfeed.com/api/behavioral-events";this.submitter=this.opts.submitter??Pt({endpoint:n,blocfeedId:this.opts.blocfeedId});let o=i=>{this.submitter?.enqueue(i);};this.detectorUninstallers.push(Bt(this.resolved,o)),this.detectorUninstallers.push(Ot(this.resolved,o)),this.detectorUninstallers.push(Ht(this.resolved,o)),this.detectorUninstallers.push(Ut(this.resolved,o)),this.detectorUninstallers.push(qt(this.resolved,o));let r=zt(this.opts.config?.sessionReplay);this.detectorUninstallers.push(Vt({blocfeedId:this.opts.blocfeedId,config:r})),this.flushTimer=setInterval(()=>{this.submitter?.flush();},bo),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;}}};function Le(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 me(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function ge(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function Xt(e,t){if(!_())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,l=null,s=(f,m=false)=>{if(!f){i=null,l=null,t.onHover(null);return}let h=Se(f.getBoundingClientRect()),E=`${Math.round(h.x)}:${Math.round(h.y)}:${Math.round(h.width)}:${Math.round(h.height)}`;!m&&f===i&&E===l||(i=f,l=E,t.onHover({element:f,rect:h}));},a=Le(f=>{if(me(f.target))return;let m=document.elementFromPoint(f.clientX,f.clientY),h=Te(m,r);s(h);}),c=Le(()=>{i&&s(i,true);}),u=f=>{me(f.target)||(ge(f),f.pointerType==="mouse"&&f.preventDefault());},d=f=>{me(f.target)||(ge(f),f.pointerType==="mouse"&&f.preventDefault());},p=f=>{if(me(f.target))return;ge(f),f.preventDefault();let m=document.elementFromPoint(f.clientX,f.clientY),h=Te(m,r);h&&t.onSelect({element:h,descriptor:Je(h)});},g=f=>{f.key==="Escape"&&(ge(f),f.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",a,{capture:true,passive:true}),window.addEventListener("pointerdown",u,{capture:true}),window.addEventListener("pointerup",d,{capture:true}),window.addEventListener("click",p,{capture:true}),window.addEventListener("keydown",g,{capture:true}),window.addEventListener("scroll",c,{capture:true,passive:true}),window.addEventListener("resize",c,{passive:true}),{stop(){window.removeEventListener("pointermove",a,{capture:true}),window.removeEventListener("pointerdown",u,{capture:true}),window.removeEventListener("pointerup",d,{capture:true}),window.removeEventListener("click",p,{capture:true}),window.removeEventListener("keydown",g,{capture:true}),window.removeEventListener("scroll",c,{capture:true}),window.removeEventListener("resize",c),a.cancel(),c.cancel(),t.onHover(null);}}}async function De(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 _t(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:w("api_failed",r)},o.ok=false;}return {payload:e.payload,result:o}}var yo=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function vo(e){let t=[...yo,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function $t(){return {phase:"idle"}}function wo(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 li(e){let t=e,n=new pe({blocfeedId:t.blocfeed_id??"",...t.behavioral!==void 0?{config:t.behavioral}:{}});n.install();let o=$t(),r=new Set,i=new Set,l=null,s=null,a=null,c=null,u=0,d=null,p=null,g=null,f=null,m=false,h=()=>{for(let v of r)v(o);},E=v=>{for(let S of i)S(v);},b=v=>{o=v,h();},k=()=>{u+=1,c?.abort(),c=null;},T=()=>{l?.stop(),l=null,E(null),a!==null&&_()&&(document.documentElement.style.cursor=a,a=null);},y=()=>{if(g){try{URL.revokeObjectURL(g.blobUrl);}catch{}g=null;}},H=()=>{p&&(p.abort(),p=null),y();},D=null,P=()=>{f&&(f.abort(),f=null),D&&(D.abort(),D=null);},z=()=>{k(),T(),H(),P(),s=null,b($t());},ze=()=>{if(!_())return;T(),s=null;let v=vo(t.picker);a=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",b({phase:"picking"}),l=Xt(v,{onHover:E,onSelect:({element:S,descriptor:I})=>{s=S,T(),b({phase:"review",selection:I});},onCancel:()=>{z();}});},Xe=()=>{let v=at();if(v.length!==0)for(let S of v)De({payload:S,...t.transport?{transport:t.transport}:{}}).catch(()=>{xe(S);});};if(_()){setTimeout(Xe,1e3);let v=()=>Xe();window.addEventListener("online",v),d=()=>window.removeEventListener("online",v);}return {getState:()=>o,getConfig:()=>t,subscribe(v){return r.add(v),()=>r.delete(v)},subscribeHover(v){return i.add(v),()=>i.delete(v)},start(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||o.phase!=="picking"&&ze();},stop(){z();},clearSelection(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||ze();},setConfig(v){t=v;},async submit(v,S){if(!_()){let R=w("configuration",new Error("BlocFeed submit can only run in the browser"));return b({phase:"error",lastError:R}),{ok:false}}let I=t.blocfeed_id?.trim?.()??"";if(!I){let L={phase:"error",lastError:w("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return o.selection&&(L.selection=o.selection),b(L),{ok:false}}if(m)return {ok:false};if(o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording")return {ok:false};m=true;let x=u+1;u=x,c?.abort(),c=new AbortController;let A=c.signal,C=o.selection,N=S?.capture?{...t.capture,...S.capture}:t.capture,X=!!(N?.element||N?.fullPage),G={phase:X?"capturing":"submitting"};C&&(G.selection=C),b(G);try{let R=X?await it({selectionElement:s,capture:N,signal:A}):void 0;if(A.aborted||u!==x)return {ok:!1};let L={phase:"submitting"};C&&(L.selection=C),R&&(L.capture=R),b(L);let U={};C&&(U.selection=C),R&&(U.capture=R);let J=await st({config:t.metadata,context:U,...t.user?{user:t.user}:{}}),$={version:1,createdAt:new Date().toISOString(),blocfeed_id:I,message:v,metadata:J};S?.category&&($.category=S.category),t.user&&($.user=t.user),C&&($.selection=C),R&&($.screenshots=R),g&&($.video=g);let{result:q}=await De({payload:$,signal:A,...t.transport?{transport:t.transport}:{}});if(A.aborted||u!==x)return q;if(q.ok){y(),s=null;let _e={phase:"success",lastSubmit:q};return C&&(_e.selection=C),R&&(_e.capture=R),b(_e),q}wo(q)&&xe($);let Yt=q.api?.error??w("unknown",new Error("Submission failed")),Ee={phase:"error",lastSubmit:q,lastError:Yt};return C&&(Ee.selection=C),R&&(Ee.capture=R),b(Ee),q}catch(R){if(A.aborted||u!==x)return {ok:false};let U={phase:"error",lastError:A.aborted?w("aborted",R):w("unknown",R)};return C&&(U.selection=C),b(U),{ok:false}}finally{m=false,u===x&&(c=null);}},async startRecording(){if(o.phase!=="review"||!t.recording?.enabled||f||p)return;let v=o.selection,S={phase:"recording",recordingElapsedMs:0};v&&(S.selection=v),b(S);try{let I={config:t.recording};c&&(I.signal=c.signal);let x=await Ie(I);p=x,x.onTick(N=>{if(o.phase==="recording"){let X={phase:"recording",recordingElapsedMs:N};v&&(X.selection=v),b(X);}});let A=await x.result;p=null,g=A;let C={phase:"review",video:A};v&&(C.selection=v),b(C);}catch(I){p=null;let A={phase:"review",lastError:I?.kind?I:w("recording_failed",I)};v&&(A.selection=v),b(A);}},stopRecording(){o.phase!=="recording"||!p||p.stop();},removeVideo(){y();let v=o.selection,S={phase:"review"};v&&(S.selection=v),b(S);},async startVoice(){if(o.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",o.phase,'(expected "review")');return}let v=t.voice;if(!v?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}if(p){console.warn("[BlocFeed] startVoice: ignored \u2014 a screen recording is already in progress");return}P();let S=o.selection,I={phase:"review",voiceRecording:true,voiceElapsedMs:0};S&&(I.selection=S),g&&(I.video=g),b(I);try{let x={config:v};c&&(x.signal=c.signal);let A=await Me(x);f=A,A.onTick(U=>{let J={phase:"review",voiceRecording:!0,voiceElapsedMs:U};S&&(J.selection=S),g&&(J.video=g),b(J);});let C=await A.result;f=null;let N={phase:"review",voiceRecording:!1,voiceTranscribing:!0};S&&(N.selection=S),g&&(N.video=g),b(N),D=new AbortController;let X={blob:C.blob,mime:C.mime,blocfeedId:t.blocfeed_id,signal:D.signal},{text:$e,warning:G}=await St(X);D=null;let R={phase:"review",voiceRecording:!1,voiceTranscribing:!1};S&&(R.selection=S),g&&(R.video=g),b(R);let L={text:$e};return G&&(L.warning=G),L}catch(x){P();let A=x?.kind?x:w("recording_failed",x);console.warn("[BlocFeed] Voice error:",A.message);let C={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:A};S&&(C.selection=S),g&&(C.video=g),b(C);return}},stopVoice(){f&&f.stop();},__unsafeGetSelectedElement(){return s},destroy(){n.uninstall(),z(),r.clear(),i.clear(),d?.(),d=null;}}}var ne=[],oe=[],Wt=20,jt=15,he=[],Kt=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)}:{},be=typeof globalThis<"u"&&typeof globalThis.fetch=="function"?globalThis.fetch:void 0,ye=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.open:void 0,ve=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.send:void 0,Oe=new Set,He=false,Ue=false,we=false,Eo=["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 _o(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 So(e,t){let n=t.map(_o).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)),ne.push(r);ne.length>Wt;)ne.shift();}function Ne(e){let t=e.url.toLowerCase();for(let n of he)if(t.includes(n))return;for(oe.push(e);oe.length>jt;)oe.shift();}function fi(e={}){if(we||!_())return;we=true,Wt=e.consoleLimit??20,jt=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?he=t.map(n=>n.toLowerCase()):he=[...Eo],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let o of n){let r=Kt[o];r&&(Oe.add(o),console[o]=(...i)=>{So(o,i),r.apply(console,i);});}}if(e.network!==false&&be){let n=be;He=true,window.fetch=async function(r,i){let l=typeof r=="string"?r:r instanceof URL?r.toString():r.url,s=(i?.method??"GET").toUpperCase(),a=Date.now();try{let c=await n.call(window,r,i);return c.ok||Ne({url:l.slice(0,500),method:s,status:c.status,statusText:c.statusText,timestamp:a,durationMs:Date.now()-a}),c}catch(c){throw Ne({url:l.slice(0,500),method:s,status:0,statusText:c instanceof Error?c.message:"Network error",timestamp:a,durationMs:Date.now()-a}),c}};}if(e.network!==false&&ye&&ve){let n=ye,o=ve;Ue=true,XMLHttpRequest.prototype.open=function(r,i,...l){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...l])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",l=this.__bf_url||"",s=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let a={url:l.slice(0,500),method:i,status:this.status,timestamp:s,durationMs:Date.now()-s};this.statusText&&(a.statusText=this.statusText),Ne(a);}},{once:true}),o.apply(this,r)};}}function pi(){if(we){for(let e of Oe){let t=Kt[e];t&&(console[e]=t);}Oe.clear(),He&&be&&(window.fetch=be,He=false),Ue&&ye&&ve&&(XMLHttpRequest.prototype.open=ye,XMLHttpRequest.prototype.send=ve,Ue=false),he=[],we=false;}}function mi(){return {consoleLogs:[...ne],networkErrors:[...oe]}}function gi(){ne=[],oe=[];}var ko=[{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}/}],K=[],Ve=0,qe=false;function To(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function Co(e,t,n,o){if(K.some(l=>l.rule===e&&l.source===t))return;let i={rule:e,source:t,hint:To(n),timestamp:Date.now()};o&&(i.location=o),K.push(i);}function re(e,t,n,o){for(let{name:r,pattern:i}of n){let l=i.exec(e);l&&Co(r,t,l[0],o);}}function Ro(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);re(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);re(n,"hydration",e,"__NUXT__");}}catch{}}function Ao(e){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&re(r,"scripts",e,`inline-script[${o}]`);});}catch{}}function xo(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let o=n.getAttribute("content"),r=n.getAttribute("name")||n.getAttribute("property")||"";o&&o.length>10&&re(o,"meta",e,r?`meta[${r}]`:void 0);});}catch{}}function Io(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&&re(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function yi(e={}){if(qe||!_()||(qe=true,e.secretScan===false))return;let t=[...ko,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{Ve=Date.now(),n.includes("hydration")&&Ro(t),n.includes("scripts")&&Ao(t),n.includes("meta")&&xo(t),n.includes("dom")&&Io(t);let o=e.notify??"both";K.length>0&&(o==="console"||o==="both")&&console.warn(`[BlocFeed Security] Found ${K.length} potential secret(s) exposed in client code:`,K.map(r=>`${r.rule} (${r.source}${r.location?`: ${r.location}`:""})`));},100);}function vi(){return {findings:[...K],scannedAt:Ve}}function wi(){K=[],Ve=0,qe=false;}
|
|
2
|
+
exports.A=gi;exports.B=yi;exports.C=vi;exports.D=wi;exports.a=_;exports.b=Se;exports.c=tt;exports.d=it;exports.e=st;exports.f=xe;exports.g=at;exports.h=zo;exports.i=Xo;exports.j=yn;exports.k=vn;exports.l=Tn;exports.m=Ie;exports.n=xn;exports.o=Me;exports.p=Ln;exports.q=ar;exports.r=St;exports.s=dr;exports.t=Mt;exports.u=fr;exports.v=pe;exports.w=li;exports.x=fi;exports.y=pi;exports.z=mi;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {record}from'rrweb';function _(){return typeof window<"u"&&typeof document<"u"}function We(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 Se(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Zt(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function Gt(e){return e.replace(/\s+/g," ").trim()}function O(e,t=140){let n=e.textContent;if(!n)return;let o=Gt(n);if(o)return o.length<=t?o:`${o.slice(0,t-1)}\u2026`}function Jt(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var Ze=["data-testid","data-test-id","data-test","data-qa","data-cy"],je="data-blocfeed-component";function V(e){let t=e.closest(`[${je}]`);if(!t)return;let o=t.getAttribute(je)?.trim();return o||void 0}function Y(e,t=5){let n=[],o=e,r=0;for(;o&&r<t*4;){let i=V(o);if(i&&n[n.length-1]!==i&&(n.push(i),n.length>=t))break;o=o.parentElement,r++;}return n}function Qt(e){for(let t of Ze){let n=e.closest(`[${t}]`);if(!n)continue;let r=n.getAttribute(t)?.trim();if(r)return r}}function Ke(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 W(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 Q(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!W(t.name))return t.name}}function F(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 F(r)}}}function ke(e){let t=Ke(e);if(!t)return;let n=Q(t._debugInfo);if(n)return n;let o=t._debugOwner!==void 0;if(o){let a=t._debugOwner;for(let c=0;a&&c<50;c+=1){let u=Q(a._debugInfo);if(u)return u;let d=F(a.type)??F(a.elementType);if(d&&!W(d))return d;a=a._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let a=t._owner;for(let c=0;a&&c<50;c+=1){let u=Q(a._debugInfo);if(u)return u;let d=F(a.type)??F(a.elementType);if(d&&!W(d))return d;a=a._owner;}}let i=t,l=o?80:25;for(let a=0;i&&a<l;a+=1){let c=Q(i._debugInfo);if(c)return c;let u=F(i.type)??F(i.elementType);if(u&&!W(u))return u;i=i.return;}let s=e.parentElement;for(let a=0;s&&a<15;a+=1){let c=Ke(s);if(c){let u=Q(c._debugInfo);if(u)return u;let d=F(c.type)??F(c.elementType);if(d&&!W(d))return d;if(c._debugOwner){let p=F(c._debugOwner.type)??F(c._debugOwner.elementType);if(p&&!W(p))return p}if(c._owner&&c._owner!==c._debugOwner){let p=F(c._owner.type)??F(c._owner.elementType);if(p&&!W(p))return p}}s=s.parentElement;}}function en(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${We(n)}`;for(let o of Ze){let r=e.getAttribute(o);if(r)return `${t}[${o}="${We(r)}"]`}return `${t}:nth-of-type(${Jt(e)})`}function j(e,t=10){let n=[],o=e;for(;o&&n.length<t;){let r=en(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}var tn=new Set(["button","link","tab","menuitem"]);function Ge(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&&tn.has(t))return "role";try{if(window.getComputedStyle(e).cursor==="pointer")return "cursor_pointer"}catch{}return null}function Ye(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function Te(e,t){if(!e||Ye(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(Ye(n,t.ignoreSelectors))return null;if(t.isSelectable?t.isSelectable(n):nn(n))return n;n=n.parentElement;}return null}function ie(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 nn(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function Je(e){let t=e.getBoundingClientRect(),n={selector:j(e),tagName:e.tagName.toLowerCase(),rect:Se(t),pageRect:Zt(t)},o=e.getAttribute("id");o&&(n.id=o);let r=e.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=O(e);i&&(n.textSnippet=i);let l=V(e)??ke(e);l&&(n.componentName=l);let s=Qt(e);return s&&(n.testId=s),n}var Ce=null;async function Qe(){return Ce||(Ce=import('html-to-image')),Ce}async function on(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 et(e,t){let{width:n,height:o}=await on(e);return {dataUrl:e,mime:t,width:n,height:o}}function Z(e){if(e?.aborted)throw new Error("Aborted")}function tt(){return {async captureElement(e,t){if(!_())throw new Error("captureElement can only run in the browser");Z(t.signal);let n=await Qe();Z(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 Z(t.signal),await et(o,t.mime)},async captureFullPage(e){if(!_())throw new Error("captureFullPage can only run in the browser");Z(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)),l=Math.max(1,Math.round(o*r)),s=await Qe();Z(e.signal);let a=e.mime==="image/jpeg"?await s.toJpeg(t,{width:i,height:l,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await s.toPng(t,{width:i,height:l,pixelRatio:e.pixelRatio});return Z(e.signal),await et(a,e.mime)}}}function rn(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function w(e,t,n){let o={kind:e,message:rn(t)};return n&&(o.detail=n),o}var sn=12e3,an=2048,cn=.92;function nt(){return Date.now()}function ln(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 ot(e,t,n){let o=new Promise((i,l)=>{let s=setTimeout(()=>l(new Error("Timeout")),t);typeof s.unref=="function"&&s.unref();}),r=[e,o];return n&&r.push(ln(n)),await Promise.race(r)}function un(e){if(!_())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function dn(e){return !!(e?.element||e?.fullPage)}function rt(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 it(e){let{selectionElement:t,capture:n,signal:o}=e;if(!_()||!dn(n))return;let r=nt(),i=[],l=n?.timeoutMs??sn,s=n?.maxDimension??an,a=n?.mime??"image/png",c=n?.quality??cn,u=n?.adapter??tt(),d={},p=un(n);if(n?.element&&t)try{let m=t.getBoundingClientRect(),h=Math.min(1,s/Math.max(m.width,m.height)),E=Math.min(p,p*h),b=await ot(Promise.resolve(u.captureElement(t,{...rt({mime:a,quality:c,pixelRatio:E,maxDimension:s,includeQuality:a==="image/jpeg",...o?{signal:o}:{}})})),l,o);d.element=b;}catch(m){if(o?.aborted)throw m;i.push(w("capture_failed",m,{target:"element"}));}if(n?.fullPage)try{let m=await ot(Promise.resolve(u.captureFullPage(rt({mime:a,quality:c,pixelRatio:p,maxDimension:s,includeQuality:a==="image/jpeg",...o?{signal:o}:{}}))),l,o);d.fullPage=m;}catch(m){if(o?.aborted)throw m;i.push(w("capture_failed",m,{target:"fullPage"}));}let g=nt(),f={startedAt:r,finishedAt:g,durationMs:Math.max(0,g-r)};return i.length>0&&(f.errors=i),{...d,diagnostics:f}}function fn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function pn(){return _()?{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:fn()}:{}}function mn(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 st(e){let{config:t,context:n,user:o}=e;if(t?.enabled===false)return {};let r={...pn(),...mn(o)},i=t?.enrich;if(!i)return r;try{let l=await i(n);return {...r,...l}}catch(l){let s=w("unknown",l);return {...r,blocfeedMetadataError:s.message}}}var ee="blocfeed-queue",gn=50;function Re(){if(!_())return [];try{let e=localStorage.getItem(ee);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(ee);}catch{}return []}catch(e){console.warn("[BlocFeed] offline queue could not be read \u2014 resetting",e);try{localStorage.removeItem(ee);}catch{}return []}}function Ae(e){if(_())try{e.length===0?localStorage.removeItem(ee):localStorage.setItem(ee,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 hn(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 xe(e){let t=Re(),n=hn(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>gn;)t.shift();Ae(t);}function at(){let e=Re();return e.length===0?[]:(Ae([]),e.map(t=>t.payload))}function zo(){Ae([]);}function Xo(){return Re().length}var bn=200,te=[],ct=0,se=false;function lt(e){let t=e.target;if(!(t instanceof Element)||t.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-ct,path:window.location.pathname,tagName:t.tagName.toLowerCase()},o=O(t,100);o&&(n.textSnippet=o);let r=V(t)??ke(t);r&&(n.componentName=r),te.length<bn&&te.push(n);}var ut={capture:true,passive:true};function dt(){se||!_()||(se=true,te=[],ct=Date.now(),document.addEventListener("click",lt,ut));}function ft(){se&&(se=false,document.removeEventListener("click",lt,ut));}function yn(){return [...te]}function vn(){te=[];}var wn=3e4,En=25e5,pt="video/webm",_n=250,Sn=1e3,kn=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function mt(){if(typeof MediaRecorder>"u")return null;for(let e of kn)if(MediaRecorder.isTypeSupported(e))return e;return null}function Tn(){return !_()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:mt()!==null}async function Ie(e){let{config:t,signal:n}=e;if(!_()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw w("recording_failed",new Error("Screen recording is not supported in this browser"));let o=mt();if(!o)throw w("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw w("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(h){let E=h instanceof DOMException&&h.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw w("recording_failed",new Error(E))}if(n?.aborted)throw r.getTracks().forEach(h=>h.stop()),w("aborted",new Error("Recording aborted after permission"));let i=t?.maxDurationMs??wn,l=t?.videoBitsPerSecond??En,s=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:l}),a=[],c=[],u=0,d=null,p=null,g=false,f=()=>{ft(),d!==null&&(clearInterval(d),d=null),p!==null&&(clearTimeout(p),p=null),r.getTracks().forEach(h=>h.stop());},m=new Promise((h,E)=>{s.ondataavailable=k=>{k.data.size>0&&a.push(k.data);},s.onstop=()=>{if(g)return;g=true,f();let k=Date.now()-u,T=new Blob(a,{type:pt}),y=URL.createObjectURL(T);h({mime:pt,blobUrl:y,blob:T,durationMs:k,sizeBytes:T.size});},s.onerror=()=>{g||(g=true,f(),E(w("recording_failed",new Error("MediaRecorder error"))));};let b=r.getVideoTracks()[0];if(b&&b.addEventListener("ended",()=>{s.state!=="inactive"&&s.stop();}),n){let k=()=>{g||(g=true,s.state!=="inactive"&&s.stop(),f(),E(w("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",k,{once:true});}});return s.start(Sn),dt(),u=Date.now(),d=setInterval(()=>{let h=Date.now()-u;for(let E of c)E(h);},_n),p=setTimeout(()=>{!g&&s.state!=="inactive"&&s.stop();},i),{result:m,stop(){!g&&s.state!=="inactive"&&s.stop();},onTick(h){c.push(h);},abort(){g||(g=true,s.state!=="inactive"&&s.stop(),f());}}}var Cn=6e4,gt="audio/webm",Rn=250,An=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function ht(){if(typeof MediaRecorder>"u")return null;for(let e of An)if(MediaRecorder.isTypeSupported(e))return e;return null}function xn(){return !_()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:ht()!==null}async function Me(e){let{config:t,signal:n}=e;if(!_()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw w("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=ht();if(!o)throw w("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw w("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(m){let h=m instanceof DOMException&&m.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw w("recording_failed",new Error(h))}if(n?.aborted)throw r.getTracks().forEach(m=>m.stop()),w("aborted",new Error("Voice recording aborted after permission"));let i=t?.maxDurationMs??Cn,l=new MediaRecorder(r,{mimeType:o}),s=[],a=[],c=0,u=null,d=null,p=false,g=()=>{u!==null&&(clearInterval(u),u=null),d!==null&&(clearTimeout(d),d=null),r.getTracks().forEach(m=>m.stop());},f=new Promise((m,h)=>{if(l.ondataavailable=E=>{E.data.size>0&&s.push(E.data);},l.onstop=()=>{if(p)return;p=true,g();let E=Date.now()-c,b=new Blob(s,{type:gt});m({blob:b,mime:gt,durationMs:E});},l.onerror=()=>{p||(p=true,g(),h(w("recording_failed",new Error("MediaRecorder error"))));},n){let E=()=>{p||(p=true,l.state!=="inactive"&&l.stop(),g(),h(w("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",E,{once:true});}});return l.start(1e3),c=Date.now(),u=setInterval(()=>{let m=Date.now()-c;for(let h of a)h(m);},Rn),d=setTimeout(()=>{d=null,!p&&l.state!=="inactive"&&l.stop();},i),{result:f,stop(){!p&&l.state!=="inactive"&&l.stop();},onTick(m){a.push(m);},abort(){p||(p=true,l.state!=="inactive"&&l.stop(),g());}}}var In=12e3,Mn=2,Fn=500,Pn=2e3,Fe="https://blocfeed.com/api/feedback",Bn="https://blocfeed.com/api/feedback/voice",bt=0,wt="blocfeed-viewer-token",Et="blocfeed-my-feedback-url";function Ln(){try{return localStorage.getItem(wt)}catch{return null}}function ar(){try{return localStorage.getItem(Et)}catch{return null}}function Dn(e,t){try{localStorage.setItem(wt,e),t&&localStorage.setItem(Et,t);}catch{}}function yt(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 Nn(e){return e>=500&&e<=599}function On(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),l=new Uint8Array(i.length);for(let s=0;s<i.length;s+=1)l[s]=i.charCodeAt(s);return new Blob([l],{type:r})}function Hn(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 vt(e,t,n){let o=On(t);await fetch(e,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function Un(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(`${Fe}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function qn(e){await fetch(`${Fe}/${e.feedbackId}/video`,{method:"POST",body:e.blob,headers:{"content-type":e.blob.type},...e.signal?{signal:e.signal}:{}});}async function _t(e){let{signal:t,transport:n}=e;if(Date.now()-bt<Pn)return {ok:false,error:w("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??In,i=n?.maxAttempts??Mn,l=n?.backoffMs??Fn,s=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),a=!!e.payload.video?.blob,c=s||a,{lean:u,extracted:d,extractedVideo:p}=c?Hn(e.payload):{lean:e.payload,extracted:{},extractedVideo:{}},g=Ln();g&&(u.viewer_token=g);let f={...d,...e.screenshotDataUrls};for(let m=1;m<=i;m+=1){let h=new AbortController,E=setTimeout(()=>h.abort(),r),b=()=>h.abort();t&&t.addEventListener("abort",b,{once:true});try{let k=await fetch(Fe,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(u),signal:h.signal});if(k.ok){bt=Date.now();let y;try{y=await k.json();}catch{}if(y?.viewer_token&&Dn(y.viewer_token,y.my_feedback_url),(f.element||f.fullPage)&&y){let P=y.upload_urls;if(P){let z=[];f.element&&P.element&&z.push(vt(P.element,f.element,t)),f.fullPage&&P.fullPage&&z.push(vt(P.fullPage,f.fullPage,t));try{await Promise.all(z);}catch{}}else if(y.feedback_id)try{await Un({feedbackId:y.feedback_id,extracted:f,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}if(p.blob&&y){let P=y.upload_urls;if(P?.video)try{await fetch(P.video,{method:"PUT",body:p.blob,headers:{"content-type":p.blob.type},...t?{signal:t}:{}});}catch{}else if(y.feedback_id)try{await qn({feedbackId:y.feedback_id,blob:p.blob,...t?{signal:t}:{}});}catch{}}let D={ok:!0,status:k.status};return y&&(D.apiResponse=y),D}if(m<i&&Nn(k.status)){let y=.85+Math.random()*.3,H=Math.round(l*2**(m-1)*y);await yt(H,t);continue}let T=`HTTP ${k.status}`;try{let y=await k.json();y?.error&&(T=y.error);}catch{}return {ok:!1,status:k.status,error:w("api_failed",new Error(T))}}catch(k){if(h.signal.aborted||t?.aborted)return {ok:false,error:w("aborted",k)};if(m<i){let T=.85+Math.random()*.3,y=Math.round(l*2**(m-1)*T);await yt(y,t);continue}return {ok:false,error:w("api_failed",k)}}finally{clearTimeout(E),t&&t.removeEventListener("abort",b);}}return {ok:false,error:w("api_failed",new Error("Failed"))}}async function St(e){let{blob:t,mime:n,blocfeedId:o,signal:r}=e,i=await fetch(Bn,{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 w("api_failed",new Error(s?.error??`Voice API returned ${i.status}`))}let l=await i.json();return {text:l.text??"",warning:l.warning}}var kt="bf_behavioral_session",ae=null;function M(){try{let e=sessionStorage.getItem(kt);if(e)return e;let t=Tt();return sessionStorage.setItem(kt,t),t}catch{return ae||(ae=Tt(),ae)}}function Tt(){let e=Math.random().toString(36).slice(2,10).padEnd(8,"0");return `bf_${Date.now()}_${e}`}var Vn="https://blocfeed.com/api/events/track",zn=5e3,Xn=50,$n=1024,ue="blocfeed-events-queue",Ct=500,Rt=100,Wn=/^[a-z][a-z0-9_]{0,127}$/,At=50,xt=1024,It;function dr(e){It=e;}function jn(e){if(typeof e!="string"||!Wn.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 Kn(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>At)throw new Error(`[BlocFeed] track(): properties has ${t.length} keys, max ${At}.`);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>xt)throw new Error(`[BlocFeed] track(): properties serialized to ${n.length} bytes, max ${xt}. Server allows 8192 bytes \u2014 the client cap is defensive; trim down or split the event.`);return e}function Pe(){if(typeof localStorage>"u")return [];try{let e=localStorage.getItem(ue);if(!e)return [];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{try{localStorage.removeItem(ue);}catch{}return []}}function Be(e){if(!(typeof localStorage>"u"))try{if(e.length===0)localStorage.removeItem(ue);else {let t=e.length>Ct?e.slice(e.length-Ct):e;localStorage.setItem(ue,JSON.stringify(t));}}catch{}}var B=null;function Yn(){if(B)return B;if(typeof window>"u")return null;let e=Zn();return e?(B={blocfeedId:e,endpoint:Vn,events:[],bytes:0,flushTimer:null,pageHideHandler:null,visibilityHandler:null},B.flushTimer=setInterval(()=>{le(false);},zn),B.pageHideHandler=()=>{le(true);},B.visibilityHandler=()=>{document.visibilityState==="hidden"&&le(true);},window.addEventListener("pagehide",B.pageHideHandler),document.addEventListener("visibilitychange",B.visibilityHandler),B):null}function Zn(){try{let t=window.__blocfeed_id__;return typeof t=="string"&&t.length>0?t:null}catch{return null}}function Mt(e){try{window.__blocfeed_id__=e;}catch{}B&&(B.blocfeedId=e);}function fr(e,t,n){jn(e);let o=Kn(t),r=n?.occurredAt?to(n.occurredAt):new Date().toISOString(),i={event_name:e,properties:o,occurred_at:r},l=n?.sessionId??Jn();l&&(i.session_id=l);let s=n?.userId??It;s&&(i.user_id=s);let a=n?.pageUrl??Qn();a&&(i.page_url=a);let c=eo();c&&(i.user_agent=c);let u=Yn();if(!u){let d=Pe();d.push(i),Be(d);return}u.events.push(i),u.bytes+=Gn(i),(u.events.length>=Xn||u.bytes>=$n)&&le(false);}async function le(e){let t=B;if(!t)return;let o=Pe().concat(t.events);if(t.events=[],t.bytes=0,Be([]),o.length!==0)for(let r=0;r<o.length;r+=Rt){let i=o.slice(r,r+Rt),l=JSON.stringify({blocfeed_id:t.blocfeedId,events:i});if(e&&no())try{let s=new Blob([l],{type:"application/json"});navigator.sendBeacon(t.endpoint,s)||ce(i);continue}catch{ce(i);continue}try{(await fetch(t.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:l})).ok||ce(i);}catch{ce(i);}}}function ce(e){let t=Pe();Be(t.concat(e));}function Gn(e){try{return JSON.stringify(e).length}catch{return 256}}function Jn(){try{return M()}catch{return}}function Qn(){try{return typeof window<"u"?window.location.href:void 0}catch{return}}function eo(){try{return typeof navigator<"u"?navigator.userAgent:void 0}catch{return}}function to(e){return e instanceof Date?e.toISOString():new Date(e).toISOString()}function no(){return typeof navigator<"u"&&typeof navigator.sendBeacon=="function"}var oo={enabled:true,sampling:1,ignoreSelectors:["[data-blocfeed-ui]","[data-blocfeed-ignore]"],rageClick:{enabled:true,threshold:3,windowMs:1e3},httpFail:{enabled:true,statusCodes:[400,401,403,422,500,502,503,504],ignoreUrls:["/api/behavioral-events","/api/feedback"]},redirectLoop:{enabled:true,threshold:3,windowMs:2e3},formDataLoss:{enabled:true},deadClick:{enabled:true,observationWindowMs:300,rateLimitPerSelector:5}};function Ft(e){let t=oo;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 Pt(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"}),l=`${e.endpoint}?_bfid=${encodeURIComponent(e.blocfeedId)}`;try{navigator.sendBeacon(l,i);}catch{}}return {enqueue(r){t.push(r);},flush:n,flushBeacon:o,size(){return t.length}}}function Bt(e,t){if(!e.rageClick.enabled)return ()=>{};let{threshold:n,windowMs:o}=e.rageClick,r=new Map;function i(l){try{let s=l.target;if(!s||!(s instanceof Element)||ie(s,e.ignoreSelectors))return;let a=j(s,4);if(!a)return;let c=Date.now(),d=(r.get(a)??[]).filter(p=>c-p<=o);if(d.push(c),r.set(a,d),d.length>=n){let p=ro(s),g=O(s,200)??null,f=s.tagName.toLowerCase(),m=s.id||null,h=V(s)??null,E=Y(s,5),b={session_id:M(),event_type:"rage_click",page_url:typeof window>"u"?"":window.location.href,selector:a,element_text:g,event_data:{click_count:d.length,window_ms:o,...p?{disabled:!0}:{},tag_name:f,...m?{element_id:m}:{},...h?{component_name:h}:{},...E.length>0?{parent_components:E}:{}},created_at:new Date().toISOString()};t(b),r.set(a,[]);}}catch{}}return document.addEventListener("click",i,{capture:true,passive:true}),()=>document.removeEventListener("click",i,{capture:true})}function ro(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 Dt=0,Nt=null,de=null,fe=[],io=1500;function so(){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;Dt=Date.now();let r=o.closest("form");Nt=(r?j(r,3):"")||null,de=O(o,100)??null,fe=Y(o,5);}catch{}}return document.addEventListener("click",e,{capture:true,passive:true}),()=>document.removeEventListener("click",e,{capture:true})}function Ot(e,t){if(!e.httpFail.enabled)return ()=>{};let{statusCodes:n,ignoreUrls:o}=e.httpFail,r=new Set(n),i=so(),l=globalThis.fetch,s=async(d,p)=>{let g=typeof d=="string"?d:d instanceof URL?d.toString():d.url,f=(p?.method??d.method??"GET").toUpperCase(),m=await l.call(globalThis,d,p);try{!Lt(g,o)&&r.has(m.status)&&t(u(m.status,g,f));}catch{}return m};globalThis.fetch=s;let a=XMLHttpRequest.prototype.open,c=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(d,p,...g){return this.__bf_url=p,this.__bf_method=d.toUpperCase(),a.call(this,d,p,...g)},XMLHttpRequest.prototype.send=function(d){let p=()=>{try{let g=this.__bf_url??"",f=this.__bf_method??"GET";!Lt(g,o)&&r.has(this.status)&&t(u(this.status,g,f));}catch{}};return this.__bf_handler=p,this.addEventListener("loadend",p),c.call(this,d??null)},()=>{globalThis.fetch=l,XMLHttpRequest.prototype.open=a,XMLHttpRequest.prototype.send=c,i(),de=null,fe=[];};function u(d,p,g){let m=Date.now()-Dt<io;return {session_id:M(),event_type:"error",page_url:typeof window>"u"?"":window.location.href,selector:null,element_text:null,event_data:{http_status:d,request_url:p,method:g,form_selector:m?Nt:null,...m&&de?{button_text:de}:{},...m&&fe.length>0?{parent_components:fe}:{}},created_at:new Date().toISOString()}}}function Lt(e,t){if(t.length===0)return false;for(let n of t)if(e.includes(n))return true;return false}var ao=3e4;function Ht(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,l=history.pushState,s=history.replaceState;function a(u){try{let d=Date.now(),p=i.get(u)??0;if(d<p)return;let f=(r.get(u)??[]).filter(m=>d-m<=o);if(f.push(d),r.set(u,f),f.length>=n){let m={session_id:M(),event_type:"thrashing",page_url:window.location.href,selector:null,element_text:null,event_data:{count:f.length,url:u,window_ms:o},created_at:new Date().toISOString()};t(m),i.set(u,d+ao),r.set(u,[]);}}catch{}}function c(){let u=window.location.pathname+window.location.search;a(u);}return history.pushState=function(...u){let d=l.apply(this,u);return c(),d},history.replaceState=function(...u){let d=s.apply(this,u);return c(),d},window.addEventListener("popstate",c),()=>{history.pushState=l,history.replaceState=s,window.removeEventListener("popstate",c);}}function Ut(e,t){if(!e.formDataLoss.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let n=new Set,o=0;function r(c){let u=c.closest("form");return u?u.id?`#${u.id}`:"form":null}function i(c){try{let u=c.target;if(!u||!(u instanceof HTMLInputElement||u instanceof HTMLTextAreaElement||u instanceof HTMLSelectElement))return;let d=r(u);if(!d)return;n.has(d)||n.add(d),o++;}catch{}}function l(c){if(n.size===0)return;let u=Array.from(n),d={session_id:M(),event_type:"form_abandonment",page_url:window.location.href,selector:u[0]??null,element_text:null,event_data:{cause:c,field_count:o,forms:u},created_at:new Date().toISOString()};t(d);}function s(c){c.persisted&&l("bfcache_restore");}function a(){l("beforeunload_after_edit");}return document.addEventListener("input",i,{capture:true,passive:true}),window.addEventListener("pageshow",s),window.addEventListener("beforeunload",a),()=>{document.removeEventListener("input",i,{capture:true}),window.removeEventListener("pageshow",s),window.removeEventListener("beforeunload",a);}}function co(){let e={domMutationCount:0,urlChangeCount:0,networkCount:0,filePickerCount:0,uninstall:()=>{}},t=new MutationObserver(()=>{e.domMutationCount+=1;});t.observe(document.body,{childList:true,attributes:true,characterData:true,subtree:true});let n=history.pushState,o=history.replaceState;history.pushState=function(...a){return e.urlChangeCount+=1,n.apply(this,a)},history.replaceState=function(...a){return e.urlChangeCount+=1,o.apply(this,a)};let r=()=>{e.urlChangeCount+=1;};window.addEventListener("popstate",r);let i=globalThis.fetch;if(i){let a=(c,u)=>(e.networkCount+=1,i.call(globalThis,c,u));globalThis.fetch=a;}let l=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(a,c,...u){return e.networkCount+=1,l.call(this,a,c,...u)};let s=HTMLInputElement.prototype.click;return HTMLInputElement.prototype.click=function(){return this.type==="file"&&(e.filePickerCount+=1),s.call(this)},e.uninstall=()=>{t.disconnect(),history.pushState=n,history.replaceState=o,window.removeEventListener("popstate",r),i&&(globalThis.fetch=i),XMLHttpRequest.prototype.open=l,HTMLInputElement.prototype.click=s;},e}function qt(e,t){if(!e.deadClick.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let{observationWindowMs:n,rateLimitPerSelector:o}=e.deadClick,r=new Map,i=co();function l(s){try{let a=s.target;if(!a||!(a instanceof Element)||s.button!==0||s.metaKey||s.ctrlKey||s.altKey||s.shiftKey||ie(a,e.ignoreSelectors)||a.closest("label"))return;if(a instanceof HTMLInputElement){let y=a.type;if(y==="checkbox"||y==="radio"||y==="file")return}if(a instanceof HTMLSelectElement||a.closest("a[target='_blank'], a[download]")||a.closest('[contenteditable="true"]'))return;try{let y=window.getSelection();if(y&&y.toString().length>0)return}catch{}let c=Ge(a);if(!c)return;let u=j(a,4);if(!u)return;let d=i.domMutationCount,p=i.urlChangeCount,g=i.networkCount,f=i.filePickerCount,m=new Date().toISOString(),h=O(a,200)??null,E=a.tagName.toLowerCase(),b=a.id||null,k=V(a)??null,T=Y(a,5);setTimeout(()=>{if(i.domMutationCount!==d||i.urlChangeCount!==p||i.networkCount!==g||i.filePickerCount!==f)return;let y=r.get(u)??0;if(y>=o)return;r.set(u,y+1);let H={session_id:M(),event_type:"dead_click",page_url:typeof window>"u"?"":window.location.href,selector:u,element_text:h,event_data:{tag_name:E,...b?{element_id:b}:{},...k?{component_name:k}:{},...T.length>0?{parent_components:T}:{},clickable_reason:c},created_at:m};t(H);},n);}catch{}}return document.addEventListener("click",l,{capture:true,passive:true}),()=>{document.removeEventListener("click",l,{capture:true}),i.uninstall();}}var uo="https://blocfeed.com/api/replay-events";function Vt(e){if(!e.config.enabled)return ()=>{};if(typeof window>"u")return ()=>{};if(typeof globalThis.matchMedia>"u")return ()=>{};let t=M();if(po(t)%100/100>=e.config.sampling)return ()=>{};let o=Date.now(),r=e.config.endpoint??uo,i=[],l=0,s=false,a=null,c=`bf_replay_chunkseq_${t}`,u=0;try{let T=sessionStorage.getItem(c);T&&(u=parseInt(T,10)||0);}catch{}let d=(T=false)=>{if(i.length===0)return;let y=T?mo(i):i;i=[],l=0;let H=u++;try{sessionStorage.setItem(c,String(u));}catch{}go({blocfeedId:e.blocfeedId,sessionId:t,sessionStartedAtMs:o,chunkSeq:H,events:y,endpoint:r,useBeacon:T});},p=setInterval(()=>{s||d();},e.config.flushIntervalMs),g=setTimeout(()=>{d(),k();},e.config.maxDurationMs),f=null,m=()=>{f&&clearTimeout(f),f=setTimeout(()=>{d(),k();},e.config.inactivityTimeoutMs);};m();let h=()=>{d(true);};window.addEventListener("pagehide",h);let E=e.config.masking,b={emit(T){s||(i.push(T),l+=fo(T),m(),l>=e.config.flushSizeBytes&&d());},recordCanvas:false,sampling:{mousemove:50}};E.maskAllInputs!==void 0&&(b.maskAllInputs=E.maskAllInputs),E.maskTextSelector!==void 0&&(b.maskTextSelector=E.maskTextSelector),E.maskTextClass!==void 0&&(b.maskTextClass=E.maskTextClass),E.blockSelector!==void 0&&(b.blockSelector=E.blockSelector),a=record(b)??null;function k(){if(!s&&(s=true,clearInterval(p),clearTimeout(g),f&&clearTimeout(f),window.removeEventListener("pagehide",h),a))try{a();}catch{}}return k}function fo(e){try{return JSON.stringify(e).length}catch{return 1024}}function po(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return Math.abs(t)}function mo(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 go(e){let t=JSON.stringify({blocfeed_id:e.blocfeedId,session_id:e.sessionId,session_started_at_ms:e.sessionStartedAtMs,chunk_seq:e.chunkSeq,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 ho={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 zt(e){let t=ho;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 bo=5e3,pe=class{constructor(t){this.submitter=null;this.detectorUninstallers=[];this.flushTimer=null;this.pageHideHandler=null;this.installed=false;this.opts=t,this.resolved=Ft(t.config);}install(){if(this.installed||!this.resolved.enabled||!(this.opts.passiveSampler??(()=>Math.random()<this.resolved.sampling))())return;Mt(this.opts.blocfeedId);let n=this.opts.endpoint??"https://blocfeed.com/api/behavioral-events";this.submitter=this.opts.submitter??Pt({endpoint:n,blocfeedId:this.opts.blocfeedId});let o=i=>{this.submitter?.enqueue(i);};this.detectorUninstallers.push(Bt(this.resolved,o)),this.detectorUninstallers.push(Ot(this.resolved,o)),this.detectorUninstallers.push(Ht(this.resolved,o)),this.detectorUninstallers.push(Ut(this.resolved,o)),this.detectorUninstallers.push(qt(this.resolved,o));let r=zt(this.opts.config?.sessionReplay);this.detectorUninstallers.push(Vt({blocfeedId:this.opts.blocfeedId,config:r})),this.flushTimer=setInterval(()=>{this.submitter?.flush();},bo),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;}}};function Le(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 me(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function ge(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function Xt(e,t){if(!_())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,l=null,s=(f,m=false)=>{if(!f){i=null,l=null,t.onHover(null);return}let h=Se(f.getBoundingClientRect()),E=`${Math.round(h.x)}:${Math.round(h.y)}:${Math.round(h.width)}:${Math.round(h.height)}`;!m&&f===i&&E===l||(i=f,l=E,t.onHover({element:f,rect:h}));},a=Le(f=>{if(me(f.target))return;let m=document.elementFromPoint(f.clientX,f.clientY),h=Te(m,r);s(h);}),c=Le(()=>{i&&s(i,true);}),u=f=>{me(f.target)||(ge(f),f.pointerType==="mouse"&&f.preventDefault());},d=f=>{me(f.target)||(ge(f),f.pointerType==="mouse"&&f.preventDefault());},p=f=>{if(me(f.target))return;ge(f),f.preventDefault();let m=document.elementFromPoint(f.clientX,f.clientY),h=Te(m,r);h&&t.onSelect({element:h,descriptor:Je(h)});},g=f=>{f.key==="Escape"&&(ge(f),f.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",a,{capture:true,passive:true}),window.addEventListener("pointerdown",u,{capture:true}),window.addEventListener("pointerup",d,{capture:true}),window.addEventListener("click",p,{capture:true}),window.addEventListener("keydown",g,{capture:true}),window.addEventListener("scroll",c,{capture:true,passive:true}),window.addEventListener("resize",c,{passive:true}),{stop(){window.removeEventListener("pointermove",a,{capture:true}),window.removeEventListener("pointerdown",u,{capture:true}),window.removeEventListener("pointerup",d,{capture:true}),window.removeEventListener("click",p,{capture:true}),window.removeEventListener("keydown",g,{capture:true}),window.removeEventListener("scroll",c,{capture:true}),window.removeEventListener("resize",c),a.cancel(),c.cancel(),t.onHover(null);}}}async function De(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 _t(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:w("api_failed",r)},o.ok=false;}return {payload:e.payload,result:o}}var yo=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function vo(e){let t=[...yo,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function $t(){return {phase:"idle"}}function wo(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 li(e){let t=e,n=new pe({blocfeedId:t.blocfeed_id??"",...t.behavioral!==void 0?{config:t.behavioral}:{}});n.install();let o=$t(),r=new Set,i=new Set,l=null,s=null,a=null,c=null,u=0,d=null,p=null,g=null,f=null,m=false,h=()=>{for(let v of r)v(o);},E=v=>{for(let S of i)S(v);},b=v=>{o=v,h();},k=()=>{u+=1,c?.abort(),c=null;},T=()=>{l?.stop(),l=null,E(null),a!==null&&_()&&(document.documentElement.style.cursor=a,a=null);},y=()=>{if(g){try{URL.revokeObjectURL(g.blobUrl);}catch{}g=null;}},H=()=>{p&&(p.abort(),p=null),y();},D=null,P=()=>{f&&(f.abort(),f=null),D&&(D.abort(),D=null);},z=()=>{k(),T(),H(),P(),s=null,b($t());},ze=()=>{if(!_())return;T(),s=null;let v=vo(t.picker);a=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",b({phase:"picking"}),l=Xt(v,{onHover:E,onSelect:({element:S,descriptor:I})=>{s=S,T(),b({phase:"review",selection:I});},onCancel:()=>{z();}});},Xe=()=>{let v=at();if(v.length!==0)for(let S of v)De({payload:S,...t.transport?{transport:t.transport}:{}}).catch(()=>{xe(S);});};if(_()){setTimeout(Xe,1e3);let v=()=>Xe();window.addEventListener("online",v),d=()=>window.removeEventListener("online",v);}return {getState:()=>o,getConfig:()=>t,subscribe(v){return r.add(v),()=>r.delete(v)},subscribeHover(v){return i.add(v),()=>i.delete(v)},start(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||o.phase!=="picking"&&ze();},stop(){z();},clearSelection(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||ze();},setConfig(v){t=v;},async submit(v,S){if(!_()){let R=w("configuration",new Error("BlocFeed submit can only run in the browser"));return b({phase:"error",lastError:R}),{ok:false}}let I=t.blocfeed_id?.trim?.()??"";if(!I){let L={phase:"error",lastError:w("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return o.selection&&(L.selection=o.selection),b(L),{ok:false}}if(m)return {ok:false};if(o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording")return {ok:false};m=true;let x=u+1;u=x,c?.abort(),c=new AbortController;let A=c.signal,C=o.selection,N=S?.capture?{...t.capture,...S.capture}:t.capture,X=!!(N?.element||N?.fullPage),G={phase:X?"capturing":"submitting"};C&&(G.selection=C),b(G);try{let R=X?await it({selectionElement:s,capture:N,signal:A}):void 0;if(A.aborted||u!==x)return {ok:!1};let L={phase:"submitting"};C&&(L.selection=C),R&&(L.capture=R),b(L);let U={};C&&(U.selection=C),R&&(U.capture=R);let J=await st({config:t.metadata,context:U,...t.user?{user:t.user}:{}}),$={version:1,createdAt:new Date().toISOString(),blocfeed_id:I,message:v,metadata:J};S?.category&&($.category=S.category),t.user&&($.user=t.user),C&&($.selection=C),R&&($.screenshots=R),g&&($.video=g);let{result:q}=await De({payload:$,signal:A,...t.transport?{transport:t.transport}:{}});if(A.aborted||u!==x)return q;if(q.ok){y(),s=null;let _e={phase:"success",lastSubmit:q};return C&&(_e.selection=C),R&&(_e.capture=R),b(_e),q}wo(q)&&xe($);let Yt=q.api?.error??w("unknown",new Error("Submission failed")),Ee={phase:"error",lastSubmit:q,lastError:Yt};return C&&(Ee.selection=C),R&&(Ee.capture=R),b(Ee),q}catch(R){if(A.aborted||u!==x)return {ok:false};let U={phase:"error",lastError:A.aborted?w("aborted",R):w("unknown",R)};return C&&(U.selection=C),b(U),{ok:false}}finally{m=false,u===x&&(c=null);}},async startRecording(){if(o.phase!=="review"||!t.recording?.enabled||f||p)return;let v=o.selection,S={phase:"recording",recordingElapsedMs:0};v&&(S.selection=v),b(S);try{let I={config:t.recording};c&&(I.signal=c.signal);let x=await Ie(I);p=x,x.onTick(N=>{if(o.phase==="recording"){let X={phase:"recording",recordingElapsedMs:N};v&&(X.selection=v),b(X);}});let A=await x.result;p=null,g=A;let C={phase:"review",video:A};v&&(C.selection=v),b(C);}catch(I){p=null;let A={phase:"review",lastError:I?.kind?I:w("recording_failed",I)};v&&(A.selection=v),b(A);}},stopRecording(){o.phase!=="recording"||!p||p.stop();},removeVideo(){y();let v=o.selection,S={phase:"review"};v&&(S.selection=v),b(S);},async startVoice(){if(o.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",o.phase,'(expected "review")');return}let v=t.voice;if(!v?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}if(p){console.warn("[BlocFeed] startVoice: ignored \u2014 a screen recording is already in progress");return}P();let S=o.selection,I={phase:"review",voiceRecording:true,voiceElapsedMs:0};S&&(I.selection=S),g&&(I.video=g),b(I);try{let x={config:v};c&&(x.signal=c.signal);let A=await Me(x);f=A,A.onTick(U=>{let J={phase:"review",voiceRecording:!0,voiceElapsedMs:U};S&&(J.selection=S),g&&(J.video=g),b(J);});let C=await A.result;f=null;let N={phase:"review",voiceRecording:!1,voiceTranscribing:!0};S&&(N.selection=S),g&&(N.video=g),b(N),D=new AbortController;let X={blob:C.blob,mime:C.mime,blocfeedId:t.blocfeed_id,signal:D.signal},{text:$e,warning:G}=await St(X);D=null;let R={phase:"review",voiceRecording:!1,voiceTranscribing:!1};S&&(R.selection=S),g&&(R.video=g),b(R);let L={text:$e};return G&&(L.warning=G),L}catch(x){P();let A=x?.kind?x:w("recording_failed",x);console.warn("[BlocFeed] Voice error:",A.message);let C={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:A};S&&(C.selection=S),g&&(C.video=g),b(C);return}},stopVoice(){f&&f.stop();},__unsafeGetSelectedElement(){return s},destroy(){n.uninstall(),z(),r.clear(),i.clear(),d?.(),d=null;}}}var ne=[],oe=[],Wt=20,jt=15,he=[],Kt=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)}:{},be=typeof globalThis<"u"&&typeof globalThis.fetch=="function"?globalThis.fetch:void 0,ye=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.open:void 0,ve=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.send:void 0,Oe=new Set,He=false,Ue=false,we=false,Eo=["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 _o(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 So(e,t){let n=t.map(_o).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)),ne.push(r);ne.length>Wt;)ne.shift();}function Ne(e){let t=e.url.toLowerCase();for(let n of he)if(t.includes(n))return;for(oe.push(e);oe.length>jt;)oe.shift();}function fi(e={}){if(we||!_())return;we=true,Wt=e.consoleLimit??20,jt=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?he=t.map(n=>n.toLowerCase()):he=[...Eo],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let o of n){let r=Kt[o];r&&(Oe.add(o),console[o]=(...i)=>{So(o,i),r.apply(console,i);});}}if(e.network!==false&&be){let n=be;He=true,window.fetch=async function(r,i){let l=typeof r=="string"?r:r instanceof URL?r.toString():r.url,s=(i?.method??"GET").toUpperCase(),a=Date.now();try{let c=await n.call(window,r,i);return c.ok||Ne({url:l.slice(0,500),method:s,status:c.status,statusText:c.statusText,timestamp:a,durationMs:Date.now()-a}),c}catch(c){throw Ne({url:l.slice(0,500),method:s,status:0,statusText:c instanceof Error?c.message:"Network error",timestamp:a,durationMs:Date.now()-a}),c}};}if(e.network!==false&&ye&&ve){let n=ye,o=ve;Ue=true,XMLHttpRequest.prototype.open=function(r,i,...l){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...l])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",l=this.__bf_url||"",s=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let a={url:l.slice(0,500),method:i,status:this.status,timestamp:s,durationMs:Date.now()-s};this.statusText&&(a.statusText=this.statusText),Ne(a);}},{once:true}),o.apply(this,r)};}}function pi(){if(we){for(let e of Oe){let t=Kt[e];t&&(console[e]=t);}Oe.clear(),He&&be&&(window.fetch=be,He=false),Ue&&ye&&ve&&(XMLHttpRequest.prototype.open=ye,XMLHttpRequest.prototype.send=ve,Ue=false),he=[],we=false;}}function mi(){return {consoleLogs:[...ne],networkErrors:[...oe]}}function gi(){ne=[],oe=[];}var ko=[{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}/}],K=[],Ve=0,qe=false;function To(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function Co(e,t,n,o){if(K.some(l=>l.rule===e&&l.source===t))return;let i={rule:e,source:t,hint:To(n),timestamp:Date.now()};o&&(i.location=o),K.push(i);}function re(e,t,n,o){for(let{name:r,pattern:i}of n){let l=i.exec(e);l&&Co(r,t,l[0],o);}}function Ro(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);re(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);re(n,"hydration",e,"__NUXT__");}}catch{}}function Ao(e){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&re(r,"scripts",e,`inline-script[${o}]`);});}catch{}}function xo(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let o=n.getAttribute("content"),r=n.getAttribute("name")||n.getAttribute("property")||"";o&&o.length>10&&re(o,"meta",e,r?`meta[${r}]`:void 0);});}catch{}}function Io(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&&re(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function yi(e={}){if(qe||!_()||(qe=true,e.secretScan===false))return;let t=[...ko,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{Ve=Date.now(),n.includes("hydration")&&Ro(t),n.includes("scripts")&&Ao(t),n.includes("meta")&&xo(t),n.includes("dom")&&Io(t);let o=e.notify??"both";K.length>0&&(o==="console"||o==="both")&&console.warn(`[BlocFeed Security] Found ${K.length} potential secret(s) exposed in client code:`,K.map(r=>`${r.rule} (${r.source}${r.location?`: ${r.location}`:""})`));},100);}function vi(){return {findings:[...K],scannedAt:Ve}}function wi(){K=[],Ve=0,qe=false;}
|
|
2
|
+
export{gi as A,yi as B,vi as C,wi as D,_ as a,Se as b,tt as c,it as d,st as e,xe as f,at as g,zo as h,Xo as i,yn as j,vn as k,Tn as l,Ie as m,xn as n,Me as o,Ln as p,ar as q,St as r,dr as s,Mt as t,fr as u,pe as v,li as w,fi as x,pi as y,mi as z};
|
package/dist/engine.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkFBLTAHNW_cjs=require('./chunk-FBLTAHNW.cjs');function s(o){if(o?.aborted)throw new Error("Aborted")}async function v(o){return await new Promise((t,e)=>{let r=new Image;r.onload=()=>t({width:r.naturalWidth,height:r.naturalHeight}),r.onerror=()=>e(new Error("Failed to load generated screenshot")),r.src=o;})}async function l(o,t){let{width:e,height:r}=await v(o);return {dataUrl:o,mime:t,width:e,height:r}}function U(o){return {async captureElement(t,e){if(!chunkFBLTAHNW_cjs.a())throw new Error("captureElement can only run in the browser");s(e.signal);let r={scale:e.pixelRatio},n=e.mime==="image/jpeg"?await o.domToJpeg(t,{...r,quality:e.quality??.92}):await o.domToPng(t,r);return s(e.signal),await l(n,e.mime)},async captureFullPage(t){if(!chunkFBLTAHNW_cjs.a())throw new Error("captureFullPage can only run in the browser");s(t.signal);let e=document.documentElement,r=Math.max(e.scrollWidth,e.clientWidth),n=Math.max(e.scrollHeight,e.clientHeight),i=Math.min(1,t.maxDimension/Math.max(r,n)),c={width:Math.max(1,Math.round(r*i)),height:Math.max(1,Math.round(n*i)),scale:t.pixelRatio},a=t.mime==="image/jpeg"?await o.domToJpeg(e,{...c,quality:t.quality??.92}):await o.domToPng(e,c);return s(t.signal),await l(a,t.mime)}}}function O(o){let[t,e]=o.split(",",2);if(!t||!e)throw new Error("Invalid data URL");let n=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(e),c=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)c[a]=i.charCodeAt(a);return new Blob([c],{type:n})}Object.defineProperty(exports,"clearClickEvents",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.k}});Object.defineProperty(exports,"clearDiagnostics",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.A}});Object.defineProperty(exports,"clearQueue",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.h}});Object.defineProperty(exports,"clearSecurityFindings",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.D}});Object.defineProperty(exports,"collectMetadata",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.e}});Object.defineProperty(exports,"createBlocFeedController",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.w}});Object.defineProperty(exports,"createHtmlToImageAdapter",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.c}});Object.defineProperty(exports,"dequeueAll",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.g}});Object.defineProperty(exports,"drainClickEvents",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.j}});Object.defineProperty(exports,"drainDiagnostics",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.z}});Object.defineProperty(exports,"enqueue",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.f}});Object.defineProperty(exports,"getMyFeedbackUrl",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.q}});Object.defineProperty(exports,"getQueueSize",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.i}});Object.defineProperty(exports,"getSecurityFindings",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.C}});Object.defineProperty(exports,"getViewerToken",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.p}});Object.defineProperty(exports,"installDiagnostics",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.x}});Object.defineProperty(exports,"isRecordingSupported",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.l}});Object.defineProperty(exports,"isVoiceSupported",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.n}});Object.defineProperty(exports,"runCapture",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.d}});Object.defineProperty(exports,"runSecretScan",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.B}});Object.defineProperty(exports,"startRecording",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.m}});Object.defineProperty(exports,"startVoiceRecording",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.o}});Object.defineProperty(exports,"transcribeAudio",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.r}});Object.defineProperty(exports,"uninstallDiagnostics",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.y}});exports.createModernScreenshotAdapter=U;exports.dataUrlToBlob=O;
|
package/dist/engine.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-GNKDVHVD.js';export{k as clearClickEvents,A as clearDiagnostics,h as clearQueue,D as clearSecurityFindings,e as collectMetadata,w as createBlocFeedController,c as createHtmlToImageAdapter,g as dequeueAll,j as drainClickEvents,z as drainDiagnostics,f as enqueue,q as getMyFeedbackUrl,i as getQueueSize,C as getSecurityFindings,p as getViewerToken,x as installDiagnostics,l as isRecordingSupported,n as isVoiceSupported,d as runCapture,B as runSecretScan,m as startRecording,o as startVoiceRecording,r as transcribeAudio,y as uninstallDiagnostics}from'./chunk-GNKDVHVD.js';function s(o){if(o?.aborted)throw new Error("Aborted")}async function v(o){return await new Promise((t,e)=>{let r=new Image;r.onload=()=>t({width:r.naturalWidth,height:r.naturalHeight}),r.onerror=()=>e(new Error("Failed to load generated screenshot")),r.src=o;})}async function l(o,t){let{width:e,height:r}=await v(o);return {dataUrl:o,mime:t,width:e,height:r}}function U(o){return {async captureElement(t,e){if(!a())throw new Error("captureElement can only run in the browser");s(e.signal);let r={scale:e.pixelRatio},n=e.mime==="image/jpeg"?await o.domToJpeg(t,{...r,quality:e.quality??.92}):await o.domToPng(t,r);return s(e.signal),await l(n,e.mime)},async captureFullPage(t){if(!a())throw new Error("captureFullPage can only run in the browser");s(t.signal);let e=document.documentElement,r=Math.max(e.scrollWidth,e.clientWidth),n=Math.max(e.scrollHeight,e.clientHeight),i=Math.min(1,t.maxDimension/Math.max(r,n)),c={width:Math.max(1,Math.round(r*i)),height:Math.max(1,Math.round(n*i)),scale:t.pixelRatio},a$1=t.mime==="image/jpeg"?await o.domToJpeg(e,{...c,quality:t.quality??.92}):await o.domToPng(e,c);return s(t.signal),await l(a$1,t.mime)}}}function O(o){let[t,e]=o.split(",",2);if(!t||!e)throw new Error("Invalid data URL");let n=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(e),c=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)c[a]=i.charCodeAt(a);return new Blob([c],{type:n})}export{U as createModernScreenshotAdapter,O as dataUrlToBlob};
|
package/dist/main.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
'use strict';var
|
|
2
|
+
'use strict';var chunkFBLTAHNW_cjs=require('./chunk-FBLTAHNW.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),framerMotion=require('framer-motion');var j=react.createContext(null);function ne(e){let t=react.useMemo(()=>chunkFBLTAHNW_cjs.w({...e.config??{},blocfeed_id:e.blocfeed_id}),[]);react.useEffect(()=>{chunkFBLTAHNW_cjs.t(e.blocfeed_id);},[e.blocfeed_id]);let[i,r]=react.useState(()=>t.getState());return react.useEffect(()=>t.subscribe(r),[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(j.Provider,{value:{controller:t,state:i},children:e.children})}var ze="blocfeed-styles-v1",Wt=`
|
|
3
3
|
:where([data-blocfeed-ui-root]),
|
|
4
4
|
:where([data-blocfeed-ui-root]) * {
|
|
5
5
|
box-sizing: border-box;
|
|
@@ -881,5 +881,5 @@
|
|
|
881
881
|
animation: none;
|
|
882
882
|
}
|
|
883
883
|
}
|
|
884
|
-
`;function Me(){if(!chunk4VWH5ZG6_cjs.a()||document.getElementById(Re))return;let t=document.createElement("style");t.id=Re,t.textContent=It,document.head.appendChild(t);}var Le={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 ze(t){return t?{...Le,...t}:Le}function ae(){let t=react.useContext(Y);if(!t)throw new Error("useBlocFeed must be used within a <BlocFeedProvider />");return {state:t.state,controller:t.controller,start:t.controller.start,stop:t.controller.stop,clearSelection:t.controller.clearSelection,submit:t.controller.submit,startRecording:t.controller.startRecording,stopRecording:t.controller.stopRecording,removeVideo:t.controller.removeVideo}}function y(t){switch(t){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 g({size:t=14}){return jsxRuntime.jsx("svg",{width:t,height:t,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 Ie({size:t=14}){return jsxRuntime.jsx("svg",{width:t,height:t,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 Ae({size:t=16}){return jsxRuntime.jsxs("svg",{width:t,height:t,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 _e({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){return i?jsxRuntime.jsxs("button",{className:y(t),type:"button",onClick:e,"aria-label":r,children:[p?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-dot","aria-hidden":"true"}),r]}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]}):null}function h(){let[t,e]=react.useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return react.useEffect(()=>{let i=window.matchMedia("(prefers-reduced-motion: reduce)"),r=a=>e(a.matches);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[]),t}var Vt={duration:.18,ease:"easeOut"},$t={duration:0};function Oe({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?$t:Vt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",animate:o?{}:{scale:n?1:[1,1.2,1],boxShadow:n?"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:n||o?c:{duration:2,repeat:1/0,ease:"easeInOut"}}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"dot")})}var Yt={duration:.18,ease:"easeOut"},Ve={duration:0};function Ke({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?Ve:Yt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsxs(framerMotion.motion.div,{className:y(t),initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{y:8,opacity:0},transition:c,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),style:{background:"transparent",border:"none",boxShadow:"none",padding:0},children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:o?0:4},animate:{opacity:1,y:0},exit:{opacity:0,y:o?0:4},transition:c,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:r},"tooltip")}),jsxRuntime.jsxs(framerMotion.motion.button,{type:"button",onClick:e,"aria-label":r,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:o?{}:{y:[0,-3,0]},transition:o?Ve:{y:{duration:3,repeat:1/0,ease:"easeInOut"}},whileHover:{scale:1.1,borderColor:"var(--bf-accent)"},whileTap:{scale:.9},children:[p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:16})},"success"):jsxRuntime.jsx(Ie,{size:16}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${a} queued`,children:a})]})]},"bubble")})}var Qt={duration:.2,ease:"easeOut"},qt={duration:0};function Xe(t){return t==="bottom-left"||t==="top-left"}function Jt(t){return `bf-trigger-edge ${Xe(t)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function Ye({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=Xe(t),c=h(),x=c?qt:Qt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:Jt(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,width:0},animate:{opacity:1,width:n?140:22,height:n?40:90},exit:{width:0,opacity:0},transition:x,whileTap:{scale:.97},style:{top:"50%",translateY:"-50%"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:x,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(framerMotion.motion.span,{animate:{rotate:c||n?0:o?-90:90,opacity:n?1:.6},transition:x,style:{display:"flex",alignItems:"center",gap:"8px",whiteSpace:"nowrap",fontSize:"12px",letterSpacing:"0.5px",textTransform:"uppercase"},children:[n&&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}}),r]}),jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",animate:{opacity:n?1:0},transition:{duration:.12},style:{position:"absolute",top:0,bottom:0,[o?"left":"right"]:0,width:"2px",background:"var(--bf-accent)"}}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"edge-tab")})}var to={duration:.18,ease:"easeOut"},oo={duration:0};function je({delay:t,hovered:e,reduced:i}){return i?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:e?{scale:1,opacity:0}:{scale:[1,1.8],opacity:[.5,0]},transition:e?{duration:.15}:{duration:2,repeat:1/0,delay:t,ease:"easeOut"}})}function qe({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?oo:to;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{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(je,{delay:0,hovered:n,reduced:o}),jsxRuntime.jsx(je,{delay:.7,hovered:n,reduced:o}),jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",style:{position:"relative",zIndex:1}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"pulse-ring")})}var no={duration:.18,ease:"easeOut"},so={duration:0};function co(t){switch(t){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 et({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?so:no;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsxs(framerMotion.motion.button,{className:co(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,y:o?0:5},animate:{opacity:n?1:.65,y:0},exit:{opacity:0,y:o?0:5},transition:c,whileTap:{scale:.95},children:[p?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:r}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${a} queued`,children:a})]}),!o&&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:n?1:0},transition:c})]},"minimal")})}var po={duration:.18,ease:"easeOut"},uo={duration:0};function ot({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?uo:po;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.9},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{style:{display:"inline-flex",flexShrink:0},animate:o?{}:n?{scale:1.2,rotate:0}:{rotate:[-5,5,-5]},transition:n||o?c:{duration:3,repeat:1/0,ease:"easeInOut"},children:jsxRuntime.jsx(Ae,{size:16})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-8},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-8},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"icon-pop")})}var ho={duration:.18,ease:"easeOut"},xo={duration:0};function at({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?xo:ho;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{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:o?{}:{opacity:n?1:[.5,1,.5],boxShadow:n?"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:n||o?c:{duration:2,repeat:1/0,ease:"easeInOut"}}),!n&&!o&&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:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"beacon")})}var To={duration:.18,ease:"easeOut"},Eo={duration:0};function lt({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),[o,c]=react.useState(0),x=h(),z=x?Eo:To,f=react.useRef(null);react.useEffect(()=>{if(f.current&&(clearInterval(f.current),f.current=null),!i||n||x){c(n||x?r.length:0);return}let b=8,T=r.length*2+b*2,m=0;return f.current=setInterval(()=>{m=(m+1)%T,m<=r.length?c(m):m<=r.length+b?c(r.length):m<=r.length*2+b?c(r.length*2+b-m):c(0);},100),()=>{f.current&&(clearInterval(f.current),f.current=null);}},[i,n,x,r]);let S=r.slice(0,o);return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,y:x?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:x?0:5},transition:z,whileTap:{scale:.95},style:{minWidth:"44px"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:z,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{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:[S,jsxRuntime.jsx("span",{className:"bf-cursor","aria-hidden":"true"})]}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"typewriter")})}function dt(t){switch(t){case "dot":return Oe;case "bubble":return Ke;case "edge-tab":return Ye;case "pulse-ring":return qe;case "minimal":return et;case "icon-pop":return ot;case "beacon":return at;case "typewriter":return lt;default:return _e}}function ft(t,e,i){return Math.max(e,Math.min(i,t))}function No(t,e,i="bottom-right"){let a=window.innerWidth,p=window.innerHeight,n;n=ft(t.x,12,Math.max(12,a-e-12));let l=t.y+t.height+12,o=Math.max(12,t.y-240);return {top:l+240<=p?l:o,left:n}}function Fo(t){let{rect:e}=t,i={left:`${e.x}px`,top:`${e.y}px`,width:`${Math.max(0,e.width)}px`,height:`${Math.max(0,e.height)}px`};return jsxRuntime.jsx("div",{className:"bf-highlight",style:i,"aria-hidden":"true"})}function Ro(t){let e=react.useRef(null);return react.useEffect(()=>{if(!t||!e.current)return;let i=e.current,r=i.querySelector(".bf-textarea");r?.focus();let a=n=>{if(n.key!=="Tab")return;let l=i.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(l.length===0)return;let o=l[0],c=l[l.length-1];n.shiftKey&&document.activeElement===o?(n.preventDefault(),c.focus()):!n.shiftKey&&document.activeElement===c&&(n.preventDefault(),o.focus());},p=n=>{let l=n.target;l&&(i.contains(l)||(n.stopImmediatePropagation(),r?.focus()));};return document.addEventListener("keydown",a,{capture:true}),document.addEventListener("focusin",p,{capture:true}),()=>{document.removeEventListener("keydown",a,{capture:true}),document.removeEventListener("focusin",p,{capture:true});}},[t]),e}function Mo(t,e){return t?typeof t=="function"?t(e):t.some(i=>i.endsWith("*")?e.startsWith(i.slice(0,-1)):e===i):true}var ce=new Set,pt=false;function Lo(){if(pt||typeof window>"u")return;pt=true;let t=history.pushState,e=history.replaceState,i=()=>{for(let r of ce)r();};history.pushState=function(...r){t.apply(this,r),setTimeout(i,0);},history.replaceState=function(...r){e.apply(this,r),setTimeout(i,0);};}function zo(t){let[e,i]=react.useState(()=>typeof window<"u"?window.location.pathname:"/");return react.useEffect(()=>{if(typeof window>"u")return;let r=()=>i(window.location.pathname);return window.addEventListener("popstate",r),Lo(),ce.add(r),()=>{window.removeEventListener("popstate",r),ce.delete(r);}},[]),Mo(t,e)}function Io(t){let[e,i]=react.useState(()=>!t||t==="dark"?"dark":t==="light"?"light":typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return react.useEffect(()=>{if(t!=="auto"){i(t==="light"?"light":"dark");return}let r=window.matchMedia("(prefers-color-scheme: dark)"),a=p=>i(p.matches?"dark":"light");return i(r.matches?"dark":"light"),r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[t]),e}var Ao=["bug","feature","ux","general"],Wo={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function X(t){let e=Math.floor(t/1e3),i=Math.floor(e/60),r=e%60;return `${i}:${String(r).padStart(2,"0")}`}function _o(t){return t<1024*1024?`${Math.round(t/1024)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Ho(t){let{state:e,controller:i,start:r,stop:a,clearSelection:p,submit:n}=ae(),l=t.config.ui?.position,o=ze(t.config.ui?.strings),c=t.config.ui?.branding!==false,[x,z]=react.useState(null),[f,S]=react.useState(""),[b,T]=react.useState(t.config.capture?.element??true),[m,C]=react.useState(t.config.capture?.fullPage??false),[bt,de]=react.useState(null),[D,fe]=react.useState(void 0),pe=t.config.ui?.categories??Ao,gt=t.config.recording?.enabled===true&&chunk4VWH5ZG6_cjs.l(),mt=t.config.recording?.maxDurationMs??3e4,ue=i.getConfig().voice,ht=ue?.enabled===true&&chunk4VWH5ZG6_cjs.n(),xt=ue?.maxDurationMs??6e4,[vt,yt]=react.useState(false),[J,wt]=react.useState(0);react.useEffect(()=>{let s=window.setTimeout(()=>{let v=chunk4VWH5ZG6_cjs.z();wt(v.findings.length);},500);return ()=>window.clearTimeout(s)},[]),react.useImperativeHandle(t.handleRef,()=>({open:r,close:a,submit:s=>n(s),startRecording:()=>i.startRecording(),stopRecording:()=>i.stopRecording(),get isOpen(){return e.phase!=="idle"}}),[r,a,n,i,e.phase]);let be=e.phase==="review"||e.phase==="capturing"||e.phase==="submitting"||e.phase==="error"||e.phase==="success",kt=Ro(be),[Tt,Et]=react.useState(0);react.useEffect(()=>{e.phase==="idle"&&Et(chunk4VWH5ZG6_cjs.i());},[e.phase]);let[St,ge]=react.useState(false),me=react.useRef(e.phase);react.useEffect(()=>{if(me.current==="success"&&e.phase==="idle"){ge(true);let s=window.setTimeout(()=>ge(false),1500);return ()=>window.clearTimeout(s)}me.current=e.phase;},[e.phase]),react.useEffect(()=>{let s=t.config.ui?.shortcut;if(!s)return;let v=s.toLowerCase().split("+").map(N=>N.trim()),B=v[v.length-1]||"",I=new Set(v.slice(0,-1)),ve=N=>{let Nt=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(I.has("mod")){if(Nt?!N.metaKey:!N.ctrlKey)return}else if(I.has("ctrl")&&!N.ctrlKey||(I.has("meta")||I.has("cmd"))&&!N.metaKey)return;I.has("shift")&&!N.shiftKey||(I.has("alt")||I.has("option"))&&!N.altKey||N.key.toLowerCase()===B&&(N.preventDefault(),e.phase==="idle"?r():a());};return document.addEventListener("keydown",ve),()=>document.removeEventListener("keydown",ve)},[t.config.ui?.shortcut,e.phase,r,a]),react.useEffect(()=>i.subscribeHover(z),[i]),react.useEffect(()=>{let s=i.__unsafeGetSelectedElement();if(!s||e.phase==="idle"||e.phase==="picking"){de(null);return}let v=()=>{de(chunk4VWH5ZG6_cjs.b(s.getBoundingClientRect()));};v();let B=()=>v();return window.addEventListener("scroll",B,{capture:true,passive:true}),window.addEventListener("resize",B,{passive:true}),()=>{window.removeEventListener("scroll",B,{capture:true}),window.removeEventListener("resize",B);}},[i,e.phase,e.selection?.selector]),react.useEffect(()=>{e.phase==="review"&&(S(""),T(t.config.capture?.element??true),C(t.config.capture?.fullPage??false),fe(void 0),V(null));},[e.phase,e.selection?.selector,t.config.capture?.element,t.config.capture?.fullPage]),react.useEffect(()=>{if(e.phase!=="success")return;let s=window.setTimeout(()=>a(),1200);return ()=>window.clearTimeout(s)},[e.phase,a]);let E=e.phase==="capturing"||e.phase==="submitting",M=e.phase==="picking"?x?.rect??null:bt??e.selection?.rect??null,Z=react.useMemo(()=>M?No(M,360,l):null,[M?.x,M?.y,M?.width,M?.height,l]),he=e.lastError?.message,ee=react.useCallback(()=>{let s={capture:{element:b,fullPage:m}};D&&(s.category=D),n(f,s);},[n,f,b,m,D]),Ct=react.useCallback(s=>{(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&f.trim().length>0&&!E&&(s.preventDefault(),ee());},[ee,f,E]),[xe,V]=react.useState(null),Pt=react.useCallback(async()=>{if(e.voiceRecording){i.stopVoice();return}V(null);let s=await i.startVoice();if(s?.text)S(v=>v?v+" "+s.text:s.text);else if(s?.warning)V(o.voiceEmptyText);else if(!s){let v=i.getState().lastError;if(v){let B=v.message?.toLowerCase()??"";B.includes("denied")||B.includes("permission")||B.includes("not allowed")?V(o.voiceDeniedText):V(o.voiceErrorText);}}},[e.voiceRecording,i,o]),Bt=dt(t.config.ui?.triggerStyle);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Bt,{position:l,onClick:()=>r(),isVisible:e.phase==="idle",label:t.config.ui?.triggerLabel??o.triggerLabel,queueCount:Tt,showSuccess:St}),e.phase!=="idle"&&e.phase!=="recording"&&jsxRuntime.jsxs("div",{className:"bf-overlay",role:"presentation",children:[e.phase!=="picking"&&jsxRuntime.jsx("div",{className:"bf-blocker",role:"presentation",onClick:()=>a()}),M&&jsxRuntime.jsx(Fo,{rect:M}),e.phase==="picking"&&jsxRuntime.jsxs("div",{className:"bf-hint",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("p",{id:"bf-hint-text",children:o.hintText}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),"aria-label":o.cancelButton,children:o.cancelButton})]}),be&&Z&&jsxRuntime.jsxs("div",{ref:kt,className:"bf-panel",style:{left:Z.left,top:Z.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:o.panelTitle}),jsxRuntime.jsxs("div",{className:"bf-row",style:{justifyContent:"flex-end"},children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>p(),disabled:E,"aria-label":o.rePickButton,children:o.rePickButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),disabled:E,"aria-label":o.closeButton,children:o.closeButton})]})]}),jsxRuntime.jsxs("div",{className:"bf-panelBody",children:[jsxRuntime.jsx("textarea",{className:"bf-textarea",placeholder:o.textareaPlaceholder,value:f,onChange:s=>S(s.target.value),onKeyDown:Ct,disabled:E,"aria-label":o.panelTitle}),pe.length>0&&jsxRuntime.jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:pe.map(s=>jsxRuntime.jsx("button",{type:"button",className:`bf-pill${D===s?" bf-pill-active":""}`,onClick:()=>fe(D===s?void 0:s),disabled:E,children:o[Wo[s]]},s))}),jsxRuntime.jsxs("div",{className:"bf-row",role:"group","aria-label":o.screenshotElement,children:[jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:b,onChange:s=>T(s.target.checked),disabled:E}),o.screenshotElement]}),jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:m,onChange:s=>C(s.target.checked),disabled:E}),o.screenshotFullPage]})]}),ht&&e.phase==="review"&&!e.voiceTranscribing&&jsxRuntime.jsx("button",{type:"button",className:`bf-voice-btn${e.voiceRecording?" bf-voice-btn-active":""}`,onClick:Pt,disabled:E,"aria-label":e.voiceRecording?o.voiceStopButton:o.voiceButton,children:e.voiceRecording?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-rec-dot bf-rec-dot-pulse","aria-hidden":"true"}),o.voiceRecordingText," ",X(e.voiceElapsedMs??0)," / ",X(xt)," \u2014 ",o.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"})]}),o.voiceButton]})}),e.voiceTranscribing&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.voiceTranscribingText]}),xe&&!e.voiceRecording&&!e.voiceTranscribing&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:xe}),gt&&e.phase==="review"&&!e.video&&jsxRuntime.jsxs("button",{type:"button",className:"bf-record-btn",onClick:()=>i.startRecording(),disabled:E,"aria-label":o.recordButton,children:[jsxRuntime.jsx("span",{className:"bf-rec-dot","aria-hidden":"true"}),o.recordButton]}),e.video&&e.phase==="review"&&jsxRuntime.jsxs("div",{className:"bf-video-preview",children:[jsxRuntime.jsx("video",{src:e.video.blobUrl,controls:true,muted:true,playsInline:true}),jsxRuntime.jsx("button",{type:"button",className:"bf-video-remove",onClick:()=>i.removeVideo(),"aria-label":o.removeVideoButton,children:"\xD7"}),jsxRuntime.jsxs("div",{className:"bf-video-meta",children:[o.videoPreviewLabel," (",X(e.video.durationMs),", ",_o(e.video.sizeBytes),")"]})]}),e.phase==="capturing"&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.capturingText]}),e.phase==="submitting"&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.submittingText]}),e.phase==="success"&&jsxRuntime.jsx("div",{className:"bf-status",role:"status","aria-live":"polite",children:o.successText}),e.phase==="error"&&he&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:he}),jsxRuntime.jsxs("div",{className:"bf-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),disabled:E,"aria-label":o.cancelButton,children:o.cancelButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:ee,disabled:E||f.trim().length===0,"aria-label":o.sendButton,children:o.sendButton})]})]}),c&&jsxRuntime.jsxs("div",{className:"bf-watermark",children:[(()=>{let s=chunk4VWH5ZG6_cjs.q();return s?jsxRuntime.jsx("a",{href:s,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"})]})]})]}),e.phase==="recording"&&jsxRuntime.jsxs("div",{className:`bf-recording-bar bf-pos-${l}`,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:[o.recordingText," ",X(e.recordingElapsedMs??0)," / ",X(mt)]}),jsxRuntime.jsx("button",{type:"button",className:"bf-recording-bar-stop",onClick:()=>i.stopRecording(),"aria-label":o.stopRecordButton,children:o.stopRecordButton})]}),e.phase==="success"&&jsxRuntime.jsxs("div",{className:"bf-toast",role:"status","aria-live":"polite",children:[o.toastText,(()=>{let s=chunk4VWH5ZG6_cjs.q();return s?jsxRuntime.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"bf-toast-link",children:"View my feedback"}):null})()]}),J>0&&!vt&&jsxRuntime.jsxs("div",{className:"bf-security-banner",role:"alert",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-security-banner-dismiss",onClick:()=>yt(true),"aria-label":"Dismiss",children:"\xD7"}),jsxRuntime.jsx("strong",{children:"Security Warning"}),J," potential secret",J>1?"s":""," exposed in client code. Check your environment variables."]})]})}var Oo=react.forwardRef(function(e,i){let r={...e.config??{},blocfeed_id:e.blocfeed_id},[a,p]=react.useState(null),n=zo(r.ui?.showOn),l=Io(r.ui?.theme?.mode),o=!!r.diagnostics;react.useEffect(()=>{if(o)return chunk4VWH5ZG6_cjs.u(r.diagnostics),()=>chunk4VWH5ZG6_cjs.v()},[o]);let c=!!r.security;react.useEffect(()=>{c&&chunk4VWH5ZG6_cjs.y(r.security);},[c]);let x=react.useRef(e.config?.metadata?.enrich);x.current=e.config?.metadata?.enrich;let z=react.useMemo(()=>{if(e.config)return {...e.config,metadata:{...e.config.metadata,enrich:async f=>{let S=x.current,b=S?await S(f):{},T=chunk4VWH5ZG6_cjs.w(),m=chunk4VWH5ZG6_cjs.z(),C=chunk4VWH5ZG6_cjs.j();return {...b,...T.consoleLogs.length>0?{_consoleLogs:T.consoleLogs}:{},...T.networkErrors.length>0?{_networkErrors:T.networkErrors}:{},...m.findings.length>0?{_securityFindings:m.findings}:{},...C.length>0?{_clickEvents:C}:{}}}}}},[]);return react.useEffect(()=>{Me();let f=document.createElement("div");f.setAttribute("data-blocfeed-ui-root","true"),f.setAttribute("data-blocfeed-ui","true"),f.setAttribute("data-bf-theme",l);let S=r.ui?.zIndex;typeof S=="number"&&f.style.setProperty("--bf-z",String(S));let b=r.ui?.theme;b&&(b.accentColor&&f.style.setProperty("--bf-accent",b.accentColor),b.panelBackground&&f.style.setProperty("--bf-panel-bg",b.panelBackground),b.panelForeground&&f.style.setProperty("--bf-panel-fg",b.panelForeground),b.fontFamily&&f.style.setProperty("--bf-font",b.fontFamily));let T=C=>C.stopPropagation(),m=["pointerdown","pointerup","mousedown","mouseup","click","touchstart","touchend"];for(let C of m)f.addEventListener(C,T);try{document.body.appendChild(f);}catch{return}return p(f),()=>{for(let C of m)f.removeEventListener(C,T);f.remove(),p(null);}},[r.ui?.zIndex,r.ui?.theme?.accentColor,r.ui?.theme?.panelBackground,r.ui?.theme?.panelForeground,r.ui?.theme?.fontFamily,l]),!n||!a?null:reactDom.createPortal(jsxRuntime.jsx(ie,{blocfeed_id:r.blocfeed_id,...z?{config:z}:{},children:jsxRuntime.jsx(Ho,{config:r,handleRef:i})}),a)});
|
|
885
|
-
Object.defineProperty(exports,"BehavioralTracker",{enumerable:true,get:function(){return
|
|
884
|
+
`;function Ie(){if(!chunkFBLTAHNW_cjs.a()||document.getElementById(ze))return;let e=document.createElement("style");e.id=ze,e.textContent=Wt,document.head.appendChild(e);}var Ae={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 _e(e){return e?{...Ae,...e}:Ae}function se(){let e=react.useContext(j);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:chunkFBLTAHNW_cjs.u}}function y(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 g({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 We({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 Oe({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 De({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){return i?jsxRuntime.jsxs("button",{className:y(e),type:"button",onClick:t,"aria-label":r,children:[p?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-dot","aria-hidden":"true"}),r]}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]}):null}function h(){let[e,t]=react.useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return react.useEffect(()=>{let i=window.matchMedia("(prefers-reduced-motion: reduce)"),r=a=>t(a.matches);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[]),e}var Ut={duration:.18,ease:"easeOut"},Xt={duration:0};function $e({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?Xt:Ut;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",animate:o?{}:{scale:n?1:[1,1.2,1],boxShadow:n?"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:n||o?c:{duration:2,repeat:1/0,ease:"easeInOut"}}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"dot")})}var Qt={duration:.18,ease:"easeOut"},Ue={duration:0};function Ye({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?Ue:Qt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsxs(framerMotion.motion.div,{className:y(e),initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{y:8,opacity:0},transition:c,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),style:{background:"transparent",border:"none",boxShadow:"none",padding:0},children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:o?0:4},animate:{opacity:1,y:0},exit:{opacity:0,y:o?0:4},transition:c,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:r},"tooltip")}),jsxRuntime.jsxs(framerMotion.motion.button,{type:"button",onClick:t,"aria-label":r,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:o?{}:{y:[0,-3,0]},transition:o?Ue:{y:{duration:3,repeat:1/0,ease:"easeInOut"}},whileHover:{scale:1.1,borderColor:"var(--bf-accent)"},whileTap:{scale:.9},children:[p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:16})},"success"):jsxRuntime.jsx(We,{size:16}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${a} queued`,children:a})]})]},"bubble")})}var Zt={duration:.2,ease:"easeOut"},eo={duration:0};function je(e){return e==="bottom-left"||e==="top-left"}function to(e){return `bf-trigger-edge ${je(e)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function Qe({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=je(e),c=h(),x=c?eo:Zt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:to(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,width:0},animate:{opacity:1,width:n?140:22,height:n?40:90},exit:{width:0,opacity:0},transition:x,whileTap:{scale:.97},style:{top:"50%",translateY:"-50%"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:x,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(framerMotion.motion.span,{animate:{rotate:c||n?0:o?-90:90,opacity:n?1:.6},transition:x,style:{display:"flex",alignItems:"center",gap:"8px",whiteSpace:"nowrap",fontSize:"12px",letterSpacing:"0.5px",textTransform:"uppercase"},children:[n&&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}}),r]}),jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",animate:{opacity:n?1:0},transition:{duration:.12},style:{position:"absolute",top:0,bottom:0,[o?"left":"right"]:0,width:"2px",background:"var(--bf-accent)"}}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"edge-tab")})}var io={duration:.18,ease:"easeOut"},ao={duration:0};function Je({delay:e,hovered:t,reduced:i}){return i?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 et({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?ao:io;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{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(Je,{delay:0,hovered:n,reduced:o}),jsxRuntime.jsx(Je,{delay:.7,hovered:n,reduced:o}),jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",style:{position:"relative",zIndex:1}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"pulse-ring")})}var lo={duration:.18,ease:"easeOut"},fo={duration:0};function po(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 rt({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?fo:lo;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsxs(framerMotion.motion.button,{className:po(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,y:o?0:5},animate:{opacity:n?1:.65,y:0},exit:{opacity:0,y:o?0:5},transition:c,whileTap:{scale:.95},children:[p?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:r}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${a} queued`,children:a})]}),!o&&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:n?1:0},transition:c})]},"minimal")})}var go={duration:.18,ease:"easeOut"},mo={duration:0};function at({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?mo:go;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.9},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{style:{display:"inline-flex",flexShrink:0},animate:o?{}:n?{scale:1.2,rotate:0}:{rotate:[-5,5,-5]},transition:n||o?c:{duration:3,repeat:1/0,ease:"easeInOut"},children:jsxRuntime.jsx(Oe,{size:16})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-8},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-8},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"icon-pop")})}var yo={duration:.18,ease:"easeOut"},wo={duration:0};function ct({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),o=h(),c=o?wo:yo;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{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:o?{}:{opacity:n?1:[.5,1,.5],boxShadow:n?"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:n||o?c:{duration:2,repeat:1/0,ease:"easeInOut"}}),!n&&!o&&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:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"beacon")})}var Bo={duration:.18,ease:"easeOut"},Po={duration:0};function pt({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=react.useState(false),[o,c]=react.useState(0),x=h(),z=x?Po:Bo,f=react.useRef(null);react.useEffect(()=>{if(f.current&&(clearInterval(f.current),f.current=null),!i||n||x){c(n||x?r.length:0);return}let b=8,T=r.length*2+b*2,m=0;return f.current=setInterval(()=>{m=(m+1)%T,m<=r.length?c(m):m<=r.length+b?c(r.length):m<=r.length*2+b?c(r.length*2+b-m):c(0);},100),()=>{f.current&&(clearInterval(f.current),f.current=null);}},[i,n,x,r]);let S=r.slice(0,o);return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,y:x?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:x?0:5},transition:z,whileTap:{scale:.95},style:{minWidth:"44px"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:z,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{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:[S,jsxRuntime.jsx("span",{className:"bf-cursor","aria-hidden":"true"})]}),a>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"typewriter")})}function ut(e){switch(e){case "dot":return $e;case "bubble":return Ye;case "edge-tab":return Qe;case "pulse-ring":return et;case "minimal":return rt;case "icon-pop":return at;case "beacon":return ct;case "typewriter":return pt;default:return De}}function bt(e,t,i){return Math.max(t,Math.min(i,e))}function Mo(e,t,i="bottom-right"){let a=window.innerWidth,p=window.innerHeight,n;n=bt(e.x,12,Math.max(12,a-t-12));let l=e.y+e.height+12,o=Math.max(12,e.y-240);return {top:l+240<=p?l:o,left:n}}function Lo(e){let{rect:t}=e,i={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:i,"aria-hidden":"true"})}function zo(e){let t=react.useRef(null);return react.useEffect(()=>{if(!e||!t.current)return;let i=t.current,r=i.querySelector(".bf-textarea");r?.focus();let a=n=>{if(n.key!=="Tab")return;let l=i.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(l.length===0)return;let o=l[0],c=l[l.length-1];n.shiftKey&&document.activeElement===o?(n.preventDefault(),c.focus()):!n.shiftKey&&document.activeElement===c&&(n.preventDefault(),o.focus());},p=n=>{let l=n.target;l&&(i.contains(l)||(n.stopImmediatePropagation(),r?.focus()));};return document.addEventListener("keydown",a,{capture:true}),document.addEventListener("focusin",p,{capture:true}),()=>{document.removeEventListener("keydown",a,{capture:true}),document.removeEventListener("focusin",p,{capture:true});}},[e]),t}function Io(e,t){return e?typeof e=="function"?e(t):e.some(i=>i.endsWith("*")?t.startsWith(i.slice(0,-1)):t===i):true}var de=new Set,gt=false;function Ao(){if(gt||typeof window>"u")return;gt=true;let e=history.pushState,t=history.replaceState,i=()=>{for(let r of de)r();};history.pushState=function(...r){e.apply(this,r),setTimeout(i,0);},history.replaceState=function(...r){t.apply(this,r),setTimeout(i,0);};}function _o(e){let[t,i]=react.useState(()=>typeof window<"u"?window.location.pathname:"/");return react.useEffect(()=>{if(typeof window>"u")return;let r=()=>i(window.location.pathname);return window.addEventListener("popstate",r),Ao(),de.add(r),()=>{window.removeEventListener("popstate",r),de.delete(r);}},[]),Io(e,t)}function Wo(e){let[t,i]=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"){i(e==="light"?"light":"dark");return}let r=window.matchMedia("(prefers-color-scheme: dark)"),a=p=>i(p.matches?"dark":"light");return i(r.matches?"dark":"light"),r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[e]),t}var Oo=["bug","feature","ux","general"],Ho={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function Y(e){let t=Math.floor(e/1e3),i=Math.floor(t/60),r=t%60;return `${i}:${String(r).padStart(2,"0")}`}function Do(e){return e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Vo(e){let{state:t,controller:i,start:r,stop:a,clearSelection:p,submit:n}=se(),l=e.config.ui?.position,o=_e(e.config.ui?.strings),c=e.config.ui?.branding!==false,[x,z]=react.useState(null),[f,S]=react.useState(""),[b,T]=react.useState(e.config.capture?.element??true),[m,B]=react.useState(e.config.capture?.fullPage??false),[ht,pe]=react.useState(null),[D,ue]=react.useState(void 0),be=e.config.ui?.categories??Oo,xt=e.config.recording?.enabled===true&&chunkFBLTAHNW_cjs.l(),vt=e.config.recording?.maxDurationMs??3e4,ge=i.getConfig().voice,yt=ge?.enabled===true&&chunkFBLTAHNW_cjs.n(),wt=ge?.maxDurationMs??6e4,[kt,Tt]=react.useState(false),[te,Et]=react.useState(0);react.useEffect(()=>{let s=window.setTimeout(()=>{let v=chunkFBLTAHNW_cjs.C();Et(v.findings.length);},500);return ()=>window.clearTimeout(s)},[]),react.useImperativeHandle(e.handleRef,()=>({open:r,close:a,submit:s=>n(s),startRecording:()=>i.startRecording(),stopRecording:()=>i.stopRecording(),get isOpen(){return t.phase!=="idle"}}),[r,a,n,i,t.phase]);let me=t.phase==="review"||t.phase==="capturing"||t.phase==="submitting"||t.phase==="error"||t.phase==="success",St=zo(me),[Bt,Pt]=react.useState(0);react.useEffect(()=>{t.phase==="idle"&&Pt(chunkFBLTAHNW_cjs.i());},[t.phase]);let[Ct,he]=react.useState(false),xe=react.useRef(t.phase);react.useEffect(()=>{if(xe.current==="success"&&t.phase==="idle"){he(true);let s=window.setTimeout(()=>he(false),1500);return ()=>window.clearTimeout(s)}xe.current=t.phase;},[t.phase]),react.useEffect(()=>{let s=e.config.ui?.shortcut;if(!s)return;let v=s.toLowerCase().split("+").map(N=>N.trim()),C=v[v.length-1]||"",I=new Set(v.slice(0,-1)),we=N=>{let Mt=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(I.has("mod")){if(Mt?!N.metaKey:!N.ctrlKey)return}else if(I.has("ctrl")&&!N.ctrlKey||(I.has("meta")||I.has("cmd"))&&!N.metaKey)return;I.has("shift")&&!N.shiftKey||(I.has("alt")||I.has("option"))&&!N.altKey||N.key.toLowerCase()===C&&(N.preventDefault(),t.phase==="idle"?r():a());};return document.addEventListener("keydown",we),()=>document.removeEventListener("keydown",we)},[e.config.ui?.shortcut,t.phase,r,a]),react.useEffect(()=>i.subscribeHover(z),[i]),react.useEffect(()=>{let s=i.__unsafeGetSelectedElement();if(!s||t.phase==="idle"||t.phase==="picking"){pe(null);return}let v=()=>{pe(chunkFBLTAHNW_cjs.b(s.getBoundingClientRect()));};v();let C=()=>v();return window.addEventListener("scroll",C,{capture:true,passive:true}),window.addEventListener("resize",C,{passive:true}),()=>{window.removeEventListener("scroll",C,{capture:true}),window.removeEventListener("resize",C);}},[i,t.phase,t.selection?.selector]),react.useEffect(()=>{t.phase==="review"&&(S(""),T(e.config.capture?.element??true),B(e.config.capture?.fullPage??false),ue(void 0),V(null));},[t.phase,t.selection?.selector,e.config.capture?.element,e.config.capture?.fullPage]),react.useEffect(()=>{if(t.phase!=="success")return;let s=window.setTimeout(()=>a(),1200);return ()=>window.clearTimeout(s)},[t.phase,a]);let E=t.phase==="capturing"||t.phase==="submitting",M=t.phase==="picking"?x?.rect??null:ht??t.selection?.rect??null,oe=react.useMemo(()=>M?Mo(M,360,l):null,[M?.x,M?.y,M?.width,M?.height,l]),ve=t.lastError?.message,re=react.useCallback(()=>{let s={capture:{element:b,fullPage:m}};D&&(s.category=D),n(f,s);},[n,f,b,m,D]),Nt=react.useCallback(s=>{(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&f.trim().length>0&&!E&&(s.preventDefault(),re());},[re,f,E]),[ye,V]=react.useState(null),Ft=react.useCallback(async()=>{if(t.voiceRecording){i.stopVoice();return}V(null);let s=await i.startVoice();if(s?.text)S(v=>v?v+" "+s.text:s.text);else if(s?.warning)V(o.voiceEmptyText);else if(!s){let v=i.getState().lastError;if(v){let C=v.message?.toLowerCase()??"";C.includes("denied")||C.includes("permission")||C.includes("not allowed")?V(o.voiceDeniedText):V(o.voiceErrorText);}}},[t.voiceRecording,i,o]),Rt=ut(e.config.ui?.triggerStyle);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Rt,{position:l,onClick:()=>r(),isVisible:t.phase==="idle",label:e.config.ui?.triggerLabel??o.triggerLabel,queueCount:Bt,showSuccess:Ct}),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:()=>a()}),M&&jsxRuntime.jsx(Lo,{rect:M}),t.phase==="picking"&&jsxRuntime.jsxs("div",{className:"bf-hint",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("p",{id:"bf-hint-text",children:o.hintText}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),"aria-label":o.cancelButton,children:o.cancelButton})]}),me&&oe&&jsxRuntime.jsxs("div",{ref:St,className:"bf-panel",style:{left:oe.left,top:oe.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:o.panelTitle}),jsxRuntime.jsxs("div",{className:"bf-row",style:{justifyContent:"flex-end"},children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>p(),disabled:E,"aria-label":o.rePickButton,children:o.rePickButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),disabled:E,"aria-label":o.closeButton,children:o.closeButton})]})]}),jsxRuntime.jsxs("div",{className:"bf-panelBody",children:[jsxRuntime.jsx("textarea",{className:"bf-textarea",placeholder:o.textareaPlaceholder,value:f,onChange:s=>S(s.target.value),onKeyDown:Nt,disabled:E,"aria-label":o.panelTitle}),be.length>0&&jsxRuntime.jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:be.map(s=>jsxRuntime.jsx("button",{type:"button",className:`bf-pill${D===s?" bf-pill-active":""}`,onClick:()=>ue(D===s?void 0:s),disabled:E,children:o[Ho[s]]},s))}),jsxRuntime.jsxs("div",{className:"bf-row",role:"group","aria-label":o.screenshotElement,children:[jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:b,onChange:s=>T(s.target.checked),disabled:E}),o.screenshotElement]}),jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:m,onChange:s=>B(s.target.checked),disabled:E}),o.screenshotFullPage]})]}),yt&&t.phase==="review"&&!t.voiceTranscribing&&jsxRuntime.jsx("button",{type:"button",className:`bf-voice-btn${t.voiceRecording?" bf-voice-btn-active":""}`,onClick:Ft,disabled:E,"aria-label":t.voiceRecording?o.voiceStopButton:o.voiceButton,children:t.voiceRecording?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-rec-dot bf-rec-dot-pulse","aria-hidden":"true"}),o.voiceRecordingText," ",Y(t.voiceElapsedMs??0)," / ",Y(wt)," \u2014 ",o.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"})]}),o.voiceButton]})}),t.voiceTranscribing&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.voiceTranscribingText]}),ye&&!t.voiceRecording&&!t.voiceTranscribing&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:ye}),xt&&t.phase==="review"&&!t.video&&jsxRuntime.jsxs("button",{type:"button",className:"bf-record-btn",onClick:()=>i.startRecording(),disabled:E,"aria-label":o.recordButton,children:[jsxRuntime.jsx("span",{className:"bf-rec-dot","aria-hidden":"true"}),o.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:()=>i.removeVideo(),"aria-label":o.removeVideoButton,children:"\xD7"}),jsxRuntime.jsxs("div",{className:"bf-video-meta",children:[o.videoPreviewLabel," (",Y(t.video.durationMs),", ",Do(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"}),o.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"}),o.submittingText]}),t.phase==="success"&&jsxRuntime.jsx("div",{className:"bf-status",role:"status","aria-live":"polite",children:o.successText}),t.phase==="error"&&ve&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:ve}),jsxRuntime.jsxs("div",{className:"bf-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),disabled:E,"aria-label":o.cancelButton,children:o.cancelButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:re,disabled:E||f.trim().length===0,"aria-label":o.sendButton,children:o.sendButton})]})]}),c&&jsxRuntime.jsxs("div",{className:"bf-watermark",children:[(()=>{let s=chunkFBLTAHNW_cjs.q();return s?jsxRuntime.jsx("a",{href:s,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-${l}`,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:[o.recordingText," ",Y(t.recordingElapsedMs??0)," / ",Y(vt)]}),jsxRuntime.jsx("button",{type:"button",className:"bf-recording-bar-stop",onClick:()=>i.stopRecording(),"aria-label":o.stopRecordButton,children:o.stopRecordButton})]}),t.phase==="success"&&jsxRuntime.jsxs("div",{className:"bf-toast",role:"status","aria-live":"polite",children:[o.toastText,(()=>{let s=chunkFBLTAHNW_cjs.q();return s?jsxRuntime.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"bf-toast-link",children:"View my feedback"}):null})()]}),te>0&&!kt&&jsxRuntime.jsxs("div",{className:"bf-security-banner",role:"alert",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-security-banner-dismiss",onClick:()=>Tt(true),"aria-label":"Dismiss",children:"\xD7"}),jsxRuntime.jsx("strong",{children:"Security Warning"}),te," potential secret",te>1?"s":""," exposed in client code. Check your environment variables."]})]})}var $o=react.forwardRef(function(t,i){let r={...t.config??{},blocfeed_id:t.blocfeed_id},[a,p]=react.useState(null),n=_o(r.ui?.showOn),l=Wo(r.ui?.theme?.mode),o=!!r.diagnostics;react.useEffect(()=>{if(o)return chunkFBLTAHNW_cjs.x(r.diagnostics),()=>chunkFBLTAHNW_cjs.y()},[o]);let c=!!r.security;react.useEffect(()=>{c&&chunkFBLTAHNW_cjs.B(r.security);},[c]);let x=react.useRef(t.config?.metadata?.enrich);x.current=t.config?.metadata?.enrich;let z=react.useMemo(()=>{if(t.config)return {...t.config,metadata:{...t.config.metadata,enrich:async f=>{let S=x.current,b=S?await S(f):{},T=chunkFBLTAHNW_cjs.z(),m=chunkFBLTAHNW_cjs.C(),B=chunkFBLTAHNW_cjs.j();return {...b,...T.consoleLogs.length>0?{_consoleLogs:T.consoleLogs}:{},...T.networkErrors.length>0?{_networkErrors:T.networkErrors}:{},...m.findings.length>0?{_securityFindings:m.findings}:{},...B.length>0?{_clickEvents:B}:{}}}}}},[]);return react.useEffect(()=>{Ie();let f=document.createElement("div");f.setAttribute("data-blocfeed-ui-root","true"),f.setAttribute("data-blocfeed-ui","true"),f.setAttribute("data-bf-theme",l);let S=r.ui?.zIndex;typeof S=="number"&&f.style.setProperty("--bf-z",String(S));let b=r.ui?.theme;b&&(b.accentColor&&f.style.setProperty("--bf-accent",b.accentColor),b.panelBackground&&f.style.setProperty("--bf-panel-bg",b.panelBackground),b.panelForeground&&f.style.setProperty("--bf-panel-fg",b.panelForeground),b.fontFamily&&f.style.setProperty("--bf-font",b.fontFamily));let T=B=>B.stopPropagation(),m=["pointerdown","pointerup","mousedown","mouseup","click","touchstart","touchend"];for(let B of m)f.addEventListener(B,T);try{document.body.appendChild(f);}catch{return}return p(f),()=>{for(let B of m)f.removeEventListener(B,T);f.remove(),p(null);}},[r.ui?.zIndex,r.ui?.theme?.accentColor,r.ui?.theme?.panelBackground,r.ui?.theme?.panelForeground,r.ui?.theme?.fontFamily,l]),!n||!a?null:reactDom.createPortal(jsxRuntime.jsx(ne,{blocfeed_id:r.blocfeed_id,...z?{config:z}:{},children:jsxRuntime.jsx(Vo,{config:r,handleRef:i})}),a)});var Di={init(e){chunkFBLTAHNW_cjs.t(e);},identify(e){chunkFBLTAHNW_cjs.s(e);},track:chunkFBLTAHNW_cjs.u};
|
|
885
|
+
Object.defineProperty(exports,"BehavioralTracker",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.v}});Object.defineProperty(exports,"track",{enumerable:true,get:function(){return chunkFBLTAHNW_cjs.u}});exports.BlocFeed=Di;exports.BlocFeedProvider=ne;exports.BlocFeedWidget=$o;exports.useBlocFeed=se;
|
package/dist/main.d.cts
CHANGED
|
@@ -17,6 +17,24 @@ type BlocFeedWidgetProps = {
|
|
|
17
17
|
};
|
|
18
18
|
declare const BlocFeedWidget: react.ForwardRefExoticComponent<BlocFeedWidgetProps & react.RefAttributes<BlocFeedHandle>>;
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Public-API types for the `track()` custom-event surface.
|
|
22
|
+
*
|
|
23
|
+
* `track(name, properties?, options?)` enqueues an event into a process-wide
|
|
24
|
+
* buffer that flushes to `POST /api/events/track`. See ./customEvents.ts.
|
|
25
|
+
*/
|
|
26
|
+
interface TrackOptions {
|
|
27
|
+
/** Override the auto-attached session_id (defaults to current rrweb session). */
|
|
28
|
+
sessionId?: string;
|
|
29
|
+
/** Override the auto-attached user_id (defaults to last `identify()` call). */
|
|
30
|
+
userId?: string;
|
|
31
|
+
/** Override the auto-attached page_url (defaults to window.location.href). */
|
|
32
|
+
pageUrl?: string;
|
|
33
|
+
/** Override the auto-attached occurred_at (defaults to now()). */
|
|
34
|
+
occurredAt?: Date | string;
|
|
35
|
+
}
|
|
36
|
+
type TrackProperties = Record<string, string | number | boolean | null>;
|
|
37
|
+
|
|
20
38
|
type BlocFeedApi = {
|
|
21
39
|
state: BlocFeedState;
|
|
22
40
|
controller: BlocFeedController;
|
|
@@ -30,6 +48,14 @@ type BlocFeedApi = {
|
|
|
30
48
|
startRecording: () => Promise<void>;
|
|
31
49
|
stopRecording: () => void;
|
|
32
50
|
removeVideo: () => void;
|
|
51
|
+
/**
|
|
52
|
+
* Send a custom event to BlocFeed for funnels, conversion tracking, and
|
|
53
|
+
* segment filters. Buffered + flushed periodically — non-blocking.
|
|
54
|
+
*
|
|
55
|
+
* `name` must match `/^[a-z][a-z0-9_]{0,127}$/`.
|
|
56
|
+
* `properties` is a flat object of string|number|boolean|null values.
|
|
57
|
+
*/
|
|
58
|
+
track: (name: string, properties?: TrackProperties, options?: TrackOptions) => void;
|
|
33
59
|
};
|
|
34
60
|
declare function useBlocFeed(): BlocFeedApi;
|
|
35
61
|
|
|
@@ -60,4 +86,37 @@ declare class BehavioralTracker {
|
|
|
60
86
|
uninstall(): void;
|
|
61
87
|
}
|
|
62
88
|
|
|
63
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Buffered custom-event tracker.
|
|
91
|
+
*
|
|
92
|
+
* Public API: `track(name, properties?, options?)`. Mirrors the offline-queue
|
|
93
|
+
* + flush patterns used by `runtime/replay/capture.ts` and the behavioral
|
|
94
|
+
* submitter — keepalive only on the pagehide beacon path, in-session flushes
|
|
95
|
+
* use plain fetch (lesson from v0.17.1).
|
|
96
|
+
*
|
|
97
|
+
* Singleton: one buffer per page load, lazily created on first track() call.
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
declare function track(name: string, properties?: TrackProperties, options?: TrackOptions): void;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Non-React entry point. Mirrors the shape of the rest of the SDK exports;
|
|
104
|
+
* use this from Vue, Svelte, or vanilla apps where there is no
|
|
105
|
+
* `useBlocFeed()` hook available.
|
|
106
|
+
*
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { BlocFeed } from "blocfeed";
|
|
109
|
+
* BlocFeed.identify("user_42");
|
|
110
|
+
* BlocFeed.track("checkout_completed", { plan: "team" });
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
declare const BlocFeed: {
|
|
114
|
+
/** Register the blocfeed_id (only needed on Vue / vanilla; React provider does this for you). */
|
|
115
|
+
init(blocfeedId: string): void;
|
|
116
|
+
/** Attach a user_id to subsequent track() calls. Pass `undefined` to clear. */
|
|
117
|
+
identify(userId: string | undefined): void;
|
|
118
|
+
/** Send a custom event. See `track()` for validation rules. */
|
|
119
|
+
track: typeof track;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export { BehavioralConfig, BehavioralEvent, BehavioralTracker, BlocFeed, type BlocFeedApi, BlocFeedConfig, BlocFeedHandle, BlocFeedProvider, BlocFeedState, BlocFeedWidget, CaptureConfig, FeedbackCategory, SubmitResult, type TrackOptions, type TrackProperties, track, useBlocFeed };
|
package/dist/main.d.ts
CHANGED
|
@@ -17,6 +17,24 @@ type BlocFeedWidgetProps = {
|
|
|
17
17
|
};
|
|
18
18
|
declare const BlocFeedWidget: react.ForwardRefExoticComponent<BlocFeedWidgetProps & react.RefAttributes<BlocFeedHandle>>;
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Public-API types for the `track()` custom-event surface.
|
|
22
|
+
*
|
|
23
|
+
* `track(name, properties?, options?)` enqueues an event into a process-wide
|
|
24
|
+
* buffer that flushes to `POST /api/events/track`. See ./customEvents.ts.
|
|
25
|
+
*/
|
|
26
|
+
interface TrackOptions {
|
|
27
|
+
/** Override the auto-attached session_id (defaults to current rrweb session). */
|
|
28
|
+
sessionId?: string;
|
|
29
|
+
/** Override the auto-attached user_id (defaults to last `identify()` call). */
|
|
30
|
+
userId?: string;
|
|
31
|
+
/** Override the auto-attached page_url (defaults to window.location.href). */
|
|
32
|
+
pageUrl?: string;
|
|
33
|
+
/** Override the auto-attached occurred_at (defaults to now()). */
|
|
34
|
+
occurredAt?: Date | string;
|
|
35
|
+
}
|
|
36
|
+
type TrackProperties = Record<string, string | number | boolean | null>;
|
|
37
|
+
|
|
20
38
|
type BlocFeedApi = {
|
|
21
39
|
state: BlocFeedState;
|
|
22
40
|
controller: BlocFeedController;
|
|
@@ -30,6 +48,14 @@ type BlocFeedApi = {
|
|
|
30
48
|
startRecording: () => Promise<void>;
|
|
31
49
|
stopRecording: () => void;
|
|
32
50
|
removeVideo: () => void;
|
|
51
|
+
/**
|
|
52
|
+
* Send a custom event to BlocFeed for funnels, conversion tracking, and
|
|
53
|
+
* segment filters. Buffered + flushed periodically — non-blocking.
|
|
54
|
+
*
|
|
55
|
+
* `name` must match `/^[a-z][a-z0-9_]{0,127}$/`.
|
|
56
|
+
* `properties` is a flat object of string|number|boolean|null values.
|
|
57
|
+
*/
|
|
58
|
+
track: (name: string, properties?: TrackProperties, options?: TrackOptions) => void;
|
|
33
59
|
};
|
|
34
60
|
declare function useBlocFeed(): BlocFeedApi;
|
|
35
61
|
|
|
@@ -60,4 +86,37 @@ declare class BehavioralTracker {
|
|
|
60
86
|
uninstall(): void;
|
|
61
87
|
}
|
|
62
88
|
|
|
63
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Buffered custom-event tracker.
|
|
91
|
+
*
|
|
92
|
+
* Public API: `track(name, properties?, options?)`. Mirrors the offline-queue
|
|
93
|
+
* + flush patterns used by `runtime/replay/capture.ts` and the behavioral
|
|
94
|
+
* submitter — keepalive only on the pagehide beacon path, in-session flushes
|
|
95
|
+
* use plain fetch (lesson from v0.17.1).
|
|
96
|
+
*
|
|
97
|
+
* Singleton: one buffer per page load, lazily created on first track() call.
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
declare function track(name: string, properties?: TrackProperties, options?: TrackOptions): void;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Non-React entry point. Mirrors the shape of the rest of the SDK exports;
|
|
104
|
+
* use this from Vue, Svelte, or vanilla apps where there is no
|
|
105
|
+
* `useBlocFeed()` hook available.
|
|
106
|
+
*
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { BlocFeed } from "blocfeed";
|
|
109
|
+
* BlocFeed.identify("user_42");
|
|
110
|
+
* BlocFeed.track("checkout_completed", { plan: "team" });
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
declare const BlocFeed: {
|
|
114
|
+
/** Register the blocfeed_id (only needed on Vue / vanilla; React provider does this for you). */
|
|
115
|
+
init(blocfeedId: string): void;
|
|
116
|
+
/** Attach a user_id to subsequent track() calls. Pass `undefined` to clear. */
|
|
117
|
+
identify(userId: string | undefined): void;
|
|
118
|
+
/** Send a custom event. See `track()` for validation rules. */
|
|
119
|
+
track: typeof track;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export { BehavioralConfig, BehavioralEvent, BehavioralTracker, BlocFeed, type BlocFeedApi, BlocFeedConfig, BlocFeedHandle, BlocFeedProvider, BlocFeedState, BlocFeedWidget, CaptureConfig, FeedbackCategory, SubmitResult, type TrackOptions, type TrackProperties, track, useBlocFeed };
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import {x,y as y$1,B,z,C,j as j$1,a,w,t,l,n,i,q,u,b,s}from'./chunk-GNKDVHVD.js';export{v as BehavioralTracker,u as track}from'./chunk-GNKDVHVD.js';import {createContext,forwardRef,useState,useEffect,useRef,useMemo,useImperativeHandle,useCallback,useContext}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {AnimatePresence,motion}from'framer-motion';var j=createContext(null);function ne(e){let t$1=useMemo(()=>w({...e.config??{},blocfeed_id:e.blocfeed_id}),[]);useEffect(()=>{t(e.blocfeed_id);},[e.blocfeed_id]);let[i,r]=useState(()=>t$1.getState());return useEffect(()=>t$1.subscribe(r),[t$1]),useEffect(()=>t$1.setConfig({...e.config??{},blocfeed_id:e.blocfeed_id}),[t$1,e.config,e.blocfeed_id]),useEffect(()=>()=>t$1.destroy(),[t$1]),jsx(j.Provider,{value:{controller:t$1,state:i},children:e.children})}var ze="blocfeed-styles-v1",Wt=`
|
|
3
3
|
:where([data-blocfeed-ui-root]),
|
|
4
4
|
:where([data-blocfeed-ui-root]) * {
|
|
5
5
|
box-sizing: border-box;
|
|
@@ -881,5 +881,5 @@ import {u,v,y as y$1,w,z,j,a,t,l,n,i,q,b}from'./chunk-CS63UWFR.js';export{s as B
|
|
|
881
881
|
animation: none;
|
|
882
882
|
}
|
|
883
883
|
}
|
|
884
|
-
`;function Me(){if(!a()||document.getElementById(Re))return;let t=document.createElement("style");t.id=Re,t.textContent=It,document.head.appendChild(t);}var Le={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 ze(t){return t?{...Le,...t}:Le}function ae(){let t=useContext(Y);if(!t)throw new Error("useBlocFeed must be used within a <BlocFeedProvider />");return {state:t.state,controller:t.controller,start:t.controller.start,stop:t.controller.stop,clearSelection:t.controller.clearSelection,submit:t.controller.submit,startRecording:t.controller.startRecording,stopRecording:t.controller.stopRecording,removeVideo:t.controller.removeVideo}}function y(t){switch(t){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 g({size:t=14}){return jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M20 6L9 17l-5-5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ie({size:t=14}){return jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 Ae({size:t=16}){return jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[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"}),jsx("path",{d:"M22 6l-10 7L2 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function _e({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){return i?jsxs("button",{className:y(t),type:"button",onClick:e,"aria-label":r,children:[p?jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})}):jsxs(Fragment,{children:[jsx("span",{className:"bf-dot","aria-hidden":"true"}),r]}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]}):null}function h(){let[t,e]=useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return useEffect(()=>{let i=window.matchMedia("(prefers-reduced-motion: reduce)"),r=a=>e(a.matches);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[]),t}var Vt={duration:.18,ease:"easeOut"},$t={duration:0};function Oe({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),o=h(),c=o?$t:Vt;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsx(motion.span,{className:"bf-dot","aria-hidden":"true",animate:o?{}:{scale:n?1:[1,1.2,1],boxShadow:n?"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:n||o?c:{duration:2,repeat:1/0,ease:"easeInOut"}}),jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"dot")})}var Yt={duration:.18,ease:"easeOut"},Ve={duration:0};function Ke({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),o=h(),c=o?Ve:Yt;return jsx(AnimatePresence,{mode:"wait",children:i&&jsxs(motion.div,{className:y(t),initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{y:8,opacity:0},transition:c,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),style:{background:"transparent",border:"none",boxShadow:"none",padding:0},children:[jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.div,{initial:{opacity:0,y:o?0:4},animate:{opacity:1,y:0},exit:{opacity:0,y:o?0:4},transition:c,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:r},"tooltip")}),jsxs(motion.button,{type:"button",onClick:e,"aria-label":r,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:o?{}:{y:[0,-3,0]},transition:o?Ve:{y:{duration:3,repeat:1/0,ease:"easeInOut"}},whileHover:{scale:1.1,borderColor:"var(--bf-accent)"},whileTap:{scale:.9},children:[p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:16})},"success"):jsx(Ie,{size:16}),a>0&&jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${a} queued`,children:a})]})]},"bubble")})}var Qt={duration:.2,ease:"easeOut"},qt={duration:0};function Xe(t){return t==="bottom-left"||t==="top-left"}function Jt(t){return `bf-trigger-edge ${Xe(t)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function Ye({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),o=Xe(t),c=h(),x=c?qt:Qt;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:Jt(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,width:0},animate:{opacity:1,width:n?140:22,height:n?40:90},exit:{width:0,opacity:0},transition:x,whileTap:{scale:.97},style:{top:"50%",translateY:"-50%"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:x,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsxs(motion.span,{animate:{rotate:c||n?0:o?-90:90,opacity:n?1:.6},transition:x,style:{display:"flex",alignItems:"center",gap:"8px",whiteSpace:"nowrap",fontSize:"12px",letterSpacing:"0.5px",textTransform:"uppercase"},children:[n&&jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:{duration:.12},style:{width:"6px",height:"6px",borderRadius:"50%",background:"var(--bf-accent)",flexShrink:0}}),r]}),jsx(motion.span,{"aria-hidden":"true",animate:{opacity:n?1:0},transition:{duration:.12},style:{position:"absolute",top:0,bottom:0,[o?"left":"right"]:0,width:"2px",background:"var(--bf-accent)"}}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"edge-tab")})}var to={duration:.18,ease:"easeOut"},oo={duration:0};function je({delay:t,hovered:e,reduced:i}){return i?null:jsx(motion.span,{"aria-hidden":"true",style:{position:"absolute",width:"10px",height:"10px",borderRadius:"50%",border:"2px solid var(--bf-accent)",pointerEvents:"none"},animate:e?{scale:1,opacity:0}:{scale:[1,1.8],opacity:[.5,0]},transition:e?{duration:.15}:{duration:2,repeat:1/0,delay:t,ease:"easeOut"}})}function qe({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),o=h(),c=o?oo:to;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsxs("span",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsx(je,{delay:0,hovered:n,reduced:o}),jsx(je,{delay:.7,hovered:n,reduced:o}),jsx(motion.span,{className:"bf-dot","aria-hidden":"true",style:{position:"relative",zIndex:1}})]}),jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"pulse-ring")})}var no={duration:.18,ease:"easeOut"},so={duration:0};function co(t){switch(t){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 et({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),o=h(),c=o?so:no;return jsx(AnimatePresence,{mode:"wait",children:i&&jsxs(motion.button,{className:co(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,y:o?0:5},animate:{opacity:n?1:.65,y:0},exit:{opacity:0,y:o?0:5},transition:c,whileTap:{scale:.95},children:[p?jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})}):jsxs(Fragment,{children:[jsx("span",{children:r}),a>0&&jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${a} queued`,children:a})]}),!o&&jsx(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:n?1:0},transition:c})]},"minimal")})}var po={duration:.18,ease:"easeOut"},uo={duration:0};function ot({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),o=h(),c=o?uo:po;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.9},style:{overflow:"hidden"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsx(motion.span,{style:{display:"inline-flex",flexShrink:0},animate:o?{}:n?{scale:1.2,rotate:0}:{rotate:[-5,5,-5]},transition:n||o?c:{duration:3,repeat:1/0,ease:"easeInOut"},children:jsx(Ae,{size:16})}),jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.span,{initial:{opacity:0,x:o?0:-8},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-8},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"icon-pop")})}var ho={duration:.18,ease:"easeOut"},xo={duration:0};function at({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),o=h(),c=o?xo:ho;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsxs("span",{style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsx(motion.span,{"aria-hidden":"true",style:{width:"10px",height:"10px",borderRadius:"50%",background:"var(--bf-accent)",position:"relative",zIndex:1},animate:o?{}:{opacity:n?1:[.5,1,.5],boxShadow:n?"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:n||o?c:{duration:2,repeat:1/0,ease:"easeInOut"}}),!n&&!o&&jsx(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"}})]}),jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"beacon")})}var To={duration:.18,ease:"easeOut"},Eo={duration:0};function lt({position:t,onClick:e,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),[o,c]=useState(0),x=h(),z=x?Eo:To,f=useRef(null);useEffect(()=>{if(f.current&&(clearInterval(f.current),f.current=null),!i||n||x){c(n||x?r.length:0);return}let b=8,T=r.length*2+b*2,m=0;return f.current=setInterval(()=>{m=(m+1)%T,m<=r.length?c(m):m<=r.length+b?c(r.length):m<=r.length*2+b?c(r.length*2+b-m):c(0);},100),()=>{f.current&&(clearInterval(f.current),f.current=null);}},[i,n,x,r]);let S=r.slice(0,o);return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:y(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,y:x?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:x?0:5},transition:z,whileTap:{scale:.95},style:{minWidth:"44px"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:z,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsx("span",{className:"bf-dot","aria-hidden":"true"}),jsxs("span",{style:{whiteSpace:"nowrap",minWidth:"1ch"},children:[S,jsx("span",{className:"bf-cursor","aria-hidden":"true"})]}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"typewriter")})}function dt(t){switch(t){case "dot":return Oe;case "bubble":return Ke;case "edge-tab":return Ye;case "pulse-ring":return qe;case "minimal":return et;case "icon-pop":return ot;case "beacon":return at;case "typewriter":return lt;default:return _e}}function ft(t,e,i){return Math.max(e,Math.min(i,t))}function No(t,e,i="bottom-right"){let a=window.innerWidth,p=window.innerHeight,n;n=ft(t.x,12,Math.max(12,a-e-12));let l=t.y+t.height+12,o=Math.max(12,t.y-240);return {top:l+240<=p?l:o,left:n}}function Fo(t){let{rect:e}=t,i={left:`${e.x}px`,top:`${e.y}px`,width:`${Math.max(0,e.width)}px`,height:`${Math.max(0,e.height)}px`};return jsx("div",{className:"bf-highlight",style:i,"aria-hidden":"true"})}function Ro(t){let e=useRef(null);return useEffect(()=>{if(!t||!e.current)return;let i=e.current,r=i.querySelector(".bf-textarea");r?.focus();let a=n=>{if(n.key!=="Tab")return;let l=i.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(l.length===0)return;let o=l[0],c=l[l.length-1];n.shiftKey&&document.activeElement===o?(n.preventDefault(),c.focus()):!n.shiftKey&&document.activeElement===c&&(n.preventDefault(),o.focus());},p=n=>{let l=n.target;l&&(i.contains(l)||(n.stopImmediatePropagation(),r?.focus()));};return document.addEventListener("keydown",a,{capture:true}),document.addEventListener("focusin",p,{capture:true}),()=>{document.removeEventListener("keydown",a,{capture:true}),document.removeEventListener("focusin",p,{capture:true});}},[t]),e}function Mo(t,e){return t?typeof t=="function"?t(e):t.some(i=>i.endsWith("*")?e.startsWith(i.slice(0,-1)):e===i):true}var ce=new Set,pt=false;function Lo(){if(pt||typeof window>"u")return;pt=true;let t=history.pushState,e=history.replaceState,i=()=>{for(let r of ce)r();};history.pushState=function(...r){t.apply(this,r),setTimeout(i,0);},history.replaceState=function(...r){e.apply(this,r),setTimeout(i,0);};}function zo(t){let[e,i]=useState(()=>typeof window<"u"?window.location.pathname:"/");return useEffect(()=>{if(typeof window>"u")return;let r=()=>i(window.location.pathname);return window.addEventListener("popstate",r),Lo(),ce.add(r),()=>{window.removeEventListener("popstate",r),ce.delete(r);}},[]),Mo(t,e)}function Io(t){let[e,i]=useState(()=>!t||t==="dark"?"dark":t==="light"?"light":typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return useEffect(()=>{if(t!=="auto"){i(t==="light"?"light":"dark");return}let r=window.matchMedia("(prefers-color-scheme: dark)"),a=p=>i(p.matches?"dark":"light");return i(r.matches?"dark":"light"),r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[t]),e}var Ao=["bug","feature","ux","general"],Wo={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function X(t){let e=Math.floor(t/1e3),i=Math.floor(e/60),r=e%60;return `${i}:${String(r).padStart(2,"0")}`}function _o(t){return t<1024*1024?`${Math.round(t/1024)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Ho(t){let{state:e,controller:i$1,start:r,stop:a,clearSelection:p,submit:n$1}=ae(),l$1=t.config.ui?.position,o=ze(t.config.ui?.strings),c=t.config.ui?.branding!==false,[x,z$1]=useState(null),[f,S]=useState(""),[b$1,T]=useState(t.config.capture?.element??true),[m,C]=useState(t.config.capture?.fullPage??false),[bt,de]=useState(null),[D,fe]=useState(void 0),pe=t.config.ui?.categories??Ao,gt=t.config.recording?.enabled===true&&l(),mt=t.config.recording?.maxDurationMs??3e4,ue=i$1.getConfig().voice,ht=ue?.enabled===true&&n(),xt=ue?.maxDurationMs??6e4,[vt,yt]=useState(false),[J,wt]=useState(0);useEffect(()=>{let s=window.setTimeout(()=>{let v=z();wt(v.findings.length);},500);return ()=>window.clearTimeout(s)},[]),useImperativeHandle(t.handleRef,()=>({open:r,close:a,submit:s=>n$1(s),startRecording:()=>i$1.startRecording(),stopRecording:()=>i$1.stopRecording(),get isOpen(){return e.phase!=="idle"}}),[r,a,n$1,i$1,e.phase]);let be=e.phase==="review"||e.phase==="capturing"||e.phase==="submitting"||e.phase==="error"||e.phase==="success",kt=Ro(be),[Tt,Et]=useState(0);useEffect(()=>{e.phase==="idle"&&Et(i());},[e.phase]);let[St,ge]=useState(false),me=useRef(e.phase);useEffect(()=>{if(me.current==="success"&&e.phase==="idle"){ge(true);let s=window.setTimeout(()=>ge(false),1500);return ()=>window.clearTimeout(s)}me.current=e.phase;},[e.phase]),useEffect(()=>{let s=t.config.ui?.shortcut;if(!s)return;let v=s.toLowerCase().split("+").map(N=>N.trim()),B=v[v.length-1]||"",I=new Set(v.slice(0,-1)),ve=N=>{let Nt=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(I.has("mod")){if(Nt?!N.metaKey:!N.ctrlKey)return}else if(I.has("ctrl")&&!N.ctrlKey||(I.has("meta")||I.has("cmd"))&&!N.metaKey)return;I.has("shift")&&!N.shiftKey||(I.has("alt")||I.has("option"))&&!N.altKey||N.key.toLowerCase()===B&&(N.preventDefault(),e.phase==="idle"?r():a());};return document.addEventListener("keydown",ve),()=>document.removeEventListener("keydown",ve)},[t.config.ui?.shortcut,e.phase,r,a]),useEffect(()=>i$1.subscribeHover(z$1),[i$1]),useEffect(()=>{let s=i$1.__unsafeGetSelectedElement();if(!s||e.phase==="idle"||e.phase==="picking"){de(null);return}let v=()=>{de(b(s.getBoundingClientRect()));};v();let B=()=>v();return window.addEventListener("scroll",B,{capture:true,passive:true}),window.addEventListener("resize",B,{passive:true}),()=>{window.removeEventListener("scroll",B,{capture:true}),window.removeEventListener("resize",B);}},[i$1,e.phase,e.selection?.selector]),useEffect(()=>{e.phase==="review"&&(S(""),T(t.config.capture?.element??true),C(t.config.capture?.fullPage??false),fe(void 0),V(null));},[e.phase,e.selection?.selector,t.config.capture?.element,t.config.capture?.fullPage]),useEffect(()=>{if(e.phase!=="success")return;let s=window.setTimeout(()=>a(),1200);return ()=>window.clearTimeout(s)},[e.phase,a]);let E=e.phase==="capturing"||e.phase==="submitting",M=e.phase==="picking"?x?.rect??null:bt??e.selection?.rect??null,Z=useMemo(()=>M?No(M,360,l$1):null,[M?.x,M?.y,M?.width,M?.height,l$1]),he=e.lastError?.message,ee=useCallback(()=>{let s={capture:{element:b$1,fullPage:m}};D&&(s.category=D),n$1(f,s);},[n$1,f,b$1,m,D]),Ct=useCallback(s=>{(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&f.trim().length>0&&!E&&(s.preventDefault(),ee());},[ee,f,E]),[xe,V]=useState(null),Pt=useCallback(async()=>{if(e.voiceRecording){i$1.stopVoice();return}V(null);let s=await i$1.startVoice();if(s?.text)S(v=>v?v+" "+s.text:s.text);else if(s?.warning)V(o.voiceEmptyText);else if(!s){let v=i$1.getState().lastError;if(v){let B=v.message?.toLowerCase()??"";B.includes("denied")||B.includes("permission")||B.includes("not allowed")?V(o.voiceDeniedText):V(o.voiceErrorText);}}},[e.voiceRecording,i$1,o]),Bt=dt(t.config.ui?.triggerStyle);return jsxs(Fragment,{children:[jsx(Bt,{position:l$1,onClick:()=>r(),isVisible:e.phase==="idle",label:t.config.ui?.triggerLabel??o.triggerLabel,queueCount:Tt,showSuccess:St}),e.phase!=="idle"&&e.phase!=="recording"&&jsxs("div",{className:"bf-overlay",role:"presentation",children:[e.phase!=="picking"&&jsx("div",{className:"bf-blocker",role:"presentation",onClick:()=>a()}),M&&jsx(Fo,{rect:M}),e.phase==="picking"&&jsxs("div",{className:"bf-hint",role:"status","aria-live":"polite",children:[jsx("p",{id:"bf-hint-text",children:o.hintText}),jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),"aria-label":o.cancelButton,children:o.cancelButton})]}),be&&Z&&jsxs("div",{ref:kt,className:"bf-panel",style:{left:Z.left,top:Z.top},role:"dialog","aria-modal":"true","aria-label":"Feedback form",children:[jsxs("div",{className:"bf-panelHeader",children:[jsx("div",{className:"bf-title",id:"bf-panel-title",children:o.panelTitle}),jsxs("div",{className:"bf-row",style:{justifyContent:"flex-end"},children:[jsx("button",{type:"button",className:"bf-btn",onClick:()=>p(),disabled:E,"aria-label":o.rePickButton,children:o.rePickButton}),jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),disabled:E,"aria-label":o.closeButton,children:o.closeButton})]})]}),jsxs("div",{className:"bf-panelBody",children:[jsx("textarea",{className:"bf-textarea",placeholder:o.textareaPlaceholder,value:f,onChange:s=>S(s.target.value),onKeyDown:Ct,disabled:E,"aria-label":o.panelTitle}),pe.length>0&&jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:pe.map(s=>jsx("button",{type:"button",className:`bf-pill${D===s?" bf-pill-active":""}`,onClick:()=>fe(D===s?void 0:s),disabled:E,children:o[Wo[s]]},s))}),jsxs("div",{className:"bf-row",role:"group","aria-label":o.screenshotElement,children:[jsxs("label",{children:[jsx("input",{type:"checkbox",checked:b$1,onChange:s=>T(s.target.checked),disabled:E}),o.screenshotElement]}),jsxs("label",{children:[jsx("input",{type:"checkbox",checked:m,onChange:s=>C(s.target.checked),disabled:E}),o.screenshotFullPage]})]}),ht&&e.phase==="review"&&!e.voiceTranscribing&&jsx("button",{type:"button",className:`bf-voice-btn${e.voiceRecording?" bf-voice-btn-active":""}`,onClick:Pt,disabled:E,"aria-label":e.voiceRecording?o.voiceStopButton:o.voiceButton,children:e.voiceRecording?jsxs(Fragment,{children:[jsx("span",{className:"bf-rec-dot bf-rec-dot-pulse","aria-hidden":"true"}),o.voiceRecordingText," ",X(e.voiceElapsedMs??0)," / ",X(xt)," \u2014 ",o.voiceStopButton]}):jsxs(Fragment,{children:[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:[jsx("rect",{x:"9",y:"1",width:"6",height:"11",rx:"3"}),jsx("path",{d:"M19 10v1a7 7 0 0 1-14 0v-1"}),jsx("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),jsx("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]}),o.voiceButton]})}),e.voiceTranscribing&&jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.voiceTranscribingText]}),xe&&!e.voiceRecording&&!e.voiceTranscribing&&jsx("div",{className:"bf-error",role:"alert",children:xe}),gt&&e.phase==="review"&&!e.video&&jsxs("button",{type:"button",className:"bf-record-btn",onClick:()=>i$1.startRecording(),disabled:E,"aria-label":o.recordButton,children:[jsx("span",{className:"bf-rec-dot","aria-hidden":"true"}),o.recordButton]}),e.video&&e.phase==="review"&&jsxs("div",{className:"bf-video-preview",children:[jsx("video",{src:e.video.blobUrl,controls:true,muted:true,playsInline:true}),jsx("button",{type:"button",className:"bf-video-remove",onClick:()=>i$1.removeVideo(),"aria-label":o.removeVideoButton,children:"\xD7"}),jsxs("div",{className:"bf-video-meta",children:[o.videoPreviewLabel," (",X(e.video.durationMs),", ",_o(e.video.sizeBytes),")"]})]}),e.phase==="capturing"&&jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.capturingText]}),e.phase==="submitting"&&jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.submittingText]}),e.phase==="success"&&jsx("div",{className:"bf-status",role:"status","aria-live":"polite",children:o.successText}),e.phase==="error"&&he&&jsx("div",{className:"bf-error",role:"alert",children:he}),jsxs("div",{className:"bf-actions",children:[jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),disabled:E,"aria-label":o.cancelButton,children:o.cancelButton}),jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:ee,disabled:E||f.trim().length===0,"aria-label":o.sendButton,children:o.sendButton})]})]}),c&&jsxs("div",{className:"bf-watermark",children:[(()=>{let s=q();return s?jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"bf-my-feedback-link",children:"View my feedback"}):null})(),jsx("a",{href:"https://blocfeed.com",target:"_blank",rel:"noopener noreferrer",children:"Powered by BlocFeed"})]})]})]}),e.phase==="recording"&&jsxs("div",{className:`bf-recording-bar bf-pos-${l$1}`,role:"status","aria-live":"polite","data-blocfeed-ui":"true",children:[jsx("span",{className:"bf-rec-dot bf-rec-dot-pulse","aria-hidden":"true"}),jsxs("span",{className:"bf-recording-bar-timer",children:[o.recordingText," ",X(e.recordingElapsedMs??0)," / ",X(mt)]}),jsx("button",{type:"button",className:"bf-recording-bar-stop",onClick:()=>i$1.stopRecording(),"aria-label":o.stopRecordButton,children:o.stopRecordButton})]}),e.phase==="success"&&jsxs("div",{className:"bf-toast",role:"status","aria-live":"polite",children:[o.toastText,(()=>{let s=q();return s?jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"bf-toast-link",children:"View my feedback"}):null})()]}),J>0&&!vt&&jsxs("div",{className:"bf-security-banner",role:"alert",children:[jsx("button",{type:"button",className:"bf-security-banner-dismiss",onClick:()=>yt(true),"aria-label":"Dismiss",children:"\xD7"}),jsx("strong",{children:"Security Warning"}),J," potential secret",J>1?"s":""," exposed in client code. Check your environment variables."]})]})}var Oo=forwardRef(function(e,i){let r={...e.config??{},blocfeed_id:e.blocfeed_id},[a,p]=useState(null),n=zo(r.ui?.showOn),l=Io(r.ui?.theme?.mode),o=!!r.diagnostics;useEffect(()=>{if(o)return u(r.diagnostics),()=>v()},[o]);let c=!!r.security;useEffect(()=>{c&&y$1(r.security);},[c]);let x=useRef(e.config?.metadata?.enrich);x.current=e.config?.metadata?.enrich;let z$1=useMemo(()=>{if(e.config)return {...e.config,metadata:{...e.config.metadata,enrich:async f=>{let S=x.current,b=S?await S(f):{},T=w(),m=z(),C=j();return {...b,...T.consoleLogs.length>0?{_consoleLogs:T.consoleLogs}:{},...T.networkErrors.length>0?{_networkErrors:T.networkErrors}:{},...m.findings.length>0?{_securityFindings:m.findings}:{},...C.length>0?{_clickEvents:C}:{}}}}}},[]);return useEffect(()=>{Me();let f=document.createElement("div");f.setAttribute("data-blocfeed-ui-root","true"),f.setAttribute("data-blocfeed-ui","true"),f.setAttribute("data-bf-theme",l);let S=r.ui?.zIndex;typeof S=="number"&&f.style.setProperty("--bf-z",String(S));let b=r.ui?.theme;b&&(b.accentColor&&f.style.setProperty("--bf-accent",b.accentColor),b.panelBackground&&f.style.setProperty("--bf-panel-bg",b.panelBackground),b.panelForeground&&f.style.setProperty("--bf-panel-fg",b.panelForeground),b.fontFamily&&f.style.setProperty("--bf-font",b.fontFamily));let T=C=>C.stopPropagation(),m=["pointerdown","pointerup","mousedown","mouseup","click","touchstart","touchend"];for(let C of m)f.addEventListener(C,T);try{document.body.appendChild(f);}catch{return}return p(f),()=>{for(let C of m)f.removeEventListener(C,T);f.remove(),p(null);}},[r.ui?.zIndex,r.ui?.theme?.accentColor,r.ui?.theme?.panelBackground,r.ui?.theme?.panelForeground,r.ui?.theme?.fontFamily,l]),!n||!a?null:createPortal(jsx(ie,{blocfeed_id:r.blocfeed_id,...z$1?{config:z$1}:{},children:jsx(Ho,{config:r,handleRef:i})}),a)});
|
|
885
|
-
export{
|
|
884
|
+
`;function Ie(){if(!a()||document.getElementById(ze))return;let e=document.createElement("style");e.id=ze,e.textContent=Wt,document.head.appendChild(e);}var Ae={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 _e(e){return e?{...Ae,...e}:Ae}function se(){let e=useContext(j);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:u}}function y(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 g({size:e=14}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M20 6L9 17l-5-5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function We({size:e=14}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children: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 Oe({size:e=16}){return jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[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"}),jsx("path",{d:"M22 6l-10 7L2 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function De({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){return i?jsxs("button",{className:y(e),type:"button",onClick:t,"aria-label":r,children:[p?jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})}):jsxs(Fragment,{children:[jsx("span",{className:"bf-dot","aria-hidden":"true"}),r]}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]}):null}function h(){let[e,t]=useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return useEffect(()=>{let i=window.matchMedia("(prefers-reduced-motion: reduce)"),r=a=>t(a.matches);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[]),e}var Ut={duration:.18,ease:"easeOut"},Xt={duration:0};function $e({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),o=h(),c=o?Xt:Ut;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsx(motion.span,{className:"bf-dot","aria-hidden":"true",animate:o?{}:{scale:n?1:[1,1.2,1],boxShadow:n?"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:n||o?c:{duration:2,repeat:1/0,ease:"easeInOut"}}),jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"dot")})}var Qt={duration:.18,ease:"easeOut"},Ue={duration:0};function Ye({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),o=h(),c=o?Ue:Qt;return jsx(AnimatePresence,{mode:"wait",children:i&&jsxs(motion.div,{className:y(e),initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{y:8,opacity:0},transition:c,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),style:{background:"transparent",border:"none",boxShadow:"none",padding:0},children:[jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.div,{initial:{opacity:0,y:o?0:4},animate:{opacity:1,y:0},exit:{opacity:0,y:o?0:4},transition:c,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:r},"tooltip")}),jsxs(motion.button,{type:"button",onClick:t,"aria-label":r,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:o?{}:{y:[0,-3,0]},transition:o?Ue:{y:{duration:3,repeat:1/0,ease:"easeInOut"}},whileHover:{scale:1.1,borderColor:"var(--bf-accent)"},whileTap:{scale:.9},children:[p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:16})},"success"):jsx(We,{size:16}),a>0&&jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${a} queued`,children:a})]})]},"bubble")})}var Zt={duration:.2,ease:"easeOut"},eo={duration:0};function je(e){return e==="bottom-left"||e==="top-left"}function to(e){return `bf-trigger-edge ${je(e)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function Qe({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),o=je(e),c=h(),x=c?eo:Zt;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:to(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,width:0},animate:{opacity:1,width:n?140:22,height:n?40:90},exit:{width:0,opacity:0},transition:x,whileTap:{scale:.97},style:{top:"50%",translateY:"-50%"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:x,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsxs(motion.span,{animate:{rotate:c||n?0:o?-90:90,opacity:n?1:.6},transition:x,style:{display:"flex",alignItems:"center",gap:"8px",whiteSpace:"nowrap",fontSize:"12px",letterSpacing:"0.5px",textTransform:"uppercase"},children:[n&&jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:{duration:.12},style:{width:"6px",height:"6px",borderRadius:"50%",background:"var(--bf-accent)",flexShrink:0}}),r]}),jsx(motion.span,{"aria-hidden":"true",animate:{opacity:n?1:0},transition:{duration:.12},style:{position:"absolute",top:0,bottom:0,[o?"left":"right"]:0,width:"2px",background:"var(--bf-accent)"}}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"edge-tab")})}var io={duration:.18,ease:"easeOut"},ao={duration:0};function Je({delay:e,hovered:t,reduced:i}){return i?null:jsx(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 et({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),o=h(),c=o?ao:io;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsxs("span",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsx(Je,{delay:0,hovered:n,reduced:o}),jsx(Je,{delay:.7,hovered:n,reduced:o}),jsx(motion.span,{className:"bf-dot","aria-hidden":"true",style:{position:"relative",zIndex:1}})]}),jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"pulse-ring")})}var lo={duration:.18,ease:"easeOut"},fo={duration:0};function po(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 rt({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),o=h(),c=o?fo:lo;return jsx(AnimatePresence,{mode:"wait",children:i&&jsxs(motion.button,{className:po(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,y:o?0:5},animate:{opacity:n?1:.65,y:0},exit:{opacity:0,y:o?0:5},transition:c,whileTap:{scale:.95},children:[p?jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})}):jsxs(Fragment,{children:[jsx("span",{children:r}),a>0&&jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${a} queued`,children:a})]}),!o&&jsx(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:n?1:0},transition:c})]},"minimal")})}var go={duration:.18,ease:"easeOut"},mo={duration:0};function at({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),o=h(),c=o?mo:go;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.9},style:{overflow:"hidden"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsx(motion.span,{style:{display:"inline-flex",flexShrink:0},animate:o?{}:n?{scale:1.2,rotate:0}:{rotate:[-5,5,-5]},transition:n||o?c:{duration:3,repeat:1/0,ease:"easeInOut"},children:jsx(Oe,{size:16})}),jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.span,{initial:{opacity:0,x:o?0:-8},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-8},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"icon-pop")})}var yo={duration:.18,ease:"easeOut"},wo={duration:0};function ct({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),o=h(),c=o?wo:yo;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:c,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:c,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsxs("span",{style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsx(motion.span,{"aria-hidden":"true",style:{width:"10px",height:"10px",borderRadius:"50%",background:"var(--bf-accent)",position:"relative",zIndex:1},animate:o?{}:{opacity:n?1:[.5,1,.5],boxShadow:n?"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:n||o?c:{duration:2,repeat:1/0,ease:"easeInOut"}}),!n&&!o&&jsx(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"}})]}),jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.span,{initial:{opacity:0,x:o?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:o?0:-6},transition:c,style:{whiteSpace:"nowrap"},children:r},"label")}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"beacon")})}var Bo={duration:.18,ease:"easeOut"},Po={duration:0};function pt({position:e,onClick:t,isVisible:i,label:r,queueCount:a,showSuccess:p}){let[n,l]=useState(false),[o,c]=useState(0),x=h(),z=x?Po:Bo,f=useRef(null);useEffect(()=>{if(f.current&&(clearInterval(f.current),f.current=null),!i||n||x){c(n||x?r.length:0);return}let b=8,T=r.length*2+b*2,m=0;return f.current=setInterval(()=>{m=(m+1)%T,m<=r.length?c(m):m<=r.length+b?c(r.length):m<=r.length*2+b?c(r.length*2+b-m):c(0);},100),()=>{f.current&&(clearInterval(f.current),f.current=null);}},[i,n,x,r]);let S=r.slice(0,o);return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,y:x?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:x?0:5},transition:z,whileTap:{scale:.95},style:{minWidth:"44px"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:z,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsx("span",{className:"bf-dot","aria-hidden":"true"}),jsxs("span",{style:{whiteSpace:"nowrap",minWidth:"1ch"},children:[S,jsx("span",{className:"bf-cursor","aria-hidden":"true"})]}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"typewriter")})}function ut(e){switch(e){case "dot":return $e;case "bubble":return Ye;case "edge-tab":return Qe;case "pulse-ring":return et;case "minimal":return rt;case "icon-pop":return at;case "beacon":return ct;case "typewriter":return pt;default:return De}}function bt(e,t,i){return Math.max(t,Math.min(i,e))}function Mo(e,t,i="bottom-right"){let a=window.innerWidth,p=window.innerHeight,n;n=bt(e.x,12,Math.max(12,a-t-12));let l=e.y+e.height+12,o=Math.max(12,e.y-240);return {top:l+240<=p?l:o,left:n}}function Lo(e){let{rect:t}=e,i={left:`${t.x}px`,top:`${t.y}px`,width:`${Math.max(0,t.width)}px`,height:`${Math.max(0,t.height)}px`};return jsx("div",{className:"bf-highlight",style:i,"aria-hidden":"true"})}function zo(e){let t=useRef(null);return useEffect(()=>{if(!e||!t.current)return;let i=t.current,r=i.querySelector(".bf-textarea");r?.focus();let a=n=>{if(n.key!=="Tab")return;let l=i.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(l.length===0)return;let o=l[0],c=l[l.length-1];n.shiftKey&&document.activeElement===o?(n.preventDefault(),c.focus()):!n.shiftKey&&document.activeElement===c&&(n.preventDefault(),o.focus());},p=n=>{let l=n.target;l&&(i.contains(l)||(n.stopImmediatePropagation(),r?.focus()));};return document.addEventListener("keydown",a,{capture:true}),document.addEventListener("focusin",p,{capture:true}),()=>{document.removeEventListener("keydown",a,{capture:true}),document.removeEventListener("focusin",p,{capture:true});}},[e]),t}function Io(e,t){return e?typeof e=="function"?e(t):e.some(i=>i.endsWith("*")?t.startsWith(i.slice(0,-1)):t===i):true}var de=new Set,gt=false;function Ao(){if(gt||typeof window>"u")return;gt=true;let e=history.pushState,t=history.replaceState,i=()=>{for(let r of de)r();};history.pushState=function(...r){e.apply(this,r),setTimeout(i,0);},history.replaceState=function(...r){t.apply(this,r),setTimeout(i,0);};}function _o(e){let[t,i]=useState(()=>typeof window<"u"?window.location.pathname:"/");return useEffect(()=>{if(typeof window>"u")return;let r=()=>i(window.location.pathname);return window.addEventListener("popstate",r),Ao(),de.add(r),()=>{window.removeEventListener("popstate",r),de.delete(r);}},[]),Io(e,t)}function Wo(e){let[t,i]=useState(()=>!e||e==="dark"?"dark":e==="light"?"light":typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return useEffect(()=>{if(e!=="auto"){i(e==="light"?"light":"dark");return}let r=window.matchMedia("(prefers-color-scheme: dark)"),a=p=>i(p.matches?"dark":"light");return i(r.matches?"dark":"light"),r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[e]),t}var Oo=["bug","feature","ux","general"],Ho={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function Y(e){let t=Math.floor(e/1e3),i=Math.floor(t/60),r=t%60;return `${i}:${String(r).padStart(2,"0")}`}function Do(e){return e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Vo(e){let{state:t,controller:i$1,start:r,stop:a,clearSelection:p,submit:n$1}=se(),l$1=e.config.ui?.position,o=_e(e.config.ui?.strings),c=e.config.ui?.branding!==false,[x,z]=useState(null),[f,S]=useState(""),[b$1,T]=useState(e.config.capture?.element??true),[m,B]=useState(e.config.capture?.fullPage??false),[ht,pe]=useState(null),[D,ue]=useState(void 0),be=e.config.ui?.categories??Oo,xt=e.config.recording?.enabled===true&&l(),vt=e.config.recording?.maxDurationMs??3e4,ge=i$1.getConfig().voice,yt=ge?.enabled===true&&n(),wt=ge?.maxDurationMs??6e4,[kt,Tt]=useState(false),[te,Et]=useState(0);useEffect(()=>{let s=window.setTimeout(()=>{let v=C();Et(v.findings.length);},500);return ()=>window.clearTimeout(s)},[]),useImperativeHandle(e.handleRef,()=>({open:r,close:a,submit:s=>n$1(s),startRecording:()=>i$1.startRecording(),stopRecording:()=>i$1.stopRecording(),get isOpen(){return t.phase!=="idle"}}),[r,a,n$1,i$1,t.phase]);let me=t.phase==="review"||t.phase==="capturing"||t.phase==="submitting"||t.phase==="error"||t.phase==="success",St=zo(me),[Bt,Pt]=useState(0);useEffect(()=>{t.phase==="idle"&&Pt(i());},[t.phase]);let[Ct,he]=useState(false),xe=useRef(t.phase);useEffect(()=>{if(xe.current==="success"&&t.phase==="idle"){he(true);let s=window.setTimeout(()=>he(false),1500);return ()=>window.clearTimeout(s)}xe.current=t.phase;},[t.phase]),useEffect(()=>{let s=e.config.ui?.shortcut;if(!s)return;let v=s.toLowerCase().split("+").map(N=>N.trim()),C=v[v.length-1]||"",I=new Set(v.slice(0,-1)),we=N=>{let Mt=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(I.has("mod")){if(Mt?!N.metaKey:!N.ctrlKey)return}else if(I.has("ctrl")&&!N.ctrlKey||(I.has("meta")||I.has("cmd"))&&!N.metaKey)return;I.has("shift")&&!N.shiftKey||(I.has("alt")||I.has("option"))&&!N.altKey||N.key.toLowerCase()===C&&(N.preventDefault(),t.phase==="idle"?r():a());};return document.addEventListener("keydown",we),()=>document.removeEventListener("keydown",we)},[e.config.ui?.shortcut,t.phase,r,a]),useEffect(()=>i$1.subscribeHover(z),[i$1]),useEffect(()=>{let s=i$1.__unsafeGetSelectedElement();if(!s||t.phase==="idle"||t.phase==="picking"){pe(null);return}let v=()=>{pe(b(s.getBoundingClientRect()));};v();let C=()=>v();return window.addEventListener("scroll",C,{capture:true,passive:true}),window.addEventListener("resize",C,{passive:true}),()=>{window.removeEventListener("scroll",C,{capture:true}),window.removeEventListener("resize",C);}},[i$1,t.phase,t.selection?.selector]),useEffect(()=>{t.phase==="review"&&(S(""),T(e.config.capture?.element??true),B(e.config.capture?.fullPage??false),ue(void 0),V(null));},[t.phase,t.selection?.selector,e.config.capture?.element,e.config.capture?.fullPage]),useEffect(()=>{if(t.phase!=="success")return;let s=window.setTimeout(()=>a(),1200);return ()=>window.clearTimeout(s)},[t.phase,a]);let E=t.phase==="capturing"||t.phase==="submitting",M=t.phase==="picking"?x?.rect??null:ht??t.selection?.rect??null,oe=useMemo(()=>M?Mo(M,360,l$1):null,[M?.x,M?.y,M?.width,M?.height,l$1]),ve=t.lastError?.message,re=useCallback(()=>{let s={capture:{element:b$1,fullPage:m}};D&&(s.category=D),n$1(f,s);},[n$1,f,b$1,m,D]),Nt=useCallback(s=>{(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&f.trim().length>0&&!E&&(s.preventDefault(),re());},[re,f,E]),[ye,V]=useState(null),Ft=useCallback(async()=>{if(t.voiceRecording){i$1.stopVoice();return}V(null);let s=await i$1.startVoice();if(s?.text)S(v=>v?v+" "+s.text:s.text);else if(s?.warning)V(o.voiceEmptyText);else if(!s){let v=i$1.getState().lastError;if(v){let C=v.message?.toLowerCase()??"";C.includes("denied")||C.includes("permission")||C.includes("not allowed")?V(o.voiceDeniedText):V(o.voiceErrorText);}}},[t.voiceRecording,i$1,o]),Rt=ut(e.config.ui?.triggerStyle);return jsxs(Fragment,{children:[jsx(Rt,{position:l$1,onClick:()=>r(),isVisible:t.phase==="idle",label:e.config.ui?.triggerLabel??o.triggerLabel,queueCount:Bt,showSuccess:Ct}),t.phase!=="idle"&&t.phase!=="recording"&&jsxs("div",{className:"bf-overlay",role:"presentation",children:[t.phase!=="picking"&&jsx("div",{className:"bf-blocker",role:"presentation",onClick:()=>a()}),M&&jsx(Lo,{rect:M}),t.phase==="picking"&&jsxs("div",{className:"bf-hint",role:"status","aria-live":"polite",children:[jsx("p",{id:"bf-hint-text",children:o.hintText}),jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),"aria-label":o.cancelButton,children:o.cancelButton})]}),me&&oe&&jsxs("div",{ref:St,className:"bf-panel",style:{left:oe.left,top:oe.top},role:"dialog","aria-modal":"true","aria-label":"Feedback form",children:[jsxs("div",{className:"bf-panelHeader",children:[jsx("div",{className:"bf-title",id:"bf-panel-title",children:o.panelTitle}),jsxs("div",{className:"bf-row",style:{justifyContent:"flex-end"},children:[jsx("button",{type:"button",className:"bf-btn",onClick:()=>p(),disabled:E,"aria-label":o.rePickButton,children:o.rePickButton}),jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),disabled:E,"aria-label":o.closeButton,children:o.closeButton})]})]}),jsxs("div",{className:"bf-panelBody",children:[jsx("textarea",{className:"bf-textarea",placeholder:o.textareaPlaceholder,value:f,onChange:s=>S(s.target.value),onKeyDown:Nt,disabled:E,"aria-label":o.panelTitle}),be.length>0&&jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:be.map(s=>jsx("button",{type:"button",className:`bf-pill${D===s?" bf-pill-active":""}`,onClick:()=>ue(D===s?void 0:s),disabled:E,children:o[Ho[s]]},s))}),jsxs("div",{className:"bf-row",role:"group","aria-label":o.screenshotElement,children:[jsxs("label",{children:[jsx("input",{type:"checkbox",checked:b$1,onChange:s=>T(s.target.checked),disabled:E}),o.screenshotElement]}),jsxs("label",{children:[jsx("input",{type:"checkbox",checked:m,onChange:s=>B(s.target.checked),disabled:E}),o.screenshotFullPage]})]}),yt&&t.phase==="review"&&!t.voiceTranscribing&&jsx("button",{type:"button",className:`bf-voice-btn${t.voiceRecording?" bf-voice-btn-active":""}`,onClick:Ft,disabled:E,"aria-label":t.voiceRecording?o.voiceStopButton:o.voiceButton,children:t.voiceRecording?jsxs(Fragment,{children:[jsx("span",{className:"bf-rec-dot bf-rec-dot-pulse","aria-hidden":"true"}),o.voiceRecordingText," ",Y(t.voiceElapsedMs??0)," / ",Y(wt)," \u2014 ",o.voiceStopButton]}):jsxs(Fragment,{children:[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:[jsx("rect",{x:"9",y:"1",width:"6",height:"11",rx:"3"}),jsx("path",{d:"M19 10v1a7 7 0 0 1-14 0v-1"}),jsx("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),jsx("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]}),o.voiceButton]})}),t.voiceTranscribing&&jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.voiceTranscribingText]}),ye&&!t.voiceRecording&&!t.voiceTranscribing&&jsx("div",{className:"bf-error",role:"alert",children:ye}),xt&&t.phase==="review"&&!t.video&&jsxs("button",{type:"button",className:"bf-record-btn",onClick:()=>i$1.startRecording(),disabled:E,"aria-label":o.recordButton,children:[jsx("span",{className:"bf-rec-dot","aria-hidden":"true"}),o.recordButton]}),t.video&&t.phase==="review"&&jsxs("div",{className:"bf-video-preview",children:[jsx("video",{src:t.video.blobUrl,controls:true,muted:true,playsInline:true}),jsx("button",{type:"button",className:"bf-video-remove",onClick:()=>i$1.removeVideo(),"aria-label":o.removeVideoButton,children:"\xD7"}),jsxs("div",{className:"bf-video-meta",children:[o.videoPreviewLabel," (",Y(t.video.durationMs),", ",Do(t.video.sizeBytes),")"]})]}),t.phase==="capturing"&&jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.capturingText]}),t.phase==="submitting"&&jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsx("span",{className:"bf-spinner","aria-hidden":"true"}),o.submittingText]}),t.phase==="success"&&jsx("div",{className:"bf-status",role:"status","aria-live":"polite",children:o.successText}),t.phase==="error"&&ve&&jsx("div",{className:"bf-error",role:"alert",children:ve}),jsxs("div",{className:"bf-actions",children:[jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),disabled:E,"aria-label":o.cancelButton,children:o.cancelButton}),jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:re,disabled:E||f.trim().length===0,"aria-label":o.sendButton,children:o.sendButton})]})]}),c&&jsxs("div",{className:"bf-watermark",children:[(()=>{let s=q();return s?jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"bf-my-feedback-link",children:"View my feedback"}):null})(),jsx("a",{href:"https://blocfeed.com",target:"_blank",rel:"noopener noreferrer",children:"Powered by BlocFeed"})]})]})]}),t.phase==="recording"&&jsxs("div",{className:`bf-recording-bar bf-pos-${l$1}`,role:"status","aria-live":"polite","data-blocfeed-ui":"true",children:[jsx("span",{className:"bf-rec-dot bf-rec-dot-pulse","aria-hidden":"true"}),jsxs("span",{className:"bf-recording-bar-timer",children:[o.recordingText," ",Y(t.recordingElapsedMs??0)," / ",Y(vt)]}),jsx("button",{type:"button",className:"bf-recording-bar-stop",onClick:()=>i$1.stopRecording(),"aria-label":o.stopRecordButton,children:o.stopRecordButton})]}),t.phase==="success"&&jsxs("div",{className:"bf-toast",role:"status","aria-live":"polite",children:[o.toastText,(()=>{let s=q();return s?jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"bf-toast-link",children:"View my feedback"}):null})()]}),te>0&&!kt&&jsxs("div",{className:"bf-security-banner",role:"alert",children:[jsx("button",{type:"button",className:"bf-security-banner-dismiss",onClick:()=>Tt(true),"aria-label":"Dismiss",children:"\xD7"}),jsx("strong",{children:"Security Warning"}),te," potential secret",te>1?"s":""," exposed in client code. Check your environment variables."]})]})}var $o=forwardRef(function(t,i){let r={...t.config??{},blocfeed_id:t.blocfeed_id},[a,p]=useState(null),n=_o(r.ui?.showOn),l=Wo(r.ui?.theme?.mode),o=!!r.diagnostics;useEffect(()=>{if(o)return x(r.diagnostics),()=>y$1()},[o]);let c=!!r.security;useEffect(()=>{c&&B(r.security);},[c]);let x$1=useRef(t.config?.metadata?.enrich);x$1.current=t.config?.metadata?.enrich;let z$1=useMemo(()=>{if(t.config)return {...t.config,metadata:{...t.config.metadata,enrich:async f=>{let S=x$1.current,b=S?await S(f):{},T=z(),m=C(),B=j$1();return {...b,...T.consoleLogs.length>0?{_consoleLogs:T.consoleLogs}:{},...T.networkErrors.length>0?{_networkErrors:T.networkErrors}:{},...m.findings.length>0?{_securityFindings:m.findings}:{},...B.length>0?{_clickEvents:B}:{}}}}}},[]);return useEffect(()=>{Ie();let f=document.createElement("div");f.setAttribute("data-blocfeed-ui-root","true"),f.setAttribute("data-blocfeed-ui","true"),f.setAttribute("data-bf-theme",l);let S=r.ui?.zIndex;typeof S=="number"&&f.style.setProperty("--bf-z",String(S));let b=r.ui?.theme;b&&(b.accentColor&&f.style.setProperty("--bf-accent",b.accentColor),b.panelBackground&&f.style.setProperty("--bf-panel-bg",b.panelBackground),b.panelForeground&&f.style.setProperty("--bf-panel-fg",b.panelForeground),b.fontFamily&&f.style.setProperty("--bf-font",b.fontFamily));let T=B=>B.stopPropagation(),m=["pointerdown","pointerup","mousedown","mouseup","click","touchstart","touchend"];for(let B of m)f.addEventListener(B,T);try{document.body.appendChild(f);}catch{return}return p(f),()=>{for(let B of m)f.removeEventListener(B,T);f.remove(),p(null);}},[r.ui?.zIndex,r.ui?.theme?.accentColor,r.ui?.theme?.panelBackground,r.ui?.theme?.panelForeground,r.ui?.theme?.fontFamily,l]),!n||!a?null:createPortal(jsx(ne,{blocfeed_id:r.blocfeed_id,...z$1?{config:z$1}:{},children:jsx(Vo,{config:r,handleRef:i})}),a)});var Di={init(e){t(e);},identify(e){s(e);},track:u};
|
|
885
|
+
export{Di as BlocFeed,ne as BlocFeedProvider,$o as BlocFeedWidget,se as useBlocFeed};
|
package/package.json
CHANGED
package/dist/chunk-4VWH5ZG6.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var rrweb=require('rrweb');function S(){return typeof window<"u"&&typeof document<"u"}function He(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 we(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Ot(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function Ut(e){return e.replace(/\s+/g," ").trim()}function N(e,t=140){let n=e.textContent;if(!n)return;let o=Ut(n);if(o)return o.length<=t?o:`${o.slice(0,t-1)}\u2026`}function Ht(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var ze=["data-testid","data-test-id","data-test","data-qa","data-cy"],qe="data-blocfeed-component";function q(e){let t=e.closest(`[${qe}]`);if(!t)return;let o=t.getAttribute(qe)?.trim();return o||void 0}function K(e,t=5){let n=[],o=e,r=0;for(;o&&r<t*4;){let i=q(o);if(i&&n[n.length-1]!==i&&(n.push(i),n.length>=t))break;o=o.parentElement,r++;}return n}function qt(e){for(let t of ze){let n=e.closest(`[${t}]`);if(!n)continue;let r=n.getAttribute(t)?.trim();if(r)return r}}function Ve(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 $(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 J(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!$(t.name))return t.name}}function F(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 F(r)}}}function ve(e){let t=Ve(e);if(!t)return;let n=J(t._debugInfo);if(n)return n;let o=t._debugOwner!==void 0;if(o){let a=t._debugOwner;for(let c=0;a&&c<50;c+=1){let u=J(a._debugInfo);if(u)return u;let d=F(a.type)??F(a.elementType);if(d&&!$(d))return d;a=a._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let a=t._owner;for(let c=0;a&&c<50;c+=1){let u=J(a._debugInfo);if(u)return u;let d=F(a.type)??F(a.elementType);if(d&&!$(d))return d;a=a._owner;}}let i=t,l=o?80:25;for(let a=0;i&&a<l;a+=1){let c=J(i._debugInfo);if(c)return c;let u=F(i.type)??F(i.elementType);if(u&&!$(u))return u;i=i.return;}let s=e.parentElement;for(let a=0;s&&a<15;a+=1){let c=Ve(s);if(c){let u=J(c._debugInfo);if(u)return u;let d=F(c.type)??F(c.elementType);if(d&&!$(d))return d;if(c._debugOwner){let p=F(c._debugOwner.type)??F(c._debugOwner.elementType);if(p&&!$(p))return p}if(c._owner&&c._owner!==c._debugOwner){let p=F(c._owner.type)??F(c._owner.elementType);if(p&&!$(p))return p}}s=s.parentElement;}}function Vt(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${He(n)}`;for(let o of ze){let r=e.getAttribute(o);if(r)return `${t}[${o}="${He(r)}"]`}return `${t}:nth-of-type(${Ht(e)})`}function W(e,t=10){let n=[],o=e;for(;o&&n.length<t;){let r=Vt(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}var Xt=new Set(["button","link","tab","menuitem"]);function $e(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&&Xt.has(t))return "role";try{if(window.getComputedStyle(e).cursor==="pointer")return "cursor_pointer"}catch{}return null}function Xe(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function Ee(e,t){if(!e||Xe(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(Xe(n,t.ignoreSelectors))return null;if(t.isSelectable?t.isSelectable(n):zt(n))return n;n=n.parentElement;}return null}function re(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 zt(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function We(e){let t=e.getBoundingClientRect(),n={selector:W(e),tagName:e.tagName.toLowerCase(),rect:we(t),pageRect:Ot(t)},o=e.getAttribute("id");o&&(n.id=o);let r=e.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=N(e);i&&(n.textSnippet=i);let l=q(e)??ve(e);l&&(n.componentName=l);let s=qt(e);return s&&(n.testId=s),n}var Se=null;async function je(){return Se||(Se=import('html-to-image')),Se}async function $t(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 Ke(e,t){let{width:n,height:o}=await $t(e);return {dataUrl:e,mime:t,width:n,height:o}}function Z(e){if(e?.aborted)throw new Error("Aborted")}function Ze(){return {async captureElement(e,t){if(!S())throw new Error("captureElement can only run in the browser");Z(t.signal);let n=await je();Z(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 Z(t.signal),await Ke(o,t.mime)},async captureFullPage(e){if(!S())throw new Error("captureFullPage can only run in the browser");Z(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)),l=Math.max(1,Math.round(o*r)),s=await je();Z(e.signal);let a=e.mime==="image/jpeg"?await s.toJpeg(t,{width:i,height:l,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await s.toPng(t,{width:i,height:l,pixelRatio:e.pixelRatio});return Z(e.signal),await Ke(a,e.mime)}}}function Wt(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function v(e,t,n){let o={kind:e,message:Wt(t)};return n&&(o.detail=n),o}var jt=12e3,Kt=2048,Zt=.92;function Ge(){return Date.now()}function Gt(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 Ye(e,t,n){let o=new Promise((i,l)=>{let s=setTimeout(()=>l(new Error("Timeout")),t);typeof s.unref=="function"&&s.unref();}),r=[e,o];return n&&r.push(Gt(n)),await Promise.race(r)}function Yt(e){if(!S())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function Jt(e){return !!(e?.element||e?.fullPage)}function Je(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 Qe(e){let{selectionElement:t,capture:n,signal:o}=e;if(!S()||!Jt(n))return;let r=Ge(),i=[],l=n?.timeoutMs??jt,s=n?.maxDimension??Kt,a=n?.mime??"image/png",c=n?.quality??Zt,u=n?.adapter??Ze(),d={},p=Yt(n);if(n?.element&&t)try{let m=t.getBoundingClientRect(),h=Math.min(1,s/Math.max(m.width,m.height)),E=Math.min(p,p*h),b=await Ye(Promise.resolve(u.captureElement(t,{...Je({mime:a,quality:c,pixelRatio:E,maxDimension:s,includeQuality:a==="image/jpeg",...o?{signal:o}:{}})})),l,o);d.element=b;}catch(m){if(o?.aborted)throw m;i.push(v("capture_failed",m,{target:"element"}));}if(n?.fullPage)try{let m=await Ye(Promise.resolve(u.captureFullPage(Je({mime:a,quality:c,pixelRatio:p,maxDimension:s,includeQuality:a==="image/jpeg",...o?{signal:o}:{}}))),l,o);d.fullPage=m;}catch(m){if(o?.aborted)throw m;i.push(v("capture_failed",m,{target:"fullPage"}));}let g=Ge(),f={startedAt:r,finishedAt:g,durationMs:Math.max(0,g-r)};return i.length>0&&(f.errors=i),{...d,diagnostics:f}}function Qt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function en(){return S()?{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:Qt()}:{}}function tn(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 et(e){let{config:t,context:n,user:o}=e;if(t?.enabled===false)return {};let r={...en(),...tn(o)},i=t?.enrich;if(!i)return r;try{let l=await i(n);return {...r,...l}}catch(l){let s=v("unknown",l);return {...r,blocfeedMetadataError:s.message}}}var Q="blocfeed-queue",nn=50;function _e(){if(!S())return [];try{let e=localStorage.getItem(Q);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(Q);}catch{}return []}catch(e){console.warn("[BlocFeed] offline queue could not be read \u2014 resetting",e);try{localStorage.removeItem(Q);}catch{}return []}}function ke(e){if(S())try{e.length===0?localStorage.removeItem(Q):localStorage.setItem(Q,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 on(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 Ce(e){let t=_e(),n=on(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>nn;)t.shift();ke(t);}function tt(){let e=_e();return e.length===0?[]:(ke([]),e.map(t=>t.payload))}function ho(){ke([]);}function bo(){return _e().length}var rn=200,ee=[],nt=0,ie=false;function ot(e){let t=e.target;if(!(t instanceof Element)||t.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-nt,path:window.location.pathname,tagName:t.tagName.toLowerCase()},o=N(t,100);o&&(n.textSnippet=o);let r=q(t)??ve(t);r&&(n.componentName=r),ee.length<rn&&ee.push(n);}var rt={capture:true,passive:true};function it(){ie||!S()||(ie=true,ee=[],nt=Date.now(),document.addEventListener("click",ot,rt));}function st(){ie&&(ie=false,document.removeEventListener("click",ot,rt));}function sn(){return [...ee]}function an(){ee=[];}var cn=3e4,ln=25e5,at="video/webm",un=250,dn=1e3,fn=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function ct(){if(typeof MediaRecorder>"u")return null;for(let e of fn)if(MediaRecorder.isTypeSupported(e))return e;return null}function pn(){return !S()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:ct()!==null}async function Te(e){let{config:t,signal:n}=e;if(!S()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw v("recording_failed",new Error("Screen recording is not supported in this browser"));let o=ct();if(!o)throw v("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw v("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(h){let E=h instanceof DOMException&&h.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw v("recording_failed",new Error(E))}if(n?.aborted)throw r.getTracks().forEach(h=>h.stop()),v("aborted",new Error("Recording aborted after permission"));let i=t?.maxDurationMs??cn,l=t?.videoBitsPerSecond??ln,s=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:l}),a=[],c=[],u=0,d=null,p=null,g=false,f=()=>{st(),d!==null&&(clearInterval(d),d=null),p!==null&&(clearTimeout(p),p=null),r.getTracks().forEach(h=>h.stop());},m=new Promise((h,E)=>{s.ondataavailable=k=>{k.data.size>0&&a.push(k.data);},s.onstop=()=>{if(g)return;g=true,f();let k=Date.now()-u,C=new Blob(a,{type:at}),y=URL.createObjectURL(C);h({mime:at,blobUrl:y,blob:C,durationMs:k,sizeBytes:C.size});},s.onerror=()=>{g||(g=true,f(),E(v("recording_failed",new Error("MediaRecorder error"))));};let b=r.getVideoTracks()[0];if(b&&b.addEventListener("ended",()=>{s.state!=="inactive"&&s.stop();}),n){let k=()=>{g||(g=true,s.state!=="inactive"&&s.stop(),f(),E(v("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",k,{once:true});}});return s.start(dn),it(),u=Date.now(),d=setInterval(()=>{let h=Date.now()-u;for(let E of c)E(h);},un),p=setTimeout(()=>{!g&&s.state!=="inactive"&&s.stop();},i),{result:m,stop(){!g&&s.state!=="inactive"&&s.stop();},onTick(h){c.push(h);},abort(){g||(g=true,s.state!=="inactive"&&s.stop(),f());}}}var mn=6e4,lt="audio/webm",gn=250,hn=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function ut(){if(typeof MediaRecorder>"u")return null;for(let e of hn)if(MediaRecorder.isTypeSupported(e))return e;return null}function bn(){return !S()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:ut()!==null}async function Re(e){let{config:t,signal:n}=e;if(!S()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw v("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=ut();if(!o)throw v("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw v("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(m){let h=m instanceof DOMException&&m.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw v("recording_failed",new Error(h))}if(n?.aborted)throw r.getTracks().forEach(m=>m.stop()),v("aborted",new Error("Voice recording aborted after permission"));let i=t?.maxDurationMs??mn,l=new MediaRecorder(r,{mimeType:o}),s=[],a=[],c=0,u=null,d=null,p=false,g=()=>{u!==null&&(clearInterval(u),u=null),d!==null&&(clearTimeout(d),d=null),r.getTracks().forEach(m=>m.stop());},f=new Promise((m,h)=>{if(l.ondataavailable=E=>{E.data.size>0&&s.push(E.data);},l.onstop=()=>{if(p)return;p=true,g();let E=Date.now()-c,b=new Blob(s,{type:lt});m({blob:b,mime:lt,durationMs:E});},l.onerror=()=>{p||(p=true,g(),h(v("recording_failed",new Error("MediaRecorder error"))));},n){let E=()=>{p||(p=true,l.state!=="inactive"&&l.stop(),g(),h(v("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",E,{once:true});}});return l.start(1e3),c=Date.now(),u=setInterval(()=>{let m=Date.now()-c;for(let h of a)h(m);},gn),d=setTimeout(()=>{d=null,!p&&l.state!=="inactive"&&l.stop();},i),{result:f,stop(){!p&&l.state!=="inactive"&&l.stop();},onTick(m){a.push(m);},abort(){p||(p=true,l.state!=="inactive"&&l.stop(),g());}}}var yn=12e3,wn=2,vn=500,En=2e3,xe="https://blocfeed.com/api/feedback",Sn="https://blocfeed.com/api/feedback/voice",dt=0,mt="blocfeed-viewer-token",gt="blocfeed-my-feedback-url";function _n(){try{return localStorage.getItem(mt)}catch{return null}}function Io(){try{return localStorage.getItem(gt)}catch{return null}}function kn(e,t){try{localStorage.setItem(mt,e),t&&localStorage.setItem(gt,t);}catch{}}function ft(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 Cn(e){return e>=500&&e<=599}function Tn(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),l=new Uint8Array(i.length);for(let s=0;s<i.length;s+=1)l[s]=i.charCodeAt(s);return new Blob([l],{type:r})}function Rn(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 pt(e,t,n){let o=Tn(t);await fetch(e,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function xn(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(`${xe}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function An(e){await fetch(`${xe}/${e.feedbackId}/video`,{method:"POST",body:e.blob,headers:{"content-type":e.blob.type},...e.signal?{signal:e.signal}:{}});}async function ht(e){let{signal:t,transport:n}=e;if(Date.now()-dt<En)return {ok:false,error:v("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??yn,i=n?.maxAttempts??wn,l=n?.backoffMs??vn,s=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),a=!!e.payload.video?.blob,c=s||a,{lean:u,extracted:d,extractedVideo:p}=c?Rn(e.payload):{lean:e.payload,extracted:{},extractedVideo:{}},g=_n();g&&(u.viewer_token=g);let f={...d,...e.screenshotDataUrls};for(let m=1;m<=i;m+=1){let h=new AbortController,E=setTimeout(()=>h.abort(),r),b=()=>h.abort();t&&t.addEventListener("abort",b,{once:true});try{let k=await fetch(xe,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(u),signal:h.signal});if(k.ok){dt=Date.now();let y;try{y=await k.json();}catch{}if(y?.viewer_token&&kn(y.viewer_token,y.my_feedback_url),(f.element||f.fullPage)&&y){let L=y.upload_urls;if(L){let V=[];f.element&&L.element&&V.push(pt(L.element,f.element,t)),f.fullPage&&L.fullPage&&V.push(pt(L.fullPage,f.fullPage,t));try{await Promise.all(V);}catch{}}else if(y.feedback_id)try{await xn({feedbackId:y.feedback_id,extracted:f,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}if(p.blob&&y){let L=y.upload_urls;if(L?.video)try{await fetch(L.video,{method:"PUT",body:p.blob,headers:{"content-type":p.blob.type},...t?{signal:t}:{}});}catch{}else if(y.feedback_id)try{await An({feedbackId:y.feedback_id,blob:p.blob,...t?{signal:t}:{}});}catch{}}let B={ok:!0,status:k.status};return y&&(B.apiResponse=y),B}if(m<i&&Cn(k.status)){let y=.85+Math.random()*.3,O=Math.round(l*2**(m-1)*y);await ft(O,t);continue}let C=`HTTP ${k.status}`;try{let y=await k.json();y?.error&&(C=y.error);}catch{}return {ok:!1,status:k.status,error:v("api_failed",new Error(C))}}catch(k){if(h.signal.aborted||t?.aborted)return {ok:false,error:v("aborted",k)};if(m<i){let C=.85+Math.random()*.3,y=Math.round(l*2**(m-1)*C);await ft(y,t);continue}return {ok:false,error:v("api_failed",k)}}finally{clearTimeout(E),t&&t.removeEventListener("abort",b);}}return {ok:false,error:v("api_failed",new Error("Failed"))}}async function bt(e){let{blob:t,mime:n,blocfeedId:o,signal:r}=e,i=await fetch(Sn,{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 v("api_failed",new Error(s?.error??`Voice API returned ${i.status}`))}let l=await i.json();return {text:l.text??"",warning:l.warning}}var Mn={enabled:true,sampling:1,ignoreSelectors:["[data-blocfeed-ui]","[data-blocfeed-ignore]"],rageClick:{enabled:true,threshold:3,windowMs:1e3},httpFail:{enabled:true,statusCodes:[400,401,403,422,500,502,503,504],ignoreUrls:["/api/behavioral-events","/api/feedback"]},redirectLoop:{enabled:true,threshold:3,windowMs:2e3},formDataLoss:{enabled:true},deadClick:{enabled:true,observationWindowMs:300,rateLimitPerSelector:5}};function yt(e){let t=Mn;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 wt(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"}),l=`${e.endpoint}?_bfid=${encodeURIComponent(e.blocfeedId)}`;try{navigator.sendBeacon(l,i);}catch{}}return {enqueue(r){t.push(r);},flush:n,flushBeacon:o,size(){return t.length}}}var vt="bf_behavioral_session",se=null;function P(){try{let e=sessionStorage.getItem(vt);if(e)return e;let t=Et();return sessionStorage.setItem(vt,t),t}catch{return se||(se=Et(),se)}}function Et(){let e=Math.random().toString(36).slice(2,10).padEnd(8,"0");return `bf_${Date.now()}_${e}`}function St(e,t){if(!e.rageClick.enabled)return ()=>{};let{threshold:n,windowMs:o}=e.rageClick,r=new Map;function i(l){try{let s=l.target;if(!s||!(s instanceof Element)||re(s,e.ignoreSelectors))return;let a=W(s,4);if(!a)return;let c=Date.now(),d=(r.get(a)??[]).filter(p=>c-p<=o);if(d.push(c),r.set(a,d),d.length>=n){let p=Fn(s),g=N(s,200)??null,f=s.tagName.toLowerCase(),m=s.id||null,h=q(s)??null,E=K(s,5),b={session_id:P(),event_type:"rage_click",page_url:typeof window>"u"?"":window.location.href,selector:a,element_text:g,event_data:{click_count:d.length,window_ms:o,...p?{disabled:!0}:{},tag_name:f,...m?{element_id:m}:{},...h?{component_name:h}:{},...E.length>0?{parent_components:E}:{}},created_at:new Date().toISOString()};t(b),r.set(a,[]);}}catch{}}return document.addEventListener("click",i,{capture:true,passive:true}),()=>document.removeEventListener("click",i,{capture:true})}function Fn(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 kt=0,Ct=null,ae=null,ce=[],Ln=1500;function Pn(){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;kt=Date.now();let r=o.closest("form");Ct=(r?W(r,3):"")||null,ae=N(o,100)??null,ce=K(o,5);}catch{}}return document.addEventListener("click",e,{capture:true,passive:true}),()=>document.removeEventListener("click",e,{capture:true})}function Tt(e,t){if(!e.httpFail.enabled)return ()=>{};let{statusCodes:n,ignoreUrls:o}=e.httpFail,r=new Set(n),i=Pn(),l=globalThis.fetch,s=async(d,p)=>{let g=typeof d=="string"?d:d instanceof URL?d.toString():d.url,f=(p?.method??d.method??"GET").toUpperCase(),m=await l.call(globalThis,d,p);try{!_t(g,o)&&r.has(m.status)&&t(u(m.status,g,f));}catch{}return m};globalThis.fetch=s;let a=XMLHttpRequest.prototype.open,c=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(d,p,...g){return this.__bf_url=p,this.__bf_method=d.toUpperCase(),a.call(this,d,p,...g)},XMLHttpRequest.prototype.send=function(d){let p=()=>{try{let g=this.__bf_url??"",f=this.__bf_method??"GET";!_t(g,o)&&r.has(this.status)&&t(u(this.status,g,f));}catch{}};return this.__bf_handler=p,this.addEventListener("loadend",p),c.call(this,d??null)},()=>{globalThis.fetch=l,XMLHttpRequest.prototype.open=a,XMLHttpRequest.prototype.send=c,i(),ae=null,ce=[];};function u(d,p,g){let m=Date.now()-kt<Ln;return {session_id:P(),event_type:"error",page_url:typeof window>"u"?"":window.location.href,selector:null,element_text:null,event_data:{http_status:d,request_url:p,method:g,form_selector:m?Ct:null,...m&&ae?{button_text:ae}:{},...m&&ce.length>0?{parent_components:ce}:{}},created_at:new Date().toISOString()}}}function _t(e,t){if(t.length===0)return false;for(let n of t)if(e.includes(n))return true;return false}var In=3e4;function Rt(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,l=history.pushState,s=history.replaceState;function a(u){try{let d=Date.now(),p=i.get(u)??0;if(d<p)return;let f=(r.get(u)??[]).filter(m=>d-m<=o);if(f.push(d),r.set(u,f),f.length>=n){let m={session_id:P(),event_type:"thrashing",page_url:window.location.href,selector:null,element_text:null,event_data:{count:f.length,url:u,window_ms:o},created_at:new Date().toISOString()};t(m),i.set(u,d+In),r.set(u,[]);}}catch{}}function c(){let u=window.location.pathname+window.location.search;a(u);}return history.pushState=function(...u){let d=l.apply(this,u);return c(),d},history.replaceState=function(...u){let d=s.apply(this,u);return c(),d},window.addEventListener("popstate",c),()=>{history.pushState=l,history.replaceState=s,window.removeEventListener("popstate",c);}}function xt(e,t){if(!e.formDataLoss.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let n=new Set,o=0;function r(c){let u=c.closest("form");return u?u.id?`#${u.id}`:"form":null}function i(c){try{let u=c.target;if(!u||!(u instanceof HTMLInputElement||u instanceof HTMLTextAreaElement||u instanceof HTMLSelectElement))return;let d=r(u);if(!d)return;n.has(d)||n.add(d),o++;}catch{}}function l(c){if(n.size===0)return;let u=Array.from(n),d={session_id:P(),event_type:"form_abandonment",page_url:window.location.href,selector:u[0]??null,element_text:null,event_data:{cause:c,field_count:o,forms:u},created_at:new Date().toISOString()};t(d);}function s(c){c.persisted&&l("bfcache_restore");}function a(){l("beforeunload_after_edit");}return document.addEventListener("input",i,{capture:true,passive:true}),window.addEventListener("pageshow",s),window.addEventListener("beforeunload",a),()=>{document.removeEventListener("input",i,{capture:true}),window.removeEventListener("pageshow",s),window.removeEventListener("beforeunload",a);}}function Bn(){let e={domMutationCount:0,urlChangeCount:0,networkCount:0,filePickerCount:0,uninstall:()=>{}},t=new MutationObserver(()=>{e.domMutationCount+=1;});t.observe(document.body,{childList:true,attributes:true,characterData:true,subtree:true});let n=history.pushState,o=history.replaceState;history.pushState=function(...a){return e.urlChangeCount+=1,n.apply(this,a)},history.replaceState=function(...a){return e.urlChangeCount+=1,o.apply(this,a)};let r=()=>{e.urlChangeCount+=1;};window.addEventListener("popstate",r);let i=globalThis.fetch;if(i){let a=(c,u)=>(e.networkCount+=1,i.call(globalThis,c,u));globalThis.fetch=a;}let l=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(a,c,...u){return e.networkCount+=1,l.call(this,a,c,...u)};let s=HTMLInputElement.prototype.click;return HTMLInputElement.prototype.click=function(){return this.type==="file"&&(e.filePickerCount+=1),s.call(this)},e.uninstall=()=>{t.disconnect(),history.pushState=n,history.replaceState=o,window.removeEventListener("popstate",r),i&&(globalThis.fetch=i),XMLHttpRequest.prototype.open=l,HTMLInputElement.prototype.click=s;},e}function At(e,t){if(!e.deadClick.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let{observationWindowMs:n,rateLimitPerSelector:o}=e.deadClick,r=new Map,i=Bn();function l(s){try{let a=s.target;if(!a||!(a instanceof Element)||s.button!==0||s.metaKey||s.ctrlKey||s.altKey||s.shiftKey||re(a,e.ignoreSelectors)||a.closest("label"))return;if(a instanceof HTMLInputElement){let y=a.type;if(y==="checkbox"||y==="radio"||y==="file")return}if(a instanceof HTMLSelectElement||a.closest("a[target='_blank'], a[download]")||a.closest('[contenteditable="true"]'))return;try{let y=window.getSelection();if(y&&y.toString().length>0)return}catch{}let c=$e(a);if(!c)return;let u=W(a,4);if(!u)return;let d=i.domMutationCount,p=i.urlChangeCount,g=i.networkCount,f=i.filePickerCount,m=new Date().toISOString(),h=N(a,200)??null,E=a.tagName.toLowerCase(),b=a.id||null,k=q(a)??null,C=K(a,5);setTimeout(()=>{if(i.domMutationCount!==d||i.urlChangeCount!==p||i.networkCount!==g||i.filePickerCount!==f)return;let y=r.get(u)??0;if(y>=o)return;r.set(u,y+1);let O={session_id:P(),event_type:"dead_click",page_url:typeof window>"u"?"":window.location.href,selector:u,element_text:h,event_data:{tag_name:E,...b?{element_id:b}:{},...k?{component_name:k}:{},...C.length>0?{parent_components:C}:{},clickable_reason:c},created_at:m};t(O);},n);}catch{}}return document.addEventListener("click",l,{capture:true,passive:true}),()=>{document.removeEventListener("click",l,{capture:true}),i.uninstall();}}var Nn="https://blocfeed.com/api/replay-events";function Mt(e){if(!e.config.enabled)return ()=>{};if(typeof window>"u")return ()=>{};if(typeof globalThis.matchMedia>"u")return ()=>{};let t=P();if(Un(t)%100/100>=e.config.sampling)return ()=>{};let o=Date.now(),r=e.config.endpoint??Nn,i=[],l=0,s=false,a=null,c=`bf_replay_chunkseq_${t}`,u=0;try{let C=sessionStorage.getItem(c);C&&(u=parseInt(C,10)||0);}catch{}let d=(C=false)=>{if(i.length===0)return;let y=C?Hn(i):i;i=[],l=0;let O=u++;try{sessionStorage.setItem(c,String(u));}catch{}qn({blocfeedId:e.blocfeedId,sessionId:t,sessionStartedAtMs:o,chunkSeq:O,events:y,endpoint:r,useBeacon:C});},p=setInterval(()=>{s||d();},e.config.flushIntervalMs),g=setTimeout(()=>{d(),k();},e.config.maxDurationMs),f=null,m=()=>{f&&clearTimeout(f),f=setTimeout(()=>{d(),k();},e.config.inactivityTimeoutMs);};m();let h=()=>{d(true);};window.addEventListener("pagehide",h);let E=e.config.masking,b={emit(C){s||(i.push(C),l+=On(C),m(),l>=e.config.flushSizeBytes&&d());},recordCanvas:false,sampling:{mousemove:50}};E.maskAllInputs!==void 0&&(b.maskAllInputs=E.maskAllInputs),E.maskTextSelector!==void 0&&(b.maskTextSelector=E.maskTextSelector),E.maskTextClass!==void 0&&(b.maskTextClass=E.maskTextClass),E.blockSelector!==void 0&&(b.blockSelector=E.blockSelector),a=rrweb.record(b)??null;function k(){if(!s&&(s=true,clearInterval(p),clearTimeout(g),f&&clearTimeout(f),window.removeEventListener("pagehide",h),a))try{a();}catch{}}return k}function On(e){try{return JSON.stringify(e).length}catch{return 1024}}function Un(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return Math.abs(t)}function Hn(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 qn(e){let t=JSON.stringify({blocfeed_id:e.blocfeedId,session_id:e.sessionId,session_started_at_ms:e.sessionStartedAtMs,chunk_seq:e.chunkSeq,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 Vn={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 Ft(e){let t=Vn;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 Xn=5e3,le=class{constructor(t){this.submitter=null;this.detectorUninstallers=[];this.flushTimer=null;this.pageHideHandler=null;this.installed=false;this.opts=t,this.resolved=yt(t.config);}install(){if(this.installed||!this.resolved.enabled||!(this.opts.passiveSampler??(()=>Math.random()<this.resolved.sampling))())return;let n=this.opts.endpoint??"https://blocfeed.com/api/behavioral-events";this.submitter=this.opts.submitter??wt({endpoint:n,blocfeedId:this.opts.blocfeedId});let o=i=>{this.submitter?.enqueue(i);};this.detectorUninstallers.push(St(this.resolved,o)),this.detectorUninstallers.push(Tt(this.resolved,o)),this.detectorUninstallers.push(Rt(this.resolved,o)),this.detectorUninstallers.push(xt(this.resolved,o)),this.detectorUninstallers.push(At(this.resolved,o));let r=Ft(this.opts.config?.sessionReplay);this.detectorUninstallers.push(Mt({blocfeedId:this.opts.blocfeedId,config:r})),this.flushTimer=setInterval(()=>{this.submitter?.flush();},Xn),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;}}};function Ae(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 ue(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function de(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function Lt(e,t){if(!S())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,l=null,s=(f,m=false)=>{if(!f){i=null,l=null,t.onHover(null);return}let h=we(f.getBoundingClientRect()),E=`${Math.round(h.x)}:${Math.round(h.y)}:${Math.round(h.width)}:${Math.round(h.height)}`;!m&&f===i&&E===l||(i=f,l=E,t.onHover({element:f,rect:h}));},a=Ae(f=>{if(ue(f.target))return;let m=document.elementFromPoint(f.clientX,f.clientY),h=Ee(m,r);s(h);}),c=Ae(()=>{i&&s(i,true);}),u=f=>{ue(f.target)||(de(f),f.pointerType==="mouse"&&f.preventDefault());},d=f=>{ue(f.target)||(de(f),f.pointerType==="mouse"&&f.preventDefault());},p=f=>{if(ue(f.target))return;de(f),f.preventDefault();let m=document.elementFromPoint(f.clientX,f.clientY),h=Ee(m,r);h&&t.onSelect({element:h,descriptor:We(h)});},g=f=>{f.key==="Escape"&&(de(f),f.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",a,{capture:true,passive:true}),window.addEventListener("pointerdown",u,{capture:true}),window.addEventListener("pointerup",d,{capture:true}),window.addEventListener("click",p,{capture:true}),window.addEventListener("keydown",g,{capture:true}),window.addEventListener("scroll",c,{capture:true,passive:true}),window.addEventListener("resize",c,{passive:true}),{stop(){window.removeEventListener("pointermove",a,{capture:true}),window.removeEventListener("pointerdown",u,{capture:true}),window.removeEventListener("pointerup",d,{capture:true}),window.removeEventListener("click",p,{capture:true}),window.removeEventListener("keydown",g,{capture:true}),window.removeEventListener("scroll",c,{capture:true}),window.removeEventListener("resize",c),a.cancel(),c.cancel(),t.onHover(null);}}}async function Me(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 ht(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:v("api_failed",r)},o.ok=false;}return {payload:e.payload,result:o}}var zn=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function $n(e){let t=[...zn,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function Pt(){return {phase:"idle"}}function Wn(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 Fr(e){let t=e,n=new le({blocfeedId:t.blocfeed_id??"",...t.behavioral!==void 0?{config:t.behavioral}:{}});n.install();let o=Pt(),r=new Set,i=new Set,l=null,s=null,a=null,c=null,u=0,d=null,p=null,g=null,f=null,m=false,h=()=>{for(let w of r)w(o);},E=w=>{for(let _ of i)_(w);},b=w=>{o=w,h();},k=()=>{u+=1,c?.abort(),c=null;},C=()=>{l?.stop(),l=null,E(null),a!==null&&S()&&(document.documentElement.style.cursor=a,a=null);},y=()=>{if(g){try{URL.revokeObjectURL(g.blobUrl);}catch{}g=null;}},O=()=>{p&&(p.abort(),p=null),y();},B=null,L=()=>{f&&(f.abort(),f=null),B&&(B.abort(),B=null);},V=()=>{k(),C(),O(),L(),s=null,b(Pt());},Ne=()=>{if(!S())return;C(),s=null;let w=$n(t.picker);a=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",b({phase:"picking"}),l=Lt(w,{onHover:E,onSelect:({element:_,descriptor:M})=>{s=_,C(),b({phase:"review",selection:M});},onCancel:()=>{V();}});},Oe=()=>{let w=tt();if(w.length!==0)for(let _ of w)Me({payload:_,...t.transport?{transport:t.transport}:{}}).catch(()=>{Ce(_);});};if(S()){setTimeout(Oe,1e3);let w=()=>Oe();window.addEventListener("online",w),d=()=>window.removeEventListener("online",w);}return {getState:()=>o,getConfig:()=>t,subscribe(w){return r.add(w),()=>r.delete(w)},subscribeHover(w){return i.add(w),()=>i.delete(w)},start(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||o.phase!=="picking"&&Ne();},stop(){V();},clearSelection(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||Ne();},setConfig(w){t=w;},async submit(w,_){if(!S()){let R=v("configuration",new Error("BlocFeed submit can only run in the browser"));return b({phase:"error",lastError:R}),{ok:false}}let M=t.blocfeed_id?.trim?.()??"";if(!M){let I={phase:"error",lastError:v("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return o.selection&&(I.selection=o.selection),b(I),{ok:false}}if(m)return {ok:false};if(o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording")return {ok:false};m=true;let A=u+1;u=A,c?.abort(),c=new AbortController;let x=c.signal,T=o.selection,D=_?.capture?{...t.capture,..._.capture}:t.capture,X=!!(D?.element||D?.fullPage),G={phase:X?"capturing":"submitting"};T&&(G.selection=T),b(G);try{let R=X?await Qe({selectionElement:s,capture:D,signal:x}):void 0;if(x.aborted||u!==A)return {ok:!1};let I={phase:"submitting"};T&&(I.selection=T),R&&(I.capture=R),b(I);let U={};T&&(U.selection=T),R&&(U.capture=R);let Y=await et({config:t.metadata,context:U,...t.user?{user:t.user}:{}}),z={version:1,createdAt:new Date().toISOString(),blocfeed_id:M,message:w,metadata:Y};_?.category&&(z.category=_.category),t.user&&(z.user=t.user),T&&(z.selection=T),R&&(z.screenshots=R),g&&(z.video=g);let{result:H}=await Me({payload:z,signal:x,...t.transport?{transport:t.transport}:{}});if(x.aborted||u!==A)return H;if(H.ok){y(),s=null;let ye={phase:"success",lastSubmit:H};return T&&(ye.selection=T),R&&(ye.capture=R),b(ye),H}Wn(H)&&Ce(z);let Nt=H.api?.error??v("unknown",new Error("Submission failed")),be={phase:"error",lastSubmit:H,lastError:Nt};return T&&(be.selection=T),R&&(be.capture=R),b(be),H}catch(R){if(x.aborted||u!==A)return {ok:false};let U={phase:"error",lastError:x.aborted?v("aborted",R):v("unknown",R)};return T&&(U.selection=T),b(U),{ok:false}}finally{m=false,u===A&&(c=null);}},async startRecording(){if(o.phase!=="review"||!t.recording?.enabled||f||p)return;let w=o.selection,_={phase:"recording",recordingElapsedMs:0};w&&(_.selection=w),b(_);try{let M={config:t.recording};c&&(M.signal=c.signal);let A=await Te(M);p=A,A.onTick(D=>{if(o.phase==="recording"){let X={phase:"recording",recordingElapsedMs:D};w&&(X.selection=w),b(X);}});let x=await A.result;p=null,g=x;let T={phase:"review",video:x};w&&(T.selection=w),b(T);}catch(M){p=null;let x={phase:"review",lastError:M?.kind?M:v("recording_failed",M)};w&&(x.selection=w),b(x);}},stopRecording(){o.phase!=="recording"||!p||p.stop();},removeVideo(){y();let w=o.selection,_={phase:"review"};w&&(_.selection=w),b(_);},async startVoice(){if(o.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",o.phase,'(expected "review")');return}let w=t.voice;if(!w?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}if(p){console.warn("[BlocFeed] startVoice: ignored \u2014 a screen recording is already in progress");return}L();let _=o.selection,M={phase:"review",voiceRecording:true,voiceElapsedMs:0};_&&(M.selection=_),g&&(M.video=g),b(M);try{let A={config:w};c&&(A.signal=c.signal);let x=await Re(A);f=x,x.onTick(U=>{let Y={phase:"review",voiceRecording:!0,voiceElapsedMs:U};_&&(Y.selection=_),g&&(Y.video=g),b(Y);});let T=await x.result;f=null;let D={phase:"review",voiceRecording:!1,voiceTranscribing:!0};_&&(D.selection=_),g&&(D.video=g),b(D),B=new AbortController;let X={blob:T.blob,mime:T.mime,blocfeedId:t.blocfeed_id,signal:B.signal},{text:Ue,warning:G}=await bt(X);B=null;let R={phase:"review",voiceRecording:!1,voiceTranscribing:!1};_&&(R.selection=_),g&&(R.video=g),b(R);let I={text:Ue};return G&&(I.warning=G),I}catch(A){L();let x=A?.kind?A:v("recording_failed",A);console.warn("[BlocFeed] Voice error:",x.message);let T={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:x};_&&(T.selection=_),g&&(T.video=g),b(T);return}},stopVoice(){f&&f.stop();},__unsafeGetSelectedElement(){return s},destroy(){n.uninstall(),V(),r.clear(),i.clear(),d?.(),d=null;}}}var te=[],ne=[],It=20,Bt=15,fe=[],Dt=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)}:{},pe=typeof globalThis<"u"&&typeof globalThis.fetch=="function"?globalThis.fetch:void 0,me=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.open:void 0,ge=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.send:void 0,Le=new Set,Pe=false,Ie=false,he=false,jn=["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 Kn(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 Zn(e,t){let n=t.map(Kn).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)),te.push(r);te.length>It;)te.shift();}function Fe(e){let t=e.url.toLowerCase();for(let n of fe)if(t.includes(n))return;for(ne.push(e);ne.length>Bt;)ne.shift();}function Ir(e={}){if(he||!S())return;he=true,It=e.consoleLimit??20,Bt=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?fe=t.map(n=>n.toLowerCase()):fe=[...jn],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let o of n){let r=Dt[o];r&&(Le.add(o),console[o]=(...i)=>{Zn(o,i),r.apply(console,i);});}}if(e.network!==false&&pe){let n=pe;Pe=true,window.fetch=async function(r,i){let l=typeof r=="string"?r:r instanceof URL?r.toString():r.url,s=(i?.method??"GET").toUpperCase(),a=Date.now();try{let c=await n.call(window,r,i);return c.ok||Fe({url:l.slice(0,500),method:s,status:c.status,statusText:c.statusText,timestamp:a,durationMs:Date.now()-a}),c}catch(c){throw Fe({url:l.slice(0,500),method:s,status:0,statusText:c instanceof Error?c.message:"Network error",timestamp:a,durationMs:Date.now()-a}),c}};}if(e.network!==false&&me&&ge){let n=me,o=ge;Ie=true,XMLHttpRequest.prototype.open=function(r,i,...l){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...l])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",l=this.__bf_url||"",s=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let a={url:l.slice(0,500),method:i,status:this.status,timestamp:s,durationMs:Date.now()-s};this.statusText&&(a.statusText=this.statusText),Fe(a);}},{once:true}),o.apply(this,r)};}}function Br(){if(he){for(let e of Le){let t=Dt[e];t&&(console[e]=t);}Le.clear(),Pe&&pe&&(window.fetch=pe,Pe=false),Ie&&me&&ge&&(XMLHttpRequest.prototype.open=me,XMLHttpRequest.prototype.send=ge,Ie=false),fe=[],he=false;}}function Dr(){return {consoleLogs:[...te],networkErrors:[...ne]}}function Nr(){te=[],ne=[];}var Gn=[{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}/}],j=[],De=0,Be=false;function Yn(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function Jn(e,t,n,o){if(j.some(l=>l.rule===e&&l.source===t))return;let i={rule:e,source:t,hint:Yn(n),timestamp:Date.now()};o&&(i.location=o),j.push(i);}function oe(e,t,n,o){for(let{name:r,pattern:i}of n){let l=i.exec(e);l&&Jn(r,t,l[0],o);}}function Qn(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);oe(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);oe(n,"hydration",e,"__NUXT__");}}catch{}}function eo(e){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&oe(r,"scripts",e,`inline-script[${o}]`);});}catch{}}function to(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let o=n.getAttribute("content"),r=n.getAttribute("name")||n.getAttribute("property")||"";o&&o.length>10&&oe(o,"meta",e,r?`meta[${r}]`:void 0);});}catch{}}function no(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&&oe(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function Hr(e={}){if(Be||!S()||(Be=true,e.secretScan===false))return;let t=[...Gn,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{De=Date.now(),n.includes("hydration")&&Qn(t),n.includes("scripts")&&eo(t),n.includes("meta")&&to(t),n.includes("dom")&&no(t);let o=e.notify??"both";j.length>0&&(o==="console"||o==="both")&&console.warn(`[BlocFeed Security] Found ${j.length} potential secret(s) exposed in client code:`,j.map(r=>`${r.rule} (${r.source}${r.location?`: ${r.location}`:""})`));},100);}function qr(){return {findings:[...j],scannedAt:De}}function Vr(){j=[],De=0,Be=false;}
|
|
2
|
-
exports.A=Vr;exports.a=S;exports.b=we;exports.c=Ze;exports.d=Qe;exports.e=et;exports.f=Ce;exports.g=tt;exports.h=ho;exports.i=bo;exports.j=sn;exports.k=an;exports.l=pn;exports.m=Te;exports.n=bn;exports.o=Re;exports.p=_n;exports.q=Io;exports.r=bt;exports.s=le;exports.t=Fr;exports.u=Ir;exports.v=Br;exports.w=Dr;exports.x=Nr;exports.y=Hr;exports.z=qr;
|
package/dist/chunk-CS63UWFR.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {record}from'rrweb';function S(){return typeof window<"u"&&typeof document<"u"}function He(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 we(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Ot(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function Ut(e){return e.replace(/\s+/g," ").trim()}function N(e,t=140){let n=e.textContent;if(!n)return;let o=Ut(n);if(o)return o.length<=t?o:`${o.slice(0,t-1)}\u2026`}function Ht(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var ze=["data-testid","data-test-id","data-test","data-qa","data-cy"],qe="data-blocfeed-component";function q(e){let t=e.closest(`[${qe}]`);if(!t)return;let o=t.getAttribute(qe)?.trim();return o||void 0}function K(e,t=5){let n=[],o=e,r=0;for(;o&&r<t*4;){let i=q(o);if(i&&n[n.length-1]!==i&&(n.push(i),n.length>=t))break;o=o.parentElement,r++;}return n}function qt(e){for(let t of ze){let n=e.closest(`[${t}]`);if(!n)continue;let r=n.getAttribute(t)?.trim();if(r)return r}}function Ve(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 $(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 J(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!$(t.name))return t.name}}function F(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 F(r)}}}function ve(e){let t=Ve(e);if(!t)return;let n=J(t._debugInfo);if(n)return n;let o=t._debugOwner!==void 0;if(o){let a=t._debugOwner;for(let c=0;a&&c<50;c+=1){let u=J(a._debugInfo);if(u)return u;let d=F(a.type)??F(a.elementType);if(d&&!$(d))return d;a=a._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let a=t._owner;for(let c=0;a&&c<50;c+=1){let u=J(a._debugInfo);if(u)return u;let d=F(a.type)??F(a.elementType);if(d&&!$(d))return d;a=a._owner;}}let i=t,l=o?80:25;for(let a=0;i&&a<l;a+=1){let c=J(i._debugInfo);if(c)return c;let u=F(i.type)??F(i.elementType);if(u&&!$(u))return u;i=i.return;}let s=e.parentElement;for(let a=0;s&&a<15;a+=1){let c=Ve(s);if(c){let u=J(c._debugInfo);if(u)return u;let d=F(c.type)??F(c.elementType);if(d&&!$(d))return d;if(c._debugOwner){let p=F(c._debugOwner.type)??F(c._debugOwner.elementType);if(p&&!$(p))return p}if(c._owner&&c._owner!==c._debugOwner){let p=F(c._owner.type)??F(c._owner.elementType);if(p&&!$(p))return p}}s=s.parentElement;}}function Vt(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${He(n)}`;for(let o of ze){let r=e.getAttribute(o);if(r)return `${t}[${o}="${He(r)}"]`}return `${t}:nth-of-type(${Ht(e)})`}function W(e,t=10){let n=[],o=e;for(;o&&n.length<t;){let r=Vt(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}var Xt=new Set(["button","link","tab","menuitem"]);function $e(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&&Xt.has(t))return "role";try{if(window.getComputedStyle(e).cursor==="pointer")return "cursor_pointer"}catch{}return null}function Xe(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function Ee(e,t){if(!e||Xe(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(Xe(n,t.ignoreSelectors))return null;if(t.isSelectable?t.isSelectable(n):zt(n))return n;n=n.parentElement;}return null}function re(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 zt(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function We(e){let t=e.getBoundingClientRect(),n={selector:W(e),tagName:e.tagName.toLowerCase(),rect:we(t),pageRect:Ot(t)},o=e.getAttribute("id");o&&(n.id=o);let r=e.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=N(e);i&&(n.textSnippet=i);let l=q(e)??ve(e);l&&(n.componentName=l);let s=qt(e);return s&&(n.testId=s),n}var Se=null;async function je(){return Se||(Se=import('html-to-image')),Se}async function $t(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 Ke(e,t){let{width:n,height:o}=await $t(e);return {dataUrl:e,mime:t,width:n,height:o}}function Z(e){if(e?.aborted)throw new Error("Aborted")}function Ze(){return {async captureElement(e,t){if(!S())throw new Error("captureElement can only run in the browser");Z(t.signal);let n=await je();Z(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 Z(t.signal),await Ke(o,t.mime)},async captureFullPage(e){if(!S())throw new Error("captureFullPage can only run in the browser");Z(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)),l=Math.max(1,Math.round(o*r)),s=await je();Z(e.signal);let a=e.mime==="image/jpeg"?await s.toJpeg(t,{width:i,height:l,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await s.toPng(t,{width:i,height:l,pixelRatio:e.pixelRatio});return Z(e.signal),await Ke(a,e.mime)}}}function Wt(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function v(e,t,n){let o={kind:e,message:Wt(t)};return n&&(o.detail=n),o}var jt=12e3,Kt=2048,Zt=.92;function Ge(){return Date.now()}function Gt(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 Ye(e,t,n){let o=new Promise((i,l)=>{let s=setTimeout(()=>l(new Error("Timeout")),t);typeof s.unref=="function"&&s.unref();}),r=[e,o];return n&&r.push(Gt(n)),await Promise.race(r)}function Yt(e){if(!S())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function Jt(e){return !!(e?.element||e?.fullPage)}function Je(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 Qe(e){let{selectionElement:t,capture:n,signal:o}=e;if(!S()||!Jt(n))return;let r=Ge(),i=[],l=n?.timeoutMs??jt,s=n?.maxDimension??Kt,a=n?.mime??"image/png",c=n?.quality??Zt,u=n?.adapter??Ze(),d={},p=Yt(n);if(n?.element&&t)try{let m=t.getBoundingClientRect(),h=Math.min(1,s/Math.max(m.width,m.height)),E=Math.min(p,p*h),b=await Ye(Promise.resolve(u.captureElement(t,{...Je({mime:a,quality:c,pixelRatio:E,maxDimension:s,includeQuality:a==="image/jpeg",...o?{signal:o}:{}})})),l,o);d.element=b;}catch(m){if(o?.aborted)throw m;i.push(v("capture_failed",m,{target:"element"}));}if(n?.fullPage)try{let m=await Ye(Promise.resolve(u.captureFullPage(Je({mime:a,quality:c,pixelRatio:p,maxDimension:s,includeQuality:a==="image/jpeg",...o?{signal:o}:{}}))),l,o);d.fullPage=m;}catch(m){if(o?.aborted)throw m;i.push(v("capture_failed",m,{target:"fullPage"}));}let g=Ge(),f={startedAt:r,finishedAt:g,durationMs:Math.max(0,g-r)};return i.length>0&&(f.errors=i),{...d,diagnostics:f}}function Qt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function en(){return S()?{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:Qt()}:{}}function tn(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 et(e){let{config:t,context:n,user:o}=e;if(t?.enabled===false)return {};let r={...en(),...tn(o)},i=t?.enrich;if(!i)return r;try{let l=await i(n);return {...r,...l}}catch(l){let s=v("unknown",l);return {...r,blocfeedMetadataError:s.message}}}var Q="blocfeed-queue",nn=50;function _e(){if(!S())return [];try{let e=localStorage.getItem(Q);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(Q);}catch{}return []}catch(e){console.warn("[BlocFeed] offline queue could not be read \u2014 resetting",e);try{localStorage.removeItem(Q);}catch{}return []}}function ke(e){if(S())try{e.length===0?localStorage.removeItem(Q):localStorage.setItem(Q,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 on(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 Ce(e){let t=_e(),n=on(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>nn;)t.shift();ke(t);}function tt(){let e=_e();return e.length===0?[]:(ke([]),e.map(t=>t.payload))}function ho(){ke([]);}function bo(){return _e().length}var rn=200,ee=[],nt=0,ie=false;function ot(e){let t=e.target;if(!(t instanceof Element)||t.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-nt,path:window.location.pathname,tagName:t.tagName.toLowerCase()},o=N(t,100);o&&(n.textSnippet=o);let r=q(t)??ve(t);r&&(n.componentName=r),ee.length<rn&&ee.push(n);}var rt={capture:true,passive:true};function it(){ie||!S()||(ie=true,ee=[],nt=Date.now(),document.addEventListener("click",ot,rt));}function st(){ie&&(ie=false,document.removeEventListener("click",ot,rt));}function sn(){return [...ee]}function an(){ee=[];}var cn=3e4,ln=25e5,at="video/webm",un=250,dn=1e3,fn=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function ct(){if(typeof MediaRecorder>"u")return null;for(let e of fn)if(MediaRecorder.isTypeSupported(e))return e;return null}function pn(){return !S()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:ct()!==null}async function Te(e){let{config:t,signal:n}=e;if(!S()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw v("recording_failed",new Error("Screen recording is not supported in this browser"));let o=ct();if(!o)throw v("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw v("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(h){let E=h instanceof DOMException&&h.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw v("recording_failed",new Error(E))}if(n?.aborted)throw r.getTracks().forEach(h=>h.stop()),v("aborted",new Error("Recording aborted after permission"));let i=t?.maxDurationMs??cn,l=t?.videoBitsPerSecond??ln,s=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:l}),a=[],c=[],u=0,d=null,p=null,g=false,f=()=>{st(),d!==null&&(clearInterval(d),d=null),p!==null&&(clearTimeout(p),p=null),r.getTracks().forEach(h=>h.stop());},m=new Promise((h,E)=>{s.ondataavailable=k=>{k.data.size>0&&a.push(k.data);},s.onstop=()=>{if(g)return;g=true,f();let k=Date.now()-u,C=new Blob(a,{type:at}),y=URL.createObjectURL(C);h({mime:at,blobUrl:y,blob:C,durationMs:k,sizeBytes:C.size});},s.onerror=()=>{g||(g=true,f(),E(v("recording_failed",new Error("MediaRecorder error"))));};let b=r.getVideoTracks()[0];if(b&&b.addEventListener("ended",()=>{s.state!=="inactive"&&s.stop();}),n){let k=()=>{g||(g=true,s.state!=="inactive"&&s.stop(),f(),E(v("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",k,{once:true});}});return s.start(dn),it(),u=Date.now(),d=setInterval(()=>{let h=Date.now()-u;for(let E of c)E(h);},un),p=setTimeout(()=>{!g&&s.state!=="inactive"&&s.stop();},i),{result:m,stop(){!g&&s.state!=="inactive"&&s.stop();},onTick(h){c.push(h);},abort(){g||(g=true,s.state!=="inactive"&&s.stop(),f());}}}var mn=6e4,lt="audio/webm",gn=250,hn=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function ut(){if(typeof MediaRecorder>"u")return null;for(let e of hn)if(MediaRecorder.isTypeSupported(e))return e;return null}function bn(){return !S()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:ut()!==null}async function Re(e){let{config:t,signal:n}=e;if(!S()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw v("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=ut();if(!o)throw v("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw v("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(m){let h=m instanceof DOMException&&m.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw v("recording_failed",new Error(h))}if(n?.aborted)throw r.getTracks().forEach(m=>m.stop()),v("aborted",new Error("Voice recording aborted after permission"));let i=t?.maxDurationMs??mn,l=new MediaRecorder(r,{mimeType:o}),s=[],a=[],c=0,u=null,d=null,p=false,g=()=>{u!==null&&(clearInterval(u),u=null),d!==null&&(clearTimeout(d),d=null),r.getTracks().forEach(m=>m.stop());},f=new Promise((m,h)=>{if(l.ondataavailable=E=>{E.data.size>0&&s.push(E.data);},l.onstop=()=>{if(p)return;p=true,g();let E=Date.now()-c,b=new Blob(s,{type:lt});m({blob:b,mime:lt,durationMs:E});},l.onerror=()=>{p||(p=true,g(),h(v("recording_failed",new Error("MediaRecorder error"))));},n){let E=()=>{p||(p=true,l.state!=="inactive"&&l.stop(),g(),h(v("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",E,{once:true});}});return l.start(1e3),c=Date.now(),u=setInterval(()=>{let m=Date.now()-c;for(let h of a)h(m);},gn),d=setTimeout(()=>{d=null,!p&&l.state!=="inactive"&&l.stop();},i),{result:f,stop(){!p&&l.state!=="inactive"&&l.stop();},onTick(m){a.push(m);},abort(){p||(p=true,l.state!=="inactive"&&l.stop(),g());}}}var yn=12e3,wn=2,vn=500,En=2e3,xe="https://blocfeed.com/api/feedback",Sn="https://blocfeed.com/api/feedback/voice",dt=0,mt="blocfeed-viewer-token",gt="blocfeed-my-feedback-url";function _n(){try{return localStorage.getItem(mt)}catch{return null}}function Io(){try{return localStorage.getItem(gt)}catch{return null}}function kn(e,t){try{localStorage.setItem(mt,e),t&&localStorage.setItem(gt,t);}catch{}}function ft(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 Cn(e){return e>=500&&e<=599}function Tn(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),l=new Uint8Array(i.length);for(let s=0;s<i.length;s+=1)l[s]=i.charCodeAt(s);return new Blob([l],{type:r})}function Rn(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 pt(e,t,n){let o=Tn(t);await fetch(e,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function xn(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(`${xe}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function An(e){await fetch(`${xe}/${e.feedbackId}/video`,{method:"POST",body:e.blob,headers:{"content-type":e.blob.type},...e.signal?{signal:e.signal}:{}});}async function ht(e){let{signal:t,transport:n}=e;if(Date.now()-dt<En)return {ok:false,error:v("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??yn,i=n?.maxAttempts??wn,l=n?.backoffMs??vn,s=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),a=!!e.payload.video?.blob,c=s||a,{lean:u,extracted:d,extractedVideo:p}=c?Rn(e.payload):{lean:e.payload,extracted:{},extractedVideo:{}},g=_n();g&&(u.viewer_token=g);let f={...d,...e.screenshotDataUrls};for(let m=1;m<=i;m+=1){let h=new AbortController,E=setTimeout(()=>h.abort(),r),b=()=>h.abort();t&&t.addEventListener("abort",b,{once:true});try{let k=await fetch(xe,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(u),signal:h.signal});if(k.ok){dt=Date.now();let y;try{y=await k.json();}catch{}if(y?.viewer_token&&kn(y.viewer_token,y.my_feedback_url),(f.element||f.fullPage)&&y){let L=y.upload_urls;if(L){let V=[];f.element&&L.element&&V.push(pt(L.element,f.element,t)),f.fullPage&&L.fullPage&&V.push(pt(L.fullPage,f.fullPage,t));try{await Promise.all(V);}catch{}}else if(y.feedback_id)try{await xn({feedbackId:y.feedback_id,extracted:f,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}if(p.blob&&y){let L=y.upload_urls;if(L?.video)try{await fetch(L.video,{method:"PUT",body:p.blob,headers:{"content-type":p.blob.type},...t?{signal:t}:{}});}catch{}else if(y.feedback_id)try{await An({feedbackId:y.feedback_id,blob:p.blob,...t?{signal:t}:{}});}catch{}}let B={ok:!0,status:k.status};return y&&(B.apiResponse=y),B}if(m<i&&Cn(k.status)){let y=.85+Math.random()*.3,O=Math.round(l*2**(m-1)*y);await ft(O,t);continue}let C=`HTTP ${k.status}`;try{let y=await k.json();y?.error&&(C=y.error);}catch{}return {ok:!1,status:k.status,error:v("api_failed",new Error(C))}}catch(k){if(h.signal.aborted||t?.aborted)return {ok:false,error:v("aborted",k)};if(m<i){let C=.85+Math.random()*.3,y=Math.round(l*2**(m-1)*C);await ft(y,t);continue}return {ok:false,error:v("api_failed",k)}}finally{clearTimeout(E),t&&t.removeEventListener("abort",b);}}return {ok:false,error:v("api_failed",new Error("Failed"))}}async function bt(e){let{blob:t,mime:n,blocfeedId:o,signal:r}=e,i=await fetch(Sn,{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 v("api_failed",new Error(s?.error??`Voice API returned ${i.status}`))}let l=await i.json();return {text:l.text??"",warning:l.warning}}var Mn={enabled:true,sampling:1,ignoreSelectors:["[data-blocfeed-ui]","[data-blocfeed-ignore]"],rageClick:{enabled:true,threshold:3,windowMs:1e3},httpFail:{enabled:true,statusCodes:[400,401,403,422,500,502,503,504],ignoreUrls:["/api/behavioral-events","/api/feedback"]},redirectLoop:{enabled:true,threshold:3,windowMs:2e3},formDataLoss:{enabled:true},deadClick:{enabled:true,observationWindowMs:300,rateLimitPerSelector:5}};function yt(e){let t=Mn;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 wt(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"}),l=`${e.endpoint}?_bfid=${encodeURIComponent(e.blocfeedId)}`;try{navigator.sendBeacon(l,i);}catch{}}return {enqueue(r){t.push(r);},flush:n,flushBeacon:o,size(){return t.length}}}var vt="bf_behavioral_session",se=null;function P(){try{let e=sessionStorage.getItem(vt);if(e)return e;let t=Et();return sessionStorage.setItem(vt,t),t}catch{return se||(se=Et(),se)}}function Et(){let e=Math.random().toString(36).slice(2,10).padEnd(8,"0");return `bf_${Date.now()}_${e}`}function St(e,t){if(!e.rageClick.enabled)return ()=>{};let{threshold:n,windowMs:o}=e.rageClick,r=new Map;function i(l){try{let s=l.target;if(!s||!(s instanceof Element)||re(s,e.ignoreSelectors))return;let a=W(s,4);if(!a)return;let c=Date.now(),d=(r.get(a)??[]).filter(p=>c-p<=o);if(d.push(c),r.set(a,d),d.length>=n){let p=Fn(s),g=N(s,200)??null,f=s.tagName.toLowerCase(),m=s.id||null,h=q(s)??null,E=K(s,5),b={session_id:P(),event_type:"rage_click",page_url:typeof window>"u"?"":window.location.href,selector:a,element_text:g,event_data:{click_count:d.length,window_ms:o,...p?{disabled:!0}:{},tag_name:f,...m?{element_id:m}:{},...h?{component_name:h}:{},...E.length>0?{parent_components:E}:{}},created_at:new Date().toISOString()};t(b),r.set(a,[]);}}catch{}}return document.addEventListener("click",i,{capture:true,passive:true}),()=>document.removeEventListener("click",i,{capture:true})}function Fn(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 kt=0,Ct=null,ae=null,ce=[],Ln=1500;function Pn(){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;kt=Date.now();let r=o.closest("form");Ct=(r?W(r,3):"")||null,ae=N(o,100)??null,ce=K(o,5);}catch{}}return document.addEventListener("click",e,{capture:true,passive:true}),()=>document.removeEventListener("click",e,{capture:true})}function Tt(e,t){if(!e.httpFail.enabled)return ()=>{};let{statusCodes:n,ignoreUrls:o}=e.httpFail,r=new Set(n),i=Pn(),l=globalThis.fetch,s=async(d,p)=>{let g=typeof d=="string"?d:d instanceof URL?d.toString():d.url,f=(p?.method??d.method??"GET").toUpperCase(),m=await l.call(globalThis,d,p);try{!_t(g,o)&&r.has(m.status)&&t(u(m.status,g,f));}catch{}return m};globalThis.fetch=s;let a=XMLHttpRequest.prototype.open,c=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(d,p,...g){return this.__bf_url=p,this.__bf_method=d.toUpperCase(),a.call(this,d,p,...g)},XMLHttpRequest.prototype.send=function(d){let p=()=>{try{let g=this.__bf_url??"",f=this.__bf_method??"GET";!_t(g,o)&&r.has(this.status)&&t(u(this.status,g,f));}catch{}};return this.__bf_handler=p,this.addEventListener("loadend",p),c.call(this,d??null)},()=>{globalThis.fetch=l,XMLHttpRequest.prototype.open=a,XMLHttpRequest.prototype.send=c,i(),ae=null,ce=[];};function u(d,p,g){let m=Date.now()-kt<Ln;return {session_id:P(),event_type:"error",page_url:typeof window>"u"?"":window.location.href,selector:null,element_text:null,event_data:{http_status:d,request_url:p,method:g,form_selector:m?Ct:null,...m&&ae?{button_text:ae}:{},...m&&ce.length>0?{parent_components:ce}:{}},created_at:new Date().toISOString()}}}function _t(e,t){if(t.length===0)return false;for(let n of t)if(e.includes(n))return true;return false}var In=3e4;function Rt(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,l=history.pushState,s=history.replaceState;function a(u){try{let d=Date.now(),p=i.get(u)??0;if(d<p)return;let f=(r.get(u)??[]).filter(m=>d-m<=o);if(f.push(d),r.set(u,f),f.length>=n){let m={session_id:P(),event_type:"thrashing",page_url:window.location.href,selector:null,element_text:null,event_data:{count:f.length,url:u,window_ms:o},created_at:new Date().toISOString()};t(m),i.set(u,d+In),r.set(u,[]);}}catch{}}function c(){let u=window.location.pathname+window.location.search;a(u);}return history.pushState=function(...u){let d=l.apply(this,u);return c(),d},history.replaceState=function(...u){let d=s.apply(this,u);return c(),d},window.addEventListener("popstate",c),()=>{history.pushState=l,history.replaceState=s,window.removeEventListener("popstate",c);}}function xt(e,t){if(!e.formDataLoss.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let n=new Set,o=0;function r(c){let u=c.closest("form");return u?u.id?`#${u.id}`:"form":null}function i(c){try{let u=c.target;if(!u||!(u instanceof HTMLInputElement||u instanceof HTMLTextAreaElement||u instanceof HTMLSelectElement))return;let d=r(u);if(!d)return;n.has(d)||n.add(d),o++;}catch{}}function l(c){if(n.size===0)return;let u=Array.from(n),d={session_id:P(),event_type:"form_abandonment",page_url:window.location.href,selector:u[0]??null,element_text:null,event_data:{cause:c,field_count:o,forms:u},created_at:new Date().toISOString()};t(d);}function s(c){c.persisted&&l("bfcache_restore");}function a(){l("beforeunload_after_edit");}return document.addEventListener("input",i,{capture:true,passive:true}),window.addEventListener("pageshow",s),window.addEventListener("beforeunload",a),()=>{document.removeEventListener("input",i,{capture:true}),window.removeEventListener("pageshow",s),window.removeEventListener("beforeunload",a);}}function Bn(){let e={domMutationCount:0,urlChangeCount:0,networkCount:0,filePickerCount:0,uninstall:()=>{}},t=new MutationObserver(()=>{e.domMutationCount+=1;});t.observe(document.body,{childList:true,attributes:true,characterData:true,subtree:true});let n=history.pushState,o=history.replaceState;history.pushState=function(...a){return e.urlChangeCount+=1,n.apply(this,a)},history.replaceState=function(...a){return e.urlChangeCount+=1,o.apply(this,a)};let r=()=>{e.urlChangeCount+=1;};window.addEventListener("popstate",r);let i=globalThis.fetch;if(i){let a=(c,u)=>(e.networkCount+=1,i.call(globalThis,c,u));globalThis.fetch=a;}let l=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(a,c,...u){return e.networkCount+=1,l.call(this,a,c,...u)};let s=HTMLInputElement.prototype.click;return HTMLInputElement.prototype.click=function(){return this.type==="file"&&(e.filePickerCount+=1),s.call(this)},e.uninstall=()=>{t.disconnect(),history.pushState=n,history.replaceState=o,window.removeEventListener("popstate",r),i&&(globalThis.fetch=i),XMLHttpRequest.prototype.open=l,HTMLInputElement.prototype.click=s;},e}function At(e,t){if(!e.deadClick.enabled)return ()=>{};if(typeof window>"u")return ()=>{};let{observationWindowMs:n,rateLimitPerSelector:o}=e.deadClick,r=new Map,i=Bn();function l(s){try{let a=s.target;if(!a||!(a instanceof Element)||s.button!==0||s.metaKey||s.ctrlKey||s.altKey||s.shiftKey||re(a,e.ignoreSelectors)||a.closest("label"))return;if(a instanceof HTMLInputElement){let y=a.type;if(y==="checkbox"||y==="radio"||y==="file")return}if(a instanceof HTMLSelectElement||a.closest("a[target='_blank'], a[download]")||a.closest('[contenteditable="true"]'))return;try{let y=window.getSelection();if(y&&y.toString().length>0)return}catch{}let c=$e(a);if(!c)return;let u=W(a,4);if(!u)return;let d=i.domMutationCount,p=i.urlChangeCount,g=i.networkCount,f=i.filePickerCount,m=new Date().toISOString(),h=N(a,200)??null,E=a.tagName.toLowerCase(),b=a.id||null,k=q(a)??null,C=K(a,5);setTimeout(()=>{if(i.domMutationCount!==d||i.urlChangeCount!==p||i.networkCount!==g||i.filePickerCount!==f)return;let y=r.get(u)??0;if(y>=o)return;r.set(u,y+1);let O={session_id:P(),event_type:"dead_click",page_url:typeof window>"u"?"":window.location.href,selector:u,element_text:h,event_data:{tag_name:E,...b?{element_id:b}:{},...k?{component_name:k}:{},...C.length>0?{parent_components:C}:{},clickable_reason:c},created_at:m};t(O);},n);}catch{}}return document.addEventListener("click",l,{capture:true,passive:true}),()=>{document.removeEventListener("click",l,{capture:true}),i.uninstall();}}var Nn="https://blocfeed.com/api/replay-events";function Mt(e){if(!e.config.enabled)return ()=>{};if(typeof window>"u")return ()=>{};if(typeof globalThis.matchMedia>"u")return ()=>{};let t=P();if(Un(t)%100/100>=e.config.sampling)return ()=>{};let o=Date.now(),r=e.config.endpoint??Nn,i=[],l=0,s=false,a=null,c=`bf_replay_chunkseq_${t}`,u=0;try{let C=sessionStorage.getItem(c);C&&(u=parseInt(C,10)||0);}catch{}let d=(C=false)=>{if(i.length===0)return;let y=C?Hn(i):i;i=[],l=0;let O=u++;try{sessionStorage.setItem(c,String(u));}catch{}qn({blocfeedId:e.blocfeedId,sessionId:t,sessionStartedAtMs:o,chunkSeq:O,events:y,endpoint:r,useBeacon:C});},p=setInterval(()=>{s||d();},e.config.flushIntervalMs),g=setTimeout(()=>{d(),k();},e.config.maxDurationMs),f=null,m=()=>{f&&clearTimeout(f),f=setTimeout(()=>{d(),k();},e.config.inactivityTimeoutMs);};m();let h=()=>{d(true);};window.addEventListener("pagehide",h);let E=e.config.masking,b={emit(C){s||(i.push(C),l+=On(C),m(),l>=e.config.flushSizeBytes&&d());},recordCanvas:false,sampling:{mousemove:50}};E.maskAllInputs!==void 0&&(b.maskAllInputs=E.maskAllInputs),E.maskTextSelector!==void 0&&(b.maskTextSelector=E.maskTextSelector),E.maskTextClass!==void 0&&(b.maskTextClass=E.maskTextClass),E.blockSelector!==void 0&&(b.blockSelector=E.blockSelector),a=record(b)??null;function k(){if(!s&&(s=true,clearInterval(p),clearTimeout(g),f&&clearTimeout(f),window.removeEventListener("pagehide",h),a))try{a();}catch{}}return k}function On(e){try{return JSON.stringify(e).length}catch{return 1024}}function Un(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return Math.abs(t)}function Hn(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 qn(e){let t=JSON.stringify({blocfeed_id:e.blocfeedId,session_id:e.sessionId,session_started_at_ms:e.sessionStartedAtMs,chunk_seq:e.chunkSeq,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 Vn={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 Ft(e){let t=Vn;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 Xn=5e3,le=class{constructor(t){this.submitter=null;this.detectorUninstallers=[];this.flushTimer=null;this.pageHideHandler=null;this.installed=false;this.opts=t,this.resolved=yt(t.config);}install(){if(this.installed||!this.resolved.enabled||!(this.opts.passiveSampler??(()=>Math.random()<this.resolved.sampling))())return;let n=this.opts.endpoint??"https://blocfeed.com/api/behavioral-events";this.submitter=this.opts.submitter??wt({endpoint:n,blocfeedId:this.opts.blocfeedId});let o=i=>{this.submitter?.enqueue(i);};this.detectorUninstallers.push(St(this.resolved,o)),this.detectorUninstallers.push(Tt(this.resolved,o)),this.detectorUninstallers.push(Rt(this.resolved,o)),this.detectorUninstallers.push(xt(this.resolved,o)),this.detectorUninstallers.push(At(this.resolved,o));let r=Ft(this.opts.config?.sessionReplay);this.detectorUninstallers.push(Mt({blocfeedId:this.opts.blocfeedId,config:r})),this.flushTimer=setInterval(()=>{this.submitter?.flush();},Xn),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;}}};function Ae(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 ue(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function de(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function Lt(e,t){if(!S())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,l=null,s=(f,m=false)=>{if(!f){i=null,l=null,t.onHover(null);return}let h=we(f.getBoundingClientRect()),E=`${Math.round(h.x)}:${Math.round(h.y)}:${Math.round(h.width)}:${Math.round(h.height)}`;!m&&f===i&&E===l||(i=f,l=E,t.onHover({element:f,rect:h}));},a=Ae(f=>{if(ue(f.target))return;let m=document.elementFromPoint(f.clientX,f.clientY),h=Ee(m,r);s(h);}),c=Ae(()=>{i&&s(i,true);}),u=f=>{ue(f.target)||(de(f),f.pointerType==="mouse"&&f.preventDefault());},d=f=>{ue(f.target)||(de(f),f.pointerType==="mouse"&&f.preventDefault());},p=f=>{if(ue(f.target))return;de(f),f.preventDefault();let m=document.elementFromPoint(f.clientX,f.clientY),h=Ee(m,r);h&&t.onSelect({element:h,descriptor:We(h)});},g=f=>{f.key==="Escape"&&(de(f),f.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",a,{capture:true,passive:true}),window.addEventListener("pointerdown",u,{capture:true}),window.addEventListener("pointerup",d,{capture:true}),window.addEventListener("click",p,{capture:true}),window.addEventListener("keydown",g,{capture:true}),window.addEventListener("scroll",c,{capture:true,passive:true}),window.addEventListener("resize",c,{passive:true}),{stop(){window.removeEventListener("pointermove",a,{capture:true}),window.removeEventListener("pointerdown",u,{capture:true}),window.removeEventListener("pointerup",d,{capture:true}),window.removeEventListener("click",p,{capture:true}),window.removeEventListener("keydown",g,{capture:true}),window.removeEventListener("scroll",c,{capture:true}),window.removeEventListener("resize",c),a.cancel(),c.cancel(),t.onHover(null);}}}async function Me(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 ht(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:v("api_failed",r)},o.ok=false;}return {payload:e.payload,result:o}}var zn=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function $n(e){let t=[...zn,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function Pt(){return {phase:"idle"}}function Wn(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 Fr(e){let t=e,n=new le({blocfeedId:t.blocfeed_id??"",...t.behavioral!==void 0?{config:t.behavioral}:{}});n.install();let o=Pt(),r=new Set,i=new Set,l=null,s=null,a=null,c=null,u=0,d=null,p=null,g=null,f=null,m=false,h=()=>{for(let w of r)w(o);},E=w=>{for(let _ of i)_(w);},b=w=>{o=w,h();},k=()=>{u+=1,c?.abort(),c=null;},C=()=>{l?.stop(),l=null,E(null),a!==null&&S()&&(document.documentElement.style.cursor=a,a=null);},y=()=>{if(g){try{URL.revokeObjectURL(g.blobUrl);}catch{}g=null;}},O=()=>{p&&(p.abort(),p=null),y();},B=null,L=()=>{f&&(f.abort(),f=null),B&&(B.abort(),B=null);},V=()=>{k(),C(),O(),L(),s=null,b(Pt());},Ne=()=>{if(!S())return;C(),s=null;let w=$n(t.picker);a=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",b({phase:"picking"}),l=Lt(w,{onHover:E,onSelect:({element:_,descriptor:M})=>{s=_,C(),b({phase:"review",selection:M});},onCancel:()=>{V();}});},Oe=()=>{let w=tt();if(w.length!==0)for(let _ of w)Me({payload:_,...t.transport?{transport:t.transport}:{}}).catch(()=>{Ce(_);});};if(S()){setTimeout(Oe,1e3);let w=()=>Oe();window.addEventListener("online",w),d=()=>window.removeEventListener("online",w);}return {getState:()=>o,getConfig:()=>t,subscribe(w){return r.add(w),()=>r.delete(w)},subscribeHover(w){return i.add(w),()=>i.delete(w)},start(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||o.phase!=="picking"&&Ne();},stop(){V();},clearSelection(){o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording"||Ne();},setConfig(w){t=w;},async submit(w,_){if(!S()){let R=v("configuration",new Error("BlocFeed submit can only run in the browser"));return b({phase:"error",lastError:R}),{ok:false}}let M=t.blocfeed_id?.trim?.()??"";if(!M){let I={phase:"error",lastError:v("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return o.selection&&(I.selection=o.selection),b(I),{ok:false}}if(m)return {ok:false};if(o.phase==="capturing"||o.phase==="submitting"||o.phase==="recording")return {ok:false};m=true;let A=u+1;u=A,c?.abort(),c=new AbortController;let x=c.signal,T=o.selection,D=_?.capture?{...t.capture,..._.capture}:t.capture,X=!!(D?.element||D?.fullPage),G={phase:X?"capturing":"submitting"};T&&(G.selection=T),b(G);try{let R=X?await Qe({selectionElement:s,capture:D,signal:x}):void 0;if(x.aborted||u!==A)return {ok:!1};let I={phase:"submitting"};T&&(I.selection=T),R&&(I.capture=R),b(I);let U={};T&&(U.selection=T),R&&(U.capture=R);let Y=await et({config:t.metadata,context:U,...t.user?{user:t.user}:{}}),z={version:1,createdAt:new Date().toISOString(),blocfeed_id:M,message:w,metadata:Y};_?.category&&(z.category=_.category),t.user&&(z.user=t.user),T&&(z.selection=T),R&&(z.screenshots=R),g&&(z.video=g);let{result:H}=await Me({payload:z,signal:x,...t.transport?{transport:t.transport}:{}});if(x.aborted||u!==A)return H;if(H.ok){y(),s=null;let ye={phase:"success",lastSubmit:H};return T&&(ye.selection=T),R&&(ye.capture=R),b(ye),H}Wn(H)&&Ce(z);let Nt=H.api?.error??v("unknown",new Error("Submission failed")),be={phase:"error",lastSubmit:H,lastError:Nt};return T&&(be.selection=T),R&&(be.capture=R),b(be),H}catch(R){if(x.aborted||u!==A)return {ok:false};let U={phase:"error",lastError:x.aborted?v("aborted",R):v("unknown",R)};return T&&(U.selection=T),b(U),{ok:false}}finally{m=false,u===A&&(c=null);}},async startRecording(){if(o.phase!=="review"||!t.recording?.enabled||f||p)return;let w=o.selection,_={phase:"recording",recordingElapsedMs:0};w&&(_.selection=w),b(_);try{let M={config:t.recording};c&&(M.signal=c.signal);let A=await Te(M);p=A,A.onTick(D=>{if(o.phase==="recording"){let X={phase:"recording",recordingElapsedMs:D};w&&(X.selection=w),b(X);}});let x=await A.result;p=null,g=x;let T={phase:"review",video:x};w&&(T.selection=w),b(T);}catch(M){p=null;let x={phase:"review",lastError:M?.kind?M:v("recording_failed",M)};w&&(x.selection=w),b(x);}},stopRecording(){o.phase!=="recording"||!p||p.stop();},removeVideo(){y();let w=o.selection,_={phase:"review"};w&&(_.selection=w),b(_);},async startVoice(){if(o.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",o.phase,'(expected "review")');return}let w=t.voice;if(!w?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}if(p){console.warn("[BlocFeed] startVoice: ignored \u2014 a screen recording is already in progress");return}L();let _=o.selection,M={phase:"review",voiceRecording:true,voiceElapsedMs:0};_&&(M.selection=_),g&&(M.video=g),b(M);try{let A={config:w};c&&(A.signal=c.signal);let x=await Re(A);f=x,x.onTick(U=>{let Y={phase:"review",voiceRecording:!0,voiceElapsedMs:U};_&&(Y.selection=_),g&&(Y.video=g),b(Y);});let T=await x.result;f=null;let D={phase:"review",voiceRecording:!1,voiceTranscribing:!0};_&&(D.selection=_),g&&(D.video=g),b(D),B=new AbortController;let X={blob:T.blob,mime:T.mime,blocfeedId:t.blocfeed_id,signal:B.signal},{text:Ue,warning:G}=await bt(X);B=null;let R={phase:"review",voiceRecording:!1,voiceTranscribing:!1};_&&(R.selection=_),g&&(R.video=g),b(R);let I={text:Ue};return G&&(I.warning=G),I}catch(A){L();let x=A?.kind?A:v("recording_failed",A);console.warn("[BlocFeed] Voice error:",x.message);let T={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:x};_&&(T.selection=_),g&&(T.video=g),b(T);return}},stopVoice(){f&&f.stop();},__unsafeGetSelectedElement(){return s},destroy(){n.uninstall(),V(),r.clear(),i.clear(),d?.(),d=null;}}}var te=[],ne=[],It=20,Bt=15,fe=[],Dt=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)}:{},pe=typeof globalThis<"u"&&typeof globalThis.fetch=="function"?globalThis.fetch:void 0,me=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.open:void 0,ge=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.send:void 0,Le=new Set,Pe=false,Ie=false,he=false,jn=["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 Kn(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 Zn(e,t){let n=t.map(Kn).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)),te.push(r);te.length>It;)te.shift();}function Fe(e){let t=e.url.toLowerCase();for(let n of fe)if(t.includes(n))return;for(ne.push(e);ne.length>Bt;)ne.shift();}function Ir(e={}){if(he||!S())return;he=true,It=e.consoleLimit??20,Bt=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?fe=t.map(n=>n.toLowerCase()):fe=[...jn],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let o of n){let r=Dt[o];r&&(Le.add(o),console[o]=(...i)=>{Zn(o,i),r.apply(console,i);});}}if(e.network!==false&&pe){let n=pe;Pe=true,window.fetch=async function(r,i){let l=typeof r=="string"?r:r instanceof URL?r.toString():r.url,s=(i?.method??"GET").toUpperCase(),a=Date.now();try{let c=await n.call(window,r,i);return c.ok||Fe({url:l.slice(0,500),method:s,status:c.status,statusText:c.statusText,timestamp:a,durationMs:Date.now()-a}),c}catch(c){throw Fe({url:l.slice(0,500),method:s,status:0,statusText:c instanceof Error?c.message:"Network error",timestamp:a,durationMs:Date.now()-a}),c}};}if(e.network!==false&&me&&ge){let n=me,o=ge;Ie=true,XMLHttpRequest.prototype.open=function(r,i,...l){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...l])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",l=this.__bf_url||"",s=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let a={url:l.slice(0,500),method:i,status:this.status,timestamp:s,durationMs:Date.now()-s};this.statusText&&(a.statusText=this.statusText),Fe(a);}},{once:true}),o.apply(this,r)};}}function Br(){if(he){for(let e of Le){let t=Dt[e];t&&(console[e]=t);}Le.clear(),Pe&&pe&&(window.fetch=pe,Pe=false),Ie&&me&&ge&&(XMLHttpRequest.prototype.open=me,XMLHttpRequest.prototype.send=ge,Ie=false),fe=[],he=false;}}function Dr(){return {consoleLogs:[...te],networkErrors:[...ne]}}function Nr(){te=[],ne=[];}var Gn=[{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}/}],j=[],De=0,Be=false;function Yn(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function Jn(e,t,n,o){if(j.some(l=>l.rule===e&&l.source===t))return;let i={rule:e,source:t,hint:Yn(n),timestamp:Date.now()};o&&(i.location=o),j.push(i);}function oe(e,t,n,o){for(let{name:r,pattern:i}of n){let l=i.exec(e);l&&Jn(r,t,l[0],o);}}function Qn(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);oe(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);oe(n,"hydration",e,"__NUXT__");}}catch{}}function eo(e){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&oe(r,"scripts",e,`inline-script[${o}]`);});}catch{}}function to(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let o=n.getAttribute("content"),r=n.getAttribute("name")||n.getAttribute("property")||"";o&&o.length>10&&oe(o,"meta",e,r?`meta[${r}]`:void 0);});}catch{}}function no(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&&oe(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function Hr(e={}){if(Be||!S()||(Be=true,e.secretScan===false))return;let t=[...Gn,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{De=Date.now(),n.includes("hydration")&&Qn(t),n.includes("scripts")&&eo(t),n.includes("meta")&&to(t),n.includes("dom")&&no(t);let o=e.notify??"both";j.length>0&&(o==="console"||o==="both")&&console.warn(`[BlocFeed Security] Found ${j.length} potential secret(s) exposed in client code:`,j.map(r=>`${r.rule} (${r.source}${r.location?`: ${r.location}`:""})`));},100);}function qr(){return {findings:[...j],scannedAt:De}}function Vr(){j=[],De=0,Be=false;}
|
|
2
|
-
export{Vr as A,S as a,we as b,Ze as c,Qe as d,et as e,Ce as f,tt as g,ho as h,bo as i,sn as j,an as k,pn as l,Te as m,bn as n,Re as o,_n as p,Io as q,bt as r,le as s,Fr as t,Ir as u,Br as v,Dr as w,Nr as x,Hr as y,qr as z};
|