"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.test=exports.serialize=exports.default=void 0;var _markup=require("./lib/markup");const ELEMENT_NODE=1,TEXT_NODE=3,COMMENT_NODE=8,FRAGMENT_NODE=11,ELEMENT_REGEXP=/^((HTML|SVG)\w*)?Element$/,testHasAttribute=e=>{try{return"function"==typeof e.hasAttribute&&e.hasAttribute("is")}catch{return!1}},testNode=e=>{const t=e.constructor.name,{nodeType:r,tagName:n}=e,s="string"==typeof n&&n.includes("-")||testHasAttribute(e);return 1===r&&(ELEMENT_REGEXP.test(t)||s)||3===r&&"Text"===t||8===r&&"Comment"===t||11===r&&"DocumentFragment"===t},test=e=>{var t;return(null==e||null===(t=e.constructor)||void 0===t?void 0:t.name)&&testNode(e)};function nodeIsText(e){return 3===e.nodeType}function nodeIsComment(e){return 8===e.nodeType}function nodeIsFragment(e){return 11===e.nodeType}exports.test=test;const serialize=(e,t,r,n,s,a)=>{if(nodeIsText(e))return(0,_markup.printText)(e.data,t);if(nodeIsComment(e))return(0,_markup.printComment)(e.data,t);const o=nodeIsFragment(e)?"DocumentFragment":e.tagName.toLowerCase();return++n>t.maxDepth?(0,_markup.printElementAsLeaf)(o,t):(0,_markup.printElement)(o,(0,_markup.printProps)(nodeIsFragment(e)?[]:Array.from(e.attributes).map((e=>e.name)).sort(),nodeIsFragment(e)?{}:Array.from(e.attributes).reduce(((e,t)=>(e[t.name]=t.value,e)),{}),t,r+t.indent,n,s,a),(0,_markup.printChildren)(Array.prototype.slice.call(e.childNodes||e.children),t,r+t.indent,n,s,a),t,r)};exports.serialize=serialize;const plugin={serialize:serialize,test:test};var _default=plugin;exports.default=_default;
//# sourceMappingURL=DOMElement.js.map