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