/**
 * @author Gilles Coomans <gilles.coomans@gmail.com>
 * Chainable sheeter for js object/values sheets (deepjs related API)
 */
if (typeof define !== 'function') {
	var define = require('amdefine')(module);
}
define(["require", "./sheet", "./promise", "./compose"],
function(require, sheet, promise, composer){
	var Sheeter = new composer.Composer(sheet.sheet);	// create composer manager for namespace deep.sheet 
	Sheeter.add("deepLoad", "after", function(context, destructive) {
		return function(entry, options) {
			return deep.deepLoad(entry, context, destructive)
			.when(deep.Arguments([entry, options]));
		};
	});
	Sheeter.add("query", "after", function(q) {
		return function(entry, options) {
			return deep(entry).query(q)
			.done(function(s){
				return deep.Arguments([s,options]);
			});
		}
	});
	Sheeter.add("up", "after", function() {
		var args = arguments;
		return function(entry, options) {
			var d = deep(entry);
			return d.up.apply(d, args)
			.when(deep.Arguments([entry, options]));
		}
	});
	Sheeter.add("bottom", "after", function() {
		var args = arguments;
		return function(entry, options) {
			var d = deep(entry);
			return d.bottom.apply(d, args)
			.when(deep.Arguments([entry, options]));
		}
	});
	Sheeter.add("flatten", "after", function() {
		return function(entry, options) {
			return deep(entry).flatten()
			.when(deep.Arguments([entry, options]));
		}
	});
	Sheeter.add("sheet", "after", function() {
		var args = arguments;
		return function(entry, options) {
			var d = deep(entry);
			return d.sheet.apply(d, args)
			.when(deep.Arguments([entry, options]));
		}
	});
	Sheeter.add("transform", "after", function(fn) {
		return function(entry, options) {
			return deep(entry)
			.transform(fn)
			.when(deep.Arguments([entry, options]));
		}
	});
	Sheeter.add("interpret", "after", function(context) {
		return function(entry, options) {
			return deep(entry)
			.interpret(context, null, true)
			.when(deep.Arguments([entry, options]));
		}
	});
	return Sheeter;
});
/**
 * @author Gilles Coomans <gilles.coomans@gmail.com>
 * Chainable sheeter for js object/values sheets (deepjs related API)
 */
if (typeof define !== 'function') {
	var define = require('amdefine')(module);
}
define(["require", "./sheet", "./promise", "./compose", "./nodes", "./query", "./flatten", "./sheet", "./utils"],
function(require, sheet, promise, composer, nodes, querier, flattener, sheets, utils){
	var Sheeter = new composer.Composer(sheet.sheet);	// create composer manager for namespace deep.sheet 
	var Arguments = composer.compose.Arguments;
	Sheeter.add("deepLoad", "after", function(context, destructive) {
		return function(entry, options) {
			return nodes.deepLoad(entry, context, destructive)
			.when(Arguments([entry, options]));
		};
	});
	Sheeter.add("query", "after", function(q) {
		return function(entry, options) {
			return querier.query(entry, q);
		}
	});
	Sheeter.add("up", "after", function() {
		var args = arguments;
		return function(entry, options) {
			return nodes.asyncUps(entry, Array.prototype.slice.call(args))
			.when(Arguments([entry, options]));
		}
	});
	Sheeter.add("bottom", "after", function() {
		var args = arguments;
		return function(entry, options) {
			return nodes.asyncBottoms(entry, Array.prototype.slice.call(args))
			.when(Arguments([entry, options]));
		}
	});
	Sheeter.add("flatten", "after", function() {
		return function(entry, options) {
			return promise.when(flattener.flatten(entry))
			.when(Arguments([entry, options]));
		}
	});
	Sheeter.add("sheet", "after", function() {
		var args = Array.prototype.slice.call(arguments);
		return function(entry, options) {
			args.push(entry);
			return sheets.sheet.apply({}, args)
			.when(Arguments([entry, options]));
		}
	});
	Sheeter.add("transform", "after", function(fn) {
		return function(entry, options) {
			return promise.when(nodes.transform(entry, fn))
			.when(Arguments([entry, options]));
		}
	});
	//_________________________________________________________________
	Sheeter.add("interpret", "after", function(context) {
		return function(entry, options) {
			entry.value = utils.interpret(entry.value, context);
			if(entry.ancestor)
				entry.ancestor.value[entry.key] = entry.value;
			return Arguments([entry, options]);
		}
	});
	return Sheeter;
});
rewrite deep-sheeers