blocfeed 0.7.0 → 0.7.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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.1 — 2026-02-21
4
+
5
+ ### New features
6
+
7
+ - **Client-side secret leak scanner** — `config.security` detects accidentally exposed API keys, database credentials, and tokens in client-side code. Scans Next.js `__NEXT_DATA__`, Nuxt `__NUXT__`, inline scripts, meta tags, and DOM attributes. Supports 20+ known patterns including:
8
+ - **Supabase / Postgres**: `SUPABASE_SERVICE_ROLE_KEY`, `POSTGRES_PASSWORD`, `DATABASE_URL` with embedded credentials
9
+ - **AWS**: Access keys (`AKIA...`), secret keys, session tokens
10
+ - **Stripe**: Secret keys (`sk_live_...`, `sk_test_...`), restricted keys
11
+ - **GitHub**: PATs, OAuth tokens, fine-grained tokens
12
+ - **OpenAI / Anthropic**: API keys
13
+ - **Infrastructure**: Private keys, database URLs with credentials, SendGrid, Twilio
14
+ - **Generic**: Any env var ending in `_SECRET`, `_PASSWORD`, `_PRIVATE_KEY`
15
+ - **Custom patterns**: `config.security.customPatterns` for app-specific secret formats
16
+ - **Security warning banner**: Visual alert when secrets are detected, dismissible by user
17
+ - **Redacted findings**: Secret values are never transmitted — only the first 6 characters + `***`
18
+ - **Dashboard reporting**: Findings attached as `metadata._securityFindings` in every feedback submission
19
+
20
+ ### Improvements
21
+
22
+ - New types exported: `SecurityConfig`, `SecurityFinding`, `SecuritySnapshot`.
23
+ - Engine exports: `runSecretScan`, `getSecurityFindings`, `clearSecurityFindings` for headless usage.
24
+ - 14 new tests for secret scanning (80 total).
25
+
26
+ ---
27
+
3
28
  ## 0.7.0 — 2026-02-20
4
29
 
5
30
  ### New features
package/README.md CHANGED
@@ -15,6 +15,7 @@ Drop-in in-app feedback widget for **Next.js** and **React**:
15
15
  - **Dark / Light mode** — `"dark"`, `"light"`, or `"auto"` (follows system preference)
16
16
  - **Conditional display** — show/hide widget by route pattern or custom predicate
17
17
  - **Programmatic API** — `ref.open()`, `ref.close()`, `ref.submit(msg)` via React ref
18
+ - **Secret leak detection** — scans client-side code for exposed API keys, database credentials, and tokens
18
19
 
19
20
  Docs live in `docs/` (start at `docs/index.md`). Architecture pointers are in `ARCHITECTURE.md`.
20
21
 
@@ -148,6 +149,12 @@ All configuration is passed via the `config` prop on `<BlocFeedWidget>` or `<Blo
148
149
  backoffMs: 500, // base backoff delay
149
150
  },
150
151
 
152
+ // Security — secret leak detection
153
+ security: {
154
+ secretScan: true,
155
+ scanTargets: ["hydration", "scripts", "meta", "dom"],
156
+ },
157
+
151
158
  // Metadata enrichment
152
159
  metadata: {
153
160
  enabled: true,
@@ -407,6 +414,74 @@ import {
407
414
  } from "blocfeed/engine";
408
415
  ```
409
416
 
417
+ ## Security — Client-Side Secret Leak Detection
418
+
419
+ Detect accidentally exposed API keys, database credentials, and tokens in client-side code:
420
+
421
+ ```tsx
422
+ <BlocFeedWidget
423
+ blocfeed_id="bf_..."
424
+ config={{
425
+ security: {
426
+ secretScan: true, // enable scanning (default when security config is present)
427
+ scanTargets: ["hydration", "scripts", "meta", "dom"], // what to scan
428
+ },
429
+ }}
430
+ />
431
+ ```
432
+
433
+ When secrets are detected, a dismissible warning banner appears in the widget, and findings are attached as `metadata._securityFindings` in every feedback submission. Secret values are **never transmitted** — only the first 6 characters + `***`.
434
+
435
+ ### What gets scanned
436
+
437
+ | Target | What | Why |
438
+ |--------|------|-----|
439
+ | `hydration` | `__NEXT_DATA__`, `__NUXT__` | Server-side props leaked to client |
440
+ | `scripts` | Inline `<script>` tags | Hardcoded secrets in JavaScript |
441
+ | `meta` | `<meta>` tag `content` attributes | Tokens in meta tags |
442
+ | `dom` | `data-api-key`, `data-secret`, etc. | Keys in HTML attributes |
443
+
444
+ ### Built-in patterns (20+)
445
+
446
+ - **Supabase / Postgres**: `SUPABASE_SERVICE_ROLE_KEY`, `POSTGRES_PASSWORD`, `DATABASE_URL` with embedded credentials
447
+ - **AWS**: Access keys (`AKIA...`), secret keys, session tokens
448
+ - **Stripe**: Secret keys (`sk_live_...`, `sk_test_...`), restricted keys
449
+ - **GitHub**: PATs (`ghp_`), OAuth tokens (`gho_`), fine-grained tokens (`github_pat_`)
450
+ - **OpenAI / Anthropic**: API keys
451
+ - **Infrastructure**: Private keys, database URLs with credentials, SendGrid, Twilio
452
+ - **Generic**: Any env var ending in `_SECRET`, `_PASSWORD`, `_PRIVATE_KEY`
453
+
454
+ > **Note**: Known-public keys like `SUPABASE_ANON_KEY` and `SUPABASE_URL` are intentionally **not** flagged.
455
+
456
+ ### Custom patterns
457
+
458
+ Add app-specific secret formats:
459
+
460
+ ```tsx
461
+ config={{
462
+ security: {
463
+ customPatterns: [
464
+ { name: "internal_api_key", pattern: /myapp_sk_[a-zA-Z0-9]{32}/ },
465
+ ],
466
+ },
467
+ }}
468
+ ```
469
+
470
+ ### Headless secret scanning
471
+
472
+ ```ts
473
+ import {
474
+ runSecretScan,
475
+ getSecurityFindings,
476
+ clearSecurityFindings,
477
+ } from "blocfeed/engine";
478
+
479
+ runSecretScan({ secretScan: true });
480
+ // ... after scan completes (~100ms)
481
+ const snapshot = getSecurityFindings();
482
+ console.log(snapshot.findings);
483
+ ```
484
+
410
485
  ## Theme Customization
411
486
 
412
487
  Override the widget's visual appearance via CSS variables:
@@ -618,6 +693,9 @@ import type {
618
693
  TransportConfig,
619
694
  TriggerStyle,
620
695
  WidgetPosition,
696
+ SecurityConfig,
697
+ SecurityFinding,
698
+ SecuritySnapshot,
621
699
  // ... and more
622
700
  } from "blocfeed";
