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