import { getTagItems } from "../../core/schemas/internal/getTagItems";
import { getLocationExtent } from "../../core/schemas/internal/getLocationExtent";
import { getLocationOptions } from "../../core/schemas/internal/getLocationOptions";
import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThumbnailUiSchemaElement";
import { fetchCategoriesUiSchemaElement } from "../../core/schemas/internal/fetchCategoriesUiSchemaElement";
/**
 * @private
 * constructs the complete edit uiSchema for Hub Discussions.
 * This defines how the schema properties should be
 * rendered in the discussion editing experience
 */
export const buildUiSchema = async (i18nScope, options, context) => {
    return {
        type: "Layout",
        elements: [
            {
                type: "Section",
                labelKey: `${i18nScope}.sections.basicInfo.label`,
                options: {
                    helperText: {
                        labelKey: `${i18nScope}.sections.basicInfo.helperText`,
                    },
                },
                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: `shared.fields.title.maxLengthError`,
                                },
                                {
                                    type: "ERROR",
                                    keyword: "format",
                                    icon: true,
                                    labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
                                },
                            ],
                        },
                    },
                    // getSlugSchemaElement(i18nScope),
                    {
                        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: `shared.fields.purpose.maxLengthError`,
                                },
                            ],
                        },
                    },
                    ...getThumbnailUiSchemaElement(i18nScope, options.thumbnail, options.thumbnailUrl, "discussion", context.requestOptions),
                    {
                        type: "Section",
                        labelKey: `${i18nScope}.sections.description.label`,
                        options: {
                            section: "block",
                        },
                        elements: [
                            {
                                labelKey: `${i18nScope}.fields.description.label`,
                                scope: "/properties/description",
                                type: "Control",
                                options: {
                                    control: "hub-field-input-rich-text",
                                    type: "textarea",
                                },
                            },
                        ],
                    },
                    {
                        type: "Section",
                        labelKey: `${i18nScope}.sections.discoverability.label`,
                        options: {
                            section: "block",
                            helperText: {
                                labelKey: `${i18nScope}.sections.discoverability.helperText`,
                            },
                        },
                        elements: [
                            {
                                labelKey: `${i18nScope}.fields.tags.label`,
                                scope: "/properties/tags",
                                type: "Control",
                                options: {
                                    control: "hub-field-input-combobox",
                                    items: await getTagItems(options.tags, context.portal.id, context.hubRequestOptions),
                                    allowCustomValues: true,
                                    selectionMode: "multiple",
                                    placeholderIcon: "label",
                                },
                            },
                            ...(await fetchCategoriesUiSchemaElement({
                                source: "org",
                                currentValues: options.categories,
                                context,
                            })),
                        ],
                    },
                ],
            },
            {
                type: "Section",
                labelKey: `${i18nScope}.sections.location.label`,
                elements: [
                    {
                        scope: "/properties/location",
                        type: "Control",
                        options: {
                            control: "hub-field-input-location-picker",
                            extent: await getLocationExtent(options.location, context.hubRequestOptions),
                            options: await getLocationOptions(options.id, options.type, options.location, context.portal.name, context.hubRequestOptions),
                            mapTools: ["polygon", "rectangle"],
                            noticeTitleElementAriaLevel: 3,
                        },
                    },
                ],
            },
            {
                type: "Section",
                labelKey: `${i18nScope}.sections.details.label`,
                elements: [
                    {
                        labelKey: `${i18nScope}.fields.prompt.label`,
                        scope: "/properties/prompt",
                        type: "Control",
                        options: {
                            control: "hub-field-input-input",
                            type: "textarea",
                            messages: [
                                {
                                    type: "ERROR",
                                    keyword: "maxLength",
                                    icon: true,
                                    labelKey: `${i18nScope}.fields.prompt.maxLengthError`,
                                },
                            ],
                        },
                    },
                ],
            },
        ],
    };
};
//# sourceMappingURL=DiscussionUiSchemaEdit.js.map