import { getItemThumbnailUrl } from "../../resources/get-item-thumbnail-url";
import { processEntityFeatures } from "../../permissions/_internal/processEntityFeatures";
import { PageDefaultFeatures } from "./PageBusinessRules";
import { computeItemProps } from "../../core/_internal/computeItemProps";
import { computeLinks } from "./computeLinks";
import { applyPageMigrations } from "./applyPageMigrations";
/**
 * Given a model and a page, set various computed properties that can't be directly mapped
 * @private
 * @param model
 * @param page
 * @param requestOptions
 * @returns
 */
export function computeProps(model, page, requestOptions) {
    var _a;
    let token;
    // istanbul ignore next - this logic is covered elsewhere and should be refactored into a shared util
    if (requestOptions.authentication) {
        const session = requestOptions.authentication;
        token = session.token;
    }
    // compute base properties on page
    page = computeItemProps(model.item, page);
    // thumbnail url
    const thumbnailUrl = getItemThumbnailUrl(model.item, requestOptions, token);
    // TODO: Remove this once opendata-ui starts using `links.thumbnail` instead
    page.thumbnailUrl = thumbnailUrl;
    page.links = computeLinks(model.item, requestOptions);
    /**
     * Features that can be disabled by the entity owner
     * NOTE: Pages do not have any features that can be disabled
     */
    page.features = processEntityFeatures(((_a = model.data.settings) === null || _a === void 0 ? void 0 : _a.features) || {}, PageDefaultFeatures);
    // Apply migrations
    page = applyPageMigrations(page);
    // cast b/c this takes a partial but returns a full page
    return page;
}
//# sourceMappingURL=computeProps.js.map