"use strict";
var EXPORTED_SYMBOLS = ["module"];
var module = function (application) {
var log = function (message) {
application.logger.trace("[Vector] " + message);
}
;
const _ERRORS = {
INVALID_ARGUMENTS_NUMBER: "You must provide at least one argument.",
INVALID_ARGUMENT_TYPE: "All constructor arguments must be numbers."};
function Vector() {
if (0 === arguments.length)
{
throw new Error(_ERRORS.INVALID_ARGUMENTS_NUMBER);
}

var argumentsArray = Array.prototype.slice.call(arguments);
this._validateArguments(argumentsArray);
this._coordinates = argumentsArray;
}

Vector.prototype = {
constructor: Vector,
_validateArguments: function Vector__validateArguments(array) {
var isInvalid = array.some(function (value) {
return "number" !== typeof value && ! value instanceof Number;
}
);
if (isInvalid)
{
throw new TypeError(_ERRORS.INVALID_ARGUMENT_TYPE);
}

}
,
toString: function Vector_toString() {
return "(" + this._coordinates.join(", ") + ")";
}
,
get length() {
var coordinates = this._coordinates;
if (1 === coordinates.length)
{
return Math.abs(coordinates[0]);
}

var quadraticSum = coordinates.map(function (x) x * x).reduce(function (previousValue, currentValue) previousValue + currentValue,0);
return Math.sqrt(Number(quadraticSum));
}
,
get x() {
return this._coordinates[0];
}
,
set x(value) {
this._coordinates[0] = value;
}
,
get y() {
return this._coordinates[1];
}
,
set y(value) {
if ("undefined" != typeof this._coordinates[1])
this._coordinates[1] = value;
}
,
get z() {
return this._coordinates[2];
}
,
set z(value) {
if ("undefined" != typeof this._coordinates[2])
this._coordinates[2] = value;
}
};
return Vector;
}
;
