@buoy-gg/location 7.0.64 → 7.0.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SchematicMap=SchematicMap;var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _geo=require("../engine/geo");var _format=require("./format");var _jsxRuntime=require("react/jsx-runtime");const PIN="#F87171";const ASPECT=1.8;const NEARBY_METERS=6e4;const MIN_SPAN_METERS=400;function SchematicMap({snapshot:t,onPinPlace:a,onCrossRegion:l}){const i=t.position;const r=t.override.mode==="route"?t.override.route:null;const n=i??t.places[0]??firstRegion(t.tasks)??null;if(!n)return null;const s=e=>!i||(0,_geo.distanceMeters)(i,e)<=NEARBY_METERS;const y=t.places.filter(s);const M=t.tasks.filter(e=>e.kind==="geofencing").flatMap(e=>e.regions.filter(s).map(o=>({task:e,region:o})));const x=t.places.length-y.length;const _=Math.cos(n.latitude*Math.PI/180);const c=e=>({x:(e.longitude-n.longitude)*111320*_,y:(e.latitude-n.latitude)*110540});const d=[];if(i)d.push({...c(i),r:60});for(const e of r?.points??[])d.push({...c(e),r:0});for(const e of y)d.push({...c(e),r:60});for(const e of M)d.push({...c(e.region),r:e.region.radius});let p=Infinity;let f=-Infinity;let b=Infinity;let m=-Infinity;for(const e of d){p=Math.min(p,e.x-e.r);f=Math.max(f,e.x+e.r);b=Math.min(b,e.y-e.r);m=Math.max(m,e.y+e.r)}const $=(p+f)/2;const I=(b+m)/2;const S=Math.max(MIN_SPAN_METERS,(m-b)*1.35,(f-p)*1.2/ASPECT);const w=S*ASPECT;const u=e=>{const o=c(e);return{x:.5+(o.x-$)/w,y:.5-(o.y-I)/S}};const j=scaleBar(w);const v=t.override.mode==="fixed"?t.override.place.label:void 0;return(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.map,testID:"location-map",accessibilityLabel:"Map of places, geofences and the simulated position",children:[GRID.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.gridV,{left:pct(e)}]},`v${e}`)),GRID.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.gridH,{top:pct(e)}]},`h${e}`)),M.map(({task:e,region:o})=>{const h=u(o);const g=2*o.radius/w;const C=g*ASPECT;const R=o.state==="inside";return(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:`location-map-region-${slug(o.identifier)}`,accessibilityRole:"button",accessibilityLabel:`${R?"Leave":"Enter"} ${o.label??o.identifier}`,activeOpacity:.6,onPress:()=>l(e,o),style:[styles.fence,R?styles.fenceInside:null,{left:pct(h.x-g/2),top:pct(h.y-C/2),width:pct(g),height:pct(C)}]},`${e.name}:${o.identifier}`)}),r?segments(r.points.map(u)).map((e,o)=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[styles.segment,{left:pct(e.midX-e.length/2),top:pct(e.midY),width:pct(e.length),transform:[{rotate:`${e.angle}rad`}]}]},`seg${o}`)):null,y.map((e,o)=>{const h=u(e);const g=!!v&&v===e.label;return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:`location-map-place-${slug(e.label??String(o))}`,accessibilityRole:"button",accessibilityLabel:`Pin ${e.label??"this place"}`,activeOpacity:.6,onPress:()=>a(e),style:[styles.placeHit,{left:pct(h.x),top:pct(h.y)}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.placeDot,g?styles.placeDotSelected:null]}),e.label?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.placeLabel,numberOfLines:1,children:e.label}):null]},`${e.label??o}`)}),i?(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"none",style:[styles.pinWrap,{left:pct(u(i).x),top:pct(u(i).y)}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.pinHalo}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.pin,t.current.reason==="gap"?styles.pinHollow:null]})]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.scale,pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.scaleBar,{width:pct(j.fraction)}]}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.scaleLabel,children:j.label})]}),x>0?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.offMap,pointerEvents:"none",children:`${x} more ${x===1?"place":"places"} off the map`}):null]})})}const GRID=[.2,.4,.6,.8];function pct(t){return`${t*100}%`}function firstRegion(t){for(const a of t)if(a.regions[0])return a.regions[0];return null}function segments(t){const a=[];for(let l=1;l<t.length;l++){const i=t[l-1];const r=t[l];const n=r.x-i.x;const s=(r.y-i.y)/ASPECT;a.push({midX:(i.x+r.x)/2,midY:(i.y+r.y)/2,length:Math.sqrt(n*n+s*s),angle:Math.atan2(s,n)})}return a}function scaleBar(t){const a=t/4;const l=(0,_format.usesMiles)()?1609.344:1e3;const i=(0,_format.usesMiles)()?[.01,.02,.05,.1,.2,.5,1,2,5,10,20,50,100].map(n=>n*l):[10,20,50,100,200,500,1e3,2e3,5e3,1e4,2e4,5e4,1e5];let r=i[0];for(const n of i)if(n<=a)r=n;return{fraction:r/t,label:(0,_format.formatDistance)(r)}}function slug(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}const styles=_reactNative.StyleSheet.create({map:{width:"100%",aspectRatio:ASPECT,borderRadius:_sharedUi.night.radius.card,borderWidth:1,borderColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface,overflow:"hidden"},gridV:{position:"absolute",top:0,bottom:0,width:_reactNative.StyleSheet.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},gridH:{position:"absolute",left:0,right:0,height:_reactNative.StyleSheet.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},fence:{position:"absolute",borderRadius:9999,borderWidth:1,borderColor:"rgba(255, 255, 255, 0.22)",backgroundColor:"rgba(255, 255, 255, 0.04)",minWidth:10,minHeight:10},fenceInside:{borderColor:_sharedUi.night.color.accentBorderStrong,backgroundColor:_sharedUi.night.color.accentSoft},segment:{position:"absolute",height:3,marginTop:-1.5,borderRadius:1.5,backgroundColor:"rgba(248, 113, 113, 0.45)"},placeHit:{position:"absolute",flexDirection:"row",alignItems:"center",gap:4,height:24,marginTop:-12,marginLeft:-12,paddingLeft:8,paddingRight:4},placeDot:{width:8,height:8,borderRadius:4,backgroundColor:_sharedUi.night.color.textSecondary},placeDotSelected:{backgroundColor:_sharedUi.night.color.text},placeLabel:{color:_sharedUi.night.color.textSecondary,fontSize:10,fontWeight:"500",maxWidth:110},pinWrap:{position:"absolute",width:28,height:28,marginLeft:-14,marginTop:-14,alignItems:"center",justifyContent:"center"},pinHalo:{position:"absolute",width:28,height:28,borderRadius:14,backgroundColor:"rgba(248, 113, 113, 0.22)"},pin:{width:14,height:14,borderRadius:7,backgroundColor:PIN,borderWidth:2,borderColor:"#FFFFFF"},pinHollow:{backgroundColor:"transparent",borderColor:PIN},scale:{position:"absolute",left:10,right:10,bottom:8,gap:3},scaleBar:{height:2,borderRadius:1,backgroundColor:_sharedUi.night.color.textTertiary},scaleLabel:{color:_sharedUi.night.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},offMap:{position:"absolute",right:10,bottom:8,color:_sharedUi.night.color.textTertiary,fontSize:10}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SchematicMap=SchematicMap;var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _geo=require("../engine/geo");var _format=require("./format");var _jsxRuntime=require("react/jsx-runtime");const PIN="#F87171";const ASPECT=1.8;const NEARBY_METERS=6e4;const MIN_SPAN_METERS=400;function SchematicMap({snapshot:t,onPinPlace:a,onCrossRegion:l}){const i=t.position;const r=t.override.mode==="route"?t.override.route:null;const n=i??t.places[0]??firstRegion(t.tasks)??null;if(!n)return null;const s=e=>!i||(0,_geo.distanceMeters)(i,e)<=NEARBY_METERS;const y=t.places.filter(s);const M=t.tasks.filter(e=>e.kind==="geofencing").flatMap(e=>e.regions.filter(s).map(o=>({task:e,region:o})));const x=t.places.length-y.length;const _=Math.cos(n.latitude*Math.PI/180);const c=e=>({x:(e.longitude-n.longitude)*111320*_,y:(e.latitude-n.latitude)*110540});const d=[];if(i)d.push({...c(i),r:60});for(const e of r?.points??[])d.push({...c(e),r:0});for(const e of y)d.push({...c(e),r:60});for(const e of M)d.push({...c(e.region),r:e.region.radius});let p=Infinity;let f=-Infinity;let b=Infinity;let m=-Infinity;for(const e of d){p=Math.min(p,e.x-e.r);f=Math.max(f,e.x+e.r);b=Math.min(b,e.y-e.r);m=Math.max(m,e.y+e.r)}const I=(p+f)/2;const $=(b+m)/2;const S=Math.max(MIN_SPAN_METERS,(m-b)*1.35,(f-p)*1.2/ASPECT);const w=S*ASPECT;const u=e=>{const o=c(e);return{x:.5+(o.x-I)/w,y:.5-(o.y-$)/S}};const j=scaleBar(w);const v=t.override.mode==="fixed"?t.override.place.label:void 0;return(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.map,testID:"location-map",accessibilityLabel:"Map of places, geofences and the simulated position",children:[GRID.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.gridV,{left:pct(e)}]},`v${e}`)),GRID.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.gridH,{top:pct(e)}]},`h${e}`)),M.map(({task:e,region:o})=>{const h=u(o);const g=2*o.radius/w;const C=g*ASPECT;const R=o.state==="inside";return(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:`location-map-region-${slug(o.identifier)}`,accessibilityRole:"button",accessibilityLabel:`${R?"Leave":"Enter"} ${o.label??o.identifier}`,activeOpacity:.6,onPress:()=>l(e,o),style:[styles.fence,R?styles.fenceInside:null,{left:pct(h.x-g/2),top:pct(h.y-C/2),width:pct(g),height:pct(C)}]},`${e.name}:${o.identifier}`)}),r?segments(r.points.map(u)).map((e,o)=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[styles.segment,{left:pct(e.midX-e.length/2),top:pct(e.midY),width:pct(e.length),transform:[{rotate:`${e.angle}rad`}]}]},`seg${o}`)):null,y.map((e,o)=>{const h=u(e);const g=!!v&&v===e.label;return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:`location-map-place-${slug(e.label??String(o))}`,accessibilityRole:"button",accessibilityLabel:`Pin ${e.label??"this place"}`,activeOpacity:.6,onPress:()=>a(e),style:[styles.placeHit,{left:pct(h.x),top:pct(h.y)}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.placeDot,g?styles.placeDotSelected:null]}),e.label?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.placeLabel,numberOfLines:1,children:e.label}):null]},`${e.label??o}`)}),i?(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"none",style:[styles.pinWrap,{left:pct(u(i).x),top:pct(u(i).y)}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.pinHalo}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.pin,t.current.reason==="gap"?styles.pinHollow:null]})]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.scale,pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.scaleBar,{width:pct(j.fraction)}]}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.scaleLabel,children:j.label})]}),x>0?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.offMap,pointerEvents:"none",children:`${x} more ${x===1?"place":"places"} off the map`}):null]})})}const GRID=[.2,.4,.6,.8];function pct(t){return`${t*100}%`}function firstRegion(t){for(const a of t)if(a.regions[0])return a.regions[0];return null}function segments(t){const a=[];for(let l=1;l<t.length;l++){const i=t[l-1];const r=t[l];const n=r.x-i.x;const s=(r.y-i.y)/ASPECT;a.push({midX:(i.x+r.x)/2,midY:(i.y+r.y)/2,length:Math.sqrt(n*n+s*s),angle:Math.atan2(s,n)})}return a}function scaleBar(t){const a=t/4;const l=(0,_format.usesMiles)()?1609.344:1e3;const i=(0,_format.usesMiles)()?[.01,.02,.05,.1,.2,.5,1,2,5,10,20,50,100].map(n=>n*l):[10,20,50,100,200,500,1e3,2e3,5e3,1e4,2e4,5e4,1e5];let r=i[0];for(const n of i)if(n<=a)r=n;return{fraction:r/t,label:(0,_format.formatDistance)(r)}}function slug(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}const styles=_reactNative.StyleSheet.create({map:{width:"100%",aspectRatio:ASPECT,borderRadius:_sharedUi.night.radius.card,borderWidth:1,borderColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface,overflow:"hidden"},gridV:{position:"absolute",top:0,bottom:0,width:_reactNative.StyleSheet.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},gridH:{position:"absolute",left:0,right:0,height:_reactNative.StyleSheet.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},fence:{position:"absolute",zIndex:1,borderRadius:9999,borderWidth:1,borderColor:"rgba(255, 255, 255, 0.22)",backgroundColor:"rgba(255, 255, 255, 0.04)",minWidth:10,minHeight:10},fenceInside:{borderColor:_sharedUi.night.color.accentBorderStrong,backgroundColor:_sharedUi.night.color.accentSoft},segment:{position:"absolute",height:3,marginTop:-1.5,borderRadius:1.5,backgroundColor:"rgba(248, 113, 113, 0.45)"},placeHit:{position:"absolute",flexDirection:"row",alignItems:"center",gap:4,height:24,marginTop:-12,marginLeft:-12,paddingLeft:8,paddingRight:4},placeDot:{width:8,height:8,borderRadius:4,backgroundColor:_sharedUi.night.color.textSecondary},placeDotSelected:{backgroundColor:_sharedUi.night.color.text},placeLabel:{color:_sharedUi.night.color.textSecondary,fontSize:10,fontWeight:"500",maxWidth:110},pinWrap:{position:"absolute",width:28,height:28,marginLeft:-14,marginTop:-14,alignItems:"center",justifyContent:"center"},pinHalo:{position:"absolute",width:28,height:28,borderRadius:14,backgroundColor:"rgba(248, 113, 113, 0.22)"},pin:{width:14,height:14,borderRadius:7,backgroundColor:PIN,borderWidth:2,borderColor:"#FFFFFF"},pinHollow:{backgroundColor:"transparent",borderColor:PIN},scale:{position:"absolute",left:10,right:10,bottom:8,gap:3},scaleBar:{height:2,borderRadius:1,backgroundColor:_sharedUi.night.color.textTertiary},scaleLabel:{color:_sharedUi.night.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},offMap:{position:"absolute",right:10,bottom:8,color:_sharedUi.night.color.textTertiary,fontSize:10}});
@@ -1 +1 @@
1
- "use strict";import{StyleSheet as k,Text as v,TouchableOpacity as F,View as s}from"react-native";import{night as d}from"@buoy-gg/shared-ui";import{distanceMeters as V}from"../engine/geo";import{formatDistance as X,usesMiles as P}from"./format";import{jsx as c,jsxs as $}from"react/jsx-runtime";const j="#F87171";const x=1.8;const A=6e4;const q=400;export function SchematicMap({snapshot:e,onPinPlace:u,onCrossRegion:p}){const r=e.position;const a=e.override.mode==="route"?e.override.route:null;const l=r??e.places[0]??G(e.tasks)??null;if(!l)return null;const f=t=>!r||V(r,t)<=A;const w=e.places.filter(f);const _=e.tasks.filter(t=>t.kind==="geofencing").flatMap(t=>t.regions.filter(f).map(o=>({task:t,region:o})));const I=e.places.length-w.length;const z=Math.cos(l.latitude*Math.PI/180);const b=t=>({x:(t.longitude-l.longitude)*111320*z,y:(t.latitude-l.latitude)*110540});const g=[];if(r)g.push({...b(r),r:60});for(const t of a?.points??[])g.push({...b(t),r:0});for(const t of w)g.push({...b(t),r:60});for(const t of _)g.push({...b(t.region),r:t.region.radius});let C=Infinity;let M=-Infinity;let S=Infinity;let R=-Infinity;for(const t of g){C=Math.min(C,t.x-t.r);M=Math.max(M,t.x+t.r);S=Math.min(S,t.y-t.r);R=Math.max(R,t.y+t.r)}const N=(C+M)/2;const O=(S+R)/2;const E=Math.max(q,(R-S)*1.35,(M-C)*1.2/x);const L=E*x;const h=t=>{const o=b(t);return{x:.5+(o.x-N)/L,y:.5-(o.y-O)/E}};const T=K(L);const W=e.override.mode==="fixed"?e.override.place.label:void 0;return c(s,{children:$(s,{style:n.map,testID:"location-map",accessibilityLabel:"Map of places, geofences and the simulated position",children:[Y.map(t=>c(s,{style:[n.gridV,{left:i(t)}]},`v${t}`)),Y.map(t=>c(s,{style:[n.gridH,{top:i(t)}]},`h${t}`)),_.map(({task:t,region:o})=>{const m=h(o);const y=2*o.radius/L;const D=y*x;const H=o.state==="inside";return c(F,{testID:`location-map-region-${B(o.identifier)}`,accessibilityRole:"button",accessibilityLabel:`${H?"Leave":"Enter"} ${o.label??o.identifier}`,activeOpacity:.6,onPress:()=>p(t,o),style:[n.fence,H?n.fenceInside:null,{left:i(m.x-y/2),top:i(m.y-D/2),width:i(y),height:i(D)}]},`${t.name}:${o.identifier}`)}),a?J(a.points.map(h)).map((t,o)=>c(s,{pointerEvents:"none",style:[n.segment,{left:i(t.midX-t.length/2),top:i(t.midY),width:i(t.length),transform:[{rotate:`${t.angle}rad`}]}]},`seg${o}`)):null,w.map((t,o)=>{const m=h(t);const y=!!W&&W===t.label;return $(F,{testID:`location-map-place-${B(t.label??String(o))}`,accessibilityRole:"button",accessibilityLabel:`Pin ${t.label??"this place"}`,activeOpacity:.6,onPress:()=>u(t),style:[n.placeHit,{left:i(m.x),top:i(m.y)}],children:[c(s,{style:[n.placeDot,y?n.placeDotSelected:null]}),t.label?c(v,{style:n.placeLabel,numberOfLines:1,children:t.label}):null]},`${t.label??o}`)}),r?$(s,{pointerEvents:"none",style:[n.pinWrap,{left:i(h(r).x),top:i(h(r).y)}],children:[c(s,{style:n.pinHalo}),c(s,{style:[n.pin,e.current.reason==="gap"?n.pinHollow:null]})]}):null,$(s,{style:n.scale,pointerEvents:"none",children:[c(s,{style:[n.scaleBar,{width:i(T.fraction)}]}),c(v,{style:n.scaleLabel,children:T.label})]}),I>0?c(v,{style:n.offMap,pointerEvents:"none",children:`${I} more ${I===1?"place":"places"} off the map`}):null]})})}const Y=[.2,.4,.6,.8];function i(e){return`${e*100}%`}function G(e){for(const u of e)if(u.regions[0])return u.regions[0];return null}function J(e){const u=[];for(let p=1;p<e.length;p++){const r=e[p-1];const a=e[p];const l=a.x-r.x;const f=(a.y-r.y)/x;u.push({midX:(r.x+a.x)/2,midY:(r.y+a.y)/2,length:Math.sqrt(l*l+f*f),angle:Math.atan2(f,l)})}return u}function K(e){const u=e/4;const p=P()?1609.344:1e3;const r=P()?[.01,.02,.05,.1,.2,.5,1,2,5,10,20,50,100].map(l=>l*p):[10,20,50,100,200,500,1e3,2e3,5e3,1e4,2e4,5e4,1e5];let a=r[0];for(const l of r)if(l<=u)a=l;return{fraction:a/e,label:X(a)}}function B(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}const n=k.create({map:{width:"100%",aspectRatio:x,borderRadius:d.radius.card,borderWidth:1,borderColor:d.color.border,backgroundColor:d.color.surface,overflow:"hidden"},gridV:{position:"absolute",top:0,bottom:0,width:k.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},gridH:{position:"absolute",left:0,right:0,height:k.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},fence:{position:"absolute",borderRadius:9999,borderWidth:1,borderColor:"rgba(255, 255, 255, 0.22)",backgroundColor:"rgba(255, 255, 255, 0.04)",minWidth:10,minHeight:10},fenceInside:{borderColor:d.color.accentBorderStrong,backgroundColor:d.color.accentSoft},segment:{position:"absolute",height:3,marginTop:-1.5,borderRadius:1.5,backgroundColor:"rgba(248, 113, 113, 0.45)"},placeHit:{position:"absolute",flexDirection:"row",alignItems:"center",gap:4,height:24,marginTop:-12,marginLeft:-12,paddingLeft:8,paddingRight:4},placeDot:{width:8,height:8,borderRadius:4,backgroundColor:d.color.textSecondary},placeDotSelected:{backgroundColor:d.color.text},placeLabel:{color:d.color.textSecondary,fontSize:10,fontWeight:"500",maxWidth:110},pinWrap:{position:"absolute",width:28,height:28,marginLeft:-14,marginTop:-14,alignItems:"center",justifyContent:"center"},pinHalo:{position:"absolute",width:28,height:28,borderRadius:14,backgroundColor:"rgba(248, 113, 113, 0.22)"},pin:{width:14,height:14,borderRadius:7,backgroundColor:j,borderWidth:2,borderColor:"#FFFFFF"},pinHollow:{backgroundColor:"transparent",borderColor:j},scale:{position:"absolute",left:10,right:10,bottom:8,gap:3},scaleBar:{height:2,borderRadius:1,backgroundColor:d.color.textTertiary},scaleLabel:{color:d.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},offMap:{position:"absolute",right:10,bottom:8,color:d.color.textTertiary,fontSize:10}});
1
+ "use strict";import{StyleSheet as k,Text as v,TouchableOpacity as F,View as s}from"react-native";import{night as d}from"@buoy-gg/shared-ui";import{distanceMeters as V}from"../engine/geo";import{formatDistance as X,usesMiles as P}from"./format";import{jsx as c,jsxs as R}from"react/jsx-runtime";const j="#F87171";const x=1.8;const A=6e4;const q=400;export function SchematicMap({snapshot:e,onPinPlace:u,onCrossRegion:p}){const r=e.position;const a=e.override.mode==="route"?e.override.route:null;const l=r??e.places[0]??G(e.tasks)??null;if(!l)return null;const f=t=>!r||V(r,t)<=A;const $=e.places.filter(f);const _=e.tasks.filter(t=>t.kind==="geofencing").flatMap(t=>t.regions.filter(f).map(o=>({task:t,region:o})));const w=e.places.length-$.length;const B=Math.cos(l.latitude*Math.PI/180);const b=t=>({x:(t.longitude-l.longitude)*111320*B,y:(t.latitude-l.latitude)*110540});const g=[];if(r)g.push({...b(r),r:60});for(const t of a?.points??[])g.push({...b(t),r:0});for(const t of $)g.push({...b(t),r:60});for(const t of _)g.push({...b(t.region),r:t.region.radius});let C=Infinity;let M=-Infinity;let S=Infinity;let I=-Infinity;for(const t of g){C=Math.min(C,t.x-t.r);M=Math.max(M,t.x+t.r);S=Math.min(S,t.y-t.r);I=Math.max(I,t.y+t.r)}const N=(C+M)/2;const O=(S+I)/2;const E=Math.max(q,(I-S)*1.35,(M-C)*1.2/x);const L=E*x;const h=t=>{const o=b(t);return{x:.5+(o.x-N)/L,y:.5-(o.y-O)/E}};const T=K(L);const W=e.override.mode==="fixed"?e.override.place.label:void 0;return c(s,{children:R(s,{style:n.map,testID:"location-map",accessibilityLabel:"Map of places, geofences and the simulated position",children:[Y.map(t=>c(s,{style:[n.gridV,{left:i(t)}]},`v${t}`)),Y.map(t=>c(s,{style:[n.gridH,{top:i(t)}]},`h${t}`)),_.map(({task:t,region:o})=>{const m=h(o);const y=2*o.radius/L;const D=y*x;const H=o.state==="inside";return c(F,{testID:`location-map-region-${z(o.identifier)}`,accessibilityRole:"button",accessibilityLabel:`${H?"Leave":"Enter"} ${o.label??o.identifier}`,activeOpacity:.6,onPress:()=>p(t,o),style:[n.fence,H?n.fenceInside:null,{left:i(m.x-y/2),top:i(m.y-D/2),width:i(y),height:i(D)}]},`${t.name}:${o.identifier}`)}),a?J(a.points.map(h)).map((t,o)=>c(s,{pointerEvents:"none",style:[n.segment,{left:i(t.midX-t.length/2),top:i(t.midY),width:i(t.length),transform:[{rotate:`${t.angle}rad`}]}]},`seg${o}`)):null,$.map((t,o)=>{const m=h(t);const y=!!W&&W===t.label;return R(F,{testID:`location-map-place-${z(t.label??String(o))}`,accessibilityRole:"button",accessibilityLabel:`Pin ${t.label??"this place"}`,activeOpacity:.6,onPress:()=>u(t),style:[n.placeHit,{left:i(m.x),top:i(m.y)}],children:[c(s,{style:[n.placeDot,y?n.placeDotSelected:null]}),t.label?c(v,{style:n.placeLabel,numberOfLines:1,children:t.label}):null]},`${t.label??o}`)}),r?R(s,{pointerEvents:"none",style:[n.pinWrap,{left:i(h(r).x),top:i(h(r).y)}],children:[c(s,{style:n.pinHalo}),c(s,{style:[n.pin,e.current.reason==="gap"?n.pinHollow:null]})]}):null,R(s,{style:n.scale,pointerEvents:"none",children:[c(s,{style:[n.scaleBar,{width:i(T.fraction)}]}),c(v,{style:n.scaleLabel,children:T.label})]}),w>0?c(v,{style:n.offMap,pointerEvents:"none",children:`${w} more ${w===1?"place":"places"} off the map`}):null]})})}const Y=[.2,.4,.6,.8];function i(e){return`${e*100}%`}function G(e){for(const u of e)if(u.regions[0])return u.regions[0];return null}function J(e){const u=[];for(let p=1;p<e.length;p++){const r=e[p-1];const a=e[p];const l=a.x-r.x;const f=(a.y-r.y)/x;u.push({midX:(r.x+a.x)/2,midY:(r.y+a.y)/2,length:Math.sqrt(l*l+f*f),angle:Math.atan2(f,l)})}return u}function K(e){const u=e/4;const p=P()?1609.344:1e3;const r=P()?[.01,.02,.05,.1,.2,.5,1,2,5,10,20,50,100].map(l=>l*p):[10,20,50,100,200,500,1e3,2e3,5e3,1e4,2e4,5e4,1e5];let a=r[0];for(const l of r)if(l<=u)a=l;return{fraction:a/e,label:X(a)}}function z(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}const n=k.create({map:{width:"100%",aspectRatio:x,borderRadius:d.radius.card,borderWidth:1,borderColor:d.color.border,backgroundColor:d.color.surface,overflow:"hidden"},gridV:{position:"absolute",top:0,bottom:0,width:k.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},gridH:{position:"absolute",left:0,right:0,height:k.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},fence:{position:"absolute",zIndex:1,borderRadius:9999,borderWidth:1,borderColor:"rgba(255, 255, 255, 0.22)",backgroundColor:"rgba(255, 255, 255, 0.04)",minWidth:10,minHeight:10},fenceInside:{borderColor:d.color.accentBorderStrong,backgroundColor:d.color.accentSoft},segment:{position:"absolute",height:3,marginTop:-1.5,borderRadius:1.5,backgroundColor:"rgba(248, 113, 113, 0.45)"},placeHit:{position:"absolute",flexDirection:"row",alignItems:"center",gap:4,height:24,marginTop:-12,marginLeft:-12,paddingLeft:8,paddingRight:4},placeDot:{width:8,height:8,borderRadius:4,backgroundColor:d.color.textSecondary},placeDotSelected:{backgroundColor:d.color.text},placeLabel:{color:d.color.textSecondary,fontSize:10,fontWeight:"500",maxWidth:110},pinWrap:{position:"absolute",width:28,height:28,marginLeft:-14,marginTop:-14,alignItems:"center",justifyContent:"center"},pinHalo:{position:"absolute",width:28,height:28,borderRadius:14,backgroundColor:"rgba(248, 113, 113, 0.22)"},pin:{width:14,height:14,borderRadius:7,backgroundColor:j,borderWidth:2,borderColor:"#FFFFFF"},pinHollow:{backgroundColor:"transparent",borderColor:j},scale:{position:"absolute",left:10,right:10,bottom:8,gap:3},scaleBar:{height:2,borderRadius:1,backgroundColor:d.color.textTertiary},scaleLabel:{color:d.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},offMap:{position:"absolute",right:10,bottom:8,color:d.color.textTertiary,fontSize:10}});
package/lib/web/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  "use client";var Yt=Object.defineProperty;var Mi=Object.getOwnPropertyDescriptor;var Ei=Object.getOwnPropertyNames;var Ri=Object.prototype.hasOwnProperty;var Ni=(e,t)=>{for(var n in t)Yt(e,n,{get:t[n],enumerable:true})},Qt=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ei(t))!Ri.call(e,o)&&o!==n&&Yt(e,o,{get:()=>t[o],enumerable:!(i=Mi(t,o))||i.enumerable});return e},Oi=(e,t,n)=>(Qt(e,t,"default"),n&&Qt(n,t,"default"));var Xt=(()=>{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{realNow as O}from"@buoy-gg/shared-ui/web";var Zt=63710088e-1,X=e=>e*Math.PI/180,yt=e=>e*180/Math.PI;function Ie(e){if(!e||typeof e!="object")return false;let{latitude:t,longitude:n}=e;return typeof t=="number"&&typeof n=="number"&&Number.isFinite(t)&&Number.isFinite(n)&&Math.abs(t)<=90&&Math.abs(n)<=180}function en(e){let t=((e+180)%360+360)%360-180;return t===-180&&e>0?180:t}function V(e,t){let n=X(t.latitude-e.latitude),i=X(t.longitude-e.longitude),o=Math.sin(n/2)**2+Math.cos(X(e.latitude))*Math.cos(X(t.latitude))*Math.sin(i/2)**2;return 2*Zt*Math.asin(Math.min(1,Math.sqrt(o)))}function Ze(e,t){let n=X(e.latitude),i=X(t.latitude),o=X(t.longitude-e.longitude),r=Math.sin(o)*Math.cos(i),a=Math.cos(n)*Math.sin(i)-Math.sin(n)*Math.cos(i)*Math.cos(o);return(yt(Math.atan2(r,a))+360)%360}function je(e,t,n){let i=n/Zt,o=X(t),r=X(e.latitude),a=X(e.longitude),c=Math.asin(Math.sin(r)*Math.cos(i)+Math.cos(r)*Math.sin(i)*Math.cos(o)),d=a+Math.atan2(Math.sin(o)*Math.sin(i)*Math.cos(r),Math.cos(i)-Math.sin(r)*Math.sin(c));return{latitude:yt(c),longitude:en(yt(d))}}function Di(e,t,n){if(n<=0)return{latitude:e.latitude,longitude:e.longitude};if(n>=1)return{latitude:t.latitude,longitude:t.longitude};let i=V(e,t);return i<1e-6?{latitude:e.latitude,longitude:e.longitude}:je(e,Ze(e,t),i*n)}function tn(e){let t=[];for(let n=1;n<e.length;n++)t.push(V(e[n-1],e[n]));return t}function bt(e){return tn(e).reduce((t,n)=>t+n,0)}function et(e,t){let{points:n}=e;if(n.length===0)throw new Error("A route needs at least one point.");let i=n[0];if(n.length===1)return{...i,along:0,heading:0,leg:0,finished:true,inGap:false};let o=tn(n),r=o.reduce((p,x)=>p+x,0),a=Math.max(0,t),c=false;r<=0?(a=0,c=!e.loop):e.loop?a=a%r:a>=r&&(a=r,c=true);let d=(e.gaps??[]).some(([p,x])=>a>=p&&a<x),h=a;for(let p=0;p<o.length;p++){let x=o[p],I=n[p],A=n[p+1],F=p===o.length-1;if(h<x||F){let _=x>0?Math.min(1,h/x):1;return{...Di(I,A,_),along:a,heading:Ze(I,A),leg:p,finished:c,inGap:d}}h-=x}return{...n[n.length-1],along:a,heading:0,leg:o.length-1,finished:c,inGap:d}}function Bi(e,t,n){if(t<=0)return{latitude:e.latitude,longitude:e.longitude};let i=nn(Math.sin(n*12.9898)*43758.5453),o=nn(Math.sin(n*78.233)*12543.1234);return je(e,i*360,Math.sqrt(o)*t)}function nn(e){return e-Math.floor(e)}var ji=3e3;function Fi(e){let t=Math.round(e.latitude/.03)*.03,n=.03/Math.max(.2,Math.cos(X(t))),i=Math.round(e.longitude/n)*n;return{...e,latitude:on(t),longitude:on(en(i)),accuracy:Math.max(e.accuracy,ji),heading:null,speed:null}}function on(e){return Math.round(e*1e6)/1e6}function _i(e,t){return V(e,t)<=e.radius}function zi(e,t,n){let i={},o=[];for(let r of e){let a=t[r.identifier]??"unknown",c=_i(r,n)?"inside":"outside";if(i[r.identifier]=c,a===c)continue;let d=c==="inside"?"enter":"exit",h=a==="unknown";(h||(d==="enter"?r.notifyOnEnter:r.notifyOnExit))&&o.push({identifier:r.identifier,kind:d,initial:h})}return{states:i,transitions:o}}function Wi(e,t,n){if(t==="inside")return{latitude:e.latitude,longitude:e.longitude};let i=n&&V(e,n)>1?Ze(e,n):0;return je(e,i,e.radius+Math.max(50,e.radius*.25))}function rn(e,t){if(!Ie(e))return null;let n=e,i=Number(n.radius);return!Number.isFinite(i)||i<=0?null:{identifier:typeof n.identifier=="string"&&n.identifier?n.identifier:`region-${t+1}`,latitude:n.latitude,longitude:n.longitude,radius:i,notifyOnEnter:n.notifyOnEnter!==false,notifyOnExit:n.notifyOnExit!==false}}function vt(e){let t=e.trim(),n=[/@(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)/,/[?&](?:q|ll|query|center)=(-?\d+(?:\.\d+)?)(?:,|%2C)\s*(-?\d+(?:\.\d+)?)/i,/^(-?\d+(?:\.\d+)?)\s*[,\s]\s*(-?\d+(?:\.\d+)?)$/];for(let i of n){let o=t.match(i);if(o){let r={latitude:Number(o[1]),longitude:Number(o[2])};if(Ie(r))return r}}return null}function Fe(e,t=5){return`${e.latitude.toFixed(t)}, ${e.longitude.toFixed(t)}`}var wt={persist:true,showChip:true},Ui={latitude:37.3349,longitude:-122.009,label:"Apple Park"};function kt(){return{mode:"real",place:{...Ui},altitude:30,accuracy:5,jitter:0,heading:null,route:null,playing:false,anchorReal:0,anchorMeters:0,signal:true,services:true,interval:1e3}}function _e(e){return!!e&&(e.mode!=="real"||!e.signal||!e.services)}function Ae(e){return!!e&&e.mode!=="real"}function ye(e,t,n=-1/0,i=1/0){let o=typeof e=="number"?e:Number(e);return Number.isFinite(o)?Math.min(i,Math.max(n,o)):t}function Hi(e,t){if(e===null)return null;let n=typeof e=="number"?e:Number(e);return e!==void 0&&Number.isFinite(n)?n:t}function xt(e){if(!e||typeof e!="object")return null;let t=e,n=Array.isArray(t.points)?t.points.filter(Ie):[];if(n.length<2)return null;let i=Array.isArray(t.gaps)?t.gaps.filter(o=>Array.isArray(o)&&o.length===2&&o.every(r=>typeof r=="number"&&Number.isFinite(r))):void 0;return{id:typeof t.id=="string"?t.id:void 0,name:typeof t.name=="string"?t.name:void 0,points:n.map(o=>({latitude:o.latitude,longitude:o.longitude})),speed:ye(t.speed,1.4,.1,400),loop:t.loop===true,gaps:i&&i.length?i:void 0}}function an(e){if(!e||typeof e!="object")return null;let t=e,n=kt(),i=t.mode==="fixed"||t.mode==="route"?t.mode:"real",o=t.place,r=Ie(o)?{latitude:o.latitude,longitude:o.longitude,label:typeof o.label=="string"?o.label:void 0}:n.place,a=xt(t.route);return{mode:i==="route"&&!a?"fixed":i,place:r,altitude:Hi(t.altitude,n.altitude),accuracy:ye(t.accuracy,n.accuracy,0,1e5),jitter:ye(t.jitter,0,0,1e4),heading:t.heading===null||t.heading===void 0?null:ye(t.heading,0,0,360)%360,route:a,playing:t.playing===true&&!!a,anchorReal:ye(t.anchorReal,0),anchorMeters:ye(t.anchorMeters,0,0),signal:t.signal!==false,services:t.services!==false,interval:ye(t.interval,n.interval,100,6e4)}}var ln={good:{accuracy:5,jitter:0,signal:true,services:true},weak:{accuracy:65,jitter:50,signal:true,services:true},"no-signal":{accuracy:5,jitter:0,signal:false,services:true},off:{accuracy:5,jitter:0,signal:true,services:false}};function Vi(e){if(!e.services)return"off";if(!e.signal)return"no-signal";for(let t of["good","weak"]){let n=ln[t];if(e.accuracy===n.accuracy&&e.jitter===n.jitter)return t}return null}import{devToolsStorageKeys as qi,persistentStorage as sn}from"@buoy-gg/shared-ui/web";function Gi(){try{let e=globalThis.localStorage;return e?cn(e.getItem(Ct)):void 0}catch{return}}var Ct=qi.location.state();function Ki(e){if(!e||typeof e!="object")return null;let t=e;return typeof t.name!="string"||!t.name||t.kind!=="geofencing"&&t.kind!=="locationUpdates"?null:{name:t.name,kind:t.kind,library:typeof t.library=="string"?t.library:"expo-location",options:t.options&&typeof t.options=="object"?t.options:{}}}function cn(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||t.v!==1)return null;let n=t.settings??{};return{v:1,override:an(t.override),settings:{persist:typeof n.persist=="boolean"?n.persist:wt.persist,showChip:typeof n.showChip=="boolean"?n.showChip:wt.showChip},tasks:Array.isArray(t.tasks)?t.tasks.map(Ki).filter(i=>i!==null):[]}}catch{return null}}async function Ji(){try{return cn(await sn.getItem(Ct))}catch{return null}}var It=Promise.resolve();function Yi(e){let t=JSON.stringify(e);return It=It.then(()=>sn.setItem(Ct,t)).catch(()=>{}),It.then(()=>{})}function un(){return globalThis.__buoyRealTimers??globalThis}function z(e,t){return un().setTimeout(e,t)}function Qi(e){un().clearTimeout(e)}var g=kt(),de={...wt},Te="full",Se=null,At=false,tt=false,Le=new Map,oe=new Map,D=new Map,Pe=[],Xi=0,dn=null,pn=1,ze=[],nt=[],it=new Set,We=null;function W(){We=null;for(let e of Array.from(it))try{e()}catch{}}function Ue(e){return it.add(e),()=>{it.delete(e)}}var fn=100;function S(e,t,n,i){Pe.push({id:++Xi,at:O(),kind:e,library:t,text:n,...i?{detail:i}:{}}),Pe.length>fn&&Pe.splice(0,Pe.length-fn),W()}function P(){return _e(g)}function be(){return g.services}function Zi(e){!e||e===Te||(Te=e,W())}function eo(e){if(!e)return;let t=Se&&Se.status===e.status&&Se.background===e.background&&Se.precision===e.precision;e.precision!==Te&&(Te=e.precision),!t&&(Se=e,W())}function $e(e){return g.route?g.playing?g.anchorMeters+Math.max(0,e-g.anchorReal)/1e3*g.route.speed:g.anchorMeters:0}function re(e=O()){if(!g.services)return{fix:null,reason:"services"};if(!g.signal)return{fix:null,reason:"signal"};if(g.mode==="real")return{fix:null,reason:"real"};let t,n=g.heading,i=0;if(g.mode==="route"&&g.route){let r=et(g.route,$e(e));if(r.inGap)return{fix:null,reason:"gap"};t=r;let a=g.playing&&!r.finished;n=r.heading,i=a?g.route.speed:0}else t=g.place;g.jitter>0&&(t=Bi(t,g.jitter,Math.floor(e/g.interval)+pn));let o={latitude:t.latitude,longitude:t.longitude,altitude:g.altitude,accuracy:Math.max(g.accuracy,g.jitter),altitudeAccuracy:g.altitude===null?null:3,heading:n,speed:i};return Te==="reduced"&&(o=Fi(o)),{fix:o,reason:null}}var Me=null,gn=0;function to(){return Ae(g)?oe.size>0||D.size>0?true:g.mode==="route"&&g.playing&&it.size>0:false}function ot(){Me===null&&to()&&(Me=z(()=>{Me=null,bn(),ot()},g.interval))}function hn(){Me!==null&&Qi(Me),Me=null}function mn(){hn(),bn(),ot()}function yn(e,t){let n=Number(e.options[t]);return Number.isFinite(n)&&n>0?n:0}function bn(){let e=O(),{fix:t}=re(e);if(g.mode==="route"&&g.route&&g.playing){let n=et(g.route,$e(e));n.finished&&(g={...g,playing:false,anchorMeters:n.along,anchorReal:e},Re())}t&&(vn(t,false),wn(t)),e-gn>5e3&&(gn=e,oo()),W()}function vn(e,t){for(let n of Array.from(oe.values())){if(n.kind==="heading"){let i=e.heading??0;if(!t&&n.lastHeading===i&&n.updates>0)continue;n.lastHeading=i}else{let i=yn(n,"distanceInterval");if(!t&&n.last&&V(n.last,e)<Math.max(i,.01))continue;n.last={latitude:e.latitude,longitude:e.longitude}}n.updates+=1,dn=O();try{n.deliver(e)}catch(i){S("error",n.library,`Watch ${n.id} callback threw: ${String(i?.message??i)}`)}}}function wn(e){for(let t of Array.from(D.values()))if(t.kind==="geofencing"){let{states:n,transitions:i}=zi(t.regions,t.states,e);t.states=n;for(let o of i)no(t,o)}else{let n=yn(t,"distanceInterval");if(t.lastBatchAt&&V(t.lastBatchAt,e)<Math.max(n,.01))continue;t.lastBatchAt={latitude:e.latitude,longitude:e.longitude},kn(t,{locations:[e]},"a location update")}}function no(e,t){let n=e.regions.find(o=>o.identifier===t.identifier);if(!n)return;S(t.kind,e.library,`${t.kind==="enter"?"Entered":"Left"} ${st(n)??n.identifier}`,`${e.name} \xB7 region ${n.identifier}${t.initial?" \xB7 first check after monitoring started":""}`);let i=st(n)??n.identifier;kn(e,{eventType:t.kind==="enter"?1:2,region:n},`${t.kind==="enter"?"entering":"leaving"} ${i}`)}function kn(e,t,n){let i=Le.get(e.library);if(!i?.fireTask)return;e.runs+=1,e.kind==="locationUpdates"&&S("batch",e.library,"Sent a background location update",e.name),i.fireTask(e,t).then(o=>{S("task",e.library,`Task ran for ${n}`,o!=null?`${e.name} \xB7 returned ${io(o)}`:e.name)},o=>{S("error",e.library,`Task failed for ${n}`,`${e.name} \xB7 ${String(o?.message??o)}`)})}function io(e){try{let t=typeof e=="string"?e:JSON.stringify(e);return t.length>80?`${t.slice(0,77)}\u2026`:t}catch{return String(e)}}function oo(){rt()}function rt(){for(let e of Le.values())e.readPermission?.().then(eo,()=>{})}function at(e){Le.set(e.library,e),W()}function lt(e){let t=`${e.library}:${e.kind}:${e.id}`;oe.set(t,{...e,key:t,since:O(),updates:0,last:null,lastHeading:null}),S("watch",e.library,e.kind==="heading"?"The app started watching the compass heading":"The app started watching location",`watch ${e.id} \xB7 ${e.library}`),z(()=>{let n=oe.get(t);if(!n)return;let{fix:i,reason:o}=re();i?(vn(i,false),W()):o==="services"&&n.fail?.("Location services are disabled")},0),ot()}function ae(e,t,n){let i=`${e}:${t}:${n}`,o=oe.delete(i);return o&&S("watch",e,t==="heading"?"The app stopped watching the heading":"The app stopped watching location",`watch ${n} \xB7 ${e}`),o}function ro(e,t,n){return oe.has(`${e}:${t}:${n}`)}function Tt(e,t){let n=e.kind==="geofencing"?(e.options.regions??[]).map((i,o)=>rn(i,o)).filter(i=>i!==null):[];D.set(e.name,{...e,regions:n,states:{},since:O(),runs:0,intercepted:t,lastBatchAt:null}),S("task",e.library,e.kind==="geofencing"?`The app started monitoring ${n.length} geofence${n.length===1?"":"s"}`:"The app started background location updates",e.name),Re(),Ae(g)&&z(()=>{let{fix:i}=re(),o=D.get(e.name);i&&o&&(wn(i),W())},0),ot()}function St(e){let t=D.get(e);return t?(D.delete(e),S("task",t.library,t.kind==="geofencing"?"The app stopped monitoring geofences":"The app stopped background updates",t.name),Re(),t):null}function Ee(e){return D.get(e)??null}function Lt(e){return Array.from(D.values()).filter(t=>!e||t.kind===e)}function xn(e,t){let n=D.get(e);n&&(n.intercepted=t,t||(n.states={}),Re())}function ao(e){for(let t of e){let n=ze.findIndex(i=>i.label&&i.label===t.label);n>=0?ze[n]={...t}:ze.push({...t})}W()}function st(e){let t=null,n=1/0;for(let i of ze){if(!i.label)continue;let o=V(i,e);o<=Math.max(50,e.radius)&&o<n&&(t=i,n=o)}return t?.label??null}function lo(e){for(let t of e){let n=xt(t);if(!n)continue;let i=nt.findIndex(o=>(o.id??o.name)===(n.id??n.name));i>=0?nt[i]=n:nt.push(n)}W()}function q(e){g=e;let t=_e(g);if(t!==tt){tt=t;for(let n of Le.values())try{n.onActiveChange?.(t)}catch(i){S("error",n.library,`Switching failed: ${String(i?.message??i)}`)}}return Re(),Ae(g)?mn():(hn(),W()),E()}function ct(e){return q({...g,mode:"fixed",place:{latitude:e.latitude,longitude:e.longitude,label:e.label},playing:false})}function He(){return g.mode==="route"&&g.route?et(g.route,$e(O())):g.place}function Cn(e){let t=xt(e);if(!t)throw new Error("A route needs two or more valid points.");return q({...g,mode:"route",route:t,playing:true,anchorReal:O(),anchorMeters:0})}function Pt(){if(g.mode!=="route"||!g.playing)return E();let e=O();return q({...g,playing:false,anchorMeters:$e(e),anchorReal:e})}function $t(){if(g.mode!=="route"||!g.route)return E();let e=bt(g.route.points),t=!g.route.loop&&g.anchorMeters>=e?0:g.anchorMeters;return q({...g,playing:true,anchorReal:O(),anchorMeters:t})}function In(e){if(g.mode!=="route"||!g.route)throw new Error("No route is playing.");return q({...g,anchorMeters:Math.max(0,e),anchorReal:O()})}function An(e){if(!g.route)throw new Error("No route is loaded.");if(!Number.isFinite(e)||e<=0)throw new Error("Speed must be a positive number of m/s.");let t=O();return q({...g,route:{...g.route,speed:e},anchorMeters:$e(t),anchorReal:t})}function Tn(e){let t=an({...g,...so(e)});return t?q({...t,anchorMeters:g.anchorMeters,anchorReal:g.anchorReal}):E()}function so(e){let t={};for(let[n,i]of Object.entries(e))i!==void 0&&(t[n]=i);return t}function Sn(e){return q({...g,signal:e})}function Ln(e){let t=q({...g,services:e});if(!e){for(let n of Array.from(oe.values()))n.kind==="position"&&n.fail?.("Location services are disabled");S("error","device","Location services switched off","open watches got an error")}return t}function Pn(e){let t=ln[e];if(!t)throw new Error(`Unknown conditions "${String(e)}". Use good, weak, no-signal or off.`);let n=g.services,i=e==="good"||e==="weak"?t:{signal:t.signal,services:t.services},o=q({...g,...i});if(n&&!t.services){for(let r of Array.from(oe.values()))r.kind==="position"&&r.fail?.("Location services are disabled");S("error","device","Location services switched off","open watches got an error")}return o}function $n(){if(g.mode!=="route"||!g.route)return E();let e=He();return ct({latitude:e.latitude,longitude:e.longitude})}function Mn(){return q({...g,mode:"real",playing:false})}function Mt(e,t,n){for(let i of D.values()){if(n&&i.name!==n)continue;let o=i.regions.find(c=>c.identifier===e);if(!o)continue;let r=Wi(o,t,He()),a=st(o)??o.identifier;return ct({...r,label:t==="inside"?`At ${a}`:`Outside ${a}`})}throw new Error(`No geofence region "${e}" is being monitored.`)}function Et(){let e=kt();return q({...e,place:g.place})}function co(e){return de={persist:typeof e.persist=="boolean"?e.persist:de.persist,showChip:typeof e.showChip=="boolean"?e.showChip:de.showChip},Re(),W(),E()}function uo(){return de}function po(){return Pe.length=0,W(),E()}function E(){if(We)return We;let e=O(),{fix:t,reason:n}=re(e),i=null;if(g.mode==="route"&&g.route){let a=et(g.route,$e(e)),c=bt(g.route.points);i={along:a.along,length:c,finished:a.finished,leg:a.leg,etaMs:g.playing&&!g.route.loop&&!a.finished?(c-a.along)/g.route.speed*1e3:null}}let o=Ae(g)?He():null,r=t??o;return We={active:_e(g),simulating:Ae(g),override:g,current:{fix:t,reason:n,precision:Te},permission:Se,position:o?{latitude:o.latitude,longitude:o.longitude}:null,progress:i,watches:Array.from(oe.values()).map(a=>({key:a.key,library:a.library,id:a.id,kind:a.kind,options:a.options,since:a.since,updates:a.updates})),tasks:Array.from(D.values()).map(a=>({name:a.name,kind:a.kind,library:a.library,intercepted:a.intercepted,since:a.since,runs:a.runs,options:a.options,regions:a.regions.map(c=>({...c,label:st(c),state:a.states[c.identifier]??"unknown",distance:r?V(c,r):null}))})),log:Pe.slice(-50),libraries:Array.from(Le.keys()),places:ze.slice(),routes:nt.slice(),settings:de,lastDeliveryAt:dn},We}function Re(){if(!At)return;let e={v:1,override:de.persist&&_e(g)?g:null,settings:de,tasks:Array.from(D.values()).filter(t=>t.intercepted).map(({name:t,kind:n,library:i,options:o})=>({name:t,kind:n,library:i,options:o}))};Yi(e)}function En(e){if(e){de=e.settings;for(let t of e.tasks)D.has(t.name)||fo(t);e.override&&_e(e.override)&&(g=e.override,tt=true)}}function fo(e){let t=e.kind==="geofencing"?(e.options.regions??[]).map((n,i)=>rn(n,i)).filter(n=>!!n):[];D.set(e.name,{...e,regions:t,states:{},since:O(),runs:0,intercepted:true,lastBatchAt:null})}function Rt(){if(At)return;At=true,pn=Math.floor(Math.random()*1e3)+1;let e=Gi();if(e!==void 0){En(e),Rn();return}Ji().then(t=>{En(t),Rn()})}function Rn(){for(let e of Le.values())e.onActiveChange?.(tt);Ae(g)?z(mn,0):W()}var Nn="__buoyLocationNext";function L(e,t,n){let i=e[t];if(typeof i!="function")return null;let o=i[Nn]??i,r=(...c)=>o.apply(e,c),a=n(r);a[Nn]=o;try{e[t]=a}catch{return null}return e[t]===a?r:null}function go(e,t){let n=new Error(t);return n.code=e,n}var Nt={};Ni(Nt,{AccessibilityInfo:()=>bo,ActivityIndicator:()=>mr,Alert:()=>vr,Animated:()=>vo,AppRegistry:()=>ko,AppState:()=>xo,Appearance:()=>wo,BackHandler:()=>Co,Button:()=>yr,CheckBox:()=>jo,Clipboard:()=>Io,DeviceEventEmitter:()=>Dn,Dimensions:()=>Ao,Easing:()=>To,FlatList:()=>Fo,I18nManager:()=>So,Image:()=>_o,ImageBackground:()=>zo,InteractionManager:()=>Po,Keyboard:()=>Lo,KeyboardAvoidingView:()=>Wo,LayoutAnimation:()=>$o,Linking:()=>Mo,LogBox:()=>Zo,Modal:()=>gr,NativeEventEmitter:()=>Eo,NativeModules:()=>yo,PanResponder:()=>Ro,Picker:()=>Uo,PixelRatio:()=>No,Platform:()=>On,Pressable:()=>fr,ProgressBar:()=>Ho,RefreshControl:()=>Vo,SafeAreaView:()=>qo,ScrollView:()=>zn,SectionList:()=>Go,Share:()=>Oo,StatusBar:()=>Ko,StyleSheet:()=>le,Switch:()=>hr,Text:()=>T,TextInput:()=>_n,Touchable:()=>Jo,TouchableHighlight:()=>dr,TouchableNativeFeedback:()=>Yo,TouchableOpacity:()=>se,TouchableWithoutFeedback:()=>pr,UIManager:()=>Do,Vibration:()=>Bo,View:()=>v,VirtualizedList:()=>Qo,YellowBox:()=>Xo,findNodeHandle:()=>br,unstable_createElement:()=>mo,useColorScheme:()=>er,useLocaleContext:()=>tr,useWindowDimensions:()=>nr});Oi(Nt,ho);import*as ho from"react-native-web";import{unstable_createElement as mo,NativeModules as yo,AccessibilityInfo as bo,Animated as vo,Appearance as wo,AppRegistry as ko,AppState as xo,BackHandler as Co,Clipboard as Io,Dimensions as Ao,Easing as To,I18nManager as So,Keyboard as Lo,InteractionManager as Po,LayoutAnimation as $o,Linking as Mo,NativeEventEmitter as Eo,PanResponder as Ro,PixelRatio as No,Platform as On,Share as Oo,StyleSheet as le,UIManager as Do,Vibration as Bo,CheckBox as jo,FlatList as Fo,Image as _o,ImageBackground as zo,KeyboardAvoidingView as Wo,Picker as Uo,ProgressBar as Ho,RefreshControl as Vo,SafeAreaView as qo,SectionList as Go,StatusBar as Ko,Touchable as Jo,TouchableNativeFeedback as Yo,VirtualizedList as Qo,YellowBox as Xo,LogBox as Zo,DeviceEventEmitter as Dn,useColorScheme as er,useLocaleContext as tr,useWindowDimensions as nr}from"react-native-web";import*as U from"react-native-web";import{createElement as Ot,forwardRef as Bn,useCallback as ir,useRef as or}from"react";import{useEffect as rr,useState as ar}from"react";import{createPortal as lr}from"react-dom";var sr='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as cr}from"react/jsx-runtime";var Ve=Symbol.for("@buoy-gg/portal-host"),jn=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 Fn(){let e=document;if(e[Ve])return e[Ve].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:sr});let n=()=>{let p=document.fullscreenElement,x=p&&p.tagName!=="CANVAS"?p:document.body;t.parentElement!==x&&x.appendChild(t)},i=new Map,o=p=>{(!t.contains(p.target)||!jn(p.target))&&i.set(p.code||p.key,{key:p.key,code:p.code,location:p.location,keyCode:p.keyCode,which:p.which,altKey:p.altKey,ctrlKey:p.ctrlKey,metaKey:p.metaKey,shiftKey:p.shiftKey})},r=p=>{i.delete(p.code||p.key)},a=()=>i.clear(),c=()=>{let p=[...i.values()];i.clear();for(let x of p)document.dispatchEvent(new KeyboardEvent("keyup",{...x,bubbles:true}))},d=p=>{jn(p.target)&&p.stopPropagation()},h=p=>p.stopPropagation();return n(),document.addEventListener("fullscreenchange",n),document.addEventListener("keydown",o,true),document.addEventListener("keyup",r,true),window.addEventListener("blur",a),t.addEventListener("focusin",c),t.addEventListener("keydown",d),t.addEventListener("keyup",d),t.addEventListener("keypress",d),t.addEventListener("wheel",h,{passive:true}),e[Ve]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",n),document.removeEventListener("keydown",o,true),document.removeEventListener("keyup",r,true),window.removeEventListener("blur",a),t.remove(),delete e[Ve]}},t}function ur({children:e}){let[t,n]=ar(null);return rr(()=>{let i=Fn(),o=document[Ve];return o.users++,n(i),()=>{--o.users===0&&o.dispose()}},[]),t?lr(cr("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}function G(e){let t=Bn((i,o)=>{let{accessibilityState:r,accessibilityValue:a,...c}=i;for(let d of["busy","checked","disabled","expanded","selected"])r?.[d]!==void 0&&c[`aria-${d}`]===void 0&&(c[`aria-${d}`]=r[d]);for(let[d,h]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[d]!==void 0&&c[`aria-${h}`]===void 0&&(c[`aria-${h}`]=a[d]);return Ot(e,{...c,ref:o})}),n=e.State;return n&&Object.assign(t,{State:n}),t.displayName=e.displayName??e.name??"NativeWebView",t}var v=G(U.View),T=G(U.Text),_n=G(U.TextInput),se=G(U.TouchableOpacity),dr=G(U.TouchableHighlight),pr=G(U.TouchableWithoutFeedback),fr=G(U.Pressable),zn=G(U.ScrollView),Wn=Bn((e,t)=>{let n=or(null),i=ir(o=>{if(o){let r=o;for(;r.parentElement&&r.parentElement!==document.body;)r=r.parentElement;r.parentElement===document.body&&(n.current=r,Object.assign(r.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),Fn().appendChild(r))}else n.current&&(document.body.appendChild(n.current),n.current=null);typeof t=="function"?t(o):t&&(t.current=o)},[t]);return Ot(ur,null,Ot(U.Modal,{...e,ref:i}))});Wn.displayName="Modal";var gr=G(Wn),hr=G(U.Switch),mr=G(U.ActivityIndicator),yr=G(U.Button),br=U.findNodeHandle,vr={alert(e,t,n,i){if(typeof document>"u")return;let o=document.createElement("dialog");o.dataset.buoyRoot="",o.setAttribute("aria-label",e),o.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 r=document.createElement("h2");if(r.textContent=e,r.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(r),t){let h=document.createElement("p");h.textContent=t,h.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(h)}let a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let c=n?.length?n:[{text:"OK"}],d=()=>{o.close?.(),o.remove()};for(let h of c){let p=document.createElement("button");p.type="button",p.textContent=h.text??"OK",p.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${h.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,p.onclick=()=>{d(),h.onPress?.()},a.appendChild(p)}o.addEventListener("cancel",h=>{h.preventDefault(),i?.cancelable!==false&&(d(),i?.onDismiss?.())}),o.appendChild(a),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};var wr=[{module:"RNCGeolocation",library:"@react-native-community/geolocation"},{module:"RNFusedLocation",library:"react-native-geolocation-service"}],kr={PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3};function Dt(e,t){return{code:e,message:t,...kr}}function Un(){return Nt}function xr(e){let t=Un();if(!t)return null;let n=null;try{(globalThis.__turboModuleProxy!=null||typeof t.TurboModuleRegistry?.get=="function")&&(n=t.TurboModuleRegistry?.get?.(e))}catch{n=null}if(!n)try{n=t.NativeModules?.[e]}catch{n=null}return n&&typeof n=="object"?n:null}function Hn(e,t,n){let i={coords:{latitude:e.latitude,longitude:e.longitude,altitude:e.altitude,accuracy:e.accuracy,altitudeAccuracy:e.altitudeAccuracy,heading:e.heading??(t==="ios"?-1:0),speed:e.speed??(t==="ios"?-1:0)},timestamp:n};return t==="android"&&(i.mocked=false),i}var Cr=[];function Ir(e){let t=xr(e.module);if(!t||typeof t.getCurrentPosition!="function")return false;Cr.push(t);let n=Un(),i=n?.Platform?.OS??"ios",o=(h,p)=>n?.DeviceEventEmitter?.emit(h,p),r={options:null,native:false,on:false},a=()=>lt({library:e.library,id:"observer",kind:"position",options:r.options??{},deliver:h=>o("geolocationDidChange",Hn(h,i,Date.now())),fail:h=>o("geolocationError",Dt(2,h))});L(t,"getCurrentPosition",h=>(...p)=>{if(!P())return h(...p);let x=p[1],I=p[2];if(!be()){S("request",e.library,"getCurrentPosition \u2192 services off"),I?.(Dt(2,"No location provider available."));return}let{fix:A}=re();if(!A){S("request",e.library,"getCurrentPosition \u2192 no signal"),z(()=>I?.(Dt(3,"Unable to fetch location within 1.0s.")),1e3);return}S("request",e.library,`getCurrentPosition \u2192 ${A.latitude.toFixed(5)}, ${A.longitude.toFixed(5)}`),z(()=>x?.(Hn(A,i,Date.now())),0)});let c=L(t,"startObserving",h=>(...p)=>{if(r.options=p[0]&&typeof p[0]=="object"?p[0]:{},r.on=true,!P())return r.native=true,h(...p);r.native=false,a()}),d=L(t,"stopObserving",h=>(...p)=>{if(r.on=false,ae(e.library,"position","observer"),r.native)return r.native=false,h(...p)});return at({library:e.library,onActiveChange(h){r.on&&(h&&r.native?(r.native=false,d?.(),a()):!h&&!r.native&&(ae(e.library,"position","observer"),r.native=true,c?.(r.options??{})))}}),true}function Ar(){return wr.filter(Ir).map(e=>e.library)}function Tr(e){return null}function Sr(e){return null}var N="expo-location";function Lr(){return On?.OS??"ios"}function Vn(e){try{let n=globalThis.expo?.modules?.[e];if(n&&typeof n=="object")return n}catch{}let t=Tr(e);return t&&typeof t=="object"?t:null}function Bt(e,t,n){let i=t==="ios",o={coords:{latitude:e.latitude,longitude:e.longitude,altitude:e.altitude??(i?0:null),accuracy:e.accuracy,altitudeAccuracy:e.altitudeAccuracy??(i?-1:null),heading:e.heading??(i?-1:null),speed:e.speed??(i?-1:null)},timestamp:n};return t==="android"&&(o.mocked=false),o}function Pr(e,t,n){return n==="ios"?`Calling the '${e}' function has failed
2
2
  \u2192 Caused by: ${t}`:`Call to function 'ExpoLocation.${e}' has been rejected.
