"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapSharedRef = wrapSharedRef;
exports.wrapObject = wrapObject;
exports.wrapSharedObjectInterface = wrapSharedObjectInterface;
const _1 = require("../Class/$");
const ObjectReadOnly_1 = require("../exception/ObjectReadOnly");
const Object_1 = require("../Object");
function wrapSharedRef(data) {
    const _data = new Object_1.Object_(data.current);
    return {
        get(name) {
            return _data.get(name);
        },
        set(name, data) {
            return _data.set(name, data);
        },
        delete(name) {
            return _data.delete(name);
        },
        hasKey(name) {
            return _data.hasKey(name);
        },
        keys() {
            return _data.keys();
        },
        deepGet(path) {
            return _data.deepGet(path);
        },
        deepSet(path, data) {
            return _data.deepSet(path, data);
        },
        deepDelete(path) {
            return _data.deepDelete(path);
        },
        subscribe(path, key, listener) {
            return _data.subscribe(path, key, listener);
        },
        raw() {
            return data;
        },
    };
}
function wrapObject(data, system) {
    const _data = new Object_1.Object_(data);
    const _obj = new (class Object__ extends _1.$ {
        constructor() {
            super(...arguments);
            this.__ = ['V', 'J'];
        }
        read(callback) {
            callback(data);
        }
        write(data, callback) {
            throw new ObjectReadOnly_1.ReadOnlyError('object');
        }
        get(name) {
            return _data.get(name);
        }
        set(name, data) {
            return _data.set(name, data);
        }
        delete(name) {
            return _data.delete(name);
        }
        hasKey(name) {
            return _data.hasKey(name);
        }
        keys() {
            return _data.keys();
        }
        deepGet(path) {
            return _data.deepGet(path);
        }
        deepSet(path, data) {
            return _data.deepSet(path, data);
        }
        deepDelete(path) {
            return _data.deepDelete(path);
        }
        subscribe(path, key, listener) {
            return _data.subscribe(path, key, listener);
        }
        raw() {
            return data;
        }
    })(system);
    return _obj;
}
function wrapSharedObjectInterface(data, system) {
    return wrapObject(data.current, system);
}
//# sourceMappingURL=Object.js.map