"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapFormData = wrapFormData;
const _1 = require("../Class/$");
const InvalidKeyPathError_1 = require("../exception/InvalidKeyPathError");
const MethodNotImplementedError_1 = require("../exception/MethodNotImplementedError");
function wrapFormData(formData, system) {
    const _obj = new (class Object_ extends _1.$ {
        constructor() {
            super(...arguments);
            this.__ = ['J', 'FD'];
        }
        async get(name) {
            const data = formData.get(name);
            return Promise.resolve(data);
        }
        async set(name, data) {
            formData.set(name, data);
            return;
        }
        async delete(name) {
            formData.delete(name);
            return;
        }
        async hasKey(name) {
            return formData.has(name);
        }
        async keys() {
            const keys = [];
            for (const key of formData.keys()) {
                keys.push(key);
            }
            return keys;
        }
        deepGet(path) {
            if (path.length === 1) {
                return Promise.resolve(formData.get(path[0]));
            }
            throw new InvalidKeyPathError_1.InvalidKeyPathError();
        }
        deepSet(path, data) {
            if (path.length === 1) {
                formData.set(path[0], data);
                return;
            }
            throw new InvalidKeyPathError_1.InvalidKeyPathError();
        }
        deepDelete(path) {
            if (path.length === 1) {
                formData.delete(path[0]);
                return;
            }
            throw new InvalidKeyPathError_1.InvalidKeyPathError();
        }
        subscribe(path, key, listener) {
            throw new MethodNotImplementedError_1.MethodNotImplementedError();
        }
        raw() {
            return formData;
        }
    })(system);
    return _obj;
}
//# sourceMappingURL=FormData.js.map