"use strict";

exports.__esModule = true;

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

/**
	Aggregation api for properties providing indexed or array-like access to child properties.

	@see {@link ArrayProperty}
	@see {@link IndexedProperty}
*/

var IndexedApi = function () {
	function IndexedApi(property) {
		_classCallCheck(this, IndexedApi);

		this._property = property;
	}

	_createClass(IndexedApi, [{
		key: "impl",
		value: function impl() {
			return this._property.__();
		}
	}, {
		key: "isActive",
		value: function isActive() {
			return this._property.isActive();
		}
	}, {
		key: "shadow",
		value: function shadow() {
			return this._property._();
		}

		//------------------------------------------------------------------------------------------------------
		//    Select Array methods:
		//          (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
		//------------------------------------------------------------------------------------------------------

	}, {
		key: "clear",
		value: function clear() {
			if (this.isActive()) {
				this.impl().clear();
			}
		}
	}, {
		key: "concat",
		value: function concat() {
			if (this.isActive()) {
				var _impl;

				return (_impl = this.impl()).concat.apply(_impl, arguments);
			}
		}
	}, {
		key: "pop",
		value: function pop() {
			if (this.isActive()) {
				return this.impl().pop();
			}
		}
	}, {
		key: "push",
		value: function push() {
			if (this.isActive()) {
				var _impl2;

				return (_impl2 = this.impl()).push.apply(_impl2, arguments);
			}
		}
	}, {
		key: "remove",
		value: function remove(idx) {
			if (this.isActive()) {
				return this.impl().remove(idx);
			}
		}
	}, {
		key: "shift",
		value: function shift() {
			if (this.isActive()) {
				return this.impl().shift();
			}
		}
	}, {
		key: "splice",
		value: function splice(start, deleteCount) {
			if (this.isActive()) {
				var _impl3;

				for (var _len = arguments.length, newItems = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
					newItems[_key - 2] = arguments[_key];
				}

				return (_impl3 = this.impl()).splice.apply(_impl3, [start, deleteCount].concat(newItems));
			}
		}
	}, {
		key: "unshift",
		value: function unshift() {
			if (this.isActive()) {
				var _impl4;

				return (_impl4 = this.impl()).unshift.apply(_impl4, arguments);
			}
		}
	}, {
		key: "length",
		get: function get() {
			if (this.isActive()) {
				return this.impl().length;
			}
		}
	}]);

	return IndexedApi;
}();

exports.default = IndexedApi;