'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-1141a245.js');
const calendar = require('./calendar-e4b7baeb.js');
const index$1 = require('./index-a2e99c85.js');
const sozlukEntries = require('./sozluk-entries-3b9686e7.js');
require('./index-b776fc14.js');
require('./_commonjsHelpers-206db00d.js');
require('./moment-7a3433f2.js');
require('./i18n-0bcf144d.js');
require('./i18n-77d45414.js');

const MentornityAnnouncementsMailingReport = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.openSelectUsersDialog = index.createEvent(this, "openSelectUsersDialog", 7);
    this.openAnnouncementReport = index.createEvent(this, "openAnnouncementReport", 7);
    this.setDictionaryLanguage = async () => {
      const apiSozluk = new index$1.SozlukApi().setLanguage(this.item.language).setContents(sozlukEntries.sozlukEntries);
      this.strings = await apiSozluk.getContent(sozlukEntries.MentornityAnnouncementWrapperI18nKey, sozlukEntries.mentornityAnnouncementWrapperI18nDefault);
    };
  }
  componentWillLoad() {
    this.setDictionaryLanguage();
  }
  render() {
    var _a, _b, _c, _d, _e, _f, _g;
    const { strings } = this;
    if (!strings)
      return;
    const hasSentEmails = ((_b = (_a = this.item) === null || _a === void 0 ? void 0 : _a.targetList) === null || _b === void 0 ? void 0 : _b.length) > 0;
    const sentEmailsDate = ((_d = (_c = this.item) === null || _c === void 0 ? void 0 : _c.sentEmailsAt) === null || _d === void 0 ? void 0 : _d.length) > 0 && calendar.CalendarUtils.format(((_e = this.item) === null || _e === void 0 ? void 0 : _e.sentEmailsAt[((_g = (_f = this.item) === null || _f === void 0 ? void 0 : _f.sentEmailsAt) === null || _g === void 0 ? void 0 : _g.length) - 1]) * 1000, `DD-MM-YYYY - ${calendar.CalendarUtils.timeFormat === '12-hour' ? 'hh:mm A' : 'HH:mm'}`); // get latest sent date
    return (index.h(index.Host, null, hasSentEmails ?
      index.h("div", { class: "d-flex align-items-center" }, index.h("p", { class: "m-0" }, index$1.SozlukApi.build(strings.sentOn, { date: sentEmailsDate })), index.h("strong", { class: "m-0 ml-3", style: { cursor: 'pointer' }, onClick: () => this.openAnnouncementReport.emit(this.item) }, index.h("dvn-icon", { iconName: "uil uil-envelope-check" }), strings.checkReport))
      :
        index.h("div", { class: "d-flex align-items-center" }, index.h("dvn-button", { tint: "primary", leaned: true, scale: "small", onClick: () => this.openSelectUsersDialog.emit(this.item) }, strings.sendNow), index.h("p", { class: "m-0 ml-3" }, strings.notSent))));
  }
};

exports.mentornity_announcements_mailing_report = MentornityAnnouncementsMailingReport;
