@buoy-gg/clock 7.0.63 → 7.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.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)(_sharedUi.NightFootnote,{tone:"danger",centered:true,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{testID:"clock-error",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[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 +1 @@
|
|
|
1
|
-
"use strict";import{useState as S}from"react";import{ScrollView as $,StyleSheet as L,Text as
|
|
1
|
+
"use strict";import{useState as S}from"react";import{ScrollView as $,StyleSheet as L,Text as h,TextInput as H,TouchableOpacity as x,View as n}from"react-native";import{ChevronRight as _,NightButton as J,NightCard as w,NightChip as M,NightFootnote as I,NightRows as v,NightSectionLabel as A,NightSegmented as K,NightSwitch as O,ProBadge as Y,ProUpgradeModal as G,getUseIsPro as q,monoFont as Q,night as i,useSafeAreaInsets as X}from"@buoy-gg/shared-ui";import{TIME_PRESETS as Z,formatRate as ee}from"../engine/clockMath";import{RealDate as te}from"../engine/patches";import{useLiveClock as z}from"./useLiveClock";import{TokenSection as re}from"./TokenSection";import{clockStatus as oe,formatClockDate as ie,formatChipTime as le,formatClockTime as V,formatInputTime as N,formatOffset as ne,jumpTestId as ce}from"./format";import{jsx as e,jsxs as c}from"react/jsx-runtime";const j="#F59E0B";export function ClockToolView({snapshot:t,onAction:o,onReload:s}){const d=X({minBottom:16});const[l,a]=S(null);const[u,y]=S(null);const m=q()();const[p,C]=S(null);const b=f=>C(f);const g=(f,D)=>{a(null);o(f,D).catch(T=>{a(T instanceof Error?T.message:String(T))})};const k=f=>y(D=>D===f?null:f);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(ae,{snapshot:t}),l?e(n,{testID:"clock-error",children:e(I,{tone:"danger",centered:true,children:l})}):null,c(n,{children:[e(A,{children:"Jump ahead"}),e(de,{run:g})]}),c(n,{children:[e(w,{children:c(v,{children:[c(n,{children:[e(B,{title:"Date & Time",testID:"clock-date-row",open:u==="date",onPress:()=>k("date"),value:e(ue,{snapshot:t})}),u==="date"?e(he,{snapshot:t,run:g,onDone:()=>y(null)}):null]},"date"),c(n,{style:r.row,children:[e(P,{title:"Freeze",isPro:m}),e(O,{value:t.mode==="frozen",testID:"clock-freeze",accessibilityLabel:"Freeze the clock",onValueChange:f=>f&&!m?b("Freeze"):g(f?"freeze":"resume")})]},"freeze"),c(n,{children:[e(B,{title:"Speed",pro:!m,testID:"clock-speed-row",open:u==="speed",onPress:()=>m?k("speed"):b("Speed"),value:e(h,{style:r.rowValue,children:W(t)})}),u==="speed"?e(pe,{snapshot:t,run:g}):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(re,{snapshot:t,run:g,openId:u,onToggle:k,isPro:m,onUpgrade:b}):null,e(w,{children:c(v,{children:[s?e(F,{label:"Reload App",testID:"clock-reload",onPress:s},"reload"):null,e(F,{label:"Use Real Time",accessibilityLabel:"Reset to real time",testID:"clock-reset",destructive:true,disabled:t.mode==="real",onPress:()=>g("reset")},"reset")]})}),c(n,{children:[e(A,{children:"Options"}),e(ge,{settings:t.settings,run:g,isPro:m,onUpgrade:b})]}),e(G,{visible:p!==null&&!m,onClose:()=>C(null),featureName:p??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(Y,{})]})}function ae({snapshot:t}){const{virtual:o,real:s}=z(t);const d=oe(t);const l=t.mode!=="real";const a=ne(o-s);const u=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 ${V(o)}`,children:V(o)}),e(h,{style:r.heroDate,testID:"clock-hero-date",children:ie(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}${u}`:"Real time"})})]})}const E=36e5;const R=24*E;const se=[{ms:E,unit:"hour"},{ms:R,unit:"day"},{ms:7*R,unit:"week"},{ms:30*R,unit:"month"}];function de({run:t}){return e(w,{style:r.jumpBar,children:se.map((o,s)=>c(x,{testID:ce(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 B({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(_,{size:16,color:i.color.textTertiary})})]})]})}function ue({snapshot:t}){const{virtual:o}=z(t,1e3);return e(h,{style:[r.rowValue,r.tabular],numberOfLines:1,children:le(o,false)})}function F({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 me=Z.filter(t=>["midnight","month-end","year-end"].includes(t.id));function he({snapshot:t,run:o,onDone:s}){const[d,l]=S("");const{virtual:a}=z(t,1e3);const u=()=>d.trim()||N(a);const y=t.mode==="frozen";const m=p=>{o("setTime",{time:p,freeze:y});s()};return c(n,{style:r.editor,children:[c(n,{style:r.inputRow,children:[e(H,{testID:"clock-time-input",accessibilityLabel:"Date and time",value:d,onChangeText:l,placeholder:N(a),placeholderTextColor:i.color.placeholder,autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>m(u()),style:r.input}),e(J,{label:"Set",testID:"clock-time-apply",accessibilityLabel:"Set this time",size:"md",variant:"primary",fullWidth:false,onPress:()=>m(u())})]}),e(h,{style:r.hint,children:"Year-month-day and 24-hour time, or +3d, -2h"}),e(n,{style:r.presets,children:me.map(p=>e(M,{label:p.label,testID:`clock-preset-${p.id}`,onPress:()=>m(p.at(a,te))},p.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??ee(t.rate)}function pe({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(K,{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 fe=[{key:"showChip",title:"Show Floating Clock"},{key:"persist",title:"Keep After Reload",pro:true}];function ge({settings:t,run:o,isPro:s,onUpgrade:d}){return e(w,{children:e(v,{children:fe.map(l=>{const a=!!l.pro&&!s;return c(n,{style:r.row,children:[e(P,{title:l.title,isPro:!a}),e(O,{value:a?false:t[l.key],testID:`clock-setting-${l.key}`,accessibilityLabel:l.title,onValueChange:u=>a?d(l.title):o("updateSettings",{[l.key]:u})})]},l.key)})})})}const r=L.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:j},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:L.hairlineWidth,borderLeftColor:i.color.separator},jumpAmount:{color:j,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:Q,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"}});
|
package/lib/web/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";var mt=Object.defineProperty;var Br=Object.getOwnPropertyDescriptor;var Ur=Object.getOwnPropertyNames;var Hr=Object.prototype.hasOwnProperty;var Vr=(e,t)=>{for(var r in t)mt(e,r,{get:t[r],enumerable:true})},gt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ur(t))!Hr.call(e,o)&&o!==r&&mt(e,o,{get:()=>t[o],enumerable:!(n=Br(t,o))||n.enumerable});return e},Wr=(e,t,r)=>(gt(e,t,"default"),r&>(r,t,"default"));var yt=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);var bt={};Vr(bt,{AccessibilityInfo:()=>Zr,ActivityIndicator:()=>Hn,Alert:()=>Jn,Animated:()=>kt,AppRegistry:()=>Gr,AppState:()=>Xr,Appearance:()=>Yr,BackHandler:()=>Qr,Button:()=>Vn,CheckBox:()=>gn,Clipboard:()=>en,DeviceEventEmitter:()=>Pn,Dimensions:()=>tn,Easing:()=>rn,FlatList:()=>yn,I18nManager:()=>nn,Image:()=>bn,ImageBackground:()=>kn,InteractionManager:()=>an,Keyboard:()=>on,KeyboardAvoidingView:()=>xn,LayoutAnimation:()=>sn,Linking:()=>ln,LogBox:()=>On,Modal:()=>Bn,NativeEventEmitter:()=>cn,NativeModules:()=>Kr,PanResponder:()=>un,Picker:()=>vn,PixelRatio:()=>fn,Platform:()=>dn,Pressable:()=>Fn,ProgressBar:()=>wn,RefreshControl:()=>Tn,SafeAreaView:()=>An,ScrollView:()=>vt,SectionList:()=>Sn,Share:()=>pn,StatusBar:()=>$n,StyleSheet:()=>Y,Switch:()=>Un,Text:()=>w,TextInput:()=>xt,Touchable:()=>In,TouchableHighlight:()=>Mn,TouchableNativeFeedback:()=>Rn,TouchableOpacity:()=>B,TouchableWithoutFeedback:()=>_n,UIManager:()=>hn,Vibration:()=>mn,View:()=>m,VirtualizedList:()=>Cn,YellowBox:()=>Dn,findNodeHandle:()=>Wn,unstable_createElement:()=>qr,useColorScheme:()=>Nn,useLocaleContext:()=>En,useWindowDimensions:()=>zn});Wr(bt,Jr);import*as Jr from"react-native-web";import{unstable_createElement as qr,NativeModules as Kr,AccessibilityInfo as Zr,Animated as kt,Appearance as Yr,AppRegistry as Gr,AppState as Xr,BackHandler as Qr,Clipboard as en,Dimensions as tn,Easing as rn,I18nManager as nn,Keyboard as on,InteractionManager as an,LayoutAnimation as sn,Linking as ln,NativeEventEmitter as cn,PanResponder as un,PixelRatio as fn,Platform as dn,Share as pn,StyleSheet as Y,UIManager as hn,Vibration as mn,CheckBox as gn,FlatList as yn,Image as bn,ImageBackground as kn,KeyboardAvoidingView as xn,Picker as vn,ProgressBar as wn,RefreshControl as Tn,SafeAreaView as An,SectionList as Sn,StatusBar as $n,Touchable as In,TouchableNativeFeedback as Rn,VirtualizedList as Cn,YellowBox as Dn,LogBox as On,DeviceEventEmitter as Pn,useColorScheme as Nn,useLocaleContext as En,useWindowDimensions as zn}from"react-native-web";import*as D from"react-native-web";import{createElement as Ln,forwardRef as jn}from"react";function P(e){let t=jn((n,o)=>{let{accessibilityState:i,accessibilityValue:a,...s}=n;for(let l of["busy","checked","disabled","expanded","selected"])i?.[l]!==void 0&&s[`aria-${l}`]===void 0&&(s[`aria-${l}`]=i[l]);for(let[l,c]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[l]!==void 0&&s[`aria-${c}`]===void 0&&(s[`aria-${c}`]=a[l]);return Ln(e,{...s,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var m=P(D.View),w=P(D.Text),xt=P(D.TextInput),B=P(D.TouchableOpacity),Mn=P(D.TouchableHighlight),_n=P(D.TouchableWithoutFeedback),Fn=P(D.Pressable),vt=P(D.ScrollView),Bn=P(D.Modal),Un=P(D.Switch),Hn=P(D.ActivityIndicator),Vn=P(D.Button),Wn=D.findNodeHandle,Jn={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 a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let s=r?.length?r:[{text:"OK"}],l=()=>{o.close?.(),o.remove()};for(let c of s){let f=document.createElement("button");f.type="button",f.textContent=c.text??"OK",f.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${c.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,f.onclick=()=>{l(),c.onPress?.()},a.appendChild(f)}o.addEventListener("cancel",c=>{c.preventDefault(),n?.cancelable!==false&&(l(),n?.onDismiss?.())}),o.appendChild(a),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};var Ce=Object.freeze({mode:"real",anchorReal:0,anchorVirtual:0,rate:1}),De=.1,Oe=86400,qn=864e13;function M(e,t){return e.mode==="real"?t:e.mode==="frozen"?e.anchorVirtual:e.anchorVirtual+(t-e.anchorReal)*e.rate}function Kn(e,t){return M(e,t)-t}function G(e){if(!Number.isFinite(e)||Math.abs(e)>qn)throw new RangeError(`Not a valid time: ${e}`);return Math.round(e)}function Pe(e,t,r,n=false){return{mode:n?"frozen":"running",anchorReal:t,anchorVirtual:G(r),rate:e.mode==="real"?1:e.rate}}function Zn(e,t,r){if(!Number.isFinite(r))throw new RangeError("Jump must be a number of ms");return Pe(e,t,M(e,t)+r,e.mode==="frozen")}function Yn(e,t,r){return Pe(e,t,r??M(e,t),true)}function Gn(e,t){return e.mode!=="frozen"?e:{...e,mode:"running",anchorReal:t}}function Xn(e,t,r){if(!Number.isFinite(r)||r<De||r>Oe)throw new RangeError(`Speed must be between ${De}\xD7 and ${Oe}\xD7`);return e.mode==="real"&&r===1?e:{mode:"running",anchorReal:t,anchorVirtual:G(M(e,t)),rate:r}}function wt(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>=De&&t.rate<=Oe}var Qn={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 Ne(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="",a;for(;a=n.exec(t);){let s=Qn[a[2]];if(s===void 0)throw new RangeError(`Unknown time unit "${a[2]}" in "${e}"`);o+=Number(a[1])*s,i+=a[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 te(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[a,s]of i)if(n>=s&&(o.push(`${Math.floor(n/s)}${a}`),n%=s),o.length===2)break;return`${t?r:""}${o.join(" ")}`}function Tt(e,t,r){if(typeof e=="number")return G(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 G(t+Ne(n));if(/^\d{11,}$/.test(n))return G(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 G(i)}var Ee=1e4,At=[{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}}}],Oa=[{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 St(e){return e===3600?"1h/s":e===600?"10m/s":e===60?"1m/s":`${Number.isInteger(e)?e:e.toFixed(1)}\xD7`}var N=globalThis,pe="__buoyClock",A=N.__buoyRealDate??(Date[pe]?Date.__buoyRealDate:Date);N.__buoyRealDate=A;var $t=A.now.bind(A);function S(){return $t()}N.__buoyRealNow=S;var ze=null,Le=0;function he(){let e=$t();return!ze||Le>0?e:ze(e)}function It(e){ze=e}function je(e){Le+=1;try{return e()}finally{Le-=1}}N.__buoyWithRealClock=je;function _(...e){let t=new.target;return t?Reflect.construct(A,e.length===0?[he()]:e,t):new A(he()).toString()}_.prototype=A.prototype;Object.defineProperty(_,"name",{value:"Date"});Object.defineProperty(_,"length",{value:7});Object.defineProperty(_,"now",{value:function(){return he()},writable:true,configurable:true});Object.defineProperty(_,"parse",{value:A.parse,writable:true,configurable:true});Object.defineProperty(_,"UTC",{value:A.UTC,writable:true,configurable:true});Object.defineProperty(_,pe,{value:true});Object.defineProperty(_,"__buoyRealDate",{value:A});var re=_,me=false,ge;function eo(){return me&&N.Date===re}function to(){if(N.Date===re){me=true;return}let e=Object.getOwnPropertyDescriptor(N,"Date");Object.defineProperty(N,"Date",{value:re,writable:e?.writable??true,enumerable:e?.enumerable??false,configurable:true}),ge=Object.getOwnPropertyDescriptor(A.prototype,"constructor");try{Object.defineProperty(A.prototype,"constructor",{value:re,writable:true,enumerable:false,configurable:true})}catch{}me=true}function ro(){if(N.Date===re){let e=Object.getOwnPropertyDescriptor(N,"Date");Object.defineProperty(N,"Date",{value:A,writable:e?.writable??true,enumerable:e?.enumerable??false,configurable:true})}if(ge){try{Object.defineProperty(A.prototype,"constructor",ge)}catch{}ge=void 0}me=false}var ne=[];function Rt(e){return function(t,...r){return e.call(this,t===void 0?he():t,...r)}}function no(){if(ne.length)return;let e=N.Intl?.DateTimeFormat?.prototype;if(e)for(let t of["format","formatToParts"]){let r=Object.getOwnPropertyDescriptor(e,t);if(!(!r||!r.configurable))try{if(typeof r.get=="function"){let n=r.get;Object.defineProperty(e,t,{...r,get(){return Rt(n.call(this))}})}else if(typeof r.value=="function")Object.defineProperty(e,t,{...r,value:Rt(r.value)});else continue;ne.push({proto:e,name:t,original:r})}catch{}}}function oo(){for(let{proto:e,name:t,original:r}of ne)try{Object.defineProperty(e,t,r)}catch{}ne=[]}function io(){return ne.length>0}function ao(){to(),no()}function so(){ro(),oo()}var Me=false;function lo(e){let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(!Object.prototype.hasOwnProperty.call(t,pe)){for(let r of["start","onUpdate"]){let n=Object.getOwnPropertyDescriptor(t,r);if(n&&typeof n.value=="function"){let o=n.value;t[r]=function(...i){return je(()=>o.apply(this,i))}}}try{Object.defineProperty(t,pe,{value:true})}catch{return}}t=Object.getPrototypeOf(t)}}function co(e){if(Me)return true;try{let t=e;if(typeof t?.Value!="function")return false;let r=Object.getPrototypeOf(new t.Value(0)),n=r?.animate;return typeof n!="function"?false:(r.animate=function(o,...i){return o&&typeof o=="object"&&lo(o),n.call(this,o,...i)},Me=true,true)}catch{return false}}function uo(){return Me}var oe=globalThis,Ct="__buoyClockTimer",E=new Map,J=null,fo={},Dt=0,q=()=>S()+Dt;function po(e){(J?.setTimeout??setTimeout)(()=>{throw e},0)}function Ot(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function ho(){return J!==null}function Pt(){if(J)return true;let{setTimeout:e,clearTimeout:t,setInterval:r,clearInterval:n}=oe;if(typeof e!="function"||typeof t!="function")return false;if(e[Ct])return true;fo={setTimeout:e,clearTimeout:t,setInterval:r,clearInterval:n},J={setTimeout:e.bind(globalThis),clearTimeout:t.bind(globalThis),setInterval:(typeof r=="function"?r:e).bind(globalThis),clearInterval:(typeof n=="function"?n:t).bind(globalThis)};let o=J,i=function(f,v,...b){if(typeof f!="function")return o.setTimeout(f,v,...b);let I=Ot(v),k,C=function(){return E.delete(k),f.apply(this,b)};return k=o.setTimeout(C,v),E.set(k,{kind:"timeout",callback:f,args:b,delay:I,due:q()+I,realHandle:k,run:C}),k},a=function(f,v,...b){if(typeof f!="function")return o.setInterval(f,v,...b);let I=Ot(v),k,C=function(){let L=E.get(k);return L&&(L.due=q()+I),f.apply(this,b)};return k=o.setInterval(C,v),E.set(k,{kind:"interval",callback:f,args:b,delay:I,due:q()+I,realHandle:k,run:C}),k},s=(f,v)=>{let b=E.get(f);return b?(E.delete(f),b.kind==="interval"?o.clearInterval(b.realHandle):o.clearTimeout(b.realHandle)):v(f)},l=function(f){return s(f,o.clearTimeout)},c=function(f){return s(f,o.clearInterval)};globalThis.__buoyRealTimers={setTimeout:o.setTimeout,clearTimeout:l,setInterval:o.setInterval,clearInterval:c};for(let f of[i,a,l,c])Object.defineProperty(f,Ct,{value:true});return oe.setTimeout=i,oe.clearTimeout=l,oe.setInterval=a,oe.clearInterval=c,true}function mo(){let e=q(),t=0,r=0,n=null;for(let o of E.values())if(o.kind==="interval")r+=1;else{t+=1;let i=Math.max(0,o.due-e);(n===null||i<n)&&(n=i)}return{total:t+r,timeouts:t,intervals:r,nextTimeoutInMs:n}}function go(e){let t=q(),r=0;for(let n of E.values())n.due-t<=e&&(r+=1);return r}function yo(e){if(!J||!(e>0))return 0;let t=J;Dt+=e;let r=q(),n=[...E.entries()].filter(([,a])=>a.due<=r).sort((a,s)=>a[1].due-s[1].due),o=0;for(let[a,s]of n)if(E.has(a)){s.kind==="timeout"?(E.delete(a),t.clearTimeout(s.realHandle)):s.due=r+s.delay;try{s.callback(...s.args)}catch(l){po(l)}o+=1}let i=q();for(let a of E.values())a.kind==="timeout"&&(t.clearTimeout(a.realHandle),a.realHandle=t.setTimeout(a.run,Math.max(0,a.due-i)));return o}import{devToolsStorageKeys as bo,persistentStorage as Nt}from"@buoy-gg/shared-ui/web";function ko(){try{let e=globalThis.localStorage;return e?Et(e.getItem(_e)):void 0}catch{return}}var ie={persist:true,showChip:true,fireTimersOnJump:true},xo=2*6e4,_e=bo.clock.state();function Et(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&&wt(t.reload.anchor)&&typeof t.reload.at=="number"?{anchor:t.reload.anchor,at:t.reload.at}:void 0;return{v:1,anchor:wt(t.anchor)?t.anchor:null,...n?{reload:n}:{},settings:{persist:typeof r.persist=="boolean"?r.persist:ie.persist,showChip:typeof r.showChip=="boolean"?r.showChip:ie.showChip,fireTimersOnJump:typeof r.fireTimersOnJump=="boolean"?r.fireTimersOnJump:ie.fireTimersOnJump}}}catch{return null}}async function vo(){try{return Et(await Nt.getItem(_e))}catch{return null}}var Fe=Promise.resolve();function Be(e){let t=JSON.stringify(e);return Fe=Fe.then(()=>Nt.setItem(_e,t)).catch(()=>{}),Fe.then(()=>{})}import{dispatchToolAction as wo}from"@buoy-gg/shared-ui/web";import{loadToolModule as To}from"@buoy-gg/shared-ui/web/utils";var zt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ye={};for(let e=0;e<zt.length;e++)ye[zt[e]]=e;ye["-"]=62;ye._=63;function Ue(e){let t=e.replace(/=+$/,""),r=[],n=0,o=0;for(let i=0;i<t.length;i++){let a=ye[t[i]];if(a===void 0)return null;n=n<<6|a,o+=6,o>=8&&(o-=8,r.push(n>>o&255))}return r}function Ao(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 a=1;a<=i;a++){let s=e[r+a];if(s===void 0||(s&192)!==128)return null;o=o<<6|s&63}t+=String.fromCodePoint(o),r+=i+1}return t}function He(e){let t=Ue(e);return t?Lt(t):null}function Lt(e){let t=Ao(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 Ve(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 ae(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 ae(Number(r),t);let n=t(r);return Number.isFinite(n)?n:void 0}}function So(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 $o=/^[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]*$/,Io=/^[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]*$/,jt=/^v([1-4])\.(local|public)\.([A-Za-z0-9_-]+)(?:\.([A-Za-z0-9_-]+))?$/,Ro={1:256,2:64,3:96,4:64};function U(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 Co(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 Do(e,t){let r={iss:U(e.iss),aud:U(e.aud),sub:U(e.sub),scope:U(e.scope??e.scp),use:U(e.token_use)},n=Ve(e.exp);return{claims:r,issuedAt:Ve(e.iat),notBefore:Ve(e.nbf),expiresAt:n,expirySource:n?t:void 0}}function Oo(e){let[t,r]=e.split("."),n=He(t);if(!n||typeof n.alg!="string"&&typeof n.typ!="string")return null;let o=He(r);if(!o)return null;let i=typeof n.alg=="string"?n.alg:void 0,a=Do(o,"exp claim");return a.claims.alg=i,!a.claims.use&&typeof n.typ=="string"&&n.typ.toUpperCase()!=="JWT"&&(a.claims.use=n.typ),{format:"jwt",formatLabel:i?`JWT \xB7 ${i}`:"JWT",hint:Co(a.claims,n),...a}}function Po(e){let t=He(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 No(e,t){let r=jt.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 a=Ue(i),s=Ro[n],l=a&&a.length>s?Lt(a.slice(0,a.length-s)):null,c={format:"paseto-public",formatLabel:`PASETO v${n}`,claims:{}};return l&&(c.claims={iss:U(l.iss),aud:U(l.aud),sub:U(l.sub)},c.issuedAt=ae(l.iat,t),c.notBefore=ae(l.nbf,t),c.expiresAt=ae(l.exp,t),c.expiresAt&&(c.expirySource="exp claim")),c}function Eo(e){if(!e.startsWith("gAAAAA")||e.length<76)return null;let t=Ue(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 zo=[{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 be(e,t=Date.parse){let r=e.trim().replace(/^"(.*)"$/,"$1");if(r.length<16||/\s/.test(r))return null;if($o.test(r)){let i=Oo(r);if(i)return i}if(Io.test(r)){let i=Po(r);if(i)return i}if(r.startsWith("v")&&jt.test(r)){let i=No(r,t);if(i)return i}let n=Eo(r);if(n)return n;let o=zo.find(i=>i.test.test(r));return{format:"opaque",formatLabel:"Opaque",hint:o?.hint,neverExpires:o?.neverExpires,claims:{}}}function Lo(e){return!!e&&e.format!=="opaque"}function H(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 We(e){let t=/^([a-z][a-z0-9+.-]*:\/\/[^/?#]+)/i.exec(e);return t?t[1].toLowerCase():null}function jo(e){let t=We(e);return t?t.replace(/^[a-z][a-z0-9+.-]*:\/\//,""):"unknown"}function Je(e){return e.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/?#]+/i,"").split(/[?#]/)[0]||"/"}function Mo(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 qe=/(token|jwt|session|auth|appcheck|api[-_]?key|apikey|credential|bearer)/i,_o=new Set(["authorization","cookie","dpop","idempotency-key","x-request-id","x-correlation-id","www-authenticate","proxy-authenticate","x-csrf-token","x-xsrf-token"]),Mt=new Set(["access_token","accesstoken","id_token","token","auth","auth_token","jwt","session","session_token"]),Fo=new Set(["bearer","token","jwt","dpop","oauth","firebase"]);function _t(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 Bo(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 se(e,t,r){let n=be(e,r);return n&&(Lo(n)||n.hint||t)?n:null}function Ft(e,t){let r=[],n=_t(e.requestHeaders),o=n.authorization;if(o){let i=/^(\S+)\s+(\S+)$/.exec(o.trim()),a=i?i[1]:void 0,s=i?i[2]:o.trim();if(!a||Fo.has(a.toLowerCase())){let l=se(s,true,t);l&&r.push({location:"authorization",name:"Authorization",scheme:a,fp:H(s),info:l})}}for(let[i,a]of Object.entries(n)){if(_o.has(i)||!qe.test(i))continue;let s=a.replace(/^bearer\s+/i,""),l=se(s,true,t);l&&r.push({location:"header",name:i,fp:H(s),info:l})}if(n.cookie)for(let[i,a]of Bo(n.cookie)){let s=se(a,qe.test(i)||/^(sid|sess)/i.test(i),t);s&&r.push({location:"cookie",name:i,fp:H(a),info:s})}for(let[i,a]of Mo(e.url)){let s=se(a,Mt.has(i.toLowerCase()),t);s&&Mt.has(i.toLowerCase())&&r.push({location:"query",name:i,fp:H(a),info:s})}return r}var Uo=/^(access_?token|accesstoken|token|jwt|auth_?token|session_?token|sessiontoken)$/i,Bt=/^(id_?token|idtoken)$/i,ke=/^(refresh_?token|refreshtoken)$/i,Ho=["expires_in","expiresIn","ExpiresIn","expires","ttl"],Vo=["expires_at","expiresAt","ExpiresAt","expiration","Expiration","expiry","expirationTime","expiration_time","access_token_expires_at","accessTokenExpiresAt","accessTokenExpiry"],Wo=["refresh_expires_in","refresh_token_expires_in","refreshTokenExpiresIn","refreshExpiresIn"],Jo=["refresh_expires_at","refreshTokenExpiresAt","refresh_token_expires_at"];function qo(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 Ke(e,t,r){if(t>4||!e||typeof e!="object")return;if(Array.isArray(e)){for(let o of e.slice(0,5))Ke(o,t+1,r);return}let n=e;for(let[o,i]of Object.entries(n))typeof i=="string"&&(Uo.test(o)||Bt.test(o)||ke.test(o))?r.push({key:o,value:i,holder:n}):i&&typeof i=="object"&&Ke(i,t+1,r)}function Ko(e){return ke.test(e)?"refresh":Bt.test(e)?"id":/session/i.test(e)?"session":"access"}function Ut(e,t,r,n,o){for(let i of t){let a=So(e[i]);if(a!==void 0)return{expiresAt:n+a*1e3,source:i,lifetimeMs:a*1e3}}for(let i of r){let a=ae(e[i],o);if(a!==void 0)return{expiresAt:a,source:i}}return{}}function Zo(e){let t=e["set-cookie"];return t?t.split(/,(?=\s*[A-Za-z0-9!#$%&'*+.^_`|~-]+=)/).map(r=>r.trim()):[]}function Yo(e,t){if(e.status===void 0||e.status>=400)return[];let r=`${e.method.toUpperCase()} ${Je(e.url)}`,n=e.timestamp+(e.duration??0),o=[],i=qo(e.responseData);if(i){let s=[];Ke(i,0,s);let l=new Map;for(let c of s.filter(f=>ke.test(f.key))){let f=be(c.value,t);if(!f)continue;let v=Ut(c.holder,Wo,Jo,n,t);l.set(c.holder,{fp:H(c.value),expiresAt:f.expiresAt??v.expiresAt,formatLabel:f.formatLabel})}for(let c of s){if(ke.test(c.key))continue;let f=be(c.value,t);if(!f)continue;let v=Ut(c.holder,Ho,Vo,n,t);o.push({fp:H(c.value),info:f,role:Ko(c.key),expiresAt:v.expiresAt,expirySource:v.source,lifetimeMs:v.lifetimeMs,issuedBy:r,refresh:l.get(c.holder)})}}let a=_t(e.responseHeaders);for(let s of Zo(a)){let[l,...c]=s.split(";"),f=l.indexOf("=");if(f<=0)continue;let v=l.slice(0,f).trim(),b=l.slice(f+1).trim(),I=se(b,qe.test(v)||/^(sid|sess)/i.test(v),t);if(!I||b===""||b.toLowerCase()==="deleted")continue;let k,C,L;for(let Mr of c){let[_r,...Fr]=Mr.split("="),pt=_r.trim().toLowerCase(),Re=Fr.join("=").trim();if(pt==="max-age"&&/^-?\d+$/.test(Re))L=Number(Re)*1e3,k=n+L,C="Max-Age";else if(pt==="expires"&&C!=="Max-Age"){let ht=t(Re);Number.isFinite(ht)&&(k=ht,C="Expires")}}o.push({fp:H(b),info:I,role:"cookie",cookie:v,expiresAt:I.expiresAt??k,expirySource:I.expiresAt?I.expirySource:C,lifetimeMs:I.expiresAt?void 0:L,issuedBy:r})}return o}var Ze=e=>A.parse(e),Ht=4,Vt=2e4,Go=8,Xo=8,Qo=200,ei=1e3,O=new Map,X=new Map,ti=new Set,ri=new Set,Wt=new Set,ni=/(token|refresh|oauth|session|auth\/)/i,p=null,xe=true,Ye=null,Ge=new Set,Xe=false;function le(){Xe||(Xe=true,Promise.resolve().then(()=>{Xe=false,Ge.forEach(e=>e())}))}function oi(e){return Ge.add(e),()=>{Ge.delete(e)}}function Jt(e,t){if(e.has(t))return false;if(e.size>=ei){let r=e.values().next().value;r!==void 0&&e.delete(r)}return e.add(t),true}function Qe(e,t){return`${e}|${t.location}:${t.name.toLowerCase()}`}function qt(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,a=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:a}}function et(e,t,r,n,o){let i=X.get(t),a=qt(r,i),s=e.fp!==t;s&&(e.history.unshift({fp:e.fp,firstSeenReal:e.firstSeenReal,expiresAt:e.expiresAt}),e.history.length=Math.min(e.history.length,Xo),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??(s?void 0:e.role),e.issuedBy=i?.issuedBy??(s?void 0:e.issuedBy),e.refresh=i?.refresh??(s?void 0:e.refresh),e.expiresAt=a.expiresAt,e.serverExpiresAt=a.serverExpiresAt,e.expirySource=a.source,e.lifetimeMs=a.lifetimeMs,s&&ii(e,n)}function Kt(e,t,r,n,o){let i=X.get(r.fp),a=qt(r.info,i);return{key:e,origin:t,host:jo(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:a.expiresAt,serverExpiresAt:a.serverExpiresAt,expirySource:a.source,lifetimeMs:a.lifetimeMs,firstSeenReal:n,firstSeenApp:o,lastUsedReal:n,lastUsedApp:o,uses:0,expiredSends:0,rejected:0,history:[]}}function Zt(){if(O.size<=Go)return;let e=null;for(let t of O.values())(!e||t.lastUsedReal<e.lastUsedReal)&&(e=t);e&&e.key!==p?.tokenId&&O.delete(e.key)}function ii(e,t){!p||p.tokenId!==e.key||(p.newTokens+=1,p.status==="waiting"&&(p.status="refreshed",p.refreshedAt=t,p.ruleId&&p.forcedAt===void 0&&wo("network","deleteOverrideRule",{id:p.ruleId}).catch(()=>{})),p.newTokens>=Ht&&t-(p.refreshedAt??t)<=Vt&&(p.status="loop"))}function ai(e){let t=We(e.url);if(!t)return;let r=Ft(e,Ze);if(r.length===0)return;let n=S(),o=e.timestamp;for(let i of r){let a=Qe(t,i),s=O.get(a);s?et(s,i.fp,i.info,n,o):(s=Kt(a,t,i,n,o),O.set(a,s),Zt()),s.uses+=1,s.lastUsedReal=n,s.lastUsedApp=o,s.expiresAt!==void 0&&o>=s.expiresAt&&(s.expiredSends+=1),p&&p.tokenId===a&&p.forcedAt!==void 0&&i.fp===p.startFp&&(p.staleAfterFailure+=1)}le()}function si(e){let t=We(e.url);if(!t)return;let r=S(),n=false;if(e.status===401||e.status===403)for(let i of Ft(e,Ze)){let a=O.get(Qe(t,i));a&&a.fp===i.fp&&(a.rejected+=1,n=true)}let o=!!p?.ruleId&&e.override?.ruleId===p.ruleId;if(p&&(e.status??0)>=400&&!o){let i=`${e.method.toUpperCase()} ${Je(e.url)}`;(Wt.has(i)||e.method.toUpperCase()==="POST"&&ni.test(Je(e.url)))&&(p.failedRefreshes+=1,p.lastRefreshError=`${e.status} ${i}`,n=true)}p?.ruleId&&e.override?.ruleId===p.ruleId&&p.forcedAt===void 0&&(p.forcedAt=r,n=true);for(let i of Yo(e,Ze)){if(Wt.add(i.issuedBy),X.set(i.fp,{...i,observedReal:r}),X.size>Qo){let a=X.keys().next().value;a!==void 0&&X.delete(a)}if(n=true,i.cookie){let a={location:"cookie",name:i.cookie,fp:i.fp,info:i.info},s=Qe(t,a),l=O.get(s);l?et(l,i.fp,i.info,r,e.timestamp):(O.set(s,Kt(s,t,a,r,e.timestamp)),Zt());continue}for(let a of O.values())a.fp===i.fp&&et(a,i.fp,a.info,r,a.lastUsedApp)}n&&le()}function li(e){let t=e;!t||typeof t.id!="string"||typeof t.url!="string"||(Jt(ti,t.id)&&ai(t),t.status!==void 0&&Jt(ri,t.id)&&si(t))}function ve(){if(Ye)return true;try{let{networkEventStore:e}=To("@buoy-gg/network");if(!e?.onEvent)throw new Error("no event store");Ye=e.onEvent(li,true),xe=true}catch{xe=false}return le(),xe}function Yt(e,t,r){let n=O.get(t);if(!n)throw new Error(`No token row "${t}".`);return p={kind:e,tokenId:t,startedAt:S(),startFp:n.fp,ruleId:r,status:"waiting",newTokens:0,staleAfterFailure:0,failedRefreshes:0},le(),p}function ci(){p=null,le()}function ui(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 fi(e,t){let r=[e.firstSeenReal,...e.history.map(o=>o.firstSeenReal)].slice(0,-1).filter(o=>t-o<=Vt).length,n=e.info.issuedAt;return{id:e.key,label:ui(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>=Ht,expiredSends:e.expiredSends,rejected:e.rejected}}function we(){let e=S(),t=[...O.values()].sort((r,n)=>n.lastUsedReal-r.lastUsedReal).map(r=>fi(r,e));if(p?.status==="refreshed"){let r=O.get(p.tokenId);r&&(p.newLifetimeMs=r.lifetimeMs,p.newIssuedBy=r.issuedBy)}return{available:xe,watching:Ye!==null,tokens:t,check:p?{...p}:null}}function di(e){let t=we();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 pi(e){return O.get(e)?.origin??null}import{isProNow as Gt}from"@buoy-gg/shared-ui/web";var d={anchor:Ce,settings:ie,lastJump:null,changedAt:null,hydrated:false},tt=new Set,Te=null;function Xt(){Te=null,tt.forEach(e=>e())}oi(Xt);function ce(e){return tt.add(e),()=>{tt.delete(e)}}function hi(){return d.settings}function Qt(){return M(d.anchor,S())}function er(){return d.anchor.mode!=="real"}function mi(e){if(e.mode==="real"){It(null),so();return}Pt(),It(t=>M(d.anchor,t)),ao()}function gi(){let e={v:1,anchor:d.settings.persist&&Gt()?d.anchor:null,settings:d.settings};Be(e)}function tr(){let e={v:1,anchor:d.settings.persist&&Gt()?d.anchor:null,settings:d.settings};return d.settings.persist&&d.anchor.mode!=="real"&&(e.reload={anchor:d.anchor,at:S()}),Be(e)}function Q(e,{save:t=true}={}){d={...d,...e},e.anchor&&mi(d.anchor),t&&gi(),Xt()}function ee(e,t=d.lastJump){Q({anchor:e,lastJump:t,changedAt:S(),hydrated:true})}var rr=e=>A.parse(e);function nr(e,t=false){let r=S(),n=M(d.anchor,r),o=Tt(e,n,rr),i=o-n;return ee(Pe(d.anchor,r,o,t),{byMs:i,firedTimers:0,at:r}),R()}function rt(e,t){let r=Ne(e),n=S(),o=Zn(d.anchor,n,r),i=(t??d.settings.fireTimersOnJump)&&r>0;if(ee(o,{byMs:r,firedTimers:0,at:n}),i){let a=yo(r);a>0&&Q({lastJump:{byMs:r,firedTimers:a,at:n}},{save:false})}return R()}function nt(e){let t=S(),r=M(d.anchor,t),n=e===void 0||e===""?r:Tt(e,r,rr);return ee(Yn(d.anchor,t,n)),R()}function ot(){return d.anchor.mode==="frozen"&&ee(Gn(d.anchor,S())),R()}function or(e){return ee(Xn(d.anchor,S(),Number(e))),R()}function it(){return ee(Ce,null),R()}function ir(e){let t={...d.settings};for(let r of Object.keys(ie))typeof e[r]=="boolean"&&(t[r]=e[r]);return Q({settings:t}),R()}function yi(e){return e>0?go(e):0}var ar=false;function sr(e){if(!e){Q({hydrated:true},{save:false});return}let t=e.reload?S()-e.reload.at:1/0,r=t>=0&&t<xo?e.reload?.anchor:void 0;e.reload&&Be({v:1,anchor:e.anchor,settings:e.settings});let n=e.anchor??r??null;Q({settings:e.settings,anchor:n??Ce,changedAt:n?S():null,hydrated:true},{save:false})}function at(){if(ar)return;ar=true,Pt();let e=ko();if(e!==void 0){sr(e);return}vo().then(t=>{d.changedAt===null?sr(t):Q({hydrated:true},{save:false})})}function bi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone??"unknown"}catch{return"unknown"}}function R(){let e=S(),t=M(d.anchor,e);return{mode:d.anchor.mode,active:d.anchor.mode!=="real",rate:d.anchor.rate,virtualNow:t,virtualIso:new A(t).toISOString(),realNow:e,offsetMs:Kn(d.anchor,e),timeZone:bi(),timers:mo(),lastJump:d.lastJump,changedAt:d.changedAt,settings:d.settings,hydrated:d.hydrated,tokens:we(),patched:{date:eo(),intl:io(),timers:ho(),animatedOnRealClock:uo()}}}function lr(){return Te||(Te=R()),Te}import{useSyncExternalStore as ki}from"react";import{ClockToolIcon as cr,FloatingTool as xi,Pause as vi,Play as wi,X as Ti,dismissFloatingTool as Ai,getFloatingTools as Si,getUseIsPro as $i,night as ue,openFloatingTool as ur}from"@buoy-gg/shared-ui/web";import{useEffect as Ii,useState as Ri}from"react";function V(e,t=250){let[,r]=Ri(0);Ii(()=>{let a=setInterval(()=>r(s=>s+1),t);return()=>clearInterval(a)},[t]);let n=S();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 F=e=>String(e).padStart(2,"0");function fe(e){let t=new A(e);return`${F(t.getHours())}:${F(t.getMinutes())}:${F(t.getSeconds())}`}var Ci=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],fr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Di(e){let t=new A(e);return`${Ci[t.getDay()]}, ${fr[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`}function Ae(e,t=true){let r=new A(e),n=t?fe(e):`${F(r.getHours())}:${F(r.getMinutes())}`;return`${fr[r.getMonth()]} ${r.getDate()} \xB7 ${n}`}function dr(e){let t=new A(e);return`${t.getFullYear()}-${F(t.getMonth()+1)}-${F(t.getDate())} ${F(t.getHours())}:${F(t.getMinutes())}`}function Oi(e){if(Math.abs(e)<1e3)return"matches real time";let t=te(Math.abs(e),{signed:false});return e>0?`${t} ahead of real time`:`${t} behind real time`}function pr(e){return e.mode==="real"?{label:"Real time",tone:"neutral"}:e.mode==="frozen"?{label:"Frozen",tone:"info"}:e.rate!==1?{label:`${St(e.rate)} speed`,tone:"warning"}:{label:"Overridden",tone:"accent"}}function Pi(e){return`clock-jump-${e<0?"minus":"plus"}-${te(Math.abs(e),{signed:false}).replace(/\s/g,"")}`}import{jsx as z,jsxs as st}from"react/jsx-runtime";var Se="clock-chip",hr={id:Se,render:e=>z(gr,{...e})},Ni=()=>Si().some(e=>e.id===Se);function Ei(){ur(hr)}var mr=false;function zi(){if(mr)return;mr=true;let e=false,t=()=>{let r=er()&&hi().showChip;r&&!e?ur(hr):!r&&Ni()&&Ai(Se),e=r};ce(t),t()}function gr({id:e,revealToken:t}){let r=ki(ce,lr,lr),{virtual:n,real:o}=V(r),i=r.mode==="frozen",a=$i()(),s=i||a,l=pr(r),c=n-o,f=`${Math.abs(c)<1e3?"0s":te(c)} \xB7 ${l.label.toLowerCase()}`;return z(xi,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:`Move or hide the clock chip. App time ${Ae(n)}`,handleAdornment:z(cr,{size:12}),children:st(m,{style:K.row,children:[z(cr,{size:18}),st(m,{style:K.text,children:[z(w,{style:K.time,numberOfLines:1,testID:"clock-chip-time",children:Ae(n)}),z(w,{style:K.detail,numberOfLines:1,testID:"clock-chip-detail",children:f})]}),s?st(B,{testID:i?"clock-chip-resume":"clock-chip-freeze",accessibilityRole:"button",accessibilityLabel:i?"Resume the app clock":"Freeze the app clock",onPress:()=>i?ot():nt(),style:K.button,hitSlop:{top:8,bottom:8,left:4,right:4},children:[i?z(wi,{size:16,color:ue.color.accent}):null,i?null:z(vi,{size:16,color:ue.color.text})]}):null,s?z(m,{style:K.separator}):null,z(B,{testID:"clock-chip-reset",accessibilityRole:"button",accessibilityLabel:"Back to real time",onPress:()=>it(),style:K.button,hitSlop:{top:8,bottom:8,left:4,right:8},children:z(Ti,{size:16,color:ue.color.textSecondary})})]})})}var K=Y.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:ue.color.textSecondary,fontSize:11,fontVariant:["tabular-nums"]},button:{width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:16},separator:{width:Y.hairlineWidth,height:20,backgroundColor:ue.color.separator}});import{ClockToolIcon as Li,CLOCK_TOOL_ICON_COLOR as ji,createToolFactory as Mi,defineToolPreset as _i}from"@buoy-gg/shared-ui/web";import{useEffect as yr,useState as Fi}from"react";import{reloadApp as Bi}from"@buoy-gg/shared-ui/web";import{createSyncAdapter as Ui}from"@buoy-gg/shared-ui/web";import{dispatchToolAction as br}from"@buoy-gg/shared-ui/web";var kr="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 xr(e){ve();let t=di(e);if(!t)throw new Error(e?`No token "${e}". Read getState for the current ids.`:kr);return t}function vr(e,t=1e4){let r=xr(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)-Qt();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 rt(n),Yt("expiry",r.id),R()}async function wr(e,t=401,r=1){let n=xr(e),o=pi(n.id);if(!o)throw new Error(kr);await Tr();let i=t===403?403:401,a=n.location==="authorization"||n.location==="header"?{urlPattern:`${o}/*`,requireHeader:n.name.toLowerCase()}:n.location==="query"?{urlPattern:`${o}/*${n.name}=*`}:{urlPattern:`${o}/*`},s=await br("network","upsertOverrideRule",{name:"Clock: force a token refresh",...a,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(!s?.ok||!s.rule)throw new Error(s?.error??"Network did not add the override.");return Yt("401",n.id,s.rule.id),R()}async function Tr(){let e=we().check;e?.ruleId&&e.forcedAt===void 0&&await br("network","deleteOverrideRule",{id:e.ruleId}).catch(()=>{})}async function Ar(){return await Tr(),ci(),R()}function Z(e){return e&&typeof e=="object"?e:{}}function lt(e,...t){for(let r of t){let n=e[r];if(typeof n=="string"||typeof n=="number")return n}}function de(e,t){let r=e[t];if(typeof r=="boolean")return r;if(r==="true")return true;if(r==="false")return false}var Sr=Ui({version:1,getSnapshot(){return R()},subscribe(e){return ce(e)},actions:{getState(){return ve(),R()},setTime(e){let t=Z(e),r=lt(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 nr(r,de(t,"freeze")??false)},shift(e){let t=Z(e),r=lt(t,"by","ms","duration","delta");if(r===void 0)throw new Error('shift needs `by`: a duration like "+1d", "-2h30m", "90s", or ms.');return rt(r,de(t,"fireTimers"))},freeze(e){return nt(lt(Z(e),"time","at"))},resume(){return ot()},setRate(e){let t=Z(e),r=Number(t.rate??t.speed);if(!Number.isFinite(r))throw new Error("setRate needs a numeric `rate` (1 = normal speed).");return or(r)},reset(){return it()},updateSettings(e){let t=Z(e);return ir({persist:de(t,"persist"),showChip:de(t,"showChip"),fireTimersOnJump:de(t,"fireTimersOnJump")})},jumpToTokenExpiry(e){let t=Z(e),r=typeof t.token=="string"?t.token:typeof t.id=="string"?t.id:void 0,n=Number(t.leadMs??t.lead??1e4);return vr(r,Number.isFinite(n)?n:1e4)},failNextRequest(e){let t=Z(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 wr(r,n,Number.isFinite(o)?o:1)},stopTokenCheck(){return Ar()},async holdForReload(){return await tr(),R()}}});import{useState as $e}from"react";import{ChevronRight as Hi,NightButton as Vi,NightCard as Ie,NightChip as Wi,NightFootnote as ct,NightRows as ut,NightSectionLabel as $r,NightSegmented as Ji,NightSwitch as Ir,ProBadge as qi,ProUpgradeModal as Ki,getUseIsPro as Zi,monoFont as Yi,night as y,useSafeAreaInsets as Gi}from"@buoy-gg/shared-ui/web";import{ChevronRight as Xi,NightButton as Rr,NightCard as Qi,NightFootnote as ea,NightRows as ta,NightSectionLabel as ra,ProBadge as na,night as x}from"@buoy-gg/shared-ui/web";import{jsx as T,jsxs as j}from"react/jsx-runtime";var W=e=>te(Math.abs(e),{signed:false});function oa({snapshot:e,run:t,openId:r,onToggle:n,isPro:o,onUpgrade:i}){let a=e.tokens;return j(m,{children:[T(ra,{children:a.tokens.length>1?"Sign-in tokens":"Sign-in token"}),T(Qi,{children:j(ta,{children:[a.tokens.map((s,l)=>j(m,{children:[T(ia,{token:s,snapshot:e,index:l,open:r===s.id,onPress:()=>n(s.id)}),r===s.id?T(aa,{token:s,snapshot:e,run:o?t:()=>i("Sign-in token tests"),isPro:o}):null]},s.id)),a.tokens.length===0?T(m,{style:g.row,testID:"clock-token-empty",children:T(w,{style:g.emptyText,children:a.available?"No token seen yet":"Needs the Network tool"})},"empty"):null]})}),T(la,{check:a.check,tokens:a.tokens,snapshot:e,run:t}),a.tokens.length===0?T(ea,{children:a.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 ia({token:e,snapshot:t,index:r,open:n,onPress:o}){let{virtual:i}=V(t,1e3),a=e.expiresAt!==void 0?e.expiresAt-i:void 0,s=e.neverExpires?"No expiry":a===void 0?"Unknown":a<=0?"Expired":W(a),l=a!==void 0&&a<=0?g.valueDanger:a!==void 0&&a<6e4?g.valueWarning:null;return j(B,{testID:`clock-token-${r}`,accessibilityRole:"button",accessibilityLabel:`${e.label} for ${e.host}: ${a!==void 0&&a>0?`expires in ${s}`:s}`,accessibilityState:{expanded:n},activeOpacity:.6,onPress:o,style:g.row,children:[j(m,{style:g.rowText,children:[T(w,{style:g.rowTitle,numberOfLines:1,children:e.label}),T(w,{style:g.rowSubtitle,numberOfLines:1,children:`${e.host} \xB7 ${e.hint??e.formatLabel}`})]}),j(m,{style:g.rowRight,children:[T(w,{style:[g.value,l],testID:`clock-token-${r}-left`,children:s}),T(m,{style:n?g.chevronOpen:null,children:T(Xi,{size:16,color:x.color.textTertiary})})]})]})}function aa({token:e,snapshot:t,run:r,isPro:n}){let{virtual:o,real:i}=V(t,1e3),a=sa(e,o,i),s=e.expiresAt!==void 0&&e.expiresAt-o>1e4;return j(m,{style:g.detail,testID:"clock-token-detail",children:[a.map(l=>T(w,{style:[g.detailLine,l.tone==="warn"?g.warn:null,l.tone==="bad"?g.bad:null],children:l.text},l.text)),j(m,{style:g.buttons,children:[T(m,{style:g.button,children:T(Rr,{label:"Jump to Expiry",testID:"clock-token-jump",accessibilityLabel:"Jump the app's clock to ten seconds before this token expires",size:"md",disabled:!s,onPress:()=>r("jumpToTokenExpiry",{token:e.id})})}),T(m,{style:g.button,children:T(Rr,{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:j(m,{style:g.proLine,children:[T(na,{}),T(w,{style:[g.hint,g.proHint],children:"Jump to Expiry and Fail Next Request are part of Buoy Pro."})]}),T(w,{style:g.hint,children:s||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 sa(e,t,r){let n=[];if(e.expiresAt!==void 0){if(n.push({text:`Expires ${Ae(e.expiresAt)}`}),e.lifetimeMs!==void 0&&e.lifetimeMs>0&&n.push({text:`Lasts ${W(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 ${W(i)}`:`The server stopped accepting it ${W(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 ${W(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 ${fe(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 la({check:e,tokens:t,snapshot:r,run:n}){let{virtual:o,real:i}=V(r,1e3);if(!e)return null;let a=t.find(c=>c.id===e.tokenId),{text:s,tone:l}=ca(e,a,o,i);return j(m,{style:g.check,children:[T(w,{style:[g.checkText,l==="good"?g.good:null,l==="bad"?g.bad:null,l==="warn"?g.warn:null],testID:"clock-token-check",children:s}),T(B,{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:T(w,{style:g.checkDone,children:e.status==="waiting"?"Stop":"Done"})})]})}function ca(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"){let s=e.newIssuedBy?` by ${e.newIssuedBy}`:"",l=e.newLifetimeMs&&e.newLifetimeMs>0?`. The new token lasts ${W(e.newLifetimeMs)}`:"",c=e.kind==="401"&&e.forcedAt!==void 0?"The app got the 401 and refreshed":"Refreshed",f=e.failedRefreshes>0?` ${e.failedRefreshes===1?"One token request":`${e.failedRefreshes} token requests`} failed first (${e.lastRefreshError}).`:"";return{text:`${c} at ${fe(e.refreshedAt??n)}${s}${l}.${f}`,tone:f?"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 ${W(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 a=t?.expiresAt!==void 0?t.expiresAt-r:void 0;return a!==void 0&&a>0?{text:`Expires in ${W(a)} 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 g=Y.create({row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:56,paddingHorizontal:x.rowPadH,paddingVertical:10},rowText:{flex:1,minWidth:0},rowTitle:{color:x.color.text,fontSize:x.font.row},rowSubtitle:{color:x.color.textTertiary,fontSize:x.font.caption,marginTop:2},rowRight:{flexDirection:"row",alignItems:"center",gap:6},value:{color:x.color.textSecondary,fontSize:x.font.row,fontVariant:["tabular-nums"]},valueWarning:{color:x.color.warning},valueDanger:{color:x.color.danger},chevronOpen:{transform:[{rotate:"90deg"}]},emptyText:{color:x.color.textSecondary,fontSize:x.font.row},detail:{paddingHorizontal:x.rowPadH,paddingBottom:14,gap:4},detailLine:{color:x.color.textSecondary,fontSize:x.font.caption},buttons:{flexDirection:"row",gap:8,marginTop:8},button:{flex:1},hint:{color:x.color.textTertiary,fontSize:x.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:x.labelInset},checkText:{flex:1,color:x.color.textSecondary,fontSize:x.font.caption,lineHeight:18},checkDone:{color:x.color.accent,fontSize:x.font.caption,fontWeight:"600"},good:{color:x.color.accent},warn:{color:x.color.warning},bad:{color:x.color.danger}});import{jsx as u,jsxs as $}from"react/jsx-runtime";var Cr="#F59E0B";function Dr({snapshot:e,onAction:t,onReload:r}){let n=Gi({minBottom:16}),[o,i]=$e(null),[a,s]=$e(null),l=Zi()(),[c,f]=$e(null),v=k=>f(k),b=(k,C)=>{i(null),t(k,C).catch(L=>{i(L instanceof Error?L.message:String(L))})},I=k=>s(C=>C===k?null:k);return e?$(vt,{style:h.fill,contentContainerStyle:[h.content,{paddingBottom:n.bottom}],testID:"clock-scroll",keyboardShouldPersistTaps:"handled",children:[u(ua,{snapshot:e}),o?u(ct,{tone:"danger",centered:true,children:u(w,{testID:"clock-error",children:o})}):null,$(m,{children:[u($r,{children:"Jump ahead"}),u(da,{run:b})]}),$(m,{children:[u(Ie,{children:$(ut,{children:[$(m,{children:[u(Pr,{title:"Date & Time",testID:"clock-date-row",open:a==="date",onPress:()=>I("date"),value:u(pa,{snapshot:e})}),a==="date"?u(ma,{snapshot:e,run:b,onDone:()=>s(null)}):null]},"date"),$(m,{style:h.row,children:[u(ft,{title:"Freeze",isPro:l}),u(Ir,{value:e.mode==="frozen",testID:"clock-freeze",accessibilityLabel:"Freeze the clock",onValueChange:k=>k&&!l?v("Freeze"):b(k?"freeze":"resume")})]},"freeze"),$(m,{children:[u(Pr,{title:"Speed",pro:!l,testID:"clock-speed-row",open:a==="speed",onPress:()=>l?I("speed"):v("Speed"),value:u(w,{style:h.rowValue,children:zr(e)})}),a==="speed"?u(ga,{snapshot:e,run:b}):null]},"speed")]})}),u(ct,{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?u(oa,{snapshot:e,run:b,openId:a,onToggle:I,isPro:l,onUpgrade:v}):null,u(Ie,{children:$(ut,{children:[r?u(Nr,{label:"Reload App",testID:"clock-reload",onPress:r},"reload"):null,u(Nr,{label:"Use Real Time",accessibilityLabel:"Reset to real time",testID:"clock-reset",destructive:true,disabled:e.mode==="real",onPress:()=>b("reset")},"reset")]})}),$(m,{children:[u($r,{children:"Options"}),u(ba,{settings:e.settings,run:b,isPro:l,onUpgrade:v})]}),u(Ki,{visible:c!==null&&!l,onClose:()=>f(null),featureName:c??void 0})]}):u(m,{style:h.waiting,testID:"clock-waiting",children:u(ct,{centered:true,children:"Waiting for the app's clock\u2026"})})}function ft({title:e,isPro:t}){return $(m,{style:h.titleRow,children:[u(w,{style:h.rowTitle,children:e}),t?null:u(qi,{})]})}function ua({snapshot:e}){let{virtual:t,real:r}=V(e),n=pr(e),o=e.mode!=="real",i=Oi(t-r),a=e.mode==="frozen"?" \xB7 Frozen":o&&e.rate!==1?` \xB7 ${zr(e)}`:"";return $(m,{style:h.hero,children:[u(w,{style:[h.heroTime,o?h.heroTimeActive:null],testID:"clock-hero-time",accessibilityLabel:`App clock ${fe(t)}`,children:fe(t)}),u(w,{style:h.heroDate,testID:"clock-hero-date",children:Di(t)}),u(m,{testID:"clock-status",accessibilityLabel:`Clock status: ${n.label}${o?`, ${i}`:""}`,children:u(w,{style:[h.heroStatus,o?h.heroStatusActive:null],testID:"clock-offset",children:o?`${i}${a}`:"Real time"})})]})}var Or=36e5,dt=24*Or,fa=[{ms:Or,unit:"hour"},{ms:dt,unit:"day"},{ms:7*dt,unit:"week"},{ms:30*dt,unit:"month"}];function da({run:e}){return u(Ie,{style:h.jumpBar,children:fa.map((t,r)=>$(B,{testID:Pi(t.ms),accessibilityRole:"button",accessibilityLabel:`Jump ahead one ${t.unit}`,activeOpacity:.6,onPress:()=>e("shift",{by:t.ms}),style:[h.jump,r>0?h.jumpDivider:null],children:[u(w,{style:h.jumpAmount,children:"+1"}),u(w,{style:h.jumpUnit,children:t.unit})]},t.unit))})}function Pr({title:e,pro:t,value:r,open:n,onPress:o,testID:i}){return $(B,{testID:i,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{expanded:n},activeOpacity:.6,onPress:o,style:h.row,children:[u(ft,{title:e,isPro:!t}),$(m,{style:h.rowRight,children:[r,u(m,{style:n?h.chevronOpen:null,children:u(Hi,{size:16,color:y.color.textTertiary})})]})]})}function pa({snapshot:e}){let{virtual:t}=V(e,1e3);return u(w,{style:[h.rowValue,h.tabular],numberOfLines:1,children:Ae(t,false)})}function Nr({label:e,onPress:t,testID:r,destructive:n,disabled:o,accessibilityLabel:i}){return u(B,{testID:r,accessibilityRole:"button",accessibilityLabel:i??e,accessibilityState:{disabled:!!o},activeOpacity:.6,disabled:o,onPress:t,style:[h.row,o?h.rowDisabled:null],children:u(w,{style:[h.actionLabel,n?h.actionDestructive:null],children:e})})}var ha=At.filter(e=>["midnight","month-end","year-end"].includes(e.id));function ma({snapshot:e,run:t,onDone:r}){let[n,o]=$e(""),{virtual:i}=V(e,1e3),a=()=>n.trim()||dr(i),s=e.mode==="frozen",l=c=>{t("setTime",{time:c,freeze:s}),r()};return $(m,{style:h.editor,children:[$(m,{style:h.inputRow,children:[u(xt,{testID:"clock-time-input",accessibilityLabel:"Date and time",value:n,onChangeText:o,placeholder:dr(i),placeholderTextColor:y.color.placeholder,autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>l(a()),style:h.input}),u(Vi,{label:"Set",testID:"clock-time-apply",accessibilityLabel:"Set this time",size:"md",variant:"primary",fullWidth:false,onPress:()=>l(a())})]}),u(w,{style:h.hint,children:"Year-month-day and 24-hour time, or +3d, -2h"}),u(m,{style:h.presets,children:ha.map(c=>u(Wi,{label:c.label,testID:`clock-preset-${c.id}`,onPress:()=>l(c.at(i,A))},c.id))})]})}var Er=[{key:"1",label:"Normal"},{key:"10",label:"10\xD7"},{key:"60",label:"1 min/s"},{key:"3600",label:"1 hr/s"}];function zr(e){return e.mode==="real"||e.rate===1?"Normal":Er.find(t=>Number(t.key)===e.rate)?.label??St(e.rate)}function ga({snapshot:e,run:t}){let r=e.mode==="real"?"1":String(e.rate);return $(m,{style:h.editor,children:[u(m,{style:h.segmentRow,children:u(Ji,{tabs:Er,activeKey:r,size:"sm",testIDPrefix:"clock-speed",onChange:n=>t("setRate",{rate:Number(n)})})}),u(w,{style:h.hint,children:"Taps, animations and timers keep real speed."})]})}var ya=[{key:"showChip",title:"Show Floating Clock"},{key:"persist",title:"Keep After Reload",pro:true}];function ba({settings:e,run:t,isPro:r,onUpgrade:n}){return u(Ie,{children:u(ut,{children:ya.map(o=>{let i=!!o.pro&&!r;return $(m,{style:h.row,children:[u(ft,{title:o.title,isPro:!i}),u(Ir,{value:i?false:e[o.key],testID:`clock-setting-${o.key}`,accessibilityLabel:o.title,onValueChange:a=>i?n(o.title):t("updateSettings",{[o.key]:a})})]},o.key)})})})}var h=Y.create({fill:{flex:1},content:{paddingHorizontal:y.gutter,paddingTop:8,gap:y.groupGap},waiting:{flex:1,alignItems:"center",justifyContent:"center",padding:24},hero:{alignItems:"center",paddingTop:12},heroTime:{color:y.color.text,fontSize:56,fontWeight:"200",fontVariant:["tabular-nums"],letterSpacing:1},heroTimeActive:{color:Cr},heroDate:{color:y.color.text,fontSize:17,fontWeight:"500",marginTop:2},heroStatus:{color:y.color.textTertiary,fontSize:y.font.caption,fontWeight:"500",marginTop:6},heroStatusActive:{color:y.color.textSecondary},jumpBar:{flexDirection:"row"},jump:{flex:1,alignItems:"center",paddingVertical:12},jumpDivider:{borderLeftWidth:Y.hairlineWidth,borderLeftColor:y.color.separator},jumpAmount:{color:Cr,fontSize:17,fontWeight:"600",fontVariant:["tabular-nums"]},jumpUnit:{color:y.color.textSecondary,fontSize:y.font.caption,marginTop:1},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:50,paddingHorizontal:y.rowPadH,paddingVertical:10},rowDisabled:{opacity:.4},rowTitle:{color:y.color.text,fontSize:y.font.row},titleRow:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:1},rowRight:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},rowValue:{color:y.color.textSecondary,fontSize:y.font.row},tabular:{fontVariant:["tabular-nums"]},chevronOpen:{transform:[{rotate:"90deg"}]},actionLabel:{color:y.color.accent,fontSize:y.font.row},actionDestructive:{color:y.color.danger},editor:{paddingHorizontal:y.rowPadH,paddingBottom:14,gap:10},inputRow:{flexDirection:"row",alignItems:"center",gap:8},input:{flex:1,color:y.color.text,fontFamily:Yi,fontSize:15,backgroundColor:y.color.bg,borderRadius:y.radius.input,borderWidth:1,borderColor:y.color.border,paddingHorizontal:12,paddingVertical:8},hint:{color:y.color.textTertiary,fontSize:y.font.caption},presets:{flexDirection:"row",flexWrap:"wrap",gap:6},segmentRow:{flexDirection:"row"}});import{jsx as ka}from"react/jsx-runtime";var xa=Sr.actions;async function va(e,t){let r=xa[e];if(!r)throw new Error(`Unknown clock action: ${e}`);return r(t)}function wa(){tr().then(()=>Bi("auto","buoy clock")).catch(()=>{})}function Lr(){yr(()=>{at(),ve()},[]);let[e,t]=Fi(R);return yr(()=>ce(()=>t(R())),[]),ka(Dr,{snapshot:e,onAction:va,onReload:wa})}import{jsx as Ta}from"react/jsx-runtime";var jr=_i({id:"clock",name:"CLOCK",description:"Travel to any date, freeze or speed up the app's clock",slot:"both",color:ji,icon:({size:e,color:t})=>Ta(Li,{size:e,color:t}),component:Lr,modal:{subtitle:"override the app's date & time"}}),Aa=Mi(jr);import{ClockToolIcon as Sa,CLOCK_TOOL_ICON_COLOR as $a}from"@buoy-gg/shared-ui/web";var Ia=typeof navigator<"u"&&navigator.product==="ReactNative",Ra=(()=>{try{return globalThis.Capacitor?.isNativePlatform?.()===true}catch{return false}})();(Ia||Ra)&&(co(kt),zi(),typeof yt<"u"&&yt&&at());export{Se as CLOCK_CHIP_ID,$a as CLOCK_TOOL_ICON_COLOR,Lr as ClockBody,gr as ClockChip,Sa as ClockToolIcon,Dr as ClockToolView,At as TIME_PRESETS,at as bootClock,Sr as clockSyncAdapter,jr as clockToolPreset,Aa as createClockTool,wr as failNextRequest,te as formatDuration,nt as freeze,R as getClockSnapshot,we as getTokenReport,be as inspectToken,er as isClockOverridden,vr as jumpToTokenExpiry,Ei as openClockChip,Ne as parseDuration,yi as previewJump,S as realNow,it as reset,ot as resume,or as setRate,nr as setTime,rt as shift,ve as startTokenWatch,Ar as stopTokenCheck,ce as subscribeClock,H as tokenFingerprint,ir as updateSettings,V as useLiveClock,Qt as virtualNow,je as withRealClock};
|
|
1
|
+
"use client";var gt=Object.defineProperty;var qr=Object.getOwnPropertyDescriptor;var Kr=Object.getOwnPropertyNames;var Zr=Object.prototype.hasOwnProperty;var Gr=(e,t)=>{for(var r in t)gt(e,r,{get:t[r],enumerable:true})},bt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Kr(t))!Zr.call(e,o)&&o!==r&>(e,o,{get:()=>t[o],enumerable:!(n=qr(t,o))||n.enumerable});return e},Yr=(e,t,r)=>(bt(e,t,"default"),r&&bt(r,t,"default"));var kt=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);var vt={};Gr(vt,{AccessibilityInfo:()=>tn,ActivityIndicator:()=>to,Alert:()=>oo,Animated:()=>xt,AppRegistry:()=>nn,AppState:()=>on,Appearance:()=>rn,BackHandler:()=>sn,Button:()=>ro,CheckBox:()=>wn,Clipboard:()=>an,DeviceEventEmitter:()=>Mn,Dimensions:()=>ln,Easing:()=>un,FlatList:()=>An,I18nManager:()=>cn,Image:()=>Tn,ImageBackground:()=>Sn,InteractionManager:()=>fn,Keyboard:()=>dn,KeyboardAvoidingView:()=>$n,LayoutAnimation:()=>pn,Linking:()=>hn,LogBox:()=>jn,Modal:()=>Xn,NativeEventEmitter:()=>mn,NativeModules:()=>en,PanResponder:()=>yn,Picker:()=>In,PixelRatio:()=>gn,Platform:()=>bn,Pressable:()=>Qn,ProgressBar:()=>Cn,RefreshControl:()=>Rn,SafeAreaView:()=>En,ScrollView:()=>$t,SectionList:()=>On,Share:()=>kn,StatusBar:()=>Dn,StyleSheet:()=>G,Switch:()=>eo,Text:()=>A,TextInput:()=>St,Touchable:()=>Pn,TouchableHighlight:()=>Gn,TouchableNativeFeedback:()=>Ln,TouchableOpacity:()=>B,TouchableWithoutFeedback:()=>Yn,UIManager:()=>vn,Vibration:()=>xn,View:()=>m,VirtualizedList:()=>Nn,YellowBox:()=>zn,findNodeHandle:()=>no,unstable_createElement:()=>Xr,useColorScheme:()=>_n,useLocaleContext:()=>Fn,useWindowDimensions:()=>Bn});Yr(vt,Qr);import*as Qr from"react-native-web";import{unstable_createElement as Xr,NativeModules as en,AccessibilityInfo as tn,Animated as xt,Appearance as rn,AppRegistry as nn,AppState as on,BackHandler as sn,Clipboard as an,Dimensions as ln,Easing as un,I18nManager as cn,Keyboard as dn,InteractionManager as fn,LayoutAnimation as pn,Linking as hn,NativeEventEmitter as mn,PanResponder as yn,PixelRatio as gn,Platform as bn,Share as kn,StyleSheet as G,UIManager as vn,Vibration as xn,CheckBox as wn,FlatList as An,Image as Tn,ImageBackground as Sn,KeyboardAvoidingView as $n,Picker as In,ProgressBar as Cn,RefreshControl as Rn,SafeAreaView as En,SectionList as On,StatusBar as Dn,Touchable as Pn,TouchableNativeFeedback as Ln,VirtualizedList as Nn,YellowBox as zn,LogBox as jn,DeviceEventEmitter as Mn,useColorScheme as _n,useLocaleContext as Fn,useWindowDimensions as Bn}from"react-native-web";import*as E from"react-native-web";import{createElement as Ee,forwardRef as wt,useCallback as Un,useRef as Hn}from"react";import{useEffect as Vn,useState as Wn}from"react";import{createPortal as Jn}from"react-dom";var qn='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as Kn}from"react/jsx-runtime";var te=Symbol.for("@buoy-gg/portal-host"),At=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 Tt(){let e=document;if(e[te])return e[te].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:qn});let r=()=>{let u=document.fullscreenElement,y=u&&u.tagName!=="CANVAS"?u:document.body;t.parentElement!==y&&y.appendChild(t)},n=new Map,o=u=>{(!t.contains(u.target)||!At(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 y of u)document.dispatchEvent(new KeyboardEvent("keyup",{...y,bubbles:true}))},l=u=>{At(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[te]={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[te]}},t}function Zn({children:e}){let[t,r]=Wn(null);return Vn(()=>{let n=Tt(),o=document[te];return o.users++,r(n),()=>{--o.users===0&&o.dispose()}},[]),t?Jn(Kn("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}function D(e){let t=wt((n,o)=>{let{accessibilityState:i,accessibilityValue:s,...a}=n;for(let l of["busy","checked","disabled","expanded","selected"])i?.[l]!==void 0&&a[`aria-${l}`]===void 0&&(a[`aria-${l}`]=i[l]);for(let[l,c]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))s?.[l]!==void 0&&a[`aria-${c}`]===void 0&&(a[`aria-${c}`]=s[l]);return Ee(e,{...a,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var m=D(E.View),A=D(E.Text),St=D(E.TextInput),B=D(E.TouchableOpacity),Gn=D(E.TouchableHighlight),Yn=D(E.TouchableWithoutFeedback),Qn=D(E.Pressable),$t=D(E.ScrollView),It=wt((e,t)=>{let r=Hn(null),n=Un(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"}),Tt().appendChild(i))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(o):t&&(t.current=o)},[t]);return Ee(Zn,null,Ee(E.Modal,{...e,ref:n}))});It.displayName="Modal";var Xn=D(It),eo=D(E.Switch),to=D(E.ActivityIndicator),ro=D(E.Button),no=E.findNodeHandle,oo={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 Oe=Object.freeze({mode:"real",anchorReal:0,anchorVirtual:0,rate:1}),De=.1,Pe=86400,io=864e13;function M(e,t){return e.mode==="real"?t:e.mode==="frozen"?e.anchorVirtual:e.anchorVirtual+(t-e.anchorReal)*e.rate}function so(e,t){return M(e,t)-t}function Y(e){if(!Number.isFinite(e)||Math.abs(e)>io)throw new RangeError(`Not a valid time: ${e}`);return Math.round(e)}function Le(e,t,r,n=false){return{mode:n?"frozen":"running",anchorReal:t,anchorVirtual:Y(r),rate:e.mode==="real"?1:e.rate}}function ao(e,t,r){if(!Number.isFinite(r))throw new RangeError("Jump must be a number of ms");return Le(e,t,M(e,t)+r,e.mode==="frozen")}function lo(e,t,r){return Le(e,t,r??M(e,t),true)}function uo(e,t){return e.mode!=="frozen"?e:{...e,mode:"running",anchorReal:t}}function co(e,t,r){if(!Number.isFinite(r)||r<De||r>Pe)throw new RangeError(`Speed must be between ${De}\xD7 and ${Pe}\xD7`);return e.mode==="real"&&r===1?e:{mode:"running",anchorReal:t,anchorVirtual:Y(M(e,t)),rate:r}}function Ct(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>=De&&t.rate<=Pe}var fo={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 Ne(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=fo[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 re(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 Rt(e,t,r){if(typeof e=="number")return Y(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 Y(t+Ne(n));if(/^\d{11,}$/.test(n))return Y(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 Y(i)}var ze=1e4,Et=[{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()-ze}},{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()-ze}},{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()-ze}},{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}}}],Js=[{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 Ot(e){return e===3600?"1h/s":e===600?"10m/s":e===60?"1m/s":`${Number.isInteger(e)?e:e.toFixed(1)}\xD7`}var P=globalThis,he="__buoyClock",T=P.__buoyRealDate??(Date[he]?Date.__buoyRealDate:Date);P.__buoyRealDate=T;var Dt=T.now.bind(T);function S(){return Dt()}P.__buoyRealNow=S;var je=null,Me=0;function me(){let e=Dt();return!je||Me>0?e:je(e)}function Pt(e){je=e}function _e(e){Me+=1;try{return e()}finally{Me-=1}}P.__buoyWithRealClock=_e;function _(...e){let t=new.target;return t?Reflect.construct(T,e.length===0?[me()]:e,t):new T(me()).toString()}_.prototype=T.prototype;Object.defineProperty(_,"name",{value:"Date"});Object.defineProperty(_,"length",{value:7});Object.defineProperty(_,"now",{value:function(){return me()},writable:true,configurable:true});Object.defineProperty(_,"parse",{value:T.parse,writable:true,configurable:true});Object.defineProperty(_,"UTC",{value:T.UTC,writable:true,configurable:true});Object.defineProperty(_,he,{value:true});Object.defineProperty(_,"__buoyRealDate",{value:T});var ne=_,ye=false,ge;function po(){return ye&&P.Date===ne}function ho(){if(P.Date===ne){ye=true;return}let e=Object.getOwnPropertyDescriptor(P,"Date");Object.defineProperty(P,"Date",{value:ne,writable:e?.writable??true,enumerable:e?.enumerable??false,configurable:true}),ge=Object.getOwnPropertyDescriptor(T.prototype,"constructor");try{Object.defineProperty(T.prototype,"constructor",{value:ne,writable:true,enumerable:false,configurable:true})}catch{}ye=true}function mo(){if(P.Date===ne){let e=Object.getOwnPropertyDescriptor(P,"Date");Object.defineProperty(P,"Date",{value:T,writable:e?.writable??true,enumerable:e?.enumerable??false,configurable:true})}if(ge){try{Object.defineProperty(T.prototype,"constructor",ge)}catch{}ge=void 0}ye=false}var oe=[];function Lt(e){return function(t,...r){return e.call(this,t===void 0?me():t,...r)}}function yo(){if(oe.length)return;let e=P.Intl?.DateTimeFormat?.prototype;if(e)for(let t of["format","formatToParts"]){let r=Object.getOwnPropertyDescriptor(e,t);if(!(!r||!r.configurable))try{if(typeof r.get=="function"){let n=r.get;Object.defineProperty(e,t,{...r,get(){return Lt(n.call(this))}})}else if(typeof r.value=="function")Object.defineProperty(e,t,{...r,value:Lt(r.value)});else continue;oe.push({proto:e,name:t,original:r})}catch{}}}function go(){for(let{proto:e,name:t,original:r}of oe)try{Object.defineProperty(e,t,r)}catch{}oe=[]}function bo(){return oe.length>0}function ko(){ho(),yo()}function vo(){mo(),go()}var Fe=false;function xo(e){let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(!Object.prototype.hasOwnProperty.call(t,he)){for(let r of["start","onUpdate"]){let n=Object.getOwnPropertyDescriptor(t,r);if(n&&typeof n.value=="function"){let o=n.value;t[r]=function(...i){return _e(()=>o.apply(this,i))}}}try{Object.defineProperty(t,he,{value:true})}catch{return}}t=Object.getPrototypeOf(t)}}function wo(e){if(Fe)return true;try{let t=e;if(typeof t?.Value!="function")return false;let r=Object.getPrototypeOf(new t.Value(0)),n=r?.animate;return typeof n!="function"?false:(r.animate=function(o,...i){return o&&typeof o=="object"&&xo(o),n.call(this,o,...i)},Fe=true,true)}catch{return false}}function Ao(){return Fe}var ie=globalThis,Nt="__buoyClockTimer",L=new Map,J=null,To={},zt=0,q=()=>S()+zt;function So(e){(J?.setTimeout??setTimeout)(()=>{throw e},0)}function jt(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function $o(){return J!==null}function Mt(){if(J)return true;let{setTimeout:e,clearTimeout:t,setInterval:r,clearInterval:n}=ie;if(typeof e!="function"||typeof t!="function")return false;if(e[Nt])return true;To={setTimeout:e,clearTimeout:t,setInterval:r,clearInterval:n},J={setTimeout:e.bind(globalThis),clearTimeout:t.bind(globalThis),setInterval:(typeof r=="function"?r:e).bind(globalThis),clearInterval:(typeof n=="function"?n:t).bind(globalThis)};let o=J,i=function(u,y,...k){if(typeof u!="function")return o.setTimeout(u,y,...k);let I=jt(y),v,R=function(){return L.delete(v),u.apply(this,k)};return v=o.setTimeout(R,y),L.set(v,{kind:"timeout",callback:u,args:k,delay:I,due:q()+I,realHandle:v,run:R}),v},s=function(u,y,...k){if(typeof u!="function")return o.setInterval(u,y,...k);let I=jt(y),v,R=function(){let z=L.get(v);return z&&(z.due=q()+I),u.apply(this,k)};return v=o.setInterval(R,y),L.set(v,{kind:"interval",callback:u,args:k,delay:I,due:q()+I,realHandle:v,run:R}),v},a=(u,y)=>{let k=L.get(u);return k?(L.delete(u),k.kind==="interval"?o.clearInterval(k.realHandle):o.clearTimeout(k.realHandle)):y(u)},l=function(u){return a(u,o.clearTimeout)},c=function(u){return a(u,o.clearInterval)};globalThis.__buoyRealTimers={setTimeout:o.setTimeout,clearTimeout:l,setInterval:o.setInterval,clearInterval:c};for(let u of[i,s,l,c])Object.defineProperty(u,Nt,{value:true});return ie.setTimeout=i,ie.clearTimeout=l,ie.setInterval=s,ie.clearInterval=c,true}function Io(){let e=q(),t=0,r=0,n=null;for(let o of L.values())if(o.kind==="interval")r+=1;else{t+=1;let i=Math.max(0,o.due-e);(n===null||i<n)&&(n=i)}return{total:t+r,timeouts:t,intervals:r,nextTimeoutInMs:n}}function Co(e){let t=q(),r=0;for(let n of L.values())n.due-t<=e&&(r+=1);return r}function Ro(e){if(!J||!(e>0))return 0;let t=J;zt+=e;let r=q(),n=[...L.entries()].filter(([,s])=>s.due<=r).sort((s,a)=>s[1].due-a[1].due),o=0;for(let[s,a]of n)if(L.has(s)){a.kind==="timeout"?(L.delete(s),t.clearTimeout(a.realHandle)):a.due=r+a.delay;try{a.callback(...a.args)}catch(l){So(l)}o+=1}let i=q();for(let s of L.values())s.kind==="timeout"&&(t.clearTimeout(s.realHandle),s.realHandle=t.setTimeout(s.run,Math.max(0,s.due-i)));return o}import{devToolsStorageKeys as Eo,persistentStorage as _t}from"@buoy-gg/shared-ui/web";function Oo(){try{let e=globalThis.localStorage;return e?Ft(e.getItem(Be)):void 0}catch{return}}var se={persist:true,showChip:true,fireTimersOnJump:true},Do=2*6e4,Be=Eo.clock.state();function Ft(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&&Ct(t.reload.anchor)&&typeof t.reload.at=="number"?{anchor:t.reload.anchor,at:t.reload.at}:void 0;return{v:1,anchor:Ct(t.anchor)?t.anchor:null,...n?{reload:n}:{},settings:{persist:typeof r.persist=="boolean"?r.persist:se.persist,showChip:typeof r.showChip=="boolean"?r.showChip:se.showChip,fireTimersOnJump:typeof r.fireTimersOnJump=="boolean"?r.fireTimersOnJump:se.fireTimersOnJump}}}catch{return null}}async function Po(){try{return Ft(await _t.getItem(Be))}catch{return null}}var Ue=Promise.resolve();function He(e){let t=JSON.stringify(e);return Ue=Ue.then(()=>_t.setItem(Be,t)).catch(()=>{}),Ue.then(()=>{})}import{dispatchToolAction as Lo}from"@buoy-gg/shared-ui/web";import{loadToolModule as No}from"@buoy-gg/shared-ui/web/utils";var Bt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",be={};for(let e=0;e<Bt.length;e++)be[Bt[e]]=e;be["-"]=62;be._=63;function Ve(e){let t=e.replace(/=+$/,""),r=[],n=0,o=0;for(let i=0;i<t.length;i++){let s=be[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 zo(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 We(e){let t=Ve(e);return t?Ut(t):null}function Ut(e){let t=zo(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 Je(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 ae(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 ae(Number(r),t);let n=t(r);return Number.isFinite(n)?n:void 0}}function jo(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 Mo=/^[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]*$/,_o=/^[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]*$/,Ht=/^v([1-4])\.(local|public)\.([A-Za-z0-9_-]+)(?:\.([A-Za-z0-9_-]+))?$/,Fo={1:256,2:64,3:96,4:64};function U(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 Bo(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 Uo(e,t){let r={iss:U(e.iss),aud:U(e.aud),sub:U(e.sub),scope:U(e.scope??e.scp),use:U(e.token_use)},n=Je(e.exp);return{claims:r,issuedAt:Je(e.iat),notBefore:Je(e.nbf),expiresAt:n,expirySource:n?t:void 0}}function Ho(e){let[t,r]=e.split("."),n=We(t);if(!n||typeof n.alg!="string"&&typeof n.typ!="string")return null;let o=We(r);if(!o)return null;let i=typeof n.alg=="string"?n.alg:void 0,s=Uo(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:Bo(s.claims,n),...s}}function Vo(e){let t=We(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=Ht.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=Ve(i),a=Fo[n],l=s&&s.length>a?Ut(s.slice(0,s.length-a)):null,c={format:"paseto-public",formatLabel:`PASETO v${n}`,claims:{}};return l&&(c.claims={iss:U(l.iss),aud:U(l.aud),sub:U(l.sub)},c.issuedAt=ae(l.iat,t),c.notBefore=ae(l.nbf,t),c.expiresAt=ae(l.exp,t),c.expiresAt&&(c.expirySource="exp claim")),c}function Jo(e){if(!e.startsWith("gAAAAA")||e.length<76)return null;let t=Ve(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 qo=[{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 ke(e,t=Date.parse){let r=e.trim().replace(/^"(.*)"$/,"$1");if(r.length<16||/\s/.test(r))return null;if(Mo.test(r)){let i=Ho(r);if(i)return i}if(_o.test(r)){let i=Vo(r);if(i)return i}if(r.startsWith("v")&&Ht.test(r)){let i=Wo(r,t);if(i)return i}let n=Jo(r);if(n)return n;let o=qo.find(i=>i.test.test(r));return{format:"opaque",formatLabel:"Opaque",hint:o?.hint,neverExpires:o?.neverExpires,claims:{}}}function Ko(e){return!!e&&e.format!=="opaque"}function H(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 qe(e){let t=/^([a-z][a-z0-9+.-]*:\/\/[^/?#]+)/i.exec(e);return t?t[1].toLowerCase():null}function Zo(e){let t=qe(e);return t?t.replace(/^[a-z][a-z0-9+.-]*:\/\//,""):"unknown"}function Ke(e){return e.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/?#]+/i,"").split(/[?#]/)[0]||"/"}function Go(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 Ze=/(token|jwt|session|auth|appcheck|api[-_]?key|apikey|credential|bearer)/i,Yo=new Set(["authorization","cookie","dpop","idempotency-key","x-request-id","x-correlation-id","www-authenticate","proxy-authenticate","x-csrf-token","x-xsrf-token"]),Vt=new Set(["access_token","accesstoken","id_token","token","auth","auth_token","jwt","session","session_token"]),Qo=new Set(["bearer","token","jwt","dpop","oauth","firebase"]);function Wt(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 Xo(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 le(e,t,r){let n=ke(e,r);return n&&(Ko(n)||n.hint||t)?n:null}function Jt(e,t){let r=[],n=Wt(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||Qo.has(s.toLowerCase())){let l=le(a,true,t);l&&r.push({location:"authorization",name:"Authorization",scheme:s,fp:H(a),info:l})}}for(let[i,s]of Object.entries(n)){if(Yo.has(i)||!Ze.test(i))continue;let a=s.replace(/^bearer\s+/i,""),l=le(a,true,t);l&&r.push({location:"header",name:i,fp:H(a),info:l})}if(n.cookie)for(let[i,s]of Xo(n.cookie)){let a=le(s,Ze.test(i)||/^(sid|sess)/i.test(i),t);a&&r.push({location:"cookie",name:i,fp:H(s),info:a})}for(let[i,s]of Go(e.url)){let a=le(s,Vt.has(i.toLowerCase()),t);a&&Vt.has(i.toLowerCase())&&r.push({location:"query",name:i,fp:H(s),info:a})}return r}var ei=/^(access_?token|accesstoken|token|jwt|auth_?token|session_?token|sessiontoken)$/i,qt=/^(id_?token|idtoken)$/i,ve=/^(refresh_?token|refreshtoken)$/i,ti=["expires_in","expiresIn","ExpiresIn","expires","ttl"],ri=["expires_at","expiresAt","ExpiresAt","expiration","Expiration","expiry","expirationTime","expiration_time","access_token_expires_at","accessTokenExpiresAt","accessTokenExpiry"],ni=["refresh_expires_in","refresh_token_expires_in","refreshTokenExpiresIn","refreshExpiresIn"],oi=["refresh_expires_at","refreshTokenExpiresAt","refresh_token_expires_at"];function ii(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 Ge(e,t,r){if(t>4||!e||typeof e!="object")return;if(Array.isArray(e)){for(let o of e.slice(0,5))Ge(o,t+1,r);return}let n=e;for(let[o,i]of Object.entries(n))typeof i=="string"&&(ei.test(o)||qt.test(o)||ve.test(o))?r.push({key:o,value:i,holder:n}):i&&typeof i=="object"&&Ge(i,t+1,r)}function si(e){return ve.test(e)?"refresh":qt.test(e)?"id":/session/i.test(e)?"session":"access"}function Kt(e,t,r,n,o){for(let i of t){let s=jo(e[i]);if(s!==void 0)return{expiresAt:n+s*1e3,source:i,lifetimeMs:s*1e3}}for(let i of r){let s=ae(e[i],o);if(s!==void 0)return{expiresAt:s,source:i}}return{}}function ai(e){let t=e["set-cookie"];return t?t.split(/,(?=\s*[A-Za-z0-9!#$%&'*+.^_`|~-]+=)/).map(r=>r.trim()):[]}function li(e,t){if(e.status===void 0||e.status>=400)return[];let r=`${e.method.toUpperCase()} ${Ke(e.url)}`,n=e.timestamp+(e.duration??0),o=[],i=ii(e.responseData);if(i){let a=[];Ge(i,0,a);let l=new Map;for(let c of a.filter(u=>ve.test(u.key))){let u=ke(c.value,t);if(!u)continue;let y=Kt(c.holder,ni,oi,n,t);l.set(c.holder,{fp:H(c.value),expiresAt:u.expiresAt??y.expiresAt,formatLabel:u.formatLabel})}for(let c of a){if(ve.test(c.key))continue;let u=ke(c.value,t);if(!u)continue;let y=Kt(c.holder,ti,ri,n,t);o.push({fp:H(c.value),info:u,role:si(c.key),expiresAt:y.expiresAt,expirySource:y.source,lifetimeMs:y.lifetimeMs,issuedBy:r,refresh:l.get(c.holder)})}}let s=Wt(e.responseHeaders);for(let a of ai(s)){let[l,...c]=a.split(";"),u=l.indexOf("=");if(u<=0)continue;let y=l.slice(0,u).trim(),k=l.slice(u+1).trim(),I=le(k,Ze.test(y)||/^(sid|sess)/i.test(y),t);if(!I||k===""||k.toLowerCase()==="deleted")continue;let v,R,z;for(let Vr of c){let[Wr,...Jr]=Vr.split("="),mt=Wr.trim().toLowerCase(),Re=Jr.join("=").trim();if(mt==="max-age"&&/^-?\d+$/.test(Re))z=Number(Re)*1e3,v=n+z,R="Max-Age";else if(mt==="expires"&&R!=="Max-Age"){let yt=t(Re);Number.isFinite(yt)&&(v=yt,R="Expires")}}o.push({fp:H(k),info:I,role:"cookie",cookie:y,expiresAt:I.expiresAt??v,expirySource:I.expiresAt?I.expirySource:R,lifetimeMs:I.expiresAt?void 0:z,issuedBy:r})}return o}var Ye=e=>T.parse(e),Zt=4,Gt=2e4,ui=8,ci=8,di=200,fi=1e3,O=new Map,Q=new Map,pi=new Set,hi=new Set,Yt=new Set,mi=/(token|refresh|oauth|session|auth\/)/i,p=null,xe=true,Qe=null,Xe=new Set,et=false;function ue(){et||(et=true,Promise.resolve().then(()=>{et=false,Xe.forEach(e=>e())}))}function yi(e){return Xe.add(e),()=>{Xe.delete(e)}}function Qt(e,t){if(e.has(t))return false;if(e.size>=fi){let r=e.values().next().value;r!==void 0&&e.delete(r)}return e.add(t),true}function tt(e,t){return`${e}|${t.location}:${t.name.toLowerCase()}`}function Xt(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 rt(e,t,r,n,o){let i=Q.get(t),s=Xt(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,ci),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&&gi(e,n)}function er(e,t,r,n,o){let i=Q.get(r.fp),s=Xt(r.info,i);return{key:e,origin:t,host:Zo(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 tr(){if(O.size<=ui)return;let e=null;for(let t of O.values())(!e||t.lastUsedReal<e.lastUsedReal)&&(e=t);e&&e.key!==p?.tokenId&&O.delete(e.key)}function gi(e,t){!p||p.tokenId!==e.key||(p.newTokens+=1,p.status==="waiting"&&(p.status="refreshed",p.refreshedAt=t,p.ruleId&&p.forcedAt===void 0&&Lo("network","deleteOverrideRule",{id:p.ruleId}).catch(()=>{})),p.newTokens>=Zt&&t-(p.refreshedAt??t)<=Gt&&(p.status="loop"))}function bi(e){let t=qe(e.url);if(!t)return;let r=Jt(e,Ye);if(r.length===0)return;let n=S(),o=e.timestamp;for(let i of r){let s=tt(t,i),a=O.get(s);a?rt(a,i.fp,i.info,n,o):(a=er(s,t,i,n,o),O.set(s,a),tr()),a.uses+=1,a.lastUsedReal=n,a.lastUsedApp=o,a.expiresAt!==void 0&&o>=a.expiresAt&&(a.expiredSends+=1),p&&p.tokenId===s&&p.forcedAt!==void 0&&i.fp===p.startFp&&(p.staleAfterFailure+=1)}ue()}function ki(e){let t=qe(e.url);if(!t)return;let r=S(),n=false;if(e.status===401||e.status===403)for(let i of Jt(e,Ye)){let s=O.get(tt(t,i));s&&s.fp===i.fp&&(s.rejected+=1,n=true)}let o=!!p?.ruleId&&e.override?.ruleId===p.ruleId;if(p&&(e.status??0)>=400&&!o){let i=`${e.method.toUpperCase()} ${Ke(e.url)}`;(Yt.has(i)||e.method.toUpperCase()==="POST"&&mi.test(Ke(e.url)))&&(p.failedRefreshes+=1,p.lastRefreshError=`${e.status} ${i}`,n=true)}p?.ruleId&&e.override?.ruleId===p.ruleId&&p.forcedAt===void 0&&(p.forcedAt=r,n=true);for(let i of li(e,Ye)){if(Yt.add(i.issuedBy),Q.set(i.fp,{...i,observedReal:r}),Q.size>di){let s=Q.keys().next().value;s!==void 0&&Q.delete(s)}if(n=true,i.cookie){let s={location:"cookie",name:i.cookie,fp:i.fp,info:i.info},a=tt(t,s),l=O.get(a);l?rt(l,i.fp,i.info,r,e.timestamp):(O.set(a,er(a,t,s,r,e.timestamp)),tr());continue}for(let s of O.values())s.fp===i.fp&&rt(s,i.fp,s.info,r,s.lastUsedApp)}n&&ue()}function vi(e){let t=e;!t||typeof t.id!="string"||typeof t.url!="string"||(Qt(pi,t.id)&&bi(t),t.status!==void 0&&Qt(hi,t.id)&&ki(t))}function we(){if(Qe)return true;try{let{networkEventStore:e}=No("@buoy-gg/network");if(!e?.onEvent)throw new Error("no event store");Qe=e.onEvent(vi,true),xe=true}catch{xe=false}return ue(),xe}function rr(e,t,r){let n=O.get(t);if(!n)throw new Error(`No token row "${t}".`);return p={kind:e,tokenId:t,startedAt:S(),startFp:n.fp,ruleId:r,status:"waiting",newTokens:0,staleAfterFailure:0,failedRefreshes:0},ue(),p}function xi(){p=null,ue()}function wi(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 Ai(e,t){let r=[e.firstSeenReal,...e.history.map(o=>o.firstSeenReal)].slice(0,-1).filter(o=>t-o<=Gt).length,n=e.info.issuedAt;return{id:e.key,label:wi(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 Ae(){let e=S(),t=[...O.values()].sort((r,n)=>n.lastUsedReal-r.lastUsedReal).map(r=>Ai(r,e));if(p?.status==="refreshed"){let r=O.get(p.tokenId);r&&(p.newLifetimeMs=r.lifetimeMs,p.newIssuedBy=r.issuedBy)}return{available:xe,watching:Qe!==null,tokens:t,check:p?{...p}:null}}function Ti(e){let t=Ae();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 Si(e){return O.get(e)?.origin??null}import{isProNow as nr}from"@buoy-gg/shared-ui/web";var f={anchor:Oe,settings:se,lastJump:null,changedAt:null,hydrated:false},nt=new Set,Te=null;function or(){Te=null,nt.forEach(e=>e())}yi(or);function ce(e){return nt.add(e),()=>{nt.delete(e)}}function $i(){return f.settings}function ir(){return M(f.anchor,S())}function sr(){return f.anchor.mode!=="real"}function Ii(e){if(e.mode==="real"){Pt(null),vo();return}Mt(),Pt(t=>M(f.anchor,t)),ko()}function Ci(){let e={v:1,anchor:f.settings.persist&&nr()?f.anchor:null,settings:f.settings};He(e)}function ar(){let e={v:1,anchor:f.settings.persist&&nr()?f.anchor:null,settings:f.settings};return f.settings.persist&&f.anchor.mode!=="real"&&(e.reload={anchor:f.anchor,at:S()}),He(e)}function X(e,{save:t=true}={}){f={...f,...e},e.anchor&&Ii(f.anchor),t&&Ci(),or()}function ee(e,t=f.lastJump){X({anchor:e,lastJump:t,changedAt:S(),hydrated:true})}var lr=e=>T.parse(e);function ur(e,t=false){let r=S(),n=M(f.anchor,r),o=Rt(e,n,lr),i=o-n;return ee(Le(f.anchor,r,o,t),{byMs:i,firedTimers:0,at:r}),C()}function ot(e,t){let r=Ne(e),n=S(),o=ao(f.anchor,n,r),i=(t??f.settings.fireTimersOnJump)&&r>0;if(ee(o,{byMs:r,firedTimers:0,at:n}),i){let s=Ro(r);s>0&&X({lastJump:{byMs:r,firedTimers:s,at:n}},{save:false})}return C()}function it(e){let t=S(),r=M(f.anchor,t),n=e===void 0||e===""?r:Rt(e,r,lr);return ee(lo(f.anchor,t,n)),C()}function st(){return f.anchor.mode==="frozen"&&ee(uo(f.anchor,S())),C()}function cr(e){return ee(co(f.anchor,S(),Number(e))),C()}function at(){return ee(Oe,null),C()}function dr(e){let t={...f.settings};for(let r of Object.keys(se))typeof e[r]=="boolean"&&(t[r]=e[r]);return X({settings:t}),C()}function Ri(e){return e>0?Co(e):0}var fr=false;function pr(e){if(!e){X({hydrated:true},{save:false});return}let t=e.reload?S()-e.reload.at:1/0,r=t>=0&&t<Do?e.reload?.anchor:void 0;e.reload&&He({v:1,anchor:e.anchor,settings:e.settings});let n=e.anchor??r??null;X({settings:e.settings,anchor:n??Oe,changedAt:n?S():null,hydrated:true},{save:false})}function lt(){if(fr)return;fr=true,Mt();let e=Oo();if(e!==void 0){pr(e);return}Po().then(t=>{f.changedAt===null?pr(t):X({hydrated:true},{save:false})})}function Ei(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone??"unknown"}catch{return"unknown"}}function C(){let e=S(),t=M(f.anchor,e);return{mode:f.anchor.mode,active:f.anchor.mode!=="real",rate:f.anchor.rate,virtualNow:t,virtualIso:new T(t).toISOString(),realNow:e,offsetMs:so(f.anchor,e),timeZone:Ei(),timers:Io(),lastJump:f.lastJump,changedAt:f.changedAt,settings:f.settings,hydrated:f.hydrated,tokens:Ae(),patched:{date:po(),intl:bo(),timers:$o(),animatedOnRealClock:Ao()}}}function hr(){return Te||(Te=C()),Te}import{useSyncExternalStore as Oi}from"react";import{ClockToolIcon as mr,FloatingTool as Di,Pause as Pi,Play as Li,X as Ni,dismissFloatingTool as zi,getFloatingTools as ji,getUseIsPro as Mi,night as de,openFloatingTool as yr}from"@buoy-gg/shared-ui/web";import{useEffect as _i,useState as Fi}from"react";function V(e,t=250){let[,r]=Fi(0);_i(()=>{let s=setInterval(()=>r(a=>a+1),t);return()=>clearInterval(s)},[t]);let n=S();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 F=e=>String(e).padStart(2,"0");function fe(e){let t=new T(e);return`${F(t.getHours())}:${F(t.getMinutes())}:${F(t.getSeconds())}`}var Bi=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],gr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ui(e){let t=new T(e);return`${Bi[t.getDay()]}, ${gr[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`}function Se(e,t=true){let r=new T(e),n=t?fe(e):`${F(r.getHours())}:${F(r.getMinutes())}`;return`${gr[r.getMonth()]} ${r.getDate()} \xB7 ${n}`}function br(e){let t=new T(e);return`${t.getFullYear()}-${F(t.getMonth()+1)}-${F(t.getDate())} ${F(t.getHours())}:${F(t.getMinutes())}`}function Hi(e){if(Math.abs(e)<1e3)return"matches real time";let t=re(Math.abs(e),{signed:false});return e>0?`${t} ahead of real time`:`${t} behind real time`}function kr(e){return e.mode==="real"?{label:"Real time",tone:"neutral"}:e.mode==="frozen"?{label:"Frozen",tone:"info"}:e.rate!==1?{label:`${Ot(e.rate)} speed`,tone:"warning"}:{label:"Overridden",tone:"accent"}}function Vi(e){return`clock-jump-${e<0?"minus":"plus"}-${re(Math.abs(e),{signed:false}).replace(/\s/g,"")}`}import{jsx as N,jsxs as ut}from"react/jsx-runtime";var $e="clock-chip",vr={id:$e,render:e=>N(wr,{...e})},Wi=()=>ji().some(e=>e.id===$e);function Ji(){yr(vr)}var xr=false;function qi(){if(xr)return;xr=true;let e=false,t=()=>{let r=sr()&&$i().showChip;r&&!e?yr(vr):!r&&Wi()&&zi($e),e=r};ce(t),t()}function wr({id:e,revealToken:t}){let r=Oi(ce,hr,hr),{virtual:n,real:o}=V(r),i=r.mode==="frozen",s=Mi()(),a=i||s,l=kr(r),c=n-o,u=`${Math.abs(c)<1e3?"0s":re(c)} \xB7 ${l.label.toLowerCase()}`;return N(Di,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:`Move or hide the clock chip. App time ${Se(n)}`,handleAdornment:N(mr,{size:12}),children:ut(m,{style:K.row,children:[N(mr,{size:18}),ut(m,{style:K.text,children:[N(A,{style:K.time,numberOfLines:1,testID:"clock-chip-time",children:Se(n)}),N(A,{style:K.detail,numberOfLines:1,testID:"clock-chip-detail",children:u})]}),a?ut(B,{testID:i?"clock-chip-resume":"clock-chip-freeze",accessibilityRole:"button",accessibilityLabel:i?"Resume the app clock":"Freeze the app clock",onPress:()=>i?st():it(),style:K.button,hitSlop:{top:8,bottom:8,left:4,right:4},children:[i?N(Li,{size:16,color:de.color.accent}):null,i?null:N(Pi,{size:16,color:de.color.text})]}):null,a?N(m,{style:K.separator}):null,N(B,{testID:"clock-chip-reset",accessibilityRole:"button",accessibilityLabel:"Back to real time",onPress:()=>at(),style:K.button,hitSlop:{top:8,bottom:8,left:4,right:8},children:N(Ni,{size:16,color:de.color.textSecondary})})]})})}var K=G.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:de.color.textSecondary,fontSize:11,fontVariant:["tabular-nums"]},button:{width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:16},separator:{width:G.hairlineWidth,height:20,backgroundColor:de.color.separator}});import{ClockToolIcon as Ki,CLOCK_TOOL_ICON_COLOR as Zi,createToolFactory as Gi,defineToolPreset as Yi}from"@buoy-gg/shared-ui/web";import{useEffect as Ar,useState as Qi}from"react";import{reloadApp as Xi}from"@buoy-gg/shared-ui/web";import{createSyncAdapter as es}from"@buoy-gg/shared-ui/web";import{dispatchToolAction as Tr}from"@buoy-gg/shared-ui/web";var Sr="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 $r(e){we();let t=Ti(e);if(!t)throw new Error(e?`No token "${e}". Read getState for the current ids.`:Sr);return t}function Ir(e,t=1e4){let r=$r(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)-ir();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 ot(n),rr("expiry",r.id),C()}async function Cr(e,t=401,r=1){let n=$r(e),o=Si(n.id);if(!o)throw new Error(Sr);await Rr();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 Tr("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 rr("401",n.id,a.rule.id),C()}async function Rr(){let e=Ae().check;e?.ruleId&&e.forcedAt===void 0&&await Tr("network","deleteOverrideRule",{id:e.ruleId}).catch(()=>{})}async function Er(){return await Rr(),xi(),C()}function Z(e){return e&&typeof e=="object"?e:{}}function ct(e,...t){for(let r of t){let n=e[r];if(typeof n=="string"||typeof n=="number")return n}}function pe(e,t){let r=e[t];if(typeof r=="boolean")return r;if(r==="true")return true;if(r==="false")return false}var Or=es({version:1,getSnapshot(){return C()},subscribe(e){return ce(e)},actions:{getState(){return we(),C()},setTime(e){let t=Z(e),r=ct(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 ur(r,pe(t,"freeze")??false)},shift(e){let t=Z(e),r=ct(t,"by","ms","duration","delta");if(r===void 0)throw new Error('shift needs `by`: a duration like "+1d", "-2h30m", "90s", or ms.');return ot(r,pe(t,"fireTimers"))},freeze(e){return it(ct(Z(e),"time","at"))},resume(){return st()},setRate(e){let t=Z(e),r=Number(t.rate??t.speed);if(!Number.isFinite(r))throw new Error("setRate needs a numeric `rate` (1 = normal speed).");return cr(r)},reset(){return at()},updateSettings(e){let t=Z(e);return dr({persist:pe(t,"persist"),showChip:pe(t,"showChip"),fireTimersOnJump:pe(t,"fireTimersOnJump")})},jumpToTokenExpiry(e){let t=Z(e),r=typeof t.token=="string"?t.token:typeof t.id=="string"?t.id:void 0,n=Number(t.leadMs??t.lead??1e4);return Ir(r,Number.isFinite(n)?n:1e4)},failNextRequest(e){let t=Z(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 Cr(r,n,Number.isFinite(o)?o:1)},stopTokenCheck(){return Er()},async holdForReload(){return await ar(),C()}}});import{useState as Ie}from"react";import{ChevronRight as ts,NightButton as rs,NightCard as Ce,NightChip as ns,NightFootnote as dt,NightRows as ft,NightSectionLabel as Dr,NightSegmented as os,NightSwitch as Pr,ProBadge as is,ProUpgradeModal as ss,getUseIsPro as as,monoFont as ls,night as b,useSafeAreaInsets as us}from"@buoy-gg/shared-ui/web";import{ChevronRight as cs,NightButton as Lr,NightCard as ds,NightFootnote as fs,NightRows as ps,NightSectionLabel as hs,ProBadge as ms,night as x}from"@buoy-gg/shared-ui/web";import{jsx as w,jsxs as j}from"react/jsx-runtime";var W=e=>re(Math.abs(e),{signed:false});function ys({snapshot:e,run:t,openId:r,onToggle:n,isPro:o,onUpgrade:i}){let s=e.tokens;return j(m,{children:[w(hs,{children:s.tokens.length>1?"Sign-in tokens":"Sign-in token"}),w(ds,{children:j(ps,{children:[s.tokens.map((a,l)=>j(m,{children:[w(gs,{token:a,snapshot:e,index:l,open:r===a.id,onPress:()=>n(a.id)}),r===a.id?w(bs,{token:a,snapshot:e,run:o?t:()=>i("Sign-in token tests"),isPro:o}):null]},a.id)),s.tokens.length===0?w(m,{style:g.row,testID:"clock-token-empty",children:w(A,{style:g.emptyText,children:s.available?"No token seen yet":"Needs the Network tool"})},"empty"):null]})}),w(vs,{check:s.check,tokens:s.tokens,snapshot:e,run:t}),s.tokens.length===0?w(fs,{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 gs({token:e,snapshot:t,index:r,open:n,onPress:o}){let{virtual:i}=V(t,1e3),s=e.expiresAt!==void 0?e.expiresAt-i:void 0,a=e.neverExpires?"No expiry":s===void 0?"Unknown":s<=0?"Expired":W(s),l=s!==void 0&&s<=0?g.valueDanger:s!==void 0&&s<6e4?g.valueWarning:null;return j(B,{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:g.row,children:[j(m,{style:g.rowText,children:[w(A,{style:g.rowTitle,numberOfLines:1,children:e.label}),w(A,{style:g.rowSubtitle,numberOfLines:1,children:`${e.host} \xB7 ${e.hint??e.formatLabel}`})]}),j(m,{style:g.rowRight,children:[w(A,{style:[g.value,l],testID:`clock-token-${r}-left`,children:a}),w(m,{style:n?g.chevronOpen:null,children:w(cs,{size:16,color:x.color.textTertiary})})]})]})}function bs({token:e,snapshot:t,run:r,isPro:n}){let{virtual:o,real:i}=V(t,1e3),s=ks(e,o,i),a=e.expiresAt!==void 0&&e.expiresAt-o>1e4;return j(m,{style:g.detail,testID:"clock-token-detail",children:[s.map(l=>w(A,{style:[g.detailLine,l.tone==="warn"?g.warn:null,l.tone==="bad"?g.bad:null],children:l.text},l.text)),j(m,{style:g.buttons,children:[w(m,{style:g.button,children:w(Lr,{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:g.button,children:w(Lr,{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:j(m,{style:g.proLine,children:[w(ms,{}),w(A,{style:[g.hint,g.proHint],children:"Jump to Expiry and Fail Next Request are part of Buoy Pro."})]}),w(A,{style:g.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 ks(e,t,r){let n=[];if(e.expiresAt!==void 0){if(n.push({text:`Expires ${Se(e.expiresAt)}`}),e.lifetimeMs!==void 0&&e.lifetimeMs>0&&n.push({text:`Lasts ${W(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 ${W(i)}`:`The server stopped accepting it ${W(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 ${W(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 ${fe(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 vs({check:e,tokens:t,snapshot:r,run:n}){let{virtual:o,real:i}=V(r,1e3);if(!e)return null;let s=t.find(c=>c.id===e.tokenId),{text:a,tone:l}=xs(e,s,o,i);return j(m,{style:g.check,children:[w(A,{style:[g.checkText,l==="good"?g.good:null,l==="bad"?g.bad:null,l==="warn"?g.warn:null],testID:"clock-token-check",children:a}),w(B,{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(A,{style:g.checkDone,children:e.status==="waiting"?"Stop":"Done"})})]})}function xs(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"){let a=e.newIssuedBy?` by ${e.newIssuedBy}`:"",l=e.newLifetimeMs&&e.newLifetimeMs>0?`. The new token lasts ${W(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 ${fe(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 ${W(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 ${W(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 g=G.create({row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:56,paddingHorizontal:x.rowPadH,paddingVertical:10},rowText:{flex:1,minWidth:0},rowTitle:{color:x.color.text,fontSize:x.font.row},rowSubtitle:{color:x.color.textTertiary,fontSize:x.font.caption,marginTop:2},rowRight:{flexDirection:"row",alignItems:"center",gap:6},value:{color:x.color.textSecondary,fontSize:x.font.row,fontVariant:["tabular-nums"]},valueWarning:{color:x.color.warning},valueDanger:{color:x.color.danger},chevronOpen:{transform:[{rotate:"90deg"}]},emptyText:{color:x.color.textSecondary,fontSize:x.font.row},detail:{paddingHorizontal:x.rowPadH,paddingBottom:14,gap:4},detailLine:{color:x.color.textSecondary,fontSize:x.font.caption},buttons:{flexDirection:"row",gap:8,marginTop:8},button:{flex:1},hint:{color:x.color.textTertiary,fontSize:x.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:x.labelInset},checkText:{flex:1,color:x.color.textSecondary,fontSize:x.font.caption,lineHeight:18},checkDone:{color:x.color.accent,fontSize:x.font.caption,fontWeight:"600"},good:{color:x.color.accent},warn:{color:x.color.warning},bad:{color:x.color.danger}});import{jsx as d,jsxs as $}from"react/jsx-runtime";var Nr="#F59E0B";function zr({snapshot:e,onAction:t,onReload:r}){let n=us({minBottom:16}),[o,i]=Ie(null),[s,a]=Ie(null),l=as()(),[c,u]=Ie(null),y=v=>u(v),k=(v,R)=>{i(null),t(v,R).catch(z=>{i(z instanceof Error?z.message:String(z))})},I=v=>a(R=>R===v?null:v);return e?$($t,{style:h.fill,contentContainerStyle:[h.content,{paddingBottom:n.bottom}],testID:"clock-scroll",keyboardShouldPersistTaps:"handled",children:[d(ws,{snapshot:e}),o?d(m,{testID:"clock-error",children:d(dt,{tone:"danger",centered:true,children:o})}):null,$(m,{children:[d(Dr,{children:"Jump ahead"}),d(Ts,{run:k})]}),$(m,{children:[d(Ce,{children:$(ft,{children:[$(m,{children:[d(Mr,{title:"Date & Time",testID:"clock-date-row",open:s==="date",onPress:()=>I("date"),value:d(Ss,{snapshot:e})}),s==="date"?d(Is,{snapshot:e,run:k,onDone:()=>a(null)}):null]},"date"),$(m,{style:h.row,children:[d(pt,{title:"Freeze",isPro:l}),d(Pr,{value:e.mode==="frozen",testID:"clock-freeze",accessibilityLabel:"Freeze the clock",onValueChange:v=>v&&!l?y("Freeze"):k(v?"freeze":"resume")})]},"freeze"),$(m,{children:[d(Mr,{title:"Speed",pro:!l,testID:"clock-speed-row",open:s==="speed",onPress:()=>l?I("speed"):y("Speed"),value:d(A,{style:h.rowValue,children:Br(e)})}),s==="speed"?d(Cs,{snapshot:e,run:k}):null]},"speed")]})}),d(dt,{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(ys,{snapshot:e,run:k,openId:s,onToggle:I,isPro:l,onUpgrade:y}):null,d(Ce,{children:$(ft,{children:[r?d(_r,{label:"Reload App",testID:"clock-reload",onPress:r},"reload"):null,d(_r,{label:"Use Real Time",accessibilityLabel:"Reset to real time",testID:"clock-reset",destructive:true,disabled:e.mode==="real",onPress:()=>k("reset")},"reset")]})}),$(m,{children:[d(Dr,{children:"Options"}),d(Es,{settings:e.settings,run:k,isPro:l,onUpgrade:y})]}),d(ss,{visible:c!==null&&!l,onClose:()=>u(null),featureName:c??void 0})]}):d(m,{style:h.waiting,testID:"clock-waiting",children:d(dt,{centered:true,children:"Waiting for the app's clock\u2026"})})}function pt({title:e,isPro:t}){return $(m,{style:h.titleRow,children:[d(A,{style:h.rowTitle,children:e}),t?null:d(is,{})]})}function ws({snapshot:e}){let{virtual:t,real:r}=V(e),n=kr(e),o=e.mode!=="real",i=Hi(t-r),s=e.mode==="frozen"?" \xB7 Frozen":o&&e.rate!==1?` \xB7 ${Br(e)}`:"";return $(m,{style:h.hero,children:[d(A,{style:[h.heroTime,o?h.heroTimeActive:null],testID:"clock-hero-time",accessibilityLabel:`App clock ${fe(t)}`,children:fe(t)}),d(A,{style:h.heroDate,testID:"clock-hero-date",children:Ui(t)}),d(m,{testID:"clock-status",accessibilityLabel:`Clock status: ${n.label}${o?`, ${i}`:""}`,children:d(A,{style:[h.heroStatus,o?h.heroStatusActive:null],testID:"clock-offset",children:o?`${i}${s}`:"Real time"})})]})}var jr=36e5,ht=24*jr,As=[{ms:jr,unit:"hour"},{ms:ht,unit:"day"},{ms:7*ht,unit:"week"},{ms:30*ht,unit:"month"}];function Ts({run:e}){return d(Ce,{style:h.jumpBar,children:As.map((t,r)=>$(B,{testID:Vi(t.ms),accessibilityRole:"button",accessibilityLabel:`Jump ahead one ${t.unit}`,activeOpacity:.6,onPress:()=>e("shift",{by:t.ms}),style:[h.jump,r>0?h.jumpDivider:null],children:[d(A,{style:h.jumpAmount,children:"+1"}),d(A,{style:h.jumpUnit,children:t.unit})]},t.unit))})}function Mr({title:e,pro:t,value:r,open:n,onPress:o,testID:i}){return $(B,{testID:i,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{expanded:n},activeOpacity:.6,onPress:o,style:h.row,children:[d(pt,{title:e,isPro:!t}),$(m,{style:h.rowRight,children:[r,d(m,{style:n?h.chevronOpen:null,children:d(ts,{size:16,color:b.color.textTertiary})})]})]})}function Ss({snapshot:e}){let{virtual:t}=V(e,1e3);return d(A,{style:[h.rowValue,h.tabular],numberOfLines:1,children:Se(t,false)})}function _r({label:e,onPress:t,testID:r,destructive:n,disabled:o,accessibilityLabel:i}){return d(B,{testID:r,accessibilityRole:"button",accessibilityLabel:i??e,accessibilityState:{disabled:!!o},activeOpacity:.6,disabled:o,onPress:t,style:[h.row,o?h.rowDisabled:null],children:d(A,{style:[h.actionLabel,n?h.actionDestructive:null],children:e})})}var $s=Et.filter(e=>["midnight","month-end","year-end"].includes(e.id));function Is({snapshot:e,run:t,onDone:r}){let[n,o]=Ie(""),{virtual:i}=V(e,1e3),s=()=>n.trim()||br(i),a=e.mode==="frozen",l=c=>{t("setTime",{time:c,freeze:a}),r()};return $(m,{style:h.editor,children:[$(m,{style:h.inputRow,children:[d(St,{testID:"clock-time-input",accessibilityLabel:"Date and time",value:n,onChangeText:o,placeholder:br(i),placeholderTextColor:b.color.placeholder,autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>l(s()),style:h.input}),d(rs,{label:"Set",testID:"clock-time-apply",accessibilityLabel:"Set this time",size:"md",variant:"primary",fullWidth:false,onPress:()=>l(s())})]}),d(A,{style:h.hint,children:"Year-month-day and 24-hour time, or +3d, -2h"}),d(m,{style:h.presets,children:$s.map(c=>d(ns,{label:c.label,testID:`clock-preset-${c.id}`,onPress:()=>l(c.at(i,T))},c.id))})]})}var Fr=[{key:"1",label:"Normal"},{key:"10",label:"10\xD7"},{key:"60",label:"1 min/s"},{key:"3600",label:"1 hr/s"}];function Br(e){return e.mode==="real"||e.rate===1?"Normal":Fr.find(t=>Number(t.key)===e.rate)?.label??Ot(e.rate)}function Cs({snapshot:e,run:t}){let r=e.mode==="real"?"1":String(e.rate);return $(m,{style:h.editor,children:[d(m,{style:h.segmentRow,children:d(os,{tabs:Fr,activeKey:r,size:"sm",testIDPrefix:"clock-speed",onChange:n=>t("setRate",{rate:Number(n)})})}),d(A,{style:h.hint,children:"Taps, animations and timers keep real speed."})]})}var Rs=[{key:"showChip",title:"Show Floating Clock"},{key:"persist",title:"Keep After Reload",pro:true}];function Es({settings:e,run:t,isPro:r,onUpgrade:n}){return d(Ce,{children:d(ft,{children:Rs.map(o=>{let i=!!o.pro&&!r;return $(m,{style:h.row,children:[d(pt,{title:o.title,isPro:!i}),d(Pr,{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 h=G.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:Nr},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:G.hairlineWidth,borderLeftColor:b.color.separator},jumpAmount:{color:Nr,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:ls,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 Os}from"react/jsx-runtime";var Ds=Or.actions;async function Ps(e,t){let r=Ds[e];if(!r)throw new Error(`Unknown clock action: ${e}`);return r(t)}function Ls(){ar().then(()=>Xi("auto","buoy clock")).catch(()=>{})}function Ur(){Ar(()=>{lt(),we()},[]);let[e,t]=Qi(C);return Ar(()=>ce(()=>t(C())),[]),Os(zr,{snapshot:e,onAction:Ps,onReload:Ls})}import{jsx as Ns}from"react/jsx-runtime";var Hr=Yi({id:"clock",name:"CLOCK",description:"Travel to any date, freeze or speed up the app's clock",slot:"both",color:Zi,icon:({size:e,color:t})=>Ns(Ki,{size:e,color:t}),component:Ur,modal:{subtitle:"override the app's date & time"}}),zs=Gi(Hr);import{ClockToolIcon as js,CLOCK_TOOL_ICON_COLOR as Ms}from"@buoy-gg/shared-ui/web";var _s=typeof navigator<"u"&&navigator.product==="ReactNative",Fs=(()=>{try{return globalThis.Capacitor?.isNativePlatform?.()===true}catch{return false}})();(_s||Fs)&&(wo(xt),qi(),typeof kt<"u"&&kt&<());export{$e as CLOCK_CHIP_ID,Ms as CLOCK_TOOL_ICON_COLOR,Ur as ClockBody,wr as ClockChip,js as ClockToolIcon,zr as ClockToolView,Et as TIME_PRESETS,lt as bootClock,Or as clockSyncAdapter,Hr as clockToolPreset,zs as createClockTool,Cr as failNextRequest,re as formatDuration,it as freeze,C as getClockSnapshot,Ae as getTokenReport,ke as inspectToken,sr as isClockOverridden,Ir as jumpToTokenExpiry,Ji as openClockChip,Ne as parseDuration,Ri as previewJump,S as realNow,at as reset,st as resume,cr as setRate,ur as setTime,ot as shift,we as startTokenWatch,Er as stopTokenCheck,ce as subscribeClock,H as tokenFingerprint,dr as updateSettings,V as useLiveClock,ir as virtualNow,_e 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.65",
|
|
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.65"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": "*"
|