1 (function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3 typeof define === 'function' && define.amd ? define(factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.doc = factory());
5 })(this, (function () { 'use strict';
7 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
10 * @param {Doc[]} parts
15 function concat$1(parts) {
16 // access the internals of a document directly.
17 // if(parts.length === 1) {
18 // // If it's a single document, no need to concat it.
29 * @param {Doc} contents
34 function indent$1(contents) {
42 * @param {number | string} widthOrString
43 * @param {Doc} contents
48 function align(widthOrString, contents) {
57 * @param {Doc} contents
58 * @param {object} [opts] - TBD ???
63 function group(contents) {
64 let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
70 break: Boolean(opts.shouldBreak),
71 expandedStates: opts.expandedStates
75 * @param {Doc} contents
80 function dedentToRoot(contents) {
81 return align(Number.NEGATIVE_INFINITY, contents);
84 * @param {Doc} contents
89 function markAsRoot(contents) {
90 // @ts-expect-error - TBD ???:
96 * @param {Doc} contents
101 function dedent(contents) {
102 return align(-1, contents);
105 * @param {Doc[]} states
106 * @param {object} [opts] - TBD ???
111 function conditionalGroup(states, opts) {
112 return group(states[0], Object.assign(Object.assign({}, opts), {}, {
113 expandedStates: states
117 * @param {Doc[]} parts
122 function fill$1(parts) {
130 * @param {Doc} [breakContents]
131 * @param {Doc} [flatContents]
132 * @param {object} [opts] - TBD ???
137 function ifBreak(breakContents, flatContents) {
138 let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
144 groupId: opts.groupId
148 * Optimized version of `ifBreak(indent(doc), doc, { groupId: ... })`
149 * @param {Doc} contents
150 * @param {{ groupId: symbol, negate?: boolean }} opts
155 function indentIfBreak(contents, opts) {
157 type: "indent-if-break",
159 groupId: opts.groupId,
164 * @param {Doc} contents
169 function lineSuffix(contents) {
177 const lineSuffixBoundary = {
178 type: "line-suffix-boundary"
180 const breakParent = {
186 const hardlineWithoutBreakParent = {
190 const literallineWithoutBreakParent = {
201 }; // eslint-disable-next-line prettier-internal-rules/no-doc-builder-concat
203 const hardline = concat$1([hardlineWithoutBreakParent, breakParent]); // eslint-disable-next-line prettier-internal-rules/no-doc-builder-concat
205 const literalline$1 = concat$1([literallineWithoutBreakParent, breakParent]);
208 placeholder: Symbol("cursor")
216 function join$1(sep, arr) {
219 for (let i = 0; i < arr.length; i++) {
225 } // eslint-disable-next-line prettier-internal-rules/no-doc-builder-concat
228 return concat$1(res);
232 * @param {number} size
233 * @param {number} tabWidth
237 function addAlignmentToDoc(doc, size, tabWidth) {
241 // Use indent to add tabs for all the levels of tabs we need
242 for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
243 aligned = indent$1(aligned);
244 } // Use align for all the spaces that are needed
247 aligned = align(size % tabWidth, aligned); // size is absolute from 0 and not relative to the current
248 // indentation, so we use -Infinity to reset the indentation to 0
250 aligned = align(Number.NEGATIVE_INFINITY, aligned);
256 function label(label, contents) {
270 literalline: literalline$1,
287 hardlineWithoutBreakParent,
288 literallineWithoutBreakParent,
292 var stringWidth$2 = {exports: {}};
294 var ansiRegex$1 = function () {
297 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
298 const pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
299 return new RegExp(pattern, onlyFirst ? undefined : 'g');
302 const ansiRegex = ansiRegex$1;
304 var stripAnsi$1 = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string;
306 var isFullwidthCodePoint$2 = {exports: {}};
308 /* eslint-disable yoda */
310 const isFullwidthCodePoint$1 = codePoint => {
311 if (Number.isNaN(codePoint)) {
313 } // Code points are derived from:
314 // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
317 if (codePoint >= 0x1100 && (codePoint <= 0x115F || // Hangul Jamo
318 codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET
319 codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET
320 // CJK Radicals Supplement .. Enclosed CJK Letters and Months
321 0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
322 0x3250 <= codePoint && codePoint <= 0x4DBF || // CJK Unified Ideographs .. Yi Radicals
323 0x4E00 <= codePoint && codePoint <= 0xA4C6 || // Hangul Jamo Extended-A
324 0xA960 <= codePoint && codePoint <= 0xA97C || // Hangul Syllables
325 0xAC00 <= codePoint && codePoint <= 0xD7A3 || // CJK Compatibility Ideographs
326 0xF900 <= codePoint && codePoint <= 0xFAFF || // Vertical Forms
327 0xFE10 <= codePoint && codePoint <= 0xFE19 || // CJK Compatibility Forms .. Small Form Variants
328 0xFE30 <= codePoint && codePoint <= 0xFE6B || // Halfwidth and Fullwidth Forms
329 0xFF01 <= codePoint && codePoint <= 0xFF60 || 0xFFE0 <= codePoint && codePoint <= 0xFFE6 || // Kana Supplement
330 0x1B000 <= codePoint && codePoint <= 0x1B001 || // Enclosed Ideographic Supplement
331 0x1F200 <= codePoint && codePoint <= 0x1F251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
332 0x20000 <= codePoint && codePoint <= 0x3FFFD)) {
339 isFullwidthCodePoint$2.exports = isFullwidthCodePoint$1;
341 isFullwidthCodePoint$2.exports.default = isFullwidthCodePoint$1;
343 var emojiRegex$1 = function () {
344 // https://mths.be/emoji
345 return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
348 const stripAnsi = stripAnsi$1;
349 const isFullwidthCodePoint = isFullwidthCodePoint$2.exports;
350 const emojiRegex = emojiRegex$1;
352 const stringWidth$1 = string => {
353 if (typeof string !== 'string' || string.length === 0) {
357 string = stripAnsi(string);
359 if (string.length === 0) {
363 string = string.replace(emojiRegex(), ' ');
366 for (let i = 0; i < string.length; i++) {
367 const code = string.codePointAt(i); // Ignore control characters
369 if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
371 } // Ignore combining characters
374 if (code >= 0x300 && code <= 0x36F) {
383 width += isFullwidthCodePoint(code) ? 2 : 1;
389 stringWidth$2.exports = stringWidth$1; // TODO: remove this in the next major version
391 stringWidth$2.exports.default = stringWidth$1;
393 var escapeStringRegexp$1 = string => {
394 if (typeof string !== 'string') {
395 throw new TypeError('Expected a string');
396 } // Escape characters with special meaning either inside or outside character sets.
397 // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
400 return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
403 const getLast$3 = arr => arr[arr.length - 1];
405 var getLast_1 = getLast$3;
407 function _objectWithoutPropertiesLoose(source, excluded) {
408 if (source == null) return {};
410 var sourceKeys = Object.keys(source);
413 for (i = 0; i < sourceKeys.length; i++) {
415 if (excluded.indexOf(key) >= 0) continue;
416 target[key] = source[key];
422 function _objectWithoutProperties(source, excluded) {
423 if (source == null) return {};
425 var target = _objectWithoutPropertiesLoose(source, excluded);
429 if (Object.getOwnPropertySymbols) {
430 var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
432 for (i = 0; i < sourceSymbolKeys.length; i++) {
433 key = sourceSymbolKeys[i];
434 if (excluded.indexOf(key) >= 0) continue;
435 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
436 target[key] = source[key];
443 function _taggedTemplateLiteral(strings, raw) {
445 raw = strings.slice(0);
448 return Object.freeze(Object.defineProperties(strings, {
450 value: Object.freeze(raw)
455 var check = function (it) {
456 return it && it.Math == Math && it;
459 // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
461 // eslint-disable-next-line es/no-global-this -- safe
462 check(typeof globalThis == 'object' && globalThis) ||
463 check(typeof window == 'object' && window) ||
464 // eslint-disable-next-line no-restricted-globals -- safe
465 check(typeof self == 'object' && self) ||
466 check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
467 // eslint-disable-next-line no-new-func -- fallback
468 (function () { return this; })() || Function('return this')();
470 var objectGetOwnPropertyDescriptor = {};
472 var fails$8 = function (exec) {
480 var fails$7 = fails$8;
482 // Detect IE8's incomplete defineProperty implementation
483 var descriptors = !fails$7(function () {
484 // eslint-disable-next-line es/no-object-defineproperty -- required for testing
485 return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
488 var call$7 = Function.prototype.call;
490 var functionCall = call$7.bind ? call$7.bind(call$7) : function () {
491 return call$7.apply(call$7, arguments);
494 var objectPropertyIsEnumerable = {};
496 var $propertyIsEnumerable = {}.propertyIsEnumerable;
497 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
498 var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
500 // Nashorn ~ JDK8 bug
501 var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
503 // `Object.prototype.propertyIsEnumerable` method implementation
504 // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
505 objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
506 var descriptor = getOwnPropertyDescriptor$1(this, V);
507 return !!descriptor && descriptor.enumerable;
508 } : $propertyIsEnumerable;
510 var createPropertyDescriptor$3 = function (bitmap, value) {
512 enumerable: !(bitmap & 1),
513 configurable: !(bitmap & 2),
514 writable: !(bitmap & 4),
519 var FunctionPrototype$1 = Function.prototype;
520 var bind$3 = FunctionPrototype$1.bind;
521 var call$6 = FunctionPrototype$1.call;
522 var callBind = bind$3 && bind$3.bind(call$6);
524 var functionUncurryThis = bind$3 ? function (fn) {
525 return fn && callBind(call$6, fn);
527 return fn && function () {
528 return call$6.apply(fn, arguments);
532 var uncurryThis$c = functionUncurryThis;
534 var toString$3 = uncurryThis$c({}.toString);
535 var stringSlice = uncurryThis$c(''.slice);
537 var classofRaw$1 = function (it) {
538 return stringSlice(toString$3(it), 8, -1);
541 var global$r = global$s;
542 var uncurryThis$b = functionUncurryThis;
543 var fails$6 = fails$8;
544 var classof$5 = classofRaw$1;
546 var Object$4 = global$r.Object;
547 var split = uncurryThis$b(''.split);
549 // fallback for non-array-like ES3 and non-enumerable old V8 strings
550 var indexedObject = fails$6(function () {
551 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
552 // eslint-disable-next-line no-prototype-builtins -- safe
553 return !Object$4('z').propertyIsEnumerable(0);
555 return classof$5(it) == 'String' ? split(it, '') : Object$4(it);
558 var global$q = global$s;
560 var TypeError$a = global$q.TypeError;
562 // `RequireObjectCoercible` abstract operation
563 // https://tc39.es/ecma262/#sec-requireobjectcoercible
564 var requireObjectCoercible$2 = function (it) {
565 if (it == undefined) throw TypeError$a("Can't call method on " + it);
569 // toObject with fallback for non-array-like ES3 strings
570 var IndexedObject = indexedObject;
571 var requireObjectCoercible$1 = requireObjectCoercible$2;
573 var toIndexedObject$3 = function (it) {
574 return IndexedObject(requireObjectCoercible$1(it));
577 // `IsCallable` abstract operation
578 // https://tc39.es/ecma262/#sec-iscallable
579 var isCallable$b = function (argument) {
580 return typeof argument == 'function';
583 var isCallable$a = isCallable$b;
585 var isObject$6 = function (it) {
586 return typeof it == 'object' ? it !== null : isCallable$a(it);
589 var global$p = global$s;
590 var isCallable$9 = isCallable$b;
592 var aFunction = function (argument) {
593 return isCallable$9(argument) ? argument : undefined;
596 var getBuiltIn$4 = function (namespace, method) {
597 return arguments.length < 2 ? aFunction(global$p[namespace]) : global$p[namespace] && global$p[namespace][method];
600 var uncurryThis$a = functionUncurryThis;
602 var objectIsPrototypeOf = uncurryThis$a({}.isPrototypeOf);
604 var getBuiltIn$3 = getBuiltIn$4;
606 var engineUserAgent = getBuiltIn$3('navigator', 'userAgent') || '';
608 var global$o = global$s;
609 var userAgent$2 = engineUserAgent;
611 var process$1 = global$o.process;
612 var Deno = global$o.Deno;
613 var versions$1 = process$1 && process$1.versions || Deno && Deno.version;
614 var v8 = versions$1 && versions$1.v8;
615 var match, version$1;
618 match = v8.split('.');
619 // in old Chrome, versions of V8 isn't V8 = Chrome / 10
620 // but their correct versions are not interesting for us
621 version$1 = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
624 // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
625 // so check `userAgent` even if `.v8` exists, but 0
626 if (!version$1 && userAgent$2) {
627 match = userAgent$2.match(/Edge\/(\d+)/);
628 if (!match || match[1] >= 74) {
629 match = userAgent$2.match(/Chrome\/(\d+)/);
630 if (match) version$1 = +match[1];
634 var engineV8Version = version$1;
636 /* eslint-disable es/no-symbol -- required for testing */
638 var V8_VERSION = engineV8Version;
639 var fails$5 = fails$8;
641 // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
642 var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$5(function () {
643 var symbol = Symbol();
644 // Chrome 38 Symbol has incorrect toString conversion
645 // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
646 return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
647 // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
648 !Symbol.sham && V8_VERSION && V8_VERSION < 41;
651 /* eslint-disable es/no-symbol -- required for testing */
653 var NATIVE_SYMBOL$1 = nativeSymbol;
655 var useSymbolAsUid = NATIVE_SYMBOL$1
657 && typeof Symbol.iterator == 'symbol';
659 var global$n = global$s;
660 var getBuiltIn$2 = getBuiltIn$4;
661 var isCallable$8 = isCallable$b;
662 var isPrototypeOf$1 = objectIsPrototypeOf;
663 var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
665 var Object$3 = global$n.Object;
667 var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
668 return typeof it == 'symbol';
670 var $Symbol = getBuiltIn$2('Symbol');
671 return isCallable$8($Symbol) && isPrototypeOf$1($Symbol.prototype, Object$3(it));
674 var global$m = global$s;
676 var String$3 = global$m.String;
678 var tryToString$3 = function (argument) {
680 return String$3(argument);
686 var global$l = global$s;
687 var isCallable$7 = isCallable$b;
688 var tryToString$2 = tryToString$3;
690 var TypeError$9 = global$l.TypeError;
692 // `Assert: IsCallable(argument) is true`
693 var aCallable$5 = function (argument) {
694 if (isCallable$7(argument)) return argument;
695 throw TypeError$9(tryToString$2(argument) + ' is not a function');
698 var aCallable$4 = aCallable$5;
700 // `GetMethod` abstract operation
701 // https://tc39.es/ecma262/#sec-getmethod
702 var getMethod$3 = function (V, P) {
704 return func == null ? undefined : aCallable$4(func);
707 var global$k = global$s;
708 var call$5 = functionCall;
709 var isCallable$6 = isCallable$b;
710 var isObject$5 = isObject$6;
712 var TypeError$8 = global$k.TypeError;
714 // `OrdinaryToPrimitive` abstract operation
715 // https://tc39.es/ecma262/#sec-ordinarytoprimitive
716 var ordinaryToPrimitive$1 = function (input, pref) {
718 if (pref === 'string' && isCallable$6(fn = input.toString) && !isObject$5(val = call$5(fn, input))) return val;
719 if (isCallable$6(fn = input.valueOf) && !isObject$5(val = call$5(fn, input))) return val;
720 if (pref !== 'string' && isCallable$6(fn = input.toString) && !isObject$5(val = call$5(fn, input))) return val;
721 throw TypeError$8("Can't convert object to primitive value");
724 var shared$3 = {exports: {}};
726 var global$j = global$s;
728 // eslint-disable-next-line es/no-object-defineproperty -- safe
729 var defineProperty = Object.defineProperty;
731 var setGlobal$3 = function (key, value) {
733 defineProperty(global$j, key, { value: value, configurable: true, writable: true });
735 global$j[key] = value;
739 var global$i = global$s;
740 var setGlobal$2 = setGlobal$3;
742 var SHARED = '__core-js_shared__';
743 var store$3 = global$i[SHARED] || setGlobal$2(SHARED, {});
745 var sharedStore = store$3;
747 var store$2 = sharedStore;
749 (shared$3.exports = function (key, value) {
750 return store$2[key] || (store$2[key] = value !== undefined ? value : {});
751 })('versions', []).push({
754 copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
757 var global$h = global$s;
758 var requireObjectCoercible = requireObjectCoercible$2;
760 var Object$2 = global$h.Object;
762 // `ToObject` abstract operation
763 // https://tc39.es/ecma262/#sec-toobject
764 var toObject$3 = function (argument) {
765 return Object$2(requireObjectCoercible(argument));
768 var uncurryThis$9 = functionUncurryThis;
769 var toObject$2 = toObject$3;
771 var hasOwnProperty = uncurryThis$9({}.hasOwnProperty);
773 // `HasOwnProperty` abstract operation
774 // https://tc39.es/ecma262/#sec-hasownproperty
775 var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
776 return hasOwnProperty(toObject$2(it), key);
779 var uncurryThis$8 = functionUncurryThis;
782 var postfix = Math.random();
783 var toString$2 = uncurryThis$8(1.0.toString);
785 var uid$2 = function (key) {
786 return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$2(++id + postfix, 36);
789 var global$g = global$s;
790 var shared$2 = shared$3.exports;
791 var hasOwn$6 = hasOwnProperty_1;
793 var NATIVE_SYMBOL = nativeSymbol;
794 var USE_SYMBOL_AS_UID = useSymbolAsUid;
796 var WellKnownSymbolsStore = shared$2('wks');
797 var Symbol$1 = global$g.Symbol;
798 var symbolFor = Symbol$1 && Symbol$1['for'];
799 var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
801 var wellKnownSymbol$6 = function (name) {
802 if (!hasOwn$6(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
803 var description = 'Symbol.' + name;
804 if (NATIVE_SYMBOL && hasOwn$6(Symbol$1, name)) {
805 WellKnownSymbolsStore[name] = Symbol$1[name];
806 } else if (USE_SYMBOL_AS_UID && symbolFor) {
807 WellKnownSymbolsStore[name] = symbolFor(description);
809 WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
811 } return WellKnownSymbolsStore[name];
814 var global$f = global$s;
815 var call$4 = functionCall;
816 var isObject$4 = isObject$6;
817 var isSymbol$1 = isSymbol$2;
818 var getMethod$2 = getMethod$3;
819 var ordinaryToPrimitive = ordinaryToPrimitive$1;
820 var wellKnownSymbol$5 = wellKnownSymbol$6;
822 var TypeError$7 = global$f.TypeError;
823 var TO_PRIMITIVE = wellKnownSymbol$5('toPrimitive');
825 // `ToPrimitive` abstract operation
826 // https://tc39.es/ecma262/#sec-toprimitive
827 var toPrimitive$1 = function (input, pref) {
828 if (!isObject$4(input) || isSymbol$1(input)) return input;
829 var exoticToPrim = getMethod$2(input, TO_PRIMITIVE);
832 if (pref === undefined) pref = 'default';
833 result = call$4(exoticToPrim, input, pref);
834 if (!isObject$4(result) || isSymbol$1(result)) return result;
835 throw TypeError$7("Can't convert object to primitive value");
837 if (pref === undefined) pref = 'number';
838 return ordinaryToPrimitive(input, pref);
841 var toPrimitive = toPrimitive$1;
842 var isSymbol = isSymbol$2;
844 // `ToPropertyKey` abstract operation
845 // https://tc39.es/ecma262/#sec-topropertykey
846 var toPropertyKey$3 = function (argument) {
847 var key = toPrimitive(argument, 'string');
848 return isSymbol(key) ? key : key + '';
851 var global$e = global$s;
852 var isObject$3 = isObject$6;
854 var document$1 = global$e.document;
855 // typeof document.createElement is 'object' in old IE
856 var EXISTS$1 = isObject$3(document$1) && isObject$3(document$1.createElement);
858 var documentCreateElement = function (it) {
859 return EXISTS$1 ? document$1.createElement(it) : {};
862 var DESCRIPTORS$4 = descriptors;
863 var fails$4 = fails$8;
864 var createElement = documentCreateElement;
866 // Thank's IE8 for his funny defineProperty
867 var ie8DomDefine = !DESCRIPTORS$4 && !fails$4(function () {
868 // eslint-disable-next-line es/no-object-defineproperty -- requied for testing
869 return Object.defineProperty(createElement('div'), 'a', {
870 get: function () { return 7; }
874 var DESCRIPTORS$3 = descriptors;
875 var call$3 = functionCall;
876 var propertyIsEnumerableModule = objectPropertyIsEnumerable;
877 var createPropertyDescriptor$2 = createPropertyDescriptor$3;
878 var toIndexedObject$2 = toIndexedObject$3;
879 var toPropertyKey$2 = toPropertyKey$3;
880 var hasOwn$5 = hasOwnProperty_1;
881 var IE8_DOM_DEFINE$1 = ie8DomDefine;
883 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
884 var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
886 // `Object.getOwnPropertyDescriptor` method
887 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
888 objectGetOwnPropertyDescriptor.f = DESCRIPTORS$3 ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
889 O = toIndexedObject$2(O);
890 P = toPropertyKey$2(P);
891 if (IE8_DOM_DEFINE$1) try {
892 return $getOwnPropertyDescriptor(O, P);
893 } catch (error) { /* empty */ }
894 if (hasOwn$5(O, P)) return createPropertyDescriptor$2(!call$3(propertyIsEnumerableModule.f, O, P), O[P]);
897 var objectDefineProperty = {};
899 var global$d = global$s;
900 var isObject$2 = isObject$6;
902 var String$2 = global$d.String;
903 var TypeError$6 = global$d.TypeError;
905 // `Assert: Type(argument) is Object`
906 var anObject$5 = function (argument) {
907 if (isObject$2(argument)) return argument;
908 throw TypeError$6(String$2(argument) + ' is not an object');
911 var global$c = global$s;
912 var DESCRIPTORS$2 = descriptors;
913 var IE8_DOM_DEFINE = ie8DomDefine;
914 var anObject$4 = anObject$5;
915 var toPropertyKey$1 = toPropertyKey$3;
917 var TypeError$5 = global$c.TypeError;
918 // eslint-disable-next-line es/no-object-defineproperty -- safe
919 var $defineProperty = Object.defineProperty;
921 // `Object.defineProperty` method
922 // https://tc39.es/ecma262/#sec-object.defineproperty
923 objectDefineProperty.f = DESCRIPTORS$2 ? $defineProperty : function defineProperty(O, P, Attributes) {
925 P = toPropertyKey$1(P);
926 anObject$4(Attributes);
927 if (IE8_DOM_DEFINE) try {
928 return $defineProperty(O, P, Attributes);
929 } catch (error) { /* empty */ }
930 if ('get' in Attributes || 'set' in Attributes) throw TypeError$5('Accessors not supported');
931 if ('value' in Attributes) O[P] = Attributes.value;
935 var DESCRIPTORS$1 = descriptors;
936 var definePropertyModule$2 = objectDefineProperty;
937 var createPropertyDescriptor$1 = createPropertyDescriptor$3;
939 var createNonEnumerableProperty$3 = DESCRIPTORS$1 ? function (object, key, value) {
940 return definePropertyModule$2.f(object, key, createPropertyDescriptor$1(1, value));
941 } : function (object, key, value) {
946 var redefine$1 = {exports: {}};
948 var uncurryThis$7 = functionUncurryThis;
949 var isCallable$5 = isCallable$b;
950 var store$1 = sharedStore;
952 var functionToString = uncurryThis$7(Function.toString);
954 // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
955 if (!isCallable$5(store$1.inspectSource)) {
956 store$1.inspectSource = function (it) {
957 return functionToString(it);
961 var inspectSource$3 = store$1.inspectSource;
963 var global$b = global$s;
964 var isCallable$4 = isCallable$b;
965 var inspectSource$2 = inspectSource$3;
967 var WeakMap$2 = global$b.WeakMap;
969 var nativeWeakMap = isCallable$4(WeakMap$2) && /native code/.test(inspectSource$2(WeakMap$2));
971 var shared$1 = shared$3.exports;
974 var keys = shared$1('keys');
976 var sharedKey$1 = function (key) {
977 return keys[key] || (keys[key] = uid(key));
980 var hiddenKeys$3 = {};
982 var NATIVE_WEAK_MAP = nativeWeakMap;
983 var global$a = global$s;
984 var uncurryThis$6 = functionUncurryThis;
985 var isObject$1 = isObject$6;
986 var createNonEnumerableProperty$2 = createNonEnumerableProperty$3;
987 var hasOwn$4 = hasOwnProperty_1;
988 var shared = sharedStore;
989 var sharedKey = sharedKey$1;
990 var hiddenKeys$2 = hiddenKeys$3;
992 var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
993 var TypeError$4 = global$a.TypeError;
994 var WeakMap$1 = global$a.WeakMap;
997 var enforce = function (it) {
998 return has(it) ? get(it) : set(it, {});
1001 var getterFor = function (TYPE) {
1002 return function (it) {
1004 if (!isObject$1(it) || (state = get(it)).type !== TYPE) {
1005 throw TypeError$4('Incompatible receiver, ' + TYPE + ' required');
1010 if (NATIVE_WEAK_MAP || shared.state) {
1011 var store = shared.state || (shared.state = new WeakMap$1());
1012 var wmget = uncurryThis$6(store.get);
1013 var wmhas = uncurryThis$6(store.has);
1014 var wmset = uncurryThis$6(store.set);
1015 set = function (it, metadata) {
1016 if (wmhas(store, it)) throw new TypeError$4(OBJECT_ALREADY_INITIALIZED);
1017 metadata.facade = it;
1018 wmset(store, it, metadata);
1021 get = function (it) {
1022 return wmget(store, it) || {};
1024 has = function (it) {
1025 return wmhas(store, it);
1028 var STATE = sharedKey('state');
1029 hiddenKeys$2[STATE] = true;
1030 set = function (it, metadata) {
1031 if (hasOwn$4(it, STATE)) throw new TypeError$4(OBJECT_ALREADY_INITIALIZED);
1032 metadata.facade = it;
1033 createNonEnumerableProperty$2(it, STATE, metadata);
1036 get = function (it) {
1037 return hasOwn$4(it, STATE) ? it[STATE] : {};
1039 has = function (it) {
1040 return hasOwn$4(it, STATE);
1044 var internalState = {
1049 getterFor: getterFor
1052 var DESCRIPTORS = descriptors;
1053 var hasOwn$3 = hasOwnProperty_1;
1055 var FunctionPrototype = Function.prototype;
1056 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1057 var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
1059 var EXISTS = hasOwn$3(FunctionPrototype, 'name');
1060 // additional protection from minified / mangled / dropped function names
1061 var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
1062 var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
1064 var functionName = {
1067 CONFIGURABLE: CONFIGURABLE
1070 var global$9 = global$s;
1071 var isCallable$3 = isCallable$b;
1072 var hasOwn$2 = hasOwnProperty_1;
1073 var createNonEnumerableProperty$1 = createNonEnumerableProperty$3;
1074 var setGlobal$1 = setGlobal$3;
1075 var inspectSource$1 = inspectSource$3;
1076 var InternalStateModule = internalState;
1077 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
1079 var getInternalState = InternalStateModule.get;
1080 var enforceInternalState = InternalStateModule.enforce;
1081 var TEMPLATE = String(String).split('String');
1083 (redefine$1.exports = function (O, key, value, options) {
1084 var unsafe = options ? !!options.unsafe : false;
1085 var simple = options ? !!options.enumerable : false;
1086 var noTargetGet = options ? !!options.noTargetGet : false;
1087 var name = options && options.name !== undefined ? options.name : key;
1089 if (isCallable$3(value)) {
1090 if (String(name).slice(0, 7) === 'Symbol(') {
1091 name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
1093 if (!hasOwn$2(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
1094 createNonEnumerableProperty$1(value, 'name', name);
1096 state = enforceInternalState(value);
1097 if (!state.source) {
1098 state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
1101 if (O === global$9) {
1102 if (simple) O[key] = value;
1103 else setGlobal$1(key, value);
1105 } else if (!unsafe) {
1107 } else if (!noTargetGet && O[key]) {
1110 if (simple) O[key] = value;
1111 else createNonEnumerableProperty$1(O, key, value);
1112 // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
1113 })(Function.prototype, 'toString', function toString() {
1114 return isCallable$3(this) && getInternalState(this).source || inspectSource$1(this);
1117 var objectGetOwnPropertyNames = {};
1119 var ceil = Math.ceil;
1120 var floor$1 = Math.floor;
1122 // `ToIntegerOrInfinity` abstract operation
1123 // https://tc39.es/ecma262/#sec-tointegerorinfinity
1124 var toIntegerOrInfinity$2 = function (argument) {
1125 var number = +argument;
1126 // eslint-disable-next-line no-self-compare -- safe
1127 return number !== number || number === 0 ? 0 : (number > 0 ? floor$1 : ceil)(number);
1130 var toIntegerOrInfinity$1 = toIntegerOrInfinity$2;
1133 var min$1 = Math.min;
1135 // Helper for a popular repeating case of the spec:
1136 // Let integer be ? ToInteger(index).
1137 // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
1138 var toAbsoluteIndex$1 = function (index, length) {
1139 var integer = toIntegerOrInfinity$1(index);
1140 return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
1143 var toIntegerOrInfinity = toIntegerOrInfinity$2;
1147 // `ToLength` abstract operation
1148 // https://tc39.es/ecma262/#sec-tolength
1149 var toLength$1 = function (argument) {
1150 return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
1153 var toLength = toLength$1;
1155 // `LengthOfArrayLike` abstract operation
1156 // https://tc39.es/ecma262/#sec-lengthofarraylike
1157 var lengthOfArrayLike$5 = function (obj) {
1158 return toLength(obj.length);
1161 var toIndexedObject$1 = toIndexedObject$3;
1162 var toAbsoluteIndex = toAbsoluteIndex$1;
1163 var lengthOfArrayLike$4 = lengthOfArrayLike$5;
1165 // `Array.prototype.{ indexOf, includes }` methods implementation
1166 var createMethod = function (IS_INCLUDES) {
1167 return function ($this, el, fromIndex) {
1168 var O = toIndexedObject$1($this);
1169 var length = lengthOfArrayLike$4(O);
1170 var index = toAbsoluteIndex(fromIndex, length);
1172 // Array#includes uses SameValueZero equality algorithm
1173 // eslint-disable-next-line no-self-compare -- NaN check
1174 if (IS_INCLUDES && el != el) while (length > index) {
1176 // eslint-disable-next-line no-self-compare -- NaN check
1177 if (value != value) return true;
1178 // Array#indexOf ignores holes, Array#includes - not
1179 } else for (;length > index; index++) {
1180 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
1181 } return !IS_INCLUDES && -1;
1185 var arrayIncludes = {
1186 // `Array.prototype.includes` method
1187 // https://tc39.es/ecma262/#sec-array.prototype.includes
1188 includes: createMethod(true),
1189 // `Array.prototype.indexOf` method
1190 // https://tc39.es/ecma262/#sec-array.prototype.indexof
1191 indexOf: createMethod(false)
1194 var uncurryThis$5 = functionUncurryThis;
1195 var hasOwn$1 = hasOwnProperty_1;
1196 var toIndexedObject = toIndexedObject$3;
1197 var indexOf = arrayIncludes.indexOf;
1198 var hiddenKeys$1 = hiddenKeys$3;
1200 var push$1 = uncurryThis$5([].push);
1202 var objectKeysInternal = function (object, names) {
1203 var O = toIndexedObject(object);
1207 for (key in O) !hasOwn$1(hiddenKeys$1, key) && hasOwn$1(O, key) && push$1(result, key);
1208 // Don't enum bug & hidden keys
1209 while (names.length > i) if (hasOwn$1(O, key = names[i++])) {
1210 ~indexOf(result, key) || push$1(result, key);
1215 // IE8- don't enum bug keys
1216 var enumBugKeys$1 = [
1220 'propertyIsEnumerable',
1226 var internalObjectKeys = objectKeysInternal;
1227 var enumBugKeys = enumBugKeys$1;
1229 var hiddenKeys = enumBugKeys.concat('length', 'prototype');
1231 // `Object.getOwnPropertyNames` method
1232 // https://tc39.es/ecma262/#sec-object.getownpropertynames
1233 // eslint-disable-next-line es/no-object-getownpropertynames -- safe
1234 objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
1235 return internalObjectKeys(O, hiddenKeys);
1238 var objectGetOwnPropertySymbols = {};
1240 // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
1241 objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
1243 var getBuiltIn$1 = getBuiltIn$4;
1244 var uncurryThis$4 = functionUncurryThis;
1245 var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
1246 var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
1247 var anObject$3 = anObject$5;
1249 var concat = uncurryThis$4([].concat);
1251 // all object keys, includes non-enumerable and symbols
1252 var ownKeys$1 = getBuiltIn$1('Reflect', 'ownKeys') || function ownKeys(it) {
1253 var keys = getOwnPropertyNamesModule.f(anObject$3(it));
1254 var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
1255 return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
1258 var hasOwn = hasOwnProperty_1;
1259 var ownKeys = ownKeys$1;
1260 var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
1261 var definePropertyModule$1 = objectDefineProperty;
1263 var copyConstructorProperties$1 = function (target, source) {
1264 var keys = ownKeys(source);
1265 var defineProperty = definePropertyModule$1.f;
1266 var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
1267 for (var i = 0; i < keys.length; i++) {
1269 if (!hasOwn(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
1273 var fails$3 = fails$8;
1274 var isCallable$2 = isCallable$b;
1276 var replacement = /#|\.prototype\./;
1278 var isForced$1 = function (feature, detection) {
1279 var value = data[normalize(feature)];
1280 return value == POLYFILL ? true
1281 : value == NATIVE ? false
1282 : isCallable$2(detection) ? fails$3(detection)
1286 var normalize = isForced$1.normalize = function (string) {
1287 return String(string).replace(replacement, '.').toLowerCase();
1290 var data = isForced$1.data = {};
1291 var NATIVE = isForced$1.NATIVE = 'N';
1292 var POLYFILL = isForced$1.POLYFILL = 'P';
1294 var isForced_1 = isForced$1;
1296 var global$8 = global$s;
1297 var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
1298 var createNonEnumerableProperty = createNonEnumerableProperty$3;
1299 var redefine = redefine$1.exports;
1300 var setGlobal = setGlobal$3;
1301 var copyConstructorProperties = copyConstructorProperties$1;
1302 var isForced = isForced_1;
1305 options.target - name of the target object
1306 options.global - target is the global object
1307 options.stat - export as static methods of target
1308 options.proto - export as prototype methods of target
1309 options.real - real prototype method for the `pure` version
1310 options.forced - export even if the native feature is available
1311 options.bind - bind methods to the target, required for the `pure` version
1312 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
1313 options.unsafe - use the simple assignment of property instead of delete + defineProperty
1314 options.sham - add a flag to not completely full polyfills
1315 options.enumerable - export as enumerable property
1316 options.noTargetGet - prevent calling a getter on target
1317 options.name - the .name of the function if it does not match the key
1319 var _export = function (options, source) {
1320 var TARGET = options.target;
1321 var GLOBAL = options.global;
1322 var STATIC = options.stat;
1323 var FORCED, target, key, targetProperty, sourceProperty, descriptor;
1326 } else if (STATIC) {
1327 target = global$8[TARGET] || setGlobal(TARGET, {});
1329 target = (global$8[TARGET] || {}).prototype;
1331 if (target) for (key in source) {
1332 sourceProperty = source[key];
1333 if (options.noTargetGet) {
1334 descriptor = getOwnPropertyDescriptor(target, key);
1335 targetProperty = descriptor && descriptor.value;
1336 } else targetProperty = target[key];
1337 FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
1338 // contained in target
1339 if (!FORCED && targetProperty !== undefined) {
1340 if (typeof sourceProperty == typeof targetProperty) continue;
1341 copyConstructorProperties(sourceProperty, targetProperty);
1343 // add a flag to not completely full polyfills
1344 if (options.sham || (targetProperty && targetProperty.sham)) {
1345 createNonEnumerableProperty(sourceProperty, 'sham', true);
1348 redefine(target, key, sourceProperty, options);
1352 var classof$4 = classofRaw$1;
1354 // `IsArray` abstract operation
1355 // https://tc39.es/ecma262/#sec-isarray
1356 // eslint-disable-next-line es/no-array-isarray -- safe
1357 var isArray$2 = Array.isArray || function isArray(argument) {
1358 return classof$4(argument) == 'Array';
1361 var uncurryThis$3 = functionUncurryThis;
1362 var aCallable$3 = aCallable$5;
1364 var bind$2 = uncurryThis$3(uncurryThis$3.bind);
1366 // optional / simple context binding
1367 var functionBindContext = function (fn, that) {
1369 return that === undefined ? fn : bind$2 ? bind$2(fn, that) : function (/* ...args */) {
1370 return fn.apply(that, arguments);
1374 var global$7 = global$s;
1375 var isArray$1 = isArray$2;
1376 var lengthOfArrayLike$3 = lengthOfArrayLike$5;
1377 var bind$1 = functionBindContext;
1379 var TypeError$3 = global$7.TypeError;
1381 // `FlattenIntoArray` abstract operation
1382 // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
1383 var flattenIntoArray$1 = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
1384 var targetIndex = start;
1385 var sourceIndex = 0;
1386 var mapFn = mapper ? bind$1(mapper, thisArg) : false;
1387 var element, elementLen;
1389 while (sourceIndex < sourceLen) {
1390 if (sourceIndex in source) {
1391 element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
1393 if (depth > 0 && isArray$1(element)) {
1394 elementLen = lengthOfArrayLike$3(element);
1395 targetIndex = flattenIntoArray$1(target, original, element, elementLen, targetIndex, depth - 1) - 1;
1397 if (targetIndex >= 0x1FFFFFFFFFFFFF) throw TypeError$3('Exceed the acceptable array length');
1398 target[targetIndex] = element;
1408 var flattenIntoArray_1 = flattenIntoArray$1;
1410 var wellKnownSymbol$4 = wellKnownSymbol$6;
1412 var TO_STRING_TAG$1 = wellKnownSymbol$4('toStringTag');
1415 test$1[TO_STRING_TAG$1] = 'z';
1417 var toStringTagSupport = String(test$1) === '[object z]';
1419 var global$6 = global$s;
1420 var TO_STRING_TAG_SUPPORT = toStringTagSupport;
1421 var isCallable$1 = isCallable$b;
1422 var classofRaw = classofRaw$1;
1423 var wellKnownSymbol$3 = wellKnownSymbol$6;
1425 var TO_STRING_TAG = wellKnownSymbol$3('toStringTag');
1426 var Object$1 = global$6.Object;
1429 var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
1431 // fallback for IE11 Script Access Denied error
1432 var tryGet = function (it, key) {
1435 } catch (error) { /* empty */ }
1438 // getting tag from ES6+ `Object.prototype.toString`
1439 var classof$3 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
1441 return it === undefined ? 'Undefined' : it === null ? 'Null'
1442 // @@toStringTag case
1443 : typeof (tag = tryGet(O = Object$1(it), TO_STRING_TAG)) == 'string' ? tag
1445 : CORRECT_ARGUMENTS ? classofRaw(O)
1446 // ES3 arguments fallback
1447 : (result = classofRaw(O)) == 'Object' && isCallable$1(O.callee) ? 'Arguments' : result;
1450 var uncurryThis$2 = functionUncurryThis;
1451 var fails$2 = fails$8;
1452 var isCallable = isCallable$b;
1453 var classof$2 = classof$3;
1454 var getBuiltIn = getBuiltIn$4;
1455 var inspectSource = inspectSource$3;
1457 var noop$1 = function () { /* empty */ };
1459 var construct = getBuiltIn('Reflect', 'construct');
1460 var constructorRegExp = /^\s*(?:class|function)\b/;
1461 var exec = uncurryThis$2(constructorRegExp.exec);
1462 var INCORRECT_TO_STRING = !constructorRegExp.exec(noop$1);
1464 var isConstructorModern = function (argument) {
1465 if (!isCallable(argument)) return false;
1467 construct(noop$1, empty, argument);
1474 var isConstructorLegacy = function (argument) {
1475 if (!isCallable(argument)) return false;
1476 switch (classof$2(argument)) {
1477 case 'AsyncFunction':
1478 case 'GeneratorFunction':
1479 case 'AsyncGeneratorFunction': return false;
1480 // we can't check .prototype since constructors produced by .bind haven't it
1481 } return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
1484 // `IsConstructor` abstract operation
1485 // https://tc39.es/ecma262/#sec-isconstructor
1486 var isConstructor$1 = !construct || fails$2(function () {
1488 return isConstructorModern(isConstructorModern.call)
1489 || !isConstructorModern(Object)
1490 || !isConstructorModern(function () { called = true; })
1492 }) ? isConstructorLegacy : isConstructorModern;
1494 var global$5 = global$s;
1495 var isArray = isArray$2;
1496 var isConstructor = isConstructor$1;
1497 var isObject = isObject$6;
1498 var wellKnownSymbol$2 = wellKnownSymbol$6;
1500 var SPECIES = wellKnownSymbol$2('species');
1501 var Array$1 = global$5.Array;
1503 // a part of `ArraySpeciesCreate` abstract operation
1504 // https://tc39.es/ecma262/#sec-arrayspeciescreate
1505 var arraySpeciesConstructor$1 = function (originalArray) {
1507 if (isArray(originalArray)) {
1508 C = originalArray.constructor;
1509 // cross-realm fallback
1510 if (isConstructor(C) && (C === Array$1 || isArray(C.prototype))) C = undefined;
1511 else if (isObject(C)) {
1513 if (C === null) C = undefined;
1515 } return C === undefined ? Array$1 : C;
1518 var arraySpeciesConstructor = arraySpeciesConstructor$1;
1520 // `ArraySpeciesCreate` abstract operation
1521 // https://tc39.es/ecma262/#sec-arrayspeciescreate
1522 var arraySpeciesCreate$1 = function (originalArray, length) {
1523 return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
1527 var flattenIntoArray = flattenIntoArray_1;
1528 var aCallable$2 = aCallable$5;
1529 var toObject$1 = toObject$3;
1530 var lengthOfArrayLike$2 = lengthOfArrayLike$5;
1531 var arraySpeciesCreate = arraySpeciesCreate$1;
1533 // `Array.prototype.flatMap` method
1534 // https://tc39.es/ecma262/#sec-array.prototype.flatmap
1535 $$2({ target: 'Array', proto: true }, {
1536 flatMap: function flatMap(callbackfn /* , thisArg */) {
1537 var O = toObject$1(this);
1538 var sourceLen = lengthOfArrayLike$2(O);
1540 aCallable$2(callbackfn);
1541 A = arraySpeciesCreate(O, 0);
1542 A.length = flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
1547 var global$4 = global$s;
1548 var classof$1 = classof$3;
1550 var String$1 = global$4.String;
1552 var toString$1 = function (argument) {
1553 if (classof$1(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
1554 return String$1(argument);
1557 var uncurryThis$1 = functionUncurryThis;
1559 var arraySlice$1 = uncurryThis$1([].slice);
1561 var arraySlice = arraySlice$1;
1563 var floor = Math.floor;
1565 var mergeSort = function (array, comparefn) {
1566 var length = array.length;
1567 var middle = floor(length / 2);
1568 return length < 8 ? insertionSort(array, comparefn) : merge(
1570 mergeSort(arraySlice(array, 0, middle), comparefn),
1571 mergeSort(arraySlice(array, middle), comparefn),
1576 var insertionSort = function (array, comparefn) {
1577 var length = array.length;
1581 while (i < length) {
1584 while (j && comparefn(array[j - 1], element) > 0) {
1585 array[j] = array[--j];
1587 if (j !== i++) array[j] = element;
1591 var merge = function (array, left, right, comparefn) {
1592 var llength = left.length;
1593 var rlength = right.length;
1597 while (lindex < llength || rindex < rlength) {
1598 array[lindex + rindex] = (lindex < llength && rindex < rlength)
1599 ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]
1600 : lindex < llength ? left[lindex++] : right[rindex++];
1604 var arraySort = mergeSort;
1606 var fails$1 = fails$8;
1608 var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
1609 var method = [][METHOD_NAME];
1610 return !!method && fails$1(function () {
1611 // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing
1612 method.call(null, argument || function () { throw 1; }, 1);
1616 var userAgent$1 = engineUserAgent;
1618 var firefox = userAgent$1.match(/firefox\/(\d+)/i);
1620 var engineFfVersion = !!firefox && +firefox[1];
1622 var UA = engineUserAgent;
1624 var engineIsIeOrEdge = /MSIE|Trident/.test(UA);
1626 var userAgent = engineUserAgent;
1628 var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
1630 var engineWebkitVersion = !!webkit && +webkit[1];
1633 var uncurryThis = functionUncurryThis;
1634 var aCallable$1 = aCallable$5;
1635 var toObject = toObject$3;
1636 var lengthOfArrayLike$1 = lengthOfArrayLike$5;
1637 var toString = toString$1;
1638 var fails = fails$8;
1639 var internalSort = arraySort;
1640 var arrayMethodIsStrict = arrayMethodIsStrict$1;
1641 var FF = engineFfVersion;
1642 var IE_OR_EDGE = engineIsIeOrEdge;
1643 var V8 = engineV8Version;
1644 var WEBKIT = engineWebkitVersion;
1647 var un$Sort = uncurryThis(test.sort);
1648 var push = uncurryThis(test.push);
1651 var FAILS_ON_UNDEFINED = fails(function () {
1652 test.sort(undefined);
1655 var FAILS_ON_NULL = fails(function () {
1659 var STRICT_METHOD = arrayMethodIsStrict('sort');
1661 var STABLE_SORT = !fails(function () {
1662 // feature detection can be too slow, so check engines versions
1663 if (V8) return V8 < 70;
1664 if (FF && FF > 3) return;
1665 if (IE_OR_EDGE) return true;
1666 if (WEBKIT) return WEBKIT < 603;
1669 var code, chr, value, index;
1671 // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
1672 for (code = 65; code < 76; code++) {
1673 chr = String.fromCharCode(code);
1676 case 66: case 69: case 70: case 72: value = 3; break;
1677 case 68: case 71: value = 4; break;
1681 for (index = 0; index < 47; index++) {
1682 test.push({ k: chr + index, v: value });
1686 test.sort(function (a, b) { return b.v - a.v; });
1688 for (index = 0; index < test.length; index++) {
1689 chr = test[index].k.charAt(0);
1690 if (result.charAt(result.length - 1) !== chr) result += chr;
1693 return result !== 'DGBEFHACIJK';
1696 var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
1698 var getSortCompare = function (comparefn) {
1699 return function (x, y) {
1700 if (y === undefined) return -1;
1701 if (x === undefined) return 1;
1702 if (comparefn !== undefined) return +comparefn(x, y) || 0;
1703 return toString(x) > toString(y) ? 1 : -1;
1707 // `Array.prototype.sort` method
1708 // https://tc39.es/ecma262/#sec-array.prototype.sort
1709 $$1({ target: 'Array', proto: true, forced: FORCED }, {
1710 sort: function sort(comparefn) {
1711 if (comparefn !== undefined) aCallable$1(comparefn);
1713 var array = toObject(this);
1715 if (STABLE_SORT) return comparefn === undefined ? un$Sort(array) : un$Sort(array, comparefn);
1718 var arrayLength = lengthOfArrayLike$1(array);
1719 var itemsLength, index;
1721 for (index = 0; index < arrayLength; index++) {
1722 if (index in array) push(items, array[index]);
1725 internalSort(items, getSortCompare(comparefn));
1727 itemsLength = items.length;
1730 while (index < itemsLength) array[index] = items[index++];
1731 while (index < arrayLength) delete array[index++];
1739 var wellKnownSymbol$1 = wellKnownSymbol$6;
1740 var Iterators$1 = iterators;
1742 var ITERATOR$1 = wellKnownSymbol$1('iterator');
1743 var ArrayPrototype = Array.prototype;
1745 // check on default Array iterator
1746 var isArrayIteratorMethod$1 = function (it) {
1747 return it !== undefined && (Iterators$1.Array === it || ArrayPrototype[ITERATOR$1] === it);
1750 var classof = classof$3;
1751 var getMethod$1 = getMethod$3;
1752 var Iterators = iterators;
1753 var wellKnownSymbol = wellKnownSymbol$6;
1755 var ITERATOR = wellKnownSymbol('iterator');
1757 var getIteratorMethod$2 = function (it) {
1758 if (it != undefined) return getMethod$1(it, ITERATOR)
1759 || getMethod$1(it, '@@iterator')
1760 || Iterators[classof(it)];
1763 var global$3 = global$s;
1764 var call$2 = functionCall;
1765 var aCallable = aCallable$5;
1766 var anObject$2 = anObject$5;
1767 var tryToString$1 = tryToString$3;
1768 var getIteratorMethod$1 = getIteratorMethod$2;
1770 var TypeError$2 = global$3.TypeError;
1772 var getIterator$1 = function (argument, usingIterator) {
1773 var iteratorMethod = arguments.length < 2 ? getIteratorMethod$1(argument) : usingIterator;
1774 if (aCallable(iteratorMethod)) return anObject$2(call$2(iteratorMethod, argument));
1775 throw TypeError$2(tryToString$1(argument) + ' is not iterable');
1778 var call$1 = functionCall;
1779 var anObject$1 = anObject$5;
1780 var getMethod = getMethod$3;
1782 var iteratorClose$1 = function (iterator, kind, value) {
1783 var innerResult, innerError;
1784 anObject$1(iterator);
1786 innerResult = getMethod(iterator, 'return');
1788 if (kind === 'throw') throw value;
1791 innerResult = call$1(innerResult, iterator);
1794 innerResult = error;
1796 if (kind === 'throw') throw value;
1797 if (innerError) throw innerResult;
1798 anObject$1(innerResult);
1802 var global$2 = global$s;
1803 var bind = functionBindContext;
1804 var call = functionCall;
1805 var anObject = anObject$5;
1806 var tryToString = tryToString$3;
1807 var isArrayIteratorMethod = isArrayIteratorMethod$1;
1808 var lengthOfArrayLike = lengthOfArrayLike$5;
1809 var isPrototypeOf = objectIsPrototypeOf;
1810 var getIterator = getIterator$1;
1811 var getIteratorMethod = getIteratorMethod$2;
1812 var iteratorClose = iteratorClose$1;
1814 var TypeError$1 = global$2.TypeError;
1816 var Result = function (stopped, result) {
1817 this.stopped = stopped;
1818 this.result = result;
1821 var ResultPrototype = Result.prototype;
1823 var iterate$1 = function (iterable, unboundFunction, options) {
1824 var that = options && options.that;
1825 var AS_ENTRIES = !!(options && options.AS_ENTRIES);
1826 var IS_ITERATOR = !!(options && options.IS_ITERATOR);
1827 var INTERRUPTED = !!(options && options.INTERRUPTED);
1828 var fn = bind(unboundFunction, that);
1829 var iterator, iterFn, index, length, result, next, step;
1831 var stop = function (condition) {
1832 if (iterator) iteratorClose(iterator, 'normal', condition);
1833 return new Result(true, condition);
1836 var callFn = function (value) {
1839 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
1840 } return INTERRUPTED ? fn(value, stop) : fn(value);
1844 iterator = iterable;
1846 iterFn = getIteratorMethod(iterable);
1847 if (!iterFn) throw TypeError$1(tryToString(iterable) + ' is not iterable');
1848 // optimisation for array iterators
1849 if (isArrayIteratorMethod(iterFn)) {
1850 for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
1851 result = callFn(iterable[index]);
1852 if (result && isPrototypeOf(ResultPrototype, result)) return result;
1853 } return new Result(false);
1855 iterator = getIterator(iterable, iterFn);
1858 next = iterator.next;
1859 while (!(step = call(next, iterator)).done) {
1861 result = callFn(step.value);
1863 iteratorClose(iterator, 'throw', error);
1865 if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
1866 } return new Result(false);
1869 var toPropertyKey = toPropertyKey$3;
1870 var definePropertyModule = objectDefineProperty;
1871 var createPropertyDescriptor = createPropertyDescriptor$3;
1873 var createProperty$1 = function (object, key, value) {
1874 var propertyKey = toPropertyKey(key);
1875 if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
1876 else object[propertyKey] = value;
1880 var iterate = iterate$1;
1881 var createProperty = createProperty$1;
1883 // `Object.fromEntries` method
1884 // https://github.com/tc39/proposal-object-from-entries
1885 $({ target: 'Object', stat: true }, {
1886 fromEntries: function fromEntries(iterable) {
1888 iterate(iterable, function (k, v) {
1889 createProperty(obj, k, v);
1890 }, { AS_ENTRIES: true });
1895 var global$1 = (typeof global$1 !== "undefined" ? global$1 :
1896 typeof self !== "undefined" ? self :
1897 typeof window !== "undefined" ? window : {});
1899 // shim for using process in browser
1900 // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
1902 function defaultSetTimout() {
1903 throw new Error('setTimeout has not been defined');
1905 function defaultClearTimeout () {
1906 throw new Error('clearTimeout has not been defined');
1908 var cachedSetTimeout = defaultSetTimout;
1909 var cachedClearTimeout = defaultClearTimeout;
1910 if (typeof global$1.setTimeout === 'function') {
1911 cachedSetTimeout = setTimeout;
1913 if (typeof global$1.clearTimeout === 'function') {
1914 cachedClearTimeout = clearTimeout;
1917 function runTimeout(fun) {
1918 if (cachedSetTimeout === setTimeout) {
1919 //normal enviroments in sane situations
1920 return setTimeout(fun, 0);
1922 // if setTimeout wasn't available but was latter defined
1923 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
1924 cachedSetTimeout = setTimeout;
1925 return setTimeout(fun, 0);
1928 // when when somebody has screwed with setTimeout but no I.E. maddness
1929 return cachedSetTimeout(fun, 0);
1932 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
1933 return cachedSetTimeout.call(null, fun, 0);
1935 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
1936 return cachedSetTimeout.call(this, fun, 0);
1942 function runClearTimeout(marker) {
1943 if (cachedClearTimeout === clearTimeout) {
1944 //normal enviroments in sane situations
1945 return clearTimeout(marker);
1947 // if clearTimeout wasn't available but was latter defined
1948 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
1949 cachedClearTimeout = clearTimeout;
1950 return clearTimeout(marker);
1953 // when when somebody has screwed with setTimeout but no I.E. maddness
1954 return cachedClearTimeout(marker);
1957 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
1958 return cachedClearTimeout.call(null, marker);
1960 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
1961 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
1962 return cachedClearTimeout.call(this, marker);
1970 var draining = false;
1972 var queueIndex = -1;
1974 function cleanUpNextTick() {
1975 if (!draining || !currentQueue) {
1979 if (currentQueue.length) {
1980 queue = currentQueue.concat(queue);
1989 function drainQueue() {
1993 var timeout = runTimeout(cleanUpNextTick);
1996 var len = queue.length;
1998 currentQueue = queue;
2000 while (++queueIndex < len) {
2002 currentQueue[queueIndex].run();
2008 currentQueue = null;
2010 runClearTimeout(timeout);
2012 function nextTick(fun) {
2013 var args = new Array(arguments.length - 1);
2014 if (arguments.length > 1) {
2015 for (var i = 1; i < arguments.length; i++) {
2016 args[i - 1] = arguments[i];
2019 queue.push(new Item(fun, args));
2020 if (queue.length === 1 && !draining) {
2021 runTimeout(drainQueue);
2024 // v8 likes predictible objects
2025 function Item(fun, array) {
2029 Item.prototype.run = function () {
2030 this.fun.apply(null, this.array);
2032 var title = 'browser';
2033 var platform = 'browser';
2037 var version = ''; // empty string to avoid regexp issues
2045 var addListener = noop;
2048 var removeListener = noop;
2049 var removeAllListeners = noop;
2052 function binding(name) {
2053 throw new Error('process.binding is not supported');
2056 function cwd () { return '/' }
2057 function chdir (dir) {
2058 throw new Error('process.chdir is not supported');
2059 }function umask() { return 0; }
2061 // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
2062 var performance = global$1.performance || {};
2063 var performanceNow =
2065 performance.mozNow ||
2066 performance.msNow ||
2068 performance.webkitNow ||
2069 function(){ return (new Date()).getTime() };
2071 // generate timestamp or delta
2072 // see http://nodejs.org/api/process.html#process_process_hrtime
2073 function hrtime(previousTimestamp){
2074 var clocktime = performanceNow.call(performance)*1e-3;
2075 var seconds = Math.floor(clocktime);
2076 var nanoseconds = Math.floor((clocktime%1)*1e9);
2077 if (previousTimestamp) {
2078 seconds = seconds - previousTimestamp[0];
2079 nanoseconds = nanoseconds - previousTimestamp[1];
2080 if (nanoseconds<0) {
2085 return [seconds,nanoseconds]
2088 var startTime = new Date();
2090 var currentTime = new Date();
2091 var dif = currentTime - startTime;
2104 addListener: addListener,
2107 removeListener: removeListener,
2108 removeAllListeners: removeAllListeners,
2121 var process = browser$1;
2123 const debug$1 = typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? function () {
2124 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2125 args[_key] = arguments[_key];
2128 return console.error('SEMVER', ...args);
2130 var debug_1 = debug$1;
2132 // Not necessarily the package version of this code.
2134 const SEMVER_SPEC_VERSION = '2.0.0';
2135 const MAX_LENGTH$1 = 256;
2136 const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
2137 /* istanbul ignore next */
2138 9007199254740991; // Max safe segment length for coercion.
2140 const MAX_SAFE_COMPONENT_LENGTH = 16;
2142 SEMVER_SPEC_VERSION,
2143 MAX_LENGTH: MAX_LENGTH$1,
2144 MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
2145 MAX_SAFE_COMPONENT_LENGTH
2148 var re$1 = {exports: {}};
2150 (function (module, exports) {
2152 MAX_SAFE_COMPONENT_LENGTH
2154 const debug = debug_1;
2155 exports = module.exports = {}; // The actual regexps go on exports.re
2157 const re = exports.re = [];
2158 const src = exports.src = [];
2159 const t = exports.t = {};
2162 const createToken = (name, value, isGlobal) => {
2164 debug(index, value);
2167 re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
2168 }; // The following Regular Expressions can be used for tokenizing,
2169 // validating, and parsing SemVer version strings.
2170 // ## Numeric Identifier
2171 // A single `0`, or a non-zero digit followed by zero or more digits.
2174 createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
2175 createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+'); // ## Non-numeric Identifier
2176 // Zero or more digits, followed by a letter or hyphen, and then zero or
2177 // more letters, digits, or hyphens.
2179 createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*'); // ## Main Version
2180 // Three dot-separated numeric identifiers.
2182 createToken('MAINVERSION', "(".concat(src[t.NUMERICIDENTIFIER], ")\\.") + "(".concat(src[t.NUMERICIDENTIFIER], ")\\.") + "(".concat(src[t.NUMERICIDENTIFIER], ")"));
2183 createToken('MAINVERSIONLOOSE', "(".concat(src[t.NUMERICIDENTIFIERLOOSE], ")\\.") + "(".concat(src[t.NUMERICIDENTIFIERLOOSE], ")\\.") + "(".concat(src[t.NUMERICIDENTIFIERLOOSE], ")")); // ## Pre-release Version Identifier
2184 // A numeric identifier, or a non-numeric identifier.
2186 createToken('PRERELEASEIDENTIFIER', "(?:".concat(src[t.NUMERICIDENTIFIER], "|").concat(src[t.NONNUMERICIDENTIFIER], ")"));
2187 createToken('PRERELEASEIDENTIFIERLOOSE', "(?:".concat(src[t.NUMERICIDENTIFIERLOOSE], "|").concat(src[t.NONNUMERICIDENTIFIER], ")")); // ## Pre-release Version
2188 // Hyphen, followed by one or more dot-separated pre-release version
2191 createToken('PRERELEASE', "(?:-(".concat(src[t.PRERELEASEIDENTIFIER], "(?:\\.").concat(src[t.PRERELEASEIDENTIFIER], ")*))"));
2192 createToken('PRERELEASELOOSE', "(?:-?(".concat(src[t.PRERELEASEIDENTIFIERLOOSE], "(?:\\.").concat(src[t.PRERELEASEIDENTIFIERLOOSE], ")*))")); // ## Build Metadata Identifier
2193 // Any combination of digits, letters, or hyphens.
2195 createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+'); // ## Build Metadata
2196 // Plus sign, followed by one or more period-separated build metadata
2199 createToken('BUILD', "(?:\\+(".concat(src[t.BUILDIDENTIFIER], "(?:\\.").concat(src[t.BUILDIDENTIFIER], ")*))")); // ## Full Version String
2200 // A main version, followed optionally by a pre-release version and
2202 // Note that the only major, minor, patch, and pre-release sections of
2203 // the version string are capturing groups. The build metadata is not a
2204 // capturing group, because it should not ever be used in version
2207 createToken('FULLPLAIN', "v?".concat(src[t.MAINVERSION]).concat(src[t.PRERELEASE], "?").concat(src[t.BUILD], "?"));
2208 createToken('FULL', "^".concat(src[t.FULLPLAIN], "$")); // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
2209 // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
2210 // common in the npm registry.
2212 createToken('LOOSEPLAIN', "[v=\\s]*".concat(src[t.MAINVERSIONLOOSE]).concat(src[t.PRERELEASELOOSE], "?").concat(src[t.BUILD], "?"));
2213 createToken('LOOSE', "^".concat(src[t.LOOSEPLAIN], "$"));
2214 createToken('GTLT', '((?:<|>)?=?)'); // Something like "2.*" or "1.2.x".
2215 // Note that "x.x" is a valid xRange identifer, meaning "any version"
2216 // Only the first item is strictly required.
2218 createToken('XRANGEIDENTIFIERLOOSE', "".concat(src[t.NUMERICIDENTIFIERLOOSE], "|x|X|\\*"));
2219 createToken('XRANGEIDENTIFIER', "".concat(src[t.NUMERICIDENTIFIER], "|x|X|\\*"));
2220 createToken('XRANGEPLAIN', "[v=\\s]*(".concat(src[t.XRANGEIDENTIFIER], ")") + "(?:\\.(".concat(src[t.XRANGEIDENTIFIER], ")") + "(?:\\.(".concat(src[t.XRANGEIDENTIFIER], ")") + "(?:".concat(src[t.PRERELEASE], ")?").concat(src[t.BUILD], "?") + ")?)?");
2221 createToken('XRANGEPLAINLOOSE', "[v=\\s]*(".concat(src[t.XRANGEIDENTIFIERLOOSE], ")") + "(?:\\.(".concat(src[t.XRANGEIDENTIFIERLOOSE], ")") + "(?:\\.(".concat(src[t.XRANGEIDENTIFIERLOOSE], ")") + "(?:".concat(src[t.PRERELEASELOOSE], ")?").concat(src[t.BUILD], "?") + ")?)?");
2222 createToken('XRANGE', "^".concat(src[t.GTLT], "\\s*").concat(src[t.XRANGEPLAIN], "$"));
2223 createToken('XRANGELOOSE', "^".concat(src[t.GTLT], "\\s*").concat(src[t.XRANGEPLAINLOOSE], "$")); // Coercion.
2224 // Extract anything that could conceivably be a part of a valid semver
2226 createToken('COERCE', "".concat('(^|[^\\d])' + '(\\d{1,').concat(MAX_SAFE_COMPONENT_LENGTH, "})") + "(?:\\.(\\d{1,".concat(MAX_SAFE_COMPONENT_LENGTH, "}))?") + "(?:\\.(\\d{1,".concat(MAX_SAFE_COMPONENT_LENGTH, "}))?") + "(?:$|[^\\d])");
2227 createToken('COERCERTL', src[t.COERCE], true); // Tilde ranges.
2228 // Meaning is "reasonably at or greater than"
2230 createToken('LONETILDE', '(?:~>?)');
2231 createToken('TILDETRIM', "(\\s*)".concat(src[t.LONETILDE], "\\s+"), true);
2232 exports.tildeTrimReplace = '$1~';
2233 createToken('TILDE', "^".concat(src[t.LONETILDE]).concat(src[t.XRANGEPLAIN], "$"));
2234 createToken('TILDELOOSE', "^".concat(src[t.LONETILDE]).concat(src[t.XRANGEPLAINLOOSE], "$")); // Caret ranges.
2235 // Meaning is "at least and backwards compatible with"
2237 createToken('LONECARET', '(?:\\^)');
2238 createToken('CARETTRIM', "(\\s*)".concat(src[t.LONECARET], "\\s+"), true);
2239 exports.caretTrimReplace = '$1^';
2240 createToken('CARET', "^".concat(src[t.LONECARET]).concat(src[t.XRANGEPLAIN], "$"));
2241 createToken('CARETLOOSE', "^".concat(src[t.LONECARET]).concat(src[t.XRANGEPLAINLOOSE], "$")); // A simple gt/lt/eq thing, or just "" to indicate "any version"
2243 createToken('COMPARATORLOOSE', "^".concat(src[t.GTLT], "\\s*(").concat(src[t.LOOSEPLAIN], ")$|^$"));
2244 createToken('COMPARATOR', "^".concat(src[t.GTLT], "\\s*(").concat(src[t.FULLPLAIN], ")$|^$")); // An expression to strip any whitespace between the gtlt and the thing
2245 // it modifies, so that `> 1.2.3` ==> `>1.2.3`
2247 createToken('COMPARATORTRIM', "(\\s*)".concat(src[t.GTLT], "\\s*(").concat(src[t.LOOSEPLAIN], "|").concat(src[t.XRANGEPLAIN], ")"), true);
2248 exports.comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
2249 // Note that these all use the loose form, because they'll be
2250 // checked against either the strict or loose comparator form
2253 createToken('HYPHENRANGE', "^\\s*(".concat(src[t.XRANGEPLAIN], ")") + "\\s+-\\s+" + "(".concat(src[t.XRANGEPLAIN], ")") + "\\s*$");
2254 createToken('HYPHENRANGELOOSE', "^\\s*(".concat(src[t.XRANGEPLAINLOOSE], ")") + "\\s+-\\s+" + "(".concat(src[t.XRANGEPLAINLOOSE], ")") + "\\s*$"); // Star ranges basically just allow anything at all.
2256 createToken('STAR', '(<|>)?=?\\s*\\*'); // >=0.0.0 is like a star
2258 createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$');
2259 createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$');
2260 })(re$1, re$1.exports);
2262 // obj with keys in a consistent order.
2264 const opts = ['includePrerelease', 'loose', 'rtl'];
2266 const parseOptions$1 = options => !options ? {} : typeof options !== 'object' ? {
2268 } : opts.filter(k => options[k]).reduce((options, k) => {
2273 var parseOptions_1 = parseOptions$1;
2275 const numeric = /^[0-9]+$/;
2277 const compareIdentifiers$1 = (a, b) => {
2278 const anum = numeric.test(a);
2279 const bnum = numeric.test(b);
2286 return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
2289 const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
2292 compareIdentifiers: compareIdentifiers$1,
2296 const debug = debug_1;
2305 const parseOptions = parseOptions_1;
2311 constructor(version, options) {
2312 options = parseOptions(options);
2314 if (version instanceof SemVer$1) {
2315 if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
2318 version = version.version;
2320 } else if (typeof version !== 'string') {
2321 throw new TypeError("Invalid Version: ".concat(version));
2324 if (version.length > MAX_LENGTH) {
2325 throw new TypeError("version is longer than ".concat(MAX_LENGTH, " characters"));
2328 debug('SemVer', version, options);
2329 this.options = options;
2330 this.loose = !!options.loose; // this isn't actually relevant for versions, but keep it so that we
2331 // don't run into trouble passing this.options around.
2333 this.includePrerelease = !!options.includePrerelease;
2334 const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
2337 throw new TypeError("Invalid Version: ".concat(version));
2340 this.raw = version; // these are actually numbers
2346 if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
2347 throw new TypeError('Invalid major version');
2350 if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
2351 throw new TypeError('Invalid minor version');
2354 if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
2355 throw new TypeError('Invalid patch version');
2356 } // numberify any prerelease numeric ids
2360 this.prerelease = [];
2362 this.prerelease = m[4].split('.').map(id => {
2363 if (/^[0-9]+$/.test(id)) {
2366 if (num >= 0 && num < MAX_SAFE_INTEGER) {
2375 this.build = m[5] ? m[5].split('.') : [];
2380 this.version = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch);
2382 if (this.prerelease.length) {
2383 this.version += "-".concat(this.prerelease.join('.'));
2386 return this.version;
2390 return this.version;
2394 debug('SemVer.compare', this.version, this.options, other);
2396 if (!(other instanceof SemVer$1)) {
2397 if (typeof other === 'string' && other === this.version) {
2401 other = new SemVer$1(other, this.options);
2404 if (other.version === this.version) {
2408 return this.compareMain(other) || this.comparePre(other);
2411 compareMain(other) {
2412 if (!(other instanceof SemVer$1)) {
2413 other = new SemVer$1(other, this.options);
2416 return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
2420 if (!(other instanceof SemVer$1)) {
2421 other = new SemVer$1(other, this.options);
2422 } // NOT having a prerelease is > having one
2425 if (this.prerelease.length && !other.prerelease.length) {
2427 } else if (!this.prerelease.length && other.prerelease.length) {
2429 } else if (!this.prerelease.length && !other.prerelease.length) {
2436 const a = this.prerelease[i];
2437 const b = other.prerelease[i];
2438 debug('prerelease compare', i, a, b);
2440 if (a === undefined && b === undefined) {
2442 } else if (b === undefined) {
2444 } else if (a === undefined) {
2446 } else if (a === b) {
2449 return compareIdentifiers(a, b);
2454 compareBuild(other) {
2455 if (!(other instanceof SemVer$1)) {
2456 other = new SemVer$1(other, this.options);
2462 const a = this.build[i];
2463 const b = other.build[i];
2464 debug('prerelease compare', i, a, b);
2466 if (a === undefined && b === undefined) {
2468 } else if (b === undefined) {
2470 } else if (a === undefined) {
2472 } else if (a === b) {
2475 return compareIdentifiers(a, b);
2478 } // preminor will bump the version up to the next minor release, and immediately
2479 // down to pre-release. premajor and prepatch work the same way.
2482 inc(release, identifier) {
2485 this.prerelease.length = 0;
2489 this.inc('pre', identifier);
2493 this.prerelease.length = 0;
2496 this.inc('pre', identifier);
2500 // If this is already a prerelease, it will bump to the next version
2501 // drop any prereleases that might already exist, since they are not
2502 // relevant at this point.
2503 this.prerelease.length = 0;
2504 this.inc('patch', identifier);
2505 this.inc('pre', identifier);
2507 // If the input is a non-prerelease version, this acts the same as
2511 if (this.prerelease.length === 0) {
2512 this.inc('patch', identifier);
2515 this.inc('pre', identifier);
2519 // If this is a pre-major version, bump up to the same major version.
2520 // Otherwise increment major.
2521 // 1.0.0-5 bumps to 1.0.0
2522 // 1.1.0 bumps to 2.0.0
2523 if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
2529 this.prerelease = [];
2533 // If this is a pre-minor version, bump up to the same minor version.
2534 // Otherwise increment minor.
2535 // 1.2.0-5 bumps to 1.2.0
2536 // 1.2.1 bumps to 1.3.0
2537 if (this.patch !== 0 || this.prerelease.length === 0) {
2542 this.prerelease = [];
2546 // If this is not a pre-release version, it will increment the patch.
2547 // If it is a pre-release it will bump up to the same patch version.
2548 // 1.2.0-5 patches to 1.2.0
2549 // 1.2.0 patches to 1.2.1
2550 if (this.prerelease.length === 0) {
2554 this.prerelease = [];
2556 // This probably shouldn't be used publicly.
2557 // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
2560 if (this.prerelease.length === 0) {
2561 this.prerelease = [0];
2563 let i = this.prerelease.length;
2566 if (typeof this.prerelease[i] === 'number') {
2567 this.prerelease[i]++;
2573 // didn't increment anything
2574 this.prerelease.push(0);
2579 // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
2580 // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
2581 if (this.prerelease[0] === identifier) {
2582 if (isNaN(this.prerelease[1])) {
2583 this.prerelease = [identifier, 0];
2586 this.prerelease = [identifier, 0];
2593 throw new Error("invalid increment argument: ".concat(release));
2597 this.raw = this.version;
2603 var semver$1 = SemVer$1;
2605 const SemVer = semver$1;
2607 const compare$2 = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
2609 var compare_1 = compare$2;
2611 const compare$1 = compare_1;
2613 const lt = (a, b, loose) => compare$1(a, b, loose) < 0;
2617 const compare = compare_1;
2619 const gte = (a, b, loose) => compare(a, b, loose) >= 0;
2623 var arrayify$1 = (object, keyName) => Object.entries(object).map(_ref => {
2624 let [key, value] = _ref;
2625 return Object.assign({
2630 var require$$4 = {"version":"2.5.0"};
2632 var lib = {exports: {}};
2634 (function (module, exports) {
2636 Object.defineProperty(exports, "__esModule", {
2639 exports.outdent = void 0; // In the absence of a WeakSet or WeakMap implementation, don't break, but don't cache either.
2644 for (var _i = 0; _i < arguments.length; _i++) {
2645 args[_i] = arguments[_i];
2649 function createWeakMap() {
2650 if (typeof WeakMap !== "undefined") {
2651 return new WeakMap();
2653 return fakeSetOrMap();
2657 * Creates and returns a no-op implementation of a WeakMap / WeakSet that never stores anything.
2661 function fakeSetOrMap() {
2671 } // Safe hasOwnProperty
2674 var hop = Object.prototype.hasOwnProperty;
2676 var has = function (obj, prop) {
2677 return hop.call(obj, prop);
2678 }; // Copy all own enumerable properties from source to target
2681 function extend(target, source) {
2682 for (var prop in source) {
2683 if (has(source, prop)) {
2684 target[prop] = source[prop];
2691 var reLeadingNewline = /^[ \t]*(?:\r\n|\r|\n)/;
2692 var reTrailingNewline = /(?:\r\n|\r|\n)[ \t]*$/;
2693 var reStartsWithNewlineOrIsEmpty = /^(?:[\r\n]|$)/;
2694 var reDetectIndentation = /(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/;
2695 var reOnlyWhitespaceWithAtLeastOneNewline = /^[ \t]*[\r\n][ \t\r\n]*$/;
2697 function _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options) {
2698 // If first interpolated value is a reference to outdent,
2699 // determine indentation level from the indentation of the interpolated value.
2700 var indentationLevel = 0;
2701 var match = strings[0].match(reDetectIndentation);
2704 indentationLevel = match[1].length;
2707 var reSource = "(\\r\\n|\\r|\\n).{0," + indentationLevel + "}";
2708 var reMatchIndent = new RegExp(reSource, "g");
2710 if (firstInterpolatedValueSetsIndentationLevel) {
2711 strings = strings.slice(1);
2714 var newline = options.newline,
2715 trimLeadingNewline = options.trimLeadingNewline,
2716 trimTrailingNewline = options.trimTrailingNewline;
2717 var normalizeNewlines = typeof newline === "string";
2718 var l = strings.length;
2719 var outdentedStrings = strings.map(function (v, i) {
2720 // Remove leading indentation from all lines
2721 v = v.replace(reMatchIndent, "$1"); // Trim a leading newline from the first string
2723 if (i === 0 && trimLeadingNewline) {
2724 v = v.replace(reLeadingNewline, "");
2725 } // Trim a trailing newline from the last string
2728 if (i === l - 1 && trimTrailingNewline) {
2729 v = v.replace(reTrailingNewline, "");
2730 } // Normalize newlines
2733 if (normalizeNewlines) {
2734 v = v.replace(/\r\n|\n|\r/g, function (_) {
2741 return outdentedStrings;
2744 function concatStringsAndValues(strings, values) {
2747 for (var i = 0, l = strings.length; i < l; i++) {
2758 function isTemplateStringsArray(v) {
2759 return has(v, "raw") && has(v, "length");
2762 * It is assumed that opts will not change. If this is a problem, clone your options object and pass the clone to
2769 function createInstance(options) {
2770 /** Cache of pre-processed template literal arrays */
2771 var arrayAutoIndentCache = createWeakMap();
2773 * Cache of pre-processed template literal arrays, where first interpolated value is a reference to outdent,
2774 * before interpolated values are injected.
2777 var arrayFirstInterpSetsIndentCache = createWeakMap();
2779 function outdent(stringsOrOptions) {
2782 for (var _i = 1; _i < arguments.length; _i++) {
2783 values[_i - 1] = arguments[_i];
2785 /* tslint:enable:no-shadowed-variable */
2788 if (isTemplateStringsArray(stringsOrOptions)) {
2789 var strings = stringsOrOptions; // Is first interpolated value a reference to outdent, alone on its own line, without any preceding non-whitespace?
2791 var firstInterpolatedValueSetsIndentationLevel = (values[0] === outdent || values[0] === defaultOutdent) && reOnlyWhitespaceWithAtLeastOneNewline.test(strings[0]) && reStartsWithNewlineOrIsEmpty.test(strings[1]); // Perform outdentation
2793 var cache = firstInterpolatedValueSetsIndentationLevel ? arrayFirstInterpSetsIndentCache : arrayAutoIndentCache;
2794 var renderedArray = cache.get(strings);
2796 if (!renderedArray) {
2797 renderedArray = _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
2798 cache.set(strings, renderedArray);
2800 /** If no interpolated values, skip concatenation step */
2803 if (values.length === 0) {
2804 return renderedArray[0];
2806 /** Concatenate string literals with interpolated values */
2809 var rendered = concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
2812 // Create and return a new instance of outdent with the given options
2813 return createInstance(extend(extend({}, options), stringsOrOptions || {}));
2817 var fullOutdent = extend(outdent, {
2818 string: function (str) {
2819 return _outdentArray([str], false, options)[0];
2825 var defaultOutdent = createInstance({
2826 trimLeadingNewline: true,
2827 trimTrailingNewline: true
2829 exports.outdent = defaultOutdent; // Named exports. Simple and preferred.
2830 // import outdent from 'outdent';
2832 exports.default = defaultOutdent;
2835 // In webpack harmony-modules environments, module.exports is read-only,
2836 // so we fail gracefully.
2838 module.exports = defaultOutdent;
2839 Object.defineProperty(defaultOutdent, "__esModule", {
2842 defaultOutdent.default = defaultOutdent;
2843 defaultOutdent.outdent = defaultOutdent;
2846 })(lib, lib.exports);
2848 var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
2853 const CATEGORY_CONFIG = "Config";
2854 const CATEGORY_EDITOR = "Editor";
2855 const CATEGORY_FORMAT = "Format";
2856 const CATEGORY_OTHER = "Other";
2857 const CATEGORY_OUTPUT = "Output";
2858 const CATEGORY_GLOBAL = "Global";
2859 const CATEGORY_SPECIAL = "Special";
2861 * @typedef {Object} OptionInfo
2862 * @property {string} [since] - available since version
2863 * @property {string} category
2864 * @property {'int' | 'boolean' | 'choice' | 'path'} type
2865 * @property {boolean} [array] - indicate it's an array of the specified type
2866 * @property {OptionValueInfo} [default]
2867 * @property {OptionRangeInfo} [range] - for type int
2868 * @property {string} description
2869 * @property {string} [deprecated] - deprecated since version
2870 * @property {OptionRedirectInfo} [redirect] - redirect deprecated option
2871 * @property {(value: any) => boolean} [exception]
2872 * @property {OptionChoiceInfo[]} [choices] - for type choice
2873 * @property {string} [cliName]
2874 * @property {string} [cliCategory]
2875 * @property {string} [cliDescription]
2877 * @typedef {number | boolean | string} OptionValue
2878 * @typedef {OptionValue | [{ value: OptionValue[] }] | Array<{ since: string, value: OptionValue}>} OptionValueInfo
2880 * @typedef {Object} OptionRedirectInfo
2881 * @property {string} option
2882 * @property {OptionValue} value
2884 * @typedef {Object} OptionRangeInfo
2885 * @property {number} start - recommended range start
2886 * @property {number} end - recommended range end
2887 * @property {number} step - recommended range step
2889 * @typedef {Object} OptionChoiceInfo
2890 * @property {boolean | string} value - boolean for the option that is originally boolean type
2891 * @property {string} description
2892 * @property {string} [since] - undefined if available since the first version of the option
2893 * @property {string} [deprecated] - deprecated since version
2894 * @property {OptionValueInfo} [redirect] - redirect deprecated value
2897 /** @type {{ [name: string]: OptionInfo }} */
2902 category: CATEGORY_SPECIAL,
2907 end: Number.POSITIVE_INFINITY,
2910 description: outdent(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n Print (to stderr) where a cursor at the given position would move to after formatting.\n This option cannot be used with --range-start and --range-end.\n "]))),
2911 cliCategory: CATEGORY_EDITOR
2915 category: CATEGORY_GLOBAL,
2924 description: "Which end of line characters to apply.",
2927 description: "Line Feed only (\\n), common on Linux and macOS as well as inside git repos"
2930 description: "Carriage Return + Line Feed characters (\\r\\n), common on Windows"
2933 description: "Carriage Return character only (\\r), used very rarely"
2936 description: outdent(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n Maintain existing\n (mixed values within one file are normalised by looking at what's used after the first line)\n "])))
2941 category: CATEGORY_SPECIAL,
2943 description: "Specify the input filepath. This will be used to do parser inference.",
2944 cliName: "stdin-filepath",
2945 cliCategory: CATEGORY_OTHER,
2946 cliDescription: "Path to the file to pretend that stdin comes from."
2950 category: CATEGORY_SPECIAL,
2953 description: "Insert @format pragma into file's first docblock comment.",
2954 cliCategory: CATEGORY_OTHER
2958 category: CATEGORY_GLOBAL,
2967 description: "Which parser to use.",
2968 exception: value => typeof value === "string" || typeof value === "function",
2975 description: "JavaScript"
2977 value: "babel-flow",
2983 description: "TypeScript"
2985 value: "typescript",
2987 description: "TypeScript"
2991 description: "JavaScript"
2995 description: "JavaScript"
3015 description: "JSON5"
3017 value: "json-stringify",
3019 description: "JSON.stringify"
3023 description: "GraphQL"
3027 description: "Markdown"
3043 description: "Ember / Handlebars"
3051 description: "Angular"
3055 description: "Lightning Web Components"
3065 category: CATEGORY_GLOBAL,
3066 description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",
3067 exception: value => typeof value === "string" || typeof value === "object",
3069 cliCategory: CATEGORY_CONFIG
3078 category: CATEGORY_GLOBAL,
3079 description: outdent(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n Custom directory that contains prettier plugins in node_modules subdirectory.\n Overrides default behavior when plugins are searched relatively to the location of Prettier.\n Multiple values are accepted.\n "]))),
3080 exception: value => typeof value === "string" || typeof value === "object",
3081 cliName: "plugin-search-dir",
3082 cliCategory: CATEGORY_CONFIG
3086 category: CATEGORY_GLOBAL,
3089 description: "The line length where Prettier will try wrap.",
3092 end: Number.POSITIVE_INFINITY,
3098 category: CATEGORY_SPECIAL,
3100 default: Number.POSITIVE_INFINITY,
3103 end: Number.POSITIVE_INFINITY,
3106 description: outdent(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n Format code ending at a given character offset (exclusive).\n The range will extend forwards to the end of the selected statement.\n This option cannot be used with --cursor-offset.\n "]))),
3107 cliCategory: CATEGORY_EDITOR
3111 category: CATEGORY_SPECIAL,
3116 end: Number.POSITIVE_INFINITY,
3119 description: outdent(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n Format code starting at a given character offset.\n The range will extend backwards to the start of the first line containing the selected statement.\n This option cannot be used with --cursor-offset.\n "]))),
3120 cliCategory: CATEGORY_EDITOR
3124 category: CATEGORY_SPECIAL,
3127 description: outdent(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n Require either '@prettier' or '@format' to be present in the file's first docblock comment\n in order for it to be formatted.\n "]))),
3128 cliCategory: CATEGORY_OTHER
3132 category: CATEGORY_GLOBAL,
3134 description: "Number of spaces per indentation level.",
3137 end: Number.POSITIVE_INFINITY,
3143 category: CATEGORY_GLOBAL,
3146 description: "Indent with tabs instead of spaces."
3148 embeddedLanguageFormatting: {
3150 category: CATEGORY_GLOBAL,
3156 description: "Control how Prettier formats quoted code embedded in the file.",
3159 description: "Format embedded code if Prettier can automatically identify it."
3162 description: "Never automatically format embedded code."
3166 var coreOptions$1 = {
3177 const _excluded = ["cliName", "cliCategory", "cliDescription"];
3184 const arrayify = arrayify$1;
3185 const currentVersion = require$$4.version;
3186 const coreOptions = coreOptions$1.options;
3188 * Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version
3189 * of this function created by `withPlugins`. Don't pass them here directly.
3190 * @param {object} param0
3191 * @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`.
3192 * @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`.
3193 * @param {boolean=} param0.showUnreleased
3194 * @param {boolean=} param0.showDeprecated
3195 * @param {boolean=} param0.showInternal
3198 function getSupportInfo$1() {
3201 showUnreleased = false,
3202 showDeprecated = false,
3203 showInternal = false
3204 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3205 // pre-release version is smaller than the normal version in semver,
3206 // we need to treat it as the normal one so as to test new features.
3207 const version = currentVersion.split("-", 1)[0];
3208 const languages = plugins.flatMap(plugin => plugin.languages || []).filter(filterSince);
3209 const options = arrayify(Object.assign({}, ...plugins.map(_ref => {
3214 }), coreOptions), "name").filter(option => filterSince(option) && filterDeprecated(option)).sort((a, b) => a.name === b.name ? 0 : a.name < b.name ? -1 : 1).map(mapInternal).map(option => {
3215 option = Object.assign({}, option);
3217 if (Array.isArray(option.default)) {
3218 option.default = option.default.length === 1 ? option.default[0].value : option.default.filter(filterSince).sort((info1, info2) => semver.compare(info2.since, info1.since))[0].value;
3221 if (Array.isArray(option.choices)) {
3222 option.choices = option.choices.filter(option => filterSince(option) && filterDeprecated(option));
3224 if (option.name === "parser") {
3225 collectParsersFromLanguages(option, languages, plugins);
3229 const pluginDefaults = Object.fromEntries(plugins.filter(plugin => plugin.defaultOptions && plugin.defaultOptions[option.name] !== undefined).map(plugin => [plugin.name, plugin.defaultOptions[option.name]]));
3230 return Object.assign(Object.assign({}, option), {}, {
3239 function filterSince(object) {
3240 return showUnreleased || !("since" in object) || object.since && semver.gte(version, object.since);
3243 function filterDeprecated(object) {
3244 return showDeprecated || !("deprecated" in object) || object.deprecated && semver.lt(version, object.deprecated);
3247 function mapInternal(object) {
3252 const newObject = _objectWithoutProperties(object, _excluded);
3258 function collectParsersFromLanguages(option, languages, plugins) {
3259 const existingValues = new Set(option.choices.map(choice => choice.value));
3261 for (const language of languages) {
3262 if (language.parsers) {
3263 for (const value of language.parsers) {
3264 if (!existingValues.has(value)) {
3265 existingValues.add(value);
3266 const plugin = plugins.find(plugin => plugin.parsers && plugin.parsers[value]);
3267 let description = language.name;
3269 if (plugin && plugin.name) {
3270 description += " (plugin: ".concat(plugin.name, ")");
3273 option.choices.push({
3284 getSupportInfo: getSupportInfo$1
3287 const stringWidth = stringWidth$2.exports;
3288 const escapeStringRegexp = escapeStringRegexp$1;
3289 const getLast$2 = getLast_1;
3293 const notAsciiRegex = /[^\x20-\x7F]/;
3295 const getPenultimate = arr => arr[arr.length - 2];
3297 * @typedef {{backwards?: boolean}} SkipOptions
3301 * @param {string | RegExp} chars
3302 * @returns {(text: string, index: number | false, opts?: SkipOptions) => number | false}
3306 function skip(chars) {
3307 return (text, index, opts) => {
3308 const backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
3309 // to check for failures (did someone say monads?).
3311 /* istanbul ignore next */
3313 if (index === false) {
3322 while (cursor >= 0 && cursor < length) {
3323 const c = text.charAt(cursor);
3325 if (chars instanceof RegExp) {
3326 if (!chars.test(c)) {
3329 } else if (!chars.includes(c)) {
3333 backwards ? cursor-- : cursor++;
3336 if (cursor === -1 || cursor === length) {
3337 // If we reached the beginning or end of the file, return the
3338 // out-of-bounds cursor. It's up to the caller to handle this
3339 // correctly. We don't want to indicate `false` though if it
3340 // actually skipped valid characters.
3348 * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
3352 const skipWhitespace = skip(/\s/);
3354 * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
3357 const skipSpaces = skip(" \t");
3359 * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
3362 const skipToLineEnd = skip(",; \t");
3364 * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
3367 const skipEverythingButNewLine = skip(/[^\n\r]/);
3369 * @param {string} text
3370 * @param {number | false} index
3371 * @returns {number | false}
3374 function skipInlineComment(text, index) {
3375 /* istanbul ignore next */
3376 if (index === false) {
3380 if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") {
3381 for (let i = index + 2; i < text.length; ++i) {
3382 if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
3391 * @param {string} text
3392 * @param {number | false} index
3393 * @returns {number | false}
3397 function skipTrailingComment(text, index) {
3398 /* istanbul ignore next */
3399 if (index === false) {
3403 if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") {
3404 return skipEverythingButNewLine(text, index);
3408 } // This one doesn't use the above helper function because it wants to
3409 // test \r\n in order and `skip` doesn't support ordering and we only
3410 // want to skip one newline. It's simple to implement.
3413 * @param {string} text
3414 * @param {number | false} index
3415 * @param {SkipOptions=} opts
3416 * @returns {number | false}
3420 function skipNewline(text, index, opts) {
3421 const backwards = opts && opts.backwards;
3423 if (index === false) {
3427 const atIndex = text.charAt(index);
3430 // We already replace `\r\n` with `\n` before parsing
3432 /* istanbul ignore next */
3433 if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
3437 if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
3441 // We already replace `\r\n` with `\n` before parsing
3443 /* istanbul ignore next */
3444 if (atIndex === "\r" && text.charAt(index + 1) === "\n") {
3448 if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
3456 * @param {string} text
3457 * @param {number} index
3458 * @param {SkipOptions=} opts
3459 * @returns {boolean}
3463 function hasNewline(text, index) {
3464 let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3465 const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
3466 const idx2 = skipNewline(text, idx, opts);
3467 return idx !== idx2;
3470 * @param {string} text
3471 * @param {number} start
3472 * @param {number} end
3473 * @returns {boolean}
3477 function hasNewlineInRange(text, start, end) {
3478 for (let i = start; i < end; ++i) {
3479 if (text.charAt(i) === "\n") {
3485 } // Note: this function doesn't ignore leading comments unlike isNextLineEmpty
3489 * @param {string} text
3491 * @param {(node: N) => number} locStart
3495 function isPreviousLineEmpty(text, node, locStart) {
3496 /** @type {number | false} */
3497 let idx = locStart(node) - 1;
3498 idx = skipSpaces(text, idx, {
3501 idx = skipNewline(text, idx, {
3504 idx = skipSpaces(text, idx, {
3507 const idx2 = skipNewline(text, idx, {
3510 return idx !== idx2;
3513 * @param {string} text
3514 * @param {number} index
3515 * @returns {boolean}
3519 function isNextLineEmptyAfterIndex(text, index) {
3520 /** @type {number | false} */
3522 /** @type {number | false} */
3526 while (idx !== oldIdx) {
3527 // We need to skip all the potential trailing inline comments
3529 idx = skipToLineEnd(text, idx);
3530 idx = skipInlineComment(text, idx);
3531 idx = skipSpaces(text, idx);
3534 idx = skipTrailingComment(text, idx);
3535 idx = skipNewline(text, idx);
3536 return idx !== false && hasNewline(text, idx);
3540 * @param {string} text
3542 * @param {(node: N) => number} locEnd
3543 * @returns {boolean}
3547 function isNextLineEmpty(text, node, locEnd) {
3548 return isNextLineEmptyAfterIndex(text, locEnd(node));
3551 * @param {string} text
3552 * @param {number} idx
3553 * @returns {number | false}
3557 function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) {
3558 /** @type {number | false} */
3560 /** @type {number | false} */
3564 while (nextIdx !== oldIdx) {
3566 nextIdx = skipSpaces(text, nextIdx);
3567 nextIdx = skipInlineComment(text, nextIdx);
3568 nextIdx = skipTrailingComment(text, nextIdx);
3569 nextIdx = skipNewline(text, nextIdx);
3576 * @param {string} text
3578 * @param {(node: N) => number} locEnd
3579 * @returns {number | false}
3583 function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
3584 return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd(node));
3588 * @param {string} text
3590 * @param {(node: N) => number} locEnd
3595 function getNextNonSpaceNonCommentCharacter(text, node, locEnd) {
3596 return text.charAt( // @ts-expect-error => TBD: can return false, should we define a fallback?
3597 getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd));
3598 } // Not using, but it's public utils
3600 /* istanbul ignore next */
3603 * @param {string} text
3604 * @param {number} index
3605 * @param {SkipOptions=} opts
3606 * @returns {boolean}
3610 function hasSpaces(text, index) {
3611 let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3612 const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
3613 return idx !== index;
3616 * @param {string} value
3617 * @param {number} tabWidth
3618 * @param {number=} startIndex
3623 function getAlignmentSize(value, tabWidth) {
3624 let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
3627 for (let i = startIndex; i < value.length; ++i) {
3628 if (value[i] === "\t") {
3629 // Tabs behave in a way that they are aligned to the nearest
3630 // multiple of tabWidth:
3631 // 0 -> 4, 1 -> 4, 2 -> 4, 3 -> 4
3632 // 4 -> 8, 5 -> 8, 6 -> 8, 7 -> 8 ...
3633 size = size + tabWidth - size % tabWidth;
3642 * @param {string} value
3643 * @param {number} tabWidth
3648 function getIndentSize(value, tabWidth) {
3649 const lastNewlineIndex = value.lastIndexOf("\n");
3651 if (lastNewlineIndex === -1) {
3655 return getAlignmentSize( // All the leading whitespaces
3656 value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0], tabWidth);
3659 * @typedef {'"' | "'"} Quote
3664 * @param {string} rawContent
3665 * @param {Quote} preferredQuote
3666 * @returns {{ quote: Quote, regex: RegExp, escaped: string }}
3670 function getPreferredQuote(rawContent, preferredQuote) {
3671 /** @type {{ quote: '"', regex: RegExp, escaped: """ }} */
3677 /** @type {{ quote: "'", regex: RegExp, escaped: "'" }} */
3684 const preferred = preferredQuote === "'" ? single : double;
3685 const alternate = preferred === single ? double : single;
3686 let result = preferred; // If `rawContent` contains at least one of the quote preferred for enclosing
3687 // the string, we might want to enclose with the alternate quote instead, to
3688 // minimize the number of escaped quotes.
3690 if (rawContent.includes(preferred.quote) || rawContent.includes(alternate.quote)) {
3691 const numPreferredQuotes = (rawContent.match(preferred.regex) || []).length;
3692 const numAlternateQuotes = (rawContent.match(alternate.regex) || []).length;
3693 result = numPreferredQuotes > numAlternateQuotes ? alternate : preferred;
3699 function printString(raw, options) {
3700 // `rawContent` is the string exactly like it appeared in the input source
3701 // code, without its enclosing quotes.
3702 const rawContent = raw.slice(1, -1);
3703 /** @type {Quote} */
3705 const enclosingQuote = options.parser === "json" || options.parser === "json5" && options.quoteProps === "preserve" && !options.singleQuote ? '"' : options.__isInHtmlAttribute ? "'" : getPreferredQuote(rawContent, options.singleQuote ? "'" : '"').quote; // It might sound unnecessary to use `makeString` even if the string already
3706 // is enclosed with `enclosingQuote`, but it isn't. The string could contain
3707 // unnecessary escapes (such as in `"\'"`). Always using `makeString` makes
3708 // sure that we consistently output the minimum amount of escaped quotes.
3710 return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.__embeddedInHtml));
3713 * @param {string} rawContent
3714 * @param {Quote} enclosingQuote
3715 * @param {boolean=} unescapeUnnecessaryEscapes
3720 function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
3721 const otherQuote = enclosingQuote === '"' ? "'" : '"'; // Matches _any_ escape and unescaped quotes (both single and double).
3723 const regex = /\\(.)|(["'])/gs; // Escape and unescape single and double quotes as needed to be able to
3724 // enclose `rawContent` with `enclosingQuote`.
3726 const newContent = rawContent.replace(regex, (match, escaped, quote) => {
3727 // If we matched an escape, and the escaped character is a quote of the
3728 // other type than we intend to enclose the string with, there's no need for
3729 // it to be escaped, so return it _without_ the backslash.
3730 if (escaped === otherQuote) {
3732 } // If we matched an unescaped quote and it is of the _same_ type as we
3733 // intend to enclose the string with, it must be escaped, so return it with
3737 if (quote === enclosingQuote) {
3738 return "\\" + quote;
3743 } // Unescape any unnecessarily escaped character.
3744 // Adapted from https://github.com/eslint/eslint/blob/de0b4ad7bd820ade41b1f606008bea68683dc11a/lib/rules/no-useless-escape.js#L27
3747 return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped;
3749 return enclosingQuote + newContent + enclosingQuote;
3752 function printNumber(rawNumber) {
3753 return rawNumber.toLowerCase() // Remove unnecessary plus and zeroes from scientific notation.
3754 .replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/, "$1$2$3") // Remove unnecessary scientific notation (1e0).
3755 .replace(/^([+-]?[\d.]+)e[+-]?0+$/, "$1") // Make sure numbers always start with a digit.
3756 .replace(/^([+-])?\./, "$10.") // Remove extraneous trailing decimal zeroes.
3757 .replace(/(\.\d+?)0+(?=e|$)/, "$1") // Remove trailing dot.
3758 .replace(/\.(?=e|$)/, "");
3761 * @param {string} str
3762 * @param {string} target
3767 function getMaxContinuousCount(str, target) {
3768 const results = str.match(new RegExp("(".concat(escapeStringRegexp(target), ")+"), "g"));
3770 if (results === null) {
3774 return results.reduce((maxCount, result) => Math.max(maxCount, result.length / target.length), 0);
3777 function getMinNotPresentContinuousCount(str, target) {
3778 const matches = str.match(new RegExp("(".concat(escapeStringRegexp(target), ")+"), "g"));
3780 if (matches === null) {
3784 const countPresent = new Map();
3787 for (const match of matches) {
3788 const count = match.length / target.length;
3789 countPresent.set(count, true);
3796 for (let i = 1; i < max; i++) {
3797 if (!countPresent.get(i)) {
3805 * @param {string} text
3810 function getStringWidth$1(text) {
3813 } // shortcut to avoid needless string `RegExp`s, replacements, and allocations within `string-width`
3816 if (!notAsciiRegex.test(text)) {
3820 return stringWidth(text);
3823 function addCommentHelper(node, comment) {
3824 const comments = node.comments || (node.comments = []);
3825 comments.push(comment);
3826 comment.printed = false;
3827 comment.nodeDescription = describeNodeForDebugging(node);
3830 function addLeadingComment(node, comment) {
3831 comment.leading = true;
3832 comment.trailing = false;
3833 addCommentHelper(node, comment);
3836 function addDanglingComment(node, comment, marker) {
3837 comment.leading = false;
3838 comment.trailing = false;
3841 comment.marker = marker;
3844 addCommentHelper(node, comment);
3847 function addTrailingComment(node, comment) {
3848 comment.leading = false;
3849 comment.trailing = true;
3850 addCommentHelper(node, comment);
3853 function inferParserByLanguage(language, options) {
3856 } = getSupportInfo({
3857 plugins: options.plugins
3859 const matched = languages.find(_ref => {
3863 return name.toLowerCase() === language;
3864 }) || languages.find(_ref2 => {
3868 return Array.isArray(aliases) && aliases.includes(language);
3869 }) || languages.find(_ref3 => {
3873 return Array.isArray(extensions) && extensions.includes(".".concat(language));
3875 return matched && matched.parsers[0];
3878 function isFrontMatterNode(node) {
3879 return node && node.type === "front-matter";
3882 function getShebang(text) {
3883 if (!text.startsWith("#!")) {
3887 const index = text.indexOf("\n");
3893 return text.slice(0, index);
3896 * @param {any} object
3897 * @returns {object is Array<any>}
3901 function isNonEmptyArray(object) {
3902 return Array.isArray(object) && object.length > 0;
3905 * @param {string} description
3906 * @returns {(node: any) => symbol}
3910 function createGroupIdMapper(description) {
3911 const groupIds = new WeakMap();
3912 return function (node) {
3913 if (!groupIds.has(node)) {
3914 groupIds.set(node, Symbol(description));
3917 return groupIds.get(node);
3921 function describeNodeForDebugging(node) {
3922 const nodeType = node.type || node.kind || "(unknown type)";
3923 let nodeName = String(node.name || node.id && (typeof node.id === "object" ? node.id.name : node.id) || node.key && (typeof node.key === "object" ? node.key.name : node.key) || node.value && (typeof node.value === "object" ? "" : String(node.value)) || node.operator || "");
3925 if (nodeName.length > 20) {
3926 nodeName = nodeName.slice(0, 19) + "…";
3929 return nodeType + (nodeName ? " " + nodeName : "");
3933 inferParserByLanguage,
3934 getStringWidth: getStringWidth$1,
3935 getMaxContinuousCount,
3936 getMinNotPresentContinuousCount,
3939 getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
3940 getNextNonSpaceNonCommentCharacterIndex,
3941 getNextNonSpaceNonCommentCharacter,
3946 skipEverythingButNewLine,
3948 skipTrailingComment,
3950 isNextLineEmptyAfterIndex,
3952 isPreviousLineEmpty,
3971 function guessEndOfLine(text) {
3972 const index = text.indexOf("\r");
3975 return text.charAt(index + 1) === "\n" ? "crlf" : "cr";
3981 function convertEndOfLineToChars$1(value) {
3994 function countEndOfLineChars(text, eol) {
3996 /* istanbul ignore else */
4000 } else if (eol === "\r") {
4002 } else if (eol === "\r\n") {
4005 throw new Error("Unexpected \"eol\" ".concat(JSON.stringify(eol), "."));
4008 const endOfLines = text.match(regex);
4009 return endOfLines ? endOfLines.length : 0;
4012 function normalizeEndOfLine(text) {
4013 return text.replace(/\r\n?/g, "\n");
4018 convertEndOfLineToChars: convertEndOfLineToChars$1,
4019 countEndOfLineChars,
4023 const getLast$1 = getLast_1;
4029 const isConcat$2 = doc => Array.isArray(doc) || doc && doc.type === "concat";
4031 const getDocParts$2 = doc => {
4032 if (Array.isArray(doc)) {
4035 /* istanbul ignore next */
4038 if (doc.type !== "concat" && doc.type !== "fill") {
4039 throw new Error("Expect doc type to be `concat` or `fill`.");
4043 }; // Using a unique object to compare by reference.
4046 const traverseDocOnExitStackMarker = {};
4048 function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
4049 const docsStack = [doc];
4051 while (docsStack.length > 0) {
4052 const doc = docsStack.pop();
4054 if (doc === traverseDocOnExitStackMarker) {
4055 onExit(docsStack.pop());
4060 docsStack.push(doc, traverseDocOnExitStackMarker);
4063 if ( // Should Recurse
4064 !onEnter || onEnter(doc) !== false) {
4065 // When there are multiple parts to process,
4066 // the parts need to be pushed onto the stack in reverse order,
4067 // so that they are processed in the original order
4068 // when the stack is popped.
4069 if (isConcat$2(doc) || doc.type === "fill") {
4070 const parts = getDocParts$2(doc);
4072 for (let ic = parts.length, i = ic - 1; i >= 0; --i) {
4073 docsStack.push(parts[i]);
4075 } else if (doc.type === "if-break") {
4076 if (doc.flatContents) {
4077 docsStack.push(doc.flatContents);
4080 if (doc.breakContents) {
4081 docsStack.push(doc.breakContents);
4083 } else if (doc.type === "group" && doc.expandedStates) {
4084 if (shouldTraverseConditionalGroups) {
4085 for (let ic = doc.expandedStates.length, i = ic - 1; i >= 0; --i) {
4086 docsStack.push(doc.expandedStates[i]);
4089 docsStack.push(doc.contents);
4091 } else if (doc.contents) {
4092 docsStack.push(doc.contents);
4098 function mapDoc(doc, cb) {
4099 // Within a doc tree, the same subtrees can be found multiple times.
4100 // E.g., often this happens in conditional groups.
4101 // As an optimization (those subtrees can be huge) and to maintain the
4102 // reference structure of the tree, the mapping results are cached in
4103 // a map and reused.
4104 const mapped = new Map();
4108 if (mapped.has(doc)) {
4109 return mapped.get(doc);
4112 const result = process(doc);
4113 mapped.set(doc, result);
4117 function process(doc) {
4118 if (Array.isArray(doc)) {
4119 return cb(doc.map(rec));
4122 if (doc.type === "concat" || doc.type === "fill") {
4123 const parts = doc.parts.map(rec);
4124 return cb(Object.assign(Object.assign({}, doc), {}, {
4129 if (doc.type === "if-break") {
4130 const breakContents = doc.breakContents && rec(doc.breakContents);
4131 const flatContents = doc.flatContents && rec(doc.flatContents);
4132 return cb(Object.assign(Object.assign({}, doc), {}, {
4138 if (doc.type === "group" && doc.expandedStates) {
4139 const expandedStates = doc.expandedStates.map(rec);
4140 const contents = expandedStates[0];
4141 return cb(Object.assign(Object.assign({}, doc), {}, {
4148 const contents = rec(doc.contents);
4149 return cb(Object.assign(Object.assign({}, doc), {}, {
4158 function findInDoc(doc, fn, defaultValue) {
4159 let result = defaultValue;
4160 let hasStopped = false;
4162 function findInDocOnEnterFn(doc) {
4163 const maybeResult = fn(doc);
4165 if (maybeResult !== undefined) {
4167 result = maybeResult;
4175 traverseDoc(doc, findInDocOnEnterFn);
4179 function willBreakFn(doc) {
4180 if (doc.type === "group" && doc.break) {
4184 if (doc.type === "line" && doc.hard) {
4188 if (doc.type === "break-parent") {
4193 function willBreak(doc) {
4194 return findInDoc(doc, willBreakFn, false);
4197 function breakParentGroup(groupStack) {
4198 if (groupStack.length > 0) {
4199 const parentGroup = getLast$1(groupStack); // Breaks are not propagated through conditional groups because
4200 // the user is expected to manually handle what breaks.
4202 if (!parentGroup.expandedStates && !parentGroup.break) {
4203 // An alternative truthy value allows to distinguish propagated group breaks
4204 // and not to print them as `group(..., { break: true })` in `--debug-print-doc`.
4205 parentGroup.break = "propagated";
4212 function propagateBreaks(doc) {
4213 const alreadyVisitedSet = new Set();
4214 const groupStack = [];
4216 function propagateBreaksOnEnterFn(doc) {
4217 if (doc.type === "break-parent") {
4218 breakParentGroup(groupStack);
4221 if (doc.type === "group") {
4222 groupStack.push(doc);
4224 if (alreadyVisitedSet.has(doc)) {
4228 alreadyVisitedSet.add(doc);
4232 function propagateBreaksOnExitFn(doc) {
4233 if (doc.type === "group") {
4234 const group = groupStack.pop();
4237 breakParentGroup(groupStack);
4242 traverseDoc(doc, propagateBreaksOnEnterFn, propagateBreaksOnExitFn,
4243 /* shouldTraverseConditionalGroups */
4247 function removeLinesFn(doc) {
4248 // Force this doc into flat mode by statically converting all
4249 // lines into spaces (or soft lines into nothing). Hard lines
4250 // should still output because there's too great of a chance
4251 // of breaking existing assumptions otherwise.
4252 if (doc.type === "line" && !doc.hard) {
4253 return doc.soft ? "" : " ";
4256 if (doc.type === "if-break") {
4257 return doc.flatContents || "";
4263 function removeLines(doc) {
4264 return mapDoc(doc, removeLinesFn);
4267 const isHardline = (doc, nextDoc) => doc && doc.type === "line" && doc.hard && nextDoc && nextDoc.type === "break-parent";
4269 function stripDocTrailingHardlineFromDoc(doc) {
4274 if (isConcat$2(doc) || doc.type === "fill") {
4275 const parts = getDocParts$2(doc);
4277 while (parts.length > 1 && isHardline(...parts.slice(-2))) {
4281 if (parts.length > 0) {
4282 const lastPart = stripDocTrailingHardlineFromDoc(getLast$1(parts));
4283 parts[parts.length - 1] = lastPart;
4286 return Array.isArray(doc) ? parts : Object.assign(Object.assign({}, doc), {}, {
4294 case "indent-if-break":
4299 const contents = stripDocTrailingHardlineFromDoc(doc.contents);
4300 return Object.assign(Object.assign({}, doc), {}, {
4307 const breakContents = stripDocTrailingHardlineFromDoc(doc.breakContents);
4308 const flatContents = stripDocTrailingHardlineFromDoc(doc.flatContents);
4309 return Object.assign(Object.assign({}, doc), {}, {
4319 function stripTrailingHardline(doc) {
4320 // HACK remove ending hardline, original PR: #1984
4321 return stripDocTrailingHardlineFromDoc(cleanDoc(doc));
4324 function cleanDocFn(doc) {
4327 if (doc.parts.every(part => part === "")) {
4334 if (!doc.contents && !doc.id && !doc.break && !doc.expandedStates) {
4336 } // Remove nested only group
4339 if (doc.contents.type === "group" && doc.contents.id === doc.id && doc.contents.break === doc.break && doc.contents.expandedStates === doc.expandedStates) {
4340 return doc.contents;
4347 case "indent-if-break":
4349 if (!doc.contents) {
4356 if (!doc.flatContents && !doc.breakContents) {
4363 if (!isConcat$2(doc)) {
4369 for (const part of getDocParts$2(doc)) {
4374 const [currentPart, ...restParts] = isConcat$2(part) ? getDocParts$2(part) : [part];
4376 if (typeof currentPart === "string" && typeof getLast$1(parts) === "string") {
4377 parts[parts.length - 1] += currentPart;
4379 parts.push(currentPart);
4382 parts.push(...restParts);
4385 if (parts.length === 0) {
4389 if (parts.length === 1) {
4393 return Array.isArray(doc) ? parts : Object.assign(Object.assign({}, doc), {}, {
4396 } // A safer version of `normalizeDoc`
4397 // - `normalizeDoc` concat strings and flat "concat" in `fill`, while `cleanDoc` don't
4398 // - On `concat` object, `normalizeDoc` always return object with `parts`, `cleanDoc` may return strings
4399 // - `cleanDoc` also remove nested `group`s and empty `fill`/`align`/`indent`/`line-suffix`/`if-break` if possible
4402 function cleanDoc(doc) {
4403 return mapDoc(doc, currentDoc => cleanDocFn(currentDoc));
4406 function normalizeParts(parts) {
4407 const newParts = [];
4408 const restParts = parts.filter(Boolean);
4410 while (restParts.length > 0) {
4411 const part = restParts.shift();
4417 if (isConcat$2(part)) {
4418 restParts.unshift(...getDocParts$2(part));
4422 if (newParts.length > 0 && typeof getLast$1(newParts) === "string" && typeof part === "string") {
4423 newParts[newParts.length - 1] += part;
4427 newParts.push(part);
4433 function normalizeDoc(doc) {
4434 return mapDoc(doc, currentDoc => {
4435 if (Array.isArray(currentDoc)) {
4436 return normalizeParts(currentDoc);
4439 if (!currentDoc.parts) {
4443 return Object.assign(Object.assign({}, currentDoc), {}, {
4444 parts: normalizeParts(currentDoc.parts)
4449 function replaceEndOfLine(doc) {
4450 return mapDoc(doc, currentDoc => typeof currentDoc === "string" && currentDoc.includes("\n") ? replaceTextEndOfLine(currentDoc) : currentDoc);
4451 } // This function need return array
4452 // TODO: remove `.parts` when we remove `docBuilders.concat()`
4455 function replaceTextEndOfLine(text) {
4456 let replacement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : literalline;
4457 return join(replacement, text.split("\n")).parts;
4460 function canBreakFn(doc) {
4461 if (doc.type === "line") {
4466 function canBreak(doc) {
4467 return findInDoc(doc, canBreakFn, false);
4471 isConcat: isConcat$2,
4472 getDocParts: getDocParts$2,
4479 stripTrailingHardline,
4483 replaceTextEndOfLine,
4493 convertEndOfLineToChars
4501 isConcat: isConcat$1,
4502 getDocParts: getDocParts$1
4504 /** @type {Record<symbol, typeof MODE_BREAK | typeof MODE_FLAT>} */
4507 const MODE_BREAK = 1;
4508 const MODE_FLAT = 2;
4510 function rootIndent() {
4518 function makeIndent(ind, options) {
4519 return generateInd(ind, {
4524 function makeAlign(indent, widthOrDoc, options) {
4525 if (widthOrDoc === Number.NEGATIVE_INFINITY) {
4526 return indent.root || rootIndent();
4529 if (widthOrDoc < 0) {
4530 return generateInd(indent, {
4539 if (widthOrDoc.type === "root") {
4540 return Object.assign(Object.assign({}, indent), {}, {
4545 const alignType = typeof widthOrDoc === "string" ? "stringAlign" : "numberAlign";
4546 return generateInd(indent, {
4552 function generateInd(ind, newPart, options) {
4553 const queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : [...ind.queue, newPart];
4559 for (const part of queue) {
4560 switch (part.type) {
4564 if (options.useTabs) {
4567 addSpaces(options.tabWidth);
4575 length += part.n.length;
4580 lastSpaces += part.n;
4583 /* istanbul ignore next */
4586 throw new Error("Unexpected type '".concat(part.type, "'"));
4591 return Object.assign(Object.assign({}, ind), {}, {
4597 function addTabs(count) {
4598 value += "\t".repeat(count);
4599 length += options.tabWidth * count;
4602 function addSpaces(count) {
4603 value += " ".repeat(count);
4608 if (options.useTabs) {
4615 function flushTabs() {
4623 function flushSpaces() {
4624 if (lastSpaces > 0) {
4625 addSpaces(lastSpaces);
4631 function resetLast() {
4637 function trim(out) {
4638 if (out.length === 0) {
4642 let trimCount = 0; // Trim whitespace at the end of line
4644 while (out.length > 0 && typeof getLast(out) === "string" && /^[\t ]*$/.test(getLast(out))) {
4645 trimCount += out.pop().length;
4648 if (out.length > 0 && typeof getLast(out) === "string") {
4649 const trimmed = getLast(out).replace(/[\t ]*$/, "");
4650 trimCount += getLast(out).length - trimmed.length;
4651 out[out.length - 1] = trimmed;
4657 function fits(next, restCommands, width, options, hasLineSuffix, mustBeFlat) {
4658 let restIdx = restCommands.length;
4659 const cmds = [next]; // `out` is only used for width counting because `trim` requires to look
4660 // backwards for space characters.
4664 while (width >= 0) {
4665 if (cmds.length === 0) {
4666 if (restIdx === 0) {
4670 cmds.push(restCommands[restIdx - 1]);
4675 const [ind, mode, doc] = cmds.pop();
4677 if (typeof doc === "string") {
4679 width -= getStringWidth(doc);
4680 } else if (isConcat$1(doc)) {
4681 const parts = getDocParts$1(doc);
4683 for (let i = parts.length - 1; i >= 0; i--) {
4684 cmds.push([ind, mode, parts[i]]);
4689 cmds.push([makeIndent(ind, options), mode, doc.contents]);
4693 cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]);
4702 if (mustBeFlat && doc.break) {
4706 const groupMode = doc.break ? MODE_BREAK : mode;
4707 cmds.push([ind, groupMode, // The most expanded state takes up the least space on the current line.
4708 doc.expandedStates && groupMode === MODE_BREAK ? getLast(doc.expandedStates) : doc.contents]);
4711 groupModeMap[doc.id] = groupMode;
4718 for (let i = doc.parts.length - 1; i >= 0; i--) {
4719 cmds.push([ind, mode, doc.parts[i]]);
4725 case "indent-if-break":
4727 const groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
4729 if (groupMode === MODE_BREAK) {
4730 const breakContents = doc.type === "if-break" ? doc.breakContents : doc.negate ? doc.contents : indent(doc.contents);
4732 if (breakContents) {
4733 cmds.push([ind, mode, breakContents]);
4737 if (groupMode === MODE_FLAT) {
4738 const flatContents = doc.type === "if-break" ? doc.flatContents : doc.negate ? indent(doc.contents) : doc.contents;
4741 cmds.push([ind, mode, flatContents]);
4770 hasLineSuffix = true;
4773 case "line-suffix-boundary":
4774 if (hasLineSuffix) {
4781 cmds.push([ind, mode, doc.contents]);
4790 function printDocToString(doc, options) {
4792 const width = options.printWidth;
4793 const newLine = convertEndOfLineToChars(options.endOfLine);
4794 let pos = 0; // cmds is basically a stack. We've turned a recursive call into a
4795 // while loop which is much faster. The while loop below adds new
4796 // cmds to the array instead of recursively calling `print`.
4798 const cmds = [[rootIndent(), MODE_BREAK, doc]];
4800 let shouldRemeasure = false;
4801 let lineSuffix = [];
4803 while (cmds.length > 0) {
4804 const [ind, mode, doc] = cmds.pop();
4806 if (typeof doc === "string") {
4807 const formatted = newLine !== "\n" ? doc.replace(/\n/g, newLine) : doc;
4808 out.push(formatted);
4809 pos += getStringWidth(formatted);
4810 } else if (isConcat$1(doc)) {
4811 const parts = getDocParts$1(doc);
4813 for (let i = parts.length - 1; i >= 0; i--) {
4814 cmds.push([ind, mode, parts[i]]);
4819 out.push(cursor.placeholder);
4823 cmds.push([makeIndent(ind, options), mode, doc.contents]);
4827 cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]);
4837 if (!shouldRemeasure) {
4838 cmds.push([ind, doc.break ? MODE_BREAK : MODE_FLAT, doc.contents]);
4846 shouldRemeasure = false;
4847 const next = [ind, MODE_FLAT, doc.contents];
4848 const rem = width - pos;
4849 const hasLineSuffix = lineSuffix.length > 0;
4851 if (!doc.break && fits(next, cmds, rem, options, hasLineSuffix)) {
4854 // Expanded states are a rare case where a document
4855 // can manually provide multiple representations of
4856 // itself. It provides an array of documents
4857 // going from the least expanded (most flattened)
4858 // representation first to the most expanded. If a
4859 // group has these, we need to manually go through
4860 // these states and find the first one that fits.
4861 if (doc.expandedStates) {
4862 const mostExpanded = getLast(doc.expandedStates);
4865 cmds.push([ind, MODE_BREAK, mostExpanded]);
4868 for (let i = 1; i < doc.expandedStates.length + 1; i++) {
4869 if (i >= doc.expandedStates.length) {
4870 cmds.push([ind, MODE_BREAK, mostExpanded]);
4873 const state = doc.expandedStates[i];
4874 const cmd = [ind, MODE_FLAT, state];
4876 if (fits(cmd, cmds, rem, options, hasLineSuffix)) {
4884 cmds.push([ind, MODE_BREAK, doc.contents]);
4893 groupModeMap[doc.id] = getLast(cmds)[1];
4897 // Fills each line with as much code as possible before moving to a new
4898 // line with the same indentation.
4900 // Expects doc.parts to be an array of alternating content and
4901 // whitespace. The whitespace contains the linebreaks.
4904 // ["I", line, "love", line, "monkeys"]
4906 // [{ type: group, ... }, softline, { type: group, ... }]
4908 // It uses this parts structure to handle three main layout cases:
4909 // * The first two content items fit on the same line without
4911 // -> output the first content item and the whitespace "flat".
4912 // * Only the first content item fits on the line without breaking
4913 // -> output the first content item "flat" and the whitespace with
4915 // * Neither content item fits on the line without breaking
4916 // -> output the first content item and the whitespace with "break".
4920 const rem = width - pos;
4925 if (parts.length === 0) {
4929 const [content, whitespace] = parts;
4930 const contentFlatCmd = [ind, MODE_FLAT, content];
4931 const contentBreakCmd = [ind, MODE_BREAK, content];
4932 const contentFits = fits(contentFlatCmd, [], rem, options, lineSuffix.length > 0, true);
4934 if (parts.length === 1) {
4936 cmds.push(contentFlatCmd);
4938 cmds.push(contentBreakCmd);
4944 const whitespaceFlatCmd = [ind, MODE_FLAT, whitespace];
4945 const whitespaceBreakCmd = [ind, MODE_BREAK, whitespace];
4947 if (parts.length === 2) {
4949 cmds.push(whitespaceFlatCmd, contentFlatCmd);
4951 cmds.push(whitespaceBreakCmd, contentBreakCmd);
4955 } // At this point we've handled the first pair (context, separator)
4956 // and will create a new fill doc for the rest of the content.
4957 // Ideally we wouldn't mutate the array here but copying all the
4958 // elements to a new array would make this algorithm quadratic,
4959 // which is unusable for large arrays (e.g. large texts in JSX).
4963 const remainingCmd = [ind, mode, fill(parts)];
4964 const secondContent = parts[0];
4965 const firstAndSecondContentFlatCmd = [ind, MODE_FLAT, [content, whitespace, secondContent]];
4966 const firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], rem, options, lineSuffix.length > 0, true);
4968 if (firstAndSecondContentFits) {
4969 cmds.push(remainingCmd, whitespaceFlatCmd, contentFlatCmd);
4970 } else if (contentFits) {
4971 cmds.push(remainingCmd, whitespaceBreakCmd, contentFlatCmd);
4973 cmds.push(remainingCmd, whitespaceBreakCmd, contentBreakCmd);
4980 case "indent-if-break":
4982 const groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
4984 if (groupMode === MODE_BREAK) {
4985 const breakContents = doc.type === "if-break" ? doc.breakContents : doc.negate ? doc.contents : indent(doc.contents);
4987 if (breakContents) {
4988 cmds.push([ind, mode, breakContents]);
4992 if (groupMode === MODE_FLAT) {
4993 const flatContents = doc.type === "if-break" ? doc.flatContents : doc.negate ? indent(doc.contents) : doc.contents;
4996 cmds.push([ind, mode, flatContents]);
5004 lineSuffix.push([ind, mode, doc.contents]);
5007 case "line-suffix-boundary":
5008 if (lineSuffix.length > 0) {
5009 cmds.push([ind, mode, {
5028 // This line was forced into the output even if we
5029 // were in flattened mode, so we need to tell the next
5030 // group that no matter what, it needs to remeasure
5031 // because the previous measurement didn't accurately
5032 // capture the entire expression (this is necessary
5033 // for nested groups)
5034 shouldRemeasure = true;
5040 if (lineSuffix.length > 0) {
5041 cmds.push([ind, mode, doc], ...lineSuffix.reverse());
5048 out.push(newLine, ind.root.value);
5049 pos = ind.root.length;
5056 out.push(newLine + ind.value);
5066 cmds.push([ind, mode, doc.contents]);
5069 } // Flush remaining line-suffix contents at the end of the document, in case
5070 // there is no new line after the line-suffix.
5073 if (cmds.length === 0 && lineSuffix.length > 0) {
5074 cmds.push(...lineSuffix.reverse());
5079 const cursorPlaceholderIndex = out.indexOf(cursor.placeholder);
5081 if (cursorPlaceholderIndex !== -1) {
5082 const otherCursorPlaceholderIndex = out.indexOf(cursor.placeholder, cursorPlaceholderIndex + 1);
5083 const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
5084 const aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
5085 const afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
5087 formatted: beforeCursor + aroundCursor + afterCursor,
5088 cursorNodeStart: beforeCursor.length,
5089 cursorNodeText: aroundCursor
5094 formatted: out.join("")
5107 function flattenDoc(doc) {
5112 if (isConcat(doc)) {
5115 for (const part of getDocParts(doc)) {
5116 if (isConcat(part)) {
5117 res.push(...flattenDoc(part).parts);
5119 const flattened = flattenDoc(part);
5121 if (flattened !== "") {
5122 res.push(flattened);
5133 if (doc.type === "if-break") {
5134 return Object.assign(Object.assign({}, doc), {}, {
5135 breakContents: flattenDoc(doc.breakContents),
5136 flatContents: flattenDoc(doc.flatContents)
5140 if (doc.type === "group") {
5141 return Object.assign(Object.assign({}, doc), {}, {
5142 contents: flattenDoc(doc.contents),
5143 expandedStates: doc.expandedStates && doc.expandedStates.map(flattenDoc)
5147 if (doc.type === "fill") {
5150 parts: doc.parts.map(flattenDoc)
5155 return Object.assign(Object.assign({}, doc), {}, {
5156 contents: flattenDoc(doc.contents)
5163 function printDocToDebug(doc) {
5164 /** @type Record<symbol, string> */
5165 const printedSymbols = Object.create(null);
5166 /** @type Set<string> */
5168 const usedKeysForSymbols = new Set();
5169 return printDoc(flattenDoc(doc));
5171 function printDoc(doc, index, parentParts) {
5172 if (typeof doc === "string") {
5173 return JSON.stringify(doc);
5176 if (isConcat(doc)) {
5177 const printed = getDocParts(doc).map(printDoc).filter(Boolean);
5178 return printed.length === 1 ? printed[0] : "[".concat(printed.join(", "), "]");
5181 if (doc.type === "line") {
5182 const withBreakParent = Array.isArray(parentParts) && parentParts[index + 1] && parentParts[index + 1].type === "break-parent";
5185 return withBreakParent ? "literalline" : "literallineWithoutBreakParent";
5189 return withBreakParent ? "hardline" : "hardlineWithoutBreakParent";
5199 if (doc.type === "break-parent") {
5200 const afterHardline = Array.isArray(parentParts) && parentParts[index - 1] && parentParts[index - 1].type === "line" && parentParts[index - 1].hard;
5201 return afterHardline ? undefined : "breakParent";
5204 if (doc.type === "trim") {
5208 if (doc.type === "indent") {
5209 return "indent(" + printDoc(doc.contents) + ")";
5212 if (doc.type === "align") {
5213 return doc.n === Number.NEGATIVE_INFINITY ? "dedentToRoot(" + printDoc(doc.contents) + ")" : doc.n < 0 ? "dedent(" + printDoc(doc.contents) + ")" : doc.n.type === "root" ? "markAsRoot(" + printDoc(doc.contents) + ")" : "align(" + JSON.stringify(doc.n) + ", " + printDoc(doc.contents) + ")";
5216 if (doc.type === "if-break") {
5217 return "ifBreak(" + printDoc(doc.breakContents) + (doc.flatContents ? ", " + printDoc(doc.flatContents) : "") + (doc.groupId ? (!doc.flatContents ? ', ""' : "") + ", { groupId: ".concat(printGroupId(doc.groupId), " }") : "") + ")";
5220 if (doc.type === "indent-if-break") {
5221 const optionsParts = [];
5224 optionsParts.push("negate: true");
5228 optionsParts.push("groupId: ".concat(printGroupId(doc.groupId)));
5231 const options = optionsParts.length > 0 ? ", { ".concat(optionsParts.join(", "), " }") : "";
5232 return "indentIfBreak(".concat(printDoc(doc.contents)).concat(options, ")");
5235 if (doc.type === "group") {
5236 const optionsParts = [];
5238 if (doc.break && doc.break !== "propagated") {
5239 optionsParts.push("shouldBreak: true");
5243 optionsParts.push("id: ".concat(printGroupId(doc.id)));
5246 const options = optionsParts.length > 0 ? ", { ".concat(optionsParts.join(", "), " }") : "";
5248 if (doc.expandedStates) {
5249 return "conditionalGroup([".concat(doc.expandedStates.map(part => printDoc(part)).join(","), "]").concat(options, ")");
5252 return "group(".concat(printDoc(doc.contents)).concat(options, ")");
5255 if (doc.type === "fill") {
5256 return "fill([".concat(doc.parts.map(part => printDoc(part)).join(", "), "])");
5259 if (doc.type === "line-suffix") {
5260 return "lineSuffix(" + printDoc(doc.contents) + ")";
5263 if (doc.type === "line-suffix-boundary") {
5264 return "lineSuffixBoundary";
5267 if (doc.type === "label") {
5268 return "label(".concat(JSON.stringify(doc.label), ", ").concat(printDoc(doc.contents), ")");
5271 throw new Error("Unknown doc type " + doc.type);
5274 function printGroupId(id) {
5275 if (typeof id !== "symbol") {
5276 return JSON.stringify(String(id));
5279 if (id in printedSymbols) {
5280 return printedSymbols[id];
5281 } // TODO: use Symbol.prototype.description instead of slice once Node 10 is dropped
5284 const prefix = String(id).slice(7, -1) || "symbol";
5286 for (let counter = 0;; counter++) {
5287 const key = prefix + (counter > 0 ? " #".concat(counter) : "");
5289 if (!usedKeysForSymbols.has(key)) {
5290 usedKeysForSymbols.add(key);
5291 return printedSymbols[id] = "Symbol.for(".concat(JSON.stringify(key), ")");
5302 * @typedef {import("./doc-builders").Doc} Doc
5307 builders: docBuilders,
5308 printer: docPrinter,