import { __exports as S } from "../../../../../../../../_virtual/dom.js";
import { __require as We } from "./conventions.js";
var Me;
function Ze() {
  if (Me) return S;
  Me = 1;
  var ie = We(), v = ie.find, B = ie.NAMESPACE;
  function Ue(e) {
    return e !== "";
  }
  function Pe(e) {
    return e ? e.split(/[\t\n\f\r ]+/).filter(Ue) : [];
  }
  function Be(e, t) {
    return e.hasOwnProperty(t) || (e[t] = !0), e;
  }
  function oe(e) {
    if (!e) return [];
    var t = Pe(e);
    return Object.keys(t.reduce(Be, {}));
  }
  function Ve(e) {
    return function(t) {
      return e && e.indexOf(t) !== -1;
    };
  }
  function V(e, t) {
    for (var n in e)
      Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
  }
  function p(e, t) {
    var n = e.prototype;
    if (!(n instanceof t)) {
      let r = function() {
      };
      r.prototype = t.prototype, r = new r(), V(n, r), e.prototype = n = r;
    }
    n.constructor != e && (typeof e != "function" && console.error("unknown Class:" + e), n.constructor = e);
  }
  var h = {}, E = h.ELEMENT_NODE = 1, b = h.ATTRIBUTE_NODE = 2, G = h.TEXT_NODE = 3, ae = h.CDATA_SECTION_NODE = 4, ue = h.ENTITY_REFERENCE_NODE = 5, ke = h.ENTITY_NODE = 6, se = h.PROCESSING_INSTRUCTION_NODE = 7, fe = h.COMMENT_NODE = 8, le = h.DOCUMENT_NODE = 9, ce = h.DOCUMENT_TYPE_NODE = 10, y = h.DOCUMENT_FRAGMENT_NODE = 11, je = h.NOTATION_NODE = 12, l = {}, f = {};
  l.INDEX_SIZE_ERR = (f[1] = "Index size error", 1), l.DOMSTRING_SIZE_ERR = (f[2] = "DOMString size error", 2);
  var m = l.HIERARCHY_REQUEST_ERR = (f[3] = "Hierarchy request error", 3);
  l.WRONG_DOCUMENT_ERR = (f[4] = "Wrong document", 4), l.INVALID_CHARACTER_ERR = (f[5] = "Invalid character", 5), l.NO_DATA_ALLOWED_ERR = (f[6] = "No data allowed", 6), l.NO_MODIFICATION_ALLOWED_ERR = (f[7] = "No modification allowed", 7);
  var pe = l.NOT_FOUND_ERR = (f[8] = "Not found", 8);
  l.NOT_SUPPORTED_ERR = (f[9] = "Not supported", 9);
  var he = l.INUSE_ATTRIBUTE_ERR = (f[10] = "Attribute in use", 10);
  l.INVALID_STATE_ERR = (f[11] = "Invalid state", 11), l.SYNTAX_ERR = (f[12] = "Syntax error", 12), l.INVALID_MODIFICATION_ERR = (f[13] = "Invalid modification", 13), l.NAMESPACE_ERR = (f[14] = "Invalid namespace", 14), l.INVALID_ACCESS_ERR = (f[15] = "Invalid access", 15);
  function s(e, t) {
    if (t instanceof Error)
      var n = t;
    else
      n = this, Error.call(this, f[e]), this.message = f[e], Error.captureStackTrace && Error.captureStackTrace(this, s);
    return n.code = e, t && (this.message = this.message + ": " + t), n;
  }
  s.prototype = Error.prototype, V(l, s);
  function g() {
  }
  g.prototype = {
    /**
     * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
     * @standard level1
     */
    length: 0,
    /**
     * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
     * @standard level1
     * @param index  unsigned long
     *   Index into the collection.
     * @return Node
     * 	The node at the indexth position in the NodeList, or null if that is not a valid index.
     */
    item: function(e) {
      return e >= 0 && e < this.length ? this[e] : null;
    },
    toString: function(e, t) {
      for (var n = [], r = 0; r < this.length; r++)
        U(this[r], n, e, t);
      return n.join("");
    },
    /**
     * @private
     * @param {function (Node):boolean} predicate
     * @returns {Node[]}
     */
    filter: function(e) {
      return Array.prototype.filter.call(this, e);
    },
    /**
     * @private
     * @param {Node} item
     * @returns {number}
     */
    indexOf: function(e) {
      return Array.prototype.indexOf.call(this, e);
    }
  };
  function M(e, t) {
    this._node = e, this._refresh = t, Q(this);
  }
  function Q(e) {
    var t = e._node._inc || e._node.ownerDocument._inc;
    if (e._inc !== t) {
      var n = e._refresh(e._node);
      if (Ce(e, "length", n.length), !e.$$length || n.length < e.$$length)
        for (var r = n.length; r in e; r++)
          Object.prototype.hasOwnProperty.call(e, r) && delete e[r];
      V(n, e), e._inc = t;
    }
  }
  M.prototype.item = function(e) {
    return Q(this), this[e] || null;
  }, p(M, g);
  function X() {
  }
  function me(e, t) {
    for (var n = e.length; n--; )
      if (e[n] === t)
        return n;
  }
  function Ne(e, t, n, r) {
    if (r ? t[me(t, r)] = n : t[t.length++] = n, e) {
      n.ownerElement = e;
      var i = e.ownerDocument;
      i && (r && Te(i, e, r), Le(i, e, n));
    }
  }
  function Ee(e, t, n) {
    var r = me(t, n);
    if (r >= 0) {
      for (var i = t.length - 1; r < i; )
        t[r] = t[++r];
      if (t.length = i, e) {
        var o = e.ownerDocument;
        o && (Te(o, e, n), n.ownerElement = null);
      }
    } else
      throw new s(pe, new Error(e.tagName + "@" + n));
  }
  X.prototype = {
    length: 0,
    item: g.prototype.item,
    getNamedItem: function(e) {
      for (var t = this.length; t--; ) {
        var n = this[t];
        if (n.nodeName == e)
          return n;
      }
    },
    setNamedItem: function(e) {
      var t = e.ownerElement;
      if (t && t != this._ownerElement)
        throw new s(he);
      var n = this.getNamedItem(e.nodeName);
      return Ne(this._ownerElement, this, e, n), n;
    },
    /* returns Node */
    setNamedItemNS: function(e) {
      var t = e.ownerElement, n;
      if (t && t != this._ownerElement)
        throw new s(he);
      return n = this.getNamedItemNS(e.namespaceURI, e.localName), Ne(this._ownerElement, this, e, n), n;
    },
    /* returns Node */
    removeNamedItem: function(e) {
      var t = this.getNamedItem(e);
      return Ee(this._ownerElement, this, t), t;
    },
    // raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
    //for level2
    removeNamedItemNS: function(e, t) {
      var n = this.getNamedItemNS(e, t);
      return Ee(this._ownerElement, this, n), n;
    },
    getNamedItemNS: function(e, t) {
      for (var n = this.length; n--; ) {
        var r = this[n];
        if (r.localName == t && r.namespaceURI == e)
          return r;
      }
      return null;
    }
  };
  function ve() {
  }
  ve.prototype = {
    /**
     * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported.
     * The different implementations fairly diverged in what kind of features were reported.
     * The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.
     *
     * @deprecated It is deprecated and modern browsers return true in all cases.
     *
     * @param {string} feature
     * @param {string} [version]
     * @returns {boolean} always true
     *
     * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
     * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
     * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
     */
    hasFeature: function(e, t) {
      return !0;
    },
    /**
     * Creates an XML Document object of the specified type with its document element.
     *
     * __It behaves slightly different from the description in the living standard__:
     * - There is no interface/class `XMLDocument`, it returns a `Document` instance.
     * - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.
     * - this implementation is not validating names or qualified names
     *   (when parsing XML strings, the SAX parser takes care of that)
     *
     * @param {string|null} namespaceURI
     * @param {string} qualifiedName
     * @param {DocumentType=null} doctype
     * @returns {Document}
     *
     * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
     * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial)
     * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument  DOM Level 2 Core
     *
     * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
     * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
     * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
     */
    createDocument: function(e, t, n) {
      var r = new j();
      if (r.implementation = this, r.childNodes = new g(), r.doctype = n || null, n && r.appendChild(n), t) {
        var i = r.createElementNS(e, t);
        r.appendChild(i);
      }
      return r;
    },
    /**
     * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
     *
     * __This behavior is slightly different from the in the specs__:
     * - this implementation is not validating names or qualified names
     *   (when parsing XML strings, the SAX parser takes care of that)
     *
     * @param {string} qualifiedName
     * @param {string} [publicId]
     * @param {string} [systemId]
     * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
     * 				  or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
     *
     * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN
     * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core
     * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard
     *
     * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
     * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
     * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
     */
    createDocumentType: function(e, t, n) {
      var r = new W();
      return r.name = e, r.nodeName = e, r.publicId = t || "", r.systemId = n || "", r;
    }
  };
  function a() {
  }
  a.prototype = {
    firstChild: null,
    lastChild: null,
    previousSibling: null,
    nextSibling: null,
    attributes: null,
    parentNode: null,
    childNodes: null,
    ownerDocument: null,
    nodeValue: null,
    namespaceURI: null,
    prefix: null,
    localName: null,
    // Modified in DOM Level 2:
    insertBefore: function(e, t) {
      return z(this, e, t);
    },
    replaceChild: function(e, t) {
      z(this, e, t, De), t && this.removeChild(t);
    },
    removeChild: function(e) {
      return ye(this, e);
    },
    appendChild: function(e) {
      return this.insertBefore(e, null);
    },
    hasChildNodes: function() {
      return this.firstChild != null;
    },
    cloneNode: function(e) {
      return re(this.ownerDocument || this, this, e);
    },
    // Modified in DOM Level 2:
    normalize: function() {
      for (var e = this.firstChild; e; ) {
        var t = e.nextSibling;
        t && t.nodeType == G && e.nodeType == G ? (this.removeChild(t), e.appendData(t.data)) : (e.normalize(), e = t);
      }
    },
    // Introduced in DOM Level 2:
    isSupported: function(e, t) {
      return this.ownerDocument.implementation.hasFeature(e, t);
    },
    // Introduced in DOM Level 2:
    hasAttributes: function() {
      return this.attributes.length > 0;
    },
    /**
     * Look up the prefix associated to the given namespace URI, starting from this node.
     * **The default namespace declarations are ignored by this method.**
     * See Namespace Prefix Lookup for details on the algorithm used by this method.
     *
     * _Note: The implementation seems to be incomplete when compared to the algorithm described in the specs._
     *
     * @param {string | null} namespaceURI
     * @returns {string | null}
     * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix
     * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo
     * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
     * @see https://github.com/xmldom/xmldom/issues/322
     */
    lookupPrefix: function(e) {
      for (var t = this; t; ) {
        var n = t._nsMap;
        if (n) {
          for (var r in n)
            if (Object.prototype.hasOwnProperty.call(n, r) && n[r] === e)
              return r;
        }
        t = t.nodeType == b ? t.ownerDocument : t.parentNode;
      }
      return null;
    },
    // Introduced in DOM Level 3:
    lookupNamespaceURI: function(e) {
      for (var t = this; t; ) {
        var n = t._nsMap;
        if (n && Object.prototype.hasOwnProperty.call(n, e))
          return n[e];
        t = t.nodeType == b ? t.ownerDocument : t.parentNode;
      }
      return null;
    },
    // Introduced in DOM Level 3:
    isDefaultNamespace: function(e) {
      var t = this.lookupPrefix(e);
      return t == null;
    }
  };
  function de(e) {
    return e == "<" && "&lt;" || e == ">" && "&gt;" || e == "&" && "&amp;" || e == '"' && "&quot;" || "&#" + e.charCodeAt() + ";";
  }
  V(h, a), V(h, a.prototype);
  function k(e, t) {
    if (t(e))
      return !0;
    if (e = e.firstChild)
      do
        if (k(e, t))
          return !0;
      while (e = e.nextSibling);
  }
  function j() {
    this.ownerDocument = this;
  }
  function Le(e, t, n) {
    e && e._inc++;
    var r = n.namespaceURI;
    r === B.XMLNS && (t._nsMap[n.prefix ? n.localName : ""] = n.value);
  }
  function Te(e, t, n, r) {
    e && e._inc++;
    var i = n.namespaceURI;
    i === B.XMLNS && delete t._nsMap[n.prefix ? n.localName : ""];
  }
  function Z(e, t, n) {
    if (e && e._inc) {
      e._inc++;
      var r = t.childNodes;
      if (n)
        r[r.length++] = n;
      else {
        for (var i = t.firstChild, o = 0; i; )
          r[o++] = i, i = i.nextSibling;
        r.length = o, delete r[r.length];
      }
    }
  }
  function ye(e, t) {
    var n = t.previousSibling, r = t.nextSibling;
    return n ? n.nextSibling = r : e.firstChild = r, r ? r.previousSibling = n : e.lastChild = n, t.parentNode = null, t.previousSibling = null, t.nextSibling = null, Z(e.ownerDocument, e), t;
  }
  function Ye(e) {
    return e && (e.nodeType === a.DOCUMENT_NODE || e.nodeType === a.DOCUMENT_FRAGMENT_NODE || e.nodeType === a.ELEMENT_NODE);
  }
  function Ge(e) {
    return e && (d(e) || J(e) || _(e) || e.nodeType === a.DOCUMENT_FRAGMENT_NODE || e.nodeType === a.COMMENT_NODE || e.nodeType === a.PROCESSING_INSTRUCTION_NODE);
  }
  function _(e) {
    return e && e.nodeType === a.DOCUMENT_TYPE_NODE;
  }
  function d(e) {
    return e && e.nodeType === a.ELEMENT_NODE;
  }
  function J(e) {
    return e && e.nodeType === a.TEXT_NODE;
  }
  function ge(e, t) {
    var n = e.childNodes || [];
    if (v(n, d) || _(t))
      return !1;
    var r = v(n, _);
    return !(t && r && n.indexOf(r) > n.indexOf(t));
  }
  function _e(e, t) {
    var n = e.childNodes || [];
    function r(o) {
      return d(o) && o !== t;
    }
    if (v(n, r))
      return !1;
    var i = v(n, _);
    return !(t && i && n.indexOf(i) > n.indexOf(t));
  }
  function Xe(e, t, n) {
    if (!Ye(e))
      throw new s(m, "Unexpected parent node type " + e.nodeType);
    if (n && n.parentNode !== e)
      throw new s(pe, "child not in parent");
    if (
      // 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a "HierarchyRequestError" DOMException.
      !Ge(t) || // 5. If either `node` is a Text node and `parent` is a document,
      // the sax parser currently adds top level text nodes, this will be fixed in 0.9.0
      // || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)
      // or `node` is a doctype and `parent` is not a document, then throw a "HierarchyRequestError" DOMException.
      _(t) && e.nodeType !== a.DOCUMENT_NODE
    )
      throw new s(
        m,
        "Unexpected node type " + t.nodeType + " for parent node type " + e.nodeType
      );
  }
  function ze(e, t, n) {
    var r = e.childNodes || [], i = t.childNodes || [];
    if (t.nodeType === a.DOCUMENT_FRAGMENT_NODE) {
      var o = i.filter(d);
      if (o.length > 1 || v(i, J))
        throw new s(m, "More than one element or text in fragment");
      if (o.length === 1 && !ge(e, n))
        throw new s(m, "Element in fragment can not be inserted before doctype");
    }
    if (d(t) && !ge(e, n))
      throw new s(m, "Only one element can be added and only after doctype");
    if (_(t)) {
      if (v(r, _))
        throw new s(m, "Only one doctype is allowed");
      var u = v(r, d);
      if (n && r.indexOf(u) < r.indexOf(n))
        throw new s(m, "Doctype can only be inserted before an element");
      if (!n && u)
        throw new s(m, "Doctype can not be appended since element is present");
    }
  }
  function De(e, t, n) {
    var r = e.childNodes || [], i = t.childNodes || [];
    if (t.nodeType === a.DOCUMENT_FRAGMENT_NODE) {
      var o = i.filter(d);
      if (o.length > 1 || v(i, J))
        throw new s(m, "More than one element or text in fragment");
      if (o.length === 1 && !_e(e, n))
        throw new s(m, "Element in fragment can not be inserted before doctype");
    }
    if (d(t) && !_e(e, n))
      throw new s(m, "Only one element can be added and only after doctype");
    if (_(t)) {
      if (v(r, function(D) {
        return _(D) && D !== n;
      }))
        throw new s(m, "Only one doctype is allowed");
      var u = v(r, d);
      if (n && r.indexOf(u) < r.indexOf(n))
        throw new s(m, "Doctype can only be inserted before an element");
    }
  }
  function z(e, t, n, r) {
    Xe(e, t, n), e.nodeType === a.DOCUMENT_NODE && (r || ze)(e, t, n);
    var i = t.parentNode;
    if (i && i.removeChild(t), t.nodeType === y) {
      var o = t.firstChild;
      if (o == null)
        return t;
      var u = t.lastChild;
    } else
      o = u = t;
    var N = n ? n.previousSibling : e.lastChild;
    o.previousSibling = N, u.nextSibling = n, N ? N.nextSibling = o : e.firstChild = o, n == null ? e.lastChild = u : n.previousSibling = u;
    do
      o.parentNode = e;
    while (o !== u && (o = o.nextSibling));
    return Z(e.ownerDocument || e, e), t.nodeType == y && (t.firstChild = t.lastChild = null), t;
  }
  function $e(e, t) {
    return t.parentNode && t.parentNode.removeChild(t), t.parentNode = e, t.previousSibling = e.lastChild, t.nextSibling = null, t.previousSibling ? t.previousSibling.nextSibling = t : e.firstChild = t, e.lastChild = t, Z(e.ownerDocument, e, t), t;
  }
  j.prototype = {
    //implementation : null,
    nodeName: "#document",
    nodeType: le,
    /**
     * The DocumentType node of the document.
     *
     * @readonly
     * @type DocumentType
     */
    doctype: null,
    documentElement: null,
    _inc: 1,
    insertBefore: function(e, t) {
      if (e.nodeType == y) {
        for (var n = e.firstChild; n; ) {
          var r = n.nextSibling;
          this.insertBefore(n, t), n = r;
        }
        return e;
      }
      return z(this, e, t), e.ownerDocument = this, this.documentElement === null && e.nodeType === E && (this.documentElement = e), e;
    },
    removeChild: function(e) {
      return this.documentElement == e && (this.documentElement = null), ye(this, e);
    },
    replaceChild: function(e, t) {
      z(this, e, t, De), e.ownerDocument = this, t && this.removeChild(t), d(e) && (this.documentElement = e);
    },
    // Introduced in DOM Level 2:
    importNode: function(e, t) {
      return Ae(this, e, t);
    },
    // Introduced in DOM Level 2:
    getElementById: function(e) {
      var t = null;
      return k(this.documentElement, function(n) {
        if (n.nodeType == E && n.getAttribute("id") == e)
          return t = n, !0;
      }), t;
    },
    /**
     * The `getElementsByClassName` method of `Document` interface returns an array-like object
     * of all child elements which have **all** of the given class name(s).
     *
     * Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters.
     *
     *
     * Warning: This is a live LiveNodeList.
     * Changes in the DOM will reflect in the array as the changes occur.
     * If an element selected by this array no longer qualifies for the selector,
     * it will automatically be removed. Be aware of this for iteration purposes.
     *
     * @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace
     *
     * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
     * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
     */
    getElementsByClassName: function(e) {
      var t = oe(e);
      return new M(this, function(n) {
        var r = [];
        return t.length > 0 && k(n.documentElement, function(i) {
          if (i !== n && i.nodeType === E) {
            var o = i.getAttribute("class");
            if (o) {
              var u = e === o;
              if (!u) {
                var N = oe(o);
                u = t.every(Ve(N));
              }
              u && r.push(i);
            }
          }
        }), r;
      });
    },
    //document factory method:
    createElement: function(e) {
      var t = new w();
      t.ownerDocument = this, t.nodeName = e, t.tagName = e, t.localName = e, t.childNodes = new g();
      var n = t.attributes = new X();
      return n._ownerElement = t, t;
    },
    createDocumentFragment: function() {
      var e = new F();
      return e.ownerDocument = this, e.childNodes = new g(), e;
    },
    createTextNode: function(e) {
      var t = new K();
      return t.ownerDocument = this, t.appendData(e), t;
    },
    createComment: function(e) {
      var t = new q();
      return t.ownerDocument = this, t.appendData(e), t;
    },
    createCDATASection: function(e) {
      var t = new H();
      return t.ownerDocument = this, t.appendData(e), t;
    },
    createProcessingInstruction: function(e, t) {
      var n = new te();
      return n.ownerDocument = this, n.tagName = n.nodeName = n.target = e, n.nodeValue = n.data = t, n;
    },
    createAttribute: function(e) {
      var t = new $();
      return t.ownerDocument = this, t.name = e, t.nodeName = e, t.localName = e, t.specified = !0, t;
    },
    createEntityReference: function(e) {
      var t = new ee();
      return t.ownerDocument = this, t.nodeName = e, t;
    },
    // Introduced in DOM Level 2:
    createElementNS: function(e, t) {
      var n = new w(), r = t.split(":"), i = n.attributes = new X();
      return n.childNodes = new g(), n.ownerDocument = this, n.nodeName = t, n.tagName = t, n.namespaceURI = e, r.length == 2 ? (n.prefix = r[0], n.localName = r[1]) : n.localName = t, i._ownerElement = n, n;
    },
    // Introduced in DOM Level 2:
    createAttributeNS: function(e, t) {
      var n = new $(), r = t.split(":");
      return n.ownerDocument = this, n.nodeName = t, n.name = t, n.namespaceURI = e, n.specified = !0, r.length == 2 ? (n.prefix = r[0], n.localName = r[1]) : n.localName = t, n;
    }
  }, p(j, a);
  function w() {
    this._nsMap = {};
  }
  w.prototype = {
    nodeType: E,
    hasAttribute: function(e) {
      return this.getAttributeNode(e) != null;
    },
    getAttribute: function(e) {
      var t = this.getAttributeNode(e);
      return t && t.value || "";
    },
    getAttributeNode: function(e) {
      return this.attributes.getNamedItem(e);
    },
    setAttribute: function(e, t) {
      var n = this.ownerDocument.createAttribute(e);
      n.value = n.nodeValue = "" + t, this.setAttributeNode(n);
    },
    removeAttribute: function(e) {
      var t = this.getAttributeNode(e);
      t && this.removeAttributeNode(t);
    },
    //four real opeartion method
    appendChild: function(e) {
      return e.nodeType === y ? this.insertBefore(e, null) : $e(this, e);
    },
    setAttributeNode: function(e) {
      return this.attributes.setNamedItem(e);
    },
    setAttributeNodeNS: function(e) {
      return this.attributes.setNamedItemNS(e);
    },
    removeAttributeNode: function(e) {
      return this.attributes.removeNamedItem(e.nodeName);
    },
    //get real attribute name,and remove it by removeAttributeNode
    removeAttributeNS: function(e, t) {
      var n = this.getAttributeNodeNS(e, t);
      n && this.removeAttributeNode(n);
    },
    hasAttributeNS: function(e, t) {
      return this.getAttributeNodeNS(e, t) != null;
    },
    getAttributeNS: function(e, t) {
      var n = this.getAttributeNodeNS(e, t);
      return n && n.value || "";
    },
    setAttributeNS: function(e, t, n) {
      var r = this.ownerDocument.createAttributeNS(e, t);
      r.value = r.nodeValue = "" + n, this.setAttributeNode(r);
    },
    getAttributeNodeNS: function(e, t) {
      return this.attributes.getNamedItemNS(e, t);
    },
    getElementsByTagName: function(e) {
      return new M(this, function(t) {
        var n = [];
        return k(t, function(r) {
          r !== t && r.nodeType == E && (e === "*" || r.tagName == e) && n.push(r);
        }), n;
      });
    },
    getElementsByTagNameNS: function(e, t) {
      return new M(this, function(n) {
        var r = [];
        return k(n, function(i) {
          i !== n && i.nodeType === E && (e === "*" || i.namespaceURI === e) && (t === "*" || i.localName == t) && r.push(i);
        }), r;
      });
    }
  }, j.prototype.getElementsByTagName = w.prototype.getElementsByTagName, j.prototype.getElementsByTagNameNS = w.prototype.getElementsByTagNameNS, p(w, a);
  function $() {
  }
  $.prototype.nodeType = b, p($, a);
  function L() {
  }
  L.prototype = {
    data: "",
    substringData: function(e, t) {
      return this.data.substring(e, e + t);
    },
    appendData: function(e) {
      e = this.data + e, this.nodeValue = this.data = e, this.length = e.length;
    },
    insertData: function(e, t) {
      this.replaceData(e, 0, t);
    },
    appendChild: function(e) {
      throw new Error(f[m]);
    },
    deleteData: function(e, t) {
      this.replaceData(e, t, "");
    },
    replaceData: function(e, t, n) {
      var r = this.data.substring(0, e), i = this.data.substring(e + t);
      n = r + n + i, this.nodeValue = this.data = n, this.length = n.length;
    }
  }, p(L, a);
  function K() {
  }
  K.prototype = {
    nodeName: "#text",
    nodeType: G,
    splitText: function(e) {
      var t = this.data, n = t.substring(e);
      t = t.substring(0, e), this.data = this.nodeValue = t, this.length = t.length;
      var r = this.ownerDocument.createTextNode(n);
      return this.parentNode && this.parentNode.insertBefore(r, this.nextSibling), r;
    }
  }, p(K, L);
  function q() {
  }
  q.prototype = {
    nodeName: "#comment",
    nodeType: fe
  }, p(q, L);
  function H() {
  }
  H.prototype = {
    nodeName: "#cdata-section",
    nodeType: ae
  }, p(H, L);
  function W() {
  }
  W.prototype.nodeType = ce, p(W, a);
  function Oe() {
  }
  Oe.prototype.nodeType = je, p(Oe, a);
  function Se() {
  }
  Se.prototype.nodeType = ke, p(Se, a);
  function ee() {
  }
  ee.prototype.nodeType = ue, p(ee, a);
  function F() {
  }
  F.prototype.nodeName = "#document-fragment", F.prototype.nodeType = y, p(F, a);
  function te() {
  }
  te.prototype.nodeType = se, p(te, a);
  function Ie() {
  }
  Ie.prototype.serializeToString = function(e, t, n) {
    return we.call(e, t, n);
  }, a.prototype.toString = we;
  function we(e, t) {
    var n = [], r = this.nodeType == 9 && this.documentElement || this, i = r.prefix, o = r.namespaceURI;
    if (o && i == null) {
      var i = r.lookupPrefix(o);
      if (i == null)
        var u = [
          { namespace: o, prefix: null }
          //{namespace:uri,prefix:''}
        ];
    }
    return U(this, n, e, t, u), n.join("");
  }
  function Re(e, t, n) {
    var r = e.prefix || "", i = e.namespaceURI;
    if (!i || r === "xml" && i === B.XML || i === B.XMLNS)
      return !1;
    for (var o = n.length; o--; ) {
      var u = n[o];
      if (u.prefix === r)
        return u.namespace !== i;
    }
    return !0;
  }
  function ne(e, t, n) {
    e.push(" ", t, '="', n.replace(/[<>&"\t\n\r]/g, de), '"');
  }
  function U(e, t, n, r, i) {
    if (i || (i = []), r)
      if (e = r(e), e) {
        if (typeof e == "string") {
          t.push(e);
          return;
        }
      } else
        return;
    switch (e.nodeType) {
      case E:
        var o = e.attributes, u = o.length, c = e.firstChild, N = e.tagName;
        n = B.isHTML(e.namespaceURI) || n;
        var D = N;
        if (!n && !e.prefix && e.namespaceURI) {
          for (var I, O = 0; O < o.length; O++)
            if (o.item(O).name === "xmlns") {
              I = o.item(O).value;
              break;
            }
          if (!I)
            for (var R = i.length - 1; R >= 0; R--) {
              var A = i[R];
              if (A.prefix === "" && A.namespace === e.namespaceURI) {
                I = A.namespace;
                break;
              }
            }
          if (I !== e.namespaceURI)
            for (var R = i.length - 1; R >= 0; R--) {
              var A = i[R];
              if (A.namespace === e.namespaceURI) {
                A.prefix && (D = A.prefix + ":" + N);
                break;
              }
            }
        }
        t.push("<", D);
        for (var C = 0; C < u; C++) {
          var T = o.item(C);
          T.prefix == "xmlns" ? i.push({ prefix: T.localName, namespace: T.value }) : T.nodeName == "xmlns" && i.push({ prefix: "", namespace: T.value });
        }
        for (var C = 0; C < u; C++) {
          var T = o.item(C);
          if (Re(T, n, i)) {
            var x = T.prefix || "", Y = T.namespaceURI;
            ne(t, x ? "xmlns:" + x : "xmlns", Y), i.push({ prefix: x, namespace: Y });
          }
          U(T, t, n, r, i);
        }
        if (N === D && Re(e, n, i)) {
          var x = e.prefix || "", Y = e.namespaceURI;
          ne(t, x ? "xmlns:" + x : "xmlns", Y), i.push({ prefix: x, namespace: Y });
        }
        if (c || n && !/^(?:meta|link|img|br|hr|input)$/i.test(N)) {
          if (t.push(">"), n && /^script$/i.test(N))
            for (; c; )
              c.data ? t.push(c.data) : U(c, t, n, r, i.slice()), c = c.nextSibling;
          else
            for (; c; )
              U(c, t, n, r, i.slice()), c = c.nextSibling;
          t.push("</", D, ">");
        } else
          t.push("/>");
        return;
      case le:
      case y:
        for (var c = e.firstChild; c; )
          U(c, t, n, r, i.slice()), c = c.nextSibling;
        return;
      case b:
        return ne(t, e.name, e.value);
      case G:
        return t.push(
          e.data.replace(/[<&>]/g, de)
        );
      case ae:
        return t.push("<![CDATA[", e.data, "]]>");
      case fe:
        return t.push("<!--", e.data, "-->");
      case ce:
        var xe = e.publicId, P = e.systemId;
        if (t.push("<!DOCTYPE ", e.name), xe)
          t.push(" PUBLIC ", xe), P && P != "." && t.push(" ", P), t.push(">");
        else if (P && P != ".")
          t.push(" SYSTEM ", P, ">");
        else {
          var be = e.internalSubset;
          be && t.push(" [", be, "]"), t.push(">");
        }
        return;
      case se:
        return t.push("<?", e.target, " ", e.data, "?>");
      case ue:
        return t.push("&", e.nodeName, ";");
      //case ENTITY_NODE:
      //case NOTATION_NODE:
      default:
        t.push("??", e.nodeName);
    }
  }
  function Ae(e, t, n) {
    var r;
    switch (t.nodeType) {
      case E:
        r = t.cloneNode(!1), r.ownerDocument = e;
      //var attrs = node2.attributes;
      //var len = attrs.length;
      //for(var i=0;i<len;i++){
      //node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
      //}
      case y:
        break;
      case b:
        n = !0;
        break;
    }
    if (r || (r = t.cloneNode(!1)), r.ownerDocument = e, r.parentNode = null, n)
      for (var i = t.firstChild; i; )
        r.appendChild(Ae(e, i, n)), i = i.nextSibling;
    return r;
  }
  function re(e, t, n) {
    var r = new t.constructor();
    for (var i in t)
      if (Object.prototype.hasOwnProperty.call(t, i)) {
        var o = t[i];
        typeof o != "object" && o != r[i] && (r[i] = o);
      }
    switch (t.childNodes && (r.childNodes = new g()), r.ownerDocument = e, r.nodeType) {
      case E:
        var u = t.attributes, N = r.attributes = new X(), D = u.length;
        N._ownerElement = r;
        for (var I = 0; I < D; I++)
          r.setAttributeNode(re(e, u.item(I), !0));
        break;
      case b:
        n = !0;
    }
    if (n)
      for (var O = t.firstChild; O; )
        r.appendChild(re(e, O, n)), O = O.nextSibling;
    return r;
  }
  function Ce(e, t, n) {
    e[t] = n;
  }
  try {
    if (Object.defineProperty) {
      let e = function(t) {
        switch (t.nodeType) {
          case E:
          case y:
            var n = [];
            for (t = t.firstChild; t; )
              t.nodeType !== 7 && t.nodeType !== 8 && n.push(e(t)), t = t.nextSibling;
            return n.join("");
          default:
            return t.nodeValue;
        }
      };
      Object.defineProperty(M.prototype, "length", {
        get: function() {
          return Q(this), this.$$length;
        }
      }), Object.defineProperty(a.prototype, "textContent", {
        get: function() {
          return e(this);
        },
        set: function(t) {
          switch (this.nodeType) {
            case E:
            case y:
              for (; this.firstChild; )
                this.removeChild(this.firstChild);
              (t || String(t)) && this.appendChild(this.ownerDocument.createTextNode(t));
              break;
            default:
              this.data = t, this.value = t, this.nodeValue = t;
          }
        }
      }), Ce = function(t, n, r) {
        t["$$" + n] = r;
      };
    }
  } catch {
  }
  return S.DocumentType = W, S.DOMException = s, S.DOMImplementation = ve, S.Element = w, S.Node = a, S.NodeList = g, S.XMLSerializer = Ie, S;
}
export {
  Ze as __require
};
//# sourceMappingURL=dom.js.map
