'use strict';

var map = require('./map.js');
var schema = require('./schema.js');

/* eslint-env browser */


/* c8 ignore start */
/**
 * @type {Document}
 */
const doc = /** @type {Document} */ (typeof document !== 'undefined' ? document : {});

/**
 * @type {$.Schema<DocumentFragment>}
 */
schema.$custom(el => el.nodeType === DOCUMENT_FRAGMENT_NODE);

/** @type {DOMParser} */ (typeof DOMParser !== 'undefined' ? new DOMParser() : null);

/**
 * @type {$.Schema<Element>}
 */
schema.$custom(el => el.nodeType === ELEMENT_NODE);

/**
 * @type {$.Schema<Text>}
 */
schema.$custom(el => el.nodeType === TEXT_NODE);

/**
 * @param {Map<string,string>} m
 * @return {string}
 */
const mapToStyleString = m => map.map(m, (value, key) => `${key}:${value};`).join('');

const ELEMENT_NODE = doc.ELEMENT_NODE;
const TEXT_NODE = doc.TEXT_NODE;
const DOCUMENT_NODE = doc.DOCUMENT_NODE;
const DOCUMENT_FRAGMENT_NODE = doc.DOCUMENT_FRAGMENT_NODE;

/**
 * @type {$.Schema<Node>}
 */
schema.$custom(el => el.nodeType === DOCUMENT_NODE);
/* c8 ignore stop */

exports.DOCUMENT_FRAGMENT_NODE = DOCUMENT_FRAGMENT_NODE;
exports.DOCUMENT_NODE = DOCUMENT_NODE;
exports.ELEMENT_NODE = ELEMENT_NODE;
exports.TEXT_NODE = TEXT_NODE;
exports.doc = doc;
exports.mapToStyleString = mapToStyleString;
//# sourceMappingURL=dom.js.map
