diff --git a/unexpected-dom.js b/unexpected-dom.js index 187c6133..7110c8a1 100644 --- a/unexpected-dom.js +++ b/unexpected-dom.js @@ -38,6 +38,10 @@ function styleStringToObject(str) { } function getClassNamesFromAttributeValue(attributeValue) { + if (attributeValue === null) { + return ''; + } + var classNames = attributeValue.split(/\s+/); if (classNames.length === 1 && classNames[0] === '') { classNames.pop(); @@ -596,7 +600,7 @@ module.exports = { var nameError = promiseByKey.name.reason(); output.sp().annotationBlock(function () { this - .error((nameError && nameError.label) || 'should satisfy') // v8: err.getLabel() + .error((nameError && nameError.getLabel()) || 'should satisfy') .sp() .append(inspect(value.name)); }).nl(); @@ -613,7 +617,7 @@ module.exports = { .sp() .annotationBlock(function () { if (promise) { - this.append(promise.reason().output); // v8: getErrorMessage + this.append(promise.reason().getErrorMessage()); } else { // onlyAttributes === true this.error('should be removed'); @@ -639,7 +643,7 @@ module.exports = { if (expectedValueByAttributeName[attributeName] !== true) { this .sp() - .error((err && err.label) || 'should satisfy') // v8: err.getLabel() + .error((err && err.getLabel()) || 'should satisfy') .sp() .append(inspect(expectedValueByAttributeName[attributeName])); } @@ -662,8 +666,8 @@ module.exports = { } }); if (childrenError) { - output.sp().annotationBlock(function () { // v8: childrenError.getErrorMessage() - this.append(childrenError.output); + output.sp().annotationBlock(function () { + this.append(childrenError.getErrorMessage()); if (childrenDiff && childrenDiff.diff) { this.nl(2).append(childrenDiff.diff); } @@ -1851,4 +1855,4 @@ module.exports = { },{"../3rdparty/prism":5}]},{},[1])(1) }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJsaWIvaW5kZXguanMiLCJsaWIvbWF0Y2hlc1NlbGVjdG9yLmpzIiwibm9kZV9tb2R1bGVzL2FycmF5LWNoYW5nZXMvbGliL2FycmF5Q2hhbmdlcy5qc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ge1xuICAgICAgICAgICAgICBvdXRwdXQudGV4dCgnLi4uJyk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHZhciBpbnNwZWN0ZWRDaGlsZHJlbiA9IFtdO1xuICAgICAgICAgICAgaWYgKGVsZW1lbnROYW1lID09PSAnc2NyaXB0Jykge1xuICAgICAgICAgICAgICB2YXIgdHlwZSA9IGVsZW1lbnQuZ2V0QXR0cmlidXRlKCd0eXBlJyk7XG4gICAgICAgICAgICAgIGlmICghdHlwZSB8fCAvamF2YXNjcmlwdC8udGVzdCh0eXBlKSkge1xuICAgICAgICAgICAgICAgIHR5cGUgPSAnamF2YXNjcmlwdCc7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgaW5zcGVjdGVkQ2hpbGRyZW4ucHVzaChvdXRwdXQuY2xvbmUoKS5jb2RlKGVsZW1lbnQudGV4dENvbnRlbnQsIHR5cGUpKTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoZWxlbWVudE5hbWUgPT09ICdzdHlsZScpIHtcbiAgICAgICAgICAgICAgaW5zcGVjdGVkQ2hpbGRyZW4ucHVzaChvdXRwdXQuY2xvbmUoKS5jb2RlKGVsZW1lbnQudGV4dENvbnRlbnQsIGVsZW1lbnQuZ2V0QXR0cmlidXRlKCd0eXBlJykgfHwgJ3RleHQvY3NzJykpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAgOyBpIDwgZWxlbWVudC5jaGlsZE5vZGVzLmxlbmd0aCA7IGkgKz0gMSkge1xuICAgICAgICAgICAgICAgIGluc3BlY3RlZENoaWxkcmVuLnB1c2goaW5zcGVjdChlbGVtZW50LmNoaWxkTm9kZXNbaV0pKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB2YXIgd2lkdGggPSAwO1xuICAgICAgICAgICAgdmFyIG11bHRpcGxlTGluZXMgPSBpbnNwZWN0ZWRDaGlsZHJlbi5zb21lKGZ1bmN0aW9uIChvKSB7XG4gICAgICAgICAgICAgIHZhciBzaXplID0gby5zaXplKCk7XG4gICAgICAgICAgICAgIHdpZHRoICs9IHNpemUud2lkdGg7XG4gICAgICAgICAgICAgIHJldHVybiB3aWR0aCA+IDUwIHx8IG8uaGVpZ2h0ID4gMTtcbiAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICBpZiAobXVsdGlwbGVMaW5lcykge1xuICAgICAgICAgICAgICBvdXRwdXQubmwoKS5pbmRlbnRMaW5lcygpO1xuXG4gICAgICAgICAgICAgIGluc3BlY3RlZENoaWxkcmVuLmZvckVhY2goZnVuY3Rpb24gKGluc3BlY3RlZENoaWxkLCBpbmRleCkge1xuICAgICAgICAgICAgICAgIG91dHB1dC5pKCkuYmxvY2soaW5zcGVjdGVkQ2hpbGQpLm5sKCk7XG4gICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgIG91dHB1dC5vdXRkZW50TGluZXMoKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIGluc3BlY3RlZENoaWxkcmVuLmZvckVhY2goZnVuY3Rpb24gKGluc3BlY3RlZENoaWxkLCBpbmRleCkge1xuICAgICAgICAgICAgICAgIG91dHB1dC5hcHBlbmQoaW5zcGVjdGVkQ2hpbGQpO1xuICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgb3V0cHV0LmNvZGUoc3RyaW5naWZ5RW5kVGFnKGVsZW1lbnQpLCAnaHRtbCcpO1xuICAgICAgICByZXR1cm4gb3V0cHV0O1xuICAgICAgfSxcbiAgICAgIGRpZmZMaW1pdDogNTEyLFxuICAgICAgZGlmZjogZnVuY3Rpb24gKGFjdHVhbCwgZXhwZWN0ZWQsIG91dHB1dCwgZGlmZiwgaW5zcGVjdCwgZXF1YWwpIHtcbiAgICAgICAgdmFyIGlzSHRtbCA9IGFjdHV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1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICB2YXIgb3V0cHV0ID0gdGhpcztcbiAgICAgICAgICAgICAgICBvdXRwdXRcbiAgICAgICAgICAgICAgICAgIC5wcmlzbVB1bmN0dWF0aW9uKCc8JylcbiAgICAgICAgICAgICAgICAgIC5wcmlzbVRhZyhpc0h0bWwgPyBzdWJqZWN0Lm5vZGVOYW1lLnRvTG93ZXJDYXNlKCkgOiBzdWJqZWN0Lm5vZGVOYW1lKTtcbiAgICAgICAgICAgICAgICB2YXIgY2FuQ29udGludWVMaW5lID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICBpZiAocHJvbWlzZUJ5S2V5Lm5hbWUuaXNSZWplY3RlZCgpKSB7XG4gICAgICAgICAgICAgICAgICB2YXIgbmFtZUVycm9yID0gcHJvbWlzZUJ5S2V5Lm5hbWUucmVhc29uKCk7XG4gICAgICAgICAgICAgICAgICBvdXRwdXQuc3AoKS5hbm5vdGF0aW9uQmxvY2soZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzXG4gICAgICAgICAgICAgICAgICAgICAgLmVycm9yKChuYW1lRXJyb3IgJiYgbmFtZUVycm9yLmxhYmVsKSB8fCAnc2hvdWxkIHNhdGlzZnknKSAvLyB2ODogZXJyLmdldExhYmVsKClcbiAgICAgICAgICAgICAgICAgICAgICAuc3AoKVxuICAgICAgICAgICAgICAgICAgICAgIC5hcHBlbmQoaW5zcGVjdCh2YWx1ZS5uYW1lKSk7XG4gICAgICAgICAgICAgICAgICB9KS5ubCgpO1xuICAgICAgICAgICAgICAgICAgY2FuQ29udGludWVMaW5lID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIE9iamVjdC5rZXlzKGF0dHJzKS5mb3JFYWNoKGZ1bmN0aW9uIChhdHRyaWJ1dGVOYW1lKSB7XG4gICAgICAgICAgICAgICAgICB2YXIgcHJvbWlzZSA9IHByb21pc2VCeUtleS5hdHRyaWJ1dGVzW2F0dHJpYnV0ZU5hbWVdO1xuICAgICAgICAgICAgICAgICAgb3V0cHV0LnNwKGNhbkNvbnRpbnVlTGluZSA/IDEgOiAyICsgc3ViamVjdC5ub2RlTmFtZS5sZW5ndGgpO1xuICAgICAgICAgICAgICAgICAgd3JpdGVBdHRyaWJ1dGVUb01hZ2ljUGVuKG91dHB1dCwgYXR0cmlidXRlTmFtZSwgYXR0cnNbYXR0cmlidXRlTmFtZV0sIGlzSHRtbCk7XG4gICAgICAgICAgICAgICAgICBpZiAoKHByb21pc2UgJiYgcHJvbWlzZS5pc0Z1bGZpbGxlZCgpKSB8fCAoIXByb21pc2UgJiYgKCFvbmx5QXR0cmlidXRlcyB8fCBleHBlY3RlZEF0dHJpYnV0ZU5hbWVzLmluZGV4T2YoYXR0cmlidXRlTmFtZSkgIT09IC0xKSkpIHtcbiAgICAgICAgICAgICAgICAgICAgY2FuQ29udGludWVMaW5lID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIG91dHB1dFxuICAgICAgICAgICAgICAgICAgICAgIC5zcCgpXG4gICAgICAgICAgICAgICAgICAgICAgLmFubm90YXRpb25CbG9jayhmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJvbWlzZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFwcGVuZChwcm9taXNlLnJlYXNvbigpLm91dHB1dCk7IC8vIHY4OiBnZXRFcnJvck1lc3NhZ2VcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIC8vIG9ubHlBdHRyaWJ1dGVzID09PSB0cnVlXG4gICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZXJyb3IoJ3Nob3VsZCBiZSByZW1vdmVkJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAgICAgICAubmwoKTtcbiAgICAgICAgICAgICAgICAgICAgY2FuQ29udGludWVMaW5lID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgZXhwZWN0ZWRBdHRyaWJ1dGVOYW1lcy5mb3JFYWNoKGZ1bmN0aW9uIChhdHRyaWJ1dGVOYW1lKSB7XG4gICAgICAgICAgICAgICAgICBpZiAoIXN1YmplY3QuaGFzQXR0cmlidXRlKGF0dHJpYnV0ZU5hbWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBwcm9taXNlID0gcHJvbWlzZUJ5S2V5LmF0dHJpYnV0ZXNbYXR0cmlidXRlTmFtZV07XG4gICAgICAgICAgICAgICAgICAgIGlmICghcHJvbWlzZSB8fCBwcm9taXNlLmlzUmVqZWN0ZWQoKSkge1xuICAgICAgICAgICAgICAgICAgICAgIHZhciBlcnIgPSBwcm9taXNlICYmIHByb21pc2UucmVhc29uKCk7XG4gICAgICAgICAgICAgICAgICAgICAgb3V0cHV0XG4gICAgICAgICAgICAgICAgICAgICAgICAubmwoKVxuICAgICAgICAgICAgICAgICAgICAgICAgLnNwKDIgKyBzdWJqZWN0Lm5vZGVOYW1lLmxlbmd0aClcbiAgICAgICAgICAgICAgICAgICAgICAgIC5hbm5vdGF0aW9uQmxvY2soZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLmVycm9yKCdtaXNzaW5nJylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3AoKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5wcmlzbUF0dHJOYW1lKGF0dHJpYnV0ZU5hbWUsICdodG1sJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChleHBlY3RlZFZhbHVlQnlBdHRyaWJ1dGVOYW1lW2F0dHJpYnV0ZU5hbWVdICE9PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpc1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3AoKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXJyb3IoKGVyciAmJiBlcnIubGFiZWwpIHx8ICdzaG91bGQgc2F0aXNmeScpIC8vIHY4OiBlcnIuZ2V0TGFiZWwoKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3AoKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKGluc3BlY3QoZXhwZWN0ZWRWYWx1ZUJ5QXR0cmlidXRlTmFtZVthdHRyaWJ1dGVOYW1lXSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgICAgICAgICAgLm5sKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgY2FuQ29udGludWVMaW5lID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgb3V0cHV0LnByaXNtUHVuY3R1YXRpb24oJz4nKTtcbiAgICAgICAgICAgICAgICB2YXIgY2hpbGRyZW5FcnJvciA9IHByb21pc2VCeUtleS5jaGlsZHJlbi5pc1JlamVjdGVkKCkgJiYgcHJvbWlzZUJ5S2V5LmNoaWxkcmVuLnJlYXNvbigpO1xuICAgICAgICAgICAgICAgIHZhciBjaGlsZHJlbkRpZmYgPSBjaGlsZHJlbkVycm9yICYmIGNoaWxkcmVuRXJyb3IuY3JlYXRlRGlmZiAmJiBjaGlsZHJlbkVycm9yLmNyZWF0ZURpZmYob3V0cHV0LmNsb25lKCksIGRpZmYsIGluc3BlY3QsIGVxdWFsKTtcbiAgICAgICAgICAgICAgICBpZiAoY2hpbGRyZW5FcnJvcikge1xuICAgICAgICAgICAgICAgICAgb3V0cHV0XG4gICAgICAgICAgICAgICAgICAgIC5ubCgpXG4gICAgICAgICAgICAgICAgICAgIC5pbmRlbnRMaW5lcygpXG4gICAgICAgICAgICAgICAgICAgIC5pKCkuYmxvY2soZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwIDsgaSA8IHN1YmplY3QuY2hpbGROb2Rlcy5sZW5ndGggOyBpICs9IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYXBwZW5kKGluc3BlY3Qoc3ViamVjdC5jaGlsZE5vZGVzW2ldKSkubmwoKTtcbiAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkcmVuRXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgb3V0cHV0LnNwKCkuYW5ub3RhdGlvbkJsb2NrKGZ1bmN0aW9uICgpIHsgLy8gdjg6IGNoaWxkcmVuRXJyb3IuZ2V0RXJyb3JNZXNzYWdlKClcbiAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFwcGVuZChjaGlsZHJlbkVycm9yLm91dHB1dCk7XG4gICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkcmVuRGlmZiAmJiBjaGlsZHJlbkRpZmYuZGlmZikge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5ubCgyKS5hcHBlbmQoY2hpbGRyZW5EaWZmLmRpZmYpO1xuICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICBvdXRwdXQubmwoKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAgOyBpIDwgc3ViamVjdC5jaGlsZE5vZGVzLmxlbmd0aCA7IGkgKz0gMSkge1xuICAgICAgICAgICAgIC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mIChhY3R1YWwubGVuZ3RoIDwgZXhwZWN0ZWQubGVuZ3RoKSB7XG4gICAgICAgICAgICBmb3IgKDsgaiA8IE1hdGgubWF4KGFjdHVhbC5sZW5ndGgsIGV4cGVjdGVkLmxlbmd0aCk7IGogKz0gMSkge1xuICAgICAgICAgICAgICAgIG11dGF0ZWRBcnJheS5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogJ2luc2VydCcsXG4gICAgICAgICAgICAgICAgICAgIHZhbHVlOiBleHBlY3RlZFtqXVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgZm9yICg7IGogPCBNYXRoLm1heChhY3R1YWwubGVuZ3RoLCBleHBlY3RlZC5sZW5ndGgpOyBqICs9IDEpIHtcbiAgICAgICAgICAgICAgICBtdXRhdGVkQXJyYXkucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6ICdyZW1vdmUnLFxuICAgICAgICAgICAgICAgICAgICB2YWx1ZTogYWN0dWFsW2pdXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKG11dGF0ZWRBcnJheS5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICBtdXRhdGVkQXJyYXlbbXV0YXRlZEFycmF5Lmxlbmd0aCAtIDFdLmxhc3QgPSB0cnVlO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgbXV0YXRlZEFycmF5LmZvckVhY2goZnVuY3Rpb24gKGRpZmZJdGVtKSB7XG4gICAgICAgIGlmIChkaWZmSXRlbS50eXBlID09PSAnc2ltaWxhcicgJiYgZXF1YWwoZGlmZkl0ZW0udmFsdWUsIGRpZmZJdGVtLmV4cGVjdGVkKSkge1xuICAgICAgICAgICAgZGlmZkl0ZW0udHlwZSA9ICdlcXVhbCc7XG4gICAgICAgIH1cbiAgICB9KTtcblxuICAgIHJldHVybiBtdXRhdG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ICByZXR1cm4gdGhpcy50ZXh0KHNvdXJjZVRleHQpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBzb3VyY2VUZXh0ID0gc291cmNlVGV4dC5yZXBsYWNlKC88L2csICcmbHQ7Jyk7IC8vIFByaXNtaXNtXG5cbiAgICAgICAgICAgIHZhciB0aGF0ID0gdGhpcyxcbiAgICAgICAgICAgICAgICBjYXBpdGFsaXplZExhbmd1YWdlID0gdXBwZXJDYW1lbENhc2UobGFuZ3VhZ2UpO1xuXG4gICAgICAgICAgICBmdW5jdGlvbiBwcmludFRva2Vucyh0b2tlbiwgcGFyZW50U3R5bGUpIHtcbiAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheSh0b2tlbikpIHtcbiAgICAgICAgICAgICAgICAgICAgdG9rZW4uZm9yRWFjaChmdW5jdGlvbiAoc3ViVG9rZW4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHByaW50VG9rZW5zKHN1YlRva2VuLCBwYXJlbnRTdHlsZSk7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHRva2VuID09PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgICAgICAgICB2YXIgdXBwZXJDYW1lbENhc2VkUGFyZW50U3R5bGUgPSB1cHBlckNhbWVsQ2FzZShwYXJlbnRTdHlsZSk7XG4gICAgICAgICAgICAgICAgICAgIHRva2VuID0gdG9rZW4ucmVwbGFjZSgvJmx0Oy9nLCAnPCcpO1xuICAgICAgICAgICAgICAgICAgICBpZiAodGhhdFsncHJpc20nICsgY2FwaXRhbGl6ZWRMYW5ndWFnZSArIHVwcGVyQ2FtZWxDYXNlZFBhcmVudFN0eWxlXSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhhdFsncHJpc20nICsgY2FwaXRhbGl6ZWRMYW5ndWFnZSArIHVwcGVyQ2FtZWxDYXNlZFBhcmVudFN0eWxlXSh0b2tlbik7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhhdFsncHJpc20nICsgdXBwZXJDYW1lbENhc2VkUGFyZW50U3R5bGVdKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGF0WydwcmlzbScgKyB1cHBlckNhbWVsQ2FzZWRQYXJlbnRTdHlsZV0odG9rZW4pO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhhdC50ZXh0KHRva2VuKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHByaW50VG9rZW5zKHRva2VuLmNvbnRlbnQsIHRva2VuLnR5cGUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHByaW50VG9rZW5zKHByaXNtLnRva2VuaXplKHNvdXJjZVRleHQsIHByaXNtLmxhbmd1YWdlc1tsYW5ndWFnZV0pLCAndGV4dCcpO1xuICAgICAgICB9LCB0cnVlKTtcbiAgICB9XG59O1xuIl19 +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJsaWIvaW5kZXguanMiLCJsaWIvbWF0Y2hlc1NlbGVjdG9yLmpzIiwibm9kZV9tb2R1bGVzL2FycmF5LWNoYW5nZXMvbGliL2FycmF5Q2hhbmdlcy5qcyIsIm5vZGVfbW9kdWxlcy9hcnJheS1jaGFuZ2VzL25vZGVfbW9kdWxlcy9hcnJheWRpZmYvaW5kZXguanMiLCJub2RlX21vZHVsZXMvbWFnaWNwZW4tcHJpc20vM3JkcGFydHkvcHJpc20uanMiLCJub2RlX21vZHVsZXMvbWFnaWNwZW4tcHJpc20vbGliL21hZ2ljUGVuUHJpc20uanMiXSwibmFtZ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AgICAgICBpZiAodHlwZW9mIGV4cGVjdGVkVmFsdWVCeUF0dHJpYnV0ZU5hbWVbYXR0cmlidXRlTmFtZV0gPT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgIGV4cGVjdChhdHRycywgJ25vdCB0byBoYXZlIGtleScsIGF0dHJpYnV0ZU5hbWUpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgYXR0cmlidXRlTmFtZXNFeHBlY3RlZFRvQmVEZWZpbmVkLnB1c2goYXR0cmlidXRlTmFtZSk7XG4gICAgICAgICAgICAgIGV4cGVjdChhdHRycywgJ3RvIGhhdmUga2V5JywgYXR0cmlidXRlTmFtZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSk7XG4gICAgICAgICAgaWYgKG9ubHlBdHRyaWJ1dGVzKSB7XG4gICAgICAgICAgICBleHBlY3QoT2JqZWN0LmtleXMoYXR0cnMpLnNvcnQoKSwgJ3RvIGVxdWFsJywgYXR0cmlidXRlTmFtZXNFeHBlY3RlZFRvQmVEZWZpbmVkLnNvcnQoKSk7XG4gICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgIH1cblxuICAgICAgcmV0dXJuIGV4cGVjdC5wcm9taXNlLmFsbChwcm9taXNlQnlLZXkpLmNhdWdodChmdW5jdGlvbiAoKSB7XG4gICAgICAgIHJldHVybiBleHBlY3QucHJvbWlzZS5zZXR0bGUocHJvbWlzZUJ5S2V5KS50aGVuKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICBleHBlY3QuZmFpbCh7XG4gICAgICAgICAgICBkaWZmOiBmdW5jdGlvbiAob3V0cHV0LCBkaWZmLCBpbnNwZWN0LCBlcXVhbCkge1xuICAgICAgICAgICAgICBvdXRwdXQuYmxvY2soZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIHZhciBvdXRwdXQgPSB0aGlzO1xuICAgICAgICAgICAgICAgIG91dHB1dFxuICAgICAgICAgICAgICAgICAgLnByaXNtUHVuY3R1YXRpb24oJzwnKVxuICAgICAgICAgICAgICAgICAgLnByaXNtVGFnKGlzSHRtbCA/IHN1YmplY3Qubm9kZU5hbWUudG9Mb3dlckNhc2UoKSA6IHN1YmplY3Qubm9kZU5hbWUpO1xuICAgICAgICAgICAgICAgIHZhciBjYW5Db250aW51ZUxpbmUgPSB0cnVlO1xuICAgICAgICAgICAgICAgIGlmIChwcm9taXNlQnlLZXkubmFtZS5pc1JlamVjdGVkKCkpIHtcbiAgICAgICAgICAgICAgICAgIHZhciBuYW1lRXJyb3IgPSBwcm9taXNlQnlLZXkubmFtZS5yZWFzb24oKTtcbiAgICAgICAgICAgICAgICAgIG91dHB1dC5zcCgpLmFubm90YXRpb25CbG9jayhmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXNcbiAgICAgICAgICAgICAgICAgICAgICAuZXJyb3IoKG5hbWVFcnJvciAmJiBuYW1lRXJyb3IuZ2V0TGFiZWwoKSkgfHwgJ3Nob3VsZCBzYXRpc2Z5JylcbiAgICAgICAgICAgICAgICAgICAgICAuc3AoKVxuICAgICAgICAgICAgICAgICAgICAgIC5hcHBlbmQoaW5zcGVjdCh2YWx1ZS5uYW1lKSk7XG4gICAgICAgICAgICAgICAgICB9KS5ubCgpO1xuICAgICAgICAgICAgICAgICAgY2FuQ29udGludWVMaW5lID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIE9iamVjdC5rZXlzKGF0dHJzKS5mb3JFYWNoKGZ1bmN0aW9uIChhdHRyaWJ1dGVOYW1lKSB7XG4gICAgICAgICAgICAgICAgICB2YXIgcHJvbWlzZSA9IHByb21pc2VCeUtleS5hdHRyaWJ1dGVzW2F0dHJpYnV0ZU5hbWVdO1xuICAgICAgICAgICAgICAgICAgb3V0cHV0LnNwKGNhbkNvbnRpbnVlTGluZSA/IDEgOiAyICsgc3ViamVjdC5ub2RlTmFtZS5sZW5ndGgpO1xuICAgICAgICAgICAgICAgICAgd3JpdGVBdHRyaWJ1dGVUb01hZ2ljUGVuKG91dHB1dCwgYXR0cmlidXRlTmFtZSwgYXR0cnNbYXR0cmlidXRlTmFtZV0sIGlzSHRtbCk7XG4gICAgICAgICAgICAgICAgICBpZiAoKHByb21pc2UgJiYgcHJvbWlzZS5pc0Z1bGZpbGxlZCgpKSB8fCAoIXByb21pc2UgJiYgKCFvbmx5QXR0cmlidXRlcyB8fCBleHBlY3RlZEF0dHJpYnV0ZU5hbWVzLmluZGV4T2YoYXR0cmlidXRlTmFtZSkgIT09IC0xKSkpIHtcbiAgICAgICAgICAgICAgICAgICAgY2FuQ29udGludWVMaW5lID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIG91dHB1dFxuICAgICAgICAgICAgICAgICAgICAgIC5zcCgpXG4gICAgICAgICAgICAgICAgICAgICAgLmFubm90YXRpb25CbG9jayhmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJvbWlzZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFwcGVuZChwcm9taXNlLnJlYXNvbigpLmdldEVycm9yTWVzc2FnZSgpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIC8vIG9ubHlBdHRyaWJ1dGVzID09PSB0cnVlXG4gICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZXJyb3IoJ3Nob3VsZCBiZSByZW1vdmVkJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAgICAgICAubmwoKTtcbiAgICAgICAgICAgICAgICAgICAgY2FuQ29udGludWVMaW5lID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgZXhwZWN0ZWRBdHRyaWJ1dGVOYW1lcy5mb3JFYWNoKGZ1bmN0aW9uIChhdHRyaWJ1dGVOYW1lKSB7XG4gICAgICAgICAgICAgICAgICBpZiAoIXN1YmplY3QuaGFzQXR0cmlidXRlKGF0dHJpYnV0ZU5hbWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBwcm9taXNlID0gcHJvbWlzZUJ5S2V5LmF0dHJpYnV0ZXNbYXR0cmlidXRlTmFtZV07XG4gICAgICAgICAgICAgICAgICAgIGlmICghcHJvbWlzZSB8fCBwcm9taXNlLmlzUmVqZWN0ZWQoKSkge1xuICAgICAgICAgICAgICAgICAgICAgIHZhciBlcnIgPSBwcm9taXNlICYmIHByb21pc2UucmVhc29uKCk7XG4gICAgICAgICAgICAgICAgICAgICAgb3V0cHV0XG4gICAgICAgICAgICAgICAgICAgICAgICAubmwoKVxuICAgICAgICAgICAgICAgICAgICAgICAgLnNwKDIgKyBzdWJqZWN0Lm5vZGVOYW1lLmxlbmd0aClcbiAgICAgICAgICAgICAgICAgICAgICAgIC5hbm5vdGF0aW9uQmxvY2soZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLmVycm9yKCdtaXNzaW5nJylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3AoKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5wcmlzbUF0dHJOYW1lKGF0dHJpYnV0ZU5hbWUsICdodG1sJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChleHBlY3RlZFZhbHVlQnlBdHRyaWJ1dGVOYW1lW2F0dHJpYnV0ZU5hbWVdICE9PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpc1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuc3AoKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZXJyb3IoKGVyciAmJiBlcnIuZ2V0TGFiZWwoKSkgfHwgJ3Nob3VsZCBzYXRpc2Z5JylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnNwKClcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFwcGVuZChpbnNwZWN0KGV4cGVjdGVkVmFsdWVCeUF0dHJpYnV0ZU5hbWVbYXR0cmlidXRlTmFtZV0pKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAgICAgICAgIC5ubCgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGNhbkNvbnRpbnVlTGluZSA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIG91dHB1dC5wcmlzbVB1bmN0dWF0aW9uKCc+Jyk7XG4gICAgICAgICAgICAgICAgdmFyIGNoaWxkcmVuRXJyb3IgPSBwcm9taXNlQnlLZXkuY2hpbGRyZW4uaXNSZWplY3RlZCgpICYmIHByb21pc2VCeUtleS5jaGlsZHJlbi5yZWFzb24oKTtcbiAgICAgICAgICAgICAgICB2YXIgY2hpbGRyZW5EaWZmID0gY2hpbGRyZW5FcnJvciAmJiBjaGlsZHJlbkVycm9yLmNyZWF0ZURpZmYgJiYgY2hpbGRyZW5FcnJvci5jcmVhdGVEaWZmKG91dHB1dC5jbG9uZSgpLCBkaWZmLCBpbnNwZWN0LCBlcXVhbCk7XG4gICAgICAgICAgICAgICAgaWYgKGNoaWxkcmVuRXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgIG91dHB1dFxuICAgICAgICAgICAgICAgICAgICAubmwoKVxuICAgICAgICAgICAgICAgICAgICAuaW5kZW50TGluZXMoKVxuICAgICAgICAgICAgICAgICAgICAuaSgpLmJsb2NrKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMCA7IGkgPCBzdWJqZWN0LmNoaWxkTm9kZXMubGVuZ3RoIDsgaSArPSAxKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFwcGVuZChpbnNwZWN0KHN1YmplY3QuY2hpbGROb2Rlc1tpXSkpLm5sKCk7XG4gICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgIGlmIChjaGlsZHJlbkVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAgIG91dHB1dC5zcCgpLmFubm90YXRpb25CbG9jayhmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgdGhpcy5hcHBlbmQoY2hpbGRyZW5FcnJvci5nZXRFcnJvck1lc3NhZ2UoKSk7XG4gICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkcmVuRGlmZiAmJiBjaGlsZHJlbkRpZmYuZGlmZikge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5ubCgyKS5hcHBlbmQoY2hpbGRyZW5EaWZmLmRpZmYpO1xuICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICBvdXRwdXQubmwoKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAgOyBpIDwgc3ViamVjdC5jaGlsZE5vZGVzLmxlbmd0aCA7IGkgKz0gMSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmFwcGVuZChpbnNwZWN0KHN1YmplY3QuY2hpbGROb2Rlc1tpXSkpO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBvdXRwdXQuY29kZShzdHJpbmdpZnlFbmRUYWcoc3ViamVjdCksICdodG1sJyk7XG4gICAgICAgICAgICAgIH0pO1xuICAgICAgIC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VvZiBhY3R1YWxbaV07XG5cbiAgICAgICAgaWYgKFxuICAgICAgICAgICAgYWN0dWFsVHlwZSAhPT0gZXhwZWN0ZWRUeXBlIHx8XG4gICAgICAgICAgICAgICAgKChhY3R1YWxUeXBlID09PSAnb2JqZWN0JyB8fCBhY3R1YWxUeXBlID09PSAnc3RyaW5nJykgJiYgIXNpbWlsYXIoYWN0dWFsW2ldLCBleHBlY3RlZFtpXSkpIHx8XG4gICAgICAgICAgICAgICAgKGFjdHVhbFR5cGUgIT09ICdvYmplY3QnICYmIGFjdHVhbFR5cGUgIT09ICdzdHJpbmcnICYmICFlcXVhbChhY3R1YWxbaV0sIGV4cGVjdGVkW2ldKSlcbiAgICAgICAgKSB7XG4gICAgICAgICAgICBjICs9IDE7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBpZiAoYyA8PSBjb25mbGljdHMpIHtcbiAgICAgICAgbXV0YXRlZEFycmF5ID0gW107XG4gICAgICAgIHZhciBqO1xuICAgICAgICBmb3IgKGogPSAwOyBqIDwgTWF0aC5taW4oYWN0dWFsLmxlbmd0aCwgZXhwZWN0ZWQubGVuZ3RoKTsgaiArPSAxKSB7XG4gICAgICAgICAgICBtdXRhdGVkQXJyYXkucHVzaCh7XG4gICAgICAgICAgICAgICAgdHlwZTogJ3NpbWlsYXInLFxuICAgICAgICAgICAgICAgIHZhbHVlOiBhY3R1YWxbal0sXG4gICAgICAgICAgICAgICAgZXhwZWN0ZWQ6IGV4cGVjdGVkW2pdXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChhY3R1YWwubGVuZ3RoIDwgZXhwZWN0ZWQubGVuZ3RoKSB7XG4gICAgICAgICAgICBmb3IgKDsgaiA8IE1hdGgubWF4KGFjdHVhbC5sZW5ndGgsIGV4cGVjdGVkLmxlbmd0aCk7IGogKz0gMSkge1xuICAgICAgICAgICAgICAgIG11dGF0ZWRBcnJheS5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogJ2luc2VydCcsXG4gICAgICAgICAgICAgICAgICAgIHZhbHVlOiBleHBlY3RlZFtqXVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgZm9yICg7IGogPCBNYXRoLm1heChhY3R1YWwubGVuZ3RoLCBleHBlY3RlZC5sZW5ndGgpOyBqICs9IDEpIHtcbiAgICAgICAgICAgICAgICBtdXRhdGVkQXJyYXkucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6ICdyZW1vdmUnLFxuICAgICAgICAgICAgICAgICAgICB2YWx1ZTogYWN0dWFsW2pdXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKG11dGF0ZWRBcnJheS5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICBtdXRhdGVkQXJyYXlbbXV0YXRlZEFycmF5Lmxlbmd0aCAtIDFdLmxhc3QgPSB0cnVlO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgbXV0YXRlZEFycmF5LmZvckVhY2goZnVuY3Rpb24gKGRpZmZJdGVtKSB7XG4gICAgICAgIGlmIChkaWZmSXRlbS50eXBlID09PSAnc2ltaWxhcicgJiYgZXF1YWwoZGlmZkl0ZW0udmFsdWUsIGRpZmZJdGVtLmV4cGVjdGVkKSkge1xuICAgICAgICAgICAgZGlmZkl0ZW0udHlwZSA9ICdlcXVhbCc7XG4gICAgICAgIH1cbiAgICB9KTtcblxuICAgIHJldHVybiBtdXRhdGVkQXJyYXk7XG59O1xuIiwibW9kdWxlLmV4cG9ydHMgPSBhcnJheURpZmY7XG5cbi8vIEJhc2VkIG9uIHNvbWUgcm91Z2ggYmVuY2htYXJraW5nLCB0aGlzIGFsZ29yaXRobSBpcyBhYm91dCBPKDJuKSB3b3JzdCBjYXNlLFxuLy8gYW5kIGl0IGNhbiBjb21wdXRlIGRpZmZzIG9uIHJhbmRvbS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saXplZExhbmd1YWdlID0gdXBwZXJDYW1lbENhc2UobGFuZ3VhZ2UpO1xuXG4gICAgICAgICAgICBmdW5jdGlvbiBwcmludFRva2Vucyh0b2tlbiwgcGFyZW50U3R5bGUpIHtcbiAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheSh0b2tlbikpIHtcbiAgICAgICAgICAgICAgICAgICAgdG9rZW4uZm9yRWFjaChmdW5jdGlvbiAoc3ViVG9rZW4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHByaW50VG9rZW5zKHN1YlRva2VuLCBwYXJlbnRTdHlsZSk7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHRva2VuID09PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgICAgICAgICB2YXIgdXBwZXJDYW1lbENhc2VkUGFyZW50U3R5bGUgPSB1cHBlckNhbWVsQ2FzZShwYXJlbnRTdHlsZSk7XG4gICAgICAgICAgICAgICAgICAgIHRva2VuID0gdG9rZW4ucmVwbGFjZSgvJmx0Oy9nLCAnPCcpO1xuICAgICAgICAgICAgICAgICAgICBpZiAodGhhdFsncHJpc20nICsgY2FwaXRhbGl6ZWRMYW5ndWFnZSArIHVwcGVyQ2FtZWxDYXNlZFBhcmVudFN0eWxlXSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhhdFsncHJpc20nICsgY2FwaXRhbGl6ZWRMYW5ndWFnZSArIHVwcGVyQ2FtZWxDYXNlZFBhcmVudFN0eWxlXSh0b2tlbik7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhhdFsncHJpc20nICsgdXBwZXJDYW1lbENhc2VkUGFyZW50U3R5bGVdKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGF0WydwcmlzbScgKyB1cHBlckNhbWVsQ2FzZWRQYXJlbnRTdHlsZV0odG9rZW4pO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhhdC50ZXh0KHRva2VuKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHByaW50VG9rZW5zKHRva2VuLmNvbnRlbnQsIHRva2VuLnR5cGUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHByaW50VG9rZW5zKHByaXNtLnRva2VuaXplKHNvdXJjZVRleHQsIHByaXNtLmxhbmd1YWdlc1tsYW5ndWFnZV0pLCAndGV4dCcpO1xuICAgICAgICB9LCB0cnVlKTtcbiAgICB9XG59O1xuIl19 diff --git a/unexpected-dom.min.js b/unexpected-dom.min.js index de94f32d..ccd5cdb6 100644 --- a/unexpected-dom.min.js +++ b/unexpected-dom.min.js @@ -1,3 +1,3 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.unexpected||(g.unexpected={})).dom=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o"}}function diffNodeLists(actual,expected,output,diff,inspect,equal){var changes=arrayChanges(Array.prototype.slice.call(actual),Array.prototype.slice.call(expected),equal,function(a,b){return a.nodeType===1&&b.nodeType===1&&a.nodeName===b.nodeName});changes.forEach(function(diffItem,index){output.i().block(function(){var type=diffItem.type;if(type==="insert"){this.annotationBlock(function(){this.error("missing ").block(inspect(diffItem.value))})}else if(type==="remove"){this.block(inspect(diffItem.value).sp().error("// should be removed"))}else if(type==="equal"){this.block(inspect(diffItem.value))}else{var valueDiff=diff(diffItem.value,diffItem.expected);if(valueDiff&&valueDiff.inline){this.block(valueDiff.diff)}else if(valueDiff){this.block(inspect(diffItem.value).sp()).annotationBlock(function(){this.shouldEqualError(diffItem.expected,inspect).nl().append(valueDiff.diff)})}else{this.block(inspect(diffItem.value).sp()).annotationBlock(function(){this.shouldEqualError(diffItem.expected,inspect)})}}}).nl(index-1},equal:function(a,b){return a.nodeValue===b.nodeValue},inspect:function(element,depth,output){return output.code(element.nodeName+' "'+element.nodeValue+'"',"prism-string")}});expect.addType({name:"DOMComment",base:"DOMNode",identify:function(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===8},equal:function(a,b){return a.nodeValue===b.nodeValue},inspect:function(element,depth,output){return output.code("","html")},diff:function(actual,expected,output,diff,inspect,equal){var d=diff("","");d.inline=true;return d}});expect.addType({name:"DOMTextNode",base:"DOMNode",identify:function(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===3},equal:function(a,b){return a.nodeValue.trim()===b.nodeValue.trim()},inspect:function(element,depth,output){return output.code(entitify(element.nodeValue.trim()),"html")},diff:function(actual,expected,output,diff,inspect,equal){var d=diff(actual.nodeValue,expected.nodeValue);d.inline=true;return d}});expect.addType({name:"DOMNodeList",base:"array-like",prefix:function(output){return output.text("NodeList[")},suffix:function(output){return output.text("]")},delimiter:function(output){return output.text("delimiter")},identify:function(obj){return obj&&typeof obj.length==="number"&&typeof obj.toString==="function"&&typeof obj.item==="function"&&obj.toString().indexOf("NodeList")!==-1}});expect.addType({name:"HTMLDocType",base:"DOMNode",identify:function(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===10&&"publicId"in obj},inspect:function(doctype,depth,output,inspect){output.code("","html")},equal:function(a,b){return a.toString()===b.toString()},diff:function(actual,expected,output,diff){var d=diff("","");d.inline=true;return d}});expect.addType({name:"DOMDocument",base:"DOMNode",identify:function(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===9&&obj.documentElement&&obj.implementation},inspect:function(document,depth,output,inspect){for(var i=0;i',"xml");for(var i=0;i0){if(depth===1){output.text("...")}else{var inspectedChildren=[];if(elementName==="script"){var type=element.getAttribute("type");if(!type||/javascript/.test(type)){type="javascript"}inspectedChildren.push(output.clone().code(element.textContent,type))}else if(elementName==="style"){inspectedChildren.push(output.clone().code(element.textContent,element.getAttribute("type")||"text/css"))}else{for(var i=0;i50||o.height>1});if(multipleLines){output.nl().indentLines();inspectedChildren.forEach(function(inspectedChild,index){output.i().block(inspectedChild).nl()});output.outdentLines()}else{inspectedChildren.forEach(function(inspectedChild,index){output.append(inspectedChild)})}}}output.code(stringifyEndTag(element),"html");return output},diffLimit:512,diff:function(actual,expected,output,diff,inspect,equal){var isHtml=actual.ownerDocument.contentType==="text/html";var result={diff:output,inline:true};if(Math.max(actual.length,expected.length)>this.diffLimit){result.diff.jsComment("Diff suppressed due to size > "+this.diffLimit);return result}var emptyElements=actual.childNodes.length===0&&expected.childNodes.length===0;var conflictingElement=actual.nodeName.toLowerCase()!==expected.nodeName.toLowerCase()||!equal(getAttributes(actual),getAttributes(expected));if(conflictingElement){var canContinueLine=true;output.prismPunctuation("<").prismTag(actual.nodeName.toLowerCase());if(actual.nodeName.toLowerCase()!==expected.nodeName.toLowerCase()){output.sp().annotationBlock(function(){this.error("should be").sp().prismTag(expected.nodeName.toLowerCase())}).nl();canContinueLine=false}var actualAttributes=getAttributes(actual);var expectedAttributes=getAttributes(expected);Object.keys(actualAttributes).forEach(function(attributeName){output.sp(canContinueLine?1:2+actual.nodeName.length);writeAttributeToMagicPen(output,attributeName,actualAttributes[attributeName],isHtml);if(attributeName in expectedAttributes){if(actualAttributes[attributeName]===expectedAttributes[attributeName]){canContinueLine=true}else{output.sp().annotationBlock(function(){this.error("should equal").sp().append(inspect(entitify(expectedAttributes[attributeName])))}).nl();canContinueLine=false}delete expectedAttributes[attributeName]}else{output.sp().annotationBlock(function(){this.error("should be removed")}).nl();canContinueLine=false}});Object.keys(expectedAttributes).forEach(function(attributeName){output.sp(canContinueLine?1:2+actual.nodeName.length);output.annotationBlock(function(){this.error("missing").sp();writeAttributeToMagicPen(this,attributeName,expectedAttributes[attributeName],isHtml)}).nl();canContinueLine=false});output.prismPunctuation(">")}else{output.code(stringifyStartTag(actual),"html")}if(!emptyElements){output.nl().indentLines();diffNodeLists(actual.childNodes,expected.childNodes,output,diff,inspect,equal);output.nl().outdentLines()}output.code(stringifyEndTag(actual),"html");return result}});expect.addAssertion("DOMElement","to [only] have (class|classes)",function(expect,subject,value){var flags=this.flags;if(flags.only){return expect(subject,"to have attributes",{"class":function(className){var actualClasses=getClassNamesFromAttributeValue(className);if(typeof value==="string"){value=getClassNamesFromAttributeValue(value)}if(flags.only){return topLevelExpect(actualClasses.sort(),"to equal",value.sort())}else{return topLevelExpect.apply(topLevelExpect,[actualClasses,"to contain"].concat(value))}}})}else{return expect(subject,"to have attributes",{"class":value})}});expect.addAssertion("DOMTextNode","to satisfy",function(expect,subject,value){return expect(subject.nodeValue,"to satisfy",value)});expect.addAssertion("DOMElement","to satisfy",function(expect,subject,value){var isHtml=subject.ownerDocument.contentType==="text/html";if(value&&typeof value==="object"){var unsupportedOptions=Object.keys(value).filter(function(key){return key!=="attributes"&&key!=="name"&&key!=="children"&&key!=="onlyAttributes"});if(unsupportedOptions.length>0){throw new Error("Unsupported option"+(unsupportedOptions.length===1?"":"s")+": "+unsupportedOptions.join(", "))}}var promiseByKey={name:expect.promise(function(){if(value&&typeof value.name!=="undefined"){return topLevelExpect(isHtml?subject.nodeName.toLowerCase():subject.nodeName,"to satisfy",value.name)}}),children:expect.promise(function(){if(typeof value.children!=="undefined"){return topLevelExpect(subject.childNodes,"to satisfy",value.children)}}),attributes:{}};var onlyAttributes=value&&value.onlyAttributes;var attrs=getAttributes(subject);var expectedAttributes=value&&value.attributes;var expectedAttributeNames=[];if(typeof expectedAttributes!=="undefined"){if(typeof expectedAttributes==="string"){expectedAttributes=[expectedAttributes]}var expectedValueByAttributeName={};if(Array.isArray(expectedAttributes)){expectedAttributes.forEach(function(attributeName){expectedValueByAttributeName[attributeName]=true})}else if(expectedAttributes&&typeof expectedAttributes==="object"){expectedValueByAttributeName=expectedAttributes}Object.keys(expectedValueByAttributeName).forEach(function(attributeName){expectedAttributeNames.push(attributeName)});expectedAttributeNames.forEach(function(attributeName){var attributeValue=subject.getAttribute(attributeName);var expectedAttributeValue=expectedValueByAttributeName[attributeName];promiseByKey.attributes[attributeName]=expect.promise(function(){if(attributeName==="class"&&(typeof expectedAttributeValue==="string"||Array.isArray(expectedAttributeValue))){var actualClasses=getClassNamesFromAttributeValue(attributeValue);var expectedClasses=expectedAttributeValue;if(typeof expectedClasses==="string"){expectedClasses=getClassNamesFromAttributeValue(expectedAttributeValue)}if(onlyAttributes){return topLevelExpect(actualClasses.sort(),"to equal",expectedClasses.sort())}else{return topLevelExpect.apply(topLevelExpect,[actualClasses,"to contain"].concat(expectedClasses))}}else if(attributeName==="style"){var expectedStyleObj;if(typeof expectedValueByAttributeName.style==="string"){expectedStyleObj=styleStringToObject(expectedValueByAttributeName.style)}else{expectedStyleObj=expectedValueByAttributeName.style}if(onlyAttributes){return topLevelExpect(attrs.style,"to exhaustively satisfy",expectedStyleObj)}else{return topLevelExpect(attrs.style,"to satisfy",expectedStyleObj)}}else if(expectedAttributeValue===true){expect(subject.hasAttribute(attributeName),"to be true")}else{return topLevelExpect(attributeValue,"to satisfy",expectedAttributeValue)}})});promiseByKey.attributePresence=expect.promise(function(){var attributeNamesExpectedToBeDefined=[];expectedAttributeNames.forEach(function(attributeName){if(typeof expectedValueByAttributeName[attributeName]==="undefined"){expect(attrs,"not to have key",attributeName)}else{attributeNamesExpectedToBeDefined.push(attributeName);expect(attrs,"to have key",attributeName)}});if(onlyAttributes){expect(Object.keys(attrs).sort(),"to equal",attributeNamesExpectedToBeDefined.sort())}})}return expect.promise.all(promiseByKey).caught(function(){return expect.promise.settle(promiseByKey).then(function(){expect.fail({diff:function(output,diff,inspect,equal){output.block(function(){var output=this;output.prismPunctuation("<").prismTag(isHtml?subject.nodeName.toLowerCase():subject.nodeName);var canContinueLine=true;if(promiseByKey.name.isRejected()){var nameError=promiseByKey.name.reason();output.sp().annotationBlock(function(){this.error(nameError&&nameError.label||"should satisfy").sp().append(inspect(value.name))}).nl();canContinueLine=false}Object.keys(attrs).forEach(function(attributeName){var promise=promiseByKey.attributes[attributeName];output.sp(canContinueLine?1:2+subject.nodeName.length);writeAttributeToMagicPen(output,attributeName,attrs[attributeName],isHtml);if(promise&&promise.isFulfilled()||!promise&&(!onlyAttributes||expectedAttributeNames.indexOf(attributeName)!==-1)){canContinueLine=true}else{output.sp().annotationBlock(function(){if(promise){this.append(promise.reason().output)}else{this.error("should be removed")}}).nl();canContinueLine=false}});expectedAttributeNames.forEach(function(attributeName){if(!subject.hasAttribute(attributeName)){var promise=promiseByKey.attributes[attributeName];if(!promise||promise.isRejected()){var err=promise&&promise.reason();output.nl().sp(2+subject.nodeName.length).annotationBlock(function(){this.error("missing").sp().prismAttrName(attributeName,"html");if(expectedValueByAttributeName[attributeName]!==true){this.sp().error(err&&err.label||"should satisfy").sp().append(inspect(expectedValueByAttributeName[attributeName]))}}).nl()}canContinueLine=false}});output.prismPunctuation(">");var childrenError=promiseByKey.children.isRejected()&&promiseByKey.children.reason();var childrenDiff=childrenError&&childrenError.createDiff&&childrenError.createDiff(output.clone(),diff,inspect,equal);if(childrenError){output.nl().indentLines().i().block(function(){for(var i=0;i3){value=Array.prototype.slice.call(arguments,2)}}else if(!value||typeof value!=="object"){throw new Error("to have attributes: Argument must be a string, an array, or an object")}return expect(subject,"to satisfy",{attributes:value,onlyAttributes:this.flags.only})});expect.addAssertion("DOMElement","to have [no] (child|children)",function(expect,subject,query,cmp){if(this.flags.no){this.errorMode="nested";return expect(Array.prototype.slice.call(subject.childNodes),"to be an empty array")}else{var children=Array.prototype.slice.call(subject.querySelectorAll(query));throw children}});expect.addAssertion("DOMElement","to have text",function(expect,subject,value){return expect(subject.textContent,"to satisfy",value)});expect.addAssertion(["DOMDocument","DOMElement"],"queried for [first]",function(expect,subject,value){var queryResult;this.errorMode="nested";if(this.flags.first){queryResult=subject.querySelector(value);if(!queryResult){expect.fail(function(output){output.error("The selector").sp().jsString(value).sp().error("yielded no results")})}}else{queryResult=subject.querySelectorAll(value);if(queryResult.length===0){expect.fail(function(output){output.error("The selector").sp().jsString(value).sp().error("yielded no results")})}}return this.shift(expect,queryResult,1)});expect.addAssertion(["DOMDocument","DOMElement"],"to contain no elements matching",function(expect,subject,value){return expect(subject.querySelectorAll(value),"to satisfy",[])});expect.addAssertion(["DOMDocument","DOMElement"],"[not] to match",function(expect,subject,value){return expect(matchesSelector(subject,value),"to be",this.flags.not?false:true)});expect.addAssertion("string","when parsed as (html|HTML) [fragment]",function(expect,subject){this.errorMode="nested";var htmlSource=subject;if(this.flags.fragment){htmlSource=" "+htmlSource+""}var htmlDocument;if(typeof DOMParser!=="undefined"){htmlDocument=(new DOMParser).parseFromString(htmlSource,"text/html")}else if(typeof document!=="undefined"&&document.implementation&&document.implementation.createHTMLDocument){htmlDocument=document.implementation.createHTMLDocument("");htmlDocument.open();htmlDocument.write(htmlSource);htmlDocument.close()}else{try{htmlDocument=require("jsdom").jsdom(htmlSource)}catch(err){throw new Error("The assertion `"+this.testDescription+"` was run outside a browser, but could not find the `jsdom` module. Please npm install jsdom to make this work.")}}if(this.flags.fragment){var body=htmlDocument.body;var documentFragment=htmlDocument.createDocumentFragment();if(body){for(var i=0;i0){mutatedArray[mutatedArray.length-1].last=true}similar=similar||function(a,b){return false};var itemsDiff=arrayDiff([].concat(actual),[].concat(expected),function(a,b){return equal(a,b)||similar(a,b)});var removeTable=[];function offsetIndex(index){return index+(removeTable[index-1]||0)}var removes=itemsDiff.filter(function(diffItem){return diffItem.type==="remove"});var removesByIndex={};var removedItems=0;removes.forEach(function(diffItem){var removeIndex=removedItems+diffItem.index;mutatedArray.slice(removeIndex,diffItem.howMany+removeIndex).forEach(function(v){v.type="remove"});removedItems+=diffItem.howMany;removesByIndex[diffItem.index]=removedItems});function updateRemoveTable(){removedItems=0;Array.prototype.forEach.call(actual,function(_,index){removedItems+=removesByIndex[index]||0;removeTable[index]=removedItems})}updateRemoveTable();var moves=itemsDiff.filter(function(diffItem){return diffItem.type==="move"});var movedItems=0;moves.forEach(function(diffItem){var moveFromIndex=offsetIndex(diffItem.from);var removed=mutatedArray.slice(moveFromIndex,diffItem.howMany+moveFromIndex);var added=removed.map(function(v){return extend({},v,{last:false,type:"insert"})});removed.forEach(function(v){v.type="remove"});Array.prototype.splice.apply(mutatedArray,[offsetIndex(diffItem.to),0].concat(added));movedItems+=diffItem.howMany;removesByIndex[diffItem.from]=movedItems;updateRemoveTable()});var inserts=itemsDiff.filter(function(diffItem){return diffItem.type==="insert"});inserts.forEach(function(diffItem){var added=new Array(diffItem.values.length);for(var i=0;i0){mutatedArray[mutatedArray.length-1].last=true}}mutatedArray.forEach(function(diffItem){if(diffItem.type==="similar"&&equal(diffItem.value,diffItem.expected)){diffItem.type="equal"}});return mutatedArray}},{arraydiff:4}],4:[function(require,module,exports){module.exports=arrayDiff;arrayDiff.InsertDiff=InsertDiff;arrayDiff.RemoveDiff=RemoveDiff;arrayDiff.MoveDiff=MoveDiff;function InsertDiff(index,values){this.index=index;this.values=values}InsertDiff.prototype.type="insert";InsertDiff.prototype.toJSON=function(){return{type:this.type,index:this.index,values:this.values}};function RemoveDiff(index,howMany){this.index=index;this.howMany=howMany}RemoveDiff.prototype.type="remove";RemoveDiff.prototype.toJSON=function(){return{type:this.type,index:this.index,howMany:this.howMany}};function MoveDiff(from,to,howMany){this.from=from;this.to=to;this.howMany=howMany}MoveDiff.prototype.type="move";MoveDiff.prototype.toJSON=function(){return{type:this.type,from:this.from,to:this.to,howMany:this.howMany}};function strictEqual(a,b){return a===b}function arrayDiff(before,after,equalFn){if(!equalFn)equalFn=strictEqual;var beforeLength=before.length;var afterLength=after.length;var moves=[];var beforeMarked={};var afterMarked={};for(var beforeIndex=0;beforeIndex=remove.index)move.from-=remove.howMany}}for(i=insertsLength;i--;){var insert=inserts[i];var howMany=insert.values.length;for(j=movesLength;j--;){var move=moves[j];if(move.to>=insert.index)move.to-=howMany}}for(i=movesLength;i-->1;){var move=moves[i];if(move.to===move.from)continue;for(j=i;j--;){var earlier=moves[j];if(earlier.to>=move.to)earlier.to-=move.howMany;if(earlier.to>=move.from)earlier.to+=move.howMany}}var outputMoves=[];for(i=0;i=move.from)later.from-=move.howMany;if(later.from>=move.to)later.from+=move.howMany}}return removes.concat(outputMoves,inserts)}},{}],5:[function(require,module,exports){var self=typeof window!=="undefined"?window:{};var Prism=function(){var lang=/\blang(?:uage)?-(?!\*)(\w+)\b/i;var _=self.Prism={util:{type:function(o){return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1]},clone:function(o){var type=_.util.type(o);switch(type){case"Object":var clone={};for(var key in o){if(o.hasOwnProperty(key)){clone[key]=_.util.clone(o[key])}}return clone;case"Array":return o.slice()}return o}},languages:{extend:function(id,redef){var lang=_.util.clone(_.languages[id]);for(var key in redef){lang[key]=redef[key]}return lang},insertBefore:function(inside,before,insert,root){root=root||_.languages;var grammar=root[inside];var ret={};for(var token in grammar){if(grammar.hasOwnProperty(token)){if(token==before){for(var newToken in insert){if(insert.hasOwnProperty(newToken)){ret[newToken]=insert[newToken]}}}ret[token]=grammar[token]}}return root[inside]=ret},DFS:function(o,callback){for(var i in o){callback.call(o,i,o[i]);if(_.util.type(o)==="Object"){_.languages.DFS(o[i],callback)}}}},highlightAll:function(async,callback){var elements=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');for(var i=0,element;element=elements[i++];){_.highlightElement(element,async===true,callback)}},highlightElement:function(element,async,callback){var language,grammar,parent=element;while(parent&&!lang.test(parent.className)){parent=parent.parentNode}if(parent){language=(parent.className.match(lang)||[,""])[1];grammar=_.languages[language]}if(!grammar){return}element.className=element.className.replace(lang,"").replace(/\s+/g," ")+" language-"+language;parent=element.parentNode;if(/pre/i.test(parent.nodeName)){parent.className=parent.className.replace(lang,"").replace(/\s+/g," ")+" language-"+language}var code=element.textContent;if(!code){return}code=code.replace(/&/g,"&").replace(/"}}function diffNodeLists(actual,expected,output,diff,inspect,equal){var changes=arrayChanges(Array.prototype.slice.call(actual),Array.prototype.slice.call(expected),equal,function(a,b){return a.nodeType===1&&b.nodeType===1&&a.nodeName===b.nodeName});changes.forEach(function(diffItem,index){output.i().block(function(){var type=diffItem.type;if(type==="insert"){this.annotationBlock(function(){this.error("missing ").block(inspect(diffItem.value))})}else if(type==="remove"){this.block(inspect(diffItem.value).sp().error("// should be removed"))}else if(type==="equal"){this.block(inspect(diffItem.value))}else{var valueDiff=diff(diffItem.value,diffItem.expected);if(valueDiff&&valueDiff.inline){this.block(valueDiff.diff)}else if(valueDiff){this.block(inspect(diffItem.value).sp()).annotationBlock(function(){this.shouldEqualError(diffItem.expected,inspect).nl().append(valueDiff.diff)})}else{this.block(inspect(diffItem.value).sp()).annotationBlock(function(){this.shouldEqualError(diffItem.expected,inspect)})}}}).nl(index-1},equal:function(a,b){return a.nodeValue===b.nodeValue},inspect:function(element,depth,output){return output.code(element.nodeName+' "'+element.nodeValue+'"',"prism-string")}});expect.addType({name:"DOMComment",base:"DOMNode",identify:function(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===8},equal:function(a,b){return a.nodeValue===b.nodeValue},inspect:function(element,depth,output){return output.code("","html")},diff:function(actual,expected,output,diff,inspect,equal){var d=diff("","");d.inline=true;return d}});expect.addType({name:"DOMTextNode",base:"DOMNode",identify:function(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===3},equal:function(a,b){return a.nodeValue.trim()===b.nodeValue.trim()},inspect:function(element,depth,output){return output.code(entitify(element.nodeValue.trim()),"html")},diff:function(actual,expected,output,diff,inspect,equal){var d=diff(actual.nodeValue,expected.nodeValue);d.inline=true;return d}});expect.addType({name:"DOMNodeList",base:"array-like",prefix:function(output){return output.text("NodeList[")},suffix:function(output){return output.text("]")},delimiter:function(output){return output.text("delimiter")},identify:function(obj){return obj&&typeof obj.length==="number"&&typeof obj.toString==="function"&&typeof obj.item==="function"&&obj.toString().indexOf("NodeList")!==-1}});expect.addType({name:"HTMLDocType",base:"DOMNode",identify:function(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===10&&"publicId"in obj},inspect:function(doctype,depth,output,inspect){output.code("","html")},equal:function(a,b){return a.toString()===b.toString()},diff:function(actual,expected,output,diff){var d=diff("","");d.inline=true;return d}});expect.addType({name:"DOMDocument",base:"DOMNode",identify:function(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===9&&obj.documentElement&&obj.implementation},inspect:function(document,depth,output,inspect){for(var i=0;i',"xml");for(var i=0;i0){if(depth===1){output.text("...")}else{var inspectedChildren=[];if(elementName==="script"){var type=element.getAttribute("type");if(!type||/javascript/.test(type)){type="javascript"}inspectedChildren.push(output.clone().code(element.textContent,type))}else if(elementName==="style"){inspectedChildren.push(output.clone().code(element.textContent,element.getAttribute("type")||"text/css"))}else{for(var i=0;i50||o.height>1});if(multipleLines){output.nl().indentLines();inspectedChildren.forEach(function(inspectedChild,index){output.i().block(inspectedChild).nl()});output.outdentLines()}else{inspectedChildren.forEach(function(inspectedChild,index){output.append(inspectedChild)})}}}output.code(stringifyEndTag(element),"html");return output},diffLimit:512,diff:function(actual,expected,output,diff,inspect,equal){var isHtml=actual.ownerDocument.contentType==="text/html";var result={diff:output,inline:true};if(Math.max(actual.length,expected.length)>this.diffLimit){result.diff.jsComment("Diff suppressed due to size > "+this.diffLimit);return result}var emptyElements=actual.childNodes.length===0&&expected.childNodes.length===0;var conflictingElement=actual.nodeName.toLowerCase()!==expected.nodeName.toLowerCase()||!equal(getAttributes(actual),getAttributes(expected));if(conflictingElement){var canContinueLine=true;output.prismPunctuation("<").prismTag(actual.nodeName.toLowerCase());if(actual.nodeName.toLowerCase()!==expected.nodeName.toLowerCase()){output.sp().annotationBlock(function(){this.error("should be").sp().prismTag(expected.nodeName.toLowerCase())}).nl();canContinueLine=false}var actualAttributes=getAttributes(actual);var expectedAttributes=getAttributes(expected);Object.keys(actualAttributes).forEach(function(attributeName){output.sp(canContinueLine?1:2+actual.nodeName.length);writeAttributeToMagicPen(output,attributeName,actualAttributes[attributeName],isHtml);if(attributeName in expectedAttributes){if(actualAttributes[attributeName]===expectedAttributes[attributeName]){canContinueLine=true}else{output.sp().annotationBlock(function(){this.error("should equal").sp().append(inspect(entitify(expectedAttributes[attributeName])))}).nl();canContinueLine=false}delete expectedAttributes[attributeName]}else{output.sp().annotationBlock(function(){this.error("should be removed")}).nl();canContinueLine=false}});Object.keys(expectedAttributes).forEach(function(attributeName){output.sp(canContinueLine?1:2+actual.nodeName.length);output.annotationBlock(function(){this.error("missing").sp();writeAttributeToMagicPen(this,attributeName,expectedAttributes[attributeName],isHtml)}).nl();canContinueLine=false});output.prismPunctuation(">")}else{output.code(stringifyStartTag(actual),"html")}if(!emptyElements){output.nl().indentLines();diffNodeLists(actual.childNodes,expected.childNodes,output,diff,inspect,equal);output.nl().outdentLines()}output.code(stringifyEndTag(actual),"html");return result}});expect.addAssertion("DOMElement","to [only] have (class|classes)",function(expect,subject,value){var flags=this.flags;if(flags.only){return expect(subject,"to have attributes",{"class":function(className){var actualClasses=getClassNamesFromAttributeValue(className);if(typeof value==="string"){value=getClassNamesFromAttributeValue(value)}if(flags.only){return topLevelExpect(actualClasses.sort(),"to equal",value.sort())}else{return topLevelExpect.apply(topLevelExpect,[actualClasses,"to contain"].concat(value))}}})}else{return expect(subject,"to have attributes",{"class":value})}});expect.addAssertion("DOMTextNode","to satisfy",function(expect,subject,value){return expect(subject.nodeValue,"to satisfy",value)});expect.addAssertion("DOMElement","to satisfy",function(expect,subject,value){var isHtml=subject.ownerDocument.contentType==="text/html";if(value&&typeof value==="object"){var unsupportedOptions=Object.keys(value).filter(function(key){return key!=="attributes"&&key!=="name"&&key!=="children"&&key!=="onlyAttributes"});if(unsupportedOptions.length>0){throw new Error("Unsupported option"+(unsupportedOptions.length===1?"":"s")+": "+unsupportedOptions.join(", "))}}var promiseByKey={name:expect.promise(function(){if(value&&typeof value.name!=="undefined"){return topLevelExpect(isHtml?subject.nodeName.toLowerCase():subject.nodeName,"to satisfy",value.name)}}),children:expect.promise(function(){if(typeof value.children!=="undefined"){return topLevelExpect(subject.childNodes,"to satisfy",value.children)}}),attributes:{}};var onlyAttributes=value&&value.onlyAttributes;var attrs=getAttributes(subject);var expectedAttributes=value&&value.attributes;var expectedAttributeNames=[];if(typeof expectedAttributes!=="undefined"){if(typeof expectedAttributes==="string"){expectedAttributes=[expectedAttributes]}var expectedValueByAttributeName={};if(Array.isArray(expectedAttributes)){expectedAttributes.forEach(function(attributeName){expectedValueByAttributeName[attributeName]=true})}else if(expectedAttributes&&typeof expectedAttributes==="object"){expectedValueByAttributeName=expectedAttributes}Object.keys(expectedValueByAttributeName).forEach(function(attributeName){expectedAttributeNames.push(attributeName)});expectedAttributeNames.forEach(function(attributeName){var attributeValue=subject.getAttribute(attributeName);var expectedAttributeValue=expectedValueByAttributeName[attributeName];promiseByKey.attributes[attributeName]=expect.promise(function(){if(attributeName==="class"&&(typeof expectedAttributeValue==="string"||Array.isArray(expectedAttributeValue))){var actualClasses=getClassNamesFromAttributeValue(attributeValue);var expectedClasses=expectedAttributeValue;if(typeof expectedClasses==="string"){expectedClasses=getClassNamesFromAttributeValue(expectedAttributeValue)}if(onlyAttributes){return topLevelExpect(actualClasses.sort(),"to equal",expectedClasses.sort())}else{return topLevelExpect.apply(topLevelExpect,[actualClasses,"to contain"].concat(expectedClasses))}}else if(attributeName==="style"){var expectedStyleObj;if(typeof expectedValueByAttributeName.style==="string"){expectedStyleObj=styleStringToObject(expectedValueByAttributeName.style)}else{expectedStyleObj=expectedValueByAttributeName.style}if(onlyAttributes){return topLevelExpect(attrs.style,"to exhaustively satisfy",expectedStyleObj)}else{return topLevelExpect(attrs.style,"to satisfy",expectedStyleObj)}}else if(expectedAttributeValue===true){expect(subject.hasAttribute(attributeName),"to be true")}else{return topLevelExpect(attributeValue,"to satisfy",expectedAttributeValue)}})});promiseByKey.attributePresence=expect.promise(function(){var attributeNamesExpectedToBeDefined=[];expectedAttributeNames.forEach(function(attributeName){if(typeof expectedValueByAttributeName[attributeName]==="undefined"){expect(attrs,"not to have key",attributeName)}else{attributeNamesExpectedToBeDefined.push(attributeName);expect(attrs,"to have key",attributeName)}});if(onlyAttributes){expect(Object.keys(attrs).sort(),"to equal",attributeNamesExpectedToBeDefined.sort())}})}return expect.promise.all(promiseByKey).caught(function(){return expect.promise.settle(promiseByKey).then(function(){expect.fail({diff:function(output,diff,inspect,equal){output.block(function(){var output=this;output.prismPunctuation("<").prismTag(isHtml?subject.nodeName.toLowerCase():subject.nodeName);var canContinueLine=true;if(promiseByKey.name.isRejected()){var nameError=promiseByKey.name.reason();output.sp().annotationBlock(function(){this.error(nameError&&nameError.getLabel()||"should satisfy").sp().append(inspect(value.name))}).nl();canContinueLine=false}Object.keys(attrs).forEach(function(attributeName){var promise=promiseByKey.attributes[attributeName];output.sp(canContinueLine?1:2+subject.nodeName.length);writeAttributeToMagicPen(output,attributeName,attrs[attributeName],isHtml);if(promise&&promise.isFulfilled()||!promise&&(!onlyAttributes||expectedAttributeNames.indexOf(attributeName)!==-1)){canContinueLine=true}else{output.sp().annotationBlock(function(){if(promise){this.append(promise.reason().getErrorMessage())}else{this.error("should be removed")}}).nl();canContinueLine=false}});expectedAttributeNames.forEach(function(attributeName){if(!subject.hasAttribute(attributeName)){var promise=promiseByKey.attributes[attributeName];if(!promise||promise.isRejected()){var err=promise&&promise.reason();output.nl().sp(2+subject.nodeName.length).annotationBlock(function(){this.error("missing").sp().prismAttrName(attributeName,"html");if(expectedValueByAttributeName[attributeName]!==true){this.sp().error(err&&err.getLabel()||"should satisfy").sp().append(inspect(expectedValueByAttributeName[attributeName]))}}).nl()}canContinueLine=false}});output.prismPunctuation(">");var childrenError=promiseByKey.children.isRejected()&&promiseByKey.children.reason();var childrenDiff=childrenError&&childrenError.createDiff&&childrenError.createDiff(output.clone(),diff,inspect,equal);if(childrenError){output.nl().indentLines().i().block(function(){for(var i=0;i3){value=Array.prototype.slice.call(arguments,2)}}else if(!value||typeof value!=="object"){throw new Error("to have attributes: Argument must be a string, an array, or an object")}return expect(subject,"to satisfy",{attributes:value,onlyAttributes:this.flags.only})});expect.addAssertion("DOMElement","to have [no] (child|children)",function(expect,subject,query,cmp){if(this.flags.no){this.errorMode="nested";return expect(Array.prototype.slice.call(subject.childNodes),"to be an empty array")}else{var children=Array.prototype.slice.call(subject.querySelectorAll(query));throw children}});expect.addAssertion("DOMElement","to have text",function(expect,subject,value){return expect(subject.textContent,"to satisfy",value)});expect.addAssertion(["DOMDocument","DOMElement"],"queried for [first]",function(expect,subject,value){var queryResult;this.errorMode="nested";if(this.flags.first){queryResult=subject.querySelector(value);if(!queryResult){expect.fail(function(output){output.error("The selector").sp().jsString(value).sp().error("yielded no results")})}}else{queryResult=subject.querySelectorAll(value);if(queryResult.length===0){expect.fail(function(output){output.error("The selector").sp().jsString(value).sp().error("yielded no results")})}}return this.shift(expect,queryResult,1)});expect.addAssertion(["DOMDocument","DOMElement"],"to contain no elements matching",function(expect,subject,value){return expect(subject.querySelectorAll(value),"to satisfy",[])});expect.addAssertion(["DOMDocument","DOMElement"],"[not] to match",function(expect,subject,value){return expect(matchesSelector(subject,value),"to be",this.flags.not?false:true)});expect.addAssertion("string","when parsed as (html|HTML) [fragment]",function(expect,subject){this.errorMode="nested";var htmlSource=subject;if(this.flags.fragment){htmlSource=" "+htmlSource+""}var htmlDocument;if(typeof DOMParser!=="undefined"){htmlDocument=(new DOMParser).parseFromString(htmlSource,"text/html")}else if(typeof document!=="undefined"&&document.implementation&&document.implementation.createHTMLDocument){htmlDocument=document.implementation.createHTMLDocument("");htmlDocument.open();htmlDocument.write(htmlSource);htmlDocument.close()}else{try{htmlDocument=require("jsdom").jsdom(htmlSource)}catch(err){throw new Error("The assertion `"+this.testDescription+"` was run outside a browser, but could not find the `jsdom` module. Please npm install jsdom to make this work.")}}if(this.flags.fragment){var body=htmlDocument.body;var documentFragment=htmlDocument.createDocumentFragment();if(body){for(var i=0;i0){mutatedArray[mutatedArray.length-1].last=true}similar=similar||function(a,b){return false};var itemsDiff=arrayDiff([].concat(actual),[].concat(expected),function(a,b){return equal(a,b)||similar(a,b)});var removeTable=[];function offsetIndex(index){return index+(removeTable[index-1]||0)}var removes=itemsDiff.filter(function(diffItem){return diffItem.type==="remove"});var removesByIndex={};var removedItems=0;removes.forEach(function(diffItem){var removeIndex=removedItems+diffItem.index;mutatedArray.slice(removeIndex,diffItem.howMany+removeIndex).forEach(function(v){v.type="remove"});removedItems+=diffItem.howMany;removesByIndex[diffItem.index]=removedItems});function updateRemoveTable(){removedItems=0;Array.prototype.forEach.call(actual,function(_,index){removedItems+=removesByIndex[index]||0;removeTable[index]=removedItems})}updateRemoveTable();var moves=itemsDiff.filter(function(diffItem){return diffItem.type==="move"});var movedItems=0;moves.forEach(function(diffItem){var moveFromIndex=offsetIndex(diffItem.from);var removed=mutatedArray.slice(moveFromIndex,diffItem.howMany+moveFromIndex);var added=removed.map(function(v){return extend({},v,{last:false,type:"insert"})});removed.forEach(function(v){v.type="remove"});Array.prototype.splice.apply(mutatedArray,[offsetIndex(diffItem.to),0].concat(added));movedItems+=diffItem.howMany;removesByIndex[diffItem.from]=movedItems;updateRemoveTable()});var inserts=itemsDiff.filter(function(diffItem){return diffItem.type==="insert"});inserts.forEach(function(diffItem){var added=new Array(diffItem.values.length);for(var i=0;i0){mutatedArray[mutatedArray.length-1].last=true}}mutatedArray.forEach(function(diffItem){if(diffItem.type==="similar"&&equal(diffItem.value,diffItem.expected)){diffItem.type="equal"}});return mutatedArray}},{arraydiff:4}],4:[function(require,module,exports){module.exports=arrayDiff;arrayDiff.InsertDiff=InsertDiff;arrayDiff.RemoveDiff=RemoveDiff;arrayDiff.MoveDiff=MoveDiff;function InsertDiff(index,values){this.index=index;this.values=values}InsertDiff.prototype.type="insert";InsertDiff.prototype.toJSON=function(){return{type:this.type,index:this.index,values:this.values}};function RemoveDiff(index,howMany){this.index=index;this.howMany=howMany}RemoveDiff.prototype.type="remove";RemoveDiff.prototype.toJSON=function(){return{type:this.type,index:this.index,howMany:this.howMany}};function MoveDiff(from,to,howMany){this.from=from;this.to=to;this.howMany=howMany}MoveDiff.prototype.type="move";MoveDiff.prototype.toJSON=function(){return{type:this.type,from:this.from,to:this.to,howMany:this.howMany}};function strictEqual(a,b){return a===b}function arrayDiff(before,after,equalFn){if(!equalFn)equalFn=strictEqual;var beforeLength=before.length;var afterLength=after.length;var moves=[];var beforeMarked={};var afterMarked={};for(var beforeIndex=0;beforeIndex=remove.index)move.from-=remove.howMany}}for(i=insertsLength;i--;){var insert=inserts[i];var howMany=insert.values.length;for(j=movesLength;j--;){var move=moves[j];if(move.to>=insert.index)move.to-=howMany}}for(i=movesLength;i-->1;){var move=moves[i];if(move.to===move.from)continue;for(j=i;j--;){var earlier=moves[j];if(earlier.to>=move.to)earlier.to-=move.howMany;if(earlier.to>=move.from)earlier.to+=move.howMany}}var outputMoves=[];for(i=0;i=move.from)later.from-=move.howMany;if(later.from>=move.to)later.from+=move.howMany}}return removes.concat(outputMoves,inserts)}},{}],5:[function(require,module,exports){var self=typeof window!=="undefined"?window:{};var Prism=function(){var lang=/\blang(?:uage)?-(?!\*)(\w+)\b/i;var _=self.Prism={util:{type:function(o){return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1]},clone:function(o){var type=_.util.type(o);switch(type){case"Object":var clone={};for(var key in o){if(o.hasOwnProperty(key)){clone[key]=_.util.clone(o[key])}}return clone;case"Array":return o.slice()}return o}},languages:{extend:function(id,redef){var lang=_.util.clone(_.languages[id]);for(var key in redef){lang[key]=redef[key]}return lang},insertBefore:function(inside,before,insert,root){root=root||_.languages;var grammar=root[inside];var ret={};for(var token in grammar){if(grammar.hasOwnProperty(token)){if(token==before){for(var newToken in insert){if(insert.hasOwnProperty(newToken)){ret[newToken]=insert[newToken]}}}ret[token]=grammar[token]}}return root[inside]=ret},DFS:function(o,callback){for(var i in o){callback.call(o,i,o[i]);if(_.util.type(o)==="Object"){_.languages.DFS(o[i],callback)}}}},highlightAll:function(async,callback){var elements=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');for(var i=0,element;element=elements[i++];){_.highlightElement(element,async===true,callback)}},highlightElement:function(element,async,callback){var language,grammar,parent=element;while(parent&&!lang.test(parent.className)){parent=parent.parentNode}if(parent){language=(parent.className.match(lang)||[,""])[1];grammar=_.languages[language]}if(!grammar){return}element.className=element.className.replace(lang,"").replace(/\s+/g," ")+" language-"+language;parent=element.parentNode;if(/pre/i.test(parent.nodeName)){parent.className=parent.className.replace(lang,"").replace(/\s+/g," ")+" language-"+language}var code=element.textContent;if(!code){return}code=code.replace(/&/g,"&").replace(/text.length){break tokenloop}if(str instanceof Token){continue}pattern.lastIndex=0;var match=pattern.exec(str);if(match){if(lookbehind){lookbehindLength=match[1].length}var from=match.index-1+lookbehindLength,match=match[0].slice(lookbehindLength),len=match.length,to=from+len,before=str.slice(0,from+1),after=str.slice(to+1);var args=[i,1];if(before){args.push(before)}var wrapped=new Token(token,inside?_.tokenize(match,inside):match);args.push(wrapped);if(after){args.push(after)}Array.prototype.splice.apply(strarr,args)}}}return strarr},hooks:{all:{},add:function(name,callback){var hooks=_.hooks.all;hooks[name]=hooks[name]||[];hooks[name].push(callback)},run:function(name,env){var callbacks=_.hooks.all[name];if(!callbacks||!callbacks.length){return}for(var i=0,callback;callback=callbacks[i++];){callback(env)}}}};var Token=_.Token=function(type,content){this.type=type;this.content=content};Token.stringify=function(o,language,parent){if(typeof o=="string"){return o}if(Object.prototype.toString.call(o)=="[object Array]"){return o.map(function(element){return Token.stringify(element,language,o)}).join("")}var env={type:o.type,content:Token.stringify(o.content,language,parent),tag:"span",classes:["token",o.type],attributes:{},language:language,parent:parent};if(env.type=="comment"){env.attributes["spellcheck"]="true"}_.hooks.run("wrap",env);var attributes="";for(var name in env.attributes){attributes+=name+'="'+(env.attributes[name]||"")+'"'}return"<"+env.tag+' class="'+env.classes.join(" ")+'" '+attributes+">"+env.content+""};if(!self.document){if(!self.addEventListener){return self.Prism}self.addEventListener("message",function(evt){var message=JSON.parse(evt.data),lang=message.language,code=message.code;self.postMessage(JSON.stringify(_.tokenize(code,_.languages[lang])));self.close()},false);return self.Prism}var script=document.getElementsByTagName("script");script=script[script.length-1];if(script){_.filename=script.src;if(document.addEventListener&&!script.hasAttribute("data-manual")){document.addEventListener("DOMContentLoaded",_.highlightAll)}}return self.Prism}();if(typeof module!=="undefined"&&module.exports){module.exports=Prism}Prism.languages.markup={comment:/<!--[\w\W]*?-->/g,prolog:/<\?.+?\?>/,doctype:/<!DOCTYPE.+?>/,cdata:/<!\[CDATA\[[\w\W]*?]]>/i,tag:{pattern:/<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/gi,inside:{tag:{pattern:/^<\/?[\w:-]+/i,inside:{punctuation:/^<\/?/,namespace:/^[\w-]+?:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi,inside:{punctuation:/=|>|"/g}},punctuation:/\/?>/g,"attr-name":{pattern:/[\w:-]+/g,inside:{namespace:/^[\w-]+?:/}}}},entity:/&#?[\da-z]{1,8};/gi};Prism.hooks.add("wrap",function(env){if(env.type==="entity"){env.attributes["title"]=env.content.replace(/&/,"&")}});Prism.languages.css={comment:/\/\*[\w\W]*?\*\//g,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*{))/gi,inside:{punctuation:/[;:]/g}},url:/url\((["']?).*?\1\)/gi,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/g,property:/(\b|\B)[\w-]+(?=\s*:)/gi,string:/("|')(\\?.)*?\1/g,important:/\B!important\b/gi,ignore:/&(lt|gt|amp);/gi,punctuation:/[\{\};:]/g};if(Prism.languages.markup){Prism.languages.insertBefore("markup","tag",{style:{pattern:/(<|<)style[\w\W]*?(>|>)[\w\W]*?(<|<)\/style(>|>)/gi,inside:{tag:{pattern:/(<|<)style[\w\W]*?(>|>)|(<|<)\/style(>|>)/gi,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css}}})}Prism.languages.clike={comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])\/\/.*?(\r?\n|$))/g,lookbehind:true},string:/("|')(\\?.)*?\1/g,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/gi,lookbehind:true,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,"function":{pattern:/[a-z0-9_]+\(/gi,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|(&){1,2}|\|?\||\?|\*|\/|\~|\^|\%/g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g};Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(var|let|if|else|while|do|for|return|in|instanceof|function|get|set|new|with|typeof|try|throw|catch|finally|null|break|continue|this)\b/g,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?|NaN|-?Infinity)\b/g});Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g,lookbehind:true}});if(Prism.languages.markup){Prism.languages.insertBefore("markup","tag",{script:{pattern:/(<|<)script[\w\W]*?(>|>)[\w\W]*?(<|<)\/script(>|>)/gi,inside:{tag:{pattern:/(<|<)script[\w\W]*?(>|>)|(<|<)\/script(>|>)/gi,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript}}})}(function(){if(!self.Prism||!self.document||!document.querySelector){return}var Extensions={js:"javascript",html:"markup",svg:"markup"};Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(pre){var src=pre.getAttribute("data-src");var extension=(src.match(/\.(\w+)$/)||[,""])[1];var language=Extensions[extension]||extension;var code=document.createElement("code");code.className="language-"+language;pre.textContent="";code.textContent="Loading…";pre.appendChild(code);var xhr=new XMLHttpRequest;xhr.open("GET",src,true);xhr.onreadystatechange=function(){if(xhr.readyState==4){if(xhr.status<400&&xhr.responseText){code.textContent=xhr.responseText;Prism.highlightElement(code)}else if(xhr.status>=400){code.textContent="✖ Error "+xhr.status+" while fetching file: "+xhr.statusText}else{code.textContent="✖ Error: File does not exist or is empty"}}};xhr.send(null)})})()},{}],6:[function(require,module,exports){var prism=require("../3rdparty/prism"),defaultTheme={prismComment:"#708090",prismProlog:"prismComment",prismDoctype:"prismComment",prismCdata:"prismComment",prismPunctuation:"#999",prismSymbol:"#905",prismProperty:"prismSymbol",prismTag:"prismSymbol",prismBoolean:"prismSymbol",prismNumber:"prismSymbol",prismConstant:"prismSymbol",prismDeleted:"prismSymbol",prismString:"#690",prismSelector:"prismString",prismAttrName:"prismString",prismChar:"prismString",prismBuiltin:"prismString",prismInserted:"prismString",prismOperator:"#a67f59",prismVariable:"prismOperator",prismEntity:"prismOperator",prismUrl:"prismOperator",prismCssString:"prismOperator",prismKeyword:"#07a",prismAtrule:"prismKeyword",prismAttrValue:"prismKeyword",prismFunction:"#DD4A68",prismRegex:"#e90",prismImportant:["#e90","bold"]},languageMapping={"text/html":"markup","application/xml":"markup","text/xml":"markup","application/json":"javascript","text/javascript":"javascript","application/javascript":"javascript","text/css":"css",html:"markup",xml:"markup",c:"clike","c++":"clike",cpp:"clike","c#":"clike",java:"clike"};function upperCamelCase(str){return str.replace(/(?:^|-)([a-z])/g,function($0,ch){return ch.toUpperCase()})}module.exports={name:"magicpen-prism",installInto:function(magicPen){magicPen.installTheme(defaultTheme);magicPen.addStyle("code",function(sourceText,language){if(language in languageMapping){language=languageMapping[language]}else if(/\+xml\b/.test(language)){language="markup"}if(!(language in prism.languages)){return this.text(sourceText)}sourceText=sourceText.replace(/text.length){break tokenloop}if(str instanceof Token){continue}pattern.lastIndex=0;var match=pattern.exec(str);if(match){if(lookbehind){lookbehindLength=match[1].length}var from=match.index-1+lookbehindLength,match=match[0].slice(lookbehindLength),len=match.length,to=from+len,before=str.slice(0,from+1),after=str.slice(to+1);var args=[i,1];if(before){args.push(before)}var wrapped=new Token(token,inside?_.tokenize(match,inside):match);args.push(wrapped);if(after){args.push(after)}Array.prototype.splice.apply(strarr,args)}}}return strarr},hooks:{all:{},add:function(name,callback){var hooks=_.hooks.all;hooks[name]=hooks[name]||[];hooks[name].push(callback)},run:function(name,env){var callbacks=_.hooks.all[name];if(!callbacks||!callbacks.length){return}for(var i=0,callback;callback=callbacks[i++];){callback(env)}}}};var Token=_.Token=function(type,content){this.type=type;this.content=content};Token.stringify=function(o,language,parent){if(typeof o=="string"){return o}if(Object.prototype.toString.call(o)=="[object Array]"){return o.map(function(element){return Token.stringify(element,language,o)}).join("")}var env={type:o.type,content:Token.stringify(o.content,language,parent),tag:"span",classes:["token",o.type],attributes:{},language:language,parent:parent};if(env.type=="comment"){env.attributes["spellcheck"]="true"}_.hooks.run("wrap",env);var attributes="";for(var name in env.attributes){attributes+=name+'="'+(env.attributes[name]||"")+'"'}return"<"+env.tag+' class="'+env.classes.join(" ")+'" '+attributes+">"+env.content+""};if(!self.document){if(!self.addEventListener){return self.Prism}self.addEventListener("message",function(evt){var message=JSON.parse(evt.data),lang=message.language,code=message.code;self.postMessage(JSON.stringify(_.tokenize(code,_.languages[lang])));self.close()},false);return self.Prism}var script=document.getElementsByTagName("script");script=script[script.length-1];if(script){_.filename=script.src;if(document.addEventListener&&!script.hasAttribute("data-manual")){document.addEventListener("DOMContentLoaded",_.highlightAll)}}return self.Prism}();if(typeof module!=="undefined"&&module.exports){module.exports=Prism}Prism.languages.markup={comment:/<!--[\w\W]*?-->/g,prolog:/<\?.+?\?>/,doctype:/<!DOCTYPE.+?>/,cdata:/<!\[CDATA\[[\w\W]*?]]>/i,tag:{pattern:/<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/gi,inside:{tag:{pattern:/^<\/?[\w:-]+/i,inside:{punctuation:/^<\/?/,namespace:/^[\w-]+?:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi,inside:{punctuation:/=|>|"/g}},punctuation:/\/?>/g,"attr-name":{pattern:/[\w:-]+/g,inside:{namespace:/^[\w-]+?:/}}}},entity:/&#?[\da-z]{1,8};/gi};Prism.hooks.add("wrap",function(env){if(env.type==="entity"){env.attributes["title"]=env.content.replace(/&/,"&")}});Prism.languages.css={comment:/\/\*[\w\W]*?\*\//g,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*{))/gi,inside:{punctuation:/[;:]/g}},url:/url\((["']?).*?\1\)/gi,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/g,property:/(\b|\B)[\w-]+(?=\s*:)/gi,string:/("|')(\\?.)*?\1/g,important:/\B!important\b/gi,ignore:/&(lt|gt|amp);/gi,punctuation:/[\{\};:]/g};if(Prism.languages.markup){Prism.languages.insertBefore("markup","tag",{style:{pattern:/(<|<)style[\w\W]*?(>|>)[\w\W]*?(<|<)\/style(>|>)/gi,inside:{tag:{pattern:/(<|<)style[\w\W]*?(>|>)|(<|<)\/style(>|>)/gi,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css}}})}Prism.languages.clike={comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])\/\/.*?(\r?\n|$))/g,lookbehind:true},string:/("|')(\\?.)*?\1/g,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/gi,lookbehind:true,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,"function":{pattern:/[a-z0-9_]+\(/gi,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|(&){1,2}|\|?\||\?|\*|\/|\~|\^|\%/g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g};Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(var|let|if|else|while|do|for|return|in|instanceof|function|get|set|new|with|typeof|try|throw|catch|finally|null|break|continue|this)\b/g,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?|NaN|-?Infinity)\b/g});Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g,lookbehind:true}});if(Prism.languages.markup){Prism.languages.insertBefore("markup","tag",{script:{pattern:/(<|<)script[\w\W]*?(>|>)[\w\W]*?(<|<)\/script(>|>)/gi,inside:{tag:{pattern:/(<|<)script[\w\W]*?(>|>)|(<|<)\/script(>|>)/gi,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript}}})}(function(){if(!self.Prism||!self.document||!document.querySelector){return}var Extensions={js:"javascript",html:"markup",svg:"markup"};Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(pre){var src=pre.getAttribute("data-src");var extension=(src.match(/\.(\w+)$/)||[,""])[1];var language=Extensions[extension]||extension;var code=document.createElement("code");code.className="language-"+language;pre.textContent="";code.textContent="Loading…";pre.appendChild(code);var xhr=new XMLHttpRequest;xhr.open("GET",src,true);xhr.onreadystatechange=function(){if(xhr.readyState==4){if(xhr.status<400&&xhr.responseText){code.textContent=xhr.responseText;Prism.highlightElement(code)}else if(xhr.status>=400){code.textContent="✖ Error "+xhr.status+" while fetching file: "+xhr.statusText}else{code.textContent="✖ Error: File does not exist or is empty"}}};xhr.send(null)})})()},{}],6:[function(require,module,exports){var prism=require("../3rdparty/prism"),defaultTheme={prismComment:"#708090",prismProlog:"prismComment",prismDoctype:"prismComment",prismCdata:"prismComment",prismPunctuation:"#999",prismSymbol:"#905",prismProperty:"prismSymbol",prismTag:"prismSymbol",prismBoolean:"prismSymbol",prismNumber:"prismSymbol",prismConstant:"prismSymbol",prismDeleted:"prismSymbol",prismString:"#690",prismSelector:"prismString",prismAttrName:"prismString",prismChar:"prismString",prismBuiltin:"prismString",prismInserted:"prismString",prismOperator:"#a67f59",prismVariable:"prismOperator",prismEntity:"prismOperator",prismUrl:"prismOperator",prismCssString:"prismOperator",prismKeyword:"#07a",prismAtrule:"prismKeyword",prismAttrValue:"prismKeyword",prismFunction:"#DD4A68",prismRegex:"#e90",prismImportant:["#e90","bold"]},languageMapping={"text/html":"markup","application/xml":"markup","text/xml":"markup","application/json":"javascript","text/javascript":"javascript","application/javascript":"javascript","text/css":"css",html:"markup",xml:"markup",c:"clike","c++":"clike",cpp:"clike","c#":"clike",java:"clike"};function upperCamelCase(str){return str.replace(/(?:^|-)([a-z])/g,function($0,ch){return ch.toUpperCase()})}module.exports={name:"magicpen-prism",installInto:function(magicPen){magicPen.installTheme(defaultTheme);magicPen.addStyle("code",function(sourceText,language){if(language in languageMapping){language=languageMapping[language]}else if(/\+xml\b/.test(language)){language="markup"}if(!(language in prism.languages)){return this.text(sourceText)}sourceText=sourceText.replace(/