@buoy-gg/impersonate 7.0.76 → 7.0.78

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.
@@ -7,4 +7,4 @@
7
7
  asyncStorage: ${e.asyncStorage},
8
8
  mmkv: ${e.mmkv},
9
9
  },
10
- },`;try{await(0,_sharedUi.copyToClipboard)(r);x(true);setTimeout(()=>x(false),2e3)}catch{}};return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{testID:"buoy-impersonate-settings-scroll",style:styles.container,contentContainerStyle:styles.contentContainer,children:[p&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.actionBar,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionBarContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.unsavedText,children:"Unsaved changes"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionButtons,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:"buoy-impersonate-discard",style:styles.discardButton,onPress:b,children:[(0,_jsxRuntime.jsx)(_sharedUi.X,{size:14,color:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.discardButtonText,children:"Discard"})]}),(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:"buoy-impersonate-save",style:styles.saveButton,onPress:m,children:[(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:14,color:_sharedUi.night.color.onAccent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.saveButtonText,children:"Save"})]})]})]})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Header Configuration",icon:_sharedUi.Settings,defaultOpen:true,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.inputLabel,children:"Header Key"}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{testID:"buoy-impersonate-header-key",style:styles.input,value:t,onChangeText:i,placeholder:"x-impersonate-user-id",placeholderTextColor:_sharedUi.night.color.placeholder,autoCapitalize:"none",autoCorrect:false}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inputFooter,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.helperText,children:"The HTTP header key used for impersonation. Value will be the user ID."}),t!==DEFAULT_HEADER_KEY&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>i(DEFAULT_HEADER_KEY),style:styles.resetLink,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.resetLinkText,children:"Reset to default"})})]})]})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Display",icon:_sharedUi.Eye,defaultOpen:true,variant:"bordered",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.sectionContent,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.togglesCard,children:(0,_jsxRuntime.jsx)(ToggleRow,{label:"Floating Banner",description:"Show a floating banner when impersonation is active",value:d,onChange:r=>{g(r);o(r)},recommended:true,testID:"buoy-impersonate-show-banner"})})})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Data Clearing",icon:_sharedUi.AlertTriangle,defaultOpen:true,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionDescription,children:"Choose what data to clear when impersonation starts or stops. This ensures you see fresh data for the impersonated user."}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.togglesCard,children:[(0,_jsxRuntime.jsx)(ToggleRow,{label:"React Query",description:"Clear query cache and cancel pending queries",value:e.reactQuery,onChange:r=>h("reactQuery",r),recommended:true,detected:s?.reactQuery}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.divider}),(0,_jsxRuntime.jsx)(ToggleRow,{label:"Redux",description:"Reset Redux store to initial state",value:e.redux,onChange:r=>h("redux",r),recommended:true,detected:s?.redux})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.advancedSection,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.advancedLabel,children:"Storage Options"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.togglesCard,styles.dangerousCard],children:[(0,_jsxRuntime.jsx)(ToggleRow,{label:"AsyncStorage",description:"Clear app data (preserves @buoy/* keys)",value:e.asyncStorage,onChange:r=>h("asyncStorage",r),dangerous:true,detected:s?.asyncStorage}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.divider}),(0,_jsxRuntime.jsx)(ToggleRow,{label:"MMKV",description:"Clear MMKV storage (preserves @buoy/* keys)",value:e.mmkv,onChange:r=>h("mmkv",r),dangerous:true,detected:s?.mmkv})]})]}),(e.asyncStorage||e.mmkv)&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningCard,children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:16,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningTitle,children:"Storage Clearing Enabled"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningText,children:"This will remove app data like settings and cached content. Auth tokens managed by @buoy/* are preserved."})]})]})]})}),!f&&(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:"buoy-impersonate-restore-defaults",style:styles.restoreButton,onPress:T,children:[(0,_jsxRuntime.jsx)(_sharedUi.RefreshCw,{size:14,color:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.restoreButtonText,children:"Restore Defaults"})]}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"How It Works",icon:_sharedUi.Info,defaultOpen:false,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.infoText,children:"When impersonation is enabled, the configured header is automatically added to all outgoing fetch and XMLHttpRequest calls."}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.infoText,styles.infoTextSpaced],children:"Your backend should check for this header and return data for the specified user ID instead of the authenticated user."}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.codeBlock,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.codeComment,children:"// Example request header"}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.codeText,children:[t||"x-impersonate-user-id",": ",(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.codeValue,children:"user_123"})]})]})]})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Export Configuration",icon:_sharedUi.Copy,defaultOpen:false,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.infoText,children:"Copy current settings to use in createImpersonateTool()."}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.dataViewerContainer,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:"",data:C,showTypeFilter:true,rawMode:true,initialExpanded:true})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.copyButton,onPress:j,children:y?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:14,color:_sharedUi.buoyColors.success}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.copyButtonText,styles.copySuccessText],children:"Copied!"})]}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.Copy,{size:14,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.copyButtonText,children:"Copy Config"})]})})]})})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1},contentContainer:{padding:16,gap:12,paddingBottom:32},actionBar:{backgroundColor:_sharedUi.night.color.accentSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder,padding:12},actionBarContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},unsavedText:{fontSize:13,fontWeight:"500",color:_sharedUi.night.color.accent},actionButtons:{flexDirection:"row",gap:8},saveButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:_sharedUi.night.color.accent,paddingHorizontal:14,paddingVertical:8,borderRadius:6},saveButtonText:{fontSize:13,fontWeight:"600",color:_sharedUi.night.color.onAccent},discardButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:_sharedUi.night.color.surfaceElevated,paddingHorizontal:14,paddingVertical:8,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.border},discardButtonText:{fontSize:13,fontWeight:"500",color:_sharedUi.night.color.textSecondary},restoreButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,paddingVertical:12,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,borderStyle:"dashed"},restoreButtonText:{fontSize:13,color:_sharedUi.night.color.textSecondary},sectionContent:{paddingTop:8},sectionDescription:{fontSize:13,color:_sharedUi.night.color.textSecondary,lineHeight:18,marginBottom:14},togglesCard:{backgroundColor:_sharedUi.night.color.surface,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.border,padding:4},dangerousCard:{borderColor:_sharedUi.night.color.warning+"30"},advancedSection:{marginTop:16},advancedLabel:{fontSize:11,fontWeight:"600",color:_sharedUi.night.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8,marginLeft:2},inputLabel:{fontSize:12,fontWeight:"600",color:_sharedUi.night.color.textSecondary,marginBottom:8},input:{height:42,backgroundColor:_sharedUi.night.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,paddingHorizontal:14,fontSize:14,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},inputFooter:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start",marginTop:8,gap:12},helperText:{flex:1,fontSize:12,color:_sharedUi.night.color.textTertiary,lineHeight:16},resetLink:{paddingVertical:2},resetLinkText:{fontSize:12,color:_sharedUi.night.color.accent,fontWeight:"500"},recommendedBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:_sharedUi.night.color.accentSoft,paddingHorizontal:8,paddingVertical:3,borderRadius:4},recommendedText:{fontSize:10,fontWeight:"600",color:_sharedUi.night.color.accent},detectedBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4},detectedBadgeActive:{backgroundColor:_sharedUi.buoyColors.success+"15"},detectedBadgeInactive:{backgroundColor:_sharedUi.night.color.textTertiary+"15"},detectedText:{fontSize:10,fontWeight:"600"},detectedTextActive:{color:_sharedUi.buoyColors.success},detectedTextInactive:{color:_sharedUi.night.color.textTertiary},divider:{height:1,backgroundColor:_sharedUi.night.color.separator,marginHorizontal:12},warningCard:{marginTop:14,flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:_sharedUi.night.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:13,fontWeight:"600",color:_sharedUi.night.color.warning,marginBottom:4},warningText:{fontSize:12,color:_sharedUi.night.color.textSecondary,lineHeight:17},infoText:{fontSize:13,color:_sharedUi.night.color.textSecondary,lineHeight:19},infoTextSpaced:{marginTop:10},codeBlock:{marginTop:14,backgroundColor:_sharedUi.night.color.bg,borderRadius:8,padding:14},codeComment:{fontSize:12,color:_sharedUi.night.color.textTertiary,fontFamily:_sharedUi.monoFont,marginBottom:6},codeText:{fontSize:13,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},codeValue:{color:_sharedUi.night.color.accent},dataViewerContainer:{marginTop:12,borderRadius:8,overflow:"hidden",borderWidth:1,borderColor:_sharedUi.night.color.border},copyButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,marginTop:14,backgroundColor:_sharedUi.night.color.accentSoft,paddingVertical:10,paddingHorizontal:16,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder},copyButtonText:{fontSize:13,fontWeight:"600",color:_sharedUi.night.color.accent},copySuccessText:{color:_sharedUi.buoyColors.success}});
10
+ },`;try{await(0,_sharedUi.copyToClipboard)(r);x(true);setTimeout(()=>x(false),2e3)}catch{}};return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",testID:"buoy-impersonate-settings-scroll",style:styles.container,contentContainerStyle:styles.contentContainer,children:[p&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.actionBar,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionBarContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.unsavedText,children:"Unsaved changes"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionButtons,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:"buoy-impersonate-discard",style:styles.discardButton,onPress:b,children:[(0,_jsxRuntime.jsx)(_sharedUi.X,{size:14,color:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.discardButtonText,children:"Discard"})]}),(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:"buoy-impersonate-save",style:styles.saveButton,onPress:m,children:[(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:14,color:_sharedUi.night.color.onAccent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.saveButtonText,children:"Save"})]})]})]})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Header Configuration",icon:_sharedUi.Settings,defaultOpen:true,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.inputLabel,children:"Header Key"}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{testID:"buoy-impersonate-header-key",style:styles.input,value:t,onChangeText:i,placeholder:"x-impersonate-user-id",placeholderTextColor:_sharedUi.night.color.placeholder,autoCapitalize:"none",autoCorrect:false}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inputFooter,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.helperText,children:"The HTTP header key used for impersonation. Value will be the user ID."}),t!==DEFAULT_HEADER_KEY&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>i(DEFAULT_HEADER_KEY),style:styles.resetLink,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.resetLinkText,children:"Reset to default"})})]})]})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Display",icon:_sharedUi.Eye,defaultOpen:true,variant:"bordered",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.sectionContent,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.togglesCard,children:(0,_jsxRuntime.jsx)(ToggleRow,{label:"Floating Banner",description:"Show a floating banner when impersonation is active",value:d,onChange:r=>{g(r);o(r)},recommended:true,testID:"buoy-impersonate-show-banner"})})})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Data Clearing",icon:_sharedUi.AlertTriangle,defaultOpen:true,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionDescription,children:"Choose what data to clear when impersonation starts or stops. This ensures you see fresh data for the impersonated user."}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.togglesCard,children:[(0,_jsxRuntime.jsx)(ToggleRow,{label:"React Query",description:"Clear query cache and cancel pending queries",value:e.reactQuery,onChange:r=>h("reactQuery",r),recommended:true,detected:s?.reactQuery}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.divider}),(0,_jsxRuntime.jsx)(ToggleRow,{label:"Redux",description:"Reset Redux store to initial state",value:e.redux,onChange:r=>h("redux",r),recommended:true,detected:s?.redux})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.advancedSection,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.advancedLabel,children:"Storage Options"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.togglesCard,styles.dangerousCard],children:[(0,_jsxRuntime.jsx)(ToggleRow,{label:"AsyncStorage",description:"Clear app data (preserves @buoy/* keys)",value:e.asyncStorage,onChange:r=>h("asyncStorage",r),dangerous:true,detected:s?.asyncStorage}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.divider}),(0,_jsxRuntime.jsx)(ToggleRow,{label:"MMKV",description:"Clear MMKV storage (preserves @buoy/* keys)",value:e.mmkv,onChange:r=>h("mmkv",r),dangerous:true,detected:s?.mmkv})]})]}),(e.asyncStorage||e.mmkv)&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningCard,children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:16,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningTitle,children:"Storage Clearing Enabled"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningText,children:"This will remove app data like settings and cached content. Auth tokens managed by @buoy/* are preserved."})]})]})]})}),!f&&(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:"buoy-impersonate-restore-defaults",style:styles.restoreButton,onPress:T,children:[(0,_jsxRuntime.jsx)(_sharedUi.RefreshCw,{size:14,color:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.restoreButtonText,children:"Restore Defaults"})]}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"How It Works",icon:_sharedUi.Info,defaultOpen:false,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.infoText,children:"When impersonation is enabled, the configured header is automatically added to all outgoing fetch and XMLHttpRequest calls."}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.infoText,styles.infoTextSpaced],children:"Your backend should check for this header and return data for the specified user ID instead of the authenticated user."}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.codeBlock,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.codeComment,children:"// Example request header"}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.codeText,children:[t||"x-impersonate-user-id",": ",(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.codeValue,children:"user_123"})]})]})]})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Export Configuration",icon:_sharedUi.Copy,defaultOpen:false,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.infoText,children:"Copy current settings to use in createImpersonateTool()."}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.dataViewerContainer,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:"",data:C,showTypeFilter:true,rawMode:true,initialExpanded:true})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.copyButton,onPress:j,children:y?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:14,color:_sharedUi.buoyColors.success}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.copyButtonText,styles.copySuccessText],children:"Copied!"})]}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.Copy,{size:14,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.copyButtonText,children:"Copy Config"})]})})]})})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1},contentContainer:{padding:16,gap:12,paddingBottom:32},actionBar:{backgroundColor:_sharedUi.night.color.accentSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder,padding:12},actionBarContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},unsavedText:{fontSize:13,fontWeight:"500",color:_sharedUi.night.color.accent},actionButtons:{flexDirection:"row",gap:8},saveButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:_sharedUi.night.color.accent,paddingHorizontal:14,paddingVertical:8,borderRadius:6},saveButtonText:{fontSize:13,fontWeight:"600",color:_sharedUi.night.color.onAccent},discardButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:_sharedUi.night.color.surfaceElevated,paddingHorizontal:14,paddingVertical:8,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.border},discardButtonText:{fontSize:13,fontWeight:"500",color:_sharedUi.night.color.textSecondary},restoreButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,paddingVertical:12,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,borderStyle:"dashed"},restoreButtonText:{fontSize:13,color:_sharedUi.night.color.textSecondary},sectionContent:{paddingTop:8},sectionDescription:{fontSize:13,color:_sharedUi.night.color.textSecondary,lineHeight:18,marginBottom:14},togglesCard:{backgroundColor:_sharedUi.night.color.surface,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.border,padding:4},dangerousCard:{borderColor:_sharedUi.night.color.warning+"30"},advancedSection:{marginTop:16},advancedLabel:{fontSize:11,fontWeight:"600",color:_sharedUi.night.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8,marginLeft:2},inputLabel:{fontSize:12,fontWeight:"600",color:_sharedUi.night.color.textSecondary,marginBottom:8},input:{height:42,backgroundColor:_sharedUi.night.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,paddingHorizontal:14,fontSize:14,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},inputFooter:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start",marginTop:8,gap:12},helperText:{flex:1,fontSize:12,color:_sharedUi.night.color.textTertiary,lineHeight:16},resetLink:{paddingVertical:2},resetLinkText:{fontSize:12,color:_sharedUi.night.color.accent,fontWeight:"500"},recommendedBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:_sharedUi.night.color.accentSoft,paddingHorizontal:8,paddingVertical:3,borderRadius:4},recommendedText:{fontSize:10,fontWeight:"600",color:_sharedUi.night.color.accent},detectedBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4},detectedBadgeActive:{backgroundColor:_sharedUi.buoyColors.success+"15"},detectedBadgeInactive:{backgroundColor:_sharedUi.night.color.textTertiary+"15"},detectedText:{fontSize:10,fontWeight:"600"},detectedTextActive:{color:_sharedUi.buoyColors.success},detectedTextInactive:{color:_sharedUi.night.color.textTertiary},divider:{height:1,backgroundColor:_sharedUi.night.color.separator,marginHorizontal:12},warningCard:{marginTop:14,flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:_sharedUi.night.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:13,fontWeight:"600",color:_sharedUi.night.color.warning,marginBottom:4},warningText:{fontSize:12,color:_sharedUi.night.color.textSecondary,lineHeight:17},infoText:{fontSize:13,color:_sharedUi.night.color.textSecondary,lineHeight:19},infoTextSpaced:{marginTop:10},codeBlock:{marginTop:14,backgroundColor:_sharedUi.night.color.bg,borderRadius:8,padding:14},codeComment:{fontSize:12,color:_sharedUi.night.color.textTertiary,fontFamily:_sharedUi.monoFont,marginBottom:6},codeText:{fontSize:13,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},codeValue:{color:_sharedUi.night.color.accent},dataViewerContainer:{marginTop:12,borderRadius:8,overflow:"hidden",borderWidth:1,borderColor:_sharedUi.night.color.border},copyButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,marginTop:14,backgroundColor:_sharedUi.night.color.accentSoft,paddingVertical:10,paddingHorizontal:16,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder},copyButtonText:{fontSize:13,fontWeight:"600",color:_sharedUi.night.color.accent},copySuccessText:{color:_sharedUi.buoyColors.success}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ImpersonateHistoryList=ImpersonateHistoryList;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _UserCard=require("./UserCard");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(o,n){if("function"==typeof WeakMap)var s=new WeakMap,l=new WeakMap;return(_interopRequireWildcard=function(e,i){if(!i&&e&&e.__esModule)return e;var t,r,a={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return a;if(t=i?l:s){if(t.has(e))return t.get(e);t.set(e,a)}for(const c in e)"default"!==c&&{}.hasOwnProperty.call(e,c)&&((r=(t=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,c))&&(r.get||r.set)?t(a,c,r):a[c]=e[c]);return a})(o,n)}function HistoryItemCard({item:o,isActive:n,onSelect:s,onStop:l,onRemove:e,showRemoveButton:i}){const t=(0,_sharedUi.useRelativeTime)(new Date(o.lastUsedAt));return(0,_jsxRuntime.jsx)(_UserCard.UserCard,{user:o.user,isActive:n,onPress:()=>!n&&s(o.user),onStop:n?l:void 0,onRemove:e,showRemoveButton:i,lastUsedTime:t})}function ImpersonateHistoryList({history:o,currentUserId:n,onSelectUser:s,onStopImpersonation:l,onRemoveFromHistory:e,onClearHistory:i}){const t=(0,_react.useCallback)(({item:r})=>{const a=n===r.user.id;return(0,_jsxRuntime.jsx)(HistoryItemCard,{item:r,isActive:a,onSelect:s,onStop:l,onRemove:e?()=>e(r.user.id):void 0,showRemoveButton:!!e})},[n,s,l,e]);if(o.length===0){return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:"buoy-impersonate-history-empty",otto:"disguise",title:"No History",message:"Users you impersonate will appear here for quick access"})}return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.headerRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.headerTitle,children:"Recent"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.headerBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.headerBadgeText,children:o.length})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.headerSpacer}),i&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:"buoy-impersonate-clear-history",style:styles.clearButton,onPress:i,activeOpacity:.7,children:(0,_jsxRuntime.jsx)(_sharedUi.Trash2,{size:12,color:_sharedUi.night.color.textTertiary})})]}),(0,_jsxRuntime.jsx)(_reactNative.FlatList,{testID:"buoy-impersonate-history-scroll",data:o,keyExtractor:r=>r.user.id,renderItem:t,ItemSeparatorComponent:()=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.separator}),contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:false})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1,paddingHorizontal:16},headerRow:{flexDirection:"row",alignItems:"center",paddingVertical:10,gap:8},headerTitle:{fontSize:12,fontWeight:"600",color:_sharedUi.night.color.textTertiary,textTransform:"uppercase",letterSpacing:.5},headerBadge:{backgroundColor:_sharedUi.night.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},headerBadgeText:{fontSize:10,fontWeight:"600",color:_sharedUi.night.color.textTertiary},headerSpacer:{flex:1},clearButton:{width:24,height:24,alignItems:"center",justifyContent:"center",backgroundColor:_sharedUi.night.color.surfaceElevated,borderRadius:4},listContent:{paddingBottom:20},separator:{height:8},emptyContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyIcon:{width:56,height:56,borderRadius:28,backgroundColor:_sharedUi.night.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyTitle:{fontSize:16,fontWeight:"600",color:_sharedUi.night.color.text,marginBottom:6},emptyDescription:{fontSize:14,color:_sharedUi.night.color.textSecondary,textAlign:"center"}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ImpersonateHistoryList=ImpersonateHistoryList;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _UserCard=require("./UserCard");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(o,n){if("function"==typeof WeakMap)var s=new WeakMap,l=new WeakMap;return(_interopRequireWildcard=function(e,i){if(!i&&e&&e.__esModule)return e;var t,r,a={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return a;if(t=i?l:s){if(t.has(e))return t.get(e);t.set(e,a)}for(const c in e)"default"!==c&&{}.hasOwnProperty.call(e,c)&&((r=(t=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,c))&&(r.get||r.set)?t(a,c,r):a[c]=e[c]);return a})(o,n)}function HistoryItemCard({item:o,isActive:n,onSelect:s,onStop:l,onRemove:e,showRemoveButton:i}){const t=(0,_sharedUi.useRelativeTime)(new Date(o.lastUsedAt));return(0,_jsxRuntime.jsx)(_UserCard.UserCard,{user:o.user,isActive:n,onPress:()=>!n&&s(o.user),onStop:n?l:void 0,onRemove:e,showRemoveButton:i,lastUsedTime:t})}function ImpersonateHistoryList({history:o,currentUserId:n,onSelectUser:s,onStopImpersonation:l,onRemoveFromHistory:e,onClearHistory:i}){const t=(0,_react.useCallback)(({item:r})=>{const a=n===r.user.id;return(0,_jsxRuntime.jsx)(HistoryItemCard,{item:r,isActive:a,onSelect:s,onStop:l,onRemove:e?()=>e(r.user.id):void 0,showRemoveButton:!!e})},[n,s,l,e]);if(o.length===0){return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:"buoy-impersonate-history-empty",otto:"disguise",title:"No History",message:"Users you impersonate will appear here for quick access"})}return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.headerRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.headerTitle,children:"Recent"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.headerBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.headerBadgeText,children:o.length})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.headerSpacer}),i&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:"buoy-impersonate-clear-history",style:styles.clearButton,onPress:i,activeOpacity:.7,children:(0,_jsxRuntime.jsx)(_sharedUi.Trash2,{size:12,color:_sharedUi.night.color.textTertiary})})]}),(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",testID:"buoy-impersonate-history-scroll",data:o,keyExtractor:r=>r.user.id,renderItem:t,ItemSeparatorComponent:()=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.separator}),contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:false})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1,paddingHorizontal:16},headerRow:{flexDirection:"row",alignItems:"center",paddingVertical:10,gap:8},headerTitle:{fontSize:12,fontWeight:"600",color:_sharedUi.night.color.textTertiary,textTransform:"uppercase",letterSpacing:.5},headerBadge:{backgroundColor:_sharedUi.night.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},headerBadgeText:{fontSize:10,fontWeight:"600",color:_sharedUi.night.color.textTertiary},headerSpacer:{flex:1},clearButton:{width:24,height:24,alignItems:"center",justifyContent:"center",backgroundColor:_sharedUi.night.color.surfaceElevated,borderRadius:4},listContent:{paddingBottom:20},separator:{height:8},emptyContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyIcon:{width:56,height:56,borderRadius:28,backgroundColor:_sharedUi.night.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyTitle:{fontSize:16,fontWeight:"600",color:_sharedUi.night.color.text,marginBottom:6},emptyDescription:{fontSize:14,color:_sharedUi.night.color.textSecondary,textAlign:"center"}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.UserSearchView=UserSearchView;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _UserCard=require("./UserCard");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(c,a){if("function"==typeof WeakMap)var n=new WeakMap,l=new WeakMap;return(_interopRequireWildcard=function(e,s){if(!s&&e&&e.__esModule)return e;var r,i,o={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return o;if(r=s?l:n){if(r.has(e))return r.get(e);r.set(e,o)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((i=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(i.get||i.set)?r(o,t,i):o[t]=e[t]);return o})(c,a)}function UserSearchView({currentUser:c,searchQuery:a,searchResults:n,isSearching:l,searchError:e,onSelectUser:s,onStopImpersonation:r,searchAvailable:i=true}){const o=(0,_react.useCallback)(({item:t})=>{const d=c?.id===t.id;return(0,_jsxRuntime.jsx)(_UserCard.UserCard,{user:t,isActive:d,onPress:()=>!d&&s(t),onStop:d?r:void 0})},[c,s,r]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[!i&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.section,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningCard,children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:18,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningTitle,children:"Search Not Available"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningText,children:"Configure the onSearchUsers callback to enable user search."})]})]})}),l&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.loadingContainer,children:[(0,_jsxRuntime.jsx)(_reactNative.ActivityIndicator,{size:"small",color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.loadingText,children:"Searching users..."})]}),e?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.section,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.errorCard,children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:16,color:_sharedUi.night.color.danger}),(0,_jsxRuntime.jsx)(_reactNative.Text,{testID:"buoy-impersonate-error",style:styles.errorText,children:e})]})}):null,n.length>0&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.resultsSection,children:[(0,_jsxRuntime.jsxs)(_sharedUi.SectionHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.SectionHeader.Title,{children:"Results"}),(0,_jsxRuntime.jsx)(_sharedUi.SectionHeader.Badge,{count:n.length})]}),(0,_jsxRuntime.jsx)(_reactNative.FlatList,{testID:"buoy-impersonate-search-scroll",data:n,keyExtractor:t=>t.id,renderItem:o,ItemSeparatorComponent:()=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.separator}),contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:false})]}),!!a&&!l&&n.length===0&&!e&&(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:"buoy-impersonate-no-results",style:styles.emptyStateContainer,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.emptyStateIcon,children:(0,_jsxRuntime.jsx)(_sharedUi.Users,{size:28,color:_sharedUi.night.color.textTertiary})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyStateTitle,children:"No users found"}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.emptyStateDescription,children:['No results for "',a,'"']}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyStateHint,children:"Try a different search term"})]}),!a&&n.length===0&&!l&&i&&(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"buoy-impersonate-search-empty",children:(0,_jsxRuntime.jsx)(_sharedUi.EmptyState,{title:"Search for users",description:"Tap the search icon in the header to find users by email, name, or ID",icon:_sharedUi.Search,variant:"minimal"})})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1},section:{padding:16,paddingBottom:8},loadingContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:10,paddingVertical:20},loadingText:{fontSize:13,color:_sharedUi.night.color.textSecondary},resultsSection:{flex:1,paddingHorizontal:16},listContent:{paddingBottom:16},separator:{height:8},warningCard:{flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:_sharedUi.night.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:14,fontWeight:"600",color:_sharedUi.night.color.warning,marginBottom:4},warningText:{fontSize:13,color:_sharedUi.night.color.textSecondary,lineHeight:18},errorCard:{flexDirection:"row",alignItems:"center",gap:10,backgroundColor:_sharedUi.night.color.dangerSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.danger+"25",padding:12},errorText:{flex:1,fontSize:13,color:_sharedUi.night.color.danger},emptyStateContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyStateIcon:{width:56,height:56,borderRadius:28,backgroundColor:_sharedUi.night.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyStateTitle:{fontSize:16,fontWeight:"600",color:_sharedUi.night.color.text,marginBottom:6},emptyStateDescription:{fontSize:14,color:_sharedUi.night.color.textSecondary,textAlign:"center",marginBottom:8},emptyStateHint:{fontSize:12,color:_sharedUi.night.color.textTertiary}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.UserSearchView=UserSearchView;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _UserCard=require("./UserCard");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(c,a){if("function"==typeof WeakMap)var n=new WeakMap,l=new WeakMap;return(_interopRequireWildcard=function(e,s){if(!s&&e&&e.__esModule)return e;var r,i,o={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return o;if(r=s?l:n){if(r.has(e))return r.get(e);r.set(e,o)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((i=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(i.get||i.set)?r(o,t,i):o[t]=e[t]);return o})(c,a)}function UserSearchView({currentUser:c,searchQuery:a,searchResults:n,isSearching:l,searchError:e,onSelectUser:s,onStopImpersonation:r,searchAvailable:i=true}){const o=(0,_react.useCallback)(({item:t})=>{const d=c?.id===t.id;return(0,_jsxRuntime.jsx)(_UserCard.UserCard,{user:t,isActive:d,onPress:()=>!d&&s(t),onStop:d?r:void 0})},[c,s,r]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[!i&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.section,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningCard,children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:18,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningTitle,children:"Search Not Available"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningText,children:"Configure the onSearchUsers callback to enable user search."})]})]})}),l&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.loadingContainer,children:[(0,_jsxRuntime.jsx)(_reactNative.ActivityIndicator,{size:"small",color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.loadingText,children:"Searching users..."})]}),e?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.section,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.errorCard,children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:16,color:_sharedUi.night.color.danger}),(0,_jsxRuntime.jsx)(_reactNative.Text,{testID:"buoy-impersonate-error",style:styles.errorText,children:e})]})}):null,n.length>0&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.resultsSection,children:[(0,_jsxRuntime.jsxs)(_sharedUi.SectionHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.SectionHeader.Title,{children:"Results"}),(0,_jsxRuntime.jsx)(_sharedUi.SectionHeader.Badge,{count:n.length})]}),(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",testID:"buoy-impersonate-search-scroll",data:n,keyExtractor:t=>t.id,renderItem:o,ItemSeparatorComponent:()=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.separator}),contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:false})]}),!!a&&!l&&n.length===0&&!e&&(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:"buoy-impersonate-no-results",style:styles.emptyStateContainer,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.emptyStateIcon,children:(0,_jsxRuntime.jsx)(_sharedUi.Users,{size:28,color:_sharedUi.night.color.textTertiary})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyStateTitle,children:"No users found"}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.emptyStateDescription,children:['No results for "',a,'"']}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyStateHint,children:"Try a different search term"})]}),!a&&n.length===0&&!l&&i&&(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"buoy-impersonate-search-empty",children:(0,_jsxRuntime.jsx)(_sharedUi.EmptyState,{title:"Search for users",description:"Tap the search icon in the header to find users by email, name, or ID",icon:_sharedUi.Search,variant:"minimal"})})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1},section:{padding:16,paddingBottom:8},loadingContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:10,paddingVertical:20},loadingText:{fontSize:13,color:_sharedUi.night.color.textSecondary},resultsSection:{flex:1,paddingHorizontal:16},listContent:{paddingBottom:16},separator:{height:8},warningCard:{flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:_sharedUi.night.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:14,fontWeight:"600",color:_sharedUi.night.color.warning,marginBottom:4},warningText:{fontSize:13,color:_sharedUi.night.color.textSecondary,lineHeight:18},errorCard:{flexDirection:"row",alignItems:"center",gap:10,backgroundColor:_sharedUi.night.color.dangerSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.danger+"25",padding:12},errorText:{flex:1,fontSize:13,color:_sharedUi.night.color.danger},emptyStateContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyStateIcon:{width:56,height:56,borderRadius:28,backgroundColor:_sharedUi.night.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyStateTitle:{fontSize:16,fontWeight:"600",color:_sharedUi.night.color.text,marginBottom:6},emptyStateDescription:{fontSize:14,color:_sharedUi.night.color.textSecondary,textAlign:"center",marginBottom:8},emptyStateHint:{fontSize:12,color:_sharedUi.night.color.textTertiary}});
@@ -7,4 +7,4 @@
7
7
  asyncStorage: ${r.asyncStorage},
