"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TranslatedPropertyHelper = void 0;
var config_1 = require("../config");
var data_context_1 = require("./../data/data-context");
var aurelia_framework_1 = require("aurelia-framework");
var TranslatedPropertyHelper = exports.TranslatedPropertyHelper = (function () {
    function TranslatedPropertyHelper(datacontext) {
        this.datacontext = datacontext;
    }
    TranslatedPropertyHelper.createMissingProperty = function (object) {
        if (object == null) {
            object = {};
        }
        var config = aurelia_framework_1.Container.instance.get(config_1.Config);
        config.globalConfig.configuredLanguages.forEach(function (language) {
            var _a;
            var prop = language._columnName;
            (_a = object[prop]) !== null && _a !== void 0 ? _a : (object[prop] = '');
        });
        return object;
    };
    TranslatedPropertyHelper.prototype.addNecessaryProperties = function (object, addSourceProperty) {
        var _this = this;
        if (addSourceProperty === void 0) { addSourceProperty = true; }
        Object.defineProperty(object, '_translation', {
            get: function () {
                return object[_this.datacontext.translatePropertyName];
            },
            set: function (val) {
                object[_this.datacontext.translatePropertyName] = val;
            }
        });
        if (addSourceProperty) {
            Object.defineProperty(object, '_sourceProperty', {
                get: function () {
                    return _this.datacontext.translatePropertyName;
                }
            });
        }
    };
    TranslatedPropertyHelper = __decorate([
        aurelia_framework_1.autoinject,
        __metadata("design:paramtypes", [data_context_1.Datacontext])
    ], TranslatedPropertyHelper);
    return TranslatedPropertyHelper;
}());

//# sourceMappingURL=translated-property-helper.js.map
