123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- 'use strict';
- exports.__esModule = true;
- exports.default = tokenize;
- var SINGLE_QUOTE = 39;
- var DOUBLE_QUOTE = 34;
- var BACKSLASH = 92;
- var SLASH = 47;
- var NEWLINE = 10;
- var SPACE = 32;
- var FEED = 12;
- var TAB = 9;
- var CR = 13;
- var OPEN_PARENTHESES = 40;
- var CLOSE_PARENTHESES = 41;
- var OPEN_CURLY = 123;
- var CLOSE_CURLY = 125;
- var SEMICOLON = 59;
- var ASTERICK = 42;
- var COLON = 58;
- var AT = 64;
- var COMMA = 44;
- var RE_AT_END = /[ \n\t\r\f{()'"\\;/]/g;
- var RE_NEW_LINE = /[\r\f\n]/g;
- var RE_WORD_END = /[ \n\t\r\f(){}:;@!'"\\,]|\/(?=\*)/g;
- var RE_BAD_BRACKET = /.[\\/("'\n]/;
- function tokenize(input) {
- var tokens = [];
- var css = input.css.valueOf();
- var code = void 0,
- next = void 0,
- quote = void 0,
- lines = void 0,
- last = void 0,
- content = void 0,
- escape = void 0,
- nextLine = void 0,
- nextOffset = void 0,
- escaped = void 0,
- escapePos = void 0,
- prev = void 0,
- n = void 0;
- var length = css.length;
- var offset = -1;
- var line = 1;
- var pos = 0;
- function unclosed(what) {
- throw input.error('Unclosed ' + what, line, pos - offset);
- }
- while (pos < length) {
- code = css.charCodeAt(pos);
- if (code === NEWLINE || code === FEED || code === CR && css.charCodeAt(pos + 1) !== NEWLINE) {
- offset = pos;
- line += 1;
- }
- switch (code) {
- case CR:
- if (css.charCodeAt(pos + 1) === NEWLINE) {
- offset = pos;
- line += 1;
- pos += 1;
- tokens.push(['newline', '\r\n', line - 1]);
- } else {
- tokens.push(['newline', '\r', line - 1]);
- }
- break;
- case FEED:
- case NEWLINE:
- tokens.push(['newline', css.slice(pos, pos + 1), line - 1]);
- break;
- case SPACE:
- case TAB:
- next = pos;
- do {
- next += 1;
- code = css.charCodeAt(next);
- } while (code === SPACE || code === TAB);
- tokens.push(['space', css.slice(pos, next)]);
- pos = next - 1;
- break;
- case OPEN_CURLY:
- tokens.push(['{', '{', line, pos - offset]);
- break;
- case CLOSE_CURLY:
- tokens.push(['}', '}', line, pos - offset]);
- break;
- case COLON:
- tokens.push([':', ':', line, pos - offset]);
- break;
- case SEMICOLON:
- tokens.push([';', ';', line, pos - offset]);
- break;
- case COMMA:
- tokens.push([',', ',', line, pos - offset]);
- break;
- case OPEN_PARENTHESES:
- prev = tokens.length ? tokens[tokens.length - 1][1] : '';
- n = css.charCodeAt(pos + 1);
- if (prev === 'url' && n !== SINGLE_QUOTE && n !== DOUBLE_QUOTE && n !== SPACE && n !== NEWLINE && n !== TAB && n !== FEED && n !== CR) {
- next = pos;
- do {
- escaped = false;
- next = css.indexOf(')', next + 1);
- if (next === -1) unclosed('bracket');
- escapePos = next;
- while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
- escapePos -= 1;
- escaped = !escaped;
- }
- } while (escaped);
- tokens.push(['brackets', css.slice(pos, next + 1), line, pos - offset, line, next - offset]);
- pos = next;
- } else {
- next = css.indexOf(')', pos + 1);
- content = css.slice(pos, next + 1);
- if (next === -1 || RE_BAD_BRACKET.test(content)) {
- tokens.push(['(', '(', line, pos - offset]);
- } else {
- tokens.push(['brackets', content, line, pos - offset, line, next - offset]);
- pos = next;
- }
- }
- break;
- case CLOSE_PARENTHESES:
- tokens.push([')', ')', line, pos - offset]);
- break;
- case SINGLE_QUOTE:
- case DOUBLE_QUOTE:
- quote = code === SINGLE_QUOTE ? '\'' : '"';
- next = pos;
- do {
- escaped = false;
- next = css.indexOf(quote, next + 1);
- if (next === -1) unclosed('quote');
- escapePos = next;
- while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
- escapePos -= 1;
- escaped = !escaped;
- }
- } while (escaped);
- content = css.slice(pos, next + 1);
- lines = content.split('\n');
- last = lines.length - 1;
- if (last > 0) {
- nextLine = line + last;
- nextOffset = next - lines[last].length;
- } else {
- nextLine = line;
- nextOffset = offset;
- }
- tokens.push(['string', css.slice(pos, next + 1), line, pos - offset, nextLine, next - nextOffset]);
- offset = nextOffset;
- line = nextLine;
- pos = next;
- break;
- case AT:
- RE_AT_END.lastIndex = pos + 1;
- RE_AT_END.test(css);
- if (RE_AT_END.lastIndex === 0) {
- next = css.length - 1;
- } else {
- next = RE_AT_END.lastIndex - 2;
- }
- tokens.push(['at-word', css.slice(pos, next + 1), line, pos - offset, line, next - offset]);
- pos = next;
- break;
- case BACKSLASH:
- next = pos;
- escape = true;
- nextLine = line;
- while (css.charCodeAt(next + 1) === BACKSLASH) {
- next += 1;
- escape = !escape;
- }
- code = css.charCodeAt(next + 1);
- if (escape) {
- if (code === CR && css.charCodeAt(next + 2) === NEWLINE) {
- next += 2;
- nextLine += 1;
- nextOffset = next;
- } else if (code === CR || code === NEWLINE || code === FEED) {
- next += 1;
- nextLine += 1;
- nextOffset = next;
- } else {
- next += 1;
- }
- }
- tokens.push(['word', css.slice(pos, next + 1), line, pos - offset, line, next - offset]);
- if (nextLine !== line) {
- line = nextLine;
- offset = nextOffset;
- }
- pos = next;
- break;
- default:
- n = css.charCodeAt(pos + 1);
- if (code === SLASH && n === ASTERICK) {
- next = css.indexOf('*/', pos + 2) + 1;
- if (next === 0) unclosed('comment');
- content = css.slice(pos, next + 1);
- lines = content.split('\n');
- last = lines.length - 1;
- if (last > 0) {
- nextLine = line + last;
- nextOffset = next - lines[last].length;
- } else {
- nextLine = line;
- nextOffset = offset;
- }
- tokens.push(['comment', content, line, pos - offset, nextLine, next - nextOffset]);
- offset = nextOffset;
- line = nextLine;
- pos = next;
- } else if (code === SLASH && n === SLASH) {
- RE_NEW_LINE.lastIndex = pos + 1;
- RE_NEW_LINE.test(css);
- if (RE_NEW_LINE.lastIndex === 0) {
- next = css.length - 1;
- } else {
- next = RE_NEW_LINE.lastIndex - 2;
- }
- content = css.slice(pos, next + 1);
- tokens.push(['comment', content, line, pos - offset, line, next - offset, 'inline']);
- pos = next;
- } else {
- RE_WORD_END.lastIndex = pos + 1;
- RE_WORD_END.test(css);
- if (RE_WORD_END.lastIndex === 0) {
- next = css.length - 1;
- } else {
- next = RE_WORD_END.lastIndex - 2;
- }
- tokens.push(['word', css.slice(pos, next + 1), line, pos - offset, line, next - offset]);
- pos = next;
- }
- break;
- }
- pos++;
- }
- return tokens;
- }
- module.exports = exports['default'];
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRva2VuaXplLmVzNiJdLCJuYW1lcyI6WyJ0b2tlbml6ZSIsIlNJTkdMRV9RVU9URSIsIkRPVUJMRV9RVU9URSIsIkJBQ0tTTEFTSCIsIlNMQVNIIiwiTkVXTElORSIsIlNQQUNFIiwiRkVFRCIsIlRBQiIsIkNSIiwiT1BFTl9QQVJFTlRIRVNFUyIsIkNMT1NFX1BBUkVOVEhFU0VTIiwiT1BFTl9DVVJMWSIsIkNMT1NFX0NVUkxZIiwiU0VNSUNPTE9OIiwiQVNURVJJQ0siLCJDT0xPTiIsIkFUIiwiQ09NTUEiLCJSRV9BVF9FTkQiLCJSRV9ORVdfTElORSIsIlJFX1dPUkRfRU5EIiwiUkVfQkFEX0JSQUNLRVQiLCJpbnB1dCIsInRva2VucyIsImNzcyIsInZhbHVlT2YiLCJjb2RlIiwibmV4dCIsInF1b3RlIiwibGluZXMiLCJsYXN0IiwiY29udGVudCIsImVzY2FwZSIsIm5leHRMaW5lIiwibmV4dE9mZnNldCIsImVzY2FwZWQiLCJlc2NhcGVQb3MiLCJwcmV2IiwibiIsImxlbmd0aCIsIm9mZn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ICd1cmwnICYmIG4gIT09IFNJTkdMRV9RVU9URSAmJiBuICE9PSBET1VCTEVfUVVPVEUgJiZcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbiAhPT0gU1BBQ0UgJiYgbiAhPT0gTkVXTElORSAmJiBuICE9PSBUQUIgJiZcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbiAhPT0gRkVFRCAmJiBuICE9PSBDUikge1xuICAgICAgICAgIG5leHQgPSBwb3NcbiAgICAgICAgICBkbyB7XG4gICAgICAgICAgICBlc2NhcGVkID0gZmFsc2VcbiAgICAgICAgICAgIG5leHQgPSBjc3MuaW5kZXhPZignKScsIG5leHQgKyAxKVxuICAgICAgICAgICAgaWYgKG5leHQgPT09IC0xKSB1bmNsb3NlZCgnYnJhY2tldCcpXG4gICAgICAgICAgICBlc2NhcGVQb3MgPSBuZXh0XG4gICAgICAgICAgICB3aGlsZSAoY3NzLmNoYXJDb2RlQXQoZXNjYXBlUG9zIC0gMSkgPT09IEJBQ0tTTEFTSCkge1xuICAgICAgICAgICAgICBlc2NhcGVQb3MgLT0gMVxuICAgICAgICAgICAgICBlc2NhcGVkID0gIWVzY2FwZWRcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IHdoaWxlIChlc2NhcGVkKVxuXG4gICAgICAgICAgdG9rZW5zLnB1c2goWydicmFja2V0cycsIGNzcy5zbGljZShwb3MsIG5leHQgKyAxKSxcbiAgICAgICAgICAgIGxpbmUsIHBvcyAtIG9mZnNldCxcbiAgICAgICAgICAgIGxpbmUsIG5leHQgLSBvZmZzZXRcbiAgICAgICAgICBdKVxuICAgICAgICAgIHBvcyA9IG5leHRcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBuZXh0ID0gY3NzLmluZGV4T2YoJyknLCBwb3MgKyAxKVxuICAgICAgICAgIGNvbnRlbnQgPSBjc3Muc2xpY2UocG9zLCBuZXh0ICsgMSlcblxuICAgICAgICAgIGlmIChuZXh0ID09PSAtMSB8fCBSRV9CQURfQlJBQ0tFVC50ZXN0KGNvbnRlbnQpKSB7XG4gICAgICAgICAgICB0b2tlbnMucHVzaChbJygnLCAnKCcsIGxpbmUsIHBvcyAtIG9mZnNldF0pXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRva2Vucy5wdXNoKFsnYnJhY2tldHMnLCBjb250ZW50LFxuICAgICAgICAgICAgICBsaW5lLCBwb3MgLSBvZmZzZXQsXG4gICAgICAgICAgICAgIGxpbmUsIG5leHQgLSBvZmZzZXRcbiAgICAgICAgICAgIF0pXG4gICAgICAgICAgICBwb3MgPSBuZXh0XG4gICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgYnJlYWtcblxuICAgICAgY2FzZSBDTE9TRV9QQVJFTlRIRVNFUzpcbiAgICAgICAgdG9rZW5zLnB1c2goWycpJywgJyknLCBsaW5lLCBwb3MgLSBvZmZzZXRdKVxuICAgICAgICBicmVha1xuXG4gICAgICBjYXNlIFNJTkdMRV9RVU9URTpcbiAgICAgIGNhc2UgRE9VQkxFX1FVT1RFOlxuICAgICAgICBxdW90ZSA9IGNvZGUgPT09IFNJTkdMRV9RVU9URSA/ICdcXCcnIDogJ1wiJ1xuICAgICAgICBuZXh0ID0gcG9zXG4gICAgICAgIGRvIHtcbiAgICAgICAgICBlc2NhcGVkID0gZmFsc2VcbiAgICAgICAgICBuZXh0ID0gY3NzLmluZGV4T2YocXVvdGUsIG5leHQgKyAxKVxuICAgICAgICAgIGlmIChuZXh0ID09PSAtMSkgdW5jbG9zZWQoJ3F1b3RlJylcbiAgICAgICAgICBlc2NhcGVQb3MgPSBuZXh0XG4gICAgICAgICAgd2hpbGUgKGNzcy5jaGFyQ29kZUF0KGVzY2FwZVBvcyAtIDEpID09PSBCQUNLU0xBU0gpIHtcbiAgICAgICAgICAgIGVzY2FwZVBvcyAtPSAxXG4gICAgICAgICAgICBlc2NhcGVkID0gIWVzY2FwZWRcbiAgICAgICAgICB9XG4gICAgICAgIH0gd2hpbGUgKGVzY2FwZWQpXG5cbiAgICAgICAgY29udGVudCA9IGNzcy5zbGljZShwb3MsIG5leHQgKyAxKVxuICAgICAgICBsaW5lcyA9IGNvbnRlbnQuc3BsaXQoJ1xcbicpXG4gICAgICAgIGxhc3QgPSBsaW5lcy5sZW5ndGggLSAxXG5cbiAgICAgICAgaWYgKGxhc3QgPiAwKSB7XG4gICAgICAgICAgbmV4dExpbmUgPSBsaW5lICsgbGFzdFxuICAgICAgICAgIG5leHRPZmZzZXQgPSBuZXh0IC0gbGluZXNbbGFzdF0ubGVuZ3RoXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgbmV4dExpbmUgPSBsaW5lXG4gICAgICAgICAgbmV4dE9mZnNldCA9IG9mZnNldFxuICAgICAgICB9XG5cbiAgICAgICAgdG9rZW5zLnB1c2goWydzdHJpbmcnLCBjc3Muc2xpY2UocG9zLCBuZXh0ICsgMSksXG4gICAgICAgICAgbGluZSwgcG9zIC0gb2Zmc2V0LFxuICAgICAgICAgIG5leHRMaW5lLCBuZXh0IC0gbmV4dE9mZnNldFxuICAgICAgICBdKVxuXG4gICAgICAgIG9mZnNldCA9IG5leHRPZmZzZXRcbiAgICAgICAgbGluZSA9IG5leHRMaW5lXG4gICAgICAgIHBvcyA9IG5leHRcbiAgICAgICAgYnJlYWtcblxuICAgICAgY2FzZSBBVDpcbiAgICAgICAgUkVfQVRfRU5ELmxhc3RJbmRleCA9IHBvcyArIDFcbiAgICAgICAgUkVfQVRfRU5ELnRlc3QoY3NzKVxuICAgICAgICBpZiAoUkVfQVRfRU5ELmxhc3RJbmRleCA9PT0gMCkge1xuICAgICAgICAgIG5leHQgPSBjc3MubGVuZ3RoIC0gMVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIG5leHQgPSBSRV9BVF9FTkQubGFzdEluZGV4IC0gMlxuICAgICAgICB9XG4gICAgICAgIHRva2Vucy5wdXNoKFsnYXQtd29yZCcsIGNzcy5zbGljZShwb3MsIG5leHQgKyAxKSxcbiAgICAgICAgICBsaW5lLCBwb3MgLSBvZmZzZXQsXG4gICAgICAgICAgbGluZSwgbmV4dCAtIG9mZnNldFxuICAgICAgICBdKVxuICAgICAgICBwb3MgPSBuZXh0XG4gICAgICAgIGJyZWFrXG5cbiAgICAgIGNhc2UgQkFDS1NMQVNIOlxuICAgICAgICBuZXh0ID0gcG9zXG4gICAgICAgIGVzY2FwZSA9IHRydWVcblxuICAgICAgICBuZXh0TGluZSA9IGxpbmVcblxuICAgICAgICB3aGlsZSAoY3NzLmNoYXJDb2RlQXQobmV4dCArIDEpID09PSBCQUNLU0xBU0gpIHtcbiAgICAgICAgICBuZXh0ICs9IDFcbiAgICAgICAgICBlc2NhcGUgPSAhZXNjYXBlXG4gICAgICAgIH1cbiAgICAgICAgY29kZSA9IGNzcy5jaGFyQ29kZUF0KG5leHQgKyAxKVxuICAgICAgICBpZiAoZXNjYXBlKSB7XG4gICAgICAgICAgaWYgKGNvZGUgPT09IENSICYmIGNzcy5jaGFyQ29kZUF0KG5leHQgKyAyKSA9PT0gTkVXTElORSkge1xuICAgICAgICAgICAgbmV4dCArPSAyXG4gICAgICAgICAgICBuZXh0TGluZSArPSAxXG4gICAgICAgICAgICBuZXh0T2Zmc2V0ID0gbmV4dFxuICAgICAgICAgIH0gZWxzZSBpZiAoY29kZSA9PT0gQ1IgfHwgY29kZSA9PT0gTkVXTElORSB8fCBjb2RlID09PSBGRUVEKSB7XG4gICAgICAgICAgICBuZXh0ICs9IDFcbiAgICAgICAgICAgIG5leHRMaW5lICs9IDFcbiAgICAgICAgICAgIG5leHRPZmZzZXQgPSBuZXh0XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIG5leHQgKz0gMVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB0b2tlbnMucHVzaChbJ3dvcmQnLCBjc3Muc2xpY2UocG9zLCBuZXh0ICsgMSksXG4gICAgICAgICAgbGluZSwgcG9zIC0gb2Zmc2V0LFxuICAgICAgICAgIGxpbmUsIG5leHQgLSBvZmZzZXRcbiAgICAgICAgXSlcbiAgICAgICAgaWYgKG5leHRMaW5lICE9PSBsaW5lKSB7XG4gICAgICAgICAgbGluZSA9IG5leHRMaW5lXG4gICAgICAgICAgb2Zmc2V0ID0gbmV4dE9mZnNldFxuICAgICAgICB9XG4gICAgICAgIHBvcyA9IG5leHRcbiAgICAgICAgYnJlYWtcblxuICAgICAgZGVmYXVsdDpcbiAgICAgICAgbiA9IGNzcy5jaGFyQ29kZUF0KHBvcyArIDEpXG5cbiAgICAgICAgaWYgKGNvZGUgPT09IFNMQVNIICYmIG4gPT09IEFTVEVSSUNLKSB7XG4gICAgICAgICAgbmV4dCA9IGNzcy5pbmRleE9mKCcqLycsIHBvcyArIDIpICsgMVxuICAgICAgICAgIGlmIChuZXh0ID09PSAwKSB1bmNsb3NlZCgnY29tbWVudCcpXG5cbiAgICAgICAgICBjb250ZW50ID0gY3NzLnNsaWNlKHBvcywgbmV4dCArIDEpXG4gICAgICAgICAgbGluZXMgPSBjb250ZW50LnNwbGl0KCdcXG4nKVxuICAgICAgICAgIGxhc3QgPSBsaW5lcy5sZW5ndGggLSAxXG5cbiAgICAgICAgICBpZiAobGFzdCA+IDApIHtcbiAgICAgICAgICAgIG5leHRMaW5lID0gbGluZSArIGxhc3RcbiAgICAgICAgICAgIG5leHRPZmZzZXQgPSBuZXh0IC0gbGluZXNbbGFzdF0ubGVuZ3RoXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIG5leHRMaW5lID0gbGluZVxuICAgICAgICAgICAgbmV4dE9mZnNldCA9IG9mZnNldFxuICAgICAgICAgIH1cblxuICAgICAgICAgIHRva2Vucy5wdXNoKFsnY29tbWVudCcsIGNvbnRlbnQsXG4gICAgICAgICAgICBsaW5lLCBwb3MgLSBvZmZzZXQsXG4gICAgICAgICAgICBuZXh0TGluZSwgbmV4dCAtIG5leHRPZmZzZXRcbiAgICAgICAgICBdKVxuXG4gICAgICAgICAgb2Zmc2V0ID0gbmV4dE9mZnNldFxuICAgICAgICAgIGxpbmUgPSBuZXh0TGluZVxuICAgICAgICAgIHBvcyA9IG5leHRcbiAgICAgICAgfSBlbHNlIGlmIChjb2RlID09PSBTTEFTSCAmJiBuID09PSBTTEFTSCkge1xuICAgICAgICAgIFJFX05FV19MSU5FLmxhc3RJbmRleCA9IHBvcyArIDFcbiAgICAgICAgICBSRV9ORVdfTElORS50ZXN0KGNzcylcbiAgICAgICAgICBpZiAoUkVfTkVXX0xJTkUubGFzdEluZGV4ID09PSAwKSB7XG4gICAgICAgICAgICBuZXh0ID0gY3NzLmxlbmd0aCAtIDFcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgbmV4dCA9IFJFX05FV19MSU5FLmxhc3RJbmRleCAtIDJcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBjb250ZW50ID0gY3NzLnNsaWNlKHBvcywgbmV4dCArIDEpXG5cbiAgICAgICAgICB0b2tlbnMucHVzaChbJ2NvbW1lbnQnLCBjb250ZW50LFxuICAgICAgICAgICAgbGluZSwgcG9zIC0gb2Zmc2V0LFxuICAgICAgICAgICAgbGluZSwgbmV4dCAtIG9mZnNldCxcbiAgICAgICAgICAgICdpbmxpbmUnXG4gICAgICAgICAgXSlcblxuICAgICAgICAgIHBvcyA9IG5leHRcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBSRV9XT1JEX0VORC5sYXN0SW5kZXggPSBwb3MgKyAxXG4gICAgICAgICAgUkVfV09SRF9FTkQudGVzdChjc3MpXG4gICAgICAgICAgaWYgKFJFX1dPUkRfRU5ELmxhc3RJbmRleCA9PT0gMCkge1xuICAgICAgICAgICAgbmV4dCA9IGNzcy5sZW5ndGggLSAxXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIG5leHQgPSBSRV9XT1JEX0VORC5sYXN0SW5kZXggLSAyXG4gICAgICAgICAgfVxuXG4gICAgICAgICAgdG9rZW5zLnB1c2goWyd3b3JkJywgY3NzLnNsaWNlKHBvcywgbmV4dCArIDEpLFxuICAgICAgICAgICAgbGluZSwgcG9zIC0gb2Zmc2V0LFxuICAgICAgICAgICAgbGluZSwgbmV4dCAtIG9mZnNldFxuICAgICAgICAgIF0pXG4gICAgICAgICAgcG9zID0gbmV4dFxuICAgICAgICB9XG5cbiAgICAgICAgYnJlYWtcbiAgICB9XG5cbiAgICBwb3MrK1xuICB9XG5cbiAgcmV0dXJuIHRva2Vuc1xufVxuIl19
|