"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 DisplayStyles
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.PlanProjectionSettings = void 0;
/** Describes how to draw a plan projection model. A plan projection model is a [GeometricModel3d]($backend) whose geometry all lies in
 * a single XY plane, wherein the Z coordinate of the plane may be arbitrary or flexible. Multiple plan projection models can be combined into one view
 * and drawn as "layers" with relative priorities.
 * @see [[DisplayStyle3dSettings.setPlanProjectionSettings]] to define plan projection settings for a [DisplayStyle3dState]($frontend).
 * @see [GeometricModel3d.isPlanProjection]($backend).
 * @public
 */
class PlanProjectionSettings {
    toJSON() {
        return {
            elevation: this.elevation,
            transparency: this.transparency,
            overlay: true === this.overlay ? true : undefined,
            enforceDisplayPriority: true === this.enforceDisplayPriority ? true : undefined,
        };
    }
    static fromJSON(props) {
        if (undefined === props)
            return undefined;
        if (undefined === props.elevation && undefined === props.transparency && undefined === props.overlay && undefined === props.enforceDisplayPriority)
            return undefined;
        return new PlanProjectionSettings(props);
    }
    /** @internal */
    constructor(props) {
        this.elevation = props.elevation;
        this.overlay = true === props.overlay;
        this.enforceDisplayPriority = true === props.enforceDisplayPriority;
        let transparency = props.transparency;
        if (undefined !== transparency)
            transparency = Math.max(0, Math.min(1, transparency));
        this.transparency = transparency;
    }
    /** Create a copy of this PlanProjectionSettings, optionally modifying some of its properties.
     * @param changedProps JSON representation of the properties to change.
     * @returns A PlanProjectionSettings with all of its properties set to match those of `this`, except those explicitly defined in `changedProps`.
     */
    clone(changedProps) {
        if (undefined === changedProps)
            return this;
        const props = this.toJSON();
        if (undefined !== changedProps.elevation)
            props.elevation = changedProps.elevation;
        if (undefined !== changedProps.transparency)
            props.transparency = changedProps.transparency;
        if (undefined !== changedProps.overlay)
            props.overlay = changedProps.overlay;
        if (undefined !== changedProps.enforceDisplayPriority)
            props.enforceDisplayPriority = changedProps.enforceDisplayPriority;
        return new PlanProjectionSettings(props);
    }
    /** Return true if these settings are equivalent to the specified settings. */
    equals(other) {
        if (this === other)
            return true;
        return this.elevation === other.elevation && this.transparency === other.transparency && this.overlay === other.overlay && this.enforceDisplayPriority === other.enforceDisplayPriority;
    }
}
exports.PlanProjectionSettings = PlanProjectionSettings;
//# sourceMappingURL=PlanProjectionSettings.js.map