"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.CdmImport = void 0;
const internal_1 = require("../internal");
class CdmImport extends internal_1.cdmObjectSimple {
    constructor(ctx, corpusPath, moniker) {
        super(ctx);
        this.TAG = CdmImport.name;
        // let bodyCode = () =>
        {
            this.corpusPath = corpusPath;
            this.moniker = moniker ? moniker : undefined;
            this.objectType = internal_1.cdmObjectType.import;
        }
        // return p.measure(bodyCode);
    }
    static get objectType() {
        return internal_1.cdmObjectType.import;
    }
    getObjectType() {
        // let bodyCode = () =>
        {
            return internal_1.cdmObjectType.import;
        }
        // return p.measure(bodyCode);
    }
    copy(resOpt, host) {
        // let bodyCode = () =>
        {
            if (!resOpt) {
                resOpt = new internal_1.resolveOptions(this, this.ctx.corpus.defaultResolutionDirectives);
            }
            let copy;
            if (!host) {
                copy = new CdmImport(this.ctx, this.corpusPath, this.moniker);
            }
            else {
                copy = host;
                copy.ctx = this.ctx;
                copy.corpusPath = this.corpusPath;
                copy.moniker = this.moniker;
            }
            copy.document = this.document ? this.document.copy(resOpt) : undefined;
            copy.previousOwner = this.owner;
            return copy;
        }
        // return p.measure(bodyCode);
    }
    fetchObjectDefinitionName() {
        return undefined;
    }
    validate() {
        // let bodyCode = () =>
        {
            if (!this.corpusPath) {
                let missingFields = ['corpusPath'];
                internal_1.Logger.error(this.ctx, this.TAG, this.validate.name, this.atCorpusPath, internal_1.cdmLogCode.ErrValdnIntegrityCheckFailure, missingFields.map((s) => `'${s}'`).join(', '), this.atCorpusPath);
                return false;
            }
            return true;
        }
        // return p.measure(bodyCode);
    }
    visit(pathFrom, preChildren, postChildren) {
        // let bodyCode = () =>
        {
            // not much to do
            if (preChildren && preChildren(this, pathFrom)) {
                return false;
            }
            if (postChildren && postChildren(this, pathFrom)) {
                return true;
            }
            return false;
        }
        // return p.measure(bodyCode);
    }
}
exports.CdmImport = CdmImport;
//# sourceMappingURL=CdmImport.js.map