/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Entities
 */
import { Id64, IModelStatus } from "@itwin/core-bentley";
import { IModelError } from "./IModelError";
/** The Id and relationship class of an Element that is somehow related to another Element
 * @public @preview
 */
export class RelatedElement {
    /** The Id of the element to which this element is related. */
    id;
    /** The full className of the relationship class. */
    relClassName;
    constructor(props) {
        this.id = Id64.fromJSON(props.id);
        this.relClassName = props.relClassName;
    }
    static fromJSON(json) {
        return json ? new RelatedElement(json) : undefined;
    }
    /** Used to *null out* an existing navigation relationship. */
    static none = new RelatedElement({ id: Id64.invalid });
    /** Accept the value of a navigation property that might be in the shortened format of just an id or might be in the full RelatedElement format. */
    static idFromJson(json) {
        if ((typeof json === "object") && ("id" in json)) {
            const r = RelatedElement.fromJSON(json);
            if (r === undefined)
                throw new IModelError(IModelStatus.BadArg, "Problem parsing Id64 from json");
            return r.id;
        }
        return Id64.fromJSON(json);
    }
    toJSON() {
        return {
            id: this.id,
            relClassName: this.relClassName,
        };
    }
}
/** A [RelatedElement]($common) relationship that describes the [TypeDefinitionElement]($backend) of an element.
 * @public @preview
 */
export class TypeDefinition extends RelatedElement {
}
/** determine if this is Placement2dProps
 * @public @preview
 */
export function isPlacement2dProps(props) {
    return props.angle !== undefined;
}
/** determine if this is Placement3dProps
 * @public @preview
 */
export function isPlacement3dProps(props) {
    return !isPlacement2dProps(props);
}
/** An enumeration of the different types of [SectionDrawing]($backend)s.
 * @public @preview
 * @extensions
 */
export var SectionType;
(function (SectionType) {
    SectionType[SectionType["Section"] = 3] = "Section";
    SectionType[SectionType["Detail"] = 4] = "Detail";
    SectionType[SectionType["Elevation"] = 5] = "Elevation";
    SectionType[SectionType["Plan"] = 6] = "Plan";
})(SectionType || (SectionType = {}));
/** The role that an attached [ExternalSource]($backend) plays.
 * @beta
 */
export var ExternalSourceAttachmentRole;
(function (ExternalSourceAttachmentRole) {
    /** The attached [ExternalSource]($backend) provides context. */
    ExternalSourceAttachmentRole[ExternalSourceAttachmentRole["SpecifyContext"] = 0] = "SpecifyContext";
    /** The attached [ExternalSource]($backend) models a part of the whole. */
    ExternalSourceAttachmentRole[ExternalSourceAttachmentRole["SpecifyPart"] = 1] = "SpecifyPart";
})(ExternalSourceAttachmentRole || (ExternalSourceAttachmentRole = {}));
/** The *rank* for a Category
 * @public @preview
 * @extensions
 */
export var Rank;
(function (Rank) {
    /** This category is predefined by the system */
    Rank[Rank["System"] = 0] = "System";
    /** This category is defined by a schema. Elements in this category are not recognized by system classes. */
    Rank[Rank["Domain"] = 1] = "Domain";
    /** This category is defined by an application. Elements in this category are not recognized by system and schema classes. */
    Rank[Rank["Application"] = 2] = "Application";
    /** This category is defined by a user. Elements in this category are not recognized by system, schema, and application classes. */
    Rank[Rank["User"] = 3] = "User";
})(Rank || (Rank = {}));
//# sourceMappingURL=ElementProps.js.map