"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "SimpleIndexStore", {
    enumerable: true,
    get: function() {
        return SimpleIndexStore;
    }
});
const _env = require("@llamaindex/env");
const _constants = require("../constants.js");
const _SimpleKVStore = require("../kvStore/SimpleKVStore.js");
const _KVIndexStore = require("./KVIndexStore.js");
class SimpleIndexStore extends _KVIndexStore.KVIndexStore {
    kvStore;
    constructor(kvStore){
        kvStore = kvStore || new _SimpleKVStore.SimpleKVStore();
        super(kvStore);
        this.kvStore = kvStore;
    }
    static async fromPersistDir(persistDir = _constants.DEFAULT_PERSIST_DIR) {
        const persistPath = _env.path.join(persistDir, _constants.DEFAULT_INDEX_STORE_PERSIST_FILENAME);
        return this.fromPersistPath(persistPath);
    }
    static async fromPersistPath(persistPath) {
        const simpleKVStore = await _SimpleKVStore.SimpleKVStore.fromPersistPath(persistPath);
        return new SimpleIndexStore(simpleKVStore);
    }
    async persist(persistPath = _constants.DEFAULT_PERSIST_DIR) {
        this.kvStore.persist(persistPath);
    }
    static fromDict(saveDict) {
        const simpleKVStore = _SimpleKVStore.SimpleKVStore.fromDict(saveDict);
        return new SimpleIndexStore(simpleKVStore);
    }
    toDict() {
        if (!(this.kvStore instanceof _SimpleKVStore.SimpleKVStore)) {
            throw new Error("KVStore is not a SimpleKVStore");
        }
        return this.kvStore.toDict();
    }
}