3
- \u2192 Caused by: ${t}`}var qn={denied:{ios:{code:"ERR_DENIED_FOREGROUND_LOCATION_PERMISSION",reason:"Location permission is required to do this operation"},android:{code:"ERR_LOCATION_UNAUTHORIZED",reason:"Not authorized to use location services"}},deniedBackground:{ios:{code:"ERR_DENIED_BACKGROUND_LOCATION_PERMISSION",reason:"Background location permission is required to do this operation"},android:{code:"ERR_LOCATION_BACKGROUND_UNAUTHORIZED",reason:"Not authorized to use background location services"}},services:{ios:{code:"ERR_LOCATION_SERVICES_DISABLED",reason:"Location services are disabled"},android:{code:"ERR_LOCATION_SETTINGS_UNSATISFIED",reason:"Location request failed due to unsatisfied device settings"}},unavailable:{ios:{code:"ERR_LOCATION_UNAVAILABLE",reason:"Cannot obtain current location"},android:{code:"ERR_CURRENT_LOCATION_IS_UNAVAILABLE",reason:"Current location is unavailable. Make sure that location services are enabled"}}};function ce(e,t,n){let i=n==="android"?qn[e].android:qn[e].ios;return Promise.reject(go(i.code,Pr(t,i.reason,n)))}var Gn=false;function $r(){let e=Vn("ExpoLocation");if(!e||typeof e.getCurrentPositionAsync!="function")return false;let t=e,n=Vn("ExpoTaskManager"),i=Lr(),o=new Map,r={},a=()=>Date.now(),c=u=>s=>t.emit?.("Expo.locationChanged",{watchId:u,location:Bt(s,i,a())}),d=u=>s=>{let f=s.heading??0;t.emit?.("Expo.headingChanged",{watchId:u,heading:{trueHeading:f,magHeading:f,accuracy:3}})},h=u=>s=>t.emit?.("Expo.locationError",{watchId:u,reason:s});async function p(){let u=t.getForegroundPermissionsAsync,s={granted:true,status:"granted",precision:"full",reported:false};if(typeof u!="function")return s;try{let f=await u.call(t),w=f?.ios?.accuracy==="reduced"||f?.android?.accuracy==="coarse"?"reduced":"full";Zi(w);let C=f?.granted===true,ie=C?"granted":f?.status==="undetermined"?"undetermined":"denied";return{granted:C,status:ie,precision:w,reported:true}}catch{return s}}async function x(){let u=t.getBackgroundPermissionsAsync;if(typeof u!="function")return null;try{return(await u.call(t))?.granted===true}catch{return null}}async function I(){let u=t.getBackgroundPermissionsAsync;if(typeof u!="function")return true;try{return(await u.call(t))?.granted===true}catch{return true}}function A(u,s){lt({library:N,id:u,kind:s.kind,options:s.options,deliver:s.kind==="position"?c(u):d(u),fail:h(u)})}r.getCurrentPositionAsync=L(t,"getCurrentPositionAsync",u=>async(...s)=>{if(!P())return u(...s);let f="getCurrentPositionAsync";if(!be())return S("request",N,"getCurrentPositionAsync \u2192 services off"),ce("services",f,i);if(!(await p()).granted)return S("request",N,"getCurrentPositionAsync \u2192 permission denied"),ce("denied",f,i);let{fix:w}=re();return w?(S("request",N,`getCurrentPositionAsync \u2192 ${w.latitude.toFixed(5)}, ${w.longitude.toFixed(5)}`),Bt(w,i,a())):(S("request",N,"getCurrentPositionAsync \u2192 no signal"),await new Promise(C=>z(()=>C(null),1e3)),ce("unavailable",f,i))}),r.getLastKnownPositionAsync=L(t,"getLastKnownPositionAsync",u=>async(...s)=>{if(!P())return u(...s);if(!(await p()).granted)return ce("denied","getLastKnownPositionAsync",i);let{fix:f}=re();return S("request",N,`getLastKnownPositionAsync \u2192 ${f?"simulated":"null"}`),f?Bt(f,i,a()):null}),r.watchPositionImplAsync=L(t,"watchPositionImplAsync",u=>async(...s)=>{let f=Number(s[0]),w=s[1]&&typeof s[1]=="object"?s[1]:{};if(!P()){let ie=await u(...s),ue={kind:"position",options:w,native:true};return o.set(f,ue),P()&&Ce(f,ue),ie}if(!(await p()).granted)return ce("denied","watchPositionImplAsync",i);if(!P())return o.set(f,{kind:"position",options:w,native:true}),u(...s);let C={kind:"position",options:w,native:false};o.set(f,C),A(f,C)}),r.watchDeviceHeading=L(t,"watchDeviceHeading",u=>async(...s)=>{let f=Number(s[0]);if(!P()){let C=await u(...s),ie={kind:"heading",options:{},native:true};return o.set(f,ie),P()&&Ce(f,ie),C}if(!(await p()).granted)return ce("denied","watchDeviceHeading",i);if(!P())return o.set(f,{kind:"heading",options:{},native:true}),u(...s);let w={kind:"heading",options:{},native:false};o.set(f,w),A(f,w)}),r.removeWatchAsync=L(t,"removeWatchAsync",u=>async(...s)=>{let f=Number(s[0]),w=o.get(f);if(o.delete(f),ae(N,"position",f),ae(N,"heading",f),!w||w.native)return u(...s)}),L(t,"hasServicesEnabledAsync",u=>async(...s)=>P()&&!be()?false:u(...s)),L(t,"getProviderStatusAsync",u=>async(...s)=>{let f=await u(...s);if(!P()||be())return f;let w={...f,locationServicesEnabled:false};for(let C of["gpsAvailable","networkAvailable","passiveAvailable"])C in w&&(w[C]=false);return w});let F=(u,s)=>L(t,s,f=>async(...w)=>{let C=String(w[0]),ie=w[1]&&typeof w[1]=="object"?w[1]:{},ue={name:C,kind:u,library:N,options:ie};if(!P()){let mt=await f(...w);return Tt(ue,false),P()&&b(true),mt}if(u==="locationUpdates"&&!be())return ce("services",s,i);if(!(await p()).granted)return ce("denied",s,i);if(u==="geofencing"&&!await I())return ce("deniedBackground",s,i);Tt(ue,true)});r.startLocationUpdatesAsync=F("locationUpdates","startLocationUpdatesAsync"),r.startGeofencingAsync=F("geofencing","startGeofencingAsync");let _=(u,s)=>L(t,s,f=>async(...w)=>{let C=Ee(String(w[0]));if(!(C&&C.kind===u&&(St(C.name),C.intercepted)))return f(...w)});r.stopLocationUpdatesAsync=_("locationUpdates","stopLocationUpdatesAsync"),r.stopGeofencingAsync=_("geofencing","stopGeofencingAsync");let ge=(u,s)=>L(t,s,f=>async(...w)=>{let C=Ee(String(w[0]));return C&&C.kind===u?true:f(...w)});ge("locationUpdates","hasStartedLocationUpdatesAsync"),ge("geofencing","hasStartedGeofencingAsync");let he=new Map,ht=0,Qe={geofencing:"geofencing",locationUpdates:"location"};n&&(L(n,"notifyTaskFinishedAsync",u=>async(...s)=>{let f=s[1]??{},w=f.eventId?he.get(f.eventId):void 0;if(w&&f.eventId){he.delete(f.eventId),w(f.result);return}return u(...s)}),L(n,"isTaskRegisteredAsync",u=>async(...s)=>Ee(String(s[0]))?.intercepted?true:u(...s)),L(n,"getTaskOptionsAsync",u=>async(...s)=>{let f=Ee(String(s[0]));return f?.intercepted?f.options:u(...s)}),L(n,"getRegisteredTasksAsync",u=>async(...s)=>{let f=await u(...s)??[],w=Lt().filter(C=>C.intercepted).map(C=>({taskName:C.name,taskType:Qe[C.kind],options:C.options}));return[...f,...w]}),L(n,"unregisterTaskAsync",u=>async(...s)=>{let f=Ee(String(s[0]));if(!(f&&(St(f.name),f.intercepted)))return u(...s)}),L(n,"unregisterAllTasksAsync",u=>async(...s)=>{for(let f of Lt())St(f.name);return u(...s)}));function Be(){if(!n)return null;if(n.__expo_module_name__&&typeof n.emit=="function")return(s,f)=>n.emit(s,f);let u=Dn;return u?(s,f)=>u.emit(s,f):null}async function me(u){for(let s=0;s<5e3&&Sr(u)===false;s+=100)await new Promise(f=>z(()=>f(null),100))}async function Xe(u,s){await me(u.name);let f=Be();if(!f)return Promise.reject(new Error("expo-task-manager is not installed"));let w=`buoy-location-${++ht}`,C=typeof n?.EVENT_NAME=="string"?n.EVENT_NAME:"TaskManager.executeTask";return new Promise((ie,ue)=>{he.set(w,ie),z(()=>{he.delete(w)&&ue(new Error("did not finish within 30 s"))},3e4);try{f(C,{data:s,error:null,executionInfo:{eventId:w,taskName:u.name,appState:"active"}})}catch(mt){he.delete(w),ue(mt)}})}function Ce(u,s){s.native&&(s.native=false,Promise.resolve(r.removeWatchAsync?.(u)).catch(()=>{}),A(u,s))}function b(u){for(let[s,f]of Array.from(o.entries()))if(u&&f.native)Ce(s,f);else if(!u&&!f.native){ae(N,f.kind,s);let w=f.kind==="position"?r.watchPositionImplAsync:r.watchDeviceHeading;f.native=true,Promise.resolve(f.kind==="position"?w?.(s,f.options):w?.(s)).catch(C=>{f.native=false,h(s)(String(C?.message??C))})}else u&&!f.native&&!ro(N,f.kind,s)&&A(s,f);for(let s of Lt()){if(s.library!==N)continue;let f=s.kind==="geofencing";if(u&&!s.intercepted){let w=f?r.stopGeofencingAsync:r.stopLocationUpdatesAsync;Promise.resolve(w?.(s.name)).catch(()=>{}),xn(s.name,true)}else if(!u&&s.intercepted){let w=f?r.startGeofencingAsync:r.startLocationUpdatesAsync;xn(s.name,false),Promise.resolve(w?.(s.name,s.options)).catch(C=>{S("error",N,`Could not restart ${s.name} natively: ${String(C?.message??C)}`)})}}}return at({library:N,fireTask:Xe,onActiveChange:b,readPermission:async()=>{let u=await p();if(!u.reported)return null;let s=u.status==="granted"?await x():false;return{status:u.status,background:s,precision:u.precision}}}),Gn||(Gn=true,n&&typeof n.getRegisteredTasksAsync=="function"&&Promise.resolve(n.getRegisteredTasksAsync.call(n)).then(u=>{for(let s of u??[]){if(!s?.taskName||Ee(s.taskName))continue;let f=s.taskType==="geofencing"?"geofencing":s.taskType==="location"?"locationUpdates":null;f&&(Tt({name:s.taskName,kind:f,library:N,options:s.options??{}},false),P()&&b(true))}}).catch(()=>{})),true}import{callCapacitorAsApp as Mr,callCapacitorNative as Kn,callCapacitorNativeCallback as Er,capacitorPlatform as Rr,hasCapacitorPlugin as Nr,installCapacitorBridge as Or,interceptCapacitor as jt,makeCapacitorCallbackId as Dr}from"@buoy-gg/license/web";var ve="@capacitor/geolocation",pe="Geolocation";function Jn(e,t){return{timestamp:t,coords:{latitude:e.latitude,longitude:e.longitude,accuracy:e.accuracy,altitude:e.altitude,altitudeAccuracy:e.altitudeAccuracy,speed:e.speed,heading:e.heading}}}function Ft(e){return new Error(e)}function Br(e){if(!e||typeof e!="object")return null;let t=e.location,n=e.coarseLocation??t;return{status:t==="granted"||n==="granted"?"granted":t==="denied"&&(n==="denied"||n===void 0)?"denied":"undetermined",background:null,precision:t!=="granted"&&n==="granted"?"reduced":"full"}}function Yn(e,t){return(n,i)=>{e.gen===t&&e.nativeId!==null&&e.callback(n,i)}}var qe=new Map,Qn=false;function Xn(e){lt({library:ve,id:e.id,kind:"position",options:e.options,deliver:t=>e.callback(Jn(t,Date.now())),fail:t=>e.callback(null,Ft(t))})}function jr(e){let t=++e.gen;e.nativeId=Er(pe,"watchPosition",e.options,Yn(e,t))}function Fr(e){if(e.gen++,e.nativeId===null)return;let t=e.nativeId;e.nativeId=null,Kn(pe,"clearWatch",{id:t}).catch(()=>{})}function _r(){return Qn?true:!Rr()||!Nr(pe)||!Or()?false:(Qn=true,jt({plugin:pe,methods:["getCurrentPosition"],promise:(e,t)=>{if(!P())return t();if(!be())return S("request",ve,"getCurrentPosition \u2192 services off"),Promise.reject(Ft("Location services are not enabled"));let{fix:n}=re();return n?(S("request",ve,`getCurrentPosition \u2192 ${n.latitude.toFixed(5)}, ${n.longitude.toFixed(5)}`),Jn(n,Date.now())):(S("request",ve,"getCurrentPosition \u2192 no signal"),new Promise((i,o)=>z(()=>o(Ft("Timeout")),1e3)))}}),jt({plugin:pe,methods:["watchPosition"],callback:(e,t,n)=>{if(!P()){let o={id:"",options:e.options,callback:t,nativeId:null,gen:1},r=n(Yn(o,1));return r===null?null:(o.id=r,o.nativeId=r,qe.set(r,o),r)}let i={id:Dr(),options:e.options,callback:t,nativeId:null,gen:1};return qe.set(i.id,i),Xn(i),i.id}}),jt({plugin:pe,methods:["clearWatch"],promise:(e,t)=>{let n=String(e.options.id??""),i=qe.get(n);if(!i)return t();if(qe.delete(n),i.gen++,ae(ve,"position",n),i.nativeId===null)return;let o=i.nativeId;return i.nativeId=null,o===n?t():Kn(pe,"clearWatch",{id:o})}}),at({library:ve,onActiveChange(e){for(let t of qe.values())e&&t.nativeId!==null?(Fr(t),Xn(t)):!e&&t.nativeId===null&&(ae(ve,"position",t.id),jr(t))},async readPermission(){try{return Br(await Mr(pe,"checkPermissions"))}catch{return null}}}),true)}var we="navigator.geolocation",zr={PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3};function _t(e,t){return{code:e,message:t,...zr}}function Zn(e,t){let n={latitude:e.latitude,longitude:e.longitude,altitude:e.altitude,accuracy:e.accuracy,altitudeAccuracy:e.altitudeAccuracy,heading:e.heading,speed:e.speed};return{coords:{...n,toJSON:()=>n},timestamp:t,toJSON:()=>({coords:n,timestamp:t})}}function ei(e,t){let n=()=>e.gen===t&&e.nativeId!==null;return[(...i)=>n()?e.success(...i):void 0,(...i)=>n()?e.error?.(...i):void 0]}var Ge=new Map,Wr=1e6,ti=false;function Ur(){if(ti)return true;let e=globalThis.navigator?.geolocation;if(!e||typeof e.getCurrentPosition!="function")return false;ti=true;let t=null,n=null,i=o=>lt({library:we,id:o.id,kind:"position",options:o.options,deliver:r=>o.success(Zn(r,Date.now())),fail:r=>o.error?.(_t(2,r))});return L(e,"getCurrentPosition",o=>(...r)=>{if(!P())return o(...r);let a=r[0],c=r[1];if(!be()){S("request",we,"getCurrentPosition \u2192 services off"),z(()=>c?.(_t(2,"Location services are disabled")),0);return}let{fix:d}=re();if(!d){S("request",we,"getCurrentPosition \u2192 no signal"),z(()=>c?.(_t(3,"Timeout expired")),1e3);return}S("request",we,`getCurrentPosition \u2192 ${d.latitude.toFixed(5)}, ${d.longitude.toFixed(5)}`),z(()=>a?.(Zn(d,Date.now())),0)}),t=L(e,"watchPosition",o=>(...r)=>{let a=r[0],c=r[1],d=r[2]&&typeof r[2]=="object"?r[2]:{};if(!P()){let p={id:0,success:a,error:c,options:d,nativeId:null,gen:1},[x,I]=ei(p,1),A=o(x,I,r[2]);return p.id=A,p.nativeId=A,Ge.set(A,p),A}let h={id:Wr++,success:a,error:c,options:d,nativeId:null,gen:1};return Ge.set(h.id,h),i(h),h.id}),n=L(e,"clearWatch",o=>(...r)=>{let a=r[0],c=Ge.get(a);if(!c)return o(...r);if(Ge.delete(a),c.gen++,ae(we,"position",a),c.nativeId!==null)return o(c.nativeId)}),at({library:we,onActiveChange(o){for(let r of Ge.values())if(o&&r.nativeId!==null)r.gen++,n?.(r.nativeId),r.nativeId=null,i(r);else if(!o&&r.nativeId===null){ae(we,"position",r.id);let a=++r.gen,[c,d]=ei(r,a);r.nativeId=t?.(c,d,r.options)??null}}}),true}var ke=null;function zt(){return ke||(ke=[],$r()&&ke.push("expo-location"),ke.push(...Ar()),_r()&&ke.push("@capacitor/geolocation"),Ur()&&ke.push("navigator.geolocation"),ke)}import{useSyncExternalStore as Hr}from"react";import{FloatingTool as Vr,LocationToolIcon as ni,Pause as qr,Play as Gr,RefreshCw as Kr,X as Jr,dismissFloatingTool as Yr,getFloatingTools as Qr,night as fe,openFloatingTool as Xr}from"@buoy-gg/shared-ui/web";var Zr=new Set(["US","GB","LR","MM"]),ii=null;function ea(){try{let e=Intl.DateTimeFormat().resolvedOptions().locale,t=/[-_]([A-Z]{2})\b/.exec(e);return t?t[1]:null}catch{return null}}var Wt=null;function Ne(){return ii!==null?ii:(Wt===null&&(Wt=Zr.has(ea()??"")),Wt)}var oi=3.28084,ri=1609.344;function K(e){if(!Number.isFinite(e))return"\u2013";let t=Math.abs(e);if(Ne()){let n=t/ri;return n<.1?`${Math.round(t*oi/10)*10} ft`:`${ai(n)} mi`}return t<1e3?`${Math.round(t)} m`:`${ai(t/1e3)} km`}function ai(e){let t=Math.round(e*10)/10;return t<10?t.toFixed(1):Math.round(e).toLocaleString("en-US")}function li(e){return Number.isFinite(e)?e>=1e3?`\xB1${K(e)}`:Ne()?`\xB1${Math.round(e*oi)} ft`:`\xB1${Math.round(e)} m`:"\u2013"}function Ut(e){if(e==null||e<0)return"\u2013";let t=Ne()?e*3600/ri:e*3.6,n=Ne()?"mph":"km/h";return`${t<10?t.toFixed(1):Math.round(t)} ${n}`}function ta(e){if(!Number.isFinite(e)||e<0)return"\u2013";let t=Math.round(e/6e4);if(t<1)return`${Math.max(1,Math.round(e/1e3))} sec`;if(t<60)return`${t} min`;let n=Math.floor(t/60),i=t%60;return i?`${n} hr ${i} min`:`${n} hr`}function na(e,t){let n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"now";if(n<60)return`${n}s ago`;try{return new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}catch{let i=new Date(e);return`${i.getHours()}:${String(i.getMinutes()).padStart(2,"0")}`}}function si(e){return e.override.services?e.override.signal?e.override.mode==="real"?"Real Location":e.override.mode==="route"?e.override.route?.name??"Route":e.override.place.label||"Dropped Pin":"No GPS Signal":"Location Services Off"}function ia(e){return!e.override.services||!e.override.signal?"broken":e.override.mode==="real"?"real":"simulated"}function oa(e){if(!e.override.services)return"The app is told location services are off";if(!e.override.signal)return"Updates stop and location requests fail";if(e.override.mode==="real")return"The app gets the device's location";let t=[];if(e.override.mode==="route"&&e.progress){let i=e.progress;i.finished?t.push("Arrived"):e.override.playing||t.push("Paused"),e.current.reason==="gap"&&t.push("no signal here"),i.finished||(t.push(`${K(i.along)} of ${K(i.length)}`),i.etaMs!=null?t.push(`${ta(i.etaMs)} left`):e.override.route?.loop&&t.push("on repeat"))}else t.push("Pinned");let n=e.current.fix;return n&&e.override.mode==="fixed"&&t.push(li(n.accuracy)),e.current.precision==="reduced"&&t.push("approximate"),t.join(" \xB7 ")}function ra(e){return e.status==="denied"?"Not Allowed":e.status==="undetermined"?"Not Asked Yet":`${e.background?"Always":"While Using"} \xB7 ${e.precision==="reduced"?"Approximate":"Precise"}`}function aa(e){if(!e.override.services)return"The app is told location is off";if(!e.override.signal)return"Updates stop, requests fail";if(e.override.mode==="route"&&e.progress){if(e.progress.finished)return"Arrived";let n=`${K(e.progress.along)} of ${K(e.progress.length)}`;return e.override.playing?n:`Paused \xB7 ${n}`}let t=e.current.fix;return t?`Pinned \xB7 ${Fe(t,3)}`:"Pinned"}import{jsx as H,jsxs as ci}from"react/jsx-runtime";var ut="location-chip",la={id:ut,render:e=>H(fi,{...e})},sa=()=>Qr().some(e=>e.id===ut),ui=false,Ht=false,di=null;function pi(e){Ht!==e&&(Ht=e,di?.())}function ca(){if(ui)return;ui=true;let e=false,t=()=>{let n=E().active&&uo().showChip&&!Ht;n&&!e?Xr(la):!n&&sa()&&Yr(ut),e=n};di=t,Ue(t),t()}function fi({id:e,revealToken:t}){let n=Hr(Ue,E,E),i=si(n),o=n.override.mode==="route"&&n.progress,r=n.override.playing,a=!!o&&o.finished;return H(Vr,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:`Move or hide the location chip. ${i}`,handleAdornment:H(ni,{size:12}),children:ci(v,{style:xe.row,children:[H(ni,{size:18}),ci(v,{style:xe.text,children:[H(T,{style:xe.title,numberOfLines:1,testID:"location-chip-title",children:i}),H(T,{style:xe.detail,numberOfLines:1,testID:"location-chip-detail",children:aa(n)})]}),o?H(se,{testID:"location-chip-playpause",accessibilityRole:"button",accessibilityLabel:r?"Pause the route":a?"Play the route again":"Resume the route",onPress:()=>r?Pt():$t(),style:xe.pill,hitSlop:{top:8,bottom:8,left:4,right:4},children:r?H(qr,{size:14,color:fe.color.accent}):a?H(Kr,{size:14,color:fe.color.accent}):H(Gr,{size:14,color:fe.color.accent})}):null,H(v,{style:xe.separator}),H(se,{testID:"location-chip-reset",accessibilityRole:"button",accessibilityLabel:"Back to the real location",onPress:()=>Et(),style:xe.button,hitSlop:{top:8,bottom:8,left:4,right:8},children:H(Jr,{size:16,color:fe.color.textSecondary})})]})})}var xe=le.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingLeft:10,paddingRight:4,paddingVertical:6,minWidth:230,maxWidth:340},text:{flexShrink:1,minWidth:120},title:{color:fe.color.text,fontSize:14,fontWeight:"600"},detail:{color:fe.color.textSecondary,fontSize:11,fontVariant:["tabular-nums"]},pill:{width:30,height:30,borderRadius:15,alignItems:"center",justifyContent:"center",backgroundColor:fe.color.accentFill},button:{width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:16},separator:{width:le.hairlineWidth,height:20,backgroundColor:fe.color.separator}});import{LocationToolIcon as ua,LOCATION_TOOL_ICON_COLOR as da,createToolFactory as pa,defineToolPreset as fa}from"@buoy-gg/shared-ui/web";import{useEffect as ga,useState as ha}from"react";import{FeatureGate as ma}from"@buoy-gg/shared-ui/web";import{createSyncAdapter as ya}from"@buoy-gg/shared-ui/web";var dt=[{latitude:37.3349,longitude:-122.009,label:"Apple Park"},{latitude:37.422,longitude:-122.0841,label:"Googleplex"},{latitude:40.758,longitude:-73.9855,label:"Times Square"},{latitude:51.508,longitude:-.1281,label:"Trafalgar Square"},{latitude:48.8584,longitude:2.2945,label:"Eiffel Tower"},{latitude:35.6595,longitude:139.7005,label:"Shibuya Crossing"},{latitude:-33.8568,longitude:151.2153,label:"Sydney Opera House"},{latitude:-23.5614,longitude:-46.6559,label:"S\xE3o Paulo"},{latitude:0,longitude:0,label:"Null Island"}],Oe=[{id:"walk",name:"Walk",description:"1 km north from here at walking pace",speed:1.4},{id:"run",name:"Run",description:"3 km north, then east, at running pace",speed:3.3},{id:"drive",name:"City Drive",description:"4 km of city streets with turns",speed:13.4},{id:"highway",name:"Highway",description:"30 km north at highway speed",speed:30},{id:"tunnel",name:"Tunnel",description:"3 km drive with no signal for 600 m in the middle",speed:13.4},{id:"loop",name:"Block Loop",description:"A 400 m block, walked on repeat",speed:1.4}];function gi(e,t,n=0){let i=Oe.find(h=>h.id===e);if(!i)throw new Error(`Unknown route preset "${e}". Use one of: ${Oe.map(h=>h.id).join(", ")}.`);let o={latitude:t.latitude,longitude:t.longitude},r=(h,p,x)=>je(h,n+p,x),a,c,d=false;switch(e){case"walk":a=[o,r(o,0,1e3)];break;case"run":a=[o,r(o,0,1500),r(r(o,0,1500),90,1500)];break;case"drive":{let h=r(o,0,1200),p=r(h,90,800),x=r(p,0,1e3),I=r(x,-90,1e3);a=[o,h,p,x,I];break}case"highway":a=[o,r(o,0,3e4)];break;case"tunnel":a=[o,r(o,0,3e3)],c=[[1200,1800]];break;case"loop":{let h=r(o,0,100),p=r(h,90,100),x=r(p,180,100);a=[o,h,p,x,o],d=true;break}}return{id:`preset:${e}`,name:i.name,points:a,speed:i.speed,loop:d,gaps:c}}function ba(e,t,n){return{id:"line",name:t.label?`To ${t.label}`:"Straight line",points:[{latitude:e.latitude,longitude:e.longitude},{latitude:t.latitude,longitude:t.longitude}],speed:n}}function Z(e){return e&&typeof e=="object"?e:{}}function Ke(e,...t){for(let n of t){let i=e[n];if(typeof i=="boolean")return i;if(i==="true"||i==="on")return true;if(i==="false"||i==="off")return false}}function J(e,...t){for(let n of t){let i=e[n];if(i==null||i==="")continue;let o=Number(i);if(Number.isFinite(o))return o}}function $(){return{...E(),builtInPlaces:dt,presets:Oe}}function va(e){let t=e.trim().toLowerCase(),n=[...E().places,...dt];return n.find(i=>i.label?.toLowerCase()===t)??n.find(i=>i.label?.toLowerCase().includes(t))??null}function hi(e){let t=typeof e.label=="string"?e.label:void 0,n=J(e,"latitude","lat"),i=J(e,"longitude","lon","lng");if(n!==void 0&&i!==void 0){let o={latitude:n,longitude:i};if(!Ie(o))throw new Error("latitude must be within \xB190 and longitude within \xB1180.");return{...o,label:t}}for(let o of["place","to","query","coordinate","at"]){let r=e[o];if(Ie(r))return{...r,label:r.label??t};if(typeof r=="string"&&r.trim()){let a=vt(r);if(a)return{...a,label:t};let c=va(r);if(c)return c;throw new Error(`No place called "${r}". Give latitude and longitude, or one of: ${wa()}.`)}}return null}function wa(){return[...E().places,...dt].map(e=>e.label).filter(Boolean).join(", ")}function ka(e){let t=J(e,"speed","metersPerSecond"),n=J(e,"heading","bearing")??0;if(Array.isArray(e.points))return{points:e.points,speed:t??1.4,loop:Ke(e,"loop")??false,name:typeof e.name=="string"?e.name:"Custom route",gaps:Array.isArray(e.gaps)?e.gaps:void 0};let i=typeof e.route=="string"?e.route:typeof e.routeId=="string"?e.routeId:typeof e.preset=="string"?e.preset:void 0;if(i){let r=E().routes.find(d=>d.id===i||d.name?.toLowerCase()===i.toLowerCase());if(r)return t?{...r,speed:t}:r;let a=Oe.find(d=>d.id===i||d.name.toLowerCase()===i.toLowerCase());if(a){let d=gi(a.id,He(),n);return t?{...d,speed:t}:d}let c=[...E().routes.map(d=>d.id??d.name),...Oe.map(d=>d.id)];throw new Error(`No route "${i}". Use one of: ${c.join(", ")}; or pass points.`)}let o=hi(e);if(o)return ba(He(),o,t??1.4);throw new Error("startRoute needs `points` (two or more {latitude, longitude}), `route` (a preset or app route id), or `to` (a place).")}var Vt=ya({version:1,getSnapshot(){return $()},subscribe(e){return Ue(e)},actions:{getState(){return $()},setLocation(e){let t=hi(Z(e));if(!t)throw new Error('setLocation needs `latitude` and `longitude`, `query` ("lat, lon" or a map link), or `place` (a place name).');return ct(t),$()},startRoute(e){return Cn(ka(Z(e))),$()},stopRoute(){return $n(),$()},setConditions(e){let t=Z(e),n=(typeof t.conditions=="string"?t.conditions:typeof t.preset=="string"?t.preset:"").trim().toLowerCase().replace(/[\s_]+/g,"-"),i={good:"good",weak:"weak","no-signal":"no-signal",nosignal:"no-signal",off:"off","services-off":"off","location-off":"off"}[n];if(!i)throw new Error("setConditions needs `conditions`: good, weak, no-signal or off.");return Pn(i),$()},pauseRoute(){return Pt(),$()},resumeRoute(){return $t(),$()},seekRoute(e){let t=Z(e),n=J(t,"meters","along"),i=J(t,"fraction","progress"),o=E().progress?.length??0;if(n===void 0&&i===void 0)throw new Error("seekRoute needs `meters` or `fraction` (0 to 1).");return In(n??(i??0)*o),$()},setSpeed(e){let t=J(Z(e),"speed","metersPerSecond");if(t===void 0)throw new Error("setSpeed needs `speed` in meters per second.");return An(t),$()},tune(e){let t=Z(e);return Tn({accuracy:J(t,"accuracy"),jitter:J(t,"jitter","drift"),altitude:t.altitude===null?null:J(t,"altitude"),heading:t.heading===null?null:J(t,"heading"),interval:J(t,"interval","intervalMs")}),$()},setSignal(e){let t=Ke(Z(e),"on","signal","enabled");if(t===void 0)throw new Error("setSignal needs `on`: true or false.");return Sn(t),$()},setServices(e){let t=Ke(Z(e),"on","services","enabled");if(t===void 0)throw new Error("setServices needs `on`: true or false.");return Ln(t),$()},enterRegion(e){let t=Z(e),n=typeof t.identifier=="string"?t.identifier:typeof t.region=="string"?t.region:void 0;if(!n)throw new Error("enterRegion needs `identifier` (a monitored geofence region).");return Mt(n,"inside",typeof t.task=="string"?t.task:void 0),$()},exitRegion(e){let t=Z(e),n=typeof t.identifier=="string"?t.identifier:typeof t.region=="string"?t.region:void 0;if(!n)throw new Error("exitRegion needs `identifier` (a monitored geofence region).");return Mt(n,"outside",typeof t.task=="string"?t.task:void 0),$()},useRealLocation(){return Mn(),$()},reset(){return Et(),$()},updateSettings(e){let t=Z(e);return co({persist:Ke(t,"persist"),showChip:Ke(t,"showChip")}),$()},clearLog(){return po(),$()}}});import{useEffect as xa,useState as De}from"react";import{Check as Ca,ChevronLeft as Ia,ChevronRight as Aa,NightButton as mi,NightCard as R,NightFootnote as ee,NightRows as te,NightSectionLabel as Y,NightSegmented as qt,NightSwitch as Ta,Pause as Sa,Play as La,RefreshCw as Pa,copyToClipboard as $a,monoFont as Ma,night as m,realNow as Gt,useSafeAreaInsets as Ea,useToolScreenHeader as Ra}from"@buoy-gg/shared-ui/web";import{night as ne}from"@buoy-gg/shared-ui/web";import{jsx as Q,jsxs as pt}from"react/jsx-runtime";var yi="#F87171",Je=1.8,Na=6e4,Oa=400;function Da({snapshot:e,onPinPlace:t,onCrossRegion:n}){let i=e.position,o=e.override.mode==="route"?e.override.route:null,r=i??e.places[0]??Ba(e.tasks)??null;if(!r)return null;let a=b=>!i||V(i,b)<=Na,c=e.places.filter(a),d=e.tasks.filter(b=>b.kind==="geofencing").flatMap(b=>b.regions.filter(a).map(u=>({task:b,region:u}))),h=e.places.length-c.length,p=Math.cos(r.latitude*Math.PI/180),x=b=>({x:(b.longitude-r.longitude)*111320*p,y:(b.latitude-r.latitude)*110540}),I=[];i&&I.push({...x(i),r:60});for(let b of o?.points??[])I.push({...x(b),r:0});for(let b of c)I.push({...x(b),r:60});for(let b of d)I.push({...x(b.region),r:b.region.radius});let A=1/0,F=-1/0,_=1/0,ge=-1/0;for(let b of I)A=Math.min(A,b.x-b.r),F=Math.max(F,b.x+b.r),_=Math.min(_,b.y-b.r),ge=Math.max(ge,b.y+b.r);let he=(A+F)/2,ht=(_+ge)/2,Qe=Math.max(Oa,(ge-_)*1.35,(F-A)*1.2/Je),Be=Qe*Je,me=b=>{let u=x(b);return{x:.5+(u.x-he)/Be,y:.5-(u.y-ht)/Qe}},Xe=Fa(Be),Ce=e.override.mode==="fixed"?e.override.place.label:void 0;return Q(v,{children:pt(v,{style:M.map,testID:"location-map",accessibilityLabel:"Map of places, geofences and the simulated position",children:[bi.map(b=>Q(v,{style:[M.gridV,{left:B(b)}]},`v${b}`)),bi.map(b=>Q(v,{style:[M.gridH,{top:B(b)}]},`h${b}`)),d.map(({task:b,region:u})=>{let s=me(u),f=2*u.radius/Be,w=f*Je,C=u.state==="inside";return Q(se,{testID:`location-map-region-${vi(u.identifier)}`,accessibilityRole:"button",accessibilityLabel:`${C?"Leave":"Enter"} ${u.label??u.identifier}`,activeOpacity:.6,onPress:()=>n(b,u),style:[M.fence,C?M.fenceInside:null,{left:B(s.x-f/2),top:B(s.y-w/2),width:B(f),height:B(w)}]},`${b.name}:${u.identifier}`)}),o?ja(o.points.map(me)).map((b,u)=>Q(v,{pointerEvents:"none",style:[M.segment,{left:B(b.midX-b.length/2),top:B(b.midY),width:B(b.length),transform:[{rotate:`${b.angle}rad`}]}]},`seg${u}`)):null,c.map((b,u)=>{let s=me(b),f=!!Ce&&Ce===b.label;return pt(se,{testID:`location-map-place-${vi(b.label??String(u))}`,accessibilityRole:"button",accessibilityLabel:`Pin ${b.label??"this place"}`,activeOpacity:.6,onPress:()=>t(b),style:[M.placeHit,{left:B(s.x),top:B(s.y)}],children:[Q(v,{style:[M.placeDot,f?M.placeDotSelected:null]}),b.label?Q(T,{style:M.placeLabel,numberOfLines:1,children:b.label}):null]},`${b.label??u}`)}),i?pt(v,{pointerEvents:"none",style:[M.pinWrap,{left:B(me(i).x),top:B(me(i).y)}],children:[Q(v,{style:M.pinHalo}),Q(v,{style:[M.pin,e.current.reason==="gap"?M.pinHollow:null]})]}):null,pt(v,{style:M.scale,pointerEvents:"none",children:[Q(v,{style:[M.scaleBar,{width:B(Xe.fraction)}]}),Q(T,{style:M.scaleLabel,children:Xe.label})]}),h>0?Q(T,{style:M.offMap,pointerEvents:"none",children:`${h} more ${h===1?"place":"places"} off the map`}):null]})})}var bi=[.2,.4,.6,.8];function B(e){return`${e*100}%`}function Ba(e){for(let t of e)if(t.regions[0])return t.regions[0];return null}function ja(e){let t=[];for(let n=1;n<e.length;n++){let i=e[n-1],o=e[n],r=o.x-i.x,a=(o.y-i.y)/Je;t.push({midX:(i.x+o.x)/2,midY:(i.y+o.y)/2,length:Math.sqrt(r*r+a*a),angle:Math.atan2(a,r)})}return t}function Fa(e){let t=e/4,n=Ne()?1609.344:1e3,i=Ne()?[.01,.02,.05,.1,.2,.5,1,2,5,10,20,50,100].map(r=>r*n):[10,20,50,100,200,500,1e3,2e3,5e3,1e4,2e4,5e4,1e5],o=i[0];for(let r of i)r<=t&&(o=r);return{fraction:o/e,label:K(o)}}function vi(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}var M=le.create({map:{width:"100%",aspectRatio:Je,borderRadius:ne.radius.card,borderWidth:1,borderColor:ne.color.border,backgroundColor:ne.color.surface,overflow:"hidden"},gridV:{position:"absolute",top:0,bottom:0,width:le.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},gridH:{position:"absolute",left:0,right:0,height:le.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},fence:{position:"absolute",borderRadius:9999,borderWidth:1,borderColor:"rgba(255, 255, 255, 0.22)",backgroundColor:"rgba(255, 255, 255, 0.04)",minWidth:10,minHeight:10},fenceInside:{borderColor:ne.color.accentBorderStrong,backgroundColor:ne.color.accentSoft},segment:{position:"absolute",height:3,marginTop:-1.5,borderRadius:1.5,backgroundColor:"rgba(248, 113, 113, 0.45)"},placeHit:{position:"absolute",flexDirection:"row",alignItems:"center",gap:4,height:24,marginTop:-12,marginLeft:-12,paddingLeft:8,paddingRight:4},placeDot:{width:8,height:8,borderRadius:4,backgroundColor:ne.color.textSecondary},placeDotSelected:{backgroundColor:ne.color.text},placeLabel:{color:ne.color.textSecondary,fontSize:10,fontWeight:"500",maxWidth:110},pinWrap:{position:"absolute",width:28,height:28,marginLeft:-14,marginTop:-14,alignItems:"center",justifyContent:"center"},pinHalo:{position:"absolute",width:28,height:28,borderRadius:14,backgroundColor:"rgba(248, 113, 113, 0.22)"},pin:{width:14,height:14,borderRadius:7,backgroundColor:yi,borderWidth:2,borderColor:"#FFFFFF"},pinHollow:{backgroundColor:"transparent",borderColor:yi},scale:{position:"absolute",left:10,right:10,bottom:8,gap:3},scaleBar:{height:2,borderRadius:1,backgroundColor:ne.color.textTertiary},scaleLabel:{color:ne.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},offMap:{position:"absolute",right:10,bottom:8,color:ne.color.textTertiary,fontSize:10}});import{Fragment as Ye,jsx as l,jsxs as k}from"react/jsx-runtime";var wi={places:"Other Location",routes:"Route",speed:"Speed",accuracy:"Accuracy & Drift",activity:"Activity",options:"Options"},_a="#F87171",ki=[{key:"1.4",label:"Walking"},{key:"3.3",label:"Running"},{key:"5.5",label:"Cycling"},{key:"13.4",label:"City Traffic"},{key:"30",label:"Highway"},{key:"250",label:"Airplane"}],xi=[{key:"good",label:"Good"},{key:"weak",label:"Weak"},{key:"no-signal",label:"No Signal"},{key:"off",label:"Off"}],za={good:"Precise fixes, like outdoors with a clear sky.",weak:"Fixes are \xB165 m and wander by up to 50 m, like indoors or between tall buildings.","no-signal":"Watches get no updates and location requests fail.",off:"The app is told location services are turned off.",custom:"Custom accuracy and drift."},Ci=[{key:"5",label:"5 m"},{key:"20",label:"20 m"},{key:"65",label:"65 m"},{key:"1000",label:"1 km"}],Ii=[{key:"0",label:"Off"},{key:"10",label:"10 m"},{key:"50",label:"50 m"},{key:"200",label:"200 m"}],Wa=4;function Kt(e){let[t,n]=De(()=>Gt());return xa(()=>{if(!e)return;let i=setInterval(()=>n(Gt()),1e3);return()=>clearInterval(i)},[e]),t}function Ai({snapshot:e,onAction:t}){let n=Ea({minBottom:16}),[i,o]=De(null),[r,a]=De("main"),c=()=>a("main"),d=Ra(r==="main"?null:{title:wi[r],subtitle:"",onBack:c,searchable:false},[r]),h=(A,F)=>{o(null),t(A,F).catch(_=>{o(_ instanceof Error?_.message:String(_))})};if(!e)return l(v,{style:y.waiting,testID:"location-waiting",children:l(ee,{centered:true,children:"Waiting for the app\u2026"})});let p=i?l(ee,{tone:"danger",centered:true,children:l(T,{testID:"location-error",children:i})}):null,x=(A,F)=>{h(A,F),c()},I;switch(r){case"places":I=l(Ka,{snapshot:e,pick:x});break;case"routes":I=l(Xa,{snapshot:e,pick:x});break;case"speed":I=l(el,{snapshot:e,pick:x});break;case"accuracy":I=l(al,{snapshot:e,run:h});break;case"activity":I=l(sl,{snapshot:e,run:h});break;case"options":I=l(ul,{snapshot:e,run:h});break;default:I=k(Ye,{children:[l(Ua,{snapshot:e,run:h}),p,l(Va,{snapshot:e,run:h}),l(qa,{snapshot:e,run:h,open:a}),l(Ya,{snapshot:e,open:a}),l(nl,{snapshot:e,run:h}),l(rl,{snapshot:e,run:h,open:a}),l(ll,{snapshot:e,open:a})]})}return k(zn,{style:y.fill,contentContainerStyle:[y.content,{paddingBottom:n.bottom}],testID:"location-scroll",keyboardShouldPersistTaps:"handled",children:[r!=="main"&&!d?l(dl,{title:wi[r],onBack:c}):null,r!=="main"?p:null,I]},r)}function Ua({snapshot:e,run:t}){let n=e.override,i=n.mode==="route"?n.route:null,o=e.progress;Kt(!!i&&n.playing);let r=ia(e),a=e.current.fix,c=o&&o.length>0?Math.min(1,o.along/o.length):0,[d,h]=De(false);return k(R,{children:[k(v,{style:y.status,children:[l(T,{style:[y.statusTitle,r==="simulated"?y.titleSimulated:r==="broken"?y.titleBroken:null],testID:"location-hero-title",numberOfLines:1,adjustsFontSizeToFit:true,children:si(e)}),l(T,{style:y.statusLine,testID:"location-hero-status",children:oa(e)}),a&&e.simulating?l(se,{testID:"location-copy-coordinates",accessibilityRole:"button",accessibilityLabel:"Copy coordinates",activeOpacity:.6,onPress:()=>{$a(`${a.latitude}, ${a.longitude}`).then(p=>{p&&(h(true),setTimeout(()=>h(false),1500))})},children:l(T,{style:y.coordinates,children:d?"Copied":Fe(a,5)})}):null,i&&o?k(v,{style:y.progressTrack,testID:"location-route-progress",children:[l(v,{style:[y.progressFill,{width:`${c*100}%`}]}),(i.gaps??[]).map(([p,x],I)=>l(v,{style:[y.progressGap,{left:`${p/o.length*100}%`,width:`${(x-p)/o.length*100}%`}]},I))]}):null,e.active?k(v,{style:y.statusButtons,children:[i&&o?l(Ha,{testID:n.playing?"location-route-pause":"location-route-resume",label:n.playing?"Pause":o.finished?"Play again":"Resume",onPress:()=>t(n.playing?"pauseRoute":"resumeRoute"),children:n.playing?l(Sa,{size:18,color:m.color.onAccent}):o.finished?l(Pa,{size:18,color:m.color.onAccent}):l(La,{size:18,color:m.color.onAccent})}):null,l(v,{style:y.flex,children:l(mi,{label:"Use Real Location",size:"md",testID:"location-reset",onPress:()=>t("reset")})})]}):null]}),e.permission?k(v,{style:y.permission,testID:"location-permission",children:[k(v,{style:y.rowBetween,children:[l(T,{style:y.rowTitle,children:"Permission"}),l(T,{style:[y.rowValue,e.permission.status!=="granted"?y.valueWarning:null],testID:"location-permission-value",children:ra(e.permission)})]}),e.permission.status!=="granted"?l(T,{style:y.detail,children:"The app's location requests fail until it's allowed. Change it in Settings or the Permissions tool."}):null]}):null]})}function Ha({children:e,label:t,onPress:n,testID:i}){return l(se,{testID:i,accessibilityRole:"button",accessibilityLabel:t,activeOpacity:.7,onPress:n,style:y.round,children:e})}function Va({snapshot:e,run:t}){return!!e.position||e.places.length>0||e.tasks.some(n=>n.regions.length>0)?k(v,{children:[l(Da,{snapshot:e,onPinPlace:n=>t("setLocation",{latitude:n.latitude,longitude:n.longitude,label:n.label}),onCrossRegion:(n,i)=>t(i.state==="inside"?"exitRegion":"enterRegion",{identifier:i.identifier,task:n.name})}),l(ee,{children:"Map views in the app still show the device's own blue dot. Move the simulator's location for those."})]}):null}function qa({snapshot:e,run:t,open:n}){let i=e.places.length>0?e.places:e.builtInPlaces.slice(0,Wa),o=e.override.mode==="fixed"?e.override.place:null,r=e.position,a=!!o&&!i.some(c=>ft(c,o));return k(v,{children:[l(Y,{children:"Location"}),l(R,{children:k(te,{children:[i.map((c,d)=>l(j,{title:c.label??Fe(c,4),value:r&&!(o&&ft(c,o))?Ga(r,c):void 0,checked:!!o&&ft(c,o),testID:`location-place-${gt(c.label??String(d))}`,onPress:()=>t("setLocation",{latitude:c.latitude,longitude:c.longitude,label:c.label})},`${c.label??d}`)),l(j,{title:"Other Location\u2026",value:a?o.label||Fe(o,3):void 0,chevron:true,testID:"location-other",onPress:()=>n("places")},"other")]})})]})}function Ga(e,t){let n=V(e,t);return n<30?"Here":K(n)}function ft(e,t){return e.label&&t.label?e.label===t.label:V(e,t)<1}function Ka({snapshot:e,pick:t}){let[n,i]=De(""),o=vt(n),r=e.override.mode==="fixed"?e.override.place:null,a=()=>{o&&(t("setLocation",{query:n}),i(""))};return k(Ye,{children:[k(v,{children:[l(Y,{children:"Coordinates"}),l(R,{children:k(v,{style:y.editor,children:[k(v,{style:y.inputRow,children:[l(_n,{value:n,onChangeText:i,placeholder:"Coordinates or a Maps link",placeholderTextColor:m.color.placeholder,autoCapitalize:"none",autoCorrect:false,style:y.input,testID:"location-coordinate-input",accessibilityLabel:"Coordinates or a Maps link",returnKeyType:"done",onSubmitEditing:a}),l(mi,{label:"Pin",size:"md",variant:"primary",disabled:!o,testID:"location-coordinate-set",onPress:a})]}),n.length>0?l(T,{style:o?y.detail:y.warning,testID:"location-coordinate-preview",children:o?Ja(o):"Type a latitude and longitude, like 40.7580, -73.9855, or paste a Google or Apple Maps link."}):null]})})]}),k(v,{children:[l(Y,{children:"Places"}),l(R,{children:l(te,{children:e.builtInPlaces.map((c,d)=>l(j,{title:c.label??Fe(c,4),detail:c.label==="Null Island"?"0, 0: catches code that treats 0 as no location":void 0,checked:!!r&&ft(c,r),testID:`location-place-${gt(c.label??String(d))}`,onPress:()=>t("setLocation",{latitude:c.latitude,longitude:c.longitude,label:c.label})},`${c.label??d}`))})}),e.places.length===0?l(ee,{children:"Add your own places, such as your stores, with registerLocationPlaces()."}):null]})]})}function Ja(e){let t=`${Math.abs(e.latitude).toFixed(4)}\xB0 ${e.latitude>=0?"N":"S"}`,n=`${Math.abs(e.longitude).toFixed(4)}\xB0 ${e.longitude>=0?"E":"W"}`;return`${t}, ${n}`}function Ya({snapshot:e,open:t}){let n=e.override.mode==="route"?e.override.route:null;return k(v,{children:[l(Y,{children:"Movement"}),l(R,{children:k(te,{children:[l(j,{title:"Route",value:n?.name??"None",chevron:true,testID:"location-route",onPress:()=>t("routes")},"route"),n?l(j,{title:"Speed",value:Qa(n.speed),chevron:true,testID:"location-speed",onPress:()=>t("speed")},"speed"):null]})})]})}function Qa(e){let t=ki.find(n=>Math.abs(Number(n.key)-e)<.05);return t?t.label:Ut(e)}function Xa({snapshot:e,pick:t}){let n=e.override.mode==="route"?e.override.route:null,i=n?.id;return k(Ye,{children:[n?l(v,{children:l(R,{children:l(te,{children:l(j,{title:"Stop Here",detail:"End the route and stay where it got to",testID:"location-route-stop",onPress:()=>t("stopRoute")},"stop")})})}):null,e.routes.length>0?k(v,{children:[l(Y,{children:"This App"}),l(R,{children:l(te,{children:e.routes.map((o,r)=>l(j,{title:o.name??o.id??`Route ${r+1}`,detail:`${K(bt(o.points))} at ${Ut(o.speed)}${o.loop?", on repeat":""}`,checked:!!i&&i===o.id,testID:`location-route-${gt(o.id??o.name??String(r))}`,onPress:()=>t("startRoute",{route:o.id??o.name})},o.id??`${o.name}-${r}`))})})]}):null,k(v,{children:[l(Y,{children:"From Here"}),l(R,{children:l(te,{children:e.presets.map(o=>l(j,{title:o.name,detail:Za(o.id)??o.description,checked:i===`preset:${o.id}`,testID:`location-preset-${o.id}`,onPress:()=>t("startRoute",{route:o.id})},o.id))})}),l(ee,{children:"These start where the app is now."})]})]})}function Za(e){let t=K;switch(e){case"walk":return`${t(1e3)} north at walking pace`;case"run":return`${t(3e3)} north, then east, at running pace`;case"drive":return`${t(4e3)} of city streets with turns`;case"highway":return`${t(3e4)} north at highway speed`;case"tunnel":return`${t(3e3)} drive with no signal for ${t(600)} in the middle`;case"loop":return`A ${t(400)} block, walked on repeat`;default:return null}}function el({snapshot:e,pick:t}){let n=e.override.route?.speed??0;return k(v,{children:[l(R,{children:l(te,{children:ki.map(i=>l(j,{title:i.label,value:Ut(Number(i.key)),checked:Math.abs(Number(i.key)-n)<.05,testID:`location-speed-${i.key}`,onPress:()=>t("setSpeed",{speed:Number(i.key)})},i.key))})}),l(ee,{children:"Heading and speed follow the route."})]})}var tl=1e4;function nl({snapshot:e,run:t}){let n=e.tasks.filter(d=>d.kind==="geofencing"&&d.regions.length>0),[i,o]=De(null),r=Kt(!!i);if(n.length===0)return null;let a=n.length>1,c=n.map(d=>d.name).join(", ");return k(v,{children:[l(Y,{children:"Geofences"}),l(R,{children:l(te,{children:n.flatMap(d=>d.regions.map(h=>{let p=`${d.name}:${h.identifier}`,x=h.state==="inside",I=i?.key===p&&r-i.at<tl?i:null,A=[il(h)];return a&&A.push(d.name),l(j,{title:h.label??h.identifier,detail:A.join(" \xB7 "),note:I?ol(e,d,I.at):void 0,action:x?"Leave":"Enter",testID:`location-region-${gt(h.identifier)}`,onPress:()=>{o({key:p,at:Gt()}),t(x?"exitRegion":"enterRegion",{identifier:h.identifier,task:d.name})}},p)}))})}),k(ee,{children:["Tap a region to cross its edge. ",a?"The app's tasks":`The app's ${c} task`," runs as it would from the OS."]})]})}function il(e){return e.state==="inside"?"Inside":e.distance==null?`${K(e.radius)} radius`:`${K(Math.max(0,e.distance-e.radius))} away`}function ol(e,t,n){let i=e.log.filter(r=>r.at>=n-50&&(r.detail??"").startsWith(t.name)),o=i.find(r=>r.kind==="error");return o?{text:`Task failed: ${o.detail?.slice(t.name.length+3)??""}`,tone:"bad"}:i.find(r=>r.kind==="task")?{text:"Task ran",tone:"ok"}:i.find(r=>r.kind==="enter"||r.kind==="exit")?{text:"Running the app's task\u2026",tone:"wait"}:{text:"Already on this side",tone:"wait"}}function rl({snapshot:e,run:t,open:n}){let i=e.override,o=Vi(i),r=e.simulating?xi:xi.filter(a=>a.key!=="weak");return k(v,{children:[l(Y,{children:"Conditions"}),k(R,{children:[l(v,{style:y.segmentWrap,children:l(qt,{tabs:r,activeKey:o??"",size:"sm",testIDPrefix:"location-conditions",onChange:a=>t("setConditions",{conditions:a})})}),e.simulating&&i.services&&i.signal?l(v,{style:y.separatorTop,children:l(j,{title:"Accuracy & Drift",value:`${li(i.accuracy)}${i.jitter>0?` \xB7 drifts ${K(i.jitter)}`:""}`,chevron:true,testID:"location-accuracy",onPress:()=>n("accuracy")})}):null]}),l(ee,{children:za[o??"custom"]})]})}function al({snapshot:e,run:t}){let n=e.override;return k(Ye,{children:[k(v,{children:[l(Y,{children:"Accuracy"}),l(R,{children:l(v,{style:y.segmentWrap,children:l(qt,{tabs:Ci,activeKey:Si(Ci,n.accuracy)??"",size:"sm",testIDPrefix:"location-accuracy",onChange:i=>t("tune",{accuracy:Number(i)})})})}),l(ee,{children:"The accuracy radius the app is given with each fix."})]}),k(v,{children:[l(Y,{children:"Drift"}),l(R,{children:l(v,{style:y.segmentWrap,children:l(qt,{tabs:Ii,activeKey:Si(Ii,n.jitter)??"0",size:"sm",testIDPrefix:"location-drift",onChange:i=>t("tune",{jitter:Number(i)})})})}),l(ee,{children:"Moves each fix by up to this much at random, the way a real fix wanders."})]})]})}function ll({snapshot:e,open:t}){let n=e.log.length;return l(v,{children:l(R,{children:k(te,{children:[l(j,{title:"Activity",value:n===0?"None":`${n} ${n===1?"event":"events"}`,chevron:true,testID:"location-activity",onPress:()=>t("activity")},"activity"),l(j,{title:"Options",chevron:true,testID:"location-options",onPress:()=>t("options")},"options")]})})})}function sl({snapshot:e,run:t}){let n=Kt(true),i=e.log.slice().reverse(),o=e.watches.filter(d=>d.kind==="position").length,r=e.tasks.filter(d=>d.kind==="locationUpdates").length,a=e.tasks.filter(d=>d.kind==="geofencing").reduce((d,h)=>d+h.regions.length,0),c=[o?`${o} location ${o===1?"watch":"watches"}`:null,a?`${a} ${a===1?"geofence":"geofences"}`:null,r?"background updates":null].filter(Boolean);return k(Ye,{children:[k(v,{children:[l(Y,{children:"The App Is Using"}),l(R,{children:k(v,{style:y.editor,children:[l(T,{style:y.rowTitle,testID:"location-activity-summary",children:c.length?c.join(", "):"Nothing right now"}),l(T,{style:y.detail,children:e.libraries.length?`Through ${e.libraries.join(" and ")}.`:"No supported location library was found in this app."})]})})]}),k(v,{children:[l(Y,{children:"Recent"}),l(R,{children:k(te,{children:[i.length===0?l(v,{style:y.editor,children:l(T,{style:y.detail,children:"Location requests, watches and geofence crossings show up here."})},"empty"):i.map(d=>k(v,{style:y.logRow,testID:"location-log-entry",children:[l(v,{style:[y.logDot,cl(d.kind)]}),k(v,{style:y.flex,children:[l(T,{style:y.logText,children:d.text}),d.detail?l(T,{style:y.logDetail,numberOfLines:2,children:d.detail}):null]}),l(T,{style:y.logWhen,children:na(d.at,n)})]},d.id)),i.length>0?l(j,{title:"Clear",tint:true,testID:"location-clear-log",onPress:()=>t("clearLog")},"clear"):null]})})]})]})}function cl(e){return e==="enter"?y.dotEnter:e==="exit"?y.dotExit:e==="error"?y.dotError:e==="task"?y.dotTask:null}function ul({snapshot:e,run:t}){return k(v,{children:[l(R,{children:k(te,{children:[l(Ti,{title:"Keep Across Reloads",value:e.settings.persist,testID:"location-setting-persist",onValueChange:n=>t("updateSettings",{persist:n})},"persist"),l(Ti,{title:"Show Floating Status",value:e.settings.showChip,testID:"location-setting-showChip",onValueChange:n=>t("updateSettings",{showChip:n})},"chip")]})}),l(ee,{children:"The floating status stays on screen while the app is somewhere else, so a simulated location is never left on by accident."})]})}function dl({title:e,onBack:t}){return k(se,{testID:"location-back",accessibilityRole:"button",accessibilityLabel:"Back",activeOpacity:.6,onPress:t,style:y.backRow,children:[l(Ia,{size:18,color:m.color.accent}),l(T,{style:y.backLabel,children:"Location"}),l(T,{style:y.backTitle,numberOfLines:1,children:e})]})}function j({title:e,detail:t,note:n,value:i,action:o,checked:r,chevron:a,tint:c,onPress:d,testID:h}){return k(se,{testID:h,accessibilityRole:"button",accessibilityLabel:o?`${o} ${e}`:e,accessibilityState:r?{selected:true}:void 0,activeOpacity:.6,onPress:d,style:y.row,children:[k(v,{style:y.rowText,children:[l(T,{style:[y.rowTitle,c?y.titleTint:null],numberOfLines:1,children:e}),t?l(T,{style:y.detail,children:t}):null,n?l(T,{style:[y.note,n.tone==="ok"?y.noteOk:n.tone==="bad"?y.noteBad:null],testID:`${h}-result`,children:n.text}):null]}),i?l(T,{style:y.rowValue,numberOfLines:1,children:i}):null,o?l(T,{style:y.rowAction,children:o}):null,r?l(Ca,{size:18,color:m.color.accent}):null,a?l(Aa,{size:16,color:m.color.textTertiary}):null]})}function Ti({title:e,value:t,onValueChange:n,testID:i}){return k(v,{style:y.row,children:[l(v,{style:y.rowText,children:l(T,{style:y.rowTitle,children:e})}),l(Ta,{value:t,testID:i,accessibilityLabel:e,onValueChange:n})]})}function Si(e,t){let n=null,i=1/0;for(let o of e){let r=Math.abs(Number(o.key)-t);r<i&&(n=o.key,i=r)}return n!==null&&i<=Math.max(.05,Number(n)*.05)?n:null}function gt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}var y=le.create({fill:{flex:1},flex:{flex:1},content:{paddingHorizontal:m.gutter,paddingTop:8,gap:m.groupGap},waiting:{flex:1,alignItems:"center",justifyContent:"center",padding:24},status:{padding:m.cardPad+2,gap:6},statusTitle:{color:m.color.text,fontSize:28,fontWeight:"600"},titleSimulated:{color:m.color.accent},titleBroken:{color:_a},statusLine:{color:m.color.textSecondary,fontSize:m.font.row,fontVariant:["tabular-nums"]},coordinates:{color:m.color.textTertiary,fontSize:m.font.caption,fontFamily:Ma},statusButtons:{flexDirection:"row",alignItems:"center",gap:10,marginTop:10},round:{width:44,height:44,borderRadius:22,alignItems:"center",justifyContent:"center",backgroundColor:m.color.accent},progressTrack:{height:6,borderRadius:3,marginTop:8,backgroundColor:m.color.fillSecondary,overflow:"hidden"},progressFill:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:m.color.accent},progressGap:{position:"absolute",top:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.28)"},permission:{borderTopWidth:le.hairlineWidth,borderTopColor:m.color.separator,paddingHorizontal:m.rowPadH,paddingVertical:12,gap:4},rowBetween:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12},valueWarning:{color:m.color.warning},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:48,paddingHorizontal:m.rowPadH,paddingVertical:10},rowText:{flex:1,gap:2},rowTitle:{color:m.color.text,fontSize:m.font.row},titleTint:{color:m.color.accent},rowValue:{color:m.color.textSecondary,fontSize:m.font.row,maxWidth:"50%"},rowAction:{color:m.color.accent,fontSize:m.font.row,fontWeight:"500"},detail:{color:m.color.textTertiary,fontSize:m.font.caption},note:{color:m.color.textSecondary,fontSize:m.font.caption,marginTop:2},noteOk:{color:m.color.accent},noteBad:{color:m.color.danger},warning:{color:m.color.warning,fontSize:m.font.caption},separatorTop:{borderTopWidth:le.hairlineWidth,borderTopColor:m.color.separator},segmentWrap:{flexDirection:"row",padding:10},editor:{paddingHorizontal:m.rowPadH,paddingVertical:14,gap:8},inputRow:{flexDirection:"row",alignItems:"center",gap:8},input:{flex:1,color:m.color.text,fontSize:m.font.body,backgroundColor:m.color.bg,borderRadius:m.radius.input,borderWidth:1,borderColor:m.color.border,paddingHorizontal:12,paddingVertical:9},backRow:{flexDirection:"row",alignItems:"center",gap:4,paddingVertical:4},backLabel:{color:m.color.accent,fontSize:m.font.row},backTitle:{flex:1,color:m.color.text,fontSize:m.font.row,fontWeight:"600",textAlign:"center",marginRight:70},logRow:{flexDirection:"row",alignItems:"flex-start",gap:10,paddingHorizontal:m.rowPadH,paddingVertical:10},logDot:{width:8,height:8,borderRadius:4,marginTop:6,backgroundColor:m.color.textTertiary},dotEnter:{backgroundColor:m.color.accent},dotExit:{backgroundColor:m.color.warning},dotError:{backgroundColor:m.color.danger},dotTask:{backgroundColor:m.color.info},logText:{color:m.color.text,fontSize:m.font.body},logDetail:{color:m.color.textTertiary,fontSize:m.font.caption,marginTop:2},logWhen:{color:m.color.textTertiary,fontSize:m.font.caption,fontVariant:["tabular-nums"],marginTop:1}});import{jsx as Li}from"react/jsx-runtime";var pl=Vt.actions;async function fl(e,t){let n=pl[e];if(!n)throw new Error(`Unknown location action: ${e}`);return n(t)}var Jt=()=>Vt.getSnapshot(),gl=2e3;function Pi(){let[e,t]=ha(Jt);return ga(()=>{zt(),Rt(),t(Jt()),pi(true),rt();let n=setInterval(rt,gl),i=Ue(()=>t(Jt()));return()=>{clearInterval(n),i(),pi(false)}},[]),Li(ma,{featureName:"Location",children:Li(Ai,{snapshot:e,onAction:fl})})}import{jsx as hl}from"react/jsx-runtime";var $i=fa({id:"location",name:"LOCATION",description:"Pin the app anywhere, play routes, trigger geofences",slot:"both",color:da,icon:({size:e,color:t})=>hl(ua,{size:e,color:t}),component:Pi,modal:{subtitle:"simulate where the app is"}}),ml=pa($i);import{LocationToolIcon as yl,LOCATION_TOOL_ICON_COLOR as bl}from"@buoy-gg/shared-ui/web";var vl=typeof navigator<"u"&&navigator.product==="ReactNative",wl=(()=>{try{return globalThis.Capacitor?.isNativePlatform?.()===true}catch{return false}})();(vl||wl)&&(ca(),typeof Xt<"u"&&Xt&&(zt(),Rt()));export{dt as BUILT_IN_PLACES,ut as LOCATION_CHIP_ID,bl as LOCATION_TOOL_ICON_COLOR,Pi as LocationBody,fi as LocationChip,yl as LocationToolIcon,Ai as LocationToolView,Oe as ROUTE_PRESETS,Ze as bearingDegrees,Rt as bootLocation,gi as buildPresetRoute,ml as createLocationTool,je as destination,V as distanceMeters,E as getLocationSnapshot,zt as installLocationAdapters,P as isLocationActive,Vt as locationSyncAdapter,$i as locationToolPreset,Mt as moveToRegion,vt as parseCoordinate,Pt as pauseRoute,rt as refreshLocationPermission,ao as registerLocationPlaces,lo as registerLocationRoutes,Et as resetLocation,$t as resumeRoute,In as seekRoute,Pn as setConditions,ct as setPlace,An as setRouteSpeed,Ln as setServices,Sn as setSignal,Cn as startRoute,$n as stopRoute,Ue as subscribeLocation,Tn as tuneOverride,Mn as useRealLocation};
3
+ \u2192 Caused by: ${t}`}var qn={denied:{ios:{code:"ERR_DENIED_FOREGROUND_LOCATION_PERMISSION",reason:"Location permission is required to do this operation"},android:{code:"ERR_LOCATION_UNAUTHORIZED",reason:"Not authorized to use location services"}},deniedBackground:{ios:{code:"ERR_DENIED_BACKGROUND_LOCATION_PERMISSION",reason:"Background location permission is required to do this operation"},android:{code:"ERR_LOCATION_BACKGROUND_UNAUTHORIZED",reason:"Not authorized to use background location services"}},services:{ios:{code:"ERR_LOCATION_SERVICES_DISABLED",reason:"Location services are disabled"},android:{code:"ERR_LOCATION_SETTINGS_UNSATISFIED",reason:"Location request failed due to unsatisfied device settings"}},unavailable:{ios:{code:"ERR_LOCATION_UNAVAILABLE",reason:"Cannot obtain current location"},android:{code:"ERR_CURRENT_LOCATION_IS_UNAVAILABLE",reason:"Current location is unavailable. Make sure that location services are enabled"}}};function ce(e,t,n){let i=n==="android"?qn[e].android:qn[e].ios;return Promise.reject(go(i.code,Pr(t,i.reason,n)))}var Gn=false;function $r(){let e=Vn("ExpoLocation");if(!e||typeof e.getCurrentPositionAsync!="function")return false;let t=e,n=Vn("ExpoTaskManager"),i=Lr(),o=new Map,r={},a=()=>Date.now(),c=u=>s=>t.emit?.("Expo.locationChanged",{watchId:u,location:Bt(s,i,a())}),d=u=>s=>{let f=s.heading??0;t.emit?.("Expo.headingChanged",{watchId:u,heading:{trueHeading:f,magHeading:f,accuracy:3}})},h=u=>s=>t.emit?.("Expo.locationError",{watchId:u,reason:s});async function p(){let u=t.getForegroundPermissionsAsync,s={granted:true,status:"granted",precision:"full",reported:false};if(typeof u!="function")return s;try{let f=await u.call(t),w=f?.ios?.accuracy==="reduced"||f?.android?.accuracy==="coarse"?"reduced":"full";Zi(w);let C=f?.granted===true,ie=C?"granted":f?.status==="undetermined"?"undetermined":"denied";return{granted:C,status:ie,precision:w,reported:true}}catch{return s}}async function x(){let u=t.getBackgroundPermissionsAsync;if(typeof u!="function")return null;try{return(await u.call(t))?.granted===true}catch{return null}}async function I(){let u=t.getBackgroundPermissionsAsync;if(typeof u!="function")return true;try{return(await u.call(t))?.granted===true}catch{return true}}function A(u,s){lt({library:N,id:u,kind:s.kind,options:s.options,deliver:s.kind==="position"?c(u):d(u),fail:h(u)})}r.getCurrentPositionAsync=L(t,"getCurrentPositionAsync",u=>async(...s)=>{if(!P())return u(...s);let f="getCurrentPositionAsync";if(!be())return S("request",N,"getCurrentPositionAsync \u2192 services off"),ce("services",f,i);if(!(await p()).granted)return S("request",N,"getCurrentPositionAsync \u2192 permission denied"),ce("denied",f,i);let{fix:w}=re();return w?(S("request",N,`getCurrentPositionAsync \u2192 ${w.latitude.toFixed(5)}, ${w.longitude.toFixed(5)}`),Bt(w,i,a())):(S("request",N,"getCurrentPositionAsync \u2192 no signal"),await new Promise(C=>z(()=>C(null),1e3)),ce("unavailable",f,i))}),r.getLastKnownPositionAsync=L(t,"getLastKnownPositionAsync",u=>async(...s)=>{if(!P())return u(...s);if(!(await p()).granted)return ce("denied","getLastKnownPositionAsync",i);let{fix:f}=re();return S("request",N,`getLastKnownPositionAsync \u2192 ${f?"simulated":"null"}`),f?Bt(f,i,a()):null}),r.watchPositionImplAsync=L(t,"watchPositionImplAsync",u=>async(...s)=>{let f=Number(s[0]),w=s[1]&&typeof s[1]=="object"?s[1]:{};if(!P()){let ie=await u(...s),ue={kind:"position",options:w,native:true};return o.set(f,ue),P()&&Ce(f,ue),ie}if(!(await p()).granted)return ce("denied","watchPositionImplAsync",i);if(!P())return o.set(f,{kind:"position",options:w,native:true}),u(...s);let C={kind:"position",options:w,native:false};o.set(f,C),A(f,C)}),r.watchDeviceHeading=L(t,"watchDeviceHeading",u=>async(...s)=>{let f=Number(s[0]);if(!P()){let C=await u(...s),ie={kind:"heading",options:{},native:true};return o.set(f,ie),P()&&Ce(f,ie),C}if(!(await p()).granted)return ce("denied","watchDeviceHeading",i);if(!P())return o.set(f,{kind:"heading",options:{},native:true}),u(...s);let w={kind:"heading",options:{},native:false};o.set(f,w),A(f,w)}),r.removeWatchAsync=L(t,"removeWatchAsync",u=>async(...s)=>{let f=Number(s[0]),w=o.get(f);if(o.delete(f),ae(N,"position",f),ae(N,"heading",f),!w||w.native)return u(...s)}),L(t,"hasServicesEnabledAsync",u=>async(...s)=>P()&&!be()?false:u(...s)),L(t,"getProviderStatusAsync",u=>async(...s)=>{let f=await u(...s);if(!P()||be())return f;let w={...f,locationServicesEnabled:false};for(let C of["gpsAvailable","networkAvailable","passiveAvailable"])C in w&&(w[C]=false);return w});let F=(u,s)=>L(t,s,f=>async(...w)=>{let C=String(w[0]),ie=w[1]&&typeof w[1]=="object"?w[1]:{},ue={name:C,kind:u,library:N,options:ie};if(!P()){let mt=await f(...w);return Tt(ue,false),P()&&b(true),mt}if(u==="locationUpdates"&&!be())return ce("services",s,i);if(!(await p()).granted)return ce("denied",s,i);if(u==="geofencing"&&!await I())return ce("deniedBackground",s,i);Tt(ue,true)});r.startLocationUpdatesAsync=F("locationUpdates","startLocationUpdatesAsync"),r.startGeofencingAsync=F("geofencing","startGeofencingAsync");let _=(u,s)=>L(t,s,f=>async(...w)=>{let C=Ee(String(w[0]));if(!(C&&C.kind===u&&(St(C.name),C.intercepted)))return f(...w)});r.stopLocationUpdatesAsync=_("locationUpdates","stopLocationUpdatesAsync"),r.stopGeofencingAsync=_("geofencing","stopGeofencingAsync");let ge=(u,s)=>L(t,s,f=>async(...w)=>{let C=Ee(String(w[0]));return C&&C.kind===u?true:f(...w)});ge("locationUpdates","hasStartedLocationUpdatesAsync"),ge("geofencing","hasStartedGeofencingAsync");let he=new Map,ht=0,Qe={geofencing:"geofencing",locationUpdates:"location"};n&&(L(n,"notifyTaskFinishedAsync",u=>async(...s)=>{let f=s[1]??{},w=f.eventId?he.get(f.eventId):void 0;if(w&&f.eventId){he.delete(f.eventId),w(f.result);return}return u(...s)}),L(n,"isTaskRegisteredAsync",u=>async(...s)=>Ee(String(s[0]))?.intercepted?true:u(...s)),L(n,"getTaskOptionsAsync",u=>async(...s)=>{let f=Ee(String(s[0]));return f?.intercepted?f.options:u(...s)}),L(n,"getRegisteredTasksAsync",u=>async(...s)=>{let f=await u(...s)??[],w=Lt().filter(C=>C.intercepted).map(C=>({taskName:C.name,taskType:Qe[C.kind],options:C.options}));return[...f,...w]}),L(n,"unregisterTaskAsync",u=>async(...s)=>{let f=Ee(String(s[0]));if(!(f&&(St(f.name),f.intercepted)))return u(...s)}),L(n,"unregisterAllTasksAsync",u=>async(...s)=>{for(let f of Lt())St(f.name);return u(...s)}));function Be(){if(!n)return null;if(n.__expo_module_name__&&typeof n.emit=="function")return(s,f)=>n.emit(s,f);let u=Dn;return u?(s,f)=>u.emit(s,f):null}async function me(u){for(let s=0;s<5e3&&Sr(u)===false;s+=100)await new Promise(f=>z(()=>f(null),100))}async function Xe(u,s){await me(u.name);let f=Be();if(!f)return Promise.reject(new Error("expo-task-manager is not installed"));let w=`buoy-location-${++ht}`,C=typeof n?.EVENT_NAME=="string"?n.EVENT_NAME:"TaskManager.executeTask";return new Promise((ie,ue)=>{he.set(w,ie),z(()=>{he.delete(w)&&ue(new Error("did not finish within 30 s"))},3e4);try{f(C,{data:s,error:null,executionInfo:{eventId:w,taskName:u.name,appState:"active"}})}catch(mt){he.delete(w),ue(mt)}})}function Ce(u,s){s.native&&(s.native=false,Promise.resolve(r.removeWatchAsync?.(u)).catch(()=>{}),A(u,s))}function b(u){for(let[s,f]of Array.from(o.entries()))if(u&&f.native)Ce(s,f);else if(!u&&!f.native){ae(N,f.kind,s);let w=f.kind==="position"?r.watchPositionImplAsync:r.watchDeviceHeading;f.native=true,Promise.resolve(f.kind==="position"?w?.(s,f.options):w?.(s)).catch(C=>{f.native=false,h(s)(String(C?.message??C))})}else u&&!f.native&&!ro(N,f.kind,s)&&A(s,f);for(let s of Lt()){if(s.library!==N)continue;let f=s.kind==="geofencing";if(u&&!s.intercepted){let w=f?r.stopGeofencingAsync:r.stopLocationUpdatesAsync;Promise.resolve(w?.(s.name)).catch(()=>{}),xn(s.name,true)}else if(!u&&s.intercepted){let w=f?r.startGeofencingAsync:r.startLocationUpdatesAsync;xn(s.name,false),Promise.resolve(w?.(s.name,s.options)).catch(C=>{S("error",N,`Could not restart ${s.name} natively: ${String(C?.message??C)}`)})}}}return at({library:N,fireTask:Xe,onActiveChange:b,readPermission:async()=>{let u=await p();if(!u.reported)return null;let s=u.status==="granted"?await x():false;return{status:u.status,background:s,precision:u.precision}}}),Gn||(Gn=true,n&&typeof n.getRegisteredTasksAsync=="function"&&Promise.resolve(n.getRegisteredTasksAsync.call(n)).then(u=>{for(let s of u??[]){if(!s?.taskName||Ee(s.taskName))continue;let f=s.taskType==="geofencing"?"geofencing":s.taskType==="location"?"locationUpdates":null;f&&(Tt({name:s.taskName,kind:f,library:N,options:s.options??{}},false),P()&&b(true))}}).catch(()=>{})),true}import{callCapacitorAsApp as Mr,callCapacitorNative as Kn,callCapacitorNativeCallback as Er,capacitorPlatform as Rr,hasCapacitorPlugin as Nr,installCapacitorBridge as Or,interceptCapacitor as jt,makeCapacitorCallbackId as Dr}from"@buoy-gg/license/web";var ve="@capacitor/geolocation",pe="Geolocation";function Jn(e,t){return{timestamp:t,coords:{latitude:e.latitude,longitude:e.longitude,accuracy:e.accuracy,altitude:e.altitude,altitudeAccuracy:e.altitudeAccuracy,speed:e.speed,heading:e.heading}}}function Ft(e){return new Error(e)}function Br(e){if(!e||typeof e!="object")return null;let t=e.location,n=e.coarseLocation??t;return{status:t==="granted"||n==="granted"?"granted":t==="denied"&&(n==="denied"||n===void 0)?"denied":"undetermined",background:null,precision:t!=="granted"&&n==="granted"?"reduced":"full"}}function Yn(e,t){return(n,i)=>{e.gen===t&&e.nativeId!==null&&e.callback(n,i)}}var qe=new Map,Qn=false;function Xn(e){lt({library:ve,id:e.id,kind:"position",options:e.options,deliver:t=>e.callback(Jn(t,Date.now())),fail:t=>e.callback(null,Ft(t))})}function jr(e){let t=++e.gen;e.nativeId=Er(pe,"watchPosition",e.options,Yn(e,t))}function Fr(e){if(e.gen++,e.nativeId===null)return;let t=e.nativeId;e.nativeId=null,Kn(pe,"clearWatch",{id:t}).catch(()=>{})}function _r(){return Qn?true:!Rr()||!Nr(pe)||!Or()?false:(Qn=true,jt({plugin:pe,methods:["getCurrentPosition"],promise:(e,t)=>{if(!P())return t();if(!be())return S("request",ve,"getCurrentPosition \u2192 services off"),Promise.reject(Ft("Location services are not enabled"));let{fix:n}=re();return n?(S("request",ve,`getCurrentPosition \u2192 ${n.latitude.toFixed(5)}, ${n.longitude.toFixed(5)}`),Jn(n,Date.now())):(S("request",ve,"getCurrentPosition \u2192 no signal"),new Promise((i,o)=>z(()=>o(Ft("Timeout")),1e3)))}}),jt({plugin:pe,methods:["watchPosition"],callback:(e,t,n)=>{if(!P()){let o={id:"",options:e.options,callback:t,nativeId:null,gen:1},r=n(Yn(o,1));return r===null?null:(o.id=r,o.nativeId=r,qe.set(r,o),r)}let i={id:Dr(),options:e.options,callback:t,nativeId:null,gen:1};return qe.set(i.id,i),Xn(i),i.id}}),jt({plugin:pe,methods:["clearWatch"],promise:(e,t)=>{let n=String(e.options.id??""),i=qe.get(n);if(!i)return t();if(qe.delete(n),i.gen++,ae(ve,"position",n),i.nativeId===null)return;let o=i.nativeId;return i.nativeId=null,o===n?t():Kn(pe,"clearWatch",{id:o})}}),at({library:ve,onActiveChange(e){for(let t of qe.values())e&&t.nativeId!==null?(Fr(t),Xn(t)):!e&&t.nativeId===null&&(ae(ve,"position",t.id),jr(t))},async readPermission(){try{return Br(await Mr(pe,"checkPermissions"))}catch{return null}}}),true)}var we="navigator.geolocation",zr={PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3};function _t(e,t){return{code:e,message:t,...zr}}function Zn(e,t){let n={latitude:e.latitude,longitude:e.longitude,altitude:e.altitude,accuracy:e.accuracy,altitudeAccuracy:e.altitudeAccuracy,heading:e.heading,speed:e.speed};return{coords:{...n,toJSON:()=>n},timestamp:t,toJSON:()=>({coords:n,timestamp:t})}}function ei(e,t){let n=()=>e.gen===t&&e.nativeId!==null;return[(...i)=>n()?e.success(...i):void 0,(...i)=>n()?e.error?.(...i):void 0]}var Ge=new Map,Wr=1e6,ti=false;function Ur(){if(ti)return true;let e=globalThis.navigator?.geolocation;if(!e||typeof e.getCurrentPosition!="function")return false;ti=true;let t=null,n=null,i=o=>lt({library:we,id:o.id,kind:"position",options:o.options,deliver:r=>o.success(Zn(r,Date.now())),fail:r=>o.error?.(_t(2,r))});return L(e,"getCurrentPosition",o=>(...r)=>{if(!P())return o(...r);let a=r[0],c=r[1];if(!be()){S("request",we,"getCurrentPosition \u2192 services off"),z(()=>c?.(_t(2,"Location services are disabled")),0);return}let{fix:d}=re();if(!d){S("request",we,"getCurrentPosition \u2192 no signal"),z(()=>c?.(_t(3,"Timeout expired")),1e3);return}S("request",we,`getCurrentPosition \u2192 ${d.latitude.toFixed(5)}, ${d.longitude.toFixed(5)}`),z(()=>a?.(Zn(d,Date.now())),0)}),t=L(e,"watchPosition",o=>(...r)=>{let a=r[0],c=r[1],d=r[2]&&typeof r[2]=="object"?r[2]:{};if(!P()){let p={id:0,success:a,error:c,options:d,nativeId:null,gen:1},[x,I]=ei(p,1),A=o(x,I,r[2]);return p.id=A,p.nativeId=A,Ge.set(A,p),A}let h={id:Wr++,success:a,error:c,options:d,nativeId:null,gen:1};return Ge.set(h.id,h),i(h),h.id}),n=L(e,"clearWatch",o=>(...r)=>{let a=r[0],c=Ge.get(a);if(!c)return o(...r);if(Ge.delete(a),c.gen++,ae(we,"position",a),c.nativeId!==null)return o(c.nativeId)}),at({library:we,onActiveChange(o){for(let r of Ge.values())if(o&&r.nativeId!==null)r.gen++,n?.(r.nativeId),r.nativeId=null,i(r);else if(!o&&r.nativeId===null){ae(we,"position",r.id);let a=++r.gen,[c,d]=ei(r,a);r.nativeId=t?.(c,d,r.options)??null}}}),true}var ke=null;function zt(){return ke||(ke=[],$r()&&ke.push("expo-location"),ke.push(...Ar()),_r()&&ke.push("@capacitor/geolocation"),Ur()&&ke.push("navigator.geolocation"),ke)}import{useSyncExternalStore as Hr}from"react";import{FloatingTool as Vr,LocationToolIcon as ni,Pause as qr,Play as Gr,RefreshCw as Kr,X as Jr,dismissFloatingTool as Yr,getFloatingTools as Qr,night as fe,openFloatingTool as Xr}from"@buoy-gg/shared-ui/web";var Zr=new Set(["US","GB","LR","MM"]),ii=null;function ea(){try{let e=Intl.DateTimeFormat().resolvedOptions().locale,t=/[-_]([A-Z]{2})\b/.exec(e);return t?t[1]:null}catch{return null}}var Wt=null;function Ne(){return ii!==null?ii:(Wt===null&&(Wt=Zr.has(ea()??"")),Wt)}var oi=3.28084,ri=1609.344;function K(e){if(!Number.isFinite(e))return"\u2013";let t=Math.abs(e);if(Ne()){let n=t/ri;return n<.1?`${Math.round(t*oi/10)*10} ft`:`${ai(n)} mi`}return t<1e3?`${Math.round(t)} m`:`${ai(t/1e3)} km`}function ai(e){let t=Math.round(e*10)/10;return t<10?t.toFixed(1):Math.round(e).toLocaleString("en-US")}function li(e){return Number.isFinite(e)?e>=1e3?`\xB1${K(e)}`:Ne()?`\xB1${Math.round(e*oi)} ft`:`\xB1${Math.round(e)} m`:"\u2013"}function Ut(e){if(e==null||e<0)return"\u2013";let t=Ne()?e*3600/ri:e*3.6,n=Ne()?"mph":"km/h";return`${t<10?t.toFixed(1):Math.round(t)} ${n}`}function ta(e){if(!Number.isFinite(e)||e<0)return"\u2013";let t=Math.round(e/6e4);if(t<1)return`${Math.max(1,Math.round(e/1e3))} sec`;if(t<60)return`${t} min`;let n=Math.floor(t/60),i=t%60;return i?`${n} hr ${i} min`:`${n} hr`}function na(e,t){let n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"now";if(n<60)return`${n}s ago`;try{return new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}catch{let i=new Date(e);return`${i.getHours()}:${String(i.getMinutes()).padStart(2,"0")}`}}function si(e){return e.override.services?e.override.signal?e.override.mode==="real"?"Real Location":e.override.mode==="route"?e.override.route?.name??"Route":e.override.place.label||"Dropped Pin":"No GPS Signal":"Location Services Off"}function ia(e){return!e.override.services||!e.override.signal?"broken":e.override.mode==="real"?"real":"simulated"}function oa(e){if(!e.override.services)return"The app is told location services are off";if(!e.override.signal)return"Updates stop and location requests fail";if(e.override.mode==="real")return"The app gets the device's location";let t=[];if(e.override.mode==="route"&&e.progress){let i=e.progress;i.finished?t.push("Arrived"):e.override.playing||t.push("Paused"),e.current.reason==="gap"&&t.push("no signal here"),i.finished||(t.push(`${K(i.along)} of ${K(i.length)}`),i.etaMs!=null?t.push(`${ta(i.etaMs)} left`):e.override.route?.loop&&t.push("on repeat"))}else t.push("Pinned");let n=e.current.fix;return n&&e.override.mode==="fixed"&&t.push(li(n.accuracy)),e.current.precision==="reduced"&&t.push("approximate"),t.join(" \xB7 ")}function ra(e){return e.status==="denied"?"Not Allowed":e.status==="undetermined"?"Not Asked Yet":`${e.background?"Always":"While Using"} \xB7 ${e.precision==="reduced"?"Approximate":"Precise"}`}function aa(e){if(!e.override.services)return"The app is told location is off";if(!e.override.signal)return"Updates stop, requests fail";if(e.override.mode==="route"&&e.progress){if(e.progress.finished)return"Arrived";let n=`${K(e.progress.along)} of ${K(e.progress.length)}`;return e.override.playing?n:`Paused \xB7 ${n}`}let t=e.current.fix;return t?`Pinned \xB7 ${Fe(t,3)}`:"Pinned"}import{jsx as H,jsxs as ci}from"react/jsx-runtime";var ut="location-chip",la={id:ut,render:e=>H(fi,{...e})},sa=()=>Qr().some(e=>e.id===ut),ui=false,Ht=false,di=null;function pi(e){Ht!==e&&(Ht=e,di?.())}function ca(){if(ui)return;ui=true;let e=false,t=()=>{let n=E().active&&uo().showChip&&!Ht;n&&!e?Xr(la):!n&&sa()&&Yr(ut),e=n};di=t,Ue(t),t()}function fi({id:e,revealToken:t}){let n=Hr(Ue,E,E),i=si(n),o=n.override.mode==="route"&&n.progress,r=n.override.playing,a=!!o&&o.finished;return H(Vr,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:`Move or hide the location chip. ${i}`,handleAdornment:H(ni,{size:12}),children:ci(v,{style:xe.row,children:[H(ni,{size:18}),ci(v,{style:xe.text,children:[H(T,{style:xe.title,numberOfLines:1,testID:"location-chip-title",children:i}),H(T,{style:xe.detail,numberOfLines:1,testID:"location-chip-detail",children:aa(n)})]}),o?H(se,{testID:"location-chip-playpause",accessibilityRole:"button",accessibilityLabel:r?"Pause the route":a?"Play the route again":"Resume the route",onPress:()=>r?Pt():$t(),style:xe.pill,hitSlop:{top:8,bottom:8,left:4,right:4},children:r?H(qr,{size:14,color:fe.color.accent}):a?H(Kr,{size:14,color:fe.color.accent}):H(Gr,{size:14,color:fe.color.accent})}):null,H(v,{style:xe.separator}),H(se,{testID:"location-chip-reset",accessibilityRole:"button",accessibilityLabel:"Back to the real location",onPress:()=>Et(),style:xe.button,hitSlop:{top:8,bottom:8,left:4,right:8},children:H(Jr,{size:16,color:fe.color.textSecondary})})]})})}var xe=le.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingLeft:10,paddingRight:4,paddingVertical:6,minWidth:230,maxWidth:340},text:{flexShrink:1,minWidth:120},title:{color:fe.color.text,fontSize:14,fontWeight:"600"},detail:{color:fe.color.textSecondary,fontSize:11,fontVariant:["tabular-nums"]},pill:{width:30,height:30,borderRadius:15,alignItems:"center",justifyContent:"center",backgroundColor:fe.color.accentFill},button:{width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:16},separator:{width:le.hairlineWidth,height:20,backgroundColor:fe.color.separator}});import{LocationToolIcon as ua,LOCATION_TOOL_ICON_COLOR as da,createToolFactory as pa,defineToolPreset as fa}from"@buoy-gg/shared-ui/web";import{useEffect as ga,useState as ha}from"react";import{FeatureGate as ma}from"@buoy-gg/shared-ui/web";import{createSyncAdapter as ya}from"@buoy-gg/shared-ui/web";var dt=[{latitude:37.3349,longitude:-122.009,label:"Apple Park"},{latitude:37.422,longitude:-122.0841,label:"Googleplex"},{latitude:40.758,longitude:-73.9855,label:"Times Square"},{latitude:51.508,longitude:-.1281,label:"Trafalgar Square"},{latitude:48.8584,longitude:2.2945,label:"Eiffel Tower"},{latitude:35.6595,longitude:139.7005,label:"Shibuya Crossing"},{latitude:-33.8568,longitude:151.2153,label:"Sydney Opera House"},{latitude:-23.5614,longitude:-46.6559,label:"S\xE3o Paulo"},{latitude:0,longitude:0,label:"Null Island"}],Oe=[{id:"walk",name:"Walk",description:"1 km north from here at walking pace",speed:1.4},{id:"run",name:"Run",description:"3 km north, then east, at running pace",speed:3.3},{id:"drive",name:"City Drive",description:"4 km of city streets with turns",speed:13.4},{id:"highway",name:"Highway",description:"30 km north at highway speed",speed:30},{id:"tunnel",name:"Tunnel",description:"3 km drive with no signal for 600 m in the middle",speed:13.4},{id:"loop",name:"Block Loop",description:"A 400 m block, walked on repeat",speed:1.4}];function gi(e,t,n=0){let i=Oe.find(h=>h.id===e);if(!i)throw new Error(`Unknown route preset "${e}". Use one of: ${Oe.map(h=>h.id).join(", ")}.`);let o={latitude:t.latitude,longitude:t.longitude},r=(h,p,x)=>je(h,n+p,x),a,c,d=false;switch(e){case"walk":a=[o,r(o,0,1e3)];break;case"run":a=[o,r(o,0,1500),r(r(o,0,1500),90,1500)];break;case"drive":{let h=r(o,0,1200),p=r(h,90,800),x=r(p,0,1e3),I=r(x,-90,1e3);a=[o,h,p,x,I];break}case"highway":a=[o,r(o,0,3e4)];break;case"tunnel":a=[o,r(o,0,3e3)],c=[[1200,1800]];break;case"loop":{let h=r(o,0,100),p=r(h,90,100),x=r(p,180,100);a=[o,h,p,x,o],d=true;break}}return{id:`preset:${e}`,name:i.name,points:a,speed:i.speed,loop:d,gaps:c}}function ba(e,t,n){return{id:"line",name:t.label?`To ${t.label}`:"Straight line",points:[{latitude:e.latitude,longitude:e.longitude},{latitude:t.latitude,longitude:t.longitude}],speed:n}}function Z(e){return e&&typeof e=="object"?e:{}}function Ke(e,...t){for(let n of t){let i=e[n];if(typeof i=="boolean")return i;if(i==="true"||i==="on")return true;if(i==="false"||i==="off")return false}}function J(e,...t){for(let n of t){let i=e[n];if(i==null||i==="")continue;let o=Number(i);if(Number.isFinite(o))return o}}function $(){return{...E(),builtInPlaces:dt,presets:Oe}}function va(e){let t=e.trim().toLowerCase(),n=[...E().places,...dt];return n.find(i=>i.label?.toLowerCase()===t)??n.find(i=>i.label?.toLowerCase().includes(t))??null}function hi(e){let t=typeof e.label=="string"?e.label:void 0,n=J(e,"latitude","lat"),i=J(e,"longitude","lon","lng");if(n!==void 0&&i!==void 0){let o={latitude:n,longitude:i};if(!Ie(o))throw new Error("latitude must be within \xB190 and longitude within \xB1180.");return{...o,label:t}}for(let o of["place","to","query","coordinate","at"]){let r=e[o];if(Ie(r))return{...r,label:r.label??t};if(typeof r=="string"&&r.trim()){let a=vt(r);if(a)return{...a,label:t};let c=va(r);if(c)return c;throw new Error(`No place called "${r}". Give latitude and longitude, or one of: ${wa()}.`)}}return null}function wa(){return[...E().places,...dt].map(e=>e.label).filter(Boolean).join(", ")}function ka(e){let t=J(e,"speed","metersPerSecond"),n=J(e,"heading","bearing")??0;if(Array.isArray(e.points))return{points:e.points,speed:t??1.4,loop:Ke(e,"loop")??false,name:typeof e.name=="string"?e.name:"Custom route",gaps:Array.isArray(e.gaps)?e.gaps:void 0};let i=typeof e.route=="string"?e.route:typeof e.routeId=="string"?e.routeId:typeof e.preset=="string"?e.preset:void 0;if(i){let r=E().routes.find(d=>d.id===i||d.name?.toLowerCase()===i.toLowerCase());if(r)return t?{...r,speed:t}:r;let a=Oe.find(d=>d.id===i||d.name.toLowerCase()===i.toLowerCase());if(a){let d=gi(a.id,He(),n);return t?{...d,speed:t}:d}let c=[...E().routes.map(d=>d.id??d.name),...Oe.map(d=>d.id)];throw new Error(`No route "${i}". Use one of: ${c.join(", ")}; or pass points.`)}let o=hi(e);if(o)return ba(He(),o,t??1.4);throw new Error("startRoute needs `points` (two or more {latitude, longitude}), `route` (a preset or app route id), or `to` (a place).")}var Vt=ya({version:1,getSnapshot(){return $()},subscribe(e){return Ue(e)},actions:{getState(){return $()},setLocation(e){let t=hi(Z(e));if(!t)throw new Error('setLocation needs `latitude` and `longitude`, `query` ("lat, lon" or a map link), or `place` (a place name).');return ct(t),$()},startRoute(e){return Cn(ka(Z(e))),$()},stopRoute(){return $n(),$()},setConditions(e){let t=Z(e),n=(typeof t.conditions=="string"?t.conditions:typeof t.preset=="string"?t.preset:"").trim().toLowerCase().replace(/[\s_]+/g,"-"),i={good:"good",weak:"weak","no-signal":"no-signal",nosignal:"no-signal",off:"off","services-off":"off","location-off":"off"}[n];if(!i)throw new Error("setConditions needs `conditions`: good, weak, no-signal or off.");return Pn(i),$()},pauseRoute(){return Pt(),$()},resumeRoute(){return $t(),$()},seekRoute(e){let t=Z(e),n=J(t,"meters","along"),i=J(t,"fraction","progress"),o=E().progress?.length??0;if(n===void 0&&i===void 0)throw new Error("seekRoute needs `meters` or `fraction` (0 to 1).");return In(n??(i??0)*o),$()},setSpeed(e){let t=J(Z(e),"speed","metersPerSecond");if(t===void 0)throw new Error("setSpeed needs `speed` in meters per second.");return An(t),$()},tune(e){let t=Z(e);return Tn({accuracy:J(t,"accuracy"),jitter:J(t,"jitter","drift"),altitude:t.altitude===null?null:J(t,"altitude"),heading:t.heading===null?null:J(t,"heading"),interval:J(t,"interval","intervalMs")}),$()},setSignal(e){let t=Ke(Z(e),"on","signal","enabled");if(t===void 0)throw new Error("setSignal needs `on`: true or false.");return Sn(t),$()},setServices(e){let t=Ke(Z(e),"on","services","enabled");if(t===void 0)throw new Error("setServices needs `on`: true or false.");return Ln(t),$()},enterRegion(e){let t=Z(e),n=typeof t.identifier=="string"?t.identifier:typeof t.region=="string"?t.region:void 0;if(!n)throw new Error("enterRegion needs `identifier` (a monitored geofence region).");return Mt(n,"inside",typeof t.task=="string"?t.task:void 0),$()},exitRegion(e){let t=Z(e),n=typeof t.identifier=="string"?t.identifier:typeof t.region=="string"?t.region:void 0;if(!n)throw new Error("exitRegion needs `identifier` (a monitored geofence region).");return Mt(n,"outside",typeof t.task=="string"?t.task:void 0),$()},useRealLocation(){return Mn(),$()},reset(){return Et(),$()},updateSettings(e){let t=Z(e);return co({persist:Ke(t,"persist"),showChip:Ke(t,"showChip")}),$()},clearLog(){return po(),$()}}});import{useEffect as xa,useState as De}from"react";import{Check as Ca,ChevronLeft as Ia,ChevronRight as Aa,NightButton as mi,NightCard as R,NightFootnote as ee,NightRows as te,NightSectionLabel as Y,NightSegmented as qt,NightSwitch as Ta,Pause as Sa,Play as La,RefreshCw as Pa,copyToClipboard as $a,monoFont as Ma,night as m,realNow as Gt,useSafeAreaInsets as Ea,useToolScreenHeader as Ra}from"@buoy-gg/shared-ui/web";import{night as ne}from"@buoy-gg/shared-ui/web";import{jsx as Q,jsxs as pt}from"react/jsx-runtime";var yi="#F87171",Je=1.8,Na=6e4,Oa=400;function Da({snapshot:e,onPinPlace:t,onCrossRegion:n}){let i=e.position,o=e.override.mode==="route"?e.override.route:null,r=i??e.places[0]??Ba(e.tasks)??null;if(!r)return null;let a=b=>!i||V(i,b)<=Na,c=e.places.filter(a),d=e.tasks.filter(b=>b.kind==="geofencing").flatMap(b=>b.regions.filter(a).map(u=>({task:b,region:u}))),h=e.places.length-c.length,p=Math.cos(r.latitude*Math.PI/180),x=b=>({x:(b.longitude-r.longitude)*111320*p,y:(b.latitude-r.latitude)*110540}),I=[];i&&I.push({...x(i),r:60});for(let b of o?.points??[])I.push({...x(b),r:0});for(let b of c)I.push({...x(b),r:60});for(let b of d)I.push({...x(b.region),r:b.region.radius});let A=1/0,F=-1/0,_=1/0,ge=-1/0;for(let b of I)A=Math.min(A,b.x-b.r),F=Math.max(F,b.x+b.r),_=Math.min(_,b.y-b.r),ge=Math.max(ge,b.y+b.r);let he=(A+F)/2,ht=(_+ge)/2,Qe=Math.max(Oa,(ge-_)*1.35,(F-A)*1.2/Je),Be=Qe*Je,me=b=>{let u=x(b);return{x:.5+(u.x-he)/Be,y:.5-(u.y-ht)/Qe}},Xe=Fa(Be),Ce=e.override.mode==="fixed"?e.override.place.label:void 0;return Q(v,{children:pt(v,{style:M.map,testID:"location-map",accessibilityLabel:"Map of places, geofences and the simulated position",children:[bi.map(b=>Q(v,{style:[M.gridV,{left:B(b)}]},`v${b}`)),bi.map(b=>Q(v,{style:[M.gridH,{top:B(b)}]},`h${b}`)),d.map(({task:b,region:u})=>{let s=me(u),f=2*u.radius/Be,w=f*Je,C=u.state==="inside";return Q(se,{testID:`location-map-region-${vi(u.identifier)}`,accessibilityRole:"button",accessibilityLabel:`${C?"Leave":"Enter"} ${u.label??u.identifier}`,activeOpacity:.6,onPress:()=>n(b,u),style:[M.fence,C?M.fenceInside:null,{left:B(s.x-f/2),top:B(s.y-w/2),width:B(f),height:B(w)}]},`${b.name}:${u.identifier}`)}),o?ja(o.points.map(me)).map((b,u)=>Q(v,{pointerEvents:"none",style:[M.segment,{left:B(b.midX-b.length/2),top:B(b.midY),width:B(b.length),transform:[{rotate:`${b.angle}rad`}]}]},`seg${u}`)):null,c.map((b,u)=>{let s=me(b),f=!!Ce&&Ce===b.label;return pt(se,{testID:`location-map-place-${vi(b.label??String(u))}`,accessibilityRole:"button",accessibilityLabel:`Pin ${b.label??"this place"}`,activeOpacity:.6,onPress:()=>t(b),style:[M.placeHit,{left:B(s.x),top:B(s.y)}],children:[Q(v,{style:[M.placeDot,f?M.placeDotSelected:null]}),b.label?Q(T,{style:M.placeLabel,numberOfLines:1,children:b.label}):null]},`${b.label??u}`)}),i?pt(v,{pointerEvents:"none",style:[M.pinWrap,{left:B(me(i).x),top:B(me(i).y)}],children:[Q(v,{style:M.pinHalo}),Q(v,{style:[M.pin,e.current.reason==="gap"?M.pinHollow:null]})]}):null,pt(v,{style:M.scale,pointerEvents:"none",children:[Q(v,{style:[M.scaleBar,{width:B(Xe.fraction)}]}),Q(T,{style:M.scaleLabel,children:Xe.label})]}),h>0?Q(T,{style:M.offMap,pointerEvents:"none",children:`${h} more ${h===1?"place":"places"} off the map`}):null]})})}var bi=[.2,.4,.6,.8];function B(e){return`${e*100}%`}function Ba(e){for(let t of e)if(t.regions[0])return t.regions[0];return null}function ja(e){let t=[];for(let n=1;n<e.length;n++){let i=e[n-1],o=e[n],r=o.x-i.x,a=(o.y-i.y)/Je;t.push({midX:(i.x+o.x)/2,midY:(i.y+o.y)/2,length:Math.sqrt(r*r+a*a),angle:Math.atan2(a,r)})}return t}function Fa(e){let t=e/4,n=Ne()?1609.344:1e3,i=Ne()?[.01,.02,.05,.1,.2,.5,1,2,5,10,20,50,100].map(r=>r*n):[10,20,50,100,200,500,1e3,2e3,5e3,1e4,2e4,5e4,1e5],o=i[0];for(let r of i)r<=t&&(o=r);return{fraction:o/e,label:K(o)}}function vi(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}var M=le.create({map:{width:"100%",aspectRatio:Je,borderRadius:ne.radius.card,borderWidth:1,borderColor:ne.color.border,backgroundColor:ne.color.surface,overflow:"hidden"},gridV:{position:"absolute",top:0,bottom:0,width:le.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},gridH:{position:"absolute",left:0,right:0,height:le.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},fence:{position:"absolute",zIndex:1,borderRadius:9999,borderWidth:1,borderColor:"rgba(255, 255, 255, 0.22)",backgroundColor:"rgba(255, 255, 255, 0.04)",minWidth:10,minHeight:10},fenceInside:{borderColor:ne.color.accentBorderStrong,backgroundColor:ne.color.accentSoft},segment:{position:"absolute",height:3,marginTop:-1.5,borderRadius:1.5,backgroundColor:"rgba(248, 113, 113, 0.45)"},placeHit:{position:"absolute",flexDirection:"row",alignItems:"center",gap:4,height:24,marginTop:-12,marginLeft:-12,paddingLeft:8,paddingRight:4},placeDot:{width:8,height:8,borderRadius:4,backgroundColor:ne.color.textSecondary},placeDotSelected:{backgroundColor:ne.color.text},placeLabel:{color:ne.color.textSecondary,fontSize:10,fontWeight:"500",maxWidth:110},pinWrap:{position:"absolute",width:28,height:28,marginLeft:-14,marginTop:-14,alignItems:"center",justifyContent:"center"},pinHalo:{position:"absolute",width:28,height:28,borderRadius:14,backgroundColor:"rgba(248, 113, 113, 0.22)"},pin:{width:14,height:14,borderRadius:7,backgroundColor:yi,borderWidth:2,borderColor:"#FFFFFF"},pinHollow:{backgroundColor:"transparent",borderColor:yi},scale:{position:"absolute",left:10,right:10,bottom:8,gap:3},scaleBar:{height:2,borderRadius:1,backgroundColor:ne.color.textTertiary},scaleLabel:{color:ne.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},offMap:{position:"absolute",right:10,bottom:8,color:ne.color.textTertiary,fontSize:10}});import{Fragment as Ye,jsx as l,jsxs as k}from"react/jsx-runtime";var wi={places:"Other Location",routes:"Route",speed:"Speed",accuracy:"Accuracy & Drift",activity:"Activity",options:"Options"},_a="#F87171",ki=[{key:"1.4",label:"Walking"},{key:"3.3",label:"Running"},{key:"5.5",label:"Cycling"},{key:"13.4",label:"City Traffic"},{key:"30",label:"Highway"},{key:"250",label:"Airplane"}],xi=[{key:"good",label:"Good"},{key:"weak",label:"Weak"},{key:"no-signal",label:"No Signal"},{key:"off",label:"Off"}],za={good:"Precise fixes, like outdoors with a clear sky.",weak:"Fixes are \xB165 m and wander by up to 50 m, like indoors or between tall buildings.","no-signal":"Watches get no updates and location requests fail.",off:"The app is told location services are turned off.",custom:"Custom accuracy and drift."},Ci=[{key:"5",label:"5 m"},{key:"20",label:"20 m"},{key:"65",label:"65 m"},{key:"1000",label:"1 km"}],Ii=[{key:"0",label:"Off"},{key:"10",label:"10 m"},{key:"50",label:"50 m"},{key:"200",label:"200 m"}],Wa=4;function Kt(e){let[t,n]=De(()=>Gt());return xa(()=>{if(!e)return;let i=setInterval(()=>n(Gt()),1e3);return()=>clearInterval(i)},[e]),t}function Ai({snapshot:e,onAction:t}){let n=Ea({minBottom:16}),[i,o]=De(null),[r,a]=De("main"),c=()=>a("main"),d=Ra(r==="main"?null:{title:wi[r],subtitle:"",onBack:c,searchable:false},[r]),h=(A,F)=>{o(null),t(A,F).catch(_=>{o(_ instanceof Error?_.message:String(_))})};if(!e)return l(v,{style:y.waiting,testID:"location-waiting",children:l(ee,{centered:true,children:"Waiting for the app\u2026"})});let p=i?l(ee,{tone:"danger",centered:true,children:l(T,{testID:"location-error",children:i})}):null,x=(A,F)=>{h(A,F),c()},I;switch(r){case"places":I=l(Ka,{snapshot:e,pick:x});break;case"routes":I=l(Xa,{snapshot:e,pick:x});break;case"speed":I=l(el,{snapshot:e,pick:x});break;case"accuracy":I=l(al,{snapshot:e,run:h});break;case"activity":I=l(sl,{snapshot:e,run:h});break;case"options":I=l(ul,{snapshot:e,run:h});break;default:I=k(Ye,{children:[l(Ua,{snapshot:e,run:h}),p,l(Va,{snapshot:e,run:h}),l(qa,{snapshot:e,run:h,open:a}),l(Ya,{snapshot:e,open:a}),l(nl,{snapshot:e,run:h}),l(rl,{snapshot:e,run:h,open:a}),l(ll,{snapshot:e,open:a})]})}return k(zn,{style:y.fill,contentContainerStyle:[y.content,{paddingBottom:n.bottom}],testID:"location-scroll",keyboardShouldPersistTaps:"handled",children:[r!=="main"&&!d?l(dl,{title:wi[r],onBack:c}):null,r!=="main"?p:null,I]},r)}function Ua({snapshot:e,run:t}){let n=e.override,i=n.mode==="route"?n.route:null,o=e.progress;Kt(!!i&&n.playing);let r=ia(e),a=e.current.fix,c=o&&o.length>0?Math.min(1,o.along/o.length):0,[d,h]=De(false);return k(R,{children:[k(v,{style:y.status,children:[l(T,{style:[y.statusTitle,r==="simulated"?y.titleSimulated:r==="broken"?y.titleBroken:null],testID:"location-hero-title",numberOfLines:1,adjustsFontSizeToFit:true,children:si(e)}),l(T,{style:y.statusLine,testID:"location-hero-status",children:oa(e)}),a&&e.simulating?l(se,{testID:"location-copy-coordinates",accessibilityRole:"button",accessibilityLabel:"Copy coordinates",activeOpacity:.6,onPress:()=>{$a(`${a.latitude}, ${a.longitude}`).then(p=>{p&&(h(true),setTimeout(()=>h(false),1500))})},children:l(T,{style:y.coordinates,children:d?"Copied":Fe(a,5)})}):null,i&&o?k(v,{style:y.progressTrack,testID:"location-route-progress",children:[l(v,{style:[y.progressFill,{width:`${c*100}%`}]}),(i.gaps??[]).map(([p,x],I)=>l(v,{style:[y.progressGap,{left:`${p/o.length*100}%`,width:`${(x-p)/o.length*100}%`}]},I))]}):null,e.active?k(v,{style:y.statusButtons,children:[i&&o?l(Ha,{testID:n.playing?"location-route-pause":"location-route-resume",label:n.playing?"Pause":o.finished?"Play again":"Resume",onPress:()=>t(n.playing?"pauseRoute":"resumeRoute"),children:n.playing?l(Sa,{size:18,color:m.color.onAccent}):o.finished?l(Pa,{size:18,color:m.color.onAccent}):l(La,{size:18,color:m.color.onAccent})}):null,l(v,{style:y.flex,children:l(mi,{label:"Use Real Location",size:"md",testID:"location-reset",onPress:()=>t("reset")})})]}):null]}),e.permission?k(v,{style:y.permission,testID:"location-permission",children:[k(v,{style:y.rowBetween,children:[l(T,{style:y.rowTitle,children:"Permission"}),l(T,{style:[y.rowValue,e.permission.status!=="granted"?y.valueWarning:null],testID:"location-permission-value",children:ra(e.permission)})]}),e.permission.status!=="granted"?l(T,{style:y.detail,children:"The app's location requests fail until it's allowed. Change it in Settings or the Permissions tool."}):null]}):null]})}function Ha({children:e,label:t,onPress:n,testID:i}){return l(se,{testID:i,accessibilityRole:"button",accessibilityLabel:t,activeOpacity:.7,onPress:n,style:y.round,children:e})}function Va({snapshot:e,run:t}){return!!e.position||e.places.length>0||e.tasks.some(n=>n.regions.length>0)?k(v,{children:[l(Da,{snapshot:e,onPinPlace:n=>t("setLocation",{latitude:n.latitude,longitude:n.longitude,label:n.label}),onCrossRegion:(n,i)=>t(i.state==="inside"?"exitRegion":"enterRegion",{identifier:i.identifier,task:n.name})}),l(ee,{children:"Map views in the app still show the device's own blue dot. Move the simulator's location for those."})]}):null}function qa({snapshot:e,run:t,open:n}){let i=e.places.length>0?e.places:e.builtInPlaces.slice(0,Wa),o=e.override.mode==="fixed"?e.override.place:null,r=e.position,a=!!o&&!i.some(c=>ft(c,o));return k(v,{children:[l(Y,{children:"Location"}),l(R,{children:k(te,{children:[i.map((c,d)=>l(j,{title:c.label??Fe(c,4),value:r&&!(o&&ft(c,o))?Ga(r,c):void 0,checked:!!o&&ft(c,o),testID:`location-place-${gt(c.label??String(d))}`,onPress:()=>t("setLocation",{latitude:c.latitude,longitude:c.longitude,label:c.label})},`${c.label??d}`)),l(j,{title:"Other Location\u2026",value:a?o.label||Fe(o,3):void 0,chevron:true,testID:"location-other",onPress:()=>n("places")},"other")]})})]})}function Ga(e,t){let n=V(e,t);return n<30?"Here":K(n)}function ft(e,t){return e.label&&t.label?e.label===t.label:V(e,t)<1}function Ka({snapshot:e,pick:t}){let[n,i]=De(""),o=vt(n),r=e.override.mode==="fixed"?e.override.place:null,a=()=>{o&&(t("setLocation",{query:n}),i(""))};return k(Ye,{children:[k(v,{children:[l(Y,{children:"Coordinates"}),l(R,{children:k(v,{style:y.editor,children:[k(v,{style:y.inputRow,children:[l(_n,{value:n,onChangeText:i,placeholder:"Coordinates or a Maps link",placeholderTextColor:m.color.placeholder,autoCapitalize:"none",autoCorrect:false,style:y.input,testID:"location-coordinate-input",accessibilityLabel:"Coordinates or a Maps link",returnKeyType:"done",onSubmitEditing:a}),l(mi,{label:"Pin",size:"md",variant:"primary",disabled:!o,testID:"location-coordinate-set",onPress:a})]}),n.length>0?l(T,{style:o?y.detail:y.warning,testID:"location-coordinate-preview",children:o?Ja(o):"Type a latitude and longitude, like 40.7580, -73.9855, or paste a Google or Apple Maps link."}):null]})})]}),k(v,{children:[l(Y,{children:"Places"}),l(R,{children:l(te,{children:e.builtInPlaces.map((c,d)=>l(j,{title:c.label??Fe(c,4),detail:c.label==="Null Island"?"0, 0: catches code that treats 0 as no location":void 0,checked:!!r&&ft(c,r),testID:`location-place-${gt(c.label??String(d))}`,onPress:()=>t("setLocation",{latitude:c.latitude,longitude:c.longitude,label:c.label})},`${c.label??d}`))})}),e.places.length===0?l(ee,{children:"Add your own places, such as your stores, with registerLocationPlaces()."}):null]})]})}function Ja(e){let t=`${Math.abs(e.latitude).toFixed(4)}\xB0 ${e.latitude>=0?"N":"S"}`,n=`${Math.abs(e.longitude).toFixed(4)}\xB0 ${e.longitude>=0?"E":"W"}`;return`${t}, ${n}`}function Ya({snapshot:e,open:t}){let n=e.override.mode==="route"?e.override.route:null;return k(v,{children:[l(Y,{children:"Movement"}),l(R,{children:k(te,{children:[l(j,{title:"Route",value:n?.name??"None",chevron:true,testID:"location-route",onPress:()=>t("routes")},"route"),n?l(j,{title:"Speed",value:Qa(n.speed),chevron:true,testID:"location-speed",onPress:()=>t("speed")},"speed"):null]})})]})}function Qa(e){let t=ki.find(n=>Math.abs(Number(n.key)-e)<.05);return t?t.label:Ut(e)}function Xa({snapshot:e,pick:t}){let n=e.override.mode==="route"?e.override.route:null,i=n?.id;return k(Ye,{children:[n?l(v,{children:l(R,{children:l(te,{children:l(j,{title:"Stop Here",detail:"End the route and stay where it got to",testID:"location-route-stop",onPress:()=>t("stopRoute")},"stop")})})}):null,e.routes.length>0?k(v,{children:[l(Y,{children:"This App"}),l(R,{children:l(te,{children:e.routes.map((o,r)=>l(j,{title:o.name??o.id??`Route ${r+1}`,detail:`${K(bt(o.points))} at ${Ut(o.speed)}${o.loop?", on repeat":""}`,checked:!!i&&i===o.id,testID:`location-route-${gt(o.id??o.name??String(r))}`,onPress:()=>t("startRoute",{route:o.id??o.name})},o.id??`${o.name}-${r}`))})})]}):null,k(v,{children:[l(Y,{children:"From Here"}),l(R,{children:l(te,{children:e.presets.map(o=>l(j,{title:o.name,detail:Za(o.id)??o.description,checked:i===`preset:${o.id}`,testID:`location-preset-${o.id}`,onPress:()=>t("startRoute",{route:o.id})},o.id))})}),l(ee,{children:"These start where the app is now."})]})]})}function Za(e){let t=K;switch(e){case"walk":return`${t(1e3)} north at walking pace`;case"run":return`${t(3e3)} north, then east, at running pace`;case"drive":return`${t(4e3)} of city streets with turns`;case"highway":return`${t(3e4)} north at highway speed`;case"tunnel":return`${t(3e3)} drive with no signal for ${t(600)} in the middle`;case"loop":return`A ${t(400)} block, walked on repeat`;default:return null}}function el({snapshot:e,pick:t}){let n=e.override.route?.speed??0;return k(v,{children:[l(R,{children:l(te,{children:ki.map(i=>l(j,{title:i.label,value:Ut(Number(i.key)),checked:Math.abs(Number(i.key)-n)<.05,testID:`location-speed-${i.key}`,onPress:()=>t("setSpeed",{speed:Number(i.key)})},i.key))})}),l(ee,{children:"Heading and speed follow the route."})]})}var tl=1e4;function nl({snapshot:e,run:t}){let n=e.tasks.filter(d=>d.kind==="geofencing"&&d.regions.length>0),[i,o]=De(null),r=Kt(!!i);if(n.length===0)return null;let a=n.length>1,c=n.map(d=>d.name).join(", ");return k(v,{children:[l(Y,{children:"Geofences"}),l(R,{children:l(te,{children:n.flatMap(d=>d.regions.map(h=>{let p=`${d.name}:${h.identifier}`,x=h.state==="inside",I=i?.key===p&&r-i.at<tl?i:null,A=[il(h)];return a&&A.push(d.name),l(j,{title:h.label??h.identifier,detail:A.join(" \xB7 "),note:I?ol(e,d,I.at):void 0,action:x?"Leave":"Enter",testID:`location-region-${gt(h.identifier)}`,onPress:()=>{o({key:p,at:Gt()}),t(x?"exitRegion":"enterRegion",{identifier:h.identifier,task:d.name})}},p)}))})}),k(ee,{children:["Tap a region to cross its edge. ",a?"The app's tasks":`The app's ${c} task`," runs as it would from the OS."]})]})}function il(e){return e.state==="inside"?"Inside":e.distance==null?`${K(e.radius)} radius`:`${K(Math.max(0,e.distance-e.radius))} away`}function ol(e,t,n){let i=e.log.filter(r=>r.at>=n-50&&(r.detail??"").startsWith(t.name)),o=i.find(r=>r.kind==="error");return o?{text:`Task failed: ${o.detail?.slice(t.name.length+3)??""}`,tone:"bad"}:i.find(r=>r.kind==="task")?{text:"Task ran",tone:"ok"}:i.find(r=>r.kind==="enter"||r.kind==="exit")?{text:"Running the app's task\u2026",tone:"wait"}:{text:"Already on this side",tone:"wait"}}function rl({snapshot:e,run:t,open:n}){let i=e.override,o=Vi(i),r=e.simulating?xi:xi.filter(a=>a.key!=="weak");return k(v,{children:[l(Y,{children:"Conditions"}),k(R,{children:[l(v,{style:y.segmentWrap,children:l(qt,{tabs:r,activeKey:o??"",size:"sm",testIDPrefix:"location-conditions",onChange:a=>t("setConditions",{conditions:a})})}),e.simulating&&i.services&&i.signal?l(v,{style:y.separatorTop,children:l(j,{title:"Accuracy & Drift",value:`${li(i.accuracy)}${i.jitter>0?` \xB7 drifts ${K(i.jitter)}`:""}`,chevron:true,testID:"location-accuracy",onPress:()=>n("accuracy")})}):null]}),l(ee,{children:za[o??"custom"]})]})}function al({snapshot:e,run:t}){let n=e.override;return k(Ye,{children:[k(v,{children:[l(Y,{children:"Accuracy"}),l(R,{children:l(v,{style:y.segmentWrap,children:l(qt,{tabs:Ci,activeKey:Si(Ci,n.accuracy)??"",size:"sm",testIDPrefix:"location-accuracy",onChange:i=>t("tune",{accuracy:Number(i)})})})}),l(ee,{children:"The accuracy radius the app is given with each fix."})]}),k(v,{children:[l(Y,{children:"Drift"}),l(R,{children:l(v,{style:y.segmentWrap,children:l(qt,{tabs:Ii,activeKey:Si(Ii,n.jitter)??"0",size:"sm",testIDPrefix:"location-drift",onChange:i=>t("tune",{jitter:Number(i)})})})}),l(ee,{children:"Moves each fix by up to this much at random, the way a real fix wanders."})]})]})}function ll({snapshot:e,open:t}){let n=e.log.length;return l(v,{children:l(R,{children:k(te,{children:[l(j,{title:"Activity",value:n===0?"None":`${n} ${n===1?"event":"events"}`,chevron:true,testID:"location-activity",onPress:()=>t("activity")},"activity"),l(j,{title:"Options",chevron:true,testID:"location-options",onPress:()=>t("options")},"options")]})})})}function sl({snapshot:e,run:t}){let n=Kt(true),i=e.log.slice().reverse(),o=e.watches.filter(d=>d.kind==="position").length,r=e.tasks.filter(d=>d.kind==="locationUpdates").length,a=e.tasks.filter(d=>d.kind==="geofencing").reduce((d,h)=>d+h.regions.length,0),c=[o?`${o} location ${o===1?"watch":"watches"}`:null,a?`${a} ${a===1?"geofence":"geofences"}`:null,r?"background updates":null].filter(Boolean);return k(Ye,{children:[k(v,{children:[l(Y,{children:"The App Is Using"}),l(R,{children:k(v,{style:y.editor,children:[l(T,{style:y.rowTitle,testID:"location-activity-summary",children:c.length?c.join(", "):"Nothing right now"}),l(T,{style:y.detail,children:e.libraries.length?`Through ${e.libraries.join(" and ")}.`:"No supported location library was found in this app."})]})})]}),k(v,{children:[l(Y,{children:"Recent"}),l(R,{children:k(te,{children:[i.length===0?l(v,{style:y.editor,children:l(T,{style:y.detail,children:"Location requests, watches and geofence crossings show up here."})},"empty"):i.map(d=>k(v,{style:y.logRow,testID:"location-log-entry",children:[l(v,{style:[y.logDot,cl(d.kind)]}),k(v,{style:y.flex,children:[l(T,{style:y.logText,children:d.text}),d.detail?l(T,{style:y.logDetail,numberOfLines:2,children:d.detail}):null]}),l(T,{style:y.logWhen,children:na(d.at,n)})]},d.id)),i.length>0?l(j,{title:"Clear",tint:true,testID:"location-clear-log",onPress:()=>t("clearLog")},"clear"):null]})})]})]})}function cl(e){return e==="enter"?y.dotEnter:e==="exit"?y.dotExit:e==="error"?y.dotError:e==="task"?y.dotTask:null}function ul({snapshot:e,run:t}){return k(v,{children:[l(R,{children:k(te,{children:[l(Ti,{title:"Keep Across Reloads",value:e.settings.persist,testID:"location-setting-persist",onValueChange:n=>t("updateSettings",{persist:n})},"persist"),l(Ti,{title:"Show Floating Status",value:e.settings.showChip,testID:"location-setting-showChip",onValueChange:n=>t("updateSettings",{showChip:n})},"chip")]})}),l(ee,{children:"The floating status stays on screen while the app is somewhere else, so a simulated location is never left on by accident."})]})}function dl({title:e,onBack:t}){return k(se,{testID:"location-back",accessibilityRole:"button",accessibilityLabel:"Back",activeOpacity:.6,onPress:t,style:y.backRow,children:[l(Ia,{size:18,color:m.color.accent}),l(T,{style:y.backLabel,children:"Location"}),l(T,{style:y.backTitle,numberOfLines:1,children:e})]})}function j({title:e,detail:t,note:n,value:i,action:o,checked:r,chevron:a,tint:c,onPress:d,testID:h}){return k(se,{testID:h,accessibilityRole:"button",accessibilityLabel:o?`${o} ${e}`:e,accessibilityState:r?{selected:true}:void 0,activeOpacity:.6,onPress:d,style:y.row,children:[k(v,{style:y.rowText,children:[l(T,{style:[y.rowTitle,c?y.titleTint:null],numberOfLines:1,children:e}),t?l(T,{style:y.detail,children:t}):null,n?l(T,{style:[y.note,n.tone==="ok"?y.noteOk:n.tone==="bad"?y.noteBad:null],testID:`${h}-result`,children:n.text}):null]}),i?l(T,{style:y.rowValue,numberOfLines:1,children:i}):null,o?l(T,{style:y.rowAction,children:o}):null,r?l(Ca,{size:18,color:m.color.accent}):null,a?l(Aa,{size:16,color:m.color.textTertiary}):null]})}function Ti({title:e,value:t,onValueChange:n,testID:i}){return k(v,{style:y.row,children:[l(v,{style:y.rowText,children:l(T,{style:y.rowTitle,children:e})}),l(Ta,{value:t,testID:i,accessibilityLabel:e,onValueChange:n})]})}function Si(e,t){let n=null,i=1/0;for(let o of e){let r=Math.abs(Number(o.key)-t);r<i&&(n=o.key,i=r)}return n!==null&&i<=Math.max(.05,Number(n)*.05)?n:null}function gt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}var y=le.create({fill:{flex:1},flex:{flex:1},content:{paddingHorizontal:m.gutter,paddingTop:8,gap:m.groupGap},waiting:{flex:1,alignItems:"center",justifyContent:"center",padding:24},status:{padding:m.cardPad+2,gap:6},statusTitle:{color:m.color.text,fontSize:28,fontWeight:"600"},titleSimulated:{color:m.color.accent},titleBroken:{color:_a},statusLine:{color:m.color.textSecondary,fontSize:m.font.row,fontVariant:["tabular-nums"]},coordinates:{color:m.color.textTertiary,fontSize:m.font.caption,fontFamily:Ma},statusButtons:{flexDirection:"row",alignItems:"center",gap:10,marginTop:10},round:{width:44,height:44,borderRadius:22,alignItems:"center",justifyContent:"center",backgroundColor:m.color.accent},progressTrack:{height:6,borderRadius:3,marginTop:8,backgroundColor:m.color.fillSecondary,overflow:"hidden"},progressFill:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:m.color.accent},progressGap:{position:"absolute",top:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.28)"},permission:{borderTopWidth:le.hairlineWidth,borderTopColor:m.color.separator,paddingHorizontal:m.rowPadH,paddingVertical:12,gap:4},rowBetween:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12},valueWarning:{color:m.color.warning},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:48,paddingHorizontal:m.rowPadH,paddingVertical:10},rowText:{flex:1,gap:2},rowTitle:{color:m.color.text,fontSize:m.font.row},titleTint:{color:m.color.accent},rowValue:{color:m.color.textSecondary,fontSize:m.font.row,maxWidth:"50%"},rowAction:{color:m.color.accent,fontSize:m.font.row,fontWeight:"500"},detail:{color:m.color.textTertiary,fontSize:m.font.caption},note:{color:m.color.textSecondary,fontSize:m.font.caption,marginTop:2},noteOk:{color:m.color.accent},noteBad:{color:m.color.danger},warning:{color:m.color.warning,fontSize:m.font.caption},separatorTop:{borderTopWidth:le.hairlineWidth,borderTopColor:m.color.separator},segmentWrap:{flexDirection:"row",padding:10},editor:{paddingHorizontal:m.rowPadH,paddingVertical:14,gap:8},inputRow:{flexDirection:"row",alignItems:"center",gap:8},input:{flex:1,color:m.color.text,fontSize:m.font.body,backgroundColor:m.color.bg,borderRadius:m.radius.input,borderWidth:1,borderColor:m.color.border,paddingHorizontal:12,paddingVertical:9},backRow:{flexDirection:"row",alignItems:"center",gap:4,paddingVertical:4},backLabel:{color:m.color.accent,fontSize:m.font.row},backTitle:{flex:1,color:m.color.text,fontSize:m.font.row,fontWeight:"600",textAlign:"center",marginRight:70},logRow:{flexDirection:"row",alignItems:"flex-start",gap:10,paddingHorizontal:m.rowPadH,paddingVertical:10},logDot:{width:8,height:8,borderRadius:4,marginTop:6,backgroundColor:m.color.textTertiary},dotEnter:{backgroundColor:m.color.accent},dotExit:{backgroundColor:m.color.warning},dotError:{backgroundColor:m.color.danger},dotTask:{backgroundColor:m.color.info},logText:{color:m.color.text,fontSize:m.font.body},logDetail:{color:m.color.textTertiary,fontSize:m.font.caption,marginTop:2},logWhen:{color:m.color.textTertiary,fontSize:m.font.caption,fontVariant:["tabular-nums"],marginTop:1}});import{jsx as Li}from"react/jsx-runtime";var pl=Vt.actions;async function fl(e,t){let n=pl[e];if(!n)throw new Error(`Unknown location action: ${e}`);return n(t)}var Jt=()=>Vt.getSnapshot(),gl=2e3;function Pi(){let[e,t]=ha(Jt);return ga(()=>{zt(),Rt(),t(Jt()),pi(true),rt();let n=setInterval(rt,gl),i=Ue(()=>t(Jt()));return()=>{clearInterval(n),i(),pi(false)}},[]),Li(ma,{featureName:"Location",children:Li(Ai,{snapshot:e,onAction:fl})})}import{jsx as hl}from"react/jsx-runtime";var $i=fa({id:"location",name:"LOCATION",description:"Pin the app anywhere, play routes, trigger geofences",slot:"both",color:da,icon:({size:e,color:t})=>hl(ua,{size:e,color:t}),component:Pi,modal:{subtitle:"simulate where the app is"}}),ml=pa($i);import{LocationToolIcon as yl,LOCATION_TOOL_ICON_COLOR as bl}from"@buoy-gg/shared-ui/web";var vl=typeof navigator<"u"&&navigator.product==="ReactNative",wl=(()=>{try{return globalThis.Capacitor?.isNativePlatform?.()===true}catch{return false}})();(vl||wl)&&(ca(),typeof Xt<"u"&&Xt&&(zt(),Rt()));export{dt as BUILT_IN_PLACES,ut as LOCATION_CHIP_ID,bl as LOCATION_TOOL_ICON_COLOR,Pi as LocationBody,fi as LocationChip,yl as LocationToolIcon,Ai as LocationToolView,Oe as ROUTE_PRESETS,Ze as bearingDegrees,Rt as bootLocation,gi as buildPresetRoute,ml as createLocationTool,je as destination,V as distanceMeters,E as getLocationSnapshot,zt as installLocationAdapters,P as isLocationActive,Vt as locationSyncAdapter,$i as locationToolPreset,Mt as moveToRegion,vt as parseCoordinate,Pt as pauseRoute,rt as refreshLocationPermission,ao as registerLocationPlaces,lo as registerLocationRoutes,Et as resetLocation,$t as resumeRoute,In as seekRoute,Pn as setConditions,ct as setPlace,An as setRouteSpeed,Ln as setServices,Sn as setSignal,Cn as startRoute,$n as stopRoute,Ue as subscribeLocation,Tn as tuneOverride,Mn as useRealLocation};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/location",
3
- "version": "7.0.64",
3
+ "version": "7.0.66",
4
4
  "description": "Location override for React Native: pin the app to any place, play routes with speed and heading, trigger geofences and test signal loss. Works with expo-location, @react-native-community/geolocation and react-native-geolocation-service.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -17,17 +17,17 @@
17
17
  "./lib/web/**/*.mjs"
18
18
  ],
19
19
  "dependencies": {
20
- "@buoy-gg/shared-ui": "^7.0.64"
20
+ "@buoy-gg/shared-ui": "^7.0.66"
21
21
  },
22
22
  "peerDependencies": {
23
- "@buoy-gg/license": "7.0.64",
23
+ "@buoy-gg/license": "7.0.66",
24
24
  "react": "*"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/react": "^19.1.0",
28
28
  "@types/react-native": "^0.73.0",
29
29
  "typescript": "~5.8.3",
30
- "@buoy-gg/license": "^7.0.64"
30
+ "@buoy-gg/license": "^7.0.66"
31
31
  },
32
32
  "react-native-builder-bob": {
33
33
  "source": "src",