"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.wrapFormData = void 0;
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'];
        }
        get(name) {
            return __awaiter(this, void 0, void 0, function* () {
                const data = formData.get(name);
                return Promise.resolve(data);
            });
        }
        set(name, data) {
            return __awaiter(this, void 0, void 0, function* () {
                formData.set(name, data);
                return;
            });
        }
        delete(name) {
            return __awaiter(this, void 0, void 0, function* () {
                formData.delete(name);
                return;
            });
        }
        hasKey(name) {
            return __awaiter(this, void 0, void 0, function* () {
                return formData.has(name);
            });
        }
        keys() {
            return __awaiter(this, void 0, void 0, function* () {
                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;
}
exports.wrapFormData = wrapFormData;
//# sourceMappingURL=FormData.js.map