"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useButtonColorMap = exports.useButtonAnimatedStyles = void 0;
var _reactNativeReanimated = require("react-native-reanimated");
var _context = require("../../../context");
var _IOColors = require("../../../core/IOColors");
const useButtonColorMap = variant => {
  const theme = (0, _context.useIOTheme)();
  const mapColorStatesVariantSolid = {
    // Primary
    primary: {
      background: {
        default: _IOColors.IOColors[theme["interactiveElem-default"]],
        pressed: _IOColors.IOColors[theme["interactiveElem-pressed"]],
        disabled: _IOColors.IOColors[theme["interactiveElem-disabled"]]
      },
      foreground: {
        default: _IOColors.IOColors[theme["buttonText-default"]],
        pressed: _IOColors.IOColors[theme["buttonText-default"]],
        disabled: _IOColors.IOColors[theme["buttonText-disabled"]]
      }
    },
    // Danger
    danger: {
      background: {
        default: _IOColors.IOColors["error-600"],
        pressed: _IOColors.IOColors["error-500"],
        disabled: _IOColors.IOColors[theme["interactiveElem-disabled"]]
      },
      foreground: {
        default: _IOColors.IOColors[theme["buttonText-danger"]],
        pressed: _IOColors.IOColors[theme["buttonText-danger"]],
        disabled: _IOColors.IOColors[theme["buttonText-disabled"]]
      }
    },
    // Contrast
    contrast: {
      background: {
        default: _IOColors.IOColors.white,
        pressed: _IOColors.IOColors["blueIO-50"],
        disabled: _IOColors.IOColors["blueIO-50"]
      },
      foreground: {
        default: _IOColors.IOColors["blueIO-500"],
        pressed: _IOColors.IOColors["blueIO-500"],
        disabled: _IOColors.IOColors["blueIO-500"]
      }
    }
  };
  const mapColorStatesVariantOutline = {
    // Primary
    primary: {
      background: {
        default: (0, _IOColors.hexToRgba)(_IOColors.IOColors[theme["interactiveElem-pressed"]], 0),
        pressed: (0, _IOColors.hexToRgba)(_IOColors.IOColors[theme["interactiveElem-pressed"]], 0.1),
        disabled: "transparent"
      },
      foreground: {
        default: _IOColors.IOColors[theme["interactiveElem-default"]],
        pressed: _IOColors.IOColors[theme["interactiveElem-pressed"]],
        disabled: _IOColors.IOColors[theme["interactiveOutline-disabled"]]
      }
    },
    // Danger
    danger: {
      background: {
        default: (0, _IOColors.hexToRgba)(_IOColors.IOColors["error-600"], 0),
        pressed: (0, _IOColors.hexToRgba)(_IOColors.IOColors["error-600"], 0.1),
        disabled: "transparent"
      },
      foreground: {
        default: _IOColors.IOColors[theme.errorText],
        pressed: _IOColors.IOColors[theme.errorText],
        disabled: _IOColors.IOColors[theme["buttonText-disabled"]]
      }
    },
    // Contrast
    contrast: {
      background: {
        default: (0, _IOColors.hexToRgba)(_IOColors.IOColors["blueIO-600"], 0),
        pressed: (0, _IOColors.hexToRgba)(_IOColors.IOColors["blueIO-600"], 0.5),
        disabled: "transparent"
      },
      foreground: {
        default: _IOColors.IOColors.white,
        pressed: _IOColors.IOColors.white,
        disabled: _IOColors.IOColors["blueIO-200"]
      }
    }
  };
  const transparentLinkBackground = {
    default: "transparent",
    pressed: "transparent",
    disabled: "transparent"
  };
  const mapColorStatesVariantLink = {
    // Primary
    primary: {
      foreground: {
        default: _IOColors.IOColors[theme["interactiveElem-default"]],
        pressed: _IOColors.IOColors[theme["interactiveElem-pressed"]],
        disabled: (0, _IOColors.hexToRgba)(_IOColors.IOColors[theme["interactiveElem-default"]], 0.85)
      },
      background: transparentLinkBackground
    },
    // Danger
    danger: {
      foreground: {
        default: _IOColors.IOColors[theme.errorText],
        pressed: _IOColors.IOColors[theme.errorText],
        disabled: (0, _IOColors.hexToRgba)(_IOColors.IOColors[theme.errorText], 0.85)
      },
      background: transparentLinkBackground
    },
    // Contrast
    contrast: {
      foreground: {
        default: _IOColors.IOColors.white,
        pressed: (0, _IOColors.hexToRgba)(_IOColors.IOColors.white, 0.85),
        disabled: (0, _IOColors.hexToRgba)(_IOColors.IOColors.white, 0.5)
      },
      background: transparentLinkBackground
    }
  };
  const colorMap = {
    solid: mapColorStatesVariantSolid,
    outline: mapColorStatesVariantOutline,
    link: mapColorStatesVariantLink
  };
  return colorMap[variant];
};
exports.useButtonColorMap = useButtonColorMap;
const useButtonAnimatedStyles = (variant, color, progress) => {
  const mapColorStates = useButtonColorMap(variant);

  // Interpolate animation values from `isPressed` values
  const pressedAnimationStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
    // `link` variant doesn't need this animated style
    if (variant === "link") {
      return {};
    }
    const backgroundColor = (0, _reactNativeReanimated.interpolateColor)(progress.value, [0, 1], [mapColorStates[color].background.default, mapColorStates[color].background.pressed]);
    const borderColor = (0, _reactNativeReanimated.interpolateColor)(progress.value, [0, 1], [mapColorStates[color].foreground.default, mapColorStates[color].foreground.pressed]);
    return variant === "outline" ? {
      backgroundColor,
      borderColor
    } : {
      backgroundColor
    };
  });
  const pressedColorLabelAnimationStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
    color: (0, _reactNativeReanimated.interpolateColor)(progress.value, [0, 1], [mapColorStates[color].foreground.default, mapColorStates[color].foreground.pressed])
  }));
  const iconColorAnimatedStyle = (0, _reactNativeReanimated.useAnimatedProps)(() => ({
    color: (0, _reactNativeReanimated.interpolateColor)(progress.value, [0, 1], [mapColorStates[color]?.foreground?.default, mapColorStates[color]?.foreground?.pressed])
  }));
  return {
    buttonAnimatedStyle: pressedAnimationStyle,
    labelAnimatedStyle: pressedColorLabelAnimationStyle,
    iconColorAnimatedStyle
  };
};
exports.useButtonAnimatedStyles = useButtonAnimatedStyles;
//# sourceMappingURL=styles.js.map