"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildUiSchema = void 0;
const getTagItems_1 = require("../../core/schemas/internal/getTagItems");
const getLocationExtent_1 = require("../../core/schemas/internal/getLocationExtent");
const getLocationOptions_1 = require("../../core/schemas/internal/getLocationOptions");
const getThumbnailUiSchemaElement_1 = require("../../core/schemas/internal/getThumbnailUiSchemaElement");
const fetchCategoriesUiSchemaElement_1 = require("../../core/schemas/internal/fetchCategoriesUiSchemaElement");
/**
 * @private
 * constructs the complete edit uiSchema for Hub Content.
 * This defines how the schema properties should be
 * rendered in the content editing experience
 */
const buildUiSchema = async (i18nScope, options, context) => {
    return {
        type: "Layout",
        elements: [
            {
                type: "Section",
                labelKey: `${i18nScope}.sections.basic.title`,
                options: {
                    helperText: {
                        labelKey: `${i18nScope}.sections.basic.helperText`,
                    },
                },
                elements: [
                    // title
                    {
                        labelKey: `${i18nScope}.fields.title.label`,
                        scope: "/properties/name",
                        type: "Control",
                        options: {
                            helperText: {
                                labelKey: `${i18nScope}.fields.title.hint`,
                            },
                            messages: [
                                {
                                    type: "ERROR",
                                    keyword: "required",
                                    icon: true,
                                    labelKey: `${i18nScope}.fields.title.requiredError`,
                                },
                                {
                                    type: "ERROR",
                                    keyword: "maxLength",
                                    icon: true,
                                    labelKey: `shared.fields.title.maxLengthError`,
                                },
                            ],
                        },
                    },
                    // getSlugSchemaElement(i18nScope),
                    // summary
                    {
                        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.summary.maxLengthError`,
                                },
                            ],
                        },
                    },
                    ...(0, getThumbnailUiSchemaElement_1.getThumbnailUiSchemaElement)(i18nScope, options.thumbnail, options.thumbnailUrl, "content", context.requestOptions, (0, getThumbnailUiSchemaElement_1.getDefaultImageEntityThumbnail)(options, context)),
                    {
                        type: "Section",
                        labelKey: `${i18nScope}.sections.description.label`,
                        options: {
                            section: "block",
                        },
                        elements: [
                            // description
                            {
                                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: [
                            // tags
                            {
                                labelKey: `${i18nScope}.fields.tags.label`,
                                scope: "/properties/tags",
                                type: "Control",
                                options: {
                                    control: "hub-field-input-combobox",
                                    items: await (0, getTagItems_1.getTagItems)(options.tags, context.portal.id, context.hubRequestOptions),
                                    allowCustomValues: true,
                                    selectionMode: "multiple",
                                    placeholderIcon: "label",
                                },
                            },
                            // categories
                            ...(await (0, fetchCategoriesUiSchemaElement_1.fetchCategoriesUiSchemaElement)({
                                source: "org",
                                currentValues: options.categories,
                                context,
                            })),
                        ],
                    },
                    // license
                    {
                        labelKey: `${i18nScope}.fields.license.label`,
                        scope: "/properties/licenseInfo",
                        type: "Control",
                        options: {
                            control: "arcgis-hub-license-picker",
                        },
                    },
                ],
            },
            // location section
            {
                type: "Section",
                labelKey: `${i18nScope}.sections.location.label`,
                elements: [
                    {
                        scope: "/properties/location",
                        type: "Control",
                        options: {
                            control: "hub-field-input-location-picker",
                            extent: await (0, getLocationExtent_1.getLocationExtent)(options.location, context.hubRequestOptions),
                            options: await (0, getLocationOptions_1.getLocationOptions)(options.id, options.type, options.location, context.portal.name, context.hubRequestOptions),
                            noticeTitleElementAriaLevel: 3,
                        },
                    },
                ],
            },
        ],
    };
};
exports.buildUiSchema = buildUiSchema;
//# sourceMappingURL=ContentUiSchemaEdit.js.map