"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AsyncJ = exports.AsyncJRef = exports.AsyncJWatch = exports.AsyncJCall = exports.AsyncJGet = void 0;
const evaluate_1 = require("../../../spec/evaluate");
const AsyncJGet = (value) => {
    return {
        $get({ name }, callback) {
            void (async () => {
                let data;
                try {
                    data = await value.get(name);
                }
                catch (err) {
                    callback(undefined, err.message);
                }
                callback(data);
            })();
        },
    };
};
exports.AsyncJGet = AsyncJGet;
const AsyncJCall = (value) => {
    return {
        $set({ name, data }, callback) {
            void (async () => {
                try {
                    const _data = (0, evaluate_1.evaluate)(data, {}, {});
                    await value.set(name, _data);
                }
                catch (err) {
                    callback(undefined, err.message);
                }
                callback();
            })();
        },
    };
};
exports.AsyncJCall = AsyncJCall;
const AsyncJWatch = (value) => {
    return {};
};
exports.AsyncJWatch = AsyncJWatch;
const AsyncJRef = (value) => {
    return {};
};
exports.AsyncJRef = AsyncJRef;
const AsyncJ = (value) => {
    return {
        ...(0, exports.AsyncJGet)(value),
        ...(0, exports.AsyncJCall)(value),
        ...(0, exports.AsyncJWatch)(value),
        ...(0, exports.AsyncJRef)(value),
    };
};
exports.AsyncJ = AsyncJ;
//# sourceMappingURL=AsyncJ.js.map