Created
September 4, 2013 10:42
-
-
Save hughsk/6435396 to your computer and use it in GitHub Desktop.
requirebin sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This version is unminified | |
var observer = require('continuous-observer') | |
var cave = require('cave-automata-2d') | |
var fill = require('ndarray-fill') | |
var zero = require('zeros') | |
var raf = require('raf') | |
var canvas = document.createElement('canvas') | |
var ctx = canvas.getContext('2d') | |
// Set up the controls, so that we can control | |
// the camera with the arrow keys or WASD. | |
var controls = require('kb-controls-iframed')({ | |
'<up>': 'up', | |
'<down>': 'down', | |
'<left>': 'left', | |
'<right>': 'right', | |
'W': 'up', | |
'S': 'down', | |
'A': 'left', | |
'D': 'right' | |
}) | |
var field = require('ndarray-continuous')({ | |
shape: [28, 28], // Make each chunk 28 elements high/wide | |
getter: getter | |
}) | |
// This method generates a new chunk for | |
// the continuous ndarray if it's needed. | |
// | |
// Here we're creating an empty ndarray, then | |
// filling it up with cave-automata-2d. We're | |
// also inverting it so that we can get links | |
// between the chunks without much extra work. | |
function getter(position, done) { | |
var array = zero(this.shape) | |
cave(array)(10) | |
invert(array) | |
return done(null, array) | |
} | |
function invert(array) { | |
return fill(array, function(x, y) { | |
return 1 - array.get(x, y) | |
}) | |
} | |
// We'll use continuous-observer to add and remove | |
// chunks as needed, based on the camera's position | |
// each frame. | |
var moveTo = observer(field) | |
var camera = { | |
x: 0, | |
y: 0 | |
} | |
raf().on('data', function() { | |
if (controls.up) camera.y -= 0.25 | |
if (controls.down) camera.y += 0.25 | |
if (controls.left) camera.x -= 0.25 | |
if (controls.right) camera.x += 0.25 | |
moveTo([camera.x, camera.y]) | |
ctx.fillStyle = '#f2f2f2' | |
ctx.fillRect(0, 0, canvas.width, canvas.height) | |
// Iterate over each chunk in the continuous-ndarray, | |
// drawing each one according to their position on the | |
// grid. | |
field.each(function(chunk) { | |
var pos = chunk.position | |
var w = chunk.shape[0] | |
var h = chunk.shape[1] | |
var offset = { | |
x: chunk.position[0] * chunk.shape[0], | |
y: chunk.position[1] * chunk.shape[1] | |
} | |
ctx.fillStyle = '#af3' | |
for (var x = 0; x < w; x += 1) { | |
for (var y = 0; y < h; y += 1) { | |
if (chunk.get(x, y) > 0) { | |
ctx.fillRect( | |
(offset.x + x - camera.x) * 40, | |
(offset.y + y - camera.y) * 40, | |
39, | |
39 | |
) | |
} | |
} | |
} | |
}) | |
}) | |
document.body.style.margin = | |
document.body.style.padding = 0 | |
document.body.style.overflow = 'hidden' | |
document.body.appendChild(canvas) | |
canvas.width = window.innerWidth | |
canvas.height = window.innerHeight |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require=(function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){ | |
"use strict" | |
function dupe_array(count, value, i) { | |
var c = count[i]|0 | |
if(c <= 0) { | |
return [] | |
} | |
var result = new Array(c), j | |
if(i === count.length-1) { | |
for(j=0; j<c; ++j) { | |
result[j] = value | |
} | |
} else { | |
for(j=0; j<c; ++j) { | |
result[j] = dupe_array(count, value, i+1) | |
} | |
} | |
return result | |
} | |
function dupe_number(count, value) { | |
var result, i | |
result = new Array(count) | |
for(i=0; i<count; ++i) { | |
result[i] = value | |
} | |
return result | |
} | |
function dupe(count, value) { | |
if(typeof value === "undefined") { | |
value = 0 | |
} | |
switch(typeof count) { | |
case "number": | |
if(count > 0) { | |
return dupe_number(count|0, value) | |
} | |
break | |
case "object": | |
if(typeof (count.length) === "number") { | |
return dupe_array(count, value, 0) | |
} | |
break | |
} | |
return [] | |
} | |
module.exports = dupe | |
},{}],"continuous-observer":[function(require,module,exports){ | |
module.exports=require('cvAJoq'); | |
},{}],"cvAJoq":[function(require,module,exports){ | |
var dup = require('dup') | |
var map = require('map-async') | |
var cells = require('cell-range') | |
var round = Math.round | |
var min = Math.min | |
var max = Math.max | |
var abs = Math.abs | |
module.exports = observer | |
function observer(field, range, linger) { | |
range = (+range|0) || 1 | |
linger = max((+linger|0) - range, range) | |
var shape = field.shape | |
var dims = shape.length | |
var neighbours = cells(dup(dims, -range), dup(dims, range)) | |
var singletemp = [] | |
function observeone(place, callback) { | |
singletemp[0] = place | |
return observe(singletemp, callback) | |
} | |
return observe | |
function observe(places, callback) { | |
if (!Array.isArray(places[0])) return observeone(places, callback) | |
callback = callback || function(){} | |
map(places, function(coord, next) { | |
coord = coord.slice() | |
var i = dims | |
while (i--) coord[i] = round(coord[i] / shape[i]) | |
map(neighbours, function(offset, next) { | |
var pos = coord.slice() | |
var i = dims | |
while (i--) pos[i] += offset[i] | |
field.chunk(pos, next) | |
}, next) | |
}, function(err) { | |
if (err) return next(err) | |
var closest = Infinity | |
var flagged = [] | |
var distance = 0 | |
var l = places.length | |
var pos | |
var i | |
var pages = field.index.pages | |
for (var p = 0; p < pages.length; p += 1) | |
for (var c = 0; c < pages[p].length; c += 1) { | |
pos = pages[p][c].position | |
closest = Infinity | |
for (i = 0; i < l; i += 1) { | |
distance = 0 | |
for (var d = 0; d < dims; d += 1) { | |
distance += abs(pos[d] - places[i][d] / shape[d]) | |
} | |
closest = distance < closest | |
? distance | |
: closest | |
} | |
if (closest > range + linger) flagged.push(pos) | |
} | |
i = flagged.length | |
while (i--) field.remove(flagged[i]) | |
return callback(null) | |
}) | |
} | |
} | |
},{"dup":1,"cell-range":2,"map-async":3}],2:[function(require,module,exports){ | |
module.exports = cells | |
function cells(hi, lo) { | |
if (hi.length !== lo.length) throw new Error( | |
'Both arguments must be arrays of equal length' | |
) | |
var dims = hi.length | |
var lod = lo[lo.length - 1] | |
return recurse([], [], 0) | |
function recurse(array, temp, d) { | |
if (d === dims - 1) { | |
for (var i = hi[d]; i <= lo[d]; i += 1) { | |
if (i === lo[d]) { | |
temp.push(i) | |
array.push(temp) | |
} else { | |
array.push(temp.concat(i)) | |
} | |
} | |
} else { | |
for (var i = hi[d]; i <= lo[d]; i += 1) { | |
if (i == lo[d]) { | |
temp.push(i) | |
recurse(array, temp, d + 1) | |
} else { | |
recurse(array, temp.concat(i), d + 1) | |
} | |
} | |
} | |
return array | |
} | |
} | |
},{}],3:[function(require,module,exports){ | |
module.exports = map | |
function map(list, iterator, context, callback) { | |
var keys = Object.keys(list) | |
, returnValue = Array.isArray(list) ? [] : {} | |
, count = keys.length | |
if (typeof context === "function") { | |
callback = context | |
context = this | |
} | |
if (keys.length === 0) { | |
return callback(null, returnValue) | |
} | |
for (var i = 0, len = keys.length; i < len; i++) { | |
var key = keys[i] | |
, value = list[key] | |
invokeIterator(iterator, | |
next(key), context, value, key, list) | |
} | |
function next(key) { | |
return handler | |
function handler(err, newValue) { | |
if (err) { | |
return callback && callback(err) | |
} | |
returnValue[key] = newValue | |
if (--count === 0) { | |
callback && callback(null, returnValue) | |
} | |
} | |
} | |
} | |
function invokeIterator(iterator, done, self, value, key, list) { | |
var length = iterator.length | |
if (length === 1) { | |
iterator.call(self, done) | |
} else if (length === 2) { | |
iterator.call(self, value, done) | |
} else if (length === 3) { | |
iterator.call(self, value, key, done) | |
} else { | |
iterator.call(self, value, key, list, done) | |
} | |
} | |
},{}]},{},[]) | |
//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJhdGVkLmpzIiwic291cmNlcyI6WyIvcHJpdmF0ZS92YXIvZm9sZGVycy80My96N3B2OHB2ZDR4NTdudF8xenoyNTYxdHcwMDAwZ24vVC9jb250aW51b3VzLW9ic2VydmVyMTEzODQtNDIzNDYtbDRhMTllL25vZGVfbW9kdWxlcy9jb250a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uICAgIGlmIChrZXlzLmxlbmd0aCA9PT0gMCkge1xuICAgICAgICByZXR1cm4gY2FsbGJhY2sobnVsbCwgcmV0dXJuVmFsdWUpXG4gICAgfVxuXG4gICAgZm9yICh2YXIgaSA9IDAsIGxlbiA9IGtleXMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHtcbiAgICAgICAgdmFyIGtleSA9IGtleXNbaV1cbiAgICAgICAgICAgICwgdmFsdWUgPSBsaXN0W2tleV1cblxuICAgICAgICBpbnZva2VJdGVyYXRvcihpdGVyYXRvcixcbiAgICAgICAgICAgIG5leHQoa2V5KSwgY29udGV4dCwgdmFsdWUsIGtleSwgbGlzdClcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBuZXh0KGtleSkge1xuICAgICAgICByZXR1cm4gaGFuZGxlclxuXG4gICAgICAgIGZ1bmN0aW9uIGhhbmRsZXIoZXJyLCBuZXdWYWx1ZSkge1xuICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayAmJiBjYWxsYmFjayhlcnIpXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHJldHVyblZhbHVlW2tleV0gPSBuZXdWYWx1ZVxuXG4gICAgICAgICAgICBpZiAoLS1jb3VudCA9PT0gMCkge1xuICAgICAgICAgICAgICAgIGNhbGxiYWNrICYmIGNhbGxiYWNrKG51bGwsIHJldHVyblZhbHVlKVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxufVxuXG5mdW5jdGlvbiBpbnZva2VJdGVyYXRvcihpdGVyYXRvciwgZG9uZSwgc2VsZiwgdmFsdWUsIGtleSwgbGlzdCkge1xuICAgIHZhciBsZW5ndGggPSBpdGVyYXRvci5sZW5ndGhcblxuICAgIGlmIChsZW5ndGggPT09IDEpIHtcbiAgICAgICAgaXRlcmF0b3IuY2FsbChzZWxmLCBkb25lKVxuICAgIH0gZWxzZSBpZiAobGVuZ3RoID09PSAyKSB7XG4gICAgICAgIGl0ZXJhdG9yLmNhbGwoc2VsZiwgdmFsdWUsIGRvbmUpXG4gICAgfSBlbHNlIGlmIChsZW5ndGggPT09IDMpIHtcbiAgICAgICAgaXRlcmF0b3IuY2FsbChzZWxmLCB2YWx1ZSwga2V5LCBkb25lKVxuICAgIH0gZWxzZSB7XG4gICAgICAgIGl0ZXJhdG9yLmNhbGwoc2VsZiwgdmFsdWUsIGtleSwgbGlzdCwgZG9uZSlcbiAgICB9XG59XG4iXX0= | |
;require=(function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({"cave-automata-2d":[function(require,module,exports){ | |
module.exports=require('5cLkHa'); | |
},{}],"5cLkHa":[function(require,module,exports){ | |
var neighborhood = require('moore')(1, 2).concat([[0,0]]) | |
var stencil = require('ndarray-stencil') | |
var fill = require('ndarray-fill') | |
var zero = require('zeros') | |
var neighbors = neighborhood.length | |
var stencils = {} | |
module.exports = generate | |
// ndarray-stencil generates code using cwise, and as | |
// such incurs a slight performance hit initially. | |
// To work around this, we can keep two cached functions | |
// which use shared parameters. See `iterator` for more info. | |
var sharedWidth = null | |
var sharedHeight = null | |
var sharedBorder = null | |
var sharedThreshold = null | |
stencils.vanilla = stencil(neighborhood, function(p1,p2,p3,p4,p5,p6,p7,p8,p9,pos) { | |
return ( | |
p1+p2+p3+p4+p5+p6+p7+p8+p9 >= sharedThreshold | |
) ? 1 : 0 | |
}, { useIndex: false }) | |
stencils.border = stencil(neighborhood, function(p1,p2,p3,p4,p5,p6,p7,p8,p9,pos) { | |
return ( | |
p1+p2+p3+p4+p5+p6+p7+p8+p9 >= sharedThreshold || | |
pos[0] < sharedBorder || | |
pos[0] > sharedWidth - sharedBorder - 3 || | |
pos[1] < sharedBorder || | |
pos[1] > sharedHeight - sharedBorder - 3 | |
) ? 1 : 0 | |
}, { useIndex: true }) | |
function generate(array, opts) { | |
opts = opts || {} | |
var width = array.shape[0] | |
, height = array.shape[1] | |
, buffer = opts.buffer || zero([ width, height ]) | |
var density = opts.density || 0.5 | |
, threshold = opts.threshold || 5 | |
, border = 'border' in opts ? opts.border : 1 | |
, shouldFill = 'fill' in opts ? opts.fill : true | |
, iterate = stencils[ | |
border ? 'border' : 'vanilla' | |
] | |
if (shouldFill) fill(array, function(x, y) { | |
return Math.random() <= density || ( | |
x <= 1 || x >= width-2 || | |
y <= 1 || y >= height-2 | |
) ? 1 : 0 | |
}) | |
if (opts.iterations) { | |
iterator(opts.iterations) | |
} | |
return iterator | |
// Updates the shared variables that are available | |
// on the module-level scope. This is a synchronous | |
// operation, so it's totally safe (though not | |
// necessarily pretty) provided these values are | |
// updated before any iteration. | |
function iterator(iterations) { | |
sharedWidth = width | |
sharedHeight = height | |
sharedBorder = border | |
sharedThreshold = threshold | |
iterations = iterations || 1 | |
for (var i = 0; i < iterations; i += 1) { | |
if (i % 2) { | |
iterate(array, buffer) | |
} else { | |
iterate(buffer, array) | |
} | |
} | |
if (iterations % 2) { | |
fill(array, function(x, y) { | |
return buffer.get(x, y) | |
}) | |
} | |
return array | |
} | |
} | |
},{"ndarray-stencil":1,"zeros":2,"ndarray-fill":3,"moore":4}],4:[function(require,module,exports){ | |
module.exports = moore | |
function moore(range, dims) { | |
dims = dims || 2 | |
range = range || 1 | |
return recurse([], [], 0) | |
function recurse(array, temp, d) { | |
if (d === dims-1) { | |
for (var i = -range; i <= range; i += 1) { | |
if (i || temp.some(function(n) { | |
return n | |
})) array.push(temp.concat(i)) | |
} | |
} else { | |
for (var i = -range; i <= range; i += 1) { | |
recurse(array, temp.concat(i), d+1) | |
} | |
} | |
return array | |
} | |
} | |
},{}],1:[function(require,module,exports){ | |
"use strict" | |
var dup = require("dup") | |
var cwise = require("cwise") | |
function generateCWiseLoop(n, d, func, options) { | |
var body_args = [] | |
var args = ["scalar", "array"] | |
for(var i=0; i<n; ++i) { | |
args.push("array") | |
body_args.push("a"+i) | |
} | |
if(options.useIndex) { | |
body_args.push("idx") | |
args.push("index") | |
} | |
body_args.push(["out=func(",body_args.join(","),")"].join("")) | |
body_args.unshift("out") | |
body_args.unshift("func") | |
var loop = cwise({ | |
args: args, | |
body: Function.apply(undefined, body_args), | |
funcName: "StencilOp" | |
}) | |
return loop.bind(undefined, func) | |
} | |
function hiOffset(hi, point) { | |
var out = new Array(point.length) | |
for(var i=0; i<hi.length; ++i) { | |
var d = -point[i]-hi[i] | |
if(d === 0) { | |
out[i] = "s" + i | |
} else { | |
out[i] = ["s", i, "-", (-d)].join("") | |
} | |
} | |
return out.join(",") | |
} | |
function loOffset(lo, point) { | |
var out = new Array(point.length) | |
for(var i=0; i<lo.length; ++i) { | |
var d = -lo[i]-point[i] | |
if(d === 0) { | |
out[i] = "0" | |
} else { | |
out[i] = d | |
} | |
} | |
return out.join(",") | |
} | |
function generateWrapper(points, lo, hi, loop) { | |
var n = points.length | |
var d = lo.length | |
var code = ["'use strict'"] | |
code.push("var s=out.shape") | |
for(var i=0; i<d; ++i) { | |
code.push(["var s", i, "=s[", i, "]|0"].join("")) | |
} | |
code.push(["func(out.hi(", hiOffset(hi, dup(d)), ").lo(", loOffset(lo, dup(d)), ")"].join("")) | |
for(var i=0; i<points.length; ++i) { | |
code.push([",inp.hi(", hiOffset(hi, points[i]), ").lo(", loOffset(lo, points[i]), ")"].join("")) | |
} | |
code.push(")") | |
var proc = new Function("func", "out", "inp", code.join("\n")) | |
return proc.bind(undefined, loop) | |
} | |
function stencilOp(points, func, options) { | |
options = options || {} | |
if(points.length === 0) { | |
throw new Error("ndarray-stencil: Need to specify at least one point for stencil") | |
} | |
var n = points.length | |
var d = points[0].length | |
var lo = dup(d) | |
var hi = dup(d) | |
for(var i=0; i<n; ++i) { | |
var p = points[i] | |
for(var j=0; j<d; ++j) { | |
lo[j] = Math.min(lo[j], p[j]) | |
hi[j] = Math.max(hi[j], p[j]) | |
} | |
} | |
var cwiseLoop = generateCWiseLoop(n, d, func, options) | |
return generateWrapper(points, lo, hi, cwiseLoop) | |
} | |
module.exports = stencilOp | |
},{"dup":5,"cwise":6}],2:[function(require,module,exports){ | |
"use strict" | |
var ndarray = require("ndarray") | |
module.exports = function zeros(shape) { | |
var sz = 1 | |
for(var i=0; i<shape.length; ++i) { | |
sz *= shape[i] | |
} | |
return ndarray(new Float64Array(sz), shape) | |
} | |
},{"ndarray":7}],3:[function(require,module,exports){ | |
"use strict" | |
var fill = require("cwise")({ | |
args: ["index", "array", "scalar"], | |
body: function(idx, out, f) { | |
out = f.apply(undefined, idx) | |
} | |
}) | |
module.exports = function(array, f) { | |
fill(array, f) | |
return array | |
} | |
},{"cwise":8}],5:[function(require,module,exports){ | |
"use strict" | |
function dupe_array(count, value, i) { | |
var c = count[i]|0 | |
if(c <= 0) { | |
return [] | |
} | |
var result = new Array(c), j | |
if(i === count.length-1) { | |
for(j=0; j<c; ++j) { | |
result[j] = value | |
} | |
} else { | |
for(j=0; j<c; ++j) { | |
result[j] = dupe_array(count, value, i+1) | |
} | |
} | |
return result | |
} | |
function dupe_number(count, value) { | |
var result, i | |
result = new Array(count) | |
for(i=0; i<count; ++i) { | |
result[i] = value | |
} | |
return result | |
} | |
function dupe(count, value) { | |
if(typeof value === "undefined") { | |
value = 0 | |
} | |
switch(typeof count) { | |
case "number": | |
if(count > 0) { | |
return dupe_number(count|0, value) | |
} | |
break | |
case "object": | |
if(typeof (count.length) === "number") { | |
return dupe_array(count, value, 0) | |
} | |
break | |
} | |
return [] | |
} | |
module.exports = dupe | |
},{}],6:[function(require,module,exports){ | |
"use strict" | |
var parse = require("cwise-parser") | |
var compile = require("cwise-compiler") | |
var REQUIRED_FIELDS = [ "args", "body" ] | |
var OPTIONAL_FIELDS = [ "pre", "post", "printCode", "funcName", "blockSize" ] | |
function createCWise(user_args) { | |
//Check parameters | |
for(var id in user_args) { | |
if(REQUIRED_FIELDS.indexOf(id) < 0 && | |
OPTIONAL_FIELDS.indexOf(id) < 0) { | |
console.warn("cwise: Unknown argument '"+id+"' passed to expression compiler") | |
} | |
} | |
for(var i=0; i<REQUIRED_FIELDS.length; ++i) { | |
if(!user_args[REQUIRED_FIELDS[i]]) { | |
throw new Error("cwise: Missing argument: " + REQUIRED_FIELDS[i]) | |
} | |
} | |
//Parse blocks | |
return compile({ | |
args: user_args.args, | |
pre: parse(user_args.pre || function(){}), | |
body: parse(user_args.body), | |
post: parse(user_args.post || function(){}), | |
debug: !!user_args.printCode, | |
funcName: user_args.funcName || user_args.body.name || "cwise", | |
blockSize: user_args.blockSize || 64 | |
}) | |
} | |
module.exports = createCWise | |
},{"cwise-parser":9,"cwise-compiler":10}],7:[function(require,module,exports){ | |
"use strict" | |
var iota = require("iota-array") | |
var arrayMethods = [ | |
"concat", | |
"join", | |
"slice", | |
"toString", | |
"indexOf", | |
"lastIndexOf", | |
"forEach", | |
"every", | |
"some", | |
"filter", | |
"map", | |
"reduce", | |
"reduceRight" | |
] | |
function compare1st(a, b) { | |
return a[0] - b[0] | |
} | |
function order() { | |
var stride = this.stride | |
var terms = new Array(stride.length) | |
var i | |
for(i=0; i<terms.length; ++i) { | |
terms[i] = [Math.abs(stride[i]), i] | |
} | |
terms.sort(compare1st) | |
var result = new Array(terms.length) | |
for(i=0; i<result.length; ++i) { | |
result[i] = terms[i][1] | |
} | |
return result | |
} | |
var ZeroArray = "function ZeroArray(a,d) {\ | |
this.data = a;\ | |
this.offset = d\ | |
};\ | |
var proto=ZeroArray.prototype;\ | |
proto.size=0;\ | |
proto.shape=[];\ | |
proto.stride=[];\ | |
proto.order=[];\ | |
proto.get=proto.set=function() {\ | |
return Number.NaN\ | |
};\ | |
proto.lo=\ | |
proto.hi=\ | |
proto.transpose=\ | |
proto.step=\ | |
proto.pick=function() {\ | |
return new ZeroArray(this.data,this.shape,this.stride,this.offset)\ | |
}" | |
function compileConstructor(dtype, dimension) { | |
//Special case for 0d arrays | |
if(dimension === 0) { | |
var compiledProc = new Function([ | |
ZeroArray, | |
"ZeroArray.prototype.dtype='"+dtype+"'", | |
"return function construct_ZeroArray(a,b,c,d){return new ZeroArray(a,d)}"].join("\n")) | |
return compiledProc() | |
} | |
var useGetters = (dtype === "generic") | |
var code = ["'use strict'"] | |
//Create constructor for view | |
var indices = iota(dimension) | |
var args = indices.map(function(i) { return "i"+i }) | |
var index_str = "this.offset+" + indices.map(function(i) { | |
return ["this._stride", i, "*i",i].join("") | |
}).join("+") | |
var className = ["View", dimension, "d", dtype].join("") | |
code.push(["function ", className, "(a,", | |
indices.map(function(i) { | |
return "b"+i | |
}).join(","), ",", | |
indices.map(function(i) { | |
return "c"+i | |
}).join(","), ",d){this.data=a"].join("")) | |
for(var i=0; i<dimension; ++i) { | |
code.push(["this._shape",i,"=b",i,"|0"].join("")) | |
} | |
for(var i=0; i<dimension; ++i) { | |
code.push(["this._stride",i,"=c",i,"|0"].join("")) | |
} | |
code.push("this.offset=d|0}") | |
//Get prototype | |
code.push(["var proto=",className,".prototype"].join("")) | |
//view.dtype: | |
code.push(["proto.dtype='", dtype, "'"].join("")) | |
code.push("proto.dimension="+dimension) | |
//view.stride and view.shape | |
var strideClassName = ["VStride", dimension, "d", dtype].join("") | |
var shapeClassName = ["VShape", dimension, "d", dtype].join("") | |
var props = {"stride":strideClassName, "shape":shapeClassName} | |
for(var prop in props) { | |
var arrayName = props[prop] | |
code.push(["function ", arrayName, "(v) {this._v=v} var aproto=", arrayName, ".prototype"].join("")) | |
code.push(["aproto.length=",dimension].join("")) | |
var array_elements = [] | |
for(var i=0; i<dimension; ++i) { | |
array_elements.push(["this._v._", prop, i].join("")) | |
} | |
code.push(["aproto.toJSON=function ", arrayName, "_toJSON(){return [", array_elements.join(","), "]}"].join("")) | |
code.push(["aproto.toString=function ", arrayName, "_toString(){return [", array_elements.join(","), "].join()}"].join("")) | |
for(var i=0; i<dimension; ++i) { | |
code.push(["Object.defineProperty(aproto,", i, ",{get:function(){return this._v._", prop, i, "},set:function(v){return this._v._", prop, i, "=v|0},enumerable:true})"].join("")) | |
} | |
for(var i=0; i<arrayMethods.length; ++i) { | |
if(arrayMethods[i] in Array.prototype) { | |
code.push(["aproto.", arrayMethods[i], "=Array.prototype.", arrayMethods[i]].join("")) | |
} | |
} | |
code.push(["Object.defineProperty(proto,'",prop,"',{get:function ", arrayName, "_get(){return new ", arrayName, "(this)},set: function ", arrayName, "_set(v){"].join("")) | |
for(var i=0; i<dimension; ++i) { | |
code.push(["this._", prop, i, "=v[", i, "]|0"].join("")) | |
} | |
code.push("return v}})") | |
} | |
//view.size: | |
code.push(["Object.defineProperty(proto,'size',{get:function ",className,"_size(){\ | |
return ", indices.map(function(i) { return ["this._shape", i].join("") }).join("*"), | |
"}})"].join("")) | |
//view.order: | |
if(dimension === 1) { | |
code.push("proto.order=[0]") | |
} else { | |
code.push("Object.defineProperty(proto,'order',{get:") | |
if(dimension < 4) { | |
code.push(["function ",className,"_order(){"].join("")) | |
if(dimension === 2) { | |
code.push("return (Math.abs(this._stride0)>Math.abs(this._stride1))?[1,0]:[0,1]}})") | |
} else if(dimension === 3) { | |
code.push( | |
"var s0=Math.abs(this._stride0),s1=Math.abs(this._stride1),s2=Math.abs(this._stride2);\ | |
if(s0>s1){\ | |
if(s1>s2){\ | |
return [2,1,0];\ | |
}else if(s0>s2){\ | |
return [1,2,0];\ | |
}else{\ | |
return [1,0,2];\ | |
}\ | |
}else if(s0>s2){\ | |
return [2,0,1];\ | |
}else if(s2>s1){\ | |
return [0,1,2];\ | |
}else{\ | |
return [0,2,1];\ | |
}}})") | |
} | |
} else { | |
code.push("ORDER})") | |
} | |
} | |
//view.set(i0, ..., v): | |
code.push([ | |
"proto.set=function ",className,"_set(", args.join(","), ",v){"].join("")) | |
if(useGetters) { | |
code.push(["return this.data.set(", index_str, ",v)}"].join("")) | |
} else { | |
code.push(["return this.data[", index_str, "]=v}"].join("")) | |
} | |
//view.get(i0, ...): | |
code.push(["proto.get=function ",className,"_get(", args.join(","), "){"].join("")) | |
if(useGetters) { | |
code.push(["return this.data.get(", index_str, ")}"].join("")) | |
} else { | |
code.push(["return this.data[", index_str, "]}"].join("")) | |
} | |
//view.hi(): | |
code.push(["proto.hi=function ",className,"_hi(",args.join(","),"){return new ", className, "(this.data,", | |
indices.map(function(i) { | |
return ["(typeof i",i,"!=='number'||i",i,"<0)?this._shape", i, ":i", i,"|0"].join("") | |
}).join(","), ",", | |
indices.map(function(i) { | |
return "this._stride"+i | |
}).join(","), ",this.offset)}"].join("")) | |
//view.lo(): | |
var a_vars = indices.map(function(i) { return "a"+i+"=this._shape"+i }) | |
var c_vars = indices.map(function(i) { return "c"+i+"=this._stride"+i }) | |
code.push(["proto.lo=function ",className,"_lo(",args.join(","),"){var b=this.offset,d=0,", a_vars.join(","), ",", c_vars.join(",")].join("")) | |
for(var i=0; i<dimension; ++i) { | |
code.push([ | |
"if(typeof i",i,"==='number'&&i",i,">=0){\ | |
d=i",i,"|0;\ | |
b+=c",i,"*d;\ | |
a",i,"-=d}"].join("")) | |
} | |
code.push(["return new ", className, "(this.data,", | |
indices.map(function(i) { | |
return "a"+i | |
}).join(","),",", | |
indices.map(function(i) { | |
return "c"+i | |
}).join(","), ",b)}"].join("")) | |
//view.step(): | |
code.push(["proto.step=function ",className,"_step(",args.join(","),"){var ", | |
indices.map(function(i) { | |
return "a"+i+"=this._shape"+i | |
}).join(","), ",", | |
indices.map(function(i) { | |
return "b"+i+"=this._stride"+i | |
}).join(","),",c=this.offset,d=0,ceil=Math.ceil"].join("")) | |
for(var i=0; i<dimension; ++i) { | |
code.push([ | |
"if(typeof i",i,"==='number'){\ | |
d=i",i,"|0;\ | |
if(d<0){\ | |
c+=b",i,"*(a",i,"-1);\ | |
a",i,"=ceil(-a",i,"/d)\ | |
}else{\ | |
a",i,"=ceil(a",i,"/d)\ | |
}\ | |
b",i,"*=d\ | |
}"].join("")) | |
} | |
code.push(["return new ", className, "(this.data,", | |
indices.map(function(i) { | |
return "a" + i | |
}).join(","), ",", | |
indices.map(function(i) { | |
return "b" + i | |
}).join(","), ",c)}"].join("")) | |
//view.transpose(): | |
var tShape = new Array(dimension) | |
var tStride = new Array(dimension) | |
for(var i=0; i<dimension; ++i) { | |
tShape[i] = ["a[i", i, "|0]"].join("") | |
tStride[i] = ["b[i", i, "|0]"].join("") | |
} | |
code.push(["proto.transpose=function ",className,"_transpose(",args,"){var a=this.shape,b=this.stride;return new ", className, "(this.data,", tShape.join(","), ",", tStride.join(","), ",this.offset)}"].join("")) | |
//view.pick(): | |
code.push(["proto.pick=function ",className,"_pick(",args,"){var a=[],b=[],c=this.offset"].join("")) | |
for(var i=0; i<dimension; ++i) { | |
code.push(["if(typeof i",i,"==='number'&&i",i,">=0){c=(c+this._stride",i,"*i",i,")|0}else{a.push(this._shape",i,");b.push(this._stride",i,")}"].join("")) | |
} | |
code.push("var ctor=CTOR_LIST[a.length];return ctor(this.data,a,b,c)}") | |
//Add return statement | |
code.push(["return function construct_",className,"(data,shape,stride,offset){return new ", className,"(data,", | |
indices.map(function(i) { | |
return "shape["+i+"]" | |
}).join(","), ",", | |
indices.map(function(i) { | |
return "stride["+i+"]" | |
}).join(","), ",offset)}"].join("")) | |
//Compile procedure | |
var procedure = new Function("CTOR_LIST", "ORDER", code.join("\n")) | |
return procedure(CACHED_CONSTRUCTORS[dtype], order) | |
} | |
function arrayDType(data) { | |
if(data instanceof Float64Array) { | |
return "float64"; | |
} else if(data instanceof Float32Array) { | |
return "float32" | |
} else if(data instanceof Int32Array) { | |
return "int32" | |
} else if(data instanceof Uint32Array) { | |
return "uint32" | |
} else if(data instanceof Uint8Array) { | |
return "uint8" | |
} else if(data instanceof Uint16Array) { | |
return "uint16" | |
} else if(data instanceof Int16Array) { | |
return "int16" | |
} else if(data instanceof Int8Array) { | |
return "int8" | |
} else if(data instanceof Array) { | |
return "array" | |
} | |
return "generic" | |
} | |
var CACHED_CONSTRUCTORS = { | |
"float32":[], | |
"float64":[], | |
"int8":[], | |
"int16":[], | |
"int32":[], | |
"uint8":[], | |
"uint16":[], | |
"uint32":[], | |
"array":[], | |
"generic":[] | |
} | |
function wrappedNDArrayCtor(data, shape, stride, offset) { | |
if(shape === undefined) { | |
shape = [ data.length ] | |
} | |
var d = shape.length | |
if(stride === undefined) { | |
stride = new Array(d) | |
for(var i=d-1, sz=1; i>=0; --i) { | |
stride[i] = sz | |
sz *= shape[i] | |
} | |
} | |
if(offset === undefined) { | |
offset = 0 | |
for(var i=0; i<d; ++i) { | |
if(stride[i] < 0) { | |
offset -= (shape[i]-1)*stride[i] | |
} | |
} | |
} | |
var dtype = arrayDType(data) | |
var ctor_list = CACHED_CONSTRUCTORS[dtype] | |
while(ctor_list.length <= d) { | |
ctor_list.push(compileConstructor(dtype, ctor_list.length)) | |
} | |
var ctor = ctor_list[d] | |
return ctor(data, shape, stride, offset) | |
} | |
module.exports = wrappedNDArrayCtor | |
},{"iota-array":11}],8:[function(require,module,exports){ | |
"use strict" | |
var parse = require("cwise-parser") | |
var compile = require("cwise-compiler") | |
var REQUIRED_FIELDS = [ "args", "body" ] | |
var OPTIONAL_FIELDS = [ "pre", "post", "printCode", "funcName", "blockSize" ] | |
function createCWise(user_args) { | |
//Check parameters | |
for(var id in user_args) { | |
if(REQUIRED_FIELDS.indexOf(id) < 0 && | |
OPTIONAL_FIELDS.indexOf(id) < 0) { | |
console.warn("cwise: Unknown argument '"+id+"' passed to expression compiler") | |
} | |
} | |
for(var i=0; i<REQUIRED_FIELDS.length; ++i) { | |
if(!user_args[REQUIRED_FIELDS[i]]) { | |
throw new Error("cwise: Missing argument: " + REQUIRED_FIELDS[i]) | |
} | |
} | |
//Parse blocks | |
return compile({ | |
args: user_args.args, | |
pre: parse(user_args.pre || function(){}), | |
body: parse(user_args.body), | |
post: parse(user_args.post || function(){}), | |
debug: !!user_args.printCode, | |
funcName: user_args.funcName || user_args.body.name || "cwise", | |
blockSize: user_args.blockSize || 64 | |
}) | |
} | |
module.exports = createCWise | |
},{"cwise-parser":12,"cwise-compiler":13}],11:[function(require,module,exports){ | |
"use strict" | |
function iota(n) { | |
var result = new Array(n) | |
for(var i=0; i<n; ++i) { | |
result[i] = i | |
} | |
return result | |
} | |
module.exports = iota | |
},{}],10:[function(require,module,exports){ | |
"use strict" | |
var createThunk = require("./lib/thunk.js") | |
function Procedure() { | |
this.argTypes = [] | |
this.shimArgs = [] | |
this.arrayArgs = [] | |
this.scalarArgs = [] | |
this.indexArgs = [] | |
this.shapeArgs = [] | |
this.funcName = "" | |
this.pre = null | |
this.body = null | |
this.post = null | |
this.debug = false | |
} | |
function compileCwise(user_args) { | |
//Create procedure | |
var proc = new Procedure() | |
//Parse blocks | |
proc.pre = user_args.pre | |
proc.body = user_args.body | |
proc.post = user_args.post | |
//Parse arguments | |
var proc_args = user_args.args.slice(0) | |
proc.argTypes = proc_args | |
for(var i=0; i<proc_args.length; ++i) { | |
switch(proc_args[i]) { | |
case "array": | |
proc.arrayArgs.push(i) | |
proc.shimArgs.push("array" + i) | |
if(i < proc.pre.args.length && proc.pre.args[i].count>0) { | |
throw new Error("cwise: pre() block may not reference array args") | |
} | |
if(i < proc.post.args.length && proc.post.args[i].count>0) { | |
throw new Error("cwise: post() block may not reference array args") | |
} | |
break | |
case "scalar": | |
proc.scalarArgs.push(i) | |
proc.shimArgs.push("scalar" + i) | |
break | |
case "index": | |
proc.indexArgs.push(i) | |
if(i < proc.pre.args.length && proc.pre.args[i].count > 0) { | |
throw new Error("cwise: pre() block may not reference array index") | |
} | |
if(i < proc.body.args.length && proc.body.args[i].lvalue) { | |
throw new Error("cwise: body() block may not write to array index") | |
} | |
if(i < proc.post.args.length && proc.post.args[i].count > 0) { | |
throw new Error("cwise: post() block may not reference array index") | |
} | |
break | |
case "shape": | |
proc.shapeArgs.push(i) | |
if(i < proc.pre.args.length && proc.pre.args[i].lvalue) { | |
throw new Error("cwise: pre() block may not write to array shape") | |
} | |
if(i < proc.body.args.length && proc.body.args[i].lvalue) { | |
throw new Error("cwise: body() block may not write to array shape") | |
} | |
if(i < proc.post.args.length && proc.post.args[i].lvalue) { | |
throw new Error("cwise: post() block may not write to array shape") | |
} | |
break | |
default: | |
throw new Error("cwise: Unknown argument type " + proc_args[i]) | |
} | |
} | |
//Make sure at least one array argument was specified | |
if(proc.arrayArgs.length <= 0) { | |
throw new Error("cwise: No array arguments specified") | |
} | |
//Make sure arguments are correct | |
if(proc.pre.args.length > proc_args.length) { | |
throw new Error("cwise: Too many arguments in pre() block") | |
} | |
if(proc.body.args.length > proc_args.length) { | |
throw new Error("cwise: Too many arguments in body() block") | |
} | |
if(proc.post.args.length > proc_args.length) { | |
throw new Error("cwise: Too many arguments in post() block") | |
} | |
//Check debug flag | |
proc.debug = !!user_args.printCode || !!user_args.debug | |
//Retrieve name | |
proc.funcName = user_args.funcName || "cwise" | |
//Read in block size | |
proc.blockSize = user_args.blockSize || 64 | |
return createThunk(proc) | |
} | |
module.exports = compileCwise | |
},{"./lib/thunk.js":14}],13:[function(require,module,exports){ | |
"use strict" | |
var createThunk = require("./lib/thunk.js") | |
function Procedure() { | |
this.argTypes = [] | |
this.shimArgs = [] | |
this.arrayArgs = [] | |
this.scalarArgs = [] | |
this.indexArgs = [] | |
this.shapeArgs = [] | |
this.funcName = "" | |
this.pre = null | |
this.body = null | |
this.post = null | |
this.debug = false | |
} | |
function compileCwise(user_args) { | |
//Create procedure | |
var proc = new Procedure() | |
//Parse blocks | |
proc.pre = user_args.pre | |
proc.body = user_args.body | |
proc.post = user_args.post | |
//Parse arguments | |
var proc_args = user_args.args.slice(0) | |
proc.argTypes = proc_args | |
for(var i=0; i<proc_args.length; ++i) { | |
switch(proc_args[i]) { | |
case "array": | |
proc.arrayArgs.push(i) | |
proc.shimArgs.push("array" + i) | |
if(i < proc.pre.args.length && proc.pre.args[i].count>0) { | |
throw new Error("cwise: pre() block may not reference array args") | |
} | |
if(i < proc.post.args.length && proc.post.args[i].count>0) { | |
throw new Error("cwise: post() block may not reference array args") | |
} | |
break | |
case "scalar": | |
proc.scalarArgs.push(i) | |
proc.shimArgs.push("scalar" + i) | |
break | |
case "index": | |
proc.indexArgs.push(i) | |
if(i < proc.pre.args.length && proc.pre.args[i].count > 0) { | |
throw new Error("cwise: pre() block may not reference array index") | |
} | |
if(i < proc.body.args.length && proc.body.args[i].lvalue) { | |
throw new Error("cwise: body() block may not write to array index") | |
} | |
if(i < proc.post.args.length && proc.post.args[i].count > 0) { | |
throw new Error("cwise: post() block may not reference array index") | |
} | |
break | |
case "shape": | |
proc.shapeArgs.push(i) | |
if(i < proc.pre.args.length && proc.pre.args[i].lvalue) { | |
throw new Error("cwise: pre() block may not write to array shape") | |
} | |
if(i < proc.body.args.length && proc.body.args[i].lvalue) { | |
throw new Error("cwise: body() block may not write to array shape") | |
} | |
if(i < proc.post.args.length && proc.post.args[i].lvalue) { | |
throw new Error("cwise: post() block may not write to array shape") | |
} | |
break | |
default: | |
throw new Error("cwise: Unknown argument type " + proc_args[i]) | |
} | |
} | |
//Make sure at least one array argument was specified | |
if(proc.arrayArgs.length <= 0) { | |
throw new Error("cwise: No array arguments specified") | |
} | |
//Make sure arguments are correct | |
if(proc.pre.args.length > proc_args.length) { | |
throw new Error("cwise: Too many arguments in pre() block") | |
} | |
if(proc.body.args.length > proc_args.length) { | |
throw new Error("cwise: Too many arguments in body() block") | |
} | |
if(proc.post.args.length > proc_args.length) { | |
throw new Error("cwise: Too many arguments in post() block") | |
} | |
//Check debug flag | |
proc.debug = !!user_args.printCode || !!user_args.debug | |
//Retrieve name | |
proc.funcName = user_args.funcName || "cwise" | |
//Read in block size | |
proc.blockSize = user_args.blockSize || 64 | |
return createThunk(proc) | |
} | |
module.exports = compileCwise | |
},{"./lib/thunk.js":15}],9:[function(require,module,exports){ | |
"use strict" | |
var esprima = require("esprima") | |
var uniq = require("uniq") | |
var PREFIX_COUNTER = 0 | |
function CompiledArgument(name, lvalue, rvalue) { | |
this.name = name | |
this.lvalue = lvalue | |
this.rvalue = rvalue | |
this.count = 0 | |
} | |
function CompiledRoutine(body, args, thisVars, localVars) { | |
this.body = body | |
this.args = args | |
this.thisVars = thisVars | |
this.localVars = localVars | |
} | |
function isGlobal(identifier) { | |
if(identifier === "eval") { | |
throw new Error("cwise-parser: eval() not allowed") | |
} | |
if(typeof window !== "undefined") { | |
return identifier in window | |
} else if(typeof GLOBAL !== "undefined") { | |
return identifier in GLOBAL | |
} else if(typeof self !== "undefined") { | |
return identifier in self | |
} else { | |
return false | |
} | |
} | |
function getArgNames(ast) { | |
var params = ast.body[0].expression.callee.params | |
var names = new Array(params.length) | |
for(var i=0; i<params.length; ++i) { | |
names[i] = params[i].name | |
} | |
return names | |
} | |
function preprocess(func) { | |
var src = ["(", func, ")()"].join("") | |
var ast = esprima.parse(src, { range: true }) | |
//Compute new prefix | |
var prefix = "_inline_" + (PREFIX_COUNTER++) + "_" | |
//Parse out arguments | |
var argNames = getArgNames(ast) | |
var compiledArgs = new Array(argNames.length) | |
for(var i=0; i<argNames.length; ++i) { | |
compiledArgs[i] = new CompiledArgument([prefix, "arg", i, "_"].join(""), false, false) | |
} | |
//Create temporary data structure for source rewriting | |
var exploded = new Array(src.length) | |
for(var i=0, n=src.length; i<n; ++i) { | |
exploded[i] = src.charAt(i) | |
} | |
//Local variables | |
var localVars = [] | |
var thisVars = [] | |
var computedThis = false | |
//Retrieves a local variable | |
function createLocal(id) { | |
var nstr = prefix + id.replace(/\_/g, "__") | |
localVars.push(nstr) | |
return nstr | |
} | |
//Creates a this variable | |
function createThisVar(id) { | |
var nstr = "this_" + id.replace(/\_/g, "__") | |
thisVars.push(nstr) | |
return nstr | |
} | |
//Rewrites an ast node | |
function rewrite(node, nstr) { | |
var lo = node.range[0], hi = node.range[1] | |
for(var i=lo+1; i<hi; ++i) { | |
exploded[i] = "" | |
} | |
exploded[lo] = nstr | |
} | |
//Remove any underscores | |
function escapeString(str) { | |
return "'"+(str.replace(/\_/g, "\\_").replace(/\'/g, "\'"))+"'" | |
} | |
//Returns the source of an identifier | |
function source(node) { | |
return exploded.slice(node.range[0], node.range[1]).join("") | |
} | |
//Computes the usage of a node | |
var LVALUE = 1 | |
var RVALUE = 2 | |
function getUsage(node) { | |
if(node.parent.type === "AssignmentExpression") { | |
if(node.parent.left === node) { | |
if(node.parent.operator === "=") { | |
return LVALUE | |
} | |
return LVALUE|RVALUE | |
} | |
} | |
if(node.parent.type === "UpdateExpression") { | |
return LVALUE|RVALUE | |
} | |
return RVALUE | |
} | |
//Handle visiting a node | |
(function visit(node, parent) { | |
node.parent = parent | |
if(node.type === "MemberExpression") { | |
//Handle member expression | |
if(node.computed) { | |
visit(node.object, node) | |
visit(node.property, node) | |
} else if(node.object.type === "ThisExpression") { | |
rewrite(node, createThisVar(node.property.name)) | |
} else { | |
visit(node.object, node) | |
} | |
} else if(node.type === "ThisExpression") { | |
throw new Error("cwise-parser: Computed this is not allowed") | |
} else if(node.type === "Identifier") { | |
//Handle identifier | |
var name = node.name | |
var argNo = argNames.indexOf(name) | |
if(argNo >= 0) { | |
var carg = compiledArgs[argNo] | |
var usage = getUsage(node) | |
if(usage & LVALUE) { | |
carg.lvalue = true | |
} | |
if(usage & RVALUE) { | |
carg.rvalue = true | |
} | |
++carg.count | |
rewrite(node, carg.name) | |
} else if(isGlobal(name)) { | |
//Don't rewrite globals | |
} else { | |
rewrite(node, createLocal(name)) | |
} | |
} else if(node.type === "Literal") { | |
if(typeof node.value === "string") { | |
rewrite(node, escapeString(node.value)) | |
} | |
} else if(node.type === "WithStatement") { | |
throw new Error("cwise-parser: with() statements not allowed") | |
} else { | |
//Visit all children | |
var keys = Object.keys(node) | |
for(var i=0, n=keys.length; i<n; ++i) { | |
if(keys[i] === "parent") { | |
continue | |
} | |
var value = node[keys[i]] | |
if(value) { | |
if(value instanceof Array) { | |
for(var j=0; j<value.length; ++j) { | |
if(value[j] && typeof value[j].type === "string") { | |
visit(value[j], node) | |
} | |
} | |
} else if(typeof value.type === "string") { | |
visit(value, node) | |
} | |
} | |
} | |
} | |
})(ast.body[0].expression.callee.body, undefined) | |
//Remove duplicate variables | |
uniq(localVars) | |
uniq(thisVars) | |
//Return body | |
var routine = new CompiledRoutine(source(ast.body[0].expression.callee.body), compiledArgs, thisVars, localVars) | |
return routine | |
} | |
module.exports = preprocess | |
},{"esprima":16,"uniq":17}],12:[function(require,module,exports){ | |
"use strict" | |
var esprima = require("esprima") | |
var uniq = require("uniq") | |
var PREFIX_COUNTER = 0 | |
function CompiledArgument(name, lvalue, rvalue) { | |
this.name = name | |
this.lvalue = lvalue | |
this.rvalue = rvalue | |
this.count = 0 | |
} | |
function CompiledRoutine(body, args, thisVars, localVars) { | |
this.body = body | |
this.args = args | |
this.thisVars = thisVars | |
this.localVars = localVars | |
} | |
function isGlobal(identifier) { | |
if(identifier === "eval") { | |
throw new Error("cwise-parser: eval() not allowed") | |
} | |
if(typeof window !== "undefined") { | |
return identifier in window | |
} else if(typeof GLOBAL !== "undefined") { | |
return identifier in GLOBAL | |
} else if(typeof self !== "undefined") { | |
return identifier in self | |
} else { | |
return false | |
} | |
} | |
function getArgNames(ast) { | |
var params = ast.body[0].expression.callee.params | |
var names = new Array(params.length) | |
for(var i=0; i<params.length; ++i) { | |
names[i] = params[i].name | |
} | |
return names | |
} | |
function preprocess(func) { | |
var src = ["(", func, ")()"].join("") | |
var ast = esprima.parse(src, { range: true }) | |
//Compute new prefix | |
var prefix = "_inline_" + (PREFIX_COUNTER++) + "_" | |
//Parse out arguments | |
var argNames = getArgNames(ast) | |
var compiledArgs = new Array(argNames.length) | |
for(var i=0; i<argNames.length; ++i) { | |
compiledArgs[i] = new CompiledArgument([prefix, "arg", i, "_"].join(""), false, false) | |
} | |
//Create temporary data structure for source rewriting | |
var exploded = new Array(src.length) | |
for(var i=0, n=src.length; i<n; ++i) { | |
exploded[i] = src.charAt(i) | |
} | |
//Local variables | |
var localVars = [] | |
var thisVars = [] | |
var computedThis = false | |
//Retrieves a local variable | |
function createLocal(id) { | |
var nstr = prefix + id.replace(/\_/g, "__") | |
localVars.push(nstr) | |
return nstr | |
} | |
//Creates a this variable | |
function createThisVar(id) { | |
var nstr = "this_" + id.replace(/\_/g, "__") | |
thisVars.push(nstr) | |
return nstr | |
} | |
//Rewrites an ast node | |
function rewrite(node, nstr) { | |
var lo = node.range[0], hi = node.range[1] | |
for(var i=lo+1; i<hi; ++i) { | |
exploded[i] = "" | |
} | |
exploded[lo] = nstr | |
} | |
//Remove any underscores | |
function escapeString(str) { | |
return "'"+(str.replace(/\_/g, "\\_").replace(/\'/g, "\'"))+"'" | |
} | |
//Returns the source of an identifier | |
function source(node) { | |
return exploded.slice(node.range[0], node.range[1]).join("") | |
} | |
//Computes the usage of a node | |
var LVALUE = 1 | |
var RVALUE = 2 | |
function getUsage(node) { | |
if(node.parent.type === "AssignmentExpression") { | |
if(node.parent.left === node) { | |
if(node.parent.operator === "=") { | |
return LVALUE | |
} | |
return LVALUE|RVALUE | |
} | |
} | |
if(node.parent.type === "UpdateExpression") { | |
return LVALUE|RVALUE | |
} | |
return RVALUE | |
} | |
//Handle visiting a node | |
(function visit(node, parent) { | |
node.parent = parent | |
if(node.type === "MemberExpression") { | |
//Handle member expression | |
if(node.computed) { | |
visit(node.object, node) | |
visit(node.property, node) | |
} else if(node.object.type === "ThisExpression") { | |
rewrite(node, createThisVar(node.property.name)) | |
} else { | |
visit(node.object, node) | |
} | |
} else if(node.type === "ThisExpression") { | |
throw new Error("cwise-parser: Computed this is not allowed") | |
} else if(node.type === "Identifier") { | |
//Handle identifier | |
var name = node.name | |
var argNo = argNames.indexOf(name) | |
if(argNo >= 0) { | |
var carg = compiledArgs[argNo] | |
var usage = getUsage(node) | |
if(usage & LVALUE) { | |
carg.lvalue = true | |
} | |
if(usage & RVALUE) { | |
carg.rvalue = true | |
} | |
++carg.count | |
rewrite(node, carg.name) | |
} else if(isGlobal(name)) { | |
//Don't rewrite globals | |
} else { | |
rewrite(node, createLocal(name)) | |
} | |
} else if(node.type === "Literal") { | |
if(typeof node.value === "string") { | |
rewrite(node, escapeString(node.value)) | |
} | |
} else if(node.type === "WithStatement") { | |
throw new Error("cwise-parser: with() statements not allowed") | |
} else { | |
//Visit all children | |
var keys = Object.keys(node) | |
for(var i=0, n=keys.length; i<n; ++i) { | |
if(keys[i] === "parent") { | |
continue | |
} | |
var value = node[keys[i]] | |
if(value) { | |
if(value instanceof Array) { | |
for(var j=0; j<value.length; ++j) { | |
if(value[j] && typeof value[j].type === "string") { | |
visit(value[j], node) | |
} | |
} | |
} else if(typeof value.type === "string") { | |
visit(value, node) | |
} | |
} | |
} | |
} | |
})(ast.body[0].expression.callee.body, undefined) | |
//Remove duplicate variables | |
uniq(localVars) | |
uniq(thisVars) | |
//Return body | |
var routine = new CompiledRoutine(source(ast.body[0].expression.callee.body), compiledArgs, thisVars, localVars) | |
return routine | |
} | |
module.exports = preprocess | |
},{"esprima":18,"uniq":19}],14:[function(require,module,exports){ | |
"use strict" | |
var compile = require("./compile.js") | |
function createThunk(proc) { | |
var code = ["'use strict'", "var CACHED={}"] | |
var vars = [] | |
var thunkName = proc.funcName + "_cwise_thunk" | |
//Build thunk | |
code.push(["return function ", thunkName, "(", proc.shimArgs.join(","), "){"].join("")) | |
var typesig = [] | |
var string_typesig = [] | |
var proc_args = [["array",proc.arrayArgs[0],".shape"].join("")] | |
for(var i=0; i<proc.arrayArgs.length; ++i) { | |
var j = proc.arrayArgs[i] | |
vars.push(["t", j, "=array", j, ".dtype,", | |
"r", j, "=array", j, ".order"].join("")) | |
typesig.push("t" + j) | |
typesig.push("r" + j) | |
string_typesig.push("t"+j) | |
string_typesig.push("r"+j+".join()") | |
proc_args.push("array" + j + ".data") | |
proc_args.push("array" + j + ".stride") | |
proc_args.push("array" + j + ".offset|0") | |
} | |
for(var i=0; i<proc.scalarArgs.length; ++i) { | |
proc_args.push("scalar" + proc.scalarArgs[i]) | |
} | |
vars.push(["type=[", string_typesig.join(","), "].join()"].join("")) | |
vars.push("proc=CACHED[type]") | |
code.push("var " + vars.join(",")) | |
code.push(["if(!proc){", | |
"CACHED[type]=proc=compile([", typesig.join(","), "])}", | |
"return proc(", proc_args.join(","), ")}"].join("")) | |
if(proc.debug) { | |
console.log("Generated thunk:", code.join("\n")) | |
} | |
//Compile thunk | |
var thunk = new Function("compile", code.join("\n")) | |
return thunk(compile.bind(undefined, proc)) | |
} | |
module.exports = createThunk | |
},{"./compile.js":20}],16:[function(require,module,exports){ | |
(function(){/* | |
Copyright (C) 2012 Ariya Hidayat <[email protected]> | |
Copyright (C) 2012 Mathias Bynens <[email protected]> | |
Copyright (C) 2012 Joost-Wim Boekesteijn <[email protected]> | |
Copyright (C) 2012 Kris Kowal <[email protected]> | |
Copyright (C) 2012 Yusuke Suzuki <[email protected]> | |
Copyright (C) 2012 Arpad Borsos <[email protected]> | |
Copyright (C) 2011 Ariya Hidayat <[email protected]> | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions are met: | |
* Redistributions of source code must retain the above copyright | |
notice, this list of conditions and the following disclaimer. | |
* Redistributions in binary form must reproduce the above copyright | |
notice, this list of conditions and the following disclaimer in the | |
documentation and/or other materials provided with the distribution. | |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY | |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
*/ | |
/*jslint bitwise:true plusplus:true */ | |
/*global esprima:true, define:true, exports:true, window: true, | |
throwError: true, createLiteral: true, generateStatement: true, | |
parseAssignmentExpression: true, parseBlock: true, parseExpression: true, | |
parseFunctionDeclaration: true, parseFunctionExpression: true, | |
parseFunctionSourceElements: true, parseVariableIdentifier: true, | |
parseLeftHandSideExpression: true, | |
parseStatement: true, parseSourceElement: true */ | |
(function (root, factory) { | |
'use strict'; | |
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, | |
// Rhino, and plain browser loading. | |
if (typeof define === 'function' && define.amd) { | |
define(['exports'], factory); | |
} else if (typeof exports !== 'undefined') { | |
factory(exports); | |
} else { | |
factory((root.esprima = {})); | |
} | |
}(this, function (exports) { | |
'use strict'; | |
var Token, | |
TokenName, | |
Syntax, | |
PropertyKind, | |
Messages, | |
Regex, | |
source, | |
strict, | |
index, | |
lineNumber, | |
lineStart, | |
length, | |
buffer, | |
state, | |
extra; | |
Token = { | |
BooleanLiteral: 1, | |
EOF: 2, | |
Identifier: 3, | |
Keyword: 4, | |
NullLiteral: 5, | |
NumericLiteral: 6, | |
Punctuator: 7, | |
StringLiteral: 8 | |
}; | |
TokenName = {}; | |
TokenName[Token.BooleanLiteral] = 'Boolean'; | |
TokenName[Token.EOF] = '<end>'; | |
TokenName[Token.Identifier] = 'Identifier'; | |
TokenName[Token.Keyword] = 'Keyword'; | |
TokenName[Token.NullLiteral] = 'Null'; | |
TokenName[Token.NumericLiteral] = 'Numeric'; | |
TokenName[Token.Punctuator] = 'Punctuator'; | |
TokenName[Token.StringLiteral] = 'String'; | |
Syntax = { | |
AssignmentExpression: 'AssignmentExpression', | |
ArrayExpression: 'ArrayExpression', | |
BlockStatement: 'BlockStatement', | |
BinaryExpression: 'BinaryExpression', | |
BreakStatement: 'BreakStatement', | |
CallExpression: 'CallExpression', | |
CatchClause: 'CatchClause', | |
ConditionalExpression: 'ConditionalExpression', | |
ContinueStatement: 'ContinueStatement', | |
DoWhileStatement: 'DoWhileStatement', | |
DebuggerStatement: 'DebuggerStatement', | |
EmptyStatement: 'EmptyStatement', | |
ExpressionStatement: 'ExpressionStatement', | |
ForStatement: 'ForStatement', | |
ForInStatement: 'ForInStatement', | |
FunctionDeclaration: 'FunctionDeclaration', | |
FunctionExpression: 'FunctionExpression', | |
Identifier: 'Identifier', | |
IfStatement: 'IfStatement', | |
Literal: 'Literal', | |
LabeledStatement: 'LabeledStatement', | |
LogicalExpression: 'LogicalExpression', | |
MemberExpression: 'MemberExpression', | |
NewExpression: 'NewExpression', | |
ObjectExpression: 'ObjectExpression', | |
Program: 'Program', | |
Property: 'Property', | |
ReturnStatement: 'ReturnStatement', | |
SequenceExpression: 'SequenceExpression', | |
SwitchStatement: 'SwitchStatement', | |
SwitchCase: 'SwitchCase', | |
ThisExpression: 'ThisExpression', | |
ThrowStatement: 'ThrowStatement', | |
TryStatement: 'TryStatement', | |
UnaryExpression: 'UnaryExpression', | |
UpdateExpression: 'UpdateExpression', | |
VariableDeclaration: 'VariableDeclaration', | |
VariableDeclarator: 'VariableDeclarator', | |
WhileStatement: 'WhileStatement', | |
WithStatement: 'WithStatement' | |
}; | |
PropertyKind = { | |
Data: 1, | |
Get: 2, | |
Set: 4 | |
}; | |
// Error messages should be identical to V8. | |
Messages = { | |
UnexpectedToken: 'Unexpected token %0', | |
UnexpectedNumber: 'Unexpected number', | |
UnexpectedString: 'Unexpected string', | |
UnexpectedIdentifier: 'Unexpected identifier', | |
UnexpectedReserved: 'Unexpected reserved word', | |
UnexpectedEOS: 'Unexpected end of input', | |
NewlineAfterThrow: 'Illegal newline after throw', | |
InvalidRegExp: 'Invalid regular expression', | |
UnterminatedRegExp: 'Invalid regular expression: missing /', | |
InvalidLHSInAssignment: 'Invalid left-hand side in assignment', | |
InvalidLHSInForIn: 'Invalid left-hand side in for-in', | |
MultipleDefaultsInSwitch: 'More than one default clause in switch statement', | |
NoCatchOrFinally: 'Missing catch or finally after try', | |
UnknownLabel: 'Undefined label \'%0\'', | |
Redeclaration: '%0 \'%1\' has already been declared', | |
IllegalContinue: 'Illegal continue statement', | |
IllegalBreak: 'Illegal break statement', | |
IllegalReturn: 'Illegal return statement', | |
StrictModeWith: 'Strict mode code may not include a with statement', | |
StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode', | |
StrictVarName: 'Variable name may not be eval or arguments in strict mode', | |
StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode', | |
StrictParamDupe: 'Strict mode function may not have duplicate parameter names', | |
StrictFunctionName: 'Function name may not be eval or arguments in strict mode', | |
StrictOctalLiteral: 'Octal literals are not allowed in strict mode.', | |
StrictDelete: 'Delete of an unqualified identifier in strict mode.', | |
StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode', | |
AccessorDataProperty: 'Object literal may not have data and accessor property with the same name', | |
AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name', | |
StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode', | |
StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode', | |
StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode', | |
StrictReservedWord: 'Use of future reserved word in strict mode' | |
}; | |
// See also tools/generate-unicode-regex.py. | |
Regex = { | |
NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'), | |
NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab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e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]') | |
}; | |
// Ensure the condition is true, otherwise throw an error. | |
// This is only to have a better contract semantic, i.e. another safety net | |
// to catch a logic error. The condition shall be fulfilled in normal case. | |
// Do NOT use this to enforce a certain condition on any user input. | |
function assert(condition, message) { | |
if (!condition) { | |
throw new Error('ASSERT: ' + message); | |
} | |
} | |
function sliceSource(from, to) { | |
return source.slice(from, to); | |
} | |
if (typeof 'esprima'[0] === 'undefined') { | |
sliceSource = function sliceArraySource(from, to) { | |
return source.slice(from, to).join(''); | |
}; | |
} | |
function isDecimalDigit(ch) { | |
return '0123456789'.indexOf(ch) >= 0; | |
} | |
function isHexDigit(ch) { | |
return '0123456789abcdefABCDEF'.indexOf(ch) >= 0; | |
} | |
function isOctalDigit(ch) { | |
return '01234567'.indexOf(ch) >= 0; | |
} | |
// 7.2 White Space | |
function isWhiteSpace(ch) { | |
return (ch === ' ') || (ch === '\u0009') || (ch === '\u000B') || | |
(ch === '\u000C') || (ch === '\u00A0') || | |
(ch.charCodeAt(0) >= 0x1680 && | |
'\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'.indexOf(ch) >= 0); | |
} | |
// 7.3 Line Terminators | |
function isLineTerminator(ch) { | |
return (ch === '\n' || ch === '\r' || ch === '\u2028' || ch === '\u2029'); | |
} | |
// 7.6 Identifier Names and Identifiers | |
function isIdentifierStart(ch) { | |
return (ch === '$') || (ch === '_') || (ch === '\\') || | |
(ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || | |
((ch.charCodeAt(0) >= 0x80) && Regex.NonAsciiIdentifierStart.test(ch)); | |
} | |
function isIdentifierPart(ch) { | |
return (ch === '$') || (ch === '_') || (ch === '\\') || | |
(ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || | |
((ch >= '0') && (ch <= '9')) || | |
((ch.charCodeAt(0) >= 0x80) && Regex.NonAsciiIdentifierPart.test(ch)); | |
} | |
// 7.6.1.2 Future Reserved Words | |
function isFutureReservedWord(id) { | |
switch (id) { | |
// Future reserved words. | |
case 'class': | |
case 'enum': | |
case 'export': | |
case 'extends': | |
case 'import': | |
case 'super': | |
return true; | |
} | |
return false; | |
} | |
function isStrictModeReservedWord(id) { | |
switch (id) { | |
// Strict Mode reserved words. | |
case 'implements': | |
case 'interface': | |
case 'package': | |
case 'private': | |
case 'protected': | |
case 'public': | |
case 'static': | |
case 'yield': | |
case 'let': | |
return true; | |
} | |
return false; | |
} | |
function isRestrictedWord(id) { | |
return id === 'eval' || id === 'arguments'; | |
} | |
// 7.6.1.1 Keywords | |
function isKeyword(id) { | |
var keyword = false; | |
switch (id.length) { | |
case 2: | |
keyword = (id === 'if') || (id === 'in') || (id === 'do'); | |
break; | |
case 3: | |
keyword = (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try'); | |
break; | |
case 4: | |
keyword = (id === 'this') || (id === 'else') || (id === 'case') || (id === 'void') || (id === 'with'); | |
break; | |
case 5: | |
keyword = (id === 'while') || (id === 'break') || (id === 'catch') || (id === 'throw'); | |
break; | |
case 6: | |
keyword = (id === 'return') || (id === 'typeof') || (id === 'delete') || (id === 'switch'); | |
break; | |
case 7: | |
keyword = (id === 'default') || (id === 'finally'); | |
break; | |
case 8: | |
keyword = (id === 'function') || (id === 'continue') || (id === 'debugger'); | |
break; | |
case 10: | |
keyword = (id === 'instanceof'); | |
break; | |
} | |
if (keyword) { | |
return true; | |
} | |
switch (id) { | |
// Future reserved words. | |
// 'const' is specialized as Keyword in V8. | |
case 'const': | |
return true; | |
// For compatiblity to SpiderMonkey and ES.next | |
case 'yield': | |
case 'let': | |
return true; | |
} | |
if (strict && isStrictModeReservedWord(id)) { | |
return true; | |
} | |
return isFutureReservedWord(id); | |
} | |
// 7.4 Comments | |
function skipComment() { | |
var ch, blockComment, lineComment; | |
blockComment = false; | |
lineComment = false; | |
while (index < length) { | |
ch = source[index]; | |
if (lineComment) { | |
ch = source[index++]; | |
if (isLineTerminator(ch)) { | |
lineComment = false; | |
if (ch === '\r' && source[index] === '\n') { | |
++index; | |
} | |
++lineNumber; | |
lineStart = index; | |
} | |
} else if (blockComment) { | |
if (isLineTerminator(ch)) { | |
if (ch === '\r' && source[index + 1] === '\n') { | |
++index; | |
} | |
++lineNumber; | |
++index; | |
lineStart = index; | |
if (index >= length) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} else { | |
ch = source[index++]; | |
if (index >= length) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
if (ch === '*') { | |
ch = source[index]; | |
if (ch === '/') { | |
++index; | |
blockComment = false; | |
} | |
} | |
} | |
} else if (ch === '/') { | |
ch = source[index + 1]; | |
if (ch === '/') { | |
index += 2; | |
lineComment = true; | |
} else if (ch === '*') { | |
index += 2; | |
blockComment = true; | |
if (index >= length) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} else { | |
break; | |
} | |
} else if (isWhiteSpace(ch)) { | |
++index; | |
} else if (isLineTerminator(ch)) { | |
++index; | |
if (ch === '\r' && source[index] === '\n') { | |
++index; | |
} | |
++lineNumber; | |
lineStart = index; | |
} else { | |
break; | |
} | |
} | |
} | |
function scanHexEscape(prefix) { | |
var i, len, ch, code = 0; | |
len = (prefix === 'u') ? 4 : 2; | |
for (i = 0; i < len; ++i) { | |
if (index < length && isHexDigit(source[index])) { | |
ch = source[index++]; | |
code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase()); | |
} else { | |
return ''; | |
} | |
} | |
return String.fromCharCode(code); | |
} | |
function scanIdentifier() { | |
var ch, start, id, restore; | |
ch = source[index]; | |
if (!isIdentifierStart(ch)) { | |
return; | |
} | |
start = index; | |
if (ch === '\\') { | |
++index; | |
if (source[index] !== 'u') { | |
return; | |
} | |
++index; | |
restore = index; | |
ch = scanHexEscape('u'); | |
if (ch) { | |
if (ch === '\\' || !isIdentifierStart(ch)) { | |
return; | |
} | |
id = ch; | |
} else { | |
index = restore; | |
id = 'u'; | |
} | |
} else { | |
id = source[index++]; | |
} | |
while (index < length) { | |
ch = source[index]; | |
if (!isIdentifierPart(ch)) { | |
break; | |
} | |
if (ch === '\\') { | |
++index; | |
if (source[index] !== 'u') { | |
return; | |
} | |
++index; | |
restore = index; | |
ch = scanHexEscape('u'); | |
if (ch) { | |
if (ch === '\\' || !isIdentifierPart(ch)) { | |
return; | |
} | |
id += ch; | |
} else { | |
index = restore; | |
id += 'u'; | |
} | |
} else { | |
id += source[index++]; | |
} | |
} | |
// There is no keyword or literal with only one character. | |
// Thus, it must be an identifier. | |
if (id.length === 1) { | |
return { | |
type: Token.Identifier, | |
value: id, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (isKeyword(id)) { | |
return { | |
type: Token.Keyword, | |
value: id, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// 7.8.1 Null Literals | |
if (id === 'null') { | |
return { | |
type: Token.NullLiteral, | |
value: id, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// 7.8.2 Boolean Literals | |
if (id === 'true' || id === 'false') { | |
return { | |
type: Token.BooleanLiteral, | |
value: id, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
return { | |
type: Token.Identifier, | |
value: id, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// 7.7 Punctuators | |
function scanPunctuator() { | |
var start = index, | |
ch1 = source[index], | |
ch2, | |
ch3, | |
ch4; | |
// Check for most common single-character punctuators. | |
if (ch1 === ';' || ch1 === '{' || ch1 === '}') { | |
++index; | |
return { | |
type: Token.Punctuator, | |
value: ch1, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (ch1 === ',' || ch1 === '(' || ch1 === ')') { | |
++index; | |
return { | |
type: Token.Punctuator, | |
value: ch1, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// Dot (.) can also start a floating-point number, hence the need | |
// to check the next character. | |
ch2 = source[index + 1]; | |
if (ch1 === '.' && !isDecimalDigit(ch2)) { | |
return { | |
type: Token.Punctuator, | |
value: source[index++], | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// Peek more characters. | |
ch3 = source[index + 2]; | |
ch4 = source[index + 3]; | |
// 4-character punctuator: >>>= | |
if (ch1 === '>' && ch2 === '>' && ch3 === '>') { | |
if (ch4 === '=') { | |
index += 4; | |
return { | |
type: Token.Punctuator, | |
value: '>>>=', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
} | |
// 3-character punctuators: === !== >>> <<= >>= | |
if (ch1 === '=' && ch2 === '=' && ch3 === '=') { | |
index += 3; | |
return { | |
type: Token.Punctuator, | |
value: '===', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (ch1 === '!' && ch2 === '=' && ch3 === '=') { | |
index += 3; | |
return { | |
type: Token.Punctuator, | |
value: '!==', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (ch1 === '>' && ch2 === '>' && ch3 === '>') { | |
index += 3; | |
return { | |
type: Token.Punctuator, | |
value: '>>>', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (ch1 === '<' && ch2 === '<' && ch3 === '=') { | |
index += 3; | |
return { | |
type: Token.Punctuator, | |
value: '<<=', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (ch1 === '>' && ch2 === '>' && ch3 === '=') { | |
index += 3; | |
return { | |
type: Token.Punctuator, | |
value: '>>=', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// 2-character punctuators: <= >= == != ++ -- << >> && || | |
// += -= *= %= &= |= ^= /= | |
if (ch2 === '=') { | |
if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) { | |
index += 2; | |
return { | |
type: Token.Punctuator, | |
value: ch1 + ch2, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
} | |
if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0)) { | |
if ('+-<>&|'.indexOf(ch2) >= 0) { | |
index += 2; | |
return { | |
type: Token.Punctuator, | |
value: ch1 + ch2, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
} | |
// The remaining 1-character punctuators. | |
if ('[]<>+-*%&|^!~?:=/'.indexOf(ch1) >= 0) { | |
return { | |
type: Token.Punctuator, | |
value: source[index++], | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
} | |
// 7.8.3 Numeric Literals | |
function scanNumericLiteral() { | |
var number, start, ch; | |
ch = source[index]; | |
assert(isDecimalDigit(ch) || (ch === '.'), | |
'Numeric literal must start with a decimal digit or a decimal point'); | |
start = index; | |
number = ''; | |
if (ch !== '.') { | |
number = source[index++]; | |
ch = source[index]; | |
// Hex number starts with '0x'. | |
// Octal number starts with '0'. | |
if (number === '0') { | |
if (ch === 'x' || ch === 'X') { | |
number += source[index++]; | |
while (index < length) { | |
ch = source[index]; | |
if (!isHexDigit(ch)) { | |
break; | |
} | |
number += source[index++]; | |
} | |
if (number.length <= 2) { | |
// only 0x | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
if (index < length) { | |
ch = source[index]; | |
if (isIdentifierStart(ch)) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} | |
return { | |
type: Token.NumericLiteral, | |
value: parseInt(number, 16), | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} else if (isOctalDigit(ch)) { | |
number += source[index++]; | |
while (index < length) { | |
ch = source[index]; | |
if (!isOctalDigit(ch)) { | |
break; | |
} | |
number += source[index++]; | |
} | |
if (index < length) { | |
ch = source[index]; | |
if (isIdentifierStart(ch) || isDecimalDigit(ch)) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} | |
return { | |
type: Token.NumericLiteral, | |
value: parseInt(number, 8), | |
octal: true, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// decimal number starts with '0' such as '09' is illegal. | |
if (isDecimalDigit(ch)) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} | |
while (index < length) { | |
ch = source[index]; | |
if (!isDecimalDigit(ch)) { | |
break; | |
} | |
number += source[index++]; | |
} | |
} | |
if (ch === '.') { | |
number += source[index++]; | |
while (index < length) { | |
ch = source[index]; | |
if (!isDecimalDigit(ch)) { | |
break; | |
} | |
number += source[index++]; | |
} | |
} | |
if (ch === 'e' || ch === 'E') { | |
number += source[index++]; | |
ch = source[index]; | |
if (ch === '+' || ch === '-') { | |
number += source[index++]; | |
} | |
ch = source[index]; | |
if (isDecimalDigit(ch)) { | |
number += source[index++]; | |
while (index < length) { | |
ch = source[index]; | |
if (!isDecimalDigit(ch)) { | |
break; | |
} | |
number += source[index++]; | |
} | |
} else { | |
ch = 'character ' + ch; | |
if (index >= length) { | |
ch = '<end>'; | |
} | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} | |
if (index < length) { | |
ch = source[index]; | |
if (isIdentifierStart(ch)) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} | |
return { | |
type: Token.NumericLiteral, | |
value: parseFloat(number), | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// 7.8.4 String Literals | |
function scanStringLiteral() { | |
var str = '', quote, start, ch, code, unescaped, restore, octal = false; | |
quote = source[index]; | |
assert((quote === '\'' || quote === '"'), | |
'String literal must starts with a quote'); | |
start = index; | |
++index; | |
while (index < length) { | |
ch = source[index++]; | |
if (ch === quote) { | |
quote = ''; | |
break; | |
} else if (ch === '\\') { | |
ch = source[index++]; | |
if (!isLineTerminator(ch)) { | |
switch (ch) { | |
case 'n': | |
str += '\n'; | |
break; | |
case 'r': | |
str += '\r'; | |
break; | |
case 't': | |
str += '\t'; | |
break; | |
case 'u': | |
case 'x': | |
restore = index; | |
unescaped = scanHexEscape(ch); | |
if (unescaped) { | |
str += unescaped; | |
} else { | |
index = restore; | |
str += ch; | |
} | |
break; | |
case 'b': | |
str += '\b'; | |
break; | |
case 'f': | |
str += '\f'; | |
break; | |
case 'v': | |
str += '\x0B'; | |
break; | |
default: | |
if (isOctalDigit(ch)) { | |
code = '01234567'.indexOf(ch); | |
// \0 is not octal escape sequence | |
if (code !== 0) { | |
octal = true; | |
} | |
if (index < length && isOctalDigit(source[index])) { | |
octal = true; | |
code = code * 8 + '01234567'.indexOf(source[index++]); | |
// 3 digits are only allowed when string starts | |
// with 0, 1, 2, 3 | |
if ('0123'.indexOf(ch) >= 0 && | |
index < length && | |
isOctalDigit(source[index])) { | |
code = code * 8 + '01234567'.indexOf(source[index++]); | |
} | |
} | |
str += String.fromCharCode(code); | |
} else { | |
str += ch; | |
} | |
break; | |
} | |
} else { | |
++lineNumber; | |
if (ch === '\r' && source[index] === '\n') { | |
++index; | |
} | |
} | |
} else if (isLineTerminator(ch)) { | |
break; | |
} else { | |
str += ch; | |
} | |
} | |
if (quote !== '') { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
return { | |
type: Token.StringLiteral, | |
value: str, | |
octal: octal, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
function scanRegExp() { | |
var str, ch, start, pattern, flags, value, classMarker = false, restore, terminated = false; | |
buffer = null; | |
skipComment(); | |
start = index; | |
ch = source[index]; | |
assert(ch === '/', 'Regular expression literal must start with a slash'); | |
str = source[index++]; | |
while (index < length) { | |
ch = source[index++]; | |
str += ch; | |
if (ch === '\\') { | |
ch = source[index++]; | |
// ECMA-262 7.8.5 | |
if (isLineTerminator(ch)) { | |
throwError({}, Messages.UnterminatedRegExp); | |
} | |
str += ch; | |
} else if (classMarker) { | |
if (ch === ']') { | |
classMarker = false; | |
} | |
} else { | |
if (ch === '/') { | |
terminated = true; | |
break; | |
} else if (ch === '[') { | |
classMarker = true; | |
} else if (isLineTerminator(ch)) { | |
throwError({}, Messages.UnterminatedRegExp); | |
} | |
} | |
} | |
if (!terminated) { | |
throwError({}, Messages.UnterminatedRegExp); | |
} | |
// Exclude leading and trailing slash. | |
pattern = str.substr(1, str.length - 2); | |
flags = ''; | |
while (index < length) { | |
ch = source[index]; | |
if (!isIdentifierPart(ch)) { | |
break; | |
} | |
++index; | |
if (ch === '\\' && index < length) { | |
ch = source[index]; | |
if (ch === 'u') { | |
++index; | |
restore = index; | |
ch = scanHexEscape('u'); | |
if (ch) { | |
flags += ch; | |
str += '\\u'; | |
for (; restore < index; ++restore) { | |
str += source[restore]; | |
} | |
} else { | |
index = restore; | |
flags += 'u'; | |
str += '\\u'; | |
} | |
} else { | |
str += '\\'; | |
} | |
} else { | |
flags += ch; | |
str += ch; | |
} | |
} | |
try { | |
value = new RegExp(pattern, flags); | |
} catch (e) { | |
throwError({}, Messages.InvalidRegExp); | |
} | |
return { | |
literal: str, | |
value: value, | |
range: [start, index] | |
}; | |
} | |
function isIdentifierName(token) { | |
return token.type === Token.Identifier || | |
token.type === Token.Keyword || | |
token.type === Token.BooleanLiteral || | |
token.type === Token.NullLiteral; | |
} | |
function advance() { | |
var ch, token; | |
skipComment(); | |
if (index >= length) { | |
return { | |
type: Token.EOF, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [index, index] | |
}; | |
} | |
token = scanPunctuator(); | |
if (typeof token !== 'undefined') { | |
return token; | |
} | |
ch = source[index]; | |
if (ch === '\'' || ch === '"') { | |
return scanStringLiteral(); | |
} | |
if (ch === '.' || isDecimalDigit(ch)) { | |
return scanNumericLiteral(); | |
} | |
token = scanIdentifier(); | |
if (typeof token !== 'undefined') { | |
return token; | |
} | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
function lex() { | |
var token; | |
if (buffer) { | |
index = buffer.range[1]; | |
lineNumber = buffer.lineNumber; | |
lineStart = buffer.lineStart; | |
token = buffer; | |
buffer = null; | |
return token; | |
} | |
buffer = null; | |
return advance(); | |
} | |
function lookahead() { | |
var pos, line, start; | |
if (buffer !== null) { | |
return buffer; | |
} | |
pos = index; | |
line = lineNumber; | |
start = lineStart; | |
buffer = advance(); | |
index = pos; | |
lineNumber = line; | |
lineStart = start; | |
return buffer; | |
} | |
// Return true if there is a line terminator before the next token. | |
function peekLineTerminator() { | |
var pos, line, start, found; | |
pos = index; | |
line = lineNumber; | |
start = lineStart; | |
skipComment(); | |
found = lineNumber !== line; | |
index = pos; | |
lineNumber = line; | |
lineStart = start; | |
return found; | |
} | |
// Throw an exception | |
function throwError(token, messageFormat) { | |
var error, | |
args = Array.prototype.slice.call(arguments, 2), | |
msg = messageFormat.replace( | |
/%(\d)/g, | |
function (whole, index) { | |
return args[index] || ''; | |
} | |
); | |
if (typeof token.lineNumber === 'number') { | |
error = new Error('Line ' + token.lineNumber + ': ' + msg); | |
error.index = token.range[0]; | |
error.lineNumber = token.lineNumber; | |
error.column = token.range[0] - lineStart + 1; | |
} else { | |
error = new Error('Line ' + lineNumber + ': ' + msg); | |
error.index = index; | |
error.lineNumber = lineNumber; | |
error.column = index - lineStart + 1; | |
} | |
throw error; | |
} | |
function throwErrorTolerant() { | |
try { | |
throwError.apply(null, arguments); | |
} catch (e) { | |
if (extra.errors) { | |
extra.errors.push(e); | |
} else { | |
throw e; | |
} | |
} | |
} | |
// Throw an exception because of the token. | |
function throwUnexpected(token) { | |
if (token.type === Token.EOF) { | |
throwError(token, Messages.UnexpectedEOS); | |
} | |
if (token.type === Token.NumericLiteral) { | |
throwError(token, Messages.UnexpectedNumber); | |
} | |
if (token.type === Token.StringLiteral) { | |
throwError(token, Messages.UnexpectedString); | |
} | |
if (token.type === Token.Identifier) { | |
throwError(token, Messages.UnexpectedIdentifier); | |
} | |
if (token.type === Token.Keyword) { | |
if (isFutureReservedWord(token.value)) { | |
throwError(token, Messages.UnexpectedReserved); | |
} else if (strict && isStrictModeReservedWord(token.value)) { | |
throwErrorTolerant(token, Messages.StrictReservedWord); | |
return; | |
} | |
throwError(token, Messages.UnexpectedToken, token.value); | |
} | |
// BooleanLiteral, NullLiteral, or Punctuator. | |
throwError(token, Messages.UnexpectedToken, token.value); | |
} | |
// Expect the next token to match the specified punctuator. | |
// If not, an exception will be thrown. | |
function expect(value) { | |
var token = lex(); | |
if (token.type !== Token.Punctuator || token.value !== value) { | |
throwUnexpected(token); | |
} | |
} | |
// Expect the next token to match the specified keyword. | |
// If not, an exception will be thrown. | |
function expectKeyword(keyword) { | |
var token = lex(); | |
if (token.type !== Token.Keyword || token.value !== keyword) { | |
throwUnexpected(token); | |
} | |
} | |
// Return true if the next token matches the specified punctuator. | |
function match(value) { | |
var token = lookahead(); | |
return token.type === Token.Punctuator && token.value === value; | |
} | |
// Return true if the next token matches the specified keyword | |
function matchKeyword(keyword) { | |
var token = lookahead(); | |
return token.type === Token.Keyword && token.value === keyword; | |
} | |
// Return true if the next token is an assignment operator | |
function matchAssign() { | |
var token = lookahead(), | |
op = token.value; | |
if (token.type !== Token.Punctuator) { | |
return false; | |
} | |
return op === '=' || | |
op === '*=' || | |
op === '/=' || | |
op === '%=' || | |
op === '+=' || | |
op === '-=' || | |
op === '<<=' || | |
op === '>>=' || | |
op === '>>>=' || | |
op === '&=' || | |
op === '^=' || | |
op === '|='; | |
} | |
function consumeSemicolon() { | |
var token, line; | |
// Catch the very common case first. | |
if (source[index] === ';') { | |
lex(); | |
return; | |
} | |
line = lineNumber; | |
skipComment(); | |
if (lineNumber !== line) { | |
return; | |
} | |
if (match(';')) { | |
lex(); | |
return; | |
} | |
token = lookahead(); | |
if (token.type !== Token.EOF && !match('}')) { | |
throwUnexpected(token); | |
} | |
} | |
// Return true if provided expression is LeftHandSideExpression | |
function isLeftHandSide(expr) { | |
return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression; | |
} | |
// 11.1.4 Array Initialiser | |
function parseArrayInitialiser() { | |
var elements = []; | |
expect('['); | |
while (!match(']')) { | |
if (match(',')) { | |
lex(); | |
elements.push(null); | |
} else { | |
elements.push(parseAssignmentExpression()); | |
if (!match(']')) { | |
expect(','); | |
} | |
} | |
} | |
expect(']'); | |
return { | |
type: Syntax.ArrayExpression, | |
elements: elements | |
}; | |
} | |
// 11.1.5 Object Initialiser | |
function parsePropertyFunction(param, first) { | |
var previousStrict, body; | |
previousStrict = strict; | |
body = parseFunctionSourceElements(); | |
if (first && strict && isRestrictedWord(param[0].name)) { | |
throwErrorTolerant(first, Messages.StrictParamName); | |
} | |
strict = previousStrict; | |
return { | |
type: Syntax.FunctionExpression, | |
id: null, | |
params: param, | |
defaults: [], | |
body: body, | |
rest: null, | |
generator: false, | |
expression: false | |
}; | |
} | |
function parseObjectPropertyKey() { | |
var token = lex(); | |
// Note: This function is called only from parseObjectProperty(), where | |
// EOF and Punctuator tokens are already filtered out. | |
if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) { | |
if (strict && token.octal) { | |
throwErrorTolerant(token, Messages.StrictOctalLiteral); | |
} | |
return createLiteral(token); | |
} | |
return { | |
type: Syntax.Identifier, | |
name: token.value | |
}; | |
} | |
function parseObjectProperty() { | |
var token, key, id, param; | |
token = lookahead(); | |
if (token.type === Token.Identifier) { | |
id = parseObjectPropertyKey(); | |
// Property Assignment: Getter and Setter. | |
if (token.value === 'get' && !match(':')) { | |
key = parseObjectPropertyKey(); | |
expect('('); | |
expect(')'); | |
return { | |
type: Syntax.Property, | |
key: key, | |
value: parsePropertyFunction([]), | |
kind: 'get' | |
}; | |
} else if (token.value === 'set' && !match(':')) { | |
key = parseObjectPropertyKey(); | |
expect('('); | |
token = lookahead(); | |
if (token.type !== Token.Identifier) { | |
expect(')'); | |
throwErrorTolerant(token, Messages.UnexpectedToken, token.value); | |
return { | |
type: Syntax.Property, | |
key: key, | |
value: parsePropertyFunction([]), | |
kind: 'set' | |
}; | |
} else { | |
param = [ parseVariableIdentifier() ]; | |
expect(')'); | |
return { | |
type: Syntax.Property, | |
key: key, | |
value: parsePropertyFunction(param, token), | |
kind: 'set' | |
}; | |
} | |
} else { | |
expect(':'); | |
return { | |
type: Syntax.Property, | |
key: id, | |
value: parseAssignmentExpression(), | |
kind: 'init' | |
}; | |
} | |
} else if (token.type === Token.EOF || token.type === Token.Punctuator) { | |
throwUnexpected(token); | |
} else { | |
key = parseObjectPropertyKey(); | |
expect(':'); | |
return { | |
type: Syntax.Property, | |
key: key, | |
value: parseAssignmentExpression(), | |
kind: 'init' | |
}; | |
} | |
} | |
function parseObjectInitialiser() { | |
var properties = [], property, name, kind, map = {}, toString = String; | |
expect('{'); | |
while (!match('}')) { | |
property = parseObjectProperty(); | |
if (property.key.type === Syntax.Identifier) { | |
name = property.key.name; | |
} else { | |
name = toString(property.key.value); | |
} | |
kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set; | |
if (Object.prototype.hasOwnProperty.call(map, name)) { | |
if (map[name] === PropertyKind.Data) { | |
if (strict && kind === PropertyKind.Data) { | |
throwErrorTolerant({}, Messages.StrictDuplicateProperty); | |
} else if (kind !== PropertyKind.Data) { | |
throwErrorTolerant({}, Messages.AccessorDataProperty); | |
} | |
} else { | |
if (kind === PropertyKind.Data) { | |
throwErrorTolerant({}, Messages.AccessorDataProperty); | |
} else if (map[name] & kind) { | |
throwErrorTolerant({}, Messages.AccessorGetSet); | |
} | |
} | |
map[name] |= kind; | |
} else { | |
map[name] = kind; | |
} | |
properties.push(property); | |
if (!match('}')) { | |
expect(','); | |
} | |
} | |
expect('}'); | |
return { | |
type: Syntax.ObjectExpression, | |
properties: properties | |
}; | |
} | |
// 11.1.6 The Grouping Operator | |
function parseGroupExpression() { | |
var expr; | |
expect('('); | |
expr = parseExpression(); | |
expect(')'); | |
return expr; | |
} | |
// 11.1 Primary Expressions | |
function parsePrimaryExpression() { | |
var token = lookahead(), | |
type = token.type; | |
if (type === Token.Identifier) { | |
return { | |
type: Syntax.Identifier, | |
name: lex().value | |
}; | |
} | |
if (type === Token.StringLiteral || type === Token.NumericLiteral) { | |
if (strict && token.octal) { | |
throwErrorTolerant(token, Messages.StrictOctalLiteral); | |
} | |
return createLiteral(lex()); | |
} | |
if (type === Token.Keyword) { | |
if (matchKeyword('this')) { | |
lex(); | |
return { | |
type: Syntax.ThisExpression | |
}; | |
} | |
if (matchKeyword('function')) { | |
return parseFunctionExpression(); | |
} | |
} | |
if (type === Token.BooleanLiteral) { | |
lex(); | |
token.value = (token.value === 'true'); | |
return createLiteral(token); | |
} | |
if (type === Token.NullLiteral) { | |
lex(); | |
token.value = null; | |
return createLiteral(token); | |
} | |
if (match('[')) { | |
return parseArrayInitialiser(); | |
} | |
if (match('{')) { | |
return parseObjectInitialiser(); | |
} | |
if (match('(')) { | |
return parseGroupExpression(); | |
} | |
if (match('/') || match('/=')) { | |
return createLiteral(scanRegExp()); | |
} | |
return throwUnexpected(lex()); | |
} | |
// 11.2 Left-Hand-Side Expressions | |
function parseArguments() { | |
var args = []; | |
expect('('); | |
if (!match(')')) { | |
while (index < length) { | |
args.push(parseAssignmentExpression()); | |
if (match(')')) { | |
break; | |
} | |
expect(','); | |
} | |
} | |
expect(')'); | |
return args; | |
} | |
function parseNonComputedProperty() { | |
var token = lex(); | |
if (!isIdentifierName(token)) { | |
throwUnexpected(token); | |
} | |
return { | |
type: Syntax.Identifier, | |
name: token.value | |
}; | |
} | |
function parseNonComputedMember() { | |
expect('.'); | |
return parseNonComputedProperty(); | |
} | |
function parseComputedMember() { | |
var expr; | |
expect('['); | |
expr = parseExpression(); | |
expect(']'); | |
return expr; | |
} | |
function parseNewExpression() { | |
var expr; | |
expectKeyword('new'); | |
expr = { | |
type: Syntax.NewExpression, | |
callee: parseLeftHandSideExpression(), | |
'arguments': [] | |
}; | |
if (match('(')) { | |
expr['arguments'] = parseArguments(); | |
} | |
return expr; | |
} | |
function parseLeftHandSideExpressionAllowCall() { | |
var expr; | |
expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); | |
while (match('.') || match('[') || match('(')) { | |
if (match('(')) { | |
expr = { | |
type: Syntax.CallExpression, | |
callee: expr, | |
'arguments': parseArguments() | |
}; | |
} else if (match('[')) { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: true, | |
object: expr, | |
property: parseComputedMember() | |
}; | |
} else { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: false, | |
object: expr, | |
property: parseNonComputedMember() | |
}; | |
} | |
} | |
return expr; | |
} | |
function parseLeftHandSideExpression() { | |
var expr; | |
expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); | |
while (match('.') || match('[')) { | |
if (match('[')) { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: true, | |
object: expr, | |
property: parseComputedMember() | |
}; | |
} else { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: false, | |
object: expr, | |
property: parseNonComputedMember() | |
}; | |
} | |
} | |
return expr; | |
} | |
// 11.3 Postfix Expressions | |
function parsePostfixExpression() { | |
var expr = parseLeftHandSideExpressionAllowCall(), token; | |
token = lookahead(); | |
if (token.type !== Token.Punctuator) { | |
return expr; | |
} | |
if ((match('++') || match('--')) && !peekLineTerminator()) { | |
// 11.3.1, 11.3.2 | |
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { | |
throwErrorTolerant({}, Messages.StrictLHSPostfix); | |
} | |
if (!isLeftHandSide(expr)) { | |
throwErrorTolerant({}, Messages.InvalidLHSInAssignment); | |
} | |
expr = { | |
type: Syntax.UpdateExpression, | |
operator: lex().value, | |
argument: expr, | |
prefix: false | |
}; | |
} | |
return expr; | |
} | |
// 11.4 Unary Operators | |
function parseUnaryExpression() { | |
var token, expr; | |
token = lookahead(); | |
if (token.type !== Token.Punctuator && token.type !== Token.Keyword) { | |
return parsePostfixExpression(); | |
} | |
if (match('++') || match('--')) { | |
token = lex(); | |
expr = parseUnaryExpression(); | |
// 11.4.4, 11.4.5 | |
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { | |
throwErrorTolerant({}, Messages.StrictLHSPrefix); | |
} | |
if (!isLeftHandSide(expr)) { | |
throwErrorTolerant({}, Messages.InvalidLHSInAssignment); | |
} | |
expr = { | |
type: Syntax.UpdateExpression, | |
operator: token.value, | |
argument: expr, | |
prefix: true | |
}; | |
return expr; | |
} | |
if (match('+') || match('-') || match('~') || match('!')) { | |
expr = { | |
type: Syntax.UnaryExpression, | |
operator: lex().value, | |
argument: parseUnaryExpression(), | |
prefix: true | |
}; | |
return expr; | |
} | |
if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) { | |
expr = { | |
type: Syntax.UnaryExpression, | |
operator: lex().value, | |
argument: parseUnaryExpression(), | |
prefix: true | |
}; | |
if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) { | |
throwErrorTolerant({}, Messages.StrictDelete); | |
} | |
return expr; | |
} | |
return parsePostfixExpression(); | |
} | |
// 11.5 Multiplicative Operators | |
function parseMultiplicativeExpression() { | |
var expr = parseUnaryExpression(); | |
while (match('*') || match('/') || match('%')) { | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseUnaryExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.6 Additive Operators | |
function parseAdditiveExpression() { | |
var expr = parseMultiplicativeExpression(); | |
while (match('+') || match('-')) { | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseMultiplicativeExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.7 Bitwise Shift Operators | |
function parseShiftExpression() { | |
var expr = parseAdditiveExpression(); | |
while (match('<<') || match('>>') || match('>>>')) { | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseAdditiveExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.8 Relational Operators | |
function parseRelationalExpression() { | |
var expr, previousAllowIn; | |
previousAllowIn = state.allowIn; | |
state.allowIn = true; | |
expr = parseShiftExpression(); | |
while (match('<') || match('>') || match('<=') || match('>=') || (previousAllowIn && matchKeyword('in')) || matchKeyword('instanceof')) { | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseShiftExpression() | |
}; | |
} | |
state.allowIn = previousAllowIn; | |
return expr; | |
} | |
// 11.9 Equality Operators | |
function parseEqualityExpression() { | |
var expr = parseRelationalExpression(); | |
while (match('==') || match('!=') || match('===') || match('!==')) { | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseRelationalExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.10 Binary Bitwise Operators | |
function parseBitwiseANDExpression() { | |
var expr = parseEqualityExpression(); | |
while (match('&')) { | |
lex(); | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: '&', | |
left: expr, | |
right: parseEqualityExpression() | |
}; | |
} | |
return expr; | |
} | |
function parseBitwiseXORExpression() { | |
var expr = parseBitwiseANDExpression(); | |
while (match('^')) { | |
lex(); | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: '^', | |
left: expr, | |
right: parseBitwiseANDExpression() | |
}; | |
} | |
return expr; | |
} | |
function parseBitwiseORExpression() { | |
var expr = parseBitwiseXORExpression(); | |
while (match('|')) { | |
lex(); | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: '|', | |
left: expr, | |
right: parseBitwiseXORExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.11 Binary Logical Operators | |
function parseLogicalANDExpression() { | |
var expr = parseBitwiseORExpression(); | |
while (match('&&')) { | |
lex(); | |
expr = { | |
type: Syntax.LogicalExpression, | |
operator: '&&', | |
left: expr, | |
right: parseBitwiseORExpression() | |
}; | |
} | |
return expr; | |
} | |
function parseLogicalORExpression() { | |
var expr = parseLogicalANDExpression(); | |
while (match('||')) { | |
lex(); | |
expr = { | |
type: Syntax.LogicalExpression, | |
operator: '||', | |
left: expr, | |
right: parseLogicalANDExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.12 Conditional Operator | |
function parseConditionalExpression() { | |
var expr, previousAllowIn, consequent; | |
expr = parseLogicalORExpression(); | |
if (match('?')) { | |
lex(); | |
previousAllowIn = state.allowIn; | |
state.allowIn = true; | |
consequent = parseAssignmentExpression(); | |
state.allowIn = previousAllowIn; | |
expect(':'); | |
expr = { | |
type: Syntax.ConditionalExpression, | |
test: expr, | |
consequent: consequent, | |
alternate: parseAssignmentExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.13 Assignment Operators | |
function parseAssignmentExpression() { | |
var token, expr; | |
token = lookahead(); | |
expr = parseConditionalExpression(); | |
if (matchAssign()) { | |
// LeftHandSideExpression | |
if (!isLeftHandSide(expr)) { | |
throwErrorTolerant({}, Messages.InvalidLHSInAssignment); | |
} | |
// 11.13.1 | |
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { | |
throwErrorTolerant(token, Messages.StrictLHSAssignment); | |
} | |
expr = { | |
type: Syntax.AssignmentExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseAssignmentExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.14 Comma Operator | |
function parseExpression() { | |
var expr = parseAssignmentExpression(); | |
if (match(',')) { | |
expr = { | |
type: Syntax.SequenceExpression, | |
expressions: [ expr ] | |
}; | |
while (index < length) { | |
if (!match(',')) { | |
break; | |
} | |
lex(); | |
expr.expressions.push(parseAssignmentExpression()); | |
} | |
} | |
return expr; | |
} | |
// 12.1 Block | |
function parseStatementList() { | |
var list = [], | |
statement; | |
while (index < length) { | |
if (match('}')) { | |
break; | |
} | |
statement = parseSourceElement(); | |
if (typeof statement === 'undefined') { | |
break; | |
} | |
list.push(statement); | |
} | |
return list; | |
} | |
function parseBlock() { | |
var block; | |
expect('{'); | |
block = parseStatementList(); | |
expect('}'); | |
return { | |
type: Syntax.BlockStatement, | |
body: block | |
}; | |
} | |
// 12.2 Variable Statement | |
function parseVariableIdentifier() { | |
var token = lex(); | |
if (token.type !== Token.Identifier) { | |
throwUnexpected(token); | |
} | |
return { | |
type: Syntax.Identifier, | |
name: token.value | |
}; | |
} | |
function parseVariableDeclaration(kind) { | |
var id = parseVariableIdentifier(), | |
init = null; | |
// 12.2.1 | |
if (strict && isRestrictedWord(id.name)) { | |
throwErrorTolerant({}, Messages.StrictVarName); | |
} | |
if (kind === 'const') { | |
expect('='); | |
init = parseAssignmentExpression(); | |
} else if (match('=')) { | |
lex(); | |
init = parseAssignmentExpression(); | |
} | |
return { | |
type: Syntax.VariableDeclarator, | |
id: id, | |
init: init | |
}; | |
} | |
function parseVariableDeclarationList(kind) { | |
var list = []; | |
do { | |
list.push(parseVariableDeclaration(kind)); | |
if (!match(',')) { | |
break; | |
} | |
lex(); | |
} while (index < length); | |
return list; | |
} | |
function parseVariableStatement() { | |
var declarations; | |
expectKeyword('var'); | |
declarations = parseVariableDeclarationList(); | |
consumeSemicolon(); | |
return { | |
type: Syntax.VariableDeclaration, | |
declarations: declarations, | |
kind: 'var' | |
}; | |
} | |
// kind may be `const` or `let` | |
// Both are experimental and not in the specification yet. | |
// see http://wiki.ecmascript.org/doku.php?id=harmony:const | |
// and http://wiki.ecmascript.org/doku.php?id=harmony:let | |
function parseConstLetDeclaration(kind) { | |
var declarations; | |
expectKeyword(kind); | |
declarations = parseVariableDeclarationList(kind); | |
consumeSemicolon(); | |
return { | |
type: Syntax.VariableDeclaration, | |
declarations: declarations, | |
kind: kind | |
}; | |
} | |
// 12.3 Empty Statement | |
function parseEmptyStatement() { | |
expect(';'); | |
return { | |
type: Syntax.EmptyStatement | |
}; | |
} | |
// 12.4 Expression Statement | |
function parseExpressionStatement() { | |
var expr = parseExpression(); | |
consumeSemicolon(); | |
return { | |
type: Syntax.ExpressionStatement, | |
expression: expr | |
}; | |
} | |
// 12.5 If statement | |
function parseIfStatement() { | |
var test, consequent, alternate; | |
expectKeyword('if'); | |
expect('('); | |
test = parseExpression(); | |
expect(')'); | |
consequent = parseStatement(); | |
if (matchKeyword('else')) { | |
lex(); | |
alternate = parseStatement(); | |
} else { | |
alternate = null; | |
} | |
return { | |
type: Syntax.IfStatement, | |
test: test, | |
consequent: consequent, | |
alternate: alternate | |
}; | |
} | |
// 12.6 Iteration Statements | |
function parseDoWhileStatement() { | |
var body, test, oldInIteration; | |
expectKeyword('do'); | |
oldInIteration = state.inIteration; | |
state.inIteration = true; | |
body = parseStatement(); | |
state.inIteration = oldInIteration; | |
expectKeyword('while'); | |
expect('('); | |
test = parseExpression(); | |
expect(')'); | |
if (match(';')) { | |
lex(); | |
} | |
return { | |
type: Syntax.DoWhileStatement, | |
body: body, | |
test: test | |
}; | |
} | |
function parseWhileStatement() { | |
var test, body, oldInIteration; | |
expectKeyword('while'); | |
expect('('); | |
test = parseExpression(); | |
expect(')'); | |
oldInIteration = state.inIteration; | |
state.inIteration = true; | |
body = parseStatement(); | |
state.inIteration = oldInIteration; | |
return { | |
type: Syntax.WhileStatement, | |
test: test, | |
body: body | |
}; | |
} | |
function parseForVariableDeclaration() { | |
var token = lex(); | |
return { | |
type: Syntax.VariableDeclaration, | |
declarations: parseVariableDeclarationList(), | |
kind: token.value | |
}; | |
} | |
function parseForStatement() { | |
var init, test, update, left, right, body, oldInIteration; | |
init = test = update = null; | |
expectKeyword('for'); | |
expect('('); | |
if (match(';')) { | |
lex(); | |
} else { | |
if (matchKeyword('var') || matchKeyword('let')) { | |
state.allowIn = false; | |
init = parseForVariableDeclaration(); | |
state.allowIn = true; | |
if (init.declarations.length === 1 && matchKeyword('in')) { | |
lex(); | |
left = init; | |
right = parseExpression(); | |
init = null; | |
} | |
} else { | |
state.allowIn = false; | |
init = parseExpression(); | |
state.allowIn = true; | |
if (matchKeyword('in')) { | |
// LeftHandSideExpression | |
if (!isLeftHandSide(init)) { | |
throwErrorTolerant({}, Messages.InvalidLHSInForIn); | |
} | |
lex(); | |
left = init; | |
right = parseExpression(); | |
init = null; | |
} | |
} | |
if (typeof left === 'undefined') { | |
expect(';'); | |
} | |
} | |
if (typeof left === 'undefined') { | |
if (!match(';')) { | |
test = parseExpression(); | |
} | |
expect(';'); | |
if (!match(')')) { | |
update = parseExpression(); | |
} | |
} | |
expect(')'); | |
oldInIteration = state.inIteration; | |
state.inIteration = true; | |
body = parseStatement(); | |
state.inIteration = oldInIteration; | |
if (typeof left === 'undefined') { | |
return { | |
type: Syntax.ForStatement, | |
init: init, | |
test: test, | |
update: update, | |
body: body | |
}; | |
} | |
return { | |
type: Syntax.ForInStatement, | |
left: left, | |
right: right, | |
body: body, | |
each: false | |
}; | |
} | |
// 12.7 The continue statement | |
function parseContinueStatement() { | |
var token, label = null; | |
expectKeyword('continue'); | |
// Optimize the most common form: 'continue;'. | |
if (source[index] === ';') { | |
lex(); | |
if (!state.inIteration) { | |
throwError({}, Messages.IllegalContinue); | |
} | |
return { | |
type: Syntax.ContinueStatement, | |
label: null | |
}; | |
} | |
if (peekLineTerminator()) { | |
if (!state.inIteration) { | |
throwError({}, Messages.IllegalContinue); | |
} | |
return { | |
type: Syntax.ContinueStatement, | |
label: null | |
}; | |
} | |
token = lookahead(); | |
if (token.type === Token.Identifier) { | |
label = parseVariableIdentifier(); | |
if (!Object.prototype.hasOwnProperty.call(state.labelSet, label.name)) { | |
throwError({}, Messages.UnknownLabel, label.name); | |
} | |
} | |
consumeSemicolon(); | |
if (label === null && !state.inIteration) { | |
throwError({}, Messages.IllegalContinue); | |
} | |
return { | |
type: Syntax.ContinueStatement, | |
label: label | |
}; | |
} | |
// 12.8 The break statement | |
function parseBreakStatement() { | |
var token, label = null; | |
expectKeyword('break'); | |
// Optimize the most common form: 'break;'. | |
if (source[index] === ';') { | |
lex(); | |
if (!(state.inIteration || state.inSwitch)) { | |
throwError({}, Messages.IllegalBreak); | |
} | |
return { | |
type: Syntax.BreakStatement, | |
label: null | |
}; | |
} | |
if (peekLineTerminator()) { | |
if (!(state.inIteration || state.inSwitch)) { | |
throwError({}, Messages.IllegalBreak); | |
} | |
return { | |
type: Syntax.BreakStatement, | |
label: null | |
}; | |
} | |
token = lookahead(); | |
if (token.type === Token.Identifier) { | |
label = parseVariableIdentifier(); | |
if (!Object.prototype.hasOwnProperty.call(state.labelSet, label.name)) { | |
throwError({}, Messages.UnknownLabel, label.name); | |
} | |
} | |
consumeSemicolon(); | |
if (label === null && !(state.inIteration || state.inSwitch)) { | |
throwError({}, Messages.IllegalBreak); | |
} | |
return { | |
type: Syntax.BreakStatement, | |
label: label | |
}; | |
} | |
// 12.9 The return statement | |
function parseReturnStatement() { | |
var token, argument = null; | |
expectKeyword('return'); | |
if (!state.inFunctionBody) { | |
throwErrorTolerant({}, Messages.IllegalReturn); | |
} | |
// 'return' followed by a space and an identifier is very common. | |
if (source[index] === ' ') { | |
if (isIdentifierStart(source[index + 1])) { | |
argument = parseExpression(); | |
consumeSemicolon(); | |
return { | |
type: Syntax.ReturnStatement, | |
argument: argument | |
}; | |
} | |
} | |
if (peekLineTerminator()) { | |
return { | |
type: Syntax.ReturnStatement, | |
argument: null | |
}; | |
} | |
if (!match(';')) { | |
token = lookahead(); | |
if (!match('}') && token.type !== Token.EOF) { | |
argument = parseExpression(); | |
} | |
} | |
consumeSemicolon(); | |
return { | |
type: Syntax.ReturnStatement, | |
argument: argument | |
}; | |
} | |
// 12.10 The with statement | |
function parseWithStatement() { | |
var object, body; | |
if (strict) { | |
throwErrorTolerant({}, Messages.StrictModeWith); | |
} | |
expectKeyword('with'); | |
expect('('); | |
object = parseExpression(); | |
expect(')'); | |
body = parseStatement(); | |
return { | |
type: Syntax.WithStatement, | |
object: object, | |
body: body | |
}; | |
} | |
// 12.10 The swith statement | |
function parseSwitchCase() { | |
var test, | |
consequent = [], | |
statement; | |
if (matchKeyword('default')) { | |
lex(); | |
test = null; | |
} else { | |
expectKeyword('case'); | |
test = parseExpression(); | |
} | |
expect(':'); | |
while (index < length) { | |
if (match('}') || matchKeyword('default') || matchKeyword('case')) { | |
break; | |
} | |
statement = parseStatement(); | |
if (typeof statement === 'undefined') { | |
break; | |
} | |
consequent.push(statement); | |
} | |
return { | |
type: Syntax.SwitchCase, | |
test: test, | |
consequent: consequent | |
}; | |
} | |
function parseSwitchStatement() { | |
var discriminant, cases, clause, oldInSwitch, defaultFound; | |
expectKeyword('switch'); | |
expect('('); | |
discriminant = parseExpression(); | |
expect(')'); | |
expect('{'); | |
cases = []; | |
if (match('}')) { | |
lex(); | |
return { | |
type: Syntax.SwitchStatement, | |
discriminant: discriminant, | |
cases: cases | |
}; | |
} | |
oldInSwitch = state.inSwitch; | |
state.inSwitch = true; | |
defaultFound = false; | |
while (index < length) { | |
if (match('}')) { | |
break; | |
} | |
clause = parseSwitchCase(); | |
if (clause.test === null) { | |
if (defaultFound) { | |
throwError({}, Messages.MultipleDefaultsInSwitch); | |
} | |
defaultFound = true; | |
} | |
cases.push(clause); | |
} | |
state.inSwitch = oldInSwitch; | |
expect('}'); | |
return { | |
type: Syntax.SwitchStatement, | |
discriminant: discriminant, | |
cases: cases | |
}; | |
} | |
// 12.13 The throw statement | |
function parseThrowStatement() { | |
var argument; | |
expectKeyword('throw'); | |
if (peekLineTerminator()) { | |
throwError({}, Messages.NewlineAfterThrow); | |
} | |
argument = parseExpression(); | |
consumeSemicolon(); | |
return { | |
type: Syntax.ThrowStatement, | |
argument: argument | |
}; | |
} | |
// 12.14 The try statement | |
function parseCatchClause() { | |
var param; | |
expectKeyword('catch'); | |
expect('('); | |
if (match(')')) { | |
throwUnexpected(lookahead()); | |
} | |
param = parseVariableIdentifier(); | |
// 12.14.1 | |
if (strict && isRestrictedWord(param.name)) { | |
throwErrorTolerant({}, Messages.StrictCatchVariable); | |
} | |
expect(')'); | |
return { | |
type: Syntax.CatchClause, | |
param: param, | |
body: parseBlock() | |
}; | |
} | |
function parseTryStatement() { | |
var block, handlers = [], finalizer = null; | |
expectKeyword('try'); | |
block = parseBlock(); | |
if (matchKeyword('catch')) { | |
handlers.push(parseCatchClause()); | |
} | |
if (matchKeyword('finally')) { | |
lex(); | |
finalizer = parseBlock(); | |
} | |
if (handlers.length === 0 && !finalizer) { | |
throwError({}, Messages.NoCatchOrFinally); | |
} | |
return { | |
type: Syntax.TryStatement, | |
block: block, | |
guardedHandlers: [], | |
handlers: handlers, | |
finalizer: finalizer | |
}; | |
} | |
// 12.15 The debugger statement | |
function parseDebuggerStatement() { | |
expectKeyword('debugger'); | |
consumeSemicolon(); | |
return { | |
type: Syntax.DebuggerStatement | |
}; | |
} | |
// 12 Statements | |
function parseStatement() { | |
var token = lookahead(), | |
expr, | |
labeledBody; | |
if (token.type === Token.EOF) { | |
throwUnexpected(token); | |
} | |
if (token.type === Token.Punctuator) { | |
switch (token.value) { | |
case ';': | |
return parseEmptyStatement(); | |
case '{': | |
return parseBlock(); | |
case '(': | |
return parseExpressionStatement(); | |
default: | |
break; | |
} | |
} | |
if (token.type === Token.Keyword) { | |
switch (token.value) { | |
case 'break': | |
return parseBreakStatement(); | |
case 'continue': | |
return parseContinueStatement(); | |
case 'debugger': | |
return parseDebuggerStatement(); | |
case 'do': | |
return parseDoWhileStatement(); | |
case 'for': | |
return parseForStatement(); | |
case 'function': | |
return parseFunctionDeclaration(); | |
case 'if': | |
return parseIfStatement(); | |
case 'return': | |
return parseReturnStatement(); | |
case 'switch': | |
return parseSwitchStatement(); | |
case 'throw': | |
return parseThrowStatement(); | |
case 'try': | |
return parseTryStatement(); | |
case 'var': | |
return parseVariableStatement(); | |
case 'while': | |
return parseWhileStatement(); | |
case 'with': | |
return parseWithStatement(); | |
default: | |
break; | |
} | |
} | |
expr = parseExpression(); | |
// 12.12 Labelled Statements | |
if ((expr.type === Syntax.Identifier) && match(':')) { | |
lex(); | |
if (Object.prototype.hasOwnProperty.call(state.labelSet, expr.name)) { | |
throwError({}, Messages.Redeclaration, 'Label', expr.name); | |
} | |
state.labelSet[expr.name] = true; | |
labeledBody = parseStatement(); | |
delete state.labelSet[expr.name]; | |
return { | |
type: Syntax.LabeledStatement, | |
label: expr, | |
body: labeledBody | |
}; | |
} | |
consumeSemicolon(); | |
return { | |
type: Syntax.ExpressionStatement, | |
expression: expr | |
}; | |
} | |
// 13 Function Definition | |
function parseFunctionSourceElements() { | |
var sourceElement, sourceElements = [], token, directive, firstRestricted, | |
oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody; | |
expect('{'); | |
while (index < length) { | |
token = lookahead(); | |
if (token.type !== Token.StringLiteral) { | |
break; | |
} | |
sourceElement = parseSourceElement(); | |
sourceElements.push(sourceElement); | |
if (sourceElement.expression.type !== Syntax.Literal) { | |
// this is not directive | |
break; | |
} | |
directive = sliceSource(token.range[0] + 1, token.range[1] - 1); | |
if (directive === 'use strict') { | |
strict = true; | |
if (firstRestricted) { | |
throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); | |
} | |
} else { | |
if (!firstRestricted && token.octal) { | |
firstRestricted = token; | |
} | |
} | |
} | |
oldLabelSet = state.labelSet; | |
oldInIteration = state.inIteration; | |
oldInSwitch = state.inSwitch; | |
oldInFunctionBody = state.inFunctionBody; | |
state.labelSet = {}; | |
state.inIteration = false; | |
state.inSwitch = false; | |
state.inFunctionBody = true; | |
while (index < length) { | |
if (match('}')) { | |
break; | |
} | |
sourceElement = parseSourceElement(); | |
if (typeof sourceElement === 'undefined') { | |
break; | |
} | |
sourceElements.push(sourceElement); | |
} | |
expect('}'); | |
state.labelSet = oldLabelSet; | |
state.inIteration = oldInIteration; | |
state.inSwitch = oldInSwitch; | |
state.inFunctionBody = oldInFunctionBody; | |
return { | |
type: Syntax.BlockStatement, | |
body: sourceElements | |
}; | |
} | |
function parseFunctionDeclaration() { | |
var id, param, params = [], body, token, stricted, firstRestricted, message, previousStrict, paramSet; | |
expectKeyword('function'); | |
token = lookahead(); | |
id = parseVariableIdentifier(); | |
if (strict) { | |
if (isRestrictedWord(token.value)) { | |
throwErrorTolerant(token, Messages.StrictFunctionName); | |
} | |
} else { | |
if (isRestrictedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictFunctionName; | |
} else if (isStrictModeReservedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictReservedWord; | |
} | |
} | |
expect('('); | |
if (!match(')')) { | |
paramSet = {}; | |
while (index < length) { | |
token = lookahead(); | |
param = parseVariableIdentifier(); | |
if (strict) { | |
if (isRestrictedWord(token.value)) { | |
stricted = token; | |
message = Messages.StrictParamName; | |
} | |
if (Object.prototype.hasOwnProperty.call(paramSet, token.value)) { | |
stricted = token; | |
message = Messages.StrictParamDupe; | |
} | |
} else if (!firstRestricted) { | |
if (isRestrictedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictParamName; | |
} else if (isStrictModeReservedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictReservedWord; | |
} else if (Object.prototype.hasOwnProperty.call(paramSet, token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictParamDupe; | |
} | |
} | |
params.push(param); | |
paramSet[param.name] = true; | |
if (match(')')) { | |
break; | |
} | |
expect(','); | |
} | |
} | |
expect(')'); | |
previousStrict = strict; | |
body = parseFunctionSourceElements(); | |
if (strict && firstRestricted) { | |
throwError(firstRestricted, message); | |
} | |
if (strict && stricted) { | |
throwErrorTolerant(stricted, message); | |
} | |
strict = previousStrict; | |
return { | |
type: Syntax.FunctionDeclaration, | |
id: id, | |
params: params, | |
defaults: [], | |
body: body, | |
rest: null, | |
generator: false, | |
expression: false | |
}; | |
} | |
function parseFunctionExpression() { | |
var token, id = null, stricted, firstRestricted, message, param, params = [], body, previousStrict, paramSet; | |
expectKeyword('function'); | |
if (!match('(')) { | |
token = lookahead(); | |
id = parseVariableIdentifier(); | |
if (strict) { | |
if (isRestrictedWord(token.value)) { | |
throwErrorTolerant(token, Messages.StrictFunctionName); | |
} | |
} else { | |
if (isRestrictedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictFunctionName; | |
} else if (isStrictModeReservedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictReservedWord; | |
} | |
} | |
} | |
expect('('); | |
if (!match(')')) { | |
paramSet = {}; | |
while (index < length) { | |
token = lookahead(); | |
param = parseVariableIdentifier(); | |
if (strict) { | |
if (isRestrictedWord(token.value)) { | |
stricted = token; | |
message = Messages.StrictParamName; | |
} | |
if (Object.prototype.hasOwnProperty.call(paramSet, token.value)) { | |
stricted = token; | |
message = Messages.StrictParamDupe; | |
} | |
} else if (!firstRestricted) { | |
if (isRestrictedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictParamName; | |
} else if (isStrictModeReservedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictReservedWord; | |
} else if (Object.prototype.hasOwnProperty.call(paramSet, token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictParamDupe; | |
} | |
} | |
params.push(param); | |
paramSet[param.name] = true; | |
if (match(')')) { | |
break; | |
} | |
expect(','); | |
} | |
} | |
expect(')'); | |
previousStrict = strict; | |
body = parseFunctionSourceElements(); | |
if (strict && firstRestricted) { | |
throwError(firstRestricted, message); | |
} | |
if (strict && stricted) { | |
throwErrorTolerant(stricted, message); | |
} | |
strict = previousStrict; | |
return { | |
type: Syntax.FunctionExpression, | |
id: id, | |
params: params, | |
defaults: [], | |
body: body, | |
rest: null, | |
generator: false, | |
expression: false | |
}; | |
} | |
// 14 Program | |
function parseSourceElement() { | |
var token = lookahead(); | |
if (token.type === Token.Keyword) { | |
switch (token.value) { | |
case 'const': | |
case 'let': | |
return parseConstLetDeclaration(token.value); | |
case 'function': | |
return parseFunctionDeclaration(); | |
default: | |
return parseStatement(); | |
} | |
} | |
if (token.type !== Token.EOF) { | |
return parseStatement(); | |
} | |
} | |
function parseSourceElements() { | |
var sourceElement, sourceElements = [], token, directive, firstRestricted; | |
while (index < length) { | |
token = lookahead(); | |
if (token.type !== Token.StringLiteral) { | |
break; | |
} | |
sourceElement = parseSourceElement(); | |
sourceElements.push(sourceElement); | |
if (sourceElement.expression.type !== Syntax.Literal) { | |
// this is not directive | |
break; | |
} | |
directive = sliceSource(token.range[0] + 1, token.range[1] - 1); | |
if (directive === 'use strict') { | |
strict = true; | |
if (firstRestricted) { | |
throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); | |
} | |
} else { | |
if (!firstRestricted && token.octal) { | |
firstRestricted = token; | |
} | |
} | |
} | |
while (index < length) { | |
sourceElement = parseSourceElement(); | |
if (typeof sourceElement === 'undefined') { | |
break; | |
} | |
sourceElements.push(sourceElement); | |
} | |
return sourceElements; | |
} | |
function parseProgram() { | |
var program; | |
strict = false; | |
program = { | |
type: Syntax.Program, | |
body: parseSourceElements() | |
}; | |
return program; | |
} | |
// The following functions are needed only when the option to preserve | |
// the comments is active. | |
function addComment(type, value, start, end, loc) { | |
assert(typeof start === 'number', 'Comment must have valid position'); | |
// Because the way the actual token is scanned, often the comments | |
// (if any) are skipped twice during the lexical analysis. | |
// Thus, we need to skip adding a comment if the comment array already | |
// handled it. | |
if (extra.comments.length > 0) { | |
if (extra.comments[extra.comments.length - 1].range[1] > start) { | |
return; | |
} | |
} | |
extra.comments.push({ | |
type: type, | |
value: value, | |
range: [start, end], | |
loc: loc | |
}); | |
} | |
function scanComment() { | |
var comment, ch, loc, start, blockComment, lineComment; | |
comment = ''; | |
blockComment = false; | |
lineComment = false; | |
while (index < length) { | |
ch = source[index]; | |
if (lineComment) { | |
ch = source[index++]; | |
if (isLineTerminator(ch)) { | |
loc.end = { | |
line: lineNumber, | |
column: index - lineStart - 1 | |
}; | |
lineComment = false; | |
addComment('Line', comment, start, index - 1, loc); | |
if (ch === '\r' && source[index] === '\n') { | |
++index; | |
} | |
++lineNumber; | |
lineStart = index; | |
comment = ''; | |
} else if (index >= length) { | |
lineComment = false; | |
comment += ch; | |
loc.end = { | |
line: lineNumber, | |
column: length - lineStart | |
}; | |
addComment('Line', comment, start, length, loc); | |
} else { | |
comment += ch; | |
} | |
} else if (blockComment) { | |
if (isLineTerminator(ch)) { | |
if (ch === '\r' && source[index + 1] === '\n') { | |
++index; | |
comment += '\r\n'; | |
} else { | |
comment += ch; | |
} | |
++lineNumber; | |
++index; | |
lineStart = index; | |
if (index >= length) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} else { | |
ch = source[index++]; | |
if (index >= length) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
comment += ch; | |
if (ch === '*') { | |
ch = source[index]; | |
if (ch === '/') { | |
comment = comment.substr(0, comment.length - 1); | |
blockComment = false; | |
++index; | |
loc.end = { | |
line: lineNumber, | |
column: index - lineStart | |
}; | |
addComment('Block', comment, start, index, loc); | |
comment = ''; | |
} | |
} | |
} | |
} else if (ch === '/') { | |
ch = source[index + 1]; | |
if (ch === '/') { | |
loc = { | |
start: { | |
line: lineNumber, | |
column: index - lineStart | |
} | |
}; | |
start = index; | |
index += 2; | |
lineComment = true; | |
if (index >= length) { | |
loc.end = { | |
line: lineNumber, | |
column: index - lineStart | |
}; | |
lineComment = false; | |
addComment('Line', comment, start, index, loc); | |
} | |
} else if (ch === '*') { | |
start = index; | |
index += 2; | |
blockComment = true; | |
loc = { | |
start: { | |
line: lineNumber, | |
column: index - lineStart - 2 | |
} | |
}; | |
if (index >= length) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} else { | |
break; | |
} | |
} else if (isWhiteSpace(ch)) { | |
++index; | |
} else if (isLineTerminator(ch)) { | |
++index; | |
if (ch === '\r' && source[index] === '\n') { | |
++index; | |
} | |
++lineNumber; | |
lineStart = index; | |
} else { | |
break; | |
} | |
} | |
} | |
function filterCommentLocation() { | |
var i, entry, comment, comments = []; | |
for (i = 0; i < extra.comments.length; ++i) { | |
entry = extra.comments[i]; | |
comment = { | |
type: entry.type, | |
value: entry.value | |
}; | |
if (extra.range) { | |
comment.range = entry.range; | |
} | |
if (extra.loc) { | |
comment.loc = entry.loc; | |
} | |
comments.push(comment); | |
} | |
extra.comments = comments; | |
} | |
function collectToken() { | |
var start, loc, token, range, value; | |
skipComment(); | |
start = index; | |
loc = { | |
start: { | |
line: lineNumber, | |
column: index - lineStart | |
} | |
}; | |
token = extra.advance(); | |
loc.end = { | |
line: lineNumber, | |
column: index - lineStart | |
}; | |
if (token.type !== Token.EOF) { | |
range = [token.range[0], token.range[1]]; | |
value = sliceSource(token.range[0], token.range[1]); | |
extra.tokens.push({ | |
type: TokenName[token.type], | |
value: value, | |
range: range, | |
loc: loc | |
}); | |
} | |
return token; | |
} | |
function collectRegex() { | |
var pos, loc, regex, token; | |
skipComment(); | |
pos = index; | |
loc = { | |
start: { | |
line: lineNumber, | |
column: index - lineStart | |
} | |
}; | |
regex = extra.scanRegExp(); | |
loc.end = { | |
line: lineNumber, | |
column: index - lineStart | |
}; | |
// Pop the previous token, which is likely '/' or '/=' | |
if (extra.tokens.length > 0) { | |
token = extra.tokens[extra.tokens.length - 1]; | |
if (token.range[0] === pos && token.type === 'Punctuator') { | |
if (token.value === '/' || token.value === '/=') { | |
extra.tokens.pop(); | |
} | |
} | |
} | |
extra.tokens.push({ | |
type: 'RegularExpression', | |
value: regex.literal, | |
range: [pos, index], | |
loc: loc | |
}); | |
return regex; | |
} | |
function filterTokenLocation() { | |
var i, entry, token, tokens = []; | |
for (i = 0; i < extra.tokens.length; ++i) { | |
entry = extra.tokens[i]; | |
token = { | |
type: entry.type, | |
value: entry.value | |
}; | |
if (extra.range) { | |
token.range = entry.range; | |
} | |
if (extra.loc) { | |
token.loc = entry.loc; | |
} | |
tokens.push(token); | |
} | |
extra.tokens = tokens; | |
} | |
function createLiteral(token) { | |
return { | |
type: Syntax.Literal, | |
value: token.value | |
}; | |
} | |
function createRawLiteral(token) { | |
return { | |
type: Syntax.Literal, | |
value: token.value, | |
raw: sliceSource(token.range[0], token.range[1]) | |
}; | |
} | |
function createLocationMarker() { | |
var marker = {}; | |
marker.range = [index, index]; | |
marker.loc = { | |
start: { | |
line: lineNumber, | |
column: index - lineStart | |
}, | |
end: { | |
line: lineNumber, | |
column: index - lineStart | |
} | |
}; | |
marker.end = function () { | |
this.range[1] = index; | |
this.loc.end.line = lineNumber; | |
this.loc.end.column = index - lineStart; | |
}; | |
marker.applyGroup = function (node) { | |
if (extra.range) { | |
node.groupRange = [this.range[0], this.range[1]]; | |
} | |
if (extra.loc) { | |
node.groupLoc = { | |
start: { | |
line: this.loc.start.line, | |
column: this.loc.start.column | |
}, | |
end: { | |
line: this.loc.end.line, | |
column: this.loc.end.column | |
} | |
}; | |
} | |
}; | |
marker.apply = function (node) { | |
if (extra.range) { | |
node.range = [this.range[0], this.range[1]]; | |
} | |
if (extra.loc) { | |
node.loc = { | |
start: { | |
line: this.loc.start.line, | |
column: this.loc.start.column | |
}, | |
end: { | |
line: this.loc.end.line, | |
column: this.loc.end.column | |
} | |
}; | |
} | |
}; | |
return marker; | |
} | |
function trackGroupExpression() { | |
var marker, expr; | |
skipComment(); | |
marker = createLocationMarker(); | |
expect('('); | |
expr = parseExpression(); | |
expect(')'); | |
marker.end(); | |
marker.applyGroup(expr); | |
return expr; | |
} | |
function trackLeftHandSideExpression() { | |
var marker, expr; | |
skipComment(); | |
marker = createLocationMarker(); | |
expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); | |
while (match('.') || match('[')) { | |
if (match('[')) { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: true, | |
object: expr, | |
property: parseComputedMember() | |
}; | |
marker.end(); | |
marker.apply(expr); | |
} else { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: false, | |
object: expr, | |
property: parseNonComputedMember() | |
}; | |
marker.end(); | |
marker.apply(expr); | |
} | |
} | |
return expr; | |
} | |
function trackLeftHandSideExpressionAllowCall() { | |
var marker, expr; | |
skipComment(); | |
marker = createLocationMarker(); | |
expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); | |
while (match('.') || match('[') || match('(')) { | |
if (match('(')) { | |
expr = { | |
type: Syntax.CallExpression, | |
callee: expr, | |
'arguments': parseArguments() | |
}; | |
marker.end(); | |
marker.apply(expr); | |
} else if (match('[')) { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: true, | |
object: expr, | |
property: parseComputedMember() | |
}; | |
marker.end(); | |
marker.apply(expr); | |
} else { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: false, | |
object: expr, | |
property: parseNonComputedMember() | |
}; | |
marker.end(); | |
marker.apply(expr); | |
} | |
} | |
return expr; | |
} | |
function filterGroup(node) { | |
var n, i, entry; | |
n = (Object.prototype.toString.apply(node) === '[object Array]') ? [] : {}; | |
for (i in node) { | |
if (node.hasOwnProperty(i) && i !== 'groupRange' && i !== 'groupLoc') { | |
entry = node[i]; | |
if (entry === null || typeof entry !== 'object' || entry instanceof RegExp) { | |
n[i] = entry; | |
} else { | |
n[i] = filterGroup(entry); | |
} | |
} | |
} | |
return n; | |
} | |
function wrapTrackingFunction(range, loc) { | |
return function (parseFunction) { | |
function isBinary(node) { | |
return node.type === Syntax.LogicalExpression || | |
node.type === Syntax.BinaryExpression; | |
} | |
function visit(node) { | |
var start, end; | |
if (isBinary(node.left)) { | |
visit(node.left); | |
} | |
if (isBinary(node.right)) { | |
visit(node.right); | |
} | |
if (range) { | |
if (node.left.groupRange || node.right.groupRange) { | |
start = node.left.groupRange ? node.left.groupRange[0] : node.left.range[0]; | |
end = node.right.groupRange ? node.right.groupRange[1] : node.right.range[1]; | |
node.range = [start, end]; | |
} else if (typeof node.range === 'undefined') { | |
start = node.left.range[0]; | |
end = node.right.range[1]; | |
node.range = [start, end]; | |
} | |
} | |
if (loc) { | |
if (node.left.groupLoc || node.right.groupLoc) { | |
start = node.left.groupLoc ? node.left.groupLoc.start : node.left.loc.start; | |
end = node.right.groupLoc ? node.right.groupLoc.end : node.right.loc.end; | |
node.loc = { | |
start: start, | |
end: end | |
}; | |
} else if (typeof node.loc === 'undefined') { | |
node.loc = { | |
start: node.left.loc.start, | |
end: node.right.loc.end | |
}; | |
} | |
} | |
} | |
return function () { | |
var marker, node; | |
skipComment(); | |
marker = createLocationMarker(); | |
node = parseFunction.apply(null, arguments); | |
marker.end(); | |
if (range && typeof node.range === 'undefined') { | |
marker.apply(node); | |
} | |
if (loc && typeof node.loc === 'undefined') { | |
marker.apply(node); | |
} | |
if (isBinary(node)) { | |
visit(node); | |
} | |
return node; | |
}; | |
}; | |
} | |
function patch() { | |
var wrapTracking; | |
if (extra.comments) { | |
extra.skipComment = skipComment; | |
skipComment = scanComment; | |
} | |
if (extra.raw) { | |
extra.createLiteral = createLiteral; | |
createLiteral = createRawLiteral; | |
} | |
if (extra.range || extra.loc) { | |
extra.parseGroupExpression = parseGroupExpression; | |
extra.parseLeftHandSideExpression = parseLeftHandSideExpression; | |
extra.parseLeftHandSideExpressionAllowCall = parseLeftHandSideExpressionAllowCall; | |
parseGroupExpression = trackGroupExpression; | |
parseLeftHandSideExpression = trackLeftHandSideExpression; | |
parseLeftHandSideExpressionAllowCall = trackLeftHandSideExpressionAllowCall; | |
wrapTracking = wrapTrackingFunction(extra.range, extra.loc); | |
extra.parseAdditiveExpression = parseAdditiveExpression; | |
extra.parseAssignmentExpression = parseAssignmentExpression; | |
extra.parseBitwiseANDExpression = parseBitwiseANDExpression; | |
extra.parseBitwiseORExpression = parseBitwiseORExpression; | |
extra.parseBitwiseXORExpression = parseBitwiseXORExpression; | |
extra.parseBlock = parseBlock; | |
extra.parseFunctionSourceElements = parseFunctionSourceElements; | |
extra.parseCatchClause = parseCatchClause; | |
extra.parseComputedMember = parseComputedMember; | |
extra.parseConditionalExpression = parseConditionalExpression; | |
extra.parseConstLetDeclaration = parseConstLetDeclaration; | |
extra.parseEqualityExpression = parseEqualityExpression; | |
extra.parseExpression = parseExpression; | |
extra.parseForVariableDeclaration = parseForVariableDeclaration; | |
extra.parseFunctionDeclaration = parseFunctionDeclaration; | |
extra.parseFunctionExpression = parseFunctionExpression; | |
extra.parseLogicalANDExpression = parseLogicalANDExpression; | |
extra.parseLogicalORExpression = parseLogicalORExpression; | |
extra.parseMultiplicativeExpression = parseMultiplicativeExpression; | |
extra.parseNewExpression = parseNewExpression; | |
extra.parseNonComputedProperty = parseNonComputedProperty; | |
extra.parseObjectProperty = parseObjectProperty; | |
extra.parseObjectPropertyKey = parseObjectPropertyKey; | |
extra.parsePostfixExpression = parsePostfixExpression; | |
extra.parsePrimaryExpression = parsePrimaryExpression; | |
extra.parseProgram = parseProgram; | |
extra.parsePropertyFunction = parsePropertyFunction; | |
extra.parseRelationalExpression = parseRelationalExpression; | |
extra.parseStatement = parseStatement; | |
extra.parseShiftExpression = parseShiftExpression; | |
extra.parseSwitchCase = parseSwitchCase; | |
extra.parseUnaryExpression = parseUnaryExpression; | |
extra.parseVariableDeclaration = parseVariableDeclaration; | |
extra.parseVariableIdentifier = parseVariableIdentifier; | |
parseAdditiveExpression = wrapTracking(extra.parseAdditiveExpression); | |
parseAssignmentExpression = wrapTracking(extra.parseAssignmentExpression); | |
parseBitwiseANDExpression = wrapTracking(extra.parseBitwiseANDExpression); | |
parseBitwiseORExpression = wrapTracking(extra.parseBitwiseORExpression); | |
parseBitwiseXORExpression = wrapTracking(extra.parseBitwiseXORExpression); | |
parseBlock = wrapTracking(extra.parseBlock); | |
parseFunctionSourceElements = wrapTracking(extra.parseFunctionSourceElements); | |
parseCatchClause = wrapTracking(extra.parseCatchClause); | |
parseComputedMember = wrapTracking(extra.parseComputedMember); | |
parseConditionalExpression = wrapTracking(extra.parseConditionalExpression); | |
parseConstLetDeclaration = wrapTracking(extra.parseConstLetDeclaration); | |
parseEqualityExpression = wrapTracking(extra.parseEqualityExpression); | |
parseExpression = wrapTracking(extra.parseExpression); | |
parseForVariableDeclaration = wrapTracking(extra.parseForVariableDeclaration); | |
parseFunctionDeclaration = wrapTracking(extra.parseFunctionDeclaration); | |
parseFunctionExpression = wrapTracking(extra.parseFunctionExpression); | |
parseLeftHandSideExpression = wrapTracking(parseLeftHandSideExpression); | |
parseLogicalANDExpression = wrapTracking(extra.parseLogicalANDExpression); | |
parseLogicalORExpression = wrapTracking(extra.parseLogicalORExpression); | |
parseMultiplicativeExpression = wrapTracking(extra.parseMultiplicativeExpression); | |
parseNewExpression = wrapTracking(extra.parseNewExpression); | |
parseNonComputedProperty = wrapTracking(extra.parseNonComputedProperty); | |
parseObjectProperty = wrapTracking(extra.parseObjectProperty); | |
parseObjectPropertyKey = wrapTracking(extra.parseObjectPropertyKey); | |
parsePostfixExpression = wrapTracking(extra.parsePostfixExpression); | |
parsePrimaryExpression = wrapTracking(extra.parsePrimaryExpression); | |
parseProgram = wrapTracking(extra.parseProgram); | |
parsePropertyFunction = wrapTracking(extra.parsePropertyFunction); | |
parseRelationalExpression = wrapTracking(extra.parseRelationalExpression); | |
parseStatement = wrapTracking(extra.parseStatement); | |
parseShiftExpression = wrapTracking(extra.parseShiftExpression); | |
parseSwitchCase = wrapTracking(extra.parseSwitchCase); | |
parseUnaryExpression = wrapTracking(extra.parseUnaryExpression); | |
parseVariableDeclaration = wrapTracking(extra.parseVariableDeclaration); | |
parseVariableIdentifier = wrapTracking(extra.parseVariableIdentifier); | |
} | |
if (typeof extra.tokens !== 'undefined') { | |
extra.advance = advance; | |
extra.scanRegExp = scanRegExp; | |
advance = collectToken; | |
scanRegExp = collectRegex; | |
} | |
} | |
function unpatch() { | |
if (typeof extra.skipComment === 'function') { | |
skipComment = extra.skipComment; | |
} | |
if (extra.raw) { | |
createLiteral = extra.createLiteral; | |
} | |
if (extra.range || extra.loc) { | |
parseAdditiveExpression = extra.parseAdditiveExpression; | |
parseAssignmentExpression = extra.parseAssignmentExpression; | |
parseBitwiseANDExpression = extra.parseBitwiseANDExpression; | |
parseBitwiseORExpression = extra.parseBitwiseORExpression; | |
parseBitwiseXORExpression = extra.parseBitwiseXORExpression; | |
parseBlock = extra.parseBlock; | |
parseFunctionSourceElements = extra.parseFunctionSourceElements; | |
parseCatchClause = extra.parseCatchClause; | |
parseComputedMember = extra.parseComputedMember; | |
parseConditionalExpression = extra.parseConditionalExpression; | |
parseConstLetDeclaration = extra.parseConstLetDeclaration; | |
parseEqualityExpression = extra.parseEqualityExpression; | |
parseExpression = extra.parseExpression; | |
parseForVariableDeclaration = extra.parseForVariableDeclaration; | |
parseFunctionDeclaration = extra.parseFunctionDeclaration; | |
parseFunctionExpression = extra.parseFunctionExpression; | |
parseGroupExpression = extra.parseGroupExpression; | |
parseLeftHandSideExpression = extra.parseLeftHandSideExpression; | |
parseLeftHandSideExpressionAllowCall = extra.parseLeftHandSideExpressionAllowCall; | |
parseLogicalANDExpression = extra.parseLogicalANDExpression; | |
parseLogicalORExpression = extra.parseLogicalORExpression; | |
parseMultiplicativeExpression = extra.parseMultiplicativeExpression; | |
parseNewExpression = extra.parseNewExpression; | |
parseNonComputedProperty = extra.parseNonComputedProperty; | |
parseObjectProperty = extra.parseObjectProperty; | |
parseObjectPropertyKey = extra.parseObjectPropertyKey; | |
parsePrimaryExpression = extra.parsePrimaryExpression; | |
parsePostfixExpression = extra.parsePostfixExpression; | |
parseProgram = extra.parseProgram; | |
parsePropertyFunction = extra.parsePropertyFunction; | |
parseRelationalExpression = extra.parseRelationalExpression; | |
parseStatement = extra.parseStatement; | |
parseShiftExpression = extra.parseShiftExpression; | |
parseSwitchCase = extra.parseSwitchCase; | |
parseUnaryExpression = extra.parseUnaryExpression; | |
parseVariableDeclaration = extra.parseVariableDeclaration; | |
parseVariableIdentifier = extra.parseVariableIdentifier; | |
} | |
if (typeof extra.scanRegExp === 'function') { | |
advance = extra.advance; | |
scanRegExp = extra.scanRegExp; | |
} | |
} | |
function stringToArray(str) { | |
var length = str.length, | |
result = [], | |
i; | |
for (i = 0; i < length; ++i) { | |
result[i] = str.charAt(i); | |
} | |
return result; | |
} | |
function parse(code, options) { | |
var program, toString; | |
toString = String; | |
if (typeof code !== 'string' && !(code instanceof String)) { | |
code = toString(code); | |
} | |
source = code; | |
index = 0; | |
lineNumber = (source.length > 0) ? 1 : 0; | |
lineStart = 0; | |
length = source.length; | |
buffer = null; | |
state = { | |
allowIn: true, | |
labelSet: {}, | |
inFunctionBody: false, | |
inIteration: false, | |
inSwitch: false | |
}; | |
extra = {}; | |
if (typeof options !== 'undefined') { | |
extra.range = (typeof options.range === 'boolean') && options.range; | |
extra.loc = (typeof options.loc === 'boolean') && options.loc; | |
extra.raw = (typeof options.raw === 'boolean') && options.raw; | |
if (typeof options.tokens === 'boolean' && options.tokens) { | |
extra.tokens = []; | |
} | |
if (typeof options.comment === 'boolean' && options.comment) { | |
extra.comments = []; | |
} | |
if (typeof options.tolerant === 'boolean' && options.tolerant) { | |
extra.errors = []; | |
} | |
} | |
if (length > 0) { | |
if (typeof source[0] === 'undefined') { | |
// Try first to convert to a string. This is good as fast path | |
// for old IE which understands string indexing for string | |
// literals only and not for string object. | |
if (code instanceof String) { | |
source = code.valueOf(); | |
} | |
// Force accessing the characters via an array. | |
if (typeof source[0] === 'undefined') { | |
source = stringToArray(code); | |
} | |
} | |
} | |
patch(); | |
try { | |
program = parseProgram(); | |
if (typeof extra.comments !== 'undefined') { | |
filterCommentLocation(); | |
program.comments = extra.comments; | |
} | |
if (typeof extra.tokens !== 'undefined') { | |
filterTokenLocation(); | |
program.tokens = extra.tokens; | |
} | |
if (typeof extra.errors !== 'undefined') { | |
program.errors = extra.errors; | |
} | |
if (extra.range || extra.loc) { | |
program.body = filterGroup(program.body); | |
} | |
} catch (e) { | |
throw e; | |
} finally { | |
unpatch(); | |
extra = {}; | |
} | |
return program; | |
} | |
// Sync with package.json. | |
exports.version = '1.0.4'; | |
exports.parse = parse; | |
// Deep copy. | |
exports.Syntax = (function () { | |
var name, types = {}; | |
if (typeof Object.create === 'function') { | |
types = Object.create(null); | |
} | |
for (name in Syntax) { | |
if (Syntax.hasOwnProperty(name)) { | |
types[name] = Syntax[name]; | |
} | |
} | |
if (typeof Object.freeze === 'function') { | |
Object.freeze(types); | |
} | |
return types; | |
}()); | |
})); | |
/* vim: set sw=4 ts=4 et tw=80 : */ | |
})() | |
},{}],17:[function(require,module,exports){ | |
"use strict" | |
function unique_pred(list, compare) { | |
var ptr = 1 | |
, len = list.length | |
, a=list[0], b=list[0] | |
for(var i=1; i<len; ++i) { | |
b = a | |
a = list[i] | |
if(compare(a, b)) { | |
if(i === ptr) { | |
ptr++ | |
continue | |
} | |
list[ptr++] = a | |
} | |
} | |
list.length = ptr | |
return list | |
} | |
function unique_eq(list) { | |
var ptr = 1 | |
, len = list.length | |
, a=list[0], b = list[0] | |
for(var i=1; i<len; ++i, b=a) { | |
b = a | |
a = list[i] | |
if(a !== b) { | |
if(i === ptr) { | |
ptr++ | |
continue | |
} | |
list[ptr++] = a | |
} | |
} | |
list.length = ptr | |
return list | |
} | |
function unique(list, compare, sorted) { | |
if(list.length === 0) { | |
return [] | |
} | |
if(compare) { | |
if(!sorted) { | |
list.sort(compare) | |
} | |
return unique_pred(list, compare) | |
} | |
if(!sorted) { | |
list.sort() | |
} | |
return unique_eq(list) | |
} | |
module.exports = unique | |
},{}],18:[function(require,module,exports){ | |
(function(){/* | |
Copyright (C) 2012 Ariya Hidayat <[email protected]> | |
Copyright (C) 2012 Mathias Bynens <[email protected]> | |
Copyright (C) 2012 Joost-Wim Boekesteijn <[email protected]> | |
Copyright (C) 2012 Kris Kowal <[email protected]> | |
Copyright (C) 2012 Yusuke Suzuki <[email protected]> | |
Copyright (C) 2012 Arpad Borsos <[email protected]> | |
Copyright (C) 2011 Ariya Hidayat <[email protected]> | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions are met: | |
* Redistributions of source code must retain the above copyright | |
notice, this list of conditions and the following disclaimer. | |
* Redistributions in binary form must reproduce the above copyright | |
notice, this list of conditions and the following disclaimer in the | |
documentation and/or other materials provided with the distribution. | |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY | |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
*/ | |
/*jslint bitwise:true plusplus:true */ | |
/*global esprima:true, define:true, exports:true, window: true, | |
throwError: true, createLiteral: true, generateStatement: true, | |
parseAssignmentExpression: true, parseBlock: true, parseExpression: true, | |
parseFunctionDeclaration: true, parseFunctionExpression: true, | |
parseFunctionSourceElements: true, parseVariableIdentifier: true, | |
parseLeftHandSideExpression: true, | |
parseStatement: true, parseSourceElement: true */ | |
(function (root, factory) { | |
'use strict'; | |
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, | |
// Rhino, and plain browser loading. | |
if (typeof define === 'function' && define.amd) { | |
define(['exports'], factory); | |
} else if (typeof exports !== 'undefined') { | |
factory(exports); | |
} else { | |
factory((root.esprima = {})); | |
} | |
}(this, function (exports) { | |
'use strict'; | |
var Token, | |
TokenName, | |
Syntax, | |
PropertyKind, | |
Messages, | |
Regex, | |
source, | |
strict, | |
index, | |
lineNumber, | |
lineStart, | |
length, | |
buffer, | |
state, | |
extra; | |
Token = { | |
BooleanLiteral: 1, | |
EOF: 2, | |
Identifier: 3, | |
Keyword: 4, | |
NullLiteral: 5, | |
NumericLiteral: 6, | |
Punctuator: 7, | |
StringLiteral: 8 | |
}; | |
TokenName = {}; | |
TokenName[Token.BooleanLiteral] = 'Boolean'; | |
TokenName[Token.EOF] = '<end>'; | |
TokenName[Token.Identifier] = 'Identifier'; | |
TokenName[Token.Keyword] = 'Keyword'; | |
TokenName[Token.NullLiteral] = 'Null'; | |
TokenName[Token.NumericLiteral] = 'Numeric'; | |
TokenName[Token.Punctuator] = 'Punctuator'; | |
TokenName[Token.StringLiteral] = 'String'; | |
Syntax = { | |
AssignmentExpression: 'AssignmentExpression', | |
ArrayExpression: 'ArrayExpression', | |
BlockStatement: 'BlockStatement', | |
BinaryExpression: 'BinaryExpression', | |
BreakStatement: 'BreakStatement', | |
CallExpression: 'CallExpression', | |
CatchClause: 'CatchClause', | |
ConditionalExpression: 'ConditionalExpression', | |
ContinueStatement: 'ContinueStatement', | |
DoWhileStatement: 'DoWhileStatement', | |
DebuggerStatement: 'DebuggerStatement', | |
EmptyStatement: 'EmptyStatement', | |
ExpressionStatement: 'ExpressionStatement', | |
ForStatement: 'ForStatement', | |
ForInStatement: 'ForInStatement', | |
FunctionDeclaration: 'FunctionDeclaration', | |
FunctionExpression: 'FunctionExpression', | |
Identifier: 'Identifier', | |
IfStatement: 'IfStatement', | |
Literal: 'Literal', | |
LabeledStatement: 'LabeledStatement', | |
LogicalExpression: 'LogicalExpression', | |
MemberExpression: 'MemberExpression', | |
NewExpression: 'NewExpression', | |
ObjectExpression: 'ObjectExpression', | |
Program: 'Program', | |
Property: 'Property', | |
ReturnStatement: 'ReturnStatement', | |
SequenceExpression: 'SequenceExpression', | |
SwitchStatement: 'SwitchStatement', | |
SwitchCase: 'SwitchCase', | |
ThisExpression: 'ThisExpression', | |
ThrowStatement: 'ThrowStatement', | |
TryStatement: 'TryStatement', | |
UnaryExpression: 'UnaryExpression', | |
UpdateExpression: 'UpdateExpression', | |
VariableDeclaration: 'VariableDeclaration', | |
VariableDeclarator: 'VariableDeclarator', | |
WhileStatement: 'WhileStatement', | |
WithStatement: 'WithStatement' | |
}; | |
PropertyKind = { | |
Data: 1, | |
Get: 2, | |
Set: 4 | |
}; | |
// Error messages should be identical to V8. | |
Messages = { | |
UnexpectedToken: 'Unexpected token %0', | |
UnexpectedNumber: 'Unexpected number', | |
UnexpectedString: 'Unexpected string', | |
UnexpectedIdentifier: 'Unexpected identifier', | |
UnexpectedReserved: 'Unexpected reserved word', | |
UnexpectedEOS: 'Unexpected end of input', | |
NewlineAfterThrow: 'Illegal newline after throw', | |
InvalidRegExp: 'Invalid regular expression', | |
UnterminatedRegExp: 'Invalid regular expression: missing /', | |
InvalidLHSInAssignment: 'Invalid left-hand side in assignment', | |
InvalidLHSInForIn: 'Invalid left-hand side in for-in', | |
MultipleDefaultsInSwitch: 'More than one default clause in switch statement', | |
NoCatchOrFinally: 'Missing catch or finally after try', | |
UnknownLabel: 'Undefined label \'%0\'', | |
Redeclaration: '%0 \'%1\' has already been declared', | |
IllegalContinue: 'Illegal continue statement', | |
IllegalBreak: 'Illegal break statement', | |
IllegalReturn: 'Illegal return statement', | |
StrictModeWith: 'Strict mode code may not include a with statement', | |
StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode', | |
StrictVarName: 'Variable name may not be eval or arguments in strict mode', | |
StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode', | |
StrictParamDupe: 'Strict mode function may not have duplicate parameter names', | |
StrictFunctionName: 'Function name may not be eval or arguments in strict mode', | |
StrictOctalLiteral: 'Octal literals are not allowed in strict mode.', | |
StrictDelete: 'Delete of an unqualified identifier in strict mode.', | |
StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode', | |
AccessorDataProperty: 'Object literal may not have data and accessor property with the same name', | |
AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name', | |
StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode', | |
StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode', | |
StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode', | |
StrictReservedWord: 'Use of future reserved word in strict mode' | |
}; | |
// See also tools/generate-unicode-regex.py. | |
Regex = { | |
NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'), | |
NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]') | |
}; | |
// Ensure the condition is true, otherwise throw an error. | |
// This is only to have a better contract semantic, i.e. another safety net | |
// to catch a logic error. The condition shall be fulfilled in normal case. | |
// Do NOT use this to enforce a certain condition on any user input. | |
function assert(condition, message) { | |
if (!condition) { | |
throw new Error('ASSERT: ' + message); | |
} | |
} | |
function sliceSource(from, to) { | |
return source.slice(from, to); | |
} | |
if (typeof 'esprima'[0] === 'undefined') { | |
sliceSource = function sliceArraySource(from, to) { | |
return source.slice(from, to).join(''); | |
}; | |
} | |
function isDecimalDigit(ch) { | |
return '0123456789'.indexOf(ch) >= 0; | |
} | |
function isHexDigit(ch) { | |
return '0123456789abcdefABCDEF'.indexOf(ch) >= 0; | |
} | |
function isOctalDigit(ch) { | |
return '01234567'.indexOf(ch) >= 0; | |
} | |
// 7.2 White Space | |
function isWhiteSpace(ch) { | |
return (ch === ' ') || (ch === '\u0009') || (ch === '\u000B') || | |
(ch === '\u000C') || (ch === '\u00A0') || | |
(ch.charCodeAt(0) >= 0x1680 && | |
'\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'.indexOf(ch) >= 0); | |
} | |
// 7.3 Line Terminators | |
function isLineTerminator(ch) { | |
return (ch === '\n' || ch === '\r' || ch === '\u2028' || ch === '\u2029'); | |
} | |
// 7.6 Identifier Names and Identifiers | |
function isIdentifierStart(ch) { | |
return (ch === '$') || (ch === '_') || (ch === '\\') || | |
(ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || | |
((ch.charCodeAt(0) >= 0x80) && Regex.NonAsciiIdentifierStart.test(ch)); | |
} | |
function isIdentifierPart(ch) { | |
return (ch === '$') || (ch === '_') || (ch === '\\') || | |
(ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || | |
((ch >= '0') && (ch <= '9')) || | |
((ch.charCodeAt(0) >= 0x80) && Regex.NonAsciiIdentifierPart.test(ch)); | |
} | |
// 7.6.1.2 Future Reserved Words | |
function isFutureReservedWord(id) { | |
switch (id) { | |
// Future reserved words. | |
case 'class': | |
case 'enum': | |
case 'export': | |
case 'extends': | |
case 'import': | |
case 'super': | |
return true; | |
} | |
return false; | |
} | |
function isStrictModeReservedWord(id) { | |
switch (id) { | |
// Strict Mode reserved words. | |
case 'implements': | |
case 'interface': | |
case 'package': | |
case 'private': | |
case 'protected': | |
case 'public': | |
case 'static': | |
case 'yield': | |
case 'let': | |
return true; | |
} | |
return false; | |
} | |
function isRestrictedWord(id) { | |
return id === 'eval' || id === 'arguments'; | |
} | |
// 7.6.1.1 Keywords | |
function isKeyword(id) { | |
var keyword = false; | |
switch (id.length) { | |
case 2: | |
keyword = (id === 'if') || (id === 'in') || (id === 'do'); | |
break; | |
case 3: | |
keyword = (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try'); | |
break; | |
case 4: | |
keyword = (id === 'this') || (id === 'else') || (id === 'case') || (id === 'void') || (id === 'with'); | |
break; | |
case 5: | |
keyword = (id === 'while') || (id === 'break') || (id === 'catch') || (id === 'throw'); | |
break; | |
case 6: | |
keyword = (id === 'return') || (id === 'typeof') || (id === 'delete') || (id === 'switch'); | |
break; | |
case 7: | |
keyword = (id === 'default') || (id === 'finally'); | |
break; | |
case 8: | |
keyword = (id === 'function') || (id === 'continue') || (id === 'debugger'); | |
break; | |
case 10: | |
keyword = (id === 'instanceof'); | |
break; | |
} | |
if (keyword) { | |
return true; | |
} | |
switch (id) { | |
// Future reserved words. | |
// 'const' is specialized as Keyword in V8. | |
case 'const': | |
return true; | |
// For compatiblity to SpiderMonkey and ES.next | |
case 'yield': | |
case 'let': | |
return true; | |
} | |
if (strict && isStrictModeReservedWord(id)) { | |
return true; | |
} | |
return isFutureReservedWord(id); | |
} | |
// 7.4 Comments | |
function skipComment() { | |
var ch, blockComment, lineComment; | |
blockComment = false; | |
lineComment = false; | |
while (index < length) { | |
ch = source[index]; | |
if (lineComment) { | |
ch = source[index++]; | |
if (isLineTerminator(ch)) { | |
lineComment = false; | |
if (ch === '\r' && source[index] === '\n') { | |
++index; | |
} | |
++lineNumber; | |
lineStart = index; | |
} | |
} else if (blockComment) { | |
if (isLineTerminator(ch)) { | |
if (ch === '\r' && source[index + 1] === '\n') { | |
++index; | |
} | |
++lineNumber; | |
++index; | |
lineStart = index; | |
if (index >= length) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} else { | |
ch = source[index++]; | |
if (index >= length) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
if (ch === '*') { | |
ch = source[index]; | |
if (ch === '/') { | |
++index; | |
blockComment = false; | |
} | |
} | |
} | |
} else if (ch === '/') { | |
ch = source[index + 1]; | |
if (ch === '/') { | |
index += 2; | |
lineComment = true; | |
} else if (ch === '*') { | |
index += 2; | |
blockComment = true; | |
if (index >= length) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} else { | |
break; | |
} | |
} else if (isWhiteSpace(ch)) { | |
++index; | |
} else if (isLineTerminator(ch)) { | |
++index; | |
if (ch === '\r' && source[index] === '\n') { | |
++index; | |
} | |
++lineNumber; | |
lineStart = index; | |
} else { | |
break; | |
} | |
} | |
} | |
function scanHexEscape(prefix) { | |
var i, len, ch, code = 0; | |
len = (prefix === 'u') ? 4 : 2; | |
for (i = 0; i < len; ++i) { | |
if (index < length && isHexDigit(source[index])) { | |
ch = source[index++]; | |
code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase()); | |
} else { | |
return ''; | |
} | |
} | |
return String.fromCharCode(code); | |
} | |
function scanIdentifier() { | |
var ch, start, id, restore; | |
ch = source[index]; | |
if (!isIdentifierStart(ch)) { | |
return; | |
} | |
start = index; | |
if (ch === '\\') { | |
++index; | |
if (source[index] !== 'u') { | |
return; | |
} | |
++index; | |
restore = index; | |
ch = scanHexEscape('u'); | |
if (ch) { | |
if (ch === '\\' || !isIdentifierStart(ch)) { | |
return; | |
} | |
id = ch; | |
} else { | |
index = restore; | |
id = 'u'; | |
} | |
} else { | |
id = source[index++]; | |
} | |
while (index < length) { | |
ch = source[index]; | |
if (!isIdentifierPart(ch)) { | |
break; | |
} | |
if (ch === '\\') { | |
++index; | |
if (source[index] !== 'u') { | |
return; | |
} | |
++index; | |
restore = index; | |
ch = scanHexEscape('u'); | |
if (ch) { | |
if (ch === '\\' || !isIdentifierPart(ch)) { | |
return; | |
} | |
id += ch; | |
} else { | |
index = restore; | |
id += 'u'; | |
} | |
} else { | |
id += source[index++]; | |
} | |
} | |
// There is no keyword or literal with only one character. | |
// Thus, it must be an identifier. | |
if (id.length === 1) { | |
return { | |
type: Token.Identifier, | |
value: id, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (isKeyword(id)) { | |
return { | |
type: Token.Keyword, | |
value: id, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// 7.8.1 Null Literals | |
if (id === 'null') { | |
return { | |
type: Token.NullLiteral, | |
value: id, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// 7.8.2 Boolean Literals | |
if (id === 'true' || id === 'false') { | |
return { | |
type: Token.BooleanLiteral, | |
value: id, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
return { | |
type: Token.Identifier, | |
value: id, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// 7.7 Punctuators | |
function scanPunctuator() { | |
var start = index, | |
ch1 = source[index], | |
ch2, | |
ch3, | |
ch4; | |
// Check for most common single-character punctuators. | |
if (ch1 === ';' || ch1 === '{' || ch1 === '}') { | |
++index; | |
return { | |
type: Token.Punctuator, | |
value: ch1, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (ch1 === ',' || ch1 === '(' || ch1 === ')') { | |
++index; | |
return { | |
type: Token.Punctuator, | |
value: ch1, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// Dot (.) can also start a floating-point number, hence the need | |
// to check the next character. | |
ch2 = source[index + 1]; | |
if (ch1 === '.' && !isDecimalDigit(ch2)) { | |
return { | |
type: Token.Punctuator, | |
value: source[index++], | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// Peek more characters. | |
ch3 = source[index + 2]; | |
ch4 = source[index + 3]; | |
// 4-character punctuator: >>>= | |
if (ch1 === '>' && ch2 === '>' && ch3 === '>') { | |
if (ch4 === '=') { | |
index += 4; | |
return { | |
type: Token.Punctuator, | |
value: '>>>=', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
} | |
// 3-character punctuators: === !== >>> <<= >>= | |
if (ch1 === '=' && ch2 === '=' && ch3 === '=') { | |
index += 3; | |
return { | |
type: Token.Punctuator, | |
value: '===', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (ch1 === '!' && ch2 === '=' && ch3 === '=') { | |
index += 3; | |
return { | |
type: Token.Punctuator, | |
value: '!==', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (ch1 === '>' && ch2 === '>' && ch3 === '>') { | |
index += 3; | |
return { | |
type: Token.Punctuator, | |
value: '>>>', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (ch1 === '<' && ch2 === '<' && ch3 === '=') { | |
index += 3; | |
return { | |
type: Token.Punctuator, | |
value: '<<=', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (ch1 === '>' && ch2 === '>' && ch3 === '=') { | |
index += 3; | |
return { | |
type: Token.Punctuator, | |
value: '>>=', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// 2-character punctuators: <= >= == != ++ -- << >> && || | |
// += -= *= %= &= |= ^= /= | |
if (ch2 === '=') { | |
if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) { | |
index += 2; | |
return { | |
type: Token.Punctuator, | |
value: ch1 + ch2, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
} | |
if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0)) { | |
if ('+-<>&|'.indexOf(ch2) >= 0) { | |
index += 2; | |
return { | |
type: Token.Punctuator, | |
value: ch1 + ch2, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
} | |
// The remaining 1-character punctuators. | |
if ('[]<>+-*%&|^!~?:=/'.indexOf(ch1) >= 0) { | |
return { | |
type: Token.Punctuator, | |
value: source[index++], | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
} | |
// 7.8.3 Numeric Literals | |
function scanNumericLiteral() { | |
var number, start, ch; | |
ch = source[index]; | |
assert(isDecimalDigit(ch) || (ch === '.'), | |
'Numeric literal must start with a decimal digit or a decimal point'); | |
start = index; | |
number = ''; | |
if (ch !== '.') { | |
number = source[index++]; | |
ch = source[index]; | |
// Hex number starts with '0x'. | |
// Octal number starts with '0'. | |
if (number === '0') { | |
if (ch === 'x' || ch === 'X') { | |
number += source[index++]; | |
while (index < length) { | |
ch = source[index]; | |
if (!isHexDigit(ch)) { | |
break; | |
} | |
number += source[index++]; | |
} | |
if (number.length <= 2) { | |
// only 0x | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
if (index < length) { | |
ch = source[index]; | |
if (isIdentifierStart(ch)) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} | |
return { | |
type: Token.NumericLiteral, | |
value: parseInt(number, 16), | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} else if (isOctalDigit(ch)) { | |
number += source[index++]; | |
while (index < length) { | |
ch = source[index]; | |
if (!isOctalDigit(ch)) { | |
break; | |
} | |
number += source[index++]; | |
} | |
if (index < length) { | |
ch = source[index]; | |
if (isIdentifierStart(ch) || isDecimalDigit(ch)) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} | |
return { | |
type: Token.NumericLiteral, | |
value: parseInt(number, 8), | |
octal: true, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// decimal number starts with '0' such as '09' is illegal. | |
if (isDecimalDigit(ch)) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} | |
while (index < length) { | |
ch = source[index]; | |
if (!isDecimalDigit(ch)) { | |
break; | |
} | |
number += source[index++]; | |
} | |
} | |
if (ch === '.') { | |
number += source[index++]; | |
while (index < length) { | |
ch = source[index]; | |
if (!isDecimalDigit(ch)) { | |
break; | |
} | |
number += source[index++]; | |
} | |
} | |
if (ch === 'e' || ch === 'E') { | |
number += source[index++]; | |
ch = source[index]; | |
if (ch === '+' || ch === '-') { | |
number += source[index++]; | |
} | |
ch = source[index]; | |
if (isDecimalDigit(ch)) { | |
number += source[index++]; | |
while (index < length) { | |
ch = source[index]; | |
if (!isDecimalDigit(ch)) { | |
break; | |
} | |
number += source[index++]; | |
} | |
} else { | |
ch = 'character ' + ch; | |
if (index >= length) { | |
ch = '<end>'; | |
} | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} | |
if (index < length) { | |
ch = source[index]; | |
if (isIdentifierStart(ch)) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} | |
return { | |
type: Token.NumericLiteral, | |
value: parseFloat(number), | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// 7.8.4 String Literals | |
function scanStringLiteral() { | |
var str = '', quote, start, ch, code, unescaped, restore, octal = false; | |
quote = source[index]; | |
assert((quote === '\'' || quote === '"'), | |
'String literal must starts with a quote'); | |
start = index; | |
++index; | |
while (index < length) { | |
ch = source[index++]; | |
if (ch === quote) { | |
quote = ''; | |
break; | |
} else if (ch === '\\') { | |
ch = source[index++]; | |
if (!isLineTerminator(ch)) { | |
switch (ch) { | |
case 'n': | |
str += '\n'; | |
break; | |
case 'r': | |
str += '\r'; | |
break; | |
case 't': | |
str += '\t'; | |
break; | |
case 'u': | |
case 'x': | |
restore = index; | |
unescaped = scanHexEscape(ch); | |
if (unescaped) { | |
str += unescaped; | |
} else { | |
index = restore; | |
str += ch; | |
} | |
break; | |
case 'b': | |
str += '\b'; | |
break; | |
case 'f': | |
str += '\f'; | |
break; | |
case 'v': | |
str += '\x0B'; | |
break; | |
default: | |
if (isOctalDigit(ch)) { | |
code = '01234567'.indexOf(ch); | |
// \0 is not octal escape sequence | |
if (code !== 0) { | |
octal = true; | |
} | |
if (index < length && isOctalDigit(source[index])) { | |
octal = true; | |
code = code * 8 + '01234567'.indexOf(source[index++]); | |
// 3 digits are only allowed when string starts | |
// with 0, 1, 2, 3 | |
if ('0123'.indexOf(ch) >= 0 && | |
index < length && | |
isOctalDigit(source[index])) { | |
code = code * 8 + '01234567'.indexOf(source[index++]); | |
} | |
} | |
str += String.fromCharCode(code); | |
} else { | |
str += ch; | |
} | |
break; | |
} | |
} else { | |
++lineNumber; | |
if (ch === '\r' && source[index] === '\n') { | |
++index; | |
} | |
} | |
} else if (isLineTerminator(ch)) { | |
break; | |
} else { | |
str += ch; | |
} | |
} | |
if (quote !== '') { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
return { | |
type: Token.StringLiteral, | |
value: str, | |
octal: octal, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
function scanRegExp() { | |
var str, ch, start, pattern, flags, value, classMarker = false, restore, terminated = false; | |
buffer = null; | |
skipComment(); | |
start = index; | |
ch = source[index]; | |
assert(ch === '/', 'Regular expression literal must start with a slash'); | |
str = source[index++]; | |
while (index < length) { | |
ch = source[index++]; | |
str += ch; | |
if (ch === '\\') { | |
ch = source[index++]; | |
// ECMA-262 7.8.5 | |
if (isLineTerminator(ch)) { | |
throwError({}, Messages.UnterminatedRegExp); | |
} | |
str += ch; | |
} else if (classMarker) { | |
if (ch === ']') { | |
classMarker = false; | |
} | |
} else { | |
if (ch === '/') { | |
terminated = true; | |
break; | |
} else if (ch === '[') { | |
classMarker = true; | |
} else if (isLineTerminator(ch)) { | |
throwError({}, Messages.UnterminatedRegExp); | |
} | |
} | |
} | |
if (!terminated) { | |
throwError({}, Messages.UnterminatedRegExp); | |
} | |
// Exclude leading and trailing slash. | |
pattern = str.substr(1, str.length - 2); | |
flags = ''; | |
while (index < length) { | |
ch = source[index]; | |
if (!isIdentifierPart(ch)) { | |
break; | |
} | |
++index; | |
if (ch === '\\' && index < length) { | |
ch = source[index]; | |
if (ch === 'u') { | |
++index; | |
restore = index; | |
ch = scanHexEscape('u'); | |
if (ch) { | |
flags += ch; | |
str += '\\u'; | |
for (; restore < index; ++restore) { | |
str += source[restore]; | |
} | |
} else { | |
index = restore; | |
flags += 'u'; | |
str += '\\u'; | |
} | |
} else { | |
str += '\\'; | |
} | |
} else { | |
flags += ch; | |
str += ch; | |
} | |
} | |
try { | |
value = new RegExp(pattern, flags); | |
} catch (e) { | |
throwError({}, Messages.InvalidRegExp); | |
} | |
return { | |
literal: str, | |
value: value, | |
range: [start, index] | |
}; | |
} | |
function isIdentifierName(token) { | |
return token.type === Token.Identifier || | |
token.type === Token.Keyword || | |
token.type === Token.BooleanLiteral || | |
token.type === Token.NullLiteral; | |
} | |
function advance() { | |
var ch, token; | |
skipComment(); | |
if (index >= length) { | |
return { | |
type: Token.EOF, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [index, index] | |
}; | |
} | |
token = scanPunctuator(); | |
if (typeof token !== 'undefined') { | |
return token; | |
} | |
ch = source[index]; | |
if (ch === '\'' || ch === '"') { | |
return scanStringLiteral(); | |
} | |
if (ch === '.' || isDecimalDigit(ch)) { | |
return scanNumericLiteral(); | |
} | |
token = scanIdentifier(); | |
if (typeof token !== 'undefined') { | |
return token; | |
} | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
function lex() { | |
var token; | |
if (buffer) { | |
index = buffer.range[1]; | |
lineNumber = buffer.lineNumber; | |
lineStart = buffer.lineStart; | |
token = buffer; | |
buffer = null; | |
return token; | |
} | |
buffer = null; | |
return advance(); | |
} | |
function lookahead() { | |
var pos, line, start; | |
if (buffer !== null) { | |
return buffer; | |
} | |
pos = index; | |
line = lineNumber; | |
start = lineStart; | |
buffer = advance(); | |
index = pos; | |
lineNumber = line; | |
lineStart = start; | |
return buffer; | |
} | |
// Return true if there is a line terminator before the next token. | |
function peekLineTerminator() { | |
var pos, line, start, found; | |
pos = index; | |
line = lineNumber; | |
start = lineStart; | |
skipComment(); | |
found = lineNumber !== line; | |
index = pos; | |
lineNumber = line; | |
lineStart = start; | |
return found; | |
} | |
// Throw an exception | |
function throwError(token, messageFormat) { | |
var error, | |
args = Array.prototype.slice.call(arguments, 2), | |
msg = messageFormat.replace( | |
/%(\d)/g, | |
function (whole, index) { | |
return args[index] || ''; | |
} | |
); | |
if (typeof token.lineNumber === 'number') { | |
error = new Error('Line ' + token.lineNumber + ': ' + msg); | |
error.index = token.range[0]; | |
error.lineNumber = token.lineNumber; | |
error.column = token.range[0] - lineStart + 1; | |
} else { | |
error = new Error('Line ' + lineNumber + ': ' + msg); | |
error.index = index; | |
error.lineNumber = lineNumber; | |
error.column = index - lineStart + 1; | |
} | |
throw error; | |
} | |
function throwErrorTolerant() { | |
try { | |
throwError.apply(null, arguments); | |
} catch (e) { | |
if (extra.errors) { | |
extra.errors.push(e); | |
} else { | |
throw e; | |
} | |
} | |
} | |
// Throw an exception because of the token. | |
function throwUnexpected(token) { | |
if (token.type === Token.EOF) { | |
throwError(token, Messages.UnexpectedEOS); | |
} | |
if (token.type === Token.NumericLiteral) { | |
throwError(token, Messages.UnexpectedNumber); | |
} | |
if (token.type === Token.StringLiteral) { | |
throwError(token, Messages.UnexpectedString); | |
} | |
if (token.type === Token.Identifier) { | |
throwError(token, Messages.UnexpectedIdentifier); | |
} | |
if (token.type === Token.Keyword) { | |
if (isFutureReservedWord(token.value)) { | |
throwError(token, Messages.UnexpectedReserved); | |
} else if (strict && isStrictModeReservedWord(token.value)) { | |
throwErrorTolerant(token, Messages.StrictReservedWord); | |
return; | |
} | |
throwError(token, Messages.UnexpectedToken, token.value); | |
} | |
// BooleanLiteral, NullLiteral, or Punctuator. | |
throwError(token, Messages.UnexpectedToken, token.value); | |
} | |
// Expect the next token to match the specified punctuator. | |
// If not, an exception will be thrown. | |
function expect(value) { | |
var token = lex(); | |
if (token.type !== Token.Punctuator || token.value !== value) { | |
throwUnexpected(token); | |
} | |
} | |
// Expect the next token to match the specified keyword. | |
// If not, an exception will be thrown. | |
function expectKeyword(keyword) { | |
var token = lex(); | |
if (token.type !== Token.Keyword || token.value !== keyword) { | |
throwUnexpected(token); | |
} | |
} | |
// Return true if the next token matches the specified punctuator. | |
function match(value) { | |
var token = lookahead(); | |
return token.type === Token.Punctuator && token.value === value; | |
} | |
// Return true if the next token matches the specified keyword | |
function matchKeyword(keyword) { | |
var token = lookahead(); | |
return token.type === Token.Keyword && token.value === keyword; | |
} | |
// Return true if the next token is an assignment operator | |
function matchAssign() { | |
var token = lookahead(), | |
op = token.value; | |
if (token.type !== Token.Punctuator) { | |
return false; | |
} | |
return op === '=' || | |
op === '*=' || | |
op === '/=' || | |
op === '%=' || | |
op === '+=' || | |
op === '-=' || | |
op === '<<=' || | |
op === '>>=' || | |
op === '>>>=' || | |
op === '&=' || | |
op === '^=' || | |
op === '|='; | |
} | |
function consumeSemicolon() { | |
var token, line; | |
// Catch the very common case first. | |
if (source[index] === ';') { | |
lex(); | |
return; | |
} | |
line = lineNumber; | |
skipComment(); | |
if (lineNumber !== line) { | |
return; | |
} | |
if (match(';')) { | |
lex(); | |
return; | |
} | |
token = lookahead(); | |
if (token.type !== Token.EOF && !match('}')) { | |
throwUnexpected(token); | |
} | |
} | |
// Return true if provided expression is LeftHandSideExpression | |
function isLeftHandSide(expr) { | |
return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression; | |
} | |
// 11.1.4 Array Initialiser | |
function parseArrayInitialiser() { | |
var elements = []; | |
expect('['); | |
while (!match(']')) { | |
if (match(',')) { | |
lex(); | |
elements.push(null); | |
} else { | |
elements.push(parseAssignmentExpression()); | |
if (!match(']')) { | |
expect(','); | |
} | |
} | |
} | |
expect(']'); | |
return { | |
type: Syntax.ArrayExpression, | |
elements: elements | |
}; | |
} | |
// 11.1.5 Object Initialiser | |
function parsePropertyFunction(param, first) { | |
var previousStrict, body; | |
previousStrict = strict; | |
body = parseFunctionSourceElements(); | |
if (first && strict && isRestrictedWord(param[0].name)) { | |
throwErrorTolerant(first, Messages.StrictParamName); | |
} | |
strict = previousStrict; | |
return { | |
type: Syntax.FunctionExpression, | |
id: null, | |
params: param, | |
defaults: [], | |
body: body, | |
rest: null, | |
generator: false, | |
expression: false | |
}; | |
} | |
function parseObjectPropertyKey() { | |
var token = lex(); | |
// Note: This function is called only from parseObjectProperty(), where | |
// EOF and Punctuator tokens are already filtered out. | |
if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) { | |
if (strict && token.octal) { | |
throwErrorTolerant(token, Messages.StrictOctalLiteral); | |
} | |
return createLiteral(token); | |
} | |
return { | |
type: Syntax.Identifier, | |
name: token.value | |
}; | |
} | |
function parseObjectProperty() { | |
var token, key, id, param; | |
token = lookahead(); | |
if (token.type === Token.Identifier) { | |
id = parseObjectPropertyKey(); | |
// Property Assignment: Getter and Setter. | |
if (token.value === 'get' && !match(':')) { | |
key = parseObjectPropertyKey(); | |
expect('('); | |
expect(')'); | |
return { | |
type: Syntax.Property, | |
key: key, | |
value: parsePropertyFunction([]), | |
kind: 'get' | |
}; | |
} else if (token.value === 'set' && !match(':')) { | |
key = parseObjectPropertyKey(); | |
expect('('); | |
token = lookahead(); | |
if (token.type !== Token.Identifier) { | |
expect(')'); | |
throwErrorTolerant(token, Messages.UnexpectedToken, token.value); | |
return { | |
type: Syntax.Property, | |
key: key, | |
value: parsePropertyFunction([]), | |
kind: 'set' | |
}; | |
} else { | |
param = [ parseVariableIdentifier() ]; | |
expect(')'); | |
return { | |
type: Syntax.Property, | |
key: key, | |
value: parsePropertyFunction(param, token), | |
kind: 'set' | |
}; | |
} | |
} else { | |
expect(':'); | |
return { | |
type: Syntax.Property, | |
key: id, | |
value: parseAssignmentExpression(), | |
kind: 'init' | |
}; | |
} | |
} else if (token.type === Token.EOF || token.type === Token.Punctuator) { | |
throwUnexpected(token); | |
} else { | |
key = parseObjectPropertyKey(); | |
expect(':'); | |
return { | |
type: Syntax.Property, | |
key: key, | |
value: parseAssignmentExpression(), | |
kind: 'init' | |
}; | |
} | |
} | |
function parseObjectInitialiser() { | |
var properties = [], property, name, kind, map = {}, toString = String; | |
expect('{'); | |
while (!match('}')) { | |
property = parseObjectProperty(); | |
if (property.key.type === Syntax.Identifier) { | |
name = property.key.name; | |
} else { | |
name = toString(property.key.value); | |
} | |
kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set; | |
if (Object.prototype.hasOwnProperty.call(map, name)) { | |
if (map[name] === PropertyKind.Data) { | |
if (strict && kind === PropertyKind.Data) { | |
throwErrorTolerant({}, Messages.StrictDuplicateProperty); | |
} else if (kind !== PropertyKind.Data) { | |
throwErrorTolerant({}, Messages.AccessorDataProperty); | |
} | |
} else { | |
if (kind === PropertyKind.Data) { | |
throwErrorTolerant({}, Messages.AccessorDataProperty); | |
} else if (map[name] & kind) { | |
throwErrorTolerant({}, Messages.AccessorGetSet); | |
} | |
} | |
map[name] |= kind; | |
} else { | |
map[name] = kind; | |
} | |
properties.push(property); | |
if (!match('}')) { | |
expect(','); | |
} | |
} | |
expect('}'); | |
return { | |
type: Syntax.ObjectExpression, | |
properties: properties | |
}; | |
} | |
// 11.1.6 The Grouping Operator | |
function parseGroupExpression() { | |
var expr; | |
expect('('); | |
expr = parseExpression(); | |
expect(')'); | |
return expr; | |
} | |
// 11.1 Primary Expressions | |
function parsePrimaryExpression() { | |
var token = lookahead(), | |
type = token.type; | |
if (type === Token.Identifier) { | |
return { | |
type: Syntax.Identifier, | |
name: lex().value | |
}; | |
} | |
if (type === Token.StringLiteral || type === Token.NumericLiteral) { | |
if (strict && token.octal) { | |
throwErrorTolerant(token, Messages.StrictOctalLiteral); | |
} | |
return createLiteral(lex()); | |
} | |
if (type === Token.Keyword) { | |
if (matchKeyword('this')) { | |
lex(); | |
return { | |
type: Syntax.ThisExpression | |
}; | |
} | |
if (matchKeyword('function')) { | |
return parseFunctionExpression(); | |
} | |
} | |
if (type === Token.BooleanLiteral) { | |
lex(); | |
token.value = (token.value === 'true'); | |
return createLiteral(token); | |
} | |
if (type === Token.NullLiteral) { | |
lex(); | |
token.value = null; | |
return createLiteral(token); | |
} | |
if (match('[')) { | |
return parseArrayInitialiser(); | |
} | |
if (match('{')) { | |
return parseObjectInitialiser(); | |
} | |
if (match('(')) { | |
return parseGroupExpression(); | |
} | |
if (match('/') || match('/=')) { | |
return createLiteral(scanRegExp()); | |
} | |
return throwUnexpected(lex()); | |
} | |
// 11.2 Left-Hand-Side Expressions | |
function parseArguments() { | |
var args = []; | |
expect('('); | |
if (!match(')')) { | |
while (index < length) { | |
args.push(parseAssignmentExpression()); | |
if (match(')')) { | |
break; | |
} | |
expect(','); | |
} | |
} | |
expect(')'); | |
return args; | |
} | |
function parseNonComputedProperty() { | |
var token = lex(); | |
if (!isIdentifierName(token)) { | |
throwUnexpected(token); | |
} | |
return { | |
type: Syntax.Identifier, | |
name: token.value | |
}; | |
} | |
function parseNonComputedMember() { | |
expect('.'); | |
return parseNonComputedProperty(); | |
} | |
function parseComputedMember() { | |
var expr; | |
expect('['); | |
expr = parseExpression(); | |
expect(']'); | |
return expr; | |
} | |
function parseNewExpression() { | |
var expr; | |
expectKeyword('new'); | |
expr = { | |
type: Syntax.NewExpression, | |
callee: parseLeftHandSideExpression(), | |
'arguments': [] | |
}; | |
if (match('(')) { | |
expr['arguments'] = parseArguments(); | |
} | |
return expr; | |
} | |
function parseLeftHandSideExpressionAllowCall() { | |
var expr; | |
expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); | |
while (match('.') || match('[') || match('(')) { | |
if (match('(')) { | |
expr = { | |
type: Syntax.CallExpression, | |
callee: expr, | |
'arguments': parseArguments() | |
}; | |
} else if (match('[')) { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: true, | |
object: expr, | |
property: parseComputedMember() | |
}; | |
} else { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: false, | |
object: expr, | |
property: parseNonComputedMember() | |
}; | |
} | |
} | |
return expr; | |
} | |
function parseLeftHandSideExpression() { | |
var expr; | |
expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); | |
while (match('.') || match('[')) { | |
if (match('[')) { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: true, | |
object: expr, | |
property: parseComputedMember() | |
}; | |
} else { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: false, | |
object: expr, | |
property: parseNonComputedMember() | |
}; | |
} | |
} | |
return expr; | |
} | |
// 11.3 Postfix Expressions | |
function parsePostfixExpression() { | |
var expr = parseLeftHandSideExpressionAllowCall(), token; | |
token = lookahead(); | |
if (token.type !== Token.Punctuator) { | |
return expr; | |
} | |
if ((match('++') || match('--')) && !peekLineTerminator()) { | |
// 11.3.1, 11.3.2 | |
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { | |
throwErrorTolerant({}, Messages.StrictLHSPostfix); | |
} | |
if (!isLeftHandSide(expr)) { | |
throwErrorTolerant({}, Messages.InvalidLHSInAssignment); | |
} | |
expr = { | |
type: Syntax.UpdateExpression, | |
operator: lex().value, | |
argument: expr, | |
prefix: false | |
}; | |
} | |
return expr; | |
} | |
// 11.4 Unary Operators | |
function parseUnaryExpression() { | |
var token, expr; | |
token = lookahead(); | |
if (token.type !== Token.Punctuator && token.type !== Token.Keyword) { | |
return parsePostfixExpression(); | |
} | |
if (match('++') || match('--')) { | |
token = lex(); | |
expr = parseUnaryExpression(); | |
// 11.4.4, 11.4.5 | |
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { | |
throwErrorTolerant({}, Messages.StrictLHSPrefix); | |
} | |
if (!isLeftHandSide(expr)) { | |
throwErrorTolerant({}, Messages.InvalidLHSInAssignment); | |
} | |
expr = { | |
type: Syntax.UpdateExpression, | |
operator: token.value, | |
argument: expr, | |
prefix: true | |
}; | |
return expr; | |
} | |
if (match('+') || match('-') || match('~') || match('!')) { | |
expr = { | |
type: Syntax.UnaryExpression, | |
operator: lex().value, | |
argument: parseUnaryExpression(), | |
prefix: true | |
}; | |
return expr; | |
} | |
if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) { | |
expr = { | |
type: Syntax.UnaryExpression, | |
operator: lex().value, | |
argument: parseUnaryExpression(), | |
prefix: true | |
}; | |
if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) { | |
throwErrorTolerant({}, Messages.StrictDelete); | |
} | |
return expr; | |
} | |
return parsePostfixExpression(); | |
} | |
// 11.5 Multiplicative Operators | |
function parseMultiplicativeExpression() { | |
var expr = parseUnaryExpression(); | |
while (match('*') || match('/') || match('%')) { | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseUnaryExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.6 Additive Operators | |
function parseAdditiveExpression() { | |
var expr = parseMultiplicativeExpression(); | |
while (match('+') || match('-')) { | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseMultiplicativeExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.7 Bitwise Shift Operators | |
function parseShiftExpression() { | |
var expr = parseAdditiveExpression(); | |
while (match('<<') || match('>>') || match('>>>')) { | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseAdditiveExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.8 Relational Operators | |
function parseRelationalExpression() { | |
var expr, previousAllowIn; | |
previousAllowIn = state.allowIn; | |
state.allowIn = true; | |
expr = parseShiftExpression(); | |
while (match('<') || match('>') || match('<=') || match('>=') || (previousAllowIn && matchKeyword('in')) || matchKeyword('instanceof')) { | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseShiftExpression() | |
}; | |
} | |
state.allowIn = previousAllowIn; | |
return expr; | |
} | |
// 11.9 Equality Operators | |
function parseEqualityExpression() { | |
var expr = parseRelationalExpression(); | |
while (match('==') || match('!=') || match('===') || match('!==')) { | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseRelationalExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.10 Binary Bitwise Operators | |
function parseBitwiseANDExpression() { | |
var expr = parseEqualityExpression(); | |
while (match('&')) { | |
lex(); | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: '&', | |
left: expr, | |
right: parseEqualityExpression() | |
}; | |
} | |
return expr; | |
} | |
function parseBitwiseXORExpression() { | |
var expr = parseBitwiseANDExpression(); | |
while (match('^')) { | |
lex(); | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: '^', | |
left: expr, | |
right: parseBitwiseANDExpression() | |
}; | |
} | |
return expr; | |
} | |
function parseBitwiseORExpression() { | |
var expr = parseBitwiseXORExpression(); | |
while (match('|')) { | |
lex(); | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: '|', | |
left: expr, | |
right: parseBitwiseXORExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.11 Binary Logical Operators | |
function parseLogicalANDExpression() { | |
var expr = parseBitwiseORExpression(); | |
while (match('&&')) { | |
lex(); | |
expr = { | |
type: Syntax.LogicalExpression, | |
operator: '&&', | |
left: expr, | |
right: parseBitwiseORExpression() | |
}; | |
} | |
return expr; | |
} | |
function parseLogicalORExpression() { | |
var expr = parseLogicalANDExpression(); | |
while (match('||')) { | |
lex(); | |
expr = { | |
type: Syntax.LogicalExpression, | |
operator: '||', | |
left: expr, | |
right: parseLogicalANDExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.12 Conditional Operator | |
function parseConditionalExpression() { | |
var expr, previousAllowIn, consequent; | |
expr = parseLogicalORExpression(); | |
if (match('?')) { | |
lex(); | |
previousAllowIn = state.allowIn; | |
state.allowIn = true; | |
consequent = parseAssignmentExpression(); | |
state.allowIn = previousAllowIn; | |
expect(':'); | |
expr = { | |
type: Syntax.ConditionalExpression, | |
test: expr, | |
consequent: consequent, | |
alternate: parseAssignmentExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.13 Assignment Operators | |
function parseAssignmentExpression() { | |
var token, expr; | |
token = lookahead(); | |
expr = parseConditionalExpression(); | |
if (matchAssign()) { | |
// LeftHandSideExpression | |
if (!isLeftHandSide(expr)) { | |
throwErrorTolerant({}, Messages.InvalidLHSInAssignment); | |
} | |
// 11.13.1 | |
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { | |
throwErrorTolerant(token, Messages.StrictLHSAssignment); | |
} | |
expr = { | |
type: Syntax.AssignmentExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseAssignmentExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.14 Comma Operator | |
function parseExpression() { | |
var expr = parseAssignmentExpression(); | |
if (match(',')) { | |
expr = { | |
type: Syntax.SequenceExpression, | |
expressions: [ expr ] | |
}; | |
while (index < length) { | |
if (!match(',')) { | |
break; | |
} | |
lex(); | |
expr.expressions.push(parseAssignmentExpression()); | |
} | |
} | |
return expr; | |
} | |
// 12.1 Block | |
function parseStatementList() { | |
var list = [], | |
statement; | |
while (index < length) { | |
if (match('}')) { | |
break; | |
} | |
statement = parseSourceElement(); | |
if (typeof statement === 'undefined') { | |
break; | |
} | |
list.push(statement); | |
} | |
return list; | |
} | |
function parseBlock() { | |
var block; | |
expect('{'); | |
block = parseStatementList(); | |
expect('}'); | |
return { | |
type: Syntax.BlockStatement, | |
body: block | |
}; | |
} | |
// 12.2 Variable Statement | |
function parseVariableIdentifier() { | |
var token = lex(); | |
if (token.type !== Token.Identifier) { | |
throwUnexpected(token); | |
} | |
return { | |
type: Syntax.Identifier, | |
name: token.value | |
}; | |
} | |
function parseVariableDeclaration(kind) { | |
var id = parseVariableIdentifier(), | |
init = null; | |
// 12.2.1 | |
if (strict && isRestrictedWord(id.name)) { | |
throwErrorTolerant({}, Messages.StrictVarName); | |
} | |
if (kind === 'const') { | |
expect('='); | |
init = parseAssignmentExpression(); | |
} else if (match('=')) { | |
lex(); | |
init = parseAssignmentExpression(); | |
} | |
return { | |
type: Syntax.VariableDeclarator, | |
id: id, | |
init: init | |
}; | |
} | |
function parseVariableDeclarationList(kind) { | |
var list = []; | |
do { | |
list.push(parseVariableDeclaration(kind)); | |
if (!match(',')) { | |
break; | |
} | |
lex(); | |
} while (index < length); | |
return list; | |
} | |
function parseVariableStatement() { | |
var declarations; | |
expectKeyword('var'); | |
declarations = parseVariableDeclarationList(); | |
consumeSemicolon(); | |
return { | |
type: Syntax.VariableDeclaration, | |
declarations: declarations, | |
kind: 'var' | |
}; | |
} | |
// kind may be `const` or `let` | |
// Both are experimental and not in the specification yet. | |
// see http://wiki.ecmascript.org/doku.php?id=harmony:const | |
// and http://wiki.ecmascript.org/doku.php?id=harmony:let | |
function parseConstLetDeclaration(kind) { | |
var declarations; | |
expectKeyword(kind); | |
declarations = parseVariableDeclarationList(kind); | |
consumeSemicolon(); | |
return { | |
type: Syntax.VariableDeclaration, | |
declarations: declarations, | |
kind: kind | |
}; | |
} | |
// 12.3 Empty Statement | |
function parseEmptyStatement() { | |
expect(';'); | |
return { | |
type: Syntax.EmptyStatement | |
}; | |
} | |
// 12.4 Expression Statement | |
function parseExpressionStatement() { | |
var expr = parseExpression(); | |
consumeSemicolon(); | |
return { | |
type: Syntax.ExpressionStatement, | |
expression: expr | |
}; | |
} | |
// 12.5 If statement | |
function parseIfStatement() { | |
var test, consequent, alternate; | |
expectKeyword('if'); | |
expect('('); | |
test = parseExpression(); | |
expect(')'); | |
consequent = parseStatement(); | |
if (matchKeyword('else')) { | |
lex(); | |
alternate = parseStatement(); | |
} else { | |
alternate = null; | |
} | |
return { | |
type: Syntax.IfStatement, | |
test: test, | |
consequent: consequent, | |
alternate: alternate | |
}; | |
} | |
// 12.6 Iteration Statements | |
function parseDoWhileStatement() { | |
var body, test, oldInIteration; | |
expectKeyword('do'); | |
oldInIteration = state.inIteration; | |
state.inIteration = true; | |
body = parseStatement(); | |
state.inIteration = oldInIteration; | |
expectKeyword('while'); | |
expect('('); | |
test = parseExpression(); | |
expect(')'); | |
if (match(';')) { | |
lex(); | |
} | |
return { | |
type: Syntax.DoWhileStatement, | |
body: body, | |
test: test | |
}; | |
} | |
function parseWhileStatement() { | |
var test, body, oldInIteration; | |
expectKeyword('while'); | |
expect('('); | |
test = parseExpression(); | |
expect(')'); | |
oldInIteration = state.inIteration; | |
state.inIteration = true; | |
body = parseStatement(); | |
state.inIteration = oldInIteration; | |
return { | |
type: Syntax.WhileStatement, | |
test: test, | |
body: body | |
}; | |
} | |
function parseForVariableDeclaration() { | |
var token = lex(); | |
return { | |
type: Syntax.VariableDeclaration, | |
declarations: parseVariableDeclarationList(), | |
kind: token.value | |
}; | |
} | |
function parseForStatement() { | |
var init, test, update, left, right, body, oldInIteration; | |
init = test = update = null; | |
expectKeyword('for'); | |
expect('('); | |
if (match(';')) { | |
lex(); | |
} else { | |
if (matchKeyword('var') || matchKeyword('let')) { | |
state.allowIn = false; | |
init = parseForVariableDeclaration(); | |
state.allowIn = true; | |
if (init.declarations.length === 1 && matchKeyword('in')) { | |
lex(); | |
left = init; | |
right = parseExpression(); | |
init = null; | |
} | |
} else { | |
state.allowIn = false; | |
init = parseExpression(); | |
state.allowIn = true; | |
if (matchKeyword('in')) { | |
// LeftHandSideExpression | |
if (!isLeftHandSide(init)) { | |
throwErrorTolerant({}, Messages.InvalidLHSInForIn); | |
} | |
lex(); | |
left = init; | |
right = parseExpression(); | |
init = null; | |
} | |
} | |
if (typeof left === 'undefined') { | |
expect(';'); | |
} | |
} | |
if (typeof left === 'undefined') { | |
if (!match(';')) { | |
test = parseExpression(); | |
} | |
expect(';'); | |
if (!match(')')) { | |
update = parseExpression(); | |
} | |
} | |
expect(')'); | |
oldInIteration = state.inIteration; | |
state.inIteration = true; | |
body = parseStatement(); | |
state.inIteration = oldInIteration; | |
if (typeof left === 'undefined') { | |
return { | |
type: Syntax.ForStatement, | |
init: init, | |
test: test, | |
update: update, | |
body: body | |
}; | |
} | |
return { | |
type: Syntax.ForInStatement, | |
left: left, | |
right: right, | |
body: body, | |
each: false | |
}; | |
} | |
// 12.7 The continue statement | |
function parseContinueStatement() { | |
var token, label = null; | |
expectKeyword('continue'); | |
// Optimize the most common form: 'continue;'. | |
if (source[index] === ';') { | |
lex(); | |
if (!state.inIteration) { | |
throwError({}, Messages.IllegalContinue); | |
} | |
return { | |
type: Syntax.ContinueStatement, | |
label: null | |
}; | |
} | |
if (peekLineTerminator()) { | |
if (!state.inIteration) { | |
throwError({}, Messages.IllegalContinue); | |
} | |
return { | |
type: Syntax.ContinueStatement, | |
label: null | |
}; | |
} | |
token = lookahead(); | |
if (token.type === Token.Identifier) { | |
label = parseVariableIdentifier(); | |
if (!Object.prototype.hasOwnProperty.call(state.labelSet, label.name)) { | |
throwError({}, Messages.UnknownLabel, label.name); | |
} | |
} | |
consumeSemicolon(); | |
if (label === null && !state.inIteration) { | |
throwError({}, Messages.IllegalContinue); | |
} | |
return { | |
type: Syntax.ContinueStatement, | |
label: label | |
}; | |
} | |
// 12.8 The break statement | |
function parseBreakStatement() { | |
var token, label = null; | |
expectKeyword('break'); | |
// Optimize the most common form: 'break;'. | |
if (source[index] === ';') { | |
lex(); | |
if (!(state.inIteration || state.inSwitch)) { | |
throwError({}, Messages.IllegalBreak); | |
} | |
return { | |
type: Syntax.BreakStatement, | |
label: null | |
}; | |
} | |
if (peekLineTerminator()) { | |
if (!(state.inIteration || state.inSwitch)) { | |
throwError({}, Messages.IllegalBreak); | |
} | |
return { | |
type: Syntax.BreakStatement, | |
label: null | |
}; | |
} | |
token = lookahead(); | |
if (token.type === Token.Identifier) { | |
label = parseVariableIdentifier(); | |
if (!Object.prototype.hasOwnProperty.call(state.labelSet, label.name)) { | |
throwError({}, Messages.UnknownLabel, label.name); | |
} | |
} | |
consumeSemicolon(); | |
if (label === null && !(state.inIteration || state.inSwitch)) { | |
throwError({}, Messages.IllegalBreak); | |
} | |
return { | |
type: Syntax.BreakStatement, | |
label: label | |
}; | |
} | |
// 12.9 The return statement | |
function parseReturnStatement() { | |
var token, argument = null; | |
expectKeyword('return'); | |
if (!state.inFunctionBody) { | |
throwErrorTolerant({}, Messages.IllegalReturn); | |
} | |
// 'return' followed by a space and an identifier is very common. | |
if (source[index] === ' ') { | |
if (isIdentifierStart(source[index + 1])) { | |
argument = parseExpression(); | |
consumeSemicolon(); | |
return { | |
type: Syntax.ReturnStatement, | |
argument: argument | |
}; | |
} | |
} | |
if (peekLineTerminator()) { | |
return { | |
type: Syntax.ReturnStatement, | |
argument: null | |
}; | |
} | |
if (!match(';')) { | |
token = lookahead(); | |
if (!match('}') && token.type !== Token.EOF) { | |
argument = parseExpression(); | |
} | |
} | |
consumeSemicolon(); | |
return { | |
type: Syntax.ReturnStatement, | |
argument: argument | |
}; | |
} | |
// 12.10 The with statement | |
function parseWithStatement() { | |
var object, body; | |
if (strict) { | |
throwErrorTolerant({}, Messages.StrictModeWith); | |
} | |
expectKeyword('with'); | |
expect('('); | |
object = parseExpression(); | |
expect(')'); | |
body = parseStatement(); | |
return { | |
type: Syntax.WithStatement, | |
object: object, | |
body: body | |
}; | |
} | |
// 12.10 The swith statement | |
function parseSwitchCase() { | |
var test, | |
consequent = [], | |
statement; | |
if (matchKeyword('default')) { | |
lex(); | |
test = null; | |
} else { | |
expectKeyword('case'); | |
test = parseExpression(); | |
} | |
expect(':'); | |
while (index < length) { | |
if (match('}') || matchKeyword('default') || matchKeyword('case')) { | |
break; | |
} | |
statement = parseStatement(); | |
if (typeof statement === 'undefined') { | |
break; | |
} | |
consequent.push(statement); | |
} | |
return { | |
type: Syntax.SwitchCase, | |
test: test, | |
consequent: consequent | |
}; | |
} | |
function parseSwitchStatement() { | |
var discriminant, cases, clause, oldInSwitch, defaultFound; | |
expectKeyword('switch'); | |
expect('('); | |
discriminant = parseExpression(); | |
expect(')'); | |
expect('{'); | |
cases = []; | |
if (match('}')) { | |
lex(); | |
return { | |
type: Syntax.SwitchStatement, | |
discriminant: discriminant, | |
cases: cases | |
}; | |
} | |
oldInSwitch = state.inSwitch; | |
state.inSwitch = true; | |
defaultFound = false; | |
while (index < length) { | |
if (match('}')) { | |
break; | |
} | |
clause = parseSwitchCase(); | |
if (clause.test === null) { | |
if (defaultFound) { | |
throwError({}, Messages.MultipleDefaultsInSwitch); | |
} | |
defaultFound = true; | |
} | |
cases.push(clause); | |
} | |
state.inSwitch = oldInSwitch; | |
expect('}'); | |
return { | |
type: Syntax.SwitchStatement, | |
discriminant: discriminant, | |
cases: cases | |
}; | |
} | |
// 12.13 The throw statement | |
function parseThrowStatement() { | |
var argument; | |
expectKeyword('throw'); | |
if (peekLineTerminator()) { | |
throwError({}, Messages.NewlineAfterThrow); | |
} | |
argument = parseExpression(); | |
consumeSemicolon(); | |
return { | |
type: Syntax.ThrowStatement, | |
argument: argument | |
}; | |
} | |
// 12.14 The try statement | |
function parseCatchClause() { | |
var param; | |
expectKeyword('catch'); | |
expect('('); | |
if (match(')')) { | |
throwUnexpected(lookahead()); | |
} | |
param = parseVariableIdentifier(); | |
// 12.14.1 | |
if (strict && isRestrictedWord(param.name)) { | |
throwErrorTolerant({}, Messages.StrictCatchVariable); | |
} | |
expect(')'); | |
return { | |
type: Syntax.CatchClause, | |
param: param, | |
body: parseBlock() | |
}; | |
} | |
function parseTryStatement() { | |
var block, handlers = [], finalizer = null; | |
expectKeyword('try'); | |
block = parseBlock(); | |
if (matchKeyword('catch')) { | |
handlers.push(parseCatchClause()); | |
} | |
if (matchKeyword('finally')) { | |
lex(); | |
finalizer = parseBlock(); | |
} | |
if (handlers.length === 0 && !finalizer) { | |
throwError({}, Messages.NoCatchOrFinally); | |
} | |
return { | |
type: Syntax.TryStatement, | |
block: block, | |
guardedHandlers: [], | |
handlers: handlers, | |
finalizer: finalizer | |
}; | |
} | |
// 12.15 The debugger statement | |
function parseDebuggerStatement() { | |
expectKeyword('debugger'); | |
consumeSemicolon(); | |
return { | |
type: Syntax.DebuggerStatement | |
}; | |
} | |
// 12 Statements | |
function parseStatement() { | |
var token = lookahead(), | |
expr, | |
labeledBody; | |
if (token.type === Token.EOF) { | |
throwUnexpected(token); | |
} | |
if (token.type === Token.Punctuator) { | |
switch (token.value) { | |
case ';': | |
return parseEmptyStatement(); | |
case '{': | |
return parseBlock(); | |
case '(': | |
return parseExpressionStatement(); | |
default: | |
break; | |
} | |
} | |
if (token.type === Token.Keyword) { | |
switch (token.value) { | |
case 'break': | |
return parseBreakStatement(); | |
case 'continue': | |
return parseContinueStatement(); | |
case 'debugger': | |
return parseDebuggerStatement(); | |
case 'do': | |
return parseDoWhileStatement(); | |
case 'for': | |
return parseForStatement(); | |
case 'function': | |
return parseFunctionDeclaration(); | |
case 'if': | |
return parseIfStatement(); | |
case 'return': | |
return parseReturnStatement(); | |
case 'switch': | |
return parseSwitchStatement(); | |
case 'throw': | |
return parseThrowStatement(); | |
case 'try': | |
return parseTryStatement(); | |
case 'var': | |
return parseVariableStatement(); | |
case 'while': | |
return parseWhileStatement(); | |
case 'with': | |
return parseWithStatement(); | |
default: | |
break; | |
} | |
} | |
expr = parseExpression(); | |
// 12.12 Labelled Statements | |
if ((expr.type === Syntax.Identifier) && match(':')) { | |
lex(); | |
if (Object.prototype.hasOwnProperty.call(state.labelSet, expr.name)) { | |
throwError({}, Messages.Redeclaration, 'Label', expr.name); | |
} | |
state.labelSet[expr.name] = true; | |
labeledBody = parseStatement(); | |
delete state.labelSet[expr.name]; | |
return { | |
type: Syntax.LabeledStatement, | |
label: expr, | |
body: labeledBody | |
}; | |
} | |
consumeSemicolon(); | |
return { | |
type: Syntax.ExpressionStatement, | |
expression: expr | |
}; | |
} | |
// 13 Function Definition | |
function parseFunctionSourceElements() { | |
var sourceElement, sourceElements = [], token, directive, firstRestricted, | |
oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody; | |
expect('{'); | |
while (index < length) { | |
token = lookahead(); | |
if (token.type !== Token.StringLiteral) { | |
break; | |
} | |
sourceElement = parseSourceElement(); | |
sourceElements.push(sourceElement); | |
if (sourceElement.expression.type !== Syntax.Literal) { | |
// this is not directive | |
break; | |
} | |
directive = sliceSource(token.range[0] + 1, token.range[1] - 1); | |
if (directive === 'use strict') { | |
strict = true; | |
if (firstRestricted) { | |
throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); | |
} | |
} else { | |
if (!firstRestricted && token.octal) { | |
firstRestricted = token; | |
} | |
} | |
} | |
oldLabelSet = state.labelSet; | |
oldInIteration = state.inIteration; | |
oldInSwitch = state.inSwitch; | |
oldInFunctionBody = state.inFunctionBody; | |
state.labelSet = {}; | |
state.inIteration = false; | |
state.inSwitch = false; | |
state.inFunctionBody = true; | |
while (index < length) { | |
if (match('}')) { | |
break; | |
} | |
sourceElement = parseSourceElement(); | |
if (typeof sourceElement === 'undefined') { | |
break; | |
} | |
sourceElements.push(sourceElement); | |
} | |
expect('}'); | |
state.labelSet = oldLabelSet; | |
state.inIteration = oldInIteration; | |
state.inSwitch = oldInSwitch; | |
state.inFunctionBody = oldInFunctionBody; | |
return { | |
type: Syntax.BlockStatement, | |
body: sourceElements | |
}; | |
} | |
function parseFunctionDeclaration() { | |
var id, param, params = [], body, token, stricted, firstRestricted, message, previousStrict, paramSet; | |
expectKeyword('function'); | |
token = lookahead(); | |
id = parseVariableIdentifier(); | |
if (strict) { | |
if (isRestrictedWord(token.value)) { | |
throwErrorTolerant(token, Messages.StrictFunctionName); | |
} | |
} else { | |
if (isRestrictedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictFunctionName; | |
} else if (isStrictModeReservedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictReservedWord; | |
} | |
} | |
expect('('); | |
if (!match(')')) { | |
paramSet = {}; | |
while (index < length) { | |
token = lookahead(); | |
param = parseVariableIdentifier(); | |
if (strict) { | |
if (isRestrictedWord(token.value)) { | |
stricted = token; | |
message = Messages.StrictParamName; | |
} | |
if (Object.prototype.hasOwnProperty.call(paramSet, token.value)) { | |
stricted = token; | |
message = Messages.StrictParamDupe; | |
} | |
} else if (!firstRestricted) { | |
if (isRestrictedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictParamName; | |
} else if (isStrictModeReservedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictReservedWord; | |
} else if (Object.prototype.hasOwnProperty.call(paramSet, token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictParamDupe; | |
} | |
} | |
params.push(param); | |
paramSet[param.name] = true; | |
if (match(')')) { | |
break; | |
} | |
expect(','); | |
} | |
} | |
expect(')'); | |
previousStrict = strict; | |
body = parseFunctionSourceElements(); | |
if (strict && firstRestricted) { | |
throwError(firstRestricted, message); | |
} | |
if (strict && stricted) { | |
throwErrorTolerant(stricted, message); | |
} | |
strict = previousStrict; | |
return { | |
type: Syntax.FunctionDeclaration, | |
id: id, | |
params: params, | |
defaults: [], | |
body: body, | |
rest: null, | |
generator: false, | |
expression: false | |
}; | |
} | |
function parseFunctionExpression() { | |
var token, id = null, stricted, firstRestricted, message, param, params = [], body, previousStrict, paramSet; | |
expectKeyword('function'); | |
if (!match('(')) { | |
token = lookahead(); | |
id = parseVariableIdentifier(); | |
if (strict) { | |
if (isRestrictedWord(token.value)) { | |
throwErrorTolerant(token, Messages.StrictFunctionName); | |
} | |
} else { | |
if (isRestrictedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictFunctionName; | |
} else if (isStrictModeReservedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictReservedWord; | |
} | |
} | |
} | |
expect('('); | |
if (!match(')')) { | |
paramSet = {}; | |
while (index < length) { | |
token = lookahead(); | |
param = parseVariableIdentifier(); | |
if (strict) { | |
if (isRestrictedWord(token.value)) { | |
stricted = token; | |
message = Messages.StrictParamName; | |
} | |
if (Object.prototype.hasOwnProperty.call(paramSet, token.value)) { | |
stricted = token; | |
message = Messages.StrictParamDupe; | |
} | |
} else if (!firstRestricted) { | |
if (isRestrictedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictParamName; | |
} else if (isStrictModeReservedWord(token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictReservedWord; | |
} else if (Object.prototype.hasOwnProperty.call(paramSet, token.value)) { | |
firstRestricted = token; | |
message = Messages.StrictParamDupe; | |
} | |
} | |
params.push(param); | |
paramSet[param.name] = true; | |
if (match(')')) { | |
break; | |
} | |
expect(','); | |
} | |
} | |
expect(')'); | |
previousStrict = strict; | |
body = parseFunctionSourceElements(); | |
if (strict && firstRestricted) { | |
throwError(firstRestricted, message); | |
} | |
if (strict && stricted) { | |
throwErrorTolerant(stricted, message); | |
} | |
strict = previousStrict; | |
return { | |
type: Syntax.FunctionExpression, | |
id: id, | |
params: params, | |
defaults: [], | |
body: body, | |
rest: null, | |
generator: false, | |
expression: false | |
}; | |
} | |
// 14 Program | |
function parseSourceElement() { | |
var token = lookahead(); | |
if (token.type === Token.Keyword) { | |
switch (token.value) { | |
case 'const': | |
case 'let': | |
return parseConstLetDeclaration(token.value); | |
case 'function': | |
return parseFunctionDeclaration(); | |
default: | |
return parseStatement(); | |
} | |
} | |
if (token.type !== Token.EOF) { | |
return parseStatement(); | |
} | |
} | |
function parseSourceElements() { | |
var sourceElement, sourceElements = [], token, directive, firstRestricted; | |
while (index < length) { | |
token = lookahead(); | |
if (token.type !== Token.StringLiteral) { | |
break; | |
} | |
sourceElement = parseSourceElement(); | |
sourceElements.push(sourceElement); | |
if (sourceElement.expression.type !== Syntax.Literal) { | |
// this is not directive | |
break; | |
} | |
directive = sliceSource(token.range[0] + 1, token.range[1] - 1); | |
if (directive === 'use strict') { | |
strict = true; | |
if (firstRestricted) { | |
throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); | |
} | |
} else { | |
if (!firstRestricted && token.octal) { | |
firstRestricted = token; | |
} | |
} | |
} | |
while (index < length) { | |
sourceElement = parseSourceElement(); | |
if (typeof sourceElement === 'undefined') { | |
break; | |
} | |
sourceElements.push(sourceElement); | |
} | |
return sourceElements; | |
} | |
function parseProgram() { | |
var program; | |
strict = false; | |
program = { | |
type: Syntax.Program, | |
body: parseSourceElements() | |
}; | |
return program; | |
} | |
// The following functions are needed only when the option to preserve | |
// the comments is active. | |
function addComment(type, value, start, end, loc) { | |
assert(typeof start === 'number', 'Comment must have valid position'); | |
// Because the way the actual token is scanned, often the comments | |
// (if any) are skipped twice during the lexical analysis. | |
// Thus, we need to skip adding a comment if the comment array already | |
// handled it. | |
if (extra.comments.length > 0) { | |
if (extra.comments[extra.comments.length - 1].range[1] > start) { | |
return; | |
} | |
} | |
extra.comments.push({ | |
type: type, | |
value: value, | |
range: [start, end], | |
loc: loc | |
}); | |
} | |
function scanComment() { | |
var comment, ch, loc, start, blockComment, lineComment; | |
comment = ''; | |
blockComment = false; | |
lineComment = false; | |
while (index < length) { | |
ch = source[index]; | |
if (lineComment) { | |
ch = source[index++]; | |
if (isLineTerminator(ch)) { | |
loc.end = { | |
line: lineNumber, | |
column: index - lineStart - 1 | |
}; | |
lineComment = false; | |
addComment('Line', comment, start, index - 1, loc); | |
if (ch === '\r' && source[index] === '\n') { | |
++index; | |
} | |
++lineNumber; | |
lineStart = index; | |
comment = ''; | |
} else if (index >= length) { | |
lineComment = false; | |
comment += ch; | |
loc.end = { | |
line: lineNumber, | |
column: length - lineStart | |
}; | |
addComment('Line', comment, start, length, loc); | |
} else { | |
comment += ch; | |
} | |
} else if (blockComment) { | |
if (isLineTerminator(ch)) { | |
if (ch === '\r' && source[index + 1] === '\n') { | |
++index; | |
comment += '\r\n'; | |
} else { | |
comment += ch; | |
} | |
++lineNumber; | |
++index; | |
lineStart = index; | |
if (index >= length) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} else { | |
ch = source[index++]; | |
if (index >= length) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
comment += ch; | |
if (ch === '*') { | |
ch = source[index]; | |
if (ch === '/') { | |
comment = comment.substr(0, comment.length - 1); | |
blockComment = false; | |
++index; | |
loc.end = { | |
line: lineNumber, | |
column: index - lineStart | |
}; | |
addComment('Block', comment, start, index, loc); | |
comment = ''; | |
} | |
} | |
} | |
} else if (ch === '/') { | |
ch = source[index + 1]; | |
if (ch === '/') { | |
loc = { | |
start: { | |
line: lineNumber, | |
column: index - lineStart | |
} | |
}; | |
start = index; | |
index += 2; | |
lineComment = true; | |
if (index >= length) { | |
loc.end = { | |
line: lineNumber, | |
column: index - lineStart | |
}; | |
lineComment = false; | |
addComment('Line', comment, start, index, loc); | |
} | |
} else if (ch === '*') { | |
start = index; | |
index += 2; | |
blockComment = true; | |
loc = { | |
start: { | |
line: lineNumber, | |
column: index - lineStart - 2 | |
} | |
}; | |
if (index >= length) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} else { | |
break; | |
} | |
} else if (isWhiteSpace(ch)) { | |
++index; | |
} else if (isLineTerminator(ch)) { | |
++index; | |
if (ch === '\r' && source[index] === '\n') { | |
++index; | |
} | |
++lineNumber; | |
lineStart = index; | |
} else { | |
break; | |
} | |
} | |
} | |
function filterCommentLocation() { | |
var i, entry, comment, comments = []; | |
for (i = 0; i < extra.comments.length; ++i) { | |
entry = extra.comments[i]; | |
comment = { | |
type: entry.type, | |
value: entry.value | |
}; | |
if (extra.range) { | |
comment.range = entry.range; | |
} | |
if (extra.loc) { | |
comment.loc = entry.loc; | |
} | |
comments.push(comment); | |
} | |
extra.comments = comments; | |
} | |
function collectToken() { | |
var start, loc, token, range, value; | |
skipComment(); | |
start = index; | |
loc = { | |
start: { | |
line: lineNumber, | |
column: index - lineStart | |
} | |
}; | |
token = extra.advance(); | |
loc.end = { | |
line: lineNumber, | |
column: index - lineStart | |
}; | |
if (token.type !== Token.EOF) { | |
range = [token.range[0], token.range[1]]; | |
value = sliceSource(token.range[0], token.range[1]); | |
extra.tokens.push({ | |
type: TokenName[token.type], | |
value: value, | |
range: range, | |
loc: loc | |
}); | |
} | |
return token; | |
} | |
function collectRegex() { | |
var pos, loc, regex, token; | |
skipComment(); | |
pos = index; | |
loc = { | |
start: { | |
line: lineNumber, | |
column: index - lineStart | |
} | |
}; | |
regex = extra.scanRegExp(); | |
loc.end = { | |
line: lineNumber, | |
column: index - lineStart | |
}; | |
// Pop the previous token, which is likely '/' or '/=' | |
if (extra.tokens.length > 0) { | |
token = extra.tokens[extra.tokens.length - 1]; | |
if (token.range[0] === pos && token.type === 'Punctuator') { | |
if (token.value === '/' || token.value === '/=') { | |
extra.tokens.pop(); | |
} | |
} | |
} | |
extra.tokens.push({ | |
type: 'RegularExpression', | |
value: regex.literal, | |
range: [pos, index], | |
loc: loc | |
}); | |
return regex; | |
} | |
function filterTokenLocation() { | |
var i, entry, token, tokens = []; | |
for (i = 0; i < extra.tokens.length; ++i) { | |
entry = extra.tokens[i]; | |
token = { | |
type: entry.type, | |
value: entry.value | |
}; | |
if (extra.range) { | |
token.range = entry.range; | |
} | |
if (extra.loc) { | |
token.loc = entry.loc; | |
} | |
tokens.push(token); | |
} | |
extra.tokens = tokens; | |
} | |
function createLiteral(token) { | |
return { | |
type: Syntax.Literal, | |
value: token.value | |
}; | |
} | |
function createRawLiteral(token) { | |
return { | |
type: Syntax.Literal, | |
value: token.value, | |
raw: sliceSource(token.range[0], token.range[1]) | |
}; | |
} | |
function createLocationMarker() { | |
var marker = {}; | |
marker.range = [index, index]; | |
marker.loc = { | |
start: { | |
line: lineNumber, | |
column: index - lineStart | |
}, | |
end: { | |
line: lineNumber, | |
column: index - lineStart | |
} | |
}; | |
marker.end = function () { | |
this.range[1] = index; | |
this.loc.end.line = lineNumber; | |
this.loc.end.column = index - lineStart; | |
}; | |
marker.applyGroup = function (node) { | |
if (extra.range) { | |
node.groupRange = [this.range[0], this.range[1]]; | |
} | |
if (extra.loc) { | |
node.groupLoc = { | |
start: { | |
line: this.loc.start.line, | |
column: this.loc.start.column | |
}, | |
end: { | |
line: this.loc.end.line, | |
column: this.loc.end.column | |
} | |
}; | |
} | |
}; | |
marker.apply = function (node) { | |
if (extra.range) { | |
node.range = [this.range[0], this.range[1]]; | |
} | |
if (extra.loc) { | |
node.loc = { | |
start: { | |
line: this.loc.start.line, | |
column: this.loc.start.column | |
}, | |
end: { | |
line: this.loc.end.line, | |
column: this.loc.end.column | |
} | |
}; | |
} | |
}; | |
return marker; | |
} | |
function trackGroupExpression() { | |
var marker, expr; | |
skipComment(); | |
marker = createLocationMarker(); | |
expect('('); | |
expr = parseExpression(); | |
expect(')'); | |
marker.end(); | |
marker.applyGroup(expr); | |
return expr; | |
} | |
function trackLeftHandSideExpression() { | |
var marker, expr; | |
skipComment(); | |
marker = createLocationMarker(); | |
expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); | |
while (match('.') || match('[')) { | |
if (match('[')) { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: true, | |
object: expr, | |
property: parseComputedMember() | |
}; | |
marker.end(); | |
marker.apply(expr); | |
} else { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: false, | |
object: expr, | |
property: parseNonComputedMember() | |
}; | |
marker.end(); | |
marker.apply(expr); | |
} | |
} | |
return expr; | |
} | |
function trackLeftHandSideExpressionAllowCall() { | |
var marker, expr; | |
skipComment(); | |
marker = createLocationMarker(); | |
expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); | |
while (match('.') || match('[') || match('(')) { | |
if (match('(')) { | |
expr = { | |
type: Syntax.CallExpression, | |
callee: expr, | |
'arguments': parseArguments() | |
}; | |
marker.end(); | |
marker.apply(expr); | |
} else if (match('[')) { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: true, | |
object: expr, | |
property: parseComputedMember() | |
}; | |
marker.end(); | |
marker.apply(expr); | |
} else { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: false, | |
object: expr, | |
property: parseNonComputedMember() | |
}; | |
marker.end(); | |
marker.apply(expr); | |
} | |
} | |
return expr; | |
} | |
function filterGroup(node) { | |
var n, i, entry; | |
n = (Object.prototype.toString.apply(node) === '[object Array]') ? [] : {}; | |
for (i in node) { | |
if (node.hasOwnProperty(i) && i !== 'groupRange' && i !== 'groupLoc') { | |
entry = node[i]; | |
if (entry === null || typeof entry !== 'object' || entry instanceof RegExp) { | |
n[i] = entry; | |
} else { | |
n[i] = filterGroup(entry); | |
} | |
} | |
} | |
return n; | |
} | |
function wrapTrackingFunction(range, loc) { | |
return function (parseFunction) { | |
function isBinary(node) { | |
return node.type === Syntax.LogicalExpression || | |
node.type === Syntax.BinaryExpression; | |
} | |
function visit(node) { | |
var start, end; | |
if (isBinary(node.left)) { | |
visit(node.left); | |
} | |
if (isBinary(node.right)) { | |
visit(node.right); | |
} | |
if (range) { | |
if (node.left.groupRange || node.right.groupRange) { | |
start = node.left.groupRange ? node.left.groupRange[0] : node.left.range[0]; | |
end = node.right.groupRange ? node.right.groupRange[1] : node.right.range[1]; | |
node.range = [start, end]; | |
} else if (typeof node.range === 'undefined') { | |
start = node.left.range[0]; | |
end = node.right.range[1]; | |
node.range = [start, end]; | |
} | |
} | |
if (loc) { | |
if (node.left.groupLoc || node.right.groupLoc) { | |
start = node.left.groupLoc ? node.left.groupLoc.start : node.left.loc.start; | |
end = node.right.groupLoc ? node.right.groupLoc.end : node.right.loc.end; | |
node.loc = { | |
start: start, | |
end: end | |
}; | |
} else if (typeof node.loc === 'undefined') { | |
node.loc = { | |
start: node.left.loc.start, | |
end: node.right.loc.end | |
}; | |
} | |
} | |
} | |
return function () { | |
var marker, node; | |
skipComment(); | |
marker = createLocationMarker(); | |
node = parseFunction.apply(null, arguments); | |
marker.end(); | |
if (range && typeof node.range === 'undefined') { | |
marker.apply(node); | |
} | |
if (loc && typeof node.loc === 'undefined') { | |
marker.apply(node); | |
} | |
if (isBinary(node)) { | |
visit(node); | |
} | |
return node; | |
}; | |
}; | |
} | |
function patch() { | |
var wrapTracking; | |
if (extra.comments) { | |
extra.skipComment = skipComment; | |
skipComment = scanComment; | |
} | |
if (extra.raw) { | |
extra.createLiteral = createLiteral; | |
createLiteral = createRawLiteral; | |
} | |
if (extra.range || extra.loc) { | |
extra.parseGroupExpression = parseGroupExpression; | |
extra.parseLeftHandSideExpression = parseLeftHandSideExpression; | |
extra.parseLeftHandSideExpressionAllowCall = parseLeftHandSideExpressionAllowCall; | |
parseGroupExpression = trackGroupExpression; | |
parseLeftHandSideExpression = trackLeftHandSideExpression; | |
parseLeftHandSideExpressionAllowCall = trackLeftHandSideExpressionAllowCall; | |
wrapTracking = wrapTrackingFunction(extra.range, extra.loc); | |
extra.parseAdditiveExpression = parseAdditiveExpression; | |
extra.parseAssignmentExpression = parseAssignmentExpression; | |
extra.parseBitwiseANDExpression = parseBitwiseANDExpression; | |
extra.parseBitwiseORExpression = parseBitwiseORExpression; | |
extra.parseBitwiseXORExpression = parseBitwiseXORExpression; | |
extra.parseBlock = parseBlock; | |
extra.parseFunctionSourceElements = parseFunctionSourceElements; | |
extra.parseCatchClause = parseCatchClause; | |
extra.parseComputedMember = parseComputedMember; | |
extra.parseConditionalExpression = parseConditionalExpression; | |
extra.parseConstLetDeclaration = parseConstLetDeclaration; | |
extra.parseEqualityExpression = parseEqualityExpression; | |
extra.parseExpression = parseExpression; | |
extra.parseForVariableDeclaration = parseForVariableDeclaration; | |
extra.parseFunctionDeclaration = parseFunctionDeclaration; | |
extra.parseFunctionExpression = parseFunctionExpression; | |
extra.parseLogicalANDExpression = parseLogicalANDExpression; | |
extra.parseLogicalORExpression = parseLogicalORExpression; | |
extra.parseMultiplicativeExpression = parseMultiplicativeExpression; | |
extra.parseNewExpression = parseNewExpression; | |
extra.parseNonComputedProperty = parseNonComputedProperty; | |
extra.parseObjectProperty = parseObjectProperty; | |
extra.parseObjectPropertyKey = parseObjectPropertyKey; | |
extra.parsePostfixExpression = parsePostfixExpression; | |
extra.parsePrimaryExpression = parsePrimaryExpression; | |
extra.parseProgram = parseProgram; | |
extra.parsePropertyFunction = parsePropertyFunction; | |
extra.parseRelationalExpression = parseRelationalExpression; | |
extra.parseStatement = parseStatement; | |
extra.parseShiftExpression = parseShiftExpression; | |
extra.parseSwitchCase = parseSwitchCase; | |
extra.parseUnaryExpression = parseUnaryExpression; | |
extra.parseVariableDeclaration = parseVariableDeclaration; | |
extra.parseVariableIdentifier = parseVariableIdentifier; | |
parseAdditiveExpression = wrapTracking(extra.parseAdditiveExpression); | |
parseAssignmentExpression = wrapTracking(extra.parseAssignmentExpression); | |
parseBitwiseANDExpression = wrapTracking(extra.parseBitwiseANDExpression); | |
parseBitwiseORExpression = wrapTracking(extra.parseBitwiseORExpression); | |
parseBitwiseXORExpression = wrapTracking(extra.parseBitwiseXORExpression); | |
parseBlock = wrapTracking(extra.parseBlock); | |
parseFunctionSourceElements = wrapTracking(extra.parseFunctionSourceElements); | |
parseCatchClause = wrapTracking(extra.parseCatchClause); | |
parseComputedMember = wrapTracking(extra.parseComputedMember); | |
parseConditionalExpression = wrapTracking(extra.parseConditionalExpression); | |
parseConstLetDeclaration = wrapTracking(extra.parseConstLetDeclaration); | |
parseEqualityExpression = wrapTracking(extra.parseEqualityExpression); | |
parseExpression = wrapTracking(extra.parseExpression); | |
parseForVariableDeclaration = wrapTracking(extra.parseForVariableDeclaration); | |
parseFunctionDeclaration = wrapTracking(extra.parseFunctionDeclaration); | |
parseFunctionExpression = wrapTracking(extra.parseFunctionExpression); | |
parseLeftHandSideExpression = wrapTracking(parseLeftHandSideExpression); | |
parseLogicalANDExpression = wrapTracking(extra.parseLogicalANDExpression); | |
parseLogicalORExpression = wrapTracking(extra.parseLogicalORExpression); | |
parseMultiplicativeExpression = wrapTracking(extra.parseMultiplicativeExpression); | |
parseNewExpression = wrapTracking(extra.parseNewExpression); | |
parseNonComputedProperty = wrapTracking(extra.parseNonComputedProperty); | |
parseObjectProperty = wrapTracking(extra.parseObjectProperty); | |
parseObjectPropertyKey = wrapTracking(extra.parseObjectPropertyKey); | |
parsePostfixExpression = wrapTracking(extra.parsePostfixExpression); | |
parsePrimaryExpression = wrapTracking(extra.parsePrimaryExpression); | |
parseProgram = wrapTracking(extra.parseProgram); | |
parsePropertyFunction = wrapTracking(extra.parsePropertyFunction); | |
parseRelationalExpression = wrapTracking(extra.parseRelationalExpression); | |
parseStatement = wrapTracking(extra.parseStatement); | |
parseShiftExpression = wrapTracking(extra.parseShiftExpression); | |
parseSwitchCase = wrapTracking(extra.parseSwitchCase); | |
parseUnaryExpression = wrapTracking(extra.parseUnaryExpression); | |
parseVariableDeclaration = wrapTracking(extra.parseVariableDeclaration); | |
parseVariableIdentifier = wrapTracking(extra.parseVariableIdentifier); | |
} | |
if (typeof extra.tokens !== 'undefined') { | |
extra.advance = advance; | |
extra.scanRegExp = scanRegExp; | |
advance = collectToken; | |
scanRegExp = collectRegex; | |
} | |
} | |
function unpatch() { | |
if (typeof extra.skipComment === 'function') { | |
skipComment = extra.skipComment; | |
} | |
if (extra.raw) { | |
createLiteral = extra.createLiteral; | |
} | |
if (extra.range || extra.loc) { | |
parseAdditiveExpression = extra.parseAdditiveExpression; | |
parseAssignmentExpression = extra.parseAssignmentExpression; | |
parseBitwiseANDExpression = extra.parseBitwiseANDExpression; | |
parseBitwiseORExpression = extra.parseBitwiseORExpression; | |
parseBitwiseXORExpression = extra.parseBitwiseXORExpression; | |
parseBlock = extra.parseBlock; | |
parseFunctionSourceElements = extra.parseFunctionSourceElements; | |
parseCatchClause = extra.parseCatchClause; | |
parseComputedMember = extra.parseComputedMember; | |
parseConditionalExpression = extra.parseConditionalExpression; | |
parseConstLetDeclaration = extra.parseConstLetDeclaration; | |
parseEqualityExpression = extra.parseEqualityExpression; | |
parseExpression = extra.parseExpression; | |
parseForVariableDeclaration = extra.parseForVariableDeclaration; | |
parseFunctionDeclaration = extra.parseFunctionDeclaration; | |
parseFunctionExpression = extra.parseFunctionExpression; | |
parseGroupExpression = extra.parseGroupExpression; | |
parseLeftHandSideExpression = extra.parseLeftHandSideExpression; | |
parseLeftHandSideExpressionAllowCall = extra.parseLeftHandSideExpressionAllowCall; | |
parseLogicalANDExpression = extra.parseLogicalANDExpression; | |
parseLogicalORExpression = extra.parseLogicalORExpression; | |
parseMultiplicativeExpression = extra.parseMultiplicativeExpression; | |
parseNewExpression = extra.parseNewExpression; | |
parseNonComputedProperty = extra.parseNonComputedProperty; | |
parseObjectProperty = extra.parseObjectProperty; | |
parseObjectPropertyKey = extra.parseObjectPropertyKey; | |
parsePrimaryExpression = extra.parsePrimaryExpression; | |
parsePostfixExpression = extra.parsePostfixExpression; | |
parseProgram = extra.parseProgram; | |
parsePropertyFunction = extra.parsePropertyFunction; | |
parseRelationalExpression = extra.parseRelationalExpression; | |
parseStatement = extra.parseStatement; | |
parseShiftExpression = extra.parseShiftExpression; | |
parseSwitchCase = extra.parseSwitchCase; | |
parseUnaryExpression = extra.parseUnaryExpression; | |
parseVariableDeclaration = extra.parseVariableDeclaration; | |
parseVariableIdentifier = extra.parseVariableIdentifier; | |
} | |
if (typeof extra.scanRegExp === 'function') { | |
advance = extra.advance; | |
scanRegExp = extra.scanRegExp; | |
} | |
} | |
function stringToArray(str) { | |
var length = str.length, | |
result = [], | |
i; | |
for (i = 0; i < length; ++i) { | |
result[i] = str.charAt(i); | |
} | |
return result; | |
} | |
function parse(code, options) { | |
var program, toString; | |
toString = String; | |
if (typeof code !== 'string' && !(code instanceof String)) { | |
code = toString(code); | |
} | |
source = code; | |
index = 0; | |
lineNumber = (source.length > 0) ? 1 : 0; | |
lineStart = 0; | |
length = source.length; | |
buffer = null; | |
state = { | |
allowIn: true, | |
labelSet: {}, | |
inFunctionBody: false, | |
inIteration: false, | |
inSwitch: false | |
}; | |
extra = {}; | |
if (typeof options !== 'undefined') { | |
extra.range = (typeof options.range === 'boolean') && options.range; | |
extra.loc = (typeof options.loc === 'boolean') && options.loc; | |
extra.raw = (typeof options.raw === 'boolean') && options.raw; | |
if (typeof options.tokens === 'boolean' && options.tokens) { | |
extra.tokens = []; | |
} | |
if (typeof options.comment === 'boolean' && options.comment) { | |
extra.comments = []; | |
} | |
if (typeof options.tolerant === 'boolean' && options.tolerant) { | |
extra.errors = []; | |
} | |
} | |
if (length > 0) { | |
if (typeof source[0] === 'undefined') { | |
// Try first to convert to a string. This is good as fast path | |
// for old IE which understands string indexing for string | |
// literals only and not for string object. | |
if (code instanceof String) { | |
source = code.valueOf(); | |
} | |
// Force accessing the characters via an array. | |
if (typeof source[0] === 'undefined') { | |
source = stringToArray(code); | |
} | |
} | |
} | |
patch(); | |
try { | |
program = parseProgram(); | |
if (typeof extra.comments !== 'undefined') { | |
filterCommentLocation(); | |
program.comments = extra.comments; | |
} | |
if (typeof extra.tokens !== 'undefined') { | |
filterTokenLocation(); | |
program.tokens = extra.tokens; | |
} | |
if (typeof extra.errors !== 'undefined') { | |
program.errors = extra.errors; | |
} | |
if (extra.range || extra.loc) { | |
program.body = filterGroup(program.body); | |
} | |
} catch (e) { | |
throw e; | |
} finally { | |
unpatch(); | |
extra = {}; | |
} | |
return program; | |
} | |
// Sync with package.json. | |
exports.version = '1.0.4'; | |
exports.parse = parse; | |
// Deep copy. | |
exports.Syntax = (function () { | |
var name, types = {}; | |
if (typeof Object.create === 'function') { | |
types = Object.create(null); | |
} | |
for (name in Syntax) { | |
if (Syntax.hasOwnProperty(name)) { | |
types[name] = Syntax[name]; | |
} | |
} | |
if (typeof Object.freeze === 'function') { | |
Object.freeze(types); | |
} | |
return types; | |
}()); | |
})); | |
/* vim: set sw=4 ts=4 et tw=80 : */ | |
})() | |
},{}],19:[function(require,module,exports){ | |
"use strict" | |
function unique_pred(list, compare) { | |
var ptr = 1 | |
, len = list.length | |
, a=list[0], b=list[0] | |
for(var i=1; i<len; ++i) { | |
b = a | |
a = list[i] | |
if(compare(a, b)) { | |
if(i === ptr) { | |
ptr++ | |
continue | |
} | |
list[ptr++] = a | |
} | |
} | |
list.length = ptr | |
return list | |
} | |
function unique_eq(list) { | |
var ptr = 1 | |
, len = list.length | |
, a=list[0], b = list[0] | |
for(var i=1; i<len; ++i, b=a) { | |
b = a | |
a = list[i] | |
if(a !== b) { | |
if(i === ptr) { | |
ptr++ | |
continue | |
} | |
list[ptr++] = a | |
} | |
} | |
list.length = ptr | |
return list | |
} | |
function unique(list, compare, sorted) { | |
if(list.length === 0) { | |
return [] | |
} | |
if(compare) { | |
if(!sorted) { | |
list.sort(compare) | |
} | |
return unique_pred(list, compare) | |
} | |
if(!sorted) { | |
list.sort() | |
} | |
return unique_eq(list) | |
} | |
module.exports = unique | |
},{}],15:[function(require,module,exports){ | |
"use strict" | |
var compile = require("./compile.js") | |
function createThunk(proc) { | |
var code = ["'use strict'", "var CACHED={}"] | |
var vars = [] | |
var thunkName = proc.funcName + "_cwise_thunk" | |
//Build thunk | |
code.push(["return function ", thunkName, "(", proc.shimArgs.join(","), "){"].join("")) | |
var typesig = [] | |
var string_typesig = [] | |
var proc_args = [["array",proc.arrayArgs[0],".shape"].join("")] | |
for(var i=0; i<proc.arrayArgs.length; ++i) { | |
var j = proc.arrayArgs[i] | |
vars.push(["t", j, "=array", j, ".dtype,", | |
"r", j, "=array", j, ".order"].join("")) | |
typesig.push("t" + j) | |
typesig.push("r" + j) | |
string_typesig.push("t"+j) | |
string_typesig.push("r"+j+".join()") | |
proc_args.push("array" + j + ".data") | |
proc_args.push("array" + j + ".stride") | |
proc_args.push("array" + j + ".offset|0") | |
} | |
for(var i=0; i<proc.scalarArgs.length; ++i) { | |
proc_args.push("scalar" + proc.scalarArgs[i]) | |
} | |
vars.push(["type=[", string_typesig.join(","), "].join()"].join("")) | |
vars.push("proc=CACHED[type]") | |
code.push("var " + vars.join(",")) | |
code.push(["if(!proc){", | |
"CACHED[type]=proc=compile([", typesig.join(","), "])}", | |
"return proc(", proc_args.join(","), ")}"].join("")) | |
if(proc.debug) { | |
console.log("Generated thunk:", code.join("\n")) | |
} | |
//Compile thunk | |
var thunk = new Function("compile", code.join("\n")) | |
return thunk(compile.bind(undefined, proc)) | |
} | |
module.exports = createThunk | |
},{"./compile.js":21}],20:[function(require,module,exports){ | |
"use strict" | |
var uniq = require("uniq") | |
function innerFill(order, proc, body) { | |
var dimension = order.length | |
, nargs = proc.arrayArgs.length | |
, has_index = proc.indexArgs.length>0 | |
, code = [] | |
, vars = [] | |
, idx=0, pidx=0, i, j | |
for(i=0; i<dimension; ++i) { | |
vars.push(["i",i,"=0"].join("")) | |
} | |
//Compute scan deltas | |
for(j=0; j<nargs; ++j) { | |
for(i=0; i<dimension; ++i) { | |
pidx = idx | |
idx = order[i] | |
if(i === 0) { | |
vars.push(["d",j,"s",i,"=t",j,"[",idx,"]"].join("")) | |
} else { | |
vars.push(["d",j,"s",i,"=(t",j,"[",idx,"]-s",pidx,"*t",j,"[",pidx,"])"].join("")) | |
} | |
} | |
} | |
code.push("var " + vars.join(",")) | |
//Scan loop | |
for(i=dimension-1; i>=0; --i) { | |
idx = order[i] | |
code.push(["for(i",i,"=0;i",i,"<s",idx,";++i",i,"){"].join("")) | |
} | |
//Push body of inner loop | |
code.push(body) | |
//Advance scan pointers | |
for(i=0; i<dimension; ++i) { | |
pidx = idx | |
idx = order[i] | |
for(j=0; j<nargs; ++j) { | |
code.push(["p",j,"+=d",j,"s",i].join("")) | |
} | |
if(has_index) { | |
if(i > 0) { | |
code.push(["index[",pidx,"]-=s",pidx].join("")) | |
} | |
code.push(["++index[",idx,"]"].join("")) | |
} | |
code.push("}") | |
} | |
return code.join("\n") | |
} | |
function outerFill(matched, order, proc, body) { | |
var dimension = order.length | |
, nargs = proc.arrayArgs.length | |
, blockSize = proc.blockSize | |
, has_index = proc.indexArgs.length > 0 | |
, code = [] | |
for(var i=0; i<nargs; ++i) { | |
code.push(["var offset",i,"=p",i].join("")) | |
} | |
//Generate matched loops | |
for(var i=matched; i<dimension; ++i) { | |
code.push(["for(var j"+i+"=SS[", order[i], "]|0;j", i, ">0;){"].join("")) | |
code.push(["if(j",i,"<",blockSize,"){"].join("")) | |
code.push(["s",order[i],"=j",i].join("")) | |
code.push(["j",i,"=0"].join("")) | |
code.push(["}else{s",order[i],"=",blockSize].join("")) | |
code.push(["j",i,"-=",blockSize,"}"].join("")) | |
if(has_index) { | |
code.push(["index[",order[i],"]=j",i].join("")) | |
} | |
} | |
for(var i=0; i<nargs; ++i) { | |
var indexStr = ["offset"+i] | |
for(var j=matched; j<dimension; ++j) { | |
indexStr.push(["j",j,"*t",i,"[",order[j],"]"].join("")) | |
} | |
code.push(["p",i,"=(",indexStr.join("+"),")"].join("")) | |
} | |
code.push(innerFill(order, proc, body)) | |
for(var i=matched; i<dimension; ++i) { | |
code.push("}") | |
} | |
return code.join("\n") | |
} | |
//Count the number of compatible inner orders | |
function countMatches(orders) { | |
var matched = 0, dimension = orders[0].length | |
while(matched < dimension) { | |
for(var j=1; j<orders.length; ++j) { | |
if(orders[j][matched] !== orders[0][matched]) { | |
return matched | |
} | |
} | |
++matched | |
} | |
return matched | |
} | |
//Processes a block according to the given data types | |
function processBlock(block, proc, dtypes) { | |
var code = block.body | |
var pre = [] | |
var post = [] | |
for(var i=0; i<block.args.length; ++i) { | |
var carg = block.args[i] | |
if(carg.count <= 0) { | |
continue | |
} | |
var re = new RegExp(carg.name, "g") | |
switch(proc.argTypes[i]) { | |
case "array": | |
var arrNum = proc.arrayArgs.indexOf(i) | |
if(carg.count === 1) { | |
if(dtypes[arrNum] === "generic") { | |
if(carg.lvalue) { | |
pre.push(["var l", arrNum, "=a", arrNum, ".get(p", arrNum, ")"].join("")) | |
code = code.replace(re, "l"+arrNum) | |
post.push(["a", arrNum, ".set(p", arrNum, ",l",arrNum,")"].join("")) | |
} else { | |
code = code.replace(re, ["a", arrNum, ".get(p", arrNum, ")"].join("")) | |
} | |
} else { | |
code = code.replace(re, ["a", arrNum, "[p", arrNum, "]"].join("")) | |
} | |
} else if(dtypes[arrNum] === "generic") { | |
pre.push(["var l", arrNum, "=a", arrNum, ".get(p", arrNum, ")"].join("")) | |
code = code.replace(re, "l"+arrNum) | |
if(carg.lvalue) { | |
post.push(["a", arrNum, ".set(p", arrNum, ",l",arrNum,")"].join("")) | |
} | |
} else { | |
pre.push(["var l", arrNum, "=a", arrNum, "[p", arrNum, "]"].join("")) | |
code = code.replace(re, "l"+arrNum) | |
if(carg.lvalue) { | |
post.push(["a", arrNum, "[p", arrNum, "]=l",arrNum].join("")) | |
} | |
} | |
break | |
case "scalar": | |
code = code.replace(re, "Y" + proc.scalarArgs.indexOf(i)) | |
break | |
case "index": | |
code = code.replace(re, "index") | |
break | |
case "shape": | |
code = code.replace(re, "shape") | |
break | |
} | |
} | |
return [pre.join("\n"), code, post.join("\n")].join("\n").trim() | |
} | |
function typeSummary(dtypes) { | |
var summary = new Array(dtypes.length) | |
var allEqual = true | |
for(var i=0; i<dtypes.length; ++i) { | |
var t = dtypes[i] | |
var digits = t.match(/\d+/) | |
if(!digits) { | |
digits = "" | |
} else { | |
digits = digits[0] | |
} | |
if(t.charAt(0) === 0) { | |
summary[i] = "u" + t.charAt(1) + digits | |
} else { | |
summary[i] = t.charAt(0) + digits | |
} | |
if(i > 0) { | |
allEqual = allEqual && summary[i] === summary[i-1] | |
} | |
} | |
if(allEqual) { | |
return summary[0] | |
} | |
return summary.join("") | |
} | |
//Generates a cwise operator | |
function generateCWiseOp(proc, typesig) { | |
//Compute dimension | |
var dimension = typesig[1].length|0 | |
var orders = new Array(proc.arrayArgs.length) | |
var dtypes = new Array(proc.arrayArgs.length) | |
//First create arguments for procedure | |
var arglist = ["SS"] | |
var code = ["'use strict'"] | |
var vars = [] | |
for(var j=0; j<dimension; ++j) { | |
vars.push(["s", j, "=SS[", j, "]"].join("")) | |
} | |
for(var i=0; i<proc.arrayArgs.length; ++i) { | |
arglist.push("a"+i) | |
arglist.push("t"+i) | |
arglist.push("p"+i) | |
dtypes[i] = typesig[2*i] | |
orders[i] = typesig[2*i+1] | |
} | |
for(var i=0; i<proc.scalarArgs.length; ++i) { | |
arglist.push("Y" + i) | |
} | |
if(proc.shapeArgs.length > 0) { | |
vars.push("shape=SS.slice(0)") | |
} | |
if(proc.indexArgs.length > 0) { | |
var zeros = new Array(dimension) | |
for(var i=0; i<dimension; ++i) { | |
zeros[i] = "0" | |
} | |
vars.push(["index=[", zeros.join(","), "]"].join("")) | |
} | |
//Prepare this variables | |
var thisVars = uniq([].concat(proc.pre.thisVars) | |
.concat(proc.body.thisVars) | |
.concat(proc.post.thisVars)) | |
vars = vars.concat(thisVars) | |
code.push("var " + vars.join(",")) | |
for(var i=0; i<proc.arrayArgs.length; ++i) { | |
code.push("p"+i+"|=0") | |
} | |
//Inline prelude | |
if(proc.pre.body.length > 3) { | |
code.push(processBlock(proc.pre, proc, dtypes)) | |
} | |
//Process body | |
var body = processBlock(proc.body, proc, dtypes) | |
var matched = countMatches(orders) | |
if(matched < dimension) { | |
code.push(outerFill(matched, orders[0], proc, body)) | |
} else { | |
code.push(innerFill(orders[0], proc, body)) | |
} | |
//Inline epilog | |
if(proc.post.body.length > 3) { | |
code.push(processBlock(proc.post, proc, dtypes)) | |
} | |
if(proc.debug) { | |
console.log("Generated cwise routine for ", typesig, ":\n\n", code.join("\n")) | |
} | |
var loopName = [(proc.funcName||"unnamed"), "_cwise_loop_", orders[0].join("s"),"m",matched,typeSummary(dtypes)].join("") | |
var f = new Function(["function ",loopName,"(", arglist.join(","),"){", code.join("\n"),"} return ", loopName].join("")) | |
return f() | |
} | |
module.exports = generateCWiseOp | |
},{"uniq":22}],21:[function(require,module,exports){ | |
"use strict" | |
var uniq = require("uniq") | |
function innerFill(order, proc, body) { | |
var dimension = order.length | |
, nargs = proc.arrayArgs.length | |
, has_index = proc.indexArgs.length>0 | |
, code = [] | |
, vars = [] | |
, idx=0, pidx=0, i, j | |
for(i=0; i<dimension; ++i) { | |
vars.push(["i",i,"=0"].join("")) | |
} | |
//Compute scan deltas | |
for(j=0; j<nargs; ++j) { | |
for(i=0; i<dimension; ++i) { | |
pidx = idx | |
idx = order[i] | |
if(i === 0) { | |
vars.push(["d",j,"s",i,"=t",j,"[",idx,"]"].join("")) | |
} else { | |
vars.push(["d",j,"s",i,"=(t",j,"[",idx,"]-s",pidx,"*t",j,"[",pidx,"])"].join("")) | |
} | |
} | |
} | |
code.push("var " + vars.join(",")) | |
//Scan loop | |
for(i=dimension-1; i>=0; --i) { | |
idx = order[i] | |
code.push(["for(i",i,"=0;i",i,"<s",idx,";++i",i,"){"].join("")) | |
} | |
//Push body of inner loop | |
code.push(body) | |
//Advance scan pointers | |
for(i=0; i<dimension; ++i) { | |
pidx = idx | |
idx = order[i] | |
for(j=0; j<nargs; ++j) { | |
code.push(["p",j,"+=d",j,"s",i].join("")) | |
} | |
if(has_index) { | |
if(i > 0) { | |
code.push(["index[",pidx,"]-=s",pidx].join("")) | |
} | |
code.push(["++index[",idx,"]"].join("")) | |
} | |
code.push("}") | |
} | |
return code.join("\n") | |
} | |
function outerFill(matched, order, proc, body) { | |
var dimension = order.length | |
, nargs = proc.arrayArgs.length | |
, blockSize = proc.blockSize | |
, has_index = proc.indexArgs.length > 0 | |
, code = [] | |
for(var i=0; i<nargs; ++i) { | |
code.push(["var offset",i,"=p",i].join("")) | |
} | |
//Generate matched loops | |
for(var i=matched; i<dimension; ++i) { | |
code.push(["for(var j"+i+"=SS[", order[i], "]|0;j", i, ">0;){"].join("")) | |
code.push(["if(j",i,"<",blockSize,"){"].join("")) | |
code.push(["s",order[i],"=j",i].join("")) | |
code.push(["j",i,"=0"].join("")) | |
code.push(["}else{s",order[i],"=",blockSize].join("")) | |
code.push(["j",i,"-=",blockSize,"}"].join("")) | |
if(has_index) { | |
code.push(["index[",order[i],"]=j",i].join("")) | |
} | |
} | |
for(var i=0; i<nargs; ++i) { | |
var indexStr = ["offset"+i] | |
for(var j=matched; j<dimension; ++j) { | |
indexStr.push(["j",j,"*t",i,"[",order[j],"]"].join("")) | |
} | |
code.push(["p",i,"=(",indexStr.join("+"),")"].join("")) | |
} | |
code.push(innerFill(order, proc, body)) | |
for(var i=matched; i<dimension; ++i) { | |
code.push("}") | |
} | |
return code.join("\n") | |
} | |
//Count the number of compatible inner orders | |
function countMatches(orders) { | |
var matched = 0, dimension = orders[0].length | |
while(matched < dimension) { | |
for(var j=1; j<orders.length; ++j) { | |
if(orders[j][matched] !== orders[0][matched]) { | |
return matched | |
} | |
} | |
++matched | |
} | |
return matched | |
} | |
//Processes a block according to the given data types | |
function processBlock(block, proc, dtypes) { | |
var code = block.body | |
var pre = [] | |
var post = [] | |
for(var i=0; i<block.args.length; ++i) { | |
var carg = block.args[i] | |
if(carg.count <= 0) { | |
continue | |
} | |
var re = new RegExp(carg.name, "g") | |
switch(proc.argTypes[i]) { | |
case "array": | |
var arrNum = proc.arrayArgs.indexOf(i) | |
if(carg.count === 1) { | |
if(dtypes[arrNum] === "generic") { | |
if(carg.lvalue) { | |
pre.push(["var l", arrNum, "=a", arrNum, ".get(p", arrNum, ")"].join("")) | |
code = code.replace(re, "l"+arrNum) | |
post.push(["a", arrNum, ".set(p", arrNum, ",l",arrNum,")"].join("")) | |
} else { | |
code = code.replace(re, ["a", arrNum, ".get(p", arrNum, ")"].join("")) | |
} | |
} else { | |
code = code.replace(re, ["a", arrNum, "[p", arrNum, "]"].join("")) | |
} | |
} else if(dtypes[arrNum] === "generic") { | |
pre.push(["var l", arrNum, "=a", arrNum, ".get(p", arrNum, ")"].join("")) | |
code = code.replace(re, "l"+arrNum) | |
if(carg.lvalue) { | |
post.push(["a", arrNum, ".set(p", arrNum, ",l",arrNum,")"].join("")) | |
} | |
} else { | |
pre.push(["var l", arrNum, "=a", arrNum, "[p", arrNum, "]"].join("")) | |
code = code.replace(re, "l"+arrNum) | |
if(carg.lvalue) { | |
post.push(["a", arrNum, "[p", arrNum, "]=l",arrNum].join("")) | |
} | |
} | |
break | |
case "scalar": | |
code = code.replace(re, "Y" + proc.scalarArgs.indexOf(i)) | |
break | |
case "index": | |
code = code.replace(re, "index") | |
break | |
case "shape": | |
code = code.replace(re, "shape") | |
break | |
} | |
} | |
return [pre.join("\n"), code, post.join("\n")].join("\n").trim() | |
} | |
function typeSummary(dtypes) { | |
var summary = new Array(dtypes.length) | |
var allEqual = true | |
for(var i=0; i<dtypes.length; ++i) { | |
var t = dtypes[i] | |
var digits = t.match(/\d+/) | |
if(!digits) { | |
digits = "" | |
} else { | |
digits = digits[0] | |
} | |
if(t.charAt(0) === 0) { | |
summary[i] = "u" + t.charAt(1) + digits | |
} else { | |
summary[i] = t.charAt(0) + digits | |
} | |
if(i > 0) { | |
allEqual = allEqual && summary[i] === summary[i-1] | |
} | |
} | |
if(allEqual) { | |
return summary[0] | |
} | |
return summary.join("") | |
} | |
//Generates a cwise operator | |
function generateCWiseOp(proc, typesig) { | |
//Compute dimension | |
var dimension = typesig[1].length|0 | |
var orders = new Array(proc.arrayArgs.length) | |
var dtypes = new Array(proc.arrayArgs.length) | |
//First create arguments for procedure | |
var arglist = ["SS"] | |
var code = ["'use strict'"] | |
var vars = [] | |
for(var j=0; j<dimension; ++j) { | |
vars.push(["s", j, "=SS[", j, "]"].join("")) | |
} | |
for(var i=0; i<proc.arrayArgs.length; ++i) { | |
arglist.push("a"+i) | |
arglist.push("t"+i) | |
arglist.push("p"+i) | |
dtypes[i] = typesig[2*i] | |
orders[i] = typesig[2*i+1] | |
} | |
for(var i=0; i<proc.scalarArgs.length; ++i) { | |
arglist.push("Y" + i) | |
} | |
if(proc.shapeArgs.length > 0) { | |
vars.push("shape=SS.slice(0)") | |
} | |
if(proc.indexArgs.length > 0) { | |
var zeros = new Array(dimension) | |
for(var i=0; i<dimension; ++i) { | |
zeros[i] = "0" | |
} | |
vars.push(["index=[", zeros.join(","), "]"].join("")) | |
} | |
//Prepare this variables | |
var thisVars = uniq([].concat(proc.pre.thisVars) | |
.concat(proc.body.thisVars) | |
.concat(proc.post.thisVars)) | |
vars = vars.concat(thisVars) | |
code.push("var " + vars.join(",")) | |
for(var i=0; i<proc.arrayArgs.length; ++i) { | |
code.push("p"+i+"|=0") | |
} | |
//Inline prelude | |
if(proc.pre.body.length > 3) { | |
code.push(processBlock(proc.pre, proc, dtypes)) | |
} | |
//Process body | |
var body = processBlock(proc.body, proc, dtypes) | |
var matched = countMatches(orders) | |
if(matched < dimension) { | |
code.push(outerFill(matched, orders[0], proc, body)) | |
} else { | |
code.push(innerFill(orders[0], proc, body)) | |
} | |
//Inline epilog | |
if(proc.post.body.length > 3) { | |
code.push(processBlock(proc.post, proc, dtypes)) | |
} | |
if(proc.debug) { | |
console.log("Generated cwise routine for ", typesig, ":\n\n", code.join("\n")) | |
} | |
var loopName = [(proc.funcName||"unnamed"), "_cwise_loop_", orders[0].join("s"),"m",matched,typeSummary(dtypes)].join("") | |
var f = new Function(["function ",loopName,"(", arglist.join(","),"){", code.join("\n"),"} return ", loopName].join("")) | |
return f() | |
} | |
module.exports = generateCWiseOp | |
},{"uniq":23}],22:[function(require,module,exports){ | |
"use strict" | |
function unique_pred(list, compare) { | |
var ptr = 1 | |
, len = list.length | |
, a=list[0], b=list[0] | |
for(var i=1; i<len; ++i) { | |
b = a | |
a = list[i] | |
if(compare(a, b)) { | |
if(i === ptr) { | |
ptr++ | |
continue | |
} | |
list[ptr++] = a | |
} | |
} | |
list.length = ptr | |
return list | |
} | |
function unique_eq(list) { | |
var ptr = 1 | |
, len = list.length | |
, a=list[0], b = list[0] | |
for(var i=1; i<len; ++i, b=a) { | |
b = a | |
a = list[i] | |
if(a !== b) { | |
if(i === ptr) { | |
ptr++ | |
continue | |
} | |
list[ptr++] = a | |
} | |
} | |
list.length = ptr | |
return list | |
} | |
function unique(list, compare, sorted) { | |
if(list.length === 0) { | |
return [] | |
} | |
if(compare) { | |
if(!sorted) { | |
list.sort(compare) | |
} | |
return unique_pred(list, compare) | |
} | |
if(!sorted) { | |
list.sort() | |
} | |
return unique_eq(list) | |
} | |
module.exports = unique | |
},{}],23:[function(require,module,exports){ | |
"use strict" | |
function unique_pred(list, compare) { | |
var ptr = 1 | |
, len = list.length | |
, a=list[0], b=list[0] | |
for(var i=1; i<len; ++i) { | |
b = a | |
a = list[i] | |
if(compare(a, b)) { | |
if(i === ptr) { | |
ptr++ | |
continue | |
} | |
list[ptr++] = a | |
} | |
} | |
list.length = ptr | |
return list | |
} | |
function unique_eq(list) { | |
var ptr = 1 | |
, len = list.length | |
, a=list[0], b = list[0] | |
for(var i=1; i<len; ++i, b=a) { | |
b = a | |
a = list[i] | |
if(a !== b) { | |
if(i === ptr) { | |
ptr++ | |
continue | |
} | |
list[ptr++] = a | |
} | |
} | |
list.length = ptr | |
return list | |
} | |
function unique(list, compare, sorted) { | |
if(list.length === 0) { | |
return [] | |
} | |
if(compare) { | |
if(!sorted) { | |
list.sort(compare) | |
} | |
return unique_pred(list, compare) | |
} | |
if(!sorted) { | |
list.sort() | |
} | |
return unique_eq(list) | |
} | |
module.exports = unique | |
},{}]},{},[]) | |
//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJhdGVkLmpzIiwic291cmNlcyI6WyIvcHJpdmF0ZS92YXIvZm9sZGVycy80My96N3B2OHB2ZDR4NTdudF8xenoyNTYxdHcwMDAwZ24vVC9jYXZlLWF1dG9tYXRhLTJkMTEzODQtNDIzNDYtMWVmYXN2Ni9ub2RlX21vZHVsZXMvY2F2ZS1hdXRvbWF0YS0yZC9pbmRleC5qcyIsIi9wcml2YXRlL3Zhci9mb2xkZXJzLzQzL3o3cHY4cHZkNHg1N250XzF6ejI1NjF0dzAw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ICAgICAgICAvL0Rvbid0IHJld3JpdGUgZ2xvYmFsc1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcmV3cml0ZShub2RlLCBjcmVhdGVMb2NhbChuYW1lKSlcbiAgICAgIH1cbiAgICB9IGVsc2UgaWYobm9kZS50eXBlID09PSBcIkxpdGVyYWxcIikge1xuICAgICAgaWYodHlwZW9mIG5vZGUudmFsdWUgPT09IFwic3RyaW5nXCIpIHtcbiAgICAgICAgcmV3cml0ZShub2RlLCBlc2NhcGVTdHJpbmcobm9kZS52YWx1ZSkpXG4gICAgICB9XG4gICAgfSBlbHNlIGlmKG5vZGUudHlwZSA9PT0gXCJXaXRoU3RhdGVtZW50XCIpIHtcbiAgICAgIHRocm93IG5ldyBFcnJvcihcImN3aXNlLXBhcnNlcjogd2l0aCgpIHN0YXRlbWVudHMgbm90IGFsbG93ZWRcIilcbiAgICB9IGVsc2Uge1xuICAgICAgLy9WaXNpdCBhbGwgY2hpbGRyZW5cbiAgICAgIHZhciBrZXlzID0gT2JqZWN0LmtleXMobm9kZSlcbiAgICAgIGZvcih2YXIgaT0wLCBuPWtleXMubGVuZ3RoOyBpPG47ICsraSkge1xuICAgICAgICBpZihrZXlzW2ldID09PSBcInBhcmVudFwiKSB7XG4gICAgICAgICAgY29udGludWVcbiAgICAgICAgfVxuICAgICAgICB2YXIgdmFsdWUgPSBub2RlW2tleXNbaV1dXG4gICAgICAgIGlmKHZhbHVlKSB7XG4gICAgICAgICAgaWYodmFsdWUgaW5zdGFuY2VvZiBBcnJheSkge1xuICAgICAgICAgICAgZm9yKHZhciBqPTA7IGo8dmFsdWUubGVuZ3RoOyArK2opIHtcbiAgICAgICAgICAgICAgaWYodmFsdWVbal0gJiYgdHlwZW9mIHZhbHVlW2pdLnR5cGUgPT09IFwic3RyaW5nXCIpIHtcbiAgICAgICAgICAgICAgICB2aXNpdCh2YWx1ZVtqXSwgbm9kZSlcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAg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GVsc2Uge1xuICAgICAgLy9WaXNpdCBhbGwgY2hpbGRyZW5cbiAgICAgIHZhciBrZXlzID0gT2JqZWN0LmtleXMobm9kZSlcbiAgICAgIGZvcih2YXIgaT0wLCBuPWtleXMubGVuZ3RoOyBpPG47ICsraSkge1xuICAgICAgICBpZihrZXlzW2ldID09PSBcInBhcmVudFwiKSB7XG4gICAgICAgICAgY29udGludWVcbiAgICAgICAgfVxuICAgICAgICB2YXIgdmFsdWUgPSBub2RlW2tleXNbaV1dXG4gICAgICAgIGlmKHZhbHVlKSB7XG4gICAgICAgICAgaWYodmFsdWUgaW5zdGFuY2VvZiBBcnJheSkge1xuICAgICAgICAgICAgZm9yKHZhciBqPTA7IGo8dmFsdWUubGVuZ3RoOyArK2opIHtcbiAgICAgICAgICAgICAgaWYodmFsdWVbal0gJiYgdHlwZW9mIHZhbHVlW2pdLnR5cGUgPT09IFwic3RyaW5nXCIpIHtcbiAgICAgICAgICAgICAgICB2aXNpdCh2YWx1ZVtqXSwgbm9kZSlcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSBpZih0eXBlb2YgdmFsdWUudHlwZSA9PT0gXCJzdHJpbmdcIikge1xuICAgICAgICAgICAgdmlzaXQodmFsdWUsIG5vZGUpXG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICB9KShhc3QuYm9keVswXS5leHByZXNzaW9uLmNhbGxlZS5ib2R5LCB1bmRlZmluZWQpXG4gIFxuICAvL1JlbW92ZSBkdXBsaWNhdGUgdmFyaWFibGVzXG4gIHVuaXEobG9jYWxWYXJzKVxuICB1bmlxKHRoaXNWYXJzKVxuICBcbiAgLy9SZXR1cm4gYm9keVxuICB2YXIgcm91dGluZSA9IG5ldyBDb21waWxlZFJvdXRpbmUoc291cmNlKGFzdC5ib2R5WzBdLmV4cHJlc3Npb24uY2FsbGVlLmJvZHkpLCBjb21waWxlZEFyZ3MsIHRoaXNWYXJzLC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uICAgIC8vIFJoaW5vLCBhbmQgcGxhaW4gYnJvd3NlciBsb2FkaW5nLlxuICAgIGlmICh0eXBlb2YgZGVmaW5lID09PSAnZnVuY3Rpb24nICYmIGRlZmluZS5hbWQpIHtcbiAgICAgICAgZGVmaW5lKFsnZXhwb3J0cyddLCBmYWN0b3J5KTtcbiAgICB9IGVsc2UgaWYgKHR5cGVvZiBleHBvcnRzICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICBmYWN0b3J5KGV4cG9ydHMpO1xuICAgIH0gZWxzZSB7XG4gICAgICAgIGZhY3RvcnkoKHJvb3QuZXNwcmltYSA9IHt9KSk7XG4gICAgfVxufSh0aGlzLCBmdW5jdGlvbiAoZXhwb3J0cykge1xuICAgICd1c2Ugc3RyaWN0JztcblxuICAgIHZhciBUb2tlbixcbiAgICAgICAgVG9rZW5OYW1lLFxuICAgICAgICBTeW50YXgsXG4gICAgICAgIFByb3BlcnR5S2luZCxcbiAgICAgICAgTWVzc2FnZXMsXG4gICAgICAgIFJlZ2V4LFxuICAgICAgICBzb3VyY2UsXG4gICAgICAgIHN0cmljdCxcbiAgICAgICAgaW5kZXgsXG4gICAgICAgIGxpbmVOdW1iZXIsXG4gICAgICAgIGxpbmVTdGFydCxcbiAgICAgICAgbGVuZ3RoLFxuICAgICAgICBidWZmZXIsXG4gICAgICAgIHN0YXRlLFxuICAgICAgICBleHRyYTtcblxuICAgIFRva2VuID0ge1xuICAgICAgICBCb29sZWFuTGl0ZXJhbDogMSxcbiAgICAgICAgRU9GOiAyLFxuICAgICAgICBJZGVudGlmaWVyOiAzLFxuICAgICAgICBLZXl3b3JkOiA0LFxuICAgICAgICBOdWxsTGl0ZXJhbDogNSxcbiAgICAgICAgTnVtZXJpY0xpdGVyYWw6IDYsXG4gICAgICAgIFB1bmN0dWF0b3I6IDcsXG4gICAgICAgIFN0cmluZ0xpdGVyYWw6IDhcbiAgICB9O1xuXG4gICAgVG9rZW5OYW1lID0ge307XG4gICAgVG9rZW5OYW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AgICBpZiAobGluZUNvbW1lbnQpIHtcbiAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgICAgICBpZiAoaXNMaW5lVGVybWluYXRvcihjaCkpIHtcbiAgICAgICAgICAgICAgICAgICAgbGluZUNvbW1lbnQgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGNoID09PSAnXFxyJyAmJiBzb3VyY2VbaW5kZXhdID09PSAnXFxuJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgKytpbmRleDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICArK2xpbmVOdW1iZXI7XG4gICAgICAgICAgICAgICAgICAgIGxpbmVTdGFydCA9IGluZGV4O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAoYmxvY2tDb21tZW50KSB7XG4gICAgICAgICAgICAgICAgaWYgKGlzTGluZVRlcm1pbmF0b3IoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gJ1xccicgJiYgc291cmNlW2luZGV4ICsgMV0gPT09ICdcXG4nKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICArK2luZGV4O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICsrbGluZU51bWJlcjtcbiAgICAgICAgICAgICAgICAgICAgKytpbmRleDtcbiAgICAgICAgICAgICAgICAgICAgbGluZVN0YXJ0ID0gaW5kZXg7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCA+PSBsZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLlVuZXhwZWN0ZWRUb2tlbiwgJ0lMTEVHQUwnKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaW5kZXggPj0gbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKHt9LCBNZXNzYWdlcy5VbmV4cGVjdGVkVG9rZW4sICdJTExFR0FMJyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKGNoID09PSAnKicpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4XTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gJy8nKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgKytpbmRleDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBibG9ja0NvbW1lbnQgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAoY2ggPT09ICcvJykge1xuICAgICAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4ICsgMV07XG4gICAgICAgICAgICAgICAgaWYgKGNoID09PSAnLycpIHtcbiAgICAgICAgICAgICAgICAgICAgaW5kZXggKz0gMjtcbiAgICAgICAgICAgICAgICAgICAgbGluZUNvbW1lbnQgPSB0cnVlO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2ggPT09ICcqJykge1xuICAgICAgICAgICAgICAgICAgICBpbmRleCArPSAyO1xuICAgICAgICAgICAgICAgICAgICBibG9ja0NvbW1lbnQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaW5kZXggPj0gbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKHt9LCBNZXNzYWdlcy5VbmV4cGVjdGVkVG9rZW4sICdJTExFR0FMJyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlzV2hpdGVTcGFjZShjaCkpIHtcbiAgICAgICAgICAgICAgICArK2luZGV4O1xuICAgICAgICAgICAgfSBlbHNlIGlmIChpc0xpbmVUZXJtaW5hdG9yKGNoKSkge1xuICAgICAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICAgICAgaWYgKGNoID09PSAgJ1xccicgJiYgc291cmNlW2luZGV4XSA9PT0gJ1xcbicpIHtcbiAgICAgICAgICAgICAgICAgICAgKytpbmRleDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgKytsaW5lTnVtYmVyO1xuICAgICAgICAgICAgICAgIGxpbmVTdGFydCA9IGluZGV4O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGZ1bmN0aW9uIHNjYW5IZXhFc2NhcGUocHJlZml4KSB7XG4gICAgICAgIHZhciBpLCBsZW4sIGNoLCBjb2RlID0gMDtcblxuICAgICAgICBsZW4gPSAocHJlZml4ID09PSAndScpID8gNCA6IDI7XG4gICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47ICsraSkge1xuICAgICAgICAgICAgaWYgKGluZGV4IDwgbGVuZ3RoICYmIGlzSGV4RGlnaXQoc291cmNlW2luZGV4XSkpIHtcbiAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgICAgICBjb2RlID0gY29kZSAqIDE2ICsgJzAxMjM0NTY3ODlhYmNkZWYnLmluZGV4T2YoY2gudG9Mb3dlckNhc2UoKSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybiAnJztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gU3RyaW5nLmZyb21DaGFyQ29kZShjb2RlKTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBzY2FuSWRlbnRpZmllcigpIHtcbiAgICAgICAgdmFyIGNoLCBzdGFydCwgaWQsIHJlc3RvcmU7XG5cbiAgICAgICAgY2ggPSBzb3VyY2VbaW5kZXhdO1xuICAgICAgICBpZiAoIWlzSWRlbnRpZmllclN0YXJ0KGNoKSkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgc3RhcnQgPSBpbmRleDtcbiAgICAgICAgaWYgKGNoID09PSAnXFxcXCcpIHtcbiAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICBpZiAoc291cmNlW2luZGV4XSAhPT0gJ3UnKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgKytpbmRleDtcbiAgICAgICAgICAgIHJlc3RvcmUgPSBpbmRleDtcbiAgICAgICAgICAgIGNoID0gc2NhbkhleEVzY2FwZSgndScpO1xuICAgICAgICAgICAgaWYgKGNoKSB7XG4gICAgICAgICAgICAgICAgaWYgKGNoID09PSAnXFxcXCcgfHwgIWlzSWRlbnRpZmllclN0YXJ0KGNoKSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlkID0gY2g7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGluZGV4ID0gcmVzdG9yZTtcbiAgICAgICAgICAgICAgICBpZCA9ICd1JztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlkID0gc291cmNlW2luZGV4KytdO1xuICAgICAgICB9XG5cbiAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG4gICAgICAgICAgICBpZiAoIWlzSWRlbnRpZmllclBhcnQoY2gpKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoY2ggPT09ICdcXFxcJykge1xuICAgICAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICAgICAgaWYgKHNvdXJjZVtpbmRleF0gIT09ICd1Jykge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICAgICAgcmVzdG9yZSA9IGluZGV4O1xuICAgICAgICAgICAgICAgIGNoID0gc2NhbkhleEVzY2FwZSgndScpO1xuICAgICAgICAgICAgICAgIGlmIChjaCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoY2ggPT09ICdcXFxcJyB8fCAhaXNJZGVudGlmaWVyUGFydChjaCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBpZCArPSBjaDtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBpbmRleCA9IHJlc3RvcmU7XG4gICAgICAgICAgICAgICAgICAgIGlkICs9ICd1JztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlkICs9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8vIFRoZXJlIGlzIG5vIGtleXdvcmQgb3IgbGl0ZXJhbCB3aXRoIG9ubHkgb25lIGNoYXJhY3Rlci5cbiAgICAgICAgLy8gVGh1cywgaXQgbXVzdCBiZSBhbiBpZGVudGlmaWVyLlxuICAgICAgICBpZiAoaWQubGVuZ3RoID09PSAxKSB7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFRva2VuLklkZW50aWZpZXIsXG4gICAgICAgICAgICAgICAgdmFsdWU6IGlkLFxuICAgICAgICAgICAgICAgIGxpbmVOdW1iZXI6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgbGluZVN0YXJ0OiBsaW5lU3RhcnQsXG4gICAgICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGlzS2V5d29yZChpZCkpIHtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogVG9rZW4uS2V5d29yZCxcbiAgICAgICAgICAgICAgICB2YWx1ZTogaWQsXG4gICAgICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICByYW5nZTogW3N0YXJ0LCBpbmRleF1cbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICAvLyA3LjguMSBOdWxsIExpdGVyYWxzXG5cbiAgICAgICAgaWYgKGlkID09PSAnbnVsbCcpIHtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogVG9rZW4uTnVsbExpdGVyYWwsXG4gICAgICAgICAgICAgICAgdmFsdWU6IGlkLFxuICAgICAgICAgICAgICAgIGxpbmVOdW1iZXI6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgbGluZVN0YXJ0OiBsaW5lU3RhcnQsXG4gICAgICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gNy44LjIgQm9vbGVhbiBMaXRlcmFsc1xuXG4gICAgICAgIGlmIChpZCA9PT0gJ3RydWUnIHx8IGlkID09PSAnZmFsc2UnKSB7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFRva2VuLkJvb2xlYW5MaXRlcmFsLFxuICAgICAgICAgICAgICAgIHZhbHVlOiBpZCxcbiAgICAgICAgICAgICAgICBsaW5lTnVtYmVyOiBsaW5lTnVtYmVyLFxuICAgICAgICAgICAgICAgIGxpbmVTdGFydDogbGluZVN0YXJ0LFxuICAgICAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGluZGV4XVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBUb2tlbi5JZGVudGlmaWVyLFxuICAgICAgICAgICAgdmFsdWU6IGlkLFxuICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgIGxpbmVTdGFydDogbGluZVN0YXJ0LFxuICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgLy8gNy43IFB1bmN0dWF0b3JzXG5cbiAgICBmdW5jdGlvbiBzY2FuUHVuY3R1YXRvcigpIHtcbiAgICAgICAgdmFyIHN0YXJ0ID0gaW5kZXgsXG4gICAgICAgICAgICBjaDEgPSBzb3VyY2VbaW5kZXhdLFxuICAgICAgICAgICAgY2gyLFxuICAgICAgICAgICAgY2gzLFxuICAgICAgICAgICAgY2g0O1xuXG4gICAgICAgIC8vIENoZWNrIGZvciBtb3N0IGNvbW1vbiBzaW5nbGUtY2hhcmFjdGVyIHB1bmN0dWF0b3JzLlxuXG4gICAgICAgIGlmIChjaDEgPT09ICc7JyB8fCBjaDEgPT09ICd7JyB8fCBjaDEgPT09ICd9Jykge1xuICAgICAgICAgICAgKytpbmRleDtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogVG9rZW4uUHVuY3R1YXRvcixcbiAgICAgICAgICAgICAgICB2YWx1ZTogY2gxLFxuICAgICAgICAgICAgICAgIGxpbmVOdW1iZXI6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgbGluZVN0YXJ0OiBsaW5lU3RhcnQsXG4gICAgICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGNoMSA9PT0gJywnIHx8IGNoMSA9PT0gJygnIHx8IGNoMSA9PT0gJyknKSB7XG4gICAgICAgICAgICArK2luZGV4O1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5QdW5jdHVhdG9yLFxuICAgICAgICAgICAgICAgIHZhbHVlOiBjaDEsXG4gICAgICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICByYW5nZTogW3N0YXJ0LCBpbmRleF1cbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICAvLyBEb3QgKC4pIGNhbiBhbHNvIHN0YXJ0IGEgZmxvYXRpbmctcG9pbnQgbnVtYmVyLCBoZW5jZSB0aGUgbmVlZFxuICAgICAgICAvLyB0byBjaGVjayB0aGUgbmV4dCBjaGFyYWN0ZXIuXG5cbiAgICAgICAgY2gyID0gc291cmNlW2luZGV4ICsgMV07XG4gICAgICAgIGlmIChjaDEgPT09ICcuJyAmJiAhaXNEZWNpbWFsRGlnaXQoY2gyKSkge1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5QdW5jdHVhdG9yLFxuICAgICAgICAgICAgICAgIHZhbHVlOiBzb3VyY2VbaW5kZXgrK10sXG4gICAgICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICByYW5nZTogW3N0YXJ0LCBpbmRleF1cbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICAvLyBQZWVrIG1vcmUgY2hhcmFjdGVycy5cblxuICAgICAgICBjaDMgPSBzb3VyY2VbaW5kZXggKyAyXTtcbiAgICAgICAgY2g0ID0gc291cmNlW2luZGV4ICsgM107XG5cbiAgICAgICAgLy8gNC1jaGFyYWN0ZXIgcHVuY3R1YXRvcjogPj4+PVxuXG4gICAgICAgIGlmIChjaDEgPT09ICc+JyAmJiBjaDIgPT09ICc+JyAmJiBjaDMgPT09ICc+Jykge1xuICAgICAgICAgICAgaWYgKGNoNCA9PT0gJz0nKSB7XG4gICAgICAgICAgICAgICAgaW5kZXggKz0gNDtcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5QdW5jdHVhdG9yLFxuICAgICAgICAgICAgICAgICAgICB2YWx1ZTogJz4+Pj0nLFxuICAgICAgICAgICAgICAgICAgICBsaW5lTnVtYmVyOiBsaW5lTnVtYmVyLFxuICAgICAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8vIDMtY2hhcmFjdGVyIHB1bmN0dWF0b3JzOiA9PT0gIT09ID4+PiA8PD0gPj49XG5cbiAgICAgICAgaWYgKGNoMSA9PT0gJz0nICYmIGNoMiA9PT0gJz0nICYmIGNoMyA9PT0gJz0nKSB7XG4gICAgICAgICAgICBpbmRleCArPSAzO1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5QdW5jdHVhdG9yLFxuICAgICAgICAgICAgICAgIHZhbHVlOiAnPT09JyxcbiAgICAgICAgICAgICAgICBsaW5lTnVtYmVyOiBsaW5lTnVtYmVyLFxuICAgICAgICAgICAgICAgIGxpbmVTdGFydDogbGluZVN0YXJ0LFxuICAgICAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGluZGV4XVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChjaDEgPT09ICchJyAmJiBjaDIgPT09ICc9JyAmJiBjaDMgPT09ICc9Jykge1xuICAgICAgICAgICAgaW5kZXggKz0gMztcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogVG9rZW4uUHVuY3R1YXRvcixcbiAgICAgICAgICAgICAgICB2YWx1ZTogJyE9PScsXG4gICAgICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICByYW5nZTogW3N0YXJ0LCBpbmRleF1cbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoY2gxID09PSAnPicgJiYgY2gyID09PSAnPicgJiYgY2gzID09PSAnPicpIHtcbiAgICAgICAgICAgIGluZGV4ICs9IDM7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFRva2VuLlB1bmN0dWF0b3IsXG4gICAgICAgICAgICAgICAgdmFsdWU6ICc+Pj4nLFxuICAgICAgICAgICAgICAgIGxpbmVOdW1iZXI6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgbGluZVN0YXJ0OiBsaW5lU3RhcnQsXG4gICAgICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGNoMSA9PT0gJzwnICYmIGNoMiA9PT0gJzwnICYmIGNoMyA9PT0gJz0nKSB7XG4gICAgICAgICAgICBpbmRleCArPSAzO1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5QdW5jdHVhdG9yLFxuICAgICAgICAgICAgICAgIHZhbHVlOiAnPDw9JyxcbiAgICAgICAgICAgICAgICBsaW5lTnVtYmVyOiBsaW5lTnVtYmVyLFxuICAgICAgICAgICAgICAgIGxpbmVTdGFydDogbGluZVN0YXJ0LFxuICAgICAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGluZGV4XVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChjaDEgPT09ICc+JyAmJiBjaDIgPT09ICc+JyAmJiBjaDMgPT09ICc9Jykge1xuICAgICAgICAgICAgaW5kZXggKz0gMztcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogVG9rZW4uUHVuY3R1YXRvcixcbiAgICAgICAgICAgICAgICB2YWx1ZTogJz4+PScsXG4gICAgICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICByYW5nZTogW3N0YXJ0LCBpbmRleF1cbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICAvLyAyLWNoYXJhY3RlciBwdW5jdHVhdG9yczogPD0gPj0gPT0gIT0gKysgLS0gPDwgPj4gJiYgfHxcbiAgICAgICAgLy8gKz0gLT0gKj0gJT0gJj0gfD0gXj0gLz1cblxuICAgICAgICBpZiAoY2gyID09PSAnPScpIHtcbiAgICAgICAgICAgIGlmICgnPD49ISstKiUmfF4vJy5pbmRleE9mKGNoMSkgPj0gMCkge1xuICAgICAgICAgICAgICAgIGluZGV4ICs9IDI7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVG9rZW4uUHVuY3R1YXRvcixcbiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGNoMSArIGNoMixcbiAgICAgICAgICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICAgICAgbGluZVN0YXJ0OiBsaW5lU3RhcnQsXG4gICAgICAgICAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGluZGV4XVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoY2gxID09PSBjaDIgJiYgKCcrLTw+JnwnLmluZGV4T2YoY2gxKSA+PSAwKSkge1xuICAgICAgICAgICAgaWYgKCcrLTw+JnwnLmluZGV4T2YoY2gyKSA+PSAwKSB7XG4gICAgICAgICAgICAgICAgaW5kZXggKz0gMjtcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5QdW5jdHVhdG9yLFxuICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2gxICsgY2gyLFxuICAgICAgICAgICAgICAgICAgICBsaW5lTnVtYmVyOiBsaW5lTnVtYmVyLFxuICAgICAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8vIFRoZSByZW1haW5pbmcgMS1jaGFyYWN0ZXIgcHVuY3R1YXRvcnMuXG5cbiAgICAgICAgaWYgKCdbXTw+Ky0qJSZ8XiF+Pzo9LycuaW5kZXhPZihjaDEpID49IDApIHtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogVG9rZW4uUHVuY3R1YXRvcixcbiAgICAgICAgICAgICAgICB2YWx1ZTogc291cmNlW2luZGV4KytdLFxuICAgICAgICAgICAgICAgIGxpbmVOdW1iZXI6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgbGluZVN0YXJ0OiBsaW5lU3RhcnQsXG4gICAgICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgLy8gNy44LjMgTnVtZXJpYyBMaXRlcmFsc1xuXG4gICAgZnVuY3Rpb24gc2Nhbk51bWVyaWNMaXRlcmFsKCkge1xuICAgICAgICB2YXIgbnVtYmVyLCBzdGFydCwgY2g7XG5cbiAgICAgICAgY2ggPSBzb3VyY2VbaW5kZXhdO1xuICAgICAgICBhc3NlcnQoaXNEZWNpbWFsRGlnaXQoY2gpIHx8IChjaCA9PT0gJy4nKSxcbiAgICAgICAgICAgICdOdW1lcmljIGxpdGVyYWwgbXVzdCBzdGFydCB3aXRoIGEgZGVjaW1hbCBkaWdpdCBvciBhIGRlY2ltYWwgcG9pbnQnKTtcblxuICAgICAgICBzdGFydCA9IGluZGV4O1xuICAgICAgICBudW1iZXIgPSAnJztcbiAgICAgICAgaWYgKGNoICE9PSAnLicpIHtcbiAgICAgICAgICAgIG51bWJlciA9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4XTtcblxuICAgICAgICAgICAgLy8gSGV4IG51bWJlciBzdGFydHMgd2l0aCAnMHgnLlxuICAgICAgICAgICAgLy8gT2N0YWwgbnVtYmVyIHN0YXJ0cyB3aXRoICcwJy5cbiAgICAgICAgICAgIGlmIChudW1iZXIgPT09ICcwJykge1xuICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gJ3gnIHx8IGNoID09PSAnWCcpIHtcbiAgICAgICAgICAgICAgICAgICAgbnVtYmVyICs9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzSGV4RGlnaXQoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBudW1iZXIgKz0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKG51bWJlci5sZW5ndGggPD0gMikge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gb25seSAweFxuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuVW5leHBlY3RlZFRva2VuLCAnSUxMRUdBTCcpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNJZGVudGlmaWVyU3RhcnQoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuVW5leHBlY3RlZFRva2VuLCAnSUxMRUdBTCcpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5OdW1lcmljTGl0ZXJhbCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBwYXJzZUludChudW1iZXIsIDE2KSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVOdW1iZXI6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGluZGV4XVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNPY3RhbERpZ2l0KGNoKSkge1xuICAgICAgICAgICAgICAgICAgICBudW1iZXIgKz0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgICAgICAgICB3aGlsZSAoaW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4XTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNPY3RhbERpZ2l0KGNoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgbnVtYmVyICs9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY2ggPSBzb3VyY2VbaW5kZXhdO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzSWRlbnRpZmllclN0YXJ0KGNoKSB8fCBpc0RlY2ltYWxEaWdpdChjaCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKHt9LCBNZXNzYWdlcy5VbmV4cGVjdGVkVG9rZW4sICdJTExFR0FMJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFRva2VuLk51bWVyaWNMaXRlcmFsLFxuICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHBhcnNlSW50KG51bWJlciwgOCksXG4gICAgICAgICAgICAgICAgICAgICAgICBvY3RhbDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVOdW1iZXI6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGluZGV4XVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIC8vIGRlY2ltYWwgbnVtYmVyIHN0YXJ0cyB3aXRoICcwJyBzdWNoIGFzICcwOScgaXMgaWxsZWdhbC5cbiAgICAgICAgICAgICAgICBpZiAoaXNEZWNpbWFsRGlnaXQoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLlVuZXhwZWN0ZWRUb2tlbiwgJ0lMTEVHQUwnKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHdoaWxlIChpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4XTtcbiAgICAgICAgICAgICAgICBpZiAoIWlzRGVjaW1hbERpZ2l0KGNoKSkge1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgbnVtYmVyICs9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChjaCA9PT0gJy4nKSB7XG4gICAgICAgICAgICBudW1iZXIgKz0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgY2ggPSBzb3VyY2VbaW5kZXhdO1xuICAgICAgICAgICAgICAgIGlmICghaXNEZWNpbWFsRGlnaXQoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBudW1iZXIgKz0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGNoID09PSAnZScgfHwgY2ggPT09ICdFJykge1xuICAgICAgICAgICAgbnVtYmVyICs9IHNvdXJjZVtpbmRleCsrXTtcblxuICAgICAgICAgICAgY2ggPSBzb3VyY2VbaW5kZXhdO1xuICAgICAgICAgICAgaWYgKGNoID09PSAnKycgfHwgY2ggPT09ICctJykge1xuICAgICAgICAgICAgICAgIG51bWJlciArPSBzb3VyY2VbaW5kZXgrK107XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4XTtcbiAgICAgICAgICAgIGlmIChpc0RlY2ltYWxEaWdpdChjaCkpIHtcbiAgICAgICAgICAgICAgICBudW1iZXIgKz0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgICAgIHdoaWxlIChpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG4gICAgICAgICAgICAgICAgICAgIGlmICghaXNEZWNpbWFsRGlnaXQoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBudW1iZXIgKz0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY2ggPSAnY2hhcmFjdGVyICcgKyBjaDtcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPj0gbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgIGNoID0gJzxlbmQ+JztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuVW5leHBlY3RlZFRva2VuLCAnSUxMRUdBTCcpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICBjaCA9IHNv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3RlID0gJyc7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNoID09PSAnXFxcXCcpIHtcbiAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgICAgICBpZiAoIWlzTGluZVRlcm1pbmF0b3IoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoY2gpIHtcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnbic6XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHIgKz0gJ1xcbic7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAncic6XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHIgKz0gJ1xccic7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAndCc6XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHIgKz0gJ1xcdCc7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAndSc6XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ3gnOlxuICAgICAgICAgICAgICAgICAgICAgICAgcmVzdG9yZSA9IGluZGV4O1xuICAgICAgICAgICAgICAgICAgICAgICAgdW5lc2NhcGVkID0gc2NhbkhleEVzY2FwZShjaCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodW5lc2NhcGVkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyICs9IHVuZXNjYXBlZDtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXggPSByZXN0b3JlO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0ciArPSBjaDtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICBjYXNlICdiJzpcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0ciArPSAnXFxiJztcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICBjYXNlICdmJzpcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0ciArPSAnXFxmJztcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICBjYXNlICd2JzpcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0ciArPSAnXFx4MEInO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc09jdGFsRGlnaXQoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29kZSA9ICcwMTIzNDU2NycuaW5kZXhPZihjaCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBcXDAgaXMgbm90IG9jdGFsIGVzY2FwZSBzZXF1ZW5jZVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb2RlICE9PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9jdGFsID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5kZXggPCBsZW5ndGggJiYgaXNPY3RhbERpZ2l0KHNvdXJjZVtpbmRleF0pKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9jdGFsID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29kZSA9IGNvZGUgKiA4ICsgJzAxMjM0NTY3Jy5pbmRleE9mKHNvdXJjZVtpbmRleCsrXSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gMyBkaWdpdHMgYXJlIG9ubHkgYWxsb3dlZCB3aGVuIHN0cmluZyBzdGFydHNcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gd2l0aCAwLCAxLCAyLCAzXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgnMDEyMycuaW5kZXhPZihjaCkgPj0gMCAmJlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4IDwgbGVuZ3RoICYmXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNPY3RhbERpZ2l0KHNvdXJjZVtpbmRleF0pKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2RlID0gY29kZSAqIDggKyAnMDEyMzQ1NjcnLmluZGV4T2Yoc291cmNlW2luZGV4KytdKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShjb2RlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyICs9IGNoO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICArK2xpbmVOdW1iZXI7XG4gICAgICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gICdcXHInICYmIHNvdXJjZVtpbmRleF0gPT09ICdcXG4nKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICArK2luZGV4O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIGlmIChpc0xpbmVUZ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sZW5ndGgpIHtcbiAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgc3RyICs9IGNoO1xuICAgICAgICAgICAgaWYgKGNoID09PSAnXFxcXCcpIHtcbiAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgICAgICAvLyBFQ01BLTI2MiA3LjguNVxuICAgICAgICAgICAgICAgIGlmIChpc0xpbmVUZXJtaW5hdG9yKGNoKSkge1xuICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKHt9LCBNZXNzYWdlcy5VbnRlcm1pbmF0ZWRSZWdFeHApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBzdHIgKz0gY2g7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNsYXNzTWFya2VyKSB7XG4gICAgICAgICAgICAgICAgaWYgKGNoID09PSAnXScpIHtcbiAgICAgICAgICAgICAgICAgICAgY2xhc3NNYXJrZXIgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gJy8nKSB7XG4gICAgICAgICAgICAgICAgICAgIHRlcm1pbmF0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoID09PSAnWycpIHtcbiAgICAgICAgICAgICAgICAgICAgY2xhc3NNYXJrZXIgPSB0cnVlO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNMaW5lVGVybWluYXRvcihjaCkpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuVW50ZXJtaW5hdGVkUmVnRXhwKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoIXRlcm1pbmF0ZWQpIHtcbiAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLlVudGVybWluYXRlZFJlZ0V4cCk7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBFeGNsdWRlIGxlYWRpbmcgYW5kIHRyYWlsaW5nIHNsYXNoLlxuICAgICAgICBwYXR0ZXJuID0gc3RyLnN1YnN0cigxLCBzdHIubGVuZ3RoIC0gMik7XG5cbiAgICAgICAgZmxhZ3MgPSAnJztcbiAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG4gICAgICAgICAgICBpZiAoIWlzSWRlbnRpZmllclBhcnQoY2gpKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICBpZiAoY2ggPT09ICdcXFxcJyAmJiBpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4XTtcbiAgICAgICAgICAgICAgICBpZiAoY2ggPT09ICd1Jykge1xuICAgICAgICAgICAgICAgICAgICArK2luZGV4O1xuICAgICAgICAgICAgICAgICAgICByZXN0b3JlID0gaW5kZXg7XG4gICAgICAgICAgICAgICAgICAgIGNoID0gc2NhbkhleEVzY2FwZSgndScpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoY2gpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZsYWdzICs9IGNoO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RyICs9ICdcXFxcdSc7XG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgcmVzdG9yZSA8IGluZGV4OyArK3Jlc3RvcmUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgKz0gc291cmNlW3Jlc3RvcmVdO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXggPSByZXN0b3JlO1xuICAgICAgICAgICAgICAgICAgICAgICAgZmxhZ3MgKz0gJ3UnO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RyICs9ICdcXFxcdSc7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzdHIgKz0gJ1xcXFwnO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZmxhZ3MgKz0gY2g7XG4gICAgICAgICAgICAgICAgc3RyICs9IGNoO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHZhbHVlID0gbmV3IFJlZ0V4cChwYXR0ZXJuLCBmbGFncyk7XG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLkludmFsaWRSZWdFeHApO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIGxpdGVyYWw6IHN0cixcbiAgICAgICAgICAgIHZhbHVlOiB2YWx1ZSxcbiAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGluZGV4XVxuICAgICAgICB9O1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGlzSWRlbnRpZmllck5hbWUodG9rZW4pIHtcbiAgICAgICAgcmV0dXJuIHRva2VuLnR5cGUgPT09IFRva2VuLklkZW50aWZpZXIgfHxcbiAgICAgICAgICAgIHRva2VuLnR5cGUgPT09IFRva2VuLktleXdvcmQgfHxcbiAgICAgICAgICAgIHRva2VuLnR5cGUgPT09IFRva2VuLkJvb2xlYW5MaXRlcmFsIHx8XG4gICAgICAgICAgICB0b2tlbi50eXBlID09PSBUb2tlbi5OdWxsTGl0ZXJhbDtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBhZHZhbmNlKCkge1xuICAgICAgICB2YXIgY2gsIHRva2VuO1xuXG4gICAgICAgIHNraXBDb21tZW50KCk7XG5cbiAgICAgICAgaWYgKGluZGV4ID49IGxlbmd0aCkge1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5FT0YsXG4gICAgICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICByYW5nZTogW2luZGV4LCBpbmRleF1cbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICB0b2tlbiA9IHNjYW5QdW5jdHVhdG9yKCk7XG4gICAgICAgIGlmICh0eXBlb2YgdG9rZW4gIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICByZXR1cm4gdG9rZW47XG4gICAgICAgIH1cblxuICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG5cbiAgICAgICAgaWYgKGNoID09PSAnXFwnJyB8fCBjaCA9PT0gJ1wiJykge1xuICAgICAgICAgICAgcmV0dXJuIHNjYW5TdHJpbmdMaXRlcmFsKCk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoY2ggPT09ICcuJyB8fCBpc0RlY2ltYWxEaWdpdChjaCkpIHtcbiAgICAgICAgICAgIHJldHVybiBzY2FuTnVtZXJpY0xpdGVyYWwoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHRva2VuID0gc2NhbklkZW50aWZpZXIoKTtcbiAgICAgICAgaWYgKHR5cGVvZiB0b2tlbiAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgIHJldHVybiB0b2tlbjtcbiAgICAgICAgfVxuXG4gICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLlVuZXhwZWN0ZWRUb2tlbiwgJ0lMTEVHQUwnKTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBs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xuXG4gICAgICAgIHBvcyA9IGluZGV4O1xuICAgICAgICBsaW5lID0gbGluZU51bWJlcjtcbiAgICAgICAgc3RhcnQgPSBsaW5lU3RhcnQ7XG4gICAgICAgIHNraXBDb21tZW50KCk7XG4gICAgICAgIGZvdW5kID0gbGluZU51bWJlciAhPT0gbGluZTtcbiAgICAgICAgaW5kZXggPSBwb3M7XG4gICAgICAgIGxpbmVOdW1iZXIgPSBsaW5lO1xuICAgICAgICBsaW5lU3RhcnQgPSBzdGFydDtcblxuICAgICAgICByZXR1cm4gZm91bmQ7XG4gICAgfVxuXG4gICAgLy8gVGhyb3cgYW4gZXhjZXB0aW9uXG5cbiAgICBmdW5jdGlvbiB0aHJvd0Vycm9yKHRva2VuLCBtZXNzYWdlRm9ybWF0KSB7XG4gICAgICAgIHZhciBlcnJvcixcbiAgICAgICAgICAgIGFyZ3MgPSBBcnJheS5wcm90b3R5cGUuc2xpY2UuY2FsbChhcmd1bWVudHMsIDIpLFxuICAgICAgICAgICAgbXNnID0gbWVzc2FnZUZvcm1hdC5yZXBsYWNlKFxuICAgICAgICAgICAgICAgIC8lKFxcZCkvZyxcbiAgICAgICAgICAgICAgICBmdW5jdGlvbiAod2hvbGUsIGluZGV4KSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBhcmdzW2luZGV4XSB8fCAnJztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICApO1xuXG4gICAgICAgIGlmICh0eXBlb2YgdG9rZW4ubGluZU51bWJlciA9PT0gJ251bWJlcicpIHtcbiAgICAgICAgICAgIGVycm9yID0gbmV3IEVycm9yKCdMaW5lICcgKyB0b2tlbi5saW5lTnVtYmVyICsgJzogJyArIG1zZyk7XG4gICAgICAgICAgICBlcnJvci5pbmRleCA9IHRva2VuLnJhbmdlWzBdO1xuICAgICAgICAgICAgZXJyb3IubGluZU51bWJlciA9IHRva2VuLmxpbmVOdW1iZXI7XG4gICAgICAgICAgICBlcnJvci5jb2x1bW4gPSB0b2tlbi5yYW5nZVswXSAtIGxpbmVTdGFydCArIDE7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBlcnJvciA9IG5ldyBFcnJvcignTGluZSAnICsgbGluZU51bWJlciArICc6ICcgKyBtc2cpO1xuICAgICAgICAgICAgZXJyb3IuaW5kZXggPSBpbmRleDtcbiAgICAgICAgICAgIGVycm9yLmxpbmVOdW1iZXIgPSBsaW5lTnVtYmVyO1xuICAgICAgICAgICAgZXJyb3IuY29sdW1uID0gaW5kZXggLSBsaW5lU3RhcnQgKyAxO1xuICAgICAgICB9XG5cbiAgICAgICAgdGhyb3cgZXJyb3I7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gdGhyb3dFcnJvclRvbGVyYW50KCkge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgdGhyb3dFcnJvci5hcHBseShudWxsLCBhcmd1bWVudHMpO1xuICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICBpZiAoZXh0cmEuZXJyb3JzKSB7XG4gICAgICAgICAgICAgICAgZXh0cmEuZXJyb3JzLnB1c2goZSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRocm93IGU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cblxuICAgIC8vIFRocm93IGFuIGV4Y2VwdGlvbiBiZWNhdXNlIG9mIHRoZSB0b2tlbi5cblxuICAgIGZ1bmN0aW9uIHRocm93VW5leHBlY3RlZCh0b2tlbikge1xuICAgICAgICBpZiAodG9rZW4udHlwZSA9PT0gVG9rZW4uRU9GKSB7XG4gICAgICAgICAgICB0aHJvd0Vycm9yKHRva2VuLCBNZXNzYWdlcy5VbmV4cGVjdGVkRU9TKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0b2tlbi50eXBlID09PSBUb2tlbi5OdW1lcmljTGl0ZXJhbCkge1xuICAgICAgICAgICAgdGhyb3dFcnJvcih0b2tlbiwgTWVzc2FnZXMuVW5leH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G4gICAgfVxuXG4gICAgLy8gUmV0dXJuIHRydWUgaWYgdGhlIG5leHQgdG9rZW4gbWF0Y2hlcyB0aGUgc3BlY2lmaWVkIGtleXdvcmRcblxuICAgIGZ1bmN0aW9uIG1hdGNoS2V5d29yZChrZXl3b3JkKSB7XG4gICAgICAgIHZhciB0b2tlbiA9IGxvb2thaGVhZCgpO1xuICAgICAgICByZXR1cm4gdG9rZW4udHlwZSA9PT0gVG9rZW4uS2V5d29yZCAmJiB0b2tlbi52YWx1ZSA9PT0ga2V5d29yZDtcbiAgICB9XG5cbiAgICAvLyBSZXR1cm4gdHJ1ZSBpZiB0aGUgbmV4dCB0b2tlbiBpcyBhbiBhc3NpZ25tZW50IG9wZXJhdG9yXG5cbiAgICBmdW5jdGlvbiBtYXRjaEFzc2lnbigpIHtcbiAgICAgICAgdmFyIHRva2VuID0gbG9va2FoZWFkKCksXG4gICAgICAgICAgICBvcCA9IHRva2VuLnZhbHVlO1xuXG4gICAgICAgIGlmICh0b2tlbi50eXBlICE9PSBUb2tlbi5QdW5jdHVhdG9yKSB7XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIG9wID09PSAnPScgfHxcbiAgICAgICAgICAgIG9wID09PSAnKj0nIHx8XG4gICAgICAgICAgICBvcCA9PT0gJy89JyB8fFxuICAgICAgICAgICAgb3AgPT09ICclPScgfHxcbiAgICAgICAgICAgIG9wID09PSAnKz0nIHx8XG4gICAgICAgICAgICBvcCA9PT0gJy09JyB8fFxuICAgICAgICAgICAgb3AgPT09ICc8PD0nIHx8XG4gICAgICAgICAgICBvcCA9PT0gJz4+PScgfHxcbiAgICAgICAgICAgIG9wID09PSAnPj4+PScgfHxcbiAgICAgICAgICAgIG9wID09PSAnJj0nIHx8XG4gICAgICAgICAgICBvcCA9PT0gJ149JyB8fFxuICAgICAgICAgICAgb3AgPT09ICd8PSc7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gY29uc3VtZVNlbWljb2xvbigpIHtcbiAgICAgICAgdmFyIHRva2VuLCBsaW5lO1xuXG4gICAgICAgIC8vIENhdGNoIHRoZSB2ZXJ5IGNvbW1vbiBjYXNlIGZpcnN0LlxuICAgICAgICBpZiAoc291cmNlW2luZGV4XSA9PT0gJzsnKSB7XG4gICAgICAgICAgICBsZXgoKTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIGxpbmUgPSBsaW5lTnVtYmVyO1xuICAgICAgICBza2lwQ29tbWVudCgpO1xuICAgICAgICBpZiAobGluZU51bWJlciAhPT0gbGluZSkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKG1hdGNoKCc7JykpIHtcbiAgICAgICAgICAgIGxleCgpO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgdG9rZW4gPSBsb29rYWhlYWQoKTtcbiAgICAgICAgaWYgKHRva2VuLnR5cGUgIT09IFRva2VuLkVPRiAmJiAhbWF0Y2goJ30nKSkge1xuICAgICAgICAgICAgdGhyb3dVbmV4cGVjdGVkKHRva2VuKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIC8vIFJldHVybiB0cnVlIGlmIHByb3ZpZGVkIGV4cHJlc3Npb24gaXMgTGVmdEhhbmRTaWRlRXhwcmVzc2lvblxuXG4gICAgZnVuY3Rpb24gaXNMZWZ0SGFuZFNpZGUoZXhwcikge1xuICAgICAgICByZXR1cm4gZXhwci50eXBlID09PSBTeW50YXguSWRlbnRpZmllciB8fCBleHByLnR5cGUgPT09IFN5bnRheC5NZW1iZXJFeHByZXNzaW9uO1xuICAgIH1cblxuICAgIC8vIDExLjEuNCBBcnJheSBJbml0aWFsaXNlclxuXG4gICAgZnVuY3Rpb24gcGFyc2VBcnJheUluaXRpYWxpc2VyKCkge1xuICAgICAgICB2YXIgZWxlbWVudHMgPSBbXTtcblxuICAgICAgICBleHBlY3QoJ1snKTtcblxuICAgICAgICB3aGlsZSAoIW1hdGNoKCddJykpIHtcbiAgICAgICAgICAgIGlmIChtYXRjaCgnLCcpKSB7XG4gICAgICAgICAgICAgICAgbGV4KCk7XG4gICAgICAgICAgICAgICAgZWxlbWVudHMucHVzaChudWxsKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZWxlbWVudHMucHVzaChwYXJzZUFzc2lnbm1lbnRFeHByZXNzaW9uKCkpO1xuXG4gICAgICAgICAgICAgICAgaWYgKCFtYXRjaCgnXScpKSB7XG4gICAgICAgICAgICAgICAgICAgIGV4cGVjdCgnLCcpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGV4cGVjdCgnXScpO1xuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBTeW50YXguQXJyYXlFeHByZXNzaW9uLFxuICAgICAgICAgICAgZWxlbWVudHM6IGVsZW1lbnRzXG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgLy8gMTEuMS41IE9iamVjdCBJbml0aWFsaXNlclxuXG4gICAgZnVuY3Rpb24gcGFyc2VQcm9wZXJ0eUZ1bmN0aW9uKHBhcmFtLCBmaXJzdCkge1xuICAgICAgICB2YXIgcHJldmlvdXNTdHJpY3QsIGJvZHk7XG5cbiAgICAgICAgcHJldmlvdXNTdHJpY3QgPSBzdHJpY3Q7XG4gICAgICAgIGJvZHkgPSBwYXJzZUZ1bmN0aW9uU291cmNlRWxlbWVudHMoKTtcbiAgICAgICAgaWYgKGZpcnN0ICYmIHN0cmljdCAmJiBpc1Jlc3RyaWN0ZWRXb3JkKHBhcmFtWzBdLm5hbWUpKSB7XG4gICAgICAgICAgICB0aHJvd0Vycm9yVG9sZXJhbnQoZmlyc3QsIE1lc3NhZ2VzLlN0cmljdFBhcmFtTmFtZSk7XG4gICAgICAgIH1cbiAgICAgICAgc3RyaWN0ID0gcHJldmlvdXNTdHJpY3Q7XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHR5cGU6IFN5bnRheC5GdW5jdGlvbkV4cHJlc3Npb24sXG4gICAgICAgICAgICBpZDogbnVsbCxcbiAgICAgICAgICAgIHBhcmFtczogcGFyYW0sXG4gICAgICAgICAgICBkZWZhdWx0czogW10sXG4gICAgICAgICAgICBib2R5OiBib2R5LFxuICAgICAgICAgICAgcmVzdDogbnVsbCxcbiAgICAgICAgICAgIGdlbmVyYXRvcjogZmFsc2UsXG4gICAgICAgICAgICBleHByZXNzaW9uOiBmYWxzZVxuICAgICAgICB9O1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBhcnNlT2JqZWN0UHJvcGVydHlLZXkoKSB7XG4gICAgICAgIHZhciB0b2tlbiA9IGxleCgpO1xuXG4gICAgICAgIC8vIE5vdGU6IFRoaXMgZnVuY3Rpb24gaXMgY2FsbGVkIG9ubHkgZnJvbSBwYXJzZU9iamVjdFByb3BlcnR5KCksIHdoZXJlXG4gICAgICAgIC8vIEVPRiBhbmQgUHVuY3R1YXRvciB0b2tlbnMgYXJlIGFscmVhZHkgZmlsdGVyZWQgb3V0LlxuXG4gICAgICAgIGlmICh0b2tlbi50eXBlID09PSBUb2tlbi5TdHJpbmdMaXRlcmFsIHx8IHRva2VuLnR5cGUgPT09IFRva2VuLk51bWVyaWNMaXRlcmFsKSB7XG4gICAgICAgICAgICBpZiAoc3RyaWN0ICYmIHRva2VuLm9jdGFsKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHRva2VuLCBNZXNzYWdlcy5TdHJpY3RPY3RhbExpdGVyYWwpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGNyZWF0ZUxpdGVyYWwodG9rZW4pO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHR5cGU6IFN5bnRheC5JZGVudGlmaWVyLFxuICAgICAgICAgICAgbmFtZTogdG9rZW4udmFsdWVcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwYXJzZU9iamVjdFByb3BlcnR5KCkge1xuICAgICAgICB2YXIgdG9rZW4sIGtleSwgaWQsIHBhcmFtO1xuXG4gICAgICAgIHRva2VuID0gbG9va2FoZWFkKCk7XG5cbiAgICAgICAgaWYgKHRva2VuLnR5cGUgPT09IFRva2VuLklkZW50aWZpZXIpIHtcblxuICAgICAgICAgICAgaWQgPSBwYXJzZU9iamVjdFByb3BlcnR5S2V5KCk7XG5cbiAgICAgICAgICAgIC8vIFByb3BlcnR5IEFzc2lnbm1lbnQ6IEdldHRlciBhbmQgU2V0dGVyLlxuXG4gICAgICAgICAgICBpZiAodG9rZW4udmFsdWUgPT09ICdnZXQnICYmICFtYXRjaCgnOicpKSB7XG4gICAgICAgICAgICAgICAga2V5ID0gcGFyc2VPYmplY3RQcm9wZXJ0eUtleSgpO1xuICAgICAgICAgICAgICAgIGV4cGVjdCgnKCcpO1xuICAgICAgICAgICAgICAgIGV4cGVjdCgnKScpO1xuICAgICAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5Qcm9wZXJ0eSxcbiAgICAgICAgICAgICAgICAgICAga2V5OiBrZXksXG4gICAgICAgICAgICAgICAgICAgIHZhbHVlOiBwYXJzZVByb3BlcnR5RnVuY3Rpb24oW10pLFxuICAgICAgICAgICAgICAgICAgICBraW5kOiAnZ2V0J1xuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRva2VuLnZhbHVlID09PSAnc2V0JyAmJiAhbWF0Y2goJzonKSkge1xuICAgICAgICAgICAgICAgIGtleSA9IHBhcnNlT2JqZWN0UHJvcGVydHlLZXkoKTtcbiAgICAgICAgICAgICAgICBleHBlY3QoJygnKTtcbiAgICAgICAgICAgICAgICB0b2tlbiA9IGxvb2thaGVhZCgpO1xuICAgICAgICAgICAgICAgIGlmICh0b2tlbi50eXBlICE9PSBUb2tlbi5JZGVudGlmaWVyKSB7XG4gICAgICAgICAgICAgICAgICAgIGV4cGVjdCgnKScpO1xuICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yVG9sZXJhbnQodG9rZW4sIE1lc3NhZ2VzLlVuZXhwZWN0ZWRUb2tlbiwgdG9rZW4udmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LlByb3BlcnR5LFxuICAgICAgICAgICAgICAgICAgICAgICAga2V5OiBrZXksXG4gICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogcGFyc2VQcm9wZXJ0eUZ1bmN0aW9uKFtdKSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGtpbmQ6ICdzZXQnXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcGFyYW0gPSBbIHBhcnNlVmFyaWFibGVJZGVudGlmaWVyKCkgXTtcbiAgICAgICAgICAgICAgICAgICAgZXhwZWN0KCcpJyk7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguUHJvcGVydHksXG4gICAgICAgICAgICAgICAgICAgICAgICBrZXk6IGtleSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBwYXJzZVByb3BlcnR5RnVuY3Rpb24ocGFyYW0sIHRva2VuKSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGtpbmQ6ICdzZXQnXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBleHBlY3QoJzonKTtcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguUHJvcGVydHksXG4gICAgICAgICAgICAgICAgICAgIGtleTogaWQsXG4gICAgICAgICAgICAgICAgICAgIHZhbHVlOiBwYXJzZUFzc2lnbm1lbnRFeHByZXNzaW9uKCksXG4gICAgICAgICAgICAgICAgICAgIGtpbmQ6ICdpbml0J1xuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAodG9rZW4udHlwZSA9PT0gVG9rZW4uRU9GIHx8IHRva2VuLnR5cGUgPT09IFRva2VuLlB1bmN0dWF0b3IpIHtcbiAgICAgICAgICAgIHRocm93VW5leHBlY3RlZCh0b2tlbik7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBrZXkgPSBwYXJzZU9iamVjdFByb3BlcnR5S2V5KCk7XG4gICAgICAgICAgICBleHBlY3QoJzonKTtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LlByb3BlcnR5LFxuICAgICAgICAgICAgICAgIGtleToga2V5LFxuICAgICAgICAgICAgICAgIHZhbHVlOiBwYXJzZUFzc2lnbm1lbnRFeHByZXNzaW9uKCksXG4gICAgICAgICAgICAgICAga2luZDogJ2luaXQnXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2VPYmplY3RJbml0aWFsaXNlcigpIHtcbiAgICAgICAgdmFyIHByb3BlcnRpZXMgPSBbXSwgcHJvcGVydHksIG5hbWUsIGtpbmQsIG1hcCA9IHt9LCB0b1N0cmluZyA9IFN0cmluZztcblxuICAgICAgICBleHBlY3QoJ3snKTtcblxuICAgICAgICB3aGlsZSAoIW1hdGNoKCd9JykpIHtcbiAgICAgICAgICAgIHByb3BlcnR5ID0gcGFyc2VPYmplY3RQcm9wZXJ0eSgpO1xuXG4gICAgICAgICAgICBpZiAocHJvcGVydHkua2V5LnR5cGUgPT09IFN5bnRheC5JZGVudGlmaWVyKSB7XG4gICAgICAgICAgICAgICAgbmFtZSA9IHByb3BlcnR5LmtleS5uYW1lO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBuYW1lID0gdG9TdHJpbmcocHJvcGVydHkua2V5LnZhbHVlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGtpbmQgPSAocHJvcGVydHkua2luZCA9PT0gJ2luaXQnKSA/IFByb3BlcnR5S2luZC5EYXRhIDogKHByb3BlcnR5LmtpbmQgPT09ICdnZXQnKSA/IFByb3BlcnR5S2luZC5HZXQgOiBQcm9wZXJ0eUtpbmQuU2V0O1xuICAgICAgICAgICAgaWYgKE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbChtYXAsIG5hbWUpKSB7XG4gICAgICAgICAgICAgICAgaWYgKG1hcFtuYW1lXSA9PT0gUHJvcGVydHlLaW5kLkRhdGEpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHN0cmljdCAmJiBraW5kID09PSBQcm9wZXJ0eUtpbmQuRGF0YSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5TdHJpY3REdXBsaWNhdGVQcm9wZXJ0eSk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoa2luZCAhPT0gUHJvcGVydHlLaW5kLkRhdGEpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93RXJyb3JUb2xlcmFudCh7fSwgTWVzc2FnZXMuQWNjZXNzb3JEYXRhUHJvcGVydHkpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGtpbmQgPT09IFByb3BlcnR5S2luZC5EYXRhKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yVG9sZXJhbnQoe30sIE1lc3NhZ2VzLkFjY2Vzc29yRGF0YVByb3BlcnR5KTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChtYXBbbmFtZV0gJiBraW5kKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yVG9sZXJhbnQoe30sIE1lc3NhZ2VzLkFjY2Vzc29yR2V0U2V0KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBbbmFtZV0gfD0ga2luZDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgbWFwW25hbWVdID0ga2luZDtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcHJvcGVydGllcy5wdXNoKHByb3BlcnR5KTtcblxuICAgICAgICAgICAgaWYgKCFtYXRjaCgnfScpKSB7XG4gICAgICAgICAgICAgICAgZXhwZWN0KCcsJyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBleHBlY3QoJ30nKTtcblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4Lk9iamVjdEV4cHJlc3Npb24sXG4gICAgICAgICAgICBwcm9wZXJ0aWVzOiBwcm9wZXJ0aWVzXG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgLy8gMTEuMS42IFRoZSBHcm91cGluZyBPcGVyYXRvclxuXG4gICAgZnVuY3Rpb24gcGFyc2VHcm91cEV4cHJlc3Npb24oKSB7XG4gICAgICAgIHZhciBleHByO1xuXG4gICAgICAgIGV4cGVjdCgnKCcpO1xuXG4gICAgICAgIGV4cHIgPSBwYXJzZUV4cHJlc3Npb24oKTtcblxuICAgICAgICBleHBlY3QoJyknKTtcblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cblxuICAgIC8vIDExLjEgUHJpbWFyeSBFeHByZXNzaW9uc1xuXG4gICAgZnVuY3Rpb24gcGFyc2VQcmltYXJ5RXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIHRva2VuID0gbG9va2FoZWFkKCksXG4gICAgICAgICAgICB0eXBlID0gdG9rZW4udHlwZTtcblxuICAgICAgICBpZiAodHlwZSA9PT0gVG9rZW4uSWRlbnRpZmllcikge1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguSWRlbnRpZmllcixcbiAgICAgICAgICAgICAgICBuYW1lOiBsZXgoKS52YWx1ZVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0eXBlID09PSBUb2tlbi5TdHJpbmdMaXRlcmFsIHx8IHR5cGUgPT09IFRva2VuLk51bWVyaWNMaXRlcmFsKSB7XG4gICAgICAgICAgICBpZiAoc3RyaWN0ICYmIHRva2VuLm9jdGFsKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHRva2VuLCBNZXNzYWdlcy5TdHJpY3RPY3RhbExpdGVyYWwpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGNyZWF0ZUxpdGVyYWwobGV4KCkpO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHR5cGUgPT09IFRva2VuLktleXdvcmQpIHtcbiAgICAgICAgICAgIGlmIChtYXRjaEtleXdvcmQoJ3RoaXMnKSkge1xuICAgICAgICAgICAgICAgIGxleCgpO1xuICAgICAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5UaGlzRXhwcmVzc2lvblxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChtYXRjaEtleXdvcmQoJ2Z1bmN0aW9uJykpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gcGFyc2VGdW5jdGlvbkV4cHJlc3Npb24oKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0eXBlID09PSBUb2tlbi5Cb29sZWFuTGl0ZXJhbCkge1xuICAgICAgICAgICAgbGV4KCk7XG4gICAgICAgICAgICB0b2tlbi52YWx1ZSA9ICh0b2tlbi52YWx1ZSA9PT0gJ3RydWUnKTtcbiAgICAgICAgICAgIHJldHVybiBjcmVhdGVMaXRlcmFsKHRva2VuKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0eXBlID09PSBUb2tlbi5OdWxsTGl0ZXJhbCkge1xuICAgICAgICAgICAgbGV4KCk7XG4gICAgICAgICAgICB0b2tlbi52YWx1ZSA9IG51bGw7XG4gICAgICAgICAgICByZXR1cm4gY3JlYXRlTGl0ZXJhbCh0b2tlbik7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAobWF0Y2goJ1snKSkge1xuICAgICAgICAgICAgcmV0dXJuIHBhcnNlQXJyYXlJbml0aWFsaXNlcigpO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKG1hdGNoKCd7JykpIHtcbiAgICAgICAgICAgIHJldHVybiBwYXJzZU9iamVjdEluaXRpYWxpc2VyKCk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAobWF0Y2goJygnKSkge1xuICAgICAgICAgICAgcmV0dXJuIHBhcnNlR3JvdXBFeHByZXNzaW9uKCk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAobWF0Y2goJy8nKSB8fCBtYXRjaCgnLz0nKSkge1xuICAgICAgICAgICAgcmV0dXJuIGNyZWF0ZUxpdGVyYWwoc2NhblJlZ0V4cCgpKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB0aHJvd1VuZXhwZWN0ZWQobGV4KCkpO1xuICAgIH1cblxuICAgIC8vIDExLjIgTGVmdC1IYW5kLVNpZGUgRXhwcmVzc2lvbnNcblxuICAgIGZ1bmN0aW9uIHBhcnNlQXJndW1lbnRzKCkge1xuICAgICAgICB2YXIgYXJncyA9IFtdO1xuXG4gICAgICAgIGV4cGVjdCgnKCcpO1xuXG4gICAgICAgIGlmICghbWF0Y2goJyknKSkge1xuICAgICAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgYXJncy5wdXNoKHBhcnNlQXNzaWdubWVudEV4cHJlc3Npb24oKSk7XG4gICAgICAgICAgICAgICAgaWYgKG1hdGNoKCcpJykpIHtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGV4cGVjdCgnLCcpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZXhwZWN0KCcpJyk7XG5cbiAgICAgICAgcmV0dXJuIGFyZ3M7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2VOb25Db21wdXRlZFByb3BlcnR5KCkge1xuICAgICAgICB2YXIgdG9rZW4gPSBsZXgoKTtcblxuICAgICAgICBpZiAoIWlzSWRlbnRpZmllck5hbWUodG9rZW4pKSB7XG4gICAgICAgICAgICB0aHJvd1VuZXhwZWN0ZWQodG9rZW4pO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHR5cGU6IFN5bnRheC5JZGVudGlmaWVyLFxuICAgICAgICAgICAgbmFtZTogdG9rZW4udmFsdWVcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwYXJzZU5vbkNvbXB1dGVkTWVtYmVyKCkge1xuICAgICAgICBleHBlY3QoJy4nKTtcblxuICAgICAgICByZXR1cm4gcGFyc2VOb25Db21wdXRlZFByb3BlcnR5KCk7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2VDb21wdXRlZE1lbWJlcigpIHtcbiAgICAgICAgdmFyIGV4cHI7XG5cbiAgICAgICAgZXhwZWN0KCdbJyk7XG5cbiAgICAgICAgZXhwciA9IHBhcnNlRXhwcmVzc2lvbigpO1xuXG4gICAgICAgIGV4cGVjdCgnXScpO1xuXG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBhcnNlTmV3RXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHI7XG5cbiAgICAgICAgZXhwZWN0S2V5d29yZCgnbmV3Jyk7XG5cbiAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgIHR5cGU6IFN5bnRheC5OZXdFeHByZXNzaW9uLFxuICAgICAgICAgICAgY2FsbGVlOiBwYXJzZUxlZnRIYW5kU2lkZUV4cHJlc3Npb24oKSxcbiAgICAgICAgICAgICdhcmd1bWVudHMnOiBbXVxuICAgICAgICB9O1xuXG4gICAgICAgIGlmIChtYXRjaCgnKCcpKSB7XG4gICAgICAgICAgICBleHByWydhcmd1bWVudHMnXSA9IHBhcnNlQXJndW1lbnRzKCk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwYXJzZUxlZnRIYW5kU2lkZUV4cHJlc3Npb25BbGxvd0NhbGwoKSB7XG4gICAgICAgIHZhciBleHByO1xuXG4gICAgICAgIGV4cHIgPSBtYXRjaEtleXdvcmQoJ25ldycpID8gcGFyc2VOZXdFeHByZXNzaW9uKCkgOiBwYXJzZVByaW1hcnlFeHByZXNzaW9uKCk7XG5cbiAgICAgICAgd2hpbGUgKG1hdGNoKCcuJykgfHwgbWF0Y2goJ1snKSB8fCBtYXRjaCgnKCcpKSB7XG4gICAgICAgICAgICBpZiAobWF0Y2goJygnKSkge1xuICAgICAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5DYWxsRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICAgICAgY2FsbGVlOiBleHByLFxuICAgICAgICAgICAgICAgICAgICAnYXJndW1lbnRzJzogcGFyc2VBcmd1bWVudHMoKVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1hdGNoKCdbJykpIHtcbiAgICAgICAgICAgICAgICBleHByID0ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguTWVtYmVyRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICAgICAgY29tcHV0ZWQ6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIG9iamVjdDogZXhwcixcbiAgICAgICAgICAgICAgICAgICAgcHJvcGVydHk6IHBhcnNlQ29tcHV0ZWRNZW1iZXIoKVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5NZW1iZXJFeHByZXNzaW9uLFxuICAgICAgICAgICAgICAgICAgICBjb21wdXRlZDogZmFsc2UsXG4gICAgICAgICAgICAgICAgICAgIG9iamVjdDogZXhwcixcbiAgICAgICAgICAgICAgICAgICAgcHJvcGVydHk6IHBhcnNlTm9uQ29tcHV0ZWRNZW1iZXIoKVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cblxuICAgIGZ1bmN0aW9uIHBhcnNlTGVmdEhhbmRTaWRlRXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHI7XG5cbiAgICAgICAgZXhwciA9IG1hdGNoS2V5d29yZCgnbmV3JykgPyBwYXJzZU5ld0V4cHJlc3Npb24oKSA6IHBhcnNlUHJpbWFyeUV4cHJlc3Npb24oKTtcblxuICAgICAgICB3aGlsZSAobWF0Y2goJy4nKSB8fCBtYXRjaCgnWycpKSB7XG4gICAgICAgICAgICBpZiAobWF0Y2goJ1snKSkge1xuICAgICAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5NZW1iZXJFeHByZXNzaW9uLFxuICAgICAgICAgICAgICAgICAgICBjb21wdXRlZDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgb2JqZWN0OiBleHByLFxuICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0eTogcGFyc2VDb21wdXRlZE1lbWJlcigpXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogU3ludGF4Lk1lbWJlckV4cHJlc3Npb24sXG4gICAgICAgICAgICAgICAgICAgIGNvbXB1dGVkOiBmYWxzZSxcbiAgICAgICAgICAgICAgICAgICAgb2JqZWN0OiBleHByLFxuICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0eTogcGFyc2VOb25Db21wdXRlZE1lbWJlcigpXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIC8vIDExLjMgUG9zdGZpeCBFeHByZXNzaW9uc1xuXG4gICAgZnVuY3Rpb24gcGFyc2VQb3N0Zml4RXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIgPSBwYXJzZUxlZnRIYW5kU2lkZUV4cHJlc3Npb25BbGxvd0NhbGwoKSwgdG9rZW47XG5cbiAgICAgICAgdG9rZW4gPSBsb29rYWhlYWQoKTtcbiAgICAgICAgaWYgKHRva2VuLnR5cGUgIT09IFRva2VuLlB1bmN0dWF0b3IpIHtcbiAgICAgICAgICAgIHJldHVybiBleHByO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKChtYXRjaCgnKysnKSB8fCBtYXRjaCgnLS0nKSkgJiYgIXBlZWtMaW5lVGVybWluYXRvcigpKSB7XG4gICAgICAgICAgICAvLyAxMS4zLjEsIDExLjMuMlxuICAgICAgICAgICAgaWYgKHN0cmljdCAmJiBleHByLnR5cGUgPT09IFN5bnRheC5JZGVudGlmaWVyICYmIGlzUmVzdHJpY3RlZFdvcmQoZXhwci5uYW1lKSkge1xuICAgICAgICAgICAgICAgIHRocm93RXJyb3JUb2xlcmFudCh7fSwgTWVzc2FnZXMuU3RyaWN0TEhTUG9zdGZpeCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoIWlzTGVmdEhhbmRTaWRlKGV4cHIpKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5JbnZhbGlkTEhTSW5Bc3NpZ25tZW50KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguVXBkYXRlRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogbGV4KCkudmFsdWUsXG4gICAgICAgICAgICAgICAgYXJndW1lbnQ6IGV4cHIsXG4gICAgICAgICAgICAgICAgcHJlZml4OiBmYWxzZVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIC8vIDExLjQgVW5hcnkgT3BlcmF0b3JzXG5cbiAgICBmdW5jdGlvbiBwYXJzZVVuYXJ5RXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIHRva2VuLCBleHByO1xuXG4gICAgICAgIHRva2VuID0gbG9va2FoZWFkKCk7XG4gICAgICAgIGlmICh0b2tlbi50eXBlICE9PSBUb2tlbi5QdW5jdHVhdG9yICYmIHRva2VuLnR5cGUgIT09IFRva2VuLktleXdvcmQpIHtcbiAgICAgICAgICAgIHJldHVybiBwYXJzZVBvc3RmaXhFeHByZXNzaW9uKCk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAobWF0Y2goJysrJykgfHwgbWF0Y2goJy0tJykpIHtcbiAgICAgICAgICAgIHRva2VuID0gbGV4KCk7XG4gICAgICAgICAgICBleHByID0gcGFyc2VVbmFyeUV4cHJlc3Npb24oKTtcbiAgICAgICAgICAgIC8vIDExLjQuNCwgMTEuNC41XG4gICAgICAgICAgICBpZiAoc3RyaWN0ICYmIGV4cHIudHlwZSA9PT0gU3ludGF4LklkZW50aWZpZXIgJiYgaXNSZXN0cmljdGVkV29yZChleHByLm5hbWUpKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5TdHJpY3RMSFNQcmVmaXgpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoIWlzTGVmdEhhbmRTaWRlKGV4cHIpKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5JbnZhbGlkTEhTSW5Bc3NpZ25tZW50KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguVXBkYXRlRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogdG9rZW4udmFsdWUsXG4gICAgICAgICAgICAgICAgYXJndW1lbnQ6IGV4cHIsXG4gICAgICAgICAgICAgICAgcHJlZml4OiB0cnVlXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgcmV0dXJuIGV4cHI7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAobWF0Y2goJysnKSB8fCBtYXRjaCgnLScpIHx8IG1hdGNoKCd+JykgfHwgbWF0Y2goJyEnKSkge1xuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguVW5hcnlFeHByZXNzaW9uLFxuICAgICAgICAgICAgICAgIG9wZXJhdG9yOiBsZXgoKS52YWx1ZSxcbiAgICAgICAgICAgICAgICBhcmd1bWVudDogcGFyc2VVbmFyeUV4cHJlc3Npb24oKSxcbiAgICAgICAgICAgICAgICBwcmVmaXg6IHRydWVcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICByZXR1cm4gZXhwcjtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChtYXRjaEtleXdvcmQoJ2RlbGV0ZScpIHx8IG1hdGNoS2V5d29yZCgndm9pZCcpIHx8IG1hdGNoS2V5d29yZCgndHlwZW9mJykpIHtcbiAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LlVuYXJ5RXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogbGV4KCkudmFsdWUsXG4gICAgICAgICAgICAgICAgYXJndW1lbnQ6IHBhcnNlVW5hcnlFeHByZXNzaW9uKCksXG4gICAgICAgICAgICAgICAgcHJlZml4OiB0cnVlXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKHN0cmljdCAmJiBleHByLm9wZXJhdG9yID09PSAnZGVsZXRlJyAmJiBleHByLmFyZ3VtZW50LnR5cGUgPT09IFN5bnRheC5JZGVudGlmaWVyKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5TdHJpY3REZWxldGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGV4cHI7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gcGFyc2VQb3N0Zml4RXhwcmVzc2lvbigpO1xuICAgIH1cblxuICAgIC8vIDExLjUgTXVsdGlwbGljYXRpdmUgT3BlcmF0b3JzXG5cbiAgICBmdW5jdGlvbiBwYXJzZU11bHRpcGxpY2F0aXZlRXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIgPSBwYXJzZVVuYXJ5RXhwcmVzc2lvbigpO1xuXG4gICAgICAgIHdoaWxlIChtYXRjaCgnKicpIHx8IG1hdGNoKCcvJykgfHwgbWF0Y2goJyUnKSkge1xuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguQmluYXJ5RXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogbGV4KCkudmFsdWUsXG4gICAgICAgICAgICAgICAgbGVmdDogZXhwcixcbiAgICAgICAgICAgICAgICByaWdodDogc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AgICAgICAgICAgICAgcmlnaHQ6IHBhcnNlQWRkaXRpdmVFeHByZXNzaW9uKClcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG4gICAgLy8gMTEuOCBSZWxhdGlvbmFsIE9wZXJhdG9yc1xuXG4gICAgZnVuY3Rpb24gcGFyc2VSZWxhdGlvbmFsRXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIsIHByZXZpb3VzQWxsb3dJbjtcblxuICAgICAgICBwcmV2aW91c0FsbG93SW4gPSBzdGF0ZS5hbGxvd0luO1xuICAgICAgICBzdGF0ZS5hbGxvd0luID0gdHJ1ZTtcblxuICAgICAgICBleHByID0gcGFyc2VTaGlmdEV4cHJlc3Npb24oKTtcblxuICAgICAgICB3aGlsZSAobWF0Y2goJzwnKSB8fCBtYXRjaCgnPicpIHx8IG1hdGNoKCc8PScpIHx8IG1hdGNoKCc+PScpIHx8IChwcmV2aW91c0FsbG93SW4gJiYgbWF0Y2hLZXl3b3JkKCdpbicpKSB8fCBtYXRjaEtleXdvcmQoJ2luc3RhbmNlb2YnKSkge1xuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguQmluYXJ5RXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogbGV4KCkudmFsdWUsXG4gICAgICAgICAgICAgICAgbGVmdDogZXhwcixcbiAgICAgICAgICAgICAgICByaWdodDogcGFyc2VTaGlmdEV4cHJlc3Npb24oKVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIHN0YXRlLmFsbG93SW4gPSBwcmV2aW91c0FsbG93SW47XG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIC8vIDExLjkgRXF1YWxpdHkgT3BlcmF0b3JzXG5cbiAgICBmdW5jdGlvbiBwYXJzZUVxdWFsaXR5RXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIgPSBwYXJzZVJlbGF0aW9uYWxFeHByZXNzaW9uKCk7XG5cbiAgICAgICAgd2hpbGUgKG1hdGNoKCc9PScpIHx8IG1hdGNoKCchPScpIHx8IG1hdGNoKCc9PT0nKSB8fCBtYXRjaCgnIT09JykpIHtcbiAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LkJpbmFyeUV4cHJlc3Npb24sXG4gICAgICAgICAgICAgICAgb3BlcmF0b3I6IGxleCgpLnZhbHVlLFxuICAgICAgICAgICAgICAgIGxlZnQ6IGV4cHIsXG4gICAgICAgICAgICAgICAgcmlnaHQ6IHBhcnNlUmVsYXRpb25hbEV4cHJlc3Npb24oKVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIC8vIDExLjEwIEJpbmFyeSBCaXR3aXNlIE9wZXJhdG9yc1xuXG4gICAgZnVuY3Rpb24gcGFyc2VCaXR3aXNlQU5ERXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIgPSBwYXJzZUVxdWFsaXR5RXhwcmVzc2lvbigpO1xuXG4gICAgICAgIHdoaWxlIChtYXRjaCgnJicpKSB7XG4gICAgICAgICAgICBsZXgoKTtcbiAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LkJpbmFyeUV4cHJlc3Npb24sXG4gICAgICAgICAgICAgICAgb3BlcmF0b3I6ICcmJyxcbiAgICAgICAgICAgICAgICBsZWZ0OiBleHByLFxuICAgICAgICAgICAgICAgIHJpZ2h0OiBwYXJzZUVxdWFsaXR5RXhwcmVzc2lvbigpXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGV4cHI7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2VCaXR3aXNlWE9SRXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIgPSBwYXJzZUJpdHdpc2VBTkRFeHByZXNzaW9uKCk7XG5cbiAgICAgICAgd2hpbGUgKG1hdGNoKCdeJykpIHtcbiAgICAgICAgICAgIGxleCgpO1xuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguQmluYXJ5RXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogJ14nLFxuICAgICAgICAgICAgICAgIGxlZnQ6IGV4cHIsXG4gICAgICAgICAgICAgICAgcmlnaHQ6IHBhcnNlQml0d2lzZUFOREV4cHJlc3Npb24oKVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBhcnNlQml0d2lzZU9SRXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIgPSBwYXJzZUJpdHdpc2VYT1JFeHByZXNzaW9uKCk7XG5cbiAgICAgICAgd2hpbGUgKG1hdGNoKCd8JykpIHtcbiAgICAgICAgICAgIGxleCgpO1xuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguQmluYXJ5RXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogJ3wnLFxuICAgICAgICAgICAgICAgIGxlZnQ6IGV4cHIsXG4gICAgICAgICAgICAgICAgcmlnaHQ6IHBhcnNlQml0d2lzZVhPUkV4cHJlc3Npb24oKVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIC8vIDExLjExIEJpbmFyeSBMb2dpY2FsIE9wZXJhdG9yc1xuXG4gICAgZnVuY3Rpb24gcGFyc2VMb2dpY2FsQU5ERXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIgPSBwYXJzZUJpdHdpc2VPUkV4cHJlc3Npb24oKTtcblxuICAgICAgICB3aGlsZSAobWF0Y2goJyYmJykpIHtcbiAgICAgICAgICAgIGxleCgpO1xuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguTG9naWNhbEV4cHJlc3Npb24sXG4gICAgICAgICAgICAgICAgb3BlcmF0b3I6ICcmJicsXG4gICAgICAgICAgICAgICAgbGVmdDogZXhwcixcbiAgICAgICAgICAgICAgICByaWdodDogcGFyc2VCaXR3aXNlT1JFeHByZXNzaW9uKClcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwYXJzZUxvZ2ljYWxPUkV4cHJlc3Npb24oKSB7XG4gICAgICAgIHZhciBleHByID0gcGFyc2VMb2dpY2FsQU5ERXhwcmVzc2lvbigpO1xuXG4gICAgICAgIHdoaWxlIChtYXRjaCgnfHwnKSkge1xuICAgICAgICAgICAgbGV4KCk7XG4gICAgICAgICAgICBleHByID0ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5Mb2dpY2FsRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogJ3x8JyxcbiAgICAgICAgICAgICAgICBsZWZ0OiBleHByLFxuICAgICAgICAgICAgICAgIHJpZ2h0OiBwYXJzZUxvZ2ljYWxBTkRFeHByZXNzaW9uKClcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cbiAgICAvLyAxMS4xMiBDb25kaXRpb25hbCBPcGVyYXRvclxuXG4gICAgZnVuY3Rpb24gcGFyc2VDb25kaXRpb25hbEV4cHJlc3Npb24oKSB7XG4gICAgICAgIHZhciBleHByLCBwcmV2aW91c0FsbG93SW4sIGNvbnNlcXVlbnQ7XG5cbiAgICAgICAgZXhwciA9IHBhcnNlTG9naWNhbE9SRXhwcmVzc2lvbigpO1xuXG4gICAgICAgIGlmIChtYXRjaCgnPycpKSB7XG4gICAgICAgICAgICBsZXgoKTtcbiAgICAgICAgICAgIHByZXZpb3VzQWxsb3dJbiA9IHN0YXRlLmFsbG93SW47XG4gICAgICAgICAgICBzdGF0ZS5hbGxvd0luID0gdHJ1ZTtcbiAgICAgICAgICAgIGNvbnNlcXVlbnQgPSBwYXJzZUFzc2lnbm1lbnRFeHByZXNzaW9uKCk7XG4gICAgICAgICAgICBzdGF0ZS5hbGxvd0luID0gcHJldmlvdXNBbGxvd0luO1xuICAgICAgICAgICAgZXhwZWN0KCc6Jyk7XG5cbiAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LkNvbmRpdGlvbmFsRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICB0ZXN0OiBleHByLFxuICAgICAgICAgICAgICAgIGNvbnNlcXVlbnQ6IGNvbnNlcXVlbnQsXG4gICAgICAgICAgICAgICAgYWx0ZXJuYXRlOiBwYXJzZUFzc2lnbm1lbnRFeHByZXNzaW9uKClcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cbiAgICAvLyAxMS4xMyBBc3NpZ25tZW50IE9wZXJhdG9yc1xuXG4gICAgZnVuY3Rpb24gcGFyc2VBc3NpZ25tZW50RXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIHRva2VuLCBleHByO1xuXG4gICAgICAgIHRva2VuID0gbG9va2FoZWFkKCk7XG4gICAgICAgIGV4cHIgPSBwYXJzZUNvbmRpdGlvbmFsRXhwcmVzc2lvbigpO1xuXG4gICAgICAgIGlmIChtYXRjaEFzc2lnbigpKSB7XG4gICAgICAgICAgICAvLyBMZWZ0SGFuZFNpZGVFeHByZXNzaW9uXG4gICAgICAgICAgICBpZiAoIWlzTGVmdEhhbmRTaWRlKGV4cHIpKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5JbnZhbGlkTEhTSW5Bc3NpZ25tZW50KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gMTEuMTMuMVxuICAgICAgICAgICAgaWYgKHN0cmljdCAmJiBleHByLnR5cGUgPT09IFN5bnRheC5JZGVudGlmaWVyICYmIGlzUmVzdHJpY3RlZFdvcmQoZXhwci5uYW1lKSkge1xuICAgICAgICAgICAgICAgIHRocm93RXJyb3JUb2xlcmFudCh0b2tlbiwgTWVzc2FnZXMuU3RyaWN0TEhTQXNzaWdubWVudCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LkFzc2lnbm1lbnRFeHByZXNzaW9uLFxuICAgICAgICAgICAgICAgIG9wZXJhdG9yOiBsZXgoKS52YWx1ZSxcbiAgICAgICAgICAgICAgICBsZWZ0OiBleHByLFxuICAgICAgICAgICAgICAgIHJpZ2h0OiBwYXJzZUFzc2lnbm1lbnRFeHByZXNzaW9uKClcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cbiAgICAvLyAxMS4xNCBDb21tYSBPcGVyYXRvclxuXG4gICAgZnVuY3Rpb24gcGFyc2VFeHByZXNzaW9uKCkge1xuICAgICAgICB2YXIgZXhwciA9IHBhcnNlQXNzaWdubWVudEV4cHJlc3Npb24oKTtcblxuICAgICAgICBpZiAobWF0Y2goJywnKSkge1xuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguU2VxdWVuY2VFeHByZXNzaW9uLFxuICAgICAgICAgICAgICAgIGV4cHJlc3Npb25zOiBbIGV4cHIgXVxuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgaWYgKCFtYXRjaCgnLCcpKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBsZXgoKTtcbiAgICAgICAgICAgICAgICBleHByLmV4cHJlc3Npb25zLnB1c2gocGFyc2VBc3NpZ25tZW50RXhwcmVzc2lvbigpKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIC8vIDEyLjEgQmxvY2tcblxuICAgIGZ1bmN0aW9uIHBhcnNlU3RhdGVtZW50TGlzdCgpIHtcbiAgICAgICAgdmFyIGxpc3QgPSBbXSxcbiAgICAgICAgICAgIHN0YXRlbWVudDtcblxuICAgICAgICB3aGlsZSAoaW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgICAgIGlmIChtYXRjaCgnfScpKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzdGF0ZW1lbnQgPSBwYXJzZVNvdXJjZUVsZW1lbnQoKTtcbiAgICAgICAgICAgIGlmICh0eXBlb2Ygc3RhdGVtZW50ID09PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbGlzdC5wdXNoKHN0YXRlbWVudCk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gbGlzdDtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwYXJzZUJsb2NrKCkge1xuICAgICAgICB2YXIgYmxvY2s7XG5cbiAgICAgICAgZXhwZWN0KCd7Jyk7XG5cbiAgICAgICAgYmxvY2sgPSBwYXJzZVN0YXRlbWVudExpc3QoKTtcblxuICAgICAgICBleHBlY3QoJ30nKTtcblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkJsb2NrU3RhdGVtZW50LFxuICAgICAgICAgICAgYm9keTogYmxvY2tcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyAxMi4yIFZhcmlhYmxlIFN0YXRlbWVudFxuXG4gICAgZnVuY3Rpb24gcGFyc2VWYXJpYWJsZUlkZW50aWZpZXIoKSB7XG4gICAgICAgIHZhciB0b2tlbiA9IGxleCgpO1xuXG4gICAgICAgIGlmICh0b2tlbi50eXBlICE9PSBUb2tlbi5JZGVudGlmaWVyKSB7XG4gICAgICAgICAgICB0aHJvd1VuZXhwZWN0ZWQodG9rZW4pO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHR5cGU6IFN5bnRheC5JZGVudGlmaWVyLFxuICAgICAgICAgICAgbmFtZTogdG9rZW4udmFsdWVcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwYXJzZVZhcmlhYmxlRGVjbGFyYXRpb24oa2luZCkge1xuICAgICAgICB2YXIgaWQgPSBwYXJzZVZhcmlhYmxlSWRlbnRpZmllcigpLFxuICAgICAgICAgICAgaW5pdCA9IG51bGw7XG5cbiAgICAgICAgLy8gMTIuMi4xXG4gICAgICAgIGlmIChzdHJpY3QgJiYgaXNSZXN0cmljdGVkV29yZChpZC5uYW1lKSkge1xuICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5TdHJpY3RWYXJOYW1lKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChraW5kID09PSAnY29uc3QnKSB7XG4gICAgICAgICAgICBleHBlY3QoJz0nKTtcbiAgICAgICAgICAgIGluaXQgPSBwYXJzZUFzc2lnbm1lbnRFeHByZXNzaW9uKCk7XG4gICAgICAgIH0gZWxzZSBpZiAobWF0Y2goJz0nKSkge1xuICAgICAgICAgICAgbGV4KCk7XG4gICAgICAgICAgICBpbml0ID0gcGFyc2VBc3NpZ25tZW50RXhwcmVzc2lvbigpO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHR5cGU6IFN5bnRheC5WYXJpYWJsZURlY2xhcmF0b3IsXG4gICAgICAgICAgICBpZDogaWQsXG4gICAgICAgICAgICBpbml0OiBpbml0XG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2VWYXJpYWJsZURlY2xhcmF0aW9uTGlzdChraW5kKSB7XG4gICAgICAgIHZhciBsaXN0ID0gW107XG5cbiAgICAgICAgZG8ge1xuICAgICAgICAgICAgbGlzdC5wdXNoKHBhcnNlVmFyaWFibGVEZWNsYXJhdGlvbihraW5kKSk7XG4gICAgICAgICAgICBpZiAoIW1hdGNoKCcsJykpIHtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGxleCgpO1xuICAgICAgICB9IHdoaWxlIChpbmRleCA8IGxlbmd0aCk7XG5cbiAgICAgICAgcmV0dXJuIGxpc3Q7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2VWYXJpYWJsZVN0YXRlbWVudCgpIHtcbiAgICAgICAgdmFyIGRlY2xhcmF0aW9ucztcblxuICAgICAgICBleHBlY3RLZXl3b3JkKCd2YXInKTtcblxuICAgICAgICBkZWNsYXJhdGlvbnMgPSBwYXJzZVZhcmlhYmxlRGVjbGFyYXRpb25MaXN0KCk7XG5cbiAgICAgICAgY29uc3VtZVNlbWljb2xvbigpO1xuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBTeW50YXguVmFyaWFibGVEZWNsYXJhdGlvbixcbiAgICAgICAgICAgIGRlY2xhcmF0aW9uczogZGVjbGFyYXRpb25zLFxuICAgICAgICAgICAga2luZDogJ3ZhcidcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyBraW5kIG1heSBiZSBgY29uc3RgIG9yIGBsZXRgXG4gICAgLy8gQm90aCBhcmUgZXhwZXJpbWVudGFsIGFuZCBub3QgaW4gdGhlIHNwZWNpZmljYXRpb24geWV0LlxuICAgIC8vIHNlZSBodHRwOi8vd2lraS5lY21hc2NyaXB0Lm9yZy9kb2t1LnBocD9pZD1oYXJtb255OmNvbnN0XG4gICAgLy8gYW5kIGh0dHA6Ly93aWtpLmVjbWFzY3JpcHQub3JnL2Rva3UucGhwP2lkPWhhcm1vbnk6bGV0XG4gICAgZnVuY3Rpb24gcGFyc2VDb25zdExldERlY2xhcmF0aW9uKGtpbmQpIHtcbiAgICAgICAgdmFyIGRlY2xhcmF0aW9ucztcblxuICAgICAgICBleHBlY3RLZXl3b3JkKGtpbmQpO1xuXG4gICAgICAgIGRlY2xhcmF0aW9ucyA9IHBhcnNlVmFyaWFibGVEZWNsYXJhdGlvbkxpc3Qoa2luZCk7XG5cbiAgICAgICAgY29uc3VtZVNlbWljb2xvbigpO1xuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBTeW50YXguVmFyaWFibGVEZWNsYXJhdGlvbixcbiAgICAgICAgICAgIGRlY2xhcmF0aW9uczogZGVjbGFyYXRpb25zLFxuICAgICAgICAgICAga2luZDoga2luZFxuICAgICAgICB9O1xuICAgIH1cblxuICAgIC8vIDEyLjMgRW1wdHkgU3RhdGVtZW50XG5cbiAgICBmdW5jdGlvbiBwYXJzZUVtcHR5U3RhdGVtZW50KCkge1xuICAgICAgICBleHBlY3QoJzsnKTtcblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkVtcHR5U3RhdGVtZW50XG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgLy8gMTIuNCBFeHByZXNzaW9uIFN0YXRlbWVudFxuXG4gICAgZnVuY3Rpb24gcGFyc2VFeHByZXNzaW9uU3RhdGVtZW50KCkge1xuICAgICAgICB2YXIgZXhwciA9IHBhcnNlRXhwcmVzc2lvbigpO1xuXG4gICAgICAgIGNvbnN1bWVTZW1pY29sb24oKTtcblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkV4cHJlc3Npb25TdGF0ZW1lb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AgICAgICAgICB0eXBlOiBTeW50YXguV2hpbGVTdGF0ZW1lbnQsXG4gICAgICAgICAgICB0ZXN0OiB0ZXN0LFxuICAgICAgICAgICAgYm9keTogYm9keVxuICAgICAgICB9O1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBhcnNlRm9yVmFyaWFibGVEZWNsYXJhdGlvbigpIHtcbiAgICAgICAgdmFyIHRva2VuID0gbGV4KCk7XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHR5cGU6IFN5bnRheC5WYXJpYWJsZURlY2xhcmF0aW9uLFxuICAgICAgICAgICAgZGVjbGFyYXRpb25zOiBwYXJzZVZhcmlhYmxlRGVjbGFyYXRpb25MaXN0KCksXG4gICAgICAgICAgICBraW5kOiB0b2tlbi52YWx1ZVxuICAgICAgICB9O1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBhcnNlRm9yU3RhdGVtZW50KCkge1xuICAgICAgICB2YXIgaW5pdCwgdGVzdCwgdXBkYXRlLCBsZWZ0LCByaWdodCwgYm9keSwgb2xkSW5JdGVyYXRpb247XG5cbiAgICAgICAgaW5pdCA9IHRlc3QgPSB1cGRhdGUgPSBudWxsO1xuXG4gICAgICAgIGV4cGVjdEtleXdvcmQoJ2ZvcicpO1xuXG4gICAgICAgIGV4cGVjdCgnKCcpO1xuXG4gICAgICAgIGlmIChtYXRjaCgnOycpKSB7XG4gICAgICAgICAgICBsZXgoKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmIChtYXRjaEtleXdvcmQoJ3ZhcicpIHx8IG1hdGNoS2V5d29yZCgnbGV0JykpIHtcbiAgICAgICAgICAgICAgICBzdGF0ZS5hbGxvd0luID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgaW5pdCA9IHBhcnNlRm9yVmFyaWFibGVEZWNsYXJhdGlvbigpO1xuICAgICAgICAgICAgICAgIHN0YXRlLmFsbG93SW4gPSB0cnVlO1xuXG4gICAgICAgICAgICAgICAgaWYgKGluaXQuZGVjbGFyYXRpb25zLmxlbmd0aCA9PT0gMSAmJiBtYXRjaEtleXdvcmQoJ2luJykpIHtcbiAgICAgICAgICAgICAgICAgICAgbGV4KCk7XG4gICAgICAgICAgICAgICAgICAgIGxlZnQgPSBpbml0O1xuICAgICAgICAgICAgICAgICAgICByaWdodCA9IHBhcnNlRXhwcmVzc2lvbigpO1xuICAgICAgICAgICAgICAgICAgICBpbml0ID0gbnVsbDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHN0YXRlLmFsbG93SW4gPSBmYWxzZTtcbiAgICAgICAgICAgICAgICBpbml0ID0gcGFyc2VFeHByZXNzaW9uKCk7XG4gICAgICAgICAgICAgICAgc3RhdGUuYWxsb3dJbiA9IHRydWU7XG5cbiAgICAgICAgICAgICAgICBpZiAobWF0Y2hLZXl3b3JkKCdpbicpKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIExlZnRIYW5kU2lkZUV4cHJlc3Npb25cbiAgICAgICAgICAgICAgICAgICAgaWYgKCFpc0xlZnRIYW5kU2lkZShpbml0KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5JbnZhbGlkTEhTSW5Gb3JJbik7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBsZXgoKTtcbiAgICAgICAgICAgICAgICAgICAgbGVmdCA9IGluaXQ7XG4gICAgICAgICAgICAgICAgICAgIHJpZ2h0ID0gcGFyc2VFeHByZXNzaW9uKCk7XG4gICAgICAgICAgICAgICAgICAgIGluaXQgPSBudWxsO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHR5cGVvZiBsZWZ0ID09PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgIGV4cGVjdCgnOycpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHR5cGVvZiBsZWZ0ID09PSAndW5kZWZpbmVkJykge1xuXG4gICAgICAgICAgICBpZiAoIW1hdGNoKCc7JykpIHtcbiAgICAgICAgICAgICAgICB0ZXN0ID0gcGFyc2VFeHByZXNzaW9uKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBleHBlY3QoJzsnKTtcblxuICAgICAgICAgICAgaWYgKCFtYXRjaCgnKScpKSB7XG4gICAgICAgICAgICAgICAgdXBkYXRlID0gcGFyc2VFeHByZXNzaW9uKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBleHBlY3QoJyknKTtcblxuICAgICAgICBvbGRJbkl0ZXJhdGlvbiA9IHN0YXRlLmluSXRlcmF0aW9uO1xuICAgICAgICBzdGF0ZS5pbkl0ZXJhdGlvbiA9IHRydWU7XG5cbiAgICAgICAgYm9keSA9IHBhcnNlU3RhdGVtZW50KCk7XG5cbiAgICAgICAgc3RhdGUuaW5JdGVyYXRpb24gPSBvbGRJbkl0ZXJhdGlvbjtcblxuICAgICAgICBpZiAodHlwZW9mIGxlZnQgPT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5Gb3JTdGF0ZW1lbnQsXG4gICAgICAgICAgICAgICAgaW5pdDogaW5pdCxcbiAgICAgICAgICAgICAgICB0ZXN0OiB0ZXN0LFxuICAgICAgICAgICAgICAgIHVwZGF0ZTogdXBkYXRlLFxuICAgICAgICAgICAgICAgIGJvZHk6IGJvZHlcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkZvckluU3RhdGVtZW50LFxuICAgICAgICAgICAgbGVmdDogbGVmdCxcbiAgICAgICAgICAgIHJpZ2h0OiByaWdodCxcbiAgICAgICAgICAgIGJvZHk6IGJvZHksXG4gICAgICAgICAgICBlYWNoOiBmYWxzZVxuICAgICAgICB9O1xuICAgIH1cblxuICAgIC8vIDEyLjcgVGhlIGNvbnRpbnVlIHN0YXRlbWVudFxuXG4gICAgZnVuY3Rpb24gcGFyc2VDb250aW51ZVN0YXRlbWVudCgpIHtcbiAgICAgICAgdmFyIHRva2VuLCBsYWJlbCA9IG51bGw7XG5cbiAgICAgICAgZXhwZWN0S2V5d29yZCgnY29udGludWUnKTtcblxuICAgICAgICAvLyBPcHRpbWl6ZSB0aGUgbW9zdCBjb21tb24gZm9ybTogJ2NvbnRpbnVlOycuXG4gICAgICAgIGlmIChzb3VyY2VbaW5kZXhdID09PSAnOycpIHtcbiAgICAgICAgICAgIGxleCgpO1xuXG4gICAgICAgICAgICBpZiAoIXN0YXRlLmluSXRlcmF0aW9uKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuSWxsZWdhbENvbnRpbnVlKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguQ29udGludWVTdGF0ZW1lbnQsXG4gICAgICAgICAgICAgICAgbGFiZWw6IG51bGxcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocGVla0xpbmVUZXJtaW5hdG9yKCkpIHtcbiAgICAgICAgICAgIGlmICghc3RhdGUuaW5JdGVyYXRpb24pIHtcbiAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKHt9LCBNZXNzYWdlcy5JbGxlZ2FsQ29udGludWUpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5Db250aW51ZVN0YXRlbWVudCxcbiAgICAgICAgICAgICAgICBsYWJlbDogbnVsbFxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIHRva2VuID0gbG9va2FoZWFkKCk7XG4gICAgICAgIGlmICh0b2tlbi50eXBlID09PSBUb2tlbi5JZGVudGlmaWVyKSB7XG4gICAgICAgICAgICBsYWJlbCA9IHBhcnNlVmFyaWFibGVJZGVudGlmaWVyKCk7XG5cbiAgICAgICAgICAgIGlmICghT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHN0YXRlLmxhYmVsU2V0LCBsYWJlbC5uYW1lKSkge1xuICAgICAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLlVua25vd25MYWJlbCwgbGFiZWwubmFtZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBjb25zdW1lU2VtaWNvbG9uKCk7XG5cbiAgICAgICAgaWYgKGxhYmVsID09PSBudWxsICYmICFzdGF0ZS5pbkl0ZXJhdGlvbikge1xuICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuSWxsZWdhbENvbnRpbnVlKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBTeW50YXguQ29udGludWVTdGF0ZW1lbnQsXG4gICAgICAgICAgICBsYWJlbDogbGFiZWxcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyAxMi44IFRoZSBicmVhayBzdGF0ZW1lbnRcblxuICAgIGZ1bmN0aW9uIHBhcnNlQnJlYWtTdGF0ZW1lbnQoKSB7XG4gICAgICAgIHZhciB0b2tlbiwgbGFiZWwgPSBudWxsO1xuXG4gICAgICAgIGV4cGVjdEtleXdvcmQoJ2JyZWFrJyk7XG5cbiAgICAgICAgLy8gT3B0aW1pemUgdGhlIG1vc3QgY29tbW9uIGZvcm06ICdicmVhazsnLlxuICAgICAgICBpZiAoc291cmNlW2luZGV4XSA9PT0gJzsnKSB7XG4gICAgICAgICAgICBsZXgoKTtcblxuICAgICAgICAgICAgaWYgKCEoc3RhdGUuaW5JdGVyYXRpb24gfHwgc3RhdGUuaW5Td2l0Y2gpKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuSWxsZWdhbEJyZWFrKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguQnJlYWtTdGF0ZW1lbnQsXG4gICAgICAgICAgICAgICAgbGFiZWw6IG51bGxcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocGVla0xpbmVUZXJtaW5hdG9yKCkpIHtcbiAgICAgICAgICAgIGlmICghKHN0YXRlLmluSXRlcmF0aW9uIHx8IHN0YXRlLmluU3dpdGNoKSkge1xuICAgICAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLklsbGVnYWxCcmVhayk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LkJyZWFrU3RhdGVtZW50LFxuICAgICAgICAgICAgICAgIGxhYmVsOiBudWxsXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgdG9rZW4gPSBsb29rYWhlYWQoKTtcbiAgICAgICAgaWYgKHRva2VuLnR5cGUgPT09IFRva2VuLklkZW50aWZpZXIpIHtcbiAgICAgICAgICAgIGxhYmVsID0gcGFyc2VWYXJpYWJsZUlkZW50aWZpZXIoKTtcblxuICAgICAgICAgICAgaWYgKCFPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoc3RhdGUubGFiZWxTZXQsIGxhYmVsLm5hbWUpKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuVW5rbm93bkxhYmVsLCBsYWJlbC5uYW1lKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN1bWVTZW1pY29sb24oKTtcblxuICAgICAgICBpZiAobGFiZWwgPT09IG51bGwgJiYgIShzdGF0ZS5pbkl0ZXJhdGlvbiB8fCBzdGF0ZS5pblN3aXRjaCkpIHtcbiAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLklsbGVnYWxCcmVhayk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkJyZWFrU3RhdGVtZW50LFxuICAgICAgICAgICAgbGFiZWw6IGxhYmVsXG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgLy8gMTIuOSBUaGUgcmV0dXJuIHN0YXRlbWVudFxuXG4gICAgZnVuY3Rpb24gcGFyc2VSZXR1cm5TdGF0ZW1lbnQoKSB7XG4gICAgICAgIHZhciB0b2tlbiwgYXJndW1lbnQgPSBudWxsO1xuXG4gICAgICAgIGV4cGVjdEtleXdvcmQoJ3JldHVybicpO1xuXG4gICAgICAgIGlmICghc3RhdGUuaW5GdW5jdGlvbkJvZHkpIHtcbiAgICAgICAgICAgIHRocm93RXJyb3JUb2xlcmFudCh7fSwgTWVzc2FnZXMuSWxsZWdhbFJldHVybik7XG4gICAgICAgIH1cblxuICAgICAgICAvLyAncmV0dXJuJyBmb2xsb3dlZCBieSBhIHNwYWNlIGFuZCBhbiBpZGVudGlmaWVyIGlzIHZlcnkgY29tbW9uLlxuICAgICAgICBpZiAoc291cmNlW2luZGV4XSA9PT0gJyAnKSB7XG4gICAgICAgICAgICBpZiAoaXNJZGVudGlmaWVyU3RhcnQoc291cmNlW2luZGV4ICsgMV0pKSB7XG4gICAgICAgICAgICAgICAgYXJndW1lbnQgPSBwYXJzZUV4cHJlc3Npb24oKTtcbiAgICAgICAgICAgICAgICBjb25zdW1lU2VtaWNvbG9uKCk7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LlJldHVyblN0YXRlbWVudCxcbiAgICAgICAgICAgICAgICAgICAgYXJndW1lbnQ6IGFyZ3VtZW50XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChwZWVrTGluZVRlcm1pbmF0b3IoKSkge1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguUmV0dXJuU3RhdGVtZW50LFxuICAgICAgICAgICAgICAgIGFyZ3VtZW50OiBudWxsXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKCFtYXRjaCgnOycpKSB7XG4gICAgICAgICAgICB0b2tlbiA9IGxvb2thaGVhZCgpO1xuICAgICAgICAgICAgaWYgKCFtYXRjaCgnfScpICYmIHRva2VuLnR5cGUgIT09IFRva2VuLkVPRikge1xuICAgICAgICAgICAgICAgIGFyZ3VtZW50ID0gcGFyc2VFeHByZXNzaW9uKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBjb25zdW1lU2VtaWNvbG9uKCk7XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHR5cGU6IFN5bnRheC5SZXR1cm5TdGF0ZW1lbnQsXG4gICAgICAgICAgICBhcmd1bWVudDogYXJndW1lbnRcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyAxMi4xMCBUaGUgd2l0aCBzdGF0ZW1lbnRcblxuICAgIGZ1bmN0aW9uIHBhcnNlV2l0aFN0YXRlbWVudCgpIHtcbiAgICAgICAgdmFyIG9iamVjdCwgYm9keTtcblxuICAgICAgICBpZiAoc3RyaWN0KSB7XG4gICAgICAgICAgICB0aHJvd0Vycm9yVG9sZXJhbnQoe30sIE1lc3NhZ2VzLlN0cmljdE1vZGVXaXRoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGV4cGVjdEtleXdvcmQoJ3dpdGgnKTtcblxuICAgICAgICBleHBlY3QoJygnKTtcblxuICAgICAgICBvYmplY3QgPSBwYXJzZUV4cHJlc3Npb24oKTtcblxuICAgICAgICBleHBlY3QoJyknKTtcblxuICAgICAgICBib2R5ID0gcGFyc2VTdGF0ZW1lbnQoKTtcblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LldpdGhTdGF0ZW1lbnQsXG4gICAgICAgICAgICBvYmplY3Q6IG9iamVjdCxcbiAgICAgICAgICAgIGJvZHk6IGJvZHlcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyAxMi4xMCBUaGUgc3dpdGggc3RhdGVtZW50XG5cbiAgICBmdW5jdGlvbiBwYXJzZVN3aXRjaENhc2UoKSB7XG4gICAgICAgIHZhciB0ZXN0LFxuICAgICAgICAgICAgY29uc2VxdWVudCA9IFtdLFxuICAgICAgICAgICAgc3RhdGVtZW50O1xuXG4gICAgICAgIGlmIChtYXRjaEtleXdvcmQoJ2RlZmF1bHQnKSkge1xuICAgICAgICAgICAgbGV4KCk7XG4gICAgICAgICAgICB0ZXN0ID0gbnVsbDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGV4cGVjdEtleXdvcmQoJ2Nhc2UnKTtcbiAgICAgICAgICAgIHRlc3QgPSBwYXJzZUV4cHJlc3Npb24oKTtcbiAgICAgICAgfVxuICAgICAgICBleHBlY3QoJzonKTtcblxuICAgICAgICB3aGlsZSAoaW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgICAgIGlmIChtYXRjaCgnfScpIHx8IG1hdGNoS2V5d29yZCgnZGVmYXVsdCcpIHx8IG1hdGNoS2V5d29yZCgnY2FzZScpKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzdGF0ZW1lbnQgPSBwYXJzZVN0YXRlbWVudCgpO1xuICAgICAgICAgICAgaWYgKHR5cGVvZiBzdGF0ZW1lbnQgPT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjb25zZXF1ZW50Ln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S2V5d29yZCgndHJ5Jyk7XG5cbiAgICAgICAgYmxvY2sgPSBwYXJzZUJsb2NrKCk7XG5cbiAgICAgICAgaWYgKG1hdGNoS2V5d29yZCgnY2F0Y2gnKSkge1xuICAgICAgICAgICAgaGFuZGxlcnMucHVzaChwYXJzZUNhdGNoQ2xhdXNlKCkpO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKG1hdGNoS2V5d29yZCgnZmluYWxseScpKSB7XG4gICAgICAgICAgICBsZXgoKTtcbiAgICAgICAgICAgIGZpbmFsaXplciA9IHBhcnNlQmxvY2soKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChoYW5kbGVycy5sZW5ndGggPT09IDAgJiYgIWZpbmFsaXplcikge1xuICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuTm9DYXRjaE9yRmluYWxseSk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LlRyeVN0YXRlbWVudCxcbiAgICAgICAgICAgIGJsb2NrOiBibG9jayxcbiAgICAgICAgICAgIGd1YXJkZWRIYW5kbGVyczogW10sXG4gICAgICAgICAgICBoYW5kbGVyczogaGFuZGxlcnMsXG4gICAgICAgICAgICBmaW5hbGl6ZXI6IGZpbmFsaXplclxuICAgICAgICB9O1xuICAgIH1cblxuICAgIC8vIDEyLjE1IFRoZSBkZWJ1Z2dlciBzdGF0ZW1lbnRcblxuICAgIGZ1bmN0aW9uIHBhcnNlRGVidWdnZXJTdGF0ZW1lbnQoKSB7XG4gICAgICAgIGV4cGVjdEtleXdvcmQoJ2RlYnVnZ2VyJyk7XG5cbiAgICAgICAgY29uc3VtZVNlbWljb2xvbigpO1xuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBTeW50YXguRGVidWdnZXJTdGF0ZW1lbnRcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyAxMiBTdGF0ZW1lbnRzXG5cbiAgICBmdW5jdGlvbiBwYXJzZVN0YXRlbWVudCgpIHtcbiAgICAgICAgdmFyIHRva2VuID0gbG9va2FoZWFkKCksXG4gICAgICAgICAgICBleHByLFxuICAgICAgICAgICAgbGFiZWxlZEJvZHk7XG5cbiAgICAgICAgaWYgKHRva2VuLnR5cGUgPT09IFRva2VuLkVPRikge1xuICAgICAgICAgICAgdGhyb3dVbmV4cGVjdGVkKHRva2VuKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0b2tlbi50eXBlID09PSBUb2tlbi5QdW5jdHVhdG9yKSB7XG4gICAgICAgICAgICBzd2l0Y2ggKHRva2VuLnZhbHVlKSB7XG4gICAgICAgICAgICBjYXNlICc7JzpcbiAgICAgICAgICAgICAgICByZXR1cm4gcGFyc2VFbXB0eVN0YXRlbWVudCgpO1xuICAgICAgICAgICAgY2FzZSAneyc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlQmxvY2soKTtcbiAgICAgICAgICAgIGNhc2UgJygnOlxuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZUV4cHJlc3Npb25TdGF0ZW1lbnQoKTtcbiAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodG9rZW4udHlwZSA9PT0gVG9rZW4uS2V5d29yZCkge1xuICAgICAgICAgICAgc3dpdGNoICh0b2tlbi52YWx1ZSkge1xuICAgICAgICAgICAgY2FzZSAnYnJlYWsnOlxuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZUJyZWFrU3RhdGVtZW50KCk7XG4gICAgICAgICAgICBjYXNlICdjb250aW51ZSc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlQ29udGludWVTdGF0ZW1lbnQoKTtcbiAgICAgICAgICAgIGNhc2UgJ2RlYnVnZ2VyJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gcGFyc2VEZWJ1Z2dlclN0YXRlbWVudCgpO1xuICAgICAgICAgICAgY2FzZSAnZG8nOlxuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZURvV2hpbGVTdGF0ZW1lbnQoKTtcbiAgICAgICAgICAgIGNhc2UgJ2Zvcic6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlRm9yU3RhdGVtZW50KCk7XG4gICAgICAgICAgICBjYXNlICdmdW5jdGlvbic6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlRnVuY3Rpb25EZWNsYXJhdGlvbigpO1xuICAgICAgICAgICAgY2FzZSAnaWYnOlxuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZUlmU3RhdGVtZW50KCk7XG4gICAgICAgICAgICBjYXNlICdyZXR1cm4nOlxuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZVJldHVyblN0YXRlbWVudCgpO1xuICAgICAgICAgICAgY2FzZSAnc3dpdGNoJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gcGFyc2VTd2l0Y2hTdGF0ZW1lbnQoKTtcbiAgICAgICAgICAgIGNhc2UgJ3Rocm93JzpcbiAgICAgICAgICAgICAgICByZXR1cm4gcGFyc2VUaHJvd1N0YXRlbWVudCgpO1xuICAgICAgICAgICAgY2FzZSAndHJ5JzpcbiAgICAgICAgICAgICAgICByZXR1cm4gcGFyc2VUcnlTdGF0ZW1lbnQoKTtcbiAgICAgICAgICAgIGNhc2UgJ3Zhcic6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlVmFyaWFibGVTdGF0ZW1lbnQoKTtcbiAgICAgICAgICAgIGNhc2UgJ3doaWxlJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gcGFyc2VXaGlsZVN0YXRlbWVudCgpO1xuICAgICAgICAgICAgY2FzZSAnd2l0aCc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlV2l0aFN0YXRlbWVudCgpO1xuICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGV4cHIgPSBwYXJzZUV4cHJlc3Npb24oKTtcblxuICAgICAgICAvLyAxMi4xMiBMYWJlbGxlZCBTdGF0ZW1lbnRzXG4gICAgICAgIGlmICgoZXhwci50eXBlID09PSBTeW50YXguSWRlbnRpZmllcikgJiYgbWF0Y2goJzonKSkge1xuICAgICAgICAgICAgbGV4KCk7XG5cbiAgICAgICAgICAgIGlmIChPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoc3RhdGUubGFiZWxTZXQsIGV4cHIubmFtZSkpIHtcbiAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKHt9LCBNZXNzYWdlcy5SZWRlY2xhcmF0aW9uLCAnTGFiZWwnLCBleHByLm5hbWUpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBzdGF0ZS5sYWJlbFNldFtleHByLm5hbWVdID0gdHJ1ZTtcbiAgICAgICAgICAgIGxhYmVsZWRCb2R5ID0gcGFyc2VTdGF0ZW1lbnQoKTtcbiAgICAgICAgICAgIGRlbGV0ZSBzdGF0ZS5sYWJlbFNldFtleHByLm5hbWVdO1xuXG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5MYWJlbGVkU3RhdGVtZW50LFxuICAgICAgICAgICAgICAgIGxhYmVsOiBleHByLFxuICAgICAgICAgICAgICAgIGJvZHk6IGxhYmVsZWRCb2R5XG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgY29uc3VtZVNlbWljb2xvbigpO1xuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBTeW50YXguRXhwcmVzc2lvblN0YXRlbWVudCxcbiAgICAgICAgICAgIGV4cHJlc3Npb246IGV4cHJcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyAxMyBGdW5jdGlvbiBEZWZpbml0aW9uXG5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SB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93RXJyb3JUb2xlcmFudChmaXJzdFJlc3RyaWN0ZWQsIE1lc3NhZ2VzLlN0cmljdE9jdGFsTGl0ZXJhbCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAoIWZpcnN0UmVzdHJpY3RlZCAmJiB0b2tlbi5vY3RhbCkge1xuICAgICAgICAgICAgICAgICAgICBmaXJzdFJlc3RyaWN0ZWQgPSB0b2tlbjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBvbGRMYWJlbFNldCA9IHN0YXRlLmxhYmVsU2V0O1xuICAgICAgICBvbGRJbkl0ZXJhdGlvbiA9IHN0YXRlLmluSXRlcmF0aW9uO1xuICAgICAgICBvbGRJblN3aXRjaCA9IHN0YXRlLmluU3dpdGNoO1xuICAgICAgICBvbGRJbkZ1bmN0aW9uQm9keSA9IHN0YXRlLmluRnVuY3Rpb25Cb2R5O1xuXG4gICAgICAgIHN0YXRlLmxhYmVsU2V0ID0ge307XG4gICAgICAgIHN0YXRlLmluSXRlcmF0aW9uID0gZmFsc2U7XG4gICAgICAgIHN0YXRlLmluU3dpdGNoID0gZmFsc2U7XG4gICAgICAgIHN0YXRlLmluRnVuY3Rpb25Cb2R5ID0gdHJ1ZTtcblxuICAgICAgICB3aGlsZSAoaW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgICAgIGlmIChtYXRjaCgnfScpKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzb3VyY2VFbGVtZW50ID0gcGFyc2VTb3VyY2VFbGVtZW50KCk7XG4gICAgICAgICAgICBpZiAodHlwZW9mIHNvdXJjZUVsZW1lbnQgPT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICA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GlzUmVzdHJpY3RlZFdvcmQodG9rZW4udmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgZmlyc3RSZXN0cmljdGVkID0gdG9rZW47XG4gICAgICAgICAgICAgICAgbWVzc2FnZSA9IE1lc3NhZ2VzLlN0cmljdEZ1bmN0aW9uTmFtZTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNTdHJpY3RNb2RlUmVzZXJ2ZWRXb3JkKHRva2VuLnZhbHVlKSkge1xuICAgICAgICAgICAgICAgIGZpcnN0UmVzdHJpY3RlZCA9IHRva2VuO1xuICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSBNZXNzYWdlcy5TdHJpY3RSZXNlcnZlZFdvcmQ7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBleHBlY3QoJygnKTtcblxuICAgICAgICBpZiAoIW1hdGNoKCcpJykpIHtcbiAgICAgICAgICAgIHBhcmFtU2V0ID0ge307XG4gICAgICAgICAgICB3aGlsZSAoaW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgICAgICAgICB0b2tlbiA9IGxvb2thaGVhZCgpO1xuICAgICAgICAgICAgICAgIHBhcmFtID0gcGFyc2VWYXJpYWJsZUlkZW50aWZpZXIoKTtcbiAgICAgICAgICAgICAgICBpZiAoc3RyaWN0KSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpc1Jlc3RyaWN0ZWRXb3JkKHRva2VuLnZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RyaWN0ZWQgPSB0b2tlbjtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSBNZXNzYWdlcy5TdHJpY3RQYXJhbU5hbWU7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbChwYXJhbVNldCwgdG9rZW4udmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHJpY3RlZCA9IHRva2VuO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IE1lc3NhZ2VzLlN0cmljdFBhcmFtRHVwZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIWZpcnN0UmVzdHJpY3RlZCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXNSZXN0cmljdGVkV29yZCh0b2tlbi52YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpcnN0UmVzdHJpY3RlZCA9IHRva2VuO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IE1lc3NhZ2VzLlN0cmljdFBhcmFtTmFtZTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpc1N0cmljdE1vZGVSZXNlcnZlZFdvcmQodG9rZW4udmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBmaXJzdFJlc3RyaWN0ZWQgPSB0b2tlbjtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSBNZXNzYWdlcy5TdHJpY3RSZXNlcnZlZFdvcmQ7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHBhcmFtU2V0LCB0b2tlbi52YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpcnN0UmVzdHJpY3RlZCA9IHRva2VuO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IE1lc3NhZ2VzLlN0cmljdFBhcmFtRHVwZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBwYXJhbXMucHVzaChwYXJhbSk7XG4gICAgICAgICAgICAgICAgcGFyYW1TZXRbcGFyYW0ubmFtZV0gPSB0cnVlO1xuICAgICAgICAgICAgICAgIGlmIChtYXRjaCgnKScpKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBleHBlY3QoJywnKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGV4cGVjdCgnKScpO1xuXG4gICAgICAgIHByZXZpb3VzU3RyaWN0ID0gc3RyaWN0O1xuICAgICAgICBib2R5ID0gcGFyc2VGdW5jdGlvblNvdXJjZUVsZW1lbnRzKCk7XG4gICAgICAgIGlmIChzdHJpY3QgJiYgZmlyc3RSZXN0cmljdGVkKSB7XG4gICAgICAgICAgICB0aHJvd0Vycm9yKGZpcnN0UmVzdHJpY3RlZCwgbWVzc2FnZSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0cmljdCAmJiBzdHJpY3RlZCkge1xuICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHN0cmljdGVkLCBtZXNzYWdlKTtcbiAgICAgICAgfVxuICAgICAgICBzdHJpY3QgPSBwcmV2aW91c1N0cmljdDtcblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkZ1bmN0aW9uRGVjbGFyYXRpb24sXG4gICAgICAgICAgICBpZDogaWQsXG4gICAgICAgICAgICBwYXJhbXM6IHBhcmFtcyxcbiAgICAgICAgICAgIGRlZmF1bHRzOiBbXSxcbiAgICAgICAgICAgIGJvZHk6IGJvZHksXG4gICAgICAgICAgICByZXN0OiBudWxsLFxuICAgICAgICAgICAgZ2VuZXJhdG9yOiBmYWxzZSxcbiAgICAgICAgICAgIGV4cHJlc3Npb246IGZhbHNlXG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2VGdW5jdGlvbkV4cHJlc3Npb24oKSB7XG4gICAgICAgIHZhciB0b2tlbiwgaWQgPSBudWxsLCBzdHJpY3RlZCwgZmlyc3RSZXN0cmljdGVkLCBtZXNzYWdlLCBwYXJhbSwgcGFyYW1zID0gW10sIGJvZHksIHByZXZpb3VzU3RyaWN0LCBwYXJhbVNldDtcblxuICAgICAgICBleHBlY3RLZXl3b3JkKCdmdW5jdGlvbicpO1xuXG4gICAgICAgIGlmICghbWF0Y2goJygnKSkge1xuICAgICAgICAgICAgdG9rZW4gPSBsb29rYWhlYWQoKTtcbiAgICAgICAgICAgIGlkID0gcGFyc2VWYXJpYWJsZUlkZW50aWZpZXIoKTtcbiAgICAgICAgICAgIGlmIChzdHJpY3QpIHtcbiAgICAgICAgICAgICAgICBpZiAoaXNSZXN0cmljdGVkV29yZCh0b2tlbi52YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHRva2VuLCBNZXNzYWdlcy5TdHJpY3RGdW5jdGlvbk5hbWUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKGlzUmVzdHJpY3RlZFdvcmQodG9rZW4udmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIGZpcnN0UmVzdHJpY3RlZCA9IHRva2VuO1xuICAgICAgICAgICAgICAgICAgICBtZXNzYWdlID0gTWVzc2FnZXMuU3RyaWN0RnVuY3Rpb25OYW1lO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNTdHJpY3RNb2RlUmVzZXJ2ZWRXb3JkKHRva2VuLnZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICBmaXJzdFJlc3RyaWN0ZWQgPSB0b2tlbjtcbiAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IE1lc3NhZ2VzLlN0cmljdFJlc2VydmVkV29yZDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBleHBlY3QoJygnKTtcblxuICAgICAgICBpZiAoIW1hdGNoKCcpJykpIHtcbiAgICAgICAgICAgIHBhcmFtU2V0ID0ge307XG4gICAgICAgICAgICB3aGlsZSAoaW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgICAgICAgICB0b2tlbiA9IGxvb2thaGVhZCgpO1xuICAgICAgICAgICAgICAgIHBhcmFtID0gcGFyc2VWYXJpYWJsZUlkZW50aWZpZXIoKTtcbiAgICAgICAgICAgICAgICBpZiAoc3RyaWN0KSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpc1Jlc3RyaWN0ZWRXb3JkKHRva2VuLnZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RyaWN0ZWQgPSB0b2tlbjtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSBNZXNzYWdlcy5TdHJpY3RQYXJhbU5hbWU7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbChwYXJhbVNldCwgdG9rZW4udmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHJpY3RlZCA9IHRva2VuO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IE1lc3NhZ2VzLlN0cmljdFBhcmFtRHVwZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIWZpcnN0UmVzdHJpY3RlZCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXNSZXN0cmljdGVkV29yZCh0b2tlbi52YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpcnN0UmVzdHJpY3RlZCA9IHRva2VuO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IE1lc3NhZ2VzLlN0cmljdFBhcmFtTmFtZTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpc1N0cmljdE1vZGVSZXNlcnZlZFdvcmQodG9rZW4udmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBmaXJzdFJlc3RyaWN0ZWQgPSB0b2tlbjtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSBNZXNzYWdlcy5TdHJpY3RSZXNlcnZlZFdvcmQ7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHBhcmFtU2V0LCB0b2tlbi52YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpcnN0UmVzdHJpY3RlZCA9IHRva2VuO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IE1lc3NhZ2VzLlN0cmljdFBhcmFtRHVwZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBwYXJhbXMucHVzaChwYXJhbSk7XG4gICAgICAgICAgICAgICAgcGFyYW1TZXRbcGFyYW0ubmFtZV0gPSB0cnVlO1xuICAgICAgICAgICAgICAgIGlmIChtYXRjaCgnKScpKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBleHBlY3QoJywnKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGV4cGVjdCgnKScpO1xuXG4gICAgICAgIHByZXZpb3VzU3RyaWN0ID0gc3RyaWN0O1xuICAgICAgICBib2R5ID0gcGFyc2VGdW5jdGlvblNvdXJjZUVsZW1lbnRzKCk7XG4gICAgICAgIGlmIChzdHJpY3QgJiYgZmlyc3RSZXN0cmljdGVkKSB7XG4gICAgICAgICAgICB0aHJvd0Vycm9yKGZpcnN0UmVzdHJpY3RlZCwgbWVzc2FnZSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0cmljdCAmJiBzdHJpY3RlZCkge1xuICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHN0cmljdGVkLCBtZXNzYWdlKTtcbiAgICAgICAgfVxuICAgICAgICBzdHJpY3QgPSBwcmV2aW91c1N0cmljdDtcblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkZ1bmN0aW9uRXhwcmVzc2lvbixcbiAgICAgICAgICAgIGlkOiBpZCxcbiAgICAgICAgICAgIHBhcmFtczogcGFyYW1zLFxuICAgICAgICAgICAgZGVmYXVsdHM6IFtdLFxuICAgICAgICAgICAgYm9keTogYm9keSxcbiAgICAgICAgICAgIHJlc3Q6IG51bGwsXG4gICAgICAgICAgICBnZW5lcmF0b3I6IGZhbHNlLFxuICAgICAgICAgICAgZXhwcmVzc2lvbjogZmFsc2VcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyAxNCBQcm9ncmFtXG5cbiAgICBmdW5jdGlvbiBwYXJzZVNvdXJjZUVsZW1lbnQoKSB7XG4gICAgICAgIHZhciB0b2tlbiA9IGxvb2thaGVhZCgpO1xuXG4gICAgICAgIGlmICh0b2tlbi50eXBlID09PSBUb2tlbi5LZXl3b3JkKSB7XG4gICAgICAgICAgICBzd2l0Y2ggKHRva2VuLnZhbHVlKSB7XG4gICAgICAgICAgICBjYXNlICdjb25zdCc6XG4gICAgICAgICAgICBjYXNlICdsZXQnOlxuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZUNvbnN0TGV0RGVjbGFyYXRpb24odG9rZW4udmFsdWUpO1xuICAgICAgICAgICAgY2FzZSAnZnVuY3Rpb24nOlxuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZUZ1bmN0aW9uRGVjbGFyYXRpb24oKTtcbiAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlU3RhdGVtZW50KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodG9rZW4udHlwZSAhPT0gVG9rZW4uRU9GKSB7XG4gICAgICAgICAgICByZXR1cm4gcGFyc2VTdGF0ZW1lbnQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBhcnNlU291cmNlRWxlbWVudHMoKSB7XG4gICAgICAgIHZhciBzb3VyY2VFbGVtZW50LCBzb3VyY2VFbGVtZW50cyA9IFtdLCB0b2tlbiwgZGlyZWN0aXZlLCBmaXJzdFJlc3RyaWN0ZWQ7XG5cbiAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICB0b2tlbiA9IGxvb2thaGVhZCgpO1xuICAgICAgICAgICAgaWYgKHRva2VuLnR5cGUgIT09IFRva2VuLlN0cmluZ0xpdGVyYWwpIHtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgc291cmNlRWxlbWVudCA9IHBhcnNlU291cmNlRWxlbWVudCgpO1xuICAgICAgICAgICAgc291cmNlRWxlbWVudHMucHVzaChzb3VyY2VFbGVtZW50KTtcbiAgICAgICAgICAgIGlmIChzb3VyY2VFbGVtZW50LmV4cHJlc3Npb24udHlwZSAhPT0gU3ludGF4LkxpdGVyYWwpIHtcbiAgICAgICAgICAgICAgICAvLyB0aGlzIGlzIG5vdCBkaXJlY3RpdmVcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRpcmVjdGl2ZSA9IHNsaWNlU291cmNlKHRva2VuLnJhbmdlWzBdICsgMSwgdG9rZW4ucmFuZ2VbMV0gLSAxKTtcbiAgICAgICAgICAgIGlmIChkaXJlY3RpdmUgPT09ICd1c2Ugc3RyaWN0Jykge1xuICAgICAgICAgICAgICAgIHN0cmljdCA9IHRydWU7XG4gICAgICAgICAgICAgICAgaWYgKGZpcnN0UmVzdHJpY3RlZCkge1xuICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yVG9sZXJhbnQoZmlyc3RSZXN0cmljdGVkLCBNZXNzYWdlcy5TdHJpY3RPY3RhbExpdGVyYWwpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKCFmaXJzdFJlc3RyaWN0ZWQgJiYgdG9rZW4ub2N0YWwpIHtcbiAgICAgICAgICAgICAgICAgICAgZmlyc3RSZXN0cmljdGVkID0gdG9rZW47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICBzb3VyY2VFbGVtZW50ID0gcGFyc2VTb3VyY2VFbGVtZW50KCk7XG4gICAgICAgICAgICBpZiAodHlwZW9mIHNvdXJjZUVsZW1lbnQgPT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzb3VyY2VFbGVtZW50cy5wdXNoKHNvdXJjZUVsZW1lbnQpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBzb3VyY2VFbGVtZW50cztcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwYXJzZVByb2dyYW0oKSB7XG4gICAgICAgIHZhciBwcm9ncmFtO1xuICAgICAgICBzdHJpY3QgPSBmYWxzZTtcbiAgICAgICAgcHJvZ3JhbSA9IHtcbiAgICAgICAgICAgIHR5cGU6IFN5bnRheC5Qcm9ncmFtLFxuICAgICAgICAgICAgYm9keTogcGFyc2VTb3VyY2VFbGVtZW50cygpXG4gICAgICAgIH07XG4gICAgICAgIHJldHVybiBwcm9ncmFtO1xuICAgIH1cblxuICAgIC8vIFRoZSBmb2xsb3dpbmcgZnVuY3Rpb25zIGFyZSBuZWVkZWQgb25seSB3aGVuIHRoZSBvcHRpb24gdG8gcHJlc2VydmVcbiAgICAvLyB0aGUgY29tbWVudHMgaXMgYWN0aXZlLlxuXG4gICAgZnVuY3Rpb24gYWRkQ29tbWVudCh0eXBlLCB2YWx1ZSwgc3RhcnQsIGVuZ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mVDb21tZW50ID0gZmFsc2U7XG5cbiAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG5cbiAgICAgICAgICAgIGlmIChsaW5lQ29tbWVudCkge1xuICAgICAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgICAgIGlmIChpc0xpbmVUZXJtaW5hdG9yKGNoKSkge1xuICAgICAgICAgICAgICAgICAgICBsb2MuZW5kID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGluZTogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbHVtbjogaW5kZXggLSBsaW5lU3RhcnQgLSAxXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIGxpbmVDb21tZW50ID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgIGFkZENvbW1lbnQoJ0xpbmUnLCBjb21tZW50LCBzdGFydCwgaW5kZXggLSAxLCBsb2MpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoY2ggPT09ICdcXHInICYmIHNvdXJjZVtpbmRleF0gPT09ICdcXG4nKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICArK2luZGV4O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICsrbGluZU51bWJlcjtcbiAgICAgICAgICAgICAgICAgICAgbGluZVN0YXJ0ID0gaW5kZXg7XG4gICAgICAgICAgICAgICAgICAgIGNvbW1lbnQgPSAnJztcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGluZGV4ID49IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICBsaW5lQ29tbWVudCA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICBjb21tZW50ICs9IGNoO1xuICAgICAgICAgICAgICAgICAgICBsb2MuZW5kID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGluZTogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbHVtbjogbGVuZ3RoIC0gbGluZVN0YXJ0XG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIGFkZENvbW1lbnQoJ0xpbmUnLCBjb21tZW50LCBzdGFydCwgbGVuZ3RoLCBsb2MpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbW1lbnQgKz0gY2g7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIGlmIChibG9ja0NvbW1lbnQpIHtcbiAgICAgICAgICAgICAgICBpZiAoaXNMaW5lVGVybWluYXRvcihjaCkpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGNoID09PSAnXFxyJyAmJiBzb3VyY2VbaW5kZXggKyAxXSA9PT0gJ1xcbicpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb21tZW50ICs9ICdcXHJcXG4nO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29tbWVudCArPSBjaDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICArK2xpbmVOdW1iZXI7XG4gICAgICAgICAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICAgICAgICAgIGxpbmVTdGFydCA9IGluZGV4O1xuICAgICAgICAgICAgICAgICAgICBpZiAoaW5kZXggPj0gbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKHt9LCBNZXNzYWdlcy5VbmV4cGVjdGVkVG9rZW4sICdJTExFR0FMJyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4ID49IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuVW5leHBlY3RlZFRva2VuLCAnSUxMRUdBTCcpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGNvbW1lbnQgKz0gY2g7XG4gICAgICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gJyonKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2ggPT09ICcvJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1lbnQgPSBjb21tZW50LnN1YnN0cigwLCBjb21tZW50Lmxlbmd0aCAtIDEpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJsb2NrQ29tbWVudCA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9jLmVuZCA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZTogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sdW1uOiBpbmRleCAtIGxpbmVTdGFydFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkQ29tbWVudCgnQmxvY2snLCBjb21tZW50LCBzdGFydCwgaW5kZXgsIGxvYyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWVudCA9ICcnO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIGlmIChjaCA9PT0gJy8nKSB7XG4gICAgICAgICAgICAgICAgY2ggPSBzb3VyY2VbaW5kZXggKyAxXTtcbiAgICAgICAgICAgICAgICBpZiAoY2ggPT09ICcvJykge1xuICAgICAgICAgICAgICAgICAgICBsb2MgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdGFydDoge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmU6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sdW1uOiBpbmRleCAtIGxpbmVTdGFydFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICBzdGFydCA9IGluZGV4O1xuICAgICAgICAgICAgICAgICAgICBpbmRleCArPSAyO1xuICAgICAgICAgICAgICAgICAgICBsaW5lQ29tbWVudCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCA+PSBsZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvYy5lbmQgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZTogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2x1bW46IGluZGV4IC0gbGluZVN0YXJ0XG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgbGluZUNvbW1lbnQgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGFkZENvbW1lbnQoJ0xpbmUnLCBjb21tZW50LCBzdGFydCwgaW5kZXgsIGxvYyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoID09PSAnKicpIHtcbiAgICAgICAgICAgICAgICAgICAgc3RhcnQgPSBpbmRleDtcbiAgICAgICAgICAgICAgICAgICAgaW5kZXggKz0gMjtcbiAgICAgICAgICAgICAgICAgICAgYmxvY2tDb21tZW50ID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgbG9jID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnQ6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5lOiBsaW5lTnVtYmVyLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbHVtbjogaW5kZXggLSBsaW5lU3RhcnQgLSAyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCA+PSBsZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLlVuZXhwZWN0ZWRUb2tlbiwgJ0lMTEVHQUwnKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNXaGl0ZVNwYWNlKGNoKSkge1xuICAgICAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlzTGluZVRlcm1pbmF0b3IoY2gpKSB7XG4gICAgICAgICAgICAgICAgKytpbmRleDtcbiAgICAgICAgICAgICAgICBpZiAoY2ggPT09ICAnXFxyJyAmJiBzb3VyY2VbaW5kZXhdID09PSAnXFxuJykge1xuICAgICAgICAgICAgICAgICAgICArK2luZGV4O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICArK2xpbmVOdW1iZXI7XG4gICAgICAgICAgICAgICAgbGluZVN0YXJ0ID0gaW5kZXg7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gZmlsdGVyQ29tbWVudExvY2F0aW9uKCkge1xuICAgICAgICB2YXIgaSwgZW50cnksIGNvbW1lbnQsIGNvbW1lbnRzID0gW107XG5cbiAgICAgICAgZm9yIChpID0gMDsgaSA8IGV4dHJhLmNvbW1lbnRzLmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICBlbnRyeSA9IGV4dHJhLmNvbW1lbnRzW2ldO1xuICAgICAgICAgICAgY29tbWVudCA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBlbnRyeS50eXBlLFxuICAgICAgICAgICAgICAgIHZhbHVlOiBlbnRyeS52YWx1ZVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGlmIChleHRyYS5yYW5nZSkge1xuICAgICAgICAgICAgICAgIGNvbW1lbnQucmFuZ2UgPSBlbnRyeS5yYW5nZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChleHRyYS5sb2MpIHtcbiAgICAgICAgICAgICAgICBjb21tZW50LmxvYyA9IGVudHJ5LmxvYztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNvbW1lbnRzLnB1c2goY29tbWVudCk7XG4gICAgICAgIH1cblxuICAgICAgICBleHRyYS5jb21tZW50cyA9IGNvbW1lbnRzO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGNvbGxlY3RUb2tlbigpIHtcbiAgICAgICAgdmFyIHN0YXJ0LCBsb2MsIHRva2VuLCByYW5nZSwgdmFsdWU7XG5cbiAgICAgICAgc2tpcENvbW1lbnQoKTtcbiAgICAgICAgc3RhcnQgPSBpbmRleDtcbiAgICAgICAgbG9jID0ge1xuICAgICAgICAgICAgc3RhcnQ6IHtcbiAgICAgICAgICAgICAgICBsaW5lOiBsaW5lTnVtYmVyLFxuICAgICAgICAgICAgICAgIGNvbHVtbjogaW5kZXggLSBsaW5lU3RhcnRcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcblxuICAgICAgICB0b2tlbiA9IGV4dHJhLmFkdmFuY2UoKTtcbiAgICAgICAgbG9jLmVuZCA9IHtcbiAgICAgICAgICAgIGxpbmU6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICBjb2x1bW46IGluZGV4IC0gbGluZVN0YXJ0XG4gICAgICAgIH07XG5cbiAgICAgICAgaWYgKHRva2VuLnR5cGUgIT09IFRva2VuLkVPRikge1xuICAgICAgICAgICAgcmFuZ2UgPSBbdG9rZW4ucmFuZ2VbMF0sIHRva2VuLnJhbmdlWzFdXTtcbiAgICAgICAgICAgIHZhbHVlID0gc2xpY2VTb3VyY2UodG9rZW4ucmFuZ2VbMF0sIHRva2VuLnJhbmdlWzFdKTtcbiAgICAgICAgICAgIGV4dHJhLnRva2Vucy5wdXNoKHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbk5hbWVbdG9rZW4udHlwZV0sXG4gICAgICAgICAgICAgICAgdmFsdWU6IHZhbHVlLFxuICAgICAgICAgICAgICAgIHJhbmdlOiByYW5nZSxcbiAgICAgICAgICAgICAgICBsb2M6IGxvY1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gdG9rZW47XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gY29sbGVjdFJlZ2V4KCkge1xuICAgICAgICB2YXIgcG9zLCBsb2MsIHJlZ2V4LCB0b2tlbjtcblxuICAgICAgICBza2lwQ29tbWVudCgpO1xuXG4gICAgICAgIHBvcyA9IGluZGV4O1xuICAgICAgICBsb2MgPSB7XG4gICAgICAgICAgICBzdGFydDoge1xuICAgICAgICAgICAgICAgIGxpbmU6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgY29sdW1uOiBpbmRleCAtIGxpbmVTdGFydFxuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuXG4gICAgICAgIHJlZ2V4ID0gZXh0cmEuc2NhblJlZ0V4cCgpO1xuICAgICAgICBsb2MuZW5kID0ge1xuICAgICAgICAgICAgbGluZTogbGluZU51bWJlcixcbiAgICAgICAgICAgIGNvbHVtbjogaW5kZXggLSBsaW5lU3RhcnRcbiAgICAgICAgfTtcblxuICAgICAgICAvLyBQb3AgdGhlIHByZXZpb3VzIHRva2VuLCB3aGljaCBpcyBsaWtlbHkgJy8nIG9yICcvPSdcbiAgICAgICAgaWYgKGV4dHJhLnRva2Vucy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICB0b2tlbiA9IGV4dHJhLnRva2Vuc1tleHRyYS50b2tlbnMubGVuZ3RoIC0gMV07XG4gICAgICAgICAgICBpZiAodG9rZW4ucmFuZ2VbMF0gPT09IHBvcyAmJiB0b2tlbi50eXBlID09PSAnUHVuY3R1YXRvcicpIHtcbiAgICAgICAgICAgICAgICBpZiAodG9rZW4udmFsdWUgPT09ICcvJyB8fCB0b2tlbi52YWx1ZSA9PT0gJy89Jykge1xuICAgICAgICAgICAgICAgICAgICBleHRyYS50b2tlbnMucG9wKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZXh0cmEudG9rZW5zLnB1c2goe1xuICAgICAgICAgICAgdHlwZTogJ1JlZ3VsYXJFeHByZXNzaW9uJyxcbiAgICAgICAgICAgIHZhbHVlOiByZWdleC5saXRlcmFsLFxuICAgICAgICAgICAgcmFuZ2U6IFtwb3MsIGluZGV4XSxcbiAgICAgICAgICAgIGxvYzogbG9jXG4gICAgICAgIH0pO1xuXG4gICAgICAgIHJldHVybiByZWdleDtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBmaWx0ZXJUb2tlbkxvY2F0aW9uKCkge1xuICAgICAgICB2YXIgaSwgZW50cnksIHRva2VuLCB0b2tlbnMgPSBbXTtcblxuICAgICAgICBmb3IgKGkgPSAwOyBpIDwgZXh0cmEudG9rZW5zLmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICBlbnRyeSA9IGV4dHJhLnRva2Vuc1tpXTtcbiAgICAgICAgICAgIHRva2VuID0ge1xuICAgICAgICAgICAgICAgIHR5cGU6IGVudHJ5LnR5cGUsXG4gICAgICAgICAgICAgICAgdmFsdWU6IGVudHJ5LnZhbHVlXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKGV4dHJhLnJhbmdlKSB7XG4gICAgICAgICAgICAgICAgdG9rZW4ucmFuZ2UgPSBlbnRyeS5yYW5nZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChleHRyYS5sb2MpIHtcbiAgICAgICAgICAgICAgICB0b2tlbi5sb2MgPSBlbnRyeS5sb2M7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0b2tlbnMucHVzaCh0b2tlbik7XG4gICAgICAgIH1cblxuICAgICAgICBleHRyYS50b2tlbnMgPSB0b2tlbnM7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gY3JlYXRlTGl0ZXJhbCh0b2tlbikge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkxpdGVyYWwsXG4gICAgICAgICAgICB2YWx1ZTogdG9rZW4udmFsdWVcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBjcmVhdGVSYXdMaXRlcmFsKHRva2VuKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBTeW50YXguTGl0ZXJhbCxcbiAgICAgICAgICAgIHZhbHVlOiB0b2tlbi52YWx1ZSxcbiAgICAgICAgICAgIHJhdzogc2xpY2VTb3VyY2UodG9rZW4ucmFuZ2VbMF0sIHRva2VuLnJhbmdlWzFdKVxuICAgICAgICB9O1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGNyZWF0ZUxvY2F0aW9uTWFya2VyKCkge1xuICAgICAgICB2YXIgbWFya2VyID0ge307XG5cbiAgICAgICAgbWFya2VyLnJhbmdlID0gW2luZGV4LCBpbmRleF07XG4gICAgICAgIG1hcmtlci5sb2MgPSB7XG4gICAgICAgICAgICBzdGFydDoge1xuICAgICAgICAgICAgICAgIGxpbmU6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgY29sdW1uOiBpbmRleCAtIGxpbmVTdGFydFxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGVuZDoge1xuICAgICAgICAgICAgICAgIGxpbmU6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgY29sdW1uOiBpbmRleCAtIGxpbmVTdGFydFxuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuXG4gICAgICAgIG1hcmtlci5lbmQgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB0aGlzLnJhbmdlWzFdID0gaW5kZXg7XG4gICAgICAgICAgICB0aGlzLmxvYy5lbmQubGluZSA9IGxpbmVOdW1iZXI7XG4gICAgICAgICAgICB0aGlzLmxvYy5lbmQuY29sdW1uID0gaW5kZXggLSBsaW5lU3RhcnQ7XG4gICAgICAgIH07XG5cbiAgICAgICAgbWFya2VyLmFwcGx5R3JvdXAgPSBmdW5jdGlvbiAobm9kZSkge1xuICAgICAgICAgICAgaWYgKGV4dHJhLnJhbmdlKSB7XG4gICAgICAgICAgICAgICAgbm9kZS5ncm91cFJhbmdlID0gW3RoaXMucmFuZ2VbMF0sIHRoaXMucmFuZ2VbMV1dO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGV4dHJhLmxvYykge1xuICAgICAgICAgICAgICAgIG5vZGUuZ3JvdXBMb2MgPSB7XG4gICAgICAgICAgICAgICAgICAgIHN0YXJ0OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsaW5lOiB0aGlzLmxvYy5zdGFydC5saW5lLFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sdW1uOiB0aGlzLmxvYy5zdGFydC5jb2x1bW5cbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgZW5kOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsaW5lOiB0aGlzLmxvYy5lbmQubGluZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbHVtbjogdGhpcy5sb2MuZW5kLmNvbHVtblxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcblxuICAgICAgICBtYXJrZXIuYXBwbHkgPSBmdW5jdGlvbiAobm9kZSkge1xuICAgICAgICAgICAgaWYgKGV4dHJhLnJhbmdlKSB7XG4gICAgICAgICAgICAgICAgbm9kZS5yYW5nZSA9IFt0aGlzLnJhbmdlWzBdLCB0aGlzLnJhbmdlWzFdXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChleHRyYS5sb2MpIHtcbiAgICAgICAgICAgICAgICBub2RlLmxvYyA9IHtcbiAgICAgICAgICAgICAgICAgICAgc3RhcnQ6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmU6IHRoaXMubG9jLnN0YXJ0LmxpbmUsXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2x1bW46IHRoaXMubG9jLnN0YXJ0LmNvbHVtblxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBlbmQ6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmU6IHRoaXMubG9jLmVuZC5saW5lLFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sdW1uOiB0aGlzLmxvYy5lbmQuY29sdW1uXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuXG4gICAgICAgIHJldHVybiBtYXJrZXI7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gdHJhY2tHcm91cEV4cHJlc3Npb24oKSB7XG4gICAgICAgIHZhciBtYXJrZXIsIGV4cHI7XG5cbiAgICAgICAgc2tpcENvbW1lbnQoKTtcbiAgICAgICAgbWFya2VyID0gY3JlYXRlTG9jYXRpb25NYXJrZXIoKTtcbiAgICAgICAgZXhwZWN0KCcoJyk7XG5cbiAgICAgICAgZXhwciA9IHBhcnNlRXhwcmVzc2lvbigpO1xuXG4gICAgICAgIGV4cGVjdCgnKScpO1xuXG4gICAgICAgIG1hcmtlci5lbmQoKTtcbiAgICAgICAgbWFya2VyLmFwcGx5R3JvdXAoZXhwcik7XG5cbiAgICAgICAgcmV0dXJuIGV4cHI7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gdHJhY2tMZWZ0SGFuZFNpZGVFeHByZXNzaW9uKCkge1xuICAgICAgICB2YXIgbWFya2VyLCBleHByO1xuXG4gICAgICAgIHNraXBDb21tZW50KCk7XG4gICAgICAgIG1hcmtlciA9IGNyZWF0ZUxvY2F0aW9uTWFya2VyKCk7XG5cbiAgICAgICAgZXhwciA9IG1hdGNoS2V5d29yZCgnbmV3JykgPyBwYXJzZU5ld0V4cHJlc3Npb24oKSA6IHBhcnNlUHJpbWFyeUV4cHJlc3Npb24oKTtcblxuICAgICAgICB3aGlsZSAobWF0Y2goJy4nKSB8fCBtYXRjaCgnWycpKSB7XG4gICAgICAgICAgICBpZiAobWF0Y2goJ1snKSkge1xuICAgICAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5NZW1iZXJFeHByZXNzaW9uLFxuICAgICAgICAgICAgICAgICAgICBjb21wdXRlZDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgb2JqZWN0OiBleHByLFxuICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0eTogcGFyc2VDb21wdXRlZE1lbWJlcigpXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBtYXJrZXIuZW5kKCk7XG4gICAgICAgICAgICAgICAgbWFya2VyLmFwcGx5KGV4cHIpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBleHByID0ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguTWVtYmVyRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICAgICAgY29tcHV0ZWQ6IGZhbHNlLFxuICAgICAgICAgICAgICAgICAgICBvYmplY3Q6IGV4cHIsXG4gICAgICAgICAgICAgICAgICAgIHByb3BlcnR5OiBwYXJzZU5vbkNvbXB1dGVkTWVtYmVyKClcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIG1hcmtlci5lbmQoKTtcbiAgICAgICAgICAgICAgICBtYXJrZXIuYXBwbHkoZXhwcik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiB0cmFja0xlZnRIYW5kU2lkZUV4cHJlc3Npb25BbGxvd0NhbGwoKSB7XG4gICAgICAgIHZhciBtYXJrZXIsIGV4cHI7XG5cbiAgICAgICAgc2tpcENvbW1lbnQoKTtcbiAgICAgICAgbWFya2VyID0gY3JlYXRlTG9jYXRpb25NYXJrZXIoKTtcblxuICAgICAgICBleHByID0gbWF0Y2hLZXl3b3JkKCduZXcnKSA/IHBhcnNlTmV3RXhwcmVzc2lvbigpIDogcGFyc2VQcmltYXJ5RXhwcmVzc2lvbigpO1xuXG4gICAgICAgIHdoaWxlIChtYXRjaCgnLicpIHx8IG1hdGNoKCdbJykgfHwgbWF0Y2goJygnKSkge1xuICAgICAgICAgICAgaWYgKG1hdGNoKCcoJykpIHtcbiAgICAgICAgICAgICAgICBleHByID0ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguQ2FsbEV4cHJlc3Npb24sXG4gICAgICAgICAgICAgICAgICAgIGNhbGxlZTogZXhwcixcbiAgICAgICAgICAgICAgICAgICAgJ2FyZ3VtZW50cyc6IHBhcnNlQXJndW1lbnRzKClcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIG1hcmtlci5lbmQoKTtcbiAgICAgICAgICAgICAgICBtYXJrZXIuYXBwbHkoZXhwcik7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1hdGNoKCdbJykpIHtcbiAgICAgICAgICAgICAgICBleHByID0ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguTWVtYmVyRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICAgICAgY29tcHV0ZWQ6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIG9iamVjdDogZXhwcixcbiAgICAgICAgICAgICAgICAgICAgcHJvcGVydHk6IHBhcnNlQ29tcHV0ZWRNZW1iZXIoKVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgbWFya2VyLmVuZCgpO1xuICAgICAgICAgICAgICAgIG1hcmtlci5hcHBseShleHByKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogU3ludGF4Lk1lbWJlckV4cHJlc3Npb24sXG4gICAgICAgICAgICAgICAgICAgIGNvbXB1dGVkOiBmYWxzZSxcbiAgICAgICAgICAgICAgICAgICAgb2JqZWN0OiBleHByLFxuICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0eTogcGFyc2VOb25Db21wdXRlZE1lbWJlcigpXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBtYXJrZXIuZW5kKCk7XG4gICAgICAgICAgICAgICAgbWFya2VyLmFwcGx5KGV4cHIpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGV4cHI7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gZmlsdGVyR3JvdXAobm9kZSkge1xuICAgICAgICB2YXIgbiwgaSwgZW50cnk7XG5cbiAgICAgICAgbiA9IChPYmplY3QucHJvdG90eXBlLnRvU3RyaW5nLmFwcGx5KG5vZGUpID09PSAnW29iamVjdCBBcnJheV0nKSA/IFtdIDoge307XG4gICAgICAgIGZvciAoaSBpbiBub2RlKSB7XG4gICAgICAgICAgICBpZiAobm9kZS5oYXNPd25Qcm9wZXJ0eShpKSAmJiBpICE9PSAnZ3JvdXBSYW5nZScgJiYgaSAhPT0gJ2dyb3VwTG9jJykge1xuICAgICAgICAgICAgICAgIGVudHJ5ID0gbm9kZVtpXTtcbiAgICAgICAgICAgICAgICBpZiAoZW50cnkgPT09IG51bGwgfHwgdHlwZW9mIGVudHJ5ICE9PSAnb2JqZWN0JyB8fCBlbnRyeSBpbnN0YW5jZW9mIFJlZ0V4cCkge1xuICAgICAgICAgICAgICAgICAgICBuW2ldID0gZW50cnk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgbltpXSA9IGZpbHRlckdyb3VwKGVudHJ5KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIG47XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gd3JhcFRyYWNraW5nRnVuY3Rpb24ocmFuZ2UsIGxvYykge1xuXG4gICAgICAgIHJldHVybiBmdW5jdGlvbiAocGFyc2VGdW5jdGlvbikge1xuXG4gICAgICAgICAgICBmdW5jdGlvbiBpc0JpbmFyeShub2RlKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIG5vZGUudHlwZSA9PT0gU3ludGF4LkxvZ2ljYWxFeHByZXNzaW9uIHx8XG4gICAgICAgICAgICAgICAgICAgIG5vZGUudHlwZSA9PT0gU3ludGF4LkJpbmFyeUV4cHJlc3Npb247XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGZ1bmN0aW9uIHZpc2l0KG5vZGUpIHtcbiAgICAgICAgICAgICAgICB2YXIgc3RhcnQsIGVuZDtcblxuICAgICAgICAgICAgICAgIGlmIChpc0JpbmFyeShub2RlLmxlZnQpKSB7XG4gICAgICAgICAgICAgICAgICAgIHZpc2l0KG5vZGUubGVmdCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChpc0JpbmFyeShub2RlLnJpZ2h0KSkge1xuICAgICAgICAgICAgICAgICAgICB2aXNpdChub2RlLnJpZ2h0KTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAocmFuZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKG5vZGUubGVmdC5ncm91cFJhbmdlIHx8IG5vZGUucmlnaHQuZ3JvdXBSYW5nZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnQgPSBub2RlLmxlZnQuZ3JvdXBSYW5nZSA/IG5vZGUubGVmdC5ncm91cFJhbmdlWzBdIDogbm9kZS5sZWZ0LnJhbmdlWzBdO1xuICAgICAgICAgICAgICAgICAgICAgICAgZW5kID0gbm9kZS5yaWdodC5ncm91cFJhbmdlID8gbm9kZS5yaWdodC5ncm91cFJhbmdlWzFdIDogbm9kZS5yaWdodC5yYW5nZVsxXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUucmFuZ2UgPSBbc3RhcnQsIGVuZF07XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIG5vZGUucmFuZ2UgPT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdGFydCA9IG5vZGUubGVmdC5yYW5nZVswXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGVuZCA9IG5vZGUucmlnaHQucmFuZ2VbMV07XG4gICAgICAgICAgICAgICAgICAgICAgICBub2RlLnJhbmdlID0gW3N0YXJ0LCBlbmRdO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChsb2MpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKG5vZGUubGVmdC5ncm91cExvYyB8fCBub2RlLnJpZ2h0Lmdyb3VwTG9jKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdGFydCA9IG5vZGUubGVmdC5ncm91cExvYyA/IG5vZGUubGVmdC5ncm91cExvYy5zdGFydCA6IG5vZGUubGVmdC5sb2Muc3RhcnQ7XG4gICAgICAgICAgICAgICAgICAgICAgICBlbmQgPSBub2RlLnJpZ2h0Lmdyb3VwTG9jID8gbm9kZS5yaWdodC5ncm91cExvYy5lbmQgOiBub2RlLnJpZ2h0LmxvYy5lbmQ7XG4gICAgICAgICAgICAgICAgICAgICAgICBub2RlLmxvYyA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFydDogc3RhcnQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kOiBlbmRcbiAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIG5vZGUubG9jID09PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5sb2MgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnQ6IG5vZGUubGVmdC5sb2Muc3RhcnQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kOiBub2RlLnJpZ2h0LmxvYy5lbmRcbiAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgdmFyIG1hcmtlciwgbm9kZTtcblxuICAgICAgICAgICAgICAgIHNraXBDb21tZW50KCk7XG5cbiAgICAgICAgICAgICAgICBtYXJrZXIgPSBjcmVhdGVMb2NhdGlvbk1hcmtlcigpO1xuICAgICAgICAgICAgICAgIG5vZGUgPSBwYXJzZUZ1bmN0aW9uLmFwcGx5KG51bGwsIGFyZ3VtZW50cyk7XG4gICAgICAgICAgICAgICAgbWFya2VyLmVuZCgpO1xuXG4gICAgICAgICAgICAgICAgaWYgKHJhbmdlICYmIHR5cGVvZiBub2RlLnJhbmdlID09PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgICAgICBtYXJrZXIuYXBwbHkobm9kZSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKGxvYyAmJiB0eXBlb2Ygbm9kZS5sb2MgPT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgICAgIG1hcmtlci5hcHBseShub2RlKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoaXNCaW5hcnkobm9kZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgdmlzaXQobm9kZSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgcmV0dXJuIG5vZGU7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9O1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBhdGNoKCkge1xuXG4gICAgICAgIHZhciB3cmFwVHJhY2tpbmc7XG5cbiAgICAgICAgaWYgKGV4dHJhLmNvbW1lbnRzKSB7XG4gICAgICAgICAgICBleHRyYS5za2lwQ29tbWVudCA9IHNraXBDb21tZW50O1xuICAgICAgICAgICAgc2tpcENvbW1lbnQgPSBzY2FuQ29tbWVudDtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChleHRyYS5yYXcpIHtcbiAgICAgICAgICAgIGV4dHJhLmNyZWF0ZUxpdGVyYWwgPSBjcmVhdGVMaXRlcmFsO1xuICAgICAgICAgICAgY3JlYXRlTGl0ZXJhbCA9IGNyZWF0ZVJhd0xpdGVyYWw7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoZXh0cmEucmFuZ2UgfHwgZXh0cmEubG9jKSB7XG5cbiAgICAgICAgICAgIGV4dHJhLnBhcnNlR3JvdXBFeHByZXNzaW9uID0gcGFyc2VHcm91cEV4cHJlc3Npb247XG4gICAgICAgICAgICBleHRyYS5wYXJzZUxlZnRIYW5kU2lkZUV4cHJlc3Npb24gPSBwYXJzZUxlZnRIYW5kU2lkZUV4cHJlc3Npb247XG4gICAgICAgICAgICBleHRyYS5wYXJzZUxlZnRIYW5kU2lkZUV4cHJlc3Npb25BbGxvd0NhbGwgPSBwYXJzZUxlZnRIYW5kU2lkZUV4cHJlc3Npb25BbGxvd0NhbGw7XG4gICAgICAgICAgICBwYXJ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lID0gY29kZTtcbiAgICAgICAgaW5kZXggPSAwO1xuICAgICAgICBsaW5lTnVtYmVyID0gKHNvdXJjZS5sZW5ndGggPiAwKSA/IDEgOiAwO1xuICAgICAgICBsaW5lU3RhcnQgPSAwO1xuICAgICAgICBsZW5ndGggPSBzb3VyY2UubGVuZ3RoO1xuICAgICAgICBidWZmZXIgPSBudWxsO1xuICAgICAgICBzdGF0ZSA9IHtcbiAgICAgICAgICAgIGFsbG93SW46IHRydWUsXG4gICAgICAgICAgICBsYWJlbFNldDoge30sXG4gICAgICAgICAgICBpbkZ1bmN0aW9uQm9keTogZmFsc2UsXG4gICAgICAgICAgICBpbkl0ZXJhdGlvbjogZmFsc2UsXG4gICAgICAgICAgICBpblN3aXRjaDogZmFsc2VcbiAgICAgICAgfTtcblxuICAgICAgICBleHRyYSA9IHt9O1xuICAgICAgICBpZiAodHlwZW9mIG9wdGlvbnMgIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICBleHRyYS5yYW5nZSA9ICh0eXBlb2Ygb3B0aW9ucy5yYW5nZSA9PT0gJ2Jvb2xlYW4nKSAmJiBvcHRpb25zLnJhbmdlO1xuICAgICAgICAgICAgZXh0cmEubG9jID0gKHR5cGVvZiBvcHRpb25zLmxvYyA9PT0gJ2Jvb2xlYW4nKSAmJiBvcHRpb25zLmxvYztcbiAgICAgICAgICAgIGV4dHJhLnJhdyA9ICh0eXBlb2Ygb3B0aW9ucy5yYXcgPT09ICdib29sZWFuJykgJiYgb3B0aW9ucy5yYXc7XG4gICAgICAgICAgICBpZiAodHlwZW9mIG9wdGlvbnMudG9rZW5zID09PSAnYm9vbGVhbicgJiYgb3B0aW9ucy50b2tlbnMpIHtcbiAgICAgICAgICAgICAgICBleHRyYS50b2tlbnMgPSBbXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0eXBlb2Ygb3B0aW9ucy5jb21tZW50ID09PSAnYm9vbGVhbicgJiYgb3B0aW9ucy5jb21tZW50KSB7XG4gICAgICAgICAgICAgICAgZXh0cmEuY29tbWVudHMgPSBbXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0eXBlb2Ygb3B0aW9ucy50b2xlcmFudCA9PT0gJ2Jvb2xlYW4nICYmIG9wdGlvbnMudG9sZXJhbnQpIHtcbiAgICAgICAgICAgICAgICBleHRyYS5lcnJvcnMgPSBbXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChsZW5ndGggPiAwKSB7XG4gICAgICAgICAgICBpZiAodHlwZW9mIHNvdXJjZVswXSA9PT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICAvLyBUcnkgZmlyc3QgdG8gY29udmVydCB0byBhIHN0cmluZy4gVGhpcyBpcyBnb29kIGFzIGZhc3QgcGF0aFxuICAgICAgICAgICAgICAgIC8vIGZvciBvbGQgSUUgd2hpY2ggdW5kZXJzdGFuZHMgc3RyaW5nIGluZGV4aW5nIGZvciBzdHJpbmdcbiAgICAgICAgICAgICAgICAvLyBsaXRlcmFscyBvbmx5IGFuZCBub3QgZm9yIHN0cmluZyBvYmplY3QuXG4gICAgICAgICAgICAgICAgaWYgKGNvZGUgaW5zdGFuY2VvZiBTdHJpbmcpIHtcbiAgICAgICAgICAgICAgICAgICAgc291cmNlID0gY29kZS52YWx1ZU9mKCk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgLy8gRm9yY2UgYWNjZXNzaW5nIHRoZSBjaGFyYWN0ZXJzIHZpYSBhbiBhcnJheS5cbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHNvdXJjZVswXSA9PT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICAgICAgc291cmNlID0gc3RyaW5nVG9BcnJheShjb2RlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBwYXRjaCgpO1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgcHJvZ3JhbSA9IHBhcnNlUHJvZ3JhbSgpO1xuICAgICAgICAgICAgaWYgKHR5cGVvZiBleHRyYS5jb21tZW50cyAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICBmaWx0ZXJDb21tZW50TG9jYXRpb24oKTtcbiAgICAgICAgICAgICAgICBwcm9ncmFtLmNvbW1lbnRzID0gZXh0cmEuY29tbWVudHM7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodHlwZW9mIGV4dHJhLnRva2VucyAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICBmaWx0ZXJUb2tlbkxvY2F0aW9uKCk7XG4gICAgICAgICAgICAgICAgcHJvZ3JhbS50b2tlbnMgPSBleHRyYS50b2tlbnM7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodHlwZW9mIGV4dHJhLmVycm9ycyAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICBwcm9ncmFtLmVycm9ycyA9IGV4dHJhLmVycm9ycztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChleHRyYS5yYW5nZSB8fCBleHRyYS5sb2MpIHtcbiAgICAgICAgICAgICAgICBwcm9ncmFtLmJvZHkgPSBmaWx0ZXJHcm91cChwcm9ncmFtLmJvZHkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICB0aHJvdyBlO1xuICAgICAgICB9IGZpbmFsbHkge1xuICAgICAgICAgICAgdW5wYXRjaCgpO1xuICAgICAgICAgICAgZXh0cmEgPSB7fTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBwcm9ncmFtO1xuICAgIH1cblxuICAgIC8vIFN5bmMgd2l0aCBwYWNrYWdlLmpzb24uXG4gICAgZXhwb3J0cy52ZXJzaW9uID0gJzEuMC40JztcblxuICAgIGV4cG9ydHMucGFyc2UgPSBwYXJzZTtcblxuICAgIC8vIERlZXAgY29weS5cbiAgICBleHBvcnRzLlN5bnRheCA9IChmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBuYW1lLCB0eXBlcyA9IHt9O1xuXG4gICAgICAgIGlmICh0eXBlb2YgT2JqZWN0LmNyZWF0ZSA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICAgICAgdHlwZXMgPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuICAgICAgICB9XG5cbiAgICAgICAgZm9yIChuYW1lIGluIFN5bnRheCkge1xuICAgICAgICAgICAgaWYgKFN5bnRheC5oYXNPd25Qcm9wZXJ0eShuYW1lKSkge1xuICAgICAgICAgICAgICAgIHR5cGVzW25hbWVdID0gU3ludGF4W25hbWVdO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHR5cGVvZiBPYmplY3QuZnJlZXplID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgICAgICBPYmplY3QuZnJlZXplKHR5cGVzKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB0eXBlcztcbiAgICB9KCkpO1xuXG59KSk7XG4vKiB2aW06IHNldCBzdz00IHRzPTQgZXQgdHc9ODAgOiAqL1xuXG59KSgpIiwiXCJ1c2Ugc3RyaWN0XCJcblxuZnVuY3Rpb24gdW5pcXVlX3ByZWQobGlzdCwgY29tcGFyZSkge1xuICB2YXIgcHRyID0gMVxuICAgICwgbGVuID0gbGlzdC5sZW5ndGhcbiAgICAsIGE9bGlzdFswXSwgYj1saXN0WzBdXG4gIGZvcih2YXIgaT0xOyBpPGxlbjsgKytpKSB7XG4gICAgYiA9IGFcbiAgICBhID0gbGlzdFtpXVxuICAgIGlmKGNvbXBhcmUoYSwgYikpIHtcbiAgICAgIGlmKGkgPT09IHB0cikge1xuICAgICAgICBwdHIrK1xuICAgICAgICBjb250aW51ZVxuICAgICAgfVxuICAgICAgbGlzdFtwdHIrK10gPSBhXG4gICAgfVxuICB9XG4gIG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lkID09PSAnZWxzZScpIHx8IChpZCA9PT0gJ2Nhc2UnKSB8fCAoaWQgPT09ICd2b2lkJykgfHwgKGlkID09PSAnd2l0aCcpO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgIGNhc2UgNTpcbiAgICAgICAgICAgIGtleXdvcmQgPSAoaWQgPT09ICd3aGlsZScpIHx8IChpZCA9PT0gJ2JyZWFrJykgfHwgKGlkID09PSAnY2F0Y2gnKSB8fCAoaWQgPT09ICd0aHJvdycpO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgIGNhc2UgNjpcbiAgICAgICAgICAgIGtleXdvcmQgPSAoaWQgPT09ICdyZXR1cm4nKSB8fCAoaWQgPT09ICd0eXBlb2YnKSB8fCAoaWQgPT09ICdkZWxldGUnKSB8fCAoaWQgPT09ICdzd2l0Y2gnKTtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICBjYXNlIDc6XG4gICAgICAgICAgICBrZXl3b3JkID0gKGlkID09PSAnZGVmYXVsdCcpIHx8IChpZCA9PT0gJ2ZpbmFsbHknKTtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICBjYXNlIDg6XG4gICAgICAgICAgICBrZXl3b3JkID0gKGlkID09PSAnZnVuY3Rpb24nKSB8fCAoaWQgPT09ICdjb250aW51ZScpIHx8IChpZCA9PT0gJ2RlYnVnZ2VyJyk7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgY2FzZSAxMDpcbiAgICAgICAgICAgIGtleXdvcmQgPSAoaWQgPT09ICdpbnN0YW5jZW9mJyk7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChrZXl3b3JkKSB7XG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgfVxuXG4gICAgICAgIHN3aXRjaCAoaWQpIHtcbiAgICAgICAgLy8gRnV0dXJlIHJlc2VydmVkIHdvcmRzLlxuICAgICAgICAvLyAnY29uc3QnIGlzIHNwZWNpYWxpemVkIGFzIEtleXdvcmQgaW4gVjguXG4gICAgICAgIGNhc2UgJ2NvbnN0JzpcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xuXG4gICAgICAgIC8vIEZvciBjb21wYXRpYmxpdHkgdG8gU3BpZGVyTW9ua2V5IGFuZCBFUy5uZXh0XG4gICAgICAgIGNhc2UgJ3lpZWxkJzpcbiAgICAgICAgY2FzZSAnbGV0JzpcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHN0cmljdCAmJiBpc1N0cmljdE1vZGVSZXNlcnZlZFdvcmQoaWQpKSB7XG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBpc0Z1dHVyZVJlc2VydmVkV29yZChpZCk7XG4gICAgfVxuXG4gICAgLy8gNy40IENvbW1lbnRzXG5cbiAgICBmdW5jdGlvbiBza2lwQ29tbWVudCgpIHtcbiAgICAgICAgdmFyIGNoLCBibG9ja0NvbW1lbnQsIGxpbmVDb21tZW50O1xuXG4gICAgICAgIGJsb2NrQ29tbWVudCA9IGZhbHNlO1xuICAgICAgICBsaW5lQ29tbWVudCA9IGZhbHNlO1xuXG4gICAgICAgIHdoaWxlIChpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICAgICAgY2ggPSBzb3VyY2VbaW5kZXhdO1xuXG4gICAgICAgICAgICBpZiAobGluZUNvbW1lbnQpIHtcbiAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgICAgICBpZiAoaXNMaW5lVGVybWluYXRvcihjaCkpIHtcbiAgICAgICAgICAgICAgICAgICAgbGluZUNvbW1lbnQgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGNoID09PSAnXFxyJyAmJiBzb3VyY2VbaW5kZXhdID09PSAnXFxuJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgKytpbmRleDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICArK2xpbmVOdW1iZXI7XG4gICAgICAgICAgICAgICAgICAgIGxpbmVTdGFydCA9IGluZGV4O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAoYmxvY2tDb21tZW50KSB7XG4gICAgICAgICAgICAgICAgaWYgKGlzTGluZVRlcm1pbmF0b3IoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gJ1xccicgJiYgc291cmNlW2luZGV4ICsgMV0gPT09ICdcXG4nKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICArK2luZGV4O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICsrbGluZU51bWJlcjtcbiAgICAgICAgICAgICAgICAgICAgKytpbmRleDtcbiAgICAgICAgICAgICAgICAgICAgbGluZVN0YXJ0ID0gaW5kZXg7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCA+PSBsZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLlVuZXhwZWN0ZWRUb2tlbiwgJ0lMTEVHQUwnKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaW5kZXggPj0gbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKHt9LCBNZXNzYWdlcy5VbmV4cGVjdGVkVG9rZW4sICdJTExFR0FMJyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKGNoID09PSAnKicpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4XTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gJy8nKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgKytpbmRleDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBibG9ja0NvbW1lbnQgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAoY2ggPT09ICcvJykge1xuICAgICAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4ICsgMV07XG4gICAgICAgICAgICAgICAgaWYgKGNoID09PSAnLycpIHtcbiAgICAgICAgICAgICAgICAgICAgaW5kZXggKz0gMjtcbiAgICAgICAgICAgICAgICAgICAgbGluZUNvbW1lbnQgPSB0cnVlO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2ggPT09ICcqJykge1xuICAgICAgICAgICAgICAgICAgICBpbmRleCArPSAyO1xuICAgICAgICAgICAgICAgICAgICBibG9ja0NvbW1lbnQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaW5kZXggPj0gbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKHt9LCBNZXNzYWdlcy5VbmV4cGVjdGVkVG9rZW4sICdJTExFR0FMJyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlzV2hpdGVTcGFjZShjaCkpIHtcbiAgICAgICAgICAgICAgICArK2luZGV4O1xuICAgICAgICAgICAgfSBlbHNlIGlmIChpc0xpbmVUZXJtaW5hdG9yKGNoKSkge1xuICAgICAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICAgICAgaWYgKGNoID09PSAgJ1xccicgJiYgc291cmNlW2luZGV4XSA9PT0gJ1xcbicpIHtcbiAgICAgICAgICAgICAgICAgICAgKytpbmRleDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgKytsaW5lTnVtYmVyO1xuICAgICAgICAgICAgICAgIGxpbmVTdGFydCA9IGluZGV4O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGZ1bmN0aW9uIHNjYW5IZXhFc2NhcGUocHJlZml4KSB7XG4gICAgICAgIHZhciBpLCBsZW4sIGNoLCBjb2RlID0gMDtcblxuICAgICAgICBsZW4gPSAocHJlZml4ID09PSAndScpID8gNCA6IDI7XG4gICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47ICsraSkge1xuICAgICAgICAgICAgaWYgKGluZGV4IDwgbGVuZ3RoICYmIGlzSGV4RGlnaXQoc291cmNlW2luZGV4XSkpIHtcbiAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgICAgICBjb2RlID0gY29kZSAqIDE2ICsgJzAxMjM0NTY3ODlhYmNkZWYnLmluZGV4T2YoY2gudG9Mb3dlckNhc2UoKSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybiAnJztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gU3RyaW5nLmZyb21DaGFyQ29kZShjb2RlKTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBzY2FuSWRlbnRpZmllcigpIHtcbiAgICAgICAgdmFyIGNoLCBzdGFydCwgaWQsIHJlc3RvcmU7XG5cbiAgICAgICAgY2ggPSBzb3VyY2VbaW5kZXhdO1xuICAgICAgICBpZiAoIWlzSWRlbnRpZmllclN0YXJ0KGNoKSkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgc3RhcnQgPSBpbmRleDtcbiAgICAgICAgaWYgKGNoID09PSAnXFxcXCcpIHtcbiAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICBpZiAoc291cmNlW2luZGV4XSAhPT0gJ3UnKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgKytpbmRleDtcbiAgICAgICAgICAgIHJlc3RvcmUgPSBpbmRleDtcbiAgICAgICAgICAgIGNoID0gc2NhbkhleEVzY2FwZSgndScpO1xuICAgICAgICAgICAgaWYgKGNoKSB7XG4gICAgICAgICAgICAgICAgaWYgKGNoID09PSAnXFxcXCcgfHwgIWlzSWRlbnRpZmllclN0YXJ0KGNoKSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlkID0gY2g7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGluZGV4ID0gcmVzdG9yZTtcbiAgICAgICAgICAgICAgICBpZCA9ICd1JztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlkID0gc291cmNlW2luZGV4KytdO1xuICAgICAgICB9XG5cbiAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG4gICAgICAgICAgICBpZiAoIWlzSWRlbnRpZmllclBhcnQoY2gpKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoY2ggPT09ICdcXFxcJykge1xuICAgICAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICAgICAgaWYgKHNvdXJjZVtpbmRleF0gIT09ICd1Jykge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICAgICAgcmVzdG9yZSA9IGluZGV4O1xuICAgICAgICAgICAgICAgIGNoID0gc2NhbkhleEVzY2FwZSgndScpO1xuICAgICAgICAgICAgICAgIGlmIChjaCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoY2ggPT09ICdcXFxcJyB8fCAhaXNJZGVudGlmaWVyUGFydChjaCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBpZCArPSBjaDtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBpbmRleCA9IHJlc3RvcmU7XG4gICAgICAgICAgICAgICAgICAgIGlkICs9ICd1JztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlkICs9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8vIFRoZXJlIGlzIG5vIGtleXdvcmQgb3IgbGl0ZXJhbCB3aXRoIG9ubHkgb25lIGNoYXJhY3Rlci5cbiAgICAgICAgLy8gVGh1cywgaXQgbXVzdCBiZSBhbiBpZGVudGlmaWVyLlxuICAgICAgICBpZiAoaWQubGVuZ3RoID09PSAxKSB7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFRva2VuLklkZW50aWZpZXIsXG4gICAgICAgICAgICAgICAgdmFsdWU6IGlkLFxuICAgICAgICAgICAgICAgIGxpbmVOdW1iZXI6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgbGluZVN0YXJ0OiBsaW5lU3RhcnQsXG4gICAgICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGlzS2V5d29yZChpZCkpIHtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogVG9rZW4uS2V5d29yZCxcbiAgICAgICAgICAgICAgICB2YWx1ZTogaWQsXG4gICAgICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICByYW5nZTogW3N0YXJ0LCBpbmRleF1cbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICAvLyA3LjguMSBOdWxsIExpdGVyYWxzXG5cbiAgICAgICAgaWYgKGlkID09PSAnbnVsbCcpIHtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogVG9rZW4uTnVsbExpdGVyYWwsXG4gICAgICAgICAgICAgICAgdmFsdWU6IGlkLFxuICAgICAgICAgICAgICAgIGxpbmVOdW1iZXI6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgbGluZVN0YXJ0OiBsaW5lU3RhcnQsXG4gICAgICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gNy44LjIgQm9vbGVhbiBMaXRlcmFsc1xuXG4gICAgICAgIGlmIChpZCA9PT0gJ3RydWUnIHx8IGlkID09PSAnZmFsc2UnKSB7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFRva2VuLkJvb2xlYW5MaXRlcmFsLFxuICAgICAgICAgICAgICAgIHZhbHVlOiBpZCxcbiAgICAgICAgICAgICAgICBsaW5lTnVtYmVyOiBsaW5lTnVtYmVyLFxuICAgICAgICAgICAgICAgIGxpbmVTdGFydDogbGluZVN0YXJ0LFxuICAgICAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGluZGV4XVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBUb2tlbi5JZGVudGlmaWVyLFxuICAgICAgICAgICAgdmFsdWU6IGlkLFxuICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgIGxpbmVTdGFydDogbGluZVN0YXJ0LFxuICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgLy8gNy43IFB1bmN0dWF0b3JzXG5cbiAgICBmdW5jdGlvbiBzY2FuUHVuY3R1YXRvcigpIHtcbiAgICAgICAgdmFyIHN0YXJ0ID0gaW5kZXgsXG4gICAgICAgICAgICBjaDEgPSBzb3VyY2VbaW5kZXhdLFxuICAgICAgICAgICAgY2gyLFxuICAgICAgICAgICAgY2gzLFxuICAgICAgICAgICAgY2g0O1xuXG4gICAgICAgIC8vIENoZWNrIGZvciBtb3N0IGNvbW1vbiBzaW5nbGUtY2hhcmFjdGVyIHB1bmN0dWF0b3JzLlxuXG4gICAgICAgIGlmIChjaDEgPT09ICc7JyB8fCBjaDEgPT09ICd7JyB8fCBjaDEgPT09ICd9Jykge1xuICAgICAgICAgICAgKytpbmRleDtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogVG9rZW4uUHVuY3R1YXRvcixcbiAgICAgICAgICAgICAgICB2YWx1ZTogY2gxLFxuICAgICAgICAgICAgICAgIGxpbmVOdW1iZXI6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgbGluZVN0YXJ0OiBsaW5lU3RhcnQsXG4gICAgICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGNoMSA9PT0gJywnIHx8IGNoMSA9PT0gJygnIHx8IGNoMSA9PT0gJyknKSB7XG4gICAgICAgICAgICArK2luZGV4O1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5QdW5jdHVhdG9yLFxuICAgICAgICAgICAgICAgIHZhbHVlOiBjaDEsXG4gICAgICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICByYW5nZTogW3N0YXJ0LCBpbmRleF1cbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICAvLyBEb3QgKC4pIGNhbiBhbHNvIHN0YXJ0IGEgZmxvYXRpbmctcG9pbnQgbnVtYmVyLCBoZW5jZSB0aGUgbmVlZFxuICAgICAgICAvLyB0byBjaGVjayB0aGUgbmV4dCBjaGFyYWN0ZXIuXG5cbiAgICAgICAgY2gyID0gc291cmNlW2luZGV4ICsgMV07XG4gICAgICAgIGlmIChjaDEgPT09ICcuJyAmJiAhaXNEZWNpbWFsRGlnaXQoY2gyKSkge1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5QdW5jdHVhdG9yLFxuICAgICAgICAgICAgICAgIHZhbHVlOiBzb3VyY2VbaW5kZXgrK10sXG4gICAgICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICByYW5nZTogW3N0YXJ0LCBpbmRleF1cbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICAvLyBQZWVrIG1vcmUgY2hhcmFjdGVycy5cblxuICAgICAgICBjaDMgPSBzb3VyY2VbaW5kZXggKyAyXTtcbiAgICAgICAgY2g0ID0gc291cmNlW2luZGV4ICsgM107XG5cbiAgICAgICAgLy8gNC1jaGFyYWN0ZXIgcHVuY3R1YXRvcjogPj4+PVxuXG4gICAgICAgIGlmIChjaDEgPT09ICc+JyAmJiBjaDIgPT09ICc+JyAmJiBjaDMgPT09ICc+Jykge1xuICAgICAgICAgICAgaWYgKGNoNCA9PT0gJz0nKSB7XG4gICAgICAgICAgICAgICAgaW5kZXggKz0gNDtcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5QdW5jdHVhdG9yLFxuICAgICAgICAgICAgICAgICAgICB2YWx1ZTogJz4+Pj0nLFxuICAgICAgICAgICAgICAgICAgICBsaW5lTnVtYmVyOiBsaW5lTnVtYmVyLFxuICAgICAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8vIDMtY2hhcmFjdGVyIHB1bmN0dWF0b3JzOiA9PT0gIT09ID4+PiA8PD0gPj49XG5cbiAgICAgICAgaWYgKGNoMSA9PT0gJz0nICYmIGNoMiA9PT0gJz0nICYmIGNoMyA9PT0gJz0nKSB7XG4gICAgICAgICAgICBpbmRleCArPSAzO1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5QdW5jdHVhdG9yLFxuICAgICAgICAgICAgICAgIHZhbHVlOiAnPT09JyxcbiAgICAgICAgICAgICAgICBsaW5lTnVtYmVyOiBsaW5lTnVtYmVyLFxuICAgICAgICAgICAgICAgIGxpbmVTdGFydDogbGluZVN0YXJ0LFxuICAgICAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGluZGV4XVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChjaDEgPT09ICchJyAmJiBjaDIgPT09ICc9JyAmJiBjaDMgPT09ICc9Jykge1xuICAgICAgICAgICAgaW5kZXggKz0gMztcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogVG9rZW4uUHVuY3R1YXRvcixcbiAgICAgICAgICAgICAgICB2YWx1ZTogJyE9PScsXG4gICAgICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICByYW5nZTogW3N0YXJ0LCBpbmRleF1cbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoY2gxID09PSAnPicgJiYgY2gyID09PSAnPicgJiYgY2gzID09PSAnPicpIHtcbiAgICAgICAgICAgIGluZGV4ICs9IDM7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFRva2VuLlB1bmN0dWF0b3IsXG4gICAgICAgICAgICAgICAgdmFsdWU6ICc+Pj4nLFxuICAgICAgICAgICAgICAgIGxpbmVOdW1iZXI6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgbGluZVN0YXJ0OiBsaW5lU3RhcnQsXG4gICAgICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGNoMSA9PT0gJzwnICYmIGNoMiA9PT0gJzwnICYmIGNoMyA9PT0gJz0nKSB7XG4gICAgICAgICAgICBpbmRleCArPSAzO1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5QdW5jdHVhdG9yLFxuICAgICAgICAgICAgICAgIHZhbHVlOiAnPDw9JyxcbiAgICAgICAgICAgICAgICBsaW5lTnVtYmVyOiBsaW5lTnVtYmVyLFxuICAgICAgICAgICAgICAgIGxpbmVTdGFydDogbGluZVN0YXJ0LFxuICAgICAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGluZGV4XVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChjaDEgPT09ICc+JyAmJiBjaDIgPT09ICc+JyAmJiBjaDMgPT09ICc9Jykge1xuICAgICAgICAgICAgaW5kZXggKz0gMztcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogVG9rZW4uUHVuY3R1YXRvcixcbiAgICAgICAgICAgICAgICB2YWx1ZTogJz4+PScsXG4gICAgICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICByYW5nZTogW3N0YXJ0LCBpbmRleF1cbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICAvLyAyLWNoYXJhY3RlciBwdW5jdHVhdG9yczogPD0gPj0gPT0gIT0gKysgLS0gPDwgPj4gJiYgfHxcbiAgICAgICAgLy8gKz0gLT0gKj0gJT0gJj0gfD0gXj0gLz1cblxuICAgICAgICBpZiAoY2gyID09PSAnPScpIHtcbiAgICAgICAgICAgIGlmICgnPD49ISstKiUmfF4vJy5pbmRleE9mKGNoMSkgPj0gMCkge1xuICAgICAgICAgICAgICAgIGluZGV4ICs9IDI7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVG9rZW4uUHVuY3R1YXRvcixcbiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGNoMSArIGNoMixcbiAgICAgICAgICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICAgICAgbGluZVN0YXJ0OiBsaW5lU3RhcnQsXG4gICAgICAgICAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGluZGV4XVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoY2gxID09PSBjaDIgJiYgKCcrLTw+JnwnLmluZGV4T2YoY2gxKSA+PSAwKSkge1xuICAgICAgICAgICAgaWYgKCcrLTw+JnwnLmluZGV4T2YoY2gyKSA+PSAwKSB7XG4gICAgICAgICAgICAgICAgaW5kZXggKz0gMjtcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5QdW5jdHVhdG9yLFxuICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2gxICsgY2gyLFxuICAgICAgICAgICAgICAgICAgICBsaW5lTnVtYmVyOiBsaW5lTnVtYmVyLFxuICAgICAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8vIFRoZSByZW1haW5pbmcgMS1jaGFyYWN0ZXIgcHVuY3R1YXRvcnMuXG5cbiAgICAgICAgaWYgKCdbXTw+Ky0qJSZ8XiF+Pzo9LycuaW5kZXhPZihjaDEpID49IDApIHtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogVG9rZW4uUHVuY3R1YXRvcixcbiAgICAgICAgICAgICAgICB2YWx1ZTogc291cmNlW2luZGV4KytdLFxuICAgICAgICAgICAgICAgIGxpbmVOdW1iZXI6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgbGluZVN0YXJ0OiBsaW5lU3RhcnQsXG4gICAgICAgICAgICAgICAgcmFuZ2U6IFtzdGFydCwgaW5kZXhdXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgLy8gNy44LjMgTnVtZXJpYyBMaXRlcmFsc1xuXG4gICAgZnVuY3Rpb24gc2Nhbk51bWVyaWNMaXRlcmFsKCkge1xuICAgICAgICB2YXIgbnVtYmVyLCBzdGFydCwgY2g7XG5cbiAgICAgICAgY2ggPSBzb3VyY2VbaW5kZXhdO1xuICAgICAgICBhc3NlcnQoaXNEZWNpbWFsRGlnaXQoY2gpIHx8IChjaCA9PT0gJy4nKSxcbiAgICAgICAgICAgICdOdW1lcmljIGxpdGVyYWwgbXVzdCBzdGFydCB3aXRoIGEgZGVjaW1hbCBkaWdpdCBvciBhIGRlY2ltYWwgcG9pbnQnKTtcblxuICAgICAgICBzdGFydCA9IGluZGV4O1xuICAgICAgICBudW1iZXIgPSAnJztcbiAgICAgICAgaWYgKGNoICE9PSAnLicpIHtcbiAgICAgICAgICAgIG51bWJlciA9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4XTtcblxuICAgICAgICAgICAgLy8gSGV4IG51bWJlciBzdGFydHMgd2l0aCAnMHgnLlxuICAgICAgICAgICAgLy8gT2N0YWwgbnVtYmVyIHN0YXJ0cyB3aXRoICcwJy5cbiAgICAgICAgICAgIGlmIChudW1iZXIgPT09ICcwJykge1xuICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gJ3gnIHx8IGNoID09PSAnWCcpIHtcbiAgICAgICAgICAgICAgICAgICAgbnVtYmVyICs9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzSGV4RGlnaXQoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBudW1iZXIgKz0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKG51bWJlci5sZW5ndGggPD0gMikge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gb25seSAweFxuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuVW5leHBlY3RlZFRva2VuLCAnSUxMRUdBTCcpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNJZGVudGlmaWVyU3RhcnQoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuVW5leHBlY3RlZFRva2VuLCAnSUxMRUdBTCcpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5OdW1lcmljTGl0ZXJhbCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBwYXJzZUludChudW1iZXIsIDE2KSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVOdW1iZXI6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGluZGV4XVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNPY3RhbERpZ2l0KGNoKSkge1xuICAgICAgICAgICAgICAgICAgICBudW1iZXIgKz0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgICAgICAgICB3aGlsZSAoaW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4XTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNPY3RhbERpZ2l0KGNoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgbnVtYmVyICs9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY2ggPSBzb3VyY2VbaW5kZXhdO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzSWRlbnRpZmllclN0YXJ0KGNoKSB8fCBpc0RlY2ltYWxEaWdpdChjaCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKHt9LCBNZXNzYWdlcy5VbmV4cGVjdGVkVG9rZW4sICdJTExFR0FMJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFRva2VuLk51bWVyaWNMaXRlcmFsLFxuICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHBhcnNlSW50KG51bWJlciwgOCksXG4gICAgICAgICAgICAgICAgICAgICAgICBvY3RhbDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVOdW1iZXI6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGluZGV4XVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIC8vIGRlY2ltYWwgbnVtYmVyIHN0YXJ0cyB3aXRoICcwJyBzdWNoIGFzICcwOScgaXMgaWxsZWdhbC5cbiAgICAgICAgICAgICAgICBpZiAoaXNEZWNpbWFsRGlnaXQoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLlVuZXhwZWN0ZWRUb2tlbiwgJ0lMTEVHQUwnKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHdoaWxlIChpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4XTtcbiAgICAgICAgICAgICAgICBpZiAoIWlzRGVjaW1hbERpZ2l0KGNoKSkge1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgbnVtYmVyICs9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChjaCA9PT0gJy4nKSB7XG4gICAgICAgICAgICBudW1iZXIgKz0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgY2ggPSBzb3VyY2VbaW5kZXhdO1xuICAgICAgICAgICAgICAgIGlmICghaXNEZWNpbWFsRGlnaXQoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBudW1iZXIgKz0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGNoID09PSAnZScgfHwgY2ggPT09ICdFJykge1xuICAgICAgICAgICAgbnVtYmVyICs9IHNvdXJjZVtpbmRleCsrXTtcblxuICAgICAgICAgICAgY2ggPSBzb3VyY2VbaW5kZXhdO1xuICAgICAgICAgICAgaWYgKGNoID09PSAnKycgfHwgY2ggPT09ICctJykge1xuICAgICAgICAgICAgICAgIG51bWJlciArPSBzb3VyY2VbaW5kZXgrK107XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4XTtcbiAgICAgICAgICAgIGlmIChpc0RlY2ltYWxEaWdpdChjaCkpIHtcbiAgICAgICAgICAgICAgICBudW1iZXIgKz0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgICAgIHdoaWxlIChpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG4gICAgICAgICAgICAgICAgICAgIGlmICghaXNEZWNpbWFsRGlnaXQoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBudW1iZXIgKz0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY2ggPSAnY2hhcmFjdGVyICcgKyBjaDtcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPj0gbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgIGNoID0gJzxlbmQ+JztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuVW5leHBlY3RlZFRva2VuLCAnSUxMRUdBTCcpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG4gICAgICAgICAgICBpZiAoaXNJZGVudGlmaWVyU3RhcnQoY2gpKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuVW5leHBlY3RlZFRva2VuLCAnSUxMRUdBTCcpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHR5cGU6IFRva2VuLk51bWVyaWNMaXRlcmFsLFxuICAgICAgICAgICAgdmFsdWU6IHBhcnNlRmxvYXQobnVtYmVyKSxcbiAgICAgICAgICAgIGxpbmVOdW1iZXI6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGluZGV4XVxuICAgICAgICB9O1xuICAgIH1cblxuICAgIC8vIDcuOC40IFN0cmluZyBMaXRlcmFsc1xuXG4gICAgZnVuY3Rpb24gc2NhblN0cmluZ0xpdGVyYWwoKSB7XG4gICAgICAgIHZhciBzdHIgPSAnJywgcXVvdGUsIHN0YXJ0LCBjaCwgY29kZSwgdW5lc2NhcGVkLCByZXN0b3JlLCBvY3RhbCA9IGZhbHNlO1xuXG4gICAgICAgIHF1b3RlID0gc291cmNlW2luZGV4XTtcbiAgICAgICAgYXNzZXJ0KChxdW90ZSA9PT0gJ1xcJycgfHwgcXVvdGUgPT09ICdcIicpLFxuICAgICAgICAgICAgJ1N0cmluZyBsaXRlcmFsIG11c3Qgc3RhcnRzIHdpdGggYSBxdW90ZScpO1xuXG4gICAgICAgIHN0YXJ0ID0gaW5kZXg7XG4gICAgICAgICsraW5kZXg7XG5cbiAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleCsrXTtcblxuICAgICAgICAgICAgaWYgKGNoID09PSBxdW90ZSkge1xuICAgICAgICAgICAgICAgIHF1b3RlID0gJyc7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNoID09PSAnXFxcXCcpIHtcbiAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgICAgICBpZiAoIWlzTGluZVRlcm1pbmF0b3IoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoY2gpIHtcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnbic6XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHIgKz0gJ1xcbic7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAncic6XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHIgKz0gJ1xccic7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAndCc6XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHIgKz0gJ1xcdCc7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAndSc6XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ3gnOlxuICAgICAgICAgICAgICAgICAgICAgICAgcmVzdG9yZSA9IGluZGV4O1xuICAgICAgICAgICAgICAgICAgICAgICAgdW5lc2NhcGVkID0gc2NhbkhleEVzY2FwZShjaCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodW5lc2NhcGVkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyICs9IHVuZXNjYXBlZDtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXggPSByZXN0b3JlO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0ciArPSBjaDtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICBjYXNlICdiJzpcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0ciArPSAnXFxiJztcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICBjYXNlICdmJzpcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0ciArPSAnXFxmJztcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICBjYXNlICd2JzpcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0ciArPSAnXFx4MEInO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc09jdGFsRGlnaXQoY2gpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29kZSA9ICcwMTIzNDU2NycuaW5kZXhPZihjaCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBcXDAgaXMgbm90IG9jdGFsIGVzY2FwZSBzZXF1ZW5jZVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb2RlICE9PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9jdGFsID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5kZXggPCBsZW5ndGggJiYgaXNPY3RhbERpZ2l0KHNvdXJjZVtpbmRleF0pKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9jdGFsID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29kZSA9IGNvZGUgKiA4ICsgJzAxMjM0NTY3Jy5pbmRleE9mKHNvdXJjZVtpbmRleCsrXSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gMyBkaWdpdHMgYXJlIG9ubHkgYWxsb3dlZCB3aGVuIHN0cmluZyBzdGFydHNcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gd2l0aCAwLCAxLCAyLCAzXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgnMDEyMycuaW5kZXhPZihjaCkgPj0gMCAmJlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4IDwgbGVuZ3RoICYmXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNPY3RhbERpZ2l0KHNvdXJjZVtpbmRleF0pKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2RlID0gY29kZSAqIDggKyAnMDEyMzQ1NjcnLmluZGV4T2Yoc291cmNlW2luZGV4KytdKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShjb2RlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyICs9IGNoO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICArK2xpbmVOdW1iZXI7XG4gICAgICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gICdcXHInICYmIHNvdXJjZVtpbmRleF0gPT09ICdcXG4nKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICArK2luZGV4O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIGlmIChpc0xpbmVUZXJtaW5hdG9yKGNoKSkge1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBzdHIgKz0gY2g7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocXVvdGUgIT09ICcnKSB7XG4gICAgICAgICAgICB0aHJvd0Vycm9yKHt9LCBNZXNzYWdlcy5VbmV4cGVjdGVkVG9rZW4sICdJTExFR0FMJyk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4ge1xuICA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m9yKHt9LCBNZXNzYWdlcy5VbnRlcm1pbmF0ZWRSZWdFeHApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBzdHIgKz0gY2g7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNsYXNzTWFya2VyKSB7XG4gICAgICAgICAgICAgICAgaWYgKGNoID09PSAnXScpIHtcbiAgICAgICAgICAgICAgICAgICAgY2xhc3NNYXJrZXIgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gJy8nKSB7XG4gICAgICAgICAgICAgICAgICAgIHRlcm1pbmF0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoID09PSAnWycpIHtcbiAgICAgICAgICAgICAgICAgICAgY2xhc3NNYXJrZXIgPSB0cnVlO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNMaW5lVGVybWluYXRvcihjaCkpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuVW50ZXJtaW5hdGVkUmVnRXhwKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoIXRlcm1pbmF0ZWQpIHtcbiAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLlVudGVybWluYXRlZFJlZ0V4cCk7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBFeGNsdWRlIGxlYWRpbmcgYW5kIHRyYWlsaW5nIHNsYXNoLlxuICAgICAgICBwYXR0ZXJuID0gc3RyLnN1YnN0cigxLCBzdHIubGVuZ3RoIC0gMik7XG5cbiAgICAgICAgZmxhZ3MgPSAnJztcbiAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG4gICAgICAgICAgICBpZiAoIWlzSWRlbnRpZmllclBhcnQoY2gpKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICBpZiAoY2ggPT09ICdcXFxcJyAmJiBpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4XTtcbiAgICAgICAgICAgICAgICBpZiAoY2ggPT09ICd1Jykge1xuICAgICAgICAgICAgICAgICAgICArK2luZGV4O1xuICAgICAgICAgICAgICAgICAgICByZXN0b3JlID0gaW5kZXg7XG4gICAgICAgICAgICAgICAgICAgIGNoID0gc2NhbkhleEVzY2FwZSgndScpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoY2gpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZsYWdzICs9IGNoO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RyICs9ICdcXFxcdSc7XG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgcmVzdG9yZSA8IGluZGV4OyArK3Jlc3RvcmUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgKz0gc291cmNlW3Jlc3RvcmVdO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXggPSByZXN0b3JlO1xuICAgICAgICAgICAgICAgICAgICAgICAgZmxhZ3MgKz0gJ3UnO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RyICs9ICdcXFxcdSc7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzdHIgKz0gJ1xcXFwnO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZmxhZ3MgKz0gY2g7XG4gICAgICAgICAgICAgICAgc3RyICs9IGNoO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHZhbHVlID0gbmV3IFJlZ0V4cChwYXR0ZXJuLCBmbGFncyk7XG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLkludmFsaWRSZWdFeHApO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIGxpdGVyYWw6IHN0cixcbiAgICAgICAgICAgIHZhbHVlOiB2YWx1ZSxcbiAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGluZGV4XVxuICAgICAgICB9O1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGlzSWRlbnRpZmllck5hbWUodG9rZW4pIHtcbiAgICAgICAgcmV0dXJuIHRva2VuLnR5cGUgPT09IFRva2VuLklkZW50aWZpZXIgfHxcbiAgICAgICAgICAgIHRva2VuLnR5cGUgPT09IFRva2VuLktleXdvcmQgfHxcbiAgICAgICAgICAgIHRva2VuLnR5cGUgPT09IFRva2VuLkJvb2xlYW5MaXRlcmFsIHx8XG4gICAgICAgICAgICB0b2tlbi50eXBlID09PSBUb2tlbi5OdWxsTGl0ZXJhbDtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBhZHZhbmNlKCkge1xuICAgICAgICB2YXIgY2gsIHRva2VuO1xuXG4gICAgICAgIHNraXBDb21tZW50KCk7XG5cbiAgICAgICAgaWYgKGluZGV4ID49IGxlbmd0aCkge1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbi5FT0YsXG4gICAgICAgICAgICAgICAgbGluZU51bWJlcjogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCxcbiAgICAgICAgICAgICAgICByYW5n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gICAgICAgICAgICByZXR1cm4gdG9rZW47XG4gICAgICAgIH1cblxuICAgICAgICBidWZmZXIgPSBudWxsO1xuICAgICAgICByZXR1cm4gYWR2YW5jZSgpO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGxvb2thaGVhZCgpIHtcbiAgICAgICAgdmFyIHBvcywgbGluZSwgc3RhcnQ7XG5cbiAgICAgICAgaWYgKGJ1ZmZlciAhPT0gbnVsbCkge1xuICAgICAgICAgICAgcmV0dXJuIGJ1ZmZlcjtcbiAgICAgICAgfVxuXG4gICAgICAgIHBvcyA9IGluZGV4O1xuICAgICAgICBsaW5lID0gbGluZU51bWJlcjtcbiAgICAgICAgc3RhcnQgPSBsaW5lU3RhcnQ7XG4gICAgICAgIGJ1ZmZlciA9IGFkdmFuY2UoKTtcbiAgICAgICAgaW5kZXggPSBwb3M7XG4gICAgICAgIGxpbmVOdW1iZXIgPSBsaW5lO1xuICAgICAgICBsaW5lU3RhcnQgPSBzdGFydDtcblxuICAgICAgICByZXR1cm4gYnVmZmVyO1xuICAgIH1cblxuICAgIC8vIFJldHVybiB0cnVlIGlmIHRoZXJlIGlzIGEgbGluZSB0ZXJtaW5hdG9yIGJlZm9yZSB0aGUgbmV4dCB0b2tlbi5cblxuICAgIGZ1bmN0aW9uIHBlZWtMaW5lVGVybWluYXRvcigpIHtcbiAgICAgICAgdmFyIHBvcywgbGluZSwgc3RhcnQsIGZvdW5kO1xuXG4gICAgICAgIHBvcyA9IGluZGV4O1xuICAgICAgICBsaW5lID0gbGluZU51bWJlcjtcbiAgICAgICAgc3RhcnQgPSBsaW5lU3RhcnQ7XG4gICAgICAgIHNraXBDb21tZW50KCk7XG4gICAgICAgIGZvdW5kID0gbGluZU51bWJlciAhPT0gbGluZTtcbiAgICAgICAgaW5kZXggPSBwb3M7XG4gICAgICAgIGxpbmVOdW1iZXIgPSBsaW5lO1xuICAgICAgICBsaW5lU3RhcnQgPSBzdGFydDtcblxuICAgICAgICByZXR1cm4gZm91bmQ7XG4gICAgfVxuXG4gICAgLy8gVGhyb3cgYW4gZXhjZXB0aW9uXG5cbiAgICBmdW5jdGlvbiB0aHJvd0Vycm9yKHRva2VuLCBtZXNzYWdlRm9ybWF0KSB7XG4gICAgICAgIHZhciBlcnJvcixcbiAgICAgICAgICAgIGFyZ3MgPSBBcnJheS5wcm90b3R5cGUuc2xpY2UuY2FsbChhcmd1bWVudHMsIDIpLFxuICAgICAgICAgICAgbXNnID0gbWVzc2FnZUZvcm1hdC5yZXBsYWNlKFxuICAgICAgICAgICAgICAgIC8lKFxcZCkvZyxcbiAgICAgICAgICAgICAgICBmdW5jdGlvbiAod2hvbGUsIGluZGV4KSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBhcmdzW2luZGV4XSB8fCAnJztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICApO1xuXG4gICAgICAgIGlmICh0eXBlb2YgdG9rZW4ubGluZU51bWJlciA9PT0gJ251bWJlcicpIHtcbiAgICAgICAgICAgIGVycm9yID0gbmV3IEVycm9yKCdMaW5lICcgKyB0b2tlbi5saW5lTnVtYmVyICsgJzogJyArIG1zZyk7XG4gICAgICAgICAgICBlcnJvci5pbmRleCA9IHRva2VuLnJhbmdlWzBdO1xuICAgICAgICAgICAgZXJyb3IubGluZU51bWJlciA9IHRva2VuLmxpbmVOdW1iZXI7XG4gICAgICAgICAgICBlcnJvci5jb2x1bW4gPSB0b2tlbi5yYW5nZVswXSAtIGxpbmVTdGFydCArIDE7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBlcnJvciA9IG5ldyBFcnJvcignTGluZSAnICsgbGluZU51bWJlciArICc6ICcgKyBtc2cpO1xuICAgICAgICAgICAgZXJyb3IuaW5kZXggPSBpbmRleDtcbiAgICAgICAgICAgIGVycm9yLmxpbmVOdW1iZXIgPSBsaW5lTnVtYmVyO1xuICAgICAgICAgICAgZXJyb3IuY29sdW1uID0gaW5kZXggLSBsaW5lU3RhcnQgKyAxO1xuICAgICAgICB9XG5cbiAgICAgICAgdGhyb3cgZXJyb3I7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gdGhyb3dFcnJvclRvbGVyYW50KCkge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgdGhyb3dFcnJvci5hcHBseShudWxsLCBhcmd1bWVudHMpO1xuICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICBpZiAoZXh0cmEuZXJyb3JzKSB7XG4gICAgICAgICAgICAgICAgZXh0cmEuZXJyb3JzLnB1c2goZSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRocm93IGU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cblxuICAgIC8vIFRocm93IGFuIGV4Y2VwdGlvbiBiZWNhdXNlIG9mIHRoZSB0b2tlbi5cblxuICAgIGZ1bmN0aW9uIHRocm93VW5leHBlY3RlZCh0b2tlbikge1xuICAgICAgICBpZiAodG9rZW4udHlwZSA9PT0gVG9rZW4uRU9GKSB7XG4gICAgICAgICAgICB0aHJvd0Vycm9yKHRva2VuLCBNZXNzYWdlcy5VbmV4cGVjdGVkRU9TKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0b2tlbi50eXBlID09PSBUb2tlbi5OdW1lcmljTGl0ZXJhbCkge1xuICAgICAgICAgICAgdGhyb3dFcnJvcih0b2tlbiwgTWVzc2FnZXMuVW5leHBlY3RlZE51bWJlcik7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodG9rZW4udHlwZSA9PT0gVG9rZW4uU3RyaW5nTGl0ZXJhbCkge1xuICAgICAgICAgICAgdGhyb3dFcnJvcih0b2tlbiwgTWVzc2FnZXMuVW5leHBlY3RlZFN0cmluZyk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodG9rZW4udHlwZSA9PT0gVG9rZW4uSWRlbnRpZmllcikge1xuICAgICAgICAgICAgdGhyb3dFcnJvcih0b2tlbiwgTWVzc2FnZXMuVW5le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G5cbiAgICAvLyBSZXR1cm4gdHJ1ZSBpZiB0aGUgbmV4dCB0b2tlbiBpcyBhbiBhc3NpZ25tZW50IG9wZXJhdG9yXG5cbiAgICBmdW5jdGlvbiBtYXRjaEFzc2lnbigpIHtcbiAgICAgICAgdmFyIHRva2VuID0gbG9va2FoZWFkKCksXG4gICAgICAgICAgICBvcCA9IHRva2VuLnZhbHVlO1xuXG4gICAgICAgIGlmICh0b2tlbi50eXBlICE9PSBUb2tlbi5QdW5jdHVhdG9yKSB7XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIG9wID09PSAnPScgfHxcbiAgICAgICAgICAgIG9wID09PSAnKj0nIHx8XG4gICAgICAgICAgICBvcCA9PT0gJy89JyB8fFxuICAgICAgICAgICAgb3AgPT09ICclPScgfHxcbiAgICAgICAgICAgIG9wID09PSAnKz0nIHx8XG4gICAgICAgICAgICBvcCA9PT0gJy09JyB8fFxuICAgICAgICAgICAgb3AgPT09ICc8PD0nIHx8XG4gICAgICAgICAgICBvcCA9PT0gJz4+PScgfHxcbiAgICAgICAgICAgIG9wID09PSAnPj4+PScgfHxcbiAgICAgICAgICAgIG9wID09PSAnJj0nIHx8XG4gICAgICAgICAgICBvcCA9PT0gJ149JyB8fFxuICAgICAgICAgICAgb3AgPT09ICd8PSc7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gY29uc3VtZVNlbWljb2xvbigpIHtcbiAgICAgICAgdmFyIHRva2VuLCBsaW5lO1xuXG4gICAgICAgIC8vIENhdGNoIHRoZSB2ZXJ5IGNvbW1vbiBjYXNlIGZpcnN0LlxuICAgICAgICBpZiAoc291cmNlW2luZGV4XSA9PT0gJzsnKSB7XG4gICAgICAgICAgICBsZXgoKTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIGxpbmUgPSBsaW5lTnVtYmVyO1xuICAgICAgICBza2lwQ29tbWVudCgpO1xuICAgICAgICBpZiAobGluZU51bWJlciAhPT0gbGluZSkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKG1hdGNoKCc7JykpIHtcbiAgICAgICAgICAgIGxleCgpO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgdG9rZW4gPSBsb29rYWhlYWQoKTtcbiAgICAgICAgaWYgKHRva2VuLnR5cGUgIT09IFRva2VuLkVPRiAmJiAhbWF0Y2goJ30nKSkge1xuICAgICAgICAgICAgdGhyb3dVbmV4cGVjdGVkKHRva2VuKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIC8vIFJldHVybiB0cnVlIGlmIHByb3ZpZGVkIGV4cHJlc3Npb24gaXMgTGVmdEhhbmRTaWRlRXhwcmVzc2lvblxuXG4gICAgZnVuY3Rpb24gaXNMZWZ0SGFuZFNpZGUoZXhwcikge1xuICAgICAgICByZXR1cm4gZXhwci50eXBlID09PSBTeW50YXguSWRlbnRpZmllciB8fCBleHByLnR5cGUgPT09IFN5bnRheC5NZW1iZXJFeHByZXNzaW9uO1xuICAgIH1cblxuICAgIC8vIDExLjEuNCBBcnJheSBJbml0aWFsaXNlclxuXG4gICAgZnVuY3Rpb24gcGFyc2VBcnJheUluaXRpYWxpc2VyKCkge1xuICAgICAgICB2YXIgZWxlbWVudHMgPSBbXTtcblxuICAgICAgICBleHBlY3QoJ1snKTtcblxuICAgICAgICB3aGlsZSAoIW1hdGNoKCddJykpIHtcbiAgICAgICAgICAgIGlmIChtYXRjaCgnLCcpKSB7XG4gICAgICAgICAgICAgICAgbGV4KCk7XG4gICAgICAgICAgICAgICAgZWxlbWVudHMucHVzaChudWxsKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZWxlbWVudHMucHVzaChwYXJzZUFzc2lnbm1lbnRFeHByZXNzaW9uKCkpO1xuXG4gICAgICAgICAgICAgICAgaWYgKCFtYXRjaCgnXScpKSB7XG4gICAgICAgICAgICAgICAgICAgIGV4cGVjdCgnLCcpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGV4cGVjdCgnXScpO1xuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBTeW50YXguQXJyYXlFeHByZXNzaW9uLFxuICAgICAgICAgICAgZWxlbWVudHM6IGVsZW1lbnRzXG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgLy8gMTEuMS41IE9iamVjdCBJbml0aWFsaXNlclxuXG4gICAgZnVuY3Rpb24gcGFyc2VQcm9wZXJ0eUZ1bmN0aW9uKHBhcmFtLCBmaXJzdCkge1xuICAgICAgICB2YXIgcHJldmlvdXNTdHJpY3QsIGJvZHk7XG5cbiAgICAgICAgcHJldmlvdXNTdHJpY3QgPSBzdHJpY3Q7XG4gICAgICAgIGJvZHkgPSBwYXJzZUZ1bmN0aW9uU291cmNlRWxlbWVudHMoKTtcbiAgICAgICAgaWYgKGZpcnN0ICYmIHN0cmljdCAmJiBpc1Jlc3RyaWN0ZWRXb3JkKHBhcmFtWzBdLm5hbWUpKSB7XG4gICAgICAgICAgICB0aHJvd0Vycm9yVG9sZXJhbnQoZmlyc3QsIE1lc3NhZ2VzLlN0cmljdFBhcmFtTmFtZSk7XG4gICAgICAgIH1cbiAgICAgICAgc3RyaWN0ID0gcHJldmlvdXNTdHJpY3Q7XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHR5cGU6IFN5bnRheC5GdW5jdGlvbkV4cHJlc3Npb24sXG4gICAgICAgICAgICBpZDogbnVsbCxcbiAgICAgICAgICAgIHBhcmFtczogcGFyYW0sXG4gICAgICAgICAgICBkZWZhdWx0czogW10sXG4gICAgICAgICAgICBib2R5OiBib2R5LFxuICAgICAgICAgICAgcmVzdDogbnVsbCxcbiAgICAgICAgICAgIGdlbmVyYXRvcjogZmFsc2UsXG4gICAgICAgICAgICBleHByZXNz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AgICAgICAgIC8vIFByb3BlcnR5IEFzc2lnbm1lbnQ6IEdldHRlciBhbmQgU2V0dGVyLlxuXG4gICAgICAgICAgICBpZiAodG9rZW4udmFsdWUgPT09ICdnZXQnICYmICFtYXRjaCgnOicpKSB7XG4gICAgICAgICAgICAgICAga2V5ID0gcGFyc2VPYmplY3RQcm9wZXJ0eUtleSgpO1xuICAgICAgICAgICAgICAgIGV4cGVjdCgnKCcpO1xuICAgICAgICAgICAgICAgIGV4cGVjdCgnKScpO1xuICAgICAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5Qcm9wZXJ0eSxcbiAgICAgICAgICAgICAgICAgICAga2V5OiBrZXksXG4gICAgICAgICAgICAgICAgICAgIHZhbHVlOiBwYXJzZVByb3BlcnR5RnVuY3Rpb24oW10pLFxuICAgICAgICAgICAgICAgICAgICBraW5kOiAnZ2V0J1xuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRva2VuLnZhbHVlID09PSAnc2V0JyAmJiAhbWF0Y2goJzonKSkge1xuICAgICAgICAgICAgICAgIGtleSA9IHBhcnNlT2JqZWN0UHJvcGVydHlLZXkoKTtcbiAgICAgICAgICAgICAgICBleHBlY3QoJygnKTtcbiAgICAgICAgICAgICAgICB0b2tlbiA9IGxvb2thaGVhZCgpO1xuICAgICAgICAgICAgICAgIGlmICh0b2tlbi50eXBlICE9PSBUb2tlbi5JZGVudGlmaWVyKSB7XG4gICAgICAgICAgICAgICAgICAgIGV4cGVjdCgnKScpO1xuICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yVG9sZXJhbnQodG9rZW4sIE1lc3NhZ2VzLlVuZXhwZWN0ZWRUb2tlbiwgdG9rZW4udmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LlByb3BlcnR5LFxuICAgICAgICAgICAgICAgICAgICAgICAga2V5OiBrZXksXG4gICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogcGFyc2VQcm9wZXJ0eUZ1bmN0aW9uKFtdKSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGtpbmQ6ICdzZXQnXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcGFyYW0gPSBbIHBhcnNlVmFyaWFibGVJZGVudGlmaWVyKCkgXTtcbiAgICAgICAgICAgICAgICAgICAgZXhwZWN0KCcpJyk7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguUHJvcGVydHksXG4gICAgICAgICAgICAgICAgICAgICAgICBrZXk6IGtleSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBwYXJzZVByb3BlcnR5RnVuY3Rpb24ocGFyYW0sIHRva2VuKSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGtpbmQ6ICdzZXQnXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBleHBlY3QoJzonKTtcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguUHJvcGVydHksXG4gICAgICAgICAgICAgICAgICAgIGtleTogaWQsXG4gICAgICAgICAgICAgICAgICAgIHZhbHVlOiBwYXJzZUFzc2lnbm1lbnRFeHByZXNzaW9uKCksXG4gICAgICAgICAgICAgICAgICAgIGtpbmQ6ICdpbml0J1xuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAodG9rZW4udHlwZSA9PT0gVG9rZW4uRU9GIHx8IHRva2VuLnR5cGUgPT09IFRva2VuLlB1bmN0dWF0b3IpIHtcbiAgICAgICAgICAgIHRocm93VW5leHBlY3RlZCh0b2tlbik7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBrZXkgPSBwYXJzZU9iamVjdFByb3BlcnR5S2V5KCk7XG4gICAgICAgICAgICBleHBlY3QoJzonKTtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LlByb3BlcnR5LFxuICAgICAgICAgICAgICAgIGtleToga2V5LFxuICAgICAgICAgICAgICAgIHZhbHVlOiBwYXJzZUFzc2lnbm1lbnRFeHByZXNzaW9uKCksXG4gICAgICAgICAgICAgICAga2luZDogJ2luaXQnXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2VPYmplY3RJbml0aWFsaXNlcigpIHtcbiAgICAgICAgdmFyIHByb3BlcnRpZXMgPSBbXSwgcHJvcGVydHksIG5hbWUsIGtpbmQsIG1hcCA9IHt9LCB0b1N0cmluZyA9IFN0cmluZztcblxuICAgICAgICBleHBlY3QoJ3snKTtcblxuICAgICAgICB3aGlsZSAoIW1hdGNoKCd9JykpIHtcbiAgICAgICAgICAgIHByb3BlcnR5ID0gcGFyc2VPYmplY3RQcm9wZXJ0eSgpO1xuXG4gICAgICAgICAgICBpZiAocHJvcGVydHkua2V5LnR5cGUgPT09IFN5bnRheC5JZGVudGlmaWVyKSB7XG4gICAgICAgICAgICAgICAgbmFtZSA9IHByb3BlcnR5LmtleS5uYW1lO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBuYW1lID0gdG9TdHJpbmcocHJvcGVydHkua2V5LnZhbHVlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGtpbmQgPSAocHJvcGVydHkua2luZCA9PT0gJ2luaXQnKSA/IFByb3BlcnR5S2luZC5EYXRhIDogKHByb3BlcnR5LmtpbmQgPT09ICdnZXQnKSA/IFByb3BlcnR5S2luZC5HZXQgOiBQcm9wZXJ0eUtpbmQuU2V0O1xuICAgICAgICAgICAgaWYgKE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbChtYXAsIG5hbWUpKSB7XG4gICAgICAgICAgICAgICAgaWYgKG1hcFtuYW1lXSA9PT0gUHJvcGVydHlLaW5kLkRhdGEpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHN0cmljdCAmJiBraW5kID09PSBQcm9wZXJ0eUtpbmQuRGF0YSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5TdHJpY3REdXBsaWNhdGVQcm9wZXJ0eSk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoa2luZCAhPT0gUHJvcGVydHlLaW5kLkRhdGEpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93RXJyb3JUb2xlcmFudCh7fSwgTWVzc2FnZXMuQWNjZXNzb3JEYXRhUHJvcGVydHkpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGtpbmQgPT09IFByb3BlcnR5S2luZC5EYXRhKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yVG9sZXJhbnQoe30sIE1lc3NhZ2VzLkFjY2Vzc29yRGF0YVByb3BlcnR5KTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChtYXBbbmFtZV0gJiBraW5kKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yVG9sZXJhbnQoe30sIE1lc3NhZ2VzLkFjY2Vzc29yR2V0U2V0KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBbbmFtZV0gfD0ga2luZDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgbWFwW25hbWVdID0ga2luZDtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcHJvcGVydGllcy5wdXNoKHByb3BlcnR5KTtcblxuICAgICAgICAgICAgaWYgKCFtYXRjaCgnfScpKSB7XG4gICAgICAgICAgICAgICAgZXhwZWN0KCcsJyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBleHBlY3QoJ30nKTtcblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4Lk9iamVjdEV4cHJlc3Npb24sXG4gICAgICAgICAgICBwcm9wZXJ0aWVzOiBwcm9wZXJ0aWVzXG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgLy8gMTEuMS42IFRoZSBHcm91cGluZyBPcGVyYXRvclxuXG4gICAgZnVuY3Rpb24gcGFyc2VHcm91cEV4cHJlc3Npb24oKSB7XG4gICAgICAgIHZhciBleHByO1xuXG4gICAgICAgIGV4cGVjdCgnKCcpO1xuXG4gICAgICAgIGV4cHIgPSBwYXJzZUV4cHJlc3Npb24oKTtcblxuICAgICAgICBleHBlY3QoJyknKTtcblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cblxuICAgIC8vIDExLjEgUHJpbWFyeSBFeHByZXNzaW9uc1xuXG4gICAgZnVuY3Rpb24gcGFyc2VQcmltYXJ5RXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIHRva2VuID0gbG9va2FoZWFkKCksXG4gICAgICAgICAgICB0eXBlID0gdG9rZW4udHlwZTtcblxuICAgICAgICBpZiAodHlwZSA9PT0gVG9rZW4uSWRlbnRpZmllcikge1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguSWRlbnRpZmllcixcbiAgICAgICAgICAgICAgICBuYW1lOiBsZXgoKS52YWx1ZVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0eXBlID09PSBUb2tlbi5TdHJpbmdMaXRlcmFsIHx8IHR5cGUgPT09IFRva2VuLk51bWVyaWNMaXRlcmFsKSB7XG4gICAgICAgICAgICBpZiAoc3RyaWN0ICYmIHRva2VuLm9jdGFsKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHRva2VuLCBNZXNzYWdlcy5TdHJpY3RPY3RhbExpdGVyYWwpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGNyZWF0ZUxpdGVyYWwobGV4KCkpO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHR5cGUgPT09IFRva2VuLktleXdvcmQpIHtcbiAgICAgICAgICAgIGlmIChtYXRjaEtleXdvcmQoJ3RoaXMnKSkge1xuICAgICAgICAgICAgICAgIGxleCgpO1xuICAgICAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5UaGlzRXhwcmVzc2lvblxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChtYXRjaEtleXdvcmQoJ2Z1bmN0aW9uJykpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gcGFyc2VGdW5jdGlvbkV4cHJlc3Npb24oKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0eXBlID09PSBUb2tlbi5Cb29sZWFuTGl0ZXJhbCkge1xuICAgICAgICAgICAgbGV4KCk7XG4gICAgICAgICAgICB0b2tlbi52YWx1ZSA9ICh0b2tlbi52YWx1ZSA9PT0gJ3RydWUnKTtcbiAgICAgICAgICAgIHJldHVybiBjcmVhdGVMaXRlcmFsKHRva2VuKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0eXBlID09PSBUb2tlbi5OdWxsTGl0ZXJhbCkge1xuICAgICAgICAgICAgbGV4KCk7XG4gICAgICAgICAgICB0b2tlbi52YWx1ZSA9IG51bGw7XG4gICAgICAgICAgICByZXR1cm4gY3JlYXRlTGl0ZXJhbCh0b2tlbik7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAobWF0Y2goJ1snKSkge1xuICAgICAgICAgICAgcmV0dXJuIHBhcnNlQXJyYXlJbml0aWFsaXNlcigpO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKG1hdGNoKCd7JykpIHtcbiAgICAgICAgICAgIHJldHVybiBwYXJzZU9iamVjdEluaXRpYWxpc2VyKCk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAobWF0Y2goJygnKSkge1xuICAgICAgICAgICAgcmV0dXJuIHBhcnNlR3JvdXBFeHByZXNzaW9uKCk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAobWF0Y2goJy8nKSB8fCBtYXRjaCgnLz0nKSkge1xuICAgICAgICAgICAgcmV0dXJuIGNyZWF0ZUxpdGVyYWwoc2NhblJlZ0V4cCgpKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB0aHJvd1VuZXhwZWN0ZWQobGV4KCkpO1xuICAgIH1cblxuICAgIC8vIDExLjIgTGVmdC1IYW5kLVNpZGUgRXhwcmVzc2lvbnNcblxuICAgIGZ1bmN0aW9uIHBhcnNlQXJndW1lbnRzKCkge1xuICAgICAgICB2YXIgYXJncyA9IFtdO1xuXG4gICAgICAgIGV4cGVjdCgnKCcpO1xuXG4gICAgICAgIGlmICghbWF0Y2goJyknKSkge1xuICAgICAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgYXJncy5wdXNoKHBhcnNlQXNzaWdubWVudEV4cHJlc3Npb24oKSk7XG4gICAgICAgICAgICAgICAgaWYgKG1hdGNoKCcpJykpIHtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGV4cGVjdCgnLCcpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZXhwZWN0KCcpJyk7XG5cbiAgICAgICAgcmV0dXJuIGFyZ3M7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2VOb25Db21wdXRlZFByb3BlcnR5KCkge1xuICAgICAgICB2YXIgdG9rZW4gPSBsZXgoKTtcblxuICAgICAgICBpZiAoIWlzSWRlbnRpZmllck5hbWUodG9rZW4pKSB7XG4gICAgICAgICAgICB0aHJvd1VuZXhwZWN0ZWQodG9rZW4pO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHR5cGU6IFN5bnRheC5JZGVudGlmaWVyLFxuICAgICAgICAgICAgbmFtZTogdG9rZW4udmFsdWVcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwYXJzZU5vbkNvbXB1dGVkTWVtYmVyKCkge1xuICAgICAgICBleHBlY3QoJy4nKTtcblxuICAgICAgICByZXR1cm4gcGFyc2VOb25Db21wdXRlZFByb3BlcnR5KCk7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2VDb21wdXRlZE1lbWJlcigpIHtcbiAgICAgICAgdmFyIGV4cHI7XG5cbiAgICAgICAgZXhwZWN0KCdbJyk7XG5cbiAgICAgICAgZXhwciA9IHBhcnNlRXhwcmVzc2lvbigpO1xuXG4gICAgICAgIGV4cGVjdCgnXScpO1xuXG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBhcnNlTmV3RXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHI7XG5cbiAgICAgICAgZXhwZWN0S2V5d29yZCgnbmV3Jyk7XG5cbiAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgIHR5cGU6IFN5bnRheC5OZXdFeHByZXNzaW9uLFxuICAgICAgICAgICAgY2FsbGVlOiBwYXJzZUxlZnRIYW5kU2lkZUV4cHJlc3Npb24oKSxcbiAgICAgICAgICAgICdhcmd1bWVudHMnOiBbXVxuICAgICAgICB9O1xuXG4gICAgICAgIGlmIChtYXRjaCgnKCcpKSB7XG4gICAgICAgICAgICBleHByWydhcmd1bWVudHMnXSA9IHBhcnNlQXJndW1lbnRzKCk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwYXJzZUxlZnRIYW5kU2lkZUV4cHJlc3Npb25BbGxvd0NhbGwoKSB7XG4gICAgICAgIHZhciBleHByO1xuXG4gICAgICAgIGV4cHIgPSBtYXRjaEtleXdvcmQoJ25ldycpID8gcGFyc2VOZXdFeHByZXNzaW9uKCkgOiBwYXJzZVByaW1hcnlFeHByZXNzaW9uKCk7XG5cbiAgICAgICAgd2hpbGUgKG1hdGNoKCcuJykgfHwgbWF0Y2goJ1snKSB8fCBtYXRjaCgnKCcpKSB7XG4gICAgICAgICAgICBpZiAobWF0Y2goJygnKSkge1xuICAgICAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5DYWxsRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICAgICAgY2FsbGVlOiBleHByLFxuICAgICAgICAgICAgICAgICAgICAnYXJndW1lbnRzJzogcGFyc2VBcmd1bWVudHMoKVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1hdGNoKCdbJykpIHtcbiAgICAgICAgICAgICAgICBleHByID0ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguTWVtYmVyRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICAgICAgY29tcHV0ZWQ6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIG9iamVjdDogZXhwcixcbiAgICAgICAgICAgICAgICAgICAgcHJvcGVydHk6IHBhcnNlQ29tcHV0ZWRNZW1iZXIoKVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5NZW1iZXJFeHByZXNzaW9uLFxuICAgICAgICAgICAgICAgICAgICBjb21wdXRlZDogZmFsc2UsXG4gICAgICAgICAgICAgICAgICAgIG9iamVjdDogZXhwcixcbiAgICAgICAgICAgICAgICAgICAgcHJvcGVydHk6IHBhcnNlTm9uQ29tcHV0ZWRNZW1iZXIoKVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cblxuICAgIGZ1bmN0aW9uIHBhcnNlTGVmdEhhbmRTaWRlRXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHI7XG5cbiAgICAgICAgZXhwciA9IG1hdGNoS2V5d29yZCgnbmV3JykgPyBwYXJzZU5ld0V4cHJlc3Npb24oKSA6IHBhcnNlUHJpbWFyeUV4cHJlc3Npb24oKTtcblxuICAgICAgICB3aGlsZSAobWF0Y2goJy4nKSB8fCBtYXRjaCgnWycpKSB7XG4gICAgICAgICAgICBpZiAobWF0Y2goJ1snKSkge1xuICAgICAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5NZW1iZXJFeHByZXNzaW9uLFxuICAgICAgICAgICAgICAgICAgICBjb21wdXRlZDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgb2JqZWN0OiBleHByLFxuICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0eTogcGFyc2VDb21wdXRlZE1lbWJlcigpXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogU3ludGF4Lk1lbWJlckV4cHJlc3Npb24sXG4gICAgICAgICAgICAgICAgICAgIGNvbXB1dGVkOiBmYWxzZSxcbiAgICAgICAgICAgICAgICAgICAgb2JqZWN0OiBleHByLFxuICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0eTogcGFyc2VOb25Db21wdXRlZE1lbWJlcigpXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIC8vIDExLjMgUG9zdGZpeCBFeHByZXNzaW9uc1xuXG4gICAgZnVuY3Rpb24gcGFyc2VQb3N0Zml4RXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIgPSBwYXJzZUxlZnRIYW5kU2lkZUV4cHJlc3Npb25BbGxvd0NhbGwoKSwgdG9rZW47XG5cbiAgICAgICAgdG9rZW4gPSBsb29rYWhlYWQoKTtcbiAgICAgICAgaWYgKHRva2VuLnR5cGUgIT09IFRva2VuLlB1bmN0dWF0b3IpIHtcbiAgICAgICAgICAgIHJldHVybiBleHByO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKChtYXRjaCgnKysnKSB8fCBtYXRjaCgnLS0nKSkgJiYgIXBlZWtMaW5lVGVybWluYXRvcigpKSB7XG4gICAgICAgICAgICAvLyAxMS4zLjEsIDExLjMuMlxuICAgICAgICAgICAgaWYgKHN0cmljdCAmJiBleHByLnR5cGUgPT09IFN5bnRheC5JZGVudGlmaWVyICYmIGlzUmVzdHJpY3RlZFdvcmQoZXhwci5uYW1lKSkge1xuICAgICAgICAgICAgICAgIHRocm93RXJyb3JUb2xlcmFudCh7fSwgTWVzc2FnZXMuU3RyaWN0TEhTUG9zdGZpeCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoIWlzTGVmdEhhbmRTaWRlKGV4cHIpKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5JbnZhbGlkTEhTSW5Bc3NpZ25tZW50KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguVXBkYXRlRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogbGV4KCkudmFsdWUsXG4gICAgICAgICAgICAgICAgYXJndW1lbnQ6IGV4cHIsXG4gICAgICAgICAgICAgICAgcHJlZml4OiBmYWxzZVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIC8vIDExLjQgVW5hcnkgT3BlcmF0b3JzXG5cbiAgICBmdW5jdGlvbiBwYXJzZVVuYXJ5RXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIHRva2VuLCBleHByO1xuXG4gICAgICAgIHRva2VuID0gbG9va2FoZWFkKCk7XG4gICAgICAgIGlmICh0b2tlbi50eXBlICE9PSBUb2tlbi5QdW5jdHVhdG9yICYmIHRva2VuLnR5cGUgIT09IFRva2VuLktleXdvcmQpIHtcbiAgICAgICAgICAgIHJldHVybiBwYXJzZVBvc3RmaXhFeHByZXNzaW9uKCk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAobWF0Y2goJysrJykgfHwgbWF0Y2goJy0tJykpIHtcbiAgICAgICAgICAgIHRva2VuID0gbGV4KCk7XG4gICAgICAgICAgICBleHByID0gcGFyc2VVbmFyeUV4cHJlc3Npb24oKTtcbiAgICAgICAgICAgIC8vIDExLjQuNCwgMTEuNC41XG4gICAgICAgICAgICBpZiAoc3RyaWN0ICYmIGV4cHIudHlwZSA9PT0gU3ludGF4LklkZW50aWZpZXIgJiYgaXNSZXN0cmljdGVkV29yZChleHByLm5hbWUpKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5TdHJpY3RMSFNQcmVmaXgpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoIWlzTGVmdEhhbmRTaWRlKGV4cHIpKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5JbnZhbGlkTEhTSW5Bc3NpZ25tZW50KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguVXBkYXRlRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogdG9rZW4udmFsdWUsXG4gICAgICAgICAgICAgICAgYXJndW1lbnQ6IGV4cHIsXG4gICAgICAgICAgICAgICAgcHJlZml4OiB0cnVlXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgcmV0dXJuIGV4cHI7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAobWF0Y2goJysnKSB8fCBtYXRjaCgnLScpIHx8IG1hdGNoKCd+JykgfHwgbWF0Y2goJyEnKSkge1xuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguVW5hcnlFeHByZXNzaW9uLFxuICAgICAgICAgICAgICAgIG9wZXJhdG9yOiBsZXgoKS52YWx1ZSxcbiAgICAgICAgICAgICAgICBhcmd1bWVudDogcGFyc2VVbmFyeUV4cHJlc3Npb24oKSxcbiAgICAgICAgICAgICAgICBwcmVmaXg6IHRydWVcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICByZXR1cm4gZXhwcjtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChtYXRjaEtleXdvcmQoJ2RlbGV0ZScpIHx8IG1hdGNoS2V5d29yZCgndm9pZCcpIHx8IG1hdGNoS2V5d29yZCgndHlwZW9mJykpIHtcbiAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LlVuYXJ5RXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogbGV4KCkudmFsdWUsXG4gICAgICAgICAgICAgICAgYXJndW1lbnQ6IHBhcnNlVW5hcnlFeHByZXNzaW9uKCksXG4gICAgICAgICAgICAgICAgcHJlZml4OiB0cnVlXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKHN0cmljdCAmJiBleHByLm9wZXJhdG9yID09PSAnZGVsZXRlJyAmJiBleHByLmFyZ3VtZW50LnR5cGUgPT09IFN5bnRheC5JZGVudGlmaWVyKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5TdHJpY3REZWxldGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGV4cHI7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gcGFyc2VQb3N0Zml4RXhwcmVzc2lvbigpO1xuICAgIH1cblxuICAgIC8vIDExLjUgTXVsdGlwbGljYXRpdmUgT3BlcmF0b3JzXG5cbiAgICBmdW5jdGlvbiBwYXJzZU11bHRpcGxpY2F0aXZlRXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIgPSBwYXJzZVVuYXJ5RXhwcmVzc2lvbigpO1xuXG4gICAgICAgIHdoaWxlIChtYXRjaCgnKicpIHx8IG1hdGNoKCcvJykgfHwgbWF0Y2goJyUnKSkge1xuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguQmluYXJ5RXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogbGV4KCkudmFsdWUsXG4gICAgICAgICAgICAgICAgbGVmdDogZXhwcixcbiAgICAgICAgICAgICAgICByaWdodDogcGFyc2VVbmFyeUV4cHJlc3Npb24oKVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIC8vIDExLjYgQWRkaXRpdmUgT3BlcmF0b3JzXG5cbiAgICBmdW5jdGlvbiBwYXJzZUFkZGl0aXZlRXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIgPSBwYXJzZU11bHRpcGxpY2F0aXZlRXhwcmVzc2lvbigpO1xuXG4gICAgICAgIHdoaWxlIChtYXRjaCgn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91c0FsbG93SW4gPSBzdGF0ZS5hbGxvd0luO1xuICAgICAgICBzdGF0ZS5hbGxvd0luID0gdHJ1ZTtcblxuICAgICAgICBleHByID0gcGFyc2VTaGlmdEV4cHJlc3Npb24oKTtcblxuICAgICAgICB3aGlsZSAobWF0Y2goJzwnKSB8fCBtYXRjaCgnPicpIHx8IG1hdGNoKCc8PScpIHx8IG1hdGNoKCc+PScpIHx8IChwcmV2aW91c0FsbG93SW4gJiYgbWF0Y2hLZXl3b3JkKCdpbicpKSB8fCBtYXRjaEtleXdvcmQoJ2luc3RhbmNlb2YnKSkge1xuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguQmluYXJ5RXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogbGV4KCkudmFsdWUsXG4gICAgICAgICAgICAgICAgbGVmdDogZXhwcixcbiAgICAgICAgICAgICAgICByaWdodDogcGFyc2VTaGlmdEV4cHJlc3Npb24oKVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIHN0YXRlLmFsbG93SW4gPSBwcmV2aW91c0FsbG93SW47XG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIC8vIDExLjkgRXF1YWxpdHkgT3BlcmF0b3JzXG5cbiAgICBmdW5jdGlvbiBwYXJzZUVxdWFsaXR5RXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIgPSBwYXJzZVJlbGF0aW9uYWxFeHByZXNzaW9uKCk7XG5cbiAgICAgICAgd2hpbGUgKG1hdGNoKCc9PScpIHx8IG1hdGNoKCchPScpIHx8IG1hdGNoKCc9PT0nKSB8fCBtYXRjaCgnIT09JykpIHtcbiAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LkJpbmFyeUV4cHJlc3Npb24sXG4gICAgICAgICAgICAgICAgb3BlcmF0b3I6IGxleCgpLnZhbHVlLFxuICAgICAgICAgICAgICAgIGxlZnQ6IGV4cHIsXG4gICAgICAgICAgICAgICAgcmlnaHQ6IHBhcnNlUmVsYXRpb25hbEV4cHJlc3Npb24oKVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIC8vIDExLjEwIEJpbmFyeSBCaXR3aXNlIE9wZXJhdG9yc1xuXG4gICAgZnVuY3Rpb24gcGFyc2VCaXR3aXNlQU5ERXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIgPSBwYXJzZUVxdWFsaXR5RXhwcmVzc2lvbigpO1xuXG4gICAgICAgIHdoaWxlIChtYXRjaCgnJicpKSB7XG4gICAgICAgICAgICBsZXgoKTtcbiAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LkJpbmFyeUV4cHJlc3Npb24sXG4gICAgICAgICAgICAgICAgb3BlcmF0b3I6ICcmJyxcbiAgICAgICAgICAgICAgICBsZWZ0OiBleHByLFxuICAgICAgICAgICAgICAgIHJpZ2h0OiBwYXJzZUVxdWFsaXR5RXhwcmVzc2lvbigpXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGV4cHI7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2VCaXR3aXNlWE9SRXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIgPSBwYXJzZUJpdHdpc2VBTkRFeHByZXNzaW9uKCk7XG5cbiAgICAgICAgd2hpbGUgKG1hdGNoKCdeJykpIHtcbiAgICAgICAgICAgIGxleCgpO1xuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguQmluYXJ5RXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogJ14nLFxuICAgICAgICAgICAgICAgIGxlZnQ6IGV4cHIsXG4gICAgICAgICAgICAgICAgcmlnaHQ6IHBhcnNlQml0d2lzZUFOREV4cHJlc3Npb24oKVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBhcnNlQml0d2lzZU9SRXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIgPSBwYXJzZUJpdHdpc2VYT1JFeHByZXNzaW9uKCk7XG5cbiAgICAgICAgd2hpbGUgKG1hdGNoKCd8JykpIHtcbiAgICAgICAgICAgIGxleCgpO1xuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguQmluYXJ5RXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogJ3wnLFxuICAgICAgICAgICAgICAgIGxlZnQ6IGV4cHIsXG4gICAgICAgICAgICAgICAgcmlnaHQ6IHBhcnNlQml0d2lzZVhPUkV4cHJlc3Npb24oKVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIC8vIDExLjExIEJpbmFyeSBMb2dpY2FsIE9wZXJhdG9yc1xuXG4gICAgZnVuY3Rpb24gcGFyc2VMb2dpY2FsQU5ERXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIGV4cHIgPSBwYXJzZUJpdHdpc2VPUkV4cHJlc3Npb24oKTtcblxuICAgICAgICB3aGlsZSAobWF0Y2goJyYmJykpIHtcbiAgICAgICAgICAgIGxleCgpO1xuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguTG9naWNhbEV4cHJlc3Npb24sXG4gICAgICAgICAgICAgICAgb3BlcmF0b3I6ICcmJicsXG4gICAgICAgICAgICAgICAgbGVmdDogZXhwcixcbiAgICAgICAgICAgICAgICByaWdodDogcGFyc2VCaXR3aXNlT1JFeHByZXNzaW9uKClcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwYXJzZUxvZ2ljYWxPUkV4cHJlc3Npb24oKSB7XG4gICAgICAgIHZhciBleHByID0gcGFyc2VMb2dpY2FsQU5ERXhwcmVzc2lvbigpO1xuXG4gICAgICAgIHdoaWxlIChtYXRjaCgnfHwnKSkge1xuICAgICAgICAgICAgbGV4KCk7XG4gICAgICAgICAgICBleHByID0ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5Mb2dpY2FsRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICBvcGVyYXRvcjogJ3x8JyxcbiAgICAgICAgICAgICAgICBsZWZ0OiBleHByLFxuICAgICAgICAgICAgICAgIHJpZ2h0OiBwYXJzZUxvZ2ljYWxBTkRFeHByZXNzaW9uKClcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cbiAgICAvLyAxMS4xMiBDb25kaXRpb25hbCBPcGVyYXRvclxuXG4gICAgZnVuY3Rpb24gcGFyc2VDb25kaXRpb25hbEV4cHJlc3Npb24oKSB7XG4gICAgICAgIHZhciBleHByLCBwcmV2aW91c0FsbG93SW4sIGNvbnNlcXVlbnQ7XG5cbiAgICAgICAgZXhwciA9IHBhcnNlTG9naWNhbE9SRXhwcmVzc2lvbigpO1xuXG4gICAgICAgIGlmIChtYXRjaCgnPycpKSB7XG4gICAgICAgICAgICBsZXgoKTtcbiAgICAgICAgICAgIHByZXZpb3VzQWxsb3dJbiA9IHN0YXRlLmFsbG93SW47XG4gICAgICAgICAgICBzdGF0ZS5hbGxvd0luID0gdHJ1ZTtcbiAgICAgICAgICAgIGNvbnNlcXVlbnQgPSBwYXJzZUFzc2lnbm1lbnRFeHByZXNzaW9uKCk7XG4gICAgICAgICAgICBzdGF0ZS5hbGxvd0luID0gcHJldmlvdXNBbGxvd0luO1xuICAgICAgICAgICAgZXhwZWN0KCc6Jyk7XG5cbiAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LkNvbmRpdGlvbmFsRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICB0ZXN0OiBleHByLFxuICAgICAgICAgICAgICAgIGNvbnNlcXVlbnQ6IGNvbnNlcXVlbnQsXG4gICAgICAgICAgICAgICAgYWx0ZXJuYXRlOiBwYXJzZUFzc2lnbm1lbnRFeHByZXNzaW9uKClcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cbiAgICAvLyAxMS4xMyBBc3NpZ25tZW50IE9wZXJhdG9yc1xuXG4gICAgZnVuY3Rpb24gcGFyc2VBc3NpZ25tZW50RXhwcmVzc2lvbigpIHtcbiAgICAgICAgdmFyIHRva2VuLCBleHByO1xuXG4gICAgICAgIHRva2VuID0gbG9va2FoZWFkKCk7XG4gICAgICAgIGV4cHIgPSBwYXJzZUNvbmRpdGlvbmFsRXhwcmVzc2lvbigpO1xuXG4gICAgICAgIGlmIChtYXRjaEFzc2lnbigpKSB7XG4gICAgICAgICAgICAvLyBMZWZ0SGFuZFNpZGVFeHByZXNzaW9uXG4gICAgICAgICAgICBpZiAoIWlzTGVmdEhhbmRTaWRlKGV4cHIpKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5JbnZhbGlkTEhTSW5Bc3NpZ25tZW50KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gMTEuMTMuMVxuICAgICAgICAgICAgaWYgKHN0cmljdCAmJiBleHByLnR5cGUgPT09IFN5bnRheC5JZGVudGlmaWVyICYmIGlzUmVzdHJpY3RlZFdvcmQoZXhwci5uYW1lKSkge1xuICAgICAgICAgICAgICAgIHRocm93RXJyb3JUb2xlcmFudCh0b2tlbiwgTWVzc2FnZXMuU3RyaWN0TEhTQXNzaWdubWVudCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LkFzc2lnbm1lbnRFeHByZXNzaW9uLFxuICAgICAgICAgICAgICAgIG9wZXJhdG9yOiBsZXgoKS52YWx1ZSxcbiAgICAgICAgICAgICAgICBsZWZ0OiBleHByLFxuICAgICAgICAgICAgICAgIHJpZ2h0OiBwYXJzZUFzc2lnbm1lbnRFeHByZXNzaW9uKClcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cbiAgICAvLyAxMS4xNCBDb21tYSBPcGVyYXRvclxuXG4gICAgZnVuY3Rpb24gcGFyc2VFeHByZXNzaW9uKCkge1xuICAgICAgICB2YXIgZXhwciA9IHBhcnNlQXNzaWdubWVudEV4cHJlc3Npb24oKTtcblxuICAgICAgICBpZiAobWF0Y2goJywnKSkge1xuICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguU2VxdWVuY2VFeHByZXNzaW9uLFxuICAgICAgICAgICAgICAgIGV4cHJlc3Npb25zOiBbIGV4cHIgXVxuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgaWYgKCFtYXRjaCgnLCcpKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBsZXgoKTtcbiAgICAgICAgICAgICAgICBleHByLmV4cHJlc3Npb25zLnB1c2gocGFyc2VBc3NpZ25tZW50RXhwcmVzc2lvbigpKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBleHByO1xuICAgIH1cblxuICAgIC8vIDEyLjEgQmxvY2tcblxuICAgIGZ1bmN0aW9uIHBhcnNlU3RhdGVtZW50TGlzdCgpIHtcbiAgICAgICAgdmFyIGxpc3QgPSBbXSxcbiAgICAgICAgICAgIHN0YXRlbWVudDtcblxuICAgICAgICB3aGlsZSAoaW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgICAgIGlmIChtYXRjaCgnfScpKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzdGF0ZW1lbnQgPSBwYXJzZVNvdXJjZUVsZW1lbnQoKTtcbiAgICAgICAgICAgIGlmICh0eXBlb2Ygc3RhdGVtZW50ID09PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbGlzdC5wdXNoKHN0YXRlbWVudCk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gbGlzdDtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwYXJzZUJsb2NrKCkge1xuICAgICAgICB2YXIgYmxvY2s7XG5cbiAgICAgICAgZXhwZWN0KCd7Jyk7XG5cbiAgICAgICAgYmxvY2sgPSBwYXJzZVN0YXRlbWVudExpc3QoKTtcblxuICAgICAgICBleHBlY3QoJ30nKTtcblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkJsb2NrU3RhdGVtZW50LFxuICAgICAgICAgICAgYm9keTogYmxvY2tcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyAxMi4yIFZhcmlhYmxlIFN0YXRlbWVudFxuXG4gICAgZnVuY3Rpb24gcGFyc2VWYXJpYWJsZUlkZW50aWZpZXIoKSB7XG4gICAgICAgIHZhciB0b2tlbiA9IGxleCgpO1xuXG4gICAgICAgIGlmICh0b2tlbi50eXBlICE9PSBUb2tlbi5JZGVudGlmaWVyKSB7XG4gICAgICAgICAgICB0aHJvd1VuZXhwZWN0ZWQodG9rZW4pO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHR5cGU6IFN5bnRheC5JZGVudGlmaWVyLFxuICAgICAgICAgICAgbmFtZTogdG9rZW4udmFsdWVcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwYXJzZVZhcmlhYmxlRGVjbGFyYXRpb24oa2luZCkge1xuICAgICAgICB2YXIgaWQgPSBwYXJzZVZhcmlhYmxlSWRlbnRpZmllcigpLFxuICAgICAgICAgICAgaW5pdCA9IG51bGw7XG5cbiAgICAgICAgLy8gMTIuMi4xXG4gICAgICAgIGlmIChzdHJpY3QgJiYgaXNSZXN0cmljdGVkV29yZChpZC5uYW1lKSkge1xuICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5TdHJpY3RWYXJOYW1lKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChraW5kID09PSAnY29uc3QnKSB7XG4gICAgICAgICAgICBleHBlY3QoJz0nKTtcbiAgICAgICAgICAgIGluaXQgPSBwYXJzZUFzc2lnbm1lbnRFeHByZXNzaW9uKCk7XG4gICAgICAgIH0gZWxzZSBpZiAobWF0Y2goJz0nKSkge1xuICAgICAgICAgICAgbGV4KCk7XG4gICAgICAgICAgICBpbml0ID0gcGFyc2VBc3NpZ25tZW50RXhwcmVzc2lvbigpO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHR5cGU6IFN5bnRheC5WYXJpYWJsZURlY2xhcmF0b3IsXG4gICAgICAgICAgICBpZDogaWQsXG4gICAgICAgICAgICBpbml0OiBpbml0XG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2VWYXJpYWJsZURlY2xhcmF0aW9uTGlzdChraW5kKSB7XG4gICAgICAgIHZhciBsaXN0ID0gW107XG5cbiAgICAgICAgZG8ge1xuICAgICAgICAgICAgbGlzdC5wdXNoKHBhcnNlVmFyaWFibGVEZWNsYXJhdGlvbihraW5kKSk7XG4gICAgICAgICAgICBpZiAoIW1hdGNoKCcsJykpIHtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGxleCgpO1xuICAgICAgICB9IHdoaWxlIChpbmRleCA8IGxlbmd0aCk7XG5cbiAgICAgICAgcmV0dXJuIGxpc3Q7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2VWYXJpYWJsZVN0YXRlbWVudCgpIHtcbiAgICAgICAgdmFyIGRlY2xhcmF0aW9ucztcblxuICAgICAgICBleHBlY3RLZXl3b3JkKCd2YXInKTtcblxuICAgICAgICBkZWNsYXJhdGlvbnMgPSBwYXJzZVZhcmlhYmxlRGVjbGFyYXRpb25MaXN0KCk7XG5cbiAgICAgICAgY29uc3VtZVNlbWljb2xvbigpO1xuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBTeW50YXguVmFyaWFibGVEZWNsYXJhdGlvbixcbiAgICAgICAgICAgIGRlY2xhcmF0aW9uczogZGVjbGFyYXRpb25zLFxuICAgICAgICAgICAga2luZDogJ3ZhcidcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyBraW5kIG1heSBiZSBgY29uc3RgIG9yIGBsZXRgXG4gICAgLy8gQm90aCBhcmUgZXhwZXJpbWVudGFsIGFuZCBub3QgaW4gdGhlIHNwZWNpZmljYXRpb24geWV0LlxuICAgIC8vIHNlZSBodHRwOi8vd2lraS5lY21hc2NyaXB0Lm9yZy9kb2t1LnBocD9pZD1oYXJtb255OmNvbnN0XG4gICAgLy8gYW5kIGh0dHA6Ly93aWtpLmVjbWFzY3JpcHQub3JnL2Rva3UucGhwP2lkPWhhcm1vbnk6bGV0XG4gICAgZnVuY3Rpb24gcGFyc2VDb25zdExldERlY2xhcmF0aW9uKGtpbmQpIHtcbiAgICAgICAgdmFyIGRlY2xhcmF0aW9ucztcblxuICAgICAgICBleHBlY3RLZXl3b3JkKGtpbmQpO1xuXG4gICAgICAgIGRlY2xhcmF0aW9ucyA9IHBhcnNlVmFyaWFibGVEZWNsYXJhdGlvbkxpc3Qoa2luZCk7XG5cbiAgICAgICAgY29uc3VtZVNlbWljb2xvbigpO1xuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBTeW50YXguVmFyaWFibGVEZWNsYXJhdGlvbixcbiAgICAgICAgICAgIGRlY2xhcmF0aW9uczogZGVjbGFyYXRpb25zLFxuICAgICAgICAgICAga2luZDoga2luZFxuICAgICAgICB9O1xuICAgIH1cblxuICAgIC8vIDEyLjMgRW1wdHkgU3RhdGVtZW50XG5cbiAgICBmdW5jdGlvbiBwYXJzZUVtcHR5U3RhdGVtZW50KCkge1xuICAgICAgICBleHBlY3QoJzsnKTtcblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkVtcHR5U3RhdGVtZW50XG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgLy8gMTIuNCBFeHByZXNzaW9uIFN0YXRlbWVudFxuXG4gICAgZnVuY3Rpb24gcGFyc2VFeHByZXNzaW9uU3RhdGVtZW50KCkge1xuICAgICAgICB2YXIgZXhwciA9IHBhcnNlRXhwcmVzc2lvbigpO1xuXG4gICAgICAgIGNvbnN1bWVTZW1pY29sb24oKTtcblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkV4cHJlc3Npb25TdGF0ZW1lbnQsXG4gICAgICAgICAgICBleHByZXNzaW9uOiBleHByXG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgLy8gMTIuNSBJZiBzdGF0ZW1lbnRcblxuICAgIGZ1bmN0aW9uIHBhcnNlSWZTdGF0ZW1lbnQoKSB7XG4gICAgICAgIHZhciB0ZXN0LCBjb25zZXF1ZW50LCBhbHRlcm5hdGU7XG5cbiAgICAgICAgZXhwZWN0S2V5d29yZCgnaWYnKTtcblxuICAgICAgICBleHBlY3QoJygnKTtcblxuICAgICAgICB0ZXN0ID0gcGFyc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xhcmF0aW9uLFxuICAgICAgICAgICAgZGVjbGFyYXRpb25zOiBwYXJzZVZhcmlhYmxlRGVjbGFyYXRpb25MaXN0KCksXG4gICAgICAgICAgICBraW5kOiB0b2tlbi52YWx1ZVxuICAgICAgICB9O1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBhcnNlRm9yU3RhdGVtZW50KCkge1xuICAgICAgICB2YXIgaW5pdCwgdGVzdCwgdXBkYXRlLCBsZWZ0LCByaWdodCwgYm9keSwgb2xkSW5JdGVyYXRpb247XG5cbiAgICAgICAgaW5pdCA9IHRlc3QgPSB1cGRhdGUgPSBudWxsO1xuXG4gICAgICAgIGV4cGVjdEtleXdvcmQoJ2ZvcicpO1xuXG4gICAgICAgIGV4cGVjdCgnKCcpO1xuXG4gICAgICAgIGlmIChtYXRjaCgnOycpKSB7XG4gICAgICAgICAgICBsZXgoKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmIChtYXRjaEtleXdvcmQoJ3ZhcicpIHx8IG1hdGNoS2V5d29yZCgnbGV0JykpIHtcbiAgICAgICAgICAgICAgICBzdGF0ZS5hbGxvd0luID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgaW5pdCA9IHBhcnNlRm9yVmFyaWFibGVEZWNsYXJhdGlvbigpO1xuICAgICAgICAgICAgICAgIHN0YXRlLmFsbG93SW4gPSB0cnVlO1xuXG4gICAgICAgICAgICAgICAgaWYgKGluaXQuZGVjbGFyYXRpb25zLmxlbmd0aCA9PT0gMSAmJiBtYXRjaEtleXdvcmQoJ2luJykpIHtcbiAgICAgICAgICAgICAgICAgICAgbGV4KCk7XG4gICAgICAgICAgICAgICAgICAgIGxlZnQgPSBpbml0O1xuICAgICAgICAgICAgICAgICAgICByaWdodCA9IHBhcnNlRXhwcmVzc2lvbigpO1xuICAgICAgICAgICAgICAgICAgICBpbml0ID0gbnVsbDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHN0YXRlLmFsbG93SW4gPSBmYWxzZTtcbiAgICAgICAgICAgICAgICBpbml0ID0gcGFyc2VFeHByZXNzaW9uKCk7XG4gICAgICAgICAgICAgICAgc3RhdGUuYWxsb3dJbiA9IHRydWU7XG5cbiAgICAgICAgICAgICAgICBpZiAobWF0Y2hLZXl3b3JkKCdpbicpKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIExlZnRIYW5kU2lkZUV4cHJlc3Npb25cbiAgICAgICAgICAgICAgICAgICAgaWYgKCFpc0xlZnRIYW5kU2lkZShpbml0KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHt9LCBNZXNzYWdlcy5JbnZhbGlkTEhTSW5Gb3JJbik7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBsZXgoKTtcbiAgICAgICAgICAgICAgICAgICAgbGVmdCA9IGluaXQ7XG4gICAgICAgICAgICAgICAgICAgIHJpZ2h0ID0gcGFyc2VFeHByZXNzaW9uKCk7XG4gICAgICAgICAgICAgICAgICAgIGluaXQgPSBudWxsO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHR5cGVvZiBsZWZ0ID09PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgIGV4cGVjdCgnOycpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHR5cGVvZiBsZWZ0ID09PSAndW5kZWZpbmVkJykge1xuXG4gICAgICAgICAgICBpZiAoIW1hdGNoKCc7JykpIHtcbiAgICAgICAgICAgICAgICB0ZXN0ID0gcGFyc2VFeHByZXNzaW9uKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBleHBlY3QoJzsnKTtcblxuICAgICAgICAgICAgaWYgKCFtYXRjaCgnKScpKSB7XG4gICAgICAgICAgICAgICAgdXBkYXRlID0gcGFyc2VFeHByZXNzaW9uKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBleHBlY3QoJyknKTtcblxuICAgICAgICBvbGRJbkl0ZXJhdGlvbiA9IHN0YXRlLmluSXRlcmF0aW9uO1xuICAgICAgICBzdGF0ZS5pbkl0ZXJhdGlvbiA9IHRydWU7XG5cbiAgICAgICAgYm9keSA9IHBhcnNlU3RhdGVtZW50KCk7XG5cbiAgICAgICAgc3RhdGUuaW5JdGVyYXRpb24gPSBvbGRJbkl0ZXJhdGlvbjtcblxuICAgICAgICBpZiAodHlwZW9mIGxlZnQgPT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5Gb3JTdGF0ZW1lbnQsXG4gICAgICAgICAgICAgICAgaW5pdDogaW5pdCxcbiAgICAgICAgICAgICAgICB0ZXN0OiB0ZXN0LFxuICAgICAgICAgICAgICAgIHVwZGF0ZTogdXBkYXRlLFxuICAgICAgICAgICAgICAgIGJvZHk6IGJvZHlcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkZvckluU3RhdGVtZW50LFxuICAgICAgICAgICAgbGVmdDogbGVmdCxcbiAgICAgICAgICAgIHJpZ2h0OiByaWdodCxcbiAgICAgICAgICAgIGJvZHk6IGJvZHksXG4gICAgICAgICAgICBlYWNoOiBmYWxzZVxuICAgICAgICB9O1xuICAgIH1cblxuICAgIC8vIDEyLjcgVGhlIGNvbnRpbnVlIHN0YXRlbWVudFxuXG4gICAgZnVuY3Rpb24gcGFyc2VDb250aW51ZVN0YXRlbWVudCgpIHtcbiAgICAgICAgdmFyIHRva2VuLCBsYWJlbCA9IG51bGw7XG5cbiAgICAgICAgZXhwZWN0S2V5d29yZCgnY29udGludWUnKTtcblxuICAgICAgICAvLyBPcHRpbWl6ZSB0aGUgbW9zdCBjb21tb24gZm9ybTogJ2NvbnRpbnVlOycuXG4gICAgICAgIGlmIChzb3VyY2VbaW5kZXhdID09PSAnOycpIHtcbiAgICAgICAgICAgIGxleCgpO1xuXG4gICAgICAgICAgICBpZiAoIXN0YXRlLmluSXRlcmF0aW9uKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuSWxsZWdhbENvbnRpbnVlKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguQ29udGludWVTdGF0ZW1lbnQsXG4gICAgICAgICAgICAgICAgbGFiZWw6IG51bGxcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocGVla0xpbmVUZXJtaW5hdG9yKCkpIHtcbiAgICAgICAgICAgIGlmICghc3RhdGUuaW5JdGVyYXRpb24pIHtcbiAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKHt9LCBNZXNzYWdlcy5JbGxlZ2FsQ29udGludWUpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5Db250aW51ZVN0YXRlbWVudCxcbiAgICAgICAgICAgICAgICBsYWJlbDogbnVsbFxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgICAgIHRva2VuID0gbG9va2FoZWFkKCk7XG4gICAgICAgIGlmICh0b2tlbi50eXBlID09PSBUb2tlbi5JZGVudGlmaWVyKSB7XG4gICAgICAgICAgICBsYWJlbCA9IHBhcnNlVmFyaWFibGVJZGVudGlmaWVyKCk7XG5cbiAgICAgICAgICAgIGlmICghT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHN0YXRlLmxhYmVsU2V0LCBsYWJlbC5uYW1lKSkge1xuICAgICAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLlVua25vd25MYWJlbCwgbGFiZWwubmFtZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBjb25zdW1lU2VtaWNvbG9uKCk7XG5cbiAgICAgICAgaWYgKGxhYmVsID09PSBudWxsICYmICFzdGF0ZS5pbkl0ZXJhdGlvbikge1xuICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuSWxsZWdhbENvbnRpbnVlKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBTeW50YXguQ29udGludWVTdGF0ZW1lbnQsXG4gICAgICAgICAgICBsYWJlbDogbGFiZWxcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyAxMi44IFRoZSBicmVhayBzdGF0ZW1lbnRcblxuICAgIGZ1bmN0aW9uIHBhcnNlQnJlYWtTdGF0ZW1lbnQoKSB7XG4gICAgICAgIHZhciB0b2tlbiwgbGFiZWwgPSBudWxsO1xuXG4gICAgICAgIGV4cGVjdEtleXdvcmQoJ2JyZWFrJyk7XG5cbiAgICAgICAgLy8gT3B0aW1pemUgdGhlIG1vc3QgY29tbW9uIGZvcm06ICdicmVhazsnLlxuICAgICAgICBpZiAoc291cmNlW2luZGV4XSA9PT0gJzsnKSB7XG4gICAgICAgICAgICBsZXgoKTtcblxuICAgICAgICAgICAgaWYgKCEoc3RhdGUuaW5JdGVyYXRpb24gfHwgc3RhdGUuaW5Td2l0Y2gpKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuSWxsZWdhbEJyZWFrKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguQnJlYWtTdGF0ZW1lbnQsXG4gICAgICAgICAgICAgICAgbGFiZWw6IG51bGxcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocGVla0xpbmVUZXJtaW5hdG9yKCkpIHtcbiAgICAgICAgICAgIGlmICghKHN0YXRlLmluSXRlcmF0aW9uIHx8IHN0YXRlLmluU3dpdGNoKSkge1xuICAgICAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLklsbGVnYWxCcmVhayk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LkJyZWFrU3RhdGVtZW50LFxuICAgICAgICAgICAgICAgIGxhYmVsOiBudWxsXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgdG9rZW4gPSBsb29rYWhlYWQoKTtcbiAgICAgICAgaWYgKHRva2VuLnR5cGUgPT09IFRva2VuLklkZW50aWZpZXIpIHtcbiAgICAgICAgICAgIGxhYmVsID0gcGFyc2VWYXJpYWJsZUlkZW50aWZpZXIoKTtcblxuICAgICAgICAgICAgaWYgKCFPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoc3RhdGUubGFiZWxTZXQsIGxhYmVsLm5hbWUpKSB7XG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuVW5rbm93bkxhYmVsLCBsYWJlbC5uYW1lKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN1bWVTZW1pY29sb24oKTtcblxuICAgICAgICBpZiAobGFiZWwgPT09IG51bGwgJiYgIShzdGF0ZS5pbkl0ZXJhdGlvbiB8fCBzdGF0ZS5pblN3aXRjaCkpIHtcbiAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLklsbGVnYWxCcmVhayk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkJyZWFrU3RhdGVtZW50LFxuICAgICAgICAgICAgbGFiZWw6IGxhYmVsXG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgLy8gMTIuOSBUaGUgcmV0dXJuIHN0YXRlbWVudFxuXG4gICAgZnVuY3Rpb24gcGFyc2VSZXR1cm5TdGF0ZW1lbnQoKSB7XG4gICAgICAgIHZhciB0b2tlbiwgYXJndW1lbnQgPSBudWxsO1xuXG4gICAgICAgIGV4cGVjdEtleXdvcmQoJ3JldHVybicpO1xuXG4gICAgICAgIGlmICghc3RhdGUuaW5GdW5jdGlvbkJvZHkpIHtcbiAgICAgICAgICAgIHRocm93RXJyb3JUb2xlcmFudCh7fSwgTWVzc2FnZXMuSWxsZWdhbFJldHVybik7XG4gICAgICAgIH1cblxuICAgICAgICAvLyAncmV0dXJuJyBmb2xsb3dlZCBieSBhIHNwYWNlIGFuZCBhbiBpZGVudGlmaWVyIGlzIHZlcnkgY29tbW9uLlxuICAgICAgICBpZiAoc291cmNlW2luZGV4XSA9PT0gJyAnKSB7XG4gICAgICAgICAgICBpZiAoaXNJZGVudGlmaWVyU3RhcnQoc291cmNlW2luZGV4ICsgMV0pKSB7XG4gICAgICAgICAgICAgICAgYXJndW1lbnQgPSBwYXJzZUV4cHJlc3Npb24oKTtcbiAgICAgICAgICAgICAgICBjb25zdW1lU2VtaWNvbG9uKCk7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogU3ludGF4LlJldHVyblN0YXRlbWVudCxcbiAgICAgICAgICAgICAgICAgICAgYXJndW1lbnQ6IGFyZ3VtZW50XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChwZWVrTGluZVRlcm1pbmF0b3IoKSkge1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguUmV0dXJuU3RhdGVtZW50LFxuICAgICAgICAgICAgICAgIGFyZ3VtZW50OiBudWxsXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKCFtYXRjaCgnOycpKSB7XG4gICAgICAgICAgICB0b2tlbiA9IGxvb2thaGVhZCgpO1xuICAgICAgICAgICAgaWYgKCFtYXRjaCgnfScpICYmIHRva2VuLnR5cGUgIT09IFRva2VuLkVPRikge1xuICAgICAgICAgICAgICAgIGFyZ3VtZW50ID0gcGFyc2VFeHByZXNzaW9uKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBjb25zdW1lU2VtaWNvbG9uKCk7XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHR5cGU6IFN5bnRheC5SZXR1cm5TdGF0ZW1lbnQsXG4gICAgICAgICAgICBhcmd1bWVudDogYXJndW1lbnRcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyAxMi4xMCBUaGUgd2l0aCBzdGF0ZW1lbnRcblxuICAgIGZ1bmN0aW9uIHBhcnNlV2l0aFN0YXRlbWVudCgpIHtcbiAgICAgICAgdmFyIG9iamVjdCwgYm9keTtcblxuICAgICAgICBpZiAoc3RyaWN0KSB7XG4gICAgICAgICAgICB0aHJvd0Vycm9yVG9sZXJhbnQoe30sIE1lc3NhZ2VzLlN0cmljdE1vZGVXaXRoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGV4cGVjdEtleXdvcmQoJ3dpdGgnKTtcblxuICAgICAgICBleHBlY3QoJygnKTtcblxuICAgICAgICBvYmplY3QgPSBwYXJzZUV4cHJlc3Npb24oKTtcblxuICAgICAgICBleHBlY3QoJyknKTtcblxuICAgICAgICBib2R5ID0gcGFyc2VTdGF0ZW1lbnQoKTtcblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LldpdGhTdGF0ZW1lbnQsXG4gICAgICAgICAgICBvYmplY3Q6IG9iamVjdCxcbiAgICAgICAgICAgIGJvZHk6IGJvZHlcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyAxMi4xMCBUaGUgc3dpdGggc3RhdGVtZW50XG5cbiAgICBmdW5jdGlvbiBwYXJzZVN3aXRjaENhc2UoKSB7XG4gICAgICAgIHZhciB0ZXN0LFxuICAgICAgICAgICAgY29uc2VxdWVudCA9IFtdLFxuICAgICAgICAgICAgc3RhdGVtZW50O1xuXG4gICAgICAgIGlmIChtYXRjaEtleXdvcmQoJ2RlZmF1bHQnKSkge1xuICAgICAgICAgICAgbGV4KCk7XG4gICAgICAgICAgICB0ZXN0ID0gbnVsbDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGV4cGVjdEtleXdvcmQoJ2Nhc2UnKTtcbiAgICAgICAgICAgIHRlc3QgPSBwYXJzZUV4cHJlc3Npb24oKTtcbiAgICAgICAgfVxuICAgICAgICBleHBlY3QoJzonKTtcblxuICAgICAgICB3aGlsZSAoaW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgICAgIGlmIChtYXRjaCgnfScpIHx8IG1hdGNoS2V5d29yZCgnZGVmYXVsdCcpIHx8IG1hdGNoS2V5d29yZCgnY2FzZScpKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzdGF0ZW1lbnQgPSBwYXJzZVN0YXRlbWVudCgpO1xuICAgICAgICAgICAgaWYgKHR5cGVvZiBzdGF0ZW1lbnQgPT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjb25zZXF1ZW50LnB1c2goc3RhdGVtZW50KTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBTeW50YXguU3dpdGNoQ2FzZSxcbiAgICAgICAgICAgIHRlc3Q6IHRlc3QsXG4gICAgICAgICAgICBjb25zZXF1ZW50OiBjb25zZXF1ZW50XG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2VTd2l0Y2hTdGF0ZW1lbnQoKSB7XG4gICAgICAgIHZhciBkaXNjcmltaW5hbnQsIGNhc2VzLCBjbGF1c2UsIG9sZEluU3dpdGNoLCBkZWZhdWx0Rm91bmQ7XG5cbiAgICAgICAgZXhwZWN0S2V5d29yZCgnc3dpdGNoJyk7XG5cbiAgICAgICAgZXhwZWN0KCcoJyk7XG5cbiAgICAgICAgZGlzY3JpbWluYW50ID0gcGFyc2VFeHByZXNzaW9uKCk7XG5cbiAgICAgICAgZXhwZWN0KCcpJyk7XG5cbiAgICAgICAgZXhwZWN0KCd7Jyk7XG5cbiAgICAgICAgY2FzZXMgPSBbXTtcblxuICAgICAgICBpZiAobWF0Y2goJ30nKSkge1xuICAgICAgICAgICAgbGV4KCk7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5Td2l0Y2hTdGF0ZW1lbnQsXG4gICAgICAgICAgICAgICAgZGlzY3JpbWluYW50OiBkaXNjcmltaW5hbnQsXG4gICAgICAgICAgICAgICAgY2FzZXM6IGNhc2VzXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgb2xkSW5Td2l0Y2ggPSBzdGF0ZS5pblN3aXRjaDtcbiAgICAgICAgc3RhdGUuaW5Td2l0Y2ggPSB0cnVlO1xuICAgICAgICBkZWZhdWx0Rm91bmQgPSBmYWxzZTtcblxuICAgICAgICB3aGlsZSAoaW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgICAgIGlmIChtYXRjaCgnfScpKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjbGF1c2UgPSBwYXJzZVN3aXRjaENhc2UoKTtcbiAgICAgICAgICAgIGlmIChjbGF1c2UudGVzdCA9PT0gbnVsbCkge1xuICAgICAgICAgICAgICAgIGlmIChkZWZhdWx0Rm91bmQpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuTXVsdGlwbGVEZWZhdWx0c0luU3dpdGNoKTtcbiAgICAgICAgICAgIC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nNlQmxvY2soKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChoYW5kbGVycy5sZW5ndGggPT09IDAgJiYgIWZpbmFsaXplcikge1xuICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuTm9DYXRjaE9yRmluYWxseSk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LlRyeVN0YXRlbWVudCxcbiAgICAgICAgICAgIGJsb2NrOiBibG9jayxcbiAgICAgICAgICAgIGd1YXJkZWRIYW5kbGVyczogW10sXG4gICAgICAgICAgICBoYW5kbGVyczogaGFuZGxlcnMsXG4gICAgICAgICAgICBmaW5hbGl6ZXI6IGZpbmFsaXplclxuICAgICAgICB9O1xuICAgIH1cblxuICAgIC8vIDEyLjE1IFRoZSBkZWJ1Z2dlciBzdGF0ZW1lbnRcblxuICAgIGZ1bmN0aW9uIHBhcnNlRGVidWdnZXJTdGF0ZW1lbnQoKSB7XG4gICAgICAgIGV4cGVjdEtleXdvcmQoJ2RlYnVnZ2VyJyk7XG5cbiAgICAgICAgY29uc3VtZVNlbWljb2xvbigpO1xuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBTeW50YXguRGVidWdnZXJTdGF0ZW1lbnRcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyAxMiBTdGF0ZW1lbnRzXG5cbiAgICBmdW5jdGlvbiBwYXJzZVN0YXRlbWVudCgpIHtcbiAgICAgICAgdmFyIHRva2VuID0gbG9va2FoZWFkKCksXG4gICAgICAgICAgICBleHByLFxuICAgICAgICAgICAgbGFiZWxlZEJvZHk7XG5cbiAgICAgICAgaWYgKHRva2VuLnR5cGUgPT09IFRva2VuLkVPRikge1xuICAgICAgICAgICAgdGhyb3dVbmV4cGVjdGVkKHRva2VuKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0b2tlbi50eXBlID09PSBUb2tlbi5QdW5jdHVhdG9yKSB7XG4gICAgICAgICAgICBzd2l0Y2ggKHRva2VuLnZhbHVlKSB7XG4gICAgICAgICAgICBjYXNlICc7JzpcbiAgICAgICAgICAgICAgICByZXR1cm4gcGFyc2VFbXB0eVN0YXRlbWVudCgpO1xuICAgICAgICAgICAgY2FzZSAneyc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlQmxvY2soKTtcbiAgICAgICAgICAgIGNhc2UgJygnOlxuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZUV4cHJlc3Npb25TdGF0ZW1lbnQoKTtcbiAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodG9rZW4udHlwZSA9PT0gVG9rZW4uS2V5d29yZCkge1xuICAgICAgICAgICAgc3dpdGNoICh0b2tlbi52YWx1ZSkge1xuICAgICAgICAgICAgY2FzZSAnYnJlYWsnOlxuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZUJyZWFrU3RhdGVtZW50KCk7XG4gICAgICAgICAgICBjYXNlICdjb250aW51ZSc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlQ29udGludWVTdGF0ZW1lbnQoKTtcbiAgICAgICAgICAgIGNhc2UgJ2RlYnVnZ2VyJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gcGFyc2VEZWJ1Z2dlclN0YXRlbWVudCgpO1xuICAgICAgICAgICAgY2FzZSAnZG8nOlxuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZURvV2hpbGVTdGF0ZW1lbnQoKTtcbiAgICAgICAgICAgIGNhc2UgJ2Zvcic6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlRm9yU3RhdGVtZW50KCk7XG4gICAgICAgICAgICBjYXNlICdmdW5jdGlvbic6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlRnVuY3Rpb25EZWNsYXJhdGlvbigpO1xuICAgICAgICAgICAgY2FzZSAnaWYnOlxuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZUlmU3RhdGVtZW50KCk7XG4gICAgICAgICAgICBjYXNlICdyZXR1cm4nOlxuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZVJldHVyblN0YXRlbWVudCgpO1xuICAgICAgICAgICAgY2FzZSAnc3dpdGNoJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gcGFyc2VTd2l0Y2hTdGF0ZW1lbnQoKTtcbiAgICAgICAgICAgIGNhc2UgJ3Rocm93JzpcbiAgICAgICAgICAgICAgICByZXR1cm4gcGFyc2VUaHJvd1N0YXRlbWVudCgpO1xuICAgICAgICAgICAgY2FzZSAndHJ5JzpcbiAgICAgICAgICAgICAgICByZXR1cm4gcGFyc2VUcnlTdGF0ZW1lbnQoKTtcbiAgICAgICAgICAgIGNhc2UgJ3Zhcic6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlVmFyaWFibGVTdGF0ZW1lbnQoKTtcbiAgICAgICAgICAgIGNhc2UgJ3doaWxlJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gcGFyc2VXaGlsZVN0YXRlbWVudCgpO1xuICAgICAgICAgICAgY2FzZSAnd2l0aCc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlV2l0aFN0YXRlbWVudCgpO1xuICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGV4cHIgPSBwYXJzZUV4cHJlc3Npb24oKTtcblxuICAgICAgICAvLyAxMi4xMiBMYWJlbGxlZCBTdGF0ZW1lbnRzXG4gICAgICAgIGlmICgoZXhwci50eXBlID09PSBTeW50YXguSWRlbnRpZmllcikgJiYgbWF0Y2goJzonKSkge1xuICAgICAgICAgICAgbGV4KCk7XG5cbiAgICAgICAgICAgIGlmIChPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5Lm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ICAgICAgICB3aGlsZSAoaW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgICAgIHRva2VuID0gbG9va2FoZWFkKCk7XG4gICAgICAgICAgICBpZiAodG9rZW4udHlwZSAhPT0gVG9rZW4uU3RyaW5nTGl0ZXJhbCkge1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBzb3VyY2VFbGVtZW50ID0gcGFyc2VTb3VyY2VFbGVtZW50KCk7XG4gICAgICAgICAgICBzb3VyY2VFbGVtZW50cy5wdXNoKHNvdXJjZUVsZW1lbnQpO1xuICAgICAgICAgICAgaWYgKHNvdXJjZUVsZW1lbnQuZXhwcmVzc2lvbi50eXBlICE9PSBTeW50YXguTGl0ZXJhbCkge1xuICAgICAgICAgICAgICAgIC8vIHRoaXMgaXMgbm90IGRpcmVjdGl2ZVxuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZGlyZWN0aXZlID0gc2xpY2VTb3VyY2UodG9rZW4ucmFuZ2VbMF0gKyAxLCB0b2tlbi5yYW5nZVsxXSAtIDEpO1xuICAgICAgICAgICAgaWYgKGRpcmVjdGl2ZSA9PT0gJ3VzZSBzdHJpY3QnKSB7XG4gICAgICAgICAgICAgICAgc3RyaWN0ID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICBpZiAoZmlyc3RSZXN0cmljdGVkKSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93RXJyb3JUb2xlcmFudChmaXJzdFJlc3RyaWN0ZWQsIE1lc3NhZ2VzLlN0cmljdE9jdGFsTGl0ZXJhbCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAoIWZpcnN0UmVzdHJpY3RlZCAmJiB0b2tlbi5vY3RhbCkge1xuICAgICAgICAgICAgICAgICAgICBmaXJzdFJlc3RyaWN0ZWQgPSB0b2tlbjtcbiAgICAg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2VuO1xuICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSBNZXNzYWdlcy5TdHJpY3RSZXNlcnZlZFdvcmQ7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBleHBlY3QoJygnKTtcblxuICAgICAgICBpZiAoIW1hdGNoKCcpJykpIHtcbiAgICAgICAgICAgIHBhcmFtU2V0ID0ge307XG4gICAgICAgICAgICB3aGlsZSAoaW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgICAgICAgICB0b2tlbiA9IGxvb2thaGVhZCgpO1xuICAgICAgICAgICAgICAgIHBhcmFtID0gcGFyc2VWYXJpYWJsZUlkZW50aWZpZXIoKTtcbiAgICAgICAgICAgICAgICBpZiAoc3RyaWN0KSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpc1Jlc3RyaWN0ZWRXb3JkKHRva2VuLnZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RyaWN0ZWQgPSB0b2tlbjtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSBNZXNzYWdlcy5TdHJpY3RQYXJhbU5hbWU7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbChwYXJhbVNldCwgdG9rZW4udmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHJpY3RlZCA9IHRva2VuO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IE1lc3NhZ2VzLlN0cmljdFBhcmFtRHVwZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIWZpcnN0UmVzdHJpY3RlZCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXNSZXN0cmljdGVkV29yZCh0b2tlbi52YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpcnN0UmVzdHJpY3RlZCA9IHRva2VuO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IE1lc3NhZ2VzLlN0cmljdFBhcmFtTmFtZTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpc1N0cmljdE1vZGVSZXNlcnZlZFdvcmQodG9rZW4udmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBmaXJzdFJlc3RyaWN0ZWQgPSB0b2tlbjtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSBNZXNzYWdlcy5TdHJpY3RSZXNlcnZlZFdvcmQ7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHBhcmFtU2V0LCB0b2tlbi52YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpcnN0UmVzdHJpY3RlZCA9IHRva2VuO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IE1lc3NhZ2VzLlN0cmljdFBhcmFtRHVwZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBwYXJhbXMucHVzaChwYXJhbSk7XG4gICAgICAgICAgICAgICAgcGFyYW1TZXRbcGFyYW0ubmFtZV0gPSB0cnVlO1xuICAgICAgICAgICAgICAgIGlmIChtYXRjaCgnKScpKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBleHBlY3QoJywnKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGV4cGVjdCgnKScpO1xuXG4gICAgICAgIHByZXZpb3VzU3RyaWN0ID0gc3RyaWN0O1xuICAgICAgICBib2R5ID0gcGFyc2VGdW5jdGlvblNvdXJjZUVsZW1lbnRzKCk7XG4gICAgICAgIGlmIChzdHJpY3QgJiYgZmlyc3RSZXN0cmljdGVkKSB7XG4gICAgICAgICAgICB0aHJvd0Vycm9yKGZpcnN0UmVzdHJpY3RlZCwgbWVzc2FnZSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0cmljdCAmJiBzdHJpY3RlZCkge1xuICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHN0cmljdGVkLCBtZXNzYWdlKTtcbiAgICAgICAgfVxuICAgICAgICBzdHJpY3QgPSBwcmV2aW91c1N0cmljdDtcblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkZ1bmN0aW9uRGVjbGFyYXRpb24sXG4gICAgICAgICAgICBpZDogaWQsXG4gICAgICAgICAgICBwYXJhbXM6IHBhcmFtcyxcbiAgICAgICAgICAgIGRlZmF1bHRzOiBbXSxcbiAgICAgICAgICAgIGJvZHk6IGJvZHksXG4gICAgICAgICAgICByZXN0OiBudWxsLFxuICAgICAgICAgICAgZ2VuZXJhdG9yOiBmYWxzZSxcbiAgICAgICAgICAgIGV4cHJlc3Npb246IGZhbHNlXG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2VGdW5jdGlvbkV4cHJlc3Npb24oKSB7XG4gICAgICAgIHZhciB0b2tlbiwgaWQgPSBudWxsLCBzdHJpY3RlZCwgZmlyc3RSZXN0cmljdGVkLCBtZXNzYWdlLCBwYXJhbSwgcGFyYW1zID0gW10sIGJvZHksIHByZXZpb3VzU3RyaWN0LCBwYXJhbVNldDtcblxuICAgICAgICBleHBlY3RLZXl3b3JkKCdmdW5jdGlvbicpO1xuXG4gICAgICAgIGlmICghbWF0Y2goJygnKSkge1xuICAgICAgICAgICAgdG9rZW4gPSBsb29rYWhlYWQoKTtcbiAgICAgICAgICAgIGlkID0gcGFyc2VWYXJpYWJsZUlkZW50aWZpZXIoKTtcbiAgICAgICAgICAgIGlmIChzdHJpY3QpIHtcbiAgICAgICAgICAgICAgICBpZiAoaXNSZXN0cmljdGVkV29yZCh0b2tlbi52YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHRva2VuLCBNZXNzYWdlcy5TdHJpY3RGdW5jdGlvbk5hbWUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKGlzUmVzdHJpY3RlZFdvcmQodG9rZW4udmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIGZpcnN0UmVzdHJpY3RlZCA9IHRva2VuO1xuICAgICAgICAgICAgICAgICAgICBtZXNzYWdlID0gTWVzc2FnZXMuU3RyaWN0RnVuY3Rpb25OYW1lO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNTdHJpY3RNb2RlUmVzZXJ2ZWRXb3JkKHRva2VuLnZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICBmaXJzdFJlc3RyaWN0ZWQgPSB0b2tlbjtcbiAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IE1lc3NhZ2VzLlN0cmljdFJlc2VydmVkV29yZDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBleHBlY3QoJygnKTtcblxuICAgICAgICBpZiAoIW1hdGNoKCcpJykpIHtcbiAgICAgICAgICAgIHBhcmFtU2V0ID0ge307XG4gICAgICAgICAgICB3aGlsZSAoaW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgICAgICAgICB0b2tlbiA9IGxvb2thaGVhZCgpO1xuICAgICAgICAgICAgICAgIHBhcmFtID0gcGFyc2VWYXJpYWJsZUlkZW50aWZpZXIoKTtcbiAgICAgICAgICAgICAgICBpZiAoc3RyaWN0KSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpc1Jlc3RyaWN0ZWRXb3JkKHRva2VuLnZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RyaWN0ZWQgPSB0b2tlbjtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSBNZXNzYWdlcy5TdHJpY3RQYXJhbU5hbWU7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbChwYXJhbVNldCwgdG9rZW4udmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHJpY3RlZCA9IHRva2VuO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IE1lc3NhZ2VzLlN0cmljdFBhcmFtRHVwZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIWZpcnN0UmVzdHJpY3RlZCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXNSZXN0cmljdGVkV29yZCh0b2tlbi52YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpcnN0UmVzdHJpY3RlZCA9IHRva2VuO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IE1lc3NhZ2VzLlN0cmljdFBhcmFtTmFtZTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpc1N0cmljdE1vZGVSZXNlcnZlZFdvcmQodG9rZW4udmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBmaXJzdFJlc3RyaWN0ZWQgPSB0b2tlbjtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSBNZXNzYWdlcy5TdHJpY3RSZXNlcnZlZFdvcmQ7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHBhcmFtU2V0LCB0b2tlbi52YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpcnN0UmVzdHJpY3RlZCA9IHRva2VuO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IE1lc3NhZ2VzLlN0cmljdFBhcmFtRHVwZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBwYXJhbXMucHVzaChwYXJhbSk7XG4gICAgICAgICAgICAgICAgcGFyYW1TZXRbcGFyYW0ubmFtZV0gPSB0cnVlO1xuICAgICAgICAgICAgICAgIGlmIChtYXRjaCgnKScpKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBleHBlY3QoJywnKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGV4cGVjdCgnKScpO1xuXG4gICAgICAgIHByZXZpb3VzU3RyaWN0ID0gc3RyaWN0O1xuICAgICAgICBib2R5ID0gcGFyc2VGdW5jdGlvblNvdXJjZUVsZW1lbnRzKCk7XG4gICAgICAgIGlmIChzdHJpY3QgJiYgZmlyc3RSZXN0cmljdGVkKSB7XG4gICAgICAgICAgICB0aHJvd0Vycm9yKGZpcnN0UmVzdHJpY3RlZCwgbWVzc2FnZSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0cmljdCAmJiBzdHJpY3RlZCkge1xuICAgICAgICAgICAgdGhyb3dFcnJvclRvbGVyYW50KHN0cmljdGVkLCBtZXNzYWdlKTtcbiAgICAgICAgfVxuICAgICAgICBzdHJpY3QgPSBwcmV2aW91c1N0cmljdDtcblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkZ1bmN0aW9uRXhwcmVzc2lvbixcbiAgICAgICAgICAgIGlkOiBpZCxcbiAgICAgICAgICAgIHBhcmFtczogcGFyYW1zLFxuICAgICAgICAgICAgZGVmYXVsdHM6IFtdLFxuICAgICAgICAgICAgYm9keTogYm9keSxcbiAgICAgICAgICAgIHJlc3Q6IG51bGwsXG4gICAgICAgICAgICBnZW5lcmF0b3I6IGZhbHNlLFxuICAgICAgICAgICAgZXhwcmVzc2lvbjogZmFsc2VcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyAxNCBQcm9ncmFtXG5cbiAgICBmdW5jdGlvbiBwYXJzZVNvdXJjZUVsZW1lbnQoKSB7XG4gICAgICAgIHZhciB0b2tlbiA9IGxvb2thaGVhZCgpO1xuXG4gICAgICAgIGlmICh0b2tlbi50eXBlID09PSBUb2tlbi5LZXl3b3JkKSB7XG4gICAgICAgICAgICBzd2l0Y2ggKHRva2VuLnZhbHVlKSB7XG4gICAgICAgICAgICBjYXNlICdjb25zdCc6XG4gICAgICAgICAgICBjYXNlICdsZXQnOlxuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZUNvbnN0TGV0RGVjbGFyYXRpb24odG9rZW4udmFsdWUpO1xuICAgICAgICAgICAgY2FzZSAnZnVuY3Rpb24nOlxuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZUZ1bmN0aW9uRGVjbGFyYXRpb24oKTtcbiAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlU3RhdGVtZW50KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodG9rZW4udHlwZSAhPT0gVG9rZW4uRU9GKSB7XG4gICAgICAgICAgICByZXR1cm4gcGFyc2VTdGF0ZW1lbnQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBhcnNlU291cmNlRWxlbWVudHMoKSB7XG4gICAgICAgIHZhciBzb3VyY2VFbGVtZW50LCBzb3VyY2VFbGVtZW50cyA9IFtdLCB0b2tlbiwgZGlyZWN0aXZlLCBmaXJzdFJlc3RyaWN0ZWQ7XG5cbiAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICB0b2tlbiA9IGxvb2thaGVhZCgpO1xuICAgICAgICAgICAgaWYgKHRva2VuLnR5cGUgIT09IFRva2VuLlN0cmluZ0xpdGVyYWwpIHtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgc291cmNlRWxlbWVudCA9IHBhcnNlU291cmNlRWxlbWVudCgpO1xuICAgICAgICAgICAgc291cmNlRWxlbWVudHMucHVzaChzb3VyY2VFbGVtZW50KTtcbiAgICAgICAgICAgIGlmIChzb3VyY2VFbGVtZW50LmV4cHJlc3Npb24udHlwZSAhPT0gU3ludGF4LkxpdGVyYWwpIHtcbiAgICAgICAgICAgICAgICAvLyB0aGlzIGlzIG5vdCBkaXJlY3RpdmVcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRpcmVjdGl2ZSA9IHNsaWNlU291cmNlKHRva2VuLnJhbmdlWzBdICsgMSwgdG9rZW4ucmFuZ2VbMV0gLSAxKTtcbiAgICAgICAgICAgIGlmIChkaXJlY3RpdmUgPT09ICd1c2Ugc3RyaWN0Jykge1xuICAgICAgICAgICAgICAgIHN0cmljdCA9IHRydWU7XG4gICAgICAgICAgICAgICAgaWYgKGZpcnN0UmVzdHJpY3RlZCkge1xuICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yVG9sZXJhbnQoZmlyc3RSZXN0cmljdGVkLCBNZXNzYWdlcy5TdHJpY3RPY3RhbExpdGVyYWwpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKCFmaXJzdFJlc3RyaWN0ZWQgJiYgdG9rZW4ub2N0YWwpIHtcbiAgICAgICAgICAgICAgICAgICAgZmlyc3RSZXN0cmljdGVkID0gdG9rZW47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICBzb3VyY2VFbGV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c2lzLlxuICAgICAgICAvLyBUaHVzLCB3ZSBuZWVkIHRvIHNraXAgYWRkaW5nIGEgY29tbWVudCBpZiB0aGUgY29tbWVudCBhcnJheSBhbHJlYWR5XG4gICAgICAgIC8vIGhhbmRsZWQgaXQuXG4gICAgICAgIGlmIChleHRyYS5jb21tZW50cy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICBpZiAoZXh0cmEuY29tbWVudHNbZXh0cmEuY29tbWVudHMubGVuZ3RoIC0gMV0ucmFuZ2VbMV0gPiBzdGFydCkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGV4dHJhLmNvbW1lbnRzLnB1c2goe1xuICAgICAgICAgICAgdHlwZTogdHlwZSxcbiAgICAgICAgICAgIHZhbHVlOiB2YWx1ZSxcbiAgICAgICAgICAgIHJhbmdlOiBbc3RhcnQsIGVuZF0sXG4gICAgICAgICAgICBsb2M6IGxvY1xuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBzY2FuQ29tbWVudCgpIHtcbiAgICAgICAgdmFyIGNvbW1lbnQsIGNoLCBsb2MsIHN0YXJ0LCBibG9ja0NvbW1lbnQsIGxpbmVDb21tZW50O1xuXG4gICAgICAgIGNvbW1lbnQgPSAnJztcbiAgICAgICAgYmxvY2tDb21tZW50ID0gZmFsc2U7XG4gICAgICAgIGxpbmVDb21tZW50ID0gZmFsc2U7XG5cbiAgICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG5cbiAgICAgICAgICAgIGlmIChsaW5lQ29tbWVudCkge1xuICAgICAgICAgICAgICAgIGNoID0gc291cmNlW2luZGV4KytdO1xuICAgICAgICAgICAgICAgIGlmIChpc0xpbmVUZXJtaW5hdG9yKGNoKSkge1xuICAgICAgICAgICAgICAgICAgICBsb2MuZW5kID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGluZTogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbHVtbjogaW5kZXggLSBsaW5lU3RhcnQgLSAxXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIGxpbmVDb21tZW50ID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgIGFkZENvbW1lbnQoJ0xpbmUnLCBjb21tZW50LCBzdGFydCwgaW5kZXggLSAxLCBsb2MpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoY2ggPT09ICdcXHInICYmIHNvdXJjZVtpbmRleF0gPT09ICdcXG4nKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICArK2luZGV4O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICsrbGluZU51bWJlcjtcbiAgICAgICAgICAgICAgICAgICAgbGluZVN0YXJ0ID0gaW5kZXg7XG4gICAgICAgICAgICAgICAgICAgIGNvbW1lbnQgPSAnJztcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGluZGV4ID49IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICBsaW5lQ29tbWVudCA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICBjb21tZW50ICs9IGNoO1xuICAgICAgICAgICAgICAgICAgICBsb2MuZW5kID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGluZTogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbHVtbjogbGVuZ3RoIC0gbGluZVN0YXJ0XG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIGFkZENvbW1lbnQoJ0xpbmUnLCBjb21tZW50LCBzdGFydCwgbGVuZ3RoLCBsb2MpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbW1lbnQgKz0gY2g7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIGlmIChibG9ja0NvbW1lbnQpIHtcbiAgICAgICAgICAgICAgICBpZiAoaXNMaW5lVGVybWluYXRvcihjaCkpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGNoID09PSAnXFxyJyAmJiBzb3VyY2VbaW5kZXggKyAxXSA9PT0gJ1xcbicpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb21tZW50ICs9ICdcXHJcXG4nO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29tbWVudCArPSBjaDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICArK2xpbmVOdW1iZXI7XG4gICAgICAgICAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICAgICAgICAgIGxpbmVTdGFydCA9IGluZGV4O1xuICAgICAgICAgICAgICAgICAgICBpZiAoaW5kZXggPj0gbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKHt9LCBNZXNzYWdlcy5VbmV4cGVjdGVkVG9rZW4sICdJTExFR0FMJyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleCsrXTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4ID49IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvcih7fSwgTWVzc2FnZXMuVW5leHBlY3RlZFRva2VuLCAnSUxMRUdBTCcpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGNvbW1lbnQgKz0gY2g7XG4gICAgICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gJyonKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjaCA9IHNvdXJjZVtpbmRleF07XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2ggPT09ICcvJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1lbnQgPSBjb21tZW50LnN1YnN0cigwLCBjb21tZW50Lmxlbmd0aCAtIDEpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJsb2NrQ29tbWVudCA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9jLmVuZCA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZTogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sdW1uOiBpbmRleCAtIGxpbmVTdGFydFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkQ29tbWVudCgnQmxvY2snLCBjb21tZW50LCBzdGFydCwgaW5kZXgsIGxvYyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWVudCA9ICcnO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIGlmIChjaCA9PT0gJy8nKSB7XG4gICAgICAgICAgICAgICAgY2ggPSBzb3VyY2VbaW5kZXggKyAxXTtcbiAgICAgICAgICAgICAgICBpZiAoY2ggPT09ICcvJykge1xuICAgICAgICAgICAgICAgICAgICBsb2MgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdGFydDoge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmU6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sdW1uOiBpbmRleCAtIGxpbmVTdGFydFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICBzdGFydCA9IGluZGV4O1xuICAgICAgICAgICAgICAgICAgICBpbmRleCArPSAyO1xuICAgICAgICAgICAgICAgICAgICBsaW5lQ29tbWVudCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCA+PSBsZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvYy5lbmQgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZTogbGluZU51bWJlcixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2x1bW46IGluZGV4IC0gbGluZVN0YXJ0XG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgbGluZUNvbW1lbnQgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGFkZENvbW1lbnQoJ0xpbmUnLCBjb21tZW50LCBzdGFydCwgaW5kZXgsIGxvYyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoID09PSAnKicpIHtcbiAgICAgICAgICAgICAgICAgICAgc3RhcnQgPSBpbmRleDtcbiAgICAgICAgICAgICAgICAgICAgaW5kZXggKz0gMjtcbiAgICAgICAgICAgICAgICAgICAgYmxvY2tDb21tZW50ID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgbG9jID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnQ6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5lOiBsaW5lTnVtYmVyLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbHVtbjogaW5kZXggLSBsaW5lU3RhcnQgLSAyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCA+PSBsZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93RXJyb3Ioe30sIE1lc3NhZ2VzLlVuZXhwZWN0ZWRUb2tlbiwgJ0lMTEVHQUwnKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNXaGl0ZVNwYWNlKGNoKSkge1xuICAgICAgICAgICAgICAgICsraW5kZXg7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlzTGluZVRlcm1pbmF0b3IoY2gpKSB7XG4gICAgICAgICAgICAgICAgKytpbmRleDtcbiAgICAgICAgICAgICAgICBpZiAoY2ggPT09ICAnXFxyJyAmJiBzb3VyY2VbaW5kZXhdID09PSAnXFxuJykge1xuICAgICAgICAgICAgICAgICAgICArK2luZGV4O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICArK2xpbmVOdW1iZXI7XG4gICAgICAgICAgICAgICAgbGluZVN0YXJ0ID0gaW5kZXg7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gZmlsdGVyQ29tbWVudExvY2F0aW9uKCkge1xuICAgICAgICB2YXIgaSwgZW50cnksIGNvbW1lbnQsIGNvbW1lbnRzID0gW107XG5cbiAgICAgICAgZm9yIChpID0gMDsgaSA8IGV4dHJhLmNvbW1lbnRzLmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICBlbnRyeSA9IGV4dHJhLmNvbW1lbnRzW2ldO1xuICAgICAgICAgICAgY29tbWVudCA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBlbnRyeS50eXBlLFxuICAgICAgICAgICAgICAgIHZhbHVlOiBlbnRyeS52YWx1ZVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGlmIChleHRyYS5yYW5nZSkge1xuICAgICAgICAgICAgICAgIGNvbW1lbnQucmFuZ2UgPSBlbnRyeS5yYW5nZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChleHRyYS5sb2MpIHtcbiAgICAgICAgICAgICAgICBjb21tZW50LmxvYyA9IGVudHJ5LmxvYztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNvbW1lbnRzLnB1c2goY29tbWVudCk7XG4gICAgICAgIH1cblxuICAgICAgICBleHRyYS5jb21tZW50cyA9IGNvbW1lbnRzO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGNvbGxlY3RUb2tlbigpIHtcbiAgICAgICAgdmFyIHN0YXJ0LCBsb2MsIHRva2VuLCByYW5nZSwgdmFsdWU7XG5cbiAgICAgICAgc2tpcENvbW1lbnQoKTtcbiAgICAgICAgc3RhcnQgPSBpbmRleDtcbiAgICAgICAgbG9jID0ge1xuICAgICAgICAgICAgc3RhcnQ6IHtcbiAgICAgICAgICAgICAgICBsaW5lOiBsaW5lTnVtYmVyLFxuICAgICAgICAgICAgICAgIGNvbHVtbjogaW5kZXggLSBsaW5lU3RhcnRcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcblxuICAgICAgICB0b2tlbiA9IGV4dHJhLmFkdmFuY2UoKTtcbiAgICAgICAgbG9jLmVuZCA9IHtcbiAgICAgICAgICAgIGxpbmU6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICBjb2x1bW46IGluZGV4IC0gbGluZVN0YXJ0XG4gICAgICAgIH07XG5cbiAgICAgICAgaWYgKHRva2VuLnR5cGUgIT09IFRva2VuLkVPRikge1xuICAgICAgICAgICAgcmFuZ2UgPSBbdG9rZW4ucmFuZ2VbMF0sIHRva2VuLnJhbmdlWzFdXTtcbiAgICAgICAgICAgIHZhbHVlID0gc2xpY2VTb3VyY2UodG9rZW4ucmFuZ2VbMF0sIHRva2VuLnJhbmdlWzFdKTtcbiAgICAgICAgICAgIGV4dHJhLnRva2Vucy5wdXNoKHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUb2tlbk5hbWVbdG9rZW4udHlwZV0sXG4gICAgICAgICAgICAgICAgdmFsdWU6IHZhbHVlLFxuICAgICAgICAgICAgICAgIHJhbmdlOiByYW5nZSxcbiAgICAgICAgICAgICAgICBsb2M6IGxvY1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gdG9rZW47XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gY29sbGVjdFJlZ2V4KCkge1xuICAgICAgICB2YXIgcG9zLCBsb2MsIHJlZ2V4LCB0b2tlbjtcblxuICAgICAgICBza2lwQ29tbWVudCgpO1xuXG4gICAgICAgIHBvcyA9IGluZGV4O1xuICAgICAgICBsb2MgPSB7XG4gICAgICAgICAgICBzdGFydDoge1xuICAgICAgICAgICAgICAgIGxpbmU6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgY29sdW1uOiBpbmRleCAtIGxpbmVTdGFydFxuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuXG4gICAgICAgIHJlZ2V4ID0gZXh0cmEuc2NhblJlZ0V4cCgpO1xuICAgICAgICBsb2MuZW5kID0ge1xuICAgICAgICAgICAgbGluZTogbGluZU51bWJlcixcbiAgICAgICAgICAgIGNvbHVtbjogaW5kZXggLSBsaW5lU3RhcnRcbiAgICAgICAgfTtcblxuICAgICAgICAvLyBQb3AgdGhlIHByZXZpb3VzIHRva2VuLCB3aGljaCBpcyBsaWtlbHkgJy8nIG9yICcvPSdcbiAgICAgICAgaWYgKGV4dHJhLnRva2Vucy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICB0b2tlbiA9IGV4dHJhLnRva2Vuc1tleHRyYS50b2tlbnMubGVuZ3RoIC0gMV07XG4gICAgICAgICAgICBpZiAodG9rZW4ucmFuZ2VbMF0gPT09IHBvcyAmJiB0b2tlbi50eXBlID09PSAnUHVuY3R1YXRvcicpIHtcbiAgICAgICAgICAgICAgICBpZiAodG9rZW4udmFsdWUgPT09ICcvJyB8fCB0b2tlbi52YWx1ZSA9PT0gJy89Jykge1xuICAgICAgICAgICAgICAgICAgICBleHRyYS50b2tlbnMucG9wKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZXh0cmEudG9rZW5zLnB1c2goe1xuICAgICAgICAgICAgdHlwZTogJ1JlZ3VsYXJFeHByZXNzaW9uJyxcbiAgICAgICAgICAgIHZhbHVlOiByZWdleC5saXRlcmFsLFxuICAgICAgICAgICAgcmFuZ2U6IFtwb3MsIGluZGV4XSxcbiAgICAgICAgICAgIGxvYzogbG9jXG4gICAgICAgIH0pO1xuXG4gICAgICAgIHJldHVybiByZWdleDtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBmaWx0ZXJUb2tlbkxvY2F0aW9uKCkge1xuICAgICAgICB2YXIgaSwgZW50cnksIHRva2VuLCB0b2tlbnMgPSBbXTtcblxuICAgICAgICBmb3IgKGkgPSAwOyBpIDwgZXh0cmEudG9rZW5zLmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICBlbnRyeSA9IGV4dHJhLnRva2Vuc1tpXTtcbiAgICAgICAgICAgIHRva2VuID0ge1xuICAgICAgICAgICAgICAgIHR5cGU6IGVudHJ5LnR5cGUsXG4gICAgICAgICAgICAgICAgdmFsdWU6IGVudHJ5LnZhbHVlXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKGV4dHJhLnJhbmdlKSB7XG4gICAgICAgICAgICAgICAgdG9rZW4ucmFuZ2UgPSBlbnRyeS5yYW5nZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChleHRyYS5sb2MpIHtcbiAgICAgICAgICAgICAgICB0b2tlbi5sb2MgPSBlbnRyeS5sb2M7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0b2tlbnMucHVzaCh0b2tlbik7XG4gICAgICAgIH1cblxuICAgICAgICBleHRyYS50b2tlbnMgPSB0b2tlbnM7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gY3JlYXRlTGl0ZXJhbCh0b2tlbikge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogU3ludGF4LkxpdGVyYWwsXG4gICAgICAgICAgICB2YWx1ZTogdG9rZW4udmFsdWVcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBjcmVhdGVSYXdMaXRlcmFsKHRva2VuKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBTeW50YXguTGl0ZXJhbCxcbiAgICAgICAgICAgIHZhbHVlOiB0b2tlbi52YWx1ZSxcbiAgICAgICAgICAgIHJhdzogc2xpY2VTb3VyY2UodG9rZW4ucmFuZ2VbMF0sIHRva2VuLnJhbmdlWzFdKVxuICAgICAgICB9O1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGNyZWF0ZUxvY2F0aW9uTWFya2VyKCkge1xuICAgICAgICB2YXIgbWFya2VyID0ge307XG5cbiAgICAgICAgbWFya2VyLnJhbmdlID0gW2luZGV4LCBpbmRleF07XG4gICAgICAgIG1hcmtlci5sb2MgPSB7XG4gICAgICAgICAgICBzdGFydDoge1xuICAgICAgICAgICAgICAgIGxpbmU6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgY29sdW1uOiBpbmRleCAtIGxpbmVTdGFydFxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGVuZDoge1xuICAgICAgICAgICAgICAgIGxpbmU6IGxpbmVOdW1iZXIsXG4gICAgICAgICAgICAgICAgY29sdW1uOiBpbmRleCAtIGxpbmVTdGFydFxuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuXG4gICAgICAgIG1hcmtlci5lbmQgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB0aGlzLnJhbmdlWzFdID0gaW5kZXg7XG4gICAgICAgICAgICB0aGlzLmxvYy5lbmQubGluZSA9IGxpbmVOdW1iZXI7XG4gICAgICAgICAgICB0aGlzLmxvYy5lbmQuY29sdW1uID0gaW5kZXggLSBsaW5lU3RhcnQ7XG4gICAgICAgIH07XG5cbiAgICAgICAgbWFya2VyLmFwcGx5R3JvdXAgPSBmdW5jdGlvbiAobm9kZSkge1xuICAgICAgICAgICAgaWYgKGV4dHJhLnJhbmdlKSB7XG4gICAgICAgICAgICAgICAgbm9kZS5ncm91cFJhbmdlID0gW3RoaXMucmFuZ2VbMF0sIHRoaXMucmFuZ2VbMV1dO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGV4dHJhLmxvYykge1xuICAgICAgICAgICAgICAgIG5vZGUuZ3JvdXBMb2MgPSB7XG4gICAgICAgICAgICAgICAgICAgIHN0YXJ0OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsaW5lOiB0aGlzLmxvYy5zdGFydC5saW5lLFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sdW1uOiB0aGlzLmxvYy5zdGFydC5jb2x1bW5cbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgZW5kOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsaW5lOiB0aGlzLmxvYy5lbmQubGluZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbHVtbjogdGhpcy5sb2MuZW5kLmNvbHVtblxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcblxuICAgICAgICBtYXJrZXIuYXBwbHkgPSBmdW5jdGlvbiAobm9kZSkge1xuICAgICAgICAgICAgaWYgKGV4dHJhLnJhbmdlKSB7XG4gICAgICAgICAgICAgICAgbm9kZS5yYW5nZSA9IFt0aGlzLnJhbmdlWzBdLCB0aGlzLnJhbmdlWzFdXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChleHRyYS5sb2MpIHtcbiAgICAgICAgICAgICAgICBub2RlLmxvYyA9IHtcbiAgICAgICAgICAgICAgICAgICAgc3RhcnQ6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmU6IHRoaXMubG9jLnN0YXJ0LmxpbmUsXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2x1bW46IHRoaXMubG9jLnN0YXJ0LmNvbHVtblxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBlbmQ6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmU6IHRoaXMubG9jLmVuZC5saW5lLFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sdW1uOiB0aGlzLmxvYy5lbmQuY29sdW1uXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuXG4gICAgICAgIHJldHVybiBtYXJrZXI7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gdHJhY2tHcm91cEV4cHJlc3Npb24oKSB7XG4gICAgICAgIHZhciBtYXJrZXIsIGV4cHI7XG5cbiAgICAgICAgc2tpcENvbW1lbnQoKTtcbiAgICAgICAgbWFya2VyID0gY3JlYXRlTG9jYXRpb25NYXJrZXIoKTtcbiAgICAgICAgZXhwZWN0KCcoJyk7XG5cbiAgICAgICAgZXhwciA9IHBhcnNlRXhwcmVzc2lvbigpO1xuXG4gICAgICAgIGV4cGVjdCgnKScpO1xuXG4gICAgICAgIG1hcmtlci5lbmQoKTtcbiAgICAgICAgbWFya2VyLmFwcGx5R3JvdXAoZXhwcik7XG5cbiAgICAgICAgcmV0dXJuIGV4cHI7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gdHJhY2tMZWZ0SGFuZFNpZGVFeHByZXNzaW9uKCkge1xuICAgICAgICB2YXIgbWFya2VyLCBleHByO1xuXG4gICAgICAgIHNraXBDb21tZW50KCk7XG4gICAgICAgIG1hcmtlciA9IGNyZWF0ZUxvY2F0aW9uTWFya2VyKCk7XG5cbiAgICAgICAgZXhwciA9IG1hdGNoS2V5d29yZCgnbmV3JykgPyBwYXJzZU5ld0V4cHJlc3Npb24oKSA6IHBhcnNlUHJpbWFyeUV4cHJlc3Npb24oKTtcblxuICAgICAgICB3aGlsZSAobWF0Y2goJy4nKSB8fCBtYXRjaCgnWycpKSB7XG4gICAgICAgICAgICBpZiAobWF0Y2goJ1snKSkge1xuICAgICAgICAgICAgICAgIGV4cHIgPSB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFN5bnRheC5NZW1iZXJFeHByZXNzaW9uLFxuICAgICAgICAgICAgICAgICAgICBjb21wdXRlZDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgb2JqZWN0OiBleHByLFxuICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0eTogcGFyc2VDb21wdXRlZE1lbWJlcigpXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBtYXJrZXIuZW5kKCk7XG4gICAgICAgICAgICAgICAgbWFya2VyLmFwcGx5KGV4cHIpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBleHByID0ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguTWVtYmVyRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICAgICAgY29tcHV0ZWQ6IGZhbHNlLFxuICAgICAgICAgICAgICAgICAgICBvYmplY3Q6IGV4cHIsXG4gICAgICAgICAgICAgICAgICAgIHByb3BlcnR5OiBwYXJzZU5vbkNvbXB1dGVkTWVtYmVyKClcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIG1hcmtlci5lbmQoKTtcbiAgICAgICAgICAgICAgICBtYXJrZXIuYXBwbHkoZXhwcik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZXhwcjtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiB0cmFja0xlZnRIYW5kU2lkZUV4cHJlc3Npb25BbGxvd0NhbGwoKSB7XG4gICAgICAgIHZhciBtYXJrZXIsIGV4cHI7XG5cbiAgICAgICAgc2tpcENvbW1lbnQoKTtcbiAgICAgICAgbWFya2VyID0gY3JlYXRlTG9jYXRpb25NYXJrZXIoKTtcblxuICAgICAgICBleHByID0gbWF0Y2hLZXl3b3JkKCduZXcnKSA/IHBhcnNlTmV3RXhwcmVzc2lvbigpIDogcGFyc2VQcmltYXJ5RXhwcmVzc2lvbigpO1xuXG4gICAgICAgIHdoaWxlIChtYXRjaCgnLicpIHx8IG1hdGNoKCdbJykgfHwgbWF0Y2goJygnKSkge1xuICAgICAgICAgICAgaWYgKG1hdGNoKCcoJykpIHtcbiAgICAgICAgICAgICAgICBleHByID0ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguQ2FsbEV4cHJlc3Npb24sXG4gICAgICAgICAgICAgICAgICAgIGNhbGxlZTogZXhwcixcbiAgICAgICAgICAgICAgICAgICAgJ2FyZ3VtZW50cyc6IHBhcnNlQXJndW1lbnRzKClcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIG1hcmtlci5lbmQoKTtcbiAgICAgICAgICAgICAgICBtYXJrZXIuYXBwbHkoZXhwcik7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1hdGNoKCdbJykpIHtcbiAgICAgICAgICAgICAgICBleHByID0ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBTeW50YXguTWVtYmVyRXhwcmVzc2lvbixcbiAgICAgICAgICAgICAgICAgICAgY29tcHV0ZWQ6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIG9iamVjdDogZXhwcixcbiAgICAgICAgICAgICAgICAgICAgcHJvcGVydHk6IHBhcnNlQ29tcHV0ZWRNZW1iZXIoKVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgbWFya2VyLmVuZCgpO1xuICAgICAgICAgICAgICAgIG1hcmtlci5hcHBseShleHByKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZXhwciA9IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogU3ludGF4Lk1lbWJlckV4cHJlc3Npb24sXG4gICAgICAgICAgICAgICAgICAgIGNvbXB1dGVkOiBmYWxzZSxcbiAgICAgICAgICAgICAgICAgICAgb2JqZWN0OiBleHByLFxuICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0eTogcGFyc2VOb25Db21wdXRlZE1lbWJlcigpXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBtYXJrZXIuZW5kKCk7XG4gICAgICAgICAgICAgICAgbWFya2VyLmFwcGx5KGV4cHIpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGV4cHI7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gZmlsdGVyR3JvdXAobm9kZSkge1xuICAgICAgICB2YXIgbiwgaSwgZW50cnk7XG5cbiAgICAgICAgbiA9IChPYmplY3QucHJvdG90eXBlLnRvU3RyaW5nLmFwcGx5KG5vZGUpID09PSAnW29iamVjdCBBcnJheV0nKSA/IFtdIDoge307XG4gICAgICAgIGZvciAoaSBpbiBub2RlKSB7XG4gICAgICAgICAgICBpZiAobm9kZS5oYXNPd25Qcm9wZXJ0eShpKSAmJiBpICE9PSAnZ3JvdXBSYW5nZScgJiYgaSAhPT0gJ2dyb3VwTG9jJykge1xuICAgICAgICAgICAgICAgIGVudHJ5ID0gbm9kZVtpXTtcbiAgICAgICAgICAgICAgICBpZiAoZW50cnkgPT09IG51bGwgfHwgdHlwZW9mIGVudHJ5ICE9PSAnb2JqZWN0JyB8fCBlbnRyeSBpbnN0YW5jZW9mIFJlZ0V4cCkge1xuICAgICAgICAgICAgICAgICAgICBuW2ldID0gZW50cnk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgbltpXSA9IGZpbHRlckdyb3VwKGVudHJ5KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIG47XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gd3JhcFRyYWNraW5nRnVuY3Rpb24ocmFuZ2UsIGxvYykge1xuXG4gICAgICAgIHJldHVybiBmdW5jdGlvbiAocGFyc2VGdW5jdGlvbikge1xuXG4gICAgICAgICAgICBmdW5jdGlvbiBpc0JpbmFyeShub2RlKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIG5vZGUudHlwZSA9PT0gU3ludGF4LkxvZ2ljYWxFeHByZXNzaW9uIHx8XG4gICAgICAgICAgICAgICAgICAgIG5vZGUudHlwZSA9PT0gU3ludGF4LkJpbmFyeUV4cHJlc3Npb247XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGZ1bmN0aW9uIHZpc2l0KG5vZGUpIHtcbiAgICAgICAgICAgICAgICB2YXIgc3RhcnQsIGVuZDtcblxuICAgICAgICAgICAgICAgIGlmIChpc0JpbmFyeShub2RlLmxlZnQpKSB7XG4gICAgICAgICAgICAgICAgICAgIHZpc2l0KG5vZGUubGVmdCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChpc0JpbmFyeShub2RlLnJpZ2h0KSkge1xuICAgICAgICAgICAgICAgICAgICB2aXNpdChub2RlLnJpZ2h0KTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAocmFuZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKG5vZGUubGVmdC5ncm91cFJhbmdlIHx8IG5vZGUucmlnaHQuZ3JvdXBSYW5nZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnQgPSBub2RlLmxlZnQuZ3JvdXBSYW5nZSA/IG5vZGUubGVmdC5ncm91cFJhbmdlWzBdIDogbm9kZS5sZWZ0LnJhbmdlWzBdO1xuICAgICAgICAgICAgICAgICAgICAgICAgZW5kID0gbm9kZS5yaWdodC5ncm91cFJhbmdlID8gbm9kZS5yaWdodC5ncm91cFJhbmdlWzFdIDogbm9kZS5yaWdodC5yYW5nZVsxXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUucmFuZ2UgPSBbc3RhcnQsIGVuZF07XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIG5vZGUucmFuZ2UgPT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdGFydCA9IG5vZGUubGVmdC5yYW5nZVswXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGVuZCA9IG5vZGUucmlnaHQucmFuZ2VbMV07XG4gICAgICAgICAgICAgICAgICAgICAgICBub2RlLnJhbmdlID0gW3N0YXJ0LCBlbmRdO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChsb2MpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKG5vZGUubGVmdC5ncm91cExvYyB8fCBub2RlLnJpZ2h0Lmdyb3VwTG9jKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdGFydCA9IG5vZGUubGVmdC5ncm91cExvYyA/IG5vZGUubGVmdC5ncm91cExvYy5zdGFydCA6IG5vZGUubGVmdC5sb2Muc3RhcnQ7XG4gICAgICAgICAgICAgICAgICAgICAgICBlbmQgPSBub2RlLnJpZ2h0Lmdyb3VwTG9jID8gbm9kZS5yaWdodC5ncm91cExvYy5lbmQgOiBub2RlLnJpZ2h0LmxvYy5lbmQ7XG4gICAgICAgICAgICAgICAgICAgICAgICBub2RlLmxvYyA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFydDogc3RhcnQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kOiBlbmRcbiAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIG5vZGUubG9jID09PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5sb2MgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnQ6IG5vZGUubGVmdC5sb2Muc3RhcnQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kOiBub2RlLnJpZ2h0LmxvYy5lbmRcbiAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgdmFyIG1hcmtlciwgbm9kZTtcblxuICAgICAgICAgICAgICAgIHNraXBDb21tZW50KCk7XG5cbiAgICAgICAgICAgICAgICBtYXJrZXIgPSBjcmVhdGVMb2NhdGlvbk1hcmtlcigpO1xuICAgICAgICAgICAgICAgIG5vZGUgPSBwYXJzZUZ1bmN0aW9uLmFwcGx5KG51bGwsIGFyZ3VtZW50cyk7XG4gICAgICAgICAgICAgICAgbWFya2VyLmVuZCgpO1xuXG4gICAgICAgICAgICAgICAgaWYgKHJhbmdlICYmIHR5cGVvZiBub2RlLnJhbmdlID09PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgICAgICBtYXJrZXIuYXBwbHkobm9kZSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKGxvYyAmJiB0eXBlb2Ygbm9kZS5sb2MgPT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgICAgIG1hcmtlci5hcHBseShub2RlKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoaXNCaW5hcnkobm9kZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgdmlzaXQobm9kZSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgcmV0dXJuIG5vZGU7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9O1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBhdG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9mIGV4dHJhLnNjYW5SZWdFeHAgPT09ICdmdW5jdGlvbicpIHtcbiAgICAgICAgICAgIGFkdmFuY2UgPSBleHRyYS5hZHZhbmNlO1xuICAgICAgICAgICAgc2NhblJlZ0V4cCA9IGV4dHJhLnNjYW5SZWdFeHA7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBmdW5jdGlvbiBzdHJpbmdUb0FycmF5KHN0cikge1xuICAgICAgICB2YXIgbGVuZ3RoID0gc3RyLmxlbmd0aCxcbiAgICAgICAgICAgIHJlc3VsdCA9IFtdLFxuICAgICAgICAgICAgaTtcbiAgICAgICAgZm9yIChpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICByZXN1bHRbaV0gPSBzdHIuY2hhckF0KGkpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGFyc2UoY29kZSwgb3B0aW9ucykge1xuICAgICAgICB2YXIgcHJvZ3JhbSwgdG9TdHJpbmc7XG5cbiAgICAgICAgdG9TdHJpbmcgPSBTdHJpbmc7XG4gICAgICAgIGlmICh0eXBlb2YgY29kZSAhPT0gJ3N0cmluZycgJiYgIShjb2RlIGluc3RhbmNlb2YgU3RyaW5nKSkge1xuICAgICAgICAgICAgY29kZSA9IHRvU3RyaW5nKGNvZGUpO1xuICAgICAgICB9XG5cbiAgICAgICAgc291cmNlID0gY29kZTtcbiAgICAgICAgaW5kZXggPSAwO1xuICAgICAgICBsaW5lTnVtYmVyID0gKHNvdXJjZS5sZW5ndGggPiAwKSA/IDEgOiAwO1xuICAgICAgICBsaW5lU3RhcnQgPSAwO1xuICAgICAgICBsZW5ndGggPSBzb3VyY2UubGVuZ3RoO1xuICAgICAgICBidWZmZXIgPSBudWxsO1xuICAgICAgICBzdGF0ZSA9IHtcbiAgICAgICAgICAgIGFsbG93SW46IHRydWUsXG4gICAgICAgICAgICBsYWJlbFNldDoge30sXG4gICAgICAgICAgICBpbkZ1bmN0aW9uQm9keTogZmFsc2UsXG4gICAgICAgICAgICBpbkl0ZXJhdGlvbjogZmFsc2UsXG4gICAgICAgICAgICBpblN3aXRjaDogZmFsc2VcbiAgICAgICAgfTtcblxuICAgICAgICBleHRyYSA9IHt9O1xuICAgICAgICBpZiAodHlwZW9mIG9wdGlvbnMgIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICBleHRyYS5yYW5nZSA9ICh0eXBlb2Ygb3B0aW9ucy5yYW5nZSA9PT0gJ2Jvb2xlYW4nKSAmJiBvcHRpb25zLnJhbmdlO1xuICAgICAgICAgICAgZXh0cmEubG9jID0gKHR5cGVvZiBvcHRpb25zLmxvYyA9PT0gJ2Jvb2xlYW4nKSAmJiBvcHRpb25zLmxvYztcbiAgICAgICAgICAgIGV4dHJhLnJhdyA9ICh0eXBlb2Ygb3B0aW9ucy5yYXcgPT09ICdib29sZWFuJykgJiYgb3B0aW9ucy5yYXc7XG4gICAgICAgICAgICBpZiAodHlwZW9mIG9wdGlvbnMudG9rZW5zID09PSAnYm9vbGVhbicgJiYgb3B0aW9ucy50b2tlbnMpIHtcbiAgICAgICAgICAgICAgICBleHRyYS50b2tlbnMgPSBbXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0eXBlb2Ygb3B0aW9ucy5jb21tZW50ID09PSAnYm9vbGVhbicgJiYgb3B0aW9ucy5jb21tZW50KSB7XG4gICAgICAgICAgICAgICAgZXh0cmEuY29tbWVudHMgPSBbXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0eXBlb2Ygb3B0aW9ucy50b2xlcmFudCA9PT0gJ2Jvb2xlYW4nICYmIG9wdGlvbnMudG9sZXJhbnQpIHtcbiAgICAgICAgICAgICAgICBleHRyYS5lcnJvcnMgPSBbXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChsZW5ndGggPiAwKSB7XG4gICAgICAgICAgICBpZiAodHlwZW9mIHNvdXJjZVswXSA9PT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICAvLyBUcnkgZmlyc3QgdG8gY29udmVydCB0byBhIHN0cmluZy4gVGhpcyBpcyBnb29kIGFzIGZhc3QgcGF0aFxuICAgICAgICAgICAgICAgIC8vIGZvciBvbGQgSUUgd2hpY2ggdW5kZXJzdGFuZHMgc3RyaW5nIGluZGV4aW5nIGZvciBzdHJpbmdcbiAgICAgICAgICAgICAgICAvLyBsaXRlcmFscyBvbmx5IGFuZCBub3QgZm9yIHN0cmluZyBvYmplY3QuXG4gICAgICAgICAgICAgICAgaWYgKGNvZGUgaW5zdGFuY2VvZiBTdHJpbmcpIHtcbiAgICAgICAgICAgICAgICAgICAgc291cmNlID0gY29kZS52YWx1ZU9mKCk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgLy8gRm9yY2UgYWNjZXNzaW5nIHRoZSBjaGFyYWN0ZXJzIHZpYSBhbiBhcnJheS5cbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHNvdXJjZVswXSA9PT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICAgICAgc291cmNlID0gc3RyaW5nVG9BcnJheShjb2RlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBwYXRjaCgpO1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgcHJvZ3JhbSA9IHBhcnNlUHJvZ3JhbSgpO1xuICAgICAgICAgICAgaWYgKHR5cGVvZiBleHRyYS5jb21tZW50cyAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICBmaWx0ZXJDb21tZW50TG9jYXRpb24oKTtcbiAgICAgICAgICAgICAgICBwcm9ncmFtLmNvbW1lbnRzID0gZXh0cmEuY29tbWVudHM7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodHlwZW9mIGV4dHJhLnRva2VucyAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICBmaWx0ZXJUb2tlbkxvY2F0aW9uKCk7XG4gICAgICAgICAgICAgICAgcHJvZ3JhbS50b2tlbnMgPSBleHRyYS50b2tlbnM7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodHlwZW9mIGV4dHJhLmVycm9ycyAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICBwcm9ncmFtLmVycm9ycyA9IGV4dHJhLmVycm9ycztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChleHRyYS5yYW5nZSB8fCBleHRyYS5sb2MpIHtcbiAgICAgICAgICAgICAgICBwcm9ncmFtLmJvZHkgPSBmaWx0ZXJHcm91cChwcm9ncmFtLmJvZHkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICB0aHJvdyBlO1xuICAgICAgICB9IGZpbmFsbHkge1xuICAgICAgICAgICAgdW5wYXRjaCgpO1xuICAgICAgICAgICAgZXh0cmEgPSB7fTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBwcm9ncmFtO1xuICAgIH1cblxuICAgIC8vIFN5bmMgd2l0aCBwYWNrYWdlLmpzb24uXG4gICAgZXhwb3J0cy52ZXJzaW9uID0gJzEuMC40JztcblxuICAgIGV4cG9ydHMucGFyc2UgPSBwYXJzZTtcblxuICAgIC8vIERlZXAgY29weS5cbiAgICBleHBvcnRzLlN5bnRheCA9IChmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBuYW1lLCB0eXBlcyA9IHt9O1xuXG4gICAgICAgIGlmICh0eXBlb2YgT2JqZWN0LmNyZWF0ZSA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICAgICAgdHlwZXMgPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuICAgICAgICB9XG5cbiAgICAgICAgZm9yIChuYW1lIGluIFN5bnRheCkge1xuICAgICAgICA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blxubW9kdWxlLmV4cG9ydHMgPSB1bmlxdWUiXX0= | |
;require=(function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({"ndarray-fill":[function(require,module,exports){ | |
module.exports=require('uqHaBP'); | |
},{}],"uqHaBP":[function(require,module,exports){ | |
"use strict" | |
var fill = require("cwise")({ | |
args: ["index", "array", "scalar"], | |
body: function(idx, out, f) { | |
out = f.apply(undefined, idx) | |
} | |
}) | |
module.exports = function(array, f) { | |
fill(array, f) | |
return array | |
} | |
},{"cwise":1}],1:[function(require,module,exports){ | |
"use strict" | |
var parse = require("cwise-parser") | |
var compile = require("cwise-compiler") | |
var REQUIRED_FIELDS = [ "args", "body" ] | |
var OPTIONAL_FIELDS = [ "pre", "post", "printCode", "funcName", "blockSize" ] | |
function createCWise(user_args) { | |
//Check parameters | |
for(var id in user_args) { | |
if(REQUIRED_FIELDS.indexOf(id) < 0 && | |
OPTIONAL_FIELDS.indexOf(id) < 0) { | |
console.warn("cwise: Unknown argument '"+id+"' passed to expression compiler") | |
} | |
} | |
for(var i=0; i<REQUIRED_FIELDS.length; ++i) { | |
if(!user_args[REQUIRED_FIELDS[i]]) { | |
throw new Error("cwise: Missing argument: " + REQUIRED_FIELDS[i]) | |
} | |
} | |
//Parse blocks | |
return compile({ | |
args: user_args.args, | |
pre: parse(user_args.pre || function(){}), | |
body: parse(user_args.body), | |
post: parse(user_args.post || function(){}), | |
debug: !!user_args.printCode, | |
funcName: user_args.funcName || user_args.body.name || "cwise", | |
blockSize: user_args.blockSize || 64 | |
}) | |
} | |
module.exports = createCWise | |
},{"cwise-parser":2,"cwise-compiler":3}],3:[function(require,module,exports){ | |
"use strict" | |
var createThunk = require("./lib/thunk.js") | |
function Procedure() { | |
this.argTypes = [] | |
this.shimArgs = [] | |
this.arrayArgs = [] | |
this.scalarArgs = [] | |
this.indexArgs = [] | |
this.shapeArgs = [] | |
this.funcName = "" | |
this.pre = null | |
this.body = null | |
this.post = null | |
this.debug = false | |
} | |
function compileCwise(user_args) { | |
//Create procedure | |
var proc = new Procedure() | |
//Parse blocks | |
proc.pre = user_args.pre | |
proc.body = user_args.body | |
proc.post = user_args.post | |
//Parse arguments | |
var proc_args = user_args.args.slice(0) | |
proc.argTypes = proc_args | |
for(var i=0; i<proc_args.length; ++i) { | |
switch(proc_args[i]) { | |
case "array": | |
proc.arrayArgs.push(i) | |
proc.shimArgs.push("array" + i) | |
if(i < proc.pre.args.length && proc.pre.args[i].count>0) { | |
throw new Error("cwise: pre() block may not reference array args") | |
} | |
if(i < proc.post.args.length && proc.post.args[i].count>0) { | |
throw new Error("cwise: post() block may not reference array args") | |
} | |
break | |
case "scalar": | |
proc.scalarArgs.push(i) | |
proc.shimArgs.push("scalar" + i) | |
break | |
case "index": | |
proc.indexArgs.push(i) | |
if(i < proc.pre.args.length && proc.pre.args[i].count > 0) { | |
throw new Error("cwise: pre() block may not reference array index") | |
} | |
if(i < proc.body.args.length && proc.body.args[i].lvalue) { | |
throw new Error("cwise: body() block may not write to array index") | |
} | |
if(i < proc.post.args.length && proc.post.args[i].count > 0) { | |
throw new Error("cwise: post() block may not reference array index") | |
} | |
break | |
case "shape": | |
proc.shapeArgs.push(i) | |
if(i < proc.pre.args.length && proc.pre.args[i].lvalue) { | |
throw new Error("cwise: pre() block may not write to array shape") | |
} | |
if(i < proc.body.args.length && proc.body.args[i].lvalue) { | |
throw new Error("cwise: body() block may not write to array shape") | |
} | |
if(i < proc.post.args.length && proc.post.args[i].lvalue) { | |
throw new Error("cwise: post() block may not write to array shape") | |
} | |
break | |
default: | |
throw new Error("cwise: Unknown argument type " + proc_args[i]) | |
} | |
} | |
//Make sure at least one array argument was specified | |
if(proc.arrayArgs.length <= 0) { | |
throw new Error("cwise: No array arguments specified") | |
} | |
//Make sure arguments are correct | |
if(proc.pre.args.length > proc_args.length) { | |
throw new Error("cwise: Too many arguments in pre() block") | |
} | |
if(proc.body.args.length > proc_args.length) { | |
throw new Error("cwise: Too many arguments in body() block") | |
} | |
if(proc.post.args.length > proc_args.length) { | |
throw new Error("cwise: Too many arguments in post() block") | |
} | |
//Check debug flag | |
proc.debug = !!user_args.printCode || !!user_args.debug | |
//Retrieve name | |
proc.funcName = user_args.funcName || "cwise" | |
//Read in block size | |
proc.blockSize = user_args.blockSize || 64 | |
return createThunk(proc) | |
} | |
module.exports = compileCwise | |
},{"./lib/thunk.js":4}],2:[function(require,module,exports){ | |
"use strict" | |
var esprima = require("esprima") | |
var uniq = require("uniq") | |
var PREFIX_COUNTER = 0 | |
function CompiledArgument(name, lvalue, rvalue) { | |
this.name = name | |
this.lvalue = lvalue | |
this.rvalue = rvalue | |
this.count = 0 | |
} | |
function CompiledRoutine(body, args, thisVars, localVars) { | |
this.body = body | |
this.args = args | |
this.thisVars = thisVars | |
this.localVars = localVars | |
} | |
function isGlobal(identifier) { | |
if(identifier === "eval") { | |
throw new Error("cwise-parser: eval() not allowed") | |
} | |
if(typeof window !== "undefined") { | |
return identifier in window | |
} else if(typeof GLOBAL !== "undefined") { | |
return identifier in GLOBAL | |
} else if(typeof self !== "undefined") { | |
return identifier in self | |
} else { | |
return false | |
} | |
} | |
function getArgNames(ast) { | |
var params = ast.body[0].expression.callee.params | |
var names = new Array(params.length) | |
for(var i=0; i<params.length; ++i) { | |
names[i] = params[i].name | |
} | |
return names | |
} | |
function preprocess(func) { | |
var src = ["(", func, ")()"].join("") | |
var ast = esprima.parse(src, { range: true }) | |
//Compute new prefix | |
var prefix = "_inline_" + (PREFIX_COUNTER++) + "_" | |
//Parse out arguments | |
var argNames = getArgNames(ast) | |
var compiledArgs = new Array(argNames.length) | |
for(var i=0; i<argNames.length; ++i) { | |
compiledArgs[i] = new CompiledArgument([prefix, "arg", i, "_"].join(""), false, false) | |
} | |
//Create temporary data structure for source rewriting | |
var exploded = new Array(src.length) | |
for(var i=0, n=src.length; i<n; ++i) { | |
exploded[i] = src.charAt(i) | |
} | |
//Local variables | |
var localVars = [] | |
var thisVars = [] | |
var computedThis = false | |
//Retrieves a local variable | |
function createLocal(id) { | |
var nstr = prefix + id.replace(/\_/g, "__") | |
localVars.push(nstr) | |
return nstr | |
} | |
//Creates a this variable | |
function createThisVar(id) { | |
var nstr = "this_" + id.replace(/\_/g, "__") | |
thisVars.push(nstr) | |
return nstr | |
} | |
//Rewrites an ast node | |
function rewrite(node, nstr) { | |
var lo = node.range[0], hi = node.range[1] | |
for(var i=lo+1; i<hi; ++i) { | |
exploded[i] = "" | |
} | |
exploded[lo] = nstr | |
} | |
//Remove any underscores | |
function escapeString(str) { | |
return "'"+(str.replace(/\_/g, "\\_").replace(/\'/g, "\'"))+"'" | |
} | |
//Returns the source of an identifier | |
function source(node) { | |
return exploded.slice(node.range[0], node.range[1]).join("") | |
} | |
//Computes the usage of a node | |
var LVALUE = 1 | |
var RVALUE = 2 | |
function getUsage(node) { | |
if(node.parent.type === "AssignmentExpression") { | |
if(node.parent.left === node) { | |
if(node.parent.operator === "=") { | |
return LVALUE | |
} | |
return LVALUE|RVALUE | |
} | |
} | |
if(node.parent.type === "UpdateExpression") { | |
return LVALUE|RVALUE | |
} | |
return RVALUE | |
} | |
//Handle visiting a node | |
(function visit(node, parent) { | |
node.parent = parent | |
if(node.type === "MemberExpression") { | |
//Handle member expression | |
if(node.computed) { | |
visit(node.object, node) | |
visit(node.property, node) | |
} else if(node.object.type === "ThisExpression") { | |
rewrite(node, createThisVar(node.property.name)) | |
} else { | |
visit(node.object, node) | |
} | |
} else if(node.type === "ThisExpression") { | |
throw new Error("cwise-parser: Computed this is not allowed") | |
} else if(node.type === "Identifier") { | |
//Handle identifier | |
var name = node.name | |
var argNo = argNames.indexOf(name) | |
if(argNo >= 0) { | |
var carg = compiledArgs[argNo] | |
var usage = getUsage(node) | |
if(usage & LVALUE) { | |
carg.lvalue = true | |
} | |
if(usage & RVALUE) { | |
carg.rvalue = true | |
} | |
++carg.count | |
rewrite(node, carg.name) | |
} else if(isGlobal(name)) { | |
//Don't rewrite globals | |
} else { | |
rewrite(node, createLocal(name)) | |
} | |
} else if(node.type === "Literal") { | |
if(typeof node.value === "string") { | |
rewrite(node, escapeString(node.value)) | |
} | |
} else if(node.type === "WithStatement") { | |
throw new Error("cwise-parser: with() statements not allowed") | |
} else { | |
//Visit all children | |
var keys = Object.keys(node) | |
for(var i=0, n=keys.length; i<n; ++i) { | |
if(keys[i] === "parent") { | |
continue | |
} | |
var value = node[keys[i]] | |
if(value) { | |
if(value instanceof Array) { | |
for(var j=0; j<value.length; ++j) { | |
if(value[j] && typeof value[j].type === "string") { | |
visit(value[j], node) | |
} | |
} | |
} else if(typeof value.type === "string") { | |
visit(value, node) | |
} | |
} | |
} | |
} | |
})(ast.body[0].expression.callee.body, undefined) | |
//Remove duplicate variables | |
uniq(localVars) | |
uniq(thisVars) | |
//Return body | |
var routine = new CompiledRoutine(source(ast.body[0].expression.callee.body), compiledArgs, thisVars, localVars) | |
return routine | |
} | |
module.exports = preprocess | |
},{"esprima":5,"uniq":6}],5:[function(require,module,exports){ | |
(function(){/* | |
Copyright (C) 2012 Ariya Hidayat <[email protected]> | |
Copyright (C) 2012 Mathias Bynens <[email protected]> | |
Copyright (C) 2012 Joost-Wim Boekesteijn <[email protected]> | |
Copyright (C) 2012 Kris Kowal <[email protected]> | |
Copyright (C) 2012 Yusuke Suzuki <[email protected]> | |
Copyright (C) 2012 Arpad Borsos <[email protected]> | |
Copyright (C) 2011 Ariya Hidayat <[email protected]> | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions are met: | |
* Redistributions of source code must retain the above copyright | |
notice, this list of conditions and the following disclaimer. | |
* Redistributions in binary form must reproduce the above copyright | |
notice, this list of conditions and the following disclaimer in the | |
documentation and/or other materials provided with the distribution. | |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY | |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
*/ | |
/*jslint bitwise:true plusplus:true */ | |
/*global esprima:true, define:true, exports:true, window: true, | |
throwError: true, createLiteral: true, generateStatement: true, | |
parseAssignmentExpression: true, parseBlock: true, parseExpression: true, | |
parseFunctionDeclaration: true, parseFunctionExpression: true, | |
parseFunctionSourceElements: true, parseVariableIdentifier: true, | |
parseLeftHandSideExpression: true, | |
parseStatement: true, parseSourceElement: true */ | |
(function (root, factory) { | |
'use strict'; | |
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, | |
// Rhino, and plain browser loading. | |
if (typeof define === 'function' && define.amd) { | |
define(['exports'], factory); | |
} else if (typeof exports !== 'undefined') { | |
factory(exports); | |
} else { | |
factory((root.esprima = {})); | |
} | |
}(this, function (exports) { | |
'use strict'; | |
var Token, | |
TokenName, | |
Syntax, | |
PropertyKind, | |
Messages, | |
Regex, | |
source, | |
strict, | |
index, | |
lineNumber, | |
lineStart, | |
length, | |
buffer, | |
state, | |
extra; | |
Token = { | |
BooleanLiteral: 1, | |
EOF: 2, | |
Identifier: 3, | |
Keyword: 4, | |
NullLiteral: 5, | |
NumericLiteral: 6, | |
Punctuator: 7, | |
StringLiteral: 8 | |
}; | |
TokenName = {}; | |
TokenName[Token.BooleanLiteral] = 'Boolean'; | |
TokenName[Token.EOF] = '<end>'; | |
TokenName[Token.Identifier] = 'Identifier'; | |
TokenName[Token.Keyword] = 'Keyword'; | |
TokenName[Token.NullLiteral] = 'Null'; | |
TokenName[Token.NumericLiteral] = 'Numeric'; | |
TokenName[Token.Punctuator] = 'Punctuator'; | |
TokenName[Token.StringLiteral] = 'String'; | |
Syntax = { | |
AssignmentExpression: 'AssignmentExpression', | |
ArrayExpression: 'ArrayExpression', | |
BlockStatement: 'BlockStatement', | |
BinaryExpression: 'BinaryExpression', | |
BreakStatement: 'BreakStatement', | |
CallExpression: 'CallExpression', | |
CatchClause: 'CatchClause', | |
ConditionalExpression: 'ConditionalExpression', | |
ContinueStatement: 'ContinueStatement', | |
DoWhileStatement: 'DoWhileStatement', | |
DebuggerStatement: 'DebuggerStatement', | |
EmptyStatement: 'EmptyStatement', | |
ExpressionStatement: 'ExpressionStatement', | |
ForStatement: 'ForStatement', | |
ForInStatement: 'ForInStatement', | |
FunctionDeclaration: 'FunctionDeclaration', | |
FunctionExpression: 'FunctionExpression', | |
Identifier: 'Identifier', | |
IfStatement: 'IfStatement', | |
Literal: 'Literal', | |
LabeledStatement: 'LabeledStatement', | |
LogicalExpression: 'LogicalExpression', | |
MemberExpression: 'MemberExpression', | |
NewExpression: 'NewExpression', | |
ObjectExpression: 'ObjectExpression', | |
Program: 'Program', | |
Property: 'Property', | |
ReturnStatement: 'ReturnStatement', | |
SequenceExpression: 'SequenceExpression', | |
SwitchStatement: 'SwitchStatement', | |
SwitchCase: 'SwitchCase', | |
ThisExpression: 'ThisExpression', | |
ThrowStatement: 'ThrowStatement', | |
TryStatement: 'TryStatement', | |
UnaryExpression: 'UnaryExpression', | |
UpdateExpression: 'UpdateExpression', | |
VariableDeclaration: 'VariableDeclaration', | |
VariableDeclarator: 'VariableDeclarator', | |
WhileStatement: 'WhileStatement', | |
WithStatement: 'WithStatement' | |
}; | |
PropertyKind = { | |
Data: 1, | |
Get: 2, | |
Set: 4 | |
}; | |
// Error messages should be identical to V8. | |
Messages = { | |
UnexpectedToken: 'Unexpected token %0', | |
UnexpectedNumber: 'Unexpected number', | |
UnexpectedString: 'Unexpected string', | |
UnexpectedIdentifier: 'Unexpected identifier', | |
UnexpectedReserved: 'Unexpected reserved word', | |
UnexpectedEOS: 'Unexpected end of input', | |
NewlineAfterThrow: 'Illegal newline after throw', | |
InvalidRegExp: 'Invalid regular expression', | |
UnterminatedRegExp: 'Invalid regular expression: missing /', | |
InvalidLHSInAssignment: 'Invalid left-hand side in assignment', | |
InvalidLHSInForIn: 'Invalid left-hand side in for-in', | |
MultipleDefaultsInSwitch: 'More than one default clause in switch statement', | |
NoCatchOrFinally: 'Missing catch or finally after try', | |
UnknownLabel: 'Undefined label \'%0\'', | |
Redeclaration: '%0 \'%1\' has already been declared', | |
IllegalContinue: 'Illegal continue statement', | |
IllegalBreak: 'Illegal break statement', | |
IllegalReturn: 'Illegal return statement', | |
StrictModeWith: 'Strict mode code may not include a with statement', | |
StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode', | |
StrictVarName: 'Variable name may not be eval or arguments in strict mode', | |
StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode', | |
StrictParamDupe: 'Strict mode function may not have duplicate parameter names', | |
StrictFunctionName: 'Function name may not be eval or arguments in strict mode', | |
StrictOctalLiteral: 'Octal literals are not allowed in strict mode.', | |
StrictDelete: 'Delete of an unqualified identifier in strict mode.', | |
StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode', | |
AccessorDataProperty: 'Object literal may not have data and accessor property with the same name', | |
AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name', | |
StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode', | |
StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode', | |
StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode', | |
StrictReservedWord: 'Use of future reserved word in strict mode' | |
}; | |
// See also tools/generate-unicode-regex.py. | |
Regex = { | |
NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'), | |
NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]') | |
}; | |
// Ensure the condition is true, otherwise throw an error. | |
// This is only to have a better contract semantic, i.e. another safety net | |
// to catch a logic error. The condition shall be fulfilled in normal case. | |
// Do NOT use this to enforce a certain condition on any user input. | |
function assert(condition, message) { | |
if (!condition) { | |
throw new Error('ASSERT: ' + message); | |
} | |
} | |
function sliceSource(from, to) { | |
return source.slice(from, to); | |
} | |
if (typeof 'esprima'[0] === 'undefined') { | |
sliceSource = function sliceArraySource(from, to) { | |
return source.slice(from, to).join(''); | |
}; | |
} | |
function isDecimalDigit(ch) { | |
return '0123456789'.indexOf(ch) >= 0; | |
} | |
function isHexDigit(ch) { | |
return '0123456789abcdefABCDEF'.indexOf(ch) >= 0; | |
} | |
function isOctalDigit(ch) { | |
return '01234567'.indexOf(ch) >= 0; | |
} | |
// 7.2 White Space | |
function isWhiteSpace(ch) { | |
return (ch === ' ') || (ch === '\u0009') || (ch === '\u000B') || | |
(ch === '\u000C') || (ch === '\u00A0') || | |
(ch.charCodeAt(0) >= 0x1680 && | |
'\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'.indexOf(ch) >= 0); | |
} | |
// 7.3 Line Terminators | |
function isLineTerminator(ch) { | |
return (ch === '\n' || ch === '\r' || ch === '\u2028' || ch === '\u2029'); | |
} | |
// 7.6 Identifier Names and Identifiers | |
function isIdentifierStart(ch) { | |
return (ch === '$') || (ch === '_') || (ch === '\\') || | |
(ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || | |
((ch.charCodeAt(0) >= 0x80) && Regex.NonAsciiIdentifierStart.test(ch)); | |
} | |
function isIdentifierPart(ch) { | |
return (ch === '$') || (ch === '_') || (ch === '\\') || | |
(ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || | |
((ch >= '0') && (ch <= '9')) || | |
((ch.charCodeAt(0) >= 0x80) && Regex.NonAsciiIdentifierPart.test(ch)); | |
} | |
// 7.6.1.2 Future Reserved Words | |
function isFutureReservedWord(id) { | |
switch (id) { | |
// Future reserved words. | |
case 'class': | |
case 'enum': | |
case 'export': | |
case 'extends': | |
case 'import': | |
case 'super': | |
return true; | |
} | |
return false; | |
} | |
function isStrictModeReservedWord(id) { | |
switch (id) { | |
// Strict Mode reserved words. | |
case 'implements': | |
case 'interface': | |
case 'package': | |
case 'private': | |
case 'protected': | |
case 'public': | |
case 'static': | |
case 'yield': | |
case 'let': | |
return true; | |
} | |
return false; | |
} | |
function isRestrictedWord(id) { | |
return id === 'eval' || id === 'arguments'; | |
} | |
// 7.6.1.1 Keywords | |
function isKeyword(id) { | |
var keyword = false; | |
switch (id.length) { | |
case 2: | |
keyword = (id === 'if') || (id === 'in') || (id === 'do'); | |
break; | |
case 3: | |
keyword = (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try'); | |
break; | |
case 4: | |
keyword = (id === 'this') || (id === 'else') || (id === 'case') || (id === 'void') || (id === 'with'); | |
break; | |
case 5: | |
keyword = (id === 'while') || (id === 'break') || (id === 'catch') || (id === 'throw'); | |
break; | |
case 6: | |
keyword = (id === 'return') || (id === 'typeof') || (id === 'delete') || (id === 'switch'); | |
break; | |
case 7: | |
keyword = (id === 'default') || (id === 'finally'); | |
break; | |
case 8: | |
keyword = (id === 'function') || (id === 'continue') || (id === 'debugger'); | |
break; | |
case 10: | |
keyword = (id === 'instanceof'); | |
break; | |
} | |
if (keyword) { | |
return true; | |
} | |
switch (id) { | |
// Future reserved words. | |
// 'const' is specialized as Keyword in V8. | |
case 'const': | |
return true; | |
// For compatiblity to SpiderMonkey and ES.next | |
case 'yield': | |
case 'let': | |
return true; | |
} | |
if (strict && isStrictModeReservedWord(id)) { | |
return true; | |
} | |
return isFutureReservedWord(id); | |
} | |
// 7.4 Comments | |
function skipComment() { | |
var ch, blockComment, lineComment; | |
blockComment = false; | |
lineComment = false; | |
while (index < length) { | |
ch = source[index]; | |
if (lineComment) { | |
ch = source[index++]; | |
if (isLineTerminator(ch)) { | |
lineComment = false; | |
if (ch === '\r' && source[index] === '\n') { | |
++index; | |
} | |
++lineNumber; | |
lineStart = index; | |
} | |
} else if (blockComment) { | |
if (isLineTerminator(ch)) { | |
if (ch === '\r' && source[index + 1] === '\n') { | |
++index; | |
} | |
++lineNumber; | |
++index; | |
lineStart = index; | |
if (index >= length) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} else { | |
ch = source[index++]; | |
if (index >= length) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
if (ch === '*') { | |
ch = source[index]; | |
if (ch === '/') { | |
++index; | |
blockComment = false; | |
} | |
} | |
} | |
} else if (ch === '/') { | |
ch = source[index + 1]; | |
if (ch === '/') { | |
index += 2; | |
lineComment = true; | |
} else if (ch === '*') { | |
index += 2; | |
blockComment = true; | |
if (index >= length) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} else { | |
break; | |
} | |
} else if (isWhiteSpace(ch)) { | |
++index; | |
} else if (isLineTerminator(ch)) { | |
++index; | |
if (ch === '\r' && source[index] === '\n') { | |
++index; | |
} | |
++lineNumber; | |
lineStart = index; | |
} else { | |
break; | |
} | |
} | |
} | |
function scanHexEscape(prefix) { | |
var i, len, ch, code = 0; | |
len = (prefix === 'u') ? 4 : 2; | |
for (i = 0; i < len; ++i) { | |
if (index < length && isHexDigit(source[index])) { | |
ch = source[index++]; | |
code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase()); | |
} else { | |
return ''; | |
} | |
} | |
return String.fromCharCode(code); | |
} | |
function scanIdentifier() { | |
var ch, start, id, restore; | |
ch = source[index]; | |
if (!isIdentifierStart(ch)) { | |
return; | |
} | |
start = index; | |
if (ch === '\\') { | |
++index; | |
if (source[index] !== 'u') { | |
return; | |
} | |
++index; | |
restore = index; | |
ch = scanHexEscape('u'); | |
if (ch) { | |
if (ch === '\\' || !isIdentifierStart(ch)) { | |
return; | |
} | |
id = ch; | |
} else { | |
index = restore; | |
id = 'u'; | |
} | |
} else { | |
id = source[index++]; | |
} | |
while (index < length) { | |
ch = source[index]; | |
if (!isIdentifierPart(ch)) { | |
break; | |
} | |
if (ch === '\\') { | |
++index; | |
if (source[index] !== 'u') { | |
return; | |
} | |
++index; | |
restore = index; | |
ch = scanHexEscape('u'); | |
if (ch) { | |
if (ch === '\\' || !isIdentifierPart(ch)) { | |
return; | |
} | |
id += ch; | |
} else { | |
index = restore; | |
id += 'u'; | |
} | |
} else { | |
id += source[index++]; | |
} | |
} | |
// There is no keyword or literal with only one character. | |
// Thus, it must be an identifier. | |
if (id.length === 1) { | |
return { | |
type: Token.Identifier, | |
value: id, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (isKeyword(id)) { | |
return { | |
type: Token.Keyword, | |
value: id, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// 7.8.1 Null Literals | |
if (id === 'null') { | |
return { | |
type: Token.NullLiteral, | |
value: id, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// 7.8.2 Boolean Literals | |
if (id === 'true' || id === 'false') { | |
return { | |
type: Token.BooleanLiteral, | |
value: id, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
return { | |
type: Token.Identifier, | |
value: id, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// 7.7 Punctuators | |
function scanPunctuator() { | |
var start = index, | |
ch1 = source[index], | |
ch2, | |
ch3, | |
ch4; | |
// Check for most common single-character punctuators. | |
if (ch1 === ';' || ch1 === '{' || ch1 === '}') { | |
++index; | |
return { | |
type: Token.Punctuator, | |
value: ch1, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (ch1 === ',' || ch1 === '(' || ch1 === ')') { | |
++index; | |
return { | |
type: Token.Punctuator, | |
value: ch1, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// Dot (.) can also start a floating-point number, hence the need | |
// to check the next character. | |
ch2 = source[index + 1]; | |
if (ch1 === '.' && !isDecimalDigit(ch2)) { | |
return { | |
type: Token.Punctuator, | |
value: source[index++], | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// Peek more characters. | |
ch3 = source[index + 2]; | |
ch4 = source[index + 3]; | |
// 4-character punctuator: >>>= | |
if (ch1 === '>' && ch2 === '>' && ch3 === '>') { | |
if (ch4 === '=') { | |
index += 4; | |
return { | |
type: Token.Punctuator, | |
value: '>>>=', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
} | |
// 3-character punctuators: === !== >>> <<= >>= | |
if (ch1 === '=' && ch2 === '=' && ch3 === '=') { | |
index += 3; | |
return { | |
type: Token.Punctuator, | |
value: '===', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (ch1 === '!' && ch2 === '=' && ch3 === '=') { | |
index += 3; | |
return { | |
type: Token.Punctuator, | |
value: '!==', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (ch1 === '>' && ch2 === '>' && ch3 === '>') { | |
index += 3; | |
return { | |
type: Token.Punctuator, | |
value: '>>>', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (ch1 === '<' && ch2 === '<' && ch3 === '=') { | |
index += 3; | |
return { | |
type: Token.Punctuator, | |
value: '<<=', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
if (ch1 === '>' && ch2 === '>' && ch3 === '=') { | |
index += 3; | |
return { | |
type: Token.Punctuator, | |
value: '>>=', | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// 2-character punctuators: <= >= == != ++ -- << >> && || | |
// += -= *= %= &= |= ^= /= | |
if (ch2 === '=') { | |
if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) { | |
index += 2; | |
return { | |
type: Token.Punctuator, | |
value: ch1 + ch2, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
} | |
if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0)) { | |
if ('+-<>&|'.indexOf(ch2) >= 0) { | |
index += 2; | |
return { | |
type: Token.Punctuator, | |
value: ch1 + ch2, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
} | |
// The remaining 1-character punctuators. | |
if ('[]<>+-*%&|^!~?:=/'.indexOf(ch1) >= 0) { | |
return { | |
type: Token.Punctuator, | |
value: source[index++], | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
} | |
// 7.8.3 Numeric Literals | |
function scanNumericLiteral() { | |
var number, start, ch; | |
ch = source[index]; | |
assert(isDecimalDigit(ch) || (ch === '.'), | |
'Numeric literal must start with a decimal digit or a decimal point'); | |
start = index; | |
number = ''; | |
if (ch !== '.') { | |
number = source[index++]; | |
ch = source[index]; | |
// Hex number starts with '0x'. | |
// Octal number starts with '0'. | |
if (number === '0') { | |
if (ch === 'x' || ch === 'X') { | |
number += source[index++]; | |
while (index < length) { | |
ch = source[index]; | |
if (!isHexDigit(ch)) { | |
break; | |
} | |
number += source[index++]; | |
} | |
if (number.length <= 2) { | |
// only 0x | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
if (index < length) { | |
ch = source[index]; | |
if (isIdentifierStart(ch)) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} | |
return { | |
type: Token.NumericLiteral, | |
value: parseInt(number, 16), | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} else if (isOctalDigit(ch)) { | |
number += source[index++]; | |
while (index < length) { | |
ch = source[index]; | |
if (!isOctalDigit(ch)) { | |
break; | |
} | |
number += source[index++]; | |
} | |
if (index < length) { | |
ch = source[index]; | |
if (isIdentifierStart(ch) || isDecimalDigit(ch)) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} | |
return { | |
type: Token.NumericLiteral, | |
value: parseInt(number, 8), | |
octal: true, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// decimal number starts with '0' such as '09' is illegal. | |
if (isDecimalDigit(ch)) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} | |
while (index < length) { | |
ch = source[index]; | |
if (!isDecimalDigit(ch)) { | |
break; | |
} | |
number += source[index++]; | |
} | |
} | |
if (ch === '.') { | |
number += source[index++]; | |
while (index < length) { | |
ch = source[index]; | |
if (!isDecimalDigit(ch)) { | |
break; | |
} | |
number += source[index++]; | |
} | |
} | |
if (ch === 'e' || ch === 'E') { | |
number += source[index++]; | |
ch = source[index]; | |
if (ch === '+' || ch === '-') { | |
number += source[index++]; | |
} | |
ch = source[index]; | |
if (isDecimalDigit(ch)) { | |
number += source[index++]; | |
while (index < length) { | |
ch = source[index]; | |
if (!isDecimalDigit(ch)) { | |
break; | |
} | |
number += source[index++]; | |
} | |
} else { | |
ch = 'character ' + ch; | |
if (index >= length) { | |
ch = '<end>'; | |
} | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} | |
if (index < length) { | |
ch = source[index]; | |
if (isIdentifierStart(ch)) { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
} | |
return { | |
type: Token.NumericLiteral, | |
value: parseFloat(number), | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
// 7.8.4 String Literals | |
function scanStringLiteral() { | |
var str = '', quote, start, ch, code, unescaped, restore, octal = false; | |
quote = source[index]; | |
assert((quote === '\'' || quote === '"'), | |
'String literal must starts with a quote'); | |
start = index; | |
++index; | |
while (index < length) { | |
ch = source[index++]; | |
if (ch === quote) { | |
quote = ''; | |
break; | |
} else if (ch === '\\') { | |
ch = source[index++]; | |
if (!isLineTerminator(ch)) { | |
switch (ch) { | |
case 'n': | |
str += '\n'; | |
break; | |
case 'r': | |
str += '\r'; | |
break; | |
case 't': | |
str += '\t'; | |
break; | |
case 'u': | |
case 'x': | |
restore = index; | |
unescaped = scanHexEscape(ch); | |
if (unescaped) { | |
str += unescaped; | |
} else { | |
index = restore; | |
str += ch; | |
} | |
break; | |
case 'b': | |
str += '\b'; | |
break; | |
case 'f': | |
str += '\f'; | |
break; | |
case 'v': | |
str += '\x0B'; | |
break; | |
default: | |
if (isOctalDigit(ch)) { | |
code = '01234567'.indexOf(ch); | |
// \0 is not octal escape sequence | |
if (code !== 0) { | |
octal = true; | |
} | |
if (index < length && isOctalDigit(source[index])) { | |
octal = true; | |
code = code * 8 + '01234567'.indexOf(source[index++]); | |
// 3 digits are only allowed when string starts | |
// with 0, 1, 2, 3 | |
if ('0123'.indexOf(ch) >= 0 && | |
index < length && | |
isOctalDigit(source[index])) { | |
code = code * 8 + '01234567'.indexOf(source[index++]); | |
} | |
} | |
str += String.fromCharCode(code); | |
} else { | |
str += ch; | |
} | |
break; | |
} | |
} else { | |
++lineNumber; | |
if (ch === '\r' && source[index] === '\n') { | |
++index; | |
} | |
} | |
} else if (isLineTerminator(ch)) { | |
break; | |
} else { | |
str += ch; | |
} | |
} | |
if (quote !== '') { | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
return { | |
type: Token.StringLiteral, | |
value: str, | |
octal: octal, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [start, index] | |
}; | |
} | |
function scanRegExp() { | |
var str, ch, start, pattern, flags, value, classMarker = false, restore, terminated = false; | |
buffer = null; | |
skipComment(); | |
start = index; | |
ch = source[index]; | |
assert(ch === '/', 'Regular expression literal must start with a slash'); | |
str = source[index++]; | |
while (index < length) { | |
ch = source[index++]; | |
str += ch; | |
if (ch === '\\') { | |
ch = source[index++]; | |
// ECMA-262 7.8.5 | |
if (isLineTerminator(ch)) { | |
throwError({}, Messages.UnterminatedRegExp); | |
} | |
str += ch; | |
} else if (classMarker) { | |
if (ch === ']') { | |
classMarker = false; | |
} | |
} else { | |
if (ch === '/') { | |
terminated = true; | |
break; | |
} else if (ch === '[') { | |
classMarker = true; | |
} else if (isLineTerminator(ch)) { | |
throwError({}, Messages.UnterminatedRegExp); | |
} | |
} | |
} | |
if (!terminated) { | |
throwError({}, Messages.UnterminatedRegExp); | |
} | |
// Exclude leading and trailing slash. | |
pattern = str.substr(1, str.length - 2); | |
flags = ''; | |
while (index < length) { | |
ch = source[index]; | |
if (!isIdentifierPart(ch)) { | |
break; | |
} | |
++index; | |
if (ch === '\\' && index < length) { | |
ch = source[index]; | |
if (ch === 'u') { | |
++index; | |
restore = index; | |
ch = scanHexEscape('u'); | |
if (ch) { | |
flags += ch; | |
str += '\\u'; | |
for (; restore < index; ++restore) { | |
str += source[restore]; | |
} | |
} else { | |
index = restore; | |
flags += 'u'; | |
str += '\\u'; | |
} | |
} else { | |
str += '\\'; | |
} | |
} else { | |
flags += ch; | |
str += ch; | |
} | |
} | |
try { | |
value = new RegExp(pattern, flags); | |
} catch (e) { | |
throwError({}, Messages.InvalidRegExp); | |
} | |
return { | |
literal: str, | |
value: value, | |
range: [start, index] | |
}; | |
} | |
function isIdentifierName(token) { | |
return token.type === Token.Identifier || | |
token.type === Token.Keyword || | |
token.type === Token.BooleanLiteral || | |
token.type === Token.NullLiteral; | |
} | |
function advance() { | |
var ch, token; | |
skipComment(); | |
if (index >= length) { | |
return { | |
type: Token.EOF, | |
lineNumber: lineNumber, | |
lineStart: lineStart, | |
range: [index, index] | |
}; | |
} | |
token = scanPunctuator(); | |
if (typeof token !== 'undefined') { | |
return token; | |
} | |
ch = source[index]; | |
if (ch === '\'' || ch === '"') { | |
return scanStringLiteral(); | |
} | |
if (ch === '.' || isDecimalDigit(ch)) { | |
return scanNumericLiteral(); | |
} | |
token = scanIdentifier(); | |
if (typeof token !== 'undefined') { | |
return token; | |
} | |
throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); | |
} | |
function lex() { | |
var token; | |
if (buffer) { | |
index = buffer.range[1]; | |
lineNumber = buffer.lineNumber; | |
lineStart = buffer.lineStart; | |
token = buffer; | |
buffer = null; | |
return token; | |
} | |
buffer = null; | |
return advance(); | |
} | |
function lookahead() { | |
var pos, line, start; | |
if (buffer !== null) { | |
return buffer; | |
} | |
pos = index; | |
line = lineNumber; | |
start = lineStart; | |
buffer = advance(); | |
index = pos; | |
lineNumber = line; | |
lineStart = start; | |
return buffer; | |
} | |
// Return true if there is a line terminator before the next token. | |
function peekLineTerminator() { | |
var pos, line, start, found; | |
pos = index; | |
line = lineNumber; | |
start = lineStart; | |
skipComment(); | |
found = lineNumber !== line; | |
index = pos; | |
lineNumber = line; | |
lineStart = start; | |
return found; | |
} | |
// Throw an exception | |
function throwError(token, messageFormat) { | |
var error, | |
args = Array.prototype.slice.call(arguments, 2), | |
msg = messageFormat.replace( | |
/%(\d)/g, | |
function (whole, index) { | |
return args[index] || ''; | |
} | |
); | |
if (typeof token.lineNumber === 'number') { | |
error = new Error('Line ' + token.lineNumber + ': ' + msg); | |
error.index = token.range[0]; | |
error.lineNumber = token.lineNumber; | |
error.column = token.range[0] - lineStart + 1; | |
} else { | |
error = new Error('Line ' + lineNumber + ': ' + msg); | |
error.index = index; | |
error.lineNumber = lineNumber; | |
error.column = index - lineStart + 1; | |
} | |
throw error; | |
} | |
function throwErrorTolerant() { | |
try { | |
throwError.apply(null, arguments); | |
} catch (e) { | |
if (extra.errors) { | |
extra.errors.push(e); | |
} else { | |
throw e; | |
} | |
} | |
} | |
// Throw an exception because of the token. | |
function throwUnexpected(token) { | |
if (token.type === Token.EOF) { | |
throwError(token, Messages.UnexpectedEOS); | |
} | |
if (token.type === Token.NumericLiteral) { | |
throwError(token, Messages.UnexpectedNumber); | |
} | |
if (token.type === Token.StringLiteral) { | |
throwError(token, Messages.UnexpectedString); | |
} | |
if (token.type === Token.Identifier) { | |
throwError(token, Messages.UnexpectedIdentifier); | |
} | |
if (token.type === Token.Keyword) { | |
if (isFutureReservedWord(token.value)) { | |
throwError(token, Messages.UnexpectedReserved); | |
} else if (strict && isStrictModeReservedWord(token.value)) { | |
throwErrorTolerant(token, Messages.StrictReservedWord); | |
return; | |
} | |
throwError(token, Messages.UnexpectedToken, token.value); | |
} | |
// BooleanLiteral, NullLiteral, or Punctuator. | |
throwError(token, Messages.UnexpectedToken, token.value); | |
} | |
// Expect the next token to match the specified punctuator. | |
// If not, an exception will be thrown. | |
function expect(value) { | |
var token = lex(); | |
if (token.type !== Token.Punctuator || token.value !== value) { | |
throwUnexpected(token); | |
} | |
} | |
// Expect the next token to match the specified keyword. | |
// If not, an exception will be thrown. | |
function expectKeyword(keyword) { | |
var token = lex(); | |
if (token.type !== Token.Keyword || token.value !== keyword) { | |
throwUnexpected(token); | |
} | |
} | |
// Return true if the next token matches the specified punctuator. | |
function match(value) { | |
var token = lookahead(); | |
return token.type === Token.Punctuator && token.value === value; | |
} | |
// Return true if the next token matches the specified keyword | |
function matchKeyword(keyword) { | |
var token = lookahead(); | |
return token.type === Token.Keyword && token.value === keyword; | |
} | |
// Return true if the next token is an assignment operator | |
function matchAssign() { | |
var token = lookahead(), | |
op = token.value; | |
if (token.type !== Token.Punctuator) { | |
return false; | |
} | |
return op === '=' || | |
op === '*=' || | |
op === '/=' || | |
op === '%=' || | |
op === '+=' || | |
op === '-=' || | |
op === '<<=' || | |
op === '>>=' || | |
op === '>>>=' || | |
op === '&=' || | |
op === '^=' || | |
op === '|='; | |
} | |
function consumeSemicolon() { | |
var token, line; | |
// Catch the very common case first. | |
if (source[index] === ';') { | |
lex(); | |
return; | |
} | |
line = lineNumber; | |
skipComment(); | |
if (lineNumber !== line) { | |
return; | |
} | |
if (match(';')) { | |
lex(); | |
return; | |
} | |
token = lookahead(); | |
if (token.type !== Token.EOF && !match('}')) { | |
throwUnexpected(token); | |
} | |
} | |
// Return true if provided expression is LeftHandSideExpression | |
function isLeftHandSide(expr) { | |
return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression; | |
} | |
// 11.1.4 Array Initialiser | |
function parseArrayInitialiser() { | |
var elements = []; | |
expect('['); | |
while (!match(']')) { | |
if (match(',')) { | |
lex(); | |
elements.push(null); | |
} else { | |
elements.push(parseAssignmentExpression()); | |
if (!match(']')) { | |
expect(','); | |
} | |
} | |
} | |
expect(']'); | |
return { | |
type: Syntax.ArrayExpression, | |
elements: elements | |
}; | |
} | |
// 11.1.5 Object Initialiser | |
function parsePropertyFunction(param, first) { | |
var previousStrict, body; | |
previousStrict = strict; | |
body = parseFunctionSourceElements(); | |
if (first && strict && isRestrictedWord(param[0].name)) { | |
throwErrorTolerant(first, Messages.StrictParamName); | |
} | |
strict = previousStrict; | |
return { | |
type: Syntax.FunctionExpression, | |
id: null, | |
params: param, | |
defaults: [], | |
body: body, | |
rest: null, | |
generator: false, | |
expression: false | |
}; | |
} | |
function parseObjectPropertyKey() { | |
var token = lex(); | |
// Note: This function is called only from parseObjectProperty(), where | |
// EOF and Punctuator tokens are already filtered out. | |
if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) { | |
if (strict && token.octal) { | |
throwErrorTolerant(token, Messages.StrictOctalLiteral); | |
} | |
return createLiteral(token); | |
} | |
return { | |
type: Syntax.Identifier, | |
name: token.value | |
}; | |
} | |
function parseObjectProperty() { | |
var token, key, id, param; | |
token = lookahead(); | |
if (token.type === Token.Identifier) { | |
id = parseObjectPropertyKey(); | |
// Property Assignment: Getter and Setter. | |
if (token.value === 'get' && !match(':')) { | |
key = parseObjectPropertyKey(); | |
expect('('); | |
expect(')'); | |
return { | |
type: Syntax.Property, | |
key: key, | |
value: parsePropertyFunction([]), | |
kind: 'get' | |
}; | |
} else if (token.value === 'set' && !match(':')) { | |
key = parseObjectPropertyKey(); | |
expect('('); | |
token = lookahead(); | |
if (token.type !== Token.Identifier) { | |
expect(')'); | |
throwErrorTolerant(token, Messages.UnexpectedToken, token.value); | |
return { | |
type: Syntax.Property, | |
key: key, | |
value: parsePropertyFunction([]), | |
kind: 'set' | |
}; | |
} else { | |
param = [ parseVariableIdentifier() ]; | |
expect(')'); | |
return { | |
type: Syntax.Property, | |
key: key, | |
value: parsePropertyFunction(param, token), | |
kind: 'set' | |
}; | |
} | |
} else { | |
expect(':'); | |
return { | |
type: Syntax.Property, | |
key: id, | |
value: parseAssignmentExpression(), | |
kind: 'init' | |
}; | |
} | |
} else if (token.type === Token.EOF || token.type === Token.Punctuator) { | |
throwUnexpected(token); | |
} else { | |
key = parseObjectPropertyKey(); | |
expect(':'); | |
return { | |
type: Syntax.Property, | |
key: key, | |
value: parseAssignmentExpression(), | |
kind: 'init' | |
}; | |
} | |
} | |
function parseObjectInitialiser() { | |
var properties = [], property, name, kind, map = {}, toString = String; | |
expect('{'); | |
while (!match('}')) { | |
property = parseObjectProperty(); | |
if (property.key.type === Syntax.Identifier) { | |
name = property.key.name; | |
} else { | |
name = toString(property.key.value); | |
} | |
kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set; | |
if (Object.prototype.hasOwnProperty.call(map, name)) { | |
if (map[name] === PropertyKind.Data) { | |
if (strict && kind === PropertyKind.Data) { | |
throwErrorTolerant({}, Messages.StrictDuplicateProperty); | |
} else if (kind !== PropertyKind.Data) { | |
throwErrorTolerant({}, Messages.AccessorDataProperty); | |
} | |
} else { | |
if (kind === PropertyKind.Data) { | |
throwErrorTolerant({}, Messages.AccessorDataProperty); | |
} else if (map[name] & kind) { | |
throwErrorTolerant({}, Messages.AccessorGetSet); | |
} | |
} | |
map[name] |= kind; | |
} else { | |
map[name] = kind; | |
} | |
properties.push(property); | |
if (!match('}')) { | |
expect(','); | |
} | |
} | |
expect('}'); | |
return { | |
type: Syntax.ObjectExpression, | |
properties: properties | |
}; | |
} | |
// 11.1.6 The Grouping Operator | |
function parseGroupExpression() { | |
var expr; | |
expect('('); | |
expr = parseExpression(); | |
expect(')'); | |
return expr; | |
} | |
// 11.1 Primary Expressions | |
function parsePrimaryExpression() { | |
var token = lookahead(), | |
type = token.type; | |
if (type === Token.Identifier) { | |
return { | |
type: Syntax.Identifier, | |
name: lex().value | |
}; | |
} | |
if (type === Token.StringLiteral || type === Token.NumericLiteral) { | |
if (strict && token.octal) { | |
throwErrorTolerant(token, Messages.StrictOctalLiteral); | |
} | |
return createLiteral(lex()); | |
} | |
if (type === Token.Keyword) { | |
if (matchKeyword('this')) { | |
lex(); | |
return { | |
type: Syntax.ThisExpression | |
}; | |
} | |
if (matchKeyword('function')) { | |
return parseFunctionExpression(); | |
} | |
} | |
if (type === Token.BooleanLiteral) { | |
lex(); | |
token.value = (token.value === 'true'); | |
return createLiteral(token); | |
} | |
if (type === Token.NullLiteral) { | |
lex(); | |
token.value = null; | |
return createLiteral(token); | |
} | |
if (match('[')) { | |
return parseArrayInitialiser(); | |
} | |
if (match('{')) { | |
return parseObjectInitialiser(); | |
} | |
if (match('(')) { | |
return parseGroupExpression(); | |
} | |
if (match('/') || match('/=')) { | |
return createLiteral(scanRegExp()); | |
} | |
return throwUnexpected(lex()); | |
} | |
// 11.2 Left-Hand-Side Expressions | |
function parseArguments() { | |
var args = []; | |
expect('('); | |
if (!match(')')) { | |
while (index < length) { | |
args.push(parseAssignmentExpression()); | |
if (match(')')) { | |
break; | |
} | |
expect(','); | |
} | |
} | |
expect(')'); | |
return args; | |
} | |
function parseNonComputedProperty() { | |
var token = lex(); | |
if (!isIdentifierName(token)) { | |
throwUnexpected(token); | |
} | |
return { | |
type: Syntax.Identifier, | |
name: token.value | |
}; | |
} | |
function parseNonComputedMember() { | |
expect('.'); | |
return parseNonComputedProperty(); | |
} | |
function parseComputedMember() { | |
var expr; | |
expect('['); | |
expr = parseExpression(); | |
expect(']'); | |
return expr; | |
} | |
function parseNewExpression() { | |
var expr; | |
expectKeyword('new'); | |
expr = { | |
type: Syntax.NewExpression, | |
callee: parseLeftHandSideExpression(), | |
'arguments': [] | |
}; | |
if (match('(')) { | |
expr['arguments'] = parseArguments(); | |
} | |
return expr; | |
} | |
function parseLeftHandSideExpressionAllowCall() { | |
var expr; | |
expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); | |
while (match('.') || match('[') || match('(')) { | |
if (match('(')) { | |
expr = { | |
type: Syntax.CallExpression, | |
callee: expr, | |
'arguments': parseArguments() | |
}; | |
} else if (match('[')) { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: true, | |
object: expr, | |
property: parseComputedMember() | |
}; | |
} else { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: false, | |
object: expr, | |
property: parseNonComputedMember() | |
}; | |
} | |
} | |
return expr; | |
} | |
function parseLeftHandSideExpression() { | |
var expr; | |
expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); | |
while (match('.') || match('[')) { | |
if (match('[')) { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: true, | |
object: expr, | |
property: parseComputedMember() | |
}; | |
} else { | |
expr = { | |
type: Syntax.MemberExpression, | |
computed: false, | |
object: expr, | |
property: parseNonComputedMember() | |
}; | |
} | |
} | |
return expr; | |
} | |
// 11.3 Postfix Expressions | |
function parsePostfixExpression() { | |
var expr = parseLeftHandSideExpressionAllowCall(), token; | |
token = lookahead(); | |
if (token.type !== Token.Punctuator) { | |
return expr; | |
} | |
if ((match('++') || match('--')) && !peekLineTerminator()) { | |
// 11.3.1, 11.3.2 | |
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { | |
throwErrorTolerant({}, Messages.StrictLHSPostfix); | |
} | |
if (!isLeftHandSide(expr)) { | |
throwErrorTolerant({}, Messages.InvalidLHSInAssignment); | |
} | |
expr = { | |
type: Syntax.UpdateExpression, | |
operator: lex().value, | |
argument: expr, | |
prefix: false | |
}; | |
} | |
return expr; | |
} | |
// 11.4 Unary Operators | |
function parseUnaryExpression() { | |
var token, expr; | |
token = lookahead(); | |
if (token.type !== Token.Punctuator && token.type !== Token.Keyword) { | |
return parsePostfixExpression(); | |
} | |
if (match('++') || match('--')) { | |
token = lex(); | |
expr = parseUnaryExpression(); | |
// 11.4.4, 11.4.5 | |
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { | |
throwErrorTolerant({}, Messages.StrictLHSPrefix); | |
} | |
if (!isLeftHandSide(expr)) { | |
throwErrorTolerant({}, Messages.InvalidLHSInAssignment); | |
} | |
expr = { | |
type: Syntax.UpdateExpression, | |
operator: token.value, | |
argument: expr, | |
prefix: true | |
}; | |
return expr; | |
} | |
if (match('+') || match('-') || match('~') || match('!')) { | |
expr = { | |
type: Syntax.UnaryExpression, | |
operator: lex().value, | |
argument: parseUnaryExpression(), | |
prefix: true | |
}; | |
return expr; | |
} | |
if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) { | |
expr = { | |
type: Syntax.UnaryExpression, | |
operator: lex().value, | |
argument: parseUnaryExpression(), | |
prefix: true | |
}; | |
if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) { | |
throwErrorTolerant({}, Messages.StrictDelete); | |
} | |
return expr; | |
} | |
return parsePostfixExpression(); | |
} | |
// 11.5 Multiplicative Operators | |
function parseMultiplicativeExpression() { | |
var expr = parseUnaryExpression(); | |
while (match('*') || match('/') || match('%')) { | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseUnaryExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.6 Additive Operators | |
function parseAdditiveExpression() { | |
var expr = parseMultiplicativeExpression(); | |
while (match('+') || match('-')) { | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseMultiplicativeExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.7 Bitwise Shift Operators | |
function parseShiftExpression() { | |
var expr = parseAdditiveExpression(); | |
while (match('<<') || match('>>') || match('>>>')) { | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseAdditiveExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.8 Relational Operators | |
function parseRelationalExpression() { | |
var expr, previousAllowIn; | |
previousAllowIn = state.allowIn; | |
state.allowIn = true; | |
expr = parseShiftExpression(); | |
while (match('<') || match('>') || match('<=') || match('>=') || (previousAllowIn && matchKeyword('in')) || matchKeyword('instanceof')) { | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseShiftExpression() | |
}; | |
} | |
state.allowIn = previousAllowIn; | |
return expr; | |
} | |
// 11.9 Equality Operators | |
function parseEqualityExpression() { | |
var expr = parseRelationalExpression(); | |
while (match('==') || match('!=') || match('===') || match('!==')) { | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseRelationalExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.10 Binary Bitwise Operators | |
function parseBitwiseANDExpression() { | |
var expr = parseEqualityExpression(); | |
while (match('&')) { | |
lex(); | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: '&', | |
left: expr, | |
right: parseEqualityExpression() | |
}; | |
} | |
return expr; | |
} | |
function parseBitwiseXORExpression() { | |
var expr = parseBitwiseANDExpression(); | |
while (match('^')) { | |
lex(); | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: '^', | |
left: expr, | |
right: parseBitwiseANDExpression() | |
}; | |
} | |
return expr; | |
} | |
function parseBitwiseORExpression() { | |
var expr = parseBitwiseXORExpression(); | |
while (match('|')) { | |
lex(); | |
expr = { | |
type: Syntax.BinaryExpression, | |
operator: '|', | |
left: expr, | |
right: parseBitwiseXORExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.11 Binary Logical Operators | |
function parseLogicalANDExpression() { | |
var expr = parseBitwiseORExpression(); | |
while (match('&&')) { | |
lex(); | |
expr = { | |
type: Syntax.LogicalExpression, | |
operator: '&&', | |
left: expr, | |
right: parseBitwiseORExpression() | |
}; | |
} | |
return expr; | |
} | |
function parseLogicalORExpression() { | |
var expr = parseLogicalANDExpression(); | |
while (match('||')) { | |
lex(); | |
expr = { | |
type: Syntax.LogicalExpression, | |
operator: '||', | |
left: expr, | |
right: parseLogicalANDExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.12 Conditional Operator | |
function parseConditionalExpression() { | |
var expr, previousAllowIn, consequent; | |
expr = parseLogicalORExpression(); | |
if (match('?')) { | |
lex(); | |
previousAllowIn = state.allowIn; | |
state.allowIn = true; | |
consequent = parseAssignmentExpression(); | |
state.allowIn = previousAllowIn; | |
expect(':'); | |
expr = { | |
type: Syntax.ConditionalExpression, | |
test: expr, | |
consequent: consequent, | |
alternate: parseAssignmentExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.13 Assignment Operators | |
function parseAssignmentExpression() { | |
var token, expr; | |
token = lookahead(); | |
expr = parseConditionalExpression(); | |
if (matchAssign()) { | |
// LeftHandSideExpression | |
if (!isLeftHandSide(expr)) { | |
throwErrorTolerant({}, Messages.InvalidLHSInAssignment); | |
} | |
// 11.13.1 | |
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { | |
throwErrorTolerant(token, Messages.StrictLHSAssignment); | |
} | |
expr = { | |
type: Syntax.AssignmentExpression, | |
operator: lex().value, | |
left: expr, | |
right: parseAssignmentExpression() | |
}; | |
} | |
return expr; | |
} | |
// 11.14 Comma Operator | |
function parseExpression() { | |
var expr = parseAssignmentExpression(); | |
if (match(',')) { | |
expr = { | |
type: Syntax.SequenceExpression, | |
expressions: [ expr ] | |
}; | |
while (index < length) { | |
if (!match(',')) { | |
break; | |
} | |
lex(); | |
expr.expressions.push(parseAssignmentExpression()); | |
} | |
} | |
return expr; | |
} | |
// 12.1 Block | |
function parseStatementList() { | |
var list = [], | |
statement; | |
while (index < length) { | |
if (match('}')) { | |
break; | |
} | |
statement = parseSourceElement(); | |
if (typeof statement === 'undefined') { | |
break; | |
} | |
list.push(statement); | |
} | |
return list; | |
} | |
function parseBlock() { | |
var block; | |
expect('{'); | |
block = parseStatementList(); | |
expect('}'); | |
return { | |
type: Syntax.BlockStatement, | |
body: block | |
}; | |
} | |
// 12.2 Variable Statement | |
function parseVariableIdentifier() { | |
var token = lex(); | |
if (token.type !== Token.Identifier) { | |
throwUnexpected(token); | |
} | |
return { | |
type: Syntax.Identifier, | |
name: token.value | |
}; | |
} | |
function parseVariableDeclaration(kind) { | |
var id = parseVariableIdentifier(), | |
init = null; | |
// 12.2.1 | |
if (strict && isRestrictedWord(id.name)) { | |
throwErrorTolerant({}, Messages.StrictVarName); | |
} | |
if (kind === 'const') { | |
expect('='); | |
init = parseAssignmentExpression(); | |
} else if (match('=')) { | |
lex(); | |
init = parseAssignmentExpression(); | |
} | |
return { | |
type: Syntax.VariableDeclarator, | |
id: id, | |
init: init | |
}; | |
} | |
function parseVariableDeclarationList(kind) { | |
var list = []; | |
do { | |
list.push(parseVariableDeclaration(kind)); | |
if (!match(',')) { | |
break; | |
} | |
lex(); | |
} while (index < length); | |
return list; | |
} | |
function parseVariableStatement() { | |
var declarations; | |
expectKeyword('var'); | |
declarations = parseVariableDeclarationList(); | |
consumeSemicolon(); | |
return { | |
type: Syntax.VariableDeclaration, | |
declarations: declarations, | |
kind: 'var' | |
}; | |
} | |
// kind may be `const` or `let` | |
// Both are experimental and not in the specification yet. | |
// see http://wiki.ecmascript.org/doku.php?id=harmony:const | |
// and http://wiki.ecmascript.org/doku.php?id=harmony:let | |
function parseConstLetDeclaration(kind) { | |
var declarations; | |
expectKeyword(kind); | |
declarations = parseVariableDeclarationList(kind); | |
consumeSemicolon(); | |
return { | |
type: Syntax.VariableDeclaration, | |
declarations: declarations, | |
kind: kind | |
}; | |
} | |
// 12.3 Empty Statement | |
function parseEmptyStatement() { | |
expect(';'); | |
return { | |
type: Syntax.EmptyStatement | |
}; | |
} | |
// 12.4 Expression Statement | |
function parseExpressionStatement() { | |
var expr = parseExpression(); | |
consumeSemicolon(); | |
return { | |
type: Syntax.ExpressionStatement, | |
expression: expr | |
}; | |
} | |
// 12.5 If statement | |
function parseIfStatement() { | |
var test, consequent, alternate; | |
expectKeyword('if'); | |
expect('('); | |
test = parseExpression(); | |
expect(')'); | |
consequent = parseStatement(); | |
if (matchKeyword('else')) { | |
lex(); | |
alternate = parseStatement(); | |
} else { | |
alternate = null; | |
} | |
return { | |
type: Syntax.IfStatement, | |
test: test, | |
consequent: consequent, | |
alternate: alternate | |
}; | |
} | |
// 12.6 Iteration Statements | |
function parseDoWhileStatement() { | |
var body, test, oldInIteration; | |
expectKeyword('do'); | |
oldInIteration = state.inIteration; | |
state.inIteration = true; | |
body = parseStatement(); | |
state.inIteration = oldInIteration; | |
expectKeyword('while'); | |
expect('('); | |
test = parseExpression(); | |
expect(')'); | |
if (match(';')) { | |
lex(); | |
} | |
return { | |
type: Syntax.DoWhileStatement, | |
body: body, | |
test: test | |
}; | |
} | |
function parseWhileStatement() { | |
var test, body, oldInIteration; | |
expectKeyword('while'); | |
expect('('); | |
test = parseExpression(); | |
expect(')'); | |
oldInIteration = state.inIteration; | |
state.inIteration = true; | |
body = parseStatement(); | |
state.inIteration = oldInIteration; | |
return { | |
type: Syntax.WhileStatement, | |
test: test, | |
body: body | |
}; | |
} | |
function parseForVariableDeclaration() { | |
var token = lex(); | |
return { | |
type: Syntax.VariableDeclaration, | |
declarations: parseVariableDeclarationList(), | |
kind: token.value | |
}; | |
} | |
function parseForStatement() { | |
var init, test, update, left, right, body, oldInIteration; | |
init = test = update = null; | |
expectKeyword('for'); | |
expect('('); | |
if (match(';')) { | |
lex(); | |
} else { | |
if (matchKeyword('var') || matchKeyword('let')) { | |
state.allowIn = false; | |
init = parseForVariableDeclaration(); | |
state.allowIn = true; | |
if (init.declarations.length === 1 && matchKeyword('in')) { | |
lex(); | |
left = init; | |
right = parseExpression(); | |
init = null; | |
} | |
} else { | |
state.allowIn = false; | |
init = parseExpression(); | |
state.allowIn = true; | |
if (matchKeyword('in')) { | |
// LeftHandSideExpression | |
if (!isLeftHandSide(init)) { | |
throwErrorTolerant({}, Messages.InvalidLHSInForIn); | |
} | |
lex(); | |
left = init; | |
right = parseExpression(); | |
init = null; | |
} | |
} | |
if (typeof left === 'undefined') { | |
expect(';'); | |
} | |
} | |
if (typeof left === 'undefined') { | |
if (!match(';')) { | |
test = parseExpression(); | |
} | |
expect(';'); | |
if (!match(')')) { | |
update = parseExpression(); | |
} | |
} | |
expect(')'); | |
oldInIteration = state.inIteration; | |
state.inIteration = true; | |
body = parseStatement(); | |
state.inIteration = oldInIteration; | |
if (typeof left === 'undefined') { | |
return { | |
type: Syntax.ForStatement, | |
init: init, | |
test: test, | |
update: update, | |
body: body | |
}; | |
} | |
return { | |
type: Syntax.ForInStatement, | |
left: left, | |
right: right, | |
body: body, | |
each: false | |
}; | |
} | |
// 12.7 The continue statement | |
function parseContinueStatement() { | |
var token, label = null; | |
expectKeyword('continue'); | |
// Optimize the most common form: 'continue;'. | |
if (source[index] === ';') { | |
lex(); | |
if (!state.inIteration) { | |
throwError({}, Messages.IllegalContinue); | |
} | |
return { | |
type: Syntax.ContinueStatement, | |
label: null | |
}; | |
} | |
if (peekLineTerminator()) { | |
if (!state.inIteration) { | |
throwError({}, Messages.IllegalContinue); | |
} | |
return { | |
type: Syntax.ContinueStatement, | |
label: null | |
}; | |
} | |
token = lookahead(); | |
if (token.type === Token.Identifier) { | |
label = parseVariableIdentifier(); | |
if (!Object.prototype.hasOwnProperty.call(state.labelSet, label.name)) { | |
throwError({}, Messages.UnknownLabel, label.name); | |
} | |
} | |
consumeSemicolon(); | |
if (label === null && !state.inIteration) { | |
throwError({}, Messages.IllegalContinue); | |
} | |
return { | |
type: Syntax.ContinueStatement, | |
label: label | |
}; | |
} | |
// 12.8 The break statement | |
function parseBreakStatement() { | |
var token, label = null; | |
expectKeyword('break'); | |
// Optimize the most common form: 'break;'. | |
if (source[index] === ';') { | |
lex(); | |
if (!(state.inIteration || state.inSwitch)) { | |
throwError({}, Messages.IllegalBreak); | |
} | |
return { | |
type: Syntax.BreakStatement, | |
label: null | |
}; | |
} | |
if (peekLineTerminator()) { | |
if (!(state.inIteration || state.inSwitch)) { | |
throwError({}, Messages.IllegalBreak); | |
} | |
return { | |
type: Syntax.BreakStatement, | |
label: null | |
}; | |
} | |
token = lookahead(); | |
if (token.type === Token.Identifier) { | |
label = parseVariableIdentifier(); | |
if (!Object.prototype.hasOwnProperty.call(state.labelSet, label.name)) { | |
throwError({}, Messages.UnknownLabel, label.name); | |
} | |
} | |
consumeSemicolon(); | |
if (label === null && !(state.inIteration || state.inSwitch)) { | |
throwError({}, Messages.IllegalBreak); | |
} | |
return { | |
type: Syntax.BreakStatement, | |
label: label | |
}; | |
} | |
// 12.9 The return statement | |
function parseReturnStatement() { | |
var token, argument = null; | |
expectKeyword('return'); | |
if (!state.inFunctionBody) { | |
throwErrorTolerant({}, Messages.IllegalReturn); | |
} | |
// 'return' followed by a space and an identifier is very common. | |
if (source[index] === ' ') { | |
if (isIdentifierStart(source[index + 1])) { | |
argument = parseExpression(); | |
consumeSemicolon(); | |
return { | |
type: Syntax.ReturnStatement, | |
argument: argument | |
}; | |
} | |
} | |
if (peekLineTerminator()) { | |
return { | |
type: Syntax.ReturnStatement, | |
argument: null | |
}; | |
} | |
if (!match(';')) { | |
token = lookahead(); | |
if (!match('}') && token.type !== Token.EOF) { | |
argument = parseExpression(); | |
} | |
} | |
consumeSemicolon(); | |
return { | |
type: Syntax.ReturnStatement, | |
argument: argument | |
}; | |
} | |
// 12.10 The with statement | |
function parseWithStatement() { | |
var object, body; | |
if (strict) { | |
throwErrorTolerant({}, Messages.StrictModeWith); | |
} | |
expectKeyword('with'); | |
expect('('); | |
object = parseExpression(); | |
expect(')'); | |
body = parseStatement(); | |
return { | |
type: Syntax.WithStatement, | |
object: object, | |
body: body | |
}; | |
} | |
// 12.10 The swith statement | |
function parseSwitchCase() { | |
var test, | |
consequent = [], | |
statement; | |
if (matchKeyword('default')) { | |
lex(); | |
test = null; | |
} else { | |
expectKeyword('case'); | |
test = parseExpression(); | |
} | |
expect(':'); | |
while (index < length) { | |
if (match('}') || matchKeyword('default') || matchKeyword('case')) { | |
break; | |
} | |
statement = parseStatement(); | |
if (typeof statement === 'undefined') { | |
break; | |
} | |
consequent.push(statement); | |
} | |
return { | |
type: Syntax.SwitchCase, | |
test: test, | |
consequent: consequent | |
}; | |
} | |
function parseSwitchStatement() { | |
var discriminant, cases, clause, oldInSwitch, defaultFound; | |
expectKeyword('switch'); | |
expect('('); | |
discriminant = parseExpression(); | |
expect(')'); | |
expect('{'); | |
cases = []; | |
if (match('}')) { | |
lex(); | |
return { | |
type: Syntax.SwitchStatement, | |
discriminant: discriminant, | |
cases: cases | |
}; | |
} | |
oldInSwitch = state.inSwitch; | |
state.inSwitch = true; | |
defaultFound = false; | |
while (index < length) { | |
if (match('}')) { | |
break; | |
} | |
clause = parseSwitchCase(); | |
if (clause.test === null) { | |
if (defaultFound) { | |
throwError({}, Messages.MultipleDefaultsInSwitch); | |
} | |
defaultFound = true; | |
} | |
cases.push(clause); | |
} | |
state.inSwitch = oldInSwitch; | |
expect('}'); | |
return { | |
type: Syntax.SwitchStatement, | |
discriminant: discriminant, | |
cases: cases | |
}; | |
} | |
// 12.13 The throw statement | |
function parseThrowStatement() { | |
var argument; | |
expectKeyword('throw'); | |
if (peekLineTerminator()) { | |
throwError({}, Messages.NewlineAfterThrow); | |
} | |
argument = parseExpression(); | |
consumeSemicolon(); | |
return { | |
type: Syntax.ThrowStatement, | |
argument: argument | |
}; | |
} | |
// 12.14 The try statement | |
function parseCatchClause() { | |
var param; | |
expectKeyword('catch'); | |
expect('('); | |
if (match(')')) { | |
throwUnexpected(lookahead()); | |
} | |
param = parseVariableIdentifier(); | |
// 12.14.1 | |
if (strict && isRestrictedWord(param.name)) { | |
throwErrorTolerant({}, Messages.StrictCatchVariable); | |
} | |
expect(')'); | |
return { | |
type: Syntax.CatchClause, | |
param: param, | |
body: parseBlock() | |
}; | |
} | |
function parseTryStatement() { | |
var block, handlers = [], finalizer = null; | |
expectKeyword('try'); | |
block = parseBlock(); | |
if (matchKeyword('catch')) { | |
handlers.push(parseCatchClause()); | |
} | |
if (matchKeyword('finally')) { | |
lex(); | |
finalizer = parseBlock(); | |
} | |
if (handlers.length === 0 && !finalizer) { | |
throwError({}, Messages.NoCatchOrFinally); | |
} | |
return { | |
type: Syntax.TryStatement, | |
block: block, | |
View raw
(Sorry about that, but we can’t show files that are this big right now.)
View raw
(Sorry about that, but we can’t show files that are this big right now.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment