import { __esDecorate, __runInitializers } from "tslib";
import { LitElement } from 'lit';
import { property } from 'lit/decorators.js';
/**
 * A base class for API modeling screens.
 */
let ApiModelingScreen = (() => {
    let _classSuper = LitElement;
    let _model_decorators;
    let _model_initializers = [];
    let _model_extraInitializers = [];
    return class ApiModelingScreen extends _classSuper {
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _model_decorators = [property({ type: Object })];
            __esDecorate(this, null, _model_decorators, { kind: "accessor", name: "model", static: false, private: false, access: { has: obj => "model" in obj, get: obj => obj.model, set: (obj, value) => { obj.model = value; } }, metadata: _metadata }, _model_initializers, _model_extraInitializers);
            if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        #model_accessor_storage = __runInitializers(this, _model_initializers, void 0);
        /**
         * The API model being edited.
         */
        get model() { return this.#model_accessor_storage; }
        set model(value) { this.#model_accessor_storage = value; }
        constructor() {
            super();
            __runInitializers(this, _model_extraInitializers);
            this.handleDomainChange = this.handleDomainChange.bind(this);
        }
        willUpdate(cp) {
            if (cp.has('model')) {
                const old = cp.get('model');
                if (old) {
                    old.removeEventListener('change', this.handleDomainChange);
                }
                this.model?.addEventListener('change', this.handleDomainChange);
                this.handleModelChange(this.model);
            }
            super.willUpdate(cp);
        }
        /**
         * A handler for the model change events.
         */
        handleDomainChange() {
            this.requestUpdate();
        }
    };
})();
export { ApiModelingScreen };
//# sourceMappingURL=ApiModelingScreen.js.map