"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Schema
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.FunctionalSchema = void 0;
const path = require("path");
const core_bentley_1 = require("@itwin/core-bentley");
const core_common_1 = require("@itwin/core-common");
const ClassRegistry_1 = require("../ClassRegistry");
const IModelHost_1 = require("../IModelHost");
const Schema_1 = require("../Schema");
const elementsModule = require("./FunctionalElements");
const Symbols_1 = require("../internal/Symbols");
/** @public */
class FunctionalSchema extends Schema_1.Schema {
    static get schemaName() { return "Functional"; }
    static get schemaFilePath() { return path.join(IModelHost_1.KnownLocations.nativeAssetsDir, "ECSchemas", "Domain", `${FunctionalSchema.schemaName}.ecschema.xml`); }
    static registerSchema() {
        if (this !== Schema_1.Schemas.getRegisteredSchema(this.schemaName)) {
            Schema_1.Schemas.unregisterSchema(this.schemaName);
            Schema_1.Schemas.registerSchema(this);
            ClassRegistry_1.ClassRegistry.registerModule(elementsModule, this);
        }
    }
    /** @public */
    static async importSchema(iModelDb) {
        if (iModelDb.isBriefcaseDb())
            await iModelDb.acquireSchemaLock();
        const stat = iModelDb[Symbols_1._nativeDb].importFunctionalSchema();
        if (core_bentley_1.DbResult.BE_SQLITE_OK !== stat) {
            throw new core_common_1.IModelError(stat, "Error importing Functional schema");
        }
    }
}
exports.FunctionalSchema = FunctionalSchema;
//# sourceMappingURL=FunctionalSchema.js.map