@better-webhook/cli 3.4.1 → 3.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,7 +20,9 @@ export const dashboard = new Command()
20
20
  }
21
21
  try {
22
22
  const capturePort = Number.parseInt(String(options.capturePort), 10);
23
- if (!Number.isFinite(capturePort) || capturePort < 0 || capturePort > 65535) {
23
+ if (!Number.isFinite(capturePort) ||
24
+ capturePort < 0 ||
25
+ capturePort > 65535) {
24
26
  console.error(chalk.red("Invalid capture port number"));
25
27
  process.exitCode = 1;
26
28
  return;
@@ -141,7 +141,7 @@ export class CaptureServer {
141
141
  body = rawBody;
142
142
  }
143
143
  }
144
- const provider = this.detectProvider(req.headers);
144
+ const provider = this.detectProvider(req.headers, body);
145
145
  const captured = {
146
146
  id,
147
147
  timestamp,
@@ -195,15 +195,21 @@ export class CaptureServer {
195
195
  file: filename,
196
196
  }));
197
197
  }
198
- detectProvider(headers) {
198
+ detectProvider(headers, body) {
199
199
  if (headers["stripe-signature"]) {
200
200
  return "stripe";
201
201
  }
202
202
  if (headers["x-github-event"] || headers["x-hub-signature-256"]) {
203
203
  return "github";
204
204
  }
205
- if (headers["x-ragie-delivery"]) {
206
- return "ragie";
205
+ if (headers["x-signature"]) {
206
+ if (body &&
207
+ typeof body === "object" &&
208
+ "type" in body &&
209
+ "payload" in body &&
210
+ "nonce" in body) {
211
+ return "ragie";
212
+ }
207
213
  }
208
214
  if (headers["x-shopify-hmac-sha256"] || headers["x-shopify-topic"]) {
209
215
  return "shopify";
@@ -161,13 +161,7 @@ export function getProviderHeaders(provider, options) {
161
161
  headers.push({ key: "Content-Type", value: "application/json" }, { key: "User-Agent", value: "Discord-Webhook/1.0" });
162
162
  break;
163
163
  case "ragie":
164
- headers.push({ key: "Content-Type", value: "application/json" }, {
165
- key: "X-Ragie-Event",
166
- value: options?.event || "document_status_updated",
167
- }, {
168
- key: "X-Ragie-Delivery",
169
- value: options?.webhookId || generateDeliveryId(),
170
- });
164
+ headers.push({ key: "Content-Type", value: "application/json" });
171
165
  break;
172
166
  default:
173
167
  headers.push({ key: "Content-Type", value: "application/json" });
@@ -20,4 +20,4 @@ Error generating stack: `+a.message+`
20
20
  )`}return x.jsx("div",{ref:o,role:"presentation","data-base-ui-inert":"",...c,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:d}})}),k3=f.forwardRef(function(r,o){const{anchor:i,positionMethod:c="absolute",className:d,render:m,side:g,align:v,sideOffset:h=0,alignOffset:b=0,collisionBoundary:y="clipping-ancestors",collisionPadding:E=5,arrowPadding:R=5,sticky:C=!1,disableAnchorTracking:M=!1,collisionAvoidance:O=ig,...z}=r,{store:N}=Qa(),H=O3(),L=fu(!0),A=N.useState("parent"),B=N.useState("floatingRootContext"),U=N.useState("floatingTreeRoot"),k=N.useState("mounted"),re=N.useState("open"),ce=N.useState("modal"),oe=N.useState("activeTriggerElement"),ae=N.useState("lastOpenChangeReason"),G=N.useState("floatingNodeId"),$=N.useState("floatingParentNodeId");let Q=i,T=h,_=b,j=v,F=O;A.type==="context-menu"&&(Q=i??A.context?.anchor,j=j??"start",!g&&j!=="center"&&(_=r.alignOffset??2,T=r.sideOffset??-5));let ne=g,w=j;A.type==="menu"?(ne=ne??"inline-end",w=w??"start",F=r.collisionAvoidance??w6):A.type==="menubar"&&(ne=ne??"bottom",w=w??"start");const Y=A.type==="context-menu",Z=U2({anchor:Q,floatingRootContext:B,positionMethod:L?"fixed":c,mounted:k,side:ne,sideOffset:T,align:w,alignOffset:_,arrowPadding:Y?0:R,collisionBoundary:y,collisionPadding:E,sticky:C,nodeId:G,keepMounted:H,disableAnchorTracking:M,collisionAvoidance:F,shiftCrossAxis:Y,externalTree:U}),W=f.useMemo(()=>{const Ee={};return re||(Ee.pointerEvents="none"),{role:"presentation",hidden:!k,style:{...Z.positionerStyles,...Ee}}},[re,k,Z.positionerStyles]);f.useEffect(()=>{function Ee(te){te.open?(te.parentNodeId===G&&N.set("hoverEnabled",!1),te.nodeId!==G&&te.parentNodeId===N.select("floatingParentNodeId")&&N.setOpen(!1,Ie(Po))):te.parentNodeId===G&&te.reason!==Po&&N.set("hoverEnabled",!0)}return U.events.on("menuopenchange",Ee),()=>{U.events.off("menuopenchange",Ee)}},[N,U.events,G]),f.useEffect(()=>{if(N.select("floatingParentNodeId")==null)return;function Ee(te){if(te.open||te.nodeId!==N.select("floatingParentNodeId"))return;const be=te.reason??Po;N.setOpen(!1,Ie(be))}return U.events.on("menuopenchange",Ee),()=>{U.events.off("menuopenchange",Ee)}},[U.events,N]),f.useEffect(()=>{function Ee(te){!re||te.nodeId!==N.select("floatingParentNodeId")||te.target&&oe&&oe!==te.target&&N.setOpen(!1,Ie(Po))}return U.events.on("itemhover",Ee),()=>{U.events.off("itemhover",Ee)}},[U.events,re,oe,N]),f.useEffect(()=>{const Ee={open:re,nodeId:G,parentNodeId:$,reason:N.select("lastOpenChangeReason")};U.events.emit("menuopenchange",Ee)},[U.events,re,N,G,$]);const de=f.useMemo(()=>({open:re,side:Z.side,align:Z.align,anchorHidden:Z.anchorHidden,nested:A.type==="menu"}),[re,Z.side,Z.align,Z.anchorHidden,A.type]),ee=f.useMemo(()=>({side:Z.side,align:Z.align,arrowRef:Z.arrowRef,arrowUncentered:Z.arrowUncentered,arrowStyles:Z.arrowStyles,nodeId:Z.context.nodeId}),[Z.side,Z.align,Z.arrowRef,Z.arrowUncentered,Z.arrowStyles,Z.context.nodeId]),J=At("div",r,{state:de,stateAttributesMapping:cu,ref:[o,N.useStateSetter("positionerElement")],props:[W,z]}),fe=k&&A.type!=="menu"&&(A.type!=="menubar"&&ce&&ae!==jn||A.type==="menubar"&&A.context.modal);let pe=null;return A.type==="menubar"?pe=A.context.contentElement:A.type===void 0&&(pe=oe),x.jsxs(Eg.Provider,{value:ee,children:[fe&&x.jsx(Z2,{ref:A.type==="context-menu"||A.type==="nested-context-menu"?A.context.internalBackdropRef:null,inert:L2(!re),cutout:pe}),x.jsx(Ob,{id:G,children:x.jsx(k2,{elementsRef:N.context.itemDomElements,labelsRef:N.context.itemLabels,children:J})})]})}),B2=f.createContext(void 0);function Z3(){const l=f.useContext(B2);if(l===void 0)throw new Error(an(34));return l}const B3=f.memo(f.forwardRef(function(r,o){const{render:i,className:c,value:d,defaultValue:m,onValueChange:g,disabled:v=!1,...h}=r,[b,y]=Fs({controlled:d,default:m,name:"MenuRadioGroup"}),E=Ae(g),R=Ae((z,N)=>{E?.(z,N),!N.isCanceled&&y(z)}),C=f.useMemo(()=>({disabled:v}),[v]),M=At("div",r,{state:C,ref:o,props:{role:"group","aria-disabled":v||void 0,...h}}),O=f.useMemo(()=>({value:b,setValue:R,disabled:v}),[b,R,v]);return x.jsx(B2.Provider,{value:O,children:M})})),q2=f.createContext(void 0);function q3(){const l=f.useContext(q2);if(l===void 0)throw new Error(an(35));return l}const Y3=f.forwardRef(function(r,o){const{render:i,className:c,id:d,label:m,nativeButton:g=!1,disabled:v=!1,closeOnClick:h=!1,value:b,...y}=r,E=Bd({label:m}),R=Rg(!0),C=mu(d),{store:M}=Qa(),O=M.useState("isActive",E.index),z=M.useState("itemProps"),{value:N,setValue:H,disabled:L}=Z3(),A=L||v,B=N===b,{getItemProps:U,itemRef:k}=Dy({closeOnClick:h,disabled:A,highlighted:O,id:C,store:M,nativeButton:g,nodeId:R?.nodeId,itemMetadata:Hy}),re=f.useMemo(()=>({disabled:A,highlighted:O,checked:B}),[A,O,B]),ce=Ae(ae=>{const G={...Ie(Vr,ae.nativeEvent),preventUnmountOnClose:()=>{}};H(b,G)}),oe=At("div",r,{state:re,stateAttributesMapping:Cg,props:[z,{role:"menuitemradio","aria-checked":B,onClick:ce},y,U],ref:[k,o,E.ref]});return x.jsx(q2.Provider,{value:re,children:oe})}),G3=f.forwardRef(function(r,o){const{render:i,className:c,keepMounted:d=!1,...m}=r,g=q3(),v=f.useRef(null),{transitionStatus:h,setMounted:b}=fi(g.checked);Ka({open:g.checked,ref:v,onComplete(){g.checked||b(!1)}});const y=f.useMemo(()=>({checked:g.checked,disabled:g.disabled,highlighted:g.highlighted,transitionStatus:h}),[g.checked,g.disabled,g.highlighted,h]);return At("span",r,{state:y,stateAttributesMapping:Cg,ref:[o,v],props:{"aria-hidden":!0,...m},enabled:d||g.checked})});let Xp={},Ip={},Qp="";function X3(l){if(typeof document>"u")return!1;const r=al(l);return Yt(r).innerWidth-r.documentElement.clientWidth>0}function I3(l){const r=al(l),o=r.documentElement,i=r.body,c=Ia(o)?o:i,d=c.style.overflow;return c.style.overflow="hidden",()=>{c.style.overflow=d}}function Q3(l){const r=al(l),o=r.documentElement,i=r.body,c=Yt(o);let d=0,m=0;const g=cl.create(),v=typeof CSS<"u"&&CSS.supports?.("scrollbar-gutter","stable");if(jg&&(c.visualViewport?.scale??1)!==1)return()=>{};function h(){const E=c.getComputedStyle(o),R=c.getComputedStyle(i),O=(E.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";d=o.scrollTop,m=o.scrollLeft,Xp={scrollbarGutter:o.style.scrollbarGutter,overflowY:o.style.overflowY,overflowX:o.style.overflowX},Qp=o.style.scrollBehavior,Ip={position:i.style.position,height:i.style.height,width:i.style.width,boxSizing:i.style.boxSizing,overflowY:i.style.overflowY,overflowX:i.style.overflowX,scrollBehavior:i.style.scrollBehavior};const z=o.scrollHeight>o.clientHeight,N=o.scrollWidth>o.clientWidth,H=E.overflowY==="scroll"||R.overflowY==="scroll",L=E.overflowX==="scroll"||R.overflowX==="scroll",A=Math.max(0,c.innerWidth-o.clientWidth),B=Math.max(0,c.innerHeight-o.clientHeight),U=parseFloat(R.marginTop)+parseFloat(R.marginBottom),k=parseFloat(R.marginLeft)+parseFloat(R.marginRight),re=Ia(o)?o:i;if(v){o.style.scrollbarGutter=O,re.style.overflowY="hidden",re.style.overflowX="hidden";return}Object.assign(o.style,{scrollbarGutter:O,overflowY:"hidden",overflowX:"hidden"}),(z||H)&&(o.style.overflowY="scroll"),(N||L)&&(o.style.overflowX="scroll"),Object.assign(i.style,{position:"relative",height:U||B?`calc(100dvh - ${U+B}px)`:"100dvh",width:k||A?`calc(100vw - ${k+A}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),i.scrollTop=d,i.scrollLeft=m,o.setAttribute("data-base-ui-scroll-locked",""),o.style.scrollBehavior="unset"}function b(){Object.assign(o.style,Xp),Object.assign(i.style,Ip),v||(o.scrollTop=d,o.scrollLeft=m,o.removeAttribute("data-base-ui-scroll-locked"),o.style.scrollBehavior=Qp)}function y(){b(),g.request(h)}return h(),c.addEventListener("resize",y),()=>{g.cancel(),b(),typeof c.removeEventListener=="function"&&c.removeEventListener("resize",y)}}class F3{lockCount=0;restore=null;timeoutLock=Ga.create();timeoutUnlock=Ga.create();acquire(r){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(r)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(r){if(this.lockCount===0||this.restore!==null)return;const i=al(r).documentElement,c=Yt(i).getComputedStyle(i).overflowY;if(c==="hidden"||c==="clip"){this.restore=Nn;return}const d=qy||!X3(r);this.restore=d?I3(r):Q3(r)}}const K3=new F3;function Y2(l=!0,r=null){we(()=>{if(l)return K3.acquire(r)},[l,r])}const J3=f.createContext(null);function G2(l){return f.useContext(J3)}function P3(l){const r=f.useRef(""),o=f.useCallback(c=>{c.defaultPrevented||(r.current=c.pointerType,l(c,c.pointerType))},[l]);return{onClick:f.useCallback(c=>{if(c.detail===0){l(c,"keyboard");return}"pointerType"in c&&l(c,c.pointerType),l(c,r.current),r.current=""},[l]),onPointerDown:o}}function X2(l){const[r,o]=f.useState(null),i=Ae((g,v)=>{l||o(v)}),c=f.useCallback(()=>{o(null)},[]),{onClick:d,onPointerDown:m}=P3(i);return f.useMemo(()=>({openMethod:r,reset:c,triggerProps:{onClick:d,onPointerDown:m}}),[r,c,d,m])}const $3={...r3,disabled:Me(l=>l.parent.type==="menubar"&&l.parent.context.disabled||l.disabled),modal:Me(l=>(l.parent.type===void 0||l.parent.type==="context-menu")&&(l.modal??!0)),allowMouseEnter:Me(l=>l.parent.type==="menu"?l.parent.store.select("allowMouseEnter"):l.allowMouseEnter),stickIfOpen:Me(l=>l.stickIfOpen),parent:Me(l=>l.parent),rootId:Me(l=>l.parent.type==="menu"?l.parent.store.select("rootId"):l.parent.type!==void 0?l.parent.context.rootId:l.rootId),activeIndex:Me(l=>l.activeIndex),isActive:Me((l,r)=>l.activeIndex===r),hoverEnabled:Me(l=>l.hoverEnabled),instantType:Me(l=>l.instantType),lastOpenChangeReason:Me(l=>l.openChangeReason),floatingTreeRoot:Me(l=>l.parent.type==="menu"?l.parent.store.select("floatingTreeRoot"):l.floatingTreeRoot),floatingNodeId:Me(l=>l.floatingNodeId),floatingParentNodeId:Me(l=>l.floatingParentNodeId),itemProps:Me(l=>l.itemProps),closeDelay:Me(l=>l.closeDelay),keyboardEventRelay:Me(l=>{if(l.keyboardEventRelay)return l.keyboardEventRelay;if(l.parent.type==="menu")return l.parent.store.select("keyboardEventRelay")})};class t0 extends x2{constructor(r){super({...W3(),...r},{positionerRef:f.createRef(),popupRef:f.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:f.createRef(),beforeContentFocusGuardRef:f.createRef(),onOpenChangeComplete:void 0,triggerElements:new Wd},$3),this.observe(Me(o=>o.allowMouseEnter),(o,i)=>{this.state.parent.type==="menu"&&o!==i&&this.state.parent.store.set("allowMouseEnter",o)}),this.unsubscribeParentListener=this.observe("parent",o=>{if(this.unsubscribeParentListener?.(),o.type==="menu"){this.unsubscribeParentListener=o.store.subscribe(()=>{this.notifyAll()}),this.context.allowMouseUpTriggerRef=o.store.context.allowMouseUpTriggerRef;return}o.type!==void 0&&(this.context.allowMouseUpTriggerRef=o.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(r,o){this.state.floatingRootContext.context.events.emit("setOpen",{open:r,eventDetails:o})}static useStore(r,o){return Ln(()=>r??new t0(o)).current}unsubscribeParentListener=null}function W3(){return{...a3(),disabled:!1,modal:!0,allowMouseEnter:!0,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new Fd,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Bt,keyboardEventRelay:void 0,closeDelay:0}}const eS=f.createContext(void 0);function tS(){return f.useContext(eS)}function nS(l){const{children:r,open:o,onOpenChange:i,onOpenChangeComplete:c,defaultOpen:d=!1,disabled:m=!1,modal:g,loopFocus:v=!0,orientation:h="vertical",actionsRef:b,closeParentOnEsc:y=!1,handle:E,triggerId:R,defaultTriggerId:C=null,highlightItemOnHover:M=!0}=l,O=fu(!0),z=Qa(!0),N=G2(),H=tS(),L=f.useMemo(()=>H&&z?{type:"menu",store:z.store}:N?{type:"menubar",context:N}:O&&!z?{type:"context-menu",context:O}:{type:void 0},[O,z,N,H]),A=t0.useStore(E?.store,{parent:L}),B=A.useState("floatingTreeRoot"),U=t2(B),k=kl();we(()=>{O&&!z?A.update({parent:{type:"context-menu",context:O},floatingNodeId:U,floatingParentNodeId:k}):z&&A.update({floatingNodeId:U,floatingParentNodeId:k})},[O,z,U,k,A]),A.useControlledProp("open",o,d),A.useControlledProp("activeTriggerId",R,C),A.useContextCallback("onOpenChangeComplete",c);const re=A.useState("open"),ce=A.useState("activeTriggerElement"),oe=A.useState("positionerElement"),ae=A.useState("hoverEnabled"),G=A.useState("modal"),$=A.useState("disabled"),Q=A.useState("lastOpenChangeReason"),T=A.useState("parent"),_=A.useState("activeIndex"),j=A.useState("payload"),F=A.useState("floatingParentNodeId"),ne=f.useRef(null),w=F!=null;let Y;A.useSyncedValues({disabled:m,modal:T.type===void 0?g:void 0,rootId:Fa()});const{openMethod:Z,triggerProps:W,reset:de}=X2(re);t3(A);const{forceUnmount:ee}=n3(re,A,()=>{A.update({allowMouseEnter:!1,stickIfOpen:!0}),de()}),J=f.useRef(T.type!=="context-menu"),fe=qt();f.useEffect(()=>{if(re||(ne.current=null),T.type==="context-menu"){if(!re){fe.clear(),J.current=!1;return}fe.start(500,()=>{J.current=!0})}},[fe,re,T.type]),Y2(re&&G&&Q!==jn&&Z!=="touch",oe),we(()=>{!re&&!ae&&A.set("hoverEnabled",!0)},[re,ae,A]);const pe=f.useRef(!0),Ee=qt(),te=Ae((ze,Be)=>{const Je=Be.reason;if(re===ze&&Be.trigger===ce||(Be.preventUnmountOnClose=()=>{A.set("preventUnmountingOnClose",!0)},!ze&&Be.trigger==null&&(Be.trigger=ce??void 0),i?.(ze,Be),Be.isCanceled))return;const ct={open:ze,nativeEvent:Be.event,reason:Be.reason,nested:w};Y?.emit("openchange",ct);const bt=Be.event;if(ze===!1&&bt?.type==="click"&&bt.pointerType==="touch"&&!pe.current)return;if(!ze&&_!==null){const Tt=A.context.itemDomElements.current[_];queueMicrotask(()=>{Tt?.setAttribute("tabindex","-1")})}ze&&Je===Qs?(pe.current=!1,Ee.start(300,()=>{pe.current=!0})):(pe.current=!0,Ee.clear());const jt=(Je===Za||Je===Vr)&&bt.detail===0&&bt?.isTrusted,gt=!ze&&(Je===Zd||Je==null);function Gt(){const Tt={open:ze,openChangeReason:Je};ne.current=Be.event??null;const Mt=Be.trigger?.id??null;(Mt||ze)&&(Tt.activeTriggerId=Mt,Tt.activeTriggerElement=Be.trigger??null),A.update(Tt)}Je===jn?ll.flushSync(Gt):Gt(),T.type==="menubar"&&(Je===Qs||Je===Ya||Je===jn||Je===Bs||Je===Po)?A.set("instantType","group"):jt||gt?A.set("instantType",jt?"click":"dismiss"):A.set("instantType",void 0)}),be=f.useCallback(ze=>{const Be=Ie(ze);return Be.preventUnmountOnClose=()=>{A.set("preventUnmountingOnClose",!0)},Be},[A]),ye=f.useCallback(()=>{A.setOpen(!1,be(Ny))},[A,be]);f.useImperativeHandle(b,()=>({unmount:ee,close:ye}),[ee,ye]);let Ue;T.type==="context-menu"&&(Ue=T.context),f.useImperativeHandle(Ue?.positionerRef,()=>oe,[oe]),f.useImperativeHandle(Ue?.actionsRef,()=>({setOpen:te}),[te]);const Re=i3({popupStore:A,onOpenChange:te});Y=Re.context.events,f.useEffect(()=>{const ze=({open:Be,eventDetails:Je})=>te(Be,Je);return Y.on("setOpen",ze),()=>{Y?.off("setOpen",ze)}},[Y,te]);const me=g2(Re,{enabled:!$,bubbles:y&&T.type==="menu",outsidePress(){return T.type!=="context-menu"||ne.current?.type==="contextmenu"?!0:J.current},externalTree:w?B:void 0}),he=x3(Re,{role:"menu"}),He=_2(),xe=f.useCallback(ze=>{A.select("activeIndex")!==ze&&A.set("activeIndex",ze)},[A]),Ne=R2(Re,{enabled:!$,listRef:A.context.itemDomElements,activeIndex:_,nested:T.type!==void 0,loopFocus:v,orientation:h,parentOrientation:T.type==="menubar"?T.context.orientation:void 0,rtl:He==="rtl",disabledIndices:qr,onNavigate:xe,openOnArrowKeyDown:T.type!=="context-menu",externalTree:w?B:void 0,focusItemOnHover:M}),ue=f.useCallback(ze=>{A.context.typingRef.current=ze},[A]),De=A2(Re,{listRef:A.context.itemLabels,activeIndex:_,resetMs:R6,onMatch:ze=>{re&&ze!==_&&A.set("activeIndex",ze)},onTypingChange:ue}),{getReferenceProps:ge,getFloatingProps:Se,getItemProps:ve,getTriggerProps:Ge}=e0([me,he,Ne,De]),nt=f.useMemo(()=>{const ze=pa(ge(),{onMouseEnter(){A.set("hoverEnabled",!0)},onMouseMove(){A.set("allowMouseEnter",!0)}},W);return delete ze.role,ze},[ge,A,W]),qe=f.useMemo(()=>{const ze=Ge();if(!ze)return ze;const Be=pa(ze,W);return delete Be.role,delete Be["aria-controls"],Be},[Ge,W]),vt=ci(),yt=f.useMemo(()=>Se({onMouseEnter(){T.type==="menu"&&vt.request(()=>A.set("hoverEnabled",!1))},onMouseMove(){A.set("allowMouseEnter",!0)},onClick(){A.select("hoverEnabled")&&A.set("hoverEnabled",!1)},onKeyDown(ze){const Be=A.select("keyboardEventRelay");Be&&!ze.isPropagationStopped()&&Be(ze)}}),[Se,T.type,vt,A]),Nt=f.useMemo(()=>ve(),[ve]);A.useSyncedValues({floatingRootContext:Re,activeTriggerProps:nt,inactiveTriggerProps:qe,popupProps:yt,itemProps:Nt});const Et=f.useMemo(()=>({store:A,parent:L}),[A,L]),ut=x.jsx(Ag.Provider,{value:Et,children:typeof r=="function"?r({payload:j}):r});return T.type===void 0||T.type==="context-menu"?x.jsx(zb,{externalTree:B,children:ut}):ut}function I2(l){const r=l.getBoundingClientRect(),o=window.getComputedStyle(l,"::before"),i=window.getComputedStyle(l,"::after");if(!(o.content!=="none"||i.content!=="none"))return r;const d=parseFloat(o.width)||0,m=parseFloat(o.height)||0,g=parseFloat(i.width)||0,v=parseFloat(i.height)||0,h=Math.max(r.width,d,g),b=Math.max(r.height,m,v),y=h-r.width,E=b-r.height;return{left:r.left-y/2,right:r.right+y/2,top:r.top-E/2,bottom:r.bottom+E/2}}function lS(l={}){const{highlightItemOnHover:r,highlightedIndex:o,onHighlightedIndexChange:i}=Dd(),{ref:c,index:d}=Bd(l),m=o===d,g=f.useRef(null),v=ga(c,g);return{compositeProps:f.useMemo(()=>({tabIndex:m?0:-1,onFocus(){i(d)},onMouseMove(){const b=g.current;if(!r||!b)return;const y=b.hasAttribute("disabled")||b.ariaDisabled==="true";!m&&!y&&b.focus()}}),[m,i,d,r]),compositeRef:v,index:d}}function aS(l){const{render:r,className:o,state:i=Bt,props:c=qr,refs:d=qr,metadata:m,stateAttributesMapping:g,tag:v="div",...h}=l,{compositeProps:b,compositeRef:y}=lS({metadata:m});return At(v,l,{state:i,ref:[...d,y],props:[b,...c,h],stateAttributesMapping:g})}function Q2(l){if(zt(l)&&l.hasAttribute("data-rootownerid"))return l.getAttribute("data-rootownerid")??void 0;if(!dl(l))return Q2(hl(l))}function rS(l){const{enabled:r=!0,mouseDownAction:o,open:i}=l,c=f.useRef(!1);return f.useMemo(()=>r?{onMouseDown:d=>{(o==="open"&&!i||o==="close"&&i)&&(c.current=!0,al(d.currentTarget).addEventListener("click",()=>{c.current=!1},{once:!0}))},onClick:d=>{c.current&&(c.current=!1,d.preventBaseUIHandler())}}:Bt,[r,o,i])}const Us=2,oS=f.forwardRef(function(r,o){const{render:i,className:c,disabled:d=!1,nativeButton:m=!0,id:g,openOnHover:v,delay:h=100,closeDelay:b=0,handle:y,payload:E,...R}=r,C=Qa(!0),M=y?.store??C?.store;if(!M)throw new Error(an(85));const O=mu(g),z=M.useState("isTriggerActive",O),N=M.useState("floatingRootContext"),H=M.useState("isOpenedByTrigger",O),L=f.useRef(null),A=sS(),B=Dd(!0),U=ba(),k=f.useMemo(()=>U??new Fd,[U]),re=t2(k),ce=kl(),{registerTrigger:oe,isMountedByThisTrigger:ae}=e3(O,L,M,{payload:E,closeDelay:b,parent:A,floatingTreeRoot:k,floatingNodeId:re,floatingParentNodeId:ce,keyboardEventRelay:B?.relayKeyboardEvent}),G=M.useState("disabled"),$=d||G||A.type==="menubar"&&A.context.disabled,{getButtonProps:Q,buttonRef:T}=ui({disabled:$,native:m});f.useEffect(()=>{!H&&A.type===void 0&&(M.context.allowMouseUpTriggerRef.current=!1)},[M,H,A.type]);const _=f.useRef(null),j=qt(),F=Ae(he=>{if(!_.current)return;j.clear(),M.context.allowMouseUpTriggerRef.current=!1;const He=he.target;if(et(_.current,He)||et(M.select("positionerElement"),He)||He===_.current||He!=null&&Q2(He)===M.select("rootId"))return;const xe=I2(_.current);he.clientX>=xe.left-Us&&he.clientX<=xe.right+Us&&he.clientY>=xe.top-Us&&he.clientY<=xe.bottom+Us||k.events.emit("close",{domEvent:he,reason:Tg})});f.useEffect(()=>{H&&M.select("lastOpenChangeReason")===jn&&al(_.current).addEventListener("mouseup",F,{once:!0})},[H,F,M]);const ne=A.type==="menubar"&&A.context.hasSubmenuOpen,Y=p3(N,{enabled:(v??ne??!1)&&!$&&A.type!=="context-menu"&&(A.type!=="menubar"||ne&&!ae),handleClose:E3({blockPointerEvents:A.type!=="menubar"}),mouseOnly:!0,move:!1,restMs:A.type===void 0?h:void 0,delay:{close:b},triggerElementRef:L,externalTree:k,isActiveTrigger:z}),Z=iS(H,M.select("lastOpenChangeReason")),W=i2(N,{enabled:!$&&A.type!=="context-menu",event:H&&A.type==="menubar"?"click":"mousedown",toggle:!0,ignoreMouse:!1,stickIfOpen:A.type===void 0?Z:!1}),de=s3(N,{enabled:!$&&(A.type!=="menubar"&&H||ne)}),ee=rS({open:H,enabled:A.type==="menubar",mouseDownAction:"open"}),J=e0([W,de]),fe=A.type==="menubar",pe=f.useMemo(()=>({disabled:$,open:H}),[$,H]),Ee=M.useState("triggerProps",ae),te=[_,o,T,oe,L],be=[J.getReferenceProps(),Y??Bt,Ee,{"aria-haspopup":"menu",id:O,onMouseDown:he=>{if(M.select("open"))return;j.start(200,()=>{M.context.allowMouseUpTriggerRef.current=!0}),al(he.currentTarget).addEventListener("mouseup",F,{once:!0})}},fe?{role:"menuitem"}:{},ee,R,Q],ye=f.useRef(null),Ue=Ae(he=>{ll.flushSync(()=>{M.setOpen(!1,Ie(Ya,he.nativeEvent,he.currentTarget))}),wb(ye.current)?.focus()}),Re=Ae(he=>{const He=M.select("positionerElement");if(He&&Ur(he,He))M.context.beforeContentFocusGuardRef.current?.focus();else{ll.flushSync(()=>{M.setOpen(!1,Ie(Ya,he.nativeEvent,he.currentTarget))});let xe=Mb(L.current);for(;xe!==null&&et(He,xe)||xe?.hasAttribute("aria-hidden");){const Ne=xe;if(xe=Qd(xe),xe===Ne)break}xe?.focus()}}),me=At("button",r,{enabled:!fe,stateAttributesMapping:ud,state:pe,ref:te,props:be});return fe?x.jsx(aS,{tag:"button",render:i,className:c,state:pe,refs:te,props:be,stateAttributesMapping:ud}):H?x.jsxs(f.Fragment,{children:[x.jsx(Qr,{ref:ye,onFocus:Ue},`${O}-pre-focus-guard`),x.jsx(f.Fragment,{children:me},O),x.jsx(Qr,{ref:M.context.triggerFocusTargetRef,onFocus:Re},`${O}-post-focus-guard`)]}):x.jsx(f.Fragment,{children:me},O)});function iS(l,r){const o=qt(),[i,c]=f.useState(!1);return we(()=>{l&&r==="trigger-hover"?(c(!0),o.start(A6,()=>{c(!1)})):l||(o.clear(),c(!1))},[l,r,o]),i}function sS(){const l=fu(!0),r=Qa(!0),o=G2();return f.useMemo(()=>o?{type:"menubar",context:o}:l&&!r?{type:"context-menu",context:l}:{type:void 0},[l,r,o])}const uS=f.forwardRef(function(r,o){const{className:i,render:c,orientation:d="horizontal",...m}=r,g=f.useMemo(()=>({orientation:d}),[d]);return At("div",r,{state:g,ref:o,props:[{role:"separator","aria-orientation":d},m]})});function cS({...l}){return x.jsx(nS,{"data-slot":"dropdown-menu",...l})}function fS({...l}){return x.jsx(oS,{"data-slot":"dropdown-menu-trigger",...l})}function dS({align:l="start",alignOffset:r=0,side:o="bottom",sideOffset:i=4,className:c,...d}){return x.jsx(z3,{children:x.jsx(k3,{className:"isolate z-50 outline-none",align:l,alignOffset:r,side:o,sideOffset:i,children:x.jsx(C3,{"data-slot":"dropdown-menu-content",className:pt("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-none shadow-md ring-1 duration-100 z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden",c),...d})})})}function mS({...l}){return x.jsx(B3,{"data-slot":"dropdown-menu-radio-group",...l})}function Jf({className:l,children:r,...o}){return x.jsxs(Y3,{"data-slot":"dropdown-menu-radio-item",className:pt("focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground gap-2 rounded-none py-2 pr-8 pl-2 text-xs [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",l),...o,children:[x.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center pointer-events-none","data-slot":"dropdown-menu-radio-item-indicator",children:x.jsx(G3,{children:x.jsx(zd,{})})}),r]})}const F2=f.createContext(void 0);function hS({children:l,defaultTheme:r="system",storageKey:o="vite-ui-theme",...i}){const[c,d]=f.useState(()=>localStorage.getItem(o)||r);f.useEffect(()=>{const g=window.document.documentElement;if(g.classList.remove("light","dark"),c==="system"){const v=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";g.classList.add(v);return}g.classList.add(c)},[c]);const m=f.useMemo(()=>({theme:c,setTheme:g=>{localStorage.setItem(o,g),d(g)}}),[o,c]);return x.jsx(F2.Provider,{...i,value:m,children:l})}const pS=()=>{const l=f.useContext(F2);if(l===void 0)throw new Error("useTheme must be used within a ThemeProvider");return l};function gS(){const{theme:l,setTheme:r}=pS();return x.jsxs(cS,{children:[x.jsxs(fS,{render:x.jsx(xn,{variant:"outline",size:"icon"}),children:[x.jsx(ed,{className:"size-4 scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90"}),x.jsx(Wf,{className:"absolute size-4 scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0"}),x.jsx("span",{className:"sr-only",children:"Toggle theme"})]}),x.jsx(dS,{align:"end",className:"w-40",children:x.jsxs(mS,{value:l,onValueChange:o=>r(o),children:[x.jsxs(Jf,{value:"light",children:[x.jsx(ed,{}),"Light"]}),x.jsxs(Jf,{value:"dark",children:[x.jsx(Wf,{}),"Dark"]}),x.jsxs(Jf,{value:"system",children:[x.jsx(tg,{}),"System"]})]})})]})}function vS(l){return At(l.defaultTagName??"div",l,l)}const yS=_d("h-5 gap-1 rounded-none border border-transparent px-2 py-0.5 text-xs font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-3! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-colors overflow-hidden group/badge",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function Sn({className:l,variant:r="default",render:o,...i}){return vS({defaultTagName:"span",props:pa({className:pt(yS({className:l,variant:r}))},i),render:o,state:{slot:"badge",variant:r}})}function Qn({className:l,size:r="default",...o}){return x.jsx("div",{"data-slot":"card","data-size":r,className:pt("ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-none py-4 text-xs/relaxed ring-1 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-2 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-none *:[img:last-child]:rounded-none group/card flex flex-col",l),...o})}function Wn({className:l,...r}){return x.jsx("div",{"data-slot":"card-header",className:pt("gap-1 rounded-none px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",l),...r})}function el({className:l,...r}){return x.jsx("div",{"data-slot":"card-title",className:pt("text-sm font-medium group-data-[size=sm]/card:text-sm",l),...r})}function tl({className:l,...r}){return x.jsx("div",{"data-slot":"card-description",className:pt("text-muted-foreground text-xs/relaxed",l),...r})}function lu({className:l,...r}){return x.jsx("div",{"data-slot":"card-action",className:pt("col-start-2 row-span-2 row-start-1 self-start justify-self-end",l),...r})}function nl({className:l,...r}){return x.jsx("div",{"data-slot":"card-content",className:pt("px-4 group-data-[size=sm]/card:px-3",l),...r})}function yd({className:l,...r}){return x.jsx("div",{"data-slot":"card-footer",className:pt("rounded-none border-t p-4 group-data-[size=sm]/card:p-3 flex items-center",l),...r})}function n0({className:l,orientation:r="horizontal",...o}){return x.jsx(uS,{"data-slot":"separator",orientation:r,className:pt("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",l),...o})}const bS=[{key:"captures",label:"Captures",icon:x.jsx(Wp,{})},{key:"templates",label:"Templates",icon:x.jsx($p,{})},{key:"run",label:"Run",icon:x.jsx(Nd,{})},{key:"settings",label:"Settings",icon:x.jsx(eg,{})}];async function rl(l,r){const o=await fetch(l,{...r,headers:{...r?.headers||{},...r?.body?{"Content-Type":"application/json"}:{}}}),d=(o.headers.get("content-type")||"").includes("application/json")?await o.json().catch(()=>null):await o.text();if(!o.ok){const m=d&&typeof d=="object"&&"error"in d&&d.error||o.statusText||"Request failed";throw new Error(String(m))}return d}async function xS(){return rl("/health")}async function SS(l){const r=new URLSearchParams;r.set("limit",String(l.limit)),l?.provider&&r.set("provider",l.provider),l?.q&&r.set("q",l.q);const o=r.toString();return rl(`/api/captures${o?`?${o}`:""}`)}async function ES(l){return rl(`/api/captures/${encodeURIComponent(l)}`)}async function RS(l){return rl(`/api/captures/${encodeURIComponent(l)}`,{method:"DELETE"})}async function AS(){return rl("/api/captures",{method:"DELETE"})}async function TS(l){return rl("/api/replay",{method:"POST",body:JSON.stringify(l)})}async function K2(){return rl("/api/templates/local")}async function J2(l){const r=l?.refresh?"?refresh=true":"";return rl(`/api/templates/remote${r}`)}async function MS(l){return rl("/api/templates/download",{method:"POST",body:JSON.stringify({id:l})})}async function wS(){return rl("/api/templates/download-all",{method:"POST",body:JSON.stringify({})})}async function CS(l){return rl("/api/run",{method:"POST",body:JSON.stringify(l)})}function OS({className:l,...r}){return x.jsx("label",{"data-slot":"label",className:pt("gap-2 text-xs leading-none group-data-[disabled=true]:opacity-50 peer-disabled:opacity-50 flex items-center select-none group-data-[disabled=true]:pointer-events-none peer-disabled:cursor-not-allowed",l),...r})}function oi({className:l,...r}){return x.jsx("div",{"data-slot":"field-group",className:pt("gap-5 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4 group/field-group @container/field-group flex w-full flex-col",l),...r})}const zS=_d("data-[invalid=true]:text-destructive gap-2 group/field flex w-full",{variants:{orientation:{vertical:"flex-col [&>*]:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center [&>[data-slot=field-label]]:flex-auto has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto @md/field-group:[&>[data-slot=field-label]]:flex-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function yn({className:l,orientation:r="vertical",...o}){return x.jsx("div",{role:"group","data-slot":"field","data-orientation":r,className:pt(zS({orientation:r}),l),...o})}function bn({className:l,...r}){return x.jsx(OS,{"data-slot":"field-label",className:pt("has-data-checked:bg-primary/5 has-data-checked:border-primary dark:has-data-checked:bg-primary/10 gap-2 group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-none has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-2 group/field-label peer/field-label flex w-fit leading-snug","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",l),...r})}function qa({className:l,...r}){return x.jsx("p",{"data-slot":"field-description",className:pt("text-muted-foreground text-left text-xs/relaxed [[data-variant=legend]+&]:-mt-1.5 leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance","last:mt-0 nth-last-2:-mt-1","[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",l),...r})}let Fp=(function(l){return l.disabled="data-disabled",l.valid="data-valid",l.invalid="data-invalid",l.touched="data-touched",l.dirty="data-dirty",l.filled="data-filled",l.focused="data-focused",l})({});const NS={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},P2={valid(l){return l===null?null:l?{[Fp.valid]:""}:{[Fp.invalid]:""}}},jS=f.createContext({invalid:void 0,name:void 0,validityData:{state:NS,errors:[],error:"",value:"",initialValue:null},setValidityData:Nn,disabled:void 0,touched:!1,setTouched:Nn,dirty:!1,setDirty:Nn,filled:!1,setFilled:Nn,focused:!1,setFocused:Nn,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:{disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},markedDirtyRef:{current:!1},validation:{getValidationProps:(l=Bt)=>l,getInputValidationProps:(l=Bt)=>l,inputRef:{current:null},commit:async()=>{}}});function ii(l=!0){const r=f.useContext(jS);if(r.setValidityData===Nn&&!l)throw new Error(an(28));return r}const HS=f.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:Nn,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function $2(){return f.useContext(HS)}const DS=f.createContext({controlId:void 0,setControlId:Nn,labelId:void 0,setLabelId:Nn,messageIds:[],setMessageIds:Nn,getDescriptionProps:l=>l});function gu(){return f.useContext(DS)}function LS(l,r){return{...l,state:{...l.state,valid:!r&&l.state.valid}}}function W2(l={}){const{id:r,implicit:o=!1,controlRef:i}=l,{controlId:c,setControlId:d}=gu(),m=mu(r);return we(()=>{if(!(!o&&!r||d===Nn)){if(o){const g=i?.current;ot(g)&&g.closest("label")!=null?d(r??null):d(c??m)}else r&&d(r);return()=>{r&&d(void 0)}}},[r,i,c,d,o,m]),c??m}function ev(l){const{enabled:r=!0,value:o,id:i,name:c,controlRef:d,commit:m}=l,{formRef:g}=$2(),{invalid:v,markedDirtyRef:h,validityData:b,setValidityData:y}=ii(),E=Ae(l.getValue);we(()=>{if(!r)return;let R=o;R===void 0&&(R=E()),b.initialValue===null&&R!==null&&y(C=>({...C,initialValue:R}))},[r,y,o,b.initialValue,E]),we(()=>{!r||!i||g.current.fields.set(i,{getValue:E,name:c,controlRef:d,validityData:LS(b,v),validate(){let R=o;R===void 0&&(R=E()),h.current=!0,ll.flushSync(()=>m(R))}})},[m,d,r,g,E,i,v,h,c,b,o]),we(()=>{const R=g.current.fields;return()=>{i&&R.delete(i)}},[g,i])}const _S=f.forwardRef(function(r,o){const{render:i,className:c,id:d,name:m,value:g,disabled:v=!1,onValueChange:h,defaultValue:b,...y}=r,{state:E,name:R,disabled:C}=ii(),M=C||v,O=R??m,z=f.useMemo(()=>({...E,disabled:M}),[E,M]),{setTouched:N,setDirty:H,validityData:L,setFocused:A,setFilled:B,validationMode:U,validation:k}=ii(),{labelId:re}=gu(),ce=W2({id:d});we(()=>{const T=g!=null;k.inputRef.current?.value||T&&g!==""?B(!0):T&&g===""&&B(!1)},[k.inputRef,B,g]);const[oe,ae]=Fs({controlled:g,default:b,name:"FieldControl",state:"value"}),G=g!==void 0,$=Ae((T,_)=>{h?.(T,_),!_.isCanceled&&ae(T)});return ev({id:ce,name:O,commit:k.commit,value:oe,getValue:()=>k.inputRef.current?.value,controlRef:k.inputRef}),At("input",r,{ref:o,state:z,props:[{id:ce,disabled:M,name:O,ref:k.inputRef,"aria-labelledby":re,...G?{value:oe}:{defaultValue:b},onChange(T){const _=T.currentTarget.value;$(_,Ie(du,T.nativeEvent)),H(_!==L.initialValue),B(_!=="")},onFocus(){A(!0)},onBlur(T){N(!0),A(!1),U==="onBlur"&&k.commit(T.currentTarget.value)},onKeyDown(T){T.currentTarget.tagName==="INPUT"&&T.key==="Enter"&&(N(!0),k.commit(T.currentTarget.value))}},k.getInputValidationProps(),y],stateAttributesMapping:P2})}),VS=f.forwardRef(function(r,o){return x.jsx(_S,{ref:o,...r})});function Fr({className:l,type:r,...o}){return x.jsx(VS,{type:r,"data-slot":"input",className:pt("dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 h-8 rounded-none border bg-transparent px-2.5 py-1 text-xs transition-colors file:h-6 file:text-xs file:font-medium focus-visible:ring-1 aria-invalid:ring-1 md:text-xs file:text-foreground placeholder:text-muted-foreground w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",l),...o})}function US(l){const r=f.useRef(!0);r.current&&(r.current=!1,l())}const tv=f.createContext(null),nv=f.createContext(null);function gl(){const l=f.useContext(tv);if(l===null)throw new Error(an(60));return l}function lv(){const l=f.useContext(nv);if(l===null)throw new Error(an(61));return l}const kS=(l,r)=>Object.is(l,r);function Kr(l,r,o){return l==null||r==null?Object.is(l,r):o(l,r)}function Pf(l,r,o){return!l||l.length===0?!1:l.some(i=>i===void 0?!1:Kr(i,r,o))}function bd(l,r,o){return!l||l.length===0?-1:l.findIndex(i=>i===void 0?!1:Kr(i,r,o))}function ZS(l,r,o){return l.filter(i=>!Kr(i,r,o))}function xd(l){if(l==null)return"";if(typeof l=="string")return l;try{return JSON.stringify(l)}catch{return String(l)}}function BS(l){return l!=null&&l.length>0&&typeof l[0]=="object"&&l[0]!=null&&"items"in l[0]}function $o(l,r){if(r&&l!=null)return r(l)??"";if(l&&typeof l=="object"){if("label"in l&&l.label!=null)return String(l.label);if("value"in l)return String(l.value)}return xd(l)}function Lr(l,r){return r&&l!=null?r(l)??"":l&&typeof l=="object"&&"value"in l&&"label"in l?xd(l.value):xd(l)}function qS(l,r,o){if(o&&l!=null)return o(l);if(l&&typeof l=="object"&&"label"in l&&l.label!=null)return l.label;if(r&&!Array.isArray(r))return r[l]??$o(l,o);if(Array.isArray(r)){const i=BS(r)?r.flatMap(c=>c.items):r;if(l==null){const c=i.find(d=>d.value==null);return c&&c.label!=null?c.label:$o(l,o)}if(typeof l!="object"){const c=i.find(d=>d&&d.value===l);return c&&c.label!=null?c.label:$o(l,o)}if("value"in l){const c=i.find(d=>d&&d.value===l.value);if(c&&c.label!=null)return c.label}}return $o(l,o)}function YS(l,r){return!Array.isArray(l)||l.length===0?"":l.map(o=>$o(o,r)).join(", ")}const Ve={id:Me(l=>l.id),modal:Me(l=>l.modal),multiple:Me(l=>l.multiple),items:Me(l=>l.items),itemToStringLabel:Me(l=>l.itemToStringLabel),itemToStringValue:Me(l=>l.itemToStringValue),isItemEqualToValue:Me(l=>l.isItemEqualToValue),value:Me(l=>l.value),open:Me(l=>l.open),mounted:Me(l=>l.mounted),forceMount:Me(l=>l.forceMount),transitionStatus:Me(l=>l.transitionStatus),openMethod:Me(l=>l.openMethod),activeIndex:Me(l=>l.activeIndex),selectedIndex:Me(l=>l.selectedIndex),isActive:Me((l,r)=>l.activeIndex===r),isSelected:Me((l,r,o)=>{const i=l.isItemEqualToValue,c=l.value;return l.multiple?Array.isArray(c)&&c.some(d=>Kr(d,o,i)):l.selectedIndex===r&&l.selectedIndex!==null?!0:Kr(c,o,i)}),isSelectedByFocus:Me((l,r)=>l.selectedIndex===r),popupProps:Me(l=>l.popupProps),triggerProps:Me(l=>l.triggerProps),triggerElement:Me(l=>l.triggerElement),positionerElement:Me(l=>l.positionerElement),listElement:Me(l=>l.listElement),scrollUpArrowVisible:Me(l=>l.scrollUpArrowVisible),scrollDownArrowVisible:Me(l=>l.scrollDownArrowVisible),hasScrollArrows:Me(l=>l.hasScrollArrows),serializedValue:Me(l=>{const{multiple:r,value:o,itemToStringValue:i}=l;return r&&Array.isArray(o)&&o.length===0?"":Lr(o,i)})};function GS(l,r){const o=f.useRef(l),i=Ae(r);we(()=>{o.current!==l&&i(o.current)},[l,i]),we(()=>{o.current=l},[l])}function XS(l){const{id:r,value:o,defaultValue:i=null,onValueChange:c,open:d,defaultOpen:m=!1,onOpenChange:g,name:v,disabled:h=!1,readOnly:b=!1,required:y=!1,modal:E=!0,actionsRef:R,inputRef:C,onOpenChangeComplete:M,items:O,multiple:z=!1,itemToStringLabel:N,itemToStringValue:H,isItemEqualToValue:L=kS,highlightItemOnHover:A=!0,children:B}=l,{clearErrors:U}=$2(),{setDirty:k,shouldValidateOnChange:re,validityData:ce,setFilled:oe,name:ae,disabled:G,validation:$}=ii(),{controlId:Q}=gu(),T=W2({id:r}),_=G||h,j=ae??v,[F,ne]=Fs({controlled:o,default:z?i??qr:i,name:"Select",state:"value"}),[w,Y]=Fs({controlled:d,default:m,name:"Select",state:"open"}),Z=f.useRef([]),W=f.useRef([]),de=f.useRef(null),ee=f.useRef(null),J=f.useRef(0),fe=f.useRef(null),pe=f.useRef([]),Ee=f.useRef(!1),te=f.useRef(!1),be=f.useRef(null),ye=f.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}),Ue=f.useRef(!1),{mounted:Re,setMounted:me,transitionStatus:he}=fi(w),{openMethod:He,triggerProps:xe,reset:Ne}=X2(w),ue=Ln(()=>new Br({id:T,modal:E,multiple:z,itemToStringLabel:N,itemToStringValue:H,isItemEqualToValue:L,value:F,open:w,mounted:Re,transitionStatus:he,items:O,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,De=Ze(ue,Ve.activeIndex),ge=Ze(ue,Ve.selectedIndex),Se=Ze(ue,Ve.triggerElement),ve=Ze(ue,Ve.positionerElement),Ge=f.useMemo(()=>z&&Array.isArray(F)&&F.length===0?"":Lr(F,H),[z,F,H]),nt=f.useMemo(()=>z&&Array.isArray(F)?F.map(Pe=>Lr(Pe,H)):Lr(F,H),[z,F,H]),qe=Zt(ue.state.triggerElement);ev({id:T,commit:$.commit,value:F,controlRef:qe,name:j,getValue:()=>nt});const vt=f.useRef(F);we(()=>{F!==vt.current&&ue.set("forceMount",!0)},[ue,F]),we(()=>{oe(F!==null)},[F,oe]),we(function(){if(w)return;const wt=pe.current;if(z){const un=Array.isArray(F)?F:[];if(un.length===0){ue.set("selectedIndex",null);return}const rn=un[un.length-1],vl=bd(wt,rn,L);ue.set("selectedIndex",vl===-1?null:vl);return}const en=bd(wt,F,L);ue.set("selectedIndex",en===-1?null:en)},[z,w,F,pe,L,ue]),GS(F,()=>{U(j),k(F!==ce.initialValue),re()?$.commit(F):$.commit(F,!0)});const yt=Ae((Pe,wt)=>{if(g?.(Pe,wt),!wt.isCanceled&&(Y(Pe),!Pe&&ue.state.activeIndex!==null)){const en=Z.current[ue.state.activeIndex];queueMicrotask(()=>{en?.setAttribute("tabindex","-1")})}}),Nt=Ae(()=>{me(!1),ue.set("activeIndex",null),Ne(),M?.(!1)});Ka({enabled:!R,open:w,ref:de,onComplete(){w||Nt()}}),f.useImperativeHandle(R,()=>({unmount:Nt}),[Nt]);const Et=Ae((Pe,wt)=>{c?.(Pe,wt),!wt.isCanceled&&ne(Pe)}),ut=Ae(()=>{const Pe=ue.state.listElement||de.current;if(!Pe)return;const wt=Pe.scrollTop,en=Pe.scrollTop+Pe.clientHeight,un=wt>1,rn=en<Pe.scrollHeight-1;ue.state.scrollUpArrowVisible!==un&&ue.set("scrollUpArrowVisible",un),ue.state.scrollDownArrowVisible!==rn&&ue.set("scrollDownArrowVisible",rn)}),ze=S2({open:w,onOpenChange:yt,elements:{reference:Se,floating:ve}}),Be=i2(ze,{enabled:!b&&!_,event:"mousedown"}),Je=g2(ze,{bubbles:!1}),ct=R2(ze,{enabled:!b&&!_,listRef:Z,activeIndex:De,selectedIndex:ge,disabledIndices:qr,onNavigate(Pe){Pe===null&&!w||ue.set("activeIndex",Pe)},focusItemOnHover:!1}),bt=A2(ze,{enabled:!b&&!_&&(w||!z),listRef:W,activeIndex:De,selectedIndex:ge,onMatch(Pe){w?ue.set("activeIndex",Pe):Et(pe.current[Pe],Ie("none"))},onTypingChange(Pe){Ee.current=Pe}}),{getReferenceProps:jt,getFloatingProps:gt,getItemProps:Gt}=e0([Be,Je,ct,bt]),Tt=f.useMemo(()=>pa(jt(),xe),[jt,xe]);US(()=>{ue.update({popupProps:gt(),triggerProps:Tt})}),we(()=>{ue.update({id:T,modal:E,multiple:z,value:F,open:w,mounted:Re,transitionStatus:he,popupProps:gt(),triggerProps:Tt,items:O,itemToStringLabel:N,itemToStringValue:H,isItemEqualToValue:L,openMethod:He})},[ue,T,E,z,F,w,Re,he,gt,Tt,O,N,H,L,He]);const Mt=f.useMemo(()=>({store:ue,name:j,required:y,disabled:_,readOnly:b,multiple:z,itemToStringLabel:N,itemToStringValue:H,highlightItemOnHover:A,setValue:Et,setOpen:yt,listRef:Z,popupRef:de,scrollHandlerRef:ee,handleScrollArrowVisibility:ut,scrollArrowsMountedCountRef:J,getItemProps:Gt,events:ze.context.events,valueRef:fe,valuesRef:pe,labelsRef:W,typingRef:Ee,selectionRef:ye,selectedItemTextRef:be,validation:$,onOpenChangeComplete:M,keyboardActiveRef:te,alignItemWithTriggerActiveRef:Ue,initialValueRef:vt}),[ue,j,y,_,b,z,N,H,A,Et,yt,Gt,ze.context.events,$,M,ut]),sn=ga(C,$.inputRef),_n=z&&Array.isArray(F)&&F.length>0,xa=f.useMemo(()=>!z||!Array.isArray(F)||!j?null:F.map(Pe=>{const wt=Lr(Pe,H);return x.jsx("input",{type:"hidden",name:j,value:wt},wt)}),[z,F,j,H]);return x.jsx(tv.Provider,{value:Mt,children:x.jsxs(nv.Provider,{value:ze,children:[B,x.jsx("input",{...$.getInputValidationProps({onFocus(){ue.state.triggerElement?.focus()},onChange(Pe){if(Pe.nativeEvent.defaultPrevented)return;const wt=Pe.target.value,en=Ie(du,Pe.nativeEvent);function un(){if(z)return;const rn=pe.current.find(vl=>Lr(vl,H).toLowerCase()===wt.toLowerCase());rn!=null&&(k(rn!==ce.initialValue),Et(rn,en),re()&&$.commit(rn))}ue.set("forceMount",!0),queueMicrotask(un)}}),id:r||Q||void 0,name:z?void 0:j,value:Ge,disabled:_,required:y&&!_n,readOnly:b,ref:sn,style:Kd,tabIndex:-1,"aria-hidden":!0}),xa]})})}const ks=2,IS={...ud,...P2,value:()=>null},QS=f.forwardRef(function(r,o){const{render:i,className:c,disabled:d=!1,nativeButton:m=!0,...g}=r,{setTouched:v,setFocused:h,validationMode:b,state:y,disabled:E}=ii(),{labelId:R}=gu(),{store:C,setOpen:M,selectionRef:O,validation:z,readOnly:N,alignItemWithTriggerActiveRef:H,disabled:L,keyboardActiveRef:A}=gl(),B=E||L||d,U=Ze(C,Ve.open),k=Ze(C,Ve.value),re=Ze(C,Ve.triggerProps),ce=Ze(C,Ve.positionerElement),oe=Ze(C,Ve.listElement),ae=Ze(C,Ve.serializedValue),G=Zt(ce),$=f.useRef(null),Q=qt(),T=qt(),{getButtonProps:_,buttonRef:j}=ui({disabled:B,native:m}),F=Ae(ee=>{C.set("triggerElement",ee)}),ne=ga(o,$,j,F),w=qt(),Y=qt();f.useEffect(()=>{if(U)return Y.start(200,()=>{O.current.allowUnselectedMouseUp=!0,w.start(200,()=>{O.current.allowSelectedMouseUp=!0})}),()=>{w.clear(),Y.clear()};O.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1},T.clear()},[U,O,T,w,Y]);const Z=f.useMemo(()=>oe?.id??li(ce)?.id,[oe,ce]),W=pa(re,{role:"combobox","aria-expanded":U?"true":"false","aria-haspopup":"listbox","aria-controls":U?Z:void 0,"aria-labelledby":R,"aria-readonly":N||void 0,tabIndex:B?-1:0,ref:ne,onFocus(ee){h(!0),U&&H.current&&M(!1,Ie(Ya,ee.nativeEvent)),Q.start(0,()=>{C.set("forceMount",!0)})},onBlur(){v(!0),h(!1),b==="onBlur"&&z.commit(k)},onPointerMove(){A.current=!1},onKeyDown(){A.current=!0},onMouseDown(ee){if(U)return;const J=al(ee.currentTarget);function fe(pe){if(!$.current)return;const Ee=pe.target;if(et($.current,Ee)||et(G.current,Ee)||Ee===$.current)return;const te=I2($.current);pe.clientX>=te.left-ks&&pe.clientX<=te.right+ks&&pe.clientY>=te.top-ks&&pe.clientY<=te.bottom+ks||M(!1,Ie(Tg,pe))}T.start(0,()=>{J.addEventListener("mouseup",fe,{once:!0})})}},z.getValidationProps,g,_);W.role="combobox";const de=f.useMemo(()=>({...y,open:U,disabled:B,value:k,readOnly:N,placeholder:!ae}),[y,U,B,k,N,ae]);return At("button",r,{ref:[o,$],state:de,stateAttributesMapping:IS,props:W})}),FS={value:()=>null},KS=f.forwardRef(function(r,o){const{className:i,render:c,children:d,...m}=r,{store:g,valueRef:v}=gl(),h=Ze(g,Ve.value),b=Ze(g,Ve.items),y=Ze(g,Ve.itemToStringLabel),E=Ze(g,Ve.serializedValue),R=f.useMemo(()=>({value:h,placeholder:!E}),[h,E]),C=typeof d=="function"?d(h):d??(Array.isArray(h)?YS(h,y):qS(h,b,y));return At("span",r,{state:R,ref:[o,v],props:[{children:C},m],stateAttributesMapping:FS})}),JS=f.forwardRef(function(r,o){const{className:i,render:c,...d}=r,{store:m}=gl(),g=Ze(m,Ve.open),v=f.useMemo(()=>({open:g}),[g]);return At("span",r,{state:v,ref:o,props:[{"aria-hidden":!0,children:"▼"},d],stateAttributesMapping:Oy})}),PS=f.createContext(void 0),$S=f.forwardRef(function(r,o){const{store:i}=gl(),c=Ze(i,Ve.mounted),d=Ze(i,Ve.forceMount);return c||d?x.jsx(PS.Provider,{value:!0,children:x.jsx(r2,{ref:o,...r})}):null}),av=f.createContext(void 0);function l0(){const l=f.useContext(av);if(!l)throw new Error(an(59));return l}function au(l,r){l&&Object.assign(l.style,r)}const rv={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},WS={position:"fixed"},eE=f.forwardRef(function(r,o){const{anchor:i,positionMethod:c="absolute",className:d,render:m,side:g="bottom",align:v="center",sideOffset:h=0,alignOffset:b=0,collisionBoundary:y="clipping-ancestors",collisionPadding:E,arrowPadding:R=5,sticky:C=!1,disableAnchorTracking:M,alignItemWithTrigger:O=!0,collisionAvoidance:z=ig,...N}=r,{store:H,listRef:L,labelsRef:A,alignItemWithTriggerActiveRef:B,selectedItemTextRef:U,valuesRef:k,initialValueRef:re,popupRef:ce,setValue:oe}=gl(),ae=lv(),G=Ze(H,Ve.open),$=Ze(H,Ve.mounted),Q=Ze(H,Ve.modal),T=Ze(H,Ve.value),_=Ze(H,Ve.openMethod),j=Ze(H,Ve.positionerElement),F=Ze(H,Ve.triggerElement),ne=Ze(H,Ve.isItemEqualToValue),w=f.useRef(null),Y=f.useRef(null),[Z,W]=f.useState(O),de=$&&Z&&_!=="touch";!$&&Z!==O&&W(O),we(()=>{$||(Ve.scrollUpArrowVisible(H.state)&&H.set("scrollUpArrowVisible",!1),Ve.scrollDownArrowVisible(H.state)&&H.set("scrollDownArrowVisible",!1))},[H,$]),f.useImperativeHandle(B,()=>de),Y2((de||Q)&&G&&_!=="touch",F);const ee=U2({anchor:i,floatingRootContext:ae,positionMethod:c,mounted:$,side:g,sideOffset:h,align:v,alignOffset:b,arrowPadding:R,collisionBoundary:y,collisionPadding:E,sticky:C,disableAnchorTracking:M??de,collisionAvoidance:z,keepMounted:!0}),J=de?"none":ee.side,fe=de?WS:ee.positionerStyles,pe=f.useMemo(()=>{const me={};return G||(me.pointerEvents="none"),{role:"presentation",hidden:!$,style:{...fe,...me}}},[G,$,fe]),Ee=f.useMemo(()=>({open:G,side:J,align:ee.align,anchorHidden:ee.anchorHidden}),[G,J,ee.align,ee.anchorHidden]),te=Ae(me=>{H.set("positionerElement",me)}),be=At("div",r,{ref:[o,te],state:Ee,stateAttributesMapping:cu,props:[pe,N]}),ye=f.useRef(0),Ue=Ae(me=>{if(me.size===0&&ye.current===0||k.current.length===0)return;const he=ye.current;if(ye.current=me.size,me.size===he)return;const He=Ie(du);if(he!==0&&!H.state.multiple&&T!==null&&bd(k.current,T,ne)===-1){const Ne=re.current,De=Ne!=null&&Pf(k.current,Ne,ne)?Ne:null;oe(De,He),De===null&&(H.set("selectedIndex",null),U.current=null)}if(he!==0&&H.state.multiple&&Array.isArray(T)){const xe=T.filter(Ne=>Pf(k.current,Ne,ne));(xe.length!==T.length||xe.some(Ne=>!Pf(T,Ne,ne)))&&(oe(xe,He),xe.length===0&&(H.set("selectedIndex",null),U.current=null))}if(G&&de){H.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const xe={height:""};au(j,xe),au(ce.current,xe)}}),Re=f.useMemo(()=>({...ee,side:J,alignItemWithTriggerActive:de,setControlledAlignItemWithTrigger:W,scrollUpArrowRef:w,scrollDownArrowRef:Y}),[ee,J,de,W]);return x.jsx(k2,{elementsRef:L,labelsRef:A,onMapChange:Ue,children:x.jsxs(av.Provider,{value:Re,children:[$&&Q&&x.jsx(Z2,{inert:L2(!G),cutout:F}),be]})})});function ov(l){const r=l.currentTarget.getBoundingClientRect();return r.top+1<=l.clientY&&l.clientY<=r.bottom-1&&r.left+1<=l.clientX&&l.clientX<=r.right-1}const Zs="base-ui-disable-scrollbar",Sd={className:Zs,element:x.jsx("style",{href:Zs,precedence:"base-ui:low",children:`.${Zs}{scrollbar-width:none}.${Zs}::-webkit-scrollbar{display:none}`})},tE={...cu,...uu},nE=f.forwardRef(function(r,o){const{render:i,className:c,...d}=r,{store:m,popupRef:g,onOpenChangeComplete:v,setOpen:h,valueRef:b,selectedItemTextRef:y,keyboardActiveRef:E,multiple:R,handleScrollArrowVisibility:C,scrollHandlerRef:M}=gl(),{side:O,align:z,alignItemWithTriggerActive:N,setControlledAlignItemWithTrigger:H,scrollDownArrowRef:L,scrollUpArrowRef:A}=l0(),B=T2()!=null,U=lv(),k=qt(),re=Ze(m,Ve.id),ce=Ze(m,Ve.open),oe=Ze(m,Ve.mounted),ae=Ze(m,Ve.popupProps),G=Ze(m,Ve.transitionStatus),$=Ze(m,Ve.triggerElement),Q=Ze(m,Ve.positionerElement),T=Ze(m,Ve.listElement),_=f.useRef(0),j=f.useRef(!1),F=f.useRef(0),ne=f.useRef(!1),w=f.useRef({}),Y=ci(),Z=Ae(J=>{if(!Q||!g.current||!ne.current)return;if(j.current||!N){C();return}const fe=Q.style.top==="0px",pe=Q.style.bottom==="0px",Ee=Q.getBoundingClientRect().height,te=al(Q),be=getComputedStyle(Q),ye=parseFloat(be.marginTop),Ue=parseFloat(be.marginBottom),Re=te.documentElement.clientHeight-ye-Ue,me=J.scrollTop,he=J.scrollHeight,He=J.clientHeight,xe=he-He;let Ne=null,ue=null,De=!1;if(fe){const ge=xe-me,Se=Ee+ge,ve=Math.min(Se,Re);Ne=ve,ve!==Re?ue=xe:De=!0}else if(pe){const ge=me-0,Se=Ee+ge,ve=Math.min(Se,Re),Ge=Se-Re;Ne=ve,ve!==Re?ue=0:(De=!0,me<xe&&(ue=me-(ge-Ge)))}Ne!=null&&(Q.style.height=`${Ne}px`),ue!=null&&(J.scrollTop=ue),De&&(j.current=!0),C()});f.useImperativeHandle(M,()=>Z,[Z]),Ka({open:ce,ref:g,onComplete(){ce&&v?.(!0)}});const W=f.useMemo(()=>({open:ce,transitionStatus:G,side:O,align:z}),[ce,G,O,z]);we(()=>{!Q||!g.current||Object.keys(w.current).length||(w.current={top:Q.style.top||"0",left:Q.style.left||"0",right:Q.style.right,height:Q.style.height,bottom:Q.style.bottom,minHeight:Q.style.minHeight,maxHeight:Q.style.maxHeight,marginTop:Q.style.marginTop,marginBottom:Q.style.marginBottom})},[g,Q]),we(()=>{oe||N||(ne.current=!1,j.current=!1,_.current=0,F.current=0,au(Q,w.current))},[oe,N,Q,g]),we(()=>{const J=g.current;if(!(!oe||!$||!Q||!J)){if(!N){ne.current=!0,Y.request(C);return}queueMicrotask(()=>{const fe=getComputedStyle(Q),pe=getComputedStyle(J),Ee=al($),te=Yt(Q),be=$.getBoundingClientRect(),ye=Q.getBoundingClientRect(),Ue=be.left,Re=be.height,me=T||J,he=me.scrollHeight,He=parseFloat(pe.borderBottomWidth),xe=parseFloat(fe.marginTop)||10,Ne=parseFloat(fe.marginBottom)||10,ue=parseFloat(fe.minHeight)||100,De=5,ge=5,Se=20,ve=Ee.documentElement.clientHeight-xe-Ne,Ge=Ee.documentElement.clientWidth,nt=ve-be.bottom+Re,qe=y.current,vt=b.current;let yt=0,Nt=0;if(qe&&vt){const Mt=vt.getBoundingClientRect(),sn=qe.getBoundingClientRect(),_n=Mt.left-Ue,xa=sn.left-ye.left,Pe=Mt.top-be.top+Mt.height/2,wt=sn.top-ye.top+sn.height/2;yt=_n-xa,Nt=wt-Pe}const Et=nt+Nt+Ne+He;let ut=Math.min(ve,Et);const ze=ve-xe-Ne,Be=Et-ut,Je=Math.max(De,Ue+yt),ct=Ge-ge,bt=Math.max(0,Je+ye.width-ct);Q.style.left=`${Je-bt}px`,Q.style.height=`${ut}px`,Q.style.maxHeight="auto",Q.style.marginTop=`${xe}px`,Q.style.marginBottom=`${Ne}px`,J.style.height="100%";const jt=me.scrollHeight-me.clientHeight,gt=Be>=jt;gt&&(ut=Math.min(ve,ye.height)-(Be-jt));const Gt=be.top<Se||be.bottom>ve-Se||ut<Math.min(he,ue),Tt=(te.visualViewport?.scale??1)!==1&&jg;if(Gt||Tt){ne.current=!0,au(Q,w.current),ll.flushSync(()=>H(!1));return}if(gt){const Mt=Math.max(0,ve-Et);Q.style.top=ye.height>=ze?"0":`${Mt}px`,Q.style.height=`${ut}px`,me.scrollTop=me.scrollHeight-me.clientHeight,_.current=Math.max(ue,ut)}else Q.style.bottom="0",_.current=Math.max(ue,ut),me.scrollTop=Be;_.current===ve&&(j.current=!0),C(),setTimeout(()=>{ne.current=!0})})}},[m,oe,Q,$,b,y,g,C,N,H,Y,L,A,T]),f.useEffect(()=>{if(!N||!Q||!oe)return;const J=Yt(Q);function fe(pe){h(!1,Ie(jy,pe))}return J.addEventListener("resize",fe),()=>{J.removeEventListener("resize",fe)}},[h,N,Q,oe]);const de={...T?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":R||void 0,id:`${re}-list`},onKeyDown(J){E.current=!0,B&&j2.has(J.key)&&J.stopPropagation()},onMouseMove(){E.current=!1},onPointerLeave(J){if(ov(J)||J.pointerType==="touch")return;const fe=J.currentTarget;k.start(0,()=>{m.set("activeIndex",null),fe.focus({preventScroll:!0})})},onScroll(J){T||M.current?.(J.currentTarget)},...N&&{style:T?{height:"100%"}:rv}},ee=At("div",r,{ref:[o,g],state:W,stateAttributesMapping:tE,props:[ae,de,H2(G),{className:!T&&N?Sd.className:void 0},d]});return x.jsxs(f.Fragment,{children:[Sd.element,x.jsx(o2,{context:U,modal:!1,disabled:!oe,restoreFocus:!0,children:ee})]})}),lE=f.forwardRef(function(r,o){const{className:i,render:c,...d}=r,{store:m,scrollHandlerRef:g}=gl(),{alignItemWithTriggerActive:v}=l0(),h=Ze(m,Ve.hasScrollArrows),b=Ze(m,Ve.openMethod),y=Ze(m,Ve.multiple),R={id:`${Ze(m,Ve.id)}-list`,role:"listbox","aria-multiselectable":y||void 0,onScroll(M){g.current?.(M.currentTarget)},...v&&{style:rv},className:h&&b!=="touch"?Sd.className:void 0},C=Ae(M=>{m.set("listElement",M)});return At("div",r,{ref:[o,C],props:[R,d]})}),iv=f.createContext(void 0);function a0(){const l=f.useContext(iv);if(!l)throw new Error(an(57));return l}const aE=f.memo(f.forwardRef(function(r,o){const{render:i,className:c,value:d=null,label:m,disabled:g=!1,nativeButton:v=!1,...h}=r,b=f.useRef(null),y=Bd({label:m,textRef:b,indexGuessBehavior:wg.GuessFromOrder}),{store:E,getItemProps:R,setOpen:C,setValue:M,selectionRef:O,typingRef:z,valuesRef:N,keyboardActiveRef:H,multiple:L,highlightItemOnHover:A}=gl(),B=qt(),U=Ze(E,Ve.isActive,y.index),k=Ze(E,Ve.isSelected,y.index,d),re=Ze(E,Ve.isSelectedByFocus,y.index),ce=Ze(E,Ve.isItemEqualToValue),oe=y.index,ae=oe!==-1,G=f.useRef(null),$=Zt(oe);we(()=>{if(!ae)return;const ee=N.current;return ee[oe]=d,()=>{delete ee[oe]}},[ae,oe,d,N]),we(()=>{if(!ae)return;const ee=E.state.value;let J=ee;L&&Array.isArray(ee)&&ee.length>0&&(J=ee[ee.length-1]),J!==void 0&&Kr(J,d,ce)&&E.set("selectedIndex",oe)},[ae,oe,L,ce,E,d]);const Q=f.useMemo(()=>({disabled:g,selected:k,highlighted:U}),[g,k,U]),T=R({active:U,selected:k});T.onFocus=void 0,T.id=void 0;const _=f.useRef(null),j=f.useRef("mouse"),F=f.useRef(!1),{getButtonProps:ne,buttonRef:w}=ui({disabled:g,focusableWhenDisabled:!0,native:v});function Y(ee){const J=E.state.value;if(L){const fe=Array.isArray(J)?J:[],pe=k?ZS(fe,d,ce):[...fe,d];M(pe,Ie(Vr,ee))}else M(d,Ie(Vr,ee)),C(!1,Ie(Vr,ee))}const Z={role:"option","aria-selected":k,"aria-disabled":g||void 0,tabIndex:U?0:-1,onFocus(){E.set("activeIndex",oe)},onMouseEnter(){!H.current&&E.state.selectedIndex===null&&E.set("activeIndex",oe)},onMouseMove(){A&&E.set("activeIndex",oe)},onMouseLeave(ee){!A||H.current||ov(ee)||B.start(0,()=>{E.state.activeIndex===oe&&E.set("activeIndex",null)})},onTouchStart(){O.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(ee){_.current=ee.key,E.set("activeIndex",oe)},onClick(ee){F.current=!1,!(ee.type==="keydown"&&_.current===null)&&(g||_.current===" "&&z.current||j.current!=="touch"&&!U||(_.current=null,Y(ee.nativeEvent)))},onPointerEnter(ee){j.current=ee.pointerType},onPointerDown(ee){j.current=ee.pointerType,F.current=!0},onMouseUp(ee){if(g)return;if(F.current){F.current=!1;return}const J=!O.current.allowSelectedMouseUp&&k,fe=!O.current.allowUnselectedMouseUp&&!k;J||fe||j.current!=="touch"&&!U||Y(ee.nativeEvent)}},W=At("div",r,{ref:[w,o,y.ref,G],state:Q,props:[T,Z,h,ne]}),de=f.useMemo(()=>({selected:k,indexRef:$,textRef:b,selectedByFocus:re,hasRegistered:ae}),[k,$,b,re,ae]);return x.jsx(iv.Provider,{value:de,children:W})})),rE=f.forwardRef(function(r,o){const i=r.keepMounted??!1,{selected:c}=a0();return i||c?x.jsx(oE,{...r,ref:o}):null}),oE=f.memo(f.forwardRef((l,r)=>{const{render:o,className:i,keepMounted:c,...d}=l,{selected:m}=a0(),g=f.useRef(null),{transitionStatus:v,setMounted:h}=fi(m),b=f.useMemo(()=>({selected:m,transitionStatus:v}),[m,v]),y=At("span",l,{ref:[r,g],state:b,props:[{"aria-hidden":!0,children:"✔️"},d],stateAttributesMapping:uu});return Ka({open:m,ref:g,onComplete(){m||h(!1)}}),y})),iE=f.memo(f.forwardRef(function(r,o){const{indexRef:i,textRef:c,selectedByFocus:d,hasRegistered:m}=a0(),{selectedItemTextRef:g}=gl(),{className:v,render:h,...b}=r,y=f.useCallback(R=>{if(!R||!m)return;const C=g.current===null||!g.current.isConnected;(d||C&&i.current===0)&&(g.current=R)},[g,i,d,m]);return At("div",r,{ref:[y,o,c],props:b})})),sv=f.forwardRef(function(r,o){const{render:i,className:c,direction:d,keepMounted:m=!1,...g}=r,{store:v,popupRef:h,listRef:b,handleScrollArrowVisibility:y,scrollArrowsMountedCountRef:E}=gl(),{side:R,scrollDownArrowRef:C,scrollUpArrowRef:M}=l0(),O=d==="up"?Ve.scrollUpArrowVisible:Ve.scrollDownArrowVisible,z=Ze(v,O),N=Ze(v,Ve.openMethod),H=z&&N!=="touch",L=qt(),A=d==="up"?M:C,{transitionStatus:B,setMounted:U}=fi(H);we(()=>(E.current+=1,v.state.hasScrollArrows||v.set("hasScrollArrows",!0),()=>{E.current=Math.max(0,E.current-1),E.current===0&&v.state.hasScrollArrows&&v.set("hasScrollArrows",!1)}),[v,E]),Ka({open:H,ref:A,onComplete(){H||U(!1)}});const k=f.useMemo(()=>({direction:d,visible:H,side:R,transitionStatus:B}),[d,H,R,B]),ce=At("div",r,{ref:[o,A],state:k,props:[{"aria-hidden":!0,children:d==="up"?"▲":"▼",style:{position:"absolute"},onMouseMove(ae){if(ae.movementX===0&&ae.movementY===0||L.isStarted())return;v.set("activeIndex",null);function G(){const $=v.state.listElement??h.current;if(!$)return;v.set("activeIndex",null),y();const Q=$.scrollTop===0,T=Math.round($.scrollTop+$.clientHeight)>=$.scrollHeight;if(b.current.length===0&&(d==="up"?v.set("scrollUpArrowVisible",!Q):v.set("scrollDownArrowVisible",!T)),d==="up"&&Q||d==="down"&&T){L.clear();return}if((v.state.listElement||h.current)&&b.current&&b.current.length>0){const j=b.current,F=A.current?.offsetHeight||0;if(d==="up"){let ne=0;const w=$.scrollTop+F;for(let Z=0;Z<j.length;Z+=1){const W=j[Z];if(W&&W.offsetTop>=w){ne=Z;break}}const Y=Math.max(0,ne-1);if(Y<ne){const Z=j[Y];Z&&($.scrollTop=Math.max(0,Z.offsetTop-F))}else $.scrollTop=0}else{let ne=j.length-1;const w=$.scrollTop+$.clientHeight-F;for(let Z=0;Z<j.length;Z+=1){const W=j[Z];if(W&&W.offsetTop+W.offsetHeight>w){ne=Math.max(0,Z-1);break}}const Y=Math.min(j.length-1,ne+1);if(Y>ne){const Z=j[Y];Z&&($.scrollTop=Z.offsetTop+Z.offsetHeight-$.clientHeight+F)}else $.scrollTop=$.scrollHeight-$.clientHeight}}L.start(40,G)}L.start(40,G)},onMouseLeave(){L.clear()}},g]});return H||m?ce:null}),sE=f.forwardRef(function(r,o){return x.jsx(sv,{...r,ref:o,direction:"down"})}),uE=f.forwardRef(function(r,o){return x.jsx(sv,{...r,ref:o,direction:"up"})}),uv=f.createContext(void 0);function cE(){const l=f.useContext(uv);if(l===void 0)throw new Error(an(56));return l}const fE=f.forwardRef(function(r,o){const{className:i,render:c,...d}=r,[m,g]=f.useState(),v=f.useMemo(()=>({labelId:m,setLabelId:g}),[m,g]),h=At("div",r,{ref:o,props:[{role:"group","aria-labelledby":m},d]});return x.jsx(uv.Provider,{value:v,children:h})}),dE=f.forwardRef(function(r,o){const{className:i,render:c,id:d,...m}=r,{setLabelId:g}=cE(),v=mu(d);return we(()=>{g(v)},[v,g]),At("div",r,{ref:o,props:[{id:v},m]})}),Ed=XS;function Rd({className:l,...r}){return x.jsx(fE,{"data-slot":"select-group",className:pt("scroll-my-1",l),...r})}function Ad({className:l,...r}){return x.jsx(KS,{"data-slot":"select-value",className:pt("flex flex-1 text-left",l),...r})}function Td({className:l,size:r="default",children:o,...i}){return x.jsxs(QS,{"data-slot":"select-trigger","data-size":r,className:pt("border-input data-[placeholder]:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 gap-1.5 rounded-none border bg-transparent py-2 pr-2 pl-2.5 text-xs transition-colors select-none focus-visible:ring-1 aria-invalid:ring-1 data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-none *:data-[slot=select-value]:flex *:data-[slot=select-value]:gap-1.5 [&_svg:not([class*='size-'])]:size-4 flex w-fit items-center justify-between whitespace-nowrap outline-none disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center [&_svg]:pointer-events-none [&_svg]:shrink-0",l),...i,children:[o,x.jsx(JS,{render:x.jsx(Od,{className:"text-muted-foreground size-4 pointer-events-none"})})]})}function Md({className:l,children:r,side:o="bottom",sideOffset:i=4,align:c="center",alignOffset:d=0,alignItemWithTrigger:m=!0,...g}){return x.jsx($S,{children:x.jsx(eE,{side:o,sideOffset:i,align:c,alignOffset:d,alignItemWithTrigger:m,className:"isolate z-50",children:x.jsxs(nE,{"data-slot":"select-content",className:pt("bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 min-w-36 rounded-none shadow-md ring-1 duration-100 relative isolate z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto",l),...g,children:[x.jsx(mE,{}),x.jsx(lE,{children:r}),x.jsx(hE,{})]})})})}function wd({className:l,...r}){return x.jsx(dE,{"data-slot":"select-label",className:pt("text-muted-foreground px-2 py-2 text-xs",l),...r})}function Cd({className:l,children:r,...o}){return x.jsxs(aE,{"data-slot":"select-item",className:pt("focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground gap-2 rounded-none py-2 pr-8 pl-2 text-xs [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2 relative flex w-full cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",l),...o,children:[x.jsx(iE,{className:"flex flex-1 gap-2 shrink-0 whitespace-nowrap",children:r}),x.jsx(rE,{render:x.jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:x.jsx(zd,{className:"pointer-events-none"})})]})}function mE({className:l,...r}){return x.jsx(uE,{"data-slot":"select-scroll-up-button",className:pt("bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4 top-0 w-full",l),...r,children:x.jsx(Pp,{})})}function hE({className:l,...r}){return x.jsx(sE,{"data-slot":"select-scroll-down-button",className:pt("bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4 bottom-0 w-full",l),...r,children:x.jsx(Od,{})})}function cv({className:l,...r}){return x.jsx("textarea",{"data-slot":"textarea",className:pt("border-input dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 rounded-none border bg-transparent px-2.5 py-2 text-xs transition-colors focus-visible:ring-1 aria-invalid:ring-1 md:text-xs placeholder:text-muted-foreground flex field-sizing-content min-h-16 w-full outline-none disabled:cursor-not-allowed disabled:opacity-50",l),...r})}function pE(l){if(!l||l<0)return"0 B";const r=["B","KB","MB","GB"];let o=l,i=0;for(;o>=1024&&i<r.length-1;)o/=1024,i++;return`${i===0?o:o.toFixed(1)} ${r[i]}`}function fv(l){const r=l.split(`
21
21
  `).map(i=>i.trim()).filter(Boolean),o=[];for(const i of r){const c=i.indexOf(":");if(c<=0)continue;const d=i.slice(0,c).trim(),m=i.slice(c+1).trim();d&&o.push({key:d,value:m})}return o}function Gs(l){try{return JSON.stringify(l,null,2)}catch{return String(l)}}const gE=[{label:"All providers",value:"all"},{label:"stripe",value:"stripe"},{label:"github",value:"github"},{label:"shopify",value:"shopify"},{label:"twilio",value:"twilio"},{label:"ragie",value:"ragie"},{label:"sendgrid",value:"sendgrid"},{label:"slack",value:"slack"},{label:"discord",value:"discord"},{label:"linear",value:"linear"},{label:"clerk",value:"clerk"},{label:"custom",value:"custom"}];function vE(l){const[r,o]=f.useState(""),[i,c]=f.useState("all"),[d,m]=f.useState(!1),[g,v]=f.useState(null),[h,b]=f.useState([]),[y,E]=f.useState(null),[R,C]=f.useState(null),[M,O]=f.useState(""),[z,N]=f.useState(""),[H,L]=f.useState(""),[A,B]=f.useState(null),[U,k]=f.useState(null),[re,ce]=f.useState(!1),oe=async()=>{m(!0),v(null);try{const T=await SS({limit:200,provider:i==="all"?void 0:i,q:r.trim()||void 0});b(T.captures)}catch(T){v(T instanceof Error?T.message:"Failed to load captures")}finally{m(!1)}};f.useEffect(()=>{oe()},[i]),f.useEffect(()=>{const T=window.setTimeout(()=>{oe()},250);return()=>window.clearTimeout(T)},[r]),f.useEffect(()=>{l.wsCaptures&&b(l.wsCaptures)},[l.wsCaptures]),f.useEffect(()=>{if(!y){C(null);return}const T=h.find(_=>_.capture.id===y)||null;T&&(C(T),M||O(`http://localhost:3000${T.capture.path}`),z||N(T.capture.method))},[y,h,M,z]);const ae=async T=>{E(T),l.onWsCaptureSelected?.(T),B(null),k(null);try{const _=await ES(T);C(_),O(`http://localhost:3000${_.capture.path}`),N(_.capture.method)}catch{}},G=async()=>{if(!R)return;const T=R.capture.id;try{await RS(T),C(null),E(null),B(null),k(null),await oe()}catch(_){v(_ instanceof Error?_.message:"Failed to delete capture")}},$=async()=>{try{await AS(),C(null),E(null),B(null),k(null),await oe()}catch(T){v(T instanceof Error?T.message:"Failed to delete all captures")}},Q=async()=>{if(R){ce(!0),k(null),B(null);try{const T=fv(H),_=await TS({captureId:R.capture.id,targetUrl:M,method:z||void 0,headers:T.length?T:void 0});B(_)}catch(T){k(T instanceof Error?T.message:"Replay failed")}finally{ce(!1)}}};return x.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(320px,420px)_1fr]",children:[x.jsxs(Qn,{children:[x.jsxs(Wn,{className:"border-b",children:[x.jsx(el,{children:"Captures"}),x.jsx(tl,{children:"Incoming webhooks captured by the local capture server."}),x.jsxs(lu,{className:"flex items-center gap-2",children:[x.jsxs(xn,{variant:"outline",size:"icon",onClick:()=>{oe()},disabled:d,children:[x.jsx(ni,{}),x.jsx("span",{className:"sr-only",children:"Refresh"})]}),x.jsxs(xn,{variant:"destructive",size:"icon",onClick:()=>{$()},children:[x.jsx(td,{}),x.jsx("span",{className:"sr-only",children:"Delete all"})]})]})]}),x.jsxs(nl,{className:"space-y-4",children:[x.jsxs("div",{className:"grid gap-3 @container/card-content",children:[x.jsxs("div",{className:"flex flex-col gap-2 @md/card-content:flex-row @md/card-content:items-center",children:[x.jsx(Fr,{placeholder:"Search by id, path, provider...",value:r,onChange:T=>o(T.target.value)}),x.jsxs(Ed,{value:i,onValueChange:T=>c(T??"all"),children:[x.jsx(Td,{className:"w-full @md/card-content:w-44",children:x.jsx(Ad,{})}),x.jsx(Md,{children:x.jsxs(Rd,{children:[x.jsx(wd,{children:"Provider"}),gE.map(T=>x.jsx(Cd,{value:T.value,children:T.label},T.value||"all"))]})})]})]}),g&&x.jsx("div",{className:"text-destructive text-xs",children:g})]}),x.jsx("div",{className:"border-border max-h-[calc(100vh-22rem)] overflow-auto border",children:h.length===0?x.jsxs("div",{className:"text-muted-foreground p-4 text-xs",children:["No captures yet. Send a webhook to the capture server (default:"," ",x.jsx("span",{className:"text-foreground",children:"http://localhost:3001"}),")."]}):x.jsx("div",{className:"divide-border divide-y",children:h.map(({file:T,capture:_})=>{const j=y===_.id,F=new Date(_.timestamp).toLocaleString();return x.jsxs("button",{type:"button",onClick:()=>{ae(_.id)},className:["hover:bg-muted/50 w-full cursor-default p-3 text-left outline-none",j?"bg-muted":""].join(" "),children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("div",{className:"text-foreground font-medium",children:_.id.slice(0,8)}),_.provider?x.jsx(Sn,{variant:"secondary",children:_.provider}):x.jsx(Sn,{variant:"outline",children:"unknown"}),x.jsx("div",{className:"text-muted-foreground ml-auto",children:pE(_.contentLength)})]}),x.jsxs("div",{className:"text-muted-foreground mt-1 flex items-center gap-2",children:[x.jsx("span",{className:"text-foreground",children:_.method}),x.jsx("span",{className:"truncate",children:_.path})]}),x.jsx("div",{className:"text-muted-foreground mt-1",children:F})]},T)})})})]}),x.jsx(yd,{className:"text-muted-foreground",children:d?"Loading...":`Showing ${h.length} capture(s)`})]}),x.jsxs(Qn,{children:[x.jsxs(Wn,{className:"border-b",children:[x.jsx(el,{children:"Details"}),x.jsx(tl,{children:"Inspect a capture, then replay it to any local endpoint."}),x.jsx(lu,{className:"flex items-center gap-2",children:x.jsxs(xn,{variant:"destructive",size:"default",onClick:()=>{G()},disabled:!R,children:[x.jsx(td,{"data-icon":"inline-start"}),"Delete"]})})]}),x.jsx(nl,{className:"space-y-4",children:R?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"grid gap-2",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("div",{className:"text-sm font-medium",children:R.capture.id}),R.capture.provider?x.jsx(Sn,{variant:"secondary",children:R.capture.provider}):x.jsx(Sn,{variant:"outline",children:"unknown"})]}),x.jsxs("div",{className:"text-muted-foreground text-xs",children:[R.capture.method," ",R.capture.url]})]}),x.jsx(n0,{}),x.jsxs(Qn,{size:"sm",children:[x.jsxs(Wn,{className:"border-b",children:[x.jsx(el,{children:"Replay"}),x.jsx(tl,{children:"Sends the captured payload to a target URL. Original headers are preserved (connection headers excluded)."})]}),x.jsx(nl,{children:x.jsxs(oi,{children:[x.jsxs(yn,{children:[x.jsx(bn,{htmlFor:"replay-url",children:"Target URL"}),x.jsx(Fr,{id:"replay-url",value:M,onChange:T=>O(T.target.value),placeholder:"http://localhost:3000/webhooks/provider"}),x.jsx(qa,{children:"Default is based on the captured path."})]}),x.jsxs(yn,{orientation:"responsive",children:[x.jsx(bn,{htmlFor:"replay-method",children:"Method"}),x.jsxs(Ed,{value:z,onValueChange:T=>N(T??""),children:[x.jsx(Td,{id:"replay-method",className:"w-full @md/field-group:w-40",children:x.jsx(Ad,{})}),x.jsx(Md,{children:x.jsxs(Rd,{children:[x.jsx(wd,{children:"Method"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>x.jsx(Cd,{value:T,children:T},T))]})})]})]}),x.jsxs(yn,{children:[x.jsx(bn,{htmlFor:"replay-headers",children:"Header overrides"}),x.jsx(cv,{id:"replay-headers",value:H,onChange:T=>L(T.target.value),placeholder:`X-Debug:true
22
22
  X-Request-Id: 123`}),x.jsxs(qa,{children:["One header per line, format:"," ",x.jsx("span",{className:"text-foreground",children:"key:value"})]})]}),U&&x.jsx("div",{className:"text-destructive text-xs",children:U}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsxs(xn,{onClick:()=>{Q()},disabled:re,children:[x.jsx(ni,{"data-icon":"inline-start"}),re?"Replaying...":"Replay"]}),x.jsx(xn,{variant:"outline",onClick:()=>{B(null),k(null)},disabled:re,children:"Clear result"})]})]})})]}),A&&x.jsxs(Qn,{size:"sm",children:[x.jsxs(Wn,{className:"border-b",children:[x.jsx(el,{children:"Replay result"}),x.jsxs(tl,{children:[A.status," ",A.statusText," •"," ",A.duration,"ms"]})]}),x.jsxs(nl,{className:"space-y-2",children:[x.jsx("div",{className:"text-muted-foreground text-xs",children:"Response body"}),x.jsx("pre",{className:"bg-muted/40 border-border overflow-auto border p-3 text-xs",children:Gs(A.json??A.body)})]})]}),x.jsxs(Qn,{size:"sm",children:[x.jsxs(Wn,{className:"border-b",children:[x.jsx(el,{children:"Raw request"}),x.jsx(tl,{children:"Headers + raw body as captured."})]}),x.jsxs(nl,{className:"space-y-2",children:[x.jsx("div",{className:"text-muted-foreground text-xs",children:"Headers"}),x.jsx("pre",{className:"bg-muted/40 border-border overflow-auto border p-3 text-xs",children:Gs(R.capture.headers)}),x.jsx("div",{className:"text-muted-foreground text-xs",children:"Body"}),x.jsx("pre",{className:"bg-muted/40 border-border overflow-auto border p-3 text-xs",children:R.capture.rawBody||Gs(R.capture.body)})]})]})]}):x.jsx("div",{className:"text-muted-foreground p-2 text-xs",children:"Select a capture on the left."})})]})]})}function yE(l){const[r,o]=f.useState(""),[i,c]=f.useState(!1),[d,m]=f.useState(null),[g,v]=f.useState([]),[h,b]=f.useState([]),y=async O=>{c(!0),m(null);try{const[z,N]=await Promise.all([K2(),J2({refresh:O?.refreshRemote})]);v(z.templates),b(N.templates)}catch(z){m(z instanceof Error?z.message:"Failed to load templates")}finally{c(!1)}};f.useEffect(()=>{y()},[]),f.useEffect(()=>{l.wsLocalTemplates&&v(l.wsLocalTemplates)},[l.wsLocalTemplates]),f.useEffect(()=>{l.wsRemoteTemplates&&b(l.wsRemoteTemplates)},[l.wsRemoteTemplates]);const E=f.useMemo(()=>{const O=r.trim().toLowerCase();return O?g.filter(z=>{const N=z.metadata;return N.id.toLowerCase().includes(O)||N.name.toLowerCase().includes(O)||N.provider.toLowerCase().includes(O)||N.event.toLowerCase().includes(O)||(N.description||"").toLowerCase().includes(O)}):g},[r,g]),R=f.useMemo(()=>{const O=r.trim().toLowerCase();return O?h.filter(z=>{const N=z.metadata;return N.id.toLowerCase().includes(O)||N.name.toLowerCase().includes(O)||N.provider.toLowerCase().includes(O)||N.event.toLowerCase().includes(O)||(N.description||"").toLowerCase().includes(O)}):h},[r,h]),C=async O=>{m(null);try{await MS(O),await y()}catch(z){m(z instanceof Error?z.message:"Download failed")}},M=async()=>{m(null),c(!0);try{await wS(),await y()}catch(O){m(O instanceof Error?O.message:"Download-all failed")}finally{c(!1)}};return x.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[x.jsxs(Qn,{children:[x.jsxs(Wn,{className:"border-b",children:[x.jsx(el,{children:"Templates"}),x.jsx(tl,{children:"Browse remote templates and download them locally."}),x.jsxs(lu,{className:"flex items-center gap-2",children:[x.jsxs(xn,{variant:"outline",size:"icon",onClick:()=>{y({refreshRemote:!0})},disabled:i,children:[x.jsx(ni,{}),x.jsx("span",{className:"sr-only",children:"Refresh remote"})]}),x.jsxs(xn,{variant:"default",onClick:()=>{M()},disabled:i,children:[x.jsx($f,{"data-icon":"inline-start"}),"Download all"]})]})]}),x.jsxs(nl,{className:"space-y-4",children:[x.jsx(oi,{children:x.jsxs(yn,{children:[x.jsx(bn,{htmlFor:"templates-search",children:"Search"}),x.jsx(Fr,{id:"templates-search",placeholder:"Search by id, provider, event...",value:r,onChange:O=>o(O.target.value)})]})}),d&&x.jsx("div",{className:"text-destructive text-xs",children:d}),x.jsx("div",{className:"border-border max-h-[calc(100vh-22rem)] overflow-auto border",children:R.length===0?x.jsx("div",{className:"text-muted-foreground p-4 text-xs",children:"No remote templates found."}):x.jsx("div",{className:"divide-border divide-y",children:R.map(O=>x.jsxs("div",{className:"p-3",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("div",{className:"text-sm font-medium",children:O.metadata.id}),x.jsx(Sn,{variant:"secondary",children:O.metadata.provider}),x.jsx("div",{className:"text-muted-foreground ml-auto",children:O.isDownloaded?x.jsx(Sn,{variant:"outline",children:"downloaded"}):x.jsx(Sn,{variant:"outline",children:"remote"})})]}),x.jsxs("div",{className:"text-muted-foreground mt-1 text-xs",children:[O.metadata.event," • ",O.metadata.name]}),O.metadata.description&&x.jsx("div",{className:"text-muted-foreground mt-1 text-xs",children:O.metadata.description}),x.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[x.jsxs(xn,{variant:"outline",size:"sm",onClick:()=>{C(O.metadata.id)},disabled:O.isDownloaded||i,children:[x.jsx($f,{"data-icon":"inline-start"}),"Download"]}),O.metadata.docsUrl&&x.jsx(xn,{variant:"ghost",size:"sm",render:x.jsx("a",{href:O.metadata.docsUrl,target:"_blank",rel:"noreferrer"}),children:"Docs"})]})]},O.metadata.id))})})]}),x.jsx(yd,{className:"text-muted-foreground",children:i?"Loading...":`Remote: ${R.length}`})]}),x.jsxs(Qn,{children:[x.jsxs(Wn,{className:"border-b",children:[x.jsx(el,{children:"Local templates"}),x.jsx(tl,{children:"Templates saved on your machine (downloaded from remote)."})]}),x.jsxs(nl,{className:"space-y-3",children:[x.jsx(n0,{}),x.jsx("div",{className:"border-border max-h-[calc(100vh-22rem)] overflow-auto border",children:E.length===0?x.jsx("div",{className:"text-muted-foreground p-4 text-xs",children:"No local templates yet. Download one from the left."}):x.jsx("div",{className:"divide-border divide-y",children:E.map(O=>x.jsxs("div",{className:"p-3",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("div",{className:"text-sm font-medium",children:O.id}),x.jsx(Sn,{variant:"secondary",children:O.metadata.provider}),x.jsx("div",{className:"text-muted-foreground ml-auto",children:O.metadata.event})]}),x.jsx("div",{className:"text-muted-foreground mt-1 text-xs",children:O.metadata.name}),O.metadata.description&&x.jsx("div",{className:"text-muted-foreground mt-1 text-xs",children:O.metadata.description})]},O.id))})})]}),x.jsxs(yd,{className:"text-muted-foreground",children:["Local: ",E.length]})]})]})}function bE(l){const r=new Set(l.local.map(i=>i.id)),o=[];for(const i of l.local)o.push({id:i.id,label:i.id,provider:i.metadata.provider,event:i.metadata.event,isDownloaded:!0});for(const i of l.remote)r.has(i.metadata.id)||o.push({id:`remote:${i.metadata.id}`,label:i.metadata.id,provider:i.metadata.provider,event:i.metadata.event,isDownloaded:!1});return o.sort((i,c)=>i.label.localeCompare(c.label))}function xE(){const[l,r]=f.useState([]),[o,i]=f.useState(""),[c,d]=f.useState("http://localhost:3000/webhooks"),[m,g]=f.useState(""),[v,h]=f.useState(""),[b,y]=f.useState(null),[E,R]=f.useState(null),[C,M]=f.useState(!1),[O,z]=f.useState(!1),N=async()=>{z(!0),R(null);try{const[A,B]=await Promise.all([K2(),J2({refresh:!1})]),U=bE({local:A.templates,remote:B.templates});r(U),!o&&U.length&&i(U[0].id)}catch(A){R(A instanceof Error?A.message:"Failed to load templates")}finally{z(!1)}};f.useEffect(()=>{N()},[]);const H=f.useMemo(()=>l.find(A=>A.id===o)||null,[l,o]),L=async()=>{M(!0),R(null),y(null);try{const A=fv(v),B=await CS({templateId:o,url:c,secret:m.trim()?m.trim():void 0,headers:A.length?A:void 0});y(B)}catch(A){R(A instanceof Error?A.message:"Run failed")}finally{M(!1)}};return x.jsxs("div",{className:"grid gap-4 lg:grid-cols-[1fr_minmax(320px,420px)]",children:[x.jsxs(Qn,{children:[x.jsxs(Wn,{className:"border-b",children:[x.jsx(el,{children:"Run template"}),x.jsx(tl,{children:"Send a webhook template to any URL. Remote templates can be run by selecting them (they’ll download automatically)."}),x.jsx(lu,{children:x.jsxs(xn,{variant:"outline",size:"icon",onClick:()=>{N()},disabled:O,children:[x.jsx(ni,{}),x.jsx("span",{className:"sr-only",children:"Refresh templates"})]})})]}),x.jsx(nl,{children:x.jsxs(oi,{children:[x.jsxs(yn,{children:[x.jsx(bn,{htmlFor:"run-template",children:"Template"}),x.jsxs(Ed,{value:o,onValueChange:A=>i(A??""),children:[x.jsx(Td,{id:"run-template",className:"w-full",children:x.jsx(Ad,{})}),x.jsx(Md,{children:x.jsxs(Rd,{children:[x.jsx(wd,{children:"Templates"}),l.map(A=>x.jsx(Cd,{value:A.id,children:A.label},A.id))]})})]}),H&&x.jsx(qa,{children:H.provider&&x.jsxs("span",{className:"inline-flex items-center gap-2",children:[x.jsx(Sn,{variant:"secondary",children:H.provider}),x.jsx("span",{className:"text-muted-foreground",children:H.event}),H.isDownloaded===!1&&x.jsx(Sn,{variant:"outline",children:"remote"})]})})]}),x.jsxs(yn,{children:[x.jsx(bn,{htmlFor:"run-url",children:"Target URL"}),x.jsx(Fr,{id:"run-url",value:c,onChange:A=>d(A.target.value)})]}),x.jsxs(yn,{children:[x.jsx(bn,{htmlFor:"run-secret",children:"Secret (optional)"}),x.jsx(Fr,{id:"run-secret",value:m,onChange:A=>g(A.target.value),placeholder:"If omitted, server will try provider env vars"})]}),x.jsxs(yn,{children:[x.jsx(bn,{htmlFor:"run-headers",children:"Headers (optional)"}),x.jsx(cv,{id:"run-headers",value:v,onChange:A=>h(A.target.value),placeholder:`X-Debug:true
23
- X-Request-Id: 123`}),x.jsx(qa,{children:"One header per line, format: key:value"})]}),E&&x.jsx("div",{className:"text-destructive text-xs",children:E}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsxs(xn,{onClick:()=>{L()},disabled:C||!o,children:[x.jsx(Nd,{"data-icon":"inline-start"}),C?"Sending...":"Send"]}),x.jsx(xn,{variant:"outline",onClick:()=>y(null),disabled:C,children:"Clear result"})]})]})})]}),x.jsxs(Qn,{children:[x.jsxs(Wn,{className:"border-b",children:[x.jsx(el,{children:"Result"}),x.jsx(tl,{children:b?`${b.status} ${b.statusText} • ${b.duration}ms`:"No result yet."})]}),x.jsx(nl,{className:"space-y-2",children:b?x.jsx("pre",{className:"bg-muted/40 border-border overflow-auto border p-3 text-xs",children:Gs(b.json??b.body)}):x.jsx("div",{className:"text-muted-foreground text-xs",children:"Select a template, set a target URL, and send it."})})]})]})}function SE(l){const r=f.useMemo(()=>`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`,[]);return x.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[x.jsxs(Qn,{children:[x.jsxs(Wn,{className:"border-b",children:[x.jsx(el,{children:"Connection"}),x.jsx(tl,{children:"Dashboard server status and endpoints."})]}),x.jsx(nl,{children:x.jsxs(oi,{children:[x.jsxs(yn,{children:[x.jsx(bn,{children:"API"}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(Sn,{variant:l.apiOk?"secondary":"outline",children:l.apiOk?"healthy":"unavailable"}),x.jsx("span",{className:"text-muted-foreground text-xs",children:"/api"})]})]}),x.jsxs(yn,{children:[x.jsx(bn,{children:"WebSocket"}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(Sn,{variant:l.wsOk?"secondary":"outline",children:l.wsOk?"connected":"disconnected"}),x.jsx("span",{className:"text-muted-foreground text-xs",children:r})]})]}),l.captureUrl&&x.jsxs(yn,{children:[x.jsx(bn,{children:"Capture server"}),x.jsxs("div",{className:"text-muted-foreground text-xs",children:["Send webhooks to: ",x.jsx("span",{className:"text-foreground",children:l.captureUrl})]})]})]})})]}),x.jsxs(Qn,{children:[x.jsxs(Wn,{className:"border-b",children:[x.jsx(el,{children:"Notes"}),x.jsx(tl,{children:"Helpful reminders for local webhook development."})]}),x.jsx(nl,{children:x.jsxs(oi,{children:[x.jsxs(yn,{children:[x.jsx(bn,{children:"Same-origin API"}),x.jsxs(qa,{children:["The dashboard UI uses relative paths (e.g. ",x.jsx("span",{className:"text-foreground",children:"/api/captures"}),") so it works when served from the CLI."]})]}),x.jsxs(yn,{children:[x.jsx(bn,{children:"Security"}),x.jsxs(qa,{children:["Keep the dashboard on ",x.jsx("span",{className:"text-foreground",children:"localhost"})," unless you trust your network. The API can send requests to arbitrary URLs (run/replay)."]})]}),x.jsxs(yn,{children:[x.jsx(bn,{children:"Default app target"}),x.jsx(Fr,{disabled:!0,value:"http://localhost:3000"}),x.jsxs(qa,{children:["Replay defaults to ",x.jsx("span",{className:"text-foreground",children:"localhost:3000"})," + captured path."]})]})]})})]})]})}function EE(){return`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`}function RE(l){const r=new WebSocket(EE());return r.onopen=()=>l.onOpen?.(),r.onclose=()=>l.onClose?.(),r.onerror=()=>l.onError?.(),r.onmessage=o=>{try{const i=JSON.parse(String(o.data));l.onMessage(i)}catch{}},r}function AE(){const[l,r]=f.useState("captures"),[o,i]=f.useState(!1),[c,d]=f.useState(!1),[m,g]=f.useState(void 0),[v,h]=f.useState(void 0),[b,y]=f.useState(void 0);return f.useEffect(()=>{xS().then(()=>i(!0)).catch(()=>i(!1))},[]),f.useEffect(()=>{const E=RE({onOpen:()=>d(!0),onClose:()=>d(!1),onError:()=>d(!1),onMessage:R=>{R.type==="captures_updated"&&g(R.payload.captures),R.type==="capture"&&g(C=>{const M=C?[...C]:[];return[{file:R.payload.file,capture:R.payload.capture},...M].slice(0,200)}),R.type==="templates_updated"&&(h(R.payload.local),y(R.payload.remote))}});return()=>E.close()},[]),x.jsx(hS,{defaultTheme:"system",storageKey:"vite-ui-theme",children:x.jsxs("div",{className:"min-h-dvh",children:[x.jsx("div",{className:"fixed right-4 top-4 z-50",children:x.jsx(gS,{})}),x.jsxs("div",{className:"mx-auto grid max-w-screen-2xl grid-cols-1 gap-4 p-4 lg:grid-cols-[220px_1fr]",children:[x.jsxs(Qn,{className:"h-fit",children:[x.jsxs("div",{className:"px-4",children:[x.jsxs("div",{className:"flex items-center justify-between pt-1",children:[x.jsx("div",{className:"text-sm font-medium",children:"better-webhook"}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(Sn,{variant:o?"secondary":"outline",children:"api"}),x.jsx(Sn,{variant:c?"secondary":"outline",children:"ws"})]})]}),x.jsx("div",{className:"text-muted-foreground text-xs",children:"Local dashboard"})]}),x.jsx(n0,{className:"mt-4"}),x.jsx("nav",{className:"flex flex-col gap-1 px-2 pt-2",children:bS.map(E=>x.jsxs(xn,{variant:l===E.key?"secondary":"ghost",className:"justify-start",onClick:()=>r(E.key),children:[E.icon,E.label]},E.key))}),x.jsxs("div",{className:"text-muted-foreground px-4 pt-3 pb-2 text-xs",children:["Run:"," ",x.jsx("span",{className:"text-foreground",children:"better-webhook dashboard"})]})]}),x.jsxs("div",{className:"min-w-0",children:[l==="captures"&&x.jsx(vE,{wsCaptures:m}),l==="templates"&&x.jsx(yE,{wsLocalTemplates:v,wsRemoteTemplates:b}),l==="run"&&x.jsx(xE,{}),l==="settings"&&x.jsx(SE,{apiOk:o,wsOk:c,captureUrl:"http://localhost:3001"})]})]})]})})}D4.createRoot(document.getElementById("root")).render(x.jsx(f.StrictMode,{children:x.jsx(AE,{})}));
23
+ X-Request-Id: 123`}),x.jsx(qa,{children:"One header per line, format: key:value"})]}),E&&x.jsx("div",{className:"text-destructive text-xs",children:E}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsxs(xn,{onClick:()=>{L()},disabled:C||!o,children:[x.jsx(Nd,{"data-icon":"inline-start"}),C?"Sending...":"Send"]}),x.jsx(xn,{variant:"outline",onClick:()=>y(null),disabled:C,children:"Clear result"})]})]})})]}),x.jsxs(Qn,{children:[x.jsxs(Wn,{className:"border-b",children:[x.jsx(el,{children:"Result"}),x.jsx(tl,{children:b?`${b.status} ${b.statusText} • ${b.duration}ms`:"No result yet."})]}),x.jsx(nl,{className:"space-y-2",children:b?x.jsx("pre",{className:"bg-muted/40 border-border overflow-auto border p-3 text-xs",children:Gs(b.json??b.body)}):x.jsx("div",{className:"text-muted-foreground text-xs",children:"Select a template, set a target URL, and send it."})})]})]})}function SE(l){const r=f.useMemo(()=>`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`,[]);return x.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[x.jsxs(Qn,{children:[x.jsxs(Wn,{className:"border-b",children:[x.jsx(el,{children:"Connection"}),x.jsx(tl,{children:"Dashboard server status and endpoints."})]}),x.jsx(nl,{children:x.jsxs(oi,{children:[x.jsxs(yn,{children:[x.jsx(bn,{children:"API"}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(Sn,{variant:l.apiOk?"secondary":"outline",children:l.apiOk?"healthy":"unavailable"}),x.jsx("span",{className:"text-muted-foreground text-xs",children:"/api"})]})]}),x.jsxs(yn,{children:[x.jsx(bn,{children:"WebSocket"}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(Sn,{variant:l.wsOk?"secondary":"outline",children:l.wsOk?"connected":"disconnected"}),x.jsx("span",{className:"text-muted-foreground text-xs",children:r})]})]}),l.captureUrl&&x.jsxs(yn,{children:[x.jsx(bn,{children:"Capture server"}),x.jsxs("div",{className:"text-muted-foreground text-xs",children:["Send webhooks to:"," ",x.jsx("span",{className:"text-foreground",children:l.captureUrl})]})]})]})})]}),x.jsxs(Qn,{children:[x.jsxs(Wn,{className:"border-b",children:[x.jsx(el,{children:"Notes"}),x.jsx(tl,{children:"Helpful reminders for local webhook development."})]}),x.jsx(nl,{children:x.jsxs(oi,{children:[x.jsxs(yn,{children:[x.jsx(bn,{children:"Same-origin API"}),x.jsxs(qa,{children:["The dashboard UI uses relative paths (e.g."," ",x.jsx("span",{className:"text-foreground",children:"/api/captures"}),") so it works when served from the CLI."]})]}),x.jsxs(yn,{children:[x.jsx(bn,{children:"Security"}),x.jsxs(qa,{children:["Keep the dashboard on"," ",x.jsx("span",{className:"text-foreground",children:"localhost"})," unless you trust your network. The API can send requests to arbitrary URLs (run/replay)."]})]}),x.jsxs(yn,{children:[x.jsx(bn,{children:"Default app target"}),x.jsx(Fr,{disabled:!0,value:"http://localhost:3000"}),x.jsxs(qa,{children:["Replay defaults to"," ",x.jsx("span",{className:"text-foreground",children:"localhost:3000"})," + captured path."]})]})]})})]})]})}function EE(){return`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`}function RE(l){const r=new WebSocket(EE());return r.onopen=()=>l.onOpen?.(),r.onclose=()=>l.onClose?.(),r.onerror=()=>l.onError?.(),r.onmessage=o=>{try{const i=JSON.parse(String(o.data));l.onMessage(i)}catch{}},r}function AE(){const[l,r]=f.useState("captures"),[o,i]=f.useState(!1),[c,d]=f.useState(!1),[m,g]=f.useState(void 0),[v,h]=f.useState(void 0),[b,y]=f.useState(void 0);return f.useEffect(()=>{xS().then(()=>i(!0)).catch(()=>i(!1))},[]),f.useEffect(()=>{const E=RE({onOpen:()=>d(!0),onClose:()=>d(!1),onError:()=>d(!1),onMessage:R=>{R.type==="captures_updated"&&g(R.payload.captures),R.type==="capture"&&g(C=>{const M=C?[...C]:[];return[{file:R.payload.file,capture:R.payload.capture},...M].slice(0,200)}),R.type==="templates_updated"&&(h(R.payload.local),y(R.payload.remote))}});return()=>E.close()},[]),x.jsx(hS,{defaultTheme:"system",storageKey:"vite-ui-theme",children:x.jsxs("div",{className:"min-h-dvh",children:[x.jsx("div",{className:"fixed right-4 top-4 z-50",children:x.jsx(gS,{})}),x.jsxs("div",{className:"mx-auto grid max-w-screen-2xl grid-cols-1 gap-4 p-4 lg:grid-cols-[220px_1fr]",children:[x.jsxs(Qn,{className:"h-fit",children:[x.jsxs("div",{className:"px-4",children:[x.jsxs("div",{className:"flex items-center justify-between pt-1",children:[x.jsx("div",{className:"text-sm font-medium",children:"better-webhook"}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(Sn,{variant:o?"secondary":"outline",children:"api"}),x.jsx(Sn,{variant:c?"secondary":"outline",children:"ws"})]})]}),x.jsx("div",{className:"text-muted-foreground text-xs",children:"Local dashboard"})]}),x.jsx(n0,{className:"mt-4"}),x.jsx("nav",{className:"flex flex-col gap-1 px-2 pt-2",children:bS.map(E=>x.jsxs(xn,{variant:l===E.key?"secondary":"ghost",className:"justify-start",onClick:()=>r(E.key),children:[E.icon,E.label]},E.key))}),x.jsxs("div",{className:"text-muted-foreground px-4 pt-3 pb-2 text-xs",children:["Run:"," ",x.jsx("span",{className:"text-foreground",children:"better-webhook dashboard"})]})]}),x.jsxs("div",{className:"min-w-0",children:[l==="captures"&&x.jsx(vE,{wsCaptures:m}),l==="templates"&&x.jsx(yE,{wsLocalTemplates:v,wsRemoteTemplates:b}),l==="run"&&x.jsx(xE,{}),l==="settings"&&x.jsx(SE,{apiOk:o,wsOk:c,captureUrl:"http://localhost:3001"})]})]})]})})}D4.createRoot(document.getElementById("root")).render(x.jsx(f.StrictMode,{children:x.jsx(AE,{})}));
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>better-webhook dashboard</title>
8
- <script type="module" crossorigin src="/assets/index-JTnjYuBA.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-Mir6leOJ.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index--Ns7zZwD.css">
10
10
  </head>
