aboutsummaryrefslogtreecommitdiff
path: root/node_modules/postcss/lib/lazy-result.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/postcss/lib/lazy-result.js')
-rw-r--r--node_modules/postcss/lib/lazy-result.js435
1 files changed, 435 insertions, 0 deletions
diff --git a/node_modules/postcss/lib/lazy-result.js b/node_modules/postcss/lib/lazy-result.js
new file mode 100644
index 0000000..dd13ee4
--- /dev/null
+++ b/node_modules/postcss/lib/lazy-result.js
@@ -0,0 +1,435 @@
+'use strict';
+
+exports.__esModule = true;
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+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; };
+
+var _mapGenerator = require('./map-generator');
+
+var _mapGenerator2 = _interopRequireDefault(_mapGenerator);
+
+var _stringify2 = require('./stringify');
+
+var _stringify3 = _interopRequireDefault(_stringify2);
+
+var _warnOnce = require('./warn-once');
+
+var _warnOnce2 = _interopRequireDefault(_warnOnce);
+
+var _result = require('./result');
+
+var _result2 = _interopRequireDefault(_result);
+
+var _parse = require('./parse');
+
+var _parse2 = _interopRequireDefault(_parse);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function isPromise(obj) {
+ return (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && typeof obj.then === 'function';
+}
+
+/**
+ * A Promise proxy for the result of PostCSS transformations.
+ *
+ * A `LazyResult` instance is returned by {@link Processor#process}.
+ *
+ * @example
+ * const lazy = postcss([cssnext]).process(css);
+ */
+
+var LazyResult = function () {
+ function LazyResult(processor, css, opts) {
+ _classCallCheck(this, LazyResult);
+
+ this.stringified = false;
+ this.processed = false;
+
+ var root = void 0;
+ if ((typeof css === 'undefined' ? 'undefined' : _typeof(css)) === 'object' && css !== null && css.type === 'root') {
+ root = css;
+ } else if (css instanceof LazyResult || css instanceof _result2.default) {
+ root = css.root;
+ if (css.map) {
+ if (typeof opts.map === 'undefined') opts.map = {};
+ if (!opts.map.inline) opts.map.inline = false;
+ opts.map.prev = css.map;
+ }
+ } else {
+ var parser = _parse2.default;
+ if (opts.syntax) parser = opts.syntax.parse;
+ if (opts.parser) parser = opts.parser;
+ if (parser.parse) parser = parser.parse;
+
+ try {
+ root = parser(css, opts);
+ } catch (error) {
+ this.error = error;
+ }
+ }
+
+ this.result = new _result2.default(processor, root, opts);
+ }
+
+ /**
+ * Returns a {@link Processor} instance, which will be used
+ * for CSS transformations.
+ * @type {Processor}
+ */
+
+
+ /**
+ * Processes input CSS through synchronous plugins
+ * and calls {@link Result#warnings()}.
+ *
+ * @return {Warning[]} warnings from plugins
+ */
+ LazyResult.prototype.warnings = function warnings() {
+ return this.sync().warnings();
+ };
+
+ /**
+ * Alias for the {@link LazyResult#css} property.
+ *
+ * @example
+ * lazy + '' === lazy.css;
+ *
+ * @return {string} output CSS
+ */
+
+
+ LazyResult.prototype.toString = function toString() {
+ return this.css;
+ };
+
+ /**
+ * Processes input CSS through synchronous and asynchronous plugins
+ * and calls `onFulfilled` with a Result instance. If a plugin throws
+ * an error, the `onRejected` callback will be executed.
+ *
+ * It implements standard Promise API.
+ *
+ * @param {onFulfilled} onFulfilled - callback will be executed
+ * when all plugins will finish work
+ * @param {onRejected} onRejected - callback will be executed on any error
+ *
+ * @return {Promise} Promise API to make queue
+ *
+ * @example
+ * postcss([cssnext]).process(css, { from: cssPath }).then(result => {
+ * console.log(result.css);
+ * });
+ */
+
+
+ LazyResult.prototype.then = function then(onFulfilled, onRejected) {
+ if (!('from' in this.opts)) {
+ (0, _warnOnce2.default)('Without `from` option PostCSS could generate wrong ' + 'source map and will not find Browserslist config. ' + 'Set it to CSS file path or to `undefined` to prevent ' + 'this warning.');
+ }
+ return this.async().then(onFulfilled, onRejected);
+ };
+
+ /**
+ * Processes input CSS through synchronous and asynchronous plugins
+ * and calls onRejected for each error thrown in any plugin.
+ *
+ * It implements standard Promise API.
+ *
+ * @param {onRejected} onRejected - callback will be executed on any error
+ *
+ * @return {Promise} Promise API to make queue
+ *
+ * @example
+ * postcss([cssnext]).process(css).then(result => {
+ * console.log(result.css);
+ * }).catch(error => {
+ * console.error(error);
+ * });
+ */
+
+
+ LazyResult.prototype.catch = function _catch(onRejected) {
+ return this.async().catch(onRejected);
+ };
+
+ LazyResult.prototype.handleError = function handleError(error, plugin) {
+ try {
+ this.error = error;
+ if (error.name === 'CssSyntaxError' && !error.plugin) {
+ error.plugin = plugin.postcssPlugin;
+ error.setMessage();
+ } else if (plugin.postcssVersion) {
+ var pluginName = plugin.postcssPlugin;
+ var pluginVer = plugin.postcssVersion;
+ var runtimeVer = this.result.processor.version;
+ var a = pluginVer.split('.');
+ var b = runtimeVer.split('.');
+
+ if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) {
+ console.error('Unknown error from PostCSS plugin. ' + 'Your current PostCSS version ' + 'is ' + runtimeVer + ', but ' + pluginName + ' ' + 'uses ' + pluginVer + '. Perhaps this is ' + 'the source of the error below.');
+ }
+ }
+ } catch (err) {
+ if (console && console.error) console.error(err);
+ }
+ };
+
+ LazyResult.prototype.asyncTick = function asyncTick(resolve, reject) {
+ var _this = this;
+
+ if (this.plugin >= this.processor.plugins.length) {
+ this.processed = true;
+ return resolve();
+ }
+
+ try {
+ var plugin = this.processor.plugins[this.plugin];
+ var promise = this.run(plugin);
+ this.plugin += 1;
+
+ if (isPromise(promise)) {
+ promise.then(function () {
+ _this.asyncTick(resolve, reject);
+ }).catch(function (error) {
+ _this.handleError(error, plugin);
+ _this.processed = true;
+ reject(error);
+ });
+ } else {
+ this.asyncTick(resolve, reject);
+ }
+ } catch (error) {
+ this.processed = true;
+ reject(error);
+ }
+ };
+
+ LazyResult.prototype.async = function async() {
+ var _this2 = this;
+
+ if (this.processed) {
+ return new Promise(function (resolve, reject) {
+ if (_this2.error) {
+ reject(_this2.error);
+ } else {
+ resolve(_this2.stringify());
+ }
+ });
+ }
+ if (this.processing) {
+ return this.processing;
+ }
+
+ this.processing = new Promise(function (resolve, reject) {
+ if (_this2.error) return reject(_this2.error);
+ _this2.plugin = 0;
+ _this2.asyncTick(resolve, reject);
+ }).then(function () {
+ _this2.processed = true;
+ return _this2.stringify();
+ });
+
+ return this.processing;
+ };
+
+ LazyResult.prototype.sync = function sync() {
+ if (this.processed) return this.result;
+ this.processed = true;
+
+ if (this.processing) {
+ throw new Error('Use process(css).then(cb) to work with async plugins');
+ }
+
+ if (this.error) throw this.error;
+
+ for (var _iterator = this.result.processor.plugins, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+
+ if (_isArray) {
+ if (_i >= _iterator.length) break;
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) break;
+ _ref = _i.value;
+ }
+
+ var plugin = _ref;
+
+ var promise = this.run(plugin);
+ if (isPromise(promise)) {
+ throw new Error('Use process(css).then(cb) to work with async plugins');
+ }
+ }
+
+ return this.result;
+ };
+
+ LazyResult.prototype.run = function run(plugin) {
+ this.result.lastPlugin = plugin;
+
+ try {
+ return plugin(this.result.root, this.result);
+ } catch (error) {
+ this.handleError(error, plugin);
+ throw error;
+ }
+ };
+
+ LazyResult.prototype.stringify = function stringify() {
+ if (this.stringified) return this.result;
+ this.stringified = true;
+
+ this.sync();
+
+ var opts = this.result.opts;
+ var str = _stringify3.default;
+ if (opts.syntax) str = opts.syntax.stringify;
+ if (opts.stringifier) str = opts.stringifier;
+ if (str.stringify) str = str.stringify;
+
+ var map = new _mapGenerator2.default(str, this.result.root, this.result.opts);
+ var data = map.generate();
+ this.result.css = data[0];
+ this.result.map = data[1];
+
+ return this.result;
+ };
+
+ _createClass(LazyResult, [{
+ key: 'processor',
+ get: function get() {
+ return this.result.processor;
+ }
+
+ /**
+ * Options from the {@link Processor#process} call.
+ * @type {processOptions}
+ */
+
+ }, {
+ key: 'opts',
+ get: function get() {
+ return this.result.opts;
+ }
+
+ /**
+ * Processes input CSS through synchronous plugins, converts `Root`
+ * to a CSS string and returns {@link Result#css}.
+ *
+ * This property will only work with synchronous plugins.
+ * If the processor contains any asynchronous plugins
+ * it will throw an error. This is why this method is only
+ * for debug purpose, you should always use {@link LazyResult#then}.
+ *
+ * @type {string}
+ * @see Result#css
+ */
+
+ }, {
+ key: 'css',
+ get: function get() {
+ return this.stringify().css;
+ }
+
+ /**
+ * An alias for the `css` property. Use it with syntaxes
+ * that generate non-CSS output.
+ *
+ * This property will only work with synchronous plugins.
+ * If the processor contains any asynchronous plugins
+ * it will throw an error. This is why this method is only
+ * for debug purpose, you should always use {@link LazyResult#then}.
+ *
+ * @type {string}
+ * @see Result#content
+ */
+
+ }, {
+ key: 'content',
+ get: function get() {
+ return this.stringify().content;
+ }
+
+ /**
+ * Processes input CSS through synchronous plugins
+ * and returns {@link Result#map}.
+ *
+ * This property will only work with synchronous plugins.
+ * If the processor contains any asynchronous plugins
+ * it will throw an error. This is why this method is only
+ * for debug purpose, you should always use {@link LazyResult#then}.
+ *
+ * @type {SourceMapGenerator}
+ * @see Result#map
+ */
+
+ }, {
+ key: 'map',
+ get: function get() {
+ return this.stringify().map;
+ }
+
+ /**
+ * Processes input CSS through synchronous plugins
+ * and returns {@link Result#root}.
+ *
+ * This property will only work with synchronous plugins. If the processor
+ * contains any asynchronous plugins it will throw an error.
+ *
+ * This is why this method is only for debug purpose,
+ * you should always use {@link LazyResult#then}.
+ *
+ * @type {Root}
+ * @see Result#root
+ */
+
+ }, {
+ key: 'root',
+ get: function get() {
+ return this.sync().root;
+ }
+
+ /**
+ * Processes input CSS through synchronous plugins
+ * and returns {@link Result#messages}.
+ *
+ * This property will only work with synchronous plugins. If the processor
+ * contains any asynchronous plugins it will throw an error.
+ *
+ * This is why this method is only for debug purpose,
+ * you should always use {@link LazyResult#then}.
+ *
+ * @type {Message[]}
+ * @see Result#messages
+ */
+
+ }, {
+ key: 'messages',
+ get: function get() {
+ return this.sync().messages;
+ }
+ }]);
+
+ return LazyResult;
+}();
+
+exports.default = LazyResult;
+
+/**
+ * @callback onFulfilled
+ * @param {Result} result
+ */
+
+/**
+ * @callback onRejected
+ * @param {Error} error
+ */
+
+module.exports = exports['default'];
+//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImxhenktcmVzdWx0LmVzNiJdLCJuYW1lcyI6WyJpc1Byb21pc2UiLCJvYmoiLCJ0aGVuIiwiTGF6eVJlc3VsdCIsInByb2Nlc3NvciIsImNzcyIsIm9wdHMiLCJzdHJpbmdpZmllZCIsInByb2Nlc3NlZCIsInJvb3QiLCJ0eXBlIiwiUmVzdWx0IiwibWFwIiwiaW5saW5lIiwicHJldiIsInBhcnNlciIsInBhcnNlIiwic3ludGF4IiwiZXJyb3IiLCJyZXN1bHQiLCJ3YXJuaW5ncyIsInN5bmMiLCJ0b1N0cmluZyIsIm9uRnVsZmlsbGVkIiwib25SZWplY3RlZCIsImFzeW5jIiwiY2F0Y2giLCJoYW5kbGVFcnJvciIsInBsdWdpbiIsIm5hbWUiLCJwb3N0Y3NzUGx1Z2luIiwic2V0TWVzc2FnZSIsInBvc3Rjc3NWZXJzaW9uIiwicGx1Z2luTmFtZSIsInBsdWdpblZlciIsInJ1bnRpbWVWZXIiLCJ2ZXJzaW9uIiwiYSIsInNwbGl0IiwiYiIsInBhcnNlSW50IiwiY29uc29sZSIsImVyciIsImFzeW5jVGljayIs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4gICAgICogYW5kIGNhbGxzIG9uUmVqZWN0ZWQgZm9yIGVhY2ggZXJyb3IgdGhyb3duIGluIGFueSBwbHVnaW4uXG4gICAgICpcbiAgICAgKiBJdCBpbXBsZW1lbnRzIHN0YW5kYXJkIFByb21pc2UgQVBJLlxuICAgICAqXG4gICAgICogQHBhcmFtIHtvblJlamVjdGVkfSBvblJlamVjdGVkIC0gY2FsbGJhY2sgd2lsbCBiZSBleGVjdXRlZCBvbiBhbnkgZXJyb3JcbiAgICAgKlxuICAgICAqIEByZXR1cm4ge1Byb21pc2V9IFByb21pc2UgQVBJIHRvIG1ha2UgcXVldWVcbiAgICAgKlxuICAgICAqIEBleGFtcGxlXG4gICAgICogcG9zdGNzcyhbY3NzbmV4dF0pLnByb2Nlc3MoY3NzKS50aGVuKHJlc3VsdCA9PiB7XG4gICAgICogICBjb25zb2xlLmxvZyhyZXN1bHQuY3NzKTtcbiAgICAgKiB9KS5jYXRjaChlcnJvciA9PiB7XG4gICAgICogICBjb25zb2xlLmVycm9yKGVycm9yKTtcbiAgICAgKiB9KTtcbiAgICAgKi9cbiAgICBjYXRjaChvblJlamVjdGVkKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmFzeW5jKCkuY2F0Y2gob25SZWplY3RlZCk7XG4gICAgfVxuXG4gICAgaGFuZGxlRXJyb3IoZXJyb3IsIHBsdWdpbikge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgdGhpcy5lcnJvciA9IGVycm9yO1xuICAgICAgICAgICAgaWYgKCBlcnJvci5uYW1lID09PSAnQ3NzU3ludGF4RXJyb3InICYmICFlcnJvci5wbHVnaW4gKSB7XG4gICAgICAgICAgICAgICAgZXJyb3IucGx1Z2luID0gcGx1Z2luLnBvc3Rjc3NQbHVnaW47XG4gICAgICAgICAgICAgICAgZXJyb3Iuc2V0TWVzc2FnZSgpO1xuICAgICAgICAgICAgfSBlbHNlIGlmICggcGx1Z2luLnBvc3Rjc3NWZXJzaW9uICkge1xuICAgICAgICAgICAgICAgIGxldCBwbHVnaW5OYW1lID0gcGx1Z2luLnBvc3Rjc3NQbHVnaW47XG4gICAgICAgICAgICAgICAgbGV0IHBsdWdpblZlciAgPSBwbHVnaW4ucG9zdGNzc1ZlcnNpb247XG4gICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVWZXIgPSB0aGlzLnJlc3VsdC5wcm9jZXNzb3IudmVyc2lvbjtcbiAgICAgICAgICAgICAgICBsZXQgYSA9IHBsdWdpblZlci5zcGxpdCgnLicpO1xuICAgICAgICAgICAgICAgIGxldCBiID0gcnVudGltZVZlci5zcGxpdCgnLicpO1xuXG4gICAgICAgICAgICAgICAgaWYgKCBhWzBdICE9PSBiWzBdIHx8IHBhcnNlSW50KGFbMV0pID4gcGFyc2VJbnQoYlsxXSkgKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoXG4gICAgICAgICAgICAgICAgICAgICAgICAnVW5rbm93biBlcnJvciBmcm9tIFBvc3RDU1MgcGx1Z2luLiAnICtcbiAgICAgICAgICAgICAgICAgICAgICAgICdZb3VyIGN1cnJlbnQgUG9zdENTUyB2ZXJzaW9uICcgK1xuICAgICAgICAgICAgICAgICAgICAgICAgJ2lzICcgKyBydW50aW1lVmVyICsgJywgYnV0ICcgKyBwbHVnaW5OYW1lICsgJyAnICtcbiAgICAgICAgICAgICAgICAgICAgICAgICd1c2VzICcgKyBwbHVnaW5WZXIgKyAnLiBQZXJoYXBzIHRoaXMgaXMgJyArXG4gICAgICAgICAgICAgICAgICAgICAgICAndGhlIHNvdXJjZSBvZiB0aGUgZXJyb3IgYmVsb3cuJyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9IGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgIGlmICggY29uc29sZSAmJiBjb25zb2xlLmVycm9yICkgY29uc29sZS5lcnJvcihlcnIpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgYXN5bmNUaWNrKHJlc29sdmUsIHJlamVjdCkge1xuICAgICAgICBpZiAoIHRoaXMucGx1Z2luID49IHRoaXMucHJvY2Vzc29yLnBsdWdpbnMubGVuZ3RoICkge1xuICAgICAgICAgICAgdGhpcy5wcm9jZXNzZWQgPSB0cnVlO1xuICAgICAgICAgICAgcmV0dXJuIHJlc29sdmUoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICBsZXQgcGx1Z2luICA9IHRoaXMucHJvY2Vzc29yLnBsdWdpbnNbdGhpcy5wbHVnaW5dO1xuICAgICAgICAgICAgbGV0IHByb21pc2UgPSB0aGlzLnJ1bihwbHVnaW4pO1xuICAgICAgICAgICAgdGhpcy5wbHVnaW4gKz0gMTtcblxuICAgICAgICAgICAgaWYgKCBpc1Byb21pc2UocHJvbWlzZSkgKSB7XG4gICAgICAgICAgICAgICAgcHJvbWlzZS50aGVuKCAoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuYXN5bmNUaWNrKHJlc29sdmUsIHJlamVjdCk7XG4gICAgICAgICAgICAgICAgfSkuY2F0Y2goIGVycm9yID0+IHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5oYW5kbGVFcnJvcihlcnJvciwgcGx1Z2luKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5wcm9jZXNzZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICByZWplY3QoZXJyb3IpO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLmFzeW5jVGljayhyZXNvbHZlLCByZWplY3QpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7XG4gICAgICAgICAgICB0aGlzLnByb2Nlc3NlZCA9IHRydWU7XG4gICAgICAgICAgICByZWplY3QoZXJyb3IpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgYXN5bmMoKSB7XG4gICAgICAgIGlmICggdGhpcy5wcm9jZXNzZWQgKSB7XG4gICAgICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoIChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICAgICAgICAgICAgICBpZiAoIHRoaXMuZXJyb3IgKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlamVjdCh0aGlzLmVycm9yKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICByZXNvbHZlKHRoaXMuc3RyaW5naWZ5KCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIGlmICggdGhpcy5wcm9jZXNzaW5nICkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMucHJvY2Vzc2luZztcbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMucHJvY2Vzc2luZyA9IG5ldyBQcm9taXNlKCAocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XG4gICAgICAgICAgICBpZiAoIHRoaXMuZXJyb3IgKSByZXR1cm4gcmVqZWN0KHRoaXMuZXJyb3IpO1xuICAgICAgICAgICAgdGhpcy5wbHVnaW4gPSAwO1xuICAgICAgICAgICAgdGhpcy5hc3luY1RpY2socmVzb2x2ZSwgcmVqZWN0KTtcbiAgICAgICAgfSkudGhlbiggKCkgPT4ge1xuICAgICAgICAgICAgdGhpcy5wcm9jZXNzZWQgPSB0cnVlO1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuc3RyaW5naWZ5KCk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHJldHVybiB0aGlzLnByb2Nlc3Npbmc7XG4gICAgfVxuXG4gICAgc3luYygpIHtcbiAgICAgICAgaWYgKCB0aGlzLnByb2Nlc3NlZCApIHJldHVybiB0aGlzLnJlc3VsdDtcbiAgICAgICAgdGhpcy5wcm9jZXNzZWQgPSB0cnVlO1xuXG4gICAgICAgIGlmICggdGhpcy5wcm9jZXNzaW5nICkge1xuICAgICAgICAgIC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