8
8
  mmkv: ${r.mmkv},
9
9
  },
10
- },`;try{await te(l);L(true);setTimeout(()=>L(false),2e3)}catch{}};return n(X,{testID:"buoy-impersonate-settings-scroll",style:e.container,contentContainerStyle:e.contentContainer,children:[Q&&t(a,{style:e.actionBar,children:n(a,{style:e.actionBarContent,children:[t(c,{style:e.unsavedText,children:"Unsaved changes"}),n(a,{style:e.actionButtons,children:[n(p,{testID:"buoy-impersonate-discard",style:e.discardButton,onPress:N,children:[t(E,{size:14,color:o.color.textSecondary}),t(c,{style:e.discardButtonText,children:"Discard"})]}),n(p,{testID:"buoy-impersonate-save",style:e.saveButton,onPress:j,children:[t(R,{size:14,color:o.color.onAccent}),t(c,{style:e.saveButtonText,children:"Save"})]})]})]})}),t(m,{title:"Header Configuration",icon:Y,defaultOpen:true,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.inputLabel,children:"Header Key"}),t(q,{testID:"buoy-impersonate-header-key",style:e.input,value:i,onChangeText:g,placeholder:"x-impersonate-user-id",placeholderTextColor:o.color.placeholder,autoCapitalize:"none",autoCorrect:false}),n(a,{style:e.inputFooter,children:[t(c,{style:e.helperText,children:"The HTTP header key used for impersonation. Value will be the user ID."}),i!==x&&t(p,{onPress:()=>g(x),style:e.resetLink,children:t(c,{style:e.resetLinkText,children:"Reset to default"})})]})]})}),t(m,{title:"Display",icon:ee,defaultOpen:true,variant:"bordered",children:t(a,{style:e.sectionContent,children:t(a,{style:e.togglesCard,children:t(C,{label:"Floating Banner",description:"Show a floating banner when impersonation is active",value:y,onChange:l=>{v(l);T(l)},recommended:true,testID:"buoy-impersonate-show-banner"})})})}),t(m,{title:"Data Clearing",icon:V,defaultOpen:true,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.sectionDescription,children:"Choose what data to clear when impersonation starts or stops. This ensures you see fresh data for the impersonated user."}),n(a,{style:e.togglesCard,children:[t(C,{label:"React Query",description:"Clear query cache and cancel pending queries",value:r.reactQuery,onChange:l=>w("reactQuery",l),recommended:true,detected:u?.reactQuery}),t(a,{style:e.divider}),t(C,{label:"Redux",description:"Reset Redux store to initial state",value:r.redux,onChange:l=>w("redux",l),recommended:true,detected:u?.redux})]}),n(a,{style:e.advancedSection,children:[t(c,{style:e.advancedLabel,children:"Storage Options"}),n(a,{style:[e.togglesCard,e.dangerousCard],children:[t(C,{label:"AsyncStorage",description:"Clear app data (preserves @buoy/* keys)",value:r.asyncStorage,onChange:l=>w("asyncStorage",l),dangerous:true,detected:u?.asyncStorage}),t(a,{style:e.divider}),t(C,{label:"MMKV",description:"Clear MMKV storage (preserves @buoy/* keys)",value:r.mmkv,onChange:l=>w("mmkv",l),dangerous:true,detected:u?.mmkv})]})]}),(r.asyncStorage||r.mmkv)&&n(a,{style:e.warningCard,children:[t(V,{size:16,color:o.color.warning}),n(a,{style:e.warningContent,children:[t(c,{style:e.warningTitle,children:"Storage Clearing Enabled"}),t(c,{style:e.warningText,children:"This will remove app data like settings and cached content. Auth tokens managed by @buoy/* are preserved."})]})]})]})}),!_&&n(p,{testID:"buoy-impersonate-restore-defaults",style:e.restoreButton,onPress:O,children:[t(J,{size:14,color:o.color.textSecondary}),t(c,{style:e.restoreButtonText,children:"Restore Defaults"})]}),t(m,{title:"How It Works",icon:G,defaultOpen:false,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.infoText,children:"When impersonation is enabled, the configured header is automatically added to all outgoing fetch and XMLHttpRequest calls."}),t(c,{style:[e.infoText,e.infoTextSpaced],children:"Your backend should check for this header and return data for the specified user ID instead of the authenticated user."}),n(a,{style:e.codeBlock,children:[t(c,{style:e.codeComment,children:"// Example request header"}),n(c,{style:e.codeText,children:[i||"x-impersonate-user-id",": ",t(c,{style:e.codeValue,children:"user_123"})]})]})]})}),t(m,{title:"Export Configuration",icon:A,defaultOpen:false,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.infoText,children:"Copy current settings to use in createImpersonateTool()."}),t(a,{style:e.dataViewerContainer,children:t(re,{title:"",data:M,showTypeFilter:true,rawMode:true,initialExpanded:true})}),t(p,{style:e.copyButton,onPress:P,children:F?n(W,{children:[t(R,{size:14,color:f.success}),t(c,{style:[e.copyButtonText,e.copySuccessText],children:"Copied!"})]}):n(W,{children:[t(A,{size:14,color:o.color.accent}),t(c,{style:e.copyButtonText,children:"Copy Config"})]})})]})})]})}const e=K.create({container:{flex:1},contentContainer:{padding:16,gap:12,paddingBottom:32},actionBar:{backgroundColor:o.color.accentSoft,borderRadius:10,borderWidth:1,borderColor:o.color.accentBorder,padding:12},actionBarContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},unsavedText:{fontSize:13,fontWeight:"500",color:o.color.accent},actionButtons:{flexDirection:"row",gap:8},saveButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:o.color.accent,paddingHorizontal:14,paddingVertical:8,borderRadius:6},saveButtonText:{fontSize:13,fontWeight:"600",color:o.color.onAccent},discardButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:o.color.surfaceElevated,paddingHorizontal:14,paddingVertical:8,borderRadius:6,borderWidth:1,borderColor:o.color.border},discardButtonText:{fontSize:13,fontWeight:"500",color:o.color.textSecondary},restoreButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,paddingVertical:12,borderRadius:8,borderWidth:1,borderColor:o.color.border,borderStyle:"dashed"},restoreButtonText:{fontSize:13,color:o.color.textSecondary},sectionContent:{paddingTop:8},sectionDescription:{fontSize:13,color:o.color.textSecondary,lineHeight:18,marginBottom:14},togglesCard:{backgroundColor:o.color.surface,borderRadius:10,borderWidth:1,borderColor:o.color.border,padding:4},dangerousCard:{borderColor:o.color.warning+"30"},advancedSection:{marginTop:16},advancedLabel:{fontSize:11,fontWeight:"600",color:o.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8,marginLeft:2},inputLabel:{fontSize:12,fontWeight:"600",color:o.color.textSecondary,marginBottom:8},input:{height:42,backgroundColor:o.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:o.color.border,paddingHorizontal:14,fontSize:14,color:o.color.text,fontFamily:I},inputFooter:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start",marginTop:8,gap:12},helperText:{flex:1,fontSize:12,color:o.color.textTertiary,lineHeight:16},resetLink:{paddingVertical:2},resetLinkText:{fontSize:12,color:o.color.accent,fontWeight:"500"},recommendedBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:o.color.accentSoft,paddingHorizontal:8,paddingVertical:3,borderRadius:4},recommendedText:{fontSize:10,fontWeight:"600",color:o.color.accent},detectedBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4},detectedBadgeActive:{backgroundColor:f.success+"15"},detectedBadgeInactive:{backgroundColor:o.color.textTertiary+"15"},detectedText:{fontSize:10,fontWeight:"600"},detectedTextActive:{color:f.success},detectedTextInactive:{color:o.color.textTertiary},divider:{height:1,backgroundColor:o.color.separator,marginHorizontal:12},warningCard:{marginTop:14,flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:o.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:o.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:13,fontWeight:"600",color:o.color.warning,marginBottom:4},warningText:{fontSize:12,color:o.color.textSecondary,lineHeight:17},infoText:{fontSize:13,color:o.color.textSecondary,lineHeight:19},infoTextSpaced:{marginTop:10},codeBlock:{marginTop:14,backgroundColor:o.color.bg,borderRadius:8,padding:14},codeComment:{fontSize:12,color:o.color.textTertiary,fontFamily:I,marginBottom:6},codeText:{fontSize:13,color:o.color.text,fontFamily:I},codeValue:{color:o.color.accent},dataViewerContainer:{marginTop:12,borderRadius:8,overflow:"hidden",borderWidth:1,borderColor:o.color.border},copyButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,marginTop:14,backgroundColor:o.color.accentSoft,paddingVertical:10,paddingHorizontal:16,borderRadius:8,borderWidth:1,borderColor:o.color.accentBorder},copyButtonText:{fontSize:13,fontWeight:"600",color:o.color.accent},copySuccessText:{color:f.success}});
10
+ },`;try{await te(l);L(true);setTimeout(()=>L(false),2e3)}catch{}};return n(X,{keyboardShouldPersistTaps:"handled",testID:"buoy-impersonate-settings-scroll",style:e.container,contentContainerStyle:e.contentContainer,children:[Q&&t(a,{style:e.actionBar,children:n(a,{style:e.actionBarContent,children:[t(c,{style:e.unsavedText,children:"Unsaved changes"}),n(a,{style:e.actionButtons,children:[n(p,{testID:"buoy-impersonate-discard",style:e.discardButton,onPress:N,children:[t(E,{size:14,color:o.color.textSecondary}),t(c,{style:e.discardButtonText,children:"Discard"})]}),n(p,{testID:"buoy-impersonate-save",style:e.saveButton,onPress:j,children:[t(R,{size:14,color:o.color.onAccent}),t(c,{style:e.saveButtonText,children:"Save"})]})]})]})}),t(m,{title:"Header Configuration",icon:Y,defaultOpen:true,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.inputLabel,children:"Header Key"}),t(q,{testID:"buoy-impersonate-header-key",style:e.input,value:i,onChangeText:g,placeholder:"x-impersonate-user-id",placeholderTextColor:o.color.placeholder,autoCapitalize:"none",autoCorrect:false}),n(a,{style:e.inputFooter,children:[t(c,{style:e.helperText,children:"The HTTP header key used for impersonation. Value will be the user ID."}),i!==x&&t(p,{onPress:()=>g(x),style:e.resetLink,children:t(c,{style:e.resetLinkText,children:"Reset to default"})})]})]})}),t(m,{title:"Display",icon:ee,defaultOpen:true,variant:"bordered",children:t(a,{style:e.sectionContent,children:t(a,{style:e.togglesCard,children:t(C,{label:"Floating Banner",description:"Show a floating banner when impersonation is active",value:y,onChange:l=>{v(l);T(l)},recommended:true,testID:"buoy-impersonate-show-banner"})})})}),t(m,{title:"Data Clearing",icon:V,defaultOpen:true,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.sectionDescription,children:"Choose what data to clear when impersonation starts or stops. This ensures you see fresh data for the impersonated user."}),n(a,{style:e.togglesCard,children:[t(C,{label:"React Query",description:"Clear query cache and cancel pending queries",value:r.reactQuery,onChange:l=>w("reactQuery",l),recommended:true,detected:u?.reactQuery}),t(a,{style:e.divider}),t(C,{label:"Redux",description:"Reset Redux store to initial state",value:r.redux,onChange:l=>w("redux",l),recommended:true,detected:u?.redux})]}),n(a,{style:e.advancedSection,children:[t(c,{style:e.advancedLabel,children:"Storage Options"}),n(a,{style:[e.togglesCard,e.dangerousCard],children:[t(C,{label:"AsyncStorage",description:"Clear app data (preserves @buoy/* keys)",value:r.asyncStorage,onChange:l=>w("asyncStorage",l),dangerous:true,detected:u?.asyncStorage}),t(a,{style:e.divider}),t(C,{label:"MMKV",description:"Clear MMKV storage (preserves @buoy/* keys)",value:r.mmkv,onChange:l=>w("mmkv",l),dangerous:true,detected:u?.mmkv})]})]}),(r.asyncStorage||r.mmkv)&&n(a,{style:e.warningCard,children:[t(V,{size:16,color:o.color.warning}),n(a,{style:e.warningContent,children:[t(c,{style:e.warningTitle,children:"Storage Clearing Enabled"}),t(c,{style:e.warningText,children:"This will remove app data like settings and cached content. Auth tokens managed by @buoy/* are preserved."})]})]})]})}),!_&&n(p,{testID:"buoy-impersonate-restore-defaults",style:e.restoreButton,onPress:O,children:[t(J,{size:14,color:o.color.textSecondary}),t(c,{style:e.restoreButtonText,children:"Restore Defaults"})]}),t(m,{title:"How It Works",icon:G,defaultOpen:false,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.infoText,children:"When impersonation is enabled, the configured header is automatically added to all outgoing fetch and XMLHttpRequest calls."}),t(c,{style:[e.infoText,e.infoTextSpaced],children:"Your backend should check for this header and return data for the specified user ID instead of the authenticated user."}),n(a,{style:e.codeBlock,children:[t(c,{style:e.codeComment,children:"// Example request header"}),n(c,{style:e.codeText,children:[i||"x-impersonate-user-id",": ",t(c,{style:e.codeValue,children:"user_123"})]})]})]})}),t(m,{title:"Export Configuration",icon:A,defaultOpen:false,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.infoText,children:"Copy current settings to use in createImpersonateTool()."}),t(a,{style:e.dataViewerContainer,children:t(re,{title:"",data:M,showTypeFilter:true,rawMode:true,initialExpanded:true})}),t(p,{style:e.copyButton,onPress:P,children:F?n(W,{children:[t(R,{size:14,color:f.success}),t(c,{style:[e.copyButtonText,e.copySuccessText],children:"Copied!"})]}):n(W,{children:[t(A,{size:14,color:o.color.accent}),t(c,{style:e.copyButtonText,children:"Copy Config"})]})})]})})]})}const e=K.create({container:{flex:1},contentContainer:{padding:16,gap:12,paddingBottom:32},actionBar:{backgroundColor:o.color.accentSoft,borderRadius:10,borderWidth:1,borderColor:o.color.accentBorder,padding:12},actionBarContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},unsavedText:{fontSize:13,fontWeight:"500",color:o.color.accent},actionButtons:{flexDirection:"row",gap:8},saveButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:o.color.accent,paddingHorizontal:14,paddingVertical:8,borderRadius:6},saveButtonText:{fontSize:13,fontWeight:"600",color:o.color.onAccent},discardButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:o.color.surfaceElevated,paddingHorizontal:14,paddingVertical:8,borderRadius:6,borderWidth:1,borderColor:o.color.border},discardButtonText:{fontSize:13,fontWeight:"500",color:o.color.textSecondary},restoreButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,paddingVertical:12,borderRadius:8,borderWidth:1,borderColor:o.color.border,borderStyle:"dashed"},restoreButtonText:{fontSize:13,color:o.color.textSecondary},sectionContent:{paddingTop:8},sectionDescription:{fontSize:13,color:o.color.textSecondary,lineHeight:18,marginBottom:14},togglesCard:{backgroundColor:o.color.surface,borderRadius:10,borderWidth:1,borderColor:o.color.border,padding:4},dangerousCard:{borderColor:o.color.warning+"30"},advancedSection:{marginTop:16},advancedLabel:{fontSize:11,fontWeight:"600",color:o.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8,marginLeft:2},inputLabel:{fontSize:12,fontWeight:"600",color:o.color.textSecondary,marginBottom:8},input:{height:42,backgroundColor:o.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:o.color.border,paddingHorizontal:14,fontSize:14,color:o.color.text,fontFamily:I},inputFooter:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start",marginTop:8,gap:12},helperText:{flex:1,fontSize:12,color:o.color.textTertiary,lineHeight:16},resetLink:{paddingVertical:2},resetLinkText:{fontSize:12,color:o.color.accent,fontWeight:"500"},recommendedBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:o.color.accentSoft,paddingHorizontal:8,paddingVertical:3,borderRadius:4},recommendedText:{fontSize:10,fontWeight:"600",color:o.color.accent},detectedBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4},detectedBadgeActive:{backgroundColor:f.success+"15"},detectedBadgeInactive:{backgroundColor:o.color.textTertiary+"15"},detectedText:{fontSize:10,fontWeight:"600"},detectedTextActive:{color:f.success},detectedTextInactive:{color:o.color.textTertiary},divider:{height:1,backgroundColor:o.color.separator,marginHorizontal:12},warningCard:{marginTop:14,flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:o.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:o.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:13,fontWeight:"600",color:o.color.warning,marginBottom:4},warningText:{fontSize:12,color:o.color.textSecondary,lineHeight:17},infoText:{fontSize:13,color:o.color.textSecondary,lineHeight:19},infoTextSpaced:{marginTop:10},codeBlock:{marginTop:14,backgroundColor:o.color.bg,borderRadius:8,padding:14},codeComment:{fontSize:12,color:o.color.textTertiary,fontFamily:I,marginBottom:6},codeText:{fontSize:13,color:o.color.text,fontFamily:I},codeValue:{color:o.color.accent},dataViewerContainer:{marginTop:12,borderRadius:8,overflow:"hidden",borderWidth:1,borderColor:o.color.border},copyButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,marginTop:14,backgroundColor:o.color.accentSoft,paddingVertical:10,paddingHorizontal:16,borderRadius:8,borderWidth:1,borderColor:o.color.accentBorder},copyButtonText:{fontSize:13,fontWeight:"600",color:o.color.accent},copySuccessText:{color:f.success}});
@@ -1 +1 @@
1
- "use strict";import B,{useCallback as m}from"react";import{View as s,Text as p,TouchableOpacity as y,StyleSheet as f,FlatList as x}from"react-native";import{night as r,Trash2 as T,useRelativeTime as S,ToolEmptyState as C}from"@buoy-gg/shared-ui";import{UserCard as I}from"./UserCard";import{jsx as e,jsxs as h}from"react/jsx-runtime";function b({item:o,isActive:a,onSelect:l,onStop:c,onRemove:n,showRemoveButton:d}){const u=S(new Date(o.lastUsedAt));return e(I,{user:o.user,isActive:a,onPress:()=>!a&&l(o.user),onStop:a?c:void 0,onRemove:n,showRemoveButton:d,lastUsedTime:u})}export function ImpersonateHistoryList({history:o,currentUserId:a,onSelectUser:l,onStopImpersonation:c,onRemoveFromHistory:n,onClearHistory:d}){const u=m(({item:i})=>{const g=a===i.user.id;return e(b,{item:i,isActive:g,onSelect:l,onStop:c,onRemove:n?()=>n(i.user.id):void 0,showRemoveButton:!!n})},[a,l,c,n]);if(o.length===0){return e(C,{testID:"buoy-impersonate-history-empty",otto:"disguise",title:"No History",message:"Users you impersonate will appear here for quick access"})}return h(s,{style:t.container,children:[h(s,{style:t.headerRow,children:[e(p,{style:t.headerTitle,children:"Recent"}),e(s,{style:t.headerBadge,children:e(p,{style:t.headerBadgeText,children:o.length})}),e(s,{style:t.headerSpacer}),d&&e(y,{testID:"buoy-impersonate-clear-history",style:t.clearButton,onPress:d,activeOpacity:.7,children:e(T,{size:12,color:r.color.textTertiary})})]}),e(x,{testID:"buoy-impersonate-history-scroll",data:o,keyExtractor:i=>i.user.id,renderItem:u,ItemSeparatorComponent:()=>e(s,{style:t.separator}),contentContainerStyle:t.listContent,showsVerticalScrollIndicator:false})]})}const t=f.create({container:{flex:1,paddingHorizontal:16},headerRow:{flexDirection:"row",alignItems:"center",paddingVertical:10,gap:8},headerTitle:{fontSize:12,fontWeight:"600",color:r.color.textTertiary,textTransform:"uppercase",letterSpacing:.5},headerBadge:{backgroundColor:r.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},headerBadgeText:{fontSize:10,fontWeight:"600",color:r.color.textTertiary},headerSpacer:{flex:1},clearButton:{width:24,height:24,alignItems:"center",justifyContent:"center",backgroundColor:r.color.surfaceElevated,borderRadius:4},listContent:{paddingBottom:20},separator:{height:8},emptyContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyIcon:{width:56,height:56,borderRadius:28,backgroundColor:r.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyTitle:{fontSize:16,fontWeight:"600",color:r.color.text,marginBottom:6},emptyDescription:{fontSize:14,color:r.color.textSecondary,textAlign:"center"}});
1
+ "use strict";import B,{useCallback as m}from"react";import{View as s,Text as h,TouchableOpacity as y,StyleSheet as f,FlatList as x}from"react-native";import{night as r,Trash2 as T,useRelativeTime as S,ToolEmptyState as C}from"@buoy-gg/shared-ui";import{UserCard as b}from"./UserCard";import{jsx as e,jsxs as p}from"react/jsx-runtime";function I({item:o,isActive:a,onSelect:l,onStop:c,onRemove:n,showRemoveButton:d}){const u=S(new Date(o.lastUsedAt));return e(b,{user:o.user,isActive:a,onPress:()=>!a&&l(o.user),onStop:a?c:void 0,onRemove:n,showRemoveButton:d,lastUsedTime:u})}export function ImpersonateHistoryList({history:o,currentUserId:a,onSelectUser:l,onStopImpersonation:c,onRemoveFromHistory:n,onClearHistory:d}){const u=m(({item:i})=>{const g=a===i.user.id;return e(I,{item:i,isActive:g,onSelect:l,onStop:c,onRemove:n?()=>n(i.user.id):void 0,showRemoveButton:!!n})},[a,l,c,n]);if(o.length===0){return e(C,{testID:"buoy-impersonate-history-empty",otto:"disguise",title:"No History",message:"Users you impersonate will appear here for quick access"})}return p(s,{style:t.container,children:[p(s,{style:t.headerRow,children:[e(h,{style:t.headerTitle,children:"Recent"}),e(s,{style:t.headerBadge,children:e(h,{style:t.headerBadgeText,children:o.length})}),e(s,{style:t.headerSpacer}),d&&e(y,{testID:"buoy-impersonate-clear-history",style:t.clearButton,onPress:d,activeOpacity:.7,children:e(T,{size:12,color:r.color.textTertiary})})]}),e(x,{keyboardShouldPersistTaps:"handled",testID:"buoy-impersonate-history-scroll",data:o,keyExtractor:i=>i.user.id,renderItem:u,ItemSeparatorComponent:()=>e(s,{style:t.separator}),contentContainerStyle:t.listContent,showsVerticalScrollIndicator:false})]})}const t=f.create({container:{flex:1,paddingHorizontal:16},headerRow:{flexDirection:"row",alignItems:"center",paddingVertical:10,gap:8},headerTitle:{fontSize:12,fontWeight:"600",color:r.color.textTertiary,textTransform:"uppercase",letterSpacing:.5},headerBadge:{backgroundColor:r.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},headerBadgeText:{fontSize:10,fontWeight:"600",color:r.color.textTertiary},headerSpacer:{flex:1},clearButton:{width:24,height:24,alignItems:"center",justifyContent:"center",backgroundColor:r.color.surfaceElevated,borderRadius:4},listContent:{paddingBottom:20},separator:{height:8},emptyContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyIcon:{width:56,height:56,borderRadius:28,backgroundColor:r.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyTitle:{fontSize:16,fontWeight:"600",color:r.color.text,marginBottom:6},emptyDescription:{fontSize:14,color:r.color.textSecondary,textAlign:"center"}});
@@ -1 +1 @@
1
- "use strict";import B,{useCallback as x}from"react";import{View as o,Text as i,StyleSheet as C,FlatList as w,ActivityIndicator as b}from"react-native";import{SectionHeader as m,EmptyState as T,night as r,Search as I,AlertTriangle as S,Users as z}from"@buoy-gg/shared-ui";import{UserCard as D}from"./UserCard";import{jsx as e,jsxs as n}from"react/jsx-runtime";export function UserSearchView({currentUser:y,searchQuery:c,searchResults:l,isSearching:s,searchError:d,onSelectUser:h,onStopImpersonation:p,searchAvailable:f=true}){const u=x(({item:a})=>{const g=y?.id===a.id;return e(D,{user:a,isActive:g,onPress:()=>!g&&h(a),onStop:g?p:void 0})},[y,h,p]);return n(o,{style:t.container,children:[!f&&e(o,{style:t.section,children:n(o,{style:t.warningCard,children:[e(S,{size:18,color:r.color.warning}),n(o,{style:t.warningContent,children:[e(i,{style:t.warningTitle,children:"Search Not Available"}),e(i,{style:t.warningText,children:"Configure the onSearchUsers callback to enable user search."})]})]})}),s&&n(o,{style:t.loadingContainer,children:[e(b,{size:"small",color:r.color.accent}),e(i,{style:t.loadingText,children:"Searching users..."})]}),d?e(o,{style:t.section,children:n(o,{style:t.errorCard,children:[e(S,{size:16,color:r.color.danger}),e(i,{testID:"buoy-impersonate-error",style:t.errorText,children:d})]})}):null,l.length>0&&n(o,{style:t.resultsSection,children:[n(m,{children:[e(m.Title,{children:"Results"}),e(m.Badge,{count:l.length})]}),e(w,{testID:"buoy-impersonate-search-scroll",data:l,keyExtractor:a=>a.id,renderItem:u,ItemSeparatorComponent:()=>e(o,{style:t.separator}),contentContainerStyle:t.listContent,showsVerticalScrollIndicator:false})]}),!!c&&!s&&l.length===0&&!d&&n(o,{testID:"buoy-impersonate-no-results",style:t.emptyStateContainer,children:[e(o,{style:t.emptyStateIcon,children:e(z,{size:28,color:r.color.textTertiary})}),e(i,{style:t.emptyStateTitle,children:"No users found"}),n(i,{style:t.emptyStateDescription,children:['No results for "',c,'"']}),e(i,{style:t.emptyStateHint,children:"Try a different search term"})]}),!c&&l.length===0&&!s&&f&&e(o,{testID:"buoy-impersonate-search-empty",children:e(T,{title:"Search for users",description:"Tap the search icon in the header to find users by email, name, or ID",icon:I,variant:"minimal"})})]})}const t=C.create({container:{flex:1},section:{padding:16,paddingBottom:8},loadingContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:10,paddingVertical:20},loadingText:{fontSize:13,color:r.color.textSecondary},resultsSection:{flex:1,paddingHorizontal:16},listContent:{paddingBottom:16},separator:{height:8},warningCard:{flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:r.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:r.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:14,fontWeight:"600",color:r.color.warning,marginBottom:4},warningText:{fontSize:13,color:r.color.textSecondary,lineHeight:18},errorCard:{flexDirection:"row",alignItems:"center",gap:10,backgroundColor:r.color.dangerSoft,borderRadius:10,borderWidth:1,borderColor:r.color.danger+"25",padding:12},errorText:{flex:1,fontSize:13,color:r.color.danger},emptyStateContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyStateIcon:{width:56,height:56,borderRadius:28,backgroundColor:r.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyStateTitle:{fontSize:16,fontWeight:"600",color:r.color.text,marginBottom:6},emptyStateDescription:{fontSize:14,color:r.color.textSecondary,textAlign:"center",marginBottom:8},emptyStateHint:{fontSize:12,color:r.color.textTertiary}});
1
+ "use strict";import k,{useCallback as x}from"react";import{View as o,Text as i,StyleSheet as C,FlatList as b,ActivityIndicator as w}from"react-native";import{SectionHeader as m,EmptyState as T,night as r,Search as I,AlertTriangle as S,Users as z}from"@buoy-gg/shared-ui";import{UserCard as D}from"./UserCard";import{jsx as e,jsxs as n}from"react/jsx-runtime";export function UserSearchView({currentUser:y,searchQuery:c,searchResults:l,isSearching:s,searchError:d,onSelectUser:h,onStopImpersonation:p,searchAvailable:f=true}){const u=x(({item:a})=>{const g=y?.id===a.id;return e(D,{user:a,isActive:g,onPress:()=>!g&&h(a),onStop:g?p:void 0})},[y,h,p]);return n(o,{style:t.container,children:[!f&&e(o,{style:t.section,children:n(o,{style:t.warningCard,children:[e(S,{size:18,color:r.color.warning}),n(o,{style:t.warningContent,children:[e(i,{style:t.warningTitle,children:"Search Not Available"}),e(i,{style:t.warningText,children:"Configure the onSearchUsers callback to enable user search."})]})]})}),s&&n(o,{style:t.loadingContainer,children:[e(w,{size:"small",color:r.color.accent}),e(i,{style:t.loadingText,children:"Searching users..."})]}),d?e(o,{style:t.section,children:n(o,{style:t.errorCard,children:[e(S,{size:16,color:r.color.danger}),e(i,{testID:"buoy-impersonate-error",style:t.errorText,children:d})]})}):null,l.length>0&&n(o,{style:t.resultsSection,children:[n(m,{children:[e(m.Title,{children:"Results"}),e(m.Badge,{count:l.length})]}),e(b,{keyboardShouldPersistTaps:"handled",testID:"buoy-impersonate-search-scroll",data:l,keyExtractor:a=>a.id,renderItem:u,ItemSeparatorComponent:()=>e(o,{style:t.separator}),contentContainerStyle:t.listContent,showsVerticalScrollIndicator:false})]}),!!c&&!s&&l.length===0&&!d&&n(o,{testID:"buoy-impersonate-no-results",style:t.emptyStateContainer,children:[e(o,{style:t.emptyStateIcon,children:e(z,{size:28,color:r.color.textTertiary})}),e(i,{style:t.emptyStateTitle,children:"No users found"}),n(i,{style:t.emptyStateDescription,children:['No results for "',c,'"']}),e(i,{style:t.emptyStateHint,children:"Try a different search term"})]}),!c&&l.length===0&&!s&&f&&e(o,{testID:"buoy-impersonate-search-empty",children:e(T,{title:"Search for users",description:"Tap the search icon in the header to find users by email, name, or ID",icon:I,variant:"minimal"})})]})}const t=C.create({container:{flex:1},section:{padding:16,paddingBottom:8},loadingContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:10,paddingVertical:20},loadingText:{fontSize:13,color:r.color.textSecondary},resultsSection:{flex:1,paddingHorizontal:16},listContent:{paddingBottom:16},separator:{height:8},warningCard:{flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:r.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:r.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:14,fontWeight:"600",color:r.color.warning,marginBottom:4},warningText:{fontSize:13,color:r.color.textSecondary,lineHeight:18},errorCard:{flexDirection:"row",alignItems:"center",gap:10,backgroundColor:r.color.dangerSoft,borderRadius:10,borderWidth:1,borderColor:r.color.danger+"25",padding:12},errorText:{flex:1,fontSize:13,color:r.color.danger},emptyStateContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyStateIcon:{width:56,height:56,borderRadius:28,backgroundColor:r.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyStateTitle:{fontSize:16,fontWeight:"600",color:r.color.text,marginBottom:6},emptyStateDescription:{fontSize:14,color:r.color.textSecondary,textAlign:"center",marginBottom:8},emptyStateHint:{fontSize:12,color:r.color.textTertiary}});
package/lib/web/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- "use client";var st=Object.defineProperty;var br=Object.getOwnPropertyDescriptor;var Sr=Object.getOwnPropertyNames;var vr=Object.prototype.hasOwnProperty;var wr=(e,t)=>{for(var r in t)st(e,r,{get:t[r],enumerable:true})},it=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Sr(t))!vr.call(e,o)&&o!==r&&st(e,o,{get:()=>t[o],enumerable:!(n=br(t,o))||n.enumerable});return e},xr=(e,t,r)=>(it(e,t,"default"),r&&it(r,t,"default"));var ca=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import lt from"@buoy-gg/shared-ui/web/asyncStorage";import{getCapacitorAppStorage as Cr}from"@buoy-gg/shared-ui/web";function Ir(){return lt}function kr(){return Cr()??lt}import{useState as ke,useCallback as oe,useRef as ct,useEffect as dt}from"react";var ut={};wr(ut,{AccessibilityInfo:()=>Ar,ActivityIndicator:()=>St,Alert:()=>Do,Animated:()=>ko,AppRegistry:()=>Pr,AppState:()=>Er,Appearance:()=>Hr,BackHandler:()=>Dr,Button:()=>Po,CheckBox:()=>_r,Clipboard:()=>zr,DeviceEventEmitter:()=>uo,Dimensions:()=>Lr,Easing:()=>Nr,FlatList:()=>Te,I18nManager:()=>Ur,Image:()=>Yr,ImageBackground:()=>Jr,InteractionManager:()=>Kr,Keyboard:()=>Or,KeyboardAvoidingView:()=>Gr,LayoutAnimation:()=>Wr,Linking:()=>jr,LogBox:()=>co,Modal:()=>Ao,NativeEventEmitter:()=>Fr,NativeModules:()=>Rr,PanResponder:()=>Mr,Picker:()=>Zr,PixelRatio:()=>Vr,Platform:()=>$r,Pressable:()=>Ro,ProgressBar:()=>eo,RefreshControl:()=>to,SafeAreaView:()=>ro,ScrollView:()=>ft,SectionList:()=>oo,Share:()=>Xr,StatusBar:()=>no,StyleSheet:()=>j,Switch:()=>Ho,Text:()=>y,TextInput:()=>yt,Touchable:()=>ao,TouchableHighlight:()=>To,TouchableNativeFeedback:()=>so,TouchableOpacity:()=>H,TouchableWithoutFeedback:()=>Bo,UIManager:()=>Qr,Vibration:()=>qr,View:()=>d,VirtualizedList:()=>io,YellowBox:()=>lo,findNodeHandle:()=>Eo,unstable_createElement:()=>Br,useColorScheme:()=>ho,useLocaleContext:()=>po,useWindowDimensions:()=>go});xr(ut,Tr);import*as Tr from"react-native-web";import{unstable_createElement as Br,NativeModules as Rr,AccessibilityInfo as Ar,Appearance as Hr,AppRegistry as Pr,AppState as Er,BackHandler as Dr,Clipboard as zr,Dimensions as Lr,Easing as Nr,I18nManager as Ur,Keyboard as Or,InteractionManager as Kr,LayoutAnimation as Wr,Linking as jr,NativeEventEmitter as Fr,PanResponder as Mr,PixelRatio as Vr,Platform as $r,Share as Xr,UIManager as Qr,Vibration as qr,CheckBox as _r,FlatList as Te,Image as Yr,ImageBackground as Jr,KeyboardAvoidingView as Gr,Picker as Zr,ProgressBar as eo,RefreshControl as to,SafeAreaView as ro,SectionList as oo,StatusBar as no,Touchable as ao,TouchableNativeFeedback as so,VirtualizedList as io,YellowBox as lo,LogBox as co,DeviceEventEmitter as uo,useColorScheme as ho,useLocaleContext as po,useWindowDimensions as go}from"react-native-web";import*as E from"react-native-web";import{createElement as Be,forwardRef as ht,useCallback as mo,useRef as yo}from"react";import{useEffect as fo,useState as bo}from"react";import{createPortal as So}from"react-dom";var vo='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as wo}from"react/jsx-runtime";var ne=Symbol.for("@buoy-gg/portal-host"),pt=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 gt(){let e=document;if(e[ne])return e[ne].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:vo});let r=()=>{let s=document.fullscreenElement,f=s&&s.tagName!=="CANVAS"?s:document.body;t.parentElement!==f&&f.appendChild(t)},n=new Map,o=s=>{(!t.contains(s.target)||!pt(s.target))&&n.set(s.code||s.key,{key:s.key,code:s.code,location:s.location,keyCode:s.keyCode,which:s.which,altKey:s.altKey,ctrlKey:s.ctrlKey,metaKey:s.metaKey,shiftKey:s.shiftKey})},i=s=>{n.delete(s.code||s.key)},l=()=>n.clear(),p=()=>{let s=[...n.values()];n.clear();for(let f of s)document.dispatchEvent(new KeyboardEvent("keyup",{...f,bubbles:true}))},a=s=>{pt(s.target)&&s.stopPropagation()},c=s=>s.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",o,true),document.addEventListener("keyup",i,true),window.addEventListener("blur",l),t.addEventListener("focusin",p),t.addEventListener("keydown",a),t.addEventListener("keyup",a),t.addEventListener("keypress",a),t.addEventListener("wheel",c,{passive:true}),e[ne]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",o,true),document.removeEventListener("keyup",i,true),window.removeEventListener("blur",l),t.remove(),delete e[ne]}},t}function xo({children:e}){let[t,r]=bo(null);return fo(()=>{let n=gt(),o=document[ne];return o.users++,r(n),()=>{--o.users===0&&o.dispose()}},[]),t?So(wo("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var Z=E,Co=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],ee=e=>typeof e=="number"?`${e}px`:e;function Re(e){if(Array.isArray(e)){let f=e.map(Re);return f.some((S,b)=>S!==e[b])?f:e}if(!e||typeof e!="object"||!Co.some(f=>e[f]!=null))return e;let{shadowColor:t,shadowOffset:r,shadowOpacity:n,shadowRadius:o,textShadowColor:i,textShadowOffset:l,textShadowRadius:p,...a}=e;if(t!=null||r!=null||n!=null||o!=null){let f=t??"black",S=n==null?f:`color-mix(in srgb, ${f} ${Math.min(n,1)*100}%, transparent)`,b=`${ee(r?.width??0)} ${ee(r?.height??0)} ${ee(o??0)} ${S}`;a.boxShadow=typeof a.boxShadow=="string"?`${a.boxShadow}, ${b}`:a.boxShadow??b}let{width:c=0,height:s=0}=l??{};if(i&&(c||s||p)){let f=`${ee(c)} ${ee(s)} ${ee(p??0)} ${i}`;a.textShadow=a.textShadow?`${a.textShadow}, ${f}`:f}return a}var Io=Z.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function mt(e,t){if(typeof e=="function")return n=>mt(e(n),t);let r=Re(e);return t?[r,Io[t]]:r}var j={...Z.StyleSheet,create:e=>Z.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Re(r)])))};function L(e){let t=ht((n,o)=>{let{accessibilityState:i,accessibilityValue:l,pointerEvents:p,...a}=n;for(let s of["busy","checked","disabled","expanded","selected"])i?.[s]!==void 0&&a[`aria-${s}`]===void 0&&(a[`aria-${s}`]=i[s]);for(let[s,f]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))l?.[s]!==void 0&&a[`aria-${f}`]===void 0&&(a[`aria-${f}`]=l[s]);let c=mt(a.style,p);return c!==a.style&&(a.style=c),Be(e,{...a,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var d=L(E.View),y=L(E.Text),ko={...Z.Animated,View:Z.Animated.createAnimatedComponent(d),Text:Z.Animated.createAnimatedComponent(y)},yt=L(E.TextInput),H=L(E.TouchableOpacity),To=L(E.TouchableHighlight),Bo=L(E.TouchableWithoutFeedback),Ro=L(E.Pressable),ft=L(E.ScrollView),bt=ht((e,t)=>{let r=yo(null),n=mo(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"}),gt().appendChild(i))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(o):t&&(t.current=o)},[t]);return Be(xo,null,Be(E.Modal,{...e,ref:n}))});bt.displayName="Modal";var Ao=L(bt),Ho=L(E.Switch),St=L(E.ActivityIndicator),Po=L(E.Button),Eo=E.findNodeHandle,Do={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 l=document.createElement("div");l.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let p=r?.length?r:[{text:"OK"}],a=()=>{o.close?.(),o.remove()};for(let c of p){let s=document.createElement("button");s.type="button",s.textContent=c.text??"OK",s.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${c.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,s.onclick=()=>{a(),c.onPress?.()},l.appendChild(s)}o.addEventListener("cancel",c=>{c.preventDefault(),n?.cancelable!==false&&(a(),n?.onDismiss?.())}),o.appendChild(l),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{JsModal as zo,TabSelector as Lo,ModalHeader as ae,buoyColors as No,night as vt,Search as Uo,TickProvider as wt,windowDragProps as Oo}from"@buoy-gg/shared-ui/web";import{useState as fe,useEffect as xt,useCallback as N,useSyncExternalStore as Ko}from"react";import{assertAccountAccess as Ct,getAccountAccess as Wo,hasAccountAccess as jo,subscribeAccountAccess as Fo}from"@buoy-gg/shared-ui/web";var It=[/\/symbolicate$/,/\/logs$/,/\/debugger-proxy/,/\/reload$/,/\/launch-js-devtools/,/localhost:8081/,/100\.64\.\d+\.\d+:8081/,/10\.0\.\d+\.\d+:8081/,/\.hot-update\./,/__metro/];function Ae(e,t){for(let r of Object.keys(t))r.startsWith("__buoy")&&(e[r]=t[r])}var Mo=class{constructor(){this.isListeningFlag=false;this.patchedFetch=null;this.patchedXHROpen=null;this.patchedXHRSend=null;this.reportHeader=e=>this.shouldInjectHeader(e)?{[this.config.headerKey]:this.config.userId}:null;this.originalFetch=globalThis.fetch.bind(globalThis),this.originalXHROpen=XMLHttpRequest.prototype.open,this.originalXHRSend=XMLHttpRequest.prototype.send,this.config={headerKey:"x-impersonate-user-id",userId:null,ignorePatterns:[...It]}}setConfig(e){this.config={...this.config,...e},e.ignorePatterns&&(this.config.ignorePatterns=[...It,...e.ignorePatterns])}getConfig(){return{...this.config}}shouldInjectHeader(e){return!this.config.userId||this.config.gate&&!this.config.gate()?false:!this.config.ignorePatterns.some(t=>t.test(e))}extractUrl(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}startListening(){if(this.isListeningFlag)return;let e=globalThis.fetch,t=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send;this.originalFetch=e.bind(globalThis),this.originalXHROpen=t,this.originalXHRSend=r;let n=this,o=async function(c,s){let f=n.extractUrl(c);if(n.shouldInjectHeader(f)){let S=s?.headers??(typeof c=="object"&&"headers"in c?c.headers:void 0),b=new Headers(S);return b.set(n.config.headerKey,n.config.userId),n.originalFetch(c,{...s,headers:b})}return n.originalFetch(c,s)};Ae(o,e),this.patchedFetch=o,globalThis.fetch=this.patchedFetch;let i=function(c,s,f=true,S,b){let C=this;C._impersonateUrl=typeof s=="string"?s:s.href;let I=typeof s=="string"?s:s.toString();return n.originalXHROpen.call(this,c,I,f,S,b)},l=function(c){let s=this;return s._impersonateUrl&&n.shouldInjectHeader(s._impersonateUrl)&&this.setRequestHeader(n.config.headerKey,n.config.userId),n.originalXHRSend.call(this,c)};Ae(i,t),Ae(l,r),this.patchedXHROpen=i,this.patchedXHRSend=l,XMLHttpRequest.prototype.open=this.patchedXHROpen,XMLHttpRequest.prototype.send=this.patchedXHRSend;let p=globalThis,a=p.__buoyHeaderInjectors??(p.__buoyHeaderInjectors=[]);a.includes(this.reportHeader)||a.push(this.reportHeader),this.isListeningFlag=true}stopListening(){if(!this.isListeningFlag)return;this.patchedFetch&&globalThis.fetch===this.patchedFetch&&(globalThis.fetch=this.originalFetch),this.patchedXHROpen&&XMLHttpRequest.prototype.open===this.patchedXHROpen&&(XMLHttpRequest.prototype.open=this.originalXHROpen),this.patchedXHRSend&&XMLHttpRequest.prototype.send===this.patchedXHRSend&&(XMLHttpRequest.prototype.send=this.originalXHRSend),this.patchedFetch=null,this.patchedXHROpen=null,this.patchedXHRSend=null;let e=globalThis.__buoyHeaderInjectors,t=e?.indexOf(this.reportHeader)??-1;e&&t>=0&&e.splice(t,1),this.isListeningFlag=false}get isListening(){return this.isListeningFlag}get isImpersonating(){return this.config.userId!==null&&(this.config.gate?.()??true)}},se=null;function O(){return se||(se=new Mo),se}function Vo(){O().startListening()}function $o(){O().stopListening()}function kt(e){O().setConfig(e)}function Xo(){return se?.isImpersonating??false}function Qo(){return se?.getConfig().userId??null}var ie="@buoy/impersonate/state",qo=10,Tt={reactQuery:true,redux:true,asyncStorage:false,mmkv:false},te={isActive:false,isPaused:false,currentUser:null,headerKey:"x-impersonate-user-id",ignorePatterns:[],dataNukeSettings:Tt,showBanner:true,history:[]},He=false,Bt={getItem:e=>{try{return typeof localStorage<"u"?localStorage.getItem(e):null}catch{return null}},setItem:(e,t)=>{try{typeof localStorage<"u"&&localStorage.setItem(e,t)}catch{}},removeItem:e=>{try{typeof localStorage<"u"&&localStorage.removeItem(e)}catch{}}},_o=class{constructor(){this.state={...te};this.listeners=new Set;this.nukeCallbacks={};this.isInitialized=false;this.asyncStorageRef=null;this.storageReadyPromise=null;this.resolveStorageReady=null;this.developerDefaults=null;this.getSnapshot=()=>this.state;this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));this.remoteHandler=null;this.loadFromStorage(),Promise.resolve().then(()=>{let e=false,t=()=>{let r=Wo().status;r==="admitted"?e=true:r==="locked"&&e&&(e=false,this.disposeAccountSession())};Fo(t),t()}),typeof localStorage<"u"?this.storageReadyPromise=Promise.resolve():this.storageReadyPromise=new Promise(e=>{this.resolveStorageReady=e})}loadFromStorage(){try{let e=Bt.getItem(ie),t=this.getEffectiveDefaults();if(e){let r=JSON.parse(e);this.state={...te,headerKey:r.headerKey??t.headerKey,ignorePatterns:r.ignorePatterns??te.ignorePatterns,dataNukeSettings:{...t.dataNukeSettings,...r.dataNukeSettings},showBanner:r.showBanner??t.showBanner,history:r.history??[],isActive:r.isActive??false,isPaused:r.isPaused??false,currentUser:r.currentUser??null},this.state.isActive&&this.state.currentUser&&this.syncWithListener()}else this.state={...te,headerKey:t.headerKey,dataNukeSettings:t.dataNukeSettings,showBanner:t.showBanner};this.isInitialized=true}catch{this.isInitialized=true}}setAsyncStorage(e){this.asyncStorageRef=e,this.resolveStorageReady&&(this.resolveStorageReady(),this.resolveStorageReady=null)}setDeveloperDefaults(e){this.developerDefaults=e;let t=this.getEffectiveDefaults();this.isInitialized||(this.state={...this.state,headerKey:t.headerKey,dataNukeSettings:t.dataNukeSettings,showBanner:t.showBanner})}getEffectiveDefaults(){return{headerKey:this.developerDefaults?.headerKey??te.headerKey,dataNukeSettings:{...Tt,...this.developerDefaults?.dataNukeSettings},showBanner:this.developerDefaults?.showBanner??te.showBanner}}getDeveloperDefaults(){return this.developerDefaults}async initializeAsync(e){if(e){this.asyncStorageRef=e;try{let t=await e.getItem(ie);if(console.log("[Buoy]",`[impersonate] initializeAsync read STORAGE_KEY=${ie} stored=${t?t.slice(0,200):"null"}`),t){let r=JSON.parse(t);this.state={...this.state,headerKey:r.headerKey??this.state.headerKey,ignorePatterns:r.ignorePatterns??this.state.ignorePatterns,dataNukeSettings:{...this.state.dataNukeSettings,...r.dataNukeSettings},showBanner:r.showBanner??this.state.showBanner,history:r.history??this.state.history,isActive:r.isActive??this.state.isActive,isPaused:r.isPaused??this.state.isPaused,currentUser:r.currentUser??this.state.currentUser},this.state.isActive&&this.state.currentUser&&this.syncWithListener(),this.notify()}}catch{}}}registerNukeCallbacks(e){this.nukeCallbacks={...this.nukeCallbacks,...e}}getState(){return{...this.state}}setRemoteHandler(e){this.remoteHandler=e}replaceState(e){this.state=e,this.notify()}async startImpersonation(e){if(Ct(),this.remoteHandler){this.remoteHandler("startImpersonation",{user:e});return}let t=[{user:e,lastUsedAt:new Date().toISOString()},...this.state.history.filter(r=>r.user.id!==e.id)].slice(0,qo);this.state={...this.state,isActive:true,currentUser:e,history:t},this.syncWithListener(),this.notify(),await this.executeDataNuke(),await this.persist()}async stopImpersonation(){if(this.remoteHandler){this.remoteHandler("stopImpersonation");return}console.log("[Buoy]",`[impersonate] stopImpersonation: isActive ${this.state.isActive} -> false, listeners=${this.listeners.size}`),this.state={...this.state,isActive:false,isPaused:false,currentUser:null},this.syncWithListener(),this.notify(),await this.executeDataNuke(),await this.persist()}async pauseImpersonation(){if(this.remoteHandler){this.remoteHandler("pauseImpersonation");return}!this.state.isActive||this.state.isPaused||(this.state={...this.state,isPaused:true},this.syncWithListener(),await this.persist(),this.notify())}async resumeImpersonation(){if(Ct(),this.remoteHandler){this.remoteHandler("resumeImpersonation");return}!this.state.isActive||!this.state.isPaused||(this.state={...this.state,isPaused:false},this.syncWithListener(),await this.persist(),this.notify())}async quickSwitch(e){return this.startImpersonation(e)}async updateSettings(e){if(this.remoteHandler){this.remoteHandler("updateSettings",{settings:e});return}this.state={...this.state,headerKey:e.headerKey??this.state.headerKey,ignorePatterns:e.ignorePatterns??this.state.ignorePatterns,showBanner:e.showBanner??this.state.showBanner,dataNukeSettings:e.dataNukeSettings?{...this.state.dataNukeSettings,...e.dataNukeSettings}:this.state.dataNukeSettings},(e.headerKey||e.ignorePatterns)&&this.syncWithListener(),await this.persist(),this.notify()}async removeFromHistory(e){if(this.remoteHandler){this.remoteHandler("removeFromHistory",{userId:e});return}this.state={...this.state,history:this.state.history.filter(t=>t.user.id!==e)},await this.persist(),this.notify()}async clearHistory(){if(this.remoteHandler){this.remoteHandler("clearHistory");return}this.state={...this.state,history:[]},await this.persist(),this.notify()}async executeDataNuke(){if(!He){He=true;try{let{dataNukeSettings:e}=this.state,t=[];e.reactQuery&&this.nukeCallbacks.reactQuery&&t.push(Promise.resolve(this.nukeCallbacks.reactQuery())),e.redux&&this.nukeCallbacks.redux&&t.push(Promise.resolve(this.nukeCallbacks.redux())),e.asyncStorage&&this.nukeCallbacks.asyncStorage&&t.push(Promise.resolve(this.nukeCallbacks.asyncStorage())),e.mmkv&&this.nukeCallbacks.mmkv&&t.push(Promise.resolve(this.nukeCallbacks.mmkv())),await Promise.allSettled(t)}finally{setTimeout(()=>{He=false},100)}}}disposeAccountSession(){this.remoteHandler||!this.state.isActive||(this.state={...this.state,isActive:false,isPaused:false,currentUser:null},this.syncWithListener(),this.notify(),this.persist())}syncWithListener(){let e=this.state.isActive&&!this.state.isPaused;kt({headerKey:this.state.headerKey,userId:e?this.state.currentUser?.id??null:null,ignorePatterns:this.state.ignorePatterns.map(t=>new RegExp(t)),gate:jo}),O().isListening||O().startListening()}async persist(){this.storageReadyPromise&&await this.storageReadyPromise;let e={headerKey:this.state.headerKey,ignorePatterns:this.state.ignorePatterns,dataNukeSettings:this.state.dataNukeSettings,showBanner:this.state.showBanner,history:this.state.history,isActive:this.state.isActive,isPaused:this.state.isPaused,currentUser:this.state.currentUser},t=JSON.stringify(e);try{this.asyncStorageRef?(await this.asyncStorageRef.setItem(ie,t),console.log("[Buoy]",`[impersonate] persist -> AsyncStorage isActive=${e.isActive} userId=${e.currentUser?.id??"null"}`)):(Bt.setItem(ie,t),console.log("[Buoy]",`[impersonate] persist -> localStorage isActive=${e.isActive} userId=${e.currentUser?.id??"null"}`))}catch(r){console.warn("[Buoy]","[impersonate] persist failed",r)}}notify(){this.listeners.forEach(e=>{try{e(this.state)}catch{}})}},g=new _o;function Rt(e={}){let[t,r]=fe(""),[n,o]=fe([]),[i,l]=fe(false),[p,a]=fe(null),c=Ko(g.subscribe,g.getSnapshot,g.getSnapshot);xt(()=>{g.registerNukeCallbacks({reactQuery:e.onClearReactQuery,redux:e.onClearRedux,asyncStorage:e.onClearAsyncStorage,mmkv:e.onClearMMKV})},[e.onClearReactQuery,e.onClearRedux,e.onClearAsyncStorage,e.onClearMMKV]),xt(()=>{let v=true;return(async()=>{try{let w=await import("@buoy-gg/shared-ui/web/asyncStorage").then(W=>W.default),G={getItem:W=>w.getItem(W),setItem:(W,Ce)=>w.setItem(W,Ce)};g.setAsyncStorage(G),v&&await g.initializeAsync(G)}catch{}})(),O().isListening||O().startListening(),()=>{v=false}},[]);let s=N(async v=>{if(r(v),a(null),!v.trim()){o([]);return}if(!e.onSearchUsers){a("Search not configured"),o([]);return}l(true);try{let w=await e.onSearchUsers(v);o(w)}catch(w){a(w instanceof Error?w.message:"Search failed"),o([])}finally{l(false)}},[e.onSearchUsers]),f=N(()=>{r(""),o([]),a(null)},[]),S=N(async v=>{await g.startImpersonation(v)},[]),b=N(async()=>{await g.stopImpersonation()},[]),C=N(async v=>{await g.quickSwitch(v)},[]),I=N(async v=>{await g.updateSettings({headerKey:v})},[]),ye=N(async v=>{await g.updateSettings({ignorePatterns:v})},[]),X=N(async v=>{await g.updateSettings({dataNukeSettings:v})},[]),J=N(async v=>{await g.updateSettings({showBanner:v})},[]),K=N(async v=>{await g.removeFromHistory(v)},[]),re=N(async()=>{await g.clearHistory()},[]);return{isActive:c.isActive,currentUser:c.currentUser,headerKey:c.headerKey,ignorePatterns:c.ignorePatterns,dataNukeSettings:c.dataNukeSettings,showBanner:c.showBanner,history:c.history,searchQuery:t,searchResults:n,isSearching:i,searchError:p,searchUsers:s,clearSearch:f,startImpersonation:S,stopImpersonation:b,quickSwitch:C,updateHeaderKey:I,updateIgnorePatterns:ye,updateDataNukeSettings:X,updateShowBanner:J,removeFromHistory:K,clearHistory:re}}import{useCallback as Yo}from"react";import{dispatchToolAction as At,getToolAdapters as Jo}from"@buoy-gg/shared-ui/web";function Go(){let e=!!Jo().query,t=Yo(async()=>{await At("query","clearQueryCache"),await At("query","clearMutationCache")},[]);return{isAvailable:e,error:e?null:"Connect React Query to Buoy or provide onClearReactQuery.",clearCache:e?t:null}}import{useCallback as Zo}from"react";import{dispatchToolAction as en,getToolAdapters as tn}from"@buoy-gg/shared-ui/web";var rn="@@RESET";function on({resetActionType:e=rn}={}){let t=!!tn().redux,r=Zo(async()=>{await en("redux","dispatch",{action:{type:e}})},[e]);return{isAvailable:t,error:t?null:"Connect Redux to Buoy or provide onClearRedux.",resetStore:t?r:null}}import{isDevToolsStorageKey as nn}from"@buoy-gg/shared-ui/web";import{useCallback as an,useMemo as sn,useState as Ht,useEffect as ln}from"react";var Pe=false;function cn(){let[e,t]=Ht(null),[r,n]=Ht(null);ln(()=>{let i=kr();i?(t(i),n(null)):n("@react-native-async-storage/async-storage is not installed")},[]);let o=an(async()=>{if(!Pe){Pe=true;try{if(e){let i=(await e.getAllKeys()).filter(l=>!nn(l));i.length>0&&await e.multiRemove([...i])}}finally{setTimeout(()=>{Pe=false},100)}}},[e]);return sn(()=>!e||r?{isAvailable:false,error:r||"@react-native-async-storage/async-storage is not available",clearStorage:null}:{isAvailable:true,error:null,clearStorage:o},[e,r,o])}import{useCallback as dn}from"react";import{SectionHeader as Ee,EmptyState as un,night as A,Search as hn,AlertTriangle as Pt,Users as pn}from"@buoy-gg/shared-ui/web";import{buoyColors as De,night as D,Play as gn,X as mn,PowerToggleButton as yn,monoFont as fn}from"@buoy-gg/shared-ui/web";import{useMemo as Et}from"react";import{buoyColors as bn,night as Sn}from"@buoy-gg/shared-ui/web";import{jsx as ze,jsxs as vn}from"react/jsx-runtime";var Dt=["#6366F1","#8B5CF6","#EC4899","#F43F5E","#F97316","#EAB308","#22C55E","#14B8A6","#06B6D4","#3B82F6"],wn={small:{container:24,font:10,indicator:8},medium:{container:36,font:14,indicator:10},large:{container:44,font:16,indicator:12}};function xn(e){if(!e)return"?";if(e.includes("@"))return e.charAt(0).toUpperCase();let t=e.trim().split(/\s+/);return t.length===1?t[0].charAt(0).toUpperCase():(t[0].charAt(0)+t[t.length-1].charAt(0)).toUpperCase()}function Cn(e){let t=0;for(let r=0;r<e.length;r++)t=e.charCodeAt(r)+((t<<5)-t);return Dt[Math.abs(t)%Dt.length]}function Le({userId:e,name:t,size:r="medium",showActiveIndicator:n=false,backgroundColor:o}){let i=wn[r],l=Et(()=>o??Cn(e),[e,o]),p=Et(()=>xn(t),[t]);return vn(d,{style:be.wrapper,children:[ze(d,{style:[be.container,{width:i.container,height:i.container,borderRadius:i.container/2,backgroundColor:l}],children:ze(y,{style:[be.initials,{fontSize:i.font}],children:p})}),n&&ze(d,{style:[be.indicator,{width:i.indicator,height:i.indicator,borderRadius:i.indicator/2,right:-1,bottom:-1}]})]})}var be=j.create({wrapper:{position:"relative"},container:{alignItems:"center",justifyContent:"center"},initials:{color:"#FFFFFF",fontWeight:"600",letterSpacing:.5},indicator:{position:"absolute",backgroundColor:bn.success,borderWidth:2,borderColor:Sn.color.surface}});import{jsx as z,jsxs as le}from"react/jsx-runtime";function zt({user:e,isActive:t=false,onPress:r,onStop:n,onRemove:o,showRemoveButton:i=false,lastUsedTime:l,variant:p="default"}){let a=e.displayName||e.email||e.id,c=e.email&&e.displayName,s=typeof e.metadata?.role=="string"?e.metadata.role:null;return le(H,{testID:`buoy-impersonate-user-${e.id}`,style:[R.container,t&&R.activeContainer,p==="compact"&&R.compactContainer],onPress:r,disabled:t,activeOpacity:.7,children:[z(d,{style:R.avatarSection,children:z(Le,{userId:e.id,name:a,size:p==="compact"?"small":"medium",showActiveIndicator:t})}),le(d,{style:R.content,children:[le(d,{style:R.nameRow,children:[z(y,{style:[R.name,t&&R.activeName],numberOfLines:1,children:a}),s?z(d,{style:R.roleBadge,children:z(y,{style:R.roleBadgeText,children:s.toUpperCase()})}):null]}),c&&z(y,{style:R.email,numberOfLines:1,children:e.email}),z(d,{style:R.metadataRow,children:le(y,{style:R.userId,children:["ID: ",e.id]})})]}),le(d,{style:R.actions,children:[t?z(yn,{isEnabled:true,onToggle:n||(()=>{}),accessibilityLabel:"Stop impersonation",testID:`buoy-impersonate-stop-${e.id}`}):z(H,{testID:`buoy-impersonate-start-${e.id}`,style:R.actionButton,onPress:r,activeOpacity:.7,children:z(gn,{size:14,color:D.color.onAccent})}),i&&o&&!t&&z(H,{testID:`buoy-impersonate-remove-${e.id}`,style:R.removeButton,onPress:o,activeOpacity:.7,children:z(mn,{size:12,color:D.color.textTertiary})})]}),l?z(y,{style:R.lastUsed,children:l}):null]})}var R=j.create({container:{flexDirection:"row",alignItems:"center",backgroundColor:D.color.surface,borderRadius:10,borderWidth:1,borderColor:D.color.border,padding:12,gap:12},activeContainer:{backgroundColor:De.success+"10",borderColor:De.success+"40"},compactContainer:{padding:10,gap:10},avatarSection:{flexShrink:0},content:{flex:1,minWidth:0},nameRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:2},name:{fontSize:15,fontWeight:"600",color:D.color.text,flexShrink:1},activeName:{color:De.success},roleBadge:{backgroundColor:D.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},roleBadgeText:{fontSize:9,fontWeight:"700",color:D.color.textTertiary,letterSpacing:.5},email:{fontSize:13,color:D.color.textSecondary,marginBottom:4},metadataRow:{flexDirection:"row",alignItems:"center",gap:4},userId:{fontSize:11,color:D.color.textTertiary,fontFamily:fn},lastUsed:{position:"absolute",bottom:8,right:10,fontSize:10,color:D.color.textTertiary},actions:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:0},actionButton:{width:36,height:36,borderRadius:8,backgroundColor:D.color.accent,alignItems:"center",justifyContent:"center"},removeButton:{width:28,height:28,borderRadius:6,backgroundColor:D.color.surfaceElevated,borderWidth:1,borderColor:D.color.border,alignItems:"center",justifyContent:"center"}});import{jsx as k,jsxs as F}from"react/jsx-runtime";function Lt({currentUser:e,searchQuery:t,searchResults:r,isSearching:n,searchError:o,onSelectUser:i,onStopImpersonation:l,searchAvailable:p=true}){let a=dn(({item:c})=>{let s=e?.id===c.id;return k(zt,{user:c,isActive:s,onPress:()=>!s&&i(c),onStop:s?l:void 0})},[e,i,l]);return F(d,{style:B.container,children:[!p&&k(d,{style:B.section,children:F(d,{style:B.warningCard,children:[k(Pt,{size:18,color:A.color.warning}),F(d,{style:B.warningContent,children:[k(y,{style:B.warningTitle,children:"Search Not Available"}),k(y,{style:B.warningText,children:"Configure the onSearchUsers callback to enable user search."})]})]})}),n&&F(d,{style:B.loadingContainer,children:[k(St,{size:"small",color:A.color.accent}),k(y,{style:B.loadingText,children:"Searching users..."})]}),o?k(d,{style:B.section,children:F(d,{style:B.errorCard,children:[k(Pt,{size:16,color:A.color.danger}),k(y,{testID:"buoy-impersonate-error",style:B.errorText,children:o})]})}):null,r.length>0&&F(d,{style:B.resultsSection,children:[F(Ee,{children:[k(Ee.Title,{children:"Results"}),k(Ee.Badge,{count:r.length})]}),k(Te,{testID:"buoy-impersonate-search-scroll",data:r,keyExtractor:c=>c.id,renderItem:a,ItemSeparatorComponent:()=>k(d,{style:B.separator}),contentContainerStyle:B.listContent,showsVerticalScrollIndicator:false})]}),!!t&&!n&&r.length===0&&!o&&F(d,{testID:"buoy-impersonate-no-results",style:B.emptyStateContainer,children:[k(d,{style:B.emptyStateIcon,children:k(pn,{size:28,color:A.color.textTertiary})}),k(y,{style:B.emptyStateTitle,children:"No users found"}),F(y,{style:B.emptyStateDescription,children:['No results for "',t,'"']}),k(y,{style:B.emptyStateHint,children:"Try a different search term"})]}),!t&&r.length===0&&!n&&p&&k(d,{testID:"buoy-impersonate-search-empty",children:k(un,{title:"Search for users",description:"Tap the search icon in the header to find users by email, name, or ID",icon:hn,variant:"minimal"})})]})}var B=j.create({container:{flex:1},section:{padding:16,paddingBottom:8},loadingContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:10,paddingVertical:20},loadingText:{fontSize:13,color:A.color.textSecondary},resultsSection:{flex:1,paddingHorizontal:16},listContent:{paddingBottom:16},separator:{height:8},warningCard:{flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:A.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:A.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:14,fontWeight:"600",color:A.color.warning,marginBottom:4},warningText:{fontSize:13,color:A.color.textSecondary,lineHeight:18},errorCard:{flexDirection:"row",alignItems:"center",gap:10,backgroundColor:A.color.dangerSoft,borderRadius:10,borderWidth:1,borderColor:A.color.danger+"25",padding:12},errorText:{flex:1,fontSize:13,color:A.color.danger},emptyStateContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyStateIcon:{width:56,height:56,borderRadius:28,backgroundColor:A.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyStateTitle:{fontSize:16,fontWeight:"600",color:A.color.text,marginBottom:6},emptyStateDescription:{fontSize:14,color:A.color.textSecondary,textAlign:"center",marginBottom:8},emptyStateHint:{fontSize:12,color:A.color.textTertiary}});import{useCallback as In}from"react";import{night as Q,Trash2 as kn,useRelativeTime as Tn,ToolEmptyState as Bn}from"@buoy-gg/shared-ui/web";import{jsx as U,jsxs as Nt}from"react/jsx-runtime";function Rn({item:e,isActive:t,onSelect:r,onStop:n,onRemove:o,showRemoveButton:i}){let l=Tn(new Date(e.lastUsedAt));return U(zt,{user:e.user,isActive:t,onPress:()=>!t&&r(e.user),onStop:t?n:void 0,onRemove:o,showRemoveButton:i,lastUsedTime:l})}function Ut({history:e,currentUserId:t,onSelectUser:r,onStopImpersonation:n,onRemoveFromHistory:o,onClearHistory:i}){let l=In(({item:p})=>{let a=t===p.user.id;return U(Rn,{item:p,isActive:a,onSelect:r,onStop:n,onRemove:o?()=>o(p.user.id):void 0,showRemoveButton:!!o})},[t,r,n,o]);return e.length===0?U(Bn,{testID:"buoy-impersonate-history-empty",otto:"disguise",title:"No History",message:"Users you impersonate will appear here for quick access"}):Nt(d,{style:M.container,children:[Nt(d,{style:M.headerRow,children:[U(y,{style:M.headerTitle,children:"Recent"}),U(d,{style:M.headerBadge,children:U(y,{style:M.headerBadgeText,children:e.length})}),U(d,{style:M.headerSpacer}),i&&U(H,{testID:"buoy-impersonate-clear-history",style:M.clearButton,onPress:i,activeOpacity:.7,children:U(kn,{size:12,color:Q.color.textTertiary})})]}),U(Te,{testID:"buoy-impersonate-history-scroll",data:e,keyExtractor:p=>p.user.id,renderItem:l,ItemSeparatorComponent:()=>U(d,{style:M.separator}),contentContainerStyle:M.listContent,showsVerticalScrollIndicator:false})]})}var M=j.create({container:{flex:1,paddingHorizontal:16},headerRow:{flexDirection:"row",alignItems:"center",paddingVertical:10,gap:8},headerTitle:{fontSize:12,fontWeight:"600",color:Q.color.textTertiary,textTransform:"uppercase",letterSpacing:.5},headerBadge:{backgroundColor:Q.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},headerBadgeText:{fontSize:10,fontWeight:"600",color:Q.color.textTertiary},headerSpacer:{flex:1},clearButton:{width:24,height:24,alignItems:"center",justifyContent:"center",backgroundColor:Q.color.surfaceElevated,borderRadius:4},listContent:{paddingBottom:20},separator:{height:8},emptyContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyIcon:{width:56,height:56,borderRadius:28,backgroundColor:Q.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyTitle:{fontSize:16,fontWeight:"600",color:Q.color.text,marginBottom:6},emptyDescription:{fontSize:14,color:Q.color.textSecondary,textAlign:"center"}});import{useState as Se,useEffect as Ne,useMemo as Ue}from"react";import{CollapsibleSection as ce,buoyColors as de,night as m,Settings as An,AlertTriangle as Ot,Info as Hn,Zap as Pn,RefreshCw as En,Check as Oe,X as Kt,Copy as Wt,Eye as Dn,copyToClipboard as zn,ToggleRow as Ln,monoFont as Ke}from"@buoy-gg/shared-ui/web";import{DataViewer as Nn}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as We,jsx as h,jsxs as x}from"react/jsx-runtime";var ue="x-impersonate-user-id",je=true,he={reactQuery:true,redux:true,asyncStorage:false,mmkv:false};function pe({label:e,description:t,value:r,onChange:n,recommended:o,dangerous:i,detected:l,testID:p}){let a=x(We,{children:[l!==void 0&&x(d,{style:[u.detectedBadge,l?u.detectedBadgeActive:u.detectedBadgeInactive],children:[l?h(Oe,{size:10,color:de.success}):h(Kt,{size:10,color:m.color.textTertiary}),h(y,{style:[u.detectedText,l?u.detectedTextActive:u.detectedTextInactive],children:l?"Detected":"Not Detected"})]}),o&&l!==false&&x(d,{style:u.recommendedBadge,children:[h(Pn,{size:10,color:m.color.accent}),h(y,{style:u.recommendedText,children:"Recommended"})]})]});return h(Ln,{variant:"plain",label:e,description:t,value:r,onValueChange:n,tone:i?"warning":"accent",emphasizeLabel:i,accessory:a,testID:p})}function jt({headerKey:e,settings:t,showBanner:r,onSave:n,onShowBannerChange:o,detectionStatus:i}){let[l,p]=Se(e),[a,c]=Se(t),[s,f]=Se(r),[S,b]=Se(false);Ne(()=>{p(e)},[e]),Ne(()=>{c(t)},[t]),Ne(()=>{f(r)},[r]);let C=Ue(()=>l!==e||a.reactQuery!==t.reactQuery||a.redux!==t.redux||a.asyncStorage!==t.asyncStorage||a.mmkv!==t.mmkv,[l,a,e,t]),I=Ue(()=>l===ue&&s===je&&a.reactQuery===he.reactQuery&&a.redux===he.redux&&a.asyncStorage===he.asyncStorage&&a.mmkv===he.mmkv,[l,s,a]),ye=()=>{n(l.trim()||ue,a,s)},X=()=>{p(e),c(t),f(r)},J=()=>{p(ue),c(he),f(je),o(je)},K=(w,G)=>{c(W=>({...W,[w]:G}))},re=Ue(()=>({defaults:{headerKey:l,showBanner:s,dataNukeSettings:{reactQuery:a.reactQuery,redux:a.redux,asyncStorage:a.asyncStorage,mmkv:a.mmkv}}}),[l,s,a]),v=async()=>{let w=`defaults: {
1
+ "use client";var st=Object.defineProperty;var br=Object.getOwnPropertyDescriptor;var Sr=Object.getOwnPropertyNames;var vr=Object.prototype.hasOwnProperty;var wr=(e,t)=>{for(var r in t)st(e,r,{get:t[r],enumerable:true})},it=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Sr(t))!vr.call(e,o)&&o!==r&&st(e,o,{get:()=>t[o],enumerable:!(n=br(t,o))||n.enumerable});return e},xr=(e,t,r)=>(it(e,t,"default"),r&&it(r,t,"default"));var ca=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import lt from"@buoy-gg/shared-ui/web/asyncStorage";import{getCapacitorAppStorage as Cr}from"@buoy-gg/shared-ui/web";function Ir(){return lt}function kr(){return Cr()??lt}import{useState as ke,useCallback as oe,useRef as ct,useEffect as dt}from"react";var ut={};wr(ut,{AccessibilityInfo:()=>Ar,ActivityIndicator:()=>St,Alert:()=>Do,Animated:()=>ko,AppRegistry:()=>Pr,AppState:()=>Er,Appearance:()=>Hr,BackHandler:()=>Dr,Button:()=>Po,CheckBox:()=>_r,Clipboard:()=>zr,DeviceEventEmitter:()=>uo,Dimensions:()=>Lr,Easing:()=>Nr,FlatList:()=>Te,I18nManager:()=>Ur,Image:()=>Yr,ImageBackground:()=>Jr,InteractionManager:()=>Kr,Keyboard:()=>Or,KeyboardAvoidingView:()=>Gr,LayoutAnimation:()=>Wr,Linking:()=>jr,LogBox:()=>co,Modal:()=>Ao,NativeEventEmitter:()=>Fr,NativeModules:()=>Rr,PanResponder:()=>Mr,Picker:()=>Zr,PixelRatio:()=>Vr,Platform:()=>$r,Pressable:()=>Ro,ProgressBar:()=>eo,RefreshControl:()=>to,SafeAreaView:()=>ro,ScrollView:()=>ft,SectionList:()=>oo,Share:()=>Xr,StatusBar:()=>no,StyleSheet:()=>j,Switch:()=>Ho,Text:()=>y,TextInput:()=>yt,Touchable:()=>ao,TouchableHighlight:()=>To,TouchableNativeFeedback:()=>so,TouchableOpacity:()=>H,TouchableWithoutFeedback:()=>Bo,UIManager:()=>Qr,Vibration:()=>qr,View:()=>d,VirtualizedList:()=>io,YellowBox:()=>lo,findNodeHandle:()=>Eo,unstable_createElement:()=>Br,useColorScheme:()=>ho,useLocaleContext:()=>po,useWindowDimensions:()=>go});xr(ut,Tr);import*as Tr from"react-native-web";import{unstable_createElement as Br,NativeModules as Rr,AccessibilityInfo as Ar,Appearance as Hr,AppRegistry as Pr,AppState as Er,BackHandler as Dr,Clipboard as zr,Dimensions as Lr,Easing as Nr,I18nManager as Ur,Keyboard as Or,InteractionManager as Kr,LayoutAnimation as Wr,Linking as jr,NativeEventEmitter as Fr,PanResponder as Mr,PixelRatio as Vr,Platform as $r,Share as Xr,UIManager as Qr,Vibration as qr,CheckBox as _r,FlatList as Te,Image as Yr,ImageBackground as Jr,KeyboardAvoidingView as Gr,Picker as Zr,ProgressBar as eo,RefreshControl as to,SafeAreaView as ro,SectionList as oo,StatusBar as no,Touchable as ao,TouchableNativeFeedback as so,VirtualizedList as io,YellowBox as lo,LogBox as co,DeviceEventEmitter as uo,useColorScheme as ho,useLocaleContext as po,useWindowDimensions as go}from"react-native-web";import*as E from"react-native-web";import{createElement as Be,forwardRef as ht,useCallback as mo,useRef as yo}from"react";import{useEffect as fo,useState as bo}from"react";import{createPortal as So}from"react-dom";var vo='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as wo}from"react/jsx-runtime";var ne=Symbol.for("@buoy-gg/portal-host"),pt=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 gt(){let e=document;if(e[ne])return e[ne].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:vo});let r=()=>{let s=document.fullscreenElement,f=s&&s.tagName!=="CANVAS"?s:document.body;t.parentElement!==f&&f.appendChild(t)},n=new Map,o=s=>{(!t.contains(s.target)||!pt(s.target))&&n.set(s.code||s.key,{key:s.key,code:s.code,location:s.location,keyCode:s.keyCode,which:s.which,altKey:s.altKey,ctrlKey:s.ctrlKey,metaKey:s.metaKey,shiftKey:s.shiftKey})},i=s=>{n.delete(s.code||s.key)},l=()=>n.clear(),p=()=>{let s=[...n.values()];n.clear();for(let f of s)document.dispatchEvent(new KeyboardEvent("keyup",{...f,bubbles:true}))},a=s=>{pt(s.target)&&s.stopPropagation()},c=s=>s.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",o,true),document.addEventListener("keyup",i,true),window.addEventListener("blur",l),t.addEventListener("focusin",p),t.addEventListener("keydown",a),t.addEventListener("keyup",a),t.addEventListener("keypress",a),t.addEventListener("wheel",c,{passive:true}),e[ne]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",o,true),document.removeEventListener("keyup",i,true),window.removeEventListener("blur",l),t.remove(),delete e[ne]}},t}function xo({children:e}){let[t,r]=bo(null);return fo(()=>{let n=gt(),o=document[ne];return o.users++,r(n),()=>{--o.users===0&&o.dispose()}},[]),t?So(wo("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var Z=E,Co=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],ee=e=>typeof e=="number"?`${e}px`:e;function Re(e){if(Array.isArray(e)){let f=e.map(Re);return f.some((S,b)=>S!==e[b])?f:e}if(!e||typeof e!="object"||!Co.some(f=>e[f]!=null))return e;let{shadowColor:t,shadowOffset:r,shadowOpacity:n,shadowRadius:o,textShadowColor:i,textShadowOffset:l,textShadowRadius:p,...a}=e;if(t!=null||r!=null||n!=null||o!=null){let f=t??"black",S=n==null?f:`color-mix(in srgb, ${f} ${Math.min(n,1)*100}%, transparent)`,b=`${ee(r?.width??0)} ${ee(r?.height??0)} ${ee(o??0)} ${S}`;a.boxShadow=typeof a.boxShadow=="string"?`${a.boxShadow}, ${b}`:a.boxShadow??b}let{width:c=0,height:s=0}=l??{};if(i&&(c||s||p)){let f=`${ee(c)} ${ee(s)} ${ee(p??0)} ${i}`;a.textShadow=a.textShadow?`${a.textShadow}, ${f}`:f}return a}var Io=Z.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function mt(e,t){if(typeof e=="function")return n=>mt(e(n),t);let r=Re(e);return t?[r,Io[t]]:r}var j={...Z.StyleSheet,create:e=>Z.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Re(r)])))};function L(e){let t=ht((n,o)=>{let{accessibilityState:i,accessibilityValue:l,pointerEvents:p,...a}=n;for(let s of["busy","checked","disabled","expanded","selected"])i?.[s]!==void 0&&a[`aria-${s}`]===void 0&&(a[`aria-${s}`]=i[s]);for(let[s,f]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))l?.[s]!==void 0&&a[`aria-${f}`]===void 0&&(a[`aria-${f}`]=l[s]);let c=mt(a.style,p);return c!==a.style&&(a.style=c),Be(e,{...a,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var d=L(E.View),y=L(E.Text),ko={...Z.Animated,View:Z.Animated.createAnimatedComponent(d),Text:Z.Animated.createAnimatedComponent(y)},yt=L(E.TextInput),H=L(E.TouchableOpacity),To=L(E.TouchableHighlight),Bo=L(E.TouchableWithoutFeedback),Ro=L(E.Pressable),ft=L(E.ScrollView),bt=ht((e,t)=>{let r=yo(null),n=mo(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"}),gt().appendChild(i))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(o):t&&(t.current=o)},[t]);return Be(xo,null,Be(E.Modal,{...e,ref:n}))});bt.displayName="Modal";var Ao=L(bt),Ho=L(E.Switch),St=L(E.ActivityIndicator),Po=L(E.Button),Eo=E.findNodeHandle,Do={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 l=document.createElement("div");l.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let p=r?.length?r:[{text:"OK"}],a=()=>{o.close?.(),o.remove()};for(let c of p){let s=document.createElement("button");s.type="button",s.textContent=c.text??"OK",s.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${c.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,s.onclick=()=>{a(),c.onPress?.()},l.appendChild(s)}o.addEventListener("cancel",c=>{c.preventDefault(),n?.cancelable!==false&&(a(),n?.onDismiss?.())}),o.appendChild(l),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{JsModal as zo,TabSelector as Lo,ModalHeader as ae,buoyColors as No,night as vt,Search as Uo,TickProvider as wt,windowDragProps as Oo}from"@buoy-gg/shared-ui/web";import{useState as fe,useEffect as xt,useCallback as N,useSyncExternalStore as Ko}from"react";import{assertAccountAccess as Ct,getAccountAccess as Wo,hasAccountAccess as jo,subscribeAccountAccess as Fo}from"@buoy-gg/shared-ui/web";var It=[/\/symbolicate$/,/\/logs$/,/\/debugger-proxy/,/\/reload$/,/\/launch-js-devtools/,/localhost:8081/,/100\.64\.\d+\.\d+:8081/,/10\.0\.\d+\.\d+:8081/,/\.hot-update\./,/__metro/];function Ae(e,t){for(let r of Object.keys(t))r.startsWith("__buoy")&&(e[r]=t[r])}var Mo=class{constructor(){this.isListeningFlag=false;this.patchedFetch=null;this.patchedXHROpen=null;this.patchedXHRSend=null;this.reportHeader=e=>this.shouldInjectHeader(e)?{[this.config.headerKey]:this.config.userId}:null;this.originalFetch=globalThis.fetch.bind(globalThis),this.originalXHROpen=XMLHttpRequest.prototype.open,this.originalXHRSend=XMLHttpRequest.prototype.send,this.config={headerKey:"x-impersonate-user-id",userId:null,ignorePatterns:[...It]}}setConfig(e){this.config={...this.config,...e},e.ignorePatterns&&(this.config.ignorePatterns=[...It,...e.ignorePatterns])}getConfig(){return{...this.config}}shouldInjectHeader(e){return!this.config.userId||this.config.gate&&!this.config.gate()?false:!this.config.ignorePatterns.some(t=>t.test(e))}extractUrl(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}startListening(){if(this.isListeningFlag)return;let e=globalThis.fetch,t=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send;this.originalFetch=e.bind(globalThis),this.originalXHROpen=t,this.originalXHRSend=r;let n=this,o=async function(c,s){let f=n.extractUrl(c);if(n.shouldInjectHeader(f)){let S=s?.headers??(typeof c=="object"&&"headers"in c?c.headers:void 0),b=new Headers(S);return b.set(n.config.headerKey,n.config.userId),n.originalFetch(c,{...s,headers:b})}return n.originalFetch(c,s)};Ae(o,e),this.patchedFetch=o,globalThis.fetch=this.patchedFetch;let i=function(c,s,f=true,S,b){let C=this;C._impersonateUrl=typeof s=="string"?s:s.href;let I=typeof s=="string"?s:s.toString();return n.originalXHROpen.call(this,c,I,f,S,b)},l=function(c){let s=this;return s._impersonateUrl&&n.shouldInjectHeader(s._impersonateUrl)&&this.setRequestHeader(n.config.headerKey,n.config.userId),n.originalXHRSend.call(this,c)};Ae(i,t),Ae(l,r),this.patchedXHROpen=i,this.patchedXHRSend=l,XMLHttpRequest.prototype.open=this.patchedXHROpen,XMLHttpRequest.prototype.send=this.patchedXHRSend;let p=globalThis,a=p.__buoyHeaderInjectors??(p.__buoyHeaderInjectors=[]);a.includes(this.reportHeader)||a.push(this.reportHeader),this.isListeningFlag=true}stopListening(){if(!this.isListeningFlag)return;this.patchedFetch&&globalThis.fetch===this.patchedFetch&&(globalThis.fetch=this.originalFetch),this.patchedXHROpen&&XMLHttpRequest.prototype.open===this.patchedXHROpen&&(XMLHttpRequest.prototype.open=this.originalXHROpen),this.patchedXHRSend&&XMLHttpRequest.prototype.send===this.patchedXHRSend&&(XMLHttpRequest.prototype.send=this.originalXHRSend),this.patchedFetch=null,this.patchedXHROpen=null,this.patchedXHRSend=null;let e=globalThis.__buoyHeaderInjectors,t=e?.indexOf(this.reportHeader)??-1;e&&t>=0&&e.splice(t,1),this.isListeningFlag=false}get isListening(){return this.isListeningFlag}get isImpersonating(){return this.config.userId!==null&&(this.config.gate?.()??true)}},se=null;function O(){return se||(se=new Mo),se}function Vo(){O().startListening()}function $o(){O().stopListening()}function kt(e){O().setConfig(e)}function Xo(){return se?.isImpersonating??false}function Qo(){return se?.getConfig().userId??null}var ie="@buoy/impersonate/state",qo=10,Tt={reactQuery:true,redux:true,asyncStorage:false,mmkv:false},te={isActive:false,isPaused:false,currentUser:null,headerKey:"x-impersonate-user-id",ignorePatterns:[],dataNukeSettings:Tt,showBanner:true,history:[]},He=false,Bt={getItem:e=>{try{return typeof localStorage<"u"?localStorage.getItem(e):null}catch{return null}},setItem:(e,t)=>{try{typeof localStorage<"u"&&localStorage.setItem(e,t)}catch{}},removeItem:e=>{try{typeof localStorage<"u"&&localStorage.removeItem(e)}catch{}}},_o=class{constructor(){this.state={...te};this.listeners=new Set;this.nukeCallbacks={};this.isInitialized=false;this.asyncStorageRef=null;this.storageReadyPromise=null;this.resolveStorageReady=null;this.developerDefaults=null;this.getSnapshot=()=>this.state;this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));this.remoteHandler=null;this.loadFromStorage(),Promise.resolve().then(()=>{let e=false,t=()=>{let r=Wo().status;r==="admitted"?e=true:r==="locked"&&e&&(e=false,this.disposeAccountSession())};Fo(t),t()}),typeof localStorage<"u"?this.storageReadyPromise=Promise.resolve():this.storageReadyPromise=new Promise(e=>{this.resolveStorageReady=e})}loadFromStorage(){try{let e=Bt.getItem(ie),t=this.getEffectiveDefaults();if(e){let r=JSON.parse(e);this.state={...te,headerKey:r.headerKey??t.headerKey,ignorePatterns:r.ignorePatterns??te.ignorePatterns,dataNukeSettings:{...t.dataNukeSettings,...r.dataNukeSettings},showBanner:r.showBanner??t.showBanner,history:r.history??[],isActive:r.isActive??false,isPaused:r.isPaused??false,currentUser:r.currentUser??null},this.state.isActive&&this.state.currentUser&&this.syncWithListener()}else this.state={...te,headerKey:t.headerKey,dataNukeSettings:t.dataNukeSettings,showBanner:t.showBanner};this.isInitialized=true}catch{this.isInitialized=true}}setAsyncStorage(e){this.asyncStorageRef=e,this.resolveStorageReady&&(this.resolveStorageReady(),this.resolveStorageReady=null)}setDeveloperDefaults(e){this.developerDefaults=e;let t=this.getEffectiveDefaults();this.isInitialized||(this.state={...this.state,headerKey:t.headerKey,dataNukeSettings:t.dataNukeSettings,showBanner:t.showBanner})}getEffectiveDefaults(){return{headerKey:this.developerDefaults?.headerKey??te.headerKey,dataNukeSettings:{...Tt,...this.developerDefaults?.dataNukeSettings},showBanner:this.developerDefaults?.showBanner??te.showBanner}}getDeveloperDefaults(){return this.developerDefaults}async initializeAsync(e){if(e){this.asyncStorageRef=e;try{let t=await e.getItem(ie);if(console.log("[Buoy]",`[impersonate] initializeAsync read STORAGE_KEY=${ie} stored=${t?t.slice(0,200):"null"}`),t){let r=JSON.parse(t);this.state={...this.state,headerKey:r.headerKey??this.state.headerKey,ignorePatterns:r.ignorePatterns??this.state.ignorePatterns,dataNukeSettings:{...this.state.dataNukeSettings,...r.dataNukeSettings},showBanner:r.showBanner??this.state.showBanner,history:r.history??this.state.history,isActive:r.isActive??this.state.isActive,isPaused:r.isPaused??this.state.isPaused,currentUser:r.currentUser??this.state.currentUser},this.state.isActive&&this.state.currentUser&&this.syncWithListener(),this.notify()}}catch{}}}registerNukeCallbacks(e){this.nukeCallbacks={...this.nukeCallbacks,...e}}getState(){return{...this.state}}setRemoteHandler(e){this.remoteHandler=e}replaceState(e){this.state=e,this.notify()}async startImpersonation(e){if(Ct(),this.remoteHandler){this.remoteHandler("startImpersonation",{user:e});return}let t=[{user:e,lastUsedAt:new Date().toISOString()},...this.state.history.filter(r=>r.user.id!==e.id)].slice(0,qo);this.state={...this.state,isActive:true,currentUser:e,history:t},this.syncWithListener(),this.notify(),await this.executeDataNuke(),await this.persist()}async stopImpersonation(){if(this.remoteHandler){this.remoteHandler("stopImpersonation");return}console.log("[Buoy]",`[impersonate] stopImpersonation: isActive ${this.state.isActive} -> false, listeners=${this.listeners.size}`),this.state={...this.state,isActive:false,isPaused:false,currentUser:null},this.syncWithListener(),this.notify(),await this.executeDataNuke(),await this.persist()}async pauseImpersonation(){if(this.remoteHandler){this.remoteHandler("pauseImpersonation");return}!this.state.isActive||this.state.isPaused||(this.state={...this.state,isPaused:true},this.syncWithListener(),await this.persist(),this.notify())}async resumeImpersonation(){if(Ct(),this.remoteHandler){this.remoteHandler("resumeImpersonation");return}!this.state.isActive||!this.state.isPaused||(this.state={...this.state,isPaused:false},this.syncWithListener(),await this.persist(),this.notify())}async quickSwitch(e){return this.startImpersonation(e)}async updateSettings(e){if(this.remoteHandler){this.remoteHandler("updateSettings",{settings:e});return}this.state={...this.state,headerKey:e.headerKey??this.state.headerKey,ignorePatterns:e.ignorePatterns??this.state.ignorePatterns,showBanner:e.showBanner??this.state.showBanner,dataNukeSettings:e.dataNukeSettings?{...this.state.dataNukeSettings,...e.dataNukeSettings}:this.state.dataNukeSettings},(e.headerKey||e.ignorePatterns)&&this.syncWithListener(),await this.persist(),this.notify()}async removeFromHistory(e){if(this.remoteHandler){this.remoteHandler("removeFromHistory",{userId:e});return}this.state={...this.state,history:this.state.history.filter(t=>t.user.id!==e)},await this.persist(),this.notify()}async clearHistory(){if(this.remoteHandler){this.remoteHandler("clearHistory");return}this.state={...this.state,history:[]},await this.persist(),this.notify()}async executeDataNuke(){if(!He){He=true;try{let{dataNukeSettings:e}=this.state,t=[];e.reactQuery&&this.nukeCallbacks.reactQuery&&t.push(Promise.resolve(this.nukeCallbacks.reactQuery())),e.redux&&this.nukeCallbacks.redux&&t.push(Promise.resolve(this.nukeCallbacks.redux())),e.asyncStorage&&this.nukeCallbacks.asyncStorage&&t.push(Promise.resolve(this.nukeCallbacks.asyncStorage())),e.mmkv&&this.nukeCallbacks.mmkv&&t.push(Promise.resolve(this.nukeCallbacks.mmkv())),await Promise.allSettled(t)}finally{setTimeout(()=>{He=false},100)}}}disposeAccountSession(){this.remoteHandler||!this.state.isActive||(this.state={...this.state,isActive:false,isPaused:false,currentUser:null},this.syncWithListener(),this.notify(),this.persist())}syncWithListener(){let e=this.state.isActive&&!this.state.isPaused;kt({headerKey:this.state.headerKey,userId:e?this.state.currentUser?.id??null:null,ignorePatterns:this.state.ignorePatterns.map(t=>new RegExp(t)),gate:jo}),O().isListening||O().startListening()}async persist(){this.storageReadyPromise&&await this.storageReadyPromise;let e={headerKey:this.state.headerKey,ignorePatterns:this.state.ignorePatterns,dataNukeSettings:this.state.dataNukeSettings,showBanner:this.state.showBanner,history:this.state.history,isActive:this.state.isActive,isPaused:this.state.isPaused,currentUser:this.state.currentUser},t=JSON.stringify(e);try{this.asyncStorageRef?(await this.asyncStorageRef.setItem(ie,t),console.log("[Buoy]",`[impersonate] persist -> AsyncStorage isActive=${e.isActive} userId=${e.currentUser?.id??"null"}`)):(Bt.setItem(ie,t),console.log("[Buoy]",`[impersonate] persist -> localStorage isActive=${e.isActive} userId=${e.currentUser?.id??"null"}`))}catch(r){console.warn("[Buoy]","[impersonate] persist failed",r)}}notify(){this.listeners.forEach(e=>{try{e(this.state)}catch{}})}},g=new _o;function Rt(e={}){let[t,r]=fe(""),[n,o]=fe([]),[i,l]=fe(false),[p,a]=fe(null),c=Ko(g.subscribe,g.getSnapshot,g.getSnapshot);xt(()=>{g.registerNukeCallbacks({reactQuery:e.onClearReactQuery,redux:e.onClearRedux,asyncStorage:e.onClearAsyncStorage,mmkv:e.onClearMMKV})},[e.onClearReactQuery,e.onClearRedux,e.onClearAsyncStorage,e.onClearMMKV]),xt(()=>{let v=true;return(async()=>{try{let w=await import("@buoy-gg/shared-ui/web/asyncStorage").then(W=>W.default),G={getItem:W=>w.getItem(W),setItem:(W,Ce)=>w.setItem(W,Ce)};g.setAsyncStorage(G),v&&await g.initializeAsync(G)}catch{}})(),O().isListening||O().startListening(),()=>{v=false}},[]);let s=N(async v=>{if(r(v),a(null),!v.trim()){o([]);return}if(!e.onSearchUsers){a("Search not configured"),o([]);return}l(true);try{let w=await e.onSearchUsers(v);o(w)}catch(w){a(w instanceof Error?w.message:"Search failed"),o([])}finally{l(false)}},[e.onSearchUsers]),f=N(()=>{r(""),o([]),a(null)},[]),S=N(async v=>{await g.startImpersonation(v)},[]),b=N(async()=>{await g.stopImpersonation()},[]),C=N(async v=>{await g.quickSwitch(v)},[]),I=N(async v=>{await g.updateSettings({headerKey:v})},[]),ye=N(async v=>{await g.updateSettings({ignorePatterns:v})},[]),X=N(async v=>{await g.updateSettings({dataNukeSettings:v})},[]),J=N(async v=>{await g.updateSettings({showBanner:v})},[]),K=N(async v=>{await g.removeFromHistory(v)},[]),re=N(async()=>{await g.clearHistory()},[]);return{isActive:c.isActive,currentUser:c.currentUser,headerKey:c.headerKey,ignorePatterns:c.ignorePatterns,dataNukeSettings:c.dataNukeSettings,showBanner:c.showBanner,history:c.history,searchQuery:t,searchResults:n,isSearching:i,searchError:p,searchUsers:s,clearSearch:f,startImpersonation:S,stopImpersonation:b,quickSwitch:C,updateHeaderKey:I,updateIgnorePatterns:ye,updateDataNukeSettings:X,updateShowBanner:J,removeFromHistory:K,clearHistory:re}}import{useCallback as Yo}from"react";import{dispatchToolAction as At,getToolAdapters as Jo}from"@buoy-gg/shared-ui/web";function Go(){let e=!!Jo().query,t=Yo(async()=>{await At("query","clearQueryCache"),await At("query","clearMutationCache")},[]);return{isAvailable:e,error:e?null:"Connect React Query to Buoy or provide onClearReactQuery.",clearCache:e?t:null}}import{useCallback as Zo}from"react";import{dispatchToolAction as en,getToolAdapters as tn}from"@buoy-gg/shared-ui/web";var rn="@@RESET";function on({resetActionType:e=rn}={}){let t=!!tn().redux,r=Zo(async()=>{await en("redux","dispatch",{action:{type:e}})},[e]);return{isAvailable:t,error:t?null:"Connect Redux to Buoy or provide onClearRedux.",resetStore:t?r:null}}import{isDevToolsStorageKey as nn}from"@buoy-gg/shared-ui/web";import{useCallback as an,useMemo as sn,useState as Ht,useEffect as ln}from"react";var Pe=false;function cn(){let[e,t]=Ht(null),[r,n]=Ht(null);ln(()=>{let i=kr();i?(t(i),n(null)):n("@react-native-async-storage/async-storage is not installed")},[]);let o=an(async()=>{if(!Pe){Pe=true;try{if(e){let i=(await e.getAllKeys()).filter(l=>!nn(l));i.length>0&&await e.multiRemove([...i])}}finally{setTimeout(()=>{Pe=false},100)}}},[e]);return sn(()=>!e||r?{isAvailable:false,error:r||"@react-native-async-storage/async-storage is not available",clearStorage:null}:{isAvailable:true,error:null,clearStorage:o},[e,r,o])}import{useCallback as dn}from"react";import{SectionHeader as Ee,EmptyState as un,night as A,Search as hn,AlertTriangle as Pt,Users as pn}from"@buoy-gg/shared-ui/web";import{buoyColors as De,night as D,Play as gn,X as mn,PowerToggleButton as yn,monoFont as fn}from"@buoy-gg/shared-ui/web";import{useMemo as Et}from"react";import{buoyColors as bn,night as Sn}from"@buoy-gg/shared-ui/web";import{jsx as ze,jsxs as vn}from"react/jsx-runtime";var Dt=["#6366F1","#8B5CF6","#EC4899","#F43F5E","#F97316","#EAB308","#22C55E","#14B8A6","#06B6D4","#3B82F6"],wn={small:{container:24,font:10,indicator:8},medium:{container:36,font:14,indicator:10},large:{container:44,font:16,indicator:12}};function xn(e){if(!e)return"?";if(e.includes("@"))return e.charAt(0).toUpperCase();let t=e.trim().split(/\s+/);return t.length===1?t[0].charAt(0).toUpperCase():(t[0].charAt(0)+t[t.length-1].charAt(0)).toUpperCase()}function Cn(e){let t=0;for(let r=0;r<e.length;r++)t=e.charCodeAt(r)+((t<<5)-t);return Dt[Math.abs(t)%Dt.length]}function Le({userId:e,name:t,size:r="medium",showActiveIndicator:n=false,backgroundColor:o}){let i=wn[r],l=Et(()=>o??Cn(e),[e,o]),p=Et(()=>xn(t),[t]);return vn(d,{style:be.wrapper,children:[ze(d,{style:[be.container,{width:i.container,height:i.container,borderRadius:i.container/2,backgroundColor:l}],children:ze(y,{style:[be.initials,{fontSize:i.font}],children:p})}),n&&ze(d,{style:[be.indicator,{width:i.indicator,height:i.indicator,borderRadius:i.indicator/2,right:-1,bottom:-1}]})]})}var be=j.create({wrapper:{position:"relative"},container:{alignItems:"center",justifyContent:"center"},initials:{color:"#FFFFFF",fontWeight:"600",letterSpacing:.5},indicator:{position:"absolute",backgroundColor:bn.success,borderWidth:2,borderColor:Sn.color.surface}});import{jsx as z,jsxs as le}from"react/jsx-runtime";function zt({user:e,isActive:t=false,onPress:r,onStop:n,onRemove:o,showRemoveButton:i=false,lastUsedTime:l,variant:p="default"}){let a=e.displayName||e.email||e.id,c=e.email&&e.displayName,s=typeof e.metadata?.role=="string"?e.metadata.role:null;return le(H,{testID:`buoy-impersonate-user-${e.id}`,style:[R.container,t&&R.activeContainer,p==="compact"&&R.compactContainer],onPress:r,disabled:t,activeOpacity:.7,children:[z(d,{style:R.avatarSection,children:z(Le,{userId:e.id,name:a,size:p==="compact"?"small":"medium",showActiveIndicator:t})}),le(d,{style:R.content,children:[le(d,{style:R.nameRow,children:[z(y,{style:[R.name,t&&R.activeName],numberOfLines:1,children:a}),s?z(d,{style:R.roleBadge,children:z(y,{style:R.roleBadgeText,children:s.toUpperCase()})}):null]}),c&&z(y,{style:R.email,numberOfLines:1,children:e.email}),z(d,{style:R.metadataRow,children:le(y,{style:R.userId,children:["ID: ",e.id]})})]}),le(d,{style:R.actions,children:[t?z(yn,{isEnabled:true,onToggle:n||(()=>{}),accessibilityLabel:"Stop impersonation",testID:`buoy-impersonate-stop-${e.id}`}):z(H,{testID:`buoy-impersonate-start-${e.id}`,style:R.actionButton,onPress:r,activeOpacity:.7,children:z(gn,{size:14,color:D.color.onAccent})}),i&&o&&!t&&z(H,{testID:`buoy-impersonate-remove-${e.id}`,style:R.removeButton,onPress:o,activeOpacity:.7,children:z(mn,{size:12,color:D.color.textTertiary})})]}),l?z(y,{style:R.lastUsed,children:l}):null]})}var R=j.create({container:{flexDirection:"row",alignItems:"center",backgroundColor:D.color.surface,borderRadius:10,borderWidth:1,borderColor:D.color.border,padding:12,gap:12},activeContainer:{backgroundColor:De.success+"10",borderColor:De.success+"40"},compactContainer:{padding:10,gap:10},avatarSection:{flexShrink:0},content:{flex:1,minWidth:0},nameRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:2},name:{fontSize:15,fontWeight:"600",color:D.color.text,flexShrink:1},activeName:{color:De.success},roleBadge:{backgroundColor:D.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},roleBadgeText:{fontSize:9,fontWeight:"700",color:D.color.textTertiary,letterSpacing:.5},email:{fontSize:13,color:D.color.textSecondary,marginBottom:4},metadataRow:{flexDirection:"row",alignItems:"center",gap:4},userId:{fontSize:11,color:D.color.textTertiary,fontFamily:fn},lastUsed:{position:"absolute",bottom:8,right:10,fontSize:10,color:D.color.textTertiary},actions:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:0},actionButton:{width:36,height:36,borderRadius:8,backgroundColor:D.color.accent,alignItems:"center",justifyContent:"center"},removeButton:{width:28,height:28,borderRadius:6,backgroundColor:D.color.surfaceElevated,borderWidth:1,borderColor:D.color.border,alignItems:"center",justifyContent:"center"}});import{jsx as k,jsxs as F}from"react/jsx-runtime";function Lt({currentUser:e,searchQuery:t,searchResults:r,isSearching:n,searchError:o,onSelectUser:i,onStopImpersonation:l,searchAvailable:p=true}){let a=dn(({item:c})=>{let s=e?.id===c.id;return k(zt,{user:c,isActive:s,onPress:()=>!s&&i(c),onStop:s?l:void 0})},[e,i,l]);return F(d,{style:B.container,children:[!p&&k(d,{style:B.section,children:F(d,{style:B.warningCard,children:[k(Pt,{size:18,color:A.color.warning}),F(d,{style:B.warningContent,children:[k(y,{style:B.warningTitle,children:"Search Not Available"}),k(y,{style:B.warningText,children:"Configure the onSearchUsers callback to enable user search."})]})]})}),n&&F(d,{style:B.loadingContainer,children:[k(St,{size:"small",color:A.color.accent}),k(y,{style:B.loadingText,children:"Searching users..."})]}),o?k(d,{style:B.section,children:F(d,{style:B.errorCard,children:[k(Pt,{size:16,color:A.color.danger}),k(y,{testID:"buoy-impersonate-error",style:B.errorText,children:o})]})}):null,r.length>0&&F(d,{style:B.resultsSection,children:[F(Ee,{children:[k(Ee.Title,{children:"Results"}),k(Ee.Badge,{count:r.length})]}),k(Te,{keyboardShouldPersistTaps:"handled",testID:"buoy-impersonate-search-scroll",data:r,keyExtractor:c=>c.id,renderItem:a,ItemSeparatorComponent:()=>k(d,{style:B.separator}),contentContainerStyle:B.listContent,showsVerticalScrollIndicator:false})]}),!!t&&!n&&r.length===0&&!o&&F(d,{testID:"buoy-impersonate-no-results",style:B.emptyStateContainer,children:[k(d,{style:B.emptyStateIcon,children:k(pn,{size:28,color:A.color.textTertiary})}),k(y,{style:B.emptyStateTitle,children:"No users found"}),F(y,{style:B.emptyStateDescription,children:['No results for "',t,'"']}),k(y,{style:B.emptyStateHint,children:"Try a different search term"})]}),!t&&r.length===0&&!n&&p&&k(d,{testID:"buoy-impersonate-search-empty",children:k(un,{title:"Search for users",description:"Tap the search icon in the header to find users by email, name, or ID",icon:hn,variant:"minimal"})})]})}var B=j.create({container:{flex:1},section:{padding:16,paddingBottom:8},loadingContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:10,paddingVertical:20},loadingText:{fontSize:13,color:A.color.textSecondary},resultsSection:{flex:1,paddingHorizontal:16},listContent:{paddingBottom:16},separator:{height:8},warningCard:{flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:A.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:A.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:14,fontWeight:"600",color:A.color.warning,marginBottom:4},warningText:{fontSize:13,color:A.color.textSecondary,lineHeight:18},errorCard:{flexDirection:"row",alignItems:"center",gap:10,backgroundColor:A.color.dangerSoft,borderRadius:10,borderWidth:1,borderColor:A.color.danger+"25",padding:12},errorText:{flex:1,fontSize:13,color:A.color.danger},emptyStateContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyStateIcon:{width:56,height:56,borderRadius:28,backgroundColor:A.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyStateTitle:{fontSize:16,fontWeight:"600",color:A.color.text,marginBottom:6},emptyStateDescription:{fontSize:14,color:A.color.textSecondary,textAlign:"center",marginBottom:8},emptyStateHint:{fontSize:12,color:A.color.textTertiary}});import{useCallback as In}from"react";import{night as Q,Trash2 as kn,useRelativeTime as Tn,ToolEmptyState as Bn}from"@buoy-gg/shared-ui/web";import{jsx as U,jsxs as Nt}from"react/jsx-runtime";function Rn({item:e,isActive:t,onSelect:r,onStop:n,onRemove:o,showRemoveButton:i}){let l=Tn(new Date(e.lastUsedAt));return U(zt,{user:e.user,isActive:t,onPress:()=>!t&&r(e.user),onStop:t?n:void 0,onRemove:o,showRemoveButton:i,lastUsedTime:l})}function Ut({history:e,currentUserId:t,onSelectUser:r,onStopImpersonation:n,onRemoveFromHistory:o,onClearHistory:i}){let l=In(({item:p})=>{let a=t===p.user.id;return U(Rn,{item:p,isActive:a,onSelect:r,onStop:n,onRemove:o?()=>o(p.user.id):void 0,showRemoveButton:!!o})},[t,r,n,o]);return e.length===0?U(Bn,{testID:"buoy-impersonate-history-empty",otto:"disguise",title:"No History",message:"Users you impersonate will appear here for quick access"}):Nt(d,{style:M.container,children:[Nt(d,{style:M.headerRow,children:[U(y,{style:M.headerTitle,children:"Recent"}),U(d,{style:M.headerBadge,children:U(y,{style:M.headerBadgeText,children:e.length})}),U(d,{style:M.headerSpacer}),i&&U(H,{testID:"buoy-impersonate-clear-history",style:M.clearButton,onPress:i,activeOpacity:.7,children:U(kn,{size:12,color:Q.color.textTertiary})})]}),U(Te,{keyboardShouldPersistTaps:"handled",testID:"buoy-impersonate-history-scroll",data:e,keyExtractor:p=>p.user.id,renderItem:l,ItemSeparatorComponent:()=>U(d,{style:M.separator}),contentContainerStyle:M.listContent,showsVerticalScrollIndicator:false})]})}var M=j.create({container:{flex:1,paddingHorizontal:16},headerRow:{flexDirection:"row",alignItems:"center",paddingVertical:10,gap:8},headerTitle:{fontSize:12,fontWeight:"600",color:Q.color.textTertiary,textTransform:"uppercase",letterSpacing:.5},headerBadge:{backgroundColor:Q.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},headerBadgeText:{fontSize:10,fontWeight:"600",color:Q.color.textTertiary},headerSpacer:{flex:1},clearButton:{width:24,height:24,alignItems:"center",justifyContent:"center",backgroundColor:Q.color.surfaceElevated,borderRadius:4},listContent:{paddingBottom:20},separator:{height:8},emptyContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyIcon:{width:56,height:56,borderRadius:28,backgroundColor:Q.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyTitle:{fontSize:16,fontWeight:"600",color:Q.color.text,marginBottom:6},emptyDescription:{fontSize:14,color:Q.color.textSecondary,textAlign:"center"}});import{useState as Se,useEffect as Ne,useMemo as Ue}from"react";import{CollapsibleSection as ce,buoyColors as de,night as m,Settings as An,AlertTriangle as Ot,Info as Hn,Zap as Pn,RefreshCw as En,Check as Oe,X as Kt,Copy as Wt,Eye as Dn,copyToClipboard as zn,ToggleRow as Ln,monoFont as Ke}from"@buoy-gg/shared-ui/web";import{DataViewer as Nn}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as We,jsx as h,jsxs as x}from"react/jsx-runtime";var ue="x-impersonate-user-id",je=true,he={reactQuery:true,redux:true,asyncStorage:false,mmkv:false};function pe({label:e,description:t,value:r,onChange:n,recommended:o,dangerous:i,detected:l,testID:p}){let a=x(We,{children:[l!==void 0&&x(d,{style:[u.detectedBadge,l?u.detectedBadgeActive:u.detectedBadgeInactive],children:[l?h(Oe,{size:10,color:de.success}):h(Kt,{size:10,color:m.color.textTertiary}),h(y,{style:[u.detectedText,l?u.detectedTextActive:u.detectedTextInactive],children:l?"Detected":"Not Detected"})]}),o&&l!==false&&x(d,{style:u.recommendedBadge,children:[h(Pn,{size:10,color:m.color.accent}),h(y,{style:u.recommendedText,children:"Recommended"})]})]});return h(Ln,{variant:"plain",label:e,description:t,value:r,onValueChange:n,tone:i?"warning":"accent",emphasizeLabel:i,accessory:a,testID:p})}function jt({headerKey:e,settings:t,showBanner:r,onSave:n,onShowBannerChange:o,detectionStatus:i}){let[l,p]=Se(e),[a,c]=Se(t),[s,f]=Se(r),[S,b]=Se(false);Ne(()=>{p(e)},[e]),Ne(()=>{c(t)},[t]),Ne(()=>{f(r)},[r]);let C=Ue(()=>l!==e||a.reactQuery!==t.reactQuery||a.redux!==t.redux||a.asyncStorage!==t.asyncStorage||a.mmkv!==t.mmkv,[l,a,e,t]),I=Ue(()=>l===ue&&s===je&&a.reactQuery===he.reactQuery&&a.redux===he.redux&&a.asyncStorage===he.asyncStorage&&a.mmkv===he.mmkv,[l,s,a]),ye=()=>{n(l.trim()||ue,a,s)},X=()=>{p(e),c(t),f(r)},J=()=>{p(ue),c(he),f(je),o(je)},K=(w,G)=>{c(W=>({...W,[w]:G}))},re=Ue(()=>({defaults:{headerKey:l,showBanner:s,dataNukeSettings:{reactQuery:a.reactQuery,redux:a.redux,asyncStorage:a.asyncStorage,mmkv:a.mmkv}}}),[l,s,a]),v=async()=>{let w=`defaults: {
2
2
  headerKey: '${l}',
