'use strict';

var _commonjsHelpers = require('../../../_virtual/_commonjsHelpers.js');
var XMLDocument = require('../../../_virtual/XMLDocument.js');
var Utility = require('./Utility.js');
var XMLDOMImplementation = require('./XMLDOMImplementation.js');
var XMLDOMConfiguration = require('./XMLDOMConfiguration.js');
var XMLNode = require('./XMLNode.js');
var NodeType = require('./NodeType.js');
var XMLStringifier = require('./XMLStringifier.js');
var XMLStringWriter = require('./XMLStringWriter.js');

var hasRequiredXMLDocument;

function requireXMLDocument () {
	if (hasRequiredXMLDocument) return XMLDocument.__module.exports;
	hasRequiredXMLDocument = 1;
	// Generated by CoffeeScript 1.12.7
	(function() {
	  var NodeType$1, XMLDOMConfiguration$1, XMLDOMImplementation$1, XMLNode$1, XMLStringWriter$1, XMLStringifier$1, isPlainObject,
	    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
	    hasProp = {}.hasOwnProperty;

	  isPlainObject = Utility.__require().isPlainObject;

	  XMLDOMImplementation$1 = XMLDOMImplementation.__require();

	  XMLDOMConfiguration$1 = XMLDOMConfiguration.__require();

	  XMLNode$1 = XMLNode.__require();

	  NodeType$1 = NodeType.__require();

	  XMLStringifier$1 = XMLStringifier.__require();

	  XMLStringWriter$1 = XMLStringWriter.__require();

	  XMLDocument.__module.exports = (function(superClass) {
	    extend(XMLDocument, superClass);

	    function XMLDocument(options) {
	      XMLDocument.__super__.constructor.call(this, null);
	      this.name = "#document";
	      this.type = NodeType$1.Document;
	      this.documentURI = null;
	      this.domConfig = new XMLDOMConfiguration$1();
	      options || (options = {});
	      if (!options.writer) {
	        options.writer = new XMLStringWriter$1();
	      }
	      this.options = options;
	      this.stringify = new XMLStringifier$1(options);
	    }

	    Object.defineProperty(XMLDocument.prototype, 'implementation', {
	      value: new XMLDOMImplementation$1()
	    });

	    Object.defineProperty(XMLDocument.prototype, 'doctype', {
	      get: function() {
	        var child, i, len, ref;
	        ref = this.children;
	        for (i = 0, len = ref.length; i < len; i++) {
	          child = ref[i];
	          if (child.type === NodeType$1.DocType) {
	            return child;
	          }
	        }
	        return null;
	      }
	    });

	    Object.defineProperty(XMLDocument.prototype, 'documentElement', {
	      get: function() {
	        return this.rootObject || null;
	      }
	    });

	    Object.defineProperty(XMLDocument.prototype, 'inputEncoding', {
	      get: function() {
	        return null;
	      }
	    });

	    Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', {
	      get: function() {
	        return false;
	      }
	    });

	    Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', {
	      get: function() {
	        if (this.children.length !== 0 && this.children[0].type === NodeType$1.Declaration) {
	          return this.children[0].encoding;
	        } else {
	          return null;
	        }
	      }
	    });

	    Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', {
	      get: function() {
	        if (this.children.length !== 0 && this.children[0].type === NodeType$1.Declaration) {
	          return this.children[0].standalone === 'yes';
	        } else {
	          return false;
	        }
	      }
	    });

	    Object.defineProperty(XMLDocument.prototype, 'xmlVersion', {
	      get: function() {
	        if (this.children.length !== 0 && this.children[0].type === NodeType$1.Declaration) {
	          return this.children[0].version;
	        } else {
	          return "1.0";
	        }
	      }
	    });

	    Object.defineProperty(XMLDocument.prototype, 'URL', {
	      get: function() {
	        return this.documentURI;
	      }
	    });

	    Object.defineProperty(XMLDocument.prototype, 'origin', {
	      get: function() {
	        return null;
	      }
	    });

	    Object.defineProperty(XMLDocument.prototype, 'compatMode', {
	      get: function() {
	        return null;
	      }
	    });

	    Object.defineProperty(XMLDocument.prototype, 'characterSet', {
	      get: function() {
	        return null;
	      }
	    });

	    Object.defineProperty(XMLDocument.prototype, 'contentType', {
	      get: function() {
	        return null;
	      }
	    });

	    XMLDocument.prototype.end = function(writer) {
	      var writerOptions;
	      writerOptions = {};
	      if (!writer) {
	        writer = this.options.writer;
	      } else if (isPlainObject(writer)) {
	        writerOptions = writer;
	        writer = this.options.writer;
	      }
	      return writer.document(this, writer.filterOptions(writerOptions));
	    };

	    XMLDocument.prototype.toString = function(options) {
	      return this.options.writer.document(this, this.options.writer.filterOptions(options));
	    };

	    XMLDocument.prototype.createElement = function(tagName) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.createDocumentFragment = function() {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.createTextNode = function(data) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.createComment = function(data) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.createCDATASection = function(data) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.createProcessingInstruction = function(target, data) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.createAttribute = function(name) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.createEntityReference = function(name) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.getElementsByTagName = function(tagname) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.importNode = function(importedNode, deep) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.createElementNS = function(namespaceURI, qualifiedName) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.createAttributeNS = function(namespaceURI, qualifiedName) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.getElementById = function(elementId) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.adoptNode = function(source) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.normalizeDocument = function() {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.renameNode = function(node, namespaceURI, qualifiedName) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.getElementsByClassName = function(classNames) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.createEvent = function(eventInterface) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.createRange = function() {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.createNodeIterator = function(root, whatToShow, filter) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    XMLDocument.prototype.createTreeWalker = function(root, whatToShow, filter) {
	      throw new Error("This DOM method is not implemented." + this.debugInfo());
	    };

	    return XMLDocument;

	  })(XMLNode$1);

	}).call(_commonjsHelpers.commonjsGlobal);
	return XMLDocument.__module.exports;
}

exports.__require = requireXMLDocument;
