"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var igd_core_1 = require("@intelligentgraphics/igd.core");
/**
 * Checks wether the specified target exists inside the session. Throws an error if it doesn't
 *
 * @param {(ArticleQuery | Session)} articleQuery
 * @param {string | Article} target
 */
exports.getArticleOrThrow = function (articleQuery, target) {
    var comId = typeof target === "string" ? target : target.comId;
    var article = articleQuery.getArticleByComId(comId);
    if (article === undefined) {
        throw new Error("Could not find an article for comId \"" + comId + "\"");
    }
    return article;
};
exports.getPropertyValue = function (article, property, value) {
    var propertyDefinition = igd_core_1.IGXE.findProperty(article.properties, property);
    if (propertyDefinition === undefined) {
        return undefined;
    }
    var valueDefinition = igd_core_1.IGXE.findValueDefinition(propertyDefinition, value);
    return valueDefinition;
};
