"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 Symbology
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubCategoryAppearance = void 0;
const core_bentley_1 = require("@itwin/core-bentley");
const ColorDef_1 = require("./ColorDef");
/** Parameters that define the way geometry on a [[SubCategory]] appears.
 * SubCategoryAppearance describes the intrinsic appearance of geometry belonging to that SubCategory, independent of a particular [[ViewState]].
 * Aspects of a SubCategory's appearance can be overridden in the context of a particular [[ViewState]] through the use of [[SubCategoryOverride]]s.
 * @public
 */
class SubCategoryAppearance {
    /** The fill color of geometry marked as being filled.
     * @note The transparency component of the fill color is ignored.
     * @see [[SubCategoryAppearance.fillTransparency]].
     */
    get fillColor() { return (undefined !== this._fillColor ? this._fillColor : this.color); }
    /** A value in the range [0, 1] indicating the fill transparency of the geometry where 0.0 means "fully opaque" and 1.0 means "fully transparent". */
    get fillTransparency() { return (undefined !== this._fillTransparency ? this._fillTransparency : this.transparency); }
    constructor(props) {
        if (!props) {
            this.color = ColorDef_1.ColorDef.black;
            this.weight = 0;
            this.priority = 0;
            this.transparency = 0;
            this.invisible = this.dontPlot = this.dontSnap = this.dontLocate = false;
            this.styleId = core_bentley_1.Id64.invalid;
            this.materialId = core_bentley_1.Id64.invalid;
            return;
        }
        this.invisible = core_bentley_1.JsonUtils.asBool(props.invisible);
        this.dontSnap = core_bentley_1.JsonUtils.asBool(props.dontSnap);
        this.dontLocate = core_bentley_1.JsonUtils.asBool(props.dontLocate);
        this.dontPlot = core_bentley_1.JsonUtils.asBool(props.dontPlot);
        this.color = ColorDef_1.ColorDef.fromJSON(props.color);
        this.weight = core_bentley_1.JsonUtils.asInt(props.weight);
        this.styleId = core_bentley_1.Id64.fromJSON(props.style);
        this.priority = core_bentley_1.JsonUtils.asInt(props.priority);
        this.materialId = core_bentley_1.Id64.fromJSON(props.material);
        this.transparency = core_bentley_1.JsonUtils.asDouble(props.transp);
        if (props.fill)
            this._fillColor = ColorDef_1.ColorDef.fromJSON(props.fill);
        if (props.transpFill)
            this._fillTransparency = core_bentley_1.JsonUtils.asDouble(props.transpFill);
    }
    equals(other) {
        return this.invisible === other.invisible &&
            this.dontPlot === other.dontPlot &&
            this.dontSnap === other.dontSnap &&
            this.dontLocate === other.dontLocate &&
            this.color.equals(other.color) &&
            this.weight === other.weight &&
            this.priority === other.priority &&
            this.styleId === other.styleId &&
            this.materialId === other.materialId &&
            this.transparency === other.transparency &&
            this.fillColor.equals(other.fillColor) &&
            this.fillTransparency === other.fillTransparency;
    }
    /** @internal */
    toJSON() {
        const val = { color: this.color.toJSON() };
        if (this.invisible)
            val.invisible = true;
        if (this.dontPlot)
            val.dontPlot = true;
        if (this.dontSnap)
            val.dontSnap = true;
        if (this.dontLocate)
            val.dontLocate = true;
        if (0 !== this.weight)
            val.weight = this.weight;
        if (0 !== this.priority)
            val.priority = this.priority;
        if (core_bentley_1.Id64.isValid(this.styleId))
            val.style = this.styleId;
        if (core_bentley_1.Id64.isValid(this.materialId))
            val.material = this.materialId;
        if (0.0 !== this.transparency)
            val.transp = this.transparency;
        if (this._fillColor)
            val.fill = this._fillColor.toJSON();
        if (this._fillTransparency)
            val.transpFill = this._fillTransparency;
        return val;
    }
    clone() { return new SubCategoryAppearance(this.toJSON()); }
}
exports.SubCategoryAppearance = SubCategoryAppearance;
SubCategoryAppearance.defaults = new SubCategoryAppearance();
//# sourceMappingURL=SubCategoryAppearance.js.map