{"ast":null,"code":"'use strict';\n\nconst escapeStringRegexp = require('escape-string-regexp');\n\nconst ansiStyles = require('ansi-styles');\n\nconst stdoutColor = require('supports-color').stdout;\n\nconst template = require('./templates.js');\n\nconst isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping\n\nconst levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such\n\nconst skipModels = new Set(['gray']);\nconst styles = Object.create(null);\n\nfunction applyOptions(obj, options) {\n  options = options || {}; // Detect level if not set manually\n\n  const scLevel = stdoutColor ? stdoutColor.level : 0;\n  obj.level = options.level === undefined ? scLevel : options.level;\n  obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;\n}\n\nfunction Chalk(options) {\n  // We check for this.template here since calling `chalk.constructor()`\n  // by itself will have a `this` of a previously constructed chalk object\n  if (!this || !(this instanceof Chalk) || this.template) {\n    const chalk = {};\n    applyOptions(chalk, options);\n\n    chalk.template = function () {\n      const args = [].slice.call(arguments);\n      return chalkTag.apply(null, [chalk.template].concat(args));\n    };\n\n    Object.setPrototypeOf(chalk, Chalk.prototype);\n    Object.setPrototypeOf(chalk.template, chalk);\n    chalk.template.constructor = Chalk;\n    return chalk.template;\n  }\n\n  applyOptions(this, options);\n} // Use bright blue on Windows as the normal blue color is illegible\n\n\nif (isSimpleWindowsTerm) {\n  ansiStyles.blue.open = '\\u001B[94m';\n}\n\nfor (const key of Object.keys(ansiStyles)) {\n  ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');\n  styles[key] = {\n    get() {\n      const codes = ansiStyles[key];\n      return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);\n    }\n\n  };\n}\n\nstyles.visible = {\n  get() {\n    return build.call(this, this._styles || [], true, 'visible');\n  }\n\n};\nansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');\n\nfor (const model of Object.keys(ansiStyles.color.ansi)) {\n  if (skipModels.has(model)) {\n    continue;\n  }\n\n  styles[model] = {\n    get() {\n      const level = this.level;\n      return function () {\n        const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);\n        const codes = {\n          open,\n          close: ansiStyles.color.close,\n          closeRe: ansiStyles.color.closeRe\n        };\n        return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);\n      };\n    }\n\n  };\n}\n\nansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');\n\nfor (const model of Object.keys(ansiStyles.bgColor.ansi)) {\n  if (skipModels.has(model)) {\n    continue;\n  }\n\n  const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);\n  styles[bgModel] = {\n    get() {\n      const level = this.level;\n      return function () {\n        const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);\n        const codes = {\n          open,\n          close: ansiStyles.bgColor.close,\n          closeRe: ansiStyles.bgColor.closeRe\n        };\n        return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);\n      };\n    }\n\n  };\n}\n\nconst proto = Object.defineProperties(() => {}, styles);\n\nfunction build(_styles, _empty, key) {\n  const builder = function () {\n    return applyStyle.apply(builder, arguments);\n  };\n\n  builder._styles = _styles;\n  builder._empty = _empty;\n  const self = this;\n  Object.defineProperty(builder, 'level', {\n    enumerable: true,\n\n    get() {\n      return self.level;\n    },\n\n    set(level) {\n      self.level = level;\n    }\n\n  });\n  Object.defineProperty(builder, 'enabled', {\n    enumerable: true,\n\n    get() {\n      return self.enabled;\n    },\n\n    set(enabled) {\n      self.enabled = enabled;\n    }\n\n  }); // See below for fix regarding invisible grey/dim combination on Windows\n\n  builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is\n  // no way to create a function with a different prototype\n\n  builder.__proto__ = proto; // eslint-disable-line no-proto\n\n  return builder;\n}\n\nfunction applyStyle() {\n  // Support varags, but simply cast to string in case there's only one arg\n  const args = arguments;\n  const argsLen = args.length;\n  let str = String(arguments[0]);\n\n  if (argsLen === 0) {\n    return '';\n  }\n\n  if (argsLen > 1) {\n    // Don't slice `arguments`, it prevents V8 optimizations\n    for (let a = 1; a < argsLen; a++) {\n      str += ' ' + args[a];\n    }\n  }\n\n  if (!this.enabled || this.level <= 0 || !str) {\n    return this._empty ? '' : str;\n  } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,\n  // see https://github.com/chalk/chalk/issues/58\n  // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.\n\n\n  const originalDim = ansiStyles.dim.open;\n\n  if (isSimpleWindowsTerm && this.hasGrey) {\n    ansiStyles.dim.open = '';\n  }\n\n  for (const code of this._styles.slice().reverse()) {\n    // Replace any instances already present with a re-opening code\n    // otherwise only the part of the string until said closing code\n    // will be colored, and the rest will simply be 'plain'.\n    str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen\n    // after next line to fix a bleed issue on macOS\n    // https://github.com/chalk/chalk/pull/92\n\n    str = str.replace(/\\r?\\n/g, \"\".concat(code.close, \"$&\").concat(code.open));\n  } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue\n\n\n  ansiStyles.dim.open = originalDim;\n  return str;\n}\n\nfunction chalkTag(chalk, strings) {\n  if (!Array.isArray(strings)) {\n    // If chalk() was called by itself or with a string,\n    // return the string itself as a string.\n    return [].slice.call(arguments, 1).join(' ');\n  }\n\n  const args = [].slice.call(arguments, 2);\n  const parts = [strings.raw[0]];\n\n  for (let i = 1; i < strings.length; i++) {\n    parts.push(String(args[i - 1]).replace(/[{}\\\\]/g, '\\\\$&'));\n    parts.push(String(strings.raw[i]));\n  }\n\n  return template(chalk, parts.join(''));\n}\n\nObject.defineProperties(Chalk.prototype, styles);\nmodule.exports = Chalk(); // eslint-disable-line new-cap\n\nmodule.exports.supportsColor = stdoutColor;\nmodule.exports.default = module.exports; // For TypeScript","map":null,"metadata":{},"sourceType":"script"}