{"ast":null,"code":"import StyleSheet from \"react-native-web/dist/exports/StyleSheet\";\nimport color from 'color';\nimport { black, white } from \"../../styles/themes/v2/colors\";\nimport { splitStyles } from \"../../utils/splitStyles\";\nconst isDark = ({\n  dark,\n  backgroundColor\n}) => {\n  if (typeof dark === 'boolean') {\n    return dark;\n  }\n  if (backgroundColor === 'transparent') {\n    return false;\n  }\n  if (backgroundColor !== 'transparent') {\n    return !color(backgroundColor).isLight();\n  }\n  return false;\n};\nconst getButtonBackgroundColor = ({\n  isMode,\n  theme,\n  disabled,\n  customButtonColor\n}) => {\n  if (customButtonColor && !disabled) {\n    return customButtonColor;\n  }\n  if (theme.isV3) {\n    if (disabled) {\n      if (isMode('outlined') || isMode('text')) {\n        return 'transparent';\n      }\n      return theme.colors.surfaceDisabled;\n    }\n    if (isMode('elevated')) {\n      return theme.colors.elevation.level1;\n    }\n    if (isMode('contained')) {\n      return theme.colors.primary;\n    }\n    if (isMode('contained-tonal')) {\n      return theme.colors.secondaryContainer;\n    }\n  }\n  if (isMode('contained')) {\n    if (disabled) {\n      return color(theme.dark ? white : black).alpha(0.12).rgb().string();\n    }\n    return theme.colors.primary;\n  }\n  return 'transparent';\n};\nconst getButtonTextColor = ({\n  isMode,\n  theme,\n  disabled,\n  customTextColor,\n  backgroundColor,\n  dark\n}) => {\n  if (customTextColor && !disabled) {\n    return customTextColor;\n  }\n  if (theme.isV3) {\n    if (disabled) {\n      return theme.colors.onSurfaceDisabled;\n    }\n    if (typeof dark === 'boolean') {\n      if (isMode('contained') || isMode('contained-tonal') || isMode('elevated')) {\n        return isDark({\n          dark,\n          backgroundColor\n        }) ? white : black;\n      }\n    }\n    if (isMode('outlined') || isMode('text') || isMode('elevated')) {\n      return theme.colors.primary;\n    }\n    if (isMode('contained')) {\n      return theme.colors.onPrimary;\n    }\n    if (isMode('contained-tonal')) {\n      return theme.colors.onSecondaryContainer;\n    }\n  }\n  if (disabled) {\n    return color(theme.dark ? white : black).alpha(0.32).rgb().string();\n  }\n  if (isMode('contained')) {\n    return isDark({\n      dark,\n      backgroundColor\n    }) ? white : black;\n  }\n  return theme.colors.primary;\n};\nconst getButtonBorderColor = ({\n  isMode,\n  disabled,\n  theme\n}) => {\n  if (theme.isV3) {\n    if (disabled && isMode('outlined')) {\n      return theme.colors.surfaceDisabled;\n    }\n    if (isMode('outlined')) {\n      return theme.colors.outline;\n    }\n  }\n  if (isMode('outlined')) {\n    return color(theme.dark ? white : black).alpha(0.29).rgb().string();\n  }\n  return 'transparent';\n};\nconst getButtonBorderWidth = ({\n  isMode,\n  theme\n}) => {\n  if (theme.isV3) {\n    if (isMode('outlined')) {\n      return 1;\n    }\n  }\n  if (isMode('outlined')) {\n    return StyleSheet.hairlineWidth;\n  }\n  return 0;\n};\nexport const getButtonColors = ({\n  theme,\n  mode,\n  customButtonColor,\n  customTextColor,\n  disabled,\n  dark\n}) => {\n  const isMode = modeToCompare => {\n    return mode === modeToCompare;\n  };\n  const backgroundColor = getButtonBackgroundColor({\n    isMode,\n    theme,\n    disabled,\n    customButtonColor\n  });\n  const textColor = getButtonTextColor({\n    isMode,\n    theme,\n    disabled,\n    customTextColor,\n    backgroundColor,\n    dark\n  });\n  const borderColor = getButtonBorderColor({\n    isMode,\n    theme,\n    disabled\n  });\n  const borderWidth = getButtonBorderWidth({\n    isMode,\n    theme\n  });\n  return {\n    backgroundColor,\n    borderColor,\n    textColor,\n    borderWidth\n  };\n};\nexport const getButtonTouchableRippleStyle = (style, borderWidth = 0) => {\n  if (!style) return {};\n  const touchableRippleStyle = {};\n  const [, borderRadiusStyles] = splitStyles(style, style => style.startsWith('border') && style.endsWith('Radius'));\n  Object.keys(borderRadiusStyles).forEach(key => {\n    const value = style[key];\n    if (typeof value === 'number') {\n      const radius = value > 0 ? value - borderWidth : 0;\n      touchableRippleStyle[key] = radius;\n    }\n  });\n  return touchableRippleStyle;\n};","map":{"version":3,"names":["color","black","white","splitStyles","isDark","dark","backgroundColor","isLight","getButtonBackgroundColor","isMode","theme","disabled","customButtonColor","isV3","colors","surfaceDisabled","elevation","level1","primary","secondaryContainer","alpha","rgb","string","getButtonTextColor","customTextColor","onSurfaceDisabled","onPrimary","onSecondaryContainer","getButtonBorderColor","outline","getButtonBorderWidth","StyleSheet","hairlineWidth","getButtonColors","mode","modeToCompare","textColor","borderColor","borderWidth","getButtonTouchableRippleStyle","style","touchableRippleStyle","borderRadiusStyles","startsWith","endsWith","Object","keys","forEach","key","value","radius"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/react-native-paper/src/components/Button/utils.tsx"],"sourcesContent":["import { StyleSheet, type ViewStyle } from 'react-native';\n\nimport color from 'color';\n\nimport { black, white } from '../../styles/themes/v2/colors';\nimport type { InternalTheme } from '../../types';\nimport { splitStyles } from '../../utils/splitStyles';\n\nexport type ButtonMode =\n  | 'text'\n  | 'outlined'\n  | 'contained'\n  | 'elevated'\n  | 'contained-tonal';\n\ntype BaseProps = {\n  isMode: (mode: ButtonMode) => boolean;\n  theme: InternalTheme;\n  disabled?: boolean;\n};\n\nconst isDark = ({\n  dark,\n  backgroundColor,\n}: {\n  dark?: boolean;\n  backgroundColor?: string;\n}) => {\n  if (typeof dark === 'boolean') {\n    return dark;\n  }\n\n  if (backgroundColor === 'transparent') {\n    return false;\n  }\n\n  if (backgroundColor !== 'transparent') {\n    return !color(backgroundColor).isLight();\n  }\n\n  return false;\n};\n\nconst getButtonBackgroundColor = ({\n  isMode,\n  theme,\n  disabled,\n  customButtonColor,\n}: BaseProps & {\n  customButtonColor?: string;\n}) => {\n  if (customButtonColor && !disabled) {\n    return customButtonColor;\n  }\n\n  if (theme.isV3) {\n    if (disabled) {\n      if (isMode('outlined') || isMode('text')) {\n        return 'transparent';\n      }\n\n      return theme.colors.surfaceDisabled;\n    }\n\n    if (isMode('elevated')) {\n      return theme.colors.elevation.level1;\n    }\n\n    if (isMode('contained')) {\n      return theme.colors.primary;\n    }\n\n    if (isMode('contained-tonal')) {\n      return theme.colors.secondaryContainer;\n    }\n  }\n\n  if (isMode('contained')) {\n    if (disabled) {\n      return color(theme.dark ? white : black)\n        .alpha(0.12)\n        .rgb()\n        .string();\n    }\n\n    return theme.colors.primary;\n  }\n\n  return 'transparent';\n};\n\nconst getButtonTextColor = ({\n  isMode,\n  theme,\n  disabled,\n  customTextColor,\n  backgroundColor,\n  dark,\n}: BaseProps & {\n  customTextColor?: string;\n  backgroundColor: string;\n  dark?: boolean;\n}) => {\n  if (customTextColor && !disabled) {\n    return customTextColor;\n  }\n\n  if (theme.isV3) {\n    if (disabled) {\n      return theme.colors.onSurfaceDisabled;\n    }\n\n    if (typeof dark === 'boolean') {\n      if (\n        isMode('contained') ||\n        isMode('contained-tonal') ||\n        isMode('elevated')\n      ) {\n        return isDark({ dark, backgroundColor }) ? white : black;\n      }\n    }\n\n    if (isMode('outlined') || isMode('text') || isMode('elevated')) {\n      return theme.colors.primary;\n    }\n\n    if (isMode('contained')) {\n      return theme.colors.onPrimary;\n    }\n\n    if (isMode('contained-tonal')) {\n      return theme.colors.onSecondaryContainer;\n    }\n  }\n\n  if (disabled) {\n    return color(theme.dark ? white : black)\n      .alpha(0.32)\n      .rgb()\n      .string();\n  }\n\n  if (isMode('contained')) {\n    return isDark({ dark, backgroundColor }) ? white : black;\n  }\n\n  return theme.colors.primary;\n};\n\nconst getButtonBorderColor = ({ isMode, disabled, theme }: BaseProps) => {\n  if (theme.isV3) {\n    if (disabled && isMode('outlined')) {\n      return theme.colors.surfaceDisabled;\n    }\n\n    if (isMode('outlined')) {\n      return theme.colors.outline;\n    }\n  }\n\n  if (isMode('outlined')) {\n    return color(theme.dark ? white : black)\n      .alpha(0.29)\n      .rgb()\n      .string();\n  }\n\n  return 'transparent';\n};\n\nconst getButtonBorderWidth = ({\n  isMode,\n  theme,\n}: Omit<BaseProps, 'disabled'>) => {\n  if (theme.isV3) {\n    if (isMode('outlined')) {\n      return 1;\n    }\n  }\n\n  if (isMode('outlined')) {\n    return StyleSheet.hairlineWidth;\n  }\n\n  return 0;\n};\n\nexport const getButtonColors = ({\n  theme,\n  mode,\n  customButtonColor,\n  customTextColor,\n  disabled,\n  dark,\n}: {\n  theme: InternalTheme;\n  mode: ButtonMode;\n  customButtonColor?: string;\n  customTextColor?: string;\n  disabled?: boolean;\n  dark?: boolean;\n}) => {\n  const isMode = (modeToCompare: ButtonMode) => {\n    return mode === modeToCompare;\n  };\n\n  const backgroundColor = getButtonBackgroundColor({\n    isMode,\n    theme,\n    disabled,\n    customButtonColor,\n  });\n\n  const textColor = getButtonTextColor({\n    isMode,\n    theme,\n    disabled,\n    customTextColor,\n    backgroundColor,\n    dark,\n  });\n\n  const borderColor = getButtonBorderColor({ isMode, theme, disabled });\n\n  const borderWidth = getButtonBorderWidth({ isMode, theme });\n\n  return {\n    backgroundColor,\n    borderColor,\n    textColor,\n    borderWidth,\n  };\n};\n\ntype ViewStyleBorderRadiusStyles = Partial<\n  Pick<\n    ViewStyle,\n    | 'borderBottomEndRadius'\n    | 'borderBottomLeftRadius'\n    | 'borderBottomRightRadius'\n    | 'borderBottomStartRadius'\n    | 'borderTopEndRadius'\n    | 'borderTopLeftRadius'\n    | 'borderTopRightRadius'\n    | 'borderTopStartRadius'\n    | 'borderRadius'\n  >\n>;\nexport const getButtonTouchableRippleStyle = (\n  style?: ViewStyle,\n  borderWidth: number = 0\n): ViewStyleBorderRadiusStyles => {\n  if (!style) return {};\n  const touchableRippleStyle: ViewStyleBorderRadiusStyles = {};\n\n  const [, borderRadiusStyles] = splitStyles(\n    style,\n    (style) => style.startsWith('border') && style.endsWith('Radius')\n  );\n\n  (\n    Object.keys(borderRadiusStyles) as Array<keyof ViewStyleBorderRadiusStyles>\n  ).forEach((key) => {\n    const value = style[key as keyof ViewStyleBorderRadiusStyles];\n    if (typeof value === 'number') {\n      // Only subtract borderWidth if value is greater than 0\n      const radius = value > 0 ? value - borderWidth : 0;\n      touchableRippleStyle[key as keyof ViewStyleBorderRadiusStyles] = radius;\n    }\n  });\n  return touchableRippleStyle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