consola.36c0034f.mjs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. import { createConsola as createConsola$1, LogLevels } from '../core.mjs';
  2. import { B as BasicReporter, p as parseStack } from './consola.06ad8a64.mjs';
  3. import process$1 from 'node:process';
  4. import { colors, box, stripAnsi as stripAnsi$1 } from '../utils.mjs';
  5. const providers = [
  6. ["APPVEYOR"],
  7. ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],
  8. ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],
  9. ["APPCIRCLE", "AC_APPCIRCLE"],
  10. ["BAMBOO", "bamboo_planKey"],
  11. ["BITBUCKET", "BITBUCKET_COMMIT"],
  12. ["BITRISE", "BITRISE_IO"],
  13. ["BUDDY", "BUDDY_WORKSPACE_ID"],
  14. ["BUILDKITE"],
  15. ["CIRCLE", "CIRCLECI"],
  16. ["CIRRUS", "CIRRUS_CI"],
  17. ["CLOUDFLARE_PAGES", "CF_PAGES", { ci: true }],
  18. ["CODEBUILD", "CODEBUILD_BUILD_ARN"],
  19. ["CODEFRESH", "CF_BUILD_ID"],
  20. ["DRONE"],
  21. ["DRONE", "DRONE_BUILD_EVENT"],
  22. ["DSARI"],
  23. ["GITHUB_ACTIONS"],
  24. ["GITLAB", "GITLAB_CI"],
  25. ["GITLAB", "CI_MERGE_REQUEST_ID"],
  26. ["GOCD", "GO_PIPELINE_LABEL"],
  27. ["LAYERCI"],
  28. ["HUDSON", "HUDSON_URL"],
  29. ["JENKINS", "JENKINS_URL"],
  30. ["MAGNUM"],
  31. ["NETLIFY"],
  32. ["NETLIFY", "NETLIFY_LOCAL", { ci: false }],
  33. ["NEVERCODE"],
  34. ["RENDER"],
  35. ["SAIL", "SAILCI"],
  36. ["SEMAPHORE"],
  37. ["SCREWDRIVER"],
  38. ["SHIPPABLE"],
  39. ["SOLANO", "TDDIUM"],
  40. ["STRIDER"],
  41. ["TEAMCITY", "TEAMCITY_VERSION"],
  42. ["TRAVIS"],
  43. ["VERCEL", "NOW_BUILDER"],
  44. ["APPCENTER", "APPCENTER_BUILD_ID"],
  45. ["CODESANDBOX", "CODESANDBOX_SSE", { ci: false }],
  46. ["STACKBLITZ"],
  47. ["STORMKIT"],
  48. ["CLEAVR"]
  49. ];
  50. function detectProvider(env) {
  51. for (const provider of providers) {
  52. const envName = provider[1] || provider[0];
  53. if (env[envName]) {
  54. return {
  55. name: provider[0].toLowerCase(),
  56. ...provider[2]
  57. };
  58. }
  59. }
  60. if (env.SHELL && env.SHELL === "/bin/jsh") {
  61. return {
  62. name: "stackblitz",
  63. ci: false
  64. };
  65. }
  66. return {
  67. name: "",
  68. ci: false
  69. };
  70. }
  71. const processShim = typeof process !== "undefined" ? process : {};
  72. const envShim = processShim.env || {};
  73. const providerInfo = detectProvider(envShim);
  74. const nodeENV = typeof process !== "undefined" && process.env && process.env.NODE_ENV || "";
  75. processShim.platform;
  76. providerInfo.name;
  77. const isCI = toBoolean(envShim.CI) || providerInfo.ci !== false;
  78. const hasTTY = toBoolean(processShim.stdout && processShim.stdout.isTTY);
  79. const isDebug = toBoolean(envShim.DEBUG);
  80. const isTest = nodeENV === "test" || toBoolean(envShim.TEST);
  81. toBoolean(envShim.MINIMAL) || isCI || isTest || !hasTTY;
  82. function toBoolean(val) {
  83. return val ? val !== "false" : false;
  84. }
  85. function ansiRegex({onlyFirst = false} = {}) {
  86. const pattern = [
  87. '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
  88. '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
  89. ].join('|');
  90. return new RegExp(pattern, onlyFirst ? undefined : 'g');
  91. }
  92. const regex = ansiRegex();
  93. function stripAnsi(string) {
  94. if (typeof string !== 'string') {
  95. throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
  96. }
  97. // Even though the regex is global, we don't need to reset the `.lastIndex`
  98. // because unlike `.exec()` and `.test()`, `.replace()` does it automatically
  99. // and doing it manually has a performance penalty.
  100. return string.replace(regex, '');
  101. }
  102. function getDefaultExportFromCjs (x) {
  103. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  104. }
  105. var eastasianwidth = {exports: {}};
  106. (function (module) {
  107. var eaw = {};
  108. {
  109. module.exports = eaw;
  110. }
  111. eaw.eastAsianWidth = function(character) {
  112. var x = character.charCodeAt(0);
  113. var y = (character.length == 2) ? character.charCodeAt(1) : 0;
  114. var codePoint = x;
  115. if ((0xD800 <= x && x <= 0xDBFF) && (0xDC00 <= y && y <= 0xDFFF)) {
  116. x &= 0x3FF;
  117. y &= 0x3FF;
  118. codePoint = (x << 10) | y;
  119. codePoint += 0x10000;
  120. }
  121. if ((0x3000 == codePoint) ||
  122. (0xFF01 <= codePoint && codePoint <= 0xFF60) ||
  123. (0xFFE0 <= codePoint && codePoint <= 0xFFE6)) {
  124. return 'F';
  125. }
  126. if ((0x20A9 == codePoint) ||
  127. (0xFF61 <= codePoint && codePoint <= 0xFFBE) ||
  128. (0xFFC2 <= codePoint && codePoint <= 0xFFC7) ||
  129. (0xFFCA <= codePoint && codePoint <= 0xFFCF) ||
  130. (0xFFD2 <= codePoint && codePoint <= 0xFFD7) ||
  131. (0xFFDA <= codePoint && codePoint <= 0xFFDC) ||
  132. (0xFFE8 <= codePoint && codePoint <= 0xFFEE)) {
  133. return 'H';
  134. }
  135. if ((0x1100 <= codePoint && codePoint <= 0x115F) ||
  136. (0x11A3 <= codePoint && codePoint <= 0x11A7) ||
  137. (0x11FA <= codePoint && codePoint <= 0x11FF) ||
  138. (0x2329 <= codePoint && codePoint <= 0x232A) ||
  139. (0x2E80 <= codePoint && codePoint <= 0x2E99) ||
  140. (0x2E9B <= codePoint && codePoint <= 0x2EF3) ||
  141. (0x2F00 <= codePoint && codePoint <= 0x2FD5) ||
  142. (0x2FF0 <= codePoint && codePoint <= 0x2FFB) ||
  143. (0x3001 <= codePoint && codePoint <= 0x303E) ||
  144. (0x3041 <= codePoint && codePoint <= 0x3096) ||
  145. (0x3099 <= codePoint && codePoint <= 0x30FF) ||
  146. (0x3105 <= codePoint && codePoint <= 0x312D) ||
  147. (0x3131 <= codePoint && codePoint <= 0x318E) ||
  148. (0x3190 <= codePoint && codePoint <= 0x31BA) ||
  149. (0x31C0 <= codePoint && codePoint <= 0x31E3) ||
  150. (0x31F0 <= codePoint && codePoint <= 0x321E) ||
  151. (0x3220 <= codePoint && codePoint <= 0x3247) ||
  152. (0x3250 <= codePoint && codePoint <= 0x32FE) ||
  153. (0x3300 <= codePoint && codePoint <= 0x4DBF) ||
  154. (0x4E00 <= codePoint && codePoint <= 0xA48C) ||
  155. (0xA490 <= codePoint && codePoint <= 0xA4C6) ||
  156. (0xA960 <= codePoint && codePoint <= 0xA97C) ||
  157. (0xAC00 <= codePoint && codePoint <= 0xD7A3) ||
  158. (0xD7B0 <= codePoint && codePoint <= 0xD7C6) ||
  159. (0xD7CB <= codePoint && codePoint <= 0xD7FB) ||
  160. (0xF900 <= codePoint && codePoint <= 0xFAFF) ||
  161. (0xFE10 <= codePoint && codePoint <= 0xFE19) ||
  162. (0xFE30 <= codePoint && codePoint <= 0xFE52) ||
  163. (0xFE54 <= codePoint && codePoint <= 0xFE66) ||
  164. (0xFE68 <= codePoint && codePoint <= 0xFE6B) ||
  165. (0x1B000 <= codePoint && codePoint <= 0x1B001) ||
  166. (0x1F200 <= codePoint && codePoint <= 0x1F202) ||
  167. (0x1F210 <= codePoint && codePoint <= 0x1F23A) ||
  168. (0x1F240 <= codePoint && codePoint <= 0x1F248) ||
  169. (0x1F250 <= codePoint && codePoint <= 0x1F251) ||
  170. (0x20000 <= codePoint && codePoint <= 0x2F73F) ||
  171. (0x2B740 <= codePoint && codePoint <= 0x2FFFD) ||
  172. (0x30000 <= codePoint && codePoint <= 0x3FFFD)) {
  173. return 'W';
  174. }
  175. if ((0x0020 <= codePoint && codePoint <= 0x007E) ||
  176. (0x00A2 <= codePoint && codePoint <= 0x00A3) ||
  177. (0x00A5 <= codePoint && codePoint <= 0x00A6) ||
  178. (0x00AC == codePoint) ||
  179. (0x00AF == codePoint) ||
  180. (0x27E6 <= codePoint && codePoint <= 0x27ED) ||
  181. (0x2985 <= codePoint && codePoint <= 0x2986)) {
  182. return 'Na';
  183. }
  184. if ((0x00A1 == codePoint) ||
  185. (0x00A4 == codePoint) ||
  186. (0x00A7 <= codePoint && codePoint <= 0x00A8) ||
  187. (0x00AA == codePoint) ||
  188. (0x00AD <= codePoint && codePoint <= 0x00AE) ||
  189. (0x00B0 <= codePoint && codePoint <= 0x00B4) ||
  190. (0x00B6 <= codePoint && codePoint <= 0x00BA) ||
  191. (0x00BC <= codePoint && codePoint <= 0x00BF) ||
  192. (0x00C6 == codePoint) ||
  193. (0x00D0 == codePoint) ||
  194. (0x00D7 <= codePoint && codePoint <= 0x00D8) ||
  195. (0x00DE <= codePoint && codePoint <= 0x00E1) ||
  196. (0x00E6 == codePoint) ||
  197. (0x00E8 <= codePoint && codePoint <= 0x00EA) ||
  198. (0x00EC <= codePoint && codePoint <= 0x00ED) ||
  199. (0x00F0 == codePoint) ||
  200. (0x00F2 <= codePoint && codePoint <= 0x00F3) ||
  201. (0x00F7 <= codePoint && codePoint <= 0x00FA) ||
  202. (0x00FC == codePoint) ||
  203. (0x00FE == codePoint) ||
  204. (0x0101 == codePoint) ||
  205. (0x0111 == codePoint) ||
  206. (0x0113 == codePoint) ||
  207. (0x011B == codePoint) ||
  208. (0x0126 <= codePoint && codePoint <= 0x0127) ||
  209. (0x012B == codePoint) ||
  210. (0x0131 <= codePoint && codePoint <= 0x0133) ||
  211. (0x0138 == codePoint) ||
  212. (0x013F <= codePoint && codePoint <= 0x0142) ||
  213. (0x0144 == codePoint) ||
  214. (0x0148 <= codePoint && codePoint <= 0x014B) ||
  215. (0x014D == codePoint) ||
  216. (0x0152 <= codePoint && codePoint <= 0x0153) ||
  217. (0x0166 <= codePoint && codePoint <= 0x0167) ||
  218. (0x016B == codePoint) ||
  219. (0x01CE == codePoint) ||
  220. (0x01D0 == codePoint) ||
  221. (0x01D2 == codePoint) ||
  222. (0x01D4 == codePoint) ||
  223. (0x01D6 == codePoint) ||
  224. (0x01D8 == codePoint) ||
  225. (0x01DA == codePoint) ||
  226. (0x01DC == codePoint) ||
  227. (0x0251 == codePoint) ||
  228. (0x0261 == codePoint) ||
  229. (0x02C4 == codePoint) ||
  230. (0x02C7 == codePoint) ||
  231. (0x02C9 <= codePoint && codePoint <= 0x02CB) ||
  232. (0x02CD == codePoint) ||
  233. (0x02D0 == codePoint) ||
  234. (0x02D8 <= codePoint && codePoint <= 0x02DB) ||
  235. (0x02DD == codePoint) ||
  236. (0x02DF == codePoint) ||
  237. (0x0300 <= codePoint && codePoint <= 0x036F) ||
  238. (0x0391 <= codePoint && codePoint <= 0x03A1) ||
  239. (0x03A3 <= codePoint && codePoint <= 0x03A9) ||
  240. (0x03B1 <= codePoint && codePoint <= 0x03C1) ||
  241. (0x03C3 <= codePoint && codePoint <= 0x03C9) ||
  242. (0x0401 == codePoint) ||
  243. (0x0410 <= codePoint && codePoint <= 0x044F) ||
  244. (0x0451 == codePoint) ||
  245. (0x2010 == codePoint) ||
  246. (0x2013 <= codePoint && codePoint <= 0x2016) ||
  247. (0x2018 <= codePoint && codePoint <= 0x2019) ||
  248. (0x201C <= codePoint && codePoint <= 0x201D) ||
  249. (0x2020 <= codePoint && codePoint <= 0x2022) ||
  250. (0x2024 <= codePoint && codePoint <= 0x2027) ||
  251. (0x2030 == codePoint) ||
  252. (0x2032 <= codePoint && codePoint <= 0x2033) ||
  253. (0x2035 == codePoint) ||
  254. (0x203B == codePoint) ||
  255. (0x203E == codePoint) ||
  256. (0x2074 == codePoint) ||
  257. (0x207F == codePoint) ||
  258. (0x2081 <= codePoint && codePoint <= 0x2084) ||
  259. (0x20AC == codePoint) ||
  260. (0x2103 == codePoint) ||
  261. (0x2105 == codePoint) ||
  262. (0x2109 == codePoint) ||
  263. (0x2113 == codePoint) ||
  264. (0x2116 == codePoint) ||
  265. (0x2121 <= codePoint && codePoint <= 0x2122) ||
  266. (0x2126 == codePoint) ||
  267. (0x212B == codePoint) ||
  268. (0x2153 <= codePoint && codePoint <= 0x2154) ||
  269. (0x215B <= codePoint && codePoint <= 0x215E) ||
  270. (0x2160 <= codePoint && codePoint <= 0x216B) ||
  271. (0x2170 <= codePoint && codePoint <= 0x2179) ||
  272. (0x2189 == codePoint) ||
  273. (0x2190 <= codePoint && codePoint <= 0x2199) ||
  274. (0x21B8 <= codePoint && codePoint <= 0x21B9) ||
  275. (0x21D2 == codePoint) ||
  276. (0x21D4 == codePoint) ||
  277. (0x21E7 == codePoint) ||
  278. (0x2200 == codePoint) ||
  279. (0x2202 <= codePoint && codePoint <= 0x2203) ||
  280. (0x2207 <= codePoint && codePoint <= 0x2208) ||
  281. (0x220B == codePoint) ||
  282. (0x220F == codePoint) ||
  283. (0x2211 == codePoint) ||
  284. (0x2215 == codePoint) ||
  285. (0x221A == codePoint) ||
  286. (0x221D <= codePoint && codePoint <= 0x2220) ||
  287. (0x2223 == codePoint) ||
  288. (0x2225 == codePoint) ||
  289. (0x2227 <= codePoint && codePoint <= 0x222C) ||
  290. (0x222E == codePoint) ||
  291. (0x2234 <= codePoint && codePoint <= 0x2237) ||
  292. (0x223C <= codePoint && codePoint <= 0x223D) ||
  293. (0x2248 == codePoint) ||
  294. (0x224C == codePoint) ||
  295. (0x2252 == codePoint) ||
  296. (0x2260 <= codePoint && codePoint <= 0x2261) ||
  297. (0x2264 <= codePoint && codePoint <= 0x2267) ||
  298. (0x226A <= codePoint && codePoint <= 0x226B) ||
  299. (0x226E <= codePoint && codePoint <= 0x226F) ||
  300. (0x2282 <= codePoint && codePoint <= 0x2283) ||
  301. (0x2286 <= codePoint && codePoint <= 0x2287) ||
  302. (0x2295 == codePoint) ||
  303. (0x2299 == codePoint) ||
  304. (0x22A5 == codePoint) ||
  305. (0x22BF == codePoint) ||
  306. (0x2312 == codePoint) ||
  307. (0x2460 <= codePoint && codePoint <= 0x24E9) ||
  308. (0x24EB <= codePoint && codePoint <= 0x254B) ||
  309. (0x2550 <= codePoint && codePoint <= 0x2573) ||
  310. (0x2580 <= codePoint && codePoint <= 0x258F) ||
  311. (0x2592 <= codePoint && codePoint <= 0x2595) ||
  312. (0x25A0 <= codePoint && codePoint <= 0x25A1) ||
  313. (0x25A3 <= codePoint && codePoint <= 0x25A9) ||
  314. (0x25B2 <= codePoint && codePoint <= 0x25B3) ||
  315. (0x25B6 <= codePoint && codePoint <= 0x25B7) ||
  316. (0x25BC <= codePoint && codePoint <= 0x25BD) ||
  317. (0x25C0 <= codePoint && codePoint <= 0x25C1) ||
  318. (0x25C6 <= codePoint && codePoint <= 0x25C8) ||
  319. (0x25CB == codePoint) ||
  320. (0x25CE <= codePoint && codePoint <= 0x25D1) ||
  321. (0x25E2 <= codePoint && codePoint <= 0x25E5) ||
  322. (0x25EF == codePoint) ||
  323. (0x2605 <= codePoint && codePoint <= 0x2606) ||
  324. (0x2609 == codePoint) ||
  325. (0x260E <= codePoint && codePoint <= 0x260F) ||
  326. (0x2614 <= codePoint && codePoint <= 0x2615) ||
  327. (0x261C == codePoint) ||
  328. (0x261E == codePoint) ||
  329. (0x2640 == codePoint) ||
  330. (0x2642 == codePoint) ||
  331. (0x2660 <= codePoint && codePoint <= 0x2661) ||
  332. (0x2663 <= codePoint && codePoint <= 0x2665) ||
  333. (0x2667 <= codePoint && codePoint <= 0x266A) ||
  334. (0x266C <= codePoint && codePoint <= 0x266D) ||
  335. (0x266F == codePoint) ||
  336. (0x269E <= codePoint && codePoint <= 0x269F) ||
  337. (0x26BE <= codePoint && codePoint <= 0x26BF) ||
  338. (0x26C4 <= codePoint && codePoint <= 0x26CD) ||
  339. (0x26CF <= codePoint && codePoint <= 0x26E1) ||
  340. (0x26E3 == codePoint) ||
  341. (0x26E8 <= codePoint && codePoint <= 0x26FF) ||
  342. (0x273D == codePoint) ||
  343. (0x2757 == codePoint) ||
  344. (0x2776 <= codePoint && codePoint <= 0x277F) ||
  345. (0x2B55 <= codePoint && codePoint <= 0x2B59) ||
  346. (0x3248 <= codePoint && codePoint <= 0x324F) ||
  347. (0xE000 <= codePoint && codePoint <= 0xF8FF) ||
  348. (0xFE00 <= codePoint && codePoint <= 0xFE0F) ||
  349. (0xFFFD == codePoint) ||
  350. (0x1F100 <= codePoint && codePoint <= 0x1F10A) ||
  351. (0x1F110 <= codePoint && codePoint <= 0x1F12D) ||
  352. (0x1F130 <= codePoint && codePoint <= 0x1F169) ||
  353. (0x1F170 <= codePoint && codePoint <= 0x1F19A) ||
  354. (0xE0100 <= codePoint && codePoint <= 0xE01EF) ||
  355. (0xF0000 <= codePoint && codePoint <= 0xFFFFD) ||
  356. (0x100000 <= codePoint && codePoint <= 0x10FFFD)) {
  357. return 'A';
  358. }
  359. return 'N';
  360. };
  361. eaw.characterLength = function(character) {
  362. var code = this.eastAsianWidth(character);
  363. if (code == 'F' || code == 'W' || code == 'A') {
  364. return 2;
  365. } else {
  366. return 1;
  367. }
  368. };
  369. // Split a string considering surrogate-pairs.
  370. function stringToArray(string) {
  371. return string.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
  372. }
  373. eaw.length = function(string) {
  374. var characters = stringToArray(string);
  375. var len = 0;
  376. for (var i = 0; i < characters.length; i++) {
  377. len = len + this.characterLength(characters[i]);
  378. }
  379. return len;
  380. };
  381. eaw.slice = function(text, start, end) {
  382. textLen = eaw.length(text);
  383. start = start ? start : 0;
  384. end = end ? end : 1;
  385. if (start < 0) {
  386. start = textLen + start;
  387. }
  388. if (end < 0) {
  389. end = textLen + end;
  390. }
  391. var result = '';
  392. var eawLen = 0;
  393. var chars = stringToArray(text);
  394. for (var i = 0; i < chars.length; i++) {
  395. var char = chars[i];
  396. var charLen = eaw.length(char);
  397. if (eawLen >= start - (charLen == 2 ? 1 : 0)) {
  398. if (eawLen + charLen <= end) {
  399. result += char;
  400. } else {
  401. break;
  402. }
  403. }
  404. eawLen += charLen;
  405. }
  406. return result;
  407. };
  408. } (eastasianwidth));
  409. var eastasianwidthExports = eastasianwidth.exports;
  410. const eastAsianWidth = /*@__PURE__*/getDefaultExportFromCjs(eastasianwidthExports);
  411. const emojiRegex = () => {
  412. // https://mths.be/emoji
  413. return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC3\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC08\uDC26](?:\u200D\u2B1B)?|[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC2\uDECE-\uDEDB\uDEE0-\uDEE8]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
  414. };
  415. function stringWidth$1(string, options) {
  416. if (typeof string !== 'string' || string.length === 0) {
  417. return 0;
  418. }
  419. options = {
  420. ambiguousIsNarrow: true,
  421. countAnsiEscapeCodes: false,
  422. ...options,
  423. };
  424. if (!options.countAnsiEscapeCodes) {
  425. string = stripAnsi(string);
  426. }
  427. if (string.length === 0) {
  428. return 0;
  429. }
  430. const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2;
  431. let width = 0;
  432. for (const {segment: character} of new Intl.Segmenter().segment(string)) {
  433. const codePoint = character.codePointAt(0);
  434. // Ignore control characters
  435. if (codePoint <= 0x1F || (codePoint >= 0x7F && codePoint <= 0x9F)) {
  436. continue;
  437. }
  438. // Ignore combining characters
  439. if (codePoint >= 0x3_00 && codePoint <= 0x3_6F) {
  440. continue;
  441. }
  442. if (emojiRegex().test(character)) {
  443. width += 2;
  444. continue;
  445. }
  446. const code = eastAsianWidth.eastAsianWidth(character);
  447. switch (code) {
  448. case 'F':
  449. case 'W': {
  450. width += 2;
  451. break;
  452. }
  453. case 'A': {
  454. width += ambiguousCharacterWidth;
  455. break;
  456. }
  457. default: {
  458. width += 1;
  459. }
  460. }
  461. }
  462. return width;
  463. }
  464. function isUnicodeSupported() {
  465. if (process$1.platform !== 'win32') {
  466. return process$1.env.TERM !== 'linux'; // Linux console (kernel)
  467. }
  468. return Boolean(process$1.env.CI)
  469. || Boolean(process$1.env.WT_SESSION) // Windows Terminal
  470. || Boolean(process$1.env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
  471. || process$1.env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
  472. || process$1.env.TERM_PROGRAM === 'Terminus-Sublime'
  473. || process$1.env.TERM_PROGRAM === 'vscode'
  474. || process$1.env.TERM === 'xterm-256color'
  475. || process$1.env.TERM === 'alacritty'
  476. || process$1.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
  477. }
  478. const TYPE_COLOR_MAP = {
  479. info: "cyan",
  480. fail: "red",
  481. success: "green",
  482. ready: "green",
  483. start: "magenta"
  484. };
  485. const LEVEL_COLOR_MAP = {
  486. 0: "red",
  487. 1: "yellow"
  488. };
  489. const unicode = isUnicodeSupported();
  490. const s = (c, fallback) => unicode ? c : fallback;
  491. const TYPE_ICONS = {
  492. error: s("\u2716", "\xD7"),
  493. fatal: s("\u2716", "\xD7"),
  494. ready: s("\u2714", "\u221A"),
  495. warn: s("\u26A0", "\u203C"),
  496. info: s("\u2139", "i"),
  497. success: s("\u2714", "\u221A"),
  498. debug: s("\u2699", "D"),
  499. trace: s("\u2192", "\u2192"),
  500. fail: s("\u2716", "\xD7"),
  501. start: s("\u25D0", "o"),
  502. log: ""
  503. };
  504. function stringWidth(str) {
  505. if (!Intl.Segmenter) {
  506. return stripAnsi$1(str).length;
  507. }
  508. return stringWidth$1(str);
  509. }
  510. class FancyReporter extends BasicReporter {
  511. formatStack(stack) {
  512. return "\n" + parseStack(stack).map(
  513. (line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)
  514. ).join("\n");
  515. }
  516. formatType(logObj, isBadge, opts) {
  517. const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
  518. if (isBadge) {
  519. return getBgColor(typeColor)(
  520. colors.black(` ${logObj.type.toUpperCase()} `)
  521. );
  522. }
  523. const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
  524. return _type ? getColor(typeColor)(_type) : "";
  525. }
  526. formatLogObj(logObj, opts) {
  527. const [message, ...additional] = this.formatArgs(logObj.args, opts).split(
  528. "\n"
  529. );
  530. if (logObj.type === "box") {
  531. return box(
  532. characterFormat(
  533. message + (additional.length > 0 ? "\n" + additional.join("\n") : "")
  534. ),
  535. {
  536. title: logObj.title ? characterFormat(logObj.title) : void 0,
  537. style: logObj.style
  538. }
  539. );
  540. }
  541. const date = this.formatDate(logObj.date, opts);
  542. const coloredDate = date && colors.gray(date);
  543. const isBadge = logObj.badge ?? logObj.level < 2;
  544. const type = this.formatType(logObj, isBadge, opts);
  545. const tag = logObj.tag ? colors.gray(logObj.tag) : "";
  546. let line;
  547. const left = this.filterAndJoin([type, characterFormat(message)]);
  548. const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
  549. const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
  550. line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
  551. line += characterFormat(
  552. additional.length > 0 ? "\n" + additional.join("\n") : ""
  553. );
  554. if (logObj.type === "trace") {
  555. const _err = new Error("Trace: " + logObj.message);
  556. line += this.formatStack(_err.stack || "");
  557. }
  558. return isBadge ? "\n" + line + "\n" : line;
  559. }
  560. }
  561. function characterFormat(str) {
  562. return str.replace(/`([^`]+)`/gm, (_, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_, m) => ` ${colors.underline(m)} `);
  563. }
  564. function getColor(color = "white") {
  565. return colors[color] || colors.white;
  566. }
  567. function getBgColor(color = "bgWhite") {
  568. return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
  569. }
  570. function createConsola(options = {}) {
  571. let level = _getDefaultLogLevel();
  572. if (process.env.CONSOLA_LEVEL) {
  573. level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
  574. }
  575. const consola2 = createConsola$1({
  576. level,
  577. defaults: { level },
  578. stdout: process.stdout,
  579. stderr: process.stderr,
  580. prompt: (...args) => import('../chunks/prompt.mjs').then((m) => m.prompt(...args)),
  581. reporters: options.reporters || [
  582. options.fancy ?? !(isCI || isTest) ? new FancyReporter() : new BasicReporter()
  583. ],
  584. ...options
  585. });
  586. return consola2;
  587. }
  588. function _getDefaultLogLevel() {
  589. if (isDebug) {
  590. return LogLevels.debug;
  591. }
  592. if (isTest) {
  593. return LogLevels.warn;
  594. }
  595. return LogLevels.info;
  596. }
  597. const consola = createConsola();
  598. export { consola as a, createConsola as c, getDefaultExportFromCjs as g, isUnicodeSupported as i };