import { B as BaseField } from './BaseField-d94c5b14.js';
import { b as InfoVisibility } from './instance-b3864e36.js';
import { P as PairConfig, R as Rule, C as Comparison, a as RuleType } from './pair-config-b11a5ee7.js';

/**
 * This configuration is used to satisfy the pair configuration that is required by the Devingen app.
 * The values here represents the 'subscription' model used in Mentornity and some new fields are added on top of that.
 */
const pairConfig = (organisationConfig, goalConfig, options) => {
  var _a;
  return PairConfig.decode({
    actionPermissions: {
      subscriber: {
        completePair: false,
      },
      subscribed: {
        completePair: !!(options === null || options === void 0 ? void 0 : options.canMentorEndSubscription),
      },
    },
    fields: [
      {
        type: 'reference',
        id: 'subscriber',
        otherCollection: organisationConfig.menteeType === 'group' ? 'groups' : 'mentees',
      },
      {
        type: 'reference',
        id: 'subscribed',
        otherCollection: 'mentors',
      },
    ],
    selection: organisationConfig.menteeType === 'group' ? undefined : {
      subscriber: {
        initiation: 'approvingly',
        pairLimit: options === null || options === void 0 ? void 0 : options.pairLimitForMentees,
        selectionLimit: options === null || options === void 0 ? void 0 : options.selectionLimitForMentees,
        roleNameToSelect: 'subscribed',
        rules: [
          new Rule([
            {
              firstField: BaseField.decode({ id: 'city', type: 'text' }),
              comparison: Comparison.eq,
              secondField: BaseField.decode({ id: 'city', type: 'text' }),
            }
          ], RuleType.comparison),
        ],
        selectionUI: {
          showMessageButton: [
            InfoVisibility.allMentors,
            InfoVisibility.everyone,
          ].includes(organisationConfig.conversationPermissions.mentee),
        },
        status: (options === null || options === void 0 ? void 0 : options.isMentorSelectionOn) ? 'active' : 'passive',
      },
    },
    structure: goalConfig ? {
      meetingConfigs: ((_a = goalConfig.meetingGoals) === null || _a === void 0 ? void 0 : _a.map(meetingConfig => ({
        id: meetingConfig.identifier,
        name: meetingConfig.meetingTitle,
        meetingCount: 1,
        specifications: {
          subscriber: meetingConfig.specifications.mentee,
          subscribed: meetingConfig.specifications.mentor,
        },
      }))) || [],
    } : undefined
  });
};

export { pairConfig as p };