623
701
  ```
@@ -0,0 +1,2 @@
1
+ 'use strict';function w(){return typeof window<"u"&&typeof document<"u"}function ue(e){let t=globalThis.CSS;return typeof t?.escape=="function"?t.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>{let r=n.codePointAt(0);return r===void 0?"":`\\${r.toString(16)} `})}function Y(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Be(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function De(e){return e.replace(/\s+/g," ").trim()}function Oe(e,t=140){let n=e.textContent;if(!n)return;let r=De(n);if(r)return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function Ue(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var pe=["data-testid","data-test-id","data-test","data-qa","data-cy"],de="data-blocfeed-component";function He(e){let t=e.closest(`[${de}]`);if(!t)return;let r=t.getAttribute(de)?.trim();return r||void 0}function qe(e){for(let t of pe){let n=e.closest(`[${t}]`);if(!n)continue;let o=n.getAttribute(t)?.trim();if(o)return o}}function fe(e){try{let t=e,n=Object.getOwnPropertyNames(t);for(let r of n)if(r.startsWith("__reactFiber$")||r.startsWith("__reactInternalInstance$")){let o=t[r];if(o&&typeof o=="object")return o}}catch{}return null}function T(e){if(e.length<=1||e.length===2&&e[0]===e[0].toLowerCase())return true;let t=e[0];return t>="a"&&t<="z"}function I(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!T(t.name))return t.name}}function k(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 r=t.render;if(typeof r=="function"){let i=r;if(typeof i.displayName=="string"&&i.displayName)return i.displayName;if(typeof i.name=="string"&&i.name)return i.name}let o=t.type;return k(o)}}}function $e(e){let t=fe(e);if(!t)return;let n=I(t._debugInfo);if(n)return n;let r=t._debugOwner!==void 0;if(r){let a=t._debugOwner;for(let l=0;a&&l<50;l+=1){let d=I(a._debugInfo);if(d)return d;let g=k(a.type)??k(a.elementType);if(g&&!T(g))return g;a=a._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let a=t._owner;for(let l=0;a&&l<50;l+=1){let d=I(a._debugInfo);if(d)return d;let g=k(a.type)??k(a.elementType);if(g&&!T(g))return g;a=a._owner;}}let i=t,s=r?80:25;for(let a=0;i&&a<s;a+=1){let l=I(i._debugInfo);if(l)return l;let d=k(i.type)??k(i.elementType);if(d&&!T(d))return d;i=i.return;}let c=e.parentElement;for(let a=0;c&&a<15;a+=1){let l=fe(c);if(l){let d=I(l._debugInfo);if(d)return d;let g=k(l.type)??k(l.elementType);if(g&&!T(g))return g;if(l._debugOwner){let h=k(l._debugOwner.type)??k(l._debugOwner.elementType);if(h&&!T(h))return h}if(l._owner&&l._owner!==l._debugOwner){let h=k(l._owner.type)??k(l._owner.elementType);if(h&&!T(h))return h}}c=c.parentElement;}}function ze(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${ue(n)}`;for(let r of pe){let o=e.getAttribute(r);if(o)return `${t}[${r}="${ue(o)}"]`}return `${t}:nth-of-type(${Ue(e)})`}function Xe(e,t=10){let n=[],r=e;for(;r&&n.length<t;){let o=ze(r);if(n.unshift(o),o.startsWith("#"))break;r=r.parentElement;}return n.join(" > ")}function me(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function J(e,t){if(!e||me(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(me(n,t.ignoreSelectors))return null;if(t.isSelectable?.(n)??Ze(n))return n;n=n.parentElement;}return null}function Ze(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function ge(e){let t=e.getBoundingClientRect(),n={selector:Xe(e),tagName:e.tagName.toLowerCase(),rect:Y(t),pageRect:Be(t)},r=e.getAttribute("id");r&&(n.id=r);let o=e.className;typeof o=="string"&&o.trim()&&(n.className=o);let i=Oe(e);i&&(n.textSnippet=i);let s=He(e)??$e(e);s&&(n.componentName=s);let c=qe(e);return c&&(n.testId=c),n}var G=null;async function he(){return G||(G=import('html-to-image')),G}async function je(e){return await new Promise((t,n)=>{let r=new Image;r.onload=()=>t({width:r.naturalWidth,height:r.naturalHeight}),r.onerror=()=>n(new Error("Failed to load generated screenshot")),r.src=e;})}async function we(e,t){let{width:n,height:r}=await je(e);return {dataUrl:e,mime:t,width:n,height:r}}function L(e){if(e?.aborted)throw new Error("Aborted")}function ye(){return {async captureElement(e,t){if(!w())throw new Error("captureElement can only run in the browser");L(t.signal);let n=await he();L(t.signal);let r=t.mime==="image/jpeg"?await n.toJpeg(e,{quality:t.quality??.92,pixelRatio:t.pixelRatio}):await n.toPng(e,{pixelRatio:t.pixelRatio});return L(t.signal),await we(r,t.mime)},async captureFullPage(e){if(!w())throw new Error("captureFullPage can only run in the browser");L(e.signal);let t=document.documentElement,n=Math.max(t.scrollWidth,t.clientWidth),r=Math.max(t.scrollHeight,t.clientHeight),o=Math.min(1,e.maxDimension/Math.max(n,r)),i=Math.max(1,Math.round(n*o)),s=Math.max(1,Math.round(r*o)),c=await he();L(e.signal);let a=e.mime==="image/jpeg"?await c.toJpeg(t,{width:i,height:s,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await c.toPng(t,{width:i,height:s,pixelRatio:e.pixelRatio});return L(e.signal),await we(a,e.mime)}}}function We(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function y(e,t,n){let r={kind:e,message:We(t)};return n&&(r.detail=n),r}var Ke=12e3,Qe=2048,Ye=.92;function be(){return Date.now()}function Je(e){return new Promise((t,n)=>{let r=()=>n(new Error("Aborted"));if(e.aborted){r();return}e.addEventListener("abort",r,{once:true});})}async function Ee(e,t,n){let r=new Promise((i,s)=>{let c=setTimeout(()=>s(new Error("Timeout")),t);typeof c.unref=="function"&&c.unref();}),o=[e,r];return n&&o.push(Je(n)),await Promise.race(o)}function Ge(e){if(!w())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function Ve(e){return !!(e?.element||e?.fullPage)}function _e(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 Se(e){let{selectionElement:t,capture:n,signal:r}=e;if(!w()||!Ve(n))return;let o=be(),i=[],s=n?.timeoutMs??Ke,c=n?.maxDimension??Qe,a=n?.mime??"image/png",l=n?.quality??Ye,d=n?.adapter??ye(),g={},h=Ge(n);if(n?.element&&t)try{let f=t.getBoundingClientRect(),m=Math.min(1,c/Math.max(f.width,f.height)),v=Math.min(h,h*m),A=await Ee(Promise.resolve(d.captureElement(t,{..._e({mime:a,quality:l,pixelRatio:v,maxDimension:c,includeQuality:a==="image/jpeg",...r?{signal:r}:{}})})),s,r);g.element=A;}catch(f){if(r?.aborted)throw f;i.push(y("capture_failed",f,{target:"element"}));}if(n?.fullPage)try{let f=await Ee(Promise.resolve(d.captureFullPage(_e({mime:a,quality:l,pixelRatio:h,maxDimension:c,includeQuality:a==="image/jpeg",...r?{signal:r}:{}}))),s,r);g.fullPage=f;}catch(f){if(r?.aborted)throw f;i.push(y("capture_failed",f,{target:"fullPage"}));}let b=be(),u={startedAt:o,finishedAt:b,durationMs:Math.max(0,b-o)};return i.length>0&&(u.errors=i),{...g,diagnostics:u}}function et(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function tt(){return w()?{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 nt(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 ke(e){let{config:t,context:n,user:r}=e;if(t?.enabled===false)return {};let o={...tt(),...nt(r)},i=t?.enrich;if(!i)return o;try{let s=await i(n);return {...o,...s}}catch(s){let c=y("unknown",s);return {...o,blocfeedMetadataError:c.message}}}var V="blocfeed-queue",rt=50;function ee(){if(!w())return [];try{let e=localStorage.getItem(V);if(!e)return [];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return []}}function te(e){if(w())try{e.length===0?localStorage.removeItem(V):localStorage.setItem(V,JSON.stringify(e));}catch{}}function ot(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 t}function ne(e){let t=ee(),n=ot(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>rt;)t.shift();te(t);}function ve(){let e=ee();return e.length===0?[]:(te([]),e.map(t=>t.payload))}function Ot(){te([]);}function Ut(){return ee().length}function re(e){let t=null,n=null,r=(...o)=>{n=o,t===null&&(t=requestAnimationFrame(()=>{if(t=null,!n)return;let i=n;n=null,e(...i);}));};return r.cancel=()=>{t!==null&&cancelAnimationFrame(t),t=null,n=null;},r}function X(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function Z(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function Pe(e,t){if(!w())throw new Error("BlocFeed picker can only run in a browser environment.");let n=e.ignoreSelectors,r=e.isSelectable,o={};n&&n.length>0&&(o.ignoreSelectors=n),r&&(o.isSelectable=r);let i=null,s=null,c=(u,f=false)=>{if(!u){i=null,s=null,t.onHover(null);return}let m=Y(u.getBoundingClientRect()),v=`${Math.round(m.x)}:${Math.round(m.y)}:${Math.round(m.width)}:${Math.round(m.height)}`;!f&&u===i&&v===s||(i=u,s=v,t.onHover({element:u,rect:m}));},a=re(u=>{if(X(u.target))return;let f=document.elementFromPoint(u.clientX,u.clientY),m=J(f,o);c(m);}),l=re(()=>{i&&c(i,true);}),d=u=>{X(u.target)||(Z(u),u.pointerType==="mouse"&&u.preventDefault());},g=u=>{X(u.target)||(Z(u),u.pointerType==="mouse"&&u.preventDefault());},h=u=>{if(X(u.target))return;Z(u),u.preventDefault();let f=document.elementFromPoint(u.clientX,u.clientY),m=J(f,o);m&&t.onSelect({element:m,descriptor:ge(m)});},b=u=>{u.key==="Escape"&&(Z(u),u.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",a,{capture:true,passive:true}),window.addEventListener("pointerdown",d,{capture:true}),window.addEventListener("pointerup",g,{capture:true}),window.addEventListener("click",h,{capture:true}),window.addEventListener("keydown",b,{capture:true}),window.addEventListener("scroll",l,{capture:true,passive:true}),window.addEventListener("resize",l,{passive:true}),{stop(){window.removeEventListener("pointermove",a,{capture:true}),window.removeEventListener("pointerdown",d,{capture:true}),window.removeEventListener("pointerup",g,{capture:true}),window.removeEventListener("click",h,{capture:true}),window.removeEventListener("keydown",b,{capture:true}),window.removeEventListener("scroll",l,{capture:true}),window.removeEventListener("resize",l),a.cancel(),l.cancel(),t.onHover(null);}}}var it=12e3,at=2,st=500,ct=2e3,Re="https://blocfeed.com/api/feedback",Ae=0;function xe(e,t){return new Promise((n,r)=>{if(t?.aborted){r(new Error("Aborted"));return}let o=setTimeout(n,e),i=()=>{clearTimeout(o),r(new Error("Aborted"));};t?.addEventListener("abort",i,{once:true});})}function lt(e){return e>=500&&e<=599}function ut(e){let[t,n]=e.split(",",2);if(!t||!n)throw new Error("Invalid data URL");let o=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(n),s=new Uint8Array(i.length);for(let c=0;c<i.length;c+=1)s[c]=i.charCodeAt(c);return new Blob([s],{type:o})}function dt(e){let t={},n={...e};if(n.screenshots){let r={},o={...n.screenshots};o.element&&(t.element=o.element.dataUrl,r.element={mime:o.element.mime,width:o.element.width,height:o.element.height},o.element={...o.element,dataUrl:""}),o.fullPage&&(t.fullPage=o.fullPage.dataUrl,r.fullPage={mime:o.fullPage.mime,width:o.fullPage.width,height:o.fullPage.height},o.fullPage={...o.fullPage,dataUrl:""}),n.screenshots=o,(r.element||r.fullPage)&&(n.screenshot_intent=r);}return {lean:n,extracted:t}}async function Te(e,t,n){let r=ut(t);await fetch(e,{method:"PUT",body:r,headers:{"content-type":r.type},...n?{signal:n}:{}});}async function ft(e){let{feedbackId:t,extracted:n,screenshots:r,signal:o}=e,i={};n.element&&r?.element&&(i.element={dataUrl:n.element,mime:r.element.mime,width:r.element.width,height:r.element.height}),n.fullPage&&r?.fullPage&&(i.fullPage={dataUrl:n.fullPage,mime:r.fullPage.mime,width:r.fullPage.width,height:r.fullPage.height}),Object.keys(i).length!==0&&await fetch(`${Re}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...o?{signal:o}:{}});}async function Fe(e){let{signal:t,transport:n}=e;if(Date.now()-Ae<ct)return {ok:false,error:y("configuration",new Error("Please wait before submitting again"))};let o=n?.timeoutMs??it,i=n?.maxAttempts??at,s=n?.backoffMs??st,c=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),{lean:a,extracted:l}=c?dt(e.payload):{lean:e.payload,extracted:{}},d={...l,...e.screenshotDataUrls};for(let g=1;g<=i;g+=1){let h=new AbortController,b=setTimeout(()=>h.abort(),o),u=()=>h.abort();t&&t.addEventListener("abort",u,{once:true});try{let f=await fetch(Re,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(a),signal:h.signal});if(f.ok){Ae=Date.now();let m;try{m=await f.json();}catch{}if((d.element||d.fullPage)&&m){let p=m.upload_urls;if(p){let _=[];d.element&&p.element&&_.push(Te(p.element,d.element,t)),d.fullPage&&p.fullPage&&_.push(Te(p.fullPage,d.fullPage,t));try{await Promise.all(_);}catch{}}else if(m.feedback_id)try{await ft({feedbackId:m.feedback_id,extracted:d,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}let A={ok:!0,status:f.status};return m&&(A.apiResponse=m),A}if(g<i&&lt(f.status)){let m=.85+Math.random()*.3,v=Math.round(s*2**(g-1)*m);await xe(v,t);continue}return {ok:!1,status:f.status,error:y("api_failed",new Error(`HTTP ${f.status}`))}}catch(f){if(h.signal.aborted||t?.aborted)return {ok:false,error:y("aborted",f)};if(g<i){let m=.85+Math.random()*.3,v=Math.round(s*2**(g-1)*m);await xe(v,t);continue}return {ok:false,error:y("api_failed",f)}}finally{clearTimeout(b),t&&t.removeEventListener("abort",u);}}return {ok:false,error:y("api_failed",new Error("Failed"))}}async function oe(e){let{signal:t,transport:n}=e,r={ok:false};try{let o={payload:e.payload,...t?{signal:t}:{},...n?{transport:n}:{}};r.api=await Fe(o),r.ok=!!r.api?.ok;}catch(o){r.api={ok:false,error:y("api_failed",o)},r.ok=false;}return {payload:e.payload,result:r}}var mt=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function pt(e){let t=[...mt,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function Ce(){return {phase:"idle"}}function gt(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 rn(e){let t=e,n=Ce(),r=new Set,o=new Set,i=null,s=null,c=null,a=null,l=0,d=null,g=()=>{for(let p of r)p(n);},h=p=>{for(let _ of o)_(p);},b=p=>{n=p,g();},u=()=>{l+=1,a?.abort(),a=null;},f=()=>{i?.stop(),i=null,h(null),c!==null&&w()&&(document.documentElement.style.cursor=c,c=null);},m=()=>{u(),f(),s=null,b(Ce());},v=()=>{if(!w())return;f(),s=null;let p=pt(t.picker);c=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",b({phase:"picking"}),i=Pe(p,{onHover:h,onSelect:({element:_,descriptor:z})=>{s=_,f(),b({phase:"review",selection:z});},onCancel:()=>{m();}});},A=()=>{let p=ve();if(p.length!==0)for(let _ of p)oe({payload:_,...t.transport?{transport:t.transport}:{}}).catch(()=>{ne(_);});};if(w()){setTimeout(A,1e3);let p=()=>A();window.addEventListener("online",p),d=()=>window.removeEventListener("online",p);}return {getState:()=>n,subscribe(p){return r.add(p),()=>r.delete(p)},subscribeHover(p){return o.add(p),()=>o.delete(p)},start(){n.phase==="capturing"||n.phase==="submitting"||n.phase!=="picking"&&v();},stop(){m();},clearSelection(){n.phase==="capturing"||n.phase==="submitting"||v();},setConfig(p){t=p;},async submit(p,_){if(!w()){let E=y("configuration",new Error("BlocFeed submit can only run in the browser"));return b({phase:"error",lastError:E}),{ok:false}}let z=t.blocfeed_id?.trim?.()??"";if(!z){let x={phase:"error",lastError:y("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return n.selection&&(x.selection=n.selection),b(x),{ok:false}}if(n.phase==="capturing"||n.phase==="submitting")return {ok:false};let N=l+1;l=N,a?.abort(),a=new AbortController;let F=a.signal,S=n.selection,W=_?.capture?{...t.capture,..._.capture}:t.capture,ce=!!(W?.element||W?.fullPage),le={phase:ce?"capturing":"submitting"};S&&(le.selection=S),b(le);try{let E=ce?await Se({selectionElement:s,capture:W,signal:F}):void 0;if(F.aborted||l!==N)return {ok:!1};let x={phase:"submitting"};S&&(x.selection=S),E&&(x.capture=E),b(x);let C={};S&&(C.selection=S),E&&(C.capture=E);let Ne=await ke({config:t.metadata,context:C,...t.user?{user:t.user}:{}}),M={version:1,createdAt:new Date().toISOString(),blocfeed_id:z,message:p,metadata:Ne};_?.category&&(M.category=_.category),t.user&&(M.user=t.user),S&&(M.selection=S),E&&(M.screenshots=E);let{result:P}=await oe({payload:M,signal:F,...t.transport?{transport:t.transport}:{}});if(F.aborted||l!==N)return P;if(P.ok){let Q={phase:"success",lastSubmit:P};return S&&(Q.selection=S),E&&(Q.capture=E),b(Q),P}gt(P)&&ne(M);let Ie=P.api?.error??y("unknown",new Error("Submission failed")),K={phase:"error",lastSubmit:P,lastError:Ie};return S&&(K.selection=S),E&&(K.capture=E),b(K),P}catch(E){if(F.aborted||l!==N)return {ok:false};let C={phase:"error",lastError:F.aborted?y("aborted",E):y("unknown",E)};return S&&(C.selection=S),b(C),{ok:false}}finally{l===N&&(a=null);}},__unsafeGetSelectedElement(){return s},destroy(){m(),r.clear(),o.clear(),d?.(),d=null;}}}var B=[],D=[],Me=20,Le=15,O={},U=null,H=null,q=null,j=false;function ht(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function wt(e,t){let n=t.map(ht).join(" "),r=t.find(i=>i instanceof Error),o={level:e,message:n.slice(0,2e3),timestamp:Date.now()};for(r?.stack&&(o.stack=r.stack.slice(0,2e3)),B.push(o);B.length>Me;)B.shift();}function ie(e){if(!e.url.includes("blocfeed.com"))for(D.push(e);D.length>Le;)D.shift();}function sn(e={}){if(!(j||!w())){if(j=true,Me=e.consoleLimit??20,Le=e.networkLimit??15,e.console!==false){let t=e.consoleLevels??["error","warn"];for(let n of t)O[n]=console[n],console[n]=(...r)=>{wt(n,r),O[n]?.apply(console,r);};}if(e.network!==false&&typeof window.fetch=="function"){U=window.fetch;let t=U;window.fetch=async function(r,o){let i=typeof r=="string"?r:r instanceof URL?r.toString():r.url,s=(o?.method??"GET").toUpperCase(),c=Date.now();try{let a=await t.call(window,r,o);return a.ok||ie({url:i.slice(0,500),method:s,status:a.status,statusText:a.statusText,timestamp:c,durationMs:Date.now()-c}),a}catch(a){throw ie({url:i.slice(0,500),method:s,status:0,statusText:a instanceof Error?a.message:"Network error",timestamp:c,durationMs:Date.now()-c}),a}};}if(e.network!==false&&typeof XMLHttpRequest<"u"){H=XMLHttpRequest.prototype.open,q=XMLHttpRequest.prototype.send;let t=H,n=q;XMLHttpRequest.prototype.open=function(r,o,...i){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(o),t.apply(this,[r,o,...i])},XMLHttpRequest.prototype.send=function(...r){let o=this.__bf_method||"GET",i=this.__bf_url||"",s=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let c={url:i.slice(0,500),method:o,status:this.status,timestamp:s,durationMs:Date.now()-s};this.statusText&&(c.statusText=this.statusText),ie(c);}}),n.apply(this,r)};}}}function cn(){if(j){for(let[e,t]of Object.entries(O))console[e]=t;for(let e of Object.keys(O))delete O[e];U&&(window.fetch=U,U=null),H&&(XMLHttpRequest.prototype.open=H,H=null),q&&(XMLHttpRequest.prototype.send=q,q=null),j=false;}}function ln(){return {consoleLogs:[...B],networkErrors:[...D]}}function un(){B=[],D=[];}var yt=[{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,}/}],R=[],se=0,ae=false;function bt(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function Et(e,t,n,r){if(R.some(s=>s.rule===e&&s.source===t))return;let i={rule:e,source:t,hint:bt(n),timestamp:Date.now()};r&&(i.location=r),R.push(i);}function $(e,t,n,r){for(let{name:o,pattern:i}of n){let s=i.exec(e);s&&Et(o,t,s[0],r);}}function _t(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);$(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);$(n,"hydration",e,"__NUXT__");}}catch{}}function St(e){try{document.querySelectorAll("script:not([src])").forEach((n,r)=>{let o=n.textContent;o&&o.length>0&&$(o,"scripts",e,`inline-script[${r}]`);});}catch{}}function kt(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let r=n.getAttribute("content"),o=n.getAttribute("name")||n.getAttribute("property")||"";r&&r.length>10&&$(r,"meta",e,o?`meta[${o}]`:void 0);});}catch{}}function vt(e){try{document.querySelectorAll("[data-api-key], [data-secret], [data-token], [data-password]").forEach(n=>{let r=n.attributes;for(let o=0;o<r.length;o++){let i=r[o];i.name.startsWith("data-")&&i.value.length>10&&$(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function mn(e={}){if(ae||!w()||(ae=true,e.secretScan===false))return;let t=[...yt,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{se=Date.now(),n.includes("hydration")&&_t(t),n.includes("scripts")&&St(t),n.includes("meta")&&kt(t),n.includes("dom")&&vt(t);let r=e.notify??"both";R.length>0&&(r==="console"||r==="both")&&console.warn(`[BlocFeed Security] Found ${R.length} potential secret(s) exposed in client code:`,R.map(o=>`${o.rule} (${o.source}${o.location?`: ${o.location}`:""})`));},100);}function pn(){return {findings:[...R],scannedAt:se}}function gn(){R=[],se=0,ae=false;}
2
+ exports.a=w;exports.b=Y;exports.c=ye;exports.d=Se;exports.e=ke;exports.f=ne;exports.g=ve;exports.h=Ot;exports.i=Ut;exports.j=rn;exports.k=sn;exports.l=cn;exports.m=ln;exports.n=un;exports.o=mn;exports.p=pn;exports.q=gn;
@@ -0,0 +1,2 @@
1
+ function w(){return typeof window<"u"&&typeof document<"u"}function ue(e){let t=globalThis.CSS;return typeof t?.escape=="function"?t.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>{let r=n.codePointAt(0);return r===void 0?"":`\\${r.toString(16)} `})}function Y(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Be(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function De(e){return e.replace(/\s+/g," ").trim()}function Oe(e,t=140){let n=e.textContent;if(!n)return;let r=De(n);if(r)return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function Ue(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var pe=["data-testid","data-test-id","data-test","data-qa","data-cy"],de="data-blocfeed-component";function He(e){let t=e.closest(`[${de}]`);if(!t)return;let r=t.getAttribute(de)?.trim();return r||void 0}function qe(e){for(let t of pe){let n=e.closest(`[${t}]`);if(!n)continue;let o=n.getAttribute(t)?.trim();if(o)return o}}function fe(e){try{let t=e,n=Object.getOwnPropertyNames(t);for(let r of n)if(r.startsWith("__reactFiber$")||r.startsWith("__reactInternalInstance$")){let o=t[r];if(o&&typeof o=="object")return o}}catch{}return null}function T(e){if(e.length<=1||e.length===2&&e[0]===e[0].toLowerCase())return true;let t=e[0];return t>="a"&&t<="z"}function I(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!T(t.name))return t.name}}function k(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 r=t.render;if(typeof r=="function"){let i=r;if(typeof i.displayName=="string"&&i.displayName)return i.displayName;if(typeof i.name=="string"&&i.name)return i.name}let o=t.type;return k(o)}}}function $e(e){let t=fe(e);if(!t)return;let n=I(t._debugInfo);if(n)return n;let r=t._debugOwner!==void 0;if(r){let a=t._debugOwner;for(let l=0;a&&l<50;l+=1){let d=I(a._debugInfo);if(d)return d;let g=k(a.type)??k(a.elementType);if(g&&!T(g))return g;a=a._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let a=t._owner;for(let l=0;a&&l<50;l+=1){let d=I(a._debugInfo);if(d)return d;let g=k(a.type)??k(a.elementType);if(g&&!T(g))return g;a=a._owner;}}let i=t,s=r?80:25;for(let a=0;i&&a<s;a+=1){let l=I(i._debugInfo);if(l)return l;let d=k(i.type)??k(i.elementType);if(d&&!T(d))return d;i=i.return;}let c=e.parentElement;for(let a=0;c&&a<15;a+=1){let l=fe(c);if(l){let d=I(l._debugInfo);if(d)return d;let g=k(l.type)??k(l.elementType);if(g&&!T(g))return g;if(l._debugOwner){let h=k(l._debugOwner.type)??k(l._debugOwner.elementType);if(h&&!T(h))return h}if(l._owner&&l._owner!==l._debugOwner){let h=k(l._owner.type)??k(l._owner.elementType);if(h&&!T(h))return h}}c=c.parentElement;}}function ze(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${ue(n)}`;for(let r of pe){let o=e.getAttribute(r);if(o)return `${t}[${r}="${ue(o)}"]`}return `${t}:nth-of-type(${Ue(e)})`}function Xe(e,t=10){let n=[],r=e;for(;r&&n.length<t;){let o=ze(r);if(n.unshift(o),o.startsWith("#"))break;r=r.parentElement;}return n.join(" > ")}function me(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function J(e,t){if(!e||me(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(me(n,t.ignoreSelectors))return null;if(t.isSelectable?.(n)??Ze(n))return n;n=n.parentElement;}return null}function Ze(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function ge(e){let t=e.getBoundingClientRect(),n={selector:Xe(e),tagName:e.tagName.toLowerCase(),rect:Y(t),pageRect:Be(t)},r=e.getAttribute("id");r&&(n.id=r);let o=e.className;typeof o=="string"&&o.trim()&&(n.className=o);let i=Oe(e);i&&(n.textSnippet=i);let s=He(e)??$e(e);s&&(n.componentName=s);let c=qe(e);return c&&(n.testId=c),n}var G=null;async function he(){return G||(G=import('html-to-image')),G}async function je(e){return await new Promise((t,n)=>{let r=new Image;r.onload=()=>t({width:r.naturalWidth,height:r.naturalHeight}),r.onerror=()=>n(new Error("Failed to load generated screenshot")),r.src=e;})}async function we(e,t){let{width:n,height:r}=await je(e);return {dataUrl:e,mime:t,width:n,height:r}}function L(e){if(e?.aborted)throw new Error("Aborted")}function ye(){return {async captureElement(e,t){if(!w())throw new Error("captureElement can only run in the browser");L(t.signal);let n=await he();L(t.signal);let r=t.mime==="image/jpeg"?await n.toJpeg(e,{quality:t.quality??.92,pixelRatio:t.pixelRatio}):await n.toPng(e,{pixelRatio:t.pixelRatio});return L(t.signal),await we(r,t.mime)},async captureFullPage(e){if(!w())throw new Error("captureFullPage can only run in the browser");L(e.signal);let t=document.documentElement,n=Math.max(t.scrollWidth,t.clientWidth),r=Math.max(t.scrollHeight,t.clientHeight),o=Math.min(1,e.maxDimension/Math.max(n,r)),i=Math.max(1,Math.round(n*o)),s=Math.max(1,Math.round(r*o)),c=await he();L(e.signal);let a=e.mime==="image/jpeg"?await c.toJpeg(t,{width:i,height:s,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await c.toPng(t,{width:i,height:s,pixelRatio:e.pixelRatio});return L(e.signal),await we(a,e.mime)}}}function We(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function y(e,t,n){let r={kind:e,message:We(t)};return n&&(r.detail=n),r}var Ke=12e3,Qe=2048,Ye=.92;function be(){return Date.now()}function Je(e){return new Promise((t,n)=>{let r=()=>n(new Error("Aborted"));if(e.aborted){r();return}e.addEventListener("abort",r,{once:true});})}async function Ee(e,t,n){let r=new Promise((i,s)=>{let c=setTimeout(()=>s(new Error("Timeout")),t);typeof c.unref=="function"&&c.unref();}),o=[e,r];return n&&o.push(Je(n)),await Promise.race(o)}function Ge(e){if(!w())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function Ve(e){return !!(e?.element||e?.fullPage)}function _e(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 Se(e){let{selectionElement:t,capture:n,signal:r}=e;if(!w()||!Ve(n))return;let o=be(),i=[],s=n?.timeoutMs??Ke,c=n?.maxDimension??Qe,a=n?.mime??"image/png",l=n?.quality??Ye,d=n?.adapter??ye(),g={},h=Ge(n);if(n?.element&&t)try{let f=t.getBoundingClientRect(),m=Math.min(1,c/Math.max(f.width,f.height)),v=Math.min(h,h*m),A=await Ee(Promise.resolve(d.captureElement(t,{..._e({mime:a,quality:l,pixelRatio:v,maxDimension:c,includeQuality:a==="image/jpeg",...r?{signal:r}:{}})})),s,r);g.element=A;}catch(f){if(r?.aborted)throw f;i.push(y("capture_failed",f,{target:"element"}));}if(n?.fullPage)try{let f=await Ee(Promise.resolve(d.captureFullPage(_e({mime:a,quality:l,pixelRatio:h,maxDimension:c,includeQuality:a==="image/jpeg",...r?{signal:r}:{}}))),s,r);g.fullPage=f;}catch(f){if(r?.aborted)throw f;i.push(y("capture_failed",f,{target:"fullPage"}));}let b=be(),u={startedAt:o,finishedAt:b,durationMs:Math.max(0,b-o)};return i.length>0&&(u.errors=i),{...g,diagnostics:u}}function et(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function tt(){return w()?{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 nt(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 ke(e){let{config:t,context:n,user:r}=e;if(t?.enabled===false)return {};let o={...tt(),...nt(r)},i=t?.enrich;if(!i)return o;try{let s=await i(n);return {...o,...s}}catch(s){let c=y("unknown",s);return {...o,blocfeedMetadataError:c.message}}}var V="blocfeed-queue",rt=50;function ee(){if(!w())return [];try{let e=localStorage.getItem(V);if(!e)return [];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return []}}function te(e){if(w())try{e.length===0?localStorage.removeItem(V):localStorage.setItem(V,JSON.stringify(e));}catch{}}function ot(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 t}function ne(e){let t=ee(),n=ot(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>rt;)t.shift();te(t);}function ve(){let e=ee();return e.length===0?[]:(te([]),e.map(t=>t.payload))}function Ot(){te([]);}function Ut(){return ee().length}function re(e){let t=null,n=null,r=(...o)=>{n=o,t===null&&(t=requestAnimationFrame(()=>{if(t=null,!n)return;let i=n;n=null,e(...i);}));};return r.cancel=()=>{t!==null&&cancelAnimationFrame(t),t=null,n=null;},r}function X(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function Z(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function Pe(e,t){if(!w())throw new Error("BlocFeed picker can only run in a browser environment.");let n=e.ignoreSelectors,r=e.isSelectable,o={};n&&n.length>0&&(o.ignoreSelectors=n),r&&(o.isSelectable=r);let i=null,s=null,c=(u,f=false)=>{if(!u){i=null,s=null,t.onHover(null);return}let m=Y(u.getBoundingClientRect()),v=`${Math.round(m.x)}:${Math.round(m.y)}:${Math.round(m.width)}:${Math.round(m.height)}`;!f&&u===i&&v===s||(i=u,s=v,t.onHover({element:u,rect:m}));},a=re(u=>{if(X(u.target))return;let f=document.elementFromPoint(u.clientX,u.clientY),m=J(f,o);c(m);}),l=re(()=>{i&&c(i,true);}),d=u=>{X(u.target)||(Z(u),u.pointerType==="mouse"&&u.preventDefault());},g=u=>{X(u.target)||(Z(u),u.pointerType==="mouse"&&u.preventDefault());},h=u=>{if(X(u.target))return;Z(u),u.preventDefault();let f=document.elementFromPoint(u.clientX,u.clientY),m=J(f,o);m&&t.onSelect({element:m,descriptor:ge(m)});},b=u=>{u.key==="Escape"&&(Z(u),u.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",a,{capture:true,passive:true}),window.addEventListener("pointerdown",d,{capture:true}),window.addEventListener("pointerup",g,{capture:true}),window.addEventListener("click",h,{capture:true}),window.addEventListener("keydown",b,{capture:true}),window.addEventListener("scroll",l,{capture:true,passive:true}),window.addEventListener("resize",l,{passive:true}),{stop(){window.removeEventListener("pointermove",a,{capture:true}),window.removeEventListener("pointerdown",d,{capture:true}),window.removeEventListener("pointerup",g,{capture:true}),window.removeEventListener("click",h,{capture:true}),window.removeEventListener("keydown",b,{capture:true}),window.removeEventListener("scroll",l,{capture:true}),window.removeEventListener("resize",l),a.cancel(),l.cancel(),t.onHover(null);}}}var it=12e3,at=2,st=500,ct=2e3,Re="https://blocfeed.com/api/feedback",Ae=0;function xe(e,t){return new Promise((n,r)=>{if(t?.aborted){r(new Error("Aborted"));return}let o=setTimeout(n,e),i=()=>{clearTimeout(o),r(new Error("Aborted"));};t?.addEventListener("abort",i,{once:true});})}function lt(e){return e>=500&&e<=599}function ut(e){let[t,n]=e.split(",",2);if(!t||!n)throw new Error("Invalid data URL");let o=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(n),s=new Uint8Array(i.length);for(let c=0;c<i.length;c+=1)s[c]=i.charCodeAt(c);return new Blob([s],{type:o})}function dt(e){let t={},n={...e};if(n.screenshots){let r={},o={...n.screenshots};o.element&&(t.element=o.element.dataUrl,r.element={mime:o.element.mime,width:o.element.width,height:o.element.height},o.element={...o.element,dataUrl:""}),o.fullPage&&(t.fullPage=o.fullPage.dataUrl,r.fullPage={mime:o.fullPage.mime,width:o.fullPage.width,height:o.fullPage.height},o.fullPage={...o.fullPage,dataUrl:""}),n.screenshots=o,(r.element||r.fullPage)&&(n.screenshot_intent=r);}return {lean:n,extracted:t}}async function Te(e,t,n){let r=ut(t);await fetch(e,{method:"PUT",body:r,headers:{"content-type":r.type},...n?{signal:n}:{}});}async function ft(e){let{feedbackId:t,extracted:n,screenshots:r,signal:o}=e,i={};n.element&&r?.element&&(i.element={dataUrl:n.element,mime:r.element.mime,width:r.element.width,height:r.element.height}),n.fullPage&&r?.fullPage&&(i.fullPage={dataUrl:n.fullPage,mime:r.fullPage.mime,width:r.fullPage.width,height:r.fullPage.height}),Object.keys(i).length!==0&&await fetch(`${Re}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...o?{signal:o}:{}});}async function Fe(e){let{signal:t,transport:n}=e;if(Date.now()-Ae<ct)return {ok:false,error:y("configuration",new Error("Please wait before submitting again"))};let o=n?.timeoutMs??it,i=n?.maxAttempts??at,s=n?.backoffMs??st,c=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),{lean:a,extracted:l}=c?dt(e.payload):{lean:e.payload,extracted:{}},d={...l,...e.screenshotDataUrls};for(let g=1;g<=i;g+=1){let h=new AbortController,b=setTimeout(()=>h.abort(),o),u=()=>h.abort();t&&t.addEventListener("abort",u,{once:true});try{let f=await fetch(Re,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(a),signal:h.signal});if(f.ok){Ae=Date.now();let m;try{m=await f.json();}catch{}if((d.element||d.fullPage)&&m){let p=m.upload_urls;if(p){let _=[];d.element&&p.element&&_.push(Te(p.element,d.element,t)),d.fullPage&&p.fullPage&&_.push(Te(p.fullPage,d.fullPage,t));try{await Promise.all(_);}catch{}}else if(m.feedback_id)try{await ft({feedbackId:m.feedback_id,extracted:d,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}let A={ok:!0,status:f.status};return m&&(A.apiResponse=m),A}if(g<i&&lt(f.status)){let m=.85+Math.random()*.3,v=Math.round(s*2**(g-1)*m);await xe(v,t);continue}return {ok:!1,status:f.status,error:y("api_failed",new Error(`HTTP ${f.status}`))}}catch(f){if(h.signal.aborted||t?.aborted)return {ok:false,error:y("aborted",f)};if(g<i){let m=.85+Math.random()*.3,v=Math.round(s*2**(g-1)*m);await xe(v,t);continue}return {ok:false,error:y("api_failed",f)}}finally{clearTimeout(b),t&&t.removeEventListener("abort",u);}}return {ok:false,error:y("api_failed",new Error("Failed"))}}async function oe(e){let{signal:t,transport:n}=e,r={ok:false};try{let o={payload:e.payload,...t?{signal:t}:{},...n?{transport:n}:{}};r.api=await Fe(o),r.ok=!!r.api?.ok;}catch(o){r.api={ok:false,error:y("api_failed",o)},r.ok=false;}return {payload:e.payload,result:r}}var mt=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function pt(e){let t=[...mt,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function Ce(){return {phase:"idle"}}function gt(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 rn(e){let t=e,n=Ce(),r=new Set,o=new Set,i=null,s=null,c=null,a=null,l=0,d=null,g=()=>{for(let p of r)p(n);},h=p=>{for(let _ of o)_(p);},b=p=>{n=p,g();},u=()=>{l+=1,a?.abort(),a=null;},f=()=>{i?.stop(),i=null,h(null),c!==null&&w()&&(document.documentElement.style.cursor=c,c=null);},m=()=>{u(),f(),s=null,b(Ce());},v=()=>{if(!w())return;f(),s=null;let p=pt(t.picker);c=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",b({phase:"picking"}),i=Pe(p,{onHover:h,onSelect:({element:_,descriptor:z})=>{s=_,f(),b({phase:"review",selection:z});},onCancel:()=>{m();}});},A=()=>{let p=ve();if(p.length!==0)for(let _ of p)oe({payload:_,...t.transport?{transport:t.transport}:{}}).catch(()=>{ne(_);});};if(w()){setTimeout(A,1e3);let p=()=>A();window.addEventListener("online",p),d=()=>window.removeEventListener("online",p);}return {getState:()=>n,subscribe(p){return r.add(p),()=>r.delete(p)},subscribeHover(p){return o.add(p),()=>o.delete(p)},start(){n.phase==="capturing"||n.phase==="submitting"||n.phase!=="picking"&&v();},stop(){m();},clearSelection(){n.phase==="capturing"||n.phase==="submitting"||v();},setConfig(p){t=p;},async submit(p,_){if(!w()){let E=y("configuration",new Error("BlocFeed submit can only run in the browser"));return b({phase:"error",lastError:E}),{ok:false}}let z=t.blocfeed_id?.trim?.()??"";if(!z){let x={phase:"error",lastError:y("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return n.selection&&(x.selection=n.selection),b(x),{ok:false}}if(n.phase==="capturing"||n.phase==="submitting")return {ok:false};let N=l+1;l=N,a?.abort(),a=new AbortController;let F=a.signal,S=n.selection,W=_?.capture?{...t.capture,..._.capture}:t.capture,ce=!!(W?.element||W?.fullPage),le={phase:ce?"capturing":"submitting"};S&&(le.selection=S),b(le);try{let E=ce?await Se({selectionElement:s,capture:W,signal:F}):void 0;if(F.aborted||l!==N)return {ok:!1};let x={phase:"submitting"};S&&(x.selection=S),E&&(x.capture=E),b(x);let C={};S&&(C.selection=S),E&&(C.capture=E);let Ne=await ke({config:t.metadata,context:C,...t.user?{user:t.user}:{}}),M={version:1,createdAt:new Date().toISOString(),blocfeed_id:z,message:p,metadata:Ne};_?.category&&(M.category=_.category),t.user&&(M.user=t.user),S&&(M.selection=S),E&&(M.screenshots=E);let{result:P}=await oe({payload:M,signal:F,...t.transport?{transport:t.transport}:{}});if(F.aborted||l!==N)return P;if(P.ok){let Q={phase:"success",lastSubmit:P};return S&&(Q.selection=S),E&&(Q.capture=E),b(Q),P}gt(P)&&ne(M);let Ie=P.api?.error??y("unknown",new Error("Submission failed")),K={phase:"error",lastSubmit:P,lastError:Ie};return S&&(K.selection=S),E&&(K.capture=E),b(K),P}catch(E){if(F.aborted||l!==N)return {ok:false};let C={phase:"error",lastError:F.aborted?y("aborted",E):y("unknown",E)};return S&&(C.selection=S),b(C),{ok:false}}finally{l===N&&(a=null);}},__unsafeGetSelectedElement(){return s},destroy(){m(),r.clear(),o.clear(),d?.(),d=null;}}}var B=[],D=[],Me=20,Le=15,O={},U=null,H=null,q=null,j=false;function ht(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function wt(e,t){let n=t.map(ht).join(" "),r=t.find(i=>i instanceof Error),o={level:e,message:n.slice(0,2e3),timestamp:Date.now()};for(r?.stack&&(o.stack=r.stack.slice(0,2e3)),B.push(o);B.length>Me;)B.shift();}function ie(e){if(!e.url.includes("blocfeed.com"))for(D.push(e);D.length>Le;)D.shift();}function sn(e={}){if(!(j||!w())){if(j=true,Me=e.consoleLimit??20,Le=e.networkLimit??15,e.console!==false){let t=e.consoleLevels??["error","warn"];for(let n of t)O[n]=console[n],console[n]=(...r)=>{wt(n,r),O[n]?.apply(console,r);};}if(e.network!==false&&typeof window.fetch=="function"){U=window.fetch;let t=U;window.fetch=async function(r,o){let i=typeof r=="string"?r:r instanceof URL?r.toString():r.url,s=(o?.method??"GET").toUpperCase(),c=Date.now();try{let a=await t.call(window,r,o);return a.ok||ie({url:i.slice(0,500),method:s,status:a.status,statusText:a.statusText,timestamp:c,durationMs:Date.now()-c}),a}catch(a){throw ie({url:i.slice(0,500),method:s,status:0,statusText:a instanceof Error?a.message:"Network error",timestamp:c,durationMs:Date.now()-c}),a}};}if(e.network!==false&&typeof XMLHttpRequest<"u"){H=XMLHttpRequest.prototype.open,q=XMLHttpRequest.prototype.send;let t=H,n=q;XMLHttpRequest.prototype.open=function(r,o,...i){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(o),t.apply(this,[r,o,...i])},XMLHttpRequest.prototype.send=function(...r){let o=this.__bf_method||"GET",i=this.__bf_url||"",s=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let c={url:i.slice(0,500),method:o,status:this.status,timestamp:s,durationMs:Date.now()-s};this.statusText&&(c.statusText=this.statusText),ie(c);}}),n.apply(this,r)};}}}function cn(){if(j){for(let[e,t]of Object.entries(O))console[e]=t;for(let e of Object.keys(O))delete O[e];U&&(window.fetch=U,U=null),H&&(XMLHttpRequest.prototype.open=H,H=null),q&&(XMLHttpRequest.prototype.send=q,q=null),j=false;}}function ln(){return {consoleLogs:[...B],networkErrors:[...D]}}function un(){B=[],D=[];}var yt=[{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,}/}],R=[],se=0,ae=false;function bt(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function Et(e,t,n,r){if(R.some(s=>s.rule===e&&s.source===t))return;let i={rule:e,source:t,hint:bt(n),timestamp:Date.now()};r&&(i.location=r),R.push(i);}function $(e,t,n,r){for(let{name:o,pattern:i}of n){let s=i.exec(e);s&&Et(o,t,s[0],r);}}function _t(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);$(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);$(n,"hydration",e,"__NUXT__");}}catch{}}function St(e){try{document.querySelectorAll("script:not([src])").forEach((n,r)=>{let o=n.textContent;o&&o.length>0&&$(o,"scripts",e,`inline-script[${r}]`);});}catch{}}function kt(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let r=n.getAttribute("content"),o=n.getAttribute("name")||n.getAttribute("property")||"";r&&r.length>10&&$(r,"meta",e,o?`meta[${o}]`:void 0);});}catch{}}function vt(e){try{document.querySelectorAll("[data-api-key], [data-secret], [data-token], [data-password]").forEach(n=>{let r=n.attributes;for(let o=0;o<r.length;o++){let i=r[o];i.name.startsWith("data-")&&i.value.length>10&&$(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function mn(e={}){if(ae||!w()||(ae=true,e.secretScan===false))return;let t=[...yt,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{se=Date.now(),n.includes("hydration")&&_t(t),n.includes("scripts")&&St(t),n.includes("meta")&&kt(t),n.includes("dom")&&vt(t);let r=e.notify??"both";R.length>0&&(r==="console"||r==="both")&&console.warn(`[BlocFeed Security] Found ${R.length} potential secret(s) exposed in client code:`,R.map(o=>`${o.rule} (${o.source}${o.location?`: ${o.location}`:""})`));},100);}function pn(){return {findings:[...R],scannedAt:se}}function gn(){R=[],se=0,ae=false;}
2
+ export{w as a,Y as b,ye as c,Se as d,ke as e,ne as f,ve as g,Ot as h,Ut as i,rn as j,sn as k,cn as l,ln as m,un as n,mn as o,pn as p,gn as q};
@@ -86,6 +86,36 @@ interface DiagnosticsConfig {
86
86
  /** Max network entries to retain. Default: 15 */
87
87
  networkLimit?: number;
88
88
  }
89
+ type SecurityScanTarget = "hydration" | "scripts" | "meta" | "dom";
90
+ interface SecurityConfig {
91
+ /** Enable secret leak scanning. Default: true when security config is present. */
92
+ secretScan?: boolean;
93
+ /** Additional regex patterns to scan for. */
94
+ customPatterns?: Array<{
95
+ name: string;
96
+ pattern: RegExp;
97
+ }>;
98
+ /** What to scan. Default: all targets. */
99
+ scanTargets?: SecurityScanTarget[];
100
+ /** Where to report findings. Default: "both" */
101
+ notify?: "dashboard" | "console" | "both";
102
+ }
103
+ interface SecurityFinding {
104
+ /** Which pattern matched. */
105
+ rule: string;
106
+ /** Where it was found. */
107
+ source: SecurityScanTarget;
108
+ /** Truncated/redacted hint (first 6 chars + "***") — NEVER the full secret. */
109
+ hint: string;
110
+ /** Location details (e.g. script index, meta name). */
111
+ location?: string;
112
+ /** Timestamp. */
113
+ timestamp: number;
114
+ }
115
+ interface SecuritySnapshot {
116
+ findings: SecurityFinding[];
117
+ scannedAt: number;
118
+ }
89
119
  interface Rect {
90
120
  x: number;
91
121
  y: number;
@@ -203,6 +233,8 @@ interface BlocFeedConfig {
203
233
  transport?: TransportConfig;
204
234
  /** Diagnostics capture (console logs + failed network requests). */
205
235
  diagnostics?: DiagnosticsConfig;
236
+ /** Client-side secret leak detection. */
237
+ security?: SecurityConfig;
206
238
  ui?: {
207
239
  /** z-index for the widget overlay/panel. */
208
240
  zIndex?: number;
@@ -309,4 +341,4 @@ interface BlocFeedController {
309
341
  }
310
342
  declare function createBlocFeedController(config: BlocFeedConfig): BlocFeedController;
311
343
 
312
- export { type BlocFeedConfig as B, type CaptureConfig as C, type DiagnosticsConfig as D, type ElementDescriptor as E, type FeedbackCategory as F, type HoverListener as H, type ImageAsset as I, type MaybePromise as M, type NetworkEntry as N, type PickerConfig as P, type Rect as R, type SubmitResult as S, type ThemeConfig as T, type WidgetPosition as W, type BlocFeedHandle as a, type BlocFeedState as b, type BlocFeedController as c, type BlocFeedError as d, type BlocFeedStrings as e, type BlocFeedUser as f, type CaptureDiagnostics as g, type CaptureResult as h, type ConsoleEntry as i, type FeedbackApiResponse as j, type FeedbackPayload as k, type MetadataConfig as l, type MetadataContext as m, type ScreenshotAdapter as n, type ScreenshotAdapterOptions as o, type ScreenshotIntent as p, type ScreenshotMime as q, type SessionPhase as r, type TransportConfig as s, type TransportResult as t, type TriggerStyle as u, type StateListener as v, createBlocFeedController as w };
344
+ export { type BlocFeedConfig as B, type CaptureConfig as C, type DiagnosticsConfig as D, type ElementDescriptor as E, type FeedbackCategory as F, type HoverListener as H, type ImageAsset as I, type MaybePromise as M, type NetworkEntry as N, type PickerConfig as P, type Rect as R, type SubmitResult as S, type ThemeConfig as T, type WidgetPosition as W, type BlocFeedHandle as a, type BlocFeedState as b, type BlocFeedController as c, type BlocFeedError as d, type BlocFeedStrings as e, type BlocFeedUser as f, type CaptureDiagnostics as g, type CaptureResult as h, type ConsoleEntry as i, type FeedbackApiResponse as j, type FeedbackPayload as k, type MetadataConfig as l, type MetadataContext as m, type ScreenshotAdapter as n, type ScreenshotAdapterOptions as o, type ScreenshotIntent as p, type ScreenshotMime as q, type SecurityConfig as r, type SecurityFinding as s, type SecuritySnapshot as t, type SessionPhase as u, type TransportConfig as v, type TransportResult as w, type TriggerStyle as x, type StateListener as y, createBlocFeedController as z };
@@ -86,6 +86,36 @@ interface DiagnosticsConfig {
86
86
  /** Max network entries to retain. Default: 15 */
87
87
  networkLimit?: number;
88
88
  }
89
+ type SecurityScanTarget = "hydration" | "scripts" | "meta" | "dom";
90
+ interface SecurityConfig {
91
+ /** Enable secret leak scanning. Default: true when security config is present. */
92
+ secretScan?: boolean;
93
+ /** Additional regex patterns to scan for. */
94
+ customPatterns?: Array<{
95
+ name: string;
96
+ pattern: RegExp;
97
+ }>;
98
+ /** What to scan. Default: all targets. */
99
+ scanTargets?: SecurityScanTarget[];
100
+ /** Where to report findings. Default: "both" */
101
+ notify?: "dashboard" | "console" | "both";
102
+ }
103
+ interface SecurityFinding {
104
+ /** Which pattern matched. */
105
+ rule: string;
106
+ /** Where it was found. */
107
+ source: SecurityScanTarget;
108
+ /** Truncated/redacted hint (first 6 chars + "***") — NEVER the full secret. */
109
+ hint: string;
110
+ /** Location details (e.g. script index, meta name). */
111
+ location?: string;
112
+ /** Timestamp. */
113
+ timestamp: number;
114
+ }
115
+ interface SecuritySnapshot {
116
+ findings: SecurityFinding[];
117
+ scannedAt: number;
118
+ }
89
119
  interface Rect {
90
120
  x: number;
91
121
  y: number;
@@ -203,6 +233,8 @@ interface BlocFeedConfig {
203
233
  transport?: TransportConfig;
204
234
  /** Diagnostics capture (console logs + failed network requests). */
205
235
  diagnostics?: DiagnosticsConfig;
236
+ /** Client-side secret leak detection. */
237
+ security?: SecurityConfig;
206
238
  ui?: {
207
239
  /** z-index for the widget overlay/panel. */
208
240
  zIndex?: number;
@@ -309,4 +341,4 @@ interface BlocFeedController {
309
341
  }
310
342
  declare function createBlocFeedController(config: BlocFeedConfig): BlocFeedController;
311
343
 
312
- export { type BlocFeedConfig as B, type CaptureConfig as C, type DiagnosticsConfig as D, type ElementDescriptor as E, type FeedbackCategory as F, type HoverListener as H, type ImageAsset as I, type MaybePromise as M, type NetworkEntry as N, type PickerConfig as P, type Rect as R, type SubmitResult as S, type ThemeConfig as T, type WidgetPosition as W, type BlocFeedHandle as a, type BlocFeedState as b, type BlocFeedController as c, type BlocFeedError as d, type BlocFeedStrings as e, type BlocFeedUser as f, type CaptureDiagnostics as g, type CaptureResult as h, type ConsoleEntry as i, type FeedbackApiResponse as j, type FeedbackPayload as k, type MetadataConfig as l, type MetadataContext as m, type ScreenshotAdapter as n, type ScreenshotAdapterOptions as o, type ScreenshotIntent as p, type ScreenshotMime as q, type SessionPhase as r, type TransportConfig as s, type TransportResult as t, type TriggerStyle as u, type StateListener as v, createBlocFeedController as w };
344
+ export { type BlocFeedConfig as B, type CaptureConfig as C, type DiagnosticsConfig as D, type ElementDescriptor as E, type FeedbackCategory as F, type HoverListener as H, type ImageAsset as I, type MaybePromise as M, type NetworkEntry as N, type PickerConfig as P, type Rect as R, type SubmitResult as S, type ThemeConfig as T, type WidgetPosition as W, type BlocFeedHandle as a, type BlocFeedState as b, type BlocFeedController as c, type BlocFeedError as d, type BlocFeedStrings as e, type BlocFeedUser as f, type CaptureDiagnostics as g, type CaptureResult as h, type ConsoleEntry as i, type FeedbackApiResponse as j, type FeedbackPayload as k, type MetadataConfig as l, type MetadataContext as m, type ScreenshotAdapter as n, type ScreenshotAdapterOptions as o, type ScreenshotIntent as p, type ScreenshotMime as q, type SecurityConfig as r, type SecurityFinding as s, type SecuritySnapshot as t, type SessionPhase as u, type TransportConfig as v, type TransportResult as w, type TriggerStyle as x, type StateListener as y, createBlocFeedController as z };
package/dist/engine.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunkCHN4RORX_cjs=require('./chunk-CHN4RORX.cjs');function c(o){if(o?.aborted)throw new Error("Aborted")}async function M(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 d(o,t){let{width:e,height:r}=await M(o);return {dataUrl:o,mime:t,width:e,height:r}}function F(o){return {async captureElement(t,e){if(!chunkCHN4RORX_cjs.a())throw new Error("captureElement can only run in the browser");c(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 c(e.signal),await d(n,e.mime)},async captureFullPage(t){if(!chunkCHN4RORX_cjs.a())throw new Error("captureFullPage can only run in the browser");c(t.signal);let e=document.documentElement,r=Math.max(e.scrollWidth,e.clientWidth),n=Math.max(e.scrollHeight,e.clientHeight),a=Math.min(1,t.maxDimension/Math.max(r,n)),s={width:Math.max(1,Math.round(r*a)),height:Math.max(1,Math.round(n*a)),scale:t.pixelRatio},i=t.mime==="image/jpeg"?await o.domToJpeg(e,{...s,quality:t.quality??.92}):await o.domToPng(e,s);return c(t.signal),await d(i,t.mime)}}}function B(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",a=atob(e),s=new Uint8Array(a.length);for(let i=0;i<a.length;i+=1)s[i]=a.charCodeAt(i);return new Blob([s],{type:n})}Object.defineProperty(exports,"clearDiagnostics",{enumerable:true,get:function(){return chunkCHN4RORX_cjs.n}});Object.defineProperty(exports,"clearQueue",{enumerable:true,get:function(){return chunkCHN4RORX_cjs.h}});Object.defineProperty(exports,"collectMetadata",{enumerable:true,get:function(){return chunkCHN4RORX_cjs.e}});Object.defineProperty(exports,"createBlocFeedController",{enumerable:true,get:function(){return chunkCHN4RORX_cjs.j}});Object.defineProperty(exports,"createHtmlToImageAdapter",{enumerable:true,get:function(){return chunkCHN4RORX_cjs.c}});Object.defineProperty(exports,"dequeueAll",{enumerable:true,get:function(){return chunkCHN4RORX_cjs.g}});Object.defineProperty(exports,"drainDiagnostics",{enumerable:true,get:function(){return chunkCHN4RORX_cjs.m}});Object.defineProperty(exports,"enqueue",{enumerable:true,get:function(){return chunkCHN4RORX_cjs.f}});Object.defineProperty(exports,"getQueueSize",{enumerable:true,get:function(){return chunkCHN4RORX_cjs.i}});Object.defineProperty(exports,"installDiagnostics",{enumerable:true,get:function(){return chunkCHN4RORX_cjs.k}});Object.defineProperty(exports,"runCapture",{enumerable:true,get:function(){return chunkCHN4RORX_cjs.d}});Object.defineProperty(exports,"uninstallDiagnostics",{enumerable:true,get:function(){return chunkCHN4RORX_cjs.l}});exports.createModernScreenshotAdapter=F;exports.dataUrlToBlob=B;
1
+ 'use strict';var chunkJVY6JTXP_cjs=require('./chunk-JVY6JTXP.cjs');function c(o){if(o?.aborted)throw new Error("Aborted")}async function P(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 P(o);return {dataUrl:o,mime:t,width:e,height:r}}function B(o){return {async captureElement(t,e){if(!chunkJVY6JTXP_cjs.a())throw new Error("captureElement can only run in the browser");c(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 c(e.signal),await l(n,e.mime)},async captureFullPage(t){if(!chunkJVY6JTXP_cjs.a())throw new Error("captureFullPage can only run in the browser");c(t.signal);let e=document.documentElement,r=Math.max(e.scrollWidth,e.clientWidth),n=Math.max(e.scrollHeight,e.clientHeight),a=Math.min(1,t.maxDimension/Math.max(r,n)),s={width:Math.max(1,Math.round(r*a)),height:Math.max(1,Math.round(n*a)),scale:t.pixelRatio},i=t.mime==="image/jpeg"?await o.domToJpeg(e,{...s,quality:t.quality??.92}):await o.domToPng(e,s);return c(t.signal),await l(i,t.mime)}}}function T(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",a=atob(e),s=new Uint8Array(a.length);for(let i=0;i<a.length;i+=1)s[i]=a.charCodeAt(i);return new Blob([s],{type:n})}Object.defineProperty(exports,"clearDiagnostics",{enumerable:true,get:function(){return chunkJVY6JTXP_cjs.n}});Object.defineProperty(exports,"clearQueue",{enumerable:true,get:function(){return chunkJVY6JTXP_cjs.h}});Object.defineProperty(exports,"clearSecurityFindings",{enumerable:true,get:function(){return chunkJVY6JTXP_cjs.q}});Object.defineProperty(exports,"collectMetadata",{enumerable:true,get:function(){return chunkJVY6JTXP_cjs.e}});Object.defineProperty(exports,"createBlocFeedController",{enumerable:true,get:function(){return chunkJVY6JTXP_cjs.j}});Object.defineProperty(exports,"createHtmlToImageAdapter",{enumerable:true,get:function(){return chunkJVY6JTXP_cjs.c}});Object.defineProperty(exports,"dequeueAll",{enumerable:true,get:function(){return chunkJVY6JTXP_cjs.g}});Object.defineProperty(exports,"drainDiagnostics",{enumerable:true,get:function(){return chunkJVY6JTXP_cjs.m}});Object.defineProperty(exports,"enqueue",{enumerable:true,get:function(){return chunkJVY6JTXP_cjs.f}});Object.defineProperty(exports,"getQueueSize",{enumerable:true,get:function(){return chunkJVY6JTXP_cjs.i}});Object.defineProperty(exports,"getSecurityFindings",{enumerable:true,get:function(){return chunkJVY6JTXP_cjs.p}});Object.defineProperty(exports,"installDiagnostics",{enumerable:true,get:function(){return chunkJVY6JTXP_cjs.k}});Object.defineProperty(exports,"runCapture",{enumerable:true,get:function(){return chunkJVY6JTXP_cjs.d}});Object.defineProperty(exports,"runSecretScan",{enumerable:true,get:function(){return chunkJVY6JTXP_cjs.o}});Object.defineProperty(exports,"uninstallDiagnostics",{enumerable:true,get:function(){return chunkJVY6JTXP_cjs.l}});exports.createModernScreenshotAdapter=B;exports.dataUrlToBlob=T;
package/dist/engine.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { n as ScreenshotAdapter, C as CaptureConfig, h as CaptureResult, l as MetadataConfig, m as MetadataContext, f as BlocFeedUser, k as FeedbackPayload } from './controller-hJ_lZRbR.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, H as HoverListener, I as ImageAsset, N as NetworkEntry, R as Rect, o as ScreenshotAdapterOptions, p as ScreenshotIntent, q as ScreenshotMime, r as SessionPhase, v as StateListener, S as SubmitResult, T as ThemeConfig, s as TransportConfig, u as TriggerStyle, W as WidgetPosition, w as createBlocFeedController } from './controller-hJ_lZRbR.cjs';
1
+ import { n as ScreenshotAdapter, C as CaptureConfig, h as CaptureResult, l as MetadataConfig, m as MetadataContext, f as BlocFeedUser, k as FeedbackPayload, t as SecuritySnapshot, r as SecurityConfig } from './controller-BPsU7cuY.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, H as HoverListener, I as ImageAsset, N as NetworkEntry, R as Rect, o as ScreenshotAdapterOptions, p as ScreenshotIntent, q as ScreenshotMime, s as SecurityFinding, u as SessionPhase, y as StateListener, S as SubmitResult, T as ThemeConfig, v as TransportConfig, x as TriggerStyle, W as WidgetPosition, z as createBlocFeedController } from './controller-BPsU7cuY.cjs';
3
3
 
4
4
  declare function createHtmlToImageAdapter(): ScreenshotAdapter;
5
5
 
@@ -110,6 +110,19 @@ declare function drainDiagnostics(): DiagnosticsSnapshot;
110
110
  */
111
111
  declare function clearDiagnostics(): void;
112
112
 
113
+ /**
114
+ * Run the secret scan once. Safe to call multiple times — subsequent calls are no-ops.
115
+ */
116
+ declare function runSecretScan(config?: SecurityConfig): void;
117
+ /**
118
+ * Return a copy of all findings (non-destructive).
119
+ */
120
+ declare function getSecurityFindings(): SecuritySnapshot;
121
+ /**
122
+ * Clear all findings and reset state.
123
+ */
124
+ declare function clearSecurityFindings(): void;
125
+
113
126
  declare function dataUrlToBlob(dataUrl: string): Blob;
114
127
 
115
- export { BlocFeedUser, CaptureResult, FeedbackPayload, type ModernScreenshotModule, ScreenshotAdapter, clearDiagnostics, clearQueue, collectMetadata, createHtmlToImageAdapter, createModernScreenshotAdapter, dataUrlToBlob, dequeueAll, drainDiagnostics, enqueue, getQueueSize, installDiagnostics, runCapture, uninstallDiagnostics };
128
+ export { BlocFeedUser, CaptureResult, FeedbackPayload, type ModernScreenshotModule, ScreenshotAdapter, SecurityConfig, SecuritySnapshot, clearDiagnostics, clearQueue, clearSecurityFindings, collectMetadata, createHtmlToImageAdapter, createModernScreenshotAdapter, dataUrlToBlob, dequeueAll, drainDiagnostics, enqueue, getQueueSize, getSecurityFindings, installDiagnostics, runCapture, runSecretScan, uninstallDiagnostics };
package/dist/engine.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { n as ScreenshotAdapter, C as CaptureConfig, h as CaptureResult, l as MetadataConfig, m as MetadataContext, f as BlocFeedUser, k as FeedbackPayload } from './controller-hJ_lZRbR.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, H as HoverListener, I as ImageAsset, N as NetworkEntry, R as Rect, o as ScreenshotAdapterOptions, p as ScreenshotIntent, q as ScreenshotMime, r as SessionPhase, v as StateListener, S as SubmitResult, T as ThemeConfig, s as TransportConfig, u as TriggerStyle, W as WidgetPosition, w as createBlocFeedController } from './controller-hJ_lZRbR.js';
1
+ import { n as ScreenshotAdapter, C as CaptureConfig, h as CaptureResult, l as MetadataConfig, m as MetadataContext, f as BlocFeedUser, k as FeedbackPayload, t as SecuritySnapshot, r as SecurityConfig } from './controller-BPsU7cuY.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, H as HoverListener, I as ImageAsset, N as NetworkEntry, R as Rect, o as ScreenshotAdapterOptions, p as ScreenshotIntent, q as ScreenshotMime, s as SecurityFinding, u as SessionPhase, y as StateListener, S as SubmitResult, T as ThemeConfig, v as TransportConfig, x as TriggerStyle, W as WidgetPosition, z as createBlocFeedController } from './controller-BPsU7cuY.js';
3
3
 
4
4
  declare function createHtmlToImageAdapter(): ScreenshotAdapter;
5
5
 
@@ -110,6 +110,19 @@ declare function drainDiagnostics(): DiagnosticsSnapshot;
110
110
  */
111
111
  declare function clearDiagnostics(): void;
112
112
 
113
+ /**
114
+ * Run the secret scan once. Safe to call multiple times — subsequent calls are no-ops.
115
+ */
116
+ declare function runSecretScan(config?: SecurityConfig): void;
117
+ /**
118
+ * Return a copy of all findings (non-destructive).
119
+ */
120
+ declare function getSecurityFindings(): SecuritySnapshot;
121
+ /**
122
+ * Clear all findings and reset state.
123
+ */
124
+ declare function clearSecurityFindings(): void;
125
+
113
126
  declare function dataUrlToBlob(dataUrl: string): Blob;
114
127
 
115
- export { BlocFeedUser, CaptureResult, FeedbackPayload, type ModernScreenshotModule, ScreenshotAdapter, clearDiagnostics, clearQueue, collectMetadata, createHtmlToImageAdapter, createModernScreenshotAdapter, dataUrlToBlob, dequeueAll, drainDiagnostics, enqueue, getQueueSize, installDiagnostics, runCapture, uninstallDiagnostics };
128
+ export { BlocFeedUser, CaptureResult, FeedbackPayload, type ModernScreenshotModule, ScreenshotAdapter, SecurityConfig, SecuritySnapshot, clearDiagnostics, clearQueue, clearSecurityFindings, collectMetadata, createHtmlToImageAdapter, createModernScreenshotAdapter, dataUrlToBlob, dequeueAll, drainDiagnostics, enqueue, getQueueSize, getSecurityFindings, installDiagnostics, runCapture, runSecretScan, uninstallDiagnostics };
package/dist/engine.js CHANGED
@@ -1 +1 @@
1
- import {a}from'./chunk-DVNOWOIG.js';export{n as clearDiagnostics,h as clearQueue,e as collectMetadata,j as createBlocFeedController,c as createHtmlToImageAdapter,g as dequeueAll,m as drainDiagnostics,f as enqueue,i as getQueueSize,k as installDiagnostics,d as runCapture,l as uninstallDiagnostics}from'./chunk-DVNOWOIG.js';function c(o){if(o?.aborted)throw new Error("Aborted")}async function M(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 d(o,t){let{width:e,height:r}=await M(o);return {dataUrl:o,mime:t,width:e,height:r}}function F(o){return {async captureElement(t,e){if(!a())throw new Error("captureElement can only run in the browser");c(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 c(e.signal),await d(n,e.mime)},async captureFullPage(t){if(!a())throw new Error("captureFullPage can only run in the browser");c(t.signal);let e=document.documentElement,r=Math.max(e.scrollWidth,e.clientWidth),n=Math.max(e.scrollHeight,e.clientHeight),a$1=Math.min(1,t.maxDimension/Math.max(r,n)),s={width:Math.max(1,Math.round(r*a$1)),height:Math.max(1,Math.round(n*a$1)),scale:t.pixelRatio},i=t.mime==="image/jpeg"?await o.domToJpeg(e,{...s,quality:t.quality??.92}):await o.domToPng(e,s);return c(t.signal),await d(i,t.mime)}}}function B(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",a=atob(e),s=new Uint8Array(a.length);for(let i=0;i<a.length;i+=1)s[i]=a.charCodeAt(i);return new Blob([s],{type:n})}export{F as createModernScreenshotAdapter,B as dataUrlToBlob};
1
+ import {a}from'./chunk-LAK7UUTC.js';export{n as clearDiagnostics,h as clearQueue,q as clearSecurityFindings,e as collectMetadata,j as createBlocFeedController,c as createHtmlToImageAdapter,g as dequeueAll,m as drainDiagnostics,f as enqueue,i as getQueueSize,p as getSecurityFindings,k as installDiagnostics,d as runCapture,o as runSecretScan,l as uninstallDiagnostics}from'./chunk-LAK7UUTC.js';function c(o){if(o?.aborted)throw new Error("Aborted")}async function P(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 P(o);return {dataUrl:o,mime:t,width:e,height:r}}function B(o){return {async captureElement(t,e){if(!a())throw new Error("captureElement can only run in the browser");c(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 c(e.signal),await l(n,e.mime)},async captureFullPage(t){if(!a())throw new Error("captureFullPage can only run in the browser");c(t.signal);let e=document.documentElement,r=Math.max(e.scrollWidth,e.clientWidth),n=Math.max(e.scrollHeight,e.clientHeight),a$1=Math.min(1,t.maxDimension/Math.max(r,n)),s={width:Math.max(1,Math.round(r*a$1)),height:Math.max(1,Math.round(n*a$1)),scale:t.pixelRatio},i=t.mime==="image/jpeg"?await o.domToJpeg(e,{...s,quality:t.quality??.92}):await o.domToPng(e,s);return c(t.signal),await l(i,t.mime)}}}function T(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",a=atob(e),s=new Uint8Array(a.length);for(let i=0;i<a.length;i+=1)s[i]=a.charCodeAt(i);return new Blob([s],{type:n})}export{B as createModernScreenshotAdapter,T as dataUrlToBlob};
package/dist/main.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- 'use strict';var chunkCHN4RORX_cjs=require('./chunk-CHN4RORX.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),framerMotion=require('framer-motion');var U=react.createContext(null);function J(e){let t=react.useMemo(()=>chunkCHN4RORX_cjs.j({...e.config??{},blocfeed_id:e.blocfeed_id}),[]),[i,o]=react.useState(()=>t.getState());return react.useEffect(()=>t.subscribe(o),[t]),react.useEffect(()=>t.setConfig({...e.config??{},blocfeed_id:e.blocfeed_id}),[t,e.config,e.blocfeed_id]),react.useEffect(()=>()=>t.destroy(),[t]),jsxRuntime.jsx(U.Provider,{value:{controller:t,state:i},children:e.children})}var he="blocfeed-styles-v1",ft=`
2
+ 'use strict';var chunkJVY6JTXP_cjs=require('./chunk-JVY6JTXP.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),framerMotion=require('framer-motion');var U=react.createContext(null);function ee(e){let t=react.useMemo(()=>chunkJVY6JTXP_cjs.j({...e.config??{},blocfeed_id:e.blocfeed_id}),[]),[n,o]=react.useState(()=>t.getState());return react.useEffect(()=>t.subscribe(o),[t]),react.useEffect(()=>t.setConfig({...e.config??{},blocfeed_id:e.blocfeed_id}),[t,e.config,e.blocfeed_id]),react.useEffect(()=>()=>t.destroy(),[t]),jsxRuntime.jsx(U.Provider,{value:{controller:t,state:n},children:e.children})}var we="blocfeed-styles-v1",xt=`
3
3
  :where([data-blocfeed-ui-root]),
4
4
  :where([data-blocfeed-ui-root]) * {
5
5
  box-sizing: border-box;
@@ -548,6 +548,57 @@
548
548
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
549
549
  }
550
550
 
551
+ /* ------------------------------------------------------------------ */
552
+ /* Security warning banner */
553
+ /* ------------------------------------------------------------------ */
554
+
555
+ :where([data-blocfeed-ui-root]) .bf-security-banner {
556
+ position: fixed;
557
+ top: 8px;
558
+ right: 8px;
559
+ z-index: var(--bf-z);
560
+ max-width: 360px;
561
+ padding: 10px 14px;
562
+ border-radius: 10px;
563
+ border-left: 3px solid var(--bf-danger);
564
+ background: rgba(239, 68, 68, 0.12);
565
+ color: rgb(254, 202, 202);
566
+ font-family: var(--bf-font);
567
+ font-size: 12px;
568
+ line-height: 1.5;
569
+ pointer-events: auto;
570
+ animation: bf-panel-in 0.2s ease-out;
571
+ }
572
+
573
+ :where([data-blocfeed-ui-root][data-bf-theme="light"]) .bf-security-banner {
574
+ background: rgba(239, 68, 68, 0.08);
575
+ color: rgb(185, 28, 28);
576
+ }
577
+
578
+ :where([data-blocfeed-ui-root]) .bf-security-banner strong {
579
+ display: block;
580
+ margin-bottom: 4px;
581
+ font-size: 13px;
582
+ }
583
+
584
+ :where([data-blocfeed-ui-root]) .bf-security-banner-dismiss {
585
+ position: absolute;
586
+ top: 6px;
587
+ right: 6px;
588
+ background: none;
589
+ border: none;
590
+ color: inherit;
591
+ opacity: 0.6;
592
+ cursor: pointer;
593
+ padding: 2px 4px;
594
+ font-size: 14px;
595
+ line-height: 1;
596
+ }
597
+
598
+ :where([data-blocfeed-ui-root]) .bf-security-banner-dismiss:hover {
599
+ opacity: 1;
600
+ }
601
+
551
602
  /* ------------------------------------------------------------------ */
552
603
  /* Reduced motion */
553
604
  /* ------------------------------------------------------------------ */
@@ -584,5 +635,5 @@
584
635
  animation: none;
585
636
  }
586
637
  }
587
- `;function xe(){if(!chunkCHN4RORX_cjs.a()||document.getElementById(he))return;let e=document.createElement("style");e.id=he,e.textContent=ft,document.head.appendChild(e);}var ye={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"};function we(e){return e?{...ye,...e}:ye}function Z(){let e=react.useContext(U);if(!e)throw new Error("useBlocFeed must be used within a <BlocFeedProvider />");return {state:e.state,controller:e.controller,start:e.controller.start,stop:e.controller.stop,clearSelection:e.controller.clearSelection,submit:e.controller.submit}}function x(e){switch(e){case "bottom-left":return "bf-trigger bf-trigger-bl";case "top-right":return "bf-trigger bf-trigger-tr";case "top-left":return "bf-trigger bf-trigger-tl";default:return "bf-trigger"}}function b({size:e=14}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M20 6L9 17l-5-5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function ve({size:e=14}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M21 11.5a8.38 8.38 0 01-.9 3.8 8.5 8.5 0 01-7.6 4.7 8.38 8.38 0 01-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 01-.9-3.8 8.5 8.5 0 014.7-7.6 8.38 8.38 0 013.8-.9h.5a8.48 8.48 0 018 8v.5z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function ke({size:e=16}){return jsxRuntime.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[jsxRuntime.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M22 6l-10 7L2 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Pe({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){return i?jsxRuntime.jsxs("button",{className:x(e),type:"button",onClick:t,"aria-label":o,children:[c?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-dot","aria-hidden":"true"}),o]}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]}):null}function m(){let[e,t]=react.useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return react.useEffect(()=>{let i=window.matchMedia("(prefers-reduced-motion: reduce)"),o=r=>t(r.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}var yt={duration:.18,ease:"easeOut"},wt={duration:0};function Ce({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=react.useState(false),a=m(),s=a?wt:yt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:x(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:c?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",animate:a?{}:{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||a?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:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"dot")})}var Pt={duration:.18,ease:"easeOut"},Fe={duration:0};function Ne({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=react.useState(false),a=m(),s=a?Fe:Pt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsxs(framerMotion.motion.div,{className:x(e),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:a?0:4},animate:{opacity:1,y:0},exit:{opacity:0,y:a?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:o},"tooltip")}),jsxRuntime.jsxs(framerMotion.motion.button,{type:"button",onClick:t,"aria-label":o,style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"40px",borderRadius:"50%",border:"1px solid var(--bf-border)",background:"var(--bf-panel-bg)",color:"var(--bf-panel-fg)",boxShadow:"var(--bf-shadow)",cursor:"pointer",padding:0},animate:a?{}:{y:[0,-3,0]},transition:a?Fe:{y:{duration:3,repeat:1/0,ease:"easeInOut"}},whileHover:{scale:1.1,borderColor:"var(--bf-accent)"},whileTap:{scale:.9},children:[c?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{size:16})},"success"):jsxRuntime.jsx(ve,{size:16}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${r} queued`,children:r})]})]},"bubble")})}var St={duration:.2,ease:"easeOut"},Ft={duration:0};function Me(e){return e==="bottom-left"||e==="top-left"}function Bt(e){return `bf-trigger-edge ${Me(e)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function Le({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=react.useState(false),a=Me(e),s=m(),h=s?Ft:St;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:Bt(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,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:c?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:h,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(framerMotion.motion.span,{animate:{rotate:s||n?0:a?-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}}),o]}),jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",animate:{opacity:n?1:0},transition:{duration:.12},style:{position:"absolute",top:0,bottom:0,[a?"left":"right"]:0,width:"2px",background:"var(--bf-accent)"}}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"edge-tab")})}var Mt={duration:.18,ease:"easeOut"},Lt={duration:0};function ze({delay:e,hovered:t,reduced:i}){return i?null:jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",width:"10px",height:"10px",borderRadius:"50%",border:"2px solid var(--bf-accent)",pointerEvents:"none"},animate:t?{scale:1,opacity:0}:{scale:[1,1.8],opacity:[.5,0]},transition:t?{duration:.15}:{duration:2,repeat:1/0,delay:e,ease:"easeOut"}})}function We({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=react.useState(false),a=m(),s=a?Lt:Mt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:x(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:c?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{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(ze,{delay:0,hovered:n,reduced:a}),jsxRuntime.jsx(ze,{delay:.7,hovered:n,reduced:a}),jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",style:{position:"relative",zIndex:1}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"pulse-ring")})}var Wt={duration:.18,ease:"easeOut"},_t={duration:0};function Ht(e){switch(e){case "bottom-left":return "bf-trigger-minimal bf-trigger-bl";case "top-right":return "bf-trigger-minimal bf-trigger-tr";case "top-left":return "bf-trigger-minimal bf-trigger-tl";default:return "bf-trigger-minimal"}}function Oe({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=react.useState(false),a=m(),s=a?_t:Wt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsxs(framerMotion.motion.button,{className:Ht(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{opacity:0,y:a?0:5},animate:{opacity:n?1:.65,y:0},exit:{opacity:0,y:a?0:5},transition:s,whileTap:{scale:.95},children:[c?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:o}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${r} queued`,children:r})]}),!a&&jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",bottom:4,left:4,right:4,height:"2px",background:"var(--bf-accent)",borderRadius:"1px",transformOrigin:"left"},initial:false,animate:{scaleX:n?1:0},transition:s})]},"minimal")})}var Kt={duration:.18,ease:"easeOut"},$t={duration:0};function Ke({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=react.useState(false),a=m(),s=a?$t:Kt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:x(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.9},style:{overflow:"hidden"},children:c?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{style:{display:"inline-flex",flexShrink:0},animate:a?{}:n?{scale:1.2,rotate:0}:{rotate:[-5,5,-5]},transition:n||a?s:{duration:3,repeat:1/0,ease:"easeInOut"},children:jsxRuntime.jsx(ke,{size:16})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:a?0:-8},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-8},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"icon-pop")})}var Gt={duration:.18,ease:"easeOut"},Qt={duration:0};function Xe({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=react.useState(false),a=m(),s=a?Qt:Gt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:x(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:c?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{width:"10px",height:"10px",borderRadius:"50%",background:"var(--bf-accent)",position:"relative",zIndex:1},animate:a?{}:{opacity: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||a?s:{duration:2,repeat:1/0,ease:"easeInOut"}}),!n&&!a&&jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",width:"18px",height:"2px",background:"linear-gradient(90deg, var(--bf-accent), transparent)",transformOrigin:"left center",left:"5px",top:"4px"},animate:{rotate:[0,360]},transition:{duration:4,repeat:1/0,ease:"linear"}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"beacon")})}var Zt={duration:.18,ease:"easeOut"},eo={duration:0};function je({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=react.useState(false),[a,s]=react.useState(0),h=m(),u=h?eo:Zt,f=react.useRef(null);react.useEffect(()=>{if(f.current&&(clearInterval(f.current),f.current=null),!i||n||h){s(n||h?o.length:0);return}let y=8,$=o.length*2+y*2,k=0;return f.current=setInterval(()=>{k=(k+1)%$,k<=o.length?s(k):k<=o.length+y?s(o.length):k<=o.length*2+y?s(o.length*2+y-k):s(0);},100),()=>{f.current&&(clearInterval(f.current),f.current=null);}},[i,n,h,o]);let g=o.slice(0,a);return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.button,{className:x(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{opacity:0,y:h?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:h?0:5},transition:u,whileTap:{scale:.95},style:{minWidth:"44px"},children:c?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:u,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{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:[g,jsxRuntime.jsx("span",{className:"bf-cursor","aria-hidden":"true"})]}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"typewriter")})}function Ve(e){switch(e){case "dot":return Ce;case "bubble":return Ne;case "edge-tab":return Le;case "pulse-ring":return We;case "minimal":return Oe;case "icon-pop":return Ke;case "beacon":return Xe;case "typewriter":return je;default:return Pe}}function Je(e,t,i){return Math.max(t,Math.min(i,e))}function no(e,t,i="bottom-right"){let r=window.innerWidth,c=window.innerHeight,n;n=Je(e.x,12,Math.max(12,r-t-12));let l=e.y+e.height+12,a=Math.max(12,e.y-240);return {top:l+240<=c?l:a,left:n}}function io(e){let{rect:t}=e,i={left:`${t.x}px`,top:`${t.y}px`,width:`${Math.max(0,t.width)}px`,height:`${Math.max(0,t.height)}px`};return jsxRuntime.jsx("div",{className:"bf-highlight",style:i,"aria-hidden":"true"})}function so(e){let t=react.useRef(null);return react.useEffect(()=>{if(!e||!t.current)return;t.current.querySelector(".bf-textarea")?.focus();let o=r=>{if(r.key!=="Tab"||!t.current)return;let c=t.current.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(c.length===0)return;let n=c[0],l=c[c.length-1];r.shiftKey&&document.activeElement===n?(r.preventDefault(),l.focus()):!r.shiftKey&&document.activeElement===l&&(r.preventDefault(),n.focus());};return document.addEventListener("keydown",o,{capture:true}),()=>document.removeEventListener("keydown",o,{capture:true})},[e]),t}function lo(e,t){return e?typeof e=="function"?e(t):e.some(i=>i.endsWith("*")?t.startsWith(i.slice(0,-1)):t===i):true}function co(e){let[t,i]=react.useState(()=>typeof window<"u"?window.location.pathname:"/");return react.useEffect(()=>{if(typeof window>"u")return;let o=()=>i(window.location.pathname);window.addEventListener("popstate",o);let r=history.pushState,c=history.replaceState;return history.pushState=function(...n){r.apply(this,n),o();},history.replaceState=function(...n){c.apply(this,n),o();},()=>{window.removeEventListener("popstate",o),history.pushState=r,history.replaceState=c;}},[]),lo(e,t)}function po(e){let[t,i]=react.useState(()=>!e||e==="dark"?"dark":e==="light"?"light":typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return react.useEffect(()=>{if(e!=="auto"){i(e==="light"?"light":"dark");return}let o=window.matchMedia("(prefers-color-scheme: dark)"),r=c=>i(c.matches?"dark":"light");return i(o.matches?"dark":"light"),o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[e]),t}var fo=["bug","feature","ux","general"],uo={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function bo(e){let{state:t,controller:i,start:o,stop:r,clearSelection:c,submit:n}=Z(),l=e.config.ui?.position,a=we(e.config.ui?.strings),s=e.config.ui?.branding!==false,[h,u]=react.useState(null),[f,g]=react.useState(""),[y,$]=react.useState(e.config.capture?.element??true),[k,te]=react.useState(e.config.capture?.fullPage??false),[et,oe]=react.useState(null),[H,re]=react.useState(void 0),ae=e.config.ui?.categories??fo;react.useImperativeHandle(e.handleRef,()=>({open:o,close:r,submit:d=>n(d),get isOpen(){return t.phase!=="idle"}}),[o,r,n,t.phase]);let ne=t.phase==="review"||t.phase==="capturing"||t.phase==="submitting"||t.phase==="error"||t.phase==="success",tt=so(ne),[ot,rt]=react.useState(0);react.useEffect(()=>{t.phase==="idle"&&rt(chunkCHN4RORX_cjs.i());},[t.phase]);let[at,ie]=react.useState(false),se=react.useRef(t.phase);react.useEffect(()=>{if(se.current==="success"&&t.phase==="idle"){ie(true);let d=window.setTimeout(()=>ie(false),1500);return ()=>window.clearTimeout(d)}se.current=t.phase;},[t.phase]),react.useEffect(()=>{let d=e.config.ui?.shortcut;if(!d)return;let z=d.toLowerCase().split("+").map(C=>C.trim()),I=z[z.length-1]||"",R=new Set(z.slice(0,-1)),ce=C=>{let st=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(R.has("mod")){if(st?!C.metaKey:!C.ctrlKey)return}else if(R.has("ctrl")&&!C.ctrlKey||(R.has("meta")||R.has("cmd"))&&!C.metaKey)return;R.has("shift")&&!C.shiftKey||(R.has("alt")||R.has("option"))&&!C.altKey||C.key.toLowerCase()===I&&(C.preventDefault(),t.phase==="idle"?o():r());};return document.addEventListener("keydown",ce),()=>document.removeEventListener("keydown",ce)},[e.config.ui?.shortcut,t.phase,o,r]),react.useEffect(()=>i.subscribeHover(u),[i]),react.useEffect(()=>{let d=i.__unsafeGetSelectedElement();if(!d||t.phase==="idle"||t.phase==="picking"){oe(null);return}let z=()=>{oe(chunkCHN4RORX_cjs.b(d.getBoundingClientRect()));};z();let I=()=>z();return window.addEventListener("scroll",I,{capture:true,passive:true}),window.addEventListener("resize",I,{passive:true}),()=>{window.removeEventListener("scroll",I,{capture:true}),window.removeEventListener("resize",I);}},[i,t.phase,t.selection?.selector]),react.useEffect(()=>{t.phase==="review"&&(g(""),$(e.config.capture?.element??true),te(e.config.capture?.fullPage??false),re(void 0));},[t.phase,t.selection?.selector,e.config.capture?.element,e.config.capture?.fullPage]),react.useEffect(()=>{if(t.phase!=="success")return;let d=window.setTimeout(()=>r(),1200);return ()=>window.clearTimeout(d)},[t.phase,r]);let E=t.phase==="capturing"||t.phase==="submitting",B=t.phase==="picking"?h?.rect??null:et??t.selection?.rect??null,j=react.useMemo(()=>B?no(B,360,l):null,[B?.x,B?.y,B?.width,B?.height,l]),le=t.lastError?.message,V=react.useCallback(()=>{let d={capture:{element:y,fullPage:k}};H&&(d.category=H),n(f,d);},[n,f,y,k,H]),nt=react.useCallback(d=>{(d.metaKey||d.ctrlKey)&&d.key==="Enter"&&f.trim().length>0&&!E&&(d.preventDefault(),V());},[V,f,E]),it=Ve(e.config.ui?.triggerStyle);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(it,{position:l,onClick:()=>o(),isVisible:t.phase==="idle",label:e.config.ui?.triggerLabel??a.triggerLabel,queueCount:ot,showSuccess:at}),t.phase!=="idle"&&jsxRuntime.jsxs("div",{className:"bf-overlay",role:"presentation",children:[t.phase!=="picking"&&jsxRuntime.jsx("div",{className:"bf-blocker",role:"presentation",onClick:()=>r()}),B&&jsxRuntime.jsx(io,{rect:B}),t.phase==="picking"&&jsxRuntime.jsxs("div",{className:"bf-hint",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("p",{id:"bf-hint-text",children:a.hintText}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),"aria-label":a.cancelButton,children:a.cancelButton})]}),ne&&j&&jsxRuntime.jsxs("div",{ref:tt,className:"bf-panel",style:{left:j.left,top:j.top},role:"dialog","aria-modal":"true","aria-label":"Feedback form",children:[jsxRuntime.jsxs("div",{className:"bf-panelHeader",children:[jsxRuntime.jsx("div",{className:"bf-title",id:"bf-panel-title",children:a.panelTitle}),jsxRuntime.jsxs("div",{className:"bf-row",style:{justifyContent:"flex-end"},children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>c(),disabled:E,"aria-label":a.rePickButton,children:a.rePickButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),disabled:E,"aria-label":a.closeButton,children:a.closeButton})]})]}),jsxRuntime.jsxs("div",{className:"bf-panelBody",children:[jsxRuntime.jsx("textarea",{className:"bf-textarea",placeholder:a.textareaPlaceholder,value:f,onChange:d=>g(d.target.value),onKeyDown:nt,disabled:E,"aria-label":a.panelTitle}),ae.length>0&&jsxRuntime.jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:ae.map(d=>jsxRuntime.jsx("button",{type:"button",className:`bf-pill${H===d?" bf-pill-active":""}`,onClick:()=>re(H===d?void 0:d),disabled:E,children:a[uo[d]]},d))}),jsxRuntime.jsxs("div",{className:"bf-row",role:"group","aria-label":a.screenshotElement,children:[jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:y,onChange:d=>$(d.target.checked),disabled:E}),a.screenshotElement]}),jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:k,onChange:d=>te(d.target.checked),disabled:E}),a.screenshotFullPage]})]}),t.phase==="capturing"&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),a.capturingText]}),t.phase==="submitting"&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),a.submittingText]}),t.phase==="success"&&jsxRuntime.jsx("div",{className:"bf-status",role:"status","aria-live":"polite",children:a.successText}),t.phase==="error"&&le&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:le}),jsxRuntime.jsxs("div",{className:"bf-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),disabled:E,"aria-label":a.cancelButton,children:a.cancelButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:V,disabled:E||f.trim().length===0,"aria-label":a.sendButton,children:a.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"})})]})]}),t.phase==="success"&&jsxRuntime.jsx("div",{className:"bf-toast",role:"status","aria-live":"polite",children:a.toastText})]})}var go=react.forwardRef(function(t,i){let o={...t.config??{},blocfeed_id:t.blocfeed_id},[r,c]=react.useState(null),n=co(o.ui?.showOn),l=po(o.ui?.theme?.mode),a=!!o.diagnostics;react.useEffect(()=>{if(a)return chunkCHN4RORX_cjs.k(o.diagnostics),()=>chunkCHN4RORX_cjs.l()},[a]);let s=react.useRef(t.config?.metadata?.enrich);s.current=t.config?.metadata?.enrich;let h=react.useMemo(()=>{if(t.config)return {...t.config,metadata:{...t.config.metadata,enrich:async u=>{let f=s.current,g=f?await f(u):{},y=chunkCHN4RORX_cjs.m();return {...g,...y.consoleLogs.length>0?{_consoleLogs:y.consoleLogs}:{},...y.networkErrors.length>0?{_networkErrors:y.networkErrors}:{}}}}}},[]);return react.useEffect(()=>{xe();let u=document.createElement("div");u.setAttribute("data-blocfeed-ui-root","true"),u.setAttribute("data-blocfeed-ui","true"),u.setAttribute("data-bf-theme",l);let f=o.ui?.zIndex;typeof f=="number"&&u.style.setProperty("--bf-z",String(f));let g=o.ui?.theme;return g&&(g.accentColor&&u.style.setProperty("--bf-accent",g.accentColor),g.panelBackground&&u.style.setProperty("--bf-panel-bg",g.panelBackground),g.panelForeground&&u.style.setProperty("--bf-panel-fg",g.panelForeground),g.fontFamily&&u.style.setProperty("--bf-font",g.fontFamily)),document.body.appendChild(u),c(u),()=>{u.remove(),c(null);}},[o.ui?.zIndex,o.ui?.theme?.accentColor,o.ui?.theme?.panelBackground,o.ui?.theme?.panelForeground,o.ui?.theme?.fontFamily,l]),react.useEffect(()=>{r&&r.setAttribute("data-bf-theme",l);},[r,l]),!n||!r?null:reactDom.createPortal(jsxRuntime.jsx(J,{blocfeed_id:o.blocfeed_id,...h?{config:h}:{},children:jsxRuntime.jsx(bo,{config:o,handleRef:i})}),r)});
588
- exports.BlocFeedProvider=J;exports.BlocFeedWidget=go;exports.useBlocFeed=Z;
638
+ `;function ve(){if(!chunkJVY6JTXP_cjs.a()||document.getElementById(we))return;let e=document.createElement("style");e.id=we,e.textContent=xt,document.head.appendChild(e);}var ke={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"};function Te(e){return e?{...ke,...e}:ke}function te(){let e=react.useContext(U);if(!e)throw new Error("useBlocFeed must be used within a <BlocFeedProvider />");return {state:e.state,controller:e.controller,start:e.controller.start,stop:e.controller.stop,clearSelection:e.controller.clearSelection,submit:e.controller.submit}}function y(e){switch(e){case "bottom-left":return "bf-trigger bf-trigger-bl";case "top-right":return "bf-trigger bf-trigger-tr";case "top-left":return "bf-trigger bf-trigger-tl";default:return "bf-trigger"}}function b({size:e=14}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M20 6L9 17l-5-5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Se({size:e=14}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M21 11.5a8.38 8.38 0 01-.9 3.8 8.5 8.5 0 01-7.6 4.7 8.38 8.38 0 01-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 01-.9-3.8 8.5 8.5 0 014.7-7.6 8.38 8.38 0 013.8-.9h.5a8.48 8.48 0 018 8v.5z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Pe({size:e=16}){return jsxRuntime.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[jsxRuntime.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M22 6l-10 7L2 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ce({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){return n?jsxRuntime.jsxs("button",{className:y(e),type:"button",onClick:t,"aria-label":o,children:[c?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"bf-dot","aria-hidden":"true"}),o]}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]}):null}function g(){let[e,t]=react.useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return react.useEffect(()=>{let n=window.matchMedia("(prefers-reduced-motion: reduce)"),o=r=>t(r.matches);return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[]),e}var Pt={duration:.18,ease:"easeOut"},Et={duration:0};function Be({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=react.useState(false),a=g(),s=a?Et:Pt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:c?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",animate:a?{}:{scale:i?1:[1,1.2,1],boxShadow:i?"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:i||a?s:{duration:2,repeat:1/0,ease:"easeInOut"}}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"dot")})}var Nt={duration:.18,ease:"easeOut"},Re={duration:0};function Le({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=react.useState(false),a=g(),s=a?Re:Nt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsxs(framerMotion.motion.div,{className:y(e),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:i&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:a?0:4},animate:{opacity:1,y:0},exit:{opacity:0,y:a?0:4},transition: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:o},"tooltip")}),jsxRuntime.jsxs(framerMotion.motion.button,{type:"button",onClick:t,"aria-label":o,style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"40px",borderRadius:"50%",border:"1px solid var(--bf-border)",background:"var(--bf-panel-bg)",color:"var(--bf-panel-fg)",boxShadow:"var(--bf-shadow)",cursor:"pointer",padding:0},animate:a?{}:{y:[0,-3,0]},transition:a?Re:{y:{duration:3,repeat:1/0,ease:"easeInOut"}},whileHover:{scale:1.1,borderColor:"var(--bf-accent)"},whileTap:{scale:.9},children:[c?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{size:16})},"success"):jsxRuntime.jsx(Se,{size:16}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${r} queued`,children:r})]})]},"bubble")})}var Lt={duration:.2,ease:"easeOut"},zt={duration:0};function Ae(e){return e==="bottom-left"||e==="top-left"}function At(e){return `bf-trigger-edge ${Ae(e)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function Ie({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=react.useState(false),a=Ae(e),s=g(),m=s?zt:Lt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:At(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{opacity:0,width:0},animate:{opacity:1,width:i?140:22,height:i?40:90},exit:{width:0,opacity:0},transition:m,whileTap:{scale:.97},style:{top:"50%",translateY:"-50%"},children:c?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:m,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(framerMotion.motion.span,{animate:{rotate:s||i?0:a?-90:90,opacity:i?1:.6},transition:m,style:{display:"flex",alignItems:"center",gap:"8px",whiteSpace:"nowrap",fontSize:"12px",letterSpacing:"0.5px",textTransform:"uppercase"},children:[i&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:{duration:.12},style:{width:"6px",height:"6px",borderRadius:"50%",background:"var(--bf-accent)",flexShrink:0}}),o]}),jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",animate:{opacity:i?1:0},transition:{duration:.12},style:{position:"absolute",top:0,bottom:0,[a?"left":"right"]:0,width:"2px",background:"var(--bf-accent)"}}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"edge-tab")})}var _t={duration:.18,ease:"easeOut"},Ht={duration:0};function _e({delay:e,hovered:t,reduced:n}){return n?null:jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",width:"10px",height:"10px",borderRadius:"50%",border:"2px solid var(--bf-accent)",pointerEvents:"none"},animate:t?{scale:1,opacity:0}:{scale:[1,1.8],opacity:[.5,0]},transition:t?{duration:.15}:{duration:2,repeat:1/0,delay:e,ease:"easeOut"}})}function Oe({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=react.useState(false),a=g(),s=a?Ht:_t;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:c?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{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(_e,{delay:0,hovered:i,reduced:a}),jsxRuntime.jsx(_e,{delay:.7,hovered:i,reduced:a}),jsxRuntime.jsx(framerMotion.motion.span,{className:"bf-dot","aria-hidden":"true",style:{position:"relative",zIndex:1}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"pulse-ring")})}var $t={duration:.18,ease:"easeOut"},Ut={duration:0};function Xt(e){switch(e){case "bottom-left":return "bf-trigger-minimal bf-trigger-bl";case "top-right":return "bf-trigger-minimal bf-trigger-tr";case "top-left":return "bf-trigger-minimal bf-trigger-tl";default:return "bf-trigger-minimal"}}function $e({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=react.useState(false),a=g(),s=a?Ut:$t;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsxs(framerMotion.motion.button,{className:Xt(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{opacity:0,y:a?0:5},animate:{opacity:i?1:.65,y:0},exit:{opacity:0,y:a?0:5},transition:s,whileTap:{scale:.95},children:[c?jsxRuntime.jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{size:14})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:o}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${r} queued`,children:r})]}),!a&&jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",bottom:4,left:4,right:4,height:"2px",background:"var(--bf-accent)",borderRadius:"1px",transformOrigin:"left"},initial:false,animate:{scaleX:i?1:0},transition:s})]},"minimal")})}var Qt={duration:.18,ease:"easeOut"},jt={duration:0};function Xe({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=react.useState(false),a=g(),s=a?jt:Qt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.9},style:{overflow:"hidden"},children:c?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.span,{style:{display:"inline-flex",flexShrink:0},animate:a?{}:i?{scale:1.2,rotate:0}:{rotate:[-5,5,-5]},transition:i||a?s:{duration:3,repeat:1/0,ease:"easeInOut"},children:jsxRuntime.jsx(Pe,{size:16})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:a?0:-8},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-8},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"icon-pop")})}var Zt={duration:.18,ease:"easeOut"},eo={duration:0};function Qe({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=react.useState(false),a=g(),s=a?eo:Zt;return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:c?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{size:14})},"success"):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{width:"10px",height:"10px",borderRadius:"50%",background:"var(--bf-accent)",position:"relative",zIndex:1},animate:a?{}:{opacity:i?1:[.5,1,.5],boxShadow:i?"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:i||a?s:{duration:2,repeat:1/0,ease:"easeInOut"}}),!i&&!a&&jsxRuntime.jsx(framerMotion.motion.span,{"aria-hidden":"true",style:{position:"absolute",width:"18px",height:"2px",background:"linear-gradient(90deg, var(--bf-accent), transparent)",transformOrigin:"left center",left:"5px",top:"4px"},animate:{rotate:[0,360]},transition:{duration:4,repeat:1/0,ease:"linear"}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:i&&jsxRuntime.jsx(framerMotion.motion.span,{initial:{opacity:0,x:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"beacon")})}var io={duration:.18,ease:"easeOut"},no={duration:0};function Je({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=react.useState(false),[a,s]=react.useState(0),m=g(),M=m?no:io,p=react.useRef(null);react.useEffect(()=>{if(p.current&&(clearInterval(p.current),p.current=null),!n||i||m){s(i||m?o.length:0);return}let u=8,E=o.length*2+u*2,x=0;return p.current=setInterval(()=>{x=(x+1)%E,x<=o.length?s(x):x<=o.length+u?s(o.length):x<=o.length*2+u?s(o.length*2+u-x):s(0);},100),()=>{p.current&&(clearInterval(p.current),p.current=null);}},[n,i,m,o]);let T=o.slice(0,a);return jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:n&&jsxRuntime.jsx(framerMotion.motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{opacity:0,y:m?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:m?0:5},transition:M,whileTap:{scale:.95},style:{minWidth:"44px"},children:c?jsxRuntime.jsx(framerMotion.motion.span,{initial:{scale:0},animate:{scale:1},transition:M,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsxRuntime.jsx(b,{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:[T,jsxRuntime.jsx("span",{className:"bf-cursor","aria-hidden":"true"})]}),r>0&&jsxRuntime.jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"typewriter")})}function Ze(e){switch(e){case "dot":return Be;case "bubble":return Le;case "edge-tab":return Ie;case "pulse-ring":return Oe;case "minimal":return $e;case "icon-pop":return Xe;case "beacon":return Qe;case "typewriter":return Je;default:return Ce}}function tt(e,t,n){return Math.max(t,Math.min(n,e))}function fo(e,t,n="bottom-right"){let r=window.innerWidth,c=window.innerHeight,i;i=tt(e.x,12,Math.max(12,r-t-12));let l=e.y+e.height+12,a=Math.max(12,e.y-240);return {top:l+240<=c?l:a,left:i}}function uo(e){let{rect:t}=e,n={left:`${t.x}px`,top:`${t.y}px`,width:`${Math.max(0,t.width)}px`,height:`${Math.max(0,t.height)}px`};return jsxRuntime.jsx("div",{className:"bf-highlight",style:n,"aria-hidden":"true"})}function bo(e){let t=react.useRef(null);return react.useEffect(()=>{if(!e||!t.current)return;t.current.querySelector(".bf-textarea")?.focus();let o=r=>{if(r.key!=="Tab"||!t.current)return;let c=t.current.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(c.length===0)return;let i=c[0],l=c[c.length-1];r.shiftKey&&document.activeElement===i?(r.preventDefault(),l.focus()):!r.shiftKey&&document.activeElement===l&&(r.preventDefault(),i.focus());};return document.addEventListener("keydown",o,{capture:true}),()=>document.removeEventListener("keydown",o,{capture:true})},[e]),t}function go(e,t){return e?typeof e=="function"?e(t):e.some(n=>n.endsWith("*")?t.startsWith(n.slice(0,-1)):t===n):true}function mo(e){let[t,n]=react.useState(()=>typeof window<"u"?window.location.pathname:"/");return react.useEffect(()=>{if(typeof window>"u")return;let o=()=>n(window.location.pathname);window.addEventListener("popstate",o);let r=history.pushState,c=history.replaceState;return history.pushState=function(...i){r.apply(this,i),o();},history.replaceState=function(...i){c.apply(this,i),o();},()=>{window.removeEventListener("popstate",o),history.pushState=r,history.replaceState=c;}},[]),go(e,t)}function ho(e){let[t,n]=react.useState(()=>!e||e==="dark"?"dark":e==="light"?"light":typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return react.useEffect(()=>{if(e!=="auto"){n(e==="light"?"light":"dark");return}let o=window.matchMedia("(prefers-color-scheme: dark)"),r=c=>n(c.matches?"dark":"light");return n(o.matches?"dark":"light"),o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[e]),t}var xo=["bug","feature","ux","general"],yo={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function wo(e){let{state:t,controller:n,start:o,stop:r,clearSelection:c,submit:i}=te(),l=e.config.ui?.position,a=Te(e.config.ui?.strings),s=e.config.ui?.branding!==false,[m,M]=react.useState(null),[p,T]=react.useState(""),[u,E]=react.useState(e.config.capture?.element??true),[x,re]=react.useState(e.config.capture?.fullPage??false),[rt,ae]=react.useState(null),[O,ie]=react.useState(void 0),ne=e.config.ui?.categories??xo,[at,it]=react.useState(false),[j,nt]=react.useState(0);react.useEffect(()=>{let d=window.setTimeout(()=>{let N=chunkJVY6JTXP_cjs.p();nt(N.findings.length);},500);return ()=>window.clearTimeout(d)},[]),react.useImperativeHandle(e.handleRef,()=>({open:o,close:r,submit:d=>i(d),get isOpen(){return t.phase!=="idle"}}),[o,r,i,t.phase]);let se=t.phase==="review"||t.phase==="capturing"||t.phase==="submitting"||t.phase==="error"||t.phase==="success",st=bo(se),[lt,ct]=react.useState(0);react.useEffect(()=>{t.phase==="idle"&&ct(chunkJVY6JTXP_cjs.i());},[t.phase]);let[dt,le]=react.useState(false),ce=react.useRef(t.phase);react.useEffect(()=>{if(ce.current==="success"&&t.phase==="idle"){le(true);let d=window.setTimeout(()=>le(false),1500);return ()=>window.clearTimeout(d)}ce.current=t.phase;},[t.phase]),react.useEffect(()=>{let d=e.config.ui?.shortcut;if(!d)return;let N=d.toLowerCase().split("+").map(P=>P.trim()),W=N[N.length-1]||"",L=new Set(N.slice(0,-1)),pe=P=>{let ut=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(L.has("mod")){if(ut?!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()===W&&(P.preventDefault(),t.phase==="idle"?o():r());};return document.addEventListener("keydown",pe),()=>document.removeEventListener("keydown",pe)},[e.config.ui?.shortcut,t.phase,o,r]),react.useEffect(()=>n.subscribeHover(M),[n]),react.useEffect(()=>{let d=n.__unsafeGetSelectedElement();if(!d||t.phase==="idle"||t.phase==="picking"){ae(null);return}let N=()=>{ae(chunkJVY6JTXP_cjs.b(d.getBoundingClientRect()));};N();let W=()=>N();return window.addEventListener("scroll",W,{capture:true,passive:true}),window.addEventListener("resize",W,{passive:true}),()=>{window.removeEventListener("scroll",W,{capture:true}),window.removeEventListener("resize",W);}},[n,t.phase,t.selection?.selector]),react.useEffect(()=>{t.phase==="review"&&(T(""),E(e.config.capture?.element??true),re(e.config.capture?.fullPage??false),ie(void 0));},[t.phase,t.selection?.selector,e.config.capture?.element,e.config.capture?.fullPage]),react.useEffect(()=>{if(t.phase!=="success")return;let d=window.setTimeout(()=>r(),1200);return ()=>window.clearTimeout(d)},[t.phase,r]);let S=t.phase==="capturing"||t.phase==="submitting",B=t.phase==="picking"?m?.rect??null:rt??t.selection?.rect??null,V=react.useMemo(()=>B?fo(B,360,l):null,[B?.x,B?.y,B?.width,B?.height,l]),de=t.lastError?.message,q=react.useCallback(()=>{let d={capture:{element:u,fullPage:x}};O&&(d.category=O),i(p,d);},[i,p,u,x,O]),pt=react.useCallback(d=>{(d.metaKey||d.ctrlKey)&&d.key==="Enter"&&p.trim().length>0&&!S&&(d.preventDefault(),q());},[q,p,S]),ft=Ze(e.config.ui?.triggerStyle);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ft,{position:l,onClick:()=>o(),isVisible:t.phase==="idle",label:e.config.ui?.triggerLabel??a.triggerLabel,queueCount:lt,showSuccess:dt}),t.phase!=="idle"&&jsxRuntime.jsxs("div",{className:"bf-overlay",role:"presentation",children:[t.phase!=="picking"&&jsxRuntime.jsx("div",{className:"bf-blocker",role:"presentation",onClick:()=>r()}),B&&jsxRuntime.jsx(uo,{rect:B}),t.phase==="picking"&&jsxRuntime.jsxs("div",{className:"bf-hint",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("p",{id:"bf-hint-text",children:a.hintText}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),"aria-label":a.cancelButton,children:a.cancelButton})]}),se&&V&&jsxRuntime.jsxs("div",{ref:st,className:"bf-panel",style:{left:V.left,top:V.top},role:"dialog","aria-modal":"true","aria-label":"Feedback form",children:[jsxRuntime.jsxs("div",{className:"bf-panelHeader",children:[jsxRuntime.jsx("div",{className:"bf-title",id:"bf-panel-title",children:a.panelTitle}),jsxRuntime.jsxs("div",{className:"bf-row",style:{justifyContent:"flex-end"},children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>c(),disabled:S,"aria-label":a.rePickButton,children:a.rePickButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),disabled:S,"aria-label":a.closeButton,children:a.closeButton})]})]}),jsxRuntime.jsxs("div",{className:"bf-panelBody",children:[jsxRuntime.jsx("textarea",{className:"bf-textarea",placeholder:a.textareaPlaceholder,value:p,onChange:d=>T(d.target.value),onKeyDown:pt,disabled:S,"aria-label":a.panelTitle}),ne.length>0&&jsxRuntime.jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:ne.map(d=>jsxRuntime.jsx("button",{type:"button",className:`bf-pill${O===d?" bf-pill-active":""}`,onClick:()=>ie(O===d?void 0:d),disabled:S,children:a[yo[d]]},d))}),jsxRuntime.jsxs("div",{className:"bf-row",role:"group","aria-label":a.screenshotElement,children:[jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:u,onChange:d=>E(d.target.checked),disabled:S}),a.screenshotElement]}),jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:x,onChange:d=>re(d.target.checked),disabled:S}),a.screenshotFullPage]})]}),t.phase==="capturing"&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),a.capturingText]}),t.phase==="submitting"&&jsxRuntime.jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"bf-spinner","aria-hidden":"true"}),a.submittingText]}),t.phase==="success"&&jsxRuntime.jsx("div",{className:"bf-status",role:"status","aria-live":"polite",children:a.successText}),t.phase==="error"&&de&&jsxRuntime.jsx("div",{className:"bf-error",role:"alert",children:de}),jsxRuntime.jsxs("div",{className:"bf-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),disabled:S,"aria-label":a.cancelButton,children:a.cancelButton}),jsxRuntime.jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:q,disabled:S||p.trim().length===0,"aria-label":a.sendButton,children:a.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"})})]})]}),t.phase==="success"&&jsxRuntime.jsx("div",{className:"bf-toast",role:"status","aria-live":"polite",children:a.toastText}),j>0&&!at&&jsxRuntime.jsxs("div",{className:"bf-security-banner",role:"alert",children:[jsxRuntime.jsx("button",{type:"button",className:"bf-security-banner-dismiss",onClick:()=>it(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 vo=react.forwardRef(function(t,n){let o={...t.config??{},blocfeed_id:t.blocfeed_id},[r,c]=react.useState(null),i=mo(o.ui?.showOn),l=ho(o.ui?.theme?.mode),a=!!o.diagnostics;react.useEffect(()=>{if(a)return chunkJVY6JTXP_cjs.k(o.diagnostics),()=>chunkJVY6JTXP_cjs.l()},[a]);let s=!!o.security;react.useEffect(()=>{s&&chunkJVY6JTXP_cjs.o(o.security);},[s]);let m=react.useRef(t.config?.metadata?.enrich);m.current=t.config?.metadata?.enrich;let M=react.useMemo(()=>{if(t.config)return {...t.config,metadata:{...t.config.metadata,enrich:async p=>{let T=m.current,u=T?await T(p):{},E=chunkJVY6JTXP_cjs.m(),x=chunkJVY6JTXP_cjs.p();return {...u,...E.consoleLogs.length>0?{_consoleLogs:E.consoleLogs}:{},...E.networkErrors.length>0?{_networkErrors:E.networkErrors}:{},...x.findings.length>0?{_securityFindings:x.findings}:{}}}}}},[]);return react.useEffect(()=>{ve();let p=document.createElement("div");p.setAttribute("data-blocfeed-ui-root","true"),p.setAttribute("data-blocfeed-ui","true"),p.setAttribute("data-bf-theme",l);let T=o.ui?.zIndex;typeof T=="number"&&p.style.setProperty("--bf-z",String(T));let u=o.ui?.theme;return u&&(u.accentColor&&p.style.setProperty("--bf-accent",u.accentColor),u.panelBackground&&p.style.setProperty("--bf-panel-bg",u.panelBackground),u.panelForeground&&p.style.setProperty("--bf-panel-fg",u.panelForeground),u.fontFamily&&p.style.setProperty("--bf-font",u.fontFamily)),document.body.appendChild(p),c(p),()=>{p.remove(),c(null);}},[o.ui?.zIndex,o.ui?.theme?.accentColor,o.ui?.theme?.panelBackground,o.ui?.theme?.panelForeground,o.ui?.theme?.fontFamily,l]),react.useEffect(()=>{r&&r.setAttribute("data-bf-theme",l);},[r,l]),!i||!r?null:reactDom.createPortal(jsxRuntime.jsx(ee,{blocfeed_id:o.blocfeed_id,...M?{config:M}:{},children:jsxRuntime.jsx(wo,{config:o,handleRef:n})}),r)});
639
+ exports.BlocFeedProvider=ee;exports.BlocFeedWidget=vo;exports.useBlocFeed=te;
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-hJ_lZRbR.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 Rect, n as ScreenshotAdapter, o as ScreenshotAdapterOptions, p as ScreenshotIntent, q as ScreenshotMime, r as SessionPhase, T as ThemeConfig, s as TransportConfig, t as TransportResult, u as TriggerStyle, W as WidgetPosition } from './controller-hJ_lZRbR.cjs';
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-BPsU7cuY.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 Rect, n as ScreenshotAdapter, o as ScreenshotAdapterOptions, p as ScreenshotIntent, q as ScreenshotMime, r as SecurityConfig, s as SecurityFinding, t as SecuritySnapshot, u as SessionPhase, T as ThemeConfig, v as TransportConfig, w as TransportResult, x as TriggerStyle, W as WidgetPosition } from './controller-BPsU7cuY.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-hJ_lZRbR.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 Rect, n as ScreenshotAdapter, o as ScreenshotAdapterOptions, p as ScreenshotIntent, q as ScreenshotMime, r as SessionPhase, T as ThemeConfig, s as TransportConfig, t as TransportResult, u as TriggerStyle, W as WidgetPosition } from './controller-hJ_lZRbR.js';
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-BPsU7cuY.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 Rect, n as ScreenshotAdapter, o as ScreenshotAdapterOptions, p as ScreenshotIntent, q as ScreenshotMime, r as SecurityConfig, s as SecurityFinding, t as SecuritySnapshot, u as SessionPhase, T as ThemeConfig, v as TransportConfig, w as TransportResult, x as TriggerStyle, W as WidgetPosition } from './controller-BPsU7cuY.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 {k,l,m as m$1,a,j,i,b as b$1}from'./chunk-DVNOWOIG.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 U=createContext(null);function J(e){let t=useMemo(()=>j({...e.config??{},blocfeed_id:e.blocfeed_id}),[]),[i,o]=useState(()=>t.getState());return useEffect(()=>t.subscribe(o),[t]),useEffect(()=>t.setConfig({...e.config??{},blocfeed_id:e.blocfeed_id}),[t,e.config,e.blocfeed_id]),useEffect(()=>()=>t.destroy(),[t]),jsx(U.Provider,{value:{controller:t,state:i},children:e.children})}var he="blocfeed-styles-v1",ft=`
2
+ import {k,l,o,m,p,a,j,i,b as b$1}from'./chunk-LAK7UUTC.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 U=createContext(null);function ee(e){let t=useMemo(()=>j({...e.config??{},blocfeed_id:e.blocfeed_id}),[]),[n,o]=useState(()=>t.getState());return useEffect(()=>t.subscribe(o),[t]),useEffect(()=>t.setConfig({...e.config??{},blocfeed_id:e.blocfeed_id}),[t,e.config,e.blocfeed_id]),useEffect(()=>()=>t.destroy(),[t]),jsx(U.Provider,{value:{controller:t,state:n},children:e.children})}var we="blocfeed-styles-v1",xt=`
3
3
  :where([data-blocfeed-ui-root]),
4
4
  :where([data-blocfeed-ui-root]) * {
5
5
  box-sizing: border-box;
@@ -548,6 +548,57 @@ import {k,l,m as m$1,a,j,i,b as b$1}from'./chunk-DVNOWOIG.js';import {createCont
548
548
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
549
549
  }
550
550
 
551
+ /* ------------------------------------------------------------------ */
552
+ /* Security warning banner */
553
+ /* ------------------------------------------------------------------ */
554
+
555
+ :where([data-blocfeed-ui-root]) .bf-security-banner {
556
+ position: fixed;
557
+ top: 8px;
558
+ right: 8px;
559
+ z-index: var(--bf-z);
560
+ max-width: 360px;
561
+ padding: 10px 14px;
562
+ border-radius: 10px;
563
+ border-left: 3px solid var(--bf-danger);
564
+ background: rgba(239, 68, 68, 0.12);
565
+ color: rgb(254, 202, 202);
566
+ font-family: var(--bf-font);
567
+ font-size: 12px;
568
+ line-height: 1.5;
569
+ pointer-events: auto;
570
+ animation: bf-panel-in 0.2s ease-out;
571
+ }
572
+
573
+ :where([data-blocfeed-ui-root][data-bf-theme="light"]) .bf-security-banner {
574
+ background: rgba(239, 68, 68, 0.08);
575
+ color: rgb(185, 28, 28);
576
+ }
577
+
578
+ :where([data-blocfeed-ui-root]) .bf-security-banner strong {
579
+ display: block;
580
+ margin-bottom: 4px;
581
+ font-size: 13px;
582
+ }
583
+
584
+ :where([data-blocfeed-ui-root]) .bf-security-banner-dismiss {
585
+ position: absolute;
586
+ top: 6px;
587
+ right: 6px;
588
+ background: none;
589
+ border: none;
590
+ color: inherit;
591
+ opacity: 0.6;
592
+ cursor: pointer;
593
+ padding: 2px 4px;
594
+ font-size: 14px;
595
+ line-height: 1;
596
+ }
597
+
598
+ :where([data-blocfeed-ui-root]) .bf-security-banner-dismiss:hover {
599
+ opacity: 1;
600
+ }
601
+
551
602
  /* ------------------------------------------------------------------ */
552
603
  /* Reduced motion */
553
604
  /* ------------------------------------------------------------------ */
@@ -584,5 +635,5 @@ import {k,l,m as m$1,a,j,i,b as b$1}from'./chunk-DVNOWOIG.js';import {createCont
584
635
  animation: none;
585
636
  }
586
637
  }
587
- `;function xe(){if(!a()||document.getElementById(he))return;let e=document.createElement("style");e.id=he,e.textContent=ft,document.head.appendChild(e);}var ye={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"};function we(e){return e?{...ye,...e}:ye}function Z(){let e=useContext(U);if(!e)throw new Error("useBlocFeed must be used within a <BlocFeedProvider />");return {state:e.state,controller:e.controller,start:e.controller.start,stop:e.controller.stop,clearSelection:e.controller.clearSelection,submit:e.controller.submit}}function x(e){switch(e){case "bottom-left":return "bf-trigger bf-trigger-bl";case "top-right":return "bf-trigger bf-trigger-tr";case "top-left":return "bf-trigger bf-trigger-tl";default:return "bf-trigger"}}function b({size:e=14}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M20 6L9 17l-5-5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function ve({size:e=14}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M21 11.5a8.38 8.38 0 01-.9 3.8 8.5 8.5 0 01-7.6 4.7 8.38 8.38 0 01-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 01-.9-3.8 8.5 8.5 0 014.7-7.6 8.38 8.38 0 013.8-.9h.5a8.48 8.48 0 018 8v.5z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function ke({size:e=16}){return jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M22 6l-10 7L2 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Pe({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){return i?jsxs("button",{className:x(e),type:"button",onClick:t,"aria-label":o,children:[c?jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{size:14})}):jsxs(Fragment,{children:[jsx("span",{className:"bf-dot","aria-hidden":"true"}),o]}),r>0&&jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]}):null}function m(){let[e,t]=useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return useEffect(()=>{let i=window.matchMedia("(prefers-reduced-motion: reduce)"),o=r=>t(r.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}var yt={duration:.18,ease:"easeOut"},wt={duration:0};function Ce({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=useState(false),a=m(),s=a?wt:yt;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:x(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:c?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{size:14})},"success"):jsxs(Fragment,{children:[jsx(motion.span,{className:"bf-dot","aria-hidden":"true",animate:a?{}:{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||a?s:{duration:2,repeat:1/0,ease:"easeInOut"}}),jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.span,{initial:{opacity:0,x:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"dot")})}var Pt={duration:.18,ease:"easeOut"},Fe={duration:0};function Ne({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=useState(false),a=m(),s=a?Fe:Pt;return jsx(AnimatePresence,{mode:"wait",children:i&&jsxs(motion.div,{className:x(e),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:a?0:4},animate:{opacity:1,y:0},exit:{opacity:0,y:a?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:o},"tooltip")}),jsxs(motion.button,{type:"button",onClick:t,"aria-label":o,style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"40px",borderRadius:"50%",border:"1px solid var(--bf-border)",background:"var(--bf-panel-bg)",color:"var(--bf-panel-fg)",boxShadow:"var(--bf-shadow)",cursor:"pointer",padding:0},animate:a?{}:{y:[0,-3,0]},transition:a?Fe:{y:{duration:3,repeat:1/0,ease:"easeInOut"}},whileHover:{scale:1.1,borderColor:"var(--bf-accent)"},whileTap:{scale:.9},children:[c?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{size:16})},"success"):jsx(ve,{size:16}),r>0&&jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${r} queued`,children:r})]})]},"bubble")})}var St={duration:.2,ease:"easeOut"},Ft={duration:0};function Me(e){return e==="bottom-left"||e==="top-left"}function Bt(e){return `bf-trigger-edge ${Me(e)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function Le({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=useState(false),a=Me(e),s=m(),h=s?Ft:St;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:Bt(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,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:c?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:h,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{size:14})},"success"):jsxs(Fragment,{children:[jsxs(motion.span,{animate:{rotate:s||n?0:a?-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}}),o]}),jsx(motion.span,{"aria-hidden":"true",animate:{opacity:n?1:0},transition:{duration:.12},style:{position:"absolute",top:0,bottom:0,[a?"left":"right"]:0,width:"2px",background:"var(--bf-accent)"}}),r>0&&jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"edge-tab")})}var Mt={duration:.18,ease:"easeOut"},Lt={duration:0};function ze({delay:e,hovered:t,reduced:i}){return i?null:jsx(motion.span,{"aria-hidden":"true",style:{position:"absolute",width:"10px",height:"10px",borderRadius:"50%",border:"2px solid var(--bf-accent)",pointerEvents:"none"},animate:t?{scale:1,opacity:0}:{scale:[1,1.8],opacity:[.5,0]},transition:t?{duration:.15}:{duration:2,repeat:1/0,delay:e,ease:"easeOut"}})}function We({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=useState(false),a=m(),s=a?Lt:Mt;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:x(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:c?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{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(ze,{delay:0,hovered:n,reduced:a}),jsx(ze,{delay:.7,hovered:n,reduced:a}),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:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"pulse-ring")})}var Wt={duration:.18,ease:"easeOut"},_t={duration:0};function Ht(e){switch(e){case "bottom-left":return "bf-trigger-minimal bf-trigger-bl";case "top-right":return "bf-trigger-minimal bf-trigger-tr";case "top-left":return "bf-trigger-minimal bf-trigger-tl";default:return "bf-trigger-minimal"}}function Oe({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=useState(false),a=m(),s=a?_t:Wt;return jsx(AnimatePresence,{mode:"wait",children:i&&jsxs(motion.button,{className:Ht(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{opacity:0,y:a?0:5},animate:{opacity:n?1:.65,y:0},exit:{opacity:0,y:a?0:5},transition:s,whileTap:{scale:.95},children:[c?jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{size:14})}):jsxs(Fragment,{children:[jsx("span",{children:o}),r>0&&jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${r} queued`,children:r})]}),!a&&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 Kt={duration:.18,ease:"easeOut"},$t={duration:0};function Ke({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=useState(false),a=m(),s=a?$t:Kt;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:x(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.9},style:{overflow:"hidden"},children:c?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{size:14})},"success"):jsxs(Fragment,{children:[jsx(motion.span,{style:{display:"inline-flex",flexShrink:0},animate:a?{}:n?{scale:1.2,rotate:0}:{rotate:[-5,5,-5]},transition:n||a?s:{duration:3,repeat:1/0,ease:"easeInOut"},children:jsx(ke,{size:16})}),jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.span,{initial:{opacity:0,x:a?0:-8},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-8},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"icon-pop")})}var Gt={duration:.18,ease:"easeOut"},Qt={duration:0};function Xe({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=useState(false),a=m(),s=a?Qt:Gt;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:x(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:c?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{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:a?{}:{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||a?s:{duration:2,repeat:1/0,ease:"easeInOut"}}),!n&&!a&&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:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"beacon")})}var Zt={duration:.18,ease:"easeOut"},eo={duration:0};function je({position:e,onClick:t,isVisible:i,label:o,queueCount:r,showSuccess:c}){let[n,l]=useState(false),[a,s]=useState(0),h=m(),u=h?eo:Zt,f=useRef(null);useEffect(()=>{if(f.current&&(clearInterval(f.current),f.current=null),!i||n||h){s(n||h?o.length:0);return}let y=8,$=o.length*2+y*2,k=0;return f.current=setInterval(()=>{k=(k+1)%$,k<=o.length?s(k):k<=o.length+y?s(o.length):k<=o.length*2+y?s(o.length*2+y-k):s(0);},100),()=>{f.current&&(clearInterval(f.current),f.current=null);}},[i,n,h,o]);let g=o.slice(0,a);return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:x(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{opacity:0,y:h?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:h?0:5},transition:u,whileTap:{scale:.95},style:{minWidth:"44px"},children:c?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:u,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{size:14})},"success"):jsxs(Fragment,{children:[jsx("span",{className:"bf-dot","aria-hidden":"true"}),jsxs("span",{style:{whiteSpace:"nowrap",minWidth:"1ch"},children:[g,jsx("span",{className:"bf-cursor","aria-hidden":"true"})]}),r>0&&jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"typewriter")})}function Ve(e){switch(e){case "dot":return Ce;case "bubble":return Ne;case "edge-tab":return Le;case "pulse-ring":return We;case "minimal":return Oe;case "icon-pop":return Ke;case "beacon":return Xe;case "typewriter":return je;default:return Pe}}function Je(e,t,i){return Math.max(t,Math.min(i,e))}function no(e,t,i="bottom-right"){let r=window.innerWidth,c=window.innerHeight,n;n=Je(e.x,12,Math.max(12,r-t-12));let l=e.y+e.height+12,a=Math.max(12,e.y-240);return {top:l+240<=c?l:a,left:n}}function io(e){let{rect:t}=e,i={left:`${t.x}px`,top:`${t.y}px`,width:`${Math.max(0,t.width)}px`,height:`${Math.max(0,t.height)}px`};return jsx("div",{className:"bf-highlight",style:i,"aria-hidden":"true"})}function so(e){let t=useRef(null);return useEffect(()=>{if(!e||!t.current)return;t.current.querySelector(".bf-textarea")?.focus();let o=r=>{if(r.key!=="Tab"||!t.current)return;let c=t.current.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(c.length===0)return;let n=c[0],l=c[c.length-1];r.shiftKey&&document.activeElement===n?(r.preventDefault(),l.focus()):!r.shiftKey&&document.activeElement===l&&(r.preventDefault(),n.focus());};return document.addEventListener("keydown",o,{capture:true}),()=>document.removeEventListener("keydown",o,{capture:true})},[e]),t}function lo(e,t){return e?typeof e=="function"?e(t):e.some(i=>i.endsWith("*")?t.startsWith(i.slice(0,-1)):t===i):true}function co(e){let[t,i]=useState(()=>typeof window<"u"?window.location.pathname:"/");return useEffect(()=>{if(typeof window>"u")return;let o=()=>i(window.location.pathname);window.addEventListener("popstate",o);let r=history.pushState,c=history.replaceState;return history.pushState=function(...n){r.apply(this,n),o();},history.replaceState=function(...n){c.apply(this,n),o();},()=>{window.removeEventListener("popstate",o),history.pushState=r,history.replaceState=c;}},[]),lo(e,t)}function po(e){let[t,i]=useState(()=>!e||e==="dark"?"dark":e==="light"?"light":typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return useEffect(()=>{if(e!=="auto"){i(e==="light"?"light":"dark");return}let o=window.matchMedia("(prefers-color-scheme: dark)"),r=c=>i(c.matches?"dark":"light");return i(o.matches?"dark":"light"),o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[e]),t}var fo=["bug","feature","ux","general"],uo={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function bo(e){let{state:t,controller:i$1,start:o,stop:r,clearSelection:c,submit:n}=Z(),l=e.config.ui?.position,a=we(e.config.ui?.strings),s=e.config.ui?.branding!==false,[h,u]=useState(null),[f,g]=useState(""),[y,$]=useState(e.config.capture?.element??true),[k,te]=useState(e.config.capture?.fullPage??false),[et,oe]=useState(null),[H,re]=useState(void 0),ae=e.config.ui?.categories??fo;useImperativeHandle(e.handleRef,()=>({open:o,close:r,submit:d=>n(d),get isOpen(){return t.phase!=="idle"}}),[o,r,n,t.phase]);let ne=t.phase==="review"||t.phase==="capturing"||t.phase==="submitting"||t.phase==="error"||t.phase==="success",tt=so(ne),[ot,rt]=useState(0);useEffect(()=>{t.phase==="idle"&&rt(i());},[t.phase]);let[at,ie]=useState(false),se=useRef(t.phase);useEffect(()=>{if(se.current==="success"&&t.phase==="idle"){ie(true);let d=window.setTimeout(()=>ie(false),1500);return ()=>window.clearTimeout(d)}se.current=t.phase;},[t.phase]),useEffect(()=>{let d=e.config.ui?.shortcut;if(!d)return;let z=d.toLowerCase().split("+").map(C=>C.trim()),I=z[z.length-1]||"",R=new Set(z.slice(0,-1)),ce=C=>{let st=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(R.has("mod")){if(st?!C.metaKey:!C.ctrlKey)return}else if(R.has("ctrl")&&!C.ctrlKey||(R.has("meta")||R.has("cmd"))&&!C.metaKey)return;R.has("shift")&&!C.shiftKey||(R.has("alt")||R.has("option"))&&!C.altKey||C.key.toLowerCase()===I&&(C.preventDefault(),t.phase==="idle"?o():r());};return document.addEventListener("keydown",ce),()=>document.removeEventListener("keydown",ce)},[e.config.ui?.shortcut,t.phase,o,r]),useEffect(()=>i$1.subscribeHover(u),[i$1]),useEffect(()=>{let d=i$1.__unsafeGetSelectedElement();if(!d||t.phase==="idle"||t.phase==="picking"){oe(null);return}let z=()=>{oe(b$1(d.getBoundingClientRect()));};z();let I=()=>z();return window.addEventListener("scroll",I,{capture:true,passive:true}),window.addEventListener("resize",I,{passive:true}),()=>{window.removeEventListener("scroll",I,{capture:true}),window.removeEventListener("resize",I);}},[i$1,t.phase,t.selection?.selector]),useEffect(()=>{t.phase==="review"&&(g(""),$(e.config.capture?.element??true),te(e.config.capture?.fullPage??false),re(void 0));},[t.phase,t.selection?.selector,e.config.capture?.element,e.config.capture?.fullPage]),useEffect(()=>{if(t.phase!=="success")return;let d=window.setTimeout(()=>r(),1200);return ()=>window.clearTimeout(d)},[t.phase,r]);let E=t.phase==="capturing"||t.phase==="submitting",B=t.phase==="picking"?h?.rect??null:et??t.selection?.rect??null,j=useMemo(()=>B?no(B,360,l):null,[B?.x,B?.y,B?.width,B?.height,l]),le=t.lastError?.message,V=useCallback(()=>{let d={capture:{element:y,fullPage:k}};H&&(d.category=H),n(f,d);},[n,f,y,k,H]),nt=useCallback(d=>{(d.metaKey||d.ctrlKey)&&d.key==="Enter"&&f.trim().length>0&&!E&&(d.preventDefault(),V());},[V,f,E]),it=Ve(e.config.ui?.triggerStyle);return jsxs(Fragment,{children:[jsx(it,{position:l,onClick:()=>o(),isVisible:t.phase==="idle",label:e.config.ui?.triggerLabel??a.triggerLabel,queueCount:ot,showSuccess:at}),t.phase!=="idle"&&jsxs("div",{className:"bf-overlay",role:"presentation",children:[t.phase!=="picking"&&jsx("div",{className:"bf-blocker",role:"presentation",onClick:()=>r()}),B&&jsx(io,{rect:B}),t.phase==="picking"&&jsxs("div",{className:"bf-hint",role:"status","aria-live":"polite",children:[jsx("p",{id:"bf-hint-text",children:a.hintText}),jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),"aria-label":a.cancelButton,children:a.cancelButton})]}),ne&&j&&jsxs("div",{ref:tt,className:"bf-panel",style:{left:j.left,top:j.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:a.panelTitle}),jsxs("div",{className:"bf-row",style:{justifyContent:"flex-end"},children:[jsx("button",{type:"button",className:"bf-btn",onClick:()=>c(),disabled:E,"aria-label":a.rePickButton,children:a.rePickButton}),jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),disabled:E,"aria-label":a.closeButton,children:a.closeButton})]})]}),jsxs("div",{className:"bf-panelBody",children:[jsx("textarea",{className:"bf-textarea",placeholder:a.textareaPlaceholder,value:f,onChange:d=>g(d.target.value),onKeyDown:nt,disabled:E,"aria-label":a.panelTitle}),ae.length>0&&jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:ae.map(d=>jsx("button",{type:"button",className:`bf-pill${H===d?" bf-pill-active":""}`,onClick:()=>re(H===d?void 0:d),disabled:E,children:a[uo[d]]},d))}),jsxs("div",{className:"bf-row",role:"group","aria-label":a.screenshotElement,children:[jsxs("label",{children:[jsx("input",{type:"checkbox",checked:y,onChange:d=>$(d.target.checked),disabled:E}),a.screenshotElement]}),jsxs("label",{children:[jsx("input",{type:"checkbox",checked:k,onChange:d=>te(d.target.checked),disabled:E}),a.screenshotFullPage]})]}),t.phase==="capturing"&&jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsx("span",{className:"bf-spinner","aria-hidden":"true"}),a.capturingText]}),t.phase==="submitting"&&jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsx("span",{className:"bf-spinner","aria-hidden":"true"}),a.submittingText]}),t.phase==="success"&&jsx("div",{className:"bf-status",role:"status","aria-live":"polite",children:a.successText}),t.phase==="error"&&le&&jsx("div",{className:"bf-error",role:"alert",children:le}),jsxs("div",{className:"bf-actions",children:[jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),disabled:E,"aria-label":a.cancelButton,children:a.cancelButton}),jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:V,disabled:E||f.trim().length===0,"aria-label":a.sendButton,children:a.sendButton})]})]}),s&&jsx("div",{className:"bf-watermark",children:jsx("a",{href:"https://blocfeed.com",target:"_blank",rel:"noopener noreferrer",children:"Powered by BlocFeed"})})]})]}),t.phase==="success"&&jsx("div",{className:"bf-toast",role:"status","aria-live":"polite",children:a.toastText})]})}var go=forwardRef(function(t,i){let o={...t.config??{},blocfeed_id:t.blocfeed_id},[r,c]=useState(null),n=co(o.ui?.showOn),l$1=po(o.ui?.theme?.mode),a=!!o.diagnostics;useEffect(()=>{if(a)return k(o.diagnostics),()=>l()},[a]);let s=useRef(t.config?.metadata?.enrich);s.current=t.config?.metadata?.enrich;let h=useMemo(()=>{if(t.config)return {...t.config,metadata:{...t.config.metadata,enrich:async u=>{let f=s.current,g=f?await f(u):{},y=m$1();return {...g,...y.consoleLogs.length>0?{_consoleLogs:y.consoleLogs}:{},...y.networkErrors.length>0?{_networkErrors:y.networkErrors}:{}}}}}},[]);return useEffect(()=>{xe();let u=document.createElement("div");u.setAttribute("data-blocfeed-ui-root","true"),u.setAttribute("data-blocfeed-ui","true"),u.setAttribute("data-bf-theme",l$1);let f=o.ui?.zIndex;typeof f=="number"&&u.style.setProperty("--bf-z",String(f));let g=o.ui?.theme;return g&&(g.accentColor&&u.style.setProperty("--bf-accent",g.accentColor),g.panelBackground&&u.style.setProperty("--bf-panel-bg",g.panelBackground),g.panelForeground&&u.style.setProperty("--bf-panel-fg",g.panelForeground),g.fontFamily&&u.style.setProperty("--bf-font",g.fontFamily)),document.body.appendChild(u),c(u),()=>{u.remove(),c(null);}},[o.ui?.zIndex,o.ui?.theme?.accentColor,o.ui?.theme?.panelBackground,o.ui?.theme?.panelForeground,o.ui?.theme?.fontFamily,l$1]),useEffect(()=>{r&&r.setAttribute("data-bf-theme",l$1);},[r,l$1]),!n||!r?null:createPortal(jsx(J,{blocfeed_id:o.blocfeed_id,...h?{config:h}:{},children:jsx(bo,{config:o,handleRef:i})}),r)});
588
- export{J as BlocFeedProvider,go as BlocFeedWidget,Z as useBlocFeed};
638
+ `;function ve(){if(!a()||document.getElementById(we))return;let e=document.createElement("style");e.id=we,e.textContent=xt,document.head.appendChild(e);}var ke={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"};function Te(e){return e?{...ke,...e}:ke}function te(){let e=useContext(U);if(!e)throw new Error("useBlocFeed must be used within a <BlocFeedProvider />");return {state:e.state,controller:e.controller,start:e.controller.start,stop:e.controller.stop,clearSelection:e.controller.clearSelection,submit:e.controller.submit}}function y(e){switch(e){case "bottom-left":return "bf-trigger bf-trigger-bl";case "top-right":return "bf-trigger bf-trigger-tr";case "top-left":return "bf-trigger bf-trigger-tl";default:return "bf-trigger"}}function b({size:e=14}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M20 6L9 17l-5-5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Se({size:e=14}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M21 11.5a8.38 8.38 0 01-.9 3.8 8.5 8.5 0 01-7.6 4.7 8.38 8.38 0 01-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 01-.9-3.8 8.5 8.5 0 014.7-7.6 8.38 8.38 0 013.8-.9h.5a8.48 8.48 0 018 8v.5z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Pe({size:e=16}){return jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M22 6l-10 7L2 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ce({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){return n?jsxs("button",{className:y(e),type:"button",onClick:t,"aria-label":o,children:[c?jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{size:14})}):jsxs(Fragment,{children:[jsx("span",{className:"bf-dot","aria-hidden":"true"}),o]}),r>0&&jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]}):null}function g(){let[e,t]=useState(()=>typeof window>"u"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return useEffect(()=>{let n=window.matchMedia("(prefers-reduced-motion: reduce)"),o=r=>t(r.matches);return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[]),e}var Pt={duration:.18,ease:"easeOut"},Et={duration:0};function Be({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=useState(false),a=g(),s=a?Et:Pt;return jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:c?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{size:14})},"success"):jsxs(Fragment,{children:[jsx(motion.span,{className:"bf-dot","aria-hidden":"true",animate:a?{}:{scale:i?1:[1,1.2,1],boxShadow:i?"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:i||a?s:{duration:2,repeat:1/0,ease:"easeInOut"}}),jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.span,{initial:{opacity:0,x:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"dot")})}var Nt={duration:.18,ease:"easeOut"},Re={duration:0};function Le({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=useState(false),a=g(),s=a?Re:Nt;return jsx(AnimatePresence,{mode:"wait",children:n&&jsxs(motion.div,{className:y(e),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:i&&jsx(motion.div,{initial:{opacity:0,y:a?0:4},animate:{opacity:1,y:0},exit:{opacity:0,y:a?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:o},"tooltip")}),jsxs(motion.button,{type:"button",onClick:t,"aria-label":o,style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"40px",borderRadius:"50%",border:"1px solid var(--bf-border)",background:"var(--bf-panel-bg)",color:"var(--bf-panel-fg)",boxShadow:"var(--bf-shadow)",cursor:"pointer",padding:0},animate:a?{}:{y:[0,-3,0]},transition:a?Re:{y:{duration:3,repeat:1/0,ease:"easeInOut"}},whileHover:{scale:1.1,borderColor:"var(--bf-accent)"},whileTap:{scale:.9},children:[c?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{size:16})},"success"):jsx(Se,{size:16}),r>0&&jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${r} queued`,children:r})]})]},"bubble")})}var Lt={duration:.2,ease:"easeOut"},zt={duration:0};function Ae(e){return e==="bottom-left"||e==="top-left"}function At(e){return `bf-trigger-edge ${Ae(e)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function Ie({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=useState(false),a=Ae(e),s=g(),m=s?zt:Lt;return jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.button,{className:At(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{opacity:0,width:0},animate:{opacity:1,width:i?140:22,height:i?40:90},exit:{width:0,opacity:0},transition:m,whileTap:{scale:.97},style:{top:"50%",translateY:"-50%"},children:c?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:m,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{size:14})},"success"):jsxs(Fragment,{children:[jsxs(motion.span,{animate:{rotate:s||i?0:a?-90:90,opacity:i?1:.6},transition:m,style:{display:"flex",alignItems:"center",gap:"8px",whiteSpace:"nowrap",fontSize:"12px",letterSpacing:"0.5px",textTransform:"uppercase"},children:[i&&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}}),o]}),jsx(motion.span,{"aria-hidden":"true",animate:{opacity:i?1:0},transition:{duration:.12},style:{position:"absolute",top:0,bottom:0,[a?"left":"right"]:0,width:"2px",background:"var(--bf-accent)"}}),r>0&&jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"edge-tab")})}var _t={duration:.18,ease:"easeOut"},Ht={duration:0};function _e({delay:e,hovered:t,reduced:n}){return n?null:jsx(motion.span,{"aria-hidden":"true",style:{position:"absolute",width:"10px",height:"10px",borderRadius:"50%",border:"2px solid var(--bf-accent)",pointerEvents:"none"},animate:t?{scale:1,opacity:0}:{scale:[1,1.8],opacity:[.5,0]},transition:t?{duration:.15}:{duration:2,repeat:1/0,delay:e,ease:"easeOut"}})}function Oe({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=useState(false),a=g(),s=a?Ht:_t;return jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:c?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{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(_e,{delay:0,hovered:i,reduced:a}),jsx(_e,{delay:.7,hovered:i,reduced:a}),jsx(motion.span,{className:"bf-dot","aria-hidden":"true",style:{position:"relative",zIndex:1}})]}),jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.span,{initial:{opacity:0,x:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"pulse-ring")})}var $t={duration:.18,ease:"easeOut"},Ut={duration:0};function Xt(e){switch(e){case "bottom-left":return "bf-trigger-minimal bf-trigger-bl";case "top-right":return "bf-trigger-minimal bf-trigger-tr";case "top-left":return "bf-trigger-minimal bf-trigger-tl";default:return "bf-trigger-minimal"}}function $e({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=useState(false),a=g(),s=a?Ut:$t;return jsx(AnimatePresence,{mode:"wait",children:n&&jsxs(motion.button,{className:Xt(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{opacity:0,y:a?0:5},animate:{opacity:i?1:.65,y:0},exit:{opacity:0,y:a?0:5},transition:s,whileTap:{scale:.95},children:[c?jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{size:14})}):jsxs(Fragment,{children:[jsx("span",{children:o}),r>0&&jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${r} queued`,children:r})]}),!a&&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:i?1:0},transition:s})]},"minimal")})}var Qt={duration:.18,ease:"easeOut"},jt={duration:0};function Xe({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=useState(false),a=g(),s=a?jt:Qt;return jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.9},style:{overflow:"hidden"},children:c?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{size:14})},"success"):jsxs(Fragment,{children:[jsx(motion.span,{style:{display:"inline-flex",flexShrink:0},animate:a?{}:i?{scale:1.2,rotate:0}:{rotate:[-5,5,-5]},transition:i||a?s:{duration:3,repeat:1/0,ease:"easeInOut"},children:jsx(Pe,{size:16})}),jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.span,{initial:{opacity:0,x:a?0:-8},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-8},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"icon-pop")})}var Zt={duration:.18,ease:"easeOut"},eo={duration:0};function Qe({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=useState(false),a=g(),s=a?eo:Zt;return jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:s,whileTap:{scale:.92},style:{overflow:"hidden"},children:c?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{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:a?{}:{opacity:i?1:[.5,1,.5],boxShadow:i?"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:i||a?s:{duration:2,repeat:1/0,ease:"easeInOut"}}),!i&&!a&&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:i&&jsx(motion.span,{initial:{opacity:0,x:a?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:a?0:-6},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),r>0&&jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"beacon")})}var io={duration:.18,ease:"easeOut"},no={duration:0};function Je({position:e,onClick:t,isVisible:n,label:o,queueCount:r,showSuccess:c}){let[i,l]=useState(false),[a,s]=useState(0),m=g(),M=m?no:io,p=useRef(null);useEffect(()=>{if(p.current&&(clearInterval(p.current),p.current=null),!n||i||m){s(i||m?o.length:0);return}let u=8,E=o.length*2+u*2,x=0;return p.current=setInterval(()=>{x=(x+1)%E,x<=o.length?s(x):x<=o.length+u?s(o.length):x<=o.length*2+u?s(o.length*2+u-x):s(0);},100),()=>{p.current&&(clearInterval(p.current),p.current=null);}},[n,i,m,o]);let T=o.slice(0,a);return jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.button,{className:y(e),type:"button",onClick:t,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-label":o,initial:{opacity:0,y:m?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:m?0:5},transition:M,whileTap:{scale:.95},style:{minWidth:"44px"},children:c?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:M,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(b,{size:14})},"success"):jsxs(Fragment,{children:[jsx("span",{className:"bf-dot","aria-hidden":"true"}),jsxs("span",{style:{whiteSpace:"nowrap",minWidth:"1ch"},children:[T,jsx("span",{className:"bf-cursor","aria-hidden":"true"})]}),r>0&&jsx("span",{className:"bf-badge","aria-label":`${r} queued`,children:r})]})},"typewriter")})}function Ze(e){switch(e){case "dot":return Be;case "bubble":return Le;case "edge-tab":return Ie;case "pulse-ring":return Oe;case "minimal":return $e;case "icon-pop":return Xe;case "beacon":return Qe;case "typewriter":return Je;default:return Ce}}function tt(e,t,n){return Math.max(t,Math.min(n,e))}function fo(e,t,n="bottom-right"){let r=window.innerWidth,c=window.innerHeight,i;i=tt(e.x,12,Math.max(12,r-t-12));let l=e.y+e.height+12,a=Math.max(12,e.y-240);return {top:l+240<=c?l:a,left:i}}function uo(e){let{rect:t}=e,n={left:`${t.x}px`,top:`${t.y}px`,width:`${Math.max(0,t.width)}px`,height:`${Math.max(0,t.height)}px`};return jsx("div",{className:"bf-highlight",style:n,"aria-hidden":"true"})}function bo(e){let t=useRef(null);return useEffect(()=>{if(!e||!t.current)return;t.current.querySelector(".bf-textarea")?.focus();let o=r=>{if(r.key!=="Tab"||!t.current)return;let c=t.current.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(c.length===0)return;let i=c[0],l=c[c.length-1];r.shiftKey&&document.activeElement===i?(r.preventDefault(),l.focus()):!r.shiftKey&&document.activeElement===l&&(r.preventDefault(),i.focus());};return document.addEventListener("keydown",o,{capture:true}),()=>document.removeEventListener("keydown",o,{capture:true})},[e]),t}function go(e,t){return e?typeof e=="function"?e(t):e.some(n=>n.endsWith("*")?t.startsWith(n.slice(0,-1)):t===n):true}function mo(e){let[t,n]=useState(()=>typeof window<"u"?window.location.pathname:"/");return useEffect(()=>{if(typeof window>"u")return;let o=()=>n(window.location.pathname);window.addEventListener("popstate",o);let r=history.pushState,c=history.replaceState;return history.pushState=function(...i){r.apply(this,i),o();},history.replaceState=function(...i){c.apply(this,i),o();},()=>{window.removeEventListener("popstate",o),history.pushState=r,history.replaceState=c;}},[]),go(e,t)}function ho(e){let[t,n]=useState(()=>!e||e==="dark"?"dark":e==="light"?"light":typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return useEffect(()=>{if(e!=="auto"){n(e==="light"?"light":"dark");return}let o=window.matchMedia("(prefers-color-scheme: dark)"),r=c=>n(c.matches?"dark":"light");return n(o.matches?"dark":"light"),o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[e]),t}var xo=["bug","feature","ux","general"],yo={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function wo(e){let{state:t,controller:n,start:o,stop:r,clearSelection:c,submit:i$1}=te(),l=e.config.ui?.position,a=Te(e.config.ui?.strings),s=e.config.ui?.branding!==false,[m,M]=useState(null),[p$1,T]=useState(""),[u,E]=useState(e.config.capture?.element??true),[x,re]=useState(e.config.capture?.fullPage??false),[rt,ae]=useState(null),[O,ie]=useState(void 0),ne=e.config.ui?.categories??xo,[at,it]=useState(false),[j,nt]=useState(0);useEffect(()=>{let d=window.setTimeout(()=>{let N=p();nt(N.findings.length);},500);return ()=>window.clearTimeout(d)},[]),useImperativeHandle(e.handleRef,()=>({open:o,close:r,submit:d=>i$1(d),get isOpen(){return t.phase!=="idle"}}),[o,r,i$1,t.phase]);let se=t.phase==="review"||t.phase==="capturing"||t.phase==="submitting"||t.phase==="error"||t.phase==="success",st=bo(se),[lt,ct]=useState(0);useEffect(()=>{t.phase==="idle"&&ct(i());},[t.phase]);let[dt,le]=useState(false),ce=useRef(t.phase);useEffect(()=>{if(ce.current==="success"&&t.phase==="idle"){le(true);let d=window.setTimeout(()=>le(false),1500);return ()=>window.clearTimeout(d)}ce.current=t.phase;},[t.phase]),useEffect(()=>{let d=e.config.ui?.shortcut;if(!d)return;let N=d.toLowerCase().split("+").map(P=>P.trim()),W=N[N.length-1]||"",L=new Set(N.slice(0,-1)),pe=P=>{let ut=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(L.has("mod")){if(ut?!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()===W&&(P.preventDefault(),t.phase==="idle"?o():r());};return document.addEventListener("keydown",pe),()=>document.removeEventListener("keydown",pe)},[e.config.ui?.shortcut,t.phase,o,r]),useEffect(()=>n.subscribeHover(M),[n]),useEffect(()=>{let d=n.__unsafeGetSelectedElement();if(!d||t.phase==="idle"||t.phase==="picking"){ae(null);return}let N=()=>{ae(b$1(d.getBoundingClientRect()));};N();let W=()=>N();return window.addEventListener("scroll",W,{capture:true,passive:true}),window.addEventListener("resize",W,{passive:true}),()=>{window.removeEventListener("scroll",W,{capture:true}),window.removeEventListener("resize",W);}},[n,t.phase,t.selection?.selector]),useEffect(()=>{t.phase==="review"&&(T(""),E(e.config.capture?.element??true),re(e.config.capture?.fullPage??false),ie(void 0));},[t.phase,t.selection?.selector,e.config.capture?.element,e.config.capture?.fullPage]),useEffect(()=>{if(t.phase!=="success")return;let d=window.setTimeout(()=>r(),1200);return ()=>window.clearTimeout(d)},[t.phase,r]);let S=t.phase==="capturing"||t.phase==="submitting",B=t.phase==="picking"?m?.rect??null:rt??t.selection?.rect??null,V=useMemo(()=>B?fo(B,360,l):null,[B?.x,B?.y,B?.width,B?.height,l]),de=t.lastError?.message,q=useCallback(()=>{let d={capture:{element:u,fullPage:x}};O&&(d.category=O),i$1(p$1,d);},[i$1,p$1,u,x,O]),pt=useCallback(d=>{(d.metaKey||d.ctrlKey)&&d.key==="Enter"&&p$1.trim().length>0&&!S&&(d.preventDefault(),q());},[q,p$1,S]),ft=Ze(e.config.ui?.triggerStyle);return jsxs(Fragment,{children:[jsx(ft,{position:l,onClick:()=>o(),isVisible:t.phase==="idle",label:e.config.ui?.triggerLabel??a.triggerLabel,queueCount:lt,showSuccess:dt}),t.phase!=="idle"&&jsxs("div",{className:"bf-overlay",role:"presentation",children:[t.phase!=="picking"&&jsx("div",{className:"bf-blocker",role:"presentation",onClick:()=>r()}),B&&jsx(uo,{rect:B}),t.phase==="picking"&&jsxs("div",{className:"bf-hint",role:"status","aria-live":"polite",children:[jsx("p",{id:"bf-hint-text",children:a.hintText}),jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),"aria-label":a.cancelButton,children:a.cancelButton})]}),se&&V&&jsxs("div",{ref:st,className:"bf-panel",style:{left:V.left,top:V.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:a.panelTitle}),jsxs("div",{className:"bf-row",style:{justifyContent:"flex-end"},children:[jsx("button",{type:"button",className:"bf-btn",onClick:()=>c(),disabled:S,"aria-label":a.rePickButton,children:a.rePickButton}),jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),disabled:S,"aria-label":a.closeButton,children:a.closeButton})]})]}),jsxs("div",{className:"bf-panelBody",children:[jsx("textarea",{className:"bf-textarea",placeholder:a.textareaPlaceholder,value:p$1,onChange:d=>T(d.target.value),onKeyDown:pt,disabled:S,"aria-label":a.panelTitle}),ne.length>0&&jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:ne.map(d=>jsx("button",{type:"button",className:`bf-pill${O===d?" bf-pill-active":""}`,onClick:()=>ie(O===d?void 0:d),disabled:S,children:a[yo[d]]},d))}),jsxs("div",{className:"bf-row",role:"group","aria-label":a.screenshotElement,children:[jsxs("label",{children:[jsx("input",{type:"checkbox",checked:u,onChange:d=>E(d.target.checked),disabled:S}),a.screenshotElement]}),jsxs("label",{children:[jsx("input",{type:"checkbox",checked:x,onChange:d=>re(d.target.checked),disabled:S}),a.screenshotFullPage]})]}),t.phase==="capturing"&&jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsx("span",{className:"bf-spinner","aria-hidden":"true"}),a.capturingText]}),t.phase==="submitting"&&jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsx("span",{className:"bf-spinner","aria-hidden":"true"}),a.submittingText]}),t.phase==="success"&&jsx("div",{className:"bf-status",role:"status","aria-live":"polite",children:a.successText}),t.phase==="error"&&de&&jsx("div",{className:"bf-error",role:"alert",children:de}),jsxs("div",{className:"bf-actions",children:[jsx("button",{type:"button",className:"bf-btn",onClick:()=>r(),disabled:S,"aria-label":a.cancelButton,children:a.cancelButton}),jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:q,disabled:S||p$1.trim().length===0,"aria-label":a.sendButton,children:a.sendButton})]})]}),s&&jsx("div",{className:"bf-watermark",children:jsx("a",{href:"https://blocfeed.com",target:"_blank",rel:"noopener noreferrer",children:"Powered by BlocFeed"})})]})]}),t.phase==="success"&&jsx("div",{className:"bf-toast",role:"status","aria-live":"polite",children:a.toastText}),j>0&&!at&&jsxs("div",{className:"bf-security-banner",role:"alert",children:[jsx("button",{type:"button",className:"bf-security-banner-dismiss",onClick:()=>it(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 vo=forwardRef(function(t,n){let o$1={...t.config??{},blocfeed_id:t.blocfeed_id},[r,c]=useState(null),i=mo(o$1.ui?.showOn),l$1=ho(o$1.ui?.theme?.mode),a=!!o$1.diagnostics;useEffect(()=>{if(a)return k(o$1.diagnostics),()=>l()},[a]);let s=!!o$1.security;useEffect(()=>{s&&o(o$1.security);},[s]);let m$1=useRef(t.config?.metadata?.enrich);m$1.current=t.config?.metadata?.enrich;let M=useMemo(()=>{if(t.config)return {...t.config,metadata:{...t.config.metadata,enrich:async p$1=>{let T=m$1.current,u=T?await T(p$1):{},E=m(),x=p();return {...u,...E.consoleLogs.length>0?{_consoleLogs:E.consoleLogs}:{},...E.networkErrors.length>0?{_networkErrors:E.networkErrors}:{},...x.findings.length>0?{_securityFindings:x.findings}:{}}}}}},[]);return useEffect(()=>{ve();let p=document.createElement("div");p.setAttribute("data-blocfeed-ui-root","true"),p.setAttribute("data-blocfeed-ui","true"),p.setAttribute("data-bf-theme",l$1);let T=o$1.ui?.zIndex;typeof T=="number"&&p.style.setProperty("--bf-z",String(T));let u=o$1.ui?.theme;return u&&(u.accentColor&&p.style.setProperty("--bf-accent",u.accentColor),u.panelBackground&&p.style.setProperty("--bf-panel-bg",u.panelBackground),u.panelForeground&&p.style.setProperty("--bf-panel-fg",u.panelForeground),u.fontFamily&&p.style.setProperty("--bf-font",u.fontFamily)),document.body.appendChild(p),c(p),()=>{p.remove(),c(null);}},[o$1.ui?.zIndex,o$1.ui?.theme?.accentColor,o$1.ui?.theme?.panelBackground,o$1.ui?.theme?.panelForeground,o$1.ui?.theme?.fontFamily,l$1]),useEffect(()=>{r&&r.setAttribute("data-bf-theme",l$1);},[r,l$1]),!i||!r?null:createPortal(jsx(ee,{blocfeed_id:o$1.blocfeed_id,...M?{config:M}:{},children:jsx(wo,{config:o$1,handleRef:n})}),r)});
639
+ export{ee as BlocFeedProvider,vo as BlocFeedWidget,te as useBlocFeed};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blocfeed",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "Drop-in feedback + screenshot widget for React.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,2 +0,0 @@
1
- 'use strict';function w(){return typeof window<"u"&&typeof document<"u"}function se(e){let t=globalThis.CSS;return typeof t?.escape=="function"?t.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>{let r=n.codePointAt(0);return r===void 0?"":`\\${r.toString(16)} `})}function J(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Me(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function Le(e){return e.replace(/\s+/g," ").trim()}function Be(e,t=140){let n=e.textContent;if(!n)return;let r=Le(n);if(r)return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function Ie(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var ue=["data-testid","data-test-id","data-test","data-qa","data-cy"],ae="data-blocfeed-component";function De(e){let t=e.closest(`[${ae}]`);if(!t)return;let r=t.getAttribute(ae)?.trim();return r||void 0}function Ne(e){for(let t of ue){let n=e.closest(`[${t}]`);if(!n)continue;let o=n.getAttribute(t)?.trim();if(o)return o}}function le(e){try{let t=e,n=Object.getOwnPropertyNames(t);for(let r of n)if(r.startsWith("__reactFiber$")||r.startsWith("__reactInternalInstance$")){let o=t[r];if(o&&typeof o=="object")return o}}catch{}return null}function T(e){if(e.length<=1||e.length===2&&e[0]===e[0].toLowerCase())return true;let t=e[0];return t>="a"&&t<="z"}function B(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!T(t.name))return t.name}}function v(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 r=t.render;if(typeof r=="function"){let i=r;if(typeof i.displayName=="string"&&i.displayName)return i.displayName;if(typeof i.name=="string"&&i.name)return i.name}let o=t.type;return v(o)}}}function Oe(e){let t=le(e);if(!t)return;let n=B(t._debugInfo);if(n)return n;let r=t._debugOwner!==void 0;if(r){let s=t._debugOwner;for(let l=0;s&&l<50;l+=1){let d=B(s._debugInfo);if(d)return d;let g=v(s.type)??v(s.elementType);if(g&&!T(g))return g;s=s._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let s=t._owner;for(let l=0;s&&l<50;l+=1){let d=B(s._debugInfo);if(d)return d;let g=v(s.type)??v(s.elementType);if(g&&!T(g))return g;s=s._owner;}}let i=t,c=r?80:25;for(let s=0;i&&s<c;s+=1){let l=B(i._debugInfo);if(l)return l;let d=v(i.type)??v(i.elementType);if(d&&!T(d))return d;i=i.return;}let a=e.parentElement;for(let s=0;a&&s<15;s+=1){let l=le(a);if(l){let d=B(l._debugInfo);if(d)return d;let g=v(l.type)??v(l.elementType);if(g&&!T(g))return g;if(l._debugOwner){let h=v(l._debugOwner.type)??v(l._debugOwner.elementType);if(h&&!T(h))return h}if(l._owner&&l._owner!==l._debugOwner){let h=v(l._owner.type)??v(l._owner.elementType);if(h&&!T(h))return h}}a=a.parentElement;}}function He(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${se(n)}`;for(let r of ue){let o=e.getAttribute(r);if(o)return `${t}[${r}="${se(o)}"]`}return `${t}:nth-of-type(${Ie(e)})`}function Ue(e,t=10){let n=[],r=e;for(;r&&n.length<t;){let o=He(r);if(n.unshift(o),o.startsWith("#"))break;r=r.parentElement;}return n.join(" > ")}function ce(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function Y(e,t){if(!e||ce(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(ce(n,t.ignoreSelectors))return null;if(t.isSelectable?.(n)??qe(n))return n;n=n.parentElement;}return null}function qe(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function de(e){let t=e.getBoundingClientRect(),n={selector:Ue(e),tagName:e.tagName.toLowerCase(),rect:J(t),pageRect:Me(t)},r=e.getAttribute("id");r&&(n.id=r);let o=e.className;typeof o=="string"&&o.trim()&&(n.className=o);let i=Be(e);i&&(n.textSnippet=i);let c=De(e)??Oe(e);c&&(n.componentName=c);let a=Ne(e);return a&&(n.testId=a),n}var K=null;async function fe(){return K||(K=import('html-to-image')),K}async function Xe(e){return await new Promise((t,n)=>{let r=new Image;r.onload=()=>t({width:r.naturalWidth,height:r.naturalHeight}),r.onerror=()=>n(new Error("Failed to load generated screenshot")),r.src=e;})}async function me(e,t){let{width:n,height:r}=await Xe(e);return {dataUrl:e,mime:t,width:n,height:r}}function M(e){if(e?.aborted)throw new Error("Aborted")}function pe(){return {async captureElement(e,t){if(!w())throw new Error("captureElement can only run in the browser");M(t.signal);let n=await fe();M(t.signal);let r=t.mime==="image/jpeg"?await n.toJpeg(e,{quality:t.quality??.92,pixelRatio:t.pixelRatio}):await n.toPng(e,{pixelRatio:t.pixelRatio});return M(t.signal),await me(r,t.mime)},async captureFullPage(e){if(!w())throw new Error("captureFullPage can only run in the browser");M(e.signal);let t=document.documentElement,n=Math.max(t.scrollWidth,t.clientWidth),r=Math.max(t.scrollHeight,t.clientHeight),o=Math.min(1,e.maxDimension/Math.max(n,r)),i=Math.max(1,Math.round(n*o)),c=Math.max(1,Math.round(r*o)),a=await fe();M(e.signal);let s=e.mime==="image/jpeg"?await a.toJpeg(t,{width:i,height:c,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await a.toPng(t,{width:i,height:c,pixelRatio:e.pixelRatio});return M(e.signal),await me(s,e.mime)}}}function $e(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function y(e,t,n){let r={kind:e,message:$e(t)};return n&&(r.detail=n),r}var je=12e3,Qe=2048,ze=.92;function ge(){return Date.now()}function We(e){return new Promise((t,n)=>{let r=()=>n(new Error("Aborted"));if(e.aborted){r();return}e.addEventListener("abort",r,{once:true});})}async function he(e,t,n){let r=new Promise((i,c)=>{let a=setTimeout(()=>c(new Error("Timeout")),t);typeof a.unref=="function"&&a.unref();}),o=[e,r];return n&&o.push(We(n)),await Promise.race(o)}function Je(e){if(!w())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function Ye(e){return !!(e?.element||e?.fullPage)}function we(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 ye(e){let{selectionElement:t,capture:n,signal:r}=e;if(!w()||!Ye(n))return;let o=ge(),i=[],c=n?.timeoutMs??je,a=n?.maxDimension??Qe,s=n?.mime??"image/png",l=n?.quality??ze,d=n?.adapter??pe(),g={},h=Je(n);if(n?.element&&t)try{let f=t.getBoundingClientRect(),m=Math.min(1,a/Math.max(f.width,f.height)),P=Math.min(h,h*m),R=await he(Promise.resolve(d.captureElement(t,{...we({mime:s,quality:l,pixelRatio:P,maxDimension:a,includeQuality:s==="image/jpeg",...r?{signal:r}:{}})})),c,r);g.element=R;}catch(f){if(r?.aborted)throw f;i.push(y("capture_failed",f,{target:"element"}));}if(n?.fullPage)try{let f=await he(Promise.resolve(d.captureFullPage(we({mime:s,quality:l,pixelRatio:h,maxDimension:a,includeQuality:s==="image/jpeg",...r?{signal:r}:{}}))),c,r);g.fullPage=f;}catch(f){if(r?.aborted)throw f;i.push(y("capture_failed",f,{target:"fullPage"}));}let b=ge(),u={startedAt:o,finishedAt:b,durationMs:Math.max(0,b-o)};return i.length>0&&(u.errors=i),{...g,diagnostics:u}}function Ke(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Ge(){return w()?{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:Ke()}:{}}function Ze(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 be(e){let{config:t,context:n,user:r}=e;if(t?.enabled===false)return {};let o={...Ge(),...Ze(r)},i=t?.enrich;if(!i)return o;try{let c=await i(n);return {...o,...c}}catch(c){let a=y("unknown",c);return {...o,blocfeedMetadataError:a.message}}}var G="blocfeed-queue",Ve=50;function Z(){if(!w())return [];try{let e=localStorage.getItem(G);if(!e)return [];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return []}}function V(e){if(w())try{e.length===0?localStorage.removeItem(G):localStorage.setItem(G,JSON.stringify(e));}catch{}}function et(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 t}function ee(e){let t=Z(),n=et(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>Ve;)t.shift();V(t);}function Ee(){let e=Z();return e.length===0?[]:(V([]),e.map(t=>t.payload))}function Ft(){V([]);}function Tt(){return Z().length}function te(e){let t=null,n=null,r=(...o)=>{n=o,t===null&&(t=requestAnimationFrame(()=>{if(t=null,!n)return;let i=n;n=null,e(...i);}));};return r.cancel=()=>{t!==null&&cancelAnimationFrame(t),t=null,n=null;},r}function X(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function $(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function ke(e,t){if(!w())throw new Error("BlocFeed picker can only run in a browser environment.");let n=e.ignoreSelectors,r=e.isSelectable,o={};n&&n.length>0&&(o.ignoreSelectors=n),r&&(o.isSelectable=r);let i=null,c=null,a=(u,f=false)=>{if(!u){i=null,c=null,t.onHover(null);return}let m=J(u.getBoundingClientRect()),P=`${Math.round(m.x)}:${Math.round(m.y)}:${Math.round(m.width)}:${Math.round(m.height)}`;!f&&u===i&&P===c||(i=u,c=P,t.onHover({element:u,rect:m}));},s=te(u=>{if(X(u.target))return;let f=document.elementFromPoint(u.clientX,u.clientY),m=Y(f,o);a(m);}),l=te(()=>{i&&a(i,true);}),d=u=>{X(u.target)||($(u),u.pointerType==="mouse"&&u.preventDefault());},g=u=>{X(u.target)||($(u),u.pointerType==="mouse"&&u.preventDefault());},h=u=>{if(X(u.target))return;$(u),u.preventDefault();let f=document.elementFromPoint(u.clientX,u.clientY),m=Y(f,o);m&&t.onSelect({element:m,descriptor:de(m)});},b=u=>{u.key==="Escape"&&($(u),u.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",s,{capture:true,passive:true}),window.addEventListener("pointerdown",d,{capture:true}),window.addEventListener("pointerup",g,{capture:true}),window.addEventListener("click",h,{capture:true}),window.addEventListener("keydown",b,{capture:true}),window.addEventListener("scroll",l,{capture:true,passive:true}),window.addEventListener("resize",l,{passive:true}),{stop(){window.removeEventListener("pointermove",s,{capture:true}),window.removeEventListener("pointerdown",d,{capture:true}),window.removeEventListener("pointerup",g,{capture:true}),window.removeEventListener("click",h,{capture:true}),window.removeEventListener("keydown",b,{capture:true}),window.removeEventListener("scroll",l,{capture:true}),window.removeEventListener("resize",l),s.cancel(),l.cancel(),t.onHover(null);}}}var tt=12e3,nt=2,rt=500,ot=2e3,xe="https://blocfeed.com/api/feedback",Se=0;function ve(e,t){return new Promise((n,r)=>{if(t?.aborted){r(new Error("Aborted"));return}let o=setTimeout(n,e),i=()=>{clearTimeout(o),r(new Error("Aborted"));};t?.addEventListener("abort",i,{once:true});})}function it(e){return e>=500&&e<=599}function st(e){let[t,n]=e.split(",",2);if(!t||!n)throw new Error("Invalid data URL");let o=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(n),c=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)c[a]=i.charCodeAt(a);return new Blob([c],{type:o})}function at(e){let t={},n={...e};if(n.screenshots){let r={},o={...n.screenshots};o.element&&(t.element=o.element.dataUrl,r.element={mime:o.element.mime,width:o.element.width,height:o.element.height},o.element={...o.element,dataUrl:""}),o.fullPage&&(t.fullPage=o.fullPage.dataUrl,r.fullPage={mime:o.fullPage.mime,width:o.fullPage.width,height:o.fullPage.height},o.fullPage={...o.fullPage,dataUrl:""}),n.screenshots=o,(r.element||r.fullPage)&&(n.screenshot_intent=r);}return {lean:n,extracted:t}}async function Pe(e,t,n){let r=st(t);await fetch(e,{method:"PUT",body:r,headers:{"content-type":r.type},...n?{signal:n}:{}});}async function lt(e){let{feedbackId:t,extracted:n,screenshots:r,signal:o}=e,i={};n.element&&r?.element&&(i.element={dataUrl:n.element,mime:r.element.mime,width:r.element.width,height:r.element.height}),n.fullPage&&r?.fullPage&&(i.fullPage={dataUrl:n.fullPage,mime:r.fullPage.mime,width:r.fullPage.width,height:r.fullPage.height}),Object.keys(i).length!==0&&await fetch(`${xe}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...o?{signal:o}:{}});}async function Re(e){let{signal:t,transport:n}=e;if(Date.now()-Se<ot)return {ok:false,error:y("configuration",new Error("Please wait before submitting again"))};let o=n?.timeoutMs??tt,i=n?.maxAttempts??nt,c=n?.backoffMs??rt,a=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),{lean:s,extracted:l}=a?at(e.payload):{lean:e.payload,extracted:{}},d={...l,...e.screenshotDataUrls};for(let g=1;g<=i;g+=1){let h=new AbortController,b=setTimeout(()=>h.abort(),o),u=()=>h.abort();t&&t.addEventListener("abort",u,{once:true});try{let f=await fetch(xe,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s),signal:h.signal});if(f.ok){Se=Date.now();let m;try{m=await f.json();}catch{}if((d.element||d.fullPage)&&m){let p=m.upload_urls;if(p){let k=[];d.element&&p.element&&k.push(Pe(p.element,d.element,t)),d.fullPage&&p.fullPage&&k.push(Pe(p.fullPage,d.fullPage,t));try{await Promise.all(k);}catch{}}else if(m.feedback_id)try{await lt({feedbackId:m.feedback_id,extracted:d,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}let R={ok:!0,status:f.status};return m&&(R.apiResponse=m),R}if(g<i&&it(f.status)){let m=.85+Math.random()*.3,P=Math.round(c*2**(g-1)*m);await ve(P,t);continue}return {ok:!1,status:f.status,error:y("api_failed",new Error(`HTTP ${f.status}`))}}catch(f){if(h.signal.aborted||t?.aborted)return {ok:false,error:y("aborted",f)};if(g<i){let m=.85+Math.random()*.3,P=Math.round(c*2**(g-1)*m);await ve(P,t);continue}return {ok:false,error:y("api_failed",f)}}finally{clearTimeout(b),t&&t.removeEventListener("abort",u);}}return {ok:false,error:y("api_failed",new Error("Failed"))}}async function ne(e){let{signal:t,transport:n}=e,r={ok:false};try{let o={payload:e.payload,...t?{signal:t}:{},...n?{transport:n}:{}};r.api=await Re(o),r.ok=!!r.api?.ok;}catch(o){r.api={ok:false,error:y("api_failed",o)},r.ok=false;}return {payload:e.payload,result:r}}var ct=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function ut(e){let t=[...ct,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function Fe(){return {phase:"idle"}}function dt(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 zt(e){let t=e,n=Fe(),r=new Set,o=new Set,i=null,c=null,a=null,s=null,l=0,d=null,g=()=>{for(let p of r)p(n);},h=p=>{for(let k of o)k(p);},b=p=>{n=p,g();},u=()=>{l+=1,s?.abort(),s=null;},f=()=>{i?.stop(),i=null,h(null),a!==null&&w()&&(document.documentElement.style.cursor=a,a=null);},m=()=>{u(),f(),c=null,b(Fe());},P=()=>{if(!w())return;f(),c=null;let p=ut(t.picker);a=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",b({phase:"picking"}),i=ke(p,{onHover:h,onSelect:({element:k,descriptor:q})=>{c=k,f(),b({phase:"review",selection:q});},onCancel:()=>{m();}});},R=()=>{let p=Ee();if(p.length!==0)for(let k of p)ne({payload:k,...t.transport?{transport:t.transport}:{}}).catch(()=>{ee(k);});};if(w()){setTimeout(R,1e3);let p=()=>R();window.addEventListener("online",p),d=()=>window.removeEventListener("online",p);}return {getState:()=>n,subscribe(p){return r.add(p),()=>r.delete(p)},subscribeHover(p){return o.add(p),()=>o.delete(p)},start(){n.phase==="capturing"||n.phase==="submitting"||n.phase!=="picking"&&P();},stop(){m();},clearSelection(){n.phase==="capturing"||n.phase==="submitting"||P();},setConfig(p){t=p;},async submit(p,k){if(!w()){let E=y("configuration",new Error("BlocFeed submit can only run in the browser"));return b({phase:"error",lastError:E}),{ok:false}}let q=t.blocfeed_id?.trim?.()??"";if(!q){let F={phase:"error",lastError:y("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return n.selection&&(F.selection=n.selection),b(F),{ok:false}}if(n.phase==="capturing"||n.phase==="submitting")return {ok:false};let L=l+1;l=L,s?.abort(),s=new AbortController;let A=s.signal,S=n.selection,Q=k?.capture?{...t.capture,...k.capture}:t.capture,oe=!!(Q?.element||Q?.fullPage),ie={phase:oe?"capturing":"submitting"};S&&(ie.selection=S),b(ie);try{let E=oe?await ye({selectionElement:c,capture:Q,signal:A}):void 0;if(A.aborted||l!==L)return {ok:!1};let F={phase:"submitting"};S&&(F.selection=S),E&&(F.capture=E),b(F);let C={};S&&(C.selection=S),E&&(C.capture=E);let Ce=await be({config:t.metadata,context:C,...t.user?{user:t.user}:{}}),_={version:1,createdAt:new Date().toISOString(),blocfeed_id:q,message:p,metadata:Ce};k?.category&&(_.category=k.category),t.user&&(_.user=t.user),S&&(_.selection=S),E&&(_.screenshots=E);let{result:x}=await ne({payload:_,signal:A,...t.transport?{transport:t.transport}:{}});if(A.aborted||l!==L)return x;if(x.ok){let W={phase:"success",lastSubmit:x};return S&&(W.selection=S),E&&(W.capture=E),b(W),x}dt(x)&&ee(_);let _e=x.api?.error??y("unknown",new Error("Submission failed")),z={phase:"error",lastSubmit:x,lastError:_e};return S&&(z.selection=S),E&&(z.capture=E),b(z),x}catch(E){if(A.aborted||l!==L)return {ok:false};let C={phase:"error",lastError:A.aborted?y("aborted",E):y("unknown",E)};return S&&(C.selection=S),b(C),{ok:false}}finally{l===L&&(s=null);}},__unsafeGetSelectedElement(){return c},destroy(){m(),r.clear(),o.clear(),d?.(),d=null;}}}var I=[],D=[],Te=20,Ae=15,N={},O=null,H=null,U=null,j=false;function ft(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function mt(e,t){let n=t.map(ft).join(" "),r=t.find(i=>i instanceof Error),o={level:e,message:n.slice(0,2e3),timestamp:Date.now()};for(r?.stack&&(o.stack=r.stack.slice(0,2e3)),I.push(o);I.length>Te;)I.shift();}function re(e){if(!e.url.includes("blocfeed.com"))for(D.push(e);D.length>Ae;)D.shift();}function Yt(e={}){if(!(j||!w())){if(j=true,Te=e.consoleLimit??20,Ae=e.networkLimit??15,e.console!==false){let t=e.consoleLevels??["error","warn"];for(let n of t)N[n]=console[n],console[n]=(...r)=>{mt(n,r),N[n]?.apply(console,r);};}if(e.network!==false&&typeof window.fetch=="function"){O=window.fetch;let t=O;window.fetch=async function(r,o){let i=typeof r=="string"?r:r instanceof URL?r.toString():r.url,c=(o?.method??"GET").toUpperCase(),a=Date.now();try{let s=await t.call(window,r,o);return s.ok||re({url:i.slice(0,500),method:c,status:s.status,statusText:s.statusText,timestamp:a,durationMs:Date.now()-a}),s}catch(s){throw re({url:i.slice(0,500),method:c,status:0,statusText:s instanceof Error?s.message:"Network error",timestamp:a,durationMs:Date.now()-a}),s}};}if(e.network!==false&&typeof XMLHttpRequest<"u"){H=XMLHttpRequest.prototype.open,U=XMLHttpRequest.prototype.send;let t=H,n=U;XMLHttpRequest.prototype.open=function(r,o,...i){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(o),t.apply(this,[r,o,...i])},XMLHttpRequest.prototype.send=function(...r){let o=this.__bf_method||"GET",i=this.__bf_url||"",c=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let a={url:i.slice(0,500),method:o,status:this.status,timestamp:c,durationMs:Date.now()-c};this.statusText&&(a.statusText=this.statusText),re(a);}}),n.apply(this,r)};}}}function Kt(){if(j){for(let[e,t]of Object.entries(N))console[e]=t;for(let e of Object.keys(N))delete N[e];O&&(window.fetch=O,O=null),H&&(XMLHttpRequest.prototype.open=H,H=null),U&&(XMLHttpRequest.prototype.send=U,U=null),j=false;}}function Gt(){return {consoleLogs:[...I],networkErrors:[...D]}}function Zt(){I=[],D=[];}
2
- exports.a=w;exports.b=J;exports.c=pe;exports.d=ye;exports.e=be;exports.f=ee;exports.g=Ee;exports.h=Ft;exports.i=Tt;exports.j=zt;exports.k=Yt;exports.l=Kt;exports.m=Gt;exports.n=Zt;
@@ -1,2 +0,0 @@
1
- function w(){return typeof window<"u"&&typeof document<"u"}function se(e){let t=globalThis.CSS;return typeof t?.escape=="function"?t.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>{let r=n.codePointAt(0);return r===void 0?"":`\\${r.toString(16)} `})}function J(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Me(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function Le(e){return e.replace(/\s+/g," ").trim()}function Be(e,t=140){let n=e.textContent;if(!n)return;let r=Le(n);if(r)return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function Ie(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var ue=["data-testid","data-test-id","data-test","data-qa","data-cy"],ae="data-blocfeed-component";function De(e){let t=e.closest(`[${ae}]`);if(!t)return;let r=t.getAttribute(ae)?.trim();return r||void 0}function Ne(e){for(let t of ue){let n=e.closest(`[${t}]`);if(!n)continue;let o=n.getAttribute(t)?.trim();if(o)return o}}function le(e){try{let t=e,n=Object.getOwnPropertyNames(t);for(let r of n)if(r.startsWith("__reactFiber$")||r.startsWith("__reactInternalInstance$")){let o=t[r];if(o&&typeof o=="object")return o}}catch{}return null}function T(e){if(e.length<=1||e.length===2&&e[0]===e[0].toLowerCase())return true;let t=e[0];return t>="a"&&t<="z"}function B(e){if(e){for(let t of e)if(typeof t.name=="string"&&t.name&&!T(t.name))return t.name}}function v(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 r=t.render;if(typeof r=="function"){let i=r;if(typeof i.displayName=="string"&&i.displayName)return i.displayName;if(typeof i.name=="string"&&i.name)return i.name}let o=t.type;return v(o)}}}function Oe(e){let t=le(e);if(!t)return;let n=B(t._debugInfo);if(n)return n;let r=t._debugOwner!==void 0;if(r){let s=t._debugOwner;for(let l=0;s&&l<50;l+=1){let d=B(s._debugInfo);if(d)return d;let g=v(s.type)??v(s.elementType);if(g&&!T(g))return g;s=s._debugOwner;}}if(t._owner!==void 0&&t._owner!==t._debugOwner){let s=t._owner;for(let l=0;s&&l<50;l+=1){let d=B(s._debugInfo);if(d)return d;let g=v(s.type)??v(s.elementType);if(g&&!T(g))return g;s=s._owner;}}let i=t,c=r?80:25;for(let s=0;i&&s<c;s+=1){let l=B(i._debugInfo);if(l)return l;let d=v(i.type)??v(i.elementType);if(d&&!T(d))return d;i=i.return;}let a=e.parentElement;for(let s=0;a&&s<15;s+=1){let l=le(a);if(l){let d=B(l._debugInfo);if(d)return d;let g=v(l.type)??v(l.elementType);if(g&&!T(g))return g;if(l._debugOwner){let h=v(l._debugOwner.type)??v(l._debugOwner.elementType);if(h&&!T(h))return h}if(l._owner&&l._owner!==l._debugOwner){let h=v(l._owner.type)??v(l._owner.elementType);if(h&&!T(h))return h}}a=a.parentElement;}}function He(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${se(n)}`;for(let r of ue){let o=e.getAttribute(r);if(o)return `${t}[${r}="${se(o)}"]`}return `${t}:nth-of-type(${Ie(e)})`}function Ue(e,t=10){let n=[],r=e;for(;r&&n.length<t;){let o=He(r);if(n.unshift(o),o.startsWith("#"))break;r=r.parentElement;}return n.join(" > ")}function ce(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function Y(e,t){if(!e||ce(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(ce(n,t.ignoreSelectors))return null;if(t.isSelectable?.(n)??qe(n))return n;n=n.parentElement;}return null}function qe(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function de(e){let t=e.getBoundingClientRect(),n={selector:Ue(e),tagName:e.tagName.toLowerCase(),rect:J(t),pageRect:Me(t)},r=e.getAttribute("id");r&&(n.id=r);let o=e.className;typeof o=="string"&&o.trim()&&(n.className=o);let i=Be(e);i&&(n.textSnippet=i);let c=De(e)??Oe(e);c&&(n.componentName=c);let a=Ne(e);return a&&(n.testId=a),n}var K=null;async function fe(){return K||(K=import('html-to-image')),K}async function Xe(e){return await new Promise((t,n)=>{let r=new Image;r.onload=()=>t({width:r.naturalWidth,height:r.naturalHeight}),r.onerror=()=>n(new Error("Failed to load generated screenshot")),r.src=e;})}async function me(e,t){let{width:n,height:r}=await Xe(e);return {dataUrl:e,mime:t,width:n,height:r}}function M(e){if(e?.aborted)throw new Error("Aborted")}function pe(){return {async captureElement(e,t){if(!w())throw new Error("captureElement can only run in the browser");M(t.signal);let n=await fe();M(t.signal);let r=t.mime==="image/jpeg"?await n.toJpeg(e,{quality:t.quality??.92,pixelRatio:t.pixelRatio}):await n.toPng(e,{pixelRatio:t.pixelRatio});return M(t.signal),await me(r,t.mime)},async captureFullPage(e){if(!w())throw new Error("captureFullPage can only run in the browser");M(e.signal);let t=document.documentElement,n=Math.max(t.scrollWidth,t.clientWidth),r=Math.max(t.scrollHeight,t.clientHeight),o=Math.min(1,e.maxDimension/Math.max(n,r)),i=Math.max(1,Math.round(n*o)),c=Math.max(1,Math.round(r*o)),a=await fe();M(e.signal);let s=e.mime==="image/jpeg"?await a.toJpeg(t,{width:i,height:c,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await a.toPng(t,{width:i,height:c,pixelRatio:e.pixelRatio});return M(e.signal),await me(s,e.mime)}}}function $e(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return "Unknown error"}}function y(e,t,n){let r={kind:e,message:$e(t)};return n&&(r.detail=n),r}var je=12e3,Qe=2048,ze=.92;function ge(){return Date.now()}function We(e){return new Promise((t,n)=>{let r=()=>n(new Error("Aborted"));if(e.aborted){r();return}e.addEventListener("abort",r,{once:true});})}async function he(e,t,n){let r=new Promise((i,c)=>{let a=setTimeout(()=>c(new Error("Timeout")),t);typeof a.unref=="function"&&a.unref();}),o=[e,r];return n&&o.push(We(n)),await Promise.race(o)}function Je(e){if(!w())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function Ye(e){return !!(e?.element||e?.fullPage)}function we(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 ye(e){let{selectionElement:t,capture:n,signal:r}=e;if(!w()||!Ye(n))return;let o=ge(),i=[],c=n?.timeoutMs??je,a=n?.maxDimension??Qe,s=n?.mime??"image/png",l=n?.quality??ze,d=n?.adapter??pe(),g={},h=Je(n);if(n?.element&&t)try{let f=t.getBoundingClientRect(),m=Math.min(1,a/Math.max(f.width,f.height)),P=Math.min(h,h*m),R=await he(Promise.resolve(d.captureElement(t,{...we({mime:s,quality:l,pixelRatio:P,maxDimension:a,includeQuality:s==="image/jpeg",...r?{signal:r}:{}})})),c,r);g.element=R;}catch(f){if(r?.aborted)throw f;i.push(y("capture_failed",f,{target:"element"}));}if(n?.fullPage)try{let f=await he(Promise.resolve(d.captureFullPage(we({mime:s,quality:l,pixelRatio:h,maxDimension:a,includeQuality:s==="image/jpeg",...r?{signal:r}:{}}))),c,r);g.fullPage=f;}catch(f){if(r?.aborted)throw f;i.push(y("capture_failed",f,{target:"fullPage"}));}let b=ge(),u={startedAt:o,finishedAt:b,durationMs:Math.max(0,b-o)};return i.length>0&&(u.errors=i),{...g,diagnostics:u}}function Ke(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Ge(){return w()?{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:Ke()}:{}}function Ze(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 be(e){let{config:t,context:n,user:r}=e;if(t?.enabled===false)return {};let o={...Ge(),...Ze(r)},i=t?.enrich;if(!i)return o;try{let c=await i(n);return {...o,...c}}catch(c){let a=y("unknown",c);return {...o,blocfeedMetadataError:a.message}}}var G="blocfeed-queue",Ve=50;function Z(){if(!w())return [];try{let e=localStorage.getItem(G);if(!e)return [];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return []}}function V(e){if(w())try{e.length===0?localStorage.removeItem(G):localStorage.setItem(G,JSON.stringify(e));}catch{}}function et(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 t}function ee(e){let t=Z(),n=et(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>Ve;)t.shift();V(t);}function Ee(){let e=Z();return e.length===0?[]:(V([]),e.map(t=>t.payload))}function Ft(){V([]);}function Tt(){return Z().length}function te(e){let t=null,n=null,r=(...o)=>{n=o,t===null&&(t=requestAnimationFrame(()=>{if(t=null,!n)return;let i=n;n=null,e(...i);}));};return r.cancel=()=>{t!==null&&cancelAnimationFrame(t),t=null,n=null;},r}function X(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function $(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function ke(e,t){if(!w())throw new Error("BlocFeed picker can only run in a browser environment.");let n=e.ignoreSelectors,r=e.isSelectable,o={};n&&n.length>0&&(o.ignoreSelectors=n),r&&(o.isSelectable=r);let i=null,c=null,a=(u,f=false)=>{if(!u){i=null,c=null,t.onHover(null);return}let m=J(u.getBoundingClientRect()),P=`${Math.round(m.x)}:${Math.round(m.y)}:${Math.round(m.width)}:${Math.round(m.height)}`;!f&&u===i&&P===c||(i=u,c=P,t.onHover({element:u,rect:m}));},s=te(u=>{if(X(u.target))return;let f=document.elementFromPoint(u.clientX,u.clientY),m=Y(f,o);a(m);}),l=te(()=>{i&&a(i,true);}),d=u=>{X(u.target)||($(u),u.pointerType==="mouse"&&u.preventDefault());},g=u=>{X(u.target)||($(u),u.pointerType==="mouse"&&u.preventDefault());},h=u=>{if(X(u.target))return;$(u),u.preventDefault();let f=document.elementFromPoint(u.clientX,u.clientY),m=Y(f,o);m&&t.onSelect({element:m,descriptor:de(m)});},b=u=>{u.key==="Escape"&&($(u),u.preventDefault(),t.onCancel());};return window.addEventListener("pointermove",s,{capture:true,passive:true}),window.addEventListener("pointerdown",d,{capture:true}),window.addEventListener("pointerup",g,{capture:true}),window.addEventListener("click",h,{capture:true}),window.addEventListener("keydown",b,{capture:true}),window.addEventListener("scroll",l,{capture:true,passive:true}),window.addEventListener("resize",l,{passive:true}),{stop(){window.removeEventListener("pointermove",s,{capture:true}),window.removeEventListener("pointerdown",d,{capture:true}),window.removeEventListener("pointerup",g,{capture:true}),window.removeEventListener("click",h,{capture:true}),window.removeEventListener("keydown",b,{capture:true}),window.removeEventListener("scroll",l,{capture:true}),window.removeEventListener("resize",l),s.cancel(),l.cancel(),t.onHover(null);}}}var tt=12e3,nt=2,rt=500,ot=2e3,xe="https://blocfeed.com/api/feedback",Se=0;function ve(e,t){return new Promise((n,r)=>{if(t?.aborted){r(new Error("Aborted"));return}let o=setTimeout(n,e),i=()=>{clearTimeout(o),r(new Error("Aborted"));};t?.addEventListener("abort",i,{once:true});})}function it(e){return e>=500&&e<=599}function st(e){let[t,n]=e.split(",",2);if(!t||!n)throw new Error("Invalid data URL");let o=/data:(.*?);base64/.exec(t)?.[1]||"application/octet-stream",i=atob(n),c=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)c[a]=i.charCodeAt(a);return new Blob([c],{type:o})}function at(e){let t={},n={...e};if(n.screenshots){let r={},o={...n.screenshots};o.element&&(t.element=o.element.dataUrl,r.element={mime:o.element.mime,width:o.element.width,height:o.element.height},o.element={...o.element,dataUrl:""}),o.fullPage&&(t.fullPage=o.fullPage.dataUrl,r.fullPage={mime:o.fullPage.mime,width:o.fullPage.width,height:o.fullPage.height},o.fullPage={...o.fullPage,dataUrl:""}),n.screenshots=o,(r.element||r.fullPage)&&(n.screenshot_intent=r);}return {lean:n,extracted:t}}async function Pe(e,t,n){let r=st(t);await fetch(e,{method:"PUT",body:r,headers:{"content-type":r.type},...n?{signal:n}:{}});}async function lt(e){let{feedbackId:t,extracted:n,screenshots:r,signal:o}=e,i={};n.element&&r?.element&&(i.element={dataUrl:n.element,mime:r.element.mime,width:r.element.width,height:r.element.height}),n.fullPage&&r?.fullPage&&(i.fullPage={dataUrl:n.fullPage,mime:r.fullPage.mime,width:r.fullPage.width,height:r.fullPage.height}),Object.keys(i).length!==0&&await fetch(`${xe}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...o?{signal:o}:{}});}async function Re(e){let{signal:t,transport:n}=e;if(Date.now()-Se<ot)return {ok:false,error:y("configuration",new Error("Please wait before submitting again"))};let o=n?.timeoutMs??tt,i=n?.maxAttempts??nt,c=n?.backoffMs??rt,a=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),{lean:s,extracted:l}=a?at(e.payload):{lean:e.payload,extracted:{}},d={...l,...e.screenshotDataUrls};for(let g=1;g<=i;g+=1){let h=new AbortController,b=setTimeout(()=>h.abort(),o),u=()=>h.abort();t&&t.addEventListener("abort",u,{once:true});try{let f=await fetch(xe,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s),signal:h.signal});if(f.ok){Se=Date.now();let m;try{m=await f.json();}catch{}if((d.element||d.fullPage)&&m){let p=m.upload_urls;if(p){let k=[];d.element&&p.element&&k.push(Pe(p.element,d.element,t)),d.fullPage&&p.fullPage&&k.push(Pe(p.fullPage,d.fullPage,t));try{await Promise.all(k);}catch{}}else if(m.feedback_id)try{await lt({feedbackId:m.feedback_id,extracted:d,screenshots:e.payload.screenshots,...t?{signal:t}:{}});}catch{}}let R={ok:!0,status:f.status};return m&&(R.apiResponse=m),R}if(g<i&&it(f.status)){let m=.85+Math.random()*.3,P=Math.round(c*2**(g-1)*m);await ve(P,t);continue}return {ok:!1,status:f.status,error:y("api_failed",new Error(`HTTP ${f.status}`))}}catch(f){if(h.signal.aborted||t?.aborted)return {ok:false,error:y("aborted",f)};if(g<i){let m=.85+Math.random()*.3,P=Math.round(c*2**(g-1)*m);await ve(P,t);continue}return {ok:false,error:y("api_failed",f)}}finally{clearTimeout(b),t&&t.removeEventListener("abort",u);}}return {ok:false,error:y("api_failed",new Error("Failed"))}}async function ne(e){let{signal:t,transport:n}=e,r={ok:false};try{let o={payload:e.payload,...t?{signal:t}:{},...n?{transport:n}:{}};r.api=await Re(o),r.ok=!!r.api?.ok;}catch(o){r.api={ok:false,error:y("api_failed",o)},r.ok=false;}return {payload:e.payload,result:r}}var ct=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function ut(e){let t=[...ct,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function Fe(){return {phase:"idle"}}function dt(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 zt(e){let t=e,n=Fe(),r=new Set,o=new Set,i=null,c=null,a=null,s=null,l=0,d=null,g=()=>{for(let p of r)p(n);},h=p=>{for(let k of o)k(p);},b=p=>{n=p,g();},u=()=>{l+=1,s?.abort(),s=null;},f=()=>{i?.stop(),i=null,h(null),a!==null&&w()&&(document.documentElement.style.cursor=a,a=null);},m=()=>{u(),f(),c=null,b(Fe());},P=()=>{if(!w())return;f(),c=null;let p=ut(t.picker);a=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",b({phase:"picking"}),i=ke(p,{onHover:h,onSelect:({element:k,descriptor:q})=>{c=k,f(),b({phase:"review",selection:q});},onCancel:()=>{m();}});},R=()=>{let p=Ee();if(p.length!==0)for(let k of p)ne({payload:k,...t.transport?{transport:t.transport}:{}}).catch(()=>{ee(k);});};if(w()){setTimeout(R,1e3);let p=()=>R();window.addEventListener("online",p),d=()=>window.removeEventListener("online",p);}return {getState:()=>n,subscribe(p){return r.add(p),()=>r.delete(p)},subscribeHover(p){return o.add(p),()=>o.delete(p)},start(){n.phase==="capturing"||n.phase==="submitting"||n.phase!=="picking"&&P();},stop(){m();},clearSelection(){n.phase==="capturing"||n.phase==="submitting"||P();},setConfig(p){t=p;},async submit(p,k){if(!w()){let E=y("configuration",new Error("BlocFeed submit can only run in the browser"));return b({phase:"error",lastError:E}),{ok:false}}let q=t.blocfeed_id?.trim?.()??"";if(!q){let F={phase:"error",lastError:y("configuration",new Error("Missing blocfeed_id. Create a project in BlocFeed and pass its blocfeed_id."))};return n.selection&&(F.selection=n.selection),b(F),{ok:false}}if(n.phase==="capturing"||n.phase==="submitting")return {ok:false};let L=l+1;l=L,s?.abort(),s=new AbortController;let A=s.signal,S=n.selection,Q=k?.capture?{...t.capture,...k.capture}:t.capture,oe=!!(Q?.element||Q?.fullPage),ie={phase:oe?"capturing":"submitting"};S&&(ie.selection=S),b(ie);try{let E=oe?await ye({selectionElement:c,capture:Q,signal:A}):void 0;if(A.aborted||l!==L)return {ok:!1};let F={phase:"submitting"};S&&(F.selection=S),E&&(F.capture=E),b(F);let C={};S&&(C.selection=S),E&&(C.capture=E);let Ce=await be({config:t.metadata,context:C,...t.user?{user:t.user}:{}}),_={version:1,createdAt:new Date().toISOString(),blocfeed_id:q,message:p,metadata:Ce};k?.category&&(_.category=k.category),t.user&&(_.user=t.user),S&&(_.selection=S),E&&(_.screenshots=E);let{result:x}=await ne({payload:_,signal:A,...t.transport?{transport:t.transport}:{}});if(A.aborted||l!==L)return x;if(x.ok){let W={phase:"success",lastSubmit:x};return S&&(W.selection=S),E&&(W.capture=E),b(W),x}dt(x)&&ee(_);let _e=x.api?.error??y("unknown",new Error("Submission failed")),z={phase:"error",lastSubmit:x,lastError:_e};return S&&(z.selection=S),E&&(z.capture=E),b(z),x}catch(E){if(A.aborted||l!==L)return {ok:false};let C={phase:"error",lastError:A.aborted?y("aborted",E):y("unknown",E)};return S&&(C.selection=S),b(C),{ok:false}}finally{l===L&&(s=null);}},__unsafeGetSelectedElement(){return c},destroy(){m(),r.clear(),o.clear(),d?.(),d=null;}}}var I=[],D=[],Te=20,Ae=15,N={},O=null,H=null,U=null,j=false;function ft(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function mt(e,t){let n=t.map(ft).join(" "),r=t.find(i=>i instanceof Error),o={level:e,message:n.slice(0,2e3),timestamp:Date.now()};for(r?.stack&&(o.stack=r.stack.slice(0,2e3)),I.push(o);I.length>Te;)I.shift();}function re(e){if(!e.url.includes("blocfeed.com"))for(D.push(e);D.length>Ae;)D.shift();}function Yt(e={}){if(!(j||!w())){if(j=true,Te=e.consoleLimit??20,Ae=e.networkLimit??15,e.console!==false){let t=e.consoleLevels??["error","warn"];for(let n of t)N[n]=console[n],console[n]=(...r)=>{mt(n,r),N[n]?.apply(console,r);};}if(e.network!==false&&typeof window.fetch=="function"){O=window.fetch;let t=O;window.fetch=async function(r,o){let i=typeof r=="string"?r:r instanceof URL?r.toString():r.url,c=(o?.method??"GET").toUpperCase(),a=Date.now();try{let s=await t.call(window,r,o);return s.ok||re({url:i.slice(0,500),method:c,status:s.status,statusText:s.statusText,timestamp:a,durationMs:Date.now()-a}),s}catch(s){throw re({url:i.slice(0,500),method:c,status:0,statusText:s instanceof Error?s.message:"Network error",timestamp:a,durationMs:Date.now()-a}),s}};}if(e.network!==false&&typeof XMLHttpRequest<"u"){H=XMLHttpRequest.prototype.open,U=XMLHttpRequest.prototype.send;let t=H,n=U;XMLHttpRequest.prototype.open=function(r,o,...i){return this.__bf_method=r.toUpperCase(),this.__bf_url=String(o),t.apply(this,[r,o,...i])},XMLHttpRequest.prototype.send=function(...r){let o=this.__bf_method||"GET",i=this.__bf_url||"",c=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let a={url:i.slice(0,500),method:o,status:this.status,timestamp:c,durationMs:Date.now()-c};this.statusText&&(a.statusText=this.statusText),re(a);}}),n.apply(this,r)};}}}function Kt(){if(j){for(let[e,t]of Object.entries(N))console[e]=t;for(let e of Object.keys(N))delete N[e];O&&(window.fetch=O,O=null),H&&(XMLHttpRequest.prototype.open=H,H=null),U&&(XMLHttpRequest.prototype.send=U,U=null),j=false;}}function Gt(){return {consoleLogs:[...I],networkErrors:[...D]}}function Zt(){I=[],D=[];}
2
- export{w as a,J as b,pe as c,ye as d,be as e,ee as f,Ee as g,Ft as h,Tt as i,zt as j,Yt as k,Kt as l,Gt as m,Zt as n};