"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _ProjectUpdateResult_data;
Object.defineProperty(exports, "__esModule", { value: true });
const Utilities_1 = require("../core/Utilities");
const IUpdateResult_1 = require("./IUpdateResult");
class ProjectUpdateResult {
    get dataObject() {
        return __classPrivateFieldGet(this, _ProjectUpdateResult_data, "f");
    }
    get resultType() {
        return __classPrivateFieldGet(this, _ProjectUpdateResult_data, "f").resultType;
    }
    get message() {
        return __classPrivateFieldGet(this, _ProjectUpdateResult_data, "f").message;
    }
    get updaterId() {
        return __classPrivateFieldGet(this, _ProjectUpdateResult_data, "f").updaterId;
    }
    get updaterIndex() {
        return __classPrivateFieldGet(this, _ProjectUpdateResult_data, "f").updaterIndex;
    }
    get data() {
        return __classPrivateFieldGet(this, _ProjectUpdateResult_data, "f").data;
    }
    get content() {
        return __classPrivateFieldGet(this, _ProjectUpdateResult_data, "f").content;
    }
    get contentSummary() {
        let errorContent = __classPrivateFieldGet(this, _ProjectUpdateResult_data, "f").content;
        if (errorContent) {
            errorContent = errorContent.replace(/\n/gi, " ");
            errorContent = errorContent.replace(/\r/gi, " ");
            if (errorContent.length > 80) {
                errorContent = errorContent.substring(0, 77) + "...";
            }
        }
        return errorContent;
    }
    get typeSummary() {
        switch (__classPrivateFieldGet(this, _ProjectUpdateResult_data, "f").resultType) {
            case IUpdateResult_1.UpdateResultType.noChange:
                return "No changes";
            case IUpdateResult_1.UpdateResultType.updatedFile:
                return "Updated file";
            default:
                return "Unknown";
        }
    }
    get typeSummaryShort() {
        let short = this.typeSummary.toUpperCase();
        short = short.replace(/\s/g, "");
        return short;
    }
    toString() {
        let summaryString = this.typeSummaryShort + ": ";
        summaryString += "[" + this.updaterId + Utilities_1.default.frontPadToLength(this.updaterIndex, 3, "0") + "] ";
        summaryString += this.message;
        if (this.data) {
            summaryString += ": " + this.data;
        }
        const errorContent = this.contentSummary;
        if (errorContent) {
            summaryString += " [in " + errorContent + "]";
        }
        return summaryString;
    }
    constructor(resultType, updaterId, updaterIndex, message, projectItem, data, itemId, content) {
        _ProjectUpdateResult_data.set(this, void 0);
        __classPrivateFieldSet(this, _ProjectUpdateResult_data, {
            resultType: resultType,
            updaterId: updaterId,
            updaterIndex: updaterIndex,
            message: message,
            itemStoragePath: projectItem ? projectItem.projectPath : undefined,
            data: data,
            itemId: itemId,
            content: content,
        }, "f");
    }
}
exports.default = ProjectUpdateResult;
_ProjectUpdateResult_data = new WeakMap();

//# sourceMappingURL=../maps/updates/ProjectUpdateResult.js.map
