"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 _CardWatermark = _interopRequireDefault(require("../misc/CardWatermark"));
var _theme = require("../../contexts/theme");
var _credential = require("../../utils/credential");
var _testable = require("../../utils/testable");
var _reactI18next = require("react-i18next");
var _helpers = require("../../utils/helpers");
var _ThemedText = require("../texts/ThemedText");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const paddingHorizontal = 24;
const paddingVertical = 16;
const logoHeight = 80;
const CredentialDetailPrimaryHeader = ({
  overlay,
  brandingOverlayType = _legacy.BrandingOverlayType.Branding10,
  credential
}) => {
  var _overlay$brandingOver, _overlay$metaOverlay, _overlay$metaOverlay2, _overlay$metaOverlay3, _overlay$metaOverlay4, _overlay$metaOverlay5, _overlay$metaOverlay6;
  const {
    t
  } = (0, _reactI18next.useTranslation)();
  const {
    ColorPallet
  } = (0, _theme.useTheme)();
  const {
    width,
    height
  } = (0, _reactNative.useWindowDimensions)();
  const styles = _reactNative.StyleSheet.create({
    primaryHeaderContainer: {
      paddingHorizontal,
      paddingVertical,
      overflow: 'hidden'
    },
    textContainer: {
      color: brandingOverlayType === _legacy.BrandingOverlayType.Branding10 ? (0, _credential.credentialTextColor)(ColorPallet, (_overlay$brandingOver = overlay.brandingOverlay) === null || _overlay$brandingOver === void 0 ? void 0 : _overlay$brandingOver.primaryBackgroundColor) : ColorPallet.brand.primary
    }
  });
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    testID: (0, _testable.testIdWithKey)('CredentialDetailsPrimaryHeader'),
    style: [styles.primaryHeaderContainer, {
      zIndex: -1
    }]
  }, /*#__PURE__*/React.createElement(_reactNative.View, null, ((_overlay$metaOverlay = overlay.metaOverlay) === null || _overlay$metaOverlay === void 0 ? void 0 : _overlay$metaOverlay.watermark) && brandingOverlayType === _legacy.BrandingOverlayType.Branding10 && /*#__PURE__*/React.createElement(_CardWatermark.default, {
    width: width,
    height: height,
    watermark: (_overlay$metaOverlay2 = overlay.metaOverlay) === null || _overlay$metaOverlay2 === void 0 ? void 0 : _overlay$metaOverlay2.watermark
  }), brandingOverlayType === _legacy.BrandingOverlayType.Branding10 && /*#__PURE__*/React.createElement(_ThemedText.ThemedText, {
    accessibilityLabel: `${t('Credentials.IssuedBy')} ${(_overlay$metaOverlay3 = overlay.metaOverlay) === null || _overlay$metaOverlay3 === void 0 ? void 0 : _overlay$metaOverlay3.issuer}`,
    testID: (0, _testable.testIdWithKey)('CredentialIssuer'),
    variant: "label",
    style: [styles.textContainer, {
      paddingLeft: logoHeight + paddingVertical,
      paddingBottom: paddingVertical,
      lineHeight: 19,
      opacity: 0.8
    }],
    numberOfLines: 1
  }, (_overlay$metaOverlay4 = overlay.metaOverlay) === null || _overlay$metaOverlay4 === void 0 ? void 0 : _overlay$metaOverlay4.issuer), /*#__PURE__*/React.createElement(_ThemedText.ThemedText, {
    accessibilityLabel: `${(_overlay$metaOverlay5 = overlay.metaOverlay) === null || _overlay$metaOverlay5 === void 0 ? void 0 : _overlay$metaOverlay5.name} ${t('Credentials.Credential')}`,
    testID: (0, _testable.testIdWithKey)('CredentialName'),
    style: [styles.textContainer, {
      lineHeight: 24
    }]
  }, (_overlay$metaOverlay6 = overlay.metaOverlay) === null || _overlay$metaOverlay6 === void 0 ? void 0 : _overlay$metaOverlay6.name), brandingOverlayType === _legacy.BrandingOverlayType.Branding11 && credential && /*#__PURE__*/React.createElement(_ThemedText.ThemedText, {
    testID: (0, _testable.testIdWithKey)('IssuedOn'),
    style: [styles.textContainer, {
      lineHeight: 24,
      marginTop: 8,
      fontSize: 14,
      color: ColorPallet.grayscale.mediumGrey
    }]
  }, t('CredentialDetails.IssuedOn'), " ", (0, _helpers.formatTime)(credential.createdAt, {
    includeHour: true
  }))));
};
var _default = exports.default = CredentialDetailPrimaryHeader;
//# sourceMappingURL=CredentialDetailPrimaryHeader.js.map