'use strict';

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

const index = require('./index-1ee80297.js');
const index$1 = require('./index-17394420.js');
require('./kimlikApi-1cd43caf.js');
require('./data-transfer-field-0ce05c1a.js');
require('./filter-d5040f65.js');
const instance = require('./instance-8904b0e4.js');
const env = require('./env-56a21d68.js');
const session = require('./session-612c0d2f.js');
const wrapperUtil = require('./wrapper-util-465491e6.js');
require('./state-tunnel-786a62ce.js');
require('./BaseField-d019ade6.js');
require('./FieldModelGenerator-2c39c8e9.js');
require('./index-42baafa9.js');
require('./index-a77c3004.js');
require('./date-25b104f6.js');
require('./index-521d07b9.js');
require('./index-9e7c4ca0.js');
require('./membership-14c44e7c.js');
require('./data-model-c51de090.js');
require('./membership-config-6ba394cc.js');
require('./table-config-be88299b.js');
require('./string-de672b69.js');
require('./User-286a0714.js');
require('./UserSettings-016122e8.js');
require('./cookie-c4d9848a.js');
require('./_commonjsHelpers-206db00d.js');
require('./index-33e96540.js');
require('./form-view-config-36f31520.js');
require('./InterceptorHandler-09a1e84b.js');
require('./view-config-c409ff28.js');
require('./ValidatorLength-06e5c6f8.js');
require('./mentorinty-bridge-api-ede51458.js');
require('./index-30008542.js');
require('./attachment-3090e25e.js');
require('./CalendarConfig-fed039db.js');
require('./common-wrapper-util-5385d126.js');
require('./models-813707d2.js');
require('./actions-d7eabd95.js');

let 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(env.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;
