"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 });
const _1 = require("../../../../Class/$");
const Functional_1 = require("../../../../Class/Functional");
const deepGet_1 = require("../../../../deepGet");
const deepSet_1 = require("../../../../deepSet");
const MethodNotImplementedError_1 = require("../../../../exception/MethodNotImplementedError");
const object_1 = require("../../../../util/object");
const _ids_1 = require("../../../_ids");
const f_1 = require("../../object/Keys/f");
class Spec_ extends Functional_1.Functional {
    constructor(system) {
        super({
            i: ['unit'],
            o: ['spec'],
        }, {
            input: {
                unit: {
                    ref: true,
                },
            },
            output: {
                spec: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_SPEC_0);
        this.__ = ['J'];
    }
    f({ unit }, done) {
        const spec = new (class Object_ extends _1.$ {
            get(name) {
                const _spec = unit.getSpec();
                return Promise.resolve(_spec[name]);
            }
            set(name, data) {
                const _spec = unit.getSpec();
                _spec[name] = data;
                return;
            }
            delete(name) {
                const _spec = unit.getSpec();
                delete _spec[name];
                return;
            }
            hasKey(name) {
                return __awaiter(this, void 0, void 0, function* () {
                    const _spec = unit.getSpec();
                    const has = (0, object_1.hasKey)(_spec, name);
                    return has;
                });
            }
            keys() {
                return __awaiter(this, void 0, void 0, function* () {
                    const _spec = unit.getSpec();
                    return (0, f_1.keys)(_spec);
                });
            }
            deepGet(path) {
                const _spec = unit.getSpec();
                return (0, deepGet_1.default)(_spec, path);
            }
            deepSet(path, data) {
                const _spec = unit.getSpec();
                (0, deepSet_1.deepSet_)(_spec, path, data);
                return;
            }
            deepDelete(path) {
                throw new MethodNotImplementedError_1.MethodNotImplementedError();
            }
            subscribe(path, key, listener) {
                throw new MethodNotImplementedError_1.MethodNotImplementedError();
            }
        })(this.__system);
        done({
            spec,
        });
    }
}
exports.default = Spec_;
//# sourceMappingURL=index.js.map