"use strict";

const { validateArguments } = require("@validatem/core");
const required = require("@validatem/required");
const arrayOf = require("@validatem/array-of");

const node = require("../ast-node");

module.exports = function (operations) {
	const isPossiblyRemoteField = require("../validators/operations/is-possibly-remote-field")(operations);

	return function hierarchical(_fields) {
		let [ fields ] = validateArguments(arguments, {
			fields: [ required, arrayOf([ required, isPossiblyRemoteField ]) ] // FIXME: Require minimum 2, probably
		});

		return node({
			type: "hierarchical",
			fields: fields
		});
	};
};
