/*
*
* 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 * as tslib_1 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.
 * -----------------------------------------------------------------------------
 *
 * 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, fromEn, markType, BaseError, EnumUtil, fromEnum, NotSupportedException, String_$type } from "igniteui-angular-core";
import { AttDef } from "./AttDef";
import { AttList } from "./AttList";
import { stringFormat } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { GroupType_$type } from "./GroupType";
import { Dictionary$2 } from "igniteui-angular-core";
import { Entity } from "./Entity";
import { StringBuilder } from "igniteui-angular-core";
import { NotImplementedException } from "igniteui-angular-core";
/**
 * @hidden
 */
var ElementDecl = /** @class */ (function (_super) {
    tslib_1.__extends(ElementDecl, _super);
    function ElementDecl(a, b, c, d, e, f) {
        var _this = _super.call(this) || this;
        _this.i = null;
        _this.h = false;
        _this.g = false;
        _this.e = null;
        _this.b = null;
        _this.a = null;
        _this.d = null;
        _this.i = a;
        _this.h = b;
        _this.g = c;
        _this.e = d;
        _this.b = e;
        _this.a = f;
        return _this;
    }
    ElementDecl.prototype.c = function (a) {
        return this.d._item(a.toUpperCase());
    };
    ElementDecl.prototype.j = function (a) {
        var e_1, _a;
        if (this.d == null) {
            this.d = a;
        }
        else {
            try {
                for (var _b = tslib_1.__values(fromEn(a)), _d = _b.next(); !_d.done; _d = _b.next()) {
                    var b = _d.value;
                    if (this.d._item(b.f) == null) {
                        this.d._c(b);
                    }
                }
            }
            catch (e_1_1) { e_1 = { error: e_1_1 }; }
            finally {
                try {
                    if (_d && !_d.done && (_a = _b.return)) _a.call(_b);
                }
                finally { if (e_1) throw e_1.error; }
            }
        }
    };
    ElementDecl.prototype.f = function (a, b) {
        if (this.a != null) {
            var e = this.a;
            for (var d = 0; d < e.length; d++) {
                var c = e[d];
                if (c == a) {
                    return false;
                }
            }
        }
        if (this.b != null) {
            var h = this.b;
            for (var g = 0; g < h.length; g++) {
                var f = h[g];
                if (f == a) {
                    return true;
                }
            }
        }
        return this.e.c(a, b);
    };
    ElementDecl.$t = markType(ElementDecl, 'ElementDecl');
    return ElementDecl;
}(Base));
export { ElementDecl };
/**
 * @hidden
 */
var ContentModel = /** @class */ (function (_super) {
    tslib_1.__extends(ContentModel, _super);
    function ContentModel() {
        var _this = _super.call(this) || this;
        _this.a = 0;
        _this.d = 0;
        _this.b = null;
        _this.b = new Group(null);
        return _this;
    }
    ContentModel.prototype.i = function () {
        this.b = new Group(this.b);
        this.d++;
    };
    ContentModel.prototype.e = function () {
        if (this.d == 0) {
            return -1;
        }
        this.d--;
        this.b.a.i(this.b);
        this.b = this.b.a;
        return this.d;
    };
    ContentModel.prototype.h = function (a) {
        this.b.k(a);
    };
    ContentModel.prototype.f = function (a) {
        this.b.h(a);
    };
    ContentModel.prototype.g = function (a) {
        this.b.j(a);
    };
    ContentModel.prototype.j = function (a) {
        switch (a) {
            case "EMPTY":
                this.a = 3;
                break;
            case "RCDATA":
                this.a = 2;
                break;
            case "CDATA":
                this.a = 1;
                break;
            default: throw new BaseError(1, stringFormat("Declared content type '{0}' is not supported", a));
        }
    };
    ContentModel.prototype.c = function (a, b) {
        if (this.a != 0) {
            return false;
        }
        return this.b.d(a, b);
    };
    ContentModel.$t = markType(ContentModel, 'ContentModel');
    return ContentModel;
}(Base));
export { ContentModel };
/**
 * @hidden
 */
