import { r as registerInstance, h, H as Host } from './index-ecdfb761.js';
import { T as TakvimAvailableTimePickerViewConfig } from './takvim-available-time-picker-view-config-051fa55b.js';
import { T as TableConfig } from './table-config-3820fb34.js';
import { D as DvnAppViewConfig } from './view-config-2fc2ba10.js';
import { g as generateCalendarConfig } from './mentorinty-bridge-api-f70621dd.js';
import { b as generateMentornitySessionContext, c as generateMembershipForRole } from './session-a602596d.js';
import './FieldModelGenerator-03c7516c.js';
import './reference-field-a5b414d1.js';
import './BaseField-0b01dc2c.js';
import './index-61dcd269.js';
import './FieldGenerator-3ae403b2.js';
import './date-1bc489bd.js';
import './index-4e451db4.js';
import './index-32d8b974.js';
import './index-23baeeef.js';
import './index-09efdc01.js';
import './index-150b6a59.js';
import './data-model-f7ccf826.js';
import './apiBase-648a161d.js';
import './data-transfer-field-2f305919.js';
import './filter-cbaa3d7d.js';
import './index-5f14b4fc.js';
import './attachment-d13ad547.js';
import './membership-24db029a.js';
import './string-3065a411.js';
import './User-9f1f4513.js';
import './CalendarConfig-f8d4a70d.js';
import './UserSettings-27df01e6.js';
import './cookie-9f22e0fb.js';
import './kimlik-api-66e341bd.js';
import './_commonjsHelpers-27f122dd.js';
import './index-d3bd30bd.js';
import './instance-db63ecb7.js';
import './index-3bf9b308.js';
import './i18n-4dcb85fe.js';
import './i18n-73c2e20d.js';
import './calendar-470c802a.js';
import './index-a3ca021c.js';
import './moment-65eca6b3.js';

class TakvimDailyCalendarViewConfig extends DvnAppViewConfig {
  static decode(json) {
    const model = Object.assign(Object.create(TakvimDailyCalendarViewConfig.prototype), json);
    model.table = TableConfig.decode(model.table);
    return model;
  }
}

const MentornityHomeMessageWrapper = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
  }
  componentWillLoad() {
    // fetch the context async to unblock the component render
    generateMentornitySessionContext(this.contextParams, { fetchConfig: true })
      .then((mentornitySessionContext) => {
      this.mentornitySessionContext = mentornitySessionContext;
      this.view = generateView(mentornitySessionContext);
      this.membership = generateMembershipForRole('admin');
    })
      .catch(error => this.error = error);
  }
  onViewMeeting(event) {
    window.dispatchEvent(new CustomEvent('dvn.mentornity-admin-calendar-view.open-meeting-page', {
      detail: {
        meetingId: event.detail._id,
      }
    }));
  }
  onAction(event) {
    const action = event.detail;
    switch (action.name) {
      case 'open-meeting-detail-after-creation':
        // dispatch event for Mentornity web-client to handle the action
        window.dispatchEvent(new CustomEvent('dvn.mentornity-admin-calendar-view.open-meeting-page', {
          detail: {
            meetingId: action.params.meetingId,
          }
        }));
        break;
    }
  }
  render() {
    const { error, mentornitySessionContext, view } = this;
    if (!!error) {
      return (h("dvn-card", { leanedSides: true, tint: "danger" }, "Failed to get data."));
    }
    if (!mentornitySessionContext) {
      return (h("div", { class: "d-flex justify-content-center pt-3" }, h("dvn-progress", { indefinite: true })));
    }
    return (h(Host, { class: "d-flex flex-grow-1", style: { overflow: 'hidden', background: 'var(--color-background-primary)' } }, h("mentornity-root-wrapper", null, h("dvn-app-view-takvim-daily-calendar-view", { apiData: this.mentornitySessionContext.mentornityBridgeApi, apiSozluk: this.mentornitySessionContext.apiSozluk, apiTakvim: this.mentornitySessionContext.mentornityBridgeApi, user: this.mentornitySessionContext.user, userSettings: this.mentornitySessionContext.userSettings, membership: this.membership, view: view }))));
  }
};
function generateView(mentornitySessionContext) {
  // this value can be changed to 'mentees' or 'groups' to show them in the list on the left
  const membershipConfigIdToGroupMeetings = 'mentors';
  let membershipConfigIdToViewOnMeetings = 'mentees';
  if (mentornitySessionContext.organisationConfig.menteeType === 'group') {
    membershipConfigIdToViewOnMeetings = 'groups';
  }
  return TakvimDailyCalendarViewConfig.decode({
    i18nEntryId: 'dailyCalendarView',
    table: generateCalendarConfig(mentornitySessionContext.organisationConfig),
    membershipConfigIdToGroupMeetings,
    membershipConfigIdToViewOnMeetings,
    availableTimePickerConfig: TakvimAvailableTimePickerViewConfig.decode({
      _id: 'admin-calendar-page-available-time-picker-view-wrapper',
      i18nEntryId: 'user-card-list-page-available-time-picker-view',
      table: generateCalendarConfig(mentornitySessionContext.organisationConfig),
      successNavigationAction: {
        type: 'navigation',
        direction: 'forward',
        name: 'open-meeting-detail-after-creation',
        params: {
          conversionConfig: {
            'item._id': 'meetingId',
          }
        }
      },
    }),
  });
}

export { MentornityHomeMessageWrapper as mentornity_admin_calendar_view };
