'use strict';

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

const index = require('./index-36b3af04.js');
const index$1 = require('./index-4d2f1ab7.js');
require('./kimlikApi-85c6d3ac.js');
require('./data-transfer-field-0ce05c1a.js');
require('./filter-d5040f65.js');
const instance = require('./instance-79d61640.js');
const session = require('./session-3b788cd7.js');
const wrapperUtil = require('./wrapper-util-e0218ae9.js');
require('./state-tunnel-786a62ce.js');
require('./BaseField-d019ade6.js');
require('./FieldModelGenerator-205dd99c.js');
require('./index-74a00556.js');
require('./index-a8f1783c.js');
require('./date-25b104f6.js');
require('./index-fe19a98b.js');
require('./index-ae305bae.js');
require('./membership-dfbf512e.js');
require('./data-model-c51de090.js');
require('./membership-config-707b2c51.js');
require('./table-config-444a77e4.js');
require('./string-de672b69.js');
require('./User-286a0714.js');
require('./UserSettings-016122e8.js');
require('./cookie-370bc992.js');
require('./_commonjsHelpers-206db00d.js');
require('./index-33e96540.js');
require('./form-view-config-51279874.js');
require('./InterceptorHandler-09a1e84b.js');
require('./view-config-ec5f62df.js');
require('./ValidatorLength-06e5c6f8.js');
require('./mentorinty-bridge-api-22218ac9.js');
require('./index-d90390f1.js');
require('./attachment-3090e25e.js');
require('./CalendarConfig-9459e520.js');
require('./common-wrapper-util-25ff9eca.js');
require('./models-813707d2.js');
require('./actions-d7eabd95.js');

const MentornityMembershipSettingsWrapper = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.isViewConfigWrapperLoaded = false;
  }
  onInvalidation(event) {
    this.notifier.showCustomNotification(event.detail.notification);
  }
  ;
  componentWillLoad() {
    const { context: { organisationId, role, userId }, headers } = session.getSessionDetails();
    const mentornityApi = instance.createMentornityApiInstance(session.mentornityApiEndpoint, headers);
    mentornityApi.getOrganisationConfig(organisationId).then((response) => {
      this.organisationConfig = response;
    });
    const viewName = role === 'mentor'
      ? instance.MentornityViewConfigViewName.MentorInfoForm
      : instance.MentornityViewConfigViewName.MenteeInfoForm;
    mentornityApi.getViewConfig(organisationId, viewName)
      .then(viewConfigWrapper => {
      this.viewConfigWrapper = viewConfigWrapper;
    }).finally(() => this.isViewConfigWrapperLoaded = true);
    mentornityApi.get('users', userId).then((response) => {
      this.user = response;
    });
    mentornityApi
      .getMetadataOfUser(organisationId, role === 'mentor' ? 'mentors' : 'mentees', userId)
      .then((response) => {
      this.userMetadata = response;
    });
    if (role === 'mentor') {
      mentornityApi
        .getMentorshipOfUser(organisationId, userId)
        .then((response) => {
        this.userMentorship = response;
      });
    }
  }
  render() {
    const { isViewConfigWrapperLoaded, language, organisationConfig, user, userMentorship, userMetadata, viewConfigWrapper } = this;
    const { context } = session.getSessionDetails();
    if (!isViewConfigWrapperLoaded || !organisationConfig || !user || !userMetadata || (context.role === 'mentor' && !userMentorship)) {
      return (index.h("mentornity-root-wrapper", null, index.h("div", { class: "d-flex justify-content-center pt-3" }, index.h("dvn-progress", { indefinite: true }))));
    }
    const pairDetailViewConfig = wrapperUtil.getFormViewConfig(context, language, organisationConfig, viewConfigWrapper, user, userMetadata, userMentorship);
    return (index.h("mentornity-root-wrapper", null, index.h("dvn-card", null, index.h("dvn-app-view-form-view", { params: wrapperUtil.getFormParameters(context, organisationConfig, user, userMetadata, userMentorship), view: pairDetailViewConfig }))));
  }
};
index$1.injectNotifier(MentornityMembershipSettingsWrapper);

exports.mentornity_membership_settings_wrapper = MentornityMembershipSettingsWrapper;
