@buoy-gg/route-events 7.0.78 → 7.0.79
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.RouteEventsTimeline=RouteEventsTimeline;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _RouteEventItemCompact=require("./RouteEventItemCompact");var _jsxRuntime=require("react/jsx-runtime");function RouteEventsTimeline({events:r,visitCounts:i,onNavigate:n,onSelectEvent:o}){const a=(0,_react.useCallback)(e=>{const t=r[e];if(!t)return;o(t,i.get(t)||1)},[r,i,o]);if(r.length===0){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.emptyState,testID:"buoy-routes-empty",children:[(0,_jsxRuntime.jsx)(_sharedUi.Navigation,{size:48,color:_sharedUi.night.color.textTertiary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyTitle,testID:"buoy-routes-empty-title",children:"No events yet"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptySubtitle,testID:"buoy-routes-empty-subtitle",children:"Navigation events will appear here"})]})}return(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",testID:"buoy-routes-timeline",contentContainerStyle:styles.listContent,data:r,keyExtractor:e=>`${e.timestamp}-${e.pathname}`,renderItem:({item:e,index:t})=>(0,_jsxRuntime.jsx)(_RouteEventItemCompact.RouteEventItemCompact,{event:e,visitNumber:i.get(e)||1,isExpanded:false,index:t,onPress:a,onNavigate:n}),showsVerticalScrollIndicator:true,..._sharedUi.EVENT_LIST_PRESET})}const styles=_reactNative.StyleSheet.create({listContent:{paddingVertical:8},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:_sharedUi.night.color.text,fontSize:16,fontWeight:"600",marginTop:16,marginBottom:8,fontFamily:_sharedUi.monoFont,letterSpacing:.5,textTransform:"uppercase"},emptySubtitle:{color:_sharedUi.night.color.textSecondary,fontSize:14,textAlign:"center",fontFamily:_sharedUi.monoFont}});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.RouteEventsTimeline=RouteEventsTimeline;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _RouteEventItemCompact=require("./RouteEventItemCompact");var _jsxRuntime=require("react/jsx-runtime");function RouteEventsTimeline({events:r,visitCounts:i,onNavigate:n,onSelectEvent:o}){const a=(0,_react.useCallback)(e=>{const t=r[e];if(!t)return;_reactNative.Keyboard.dismiss();o(t,i.get(t)||1)},[r,i,o]);if(r.length===0){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.emptyState,testID:"buoy-routes-empty",children:[(0,_jsxRuntime.jsx)(_sharedUi.Navigation,{size:48,color:_sharedUi.night.color.textTertiary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyTitle,testID:"buoy-routes-empty-title",children:"No events yet"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptySubtitle,testID:"buoy-routes-empty-subtitle",children:"Navigation events will appear here"})]})}return(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",testID:"buoy-routes-timeline",contentContainerStyle:styles.listContent,data:r,keyExtractor:e=>`${e.timestamp}-${e.pathname}`,renderItem:({item:e,index:t})=>(0,_jsxRuntime.jsx)(_RouteEventItemCompact.RouteEventItemCompact,{event:e,visitNumber:i.get(e)||1,isExpanded:false,index:t,onPress:a,onNavigate:n}),showsVerticalScrollIndicator:true,..._sharedUi.EVENT_LIST_PRESET})}const styles=_reactNative.StyleSheet.create({listContent:{paddingVertical:8},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:_sharedUi.night.color.text,fontSize:16,fontWeight:"600",marginTop:16,marginBottom:8,fontFamily:_sharedUi.monoFont,letterSpacing:.5,textTransform:"uppercase"},emptySubtitle:{color:_sharedUi.night.color.textSecondary,fontSize:14,textAlign:"center",fontFamily:_sharedUi.monoFont}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useCallback as y}from"react";import{View as u,Text as l,FlatList as d,StyleSheet as f}from"react-native";import{Navigation as
|
|
1
|
+
"use strict";import{useCallback as y}from"react";import{View as u,Text as l,FlatList as d,StyleSheet as f,Keyboard as g}from"react-native";import{Navigation as x,night as s,EVENT_LIST_PRESET as S,monoFont as m}from"@buoy-gg/shared-ui";import{RouteEventItemCompact as h}from"./RouteEventItemCompact";import{jsx as o,jsxs as b}from"react/jsx-runtime";export function RouteEventsTimeline({events:r,visitCounts:n,onNavigate:c,onSelectEvent:a}){const p=y(t=>{const e=r[t];if(!e)return;g.dismiss();a(e,n.get(e)||1)},[r,n,a]);if(r.length===0){return b(u,{style:i.emptyState,testID:"buoy-routes-empty",children:[o(x,{size:48,color:s.color.textTertiary}),o(l,{style:i.emptyTitle,testID:"buoy-routes-empty-title",children:"No events yet"}),o(l,{style:i.emptySubtitle,testID:"buoy-routes-empty-subtitle",children:"Navigation events will appear here"})]})}return o(d,{keyboardShouldPersistTaps:"handled",testID:"buoy-routes-timeline",contentContainerStyle:i.listContent,data:r,keyExtractor:t=>`${t.timestamp}-${t.pathname}`,renderItem:({item:t,index:e})=>o(h,{event:t,visitNumber:n.get(t)||1,isExpanded:false,index:e,onPress:p,onNavigate:c}),showsVerticalScrollIndicator:true,...S})}const i=f.create({listContent:{paddingVertical:8},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:s.color.text,fontSize:16,fontWeight:"600",marginTop:16,marginBottom:8,fontFamily:m,letterSpacing:.5,textTransform:"uppercase"},emptySubtitle:{color:s.color.textSecondary,fontSize:14,textAlign:"center",fontFamily:m}});
|
package/lib/web/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use client";var Nt=Object.defineProperty;var $o=Object.getOwnPropertyDescriptor;var Ao=Object.getOwnPropertyNames;var Fo=Object.prototype.hasOwnProperty;var No=(e,t)=>{for(var o in t)Nt(e,o,{get:t[o],enumerable:true})},zt=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ao(t))!Fo.call(e,a)&&a!==o&&Nt(e,a,{get:()=>t[a],enumerable:!(r=$o(t,a))||r.enumerable});return e},zo=(e,t,o)=>(zt(e,t,"default"),o&&zt(o,t,"default"));var qn=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{RoutesIcon as Wo}from"@buoy-gg/floating-tools-core/web";import{useState as ke,useCallback as he,useEffect as Wt,useRef as Oo,useMemo as Ie}from"react";var Ot={};No(Ot,{AccessibilityInfo:()=>Mo,ActivityIndicator:()=>Mr,Alert:()=>_,Animated:()=>zr,AppRegistry:()=>Ko,AppState:()=>_o,Appearance:()=>Uo,BackHandler:()=>Go,Button:()=>Ur,CheckBox:()=>lr,Clipboard:()=>Jo,DeviceEventEmitter:()=>Cr,Dimensions:()=>qo,Easing:()=>Yo,FlatList:()=>jt,I18nManager:()=>Zo,Image:()=>cr,ImageBackground:()=>ur,InteractionManager:()=>Xo,Keyboard:()=>Qo,KeyboardAvoidingView:()=>dr,LayoutAnimation:()=>er,Linking:()=>tr,LogBox:()=>wr,Modal:()=>Hr,NativeEventEmitter:()=>or,NativeModules:()=>Vo,PanResponder:()=>rr,Picker:()=>pr,PixelRatio:()=>ar,Platform:()=>ct,Pressable:()=>jr,ProgressBar:()=>hr,RefreshControl:()=>mr,SafeAreaView:()=>fr,ScrollView:()=>qe,SectionList:()=>gr,Share:()=>nr,StatusBar:()=>yr,StyleSheet:()=>ve,Switch:()=>Vr,Text:()=>p,TextInput:()=>Kt,Touchable:()=>br,TouchableHighlight:()=>Wr,TouchableNativeFeedback:()=>vr,TouchableOpacity:()=>V,TouchableWithoutFeedback:()=>Or,UIManager:()=>ir,Vibration:()=>sr,View:()=>c,VirtualizedList:()=>xr,YellowBox:()=>Sr,findNodeHandle:()=>Kr,unstable_createElement:()=>Ho,useColorScheme:()=>Tr,useLocaleContext:()=>Rr,useWindowDimensions:()=>kr});zo(Ot,jo);import*as jo from"react-native-web";import{unstable_createElement as Ho,NativeModules as Vo,AccessibilityInfo as Mo,Appearance as Uo,AppRegistry as Ko,AppState as _o,BackHandler as Go,Clipboard as Jo,Dimensions as qo,Easing as Yo,I18nManager as Zo,Keyboard as Qo,InteractionManager as Xo,LayoutAnimation as er,Linking as tr,NativeEventEmitter as or,PanResponder as rr,PixelRatio as ar,Platform as ct,Share as nr,UIManager as ir,Vibration as sr,CheckBox as lr,FlatList as jt,Image as cr,ImageBackground as ur,KeyboardAvoidingView as dr,Picker as pr,ProgressBar as hr,RefreshControl as mr,SafeAreaView as fr,SectionList as gr,StatusBar as yr,Touchable as br,TouchableNativeFeedback as vr,VirtualizedList as xr,YellowBox as Sr,LogBox as wr,DeviceEventEmitter as Cr,useColorScheme as Tr,useLocaleContext as Rr,useWindowDimensions as kr}from"react-native-web";import*as oe from"react-native-web";import{createElement as ut,forwardRef as Ht,useCallback as Ir,useRef as Br}from"react";import{useEffect as Er,useState as Dr}from"react";import{createPortal as Pr}from"react-dom";var Lr='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as $r}from"react/jsx-runtime";var ze=Symbol.for("@buoy-gg/portal-host"),Vt=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function Mt(){let e=document;if(e[ze])return e[ze].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:Lr});let o=()=>{let l=document.fullscreenElement,m=l&&l.tagName!=="CANVAS"?l:document.body;t.parentElement!==m&&m.appendChild(t)},r=new Map,a=l=>{(!t.contains(l.target)||!Vt(l.target))&&r.set(l.code||l.key,{key:l.key,code:l.code,location:l.location,keyCode:l.keyCode,which:l.which,altKey:l.altKey,ctrlKey:l.ctrlKey,metaKey:l.metaKey,shiftKey:l.shiftKey})},n=l=>{r.delete(l.code||l.key)},i=()=>r.clear(),d=()=>{let l=[...r.values()];r.clear();for(let m of l)document.dispatchEvent(new KeyboardEvent("keyup",{...m,bubbles:true}))},s=l=>{Vt(l.target)&&l.stopPropagation()},f=l=>l.stopPropagation();return o(),document.addEventListener("fullscreenchange",o),document.addEventListener("keydown",a,true),document.addEventListener("keyup",n,true),window.addEventListener("blur",i),t.addEventListener("focusin",d),t.addEventListener("keydown",s),t.addEventListener("keyup",s),t.addEventListener("keypress",s),t.addEventListener("wheel",f,{passive:true}),e[ze]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",o),document.removeEventListener("keydown",a,true),document.removeEventListener("keyup",n,true),window.removeEventListener("blur",i),t.remove(),delete e[ze]}},t}function Ar({children:e}){let[t,o]=Dr(null);return Er(()=>{let r=Mt(),a=document[ze];return a.users++,o(r),()=>{--a.users===0&&a.dispose()}},[]),t?Pr($r("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var Be=oe,Fr=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],Ee=e=>typeof e=="number"?`${e}px`:e;function dt(e){if(Array.isArray(e)){let m=e.map(dt);return m.some((R,F)=>R!==e[F])?m:e}if(!e||typeof e!="object"||!Fr.some(m=>e[m]!=null))return e;let{shadowColor:t,shadowOffset:o,shadowOpacity:r,shadowRadius:a,textShadowColor:n,textShadowOffset:i,textShadowRadius:d,...s}=e;if(t!=null||o!=null||r!=null||a!=null){let m=t??"black",R=r==null?m:`color-mix(in srgb, ${m} ${Math.min(r,1)*100}%, transparent)`,F=`${Ee(o?.width??0)} ${Ee(o?.height??0)} ${Ee(a??0)} ${R}`;s.boxShadow=typeof s.boxShadow=="string"?`${s.boxShadow}, ${F}`:s.boxShadow??F}let{width:f=0,height:l=0}=i??{};if(n&&(f||l||d)){let m=`${Ee(f)} ${Ee(l)} ${Ee(d??0)} ${n}`;s.textShadow=s.textShadow?`${s.textShadow}, ${m}`:m}return s}var Nr=Be.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function Ut(e,t){if(typeof e=="function")return r=>Ut(e(r),t);let o=dt(e);return t?[o,Nr[t]]:o}var ve={...Be.StyleSheet,create:e=>Be.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,o])=>[t,dt(o)])))};function ne(e){let t=Ht((r,a)=>{let{accessibilityState:n,accessibilityValue:i,pointerEvents:d,...s}=r;for(let l of["busy","checked","disabled","expanded","selected"])n?.[l]!==void 0&&s[`aria-${l}`]===void 0&&(s[`aria-${l}`]=n[l]);for(let[l,m]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))i?.[l]!==void 0&&s[`aria-${m}`]===void 0&&(s[`aria-${m}`]=i[l]);let f=Ut(s.style,d);return f!==s.style&&(s.style=f),ut(e,{...s,ref:a})}),o=e.State;return o&&Object.assign(t,{State:o}),t.displayName=e.displayName??e.name??"NativeWebView",t}var c=ne(oe.View),p=ne(oe.Text),zr={...Be.Animated,View:Be.Animated.createAnimatedComponent(c),Text:Be.Animated.createAnimatedComponent(p)},Kt=ne(oe.TextInput),V=ne(oe.TouchableOpacity),Wr=ne(oe.TouchableHighlight),Or=ne(oe.TouchableWithoutFeedback),jr=ne(oe.Pressable),qe=ne(oe.ScrollView),_t=Ht((e,t)=>{let o=Br(null),r=Ir(a=>{if(a){let n=a;for(;n.parentElement&&n.parentElement!==document.body;)n=n.parentElement;n.parentElement===document.body&&(o.current=n,Object.assign(n.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),Mt().appendChild(n))}else o.current&&(document.body.appendChild(o.current),o.current=null);typeof t=="function"?t(a):t&&(t.current=a)},[t]);return ut(Ar,null,ut(oe.Modal,{...e,ref:r}))});_t.displayName="Modal";var Hr=ne(_t),Vr=ne(oe.Switch),Mr=ne(oe.ActivityIndicator),Ur=ne(oe.Button),Kr=oe.findNodeHandle,_={alert(e,t,o,r){if(typeof document>"u")return;let a=document.createElement("dialog");a.dataset.buoyRoot="",a.setAttribute("aria-label",e),a.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let n=document.createElement("h2");if(n.textContent=e,n.style.cssText="font-size:18px;margin:0 0 12px",a.appendChild(n),t){let f=document.createElement("p");f.textContent=t,f.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",a.appendChild(f)}let i=document.createElement("div");i.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let d=o?.length?o:[{text:"OK"}],s=()=>{a.close?.(),a.remove()};for(let f of d){let l=document.createElement("button");l.type="button",l.textContent=f.text??"OK",l.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${f.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,l.onclick=()=>{s(),f.onPress?.()},i.appendChild(l)}a.addEventListener("cancel",f=>{f.preventDefault(),r?.cancelable!==false&&(s(),r?.onDismiss?.())}),a.appendChild(i),document.body.appendChild(a),a.showModal?a.showModal():a.setAttribute("open","")}};import{browserRouter as ai}from"@buoy-gg/shared-ui/web/utils";function _r(){return null}import{useSafeRouter as Gr,isExpoRouterAvailable as Jr,windowDragProps as qr,ToolEmptyState as Yr,resolveListEmptyState as Zr,usePersistedState as pt,monoFont as Ye}from"@buoy-gg/shared-ui/web";import{JsModal as Qr,ModalHeader as le,TabSelector as Xr,formatRelativeTime as ea,devToolsStorageKeys as We,Trash2 as ta,Filter as oa,SearchBar as Gt,ToolbarCopyButton as ht,Lock as ra,ProUpgradeModal as aa,PowerToggleButton as na,buoyColors as ia,night as Z,TickProvider as Jt,useLimit as sa}from"@buoy-gg/shared-ui/web";import{useIsPro as la}from"@buoy-gg/license/web";import{useEventStoreEvents as ca}from"@buoy-gg/shared-ui/web";import{BaseEventStore as ua,devToolsStorageKeys as da,persistentStorage as pa}from"@buoy-gg/shared-ui/web";var qt=class{constructor(){this.listeners=new Set}emit(e){this.listeners.forEach(t=>{try{t(e)}catch(o){console.error("[Buoy]","[RouteObserver] Error in listener:",o)}})}addListener(e){return this.listeners.add(e),()=>this.listeners.delete(e)}removeListener(e){this.listeners.delete(e)}},De=new qt;var ha=class extends ua{constructor(){super({storeName:"route-events",maxEvents:500});this.routeObserverUnsubscribe=null;this.bootCaptureRelease=null;this.bootCaptureHydrated=false;this.lastUnrecorded=null;this.everCaptured=false;let e=De.addListener(t=>{if(this.everCaptured){e();return}this.lastUnrecorded=t})}setBootCapture(e){e&&!this.bootCaptureRelease?this.bootCaptureRelease=this.subscribeToEvents(()=>{}):!e&&this.bootCaptureRelease&&(this.bootCaptureRelease(),this.bootCaptureRelease=null)}hydrateBootCapture(){if(this.bootCaptureHydrated)return;this.bootCaptureHydrated=true;let e=this.bootCaptureRelease!==null,t=this.getEventCount();e||this.setBootCapture(true);let o=this.bootCaptureRelease;pa.getItem(da.routeEvents.isMonitoring()).then(r=>{if(e||this.bootCaptureRelease!==o||r!=="false")return;this.setBootCapture(false);let a=this.getEventCount()-t;a>0&&this.replaceEvents(this.getEvents().slice(a))}).catch(()=>{})}startCapturing(){if(!this.routeObserverUnsubscribe){this.routeObserverUnsubscribe=De.addListener(t=>{this.addEvent(t)});let e=this.everCaptured?null:this.lastUnrecorded;this.everCaptured=true,this.lastUnrecorded=null,e&&this.getEventCount()===0&&this.addEvent(e)}}stopCapturing(){this.routeObserverUnsubscribe&&(this.routeObserverUnsubscribe(),this.routeObserverUnsubscribe=null)}isCapturing(){return this.routeObserverUnsubscribe!==null}isListening(){return this.isCapturing()}},me=new ha;function Yt(e={}){let{maxEvents:t=500,enabled:o=true}=e,{events:r,clearEvents:a,isActive:n}=ca(me,{maxEvents:t,enabled:o});return{events:r,clearEvents:a,isListening:n}}import{Navigation as ma,night as Ze,monoFont as fa}from"@buoy-gg/shared-ui/web";import{InlineCopyButton as Oe,night as mt,monoFont as ft}from"@buoy-gg/shared-ui/web";import{DataViewer as ga}from"@buoy-gg/shared-ui/web/dataViewer";import{jsx as z,jsxs as G}from"react/jsx-runtime";function ya(e){if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/6e4),o=(e%6e4/1e3).toFixed(0);return`${t}m ${o}s`}function gt({event:e,visitNumber:t,routeTemplate:o}){let r=e.params&&Object.keys(e.params).length>0;return G(c,{style:T.container,children:[G(c,{style:T.section,children:[e.routeName&&G(c,{style:T.detailRow,children:[z(p,{style:T.detailLabel,children:"Name:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-name",children:e.routeName})]}),e.matchedPath&&G(c,{style:T.detailRow,children:[z(p,{style:T.detailLabel,children:"Match:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-match",children:e.matchedPath})]}),o&&G(c,{style:T.detailRow,testID:"buoy-routes-detail-template",children:[z(p,{style:T.detailLabel,children:"Template:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-template-value",children:o}),z(Oe,{value:o,buttonStyle:T.copyButton})]}),e.previousPathname&&G(c,{style:T.detailRow,testID:"buoy-routes-detail-from",children:[z(p,{style:T.detailLabel,children:"From:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-from-value",children:e.previousPathname}),z(Oe,{value:e.previousPathname,buttonStyle:T.copyButton})]}),G(c,{style:T.detailRow,testID:"buoy-routes-detail-to",children:[z(p,{style:T.detailLabel,children:"To:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-to-value",children:e.pathname}),z(Oe,{value:e.pathname,buttonStyle:T.copyButton})]})]}),G(c,{style:T.section,children:[e.timeSincePrevious!==void 0&&G(c,{style:T.detailRow,testID:"buoy-routes-detail-duration",children:[z(p,{style:T.detailLabel,children:"Duration:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-duration-value",children:ya(e.timeSincePrevious)})]}),G(c,{style:T.detailRow,testID:"buoy-routes-detail-time",children:[z(p,{style:T.detailLabel,children:"Time:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-time-value",children:new Date(e.timestamp).toLocaleString()})]})]}),G(c,{style:T.section,children:[e.segments&&e.segments.length>0&&G(c,{style:T.detailRow,testID:"buoy-routes-detail-segments",children:[z(p,{style:T.detailLabel,children:"Segments:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-segments-value",children:e.segments.join(" \u2192 ")}),z(Oe,{value:JSON.stringify(e.segments),buttonStyle:T.copyButton})]}),r&&G(c,{style:T.dataViewerContainer,children:[G(c,{style:T.dataViewerHeader,children:[G(p,{style:T.dataViewerTitle,testID:"buoy-routes-detail-params-title",children:["Parameters (",Object.keys(e.params).length,")"]}),z(Oe,{value:JSON.stringify(e.params,null,2),buttonStyle:T.copyButton})]}),z(ga,{data:e.params,title:"",showTypeFilter:true,rawMode:true,initialExpanded:true})]}),t>1&&G(c,{style:T.detailRow,testID:"buoy-routes-detail-visited",children:[z(p,{style:T.detailLabel,children:"Visited:"}),G(p,{style:T.detailValue,testID:"buoy-routes-detail-visited-value",children:[t," time",t!==1?"s":""]})]})]})]})}var T=ve.create({container:{gap:12},section:{gap:8},detailRow:{flexDirection:"row",alignItems:"center",gap:8},detailLabel:{fontSize:10,color:mt.color.textSecondary,fontFamily:ft,fontWeight:"600",minWidth:70},detailValue:{fontSize:11,color:mt.color.text,fontFamily:ft,flex:1},copyButton:{padding:4,borderRadius:4},dataViewerContainer:{marginTop:4},dataViewerHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},dataViewerTitle:{fontSize:11,color:mt.color.textSecondary,fontFamily:ft,fontWeight:"600"}});function yt(e,t){if(!t||t.length===0)return null;let o="/"+t.map(r=>/^\d+$/.test(r)||/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)?"[id]":r).join("/");return o!==e?o:null}function Zt(e,t){if(!t)return e;let o=new Set(e.split("/").filter(Boolean).map(a=>{try{return decodeURIComponent(a)}catch{return a}})),r=[];for(let[a,n]of Object.entries(t)){let i=Array.isArray(n)?n:[n];if(!(i.length>0&&i.every(d=>o.has(String(d)))))for(let d of i)r.push(`${encodeURIComponent(a)}=${encodeURIComponent(String(d))}`)}return r.length?`${e}?${r.join("&")}`:e}function ba(e){let t=e.indexOf("?");if(t<0)return{pathname:e,params:{}};let o={};for(let r of e.slice(t+1).split("&")){if(!r)continue;let[a,n=""]=r.split("=");try{o[decodeURIComponent(a)]=decodeURIComponent(n)}catch{o[a]=n}}return{pathname:e.slice(0,t),params:o}}import{jsx as je,jsxs as Qt}from"react/jsx-runtime";function Xt({event:e,visitNumber:t=1,onNavigate:o}){let r=yt(e.pathname,e.segments);return Qt(c,{style:Pe.container,children:[je(qe,{keyboardShouldPersistTaps:"handled",testID:"buoy-routes-detail-scroll",style:Pe.scroll,contentContainerStyle:Pe.scrollContent,showsVerticalScrollIndicator:true,children:je(gt,{event:e,visitNumber:t,routeTemplate:r})}),o&&je(c,{style:Pe.footer,children:Qt(V,{style:Pe.goButton,onPress:()=>o(Zt(e.pathname,e.params)),activeOpacity:.8,testID:"buoy-routes-detail-go",accessibilityRole:"button",accessibilityLabel:`Go to route ${e.pathname}`,children:[je(ma,{size:16,color:Ze.color.onAccent}),je(p,{style:Pe.goButtonText,children:"Go to route"})]})})]})}var Pe=ve.create({container:{flex:1,backgroundColor:"transparent"},scroll:{flex:1},scrollContent:{padding:14},footer:{paddingHorizontal:16,paddingVertical:12,backgroundColor:"transparent",borderTopWidth:1,borderTopColor:Ze.color.border},goButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,backgroundColor:Ze.color.accent,paddingVertical:12,borderRadius:8},goButtonText:{fontSize:13,fontWeight:"600",color:Ze.color.onAccent,fontFamily:fa,textTransform:"uppercase",letterSpacing:.5}});import{Filter as eo,DynamicFilterView as va}from"@buoy-gg/shared-ui/web";import{jsx as xa}from"react/jsx-runtime";function Sa({ignoredPatterns:e,onTogglePattern:t,onAddPattern:o,availablePathnames:r=[]}){return xa(va,{...{addFilterSection:{enabled:true,placeholder:"Enter pattern (e.g., /_sitemap)",title:"ACTIVE FILTERS",icon:eo},availableItemsSection:{enabled:true,title:"AVAILABLE ROUTES FROM EVENTS",emptyMessage:"No routes available. Routes from navigation events will appear here.",items:r},howItWorksSection:{enabled:true,title:"HOW FILTERS WORK",description:"Filtered routes will not appear in the route events list. Patterns match if the route contains the specified text.",examples:["\u2022 /_sitemap \u2192 filters /_sitemap routes","\u2022 /api \u2192 filters /api/users, /api/posts","\u2022 [id] \u2192 filters all routes with [id] param"],icon:eo},onPatternToggle:t,onPatternAdd:o,activePatterns:e}})}import{useState as Le,useCallback as He,useMemo as Qe,useEffect as wa}from"react";import{night as v,ToolEmptyState as Ca,monoFont as Q}from"@buoy-gg/shared-ui/web";import{isCapacitorNative as Ta}from"@buoy-gg/license/web";import{useSafeRouter as Ra}from"@buoy-gg/shared-ui/web";import{Search as to,ChevronDown as oo,ChevronRight as ro,Home as ka,InlineCopyButton as Ia,CopyButton as Ba,RefreshCw as Ea,formatRelativeTime as Da,ProUpgradeModal as Pa}from"@buoy-gg/shared-ui/web";import{useIsPro as La}from"@buoy-gg/license/web";import{useState as $a,useEffect as ao,useMemo as Se,useCallback as Aa}from"react";var ye=class{static parseRouteTree(e){if(!e)return[];let t=[];return this.traverseNode(e,"",t,0),t}static traverseNode(e,t,o,r){let a=this.buildPath(e,t),n=this.detectRouteType(e),i=this.shouldIncludeRoute(e),d={path:a,name:e.route,type:n,params:this.extractParams(e),nodeType:e.type,contextKey:e.contextKey,isInternal:e.internal??false,children:[],depth:r};i&&o.push(d);for(let s of e.children)this.traverseNode(s,a,i?d.children:o,r+1)}static buildPath(e,t){if(e.type==="layout"&&e.route==="_layout"||e.route.startsWith("(")&&e.route.endsWith(")"))return t;if(e.route==="index")return t||"/";let o=e.route;return!t||t==="/"?`/${o}`:`${t}/${o}`}static detectRouteType(e){let t=e.route;return e.dynamic?.some(o=>o.notFound)?"not-found":e.dynamic?.some(o=>o.deep)?"catch-all":e.dynamic&&e.dynamic.length>0?"dynamic":e.type==="layout"?"layout":t.startsWith("(")&&t.endsWith(")")?"group":t==="index"?"index":"static"}static extractParams(e){return!e.dynamic||e.dynamic.length===0?[]:e.dynamic.map(t=>t.name)}static shouldIncludeRoute(e){return!(e.internal||e.generated||e.type==="api")}static organizeRoutes(e){let t=[],o=this.flattenRoutes(e).filter(i=>i.type==="static"||i.type==="index"),r=this.flattenRoutes(e).filter(i=>i.type==="dynamic"||i.type==="catch-all"),a=this.flattenRoutes(e).filter(i=>i.type==="layout"),n=this.flattenRoutes(e).filter(i=>i.type==="group");return o.length>0&&t.push({title:"Static Routes",icon:"",routes:o}),r.length>0&&t.push({title:"Dynamic Routes",icon:"",description:"Routes that accept parameters",routes:r}),a.length>0&&t.push({title:"Layouts",icon:"",description:"Shared UI for nested screens",routes:a}),n.length>0&&t.push({title:"Route Groups",icon:"",routes:n}),t}static flattenRoutes(e){let t=[];function o(r){t.push(r),r.children.forEach(o)}return e.forEach(o),t}static getRouteStats(e){let t=this.flattenRoutes(e);return{total:t.length,static:t.filter(o=>o.type==="static").length,dynamic:t.filter(o=>o.type==="dynamic").length,catchAll:t.filter(o=>o.type==="catch-all").length,layouts:t.filter(o=>o.type==="layout").length,groups:t.filter(o=>o.type==="group").length}}static filterRoutes(e,t){if(!t)return e;let o=t.toLowerCase();return this.flattenRoutes(e).filter(r=>r.path.toLowerCase().includes(o)||r.name.toLowerCase().includes(o)||r.type.toLowerCase().includes(o)||r.params.some(a=>a.toLowerCase().includes(o)))}static buildTreeString(e,t=0){let o="";return e.forEach((r,a)=>{let n=a===e.length-1,i=`${this.buildTreePrefix(t,n)}${r.path}`;r.params.length>0&&(i+=` { ${r.params.join(", ")} }`),o+=i+`
|
|
2
|
-
`,r.children.length>0&&(o+=this.buildTreeString(r.children,t+1))}),o}static buildTreePrefix(e,t){return e===0?"":" ".repeat(e-1)+(t?"\u2514\u2500 ":"\u251C\u2500 ")}static sortRoutes(e,t="path"){let o=[...e];return o.sort((r,a)=>{switch(t){case"path":return r.path.localeCompare(a.path);case"type":return r.type.localeCompare(a.type);case"name":return r.name.localeCompare(a.name);default:return 0}}),o}static findRouteByPath(e,t){return this.flattenRoutes(e).find(o=>o.path===t)||null}static getParentRoutes(e,t){let o=[],r=this.flattenRoutes(e);if(!r.find(i=>i.path===t))return o;let a=t.split("/").filter(Boolean),n="";for(let i=0;i<a.length-1;i++){n+="/"+a[i];let d=r.find(s=>s.path===n);d&&o.push(d)}return o}};import{getBrowserHref as Fa}from"@buoy-gg/shared-ui/web/utils";var $e=new Map,bt=null;function Na(e){for(let o of e)$e.set(o,($e.get(o)??0)+1);bt=Date.now();let t=true;return()=>{if(t){t=false;for(let o of e){let r=($e.get(o)??1)-1;r?$e.set(o,r):$e.delete(o)}bt=Date.now()}}}function vt(){return[...$e.keys()]}function za(){return bt}function
|
|
1
|
+
"use client";var Nt=Object.defineProperty;var Ao=Object.getOwnPropertyDescriptor;var Fo=Object.getOwnPropertyNames;var No=Object.prototype.hasOwnProperty;var zo=(e,t)=>{for(var o in t)Nt(e,o,{get:t[o],enumerable:true})},zt=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Fo(t))!No.call(e,a)&&a!==o&&Nt(e,a,{get:()=>t[a],enumerable:!(r=Ao(t,a))||r.enumerable});return e},Wo=(e,t,o)=>(zt(e,t,"default"),o&&zt(o,t,"default"));var qn=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{RoutesIcon as Oo}from"@buoy-gg/floating-tools-core/web";import{useState as ke,useCallback as me,useEffect as Wt,useRef as jo,useMemo as Ie}from"react";var Ot={};zo(Ot,{AccessibilityInfo:()=>Uo,ActivityIndicator:()=>Mr,Alert:()=>_,Animated:()=>zr,AppRegistry:()=>_o,AppState:()=>Go,Appearance:()=>Ko,BackHandler:()=>Jo,Button:()=>Ur,CheckBox:()=>lr,Clipboard:()=>qo,DeviceEventEmitter:()=>Cr,Dimensions:()=>Yo,Easing:()=>Zo,FlatList:()=>Ht,I18nManager:()=>Qo,Image:()=>cr,ImageBackground:()=>ur,InteractionManager:()=>Xo,Keyboard:()=>jt,KeyboardAvoidingView:()=>dr,LayoutAnimation:()=>er,Linking:()=>tr,LogBox:()=>wr,Modal:()=>Hr,NativeEventEmitter:()=>or,NativeModules:()=>Mo,PanResponder:()=>rr,Picker:()=>pr,PixelRatio:()=>ar,Platform:()=>ct,Pressable:()=>jr,ProgressBar:()=>mr,RefreshControl:()=>hr,SafeAreaView:()=>fr,ScrollView:()=>qe,SectionList:()=>gr,Share:()=>nr,StatusBar:()=>yr,StyleSheet:()=>ve,Switch:()=>Vr,Text:()=>p,TextInput:()=>_t,Touchable:()=>br,TouchableHighlight:()=>Wr,TouchableNativeFeedback:()=>vr,TouchableOpacity:()=>V,TouchableWithoutFeedback:()=>Or,UIManager:()=>ir,Vibration:()=>sr,View:()=>c,VirtualizedList:()=>xr,YellowBox:()=>Sr,findNodeHandle:()=>Kr,unstable_createElement:()=>Vo,useColorScheme:()=>Tr,useLocaleContext:()=>Rr,useWindowDimensions:()=>kr});Wo(Ot,Ho);import*as Ho from"react-native-web";import{unstable_createElement as Vo,NativeModules as Mo,AccessibilityInfo as Uo,Appearance as Ko,AppRegistry as _o,AppState as Go,BackHandler as Jo,Clipboard as qo,Dimensions as Yo,Easing as Zo,I18nManager as Qo,Keyboard as jt,InteractionManager as Xo,LayoutAnimation as er,Linking as tr,NativeEventEmitter as or,PanResponder as rr,PixelRatio as ar,Platform as ct,Share as nr,UIManager as ir,Vibration as sr,CheckBox as lr,FlatList as Ht,Image as cr,ImageBackground as ur,KeyboardAvoidingView as dr,Picker as pr,ProgressBar as mr,RefreshControl as hr,SafeAreaView as fr,SectionList as gr,StatusBar as yr,Touchable as br,TouchableNativeFeedback as vr,VirtualizedList as xr,YellowBox as Sr,LogBox as wr,DeviceEventEmitter as Cr,useColorScheme as Tr,useLocaleContext as Rr,useWindowDimensions as kr}from"react-native-web";import*as oe from"react-native-web";import{createElement as ut,forwardRef as Vt,useCallback as Ir,useRef as Br}from"react";import{useEffect as Er,useState as Dr}from"react";import{createPortal as Pr}from"react-dom";var Lr='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as $r}from"react/jsx-runtime";var ze=Symbol.for("@buoy-gg/portal-host"),Mt=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function Ut(){let e=document;if(e[ze])return e[ze].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:Lr});let o=()=>{let l=document.fullscreenElement,h=l&&l.tagName!=="CANVAS"?l:document.body;t.parentElement!==h&&h.appendChild(t)},r=new Map,a=l=>{(!t.contains(l.target)||!Mt(l.target))&&r.set(l.code||l.key,{key:l.key,code:l.code,location:l.location,keyCode:l.keyCode,which:l.which,altKey:l.altKey,ctrlKey:l.ctrlKey,metaKey:l.metaKey,shiftKey:l.shiftKey})},n=l=>{r.delete(l.code||l.key)},i=()=>r.clear(),d=()=>{let l=[...r.values()];r.clear();for(let h of l)document.dispatchEvent(new KeyboardEvent("keyup",{...h,bubbles:true}))},s=l=>{Mt(l.target)&&l.stopPropagation()},f=l=>l.stopPropagation();return o(),document.addEventListener("fullscreenchange",o),document.addEventListener("keydown",a,true),document.addEventListener("keyup",n,true),window.addEventListener("blur",i),t.addEventListener("focusin",d),t.addEventListener("keydown",s),t.addEventListener("keyup",s),t.addEventListener("keypress",s),t.addEventListener("wheel",f,{passive:true}),e[ze]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",o),document.removeEventListener("keydown",a,true),document.removeEventListener("keyup",n,true),window.removeEventListener("blur",i),t.remove(),delete e[ze]}},t}function Ar({children:e}){let[t,o]=Dr(null);return Er(()=>{let r=Ut(),a=document[ze];return a.users++,o(r),()=>{--a.users===0&&a.dispose()}},[]),t?Pr($r("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var Be=oe,Fr=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],Ee=e=>typeof e=="number"?`${e}px`:e;function dt(e){if(Array.isArray(e)){let h=e.map(dt);return h.some((R,F)=>R!==e[F])?h:e}if(!e||typeof e!="object"||!Fr.some(h=>e[h]!=null))return e;let{shadowColor:t,shadowOffset:o,shadowOpacity:r,shadowRadius:a,textShadowColor:n,textShadowOffset:i,textShadowRadius:d,...s}=e;if(t!=null||o!=null||r!=null||a!=null){let h=t??"black",R=r==null?h:`color-mix(in srgb, ${h} ${Math.min(r,1)*100}%, transparent)`,F=`${Ee(o?.width??0)} ${Ee(o?.height??0)} ${Ee(a??0)} ${R}`;s.boxShadow=typeof s.boxShadow=="string"?`${s.boxShadow}, ${F}`:s.boxShadow??F}let{width:f=0,height:l=0}=i??{};if(n&&(f||l||d)){let h=`${Ee(f)} ${Ee(l)} ${Ee(d??0)} ${n}`;s.textShadow=s.textShadow?`${s.textShadow}, ${h}`:h}return s}var Nr=Be.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function Kt(e,t){if(typeof e=="function")return r=>Kt(e(r),t);let o=dt(e);return t?[o,Nr[t]]:o}var ve={...Be.StyleSheet,create:e=>Be.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,o])=>[t,dt(o)])))};function ne(e){let t=Vt((r,a)=>{let{accessibilityState:n,accessibilityValue:i,pointerEvents:d,...s}=r;for(let l of["busy","checked","disabled","expanded","selected"])n?.[l]!==void 0&&s[`aria-${l}`]===void 0&&(s[`aria-${l}`]=n[l]);for(let[l,h]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))i?.[l]!==void 0&&s[`aria-${h}`]===void 0&&(s[`aria-${h}`]=i[l]);let f=Kt(s.style,d);return f!==s.style&&(s.style=f),ut(e,{...s,ref:a})}),o=e.State;return o&&Object.assign(t,{State:o}),t.displayName=e.displayName??e.name??"NativeWebView",t}var c=ne(oe.View),p=ne(oe.Text),zr={...Be.Animated,View:Be.Animated.createAnimatedComponent(c),Text:Be.Animated.createAnimatedComponent(p)},_t=ne(oe.TextInput),V=ne(oe.TouchableOpacity),Wr=ne(oe.TouchableHighlight),Or=ne(oe.TouchableWithoutFeedback),jr=ne(oe.Pressable),qe=ne(oe.ScrollView),Gt=Vt((e,t)=>{let o=Br(null),r=Ir(a=>{if(a){let n=a;for(;n.parentElement&&n.parentElement!==document.body;)n=n.parentElement;n.parentElement===document.body&&(o.current=n,Object.assign(n.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),Ut().appendChild(n))}else o.current&&(document.body.appendChild(o.current),o.current=null);typeof t=="function"?t(a):t&&(t.current=a)},[t]);return ut(Ar,null,ut(oe.Modal,{...e,ref:r}))});Gt.displayName="Modal";var Hr=ne(Gt),Vr=ne(oe.Switch),Mr=ne(oe.ActivityIndicator),Ur=ne(oe.Button),Kr=oe.findNodeHandle,_={alert(e,t,o,r){if(typeof document>"u")return;let a=document.createElement("dialog");a.dataset.buoyRoot="",a.setAttribute("aria-label",e),a.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let n=document.createElement("h2");if(n.textContent=e,n.style.cssText="font-size:18px;margin:0 0 12px",a.appendChild(n),t){let f=document.createElement("p");f.textContent=t,f.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",a.appendChild(f)}let i=document.createElement("div");i.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let d=o?.length?o:[{text:"OK"}],s=()=>{a.close?.(),a.remove()};for(let f of d){let l=document.createElement("button");l.type="button",l.textContent=f.text??"OK",l.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${f.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,l.onclick=()=>{s(),f.onPress?.()},i.appendChild(l)}a.addEventListener("cancel",f=>{f.preventDefault(),r?.cancelable!==false&&(s(),r?.onDismiss?.())}),a.appendChild(i),document.body.appendChild(a),a.showModal?a.showModal():a.setAttribute("open","")}};import{browserRouter as ai}from"@buoy-gg/shared-ui/web/utils";function _r(){return null}import{useSafeRouter as Gr,isExpoRouterAvailable as Jr,windowDragProps as qr,ToolEmptyState as Yr,resolveListEmptyState as Zr,usePersistedState as pt,monoFont as Ye}from"@buoy-gg/shared-ui/web";import{JsModal as Qr,ModalHeader as le,TabSelector as Xr,formatRelativeTime as ea,devToolsStorageKeys as We,Trash2 as ta,Filter as oa,SearchBar as Jt,ToolbarCopyButton as mt,Lock as ra,ProUpgradeModal as aa,PowerToggleButton as na,buoyColors as ia,night as Z,TickProvider as qt,useLimit as sa}from"@buoy-gg/shared-ui/web";import{useIsPro as la}from"@buoy-gg/license/web";import{useEventStoreEvents as ca}from"@buoy-gg/shared-ui/web";import{BaseEventStore as ua,devToolsStorageKeys as da,persistentStorage as pa}from"@buoy-gg/shared-ui/web";var Yt=class{constructor(){this.listeners=new Set}emit(e){this.listeners.forEach(t=>{try{t(e)}catch(o){console.error("[Buoy]","[RouteObserver] Error in listener:",o)}})}addListener(e){return this.listeners.add(e),()=>this.listeners.delete(e)}removeListener(e){this.listeners.delete(e)}},De=new Yt;var ma=class extends ua{constructor(){super({storeName:"route-events",maxEvents:500});this.routeObserverUnsubscribe=null;this.bootCaptureRelease=null;this.bootCaptureHydrated=false;this.lastUnrecorded=null;this.everCaptured=false;let e=De.addListener(t=>{if(this.everCaptured){e();return}this.lastUnrecorded=t})}setBootCapture(e){e&&!this.bootCaptureRelease?this.bootCaptureRelease=this.subscribeToEvents(()=>{}):!e&&this.bootCaptureRelease&&(this.bootCaptureRelease(),this.bootCaptureRelease=null)}hydrateBootCapture(){if(this.bootCaptureHydrated)return;this.bootCaptureHydrated=true;let e=this.bootCaptureRelease!==null,t=this.getEventCount();e||this.setBootCapture(true);let o=this.bootCaptureRelease;pa.getItem(da.routeEvents.isMonitoring()).then(r=>{if(e||this.bootCaptureRelease!==o||r!=="false")return;this.setBootCapture(false);let a=this.getEventCount()-t;a>0&&this.replaceEvents(this.getEvents().slice(a))}).catch(()=>{})}startCapturing(){if(!this.routeObserverUnsubscribe){this.routeObserverUnsubscribe=De.addListener(t=>{this.addEvent(t)});let e=this.everCaptured?null:this.lastUnrecorded;this.everCaptured=true,this.lastUnrecorded=null,e&&this.getEventCount()===0&&this.addEvent(e)}}stopCapturing(){this.routeObserverUnsubscribe&&(this.routeObserverUnsubscribe(),this.routeObserverUnsubscribe=null)}isCapturing(){return this.routeObserverUnsubscribe!==null}isListening(){return this.isCapturing()}},he=new ma;function Zt(e={}){let{maxEvents:t=500,enabled:o=true}=e,{events:r,clearEvents:a,isActive:n}=ca(he,{maxEvents:t,enabled:o});return{events:r,clearEvents:a,isListening:n}}import{Navigation as ha,night as Ze,monoFont as fa}from"@buoy-gg/shared-ui/web";import{InlineCopyButton as Oe,night as ht,monoFont as ft}from"@buoy-gg/shared-ui/web";import{DataViewer as ga}from"@buoy-gg/shared-ui/web/dataViewer";import{jsx as z,jsxs as G}from"react/jsx-runtime";function ya(e){if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/6e4),o=(e%6e4/1e3).toFixed(0);return`${t}m ${o}s`}function gt({event:e,visitNumber:t,routeTemplate:o}){let r=e.params&&Object.keys(e.params).length>0;return G(c,{style:T.container,children:[G(c,{style:T.section,children:[e.routeName&&G(c,{style:T.detailRow,children:[z(p,{style:T.detailLabel,children:"Name:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-name",children:e.routeName})]}),e.matchedPath&&G(c,{style:T.detailRow,children:[z(p,{style:T.detailLabel,children:"Match:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-match",children:e.matchedPath})]}),o&&G(c,{style:T.detailRow,testID:"buoy-routes-detail-template",children:[z(p,{style:T.detailLabel,children:"Template:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-template-value",children:o}),z(Oe,{value:o,buttonStyle:T.copyButton})]}),e.previousPathname&&G(c,{style:T.detailRow,testID:"buoy-routes-detail-from",children:[z(p,{style:T.detailLabel,children:"From:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-from-value",children:e.previousPathname}),z(Oe,{value:e.previousPathname,buttonStyle:T.copyButton})]}),G(c,{style:T.detailRow,testID:"buoy-routes-detail-to",children:[z(p,{style:T.detailLabel,children:"To:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-to-value",children:e.pathname}),z(Oe,{value:e.pathname,buttonStyle:T.copyButton})]})]}),G(c,{style:T.section,children:[e.timeSincePrevious!==void 0&&G(c,{style:T.detailRow,testID:"buoy-routes-detail-duration",children:[z(p,{style:T.detailLabel,children:"Duration:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-duration-value",children:ya(e.timeSincePrevious)})]}),G(c,{style:T.detailRow,testID:"buoy-routes-detail-time",children:[z(p,{style:T.detailLabel,children:"Time:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-time-value",children:new Date(e.timestamp).toLocaleString()})]})]}),G(c,{style:T.section,children:[e.segments&&e.segments.length>0&&G(c,{style:T.detailRow,testID:"buoy-routes-detail-segments",children:[z(p,{style:T.detailLabel,children:"Segments:"}),z(p,{style:T.detailValue,testID:"buoy-routes-detail-segments-value",children:e.segments.join(" \u2192 ")}),z(Oe,{value:JSON.stringify(e.segments),buttonStyle:T.copyButton})]}),r&&G(c,{style:T.dataViewerContainer,children:[G(c,{style:T.dataViewerHeader,children:[G(p,{style:T.dataViewerTitle,testID:"buoy-routes-detail-params-title",children:["Parameters (",Object.keys(e.params).length,")"]}),z(Oe,{value:JSON.stringify(e.params,null,2),buttonStyle:T.copyButton})]}),z(ga,{data:e.params,title:"",showTypeFilter:true,rawMode:true,initialExpanded:true})]}),t>1&&G(c,{style:T.detailRow,testID:"buoy-routes-detail-visited",children:[z(p,{style:T.detailLabel,children:"Visited:"}),G(p,{style:T.detailValue,testID:"buoy-routes-detail-visited-value",children:[t," time",t!==1?"s":""]})]})]})]})}var T=ve.create({container:{gap:12},section:{gap:8},detailRow:{flexDirection:"row",alignItems:"center",gap:8},detailLabel:{fontSize:10,color:ht.color.textSecondary,fontFamily:ft,fontWeight:"600",minWidth:70},detailValue:{fontSize:11,color:ht.color.text,fontFamily:ft,flex:1},copyButton:{padding:4,borderRadius:4},dataViewerContainer:{marginTop:4},dataViewerHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},dataViewerTitle:{fontSize:11,color:ht.color.textSecondary,fontFamily:ft,fontWeight:"600"}});function yt(e,t){if(!t||t.length===0)return null;let o="/"+t.map(r=>/^\d+$/.test(r)||/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)?"[id]":r).join("/");return o!==e?o:null}function Qt(e,t){if(!t)return e;let o=new Set(e.split("/").filter(Boolean).map(a=>{try{return decodeURIComponent(a)}catch{return a}})),r=[];for(let[a,n]of Object.entries(t)){let i=Array.isArray(n)?n:[n];if(!(i.length>0&&i.every(d=>o.has(String(d)))))for(let d of i)r.push(`${encodeURIComponent(a)}=${encodeURIComponent(String(d))}`)}return r.length?`${e}?${r.join("&")}`:e}function ba(e){let t=e.indexOf("?");if(t<0)return{pathname:e,params:{}};let o={};for(let r of e.slice(t+1).split("&")){if(!r)continue;let[a,n=""]=r.split("=");try{o[decodeURIComponent(a)]=decodeURIComponent(n)}catch{o[a]=n}}return{pathname:e.slice(0,t),params:o}}import{jsx as je,jsxs as Xt}from"react/jsx-runtime";function eo({event:e,visitNumber:t=1,onNavigate:o}){let r=yt(e.pathname,e.segments);return Xt(c,{style:Pe.container,children:[je(qe,{keyboardShouldPersistTaps:"handled",testID:"buoy-routes-detail-scroll",style:Pe.scroll,contentContainerStyle:Pe.scrollContent,showsVerticalScrollIndicator:true,children:je(gt,{event:e,visitNumber:t,routeTemplate:r})}),o&&je(c,{style:Pe.footer,children:Xt(V,{style:Pe.goButton,onPress:()=>o(Qt(e.pathname,e.params)),activeOpacity:.8,testID:"buoy-routes-detail-go",accessibilityRole:"button",accessibilityLabel:`Go to route ${e.pathname}`,children:[je(ha,{size:16,color:Ze.color.onAccent}),je(p,{style:Pe.goButtonText,children:"Go to route"})]})})]})}var Pe=ve.create({container:{flex:1,backgroundColor:"transparent"},scroll:{flex:1},scrollContent:{padding:14},footer:{paddingHorizontal:16,paddingVertical:12,backgroundColor:"transparent",borderTopWidth:1,borderTopColor:Ze.color.border},goButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,backgroundColor:Ze.color.accent,paddingVertical:12,borderRadius:8},goButtonText:{fontSize:13,fontWeight:"600",color:Ze.color.onAccent,fontFamily:fa,textTransform:"uppercase",letterSpacing:.5}});import{Filter as to,DynamicFilterView as va}from"@buoy-gg/shared-ui/web";import{jsx as xa}from"react/jsx-runtime";function Sa({ignoredPatterns:e,onTogglePattern:t,onAddPattern:o,availablePathnames:r=[]}){return xa(va,{...{addFilterSection:{enabled:true,placeholder:"Enter pattern (e.g., /_sitemap)",title:"ACTIVE FILTERS",icon:to},availableItemsSection:{enabled:true,title:"AVAILABLE ROUTES FROM EVENTS",emptyMessage:"No routes available. Routes from navigation events will appear here.",items:r},howItWorksSection:{enabled:true,title:"HOW FILTERS WORK",description:"Filtered routes will not appear in the route events list. Patterns match if the route contains the specified text.",examples:["\u2022 /_sitemap \u2192 filters /_sitemap routes","\u2022 /api \u2192 filters /api/users, /api/posts","\u2022 [id] \u2192 filters all routes with [id] param"],icon:to},onPatternToggle:t,onPatternAdd:o,activePatterns:e}})}import{useState as Le,useCallback as He,useMemo as Qe,useEffect as wa}from"react";import{night as v,ToolEmptyState as Ca,monoFont as Q}from"@buoy-gg/shared-ui/web";import{isCapacitorNative as Ta}from"@buoy-gg/license/web";import{useSafeRouter as Ra}from"@buoy-gg/shared-ui/web";import{Search as oo,ChevronDown as ro,ChevronRight as ao,Home as ka,InlineCopyButton as Ia,CopyButton as Ba,RefreshCw as Ea,formatRelativeTime as Da,ProUpgradeModal as Pa}from"@buoy-gg/shared-ui/web";import{useIsPro as La}from"@buoy-gg/license/web";import{useState as $a,useEffect as no,useMemo as Se,useCallback as Aa}from"react";var ye=class{static parseRouteTree(e){if(!e)return[];let t=[];return this.traverseNode(e,"",t,0),t}static traverseNode(e,t,o,r){let a=this.buildPath(e,t),n=this.detectRouteType(e),i=this.shouldIncludeRoute(e),d={path:a,name:e.route,type:n,params:this.extractParams(e),nodeType:e.type,contextKey:e.contextKey,isInternal:e.internal??false,children:[],depth:r};i&&o.push(d);for(let s of e.children)this.traverseNode(s,a,i?d.children:o,r+1)}static buildPath(e,t){if(e.type==="layout"&&e.route==="_layout"||e.route.startsWith("(")&&e.route.endsWith(")"))return t;if(e.route==="index")return t||"/";let o=e.route;return!t||t==="/"?`/${o}`:`${t}/${o}`}static detectRouteType(e){let t=e.route;return e.dynamic?.some(o=>o.notFound)?"not-found":e.dynamic?.some(o=>o.deep)?"catch-all":e.dynamic&&e.dynamic.length>0?"dynamic":e.type==="layout"?"layout":t.startsWith("(")&&t.endsWith(")")?"group":t==="index"?"index":"static"}static extractParams(e){return!e.dynamic||e.dynamic.length===0?[]:e.dynamic.map(t=>t.name)}static shouldIncludeRoute(e){return!(e.internal||e.generated||e.type==="api")}static organizeRoutes(e){let t=[],o=this.flattenRoutes(e).filter(i=>i.type==="static"||i.type==="index"),r=this.flattenRoutes(e).filter(i=>i.type==="dynamic"||i.type==="catch-all"),a=this.flattenRoutes(e).filter(i=>i.type==="layout"),n=this.flattenRoutes(e).filter(i=>i.type==="group");return o.length>0&&t.push({title:"Static Routes",icon:"",routes:o}),r.length>0&&t.push({title:"Dynamic Routes",icon:"",description:"Routes that accept parameters",routes:r}),a.length>0&&t.push({title:"Layouts",icon:"",description:"Shared UI for nested screens",routes:a}),n.length>0&&t.push({title:"Route Groups",icon:"",routes:n}),t}static flattenRoutes(e){let t=[];function o(r){t.push(r),r.children.forEach(o)}return e.forEach(o),t}static getRouteStats(e){let t=this.flattenRoutes(e);return{total:t.length,static:t.filter(o=>o.type==="static").length,dynamic:t.filter(o=>o.type==="dynamic").length,catchAll:t.filter(o=>o.type==="catch-all").length,layouts:t.filter(o=>o.type==="layout").length,groups:t.filter(o=>o.type==="group").length}}static filterRoutes(e,t){if(!t)return e;let o=t.toLowerCase();return this.flattenRoutes(e).filter(r=>r.path.toLowerCase().includes(o)||r.name.toLowerCase().includes(o)||r.type.toLowerCase().includes(o)||r.params.some(a=>a.toLowerCase().includes(o)))}static buildTreeString(e,t=0){let o="";return e.forEach((r,a)=>{let n=a===e.length-1,i=`${this.buildTreePrefix(t,n)}${r.path}`;r.params.length>0&&(i+=` { ${r.params.join(", ")} }`),o+=i+`
|
|
2
|
+
`,r.children.length>0&&(o+=this.buildTreeString(r.children,t+1))}),o}static buildTreePrefix(e,t){return e===0?"":" ".repeat(e-1)+(t?"\u2514\u2500 ":"\u251C\u2500 ")}static sortRoutes(e,t="path"){let o=[...e];return o.sort((r,a)=>{switch(t){case"path":return r.path.localeCompare(a.path);case"type":return r.type.localeCompare(a.type);case"name":return r.name.localeCompare(a.name);default:return 0}}),o}static findRouteByPath(e,t){return this.flattenRoutes(e).find(o=>o.path===t)||null}static getParentRoutes(e,t){let o=[],r=this.flattenRoutes(e);if(!r.find(i=>i.path===t))return o;let a=t.split("/").filter(Boolean),n="";for(let i=0;i<a.length-1;i++){n+="/"+a[i];let d=r.find(s=>s.path===n);d&&o.push(d)}return o}};import{getBrowserHref as Fa}from"@buoy-gg/shared-ui/web/utils";var $e=new Map,bt=null;function Na(e){for(let o of e)$e.set(o,($e.get(o)??0)+1);bt=Date.now();let t=true;return()=>{if(t){t=false;for(let o of e){let r=($e.get(o)??1)-1;r?$e.set(o,r):$e.delete(o)}bt=Date.now()}}}function vt(){return[...$e.keys()]}function za(){return bt}function io(e){let t={segments:e.split("/").filter(Boolean),params:{}},o=vt();if(o.includes(e))return t;for(let r of o){let a=r.split("/").filter(Boolean),n=[],i=a.map(l=>{let h=/^\[(\.\.\.)?([^\]]+)\]$/.exec(l);return h?(n.push({name:h[2],deep:!!h[1]}),h[1]?"(.+)":"([^/]+)"):l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}),d=new RegExp("^/"+i.join("/")+"/?$").exec(e);if(!d)continue;let s=l=>{try{return decodeURIComponent(l)}catch{return l}},f={};return n.forEach(({name:l,deep:h},R)=>{let F=d[R+1];f[l]=h?F.split("/").map(s):s(F)}),{segments:a,params:f}}return t}var xt=0;function Wa(){xt++,he.hydrateBootCapture();let e=true;return()=>{e&&(e=false,xt--)}}function Oa(){return xt>0}function St(){return typeof window<"u"}function Ve(){return St()?{route:"",type:"layout",contextKey:"browser",children:[...new Set([...vt(),new URL(Fa()).pathname])].map(e=>({route:e.replace(/^\//,"")||"index",type:"route",contextKey:e,children:[],dynamic:e.split("/").flatMap(t=>{let o=/^\[(\.\.\.)?([^\]]+)\]$/.exec(t);return o?[{name:o[2],deep:!!o[1]}]:[]})}))}:null}function wt(){return{source:vt().length>0?"registered":null,lastLoadedAt:za()}}function so(){return false}function Xe(e={}){let{searchQuery:t="",sortBy:o="path",autoRefresh:r=false,refreshInterval:a=1e3,injectedRoutes:n,injectedSource:i=null,injectedLastUpdatedAt:d=null}=e,s=n!=null,[f,l]=$a(()=>{let P=Ve(),Y=wt();return{node:P,version:0,lastUpdatedAt:Y.lastLoadedAt,source:Y.source}}),h=f.node,R=f.version,F=f.lastUpdatedAt,g=f.source,x=Aa(()=>{l(P=>{let Y=Ve(),X=wt();return{node:Y,version:P.version+1,lastUpdatedAt:X.lastLoadedAt,source:X.source}})},[]);no(()=>{if(h||s||!St())return;let P=0,Y=100,X=()=>{P++,x(),P<Y&&(j=setTimeout(X,100))},j=setTimeout(X,100);return()=>clearTimeout(j)},[h,x,s]),no(()=>{if(!r)return;let P=setInterval(x,a);return()=>clearInterval(P)},[r,a,x]);let L=s?n.length>0:!!h,I=s?true:St(),E=Se(()=>s?n:h?ye.parseRouteTree(h):[],[h,R,s,n]),W=Se(()=>ye.sortRoutes(E,o),[E,o]),C=Se(()=>t?ye.filterRoutes(W,t):W,[W,t]),A=Se(()=>ye.organizeRoutes(C),[C]),q=Se(()=>ye.getRouteStats(E),[E]);return{routes:W,groups:A,stats:q,filteredRoutes:C,isLoaded:L,isSupported:I,refresh:x,findRoute:P=>ye.findRouteByPath(E,P),getParents:P=>ye.getParentRoutes(E,P),lastUpdatedAt:s?d:F,source:s?i:g}}function ja(e){let{findRoute:t}=Xe();return Se(()=>t(e),[t,e])}function Ha(e){let{getParents:t}=Xe();return Se(()=>t(e),[t,e])}function Ct(e){return String(e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"root"}function Va(e,t){return`buoy-routes-event-row-${Ct(e)}-${t}`}function Ma(e){return`buoy-routes-route-${Ct(e)}`}function lo(e){return`buoy-routes-group-${Ct(e)}`}function Ua(e){return`buoy-routes-stack-item-${e}`}import{jsx as m,jsxs as O}from"react/jsx-runtime";var re=ct.OS==="web"&&!Ta(),et=re?22:16,Ka={path:"/",name:"index",type:"index",params:[],nodeType:"route",contextKey:"/",isInternal:false,children:[],depth:0};function Tt({style:e,injectedRoutes:t,injectedSource:o,injectedLastUpdatedAt:r,onNavigateRoute:a}){let[n,i]=Le(""),[d,s]=Le(false),[f,l]=Le(new Set(["Static Routes","Dynamic Routes"])),[h,R]=Le(false),[F,g]=Le(false),x=La();wa(()=>{F&&x&&g(false)},[F,x]);let L=Ra(),{groups:I,stats:E,isLoaded:W,isSupported:C,filteredRoutes:A,routes:q,refresh:P,lastUpdatedAt:Y,source:X}=Xe({searchQuery:n,sortBy:"path",injectedRoutes:t,injectedSource:o,injectedLastUpdatedAt:r}),j=Qe(()=>({summary:{total:E.total,static:E.static,dynamic:E.dynamic,layouts:E.layouts,groups:E.groups,timestamp:new Date().toISOString()},groups:I.map(w=>({title:w.title,description:w.description,count:w.routes.length,routes:w.routes.map(D=>({path:D.path,name:D.name,type:D.type,params:D.params,depth:D.depth,hasChildren:D.children.length>0,childrenCount:D.children.length}))})),allRoutes:q.map(w=>w.path)}),[I,E,q]),we=He(w=>{l(D=>{let ee=new Set(D);return ee.has(w)?ee.delete(w):ee.add(w),ee})},[]),ue=He((w,D=0,ee={})=>{let Fe=w.params;if(D>=Fe.length){let H=w.path;Object.entries(ee).forEach(([be,se])=>{w.type==="catch-all"?H=H.replace(`[...${be}]`,se):H=H.replace(`[${be}]`,se)});try{L.push(H)}catch(be){_.alert("Navigation Error",String(be))}return}let Ce=Fe[D],_e=w.type==="catch-all"?`[...${Ce}]`:`[${Ce}]`,Ne="Enter Parameter Value",Ge=`Enter value for ${_e}:
|
|
3
3
|
|
|
4
4
|
Route: ${w.path}`,nt=H=>{H&&H.trim()&&ue(w,D+1,{...ee,[Ce]:H.trim()})};if(typeof _.prompt!="function"){let H=globalThis.prompt;H?nt(H(`${Ne}
|
|
5
5
|
|
|
6
|
-
${Ge}`)):_.alert(Ne,`${w.path} needs a value for ${_e}, and this platform can't ask for one here.`);return}_.prompt(Ne,Ge,[{text:"Cancel",style:"cancel"},{text:D<Fe.length-1?"Next":"Navigate",onPress:H=>{if(H&&H.trim()){let be={...ee,[Ce]:H.trim()};ue(w,D+1,be)}else _.alert("Invalid Value","Please enter a value for the parameter")}}],"plain-text")},[L]),xe=He((w,D)=>{if(a){a(w);return}if(!x&&!D?.bypassPro){g(true);return}if(w.type==="layout"||w.type==="group"){_.alert("Cannot Navigate",`${w.type==="layout"?"Layouts":"Route groups"} are not navigable routes`);return}if(w.type==="dynamic"||w.type==="catch-all"){if(w.params.length===0){try{L.push(w.path)}catch(ee){_.alert("Navigation Error",String(ee))}return}ue(w);return}try{L.push(w.path)}catch(ee){_.alert("Navigation Error",String(ee))}},[L,ue,x,a]),de=He(()=>{xe(Ka,{bypassPro:true})},[xe]),S=He(()=>{m||(R(true),P(),setTimeout(()=>R(false),400))},[m,P]),N=Qe(()=>Y?`Updated ${Da(Y)}`:"Awaiting route data",[Y]),K=Qe(()=>X?`Source: ${X}`:"Source: unknown",[X]),pe=Qe(()=>n&&A.length>0?[{title:"Search Results",icon:"",routes:A}]:I,[n,A,I]);return W?O(c,{style:[u.container,e],children:[d&&O(c,{style:u.searchContainer,testID:"buoy-routes-sitemap-search-field",children:[h(to,{size:16,color:v.color.textTertiary}),h(Kt,{style:u.searchInput,placeholder:"Search routes...",placeholderTextColor:v.color.placeholder,value:n,onChangeText:i,autoCapitalize:"none",autoCorrect:false,autoFocus:true,testID:"buoy-routes-sitemap-search",accessibilityLabel:"Search routes"}),n.length>0&&h(V,{onPress:()=>i(""),style:u.clearButton,testID:"buoy-routes-sitemap-search-clear",accessibilityRole:"button",accessibilityLabel:"Clear route search",children:h(p,{style:u.clearButtonText,children:"\u2715"})}),h(V,{style:u.closeSearchButton,onPress:()=>{s(false),i("")},testID:"buoy-routes-sitemap-search-done",accessibilityRole:"button",accessibilityLabel:"Done searching routes",children:h(p,{style:u.closeSearchText,children:"Done"})})]}),O(qe,{keyboardShouldPersistTaps:"handled",testID:"buoy-routes-sitemap-scroll",style:u.scrollView,contentContainerStyle:u.scrollContent,children:[!d&&O(c,{style:u.header,children:[O(c,{style:u.actionsRow,children:[O(c,{style:[u.actionWrapper,re&&u.actionWrapperDesktop],children:[h(V,{style:[u.iconButton,re&&u.iconButtonDesktop],onPress:de,accessibilityLabel:"Go to home route",accessibilityRole:"button",testID:"buoy-routes-sitemap-home",children:h(ka,{size:et,color:v.color.textSecondary})}),h(p,{style:[u.actionLabel,re&&u.actionLabelDesktop],children:"Home"})]}),O(c,{style:[u.actionWrapper,re&&u.actionWrapperDesktop],children:[h(Ba,{value:j,testID:"buoy-routes-sitemap-copy",size:re?et:14,buttonStyle:re?u.actionButtonHeaderDesktop:u.actionButtonHeader}),h(p,{style:[u.actionLabel,re&&u.actionLabelDesktop],children:"Copy"})]}),O(c,{style:[u.actionWrapper,re&&u.actionWrapperDesktop],children:[h(V,{style:[u.iconButton,re&&u.iconButtonDesktop,m&&u.refreshButtonDisabled],onPress:S,disabled:m,testID:"buoy-routes-sitemap-refresh",accessibilityRole:"button",accessibilityLabel:"Refresh route tree",children:h(Ea,{size:et,color:m?v.color.textTertiary:v.color.textSecondary})}),h(p,{style:[u.actionLabel,re&&u.actionLabelDesktop],children:"Refresh"})]}),O(c,{style:[u.actionWrapper,re&&u.actionWrapperDesktop],children:[h(V,{style:[u.iconButton,re&&u.iconButtonDesktop],onPress:()=>s(true),testID:"buoy-routes-sitemap-search-open",accessibilityRole:"button",accessibilityLabel:"Search routes",children:h(to,{size:et,color:v.color.textSecondary})}),h(p,{style:[u.actionLabel,re&&u.actionLabelDesktop],children:"Search"})]})]}),O(c,{style:u.statsGrid,children:[h(Ae,{value:E.total,label:"Total",id:"total"}),h(Ae,{value:E.static,label:"Static",id:"static"}),h(Ae,{value:E.dynamic,label:"Dynamic",id:"dynamic"}),h(Ae,{value:E.catchAll,label:"Catch-All",id:"catch-all"}),h(Ae,{value:E.layouts,label:"Layouts",id:"layouts"}),h(Ae,{value:E.groups,label:"Groups",id:"groups"})]})]}),pe.length===0?h(Ca,{testID:"buoy-routes-sitemap-empty",otto:"map",title:"No routes found",message:"Nothing in the router matches. Clear the search to see the whole tree."}):pe.map(w=>h(_a,{group:w,isExpanded:n.length>0||f.has(w.title),onToggleExpand:()=>we(w.title),onNavigate:xe},w.title)),O(c,{style:u.metaFooter,children:[h(p,{style:u.metaText,testID:"buoy-routes-sitemap-updated",children:N}),h(c,{style:u.sourceBadge,children:h(p,{style:u.sourceText,testID:"buoy-routes-sitemap-source",children:K})})]})]}),h(Pa,{visible:F,onClose:()=>g(false),featureName:"Route Navigation"})]}):h(c,{style:[u.container,e],children:h(c,{style:u.loadingContainer,children:h(p,{style:u.loadingText,testID:"buoy-routes-sitemap-loading",children:C?"Loading routes...":"Route sitemap isn't available on the dashboard \u2014 the route tree lives on the device. Use the Events tab to see navigation here."})})})}function Ae({value:e,label:t,id:o}){return O(c,{style:u.statItem,testID:`buoy-routes-stat-${o}`,accessibilityLabel:`${t}, ${e}`,children:[h(p,{style:u.statValue,testID:`buoy-routes-stat-${o}-value`,children:e}),h(p,{style:u.statLabel,children:t})]})}function _a({group:e,isExpanded:t,onToggleExpand:o,onNavigate:r}){return O(c,{style:u.groupContainer,children:[O(V,{style:u.groupHeader,onPress:o,activeOpacity:.7,testID:so(e.title),accessibilityRole:"button",accessibilityLabel:`${e.title}, ${e.routes.length} routes`,children:[O(c,{style:u.groupHeaderLeft,children:[t?h(oo,{size:14,color:v.color.textSecondary}):h(ro,{size:14,color:v.color.textSecondary}),h(p,{style:u.groupTitle,children:e.title})]}),h(c,{style:u.groupBadge,children:h(p,{style:u.groupCount,testID:`${so(e.title)}-count`,children:e.routes.length})})]}),e.description&&h(c,{style:u.groupDescription,children:h(p,{style:u.groupDescriptionText,children:e.description})}),t&&h(c,{style:u.routesList,children:e.routes.map((a,n)=>h(lo,{route:a,onNavigate:r},`${a.path}-${n}`))})]})}function lo({route:e,depth:t=0,onNavigate:o}){let[r,a]=Le(false),n=e.children.length>0,i=Ga(e.type),d=e.type!=="layout"&&e.type!=="group",s=Ma(e.path),f=n,l=f?r:true;return h(c,{style:[u.routeItem,{marginLeft:t*12}],testID:s,children:O(c,{style:u.routeCard,children:[O(c,{style:u.routeHeader,children:[f?O(V,{style:u.routeHeaderLeft,onPress:()=>a(!r),activeOpacity:.7,testID:`${s}-toggle`,accessibilityRole:"button",accessibilityLabel:`${e.path}, ${e.type}, ${e.children.length} nested`,children:[h(c,{style:u.expandIndicator,children:r?h(oo,{size:14,color:v.color.textSecondary}):h(ro,{size:14,color:v.color.textSecondary})}),h(p,{style:u.routePath,numberOfLines:3,testID:`${s}-path`,children:e.path})]}):O(c,{style:u.routeHeaderLeft,accessible:true,accessibilityLabel:`${e.path}, ${e.type}`,children:[h(c,{style:u.expandIndicator}),h(p,{style:u.routePath,numberOfLines:3,testID:`${s}-path`,children:e.path})]}),O(c,{style:u.routeHeaderActions,children:[n&&h(c,{style:u.childCountBadge,children:h(p,{style:u.childCountText,testID:`${s}-children-count`,children:e.children.length})}),h(c,{style:[u.typeTag,{backgroundColor:`${i}15`,borderColor:`${i}40`}],children:h(p,{style:[u.typeText,{color:i}],testID:`${s}-type`,children:e.type.toUpperCase()})}),h(Ia,{value:e.path,buttonStyle:u.iconAction,testID:`${s}-copy`}),d&&h(V,{style:u.goButton,onPress:()=>o(e),activeOpacity:.7,testID:`${s}-go`,accessibilityRole:"button",accessibilityLabel:`Go to ${e.path}`,children:h(p,{style:u.goButtonText,children:"Go"})})]})]}),l&&n&&h(c,{style:u.childrenContainer,children:e.children.map((m,R)=>h(lo,{route:m,depth:t+1,onNavigate:o},`${m.path}-${R}`))})]})})}function Ga(e){switch(e){case"static":return"#3B82F6";case"dynamic":return"#F59E0B";case"catch-all":return"#EC4899";case"index":return"#10B981";case"layout":return"#8B5CF6";case"group":return"#6366F1";case"not-found":return"#EF4444";default:return"#6B7280"}}var u=ve.create({container:{flex:1,backgroundColor:"transparent"},loadingContainer:{flex:1,justifyContent:"center",alignItems:"center"},loadingText:{color:v.color.textSecondary,fontSize:14,fontFamily:Q,textAlign:"center",lineHeight:20,paddingHorizontal:32,maxWidth:420},header:{flexDirection:"column",padding:8,borderBottomWidth:1,borderBottomColor:v.color.border,gap:12,marginBottom:8},actionsRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,paddingBottom:4},statsGrid:{flexDirection:"row",flexWrap:"wrap",gap:8},statItem:{flexGrow:1,flexShrink:1,flexBasis:"30%",minWidth:90,backgroundColor:v.color.surface,borderRadius:8,paddingVertical:10,paddingHorizontal:12,alignItems:"center"},statValue:{fontSize:18,fontWeight:"800",color:v.color.text,fontFamily:Q},statLabel:{fontSize:10,color:v.color.textTertiary,marginTop:4,fontFamily:Q,textTransform:"uppercase",letterSpacing:.5},actionWrapper:{flex:1,alignItems:"center",justifyContent:"center",gap:4,minWidth:48},actionWrapperDesktop:{gap:8,minWidth:72},actionButtonHeader:{padding:6,borderRadius:4,backgroundColor:v.color.surfaceElevated},actionButtonHeaderDesktop:{padding:12,borderRadius:8,backgroundColor:v.color.surfaceElevated},iconButton:{padding:6,borderRadius:4,alignItems:"center",justifyContent:"center"},iconButtonDesktop:{padding:12,borderRadius:8,backgroundColor:v.color.surfaceElevated},actionLabel:{fontSize:8,color:v.color.textTertiary,fontFamily:Q,textTransform:"uppercase",letterSpacing:.5},actionLabelDesktop:{fontSize:12},refreshButtonDisabled:{opacity:.5},metaFooter:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8,paddingHorizontal:16,paddingVertical:16,marginTop:16,borderTopWidth:1,borderTopColor:v.color.border},metaText:{fontSize:12,color:v.color.textSecondary,fontFamily:Q},sourceBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:v.color.border,backgroundColor:v.color.surface},sourceText:{fontSize:11,color:v.color.textSecondary,textTransform:"capitalize",fontFamily:Q},searchContainer:{flexDirection:"row",alignItems:"center",padding:8,gap:8,borderBottomWidth:1,borderBottomColor:v.color.border},searchInput:{flex:1,color:v.color.text,fontSize:14,fontFamily:Q},clearButton:{padding:4},clearButtonText:{color:v.color.textTertiary,fontSize:18},closeSearchButton:{paddingHorizontal:8,paddingVertical:4},closeSearchText:{color:v.color.accent,fontSize:14,fontWeight:"600",fontFamily:Q},scrollView:{flex:1},scrollContent:{paddingBottom:8},emptyState:{padding:32,alignItems:"center"},emptyText:{color:v.color.textSecondary,fontSize:14,fontFamily:Q},groupContainer:{marginVertical:4},groupHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,paddingHorizontal:16,backgroundColor:v.color.surface,borderLeftWidth:3,borderLeftColor:v.color.fillTertiary},groupHeaderLeft:{flexDirection:"row",alignItems:"center",gap:8,flex:1},groupTitle:{fontSize:12,fontWeight:"700",color:v.color.text,fontFamily:Q,textTransform:"uppercase",letterSpacing:.8},groupBadge:{backgroundColor:"#3B82F615",borderColor:"#3B82F640",borderWidth:1,borderRadius:12,paddingHorizontal:8,paddingVertical:3,minWidth:24,alignItems:"center",justifyContent:"center"},groupCount:{fontSize:11,fontWeight:"600",color:"#3B82F6",fontFamily:Q},routesList:{backgroundColor:"transparent"},groupDescription:{paddingHorizontal:16,paddingVertical:8,marginBottom:8,backgroundColor:v.color.surfaceElevated,borderLeftWidth:3,borderLeftColor:v.color.fillTertiary},groupDescriptionText:{fontSize:11,color:v.color.textSecondary,fontFamily:Q,lineHeight:16},routeItem:{marginBottom:6},routeCard:{backgroundColor:v.color.surface,borderRadius:6,borderWidth:1,borderColor:v.color.border,overflow:"hidden",shadowColor:"#000",shadowOffset:{width:0,height:1},shadowOpacity:.05,shadowRadius:2,elevation:1},routeHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:7,paddingHorizontal:10,gap:8},expandIndicator:{width:18,alignItems:"center"},routeHeaderLeft:{flexDirection:"row",alignItems:"center",gap:8,flex:1},routePath:{fontSize:13,fontWeight:"600",color:v.color.text,fontFamily:Q,flex:1},routeHeaderActions:{flexDirection:"row",alignItems:"center",gap:6},childCountBadge:{backgroundColor:"#6B728015",borderColor:"#6B728040",borderWidth:1,borderRadius:12,paddingHorizontal:7,paddingVertical:2,minWidth:22,alignItems:"center",justifyContent:"center"},childCountText:{fontSize:11,fontWeight:"600",color:v.color.textSecondary,fontFamily:Q},typeTag:{borderRadius:4,paddingHorizontal:6,paddingVertical:2,borderWidth:1},typeText:{fontSize:10,fontWeight:"600",fontFamily:Q},iconAction:{width:28,height:24,borderRadius:4,backgroundColor:v.color.surfaceElevated,borderWidth:1,borderColor:v.color.border,alignItems:"center",justifyContent:"center"},goButton:{height:24,paddingHorizontal:10,borderRadius:4,alignItems:"center",justifyContent:"center",backgroundColor:v.color.accentSoft,borderWidth:1,borderColor:v.color.accentBorder},goButtonText:{fontSize:12,color:v.color.accent,fontFamily:Q,fontWeight:"600"},childrenContainer:{borderLeftWidth:2,borderLeftColor:v.color.border,marginLeft:16,marginRight:8,marginTop:2,marginBottom:8}});import{useState as co,useMemo as tt,useEffect as uo}from"react";import{ChevronDown as Ja,ChevronRight as qa,InlineCopyButton as Ya,ProUpgradeModal as Za,buoyColors as ot,night as J,useSafeAreaInsets as Qa,ToolEmptyState as Xa,monoFont as ce}from"@buoy-gg/shared-ui/web";import{useIsPro as en}from"@buoy-gg/license/web";import{DataViewer as tn}from"@buoy-gg/shared-ui/web/dataViewer";import{useSyncExternalStore as on}from"react";var rn=class{constructor(){this.stack=[];this.actions=null;this.listeners=new Set}getStack(){return this.stack}setStack(e){this.stack=e,this.listeners.forEach(t=>t())}getActions(){return this.actions}setActions(e){this.actions=e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}},M=new rn;var an=[];function po(){let e=on(r=>M.subscribe(r),()=>M.getStack(),()=>an),t=e.find(r=>r.isFocused)??null,o=()=>{let r=M.getActions();if(!r)throw new Error("Mount RouteTracker to capture browser navigation.");return r};return{stack:e,focusedRoute:t,stackDepth:e.length,isAtRoot:!t||t.index===0,isLoaded:e.length>0,error:null,refresh:()=>{},navigateToIndex:r=>o().navigateToIndex(r),navigateToRoute:(r,a)=>o().navigateToRoute?.(r,a)??false,popToIndex:r=>o().popToIndex(r),goBack:()=>o().goBack(),popToTop:()=>o().popToTop()}}import{jsx as B,jsxs as ae}from"react/jsx-runtime";function ho({style:e,injectedStack:t,onAction:o,onCopyValueChange:r}){let a=po(),n=t!=null,i=Qa({minBottom:8}),d=n?t:a.stack,s=n?true:a.isLoaded,f=n?null:a.error,l=tt(()=>d.find(S=>S.isFocused)??null,[d]),m=d.length,R=m<=1,F=S=>o?o("navigateToIndex",{index:S}):a.navigateToIndex(S),g=S=>o?o("popToIndex",{index:S}):a.popToIndex(S),x=()=>o?o("goBack"):a.goBack(),L=()=>o?o("popToTop"):a.popToTop(),[I,E]=co(null),[W,C]=co(false),A=en();uo(()=>{W&&A&&C(false)},[W,A]);let q=tt(()=>{let S=d.map(N=>({pathname:N.pathname,name:N.name,params:N.params,isFocused:N.isFocused}));return JSON.stringify(S,null,2)},[d]);uo(()=>{r?.(q)},[q,r]);let P=tt(()=>I!==null&&d[I]?d[I]:l,[I,d,l]),Y=tt(()=>I!==null&&d[I]&&!d[I].isFocused,[I,d]);if(!s)return B(c,{style:[y.container,e],children:B(c,{style:y.loadingContainer,children:B(p,{style:y.loadingText,testID:"buoy-routes-stack-loading",children:"Loading navigation stack..."})})});if(f)return B(c,{style:[y.container,e],children:ae(c,{style:y.errorContainer,testID:"buoy-routes-stack-error",children:[B(p,{style:y.errorText,children:"Error loading stack"}),B(p,{style:y.errorDetail,testID:"buoy-routes-stack-error-detail",children:f.message})]})});if(d.length===0)return B(c,{style:[y.container,e],children:B(Xa,{testID:"buoy-routes-stack-empty",otto:"walking",title:"No navigation stack",message:"Navigate to a route to see the stack"})});let X=(S,N,K,pe)=>{if(o){let w=globalThis.window?.confirm;(!w||w(`${S}
|
|
6
|
+
${Ge}`)):_.alert(Ne,`${w.path} needs a value for ${_e}, and this platform can't ask for one here.`);return}_.prompt(Ne,Ge,[{text:"Cancel",style:"cancel"},{text:D<Fe.length-1?"Next":"Navigate",onPress:H=>{if(H&&H.trim()){let be={...ee,[Ce]:H.trim()};ue(w,D+1,be)}else _.alert("Invalid Value","Please enter a value for the parameter")}}],"plain-text")},[L]),xe=He((w,D)=>{if(a){a(w);return}if(!x&&!D?.bypassPro){g(true);return}if(w.type==="layout"||w.type==="group"){_.alert("Cannot Navigate",`${w.type==="layout"?"Layouts":"Route groups"} are not navigable routes`);return}if(w.type==="dynamic"||w.type==="catch-all"){if(w.params.length===0){try{L.push(w.path)}catch(ee){_.alert("Navigation Error",String(ee))}return}ue(w);return}try{L.push(w.path)}catch(ee){_.alert("Navigation Error",String(ee))}},[L,ue,x,a]),de=He(()=>{xe(Ka,{bypassPro:true})},[xe]),S=He(()=>{h||(R(true),P(),setTimeout(()=>R(false),400))},[h,P]),N=Qe(()=>Y?`Updated ${Da(Y)}`:"Awaiting route data",[Y]),K=Qe(()=>X?`Source: ${X}`:"Source: unknown",[X]),pe=Qe(()=>n&&A.length>0?[{title:"Search Results",icon:"",routes:A}]:I,[n,A,I]);return W?O(c,{style:[u.container,e],children:[d&&O(c,{style:u.searchContainer,testID:"buoy-routes-sitemap-search-field",children:[m(oo,{size:16,color:v.color.textTertiary}),m(_t,{style:u.searchInput,placeholder:"Search routes...",placeholderTextColor:v.color.placeholder,value:n,onChangeText:i,autoCapitalize:"none",autoCorrect:false,autoFocus:true,testID:"buoy-routes-sitemap-search",accessibilityLabel:"Search routes"}),n.length>0&&m(V,{onPress:()=>i(""),style:u.clearButton,testID:"buoy-routes-sitemap-search-clear",accessibilityRole:"button",accessibilityLabel:"Clear route search",children:m(p,{style:u.clearButtonText,children:"\u2715"})}),m(V,{style:u.closeSearchButton,onPress:()=>{s(false),i("")},testID:"buoy-routes-sitemap-search-done",accessibilityRole:"button",accessibilityLabel:"Done searching routes",children:m(p,{style:u.closeSearchText,children:"Done"})})]}),O(qe,{keyboardShouldPersistTaps:"handled",testID:"buoy-routes-sitemap-scroll",style:u.scrollView,contentContainerStyle:u.scrollContent,children:[!d&&O(c,{style:u.header,children:[O(c,{style:u.actionsRow,children:[O(c,{style:[u.actionWrapper,re&&u.actionWrapperDesktop],children:[m(V,{style:[u.iconButton,re&&u.iconButtonDesktop],onPress:de,accessibilityLabel:"Go to home route",accessibilityRole:"button",testID:"buoy-routes-sitemap-home",children:m(ka,{size:et,color:v.color.textSecondary})}),m(p,{style:[u.actionLabel,re&&u.actionLabelDesktop],children:"Home"})]}),O(c,{style:[u.actionWrapper,re&&u.actionWrapperDesktop],children:[m(Ba,{value:j,testID:"buoy-routes-sitemap-copy",size:re?et:14,buttonStyle:re?u.actionButtonHeaderDesktop:u.actionButtonHeader}),m(p,{style:[u.actionLabel,re&&u.actionLabelDesktop],children:"Copy"})]}),O(c,{style:[u.actionWrapper,re&&u.actionWrapperDesktop],children:[m(V,{style:[u.iconButton,re&&u.iconButtonDesktop,h&&u.refreshButtonDisabled],onPress:S,disabled:h,testID:"buoy-routes-sitemap-refresh",accessibilityRole:"button",accessibilityLabel:"Refresh route tree",children:m(Ea,{size:et,color:h?v.color.textTertiary:v.color.textSecondary})}),m(p,{style:[u.actionLabel,re&&u.actionLabelDesktop],children:"Refresh"})]}),O(c,{style:[u.actionWrapper,re&&u.actionWrapperDesktop],children:[m(V,{style:[u.iconButton,re&&u.iconButtonDesktop],onPress:()=>s(true),testID:"buoy-routes-sitemap-search-open",accessibilityRole:"button",accessibilityLabel:"Search routes",children:m(oo,{size:et,color:v.color.textSecondary})}),m(p,{style:[u.actionLabel,re&&u.actionLabelDesktop],children:"Search"})]})]}),O(c,{style:u.statsGrid,children:[m(Ae,{value:E.total,label:"Total",id:"total"}),m(Ae,{value:E.static,label:"Static",id:"static"}),m(Ae,{value:E.dynamic,label:"Dynamic",id:"dynamic"}),m(Ae,{value:E.catchAll,label:"Catch-All",id:"catch-all"}),m(Ae,{value:E.layouts,label:"Layouts",id:"layouts"}),m(Ae,{value:E.groups,label:"Groups",id:"groups"})]})]}),pe.length===0?m(Ca,{testID:"buoy-routes-sitemap-empty",otto:"map",title:"No routes found",message:"Nothing in the router matches. Clear the search to see the whole tree."}):pe.map(w=>m(_a,{group:w,isExpanded:n.length>0||f.has(w.title),onToggleExpand:()=>we(w.title),onNavigate:xe},w.title)),O(c,{style:u.metaFooter,children:[m(p,{style:u.metaText,testID:"buoy-routes-sitemap-updated",children:N}),m(c,{style:u.sourceBadge,children:m(p,{style:u.sourceText,testID:"buoy-routes-sitemap-source",children:K})})]})]}),m(Pa,{visible:F,onClose:()=>g(false),featureName:"Route Navigation"})]}):m(c,{style:[u.container,e],children:m(c,{style:u.loadingContainer,children:m(p,{style:u.loadingText,testID:"buoy-routes-sitemap-loading",children:C?"Loading routes...":"Route sitemap isn't available on the dashboard \u2014 the route tree lives on the device. Use the Events tab to see navigation here."})})})}function Ae({value:e,label:t,id:o}){return O(c,{style:u.statItem,testID:`buoy-routes-stat-${o}`,accessibilityLabel:`${t}, ${e}`,children:[m(p,{style:u.statValue,testID:`buoy-routes-stat-${o}-value`,children:e}),m(p,{style:u.statLabel,children:t})]})}function _a({group:e,isExpanded:t,onToggleExpand:o,onNavigate:r}){return O(c,{style:u.groupContainer,children:[O(V,{style:u.groupHeader,onPress:o,activeOpacity:.7,testID:lo(e.title),accessibilityRole:"button",accessibilityLabel:`${e.title}, ${e.routes.length} routes`,children:[O(c,{style:u.groupHeaderLeft,children:[t?m(ro,{size:14,color:v.color.textSecondary}):m(ao,{size:14,color:v.color.textSecondary}),m(p,{style:u.groupTitle,children:e.title})]}),m(c,{style:u.groupBadge,children:m(p,{style:u.groupCount,testID:`${lo(e.title)}-count`,children:e.routes.length})})]}),e.description&&m(c,{style:u.groupDescription,children:m(p,{style:u.groupDescriptionText,children:e.description})}),t&&m(c,{style:u.routesList,children:e.routes.map((a,n)=>m(co,{route:a,onNavigate:r},`${a.path}-${n}`))})]})}function co({route:e,depth:t=0,onNavigate:o}){let[r,a]=Le(false),n=e.children.length>0,i=Ga(e.type),d=e.type!=="layout"&&e.type!=="group",s=Ma(e.path),f=n,l=f?r:true;return m(c,{style:[u.routeItem,{marginLeft:t*12}],testID:s,children:O(c,{style:u.routeCard,children:[O(c,{style:u.routeHeader,children:[f?O(V,{style:u.routeHeaderLeft,onPress:()=>a(!r),activeOpacity:.7,testID:`${s}-toggle`,accessibilityRole:"button",accessibilityLabel:`${e.path}, ${e.type}, ${e.children.length} nested`,children:[m(c,{style:u.expandIndicator,children:r?m(ro,{size:14,color:v.color.textSecondary}):m(ao,{size:14,color:v.color.textSecondary})}),m(p,{style:u.routePath,numberOfLines:3,testID:`${s}-path`,children:e.path})]}):O(c,{style:u.routeHeaderLeft,accessible:true,accessibilityLabel:`${e.path}, ${e.type}`,children:[m(c,{style:u.expandIndicator}),m(p,{style:u.routePath,numberOfLines:3,testID:`${s}-path`,children:e.path})]}),O(c,{style:u.routeHeaderActions,children:[n&&m(c,{style:u.childCountBadge,children:m(p,{style:u.childCountText,testID:`${s}-children-count`,children:e.children.length})}),m(c,{style:[u.typeTag,{backgroundColor:`${i}15`,borderColor:`${i}40`}],children:m(p,{style:[u.typeText,{color:i}],testID:`${s}-type`,children:e.type.toUpperCase()})}),m(Ia,{value:e.path,buttonStyle:u.iconAction,testID:`${s}-copy`}),d&&m(V,{style:u.goButton,onPress:()=>o(e),activeOpacity:.7,testID:`${s}-go`,accessibilityRole:"button",accessibilityLabel:`Go to ${e.path}`,children:m(p,{style:u.goButtonText,children:"Go"})})]})]}),l&&n&&m(c,{style:u.childrenContainer,children:e.children.map((h,R)=>m(co,{route:h,depth:t+1,onNavigate:o},`${h.path}-${R}`))})]})})}function Ga(e){switch(e){case"static":return"#3B82F6";case"dynamic":return"#F59E0B";case"catch-all":return"#EC4899";case"index":return"#10B981";case"layout":return"#8B5CF6";case"group":return"#6366F1";case"not-found":return"#EF4444";default:return"#6B7280"}}var u=ve.create({container:{flex:1,backgroundColor:"transparent"},loadingContainer:{flex:1,justifyContent:"center",alignItems:"center"},loadingText:{color:v.color.textSecondary,fontSize:14,fontFamily:Q,textAlign:"center",lineHeight:20,paddingHorizontal:32,maxWidth:420},header:{flexDirection:"column",padding:8,borderBottomWidth:1,borderBottomColor:v.color.border,gap:12,marginBottom:8},actionsRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,paddingBottom:4},statsGrid:{flexDirection:"row",flexWrap:"wrap",gap:8},statItem:{flexGrow:1,flexShrink:1,flexBasis:"30%",minWidth:90,backgroundColor:v.color.surface,borderRadius:8,paddingVertical:10,paddingHorizontal:12,alignItems:"center"},statValue:{fontSize:18,fontWeight:"800",color:v.color.text,fontFamily:Q},statLabel:{fontSize:10,color:v.color.textTertiary,marginTop:4,fontFamily:Q,textTransform:"uppercase",letterSpacing:.5},actionWrapper:{flex:1,alignItems:"center",justifyContent:"center",gap:4,minWidth:48},actionWrapperDesktop:{gap:8,minWidth:72},actionButtonHeader:{padding:6,borderRadius:4,backgroundColor:v.color.surfaceElevated},actionButtonHeaderDesktop:{padding:12,borderRadius:8,backgroundColor:v.color.surfaceElevated},iconButton:{padding:6,borderRadius:4,alignItems:"center",justifyContent:"center"},iconButtonDesktop:{padding:12,borderRadius:8,backgroundColor:v.color.surfaceElevated},actionLabel:{fontSize:8,color:v.color.textTertiary,fontFamily:Q,textTransform:"uppercase",letterSpacing:.5},actionLabelDesktop:{fontSize:12},refreshButtonDisabled:{opacity:.5},metaFooter:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8,paddingHorizontal:16,paddingVertical:16,marginTop:16,borderTopWidth:1,borderTopColor:v.color.border},metaText:{fontSize:12,color:v.color.textSecondary,fontFamily:Q},sourceBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:v.color.border,backgroundColor:v.color.surface},sourceText:{fontSize:11,color:v.color.textSecondary,textTransform:"capitalize",fontFamily:Q},searchContainer:{flexDirection:"row",alignItems:"center",padding:8,gap:8,borderBottomWidth:1,borderBottomColor:v.color.border},searchInput:{flex:1,color:v.color.text,fontSize:14,fontFamily:Q},clearButton:{padding:4},clearButtonText:{color:v.color.textTertiary,fontSize:18},closeSearchButton:{paddingHorizontal:8,paddingVertical:4},closeSearchText:{color:v.color.accent,fontSize:14,fontWeight:"600",fontFamily:Q},scrollView:{flex:1},scrollContent:{paddingBottom:8},emptyState:{padding:32,alignItems:"center"},emptyText:{color:v.color.textSecondary,fontSize:14,fontFamily:Q},groupContainer:{marginVertical:4},groupHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,paddingHorizontal:16,backgroundColor:v.color.surface,borderLeftWidth:3,borderLeftColor:v.color.fillTertiary},groupHeaderLeft:{flexDirection:"row",alignItems:"center",gap:8,flex:1},groupTitle:{fontSize:12,fontWeight:"700",color:v.color.text,fontFamily:Q,textTransform:"uppercase",letterSpacing:.8},groupBadge:{backgroundColor:"#3B82F615",borderColor:"#3B82F640",borderWidth:1,borderRadius:12,paddingHorizontal:8,paddingVertical:3,minWidth:24,alignItems:"center",justifyContent:"center"},groupCount:{fontSize:11,fontWeight:"600",color:"#3B82F6",fontFamily:Q},routesList:{backgroundColor:"transparent"},groupDescription:{paddingHorizontal:16,paddingVertical:8,marginBottom:8,backgroundColor:v.color.surfaceElevated,borderLeftWidth:3,borderLeftColor:v.color.fillTertiary},groupDescriptionText:{fontSize:11,color:v.color.textSecondary,fontFamily:Q,lineHeight:16},routeItem:{marginBottom:6},routeCard:{backgroundColor:v.color.surface,borderRadius:6,borderWidth:1,borderColor:v.color.border,overflow:"hidden",shadowColor:"#000",shadowOffset:{width:0,height:1},shadowOpacity:.05,shadowRadius:2,elevation:1},routeHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:7,paddingHorizontal:10,gap:8},expandIndicator:{width:18,alignItems:"center"},routeHeaderLeft:{flexDirection:"row",alignItems:"center",gap:8,flex:1},routePath:{fontSize:13,fontWeight:"600",color:v.color.text,fontFamily:Q,flex:1},routeHeaderActions:{flexDirection:"row",alignItems:"center",gap:6},childCountBadge:{backgroundColor:"#6B728015",borderColor:"#6B728040",borderWidth:1,borderRadius:12,paddingHorizontal:7,paddingVertical:2,minWidth:22,alignItems:"center",justifyContent:"center"},childCountText:{fontSize:11,fontWeight:"600",color:v.color.textSecondary,fontFamily:Q},typeTag:{borderRadius:4,paddingHorizontal:6,paddingVertical:2,borderWidth:1},typeText:{fontSize:10,fontWeight:"600",fontFamily:Q},iconAction:{width:28,height:24,borderRadius:4,backgroundColor:v.color.surfaceElevated,borderWidth:1,borderColor:v.color.border,alignItems:"center",justifyContent:"center"},goButton:{height:24,paddingHorizontal:10,borderRadius:4,alignItems:"center",justifyContent:"center",backgroundColor:v.color.accentSoft,borderWidth:1,borderColor:v.color.accentBorder},goButtonText:{fontSize:12,color:v.color.accent,fontFamily:Q,fontWeight:"600"},childrenContainer:{borderLeftWidth:2,borderLeftColor:v.color.border,marginLeft:16,marginRight:8,marginTop:2,marginBottom:8}});import{useState as uo,useMemo as tt,useEffect as po}from"react";import{ChevronDown as Ja,ChevronRight as qa,InlineCopyButton as Ya,ProUpgradeModal as Za,buoyColors as ot,night as J,useSafeAreaInsets as Qa,ToolEmptyState as Xa,monoFont as ce}from"@buoy-gg/shared-ui/web";import{useIsPro as en}from"@buoy-gg/license/web";import{DataViewer as tn}from"@buoy-gg/shared-ui/web/dataViewer";import{useSyncExternalStore as on}from"react";var rn=class{constructor(){this.stack=[];this.actions=null;this.listeners=new Set}getStack(){return this.stack}setStack(e){this.stack=e,this.listeners.forEach(t=>t())}getActions(){return this.actions}setActions(e){this.actions=e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}},M=new rn;var an=[];function mo(){let e=on(r=>M.subscribe(r),()=>M.getStack(),()=>an),t=e.find(r=>r.isFocused)??null,o=()=>{let r=M.getActions();if(!r)throw new Error("Mount RouteTracker to capture browser navigation.");return r};return{stack:e,focusedRoute:t,stackDepth:e.length,isAtRoot:!t||t.index===0,isLoaded:e.length>0,error:null,refresh:()=>{},navigateToIndex:r=>o().navigateToIndex(r),navigateToRoute:(r,a)=>o().navigateToRoute?.(r,a)??false,popToIndex:r=>o().popToIndex(r),goBack:()=>o().goBack(),popToTop:()=>o().popToTop()}}import{jsx as B,jsxs as ae}from"react/jsx-runtime";function ho({style:e,injectedStack:t,onAction:o,onCopyValueChange:r}){let a=mo(),n=t!=null,i=Qa({minBottom:8}),d=n?t:a.stack,s=n?true:a.isLoaded,f=n?null:a.error,l=tt(()=>d.find(S=>S.isFocused)??null,[d]),h=d.length,R=h<=1,F=S=>o?o("navigateToIndex",{index:S}):a.navigateToIndex(S),g=S=>o?o("popToIndex",{index:S}):a.popToIndex(S),x=()=>o?o("goBack"):a.goBack(),L=()=>o?o("popToTop"):a.popToTop(),[I,E]=uo(null),[W,C]=uo(false),A=en();po(()=>{W&&A&&C(false)},[W,A]);let q=tt(()=>{let S=d.map(N=>({pathname:N.pathname,name:N.name,params:N.params,isFocused:N.isFocused}));return JSON.stringify(S,null,2)},[d]);po(()=>{r?.(q)},[q,r]);let P=tt(()=>I!==null&&d[I]?d[I]:l,[I,d,l]),Y=tt(()=>I!==null&&d[I]&&!d[I].isFocused,[I,d]);if(!s)return B(c,{style:[y.container,e],children:B(c,{style:y.loadingContainer,children:B(p,{style:y.loadingText,testID:"buoy-routes-stack-loading",children:"Loading navigation stack..."})})});if(f)return B(c,{style:[y.container,e],children:ae(c,{style:y.errorContainer,testID:"buoy-routes-stack-error",children:[B(p,{style:y.errorText,children:"Error loading stack"}),B(p,{style:y.errorDetail,testID:"buoy-routes-stack-error-detail",children:f.message})]})});if(d.length===0)return B(c,{style:[y.container,e],children:B(Xa,{testID:"buoy-routes-stack-empty",otto:"walking",title:"No navigation stack",message:"Navigate to a route to see the stack"})});let X=(S,N,K,pe)=>{if(o){let w=globalThis.window?.confirm;(!w||w(`${S}
|
|
7
7
|
|
|
8
|
-
${N}`))&&pe();return}_.alert(S,N,[{text:"Cancel",style:"cancel"},{text:K,style:"destructive",onPress:pe}])},j=()=>{if(!A){C(true);return}if(R){_.alert("Cannot Go Back","Already at the root of the stack");return}x()},we=()=>{if(!A){C(true);return}if(R){_.alert("Already at Top","Stack only has one screen");return}X("Pop to Top","This will remove all screens except the root screen.","Pop to Top",L)},ue=S=>{E(I===S?null:S)},xe=()=>{if(!A){C(true);return}if(P){if(P.isFocused){_.alert("Already There","This route is already visible");return}F(P.index)}},de=()=>{if(!A){C(true);return}if(!P)return;if(P.isFocused){_.alert("Cannot Pop","Selected route is already visible");return}if(P.index===m-1){_.alert("Cannot Pop","No screens above selected route");return}let S=m-1-P.index,N=P.index;X("Pop to Route",`Remove ${S} screen${S!==1?"s":""} above ${P.pathname}?`,"Pop",()=>g(N))};return ae(c,{style:[y.container,e],children:[B(qe,{keyboardShouldPersistTaps:"handled",testID:"buoy-routes-stack-scroll",style:y.stackScroll,contentContainerStyle:[y.stackContent,{paddingBottom:y.stackContent.padding+i.bottom}],children:[...d].reverse().map((S,N)=>{let K=d.length-1-N,pe=I===K,w=Object.keys(S.params).length>0,D=Ua(K);return B(c,{style:y.stackItemWrapper,testID:D,children:ae(c,{style:[y.stackItem,pe&&y.stackItemSelected],children:[ae(c,{style:y.stackItemHeader,children:[ae(V,{style:y.stackItemToggle,onPress:()=>ue(K),activeOpacity:.7,testID:`${D}-toggle`,accessibilityRole:"button",accessibilityLabel:`${S.pathname}, ${S.isFocused?"focused":"mounted"}, position ${K} of ${m-1}`,children:[B(c,{style:y.expandIndicator,children:pe?B(Ja,{size:14,color:J.color.textSecondary}):B(qa,{size:14,color:J.color.textSecondary})}),B(p,{style:y.stackItemPath,numberOfLines:1,testID:`${D}-path`,children:S.pathname})]}),B(Ya,{value:S.pathname,buttonStyle:y.copyRouteButton,testID:`${D}-copy`}),B(V,{onPress:()=>ue(K),activeOpacity:.7,accessible:false,style:[y.statusBadge,{backgroundColor:S.isFocused?`${ot.success}15`:"#3B82F615",borderColor:S.isFocused?`${ot.success}40`:"#3B82F640"}],children:B(p,{style:[y.statusBadgeText,{color:S.isFocused?ot.success:"#3B82F6"}],testID:`${D}-status`,children:S.isFocused?"FOCUSED":"MOUNTED"})})]}),pe&&ae(c,{style:y.expandedContent,children:[ae(c,{style:y.detailRow,children:[B(p,{style:y.detailLabel,children:"Route Name:"}),B(p,{style:y.detailValue,testID:`${D}-name`,children:S.name})]}),ae(c,{style:y.detailRow,children:[B(p,{style:y.detailLabel,children:"Position:"}),ae(p,{style:y.detailValue,testID:`${D}-position`,children:[K," / ",m-1]})]}),w&&B(c,{style:y.dataViewerContainer,children:B(tn,{title:"Parameters",data:S.params,showTypeFilter:false})}),ae(c,{style:y.actionsRow,children:[ae(c,{style:y.actionWrapper,children:[B(V,{style:[y.actionButton,R&&y.actionButtonDisabled],onPress:j,disabled:R,testID:`${D}-back`,accessibilityRole:"button",accessibilityLabel:"Go back one screen",children:B(p,{style:[y.actionButtonText,R&&y.actionButtonTextDisabled],children:"Back"})}),B(p,{style:y.helpText,children:"Go back one screen"})]}),ae(c,{style:y.actionWrapper,children:[B(V,{style:[y.actionButton,S.isFocused&&y.actionButtonDisabled],onPress:xe,disabled:S.isFocused,testID:`${D}-go`,accessibilityRole:"button",accessibilityLabel:`Navigate to ${S.pathname}`,children:B(p,{style:[y.actionButtonText,S.isFocused&&y.actionButtonTextDisabled],children:"Go"})}),B(p,{style:y.helpText,children:"Navigate to this route"})]}),ae(c,{style:y.actionWrapper,children:[B(V,{style:[y.actionButton,(S.isFocused||K===m-1)&&y.actionButtonDisabled],onPress:de,disabled:S.isFocused||K===m-1,testID:`${D}-pop-to`,accessibilityRole:"button",accessibilityLabel:`Remove screens above ${S.pathname}`,children:B(p,{style:[y.actionButtonText,(S.isFocused||K===m-1)&&y.actionButtonTextDisabled],children:"Pop To"})}),B(p,{style:y.helpText,children:"Remove screens above this"})]})]})]})]})},`stack-${K}-${S.key}`)})}),B(Za,{visible:W,onClose:()=>C(false),featureName:"Stack Navigation"})]})}var y=ve.create({container:{flex:1,backgroundColor:"transparent"},loadingContainer:{flex:1,justifyContent:"center",alignItems:"center",padding:32},loadingText:{color:J.color.textSecondary,fontSize:14,fontFamily:ce},errorContainer:{flex:1,justifyContent:"center",alignItems:"center",padding:32},errorText:{color:ot.error,fontSize:16,fontWeight:"600",fontFamily:ce,marginBottom:8},errorDetail:{color:J.color.textSecondary,fontSize:12,fontFamily:ce,textAlign:"center"},emptyContainer:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyText:{color:J.color.text,fontSize:16,fontWeight:"600",fontFamily:ce,marginBottom:8},emptySubtext:{color:J.color.textSecondary,fontSize:14,fontFamily:ce,textAlign:"center"},stackScroll:{flex:1},stackContent:{padding:8},stackItemWrapper:{marginBottom:6},stackItem:{backgroundColor:J.color.surface,borderRadius:6,borderWidth:1,borderColor:J.color.border,overflow:"hidden"},stackItemSelected:{borderColor:J.color.accent,borderWidth:2},stackItemHeader:{flexDirection:"row",alignItems:"center",paddingVertical:10,paddingHorizontal:12,gap:8},stackItemToggle:{flex:1,flexDirection:"row",alignItems:"center",gap:8},expandIndicator:{width:20,alignItems:"center"},stackItemPath:{fontSize:13,fontWeight:"600",color:J.color.text,fontFamily:ce,flex:1},copyRouteButton:{padding:4,marginLeft:4},statusBadge:{borderRadius:4,paddingHorizontal:6,paddingVertical:2,borderWidth:1},statusBadgeText:{fontSize:10,fontWeight:"600",fontFamily:ce},expandedContent:{paddingHorizontal:12,paddingTop:8,paddingBottom:12,borderTopWidth:1,borderTopColor:J.color.border},detailRow:{marginBottom:8},detailLabel:{fontSize:10,color:J.color.textSecondary,fontFamily:ce,marginBottom:2},detailValue:{fontSize:12,color:J.color.text,fontFamily:ce},dataViewerContainer:{marginTop:4,marginHorizontal:-12,marginBottom:8},actionsRow:{flexDirection:"row",gap:6,marginTop:12},actionWrapper:{flex:1},actionButton:{backgroundColor:J.color.surfaceElevated,paddingVertical:8,paddingHorizontal:8,borderRadius:6,alignItems:"center"},actionButtonDisabled:{opacity:.5},actionButtonText:{fontSize:12,fontWeight:"600",color:J.color.text,fontFamily:ce},actionButtonTextDisabled:{color:J.color.textTertiary},helpText:{fontSize:9,color:J.color.textSecondary,fontFamily:ce,textAlign:"center",marginTop:4,lineHeight:12}});import{useCallback as nn}from"react";import{Navigation as sn,night as Rt,EVENT_LIST_PRESET as ln,monoFont as mo}from"@buoy-gg/shared-ui/web";import{memo as cn,useMemo as fe}from"react";import{CompactRow as un,RelativeTime as dn,buoyColors as fo,night as rt,monoFont as go}from"@buoy-gg/shared-ui/web";import{jsx as Me}from"react/jsx-runtime";function pn(e){return e.pathname==="/"?"home":yt(e.pathname,e.segments)?"dynamic":e.params&&Object.keys(e.params).length>0?"with-params":"default"}function hn(e){switch(e){case"home":return fo.success;case"dynamic":return rt.color.accent;case"with-params":return fo.warning;default:return rt.color.textSecondary}}function mn(e){switch(e){case"home":return"Home";case"dynamic":return"Dynamic";case"with-params":return"Params";default:return"Static"}}function fn(e){if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/6e4),o=Math.floor(e%6e4/1e3);return o>0?`${t}m ${o}s`:`${t}m`}function gn(e){let t=[];e.timeSincePrevious!==void 0&&e.timeSincePrevious>0&&t.push(fn(e.timeSincePrevious));let o=e.segments?.length||0;return o>0&&t.push(`depth ${o}`),t.join(" \xB7 ")||"root"}function yn(e){if(e.params&&Object.keys(e.params).length>0){let t=Object.keys(e.params).length;return`${t} PARAM${t!==1?"S":""}`}}var yo=cn(function({event:e,visitNumber:t,isExpanded:o,onPress:r,onNavigate:a,index:n}){let i=fe(()=>pn(e),[e]),d=fe(()=>yt(e.pathname,e.segments),[e.pathname,e.segments]),s=fe(()=>hn(i),[i]),f=fe(()=>mn(i),[i]),l=fe(()=>gn(e),[e]),m=fe(()=>yn(e),[e]),R=fe(()=>Va(e.pathname,t),[e.pathname,t]),F=fe(()=>`${e.pathname}, ${f}, ${l}`,[e.pathname,f,l]),g=fe(()=>{if(o)return Me(gt,{event:e,visitNumber:t,routeTemplate:d})},[o,e,t,d]),x=fe(()=>{if(a)return Me(V,{style:bo.goButton,onPress:()=>a(Zt(e.pathname,e.params)),testID:`${R}-go`,accessibilityRole:"button",accessibilityLabel:`Go to ${e.pathname}`,children:Me(p,{style:bo.goButtonText,children:"Go"})})},[a,e.pathname,R]);return Me(un,{statusDotColor:s,statusLabel:f,statusSublabel:l,primaryText:e.pathname,badgeText:m,badgeColor:s,trailingAction:x,bottomRightText:Me(dn,{timestamp:e.timestamp}),showChevron:true,expandedContent:g,isExpanded:o,expandedGlowColor:s,onPress:()=>r(n),testID:R,statusTestID:`${R}-status`,statusSublabelTestID:`${R}-sublabel`,accessibilityLabel:F})}),bo=ve.create({badgeText:{fontSize:11,fontWeight:"600",fontFamily:go},goButton:{backgroundColor:rt.color.accent,paddingHorizontal:8,paddingVertical:4,borderRadius:4},goButtonText:{fontSize:10,fontWeight:"600",color:rt.color.onAccent,fontFamily:go}});import{jsx as Ue,jsxs as bn}from"react/jsx-runtime";function vn({events:e,visitCounts:t,onNavigate:o,onSelectEvent:r}){let a=nn(n=>{let i=e[n];i&&r(i,t.get(i)||1)},[e,t,r]);return e.length===0?bn(c,{style:at.emptyState,testID:"buoy-routes-empty",children:[Ue(sn,{size:48,color:Rt.color.textTertiary}),Ue(p,{style:at.emptyTitle,testID:"buoy-routes-empty-title",children:"No events yet"}),Ue(p,{style:at.emptySubtitle,testID:"buoy-routes-empty-subtitle",children:"Navigation events will appear here"})]}):Ue(jt,{keyboardShouldPersistTaps:"handled",testID:"buoy-routes-timeline",contentContainerStyle:at.listContent,data:e,keyExtractor:n=>`${n.timestamp}-${n.pathname}`,renderItem:({item:n,index:i})=>Ue(yo,{event:n,visitNumber:t.get(n)||1,isExpanded:false,index:i,onPress:a,onNavigate:o}),showsVerticalScrollIndicator:true,...ln})}var at=ve.create({listContent:{paddingVertical:8},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:Rt.color.text,fontSize:16,fontWeight:"600",marginTop:16,marginBottom:8,fontFamily:mo,letterSpacing:.5,textTransform:"uppercase"},emptySubtitle:{color:Rt.color.textSecondary,fontSize:14,textAlign:"center",fontFamily:mo}});import{Fragment as xn,jsx as k,jsxs as ie}from"react/jsx-runtime";var kt=_r(),Sn={parse:e=>e==="routes"||e==="events"||e==="stack"?e:void 0,serialize:e=>e},wn={parse:e=>e==="true",serialize:e=>e.toString()},Cn={parse:e=>new Set(JSON.parse(e)),serialize:e=>JSON.stringify(Array.from(e))};function vo(e,t){if(!e||!e.routes)return null;for(let o of e.routes){if(o.name===t)return[o.name];if(o.state){let r=vo(o.state,t);if(r)return[o.name,...r]}}return null}function Tn(e,t){if(e.length===0)return null;let o=t&&Object.keys(t).length>0?t:void 0;if(e.length===1)return kt.navigate(o?{name:e[0],params:o}:{name:e[0]});let r=o?{screen:e[e.length-1],params:o}:{screen:e[e.length-1]};for(let a=e.length-2;a>=1;a--)r={screen:e[a],params:r};return kt.navigate({name:e[0],params:r})}function It({visible:e,onClose:t,onBack:o,onMinimize:r,enableSharedModalDimensions:a=false,inline:n=false,remote:i}){let d=Gr(),s=void 0,f=ct.OS==="web"||Jr(),[l,m]=pt(We.routeEvents.activeTab(),"events",Sn),[R,F]=ke(false),[g,x]=ke(""),L=la(),I=sa("routeEvents.entries");Wt(()=>{R&&L&&F(false)},[R,L]);let[E,W]=pt(We.routeEvents.isMonitoring(),true,wn),{events:C,clearEvents:A,isListening:q}=Yt({enabled:E}),P=E&&q;Wt(()=>{me.setBootCapture(E)},[E]);let[Y,X]=ke(false),[j,we]=ke(null),[ue,xe]=ke(1),[de,S]=ke(""),[N,K]=pt(We.routeEvents.eventFilters(),new Set(["/_sitemap","/api","/__dev"]),Cn),pe=Oo(null),w=he(b=>{},[]),D=he(b=>{try{if(i){if(!i.onNavigatePath)return;if(!L&&b!=="/"){F(true);return}i.onNavigatePath(b);return}if(f)d.push(b);else if(s){let{pathname:$,params:te}=ba(b),ge=$.startsWith("/")?$.slice(1):$,Te=Object.keys(te).length>0,Re=s.getRootState?.();if(Re){let Je=vo(Re,ge);if(Je){let Ft=Tn(Je,te);if(Ft){s.dispatch(Ft);return}}}s.dispatch(kt.navigate(Te?{name:ge,params:te}:{name:ge}))}else _.alert("Navigation Unavailable","No Expo Router or React Navigation container was found in this app.")}catch($){_.alert("Navigation Error",String($))}},[d,s,f,i,L]),ee=he(()=>{W(b=>!b)},[]),Fe=he(()=>{if(C.length!==0){if(!L){F(true);return}A()}},[C.length,L,A]),Ce=he(b=>{K($=>{let te=new Set($);return te.has(b)?te.delete(b):te.add(b),te})},[]),_e=he(b=>{K($=>new Set([...$,b]))},[]),Ne=he(()=>{X(!Y)},[Y]),Ge=he((b,$)=>{we(b),xe($)},[]),nt=he(()=>{we(null)},[]),H=he(b=>{we(null),m(b)},[]),be=Ie(()=>{let b=new Set;return C.forEach($=>{$.pathname&&b.add($.pathname)}),Array.from(b).sort()},[C]),se=Ie(()=>C.filter(b=>{if(!b.pathname||Array.from(N).some($=>b.pathname.includes($)))return false;if(de.trim()){let $=de.toLowerCase(),te=b.pathname.toLowerCase().includes($),ge=Object.entries(b.params||{}).some(([Te,Re])=>{let Je=Array.isArray(Re)?Re.join(" "):Re;return Te.toLowerCase().includes($)||Je.toLowerCase().includes($)});return te||ge}return true}),[C,N,de]),Eo=Ie(()=>se.slice(0,I),[se,I]),it=Ie(()=>Math.max(0,se.length-I),[se.length,I]),st=Ie(()=>{let b=new Map,$=new Map;for(let te=C.length-1;te>=0;te--){let ge=C[te],Te=(b.get(ge.pathname)||0)+1;b.set(ge.pathname,Te),$.set(ge,Te)}return $},[C]),Do=Ie(()=>({summary:{total:C.length,filtered:se.length,listening:P,ignoredPatterns:Array.from(N),timestamp:new Date().toISOString()},events:se.map((b,$)=>({index:$,visitNumber:st.get(b)||1,pathname:b.pathname,timestamp:b.timestamp,timestampRelative:ea(b.timestamp),params:b.params,segments:b.segments,previousPathname:b.previousPathname,timeSincePrevious:b.timeSincePrevious}))}),[C.length,se,P,N,st]);if(!e)return null;let Po=a?We.modal.root():We.routeEvents.modal(),lt=null,Lt=()=>{if(j)return k(Xt,{event:j,visitNumber:ue,onNavigate:D});if(l==="routes")return f||i?.sitemap?k(Tt,{style:U.contentWrapper,injectedRoutes:i?.sitemap?.routes,injectedSource:i?.sitemap?.source??null,injectedLastUpdatedAt:i?.sitemap?.lastUpdatedAt??null,onNavigateRoute:i?Lo:void 0}):k(Tt,{style:U.contentWrapper});if(l==="stack")return k(ho,{style:U.contentWrapper,injectedStack:i?i.stack??[]:void 0,onAction:i?.onStackAction,onCopyValueChange:x});if(Y)return k(Sa,{ignoredPatterns:N,onTogglePattern:Ce,onAddPattern:_e,availablePathnames:be});let b=C.length>0;return se.length===0?ie(c,{style:U.contentWrapper,testID:"buoy-routes-events",children:[b&&k(c,{style:U.searchContainer,testID:"buoy-routes-search-field",children:k(Gt,{value:de,onChange:S,placeholder:"Search pathname or params...",testID:"buoy-routes-search"})}),k(Yr,{testID:"buoy-routes-empty",...Zr({subject:"route events",search:de,total:C.length,capturing:P,waiting:{otto:"walking",title:"No route events yet",message:"Navigation events will appear here"},paused:{title:"Event listener is paused",message:"Press play to start monitoring"}})})]}):ie(c,{style:U.contentWrapper,testID:"buoy-routes-events",children:[k(c,{style:U.searchContainer,testID:"buoy-routes-search-field",children:k(Gt,{value:de,onChange:S,placeholder:"Search pathname or params...",testID:"buoy-routes-search"})}),it>0&&ie(c,{style:U.lockedEventsBanner,testID:"buoy-routes-locked-banner",children:[k(ra,{size:14,color:Z.color.warning}),ie(p,{style:U.lockedEventsBannerText,testID:"buoy-routes-locked-banner-text",children:[it," older ",it===1?"event":"events"," locked"]}),k(p,{style:U.lockedEventsBannerSubtext,children:"Upgrade to Pro for full history"})]}),k(vn,{events:Eo,visitCounts:st,onNavigate:D,onSelectEvent:Ge})]})},$t=j?ie(le,{children:[k(le.Navigation,{onBack:nt}),k(le.Content,{title:j.pathname,testID:"buoy-routes-detail-title"}),k(le.Actions,{children:k(ht,{testID:"buoy-routes-detail-copy",value:{pathname:j.pathname,previousPathname:j.previousPathname,params:j.params,segments:j.segments,timestamp:j.timestamp,timestampISO:new Date(j.timestamp).toISOString(),timeSincePrevious:j.timeSincePrevious,visitNumber:ue},buttonStyle:U.iconButton})})]}):Y?ie(le,{children:[k(le.Navigation,{onBack:()=>X(false)}),k(le.Content,{title:"Filters",testID:"buoy-routes-filters-title"})]}):ie(le,{children:[o&&k(le.Navigation,{onBack:o}),k(le.Content,{title:"",noMargin:true,children:k(Xr,{tabs:[{key:"routes",label:f?"Routes":"Screens"},{key:"events",label:`Events${C.length>0&&l!=="events"?` (${C.length})`:""}`},{key:"stack",label:"Stack"}],activeTab:l,onTabChange:b=>H(b),testIDPrefix:"buoy-routes-tab"})}),ie(le.Actions,{children:[l==="stack"&&k(ht,{value:g,buttonStyle:U.iconButton,testID:"buoy-routes-stack-copy"}),l==="events"&&ie(xn,{children:[k(ht,{value:Do,buttonStyle:U.iconButton,testID:"buoy-routes-copy"}),k(V,{onPress:Ne,style:[U.iconButton,N.size>0&&U.activeFilterButton],testID:"buoy-routes-filters",accessibilityRole:"button",accessibilityLabel:N.size>0?`Route filters, ${N.size} active`:"Route filters",children:k(oa,{size:14,color:N.size>0?Z.color.accent:Z.color.textSecondary})}),k(na,{isEnabled:P,onToggle:ee,accessibilityLabel:"Toggle route event monitoring",testID:"buoy-routes-power"}),k(V,{onPress:Fe,style:U.iconButton,testID:"buoy-routes-clear",accessibilityRole:"button",accessibilityLabel:"Clear route events",children:k(ta,{size:14,color:Z.color.danger})})]})]})]}),Lo=b=>{if(b.type==="layout"||b.type==="group")return;let $=b.type==="index"||b.path==="/";if(!L&&!$){F(true);return}i?.onNavigateRoute?.(b)},At=k(aa,{visible:R,onClose:()=>F(false),featureName:"Route Event Management"});return n?ie(Jt,{children:[ie(c,{style:U.inlineRoot,children:[k(c,{style:U.inlineHeader,...qr,children:$t}),Lt(),lt]}),At]}):k(Jt,{children:ie(Qr,{visible:e,onClose:t,onMinimize:r,persistenceKey:Po,header:{showToggleButton:true,customContent:$t},onModeChange:w,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:true,styles:{},footer:lt,footerHeight:lt?68:0,children:[Lt(),At]})})}function Rn(e={}){return k(It,{...e,inline:true,visible:true,onClose:()=>{}})}var U=ve.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:ia.border,backgroundColor:"transparent"},iconButton:{padding:6,borderRadius:6,backgroundColor:Z.color.buttonSurface},activeFilterButton:{backgroundColor:Z.color.accentSoft},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:Z.color.text,fontSize:16,fontWeight:"600",marginTop:16,marginBottom:8,fontFamily:Ye,letterSpacing:.5,textTransform:"uppercase"},emptySubtitle:{color:Z.color.textSecondary,fontSize:14,textAlign:"center",fontFamily:Ye},contentWrapper:{flex:1},statsContainer:{paddingHorizontal:16,paddingVertical:8,backgroundColor:Z.color.surface,borderBottomWidth:1,borderBottomColor:Z.color.border},statsText:{fontSize:11,color:Z.color.textSecondary,fontFamily:Ye,textAlign:"center"},statsWarning:{color:Z.color.warning,fontWeight:"600"},searchContainer:{paddingHorizontal:16,paddingVertical:8,backgroundColor:"transparent"},lockedEventsBanner:{flexDirection:"row",alignItems:"center",gap:8,backgroundColor:Z.color.warningSoft,borderWidth:1,borderColor:Z.color.warning+"30",borderRadius:8,paddingVertical:10,paddingHorizontal:14,marginHorizontal:16,marginBottom:8},lockedEventsBannerText:{fontSize:12,fontWeight:"600",color:Z.color.warning,fontFamily:Ye},lockedEventsBannerSubtext:{fontSize:11,color:Z.color.textSecondary,marginLeft:"auto"}});import{createToolFactory as kn,defineToolPreset as In}from"@buoy-gg/shared-ui/web";import{jsx as Bn}from"react/jsx-runtime";var xo=In({id:"route-events",name:"ROUTES",description:"Route tracking & navigation inspector",slot:"both",icon:({size:e})=>Bn(Wo,{size:e}),component:It,props:{enableSharedModalDimensions:false}}),En=kn(xo,e=>({enableSharedModalDimensions:e.enableSharedModalDimensions??false}));import{useEffect as Dn}from"react";import{browserRouter as So,getBrowserHref as Pn,getBrowserRouteURL as wo,subscribeBrowserNavigation as Ln}from"@buoy-gg/shared-ui/web/utils";var Co=0,Bt;function $n(){if(typeof window>"u")return()=>{};if(Co++===0){me.hydrateBootCapture();let t,o,r="",a=[],n=-1,i,d,s=()=>{i=void 0,clearTimeout(d)},f=()=>{let g=window.history.state;if(!g||typeof g!="object")return;let x=g.key??g.__TSR_key;if(typeof x=="string"||typeof x=="number")return String(x);for(let[L,I]of[["depth",g._depth],["position",g.position],["nav",g.navigationId]])if(typeof I=="number")return`${L}:${I}`},l=g=>{for(let x=n-1;x>=0;x--)if(a[x].href===g)return x;for(let x=n+1;x<a.length;x++)if(a[x].href===g)return x;return-1},m=g=>{let x=f();if(g.href===r&&g.kind==="pop"&&(x===void 0||a[n]?.key===x))return;if(g.kind==="replace"&&g.href===r&&n>=0){a[n]={href:g.href,key:x};return}if(g.kind!=="pop"&&s(),g.kind==="replace"&&n>=0)a[n]={href:g.href,key:x};else if(g.kind==="pop"){let W=x===void 0?-1:a.findIndex(q=>q.key===x),C=W<0&&i!==void 0&&a[i]?.href===g.href?i:-1,A=W>=0?W:C>=0?C:l(g.href);A>=0?n=A:(a.splice(n+1),a.push({href:g.href,key:x}),n++),n===i&&s()}else a.splice(n+1),a.push({href:g.href,key:x}),n++;r=g.href;let L=wo(g.href),I=Date.now(),E=no(L.pathname);Oa()||De.emit({pathname:L.pathname,params:{...E.params,...Object.fromEntries(L.searchParams)},segments:E.segments,previousPathname:t,timestamp:I,timeSincePrevious:o===void 0?void 0:I-o}),t=L.pathname,o=I,M.setStack(a.slice(0,n+1).map(({href:W},C)=>{let A=wo(W),q=no(A.pathname);return{key:`browser:${C}`,name:q.segments.join("/")||"index",pathname:A.pathname,params:{...q.params,...Object.fromEntries(A.searchParams)},index:C,isFocused:C===n,canPop:C>0}}))},R=g=>{if(!Number.isInteger(g)||g<0||g>=a.length)throw new Error("That browser history entry is unavailable.");let x=i??n;g!==x&&(i=g,clearTimeout(d),d=setTimeout(s,1500),window.history.go(g-x))},F=()=>{let g=i??n;g>0?R(g-1):i===void 0&&So.back()};M.setActions({navigateToIndex:R,popToIndex:R,goBack:F,popToTop:()=>R(0),navigateToRoute:(g,x)=>{let L={...x},I=`/${g.replace(/^\//,"")}`.replace(/\[(\.\.\.)?([^\]]+)\]/g,(E,W,C)=>{if(!(C in L))return E;let A=L[C];return delete L[C],W&&Array.isArray(A)?A.map(q=>encodeURIComponent(String(q))).join("/"):encodeURIComponent(String(A))});return So.push({pathname:I==="/index"?"/":I,params:L}),true}}),Bt=Ln(m),m({href:Pn(),kind:"initial"})}let e=false;return()=>{e||(e=true,--Co===0&&(Bt?.(),Bt=void 0,M.setActions(null)))}}function An(){return Dn($n,[]),null}import{useEffect as To,useRef as Et}from"react";import{useSafePathname as Fn,useSafeSegments as Nn,useSafeGlobalSearchParams as zn}from"@buoy-gg/shared-ui/web";function Wn(e){let t=Fn(),o=Nn(),r=zn(),a=Et(e),n=Et(void 0),i=Et(void 0);To(()=>{a.current=e},[e]),To(()=>{let d=Date.now(),s=i.current?d-i.current:void 0,f={pathname:t,params:r,segments:o,timestamp:d,previousPathname:n.current,timeSincePrevious:s};n.current=t,i.current=d,De.emit(f),a.current&&a.current(f)},[t,o,r])}import{useEffect as Ro,useRef as Dt}from"react";function ko(e){if(!e||!e.routes||e.routes.length===0)return{route:null,segments:[]};let t=e.routes[e.index??0],o=[t.name];if(t.state){let r=ko(t.state);if(r.route)return{route:r.route,segments:[...o,...r.segments]}}return{route:t,segments:o}}function Io(e,t,o,r){if(!e)return;let{route:a,segments:n}=ko(e);if(!a)return;let i=`/${a.name}`;if(i===t.current)return;let d=Date.now(),s=o.current?d-o.current:void 0,f={pathname:i,params:a.params||{},segments:n,timestamp:d,previousPathname:t.current,timeSincePrevious:s};t.current=i,o.current=d,De.emit(f),r.current&&r.current(f)}function On(e){let t=void 0,o=Dt(e),r=Dt(void 0),a=Dt(void 0);Ro(()=>{o.current=e},[e]),Ro(()=>{if(!t)return;let n=t.getRootState?.();n&&Io(n,r,a,o);let i=t.addListener?.("state",()=>{let d=t.getRootState?.();Io(d,r,a,o)});return()=>{i?.()}},[t])}import{getSafeRouter as jn}from"@buoy-gg/shared-ui/web";function Hn(e,t){let o=[],r=false,a=d=>{for(let s of d??[])(s.name?.includes("+not-found")||s.path?.includes("+not-found"))&&(r=true),typeof s.path=="string"&&o.push(s.path),a(s.children)};if(a(t),r||o.length===0)return;let n=d=>"/"+d.split("?")[0].split("#")[0].split("/").filter(s=>s&&!/^\(.*\)$/.test(s)).join("/"),i=n(e);return o.some(d=>{let s=n(d);return s===i?true:new RegExp("^"+s.split("/").map(f=>/^\[\.\.\..+\]$/.test(f)?".+":/^\[.+\]$/.test(f)?"[^/]+":f.replace(/[.*+?^${}()|\\]/g,"\\$&")).join("/")+"$").test(i)})}import{isOverWireBudget as Vn}from"@buoy-gg/shared-ui/web";async function Mn(e,t){let o=M.getStack().findIndex(a=>a.isFocused),r=M.getActions();if(o<0||!r||typeof e.replace!="function")throw new Error("This app's history isn't captured yet, so Buoy can't start over. Open the Routes tool once, or navigate without reset.");if(o>0){let a=globalThis;await new Promise((n,i)=>{let d=l=>{clearTimeout(f),a.removeEventListener?.("popstate",s),l?n():i(new Error("The app didn't go back to its first page, so nothing was reset. Try again, or navigate without reset."))},s=()=>setTimeout(()=>d(true),0),f=setTimeout(()=>d(false),1500);a.addEventListener?.("popstate",s),r.popToTop()})}if(M.getStack().findIndex(a=>a.isFocused)!==0)throw new Error("The app isn't on its first page, so nothing was reset. Try again, or navigate without reset.");return e.replace(t),{navigated:t,replaced:true,reset:true}}var Un=16*1024,Kn=Object.freeze({__buoyOmitted:"route-params",note:"Navigation params stay on the device."});function Pt(e){return e==null?false:Vn(e,Un)}function Ke(e){return Pt(e)?Kn:e}function _n(e){return Pt(e.params)?{...e,params:Ke(e.params)}:e}function Gn(e){return Pt(e.params)?{...e,params:Ke(e.params)}:e}function Bo(){let e=wt();return{routes:ye.parseRouteTree(Ve()),source:e.source,lastUpdatedAt:e.lastLoadedAt,complete:io()}}var Jn={version:3,getSnapshot:()=>({events:me.getEvents().map(_n),sitemap:Bo(),stack:M.getStack().map(Gn)}),subscribe:e=>{let t=me.subscribeToEvents(e),o=M.subscribe(e),r=null;if(!Ve()){let a=0,n=100,i=()=>{if(a+=1,Ve()){r=null,e();return}r=a<n?setTimeout(i,100):null};r=setTimeout(i,100)}return()=>{t(),o(),r&&clearTimeout(r)}},actions:{clearEvents:()=>{me.clearEvents()},getCurrentRoute:()=>{let e=me.getEvents()[0];if(e&&me.isCapturing())return{path:e.pathname,params:Ke(e.params),at:e.timestamp,source:"event"};let t=M.getStack(),o=t.find(r=>r.isFocused)??t[t.length-1];return o?.pathname?{path:o.pathname,params:Ke(o.params??{}),at:null,source:"stack"}:e?{path:e.pathname,params:Ke(e.params),at:e.timestamp,source:"event",stale:true}:{path:null,params:{},at:null,source:null}},navigate:e=>{let t=e,o=t?.path;if(!o)throw new Error("navigate requires a 'path' param");let r=jn();if(!r){let n=M.getActions(),i=o.replace(/^\//,"");if(!n?.navigateToRoute||!i)throw new Error("expo-router is not available here and no navigation container was captured \u2014 is <RouteTracker /> mounted inside your NavigationContainer?");if(!n.navigateToRoute(i,t?.params))throw new Error(`Could not navigate to "${i}" \u2014 no navigation container is live.`);return{navigated:o,replaced:false,via:"react-navigation"}}let a=[];try{a=Bo().routes}catch{a=[]}if(io()&&Hn(o,a)===false)throw new Error(`No screen matches "${o}". Navigating there would open expo-router's "Unmatched Route" page, which replaces the app's layout (and disconnects Buoy). Read the sitemap for the paths this app has.`);if(t?.reset===true){if(typeof r.canDismiss!="function")return Mn(r,o);try{r.canDismiss()&&r.dismissAll?.()}catch{}return r.navigate(o),{navigated:o,replaced:false,reset:true}}return(t?.replace===true&&typeof r.replace=="function"?r.replace:r.navigate)(o),{navigated:o,replaced:t?.replace===true}},stackNavigateToIndex:e=>{let t=e?.index;if(typeof t!="number")throw new Error("stackNavigateToIndex requires a numeric 'index'");let o=M.getActions();if(!o)throw new Error("navigation stack is not available");return o.navigateToIndex(t),{navigatedToIndex:t}},stackPopToIndex:e=>{let t=e?.index;if(typeof t!="number")throw new Error("stackPopToIndex requires a numeric 'index'");let o=M.getActions();if(!o)throw new Error("navigation stack is not available");return o.popToIndex(t),{poppedToIndex:t}},stackGoBack:()=>{let e=M.getActions();if(!e)throw new Error("navigation stack is not available");return e.goBack(),{wentBack:true}},stackPopToTop:()=>{let e=M.getActions();if(!e)throw new Error("navigation stack is not available");return e.popToTop(),{poppedToTop:true}}}};export{ho as NavigationStack,Xt as RouteEventDetail,gt as RouteEventExpandedContent,yo as RouteEventItemCompact,It as RouteEventsModalWithTabs,qt as RouteObserver,ye as RouteParser,An as RouteTracker,Tt as RoutesSitemap,Rn as RoutesToolView,Wa as claimBrowserRouteEvents,En as createRouteEventsTool,M as navigationStackStore,Na as registerBrowserRoutes,me as routeEventStore,Jn as routeEventsSyncAdapter,xo as routeEventsToolPreset,De as routeObserver,po as useNavigationStack,Ha as useParentRoutes,ja as useRoute,Yt as useRouteEvents,Wn as useRouteObserver,On as useRouteObserverReactNavigation,Xe as useRouteSitemap};
|
|
8
|
+
${N}`))&&pe();return}_.alert(S,N,[{text:"Cancel",style:"cancel"},{text:K,style:"destructive",onPress:pe}])},j=()=>{if(!A){C(true);return}if(R){_.alert("Cannot Go Back","Already at the root of the stack");return}x()},we=()=>{if(!A){C(true);return}if(R){_.alert("Already at Top","Stack only has one screen");return}X("Pop to Top","This will remove all screens except the root screen.","Pop to Top",L)},ue=S=>{E(I===S?null:S)},xe=()=>{if(!A){C(true);return}if(P){if(P.isFocused){_.alert("Already There","This route is already visible");return}F(P.index)}},de=()=>{if(!A){C(true);return}if(!P)return;if(P.isFocused){_.alert("Cannot Pop","Selected route is already visible");return}if(P.index===h-1){_.alert("Cannot Pop","No screens above selected route");return}let S=h-1-P.index,N=P.index;X("Pop to Route",`Remove ${S} screen${S!==1?"s":""} above ${P.pathname}?`,"Pop",()=>g(N))};return ae(c,{style:[y.container,e],children:[B(qe,{keyboardShouldPersistTaps:"handled",testID:"buoy-routes-stack-scroll",style:y.stackScroll,contentContainerStyle:[y.stackContent,{paddingBottom:y.stackContent.padding+i.bottom}],children:[...d].reverse().map((S,N)=>{let K=d.length-1-N,pe=I===K,w=Object.keys(S.params).length>0,D=Ua(K);return B(c,{style:y.stackItemWrapper,testID:D,children:ae(c,{style:[y.stackItem,pe&&y.stackItemSelected],children:[ae(c,{style:y.stackItemHeader,children:[ae(V,{style:y.stackItemToggle,onPress:()=>ue(K),activeOpacity:.7,testID:`${D}-toggle`,accessibilityRole:"button",accessibilityLabel:`${S.pathname}, ${S.isFocused?"focused":"mounted"}, position ${K} of ${h-1}`,children:[B(c,{style:y.expandIndicator,children:pe?B(Ja,{size:14,color:J.color.textSecondary}):B(qa,{size:14,color:J.color.textSecondary})}),B(p,{style:y.stackItemPath,numberOfLines:1,testID:`${D}-path`,children:S.pathname})]}),B(Ya,{value:S.pathname,buttonStyle:y.copyRouteButton,testID:`${D}-copy`}),B(V,{onPress:()=>ue(K),activeOpacity:.7,accessible:false,style:[y.statusBadge,{backgroundColor:S.isFocused?`${ot.success}15`:"#3B82F615",borderColor:S.isFocused?`${ot.success}40`:"#3B82F640"}],children:B(p,{style:[y.statusBadgeText,{color:S.isFocused?ot.success:"#3B82F6"}],testID:`${D}-status`,children:S.isFocused?"FOCUSED":"MOUNTED"})})]}),pe&&ae(c,{style:y.expandedContent,children:[ae(c,{style:y.detailRow,children:[B(p,{style:y.detailLabel,children:"Route Name:"}),B(p,{style:y.detailValue,testID:`${D}-name`,children:S.name})]}),ae(c,{style:y.detailRow,children:[B(p,{style:y.detailLabel,children:"Position:"}),ae(p,{style:y.detailValue,testID:`${D}-position`,children:[K," / ",h-1]})]}),w&&B(c,{style:y.dataViewerContainer,children:B(tn,{title:"Parameters",data:S.params,showTypeFilter:false})}),ae(c,{style:y.actionsRow,children:[ae(c,{style:y.actionWrapper,children:[B(V,{style:[y.actionButton,R&&y.actionButtonDisabled],onPress:j,disabled:R,testID:`${D}-back`,accessibilityRole:"button",accessibilityLabel:"Go back one screen",children:B(p,{style:[y.actionButtonText,R&&y.actionButtonTextDisabled],children:"Back"})}),B(p,{style:y.helpText,children:"Go back one screen"})]}),ae(c,{style:y.actionWrapper,children:[B(V,{style:[y.actionButton,S.isFocused&&y.actionButtonDisabled],onPress:xe,disabled:S.isFocused,testID:`${D}-go`,accessibilityRole:"button",accessibilityLabel:`Navigate to ${S.pathname}`,children:B(p,{style:[y.actionButtonText,S.isFocused&&y.actionButtonTextDisabled],children:"Go"})}),B(p,{style:y.helpText,children:"Navigate to this route"})]}),ae(c,{style:y.actionWrapper,children:[B(V,{style:[y.actionButton,(S.isFocused||K===h-1)&&y.actionButtonDisabled],onPress:de,disabled:S.isFocused||K===h-1,testID:`${D}-pop-to`,accessibilityRole:"button",accessibilityLabel:`Remove screens above ${S.pathname}`,children:B(p,{style:[y.actionButtonText,(S.isFocused||K===h-1)&&y.actionButtonTextDisabled],children:"Pop To"})}),B(p,{style:y.helpText,children:"Remove screens above this"})]})]})]})]})},`stack-${K}-${S.key}`)})}),B(Za,{visible:W,onClose:()=>C(false),featureName:"Stack Navigation"})]})}var y=ve.create({container:{flex:1,backgroundColor:"transparent"},loadingContainer:{flex:1,justifyContent:"center",alignItems:"center",padding:32},loadingText:{color:J.color.textSecondary,fontSize:14,fontFamily:ce},errorContainer:{flex:1,justifyContent:"center",alignItems:"center",padding:32},errorText:{color:ot.error,fontSize:16,fontWeight:"600",fontFamily:ce,marginBottom:8},errorDetail:{color:J.color.textSecondary,fontSize:12,fontFamily:ce,textAlign:"center"},emptyContainer:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyText:{color:J.color.text,fontSize:16,fontWeight:"600",fontFamily:ce,marginBottom:8},emptySubtext:{color:J.color.textSecondary,fontSize:14,fontFamily:ce,textAlign:"center"},stackScroll:{flex:1},stackContent:{padding:8},stackItemWrapper:{marginBottom:6},stackItem:{backgroundColor:J.color.surface,borderRadius:6,borderWidth:1,borderColor:J.color.border,overflow:"hidden"},stackItemSelected:{borderColor:J.color.accent,borderWidth:2},stackItemHeader:{flexDirection:"row",alignItems:"center",paddingVertical:10,paddingHorizontal:12,gap:8},stackItemToggle:{flex:1,flexDirection:"row",alignItems:"center",gap:8},expandIndicator:{width:20,alignItems:"center"},stackItemPath:{fontSize:13,fontWeight:"600",color:J.color.text,fontFamily:ce,flex:1},copyRouteButton:{padding:4,marginLeft:4},statusBadge:{borderRadius:4,paddingHorizontal:6,paddingVertical:2,borderWidth:1},statusBadgeText:{fontSize:10,fontWeight:"600",fontFamily:ce},expandedContent:{paddingHorizontal:12,paddingTop:8,paddingBottom:12,borderTopWidth:1,borderTopColor:J.color.border},detailRow:{marginBottom:8},detailLabel:{fontSize:10,color:J.color.textSecondary,fontFamily:ce,marginBottom:2},detailValue:{fontSize:12,color:J.color.text,fontFamily:ce},dataViewerContainer:{marginTop:4,marginHorizontal:-12,marginBottom:8},actionsRow:{flexDirection:"row",gap:6,marginTop:12},actionWrapper:{flex:1},actionButton:{backgroundColor:J.color.surfaceElevated,paddingVertical:8,paddingHorizontal:8,borderRadius:6,alignItems:"center"},actionButtonDisabled:{opacity:.5},actionButtonText:{fontSize:12,fontWeight:"600",color:J.color.text,fontFamily:ce},actionButtonTextDisabled:{color:J.color.textTertiary},helpText:{fontSize:9,color:J.color.textSecondary,fontFamily:ce,textAlign:"center",marginTop:4,lineHeight:12}});import{useCallback as nn}from"react";import{Navigation as sn,night as Rt,EVENT_LIST_PRESET as ln,monoFont as fo}from"@buoy-gg/shared-ui/web";import{memo as cn,useMemo as fe}from"react";import{CompactRow as un,RelativeTime as dn,buoyColors as go,night as rt,monoFont as yo}from"@buoy-gg/shared-ui/web";import{jsx as Me}from"react/jsx-runtime";function pn(e){return e.pathname==="/"?"home":yt(e.pathname,e.segments)?"dynamic":e.params&&Object.keys(e.params).length>0?"with-params":"default"}function mn(e){switch(e){case"home":return go.success;case"dynamic":return rt.color.accent;case"with-params":return go.warning;default:return rt.color.textSecondary}}function hn(e){switch(e){case"home":return"Home";case"dynamic":return"Dynamic";case"with-params":return"Params";default:return"Static"}}function fn(e){if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/6e4),o=Math.floor(e%6e4/1e3);return o>0?`${t}m ${o}s`:`${t}m`}function gn(e){let t=[];e.timeSincePrevious!==void 0&&e.timeSincePrevious>0&&t.push(fn(e.timeSincePrevious));let o=e.segments?.length||0;return o>0&&t.push(`depth ${o}`),t.join(" \xB7 ")||"root"}function yn(e){if(e.params&&Object.keys(e.params).length>0){let t=Object.keys(e.params).length;return`${t} PARAM${t!==1?"S":""}`}}var bo=cn(function({event:e,visitNumber:t,isExpanded:o,onPress:r,onNavigate:a,index:n}){let i=fe(()=>pn(e),[e]),d=fe(()=>yt(e.pathname,e.segments),[e.pathname,e.segments]),s=fe(()=>mn(i),[i]),f=fe(()=>hn(i),[i]),l=fe(()=>gn(e),[e]),h=fe(()=>yn(e),[e]),R=fe(()=>Va(e.pathname,t),[e.pathname,t]),F=fe(()=>`${e.pathname}, ${f}, ${l}`,[e.pathname,f,l]),g=fe(()=>{if(o)return Me(gt,{event:e,visitNumber:t,routeTemplate:d})},[o,e,t,d]),x=fe(()=>{if(a)return Me(V,{style:vo.goButton,onPress:()=>a(Qt(e.pathname,e.params)),testID:`${R}-go`,accessibilityRole:"button",accessibilityLabel:`Go to ${e.pathname}`,children:Me(p,{style:vo.goButtonText,children:"Go"})})},[a,e.pathname,R]);return Me(un,{statusDotColor:s,statusLabel:f,statusSublabel:l,primaryText:e.pathname,badgeText:h,badgeColor:s,trailingAction:x,bottomRightText:Me(dn,{timestamp:e.timestamp}),showChevron:true,expandedContent:g,isExpanded:o,expandedGlowColor:s,onPress:()=>r(n),testID:R,statusTestID:`${R}-status`,statusSublabelTestID:`${R}-sublabel`,accessibilityLabel:F})}),vo=ve.create({badgeText:{fontSize:11,fontWeight:"600",fontFamily:yo},goButton:{backgroundColor:rt.color.accent,paddingHorizontal:8,paddingVertical:4,borderRadius:4},goButtonText:{fontSize:10,fontWeight:"600",color:rt.color.onAccent,fontFamily:yo}});import{jsx as Ue,jsxs as bn}from"react/jsx-runtime";function vn({events:e,visitCounts:t,onNavigate:o,onSelectEvent:r}){let a=nn(n=>{let i=e[n];i&&(jt.dismiss(),r(i,t.get(i)||1))},[e,t,r]);return e.length===0?bn(c,{style:at.emptyState,testID:"buoy-routes-empty",children:[Ue(sn,{size:48,color:Rt.color.textTertiary}),Ue(p,{style:at.emptyTitle,testID:"buoy-routes-empty-title",children:"No events yet"}),Ue(p,{style:at.emptySubtitle,testID:"buoy-routes-empty-subtitle",children:"Navigation events will appear here"})]}):Ue(Ht,{keyboardShouldPersistTaps:"handled",testID:"buoy-routes-timeline",contentContainerStyle:at.listContent,data:e,keyExtractor:n=>`${n.timestamp}-${n.pathname}`,renderItem:({item:n,index:i})=>Ue(bo,{event:n,visitNumber:t.get(n)||1,isExpanded:false,index:i,onPress:a,onNavigate:o}),showsVerticalScrollIndicator:true,...ln})}var at=ve.create({listContent:{paddingVertical:8},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:Rt.color.text,fontSize:16,fontWeight:"600",marginTop:16,marginBottom:8,fontFamily:fo,letterSpacing:.5,textTransform:"uppercase"},emptySubtitle:{color:Rt.color.textSecondary,fontSize:14,textAlign:"center",fontFamily:fo}});import{Fragment as xn,jsx as k,jsxs as ie}from"react/jsx-runtime";var kt=_r(),Sn={parse:e=>e==="routes"||e==="events"||e==="stack"?e:void 0,serialize:e=>e},wn={parse:e=>e==="true",serialize:e=>e.toString()},Cn={parse:e=>new Set(JSON.parse(e)),serialize:e=>JSON.stringify(Array.from(e))};function xo(e,t){if(!e||!e.routes)return null;for(let o of e.routes){if(o.name===t)return[o.name];if(o.state){let r=xo(o.state,t);if(r)return[o.name,...r]}}return null}function Tn(e,t){if(e.length===0)return null;let o=t&&Object.keys(t).length>0?t:void 0;if(e.length===1)return kt.navigate(o?{name:e[0],params:o}:{name:e[0]});let r=o?{screen:e[e.length-1],params:o}:{screen:e[e.length-1]};for(let a=e.length-2;a>=1;a--)r={screen:e[a],params:r};return kt.navigate({name:e[0],params:r})}function It({visible:e,onClose:t,onBack:o,onMinimize:r,enableSharedModalDimensions:a=false,inline:n=false,remote:i}){let d=Gr(),s=void 0,f=ct.OS==="web"||Jr(),[l,h]=pt(We.routeEvents.activeTab(),"events",Sn),[R,F]=ke(false),[g,x]=ke(""),L=la(),I=sa("routeEvents.entries");Wt(()=>{R&&L&&F(false)},[R,L]);let[E,W]=pt(We.routeEvents.isMonitoring(),true,wn),{events:C,clearEvents:A,isListening:q}=Zt({enabled:E}),P=E&&q;Wt(()=>{he.setBootCapture(E)},[E]);let[Y,X]=ke(false),[j,we]=ke(null),[ue,xe]=ke(1),[de,S]=ke(""),[N,K]=pt(We.routeEvents.eventFilters(),new Set(["/_sitemap","/api","/__dev"]),Cn),pe=jo(null),w=me(b=>{},[]),D=me(b=>{try{if(i){if(!i.onNavigatePath)return;if(!L&&b!=="/"){F(true);return}i.onNavigatePath(b);return}if(f)d.push(b);else if(s){let{pathname:$,params:te}=ba(b),ge=$.startsWith("/")?$.slice(1):$,Te=Object.keys(te).length>0,Re=s.getRootState?.();if(Re){let Je=xo(Re,ge);if(Je){let Ft=Tn(Je,te);if(Ft){s.dispatch(Ft);return}}}s.dispatch(kt.navigate(Te?{name:ge,params:te}:{name:ge}))}else _.alert("Navigation Unavailable","No Expo Router or React Navigation container was found in this app.")}catch($){_.alert("Navigation Error",String($))}},[d,s,f,i,L]),ee=me(()=>{W(b=>!b)},[]),Fe=me(()=>{if(C.length!==0){if(!L){F(true);return}A()}},[C.length,L,A]),Ce=me(b=>{K($=>{let te=new Set($);return te.has(b)?te.delete(b):te.add(b),te})},[]),_e=me(b=>{K($=>new Set([...$,b]))},[]),Ne=me(()=>{X(!Y)},[Y]),Ge=me((b,$)=>{we(b),xe($)},[]),nt=me(()=>{we(null)},[]),H=me(b=>{we(null),h(b)},[]),be=Ie(()=>{let b=new Set;return C.forEach($=>{$.pathname&&b.add($.pathname)}),Array.from(b).sort()},[C]),se=Ie(()=>C.filter(b=>{if(!b.pathname||Array.from(N).some($=>b.pathname.includes($)))return false;if(de.trim()){let $=de.toLowerCase(),te=b.pathname.toLowerCase().includes($),ge=Object.entries(b.params||{}).some(([Te,Re])=>{let Je=Array.isArray(Re)?Re.join(" "):Re;return Te.toLowerCase().includes($)||Je.toLowerCase().includes($)});return te||ge}return true}),[C,N,de]),Do=Ie(()=>se.slice(0,I),[se,I]),it=Ie(()=>Math.max(0,se.length-I),[se.length,I]),st=Ie(()=>{let b=new Map,$=new Map;for(let te=C.length-1;te>=0;te--){let ge=C[te],Te=(b.get(ge.pathname)||0)+1;b.set(ge.pathname,Te),$.set(ge,Te)}return $},[C]),Po=Ie(()=>({summary:{total:C.length,filtered:se.length,listening:P,ignoredPatterns:Array.from(N),timestamp:new Date().toISOString()},events:se.map((b,$)=>({index:$,visitNumber:st.get(b)||1,pathname:b.pathname,timestamp:b.timestamp,timestampRelative:ea(b.timestamp),params:b.params,segments:b.segments,previousPathname:b.previousPathname,timeSincePrevious:b.timeSincePrevious}))}),[C.length,se,P,N,st]);if(!e)return null;let Lo=a?We.modal.root():We.routeEvents.modal(),lt=null,Lt=()=>{if(j)return k(eo,{event:j,visitNumber:ue,onNavigate:D});if(l==="routes")return f||i?.sitemap?k(Tt,{style:U.contentWrapper,injectedRoutes:i?.sitemap?.routes,injectedSource:i?.sitemap?.source??null,injectedLastUpdatedAt:i?.sitemap?.lastUpdatedAt??null,onNavigateRoute:i?$o:void 0}):k(Tt,{style:U.contentWrapper});if(l==="stack")return k(ho,{style:U.contentWrapper,injectedStack:i?i.stack??[]:void 0,onAction:i?.onStackAction,onCopyValueChange:x});if(Y)return k(Sa,{ignoredPatterns:N,onTogglePattern:Ce,onAddPattern:_e,availablePathnames:be});let b=C.length>0;return se.length===0?ie(c,{style:U.contentWrapper,testID:"buoy-routes-events",children:[b&&k(c,{style:U.searchContainer,testID:"buoy-routes-search-field",children:k(Jt,{value:de,onChange:S,placeholder:"Search pathname or params...",testID:"buoy-routes-search"})}),k(Yr,{testID:"buoy-routes-empty",...Zr({subject:"route events",search:de,total:C.length,capturing:P,waiting:{otto:"walking",title:"No route events yet",message:"Navigation events will appear here"},paused:{title:"Event listener is paused",message:"Press play to start monitoring"}})})]}):ie(c,{style:U.contentWrapper,testID:"buoy-routes-events",children:[k(c,{style:U.searchContainer,testID:"buoy-routes-search-field",children:k(Jt,{value:de,onChange:S,placeholder:"Search pathname or params...",testID:"buoy-routes-search"})}),it>0&&ie(c,{style:U.lockedEventsBanner,testID:"buoy-routes-locked-banner",children:[k(ra,{size:14,color:Z.color.warning}),ie(p,{style:U.lockedEventsBannerText,testID:"buoy-routes-locked-banner-text",children:[it," older ",it===1?"event":"events"," locked"]}),k(p,{style:U.lockedEventsBannerSubtext,children:"Upgrade to Pro for full history"})]}),k(vn,{events:Do,visitCounts:st,onNavigate:D,onSelectEvent:Ge})]})},$t=j?ie(le,{children:[k(le.Navigation,{onBack:nt}),k(le.Content,{title:j.pathname,testID:"buoy-routes-detail-title"}),k(le.Actions,{children:k(mt,{testID:"buoy-routes-detail-copy",value:{pathname:j.pathname,previousPathname:j.previousPathname,params:j.params,segments:j.segments,timestamp:j.timestamp,timestampISO:new Date(j.timestamp).toISOString(),timeSincePrevious:j.timeSincePrevious,visitNumber:ue},buttonStyle:U.iconButton})})]}):Y?ie(le,{children:[k(le.Navigation,{onBack:()=>X(false)}),k(le.Content,{title:"Filters",testID:"buoy-routes-filters-title"})]}):ie(le,{children:[o&&k(le.Navigation,{onBack:o}),k(le.Content,{title:"",noMargin:true,children:k(Xr,{tabs:[{key:"routes",label:f?"Routes":"Screens"},{key:"events",label:`Events${C.length>0&&l!=="events"?` (${C.length})`:""}`},{key:"stack",label:"Stack"}],activeTab:l,onTabChange:b=>H(b),testIDPrefix:"buoy-routes-tab"})}),ie(le.Actions,{children:[l==="stack"&&k(mt,{value:g,buttonStyle:U.iconButton,testID:"buoy-routes-stack-copy"}),l==="events"&&ie(xn,{children:[k(mt,{value:Po,buttonStyle:U.iconButton,testID:"buoy-routes-copy"}),k(V,{onPress:Ne,style:[U.iconButton,N.size>0&&U.activeFilterButton],testID:"buoy-routes-filters",accessibilityRole:"button",accessibilityLabel:N.size>0?`Route filters, ${N.size} active`:"Route filters",children:k(oa,{size:14,color:N.size>0?Z.color.accent:Z.color.textSecondary})}),k(na,{isEnabled:P,onToggle:ee,accessibilityLabel:"Toggle route event monitoring",testID:"buoy-routes-power"}),k(V,{onPress:Fe,style:U.iconButton,testID:"buoy-routes-clear",accessibilityRole:"button",accessibilityLabel:"Clear route events",children:k(ta,{size:14,color:Z.color.danger})})]})]})]}),$o=b=>{if(b.type==="layout"||b.type==="group")return;let $=b.type==="index"||b.path==="/";if(!L&&!$){F(true);return}i?.onNavigateRoute?.(b)},At=k(aa,{visible:R,onClose:()=>F(false),featureName:"Route Event Management"});return n?ie(qt,{children:[ie(c,{style:U.inlineRoot,children:[k(c,{style:U.inlineHeader,...qr,children:$t}),Lt(),lt]}),At]}):k(qt,{children:ie(Qr,{visible:e,onClose:t,onMinimize:r,persistenceKey:Lo,header:{showToggleButton:true,customContent:$t},onModeChange:w,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:true,styles:{},footer:lt,footerHeight:lt?68:0,children:[Lt(),At]})})}function Rn(e={}){return k(It,{...e,inline:true,visible:true,onClose:()=>{}})}var U=ve.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:ia.border,backgroundColor:"transparent"},iconButton:{padding:6,borderRadius:6,backgroundColor:Z.color.buttonSurface},activeFilterButton:{backgroundColor:Z.color.accentSoft},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:Z.color.text,fontSize:16,fontWeight:"600",marginTop:16,marginBottom:8,fontFamily:Ye,letterSpacing:.5,textTransform:"uppercase"},emptySubtitle:{color:Z.color.textSecondary,fontSize:14,textAlign:"center",fontFamily:Ye},contentWrapper:{flex:1},statsContainer:{paddingHorizontal:16,paddingVertical:8,backgroundColor:Z.color.surface,borderBottomWidth:1,borderBottomColor:Z.color.border},statsText:{fontSize:11,color:Z.color.textSecondary,fontFamily:Ye,textAlign:"center"},statsWarning:{color:Z.color.warning,fontWeight:"600"},searchContainer:{paddingHorizontal:16,paddingVertical:8,backgroundColor:"transparent"},lockedEventsBanner:{flexDirection:"row",alignItems:"center",gap:8,backgroundColor:Z.color.warningSoft,borderWidth:1,borderColor:Z.color.warning+"30",borderRadius:8,paddingVertical:10,paddingHorizontal:14,marginHorizontal:16,marginBottom:8},lockedEventsBannerText:{fontSize:12,fontWeight:"600",color:Z.color.warning,fontFamily:Ye},lockedEventsBannerSubtext:{fontSize:11,color:Z.color.textSecondary,marginLeft:"auto"}});import{createToolFactory as kn,defineToolPreset as In}from"@buoy-gg/shared-ui/web";import{jsx as Bn}from"react/jsx-runtime";var So=In({id:"route-events",name:"ROUTES",description:"Route tracking & navigation inspector",slot:"both",icon:({size:e})=>Bn(Oo,{size:e}),component:It,props:{enableSharedModalDimensions:false}}),En=kn(So,e=>({enableSharedModalDimensions:e.enableSharedModalDimensions??false}));import{useEffect as Dn}from"react";import{browserRouter as wo,getBrowserHref as Pn,getBrowserRouteURL as Co,subscribeBrowserNavigation as Ln}from"@buoy-gg/shared-ui/web/utils";var To=0,Bt;function $n(){if(typeof window>"u")return()=>{};if(To++===0){he.hydrateBootCapture();let t,o,r="",a=[],n=-1,i,d,s=()=>{i=void 0,clearTimeout(d)},f=()=>{let g=window.history.state;if(!g||typeof g!="object")return;let x=g.key??g.__TSR_key;if(typeof x=="string"||typeof x=="number")return String(x);for(let[L,I]of[["depth",g._depth],["position",g.position],["nav",g.navigationId]])if(typeof I=="number")return`${L}:${I}`},l=g=>{for(let x=n-1;x>=0;x--)if(a[x].href===g)return x;for(let x=n+1;x<a.length;x++)if(a[x].href===g)return x;return-1},h=g=>{let x=f();if(g.href===r&&g.kind==="pop"&&(x===void 0||a[n]?.key===x))return;if(g.kind==="replace"&&g.href===r&&n>=0){a[n]={href:g.href,key:x};return}if(g.kind!=="pop"&&s(),g.kind==="replace"&&n>=0)a[n]={href:g.href,key:x};else if(g.kind==="pop"){let W=x===void 0?-1:a.findIndex(q=>q.key===x),C=W<0&&i!==void 0&&a[i]?.href===g.href?i:-1,A=W>=0?W:C>=0?C:l(g.href);A>=0?n=A:(a.splice(n+1),a.push({href:g.href,key:x}),n++),n===i&&s()}else a.splice(n+1),a.push({href:g.href,key:x}),n++;r=g.href;let L=Co(g.href),I=Date.now(),E=io(L.pathname);Oa()||De.emit({pathname:L.pathname,params:{...E.params,...Object.fromEntries(L.searchParams)},segments:E.segments,previousPathname:t,timestamp:I,timeSincePrevious:o===void 0?void 0:I-o}),t=L.pathname,o=I,M.setStack(a.slice(0,n+1).map(({href:W},C)=>{let A=Co(W),q=io(A.pathname);return{key:`browser:${C}`,name:q.segments.join("/")||"index",pathname:A.pathname,params:{...q.params,...Object.fromEntries(A.searchParams)},index:C,isFocused:C===n,canPop:C>0}}))},R=g=>{if(!Number.isInteger(g)||g<0||g>=a.length)throw new Error("That browser history entry is unavailable.");let x=i??n;g!==x&&(i=g,clearTimeout(d),d=setTimeout(s,1500),window.history.go(g-x))},F=()=>{let g=i??n;g>0?R(g-1):i===void 0&&wo.back()};M.setActions({navigateToIndex:R,popToIndex:R,goBack:F,popToTop:()=>R(0),navigateToRoute:(g,x)=>{let L={...x},I=`/${g.replace(/^\//,"")}`.replace(/\[(\.\.\.)?([^\]]+)\]/g,(E,W,C)=>{if(!(C in L))return E;let A=L[C];return delete L[C],W&&Array.isArray(A)?A.map(q=>encodeURIComponent(String(q))).join("/"):encodeURIComponent(String(A))});return wo.push({pathname:I==="/index"?"/":I,params:L}),true}}),Bt=Ln(h),h({href:Pn(),kind:"initial"})}let e=false;return()=>{e||(e=true,--To===0&&(Bt?.(),Bt=void 0,M.setActions(null)))}}function An(){return Dn($n,[]),null}import{useEffect as Ro,useRef as Et}from"react";import{useSafePathname as Fn,useSafeSegments as Nn,useSafeGlobalSearchParams as zn}from"@buoy-gg/shared-ui/web";function Wn(e){let t=Fn(),o=Nn(),r=zn(),a=Et(e),n=Et(void 0),i=Et(void 0);Ro(()=>{a.current=e},[e]),Ro(()=>{let d=Date.now(),s=i.current?d-i.current:void 0,f={pathname:t,params:r,segments:o,timestamp:d,previousPathname:n.current,timeSincePrevious:s};n.current=t,i.current=d,De.emit(f),a.current&&a.current(f)},[t,o,r])}import{useEffect as ko,useRef as Dt}from"react";function Io(e){if(!e||!e.routes||e.routes.length===0)return{route:null,segments:[]};let t=e.routes[e.index??0],o=[t.name];if(t.state){let r=Io(t.state);if(r.route)return{route:r.route,segments:[...o,...r.segments]}}return{route:t,segments:o}}function Bo(e,t,o,r){if(!e)return;let{route:a,segments:n}=Io(e);if(!a)return;let i=`/${a.name}`;if(i===t.current)return;let d=Date.now(),s=o.current?d-o.current:void 0,f={pathname:i,params:a.params||{},segments:n,timestamp:d,previousPathname:t.current,timeSincePrevious:s};t.current=i,o.current=d,De.emit(f),r.current&&r.current(f)}function On(e){let t=void 0,o=Dt(e),r=Dt(void 0),a=Dt(void 0);ko(()=>{o.current=e},[e]),ko(()=>{if(!t)return;let n=t.getRootState?.();n&&Bo(n,r,a,o);let i=t.addListener?.("state",()=>{let d=t.getRootState?.();Bo(d,r,a,o)});return()=>{i?.()}},[t])}import{getSafeRouter as jn}from"@buoy-gg/shared-ui/web";function Hn(e,t){let o=[],r=false,a=d=>{for(let s of d??[])(s.name?.includes("+not-found")||s.path?.includes("+not-found"))&&(r=true),typeof s.path=="string"&&o.push(s.path),a(s.children)};if(a(t),r||o.length===0)return;let n=d=>"/"+d.split("?")[0].split("#")[0].split("/").filter(s=>s&&!/^\(.*\)$/.test(s)).join("/"),i=n(e);return o.some(d=>{let s=n(d);return s===i?true:new RegExp("^"+s.split("/").map(f=>/^\[\.\.\..+\]$/.test(f)?".+":/^\[.+\]$/.test(f)?"[^/]+":f.replace(/[.*+?^${}()|\\]/g,"\\$&")).join("/")+"$").test(i)})}import{isOverWireBudget as Vn}from"@buoy-gg/shared-ui/web";async function Mn(e,t){let o=M.getStack().findIndex(a=>a.isFocused),r=M.getActions();if(o<0||!r||typeof e.replace!="function")throw new Error("This app's history isn't captured yet, so Buoy can't start over. Open the Routes tool once, or navigate without reset.");if(o>0){let a=globalThis;await new Promise((n,i)=>{let d=l=>{clearTimeout(f),a.removeEventListener?.("popstate",s),l?n():i(new Error("The app didn't go back to its first page, so nothing was reset. Try again, or navigate without reset."))},s=()=>setTimeout(()=>d(true),0),f=setTimeout(()=>d(false),1500);a.addEventListener?.("popstate",s),r.popToTop()})}if(M.getStack().findIndex(a=>a.isFocused)!==0)throw new Error("The app isn't on its first page, so nothing was reset. Try again, or navigate without reset.");return e.replace(t),{navigated:t,replaced:true,reset:true}}var Un=16*1024,Kn=Object.freeze({__buoyOmitted:"route-params",note:"Navigation params stay on the device."});function Pt(e){return e==null?false:Vn(e,Un)}function Ke(e){return Pt(e)?Kn:e}function _n(e){return Pt(e.params)?{...e,params:Ke(e.params)}:e}function Gn(e){return Pt(e.params)?{...e,params:Ke(e.params)}:e}function Eo(){let e=wt();return{routes:ye.parseRouteTree(Ve()),source:e.source,lastUpdatedAt:e.lastLoadedAt,complete:so()}}var Jn={version:3,getSnapshot:()=>({events:he.getEvents().map(_n),sitemap:Eo(),stack:M.getStack().map(Gn)}),subscribe:e=>{let t=he.subscribeToEvents(e),o=M.subscribe(e),r=null;if(!Ve()){let a=0,n=100,i=()=>{if(a+=1,Ve()){r=null,e();return}r=a<n?setTimeout(i,100):null};r=setTimeout(i,100)}return()=>{t(),o(),r&&clearTimeout(r)}},actions:{clearEvents:()=>{he.clearEvents()},getCurrentRoute:()=>{let e=he.getEvents()[0];if(e&&he.isCapturing())return{path:e.pathname,params:Ke(e.params),at:e.timestamp,source:"event"};let t=M.getStack(),o=t.find(r=>r.isFocused)??t[t.length-1];return o?.pathname?{path:o.pathname,params:Ke(o.params??{}),at:null,source:"stack"}:e?{path:e.pathname,params:Ke(e.params),at:e.timestamp,source:"event",stale:true}:{path:null,params:{},at:null,source:null}},navigate:e=>{let t=e,o=t?.path;if(!o)throw new Error("navigate requires a 'path' param");let r=jn();if(!r){let n=M.getActions(),i=o.replace(/^\//,"");if(!n?.navigateToRoute||!i)throw new Error("expo-router is not available here and no navigation container was captured \u2014 is <RouteTracker /> mounted inside your NavigationContainer?");if(!n.navigateToRoute(i,t?.params))throw new Error(`Could not navigate to "${i}" \u2014 no navigation container is live.`);return{navigated:o,replaced:false,via:"react-navigation"}}let a=[];try{a=Eo().routes}catch{a=[]}if(so()&&Hn(o,a)===false)throw new Error(`No screen matches "${o}". Navigating there would open expo-router's "Unmatched Route" page, which replaces the app's layout (and disconnects Buoy). Read the sitemap for the paths this app has.`);if(t?.reset===true){if(typeof r.canDismiss!="function")return Mn(r,o);try{r.canDismiss()&&r.dismissAll?.()}catch{}return r.navigate(o),{navigated:o,replaced:false,reset:true}}return(t?.replace===true&&typeof r.replace=="function"?r.replace:r.navigate)(o),{navigated:o,replaced:t?.replace===true}},stackNavigateToIndex:e=>{let t=e?.index;if(typeof t!="number")throw new Error("stackNavigateToIndex requires a numeric 'index'");let o=M.getActions();if(!o)throw new Error("navigation stack is not available");return o.navigateToIndex(t),{navigatedToIndex:t}},stackPopToIndex:e=>{let t=e?.index;if(typeof t!="number")throw new Error("stackPopToIndex requires a numeric 'index'");let o=M.getActions();if(!o)throw new Error("navigation stack is not available");return o.popToIndex(t),{poppedToIndex:t}},stackGoBack:()=>{let e=M.getActions();if(!e)throw new Error("navigation stack is not available");return e.goBack(),{wentBack:true}},stackPopToTop:()=>{let e=M.getActions();if(!e)throw new Error("navigation stack is not available");return e.popToTop(),{poppedToTop:true}}}};export{ho as NavigationStack,eo as RouteEventDetail,gt as RouteEventExpandedContent,bo as RouteEventItemCompact,It as RouteEventsModalWithTabs,Yt as RouteObserver,ye as RouteParser,An as RouteTracker,Tt as RoutesSitemap,Rn as RoutesToolView,Wa as claimBrowserRouteEvents,En as createRouteEventsTool,M as navigationStackStore,Na as registerBrowserRoutes,he as routeEventStore,Jn as routeEventsSyncAdapter,So as routeEventsToolPreset,De as routeObserver,mo as useNavigationStack,Ha as useParentRoutes,ja as useRoute,Zt as useRouteEvents,Wn as useRouteObserver,On as useRouteObserverReactNavigation,Xe as useRouteSitemap};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/route-events",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.79",
|
|
4
4
|
"description": "Inspect reported navigation state and supported route actions in React Native apps using Expo Router or React Navigation.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
],
|
|
35
35
|
"sideEffects": false,
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@buoy-gg/floating-tools-core": "^7.0.
|
|
38
|
-
"@buoy-gg/shared-ui": "^7.0.
|
|
37
|
+
"@buoy-gg/floating-tools-core": "^7.0.79",
|
|
38
|
+
"@buoy-gg/shared-ui": "^7.0.79"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@buoy-gg/license": "7.0.
|
|
41
|
+
"@buoy-gg/license": "7.0.79",
|
|
42
42
|
"react": "*"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@types/react-native": "^0.73.0",
|
|
66
66
|
"expo-router": "~5.0.7",
|
|
67
67
|
"typescript": "~5.8.3",
|
|
68
|
-
"@buoy-gg/license": "^7.0.
|
|
68
|
+
"@buoy-gg/license": "^7.0.79"
|
|
69
69
|
},
|
|
70
70
|
"react-native-builder-bob": {
|
|
71
71
|
"source": "src",
|