var Group = /** @class */ (function (_super) {
    tslib_1.__extends(Group, _super);
    function Group(a) {
        var _this = _super.call(this) || this;
        _this.a = null;
        _this.g = null;
        _this.b = 0;
        _this.c = 0;
        _this.e = false;
        _this.a = a;
        _this.g = new List$1(Base.$, 0);
        _this.b = 0;
        _this.c = 0;
        return _this;
    }
    Object.defineProperty(Group.prototype, "f", {
        get: function () {
            return this.e && this.g.count == 0;
        },
        enumerable: true,
        configurable: true
    });
    Group.prototype.i = function (a) {
        this.g.add1(a);
    };
    Group.prototype.k = function (a) {
        if (a == "#PCDATA") {
            this.e = true;
        }
        else {
            this.g.add1(a);
        }
    };
    Group.prototype.h = function (a) {
        if (!this.e && this.g.count == 0) {
            throw new BaseError(1, stringFormat("Missing token before connector '{0}'.", a));
        }
        var b = 0;
        switch (a) {
            case ',':
                b = 3;
                break;
            case '|':
                b = 2;
                break;
            case '&':
                b = 1;
                break;
        }
        if (this.b != 0 && this.b != b) {
            throw new BaseError(1, stringFormat("Connector '{0}' is inconsistent with {1} group.", a, EnumUtil.getName(GroupType_$type, this.b)));
        }
        this.b = b;
    };
    Group.prototype.j = function (a) {
        var b = 0;
        switch (a) {
            case '?':
                b = 1;
                break;
            case '+':
                b = 3;
                break;
            case '*':
                b = 2;
                break;
        }
        this.c = b;
    };
    Group.prototype.d = function (a, b) {
        var e_2, _a, e_3, _b;
        try {
            for (var _d = tslib_1.__values(fromEnum(this.g)), _e = _d.next(); !_e.done; _e = _d.next()) {
                var c = _e.value;
                if (typeof c === 'string') {
                    if (c == a) {
                        return true;
                    }
                }
            }
        }
        catch (e_2_1) { e_2 = { error: e_2_1 }; }
        finally {
            try {
                if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
            }
            finally { if (e_2) throw e_2.error; }
        }
        try {
            for (var _f = tslib_1.__values(fromEnum(this.g)), _g = _f.next(); !_g.done; _g = _f.next()) {
                var d = _g.value;
                if (typeof d === 'string') {
                    var e = d;
                    var f = b.d(e);
                    if (f != null) {
                        if (f.h) {
                            if (f.f(a, b)) {
                                return true;
                            }
                        }
                    }
                }
                else {
                    var g = d;
                    if (g.d(a, b)) {
                        return true;
                    }
                }
            }
        }
        catch (e_3_1) { e_3 = { error: e_3_1 }; }
        finally {
            try {
                if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
            }
            finally { if (e_3) throw e_3.error; }
        }
        return false;
    };
    Group.$t = markType(Group, 'Group');
    return Group;
}(Base));
export { Group };
/**
 * @hidden
 */
