import { map } from './map.js';
import { $custom } from './schema.js';

/* eslint-env browser */


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

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

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

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

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

/**
 * @param {Map<string,string>} m
 * @return {string}
 */
const mapToStyleString = m => 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>}
 */
$custom(el => el.nodeType === DOCUMENT_NODE);
/* c8 ignore stop */

export { DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, ELEMENT_NODE, TEXT_NODE, doc, mapToStyleString };
//# sourceMappingURL=dom.js.map
