123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. 'use strict';
  2. exports.__esModule = true;
  3. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  4. var _cssSyntaxError = require('./css-syntax-error');
  5. var _cssSyntaxError2 = _interopRequireDefault(_cssSyntaxError);
  6. var _stringifier = require('./stringifier');
  7. var _stringifier2 = _interopRequireDefault(_stringifier);
  8. var _stringify = require('./stringify');
  9. var _stringify2 = _interopRequireDefault(_stringify);
  10. var _warnOnce = require('./warn-once');
  11. var _warnOnce2 = _interopRequireDefault(_warnOnce);
  12. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14. var cloneNode = function cloneNode(obj, parent) {
  15. var cloned = new obj.constructor();
  16. for (var i in obj) {
  17. if (!obj.hasOwnProperty(i)) continue;
  18. var value = obj[i];
  19. var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
  20. if (i === 'parent' && type === 'object') {
  21. if (parent) cloned[i] = parent;
  22. } else if (i === 'source') {
  23. cloned[i] = value;
  24. } else if (value instanceof Array) {
  25. cloned[i] = value.map(function (j) {
  26. return cloneNode(j, cloned);
  27. });
  28. } else {
  29. if (type === 'object' && value !== null) value = cloneNode(value);
  30. cloned[i] = value;
  31. }
  32. }
  33. return cloned;
  34. };
  35. /**
  36. * All node classes inherit the following common methods.
  37. *
  38. * @abstract
  39. */
  40. var Node = function () {
  41. /**
  42. * @param {object} [defaults] - value for node properties
  43. */
  44. function Node() {
  45. var defaults = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  46. _classCallCheck(this, Node);
  47. this.raws = {};
  48. if ((typeof defaults === 'undefined' ? 'undefined' : _typeof(defaults)) !== 'object' && typeof defaults !== 'undefined') {
  49. throw new Error('PostCSS nodes constructor accepts object, not ' + JSON.stringify(defaults));
  50. }
  51. for (var name in defaults) {
  52. this[name] = defaults[name];
  53. }
  54. }
  55. /**
  56. * Returns a CssSyntaxError instance containing the original position
  57. * of the node in the source, showing line and column numbers and also
  58. * a small excerpt to facilitate debugging.
  59. *
  60. * If present, an input source map will be used to get the original position
  61. * of the source, even from a previous compilation step
  62. * (e.g., from Sass compilation).
  63. *
  64. * This method produces very useful error messages.
  65. *
  66. * @param {string} message - error description
  67. * @param {object} [opts] - options
  68. * @param {string} opts.plugin - plugin name that created this error.
  69. * PostCSS will set it automatically.
  70. * @param {string} opts.word - a word inside a node’s string that should
  71. * be highlighted as the source of the error
  72. * @param {number} opts.index - an index inside a node’s string that should
  73. * be highlighted as the source of the error
  74. *
  75. * @return {CssSyntaxError} error object to throw it
  76. *
  77. * @example
  78. * if ( !variables[name] ) {
  79. * throw decl.error('Unknown variable ' + name, { word: name });
  80. * // CssSyntaxError: postcss-vars:a.sass:4:3: Unknown variable $black
  81. * // color: $black
  82. * // a
  83. * // ^
  84. * // background: white
  85. * }
  86. */
  87. Node.prototype.error = function error(message) {
  88. var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  89. if (this.source) {
  90. var pos = this.positionBy(opts);
  91. return this.source.input.error(message, pos.line, pos.column, opts);
  92. } else {
  93. return new _cssSyntaxError2.default(message);
  94. }
  95. };
  96. /**
  97. * This method is provided as a convenience wrapper for {@link Result#warn}.
  98. *
  99. * @param {Result} result - the {@link Result} instance
  100. * that will receive the warning
  101. * @param {string} text - warning message
  102. * @param {object} [opts] - options
  103. * @param {string} opts.plugin - plugin name that created this warning.
  104. * PostCSS will set it automatically.
  105. * @param {string} opts.word - a word inside a node’s string that should
  106. * be highlighted as the source of the warning
  107. * @param {number} opts.index - an index inside a node’s string that should
  108. * be highlighted as the source of the warning
  109. *
  110. * @return {Warning} created warning object
  111. *
  112. * @example
  113. * const plugin = postcss.plugin('postcss-deprecated', () => {
  114. * return (root, result) => {
  115. * root.walkDecls('bad', decl => {
  116. * decl.warn(result, 'Deprecated property bad');
  117. * });
  118. * };
  119. * });
  120. */
  121. Node.prototype.warn = function warn(result, text, opts) {
  122. var data = { node: this };
  123. for (var i in opts) {
  124. data[i] = opts[i];
  125. }return result.warn(text, data);
  126. };
  127. /**
  128. * Removes the node from its parent and cleans the parent properties
  129. * from the node and its children.
  130. *
  131. * @example
  132. * if ( decl.prop.match(/^-webkit-/) ) {
  133. * decl.remove();
  134. * }
  135. *
  136. * @return {Node} node to make calls chain
  137. */
  138. Node.prototype.remove = function remove() {
  139. if (this.parent) {
  140. this.parent.removeChild(this);
  141. }
  142. this.parent = undefined;
  143. return this;
  144. };
  145. /**
  146. * Returns a CSS string representing the node.
  147. *
  148. * @param {stringifier|syntax} [stringifier] - a syntax to use
  149. * in string generation
  150. *
  151. * @return {string} CSS string of this node
  152. *
  153. * @example
  154. * postcss.rule({ selector: 'a' }).toString() //=> "a {}"
  155. */
  156. Node.prototype.toString = function toString() {
  157. var stringifier = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _stringify2.default;
  158. if (stringifier.stringify) stringifier = stringifier.stringify;
  159. var result = '';
  160. stringifier(this, function (i) {
  161. result += i;
  162. });
  163. return result;
  164. };
  165. /**
  166. * Returns a clone of the node.
  167. *
  168. * The resulting cloned node and its (cloned) children will have
  169. * a clean parent and code style properties.
  170. *
  171. * @param {object} [overrides] - new properties to override in the clone.
  172. *
  173. * @example
  174. * const cloned = decl.clone({ prop: '-moz-' + decl.prop });
  175. * cloned.raws.before //=> undefined
  176. * cloned.parent //=> undefined
  177. * cloned.toString() //=> -moz-transform: scale(0)
  178. *
  179. * @return {Node} clone of the node
  180. */
  181. Node.prototype.clone = function clone() {
  182. var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  183. var cloned = cloneNode(this);
  184. for (var name in overrides) {
  185. cloned[name] = overrides[name];
  186. }
  187. return cloned;
  188. };
  189. /**
  190. * Shortcut to clone the node and insert the resulting cloned node
  191. * before the current node.
  192. *
  193. * @param {object} [overrides] - new properties to override in the clone.
  194. *
  195. * @example
  196. * decl.cloneBefore({ prop: '-moz-' + decl.prop });
  197. *
  198. * @return {Node} - new node
  199. */
  200. Node.prototype.cloneBefore = function cloneBefore() {
  201. var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  202. var cloned = this.clone(overrides);
  203. this.parent.insertBefore(this, cloned);
  204. return cloned;
  205. };
  206. /**
  207. * Shortcut to clone the node and insert the resulting cloned node
  208. * after the current node.
  209. *
  210. * @param {object} [overrides] - new properties to override in the clone.
  211. *
  212. * @return {Node} - new node
  213. */
  214. Node.prototype.cloneAfter = function cloneAfter() {
  215. var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  216. var cloned = this.clone(overrides);
  217. this.parent.insertAfter(this, cloned);
  218. return cloned;
  219. };
  220. /**
  221. * Inserts node(s) before the current node and removes the current node.
  222. *
  223. * @param {...Node} nodes - node(s) to replace current one
  224. *
  225. * @example
  226. * if ( atrule.name == 'mixin' ) {
  227. * atrule.replaceWith(mixinRules[atrule.params]);
  228. * }
  229. *
  230. * @return {Node} current node to methods chain
  231. */
  232. Node.prototype.replaceWith = function replaceWith() {
  233. if (this.parent) {
  234. for (var _len = arguments.length, nodes = Array(_len), _key = 0; _key < _len; _key++) {
  235. nodes[_key] = arguments[_key];
  236. }
  237. for (var _iterator = nodes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
  238. var _ref;
  239. if (_isArray) {
  240. if (_i >= _iterator.length) break;
  241. _ref = _iterator[_i++];
  242. } else {
  243. _i = _iterator.next();
  244. if (_i.done) break;
  245. _ref = _i.value;
  246. }
  247. var node = _ref;
  248. this.parent.insertBefore(this, node);
  249. }
  250. this.remove();
  251. }
  252. return this;
  253. };
  254. Node.prototype.moveTo = function moveTo(newParent) {
  255. (0, _warnOnce2.default)('Node#moveTo was deprecated. Use Container#append.');
  256. this.cleanRaws(this.root() === newParent.root());
  257. this.remove();
  258. newParent.append(this);
  259. return this;
  260. };
  261. Node.prototype.moveBefore = function moveBefore(otherNode) {
  262. (0, _warnOnce2.default)('Node#moveBefore was deprecated. Use Node#before.');
  263. this.cleanRaws(this.root() === otherNode.root());
  264. this.remove();
  265. otherNode.parent.insertBefore(otherNode, this);
  266. return this;
  267. };
  268. Node.prototype.moveAfter = function moveAfter(otherNode) {
  269. (0, _warnOnce2.default)('Node#moveAfter was deprecated. Use Node#after.');
  270. this.cleanRaws(this.root() === otherNode.root());
  271. this.remove();
  272. otherNode.parent.insertAfter(otherNode, this);
  273. return this;
  274. };
  275. /**
  276. * Returns the next child of the node’s parent.
  277. * Returns `undefined` if the current node is the last child.
  278. *
  279. * @return {Node|undefined} next node
  280. *
  281. * @example
  282. * if ( comment.text === 'delete next' ) {
  283. * const next = comment.next();
  284. * if ( next ) {
  285. * next.remove();
  286. * }
  287. * }
  288. */
  289. Node.prototype.next = function next() {
  290. if (!this.parent) return undefined;
  291. var index = this.parent.index(this);
  292. return this.parent.nodes[index + 1];
  293. };
  294. /**
  295. * Returns the previous child of the node’s parent.
  296. * Returns `undefined` if the current node is the first child.
  297. *
  298. * @return {Node|undefined} previous node
  299. *
  300. * @example
  301. * const annotation = decl.prev();
  302. * if ( annotation.type == 'comment' ) {
  303. * readAnnotation(annotation.text);
  304. * }
  305. */
  306. Node.prototype.prev = function prev() {
  307. if (!this.parent) return undefined;
  308. var index = this.parent.index(this);
  309. return this.parent.nodes[index - 1];
  310. };
  311. /**
  312. * Insert new node before current node to current node’s parent.
  313. *
  314. * Just alias for `node.parent.insertBefore(node, add)`.
  315. *
  316. * @param {Node|object|string|Node[]} add - new node
  317. *
  318. * @return {Node} this node for methods chain.
  319. *
  320. * @example
  321. * decl.before('content: ""');
  322. */
  323. Node.prototype.before = function before(add) {
  324. this.parent.insertBefore(this, add);
  325. return this;
  326. };
  327. /**
  328. * Insert new node after current node to current node’s parent.
  329. *
  330. * Just alias for `node.parent.insertAfter(node, add)`.
  331. *
  332. * @param {Node|object|string|Node[]} add - new node
  333. *
  334. * @return {Node} this node for methods chain.
  335. *
  336. * @example
  337. * decl.after('color: black');
  338. */
  339. Node.prototype.after = function after(add) {
  340. this.parent.insertAfter(this, add);
  341. return this;
  342. };
  343. Node.prototype.toJSON = function toJSON() {
  344. var fixed = {};
  345. for (var name in this) {
  346. if (!this.hasOwnProperty(name)) continue;
  347. if (name === 'parent') continue;
  348. var value = this[name];
  349. if (value instanceof Array) {
  350. fixed[name] = value.map(function (i) {
  351. if ((typeof i === 'undefined' ? 'undefined' : _typeof(i)) === 'object' && i.toJSON) {
  352. return i.toJSON();
  353. } else {
  354. return i;
  355. }
  356. });
  357. } else if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.toJSON) {
  358. fixed[name] = value.toJSON();
  359. } else {
  360. fixed[name] = value;
  361. }
  362. }
  363. return fixed;
  364. };
  365. /**
  366. * Returns a {@link Node#raws} value. If the node is missing
  367. * the code style property (because the node was manually built or cloned),
  368. * PostCSS will try to autodetect the code style property by looking
  369. * at other nodes in the tree.
  370. *
  371. * @param {string} prop - name of code style property
  372. * @param {string} [defaultType] - name of default value, it can be missed
  373. * if the value is the same as prop
  374. *
  375. * @example
  376. * const root = postcss.parse('a { background: white }');
  377. * root.nodes[0].append({ prop: 'color', value: 'black' });
  378. * root.nodes[0].nodes[1].raws.before //=> undefined
  379. * root.nodes[0].nodes[1].raw('before') //=> ' '
  380. *
  381. * @return {string} code style value
  382. */
  383. Node.prototype.raw = function raw(prop, defaultType) {
  384. var str = new _stringifier2.default();
  385. return str.raw(this, prop, defaultType);
  386. };
  387. /**
  388. * Finds the Root instance of the node’s tree.
  389. *
  390. * @example
  391. * root.nodes[0].nodes[0].root() === root
  392. *
  393. * @return {Root} root parent
  394. */
  395. Node.prototype.root = function root() {
  396. var result = this;
  397. while (result.parent) {
  398. result = result.parent;
  399. }return result;
  400. };
  401. Node.prototype.cleanRaws = function cleanRaws(keepBetween) {
  402. delete this.raws.before;
  403. delete this.raws.after;
  404. if (!keepBetween) delete this.raws.between;
  405. };
  406. Node.prototype.positionInside = function positionInside(index) {
  407. var string = this.toString();
  408. var column = this.source.start.column;
  409. var line = this.source.start.line;
  410. for (var i = 0; i < index; i++) {
  411. if (string[i] === '\n') {
  412. column = 1;
  413. line += 1;
  414. } else {
  415. column += 1;
  416. }
  417. }
  418. return { line: line, column: column };
  419. };
  420. Node.prototype.positionBy = function positionBy(opts) {
  421. var pos = this.source.start;
  422. if (opts.index) {
  423. pos = this.positionInside(opts.index);
  424. } else if (opts.word) {
  425. var index = this.toString().indexOf(opts.word);
  426. if (index !== -1) pos = this.positionInside(index);
  427. }
  428. return pos;
  429. };
  430. /**
  431. * @memberof Node#
  432. * @member {string} type - String representing the node’s type.
  433. * Possible values are `root`, `atrule`, `rule`,
  434. * `decl`, or `comment`.
  435. *
  436. * @example
  437. * postcss.decl({ prop: 'color', value: 'black' }).type //=> 'decl'
  438. */
  439. /**
  440. * @memberof Node#
  441. * @member {Container} parent - the node’s parent node.
  442. *
  443. * @example
  444. * root.nodes[0].parent == root;
  445. */
  446. /**
  447. * @memberof Node#
  448. * @member {source} source - the input source of the node
  449. *
  450. * The property is used in source map generation.
  451. *
  452. * If you create a node manually (e.g., with `postcss.decl()`),
  453. * that node will not have a `source` property and will be absent
  454. * from the source map. For this reason, the plugin developer should
  455. * consider cloning nodes to create new ones (in which case the new node’s
  456. * source will reference the original, cloned node) or setting
  457. * the `source` property manually.
  458. *
  459. * ```js
  460. * // Bad
  461. * const prefixed = postcss.decl({
  462. * prop: '-moz-' + decl.prop,
  463. * value: decl.value
  464. * });
  465. *
  466. * // Good
  467. * const prefixed = decl.clone({ prop: '-moz-' + decl.prop });
  468. * ```
  469. *
  470. * ```js
  471. * if ( atrule.name == 'add-link' ) {
  472. * const rule = postcss.rule({ selector: 'a', source: atrule.source });
  473. * atrule.parent.insertBefore(atrule, rule);
  474. * }
  475. * ```
  476. *
  477. * @example
  478. * decl.source.input.from //=> '/home/ai/a.sass'
  479. * decl.source.start //=> { line: 10, column: 2 }
  480. * decl.source.end //=> { line: 10, column: 12 }
  481. */
  482. /**
  483. * @memberof Node#
  484. * @member {object} raws - Information to generate byte-to-byte equal
  485. * node string as it was in the origin input.
  486. *
  487. * Every parser saves its own properties,
  488. * but the default CSS parser uses:
  489. *
  490. * * `before`: the space symbols before the node. It also stores `*`
  491. * and `_` symbols before the declaration (IE hack).
  492. * * `after`: the space symbols after the last child of the node
  493. * to the end of the node.
  494. * * `between`: the symbols between the property and value
  495. * for declarations, selector and `{` for rules, or last parameter
  496. * and `{` for at-rules.
  497. * * `semicolon`: contains true if the last child has
  498. * an (optional) semicolon.
  499. * * `afterName`: the space between the at-rule name and its parameters.
  500. * * `left`: the space symbols between `/*` and the comment’s text.
  501. * * `right`: the space symbols between the comment’s text
  502. * and <code>*&#47;</code>.
  503. * * `important`: the content of the important statement,
  504. * if it is not just `!important`.
  505. *
  506. * PostCSS cleans selectors, declaration values and at-rule parameters
  507. * from comments and extra spaces, but it stores origin content in raws
  508. * properties. As such, if you don’t change a declaration’s value,
  509. * PostCSS will use the raw value with comments.
  510. *
  511. * @example
  512. * const root = postcss.parse('a {\n color:black\n}')
  513. * root.first.first.raws //=> { before: '\n ', between: ':' }
  514. */
  515. return Node;
  516. }();
  517. exports.default = Node;
  518. /**
  519. * @typedef {object} position
  520. * @property {number} line - source line in file
  521. * @property {number} column - source column in file
  522. */
  523. /**
  524. * @typedef {object} source
  525. * @property {Input} input - {@link Input} with input file
  526. * @property {position} start - The starting position of the node’s source
  527. * @property {position} end - The ending position of the node’s source
  528. */
  529. module.exports = exports['default'];
  530. //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGUuZXM2Il0sIm5hbWVzIjpbImNsb25lTm9kZSIsIm9iaiIsInBhcmVudCIsImNsb25lZCIsImNvbnN0cnVjdG9yIiwiaSIsImhhc093blByb3BlcnR5IiwidmFsdWUiLCJ0eXBlIiwiQXJyYXkiLCJtYXAiLCJqIiwiTm9kZSIsImRlZmF1bHRzIiwicmF3cyIsIkVycm9yIiwiSlNPTiIsInN0cmluZ2lmeSIsIm5hbWUiLCJlcnJvciIsIm1lc3NhZ2UiLCJvcHRzIiwic291cmNlIiwicG9zIiwicG9zaXRpb25CeSIsImlucHV0IiwibGluZSIsImNvbHVtbiIsIkNzc1N5bnRheEVycm9yIiwid2FybiIsInJlc3VsdCIsInRleHQiLCJkYXRhIiwibm9kZSIsInJlbW92ZSIsInJlbW92ZUNoaWxkIiwidW5kZWZpbmVkIiwidG9TdHJpbmciLCJzdHJpbmdpZmllciIsImNsb25lIiwib3ZlcnJpZGVzIiwiY2xvbmVCZWZvcmUiLCJpbnNlcnRCZWZvcmUiLCJjbG9uZUFmdG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tLykgKSB7XG4gICAgICogICBkZWNsLnJlbW92ZSgpO1xuICAgICAqIH1cbiAgICAgKlxuICAgICAqIEByZXR1cm4ge05vZGV9IG5vZGUgdG8gbWFrZSBjYWxscyBjaGFpblxuICAgICAqL1xuICAgIHJlbW92ZSgpIHtcbiAgICAgICAgaWYgKCB0aGlzLnBhcmVudCApIHtcbiAgICAgICAgICAgIHRoaXMucGFyZW50LnJlbW92ZUNoaWxkKHRoaXMpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMucGFyZW50ID0gdW5kZWZpbmVkO1xuICAgICAgICByZXR1cm4gdGhpcztcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBSZXR1cm5zIGEgQ1NTIHN0cmluZyByZXByZXNlbnRpbmcgdGhlIG5vZGUuXG4gICAgICpcbiAgICAgKiBAcGFyYW0ge3N0cmluZ2lmaWVyfHN5bnRheH0gW3N0cmluZ2lmaWVyXSAtIGEgc3ludGF4IHRvIHVzZVxuICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW4gc3RyaW5nIGdlbmVyYXRpb25cbiAgICAgKlxuICAgICAqIEByZXR1cm4ge3N0cmluZ30gQ1NTIHN0cmluZyBvZiB0aGlzIG5vZGVcbiAgICAgKlxuICAgICAqIEBleGFtcGxlXG4gICAgICogcG9zdGNzcy5ydWxlKHsgc2VsZWN0b3I6ICdhJyB9KS50b1N0cmluZygpIC8vPT4gXCJhIHt9XCJcbiAgICAgKi9cbiAgICB0b1N0cmluZyhzdHJpbmdpZmllciA9IHN0cmluZ2lmeSkge1xuICAgICAgICBpZiAoIHN0cmluZ2lmaWVyLnN0cmluZ2lmeSApIHN0cmluZ2lmaWVyID0gc3RyaW5naWZpZXIuc3RyaW5naWZ5O1xuICAgICAgICBsZXQgcmVzdWx0ICA9ICcnO1xuICAgICAgICBzdHJpbmdpZmllcih0aGlzLCBpID0+IHtcbiAgICAgICAgICAgIHJlc3VsdCArPSBpO1xuICAgICAg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LCBhZGQpO1xuICAgICAgICByZXR1cm4gdGhpcztcbiAgICB9XG5cbiAgICB0b0pTT04oKSB7XG4gICAgICAgIGxldCBmaXhlZCA9IHsgfTtcblxuICAgICAgICBmb3IgKCBsZXQgbmFtZSBpbiB0aGlzICkge1xuICAgICAgICAgICAgaWYgKCAhdGhpcy5oYXNPd25Qcm9wZXJ0eShuYW1lKSApIGNvbnRpbnVlO1xuICAgICAgICAgICAgaWYgKCBuYW1lID09PSAncGFyZW50JyApIGNvbnRpbnVlO1xuICAgICAgICAgICAgbGV0IHZhbHVlID0gdGhpc1tuYW1lXTtcblxuICAgICAgICAgICAgaWYgKCB2YWx1ZSBpbnN0YW5jZW9mIEFycmF5ICkge1xuICAgICAgICAgICAgICAgIGZpeGVkW25hbWVdID0gdmFsdWUubWFwKCBpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCB0eXBlb2YgaSA9PT0gJ29iamVjdCcgJiYgaS50b0pTT04gKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaS50b0pTT04oKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKCB0eXBlb2YgdmFsdWUgPT09ICdvYmplY3QnICYmIHZhbHVlLnRvSlNPTiApIHtcbiAgICAgICAgICAgICAgICBmaXhlZFtuYW1lXSA9IHZhbHVlLnRvSlNPTigpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBmaXhlZFtuYW1lXSA9IHZhbHVlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGZpeGVkO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFJldHVybnMgYSB7QGxpbmsgTm9kZSNyYXdzfSB2YWx1ZS4gSWYgdGhl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ICBsaW5lICArPSAxO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjb2x1bW4gKz0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB7IGxpbmUsIGNvbHVtbiB9O1xuICAgIH1cblxuICAgIHBvc2l0aW9uQnkob3B0cykge1xuICAgICAgICBsZXQgcG9zID0gdGhpcy5zb3VyY2Uuc3RhcnQ7XG4gICAgICAgIGlmICggb3B0cy5pbmRleCApIHtcbiAgICAgICAgICAgIHBvcyA9IHRoaXMucG9zaXRpb25JbnNpZGUob3B0cy5pbmRleCk7XG4gICAgICAgIH0gZWxzZSBpZiAoIG9wdHMud29yZCApIHtcbiAgICAgICAgICAgIGxldCBpbmRleCA9IHRoaXMudG9TdHJpbmcoKS5pbmRleE9mKG9wdHMud29yZCk7XG4gICAgICAgICAgICBpZiAoIGluZGV4ICE9PSAtMSApIHBvcyA9IHRoaXMucG9zaXRpb25JbnNpZGUoaW5kZXgpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBwb3M7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlcm9mIE5vZGUjXG4gICAgICogQG1lbWJlciB7c3RyaW5nfSB0eXBlIC0gU3RyaW5nIHJlcHJlc2VudGluZyB0aGUgbm9kZeKAmXMgdHlwZS5cbiAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICBQb3NzaWJsZSB2YWx1ZXMgYXJlIGByb290YCwgYGF0cnVsZWAsIGBydWxlYCxcbiAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICBgZGVjbGAsIG9yIGBjb21tZW50YC5cbiAgICAgKlxuICAgICAqIEBleGFtcGxlXG4gICAgICogcG9zdGNzcy5kZWNsKHsgcHJvcDogJ2NvbG9yJywgdmFsdWU6ICdibGFjaycgfSkudHlwZSAvLz0+ICdkZWNsJ1xuICAgICAqL1xuXG4gICAgLyoqXG4gICAgICogQG1lbWJlcm9mIE5vZ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