@buoy-gg/clock 7.0.85 → 7.0.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/ClockChip.js +1 -1
- package/lib/commonjs/components/ClockToolView.js +1 -1
- package/lib/commonjs/sync/clockSyncAdapter.js +1 -1
- package/lib/module/components/ClockChip.js +1 -1
- package/lib/module/components/ClockToolView.js +1 -1
- package/lib/module/sync/clockSyncAdapter.js +1 -1
- package/lib/web/index.mjs +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CLOCK_CHIP_ID=void 0;exports.ClockChip=ClockChip;exports.openClockChip=openClockChip;exports.watchClockChip=watchClockChip;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _clockStore=require("../engine/clockStore");var _clockMath=require("../engine/clockMath");var _useLiveClock=require("./useLiveClock");var _format=require("./format");var _jsxRuntime=require("react/jsx-runtime");const CLOCK_CHIP_ID=exports.CLOCK_CHIP_ID="clock-chip";const registration={id:CLOCK_CHIP_ID,render:e=>(0,_jsxRuntime.jsx)(ClockChip,{...e})};const isChipOpen=()=>(0,_sharedUi.getFloatingTools)().some(e=>e.id===CLOCK_CHIP_ID);function openClockChip(){(0,_sharedUi.openFloatingTool)(registration)}let watching=false;function watchClockChip(){if(watching)return;watching=true;let e=false;const i=()=>{const t=(0,_clockStore.isClockOverridden)()&&(0,_clockStore.getClockSettings)().showChip;if(t&&!e)(0,_sharedUi.openFloatingTool)(registration);else if(!t&&isChipOpen())(0,_sharedUi.dismissFloatingTool)(CLOCK_CHIP_ID);e=t};(0,_clockStore.subscribeClock)(i);i()}function ClockChip({id:e,revealToken:i}){const t=(0,_react.useSyncExternalStore)(_clockStore.subscribeClock,_clockStore.getStableClockSnapshot,_clockStore.getStableClockSnapshot);const{virtual:r,real:l}=(0,_useLiveClock.useLiveClock)(t);const o=t.mode==="frozen";const n=(0,_sharedUi.getUseIsPro)()();const s=o||
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CLOCK_CHIP_ID=void 0;exports.ClockChip=ClockChip;exports.openClockChip=openClockChip;exports.watchClockChip=watchClockChip;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _clockStore=require("../engine/clockStore");var _clockMath=require("../engine/clockMath");var _useLiveClock=require("./useLiveClock");var _format=require("./format");var _jsxRuntime=require("react/jsx-runtime");const CLOCK_CHIP_ID=exports.CLOCK_CHIP_ID="clock-chip";const registration={id:CLOCK_CHIP_ID,render:e=>(0,_jsxRuntime.jsx)(ClockChip,{...e})};const isChipOpen=()=>(0,_sharedUi.getFloatingTools)().some(e=>e.id===CLOCK_CHIP_ID);function openClockChip(){(0,_sharedUi.openFloatingTool)(registration)}let watching=false;function watchClockChip(){if(watching)return;watching=true;let e=false;const i=()=>{const t=(0,_clockStore.isClockOverridden)()&&(0,_clockStore.getClockSettings)().showChip;if(t&&!e)(0,_sharedUi.openFloatingTool)(registration);else if(!t&&isChipOpen())(0,_sharedUi.dismissFloatingTool)(CLOCK_CHIP_ID);e=t};(0,_clockStore.subscribeClock)(i);i()}function ClockChip({id:e,revealToken:i}){const t=(0,_react.useSyncExternalStore)(_clockStore.subscribeClock,_clockStore.getStableClockSnapshot,_clockStore.getStableClockSnapshot);const{virtual:r,real:l}=(0,_useLiveClock.useLiveClock)(t);const o=t.mode==="frozen";const n=(0,_sharedUi.getUseIsPro)();const a=n();const s=o||a;const h=(0,_format.clockStatus)(t);const c=r-l;const u=`${Math.abs(c)<1e3?"0s":(0,_clockMath.formatDuration)(c)} \xB7 ${h.label.toLowerCase()}`;return(0,_jsxRuntime.jsx)(_sharedUi.FloatingTool,{id:e,revealToken:i,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:`Move or hide the clock chip. App time ${(0,_format.formatChipTime)(r)}`,handleAdornment:(0,_jsxRuntime.jsx)(_sharedUi.ClockToolIcon,{size:12}),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.row,children:[(0,_jsxRuntime.jsx)(_sharedUi.ClockToolIcon,{size:18}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.text,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.time,numberOfLines:1,testID:"clock-chip-time",children:(0,_format.formatChipTime)(r)}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.detail,numberOfLines:1,testID:"clock-chip-detail",children:u})]}),s?(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:o?"clock-chip-resume":"clock-chip-freeze",accessibilityRole:"button",accessibilityLabel:o?"Resume the app clock":"Freeze the app clock",onPress:()=>o?(0,_clockStore.resume)():(0,_clockStore.freeze)(),style:styles.button,hitSlop:{top:8,bottom:8,left:4,right:4},children:[o?(0,_jsxRuntime.jsx)(_sharedUi.Play,{size:16,color:_sharedUi.night.color.accent}):null,o?null:(0,_jsxRuntime.jsx)(_sharedUi.Pause,{size:16,color:_sharedUi.night.color.text})]}):null,s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.separator}):null,(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:"clock-chip-reset",accessibilityRole:"button",accessibilityLabel:"Back to real time",onPress:()=>(0,_clockStore.reset)(),style:styles.button,hitSlop:{top:8,bottom:8,left:4,right:8},children:(0,_jsxRuntime.jsx)(_sharedUi.X,{size:16,color:_sharedUi.night.color.textSecondary})})]})})}const styles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingLeft:10,paddingRight:4,paddingVertical:6,minWidth:220},text:{flexShrink:1,minWidth:120},time:{color:"#F59E0B",fontSize:14,fontWeight:"600",fontVariant:["tabular-nums"]},detail:{color:_sharedUi.night.color.textSecondary,fontSize:11,fontVariant:["tabular-nums"]},button:{width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:16},separator:{width:_reactNative.StyleSheet.hairlineWidth,height:20,backgroundColor:_sharedUi.night.color.separator}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ClockToolView=ClockToolView;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _clockMath=require("../engine/clockMath");var _patches=require("../engine/patches");var _useLiveClock=require("./useLiveClock");var _TokenSection=require("./TokenSection");var _format=require("./format");var _jsxRuntime=require("react/jsx-runtime");const AMBER="#F59E0B";function ClockToolView({snapshot:e,onAction:t,onReload:o}){const n=(0,_sharedUi.useSafeAreaInsets)({minBottom:16});const[i,r]=(0,_react.useState)(null);const[l,u]=(0,_react.useState)(null);const s=(0,_sharedUi.getUseIsPro)()();const[a,p]=(0,_react.useState)(null);const h=c=>p(c);const d=(c,x)=>{r(null);t(c,x).catch(m=>{r(m instanceof Error?m.message:String(m))})};const g=c=>u(x=>x===c?null:c);if(!e){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.waiting,testID:"clock-waiting",children:(0,_jsxRuntime.jsx)(_sharedUi.NightFootnote,{centered:true,children:"Waiting for the app's clock\u2026"})})}return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.fill,contentContainerStyle:[styles.content,{paddingBottom:n.bottom}],testID:"clock-scroll",keyboardShouldPersistTaps:"handled",children:[(0,_jsxRuntime.jsx)(Hero,{snapshot:e}),i?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"clock-error",children:(0,_jsxRuntime.jsx)(_sharedUi.NightFootnote,{tone:"danger",centered:true,children:i})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_sharedUi.NightSectionLabel,{children:"Jump ahead"}),(0,_jsxRuntime.jsx)(JumpBar,{run:d})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{children:(0,_jsxRuntime.jsxs)(_sharedUi.NightRows,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(DisclosureRow,{title:"Date & Time",testID:"clock-date-row",open:l==="date",onPress:()=>g("date"),value:(0,_jsxRuntime.jsx)(LiveDateValue,{snapshot:e})}),l==="date"?(0,_jsxRuntime.jsx)(DateEditor,{snapshot:e,run:d,onDone:()=>u(null)}):null]},"date"),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.row,children:[(0,_jsxRuntime.jsx)(ProTitle,{title:"Freeze",isPro:s}),(0,_jsxRuntime.jsx)(_sharedUi.NightSwitch,{value:e.mode==="frozen",testID:"clock-freeze",accessibilityLabel:"Freeze the clock",onValueChange:c=>c&&!s?h("Freeze"):d(c?"freeze":"resume")})]},"freeze"),(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(DisclosureRow,{title:"Speed",pro:!s,testID:"clock-speed-row",open:l==="speed",onPress:()=>s?g("speed"):h("Speed"),value:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowValue,children:speedLabel(e)})}),l==="speed"?(0,_jsxRuntime.jsx)(SpeedPicker,{snapshot:e,run:d}):null]},"speed")]})}),(0,_jsxRuntime.jsx)(_sharedUi.NightFootnote,{children:"Only this app's clock changes. Screens pick up the new time when they next render, or all at once when you reload."})]}),e.tokens?(0,_jsxRuntime.jsx)(_TokenSection.TokenSection,{snapshot:e,run:d,openId:l,onToggle:g,isPro:s,onUpgrade:h}):null,(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{children:(0,_jsxRuntime.jsxs)(_sharedUi.NightRows,{children:[o?(0,_jsxRuntime.jsx)(ActionRow,{label:"Reload App",testID:"clock-reload",onPress:o},"reload"):null,(0,_jsxRuntime.jsx)(ActionRow,{label:"Use Real Time",accessibilityLabel:"Reset to real time",testID:"clock-reset",destructive:true,disabled:e.mode==="real",onPress:()=>d("reset")},"reset")]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_sharedUi.NightSectionLabel,{children:"Options"}),(0,_jsxRuntime.jsx)(OptionsCard,{settings:e.settings,run:d,isPro:s,onUpgrade:h})]}),(0,_jsxRuntime.jsx)(_sharedUi.ProUpgradeModal,{visible:a!==null&&!s,onClose:()=>p(null),featureName:a??void 0})]})}function ProTitle({title:e,isPro:t}){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.titleRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowTitle,children:e}),t?null:(0,_jsxRuntime.jsx)(_sharedUi.ProBadge,{})]})}function Hero({snapshot:e}){const{virtual:t,real:o}=(0,_useLiveClock.useLiveClock)(e);const n=(0,_format.clockStatus)(e);const i=e.mode!=="real";const r=(0,_format.formatOffset)(t-o);const l=e.mode==="frozen"?" \xB7 Frozen":i&&e.rate!==1?` \xB7 ${speedLabel(e)}`:"";return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.hero,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.heroTime,i?styles.heroTimeActive:null],testID:"clock-hero-time",accessibilityLabel:`App clock ${(0,_format.formatClockTime)(t)}`,children:(0,_format.formatClockTime)(t)}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.heroDate,testID:"clock-hero-date",children:(0,_format.formatClockDate)(t)}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"clock-status",accessibilityLabel:`Clock status: ${n.label}${i?`, ${r}`:""}`,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.heroStatus,i?styles.heroStatusActive:null],testID:"clock-offset",children:i?`${r}${l}`:"Real time"})})]})}const HOUR=36e5;const DAY=24*HOUR;const JUMP_BAR=[{ms:HOUR,unit:"hour"},{ms:DAY,unit:"day"},{ms:7*DAY,unit:"week"},{ms:30*DAY,unit:"month"}];function JumpBar({run:e}){return(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{style:styles.jumpBar,children:JUMP_BAR.map((t,o)=>(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:(0,_format.jumpTestId)(t.ms),accessibilityRole:"button",accessibilityLabel:`Jump ahead one ${t.unit}`,activeOpacity:.6,onPress:()=>e("shift",{by:t.ms}),style:[styles.jump,o>0?styles.jumpDivider:null],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.jumpAmount,children:"+1"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.jumpUnit,children:t.unit})]},t.unit))})}function DisclosureRow({title:e,pro:t,value:o,open:n,onPress:i,testID:r}){return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:r,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{expanded:n},activeOpacity:.6,onPress:i,style:styles.row,children:[(0,_jsxRuntime.jsx)(ProTitle,{title:e,isPro:!t}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowRight,children:[o,(0,_jsxRuntime.jsx)(_reactNative.View,{style:n?styles.chevronOpen:null,children:(0,_jsxRuntime.jsx)(_sharedUi.ChevronRight,{size:16,color:_sharedUi.night.color.textTertiary})})]})]})}function LiveDateValue({snapshot:e}){const{virtual:t}=(0,_useLiveClock.useLiveClock)(e,1e3);return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.rowValue,styles.tabular],numberOfLines:1,children:(0,_format.formatChipTime)(t,false)})}function ActionRow({label:e,onPress:t,testID:o,destructive:n,disabled:i,accessibilityLabel:r}){return(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:o,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!i},activeOpacity:.6,disabled:i,onPress:t,style:[styles.row,i?styles.rowDisabled:null],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.actionLabel,n?styles.actionDestructive:null],children:e})})}const PRESETS=_clockMath.TIME_PRESETS.filter(e=>["midnight","month-end","year-end"].includes(e.id));function DateEditor({snapshot:e,run:t,onDone:o}){const[n,i]=(0,_react.useState)("");const{virtual:r}=(0,_useLiveClock.useLiveClock)(e,1e3);const l=()=>n.trim()||(0,_format.formatInputTime)(r);const u=e.mode==="frozen";const s=a=>{t("setTime",{time:a,freeze:u});o()};return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.editor,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inputRow,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{testID:"clock-time-input",accessibilityLabel:"Date and time",value:n,onChangeText:i,placeholder:(0,_format.formatInputTime)(r),placeholderTextColor:_sharedUi.night.color.placeholder,autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>s(l()),style:styles.input}),(0,_jsxRuntime.jsx)(_sharedUi.NightButton,{label:"Set",testID:"clock-time-apply",accessibilityLabel:"Set this time",size:"md",variant:"primary",fullWidth:false,onPress:()=>s(l())})]}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.hint,children:"Year-month-day and 24-hour time, or +3d, -2h"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.presets,children:PRESETS.map(a=>(0,_jsxRuntime.jsx)(_sharedUi.NightChip,{label:a.label,testID:`clock-preset-${a.id}`,onPress:()=>s(a.at(r,_patches.RealDate))},a.id))})]})}const SPEED_TABS=[{key:"1",label:"Normal"},{key:"10",label:"10\xD7"},{key:"60",label:"1 min/s"},{key:"3600",label:"1 hr/s"}];function speedLabel(e){if(e.mode==="real"||e.rate===1)return"Normal";return SPEED_TABS.find(t=>Number(t.key)===e.rate)?.label??(0,_clockMath.formatRate)(e.rate)}function SpeedPicker({snapshot:e,run:t}){const o=e.mode==="real"?"1":String(e.rate);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.editor,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.segmentRow,children:(0,_jsxRuntime.jsx)(_sharedUi.NightSegmented,{tabs:SPEED_TABS,activeKey:o,size:"sm",testIDPrefix:"clock-speed",onChange:n=>t("setRate",{rate:Number(n)})})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.hint,children:"Taps, animations and timers keep real speed."})]})}const OPTIONS=[{key:"showChip",title:"Show Floating Clock"},{key:"persist",title:"Keep After Reload",pro:true}];function OptionsCard({settings:e,run:t,isPro:o,onUpgrade:n}){return(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{children:(0,_jsxRuntime.jsx)(_sharedUi.NightRows,{children:OPTIONS.map(i=>{const r=!!i.pro&&!o;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.row,children:[(0,_jsxRuntime.jsx)(ProTitle,{title:i.title,isPro:!r}),(0,_jsxRuntime.jsx)(_sharedUi.NightSwitch,{value:r?false:e[i.key],testID:`clock-setting-${i.key}`,accessibilityLabel:i.title,onValueChange:l=>r?n(i.title):t("updateSettings",{[i.key]:l})})]},i.key)})})})}const styles=_reactNative.StyleSheet.create({fill:{flex:1},content:{paddingHorizontal:_sharedUi.night.gutter,paddingTop:8,gap:_sharedUi.night.groupGap},waiting:{flex:1,alignItems:"center",justifyContent:"center",padding:24},hero:{alignItems:"center",paddingTop:12},heroTime:{color:_sharedUi.night.color.text,fontSize:56,fontWeight:"200",fontVariant:["tabular-nums"],letterSpacing:1},heroTimeActive:{color:AMBER},heroDate:{color:_sharedUi.night.color.text,fontSize:17,fontWeight:"500",marginTop:2},heroStatus:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption,fontWeight:"500",marginTop:6},heroStatusActive:{color:_sharedUi.night.color.textSecondary},jumpBar:{flexDirection:"row"},jump:{flex:1,alignItems:"center",paddingVertical:12},jumpDivider:{borderLeftWidth:_reactNative.StyleSheet.hairlineWidth,borderLeftColor:_sharedUi.night.color.separator},jumpAmount:{color:AMBER,fontSize:17,fontWeight:"600",fontVariant:["tabular-nums"]},jumpUnit:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.caption,marginTop:1},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:50,paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:10},rowDisabled:{opacity:.4},rowTitle:{color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.row},titleRow:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:1},rowRight:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},rowValue:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.row},tabular:{fontVariant:["tabular-nums"]},chevronOpen:{transform:[{rotate:"90deg"}]},actionLabel:{color:_sharedUi.night.color.accent,fontSize:_sharedUi.night.font.row},actionDestructive:{color:_sharedUi.night.color.danger},editor:{paddingHorizontal:_sharedUi.night.rowPadH,paddingBottom:14,gap:10},inputRow:{flexDirection:"row",alignItems:"center",gap:8},input:{flex:1,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont,fontSize:15,backgroundColor:_sharedUi.night.color.bg,borderRadius:_sharedUi.night.radius.input,borderWidth:1,borderColor:_sharedUi.night.color.border,paddingHorizontal:12,paddingVertical:8},hint:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption},presets:{flexDirection:"row",flexWrap:"wrap",gap:6},segmentRow:{flexDirection:"row"}});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ClockToolView=ClockToolView;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _clockMath=require("../engine/clockMath");var _patches=require("../engine/patches");var _useLiveClock=require("./useLiveClock");var _TokenSection=require("./TokenSection");var _format=require("./format");var _jsxRuntime=require("react/jsx-runtime");const AMBER="#F59E0B";function ClockToolView({snapshot:e,onAction:t,onReload:o}){const n=(0,_sharedUi.useSafeAreaInsets)({minBottom:16});const[i,r]=(0,_react.useState)(null);const[s,u]=(0,_react.useState)(null);const d=(0,_sharedUi.getUseIsPro)();const l=d();const[p,f]=(0,_react.useState)(null);const h=a=>f(a);const c=(a,x)=>{r(null);t(a,x).catch(m=>{r(m instanceof Error?m.message:String(m))})};const g=a=>u(x=>x===a?null:a);if(!e){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.waiting,testID:"clock-waiting",children:(0,_jsxRuntime.jsx)(_sharedUi.NightFootnote,{centered:true,children:"Waiting for the app's clock\u2026"})})}return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.fill,contentContainerStyle:[styles.content,{paddingBottom:n.bottom}],testID:"clock-scroll",keyboardShouldPersistTaps:"handled",children:[(0,_jsxRuntime.jsx)(Hero,{snapshot:e}),i?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"clock-error",children:(0,_jsxRuntime.jsx)(_sharedUi.NightFootnote,{tone:"danger",centered:true,children:i})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_sharedUi.NightSectionLabel,{children:"Jump ahead"}),(0,_jsxRuntime.jsx)(JumpBar,{run:c})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{children:(0,_jsxRuntime.jsxs)(_sharedUi.NightRows,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(DisclosureRow,{title:"Date & Time",testID:"clock-date-row",open:s==="date",onPress:()=>g("date"),value:(0,_jsxRuntime.jsx)(LiveDateValue,{snapshot:e})}),s==="date"?(0,_jsxRuntime.jsx)(DateEditor,{snapshot:e,run:c,onDone:()=>u(null)}):null]},"date"),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.row,children:[(0,_jsxRuntime.jsx)(ProTitle,{title:"Freeze",isPro:l}),(0,_jsxRuntime.jsx)(_sharedUi.NightSwitch,{value:e.mode==="frozen",testID:"clock-freeze",accessibilityLabel:"Freeze the clock",onValueChange:a=>a&&!l?h("Freeze"):c(a?"freeze":"resume")})]},"freeze"),(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(DisclosureRow,{title:"Speed",pro:!l,testID:"clock-speed-row",open:s==="speed",onPress:()=>l?g("speed"):h("Speed"),value:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowValue,children:speedLabel(e)})}),s==="speed"?(0,_jsxRuntime.jsx)(SpeedPicker,{snapshot:e,run:c}):null]},"speed")]})}),(0,_jsxRuntime.jsx)(_sharedUi.NightFootnote,{children:"Only this app's clock changes. Screens pick up the new time when they next render, or all at once when you reload."})]}),e.tokens?(0,_jsxRuntime.jsx)(_TokenSection.TokenSection,{snapshot:e,run:c,openId:s,onToggle:g,isPro:l,onUpgrade:h}):null,(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{children:(0,_jsxRuntime.jsxs)(_sharedUi.NightRows,{children:[o?(0,_jsxRuntime.jsx)(ActionRow,{label:"Reload App",testID:"clock-reload",onPress:o},"reload"):null,(0,_jsxRuntime.jsx)(ActionRow,{label:"Use Real Time",accessibilityLabel:"Reset to real time",testID:"clock-reset",destructive:true,disabled:e.mode==="real",onPress:()=>c("reset")},"reset")]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_sharedUi.NightSectionLabel,{children:"Options"}),(0,_jsxRuntime.jsx)(OptionsCard,{settings:e.settings,run:c,isPro:l,onUpgrade:h})]}),(0,_jsxRuntime.jsx)(_sharedUi.ProUpgradeModal,{visible:p!==null&&!l,onClose:()=>f(null),featureName:p??void 0})]})}function ProTitle({title:e,isPro:t}){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.titleRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowTitle,children:e}),t?null:(0,_jsxRuntime.jsx)(_sharedUi.ProBadge,{})]})}function Hero({snapshot:e}){const{virtual:t,real:o}=(0,_useLiveClock.useLiveClock)(e);const n=(0,_format.clockStatus)(e);const i=e.mode!=="real";const r=(0,_format.formatOffset)(t-o);const s=e.mode==="frozen"?" \xB7 Frozen":i&&e.rate!==1?` \xB7 ${speedLabel(e)}`:"";return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.hero,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.heroTime,i?styles.heroTimeActive:null],testID:"clock-hero-time",accessibilityLabel:`App clock ${(0,_format.formatClockTime)(t)}`,children:(0,_format.formatClockTime)(t)}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.heroDate,testID:"clock-hero-date",children:(0,_format.formatClockDate)(t)}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"clock-status",accessibilityLabel:`Clock status: ${n.label}${i?`, ${r}`:""}`,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.heroStatus,i?styles.heroStatusActive:null],testID:"clock-offset",children:i?`${r}${s}`:"Real time"})})]})}const HOUR=36e5;const DAY=24*HOUR;const JUMP_BAR=[{ms:HOUR,unit:"hour"},{ms:DAY,unit:"day"},{ms:7*DAY,unit:"week"},{ms:30*DAY,unit:"month"}];function JumpBar({run:e}){return(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{style:styles.jumpBar,children:JUMP_BAR.map((t,o)=>(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:(0,_format.jumpTestId)(t.ms),accessibilityRole:"button",accessibilityLabel:`Jump ahead one ${t.unit}`,activeOpacity:.6,onPress:()=>e("shift",{by:t.ms}),style:[styles.jump,o>0?styles.jumpDivider:null],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.jumpAmount,children:"+1"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.jumpUnit,children:t.unit})]},t.unit))})}function DisclosureRow({title:e,pro:t,value:o,open:n,onPress:i,testID:r}){return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:r,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{expanded:n},activeOpacity:.6,onPress:i,style:styles.row,children:[(0,_jsxRuntime.jsx)(ProTitle,{title:e,isPro:!t}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowRight,children:[o,(0,_jsxRuntime.jsx)(_reactNative.View,{style:n?styles.chevronOpen:null,children:(0,_jsxRuntime.jsx)(_sharedUi.ChevronRight,{size:16,color:_sharedUi.night.color.textTertiary})})]})]})}function LiveDateValue({snapshot:e}){const{virtual:t}=(0,_useLiveClock.useLiveClock)(e,1e3);return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.rowValue,styles.tabular],numberOfLines:1,children:(0,_format.formatChipTime)(t,false)})}function ActionRow({label:e,onPress:t,testID:o,destructive:n,disabled:i,accessibilityLabel:r}){return(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:o,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!i},activeOpacity:.6,disabled:i,onPress:t,style:[styles.row,i?styles.rowDisabled:null],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.actionLabel,n?styles.actionDestructive:null],children:e})})}const PRESETS=_clockMath.TIME_PRESETS.filter(e=>["midnight","month-end","year-end"].includes(e.id));function DateEditor({snapshot:e,run:t,onDone:o}){const[n,i]=(0,_react.useState)("");const{virtual:r}=(0,_useLiveClock.useLiveClock)(e,1e3);const s=()=>n.trim()||(0,_format.formatInputTime)(r);const u=e.mode==="frozen";const d=l=>{t("setTime",{time:l,freeze:u});o()};return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.editor,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inputRow,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{testID:"clock-time-input",accessibilityLabel:"Date and time",value:n,onChangeText:i,placeholder:(0,_format.formatInputTime)(r),placeholderTextColor:_sharedUi.night.color.placeholder,autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>d(s()),style:styles.input}),(0,_jsxRuntime.jsx)(_sharedUi.NightButton,{label:"Set",testID:"clock-time-apply",accessibilityLabel:"Set this time",size:"md",variant:"primary",fullWidth:false,onPress:()=>d(s())})]}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.hint,children:"Year-month-day and 24-hour time, or +3d, -2h"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.presets,children:PRESETS.map(l=>(0,_jsxRuntime.jsx)(_sharedUi.NightChip,{label:l.label,testID:`clock-preset-${l.id}`,onPress:()=>d(l.at(r,_patches.RealDate))},l.id))})]})}const SPEED_TABS=[{key:"1",label:"Normal"},{key:"10",label:"10\xD7"},{key:"60",label:"1 min/s"},{key:"3600",label:"1 hr/s"}];function speedLabel(e){if(e.mode==="real"||e.rate===1)return"Normal";return SPEED_TABS.find(t=>Number(t.key)===e.rate)?.label??(0,_clockMath.formatRate)(e.rate)}function SpeedPicker({snapshot:e,run:t}){const o=e.mode==="real"?"1":String(e.rate);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.editor,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.segmentRow,children:(0,_jsxRuntime.jsx)(_sharedUi.NightSegmented,{tabs:SPEED_TABS,activeKey:o,size:"sm",testIDPrefix:"clock-speed",onChange:n=>t("setRate",{rate:Number(n)})})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.hint,children:"Taps, animations and timers keep real speed."})]})}const OPTIONS=[{key:"showChip",title:"Show Floating Clock"},{key:"persist",title:"Keep After Reload",pro:true}];function OptionsCard({settings:e,run:t,isPro:o,onUpgrade:n}){return(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{children:(0,_jsxRuntime.jsx)(_sharedUi.NightRows,{children:OPTIONS.map(i=>{const r=!!i.pro&&!o;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.row,children:[(0,_jsxRuntime.jsx)(ProTitle,{title:i.title,isPro:!r}),(0,_jsxRuntime.jsx)(_sharedUi.NightSwitch,{value:r?false:e[i.key],testID:`clock-setting-${i.key}`,accessibilityLabel:i.title,onValueChange:s=>r?n(i.title):t("updateSettings",{[i.key]:s})})]},i.key)})})})}const styles=_reactNative.StyleSheet.create({fill:{flex:1},content:{paddingHorizontal:_sharedUi.night.gutter,paddingTop:8,gap:_sharedUi.night.groupGap},waiting:{flex:1,alignItems:"center",justifyContent:"center",padding:24},hero:{alignItems:"center",paddingTop:12},heroTime:{color:_sharedUi.night.color.text,fontSize:56,fontWeight:"200",fontVariant:["tabular-nums"],letterSpacing:1},heroTimeActive:{color:AMBER},heroDate:{color:_sharedUi.night.color.text,fontSize:17,fontWeight:"500",marginTop:2},heroStatus:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption,fontWeight:"500",marginTop:6},heroStatusActive:{color:_sharedUi.night.color.textSecondary},jumpBar:{flexDirection:"row"},jump:{flex:1,alignItems:"center",paddingVertical:12},jumpDivider:{borderLeftWidth:_reactNative.StyleSheet.hairlineWidth,borderLeftColor:_sharedUi.night.color.separator},jumpAmount:{color:AMBER,fontSize:17,fontWeight:"600",fontVariant:["tabular-nums"]},jumpUnit:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.caption,marginTop:1},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:50,paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:10},rowDisabled:{opacity:.4},rowTitle:{color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.row},titleRow:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:1},rowRight:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},rowValue:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.row},tabular:{fontVariant:["tabular-nums"]},chevronOpen:{transform:[{rotate:"90deg"}]},actionLabel:{color:_sharedUi.night.color.accent,fontSize:_sharedUi.night.font.row},actionDestructive:{color:_sharedUi.night.color.danger},editor:{paddingHorizontal:_sharedUi.night.rowPadH,paddingBottom:14,gap:10},inputRow:{flexDirection:"row",alignItems:"center",gap:8},input:{flex:1,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont,fontSize:15,backgroundColor:_sharedUi.night.color.bg,borderRadius:_sharedUi.night.radius.input,borderWidth:1,borderColor:_sharedUi.night.color.border,paddingHorizontal:12,paddingVertical:8},hint:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption},presets:{flexDirection:"row",flexWrap:"wrap",gap:6},segmentRow:{flexDirection:"row"}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.clockSyncAdapter=void 0;var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.clockSyncAdapter=void 0;var _clockStore=require("../engine/clockStore");var _sharedUi=require("@buoy-gg/shared-ui");var _tokenStore=require("../tokens/tokenStore");var _tokenActions=require("../tokens/tokenActions");function obj(t){return t&&typeof t==="object"?t:{}}function timeParam(t,...e){for(const r of e){const n=t[r];if(typeof n==="string"||typeof n==="number")return n}return void 0}function boolParam(t,e){const r=t[e];if(typeof r==="boolean")return r;if(r==="true")return true;if(r==="false")return false;return void 0}const clockSyncAdapter=exports.clockSyncAdapter=(0,_sharedUi.createSyncAdapter)({version:1,getSnapshot(){return(0,_clockStore.getClockSnapshot)()},subscribe(t){return(0,_clockStore.subscribeClock)(t)},actions:{getState(){(0,_tokenStore.startTokenWatch)();return(0,_clockStore.getClockSnapshot)()},setTime(t){const e=obj(t);const r=timeParam(e,"time","at","date","iso");if(r===void 0){throw new Error('setTime needs `time`: ISO 8601 ("2026-12-31T23:59:50"), epoch ms, or relative ("+1d").')}return(0,_clockStore.setTime)(r,boolParam(e,"freeze")??false)},shift(t){const e=obj(t);const r=timeParam(e,"by","ms","duration","delta");if(r===void 0){throw new Error('shift needs `by`: a duration like "+1d", "-2h30m", "90s", or ms.')}return(0,_clockStore.shift)(r,boolParam(e,"fireTimers"))},freeze(t){return(0,_clockStore.freeze)(timeParam(obj(t),"time","at"))},resume(){return(0,_clockStore.resume)()},setRate(t){const e=obj(t);const r=Number(e.rate??e.speed);if(!Number.isFinite(r))throw new Error("setRate needs a numeric `rate` (1 = normal speed).");return(0,_clockStore.setRate)(r)},reset(){return(0,_clockStore.reset)()},updateSettings(t){const e=obj(t);return(0,_clockStore.updateSettings)({persist:boolParam(e,"persist"),showChip:boolParam(e,"showChip"),fireTimersOnJump:boolParam(e,"fireTimersOnJump")})},jumpToTokenExpiry(t){const e=obj(t);const r=typeof e.token==="string"?e.token:typeof e.id==="string"?e.id:void 0;const n=Number(e.leadMs??e.lead??1e4);return(0,_tokenActions.jumpToTokenExpiry)(r,Number.isFinite(n)?n:1e4)},failNextRequest(t){const e=obj(t);const r=typeof e.token==="string"?e.token:typeof e.id==="string"?e.id:void 0;const n=Number(e.status??401);const o=Number(e.times??1);return(0,_tokenActions.failNextRequest)(r,n,Number.isFinite(o)?o:1)},stopTokenCheck(){return(0,_tokenActions.stopTokenCheck)()},async holdForReload(){await(0,_clockStore.holdForNextReload)();return(0,_clockStore.getClockSnapshot)()}}});(0,_sharedUi.bootBeforeActions)(clockSyncAdapter,_clockStore.bootClock);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useSyncExternalStore as
|
|
1
|
+
"use strict";import{useSyncExternalStore as P}from"react";import{StyleSheet as m,Text as d,TouchableOpacity as u,View as n}from"react-native";import{ClockToolIcon as f,FloatingTool as T,Pause as F,Play as D,X as v,dismissFloatingTool as O,getFloatingTools as j,getUseIsPro as R,night as s,openFloatingTool as b}from"@buoy-gg/shared-ui";import{freeze as W,getStableClockSnapshot as g,reset as V,resume as _,subscribeClock as k,getClockSettings as $,isClockOverridden as A}from"../engine/clockStore";import{formatDuration as B}from"../engine/clockMath";import{useLiveClock as E}from"./useLiveClock";import{clockStatus as H,formatChipTime as y}from"./format";import{jsx as t,jsxs as a}from"react/jsx-runtime";export const CLOCK_CHIP_ID="clock-chip";const C={id:CLOCK_CHIP_ID,render:e=>t(ClockChip,{...e})};const M=()=>j().some(e=>e.id===CLOCK_CHIP_ID);export function openClockChip(){b(C)}let x=false;export function watchClockChip(){if(x)return;x=true;let e=false;const l=()=>{const o=A()&&$().showChip;if(o&&!e)b(C);else if(!o&&M())O(CLOCK_CHIP_ID);e=o};k(l);l()}export function ClockChip({id:e,revealToken:l}){const o=P(k,g,g);const{virtual:c,real:S}=E(o);const r=o.mode==="frozen";const w=R();const z=w();const h=r||z;const I=H(o);const p=c-S;const L=`${Math.abs(p)<1e3?"0s":B(p)} \xB7 ${I.label.toLowerCase()}`;return t(T,{id:e,revealToken:l,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:`Move or hide the clock chip. App time ${y(c)}`,handleAdornment:t(f,{size:12}),children:a(n,{style:i.row,children:[t(f,{size:18}),a(n,{style:i.text,children:[t(d,{style:i.time,numberOfLines:1,testID:"clock-chip-time",children:y(c)}),t(d,{style:i.detail,numberOfLines:1,testID:"clock-chip-detail",children:L})]}),h?a(u,{testID:r?"clock-chip-resume":"clock-chip-freeze",accessibilityRole:"button",accessibilityLabel:r?"Resume the app clock":"Freeze the app clock",onPress:()=>r?_():W(),style:i.button,hitSlop:{top:8,bottom:8,left:4,right:4},children:[r?t(D,{size:16,color:s.color.accent}):null,r?null:t(F,{size:16,color:s.color.text})]}):null,h?t(n,{style:i.separator}):null,t(u,{testID:"clock-chip-reset",accessibilityRole:"button",accessibilityLabel:"Back to real time",onPress:()=>V(),style:i.button,hitSlop:{top:8,bottom:8,left:4,right:8},children:t(v,{size:16,color:s.color.textSecondary})})]})})}const i=m.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingLeft:10,paddingRight:4,paddingVertical:6,minWidth:220},text:{flexShrink:1,minWidth:120},time:{color:"#F59E0B",fontSize:14,fontWeight:"600",fontVariant:["tabular-nums"]},detail:{color:s.color.textSecondary,fontSize:11,fontVariant:["tabular-nums"]},button:{width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:16},separator:{width:m.hairlineWidth,height:20,backgroundColor:s.color.separator}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useState as S}from"react";import{ScrollView as $,StyleSheet as
|
|
1
|
+
"use strict";import{useState as S}from"react";import{ScrollView as $,StyleSheet as A,Text as h,TextInput as _,TouchableOpacity as x,View as n}from"react-native";import{ChevronRight as J,NightButton as M,NightCard as k,NightChip as K,NightFootnote as I,NightRows as v,NightSectionLabel as O,NightSegmented as Y,NightSwitch as V,ProBadge as G,ProUpgradeModal as q,getUseIsPro as Q,monoFont as X,night as i,useSafeAreaInsets as Z}from"@buoy-gg/shared-ui";import{TIME_PRESETS as ee,formatRate as te}from"../engine/clockMath";import{RealDate as re}from"../engine/patches";import{useLiveClock as z}from"./useLiveClock";import{TokenSection as oe}from"./TokenSection";import{clockStatus as ie,formatClockDate as le,formatChipTime as ne,formatClockTime as N,formatInputTime as j,formatOffset as ce,jumpTestId as ae}from"./format";import{jsx as e,jsxs as c}from"react/jsx-runtime";const E="#F59E0B";export function ClockToolView({snapshot:t,onAction:o,onReload:s}){const d=Z({minBottom:16});const[l,a]=S(null);const[m,y]=S(null);const g=Q();const u=g();const[C,L]=S(null);const b=p=>L(p);const f=(p,D)=>{a(null);o(p,D).catch(T=>{a(T instanceof Error?T.message:String(T))})};const w=p=>y(D=>D===p?null:p);if(!t){return e(n,{style:r.waiting,testID:"clock-waiting",children:e(I,{centered:true,children:"Waiting for the app's clock\u2026"})})}return c($,{style:r.fill,contentContainerStyle:[r.content,{paddingBottom:d.bottom}],testID:"clock-scroll",keyboardShouldPersistTaps:"handled",children:[e(se,{snapshot:t}),l?e(n,{testID:"clock-error",children:e(I,{tone:"danger",centered:true,children:l})}):null,c(n,{children:[e(O,{children:"Jump ahead"}),e(ue,{run:f})]}),c(n,{children:[e(k,{children:c(v,{children:[c(n,{children:[e(F,{title:"Date & Time",testID:"clock-date-row",open:m==="date",onPress:()=>w("date"),value:e(me,{snapshot:t})}),m==="date"?e(pe,{snapshot:t,run:f,onDone:()=>y(null)}):null]},"date"),c(n,{style:r.row,children:[e(P,{title:"Freeze",isPro:u}),e(V,{value:t.mode==="frozen",testID:"clock-freeze",accessibilityLabel:"Freeze the clock",onValueChange:p=>p&&!u?b("Freeze"):f(p?"freeze":"resume")})]},"freeze"),c(n,{children:[e(F,{title:"Speed",pro:!u,testID:"clock-speed-row",open:m==="speed",onPress:()=>u?w("speed"):b("Speed"),value:e(h,{style:r.rowValue,children:W(t)})}),m==="speed"?e(fe,{snapshot:t,run:f}):null]},"speed")]})}),e(I,{children:"Only this app's clock changes. Screens pick up the new time when they next render, or all at once when you reload."})]}),t.tokens?e(oe,{snapshot:t,run:f,openId:m,onToggle:w,isPro:u,onUpgrade:b}):null,e(k,{children:c(v,{children:[s?e(H,{label:"Reload App",testID:"clock-reload",onPress:s},"reload"):null,e(H,{label:"Use Real Time",accessibilityLabel:"Reset to real time",testID:"clock-reset",destructive:true,disabled:t.mode==="real",onPress:()=>f("reset")},"reset")]})}),c(n,{children:[e(O,{children:"Options"}),e(ye,{settings:t.settings,run:f,isPro:u,onUpgrade:b})]}),e(q,{visible:C!==null&&!u,onClose:()=>L(null),featureName:C??void 0})]})}function P({title:t,isPro:o}){return c(n,{style:r.titleRow,children:[e(h,{style:r.rowTitle,children:t}),o?null:e(G,{})]})}function se({snapshot:t}){const{virtual:o,real:s}=z(t);const d=ie(t);const l=t.mode!=="real";const a=ce(o-s);const m=t.mode==="frozen"?" \xB7 Frozen":l&&t.rate!==1?` \xB7 ${W(t)}`:"";return c(n,{style:r.hero,children:[e(h,{style:[r.heroTime,l?r.heroTimeActive:null],testID:"clock-hero-time",accessibilityLabel:`App clock ${N(o)}`,children:N(o)}),e(h,{style:r.heroDate,testID:"clock-hero-date",children:le(o)}),e(n,{testID:"clock-status",accessibilityLabel:`Clock status: ${d.label}${l?`, ${a}`:""}`,children:e(h,{style:[r.heroStatus,l?r.heroStatusActive:null],testID:"clock-offset",children:l?`${a}${m}`:"Real time"})})]})}const B=36e5;const R=24*B;const de=[{ms:B,unit:"hour"},{ms:R,unit:"day"},{ms:7*R,unit:"week"},{ms:30*R,unit:"month"}];function ue({run:t}){return e(k,{style:r.jumpBar,children:de.map((o,s)=>c(x,{testID:ae(o.ms),accessibilityRole:"button",accessibilityLabel:`Jump ahead one ${o.unit}`,activeOpacity:.6,onPress:()=>t("shift",{by:o.ms}),style:[r.jump,s>0?r.jumpDivider:null],children:[e(h,{style:r.jumpAmount,children:"+1"}),e(h,{style:r.jumpUnit,children:o.unit})]},o.unit))})}function F({title:t,pro:o,value:s,open:d,onPress:l,testID:a}){return c(x,{testID:a,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{expanded:d},activeOpacity:.6,onPress:l,style:r.row,children:[e(P,{title:t,isPro:!o}),c(n,{style:r.rowRight,children:[s,e(n,{style:d?r.chevronOpen:null,children:e(J,{size:16,color:i.color.textTertiary})})]})]})}function me({snapshot:t}){const{virtual:o}=z(t,1e3);return e(h,{style:[r.rowValue,r.tabular],numberOfLines:1,children:ne(o,false)})}function H({label:t,onPress:o,testID:s,destructive:d,disabled:l,accessibilityLabel:a}){return e(x,{testID:s,accessibilityRole:"button",accessibilityLabel:a??t,accessibilityState:{disabled:!!l},activeOpacity:.6,disabled:l,onPress:o,style:[r.row,l?r.rowDisabled:null],children:e(h,{style:[r.actionLabel,d?r.actionDestructive:null],children:t})})}const he=ee.filter(t=>["midnight","month-end","year-end"].includes(t.id));function pe({snapshot:t,run:o,onDone:s}){const[d,l]=S("");const{virtual:a}=z(t,1e3);const m=()=>d.trim()||j(a);const y=t.mode==="frozen";const g=u=>{o("setTime",{time:u,freeze:y});s()};return c(n,{style:r.editor,children:[c(n,{style:r.inputRow,children:[e(_,{testID:"clock-time-input",accessibilityLabel:"Date and time",value:d,onChangeText:l,placeholder:j(a),placeholderTextColor:i.color.placeholder,autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>g(m()),style:r.input}),e(M,{label:"Set",testID:"clock-time-apply",accessibilityLabel:"Set this time",size:"md",variant:"primary",fullWidth:false,onPress:()=>g(m())})]}),e(h,{style:r.hint,children:"Year-month-day and 24-hour time, or +3d, -2h"}),e(n,{style:r.presets,children:he.map(u=>e(K,{label:u.label,testID:`clock-preset-${u.id}`,onPress:()=>g(u.at(a,re))},u.id))})]})}const U=[{key:"1",label:"Normal"},{key:"10",label:"10\xD7"},{key:"60",label:"1 min/s"},{key:"3600",label:"1 hr/s"}];function W(t){if(t.mode==="real"||t.rate===1)return"Normal";return U.find(o=>Number(o.key)===t.rate)?.label??te(t.rate)}function fe({snapshot:t,run:o}){const s=t.mode==="real"?"1":String(t.rate);return c(n,{style:r.editor,children:[e(n,{style:r.segmentRow,children:e(Y,{tabs:U,activeKey:s,size:"sm",testIDPrefix:"clock-speed",onChange:d=>o("setRate",{rate:Number(d)})})}),e(h,{style:r.hint,children:"Taps, animations and timers keep real speed."})]})}const ge=[{key:"showChip",title:"Show Floating Clock"},{key:"persist",title:"Keep After Reload",pro:true}];function ye({settings:t,run:o,isPro:s,onUpgrade:d}){return e(k,{children:e(v,{children:ge.map(l=>{const a=!!l.pro&&!s;return c(n,{style:r.row,children:[e(P,{title:l.title,isPro:!a}),e(V,{value:a?false:t[l.key],testID:`clock-setting-${l.key}`,accessibilityLabel:l.title,onValueChange:m=>a?d(l.title):o("updateSettings",{[l.key]:m})})]},l.key)})})})}const r=A.create({fill:{flex:1},content:{paddingHorizontal:i.gutter,paddingTop:8,gap:i.groupGap},waiting:{flex:1,alignItems:"center",justifyContent:"center",padding:24},hero:{alignItems:"center",paddingTop:12},heroTime:{color:i.color.text,fontSize:56,fontWeight:"200",fontVariant:["tabular-nums"],letterSpacing:1},heroTimeActive:{color:E},heroDate:{color:i.color.text,fontSize:17,fontWeight:"500",marginTop:2},heroStatus:{color:i.color.textTertiary,fontSize:i.font.caption,fontWeight:"500",marginTop:6},heroStatusActive:{color:i.color.textSecondary},jumpBar:{flexDirection:"row"},jump:{flex:1,alignItems:"center",paddingVertical:12},jumpDivider:{borderLeftWidth:A.hairlineWidth,borderLeftColor:i.color.separator},jumpAmount:{color:E,fontSize:17,fontWeight:"600",fontVariant:["tabular-nums"]},jumpUnit:{color:i.color.textSecondary,fontSize:i.font.caption,marginTop:1},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:50,paddingHorizontal:i.rowPadH,paddingVertical:10},rowDisabled:{opacity:.4},rowTitle:{color:i.color.text,fontSize:i.font.row},titleRow:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:1},rowRight:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},rowValue:{color:i.color.textSecondary,fontSize:i.font.row},tabular:{fontVariant:["tabular-nums"]},chevronOpen:{transform:[{rotate:"90deg"}]},actionLabel:{color:i.color.accent,fontSize:i.font.row},actionDestructive:{color:i.color.danger},editor:{paddingHorizontal:i.rowPadH,paddingBottom:14,gap:10},inputRow:{flexDirection:"row",alignItems:"center",gap:8},input:{flex:1,color:i.color.text,fontFamily:X,fontSize:15,backgroundColor:i.color.bg,borderRadius:i.radius.input,borderWidth:1,borderColor:i.color.border,paddingHorizontal:12,paddingVertical:8},hint:{color:i.color.textTertiary,fontSize:i.font.caption},presets:{flexDirection:"row",flexWrap:"wrap",gap:6},segmentRow:{flexDirection:"row"}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{createSyncAdapter as
|
|
1
|
+
"use strict";import{bootClock as a}from"../engine/clockStore";import{bootBeforeActions as m,createSyncAdapter as c}from"@buoy-gg/shared-ui";import{freeze as p,getClockSnapshot as i,holdForNextReload as d,reset as l,resume as b,setRate as h,setTime as k,shift as y,subscribeClock as T,updateSettings as g}from"../engine/clockStore";import{startTokenWatch as N}from"../tokens/tokenStore";import{failNextRequest as w,jumpToTokenExpiry as S,stopTokenCheck as C}from"../tokens/tokenActions";function o(t){return t&&typeof t==="object"?t:{}}function u(t,...e){for(const r of e){const n=t[r];if(typeof n==="string"||typeof n==="number")return n}return void 0}function s(t,e){const r=t[e];if(typeof r==="boolean")return r;if(r==="true")return true;if(r==="false")return false;return void 0}export const clockSyncAdapter=c({version:1,getSnapshot(){return i()},subscribe(t){return T(t)},actions:{getState(){N();return i()},setTime(t){const e=o(t);const r=u(e,"time","at","date","iso");if(r===void 0){throw new Error('setTime needs `time`: ISO 8601 ("2026-12-31T23:59:50"), epoch ms, or relative ("+1d").')}return k(r,s(e,"freeze")??false)},shift(t){const e=o(t);const r=u(e,"by","ms","duration","delta");if(r===void 0){throw new Error('shift needs `by`: a duration like "+1d", "-2h30m", "90s", or ms.')}return y(r,s(e,"fireTimers"))},freeze(t){return p(u(o(t),"time","at"))},resume(){return b()},setRate(t){const e=o(t);const r=Number(e.rate??e.speed);if(!Number.isFinite(r))throw new Error("setRate needs a numeric `rate` (1 = normal speed).");return h(r)},reset(){return l()},updateSettings(t){const e=o(t);return g({persist:s(e,"persist"),showChip:s(e,"showChip"),fireTimersOnJump:s(e,"fireTimersOnJump")})},jumpToTokenExpiry(t){const e=o(t);const r=typeof e.token==="string"?e.token:typeof e.id==="string"?e.id:void 0;const n=Number(e.leadMs??e.lead??1e4);return S(r,Number.isFinite(n)?n:1e4)},failNextRequest(t){const e=o(t);const r=typeof e.token==="string"?e.token:typeof e.id==="string"?e.id:void 0;const n=Number(e.status??401);const f=Number(e.times??1);return w(r,n,Number.isFinite(f)?f:1)},stopTokenCheck(){return C()},async holdForReload(){await d();return i()}}});m(clockSyncAdapter,a);
|
package/lib/web/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{a as Rr,b as Lr,c as st,d as M,e as A,f as at,g as zr,h as Nr,i as Dr,j as Or,k as Mr,l as Pr,m as Fr,o as jr,p as lt,q as _r,r as Br,s as Ur}from"./chunks/chunk-FCZBPAZF.mjs";var ct={};Rr(ct,{AccessibilityInfo:()=>Jr,ActivityIndicator:()=>Kn,Alert:()=>Yn,Animated:()=>ht,AppRegistry:()=>Kr,AppState:()=>Zr,Appearance:()=>qr,BackHandler:()=>Gr,Button:()=>Zn,CheckBox:()=>pn,Clipboard:()=>Yr,DeviceEventEmitter:()=>In,Dimensions:()=>Xr,Easing:()=>Qr,FlatList:()=>hn,I18nManager:()=>en,Image:()=>mn,ImageBackground:()=>gn,InteractionManager:()=>rn,Keyboard:()=>tn,KeyboardAvoidingView:()=>yn,LayoutAnimation:()=>nn,Linking:()=>on,LogBox:()=>En,Modal:()=>Jn,NativeEventEmitter:()=>sn,NativeModules:()=>Wr,PanResponder:()=>an,Picker:()=>bn,PixelRatio:()=>ln,Platform:()=>cn,Pressable:()=>Wn,ProgressBar:()=>kn,RefreshControl:()=>xn,SafeAreaView:()=>wn,ScrollView:()=>gt,SectionList:()=>vn,Share:()=>un,StatusBar:()=>An,StyleSheet:()=>q,Switch:()=>qn,Text:()=>x,TextInput:()=>mt,Touchable:()=>Sn,TouchableHighlight:()=>Vn,TouchableNativeFeedback:()=>Tn,TouchableOpacity:()=>P,TouchableWithoutFeedback:()=>Hn,UIManager:()=>dn,Vibration:()=>fn,View:()=>m,VirtualizedList:()=>$n,YellowBox:()=>Cn,findNodeHandle:()=>Gn,unstable_createElement:()=>Hr,useColorScheme:()=>Rn,useLocaleContext:()=>Ln,useWindowDimensions:()=>zn});Lr(ct,Vr);import*as Vr from"react-native-web";import{unstable_createElement as Hr,NativeModules as Wr,AccessibilityInfo as Jr,Appearance as qr,AppRegistry as Kr,AppState as Zr,BackHandler as Gr,Clipboard as Yr,Dimensions as Xr,Easing as Qr,I18nManager as en,Keyboard as tn,InteractionManager as rn,LayoutAnimation as nn,Linking as on,NativeEventEmitter as sn,PanResponder as an,PixelRatio as ln,Platform as cn,Share as un,UIManager as dn,Vibration as fn,CheckBox as pn,FlatList as hn,Image as mn,ImageBackground as gn,KeyboardAvoidingView as yn,Picker as bn,ProgressBar as kn,RefreshControl as xn,SafeAreaView as wn,SectionList as vn,StatusBar as An,Touchable as Sn,TouchableNativeFeedback as Tn,VirtualizedList as $n,YellowBox as Cn,LogBox as En,DeviceEventEmitter as In,useColorScheme as Rn,useLocaleContext as Ln,useWindowDimensions as zn}from"react-native-web";import*as C from"react-native-web";import{createElement as we,forwardRef as ut,useCallback as Nn,useRef as Dn}from"react";import{useEffect as On,useState as Mn}from"react";import{createPortal as Pn}from"react-dom";var Fn='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as jn}from"react/jsx-runtime";var Q=Symbol.for("@buoy-gg/portal-host"),dt=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 ft(){let e=document;if(e[Q])return e[Q].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:Fn});let r=()=>{let u=document.fullscreenElement,h=u&&u.tagName!=="CANVAS"?u:document.body;t.parentElement!==h&&h.appendChild(t)},n=new Map,o=u=>{(!t.contains(u.target)||!dt(u.target))&&n.set(u.code||u.key,{key:u.key,code:u.code,location:u.location,keyCode:u.keyCode,which:u.which,altKey:u.altKey,ctrlKey:u.ctrlKey,metaKey:u.metaKey,shiftKey:u.shiftKey})},i=u=>{n.delete(u.code||u.key)},s=()=>n.clear(),a=()=>{let u=[...n.values()];n.clear();for(let h of u)document.dispatchEvent(new KeyboardEvent("keyup",{...h,bubbles:true}))},l=u=>{dt(u.target)&&u.stopPropagation()},c=u=>u.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",o,true),document.addEventListener("keyup",i,true),window.addEventListener("blur",s),t.addEventListener("focusin",a),t.addEventListener("keydown",l),t.addEventListener("keyup",l),t.addEventListener("keypress",l),t.addEventListener("wheel",c,{passive:true}),e[Q]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",o,true),document.removeEventListener("keyup",i,true),window.removeEventListener("blur",s),t.remove(),delete e[Q]}},t}function _n({children:e}){let[t,r]=Mn(null);return On(()=>{let n=ft(),o=document[Q];return o.users++,r(n),()=>{--o.users===0&&o.dispose()}},[]),t?Pn(jn("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var W=C,Bn=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],J=e=>typeof e=="number"?`${e}px`:e;function ve(e){if(Array.isArray(e)){let h=e.map(ve);return h.some((T,$)=>T!==e[$])?h:e}if(!e||typeof e!="object"||!Bn.some(h=>e[h]!=null))return e;let{shadowColor:t,shadowOffset:r,shadowOpacity:n,shadowRadius:o,textShadowColor:i,textShadowOffset:s,textShadowRadius:a,...l}=e;if(t!=null||r!=null||n!=null||o!=null){let h=t??"black",T=n==null?h:`color-mix(in srgb, ${h} ${Math.min(n,1)*100}%, transparent)`,$=`${J(r?.width??0)} ${J(r?.height??0)} ${J(o??0)} ${T}`;l.boxShadow=typeof l.boxShadow=="string"?`${l.boxShadow}, ${$}`:l.boxShadow??$}let{width:c=0,height:u=0}=s??{};if(i&&(c||u||a)){let h=`${J(c)} ${J(u)} ${J(a??0)} ${i}`;l.textShadow=l.textShadow?`${l.textShadow}, ${h}`:h}return l}var Un=W.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function pt(e,t){if(typeof e=="function")return n=>pt(e(n),t);let r=ve(e);return t?[r,Un[t]]:r}var q={...W.StyleSheet,create:e=>W.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,ve(r)])))};function R(e){let t=ut((n,o)=>{let{accessibilityState:i,accessibilityValue:s,pointerEvents:a,...l}=n;for(let u of["busy","checked","disabled","expanded","selected"])i?.[u]!==void 0&&l[`aria-${u}`]===void 0&&(l[`aria-${u}`]=i[u]);for(let[u,h]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))s?.[u]!==void 0&&l[`aria-${h}`]===void 0&&(l[`aria-${h}`]=s[u]);let c=pt(l.style,a);return c!==l.style&&(l.style=c),we(e,{...l,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var m=R(C.View),x=R(C.Text),ht={...W.Animated,View:W.Animated.createAnimatedComponent(m),Text:W.Animated.createAnimatedComponent(x)},mt=R(C.TextInput),P=R(C.TouchableOpacity),Vn=R(C.TouchableHighlight),Hn=R(C.TouchableWithoutFeedback),Wn=R(C.Pressable),gt=R(C.ScrollView),yt=ut((e,t)=>{let r=Dn(null),n=Nn(o=>{if(o){let i=o;for(;i.parentElement&&i.parentElement!==document.body;)i=i.parentElement;i.parentElement===document.body&&(r.current=i,Object.assign(i.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),ft().appendChild(i))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(o):t&&(t.current=o)},[t]);return we(_n,null,we(C.Modal,{...e,ref:n}))});yt.displayName="Modal";var Jn=R(yt),qn=R(C.Switch),Kn=R(C.ActivityIndicator),Zn=R(C.Button),Gn=C.findNodeHandle,Yn={alert(e,t,r,n){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 i=document.createElement("h2");if(i.textContent=e,i.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(i),t){let c=document.createElement("p");c.textContent=t,c.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(c)}let s=document.createElement("div");s.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let a=r?.length?r:[{text:"OK"}],l=()=>{o.close?.(),o.remove()};for(let c of a){let u=document.createElement("button");u.type="button",u.textContent=c.text??"OK",u.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${c.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,u.onclick=()=>{l(),c.onPress?.()},s.appendChild(u)}o.addEventListener("cancel",c=>{c.preventDefault(),n?.cancelable!==false&&(l(),n?.onDismiss?.())}),o.appendChild(s),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};var Ae=Object.freeze({mode:"real",anchorReal:0,anchorVirtual:0,rate:1}),Se=.1,Te=86400,Xn=864e13;function N(e,t){return e.mode==="real"?t:e.mode==="frozen"?e.anchorVirtual:e.anchorVirtual+(t-e.anchorReal)*e.rate}function Qn(e,t){return N(e,t)-t}function K(e){if(!Number.isFinite(e)||Math.abs(e)>Xn)throw new RangeError(`Not a valid time: ${e}`);return Math.round(e)}function $e(e,t,r,n=false){return{mode:n?"frozen":"running",anchorReal:t,anchorVirtual:K(r),rate:e.mode==="real"?1:e.rate}}function eo(e,t,r){if(!Number.isFinite(r))throw new RangeError("Jump must be a number of ms");return $e(e,t,N(e,t)+r,e.mode==="frozen")}function to(e,t,r){return $e(e,t,r??N(e,t),true)}function ro(e,t){return e.mode!=="frozen"?e:{...e,mode:"running",anchorReal:t}}function no(e,t,r){if(!Number.isFinite(r)||r<Se||r>Te)throw new RangeError(`Speed must be between ${Se}\xD7 and ${Te}\xD7`);return e.mode==="real"&&r===1?e:{mode:"running",anchorReal:t,anchorVirtual:K(N(e,t)),rate:r}}function bt(e){let t=e;return!!t&&(t.mode==="real"||t.mode==="running"||t.mode==="frozen")&&Number.isFinite(t.anchorReal)&&Number.isFinite(t.anchorVirtual)&&Number.isFinite(t.rate)&&t.rate>=Se&&t.rate<=Te}var oo={ms:1,millisecond:1,milliseconds:1,s:1e3,sec:1e3,secs:1e3,second:1e3,seconds:1e3,m:6e4,min:6e4,mins:6e4,minute:6e4,minutes:6e4,h:36e5,hr:36e5,hrs:36e5,hour:36e5,hours:36e5,d:864e5,day:864e5,days:864e5,w:6048e5,wk:6048e5,week:6048e5,weeks:6048e5,mo:30*864e5,month:30*864e5,months:30*864e5,y:365*864e5,yr:365*864e5,year:365*864e5,years:365*864e5};function Ce(e){if(typeof e=="number"){if(!Number.isFinite(e))throw new RangeError("Duration must be finite");return Math.round(e)}let t=String(e).trim().toLowerCase();if(!t)throw new RangeError("Duration is empty");let r=1;if((t[0]==="+"||t[0]==="-"||t[0]==="\u2212")&&(r=t[0]==="+"?1:-1,t=t.slice(1).trim()),/^\d+(\.\d+)?$/.test(t))return r*Math.round(Number(t));let n=/(\d+(?:\.\d+)?)\s*([a-z]+)/g,o=0,i="",s;for(;s=n.exec(t);){let a=oo[s[2]];if(a===void 0)throw new RangeError(`Unknown time unit "${s[2]}" in "${e}"`);o+=Number(s[1])*a,i+=s[0]}if(!i||i.replace(/\s/g,"")!==t.replace(/[\s,]/g,""))throw new RangeError(`Could not read "${e}" as a duration. Try "+1d", "-2h30m" or "90s".`);return r*Math.round(o)}function ee(e,{signed:t=true}={}){let r=e<0?"\u2212":"+",n=Math.abs(Math.round(e));if(n<1e3)return t&&n>0?`${r}${n}ms`:"0s";let o=[],i=[["y",365*864e5],["d",864e5],["h",36e5],["m",6e4],["s",1e3]];for(let[s,a]of i)if(n>=a&&(o.push(`${Math.floor(n/a)}${s}`),n%=a),o.length===2)break;return`${t?r:""}${o.join(" ")}`}function kt(e,t,r){if(typeof e=="number")return K(e);let n=String(e).trim();if(!n)throw new RangeError("Time is empty");if(/^now$/i.test(n))return t;if(/^[+\-−]/.test(n))return K(t+Ce(n));if(/^\d{11,}$/.test(n))return K(Number(n));let o=n.replace(/^(\d{4}-\d{2}-\d{2})[ ](\d{2}:\d{2})/,"$1T$2"),i=r(o);if(!Number.isFinite(i))throw new RangeError(`Could not read "${e}" as a time. Use ISO 8601 like 2026-12-31T23:59:50, epoch ms, or "+1d".`);return K(i)}var Ee=1e4,xt=[{id:"midnight",label:"Before midnight",hint:"23:59:50 tonight",at(e,t){let r=new t(e);return r.setHours(24,0,0,0),r.getTime()-Ee}},{id:"month-end",label:"Month end",hint:"last day, 23:59:50",at(e,t){let r=new t(e);return r.setMonth(r.getMonth()+1,1),r.setHours(0,0,0,0),r.getTime()-Ee}},{id:"year-end",label:"New Year's Eve",hint:"Dec 31, 23:59:50",at(e,t){let r=new t(e);return r.setFullYear(r.getFullYear()+1,0,1),r.setHours(0,0,0,0),r.getTime()-Ee}},{id:"tomorrow-9",label:"Tomorrow 9 AM",hint:"start of a business day",at(e,t){let r=new t(e);return r.setDate(r.getDate()+1),r.setHours(9,0,0,0),r.getTime()}},{id:"leap-day",label:"Leap day",hint:"next Feb 29, 09:00",at(e,t){let r=new t(e).getFullYear();for(;;){let n=r%4===0&&r%100!==0||r%400===0,o=new t(r,1,29,9,0,0,0).getTime();if(n&&o>e)return o;r+=1}}}],vs=[{label:"1m",ms:6e4},{label:"15m",ms:15*6e4},{label:"1h",ms:36e5},{label:"1d",ms:864e5},{label:"7d",ms:7*864e5},{label:"30d",ms:30*864e5},{label:"1y",ms:365*864e5}];function wt(e){return e===3600?"1h/s":e===600?"10m/s":e===60?"1m/s":`${Number.isInteger(e)?e:e.toFixed(1)}\xD7`}import{devToolsStorageKeys as io,persistentStorage as vt}from"@buoy-gg/shared-ui/web";function so(){try{let e=globalThis.localStorage;return e?At(e.getItem(Ie)):void 0}catch{return}}var te={persist:true,showChip:true,fireTimersOnJump:true},ao=2*6e4,Ie=io.clock.state();function At(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||t.v!==1)return null;let r=t.settings??{},n=t.reload&&bt(t.reload.anchor)&&typeof t.reload.at=="number"?{anchor:t.reload.anchor,at:t.reload.at}:void 0;return{v:1,anchor:bt(t.anchor)?t.anchor:null,...n?{reload:n}:{},settings:{persist:typeof r.persist=="boolean"?r.persist:te.persist,showChip:typeof r.showChip=="boolean"?r.showChip:te.showChip,fireTimersOnJump:typeof r.fireTimersOnJump=="boolean"?r.fireTimersOnJump:te.fireTimersOnJump}}}catch{return null}}async function lo(){try{return At(await vt.getItem(Ie))}catch{return null}}var Re=Promise.resolve();function Le(e){let t=JSON.stringify(e);return Re=Re.then(()=>vt.setItem(Ie,t)).catch(()=>{}),Re.then(()=>{})}import{dispatchToolAction as co}from"@buoy-gg/shared-ui/web";import{loadToolModule as uo}from"@buoy-gg/shared-ui/web/utils";var St="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",le={};for(let e=0;e<St.length;e++)le[St[e]]=e;le["-"]=62;le._=63;function ze(e){let t=e.replace(/=+$/,""),r=[],n=0,o=0;for(let i=0;i<t.length;i++){let s=le[t[i]];if(s===void 0)return null;n=n<<6|s,o+=6,o>=8&&(o-=8,r.push(n>>o&255))}return r}function fo(e){let t="";for(let r=0;r<e.length;){let n=e[r],o,i;if(n<128)o=n,i=0;else if(n>=192&&n<224)o=n&31,i=1;else if(n>=224&&n<240)o=n&15,i=2;else if(n>=240&&n<248)o=n&7,i=3;else return null;for(let s=1;s<=i;s++){let a=e[r+s];if(a===void 0||(a&192)!==128)return null;o=o<<6|a&63}t+=String.fromCodePoint(o),r+=i+1}return t}function Ne(e){let t=ze(e);return t?Tt(t):null}function Tt(e){let t=fo(e);if(!t||t[0]!=="{")return null;try{let r=JSON.parse(t);return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}function De(e){let t=typeof e=="string"&&e.trim()!==""?Number(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>0?t*1e3:void 0}function re(e,t){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e<1e11?e*1e3:e;if(typeof e=="string"&&e.trim()!==""){let r=e.trim();if(/^\d+(\.\d+)?$/.test(r))return re(Number(r),t);let n=t(r);return Number.isFinite(n)?n:void 0}}function po(e){let t=typeof e=="string"&&/^\d+(\.\d+)?$/.test(e.trim())?Number(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}var ho=/^[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]*$/,mo=/^[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]*$/,$t=/^v([1-4])\.(local|public)\.([A-Za-z0-9_-]+)(?:\.([A-Za-z0-9_-]+))?$/,go={1:256,2:64,3:96,4:64};function F(e){if(typeof e=="string"&&e)return e;if(Array.isArray(e)){let t=e.filter(r=>typeof r=="string");return t.length?t.join(", "):void 0}}function yo(e,t){let r=e.iss??"",n=e.use;if(r.includes("securetoken.google.com"))return"Firebase ID token";if(r.includes("firebaseappcheck"))return"Firebase App Check token";if(r.includes("cognito-idp"))return n?`Cognito ${n} token`:"Cognito token";if(r.includes("appleid.apple.com"))return"Sign in with Apple token";if(r.includes("accounts.google.com"))return"Google ID token";if(r.includes(".auth0.com")||r.includes("auth0"))return"Auth0 token";if(r.includes("clerk"))return"Clerk session token";if(r.includes("supabase")||r.includes("/auth/v1"))return"Supabase access token";if(r.includes("okta"))return"Okta token";if(r.includes("/realms/"))return"Keycloak token";if(r.includes("login.microsoftonline.com")||r.includes("sts.windows.net"))return"Microsoft Entra token";let o=typeof t?.typ=="string"?t.typ.toLowerCase():"";if(o==="at+jwt"||o==="application/at+jwt")return"OAuth access token"}function bo(e,t){let r={iss:F(e.iss),aud:F(e.aud),sub:F(e.sub),scope:F(e.scope??e.scp),use:F(e.token_use)},n=De(e.exp);return{claims:r,issuedAt:De(e.iat),notBefore:De(e.nbf),expiresAt:n,expirySource:n?t:void 0}}function ko(e){let[t,r]=e.split("."),n=Ne(t);if(!n||typeof n.alg!="string"&&typeof n.typ!="string")return null;let o=Ne(r);if(!o)return null;let i=typeof n.alg=="string"?n.alg:void 0,s=bo(o,"exp claim");return s.claims.alg=i,!s.claims.use&&typeof n.typ=="string"&&n.typ.toUpperCase()!=="JWT"&&(s.claims.use=n.typ),{format:"jwt",formatLabel:i?`JWT \xB7 ${i}`:"JWT",hint:yo(s.claims,n),...s}}function xo(e){let t=Ne(e.split(".")[0]);return!t||typeof t.enc!="string"?null:{format:"jwe",formatLabel:"Encrypted JWT",claims:{alg:typeof t.alg=="string"?t.alg:void 0}}}function wo(e,t){let r=$t.exec(e);if(!r)return null;let[,n,o,i]=r;if(o==="local")return{format:"paseto-local",formatLabel:`PASETO v${n} (encrypted)`,claims:{}};let s=ze(i),a=go[n],l=s&&s.length>a?Tt(s.slice(0,s.length-a)):null,c={format:"paseto-public",formatLabel:`PASETO v${n}`,claims:{}};return l&&(c.claims={iss:F(l.iss),aud:F(l.aud),sub:F(l.sub)},c.issuedAt=re(l.iat,t),c.notBefore=re(l.nbf,t),c.expiresAt=re(l.exp,t),c.expiresAt&&(c.expirySource="exp claim")),c}function vo(e){if(!e.startsWith("gAAAAA")||e.length<76)return null;let t=ze(e);if(!t||t[0]!==128||t.length<73||(t.length-57)%16!==0)return null;let r=0;for(let n=1;n<=8;n++)r=r*256+t[n];return r<978307200||r>4102444800?null:{format:"fernet",formatLabel:"Fernet",claims:{},issuedAt:r*1e3}}var Ao=[{test:/^ya29\./,hint:"Google OAuth access token"},{test:/^gh[opsu]_/,hint:"GitHub token"},{test:/^github_pat_/,hint:"GitHub token"},{test:/^xox[abeprs]-/,hint:"Slack token"},{test:/^EAA[A-Za-z0-9]{40,}/,hint:"Facebook access token"},{test:/^shp(at|ca|pa|ss)_/,hint:"Shopify token"},{test:/^(sk|rk|pk)_(live|test)_/,hint:"Stripe API key",neverExpires:true},{test:/^AIza[0-9A-Za-z_-]{35}$/,hint:"Google API key",neverExpires:true}];function ce(e,t=Date.parse){let r=e.trim().replace(/^"(.*)"$/,"$1");if(r.length<16||/\s/.test(r))return null;if(ho.test(r)){let i=ko(r);if(i)return i}if(mo.test(r)){let i=xo(r);if(i)return i}if(r.startsWith("v")&&$t.test(r)){let i=wo(r,t);if(i)return i}let n=vo(r);if(n)return n;let o=Ao.find(i=>i.test.test(r));return{format:"opaque",formatLabel:"Opaque",hint:o?.hint,neverExpires:o?.neverExpires,claims:{}}}function So(e){return!!e&&e.format!=="opaque"}function j(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,"0")}function Oe(e){let t=/^([a-z][a-z0-9+.-]*:\/\/[^/?#]+)/i.exec(e);return t?t[1].toLowerCase():null}function To(e){let t=Oe(e);return t?t.replace(/^[a-z][a-z0-9+.-]*:\/\//,""):"unknown"}function Me(e){return e.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/?#]+/i,"").split(/[?#]/)[0]||"/"}function $o(e){let t=e.split("#")[0].split("?")[1];if(!t)return[];let r=[];for(let n of t.split("&")){let o=n.indexOf("=");if(!(o<=0))try{r.push([decodeURIComponent(n.slice(0,o)),decodeURIComponent(n.slice(o+1))])}catch{}}return r}var Pe=/(token|jwt|session|auth|appcheck|api[-_]?key|apikey|credential|bearer)/i,Co=new Set(["authorization","cookie","dpop","idempotency-key","x-request-id","x-correlation-id","www-authenticate","proxy-authenticate","x-csrf-token","x-xsrf-token"]),Ct=new Set(["access_token","accesstoken","id_token","token","auth","auth_token","jwt","session","session_token"]),Eo=new Set(["bearer","token","jwt","dpop","oauth","firebase"]);function Et(e){let t={};if(!e)return t;for(let[r,n]of Object.entries(e))typeof n=="string"?t[r.toLowerCase()]=n:Array.isArray(n)&&(t[r.toLowerCase()]=n.join(", "));return t}function Io(e){let t=[];for(let r of e.split(";")){let n=r.indexOf("=");n<=0||t.push([r.slice(0,n).trim(),r.slice(n+1).trim()])}return t}function ne(e,t,r){let n=ce(e,r);return n&&(So(n)||n.hint||t)?n:null}function It(e,t){let r=[],n=Et(e.requestHeaders),o=n.authorization;if(o){let i=/^(\S+)\s+(\S+)$/.exec(o.trim()),s=i?i[1]:void 0,a=i?i[2]:o.trim();if(!s||Eo.has(s.toLowerCase())){let l=ne(a,true,t)??(s&&!/^(null|undefined)$/i.test(a)?{format:"opaque",formatLabel:"Opaque",claims:{}}:null);l&&r.push({location:"authorization",name:"Authorization",scheme:s,fp:j(a),info:l})}}for(let[i,s]of Object.entries(n)){if(Co.has(i)||!Pe.test(i))continue;let a=s.replace(/^bearer\s+/i,""),l=ne(a,true,t);l&&r.push({location:"header",name:i,fp:j(a),info:l})}if(n.cookie)for(let[i,s]of Io(n.cookie)){let a=ne(s,Pe.test(i)||/^(sid|sess)/i.test(i),t);a&&r.push({location:"cookie",name:i,fp:j(s),info:a})}for(let[i,s]of $o(e.url)){let a=ne(s,Ct.has(i.toLowerCase()),t);a&&Ct.has(i.toLowerCase())&&r.push({location:"query",name:i,fp:j(s),info:a})}return r}var Ro=/^(access_?token|accesstoken|token|jwt|auth_?token|session_?token|sessiontoken)$/i,Rt=/^(id_?token|idtoken)$/i,ue=/^(refresh_?token|refreshtoken)$/i,Lo=["expires_in","expiresIn","ExpiresIn","expires","ttl"],zo=["expires_at","expiresAt","ExpiresAt","expiration","Expiration","expiry","expirationTime","expiration_time","access_token_expires_at","accessTokenExpiresAt","accessTokenExpiry"],No=["refresh_expires_in","refresh_token_expires_in","refreshTokenExpiresIn","refreshExpiresIn"],Do=["refresh_expires_at","refreshTokenExpiresAt","refresh_token_expires_at"];function Oo(e){if(typeof e!="string")return e;let t=e.trim();if(!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function Fe(e,t,r){if(t>4||!e||typeof e!="object")return;if(Array.isArray(e)){for(let o of e.slice(0,5))Fe(o,t+1,r);return}let n=e;for(let[o,i]of Object.entries(n))typeof i=="string"&&(Ro.test(o)||Rt.test(o)||ue.test(o))?r.push({key:o,value:i,holder:n}):i&&typeof i=="object"&&Fe(i,t+1,r)}function Mo(e){return ue.test(e)?"refresh":Rt.test(e)?"id":/session/i.test(e)?"session":"access"}function Lt(e,t,r,n,o){for(let i of t){let s=po(e[i]);if(s!==void 0)return{expiresAt:n+s*1e3,source:i,lifetimeMs:s*1e3}}for(let i of r){let s=re(e[i],o);if(s!==void 0)return{expiresAt:s,source:i}}return{}}function Po(e){let t=e["set-cookie"];return t?t.split(/,(?=\s*[A-Za-z0-9!#$%&'*+.^_`|~-]+=)/).map(r=>r.trim()):[]}function Fo(e,t){if(e.status===void 0||e.status>=400)return[];let r=`${e.method.toUpperCase()} ${Me(e.url)}`,n=e.timestamp+(e.duration??0),o=[],i=Oo(e.responseData);if(i){let a=[];Fe(i,0,a);let l=new Map;for(let c of a.filter(u=>ue.test(u.key))){let u=ce(c.value,t);if(!u)continue;let h=Lt(c.holder,No,Do,n,t);l.set(c.holder,{fp:j(c.value),expiresAt:u.expiresAt??h.expiresAt,formatLabel:u.formatLabel})}for(let c of a){if(ue.test(c.key))continue;let u=ce(c.value,t);if(!u)continue;let h=Lt(c.holder,Lo,zo,n,t);o.push({fp:j(c.value),info:u,role:Mo(c.key),expiresAt:h.expiresAt,expirySource:h.source,lifetimeMs:h.lifetimeMs,issuedBy:r,refresh:l.get(c.holder)})}}let s=Et(e.responseHeaders);for(let a of Po(s)){let[l,...c]=a.split(";"),u=l.indexOf("=");if(u<=0)continue;let h=l.slice(0,u).trim(),T=l.slice(u+1).trim(),$=ne(T,Pe.test(h)||/^(sid|sess)/i.test(h),t);if(!$||T===""||T.toLowerCase()==="deleted")continue;let E,O,U;for(let Cr of c){let[Er,...Ir]=Cr.split("="),ot=Er.trim().toLowerCase(),xe=Ir.join("=").trim();if(ot==="max-age"&&/^-?\d+$/.test(xe))U=Number(xe)*1e3,E=n+U,O="Max-Age";else if(ot==="expires"&&O!=="Max-Age"){let it=t(xe);Number.isFinite(it)&&(E=it,O="Expires")}}o.push({fp:j(T),info:$,role:"cookie",cookie:h,expiresAt:$.expiresAt??E,expirySource:$.expiresAt?$.expirySource:O,lifetimeMs:$.expiresAt?void 0:U,issuedBy:r})}return o}var je=e=>M.parse(e),zt=4,Nt=2e4,jo=8,_o=8,Bo=200,Uo=1e3,I=new Map,Z=new Map,Vo=new Set,Ho=new Set,Dt=new Set,Wo=/(token|refresh|oauth|session|auth\/)/i,f=null,de=new Set,fe=true,_e=null,Be=new Set,Ue=false;function oe(){Ue||(Ue=true,Promise.resolve().then(()=>{Ue=false,Be.forEach(e=>e())}))}function Jo(e){return Be.add(e),()=>{Be.delete(e)}}function Ve(e,t){if(e.has(t))return false;if(e.size>=Uo){let r=e.values().next().value;r!==void 0&&e.delete(r)}return e.add(t),true}function He(e,t){return`${e}|${t.location}:${t.name.toLowerCase()}`}function Ot(e,t){let r=t?.lifetimeMs!==void 0&&t.expiresAt!==void 0,n=r?t.expiresAt:e.expiresAt??t?.expiresAt,o=e.expiresAt??(r?t.observedReal+t.lifetimeMs:t?.expiresAt),i=r?t.expirySource:e.expiresAt?e.expirySource:t?.expirySource,s=r?t.lifetimeMs:e.expiresAt!==void 0&&e.issuedAt!==void 0?e.expiresAt-e.issuedAt:void 0;return{expiresAt:n,serverExpiresAt:o,source:i,lifetimeMs:s}}function We(e,t,r,n,o){let i=Z.get(t),s=Ot(r,i),a=e.fp!==t;a&&(e.history.unshift({fp:e.fp,firstSeenReal:e.firstSeenReal,expiresAt:e.expiresAt}),e.history.length=Math.min(e.history.length,_o),e.fp=t,e.firstSeenReal=n,e.firstSeenApp=o,e.uses=0,e.expiredSends=0,e.rejected=0),e.info=r,e.role=i?.role??(a?void 0:e.role),e.issuedBy=i?.issuedBy??(a?void 0:e.issuedBy),e.refresh=i?.refresh??(a?void 0:e.refresh),e.expiresAt=s.expiresAt,e.serverExpiresAt=s.serverExpiresAt,e.expirySource=s.source,e.lifetimeMs=s.lifetimeMs,a&&qo(e,n)}function Mt(e,t,r,n,o){let i=Z.get(r.fp),s=Ot(r.info,i);return{key:e,origin:t,host:To(t),location:r.location,name:r.name,scheme:r.scheme,fp:r.fp,info:r.info,role:i?.role,issuedBy:i?.issuedBy,refresh:i?.refresh,expiresAt:s.expiresAt,serverExpiresAt:s.serverExpiresAt,expirySource:s.source,lifetimeMs:s.lifetimeMs,firstSeenReal:n,firstSeenApp:o,lastUsedReal:n,lastUsedApp:o,uses:0,expiredSends:0,rejected:0,history:[]}}function Pt(){if(I.size<=jo)return;let e=null;for(let t of I.values())(!e||t.lastUsedReal<e.lastUsedReal)&&(e=t);e&&e.key!==f?.tokenId&&I.delete(e.key)}function qo(e,t){!f||f.tokenId!==e.key||(f.newTokens+=1,f.status==="waiting"&&(f.status="refreshed",f.refreshedAt=t,f.ruleId&&f.forcedAt===void 0&&co("network","deleteOverrideRule",{id:f.ruleId}).catch(()=>{})),f.newTokens>=zt&&t-(f.refreshedAt??t)<=Nt&&(f.status="loop"))}function Ko(e){let t=Oe(e.url);if(!t)return;let r=It(e,je);if(r.length===0)return;let n=A(),o=e.timestamp;for(let i of r){let s=He(t,i),a=I.get(s);a?We(a,i.fp,i.info,n,o):(a=Mt(s,t,i,n,o),I.set(s,a),Pt()),a.uses+=1,a.lastUsedReal=n,a.lastUsedApp=o,a.expiresAt!==void 0&&o>=a.expiresAt&&(a.expiredSends+=1),f&&f.tokenId===s&&f.forcedAt!==void 0&&i.fp===f.startFp&&(f.staleAfterFailure+=1,Ve(de,e.id))}oe()}function Zo(e){let t=Oe(e.url);if(!t)return;let r=A(),n=false;if(e.status===401||e.status===403)for(let l of It(e,je)){let c=I.get(He(t,l));c&&c.fp===l.fp&&(c.rejected+=1,n=true)}let o=!!f?.ruleId&&e.override?.ruleId===f.ruleId,i=`${e.method.toUpperCase()} ${Me(e.url)}`,s=Dt.has(i)||e.method.toUpperCase()==="POST"&&Wo.test(Me(e.url)),a=e.status??0;f&&a>=400&&!o&&s&&(f.failedRefreshes+=1,f.lastRefreshError=`${e.status} ${i}`,n=true),f?.status==="waiting"&&f.forcedAt!==void 0&&!o&&a>=200&&a<400&&(s&&f.refreshOkAt===void 0?(f.refreshOkAt=r,n=true):!s&&f.refreshOkAt!==void 0&&de.has(e.id)&&(f.status="refreshed",f.refreshedAt=r,f.sameToken=true,n=true)),f?.ruleId&&e.override?.ruleId===f.ruleId&&f.forcedAt===void 0&&(f.forcedAt=r,n=true);for(let l of Fo(e,je)){if(Dt.add(l.issuedBy),Z.set(l.fp,{...l,observedReal:r}),Z.size>Bo){let c=Z.keys().next().value;c!==void 0&&Z.delete(c)}if(n=true,l.cookie){let c={location:"cookie",name:l.cookie,fp:l.fp,info:l.info},u=He(t,c),h=I.get(u);h?We(h,l.fp,l.info,r,e.timestamp):(I.set(u,Mt(u,t,c,r,e.timestamp)),Pt());continue}for(let c of I.values())c.fp===l.fp&&We(c,l.fp,c.info,r,c.lastUsedApp)}n&&oe()}function Go(e){let t=e;!t||typeof t.id!="string"||typeof t.url!="string"||(Ve(Vo,t.id)&&Ko(t),t.status!==void 0&&Ve(Ho,t.id)&&Zo(t))}function pe(){if(_e)return true;try{let{networkEventStore:e}=uo("@buoy-gg/network");if(!e?.onEvent)throw new Error("no event store");_e=e.onEvent(Go,true),fe=true}catch{fe=false}return oe(),fe}function Ft(e,t,r){let n=I.get(t);if(!n)throw new Error(`No token row "${t}".`);return f={kind:e,tokenId:t,startedAt:A(),startFp:n.fp,ruleId:r,status:"waiting",newTokens:0,staleAfterFailure:0,failedRefreshes:0},de.clear(),oe(),f}function Yo(){f=null,de.clear(),oe()}function Xo(e){return e.location==="cookie"?`${e.name} cookie`:e.location==="query"?`${e.name} parameter`:e.location==="header"?`${e.name} header`:e.role==="id"||e.info.claims.use==="id"?"ID token":"Access token"}function Qo(e,t){let r=[e.firstSeenReal,...e.history.map(o=>o.firstSeenReal)].slice(0,-1).filter(o=>t-o<=Nt).length,n=e.info.issuedAt;return{id:e.key,label:Xo(e),host:e.host,location:e.location,name:e.name,scheme:e.scheme,format:e.info.format,formatLabel:e.info.formatLabel,hint:e.info.hint,claims:e.info.claims,fingerprint:e.fp,issuedAt:n,notBefore:e.info.notBefore,expiresAt:e.expiresAt,serverExpiresAt:e.serverExpiresAt,expirySource:e.expirySource,lifetimeMs:e.lifetimeMs,neverExpires:e.info.neverExpires,issuedBy:e.issuedBy,refresh:e.refresh?{expiresAt:e.refresh.expiresAt,formatLabel:e.refresh.formatLabel}:void 0,firstUsed:e.firstSeenApp,lastUsed:e.lastUsedApp,lastUsedReal:e.lastUsedReal,uses:e.uses,refreshes:e.history.length,lastRefreshAt:e.history.length?e.firstSeenReal:void 0,recentRefreshes:r,looping:r>=zt,expiredSends:e.expiredSends,rejected:e.rejected}}function he(){let e=A(),t=[...I.values()].sort((r,n)=>n.lastUsedReal-r.lastUsedReal).map(r=>Qo(r,e));if(f?.status==="refreshed"){let r=I.get(f.tokenId);r&&(f.newLifetimeMs=r.lifetimeMs,f.newIssuedBy=r.issuedBy)}return{available:fe,watching:_e!==null,tokens:t,check:f?{...f}:null}}function ei(e){let t=he();return e?t.tokens.find(r=>r.id===e||r.fingerprint===e)??null:t.tokens.find(r=>r.expiresAt!==void 0)??t.tokens[0]??null}function ti(e){return I.get(e)?.origin??null}import{isProNow as jt}from"@buoy-gg/shared-ui/web";var p={anchor:Ae,settings:te,lastJump:null,changedAt:null,hydrated:false},Je=new Set,me=null;function _t(){me=null,Je.forEach(e=>e())}Jo(_t);function ie(e){return Je.add(e),()=>{Je.delete(e)}}function ri(){return p.settings}function Bt(){return N(p.anchor,A())}function Ut(){return p.anchor.mode!=="real"}function ni(e){if(e.mode==="real"){at(null),Mr();return}lt(),at(t=>N(p.anchor,t)),Or()}function oi(){let e={v:1,anchor:p.settings.persist&&jt()?p.anchor:null,settings:p.settings};Le(e)}function Vt(){let e={v:1,anchor:p.settings.persist&&jt()?p.anchor:null,settings:p.settings};return p.settings.persist&&p.anchor.mode!=="real"&&(e.reload={anchor:p.anchor,at:A()}),Le(e)}function G(e,{save:t=true}={}){p={...p,...e},e.anchor&&ni(p.anchor),t&&oi(),_t()}function Y(e,t=p.lastJump){G({anchor:e,lastJump:t,changedAt:A(),hydrated:true})}var Ht=e=>M.parse(e);function Wt(e,t=false){let r=A(),n=N(p.anchor,r),o=kt(e,n,Ht),i=o-n;return Y($e(p.anchor,r,o,t),{byMs:i,firedTimers:0,at:r}),S()}function qe(e,t){let r=Ce(e),n=A(),o=eo(p.anchor,n,r),i=(t??p.settings.fireTimersOnJump)&&r>0;if(Y(o,{byMs:r,firedTimers:0,at:n}),i){let s=Ur(r);s>0&&G({lastJump:{byMs:r,firedTimers:s,at:n}},{save:false})}return S()}function Ke(e){let t=A(),r=N(p.anchor,t),n=e===void 0||e===""?r:kt(e,r,Ht);return Y(to(p.anchor,t,n)),S()}function Ze(){return p.anchor.mode==="frozen"&&Y(ro(p.anchor,A())),S()}function Jt(e){return Y(no(p.anchor,A(),Number(e))),S()}function Ge(){return Y(Ae,null),S()}function qt(e){let t={...p.settings};for(let r of Object.keys(te))typeof e[r]=="boolean"&&(t[r]=e[r]);return G({settings:t}),S()}function ii(e){return e>0?Br(e):0}var Kt=false;function Zt(e){if(!e){G({hydrated:true},{save:false});return}let t=e.reload?A()-e.reload.at:1/0,r=t>=0&&t<ao?e.reload?.anchor:void 0;e.reload&&Le({v:1,anchor:e.anchor,settings:e.settings});let n=e.anchor??r??null;G({settings:e.settings,anchor:n??Ae,changedAt:n?A():null,hydrated:true},{save:false})}function Ye(){if(Kt)return;Kt=true,lt();let e=so();if(e!==void 0){Zt(e);return}lo().then(t=>{p.changedAt===null?Zt(t):G({hydrated:true},{save:false})})}function si(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone??"unknown"}catch{return"unknown"}}function S(){let e=A(),t=N(p.anchor,e);return{mode:p.anchor.mode,active:p.anchor.mode!=="real",rate:p.anchor.rate,virtualNow:t,virtualIso:new M(t).toISOString(),realNow:e,offsetMs:Qn(p.anchor,e),timeZone:si(),timers:_r(),lastJump:p.lastJump,changedAt:p.changedAt,settings:p.settings,hydrated:p.hydrated,tokens:he(),patched:{date:Nr(),intl:Dr(),timers:jr(),animatedOnRealClock:Fr()}}}function Gt(){return me||(me=S()),me}import{useSyncExternalStore as ai}from"react";import{ClockToolIcon as Yt,FloatingTool as li,Pause as ci,Play as ui,X as di,dismissFloatingTool as fi,getFloatingTools as pi,getUseIsPro as hi,night as se,openFloatingTool as Xt}from"@buoy-gg/shared-ui/web";import{useEffect as mi,useState as gi}from"react";function _(e,t=250){let[,r]=gi(0);mi(()=>{let s=setInterval(()=>r(a=>a+1),t);return()=>clearInterval(s)},[t]);let n=A();if(!e)return{virtual:n,real:n};let o=n-e.realNow,i=e.mode==="real"?1:e.rate;return{virtual:e.mode==="frozen"?e.virtualNow:e.virtualNow+o*i,real:n}}var D=e=>String(e).padStart(2,"0");function X(e){let t=new M(e);return`${D(t.getHours())}:${D(t.getMinutes())}:${D(t.getSeconds())}`}var yi=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Qt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function bi(e){let t=new M(e);return`${yi[t.getDay()]}, ${Qt[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`}function ge(e,t=true){let r=new M(e),n=t?X(e):`${D(r.getHours())}:${D(r.getMinutes())}`;return`${Qt[r.getMonth()]} ${r.getDate()} \xB7 ${n}`}function er(e){let t=new M(e);return`${t.getFullYear()}-${D(t.getMonth()+1)}-${D(t.getDate())} ${D(t.getHours())}:${D(t.getMinutes())}`}function ki(e){if(Math.abs(e)<1e3)return"matches real time";let t=ee(Math.abs(e),{signed:false});return e>0?`${t} ahead of real time`:`${t} behind real time`}function tr(e){return e.mode==="real"?{label:"Real time",tone:"neutral"}:e.mode==="frozen"?{label:"Frozen",tone:"info"}:e.rate!==1?{label:`${wt(e.rate)} speed`,tone:"warning"}:{label:"Overridden",tone:"accent"}}function xi(e){return`clock-jump-${e<0?"minus":"plus"}-${ee(Math.abs(e),{signed:false}).replace(/\s/g,"")}`}import{jsx as L,jsxs as Xe}from"react/jsx-runtime";var ye="clock-chip",rr={id:ye,render:e=>L(ir,{...e})},wi=()=>pi().some(e=>e.id===ye);function vi(){Xt(rr)}var nr=false;function or(){if(nr)return;nr=true;let e=false,t=()=>{let r=Ut()&&ri().showChip;r&&!e?Xt(rr):!r&&wi()&&fi(ye),e=r};ie(t),t()}function ir({id:e,revealToken:t}){let r=ai(ie,Gt,Gt),{virtual:n,real:o}=_(r),i=r.mode==="frozen",s=hi()(),a=i||s,l=tr(r),c=n-o,u=`${Math.abs(c)<1e3?"0s":ee(c)} \xB7 ${l.label.toLowerCase()}`;return L(li,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:`Move or hide the clock chip. App time ${ge(n)}`,handleAdornment:L(Yt,{size:12}),children:Xe(m,{style:V.row,children:[L(Yt,{size:18}),Xe(m,{style:V.text,children:[L(x,{style:V.time,numberOfLines:1,testID:"clock-chip-time",children:ge(n)}),L(x,{style:V.detail,numberOfLines:1,testID:"clock-chip-detail",children:u})]}),a?Xe(P,{testID:i?"clock-chip-resume":"clock-chip-freeze",accessibilityRole:"button",accessibilityLabel:i?"Resume the app clock":"Freeze the app clock",onPress:()=>i?Ze():Ke(),style:V.button,hitSlop:{top:8,bottom:8,left:4,right:4},children:[i?L(ui,{size:16,color:se.color.accent}):null,i?null:L(ci,{size:16,color:se.color.text})]}):null,a?L(m,{style:V.separator}):null,L(P,{testID:"clock-chip-reset",accessibilityRole:"button",accessibilityLabel:"Back to real time",onPress:()=>Ge(),style:V.button,hitSlop:{top:8,bottom:8,left:4,right:8},children:L(di,{size:16,color:se.color.textSecondary})})]})})}var V=q.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingLeft:10,paddingRight:4,paddingVertical:6,minWidth:220},text:{flexShrink:1,minWidth:120},time:{color:"#F59E0B",fontSize:14,fontWeight:"600",fontVariant:["tabular-nums"]},detail:{color:se.color.textSecondary,fontSize:11,fontVariant:["tabular-nums"]},button:{width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:16},separator:{width:q.hairlineWidth,height:20,backgroundColor:se.color.separator}});import{ClockToolIcon as Ai,CLOCK_TOOL_ICON_COLOR as Si,createToolFactory as Ti,defineToolPreset as $i}from"@buoy-gg/shared-ui/web";import{useEffect as sr,useState as Ci}from"react";import{reloadApp as Ei}from"@buoy-gg/shared-ui/web";import{createSyncAdapter as Ii}from"@buoy-gg/shared-ui/web";import{dispatchToolAction as ar}from"@buoy-gg/shared-ui/web";var lr="No sign-in token seen yet. Use the app so it sends a signed-in request, then try again. Tokens are read from the Network tool's captured requests.";function cr(e){pe();let t=ei(e);if(!t)throw new Error(e?`No token "${e}". Read getState for the current ids.`:lr);return t}function ur(e,t=1e4){let r=cr(e);if(r.expiresAt===void 0)throw new Error(r.neverExpires?`${r.label} for ${r.host} is ${r.hint??"a key"} and never expires.`:`${r.label} for ${r.host} (${r.formatLabel}) has no expiry Buoy can read. Use failNextRequest to test the refresh instead.`);let n=r.expiresAt-Math.max(0,t)-Bt();if(n<=0)throw new Error(`${r.label} for ${r.host} has already expired on the app's clock. Go back to real time, or use failNextRequest.`);return qe(n),Ft("expiry",r.id),S()}async function dr(e,t=401,r=1){let n=cr(e),o=ti(n.id);if(!o)throw new Error(lr);await fr();let i=t===403?403:401,s=n.location==="authorization"||n.location==="header"?{urlPattern:`${o}/*`,requireHeader:n.name.toLowerCase()}:n.location==="query"?{urlPattern:`${o}/*${n.name}=*`}:{urlPattern:`${o}/*`},a=await ar("network","upsertOverrideRule",{name:"Clock: force a token refresh",...s,kind:"respond",status:i,headers:{"content-type":"application/json","www-authenticate":'Bearer error="invalid_token", error_description="The access token expired"'},body:JSON.stringify({error:"invalid_token",error_description:"The access token expired (forced by Buoy Clock to test token refresh)"}),times:Math.max(1,Math.min(10,Math.round(r)))}).catch(l=>{let c=l instanceof Error?l.message:String(l);throw new Error(c.includes("Unknown tool")?"Failing a request needs the Network tool (@buoy-gg/network).":c)});if(!a?.ok||!a.rule)throw new Error(a?.error??"Network did not add the override.");return Ft("401",n.id,a.rule.id),S()}async function fr(){let e=he().check;e?.ruleId&&e.forcedAt===void 0&&await ar("network","deleteOverrideRule",{id:e.ruleId}).catch(()=>{})}async function pr(){return await fr(),Yo(),S()}function H(e){return e&&typeof e=="object"?e:{}}function Qe(e,...t){for(let r of t){let n=e[r];if(typeof n=="string"||typeof n=="number")return n}}function ae(e,t){let r=e[t];if(typeof r=="boolean")return r;if(r==="true")return true;if(r==="false")return false}var hr=Ii({version:1,getSnapshot(){return S()},subscribe(e){return ie(e)},actions:{getState(){return pe(),S()},setTime(e){let t=H(e),r=Qe(t,"time","at","date","iso");if(r===void 0)throw new Error('setTime needs `time`: ISO 8601 ("2026-12-31T23:59:50"), epoch ms, or relative ("+1d").');return Wt(r,ae(t,"freeze")??false)},shift(e){let t=H(e),r=Qe(t,"by","ms","duration","delta");if(r===void 0)throw new Error('shift needs `by`: a duration like "+1d", "-2h30m", "90s", or ms.');return qe(r,ae(t,"fireTimers"))},freeze(e){return Ke(Qe(H(e),"time","at"))},resume(){return Ze()},setRate(e){let t=H(e),r=Number(t.rate??t.speed);if(!Number.isFinite(r))throw new Error("setRate needs a numeric `rate` (1 = normal speed).");return Jt(r)},reset(){return Ge()},updateSettings(e){let t=H(e);return qt({persist:ae(t,"persist"),showChip:ae(t,"showChip"),fireTimersOnJump:ae(t,"fireTimersOnJump")})},jumpToTokenExpiry(e){let t=H(e),r=typeof t.token=="string"?t.token:typeof t.id=="string"?t.id:void 0,n=Number(t.leadMs??t.lead??1e4);return ur(r,Number.isFinite(n)?n:1e4)},failNextRequest(e){let t=H(e),r=typeof t.token=="string"?t.token:typeof t.id=="string"?t.id:void 0,n=Number(t.status??401),o=Number(t.times??1);return dr(r,n,Number.isFinite(o)?o:1)},stopTokenCheck(){return pr()},async holdForReload(){return await Vt(),S()}}});import{useState as be}from"react";import{ChevronRight as Ri,NightButton as Li,NightCard as ke,NightChip as zi,NightFootnote as et,NightRows as tt,NightSectionLabel as mr,NightSegmented as Ni,NightSwitch as gr,ProBadge as Di,ProUpgradeModal as Oi,getUseIsPro as Mi,monoFont as Pi,night as b,useSafeAreaInsets as Fi}from"@buoy-gg/shared-ui/web";import{ChevronRight as ji,NightButton as yr,NightCard as _i,NightFootnote as Bi,NightRows as Ui,NightSectionLabel as Vi,ProBadge as Hi,night as k}from"@buoy-gg/shared-ui/web";import{jsx as w,jsxs as z}from"react/jsx-runtime";var B=e=>ee(Math.abs(e),{signed:false});function Wi({snapshot:e,run:t,openId:r,onToggle:n,isPro:o,onUpgrade:i}){let s=e.tokens;return z(m,{children:[w(Vi,{children:s.tokens.length>1?"Sign-in tokens":"Sign-in token"}),w(_i,{children:z(Ui,{children:[s.tokens.map((a,l)=>z(m,{children:[w(Ji,{token:a,snapshot:e,index:l,open:r===a.id,onPress:()=>n(a.id)}),r===a.id?w(qi,{token:a,snapshot:e,run:o?t:()=>i("Sign-in token tests"),isPro:o}):null]},a.id)),s.tokens.length===0?w(m,{style:y.row,testID:"clock-token-empty",children:w(x,{style:y.emptyText,children:s.available?"No token seen yet":"Needs the Network tool"})},"empty"):null]})}),w(Zi,{check:s.check,tokens:s.tokens,snapshot:e,run:t}),s.tokens.length===0?w(Bi,{children:s.available?"Tokens show up here when the app sends a signed-in request.":"Install @buoy-gg/network so the Clock tool can read the app's tokens."}):null]})}function Ji({token:e,snapshot:t,index:r,open:n,onPress:o}){let{virtual:i}=_(t,1e3),s=e.expiresAt!==void 0?e.expiresAt-i:void 0,a=e.neverExpires?"No expiry":s===void 0?"Unknown":s<=0?"Expired":B(s),l=s!==void 0&&s<=0?y.valueDanger:s!==void 0&&s<6e4?y.valueWarning:null;return z(P,{testID:`clock-token-${r}`,accessibilityRole:"button",accessibilityLabel:`${e.label} for ${e.host}: ${s!==void 0&&s>0?`expires in ${a}`:a}`,accessibilityState:{expanded:n},activeOpacity:.6,onPress:o,style:y.row,children:[z(m,{style:y.rowText,children:[w(x,{style:y.rowTitle,numberOfLines:1,children:e.label}),w(x,{style:y.rowSubtitle,numberOfLines:1,children:`${e.host} \xB7 ${e.hint??e.formatLabel}`})]}),z(m,{style:y.rowRight,children:[w(x,{style:[y.value,l],testID:`clock-token-${r}-left`,children:a}),w(m,{style:n?y.chevronOpen:null,children:w(ji,{size:16,color:k.color.textTertiary})})]})]})}function qi({token:e,snapshot:t,run:r,isPro:n}){let{virtual:o,real:i}=_(t,1e3),s=Ki(e,o,i),a=e.expiresAt!==void 0&&e.expiresAt-o>1e4;return z(m,{style:y.detail,testID:"clock-token-detail",children:[s.map(l=>w(x,{style:[y.detailLine,l.tone==="warn"?y.warn:null,l.tone==="bad"?y.bad:null],children:l.text},l.text)),z(m,{style:y.buttons,children:[w(m,{style:y.button,children:w(yr,{label:"Jump to Expiry",testID:"clock-token-jump",accessibilityLabel:"Jump the app's clock to ten seconds before this token expires",size:"md",disabled:!a,onPress:()=>r("jumpToTokenExpiry",{token:e.id})})}),w(m,{style:y.button,children:w(yr,{label:"Fail Next Request",testID:"clock-token-fail",accessibilityLabel:"Answer the app's next request to this API with 401",size:"md",onPress:()=>r("failNextRequest",{token:e.id})})})]}),n?null:z(m,{style:y.proLine,children:[w(Hi,{}),w(x,{style:[y.hint,y.proHint],children:"Jump to Expiry and Fail Next Request are part of Buoy Pro."})]}),w(x,{style:y.hint,children:a||e.expiresAt===void 0?"Jump tests an app that refreshes before expiry. Fail tests one that refreshes after a 401.":"This token has already expired on the app's clock. Use Real Time to jump to it again."})]})}function Ki(e,t,r){let n=[];if(e.expiresAt!==void 0){if(n.push({text:`Expires ${ge(e.expiresAt)}`}),e.lifetimeMs!==void 0&&e.lifetimeMs>0&&n.push({text:`Lasts ${B(e.lifetimeMs)}${e.expirySource?`, from ${e.expirySource}`:""}`}),e.serverExpiresAt!==void 0){let o=e.expiresAt-t,i=e.serverExpiresAt-r;Math.abs(o-i)>2e3&&n.push({text:i>0?`The server still accepts it for ${B(i)}`:`The server stopped accepting it ${B(i)} ago`})}}else e.neverExpires||n.push({text:"The token doesn't say when it expires, and no login response did either."});if(e.hint&&n.push({text:e.formatLabel}),e.issuedBy&&n.push({text:`Issued by ${e.issuedBy}`}),e.refresh?.expiresAt!==void 0){let o=e.refresh.expiresAt-t;n.push({text:o>0?`Refresh token expires in ${B(o)}`:"Refresh token expired"})}return e.refreshes>0&&e.lastRefreshAt!==void 0&&n.push({text:`Refreshed ${e.refreshes===1?"once":`${e.refreshes} times`}, last at ${X(e.lastRefreshAt)}`}),n.push({text:`Sent with ${e.uses} request${e.uses===1?"":"s"}`}),e.expiredSends>0&&n.push({text:`Sent ${e.expiredSends} time${e.expiredSends===1?"":"s"} after it expired on the app's clock`,tone:"warn"}),e.rejected>0&&n.push({text:`Rejected by the server ${e.rejected} time${e.rejected===1?"":"s"}`,tone:"warn"}),e.looping&&n.push({text:`Refresh loop: ${e.recentRefreshes} new tokens in 20s`,tone:"bad"}),n}function Zi({check:e,tokens:t,snapshot:r,run:n}){let{virtual:o,real:i}=_(r,1e3);if(!e)return null;let s=t.find(c=>c.id===e.tokenId),{text:a,tone:l}=Gi(e,s,o,i);return z(m,{style:y.check,children:[w(x,{style:[y.checkText,l==="good"?y.good:null,l==="bad"?y.bad:null,l==="warn"?y.warn:null],testID:"clock-token-check",children:a}),w(P,{testID:"clock-token-check-done",accessibilityRole:"button",accessibilityLabel:e.status==="waiting"?"Stop the refresh check":"Dismiss",onPress:()=>n("stopTokenCheck"),hitSlop:{top:8,bottom:8,left:8,right:8},children:w(x,{style:y.checkDone,children:e.status==="waiting"?"Stop":"Done"})})]})}function Gi(e,t,r,n){if(e.status==="loop")return{text:`Refresh loop: ${e.newTokens} new tokens since the check started. The new tokens may already look expired to the app's clock.`,tone:"bad"};if(e.status==="refreshed"&&e.sameToken)return{text:`The app got the 401 and refreshed at ${X(e.refreshedAt??n)}. The refresh sent back the same token, and the retry worked.`,tone:"good"};if(e.status==="refreshed"){let a=e.newIssuedBy?` by ${e.newIssuedBy}`:"",l=e.newLifetimeMs&&e.newLifetimeMs>0?`. The new token lasts ${B(e.newLifetimeMs)}`:"",c=e.kind==="401"&&e.forcedAt!==void 0?"The app got the 401 and refreshed":"Refreshed",u=e.failedRefreshes>0?` ${e.failedRefreshes===1?"One token request":`${e.failedRefreshes} token requests`} failed first (${e.lastRefreshError}).`:"";return{text:`${c} at ${X(e.refreshedAt??n)}${a}${l}.${u}`,tone:u?"warn":"good"}}let o=n-e.startedAt,i=(e.staleAfterFailure>0?` It sent the old token again ${e.staleAfterFailure} time${e.staleAfterFailure===1?"":"s"}.`:"")+(e.failedRefreshes>0?` Its token request failed (${e.lastRefreshError}).`:"");if(o>6e4)return{text:`No new token after ${B(o)}. The app may refresh on its next action, or not at all.${i}`,tone:"warn"};if(e.kind==="401")return e.forcedAt===void 0?{text:`The next request to ${t?.host??"the API"} will get a 401. Use the app to send one.`}:{text:`The app got the 401. Waiting for a new token\u2026${i}`,tone:i?"warn":void 0};let s=t?.expiresAt!==void 0?t.expiresAt-r:void 0;return s!==void 0&&s>0?{text:`Expires in ${B(s)} on the app's clock. Waiting for a new token\u2026`}:{text:"Expired on the app's clock. Waiting for the app's next request\u2026"}}var y=q.create({row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:56,paddingHorizontal:k.rowPadH,paddingVertical:10},rowText:{flex:1,minWidth:0},rowTitle:{color:k.color.text,fontSize:k.font.row},rowSubtitle:{color:k.color.textTertiary,fontSize:k.font.caption,marginTop:2},rowRight:{flexDirection:"row",alignItems:"center",gap:6},value:{color:k.color.textSecondary,fontSize:k.font.row,fontVariant:["tabular-nums"]},valueWarning:{color:k.color.warning},valueDanger:{color:k.color.danger},chevronOpen:{transform:[{rotate:"90deg"}]},emptyText:{color:k.color.textSecondary,fontSize:k.font.row},detail:{paddingHorizontal:k.rowPadH,paddingBottom:14,gap:4},detailLine:{color:k.color.textSecondary,fontSize:k.font.caption},buttons:{flexDirection:"row",gap:8,marginTop:8},button:{flex:1},hint:{color:k.color.textTertiary,fontSize:k.font.caption,marginTop:6},proLine:{flexDirection:"row",alignItems:"center",gap:8,marginTop:6},proHint:{marginTop:0,flexShrink:1},check:{flexDirection:"row",alignItems:"flex-start",gap:12,marginTop:8,marginHorizontal:k.labelInset},checkText:{flex:1,color:k.color.textSecondary,fontSize:k.font.caption,lineHeight:18},checkDone:{color:k.color.accent,fontSize:k.font.caption,fontWeight:"600"},good:{color:k.color.accent},warn:{color:k.color.warning},bad:{color:k.color.danger}});import{jsx as d,jsxs as v}from"react/jsx-runtime";var br="#F59E0B";function kr({snapshot:e,onAction:t,onReload:r}){let n=Fi({minBottom:16}),[o,i]=be(null),[s,a]=be(null),l=Mi()(),[c,u]=be(null),h=E=>u(E),T=(E,O)=>{i(null),t(E,O).catch(U=>{i(U instanceof Error?U.message:String(U))})},$=E=>a(O=>O===E?null:E);return e?v(gt,{style:g.fill,contentContainerStyle:[g.content,{paddingBottom:n.bottom}],testID:"clock-scroll",keyboardShouldPersistTaps:"handled",children:[d(Yi,{snapshot:e}),o?d(m,{testID:"clock-error",children:d(et,{tone:"danger",centered:true,children:o})}):null,v(m,{children:[d(mr,{children:"Jump ahead"}),d(Qi,{run:T})]}),v(m,{children:[d(ke,{children:v(tt,{children:[v(m,{children:[d(wr,{title:"Date & Time",testID:"clock-date-row",open:s==="date",onPress:()=>$("date"),value:d(es,{snapshot:e})}),s==="date"?d(rs,{snapshot:e,run:T,onDone:()=>a(null)}):null]},"date"),v(m,{style:g.row,children:[d(rt,{title:"Freeze",isPro:l}),d(gr,{value:e.mode==="frozen",testID:"clock-freeze",accessibilityLabel:"Freeze the clock",onValueChange:E=>E&&!l?h("Freeze"):T(E?"freeze":"resume")})]},"freeze"),v(m,{children:[d(wr,{title:"Speed",pro:!l,testID:"clock-speed-row",open:s==="speed",onPress:()=>l?$("speed"):h("Speed"),value:d(x,{style:g.rowValue,children:Sr(e)})}),s==="speed"?d(ns,{snapshot:e,run:T}):null]},"speed")]})}),d(et,{children:"Only this app's clock changes. Screens pick up the new time when they next render, or all at once when you reload."})]}),e.tokens?d(Wi,{snapshot:e,run:T,openId:s,onToggle:$,isPro:l,onUpgrade:h}):null,d(ke,{children:v(tt,{children:[r?d(vr,{label:"Reload App",testID:"clock-reload",onPress:r},"reload"):null,d(vr,{label:"Use Real Time",accessibilityLabel:"Reset to real time",testID:"clock-reset",destructive:true,disabled:e.mode==="real",onPress:()=>T("reset")},"reset")]})}),v(m,{children:[d(mr,{children:"Options"}),d(is,{settings:e.settings,run:T,isPro:l,onUpgrade:h})]}),d(Oi,{visible:c!==null&&!l,onClose:()=>u(null),featureName:c??void 0})]}):d(m,{style:g.waiting,testID:"clock-waiting",children:d(et,{centered:true,children:"Waiting for the app's clock\u2026"})})}function rt({title:e,isPro:t}){return v(m,{style:g.titleRow,children:[d(x,{style:g.rowTitle,children:e}),t?null:d(Di,{})]})}function Yi({snapshot:e}){let{virtual:t,real:r}=_(e),n=tr(e),o=e.mode!=="real",i=ki(t-r),s=e.mode==="frozen"?" \xB7 Frozen":o&&e.rate!==1?` \xB7 ${Sr(e)}`:"";return v(m,{style:g.hero,children:[d(x,{style:[g.heroTime,o?g.heroTimeActive:null],testID:"clock-hero-time",accessibilityLabel:`App clock ${X(t)}`,children:X(t)}),d(x,{style:g.heroDate,testID:"clock-hero-date",children:bi(t)}),d(m,{testID:"clock-status",accessibilityLabel:`Clock status: ${n.label}${o?`, ${i}`:""}`,children:d(x,{style:[g.heroStatus,o?g.heroStatusActive:null],testID:"clock-offset",children:o?`${i}${s}`:"Real time"})})]})}var xr=36e5,nt=24*xr,Xi=[{ms:xr,unit:"hour"},{ms:nt,unit:"day"},{ms:7*nt,unit:"week"},{ms:30*nt,unit:"month"}];function Qi({run:e}){return d(ke,{style:g.jumpBar,children:Xi.map((t,r)=>v(P,{testID:xi(t.ms),accessibilityRole:"button",accessibilityLabel:`Jump ahead one ${t.unit}`,activeOpacity:.6,onPress:()=>e("shift",{by:t.ms}),style:[g.jump,r>0?g.jumpDivider:null],children:[d(x,{style:g.jumpAmount,children:"+1"}),d(x,{style:g.jumpUnit,children:t.unit})]},t.unit))})}function wr({title:e,pro:t,value:r,open:n,onPress:o,testID:i}){return v(P,{testID:i,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{expanded:n},activeOpacity:.6,onPress:o,style:g.row,children:[d(rt,{title:e,isPro:!t}),v(m,{style:g.rowRight,children:[r,d(m,{style:n?g.chevronOpen:null,children:d(Ri,{size:16,color:b.color.textTertiary})})]})]})}function es({snapshot:e}){let{virtual:t}=_(e,1e3);return d(x,{style:[g.rowValue,g.tabular],numberOfLines:1,children:ge(t,false)})}function vr({label:e,onPress:t,testID:r,destructive:n,disabled:o,accessibilityLabel:i}){return d(P,{testID:r,accessibilityRole:"button",accessibilityLabel:i??e,accessibilityState:{disabled:!!o},activeOpacity:.6,disabled:o,onPress:t,style:[g.row,o?g.rowDisabled:null],children:d(x,{style:[g.actionLabel,n?g.actionDestructive:null],children:e})})}var ts=xt.filter(e=>["midnight","month-end","year-end"].includes(e.id));function rs({snapshot:e,run:t,onDone:r}){let[n,o]=be(""),{virtual:i}=_(e,1e3),s=()=>n.trim()||er(i),a=e.mode==="frozen",l=c=>{t("setTime",{time:c,freeze:a}),r()};return v(m,{style:g.editor,children:[v(m,{style:g.inputRow,children:[d(mt,{testID:"clock-time-input",accessibilityLabel:"Date and time",value:n,onChangeText:o,placeholder:er(i),placeholderTextColor:b.color.placeholder,autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>l(s()),style:g.input}),d(Li,{label:"Set",testID:"clock-time-apply",accessibilityLabel:"Set this time",size:"md",variant:"primary",fullWidth:false,onPress:()=>l(s())})]}),d(x,{style:g.hint,children:"Year-month-day and 24-hour time, or +3d, -2h"}),d(m,{style:g.presets,children:ts.map(c=>d(zi,{label:c.label,testID:`clock-preset-${c.id}`,onPress:()=>l(c.at(i,M))},c.id))})]})}var Ar=[{key:"1",label:"Normal"},{key:"10",label:"10\xD7"},{key:"60",label:"1 min/s"},{key:"3600",label:"1 hr/s"}];function Sr(e){return e.mode==="real"||e.rate===1?"Normal":Ar.find(t=>Number(t.key)===e.rate)?.label??wt(e.rate)}function ns({snapshot:e,run:t}){let r=e.mode==="real"?"1":String(e.rate);return v(m,{style:g.editor,children:[d(m,{style:g.segmentRow,children:d(Ni,{tabs:Ar,activeKey:r,size:"sm",testIDPrefix:"clock-speed",onChange:n=>t("setRate",{rate:Number(n)})})}),d(x,{style:g.hint,children:"Taps, animations and timers keep real speed."})]})}var os=[{key:"showChip",title:"Show Floating Clock"},{key:"persist",title:"Keep After Reload",pro:true}];function is({settings:e,run:t,isPro:r,onUpgrade:n}){return d(ke,{children:d(tt,{children:os.map(o=>{let i=!!o.pro&&!r;return v(m,{style:g.row,children:[d(rt,{title:o.title,isPro:!i}),d(gr,{value:i?false:e[o.key],testID:`clock-setting-${o.key}`,accessibilityLabel:o.title,onValueChange:s=>i?n(o.title):t("updateSettings",{[o.key]:s})})]},o.key)})})})}var g=q.create({fill:{flex:1},content:{paddingHorizontal:b.gutter,paddingTop:8,gap:b.groupGap},waiting:{flex:1,alignItems:"center",justifyContent:"center",padding:24},hero:{alignItems:"center",paddingTop:12},heroTime:{color:b.color.text,fontSize:56,fontWeight:"200",fontVariant:["tabular-nums"],letterSpacing:1},heroTimeActive:{color:br},heroDate:{color:b.color.text,fontSize:17,fontWeight:"500",marginTop:2},heroStatus:{color:b.color.textTertiary,fontSize:b.font.caption,fontWeight:"500",marginTop:6},heroStatusActive:{color:b.color.textSecondary},jumpBar:{flexDirection:"row"},jump:{flex:1,alignItems:"center",paddingVertical:12},jumpDivider:{borderLeftWidth:q.hairlineWidth,borderLeftColor:b.color.separator},jumpAmount:{color:br,fontSize:17,fontWeight:"600",fontVariant:["tabular-nums"]},jumpUnit:{color:b.color.textSecondary,fontSize:b.font.caption,marginTop:1},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:50,paddingHorizontal:b.rowPadH,paddingVertical:10},rowDisabled:{opacity:.4},rowTitle:{color:b.color.text,fontSize:b.font.row},titleRow:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:1},rowRight:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},rowValue:{color:b.color.textSecondary,fontSize:b.font.row},tabular:{fontVariant:["tabular-nums"]},chevronOpen:{transform:[{rotate:"90deg"}]},actionLabel:{color:b.color.accent,fontSize:b.font.row},actionDestructive:{color:b.color.danger},editor:{paddingHorizontal:b.rowPadH,paddingBottom:14,gap:10},inputRow:{flexDirection:"row",alignItems:"center",gap:8},input:{flex:1,color:b.color.text,fontFamily:Pi,fontSize:15,backgroundColor:b.color.bg,borderRadius:b.radius.input,borderWidth:1,borderColor:b.color.border,paddingHorizontal:12,paddingVertical:8},hint:{color:b.color.textTertiary,fontSize:b.font.caption},presets:{flexDirection:"row",flexWrap:"wrap",gap:6},segmentRow:{flexDirection:"row"}});import{jsx as ss}from"react/jsx-runtime";var as=hr.actions;async function ls(e,t){let r=as[e];if(!r)throw new Error(`Unknown clock action: ${e}`);return r(t)}function cs(){Vt().then(()=>Ei("auto","buoy clock")).catch(()=>{})}function Tr(){sr(()=>{Ye(),pe()},[]);let[e,t]=Ci(S);return sr(()=>ie(()=>t(S())),[]),ss(kr,{snapshot:e,onAction:ls,onReload:cs})}import{jsx as us}from"react/jsx-runtime";var $r=$i({id:"clock",name:"CLOCK",description:"Travel to any date, freeze or speed up the app's clock",slot:"both",color:Si,icon:({size:e,color:t})=>us(Ai,{size:e,color:t}),component:Tr,modal:{subtitle:"override the app's date & time"}}),ds=Ti($r);import{ClockToolIcon as fs,CLOCK_TOOL_ICON_COLOR as ps}from"@buoy-gg/shared-ui/web";var hs=typeof navigator<"u"&&navigator.product==="ReactNative",ms=(()=>{try{return globalThis.Capacitor?.isNativePlatform?.()===true}catch{return false}})();hs||ms?(Pr(ht),or(),typeof st<"u"&&st&&Ye()):typeof globalThis.document<"u"&&or();export{ye as CLOCK_CHIP_ID,ps as CLOCK_TOOL_ICON_COLOR,Tr as ClockBody,ir as ClockChip,fs as ClockToolIcon,kr as ClockToolView,xt as TIME_PRESETS,Ye as bootClock,hr as clockSyncAdapter,$r as clockToolPreset,ds as createClockTool,dr as failNextRequest,ee as formatDuration,Ke as freeze,S as getClockSnapshot,he as getTokenReport,ce as inspectToken,Ut as isClockOverridden,ur as jumpToTokenExpiry,vi as openClockChip,Ce as parseDuration,ii as previewJump,A as realNow,Ge as reset,Ze as resume,Jt as setRate,Wt as setTime,qe as shift,pe as startTokenWatch,pr as stopTokenCheck,ie as subscribeClock,j as tokenFingerprint,qt as updateSettings,_ as useLiveClock,Bt as virtualNow,zr as withRealClock};
|
|
1
|
+
"use client";import{a as Ir,b as Lr,c as at,d as M,e as A,f as lt,g as zr,h as Nr,i as Or,j as Dr,k as Mr,l as Pr,m as Fr,o as jr,p as ct,q as Br,r as _r,s as Ur}from"./chunks/chunk-FCZBPAZF.mjs";var ut={};Ir(ut,{AccessibilityInfo:()=>Jr,ActivityIndicator:()=>Kn,Alert:()=>Gn,Animated:()=>mt,AppRegistry:()=>Kr,AppState:()=>Zr,Appearance:()=>qr,BackHandler:()=>Yr,Button:()=>Zn,CheckBox:()=>pn,Clipboard:()=>Gr,DeviceEventEmitter:()=>Rn,Dimensions:()=>Xr,Easing:()=>Qr,FlatList:()=>hn,I18nManager:()=>en,Image:()=>mn,ImageBackground:()=>gn,InteractionManager:()=>rn,Keyboard:()=>tn,KeyboardAvoidingView:()=>yn,LayoutAnimation:()=>nn,Linking:()=>on,LogBox:()=>Cn,Modal:()=>Jn,NativeEventEmitter:()=>sn,NativeModules:()=>Wr,PanResponder:()=>an,Picker:()=>bn,PixelRatio:()=>ln,Platform:()=>cn,Pressable:()=>Wn,ProgressBar:()=>kn,RefreshControl:()=>xn,SafeAreaView:()=>wn,ScrollView:()=>yt,SectionList:()=>vn,Share:()=>un,StatusBar:()=>An,StyleSheet:()=>q,Switch:()=>qn,Text:()=>x,TextInput:()=>gt,Touchable:()=>Sn,TouchableHighlight:()=>Vn,TouchableNativeFeedback:()=>$n,TouchableOpacity:()=>P,TouchableWithoutFeedback:()=>Hn,UIManager:()=>dn,Vibration:()=>fn,View:()=>m,VirtualizedList:()=>Tn,YellowBox:()=>En,findNodeHandle:()=>Yn,unstable_createElement:()=>Hr,useColorScheme:()=>In,useLocaleContext:()=>Ln,useWindowDimensions:()=>zn});Lr(ut,Vr);import*as Vr from"react-native-web";import{unstable_createElement as Hr,NativeModules as Wr,AccessibilityInfo as Jr,Appearance as qr,AppRegistry as Kr,AppState as Zr,BackHandler as Yr,Clipboard as Gr,Dimensions as Xr,Easing as Qr,I18nManager as en,Keyboard as tn,InteractionManager as rn,LayoutAnimation as nn,Linking as on,NativeEventEmitter as sn,PanResponder as an,PixelRatio as ln,Platform as cn,Share as un,UIManager as dn,Vibration as fn,CheckBox as pn,FlatList as hn,Image as mn,ImageBackground as gn,KeyboardAvoidingView as yn,Picker as bn,ProgressBar as kn,RefreshControl as xn,SafeAreaView as wn,SectionList as vn,StatusBar as An,Touchable as Sn,TouchableNativeFeedback as $n,VirtualizedList as Tn,YellowBox as En,LogBox as Cn,DeviceEventEmitter as Rn,useColorScheme as In,useLocaleContext as Ln,useWindowDimensions as zn}from"react-native-web";import*as E from"react-native-web";import{createElement as ve,forwardRef as dt,useCallback as Nn,useRef as On}from"react";import{useEffect as Dn,useState as Mn}from"react";import{createPortal as Pn}from"react-dom";var Fn='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as jn}from"react/jsx-runtime";var Q=Symbol.for("@buoy-gg/portal-host"),ft=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 pt(){let e=document;if(e[Q])return e[Q].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:Fn});let r=()=>{let u=document.fullscreenElement,h=u&&u.tagName!=="CANVAS"?u:document.body;t.parentElement!==h&&h.appendChild(t)},n=new Map,o=u=>{(!t.contains(u.target)||!ft(u.target))&&n.set(u.code||u.key,{key:u.key,code:u.code,location:u.location,keyCode:u.keyCode,which:u.which,altKey:u.altKey,ctrlKey:u.ctrlKey,metaKey:u.metaKey,shiftKey:u.shiftKey})},i=u=>{n.delete(u.code||u.key)},s=()=>n.clear(),a=()=>{let u=[...n.values()];n.clear();for(let h of u)document.dispatchEvent(new KeyboardEvent("keyup",{...h,bubbles:true}))},l=u=>{ft(u.target)&&u.stopPropagation()},c=u=>u.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",o,true),document.addEventListener("keyup",i,true),window.addEventListener("blur",s),t.addEventListener("focusin",a),t.addEventListener("keydown",l),t.addEventListener("keyup",l),t.addEventListener("keypress",l),t.addEventListener("wheel",c,{passive:true}),e[Q]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",o,true),document.removeEventListener("keyup",i,true),window.removeEventListener("blur",s),t.remove(),delete e[Q]}},t}function Bn({children:e}){let[t,r]=Mn(null);return Dn(()=>{let n=pt(),o=document[Q];return o.users++,r(n),()=>{--o.users===0&&o.dispose()}},[]),t?Pn(jn("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var W=E,_n=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],J=e=>typeof e=="number"?`${e}px`:e;function Ae(e){if(Array.isArray(e)){let h=e.map(Ae);return h.some(($,T)=>$!==e[T])?h:e}if(!e||typeof e!="object"||!_n.some(h=>e[h]!=null))return e;let{shadowColor:t,shadowOffset:r,shadowOpacity:n,shadowRadius:o,textShadowColor:i,textShadowOffset:s,textShadowRadius:a,...l}=e;if(t!=null||r!=null||n!=null||o!=null){let h=t??"black",$=n==null?h:`color-mix(in srgb, ${h} ${Math.min(n,1)*100}%, transparent)`,T=`${J(r?.width??0)} ${J(r?.height??0)} ${J(o??0)} ${$}`;l.boxShadow=typeof l.boxShadow=="string"?`${l.boxShadow}, ${T}`:l.boxShadow??T}let{width:c=0,height:u=0}=s??{};if(i&&(c||u||a)){let h=`${J(c)} ${J(u)} ${J(a??0)} ${i}`;l.textShadow=l.textShadow?`${l.textShadow}, ${h}`:h}return l}var Un=W.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function ht(e,t){if(typeof e=="function")return n=>ht(e(n),t);let r=Ae(e);return t?[r,Un[t]]:r}var q={...W.StyleSheet,create:e=>W.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Ae(r)])))};function I(e){let t=dt((n,o)=>{let{accessibilityState:i,accessibilityValue:s,pointerEvents:a,...l}=n;for(let u of["busy","checked","disabled","expanded","selected"])i?.[u]!==void 0&&l[`aria-${u}`]===void 0&&(l[`aria-${u}`]=i[u]);for(let[u,h]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))s?.[u]!==void 0&&l[`aria-${h}`]===void 0&&(l[`aria-${h}`]=s[u]);let c=ht(l.style,a);return c!==l.style&&(l.style=c),ve(e,{...l,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var m=I(E.View),x=I(E.Text),mt={...W.Animated,View:W.Animated.createAnimatedComponent(m),Text:W.Animated.createAnimatedComponent(x)},gt=I(E.TextInput),P=I(E.TouchableOpacity),Vn=I(E.TouchableHighlight),Hn=I(E.TouchableWithoutFeedback),Wn=I(E.Pressable),yt=I(E.ScrollView),bt=dt((e,t)=>{let r=On(null),n=Nn(o=>{if(o){let i=o;for(;i.parentElement&&i.parentElement!==document.body;)i=i.parentElement;i.parentElement===document.body&&(r.current=i,Object.assign(i.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),pt().appendChild(i))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(o):t&&(t.current=o)},[t]);return ve(Bn,null,ve(E.Modal,{...e,ref:n}))});bt.displayName="Modal";var Jn=I(bt),qn=I(E.Switch),Kn=I(E.ActivityIndicator),Zn=I(E.Button),Yn=E.findNodeHandle,Gn={alert(e,t,r,n){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 i=document.createElement("h2");if(i.textContent=e,i.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(i),t){let c=document.createElement("p");c.textContent=t,c.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(c)}let s=document.createElement("div");s.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let a=r?.length?r:[{text:"OK"}],l=()=>{o.close?.(),o.remove()};for(let c of a){let u=document.createElement("button");u.type="button",u.textContent=c.text??"OK",u.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${c.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,u.onclick=()=>{l(),c.onPress?.()},s.appendChild(u)}o.addEventListener("cancel",c=>{c.preventDefault(),n?.cancelable!==false&&(l(),n?.onDismiss?.())}),o.appendChild(s),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};var Se=Object.freeze({mode:"real",anchorReal:0,anchorVirtual:0,rate:1}),$e=.1,Te=86400,Xn=864e13;function N(e,t){return e.mode==="real"?t:e.mode==="frozen"?e.anchorVirtual:e.anchorVirtual+(t-e.anchorReal)*e.rate}function Qn(e,t){return N(e,t)-t}function K(e){if(!Number.isFinite(e)||Math.abs(e)>Xn)throw new RangeError(`Not a valid time: ${e}`);return Math.round(e)}function Ee(e,t,r,n=false){return{mode:n?"frozen":"running",anchorReal:t,anchorVirtual:K(r),rate:e.mode==="real"?1:e.rate}}function eo(e,t,r){if(!Number.isFinite(r))throw new RangeError("Jump must be a number of ms");return Ee(e,t,N(e,t)+r,e.mode==="frozen")}function to(e,t,r){return Ee(e,t,r??N(e,t),true)}function ro(e,t){return e.mode!=="frozen"?e:{...e,mode:"running",anchorReal:t}}function no(e,t,r){if(!Number.isFinite(r)||r<$e||r>Te)throw new RangeError(`Speed must be between ${$e}\xD7 and ${Te}\xD7`);return e.mode==="real"&&r===1?e:{mode:"running",anchorReal:t,anchorVirtual:K(N(e,t)),rate:r}}function kt(e){let t=e;return!!t&&(t.mode==="real"||t.mode==="running"||t.mode==="frozen")&&Number.isFinite(t.anchorReal)&&Number.isFinite(t.anchorVirtual)&&Number.isFinite(t.rate)&&t.rate>=$e&&t.rate<=Te}var oo={ms:1,millisecond:1,milliseconds:1,s:1e3,sec:1e3,secs:1e3,second:1e3,seconds:1e3,m:6e4,min:6e4,mins:6e4,minute:6e4,minutes:6e4,h:36e5,hr:36e5,hrs:36e5,hour:36e5,hours:36e5,d:864e5,day:864e5,days:864e5,w:6048e5,wk:6048e5,week:6048e5,weeks:6048e5,mo:30*864e5,month:30*864e5,months:30*864e5,y:365*864e5,yr:365*864e5,year:365*864e5,years:365*864e5};function Ce(e){if(typeof e=="number"){if(!Number.isFinite(e))throw new RangeError("Duration must be finite");return Math.round(e)}let t=String(e).trim().toLowerCase();if(!t)throw new RangeError("Duration is empty");let r=1;if((t[0]==="+"||t[0]==="-"||t[0]==="\u2212")&&(r=t[0]==="+"?1:-1,t=t.slice(1).trim()),/^\d+(\.\d+)?$/.test(t))return r*Math.round(Number(t));let n=/(\d+(?:\.\d+)?)\s*([a-z]+)/g,o=0,i="",s;for(;s=n.exec(t);){let a=oo[s[2]];if(a===void 0)throw new RangeError(`Unknown time unit "${s[2]}" in "${e}"`);o+=Number(s[1])*a,i+=s[0]}if(!i||i.replace(/\s/g,"")!==t.replace(/[\s,]/g,""))throw new RangeError(`Could not read "${e}" as a duration. Try "+1d", "-2h30m" or "90s".`);return r*Math.round(o)}function ee(e,{signed:t=true}={}){let r=e<0?"\u2212":"+",n=Math.abs(Math.round(e));if(n<1e3)return t&&n>0?`${r}${n}ms`:"0s";let o=[],i=[["y",365*864e5],["d",864e5],["h",36e5],["m",6e4],["s",1e3]];for(let[s,a]of i)if(n>=a&&(o.push(`${Math.floor(n/a)}${s}`),n%=a),o.length===2)break;return`${t?r:""}${o.join(" ")}`}function xt(e,t,r){if(typeof e=="number")return K(e);let n=String(e).trim();if(!n)throw new RangeError("Time is empty");if(/^now$/i.test(n))return t;if(/^[+\-−]/.test(n))return K(t+Ce(n));if(/^\d{11,}$/.test(n))return K(Number(n));let o=n.replace(/^(\d{4}-\d{2}-\d{2})[ ](\d{2}:\d{2})/,"$1T$2"),i=r(o);if(!Number.isFinite(i))throw new RangeError(`Could not read "${e}" as a time. Use ISO 8601 like 2026-12-31T23:59:50, epoch ms, or "+1d".`);return K(i)}var Re=1e4,wt=[{id:"midnight",label:"Before midnight",hint:"23:59:50 tonight",at(e,t){let r=new t(e);return r.setHours(24,0,0,0),r.getTime()-Re}},{id:"month-end",label:"Month end",hint:"last day, 23:59:50",at(e,t){let r=new t(e);return r.setMonth(r.getMonth()+1,1),r.setHours(0,0,0,0),r.getTime()-Re}},{id:"year-end",label:"New Year's Eve",hint:"Dec 31, 23:59:50",at(e,t){let r=new t(e);return r.setFullYear(r.getFullYear()+1,0,1),r.setHours(0,0,0,0),r.getTime()-Re}},{id:"tomorrow-9",label:"Tomorrow 9 AM",hint:"start of a business day",at(e,t){let r=new t(e);return r.setDate(r.getDate()+1),r.setHours(9,0,0,0),r.getTime()}},{id:"leap-day",label:"Leap day",hint:"next Feb 29, 09:00",at(e,t){let r=new t(e).getFullYear();for(;;){let n=r%4===0&&r%100!==0||r%400===0,o=new t(r,1,29,9,0,0,0).getTime();if(n&&o>e)return o;r+=1}}}],As=[{label:"1m",ms:6e4},{label:"15m",ms:15*6e4},{label:"1h",ms:36e5},{label:"1d",ms:864e5},{label:"7d",ms:7*864e5},{label:"30d",ms:30*864e5},{label:"1y",ms:365*864e5}];function vt(e){return e===3600?"1h/s":e===600?"10m/s":e===60?"1m/s":`${Number.isInteger(e)?e:e.toFixed(1)}\xD7`}import{devToolsStorageKeys as io,persistentStorage as At}from"@buoy-gg/shared-ui/web";function so(){try{let e=globalThis.localStorage;return e?St(e.getItem(Ie)):void 0}catch{return}}var te={persist:true,showChip:true,fireTimersOnJump:true},ao=2*6e4,Ie=io.clock.state();function St(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||t.v!==1)return null;let r=t.settings??{},n=t.reload&&kt(t.reload.anchor)&&typeof t.reload.at=="number"?{anchor:t.reload.anchor,at:t.reload.at}:void 0;return{v:1,anchor:kt(t.anchor)?t.anchor:null,...n?{reload:n}:{},settings:{persist:typeof r.persist=="boolean"?r.persist:te.persist,showChip:typeof r.showChip=="boolean"?r.showChip:te.showChip,fireTimersOnJump:typeof r.fireTimersOnJump=="boolean"?r.fireTimersOnJump:te.fireTimersOnJump}}}catch{return null}}async function lo(){try{return St(await At.getItem(Ie))}catch{return null}}var Le=Promise.resolve();function ze(e){let t=JSON.stringify(e);return Le=Le.then(()=>At.setItem(Ie,t)).catch(()=>{}),Le.then(()=>{})}import{dispatchToolAction as co}from"@buoy-gg/shared-ui/web";import{loadToolModule as uo}from"@buoy-gg/shared-ui/web/utils";var $t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",le={};for(let e=0;e<$t.length;e++)le[$t[e]]=e;le["-"]=62;le._=63;function Ne(e){let t=e.replace(/=+$/,""),r=[],n=0,o=0;for(let i=0;i<t.length;i++){let s=le[t[i]];if(s===void 0)return null;n=n<<6|s,o+=6,o>=8&&(o-=8,r.push(n>>o&255))}return r}function fo(e){let t="";for(let r=0;r<e.length;){let n=e[r],o,i;if(n<128)o=n,i=0;else if(n>=192&&n<224)o=n&31,i=1;else if(n>=224&&n<240)o=n&15,i=2;else if(n>=240&&n<248)o=n&7,i=3;else return null;for(let s=1;s<=i;s++){let a=e[r+s];if(a===void 0||(a&192)!==128)return null;o=o<<6|a&63}t+=String.fromCodePoint(o),r+=i+1}return t}function Oe(e){let t=Ne(e);return t?Tt(t):null}function Tt(e){let t=fo(e);if(!t||t[0]!=="{")return null;try{let r=JSON.parse(t);return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}function De(e){let t=typeof e=="string"&&e.trim()!==""?Number(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>0?t*1e3:void 0}function re(e,t){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e<1e11?e*1e3:e;if(typeof e=="string"&&e.trim()!==""){let r=e.trim();if(/^\d+(\.\d+)?$/.test(r))return re(Number(r),t);let n=t(r);return Number.isFinite(n)?n:void 0}}function po(e){let t=typeof e=="string"&&/^\d+(\.\d+)?$/.test(e.trim())?Number(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}var ho=/^[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]*$/,mo=/^[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]*$/,Et=/^v([1-4])\.(local|public)\.([A-Za-z0-9_-]+)(?:\.([A-Za-z0-9_-]+))?$/,go={1:256,2:64,3:96,4:64};function F(e){if(typeof e=="string"&&e)return e;if(Array.isArray(e)){let t=e.filter(r=>typeof r=="string");return t.length?t.join(", "):void 0}}function yo(e,t){let r=e.iss??"",n=e.use;if(r.includes("securetoken.google.com"))return"Firebase ID token";if(r.includes("firebaseappcheck"))return"Firebase App Check token";if(r.includes("cognito-idp"))return n?`Cognito ${n} token`:"Cognito token";if(r.includes("appleid.apple.com"))return"Sign in with Apple token";if(r.includes("accounts.google.com"))return"Google ID token";if(r.includes(".auth0.com")||r.includes("auth0"))return"Auth0 token";if(r.includes("clerk"))return"Clerk session token";if(r.includes("supabase")||r.includes("/auth/v1"))return"Supabase access token";if(r.includes("okta"))return"Okta token";if(r.includes("/realms/"))return"Keycloak token";if(r.includes("login.microsoftonline.com")||r.includes("sts.windows.net"))return"Microsoft Entra token";let o=typeof t?.typ=="string"?t.typ.toLowerCase():"";if(o==="at+jwt"||o==="application/at+jwt")return"OAuth access token"}function bo(e,t){let r={iss:F(e.iss),aud:F(e.aud),sub:F(e.sub),scope:F(e.scope??e.scp),use:F(e.token_use)},n=De(e.exp);return{claims:r,issuedAt:De(e.iat),notBefore:De(e.nbf),expiresAt:n,expirySource:n?t:void 0}}function ko(e){let[t,r]=e.split("."),n=Oe(t);if(!n||typeof n.alg!="string"&&typeof n.typ!="string")return null;let o=Oe(r);if(!o)return null;let i=typeof n.alg=="string"?n.alg:void 0,s=bo(o,"exp claim");return s.claims.alg=i,!s.claims.use&&typeof n.typ=="string"&&n.typ.toUpperCase()!=="JWT"&&(s.claims.use=n.typ),{format:"jwt",formatLabel:i?`JWT \xB7 ${i}`:"JWT",hint:yo(s.claims,n),...s}}function xo(e){let t=Oe(e.split(".")[0]);return!t||typeof t.enc!="string"?null:{format:"jwe",formatLabel:"Encrypted JWT",claims:{alg:typeof t.alg=="string"?t.alg:void 0}}}function wo(e,t){let r=Et.exec(e);if(!r)return null;let[,n,o,i]=r;if(o==="local")return{format:"paseto-local",formatLabel:`PASETO v${n} (encrypted)`,claims:{}};let s=Ne(i),a=go[n],l=s&&s.length>a?Tt(s.slice(0,s.length-a)):null,c={format:"paseto-public",formatLabel:`PASETO v${n}`,claims:{}};return l&&(c.claims={iss:F(l.iss),aud:F(l.aud),sub:F(l.sub)},c.issuedAt=re(l.iat,t),c.notBefore=re(l.nbf,t),c.expiresAt=re(l.exp,t),c.expiresAt&&(c.expirySource="exp claim")),c}function vo(e){if(!e.startsWith("gAAAAA")||e.length<76)return null;let t=Ne(e);if(!t||t[0]!==128||t.length<73||(t.length-57)%16!==0)return null;let r=0;for(let n=1;n<=8;n++)r=r*256+t[n];return r<978307200||r>4102444800?null:{format:"fernet",formatLabel:"Fernet",claims:{},issuedAt:r*1e3}}var Ao=[{test:/^ya29\./,hint:"Google OAuth access token"},{test:/^gh[opsu]_/,hint:"GitHub token"},{test:/^github_pat_/,hint:"GitHub token"},{test:/^xox[abeprs]-/,hint:"Slack token"},{test:/^EAA[A-Za-z0-9]{40,}/,hint:"Facebook access token"},{test:/^shp(at|ca|pa|ss)_/,hint:"Shopify token"},{test:/^(sk|rk|pk)_(live|test)_/,hint:"Stripe API key",neverExpires:true},{test:/^AIza[0-9A-Za-z_-]{35}$/,hint:"Google API key",neverExpires:true}];function ce(e,t=Date.parse){let r=e.trim().replace(/^"(.*)"$/,"$1");if(r.length<16||/\s/.test(r))return null;if(ho.test(r)){let i=ko(r);if(i)return i}if(mo.test(r)){let i=xo(r);if(i)return i}if(r.startsWith("v")&&Et.test(r)){let i=wo(r,t);if(i)return i}let n=vo(r);if(n)return n;let o=Ao.find(i=>i.test.test(r));return{format:"opaque",formatLabel:"Opaque",hint:o?.hint,neverExpires:o?.neverExpires,claims:{}}}function So(e){return!!e&&e.format!=="opaque"}function j(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,"0")}function Me(e){let t=/^([a-z][a-z0-9+.-]*:\/\/[^/?#]+)/i.exec(e);return t?t[1].toLowerCase():null}function $o(e){let t=Me(e);return t?t.replace(/^[a-z][a-z0-9+.-]*:\/\//,""):"unknown"}function Pe(e){return e.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/?#]+/i,"").split(/[?#]/)[0]||"/"}function To(e){let t=e.split("#")[0].split("?")[1];if(!t)return[];let r=[];for(let n of t.split("&")){let o=n.indexOf("=");if(!(o<=0))try{r.push([decodeURIComponent(n.slice(0,o)),decodeURIComponent(n.slice(o+1))])}catch{}}return r}var Fe=/(token|jwt|session|auth|appcheck|api[-_]?key|apikey|credential|bearer)/i,Eo=new Set(["authorization","cookie","dpop","idempotency-key","x-request-id","x-correlation-id","www-authenticate","proxy-authenticate","x-csrf-token","x-xsrf-token"]),Ct=new Set(["access_token","accesstoken","id_token","token","auth","auth_token","jwt","session","session_token"]),Co=new Set(["bearer","token","jwt","dpop","oauth","firebase"]);function Rt(e){let t={};if(!e)return t;for(let[r,n]of Object.entries(e))typeof n=="string"?t[r.toLowerCase()]=n:Array.isArray(n)&&(t[r.toLowerCase()]=n.join(", "));return t}function Ro(e){let t=[];for(let r of e.split(";")){let n=r.indexOf("=");n<=0||t.push([r.slice(0,n).trim(),r.slice(n+1).trim()])}return t}function ne(e,t,r){let n=ce(e,r);return n&&(So(n)||n.hint||t)?n:null}function It(e,t){let r=[],n=Rt(e.requestHeaders),o=n.authorization;if(o){let i=/^(\S+)\s+(\S+)$/.exec(o.trim()),s=i?i[1]:void 0,a=i?i[2]:o.trim();if(!s||Co.has(s.toLowerCase())){let l=ne(a,true,t)??(s&&!/^(null|undefined)$/i.test(a)?{format:"opaque",formatLabel:"Opaque",claims:{}}:null);l&&r.push({location:"authorization",name:"Authorization",scheme:s,fp:j(a),info:l})}}for(let[i,s]of Object.entries(n)){if(Eo.has(i)||!Fe.test(i))continue;let a=s.replace(/^bearer\s+/i,""),l=ne(a,true,t);l&&r.push({location:"header",name:i,fp:j(a),info:l})}if(n.cookie)for(let[i,s]of Ro(n.cookie)){let a=ne(s,Fe.test(i)||/^(sid|sess)/i.test(i),t);a&&r.push({location:"cookie",name:i,fp:j(s),info:a})}for(let[i,s]of To(e.url)){let a=ne(s,Ct.has(i.toLowerCase()),t);a&&Ct.has(i.toLowerCase())&&r.push({location:"query",name:i,fp:j(s),info:a})}return r}var Io=/^(access_?token|accesstoken|token|jwt|auth_?token|session_?token|sessiontoken)$/i,Lt=/^(id_?token|idtoken)$/i,ue=/^(refresh_?token|refreshtoken)$/i,Lo=["expires_in","expiresIn","ExpiresIn","expires","ttl"],zo=["expires_at","expiresAt","ExpiresAt","expiration","Expiration","expiry","expirationTime","expiration_time","access_token_expires_at","accessTokenExpiresAt","accessTokenExpiry"],No=["refresh_expires_in","refresh_token_expires_in","refreshTokenExpiresIn","refreshExpiresIn"],Oo=["refresh_expires_at","refreshTokenExpiresAt","refresh_token_expires_at"];function Do(e){if(typeof e!="string")return e;let t=e.trim();if(!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function je(e,t,r){if(t>4||!e||typeof e!="object")return;if(Array.isArray(e)){for(let o of e.slice(0,5))je(o,t+1,r);return}let n=e;for(let[o,i]of Object.entries(n))typeof i=="string"&&(Io.test(o)||Lt.test(o)||ue.test(o))?r.push({key:o,value:i,holder:n}):i&&typeof i=="object"&&je(i,t+1,r)}function Mo(e){return ue.test(e)?"refresh":Lt.test(e)?"id":/session/i.test(e)?"session":"access"}function zt(e,t,r,n,o){for(let i of t){let s=po(e[i]);if(s!==void 0)return{expiresAt:n+s*1e3,source:i,lifetimeMs:s*1e3}}for(let i of r){let s=re(e[i],o);if(s!==void 0)return{expiresAt:s,source:i}}return{}}function Po(e){let t=e["set-cookie"];return t?t.split(/,(?=\s*[A-Za-z0-9!#$%&'*+.^_`|~-]+=)/).map(r=>r.trim()):[]}function Fo(e,t){if(e.status===void 0||e.status>=400)return[];let r=`${e.method.toUpperCase()} ${Pe(e.url)}`,n=e.timestamp+(e.duration??0),o=[],i=Do(e.responseData);if(i){let a=[];je(i,0,a);let l=new Map;for(let c of a.filter(u=>ue.test(u.key))){let u=ce(c.value,t);if(!u)continue;let h=zt(c.holder,No,Oo,n,t);l.set(c.holder,{fp:j(c.value),expiresAt:u.expiresAt??h.expiresAt,formatLabel:u.formatLabel})}for(let c of a){if(ue.test(c.key))continue;let u=ce(c.value,t);if(!u)continue;let h=zt(c.holder,Lo,zo,n,t);o.push({fp:j(c.value),info:u,role:Mo(c.key),expiresAt:h.expiresAt,expirySource:h.source,lifetimeMs:h.lifetimeMs,issuedBy:r,refresh:l.get(c.holder)})}}let s=Rt(e.responseHeaders);for(let a of Po(s)){let[l,...c]=a.split(";"),u=l.indexOf("=");if(u<=0)continue;let h=l.slice(0,u).trim(),$=l.slice(u+1).trim(),T=ne($,Fe.test(h)||/^(sid|sess)/i.test(h),t);if(!T||$===""||$.toLowerCase()==="deleted")continue;let C,D,U;for(let Er of c){let[Cr,...Rr]=Er.split("="),it=Cr.trim().toLowerCase(),we=Rr.join("=").trim();if(it==="max-age"&&/^-?\d+$/.test(we))U=Number(we)*1e3,C=n+U,D="Max-Age";else if(it==="expires"&&D!=="Max-Age"){let st=t(we);Number.isFinite(st)&&(C=st,D="Expires")}}o.push({fp:j($),info:T,role:"cookie",cookie:h,expiresAt:T.expiresAt??C,expirySource:T.expiresAt?T.expirySource:D,lifetimeMs:T.expiresAt?void 0:U,issuedBy:r})}return o}var Be=e=>M.parse(e),Nt=4,Ot=2e4,jo=8,Bo=8,_o=200,Uo=1e3,R=new Map,Z=new Map,Vo=new Set,Ho=new Set,Dt=new Set,Wo=/(token|refresh|oauth|session|auth\/)/i,f=null,de=new Set,fe=true,_e=null,Ue=new Set,Ve=false;function oe(){Ve||(Ve=true,Promise.resolve().then(()=>{Ve=false,Ue.forEach(e=>e())}))}function Jo(e){return Ue.add(e),()=>{Ue.delete(e)}}function He(e,t){if(e.has(t))return false;if(e.size>=Uo){let r=e.values().next().value;r!==void 0&&e.delete(r)}return e.add(t),true}function We(e,t){return`${e}|${t.location}:${t.name.toLowerCase()}`}function Mt(e,t){let r=t?.lifetimeMs!==void 0&&t.expiresAt!==void 0,n=r?t.expiresAt:e.expiresAt??t?.expiresAt,o=e.expiresAt??(r?t.observedReal+t.lifetimeMs:t?.expiresAt),i=r?t.expirySource:e.expiresAt?e.expirySource:t?.expirySource,s=r?t.lifetimeMs:e.expiresAt!==void 0&&e.issuedAt!==void 0?e.expiresAt-e.issuedAt:void 0;return{expiresAt:n,serverExpiresAt:o,source:i,lifetimeMs:s}}function Je(e,t,r,n,o){let i=Z.get(t),s=Mt(r,i),a=e.fp!==t;a&&(e.history.unshift({fp:e.fp,firstSeenReal:e.firstSeenReal,expiresAt:e.expiresAt}),e.history.length=Math.min(e.history.length,Bo),e.fp=t,e.firstSeenReal=n,e.firstSeenApp=o,e.uses=0,e.expiredSends=0,e.rejected=0),e.info=r,e.role=i?.role??(a?void 0:e.role),e.issuedBy=i?.issuedBy??(a?void 0:e.issuedBy),e.refresh=i?.refresh??(a?void 0:e.refresh),e.expiresAt=s.expiresAt,e.serverExpiresAt=s.serverExpiresAt,e.expirySource=s.source,e.lifetimeMs=s.lifetimeMs,a&&qo(e,n)}function Pt(e,t,r,n,o){let i=Z.get(r.fp),s=Mt(r.info,i);return{key:e,origin:t,host:$o(t),location:r.location,name:r.name,scheme:r.scheme,fp:r.fp,info:r.info,role:i?.role,issuedBy:i?.issuedBy,refresh:i?.refresh,expiresAt:s.expiresAt,serverExpiresAt:s.serverExpiresAt,expirySource:s.source,lifetimeMs:s.lifetimeMs,firstSeenReal:n,firstSeenApp:o,lastUsedReal:n,lastUsedApp:o,uses:0,expiredSends:0,rejected:0,history:[]}}function Ft(){if(R.size<=jo)return;let e=null;for(let t of R.values())(!e||t.lastUsedReal<e.lastUsedReal)&&(e=t);e&&e.key!==f?.tokenId&&R.delete(e.key)}function qo(e,t){!f||f.tokenId!==e.key||(f.newTokens+=1,f.status==="waiting"&&(f.status="refreshed",f.refreshedAt=t,f.ruleId&&f.forcedAt===void 0&&co("network","deleteOverrideRule",{id:f.ruleId}).catch(()=>{})),f.newTokens>=Nt&&t-(f.refreshedAt??t)<=Ot&&(f.status="loop"))}function Ko(e){let t=Me(e.url);if(!t)return;let r=It(e,Be);if(r.length===0)return;let n=A(),o=e.timestamp;for(let i of r){let s=We(t,i),a=R.get(s);a?Je(a,i.fp,i.info,n,o):(a=Pt(s,t,i,n,o),R.set(s,a),Ft()),a.uses+=1,a.lastUsedReal=n,a.lastUsedApp=o,a.expiresAt!==void 0&&o>=a.expiresAt&&(a.expiredSends+=1),f&&f.tokenId===s&&f.forcedAt!==void 0&&i.fp===f.startFp&&(f.staleAfterFailure+=1,He(de,e.id))}oe()}function Zo(e){let t=Me(e.url);if(!t)return;let r=A(),n=false;if(e.status===401||e.status===403)for(let l of It(e,Be)){let c=R.get(We(t,l));c&&c.fp===l.fp&&(c.rejected+=1,n=true)}let o=!!f?.ruleId&&e.override?.ruleId===f.ruleId,i=`${e.method.toUpperCase()} ${Pe(e.url)}`,s=Dt.has(i)||e.method.toUpperCase()==="POST"&&Wo.test(Pe(e.url)),a=e.status??0;f&&a>=400&&!o&&s&&(f.failedRefreshes+=1,f.lastRefreshError=`${e.status} ${i}`,n=true),f?.status==="waiting"&&f.forcedAt!==void 0&&!o&&a>=200&&a<400&&(s&&f.refreshOkAt===void 0?(f.refreshOkAt=r,n=true):!s&&f.refreshOkAt!==void 0&&de.has(e.id)&&(f.status="refreshed",f.refreshedAt=r,f.sameToken=true,n=true)),f?.ruleId&&e.override?.ruleId===f.ruleId&&f.forcedAt===void 0&&(f.forcedAt=r,n=true);for(let l of Fo(e,Be)){if(Dt.add(l.issuedBy),Z.set(l.fp,{...l,observedReal:r}),Z.size>_o){let c=Z.keys().next().value;c!==void 0&&Z.delete(c)}if(n=true,l.cookie){let c={location:"cookie",name:l.cookie,fp:l.fp,info:l.info},u=We(t,c),h=R.get(u);h?Je(h,l.fp,l.info,r,e.timestamp):(R.set(u,Pt(u,t,c,r,e.timestamp)),Ft());continue}for(let c of R.values())c.fp===l.fp&&Je(c,l.fp,c.info,r,c.lastUsedApp)}n&&oe()}function Yo(e){let t=e;!t||typeof t.id!="string"||typeof t.url!="string"||(He(Vo,t.id)&&Ko(t),t.status!==void 0&&He(Ho,t.id)&&Zo(t))}function pe(){if(_e)return true;try{let{networkEventStore:e}=uo("@buoy-gg/network");if(!e?.onEvent)throw new Error("no event store");_e=e.onEvent(Yo,true),fe=true}catch{fe=false}return oe(),fe}function jt(e,t,r){let n=R.get(t);if(!n)throw new Error(`No token row "${t}".`);return f={kind:e,tokenId:t,startedAt:A(),startFp:n.fp,ruleId:r,status:"waiting",newTokens:0,staleAfterFailure:0,failedRefreshes:0},de.clear(),oe(),f}function Go(){f=null,de.clear(),oe()}function Xo(e){return e.location==="cookie"?`${e.name} cookie`:e.location==="query"?`${e.name} parameter`:e.location==="header"?`${e.name} header`:e.role==="id"||e.info.claims.use==="id"?"ID token":"Access token"}function Qo(e,t){let r=[e.firstSeenReal,...e.history.map(o=>o.firstSeenReal)].slice(0,-1).filter(o=>t-o<=Ot).length,n=e.info.issuedAt;return{id:e.key,label:Xo(e),host:e.host,location:e.location,name:e.name,scheme:e.scheme,format:e.info.format,formatLabel:e.info.formatLabel,hint:e.info.hint,claims:e.info.claims,fingerprint:e.fp,issuedAt:n,notBefore:e.info.notBefore,expiresAt:e.expiresAt,serverExpiresAt:e.serverExpiresAt,expirySource:e.expirySource,lifetimeMs:e.lifetimeMs,neverExpires:e.info.neverExpires,issuedBy:e.issuedBy,refresh:e.refresh?{expiresAt:e.refresh.expiresAt,formatLabel:e.refresh.formatLabel}:void 0,firstUsed:e.firstSeenApp,lastUsed:e.lastUsedApp,lastUsedReal:e.lastUsedReal,uses:e.uses,refreshes:e.history.length,lastRefreshAt:e.history.length?e.firstSeenReal:void 0,recentRefreshes:r,looping:r>=Nt,expiredSends:e.expiredSends,rejected:e.rejected}}function he(){let e=A(),t=[...R.values()].sort((r,n)=>n.lastUsedReal-r.lastUsedReal).map(r=>Qo(r,e));if(f?.status==="refreshed"){let r=R.get(f.tokenId);r&&(f.newLifetimeMs=r.lifetimeMs,f.newIssuedBy=r.issuedBy)}return{available:fe,watching:_e!==null,tokens:t,check:f?{...f}:null}}function ei(e){let t=he();return e?t.tokens.find(r=>r.id===e||r.fingerprint===e)??null:t.tokens.find(r=>r.expiresAt!==void 0)??t.tokens[0]??null}function ti(e){return R.get(e)?.origin??null}import{isProNow as Bt}from"@buoy-gg/shared-ui/web";var p={anchor:Se,settings:te,lastJump:null,changedAt:null,hydrated:false},qe=new Set,me=null;function _t(){me=null,qe.forEach(e=>e())}Jo(_t);function ie(e){return qe.add(e),()=>{qe.delete(e)}}function ri(){return p.settings}function Ut(){return N(p.anchor,A())}function Vt(){return p.anchor.mode!=="real"}function ni(e){if(e.mode==="real"){lt(null),Mr();return}ct(),lt(t=>N(p.anchor,t)),Dr()}function oi(){let e={v:1,anchor:p.settings.persist&&Bt()?p.anchor:null,settings:p.settings};ze(e)}function Ht(){let e={v:1,anchor:p.settings.persist&&Bt()?p.anchor:null,settings:p.settings};return p.settings.persist&&p.anchor.mode!=="real"&&(e.reload={anchor:p.anchor,at:A()}),ze(e)}function Y(e,{save:t=true}={}){p={...p,...e},e.anchor&&ni(p.anchor),t&&oi(),_t()}function G(e,t=p.lastJump){Y({anchor:e,lastJump:t,changedAt:A(),hydrated:true})}var Wt=e=>M.parse(e);function Jt(e,t=false){let r=A(),n=N(p.anchor,r),o=xt(e,n,Wt),i=o-n;return G(Ee(p.anchor,r,o,t),{byMs:i,firedTimers:0,at:r}),S()}function Ke(e,t){let r=Ce(e),n=A(),o=eo(p.anchor,n,r),i=(t??p.settings.fireTimersOnJump)&&r>0;if(G(o,{byMs:r,firedTimers:0,at:n}),i){let s=Ur(r);s>0&&Y({lastJump:{byMs:r,firedTimers:s,at:n}},{save:false})}return S()}function Ze(e){let t=A(),r=N(p.anchor,t),n=e===void 0||e===""?r:xt(e,r,Wt);return G(to(p.anchor,t,n)),S()}function Ye(){return p.anchor.mode==="frozen"&&G(ro(p.anchor,A())),S()}function qt(e){return G(no(p.anchor,A(),Number(e))),S()}function Ge(){return G(Se,null),S()}function Kt(e){let t={...p.settings};for(let r of Object.keys(te))typeof e[r]=="boolean"&&(t[r]=e[r]);return Y({settings:t}),S()}function ii(e){return e>0?_r(e):0}var Zt=false;function Yt(e){if(!e){Y({hydrated:true},{save:false});return}let t=e.reload?A()-e.reload.at:1/0,r=t>=0&&t<ao?e.reload?.anchor:void 0;e.reload&&ze({v:1,anchor:e.anchor,settings:e.settings});let n=e.anchor??r??null;Y({settings:e.settings,anchor:n??Se,changedAt:n?A():null,hydrated:true},{save:false})}function ge(){if(Zt)return;Zt=true,ct();let e=so();if(e!==void 0){Yt(e);return}lo().then(t=>{p.changedAt===null?Yt(t):Y({hydrated:true},{save:false})})}function si(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone??"unknown"}catch{return"unknown"}}function S(){let e=A(),t=N(p.anchor,e);return{mode:p.anchor.mode,active:p.anchor.mode!=="real",rate:p.anchor.rate,virtualNow:t,virtualIso:new M(t).toISOString(),realNow:e,offsetMs:Qn(p.anchor,e),timeZone:si(),timers:Br(),lastJump:p.lastJump,changedAt:p.changedAt,settings:p.settings,hydrated:p.hydrated,tokens:he(),patched:{date:Nr(),intl:Or(),timers:jr(),animatedOnRealClock:Fr()}}}function Gt(){return me||(me=S()),me}import{useSyncExternalStore as ai}from"react";import{ClockToolIcon as Xt,FloatingTool as li,Pause as ci,Play as ui,X as di,dismissFloatingTool as fi,getFloatingTools as pi,getUseIsPro as hi,night as se,openFloatingTool as Qt}from"@buoy-gg/shared-ui/web";import{useEffect as mi,useState as gi}from"react";function B(e,t=250){let[,r]=gi(0);mi(()=>{let s=setInterval(()=>r(a=>a+1),t);return()=>clearInterval(s)},[t]);let n=A();if(!e)return{virtual:n,real:n};let o=n-e.realNow,i=e.mode==="real"?1:e.rate;return{virtual:e.mode==="frozen"?e.virtualNow:e.virtualNow+o*i,real:n}}var O=e=>String(e).padStart(2,"0");function X(e){let t=new M(e);return`${O(t.getHours())}:${O(t.getMinutes())}:${O(t.getSeconds())}`}var yi=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],er=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function bi(e){let t=new M(e);return`${yi[t.getDay()]}, ${er[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`}function ye(e,t=true){let r=new M(e),n=t?X(e):`${O(r.getHours())}:${O(r.getMinutes())}`;return`${er[r.getMonth()]} ${r.getDate()} \xB7 ${n}`}function tr(e){let t=new M(e);return`${t.getFullYear()}-${O(t.getMonth()+1)}-${O(t.getDate())} ${O(t.getHours())}:${O(t.getMinutes())}`}function ki(e){if(Math.abs(e)<1e3)return"matches real time";let t=ee(Math.abs(e),{signed:false});return e>0?`${t} ahead of real time`:`${t} behind real time`}function rr(e){return e.mode==="real"?{label:"Real time",tone:"neutral"}:e.mode==="frozen"?{label:"Frozen",tone:"info"}:e.rate!==1?{label:`${vt(e.rate)} speed`,tone:"warning"}:{label:"Overridden",tone:"accent"}}function xi(e){return`clock-jump-${e<0?"minus":"plus"}-${ee(Math.abs(e),{signed:false}).replace(/\s/g,"")}`}import{jsx as L,jsxs as Xe}from"react/jsx-runtime";var be="clock-chip",nr={id:be,render:e=>L(sr,{...e})},wi=()=>pi().some(e=>e.id===be);function vi(){Qt(nr)}var or=false;function ir(){if(or)return;or=true;let e=false,t=()=>{let r=Vt()&&ri().showChip;r&&!e?Qt(nr):!r&&wi()&&fi(be),e=r};ie(t),t()}function sr({id:e,revealToken:t}){let r=ai(ie,Gt,Gt),{virtual:n,real:o}=B(r),i=r.mode==="frozen",s=hi()(),a=i||s,l=rr(r),c=n-o,u=`${Math.abs(c)<1e3?"0s":ee(c)} \xB7 ${l.label.toLowerCase()}`;return L(li,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:`Move or hide the clock chip. App time ${ye(n)}`,handleAdornment:L(Xt,{size:12}),children:Xe(m,{style:V.row,children:[L(Xt,{size:18}),Xe(m,{style:V.text,children:[L(x,{style:V.time,numberOfLines:1,testID:"clock-chip-time",children:ye(n)}),L(x,{style:V.detail,numberOfLines:1,testID:"clock-chip-detail",children:u})]}),a?Xe(P,{testID:i?"clock-chip-resume":"clock-chip-freeze",accessibilityRole:"button",accessibilityLabel:i?"Resume the app clock":"Freeze the app clock",onPress:()=>i?Ye():Ze(),style:V.button,hitSlop:{top:8,bottom:8,left:4,right:4},children:[i?L(ui,{size:16,color:se.color.accent}):null,i?null:L(ci,{size:16,color:se.color.text})]}):null,a?L(m,{style:V.separator}):null,L(P,{testID:"clock-chip-reset",accessibilityRole:"button",accessibilityLabel:"Back to real time",onPress:()=>Ge(),style:V.button,hitSlop:{top:8,bottom:8,left:4,right:8},children:L(di,{size:16,color:se.color.textSecondary})})]})})}var V=q.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingLeft:10,paddingRight:4,paddingVertical:6,minWidth:220},text:{flexShrink:1,minWidth:120},time:{color:"#F59E0B",fontSize:14,fontWeight:"600",fontVariant:["tabular-nums"]},detail:{color:se.color.textSecondary,fontSize:11,fontVariant:["tabular-nums"]},button:{width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:16},separator:{width:q.hairlineWidth,height:20,backgroundColor:se.color.separator}});import{ClockToolIcon as Ai,CLOCK_TOOL_ICON_COLOR as Si,createToolFactory as $i,defineToolPreset as Ti}from"@buoy-gg/shared-ui/web";import{useEffect as ar,useState as Ei}from"react";import{reloadApp as Ci}from"@buoy-gg/shared-ui/web";import{bootBeforeActions as Ri,createSyncAdapter as Ii}from"@buoy-gg/shared-ui/web";import{dispatchToolAction as lr}from"@buoy-gg/shared-ui/web";var cr="No sign-in token seen yet. Use the app so it sends a signed-in request, then try again. Tokens are read from the Network tool's captured requests.";function ur(e){pe();let t=ei(e);if(!t)throw new Error(e?`No token "${e}". Read getState for the current ids.`:cr);return t}function dr(e,t=1e4){let r=ur(e);if(r.expiresAt===void 0)throw new Error(r.neverExpires?`${r.label} for ${r.host} is ${r.hint??"a key"} and never expires.`:`${r.label} for ${r.host} (${r.formatLabel}) has no expiry Buoy can read. Use failNextRequest to test the refresh instead.`);let n=r.expiresAt-Math.max(0,t)-Ut();if(n<=0)throw new Error(`${r.label} for ${r.host} has already expired on the app's clock. Go back to real time, or use failNextRequest.`);return Ke(n),jt("expiry",r.id),S()}async function fr(e,t=401,r=1){let n=ur(e),o=ti(n.id);if(!o)throw new Error(cr);await pr();let i=t===403?403:401,s=n.location==="authorization"||n.location==="header"?{urlPattern:`${o}/*`,requireHeader:n.name.toLowerCase()}:n.location==="query"?{urlPattern:`${o}/*${n.name}=*`}:{urlPattern:`${o}/*`},a=await lr("network","upsertOverrideRule",{name:"Clock: force a token refresh",...s,kind:"respond",status:i,headers:{"content-type":"application/json","www-authenticate":'Bearer error="invalid_token", error_description="The access token expired"'},body:JSON.stringify({error:"invalid_token",error_description:"The access token expired (forced by Buoy Clock to test token refresh)"}),times:Math.max(1,Math.min(10,Math.round(r)))}).catch(l=>{let c=l instanceof Error?l.message:String(l);throw new Error(c.includes("Unknown tool")?"Failing a request needs the Network tool (@buoy-gg/network).":c)});if(!a?.ok||!a.rule)throw new Error(a?.error??"Network did not add the override.");return jt("401",n.id,a.rule.id),S()}async function pr(){let e=he().check;e?.ruleId&&e.forcedAt===void 0&&await lr("network","deleteOverrideRule",{id:e.ruleId}).catch(()=>{})}async function hr(){return await pr(),Go(),S()}function H(e){return e&&typeof e=="object"?e:{}}function Qe(e,...t){for(let r of t){let n=e[r];if(typeof n=="string"||typeof n=="number")return n}}function ae(e,t){let r=e[t];if(typeof r=="boolean")return r;if(r==="true")return true;if(r==="false")return false}var et=Ii({version:1,getSnapshot(){return S()},subscribe(e){return ie(e)},actions:{getState(){return pe(),S()},setTime(e){let t=H(e),r=Qe(t,"time","at","date","iso");if(r===void 0)throw new Error('setTime needs `time`: ISO 8601 ("2026-12-31T23:59:50"), epoch ms, or relative ("+1d").');return Jt(r,ae(t,"freeze")??false)},shift(e){let t=H(e),r=Qe(t,"by","ms","duration","delta");if(r===void 0)throw new Error('shift needs `by`: a duration like "+1d", "-2h30m", "90s", or ms.');return Ke(r,ae(t,"fireTimers"))},freeze(e){return Ze(Qe(H(e),"time","at"))},resume(){return Ye()},setRate(e){let t=H(e),r=Number(t.rate??t.speed);if(!Number.isFinite(r))throw new Error("setRate needs a numeric `rate` (1 = normal speed).");return qt(r)},reset(){return Ge()},updateSettings(e){let t=H(e);return Kt({persist:ae(t,"persist"),showChip:ae(t,"showChip"),fireTimersOnJump:ae(t,"fireTimersOnJump")})},jumpToTokenExpiry(e){let t=H(e),r=typeof t.token=="string"?t.token:typeof t.id=="string"?t.id:void 0,n=Number(t.leadMs??t.lead??1e4);return dr(r,Number.isFinite(n)?n:1e4)},failNextRequest(e){let t=H(e),r=typeof t.token=="string"?t.token:typeof t.id=="string"?t.id:void 0,n=Number(t.status??401),o=Number(t.times??1);return fr(r,n,Number.isFinite(o)?o:1)},stopTokenCheck(){return hr()},async holdForReload(){return await Ht(),S()}}});Ri(et,ge);import{useState as ke}from"react";import{ChevronRight as Li,NightButton as zi,NightCard as xe,NightChip as Ni,NightFootnote as tt,NightRows as rt,NightSectionLabel as mr,NightSegmented as Oi,NightSwitch as gr,ProBadge as Di,ProUpgradeModal as Mi,getUseIsPro as Pi,monoFont as Fi,night as b,useSafeAreaInsets as ji}from"@buoy-gg/shared-ui/web";import{ChevronRight as Bi,NightButton as yr,NightCard as _i,NightFootnote as Ui,NightRows as Vi,NightSectionLabel as Hi,ProBadge as Wi,night as k}from"@buoy-gg/shared-ui/web";import{jsx as w,jsxs as z}from"react/jsx-runtime";var _=e=>ee(Math.abs(e),{signed:false});function Ji({snapshot:e,run:t,openId:r,onToggle:n,isPro:o,onUpgrade:i}){let s=e.tokens;return z(m,{children:[w(Hi,{children:s.tokens.length>1?"Sign-in tokens":"Sign-in token"}),w(_i,{children:z(Vi,{children:[s.tokens.map((a,l)=>z(m,{children:[w(qi,{token:a,snapshot:e,index:l,open:r===a.id,onPress:()=>n(a.id)}),r===a.id?w(Ki,{token:a,snapshot:e,run:o?t:()=>i("Sign-in token tests"),isPro:o}):null]},a.id)),s.tokens.length===0?w(m,{style:y.row,testID:"clock-token-empty",children:w(x,{style:y.emptyText,children:s.available?"No token seen yet":"Needs the Network tool"})},"empty"):null]})}),w(Yi,{check:s.check,tokens:s.tokens,snapshot:e,run:t}),s.tokens.length===0?w(Ui,{children:s.available?"Tokens show up here when the app sends a signed-in request.":"Install @buoy-gg/network so the Clock tool can read the app's tokens."}):null]})}function qi({token:e,snapshot:t,index:r,open:n,onPress:o}){let{virtual:i}=B(t,1e3),s=e.expiresAt!==void 0?e.expiresAt-i:void 0,a=e.neverExpires?"No expiry":s===void 0?"Unknown":s<=0?"Expired":_(s),l=s!==void 0&&s<=0?y.valueDanger:s!==void 0&&s<6e4?y.valueWarning:null;return z(P,{testID:`clock-token-${r}`,accessibilityRole:"button",accessibilityLabel:`${e.label} for ${e.host}: ${s!==void 0&&s>0?`expires in ${a}`:a}`,accessibilityState:{expanded:n},activeOpacity:.6,onPress:o,style:y.row,children:[z(m,{style:y.rowText,children:[w(x,{style:y.rowTitle,numberOfLines:1,children:e.label}),w(x,{style:y.rowSubtitle,numberOfLines:1,children:`${e.host} \xB7 ${e.hint??e.formatLabel}`})]}),z(m,{style:y.rowRight,children:[w(x,{style:[y.value,l],testID:`clock-token-${r}-left`,children:a}),w(m,{style:n?y.chevronOpen:null,children:w(Bi,{size:16,color:k.color.textTertiary})})]})]})}function Ki({token:e,snapshot:t,run:r,isPro:n}){let{virtual:o,real:i}=B(t,1e3),s=Zi(e,o,i),a=e.expiresAt!==void 0&&e.expiresAt-o>1e4;return z(m,{style:y.detail,testID:"clock-token-detail",children:[s.map(l=>w(x,{style:[y.detailLine,l.tone==="warn"?y.warn:null,l.tone==="bad"?y.bad:null],children:l.text},l.text)),z(m,{style:y.buttons,children:[w(m,{style:y.button,children:w(yr,{label:"Jump to Expiry",testID:"clock-token-jump",accessibilityLabel:"Jump the app's clock to ten seconds before this token expires",size:"md",disabled:!a,onPress:()=>r("jumpToTokenExpiry",{token:e.id})})}),w(m,{style:y.button,children:w(yr,{label:"Fail Next Request",testID:"clock-token-fail",accessibilityLabel:"Answer the app's next request to this API with 401",size:"md",onPress:()=>r("failNextRequest",{token:e.id})})})]}),n?null:z(m,{style:y.proLine,children:[w(Wi,{}),w(x,{style:[y.hint,y.proHint],children:"Jump to Expiry and Fail Next Request are part of Buoy Pro."})]}),w(x,{style:y.hint,children:a||e.expiresAt===void 0?"Jump tests an app that refreshes before expiry. Fail tests one that refreshes after a 401.":"This token has already expired on the app's clock. Use Real Time to jump to it again."})]})}function Zi(e,t,r){let n=[];if(e.expiresAt!==void 0){if(n.push({text:`Expires ${ye(e.expiresAt)}`}),e.lifetimeMs!==void 0&&e.lifetimeMs>0&&n.push({text:`Lasts ${_(e.lifetimeMs)}${e.expirySource?`, from ${e.expirySource}`:""}`}),e.serverExpiresAt!==void 0){let o=e.expiresAt-t,i=e.serverExpiresAt-r;Math.abs(o-i)>2e3&&n.push({text:i>0?`The server still accepts it for ${_(i)}`:`The server stopped accepting it ${_(i)} ago`})}}else e.neverExpires||n.push({text:"The token doesn't say when it expires, and no login response did either."});if(e.hint&&n.push({text:e.formatLabel}),e.issuedBy&&n.push({text:`Issued by ${e.issuedBy}`}),e.refresh?.expiresAt!==void 0){let o=e.refresh.expiresAt-t;n.push({text:o>0?`Refresh token expires in ${_(o)}`:"Refresh token expired"})}return e.refreshes>0&&e.lastRefreshAt!==void 0&&n.push({text:`Refreshed ${e.refreshes===1?"once":`${e.refreshes} times`}, last at ${X(e.lastRefreshAt)}`}),n.push({text:`Sent with ${e.uses} request${e.uses===1?"":"s"}`}),e.expiredSends>0&&n.push({text:`Sent ${e.expiredSends} time${e.expiredSends===1?"":"s"} after it expired on the app's clock`,tone:"warn"}),e.rejected>0&&n.push({text:`Rejected by the server ${e.rejected} time${e.rejected===1?"":"s"}`,tone:"warn"}),e.looping&&n.push({text:`Refresh loop: ${e.recentRefreshes} new tokens in 20s`,tone:"bad"}),n}function Yi({check:e,tokens:t,snapshot:r,run:n}){let{virtual:o,real:i}=B(r,1e3);if(!e)return null;let s=t.find(c=>c.id===e.tokenId),{text:a,tone:l}=Gi(e,s,o,i);return z(m,{style:y.check,children:[w(x,{style:[y.checkText,l==="good"?y.good:null,l==="bad"?y.bad:null,l==="warn"?y.warn:null],testID:"clock-token-check",children:a}),w(P,{testID:"clock-token-check-done",accessibilityRole:"button",accessibilityLabel:e.status==="waiting"?"Stop the refresh check":"Dismiss",onPress:()=>n("stopTokenCheck"),hitSlop:{top:8,bottom:8,left:8,right:8},children:w(x,{style:y.checkDone,children:e.status==="waiting"?"Stop":"Done"})})]})}function Gi(e,t,r,n){if(e.status==="loop")return{text:`Refresh loop: ${e.newTokens} new tokens since the check started. The new tokens may already look expired to the app's clock.`,tone:"bad"};if(e.status==="refreshed"&&e.sameToken)return{text:`The app got the 401 and refreshed at ${X(e.refreshedAt??n)}. The refresh sent back the same token, and the retry worked.`,tone:"good"};if(e.status==="refreshed"){let a=e.newIssuedBy?` by ${e.newIssuedBy}`:"",l=e.newLifetimeMs&&e.newLifetimeMs>0?`. The new token lasts ${_(e.newLifetimeMs)}`:"",c=e.kind==="401"&&e.forcedAt!==void 0?"The app got the 401 and refreshed":"Refreshed",u=e.failedRefreshes>0?` ${e.failedRefreshes===1?"One token request":`${e.failedRefreshes} token requests`} failed first (${e.lastRefreshError}).`:"";return{text:`${c} at ${X(e.refreshedAt??n)}${a}${l}.${u}`,tone:u?"warn":"good"}}let o=n-e.startedAt,i=(e.staleAfterFailure>0?` It sent the old token again ${e.staleAfterFailure} time${e.staleAfterFailure===1?"":"s"}.`:"")+(e.failedRefreshes>0?` Its token request failed (${e.lastRefreshError}).`:"");if(o>6e4)return{text:`No new token after ${_(o)}. The app may refresh on its next action, or not at all.${i}`,tone:"warn"};if(e.kind==="401")return e.forcedAt===void 0?{text:`The next request to ${t?.host??"the API"} will get a 401. Use the app to send one.`}:{text:`The app got the 401. Waiting for a new token\u2026${i}`,tone:i?"warn":void 0};let s=t?.expiresAt!==void 0?t.expiresAt-r:void 0;return s!==void 0&&s>0?{text:`Expires in ${_(s)} on the app's clock. Waiting for a new token\u2026`}:{text:"Expired on the app's clock. Waiting for the app's next request\u2026"}}var y=q.create({row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:56,paddingHorizontal:k.rowPadH,paddingVertical:10},rowText:{flex:1,minWidth:0},rowTitle:{color:k.color.text,fontSize:k.font.row},rowSubtitle:{color:k.color.textTertiary,fontSize:k.font.caption,marginTop:2},rowRight:{flexDirection:"row",alignItems:"center",gap:6},value:{color:k.color.textSecondary,fontSize:k.font.row,fontVariant:["tabular-nums"]},valueWarning:{color:k.color.warning},valueDanger:{color:k.color.danger},chevronOpen:{transform:[{rotate:"90deg"}]},emptyText:{color:k.color.textSecondary,fontSize:k.font.row},detail:{paddingHorizontal:k.rowPadH,paddingBottom:14,gap:4},detailLine:{color:k.color.textSecondary,fontSize:k.font.caption},buttons:{flexDirection:"row",gap:8,marginTop:8},button:{flex:1},hint:{color:k.color.textTertiary,fontSize:k.font.caption,marginTop:6},proLine:{flexDirection:"row",alignItems:"center",gap:8,marginTop:6},proHint:{marginTop:0,flexShrink:1},check:{flexDirection:"row",alignItems:"flex-start",gap:12,marginTop:8,marginHorizontal:k.labelInset},checkText:{flex:1,color:k.color.textSecondary,fontSize:k.font.caption,lineHeight:18},checkDone:{color:k.color.accent,fontSize:k.font.caption,fontWeight:"600"},good:{color:k.color.accent},warn:{color:k.color.warning},bad:{color:k.color.danger}});import{jsx as d,jsxs as v}from"react/jsx-runtime";var br="#F59E0B";function kr({snapshot:e,onAction:t,onReload:r}){let n=ji({minBottom:16}),[o,i]=ke(null),[s,a]=ke(null),l=Pi()(),[c,u]=ke(null),h=C=>u(C),$=(C,D)=>{i(null),t(C,D).catch(U=>{i(U instanceof Error?U.message:String(U))})},T=C=>a(D=>D===C?null:C);return e?v(yt,{style:g.fill,contentContainerStyle:[g.content,{paddingBottom:n.bottom}],testID:"clock-scroll",keyboardShouldPersistTaps:"handled",children:[d(Xi,{snapshot:e}),o?d(m,{testID:"clock-error",children:d(tt,{tone:"danger",centered:true,children:o})}):null,v(m,{children:[d(mr,{children:"Jump ahead"}),d(es,{run:$})]}),v(m,{children:[d(xe,{children:v(rt,{children:[v(m,{children:[d(wr,{title:"Date & Time",testID:"clock-date-row",open:s==="date",onPress:()=>T("date"),value:d(ts,{snapshot:e})}),s==="date"?d(ns,{snapshot:e,run:$,onDone:()=>a(null)}):null]},"date"),v(m,{style:g.row,children:[d(nt,{title:"Freeze",isPro:l}),d(gr,{value:e.mode==="frozen",testID:"clock-freeze",accessibilityLabel:"Freeze the clock",onValueChange:C=>C&&!l?h("Freeze"):$(C?"freeze":"resume")})]},"freeze"),v(m,{children:[d(wr,{title:"Speed",pro:!l,testID:"clock-speed-row",open:s==="speed",onPress:()=>l?T("speed"):h("Speed"),value:d(x,{style:g.rowValue,children:Sr(e)})}),s==="speed"?d(os,{snapshot:e,run:$}):null]},"speed")]})}),d(tt,{children:"Only this app's clock changes. Screens pick up the new time when they next render, or all at once when you reload."})]}),e.tokens?d(Ji,{snapshot:e,run:$,openId:s,onToggle:T,isPro:l,onUpgrade:h}):null,d(xe,{children:v(rt,{children:[r?d(vr,{label:"Reload App",testID:"clock-reload",onPress:r},"reload"):null,d(vr,{label:"Use Real Time",accessibilityLabel:"Reset to real time",testID:"clock-reset",destructive:true,disabled:e.mode==="real",onPress:()=>$("reset")},"reset")]})}),v(m,{children:[d(mr,{children:"Options"}),d(ss,{settings:e.settings,run:$,isPro:l,onUpgrade:h})]}),d(Mi,{visible:c!==null&&!l,onClose:()=>u(null),featureName:c??void 0})]}):d(m,{style:g.waiting,testID:"clock-waiting",children:d(tt,{centered:true,children:"Waiting for the app's clock\u2026"})})}function nt({title:e,isPro:t}){return v(m,{style:g.titleRow,children:[d(x,{style:g.rowTitle,children:e}),t?null:d(Di,{})]})}function Xi({snapshot:e}){let{virtual:t,real:r}=B(e),n=rr(e),o=e.mode!=="real",i=ki(t-r),s=e.mode==="frozen"?" \xB7 Frozen":o&&e.rate!==1?` \xB7 ${Sr(e)}`:"";return v(m,{style:g.hero,children:[d(x,{style:[g.heroTime,o?g.heroTimeActive:null],testID:"clock-hero-time",accessibilityLabel:`App clock ${X(t)}`,children:X(t)}),d(x,{style:g.heroDate,testID:"clock-hero-date",children:bi(t)}),d(m,{testID:"clock-status",accessibilityLabel:`Clock status: ${n.label}${o?`, ${i}`:""}`,children:d(x,{style:[g.heroStatus,o?g.heroStatusActive:null],testID:"clock-offset",children:o?`${i}${s}`:"Real time"})})]})}var xr=36e5,ot=24*xr,Qi=[{ms:xr,unit:"hour"},{ms:ot,unit:"day"},{ms:7*ot,unit:"week"},{ms:30*ot,unit:"month"}];function es({run:e}){return d(xe,{style:g.jumpBar,children:Qi.map((t,r)=>v(P,{testID:xi(t.ms),accessibilityRole:"button",accessibilityLabel:`Jump ahead one ${t.unit}`,activeOpacity:.6,onPress:()=>e("shift",{by:t.ms}),style:[g.jump,r>0?g.jumpDivider:null],children:[d(x,{style:g.jumpAmount,children:"+1"}),d(x,{style:g.jumpUnit,children:t.unit})]},t.unit))})}function wr({title:e,pro:t,value:r,open:n,onPress:o,testID:i}){return v(P,{testID:i,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{expanded:n},activeOpacity:.6,onPress:o,style:g.row,children:[d(nt,{title:e,isPro:!t}),v(m,{style:g.rowRight,children:[r,d(m,{style:n?g.chevronOpen:null,children:d(Li,{size:16,color:b.color.textTertiary})})]})]})}function ts({snapshot:e}){let{virtual:t}=B(e,1e3);return d(x,{style:[g.rowValue,g.tabular],numberOfLines:1,children:ye(t,false)})}function vr({label:e,onPress:t,testID:r,destructive:n,disabled:o,accessibilityLabel:i}){return d(P,{testID:r,accessibilityRole:"button",accessibilityLabel:i??e,accessibilityState:{disabled:!!o},activeOpacity:.6,disabled:o,onPress:t,style:[g.row,o?g.rowDisabled:null],children:d(x,{style:[g.actionLabel,n?g.actionDestructive:null],children:e})})}var rs=wt.filter(e=>["midnight","month-end","year-end"].includes(e.id));function ns({snapshot:e,run:t,onDone:r}){let[n,o]=ke(""),{virtual:i}=B(e,1e3),s=()=>n.trim()||tr(i),a=e.mode==="frozen",l=c=>{t("setTime",{time:c,freeze:a}),r()};return v(m,{style:g.editor,children:[v(m,{style:g.inputRow,children:[d(gt,{testID:"clock-time-input",accessibilityLabel:"Date and time",value:n,onChangeText:o,placeholder:tr(i),placeholderTextColor:b.color.placeholder,autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>l(s()),style:g.input}),d(zi,{label:"Set",testID:"clock-time-apply",accessibilityLabel:"Set this time",size:"md",variant:"primary",fullWidth:false,onPress:()=>l(s())})]}),d(x,{style:g.hint,children:"Year-month-day and 24-hour time, or +3d, -2h"}),d(m,{style:g.presets,children:rs.map(c=>d(Ni,{label:c.label,testID:`clock-preset-${c.id}`,onPress:()=>l(c.at(i,M))},c.id))})]})}var Ar=[{key:"1",label:"Normal"},{key:"10",label:"10\xD7"},{key:"60",label:"1 min/s"},{key:"3600",label:"1 hr/s"}];function Sr(e){return e.mode==="real"||e.rate===1?"Normal":Ar.find(t=>Number(t.key)===e.rate)?.label??vt(e.rate)}function os({snapshot:e,run:t}){let r=e.mode==="real"?"1":String(e.rate);return v(m,{style:g.editor,children:[d(m,{style:g.segmentRow,children:d(Oi,{tabs:Ar,activeKey:r,size:"sm",testIDPrefix:"clock-speed",onChange:n=>t("setRate",{rate:Number(n)})})}),d(x,{style:g.hint,children:"Taps, animations and timers keep real speed."})]})}var is=[{key:"showChip",title:"Show Floating Clock"},{key:"persist",title:"Keep After Reload",pro:true}];function ss({settings:e,run:t,isPro:r,onUpgrade:n}){return d(xe,{children:d(rt,{children:is.map(o=>{let i=!!o.pro&&!r;return v(m,{style:g.row,children:[d(nt,{title:o.title,isPro:!i}),d(gr,{value:i?false:e[o.key],testID:`clock-setting-${o.key}`,accessibilityLabel:o.title,onValueChange:s=>i?n(o.title):t("updateSettings",{[o.key]:s})})]},o.key)})})})}var g=q.create({fill:{flex:1},content:{paddingHorizontal:b.gutter,paddingTop:8,gap:b.groupGap},waiting:{flex:1,alignItems:"center",justifyContent:"center",padding:24},hero:{alignItems:"center",paddingTop:12},heroTime:{color:b.color.text,fontSize:56,fontWeight:"200",fontVariant:["tabular-nums"],letterSpacing:1},heroTimeActive:{color:br},heroDate:{color:b.color.text,fontSize:17,fontWeight:"500",marginTop:2},heroStatus:{color:b.color.textTertiary,fontSize:b.font.caption,fontWeight:"500",marginTop:6},heroStatusActive:{color:b.color.textSecondary},jumpBar:{flexDirection:"row"},jump:{flex:1,alignItems:"center",paddingVertical:12},jumpDivider:{borderLeftWidth:q.hairlineWidth,borderLeftColor:b.color.separator},jumpAmount:{color:br,fontSize:17,fontWeight:"600",fontVariant:["tabular-nums"]},jumpUnit:{color:b.color.textSecondary,fontSize:b.font.caption,marginTop:1},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:50,paddingHorizontal:b.rowPadH,paddingVertical:10},rowDisabled:{opacity:.4},rowTitle:{color:b.color.text,fontSize:b.font.row},titleRow:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:1},rowRight:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},rowValue:{color:b.color.textSecondary,fontSize:b.font.row},tabular:{fontVariant:["tabular-nums"]},chevronOpen:{transform:[{rotate:"90deg"}]},actionLabel:{color:b.color.accent,fontSize:b.font.row},actionDestructive:{color:b.color.danger},editor:{paddingHorizontal:b.rowPadH,paddingBottom:14,gap:10},inputRow:{flexDirection:"row",alignItems:"center",gap:8},input:{flex:1,color:b.color.text,fontFamily:Fi,fontSize:15,backgroundColor:b.color.bg,borderRadius:b.radius.input,borderWidth:1,borderColor:b.color.border,paddingHorizontal:12,paddingVertical:8},hint:{color:b.color.textTertiary,fontSize:b.font.caption},presets:{flexDirection:"row",flexWrap:"wrap",gap:6},segmentRow:{flexDirection:"row"}});import{jsx as as}from"react/jsx-runtime";var ls=et.actions;async function cs(e,t){let r=ls[e];if(!r)throw new Error(`Unknown clock action: ${e}`);return r(t)}function us(){Ht().then(()=>Ci("auto","buoy clock")).catch(()=>{})}function $r(){ar(()=>{ge(),pe()},[]);let[e,t]=Ei(S);return ar(()=>ie(()=>t(S())),[]),as(kr,{snapshot:e,onAction:cs,onReload:us})}import{jsx as ds}from"react/jsx-runtime";var Tr=Ti({id:"clock",name:"CLOCK",description:"Travel to any date, freeze or speed up the app's clock",slot:"both",color:Si,icon:({size:e,color:t})=>ds(Ai,{size:e,color:t}),component:$r,modal:{subtitle:"override the app's date & time"}}),fs=$i(Tr);import{ClockToolIcon as ps,CLOCK_TOOL_ICON_COLOR as hs}from"@buoy-gg/shared-ui/web";var ms=typeof navigator<"u"&&navigator.product==="ReactNative",gs=(()=>{try{return globalThis.Capacitor?.isNativePlatform?.()===true}catch{return false}})();ms||gs?(Pr(mt),ir(),typeof at<"u"&&at&&ge()):typeof globalThis.document<"u"&&ir();export{be as CLOCK_CHIP_ID,hs as CLOCK_TOOL_ICON_COLOR,$r as ClockBody,sr as ClockChip,ps as ClockToolIcon,kr as ClockToolView,wt as TIME_PRESETS,ge as bootClock,et as clockSyncAdapter,Tr as clockToolPreset,fs as createClockTool,fr as failNextRequest,ee as formatDuration,Ze as freeze,S as getClockSnapshot,he as getTokenReport,ce as inspectToken,Vt as isClockOverridden,dr as jumpToTokenExpiry,vi as openClockChip,Ce as parseDuration,ii as previewJump,A as realNow,Ge as reset,Ye as resume,qt as setRate,Jt as setTime,Ke as shift,pe as startTokenWatch,hr as stopTokenCheck,ie as subscribeClock,j as tokenFingerprint,Kt as updateSettings,B as useLiveClock,Ut as virtualNow,zr as withRealClock};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/clock",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.86",
|
|
4
4
|
"description": "Clock override for React Native: travel to any date, freeze or speed up time, and jump ahead while firing due timers. Test expirations, countdowns and renewals without touching the device clock.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./lib/web/**/*.mjs"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@buoy-gg/shared-ui": "^7.0.
|
|
20
|
+
"@buoy-gg/shared-ui": "^7.0.86"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": "*"
|