bulmil
Version:

1,013 lines (997 loc) • 653 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const CONTENT_REF_ID = 'r';
const ORG_LOCATION_ID = 'o';
const SLOT_NODE_ID = 's';
const TEXT_NODE_ID = 't';
const XLINK_NS = 'http://www.w3.org/1999/xlink';
const attrHandler = {
get(obj, prop) {
if (prop in obj) {
return obj[prop];
}
if (!isNaN(prop)) {
return obj.__items[prop];
}
return undefined;
},
};
const createAttributeProxy = (caseInsensitive) => new Proxy(new MockAttributeMap(caseInsensitive), attrHandler);
class MockAttributeMap {
constructor(caseInsensitive = false) {
this.caseInsensitive = caseInsensitive;
this.__items = [];
}
get length() {
return this.__items.length;
}
item(index) {
return this.__items[index] || null;
}
setNamedItem(attr) {
attr.namespaceURI = null;
this.setNamedItemNS(attr);
}
setNamedItemNS(attr) {
if (attr != null && attr.value != null) {
attr.value = String(attr.value);
}
const existingAttr = this.__items.find(a => a.name === attr.name && a.namespaceURI === attr.namespaceURI);
if (existingAttr != null) {
existingAttr.value = attr.value;
}
else {
this.__items.push(attr);
}
}
getNamedItem(attrName) {
if (this.caseInsensitive) {
attrName = attrName.toLowerCase();
}
return this.getNamedItemNS(null, attrName);
}
getNamedItemNS(namespaceURI, attrName) {
namespaceURI = getNamespaceURI(namespaceURI);
return this.__items.find(attr => attr.name === attrName && getNamespaceURI(attr.namespaceURI) === namespaceURI) || null;
}
removeNamedItem(attr) {
this.removeNamedItemNS(attr);
}
removeNamedItemNS(attr) {
for (let i = 0, ii = this.__items.length; i < ii; i++) {
if (this.__items[i].name === attr.name && this.__items[i].namespaceURI === attr.namespaceURI) {
this.__items.splice(i, 1);
break;
}
}
}
}
function getNamespaceURI(namespaceURI) {
return namespaceURI === XLINK_NS ? null : namespaceURI;
}
function cloneAttributes(srcAttrs, sortByName = false) {
const dstAttrs = new MockAttributeMap(srcAttrs.caseInsensitive);
if (srcAttrs != null) {
const attrLen = srcAttrs.length;
if (sortByName && attrLen > 1) {
const sortedAttrs = [];
for (let i = 0; i < attrLen; i++) {
const srcAttr = srcAttrs.item(i);
const dstAttr = new MockAttr(srcAttr.name, srcAttr.value, srcAttr.namespaceURI);
sortedAttrs.push(dstAttr);
}
sortedAttrs.sort(sortAttributes).forEach(attr => {
dstAttrs.setNamedItemNS(attr);
});
}
else {
for (let i = 0; i < attrLen; i++) {
const srcAttr = srcAttrs.item(i);
const dstAttr = new MockAttr(srcAttr.name, srcAttr.value, srcAttr.namespaceURI);
dstAttrs.setNamedItemNS(dstAttr);
}
}
}
return dstAttrs;
}
function sortAttributes(a, b) {
if (a.name < b.name)
return -1;
if (a.name > b.name)
return 1;
return 0;
}
class MockAttr {
constructor(attrName, attrValue, namespaceURI = null) {
this._name = attrName;
this._value = String(attrValue);
this._namespaceURI = namespaceURI;
}
get name() {
return this._name;
}
set name(value) {
this._name = value;
}
get value() {
return this._value;
}
set value(value) {
this._value = String(value);
}
get nodeName() {
return this._name;
}
set nodeName(value) {
this._name = value;
}
get nodeValue() {
return this._value;
}
set nodeValue(value) {
this._value = String(value);
}
get namespaceURI() {
return this._namespaceURI;
}
set namespaceURI(namespaceURI) {
this._namespaceURI = namespaceURI;
}
}
class MockCustomElementRegistry {
constructor(win) {
this.win = win;
}
define(tagName, cstr, options) {
if (tagName.toLowerCase() !== tagName) {
throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': "${tagName}" is not a valid custom element name`);
}
if (this.__registry == null) {
this.__registry = new Map();
}
this.__registry.set(tagName, { cstr, options });
if (this.__whenDefined != null) {
const whenDefinedResolveFns = this.__whenDefined.get(tagName);
if (whenDefinedResolveFns != null) {
whenDefinedResolveFns.forEach(whenDefinedResolveFn => {
whenDefinedResolveFn();
});
whenDefinedResolveFns.length = 0;
this.__whenDefined.delete(tagName);
}
}
const doc = this.win.document;
if (doc != null) {
const hosts = doc.querySelectorAll(tagName);
hosts.forEach(host => {
if (upgradedElements.has(host) === false) {
tempDisableCallbacks.add(doc);
const upgradedCmp = createCustomElement(this, doc, tagName);
for (let i = 0; i < host.childNodes.length; i++) {
const childNode = host.childNodes[i];
childNode.remove();
upgradedCmp.appendChild(childNode);
}
tempDisableCallbacks.delete(doc);
if (proxyElements.has(host)) {
proxyElements.set(host, upgradedCmp);
}
}
fireConnectedCallback(host);
});
}
}
get(tagName) {
if (this.__registry != null) {
const def = this.__registry.get(tagName.toLowerCase());
if (def != null) {
return def.cstr;
}
}
return undefined;
}
upgrade(_rootNode) {
//
}
clear() {
if (this.__registry != null) {
this.__registry.clear();
}
if (this.__whenDefined != null) {
this.__whenDefined.clear();
}
}
whenDefined(tagName) {
tagName = tagName.toLowerCase();
if (this.__registry != null && this.__registry.has(tagName) === true) {
return Promise.resolve();
}
return new Promise(resolve => {
if (this.__whenDefined == null) {
this.__whenDefined = new Map();
}
let whenDefinedResolveFns = this.__whenDefined.get(tagName);
if (whenDefinedResolveFns == null) {
whenDefinedResolveFns = [];
this.__whenDefined.set(tagName, whenDefinedResolveFns);
}
whenDefinedResolveFns.push(resolve);
});
}
}
function createCustomElement(customElements, ownerDocument, tagName) {
const Cstr = customElements.get(tagName);
if (Cstr != null) {
const cmp = new Cstr(ownerDocument);
cmp.nodeName = tagName.toUpperCase();
upgradedElements.add(cmp);
return cmp;
}
const host = new Proxy({}, {
get(obj, prop) {
const elm = proxyElements.get(host);
if (elm != null) {
return elm[prop];
}
return obj[prop];
},
set(obj, prop, val) {
const elm = proxyElements.get(host);
if (elm != null) {
elm[prop] = val;
}
else {
obj[prop] = val;
}
return true;
},
has(obj, prop) {
const elm = proxyElements.get(host);
if (prop in elm) {
return true;
}
if (prop in obj) {
return true;
}
return false;
},
});
const elm = new MockHTMLElement(ownerDocument, tagName);
proxyElements.set(host, elm);
return host;
}
const proxyElements = new WeakMap();
const upgradedElements = new WeakSet();
function connectNode(ownerDocument, node) {
node.ownerDocument = ownerDocument;
if (node.nodeType === 1 /* ELEMENT_NODE */) {
if (ownerDocument != null && node.nodeName.includes('-')) {
const win = ownerDocument.defaultView;
if (win != null && typeof node.connectedCallback === 'function' && node.isConnected) {
fireConnectedCallback(node);
}
const shadowRoot = node.shadowRoot;
if (shadowRoot != null) {
shadowRoot.childNodes.forEach(childNode => {
connectNode(ownerDocument, childNode);
});
}
}
node.childNodes.forEach(childNode => {
connectNode(ownerDocument, childNode);
});
}
else {
node.childNodes.forEach(childNode => {
childNode.ownerDocument = ownerDocument;
});
}
}
function fireConnectedCallback(node) {
if (typeof node.connectedCallback === 'function') {
if (tempDisableCallbacks.has(node.ownerDocument) === false) {
try {
node.connectedCallback();
}
catch (e) {
console.error(e);
}
}
}
}
function disconnectNode(node) {
if (node.nodeType === 1 /* ELEMENT_NODE */) {
if (node.nodeName.includes('-') === true && typeof node.disconnectedCallback === 'function') {
if (tempDisableCallbacks.has(node.ownerDocument) === false) {
try {
node.disconnectedCallback();
}
catch (e) {
console.error(e);
}
}
}
node.childNodes.forEach(disconnectNode);
}
}
function attributeChanged(node, attrName, oldValue, newValue) {
attrName = attrName.toLowerCase();
const observedAttributes = node.constructor.observedAttributes;
if (Array.isArray(observedAttributes) === true && observedAttributes.some(obs => obs.toLowerCase() === attrName) === true) {
try {
node.attributeChangedCallback(attrName, oldValue, newValue);
}
catch (e) {
console.error(e);
}
}
}
function checkAttributeChanged(node) {
return node.nodeName.includes('-') === true && typeof node.attributeChangedCallback === 'function';
}
const tempDisableCallbacks = new Set();
function dataset(elm) {
const ds = {};
const attributes = elm.attributes;
const attrLen = attributes.length;
for (let i = 0; i < attrLen; i++) {
const attr = attributes.item(i);
const nodeName = attr.nodeName;
if (nodeName.startsWith('data-')) {
ds[dashToPascalCase(nodeName)] = attr.nodeValue;
}
}
return new Proxy(ds, {
get(_obj, camelCaseProp) {
return ds[camelCaseProp];
},
set(_obj, camelCaseProp, value) {
const dataAttr = toDataAttribute(camelCaseProp);
elm.setAttribute(dataAttr, value);
return true;
},
});
}
function toDataAttribute(str) {
return ('data-' +
String(str)
.replace(/([A-Z0-9])/g, g => ' ' + g[0])
.trim()
.replace(/ /g, '-')
.toLowerCase());
}
function dashToPascalCase(str) {
str = String(str).substr(5);
return str
.split('-')
.map((segment, index) => {
if (index === 0) {
return segment.charAt(0).toLowerCase() + segment.slice(1);
}
return segment.charAt(0).toUpperCase() + segment.slice(1);
})
.join('');
}
const Sizzle = (function() {
const window = {
document: {
createElement() {
return {};
},
nodeType: 9,
documentElement: {
nodeType: 1,
nodeName: 'HTML'
}
}
};
const module = { exports: {} };
/*! Sizzle v2.3.5 | (c) JS Foundation and other contributors | js.foundation */
!function(e){var t,n,r,i,o,u,l,a,c,s,d,f,p,h,g,m,y,v,w,b="sizzle"+1*new Date,N=e.document,C=0,x=0,E=ae(),A=ae(),S=ae(),D=ae(),T=function(e,t){return e===t&&(d=!0),0},L={}.hasOwnProperty,q=[],I=q.pop,B=q.push,R=q.push,$=q.slice,k=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return -1},H="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",P="(?:\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",z="\\["+M+"*("+P+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+P+"))|)"+M+"*\\]",F=":("+P+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+z+")*)|.*)\\)|)",O=new RegExp(M+"+","g"),j=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),G=new RegExp("^"+M+"*,"+M+"*"),U=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),V=new RegExp(M+"|>"),X=new RegExp(F),J=new RegExp("^"+P+"$"),K={ID:new RegExp("^#("+P+")"),CLASS:new RegExp("^\\.("+P+")"),TAG:new RegExp("^("+P+"|[*])"),ATTR:new RegExp("^"+z),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+H+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Q=/HTML$/i,W=/^(?:input|select|textarea|button)$/i,Y=/^h\d$/i,Z=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){f();},ue=ve(function(e){return !0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{R.apply(q=$.call(N.childNodes),N.childNodes),q[N.childNodes.length].nodeType;}catch(e){R={apply:q.length?function(e,t){B.apply(e,$.call(t));}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1;}};}function le(e,t,r,i){var o,l,c,s,d,h,y,v=t&&t.ownerDocument,N=t?t.nodeType:9;if(r=r||[],"string"!=typeof e||!e||1!==N&&9!==N&&11!==N)return r;if(!i&&(f(t),t=t||p,g)){if(11!==N&&(d=_.exec(e)))if(o=d[1]){if(9===N){if(!(c=t.getElementById(o)))return r;if(c.id===o)return r.push(c),r}else if(v&&(c=v.getElementById(o))&&w(t,c)&&c.id===o)return r.push(c),r}else {if(d[2])return R.apply(r,t.getElementsByTagName(e)),r;if((o=d[3])&&n.getElementsByClassName&&t.getElementsByClassName)return R.apply(r,t.getElementsByClassName(o)),r}if(n.qsa&&!D[e+" "]&&(!m||!m.test(e))&&(1!==N||"object"!==t.nodeName.toLowerCase())){if(y=e,v=t,1===N&&(V.test(e)||U.test(e))){(v=ee.test(e)&&ge(t.parentNode)||t)===t&&n.scope||((s=t.getAttribute("id"))?s=s.replace(re,ie):t.setAttribute("id",s=b)),l=(h=u(e)).length;while(l--)h[l]=(s?"#"+s:":scope")+" "+ye(h[l]);y=h.join(",");}try{return R.apply(r,v.querySelectorAll(y)),r}catch(t){D(e,!0);}finally{s===b&&t.removeAttribute("id");}}}return a(e.replace(j,"$1"),t,r,i)}function ae(){var e=[];function t(n,i){return e.push(n+" ")>r.cacheLength&&delete t[e.shift()],t[n+" "]=i}return t}function ce(e){return e[b]=!0,e}function se(e){var t=p.createElement("fieldset");try{return !!e(t)}catch(e){return !1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null;}}function de(e,t){var n=e.split("|"),i=n.length;while(i--)r.attrHandle[n[i]]=t;}function fe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return -1;return e?1:-1}function pe(e){return function(t){return "form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&ue(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function he(e){return ce(function(t){return t=+t,ce(function(n,r){var i,o=e([],n.length,t),u=o.length;while(u--)n[i=o[u]]&&(n[i]=!(r[i]=n[i]));})})}function ge(e){return e&&void 0!==e.getElementsByTagName&&e}n=le.support={},o=le.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return !Q.test(t||n&&n.nodeName||"HTML")},f=le.setDocument=function(e){var t,i,u=e?e.ownerDocument||e:N;return u!=p&&9===u.nodeType&&u.documentElement?(p=u,h=p.documentElement,g=!o(p),N!=p&&(i=p.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",oe,!1):i.attachEvent&&i.attachEvent("onunload",oe)),n.scope=se(function(e){return h.appendChild(e).appendChild(p.createElement("div")),void 0!==e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),n.attributes=se(function(e){return e.className="i",!e.getAttribute("className")}),n.getElementsByTagName=se(function(e){return e.appendChild(p.createComment("")),!e.getElementsByTagName("*").length}),n.getElementsByClassName=Z.test(p.getElementsByClassName),n.getById=se(function(e){return h.appendChild(e).id=b,!p.getElementsByName||!p.getElementsByName(b).length}),n.getById?(r.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},r.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var n=t.getElementById(e);return n?[n]:[]}}):(r.filter.ID=function(e){var t=e.replace(te,ne);return function(e){var n=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},r.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return [o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return [o]}return []}}),r.find.TAG=n.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):n.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=n.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&g)return t.getElementsByClassName(e)},y=[],m=[],(n.qsa=Z.test(p.querySelectorAll))&&(se(function(e){var t;h.appendChild(e).innerHTML="<a id='"+b+"'></a><select id='"+b+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&m.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||m.push("\\["+M+"*(?:value|"+H+")"),e.querySelectorAll("[id~="+b+"-]").length||m.push("~="),(t=p.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||m.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||m.push(":checked"),e.querySelectorAll("a#"+b+"+*").length||m.push(".#.+[+~]"),e.querySelectorAll("\\\f"),m.push("[\\r\\n\\f]");}),se(function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=p.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&m.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&m.push(":enabled",":disabled"),h.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&m.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),m.push(",.*:");})),(n.matchesSelector=Z.test(v=h.matches||h.webkitMatchesSelector||h.mozMatchesSelector||h.oMatchesSelector||h.msMatchesSelector))&&se(function(e){n.disconnectedMatch=v.call(e,"*"),v.call(e,"[s!='']:x"),y.push("!=",F);}),m=m.length&&new RegExp(m.join("|")),y=y.length&&new RegExp(y.join("|")),t=Z.test(h.compareDocumentPosition),w=t||Z.test(h.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return !0;return !1},T=t?function(e,t){if(e===t)return d=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r||(1&(r=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!n.sortDetached&&t.compareDocumentPosition(e)===r?e==p||e.ownerDocument==N&&w(N,e)?-1:t==p||t.ownerDocument==N&&w(N,t)?1:s?k(s,e)-k(s,t):0:4&r?-1:1)}:function(e,t){if(e===t)return d=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,u=[e],l=[t];if(!i||!o)return e==p?-1:t==p?1:i?-1:o?1:s?k(s,e)-k(s,t):0;if(i===o)return fe(e,t);n=e;while(n=n.parentNode)u.unshift(n);n=t;while(n=n.parentNode)l.unshift(n);while(u[r]===l[r])r++;return r?fe(u[r],l[r]):u[r]==N?-1:l[r]==N?1:0},p):p},le.matches=function(e,t){return le(e,null,null,t)},le.matchesSelector=function(e,t){if(f(e),n.matchesSelector&&g&&!D[t+" "]&&(!y||!y.test(t))&&(!m||!m.test(t)))try{var r=v.call(e,t);if(r||n.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){D(t,!0);}return le(t,p,null,[e]).length>0},le.contains=function(e,t){return (e.ownerDocument||e)!=p&&f(e),w(e,t)},le.attr=function(e,t){(e.ownerDocument||e)!=p&&f(e);var i=r.attrHandle[t.toLowerCase()],o=i&&L.call(r.attrHandle,t.toLowerCase())?i(e,t,!g):void 0;return void 0!==o?o:n.attributes||!g?e.getAttribute(t):(o=e.getAttributeNode(t))&&o.specified?o.value:null},le.escape=function(e){return (e+"").replace(re,ie)},le.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},le.uniqueSort=function(e){var t,r=[],i=0,o=0;if(d=!n.detectDuplicates,s=!n.sortStable&&e.slice(0),e.sort(T),d){while(t=e[o++])t===e[o]&&(i=r.push(o));while(i--)e.splice(r[i],1);}return s=null,e},i=le.getText=function(e){var t,n="",r=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=i(e);}else if(3===o||4===o)return e.nodeValue}else while(t=e[r++])n+=i(t);return n},(r=le.selectors={cacheLength:50,createPseudo:ce,match:K,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||le.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&le.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return K.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=u(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return "*"===e?function(){return !0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=E[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&E(e,function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=le.attr(r,e);return null==i?"!="===t:!t||(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i.replace(O," ")+" ").indexOf(n)>-1:"|="===t&&(i===n||i.slice(0,n.length+1)===n+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),u="last"!==e.slice(-4),l="of-type"===t;return 1===r&&0===i?function(e){return !!e.parentNode}:function(t,n,a){var c,s,d,f,p,h,g=o!==u?"nextSibling":"previousSibling",m=t.parentNode,y=l&&t.nodeName.toLowerCase(),v=!a&&!l,w=!1;if(m){if(o){while(g){f=t;while(f=f[g])if(l?f.nodeName.toLowerCase()===y:1===f.nodeType)return !1;h=g="only"===e&&!h&&"nextSibling";}return !0}if(h=[u?m.firstChild:m.lastChild],u&&v){w=(p=(c=(s=(d=(f=m)[b]||(f[b]={}))[f.uniqueID]||(d[f.uniqueID]={}))[e]||[])[0]===C&&c[1])&&c[2],f=p&&m.childNodes[p];while(f=++p&&f&&f[g]||(w=p=0)||h.pop())if(1===f.nodeType&&++w&&f===t){s[e]=[C,p,w];break}}else if(v&&(w=p=(c=(s=(d=(f=t)[b]||(f[b]={}))[f.uniqueID]||(d[f.uniqueID]={}))[e]||[])[0]===C&&c[1]),!1===w)while(f=++p&&f&&f[g]||(w=p=0)||h.pop())if((l?f.nodeName.toLowerCase()===y:1===f.nodeType)&&++w&&(v&&((s=(d=f[b]||(f[b]={}))[f.uniqueID]||(d[f.uniqueID]={}))[e]=[C,w]),f===t))break;return (w-=i)===r||w%r==0&&w/r>=0}}},PSEUDO:function(e,t){var n,i=r.pseudos[e]||r.setFilters[e.toLowerCase()]||le.error("unsupported pseudo: "+e);return i[b]?i(t):i.length>1?(n=[e,e,"",t],r.setFilters.hasOwnProperty(e.toLowerCase())?ce(function(e,n){var r,o=i(e,t),u=o.length;while(u--)e[r=k(e,o[u])]=!(n[r]=o[u]);}):function(e){return i(e,0,n)}):i}},pseudos:{not:ce(function(e){var t=[],n=[],r=l(e.replace(j,"$1"));return r[b]?ce(function(e,t,n,i){var o,u=r(e,null,i,[]),l=e.length;while(l--)(o=u[l])&&(e[l]=!(t[l]=o));}):function(e,i,o){return t[0]=e,r(t,null,o,n),t[0]=null,!n.pop()}}),has:ce(function(e){return function(t){return le(e,t).length>0}}),contains:ce(function(e){return e=e.replace(te,ne),function(t){return (t.textContent||i(t)).indexOf(e)>-1}}),lang:ce(function(e){return J.test(e||"")||le.error("unsupported lang: "+e),e=e.replace(te,ne).toLowerCase(),function(t){var n;do{if(n=g?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return (n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return !1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===h},focus:function(e){return e===p.activeElement&&(!p.hasFocus||p.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:pe(!1),disabled:pe(!0),checked:function(e){var t=e.nodeName.toLowerCase();return "input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return !1;return !0},parent:function(e){return !r.pseudos.empty(e)},header:function(e){return Y.test(e.nodeName)},input:function(e){return W.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return "input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return "input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:he(function(){return [0]}),last:he(function(e,t){return [t-1]}),eq:he(function(e,t,n){return [n<0?n+t:n]}),even:he(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:he(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:he(function(e,t,n){for(var r=n<0?n+t:n>t?t:n;--r>=0;)e.push(r);return e}),gt:he(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}}).pseudos.nth=r.pseudos.eq;for(t in {radio:!0,checkbox:!0,file:!0,password:!0,image:!0})r.pseudos[t]=function(e){return function(t){return "input"===t.nodeName.toLowerCase()&&t.type===e}}(t);for(t in {submit:!0,reset:!0})r.pseudos[t]=function(e){return function(t){var n=t.nodeName.toLowerCase();return ("input"===n||"button"===n)&&t.type===e}}(t);function me(){}me.prototype=r.filters=r.pseudos,r.setFilters=new me,u=le.tokenize=function(e,t){var n,i,o,u,l,a,c,s=A[e+" "];if(s)return t?0:s.slice(0);l=e,a=[],c=r.preFilter;while(l){n&&!(i=G.exec(l))||(i&&(l=l.slice(i[0].length)||l),a.push(o=[])),n=!1,(i=U.exec(l))&&(n=i.shift(),o.push({value:n,type:i[0].replace(j," ")}),l=l.slice(n.length));for(u in r.filter)!(i=K[u].exec(l))||c[u]&&!(i=c[u](i))||(n=i.shift(),o.push({value:n,type:u,matches:i}),l=l.slice(n.length));if(!n)break}return t?l.length:l?le.error(e):A(e,a).slice(0)};function ye(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function ve(e,t,n){var r=t.dir,i=t.next,o=i||r,u=n&&"parentNode"===o,l=x++;return t.first?function(t,n,i){while(t=t[r])if(1===t.nodeType||u)return e(t,n,i);return !1}:function(t,n,a){var c,s,d,f=[C,l];if(a){while(t=t[r])if((1===t.nodeType||u)&&e(t,n,a))return !0}else while(t=t[r])if(1===t.nodeType||u)if(d=t[b]||(t[b]={}),s=d[t.uniqueID]||(d[t.uniqueID]={}),i&&i===t.nodeName.toLowerCase())t=t[r]||t;else {if((c=s[o])&&c[0]===C&&c[1]===l)return f[2]=c[2];if(s[o]=f,f[2]=e(t,n,a))return !0}return !1}}function we(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return !1;return !0}:e[0]}function be(e,t,n){for(var r=0,i=t.length;r<i;r++)le(e,t[r],n);return n}function Ne(e,t,n,r,i){for(var o,u=[],l=0,a=e.length,c=null!=t;l<a;l++)(o=e[l])&&(n&&!n(o,r,i)||(u.push(o),c&&t.push(l)));return u}function Ce(e,t,n,r,i,o){return r&&!r[b]&&(r=Ce(r)),i&&!i[b]&&(i=Ce(i,o)),ce(function(o,u,l,a){var c,s,d,f=[],p=[],h=u.length,g=o||be(t||"*",l.nodeType?[l]:l,[]),m=!e||!o&&t?g:Ne(g,f,e,l,a),y=n?i||(o?e:h||r)?[]:u:m;if(n&&n(m,y,l,a),r){c=Ne(y,p),r(c,[],l,a),s=c.length;while(s--)(d=c[s])&&(y[p[s]]=!(m[p[s]]=d));}if(o){if(i||e){if(i){c=[],s=y.length;while(s--)(d=y[s])&&c.push(m[s]=d);i(null,y=[],c,a);}s=y.length;while(s--)(d=y[s])&&(c=i?k(o,d):f[s])>-1&&(o[c]=!(u[c]=d));}}else y=Ne(y===u?y.splice(h,y.length):y),i?i(null,u,y,a):R.apply(u,y);})}function xe(e){for(var t,n,i,o=e.length,u=r.relative[e[0].type],l=u||r.relative[" "],a=u?1:0,s=ve(function(e){return e===t},l,!0),d=ve(function(e){return k(t,e)>-1},l,!0),f=[function(e,n,r){var i=!u&&(r||n!==c)||((t=n).nodeType?s(e,n,r):d(e,n,r));return t=null,i}];a<o;a++)if(n=r.relative[e[a].type])f=[ve(we(f),n)];else {if((n=r.filter[e[a].type].apply(null,e[a].matches))[b]){for(i=++a;i<o;i++)if(r.relative[e[i].type])break;return Ce(a>1&&we(f),a>1&&ye(e.slice(0,a-1).concat({value:" "===e[a-2].type?"*":""})).replace(j,"$1"),n,a<i&&xe(e.slice(a,i)),i<o&&xe(e=e.slice(i)),i<o&&ye(e))}f.push(n);}return we(f)}function Ee(e,t){var n=t.length>0,i=e.length>0,o=function(o,u,l,a,s){var d,h,m,y=0,v="0",w=o&&[],b=[],N=c,x=o||i&&r.find.TAG("*",s),E=C+=null==N?1:Math.random()||.1,A=x.length;for(s&&(c=u==p||u||s);v!==A&&null!=(d=x[v]);v++){if(i&&d){h=0,u||d.ownerDocument==p||(f(d),l=!g);while(m=e[h++])if(m(d,u||p,l)){a.push(d);break}s&&(C=E);}n&&((d=!m&&d)&&y--,o&&w.push(d));}if(y+=v,n&&v!==y){h=0;while(m=t[h++])m(w,b,u,l);if(o){if(y>0)while(v--)w[v]||b[v]||(b[v]=I.call(a));b=Ne(b);}R.apply(a,b),s&&!o&&b.length>0&&y+t.length>1&&le.uniqueSort(a);}return s&&(C=E,c=N),w};return n?ce(o):o}l=le.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=u(e)),n=t.length;while(n--)(o=xe(t[n]))[b]?r.push(o):i.push(o);(o=S(e,Ee(i,r))).selector=e;}return o},a=le.select=function(e,t,n,i){var o,a,c,s,d,f="function"==typeof e&&e,p=!i&&u(e=f.selector||e);if(n=n||[],1===p.length){if((a=p[0]=p[0].slice(0)).length>2&&"ID"===(c=a[0]).type&&9===t.nodeType&&g&&r.relative[a[1].type]){if(!(t=(r.find.ID(c.matches[0].replace(te,ne),t)||[])[0]))return n;f&&(t=t.parentNode),e=e.slice(a.shift().value.length);}o=K.needsContext.test(e)?0:a.length;while(o--){if(c=a[o],r.relative[s=c.type])break;if((d=r.find[s])&&(i=d(c.matches[0].replace(te,ne),ee.test(a[0].type)&&ge(t.parentNode)||t))){if(a.splice(o,1),!(e=i.length&&ye(a)))return R.apply(n,i),n;break}}}return (f||l(e,p))(i,t,!g,n,!t||ee.test(e)&&ge(t.parentNode)||t),n},n.sortStable=b.split("").sort(T).join("")===b,n.detectDuplicates=!!d,f(),n.sortDetached=se(function(e){return 1&e.compareDocumentPosition(p.createElement("fieldset"))}),se(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||de("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),n.attributes&&se(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||de("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),se(function(e){return null==e.getAttribute("disabled")})||de(H,function(e,t,n){var r;if(!n)return !0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null});var Ae=e.Sizzle;le.noConflict=function(){return e.Sizzle===le&&(e.Sizzle=Ae),le},"function"==typeof define&&define.amd?define(function(){return le}):"undefined"!=typeof module&&module.exports?module.exports=le:e.Sizzle=le;}(window);
return module.exports;
})();
function matches(selector, elm) {
const r = Sizzle.matches(selector, [elm]);
return r.length > 0;
}
function selectOne(selector, elm) {
const r = Sizzle(selector, elm);
return r[0] || null;
}
function selectAll(selector, elm) {
return Sizzle(selector, elm);
}
class MockClassList {
constructor(elm) {
this.elm = elm;
}
add(...classNames) {
const clsNames = getItems(this.elm);
let updated = false;
classNames.forEach(className => {
className = String(className);
validateClass(className);
if (clsNames.includes(className) === false) {
clsNames.push(className);
updated = true;
}
});
if (updated) {
this.elm.setAttributeNS(null, 'class', clsNames.join(' '));
}
}
remove(...classNames) {
const clsNames = getItems(this.elm);
let updated = false;
classNames.forEach(className => {
className = String(className);
validateClass(className);
const index = clsNames.indexOf(className);
if (index > -1) {
clsNames.splice(index, 1);
updated = true;
}
});
if (updated) {
this.elm.setAttributeNS(null, 'class', clsNames.filter(c => c.length > 0).join(' '));
}
}
contains(className) {
className = String(className);
return getItems(this.elm).includes(className);
}
toggle(className) {
className = String(className);
if (this.contains(className) === true) {
this.remove(className);
}
else {
this.add(className);
}
}
get length() {
return getItems(this.elm).length;
}
item(index) {
return getItems(this.elm)[index];
}
toString() {
return getItems(this.elm).join(' ');
}
}
function validateClass(className) {
if (className === '') {
throw new Error('The token provided must not be empty.');
}
if (/\s/.test(className)) {
throw new Error(`The token provided ('${className}') contains HTML space characters, which are not valid in tokens.`);
}
}
function getItems(elm) {
const className = elm.getAttribute('class');
if (typeof className === 'string' && className.length > 0) {
return className
.trim()
.split(' ')
.filter(c => c.length > 0);
}
return [];
}
class MockCSSStyleDeclaration {
constructor() {
this._styles = new Map();
}
setProperty(prop, value) {
prop = jsCaseToCssCase(prop);
if (value == null || value === '') {
this._styles.delete(prop);
}
else {
this._styles.set(prop, String(value));
}
}
getPropertyValue(prop) {
prop = jsCaseToCssCase(prop);
return String(this._styles.get(prop) || '');
}
removeProperty(prop) {
prop = jsCaseToCssCase(prop);
this._styles.delete(prop);
}
get length() {
return this._styles.size;
}
get cssText() {
const cssText = [];
this._styles.forEach((value, prop) => {
cssText.push(`${prop}: ${value};`);
});
return cssText.join(' ').trim();
}
set cssText(cssText) {
if (cssText == null || cssText === '') {
this._styles.clear();
return;
}
cssText.split(';').forEach(rule => {
rule = rule.trim();
if (rule.length > 0) {
const splt = rule.split(':');
if (splt.length > 1) {
const prop = splt[0].trim();
const value = splt[1].trim();
if (prop !== '' && value !== '') {
this._styles.set(jsCaseToCssCase(prop), value);
}
}
}
});
}
}
function createCSSStyleDeclaration() {
return new Proxy(new MockCSSStyleDeclaration(), cssProxyHandler);
}
const cssProxyHandler = {
get(cssStyle, prop) {
if (prop in cssStyle) {
return cssStyle[prop];
}
prop = cssCaseToJsCase(prop);
return cssStyle.getPropertyValue(prop);
},
set(cssStyle, prop, value) {
if (prop in cssStyle) {
cssStyle[prop] = value;
}
else {
cssStyle.setProperty(prop, value);
}
return true;
},
};
function cssCaseToJsCase(str) {
// font-size to fontSize
if (str.length > 1 && str.includes('-') === true) {
str = str
.toLowerCase()
.split('-')
.map(segment => segment.charAt(0).toUpperCase() + segment.slice(1))
.join('');
str = str.substr(0, 1).toLowerCase() + str.substr(1);
}
return str;
}
function jsCaseToCssCase(str) {
// fontSize to font-size
if (str.length > 1 && str.includes('-') === false && /[A-Z]/.test(str) === true) {
str = str
.replace(/([A-Z])/g, g => ' ' + g[0])
.trim()
.replace(/ /g, '-')
.toLowerCase();
}
return str;
}
class MockEvent {
constructor(type, eventInitDict) {
this.bubbles = false;
this.cancelBubble = false;
this.cancelable = false;
this.composed = false;
this.currentTarget = null;
this.defaultPrevented = false;
this.srcElement = null;
this.target = null;
if (typeof type !== 'string') {
throw new Error(`Event type required`);
}
this.type = type;
this.timeStamp = Date.now();
if (eventInitDict != null) {
Object.assign(this, eventInitDict);
}
}
preventDefault() {
this.defaultPrevented = true;
}
stopPropagation() {
this.cancelBubble = true;
}
stopImmediatePropagation() {
this.cancelBubble = true;
}
}
class MockCustomEvent extends MockEvent {
constructor(type, customEventInitDic) {
super(type);
this.detail = null;
if (customEventInitDic != null) {
Object.assign(this, customEventInitDic);
}
}
}
class MockKeyboardEvent extends MockEvent {
constructor(type, keyboardEventInitDic) {
super(type);
this.code = '';
this.key = '';
this.altKey = false;
this.ctrlKey = false;
this.metaKey = false;
this.shiftKey = false;
this.location = 0;
this.repeat = false;
if (keyboardEventInitDic != null) {
Object.assign(this, keyboardEventInitDic);
}
}
}
class MockMouseEvent extends MockEvent {
constructor(type, mouseEventInitDic) {
super(type);
this.screenX = 0;
this.screenY = 0;
this.clientX = 0;
this.clientY = 0;
this.ctrlKey = false;
this.shiftKey = false;
this.altKey = false;
this.metaKey = false;
this.button = 0;
this.buttons = 0;
this.relatedTarget = null;
if (mouseEventInitDic != null) {
Object.assign(this, mouseEventInitDic);
}
}
}
class MockEventListener {
constructor(type, handler) {
this.type = type;
this.handler = handler;
}
}
function addEventListener(elm, type, handler) {
const target = elm;
if (target.__listeners == null) {
target.__listeners = [];
}
target.__listeners.push(new MockEventListener(type, handler));
}
function removeEventListener(elm, type, handler) {
const target = elm;
if (target != null && Array.isArray(target.__listeners) === true) {
const elmListener = target.__listeners.find(e => e.type === type && e.handler === handler);
if (elmListener != null) {
const index = target.__listeners.indexOf(elmListener);
target.__listeners.splice(index, 1);
}
}
}
function resetEventListeners(target) {
if (target != null && target.__listeners != null) {
target.__listeners = null;
}
}
function triggerEventListener(elm, ev) {
if (elm == null || ev.cancelBubble === true) {
return;
}
const target = elm;
ev.currentTarget = elm;
if (Array.isArray(target.__listeners) === true) {
const listeners = target.__listeners.filter(e => e.type === ev.type);
listeners.forEach(listener => {
try {
listener.handler.call(target, ev);
}
catch (err) {
console.error(err);
}
});
}
if (ev.bubbles === false) {
return;
}
if (elm.nodeName === "#document" /* DOCUMENT_NODE */) {
triggerEventListener(elm.defaultView, ev);
}
else {
triggerEventListener(elm.parentElement, ev);
}
}
function dispatchEvent(currentTarget, ev) {
ev.target = currentTarget;
triggerEventListener(currentTarget, ev);
return true;
}
function serializeNodeToHtml(elm, opts = {}) {
const output = {
currentLineWidth: 0,
indent: 0,
isWithinBody: false,
text: [],
};
if (opts.prettyHtml) {
if (typeof opts.indentSpaces !== 'number') {
opts.indentSpaces = 2;
}
if (typeof opts.newLines !== 'boolean') {
opts.newLines = true;
}
opts.approximateLineWidth = -1;
}
else {
opts.prettyHtml = false;
if (typeof opts.newLines !== 'boolean') {
opts.newLines = false;
}
if (typeof opts.indentSpaces !== 'number') {
opts.indentSpaces = 0;
}
}
if (typeof opts.approximateLineWidth !== 'number') {
opts.approximateLineWidth = -1;
}
if (typeof opts.removeEmptyAttributes !== 'boolean') {
opts.removeEmptyAttributes = true;
}
if (typeof opts.removeAttributeQuotes !== 'boolean') {
opts.removeAttributeQuotes = false;
}
if (typeof opts.removeBooleanAttributeQuotes !== 'boolean') {
opts.removeBooleanAttributeQuotes = false;
}
if (typeof opts.removeHtmlComments !== 'boolean') {
opts.removeHtmlComments = false;
}
if (typeof opts.serializeShadowRoot !== 'boolean') {
opts.serializeShadowRoot = false;
}
if (opts.outerHtml) {
serializeToHtml(elm, opts, output, false);
}
else {
for (let i = 0, ii = elm.childNodes.length; i < ii; i++) {
serializeToHtml(elm.childNodes[i], opts, output, false);
}
}
if (output.text[0] === '\n') {
output.text.shift();
}
if (output.text[output.text.length - 1] === '\n') {
output.text.pop();
}
return output.text.join('');
}
function serializeToHtml(node, opts, output, isShadowRoot) {
if (node.nodeType === 1 /* ELEMENT_NODE */ || isShadowRoot) {
const tagName = isShadowRoot ? 'mock:shadow-root' : getTagName(node);
if (tagName === 'body') {
output.isWithinBody = true;
}
const ignoreTag = opts.excludeTags != null && opts.excludeTags.includes(tagName);
if (ignoreTag === false) {
if (opts.newLines) {
output.text.push('\n');
output.currentLineWidth = 0;
}
if (opts.indentSpaces > 0) {
for (let i = 0; i < output.indent; i++) {
output.text.push(' ');
}
output.currentLineWidth += output.indent;
}
output.text.push('<' + tagName);
output.currentLineWidth += tagName.length + 1;
const attrsLength = node.attributes.length;
const attributes = opts.prettyHtml && attrsLength > 1 ? cloneAttributes(node.attributes, true) : node.attributes;
for (let i = 0; i < attrsLength; i++) {
const attr = attributes.item(i);
const attrName = attr.name;
if (attrName === 'style') {
continue;
}
let attrValue = attr.value;
if (opts.removeEmptyAttributes && attrValue === '' && REMOVE_EMPTY_ATTR.has(attrName)) {
continue;
}
const attrNamespaceURI = attr.namespaceURI;
if (attrNamespaceURI == null) {
output.currentLineWidth += attrName.length + 1;
if (opts.approximateLineWidth > 0 && output.currentLineWidth > opts.approximateLineWidth) {
output.text.push('\n' + attrName);
output.currentLineWidth = 0;
}
else {
output.text.push(' ' + attrName);
}
}
else if (attrNamespaceURI === 'http://www.w3.org/XML/1998/namespace') {
output.text.push(' xml:' + attrName);
output.currentLineWidth += attrName.length + 5;
}
else if (attrNamespaceURI === 'http://www.w3.org/2000/xmlns/') {
if (attrName !== 'xmlns') {
output.text.push(' xmlns:' + attrName);
output.currentLineWidth += attrName.length + 7;
}
else {
output.text.push(' ' + attrName);
output.currentLineWidth += attrName.length + 1;
}
}
else if (attrNamespaceURI === XLINK_NS) {
output.text.push(' xlink:' + attrName);
output.currentLineWidth += attrName.length + 7;
}
else {
output.text.push(' ' + attrNamespaceURI + ':' + attrName);
output.currentLineWidth += attrNamespaceURI.length + attrName.length + 2;
}
if (opts.prettyHtml && attrName === 'class') {
attrValue = attr.value = attrValue
.split(' ')
.filter(t => t !== '')
.sort()
.join(' ')
.trim();
}
if (attrValue === '') {
if (opts.removeBooleanAttributeQuotes && BOOLEAN_ATTR.has(attrName)) {
continue;
}
if (opts.removeEmptyAttributes && attrName.startsWith('data-')) {
continue;
}
}
if (opts.removeAttributeQuotes && CAN_REMOVE_ATTR_QUOTES.test(attrValue)) {
output.text.push('=' + escapeString(attrValue, true));
output.currentLineWidth += attrValue.length + 1;
}
else {
output.text.push('="' + escapeString(attrValue, true) + '"');
output.currentLineWidth += attrValue.length + 3;
}
}
if (node.hasAttribute('style')) {
const cssText = node.style.cssText;
if (opts.approximateLineWidth > 0 && output.currentLineWidth + cssText.length + 10 > opts.approximateLineWidth) {
output.text.push(`\nstyle="${cssText}">`);
output.currentLineWidth = 0;
}
else {
output.text.push(` style="${cssText}">`);
output.currentLineWidth += cssText.length + 10;
}
}
else {
output.text.push('>');
output.currentLineWidth += 1;
}
}
if (EMPTY_ELEMENTS.has(tagName) === false) {
if (opts.serializeShadowRoot && node.shadowRoot != null) {
output.indent = output.indent + opts.indentSpaces;
serializeToHtml(node.shadowRoot, opts, output, true);
output.indent = output.indent - opts.indentSpaces;
if (opts.newLines &&
(node.childNodes.length === 0 || (node.childNodes.length === 1 && node.childNodes[0].nodeType === 3 /* TEXT_NODE */ && node.childNodes[0].nodeValue.trim() === ''))) {
output.text.push('\n');
output.currentLineWidth = 0;
for (let i = 0; i < output.indent; i++) {
output.text.push(' ');
}
output.currentLineWidth += output.indent;
}
}
if (opts.excludeTagContent == null || opts.excludeTagContent.includes(tagName) === false) {
const childNodes = tagName === 'template' ? node.content.childNodes : node.childNodes;
const childNodeLength = childNodes.length;
if (childNodeLength > 0) {
if (childNodeLength === 1 && childNodes[0].nodeType === 3 /* TEXT_NODE */ && (typeof childNodes[0].nodeValue !== 'string' || childNodes[0].nodeValue.trim() === '')) ;
else {
if (opts.indentSpaces > 0 && ignoreTag === false) {
output.indent = output.indent + opts.indentSpaces;
}
for (let i = 0; i < childNodeLength; i++) {
serializeToHtml(childNodes[i], opts, output, false);
}
if (ignoreTag === false) {
if (opts.newLines) {
output.text.push('\n');
output.currentLineWidth = 0;
}
if (opts.indentSpaces > 0) {
output.indent = output.indent - opts.indentSpaces;
for (let i = 0; i < output.indent; i++) {
output.text.push(' ');
}
output.currentLineWidth += output.indent;
}
}
}
}
if (ignoreTag === false) {
output.text.push('</' + tagName + '>');
output.currentLineWidth += tagName.length + 3;
}
}
}
if (opts.approximateLineWidth > 0 && STRUCTURE_ELEMENTS.has(tagName)) {
output.text.push('\n');
output.currentLineWidth = 0;
}
if (tagName === 'body') {
output.isWithinBody = false;
}
}
else if (node.nodeType === 3 /* TEXT_NODE */) {
let textContent = node.nodeValue;
if (typeof textContent === 'string') {
const trimmedTextContent = textContent.trim();
if (trimmedTextContent === '') {
// this text node is whitespace only
if (isWithinWhitespaceSensitive(node)) {
// whitespace matters within this element
// just add the exact text we were given
output.text.push(textContent);
output.currentLineWidth += textContent.length;
}
else if (opts.approximateLineWidth > 0 && !output.isWithinBody) ;
else if (!opts.prettyHtml) {
// this text node is only whitespace, and it's not
// within a whitespace sensitive element like <pre> or <code>
// so replace the entire white space with a single new line
output.currentLineWidth += 1;
if (opts.approximateLineWidth > 0 && output.currentLineWidth > opts.approximateLineWidth) {
// good enough for a new line
// for perf these are all just estimates
// we don't care to ensure exact line lengths
output.text.push('\n');
output.currentLineWidth = 0;
}
else {
// let's keep it all on the same line yet
output.text.push(' ');
}
}
}
else {
// this text node has text content
if (opts.newLines) {
output.text.push('\n');
output.currentLineWidth = 0;
}
if (opts.indentSpaces > 0) {
for (let i = 0; i < output.indent; i++) {
output.text.push(' ');
}
output.currentLineWidth += output.indent;
}
let textContentLength = textContent.length;
if (textContentLength > 0) {
// this text node has text content
const parentTagName = node.parentNode != null && node.parentNode.nodeType === 1 /* ELEMENT_NODE */ ? node.parentNode.nodeName : null;
if (NON_ESCAPABLE_CONTENT.has(parentTagName)) {
// this text node cannot have its content escaped since it's going
// into an element like <style> or <script>
if (isWithinWhitespaceSensitive(node)) {
output.text.push(textContent);
}
else {
output.text.push(trimmedTextContent);
textContentLength = trimmedTextContent.length;
}
output.currentLineWidth += textContentLength;
}
else {
// this text node is going into a normal element and html can be escaped
if (opts.prettyHtml) {
// pretty print the text node
output.text.push(escapeString(textContent.replace(/\s\s+/g, ' ').trim(), false));
output.currentLineWidth += textContentLength;
}
else {
// not pretty printing the text node
if (isWithinWhi