"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Storage_ = void 0;
const storage_1 = require("../../../../client/util/web/storage");
const MethodNotImplementedError_1 = require("../../../../exception/MethodNotImplementedError");
class Storage_ {
    constructor(storage) {
        this._storage = storage;
    }
    read() {
        return __awaiter(this, void 0, void 0, function* () {
            const obj = (0, storage_1.getAllLocalStorage)();
            return obj;
        });
    }
    write(data) {
        return __awaiter(this, void 0, void 0, function* () {
            // TODO
            return;
        });
    }
    get(name) {
        return __awaiter(this, void 0, void 0, function* () {
            const value = this._storage.getItem(name);
            if (value === null) {
                throw new Error('item not found');
            }
            else {
                return value;
            }
        });
    }
    set(name, data) {
        return __awaiter(this, void 0, void 0, function* () {
            this._storage.setItem(name, data);
        });
    }
    delete(name) {
        return __awaiter(this, void 0, void 0, function* () {
            this._storage.removeItem(name);
        });
    }
    deepSet(path, data) {
        throw new MethodNotImplementedError_1.MethodNotImplementedError();
    }
    deepGet(path) {
        throw new MethodNotImplementedError_1.MethodNotImplementedError();
    }
    deepDelete(path) {
        throw new MethodNotImplementedError_1.MethodNotImplementedError();
    }
    keys() {
        return __awaiter(this, void 0, void 0, function* () {
            const keys = (0, storage_1.getStorageKeys)(this._storage);
            return keys;
        });
    }
    hasKey(name) {
        return __awaiter(this, void 0, void 0, function* () {
            const has = (0, storage_1.storageHasKey)(this._storage, name);
            return has;
        });
    }
    subscribe(path, key, listener) {
        throw new MethodNotImplementedError_1.MethodNotImplementedError();
    }
}
exports.Storage_ = Storage_;
//# sourceMappingURL=Storage_.js.map