"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 ContentView
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.FloatingContentControl = exports.ContentControl = exports.ContentControlActivatedEvent = void 0;
const React = require("react");
const appui_abstract_1 = require("@itwin/appui-abstract");
const ConfigurableUiControl_1 = require("../configurableui/ConfigurableUiControl");
/** ContentControl Activated Event class.
 * @public
 */
class ContentControlActivatedEvent extends appui_abstract_1.UiEvent {
}
exports.ContentControlActivatedEvent = ContentControlActivatedEvent;
/** The base class for Frontstage content controls.
 * @public
 */
class ContentControl extends ConfigurableUiControl_1.ConfigurableUiControl {
    /** Creates an instance of ContentControl.
     * @param info         An object that the subclass must pass to this base class.
     * @param options      Options provided via the applicationData in a [[ContentProps]].
     */
    constructor(info, options) {
        super(info, options);
        this._keyAdded = false;
    }
    /** Called when this ContentControl is activated */
    onActivated() { }
    /** Called when this ContentControl is deactivated */
    onDeactivated() { }
    /** Gets the type of ConfigurableUiControl, which is 'Content' in this case */
    getType() {
        return ConfigurableUiControl_1.ConfigurableUiControlType.Content;
    }
    /** Returns true if this control is a Viewport control. */
    get isViewport() {
        return false;
    }
    /** Returns the ScreenViewport if isViewport is true */
    get viewport() {
        return undefined;
    }
    getKeyedReactNode() {
        if (!this._keyAdded && React.isValidElement(this._reactNode)) {
            // istanbul ignore else
            if (!this._reactNode.key) {
                const additionalProps = { key: this.uniqueId };
                this._reactNode = React.cloneElement(this._reactNode, additionalProps);
            }
            this._keyAdded = true;
        }
        return this._reactNode;
    }
    getReactNode() {
        return this.getKeyedReactNode();
    }
    /** The React node associated with this control. */
    get reactNode() {
        return this.getReactNode();
    }
    set reactNode(r) {
        this._reactNode = r;
    }
    /** Get the NavigationAidControl associated with this ContentControl */
    get navigationAidControl() {
        return "";
    }
}
exports.ContentControl = ContentControl;
/**
 * @beta
 */
class FloatingContentControl extends ContentControl {
    constructor(uniqueId, name, node) {
        super(new ConfigurableUiControl_1.ConfigurableCreateInfo(name, uniqueId, name), undefined);
        this._reactNode = node;
    }
}
exports.FloatingContentControl = FloatingContentControl;
//# sourceMappingURL=ContentControl.js.map