import { UiSchemaRuleEffects } from "../../core/enums/uiSchemaRuleEffects";
import { checkPermission } from "../../permissions/checkPermission";
import { getWellKnownGroup } from "../getWellKnownGroup";
/**
 * @private
 * constructs the complete uiSchema for creating a edit
 * group. This defines how the schema properties should be
 * rendered in the edit group creation experience
 */
export const buildUiSchema = (i18nScope, _options, context) => {
    return Promise.resolve({
        type: "Layout",
        elements: [
            {
                type: "Section",
                options: { section: "stepper", scale: "l" },
                elements: [
                    {
                        type: "Section",
                        labelKey: `${i18nScope}.sections.details.label`,
                        options: {
                            section: "step",
                        },
                        elements: [
                            {
                                labelKey: `${i18nScope}.fields.name.label`,
                                scope: "/properties/name",
                                type: "Control",
                                options: {
                                    messages: [
                                        {
                                            type: "ERROR",
                                            keyword: "required",
                                            icon: true,
                                            labelKey: `${i18nScope}.fields.name.requiredError`,
                                        },
                                        {
                                            type: "ERROR",
                                            keyword: "maxLength",
                                            icon: true,
                                            labelKey: `${i18nScope}.fields.name.maxLengthError`,
                                        },
                                        {
                                            type: "ERROR",
                                            keyword: "format",
                                            icon: true,
                                            labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
                                        },
                                    ],
                                },
                            },
                            {
                                labelKey: `${i18nScope}.fields.summary.label`,
                                scope: "/properties/summary",
                                type: "Control",
                                options: {
                                    control: "hub-field-input-input",
                                    type: "textarea",
                                    rows: 4,
                                    messages: [
                                        {
                                            type: "ERROR",
                                            keyword: "maxLength",
                                            icon: true,
                                            labelKey: `${i18nScope}.fields.summary.maxLengthError`,
                                        },
                                    ],
                                },
                            },
                        ],
                    },
                    {
                        type: "Section",
                        labelKey: `${i18nScope}.sections.membershipAccess.label`,
                        options: {
                            section: "step",
                        },
                        rule: {
                            effect: UiSchemaRuleEffects.DISABLE,
                            condition: {
                                scope: "/properties/name",
                                schema: { const: "" },
                            },
                        },
                        elements: [
                            {
                                labelKey: `${i18nScope}.fields.membershipAccess.label`,
                                scope: "/properties/membershipAccess",
                                type: "Control",
                                options: {
                                    control: "hub-field-input-radio",
                                    labels: [
                                        `{{${i18nScope}.fields.membershipAccess.org.description:translate}}`,
                                        `{{${i18nScope}.fields.membershipAccess.collab.description:translate}}`,
                                        `{{${i18nScope}.fields.membershipAccess.any.description:translate}}`,
                                    ],
                                    disabled: [
                                        false,
                                        !checkPermission("platform:portal:user:addExternalMembersToGroup", context).access,
                                        true,
                                    ],
                                },
                            },
                            {
                                labelKey: `${i18nScope}.fields.contributeContent.label`,
                                scope: "/properties/isViewOnly",
                                type: "Control",
                                options: {
                                    control: "hub-field-input-radio",
                                    labels: [
                                        `{{${i18nScope}.fields.contributeContent.members.description:translate}}`,
                                        `{{${i18nScope}.fields.contributeContent.admins.description:translate}}`,
                                    ],
                                },
                            },
                        ],
                    },
                ],
            },
        ],
    });
};
/**
 * @private
 * constructs the default values for creating an edit group.
 * This is used to pre-populate the form with specific default values
 * that are different from the normal Group Schema defaults.
 * @param i18nScope
 * @param options
 * @param context
 * @returns
 */
export const buildDefaults = (_i18nScope, _options, context) => {
    return Promise.resolve(Object.assign({}, getWellKnownGroup("hubEditGroup", context)));
};
//# sourceMappingURL=GroupUiSchemaCreateEdit.js.map