import { r as registerInstance, h } from './index-55faf181.js';
import { i as injectNotifier } from './index-7884b902.js';
import './kimlikApi-7350588e.js';
import './data-transfer-field-918730a3.js';
import './filter-cbaa3d7d.js';
import { c as createMentornityApiInstance, b as MentornityViewConfigViewName } from './instance-46ab1e99.js';
import { g as getSessionDetails, m as mentornityApiEndpoint } from './session-3ec0aa4c.js';
import { a as getFormViewConfig, b as getFormParameters } from './wrapper-util-0c6db53e.js';
import './state-tunnel-04c0b67a.js';
import './BaseField-461b6d0c.js';
import './FieldModelGenerator-1ee7fda2.js';
import './index-6a1cf9c1.js';
import './index-403e215e.js';
import './date-ce777316.js';
import './index-083a6906.js';
import './index-fa1db470.js';
import './membership-61c4a2f7.js';
import './data-model-f5160369.js';
import './membership-config-a51a5232.js';
import './table-config-5c917348.js';
import './string-3065a411.js';
import './User-d2ee8b71.js';
import './UserSettings-7b80b841.js';
import './cookie-93ea205f.js';
import './_commonjsHelpers-27f122dd.js';
import './index-d3bd30bd.js';
import './form-view-config-00abddd1.js';
import './InterceptorHandler-6474bcf4.js';
import './view-config-39fd369a.js';
import './ValidatorLength-f56a7c14.js';
import './mentorinty-bridge-api-946adc0d.js';
import './index-ebde6a66.js';
import './attachment-32decf79.js';
import './CalendarConfig-184230a0.js';
import './common-wrapper-util-36df331f.js';
import './models-f0bc20c6.js';
import './actions-b9a0f808.js';

const MentornityMembershipSettingsWrapper = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.isViewConfigWrapperLoaded = false;
  }
  onInvalidation(event) {
    this.notifier.showCustomNotification(event.detail.notification);
  }
  ;
  componentWillLoad() {
    const { context: { organisationId, role, userId }, headers } = getSessionDetails();
    const mentornityApi = createMentornityApiInstance(mentornityApiEndpoint, headers);
    mentornityApi.getOrganisationConfig(organisationId).then((response) => {
      this.organisationConfig = response;
    });
    const viewName = role === 'mentor'
      ? MentornityViewConfigViewName.MentorInfoForm
      : 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 } = getSessionDetails();
    if (!isViewConfigWrapperLoaded || !organisationConfig || !user || !userMetadata || (context.role === 'mentor' && !userMentorship)) {
      return (h("mentornity-root-wrapper", null, h("div", { class: "d-flex justify-content-center pt-3" }, h("dvn-progress", { indefinite: true }))));
    }
    const pairDetailViewConfig = getFormViewConfig(context, language, organisationConfig, viewConfigWrapper, user, userMetadata, userMentorship);
    return (h("mentornity-root-wrapper", null, h("dvn-card", null, h("dvn-app-view-form-view", { params: getFormParameters(context, organisationConfig, user, userMetadata, userMentorship), view: pairDetailViewConfig }))));
  }
};
injectNotifier(MentornityMembershipSettingsWrapper);

export { MentornityMembershipSettingsWrapper as mentornity_membership_settings_wrapper };
