blocfeed 0.7.3 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +92 -1
- package/dist/chunk-KJRV7PRA.js +2 -0
- package/dist/chunk-ORVW2RTZ.cjs +2 -0
- package/dist/{controller-D0bplVji.d.cts → controller-BnTq9F8J.d.cts} +50 -3
- package/dist/{controller-D0bplVji.d.ts → controller-BnTq9F8J.d.ts} +50 -3
- package/dist/engine.cjs +1 -1
- package/dist/engine.d.cts +30 -3
- package/dist/engine.d.ts +30 -3
- package/dist/engine.js +1 -1
- package/dist/main.cjs +107 -4
- package/dist/main.d.cts +5 -2
- package/dist/main.d.ts +5 -2
- package/dist/main.js +107 -4
- package/package.json +4 -2
- package/dist/chunk-2BPYL6WQ.js +0 -2
- package/dist/chunk-FOZ6KYBJ.cjs +0 -2
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import {m as m$1,n,q,o,r,a,l,j,i,b}from'./chunk-KJRV7PRA.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 V=createContext(null);function ee(e){let t=useMemo(()=>l({...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(V.Provider,{value:{controller:t,state:i},children:e.children})}var ke="blocfeed-styles-v1",kt=`
|
|
3
3
|
:where([data-blocfeed-ui-root]),
|
|
4
4
|
:where([data-blocfeed-ui-root]) * {
|
|
5
5
|
box-sizing: border-box;
|
|
@@ -603,6 +603,108 @@ import {k,l,o,m,p,a,j,i,b as b$1}from'./chunk-2BPYL6WQ.js';import {createContext
|
|
|
603
603
|
/* Reduced motion */
|
|
604
604
|
/* ------------------------------------------------------------------ */
|
|
605
605
|
|
|
606
|
+
/* ------------------------------------------------------------------ */
|
|
607
|
+
/* Video recording */
|
|
608
|
+
/* ------------------------------------------------------------------ */
|
|
609
|
+
|
|
610
|
+
:where([data-blocfeed-ui-root]) .bf-record-btn {
|
|
611
|
+
display: inline-flex;
|
|
612
|
+
align-items: center;
|
|
613
|
+
gap: 6px;
|
|
614
|
+
padding: 6px 10px;
|
|
615
|
+
border-radius: 10px;
|
|
616
|
+
border: 1px solid var(--bf-border);
|
|
617
|
+
background: transparent;
|
|
618
|
+
color: var(--bf-panel-fg);
|
|
619
|
+
font-size: 13px;
|
|
620
|
+
font-family: var(--bf-font);
|
|
621
|
+
cursor: pointer;
|
|
622
|
+
user-select: none;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
:where([data-blocfeed-ui-root]) .bf-record-btn:hover {
|
|
626
|
+
border-color: var(--bf-danger);
|
|
627
|
+
color: var(--bf-danger);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
:where([data-blocfeed-ui-root]) .bf-record-btn:focus-visible {
|
|
631
|
+
outline: 2px solid var(--bf-accent);
|
|
632
|
+
outline-offset: 2px;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
:where([data-blocfeed-ui-root]) .bf-record-btn[disabled] {
|
|
636
|
+
opacity: 0.6;
|
|
637
|
+
cursor: not-allowed;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
:where([data-blocfeed-ui-root]) .bf-recording-indicator {
|
|
641
|
+
display: flex;
|
|
642
|
+
align-items: center;
|
|
643
|
+
gap: 8px;
|
|
644
|
+
font-size: 12px;
|
|
645
|
+
color: var(--bf-danger);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
:where([data-blocfeed-ui-root]) .bf-rec-dot {
|
|
649
|
+
width: 8px;
|
|
650
|
+
height: 8px;
|
|
651
|
+
border-radius: 50%;
|
|
652
|
+
background: var(--bf-danger);
|
|
653
|
+
flex-shrink: 0;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
:where([data-blocfeed-ui-root]) .bf-rec-dot-pulse {
|
|
657
|
+
animation: bf-rec-pulse 1s ease-in-out infinite;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
@keyframes bf-rec-pulse {
|
|
661
|
+
0%, 100% { opacity: 1; }
|
|
662
|
+
50% { opacity: 0.3; }
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
:where([data-blocfeed-ui-root]) .bf-video-preview {
|
|
666
|
+
position: relative;
|
|
667
|
+
border-radius: 8px;
|
|
668
|
+
overflow: hidden;
|
|
669
|
+
border: 1px solid var(--bf-border);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
:where([data-blocfeed-ui-root]) .bf-video-preview video {
|
|
673
|
+
width: 100%;
|
|
674
|
+
max-height: 120px;
|
|
675
|
+
object-fit: contain;
|
|
676
|
+
display: block;
|
|
677
|
+
background: black;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
:where([data-blocfeed-ui-root]) .bf-video-remove {
|
|
681
|
+
position: absolute;
|
|
682
|
+
top: 4px;
|
|
683
|
+
right: 4px;
|
|
684
|
+
background: rgba(0, 0, 0, 0.7);
|
|
685
|
+
border: none;
|
|
686
|
+
color: white;
|
|
687
|
+
border-radius: 50%;
|
|
688
|
+
width: 20px;
|
|
689
|
+
height: 20px;
|
|
690
|
+
font-size: 12px;
|
|
691
|
+
cursor: pointer;
|
|
692
|
+
display: flex;
|
|
693
|
+
align-items: center;
|
|
694
|
+
justify-content: center;
|
|
695
|
+
line-height: 1;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
:where([data-blocfeed-ui-root]) .bf-video-remove:hover {
|
|
699
|
+
background: rgba(0, 0, 0, 0.9);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
:where([data-blocfeed-ui-root]) .bf-video-meta {
|
|
703
|
+
font-size: 11px;
|
|
704
|
+
color: var(--bf-muted);
|
|
705
|
+
padding: 4px 8px;
|
|
706
|
+
}
|
|
707
|
+
|
|
606
708
|
/* ------------------------------------------------------------------ */
|
|
607
709
|
/* Watermark */
|
|
608
710
|
/* ------------------------------------------------------------------ */
|
|
@@ -631,9 +733,10 @@ import {k,l,o,m,p,a,j,i,b as b$1}from'./chunk-2BPYL6WQ.js';import {createContext
|
|
|
631
733
|
:where([data-blocfeed-ui-root]) .bf-panel,
|
|
632
734
|
:where([data-blocfeed-ui-root]) .bf-toast,
|
|
633
735
|
:where([data-blocfeed-ui-root]) .bf-hint,
|
|
634
|
-
:where([data-blocfeed-ui-root]) .bf-cursor
|
|
736
|
+
:where([data-blocfeed-ui-root]) .bf-cursor,
|
|
737
|
+
:where([data-blocfeed-ui-root]) .bf-rec-dot-pulse {
|
|
635
738
|
animation: none;
|
|
636
739
|
}
|
|
637
740
|
}
|
|
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,
|
|
741
|
+
`;function Te(){if(!a()||document.getElementById(ke))return;let e=document.createElement("style");e.id=ke,e.textContent=kt,document.head.appendChild(e);}var Se={triggerLabel:"Feedback",panelTitle:"Feedback",hintText:"Click an element to attach your feedback. Press Esc to cancel.",cancelButton:"Cancel",rePickButton:"Re-pick",closeButton:"Close",textareaPlaceholder:"What's happening? What did you expect?",screenshotElement:"Screenshot element",screenshotFullPage:"Full page",capturingText:"Capturing screenshots\u2026",submittingText:"Submitting\u2026",successText:"Sent. Thank you!",toastText:"Feedback sent",sendButton:"Send",categoryBug:"Bug",categoryFeature:"Feature",categoryUx:"UX",categoryGeneral:"General",recordButton:"Record",stopRecordButton:"Stop",recordingText:"Recording\u2026",recordingDeniedText:"Screen share was denied",videoPreviewLabel:"Video attached",removeVideoButton:"Remove"};function Pe(e){return e?{...Se,...e}:Se}function te(){let e=useContext(V);if(!e)throw new Error("useBlocFeed must be used within a <BlocFeedProvider />");return {state:e.state,controller:e.controller,start:e.controller.start,stop:e.controller.stop,clearSelection:e.controller.clearSelection,submit:e.controller.submit,startRecording:e.controller.startRecording,stopRecording:e.controller.stopRecording,removeVideo:e.controller.removeVideo}}function v(e){switch(e){case "bottom-left":return "bf-trigger bf-trigger-bl";case "top-right":return "bf-trigger bf-trigger-tr";case "top-left":return "bf-trigger bf-trigger-tl";default:return "bf-trigger"}}function g({size:e=14}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:jsx("path",{d:"M20 6L9 17l-5-5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ce({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 Ee({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 Fe({position:e,onClick:t,isVisible:i,label:o,queueCount:a,showSuccess:l}){return i?jsxs("button",{className:v(e),type:"button",onClick:t,"aria-label":o,children:[l?jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})}):jsxs(Fragment,{children:[jsx("span",{className:"bf-dot","aria-hidden":"true"}),o]}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]}):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=a=>t(a.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}var Ft={duration:.18,ease:"easeOut"},Nt={duration:0};function Re({position:e,onClick:t,isVisible:i,label:o,queueCount:a,showSuccess:l}){let[n,c]=useState(false),r=m(),s=r?Nt:Ft;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:v(e),type:"button",onClick:t,onMouseEnter:()=>c(true),onMouseLeave:()=>c(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:l?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsx(motion.span,{className:"bf-dot","aria-hidden":"true",animate:r?{}:{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||r?s:{duration:2,repeat:1/0,ease:"easeInOut"}}),jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.span,{initial:{opacity:0,x:r?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:r?0:-6},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"dot")})}var zt={duration:.18,ease:"easeOut"},Le={duration:0};function Ae({position:e,onClick:t,isVisible:i,label:o,queueCount:a,showSuccess:l}){let[n,c]=useState(false),r=m(),s=r?Le:zt;return jsx(AnimatePresence,{mode:"wait",children:i&&jsxs(motion.div,{className:v(e),initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{y:8,opacity:0},transition:s,onMouseEnter:()=>c(true),onMouseLeave:()=>c(false),style:{background:"transparent",border:"none",boxShadow:"none",padding:0},children:[jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.div,{initial:{opacity:0,y:r?0:4},animate:{opacity:1,y:0},exit:{opacity:0,y:r?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:r?{}:{y:[0,-3,0]},transition:r?Le:{y:{duration:3,repeat:1/0,ease:"easeInOut"}},whileHover:{scale:1.1,borderColor:"var(--bf-accent)"},whileTap:{scale:.9},children:[l?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:16})},"success"):jsx(Ce,{size:16}),a>0&&jsx("span",{className:"bf-badge bf-badge-float","aria-label":`${a} queued`,children:a})]})]},"bubble")})}var Wt={duration:.2,ease:"easeOut"},_t={duration:0};function We(e){return e==="bottom-left"||e==="top-left"}function Ht(e){return `bf-trigger-edge ${We(e)?"bf-trigger-edge-left":"bf-trigger-edge-right"}`}function _e({position:e,onClick:t,isVisible:i,label:o,queueCount:a,showSuccess:l}){let[n,c]=useState(false),r=We(e),s=m(),h=s?_t:Wt;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:Ht(e),type:"button",onClick:t,onMouseEnter:()=>c(true),onMouseLeave:()=>c(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:l?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:h,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsxs(motion.span,{animate:{rotate:s||n?0:r?-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,[r?"left":"right"]:0,width:"2px",background:"var(--bf-accent)"}}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"edge-tab")})}var $t={duration:.18,ease:"easeOut"},Kt={duration:0};function Oe({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 $e({position:e,onClick:t,isVisible:i,label:o,queueCount:a,showSuccess:l}){let[n,c]=useState(false),r=m(),s=r?Kt:$t;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:v(e),type:"button",onClick:t,onMouseEnter:()=>c(true),onMouseLeave:()=>c(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:l?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsxs("span",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsx(Oe,{delay:0,hovered:n,reduced:r}),jsx(Oe,{delay:.7,hovered:n,reduced:r}),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:r?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:r?0:-6},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"pulse-ring")})}var Yt={duration:.18,ease:"easeOut"},Gt={duration:0};function jt(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 Ue({position:e,onClick:t,isVisible:i,label:o,queueCount:a,showSuccess:l}){let[n,c]=useState(false),r=m(),s=r?Gt:Yt;return jsx(AnimatePresence,{mode:"wait",children:i&&jsxs(motion.button,{className:jt(e),type:"button",onClick:t,onMouseEnter:()=>c(true),onMouseLeave:()=>c(false),"aria-label":o,initial:{opacity:0,y:r?0:5},animate:{opacity:n?1:.65,y:0},exit:{opacity:0,y:r?0:5},transition:s,whileTap:{scale:.95},children:[l?jsx("span",{style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})}):jsxs(Fragment,{children:[jsx("span",{children:o}),a>0&&jsx("span",{className:"bf-badge",style:{marginLeft:"4px"},"aria-label":`${a} queued`,children:a})]}),!r&&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 Jt={duration:.18,ease:"easeOut"},Zt={duration:0};function Ye({position:e,onClick:t,isVisible:i,label:o,queueCount:a,showSuccess:l}){let[n,c]=useState(false),r=m(),s=r?Zt:Jt;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:v(e),type:"button",onClick:t,onMouseEnter:()=>c(true),onMouseLeave:()=>c(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:l?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsx(motion.span,{style:{display:"inline-flex",flexShrink:0},animate:r?{}:n?{scale:1.2,rotate:0}:{rotate:[-5,5,-5]},transition:n||r?s:{duration:3,repeat:1/0,ease:"easeInOut"},children:jsx(Ee,{size:16})}),jsx(AnimatePresence,{mode:"wait",children:n&&jsx(motion.span,{initial:{opacity:0,x:r?0:-8},animate:{opacity:1,x:0},exit:{opacity:0,x:r?0:-8},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"icon-pop")})}var ro={duration:.18,ease:"easeOut"},ao={duration:0};function Qe({position:e,onClick:t,isVisible:i,label:o,queueCount:a,showSuccess:l}){let[n,c]=useState(false),r=m(),s=r?ao:ro;return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:v(e),type:"button",onClick:t,onMouseEnter:()=>c(true),onMouseLeave:()=>c(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:l?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:s,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsxs("span",{style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"10px",height:"10px",flexShrink:0},children:[jsx(motion.span,{"aria-hidden":"true",style:{width:"10px",height:"10px",borderRadius:"50%",background:"var(--bf-accent)",position:"relative",zIndex:1},animate:r?{}:{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||r?s:{duration:2,repeat:1/0,ease:"easeInOut"}}),!n&&!r&&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:r?0:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:r?0:-6},transition:s,style:{whiteSpace:"nowrap"},children:o},"label")}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"beacon")})}var lo={duration:.18,ease:"easeOut"},po={duration:0};function et({position:e,onClick:t,isVisible:i,label:o,queueCount:a,showSuccess:l}){let[n,c]=useState(false),[r,s]=useState(0),h=m(),M=h?po:lo,f=useRef(null);useEffect(()=>{if(f.current&&(clearInterval(f.current),f.current=null),!i||n||h){s(n||h?o.length:0);return}let u=8,C=o.length*2+u*2,y=0;return f.current=setInterval(()=>{y=(y+1)%C,y<=o.length?s(y):y<=o.length+u?s(o.length):y<=o.length*2+u?s(o.length*2+u-y):s(0);},100),()=>{f.current&&(clearInterval(f.current),f.current=null);}},[i,n,h,o]);let S=o.slice(0,r);return jsx(AnimatePresence,{mode:"wait",children:i&&jsx(motion.button,{className:v(e),type:"button",onClick:t,onMouseEnter:()=>c(true),onMouseLeave:()=>c(false),"aria-label":o,initial:{opacity:0,y:h?0:5},animate:{opacity:1,y:0},exit:{opacity:0,y:h?0:5},transition:M,whileTap:{scale:.95},style:{minWidth:"44px"},children:l?jsx(motion.span,{initial:{scale:0},animate:{scale:1},transition:M,style:{display:"inline-flex",color:"var(--bf-accent)"},children:jsx(g,{size:14})},"success"):jsxs(Fragment,{children:[jsx("span",{className:"bf-dot","aria-hidden":"true"}),jsxs("span",{style:{whiteSpace:"nowrap",minWidth:"1ch"},children:[S,jsx("span",{className:"bf-cursor","aria-hidden":"true"})]}),a>0&&jsx("span",{className:"bf-badge","aria-label":`${a} queued`,children:a})]})},"typewriter")})}function tt(e){switch(e){case "dot":return Re;case "bubble":return Ae;case "edge-tab":return _e;case "pulse-ring":return $e;case "minimal":return Ue;case "icon-pop":return Ye;case "beacon":return Qe;case "typewriter":return et;default:return Fe}}function rt(e,t,i){return Math.max(t,Math.min(i,e))}function mo(e,t,i="bottom-right"){let a=window.innerWidth,l=window.innerHeight,n;n=rt(e.x,12,Math.max(12,a-t-12));let c=e.y+e.height+12,r=Math.max(12,e.y-240);return {top:c+240<=l?c:r,left:n}}function ho(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 xo(e){let t=useRef(null);return useEffect(()=>{if(!e||!t.current)return;t.current.querySelector(".bf-textarea")?.focus();let o=a=>{if(a.key!=="Tab"||!t.current)return;let l=t.current.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(l.length===0)return;let n=l[0],c=l[l.length-1];a.shiftKey&&document.activeElement===n?(a.preventDefault(),c.focus()):!a.shiftKey&&document.activeElement===c&&(a.preventDefault(),n.focus());};return document.addEventListener("keydown",o,{capture:true}),()=>document.removeEventListener("keydown",o,{capture:true})},[e]),t}function yo(e,t){return e?typeof e=="function"?e(t):e.some(i=>i.endsWith("*")?t.startsWith(i.slice(0,-1)):t===i):true}function vo(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 a=history.pushState,l=history.replaceState;return history.pushState=function(...n){a.apply(this,n),o();},history.replaceState=function(...n){l.apply(this,n),o();},()=>{window.removeEventListener("popstate",o),history.pushState=a,history.replaceState=l;}},[]),yo(e,t)}function wo(e){let[t,i]=useState(()=>!e||e==="dark"?"dark":e==="light"?"light":typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return useEffect(()=>{if(e!=="auto"){i(e==="light"?"light":"dark");return}let o=window.matchMedia("(prefers-color-scheme: dark)"),a=l=>i(l.matches?"dark":"light");return i(o.matches?"dark":"light"),o.addEventListener("change",a),()=>o.removeEventListener("change",a)},[e]),t}var ko=["bug","feature","ux","general"],To={bug:"categoryBug",feature:"categoryFeature",ux:"categoryUx",general:"categoryGeneral"};function oe(e){let t=Math.floor(e/1e3),i=Math.floor(t/60),o=t%60;return `${i}:${String(o).padStart(2,"0")}`}function So(e){return e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Po(e){let{state:t,controller:i$1,start:o,stop:a,clearSelection:l,submit:n}=te(),c=e.config.ui?.position,r$1=Pe(e.config.ui?.strings),s=e.config.ui?.branding!==false,[h,M]=useState(null),[f,S]=useState(""),[u,C]=useState(e.config.capture?.element??true),[y,ae]=useState(e.config.capture?.fullPage??false),[it,ie]=useState(null),[O,ne]=useState(void 0),se=e.config.ui?.categories??ko,nt=e.config.recording?.enabled===true&&j(),st=e.config.recording?.maxDurationMs??3e4,[ct,lt]=useState(false),[j$1,dt]=useState(0);useEffect(()=>{let d=window.setTimeout(()=>{let N=r();dt(N.findings.length);},500);return ()=>window.clearTimeout(d)},[]),useImperativeHandle(e.handleRef,()=>({open:o,close:a,submit:d=>n(d),startRecording:()=>i$1.startRecording(),stopRecording:()=>i$1.stopRecording(),get isOpen(){return t.phase!=="idle"}}),[o,a,n,i$1,t.phase]);let ce=t.phase==="review"||t.phase==="recording"||t.phase==="capturing"||t.phase==="submitting"||t.phase==="error"||t.phase==="success",pt=xo(ce),[ft,ut]=useState(0);useEffect(()=>{t.phase==="idle"&&ut(i());},[t.phase]);let[bt,le]=useState(false),de=useRef(t.phase);useEffect(()=>{if(de.current==="success"&&t.phase==="idle"){le(true);let d=window.setTimeout(()=>le(false),1500);return ()=>window.clearTimeout(d)}de.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)),fe=P=>{let ht=/Mac|iPod|iPhone|iPad/.test(navigator.platform);if(L.has("mod")){if(ht?!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():a());};return document.addEventListener("keydown",fe),()=>document.removeEventListener("keydown",fe)},[e.config.ui?.shortcut,t.phase,o,a]),useEffect(()=>i$1.subscribeHover(M),[i$1]),useEffect(()=>{let d=i$1.__unsafeGetSelectedElement();if(!d||t.phase==="idle"||t.phase==="picking"){ie(null);return}let N=()=>{ie(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);}},[i$1,t.phase,t.selection?.selector]),useEffect(()=>{t.phase==="review"&&(S(""),C(e.config.capture?.element??true),ae(e.config.capture?.fullPage??false),ne(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(()=>a(),1200);return ()=>window.clearTimeout(d)},[t.phase,a]);let k=t.phase==="capturing"||t.phase==="submitting"||t.phase==="recording",F=t.phase==="picking"?h?.rect??null:it??t.selection?.rect??null,Q=useMemo(()=>F?mo(F,360,c):null,[F?.x,F?.y,F?.width,F?.height,c]),pe=t.lastError?.message,q=useCallback(()=>{let d={capture:{element:u,fullPage:y}};O&&(d.category=O),n(f,d);},[n,f,u,y,O]),gt=useCallback(d=>{(d.metaKey||d.ctrlKey)&&d.key==="Enter"&&f.trim().length>0&&!k&&(d.preventDefault(),q());},[q,f,k]),mt=tt(e.config.ui?.triggerStyle);return jsxs(Fragment,{children:[jsx(mt,{position:c,onClick:()=>o(),isVisible:t.phase==="idle",label:e.config.ui?.triggerLabel??r$1.triggerLabel,queueCount:ft,showSuccess:bt}),t.phase!=="idle"&&jsxs("div",{className:"bf-overlay",role:"presentation",children:[t.phase!=="picking"&&jsx("div",{className:"bf-blocker",role:"presentation",onClick:()=>a()}),F&&jsx(ho,{rect:F}),t.phase==="picking"&&jsxs("div",{className:"bf-hint",role:"status","aria-live":"polite",children:[jsx("p",{id:"bf-hint-text",children:r$1.hintText}),jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),"aria-label":r$1.cancelButton,children:r$1.cancelButton})]}),ce&&Q&&jsxs("div",{ref:pt,className:"bf-panel",style:{left:Q.left,top:Q.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:r$1.panelTitle}),jsxs("div",{className:"bf-row",style:{justifyContent:"flex-end"},children:[jsx("button",{type:"button",className:"bf-btn",onClick:()=>l(),disabled:k,"aria-label":r$1.rePickButton,children:r$1.rePickButton}),jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),disabled:k,"aria-label":r$1.closeButton,children:r$1.closeButton})]})]}),jsxs("div",{className:"bf-panelBody",children:[jsx("textarea",{className:"bf-textarea",placeholder:r$1.textareaPlaceholder,value:f,onChange:d=>S(d.target.value),onKeyDown:gt,disabled:k,"aria-label":r$1.panelTitle}),se.length>0&&jsx("div",{className:"bf-pills",role:"group","aria-label":"Feedback category",children:se.map(d=>jsx("button",{type:"button",className:`bf-pill${O===d?" bf-pill-active":""}`,onClick:()=>ne(O===d?void 0:d),disabled:k,children:r$1[To[d]]},d))}),jsxs("div",{className:"bf-row",role:"group","aria-label":r$1.screenshotElement,children:[jsxs("label",{children:[jsx("input",{type:"checkbox",checked:u,onChange:d=>C(d.target.checked),disabled:k}),r$1.screenshotElement]}),jsxs("label",{children:[jsx("input",{type:"checkbox",checked:y,onChange:d=>ae(d.target.checked),disabled:k}),r$1.screenshotFullPage]})]}),nt&&t.phase==="review"&&!t.video&&jsxs("button",{type:"button",className:"bf-record-btn",onClick:()=>i$1.startRecording(),disabled:k,"aria-label":r$1.recordButton,children:[jsx("span",{className:"bf-rec-dot","aria-hidden":"true"}),r$1.recordButton]}),t.phase==="recording"&&jsxs("div",{className:"bf-recording-indicator",role:"status","aria-live":"polite",children:[jsx("span",{className:"bf-rec-dot bf-rec-dot-pulse","aria-hidden":"true"}),jsxs("span",{children:[r$1.recordingText," ",oe(t.recordingElapsedMs??0)," / ",oe(st)]}),jsx("button",{type:"button",className:"bf-btn",onClick:()=>i$1.stopRecording(),"aria-label":r$1.stopRecordButton,children:r$1.stopRecordButton})]}),t.video&&t.phase==="review"&&jsxs("div",{className:"bf-video-preview",children:[jsx("video",{src:t.video.blobUrl,controls:true,muted:true,playsInline:true}),jsx("button",{type:"button",className:"bf-video-remove",onClick:()=>i$1.removeVideo(),"aria-label":r$1.removeVideoButton,children:"\xD7"}),jsxs("div",{className:"bf-video-meta",children:[r$1.videoPreviewLabel," (",oe(t.video.durationMs),", ",So(t.video.sizeBytes),")"]})]}),t.phase==="capturing"&&jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsx("span",{className:"bf-spinner","aria-hidden":"true"}),r$1.capturingText]}),t.phase==="submitting"&&jsxs("div",{className:"bf-status",role:"status","aria-live":"polite",children:[jsx("span",{className:"bf-spinner","aria-hidden":"true"}),r$1.submittingText]}),t.phase==="success"&&jsx("div",{className:"bf-status",role:"status","aria-live":"polite",children:r$1.successText}),t.phase==="error"&&pe&&jsx("div",{className:"bf-error",role:"alert",children:pe}),jsxs("div",{className:"bf-actions",children:[jsx("button",{type:"button",className:"bf-btn",onClick:()=>a(),disabled:k,"aria-label":r$1.cancelButton,children:r$1.cancelButton}),jsx("button",{type:"button",className:"bf-btn bf-btnPrimary",onClick:q,disabled:k||f.trim().length===0,"aria-label":r$1.sendButton,children:r$1.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:r$1.toastText}),j$1>0&&!ct&&jsxs("div",{className:"bf-security-banner",role:"alert",children:[jsx("button",{type:"button",className:"bf-security-banner-dismiss",onClick:()=>lt(true),"aria-label":"Dismiss",children:"\xD7"}),jsx("strong",{children:"Security Warning"}),j$1," potential secret",j$1>1?"s":""," exposed in client code. Check your environment variables."]})]})}var Co=forwardRef(function(t,i){let o$1={...t.config??{},blocfeed_id:t.blocfeed_id},[a,l]=useState(null),n$1=vo(o$1.ui?.showOn),c=wo(o$1.ui?.theme?.mode),r$1=!!o$1.diagnostics;useEffect(()=>{if(r$1)return m$1(o$1.diagnostics),()=>n()},[r$1]);let s=!!o$1.security;useEffect(()=>{s&&q(o$1.security);},[s]);let h=useRef(t.config?.metadata?.enrich);h.current=t.config?.metadata?.enrich;let M=useMemo(()=>{if(t.config)return {...t.config,metadata:{...t.config.metadata,enrich:async f=>{let S=h.current,u=S?await S(f):{},C=o(),y=r();return {...u,...C.consoleLogs.length>0?{_consoleLogs:C.consoleLogs}:{},...C.networkErrors.length>0?{_networkErrors:C.networkErrors}:{},...y.findings.length>0?{_securityFindings:y.findings}:{}}}}}},[]);return useEffect(()=>{Te();let f=document.createElement("div");f.setAttribute("data-blocfeed-ui-root","true"),f.setAttribute("data-blocfeed-ui","true"),f.setAttribute("data-bf-theme",c);let S=o$1.ui?.zIndex;typeof S=="number"&&f.style.setProperty("--bf-z",String(S));let u=o$1.ui?.theme;return u&&(u.accentColor&&f.style.setProperty("--bf-accent",u.accentColor),u.panelBackground&&f.style.setProperty("--bf-panel-bg",u.panelBackground),u.panelForeground&&f.style.setProperty("--bf-panel-fg",u.panelForeground),u.fontFamily&&f.style.setProperty("--bf-font",u.fontFamily)),document.body.appendChild(f),l(f),()=>{f.remove(),l(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,c]),useEffect(()=>{a&&a.setAttribute("data-bf-theme",c);},[a,c]),!n$1||!a?null:createPortal(jsx(ee,{blocfeed_id:o$1.blocfeed_id,...M?{config:M}:{},children:jsx(Po,{config:o$1,handleRef:i})}),a)});
|
|
742
|
+
export{ee as BlocFeedProvider,Co as BlocFeedWidget,te as useBlocFeed};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blocfeed",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Drop-in feedback
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "Drop-in feedback widget for React — element picking, screenshots, and video recording.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
"feedback",
|
|
12
12
|
"widget",
|
|
13
13
|
"screenshot",
|
|
14
|
+
"video-recording",
|
|
15
|
+
"screen-capture",
|
|
14
16
|
"bug-report",
|
|
15
17
|
"product-feedback",
|
|
16
18
|
"element-picker"
|
package/dist/chunk-2BPYL6WQ.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function w(){return typeof window<"u"&&typeof document<"u"}function de(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 G(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function De(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function Oe(e){return e.replace(/\s+/g," ").trim()}function Ue(e,t=140){let n=e.textContent;if(!n)return;let r=Oe(n);if(r)return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function He(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var ge=["data-testid","data-test-id","data-test","data-qa","data-cy"],fe="data-blocfeed-component";function qe(e){let t=e.closest(`[${fe}]`);if(!t)return;let r=t.getAttribute(fe)?.trim();return r||void 0}function ze(e){for(let t of ge){let n=e.closest(`[${t}]`);if(!n)continue;let o=n.getAttribute(t)?.trim();if(o)return o}}function me(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 S(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 S(o)}}}function $e(e){let t=me(e);if(!t)return;let n=I(t._debugInfo);if(n)return n;let r=t._debugOwner!==void 0;if(r){let s=t._debugOwner;for(let a=0;s&&a<50;a+=1){let d=I(s._debugInfo);if(d)return d;let g=S(s.type)??S(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 a=0;s&&a<50;a+=1){let d=I(s._debugInfo);if(d)return d;let g=S(s.type)??S(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 a=I(i._debugInfo);if(a)return a;let d=S(i.type)??S(i.elementType);if(d&&!T(d))return d;i=i.return;}let l=e.parentElement;for(let s=0;l&&s<15;s+=1){let a=me(l);if(a){let d=I(a._debugInfo);if(d)return d;let g=S(a.type)??S(a.elementType);if(g&&!T(g))return g;if(a._debugOwner){let h=S(a._debugOwner.type)??S(a._debugOwner.elementType);if(h&&!T(h))return h}if(a._owner&&a._owner!==a._debugOwner){let h=S(a._owner.type)??S(a._owner.elementType);if(h&&!T(h))return h}}l=l.parentElement;}}function je(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${de(n)}`;for(let r of ge){let o=e.getAttribute(r);if(o)return `${t}[${r}="${de(o)}"]`}return `${t}:nth-of-type(${He(e)})`}function Xe(e,t=10){let n=[],r=e;for(;r&&n.length<t;){let o=je(r);if(n.unshift(o),o.startsWith("#"))break;r=r.parentElement;}return n.join(" > ")}function pe(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function J(e,t){if(!e||pe(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(pe(n,t.ignoreSelectors))return null;if(t.isSelectable?.(n)??Ze(n))return n;n=n.parentElement;}return null}function Ze(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function he(e){let t=e.getBoundingClientRect(),n={selector:Xe(e),tagName:e.tagName.toLowerCase(),rect:G(t),pageRect:De(t)},r=e.getAttribute("id");r&&(n.id=r);let o=e.className;typeof o=="string"&&o.trim()&&(n.className=o);let i=Ue(e);i&&(n.textSnippet=i);let c=qe(e)??$e(e);c&&(n.componentName=c);let l=ze(e);return l&&(n.testId=l),n}var V=null;async function we(){return V||(V=import('html-to-image')),V}async function We(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 ye(e,t){let{width:n,height:r}=await We(e);return {dataUrl:e,mime:t,width:n,height:r}}function L(e){if(e?.aborted)throw new Error("Aborted")}function be(){return {async captureElement(e,t){if(!w())throw new Error("captureElement can only run in the browser");L(t.signal);let n=await we();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 ye(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)),c=Math.max(1,Math.round(r*o)),l=await we();L(e.signal);let s=e.mime==="image/jpeg"?await l.toJpeg(t,{width:i,height:c,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await l.toPng(t,{width:i,height:c,pixelRatio:e.pixelRatio});return L(e.signal),await ye(s,e.mime)}}}function Ke(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:Ke(t)};return n&&(r.detail=n),r}var Qe=12e3,Ye=2048,Ge=.92;function Ee(){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 ke(e,t,n){let r=new Promise((i,c)=>{let l=setTimeout(()=>c(new Error("Timeout")),t);typeof l.unref=="function"&&l.unref();}),o=[e,r];return n&&o.push(Je(n)),await Promise.race(o)}function Ve(e){if(!w())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function et(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()||!et(n))return;let o=Ee(),i=[],c=n?.timeoutMs??Qe,l=n?.maxDimension??Ye,s=n?.mime??"image/png",a=n?.quality??Ge,d=n?.adapter??be(),g={},h=Ve(n);if(n?.element&&t)try{let f=t.getBoundingClientRect(),m=Math.min(1,l/Math.max(f.width,f.height)),v=Math.min(h,h*m),A=await ke(Promise.resolve(d.captureElement(t,{..._e({mime:s,quality:a,pixelRatio:v,maxDimension:l,includeQuality:s==="image/jpeg",...r?{signal:r}:{}})})),c,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 ke(Promise.resolve(d.captureFullPage(_e({mime:s,quality:a,pixelRatio:h,maxDimension:l,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=Ee(),u={startedAt:o,finishedAt:b,durationMs:Math.max(0,b-o)};return i.length>0&&(u.errors=i),{...g,diagnostics:u}}function tt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function nt(){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:tt()}:{}}function rt(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 ve(e){let{config:t,context:n,user:r}=e;if(t?.enabled===false)return {};let o={...nt(),...rt(r)},i=t?.enrich;if(!i)return o;try{let c=await i(n);return {...o,...c}}catch(c){let l=y("unknown",c);return {...o,blocfeedMetadataError:l.message}}}var ee="blocfeed-queue",ot=50;function te(){if(!w())return [];try{let e=localStorage.getItem(ee);if(!e)return [];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return []}}function ne(e){if(w())try{e.length===0?localStorage.removeItem(ee):localStorage.setItem(ee,JSON.stringify(e));}catch{}}function it(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 re(e){let t=te(),n=it(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>ot;)t.shift();ne(t);}function Pe(){let e=te();return e.length===0?[]:(ne([]),e.map(t=>t.payload))}function Ht(){ne([]);}function qt(){return te().length}function oe(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 j(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function X(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function Ae(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,l=(u,f=false)=>{if(!u){i=null,c=null,t.onHover(null);return}let m=G(u.getBoundingClientRect()),v=`${Math.round(m.x)}:${Math.round(m.y)}:${Math.round(m.width)}:${Math.round(m.height)}`;!f&&u===i&&v===c||(i=u,c=v,t.onHover({element:u,rect:m}));},s=oe(u=>{if(j(u.target))return;let f=document.elementFromPoint(u.clientX,u.clientY),m=J(f,o);l(m);}),a=oe(()=>{i&&l(i,true);}),d=u=>{j(u.target)||(X(u),u.pointerType==="mouse"&&u.preventDefault());},g=u=>{j(u.target)||(X(u),u.pointerType==="mouse"&&u.preventDefault());},h=u=>{if(j(u.target))return;X(u),u.preventDefault();let f=document.elementFromPoint(u.clientX,u.clientY),m=J(f,o);m&&t.onSelect({element:m,descriptor:he(m)});},b=u=>{u.key==="Escape"&&(X(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",a,{capture:true,passive:true}),window.addEventListener("resize",a,{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",a,{capture:true}),window.removeEventListener("resize",a),s.cancel(),a.cancel(),t.onHover(null);}}}var at=12e3,st=2,ct=500,lt=2e3,Fe="https://blocfeed.com/api/feedback",xe=0;function Te(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 ut(e){return e>=500&&e<=599}function dt(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 l=0;l<i.length;l+=1)c[l]=i.charCodeAt(l);return new Blob([c],{type:o})}function ft(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 Re(e,t,n){let r=dt(t);await fetch(e,{method:"PUT",body:r,headers:{"content-type":r.type},...n?{signal:n}:{}});}async function mt(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(`${Fe}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...o?{signal:o}:{}});}async function Ce(e){let{signal:t,transport:n}=e;if(Date.now()-xe<lt)return {ok:false,error:y("configuration",new Error("Please wait before submitting again"))};let o=n?.timeoutMs??at,i=n?.maxAttempts??st,c=n?.backoffMs??ct,l=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),{lean:s,extracted:a}=l?ft(e.payload):{lean:e.payload,extracted:{}},d={...a,...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(Fe,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s),signal:h.signal});if(f.ok){xe=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(Re(p.element,d.element,t)),d.fullPage&&p.fullPage&&k.push(Re(p.fullPage,d.fullPage,t));try{await Promise.all(k);}catch{}}else if(m.feedback_id)try{await mt({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&&ut(f.status)){let m=.85+Math.random()*.3,v=Math.round(c*2**(g-1)*m);await Te(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(c*2**(g-1)*m);await Te(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 ie(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 Ce(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 pt=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function gt(e){let t=[...pt,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function Me(){return {phase:"idle"}}function ht(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 an(e){let t=e,n=Me(),r=new Set,o=new Set,i=null,c=null,l=null,s=null,a=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=()=>{a+=1,s?.abort(),s=null;},f=()=>{i?.stop(),i=null,h(null),l!==null&&w()&&(document.documentElement.style.cursor=l,l=null);},m=()=>{u(),f(),c=null,b(Me());},v=()=>{if(!w())return;f(),c=null;let p=gt(t.picker);l=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",b({phase:"picking"}),i=Ae(p,{onHover:h,onSelect:({element:k,descriptor:$})=>{c=k,f(),b({phase:"review",selection:$});},onCancel:()=>{m();}});},A=()=>{let p=Pe();if(p.length!==0)for(let k of p)ie({payload:k,...t.transport?{transport:t.transport}:{}}).catch(()=>{re(k);});};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,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 $=t.blocfeed_id?.trim?.()??"";if(!$){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=a+1;a=N,s?.abort(),s=new AbortController;let F=s.signal,_=n.selection,K=k?.capture?{...t.capture,...k.capture}:t.capture,le=!!(K?.element||K?.fullPage),ue={phase:le?"capturing":"submitting"};_&&(ue.selection=_),b(ue);try{let E=le?await Se({selectionElement:c,capture:K,signal:F}):void 0;if(F.aborted||a!==N)return {ok:!1};let x={phase:"submitting"};_&&(x.selection=_),E&&(x.capture=E),b(x);let C={};_&&(C.selection=_),E&&(C.capture=E);let Ie=await ve({config:t.metadata,context:C,...t.user?{user:t.user}:{}}),M={version:1,createdAt:new Date().toISOString(),blocfeed_id:$,message:p,metadata:Ie};k?.category&&(M.category=k.category),t.user&&(M.user=t.user),_&&(M.selection=_),E&&(M.screenshots=E);let{result:P}=await ie({payload:M,signal:F,...t.transport?{transport:t.transport}:{}});if(F.aborted||a!==N)return P;if(P.ok){let Y={phase:"success",lastSubmit:P};return _&&(Y.selection=_),E&&(Y.capture=E),b(Y),P}ht(P)&&re(M);let Be=P.api?.error??y("unknown",new Error("Submission failed")),Q={phase:"error",lastSubmit:P,lastError:Be};return _&&(Q.selection=_),E&&(Q.capture=E),b(Q),P}catch(E){if(F.aborted||a!==N)return {ok:false};let C={phase:"error",lastError:F.aborted?y("aborted",E):y("unknown",E)};return _&&(C.selection=_),b(C),{ok:false}}finally{a===N&&(s=null);}},__unsafeGetSelectedElement(){return c},destroy(){m(),r.clear(),o.clear(),d?.(),d=null;}}}var B=[],D=[],Le=20,Ne=15,Z=[],O={},U=null,H=null,q=null,W=false,wt=["blocfeed.com","google-analytics.com","googletagmanager.com","analytics.google.com","googleads.g.doubleclick.net","googlesyndication.com","googleadservices.com","google.com/pagead","google.com/ads","facebook.net","facebook.com/tr","connect.facebook.net","graph.facebook.com","api.mixpanel.com","api-js.mixpanel.com","api.amplitude.com","api2.amplitude.com","api.segment.io","cdn.segment.com","vars.hotjar.com","in.hotjar.com","script.hotjar.com","heapanalytics.com","fullstory.com/s/fs.js","rs.fullstory.com","app.posthog.com","us.posthog.com","eu.posthog.com","api-iam.intercom.io","widget.intercom.io","sentry.io/api","browser.sentry-cdn.com","browser-intake-datadoghq.com","clarity.ms","js.hs-analytics.net","api.hubapi.com","forms.hubspot.com","plausible.io/api","client.crisp.chat","js.driftt.com","r.logrocket.com","app.pendo.io","events.launchdarkly.com","app.launchdarkly.com","grammarly.com","gnar.grammarly.com","capi.grammarly.com","api.languagetool.org","api.languagetoolplus.com","fonts.googleapis.com","fonts.gstatic.com","cdn.cookielaw.org","consent.cookiebot.com","js.stripe.com","api.stripe.com/v1/tokens","google.com/recaptcha","hcaptcha.com","bam.nr-data.net","rec.smartlook.com","o2.mouseflow.com","api.luckyorange.com","static.zdassets.com","ekr.zdassets.com"];function yt(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function bt(e,t){let n=t.map(yt).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>Le;)B.shift();}function ae(e){let t=e.url.toLowerCase();for(let n of Z)if(t.includes(n))return;for(D.push(e);D.length>Ne;)D.shift();}function ln(e={}){if(W||!w())return;W=true,Le=e.consoleLimit??20,Ne=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?Z=t.map(n=>n.toLowerCase()):Z=[...wt],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let r of n)O[r]=console[r],console[r]=(...o)=>{bt(r,o),O[r]?.apply(console,o);};}if(e.network!==false&&typeof window.fetch=="function"){U=window.fetch;let n=U;window.fetch=async function(o,i){let c=typeof o=="string"?o:o instanceof URL?o.toString():o.url,l=(i?.method??"GET").toUpperCase(),s=Date.now();try{let a=await n.call(window,o,i);return a.ok||ae({url:c.slice(0,500),method:l,status:a.status,statusText:a.statusText,timestamp:s,durationMs:Date.now()-s}),a}catch(a){throw ae({url:c.slice(0,500),method:l,status:0,statusText:a instanceof Error?a.message:"Network error",timestamp:s,durationMs:Date.now()-s}),a}};}if(e.network!==false&&typeof XMLHttpRequest<"u"){H=XMLHttpRequest.prototype.open,q=XMLHttpRequest.prototype.send;let n=H,r=q;XMLHttpRequest.prototype.open=function(o,i,...c){return this.__bf_method=o.toUpperCase(),this.__bf_url=String(i),n.apply(this,[o,i,...c])},XMLHttpRequest.prototype.send=function(...o){let i=this.__bf_method||"GET",c=this.__bf_url||"",l=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let s={url:c.slice(0,500),method:i,status:this.status,timestamp:l,durationMs:Date.now()-l};this.statusText&&(s.statusText=this.statusText),ae(s);}}),r.apply(this,o)};}}function un(){if(W){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),Z=[],W=false;}}function dn(){return {consoleLogs:[...B],networkErrors:[...D]}}function fn(){B=[],D=[];}var Et=[{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=[],ce=0,se=false;function kt(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function _t(e,t,n,r){if(R.some(c=>c.rule===e&&c.source===t))return;let i={rule:e,source:t,hint:kt(n),timestamp:Date.now()};r&&(i.location=r),R.push(i);}function z(e,t,n,r){for(let{name:o,pattern:i}of n){let c=i.exec(e);c&&_t(o,t,c[0],r);}}function St(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);z(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);z(n,"hydration",e,"__NUXT__");}}catch{}}function vt(e){try{document.querySelectorAll("script:not([src])").forEach((n,r)=>{let o=n.textContent;o&&o.length>0&&z(o,"scripts",e,`inline-script[${r}]`);});}catch{}}function Pt(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let r=n.getAttribute("content"),o=n.getAttribute("name")||n.getAttribute("property")||"";r&&r.length>10&&z(r,"meta",e,o?`meta[${o}]`:void 0);});}catch{}}function At(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&&z(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function gn(e={}){if(se||!w()||(se=true,e.secretScan===false))return;let t=[...Et,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{ce=Date.now(),n.includes("hydration")&&St(t),n.includes("scripts")&&vt(t),n.includes("meta")&&Pt(t),n.includes("dom")&&At(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 hn(){return {findings:[...R],scannedAt:ce}}function wn(){R=[],ce=0,se=false;}
|
|
2
|
-
export{w as a,G as b,be as c,Se as d,ve as e,re as f,Pe as g,Ht as h,qt as i,an as j,ln as k,un as l,dn as m,fn as n,gn as o,hn as p,wn as q};
|
package/dist/chunk-FOZ6KYBJ.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';function w(){return typeof window<"u"&&typeof document<"u"}function de(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 G(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function De(e){return {x:e.x+window.scrollX,y:e.y+window.scrollY,width:e.width,height:e.height}}function Oe(e){return e.replace(/\s+/g," ").trim()}function Ue(e,t=140){let n=e.textContent;if(!n)return;let r=Oe(n);if(r)return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function He(e){let t=1;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)n.tagName===e.tagName&&(t+=1);return t}var ge=["data-testid","data-test-id","data-test","data-qa","data-cy"],fe="data-blocfeed-component";function qe(e){let t=e.closest(`[${fe}]`);if(!t)return;let r=t.getAttribute(fe)?.trim();return r||void 0}function ze(e){for(let t of ge){let n=e.closest(`[${t}]`);if(!n)continue;let o=n.getAttribute(t)?.trim();if(o)return o}}function me(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 S(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 S(o)}}}function $e(e){let t=me(e);if(!t)return;let n=I(t._debugInfo);if(n)return n;let r=t._debugOwner!==void 0;if(r){let s=t._debugOwner;for(let a=0;s&&a<50;a+=1){let d=I(s._debugInfo);if(d)return d;let g=S(s.type)??S(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 a=0;s&&a<50;a+=1){let d=I(s._debugInfo);if(d)return d;let g=S(s.type)??S(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 a=I(i._debugInfo);if(a)return a;let d=S(i.type)??S(i.elementType);if(d&&!T(d))return d;i=i.return;}let l=e.parentElement;for(let s=0;l&&s<15;s+=1){let a=me(l);if(a){let d=I(a._debugInfo);if(d)return d;let g=S(a.type)??S(a.elementType);if(g&&!T(g))return g;if(a._debugOwner){let h=S(a._debugOwner.type)??S(a._debugOwner.elementType);if(h&&!T(h))return h}if(a._owner&&a._owner!==a._debugOwner){let h=S(a._owner.type)??S(a._owner.elementType);if(h&&!T(h))return h}}l=l.parentElement;}}function je(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("id");if(n)return `#${de(n)}`;for(let r of ge){let o=e.getAttribute(r);if(o)return `${t}[${r}="${de(o)}"]`}return `${t}:nth-of-type(${He(e)})`}function Xe(e,t=10){let n=[],r=e;for(;r&&n.length<t;){let o=je(r);if(n.unshift(o),o.startsWith("#"))break;r=r.parentElement;}return n.join(" > ")}function pe(e,t){if(!t||t.length===0)return false;for(let n of t)if(e.closest(n))return true;return false}function J(e,t){if(!e||pe(e,t.ignoreSelectors))return null;let n=e;for(;n;){if(pe(n,t.ignoreSelectors))return null;if(t.isSelectable?.(n)??Ze(n))return n;n=n.parentElement;}return null}function Ze(e){let t=e.tagName;return !(t==="HTML"||t==="BODY")}function he(e){let t=e.getBoundingClientRect(),n={selector:Xe(e),tagName:e.tagName.toLowerCase(),rect:G(t),pageRect:De(t)},r=e.getAttribute("id");r&&(n.id=r);let o=e.className;typeof o=="string"&&o.trim()&&(n.className=o);let i=Ue(e);i&&(n.textSnippet=i);let c=qe(e)??$e(e);c&&(n.componentName=c);let l=ze(e);return l&&(n.testId=l),n}var V=null;async function we(){return V||(V=import('html-to-image')),V}async function We(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 ye(e,t){let{width:n,height:r}=await We(e);return {dataUrl:e,mime:t,width:n,height:r}}function L(e){if(e?.aborted)throw new Error("Aborted")}function be(){return {async captureElement(e,t){if(!w())throw new Error("captureElement can only run in the browser");L(t.signal);let n=await we();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 ye(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)),c=Math.max(1,Math.round(r*o)),l=await we();L(e.signal);let s=e.mime==="image/jpeg"?await l.toJpeg(t,{width:i,height:c,quality:e.quality??.92,pixelRatio:e.pixelRatio}):await l.toPng(t,{width:i,height:c,pixelRatio:e.pixelRatio});return L(e.signal),await ye(s,e.mime)}}}function Ke(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:Ke(t)};return n&&(r.detail=n),r}var Qe=12e3,Ye=2048,Ge=.92;function Ee(){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 ke(e,t,n){let r=new Promise((i,c)=>{let l=setTimeout(()=>c(new Error("Timeout")),t);typeof l.unref=="function"&&l.unref();}),o=[e,r];return n&&o.push(Je(n)),await Promise.race(o)}function Ve(e){if(!w())return 1;let t=window.devicePixelRatio||1,n=e?.pixelRatio??Math.min(t,2);return Math.max(.1,n)}function et(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()||!et(n))return;let o=Ee(),i=[],c=n?.timeoutMs??Qe,l=n?.maxDimension??Ye,s=n?.mime??"image/png",a=n?.quality??Ge,d=n?.adapter??be(),g={},h=Ve(n);if(n?.element&&t)try{let f=t.getBoundingClientRect(),m=Math.min(1,l/Math.max(f.width,f.height)),v=Math.min(h,h*m),A=await ke(Promise.resolve(d.captureElement(t,{..._e({mime:s,quality:a,pixelRatio:v,maxDimension:l,includeQuality:s==="image/jpeg",...r?{signal:r}:{}})})),c,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 ke(Promise.resolve(d.captureFullPage(_e({mime:s,quality:a,pixelRatio:h,maxDimension:l,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=Ee(),u={startedAt:o,finishedAt:b,durationMs:Math.max(0,b-o)};return i.length>0&&(u.errors=i),{...g,diagnostics:u}}function tt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function nt(){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:tt()}:{}}function rt(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 ve(e){let{config:t,context:n,user:r}=e;if(t?.enabled===false)return {};let o={...nt(),...rt(r)},i=t?.enrich;if(!i)return o;try{let c=await i(n);return {...o,...c}}catch(c){let l=y("unknown",c);return {...o,blocfeedMetadataError:l.message}}}var ee="blocfeed-queue",ot=50;function te(){if(!w())return [];try{let e=localStorage.getItem(ee);if(!e)return [];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return []}}function ne(e){if(w())try{e.length===0?localStorage.removeItem(ee):localStorage.setItem(ee,JSON.stringify(e));}catch{}}function it(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 re(e){let t=te(),n=it(e);for(n.metadata={...n.metadata,_queued:true},t.push({payload:n,timestamp:Date.now()});t.length>ot;)t.shift();ne(t);}function Pe(){let e=te();return e.length===0?[]:(ne([]),e.map(t=>t.payload))}function Ht(){ne([]);}function qt(){return te().length}function oe(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 j(e){return e instanceof Element?!!e.closest("[data-blocfeed-ui]"):false}function X(e){e.stopPropagation(),e.stopImmediatePropagation?.();}function Ae(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,l=(u,f=false)=>{if(!u){i=null,c=null,t.onHover(null);return}let m=G(u.getBoundingClientRect()),v=`${Math.round(m.x)}:${Math.round(m.y)}:${Math.round(m.width)}:${Math.round(m.height)}`;!f&&u===i&&v===c||(i=u,c=v,t.onHover({element:u,rect:m}));},s=oe(u=>{if(j(u.target))return;let f=document.elementFromPoint(u.clientX,u.clientY),m=J(f,o);l(m);}),a=oe(()=>{i&&l(i,true);}),d=u=>{j(u.target)||(X(u),u.pointerType==="mouse"&&u.preventDefault());},g=u=>{j(u.target)||(X(u),u.pointerType==="mouse"&&u.preventDefault());},h=u=>{if(j(u.target))return;X(u),u.preventDefault();let f=document.elementFromPoint(u.clientX,u.clientY),m=J(f,o);m&&t.onSelect({element:m,descriptor:he(m)});},b=u=>{u.key==="Escape"&&(X(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",a,{capture:true,passive:true}),window.addEventListener("resize",a,{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",a,{capture:true}),window.removeEventListener("resize",a),s.cancel(),a.cancel(),t.onHover(null);}}}var at=12e3,st=2,ct=500,lt=2e3,Fe="https://blocfeed.com/api/feedback",xe=0;function Te(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 ut(e){return e>=500&&e<=599}function dt(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 l=0;l<i.length;l+=1)c[l]=i.charCodeAt(l);return new Blob([c],{type:o})}function ft(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 Re(e,t,n){let r=dt(t);await fetch(e,{method:"PUT",body:r,headers:{"content-type":r.type},...n?{signal:n}:{}});}async function mt(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(`${Fe}/${t}/screenshots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),...o?{signal:o}:{}});}async function Ce(e){let{signal:t,transport:n}=e;if(Date.now()-xe<lt)return {ok:false,error:y("configuration",new Error("Please wait before submitting again"))};let o=n?.timeoutMs??at,i=n?.maxAttempts??st,c=n?.backoffMs??ct,l=!!(e.payload.screenshots?.element?.dataUrl||e.payload.screenshots?.fullPage?.dataUrl),{lean:s,extracted:a}=l?ft(e.payload):{lean:e.payload,extracted:{}},d={...a,...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(Fe,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s),signal:h.signal});if(f.ok){xe=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(Re(p.element,d.element,t)),d.fullPage&&p.fullPage&&k.push(Re(p.fullPage,d.fullPage,t));try{await Promise.all(k);}catch{}}else if(m.feedback_id)try{await mt({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&&ut(f.status)){let m=.85+Math.random()*.3,v=Math.round(c*2**(g-1)*m);await Te(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(c*2**(g-1)*m);await Te(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 ie(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 Ce(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 pt=["[data-blocfeed-ui]","[data-blocfeed-ignore]"];function gt(e){let t=[...pt,...e?.ignoreSelectors??[]],n=Array.from(new Set(t));return {...e,ignoreSelectors:n}}function Me(){return {phase:"idle"}}function ht(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 an(e){let t=e,n=Me(),r=new Set,o=new Set,i=null,c=null,l=null,s=null,a=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=()=>{a+=1,s?.abort(),s=null;},f=()=>{i?.stop(),i=null,h(null),l!==null&&w()&&(document.documentElement.style.cursor=l,l=null);},m=()=>{u(),f(),c=null,b(Me());},v=()=>{if(!w())return;f(),c=null;let p=gt(t.picker);l=document.documentElement.style.cursor,document.documentElement.style.cursor="crosshair",b({phase:"picking"}),i=Ae(p,{onHover:h,onSelect:({element:k,descriptor:$})=>{c=k,f(),b({phase:"review",selection:$});},onCancel:()=>{m();}});},A=()=>{let p=Pe();if(p.length!==0)for(let k of p)ie({payload:k,...t.transport?{transport:t.transport}:{}}).catch(()=>{re(k);});};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,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 $=t.blocfeed_id?.trim?.()??"";if(!$){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=a+1;a=N,s?.abort(),s=new AbortController;let F=s.signal,_=n.selection,K=k?.capture?{...t.capture,...k.capture}:t.capture,le=!!(K?.element||K?.fullPage),ue={phase:le?"capturing":"submitting"};_&&(ue.selection=_),b(ue);try{let E=le?await Se({selectionElement:c,capture:K,signal:F}):void 0;if(F.aborted||a!==N)return {ok:!1};let x={phase:"submitting"};_&&(x.selection=_),E&&(x.capture=E),b(x);let C={};_&&(C.selection=_),E&&(C.capture=E);let Ie=await ve({config:t.metadata,context:C,...t.user?{user:t.user}:{}}),M={version:1,createdAt:new Date().toISOString(),blocfeed_id:$,message:p,metadata:Ie};k?.category&&(M.category=k.category),t.user&&(M.user=t.user),_&&(M.selection=_),E&&(M.screenshots=E);let{result:P}=await ie({payload:M,signal:F,...t.transport?{transport:t.transport}:{}});if(F.aborted||a!==N)return P;if(P.ok){let Y={phase:"success",lastSubmit:P};return _&&(Y.selection=_),E&&(Y.capture=E),b(Y),P}ht(P)&&re(M);let Be=P.api?.error??y("unknown",new Error("Submission failed")),Q={phase:"error",lastSubmit:P,lastError:Be};return _&&(Q.selection=_),E&&(Q.capture=E),b(Q),P}catch(E){if(F.aborted||a!==N)return {ok:false};let C={phase:"error",lastError:F.aborted?y("aborted",E):y("unknown",E)};return _&&(C.selection=_),b(C),{ok:false}}finally{a===N&&(s=null);}},__unsafeGetSelectedElement(){return c},destroy(){m(),r.clear(),o.clear(),d?.(),d=null;}}}var B=[],D=[],Le=20,Ne=15,Z=[],O={},U=null,H=null,q=null,W=false,wt=["blocfeed.com","google-analytics.com","googletagmanager.com","analytics.google.com","googleads.g.doubleclick.net","googlesyndication.com","googleadservices.com","google.com/pagead","google.com/ads","facebook.net","facebook.com/tr","connect.facebook.net","graph.facebook.com","api.mixpanel.com","api-js.mixpanel.com","api.amplitude.com","api2.amplitude.com","api.segment.io","cdn.segment.com","vars.hotjar.com","in.hotjar.com","script.hotjar.com","heapanalytics.com","fullstory.com/s/fs.js","rs.fullstory.com","app.posthog.com","us.posthog.com","eu.posthog.com","api-iam.intercom.io","widget.intercom.io","sentry.io/api","browser.sentry-cdn.com","browser-intake-datadoghq.com","clarity.ms","js.hs-analytics.net","api.hubapi.com","forms.hubspot.com","plausible.io/api","client.crisp.chat","js.driftt.com","r.logrocket.com","app.pendo.io","events.launchdarkly.com","app.launchdarkly.com","grammarly.com","gnar.grammarly.com","capi.grammarly.com","api.languagetool.org","api.languagetoolplus.com","fonts.googleapis.com","fonts.gstatic.com","cdn.cookielaw.org","consent.cookiebot.com","js.stripe.com","api.stripe.com/v1/tokens","google.com/recaptcha","hcaptcha.com","bam.nr-data.net","rec.smartlook.com","o2.mouseflow.com","api.luckyorange.com","static.zdassets.com","ekr.zdassets.com"];function yt(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function bt(e,t){let n=t.map(yt).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>Le;)B.shift();}function ae(e){let t=e.url.toLowerCase();for(let n of Z)if(t.includes(n))return;for(D.push(e);D.length>Ne;)D.shift();}function ln(e={}){if(W||!w())return;W=true,Le=e.consoleLimit??20,Ne=e.networkLimit??15;let t=e.ignoreUrls;if(t!==void 0?Z=t.map(n=>n.toLowerCase()):Z=[...wt],e.console!==false){let n=e.consoleLevels??["error","warn"];for(let r of n)O[r]=console[r],console[r]=(...o)=>{bt(r,o),O[r]?.apply(console,o);};}if(e.network!==false&&typeof window.fetch=="function"){U=window.fetch;let n=U;window.fetch=async function(o,i){let c=typeof o=="string"?o:o instanceof URL?o.toString():o.url,l=(i?.method??"GET").toUpperCase(),s=Date.now();try{let a=await n.call(window,o,i);return a.ok||ae({url:c.slice(0,500),method:l,status:a.status,statusText:a.statusText,timestamp:s,durationMs:Date.now()-s}),a}catch(a){throw ae({url:c.slice(0,500),method:l,status:0,statusText:a instanceof Error?a.message:"Network error",timestamp:s,durationMs:Date.now()-s}),a}};}if(e.network!==false&&typeof XMLHttpRequest<"u"){H=XMLHttpRequest.prototype.open,q=XMLHttpRequest.prototype.send;let n=H,r=q;XMLHttpRequest.prototype.open=function(o,i,...c){return this.__bf_method=o.toUpperCase(),this.__bf_url=String(i),n.apply(this,[o,i,...c])},XMLHttpRequest.prototype.send=function(...o){let i=this.__bf_method||"GET",c=this.__bf_url||"",l=Date.now();return this.addEventListener("loadend",function(){if(this.status>=400||this.status===0){let s={url:c.slice(0,500),method:i,status:this.status,timestamp:l,durationMs:Date.now()-l};this.statusText&&(s.statusText=this.statusText),ae(s);}}),r.apply(this,o)};}}function un(){if(W){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),Z=[],W=false;}}function dn(){return {consoleLogs:[...B],networkErrors:[...D]}}function fn(){B=[],D=[];}var Et=[{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=[],ce=0,se=false;function kt(e){let t=e.slice(0,80);return t.length<=6?"***":t.slice(0,6)+"***"}function _t(e,t,n,r){if(R.some(c=>c.rule===e&&c.source===t))return;let i={rule:e,source:t,hint:kt(n),timestamp:Date.now()};r&&(i.location=r),R.push(i);}function z(e,t,n,r){for(let{name:o,pattern:i}of n){let c=i.exec(e);c&&_t(o,t,c[0],r);}}function St(e){try{let t=window;if(t.__NEXT_DATA__){let n=JSON.stringify(t.__NEXT_DATA__);z(n,"hydration",e,"__NEXT_DATA__");}if(t.__NUXT__){let n=JSON.stringify(t.__NUXT__);z(n,"hydration",e,"__NUXT__");}}catch{}}function vt(e){try{document.querySelectorAll("script:not([src])").forEach((n,r)=>{let o=n.textContent;o&&o.length>0&&z(o,"scripts",e,`inline-script[${r}]`);});}catch{}}function Pt(e){try{document.querySelectorAll("meta[content]").forEach(n=>{let r=n.getAttribute("content"),o=n.getAttribute("name")||n.getAttribute("property")||"";r&&r.length>10&&z(r,"meta",e,o?`meta[${o}]`:void 0);});}catch{}}function At(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&&z(i.value,"dom",e,`${n.tagName.toLowerCase()}[${i.name}]`);}});}catch{}}function gn(e={}){if(se||!w()||(se=true,e.secretScan===false))return;let t=[...Et,...e.customPatterns??[]],n=e.scanTargets??["hydration","scripts","meta","dom"];setTimeout(()=>{ce=Date.now(),n.includes("hydration")&&St(t),n.includes("scripts")&&vt(t),n.includes("meta")&&Pt(t),n.includes("dom")&&At(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 hn(){return {findings:[...R],scannedAt:ce}}function wn(){R=[],ce=0,se=false;}
|
|
2
|
-
exports.a=w;exports.b=G;exports.c=be;exports.d=Se;exports.e=ve;exports.f=re;exports.g=Pe;exports.h=Ht;exports.i=qt;exports.j=an;exports.k=ln;exports.l=un;exports.m=dn;exports.n=fn;exports.o=gn;exports.p=hn;exports.q=wn;
|