3
3
  showBanner: ${s},
4
4
  dataNukeSettings: {
@@ -7,4 +7,4 @@
7
7
  asyncStorage: ${a.asyncStorage},
8
8
  mmkv: ${a.mmkv},
9
9
  },
10
- },`;try{await zn(w),b(true),setTimeout(()=>b(false),2e3)}catch{}};return x(ft,{testID:"buoy-impersonate-settings-scroll",style:u.container,contentContainerStyle:u.contentContainer,children:[C&&h(d,{style:u.actionBar,children:x(d,{style:u.actionBarContent,children:[h(y,{style:u.unsavedText,children:"Unsaved changes"}),x(d,{style:u.actionButtons,children:[x(H,{testID:"buoy-impersonate-discard",style:u.discardButton,onPress:X,children:[h(Kt,{size:14,color:m.color.textSecondary}),h(y,{style:u.discardButtonText,children:"Discard"})]}),x(H,{testID:"buoy-impersonate-save",style:u.saveButton,onPress:ye,children:[h(Oe,{size:14,color:m.color.onAccent}),h(y,{style:u.saveButtonText,children:"Save"})]})]})]})}),h(ce,{title:"Header Configuration",icon:An,defaultOpen:true,variant:"bordered",children:x(d,{style:u.sectionContent,children:[h(y,{style:u.inputLabel,children:"Header Key"}),h(yt,{testID:"buoy-impersonate-header-key",style:u.input,value:l,onChangeText:p,placeholder:"x-impersonate-user-id",placeholderTextColor:m.color.placeholder,autoCapitalize:"none",autoCorrect:false}),x(d,{style:u.inputFooter,children:[h(y,{style:u.helperText,children:"The HTTP header key used for impersonation. Value will be the user ID."}),l!==ue&&h(H,{onPress:()=>p(ue),style:u.resetLink,children:h(y,{style:u.resetLinkText,children:"Reset to default"})})]})]})}),h(ce,{title:"Display",icon:Dn,defaultOpen:true,variant:"bordered",children:h(d,{style:u.sectionContent,children:h(d,{style:u.togglesCard,children:h(pe,{label:"Floating Banner",description:"Show a floating banner when impersonation is active",value:s,onChange:w=>{f(w),o(w)},recommended:true,testID:"buoy-impersonate-show-banner"})})})}),h(ce,{title:"Data Clearing",icon:Ot,defaultOpen:true,variant:"bordered",children:x(d,{style:u.sectionContent,children:[h(y,{style:u.sectionDescription,children:"Choose what data to clear when impersonation starts or stops. This ensures you see fresh data for the impersonated user."}),x(d,{style:u.togglesCard,children:[h(pe,{label:"React Query",description:"Clear query cache and cancel pending queries",value:a.reactQuery,onChange:w=>K("reactQuery",w),recommended:true,detected:i?.reactQuery}),h(d,{style:u.divider}),h(pe,{label:"Redux",description:"Reset Redux store to initial state",value:a.redux,onChange:w=>K("redux",w),recommended:true,detected:i?.redux})]}),x(d,{style:u.advancedSection,children:[h(y,{style:u.advancedLabel,children:"Storage Options"}),x(d,{style:[u.togglesCard,u.dangerousCard],children:[h(pe,{label:"AsyncStorage",description:"Clear app data (preserves @buoy/* keys)",value:a.asyncStorage,onChange:w=>K("asyncStorage",w),dangerous:true,detected:i?.asyncStorage}),h(d,{style:u.divider}),h(pe,{label:"MMKV",description:"Clear MMKV storage (preserves @buoy/* keys)",value:a.mmkv,onChange:w=>K("mmkv",w),dangerous:true,detected:i?.mmkv})]})]}),(a.asyncStorage||a.mmkv)&&x(d,{style:u.warningCard,children:[h(Ot,{size:16,color:m.color.warning}),x(d,{style:u.warningContent,children:[h(y,{style:u.warningTitle,children:"Storage Clearing Enabled"}),h(y,{style:u.warningText,children:"This will remove app data like settings and cached content. Auth tokens managed by @buoy/* are preserved."})]})]})]})}),!I&&x(H,{testID:"buoy-impersonate-restore-defaults",style:u.restoreButton,onPress:J,children:[h(En,{size:14,color:m.color.textSecondary}),h(y,{style:u.restoreButtonText,children:"Restore Defaults"})]}),h(ce,{title:"How It Works",icon:Hn,defaultOpen:false,variant:"bordered",children:x(d,{style:u.sectionContent,children:[h(y,{style:u.infoText,children:"When impersonation is enabled, the configured header is automatically added to all outgoing fetch and XMLHttpRequest calls."}),h(y,{style:[u.infoText,u.infoTextSpaced],children:"Your backend should check for this header and return data for the specified user ID instead of the authenticated user."}),x(d,{style:u.codeBlock,children:[h(y,{style:u.codeComment,children:"// Example request header"}),x(y,{style:u.codeText,children:[l||"x-impersonate-user-id",": ",h(y,{style:u.codeValue,children:"user_123"})]})]})]})}),h(ce,{title:"Export Configuration",icon:Wt,defaultOpen:false,variant:"bordered",children:x(d,{style:u.sectionContent,children:[h(y,{style:u.infoText,children:"Copy current settings to use in createImpersonateTool()."}),h(d,{style:u.dataViewerContainer,children:h(Nn,{title:"",data:re,showTypeFilter:true,rawMode:true,initialExpanded:true})}),h(H,{style:u.copyButton,onPress:v,children:S?x(We,{children:[h(Oe,{size:14,color:de.success}),h(y,{style:[u.copyButtonText,u.copySuccessText],children:"Copied!"})]}):x(We,{children:[h(Wt,{size:14,color:m.color.accent}),h(y,{style:u.copyButtonText,children:"Copy Config"})]})})]})})]})}var u=j.create({container:{flex:1},contentContainer:{padding:16,gap:12,paddingBottom:32},actionBar:{backgroundColor:m.color.accentSoft,borderRadius:10,borderWidth:1,borderColor:m.color.accentBorder,padding:12},actionBarContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},unsavedText:{fontSize:13,fontWeight:"500",color:m.color.accent},actionButtons:{flexDirection:"row",gap:8},saveButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:m.color.accent,paddingHorizontal:14,paddingVertical:8,borderRadius:6},saveButtonText:{fontSize:13,fontWeight:"600",color:m.color.onAccent},discardButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:m.color.surfaceElevated,paddingHorizontal:14,paddingVertical:8,borderRadius:6,borderWidth:1,borderColor:m.color.border},discardButtonText:{fontSize:13,fontWeight:"500",color:m.color.textSecondary},restoreButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,paddingVertical:12,borderRadius:8,borderWidth:1,borderColor:m.color.border,borderStyle:"dashed"},restoreButtonText:{fontSize:13,color:m.color.textSecondary},sectionContent:{paddingTop:8},sectionDescription:{fontSize:13,color:m.color.textSecondary,lineHeight:18,marginBottom:14},togglesCard:{backgroundColor:m.color.surface,borderRadius:10,borderWidth:1,borderColor:m.color.border,padding:4},dangerousCard:{borderColor:m.color.warning+"30"},advancedSection:{marginTop:16},advancedLabel:{fontSize:11,fontWeight:"600",color:m.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8,marginLeft:2},inputLabel:{fontSize:12,fontWeight:"600",color:m.color.textSecondary,marginBottom:8},input:{height:42,backgroundColor:m.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:m.color.border,paddingHorizontal:14,fontSize:14,color:m.color.text,fontFamily:Ke},inputFooter:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start",marginTop:8,gap:12},helperText:{flex:1,fontSize:12,color:m.color.textTertiary,lineHeight:16},resetLink:{paddingVertical:2},resetLinkText:{fontSize:12,color:m.color.accent,fontWeight:"500"},recommendedBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:m.color.accentSoft,paddingHorizontal:8,paddingVertical:3,borderRadius:4},recommendedText:{fontSize:10,fontWeight:"600",color:m.color.accent},detectedBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4},detectedBadgeActive:{backgroundColor:de.success+"15"},detectedBadgeInactive:{backgroundColor:m.color.textTertiary+"15"},detectedText:{fontSize:10,fontWeight:"600"},detectedTextActive:{color:de.success},detectedTextInactive:{color:m.color.textTertiary},divider:{height:1,backgroundColor:m.color.separator,marginHorizontal:12},warningCard:{marginTop:14,flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:m.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:m.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:13,fontWeight:"600",color:m.color.warning,marginBottom:4},warningText:{fontSize:12,color:m.color.textSecondary,lineHeight:17},infoText:{fontSize:13,color:m.color.textSecondary,lineHeight:19},infoTextSpaced:{marginTop:10},codeBlock:{marginTop:14,backgroundColor:m.color.bg,borderRadius:8,padding:14},codeComment:{fontSize:12,color:m.color.textTertiary,fontFamily:Ke,marginBottom:6},codeText:{fontSize:13,color:m.color.text,fontFamily:Ke},codeValue:{color:m.color.accent},dataViewerContainer:{marginTop:12,borderRadius:8,overflow:"hidden",borderWidth:1,borderColor:m.color.border},copyButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,marginTop:14,backgroundColor:m.color.accentSoft,paddingVertical:10,paddingHorizontal:16,borderRadius:8,borderWidth:1,borderColor:m.color.accentBorder},copyButtonText:{fontSize:13,fontWeight:"600",color:m.color.accent},copySuccessText:{color:de.success}});import{jsx as P,jsxs as Fe}from"react/jsx-runtime";var Un=zo,On=[{key:"search",label:"Search"},{key:"history",label:"History"},{key:"settings",label:"Settings"}],Kn=[{key:"search",label:"Search"},{key:"history",label:"History"}];function Me({visible:e,onClose:t,onBack:r,onMinimize:n,onSearchUsers:o,onClearReactQuery:i,onClearRedux:l,onClearAsyncStorage:p,onClearMMKV:a,showSettingsTab:c=true,inline:s=false}){let f=c?On:Kn,[S,b]=ke("search"),[C,I]=ke(false),ye=ct(false),[X,J]=ke(""),K=ct(null),{clearCache:re,isAvailable:v}=Go(),{resetStore:w,isAvailable:G}=on(),{clearStorage:W,isAvailable:Ce}=cn(),Jt=i??re??void 0,Gt=l??w??void 0,Zt=p??W??void 0,er={reactQuery:!!i||v,redux:!!l||G,asyncStorage:!!p||Ce,mmkv:!!a},{isActive:tr,currentUser:Je,headerKey:rr,dataNukeSettings:or,showBanner:nr,searchQuery:ar,searchResults:sr,isSearching:ir,searchError:lr,searchUsers:Ge,startImpersonation:Ze,stopImpersonation:et,updateHeaderKey:tt,updateDataNukeSettings:rt,updateShowBanner:Ie,history:cr,removeFromHistory:dr,clearHistory:ur}=Rt({onSearchUsers:o,onClearReactQuery:Jt,onClearRedux:Gt,onClearAsyncStorage:Zt,onClearMMKV:a});dt(()=>{C&&K.current&&setTimeout(()=>{K.current?.focus()},100)},[C]),dt(()=>{!c&&S==="settings"&&b("search")},[c,S]);let hr=oe(_=>{J(_)},[]),pr=oe(()=>{X.trim()&&Ge(X.trim()),I(false)},[X,Ge]),ot=oe(async _=>{await Ze(_)},[Ze]),gr=oe(async(_,yr,fr)=>{await tt(_),await rt(yr),await Ie(fr)},[tt,rt,Ie]),mr=oe(_=>{b(_),I(false)},[]),nt=()=>Fe(ae,{children:[r&&P(ae.Navigation,{onBack:r}),P(ae.Content,{title:"",children:C?P(ae.Search,{value:X,onChangeText:hr,onCancel:()=>{J(""),I(false)},onDismiss:()=>I(false),dismissOnBlur:true,placeholder:"Search by email, name, or ID...",iconSize:14,testID:"buoy-impersonate-search-input",inputProps:{onSubmitEditing:pr}}):P(Lo,{tabs:f,activeTab:S,onTabChange:mr,testIDPrefix:"buoy-impersonate-tab"})}),P(ae.Actions,{children:S==="search"&&!C&&P(H,{testID:"buoy-impersonate-search-toggle",onPress:()=>I(true),style:ve.headerActionButton,children:P(Uo,{size:14,color:vt.color.textSecondary})})})]});if(!e)return null;let at=Fe(d,{style:ve.container,children:[S==="search"&&P(Lt,{currentUser:Je,isActive:tr,searchQuery:ar,searchResults:sr,isSearching:ir,searchError:lr,onSelectUser:ot,onStopImpersonation:et,searchAvailable:!!o}),S==="history"&&P(Ut,{history:cr,currentUserId:Je?.id??null,onSelectUser:ot,onStopImpersonation:et,onRemoveFromHistory:dr,onClearHistory:ur}),S==="settings"&&P(jt,{headerKey:rr,settings:or,showBanner:nr,onSave:gr,onShowBannerChange:Ie,detectionStatus:er})]});return s?P(wt,{children:Fe(d,{style:ve.inlineRoot,children:[P(d,{style:ve.inlineHeader,...Oo,children:nt()}),at]})}):P(wt,{children:P(Un,{visible:e,onClose:t,onMinimize:n,header:{showToggleButton:true,customContent:nt()},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:at})})}function Wn(e){return P(Me,{...e,inline:true,visible:true,onClose:()=>{}})}var ve=j.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:No.border,backgroundColor:"transparent"},container:{flex:1},headerActionButton:{width:28,height:28,borderRadius:6,backgroundColor:vt.color.buttonSurface,justifyContent:"center",alignItems:"center"}});import{useSyncExternalStore as Ft}from"react";import{buoyColors as we,X as jn,PowerToggleButton as Fn}from"@buoy-gg/shared-ui/web";import{jsx as q,jsxs as Ve}from"react/jsx-runtime";function $e({onPress:e,onStopPress:t,position:r="top",offset:n=50}){let o=Ft(g.subscribe,g.getSnapshot,g.getSnapshot);if(!o.isActive||!o.currentUser||!o.showBanner)return null;let i=async()=>{console.log("[Buoy]","[impersonate] banner pause/resume pressed"),o.isPaused?await g.resumeImpersonation():await g.pauseImpersonation()},l=o.currentUser.displayName||o.currentUser.email||o.currentUser.id,p=r==="top"?{top:n}:{bottom:n},a=async()=>{console.log("[Buoy]","[impersonate] banner STOP pressed"),await g.stopImpersonation()};return q(d,{style:[V.container,p],children:Ve(d,{testID:"buoy-impersonate-banner",style:V.banner,children:[Ve(H,{testID:"buoy-impersonate-banner-open",style:V.userSection,onPress:e,activeOpacity:.7,children:[q(Le,{userId:o.currentUser.id,name:l,size:"small",showActiveIndicator:false}),q(y,{style:[V.userName,o.isPaused&&V.userNamePaused],numberOfLines:1,children:l})]}),q(Fn,{isEnabled:!o.isPaused,onToggle:i,size:"small",accessibilityLabel:"Toggle impersonation",testID:"buoy-impersonate-banner-toggle"}),q(H,{testID:"buoy-impersonate-banner-stop",accessibilityLabel:"Stop impersonating",style:V.closeButton,onPress:a,activeOpacity:.7,children:q(jn,{size:12,color:"rgba(255, 255, 255, 0.5)"})})]})})}function Mn({onPress:e}){let t=Ft(g.subscribe,g.getSnapshot,g.getSnapshot);return!t.isActive||!t.currentUser?null:Ve(H,{style:V.minimalBanner,onPress:e,activeOpacity:.8,children:[q(d,{style:V.minimalDot}),q(y,{style:V.minimalText,children:"IMP"})]})}var V=j.create({container:{position:"absolute",left:0,right:0,alignItems:"center",zIndex:9999,pointerEvents:"box-none"},banner:{flexDirection:"row",alignItems:"center",backgroundColor:"rgba(20, 20, 20, 0.94)",borderWidth:1,borderColor:we.success+"40",borderRadius:22,paddingVertical:7,paddingLeft:7,paddingRight:10,gap:10,marginTop:3,shadowColor:"#000",shadowOffset:{width:0,height:6},shadowOpacity:.3,shadowRadius:14,elevation:10},userSection:{flexDirection:"row",alignItems:"center",gap:10},userName:{fontSize:14,fontWeight:"600",color:"#fff",maxWidth:180},userNamePaused:{opacity:.6},closeButton:{width:22,height:22,borderRadius:11,backgroundColor:"rgba(128, 128, 128, 0.16)",alignItems:"center",justifyContent:"center",marginLeft:-4},minimalBanner:{position:"absolute",top:60,right:16,flexDirection:"row",alignItems:"center",backgroundColor:"rgba(26, 26, 26, 0.92)",borderWidth:1,borderColor:we.success+"35",borderRadius:12,paddingVertical:5,paddingHorizontal:10,gap:5,zIndex:9999,shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.2,shadowRadius:6,elevation:4},minimalDot:{width:6,height:6,borderRadius:3,backgroundColor:we.success},minimalText:{fontSize:10,fontWeight:"700",color:we.success,letterSpacing:.5}});import{hasAccountAccess as Vn,isOverWireBudget as $n}from"@buoy-gg/shared-ui/web";var Xe=null;function Xn(e){Xe=e}var Qe=2*1024,Qn=16*1024,Mt=Object.freeze({__buoyOmitted:"user-metadata",note:"User metadata stays on the device."});function qn(e){if(!e)return e;if(e.startsWith("data:")){let t=e.indexOf(",");return`${t>=0?e.slice(0,Math.min(t+1,64)):"data:"}[${e.length} chars]`}return e.length<=Qe?e:`${e.slice(0,Qe)}\u2026 [${e.length-Qe} more]`}function _n(e){if(!e)return e;let t=typeof e.role=="string"?e.role:void 0;return $n(e,Qn)?t?{role:t,...Mt}:{...Mt}:e}function qe(e){return{...e,avatarUrl:qn(e.avatarUrl),metadata:_n(e.metadata)}}function Vt(e){return{...e,currentUser:e.currentUser?qe(e.currentUser):null,history:e.history.map(t=>({...t,user:qe(t.user)}))}}var _e=new Map;function $t(e){for(let t of e)t&&typeof t=="object"&&t.id&&_e.set(String(t.id),t)}function Yn(e){let t=_e.get(e);if(t)return t;let r=g.getState();return r.currentUser?.id===e?r.currentUser:r.history.find(n=>n.user.id===e)?.user}function Xt(e){if(!e||typeof e!="object"||!e.id)return false;if(_e.has(String(e.id)))return true;let t=g.getState();return t.currentUser?.id===e.id?true:t.history.some(r=>r.user.id===e.id)}async function Jn(e,t){let r=T(t.userId),n=r??T(t.user?.id),o=(T(t.email)??T(t.user?.email))?.toLowerCase(),i=[T(t.user?.name),T(t.user?.displayName),T(t.query)].map(b=>b?.toLowerCase()).filter(b=>!!b),l=[o,n,T(t.query),T(t.user?.name),T(t.user?.displayName)].filter((b,C,I)=>!!b&&I.indexOf(b)===C),p=new Map;for(let b of l){let C;try{C=await e(b)}catch{continue}if(Array.isArray(C)){$t(C);for(let I of C)I?.id&&p.set(String(I.id),I)}}let a=[...p.values()],c=b=>T(b.email)?.toLowerCase(),s=n?a.filter(b=>String(b.id)===n):[],f=o?a.filter(b=>c(b)===o):[];if(s.length===1&&f.length&&f[0].id!==s[0].id)throw new Error(`The id ${n} and the email ${o} belong to different users. Pass one of them.`);if(s.length===1)return s[0];if(r)return;if(f.length===1)return f[0];if(n||o)return;let S=a.filter(b=>{let C=b;return[T(C.displayName),T(C.name)].some(I=>I&&i.includes(I.toLowerCase()))});if(S.length>1)throw new Error(`${S.length} users are named that (${S.map(b=>b.id).join(", ")}). Pass the user's id or email.`);return S[0]}function T(e){return typeof e=="string"&&e.trim()?e.trim():typeof e=="number"?String(e):void 0}function Qt(e){return{searchUsers:async t=>{let r=String(t?.query??""),n=await e(r);return Array.isArray(n)&&$t(n),Array.isArray(n)?n.map(qe):n},startImpersonation:async t=>{let r=t??{},n=r.user,o=T(r.userId),i=T(n?.id);if(o&&i&&o!==i)throw new Error(`userId ${o} and user.id ${i} are different users. Pass one of them.`);let l=T(r.email)?.toLowerCase(),p=T(n?.email)?.toLowerCase();if(l&&p&&l!==p)throw new Error(`email ${l} and user.email ${p} are different users. Pass one of them.`);let a;if(n?.id&&Xt(n)&&r.userId===void 0&&r.email===void 0?a=Yn(String(n.id)):a=await Jn(e,r),!a||!Xt(a))throw new Error("That user isn't in this app's directory. Call searchUsers and impersonate one of its results \u2014 a user object that didn't come from search impersonates nobody.");let c=(T(r.email)??T(n?.email))?.toLowerCase(),s=T(a.email)?.toLowerCase();if(c&&s&&c!==s)throw new Error(`User ${a.id} has a different email than ${c}. Pass the id or the email of one user.`);return await g.startImpersonation(a),{ok:true,userId:a.id}},stopImpersonation:()=>g.stopImpersonation(),pauseImpersonation:()=>g.pauseImpersonation(),resumeImpersonation:()=>g.resumeImpersonation(),updateSettings:t=>{let r=t??{},n=r.settings??(["headerKey","ignorePatterns","showBanner","dataNukeSettings"].some(o=>o in r)?r:void 0);if(!n)throw new Error("updateSettings needs { settings: { headerKey?, ignorePatterns?, showBanner?, dataNukeSettings? } }.");return g.updateSettings(n)},removeFromHistory:t=>g.removeFromHistory(t.userId),clearHistory:()=>g.clearHistory()}}function Gn({onSearchUsers:e}){return{version:1,getSnapshot:()=>Vt(g.getState()),subscribe:t=>g.subscribe(t),actions:Qt(e)}}var Zn={dispose:()=>{Vn()||g.disposeAccountSession()},version:1,getSnapshot:()=>Vt(g.getState()),subscribe:e=>g.subscribe(e),actions:Qt(e=>{if(!Xe)throw new Error("No onSearchUsers configured \u2014 pass it to createImpersonateTool()");return Xe(e)})};import{ImpersonateIcon as qt,IMPERSONATE_ICON_COLOR as ea}from"@buoy-gg/shared-ui/web";import{jsx as _t}from"react/jsx-runtime";var Yt=false;async function ta(){if(!(typeof window>"u"||Yt)){Yt=true,console.log("[Buoy]","[impersonate] bootstrap: start"),O().isListening||O().startListening();try{let e=Ir();if(!e||typeof e.getItem!="function"){console.warn("[Buoy]","[impersonate] bootstrap: AsyncStorage shape unexpected",Object.keys(e??{}));return}let t={getItem:r=>e.getItem(r),setItem:(r,n)=>e.setItem(r,n)};g.setAsyncStorage(t),console.log("[Buoy]","[impersonate] bootstrap: AsyncStorage adapter installed"),await g.initializeAsync(t),console.log("[Buoy]","[impersonate] bootstrap: initializeAsync done")}catch(e){console.warn("[Buoy]","[impersonate] bootstrap: failed",e)}}}function ra(e){let{id:t="impersonate",name:r="IMPERSONATE",description:n="User impersonation for admin testing",defaults:o,showSettingsTab:i=true,onSearchUsers:l,onClearReactQuery:p,onClearRedux:a,onClearAsyncStorage:c,onClearMMKV:s}=e;return o&&g.setDeveloperDefaults(o),Xn(l??null),ta(),{id:t,name:r,description:n,slot:"both",icon:({size:f,slot:S})=>_t(qt,{size:S==="dial"?f*1.5:f,color:ea}),component:f=>_t(Me,{...f,onSearchUsers:l,onClearReactQuery:p,onClearRedux:a,onClearAsyncStorage:c,onClearMMKV:s,showSettingsTab:i}),props:{enableSharedModalDimensions:false},Banner:$e}}import{jsx as oa}from"react/jsx-runtime";function na(){return oa($e,{position:"top",offset:50})}import{buoyColors as ge,night as me,X as aa}from"@buoy-gg/shared-ui/web";import{jsx as Y,jsxs as xe}from"react/jsx-runtime";function sa({user:e,onStopImpersonation:t}){let r=e.displayName||e.email||e.id;return xe(d,{style:$.container,children:[xe(d,{style:$.userSection,children:[Y(Le,{userId:e.id,name:r,size:"small",showActiveIndicator:false}),Y(d,{style:$.userInfo,children:Y(y,{style:$.userName,numberOfLines:1,children:r})})]}),xe(d,{style:$.statusPill,children:[Y(d,{style:$.pulseDot}),Y(y,{style:$.statusText,children:"Active"})]}),xe(H,{style:$.stopButton,onPress:t,activeOpacity:.7,children:[Y(aa,{size:12,color:me.color.danger}),Y(y,{style:$.stopButtonText,children:"Stop"})]})]})}var $=j.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:10,paddingHorizontal:16,backgroundColor:ge.success+"10",borderBottomWidth:1,borderBottomColor:ge.success+"25",gap:12},userSection:{flexDirection:"row",alignItems:"center",flex:1,gap:10,minWidth:0},userInfo:{flex:1,minWidth:0},userName:{fontSize:14,fontWeight:"600",color:me.color.text},statusPill:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:ge.success+"20",paddingHorizontal:10,paddingVertical:5,borderRadius:12},pulseDot:{width:6,height:6,borderRadius:3,backgroundColor:ge.success},statusText:{fontSize:11,fontWeight:"600",color:ge.success,textTransform:"uppercase",letterSpacing:.5},stopButton:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:12,paddingVertical:6,backgroundColor:me.color.dangerSoft,borderRadius:6,borderWidth:1,borderColor:me.color.danger+"30"},stopButtonText:{fontSize:12,fontWeight:"600",color:me.color.danger}});import{useCallback as Ye,useSyncExternalStore as ia}from"react";function la(){let e=ia(g.subscribe,g.getSnapshot,g.getSnapshot),t=Ye(async o=>{await g.quickSwitch(o)},[]),r=Ye(async o=>{await g.removeFromHistory(o)},[]),n=Ye(async()=>{await g.clearHistory()},[]);return{history:e.history,currentUserId:e.currentUser?.id??null,quickSwitch:t,removeFromHistory:r,clearHistory:n}}export{jt as DataNukeSettingsComponent,$e as ImpersonateBanner,Mn as ImpersonateBannerMinimal,Ut as ImpersonateHistoryList,qt as ImpersonateIcon,Me as ImpersonateModal,na as ImpersonateOverlay,sa as ImpersonateStatusBar,Wn as ImpersonateToolView,Lt as UserSearchView,Gn as createImpersonateSyncAdapter,ra as createImpersonateTool,Qo as getImpersonatedUserId,O as impersonateListener,g as impersonateStore,Zn as impersonateSyncAdapter,Xo as isImpersonating,kt as setImpersonateConfig,Vo as startImpersonateListener,$o as stopImpersonateListener,Rt as useImpersonate,la as useImpersonateHistory};
10
+ },`;try{await zn(w),b(true),setTimeout(()=>b(false),2e3)}catch{}};return x(ft,{keyboardShouldPersistTaps:"handled",testID:"buoy-impersonate-settings-scroll",style:u.container,contentContainerStyle:u.contentContainer,children:[C&&h(d,{style:u.actionBar,children:x(d,{style:u.actionBarContent,children:[h(y,{style:u.unsavedText,children:"Unsaved changes"}),x(d,{style:u.actionButtons,children:[x(H,{testID:"buoy-impersonate-discard",style:u.discardButton,onPress:X,children:[h(Kt,{size:14,color:m.color.textSecondary}),h(y,{style:u.discardButtonText,children:"Discard"})]}),x(H,{testID:"buoy-impersonate-save",style:u.saveButton,onPress:ye,children:[h(Oe,{size:14,color:m.color.onAccent}),h(y,{style:u.saveButtonText,children:"Save"})]})]})]})}),h(ce,{title:"Header Configuration",icon:An,defaultOpen:true,variant:"bordered",children:x(d,{style:u.sectionContent,children:[h(y,{style:u.inputLabel,children:"Header Key"}),h(yt,{testID:"buoy-impersonate-header-key",style:u.input,value:l,onChangeText:p,placeholder:"x-impersonate-user-id",placeholderTextColor:m.color.placeholder,autoCapitalize:"none",autoCorrect:false}),x(d,{style:u.inputFooter,children:[h(y,{style:u.helperText,children:"The HTTP header key used for impersonation. Value will be the user ID."}),l!==ue&&h(H,{onPress:()=>p(ue),style:u.resetLink,children:h(y,{style:u.resetLinkText,children:"Reset to default"})})]})]})}),h(ce,{title:"Display",icon:Dn,defaultOpen:true,variant:"bordered",children:h(d,{style:u.sectionContent,children:h(d,{style:u.togglesCard,children:h(pe,{label:"Floating Banner",description:"Show a floating banner when impersonation is active",value:s,onChange:w=>{f(w),o(w)},recommended:true,testID:"buoy-impersonate-show-banner"})})})}),h(ce,{title:"Data Clearing",icon:Ot,defaultOpen:true,variant:"bordered",children:x(d,{style:u.sectionContent,children:[h(y,{style:u.sectionDescription,children:"Choose what data to clear when impersonation starts or stops. This ensures you see fresh data for the impersonated user."}),x(d,{style:u.togglesCard,children:[h(pe,{label:"React Query",description:"Clear query cache and cancel pending queries",value:a.reactQuery,onChange:w=>K("reactQuery",w),recommended:true,detected:i?.reactQuery}),h(d,{style:u.divider}),h(pe,{label:"Redux",description:"Reset Redux store to initial state",value:a.redux,onChange:w=>K("redux",w),recommended:true,detected:i?.redux})]}),x(d,{style:u.advancedSection,children:[h(y,{style:u.advancedLabel,children:"Storage Options"}),x(d,{style:[u.togglesCard,u.dangerousCard],children:[h(pe,{label:"AsyncStorage",description:"Clear app data (preserves @buoy/* keys)",value:a.asyncStorage,onChange:w=>K("asyncStorage",w),dangerous:true,detected:i?.asyncStorage}),h(d,{style:u.divider}),h(pe,{label:"MMKV",description:"Clear MMKV storage (preserves @buoy/* keys)",value:a.mmkv,onChange:w=>K("mmkv",w),dangerous:true,detected:i?.mmkv})]})]}),(a.asyncStorage||a.mmkv)&&x(d,{style:u.warningCard,children:[h(Ot,{size:16,color:m.color.warning}),x(d,{style:u.warningContent,children:[h(y,{style:u.warningTitle,children:"Storage Clearing Enabled"}),h(y,{style:u.warningText,children:"This will remove app data like settings and cached content. Auth tokens managed by @buoy/* are preserved."})]})]})]})}),!I&&x(H,{testID:"buoy-impersonate-restore-defaults",style:u.restoreButton,onPress:J,children:[h(En,{size:14,color:m.color.textSecondary}),h(y,{style:u.restoreButtonText,children:"Restore Defaults"})]}),h(ce,{title:"How It Works",icon:Hn,defaultOpen:false,variant:"bordered",children:x(d,{style:u.sectionContent,children:[h(y,{style:u.infoText,children:"When impersonation is enabled, the configured header is automatically added to all outgoing fetch and XMLHttpRequest calls."}),h(y,{style:[u.infoText,u.infoTextSpaced],children:"Your backend should check for this header and return data for the specified user ID instead of the authenticated user."}),x(d,{style:u.codeBlock,children:[h(y,{style:u.codeComment,children:"// Example request header"}),x(y,{style:u.codeText,children:[l||"x-impersonate-user-id",": ",h(y,{style:u.codeValue,children:"user_123"})]})]})]})}),h(ce,{title:"Export Configuration",icon:Wt,defaultOpen:false,variant:"bordered",children:x(d,{style:u.sectionContent,children:[h(y,{style:u.infoText,children:"Copy current settings to use in createImpersonateTool()."}),h(d,{style:u.dataViewerContainer,children:h(Nn,{title:"",data:re,showTypeFilter:true,rawMode:true,initialExpanded:true})}),h(H,{style:u.copyButton,onPress:v,children:S?x(We,{children:[h(Oe,{size:14,color:de.success}),h(y,{style:[u.copyButtonText,u.copySuccessText],children:"Copied!"})]}):x(We,{children:[h(Wt,{size:14,color:m.color.accent}),h(y,{style:u.copyButtonText,children:"Copy Config"})]})})]})})]})}var u=j.create({container:{flex:1},contentContainer:{padding:16,gap:12,paddingBottom:32},actionBar:{backgroundColor:m.color.accentSoft,borderRadius:10,borderWidth:1,borderColor:m.color.accentBorder,padding:12},actionBarContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},unsavedText:{fontSize:13,fontWeight:"500",color:m.color.accent},actionButtons:{flexDirection:"row",gap:8},saveButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:m.color.accent,paddingHorizontal:14,paddingVertical:8,borderRadius:6},saveButtonText:{fontSize:13,fontWeight:"600",color:m.color.onAccent},discardButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:m.color.surfaceElevated,paddingHorizontal:14,paddingVertical:8,borderRadius:6,borderWidth:1,borderColor:m.color.border},discardButtonText:{fontSize:13,fontWeight:"500",color:m.color.textSecondary},restoreButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,paddingVertical:12,borderRadius:8,borderWidth:1,borderColor:m.color.border,borderStyle:"dashed"},restoreButtonText:{fontSize:13,color:m.color.textSecondary},sectionContent:{paddingTop:8},sectionDescription:{fontSize:13,color:m.color.textSecondary,lineHeight:18,marginBottom:14},togglesCard:{backgroundColor:m.color.surface,borderRadius:10,borderWidth:1,borderColor:m.color.border,padding:4},dangerousCard:{borderColor:m.color.warning+"30"},advancedSection:{marginTop:16},advancedLabel:{fontSize:11,fontWeight:"600",color:m.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8,marginLeft:2},inputLabel:{fontSize:12,fontWeight:"600",color:m.color.textSecondary,marginBottom:8},input:{height:42,backgroundColor:m.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:m.color.border,paddingHorizontal:14,fontSize:14,color:m.color.text,fontFamily:Ke},inputFooter:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start",marginTop:8,gap:12},helperText:{flex:1,fontSize:12,color:m.color.textTertiary,lineHeight:16},resetLink:{paddingVertical:2},resetLinkText:{fontSize:12,color:m.color.accent,fontWeight:"500"},recommendedBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:m.color.accentSoft,paddingHorizontal:8,paddingVertical:3,borderRadius:4},recommendedText:{fontSize:10,fontWeight:"600",color:m.color.accent},detectedBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4},detectedBadgeActive:{backgroundColor:de.success+"15"},detectedBadgeInactive:{backgroundColor:m.color.textTertiary+"15"},detectedText:{fontSize:10,fontWeight:"600"},detectedTextActive:{color:de.success},detectedTextInactive:{color:m.color.textTertiary},divider:{height:1,backgroundColor:m.color.separator,marginHorizontal:12},warningCard:{marginTop:14,flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:m.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:m.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:13,fontWeight:"600",color:m.color.warning,marginBottom:4},warningText:{fontSize:12,color:m.color.textSecondary,lineHeight:17},infoText:{fontSize:13,color:m.color.textSecondary,lineHeight:19},infoTextSpaced:{marginTop:10},codeBlock:{marginTop:14,backgroundColor:m.color.bg,borderRadius:8,padding:14},codeComment:{fontSize:12,color:m.color.textTertiary,fontFamily:Ke,marginBottom:6},codeText:{fontSize:13,color:m.color.text,fontFamily:Ke},codeValue:{color:m.color.accent},dataViewerContainer:{marginTop:12,borderRadius:8,overflow:"hidden",borderWidth:1,borderColor:m.color.border},copyButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,marginTop:14,backgroundColor:m.color.accentSoft,paddingVertical:10,paddingHorizontal:16,borderRadius:8,borderWidth:1,borderColor:m.color.accentBorder},copyButtonText:{fontSize:13,fontWeight:"600",color:m.color.accent},copySuccessText:{color:de.success}});import{jsx as P,jsxs as Fe}from"react/jsx-runtime";var Un=zo,On=[{key:"search",label:"Search"},{key:"history",label:"History"},{key:"settings",label:"Settings"}],Kn=[{key:"search",label:"Search"},{key:"history",label:"History"}];function Me({visible:e,onClose:t,onBack:r,onMinimize:n,onSearchUsers:o,onClearReactQuery:i,onClearRedux:l,onClearAsyncStorage:p,onClearMMKV:a,showSettingsTab:c=true,inline:s=false}){let f=c?On:Kn,[S,b]=ke("search"),[C,I]=ke(false),ye=ct(false),[X,J]=ke(""),K=ct(null),{clearCache:re,isAvailable:v}=Go(),{resetStore:w,isAvailable:G}=on(),{clearStorage:W,isAvailable:Ce}=cn(),Jt=i??re??void 0,Gt=l??w??void 0,Zt=p??W??void 0,er={reactQuery:!!i||v,redux:!!l||G,asyncStorage:!!p||Ce,mmkv:!!a},{isActive:tr,currentUser:Je,headerKey:rr,dataNukeSettings:or,showBanner:nr,searchQuery:ar,searchResults:sr,isSearching:ir,searchError:lr,searchUsers:Ge,startImpersonation:Ze,stopImpersonation:et,updateHeaderKey:tt,updateDataNukeSettings:rt,updateShowBanner:Ie,history:cr,removeFromHistory:dr,clearHistory:ur}=Rt({onSearchUsers:o,onClearReactQuery:Jt,onClearRedux:Gt,onClearAsyncStorage:Zt,onClearMMKV:a});dt(()=>{C&&K.current&&setTimeout(()=>{K.current?.focus()},100)},[C]),dt(()=>{!c&&S==="settings"&&b("search")},[c,S]);let hr=oe(_=>{J(_)},[]),pr=oe(()=>{X.trim()&&Ge(X.trim()),I(false)},[X,Ge]),ot=oe(async _=>{await Ze(_)},[Ze]),gr=oe(async(_,yr,fr)=>{await tt(_),await rt(yr),await Ie(fr)},[tt,rt,Ie]),mr=oe(_=>{b(_),I(false)},[]),nt=()=>Fe(ae,{children:[r&&P(ae.Navigation,{onBack:r}),P(ae.Content,{title:"",children:C?P(ae.Search,{value:X,onChangeText:hr,onCancel:()=>{J(""),I(false)},onDismiss:()=>I(false),dismissOnBlur:true,placeholder:"Search by email, name, or ID...",iconSize:14,testID:"buoy-impersonate-search-input",inputProps:{onSubmitEditing:pr}}):P(Lo,{tabs:f,activeTab:S,onTabChange:mr,testIDPrefix:"buoy-impersonate-tab"})}),P(ae.Actions,{children:S==="search"&&!C&&P(H,{testID:"buoy-impersonate-search-toggle",onPress:()=>I(true),style:ve.headerActionButton,children:P(Uo,{size:14,color:vt.color.textSecondary})})})]});if(!e)return null;let at=Fe(d,{style:ve.container,children:[S==="search"&&P(Lt,{currentUser:Je,isActive:tr,searchQuery:ar,searchResults:sr,isSearching:ir,searchError:lr,onSelectUser:ot,onStopImpersonation:et,searchAvailable:!!o}),S==="history"&&P(Ut,{history:cr,currentUserId:Je?.id??null,onSelectUser:ot,onStopImpersonation:et,onRemoveFromHistory:dr,onClearHistory:ur}),S==="settings"&&P(jt,{headerKey:rr,settings:or,showBanner:nr,onSave:gr,onShowBannerChange:Ie,detectionStatus:er})]});return s?P(wt,{children:Fe(d,{style:ve.inlineRoot,children:[P(d,{style:ve.inlineHeader,...Oo,children:nt()}),at]})}):P(wt,{children:P(Un,{visible:e,onClose:t,onMinimize:n,header:{showToggleButton:true,customContent:nt()},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:at})})}function Wn(e){return P(Me,{...e,inline:true,visible:true,onClose:()=>{}})}var ve=j.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:No.border,backgroundColor:"transparent"},container:{flex:1},headerActionButton:{width:28,height:28,borderRadius:6,backgroundColor:vt.color.buttonSurface,justifyContent:"center",alignItems:"center"}});import{useSyncExternalStore as Ft}from"react";import{buoyColors as we,X as jn,PowerToggleButton as Fn}from"@buoy-gg/shared-ui/web";import{jsx as q,jsxs as Ve}from"react/jsx-runtime";function $e({onPress:e,onStopPress:t,position:r="top",offset:n=50}){let o=Ft(g.subscribe,g.getSnapshot,g.getSnapshot);if(!o.isActive||!o.currentUser||!o.showBanner)return null;let i=async()=>{console.log("[Buoy]","[impersonate] banner pause/resume pressed"),o.isPaused?await g.resumeImpersonation():await g.pauseImpersonation()},l=o.currentUser.displayName||o.currentUser.email||o.currentUser.id,p=r==="top"?{top:n}:{bottom:n},a=async()=>{console.log("[Buoy]","[impersonate] banner STOP pressed"),await g.stopImpersonation()};return q(d,{style:[V.container,p],children:Ve(d,{testID:"buoy-impersonate-banner",style:V.banner,children:[Ve(H,{testID:"buoy-impersonate-banner-open",style:V.userSection,onPress:e,activeOpacity:.7,children:[q(Le,{userId:o.currentUser.id,name:l,size:"small",showActiveIndicator:false}),q(y,{style:[V.userName,o.isPaused&&V.userNamePaused],numberOfLines:1,children:l})]}),q(Fn,{isEnabled:!o.isPaused,onToggle:i,size:"small",accessibilityLabel:"Toggle impersonation",testID:"buoy-impersonate-banner-toggle"}),q(H,{testID:"buoy-impersonate-banner-stop",accessibilityLabel:"Stop impersonating",style:V.closeButton,onPress:a,activeOpacity:.7,children:q(jn,{size:12,color:"rgba(255, 255, 255, 0.5)"})})]})})}function Mn({onPress:e}){let t=Ft(g.subscribe,g.getSnapshot,g.getSnapshot);return!t.isActive||!t.currentUser?null:Ve(H,{style:V.minimalBanner,onPress:e,activeOpacity:.8,children:[q(d,{style:V.minimalDot}),q(y,{style:V.minimalText,children:"IMP"})]})}var V=j.create({container:{position:"absolute",left:0,right:0,alignItems:"center",zIndex:9999,pointerEvents:"box-none"},banner:{flexDirection:"row",alignItems:"center",backgroundColor:"rgba(20, 20, 20, 0.94)",borderWidth:1,borderColor:we.success+"40",borderRadius:22,paddingVertical:7,paddingLeft:7,paddingRight:10,gap:10,marginTop:3,shadowColor:"#000",shadowOffset:{width:0,height:6},shadowOpacity:.3,shadowRadius:14,elevation:10},userSection:{flexDirection:"row",alignItems:"center",gap:10},userName:{fontSize:14,fontWeight:"600",color:"#fff",maxWidth:180},userNamePaused:{opacity:.6},closeButton:{width:22,height:22,borderRadius:11,backgroundColor:"rgba(128, 128, 128, 0.16)",alignItems:"center",justifyContent:"center",marginLeft:-4},minimalBanner:{position:"absolute",top:60,right:16,flexDirection:"row",alignItems:"center",backgroundColor:"rgba(26, 26, 26, 0.92)",borderWidth:1,borderColor:we.success+"35",borderRadius:12,paddingVertical:5,paddingHorizontal:10,gap:5,zIndex:9999,shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.2,shadowRadius:6,elevation:4},minimalDot:{width:6,height:6,borderRadius:3,backgroundColor:we.success},minimalText:{fontSize:10,fontWeight:"700",color:we.success,letterSpacing:.5}});import{hasAccountAccess as Vn,isOverWireBudget as $n}from"@buoy-gg/shared-ui/web";var Xe=null;function Xn(e){Xe=e}var Qe=2*1024,Qn=16*1024,Mt=Object.freeze({__buoyOmitted:"user-metadata",note:"User metadata stays on the device."});function qn(e){if(!e)return e;if(e.startsWith("data:")){let t=e.indexOf(",");return`${t>=0?e.slice(0,Math.min(t+1,64)):"data:"}[${e.length} chars]`}return e.length<=Qe?e:`${e.slice(0,Qe)}\u2026 [${e.length-Qe} more]`}function _n(e){if(!e)return e;let t=typeof e.role=="string"?e.role:void 0;return $n(e,Qn)?t?{role:t,...Mt}:{...Mt}:e}function qe(e){return{...e,avatarUrl:qn(e.avatarUrl),metadata:_n(e.metadata)}}function Vt(e){return{...e,currentUser:e.currentUser?qe(e.currentUser):null,history:e.history.map(t=>({...t,user:qe(t.user)}))}}var _e=new Map;function $t(e){for(let t of e)t&&typeof t=="object"&&t.id&&_e.set(String(t.id),t)}function Yn(e){let t=_e.get(e);if(t)return t;let r=g.getState();return r.currentUser?.id===e?r.currentUser:r.history.find(n=>n.user.id===e)?.user}function Xt(e){if(!e||typeof e!="object"||!e.id)return false;if(_e.has(String(e.id)))return true;let t=g.getState();return t.currentUser?.id===e.id?true:t.history.some(r=>r.user.id===e.id)}async function Jn(e,t){let r=T(t.userId),n=r??T(t.user?.id),o=(T(t.email)??T(t.user?.email))?.toLowerCase(),i=[T(t.user?.name),T(t.user?.displayName),T(t.query)].map(b=>b?.toLowerCase()).filter(b=>!!b),l=[o,n,T(t.query),T(t.user?.name),T(t.user?.displayName)].filter((b,C,I)=>!!b&&I.indexOf(b)===C),p=new Map;for(let b of l){let C;try{C=await e(b)}catch{continue}if(Array.isArray(C)){$t(C);for(let I of C)I?.id&&p.set(String(I.id),I)}}let a=[...p.values()],c=b=>T(b.email)?.toLowerCase(),s=n?a.filter(b=>String(b.id)===n):[],f=o?a.filter(b=>c(b)===o):[];if(s.length===1&&f.length&&f[0].id!==s[0].id)throw new Error(`The id ${n} and the email ${o} belong to different users. Pass one of them.`);if(s.length===1)return s[0];if(r)return;if(f.length===1)return f[0];if(n||o)return;let S=a.filter(b=>{let C=b;return[T(C.displayName),T(C.name)].some(I=>I&&i.includes(I.toLowerCase()))});if(S.length>1)throw new Error(`${S.length} users are named that (${S.map(b=>b.id).join(", ")}). Pass the user's id or email.`);return S[0]}function T(e){return typeof e=="string"&&e.trim()?e.trim():typeof e=="number"?String(e):void 0}function Qt(e){return{searchUsers:async t=>{let r=String(t?.query??""),n=await e(r);return Array.isArray(n)&&$t(n),Array.isArray(n)?n.map(qe):n},startImpersonation:async t=>{let r=t??{},n=r.user,o=T(r.userId),i=T(n?.id);if(o&&i&&o!==i)throw new Error(`userId ${o} and user.id ${i} are different users. Pass one of them.`);let l=T(r.email)?.toLowerCase(),p=T(n?.email)?.toLowerCase();if(l&&p&&l!==p)throw new Error(`email ${l} and user.email ${p} are different users. Pass one of them.`);let a;if(n?.id&&Xt(n)&&r.userId===void 0&&r.email===void 0?a=Yn(String(n.id)):a=await Jn(e,r),!a||!Xt(a))throw new Error("That user isn't in this app's directory. Call searchUsers and impersonate one of its results \u2014 a user object that didn't come from search impersonates nobody.");let c=(T(r.email)??T(n?.email))?.toLowerCase(),s=T(a.email)?.toLowerCase();if(c&&s&&c!==s)throw new Error(`User ${a.id} has a different email than ${c}. Pass the id or the email of one user.`);return await g.startImpersonation(a),{ok:true,userId:a.id}},stopImpersonation:()=>g.stopImpersonation(),pauseImpersonation:()=>g.pauseImpersonation(),resumeImpersonation:()=>g.resumeImpersonation(),updateSettings:t=>{let r=t??{},n=r.settings??(["headerKey","ignorePatterns","showBanner","dataNukeSettings"].some(o=>o in r)?r:void 0);if(!n)throw new Error("updateSettings needs { settings: { headerKey?, ignorePatterns?, showBanner?, dataNukeSettings? } }.");return g.updateSettings(n)},removeFromHistory:t=>g.removeFromHistory(t.userId),clearHistory:()=>g.clearHistory()}}function Gn({onSearchUsers:e}){return{version:1,getSnapshot:()=>Vt(g.getState()),subscribe:t=>g.subscribe(t),actions:Qt(e)}}var Zn={dispose:()=>{Vn()||g.disposeAccountSession()},version:1,getSnapshot:()=>Vt(g.getState()),subscribe:e=>g.subscribe(e),actions:Qt(e=>{if(!Xe)throw new Error("No onSearchUsers configured \u2014 pass it to createImpersonateTool()");return Xe(e)})};import{ImpersonateIcon as qt,IMPERSONATE_ICON_COLOR as ea}from"@buoy-gg/shared-ui/web";import{jsx as _t}from"react/jsx-runtime";var Yt=false;async function ta(){if(!(typeof window>"u"||Yt)){Yt=true,console.log("[Buoy]","[impersonate] bootstrap: start"),O().isListening||O().startListening();try{let e=Ir();if(!e||typeof e.getItem!="function"){console.warn("[Buoy]","[impersonate] bootstrap: AsyncStorage shape unexpected",Object.keys(e??{}));return}let t={getItem:r=>e.getItem(r),setItem:(r,n)=>e.setItem(r,n)};g.setAsyncStorage(t),console.log("[Buoy]","[impersonate] bootstrap: AsyncStorage adapter installed"),await g.initializeAsync(t),console.log("[Buoy]","[impersonate] bootstrap: initializeAsync done")}catch(e){console.warn("[Buoy]","[impersonate] bootstrap: failed",e)}}}function ra(e){let{id:t="impersonate",name:r="IMPERSONATE",description:n="User impersonation for admin testing",defaults:o,showSettingsTab:i=true,onSearchUsers:l,onClearReactQuery:p,onClearRedux:a,onClearAsyncStorage:c,onClearMMKV:s}=e;return o&&g.setDeveloperDefaults(o),Xn(l??null),ta(),{id:t,name:r,description:n,slot:"both",icon:({size:f,slot:S})=>_t(qt,{size:S==="dial"?f*1.5:f,color:ea}),component:f=>_t(Me,{...f,onSearchUsers:l,onClearReactQuery:p,onClearRedux:a,onClearAsyncStorage:c,onClearMMKV:s,showSettingsTab:i}),props:{enableSharedModalDimensions:false},Banner:$e}}import{jsx as oa}from"react/jsx-runtime";function na(){return oa($e,{position:"top",offset:50})}import{buoyColors as ge,night as me,X as aa}from"@buoy-gg/shared-ui/web";import{jsx as Y,jsxs as xe}from"react/jsx-runtime";function sa({user:e,onStopImpersonation:t}){let r=e.displayName||e.email||e.id;return xe(d,{style:$.container,children:[xe(d,{style:$.userSection,children:[Y(Le,{userId:e.id,name:r,size:"small",showActiveIndicator:false}),Y(d,{style:$.userInfo,children:Y(y,{style:$.userName,numberOfLines:1,children:r})})]}),xe(d,{style:$.statusPill,children:[Y(d,{style:$.pulseDot}),Y(y,{style:$.statusText,children:"Active"})]}),xe(H,{style:$.stopButton,onPress:t,activeOpacity:.7,children:[Y(aa,{size:12,color:me.color.danger}),Y(y,{style:$.stopButtonText,children:"Stop"})]})]})}var $=j.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:10,paddingHorizontal:16,backgroundColor:ge.success+"10",borderBottomWidth:1,borderBottomColor:ge.success+"25",gap:12},userSection:{flexDirection:"row",alignItems:"center",flex:1,gap:10,minWidth:0},userInfo:{flex:1,minWidth:0},userName:{fontSize:14,fontWeight:"600",color:me.color.text},statusPill:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:ge.success+"20",paddingHorizontal:10,paddingVertical:5,borderRadius:12},pulseDot:{width:6,height:6,borderRadius:3,backgroundColor:ge.success},statusText:{fontSize:11,fontWeight:"600",color:ge.success,textTransform:"uppercase",letterSpacing:.5},stopButton:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:12,paddingVertical:6,backgroundColor:me.color.dangerSoft,borderRadius:6,borderWidth:1,borderColor:me.color.danger+"30"},stopButtonText:{fontSize:12,fontWeight:"600",color:me.color.danger}});import{useCallback as Ye,useSyncExternalStore as ia}from"react";function la(){let e=ia(g.subscribe,g.getSnapshot,g.getSnapshot),t=Ye(async o=>{await g.quickSwitch(o)},[]),r=Ye(async o=>{await g.removeFromHistory(o)},[]),n=Ye(async()=>{await g.clearHistory()},[]);return{history:e.history,currentUserId:e.currentUser?.id??null,quickSwitch:t,removeFromHistory:r,clearHistory:n}}export{jt as DataNukeSettingsComponent,$e as ImpersonateBanner,Mn as ImpersonateBannerMinimal,Ut as ImpersonateHistoryList,qt as ImpersonateIcon,Me as ImpersonateModal,na as ImpersonateOverlay,sa as ImpersonateStatusBar,Wn as ImpersonateToolView,Lt as UserSearchView,Gn as createImpersonateSyncAdapter,ra as createImpersonateTool,Qo as getImpersonatedUserId,O as impersonateListener,g as impersonateStore,Zn as impersonateSyncAdapter,Xo as isImpersonating,kt as setImpersonateConfig,Vo as startImpersonateListener,$o as stopImpersonateListener,Rt as useImpersonate,la as useImpersonateHistory};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/impersonate",
3
- "version": "7.0.76",
3
+ "version": "7.0.78",
4
4
  "description": "Configure impersonation headers for supported app requests. Your backend must authenticate and authorize user changes.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -34,7 +34,7 @@
34
34
  ],
35
35
  "sideEffects": false,
36
36
  "dependencies": {
37
- "@buoy-gg/shared-ui": "^7.0.76"
37
+ "@buoy-gg/shared-ui": "^7.0.78"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": "*"