"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
var _legacy = require("@hyperledger/aries-oca/build/legacy");
var _theme = require("../../contexts/theme");
var _credential = require("../../utils/credential");
var _react = require("react");
var _ThemedText = require("../texts/ThemedText");
const CredentialCardLogo = ({
  overlay,
  brandingOverlayType = _legacy.BrandingOverlayType.Branding10
}) => {
  var _overlay$brandingOver, _overlay$brandingOver2, _overlay$brandingOver3, _overlay$brandingOver4;
  const {
    CredentialCardShadowTheme
  } = (0, _theme.useTheme)();
  const {
    fontScale
  } = (0, _reactNative.useWindowDimensions)();
  const logoHeight = brandingOverlayType === _legacy.BrandingOverlayType.Branding10 ? 80 : 48;
  const paddingHorizontal = 24;
  const isBranding11 = brandingOverlayType === _legacy.BrandingOverlayType.Branding11;
  const textColor = (_overlay$brandingOver = overlay.brandingOverlay) !== null && _overlay$brandingOver !== void 0 && _overlay$brandingOver.secondaryBackgroundColor && overlay.brandingOverlay.secondaryBackgroundColor !== '' ? overlay.brandingOverlay.secondaryBackgroundColor : (_overlay$brandingOver2 = overlay.brandingOverlay) === null || _overlay$brandingOver2 === void 0 ? void 0 : _overlay$brandingOver2.primaryBackgroundColor;
  const logoText = (0, _react.useMemo)(() => {
    var _overlay$metaOverlay2, _overlay$metaOverlay3;
    if (brandingOverlayType === _legacy.BrandingOverlayType.Branding11) {
      var _overlay$metaOverlay;
      return (((_overlay$metaOverlay = overlay.metaOverlay) === null || _overlay$metaOverlay === void 0 ? void 0 : _overlay$metaOverlay.issuer) ?? 'I').charAt(0).toUpperCase();
    }
    return (((_overlay$metaOverlay2 = overlay.metaOverlay) === null || _overlay$metaOverlay2 === void 0 ? void 0 : _overlay$metaOverlay2.name) ?? ((_overlay$metaOverlay3 = overlay.metaOverlay) === null || _overlay$metaOverlay3 === void 0 ? void 0 : _overlay$metaOverlay3.issuer) ?? 'C').charAt(0).toUpperCase();
  }, [brandingOverlayType, overlay]);
  const styles = _reactNative.StyleSheet.create({
    logoContainer: {
      width: logoHeight * (fontScale > 1.7 ? 1.2 : 1),
      height: logoHeight * (fontScale > 1.7 ? 1.2 : 1),
      backgroundColor: '#ffffff',
      borderRadius: 8,
      justifyContent: 'center',
      alignItems: 'center',
      ...(brandingOverlayType === _legacy.BrandingOverlayType.Branding10 && {
        top: -0.5 * logoHeight,
        left: paddingHorizontal,
        marginBottom: -1 * logoHeight,
        ...CredentialCardShadowTheme
      })
    }
  });
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.logoContainer
  }, (_overlay$brandingOver3 = overlay.brandingOverlay) !== null && _overlay$brandingOver3 !== void 0 && _overlay$brandingOver3.logo ? /*#__PURE__*/React.createElement(_reactNative.Image, {
    source: (0, _credential.toImageSource)((_overlay$brandingOver4 = overlay.brandingOverlay) === null || _overlay$brandingOver4 === void 0 ? void 0 : _overlay$brandingOver4.logo),
    style: {
      resizeMode: 'cover',
      width: logoHeight,
      height: logoHeight,
      borderRadius: 8
    }
  }) : /*#__PURE__*/React.createElement(_ThemedText.ThemedText, {
    variant: "title",
    style: {
      fontSize: 0.5 * logoHeight,
      color: isBranding11 ? textColor : '#000'
    },
    accessible: false
  }, logoText));
};
var _default = exports.default = CredentialCardLogo;
//# sourceMappingURL=CredentialCardLogo.js.map