import { __extends, __decorate, __metadata } from 'tslib';
import { Prop, Component } from 'vue-property-decorator';
import BaseComponent from '../../BaseComponent.js';
import { classNamesFunction, getRTL, getInitials } from '@uifabric-vue/utilities';
import { mergeStyles } from '@uifabric/merge-styles';
import { getPersonaInitialsColor } from '../PersonaInitialsColor.js';
import { PersonaSize, PersonaPresence as PersonaPresence$1 } from '../Persona.types.js';
import { PersonaPresence } from '../PersonaPresence/index.js';
import { sizeToPixels } from '../PersonaConsts.js';
import { Image } from '../../Image/index.js';
import { ImageFit } from '../../Image/Image.types.js';
import { Icon } from '../../Icon/Icon.js';

var getClassNames = classNamesFunction({
  cacheSize: 100
});
var PersonaCoinBase = function(_super) {
  __extends(PersonaCoinBase2, _super);
  function PersonaCoinBase2() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.mergeStyles = mergeStyles;
    _this.getPersonaInitialsColor = getPersonaInitialsColor;
    _this.PersonaSize = PersonaSize;
    _this.ImageFit = ImageFit;
    return _this;
  }
  Object.defineProperty(PersonaCoinBase2.prototype, "initials", {
    get: function() {
      var _a = this, imageInitials = _a.imageInitials, allowPhoneInitials = _a.allowPhoneInitials; _a.showUnknownPersonaCoin;
      var isRTL = getRTL(this.theme);
      return imageInitials || getInitials(this.text, isRTL, allowPhoneInitials);
    },
    enumerable: false,
    configurable: true
  });
  Object.defineProperty(PersonaCoinBase2.prototype, "dimension", {
    get: function() {
      var _a = this, coinSize = _a.coinSize, size = _a.size;
      return coinSize || sizeToPixels[size];
    },
    enumerable: false,
    configurable: true
  });
  Object.defineProperty(PersonaCoinBase2.prototype, "personaPresenceProps", {
    get: function() {
      var _a = this, coinSize = _a.coinSize, theme = _a.theme, isOutOfOffice = _a.isOutOfOffice, presence = _a.presence, presenceTitle = _a.presenceTitle, size = _a.size;
      return {
        coinSize: coinSize,
        isOutOfOffice: isOutOfOffice,
        presence: presence,
        presenceTitle: presenceTitle,
        size: size,
        theme: theme
      };
    },
    enumerable: false,
    configurable: true
  });
  Object.defineProperty(PersonaCoinBase2.prototype, "shouldRenderInitials", {
    get: function() {
      return !this.imageUrl;
    },
    enumerable: false,
    configurable: true
  });
  Object.defineProperty(PersonaCoinBase2.prototype, "coinSizeStyle", {
    get: function() {
      var coinSize = this.coinSize;
      return coinSize ? { width: coinSize, height: coinSize } : void 0;
    },
    enumerable: false,
    configurable: true
  });
  Object.defineProperty(PersonaCoinBase2.prototype, "classNames", {
    get: function() {
      var _a = this, styles = _a.styles, theme = _a.theme, className = _a.className, coinProps = _a.coinProps, size = _a.size, coinSize = _a.coinSize, showUnknownPersonaCoin = _a.showUnknownPersonaCoin;
      return getClassNames(styles, {
        theme: theme,
        className: coinProps && coinProps.className ? coinProps.className : className,
        size: size,
        coinSize: coinSize,
        showUnknownPersonaCoin: showUnknownPersonaCoin
      });
    },
    enumerable: false,
    configurable: true
  });
  PersonaCoinBase2.prototype.render = function(h) {
    var _a = this, classNames = _a.classNames, size = _a.size, initials = _a.initials, presence = _a.presence, personaPresenceProps = _a.personaPresenceProps, coinSizeStyle = _a.coinSizeStyle, shouldRenderInitials = _a.shouldRenderInitials, showUnknownPersonaCoin = _a.showUnknownPersonaCoin, imageUrl = _a.imageUrl, dimension = _a.dimension;
    return h("div", {
      class: classNames.coin,
      attrs: { role: "presentation" }
    }, [
      size !== PersonaSize.size8 ? h("div", {
        class: classNames.imageArea,
        style: this.coinSizeStyle,
        attrs: { role: "presentation" }
      }, [
        shouldRenderInitials && h("div", {
          class: mergeStyles(classNames.initials, !showUnknownPersonaCoin && { backgroundColor: getPersonaInitialsColor(this.$props) }),
          style: coinSizeStyle,
          attrs: { ariaHidden: "true" }
        }, [
          initials ? h("span", initials) : h(Icon, { attrs: { iconName: "Contact" } })
        ]),
        imageUrl && h(Image, {
          class: classNames.image,
          attrs: {
            imageFit: ImageFit.cover,
            src: imageUrl,
            width: dimension,
            height: dimension
          }
        }),
        h(PersonaPresence, { props: personaPresenceProps })
      ]) : presence ? h(PersonaPresence, { props: personaPresenceProps }) : h(Icon, { class: classNames.size10WithoutPresenceIcon, attrs: { iconName: "Contact" } })
    ]);
  };
  __decorate([
    Prop({ type: Boolean, default: false }),
    __metadata("design:type", Boolean)
  ], PersonaCoinBase2.prototype, "allowPhoneInitials", void 0);
  __decorate([
    Prop({ type: Number, default: PersonaPresence$1.none }),
    __metadata("design:type", Number)
  ], PersonaCoinBase2.prototype, "presence", void 0);
  __decorate([
    Prop({ type: Number, default: null }),
    __metadata("design:type", Number)
  ], PersonaCoinBase2.prototype, "size", void 0);
  __decorate([
    Prop({ type: Number, default: null }),
    __metadata("design:type", Number)
  ], PersonaCoinBase2.prototype, "coinSize", void 0);
  __decorate([
    Prop(),
    __metadata("design:type", Object)
  ], PersonaCoinBase2.prototype, "coinProps", void 0);
  __decorate([
    Prop(),
    __metadata("design:type", Object)
  ], PersonaCoinBase2.prototype, "showUnknownPersonaCoin", void 0);
  __decorate([
    Prop(),
    __metadata("design:type", Object)
  ], PersonaCoinBase2.prototype, "isOutOfOffice", void 0);
  __decorate([
    Prop(),
    __metadata("design:type", Object)
  ], PersonaCoinBase2.prototype, "presenceTitle", void 0);
  __decorate([
    Prop(),
    __metadata("design:type", Object)
  ], PersonaCoinBase2.prototype, "imageUrl", void 0);
  __decorate([
    Prop(),
    __metadata("design:type", Object)
  ], PersonaCoinBase2.prototype, "imageInitials", void 0);
  __decorate([
    Prop(),
    __metadata("design:type", Object)
  ], PersonaCoinBase2.prototype, "text", void 0);
  __decorate([
    Prop(),
    __metadata("design:type", Object)
  ], PersonaCoinBase2.prototype, "initialsColor", void 0);
  PersonaCoinBase2 = __decorate([
    Component({
      inheritAttrs: false,
      components: { Icon: Icon, OImage: Image, PersonaPresence: PersonaPresence }
    })
  ], PersonaCoinBase2);
  return PersonaCoinBase2;
}(BaseComponent);

export { PersonaCoinBase };
