/*
 * Copyright 2018 The Kubernetes Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { TabState } from '@kui-shell/core/mdist/api/Tab';
/** cheapo uuid; we only need single-threaded uniqueness. Start from 2 so that we ensure the first tab always gets uuid 1. */
export function uuidForFirstTab() {
    return 1;
}
let _uuidCounter = uuidForFirstTab() + 1;
function uuid() {
    return (_uuidCounter++).toString();
}
export default class TabModel {
    constructor(_uuid = uuid(), desiredStatusStripeDecoration, doNotChangeActiveTab, _title, _state = new TabState(_uuid, desiredStatusStripeDecoration), _buttons = [], _initialCommandLine, _onClose, _exec) {
        this._uuid = _uuid;
        this.desiredStatusStripeDecoration = desiredStatusStripeDecoration;
        this._title = _title;
        this._state = _state;
        this._buttons = _buttons;
        this._initialCommandLine = _initialCommandLine;
        this._onClose = _onClose;
        this._exec = _exec;
        this._state.capture();
        if (!doNotChangeActiveTab) {
            this._state.updateStatusStripe();
        }
    }
    get uuid() {
        return this._uuid;
    }
    get state() {
        return this._state;
    }
    get buttons() {
        return this._buttons;
    }
    get title() {
        return this._title;
    }
    setTitle(newTitle) {
        return this.update(this.buttons, newTitle);
    }
    get initialCommandLine() {
        return this._initialCommandLine;
    }
    get onClose() {
        return this._onClose;
    }
    get exec() {
        return this._exec;
    }
    update(buttons, newTitle) {
        return new TabModel(this.uuid, undefined, undefined, newTitle || this.title, this.state, buttons, undefined, this.onClose);
    }
}
//# sourceMappingURL=TabModel.js.map