/*
*
* An XmlReader implementation for loading SGML (including HTML) converting it
* to well formed XML, by adding missing quotes, empty attribute values, ignoring
* duplicate attributes, case folding on tag names, adding missing closing tags
* based on SGML DTD information, and so on.
*
* Copyright (c) 2002 Microsoft Corporation. All rights reserved.
*
* Chris Lovett
*
*/
import { __extends } from "tslib";
/* MD 2/27/13
 * This software is being re-used under the Microsoft Public License (MS-PL):
 * -----------------------------------------------------------------------------
 * This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the
 * license, do not use the software.
 *
 * 1. Definitions
 * The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
 * A "contribution" is the original software, or any additions or changes to the software. A "contributor" is any person that distributes
 * its contribution under this license. "Licensed patents" are a contributor's patent claims that read directly on its contribution.
 *
 * 2. Grant of Rights
 * (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each
 *     contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare
 *     derivative works of its contribution, and distribute its contribution or any derivative works that you create.
 * (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each
 *     contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use,
 *     sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution
 *     in the software.
 *
 * 3. Conditions and Limitations
 * (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
 * (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license
 *     from such contributor to the software ends automatically.
 * (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are
 *     present in the software.
 * (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete
 *     copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may
 *     only do so under a license that complies with this license.
 * (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions.
 *     You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your
 *     local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
 * -----------------------------------------------------------------------------
 *
 * Note: edits have also been made to support namespace prefixes. Those changes are tagged with the following comment:
 * // MD - Added support for namespaces
 *
 * In addition, the public classes have been made internal and the namespace has been changed from Sgml to
 * Infragistics.Documents.Excel.Serialization.Excel2007.Sgml
 *
 * Also, I updated the code to work with Silverlight and WinRT.
 */
import { Base, markType } from "igniteui-angular-core";
import { HWStack } from "./HWStack";
import { Attribute } from "./Attribute";
import { stringCompare1 } from "igniteui-angular-core";
/**
 * @hidden
 */
var Node = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(Node, _super);
    function Node() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.p = 0;
        _this.k = null;
        _this.q = 0;
        _this.l = null;
        _this.f = false;
        _this.j = null;
        _this.c = null;
        _this.e = 0;
        _this.g = false;
        _this.d = new HWStack(10);
        return _this;
    }
    Node.prototype.o = function (a, b, c) {
        this.k = c;
        this.j = a;
        this.p = b;
        this.q = 0;
        this.l = null;
        this.f = true;
        this.d.c = 0;
        this.c = null;
    };
    Node.prototype.a = function (a, b, c, d) {
        var e;
        for (var f = 0, g = this.d.c; f < g; f++) {
            e = this.d.item(f);
            if (d && stringCompare1(e.e, a, 1) == 0) {
                return null;
            }
            else if (e.e == a) {
                return null;
            }
        }
        e = this.d.i();
        if (e == null) {
            e = new Attribute();
            this.d.item(this.d.c - 1, e);
        }
        e.g(a, b, c);
        return e;
    };
    Node.prototype.n = function (a) {
        for (var b = 0, c = this.d.c; b < c; b++) {
            var d = this.d.item(b);
            if (d.e == a) {
                this.d.j(b);
                return;
            }
        }
    };
    Node.prototype.m = function (a) {
        for (var b = 0, c = a.d.c; b < c; b++) {
            var d = a.d.item(b);
            var e = this.a(d.e, d.f, d.c, false);
            e.a = d.a;
        }
    };
    Object.defineProperty(Node.prototype, "h", {
        get: function () {
            return this.d.c;
        },
        enumerable: false,
        configurable: true
    });
    Node.prototype.i = function (a) {
        for (var b = 0, c = this.d.c; b < c; b++) {
            var d = this.d.item(b);
            if (d.e == a) {
                return b;
            }
        }
        return -1;
    };
    Node.prototype.b = function (a) {
        if (a >= 0 && a < this.d.c) {
            var b = this.d.item(a);
            return b;
        }
        return null;
    };
    Node.$t = markType(Node, 'Node');
    return Node;
}(Base));
export { Node };
