var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
import { ParentNode } from './ParentNode';
import { Attribute } from './Attribute';
import { ClassList } from './ClassList';
var Element = /** @class */ (function (_super) {
    __extends(Element, _super);
    function Element(nodeName, prefix, localName, attributes) {
        var _this = _super.call(this, nodeName) || this;
        _this.nodeType = 1;
        _this.classList = new ClassList();
        _this.prefix = prefix;
        _this.localName = localName;
        _this._attributes = attributes;
        return _this;
    }
    Object.defineProperty(Element.prototype, "attributes", {
        get: function () { return this._attributes; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Element.prototype, "tagName", {
        get: function () { return this.nodeName; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Element.prototype, "id", {
        get: function () {
            return this.getAttribute('id');
        },
        set: function (id) { this.setAttribute('id', id); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Element.prototype, "className", {
        get: function () {
            return this.classList.value;
        },
        set: function (className) {
            this.classList.value = className;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Element.prototype, "parentElement", {
        get: function () {
            if (this.parentNode && this.parentNode.nodeType === 1) {
                return this.parentNode;
            }
            return undefined;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Element.prototype, "nextElementSibling", {
        get: function () {
            var parent = this.parentNode;
            if (!parent)
                return undefined;
            var nextSiblingIndex = parent.children.indexOf(this) + 1;
            if (nextSiblingIndex >= parent.children.length)
                return undefined;
            return parent.children[nextSiblingIndex];
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Element.prototype, "previousElementSibling", {
        get: function () {
            var parent = this.parentNode;
            if (!parent)
                return undefined;
            var nextSiblingIndex = parent.children.indexOf(this) - 1;
            if (nextSiblingIndex < 0)
                return undefined;
            return parent.children[nextSiblingIndex];
        },
        enumerable: true,
        configurable: true
    });
    Element.prototype.setAttribute = function (name, value) {
        if (name in this.attributes) {
            this._attributes[name].value = value;
        }
        else {
            this._attributes[name] = new Attribute(name, undefined, name, undefined, value);
        }
    };
    Element.prototype.getAttribute = function (name) {
        if (name in this.attributes) {
            return this.attributes[name].value;
        }
        else {
            return "";
        }
    };
    Element.prototype.hasAttribute = function (name) {
        return name in this.attributes;
    };
    return Element;
}(ParentNode));
export { Element };
//# sourceMappingURL=Element.js.map