blocfeed 0.11.3 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-EADEWOWW.js +2 -0
- package/dist/chunk-VK43CZAG.cjs +2 -0
- package/dist/{controller-KZyWlj27.d.cts → controller-JCtPYbzs.d.cts} +2 -0
- package/dist/{controller-KZyWlj27.d.ts → controller-JCtPYbzs.d.ts} +2 -0
- package/dist/engine.cjs +1 -1
- package/dist/engine.d.cts +7 -3
- package/dist/engine.d.ts +7 -3
- package/dist/engine.js +1 -1
- package/dist/main.cjs +43 -4
- package/dist/main.d.cts +2 -2
- package/dist/main.d.ts +2 -2
- package/dist/main.js +43 -4
- package/package.json +1 -1
- package/dist/chunk-A6OH75KK.js +0 -2
- package/dist/chunk-FM72GX3J.cjs +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function E(){return typeof window<"u"&&typeof document<"u"}function Re(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 ae(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function at(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function ct(e){return e.replace(/\s+/g," ").trim()}function ce(e,t=140){let n=e.textContent;if(!n)return;let o=ct(n);if(o)return o.length<=t?o:`${o.slice(0,t-1)}\u2026`}function lt(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var Ce=["data-testid","data-test-id","data-test","data-qa","data-cy"],Ae="data-blocfeed-component";function le(e){let t=e.closest(`[${Ae}]`);if(!t)return;let o=t.getAttribute(Ae)?.trim();return o||void 0}function ut(e){for(let t of Ce){let n=e.closest(`[${t}]`);if(!n)continue;let r=n.getAttribute(t)?.trim();if(r)return r}}function xe(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 O(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 $(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!O(t.name))return t.name}}function C(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 C(r)}}}function ue(e){let t=xe(e);if(!t)return;let n=$(t._debugInfo);if(n)return n;let o=t._debugOwner!==void 0;if(o){let c=t._debugOwner;for(let d=0;c&&d<50;d+=1){let w=$(c._debugInfo);if(w)return w;let g=C(c.type)??C(c.elementType);if(g&&!O(g))return g;c=c._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let c=t._owner;for(let d=0;c&&d<50;d+=1){let w=$(c._debugInfo);if(w)return w;let g=C(c.type)??C(c.elementType);if(g&&!O(g))return g;c=c._owner;}}let i=t,s=o?80:25;for(let c=0;i&&c<s;c+=1){let d=$(i._debugInfo);if(d)return d;let w=C(i.type)??C(i.elementType);if(w&&!O(w))return w;i=i.return;}let a=e.parentElement;for(let c=0;a&&c<15;c+=1){let d=xe(a);if(d){let w=$(d._debugInfo);if(w)return w;let g=C(d.type)??C(d.elementType);if(g&&!O(g))return g;if(d._debugOwner){let u=C(d._debugOwner.type)??C(d._debugOwner.elementType);if(u&&!O(u))return u}if(d._owner&&d._owner!==d._debugOwner){let u=C(d._owner.type)??C(d._owner.elementType);if(u&&!O(u))return u}}a=a.parentElement;}}function dt(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${Re(n)}`;for(let o of Ce){let r=e.getAttribute(o);if(r)return `${t}[${o}="${Re(r)}"]`}return `${t}:nth-of-type(${lt(e)})`}function ft(e,t=10){let n=[],o=e;for(;o&&n.length<t;){let r=dt(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}function Pe(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function de(e,t){if(!e||Pe(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(Pe(n,t.ignoreSelectors))return null;if(t.isSelectable?.(n)??mt(n))return n;n=n.parentElement;}return null}function mt(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function Fe(e){let t=e.getBoundingClientRect(),n={selector:ft(e),tagName:e.tagName.toLowerCase(),rect:ae(t),pageRect:at(t)},o=e.getAttribute("id");o&&(n.id=o);let r=e.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=ce(e);i&&(n.textSnippet=i);let s=le(e)??ue(e);s&&(n.componentName=s);let a=ut(e);return a&&(n.testId=a),n}var fe=null;async function Me(){return fe||(fe=import('html-to-image')),fe}async function pt(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 Ie(e,t){let{width:n,height:o}=await pt(e);return {dataUrl:e,mime:t,width:n,height:o}}function V(e){if(e?.aborted)throw new Error("Aborted")}function Be(){return {async captureElement(e,t){if(!E())throw new Error("captureElement can only run in the browser");V(t.signal);let n=await Me();V(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 V(t.signal),await Ie(o,t.mime)},async captureFullPage(e){if(!E())throw new Error("captureFullPage can only run in the browser");V(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)),s=Math.max(1,Math.round(o*r)),a=await Me();V(e.signal);let c=e.mime==="image/jpeg"?await a.toJpeg(t,{width:i,height:s,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await a.toPng(t,{width:i,height:s,pixelRatio:e.pixelRatio});return V(e.signal),await Ie(c,e.mime)}}}function gt(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function h(e,t,n){let o={kind:e,message:gt(t)};return n&&(o.detail=n),o}var ht=12e3,wt=2048,bt=.92;function De(){return Date.now()}function yt(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 Le(e,t,n){let o=new Promise((i,s)=>{let a=setTimeout(()=>s(new Error("Timeout")),t);typeof a.unref=="function"&&a.unref();}),r=[e,o];return n&&r.push(yt(n)),await Promise.race(r)}function Et(e){if(!E())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function vt(e){return !!(e?.element||e?.fullPage)}function Ne(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 Oe(e){let{selectionElement:t,capture:n,signal:o}=e;if(!E()||!vt(n))return;let r=De(),i=[],s=n?.timeoutMs??ht,a=n?.maxDimension??wt,c=n?.mime??"image/png",d=n?.quality??bt,w=n?.adapter??Be(),g={},u=Et(n);if(n?.element&&t)try{let p=t.getBoundingClientRect(),l=Math.min(1,a/Math.max(p.width,p.height)),k=Math.min(u,u*l),P=await Le(Promise.resolve(w.captureElement(t,{...Ne({mime:c,quality:d,pixelRatio:k,maxDimension:a,includeQuality:c==="image/jpeg",...o?{signal:o}:{}})})),s,o);g.element=P;}catch(p){if(o?.aborted)throw p;i.push(h("capture_failed",p,{target:"element"}));}if(n?.fullPage)try{let p=await Le(Promise.resolve(w.captureFullPage(Ne({mime:c,quality:d,pixelRatio:u,maxDimension:a,includeQuality:c==="image/jpeg",...o?{signal:o}:{}}))),s,o);g.fullPage=p;}catch(p){if(o?.aborted)throw p;i.push(h("capture_failed",p,{target:"fullPage"}));}let b=De(),f={startedAt:r,finishedAt:b,durationMs:Math.max(0,b-r)};return i.length>0&&(f.errors=i),{...g,diagnostics:f}}function St(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function kt(){return E()?{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:St()}:{}}function _t(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 Ue(e){let{config:t,context:n,user:o}=e;if(t?.enabled===false)return {};let r={...kt(),..._t(o)},i=t?.enrich;if(!i)return r;try{let s=await i(n);return {...r,...s}}catch(s){let a=h("unknown",s);return {...r,blocfeedMetadataError:a.message}}}var me="blocfeed-queue",Tt=50;function pe(){if(!E())return [];try{let e=localStorage.getItem(me);if(!e)return [];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return []}}function ge(e){if(E())try{e.length===0?localStorage.removeItem(me):localStorage.setItem(me,JSON.stringify(e));}catch{}}function Rt(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 he(e){let t=pe(),n=Rt(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>Tt;)t.shift();ge(t);}function Ve(){let e=pe();return e.length===0?[]:(ge([]),e.map(t=>t.payload))}function _n(){ge([]);}function Tn(){return pe().length}var At=200,X=[],He=0,ee=false;function qe(e){let t=e.target;if(!(t instanceof Element)||t.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-He,path:window.location.pathname,tagName:t.tagName.toLowerCase()},o=ce(t,100);o&&(n.textSnippet=o);let r=le(t)??ue(t);r&&(n.componentName=r),X.length<At&&X.push(n);}function ze(){ee||!E()||(ee=true,X=[],He=Date.now(),document.addEventListener("click",qe,{capture:true,passive:true}));}function je(){ee&&(ee=false,document.removeEventListener("click",qe,{capture:true}));}function xt(){return [...X]}function Pt(){X=[];}var Ct=3e4,Ft=25e5,$e="video/webm",Mt=250,It=1e3,Bt=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function Xe(){if(typeof MediaRecorder>"u")return null;for(let e of Bt)if(MediaRecorder.isTypeSupported(e))return e;return null}function Dt(){return !E()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:Xe()!==null}async function we(e){let{config:t,signal:n}=e;if(!E()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw h("recording_failed",new Error("Screen recording is not supported in this browser"));let o=Xe();if(!o)throw h("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw h("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(l){let k=l instanceof DOMException&&l.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw h("recording_failed",new Error(k))}if(n?.aborted)throw r.getTracks().forEach(l=>l.stop()),h("aborted",new Error("Recording aborted after permission"));let i=t?.maxDurationMs??Ct,s=t?.videoBitsPerSecond??Ft,a=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:s}),c=[],d=[],w=0,g=null,u=null,b=false,f=()=>{je(),g!==null&&(clearInterval(g),g=null),u!==null&&(clearTimeout(u),u=null),r.getTracks().forEach(l=>l.stop());},p=new Promise((l,k)=>{a.ondataavailable=T=>{T.data.size>0&&c.push(T.data);},a.onstop=()=>{if(b)return;b=true,f();let T=Date.now()-w,F=new Blob(c,{type:$e}),v=URL.createObjectURL(F);l({mime:$e,blobUrl:v,blob:F,durationMs:T,sizeBytes:F.size});},a.onerror=()=>{b||(b=true,f(),k(h("recording_failed",new Error("MediaRecorder error"))));};let P=r.getVideoTracks()[0];if(P&&P.addEventListener("ended",()=>{a.state!=="inactive"&&a.stop();}),n){let T=()=>{b||(b=true,a.state!=="inactive"&&a.stop(),f(),k(h("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",T,{once:true});}});return a.start(It),ze(),w=Date.now(),g=setInterval(()=>{let l=Date.now()-w;for(let k of d)k(l);},Mt),u=setTimeout(()=>{!b&&a.state!=="inactive"&&a.stop();},i),{result:p,stop(){!b&&a.state!=="inactive"&&a.stop();},onTick(l){d.push(l);},abort(){b||(b=true,a.state!=="inactive"&&a.stop(),f());}}}var Lt=6e4,Ze="audio/webm",Nt=250,Ot=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function Ke(){if(typeof MediaRecorder>"u")return null;for(let e of Ot)if(MediaRecorder.isTypeSupported(e))return e;return null}function Ut(){return !E()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:Ke()!==null}async function be(e){let{config:t,signal:n}=e;if(!E()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw h("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=Ke();if(!o)throw h("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw h("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(p){let l=p instanceof DOMException&&p.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw h("recording_failed",new Error(l))}if(n?.aborted)throw r.getTracks().forEach(p=>p.stop()),h("aborted",new Error("Voice recording aborted after permission"));let i=t?.maxDurationMs??Lt,s=new MediaRecorder(r,{mimeType:o}),a=[],c=[],d=0,w=null,g=null,u=false,b=()=>{w!==null&&(clearInterval(w),w=null),g!==null&&(clearTimeout(g),g=null),r.getTracks().forEach(p=>p.stop());},f=new Promise((p,l)=>{if(s.ondataavailable=k=>{k.data.size>0&&a.push(k.data);},s.onstop=()=>{if(u)return;u=true,b();let k=Date.now()-d,P=new Blob(a,{type:Ze});p({blob:P,mime:Ze,durationMs:k});},s.onerror=()=>{u||(u=true,b(),l(h("recording_failed",new Error("MediaRecorder error"))));},n){let k=()=>{u||(u=true,s.state!=="inactive"&&s.stop(),b(),l(h("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",k,{once:true});}});return s.start(1e3),d=Date.now(),w=setInterval(()=>{let p=Date.now()-d;for(let l of c)l(p);},Nt),g=setTimeout(()=>{!u&&s.state!=="inactive"&&s.stop();},i),{result:f,stop(){!u&&s.state!=="inactive"&&s.stop();},onTick(p){c.push(p);},abort(){u||(u=true,s.state!=="inactive"&&s.stop(),b());}}}var Vt=12e3,Ht=2,qt=500,zt=2e3,ye="https://blocfeed.com/api/feedback",jt="https://blocfeed.com/api/feedback/voice",We=0,Ge="blocfeed-viewer-token",Je="blocfeed-my-feedback-url";function $t(){try{return localStorage.getItem(Ge)}catch{return null}}function qn(){try{return localStorage.getItem(Je)}catch{return null}}function Xt(e,t){try{localStorage.setItem(Ge,e),t&&localStorage.setItem(Je,t);}catch{}}function Qe(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 Zt(e){return e>=500&&e<=599}function Kt(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),s=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)s[a]=i.charCodeAt(a);return new Blob([s],{type:r})}function Wt(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 Ye(e,t,n){let o=Kt(t);await fetch(e,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function Qt(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(`${ye}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function Yt(e){await fetch(`${ye}/${e.feedbackId}/video`,{method:"POST",body:e.blob,headers:{"content-type":e.blob.type},...e.signal?{signal:e.signal}:{}});}async function et(e){let{signal:t,transport:n}=e;if(Date.now()-We<zt)return {ok:false,error:h("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??Vt,i=n?.maxAttempts??Ht,s=n?.backoffMs??qt,a=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),c=!!e.payload.video?.blob,d=a||c,{lean:w,extracted:g,extractedVideo:u}=d?Wt(e.payload):{lean:e.payload,extracted:{},extractedVideo:{}},b=$t();b&&(w.viewer_token=b);let f={...g,...e.screenshotDataUrls};for(let p=1;p<=i;p+=1){let l=new AbortController,k=setTimeout(()=>l.abort(),r),P=()=>l.abort();t&&t.addEventListener("abort",P,{once:true});try{let T=await fetch(ye,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(w),signal:l.signal});if(T.ok){We=Date.now();let v;try{v=await T.json();}catch{}if(v?.viewer_token&&Xt(v.viewer_token,v.my_feedback_url),(f.element||f.fullPage)&&v){let m=v.upload_urls;if(m){let y=[];f.element&&m.element&&y.push(Ye(m.element,f.element,t)),f.fullPage&&m.fullPage&&y.push(Ye(m.fullPage,f.fullPage,t));try{await Promise.all(y);}catch{}}else if(v.feedback_id)try{await Qt({feedbackId:v.feedback_id,extracted:f,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}if(u.blob&&v){let m=v.upload_urls;if(m?.video)try{await fetch(m.video,{method:"PUT",body:u.blob,headers:{"content-type":u.blob.type},...t?{signal:t}:{}});}catch{}else if(v.feedback_id)try{await Yt({feedbackId:v.feedback_id,blob:u.blob,...t?{signal:t}:{}});}catch{}}let q={ok:!0,status:T.status};return v&&(q.apiResponse=v),q}if(p<i&&Zt(T.status)){let v=.85+Math.random()*.3,H=Math.round(s*2**(p-1)*v);await Qe(H,t);continue}let F=`HTTP ${T.status}`;try{let v=await T.json();v?.error&&(F=v.error);}catch{}return {ok:!1,status:T.status,error:h("api_failed",new Error(F))}}catch(T){if(l.signal.aborted||t?.aborted)return {ok:false,error:h("aborted",T)};if(p<i){let F=.85+Math.random()*.3,v=Math.round(s*2**(p-1)*F);await Qe(v,t);continue}return {ok:false,error:h("api_failed",T)}}finally{clearTimeout(k),t&&t.removeEventListener("abort",P);}}return {ok:false,error:h("api_failed",new Error("Failed"))}}async function tt(e){let{blob:t,mime:n,blocfeedId:o,signal:r}=e,i=await fetch(jt,{method:"POST",headers:{"Content-Type":n,"X-Blocfeed-Id":o},body:t,...r?{signal:r}:{}});if(!i.ok){let a=await i.json().catch(()=>({error:"Unknown error"}));throw h("api_failed",new Error(a?.error??`Voice API returned ${i.status}`))}let s=await i.json();return {text:s.text??"",warning:s.warning}}function Ee(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 te(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function ne(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function nt(e,t){if(!E())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,s=null,a=(f,p=false)=>{if(!f){i=null,s=null,t.onHover(null);return}let l=ae(f.getBoundingClientRect()),k=`${Math.round(l.x)}:${Math.round(l.y)}:${Math.round(l.width)}:${Math.round(l.height)}`;!p&&f===i&&k===s||(i=f,s=k,t.onHover({element:f,rect:l}));},c=Ee(f=>{if(te(f.target))return;let p=document.elementFromPoint(f.clientX,f.clientY),l=de(p,r);a(l);}),d=Ee(()=>{i&&a(i,true);}),w=f=>{te(f.target)||(ne(f),f.pointerType==="mouse"&&f.preventDefault());},g=f=>{te(f.target)||(ne(f),f.pointerType==="mouse"&&f.preventDefault());},u=f=>{if(te(f.target))return;ne(f),f.preventDefault();let p=document.elementFromPoint(f.clientX,f.clientY),l=de(p,r);l&&t.onSelect({element:l,descriptor:Fe(l)});},b=f=>{f.key==="Escape"&&(ne(f),f.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",c,{capture:true,passive:true}),window.addEventListener("pointerdown",w,{capture:true}),window.addEventListener("pointerup",g,{capture:true}),window.addEventListener("click",u,{capture:true}),window.addEventListener("keydown",b,{capture:true}),window.addEventListener("scroll",d,{capture:true,passive:true}),window.addEventListener("resize",d,{passive:true}),{stop(){window.removeEventListener("pointermove",c,{capture:true}),window.removeEventListener("pointerdown",w,{capture:true}),window.removeEventListener("pointerup",g,{capture:true}),window.removeEventListener("click",u,{capture:true}),window.removeEventListener("keydown",b,{capture:true}),window.removeEventListener("scroll",d,{capture:true}),window.removeEventListener("resize",d),c.cancel(),d.cancel(),t.onHover(null);}}}async function ve(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 et(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:h("api_failed",r)},o.ok=false;}return {payload:e.payload,result:o}}var Gt=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function Jt(e){let t=[...Gt,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function ot(){return {phase:"idle"}}function en(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 ao(e){let t=e,n=ot(),o=new Set,r=new Set,i=null,s=null,a=null,c=null,d=0,w=null,g=null,u=null,b=null,f=()=>{for(let m of o)m(n);},p=m=>{for(let y of r)y(m);},l=m=>{n=m,f();},k=()=>{d+=1,c?.abort(),c=null;},P=()=>{i?.stop(),i=null,p(null),a!==null&&E()&&(document.documentElement.style.cursor=a,a=null);},T=()=>{g&&(g.abort(),g=null),u&&(URL.revokeObjectURL(u.blobUrl),u=null);},F=()=>{b&&(b.abort(),b=null);},v=()=>{k(),P(),T(),F(),s=null,l(ot());},H=()=>{if(!E())return;P(),s=null;let m=Jt(t.picker);a=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",l({phase:"picking"}),i=nt(m,{onHover:p,onSelect:({element:y,descriptor:x})=>{s=y,P(),l({phase:"review",selection:x});},onCancel:()=>{v();}});},q=()=>{let m=Ve();if(m.length!==0)for(let y of m)ve({payload:y,...t.transport?{transport:t.transport}:{}}).catch(()=>{he(y);});};if(E()){setTimeout(q,1e3);let m=()=>q();window.addEventListener("online",m),w=()=>window.removeEventListener("online",m);}return {getState:()=>n,getConfig:()=>t,subscribe(m){return o.add(m),()=>o.delete(m)},subscribeHover(m){return r.add(m),()=>r.delete(m)},start(){n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording"||n.phase!=="picking"&&H();},stop(){v();},clearSelection(){n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording"||H();},setConfig(m){t=m;},async submit(m,y){if(!E()){let _=h("configuration",new Error("BlocFeed submit can only run in the browser"));return l({phase:"error",lastError:_}),{ok:false}}let x=t.blocfeed_id?.trim?.()??"";if(!x){let M={phase:"error",lastError:h("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return n.selection&&(M.selection=n.selection),l(M),{ok:false}}if(n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording")return {ok:false};let A=d+1;d=A,c?.abort(),c=new AbortController;let R=c.signal,S=n.selection,I=y?.capture?{...t.capture,...y.capture}:t.capture,B=!!(I?.element||I?.fullPage),z={phase:B?"capturing":"submitting"};S&&(z.selection=S),l(z);try{let _=B?await Oe({selectionElement:s,capture:I,signal:R}):void 0;if(R.aborted||d!==A)return {ok:!1};let M={phase:"submitting"};S&&(M.selection=S),_&&(M.capture=_),l(M);let D={};S&&(D.selection=S),_&&(D.capture=_);let j=await Ue({config:t.metadata,context:D,...t.user?{user:t.user}:{}}),N={version:1,createdAt:new Date().toISOString(),blocfeed_id:x,message:m,metadata:j};y?.category&&(N.category=y.category),t.user&&(N.user=t.user),S&&(N.selection=S),_&&(N.screenshots=_),u&&(N.video=u);let{result:L}=await ve({payload:N,signal:R,...t.transport?{transport:t.transport}:{}});if(R.aborted||d!==A)return L;if(L.ok){u&&(URL.revokeObjectURL(u.blobUrl),u=null);let se={phase:"success",lastSubmit:L};return S&&(se.selection=S),_&&(se.capture=_),l(se),L}en(L)&&he(N);let st=L.api?.error??h("unknown",new Error("Submission failed")),ie={phase:"error",lastSubmit:L,lastError:st};return S&&(ie.selection=S),_&&(ie.capture=_),l(ie),L}catch(_){if(R.aborted||d!==A)return {ok:false};let D={phase:"error",lastError:R.aborted?h("aborted",_):h("unknown",_)};return S&&(D.selection=S),l(D),{ok:false}}finally{d===A&&(c=null);}},async startRecording(){if(n.phase!=="review"||!t.recording?.enabled)return;let m=n.selection,y={phase:"recording",recordingElapsedMs:0};m&&(y.selection=m),l(y);try{let x={config:t.recording};c&&(x.signal=c.signal);let A=await we(x);g=A,A.onTick(I=>{if(n.phase==="recording"){let B={phase:"recording",recordingElapsedMs:I};m&&(B.selection=m),l(B);}});let R=await A.result;g=null,u=R;let S={phase:"review",video:R};m&&(S.selection=m),l(S);}catch(x){g=null;let R={phase:"review",lastError:x?.kind?x:h("recording_failed",x)};m&&(R.selection=m),l(R);}},stopRecording(){n.phase!=="recording"||!g||g.stop();},removeVideo(){u&&(URL.revokeObjectURL(u.blobUrl),u=null);let m=n.selection,y={phase:"review"};m&&(y.selection=m),l(y);},async startVoice(){if(n.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",n.phase,'(expected "review")');return}let m=t.voice;if(!m?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}F();let y=n.selection,x={phase:"review",voiceRecording:true,voiceElapsedMs:0};y&&(x.selection=y),u&&(x.video=u),l(x);try{let A={config:m};c&&(A.signal=c.signal);let R=await be(A);b=R,R.onTick(D=>{let j={phase:"review",voiceRecording:!0,voiceElapsedMs:D};y&&(j.selection=y),u&&(j.video=u),l(j);});let S=await R.result;b=null;let I={phase:"review",voiceRecording:!1,voiceTranscribing:!0};y&&(I.selection=y),u&&(I.video=u),l(I);let B={blob:S.blob,mime:S.mime,blocfeedId:t.blocfeed_id};c&&(B.signal=c.signal);let{text:Te,warning:z}=await tt(B),_={phase:"review",voiceRecording:!1,voiceTranscribing:!1};y&&(_.selection=y),u&&(_.video=u),l(_);let M={text:Te};return z&&(M.warning=z),M}catch(A){F();let R=A?.kind?A:h("recording_failed",A);console.warn("[BlocFeed] Voice error:",R.message);let S={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:R};y&&(S.selection=y),u&&(S.video=u),l(S);return}},stopVoice(){b&&b.stop();},__unsafeGetSelectedElement(){return s},destroy(){v(),o.clear(),r.clear(),w?.(),w=null;}}}var Z=[],K=[],rt=20,it=15,oe=[],W={},Q=null,Y=null,G=null,re=false,tn=["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 nn(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function on(e,t){let n=t.map(nn).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)),Z.push(r);Z.length>rt;)Z.shift();}function Se(e){let t=e.url.toLowerCase();for(let n of oe)if(t.includes(n))return;for(K.push(e);K.length>it;)K.shift();}function uo(e={}){if(re||!E())return;re=true,rt=e.consoleLimit??20,it=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?oe=t.map(n=>n.toLowerCase()):oe=[...tn],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let o of n)W[o]=console[o],console[o]=(...r)=>{on(o,r),W[o]?.apply(console,r);};}if(e.network!==false&&typeof window.fetch=="function"){Q=window.fetch;let n=Q;window.fetch=async function(r,i){let s=typeof r=="string"?r:r instanceof URL?r.toString():r.url,a=(i?.method??"GET").toUpperCase(),c=Date.now();try{let d=await n.call(window,r,i);return d.ok||Se({url:s.slice(0,500),method:a,status:d.status,statusText:d.statusText,timestamp:c,durationMs:Date.now()-c}),d}catch(d){throw Se({url:s.slice(0,500),method:a,status:0,statusText:d instanceof Error?d.message:"Network error",timestamp:c,durationMs:Date.now()-c}),d}};}if(e.network!==false&&typeof XMLHttpRequest<"u"){Y=XMLHttpRequest.prototype.open,G=XMLHttpRequest.prototype.send;let n=Y,o=G;XMLHttpRequest.prototype.open=function(r,i,...s){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...s])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",s=this.__bf_url||"",a=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let c={url:s.slice(0,500),method:i,status:this.status,timestamp:a,durationMs:Date.now()-a};this.statusText&&(c.statusText=this.statusText),Se(c);}}),o.apply(this,r)};}}function fo(){if(re){for(let[e,t]of Object.entries(W))console[e]=t;for(let e of Object.keys(W))delete W[e];Q&&(window.fetch=Q,Q=null),Y&&(XMLHttpRequest.prototype.open=Y,Y=null),G&&(XMLHttpRequest.prototype.send=G,G=null),oe=[],re=false;}}function mo(){return {consoleLogs:[...Z],networkErrors:[...K]}}function po(){Z=[],K=[];}var rn=[{name:"supabase_service_role_key",pattern:/SUPABASE_SERVICE_ROLE_KEY["'=:\s]+[A-Za-z0-9_.=-]{30,}/},{name:"supabase_db_password",pattern:/SUPABASE_DB_PASSWORD["'=:\s]+[^\s"']{6,}/},{name:"postgres_password",pattern:/POSTGRES_PASSWORD["'=:\s]+[^\s"']{6,}/},{name:"database_url_with_creds",pattern:/(?:postgres|postgresql|mysql|mongodb|redis|amqp):\/\/[^:]+:[^@\s"']+@/},{name:"aws_access_key",pattern:/AKIA[0-9A-Z]{16}/},{name:"aws_secret_key",pattern:/AWS_SECRET_ACCESS_KEY["'=:\s]+[A-Za-z0-9/+=]{30,}/},{name:"aws_session_token",pattern:/AWS_SESSION_TOKEN["'=:\s]+[A-Za-z0-9/+=]{30,}/},{name:"stripe_secret_key",pattern:/sk_live_[a-zA-Z0-9]{10,}/},{name:"stripe_secret_key_test",pattern:/sk_test_[a-zA-Z0-9]{10,}/},{name:"stripe_restricted_key",pattern:/rk_(?:live|test)_[a-zA-Z0-9]{10,}/},{name:"github_pat",pattern:/ghp_[A-Za-z0-9_]{36,}/},{name:"github_oauth",pattern:/gho_[A-Za-z0-9_]{36,}/},{name:"github_user_token",pattern:/ghu_[A-Za-z0-9_]{36,}/},{name:"github_server_token",pattern:/ghs_[A-Za-z0-9_]{36,}/},{name:"github_fine_grained",pattern:/github_pat_[A-Za-z0-9_]{22,}/},{name:"openai_api_key",pattern:/sk-[a-zA-Z0-9]{20,}(?![a-zA-Z0-9_])/},{name:"anthropic_api_key",pattern:/sk-ant-[a-zA-Z0-9\-_]{20,}/},{name:"private_key",pattern:/-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----/},{name:"sendgrid_api_key",pattern:/SG\.[a-zA-Z0-9_-]{22,}\.[a-zA-Z0-9_-]{22,}/},{name:"twilio_auth_token",pattern:/TWILIO_AUTH_TOKEN["'=:\s]+[a-f0-9]{32}/},{name:"generic_secret_key",pattern:/[A-Z_]{2,}_SECRET_KEY["'=:\s]+[^\s"']{8,}/},{name:"generic_secret",pattern:/[A-Z_]{2,}_SECRET["'=:\s]+[^\s"']{8,}/},{name:"generic_password",pattern:/[A-Z_]{2,}_PASSWORD["'=:\s]+[^\s"']{6,}/},{name:"generic_private_key_var",pattern:/[A-Z_]{2,}_PRIVATE_KEY["'=:\s]+[^\s"']{8,}/}],U=[],_e=0,ke=false;function sn(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function an(e,t,n,o){if(U.some(s=>s.rule===e&&s.source===t))return;let i={rule:e,source:t,hint:sn(n),timestamp:Date.now()};o&&(i.location=o),U.push(i);}function J(e,t,n,o){for(let{name:r,pattern:i}of n){let s=i.exec(e);s&&an(r,t,s[0],o);}}function cn(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);J(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);J(n,"hydration",e,"__NUXT__");}}catch{}}function ln(e){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&J(r,"scripts",e,`inline-script[${o}]`);});}catch{}}function un(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let o=n.getAttribute("content"),r=n.getAttribute("name")||n.getAttribute("property")||"";o&&o.length>10&&J(o,"meta",e,r?`meta[${r}]`:void 0);});}catch{}}function dn(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&&J(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function wo(e={}){if(ke||!E()||(ke=true,e.secretScan===false))return;let t=[...rn,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{_e=Date.now(),n.includes("hydration")&&cn(t),n.includes("scripts")&&ln(t),n.includes("meta")&&un(t),n.includes("dom")&&dn(t);let o=e.notify??"both";U.length>0&&(o==="console"||o==="both")&&console.warn(`[BlocFeed Security] Found ${U.length} potential secret(s) exposed in client code:`,U.map(r=>`${r.rule} (${r.source}${r.location?`: ${r.location}`:""})`));},100);}function bo(){return {findings:[...U],scannedAt:_e}}function yo(){U=[],_e=0,ke=false;}
|
|
2
|
+
export{E as a,ae as b,Be as c,Oe as d,Ue as e,he as f,Ve as g,_n as h,Tn as i,xt as j,Pt as k,Dt as l,we as m,Ut as n,be as o,$t as p,qn as q,tt as r,ao as s,uo as t,fo as u,mo as v,po as w,wo as x,bo as y,yo as z};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';function E(){return typeof window<"u"&&typeof document<"u"}function Re(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 ae(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function at(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function ct(e){return e.replace(/\s+/g," ").trim()}function ce(e,t=140){let n=e.textContent;if(!n)return;let o=ct(n);if(o)return o.length<=t?o:`${o.slice(0,t-1)}\u2026`}function lt(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var Ce=["data-testid","data-test-id","data-test","data-qa","data-cy"],Ae="data-blocfeed-component";function le(e){let t=e.closest(`[${Ae}]`);if(!t)return;let o=t.getAttribute(Ae)?.trim();return o||void 0}function ut(e){for(let t of Ce){let n=e.closest(`[${t}]`);if(!n)continue;let r=n.getAttribute(t)?.trim();if(r)return r}}function xe(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 O(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 $(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!O(t.name))return t.name}}function C(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 C(r)}}}function ue(e){let t=xe(e);if(!t)return;let n=$(t._debugInfo);if(n)return n;let o=t._debugOwner!==void 0;if(o){let c=t._debugOwner;for(let d=0;c&&d<50;d+=1){let w=$(c._debugInfo);if(w)return w;let g=C(c.type)??C(c.elementType);if(g&&!O(g))return g;c=c._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let c=t._owner;for(let d=0;c&&d<50;d+=1){let w=$(c._debugInfo);if(w)return w;let g=C(c.type)??C(c.elementType);if(g&&!O(g))return g;c=c._owner;}}let i=t,s=o?80:25;for(let c=0;i&&c<s;c+=1){let d=$(i._debugInfo);if(d)return d;let w=C(i.type)??C(i.elementType);if(w&&!O(w))return w;i=i.return;}let a=e.parentElement;for(let c=0;a&&c<15;c+=1){let d=xe(a);if(d){let w=$(d._debugInfo);if(w)return w;let g=C(d.type)??C(d.elementType);if(g&&!O(g))return g;if(d._debugOwner){let u=C(d._debugOwner.type)??C(d._debugOwner.elementType);if(u&&!O(u))return u}if(d._owner&&d._owner!==d._debugOwner){let u=C(d._owner.type)??C(d._owner.elementType);if(u&&!O(u))return u}}a=a.parentElement;}}function dt(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${Re(n)}`;for(let o of Ce){let r=e.getAttribute(o);if(r)return `${t}[${o}="${Re(r)}"]`}return `${t}:nth-of-type(${lt(e)})`}function ft(e,t=10){let n=[],o=e;for(;o&&n.length<t;){let r=dt(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}function Pe(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function de(e,t){if(!e||Pe(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(Pe(n,t.ignoreSelectors))return null;if(t.isSelectable?.(n)??mt(n))return n;n=n.parentElement;}return null}function mt(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function Fe(e){let t=e.getBoundingClientRect(),n={selector:ft(e),tagName:e.tagName.toLowerCase(),rect:ae(t),pageRect:at(t)},o=e.getAttribute("id");o&&(n.id=o);let r=e.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=ce(e);i&&(n.textSnippet=i);let s=le(e)??ue(e);s&&(n.componentName=s);let a=ut(e);return a&&(n.testId=a),n}var fe=null;async function Me(){return fe||(fe=import('html-to-image')),fe}async function pt(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 Ie(e,t){let{width:n,height:o}=await pt(e);return {dataUrl:e,mime:t,width:n,height:o}}function V(e){if(e?.aborted)throw new Error("Aborted")}function Be(){return {async captureElement(e,t){if(!E())throw new Error("captureElement can only run in the browser");V(t.signal);let n=await Me();V(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 V(t.signal),await Ie(o,t.mime)},async captureFullPage(e){if(!E())throw new Error("captureFullPage can only run in the browser");V(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)),s=Math.max(1,Math.round(o*r)),a=await Me();V(e.signal);let c=e.mime==="image/jpeg"?await a.toJpeg(t,{width:i,height:s,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await a.toPng(t,{width:i,height:s,pixelRatio:e.pixelRatio});return V(e.signal),await Ie(c,e.mime)}}}function gt(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function h(e,t,n){let o={kind:e,message:gt(t)};return n&&(o.detail=n),o}var ht=12e3,wt=2048,bt=.92;function De(){return Date.now()}function yt(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 Le(e,t,n){let o=new Promise((i,s)=>{let a=setTimeout(()=>s(new Error("Timeout")),t);typeof a.unref=="function"&&a.unref();}),r=[e,o];return n&&r.push(yt(n)),await Promise.race(r)}function Et(e){if(!E())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function vt(e){return !!(e?.element||e?.fullPage)}function Ne(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 Oe(e){let{selectionElement:t,capture:n,signal:o}=e;if(!E()||!vt(n))return;let r=De(),i=[],s=n?.timeoutMs??ht,a=n?.maxDimension??wt,c=n?.mime??"image/png",d=n?.quality??bt,w=n?.adapter??Be(),g={},u=Et(n);if(n?.element&&t)try{let p=t.getBoundingClientRect(),l=Math.min(1,a/Math.max(p.width,p.height)),k=Math.min(u,u*l),P=await Le(Promise.resolve(w.captureElement(t,{...Ne({mime:c,quality:d,pixelRatio:k,maxDimension:a,includeQuality:c==="image/jpeg",...o?{signal:o}:{}})})),s,o);g.element=P;}catch(p){if(o?.aborted)throw p;i.push(h("capture_failed",p,{target:"element"}));}if(n?.fullPage)try{let p=await Le(Promise.resolve(w.captureFullPage(Ne({mime:c,quality:d,pixelRatio:u,maxDimension:a,includeQuality:c==="image/jpeg",...o?{signal:o}:{}}))),s,o);g.fullPage=p;}catch(p){if(o?.aborted)throw p;i.push(h("capture_failed",p,{target:"fullPage"}));}let b=De(),f={startedAt:r,finishedAt:b,durationMs:Math.max(0,b-r)};return i.length>0&&(f.errors=i),{...g,diagnostics:f}}function St(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function kt(){return E()?{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:St()}:{}}function _t(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 Ue(e){let{config:t,context:n,user:o}=e;if(t?.enabled===false)return {};let r={...kt(),..._t(o)},i=t?.enrich;if(!i)return r;try{let s=await i(n);return {...r,...s}}catch(s){let a=h("unknown",s);return {...r,blocfeedMetadataError:a.message}}}var me="blocfeed-queue",Tt=50;function pe(){if(!E())return [];try{let e=localStorage.getItem(me);if(!e)return [];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return []}}function ge(e){if(E())try{e.length===0?localStorage.removeItem(me):localStorage.setItem(me,JSON.stringify(e));}catch{}}function Rt(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 he(e){let t=pe(),n=Rt(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>Tt;)t.shift();ge(t);}function Ve(){let e=pe();return e.length===0?[]:(ge([]),e.map(t=>t.payload))}function _n(){ge([]);}function Tn(){return pe().length}var At=200,X=[],He=0,ee=false;function qe(e){let t=e.target;if(!(t instanceof Element)||t.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-He,path:window.location.pathname,tagName:t.tagName.toLowerCase()},o=ce(t,100);o&&(n.textSnippet=o);let r=le(t)??ue(t);r&&(n.componentName=r),X.length<At&&X.push(n);}function ze(){ee||!E()||(ee=true,X=[],He=Date.now(),document.addEventListener("click",qe,{capture:true,passive:true}));}function je(){ee&&(ee=false,document.removeEventListener("click",qe,{capture:true}));}function xt(){return [...X]}function Pt(){X=[];}var Ct=3e4,Ft=25e5,$e="video/webm",Mt=250,It=1e3,Bt=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function Xe(){if(typeof MediaRecorder>"u")return null;for(let e of Bt)if(MediaRecorder.isTypeSupported(e))return e;return null}function Dt(){return !E()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:Xe()!==null}async function we(e){let{config:t,signal:n}=e;if(!E()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw h("recording_failed",new Error("Screen recording is not supported in this browser"));let o=Xe();if(!o)throw h("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw h("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(l){let k=l instanceof DOMException&&l.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw h("recording_failed",new Error(k))}if(n?.aborted)throw r.getTracks().forEach(l=>l.stop()),h("aborted",new Error("Recording aborted after permission"));let i=t?.maxDurationMs??Ct,s=t?.videoBitsPerSecond??Ft,a=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:s}),c=[],d=[],w=0,g=null,u=null,b=false,f=()=>{je(),g!==null&&(clearInterval(g),g=null),u!==null&&(clearTimeout(u),u=null),r.getTracks().forEach(l=>l.stop());},p=new Promise((l,k)=>{a.ondataavailable=T=>{T.data.size>0&&c.push(T.data);},a.onstop=()=>{if(b)return;b=true,f();let T=Date.now()-w,F=new Blob(c,{type:$e}),v=URL.createObjectURL(F);l({mime:$e,blobUrl:v,blob:F,durationMs:T,sizeBytes:F.size});},a.onerror=()=>{b||(b=true,f(),k(h("recording_failed",new Error("MediaRecorder error"))));};let P=r.getVideoTracks()[0];if(P&&P.addEventListener("ended",()=>{a.state!=="inactive"&&a.stop();}),n){let T=()=>{b||(b=true,a.state!=="inactive"&&a.stop(),f(),k(h("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",T,{once:true});}});return a.start(It),ze(),w=Date.now(),g=setInterval(()=>{let l=Date.now()-w;for(let k of d)k(l);},Mt),u=setTimeout(()=>{!b&&a.state!=="inactive"&&a.stop();},i),{result:p,stop(){!b&&a.state!=="inactive"&&a.stop();},onTick(l){d.push(l);},abort(){b||(b=true,a.state!=="inactive"&&a.stop(),f());}}}var Lt=6e4,Ze="audio/webm",Nt=250,Ot=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function Ke(){if(typeof MediaRecorder>"u")return null;for(let e of Ot)if(MediaRecorder.isTypeSupported(e))return e;return null}function Ut(){return !E()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:Ke()!==null}async function be(e){let{config:t,signal:n}=e;if(!E()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw h("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=Ke();if(!o)throw h("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw h("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(p){let l=p instanceof DOMException&&p.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw h("recording_failed",new Error(l))}if(n?.aborted)throw r.getTracks().forEach(p=>p.stop()),h("aborted",new Error("Voice recording aborted after permission"));let i=t?.maxDurationMs??Lt,s=new MediaRecorder(r,{mimeType:o}),a=[],c=[],d=0,w=null,g=null,u=false,b=()=>{w!==null&&(clearInterval(w),w=null),g!==null&&(clearTimeout(g),g=null),r.getTracks().forEach(p=>p.stop());},f=new Promise((p,l)=>{if(s.ondataavailable=k=>{k.data.size>0&&a.push(k.data);},s.onstop=()=>{if(u)return;u=true,b();let k=Date.now()-d,P=new Blob(a,{type:Ze});p({blob:P,mime:Ze,durationMs:k});},s.onerror=()=>{u||(u=true,b(),l(h("recording_failed",new Error("MediaRecorder error"))));},n){let k=()=>{u||(u=true,s.state!=="inactive"&&s.stop(),b(),l(h("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",k,{once:true});}});return s.start(1e3),d=Date.now(),w=setInterval(()=>{let p=Date.now()-d;for(let l of c)l(p);},Nt),g=setTimeout(()=>{!u&&s.state!=="inactive"&&s.stop();},i),{result:f,stop(){!u&&s.state!=="inactive"&&s.stop();},onTick(p){c.push(p);},abort(){u||(u=true,s.state!=="inactive"&&s.stop(),b());}}}var Vt=12e3,Ht=2,qt=500,zt=2e3,ye="https://blocfeed.com/api/feedback",jt="https://blocfeed.com/api/feedback/voice",We=0,Ge="blocfeed-viewer-token",Je="blocfeed-my-feedback-url";function $t(){try{return localStorage.getItem(Ge)}catch{return null}}function qn(){try{return localStorage.getItem(Je)}catch{return null}}function Xt(e,t){try{localStorage.setItem(Ge,e),t&&localStorage.setItem(Je,t);}catch{}}function Qe(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 Zt(e){return e>=500&&e<=599}function Kt(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),s=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)s[a]=i.charCodeAt(a);return new Blob([s],{type:r})}function Wt(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 Ye(e,t,n){let o=Kt(t);await fetch(e,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function Qt(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(`${ye}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function Yt(e){await fetch(`${ye}/${e.feedbackId}/video`,{method:"POST",body:e.blob,headers:{"content-type":e.blob.type},...e.signal?{signal:e.signal}:{}});}async function et(e){let{signal:t,transport:n}=e;if(Date.now()-We<zt)return {ok:false,error:h("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??Vt,i=n?.maxAttempts??Ht,s=n?.backoffMs??qt,a=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),c=!!e.payload.video?.blob,d=a||c,{lean:w,extracted:g,extractedVideo:u}=d?Wt(e.payload):{lean:e.payload,extracted:{},extractedVideo:{}},b=$t();b&&(w.viewer_token=b);let f={...g,...e.screenshotDataUrls};for(let p=1;p<=i;p+=1){let l=new AbortController,k=setTimeout(()=>l.abort(),r),P=()=>l.abort();t&&t.addEventListener("abort",P,{once:true});try{let T=await fetch(ye,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(w),signal:l.signal});if(T.ok){We=Date.now();let v;try{v=await T.json();}catch{}if(v?.viewer_token&&Xt(v.viewer_token,v.my_feedback_url),(f.element||f.fullPage)&&v){let m=v.upload_urls;if(m){let y=[];f.element&&m.element&&y.push(Ye(m.element,f.element,t)),f.fullPage&&m.fullPage&&y.push(Ye(m.fullPage,f.fullPage,t));try{await Promise.all(y);}catch{}}else if(v.feedback_id)try{await Qt({feedbackId:v.feedback_id,extracted:f,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}if(u.blob&&v){let m=v.upload_urls;if(m?.video)try{await fetch(m.video,{method:"PUT",body:u.blob,headers:{"content-type":u.blob.type},...t?{signal:t}:{}});}catch{}else if(v.feedback_id)try{await Yt({feedbackId:v.feedback_id,blob:u.blob,...t?{signal:t}:{}});}catch{}}let q={ok:!0,status:T.status};return v&&(q.apiResponse=v),q}if(p<i&&Zt(T.status)){let v=.85+Math.random()*.3,H=Math.round(s*2**(p-1)*v);await Qe(H,t);continue}let F=`HTTP ${T.status}`;try{let v=await T.json();v?.error&&(F=v.error);}catch{}return {ok:!1,status:T.status,error:h("api_failed",new Error(F))}}catch(T){if(l.signal.aborted||t?.aborted)return {ok:false,error:h("aborted",T)};if(p<i){let F=.85+Math.random()*.3,v=Math.round(s*2**(p-1)*F);await Qe(v,t);continue}return {ok:false,error:h("api_failed",T)}}finally{clearTimeout(k),t&&t.removeEventListener("abort",P);}}return {ok:false,error:h("api_failed",new Error("Failed"))}}async function tt(e){let{blob:t,mime:n,blocfeedId:o,signal:r}=e,i=await fetch(jt,{method:"POST",headers:{"Content-Type":n,"X-Blocfeed-Id":o},body:t,...r?{signal:r}:{}});if(!i.ok){let a=await i.json().catch(()=>({error:"Unknown error"}));throw h("api_failed",new Error(a?.error??`Voice API returned ${i.status}`))}let s=await i.json();return {text:s.text??"",warning:s.warning}}function Ee(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 te(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function ne(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function nt(e,t){if(!E())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,s=null,a=(f,p=false)=>{if(!f){i=null,s=null,t.onHover(null);return}let l=ae(f.getBoundingClientRect()),k=`${Math.round(l.x)}:${Math.round(l.y)}:${Math.round(l.width)}:${Math.round(l.height)}`;!p&&f===i&&k===s||(i=f,s=k,t.onHover({element:f,rect:l}));},c=Ee(f=>{if(te(f.target))return;let p=document.elementFromPoint(f.clientX,f.clientY),l=de(p,r);a(l);}),d=Ee(()=>{i&&a(i,true);}),w=f=>{te(f.target)||(ne(f),f.pointerType==="mouse"&&f.preventDefault());},g=f=>{te(f.target)||(ne(f),f.pointerType==="mouse"&&f.preventDefault());},u=f=>{if(te(f.target))return;ne(f),f.preventDefault();let p=document.elementFromPoint(f.clientX,f.clientY),l=de(p,r);l&&t.onSelect({element:l,descriptor:Fe(l)});},b=f=>{f.key==="Escape"&&(ne(f),f.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",c,{capture:true,passive:true}),window.addEventListener("pointerdown",w,{capture:true}),window.addEventListener("pointerup",g,{capture:true}),window.addEventListener("click",u,{capture:true}),window.addEventListener("keydown",b,{capture:true}),window.addEventListener("scroll",d,{capture:true,passive:true}),window.addEventListener("resize",d,{passive:true}),{stop(){window.removeEventListener("pointermove",c,{capture:true}),window.removeEventListener("pointerdown",w,{capture:true}),window.removeEventListener("pointerup",g,{capture:true}),window.removeEventListener("click",u,{capture:true}),window.removeEventListener("keydown",b,{capture:true}),window.removeEventListener("scroll",d,{capture:true}),window.removeEventListener("resize",d),c.cancel(),d.cancel(),t.onHover(null);}}}async function ve(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 et(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:h("api_failed",r)},o.ok=false;}return {payload:e.payload,result:o}}var Gt=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function Jt(e){let t=[...Gt,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function ot(){return {phase:"idle"}}function en(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 ao(e){let t=e,n=ot(),o=new Set,r=new Set,i=null,s=null,a=null,c=null,d=0,w=null,g=null,u=null,b=null,f=()=>{for(let m of o)m(n);},p=m=>{for(let y of r)y(m);},l=m=>{n=m,f();},k=()=>{d+=1,c?.abort(),c=null;},P=()=>{i?.stop(),i=null,p(null),a!==null&&E()&&(document.documentElement.style.cursor=a,a=null);},T=()=>{g&&(g.abort(),g=null),u&&(URL.revokeObjectURL(u.blobUrl),u=null);},F=()=>{b&&(b.abort(),b=null);},v=()=>{k(),P(),T(),F(),s=null,l(ot());},H=()=>{if(!E())return;P(),s=null;let m=Jt(t.picker);a=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",l({phase:"picking"}),i=nt(m,{onHover:p,onSelect:({element:y,descriptor:x})=>{s=y,P(),l({phase:"review",selection:x});},onCancel:()=>{v();}});},q=()=>{let m=Ve();if(m.length!==0)for(let y of m)ve({payload:y,...t.transport?{transport:t.transport}:{}}).catch(()=>{he(y);});};if(E()){setTimeout(q,1e3);let m=()=>q();window.addEventListener("online",m),w=()=>window.removeEventListener("online",m);}return {getState:()=>n,getConfig:()=>t,subscribe(m){return o.add(m),()=>o.delete(m)},subscribeHover(m){return r.add(m),()=>r.delete(m)},start(){n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording"||n.phase!=="picking"&&H();},stop(){v();},clearSelection(){n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording"||H();},setConfig(m){t=m;},async submit(m,y){if(!E()){let _=h("configuration",new Error("BlocFeed submit can only run in the browser"));return l({phase:"error",lastError:_}),{ok:false}}let x=t.blocfeed_id?.trim?.()??"";if(!x){let M={phase:"error",lastError:h("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return n.selection&&(M.selection=n.selection),l(M),{ok:false}}if(n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording")return {ok:false};let A=d+1;d=A,c?.abort(),c=new AbortController;let R=c.signal,S=n.selection,I=y?.capture?{...t.capture,...y.capture}:t.capture,B=!!(I?.element||I?.fullPage),z={phase:B?"capturing":"submitting"};S&&(z.selection=S),l(z);try{let _=B?await Oe({selectionElement:s,capture:I,signal:R}):void 0;if(R.aborted||d!==A)return {ok:!1};let M={phase:"submitting"};S&&(M.selection=S),_&&(M.capture=_),l(M);let D={};S&&(D.selection=S),_&&(D.capture=_);let j=await Ue({config:t.metadata,context:D,...t.user?{user:t.user}:{}}),N={version:1,createdAt:new Date().toISOString(),blocfeed_id:x,message:m,metadata:j};y?.category&&(N.category=y.category),t.user&&(N.user=t.user),S&&(N.selection=S),_&&(N.screenshots=_),u&&(N.video=u);let{result:L}=await ve({payload:N,signal:R,...t.transport?{transport:t.transport}:{}});if(R.aborted||d!==A)return L;if(L.ok){u&&(URL.revokeObjectURL(u.blobUrl),u=null);let se={phase:"success",lastSubmit:L};return S&&(se.selection=S),_&&(se.capture=_),l(se),L}en(L)&&he(N);let st=L.api?.error??h("unknown",new Error("Submission failed")),ie={phase:"error",lastSubmit:L,lastError:st};return S&&(ie.selection=S),_&&(ie.capture=_),l(ie),L}catch(_){if(R.aborted||d!==A)return {ok:false};let D={phase:"error",lastError:R.aborted?h("aborted",_):h("unknown",_)};return S&&(D.selection=S),l(D),{ok:false}}finally{d===A&&(c=null);}},async startRecording(){if(n.phase!=="review"||!t.recording?.enabled)return;let m=n.selection,y={phase:"recording",recordingElapsedMs:0};m&&(y.selection=m),l(y);try{let x={config:t.recording};c&&(x.signal=c.signal);let A=await we(x);g=A,A.onTick(I=>{if(n.phase==="recording"){let B={phase:"recording",recordingElapsedMs:I};m&&(B.selection=m),l(B);}});let R=await A.result;g=null,u=R;let S={phase:"review",video:R};m&&(S.selection=m),l(S);}catch(x){g=null;let R={phase:"review",lastError:x?.kind?x:h("recording_failed",x)};m&&(R.selection=m),l(R);}},stopRecording(){n.phase!=="recording"||!g||g.stop();},removeVideo(){u&&(URL.revokeObjectURL(u.blobUrl),u=null);let m=n.selection,y={phase:"review"};m&&(y.selection=m),l(y);},async startVoice(){if(n.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",n.phase,'(expected "review")');return}let m=t.voice;if(!m?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}F();let y=n.selection,x={phase:"review",voiceRecording:true,voiceElapsedMs:0};y&&(x.selection=y),u&&(x.video=u),l(x);try{let A={config:m};c&&(A.signal=c.signal);let R=await be(A);b=R,R.onTick(D=>{let j={phase:"review",voiceRecording:!0,voiceElapsedMs:D};y&&(j.selection=y),u&&(j.video=u),l(j);});let S=await R.result;b=null;let I={phase:"review",voiceRecording:!1,voiceTranscribing:!0};y&&(I.selection=y),u&&(I.video=u),l(I);let B={blob:S.blob,mime:S.mime,blocfeedId:t.blocfeed_id};c&&(B.signal=c.signal);let{text:Te,warning:z}=await tt(B),_={phase:"review",voiceRecording:!1,voiceTranscribing:!1};y&&(_.selection=y),u&&(_.video=u),l(_);let M={text:Te};return z&&(M.warning=z),M}catch(A){F();let R=A?.kind?A:h("recording_failed",A);console.warn("[BlocFeed] Voice error:",R.message);let S={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:R};y&&(S.selection=y),u&&(S.video=u),l(S);return}},stopVoice(){b&&b.stop();},__unsafeGetSelectedElement(){return s},destroy(){v(),o.clear(),r.clear(),w?.(),w=null;}}}var Z=[],K=[],rt=20,it=15,oe=[],W={},Q=null,Y=null,G=null,re=false,tn=["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 nn(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function on(e,t){let n=t.map(nn).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)),Z.push(r);Z.length>rt;)Z.shift();}function Se(e){let t=e.url.toLowerCase();for(let n of oe)if(t.includes(n))return;for(K.push(e);K.length>it;)K.shift();}function uo(e={}){if(re||!E())return;re=true,rt=e.consoleLimit??20,it=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?oe=t.map(n=>n.toLowerCase()):oe=[...tn],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let o of n)W[o]=console[o],console[o]=(...r)=>{on(o,r),W[o]?.apply(console,r);};}if(e.network!==false&&typeof window.fetch=="function"){Q=window.fetch;let n=Q;window.fetch=async function(r,i){let s=typeof r=="string"?r:r instanceof URL?r.toString():r.url,a=(i?.method??"GET").toUpperCase(),c=Date.now();try{let d=await n.call(window,r,i);return d.ok||Se({url:s.slice(0,500),method:a,status:d.status,statusText:d.statusText,timestamp:c,durationMs:Date.now()-c}),d}catch(d){throw Se({url:s.slice(0,500),method:a,status:0,statusText:d instanceof Error?d.message:"Network error",timestamp:c,durationMs:Date.now()-c}),d}};}if(e.network!==false&&typeof XMLHttpRequest<"u"){Y=XMLHttpRequest.prototype.open,G=XMLHttpRequest.prototype.send;let n=Y,o=G;XMLHttpRequest.prototype.open=function(r,i,...s){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...s])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",s=this.__bf_url||"",a=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let c={url:s.slice(0,500),method:i,status:this.status,timestamp:a,durationMs:Date.now()-a};this.statusText&&(c.statusText=this.statusText),Se(c);}}),o.apply(this,r)};}}function fo(){if(re){for(let[e,t]of Object.entries(W))console[e]=t;for(let e of Object.keys(W))delete W[e];Q&&(window.fetch=Q,Q=null),Y&&(XMLHttpRequest.prototype.open=Y,Y=null),G&&(XMLHttpRequest.prototype.send=G,G=null),oe=[],re=false;}}function mo(){return {consoleLogs:[...Z],networkErrors:[...K]}}function po(){Z=[],K=[];}var rn=[{name:"supabase_service_role_key",pattern:/SUPABASE_SERVICE_ROLE_KEY["'=:\s]+[A-Za-z0-9_.=-]{30,}/},{name:"supabase_db_password",pattern:/SUPABASE_DB_PASSWORD["'=:\s]+[^\s"']{6,}/},{name:"postgres_password",pattern:/POSTGRES_PASSWORD["'=:\s]+[^\s"']{6,}/},{name:"database_url_with_creds",pattern:/(?:postgres|postgresql|mysql|mongodb|redis|amqp):\/\/[^:]+:[^@\s"']+@/},{name:"aws_access_key",pattern:/AKIA[0-9A-Z]{16}/},{name:"aws_secret_key",pattern:/AWS_SECRET_ACCESS_KEY["'=:\s]+[A-Za-z0-9/+=]{30,}/},{name:"aws_session_token",pattern:/AWS_SESSION_TOKEN["'=:\s]+[A-Za-z0-9/+=]{30,}/},{name:"stripe_secret_key",pattern:/sk_live_[a-zA-Z0-9]{10,}/},{name:"stripe_secret_key_test",pattern:/sk_test_[a-zA-Z0-9]{10,}/},{name:"stripe_restricted_key",pattern:/rk_(?:live|test)_[a-zA-Z0-9]{10,}/},{name:"github_pat",pattern:/ghp_[A-Za-z0-9_]{36,}/},{name:"github_oauth",pattern:/gho_[A-Za-z0-9_]{36,}/},{name:"github_user_token",pattern:/ghu_[A-Za-z0-9_]{36,}/},{name:"github_server_token",pattern:/ghs_[A-Za-z0-9_]{36,}/},{name:"github_fine_grained",pattern:/github_pat_[A-Za-z0-9_]{22,}/},{name:"openai_api_key",pattern:/sk-[a-zA-Z0-9]{20,}(?![a-zA-Z0-9_])/},{name:"anthropic_api_key",pattern:/sk-ant-[a-zA-Z0-9\-_]{20,}/},{name:"private_key",pattern:/-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----/},{name:"sendgrid_api_key",pattern:/SG\.[a-zA-Z0-9_-]{22,}\.[a-zA-Z0-9_-]{22,}/},{name:"twilio_auth_token",pattern:/TWILIO_AUTH_TOKEN["'=:\s]+[a-f0-9]{32}/},{name:"generic_secret_key",pattern:/[A-Z_]{2,}_SECRET_KEY["'=:\s]+[^\s"']{8,}/},{name:"generic_secret",pattern:/[A-Z_]{2,}_SECRET["'=:\s]+[^\s"']{8,}/},{name:"generic_password",pattern:/[A-Z_]{2,}_PASSWORD["'=:\s]+[^\s"']{6,}/},{name:"generic_private_key_var",pattern:/[A-Z_]{2,}_PRIVATE_KEY["'=:\s]+[^\s"']{8,}/}],U=[],_e=0,ke=false;function sn(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function an(e,t,n,o){if(U.some(s=>s.rule===e&&s.source===t))return;let i={rule:e,source:t,hint:sn(n),timestamp:Date.now()};o&&(i.location=o),U.push(i);}function J(e,t,n,o){for(let{name:r,pattern:i}of n){let s=i.exec(e);s&&an(r,t,s[0],o);}}function cn(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);J(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);J(n,"hydration",e,"__NUXT__");}}catch{}}function ln(e){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&J(r,"scripts",e,`inline-script[${o}]`);});}catch{}}function un(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let o=n.getAttribute("content"),r=n.getAttribute("name")||n.getAttribute("property")||"";o&&o.length>10&&J(o,"meta",e,r?`meta[${r}]`:void 0);});}catch{}}function dn(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&&J(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function wo(e={}){if(ke||!E()||(ke=true,e.secretScan===false))return;let t=[...rn,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{_e=Date.now(),n.includes("hydration")&&cn(t),n.includes("scripts")&&ln(t),n.includes("meta")&&un(t),n.includes("dom")&&dn(t);let o=e.notify??"both";U.length>0&&(o==="console"||o==="both")&&console.warn(`[BlocFeed Security] Found ${U.length} potential secret(s) exposed in client code:`,U.map(r=>`${r.rule} (${r.source}${r.location?`: ${r.location}`:""})`));},100);}function bo(){return {findings:[...U],scannedAt:_e}}function yo(){U=[],_e=0,ke=false;}
|
|
2
|
+
exports.a=E;exports.b=ae;exports.c=Be;exports.d=Oe;exports.e=Ue;exports.f=he;exports.g=Ve;exports.h=_n;exports.i=Tn;exports.j=xt;exports.k=Pt;exports.l=Dt;exports.m=we;exports.n=Ut;exports.o=be;exports.p=$t;exports.q=qn;exports.r=tt;exports.s=ao;exports.t=uo;exports.u=fo;exports.v=mo;exports.w=po;exports.x=wo;exports.y=bo;exports.z=yo;
|
package/dist/engine.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkVK43CZAG_cjs=require('./chunk-VK43CZAG.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(!chunkVK43CZAG_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(!chunkVK43CZAG_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 chunkVK43CZAG_cjs.k}});Object.defineProperty(exports,"clearDiagnostics",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.w}});Object.defineProperty(exports,"clearQueue",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.h}});Object.defineProperty(exports,"clearSecurityFindings",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.z}});Object.defineProperty(exports,"collectMetadata",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.e}});Object.defineProperty(exports,"createBlocFeedController",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.s}});Object.defineProperty(exports,"createHtmlToImageAdapter",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.c}});Object.defineProperty(exports,"dequeueAll",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.g}});Object.defineProperty(exports,"drainClickEvents",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.j}});Object.defineProperty(exports,"drainDiagnostics",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.v}});Object.defineProperty(exports,"enqueue",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.f}});Object.defineProperty(exports,"getMyFeedbackUrl",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.q}});Object.defineProperty(exports,"getQueueSize",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.i}});Object.defineProperty(exports,"getSecurityFindings",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.y}});Object.defineProperty(exports,"getViewerToken",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.p}});Object.defineProperty(exports,"installDiagnostics",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.t}});Object.defineProperty(exports,"isRecordingSupported",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.l}});Object.defineProperty(exports,"isVoiceSupported",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.n}});Object.defineProperty(exports,"runCapture",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.d}});Object.defineProperty(exports,"runSecretScan",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.x}});Object.defineProperty(exports,"startRecording",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.m}});Object.defineProperty(exports,"startVoiceRecording",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.o}});Object.defineProperty(exports,"transcribeAudio",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.r}});Object.defineProperty(exports,"uninstallDiagnostics",{enumerable:true,get:function(){return chunkVK43CZAG_cjs.u}});exports.createModernScreenshotAdapter=U;exports.dataUrlToBlob=O;
|
package/dist/engine.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as ScreenshotAdapter, C as CaptureConfig, h as CaptureResult, V as VideoAsset, R as RecordingConfig, H as ClickEvent, G as VoiceConfig, l as MetadataConfig, m as MetadataContext, f as BlocFeedUser, k as FeedbackPayload, u as SecuritySnapshot, s as SecurityConfig } from './controller-
|
|
2
|
-
export { B as BlocFeedConfig, c as BlocFeedController, d as BlocFeedError, a as BlocFeedHandle, b as BlocFeedState, e as BlocFeedStrings, i as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, j as FeedbackApiResponse, F as FeedbackCategory, J as HoverListener, I as ImageAsset, N as NetworkEntry, n as Rect, p as ScreenshotAdapterOptions, q as ScreenshotIntent, r as ScreenshotMime, t as SecurityFinding, v as SessionPhase, K as StateListener, S as SubmitResult, T as ThemeConfig, w as TransportConfig, y as TriggerStyle, z as VideoIntent, A as VideoMime, W as WidgetPosition, L as createBlocFeedController } from './controller-
|
|
1
|
+
import { o as ScreenshotAdapter, C as CaptureConfig, h as CaptureResult, V as VideoAsset, R as RecordingConfig, H as ClickEvent, G as VoiceConfig, l as MetadataConfig, m as MetadataContext, f as BlocFeedUser, k as FeedbackPayload, u as SecuritySnapshot, s as SecurityConfig } from './controller-JCtPYbzs.cjs';
|
|
2
|
+
export { B as BlocFeedConfig, c as BlocFeedController, d as BlocFeedError, a as BlocFeedHandle, b as BlocFeedState, e as BlocFeedStrings, i as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, j as FeedbackApiResponse, F as FeedbackCategory, J as HoverListener, I as ImageAsset, N as NetworkEntry, n as Rect, p as ScreenshotAdapterOptions, q as ScreenshotIntent, r as ScreenshotMime, t as SecurityFinding, v as SessionPhase, K as StateListener, S as SubmitResult, T as ThemeConfig, w as TransportConfig, y as TriggerStyle, z as VideoIntent, A as VideoMime, W as WidgetPosition, L as createBlocFeedController } from './controller-JCtPYbzs.cjs';
|
|
3
3
|
|
|
4
4
|
declare function createHtmlToImageAdapter(): ScreenshotAdapter;
|
|
5
5
|
|
|
@@ -95,6 +95,10 @@ declare function startVoiceRecording(params: {
|
|
|
95
95
|
signal?: AbortSignal;
|
|
96
96
|
}): Promise<VoiceSession>;
|
|
97
97
|
|
|
98
|
+
/** Get stored viewer token from localStorage. */
|
|
99
|
+
declare function getViewerToken(): string | null;
|
|
100
|
+
/** Get stored "my feedback" URL from localStorage. */
|
|
101
|
+
declare function getMyFeedbackUrl(): string | null;
|
|
98
102
|
/**
|
|
99
103
|
* Send audio blob to the voice transcription endpoint.
|
|
100
104
|
* Returns the transcribed text or throws on failure.
|
|
@@ -203,4 +207,4 @@ declare function clearSecurityFindings(): void;
|
|
|
203
207
|
|
|
204
208
|
declare function dataUrlToBlob(dataUrl: string): Blob;
|
|
205
209
|
|
|
206
|
-
export { BlocFeedUser, CaptureResult, ClickEvent, FeedbackPayload, type ModernScreenshotModule, RecordingConfig, type RecordingSession, ScreenshotAdapter, SecurityConfig, SecuritySnapshot, VideoAsset, VoiceConfig, type VoiceSession, clearClickEvents, clearDiagnostics, clearQueue, clearSecurityFindings, collectMetadata, createHtmlToImageAdapter, createModernScreenshotAdapter, dataUrlToBlob, dequeueAll, drainClickEvents, drainDiagnostics, enqueue, getQueueSize, getSecurityFindings, installDiagnostics, isRecordingSupported, isVoiceSupported, runCapture, runSecretScan, startRecording, startVoiceRecording, transcribeAudio, uninstallDiagnostics };
|
|
210
|
+
export { BlocFeedUser, CaptureResult, ClickEvent, FeedbackPayload, type ModernScreenshotModule, RecordingConfig, type RecordingSession, ScreenshotAdapter, SecurityConfig, SecuritySnapshot, VideoAsset, VoiceConfig, type VoiceSession, clearClickEvents, clearDiagnostics, clearQueue, clearSecurityFindings, collectMetadata, createHtmlToImageAdapter, createModernScreenshotAdapter, dataUrlToBlob, dequeueAll, drainClickEvents, drainDiagnostics, enqueue, getMyFeedbackUrl, getQueueSize, getSecurityFindings, getViewerToken, installDiagnostics, isRecordingSupported, isVoiceSupported, runCapture, runSecretScan, startRecording, startVoiceRecording, transcribeAudio, uninstallDiagnostics };
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as ScreenshotAdapter, C as CaptureConfig, h as CaptureResult, V as VideoAsset, R as RecordingConfig, H as ClickEvent, G as VoiceConfig, l as MetadataConfig, m as MetadataContext, f as BlocFeedUser, k as FeedbackPayload, u as SecuritySnapshot, s as SecurityConfig } from './controller-
|
|
2
|
-
export { B as BlocFeedConfig, c as BlocFeedController, d as BlocFeedError, a as BlocFeedHandle, b as BlocFeedState, e as BlocFeedStrings, i as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, j as FeedbackApiResponse, F as FeedbackCategory, J as HoverListener, I as ImageAsset, N as NetworkEntry, n as Rect, p as ScreenshotAdapterOptions, q as ScreenshotIntent, r as ScreenshotMime, t as SecurityFinding, v as SessionPhase, K as StateListener, S as SubmitResult, T as ThemeConfig, w as TransportConfig, y as TriggerStyle, z as VideoIntent, A as VideoMime, W as WidgetPosition, L as createBlocFeedController } from './controller-
|
|
1
|
+
import { o as ScreenshotAdapter, C as CaptureConfig, h as CaptureResult, V as VideoAsset, R as RecordingConfig, H as ClickEvent, G as VoiceConfig, l as MetadataConfig, m as MetadataContext, f as BlocFeedUser, k as FeedbackPayload, u as SecuritySnapshot, s as SecurityConfig } from './controller-JCtPYbzs.js';
|
|
2
|
+
export { B as BlocFeedConfig, c as BlocFeedController, d as BlocFeedError, a as BlocFeedHandle, b as BlocFeedState, e as BlocFeedStrings, i as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, j as FeedbackApiResponse, F as FeedbackCategory, J as HoverListener, I as ImageAsset, N as NetworkEntry, n as Rect, p as ScreenshotAdapterOptions, q as ScreenshotIntent, r as ScreenshotMime, t as SecurityFinding, v as SessionPhase, K as StateListener, S as SubmitResult, T as ThemeConfig, w as TransportConfig, y as TriggerStyle, z as VideoIntent, A as VideoMime, W as WidgetPosition, L as createBlocFeedController } from './controller-JCtPYbzs.js';
|
|
3
3
|
|
|
4
4
|
declare function createHtmlToImageAdapter(): ScreenshotAdapter;
|
|
5
5
|
|
|
@@ -95,6 +95,10 @@ declare function startVoiceRecording(params: {
|
|
|
95
95
|
signal?: AbortSignal;
|
|
96
96
|
}): Promise<VoiceSession>;
|
|
97
97
|
|
|
98
|
+
/** Get stored viewer token from localStorage. */
|
|
99
|
+
declare function getViewerToken(): string | null;
|
|
100
|
+
/** Get stored "my feedback" URL from localStorage. */
|
|
101
|
+
declare function getMyFeedbackUrl(): string | null;
|
|
98
102
|
/**
|
|
99
103
|
* Send audio blob to the voice transcription endpoint.
|
|
100
104
|
* Returns the transcribed text or throws on failure.
|
|
@@ -203,4 +207,4 @@ declare function clearSecurityFindings(): void;
|
|
|
203
207
|
|
|
204
208
|
declare function dataUrlToBlob(dataUrl: string): Blob;
|
|
205
209
|
|
|
206
|
-
export { BlocFeedUser, CaptureResult, ClickEvent, FeedbackPayload, type ModernScreenshotModule, RecordingConfig, type RecordingSession, ScreenshotAdapter, SecurityConfig, SecuritySnapshot, VideoAsset, VoiceConfig, type VoiceSession, clearClickEvents, clearDiagnostics, clearQueue, clearSecurityFindings, collectMetadata, createHtmlToImageAdapter, createModernScreenshotAdapter, dataUrlToBlob, dequeueAll, drainClickEvents, drainDiagnostics, enqueue, getQueueSize, getSecurityFindings, installDiagnostics, isRecordingSupported, isVoiceSupported, runCapture, runSecretScan, startRecording, startVoiceRecording, transcribeAudio, uninstallDiagnostics };
|
|
210
|
+
export { BlocFeedUser, CaptureResult, ClickEvent, FeedbackPayload, type ModernScreenshotModule, RecordingConfig, type RecordingSession, ScreenshotAdapter, SecurityConfig, SecuritySnapshot, VideoAsset, VoiceConfig, type VoiceSession, clearClickEvents, clearDiagnostics, clearQueue, clearSecurityFindings, collectMetadata, createHtmlToImageAdapter, createModernScreenshotAdapter, dataUrlToBlob, dequeueAll, drainClickEvents, drainDiagnostics, enqueue, getMyFeedbackUrl, getQueueSize, getSecurityFindings, getViewerToken, installDiagnostics, isRecordingSupported, isVoiceSupported, runCapture, runSecretScan, startRecording, startVoiceRecording, transcribeAudio, uninstallDiagnostics };
|
package/dist/engine.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-EADEWOWW.js';export{k as clearClickEvents,w as clearDiagnostics,h as clearQueue,z as clearSecurityFindings,e as collectMetadata,s as createBlocFeedController,c as createHtmlToImageAdapter,g as dequeueAll,j as drainClickEvents,v as drainDiagnostics,f as enqueue,q as getMyFeedbackUrl,i as getQueueSize,y as getSecurityFindings,p as getViewerToken,t as installDiagnostics,l as isRecordingSupported,n as isVoiceSupported,d as runCapture,x as runSecretScan,m as startRecording,o as startVoiceRecording,r as transcribeAudio,u as uninstallDiagnostics}from'./chunk-EADEWOWW.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,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
'use strict';var
|
|
2
|
+
'use strict';var chunkVK43CZAG_cjs=require('./chunk-VK43CZAG.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),framerMotion=require('framer-motion');var Y=react.createContext(null);function ie(t){let e=react.useMemo(()=>chunkVK43CZAG_cjs.s({...t.config??{},blocfeed_id:t.blocfeed_id}),[]),[a,r]=react.useState(()=>e.getState());return react.useEffect(()=>e.subscribe(r),[e]),react.useEffect(()=>e.setConfig({...t.config??{},blocfeed_id:t.blocfeed_id}),[e,t.config,t.blocfeed_id]),react.useEffect(()=>()=>e.destroy(),[e]),jsxRuntime.jsx(Y.Provider,{value:{controller:e,state:a},children:t.children})}var Fe="blocfeed-styles-v1",Mt=`
|
|
3
3
|
:where([data-blocfeed-ui-root]),
|
|
4
4
|
:where([data-blocfeed-ui-root]) * {
|
|
5
5
|
box-sizing: border-box;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
:where([data-blocfeed-ui-root]) {
|
|
9
|
-
--bf-z:
|
|
9
|
+
--bf-z: 2147483647;
|
|
10
10
|
--bf-font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
|
|
11
11
|
--bf-panel-bg: rgba(17, 24, 39, 0.98);
|
|
12
12
|
--bf-panel-fg: rgb(243, 244, 246);
|
|
@@ -16,6 +16,17 @@
|
|
|
16
16
|
--bf-danger: rgb(239, 68, 68);
|
|
17
17
|
--bf-shadow: 0 18px 55px rgba(0, 0, 0, 0.45);
|
|
18
18
|
|
|
19
|
+
/* Ensure widget always floats above customer modals/sidepanels/overlays */
|
|
20
|
+
position: fixed;
|
|
21
|
+
top: 0;
|
|
22
|
+
left: 0;
|
|
23
|
+
width: 0;
|
|
24
|
+
height: 0;
|
|
25
|
+
overflow: visible;
|
|
26
|
+
z-index: var(--bf-z);
|
|
27
|
+
isolation: isolate;
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
|
|
19
30
|
font-family: var(--bf-font);
|
|
20
31
|
color: var(--bf-panel-fg);
|
|
21
32
|
}
|
|
@@ -75,6 +86,7 @@
|
|
|
75
86
|
right: 18px;
|
|
76
87
|
bottom: 18px;
|
|
77
88
|
z-index: var(--bf-z);
|
|
89
|
+
pointer-events: auto;
|
|
78
90
|
|
|
79
91
|
display: inline-flex;
|
|
80
92
|
align-items: center;
|
|
@@ -382,6 +394,7 @@
|
|
|
382
394
|
:where([data-blocfeed-ui-root]) .bf-trigger-edge {
|
|
383
395
|
position: fixed;
|
|
384
396
|
z-index: var(--bf-z);
|
|
397
|
+
pointer-events: auto;
|
|
385
398
|
display: flex;
|
|
386
399
|
align-items: center;
|
|
387
400
|
justify-content: center;
|
|
@@ -427,6 +440,7 @@
|
|
|
427
440
|
right: 18px;
|
|
428
441
|
bottom: 18px;
|
|
429
442
|
z-index: var(--bf-z);
|
|
443
|
+
pointer-events: auto;
|
|
430
444
|
display: inline-flex;
|
|
431
445
|
align-items: center;
|
|
432
446
|
background: transparent;
|
|
@@ -828,6 +842,31 @@
|
|
|
828
842
|
color: var(--bf-accent);
|
|
829
843
|
}
|
|
830
844
|
|
|
845
|
+
:where([data-blocfeed-ui-root]) .bf-watermark .bf-my-feedback-link {
|
|
846
|
+
display: block;
|
|
847
|
+
margin-bottom: 2px;
|
|
848
|
+
font-size: 10px;
|
|
849
|
+
color: var(--bf-accent);
|
|
850
|
+
opacity: 0.7;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
:where([data-blocfeed-ui-root]) .bf-watermark .bf-my-feedback-link:hover {
|
|
854
|
+
opacity: 1;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
:where([data-blocfeed-ui-root]) .bf-toast-link {
|
|
858
|
+
display: block;
|
|
859
|
+
margin-top: 4px;
|
|
860
|
+
font-size: 11px;
|
|
861
|
+
color: var(--bf-accent);
|
|
862
|
+
pointer-events: auto;
|
|
863
|
+
text-decoration: none;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
:where([data-blocfeed-ui-root]) .bf-toast-link:hover {
|
|
867
|
+
text-decoration: underline;
|
|
868
|
+
}
|
|
869
|
+
|
|
831
870
|
/* ------------------------------------------------------------------ */
|
|
832
871
|
/* Reduced motion */
|
|
833
872
|
/* ------------------------------------------------------------------ */
|
|
@@ -842,5 +881,5 @@
|
|
|
842
881
|
animation: none;
|
|
843
882
|
}
|
|
844
883
|
}
|
|
845
|
-
`;function Fe(){if(!chunkFM72GX3J_cjs.a()||document.getElementById(Ne))return;let t=document.createElement("style");t.id=Ne,t.textContent=Rt,document.head.appendChild(t);}var Re={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 Me(t){return t?{...Re,...t}:Re}function ie(){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 w(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 ze({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 Le({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 Ie({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){return a?jsxRuntime.jsxs("button",{className:w(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]}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]}):null}function m(){let[t,e]=react.useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return react.useEffect(()=>{let a=window.matchMedia("(prefers-reduced-motion: reduce)"),r=i=>e(i.matches);return a.addEventListener("change",r),()=>a.removeEventListener("change",r)},[]),t}var _t={duration:.18,ease:"easeOut"},Ht={duration:0};function _e({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=react.useState(false),o=m(),s=o?Ht:_t;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsx(framerMotion.motion.button,{className:w(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:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:s,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?s:{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:s,style:{whiteSpace:"nowrap"},children:r},"label")}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"dot")})}var $t={duration:.18,ease:"easeOut"},Oe={duration:0};function Ve({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=react.useState(false),o=m(),s=o?Oe:$t;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsxs(framerMotion.motion.div,{className:w(t),initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{y:8,opacity:0},transition:s,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:s,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?Oe:{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:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(g,{size:16})},"success"):jsxRuntime.jsx(ze,{size:16}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${i} queued`,children:i})]})]},"bubble")})}var Xt={duration:.2,ease:"easeOut"},Yt={duration:0};function Ke(t){return t==="bottom-left"||t==="top-left"}function Gt(t){return `bf-trigger-edge ${Ke(t)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function Ue({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=react.useState(false),o=Ke(t),s=m(),h=s?Yt:Xt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsx(framerMotion.motion.button,{className:Gt(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:h,whileTap:{scale:.97},style:{top:"50%",translateY:"-50%"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:h,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:s||n?0:o?-90:90,opacity:n?1:.6},transition:h,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)"}}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"edge-tab")})}var qt={duration:.18,ease:"easeOut"},Jt={duration:0};function Ye({delay:t,hovered:e,reduced:a}){return a?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 je({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=react.useState(false),o=m(),s=o?Jt:qt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsx(framerMotion.motion.button,{className:w(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:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:s,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(Ye,{delay:0,hovered:n,reduced:o}),jsxRuntime.jsx(Ye,{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:s,style:{whiteSpace:"nowrap"},children:r},"label")}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"pulse-ring")})}var oo={duration:.18,ease:"easeOut"},ro={duration:0};function io(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 Je({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=react.useState(false),o=m(),s=o?ro:oo;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsxs(framerMotion.motion.button,{className:io(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:s,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}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${i} queued`,children:i})]}),!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:s})]},"minimal")})}var so={duration:.18,ease:"easeOut"},co={duration:0};function et({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=react.useState(false),o=m(),s=o?co:so;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsx(framerMotion.motion.button,{className:w(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:s,whileTap:{scale:.9},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:s,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?s:{duration:3,repeat:1/0,ease:"easeInOut"},children:jsxRuntime.jsx(Le,{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:s,style:{whiteSpace:"nowrap"},children:r},"label")}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"icon-pop")})}var uo={duration:.18,ease:"easeOut"},bo={duration:0};function rt({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=react.useState(false),o=m(),s=o?bo:uo;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsx(framerMotion.motion.button,{className:w(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:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:s,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?s:{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:s,style:{whiteSpace:"nowrap"},children:r},"label")}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"beacon")})}var vo={duration:.18,ease:"easeOut"},yo={duration:0};function st({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=react.useState(false),[o,s]=react.useState(0),h=m(),z=h?yo:vo,f=react.useRef(null);react.useEffect(()=>{if(f.current&&(clearInterval(f.current),f.current=null),!a||n||h){s(n||h?r.length:0);return}let b=8,B=r.length*2+b*2,v=0;return f.current=setInterval(()=>{v=(v+1)%B,v<=r.length?s(v):v<=r.length+b?s(r.length):v<=r.length*2+b?s(r.length*2+b-v):s(0);},100),()=>{f.current&&(clearInterval(f.current),f.current=null);}},[a,n,h,r]);let S=r.slice(0,o);return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsx(framerMotion.motion.button,{className:w(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,y:h?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:h?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"})]}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"typewriter")})}function ct(t){switch(t){case "dot":return _e;case "bubble":return Ve;case "edge-tab":return Ue;case "pulse-ring":return je;case "minimal":return Je;case "icon-pop":return et;case "beacon":return rt;case "typewriter":return st;default:return Ie}}function lt(t,e,a){return Math.max(e,Math.min(a,t))}function Eo(t,e,a="bottom-right"){let i=window.innerWidth,p=window.innerHeight,n;n=lt(t.x,12,Math.max(12,i-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 Co(t){let{rect:e}=t,a={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:a,"aria-hidden":"true"})}function Po(t){let e=react.useRef(null);return react.useEffect(()=>{if(!t||!e.current)return;e.current.querySelector(".bf-textarea")?.focus();let r=i=>{if(i.key!=="Tab"||!e.current)return;let p=e.current.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(p.length===0)return;let n=p[0],l=p[p.length-1];i.shiftKey&&document.activeElement===n?(i.preventDefault(),l.focus()):!i.shiftKey&&document.activeElement===l&&(i.preventDefault(),n.focus());};return document.addEventListener("keydown",r,{capture:true}),()=>document.removeEventListener("keydown",r,{capture:true})},[t]),e}function Bo(t,e){return t?typeof t=="function"?t(e):t.some(a=>a.endsWith("*")?e.startsWith(a.slice(0,-1)):e===a):true}function No(t){let[e,a]=react.useState(()=>typeof window<"u"?window.location.pathname:"/");return react.useEffect(()=>{if(typeof window>"u")return;let r=()=>a(window.location.pathname);window.addEventListener("popstate",r);let i=history.pushState,p=history.replaceState;return history.pushState=function(...n){i.apply(this,n),setTimeout(r,0);},history.replaceState=function(...n){p.apply(this,n),setTimeout(r,0);},()=>{window.removeEventListener("popstate",r),history.pushState=i,history.replaceState=p;}},[]),Bo(t,e)}function Fo(t){let[e,a]=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"){a(t==="light"?"light":"dark");return}let r=window.matchMedia("(prefers-color-scheme: dark)"),i=p=>a(p.matches?"dark":"light");return a(r.matches?"dark":"light"),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[t]),e}var Ro=["bug","feature","ux","general"],Mo={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function X(t){let e=Math.floor(t/1e3),a=Math.floor(e/60),r=e%60;return `${a}:${String(r).padStart(2,"0")}`}function zo(t){return t<1024*1024?`${Math.round(t/1024)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Lo(t){let{state:e,controller:a,start:r,stop:i,clearSelection:p,submit:n}=ie(),l=t.config.ui?.position,o=Me(t.config.ui?.strings),s=t.config.ui?.branding!==false,[h,z]=react.useState(null),[f,S]=react.useState(""),[b,B]=react.useState(t.config.capture?.element??true),[v,O]=react.useState(t.config.capture?.fullPage??false),[pt,ce]=react.useState(null),[D,le]=react.useState(void 0),de=t.config.ui?.categories??Ro,ft=t.config.recording?.enabled===true&&chunkFM72GX3J_cjs.l(),ut=t.config.recording?.maxDurationMs??3e4,pe=a.getConfig().voice,bt=pe?.enabled===true&&chunkFM72GX3J_cjs.n(),gt=pe?.maxDurationMs??6e4,[mt,ht]=react.useState(false),[J,xt]=react.useState(0);react.useEffect(()=>{let d=window.setTimeout(()=>{let y=chunkFM72GX3J_cjs.w();xt(y.findings.length);},500);return ()=>window.clearTimeout(d)},[]),react.useImperativeHandle(t.handleRef,()=>({open:r,close:i,submit:d=>n(d),startRecording:()=>a.startRecording(),stopRecording:()=>a.stopRecording(),get isOpen(){return e.phase!=="idle"}}),[r,i,n,a,e.phase]);let fe=e.phase==="review"||e.phase==="capturing"||e.phase==="submitting"||e.phase==="error"||e.phase==="success",vt=Po(fe),[yt,wt]=react.useState(0);react.useEffect(()=>{e.phase==="idle"&&wt(chunkFM72GX3J_cjs.i());},[e.phase]);let[kt,ue]=react.useState(false),be=react.useRef(e.phase);react.useEffect(()=>{if(be.current==="success"&&e.phase==="idle"){ue(true);let d=window.setTimeout(()=>ue(false),1500);return ()=>window.clearTimeout(d)}be.current=e.phase;},[e.phase]),react.useEffect(()=>{let d=t.config.ui?.shortcut;if(!d)return;let y=d.toLowerCase().split("+").map(P=>P.trim()),C=y[y.length-1]||"",L=new Set(y.slice(0,-1)),he=P=>{let Ct=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(L.has("mod")){if(Ct?!P.metaKey:!P.ctrlKey)return}else if(L.has("ctrl")&&!P.ctrlKey||(L.has("meta")||L.has("cmd"))&&!P.metaKey)return;L.has("shift")&&!P.shiftKey||(L.has("alt")||L.has("option"))&&!P.altKey||P.key.toLowerCase()===C&&(P.preventDefault(),e.phase==="idle"?r():i());};return document.addEventListener("keydown",he),()=>document.removeEventListener("keydown",he)},[t.config.ui?.shortcut,e.phase,r,i]),react.useEffect(()=>a.subscribeHover(z),[a]),react.useEffect(()=>{let d=a.__unsafeGetSelectedElement();if(!d||e.phase==="idle"||e.phase==="picking"){ce(null);return}let y=()=>{ce(chunkFM72GX3J_cjs.b(d.getBoundingClientRect()));};y();let C=()=>y();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);}},[a,e.phase,e.selection?.selector]),react.useEffect(()=>{e.phase==="review"&&(S(""),B(t.config.capture?.element??true),O(t.config.capture?.fullPage??false),le(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 d=window.setTimeout(()=>i(),1200);return ()=>window.clearTimeout(d)},[e.phase,i]);let T=e.phase==="capturing"||e.phase==="submitting",R=e.phase==="picking"?h?.rect??null:pt??e.selection?.rect??null,Z=react.useMemo(()=>R?Eo(R,360,l):null,[R?.x,R?.y,R?.width,R?.height,l]),ge=e.lastError?.message,ee=react.useCallback(()=>{let d={capture:{element:b,fullPage:v}};D&&(d.category=D),n(f,d);},[n,f,b,v,D]),Tt=react.useCallback(d=>{(d.metaKey||d.ctrlKey)&&d.key==="Enter"&&f.trim().length>0&&!T&&(d.preventDefault(),ee());},[ee,f,T]),[me,V]=react.useState(null),St=react.useCallback(async()=>{if(e.voiceRecording){a.stopVoice();return}V(null);let d=await a.startVoice();if(d?.text)S(y=>y?y+" "+d.text:d.text);else if(d?.warning)V(o.voiceEmptyText);else if(!d){let y=a.getState().lastError;if(y){let C=y.message?.toLowerCase()??"";C.includes("denied")||C.includes("permission")||C.includes("not allowed")?V(o.voiceDeniedText):V(o.voiceErrorText);}}},[e.voiceRecording,a,o]),Et=ct(t.config.ui?.triggerStyle);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Et,{position:l,onClick:()=>r(),isVisible:e.phase==="idle",label:t.config.ui?.triggerLabel??o.triggerLabel,queueCount:yt,showSuccess:kt}),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:()=>i()}),R&&jsxRuntime.jsx(Co,{rect:R}),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:()=>i(),"aria-label":o.cancelButton,children:o.cancelButton})]}),fe&&Z&&jsxRuntime.jsxs("div",{ref:vt,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:T,"aria-label":o.rePickButton,children:o.rePickButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>i(),disabled:T,"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:d=>S(d.target.value),onKeyDown:Tt,disabled:T,"aria-label":o.panelTitle}),de.length>0&&jsxRuntime.jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:de.map(d=>jsxRuntime.jsx("button",{type:"button",className:`bf-pill${D===d?" bf-pill-active":""}`,onClick:()=>le(D===d?void 0:d),disabled:T,children:o[Mo[d]]},d))}),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:d=>B(d.target.checked),disabled:T}),o.screenshotElement]}),jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:v,onChange:d=>O(d.target.checked),disabled:T}),o.screenshotFullPage]})]}),bt&&e.phase==="review"&&!e.voiceTranscribing&&jsxRuntime.jsx("button",{type:"button",className:`bf-voice-btn${e.voiceRecording?" bf-voice-btn-active":""}`,onClick:St,disabled:T,"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(gt)," \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]}),me&&!e.voiceRecording&&!e.voiceTranscribing&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:me}),ft&&e.phase==="review"&&!e.video&&jsxRuntime.jsxs("button",{type:"button",className:"bf-record-btn",onClick:()=>a.startRecording(),disabled:T,"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:()=>a.removeVideo(),"aria-label":o.removeVideoButton,children:"\xD7"}),jsxRuntime.jsxs("div",{className:"bf-video-meta",children:[o.videoPreviewLabel," (",X(e.video.durationMs),", ",zo(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"&&ge&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:ge}),jsxRuntime.jsxs("div",{className:"bf-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>i(),disabled:T,"aria-label":o.cancelButton,children:o.cancelButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:ee,disabled:T||f.trim().length===0,"aria-label":o.sendButton,children:o.sendButton})]})]}),s&&jsxRuntime.jsx("div",{className:"bf-watermark",children: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(ut)]}),jsxRuntime.jsx("button",{type:"button",className:"bf-recording-bar-stop",onClick:()=>a.stopRecording(),"aria-label":o.stopRecordButton,children:o.stopRecordButton})]}),e.phase==="success"&&jsxRuntime.jsx("div",{className:"bf-toast",role:"status","aria-live":"polite",children:o.toastText}),J>0&&!mt&&jsxRuntime.jsxs("div",{className:"bf-security-banner",role:"alert",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-security-banner-dismiss",onClick:()=>ht(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 Ao=react.forwardRef(function(e,a){let r={...e.config??{},blocfeed_id:e.blocfeed_id},[i,p]=react.useState(null),n=No(r.ui?.showOn),l=Fo(r.ui?.theme?.mode),o=!!r.diagnostics;react.useEffect(()=>{if(o)return chunkFM72GX3J_cjs.r(r.diagnostics),()=>chunkFM72GX3J_cjs.s()},[o]);let s=!!r.security;react.useEffect(()=>{s&&chunkFM72GX3J_cjs.v(r.security);},[s]);let h=react.useRef(e.config?.metadata?.enrich);h.current=e.config?.metadata?.enrich;let z=react.useMemo(()=>{if(e.config)return {...e.config,metadata:{...e.config.metadata,enrich:async f=>{let S=h.current,b=S?await S(f):{},B=chunkFM72GX3J_cjs.t(),v=chunkFM72GX3J_cjs.w(),O=chunkFM72GX3J_cjs.j();return {...b,...B.consoleLogs.length>0?{_consoleLogs:B.consoleLogs}:{},...B.networkErrors.length>0?{_networkErrors:B.networkErrors}:{},...v.findings.length>0?{_securityFindings:v.findings}:{},...O.length>0?{_clickEvents:O}:{}}}}}},[]);return react.useEffect(()=>{Fe();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;return 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)),document.body.appendChild(f),p(f),()=>{f.remove(),p(null);}},[r.ui?.zIndex,r.ui?.theme?.accentColor,r.ui?.theme?.panelBackground,r.ui?.theme?.panelForeground,r.ui?.theme?.fontFamily,l]),react.useEffect(()=>{i&&i.setAttribute("data-bf-theme",l);},[i,l]),!n||!i?null:reactDom.createPortal(jsxRuntime.jsx(re,{blocfeed_id:r.blocfeed_id,...z?{config:z}:{},children:jsxRuntime.jsx(Lo,{config:r,handleRef:a})}),i)});
|
|
846
|
-
exports.BlocFeedProvider=
|
|
884
|
+
`;function Re(){if(!chunkVK43CZAG_cjs.a()||document.getElementById(Fe))return;let t=document.createElement("style");t.id=Fe,t.textContent=Mt,document.head.appendChild(t);}var Me={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?{...Me,...t}:Me}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 w(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 Le({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 We({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){return a?jsxRuntime.jsxs("button",{className:w(t),type:"button",onClick:e,"aria-label":r,children:[f?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]}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]}):null}function m(){let[t,e]=react.useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return react.useEffect(()=>{let a=window.matchMedia("(prefers-reduced-motion: reduce)"),r=i=>e(i.matches);return a.addEventListener("change",r),()=>a.removeEventListener("change",r)},[]),t}var Ht={duration:.18,ease:"easeOut"},Ot={duration:0};function He({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=react.useState(false),o=m(),c=o?Ot:Ht;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsx(framerMotion.motion.button,{className:w(t),type:"button",onClick:e,onMouseEnter:()=>d(true),onMouseLeave:()=>d(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:f?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")}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"dot")})}var Kt={duration:.18,ease:"easeOut"},De={duration:0};function $e({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=react.useState(false),o=m(),c=o?De:Kt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsxs(framerMotion.motion.div,{className:w(t),initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{y:8,opacity:0},transition:c,onMouseEnter:()=>d(true),onMouseLeave:()=>d(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?De:{y:{duration:3,repeat:1/0,ease:"easeInOut"}},whileHover:{scale:1.1,borderColor:"var(--bf-accent)"},whileTap:{scale:.9},children:[f?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(Le,{size:16}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${i} queued`,children:i})]})]},"bubble")})}var Yt={duration:.2,ease:"easeOut"},Gt={duration:0};function Ue(t){return t==="bottom-left"||t==="top-left"}function jt(t){return `bf-trigger-edge ${Ue(t)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function Xe({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=react.useState(false),o=Ue(t),c=m(),h=c?Gt:Yt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsx(framerMotion.motion.button,{className:jt(t),type:"button",onClick:e,onMouseEnter:()=>d(true),onMouseLeave:()=>d(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:h,whileTap:{scale:.97},style:{top:"50%",translateY:"-50%"},children:f?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:h,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:h,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)"}}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"edge-tab")})}var Jt={duration:.18,ease:"easeOut"},Zt={duration:0};function Ge({delay:t,hovered:e,reduced:a}){return a?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:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=react.useState(false),o=m(),c=o?Zt:Jt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsx(framerMotion.motion.button,{className:w(t),type:"button",onClick:e,onMouseEnter:()=>d(true),onMouseLeave:()=>d(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:f?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(Ge,{delay:0,hovered:n,reduced:o}),jsxRuntime.jsx(Ge,{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")}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"pulse-ring")})}var ro={duration:.18,ease:"easeOut"},io={duration:0};function ao(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 Ze({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=react.useState(false),o=m(),c=o?io:ro;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsxs(framerMotion.motion.button,{className:ao(t),type:"button",onClick:e,onMouseEnter:()=>d(true),onMouseLeave:()=>d(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:[f?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}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${i} queued`,children:i})]}),!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 co={duration:.18,ease:"easeOut"},lo={duration:0};function tt({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=react.useState(false),o=m(),c=o?lo:co;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsx(framerMotion.motion.button,{className:w(t),type:"button",onClick:e,onMouseEnter:()=>d(true),onMouseLeave:()=>d(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:f?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")}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"icon-pop")})}var bo={duration:.18,ease:"easeOut"},go={duration:0};function it({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=react.useState(false),o=m(),c=o?go:bo;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsx(framerMotion.motion.button,{className:w(t),type:"button",onClick:e,onMouseEnter:()=>d(true),onMouseLeave:()=>d(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:f?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")}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"beacon")})}var yo={duration:.18,ease:"easeOut"},wo={duration:0};function ct({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=react.useState(false),[o,c]=react.useState(0),h=m(),z=h?wo:yo,p=react.useRef(null);react.useEffect(()=>{if(p.current&&(clearInterval(p.current),p.current=null),!a||n||h){c(n||h?r.length:0);return}let b=8,B=r.length*2+b*2,v=0;return p.current=setInterval(()=>{v=(v+1)%B,v<=r.length?c(v):v<=r.length+b?c(r.length):v<=r.length*2+b?c(r.length*2+b-v):c(0);},100),()=>{p.current&&(clearInterval(p.current),p.current=null);}},[a,n,h,r]);let S=r.slice(0,o);return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:a&&jsxRuntime.jsx(framerMotion.motion.button,{className:w(t),type:"button",onClick:e,onMouseEnter:()=>d(true),onMouseLeave:()=>d(false),"aria-label":r,initial:{opacity:0,y:h?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:h?0:5},transition:z,whileTap:{scale:.95},style:{minWidth:"44px"},children:f?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"})]}),i>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"typewriter")})}function lt(t){switch(t){case "dot":return He;case "bubble":return $e;case "edge-tab":return Xe;case "pulse-ring":return Qe;case "minimal":return Ze;case "icon-pop":return tt;case "beacon":return it;case "typewriter":return ct;default:return We}}function dt(t,e,a){return Math.max(e,Math.min(a,t))}function Co(t,e,a="bottom-right"){let i=window.innerWidth,f=window.innerHeight,n;n=dt(t.x,12,Math.max(12,i-e-12));let d=t.y+t.height+12,o=Math.max(12,t.y-240);return {top:d+240<=f?d:o,left:n}}function Po(t){let{rect:e}=t,a={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:a,"aria-hidden":"true"})}function Bo(t){let e=react.useRef(null);return react.useEffect(()=>{if(!t||!e.current)return;e.current.querySelector(".bf-textarea")?.focus();let r=i=>{if(i.key!=="Tab"||!e.current)return;let f=e.current.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(f.length===0)return;let n=f[0],d=f[f.length-1];i.shiftKey&&document.activeElement===n?(i.preventDefault(),d.focus()):!i.shiftKey&&document.activeElement===d&&(i.preventDefault(),n.focus());};return document.addEventListener("keydown",r,{capture:true}),()=>document.removeEventListener("keydown",r,{capture:true})},[t]),e}function No(t,e){return t?typeof t=="function"?t(e):t.some(a=>a.endsWith("*")?e.startsWith(a.slice(0,-1)):e===a):true}function Fo(t){let[e,a]=react.useState(()=>typeof window<"u"?window.location.pathname:"/");return react.useEffect(()=>{if(typeof window>"u")return;let r=()=>a(window.location.pathname);window.addEventListener("popstate",r);let i=history.pushState,f=history.replaceState;return history.pushState=function(...n){i.apply(this,n),setTimeout(r,0);},history.replaceState=function(...n){f.apply(this,n),setTimeout(r,0);},()=>{window.removeEventListener("popstate",r),history.pushState=i,history.replaceState=f;}},[]),No(t,e)}function Ro(t){let[e,a]=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"){a(t==="light"?"light":"dark");return}let r=window.matchMedia("(prefers-color-scheme: dark)"),i=f=>a(f.matches?"dark":"light");return a(r.matches?"dark":"light"),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[t]),e}var Mo=["bug","feature","ux","general"],zo={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function X(t){let e=Math.floor(t/1e3),a=Math.floor(e/60),r=e%60;return `${a}:${String(r).padStart(2,"0")}`}function Lo(t){return t<1024*1024?`${Math.round(t/1024)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Ao(t){let{state:e,controller:a,start:r,stop:i,clearSelection:f,submit:n}=ae(),d=t.config.ui?.position,o=ze(t.config.ui?.strings),c=t.config.ui?.branding!==false,[h,z]=react.useState(null),[p,S]=react.useState(""),[b,B]=react.useState(t.config.capture?.element??true),[v,O]=react.useState(t.config.capture?.fullPage??false),[pt,le]=react.useState(null),[D,de]=react.useState(void 0),fe=t.config.ui?.categories??Mo,ut=t.config.recording?.enabled===true&&chunkVK43CZAG_cjs.l(),bt=t.config.recording?.maxDurationMs??3e4,pe=a.getConfig().voice,gt=pe?.enabled===true&&chunkVK43CZAG_cjs.n(),mt=pe?.maxDurationMs??6e4,[ht,xt]=react.useState(false),[J,vt]=react.useState(0);react.useEffect(()=>{let s=window.setTimeout(()=>{let y=chunkVK43CZAG_cjs.y();vt(y.findings.length);},500);return ()=>window.clearTimeout(s)},[]),react.useImperativeHandle(t.handleRef,()=>({open:r,close:i,submit:s=>n(s),startRecording:()=>a.startRecording(),stopRecording:()=>a.stopRecording(),get isOpen(){return e.phase!=="idle"}}),[r,i,n,a,e.phase]);let ue=e.phase==="review"||e.phase==="capturing"||e.phase==="submitting"||e.phase==="error"||e.phase==="success",yt=Bo(ue),[wt,kt]=react.useState(0);react.useEffect(()=>{e.phase==="idle"&&kt(chunkVK43CZAG_cjs.i());},[e.phase]);let[Tt,be]=react.useState(false),ge=react.useRef(e.phase);react.useEffect(()=>{if(ge.current==="success"&&e.phase==="idle"){be(true);let s=window.setTimeout(()=>be(false),1500);return ()=>window.clearTimeout(s)}ge.current=e.phase;},[e.phase]),react.useEffect(()=>{let s=t.config.ui?.shortcut;if(!s)return;let y=s.toLowerCase().split("+").map(P=>P.trim()),C=y[y.length-1]||"",L=new Set(y.slice(0,-1)),xe=P=>{let Pt=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(L.has("mod")){if(Pt?!P.metaKey:!P.ctrlKey)return}else if(L.has("ctrl")&&!P.ctrlKey||(L.has("meta")||L.has("cmd"))&&!P.metaKey)return;L.has("shift")&&!P.shiftKey||(L.has("alt")||L.has("option"))&&!P.altKey||P.key.toLowerCase()===C&&(P.preventDefault(),e.phase==="idle"?r():i());};return document.addEventListener("keydown",xe),()=>document.removeEventListener("keydown",xe)},[t.config.ui?.shortcut,e.phase,r,i]),react.useEffect(()=>a.subscribeHover(z),[a]),react.useEffect(()=>{let s=a.__unsafeGetSelectedElement();if(!s||e.phase==="idle"||e.phase==="picking"){le(null);return}let y=()=>{le(chunkVK43CZAG_cjs.b(s.getBoundingClientRect()));};y();let C=()=>y();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);}},[a,e.phase,e.selection?.selector]),react.useEffect(()=>{e.phase==="review"&&(S(""),B(t.config.capture?.element??true),O(t.config.capture?.fullPage??false),de(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(()=>i(),1200);return ()=>window.clearTimeout(s)},[e.phase,i]);let T=e.phase==="capturing"||e.phase==="submitting",R=e.phase==="picking"?h?.rect??null:pt??e.selection?.rect??null,Z=react.useMemo(()=>R?Co(R,360,d):null,[R?.x,R?.y,R?.width,R?.height,d]),me=e.lastError?.message,ee=react.useCallback(()=>{let s={capture:{element:b,fullPage:v}};D&&(s.category=D),n(p,s);},[n,p,b,v,D]),St=react.useCallback(s=>{(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&p.trim().length>0&&!T&&(s.preventDefault(),ee());},[ee,p,T]),[he,V]=react.useState(null),Et=react.useCallback(async()=>{if(e.voiceRecording){a.stopVoice();return}V(null);let s=await a.startVoice();if(s?.text)S(y=>y?y+" "+s.text:s.text);else if(s?.warning)V(o.voiceEmptyText);else if(!s){let y=a.getState().lastError;if(y){let C=y.message?.toLowerCase()??"";C.includes("denied")||C.includes("permission")||C.includes("not allowed")?V(o.voiceDeniedText):V(o.voiceErrorText);}}},[e.voiceRecording,a,o]),Ct=lt(t.config.ui?.triggerStyle);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ct,{position:d,onClick:()=>r(),isVisible:e.phase==="idle",label:t.config.ui?.triggerLabel??o.triggerLabel,queueCount:wt,showSuccess:Tt}),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:()=>i()}),R&&jsxRuntime.jsx(Po,{rect:R}),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:()=>i(),"aria-label":o.cancelButton,children:o.cancelButton})]}),ue&&Z&&jsxRuntime.jsxs("div",{ref:yt,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:()=>f(),disabled:T,"aria-label":o.rePickButton,children:o.rePickButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>i(),disabled:T,"aria-label":o.closeButton,children:o.closeButton})]})]}),jsxRuntime.jsxs("div",{className:"bf-panelBody",children:[jsxRuntime.jsx("textarea",{className:"bf-textarea",placeholder:o.textareaPlaceholder,value:p,onChange:s=>S(s.target.value),onKeyDown:St,disabled:T,"aria-label":o.panelTitle}),fe.length>0&&jsxRuntime.jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:fe.map(s=>jsxRuntime.jsx("button",{type:"button",className:`bf-pill${D===s?" bf-pill-active":""}`,onClick:()=>de(D===s?void 0:s),disabled:T,children:o[zo[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=>B(s.target.checked),disabled:T}),o.screenshotElement]}),jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:v,onChange:s=>O(s.target.checked),disabled:T}),o.screenshotFullPage]})]}),gt&&e.phase==="review"&&!e.voiceTranscribing&&jsxRuntime.jsx("button",{type:"button",className:`bf-voice-btn${e.voiceRecording?" bf-voice-btn-active":""}`,onClick:Et,disabled:T,"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(mt)," \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]}),he&&!e.voiceRecording&&!e.voiceTranscribing&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:he}),ut&&e.phase==="review"&&!e.video&&jsxRuntime.jsxs("button",{type:"button",className:"bf-record-btn",onClick:()=>a.startRecording(),disabled:T,"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:()=>a.removeVideo(),"aria-label":o.removeVideoButton,children:"\xD7"}),jsxRuntime.jsxs("div",{className:"bf-video-meta",children:[o.videoPreviewLabel," (",X(e.video.durationMs),", ",Lo(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"&&me&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:me}),jsxRuntime.jsxs("div",{className:"bf-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>i(),disabled:T,"aria-label":o.cancelButton,children:o.cancelButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:ee,disabled:T||p.trim().length===0,"aria-label":o.sendButton,children:o.sendButton})]})]}),c&&jsxRuntime.jsxs("div",{className:"bf-watermark",children:[(()=>{let s=chunkVK43CZAG_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-${d}`,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(bt)]}),jsxRuntime.jsx("button",{type:"button",className:"bf-recording-bar-stop",onClick:()=>a.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=chunkVK43CZAG_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&&!ht&&jsxRuntime.jsxs("div",{className:"bf-security-banner",role:"alert",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-security-banner-dismiss",onClick:()=>xt(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 Io=react.forwardRef(function(e,a){let r={...e.config??{},blocfeed_id:e.blocfeed_id},[i,f]=react.useState(null),n=Fo(r.ui?.showOn),d=Ro(r.ui?.theme?.mode),o=!!r.diagnostics;react.useEffect(()=>{if(o)return chunkVK43CZAG_cjs.t(r.diagnostics),()=>chunkVK43CZAG_cjs.u()},[o]);let c=!!r.security;react.useEffect(()=>{c&&chunkVK43CZAG_cjs.x(r.security);},[c]);let h=react.useRef(e.config?.metadata?.enrich);h.current=e.config?.metadata?.enrich;let z=react.useMemo(()=>{if(e.config)return {...e.config,metadata:{...e.config.metadata,enrich:async p=>{let S=h.current,b=S?await S(p):{},B=chunkVK43CZAG_cjs.v(),v=chunkVK43CZAG_cjs.y(),O=chunkVK43CZAG_cjs.j();return {...b,...B.consoleLogs.length>0?{_consoleLogs:B.consoleLogs}:{},...B.networkErrors.length>0?{_networkErrors:B.networkErrors}:{},...v.findings.length>0?{_securityFindings:v.findings}:{},...O.length>0?{_clickEvents:O}:{}}}}}},[]);return react.useEffect(()=>{Re();let p=document.createElement("div");p.setAttribute("data-blocfeed-ui-root","true"),p.setAttribute("data-blocfeed-ui","true"),p.setAttribute("data-bf-theme",d);let S=r.ui?.zIndex;typeof S=="number"&&p.style.setProperty("--bf-z",String(S));let b=r.ui?.theme;return b&&(b.accentColor&&p.style.setProperty("--bf-accent",b.accentColor),b.panelBackground&&p.style.setProperty("--bf-panel-bg",b.panelBackground),b.panelForeground&&p.style.setProperty("--bf-panel-fg",b.panelForeground),b.fontFamily&&p.style.setProperty("--bf-font",b.fontFamily)),document.body.appendChild(p),f(p),()=>{p.remove(),f(null);}},[r.ui?.zIndex,r.ui?.theme?.accentColor,r.ui?.theme?.panelBackground,r.ui?.theme?.panelForeground,r.ui?.theme?.fontFamily,d]),react.useEffect(()=>{i&&i.setAttribute("data-bf-theme",d);},[i,d]),!n||!i?null:reactDom.createPortal(jsxRuntime.jsx(ie,{blocfeed_id:r.blocfeed_id,...z?{config:z}:{},children:jsxRuntime.jsx(Ao,{config:r,handleRef:a})}),i)});
|
|
885
|
+
exports.BlocFeedProvider=ie;exports.BlocFeedWidget=Io;exports.useBlocFeed=ae;
|
package/dist/main.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BlocFeedConfig, a as BlocFeedHandle, b as BlocFeedState, c as BlocFeedController, C as CaptureConfig, F as FeedbackCategory, S as SubmitResult } from './controller-
|
|
2
|
-
export { d as BlocFeedError, e as BlocFeedStrings, f as BlocFeedUser, g as CaptureDiagnostics, h as CaptureResult, i as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, j as FeedbackApiResponse, k as FeedbackPayload, I as ImageAsset, M as MaybePromise, l as MetadataConfig, m as MetadataContext, N as NetworkEntry, P as PickerConfig, R as RecordingConfig, n as Rect, o as ScreenshotAdapter, p as ScreenshotAdapterOptions, q as ScreenshotIntent, r as ScreenshotMime, s as SecurityConfig, t as SecurityFinding, u as SecuritySnapshot, v as SessionPhase, T as ThemeConfig, w as TransportConfig, x as TransportResult, y as TriggerStyle, V as VideoAsset, z as VideoIntent, A as VideoMime, G as VoiceConfig, W as WidgetPosition } from './controller-
|
|
1
|
+
import { B as BlocFeedConfig, a as BlocFeedHandle, b as BlocFeedState, c as BlocFeedController, C as CaptureConfig, F as FeedbackCategory, S as SubmitResult } from './controller-JCtPYbzs.cjs';
|
|
2
|
+
export { d as BlocFeedError, e as BlocFeedStrings, f as BlocFeedUser, g as CaptureDiagnostics, h as CaptureResult, i as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, j as FeedbackApiResponse, k as FeedbackPayload, I as ImageAsset, M as MaybePromise, l as MetadataConfig, m as MetadataContext, N as NetworkEntry, P as PickerConfig, R as RecordingConfig, n as Rect, o as ScreenshotAdapter, p as ScreenshotAdapterOptions, q as ScreenshotIntent, r as ScreenshotMime, s as SecurityConfig, t as SecurityFinding, u as SecuritySnapshot, v as SessionPhase, T as ThemeConfig, w as TransportConfig, x as TransportResult, y as TriggerStyle, V as VideoAsset, z as VideoIntent, A as VideoMime, G as VoiceConfig, W as WidgetPosition } from './controller-JCtPYbzs.cjs';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ReactNode } from 'react';
|
package/dist/main.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BlocFeedConfig, a as BlocFeedHandle, b as BlocFeedState, c as BlocFeedController, C as CaptureConfig, F as FeedbackCategory, S as SubmitResult } from './controller-
|
|
2
|
-
export { d as BlocFeedError, e as BlocFeedStrings, f as BlocFeedUser, g as CaptureDiagnostics, h as CaptureResult, i as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, j as FeedbackApiResponse, k as FeedbackPayload, I as ImageAsset, M as MaybePromise, l as MetadataConfig, m as MetadataContext, N as NetworkEntry, P as PickerConfig, R as RecordingConfig, n as Rect, o as ScreenshotAdapter, p as ScreenshotAdapterOptions, q as ScreenshotIntent, r as ScreenshotMime, s as SecurityConfig, t as SecurityFinding, u as SecuritySnapshot, v as SessionPhase, T as ThemeConfig, w as TransportConfig, x as TransportResult, y as TriggerStyle, V as VideoAsset, z as VideoIntent, A as VideoMime, G as VoiceConfig, W as WidgetPosition } from './controller-
|
|
1
|
+
import { B as BlocFeedConfig, a as BlocFeedHandle, b as BlocFeedState, c as BlocFeedController, C as CaptureConfig, F as FeedbackCategory, S as SubmitResult } from './controller-JCtPYbzs.js';
|
|
2
|
+
export { d as BlocFeedError, e as BlocFeedStrings, f as BlocFeedUser, g as CaptureDiagnostics, h as CaptureResult, i as ConsoleEntry, D as DiagnosticsConfig, E as ElementDescriptor, j as FeedbackApiResponse, k as FeedbackPayload, I as ImageAsset, M as MaybePromise, l as MetadataConfig, m as MetadataContext, N as NetworkEntry, P as PickerConfig, R as RecordingConfig, n as Rect, o as ScreenshotAdapter, p as ScreenshotAdapterOptions, q as ScreenshotIntent, r as ScreenshotMime, s as SecurityConfig, t as SecurityFinding, u as SecuritySnapshot, v as SessionPhase, T as ThemeConfig, w as TransportConfig, x as TransportResult, y as TriggerStyle, V as VideoAsset, z as VideoIntent, A as VideoMime, G as VoiceConfig, W as WidgetPosition } from './controller-JCtPYbzs.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ReactNode } from 'react';
|
package/dist/main.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import {t,u,x,v,y,j,a,s,l,n,i,q,b}from'./chunk-EADEWOWW.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 Y=createContext(null);function ie(t){let e=useMemo(()=>s({...t.config??{},blocfeed_id:t.blocfeed_id}),[]),[a,r]=useState(()=>e.getState());return useEffect(()=>e.subscribe(r),[e]),useEffect(()=>e.setConfig({...t.config??{},blocfeed_id:t.blocfeed_id}),[e,t.config,t.blocfeed_id]),useEffect(()=>()=>e.destroy(),[e]),jsx(Y.Provider,{value:{controller:e,state:a},children:t.children})}var Fe="blocfeed-styles-v1",Mt=`
|
|
3
3
|
:where([data-blocfeed-ui-root]),
|
|
4
4
|
:where([data-blocfeed-ui-root]) * {
|
|
5
5
|
box-sizing: border-box;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
:where([data-blocfeed-ui-root]) {
|
|
9
|
-
--bf-z:
|
|
9
|
+
--bf-z: 2147483647;
|
|
10
10
|
--bf-font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
|
|
11
11
|
--bf-panel-bg: rgba(17, 24, 39, 0.98);
|
|
12
12
|
--bf-panel-fg: rgb(243, 244, 246);
|
|
@@ -16,6 +16,17 @@ import {r,s,v,t,w as w$1,j,a,q,l,n,i,b}from'./chunk-A6OH75KK.js';import {createC
|
|
|
16
16
|
--bf-danger: rgb(239, 68, 68);
|
|
17
17
|
--bf-shadow: 0 18px 55px rgba(0, 0, 0, 0.45);
|
|
18
18
|
|
|
19
|
+
/* Ensure widget always floats above customer modals/sidepanels/overlays */
|
|
20
|
+
position: fixed;
|
|
21
|
+
top: 0;
|
|
22
|
+
left: 0;
|
|
23
|
+
width: 0;
|
|
24
|
+
height: 0;
|
|
25
|
+
overflow: visible;
|
|
26
|
+
z-index: var(--bf-z);
|
|
27
|
+
isolation: isolate;
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
|
|
19
30
|
font-family: var(--bf-font);
|
|
20
31
|
color: var(--bf-panel-fg);
|
|
21
32
|
}
|
|
@@ -75,6 +86,7 @@ import {r,s,v,t,w as w$1,j,a,q,l,n,i,b}from'./chunk-A6OH75KK.js';import {createC
|
|
|
75
86
|
right: 18px;
|
|
76
87
|
bottom: 18px;
|
|
77
88
|
z-index: var(--bf-z);
|
|
89
|
+
pointer-events: auto;
|
|
78
90
|
|
|
79
91
|
display: inline-flex;
|
|
80
92
|
align-items: center;
|
|
@@ -382,6 +394,7 @@ import {r,s,v,t,w as w$1,j,a,q,l,n,i,b}from'./chunk-A6OH75KK.js';import {createC
|
|
|
382
394
|
:where([data-blocfeed-ui-root]) .bf-trigger-edge {
|
|
383
395
|
position: fixed;
|
|
384
396
|
z-index: var(--bf-z);
|
|
397
|
+
pointer-events: auto;
|
|
385
398
|
display: flex;
|
|
386
399
|
align-items: center;
|
|
387
400
|
justify-content: center;
|
|
@@ -427,6 +440,7 @@ import {r,s,v,t,w as w$1,j,a,q,l,n,i,b}from'./chunk-A6OH75KK.js';import {createC
|
|
|
427
440
|
right: 18px;
|
|
428
441
|
bottom: 18px;
|
|
429
442
|
z-index: var(--bf-z);
|
|
443
|
+
pointer-events: auto;
|
|
430
444
|
display: inline-flex;
|
|
431
445
|
align-items: center;
|
|
432
446
|
background: transparent;
|
|
@@ -828,6 +842,31 @@ import {r,s,v,t,w as w$1,j,a,q,l,n,i,b}from'./chunk-A6OH75KK.js';import {createC
|
|
|
828
842
|
color: var(--bf-accent);
|
|
829
843
|
}
|
|
830
844
|
|
|
845
|
+
:where([data-blocfeed-ui-root]) .bf-watermark .bf-my-feedback-link {
|
|
846
|
+
display: block;
|
|
847
|
+
margin-bottom: 2px;
|
|
848
|
+
font-size: 10px;
|
|
849
|
+
color: var(--bf-accent);
|
|
850
|
+
opacity: 0.7;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
:where([data-blocfeed-ui-root]) .bf-watermark .bf-my-feedback-link:hover {
|
|
854
|
+
opacity: 1;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
:where([data-blocfeed-ui-root]) .bf-toast-link {
|
|
858
|
+
display: block;
|
|
859
|
+
margin-top: 4px;
|
|
860
|
+
font-size: 11px;
|
|
861
|
+
color: var(--bf-accent);
|
|
862
|
+
pointer-events: auto;
|
|
863
|
+
text-decoration: none;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
:where([data-blocfeed-ui-root]) .bf-toast-link:hover {
|
|
867
|
+
text-decoration: underline;
|
|
868
|
+
}
|
|
869
|
+
|
|
831
870
|
/* ------------------------------------------------------------------ */
|
|
832
871
|
/* Reduced motion */
|
|
833
872
|
/* ------------------------------------------------------------------ */
|
|
@@ -842,5 +881,5 @@ import {r,s,v,t,w as w$1,j,a,q,l,n,i,b}from'./chunk-A6OH75KK.js';import {createC
|
|
|
842
881
|
animation: none;
|
|
843
882
|
}
|
|
844
883
|
}
|
|
845
|
-
`;function Fe(){if(!a()||document.getElementById(Ne))return;let t=document.createElement("style");t.id=Ne,t.textContent=Rt,document.head.appendChild(t);}var Re={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 Me(t){return t?{...Re,...t}:Re}function ie(){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 w(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 ze({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 Le({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 Ie({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){return a?jsxs("button",{className:w(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]}),i>0&&jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]}):null}function m(){let[t,e]=useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return useEffect(()=>{let a=window.matchMedia("(prefers-reduced-motion: reduce)"),r=i=>e(i.matches);return a.addEventListener("change",r),()=>a.removeEventListener("change",r)},[]),t}var _t={duration:.18,ease:"easeOut"},Ht={duration:0};function _e({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=useState(false),o=m(),s=o?Ht:_t;return jsx(AnimatePresence,{mode:"wait",children:a&&jsx(motion.button,{className:w(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:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,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?s:{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:s,style:{whiteSpace:"nowrap"},children:r},"label")}),i>0&&jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"dot")})}var $t={duration:.18,ease:"easeOut"},Oe={duration:0};function Ve({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=useState(false),o=m(),s=o?Oe:$t;return jsx(AnimatePresence,{mode:"wait",children:a&&jsxs(motion.div,{className:w(t),initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{y:8,opacity:0},transition:s,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:s,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?Oe:{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:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:16})},"success"):jsx(ze,{size:16}),i>0&&jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${i} queued`,children:i})]})]},"bubble")})}var Xt={duration:.2,ease:"easeOut"},Yt={duration:0};function Ke(t){return t==="bottom-left"||t==="top-left"}function Gt(t){return `bf-trigger-edge ${Ke(t)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function Ue({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=useState(false),o=Ke(t),s=m(),h=s?Yt:Xt;return jsx(AnimatePresence,{mode:"wait",children:a&&jsx(motion.button,{className:Gt(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:h,whileTap:{scale:.97},style:{top:"50%",translateY:"-50%"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:h,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsxs(motion.span,{animate:{rotate:s||n?0:o?-90:90,opacity:n?1:.6},transition:h,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)"}}),i>0&&jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"edge-tab")})}var qt={duration:.18,ease:"easeOut"},Jt={duration:0};function Ye({delay:t,hovered:e,reduced:a}){return a?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 je({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=useState(false),o=m(),s=o?Jt:qt;return jsx(AnimatePresence,{mode:"wait",children:a&&jsx(motion.button,{className:w(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:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,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(Ye,{delay:0,hovered:n,reduced:o}),jsx(Ye,{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:s,style:{whiteSpace:"nowrap"},children:r},"label")}),i>0&&jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"pulse-ring")})}var oo={duration:.18,ease:"easeOut"},ro={duration:0};function io(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 Je({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=useState(false),o=m(),s=o?ro:oo;return jsx(AnimatePresence,{mode:"wait",children:a&&jsxs(motion.button,{className:io(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:s,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}),i>0&&jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${i} queued`,children:i})]}),!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:s})]},"minimal")})}var so={duration:.18,ease:"easeOut"},co={duration:0};function et({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=useState(false),o=m(),s=o?co:so;return jsx(AnimatePresence,{mode:"wait",children:a&&jsx(motion.button,{className:w(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:s,whileTap:{scale:.9},style:{overflow:"hidden"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,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?s:{duration:3,repeat:1/0,ease:"easeInOut"},children:jsx(Le,{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:s,style:{whiteSpace:"nowrap"},children:r},"label")}),i>0&&jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"icon-pop")})}var uo={duration:.18,ease:"easeOut"},bo={duration:0};function rt({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=useState(false),o=m(),s=o?bo:uo;return jsx(AnimatePresence,{mode:"wait",children:a&&jsx(motion.button,{className:w(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:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:p?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,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?s:{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:s,style:{whiteSpace:"nowrap"},children:r},"label")}),i>0&&jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"beacon")})}var vo={duration:.18,ease:"easeOut"},yo={duration:0};function st({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:p}){let[n,l]=useState(false),[o,s]=useState(0),h=m(),z=h?yo:vo,f=useRef(null);useEffect(()=>{if(f.current&&(clearInterval(f.current),f.current=null),!a||n||h){s(n||h?r.length:0);return}let b=8,B=r.length*2+b*2,v=0;return f.current=setInterval(()=>{v=(v+1)%B,v<=r.length?s(v):v<=r.length+b?s(r.length):v<=r.length*2+b?s(r.length*2+b-v):s(0);},100),()=>{f.current&&(clearInterval(f.current),f.current=null);}},[a,n,h,r]);let S=r.slice(0,o);return jsx(AnimatePresence,{mode:"wait",children:a&&jsx(motion.button,{className:w(t),type:"button",onClick:e,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":r,initial:{opacity:0,y:h?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:h?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"})]}),i>0&&jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"typewriter")})}function ct(t){switch(t){case "dot":return _e;case "bubble":return Ve;case "edge-tab":return Ue;case "pulse-ring":return je;case "minimal":return Je;case "icon-pop":return et;case "beacon":return rt;case "typewriter":return st;default:return Ie}}function lt(t,e,a){return Math.max(e,Math.min(a,t))}function Eo(t,e,a="bottom-right"){let i=window.innerWidth,p=window.innerHeight,n;n=lt(t.x,12,Math.max(12,i-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 Co(t){let{rect:e}=t,a={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:a,"aria-hidden":"true"})}function Po(t){let e=useRef(null);return useEffect(()=>{if(!t||!e.current)return;e.current.querySelector(".bf-textarea")?.focus();let r=i=>{if(i.key!=="Tab"||!e.current)return;let p=e.current.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(p.length===0)return;let n=p[0],l=p[p.length-1];i.shiftKey&&document.activeElement===n?(i.preventDefault(),l.focus()):!i.shiftKey&&document.activeElement===l&&(i.preventDefault(),n.focus());};return document.addEventListener("keydown",r,{capture:true}),()=>document.removeEventListener("keydown",r,{capture:true})},[t]),e}function Bo(t,e){return t?typeof t=="function"?t(e):t.some(a=>a.endsWith("*")?e.startsWith(a.slice(0,-1)):e===a):true}function No(t){let[e,a]=useState(()=>typeof window<"u"?window.location.pathname:"/");return useEffect(()=>{if(typeof window>"u")return;let r=()=>a(window.location.pathname);window.addEventListener("popstate",r);let i=history.pushState,p=history.replaceState;return history.pushState=function(...n){i.apply(this,n),setTimeout(r,0);},history.replaceState=function(...n){p.apply(this,n),setTimeout(r,0);},()=>{window.removeEventListener("popstate",r),history.pushState=i,history.replaceState=p;}},[]),Bo(t,e)}function Fo(t){let[e,a]=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"){a(t==="light"?"light":"dark");return}let r=window.matchMedia("(prefers-color-scheme: dark)"),i=p=>a(p.matches?"dark":"light");return a(r.matches?"dark":"light"),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[t]),e}var Ro=["bug","feature","ux","general"],Mo={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function X(t){let e=Math.floor(t/1e3),a=Math.floor(e/60),r=e%60;return `${a}:${String(r).padStart(2,"0")}`}function zo(t){return t<1024*1024?`${Math.round(t/1024)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Lo(t){let{state:e,controller:a,start:r,stop:i$1,clearSelection:p,submit:n$1}=ie(),l$1=t.config.ui?.position,o=Me(t.config.ui?.strings),s=t.config.ui?.branding!==false,[h,z]=useState(null),[f,S]=useState(""),[b$1,B]=useState(t.config.capture?.element??true),[v,O]=useState(t.config.capture?.fullPage??false),[pt,ce]=useState(null),[D,le]=useState(void 0),de=t.config.ui?.categories??Ro,ft=t.config.recording?.enabled===true&&l(),ut=t.config.recording?.maxDurationMs??3e4,pe=a.getConfig().voice,bt=pe?.enabled===true&&n(),gt=pe?.maxDurationMs??6e4,[mt,ht]=useState(false),[J,xt]=useState(0);useEffect(()=>{let d=window.setTimeout(()=>{let y=w$1();xt(y.findings.length);},500);return ()=>window.clearTimeout(d)},[]),useImperativeHandle(t.handleRef,()=>({open:r,close:i$1,submit:d=>n$1(d),startRecording:()=>a.startRecording(),stopRecording:()=>a.stopRecording(),get isOpen(){return e.phase!=="idle"}}),[r,i$1,n$1,a,e.phase]);let fe=e.phase==="review"||e.phase==="capturing"||e.phase==="submitting"||e.phase==="error"||e.phase==="success",vt=Po(fe),[yt,wt]=useState(0);useEffect(()=>{e.phase==="idle"&&wt(i());},[e.phase]);let[kt,ue]=useState(false),be=useRef(e.phase);useEffect(()=>{if(be.current==="success"&&e.phase==="idle"){ue(true);let d=window.setTimeout(()=>ue(false),1500);return ()=>window.clearTimeout(d)}be.current=e.phase;},[e.phase]),useEffect(()=>{let d=t.config.ui?.shortcut;if(!d)return;let y=d.toLowerCase().split("+").map(P=>P.trim()),C=y[y.length-1]||"",L=new Set(y.slice(0,-1)),he=P=>{let Ct=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(L.has("mod")){if(Ct?!P.metaKey:!P.ctrlKey)return}else if(L.has("ctrl")&&!P.ctrlKey||(L.has("meta")||L.has("cmd"))&&!P.metaKey)return;L.has("shift")&&!P.shiftKey||(L.has("alt")||L.has("option"))&&!P.altKey||P.key.toLowerCase()===C&&(P.preventDefault(),e.phase==="idle"?r():i$1());};return document.addEventListener("keydown",he),()=>document.removeEventListener("keydown",he)},[t.config.ui?.shortcut,e.phase,r,i$1]),useEffect(()=>a.subscribeHover(z),[a]),useEffect(()=>{let d=a.__unsafeGetSelectedElement();if(!d||e.phase==="idle"||e.phase==="picking"){ce(null);return}let y=()=>{ce(b(d.getBoundingClientRect()));};y();let C=()=>y();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);}},[a,e.phase,e.selection?.selector]),useEffect(()=>{e.phase==="review"&&(S(""),B(t.config.capture?.element??true),O(t.config.capture?.fullPage??false),le(void 0),V(null));},[e.phase,e.selection?.selector,t.config.capture?.element,t.config.capture?.fullPage]),useEffect(()=>{if(e.phase!=="success")return;let d=window.setTimeout(()=>i$1(),1200);return ()=>window.clearTimeout(d)},[e.phase,i$1]);let T=e.phase==="capturing"||e.phase==="submitting",R=e.phase==="picking"?h?.rect??null:pt??e.selection?.rect??null,Z=useMemo(()=>R?Eo(R,360,l$1):null,[R?.x,R?.y,R?.width,R?.height,l$1]),ge=e.lastError?.message,ee=useCallback(()=>{let d={capture:{element:b$1,fullPage:v}};D&&(d.category=D),n$1(f,d);},[n$1,f,b$1,v,D]),Tt=useCallback(d=>{(d.metaKey||d.ctrlKey)&&d.key==="Enter"&&f.trim().length>0&&!T&&(d.preventDefault(),ee());},[ee,f,T]),[me,V]=useState(null),St=useCallback(async()=>{if(e.voiceRecording){a.stopVoice();return}V(null);let d=await a.startVoice();if(d?.text)S(y=>y?y+" "+d.text:d.text);else if(d?.warning)V(o.voiceEmptyText);else if(!d){let y=a.getState().lastError;if(y){let C=y.message?.toLowerCase()??"";C.includes("denied")||C.includes("permission")||C.includes("not allowed")?V(o.voiceDeniedText):V(o.voiceErrorText);}}},[e.voiceRecording,a,o]),Et=ct(t.config.ui?.triggerStyle);return jsxs(Fragment,{children:[jsx(Et,{position:l$1,onClick:()=>r(),isVisible:e.phase==="idle",label:t.config.ui?.triggerLabel??o.triggerLabel,queueCount:yt,showSuccess:kt}),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:()=>i$1()}),R&&jsx(Co,{rect:R}),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:()=>i$1(),"aria-label":o.cancelButton,children:o.cancelButton})]}),fe&&Z&&jsxs("div",{ref:vt,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:T,"aria-label":o.rePickButton,children:o.rePickButton}),jsx("button",{type:"button",className:"bf-btn",onClick:()=>i$1(),disabled:T,"aria-label":o.closeButton,children:o.closeButton})]})]}),jsxs("div",{className:"bf-panelBody",children:[jsx("textarea",{className:"bf-textarea",placeholder:o.textareaPlaceholder,value:f,onChange:d=>S(d.target.value),onKeyDown:Tt,disabled:T,"aria-label":o.panelTitle}),de.length>0&&jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:de.map(d=>jsx("button",{type:"button",className:`bf-pill${D===d?" bf-pill-active":""}`,onClick:()=>le(D===d?void 0:d),disabled:T,children:o[Mo[d]]},d))}),jsxs("div",{className:"bf-row",role:"group","aria-label":o.screenshotElement,children:[jsxs("label",{children:[jsx("input",{type:"checkbox",checked:b$1,onChange:d=>B(d.target.checked),disabled:T}),o.screenshotElement]}),jsxs("label",{children:[jsx("input",{type:"checkbox",checked:v,onChange:d=>O(d.target.checked),disabled:T}),o.screenshotFullPage]})]}),bt&&e.phase==="review"&&!e.voiceTranscribing&&jsx("button",{type:"button",className:`bf-voice-btn${e.voiceRecording?" bf-voice-btn-active":""}`,onClick:St,disabled:T,"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(gt)," \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]}),me&&!e.voiceRecording&&!e.voiceTranscribing&&jsx("div",{className:"bf-error",role:"alert",children:me}),ft&&e.phase==="review"&&!e.video&&jsxs("button",{type:"button",className:"bf-record-btn",onClick:()=>a.startRecording(),disabled:T,"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:()=>a.removeVideo(),"aria-label":o.removeVideoButton,children:"\xD7"}),jsxs("div",{className:"bf-video-meta",children:[o.videoPreviewLabel," (",X(e.video.durationMs),", ",zo(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"&&ge&&jsx("div",{className:"bf-error",role:"alert",children:ge}),jsxs("div",{className:"bf-actions",children:[jsx("button",{type:"button",className:"bf-btn",onClick:()=>i$1(),disabled:T,"aria-label":o.cancelButton,children:o.cancelButton}),jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:ee,disabled:T||f.trim().length===0,"aria-label":o.sendButton,children:o.sendButton})]})]}),s&&jsx("div",{className:"bf-watermark",children: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(ut)]}),jsx("button",{type:"button",className:"bf-recording-bar-stop",onClick:()=>a.stopRecording(),"aria-label":o.stopRecordButton,children:o.stopRecordButton})]}),e.phase==="success"&&jsx("div",{className:"bf-toast",role:"status","aria-live":"polite",children:o.toastText}),J>0&&!mt&&jsxs("div",{className:"bf-security-banner",role:"alert",children:[jsx("button",{type:"button",className:"bf-security-banner-dismiss",onClick:()=>ht(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 Ao=forwardRef(function(e,a){let r$1={...e.config??{},blocfeed_id:e.blocfeed_id},[i,p]=useState(null),n=No(r$1.ui?.showOn),l=Fo(r$1.ui?.theme?.mode),o=!!r$1.diagnostics;useEffect(()=>{if(o)return r(r$1.diagnostics),()=>s()},[o]);let s$1=!!r$1.security;useEffect(()=>{s$1&&v(r$1.security);},[s$1]);let h=useRef(e.config?.metadata?.enrich);h.current=e.config?.metadata?.enrich;let z=useMemo(()=>{if(e.config)return {...e.config,metadata:{...e.config.metadata,enrich:async f=>{let S=h.current,b=S?await S(f):{},B=t(),v=w$1(),O=j();return {...b,...B.consoleLogs.length>0?{_consoleLogs:B.consoleLogs}:{},...B.networkErrors.length>0?{_networkErrors:B.networkErrors}:{},...v.findings.length>0?{_securityFindings:v.findings}:{},...O.length>0?{_clickEvents:O}:{}}}}}},[]);return useEffect(()=>{Fe();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$1.ui?.zIndex;typeof S=="number"&&f.style.setProperty("--bf-z",String(S));let b=r$1.ui?.theme;return 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)),document.body.appendChild(f),p(f),()=>{f.remove(),p(null);}},[r$1.ui?.zIndex,r$1.ui?.theme?.accentColor,r$1.ui?.theme?.panelBackground,r$1.ui?.theme?.panelForeground,r$1.ui?.theme?.fontFamily,l]),useEffect(()=>{i&&i.setAttribute("data-bf-theme",l);},[i,l]),!n||!i?null:createPortal(jsx(re,{blocfeed_id:r$1.blocfeed_id,...z?{config:z}:{},children:jsx(Lo,{config:r$1,handleRef:a})}),i)});
|
|
846
|
-
export{
|
|
884
|
+
`;function Re(){if(!a()||document.getElementById(Fe))return;let t=document.createElement("style");t.id=Fe,t.textContent=Mt,document.head.appendChild(t);}var Me={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?{...Me,...t}:Me}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 w(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 Le({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 We({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){return a?jsxs("button",{className:w(t),type:"button",onClick:e,"aria-label":r,children:[f?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]}),i>0&&jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]}):null}function m(){let[t,e]=useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return useEffect(()=>{let a=window.matchMedia("(prefers-reduced-motion: reduce)"),r=i=>e(i.matches);return a.addEventListener("change",r),()=>a.removeEventListener("change",r)},[]),t}var Ht={duration:.18,ease:"easeOut"},Ot={duration:0};function He({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=useState(false),o=m(),c=o?Ot:Ht;return jsx(AnimatePresence,{mode:"wait",children:a&&jsx(motion.button,{className:w(t),type:"button",onClick:e,onMouseEnter:()=>d(true),onMouseLeave:()=>d(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:f?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")}),i>0&&jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"dot")})}var Kt={duration:.18,ease:"easeOut"},De={duration:0};function $e({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=useState(false),o=m(),c=o?De:Kt;return jsx(AnimatePresence,{mode:"wait",children:a&&jsxs(motion.div,{className:w(t),initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{y:8,opacity:0},transition:c,onMouseEnter:()=>d(true),onMouseLeave:()=>d(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?De:{y:{duration:3,repeat:1/0,ease:"easeInOut"}},whileHover:{scale:1.1,borderColor:"var(--bf-accent)"},whileTap:{scale:.9},children:[f?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(Le,{size:16}),i>0&&jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${i} queued`,children:i})]})]},"bubble")})}var Yt={duration:.2,ease:"easeOut"},Gt={duration:0};function Ue(t){return t==="bottom-left"||t==="top-left"}function jt(t){return `bf-trigger-edge ${Ue(t)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function Xe({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=useState(false),o=Ue(t),c=m(),h=c?Gt:Yt;return jsx(AnimatePresence,{mode:"wait",children:a&&jsx(motion.button,{className:jt(t),type:"button",onClick:e,onMouseEnter:()=>d(true),onMouseLeave:()=>d(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:h,whileTap:{scale:.97},style:{top:"50%",translateY:"-50%"},children:f?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:h,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:h,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)"}}),i>0&&jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"edge-tab")})}var Jt={duration:.18,ease:"easeOut"},Zt={duration:0};function Ge({delay:t,hovered:e,reduced:a}){return a?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:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=useState(false),o=m(),c=o?Zt:Jt;return jsx(AnimatePresence,{mode:"wait",children:a&&jsx(motion.button,{className:w(t),type:"button",onClick:e,onMouseEnter:()=>d(true),onMouseLeave:()=>d(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:f?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(Ge,{delay:0,hovered:n,reduced:o}),jsx(Ge,{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")}),i>0&&jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"pulse-ring")})}var ro={duration:.18,ease:"easeOut"},io={duration:0};function ao(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 Ze({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=useState(false),o=m(),c=o?io:ro;return jsx(AnimatePresence,{mode:"wait",children:a&&jsxs(motion.button,{className:ao(t),type:"button",onClick:e,onMouseEnter:()=>d(true),onMouseLeave:()=>d(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:[f?jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})}):jsxs(Fragment,{children:[jsx("span",{children:r}),i>0&&jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${i} queued`,children:i})]}),!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 co={duration:.18,ease:"easeOut"},lo={duration:0};function tt({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=useState(false),o=m(),c=o?lo:co;return jsx(AnimatePresence,{mode:"wait",children:a&&jsx(motion.button,{className:w(t),type:"button",onClick:e,onMouseEnter:()=>d(true),onMouseLeave:()=>d(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:f?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")}),i>0&&jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"icon-pop")})}var bo={duration:.18,ease:"easeOut"},go={duration:0};function it({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=useState(false),o=m(),c=o?go:bo;return jsx(AnimatePresence,{mode:"wait",children:a&&jsx(motion.button,{className:w(t),type:"button",onClick:e,onMouseEnter:()=>d(true),onMouseLeave:()=>d(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:f?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")}),i>0&&jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"beacon")})}var yo={duration:.18,ease:"easeOut"},wo={duration:0};function ct({position:t,onClick:e,isVisible:a,label:r,queueCount:i,showSuccess:f}){let[n,d]=useState(false),[o,c]=useState(0),h=m(),z=h?wo:yo,p=useRef(null);useEffect(()=>{if(p.current&&(clearInterval(p.current),p.current=null),!a||n||h){c(n||h?r.length:0);return}let b=8,B=r.length*2+b*2,v=0;return p.current=setInterval(()=>{v=(v+1)%B,v<=r.length?c(v):v<=r.length+b?c(r.length):v<=r.length*2+b?c(r.length*2+b-v):c(0);},100),()=>{p.current&&(clearInterval(p.current),p.current=null);}},[a,n,h,r]);let S=r.slice(0,o);return jsx(AnimatePresence,{mode:"wait",children:a&&jsx(motion.button,{className:w(t),type:"button",onClick:e,onMouseEnter:()=>d(true),onMouseLeave:()=>d(false),"aria-label":r,initial:{opacity:0,y:h?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:h?0:5},transition:z,whileTap:{scale:.95},style:{minWidth:"44px"},children:f?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"})]}),i>0&&jsx("span",{className:"bf-badge","aria-label":`${i} queued`,children:i})]})},"typewriter")})}function lt(t){switch(t){case "dot":return He;case "bubble":return $e;case "edge-tab":return Xe;case "pulse-ring":return Qe;case "minimal":return Ze;case "icon-pop":return tt;case "beacon":return it;case "typewriter":return ct;default:return We}}function dt(t,e,a){return Math.max(e,Math.min(a,t))}function Co(t,e,a="bottom-right"){let i=window.innerWidth,f=window.innerHeight,n;n=dt(t.x,12,Math.max(12,i-e-12));let d=t.y+t.height+12,o=Math.max(12,t.y-240);return {top:d+240<=f?d:o,left:n}}function Po(t){let{rect:e}=t,a={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:a,"aria-hidden":"true"})}function Bo(t){let e=useRef(null);return useEffect(()=>{if(!t||!e.current)return;e.current.querySelector(".bf-textarea")?.focus();let r=i=>{if(i.key!=="Tab"||!e.current)return;let f=e.current.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(f.length===0)return;let n=f[0],d=f[f.length-1];i.shiftKey&&document.activeElement===n?(i.preventDefault(),d.focus()):!i.shiftKey&&document.activeElement===d&&(i.preventDefault(),n.focus());};return document.addEventListener("keydown",r,{capture:true}),()=>document.removeEventListener("keydown",r,{capture:true})},[t]),e}function No(t,e){return t?typeof t=="function"?t(e):t.some(a=>a.endsWith("*")?e.startsWith(a.slice(0,-1)):e===a):true}function Fo(t){let[e,a]=useState(()=>typeof window<"u"?window.location.pathname:"/");return useEffect(()=>{if(typeof window>"u")return;let r=()=>a(window.location.pathname);window.addEventListener("popstate",r);let i=history.pushState,f=history.replaceState;return history.pushState=function(...n){i.apply(this,n),setTimeout(r,0);},history.replaceState=function(...n){f.apply(this,n),setTimeout(r,0);},()=>{window.removeEventListener("popstate",r),history.pushState=i,history.replaceState=f;}},[]),No(t,e)}function Ro(t){let[e,a]=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"){a(t==="light"?"light":"dark");return}let r=window.matchMedia("(prefers-color-scheme: dark)"),i=f=>a(f.matches?"dark":"light");return a(r.matches?"dark":"light"),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[t]),e}var Mo=["bug","feature","ux","general"],zo={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function X(t){let e=Math.floor(t/1e3),a=Math.floor(e/60),r=e%60;return `${a}:${String(r).padStart(2,"0")}`}function Lo(t){return t<1024*1024?`${Math.round(t/1024)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Ao(t){let{state:e,controller:a,start:r,stop:i$1,clearSelection:f,submit:n$1}=ae(),d=t.config.ui?.position,o=ze(t.config.ui?.strings),c=t.config.ui?.branding!==false,[h,z]=useState(null),[p,S]=useState(""),[b$1,B]=useState(t.config.capture?.element??true),[v,O]=useState(t.config.capture?.fullPage??false),[pt,le]=useState(null),[D,de]=useState(void 0),fe=t.config.ui?.categories??Mo,ut=t.config.recording?.enabled===true&&l(),bt=t.config.recording?.maxDurationMs??3e4,pe=a.getConfig().voice,gt=pe?.enabled===true&&n(),mt=pe?.maxDurationMs??6e4,[ht,xt]=useState(false),[J,vt]=useState(0);useEffect(()=>{let s=window.setTimeout(()=>{let y$1=y();vt(y$1.findings.length);},500);return ()=>window.clearTimeout(s)},[]),useImperativeHandle(t.handleRef,()=>({open:r,close:i$1,submit:s=>n$1(s),startRecording:()=>a.startRecording(),stopRecording:()=>a.stopRecording(),get isOpen(){return e.phase!=="idle"}}),[r,i$1,n$1,a,e.phase]);let ue=e.phase==="review"||e.phase==="capturing"||e.phase==="submitting"||e.phase==="error"||e.phase==="success",yt=Bo(ue),[wt,kt]=useState(0);useEffect(()=>{e.phase==="idle"&&kt(i());},[e.phase]);let[Tt,be]=useState(false),ge=useRef(e.phase);useEffect(()=>{if(ge.current==="success"&&e.phase==="idle"){be(true);let s=window.setTimeout(()=>be(false),1500);return ()=>window.clearTimeout(s)}ge.current=e.phase;},[e.phase]),useEffect(()=>{let s=t.config.ui?.shortcut;if(!s)return;let y=s.toLowerCase().split("+").map(P=>P.trim()),C=y[y.length-1]||"",L=new Set(y.slice(0,-1)),xe=P=>{let Pt=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(L.has("mod")){if(Pt?!P.metaKey:!P.ctrlKey)return}else if(L.has("ctrl")&&!P.ctrlKey||(L.has("meta")||L.has("cmd"))&&!P.metaKey)return;L.has("shift")&&!P.shiftKey||(L.has("alt")||L.has("option"))&&!P.altKey||P.key.toLowerCase()===C&&(P.preventDefault(),e.phase==="idle"?r():i$1());};return document.addEventListener("keydown",xe),()=>document.removeEventListener("keydown",xe)},[t.config.ui?.shortcut,e.phase,r,i$1]),useEffect(()=>a.subscribeHover(z),[a]),useEffect(()=>{let s=a.__unsafeGetSelectedElement();if(!s||e.phase==="idle"||e.phase==="picking"){le(null);return}let y=()=>{le(b(s.getBoundingClientRect()));};y();let C=()=>y();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);}},[a,e.phase,e.selection?.selector]),useEffect(()=>{e.phase==="review"&&(S(""),B(t.config.capture?.element??true),O(t.config.capture?.fullPage??false),de(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(()=>i$1(),1200);return ()=>window.clearTimeout(s)},[e.phase,i$1]);let T=e.phase==="capturing"||e.phase==="submitting",R=e.phase==="picking"?h?.rect??null:pt??e.selection?.rect??null,Z=useMemo(()=>R?Co(R,360,d):null,[R?.x,R?.y,R?.width,R?.height,d]),me=e.lastError?.message,ee=useCallback(()=>{let s={capture:{element:b$1,fullPage:v}};D&&(s.category=D),n$1(p,s);},[n$1,p,b$1,v,D]),St=useCallback(s=>{(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&p.trim().length>0&&!T&&(s.preventDefault(),ee());},[ee,p,T]),[he,V]=useState(null),Et=useCallback(async()=>{if(e.voiceRecording){a.stopVoice();return}V(null);let s=await a.startVoice();if(s?.text)S(y=>y?y+" "+s.text:s.text);else if(s?.warning)V(o.voiceEmptyText);else if(!s){let y=a.getState().lastError;if(y){let C=y.message?.toLowerCase()??"";C.includes("denied")||C.includes("permission")||C.includes("not allowed")?V(o.voiceDeniedText):V(o.voiceErrorText);}}},[e.voiceRecording,a,o]),Ct=lt(t.config.ui?.triggerStyle);return jsxs(Fragment,{children:[jsx(Ct,{position:d,onClick:()=>r(),isVisible:e.phase==="idle",label:t.config.ui?.triggerLabel??o.triggerLabel,queueCount:wt,showSuccess:Tt}),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:()=>i$1()}),R&&jsx(Po,{rect:R}),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:()=>i$1(),"aria-label":o.cancelButton,children:o.cancelButton})]}),ue&&Z&&jsxs("div",{ref:yt,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:()=>f(),disabled:T,"aria-label":o.rePickButton,children:o.rePickButton}),jsx("button",{type:"button",className:"bf-btn",onClick:()=>i$1(),disabled:T,"aria-label":o.closeButton,children:o.closeButton})]})]}),jsxs("div",{className:"bf-panelBody",children:[jsx("textarea",{className:"bf-textarea",placeholder:o.textareaPlaceholder,value:p,onChange:s=>S(s.target.value),onKeyDown:St,disabled:T,"aria-label":o.panelTitle}),fe.length>0&&jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:fe.map(s=>jsx("button",{type:"button",className:`bf-pill${D===s?" bf-pill-active":""}`,onClick:()=>de(D===s?void 0:s),disabled:T,children:o[zo[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=>B(s.target.checked),disabled:T}),o.screenshotElement]}),jsxs("label",{children:[jsx("input",{type:"checkbox",checked:v,onChange:s=>O(s.target.checked),disabled:T}),o.screenshotFullPage]})]}),gt&&e.phase==="review"&&!e.voiceTranscribing&&jsx("button",{type:"button",className:`bf-voice-btn${e.voiceRecording?" bf-voice-btn-active":""}`,onClick:Et,disabled:T,"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(mt)," \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]}),he&&!e.voiceRecording&&!e.voiceTranscribing&&jsx("div",{className:"bf-error",role:"alert",children:he}),ut&&e.phase==="review"&&!e.video&&jsxs("button",{type:"button",className:"bf-record-btn",onClick:()=>a.startRecording(),disabled:T,"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:()=>a.removeVideo(),"aria-label":o.removeVideoButton,children:"\xD7"}),jsxs("div",{className:"bf-video-meta",children:[o.videoPreviewLabel," (",X(e.video.durationMs),", ",Lo(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"&&me&&jsx("div",{className:"bf-error",role:"alert",children:me}),jsxs("div",{className:"bf-actions",children:[jsx("button",{type:"button",className:"bf-btn",onClick:()=>i$1(),disabled:T,"aria-label":o.cancelButton,children:o.cancelButton}),jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:ee,disabled:T||p.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-${d}`,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(bt)]}),jsx("button",{type:"button",className:"bf-recording-bar-stop",onClick:()=>a.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&&!ht&&jsxs("div",{className:"bf-security-banner",role:"alert",children:[jsx("button",{type:"button",className:"bf-security-banner-dismiss",onClick:()=>xt(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 Io=forwardRef(function(e,a){let r={...e.config??{},blocfeed_id:e.blocfeed_id},[i,f]=useState(null),n=Fo(r.ui?.showOn),d=Ro(r.ui?.theme?.mode),o=!!r.diagnostics;useEffect(()=>{if(o)return t(r.diagnostics),()=>u()},[o]);let c=!!r.security;useEffect(()=>{c&&x(r.security);},[c]);let h=useRef(e.config?.metadata?.enrich);h.current=e.config?.metadata?.enrich;let z=useMemo(()=>{if(e.config)return {...e.config,metadata:{...e.config.metadata,enrich:async p=>{let S=h.current,b=S?await S(p):{},B=v(),v$1=y(),O=j();return {...b,...B.consoleLogs.length>0?{_consoleLogs:B.consoleLogs}:{},...B.networkErrors.length>0?{_networkErrors:B.networkErrors}:{},...v$1.findings.length>0?{_securityFindings:v$1.findings}:{},...O.length>0?{_clickEvents:O}:{}}}}}},[]);return useEffect(()=>{Re();let p=document.createElement("div");p.setAttribute("data-blocfeed-ui-root","true"),p.setAttribute("data-blocfeed-ui","true"),p.setAttribute("data-bf-theme",d);let S=r.ui?.zIndex;typeof S=="number"&&p.style.setProperty("--bf-z",String(S));let b=r.ui?.theme;return b&&(b.accentColor&&p.style.setProperty("--bf-accent",b.accentColor),b.panelBackground&&p.style.setProperty("--bf-panel-bg",b.panelBackground),b.panelForeground&&p.style.setProperty("--bf-panel-fg",b.panelForeground),b.fontFamily&&p.style.setProperty("--bf-font",b.fontFamily)),document.body.appendChild(p),f(p),()=>{p.remove(),f(null);}},[r.ui?.zIndex,r.ui?.theme?.accentColor,r.ui?.theme?.panelBackground,r.ui?.theme?.panelForeground,r.ui?.theme?.fontFamily,d]),useEffect(()=>{i&&i.setAttribute("data-bf-theme",d);},[i,d]),!n||!i?null:createPortal(jsx(ie,{blocfeed_id:r.blocfeed_id,...z?{config:z}:{},children:jsx(Ao,{config:r,handleRef:a})}),i)});
|
|
885
|
+
export{ie as BlocFeedProvider,Io as BlocFeedWidget,ae as useBlocFeed};
|
package/package.json
CHANGED
package/dist/chunk-A6OH75KK.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function y(){return typeof window<"u"&&typeof document<"u"}function Ae(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 ae(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function it(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function st(e){return e.replace(/\s+/g," ").trim()}function ce(e,t=140){let n=e.textContent;if(!n)return;let o=st(n);if(o)return o.length<=t?o:`${o.slice(0,t-1)}\u2026`}function at(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var Ce=["data-testid","data-test-id","data-test","data-qa","data-cy"],Re="data-blocfeed-component";function le(e){let t=e.closest(`[${Re}]`);if(!t)return;let o=t.getAttribute(Re)?.trim();return o||void 0}function ct(e){for(let t of Ce){let n=e.closest(`[${t}]`);if(!n)continue;let r=n.getAttribute(t)?.trim();if(r)return r}}function xe(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 U(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 $(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!U(t.name))return t.name}}function C(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 C(r)}}}function ue(e){let t=xe(e);if(!t)return;let n=$(t._debugInfo);if(n)return n;let o=t._debugOwner!==void 0;if(o){let c=t._debugOwner;for(let u=0;c&&u<50;u+=1){let b=$(c._debugInfo);if(b)return b;let p=C(c.type)??C(c.elementType);if(p&&!U(p))return p;c=c._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let c=t._owner;for(let u=0;c&&u<50;u+=1){let b=$(c._debugInfo);if(b)return b;let p=C(c.type)??C(c.elementType);if(p&&!U(p))return p;c=c._owner;}}let i=t,s=o?80:25;for(let c=0;i&&c<s;c+=1){let u=$(i._debugInfo);if(u)return u;let b=C(i.type)??C(i.elementType);if(b&&!U(b))return b;i=i.return;}let a=e.parentElement;for(let c=0;a&&c<15;c+=1){let u=xe(a);if(u){let b=$(u._debugInfo);if(b)return b;let p=C(u.type)??C(u.elementType);if(p&&!U(p))return p;if(u._debugOwner){let l=C(u._debugOwner.type)??C(u._debugOwner.elementType);if(l&&!U(l))return l}if(u._owner&&u._owner!==u._debugOwner){let l=C(u._owner.type)??C(u._owner.elementType);if(l&&!U(l))return l}}a=a.parentElement;}}function lt(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${Ae(n)}`;for(let o of Ce){let r=e.getAttribute(o);if(r)return `${t}[${o}="${Ae(r)}"]`}return `${t}:nth-of-type(${at(e)})`}function ut(e,t=10){let n=[],o=e;for(;o&&n.length<t;){let r=lt(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}function Pe(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function de(e,t){if(!e||Pe(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(Pe(n,t.ignoreSelectors))return null;if(t.isSelectable?.(n)??dt(n))return n;n=n.parentElement;}return null}function dt(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function Fe(e){let t=e.getBoundingClientRect(),n={selector:ut(e),tagName:e.tagName.toLowerCase(),rect:ae(t),pageRect:it(t)},o=e.getAttribute("id");o&&(n.id=o);let r=e.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=ce(e);i&&(n.textSnippet=i);let s=le(e)??ue(e);s&&(n.componentName=s);let a=ct(e);return a&&(n.testId=a),n}var fe=null;async function Me(){return fe||(fe=import('html-to-image')),fe}async function ft(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 Be(e,t){let{width:n,height:o}=await ft(e);return {dataUrl:e,mime:t,width:n,height:o}}function H(e){if(e?.aborted)throw new Error("Aborted")}function De(){return {async captureElement(e,t){if(!y())throw new Error("captureElement can only run in the browser");H(t.signal);let n=await Me();H(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 H(t.signal),await Be(o,t.mime)},async captureFullPage(e){if(!y())throw new Error("captureFullPage can only run in the browser");H(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)),s=Math.max(1,Math.round(o*r)),a=await Me();H(e.signal);let c=e.mime==="image/jpeg"?await a.toJpeg(t,{width:i,height:s,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await a.toPng(t,{width:i,height:s,pixelRatio:e.pixelRatio});return H(e.signal),await Be(c,e.mime)}}}function mt(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function h(e,t,n){let o={kind:e,message:mt(t)};return n&&(o.detail=n),o}var pt=12e3,gt=2048,ht=.92;function Le(){return Date.now()}function wt(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 Ie(e,t,n){let o=new Promise((i,s)=>{let a=setTimeout(()=>s(new Error("Timeout")),t);typeof a.unref=="function"&&a.unref();}),r=[e,o];return n&&r.push(wt(n)),await Promise.race(r)}function bt(e){if(!y())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function yt(e){return !!(e?.element||e?.fullPage)}function Ne(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 Oe(e){let{selectionElement:t,capture:n,signal:o}=e;if(!y()||!yt(n))return;let r=Le(),i=[],s=n?.timeoutMs??pt,a=n?.maxDimension??gt,c=n?.mime??"image/png",u=n?.quality??ht,b=n?.adapter??De(),p={},l=bt(n);if(n?.element&&t)try{let g=t.getBoundingClientRect(),d=Math.min(1,a/Math.max(g.width,g.height)),k=Math.min(l,l*d),_=await Ie(Promise.resolve(b.captureElement(t,{...Ne({mime:c,quality:u,pixelRatio:k,maxDimension:a,includeQuality:c==="image/jpeg",...o?{signal:o}:{}})})),s,o);p.element=_;}catch(g){if(o?.aborted)throw g;i.push(h("capture_failed",g,{target:"element"}));}if(n?.fullPage)try{let g=await Ie(Promise.resolve(b.captureFullPage(Ne({mime:c,quality:u,pixelRatio:l,maxDimension:a,includeQuality:c==="image/jpeg",...o?{signal:o}:{}}))),s,o);p.fullPage=g;}catch(g){if(o?.aborted)throw g;i.push(h("capture_failed",g,{target:"fullPage"}));}let w=Le(),f={startedAt:r,finishedAt:w,durationMs:Math.max(0,w-r)};return i.length>0&&(f.errors=i),{...p,diagnostics:f}}function Et(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function vt(){return y()?{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:Et()}:{}}function St(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 Ue(e){let{config:t,context:n,user:o}=e;if(t?.enabled===false)return {};let r={...vt(),...St(o)},i=t?.enrich;if(!i)return r;try{let s=await i(n);return {...r,...s}}catch(s){let a=h("unknown",s);return {...r,blocfeedMetadataError:a.message}}}var me="blocfeed-queue",kt=50;function pe(){if(!y())return [];try{let e=localStorage.getItem(me);if(!e)return [];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return []}}function ge(e){if(y())try{e.length===0?localStorage.removeItem(me):localStorage.setItem(me,JSON.stringify(e));}catch{}}function _t(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 he(e){let t=pe(),n=_t(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>kt;)t.shift();ge(t);}function Ve(){let e=pe();return e.length===0?[]:(ge([]),e.map(t=>t.payload))}function En(){ge([]);}function vn(){return pe().length}var Tt=200,X=[],He=0,ee=false;function qe(e){let t=e.target;if(!(t instanceof Element)||t.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-He,path:window.location.pathname,tagName:t.tagName.toLowerCase()},o=ce(t,100);o&&(n.textSnippet=o);let r=le(t)??ue(t);r&&(n.componentName=r),X.length<Tt&&X.push(n);}function ze(){ee||!y()||(ee=true,X=[],He=Date.now(),document.addEventListener("click",qe,{capture:true,passive:true}));}function je(){ee&&(ee=false,document.removeEventListener("click",qe,{capture:true}));}function At(){return [...X]}function Rt(){X=[];}var xt=3e4,Pt=25e5,$e="video/webm",Ct=250,Ft=1e3,Mt=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function Xe(){if(typeof MediaRecorder>"u")return null;for(let e of Mt)if(MediaRecorder.isTypeSupported(e))return e;return null}function Bt(){return !y()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:Xe()!==null}async function we(e){let{config:t,signal:n}=e;if(!y()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw h("recording_failed",new Error("Screen recording is not supported in this browser"));let o=Xe();if(!o)throw h("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw h("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(d){let k=d instanceof DOMException&&d.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw h("recording_failed",new Error(k))}if(n?.aborted)throw r.getTracks().forEach(d=>d.stop()),h("aborted",new Error("Recording aborted after permission"));let i=t?.maxDurationMs??xt,s=t?.videoBitsPerSecond??Pt,a=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:s}),c=[],u=[],b=0,p=null,l=null,w=false,f=()=>{je(),p!==null&&(clearInterval(p),p=null),l!==null&&(clearTimeout(l),l=null),r.getTracks().forEach(d=>d.stop());},g=new Promise((d,k)=>{a.ondataavailable=P=>{P.data.size>0&&c.push(P.data);},a.onstop=()=>{if(w)return;w=true,f();let P=Date.now()-b,v=new Blob(c,{type:$e}),D=URL.createObjectURL(v);d({mime:$e,blobUrl:D,blob:v,durationMs:P,sizeBytes:v.size});},a.onerror=()=>{w||(w=true,f(),k(h("recording_failed",new Error("MediaRecorder error"))));};let _=r.getVideoTracks()[0];if(_&&_.addEventListener("ended",()=>{a.state!=="inactive"&&a.stop();}),n){let P=()=>{w||(w=true,a.state!=="inactive"&&a.stop(),f(),k(h("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",P,{once:true});}});return a.start(Ft),ze(),b=Date.now(),p=setInterval(()=>{let d=Date.now()-b;for(let k of u)k(d);},Ct),l=setTimeout(()=>{!w&&a.state!=="inactive"&&a.stop();},i),{result:g,stop(){!w&&a.state!=="inactive"&&a.stop();},onTick(d){u.push(d);},abort(){w||(w=true,a.state!=="inactive"&&a.stop(),f());}}}var Dt=6e4,Ze="audio/webm",Lt=250,It=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function We(){if(typeof MediaRecorder>"u")return null;for(let e of It)if(MediaRecorder.isTypeSupported(e))return e;return null}function Nt(){return !y()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:We()!==null}async function be(e){let{config:t,signal:n}=e;if(!y()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw h("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=We();if(!o)throw h("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw h("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(g){let d=g instanceof DOMException&&g.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw h("recording_failed",new Error(d))}if(n?.aborted)throw r.getTracks().forEach(g=>g.stop()),h("aborted",new Error("Voice recording aborted after permission"));let i=t?.maxDurationMs??Dt,s=new MediaRecorder(r,{mimeType:o}),a=[],c=[],u=0,b=null,p=null,l=false,w=()=>{b!==null&&(clearInterval(b),b=null),p!==null&&(clearTimeout(p),p=null),r.getTracks().forEach(g=>g.stop());},f=new Promise((g,d)=>{if(s.ondataavailable=k=>{k.data.size>0&&a.push(k.data);},s.onstop=()=>{if(l)return;l=true,w();let k=Date.now()-u,_=new Blob(a,{type:Ze});g({blob:_,mime:Ze,durationMs:k});},s.onerror=()=>{l||(l=true,w(),d(h("recording_failed",new Error("MediaRecorder error"))));},n){let k=()=>{l||(l=true,s.state!=="inactive"&&s.stop(),w(),d(h("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",k,{once:true});}});return s.start(1e3),u=Date.now(),b=setInterval(()=>{let g=Date.now()-u;for(let d of c)d(g);},Lt),p=setTimeout(()=>{!l&&s.state!=="inactive"&&s.stop();},i),{result:f,stop(){!l&&s.state!=="inactive"&&s.stop();},onTick(g){c.push(g);},abort(){l||(l=true,s.state!=="inactive"&&s.stop(),w());}}}var Ot=12e3,Ut=2,Vt=500,Ht=2e3,ye="https://blocfeed.com/api/feedback",qt="https://blocfeed.com/api/feedback/voice",Ke=0;function Qe(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 zt(e){return e>=500&&e<=599}function jt(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),s=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)s[a]=i.charCodeAt(a);return new Blob([s],{type:r})}function $t(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 Ye(e,t,n){let o=jt(t);await fetch(e,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function Xt(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(`${ye}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function Zt(e){await fetch(`${ye}/${e.feedbackId}/video`,{method:"POST",body:e.blob,headers:{"content-type":e.blob.type},...e.signal?{signal:e.signal}:{}});}async function Ge(e){let{signal:t,transport:n}=e;if(Date.now()-Ke<Ht)return {ok:false,error:h("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??Ot,i=n?.maxAttempts??Ut,s=n?.backoffMs??Vt,a=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),c=!!e.payload.video?.blob,u=a||c,{lean:b,extracted:p,extractedVideo:l}=u?$t(e.payload):{lean:e.payload,extracted:{},extractedVideo:{}},w={...p,...e.screenshotDataUrls};for(let f=1;f<=i;f+=1){let g=new AbortController,d=setTimeout(()=>g.abort(),r),k=()=>g.abort();t&&t.addEventListener("abort",k,{once:true});try{let _=await fetch(ye,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(b),signal:g.signal});if(_.ok){Ke=Date.now();let v;try{v=await _.json();}catch{}if((w.element||w.fullPage)&&v){let F=v.upload_urls;if(F){let m=[];w.element&&F.element&&m.push(Ye(F.element,w.element,t)),w.fullPage&&F.fullPage&&m.push(Ye(F.fullPage,w.fullPage,t));try{await Promise.all(m);}catch{}}else if(v.feedback_id)try{await Xt({feedbackId:v.feedback_id,extracted:w,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}if(l.blob&&v){let F=v.upload_urls;if(F?.video)try{await fetch(F.video,{method:"PUT",body:l.blob,headers:{"content-type":l.blob.type},...t?{signal:t}:{}});}catch{}else if(v.feedback_id)try{await Zt({feedbackId:v.feedback_id,blob:l.blob,...t?{signal:t}:{}});}catch{}}let q={ok:!0,status:_.status};return v&&(q.apiResponse=v),q}if(f<i&&zt(_.status)){let v=.85+Math.random()*.3,D=Math.round(s*2**(f-1)*v);await Qe(D,t);continue}let P=`HTTP ${_.status}`;try{let v=await _.json();v?.error&&(P=v.error);}catch{}return {ok:!1,status:_.status,error:h("api_failed",new Error(P))}}catch(_){if(g.signal.aborted||t?.aborted)return {ok:false,error:h("aborted",_)};if(f<i){let P=.85+Math.random()*.3,v=Math.round(s*2**(f-1)*P);await Qe(v,t);continue}return {ok:false,error:h("api_failed",_)}}finally{clearTimeout(d),t&&t.removeEventListener("abort",k);}}return {ok:false,error:h("api_failed",new Error("Failed"))}}async function Je(e){let{blob:t,mime:n,blocfeedId:o,signal:r}=e,i=await fetch(qt,{method:"POST",headers:{"Content-Type":n,"X-Blocfeed-Id":o},body:t,...r?{signal:r}:{}});if(!i.ok){let a=await i.json().catch(()=>({error:"Unknown error"}));throw h("api_failed",new Error(a?.error??`Voice API returned ${i.status}`))}let s=await i.json();return {text:s.text??"",warning:s.warning}}function Ee(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 te(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function ne(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function et(e,t){if(!y())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,s=null,a=(f,g=false)=>{if(!f){i=null,s=null,t.onHover(null);return}let d=ae(f.getBoundingClientRect()),k=`${Math.round(d.x)}:${Math.round(d.y)}:${Math.round(d.width)}:${Math.round(d.height)}`;!g&&f===i&&k===s||(i=f,s=k,t.onHover({element:f,rect:d}));},c=Ee(f=>{if(te(f.target))return;let g=document.elementFromPoint(f.clientX,f.clientY),d=de(g,r);a(d);}),u=Ee(()=>{i&&a(i,true);}),b=f=>{te(f.target)||(ne(f),f.pointerType==="mouse"&&f.preventDefault());},p=f=>{te(f.target)||(ne(f),f.pointerType==="mouse"&&f.preventDefault());},l=f=>{if(te(f.target))return;ne(f),f.preventDefault();let g=document.elementFromPoint(f.clientX,f.clientY),d=de(g,r);d&&t.onSelect({element:d,descriptor:Fe(d)});},w=f=>{f.key==="Escape"&&(ne(f),f.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",c,{capture:true,passive:true}),window.addEventListener("pointerdown",b,{capture:true}),window.addEventListener("pointerup",p,{capture:true}),window.addEventListener("click",l,{capture:true}),window.addEventListener("keydown",w,{capture:true}),window.addEventListener("scroll",u,{capture:true,passive:true}),window.addEventListener("resize",u,{passive:true}),{stop(){window.removeEventListener("pointermove",c,{capture:true}),window.removeEventListener("pointerdown",b,{capture:true}),window.removeEventListener("pointerup",p,{capture:true}),window.removeEventListener("click",l,{capture:true}),window.removeEventListener("keydown",w,{capture:true}),window.removeEventListener("scroll",u,{capture:true}),window.removeEventListener("resize",u),c.cancel(),u.cancel(),t.onHover(null);}}}async function ve(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 Ge(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:h("api_failed",r)},o.ok=false;}return {payload:e.payload,result:o}}var Wt=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function Kt(e){let t=[...Wt,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function tt(){return {phase:"idle"}}function Qt(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 no(e){let t=e,n=tt(),o=new Set,r=new Set,i=null,s=null,a=null,c=null,u=0,b=null,p=null,l=null,w=null,f=()=>{for(let m of o)m(n);},g=m=>{for(let E of r)E(m);},d=m=>{n=m,f();},k=()=>{u+=1,c?.abort(),c=null;},_=()=>{i?.stop(),i=null,g(null),a!==null&&y()&&(document.documentElement.style.cursor=a,a=null);},P=()=>{p&&(p.abort(),p=null),l&&(URL.revokeObjectURL(l.blobUrl),l=null);},v=()=>{w&&(w.abort(),w=null);},D=()=>{k(),_(),P(),v(),s=null,d(tt());},q=()=>{if(!y())return;_(),s=null;let m=Kt(t.picker);a=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",d({phase:"picking"}),i=et(m,{onHover:g,onSelect:({element:E,descriptor:x})=>{s=E,_(),d({phase:"review",selection:x});},onCancel:()=>{D();}});},F=()=>{let m=Ve();if(m.length!==0)for(let E of m)ve({payload:E,...t.transport?{transport:t.transport}:{}}).catch(()=>{he(E);});};if(y()){setTimeout(F,1e3);let m=()=>F();window.addEventListener("online",m),b=()=>window.removeEventListener("online",m);}return {getState:()=>n,getConfig:()=>t,subscribe(m){return o.add(m),()=>o.delete(m)},subscribeHover(m){return r.add(m),()=>r.delete(m)},start(){n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording"||n.phase!=="picking"&&q();},stop(){D();},clearSelection(){n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording"||q();},setConfig(m){t=m;},async submit(m,E){if(!y()){let T=h("configuration",new Error("BlocFeed submit can only run in the browser"));return d({phase:"error",lastError:T}),{ok:false}}let x=t.blocfeed_id?.trim?.()??"";if(!x){let M={phase:"error",lastError:h("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return n.selection&&(M.selection=n.selection),d(M),{ok:false}}if(n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording")return {ok:false};let R=u+1;u=R,c?.abort(),c=new AbortController;let A=c.signal,S=n.selection,B=E?.capture?{...t.capture,...E.capture}:t.capture,L=!!(B?.element||B?.fullPage),z={phase:L?"capturing":"submitting"};S&&(z.selection=S),d(z);try{let T=L?await Oe({selectionElement:s,capture:B,signal:A}):void 0;if(A.aborted||u!==R)return {ok:!1};let M={phase:"submitting"};S&&(M.selection=S),T&&(M.capture=T),d(M);let I={};S&&(I.selection=S),T&&(I.capture=T);let j=await Ue({config:t.metadata,context:I,...t.user?{user:t.user}:{}}),O={version:1,createdAt:new Date().toISOString(),blocfeed_id:x,message:m,metadata:j};E?.category&&(O.category=E.category),t.user&&(O.user=t.user),S&&(O.selection=S),T&&(O.screenshots=T),l&&(O.video=l);let{result:N}=await ve({payload:O,signal:A,...t.transport?{transport:t.transport}:{}});if(A.aborted||u!==R)return N;if(N.ok){l&&(URL.revokeObjectURL(l.blobUrl),l=null);let se={phase:"success",lastSubmit:N};return S&&(se.selection=S),T&&(se.capture=T),d(se),N}Qt(N)&&he(O);let rt=N.api?.error??h("unknown",new Error("Submission failed")),ie={phase:"error",lastSubmit:N,lastError:rt};return S&&(ie.selection=S),T&&(ie.capture=T),d(ie),N}catch(T){if(A.aborted||u!==R)return {ok:false};let I={phase:"error",lastError:A.aborted?h("aborted",T):h("unknown",T)};return S&&(I.selection=S),d(I),{ok:false}}finally{u===R&&(c=null);}},async startRecording(){if(n.phase!=="review"||!t.recording?.enabled)return;let m=n.selection,E={phase:"recording",recordingElapsedMs:0};m&&(E.selection=m),d(E);try{let x={config:t.recording};c&&(x.signal=c.signal);let R=await we(x);p=R,R.onTick(B=>{if(n.phase==="recording"){let L={phase:"recording",recordingElapsedMs:B};m&&(L.selection=m),d(L);}});let A=await R.result;p=null,l=A;let S={phase:"review",video:A};m&&(S.selection=m),d(S);}catch(x){p=null;let A={phase:"review",lastError:x?.kind?x:h("recording_failed",x)};m&&(A.selection=m),d(A);}},stopRecording(){n.phase!=="recording"||!p||p.stop();},removeVideo(){l&&(URL.revokeObjectURL(l.blobUrl),l=null);let m=n.selection,E={phase:"review"};m&&(E.selection=m),d(E);},async startVoice(){if(n.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",n.phase,'(expected "review")');return}let m=t.voice;if(!m?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}v();let E=n.selection,x={phase:"review",voiceRecording:true,voiceElapsedMs:0};E&&(x.selection=E),l&&(x.video=l),d(x);try{let R={config:m};c&&(R.signal=c.signal);let A=await be(R);w=A,A.onTick(I=>{let j={phase:"review",voiceRecording:!0,voiceElapsedMs:I};E&&(j.selection=E),l&&(j.video=l),d(j);});let S=await A.result;w=null;let B={phase:"review",voiceRecording:!1,voiceTranscribing:!0};E&&(B.selection=E),l&&(B.video=l),d(B);let L={blob:S.blob,mime:S.mime,blocfeedId:t.blocfeed_id};c&&(L.signal=c.signal);let{text:Te,warning:z}=await Je(L),T={phase:"review",voiceRecording:!1,voiceTranscribing:!1};E&&(T.selection=E),l&&(T.video=l),d(T);let M={text:Te};return z&&(M.warning=z),M}catch(R){v();let A=R?.kind?R:h("recording_failed",R);console.warn("[BlocFeed] Voice error:",A.message);let S={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:A};E&&(S.selection=E),l&&(S.video=l),d(S);return}},stopVoice(){w&&w.stop();},__unsafeGetSelectedElement(){return s},destroy(){D(),o.clear(),r.clear(),b?.(),b=null;}}}var Z=[],W=[],nt=20,ot=15,oe=[],K={},Q=null,Y=null,G=null,re=false,Yt=["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 Gt(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Jt(e,t){let n=t.map(Gt).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)),Z.push(r);Z.length>nt;)Z.shift();}function Se(e){let t=e.url.toLowerCase();for(let n of oe)if(t.includes(n))return;for(W.push(e);W.length>ot;)W.shift();}function io(e={}){if(re||!y())return;re=true,nt=e.consoleLimit??20,ot=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?oe=t.map(n=>n.toLowerCase()):oe=[...Yt],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let o of n)K[o]=console[o],console[o]=(...r)=>{Jt(o,r),K[o]?.apply(console,r);};}if(e.network!==false&&typeof window.fetch=="function"){Q=window.fetch;let n=Q;window.fetch=async function(r,i){let s=typeof r=="string"?r:r instanceof URL?r.toString():r.url,a=(i?.method??"GET").toUpperCase(),c=Date.now();try{let u=await n.call(window,r,i);return u.ok||Se({url:s.slice(0,500),method:a,status:u.status,statusText:u.statusText,timestamp:c,durationMs:Date.now()-c}),u}catch(u){throw Se({url:s.slice(0,500),method:a,status:0,statusText:u instanceof Error?u.message:"Network error",timestamp:c,durationMs:Date.now()-c}),u}};}if(e.network!==false&&typeof XMLHttpRequest<"u"){Y=XMLHttpRequest.prototype.open,G=XMLHttpRequest.prototype.send;let n=Y,o=G;XMLHttpRequest.prototype.open=function(r,i,...s){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...s])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",s=this.__bf_url||"",a=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let c={url:s.slice(0,500),method:i,status:this.status,timestamp:a,durationMs:Date.now()-a};this.statusText&&(c.statusText=this.statusText),Se(c);}}),o.apply(this,r)};}}function so(){if(re){for(let[e,t]of Object.entries(K))console[e]=t;for(let e of Object.keys(K))delete K[e];Q&&(window.fetch=Q,Q=null),Y&&(XMLHttpRequest.prototype.open=Y,Y=null),G&&(XMLHttpRequest.prototype.send=G,G=null),oe=[],re=false;}}function ao(){return {consoleLogs:[...Z],networkErrors:[...W]}}function co(){Z=[],W=[];}var en=[{name:"supabase_service_role_key",pattern:/SUPABASE_SERVICE_ROLE_KEY["'=:\s]+[A-Za-z0-9_.=-]{30,}/},{name:"supabase_db_password",pattern:/SUPABASE_DB_PASSWORD["'=:\s]+[^\s"']{6,}/},{name:"postgres_password",pattern:/POSTGRES_PASSWORD["'=:\s]+[^\s"']{6,}/},{name:"database_url_with_creds",pattern:/(?:postgres|postgresql|mysql|mongodb|redis|amqp):\/\/[^:]+:[^@\s"']+@/},{name:"aws_access_key",pattern:/AKIA[0-9A-Z]{16}/},{name:"aws_secret_key",pattern:/AWS_SECRET_ACCESS_KEY["'=:\s]+[A-Za-z0-9/+=]{30,}/},{name:"aws_session_token",pattern:/AWS_SESSION_TOKEN["'=:\s]+[A-Za-z0-9/+=]{30,}/},{name:"stripe_secret_key",pattern:/sk_live_[a-zA-Z0-9]{10,}/},{name:"stripe_secret_key_test",pattern:/sk_test_[a-zA-Z0-9]{10,}/},{name:"stripe_restricted_key",pattern:/rk_(?:live|test)_[a-zA-Z0-9]{10,}/},{name:"github_pat",pattern:/ghp_[A-Za-z0-9_]{36,}/},{name:"github_oauth",pattern:/gho_[A-Za-z0-9_]{36,}/},{name:"github_user_token",pattern:/ghu_[A-Za-z0-9_]{36,}/},{name:"github_server_token",pattern:/ghs_[A-Za-z0-9_]{36,}/},{name:"github_fine_grained",pattern:/github_pat_[A-Za-z0-9_]{22,}/},{name:"openai_api_key",pattern:/sk-[a-zA-Z0-9]{20,}(?![a-zA-Z0-9_])/},{name:"anthropic_api_key",pattern:/sk-ant-[a-zA-Z0-9\-_]{20,}/},{name:"private_key",pattern:/-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----/},{name:"sendgrid_api_key",pattern:/SG\.[a-zA-Z0-9_-]{22,}\.[a-zA-Z0-9_-]{22,}/},{name:"twilio_auth_token",pattern:/TWILIO_AUTH_TOKEN["'=:\s]+[a-f0-9]{32}/},{name:"generic_secret_key",pattern:/[A-Z_]{2,}_SECRET_KEY["'=:\s]+[^\s"']{8,}/},{name:"generic_secret",pattern:/[A-Z_]{2,}_SECRET["'=:\s]+[^\s"']{8,}/},{name:"generic_password",pattern:/[A-Z_]{2,}_PASSWORD["'=:\s]+[^\s"']{6,}/},{name:"generic_private_key_var",pattern:/[A-Z_]{2,}_PRIVATE_KEY["'=:\s]+[^\s"']{8,}/}],V=[],_e=0,ke=false;function tn(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function nn(e,t,n,o){if(V.some(s=>s.rule===e&&s.source===t))return;let i={rule:e,source:t,hint:tn(n),timestamp:Date.now()};o&&(i.location=o),V.push(i);}function J(e,t,n,o){for(let{name:r,pattern:i}of n){let s=i.exec(e);s&&nn(r,t,s[0],o);}}function on(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);J(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);J(n,"hydration",e,"__NUXT__");}}catch{}}function rn(e){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&J(r,"scripts",e,`inline-script[${o}]`);});}catch{}}function sn(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let o=n.getAttribute("content"),r=n.getAttribute("name")||n.getAttribute("property")||"";o&&o.length>10&&J(o,"meta",e,r?`meta[${r}]`:void 0);});}catch{}}function an(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&&J(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function fo(e={}){if(ke||!y()||(ke=true,e.secretScan===false))return;let t=[...en,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{_e=Date.now(),n.includes("hydration")&&on(t),n.includes("scripts")&&rn(t),n.includes("meta")&&sn(t),n.includes("dom")&&an(t);let o=e.notify??"both";V.length>0&&(o==="console"||o==="both")&&console.warn(`[BlocFeed Security] Found ${V.length} potential secret(s) exposed in client code:`,V.map(r=>`${r.rule} (${r.source}${r.location?`: ${r.location}`:""})`));},100);}function mo(){return {findings:[...V],scannedAt:_e}}function po(){V=[],_e=0,ke=false;}
|
|
2
|
-
export{y as a,ae as b,De as c,Oe as d,Ue as e,he as f,Ve as g,En as h,vn as i,At as j,Rt as k,Bt as l,we as m,Nt as n,be as o,Je as p,no as q,io as r,so as s,ao as t,co as u,fo as v,mo as w,po as x};
|
package/dist/chunk-FM72GX3J.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';function y(){return typeof window<"u"&&typeof document<"u"}function Ae(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 ae(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function it(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function st(e){return e.replace(/\s+/g," ").trim()}function ce(e,t=140){let n=e.textContent;if(!n)return;let o=st(n);if(o)return o.length<=t?o:`${o.slice(0,t-1)}\u2026`}function at(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var Ce=["data-testid","data-test-id","data-test","data-qa","data-cy"],Re="data-blocfeed-component";function le(e){let t=e.closest(`[${Re}]`);if(!t)return;let o=t.getAttribute(Re)?.trim();return o||void 0}function ct(e){for(let t of Ce){let n=e.closest(`[${t}]`);if(!n)continue;let r=n.getAttribute(t)?.trim();if(r)return r}}function xe(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 U(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 $(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!U(t.name))return t.name}}function C(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 C(r)}}}function ue(e){let t=xe(e);if(!t)return;let n=$(t._debugInfo);if(n)return n;let o=t._debugOwner!==void 0;if(o){let c=t._debugOwner;for(let u=0;c&&u<50;u+=1){let b=$(c._debugInfo);if(b)return b;let p=C(c.type)??C(c.elementType);if(p&&!U(p))return p;c=c._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let c=t._owner;for(let u=0;c&&u<50;u+=1){let b=$(c._debugInfo);if(b)return b;let p=C(c.type)??C(c.elementType);if(p&&!U(p))return p;c=c._owner;}}let i=t,s=o?80:25;for(let c=0;i&&c<s;c+=1){let u=$(i._debugInfo);if(u)return u;let b=C(i.type)??C(i.elementType);if(b&&!U(b))return b;i=i.return;}let a=e.parentElement;for(let c=0;a&&c<15;c+=1){let u=xe(a);if(u){let b=$(u._debugInfo);if(b)return b;let p=C(u.type)??C(u.elementType);if(p&&!U(p))return p;if(u._debugOwner){let l=C(u._debugOwner.type)??C(u._debugOwner.elementType);if(l&&!U(l))return l}if(u._owner&&u._owner!==u._debugOwner){let l=C(u._owner.type)??C(u._owner.elementType);if(l&&!U(l))return l}}a=a.parentElement;}}function lt(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${Ae(n)}`;for(let o of Ce){let r=e.getAttribute(o);if(r)return `${t}[${o}="${Ae(r)}"]`}return `${t}:nth-of-type(${at(e)})`}function ut(e,t=10){let n=[],o=e;for(;o&&n.length<t;){let r=lt(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}function Pe(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function de(e,t){if(!e||Pe(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(Pe(n,t.ignoreSelectors))return null;if(t.isSelectable?.(n)??dt(n))return n;n=n.parentElement;}return null}function dt(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function Fe(e){let t=e.getBoundingClientRect(),n={selector:ut(e),tagName:e.tagName.toLowerCase(),rect:ae(t),pageRect:it(t)},o=e.getAttribute("id");o&&(n.id=o);let r=e.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=ce(e);i&&(n.textSnippet=i);let s=le(e)??ue(e);s&&(n.componentName=s);let a=ct(e);return a&&(n.testId=a),n}var fe=null;async function Me(){return fe||(fe=import('html-to-image')),fe}async function ft(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 Be(e,t){let{width:n,height:o}=await ft(e);return {dataUrl:e,mime:t,width:n,height:o}}function H(e){if(e?.aborted)throw new Error("Aborted")}function De(){return {async captureElement(e,t){if(!y())throw new Error("captureElement can only run in the browser");H(t.signal);let n=await Me();H(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 H(t.signal),await Be(o,t.mime)},async captureFullPage(e){if(!y())throw new Error("captureFullPage can only run in the browser");H(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)),s=Math.max(1,Math.round(o*r)),a=await Me();H(e.signal);let c=e.mime==="image/jpeg"?await a.toJpeg(t,{width:i,height:s,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await a.toPng(t,{width:i,height:s,pixelRatio:e.pixelRatio});return H(e.signal),await Be(c,e.mime)}}}function mt(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function h(e,t,n){let o={kind:e,message:mt(t)};return n&&(o.detail=n),o}var pt=12e3,gt=2048,ht=.92;function Le(){return Date.now()}function wt(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 Ie(e,t,n){let o=new Promise((i,s)=>{let a=setTimeout(()=>s(new Error("Timeout")),t);typeof a.unref=="function"&&a.unref();}),r=[e,o];return n&&r.push(wt(n)),await Promise.race(r)}function bt(e){if(!y())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function yt(e){return !!(e?.element||e?.fullPage)}function Ne(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 Oe(e){let{selectionElement:t,capture:n,signal:o}=e;if(!y()||!yt(n))return;let r=Le(),i=[],s=n?.timeoutMs??pt,a=n?.maxDimension??gt,c=n?.mime??"image/png",u=n?.quality??ht,b=n?.adapter??De(),p={},l=bt(n);if(n?.element&&t)try{let g=t.getBoundingClientRect(),d=Math.min(1,a/Math.max(g.width,g.height)),k=Math.min(l,l*d),_=await Ie(Promise.resolve(b.captureElement(t,{...Ne({mime:c,quality:u,pixelRatio:k,maxDimension:a,includeQuality:c==="image/jpeg",...o?{signal:o}:{}})})),s,o);p.element=_;}catch(g){if(o?.aborted)throw g;i.push(h("capture_failed",g,{target:"element"}));}if(n?.fullPage)try{let g=await Ie(Promise.resolve(b.captureFullPage(Ne({mime:c,quality:u,pixelRatio:l,maxDimension:a,includeQuality:c==="image/jpeg",...o?{signal:o}:{}}))),s,o);p.fullPage=g;}catch(g){if(o?.aborted)throw g;i.push(h("capture_failed",g,{target:"fullPage"}));}let w=Le(),f={startedAt:r,finishedAt:w,durationMs:Math.max(0,w-r)};return i.length>0&&(f.errors=i),{...p,diagnostics:f}}function Et(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function vt(){return y()?{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:Et()}:{}}function St(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 Ue(e){let{config:t,context:n,user:o}=e;if(t?.enabled===false)return {};let r={...vt(),...St(o)},i=t?.enrich;if(!i)return r;try{let s=await i(n);return {...r,...s}}catch(s){let a=h("unknown",s);return {...r,blocfeedMetadataError:a.message}}}var me="blocfeed-queue",kt=50;function pe(){if(!y())return [];try{let e=localStorage.getItem(me);if(!e)return [];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return []}}function ge(e){if(y())try{e.length===0?localStorage.removeItem(me):localStorage.setItem(me,JSON.stringify(e));}catch{}}function _t(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 he(e){let t=pe(),n=_t(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>kt;)t.shift();ge(t);}function Ve(){let e=pe();return e.length===0?[]:(ge([]),e.map(t=>t.payload))}function En(){ge([]);}function vn(){return pe().length}var Tt=200,X=[],He=0,ee=false;function qe(e){let t=e.target;if(!(t instanceof Element)||t.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-He,path:window.location.pathname,tagName:t.tagName.toLowerCase()},o=ce(t,100);o&&(n.textSnippet=o);let r=le(t)??ue(t);r&&(n.componentName=r),X.length<Tt&&X.push(n);}function ze(){ee||!y()||(ee=true,X=[],He=Date.now(),document.addEventListener("click",qe,{capture:true,passive:true}));}function je(){ee&&(ee=false,document.removeEventListener("click",qe,{capture:true}));}function At(){return [...X]}function Rt(){X=[];}var xt=3e4,Pt=25e5,$e="video/webm",Ct=250,Ft=1e3,Mt=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function Xe(){if(typeof MediaRecorder>"u")return null;for(let e of Mt)if(MediaRecorder.isTypeSupported(e))return e;return null}function Bt(){return !y()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:Xe()!==null}async function we(e){let{config:t,signal:n}=e;if(!y()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw h("recording_failed",new Error("Screen recording is not supported in this browser"));let o=Xe();if(!o)throw h("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw h("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(d){let k=d instanceof DOMException&&d.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw h("recording_failed",new Error(k))}if(n?.aborted)throw r.getTracks().forEach(d=>d.stop()),h("aborted",new Error("Recording aborted after permission"));let i=t?.maxDurationMs??xt,s=t?.videoBitsPerSecond??Pt,a=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:s}),c=[],u=[],b=0,p=null,l=null,w=false,f=()=>{je(),p!==null&&(clearInterval(p),p=null),l!==null&&(clearTimeout(l),l=null),r.getTracks().forEach(d=>d.stop());},g=new Promise((d,k)=>{a.ondataavailable=P=>{P.data.size>0&&c.push(P.data);},a.onstop=()=>{if(w)return;w=true,f();let P=Date.now()-b,v=new Blob(c,{type:$e}),D=URL.createObjectURL(v);d({mime:$e,blobUrl:D,blob:v,durationMs:P,sizeBytes:v.size});},a.onerror=()=>{w||(w=true,f(),k(h("recording_failed",new Error("MediaRecorder error"))));};let _=r.getVideoTracks()[0];if(_&&_.addEventListener("ended",()=>{a.state!=="inactive"&&a.stop();}),n){let P=()=>{w||(w=true,a.state!=="inactive"&&a.stop(),f(),k(h("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",P,{once:true});}});return a.start(Ft),ze(),b=Date.now(),p=setInterval(()=>{let d=Date.now()-b;for(let k of u)k(d);},Ct),l=setTimeout(()=>{!w&&a.state!=="inactive"&&a.stop();},i),{result:g,stop(){!w&&a.state!=="inactive"&&a.stop();},onTick(d){u.push(d);},abort(){w||(w=true,a.state!=="inactive"&&a.stop(),f());}}}var Dt=6e4,Ze="audio/webm",Lt=250,It=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function We(){if(typeof MediaRecorder>"u")return null;for(let e of It)if(MediaRecorder.isTypeSupported(e))return e;return null}function Nt(){return !y()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:We()!==null}async function be(e){let{config:t,signal:n}=e;if(!y()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw h("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=We();if(!o)throw h("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw h("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(g){let d=g instanceof DOMException&&g.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw h("recording_failed",new Error(d))}if(n?.aborted)throw r.getTracks().forEach(g=>g.stop()),h("aborted",new Error("Voice recording aborted after permission"));let i=t?.maxDurationMs??Dt,s=new MediaRecorder(r,{mimeType:o}),a=[],c=[],u=0,b=null,p=null,l=false,w=()=>{b!==null&&(clearInterval(b),b=null),p!==null&&(clearTimeout(p),p=null),r.getTracks().forEach(g=>g.stop());},f=new Promise((g,d)=>{if(s.ondataavailable=k=>{k.data.size>0&&a.push(k.data);},s.onstop=()=>{if(l)return;l=true,w();let k=Date.now()-u,_=new Blob(a,{type:Ze});g({blob:_,mime:Ze,durationMs:k});},s.onerror=()=>{l||(l=true,w(),d(h("recording_failed",new Error("MediaRecorder error"))));},n){let k=()=>{l||(l=true,s.state!=="inactive"&&s.stop(),w(),d(h("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",k,{once:true});}});return s.start(1e3),u=Date.now(),b=setInterval(()=>{let g=Date.now()-u;for(let d of c)d(g);},Lt),p=setTimeout(()=>{!l&&s.state!=="inactive"&&s.stop();},i),{result:f,stop(){!l&&s.state!=="inactive"&&s.stop();},onTick(g){c.push(g);},abort(){l||(l=true,s.state!=="inactive"&&s.stop(),w());}}}var Ot=12e3,Ut=2,Vt=500,Ht=2e3,ye="https://blocfeed.com/api/feedback",qt="https://blocfeed.com/api/feedback/voice",Ke=0;function Qe(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 zt(e){return e>=500&&e<=599}function jt(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),s=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)s[a]=i.charCodeAt(a);return new Blob([s],{type:r})}function $t(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 Ye(e,t,n){let o=jt(t);await fetch(e,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function Xt(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(`${ye}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function Zt(e){await fetch(`${ye}/${e.feedbackId}/video`,{method:"POST",body:e.blob,headers:{"content-type":e.blob.type},...e.signal?{signal:e.signal}:{}});}async function Ge(e){let{signal:t,transport:n}=e;if(Date.now()-Ke<Ht)return {ok:false,error:h("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??Ot,i=n?.maxAttempts??Ut,s=n?.backoffMs??Vt,a=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),c=!!e.payload.video?.blob,u=a||c,{lean:b,extracted:p,extractedVideo:l}=u?$t(e.payload):{lean:e.payload,extracted:{},extractedVideo:{}},w={...p,...e.screenshotDataUrls};for(let f=1;f<=i;f+=1){let g=new AbortController,d=setTimeout(()=>g.abort(),r),k=()=>g.abort();t&&t.addEventListener("abort",k,{once:true});try{let _=await fetch(ye,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(b),signal:g.signal});if(_.ok){Ke=Date.now();let v;try{v=await _.json();}catch{}if((w.element||w.fullPage)&&v){let F=v.upload_urls;if(F){let m=[];w.element&&F.element&&m.push(Ye(F.element,w.element,t)),w.fullPage&&F.fullPage&&m.push(Ye(F.fullPage,w.fullPage,t));try{await Promise.all(m);}catch{}}else if(v.feedback_id)try{await Xt({feedbackId:v.feedback_id,extracted:w,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}if(l.blob&&v){let F=v.upload_urls;if(F?.video)try{await fetch(F.video,{method:"PUT",body:l.blob,headers:{"content-type":l.blob.type},...t?{signal:t}:{}});}catch{}else if(v.feedback_id)try{await Zt({feedbackId:v.feedback_id,blob:l.blob,...t?{signal:t}:{}});}catch{}}let q={ok:!0,status:_.status};return v&&(q.apiResponse=v),q}if(f<i&&zt(_.status)){let v=.85+Math.random()*.3,D=Math.round(s*2**(f-1)*v);await Qe(D,t);continue}let P=`HTTP ${_.status}`;try{let v=await _.json();v?.error&&(P=v.error);}catch{}return {ok:!1,status:_.status,error:h("api_failed",new Error(P))}}catch(_){if(g.signal.aborted||t?.aborted)return {ok:false,error:h("aborted",_)};if(f<i){let P=.85+Math.random()*.3,v=Math.round(s*2**(f-1)*P);await Qe(v,t);continue}return {ok:false,error:h("api_failed",_)}}finally{clearTimeout(d),t&&t.removeEventListener("abort",k);}}return {ok:false,error:h("api_failed",new Error("Failed"))}}async function Je(e){let{blob:t,mime:n,blocfeedId:o,signal:r}=e,i=await fetch(qt,{method:"POST",headers:{"Content-Type":n,"X-Blocfeed-Id":o},body:t,...r?{signal:r}:{}});if(!i.ok){let a=await i.json().catch(()=>({error:"Unknown error"}));throw h("api_failed",new Error(a?.error??`Voice API returned ${i.status}`))}let s=await i.json();return {text:s.text??"",warning:s.warning}}function Ee(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 te(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function ne(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function et(e,t){if(!y())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,s=null,a=(f,g=false)=>{if(!f){i=null,s=null,t.onHover(null);return}let d=ae(f.getBoundingClientRect()),k=`${Math.round(d.x)}:${Math.round(d.y)}:${Math.round(d.width)}:${Math.round(d.height)}`;!g&&f===i&&k===s||(i=f,s=k,t.onHover({element:f,rect:d}));},c=Ee(f=>{if(te(f.target))return;let g=document.elementFromPoint(f.clientX,f.clientY),d=de(g,r);a(d);}),u=Ee(()=>{i&&a(i,true);}),b=f=>{te(f.target)||(ne(f),f.pointerType==="mouse"&&f.preventDefault());},p=f=>{te(f.target)||(ne(f),f.pointerType==="mouse"&&f.preventDefault());},l=f=>{if(te(f.target))return;ne(f),f.preventDefault();let g=document.elementFromPoint(f.clientX,f.clientY),d=de(g,r);d&&t.onSelect({element:d,descriptor:Fe(d)});},w=f=>{f.key==="Escape"&&(ne(f),f.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",c,{capture:true,passive:true}),window.addEventListener("pointerdown",b,{capture:true}),window.addEventListener("pointerup",p,{capture:true}),window.addEventListener("click",l,{capture:true}),window.addEventListener("keydown",w,{capture:true}),window.addEventListener("scroll",u,{capture:true,passive:true}),window.addEventListener("resize",u,{passive:true}),{stop(){window.removeEventListener("pointermove",c,{capture:true}),window.removeEventListener("pointerdown",b,{capture:true}),window.removeEventListener("pointerup",p,{capture:true}),window.removeEventListener("click",l,{capture:true}),window.removeEventListener("keydown",w,{capture:true}),window.removeEventListener("scroll",u,{capture:true}),window.removeEventListener("resize",u),c.cancel(),u.cancel(),t.onHover(null);}}}async function ve(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 Ge(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:h("api_failed",r)},o.ok=false;}return {payload:e.payload,result:o}}var Wt=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function Kt(e){let t=[...Wt,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function tt(){return {phase:"idle"}}function Qt(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 no(e){let t=e,n=tt(),o=new Set,r=new Set,i=null,s=null,a=null,c=null,u=0,b=null,p=null,l=null,w=null,f=()=>{for(let m of o)m(n);},g=m=>{for(let E of r)E(m);},d=m=>{n=m,f();},k=()=>{u+=1,c?.abort(),c=null;},_=()=>{i?.stop(),i=null,g(null),a!==null&&y()&&(document.documentElement.style.cursor=a,a=null);},P=()=>{p&&(p.abort(),p=null),l&&(URL.revokeObjectURL(l.blobUrl),l=null);},v=()=>{w&&(w.abort(),w=null);},D=()=>{k(),_(),P(),v(),s=null,d(tt());},q=()=>{if(!y())return;_(),s=null;let m=Kt(t.picker);a=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",d({phase:"picking"}),i=et(m,{onHover:g,onSelect:({element:E,descriptor:x})=>{s=E,_(),d({phase:"review",selection:x});},onCancel:()=>{D();}});},F=()=>{let m=Ve();if(m.length!==0)for(let E of m)ve({payload:E,...t.transport?{transport:t.transport}:{}}).catch(()=>{he(E);});};if(y()){setTimeout(F,1e3);let m=()=>F();window.addEventListener("online",m),b=()=>window.removeEventListener("online",m);}return {getState:()=>n,getConfig:()=>t,subscribe(m){return o.add(m),()=>o.delete(m)},subscribeHover(m){return r.add(m),()=>r.delete(m)},start(){n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording"||n.phase!=="picking"&&q();},stop(){D();},clearSelection(){n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording"||q();},setConfig(m){t=m;},async submit(m,E){if(!y()){let T=h("configuration",new Error("BlocFeed submit can only run in the browser"));return d({phase:"error",lastError:T}),{ok:false}}let x=t.blocfeed_id?.trim?.()??"";if(!x){let M={phase:"error",lastError:h("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return n.selection&&(M.selection=n.selection),d(M),{ok:false}}if(n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording")return {ok:false};let R=u+1;u=R,c?.abort(),c=new AbortController;let A=c.signal,S=n.selection,B=E?.capture?{...t.capture,...E.capture}:t.capture,L=!!(B?.element||B?.fullPage),z={phase:L?"capturing":"submitting"};S&&(z.selection=S),d(z);try{let T=L?await Oe({selectionElement:s,capture:B,signal:A}):void 0;if(A.aborted||u!==R)return {ok:!1};let M={phase:"submitting"};S&&(M.selection=S),T&&(M.capture=T),d(M);let I={};S&&(I.selection=S),T&&(I.capture=T);let j=await Ue({config:t.metadata,context:I,...t.user?{user:t.user}:{}}),O={version:1,createdAt:new Date().toISOString(),blocfeed_id:x,message:m,metadata:j};E?.category&&(O.category=E.category),t.user&&(O.user=t.user),S&&(O.selection=S),T&&(O.screenshots=T),l&&(O.video=l);let{result:N}=await ve({payload:O,signal:A,...t.transport?{transport:t.transport}:{}});if(A.aborted||u!==R)return N;if(N.ok){l&&(URL.revokeObjectURL(l.blobUrl),l=null);let se={phase:"success",lastSubmit:N};return S&&(se.selection=S),T&&(se.capture=T),d(se),N}Qt(N)&&he(O);let rt=N.api?.error??h("unknown",new Error("Submission failed")),ie={phase:"error",lastSubmit:N,lastError:rt};return S&&(ie.selection=S),T&&(ie.capture=T),d(ie),N}catch(T){if(A.aborted||u!==R)return {ok:false};let I={phase:"error",lastError:A.aborted?h("aborted",T):h("unknown",T)};return S&&(I.selection=S),d(I),{ok:false}}finally{u===R&&(c=null);}},async startRecording(){if(n.phase!=="review"||!t.recording?.enabled)return;let m=n.selection,E={phase:"recording",recordingElapsedMs:0};m&&(E.selection=m),d(E);try{let x={config:t.recording};c&&(x.signal=c.signal);let R=await we(x);p=R,R.onTick(B=>{if(n.phase==="recording"){let L={phase:"recording",recordingElapsedMs:B};m&&(L.selection=m),d(L);}});let A=await R.result;p=null,l=A;let S={phase:"review",video:A};m&&(S.selection=m),d(S);}catch(x){p=null;let A={phase:"review",lastError:x?.kind?x:h("recording_failed",x)};m&&(A.selection=m),d(A);}},stopRecording(){n.phase!=="recording"||!p||p.stop();},removeVideo(){l&&(URL.revokeObjectURL(l.blobUrl),l=null);let m=n.selection,E={phase:"review"};m&&(E.selection=m),d(E);},async startVoice(){if(n.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",n.phase,'(expected "review")');return}let m=t.voice;if(!m?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}v();let E=n.selection,x={phase:"review",voiceRecording:true,voiceElapsedMs:0};E&&(x.selection=E),l&&(x.video=l),d(x);try{let R={config:m};c&&(R.signal=c.signal);let A=await be(R);w=A,A.onTick(I=>{let j={phase:"review",voiceRecording:!0,voiceElapsedMs:I};E&&(j.selection=E),l&&(j.video=l),d(j);});let S=await A.result;w=null;let B={phase:"review",voiceRecording:!1,voiceTranscribing:!0};E&&(B.selection=E),l&&(B.video=l),d(B);let L={blob:S.blob,mime:S.mime,blocfeedId:t.blocfeed_id};c&&(L.signal=c.signal);let{text:Te,warning:z}=await Je(L),T={phase:"review",voiceRecording:!1,voiceTranscribing:!1};E&&(T.selection=E),l&&(T.video=l),d(T);let M={text:Te};return z&&(M.warning=z),M}catch(R){v();let A=R?.kind?R:h("recording_failed",R);console.warn("[BlocFeed] Voice error:",A.message);let S={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:A};E&&(S.selection=E),l&&(S.video=l),d(S);return}},stopVoice(){w&&w.stop();},__unsafeGetSelectedElement(){return s},destroy(){D(),o.clear(),r.clear(),b?.(),b=null;}}}var Z=[],W=[],nt=20,ot=15,oe=[],K={},Q=null,Y=null,G=null,re=false,Yt=["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 Gt(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Jt(e,t){let n=t.map(Gt).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)),Z.push(r);Z.length>nt;)Z.shift();}function Se(e){let t=e.url.toLowerCase();for(let n of oe)if(t.includes(n))return;for(W.push(e);W.length>ot;)W.shift();}function io(e={}){if(re||!y())return;re=true,nt=e.consoleLimit??20,ot=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?oe=t.map(n=>n.toLowerCase()):oe=[...Yt],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let o of n)K[o]=console[o],console[o]=(...r)=>{Jt(o,r),K[o]?.apply(console,r);};}if(e.network!==false&&typeof window.fetch=="function"){Q=window.fetch;let n=Q;window.fetch=async function(r,i){let s=typeof r=="string"?r:r instanceof URL?r.toString():r.url,a=(i?.method??"GET").toUpperCase(),c=Date.now();try{let u=await n.call(window,r,i);return u.ok||Se({url:s.slice(0,500),method:a,status:u.status,statusText:u.statusText,timestamp:c,durationMs:Date.now()-c}),u}catch(u){throw Se({url:s.slice(0,500),method:a,status:0,statusText:u instanceof Error?u.message:"Network error",timestamp:c,durationMs:Date.now()-c}),u}};}if(e.network!==false&&typeof XMLHttpRequest<"u"){Y=XMLHttpRequest.prototype.open,G=XMLHttpRequest.prototype.send;let n=Y,o=G;XMLHttpRequest.prototype.open=function(r,i,...s){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...s])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",s=this.__bf_url||"",a=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let c={url:s.slice(0,500),method:i,status:this.status,timestamp:a,durationMs:Date.now()-a};this.statusText&&(c.statusText=this.statusText),Se(c);}}),o.apply(this,r)};}}function so(){if(re){for(let[e,t]of Object.entries(K))console[e]=t;for(let e of Object.keys(K))delete K[e];Q&&(window.fetch=Q,Q=null),Y&&(XMLHttpRequest.prototype.open=Y,Y=null),G&&(XMLHttpRequest.prototype.send=G,G=null),oe=[],re=false;}}function ao(){return {consoleLogs:[...Z],networkErrors:[...W]}}function co(){Z=[],W=[];}var en=[{name:"supabase_service_role_key",pattern:/SUPABASE_SERVICE_ROLE_KEY["'=:\s]+[A-Za-z0-9_.=-]{30,}/},{name:"supabase_db_password",pattern:/SUPABASE_DB_PASSWORD["'=:\s]+[^\s"']{6,}/},{name:"postgres_password",pattern:/POSTGRES_PASSWORD["'=:\s]+[^\s"']{6,}/},{name:"database_url_with_creds",pattern:/(?:postgres|postgresql|mysql|mongodb|redis|amqp):\/\/[^:]+:[^@\s"']+@/},{name:"aws_access_key",pattern:/AKIA[0-9A-Z]{16}/},{name:"aws_secret_key",pattern:/AWS_SECRET_ACCESS_KEY["'=:\s]+[A-Za-z0-9/+=]{30,}/},{name:"aws_session_token",pattern:/AWS_SESSION_TOKEN["'=:\s]+[A-Za-z0-9/+=]{30,}/},{name:"stripe_secret_key",pattern:/sk_live_[a-zA-Z0-9]{10,}/},{name:"stripe_secret_key_test",pattern:/sk_test_[a-zA-Z0-9]{10,}/},{name:"stripe_restricted_key",pattern:/rk_(?:live|test)_[a-zA-Z0-9]{10,}/},{name:"github_pat",pattern:/ghp_[A-Za-z0-9_]{36,}/},{name:"github_oauth",pattern:/gho_[A-Za-z0-9_]{36,}/},{name:"github_user_token",pattern:/ghu_[A-Za-z0-9_]{36,}/},{name:"github_server_token",pattern:/ghs_[A-Za-z0-9_]{36,}/},{name:"github_fine_grained",pattern:/github_pat_[A-Za-z0-9_]{22,}/},{name:"openai_api_key",pattern:/sk-[a-zA-Z0-9]{20,}(?![a-zA-Z0-9_])/},{name:"anthropic_api_key",pattern:/sk-ant-[a-zA-Z0-9\-_]{20,}/},{name:"private_key",pattern:/-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----/},{name:"sendgrid_api_key",pattern:/SG\.[a-zA-Z0-9_-]{22,}\.[a-zA-Z0-9_-]{22,}/},{name:"twilio_auth_token",pattern:/TWILIO_AUTH_TOKEN["'=:\s]+[a-f0-9]{32}/},{name:"generic_secret_key",pattern:/[A-Z_]{2,}_SECRET_KEY["'=:\s]+[^\s"']{8,}/},{name:"generic_secret",pattern:/[A-Z_]{2,}_SECRET["'=:\s]+[^\s"']{8,}/},{name:"generic_password",pattern:/[A-Z_]{2,}_PASSWORD["'=:\s]+[^\s"']{6,}/},{name:"generic_private_key_var",pattern:/[A-Z_]{2,}_PRIVATE_KEY["'=:\s]+[^\s"']{8,}/}],V=[],_e=0,ke=false;function tn(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function nn(e,t,n,o){if(V.some(s=>s.rule===e&&s.source===t))return;let i={rule:e,source:t,hint:tn(n),timestamp:Date.now()};o&&(i.location=o),V.push(i);}function J(e,t,n,o){for(let{name:r,pattern:i}of n){let s=i.exec(e);s&&nn(r,t,s[0],o);}}function on(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);J(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);J(n,"hydration",e,"__NUXT__");}}catch{}}function rn(e){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&J(r,"scripts",e,`inline-script[${o}]`);});}catch{}}function sn(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let o=n.getAttribute("content"),r=n.getAttribute("name")||n.getAttribute("property")||"";o&&o.length>10&&J(o,"meta",e,r?`meta[${r}]`:void 0);});}catch{}}function an(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&&J(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function fo(e={}){if(ke||!y()||(ke=true,e.secretScan===false))return;let t=[...en,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{_e=Date.now(),n.includes("hydration")&&on(t),n.includes("scripts")&&rn(t),n.includes("meta")&&sn(t),n.includes("dom")&&an(t);let o=e.notify??"both";V.length>0&&(o==="console"||o==="both")&&console.warn(`[BlocFeed Security] Found ${V.length} potential secret(s) exposed in client code:`,V.map(r=>`${r.rule} (${r.source}${r.location?`: ${r.location}`:""})`));},100);}function mo(){return {findings:[...V],scannedAt:_e}}function po(){V=[],_e=0,ke=false;}
|
|
2
|
-
exports.a=y;exports.b=ae;exports.c=De;exports.d=Oe;exports.e=Ue;exports.f=he;exports.g=Ve;exports.h=En;exports.i=vn;exports.j=At;exports.k=Rt;exports.l=Bt;exports.m=we;exports.n=Nt;exports.o=be;exports.p=Je;exports.q=no;exports.r=io;exports.s=so;exports.t=ao;exports.u=co;exports.v=fo;exports.w=mo;exports.x=po;
|