import { setProp } from "../../objects/set-prop";
import { cloneObject } from "../../util";
/**
 * Reconfigure event list card properties
 * @private
 * @param {object} model Site Model
 * @returns {object}
 */
export function _migrateEventListCardConfigs(model) {
    var _a;
    // do nothing if migration already applied
    if (((_a = model.item.properties) === null || _a === void 0 ? void 0 : _a.schemaVersion) >= 1.6)
        return model;
    // apply migration
    const clone = cloneObject(model);
    clone.data.values.layout.sections.map((section) => (Object.assign(Object.assign({}, section), { rows: (section.rows || []).map((row) => (Object.assign(Object.assign({}, row), { cards: (row.cards || []).map((card) => {
                if (card.component.name === "event-list-card") {
                    card.component.settings.displayMode = card.component.settings
                        .calendarEnabled
                        ? "calendar"
                        : "list";
                    delete card.component.settings.calendarEnabled;
                }
                return card;
            }) }))) })));
    // increment schemaVersion
    setProp("item.properties.schemaVersion", 1.6, clone);
    return clone;
}
//# sourceMappingURL=_migrate-event-list-card-configs.js.map