import _extends from "@babel/runtime/helpers/esm/extends";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["type", "className", "alt"];
import * as React from 'react';
import classnames from 'classnames';
import { getLogoUrl } from '../../logo-url';
export var TYPE = {
  BRAINLY: 'brainly',
  BRAINLY_INVERSE: 'brainly-inverse',
  BRAINLY_MOBILE: 'brainly-mobile',
  BRAINLY_MOBILE_INVERSE: 'brainly-mobile-inverse',
  EODEV: 'eodev',
  EODEV_INVERSE: 'eodev-inverse',
  EODEV_MOBILE: 'eodev-mobile',
  EODEV_MOBILE_INVERSE: 'eodev-mobile-inverse',
  NOSDEVOIRS: 'nosdevoirs',
  NOSDEVOIRS_INVERSE: 'nosdevoirs-inverse',
  NOSDEVOIRS_MOBILE: 'nosdevoirs-mobile',
  NOSDEVOIRS_MOBILE_INVERSE: 'nosdevoirs-mobile-inverse',
  ZNANIJA: 'znanija',
  ZNANIJA_INVERSE: 'znanija-inverse',
  ZNANIJA_MOBILE: 'znanija-mobile',
  ZNANIJA_MOBILE_INVERSE: 'znanija-mobile-inverse',
  ZNANIJA_PLUS: 'znanija-plus',
  ZNANIJA_PLUS_INVERSE: 'znanija-plus-inverse',
  ZNANIJA_PLUS_SMALL: 'znanija-plus-small',
  BRAINLY_PLUS: 'brainly-plus',
  BRAINLY_PLUS_INVERSE: 'brainly-plus-inverse',
  BRAINLY_TUTORING: 'brainly-tutoring',
  BRAINLY_TUTORING_INVERSE: 'brainly-tutoring-inverse',
  LOGO_TUTOR: 'logo-tutor',
  LOGO_MATH_SOLVER: 'logo-math-solver',
  LOGO_COMMUNITY_QA: 'logo-community-qa',
  LOGO_TEXTBOOK_DETECTIVE: 'logo-textbook-detective',
  BRAINLY_LOGOTYPE_TUTOR: 'brainly-logotype-tutor',
  BRAINLY_LOGOTYPE_MATH_SOLVER: 'brainly-logotype-math-solver',
  BRAINLY_LOGOTYPE_COMMUNITY_QA: 'brainly-logotype-community-qa',
  BRAINLY_LOGOTYPE_TEXTBOOK_DETECTIVE: 'brainly-logotype-textbook-detective'
};

function getDefaultAlt(type) {
  var replacers = [{
    regexp: /-mobile/g,
    newSubstr: ''
  }, {
    regexp: /-inverse/g,
    newSubstr: ''
  }, {
    regexp: /-small/g,
    newSubstr: ''
  }, {
    regexp: /-logotype-/g,
    newSubstr: ' '
  }, {
    regexp: /logo-/g,
    newSubstr: ''
  }, {
    regexp: /-/g,
    newSubstr: ' '
  }];
  return replacers.reduce(function (alt, _ref) {
    var regexp = _ref.regexp,
        newSubstr = _ref.newSubstr;
    return alt.replace(regexp, newSubstr);
  }, type);
}

var Logo = function Logo(_ref2) {
  var _ref2$type = _ref2.type,
      type = _ref2$type === void 0 ? TYPE.BRAINLY : _ref2$type,
      className = _ref2.className,
      alt = _ref2.alt,
      props = _objectWithoutProperties(_ref2, _excluded);

  var logoClass = classnames('sg-logo', _defineProperty({}, "sg-logo--".concat(type), type !== TYPE.BRAINLY), className);
  var logoPath = "".concat(getLogoUrl(type));
  var defaultAlt = getDefaultAlt(type);
  return /*#__PURE__*/React.createElement("div", _extends({}, props, {
    className: logoClass,
    "data-logotype": type
  }), /*#__PURE__*/React.createElement("img", {
    className: "sg-logo__image",
    src: logoPath,
    alt: alt !== null && alt !== void 0 ? alt : defaultAlt
  }));
};

export default Logo;