"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._ensureTelemetry = _ensureTelemetry;
const delete_prop_1 = require("../../items/delete-prop");
const get_prop_1 = require("../../objects/get-prop");
const set_prop_1 = require("../../objects/set-prop");
const util_1 = require("../../util");
/**
 * Add telemetry config object
 * @private
 * @param {object} model Site Model
 * @returns {object}
 */
function _ensureTelemetry(model) {
    if ((0, get_prop_1.getProp)(model, "item.properties.schemaVersion") >= 1.4)
        return model;
    const clone = (0, util_1.cloneObject)(model);
    const gacode = (0, get_prop_1.getProp)(clone, "data.values.gacode");
    clone.data.values.telemetry = {
        consentNotice: {
            isTheme: true,
            consentText: "",
            policyURL: "",
        },
        customAnalytics: {
            ga: {
                customerTracker: {
                    enabled: Boolean(gacode),
                    id: gacode,
                },
            },
        },
    };
    (0, delete_prop_1.deleteProp)(clone, "data.values.gacode");
    (0, set_prop_1.setProp)("item.properties.schemaVersion", 1.4, clone);
    return clone;
}
//# sourceMappingURL=_ensure-telemetry.js.map