import { AppObjectEntity, getSingletonComponent, MemoizedNumber, } from "@vived/core";
export class InspectorTabEntity extends AppObjectEntity {
}
InspectorTabEntity.type = "InspectorTabEntity";
InspectorTabEntity.get = (appObjects) => getSingletonComponent(InspectorTabEntity.type, appObjects);
export function makeInspectorTabEntity(appObject) {
    return new InspectorTabEntityImp(appObject);
}
class InspectorTabEntityImp extends InspectorTabEntity {
    get inspectorTabs() {
        return [...this._inspectorTabs];
    }
    setInspectorTabs(tabs) {
        this._inspectorTabs = [...tabs];
        if (tabs.length === 0)
            return;
        this.memoizedIndex.val = 0;
    }
    get activeTabIndex() {
        return this.memoizedIndex.val;
    }
    set activeTabIndex(val) {
        if (val < 0 || val >= this._inspectorTabs.length) {
            this.warn("Invalid index: " + val);
            return;
        }
        this.memoizedIndex.val = val;
    }
    get activeTab() {
        if (this.memoizedIndex.val < 0)
            return "";
        return this._inspectorTabs[this.memoizedIndex.val];
    }
    set activeTab(inspectorTab) {
        const index = this._inspectorTabs.indexOf(inspectorTab);
        if (index === undefined || index < 0) {
            this.warn("Unknown inspector tab: " + inspectorTab);
            return;
        }
        this.memoizedIndex.val = index;
    }
    constructor(appObject) {
        super(appObject, InspectorTabEntity.type);
        this._inspectorTabs = [];
        this.memoizedIndex = new MemoizedNumber(-1, this.notifyOnChange);
        this.appObjects.registerSingleton(this);
    }
}
//# sourceMappingURL=InspectorTabEntity.js.map