var SgmlDtd = /** @class */ (function (_super) {
    tslib_1.__extends(SgmlDtd, _super);
    function SgmlDtd(a, b) {
        var _this = _super.call(this) || this;
        _this.r = null;
        _this.m = null;
        _this.o = null;
        _this.n = null;
        _this.w = null;
        _this.e = null;
        _this.am = null;
        _this.am = b;
        _this.r = a;
        _this.m = new Dictionary$2(String_$type, ElementDecl.$, 0);
        _this.o = new Dictionary$2(String_$type, Entity.$, 0);
        _this.n = new Dictionary$2(String_$type, Entity.$, 0);
        _this.w = new StringBuilder(0);
        return _this;
    }
    Object.defineProperty(SgmlDtd.prototype, "an", {
        get: function () {
            return this.am;
        },
        enumerable: true,
        configurable: true
    });
    SgmlDtd.j = function (a, b, c, d, e, f, g) {
        var h = new SgmlDtd(b, g);
        if (d != null && d != "") {
            h.al(a, new Entity(0, h.r, c, d, f));
        }
        if (e != null && e != "") {
            h.al(a, new Entity(1, b, e));
        }
        try {
            h.x();
        }
        catch (i) {
            throw new BaseError(1, i.message + h.e.r());
        }
        return h;
    };
    SgmlDtd.i = function (a, b, c, d, e, f, g) {
        var h = new SgmlDtd(b, g);
        h.al(a, new Entity(2, h.r, a, d, f));
        if (e != null && e != "") {
            h.al(a, new Entity(1, b, e));
        }
        try {
            h.x();
        }
        catch (i) {
            throw new BaseError(1, i.message + h.e.r());
        }
        return h;
    };
    SgmlDtd.prototype.f = function (a) {
        return this.n.item(a);
    };
    SgmlDtd.prototype.d = function (a) {
        return this.m.item(a.toUpperCase());
    };
    SgmlDtd.prototype.al = function (a, b) {
        b.ak(this.e, a);
        this.e = b;
        this.e.k();
    };
    SgmlDtd.prototype.ak = function () {
        if (this.e != null) {
            this.e.af();
        }
        if (this.e.b != null) {
            this.e = this.e.b;
        }
        else {
            this.e = null;
        }
    };
    SgmlDtd.prototype.x = function () {
        var a = this.e.j;
        while (true) {
            switch (a) {
                case "\uffff":
                    this.ak();
                    if (this.e == null) {
                        return;
                    }
                    a = this.e.j;
                    break;
                case ' ':
                case '\n':
                case '\r':
                case '\t':
                    a = this.e.k();
                    break;
                case '<':
                    this.ah();
                    a = this.e.k();
                    break;
                case '%':
                    var b = this.h(SgmlDtd.v);
                    try {
                        this.al(this.e.ae, b);
                    }
                    catch (c) {
                    }
                    a = this.e.j;
                    break;
                default:
                    this.e.ah("Unexpected character '{0}'", a);
                    break;
            }
        }
    };
    SgmlDtd.prototype.ah = function () {
        var a = this.e.k();
        if (a != '!') {
            this.e.ag("Found '{0}', but expecing declaration starting with '<!'");
            return;
        }
        a = this.e.k();
        if (a == '-') {
            a = this.e.k();
            if (a != '-') {
                this.e.ah("Expecting comment '<!--' but found {0}", a);
            }
            this.e.y(this.w, "Comment", "-->");
        }
        else if (a == '[') {
            this.ag();
        }
        else {
            var b = this.e.z(this.w, SgmlDtd.v, true);
            switch (b) {
                case "ENTITY":
                    this.ad();
                    break;
                case "ELEMENT":
                    this.ac();
                    break;
                case "ATTLIST":
                    this.z();
                    break;
                default:
                    this.e.aj("Invalid declaration '<!{0}'.  Expecting 'ENTITY', 'ELEMENT' or 'ATTLIST'.", b);
                    break;
            }
        }
    };
    SgmlDtd.prototype.l = function () {
        var a = this.e.j;
        while (a == '-') {
            a = this.k(true);
        }
        return a;
    };
    SgmlDtd.prototype.k = function (a) {
        var b = this.e.n;
        var c = this.e.k();
        if (a && c != '-') {
            this.e.ah("Expecting comment delimiter '--' but found {0}", c);
        }
        this.e.y(this.w, "Markup Comment", "--");
        return this.e.l();
    };
    SgmlDtd.prototype.ag = function () {
        this.e.k();
        var a = this.u("[");
        if (a == "INCLUDE") {
            this.af();
        }
        else if (a == "IGNORE") {
            this.ae();
        }
        else {
            this.e.aj("Unsupported marked section type '{0}'", a);
        }
    };
    SgmlDtd.prototype.af = function () {
        throw new NotImplementedException(1, "Include Section");
    };
    SgmlDtd.prototype.ae = function () {
        var a = this.e.n;
        var b = this.e.l();
        if (b != '[') {
            this.e.ah("Expecting '[' but found {0}", b);
        }
        this.e.y(this.w, "Conditional Section", "]]>");
    };
    SgmlDtd.prototype.u = function (a) {
        var b = this.e.l();
        if (b == '%') {
            var c = this.h(a);
            b = this.e.j;
            if (!c.e) {
                throw new NotSupportedException(1, "External parameter entity resolution");
            }
            return c.t.trim();
        }
        else {
            return this.e.z(this.w, a, true);
        }
    };
    SgmlDtd.prototype.h = function (a) {
        var b = this.e.k();
        var c = this.e.z(this.w, ";" + a, false);
        c = this.am.b(c);
        if (this.e.j == ';') {
            this.e.k();
        }
        var d = this.g(c);
        return d;
    };
    SgmlDtd.prototype.g = function (a) {
        var b = this.o.item(a);
        if (b == null) {
            this.e.aj("Reference to undefined parameter entity '{0}'", a);
        }
        return b;
    };
    SgmlDtd.prototype.ad = function () {
        var a = this.e.l();
        var b = (a == '%');
        if (b) {
            this.e.k();
            a = this.e.l();
        }
        var c = this.e.z(this.w, SgmlDtd.v, true);
        c = this.am.b(c);
        a = this.e.l();
        var d = null;
        if (a == '\"' || a == '\'') {
            var e = this.e.x(this.w, a);
            d = new Entity(1, c, e);
        }
        else {
            var f = null;
            var g = null;
            var h = this.e.z(this.w, SgmlDtd.v, true);
            if (Entity.f(h)) {
                a = this.e.l();
                var i = this.e.x(this.w, a);
                d = new Entity(1, c, i);
                d.al(h);
            }
            else {
                g = h;
                if (g == "PUBLIC") {
                    a = this.e.l();
                    if (a == '\"' || a == '\'') {
                        f = this.e.x(this.w, a);
                    }
                    else {
                        this.e.ah("Expecting public identifier literal but found '{0}'", a);
                    }
                }
                else if (g != "SYSTEM") {
                    this.e.aj("Invalid external identifier '{0}'.  Expecing 'PUBLIC' or 'SYSTEM'.", g);
                }
                var j = null;
                a = this.e.l();
                if (a == '\"' || a == '\'') {
                    j = this.e.x(this.w, a);
                }
                else if (a != '>') {
                    this.e.ah("Expecting system identifier literal but found '{0}'", a);
                }
                d = new Entity(0, c, f, j, this.e.v);
            }
        }
        a = this.e.l();
        if (a == '-') {
            a = this.l();
        }
        if (a != '>') {
            this.e.ah("Expecting end of entity declaration '>' but found '{0}'", a);
        }
        if (b) {
            this.o.addItem(d.u, d);
        }
        else {
            this.n.addItem(d.u, d);
        }
    };
    SgmlDtd.prototype.ac = function () {
        var a = this.e.l();
        var b = this.a(a, true);
        a = this.e.l().toUpperCase();
        var c = false;
        var d = false;
        if (a == 'O' || a == '-') {
            c = (a == 'O');
            this.e.k();
            a = this.e.l().toUpperCase();
            if (a == 'O' || a == '-') {
                d = (a == 'O');
                a = this.e.k();
            }
        }
        a = this.e.l();
        var e = this.c(a);
        a = this.e.l();
        var f = null;
        var g = null;
        if (a == '-') {
            a = this.e.k();
            if (a == '(') {
                f = this.a(a, true);
                a = this.e.l();
            }
            else if (a == '-') {
                a = this.k(false);
            }
            else {
                this.e.ah("Invalid syntax at '{0}'", a);
            }
        }
        if (a == '-') {
            a = this.l();
        }
        if (a == '+') {
            a = this.e.k();
            if (a != '(') {
                this.e.ah("Expecting inclusions name group", a);
            }
            g = this.a(a, true);
            a = this.e.l();
        }
        if (a == '-') {
            a = this.l();
        }
        if (a != '>') {
            this.e.ah("Expecting end of ELEMENT declaration '>' but found '{0}'", a);
        }
        for (var i = 0; i < b.length; i++) {
            var h = b[i];
            var j = h.toUpperCase();
            j = this.am.b(h);
            this.m.addItem(j, new ElementDecl(j, c, d, e, g, f));
        }
    };
    SgmlDtd.prototype.a = function (a, b) {
        var c = new List$1(String_$type, 0);
        if (a == '(') {
            a = this.e.k();
            a = this.e.l();
            while (a != ')') {
                a = this.e.l();
                if (a == '%') {
                    var d = this.h(SgmlDtd.s);
                    this.al(this.e.ae, d);
                    this.aj(c, b);
                    this.ak();
                    a = this.e.j;
                }
                else {
                    var e = this.e.z(this.w, SgmlDtd.s, b);
                    e = e.toUpperCase();
                    var f = this.am.b(e);
                    c.add(f);
                }
                a = this.e.l();
                if (a == '|' || a == ',') {
                    a = this.e.k();
                }
            }
            this.e.k();
        }
        else {
            var g = this.e.z(this.w, SgmlDtd.v, b);
            g = g.toUpperCase();
            g = this.am.b(g);
            c.add(g);
        }
        return c.toArray();
    };
    SgmlDtd.prototype.aj = function (a, b) {
        var c = this.e.j;
        c = this.e.l();
        while (c != "\uffff") {
            var d = void 0;
            if (c == '%') {
                var e = this.h(SgmlDtd.s);
                this.al(this.e.ae, e);
                this.aj(a, b);
                this.ak();
                c = this.e.j;
            }
            else {
                d = this.e.z(this.w, SgmlDtd.s, true);
                d = d.toUpperCase();
                d = this.am.b(d);
                a.add(d);
            }
            c = this.e.l();
            if (c == '|') {
                c = this.e.k();
                c = this.e.l();
            }
        }
    };
    SgmlDtd.prototype.c = function (a) {
        var b = new ContentModel();
        if (a == '(') {
            this.e.k();
            this.ai(')', b);
            a = this.e.k();
            if (a == '?' || a == '+' || a == '*') {
                b.g(a);
                this.e.k();
            }
        }
        else if (a == '%') {
            var c = this.h(SgmlDtd.q);
            this.al(this.e.ae, c);
            b = this.c(this.e.j);
            this.ak();
        }
        else {
            var d = this.u(SgmlDtd.q);
            b.j(d);
        }
        return b;
    };
    SgmlDtd.prototype.ai = function (a, b) {
        var c = b.d;
        var d = this.e.j;
        d = this.e.l();
        while (d != a || b.d > c) {
            if (d == "\uffff") {
                this.e.ag("Content Model was not closed");
            }
            if (d == '%') {
                var e = this.h(SgmlDtd.p);
                this.al(this.e.ae, e);
                this.ai("\uffff", b);
                this.ak();
                d = this.e.l();
            }
            else if (d == '(') {
                b.i();
                this.e.k();
                d = this.e.l();
            }
            else if (d == ')') {
                d = this.e.k();
                if (d == '*' || d == '+' || d == '?') {
                    b.g(d);
                    d = this.e.k();
                }
                if (b.e() < c) {
                    this.e.ag("Parameter entity cannot close a paren outside it's own scope");
                }
                d = this.e.l();
            }
            else if (d == ',' || d == '|' || d == '&') {
                b.f(d);
                this.e.k();
                d = this.e.l();
            }
            else {
                var f = void 0;
                if (d == '#') {
                    d = this.e.k();
                    f = "#" + this.e.z(this.w, SgmlDtd.p, true);
                }
                else {
                    f = this.e.z(this.w, SgmlDtd.p, true);
                }
                f = f.toUpperCase();
                f = this.am.b(f);
                d = this.e.j;
                if (d == '?' || d == '+' || d == '*') {
                    b.i();
                    b.h(f);
                    b.g(d);
                    b.e();
                    this.e.k();
                    d = this.e.l();
                }
                else {
                    b.h(f);
                    d = this.e.l();
                }
            }
        }
    };
    SgmlDtd.prototype.z = function () {
        var a = this.e.l();
        var b = this.a(a, true);
        var c = new AttList();
        this.aa(c, '>');
        for (var e = 0; e < b.length; e++) {
            var d = b[e];
            var f = this.m.item(d);
            if (f == null) {
                this.e.aj("ATTLIST references undefined ELEMENT {0}", d);
            }
            f.j(c);
        }
    };
    SgmlDtd.prototype.aa = function (a, b) {
        var c = this.e.l();
        while (c != b) {
            if (c == '%') {
                var d = this.h(SgmlDtd.t);
                this.al(this.e.ae, d);
                this.aa(a, "\uffff");
                this.ak();
                c = this.e.l();
            }
            else if (c == '-') {
                c = this.l();
            }
            else {
                var e = this.b(c);
                a._c(e);
            }
            c = this.e.l();
        }
    };
    SgmlDtd.prototype.b = function (a) {
        a = this.e.l();
        var b = this.u(SgmlDtd.v);
        b = b.toUpperCase();
        b = this.am.b(b);
        var c = new AttDef(b);
        a = this.e.l();
        if (a == '-') {
            a = this.l();
        }
        this.ab(a, c);
        a = this.e.l();
        if (a == '-') {
            a = this.l();
        }
        this.y(a, c);
        a = this.e.l();
        if (a == '-') {
            a = this.l();
        }
        return c;
    };
    SgmlDtd.prototype.ab = function (a, b) {
        if (a == '%') {
            var c = this.h(SgmlDtd.v);
            this.al(this.e.ae, c);
            this.ab(this.e.j, b);
            this.ak();
            a = this.e.j;
            return;
        }
        if (a == '(') {
            b.a = this.a(a, false);
            b.c = 16;
        }
        else {
            var d = this.u(SgmlDtd.v);
            if (d == "NOTATION") {
                a = this.e.l();
                if (a != '(') {
                    this.e.ah("Expecting name group '(', but found '{0}'", a);
                }
                b.c = 15;
                b.a = this.a(a, true);
            }
            else {
                b.g(d);
            }
        }
    };
    SgmlDtd.prototype.y = function (a, b) {
        if (a == '%') {
            var c = this.h(SgmlDtd.v);
            this.al(this.e.ae, c);
            this.y(this.e.j, b);
            this.ak();
            a = this.e.j;
            return;
        }
        var d = true;
        if (a == '#') {
            this.e.k();
            var e = this.e.z(this.w, SgmlDtd.v, true);
            d = b.d(e);
            a = this.e.l();
        }
        if (d) {
            if (a == '\'' || a == '\"') {
                var f = this.e.x(this.w, a);
                b.e = f;
                a = this.e.l();
            }
            else {
                var g = this.e.z(this.w, SgmlDtd.v, false);
                g = g.toUpperCase();
                g = this.am.b(g);
                b.e = g;
                a = this.e.l();
            }
        }
    };
    SgmlDtd.$t = markType(SgmlDtd, 'SgmlDtd');
    SgmlDtd.v = " \r\n\t";
    SgmlDtd.s = " \r\n\t|,)";
    SgmlDtd.q = " \r\n\t>";
    SgmlDtd.p = " \r\n\t,&|()?+*";
    SgmlDtd.t = " \t\r\n>";
    return SgmlDtd;
}(Base));
export { SgmlDtd };
//# sourceMappingURL=ElementDecl_combined.js.map