blocfeed 0.11.1 → 0.11.2
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-A6OH75KK.js +2 -0
- package/dist/chunk-FM72GX3J.cjs +2 -0
- package/dist/{controller-B8sPt2d-.d.cts → controller-KZyWlj27.d.cts} +1 -1
- package/dist/{controller-B8sPt2d-.d.ts → controller-KZyWlj27.d.ts} +1 -1
- package/dist/engine.cjs +1 -1
- package/dist/engine.d.cts +3 -17
- package/dist/engine.d.ts +3 -17
- package/dist/engine.js +1 -1
- package/dist/main.cjs +2 -2
- package/dist/main.d.cts +2 -2
- package/dist/main.d.ts +2 -2
- package/dist/main.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-EHIT2JIT.cjs +0 -2
- package/dist/chunk-TY4R37ZM.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
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};
|
|
@@ -0,0 +1,2 @@
|
|
|
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;
|
|
@@ -404,7 +404,7 @@ type StateListener = (state: BlocFeedState) => void;
|
|
|
404
404
|
type HoverListener = (hover: HoverInfo) => void;
|
|
405
405
|
interface BlocFeedController {
|
|
406
406
|
getState: () => BlocFeedState;
|
|
407
|
-
/** Returns the current config
|
|
407
|
+
/** Returns the current config. */
|
|
408
408
|
getConfig: () => BlocFeedConfig;
|
|
409
409
|
subscribe: (listener: StateListener) => () => void;
|
|
410
410
|
subscribeHover: (listener: HoverListener) => () => void;
|
|
@@ -404,7 +404,7 @@ type StateListener = (state: BlocFeedState) => void;
|
|
|
404
404
|
type HoverListener = (hover: HoverInfo) => void;
|
|
405
405
|
interface BlocFeedController {
|
|
406
406
|
getState: () => BlocFeedState;
|
|
407
|
-
/** Returns the current config
|
|
407
|
+
/** Returns the current config. */
|
|
408
408
|
getConfig: () => BlocFeedConfig;
|
|
409
409
|
subscribe: (listener: StateListener) => () => void;
|
|
410
410
|
subscribeHover: (listener: HoverListener) => () => void;
|
package/dist/engine.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkFM72GX3J_cjs=require('./chunk-FM72GX3J.cjs');function s(o){if(o?.aborted)throw new Error("Aborted")}async function D(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 D(o);return {dataUrl:o,mime:t,width:e,height:r}}function v(o){return {async captureElement(t,e){if(!chunkFM72GX3J_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(!chunkFM72GX3J_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 H(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 chunkFM72GX3J_cjs.k}});Object.defineProperty(exports,"clearDiagnostics",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.u}});Object.defineProperty(exports,"clearQueue",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.h}});Object.defineProperty(exports,"clearSecurityFindings",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.x}});Object.defineProperty(exports,"collectMetadata",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.e}});Object.defineProperty(exports,"createBlocFeedController",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.q}});Object.defineProperty(exports,"createHtmlToImageAdapter",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.c}});Object.defineProperty(exports,"dequeueAll",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.g}});Object.defineProperty(exports,"drainClickEvents",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.j}});Object.defineProperty(exports,"drainDiagnostics",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.t}});Object.defineProperty(exports,"enqueue",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.f}});Object.defineProperty(exports,"getQueueSize",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.i}});Object.defineProperty(exports,"getSecurityFindings",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.w}});Object.defineProperty(exports,"installDiagnostics",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.r}});Object.defineProperty(exports,"isRecordingSupported",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.l}});Object.defineProperty(exports,"isVoiceSupported",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.n}});Object.defineProperty(exports,"runCapture",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.d}});Object.defineProperty(exports,"runSecretScan",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.v}});Object.defineProperty(exports,"startRecording",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.m}});Object.defineProperty(exports,"startVoiceRecording",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.o}});Object.defineProperty(exports,"transcribeAudio",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.p}});Object.defineProperty(exports,"uninstallDiagnostics",{enumerable:true,get:function(){return chunkFM72GX3J_cjs.s}});exports.createModernScreenshotAdapter=v;exports.dataUrlToBlob=H;
|
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-KZyWlj27.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-KZyWlj27.cjs';
|
|
3
3
|
|
|
4
4
|
declare function createHtmlToImageAdapter(): ScreenshotAdapter;
|
|
5
5
|
|
|
@@ -108,20 +108,6 @@ declare function transcribeAudio(params: {
|
|
|
108
108
|
text: string;
|
|
109
109
|
warning?: string;
|
|
110
110
|
}>;
|
|
111
|
-
interface ProjectConfig {
|
|
112
|
-
voice_feedback_enabled: boolean;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Fetch project configuration from the BlocFeed platform.
|
|
116
|
-
* Returns feature flags (e.g. voice_feedback_enabled) that the SDK
|
|
117
|
-
* uses to auto-configure itself based on dashboard settings.
|
|
118
|
-
*
|
|
119
|
-
* Fails silently (returns null) so the SDK can fall back to client config.
|
|
120
|
-
*/
|
|
121
|
-
declare function fetchProjectConfig(params: {
|
|
122
|
-
blocfeedId: string;
|
|
123
|
-
signal?: AbortSignal;
|
|
124
|
-
}): Promise<ProjectConfig | null>;
|
|
125
111
|
|
|
126
112
|
declare function collectMetadata(params: {
|
|
127
113
|
config: MetadataConfig | undefined;
|
|
@@ -217,4 +203,4 @@ declare function clearSecurityFindings(): void;
|
|
|
217
203
|
|
|
218
204
|
declare function dataUrlToBlob(dataUrl: string): Blob;
|
|
219
205
|
|
|
220
|
-
export { BlocFeedUser, CaptureResult, ClickEvent, FeedbackPayload, type ModernScreenshotModule,
|
|
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 };
|
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-KZyWlj27.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-KZyWlj27.js';
|
|
3
3
|
|
|
4
4
|
declare function createHtmlToImageAdapter(): ScreenshotAdapter;
|
|
5
5
|
|
|
@@ -108,20 +108,6 @@ declare function transcribeAudio(params: {
|
|
|
108
108
|
text: string;
|
|
109
109
|
warning?: string;
|
|
110
110
|
}>;
|
|
111
|
-
interface ProjectConfig {
|
|
112
|
-
voice_feedback_enabled: boolean;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Fetch project configuration from the BlocFeed platform.
|
|
116
|
-
* Returns feature flags (e.g. voice_feedback_enabled) that the SDK
|
|
117
|
-
* uses to auto-configure itself based on dashboard settings.
|
|
118
|
-
*
|
|
119
|
-
* Fails silently (returns null) so the SDK can fall back to client config.
|
|
120
|
-
*/
|
|
121
|
-
declare function fetchProjectConfig(params: {
|
|
122
|
-
blocfeedId: string;
|
|
123
|
-
signal?: AbortSignal;
|
|
124
|
-
}): Promise<ProjectConfig | null>;
|
|
125
111
|
|
|
126
112
|
declare function collectMetadata(params: {
|
|
127
113
|
config: MetadataConfig | undefined;
|
|
@@ -217,4 +203,4 @@ declare function clearSecurityFindings(): void;
|
|
|
217
203
|
|
|
218
204
|
declare function dataUrlToBlob(dataUrl: string): Blob;
|
|
219
205
|
|
|
220
|
-
export { BlocFeedUser, CaptureResult, ClickEvent, FeedbackPayload, type ModernScreenshotModule,
|
|
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 };
|
package/dist/engine.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-A6OH75KK.js';export{k as clearClickEvents,u as clearDiagnostics,h as clearQueue,x as clearSecurityFindings,e as collectMetadata,q as createBlocFeedController,c as createHtmlToImageAdapter,g as dequeueAll,j as drainClickEvents,t as drainDiagnostics,f as enqueue,i as getQueueSize,w as getSecurityFindings,r as installDiagnostics,l as isRecordingSupported,n as isVoiceSupported,d as runCapture,v as runSecretScan,m as startRecording,o as startVoiceRecording,p as transcribeAudio,s as uninstallDiagnostics}from'./chunk-A6OH75KK.js';function s(o){if(o?.aborted)throw new Error("Aborted")}async function D(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 D(o);return {dataUrl:o,mime:t,width:e,height:r}}function v(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 H(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{v as createModernScreenshotAdapter,H as dataUrlToBlob};
|
package/dist/main.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
'use strict';var
|
|
2
|
+
'use strict';var chunkFM72GX3J_cjs=require('./chunk-FM72GX3J.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),framerMotion=require('framer-motion');var Y=react.createContext(null);function re(t){let e=react.useMemo(()=>chunkFM72GX3J_cjs.q({...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 Ne="blocfeed-styles-v1",Rt=`
|
|
3
3
|
:where([data-blocfeed-ui-root]),
|
|
4
4
|
:where([data-blocfeed-ui-root]) * {
|
|
5
5
|
box-sizing: border-box;
|
|
@@ -842,5 +842,5 @@
|
|
|
842
842
|
animation: none;
|
|
843
843
|
}
|
|
844
844
|
}
|
|
845
|
-
`;function Fe(){if(!chunkEHIT2JIT_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),r();},history.replaceState=function(...n){p.apply(this,n),r();},()=>{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&&chunkEHIT2JIT_cjs.l(),ut=t.config.recording?.maxDurationMs??3e4,pe=a.getConfig().voice,bt=pe?.enabled===true&&chunkEHIT2JIT_cjs.n(),gt=pe?.maxDurationMs??6e4,[mt,ht]=react.useState(false),[J,xt]=react.useState(0);react.useEffect(()=>{let d=window.setTimeout(()=>{let y=chunkEHIT2JIT_cjs.x();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(chunkEHIT2JIT_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(chunkEHIT2JIT_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 chunkEHIT2JIT_cjs.s(r.diagnostics),()=>chunkEHIT2JIT_cjs.t()},[o]);let s=!!r.security;react.useEffect(()=>{s&&chunkEHIT2JIT_cjs.w(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=chunkEHIT2JIT_cjs.u(),v=chunkEHIT2JIT_cjs.x(),O=chunkEHIT2JIT_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)});
|
|
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),r();},history.replaceState=function(...n){p.apply(this,n),r();},()=>{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
846
|
exports.BlocFeedProvider=re;exports.BlocFeedWidget=Ao;exports.useBlocFeed=ie;
|
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-KZyWlj27.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-KZyWlj27.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-KZyWlj27.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-KZyWlj27.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,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {s,t,w as w$1,
|
|
2
|
+
import {r,s,v,t,w as w$1,j,a,q,l,n,i,b}from'./chunk-A6OH75KK.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 re(t){let e=useMemo(()=>q({...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 Ne="blocfeed-styles-v1",Rt=`
|
|
3
3
|
:where([data-blocfeed-ui-root]),
|
|
4
4
|
:where([data-blocfeed-ui-root]) * {
|
|
5
5
|
box-sizing: border-box;
|
|
@@ -842,5 +842,5 @@ import {s,t,w as w$1,u,x,j,a,r,l,n,i,b}from'./chunk-TY4R37ZM.js';import {createC
|
|
|
842
842
|
animation: none;
|
|
843
843
|
}
|
|
844
844
|
}
|
|
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),r();},history.replaceState=function(...n){p.apply(this,n),r();},()=>{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=x();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={...e.config??{},blocfeed_id:e.blocfeed_id},[i,p]=useState(null),n=No(r.ui?.showOn),l=Fo(r.ui?.theme?.mode),o=!!r.diagnostics;useEffect(()=>{if(o)return s(r.diagnostics),()=>t()},[o]);let s$1=!!r.security;useEffect(()=>{s$1&&w$1(r.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=u(),v=x(),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.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]),useEffect(()=>{i&&i.setAttribute("data-bf-theme",l);},[i,l]),!n||!i?null:createPortal(jsx(re,{blocfeed_id:r.blocfeed_id,...z?{config:z}:{},children:jsx(Lo,{config:r,handleRef:a})}),i)});
|
|
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),r();},history.replaceState=function(...n){p.apply(this,n),r();},()=>{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
846
|
export{re as BlocFeedProvider,Ao as BlocFeedWidget,ie as useBlocFeed};
|
package/package.json
CHANGED
package/dist/chunk-EHIT2JIT.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';function v(){return typeof window<"u"&&typeof document<"u"}function Re(t){let e=globalThis.CSS;return typeof e?.escape=="function"?e.escape(t):t.replace(/[^a-zA-Z0-9_-]/g,n=>{let o=n.codePointAt(0);return o===void 0?"":`\\${o.toString(16)} `})}function se(t){return {x:t.x,y:t.y,width:t.width,height:t.height}}function ct(t){return {x:t.x+window.scrollX,y:t.y+window.scrollY,width:t.width,height:t.height}}function lt(t){return t.replace(/\s+/g," ").trim()}function ce(t,e=140){let n=t.textContent;if(!n)return;let o=lt(n);if(o)return o.length<=e?o:`${o.slice(0,e-1)}\u2026`}function dt(t){let e=1;for(let n=t.previousElementSibling;n;n=n.previousElementSibling)n.tagName===t.tagName&&(e+=1);return e}var Fe=["data-testid","data-test-id","data-test","data-qa","data-cy"],xe="data-blocfeed-component";function le(t){let e=t.closest(`[${xe}]`);if(!e)return;let o=e.getAttribute(xe)?.trim();return o||void 0}function ut(t){for(let e of Fe){let n=t.closest(`[${e}]`);if(!n)continue;let r=n.getAttribute(e)?.trim();if(r)return r}}function Pe(t){try{let e=t,n=Object.getOwnPropertyNames(e);for(let o of n)if(o.startsWith("__reactFiber$")||o.startsWith("__reactInternalInstance$")){let r=e[o];if(r&&typeof r=="object")return r}}catch{}return null}function U(t){if(t.length<=1||t.length===2&&t[0]===t[0].toLowerCase()||t.startsWith("__")&&t.endsWith("__"))return true;let e=t[0];return e>="a"&&e<="z"}function $(t){if(t){for(let e of t)if(typeof e.name=="string"&&e.name&&!U(e.name))return e.name}}function P(t){if(t&&typeof t!="string"){if(typeof t=="function"){let e=t;return typeof e.displayName=="string"&&e.displayName?e.displayName:typeof e.name=="string"&&e.name?e.name:void 0}if(typeof t=="object"){let e=t,n=e.displayName;if(typeof n=="string"&&n)return n;let o=e.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=e.type;return P(r)}}}function de(t){let e=Pe(t);if(!e)return;let n=$(e._debugInfo);if(n)return n;let o=e._debugOwner!==void 0;if(o){let c=e._debugOwner;for(let d=0;c&&d<50;d+=1){let y=$(c._debugInfo);if(y)return y;let p=P(c.type)??P(c.elementType);if(p&&!U(p))return p;c=c._debugOwner;}}if(e._owner!==void 0&&e._owner!==e._debugOwner){let c=e._owner;for(let d=0;c&&d<50;d+=1){let y=$(c._debugInfo);if(y)return y;let p=P(c.type)??P(c.elementType);if(p&&!U(p))return p;c=c._owner;}}let i=e,a=o?80:25;for(let c=0;i&&c<a;c+=1){let d=$(i._debugInfo);if(d)return d;let y=P(i.type)??P(i.elementType);if(y&&!U(y))return y;i=i.return;}let s=t.parentElement;for(let c=0;s&&c<15;c+=1){let d=Pe(s);if(d){let y=$(d._debugInfo);if(y)return y;let p=P(d.type)??P(d.elementType);if(p&&!U(p))return p;if(d._debugOwner){let l=P(d._debugOwner.type)??P(d._debugOwner.elementType);if(l&&!U(l))return l}if(d._owner&&d._owner!==d._debugOwner){let l=P(d._owner.type)??P(d._owner.elementType);if(l&&!U(l))return l}}s=s.parentElement;}}function ft(t){let e=t.tagName.toLowerCase(),n=t.getAttribute("id");if(n)return `#${Re(n)}`;for(let o of Fe){let r=t.getAttribute(o);if(r)return `${e}[${o}="${Re(r)}"]`}return `${e}:nth-of-type(${dt(t)})`}function mt(t,e=10){let n=[],o=t;for(;o&&n.length<e;){let r=ft(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}function Ce(t,e){if(!e||e.length===0)return false;for(let n of e)if(t.closest(n))return true;return false}function ue(t,e){if(!t||Ce(t,e.ignoreSelectors))return null;let n=t;for(;n;){if(Ce(n,e.ignoreSelectors))return null;if(e.isSelectable?.(n)??pt(n))return n;n=n.parentElement;}return null}function pt(t){let e=t.tagName;return !(e==="HTML"||e==="BODY")}function Me(t){let e=t.getBoundingClientRect(),n={selector:mt(t),tagName:t.tagName.toLowerCase(),rect:se(e),pageRect:ct(e)},o=t.getAttribute("id");o&&(n.id=o);let r=t.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=ce(t);i&&(n.textSnippet=i);let a=le(t)??de(t);a&&(n.componentName=a);let s=ut(t);return s&&(n.testId=s),n}var fe=null;async function Ie(){return fe||(fe=import('html-to-image')),fe}async function gt(t){return await new Promise((e,n)=>{let o=new Image;o.onload=()=>e({width:o.naturalWidth,height:o.naturalHeight}),o.onerror=()=>n(new Error("Failed to load generated screenshot")),o.src=t;})}async function Be(t,e){let{width:n,height:o}=await gt(t);return {dataUrl:t,mime:e,width:n,height:o}}function q(t){if(t?.aborted)throw new Error("Aborted")}function Le(){return {async captureElement(t,e){if(!v())throw new Error("captureElement can only run in the browser");q(e.signal);let n=await Ie();q(e.signal);let o=e.mime==="image/jpeg"?await n.toJpeg(t,{quality:e.quality??.92,pixelRatio:e.pixelRatio}):await n.toPng(t,{pixelRatio:e.pixelRatio});return q(e.signal),await Be(o,e.mime)},async captureFullPage(t){if(!v())throw new Error("captureFullPage can only run in the browser");q(t.signal);let e=document.documentElement,n=Math.max(e.scrollWidth,e.clientWidth),o=Math.max(e.scrollHeight,e.clientHeight),r=Math.min(1,t.maxDimension/Math.max(n,o)),i=Math.max(1,Math.round(n*r)),a=Math.max(1,Math.round(o*r)),s=await Ie();q(t.signal);let c=t.mime==="image/jpeg"?await s.toJpeg(e,{width:i,height:a,quality:t.quality??.92,pixelRatio:t.pixelRatio}):await s.toPng(e,{width:i,height:a,pixelRatio:t.pixelRatio});return q(t.signal),await Be(c,t.mime)}}}function ht(t){if(t instanceof Error)return t.message;if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return "Unknown error"}}function b(t,e,n){let o={kind:t,message:ht(e)};return n&&(o.detail=n),o}var bt=12e3,wt=2048,yt=.92;function De(){return Date.now()}function Et(t){return new Promise((e,n)=>{let o=()=>n(new Error("Aborted"));if(t.aborted){o();return}t.addEventListener("abort",o,{once:true});})}async function Ne(t,e,n){let o=new Promise((i,a)=>{let s=setTimeout(()=>a(new Error("Timeout")),e);typeof s.unref=="function"&&s.unref();}),r=[t,o];return n&&r.push(Et(n)),await Promise.race(r)}function vt(t){if(!v())return 1;let e=window.devicePixelRatio||1,n=t?.pixelRatio??Math.min(e,2);return Math.max(.1,n)}function St(t){return !!(t?.element||t?.fullPage)}function Oe(t){let e={mime:t.mime,pixelRatio:t.pixelRatio,maxDimension:t.maxDimension};return t.includeQuality&&(e.quality=t.quality),t.signal&&(e.signal=t.signal),e}async function Ue(t){let{selectionElement:e,capture:n,signal:o}=t;if(!v()||!St(n))return;let r=De(),i=[],a=n?.timeoutMs??bt,s=n?.maxDimension??wt,c=n?.mime??"image/png",d=n?.quality??yt,y=n?.adapter??Le(),p={},l=vt(n);if(n?.element&&e)try{let g=e.getBoundingClientRect(),h=Math.min(1,s/Math.max(g.width,g.height)),f=Math.min(l,l*h),A=await Ne(Promise.resolve(y.captureElement(e,{...Oe({mime:c,quality:d,pixelRatio:f,maxDimension:s,includeQuality:c==="image/jpeg",...o?{signal:o}:{}})})),a,o);p.element=A;}catch(g){if(o?.aborted)throw g;i.push(b("capture_failed",g,{target:"element"}));}if(n?.fullPage)try{let g=await Ne(Promise.resolve(y.captureFullPage(Oe({mime:c,quality:d,pixelRatio:l,maxDimension:s,includeQuality:c==="image/jpeg",...o?{signal:o}:{}}))),a,o);p.fullPage=g;}catch(g){if(o?.aborted)throw g;i.push(b("capture_failed",g,{target:"fullPage"}));}let w=De(),u={startedAt:r,finishedAt:w,durationMs:Math.max(0,w-r)};return i.length>0&&(u.errors=i),{...p,diagnostics:u}}function kt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function _t(){return v()?{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:kt()}:{}}function Tt(t){if(!t)return {};let e={};return t.id&&(e.userId=t.id),t.email&&(e.userEmail=t.email),t.name&&(e.userName=t.name),e}async function Ve(t){let{config:e,context:n,user:o}=t;if(e?.enabled===false)return {};let r={..._t(),...Tt(o)},i=e?.enrich;if(!i)return r;try{let a=await i(n);return {...r,...a}}catch(a){let s=b("unknown",a);return {...r,blocfeedMetadataError:s.message}}}var me="blocfeed-queue",At=50;function pe(){if(!v())return [];try{let t=localStorage.getItem(me);if(!t)return [];let e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return []}}function ge(t){if(v())try{t.length===0?localStorage.removeItem(me):localStorage.setItem(me,JSON.stringify(t));}catch{}}function Rt(t){let e={...t};if(e.screenshots){let n={...e.screenshots};n.element&&(n.element={...n.element,dataUrl:""}),n.fullPage&&(n.fullPage={...n.fullPage,dataUrl:""}),e.screenshots=n;}return delete e.video,e}function he(t){let e=pe(),n=Rt(t);for(n.metadata={...n.metadata,_queued:true},e.push({payload:n,timestamp:Date.now()});e.length>At;)e.shift();ge(e);}function He(){let t=pe();return t.length===0?[]:(ge([]),t.map(e=>e.payload))}function _n(){ge([]);}function Tn(){return pe().length}var xt=200,X=[],qe=0,ee=false;function je(t){let e=t.target;if(!(e instanceof Element)||e.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-qe,path:window.location.pathname,tagName:e.tagName.toLowerCase()},o=ce(e,100);o&&(n.textSnippet=o);let r=le(e)??de(e);r&&(n.componentName=r),X.length<xt&&X.push(n);}function ze(){ee||!v()||(ee=true,X=[],qe=Date.now(),document.addEventListener("click",je,{capture:true,passive:true}));}function $e(){ee&&(ee=false,document.removeEventListener("click",je,{capture:true}));}function Pt(){return [...X]}function Ct(){X=[];}var Ft=3e4,Mt=25e5,Xe="video/webm",It=250,Bt=1e3,Lt=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function Ze(){if(typeof MediaRecorder>"u")return null;for(let t of Lt)if(MediaRecorder.isTypeSupported(t))return t;return null}function Dt(){return !v()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:Ze()!==null}async function be(t){let{config:e,signal:n}=t;if(!v()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw b("recording_failed",new Error("Screen recording is not supported in this browser"));let o=Ze();if(!o)throw b("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw b("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(h){let f=h instanceof DOMException&&h.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw b("recording_failed",new Error(f))}if(n?.aborted)throw r.getTracks().forEach(h=>h.stop()),b("aborted",new Error("Recording aborted after permission"));let i=e?.maxDurationMs??Ft,a=e?.videoBitsPerSecond??Mt,s=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:a}),c=[],d=[],y=0,p=null,l=null,w=false,u=()=>{$e(),p!==null&&(clearInterval(p),p=null),l!==null&&(clearTimeout(l),l=null),r.getTracks().forEach(h=>h.stop());},g=new Promise((h,f)=>{s.ondataavailable=S=>{S.data.size>0&&c.push(S.data);},s.onstop=()=>{if(w)return;w=true,u();let S=Date.now()-y,F=new Blob(c,{type:Xe}),B=URL.createObjectURL(F);h({mime:Xe,blobUrl:B,blob:F,durationMs:S,sizeBytes:F.size});},s.onerror=()=>{w||(w=true,u(),f(b("recording_failed",new Error("MediaRecorder error"))));};let A=r.getVideoTracks()[0];if(A&&A.addEventListener("ended",()=>{s.state!=="inactive"&&s.stop();}),n){let S=()=>{w||(w=true,s.state!=="inactive"&&s.stop(),u(),f(b("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",S,{once:true});}});return s.start(Bt),ze(),y=Date.now(),p=setInterval(()=>{let h=Date.now()-y;for(let f of d)f(h);},It),l=setTimeout(()=>{!w&&s.state!=="inactive"&&s.stop();},i),{result:g,stop(){!w&&s.state!=="inactive"&&s.stop();},onTick(h){d.push(h);},abort(){w||(w=true,s.state!=="inactive"&&s.stop(),u());}}}var Nt=6e4,We="audio/webm",Ot=250,Ut=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function Ke(){if(typeof MediaRecorder>"u")return null;for(let t of Ut)if(MediaRecorder.isTypeSupported(t))return t;return null}function Vt(){return !v()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:Ke()!==null}async function we(t){let{config:e,signal:n}=t;if(!v()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw b("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=Ke();if(!o)throw b("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw b("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(g){let h=g instanceof DOMException&&g.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw b("recording_failed",new Error(h))}if(n?.aborted)throw r.getTracks().forEach(g=>g.stop()),b("aborted",new Error("Voice recording aborted after permission"));let i=e?.maxDurationMs??Nt,a=new MediaRecorder(r,{mimeType:o}),s=[],c=[],d=0,y=null,p=null,l=false,w=()=>{y!==null&&(clearInterval(y),y=null),p!==null&&(clearTimeout(p),p=null),r.getTracks().forEach(g=>g.stop());},u=new Promise((g,h)=>{if(a.ondataavailable=f=>{f.data.size>0&&s.push(f.data);},a.onstop=()=>{if(l)return;l=true,w();let f=Date.now()-d,A=new Blob(s,{type:We});g({blob:A,mime:We,durationMs:f});},a.onerror=()=>{l||(l=true,w(),h(b("recording_failed",new Error("MediaRecorder error"))));},n){let f=()=>{l||(l=true,a.state!=="inactive"&&a.stop(),w(),h(b("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",f,{once:true});}});return a.start(1e3),d=Date.now(),y=setInterval(()=>{let g=Date.now()-d;for(let h of c)h(g);},Ot),p=setTimeout(()=>{!l&&a.state!=="inactive"&&a.stop();},i),{result:u,stop(){!l&&a.state!=="inactive"&&a.stop();},onTick(g){c.push(g);},abort(){l||(l=true,a.state!=="inactive"&&a.stop(),w());}}}var Ht=12e3,qt=2,jt=500,zt=2e3,ye="https://blocfeed.com/api/feedback",$t="https://blocfeed.com/api/feedback/voice",Xt="https://blocfeed.com/api/feedback/config",Qe=0;function Ge(t,e){return new Promise((n,o)=>{if(e?.aborted){o(new Error("Aborted"));return}let r=setTimeout(n,t),i=()=>{clearTimeout(r),o(new Error("Aborted"));};e?.addEventListener("abort",i,{once:true});})}function Zt(t){return t>=500&&t<=599}function Wt(t){let[e,n]=t.split(",",2);if(!e||!n)throw new Error("Invalid data URL");let r=/data:(.*?);base64/.exec(e)?.[1]||"application/octet-stream",i=atob(n),a=new Uint8Array(i.length);for(let s=0;s<i.length;s+=1)a[s]=i.charCodeAt(s);return new Blob([a],{type:r})}function Kt(t){let e={},n={},o={...t};if(o.screenshots){let r={},i={...o.screenshots};i.element&&(e.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&&(e.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:e,extractedVideo:n}}async function Ye(t,e,n){let o=Wt(e);await fetch(t,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function Qt(t){let{feedbackId:e,extracted:n,screenshots:o,signal:r}=t,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}/${e}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function Gt(t){await fetch(`${ye}/${t.feedbackId}/video`,{method:"POST",body:t.blob,headers:{"content-type":t.blob.type},...t.signal?{signal:t.signal}:{}});}async function Je(t){let{signal:e,transport:n}=t;if(Date.now()-Qe<zt)return {ok:false,error:b("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??Ht,i=n?.maxAttempts??qt,a=n?.backoffMs??jt,s=!!(t.payload.screenshots?.element?.dataUrl||t.payload.screenshots?.fullPage?.dataUrl),c=!!t.payload.video?.blob,d=s||c,{lean:y,extracted:p,extractedVideo:l}=d?Kt(t.payload):{lean:t.payload,extracted:{},extractedVideo:{}},w={...p,...t.screenshotDataUrls};for(let u=1;u<=i;u+=1){let g=new AbortController,h=setTimeout(()=>g.abort(),r),f=()=>g.abort();e&&e.addEventListener("abort",f,{once:true});try{let A=await fetch(ye,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(y),signal:g.signal});if(A.ok){Qe=Date.now();let S;try{S=await A.json();}catch{}if((w.element||w.fullPage)&&S){let C=S.upload_urls;if(C){let H=[];w.element&&C.element&&H.push(Ye(C.element,w.element,e)),w.fullPage&&C.fullPage&&H.push(Ye(C.fullPage,w.fullPage,e));try{await Promise.all(H);}catch{}}else if(S.feedback_id)try{await Qt({feedbackId:S.feedback_id,extracted:w,screenshots:t.payload.screenshots,...e?{signal:e}:{}});}catch{}}if(l.blob&&S){let C=S.upload_urls;if(C?.video)try{await fetch(C.video,{method:"PUT",body:l.blob,headers:{"content-type":l.blob.type},...e?{signal:e}:{}});}catch{}else if(S.feedback_id)try{await Gt({feedbackId:S.feedback_id,blob:l.blob,...e?{signal:e}:{}});}catch{}}let B={ok:!0,status:A.status};return S&&(B.apiResponse=S),B}if(u<i&&Zt(A.status)){let S=.85+Math.random()*.3,F=Math.round(a*2**(u-1)*S);await Ge(F,e);continue}return {ok:!1,status:A.status,error:b("api_failed",new Error(`HTTP ${A.status}`))}}catch(A){if(g.signal.aborted||e?.aborted)return {ok:false,error:b("aborted",A)};if(u<i){let S=.85+Math.random()*.3,F=Math.round(a*2**(u-1)*S);await Ge(F,e);continue}return {ok:false,error:b("api_failed",A)}}finally{clearTimeout(h),e&&e.removeEventListener("abort",f);}}return {ok:false,error:b("api_failed",new Error("Failed"))}}async function et(t){let{blob:e,mime:n,blocfeedId:o,signal:r}=t,i=await fetch($t,{method:"POST",headers:{"Content-Type":n,"X-Blocfeed-Id":o},body:e,...r?{signal:r}:{}});if(!i.ok){let s=await i.json().catch(()=>({error:"Unknown error"}));throw b("api_failed",new Error(s?.error??`Voice API returned ${i.status}`))}let a=await i.json();return {text:a.text??"",warning:a.warning}}async function tt(t){let{blocfeedId:e,signal:n}=t;try{let o=await fetch(Xt,{method:"GET",headers:{"X-Blocfeed-Id":e},...n?{signal:n}:{}});return o.ok?{voice_feedback_enabled:!!(await o.json()).voice_feedback_enabled}:null}catch{return null}}function Ee(t){let e=null,n=null,o=(...r)=>{n=r,e===null&&(e=requestAnimationFrame(()=>{if(e=null,!n)return;let i=n;n=null,t(...i);}));};return o.cancel=()=>{e!==null&&cancelAnimationFrame(e),e=null,n=null;},o}function te(t){return t instanceof Element?!!t.closest("[data-blocfeed-ui]"):false}function ne(t){t.stopPropagation(),t.stopImmediatePropagation?.();}function nt(t,e){if(!v())throw new Error("BlocFeed picker can only run in a browser environment.");let n=t.ignoreSelectors,o=t.isSelectable,r={};n&&n.length>0&&(r.ignoreSelectors=n),o&&(r.isSelectable=o);let i=null,a=null,s=(u,g=false)=>{if(!u){i=null,a=null,e.onHover(null);return}let h=se(u.getBoundingClientRect()),f=`${Math.round(h.x)}:${Math.round(h.y)}:${Math.round(h.width)}:${Math.round(h.height)}`;!g&&u===i&&f===a||(i=u,a=f,e.onHover({element:u,rect:h}));},c=Ee(u=>{if(te(u.target))return;let g=document.elementFromPoint(u.clientX,u.clientY),h=ue(g,r);s(h);}),d=Ee(()=>{i&&s(i,true);}),y=u=>{te(u.target)||(ne(u),u.pointerType==="mouse"&&u.preventDefault());},p=u=>{te(u.target)||(ne(u),u.pointerType==="mouse"&&u.preventDefault());},l=u=>{if(te(u.target))return;ne(u),u.preventDefault();let g=document.elementFromPoint(u.clientX,u.clientY),h=ue(g,r);h&&e.onSelect({element:h,descriptor:Me(h)});},w=u=>{u.key==="Escape"&&(ne(u),u.preventDefault(),e.onCancel());};return window.addEventListener("pointermove",c,{capture:true,passive:true}),window.addEventListener("pointerdown",y,{capture:true}),window.addEventListener("pointerup",p,{capture:true}),window.addEventListener("click",l,{capture:true}),window.addEventListener("keydown",w,{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",y,{capture:true}),window.removeEventListener("pointerup",p,{capture:true}),window.removeEventListener("click",l,{capture:true}),window.removeEventListener("keydown",w,{capture:true}),window.removeEventListener("scroll",d,{capture:true}),window.removeEventListener("resize",d),c.cancel(),d.cancel(),e.onHover(null);}}}async function ve(t){let{signal:e,transport:n}=t,o={ok:false};try{let r={payload:t.payload,...e?{signal:e}:{},...n?{transport:n}:{}};o.api=await Je(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:b("api_failed",r)},o.ok=false;}return {payload:t.payload,result:o}}var Yt=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function Jt(t){let e=[...Yt,...t?.ignoreSelectors??[]],n=Array.from(new Set(e));return {...t,ignoreSelectors:n}}function ot(){return {phase:"idle"}}function en(t){if(t.ok)return false;let e=t.api;return e?e.status&&e.status>=400&&e.status<500||e.error?.kind==="aborted"||e.error?.kind==="configuration"?false:!e.ok:true}function ao(t){let e=t,n=ot(),o=new Set,r=new Set,i=null,a=null,s=null,c=null,d=0,y=null,p=null,l=null,w=null,u=false,g=()=>{for(let m of o)m(n);},h=m=>{for(let E of r)E(m);},f=m=>{n=m,g();},A=()=>{d+=1,c?.abort(),c=null;},S=()=>{i?.stop(),i=null,h(null),s!==null&&v()&&(document.documentElement.style.cursor=s,s=null);},F=()=>{p&&(p.abort(),p=null),l&&(URL.revokeObjectURL(l.blobUrl),l=null);},B=()=>{w&&(w.abort(),w=null);},C=()=>{A(),S(),F(),B(),a=null,f(ot());},H=()=>{if(!v())return;S(),a=null;let m=Jt(e.picker);s=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",f({phase:"picking"}),i=nt(m,{onHover:h,onSelect:({element:E,descriptor:x})=>{a=E,S(),f({phase:"review",selection:x});},onCancel:()=>{C();}});},Te=()=>{let m=He();if(m.length!==0)for(let E of m)ve({payload:E,...e.transport?{transport:e.transport}:{}}).catch(()=>{he(E);});};if(v()){setTimeout(Te,1e3);let m=()=>Te();window.addEventListener("online",m),y=()=>window.removeEventListener("online",m);}let at=()=>{if(u)return;let m=e.blocfeed_id?.trim?.()??"";m&&(u=true,tt({blocfeedId:m}).then(E=>{E&&(E.voice_feedback_enabled?e.voice?e.voice.enabled||(e={...e,voice:{...e.voice,enabled:true}}):e={...e,voice:{enabled:true}}:e.voice?.enabled&&(e={...e,voice:{...e.voice,enabled:false}}),g());}).catch(()=>{}));};return v()&&setTimeout(at,0),{getState:()=>n,getConfig:()=>e,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(){C();},clearSelection(){n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording"||H();},setConfig(m){e=m;},async submit(m,E){if(!v()){let _=b("configuration",new Error("BlocFeed submit can only run in the browser"));return f({phase:"error",lastError:_}),{ok:false}}let x=e.blocfeed_id?.trim?.()??"";if(!x){let M={phase:"error",lastError:b("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return n.selection&&(M.selection=n.selection),f(M),{ok:false}}if(n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording")return {ok:false};let R=d+1;d=R,c?.abort(),c=new AbortController;let T=c.signal,k=n.selection,I=E?.capture?{...e.capture,...E.capture}:e.capture,L=!!(I?.element||I?.fullPage),j={phase:L?"capturing":"submitting"};k&&(j.selection=k),f(j);try{let _=L?await Ue({selectionElement:a,capture:I,signal:T}):void 0;if(T.aborted||d!==R)return {ok:!1};let M={phase:"submitting"};k&&(M.selection=k),_&&(M.capture=_),f(M);let D={};k&&(D.selection=k),_&&(D.capture=_);let z=await Ve({config:e.metadata,context:D,...e.user?{user:e.user}:{}}),O={version:1,createdAt:new Date().toISOString(),blocfeed_id:x,message:m,metadata:z};E?.category&&(O.category=E.category),e.user&&(O.user=e.user),k&&(O.selection=k),_&&(O.screenshots=_),l&&(O.video=l);let{result:N}=await ve({payload:O,signal:T,...e.transport?{transport:e.transport}:{}});if(T.aborted||d!==R)return N;if(N.ok){l&&(URL.revokeObjectURL(l.blobUrl),l=null);let ae={phase:"success",lastSubmit:N};return k&&(ae.selection=k),_&&(ae.capture=_),f(ae),N}en(N)&&he(O);let st=N.api?.error??b("unknown",new Error("Submission failed")),ie={phase:"error",lastSubmit:N,lastError:st};return k&&(ie.selection=k),_&&(ie.capture=_),f(ie),N}catch(_){if(T.aborted||d!==R)return {ok:false};let D={phase:"error",lastError:T.aborted?b("aborted",_):b("unknown",_)};return k&&(D.selection=k),f(D),{ok:false}}finally{d===R&&(c=null);}},async startRecording(){if(n.phase!=="review"||!e.recording?.enabled)return;let m=n.selection,E={phase:"recording",recordingElapsedMs:0};m&&(E.selection=m),f(E);try{let x={config:e.recording};c&&(x.signal=c.signal);let R=await be(x);p=R,R.onTick(I=>{if(n.phase==="recording"){let L={phase:"recording",recordingElapsedMs:I};m&&(L.selection=m),f(L);}});let T=await R.result;p=null,l=T;let k={phase:"review",video:T};m&&(k.selection=m),f(k);}catch(x){p=null;let T={phase:"review",lastError:x?.kind?x:b("recording_failed",x)};m&&(T.selection=m),f(T);}},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),f(E);},async startVoice(){if(n.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",n.phase,'(expected "review")');return}let m=e.voice;if(!m?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}B();let E=n.selection,x={phase:"review",voiceRecording:true,voiceElapsedMs:0};E&&(x.selection=E),l&&(x.video=l),f(x);try{let R={config:m};c&&(R.signal=c.signal);let T=await we(R);w=T,T.onTick(D=>{let z={phase:"review",voiceRecording:!0,voiceElapsedMs:D};E&&(z.selection=E),l&&(z.video=l),f(z);});let k=await T.result;w=null;let I={phase:"review",voiceRecording:!1,voiceTranscribing:!0};E&&(I.selection=E),l&&(I.video=l),f(I);let L={blob:k.blob,mime:k.mime,blocfeedId:e.blocfeed_id};c&&(L.signal=c.signal);let{text:Ae,warning:j}=await et(L),_={phase:"review",voiceRecording:!1,voiceTranscribing:!1};E&&(_.selection=E),l&&(_.video=l),f(_);let M={text:Ae};return j&&(M.warning=j),M}catch(R){B();let T=R?.kind?R:b("recording_failed",R);console.warn("[BlocFeed] Voice error:",T.message);let k={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:T};E&&(k.selection=E),l&&(k.video=l),f(k);return}},stopVoice(){w&&w.stop();},__unsafeGetSelectedElement(){return a},destroy(){C(),o.clear(),r.clear(),y?.(),y=null;}}}var Z=[],W=[],rt=20,it=15,oe=[],K={},Q=null,G=null,Y=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(t){if(t instanceof Error)return t.message;if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}function on(t,e){let n=e.map(nn).join(" "),o=e.find(i=>i instanceof Error),r={level:t,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(t){let e=t.url.toLowerCase();for(let n of oe)if(e.includes(n))return;for(W.push(t);W.length>it;)W.shift();}function lo(t={}){if(re||!v())return;re=true,rt=t.consoleLimit??20,it=t.networkLimit??15;let e=t.ignoreUrls;if(e!==void 0?oe=e.map(n=>n.toLowerCase()):oe=[...tn],t.console!==false){let n=t.consoleLevels??["error","warn"];for(let o of n)K[o]=console[o],console[o]=(...r)=>{on(o,r),K[o]?.apply(console,r);};}if(t.network!==false&&typeof window.fetch=="function"){Q=window.fetch;let n=Q;window.fetch=async function(r,i){let a=typeof r=="string"?r:r instanceof URL?r.toString():r.url,s=(i?.method??"GET").toUpperCase(),c=Date.now();try{let d=await n.call(window,r,i);return d.ok||Se({url:a.slice(0,500),method:s,status:d.status,statusText:d.statusText,timestamp:c,durationMs:Date.now()-c}),d}catch(d){throw Se({url:a.slice(0,500),method:s,status:0,statusText:d instanceof Error?d.message:"Network error",timestamp:c,durationMs:Date.now()-c}),d}};}if(t.network!==false&&typeof XMLHttpRequest<"u"){G=XMLHttpRequest.prototype.open,Y=XMLHttpRequest.prototype.send;let n=G,o=Y;XMLHttpRequest.prototype.open=function(r,i,...a){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...a])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",a=this.__bf_url||"",s=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let c={url:a.slice(0,500),method:i,status:this.status,timestamp:s,durationMs:Date.now()-s};this.statusText&&(c.statusText=this.statusText),Se(c);}}),o.apply(this,r)};}}function uo(){if(re){for(let[t,e]of Object.entries(K))console[t]=e;for(let t of Object.keys(K))delete K[t];Q&&(window.fetch=Q,Q=null),G&&(XMLHttpRequest.prototype.open=G,G=null),Y&&(XMLHttpRequest.prototype.send=Y,Y=null),oe=[],re=false;}}function fo(){return {consoleLogs:[...Z],networkErrors:[...W]}}function mo(){Z=[],W=[];}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,}/}],V=[],_e=0,ke=false;function an(t){let e=t.slice(0,80);return e.length<=6?"***":e.slice(0,6)+"***"}function sn(t,e,n,o){if(V.some(a=>a.rule===t&&a.source===e))return;let i={rule:t,source:e,hint:an(n),timestamp:Date.now()};o&&(i.location=o),V.push(i);}function J(t,e,n,o){for(let{name:r,pattern:i}of n){let a=i.exec(t);a&&sn(r,e,a[0],o);}}function cn(t){try{let e=window;if(e.__NEXT_DATA__){let n=JSON.stringify(e.__NEXT_DATA__);J(n,"hydration",t,"__NEXT_DATA__");}if(e.__NUXT__){let n=JSON.stringify(e.__NUXT__);J(n,"hydration",t,"__NUXT__");}}catch{}}function ln(t){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&J(r,"scripts",t,`inline-script[${o}]`);});}catch{}}function dn(t){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",t,r?`meta[${r}]`:void 0);});}catch{}}function un(t){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",t,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function ho(t={}){if(ke||!v()||(ke=true,t.secretScan===false))return;let e=[...rn,...t.customPatterns??[]],n=t.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{_e=Date.now(),n.includes("hydration")&&cn(e),n.includes("scripts")&&ln(e),n.includes("meta")&&dn(e),n.includes("dom")&&un(e);let o=t.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 bo(){return {findings:[...V],scannedAt:_e}}function wo(){V=[],_e=0,ke=false;}
|
|
2
|
-
exports.a=v;exports.b=se;exports.c=Le;exports.d=Ue;exports.e=Ve;exports.f=he;exports.g=He;exports.h=_n;exports.i=Tn;exports.j=Pt;exports.k=Ct;exports.l=Dt;exports.m=be;exports.n=Vt;exports.o=we;exports.p=et;exports.q=tt;exports.r=ao;exports.s=lo;exports.t=uo;exports.u=fo;exports.v=mo;exports.w=ho;exports.x=bo;exports.y=wo;
|
package/dist/chunk-TY4R37ZM.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function v(){return typeof window<"u"&&typeof document<"u"}function Re(t){let e=globalThis.CSS;return typeof e?.escape=="function"?e.escape(t):t.replace(/[^a-zA-Z0-9_-]/g,n=>{let o=n.codePointAt(0);return o===void 0?"":`\\${o.toString(16)} `})}function se(t){return {x:t.x,y:t.y,width:t.width,height:t.height}}function ct(t){return {x:t.x+window.scrollX,y:t.y+window.scrollY,width:t.width,height:t.height}}function lt(t){return t.replace(/\s+/g," ").trim()}function ce(t,e=140){let n=t.textContent;if(!n)return;let o=lt(n);if(o)return o.length<=e?o:`${o.slice(0,e-1)}\u2026`}function dt(t){let e=1;for(let n=t.previousElementSibling;n;n=n.previousElementSibling)n.tagName===t.tagName&&(e+=1);return e}var Fe=["data-testid","data-test-id","data-test","data-qa","data-cy"],xe="data-blocfeed-component";function le(t){let e=t.closest(`[${xe}]`);if(!e)return;let o=e.getAttribute(xe)?.trim();return o||void 0}function ut(t){for(let e of Fe){let n=t.closest(`[${e}]`);if(!n)continue;let r=n.getAttribute(e)?.trim();if(r)return r}}function Pe(t){try{let e=t,n=Object.getOwnPropertyNames(e);for(let o of n)if(o.startsWith("__reactFiber$")||o.startsWith("__reactInternalInstance$")){let r=e[o];if(r&&typeof r=="object")return r}}catch{}return null}function U(t){if(t.length<=1||t.length===2&&t[0]===t[0].toLowerCase()||t.startsWith("__")&&t.endsWith("__"))return true;let e=t[0];return e>="a"&&e<="z"}function $(t){if(t){for(let e of t)if(typeof e.name=="string"&&e.name&&!U(e.name))return e.name}}function P(t){if(t&&typeof t!="string"){if(typeof t=="function"){let e=t;return typeof e.displayName=="string"&&e.displayName?e.displayName:typeof e.name=="string"&&e.name?e.name:void 0}if(typeof t=="object"){let e=t,n=e.displayName;if(typeof n=="string"&&n)return n;let o=e.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=e.type;return P(r)}}}function de(t){let e=Pe(t);if(!e)return;let n=$(e._debugInfo);if(n)return n;let o=e._debugOwner!==void 0;if(o){let c=e._debugOwner;for(let d=0;c&&d<50;d+=1){let y=$(c._debugInfo);if(y)return y;let p=P(c.type)??P(c.elementType);if(p&&!U(p))return p;c=c._debugOwner;}}if(e._owner!==void 0&&e._owner!==e._debugOwner){let c=e._owner;for(let d=0;c&&d<50;d+=1){let y=$(c._debugInfo);if(y)return y;let p=P(c.type)??P(c.elementType);if(p&&!U(p))return p;c=c._owner;}}let i=e,a=o?80:25;for(let c=0;i&&c<a;c+=1){let d=$(i._debugInfo);if(d)return d;let y=P(i.type)??P(i.elementType);if(y&&!U(y))return y;i=i.return;}let s=t.parentElement;for(let c=0;s&&c<15;c+=1){let d=Pe(s);if(d){let y=$(d._debugInfo);if(y)return y;let p=P(d.type)??P(d.elementType);if(p&&!U(p))return p;if(d._debugOwner){let l=P(d._debugOwner.type)??P(d._debugOwner.elementType);if(l&&!U(l))return l}if(d._owner&&d._owner!==d._debugOwner){let l=P(d._owner.type)??P(d._owner.elementType);if(l&&!U(l))return l}}s=s.parentElement;}}function ft(t){let e=t.tagName.toLowerCase(),n=t.getAttribute("id");if(n)return `#${Re(n)}`;for(let o of Fe){let r=t.getAttribute(o);if(r)return `${e}[${o}="${Re(r)}"]`}return `${e}:nth-of-type(${dt(t)})`}function mt(t,e=10){let n=[],o=t;for(;o&&n.length<e;){let r=ft(o);if(n.unshift(r),r.startsWith("#"))break;o=o.parentElement;}return n.join(" > ")}function Ce(t,e){if(!e||e.length===0)return false;for(let n of e)if(t.closest(n))return true;return false}function ue(t,e){if(!t||Ce(t,e.ignoreSelectors))return null;let n=t;for(;n;){if(Ce(n,e.ignoreSelectors))return null;if(e.isSelectable?.(n)??pt(n))return n;n=n.parentElement;}return null}function pt(t){let e=t.tagName;return !(e==="HTML"||e==="BODY")}function Me(t){let e=t.getBoundingClientRect(),n={selector:mt(t),tagName:t.tagName.toLowerCase(),rect:se(e),pageRect:ct(e)},o=t.getAttribute("id");o&&(n.id=o);let r=t.className;typeof r=="string"&&r.trim()&&(n.className=r);let i=ce(t);i&&(n.textSnippet=i);let a=le(t)??de(t);a&&(n.componentName=a);let s=ut(t);return s&&(n.testId=s),n}var fe=null;async function Ie(){return fe||(fe=import('html-to-image')),fe}async function gt(t){return await new Promise((e,n)=>{let o=new Image;o.onload=()=>e({width:o.naturalWidth,height:o.naturalHeight}),o.onerror=()=>n(new Error("Failed to load generated screenshot")),o.src=t;})}async function Be(t,e){let{width:n,height:o}=await gt(t);return {dataUrl:t,mime:e,width:n,height:o}}function q(t){if(t?.aborted)throw new Error("Aborted")}function Le(){return {async captureElement(t,e){if(!v())throw new Error("captureElement can only run in the browser");q(e.signal);let n=await Ie();q(e.signal);let o=e.mime==="image/jpeg"?await n.toJpeg(t,{quality:e.quality??.92,pixelRatio:e.pixelRatio}):await n.toPng(t,{pixelRatio:e.pixelRatio});return q(e.signal),await Be(o,e.mime)},async captureFullPage(t){if(!v())throw new Error("captureFullPage can only run in the browser");q(t.signal);let e=document.documentElement,n=Math.max(e.scrollWidth,e.clientWidth),o=Math.max(e.scrollHeight,e.clientHeight),r=Math.min(1,t.maxDimension/Math.max(n,o)),i=Math.max(1,Math.round(n*r)),a=Math.max(1,Math.round(o*r)),s=await Ie();q(t.signal);let c=t.mime==="image/jpeg"?await s.toJpeg(e,{width:i,height:a,quality:t.quality??.92,pixelRatio:t.pixelRatio}):await s.toPng(e,{width:i,height:a,pixelRatio:t.pixelRatio});return q(t.signal),await Be(c,t.mime)}}}function ht(t){if(t instanceof Error)return t.message;if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return "Unknown error"}}function b(t,e,n){let o={kind:t,message:ht(e)};return n&&(o.detail=n),o}var bt=12e3,wt=2048,yt=.92;function De(){return Date.now()}function Et(t){return new Promise((e,n)=>{let o=()=>n(new Error("Aborted"));if(t.aborted){o();return}t.addEventListener("abort",o,{once:true});})}async function Ne(t,e,n){let o=new Promise((i,a)=>{let s=setTimeout(()=>a(new Error("Timeout")),e);typeof s.unref=="function"&&s.unref();}),r=[t,o];return n&&r.push(Et(n)),await Promise.race(r)}function vt(t){if(!v())return 1;let e=window.devicePixelRatio||1,n=t?.pixelRatio??Math.min(e,2);return Math.max(.1,n)}function St(t){return !!(t?.element||t?.fullPage)}function Oe(t){let e={mime:t.mime,pixelRatio:t.pixelRatio,maxDimension:t.maxDimension};return t.includeQuality&&(e.quality=t.quality),t.signal&&(e.signal=t.signal),e}async function Ue(t){let{selectionElement:e,capture:n,signal:o}=t;if(!v()||!St(n))return;let r=De(),i=[],a=n?.timeoutMs??bt,s=n?.maxDimension??wt,c=n?.mime??"image/png",d=n?.quality??yt,y=n?.adapter??Le(),p={},l=vt(n);if(n?.element&&e)try{let g=e.getBoundingClientRect(),h=Math.min(1,s/Math.max(g.width,g.height)),f=Math.min(l,l*h),A=await Ne(Promise.resolve(y.captureElement(e,{...Oe({mime:c,quality:d,pixelRatio:f,maxDimension:s,includeQuality:c==="image/jpeg",...o?{signal:o}:{}})})),a,o);p.element=A;}catch(g){if(o?.aborted)throw g;i.push(b("capture_failed",g,{target:"element"}));}if(n?.fullPage)try{let g=await Ne(Promise.resolve(y.captureFullPage(Oe({mime:c,quality:d,pixelRatio:l,maxDimension:s,includeQuality:c==="image/jpeg",...o?{signal:o}:{}}))),a,o);p.fullPage=g;}catch(g){if(o?.aborted)throw g;i.push(b("capture_failed",g,{target:"fullPage"}));}let w=De(),u={startedAt:r,finishedAt:w,durationMs:Math.max(0,w-r)};return i.length>0&&(u.errors=i),{...p,diagnostics:u}}function kt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function _t(){return v()?{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:kt()}:{}}function Tt(t){if(!t)return {};let e={};return t.id&&(e.userId=t.id),t.email&&(e.userEmail=t.email),t.name&&(e.userName=t.name),e}async function Ve(t){let{config:e,context:n,user:o}=t;if(e?.enabled===false)return {};let r={..._t(),...Tt(o)},i=e?.enrich;if(!i)return r;try{let a=await i(n);return {...r,...a}}catch(a){let s=b("unknown",a);return {...r,blocfeedMetadataError:s.message}}}var me="blocfeed-queue",At=50;function pe(){if(!v())return [];try{let t=localStorage.getItem(me);if(!t)return [];let e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return []}}function ge(t){if(v())try{t.length===0?localStorage.removeItem(me):localStorage.setItem(me,JSON.stringify(t));}catch{}}function Rt(t){let e={...t};if(e.screenshots){let n={...e.screenshots};n.element&&(n.element={...n.element,dataUrl:""}),n.fullPage&&(n.fullPage={...n.fullPage,dataUrl:""}),e.screenshots=n;}return delete e.video,e}function he(t){let e=pe(),n=Rt(t);for(n.metadata={...n.metadata,_queued:true},e.push({payload:n,timestamp:Date.now()});e.length>At;)e.shift();ge(e);}function He(){let t=pe();return t.length===0?[]:(ge([]),t.map(e=>e.payload))}function _n(){ge([]);}function Tn(){return pe().length}var xt=200,X=[],qe=0,ee=false;function je(t){let e=t.target;if(!(e instanceof Element)||e.closest("[data-blocfeed-ui]"))return;let n={timestampMs:Date.now()-qe,path:window.location.pathname,tagName:e.tagName.toLowerCase()},o=ce(e,100);o&&(n.textSnippet=o);let r=le(e)??de(e);r&&(n.componentName=r),X.length<xt&&X.push(n);}function ze(){ee||!v()||(ee=true,X=[],qe=Date.now(),document.addEventListener("click",je,{capture:true,passive:true}));}function $e(){ee&&(ee=false,document.removeEventListener("click",je,{capture:true}));}function Pt(){return [...X]}function Ct(){X=[];}var Ft=3e4,Mt=25e5,Xe="video/webm",It=250,Bt=1e3,Lt=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function Ze(){if(typeof MediaRecorder>"u")return null;for(let t of Lt)if(MediaRecorder.isTypeSupported(t))return t;return null}function Dt(){return !v()||typeof navigator?.mediaDevices?.getDisplayMedia!="function"?false:Ze()!==null}async function be(t){let{config:e,signal:n}=t;if(!v()||typeof navigator?.mediaDevices?.getDisplayMedia!="function")throw b("recording_failed",new Error("Screen recording is not supported in this browser"));let o=Ze();if(!o)throw b("recording_failed",new Error("No supported video codec found (WebM required)"));if(n?.aborted)throw b("aborted",new Error("Recording aborted before start"));let r;try{r=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1});}catch(h){let f=h instanceof DOMException&&h.name==="NotAllowedError"?"Screen share permission denied":"Failed to start screen share";throw b("recording_failed",new Error(f))}if(n?.aborted)throw r.getTracks().forEach(h=>h.stop()),b("aborted",new Error("Recording aborted after permission"));let i=e?.maxDurationMs??Ft,a=e?.videoBitsPerSecond??Mt,s=new MediaRecorder(r,{mimeType:o,videoBitsPerSecond:a}),c=[],d=[],y=0,p=null,l=null,w=false,u=()=>{$e(),p!==null&&(clearInterval(p),p=null),l!==null&&(clearTimeout(l),l=null),r.getTracks().forEach(h=>h.stop());},g=new Promise((h,f)=>{s.ondataavailable=S=>{S.data.size>0&&c.push(S.data);},s.onstop=()=>{if(w)return;w=true,u();let S=Date.now()-y,F=new Blob(c,{type:Xe}),B=URL.createObjectURL(F);h({mime:Xe,blobUrl:B,blob:F,durationMs:S,sizeBytes:F.size});},s.onerror=()=>{w||(w=true,u(),f(b("recording_failed",new Error("MediaRecorder error"))));};let A=r.getVideoTracks()[0];if(A&&A.addEventListener("ended",()=>{s.state!=="inactive"&&s.stop();}),n){let S=()=>{w||(w=true,s.state!=="inactive"&&s.stop(),u(),f(b("aborted",new Error("Recording aborted"))));};n.addEventListener("abort",S,{once:true});}});return s.start(Bt),ze(),y=Date.now(),p=setInterval(()=>{let h=Date.now()-y;for(let f of d)f(h);},It),l=setTimeout(()=>{!w&&s.state!=="inactive"&&s.stop();},i),{result:g,stop(){!w&&s.state!=="inactive"&&s.stop();},onTick(h){d.push(h);},abort(){w||(w=true,s.state!=="inactive"&&s.stop(),u());}}}var Nt=6e4,We="audio/webm",Ot=250,Ut=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus"];function Ke(){if(typeof MediaRecorder>"u")return null;for(let t of Ut)if(MediaRecorder.isTypeSupported(t))return t;return null}function Vt(){return !v()||typeof navigator?.mediaDevices?.getUserMedia!="function"?false:Ke()!==null}async function we(t){let{config:e,signal:n}=t;if(!v()||typeof navigator?.mediaDevices?.getUserMedia!="function")throw b("recording_failed",new Error("Microphone recording is not supported in this browser"));let o=Ke();if(!o)throw b("recording_failed",new Error("No supported audio codec found"));if(n?.aborted)throw b("aborted",new Error("Voice recording aborted before start"));let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0});}catch(g){let h=g instanceof DOMException&&g.name==="NotAllowedError"?"Microphone permission denied":"Failed to access microphone";throw b("recording_failed",new Error(h))}if(n?.aborted)throw r.getTracks().forEach(g=>g.stop()),b("aborted",new Error("Voice recording aborted after permission"));let i=e?.maxDurationMs??Nt,a=new MediaRecorder(r,{mimeType:o}),s=[],c=[],d=0,y=null,p=null,l=false,w=()=>{y!==null&&(clearInterval(y),y=null),p!==null&&(clearTimeout(p),p=null),r.getTracks().forEach(g=>g.stop());},u=new Promise((g,h)=>{if(a.ondataavailable=f=>{f.data.size>0&&s.push(f.data);},a.onstop=()=>{if(l)return;l=true,w();let f=Date.now()-d,A=new Blob(s,{type:We});g({blob:A,mime:We,durationMs:f});},a.onerror=()=>{l||(l=true,w(),h(b("recording_failed",new Error("MediaRecorder error"))));},n){let f=()=>{l||(l=true,a.state!=="inactive"&&a.stop(),w(),h(b("aborted",new Error("Voice recording aborted"))));};n.addEventListener("abort",f,{once:true});}});return a.start(1e3),d=Date.now(),y=setInterval(()=>{let g=Date.now()-d;for(let h of c)h(g);},Ot),p=setTimeout(()=>{!l&&a.state!=="inactive"&&a.stop();},i),{result:u,stop(){!l&&a.state!=="inactive"&&a.stop();},onTick(g){c.push(g);},abort(){l||(l=true,a.state!=="inactive"&&a.stop(),w());}}}var Ht=12e3,qt=2,jt=500,zt=2e3,ye="https://blocfeed.com/api/feedback",$t="https://blocfeed.com/api/feedback/voice",Xt="https://blocfeed.com/api/feedback/config",Qe=0;function Ge(t,e){return new Promise((n,o)=>{if(e?.aborted){o(new Error("Aborted"));return}let r=setTimeout(n,t),i=()=>{clearTimeout(r),o(new Error("Aborted"));};e?.addEventListener("abort",i,{once:true});})}function Zt(t){return t>=500&&t<=599}function Wt(t){let[e,n]=t.split(",",2);if(!e||!n)throw new Error("Invalid data URL");let r=/data:(.*?);base64/.exec(e)?.[1]||"application/octet-stream",i=atob(n),a=new Uint8Array(i.length);for(let s=0;s<i.length;s+=1)a[s]=i.charCodeAt(s);return new Blob([a],{type:r})}function Kt(t){let e={},n={},o={...t};if(o.screenshots){let r={},i={...o.screenshots};i.element&&(e.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&&(e.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:e,extractedVideo:n}}async function Ye(t,e,n){let o=Wt(e);await fetch(t,{method:"PUT",body:o,headers:{"content-type":o.type},...n?{signal:n}:{}});}async function Qt(t){let{feedbackId:e,extracted:n,screenshots:o,signal:r}=t,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}/${e}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...r?{signal:r}:{}});}async function Gt(t){await fetch(`${ye}/${t.feedbackId}/video`,{method:"POST",body:t.blob,headers:{"content-type":t.blob.type},...t.signal?{signal:t.signal}:{}});}async function Je(t){let{signal:e,transport:n}=t;if(Date.now()-Qe<zt)return {ok:false,error:b("configuration",new Error("Please wait before submitting again"))};let r=n?.timeoutMs??Ht,i=n?.maxAttempts??qt,a=n?.backoffMs??jt,s=!!(t.payload.screenshots?.element?.dataUrl||t.payload.screenshots?.fullPage?.dataUrl),c=!!t.payload.video?.blob,d=s||c,{lean:y,extracted:p,extractedVideo:l}=d?Kt(t.payload):{lean:t.payload,extracted:{},extractedVideo:{}},w={...p,...t.screenshotDataUrls};for(let u=1;u<=i;u+=1){let g=new AbortController,h=setTimeout(()=>g.abort(),r),f=()=>g.abort();e&&e.addEventListener("abort",f,{once:true});try{let A=await fetch(ye,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(y),signal:g.signal});if(A.ok){Qe=Date.now();let S;try{S=await A.json();}catch{}if((w.element||w.fullPage)&&S){let C=S.upload_urls;if(C){let H=[];w.element&&C.element&&H.push(Ye(C.element,w.element,e)),w.fullPage&&C.fullPage&&H.push(Ye(C.fullPage,w.fullPage,e));try{await Promise.all(H);}catch{}}else if(S.feedback_id)try{await Qt({feedbackId:S.feedback_id,extracted:w,screenshots:t.payload.screenshots,...e?{signal:e}:{}});}catch{}}if(l.blob&&S){let C=S.upload_urls;if(C?.video)try{await fetch(C.video,{method:"PUT",body:l.blob,headers:{"content-type":l.blob.type},...e?{signal:e}:{}});}catch{}else if(S.feedback_id)try{await Gt({feedbackId:S.feedback_id,blob:l.blob,...e?{signal:e}:{}});}catch{}}let B={ok:!0,status:A.status};return S&&(B.apiResponse=S),B}if(u<i&&Zt(A.status)){let S=.85+Math.random()*.3,F=Math.round(a*2**(u-1)*S);await Ge(F,e);continue}return {ok:!1,status:A.status,error:b("api_failed",new Error(`HTTP ${A.status}`))}}catch(A){if(g.signal.aborted||e?.aborted)return {ok:false,error:b("aborted",A)};if(u<i){let S=.85+Math.random()*.3,F=Math.round(a*2**(u-1)*S);await Ge(F,e);continue}return {ok:false,error:b("api_failed",A)}}finally{clearTimeout(h),e&&e.removeEventListener("abort",f);}}return {ok:false,error:b("api_failed",new Error("Failed"))}}async function et(t){let{blob:e,mime:n,blocfeedId:o,signal:r}=t,i=await fetch($t,{method:"POST",headers:{"Content-Type":n,"X-Blocfeed-Id":o},body:e,...r?{signal:r}:{}});if(!i.ok){let s=await i.json().catch(()=>({error:"Unknown error"}));throw b("api_failed",new Error(s?.error??`Voice API returned ${i.status}`))}let a=await i.json();return {text:a.text??"",warning:a.warning}}async function tt(t){let{blocfeedId:e,signal:n}=t;try{let o=await fetch(Xt,{method:"GET",headers:{"X-Blocfeed-Id":e},...n?{signal:n}:{}});return o.ok?{voice_feedback_enabled:!!(await o.json()).voice_feedback_enabled}:null}catch{return null}}function Ee(t){let e=null,n=null,o=(...r)=>{n=r,e===null&&(e=requestAnimationFrame(()=>{if(e=null,!n)return;let i=n;n=null,t(...i);}));};return o.cancel=()=>{e!==null&&cancelAnimationFrame(e),e=null,n=null;},o}function te(t){return t instanceof Element?!!t.closest("[data-blocfeed-ui]"):false}function ne(t){t.stopPropagation(),t.stopImmediatePropagation?.();}function nt(t,e){if(!v())throw new Error("BlocFeed picker can only run in a browser environment.");let n=t.ignoreSelectors,o=t.isSelectable,r={};n&&n.length>0&&(r.ignoreSelectors=n),o&&(r.isSelectable=o);let i=null,a=null,s=(u,g=false)=>{if(!u){i=null,a=null,e.onHover(null);return}let h=se(u.getBoundingClientRect()),f=`${Math.round(h.x)}:${Math.round(h.y)}:${Math.round(h.width)}:${Math.round(h.height)}`;!g&&u===i&&f===a||(i=u,a=f,e.onHover({element:u,rect:h}));},c=Ee(u=>{if(te(u.target))return;let g=document.elementFromPoint(u.clientX,u.clientY),h=ue(g,r);s(h);}),d=Ee(()=>{i&&s(i,true);}),y=u=>{te(u.target)||(ne(u),u.pointerType==="mouse"&&u.preventDefault());},p=u=>{te(u.target)||(ne(u),u.pointerType==="mouse"&&u.preventDefault());},l=u=>{if(te(u.target))return;ne(u),u.preventDefault();let g=document.elementFromPoint(u.clientX,u.clientY),h=ue(g,r);h&&e.onSelect({element:h,descriptor:Me(h)});},w=u=>{u.key==="Escape"&&(ne(u),u.preventDefault(),e.onCancel());};return window.addEventListener("pointermove",c,{capture:true,passive:true}),window.addEventListener("pointerdown",y,{capture:true}),window.addEventListener("pointerup",p,{capture:true}),window.addEventListener("click",l,{capture:true}),window.addEventListener("keydown",w,{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",y,{capture:true}),window.removeEventListener("pointerup",p,{capture:true}),window.removeEventListener("click",l,{capture:true}),window.removeEventListener("keydown",w,{capture:true}),window.removeEventListener("scroll",d,{capture:true}),window.removeEventListener("resize",d),c.cancel(),d.cancel(),e.onHover(null);}}}async function ve(t){let{signal:e,transport:n}=t,o={ok:false};try{let r={payload:t.payload,...e?{signal:e}:{},...n?{transport:n}:{}};o.api=await Je(r),o.ok=!!o.api?.ok;}catch(r){o.api={ok:false,error:b("api_failed",r)},o.ok=false;}return {payload:t.payload,result:o}}var Yt=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function Jt(t){let e=[...Yt,...t?.ignoreSelectors??[]],n=Array.from(new Set(e));return {...t,ignoreSelectors:n}}function ot(){return {phase:"idle"}}function en(t){if(t.ok)return false;let e=t.api;return e?e.status&&e.status>=400&&e.status<500||e.error?.kind==="aborted"||e.error?.kind==="configuration"?false:!e.ok:true}function ao(t){let e=t,n=ot(),o=new Set,r=new Set,i=null,a=null,s=null,c=null,d=0,y=null,p=null,l=null,w=null,u=false,g=()=>{for(let m of o)m(n);},h=m=>{for(let E of r)E(m);},f=m=>{n=m,g();},A=()=>{d+=1,c?.abort(),c=null;},S=()=>{i?.stop(),i=null,h(null),s!==null&&v()&&(document.documentElement.style.cursor=s,s=null);},F=()=>{p&&(p.abort(),p=null),l&&(URL.revokeObjectURL(l.blobUrl),l=null);},B=()=>{w&&(w.abort(),w=null);},C=()=>{A(),S(),F(),B(),a=null,f(ot());},H=()=>{if(!v())return;S(),a=null;let m=Jt(e.picker);s=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",f({phase:"picking"}),i=nt(m,{onHover:h,onSelect:({element:E,descriptor:x})=>{a=E,S(),f({phase:"review",selection:x});},onCancel:()=>{C();}});},Te=()=>{let m=He();if(m.length!==0)for(let E of m)ve({payload:E,...e.transport?{transport:e.transport}:{}}).catch(()=>{he(E);});};if(v()){setTimeout(Te,1e3);let m=()=>Te();window.addEventListener("online",m),y=()=>window.removeEventListener("online",m);}let at=()=>{if(u)return;let m=e.blocfeed_id?.trim?.()??"";m&&(u=true,tt({blocfeedId:m}).then(E=>{E&&(E.voice_feedback_enabled?e.voice?e.voice.enabled||(e={...e,voice:{...e.voice,enabled:true}}):e={...e,voice:{enabled:true}}:e.voice?.enabled&&(e={...e,voice:{...e.voice,enabled:false}}),g());}).catch(()=>{}));};return v()&&setTimeout(at,0),{getState:()=>n,getConfig:()=>e,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(){C();},clearSelection(){n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording"||H();},setConfig(m){e=m;},async submit(m,E){if(!v()){let _=b("configuration",new Error("BlocFeed submit can only run in the browser"));return f({phase:"error",lastError:_}),{ok:false}}let x=e.blocfeed_id?.trim?.()??"";if(!x){let M={phase:"error",lastError:b("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return n.selection&&(M.selection=n.selection),f(M),{ok:false}}if(n.phase==="capturing"||n.phase==="submitting"||n.phase==="recording")return {ok:false};let R=d+1;d=R,c?.abort(),c=new AbortController;let T=c.signal,k=n.selection,I=E?.capture?{...e.capture,...E.capture}:e.capture,L=!!(I?.element||I?.fullPage),j={phase:L?"capturing":"submitting"};k&&(j.selection=k),f(j);try{let _=L?await Ue({selectionElement:a,capture:I,signal:T}):void 0;if(T.aborted||d!==R)return {ok:!1};let M={phase:"submitting"};k&&(M.selection=k),_&&(M.capture=_),f(M);let D={};k&&(D.selection=k),_&&(D.capture=_);let z=await Ve({config:e.metadata,context:D,...e.user?{user:e.user}:{}}),O={version:1,createdAt:new Date().toISOString(),blocfeed_id:x,message:m,metadata:z};E?.category&&(O.category=E.category),e.user&&(O.user=e.user),k&&(O.selection=k),_&&(O.screenshots=_),l&&(O.video=l);let{result:N}=await ve({payload:O,signal:T,...e.transport?{transport:e.transport}:{}});if(T.aborted||d!==R)return N;if(N.ok){l&&(URL.revokeObjectURL(l.blobUrl),l=null);let ae={phase:"success",lastSubmit:N};return k&&(ae.selection=k),_&&(ae.capture=_),f(ae),N}en(N)&&he(O);let st=N.api?.error??b("unknown",new Error("Submission failed")),ie={phase:"error",lastSubmit:N,lastError:st};return k&&(ie.selection=k),_&&(ie.capture=_),f(ie),N}catch(_){if(T.aborted||d!==R)return {ok:false};let D={phase:"error",lastError:T.aborted?b("aborted",_):b("unknown",_)};return k&&(D.selection=k),f(D),{ok:false}}finally{d===R&&(c=null);}},async startRecording(){if(n.phase!=="review"||!e.recording?.enabled)return;let m=n.selection,E={phase:"recording",recordingElapsedMs:0};m&&(E.selection=m),f(E);try{let x={config:e.recording};c&&(x.signal=c.signal);let R=await be(x);p=R,R.onTick(I=>{if(n.phase==="recording"){let L={phase:"recording",recordingElapsedMs:I};m&&(L.selection=m),f(L);}});let T=await R.result;p=null,l=T;let k={phase:"review",video:T};m&&(k.selection=m),f(k);}catch(x){p=null;let T={phase:"review",lastError:x?.kind?x:b("recording_failed",x)};m&&(T.selection=m),f(T);}},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),f(E);},async startVoice(){if(n.phase!=="review"){console.warn("[BlocFeed] startVoice: ignored \u2014 phase is",n.phase,'(expected "review")');return}let m=e.voice;if(!m?.enabled){console.warn("[BlocFeed] startVoice: ignored \u2014 voice is not enabled in config");return}B();let E=n.selection,x={phase:"review",voiceRecording:true,voiceElapsedMs:0};E&&(x.selection=E),l&&(x.video=l),f(x);try{let R={config:m};c&&(R.signal=c.signal);let T=await we(R);w=T,T.onTick(D=>{let z={phase:"review",voiceRecording:!0,voiceElapsedMs:D};E&&(z.selection=E),l&&(z.video=l),f(z);});let k=await T.result;w=null;let I={phase:"review",voiceRecording:!1,voiceTranscribing:!0};E&&(I.selection=E),l&&(I.video=l),f(I);let L={blob:k.blob,mime:k.mime,blocfeedId:e.blocfeed_id};c&&(L.signal=c.signal);let{text:Ae,warning:j}=await et(L),_={phase:"review",voiceRecording:!1,voiceTranscribing:!1};E&&(_.selection=E),l&&(_.video=l),f(_);let M={text:Ae};return j&&(M.warning=j),M}catch(R){B();let T=R?.kind?R:b("recording_failed",R);console.warn("[BlocFeed] Voice error:",T.message);let k={phase:"review",voiceRecording:false,voiceTranscribing:false,lastError:T};E&&(k.selection=E),l&&(k.video=l),f(k);return}},stopVoice(){w&&w.stop();},__unsafeGetSelectedElement(){return a},destroy(){C(),o.clear(),r.clear(),y?.(),y=null;}}}var Z=[],W=[],rt=20,it=15,oe=[],K={},Q=null,G=null,Y=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(t){if(t instanceof Error)return t.message;if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}function on(t,e){let n=e.map(nn).join(" "),o=e.find(i=>i instanceof Error),r={level:t,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(t){let e=t.url.toLowerCase();for(let n of oe)if(e.includes(n))return;for(W.push(t);W.length>it;)W.shift();}function lo(t={}){if(re||!v())return;re=true,rt=t.consoleLimit??20,it=t.networkLimit??15;let e=t.ignoreUrls;if(e!==void 0?oe=e.map(n=>n.toLowerCase()):oe=[...tn],t.console!==false){let n=t.consoleLevels??["error","warn"];for(let o of n)K[o]=console[o],console[o]=(...r)=>{on(o,r),K[o]?.apply(console,r);};}if(t.network!==false&&typeof window.fetch=="function"){Q=window.fetch;let n=Q;window.fetch=async function(r,i){let a=typeof r=="string"?r:r instanceof URL?r.toString():r.url,s=(i?.method??"GET").toUpperCase(),c=Date.now();try{let d=await n.call(window,r,i);return d.ok||Se({url:a.slice(0,500),method:s,status:d.status,statusText:d.statusText,timestamp:c,durationMs:Date.now()-c}),d}catch(d){throw Se({url:a.slice(0,500),method:s,status:0,statusText:d instanceof Error?d.message:"Network error",timestamp:c,durationMs:Date.now()-c}),d}};}if(t.network!==false&&typeof XMLHttpRequest<"u"){G=XMLHttpRequest.prototype.open,Y=XMLHttpRequest.prototype.send;let n=G,o=Y;XMLHttpRequest.prototype.open=function(r,i,...a){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(i),n.apply(this,[r,i,...a])},XMLHttpRequest.prototype.send=function(...r){let i=this.__bf_method||"GET",a=this.__bf_url||"",s=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let c={url:a.slice(0,500),method:i,status:this.status,timestamp:s,durationMs:Date.now()-s};this.statusText&&(c.statusText=this.statusText),Se(c);}}),o.apply(this,r)};}}function uo(){if(re){for(let[t,e]of Object.entries(K))console[t]=e;for(let t of Object.keys(K))delete K[t];Q&&(window.fetch=Q,Q=null),G&&(XMLHttpRequest.prototype.open=G,G=null),Y&&(XMLHttpRequest.prototype.send=Y,Y=null),oe=[],re=false;}}function fo(){return {consoleLogs:[...Z],networkErrors:[...W]}}function mo(){Z=[],W=[];}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,}/}],V=[],_e=0,ke=false;function an(t){let e=t.slice(0,80);return e.length<=6?"***":e.slice(0,6)+"***"}function sn(t,e,n,o){if(V.some(a=>a.rule===t&&a.source===e))return;let i={rule:t,source:e,hint:an(n),timestamp:Date.now()};o&&(i.location=o),V.push(i);}function J(t,e,n,o){for(let{name:r,pattern:i}of n){let a=i.exec(t);a&&sn(r,e,a[0],o);}}function cn(t){try{let e=window;if(e.__NEXT_DATA__){let n=JSON.stringify(e.__NEXT_DATA__);J(n,"hydration",t,"__NEXT_DATA__");}if(e.__NUXT__){let n=JSON.stringify(e.__NUXT__);J(n,"hydration",t,"__NUXT__");}}catch{}}function ln(t){try{document.querySelectorAll("script:not([src])").forEach((n,o)=>{let r=n.textContent;r&&r.length>0&&J(r,"scripts",t,`inline-script[${o}]`);});}catch{}}function dn(t){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",t,r?`meta[${r}]`:void 0);});}catch{}}function un(t){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",t,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function ho(t={}){if(ke||!v()||(ke=true,t.secretScan===false))return;let e=[...rn,...t.customPatterns??[]],n=t.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{_e=Date.now(),n.includes("hydration")&&cn(e),n.includes("scripts")&&ln(e),n.includes("meta")&&dn(e),n.includes("dom")&&un(e);let o=t.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 bo(){return {findings:[...V],scannedAt:_e}}function wo(){V=[],_e=0,ke=false;}
|
|
2
|
-
export{v as a,se as b,Le as c,Ue as d,Ve as e,he as f,He as g,_n as h,Tn as i,Pt as j,Ct as k,Dt as l,be as m,Vt as n,we as o,et as p,tt as q,ao as r,lo as s,uo as t,fo as u,mo as v,ho as w,bo as x,wo as y};
|