11
11
  <body>
package/dist/index.cjs CHANGED
@@ -865,15 +865,9 @@ function getProviderHeaders(provider, options) {
865
865
  break;
866
866
  case "ragie":
867
867
  headers.push(
868
- { key: "Content-Type", value: "application/json" },
869
- {
870
- key: "X-Ragie-Event",
871
- value: options?.event || "document_status_updated"
872
- },
873
- {
874
- key: "X-Ragie-Delivery",
875
- value: options?.webhookId || generateDeliveryId()
876
- }
868
+ { key: "Content-Type", value: "application/json" }
869
+ // Ragie signs requests with an `X-Signature` header.
870
+ // Event type + nonce are included in the JSON body envelope.
877
871
  );
878
872
  break;
879
873
  default:
@@ -1361,7 +1355,7 @@ var CaptureServer = class {
1361
1355
  body = rawBody;
1362
1356
  }
1363
1357
  }
1364
- const provider = this.detectProvider(req.headers);
1358
+ const provider = this.detectProvider(req.headers, body);
1365
1359
  const captured = {
1366
1360
  id,
1367
1361
  timestamp,
@@ -1417,15 +1411,17 @@ var CaptureServer = class {
1417
1411
  /**
1418
1412
  * Detect webhook provider from headers
1419
1413
  */
1420
- detectProvider(headers) {
1414
+ detectProvider(headers, body) {
1421
1415
  if (headers["stripe-signature"]) {
1422
1416
  return "stripe";
1423
1417
  }
1424
1418
  if (headers["x-github-event"] || headers["x-hub-signature-256"]) {
1425
1419
  return "github";
1426
1420
  }
1427
- if (headers["x-ragie-delivery"]) {
1428
- return "ragie";
1421
+ if (headers["x-signature"]) {
1422
+ if (body && typeof body === "object" && "type" in body && "payload" in body && "nonce" in body) {
1423
+ return "ragie";
1424
+ }
1429
1425
  }
1430
1426
  if (headers["x-shopify-hmac-sha256"] || headers["x-shopify-topic"]) {
1431
1427
  return "shopify";
@@ -2585,12 +2581,18 @@ var dashboard = new import_commander6.Command().name("dashboard").description("S
2585
2581
  console.log(import_chalk6.default.gray(` Dashboard: ${url}/`));
2586
2582
  console.log(import_chalk6.default.gray(` Health: ${url}/health`));
2587
2583
  console.log(import_chalk6.default.gray(` API Base: ${url}/api`));
2588
- console.log(import_chalk6.default.gray(` WebSocket: ${url.replace("http://", "ws://")}/ws`));
2584
+ console.log(
2585
+ import_chalk6.default.gray(` WebSocket: ${url.replace("http://", "ws://")}/ws`)
2586
+ );
2589
2587
  if (capture2) {
2590
2588
  console.log();
2591
2589
  console.log(import_chalk6.default.bold("\u{1F3A3} Capture Server"));
2592
2590
  console.log(import_chalk6.default.gray(` Capture: ${capture2.url}`));
2593
- console.log(import_chalk6.default.gray(` Tip: Send webhooks to any path, e.g. ${capture2.url}/webhooks/github`));
2591
+ console.log(
2592
+ import_chalk6.default.gray(
2593
+ ` Tip: Send webhooks to any path, e.g. ${capture2.url}/webhooks/github`
2594
+ )
2595
+ );
2594
2596
  }
2595
2597
  console.log();
2596
2598
  const shutdown = async () => {
@@ -2603,7 +2605,11 @@ var dashboard = new import_commander6.Command().name("dashboard").description("S
2603
2605
  process.on("SIGINT", shutdown);
2604
2606
  process.on("SIGTERM", shutdown);
2605
2607
  } catch (error) {
2606
- console.error(import_chalk6.default.red(`Failed to start dashboard server: ${error?.message || error}`));
2608
+ console.error(
2609
+ import_chalk6.default.red(
2610
+ `Failed to start dashboard server: ${error?.message || error}`
2611
+ )
2612
+ );
2607
2613
  process.exitCode = 1;
2608
2614
  }
2609
2615
  });
package/dist/index.js CHANGED
@@ -850,15 +850,9 @@ function getProviderHeaders(provider, options) {
850
850
  break;
851
851
  case "ragie":
852
852
  headers.push(
853
- { key: "Content-Type", value: "application/json" },
854
- {
855
- key: "X-Ragie-Event",
856
- value: options?.event || "document_status_updated"
857
- },
858
- {
859
- key: "X-Ragie-Delivery",
860
- value: options?.webhookId || generateDeliveryId()
861
- }
853
+ { key: "Content-Type", value: "application/json" }
854
+ // Ragie signs requests with an `X-Signature` header.
855
+ // Event type + nonce are included in the JSON body envelope.
862
856
  );
863
857
  break;
864
858
  default:
@@ -1355,7 +1349,7 @@ var CaptureServer = class {
1355
1349
  body = rawBody;
1356
1350
  }
1357
1351
  }
1358
- const provider = this.detectProvider(req.headers);
1352
+ const provider = this.detectProvider(req.headers, body);
1359
1353
  const captured = {
1360
1354
  id,
1361
1355
  timestamp,
@@ -1411,15 +1405,17 @@ var CaptureServer = class {
1411
1405
  /**
1412
1406
  * Detect webhook provider from headers
1413
1407
  */
1414
- detectProvider(headers) {
1408
+ detectProvider(headers, body) {
1415
1409
  if (headers["stripe-signature"]) {
1416
1410
  return "stripe";
1417
1411
  }
1418
1412
  if (headers["x-github-event"] || headers["x-hub-signature-256"]) {
1419
1413
  return "github";
1420
1414
  }
1421
- if (headers["x-ragie-delivery"]) {
1422
- return "ragie";
1415
+ if (headers["x-signature"]) {
1416
+ if (body && typeof body === "object" && "type" in body && "payload" in body && "nonce" in body) {
1417
+ return "ragie";
1418
+ }
1423
1419
  }
1424
1420
  if (headers["x-shopify-hmac-sha256"] || headers["x-shopify-topic"]) {
1425
1421
  return "shopify";
@@ -2578,12 +2574,18 @@ var dashboard = new Command6().name("dashboard").description("Start the local da
2578
2574
  console.log(chalk6.gray(` Dashboard: ${url}/`));
2579
2575
  console.log(chalk6.gray(` Health: ${url}/health`));
2580
2576
  console.log(chalk6.gray(` API Base: ${url}/api`));
2581
- console.log(chalk6.gray(` WebSocket: ${url.replace("http://", "ws://")}/ws`));
2577
+ console.log(
2578
+ chalk6.gray(` WebSocket: ${url.replace("http://", "ws://")}/ws`)
2579
+ );
2582
2580
  if (capture2) {
2583
2581
  console.log();
2584
2582
  console.log(chalk6.bold("\u{1F3A3} Capture Server"));
2585
2583
  console.log(chalk6.gray(` Capture: ${capture2.url}`));
2586
- console.log(chalk6.gray(` Tip: Send webhooks to any path, e.g. ${capture2.url}/webhooks/github`));
2584
+ console.log(
2585
+ chalk6.gray(
2586
+ ` Tip: Send webhooks to any path, e.g. ${capture2.url}/webhooks/github`
2587
+ )
2588
+ );
2587
2589
  }
2588
2590
  console.log();
2589
2591
  const shutdown = async () => {
@@ -2596,7 +2598,11 @@ var dashboard = new Command6().name("dashboard").description("Start the local da
2596
2598
  process.on("SIGINT", shutdown);
2597
2599
  process.on("SIGTERM", shutdown);
2598
2600
  } catch (error) {
2599
- console.error(chalk6.red(`Failed to start dashboard server: ${error?.message || error}`));
2601
+ console.error(
2602
+ chalk6.red(
2603
+ `Failed to start dashboard server: ${error?.message || error}`
2604
+ )
2605
+ );
2600
2606
  process.exitCode = 1;
2601
2607
  }
2602
2608
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-webhook/cli",
3
- "version": "3.4.1",
3
+ "version": "3.4.2",
4
4
  "description": "Modern CLI for developing, capturing, and replaying webhooks locally with dashboard UI.",
5
5
  "type": "module",
6
6
  "bin": {