prettier 2.6.2 → 3.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/doc.js CHANGED
@@ -1,8 +1,15 @@
1
1
  (function (factory) {
2
+ function interopModuleDefault(factory) {
3
+ var module = factory();
4
+ return module;
5
+ }
6
+
2
7
  if (typeof exports === "object" && typeof module === "object") {
3
- module.exports = factory();
8
+ module.exports = interopModuleDefault(factory);
4
9
  } else if (typeof define === "function" && define.amd) {
5
- define(factory);
10
+ define(function () {
11
+ return interopModuleDefault(factory)
12
+ });
6
13
  } else {
7
14
  var root =
8
15
  typeof globalThis !== "undefined"
@@ -12,1369 +19,1284 @@
12
19
  : typeof self !== "undefined"
13
20
  ? self
14
21
  : this || {};
15
- root.doc = factory();
22
+ root.doc = interopModuleDefault(factory);
16
23
  }
17
24
  })(function() {
18
25
  "use strict";
26
+ var __create = Object.create;
27
+ var __defProp = Object.defineProperty;
28
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
19
29
  var __getOwnPropNames = Object.getOwnPropertyNames;
30
+ var __getProtoOf = Object.getPrototypeOf;
31
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
32
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
33
+ var __esm = (fn, res) => function __init() {
34
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
35
+ };
20
36
  var __commonJS = (cb, mod) => function __require() {
21
37
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
22
38
  };
39
+ var __export = (target, all) => {
40
+ for (var name in all)
41
+ __defProp(target, name, { get: all[name], enumerable: true });
42
+ };
43
+ var __copyProps = (to, from, except, desc) => {
44
+ if (from && typeof from === "object" || typeof from === "function") {
45
+ for (let key of __getOwnPropNames(from))
46
+ if (!__hasOwnProp.call(to, key) && key !== except)
47
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
48
+ }
49
+ return to;
50
+ };
51
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
52
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
53
+ mod
54
+ ));
55
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
56
+ var __publicField = (obj, key, value) => {
57
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
58
+ return value;
59
+ };
23
60
 
24
- // dist/doc.js
25
- var require_doc = __commonJS({
26
- "dist/doc.js"(exports, module) {
27
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
28
- var __esm = (fn, res) => function __init() {
29
- return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
30
- };
31
- var __commonJS2 = (cb, mod) => function __require() {
32
- return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = {
33
- exports: {}
34
- }).exports, mod), mod.exports;
61
+ // <define:process>
62
+ var init_define_process = __esm({
63
+ "<define:process>"() {
64
+ }
65
+ });
66
+
67
+ // node_modules/string-width/node_modules/emoji-regex/index.js
68
+ var require_emoji_regex = __commonJS({
69
+ "node_modules/string-width/node_modules/emoji-regex/index.js"(exports, module) {
70
+ "use strict";
71
+ init_define_process();
72
+ module.exports = function() {
73
+ return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\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])|\uD83C[\uDF3E\uDF73\uDF7C\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\uDF7C\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\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\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\uDF7C\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\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\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\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\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-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*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\u26A7\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-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\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[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
35
74
  };
36
- var init_define_process = __esm({
37
- "<define:process>"() {
38
- }
39
- });
40
- var require_doc_builders = __commonJS2({
41
- "src/document/doc-builders.js"(exports2, module2) {
42
- "use strict";
43
- init_define_process();
44
- function concat(parts) {
45
- if (false) {
46
- for (const part of parts) {
47
- assertDoc(part);
48
- }
49
- }
50
- return {
51
- type: "concat",
52
- parts
53
- };
54
- }
55
- function indent(contents) {
56
- if (false) {
57
- assertDoc(contents);
58
- }
59
- return {
60
- type: "indent",
61
- contents
62
- };
63
- }
64
- function align(widthOrString, contents) {
65
- if (false) {
66
- assertDoc(contents);
67
- }
68
- return {
69
- type: "align",
70
- contents,
71
- n: widthOrString
72
- };
73
- }
74
- function group(contents) {
75
- let opts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
76
- if (false) {
77
- assertDoc(contents);
78
- }
79
- return {
80
- type: "group",
81
- id: opts.id,
82
- contents,
83
- break: Boolean(opts.shouldBreak),
84
- expandedStates: opts.expandedStates
85
- };
86
- }
87
- function dedentToRoot(contents) {
88
- return align(Number.NEGATIVE_INFINITY, contents);
89
- }
90
- function markAsRoot(contents) {
91
- return align({
92
- type: "root"
93
- }, contents);
94
- }
95
- function dedent(contents) {
96
- return align(-1, contents);
97
- }
98
- function conditionalGroup(states, opts) {
99
- return group(states[0], Object.assign(Object.assign({}, opts), {}, {
100
- expandedStates: states
101
- }));
102
- }
103
- function fill(parts) {
104
- if (false) {
105
- for (const part of parts) {
106
- assertDoc(part);
107
- }
108
- }
109
- return {
110
- type: "fill",
111
- parts
112
- };
113
- }
114
- function ifBreak(breakContents, flatContents) {
115
- let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
116
- if (false) {
117
- if (breakContents) {
118
- assertDoc(breakContents);
119
- }
120
- if (flatContents) {
121
- assertDoc(flatContents);
122
- }
123
- }
124
- return {
125
- type: "if-break",
126
- breakContents,
127
- flatContents,
128
- groupId: opts.groupId
129
- };
130
- }
131
- function indentIfBreak(contents, opts) {
132
- return {
133
- type: "indent-if-break",
134
- contents,
135
- groupId: opts.groupId,
136
- negate: opts.negate
137
- };
75
+ }
76
+ });
77
+
78
+ // src/document/index.js
79
+ var document_exports = {};
80
+ __export(document_exports, {
81
+ builders: () => builders_exports,
82
+ debug: () => debug_exports,
83
+ printer: () => printer_exports,
84
+ utils: () => utils_exports
85
+ });
86
+ init_define_process();
87
+
88
+ // src/document/builders.js
89
+ var builders_exports = {};
90
+ __export(builders_exports, {
91
+ addAlignmentToDoc: () => addAlignmentToDoc,
92
+ align: () => align,
93
+ breakParent: () => breakParent,
94
+ concat: () => concat,
95
+ conditionalGroup: () => conditionalGroup,
96
+ cursor: () => cursor,
97
+ dedent: () => dedent,
98
+ dedentToRoot: () => dedentToRoot,
99
+ fill: () => fill,
100
+ group: () => group,
101
+ hardline: () => hardline,
102
+ hardlineWithoutBreakParent: () => hardlineWithoutBreakParent,
103
+ ifBreak: () => ifBreak,
104
+ indent: () => indent,
105
+ indentIfBreak: () => indentIfBreak,
106
+ join: () => join,
107
+ label: () => label,
108
+ line: () => line,
109
+ lineSuffix: () => lineSuffix,
110
+ lineSuffixBoundary: () => lineSuffixBoundary,
111
+ literalline: () => literalline,
112
+ literallineWithoutBreakParent: () => literallineWithoutBreakParent,
113
+ markAsRoot: () => markAsRoot,
114
+ softline: () => softline,
115
+ trim: () => trim
116
+ });
117
+ init_define_process();
118
+
119
+ // src/document/constants.js
120
+ init_define_process();
121
+ var DOC_TYPE_STRING = "string";
122
+ var DOC_TYPE_ARRAY = "array";
123
+ var DOC_TYPE_CURSOR = "cursor";
124
+ var DOC_TYPE_INDENT = "indent";
125
+ var DOC_TYPE_ALIGN = "align";
126
+ var DOC_TYPE_TRIM = "trim";
127
+ var DOC_TYPE_GROUP = "group";
128
+ var DOC_TYPE_FILL = "fill";
129
+ var DOC_TYPE_IF_BREAK = "if-break";
130
+ var DOC_TYPE_INDENT_IF_BREAK = "indent-if-break";
131
+ var DOC_TYPE_LINE_SUFFIX = "line-suffix";
132
+ var DOC_TYPE_LINE_SUFFIX_BOUNDARY = "line-suffix-boundary";
133
+ var DOC_TYPE_LINE = "line";
134
+ var DOC_TYPE_LABEL = "label";
135
+ var DOC_TYPE_BREAK_PARENT = "break-parent";
136
+
137
+ // src/document/builders.js
138
+ function indent(contents) {
139
+ if (false) {
140
+ assertDoc(contents);
141
+ }
142
+ return { type: DOC_TYPE_INDENT, contents };
143
+ }
144
+ function align(widthOrString, contents) {
145
+ if (false) {
146
+ assertDoc(contents);
147
+ }
148
+ return { type: DOC_TYPE_ALIGN, contents, n: widthOrString };
149
+ }
150
+ function group(contents, opts = {}) {
151
+ if (false) {
152
+ assertDoc(contents);
153
+ }
154
+ return {
155
+ type: DOC_TYPE_GROUP,
156
+ id: opts.id,
157
+ contents,
158
+ break: Boolean(opts.shouldBreak),
159
+ expandedStates: opts.expandedStates
160
+ };
161
+ }
162
+ function dedentToRoot(contents) {
163
+ return align(Number.NEGATIVE_INFINITY, contents);
164
+ }
165
+ function markAsRoot(contents) {
166
+ return align({ type: "root" }, contents);
167
+ }
168
+ function dedent(contents) {
169
+ return align(-1, contents);
170
+ }
171
+ function conditionalGroup(states, opts) {
172
+ return group(states[0], { ...opts, expandedStates: states });
173
+ }
174
+ function fill(parts) {
175
+ if (false) {
176
+ for (const part of parts) {
177
+ assertDoc(part);
178
+ }
179
+ }
180
+ return { type: DOC_TYPE_FILL, parts };
181
+ }
182
+ function ifBreak(breakContents, flatContents, opts = {}) {
183
+ if (false) {
184
+ if (breakContents) {
185
+ assertDoc(breakContents);
186
+ }
187
+ if (flatContents) {
188
+ assertDoc(flatContents);
189
+ }
190
+ }
191
+ return {
192
+ type: DOC_TYPE_IF_BREAK,
193
+ breakContents,
194
+ flatContents,
195
+ groupId: opts.groupId
196
+ };
197
+ }
198
+ function indentIfBreak(contents, opts) {
199
+ return {
200
+ type: DOC_TYPE_INDENT_IF_BREAK,
201
+ contents,
202
+ groupId: opts.groupId,
203
+ negate: opts.negate
204
+ };
205
+ }
206
+ function lineSuffix(contents) {
207
+ if (false) {
208
+ assertDoc(contents);
209
+ }
210
+ return { type: DOC_TYPE_LINE_SUFFIX, contents };
211
+ }
212
+ var lineSuffixBoundary = { type: DOC_TYPE_LINE_SUFFIX_BOUNDARY };
213
+ var breakParent = { type: DOC_TYPE_BREAK_PARENT };
214
+ var trim = { type: DOC_TYPE_TRIM };
215
+ var hardlineWithoutBreakParent = { type: DOC_TYPE_LINE, hard: true };
216
+ var literallineWithoutBreakParent = {
217
+ type: DOC_TYPE_LINE,
218
+ hard: true,
219
+ literal: true
220
+ };
221
+ var line = { type: DOC_TYPE_LINE };
222
+ var softline = { type: DOC_TYPE_LINE, soft: true };
223
+ var hardline = [hardlineWithoutBreakParent, breakParent];
224
+ var literalline = [literallineWithoutBreakParent, breakParent];
225
+ var cursor = { type: DOC_TYPE_CURSOR, placeholder: Symbol("cursor") };
226
+ function join(sep, arr) {
227
+ const res = [];
228
+ for (let i = 0; i < arr.length; i++) {
229
+ if (i !== 0) {
230
+ res.push(sep);
231
+ }
232
+ res.push(arr[i]);
233
+ }
234
+ return res;
235
+ }
236
+ function addAlignmentToDoc(doc, size, tabWidth) {
237
+ let aligned = doc;
238
+ if (size > 0) {
239
+ for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
240
+ aligned = indent(aligned);
241
+ }
242
+ aligned = align(size % tabWidth, aligned);
243
+ aligned = align(Number.NEGATIVE_INFINITY, aligned);
244
+ }
245
+ return aligned;
246
+ }
247
+ function label(label2, contents) {
248
+ return { type: DOC_TYPE_LABEL, label: label2, contents };
249
+ }
250
+ var concat = (parts) => parts;
251
+
252
+ // src/document/printer.js
253
+ var printer_exports = {};
254
+ __export(printer_exports, {
255
+ printDocToString: () => printDocToString
256
+ });
257
+ init_define_process();
258
+
259
+ // src/common/end-of-line.js
260
+ init_define_process();
261
+ function convertEndOfLineToChars(value) {
262
+ switch (value) {
263
+ case "cr":
264
+ return "\r";
265
+ case "crlf":
266
+ return "\r\n";
267
+ default:
268
+ return "\n";
269
+ }
270
+ }
271
+
272
+ // src/utils/get-last.js
273
+ init_define_process();
274
+ var getLast = (arr) => arr[arr.length - 1];
275
+ var get_last_default = getLast;
276
+
277
+ // src/utils/get-string-width.js
278
+ init_define_process();
279
+
280
+ // node_modules/string-width/index.js
281
+ init_define_process();
282
+
283
+ // node_modules/strip-ansi/index.js
284
+ init_define_process();
285
+
286
+ // node_modules/strip-ansi/node_modules/ansi-regex/index.js
287
+ init_define_process();
288
+ function ansiRegex({ onlyFirst = false } = {}) {
289
+ const pattern = [
290
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
291
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
292
+ ].join("|");
293
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
294
+ }
295
+
296
+ // node_modules/strip-ansi/index.js
297
+ function stripAnsi(string) {
298
+ if (typeof string !== "string") {
299
+ throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
300
+ }
301
+ return string.replace(ansiRegex(), "");
302
+ }
303
+
304
+ // node_modules/string-width/node_modules/is-fullwidth-code-point/index.js
305
+ init_define_process();
306
+ function isFullwidthCodePoint(codePoint) {
307
+ if (!Number.isInteger(codePoint)) {
308
+ return false;
309
+ }
310
+ return codePoint >= 4352 && (codePoint <= 4447 || codePoint === 9001 || codePoint === 9002 || 11904 <= codePoint && codePoint <= 12871 && codePoint !== 12351 || 12880 <= codePoint && codePoint <= 19903 || 19968 <= codePoint && codePoint <= 42182 || 43360 <= codePoint && codePoint <= 43388 || 44032 <= codePoint && codePoint <= 55203 || 63744 <= codePoint && codePoint <= 64255 || 65040 <= codePoint && codePoint <= 65049 || 65072 <= codePoint && codePoint <= 65131 || 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 || 110592 <= codePoint && codePoint <= 110593 || 127488 <= codePoint && codePoint <= 127569 || 131072 <= codePoint && codePoint <= 262141);
311
+ }
312
+
313
+ // node_modules/string-width/index.js
314
+ var import_emoji_regex = __toESM(require_emoji_regex(), 1);
315
+ function stringWidth(string) {
316
+ if (typeof string !== "string" || string.length === 0) {
317
+ return 0;
318
+ }
319
+ string = stripAnsi(string);
320
+ if (string.length === 0) {
321
+ return 0;
322
+ }
323
+ string = string.replace((0, import_emoji_regex.default)(), " ");
324
+ let width = 0;
325
+ for (let index = 0; index < string.length; index++) {
326
+ const codePoint = string.codePointAt(index);
327
+ if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
328
+ continue;
329
+ }
330
+ if (codePoint >= 768 && codePoint <= 879) {
331
+ continue;
332
+ }
333
+ if (codePoint > 65535) {
334
+ index++;
335
+ }
336
+ width += isFullwidthCodePoint(codePoint) ? 2 : 1;
337
+ }
338
+ return width;
339
+ }
340
+
341
+ // src/utils/get-string-width.js
342
+ var notAsciiRegex = /[^\x20-\x7F]/;
343
+ function getStringWidth(text) {
344
+ if (!text) {
345
+ return 0;
346
+ }
347
+ if (!notAsciiRegex.test(text)) {
348
+ return text.length;
349
+ }
350
+ return stringWidth(text);
351
+ }
352
+ var get_string_width_default = getStringWidth;
353
+
354
+ // src/document/utils.js
355
+ var utils_exports = {};
356
+ __export(utils_exports, {
357
+ canBreak: () => canBreak,
358
+ cleanDoc: () => cleanDoc,
359
+ findInDoc: () => findInDoc,
360
+ getDocParts: () => getDocParts,
361
+ getDocType: () => getDocType,
362
+ mapDoc: () => mapDoc,
363
+ normalizeDoc: () => normalizeDoc,
364
+ normalizeParts: () => normalizeParts,
365
+ propagateBreaks: () => propagateBreaks,
366
+ removeLines: () => removeLines,
367
+ replaceEndOfLine: () => replaceEndOfLine,
368
+ replaceTextEndOfLine: () => replaceTextEndOfLine,
369
+ stripTrailingHardline: () => stripTrailingHardline,
370
+ traverseDoc: () => traverseDoc,
371
+ willBreak: () => willBreak
372
+ });
373
+ init_define_process();
374
+ var getDocParts = (doc) => {
375
+ if (Array.isArray(doc)) {
376
+ return doc;
377
+ }
378
+ if (doc.type !== DOC_TYPE_FILL) {
379
+ throw new Error(`Expect doc to be 'array' or '${DOC_TYPE_FILL}'.`);
380
+ }
381
+ return doc.parts;
382
+ };
383
+ var traverseDocOnExitStackMarker = {};
384
+ function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
385
+ const docsStack = [doc];
386
+ while (docsStack.length > 0) {
387
+ const doc2 = docsStack.pop();
388
+ if (doc2 === traverseDocOnExitStackMarker) {
389
+ onExit(docsStack.pop());
390
+ continue;
391
+ }
392
+ if (onExit) {
393
+ docsStack.push(doc2, traverseDocOnExitStackMarker);
394
+ }
395
+ if (!onEnter || onEnter(doc2) !== false) {
396
+ if (Array.isArray(doc2) || doc2.type === DOC_TYPE_FILL) {
397
+ const parts = getDocParts(doc2);
398
+ for (let ic = parts.length, i = ic - 1; i >= 0; --i) {
399
+ docsStack.push(parts[i]);
138
400
  }
139
- function lineSuffix(contents) {
140
- if (false) {
141
- assertDoc(contents);
142
- }
143
- return {
144
- type: "line-suffix",
145
- contents
146
- };
401
+ } else if (doc2.type === DOC_TYPE_IF_BREAK) {
402
+ if (doc2.flatContents) {
403
+ docsStack.push(doc2.flatContents);
147
404
  }
148
- var lineSuffixBoundary = {
149
- type: "line-suffix-boundary"
150
- };
151
- var breakParent = {
152
- type: "break-parent"
153
- };
154
- var trim = {
155
- type: "trim"
156
- };
157
- var hardlineWithoutBreakParent = {
158
- type: "line",
159
- hard: true
160
- };
161
- var literallineWithoutBreakParent = {
162
- type: "line",
163
- hard: true,
164
- literal: true
165
- };
166
- var line = {
167
- type: "line"
168
- };
169
- var softline = {
170
- type: "line",
171
- soft: true
172
- };
173
- var hardline = concat([hardlineWithoutBreakParent, breakParent]);
174
- var literalline = concat([literallineWithoutBreakParent, breakParent]);
175
- var cursor = {
176
- type: "cursor",
177
- placeholder: Symbol("cursor")
178
- };
179
- function join(sep, arr) {
180
- const res = [];
181
- for (let i = 0; i < arr.length; i++) {
182
- if (i !== 0) {
183
- res.push(sep);
184
- }
185
- res.push(arr[i]);
186
- }
187
- return concat(res);
405
+ if (doc2.breakContents) {
406
+ docsStack.push(doc2.breakContents);
188
407
  }
189
- function addAlignmentToDoc(doc, size, tabWidth) {
190
- let aligned = doc;
191
- if (size > 0) {
192
- for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
193
- aligned = indent(aligned);
194
- }
195
- aligned = align(size % tabWidth, aligned);
196
- aligned = align(Number.NEGATIVE_INFINITY, aligned);
408
+ } else if (doc2.type === DOC_TYPE_GROUP && doc2.expandedStates) {
409
+ if (shouldTraverseConditionalGroups) {
410
+ for (let ic = doc2.expandedStates.length, i = ic - 1; i >= 0; --i) {
411
+ docsStack.push(doc2.expandedStates[i]);
197
412
  }
198
- return aligned;
199
- }
200
- function label(label2, contents) {
201
- return {
202
- type: "label",
203
- label: label2,
204
- contents
205
- };
413
+ } else {
414
+ docsStack.push(doc2.contents);
206
415
  }
207
- module2.exports = {
208
- concat,
209
- join,
210
- line,
211
- softline,
212
- hardline,
213
- literalline,
214
- group,
215
- conditionalGroup,
216
- fill,
217
- lineSuffix,
218
- lineSuffixBoundary,
219
- cursor,
220
- breakParent,
221
- ifBreak,
222
- trim,
223
- indent,
224
- indentIfBreak,
225
- align,
226
- addAlignmentToDoc,
227
- markAsRoot,
228
- dedentToRoot,
229
- dedent,
230
- hardlineWithoutBreakParent,
231
- literallineWithoutBreakParent,
232
- label
233
- };
416
+ } else if (doc2.contents) {
417
+ docsStack.push(doc2.contents);
234
418
  }
235
- });
236
- var require_end_of_line = __commonJS2({
237
- "src/common/end-of-line.js"(exports2, module2) {
238
- "use strict";
239
- init_define_process();
240
- function guessEndOfLine(text) {
241
- const index = text.indexOf("\r");
242
- if (index >= 0) {
243
- return text.charAt(index + 1) === "\n" ? "crlf" : "cr";
244
- }
245
- return "lf";
246
- }
247
- function convertEndOfLineToChars(value) {
248
- switch (value) {
249
- case "cr":
250
- return "\r";
251
- case "crlf":
252
- return "\r\n";
253
- default:
254
- return "\n";
255
- }
256
- }
257
- function countEndOfLineChars(text, eol) {
258
- let regex;
259
- switch (eol) {
260
- case "\n":
261
- regex = /\n/g;
262
- break;
263
- case "\r":
264
- regex = /\r/g;
265
- break;
266
- case "\r\n":
267
- regex = /\r\n/g;
268
- break;
269
- default:
270
- throw new Error('Unexpected "eol" '.concat(JSON.stringify(eol), "."));
271
- }
272
- const endOfLines = text.match(regex);
273
- return endOfLines ? endOfLines.length : 0;
274
- }
275
- function normalizeEndOfLine(text) {
276
- return text.replace(/\r\n?/g, "\n");
277
- }
278
- module2.exports = {
279
- guessEndOfLine,
280
- convertEndOfLineToChars,
281
- countEndOfLineChars,
282
- normalizeEndOfLine
283
- };
419
+ }
420
+ }
421
+ }
422
+ function mapDoc(doc, cb) {
423
+ const mapped = /* @__PURE__ */ new Map();
424
+ return rec(doc);
425
+ function rec(doc2) {
426
+ if (mapped.has(doc2)) {
427
+ return mapped.get(doc2);
428
+ }
429
+ const result = process2(doc2);
430
+ mapped.set(doc2, result);
431
+ return result;
432
+ }
433
+ function process2(doc2) {
434
+ if (Array.isArray(doc2)) {
435
+ return cb(doc2.map(rec));
436
+ }
437
+ if (doc2.type === DOC_TYPE_ARRAY || doc2.type === DOC_TYPE_FILL) {
438
+ const parts = doc2.parts.map(rec);
439
+ return cb({ ...doc2, parts });
440
+ }
441
+ if (doc2.type === DOC_TYPE_IF_BREAK) {
442
+ const breakContents = doc2.breakContents && rec(doc2.breakContents);
443
+ const flatContents = doc2.flatContents && rec(doc2.flatContents);
444
+ return cb({ ...doc2, breakContents, flatContents });
445
+ }
446
+ if (doc2.type === DOC_TYPE_GROUP && doc2.expandedStates) {
447
+ const expandedStates = doc2.expandedStates.map(rec);
448
+ const contents = expandedStates[0];
449
+ return cb({ ...doc2, contents, expandedStates });
450
+ }
451
+ if (doc2.contents) {
452
+ const contents = rec(doc2.contents);
453
+ return cb({ ...doc2, contents });
454
+ }
455
+ return cb(doc2);
456
+ }
457
+ }
458
+ function findInDoc(doc, fn, defaultValue) {
459
+ let result = defaultValue;
460
+ let hasStopped = false;
461
+ function findInDocOnEnterFn(doc2) {
462
+ const maybeResult = fn(doc2);
463
+ if (maybeResult !== void 0) {
464
+ hasStopped = true;
465
+ result = maybeResult;
466
+ }
467
+ if (hasStopped) {
468
+ return false;
469
+ }
470
+ }
471
+ traverseDoc(doc, findInDocOnEnterFn);
472
+ return result;
473
+ }
474
+ function willBreakFn(doc) {
475
+ if (doc.type === DOC_TYPE_GROUP && doc.break) {
476
+ return true;
477
+ }
478
+ if (doc.type === DOC_TYPE_LINE && doc.hard) {
479
+ return true;
480
+ }
481
+ if (doc.type === DOC_TYPE_BREAK_PARENT) {
482
+ return true;
483
+ }
484
+ }
485
+ function willBreak(doc) {
486
+ return findInDoc(doc, willBreakFn, false);
487
+ }
488
+ function breakParentGroup(groupStack) {
489
+ if (groupStack.length > 0) {
490
+ const parentGroup = get_last_default(groupStack);
491
+ if (!parentGroup.expandedStates && !parentGroup.break) {
492
+ parentGroup.break = "propagated";
493
+ }
494
+ }
495
+ return null;
496
+ }
497
+ function propagateBreaks(doc) {
498
+ const alreadyVisitedSet = /* @__PURE__ */ new Set();
499
+ const groupStack = [];
500
+ function propagateBreaksOnEnterFn(doc2) {
501
+ if (doc2.type === DOC_TYPE_BREAK_PARENT) {
502
+ breakParentGroup(groupStack);
503
+ }
504
+ if (doc2.type === DOC_TYPE_GROUP) {
505
+ groupStack.push(doc2);
506
+ if (alreadyVisitedSet.has(doc2)) {
507
+ return false;
284
508
  }
285
- });
286
- var require_get_last = __commonJS2({
287
- "src/utils/get-last.js"(exports2, module2) {
288
- "use strict";
289
- init_define_process();
290
- var getLast = (arr) => arr[arr.length - 1];
291
- module2.exports = getLast;
509
+ alreadyVisitedSet.add(doc2);
510
+ }
511
+ }
512
+ function propagateBreaksOnExitFn(doc2) {
513
+ if (doc2.type === DOC_TYPE_GROUP) {
514
+ const group2 = groupStack.pop();
515
+ if (group2.break) {
516
+ breakParentGroup(groupStack);
292
517
  }
293
- });
294
- var require_string_width = __commonJS2({
295
- "vendors/string-width.js"(exports2, module2) {
296
- init_define_process();
297
- var __create = Object.create;
298
- var __defProp = Object.defineProperty;
299
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
300
- var __getOwnPropNames22 = Object.getOwnPropertyNames;
301
- var __getProtoOf = Object.getPrototypeOf;
302
- var __hasOwnProp = Object.prototype.hasOwnProperty;
303
- var __commonJS22 = (cb, mod) => function __require() {
304
- return mod || (0, cb[__getOwnPropNames22(cb)[0]])((mod = {
305
- exports: {}
306
- }).exports, mod), mod.exports;
307
- };
308
- var __export = (target, all) => {
309
- for (var name in all)
310
- __defProp(target, name, {
311
- get: all[name],
312
- enumerable: true
313
- });
314
- };
315
- var __copyProps = (to, from, except, desc) => {
316
- if (from && typeof from === "object" || typeof from === "function") {
317
- for (let key of __getOwnPropNames22(from))
318
- if (!__hasOwnProp.call(to, key) && key !== except)
319
- __defProp(to, key, {
320
- get: () => from[key],
321
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
322
- });
323
- }
324
- return to;
325
- };
326
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
327
- value: mod,
328
- enumerable: true
329
- }) : target, mod));
330
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", {
331
- value: true
332
- }), mod);
333
- var require_emoji_regex = __commonJS22({
334
- "node_modules/emoji-regex/index.js"(exports3, module22) {
335
- "use strict";
336
- module22.exports = function() {
337
- return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\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])|\uD83C[\uDF3E\uDF73\uDF7C\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\uDF7C\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\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\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\uDF7C\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\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\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\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\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-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*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\u26A7\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-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\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[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
338
- };
339
- }
340
- });
341
- var string_width_exports = {};
342
- __export(string_width_exports, {
343
- default: () => stringWidth
344
- });
345
- module2.exports = __toCommonJS(string_width_exports);
346
- function ansiRegex() {
347
- let {
348
- onlyFirst = false
349
- } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
350
- 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("|");
351
- return new RegExp(pattern, onlyFirst ? void 0 : "g");
352
- }
353
- function stripAnsi(string) {
354
- if (typeof string !== "string") {
355
- throw new TypeError("Expected a `string`, got `".concat(typeof string, "`"));
356
- }
357
- return string.replace(ansiRegex(), "");
358
- }
359
- function isFullwidthCodePoint(codePoint) {
360
- if (!Number.isInteger(codePoint)) {
361
- return false;
362
- }
363
- return codePoint >= 4352 && (codePoint <= 4447 || codePoint === 9001 || codePoint === 9002 || 11904 <= codePoint && codePoint <= 12871 && codePoint !== 12351 || 12880 <= codePoint && codePoint <= 19903 || 19968 <= codePoint && codePoint <= 42182 || 43360 <= codePoint && codePoint <= 43388 || 44032 <= codePoint && codePoint <= 55203 || 63744 <= codePoint && codePoint <= 64255 || 65040 <= codePoint && codePoint <= 65049 || 65072 <= codePoint && codePoint <= 65131 || 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 || 110592 <= codePoint && codePoint <= 110593 || 127488 <= codePoint && codePoint <= 127569 || 131072 <= codePoint && codePoint <= 262141);
364
- }
365
- var import_emoji_regex = __toESM(require_emoji_regex(), 1);
366
- function stringWidth(string) {
367
- if (typeof string !== "string" || string.length === 0) {
368
- return 0;
369
- }
370
- string = stripAnsi(string);
371
- if (string.length === 0) {
372
- return 0;
373
- }
374
- string = string.replace((0, import_emoji_regex.default)(), " ");
375
- let width = 0;
376
- for (let index = 0; index < string.length; index++) {
377
- const codePoint = string.codePointAt(index);
378
- if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
379
- continue;
380
- }
381
- if (codePoint >= 768 && codePoint <= 879) {
382
- continue;
383
- }
384
- if (codePoint > 65535) {
385
- index++;
386
- }
387
- width += isFullwidthCodePoint(codePoint) ? 2 : 1;
388
- }
389
- return width;
390
- }
518
+ }
519
+ }
520
+ traverseDoc(
521
+ doc,
522
+ propagateBreaksOnEnterFn,
523
+ propagateBreaksOnExitFn,
524
+ true
525
+ );
526
+ }
527
+ function removeLinesFn(doc) {
528
+ if (doc.type === DOC_TYPE_LINE && !doc.hard) {
529
+ return doc.soft ? "" : " ";
530
+ }
531
+ if (doc.type === DOC_TYPE_IF_BREAK) {
532
+ return doc.flatContents || "";
533
+ }
534
+ return doc;
535
+ }
536
+ function removeLines(doc) {
537
+ return mapDoc(doc, removeLinesFn);
538
+ }
539
+ var isHardline = (doc, nextDoc) => doc && doc.type === DOC_TYPE_LINE && doc.hard && nextDoc && nextDoc.type === DOC_TYPE_BREAK_PARENT;
540
+ function stripDocTrailingHardlineFromDoc(doc) {
541
+ if (!doc) {
542
+ return doc;
543
+ }
544
+ if (Array.isArray(doc) || doc.type === DOC_TYPE_FILL) {
545
+ const parts = getDocParts(doc);
546
+ while (parts.length > 1 && isHardline(...parts.slice(-2))) {
547
+ parts.length -= 2;
548
+ }
549
+ if (parts.length > 0) {
550
+ const lastPart = stripDocTrailingHardlineFromDoc(get_last_default(parts));
551
+ parts[parts.length - 1] = lastPart;
552
+ }
553
+ return Array.isArray(doc) ? parts : { ...doc, parts };
554
+ }
555
+ switch (doc.type) {
556
+ case DOC_TYPE_ALIGN:
557
+ case DOC_TYPE_INDENT:
558
+ case DOC_TYPE_INDENT_IF_BREAK:
559
+ case DOC_TYPE_GROUP:
560
+ case DOC_TYPE_LINE_SUFFIX:
561
+ case DOC_TYPE_LABEL: {
562
+ const contents = stripDocTrailingHardlineFromDoc(doc.contents);
563
+ return { ...doc, contents };
564
+ }
565
+ case DOC_TYPE_IF_BREAK: {
566
+ const breakContents = stripDocTrailingHardlineFromDoc(doc.breakContents);
567
+ const flatContents = stripDocTrailingHardlineFromDoc(doc.flatContents);
568
+ return { ...doc, breakContents, flatContents };
569
+ }
570
+ }
571
+ return doc;
572
+ }
573
+ function stripTrailingHardline(doc) {
574
+ if (typeof doc === "string") {
575
+ return doc.replace(/(?:\r?\n)*$/, "");
576
+ }
577
+ return stripDocTrailingHardlineFromDoc(cleanDoc(doc));
578
+ }
579
+ function cleanDocFn(doc) {
580
+ switch (doc.type) {
581
+ case DOC_TYPE_FILL:
582
+ if (doc.parts.every((part) => part === "")) {
583
+ return "";
391
584
  }
392
- });
393
- var require_get_string_width = __commonJS2({
394
- "src/utils/get-string-width.js"(exports2, module2) {
395
- "use strict";
396
- init_define_process();
397
- var stringWidth = require_string_width().default;
398
- var notAsciiRegex = /[^\x20-\x7F]/;
399
- function getStringWidth(text) {
400
- if (!text) {
401
- return 0;
402
- }
403
- if (!notAsciiRegex.test(text)) {
404
- return text.length;
405
- }
406
- return stringWidth(text);
407
- }
408
- module2.exports = getStringWidth;
585
+ break;
586
+ case DOC_TYPE_GROUP:
587
+ if (!doc.contents && !doc.id && !doc.break && !doc.expandedStates) {
588
+ return "";
409
589
  }
410
- });
411
- var require_doc_utils = __commonJS2({
412
- "src/document/doc-utils.js"(exports2, module2) {
413
- "use strict";
414
- init_define_process();
415
- var getLast = require_get_last();
416
- var {
417
- literalline,
418
- join
419
- } = require_doc_builders();
420
- var isConcat = (doc) => Array.isArray(doc) || doc && doc.type === "concat";
421
- var getDocParts = (doc) => {
422
- if (Array.isArray(doc)) {
423
- return doc;
424
- }
425
- if (doc.type !== "concat" && doc.type !== "fill") {
426
- throw new Error("Expect doc type to be `concat` or `fill`.");
427
- }
428
- return doc.parts;
429
- };
430
- var traverseDocOnExitStackMarker = {};
431
- function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
432
- const docsStack = [doc];
433
- while (docsStack.length > 0) {
434
- const doc2 = docsStack.pop();
435
- if (doc2 === traverseDocOnExitStackMarker) {
436
- onExit(docsStack.pop());
437
- continue;
438
- }
439
- if (onExit) {
440
- docsStack.push(doc2, traverseDocOnExitStackMarker);
441
- }
442
- if (!onEnter || onEnter(doc2) !== false) {
443
- if (isConcat(doc2) || doc2.type === "fill") {
444
- const parts = getDocParts(doc2);
445
- for (let ic = parts.length, i = ic - 1; i >= 0; --i) {
446
- docsStack.push(parts[i]);
447
- }
448
- } else if (doc2.type === "if-break") {
449
- if (doc2.flatContents) {
450
- docsStack.push(doc2.flatContents);
451
- }
452
- if (doc2.breakContents) {
453
- docsStack.push(doc2.breakContents);
454
- }
455
- } else if (doc2.type === "group" && doc2.expandedStates) {
456
- if (shouldTraverseConditionalGroups) {
457
- for (let ic = doc2.expandedStates.length, i = ic - 1; i >= 0; --i) {
458
- docsStack.push(doc2.expandedStates[i]);
459
- }
460
- } else {
461
- docsStack.push(doc2.contents);
462
- }
463
- } else if (doc2.contents) {
464
- docsStack.push(doc2.contents);
465
- }
466
- }
467
- }
468
- }
469
- function mapDoc(doc, cb) {
470
- const mapped = /* @__PURE__ */ new Map();
471
- return rec(doc);
472
- function rec(doc2) {
473
- if (mapped.has(doc2)) {
474
- return mapped.get(doc2);
475
- }
476
- const result = process2(doc2);
477
- mapped.set(doc2, result);
478
- return result;
479
- }
480
- function process2(doc2) {
481
- if (Array.isArray(doc2)) {
482
- return cb(doc2.map(rec));
483
- }
484
- if (doc2.type === "concat" || doc2.type === "fill") {
485
- const parts = doc2.parts.map(rec);
486
- return cb(Object.assign(Object.assign({}, doc2), {}, {
487
- parts
488
- }));
489
- }
490
- if (doc2.type === "if-break") {
491
- const breakContents = doc2.breakContents && rec(doc2.breakContents);
492
- const flatContents = doc2.flatContents && rec(doc2.flatContents);
493
- return cb(Object.assign(Object.assign({}, doc2), {}, {
494
- breakContents,
495
- flatContents
496
- }));
497
- }
498
- if (doc2.type === "group" && doc2.expandedStates) {
499
- const expandedStates = doc2.expandedStates.map(rec);
500
- const contents = expandedStates[0];
501
- return cb(Object.assign(Object.assign({}, doc2), {}, {
502
- contents,
503
- expandedStates
504
- }));
505
- }
506
- if (doc2.contents) {
507
- const contents = rec(doc2.contents);
508
- return cb(Object.assign(Object.assign({}, doc2), {}, {
509
- contents
510
- }));
511
- }
512
- return cb(doc2);
513
- }
590
+ if (doc.contents.type === DOC_TYPE_GROUP && doc.contents.id === doc.id && doc.contents.break === doc.break && doc.contents.expandedStates === doc.expandedStates) {
591
+ return doc.contents;
592
+ }
593
+ break;
594
+ case DOC_TYPE_ALIGN:
595
+ case DOC_TYPE_INDENT:
596
+ case DOC_TYPE_INDENT_IF_BREAK:
597
+ case DOC_TYPE_LINE_SUFFIX:
598
+ if (!doc.contents) {
599
+ return "";
600
+ }
601
+ break;
602
+ case DOC_TYPE_IF_BREAK:
603
+ if (!doc.flatContents && !doc.breakContents) {
604
+ return "";
605
+ }
606
+ break;
607
+ }
608
+ if (!Array.isArray(doc)) {
609
+ return doc;
610
+ }
611
+ const parts = [];
612
+ for (const part of doc) {
613
+ if (!part) {
614
+ continue;
615
+ }
616
+ const [currentPart, ...restParts] = Array.isArray(part) ? part : [part];
617
+ if (typeof currentPart === "string" && typeof get_last_default(parts) === "string") {
618
+ parts[parts.length - 1] += currentPart;
619
+ } else {
620
+ parts.push(currentPart);
621
+ }
622
+ parts.push(...restParts);
623
+ }
624
+ if (parts.length === 0) {
625
+ return "";
626
+ }
627
+ if (parts.length === 1) {
628
+ return parts[0];
629
+ }
630
+ return parts;
631
+ }
632
+ function cleanDoc(doc) {
633
+ return mapDoc(doc, (currentDoc) => cleanDocFn(currentDoc));
634
+ }
635
+ function normalizeParts(parts) {
636
+ const newParts = [];
637
+ const restParts = parts.filter(Boolean);
638
+ while (restParts.length > 0) {
639
+ const part = restParts.shift();
640
+ if (!part) {
641
+ continue;
642
+ }
643
+ if (Array.isArray(part)) {
644
+ restParts.unshift(...part);
645
+ continue;
646
+ }
647
+ if (newParts.length > 0 && typeof get_last_default(newParts) === "string" && typeof part === "string") {
648
+ newParts[newParts.length - 1] += part;
649
+ continue;
650
+ }
651
+ newParts.push(part);
652
+ }
653
+ return newParts;
654
+ }
655
+ function normalizeDoc(doc) {
656
+ return mapDoc(doc, (currentDoc) => {
657
+ if (Array.isArray(currentDoc)) {
658
+ return normalizeParts(currentDoc);
659
+ }
660
+ if (!currentDoc.parts) {
661
+ return currentDoc;
662
+ }
663
+ return {
664
+ ...currentDoc,
665
+ parts: normalizeParts(currentDoc.parts)
666
+ };
667
+ });
668
+ }
669
+ function replaceEndOfLine(doc) {
670
+ return mapDoc(
671
+ doc,
672
+ (currentDoc) => typeof currentDoc === "string" && currentDoc.includes("\n") ? replaceTextEndOfLine(currentDoc) : currentDoc
673
+ );
674
+ }
675
+ function replaceTextEndOfLine(text, replacement = literalline) {
676
+ return join(replacement, text.split("\n"));
677
+ }
678
+ function canBreakFn(doc) {
679
+ if (doc.type === DOC_TYPE_LINE) {
680
+ return true;
681
+ }
682
+ }
683
+ function canBreak(doc) {
684
+ return findInDoc(doc, canBreakFn, false);
685
+ }
686
+ function getDocType(doc) {
687
+ if (typeof doc === "string") {
688
+ return DOC_TYPE_STRING;
689
+ }
690
+ if (Array.isArray(doc)) {
691
+ return DOC_TYPE_ARRAY;
692
+ }
693
+ return doc == null ? void 0 : doc.type;
694
+ }
695
+
696
+ // src/document/invalid-doc-error.js
697
+ init_define_process();
698
+ var VALID_OBJECT_DOC_TYPE_VALUES = [
699
+ DOC_TYPE_CURSOR,
700
+ DOC_TYPE_INDENT,
701
+ DOC_TYPE_ALIGN,
702
+ DOC_TYPE_TRIM,
703
+ DOC_TYPE_GROUP,
704
+ DOC_TYPE_FILL,
705
+ DOC_TYPE_IF_BREAK,
706
+ DOC_TYPE_INDENT_IF_BREAK,
707
+ DOC_TYPE_LINE_SUFFIX,
708
+ DOC_TYPE_LINE_SUFFIX_BOUNDARY,
709
+ DOC_TYPE_LINE,
710
+ DOC_TYPE_LABEL,
711
+ DOC_TYPE_BREAK_PARENT
712
+ ];
713
+ var disjunctionListFormat = (list) => [...list.slice(0, -1), `or ${get_last_default(list)}`].join(", ");
714
+ function getDocErrorMessage(doc) {
715
+ const type = doc === null ? null : typeof doc;
716
+ if (type !== "string" && type !== "object") {
717
+ return `Unexpected doc '${type}',
718
+ Expected it to be 'string' or 'object'.`;
719
+ }
720
+ const docType = getDocType(doc);
721
+ if (docType === DOC_TYPE_STRING || docType === DOC_TYPE_ARRAY || VALID_OBJECT_DOC_TYPE_VALUES.includes(docType)) {
722
+ throw new Error("doc is valid.");
723
+ }
724
+ const objectType = Object.prototype.toString.call(doc);
725
+ if (objectType !== "[object Object]") {
726
+ return `Unexpected doc '${objectType}'.`;
727
+ }
728
+ const EXPECTED_TYPE_VALUES = disjunctionListFormat(
729
+ VALID_OBJECT_DOC_TYPE_VALUES.map((type2) => `'${type2}'`)
730
+ );
731
+ return `Unexpected doc.type '${docType}'.
732
+ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
733
+ }
734
+ var InvalidDocError = class extends Error {
735
+ constructor(doc) {
736
+ super(getDocErrorMessage(doc));
737
+ __publicField(this, "name", "InvalidDocError");
738
+ this.doc = doc;
739
+ }
740
+ };
741
+ var invalid_doc_error_default = InvalidDocError;
742
+
743
+ // src/document/printer.js
744
+ var groupModeMap;
745
+ var MODE_BREAK = 1;
746
+ var MODE_FLAT = 2;
747
+ function rootIndent() {
748
+ return { value: "", length: 0, queue: [] };
749
+ }
750
+ function makeIndent(ind, options) {
751
+ return generateInd(ind, { type: "indent" }, options);
752
+ }
753
+ function makeAlign(indent2, widthOrDoc, options) {
754
+ if (widthOrDoc === Number.NEGATIVE_INFINITY) {
755
+ return indent2.root || rootIndent();
756
+ }
757
+ if (widthOrDoc < 0) {
758
+ return generateInd(indent2, { type: "dedent" }, options);
759
+ }
760
+ if (!widthOrDoc) {
761
+ return indent2;
762
+ }
763
+ if (widthOrDoc.type === "root") {
764
+ return { ...indent2, root: indent2 };
765
+ }
766
+ const alignType = typeof widthOrDoc === "string" ? "stringAlign" : "numberAlign";
767
+ return generateInd(indent2, { type: alignType, n: widthOrDoc }, options);
768
+ }
769
+ function generateInd(ind, newPart, options) {
770
+ const queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : [...ind.queue, newPart];
771
+ let value = "";
772
+ let length = 0;
773
+ let lastTabs = 0;
774
+ let lastSpaces = 0;
775
+ for (const part of queue) {
776
+ switch (part.type) {
777
+ case "indent":
778
+ flush();
779
+ if (options.useTabs) {
780
+ addTabs(1);
781
+ } else {
782
+ addSpaces(options.tabWidth);
514
783
  }
515
- function findInDoc(doc, fn, defaultValue) {
516
- let result = defaultValue;
517
- let hasStopped = false;
518
- function findInDocOnEnterFn(doc2) {
519
- const maybeResult = fn(doc2);
520
- if (maybeResult !== void 0) {
521
- hasStopped = true;
522
- result = maybeResult;
523
- }
524
- if (hasStopped) {
525
- return false;
526
- }
527
- }
528
- traverseDoc(doc, findInDocOnEnterFn);
529
- return result;
784
+ break;
785
+ case "stringAlign":
786
+ flush();
787
+ value += part.n;
788
+ length += part.n.length;
789
+ break;
790
+ case "numberAlign":
791
+ lastTabs += 1;
792
+ lastSpaces += part.n;
793
+ break;
794
+ default:
795
+ throw new Error(`Unexpected type '${part.type}'`);
796
+ }
797
+ }
798
+ flushSpaces();
799
+ return { ...ind, value, length, queue };
800
+ function addTabs(count) {
801
+ value += " ".repeat(count);
802
+ length += options.tabWidth * count;
803
+ }
804
+ function addSpaces(count) {
805
+ value += " ".repeat(count);
806
+ length += count;
807
+ }
808
+ function flush() {
809
+ if (options.useTabs) {
810
+ flushTabs();
811
+ } else {
812
+ flushSpaces();
813
+ }
814
+ }
815
+ function flushTabs() {
816
+ if (lastTabs > 0) {
817
+ addTabs(lastTabs);
818
+ }
819
+ resetLast();
820
+ }
821
+ function flushSpaces() {
822
+ if (lastSpaces > 0) {
823
+ addSpaces(lastSpaces);
824
+ }
825
+ resetLast();
826
+ }
827
+ function resetLast() {
828
+ lastTabs = 0;
829
+ lastSpaces = 0;
830
+ }
831
+ }
832
+ function trim2(out) {
833
+ if (out.length === 0) {
834
+ return 0;
835
+ }
836
+ let trimCount = 0;
837
+ while (out.length > 0 && typeof get_last_default(out) === "string" && /^[\t ]*$/.test(get_last_default(out))) {
838
+ trimCount += out.pop().length;
839
+ }
840
+ if (out.length > 0 && typeof get_last_default(out) === "string") {
841
+ const trimmed = get_last_default(out).replace(/[\t ]*$/, "");
842
+ trimCount += get_last_default(out).length - trimmed.length;
843
+ out[out.length - 1] = trimmed;
844
+ }
845
+ return trimCount;
846
+ }
847
+ function fits(next, restCommands, width, hasLineSuffix, mustBeFlat) {
848
+ let restIdx = restCommands.length;
849
+ const cmds = [next];
850
+ const out = [];
851
+ while (width >= 0) {
852
+ if (cmds.length === 0) {
853
+ if (restIdx === 0) {
854
+ return true;
855
+ }
856
+ cmds.push(restCommands[--restIdx]);
857
+ continue;
858
+ }
859
+ const { mode, doc } = cmds.pop();
860
+ switch (getDocType(doc)) {
861
+ case DOC_TYPE_STRING:
862
+ out.push(doc);
863
+ width -= get_string_width_default(doc);
864
+ break;
865
+ case DOC_TYPE_ARRAY:
866
+ case DOC_TYPE_FILL: {
867
+ const parts = getDocParts(doc);
868
+ for (let i = parts.length - 1; i >= 0; i--) {
869
+ cmds.push({ mode, doc: parts[i] });
530
870
  }
531
- function willBreakFn(doc) {
532
- if (doc.type === "group" && doc.break) {
533
- return true;
534
- }
535
- if (doc.type === "line" && doc.hard) {
536
- return true;
537
- }
538
- if (doc.type === "break-parent") {
539
- return true;
540
- }
871
+ break;
872
+ }
873
+ case DOC_TYPE_INDENT:
874
+ case DOC_TYPE_ALIGN:
875
+ case DOC_TYPE_INDENT_IF_BREAK:
876
+ case DOC_TYPE_LABEL:
877
+ cmds.push({ mode, doc: doc.contents });
878
+ break;
879
+ case DOC_TYPE_TRIM:
880
+ width += trim2(out);
881
+ break;
882
+ case DOC_TYPE_GROUP: {
883
+ if (mustBeFlat && doc.break) {
884
+ return false;
541
885
  }
542
- function willBreak(doc) {
543
- return findInDoc(doc, willBreakFn, false);
886
+ const groupMode = doc.break ? MODE_BREAK : mode;
887
+ const contents = doc.expandedStates && groupMode === MODE_BREAK ? get_last_default(doc.expandedStates) : doc.contents;
888
+ cmds.push({ mode: groupMode, doc: contents });
889
+ break;
890
+ }
891
+ case DOC_TYPE_IF_BREAK: {
892
+ const groupMode = doc.groupId ? groupModeMap[doc.groupId] || MODE_FLAT : mode;
893
+ const contents = groupMode === MODE_BREAK ? doc.breakContents : doc.flatContents;
894
+ if (contents) {
895
+ cmds.push({ mode, doc: contents });
544
896
  }
545
- function breakParentGroup(groupStack) {
546
- if (groupStack.length > 0) {
547
- const parentGroup = getLast(groupStack);
548
- if (!parentGroup.expandedStates && !parentGroup.break) {
549
- parentGroup.break = "propagated";
550
- }
551
- }
552
- return null;
897
+ break;
898
+ }
899
+ case DOC_TYPE_LINE:
900
+ if (mode === MODE_BREAK || doc.hard) {
901
+ return true;
553
902
  }
554
- function propagateBreaks(doc) {
555
- const alreadyVisitedSet = /* @__PURE__ */ new Set();
556
- const groupStack = [];
557
- function propagateBreaksOnEnterFn(doc2) {
558
- if (doc2.type === "break-parent") {
559
- breakParentGroup(groupStack);
560
- }
561
- if (doc2.type === "group") {
562
- groupStack.push(doc2);
563
- if (alreadyVisitedSet.has(doc2)) {
564
- return false;
565
- }
566
- alreadyVisitedSet.add(doc2);
567
- }
568
- }
569
- function propagateBreaksOnExitFn(doc2) {
570
- if (doc2.type === "group") {
571
- const group = groupStack.pop();
572
- if (group.break) {
573
- breakParentGroup(groupStack);
574
- }
575
- }
576
- }
577
- traverseDoc(doc, propagateBreaksOnEnterFn, propagateBreaksOnExitFn, true);
903
+ if (!doc.soft) {
904
+ out.push(" ");
905
+ width--;
578
906
  }
579
- function removeLinesFn(doc) {
580
- if (doc.type === "line" && !doc.hard) {
581
- return doc.soft ? "" : " ";
582
- }
583
- if (doc.type === "if-break") {
584
- return doc.flatContents || "";
585
- }
586
- return doc;
907
+ break;
908
+ case DOC_TYPE_LINE_SUFFIX:
909
+ hasLineSuffix = true;
910
+ break;
911
+ case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
912
+ if (hasLineSuffix) {
913
+ return false;
587
914
  }
588
- function removeLines(doc) {
589
- return mapDoc(doc, removeLinesFn);
915
+ break;
916
+ }
917
+ }
918
+ return false;
919
+ }
920
+ function printDocToString(doc, options) {
921
+ groupModeMap = {};
922
+ const width = options.printWidth;
923
+ const newLine = convertEndOfLineToChars(options.endOfLine);
924
+ let pos = 0;
925
+ const cmds = [{ ind: rootIndent(), mode: MODE_BREAK, doc }];
926
+ const out = [];
927
+ let shouldRemeasure = false;
928
+ const lineSuffix2 = [];
929
+ while (cmds.length > 0) {
930
+ const { ind, mode, doc: doc2 } = cmds.pop();
931
+ switch (getDocType(doc2)) {
932
+ case DOC_TYPE_STRING: {
933
+ const formatted = newLine !== "\n" ? doc2.replace(/\n/g, newLine) : doc2;
934
+ out.push(formatted);
935
+ pos += get_string_width_default(formatted);
936
+ break;
937
+ }
938
+ case DOC_TYPE_ARRAY: {
939
+ for (let i = doc2.length - 1; i >= 0; i--) {
940
+ cmds.push({ ind, mode, doc: doc2[i] });
590
941
  }
591
- var isHardline = (doc, nextDoc) => doc && doc.type === "line" && doc.hard && nextDoc && nextDoc.type === "break-parent";
592
- function stripDocTrailingHardlineFromDoc(doc) {
593
- if (!doc) {
594
- return doc;
595
- }
596
- if (isConcat(doc) || doc.type === "fill") {
597
- const parts = getDocParts(doc);
598
- while (parts.length > 1 && isHardline(...parts.slice(-2))) {
599
- parts.length -= 2;
600
- }
601
- if (parts.length > 0) {
602
- const lastPart = stripDocTrailingHardlineFromDoc(getLast(parts));
603
- parts[parts.length - 1] = lastPart;
604
- }
605
- return Array.isArray(doc) ? parts : Object.assign(Object.assign({}, doc), {}, {
606
- parts
607
- });
608
- }
609
- switch (doc.type) {
610
- case "align":
611
- case "indent":
612
- case "indent-if-break":
613
- case "group":
614
- case "line-suffix":
615
- case "label": {
616
- const contents = stripDocTrailingHardlineFromDoc(doc.contents);
617
- return Object.assign(Object.assign({}, doc), {}, {
618
- contents
619
- });
620
- }
621
- case "if-break": {
622
- const breakContents = stripDocTrailingHardlineFromDoc(doc.breakContents);
623
- const flatContents = stripDocTrailingHardlineFromDoc(doc.flatContents);
624
- return Object.assign(Object.assign({}, doc), {}, {
625
- breakContents,
626
- flatContents
942
+ break;
943
+ }
944
+ case DOC_TYPE_CURSOR:
945
+ out.push(cursor.placeholder);
946
+ break;
947
+ case DOC_TYPE_INDENT:
948
+ cmds.push({ ind: makeIndent(ind, options), mode, doc: doc2.contents });
949
+ break;
950
+ case DOC_TYPE_ALIGN:
951
+ cmds.push({
952
+ ind: makeAlign(ind, doc2.n, options),
953
+ mode,
954
+ doc: doc2.contents
955
+ });
956
+ break;
957
+ case DOC_TYPE_TRIM:
958
+ pos -= trim2(out);
959
+ break;
960
+ case DOC_TYPE_GROUP:
961
+ switch (mode) {
962
+ case MODE_FLAT:
963
+ if (!shouldRemeasure) {
964
+ cmds.push({
965
+ ind,
966
+ mode: doc2.break ? MODE_BREAK : MODE_FLAT,
967
+ doc: doc2.contents
627
968
  });
628
- }
629
- }
630
- return doc;
631
- }
632
- function stripTrailingHardline(doc) {
633
- return stripDocTrailingHardlineFromDoc(cleanDoc(doc));
634
- }
635
- function cleanDocFn(doc) {
636
- switch (doc.type) {
637
- case "fill":
638
- if (doc.parts.every((part) => part === "")) {
639
- return "";
640
- }
641
- break;
642
- case "group":
643
- if (!doc.contents && !doc.id && !doc.break && !doc.expandedStates) {
644
- return "";
645
- }
646
- if (doc.contents.type === "group" && doc.contents.id === doc.id && doc.contents.break === doc.break && doc.contents.expandedStates === doc.expandedStates) {
647
- return doc.contents;
648
- }
649
- break;
650
- case "align":
651
- case "indent":
652
- case "indent-if-break":
653
- case "line-suffix":
654
- if (!doc.contents) {
655
- return "";
656
- }
657
- break;
658
- case "if-break":
659
- if (!doc.flatContents && !doc.breakContents) {
660
- return "";
661
- }
662
969
  break;
663
- }
664
- if (!isConcat(doc)) {
665
- return doc;
666
- }
667
- const parts = [];
668
- for (const part of getDocParts(doc)) {
669
- if (!part) {
670
- continue;
671
970
  }
672
- const [currentPart, ...restParts] = isConcat(part) ? getDocParts(part) : [part];
673
- if (typeof currentPart === "string" && typeof getLast(parts) === "string") {
674
- parts[parts.length - 1] += currentPart;
971
+ case MODE_BREAK: {
972
+ shouldRemeasure = false;
973
+ const next = { ind, mode: MODE_FLAT, doc: doc2.contents };
974
+ const rem = width - pos;
975
+ const hasLineSuffix = lineSuffix2.length > 0;
976
+ if (!doc2.break && fits(next, cmds, rem, hasLineSuffix)) {
977
+ cmds.push(next);
675
978
  } else {
676
- parts.push(currentPart);
677
- }
678
- parts.push(...restParts);
679
- }
680
- if (parts.length === 0) {
681
- return "";
682
- }
683
- if (parts.length === 1) {
684
- return parts[0];
685
- }
686
- return Array.isArray(doc) ? parts : Object.assign(Object.assign({}, doc), {}, {
687
- parts
688
- });
689
- }
690
- function cleanDoc(doc) {
691
- return mapDoc(doc, (currentDoc) => cleanDocFn(currentDoc));
692
- }
693
- function normalizeParts(parts) {
694
- const newParts = [];
695
- const restParts = parts.filter(Boolean);
696
- while (restParts.length > 0) {
697
- const part = restParts.shift();
698
- if (!part) {
699
- continue;
700
- }
701
- if (isConcat(part)) {
702
- restParts.unshift(...getDocParts(part));
703
- continue;
704
- }
705
- if (newParts.length > 0 && typeof getLast(newParts) === "string" && typeof part === "string") {
706
- newParts[newParts.length - 1] += part;
707
- continue;
979
+ if (doc2.expandedStates) {
980
+ const mostExpanded = get_last_default(doc2.expandedStates);
981
+ if (doc2.break) {
982
+ cmds.push({ ind, mode: MODE_BREAK, doc: mostExpanded });
983
+ break;
984
+ } else {
985
+ for (let i = 1; i < doc2.expandedStates.length + 1; i++) {
986
+ if (i >= doc2.expandedStates.length) {
987
+ cmds.push({ ind, mode: MODE_BREAK, doc: mostExpanded });
988
+ break;
989
+ } else {
990
+ const state = doc2.expandedStates[i];
991
+ const cmd = { ind, mode: MODE_FLAT, doc: state };
992
+ if (fits(cmd, cmds, rem, hasLineSuffix)) {
993
+ cmds.push(cmd);
994
+ break;
995
+ }
996
+ }
997
+ }
998
+ }
999
+ } else {
1000
+ cmds.push({ ind, mode: MODE_BREAK, doc: doc2.contents });
1001
+ }
708
1002
  }
709
- newParts.push(part);
1003
+ break;
710
1004
  }
711
- return newParts;
712
1005
  }
713
- function normalizeDoc(doc) {
714
- return mapDoc(doc, (currentDoc) => {
715
- if (Array.isArray(currentDoc)) {
716
- return normalizeParts(currentDoc);
717
- }
718
- if (!currentDoc.parts) {
719
- return currentDoc;
720
- }
721
- return Object.assign(Object.assign({}, currentDoc), {}, {
722
- parts: normalizeParts(currentDoc.parts)
723
- });
724
- });
725
- }
726
- function replaceEndOfLine(doc) {
727
- return mapDoc(doc, (currentDoc) => typeof currentDoc === "string" && currentDoc.includes("\n") ? replaceTextEndOfLine(currentDoc) : currentDoc);
1006
+ if (doc2.id) {
1007
+ groupModeMap[doc2.id] = get_last_default(cmds).mode;
728
1008
  }
729
- function replaceTextEndOfLine(text) {
730
- let replacement = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : literalline;
731
- return join(replacement, text.split("\n")).parts;
1009
+ break;
1010
+ case DOC_TYPE_FILL: {
1011
+ const rem = width - pos;
1012
+ const { parts } = doc2;
1013
+ if (parts.length === 0) {
1014
+ break;
732
1015
  }
733
- function canBreakFn(doc) {
734
- if (doc.type === "line") {
735
- return true;
736
- }
1016
+ const [content, whitespace] = parts;
1017
+ const contentFlatCmd = { ind, mode: MODE_FLAT, doc: content };
1018
+ const contentBreakCmd = { ind, mode: MODE_BREAK, doc: content };
1019
+ const contentFits = fits(
1020
+ contentFlatCmd,
1021
+ [],
1022
+ rem,
1023
+ lineSuffix2.length > 0,
1024
+ true
1025
+ );
1026
+ if (parts.length === 1) {
1027
+ if (contentFits) {
1028
+ cmds.push(contentFlatCmd);
1029
+ } else {
1030
+ cmds.push(contentBreakCmd);
1031
+ }
1032
+ break;
737
1033
  }
738
- function canBreak(doc) {
739
- return findInDoc(doc, canBreakFn, false);
1034
+ const whitespaceFlatCmd = { ind, mode: MODE_FLAT, doc: whitespace };
1035
+ const whitespaceBreakCmd = { ind, mode: MODE_BREAK, doc: whitespace };
1036
+ if (parts.length === 2) {
1037
+ if (contentFits) {
1038
+ cmds.push(whitespaceFlatCmd, contentFlatCmd);
1039
+ } else {
1040
+ cmds.push(whitespaceBreakCmd, contentBreakCmd);
1041
+ }
1042
+ break;
740
1043
  }
741
- module2.exports = {
742
- isConcat,
743
- getDocParts,
744
- willBreak,
745
- traverseDoc,
746
- findInDoc,
747
- mapDoc,
748
- propagateBreaks,
749
- removeLines,
750
- stripTrailingHardline,
751
- normalizeParts,
752
- normalizeDoc,
753
- cleanDoc,
754
- replaceTextEndOfLine,
755
- replaceEndOfLine,
756
- canBreak
1044
+ parts.splice(0, 2);
1045
+ const remainingCmd = { ind, mode, doc: fill(parts) };
1046
+ const secondContent = parts[0];
1047
+ const firstAndSecondContentFlatCmd = {
1048
+ ind,
1049
+ mode: MODE_FLAT,
1050
+ doc: [content, whitespace, secondContent]
757
1051
  };
758
- }
759
- });
760
- var require_doc_printer = __commonJS2({
761
- "src/document/doc-printer.js"(exports2, module2) {
762
- "use strict";
763
- init_define_process();
764
- var {
765
- convertEndOfLineToChars
766
- } = require_end_of_line();
767
- var getLast = require_get_last();
768
- var getStringWidth = require_get_string_width();
769
- var {
770
- fill,
771
- cursor,
772
- indent
773
- } = require_doc_builders();
774
- var {
775
- isConcat,
776
- getDocParts
777
- } = require_doc_utils();
778
- var groupModeMap;
779
- var MODE_BREAK = 1;
780
- var MODE_FLAT = 2;
781
- function rootIndent() {
782
- return {
783
- value: "",
784
- length: 0,
785
- queue: []
786
- };
787
- }
788
- function makeIndent(ind, options) {
789
- return generateInd(ind, {
790
- type: "indent"
791
- }, options);
792
- }
793
- function makeAlign(indent2, widthOrDoc, options) {
794
- if (widthOrDoc === Number.NEGATIVE_INFINITY) {
795
- return indent2.root || rootIndent();
796
- }
797
- if (widthOrDoc < 0) {
798
- return generateInd(indent2, {
799
- type: "dedent"
800
- }, options);
801
- }
802
- if (!widthOrDoc) {
803
- return indent2;
804
- }
805
- if (widthOrDoc.type === "root") {
806
- return Object.assign(Object.assign({}, indent2), {}, {
807
- root: indent2
808
- });
809
- }
810
- const alignType = typeof widthOrDoc === "string" ? "stringAlign" : "numberAlign";
811
- return generateInd(indent2, {
812
- type: alignType,
813
- n: widthOrDoc
814
- }, options);
1052
+ const firstAndSecondContentFits = fits(
1053
+ firstAndSecondContentFlatCmd,
1054
+ [],
1055
+ rem,
1056
+ lineSuffix2.length > 0,
1057
+ true
1058
+ );
1059
+ if (firstAndSecondContentFits) {
1060
+ cmds.push(remainingCmd, whitespaceFlatCmd, contentFlatCmd);
1061
+ } else if (contentFits) {
1062
+ cmds.push(remainingCmd, whitespaceBreakCmd, contentFlatCmd);
1063
+ } else {
1064
+ cmds.push(remainingCmd, whitespaceBreakCmd, contentBreakCmd);
815
1065
  }
816
- function generateInd(ind, newPart, options) {
817
- const queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : [...ind.queue, newPart];
818
- let value = "";
819
- let length = 0;
820
- let lastTabs = 0;
821
- let lastSpaces = 0;
822
- for (const part of queue) {
823
- switch (part.type) {
824
- case "indent":
825
- flush();
826
- if (options.useTabs) {
827
- addTabs(1);
828
- } else {
829
- addSpaces(options.tabWidth);
830
- }
831
- break;
832
- case "stringAlign":
833
- flush();
834
- value += part.n;
835
- length += part.n.length;
836
- break;
837
- case "numberAlign":
838
- lastTabs += 1;
839
- lastSpaces += part.n;
840
- break;
841
- default:
842
- throw new Error("Unexpected type '".concat(part.type, "'"));
843
- }
844
- }
845
- flushSpaces();
846
- return Object.assign(Object.assign({}, ind), {}, {
847
- value,
848
- length,
849
- queue
850
- });
851
- function addTabs(count) {
852
- value += " ".repeat(count);
853
- length += options.tabWidth * count;
854
- }
855
- function addSpaces(count) {
856
- value += " ".repeat(count);
857
- length += count;
858
- }
859
- function flush() {
860
- if (options.useTabs) {
861
- flushTabs();
862
- } else {
863
- flushSpaces();
864
- }
865
- }
866
- function flushTabs() {
867
- if (lastTabs > 0) {
868
- addTabs(lastTabs);
869
- }
870
- resetLast();
871
- }
872
- function flushSpaces() {
873
- if (lastSpaces > 0) {
874
- addSpaces(lastSpaces);
875
- }
876
- resetLast();
877
- }
878
- function resetLast() {
879
- lastTabs = 0;
880
- lastSpaces = 0;
1066
+ break;
1067
+ }
1068
+ case DOC_TYPE_IF_BREAK:
1069
+ case DOC_TYPE_INDENT_IF_BREAK: {
1070
+ const groupMode = doc2.groupId ? groupModeMap[doc2.groupId] : mode;
1071
+ if (groupMode === MODE_BREAK) {
1072
+ const breakContents = doc2.type === DOC_TYPE_IF_BREAK ? doc2.breakContents : doc2.negate ? doc2.contents : indent(doc2.contents);
1073
+ if (breakContents) {
1074
+ cmds.push({ ind, mode, doc: breakContents });
881
1075
  }
882
1076
  }
883
- function trim(out) {
884
- if (out.length === 0) {
885
- return 0;
886
- }
887
- let trimCount = 0;
888
- while (out.length > 0 && typeof getLast(out) === "string" && /^[\t ]*$/.test(getLast(out))) {
889
- trimCount += out.pop().length;
890
- }
891
- if (out.length > 0 && typeof getLast(out) === "string") {
892
- const trimmed = getLast(out).replace(/[\t ]*$/, "");
893
- trimCount += getLast(out).length - trimmed.length;
894
- out[out.length - 1] = trimmed;
1077
+ if (groupMode === MODE_FLAT) {
1078
+ const flatContents = doc2.type === DOC_TYPE_IF_BREAK ? doc2.flatContents : doc2.negate ? indent(doc2.contents) : doc2.contents;
1079
+ if (flatContents) {
1080
+ cmds.push({ ind, mode, doc: flatContents });
895
1081
  }
896
- return trimCount;
897
1082
  }
898
- function fits(next, restCommands, width, options, hasLineSuffix, mustBeFlat) {
899
- let restIdx = restCommands.length;
900
- const cmds = [next];
901
- const out = [];
902
- while (width >= 0) {
903
- if (cmds.length === 0) {
904
- if (restIdx === 0) {
905
- return true;
906
- }
907
- cmds.push(restCommands[restIdx - 1]);
908
- restIdx--;
909
- continue;
910
- }
911
- const [ind, mode, doc] = cmds.pop();
912
- if (typeof doc === "string") {
913
- out.push(doc);
914
- width -= getStringWidth(doc);
915
- } else if (isConcat(doc)) {
916
- const parts = getDocParts(doc);
917
- for (let i = parts.length - 1; i >= 0; i--) {
918
- cmds.push([ind, mode, parts[i]]);
919
- }
920
- } else {
921
- switch (doc.type) {
922
- case "indent":
923
- cmds.push([makeIndent(ind, options), mode, doc.contents]);
924
- break;
925
- case "align":
926
- cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]);
927
- break;
928
- case "trim":
929
- width += trim(out);
930
- break;
931
- case "group": {
932
- if (mustBeFlat && doc.break) {
933
- return false;
934
- }
935
- const groupMode = doc.break ? MODE_BREAK : mode;
936
- cmds.push([ind, groupMode, doc.expandedStates && groupMode === MODE_BREAK ? getLast(doc.expandedStates) : doc.contents]);
937
- if (doc.id) {
938
- groupModeMap[doc.id] = groupMode;
939
- }
940
- break;
941
- }
942
- case "fill":
943
- for (let i = doc.parts.length - 1; i >= 0; i--) {
944
- cmds.push([ind, mode, doc.parts[i]]);
945
- }
946
- break;
947
- case "if-break":
948
- case "indent-if-break": {
949
- const groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
950
- if (groupMode === MODE_BREAK) {
951
- const breakContents = doc.type === "if-break" ? doc.breakContents : doc.negate ? doc.contents : indent(doc.contents);
952
- if (breakContents) {
953
- cmds.push([ind, mode, breakContents]);
954
- }
955
- }
956
- if (groupMode === MODE_FLAT) {
957
- const flatContents = doc.type === "if-break" ? doc.flatContents : doc.negate ? indent(doc.contents) : doc.contents;
958
- if (flatContents) {
959
- cmds.push([ind, mode, flatContents]);
960
- }
961
- }
962
- break;
963
- }
964
- case "line":
965
- switch (mode) {
966
- case MODE_FLAT:
967
- if (!doc.hard) {
968
- if (!doc.soft) {
969
- out.push(" ");
970
- width -= 1;
971
- }
972
- break;
973
- }
974
- return true;
975
- case MODE_BREAK:
976
- return true;
977
- }
978
- break;
979
- case "line-suffix":
980
- hasLineSuffix = true;
981
- break;
982
- case "line-suffix-boundary":
983
- if (hasLineSuffix) {
984
- return false;
985
- }
986
- break;
987
- case "label":
988
- cmds.push([ind, mode, doc.contents]);
989
- break;
990
- }
991
- }
992
- }
993
- return false;
1083
+ break;
1084
+ }
1085
+ case DOC_TYPE_LINE_SUFFIX:
1086
+ lineSuffix2.push({ ind, mode, doc: doc2.contents });
1087
+ break;
1088
+ case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
1089
+ if (lineSuffix2.length > 0) {
1090
+ cmds.push({ ind, mode, doc: hardlineWithoutBreakParent });
994
1091
  }
995
- function printDocToString(doc, options) {
996
- groupModeMap = {};
997
- const width = options.printWidth;
998
- const newLine = convertEndOfLineToChars(options.endOfLine);
999
- let pos = 0;
1000
- const cmds = [[rootIndent(), MODE_BREAK, doc]];
1001
- const out = [];
1002
- let shouldRemeasure = false;
1003
- let lineSuffix = [];
1004
- while (cmds.length > 0) {
1005
- const [ind, mode, doc2] = cmds.pop();
1006
- if (typeof doc2 === "string") {
1007
- const formatted = newLine !== "\n" ? doc2.replace(/\n/g, newLine) : doc2;
1008
- out.push(formatted);
1009
- pos += getStringWidth(formatted);
1010
- } else if (isConcat(doc2)) {
1011
- const parts = getDocParts(doc2);
1012
- for (let i = parts.length - 1; i >= 0; i--) {
1013
- cmds.push([ind, mode, parts[i]]);
1092
+ break;
1093
+ case DOC_TYPE_LINE:
1094
+ switch (mode) {
1095
+ case MODE_FLAT:
1096
+ if (!doc2.hard) {
1097
+ if (!doc2.soft) {
1098
+ out.push(" ");
1099
+ pos += 1;
1014
1100
  }
1101
+ break;
1015
1102
  } else {
1016
- switch (doc2.type) {
1017
- case "cursor":
1018
- out.push(cursor.placeholder);
1019
- break;
1020
- case "indent":
1021
- cmds.push([makeIndent(ind, options), mode, doc2.contents]);
1022
- break;
1023
- case "align":
1024
- cmds.push([makeAlign(ind, doc2.n, options), mode, doc2.contents]);
1025
- break;
1026
- case "trim":
1027
- pos -= trim(out);
1028
- break;
1029
- case "group":
1030
- switch (mode) {
1031
- case MODE_FLAT:
1032
- if (!shouldRemeasure) {
1033
- cmds.push([ind, doc2.break ? MODE_BREAK : MODE_FLAT, doc2.contents]);
1034
- break;
1035
- }
1036
- case MODE_BREAK: {
1037
- shouldRemeasure = false;
1038
- const next = [ind, MODE_FLAT, doc2.contents];
1039
- const rem = width - pos;
1040
- const hasLineSuffix = lineSuffix.length > 0;
1041
- if (!doc2.break && fits(next, cmds, rem, options, hasLineSuffix)) {
1042
- cmds.push(next);
1043
- } else {
1044
- if (doc2.expandedStates) {
1045
- const mostExpanded = getLast(doc2.expandedStates);
1046
- if (doc2.break) {
1047
- cmds.push([ind, MODE_BREAK, mostExpanded]);
1048
- break;
1049
- } else {
1050
- for (let i = 1; i < doc2.expandedStates.length + 1; i++) {
1051
- if (i >= doc2.expandedStates.length) {
1052
- cmds.push([ind, MODE_BREAK, mostExpanded]);
1053
- break;
1054
- } else {
1055
- const state = doc2.expandedStates[i];
1056
- const cmd = [ind, MODE_FLAT, state];
1057
- if (fits(cmd, cmds, rem, options, hasLineSuffix)) {
1058
- cmds.push(cmd);
1059
- break;
1060
- }
1061
- }
1062
- }
1063
- }
1064
- } else {
1065
- cmds.push([ind, MODE_BREAK, doc2.contents]);
1066
- }
1067
- }
1068
- break;
1069
- }
1070
- }
1071
- if (doc2.id) {
1072
- groupModeMap[doc2.id] = getLast(cmds)[1];
1073
- }
1074
- break;
1075
- case "fill": {
1076
- const rem = width - pos;
1077
- const {
1078
- parts
1079
- } = doc2;
1080
- if (parts.length === 0) {
1081
- break;
1082
- }
1083
- const [content, whitespace] = parts;
1084
- const contentFlatCmd = [ind, MODE_FLAT, content];
1085
- const contentBreakCmd = [ind, MODE_BREAK, content];
1086
- const contentFits = fits(contentFlatCmd, [], rem, options, lineSuffix.length > 0, true);
1087
- if (parts.length === 1) {
1088
- if (contentFits) {
1089
- cmds.push(contentFlatCmd);
1090
- } else {
1091
- cmds.push(contentBreakCmd);
1092
- }
1093
- break;
1094
- }
1095
- const whitespaceFlatCmd = [ind, MODE_FLAT, whitespace];
1096
- const whitespaceBreakCmd = [ind, MODE_BREAK, whitespace];
1097
- if (parts.length === 2) {
1098
- if (contentFits) {
1099
- cmds.push(whitespaceFlatCmd, contentFlatCmd);
1100
- } else {
1101
- cmds.push(whitespaceBreakCmd, contentBreakCmd);
1102
- }
1103
- break;
1104
- }
1105
- parts.splice(0, 2);
1106
- const remainingCmd = [ind, mode, fill(parts)];
1107
- const secondContent = parts[0];
1108
- const firstAndSecondContentFlatCmd = [ind, MODE_FLAT, [content, whitespace, secondContent]];
1109
- const firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], rem, options, lineSuffix.length > 0, true);
1110
- if (firstAndSecondContentFits) {
1111
- cmds.push(remainingCmd, whitespaceFlatCmd, contentFlatCmd);
1112
- } else if (contentFits) {
1113
- cmds.push(remainingCmd, whitespaceBreakCmd, contentFlatCmd);
1114
- } else {
1115
- cmds.push(remainingCmd, whitespaceBreakCmd, contentBreakCmd);
1116
- }
1117
- break;
1118
- }
1119
- case "if-break":
1120
- case "indent-if-break": {
1121
- const groupMode = doc2.groupId ? groupModeMap[doc2.groupId] : mode;
1122
- if (groupMode === MODE_BREAK) {
1123
- const breakContents = doc2.type === "if-break" ? doc2.breakContents : doc2.negate ? doc2.contents : indent(doc2.contents);
1124
- if (breakContents) {
1125
- cmds.push([ind, mode, breakContents]);
1126
- }
1127
- }
1128
- if (groupMode === MODE_FLAT) {
1129
- const flatContents = doc2.type === "if-break" ? doc2.flatContents : doc2.negate ? indent(doc2.contents) : doc2.contents;
1130
- if (flatContents) {
1131
- cmds.push([ind, mode, flatContents]);
1132
- }
1133
- }
1134
- break;
1135
- }
1136
- case "line-suffix":
1137
- lineSuffix.push([ind, mode, doc2.contents]);
1138
- break;
1139
- case "line-suffix-boundary":
1140
- if (lineSuffix.length > 0) {
1141
- cmds.push([ind, mode, {
1142
- type: "line",
1143
- hard: true
1144
- }]);
1145
- }
1146
- break;
1147
- case "line":
1148
- switch (mode) {
1149
- case MODE_FLAT:
1150
- if (!doc2.hard) {
1151
- if (!doc2.soft) {
1152
- out.push(" ");
1153
- pos += 1;
1154
- }
1155
- break;
1156
- } else {
1157
- shouldRemeasure = true;
1158
- }
1159
- case MODE_BREAK:
1160
- if (lineSuffix.length > 0) {
1161
- cmds.push([ind, mode, doc2], ...lineSuffix.reverse());
1162
- lineSuffix = [];
1163
- break;
1164
- }
1165
- if (doc2.literal) {
1166
- if (ind.root) {
1167
- out.push(newLine, ind.root.value);
1168
- pos = ind.root.length;
1169
- } else {
1170
- out.push(newLine);
1171
- pos = 0;
1172
- }
1173
- } else {
1174
- pos -= trim(out);
1175
- out.push(newLine + ind.value);
1176
- pos = ind.length;
1177
- }
1178
- break;
1179
- }
1180
- break;
1181
- case "label":
1182
- cmds.push([ind, mode, doc2.contents]);
1183
- break;
1184
- default:
1185
- }
1103
+ shouldRemeasure = true;
1186
1104
  }
1187
- if (cmds.length === 0 && lineSuffix.length > 0) {
1188
- cmds.push(...lineSuffix.reverse());
1189
- lineSuffix = [];
1105
+ case MODE_BREAK:
1106
+ if (lineSuffix2.length > 0) {
1107
+ cmds.push({ ind, mode, doc: doc2 }, ...lineSuffix2.reverse());
1108
+ lineSuffix2.length = 0;
1109
+ break;
1190
1110
  }
1191
- }
1192
- const cursorPlaceholderIndex = out.indexOf(cursor.placeholder);
1193
- if (cursorPlaceholderIndex !== -1) {
1194
- const otherCursorPlaceholderIndex = out.indexOf(cursor.placeholder, cursorPlaceholderIndex + 1);
1195
- const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
1196
- const aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
1197
- const afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
1198
- return {
1199
- formatted: beforeCursor + aroundCursor + afterCursor,
1200
- cursorNodeStart: beforeCursor.length,
1201
- cursorNodeText: aroundCursor
1202
- };
1203
- }
1204
- return {
1205
- formatted: out.join("")
1206
- };
1207
- }
1208
- module2.exports = {
1209
- printDocToString
1210
- };
1211
- }
1212
- });
1213
- var require_doc_debug = __commonJS2({
1214
- "src/document/doc-debug.js"(exports2, module2) {
1215
- "use strict";
1216
- init_define_process();
1217
- var {
1218
- isConcat,
1219
- getDocParts
1220
- } = require_doc_utils();
1221
- function flattenDoc(doc) {
1222
- if (!doc) {
1223
- return "";
1224
- }
1225
- if (isConcat(doc)) {
1226
- const res = [];
1227
- for (const part of getDocParts(doc)) {
1228
- if (isConcat(part)) {
1229
- res.push(...flattenDoc(part).parts);
1111
+ if (doc2.literal) {
1112
+ if (ind.root) {
1113
+ out.push(newLine, ind.root.value);
1114
+ pos = ind.root.length;
1230
1115
  } else {
1231
- const flattened = flattenDoc(part);
1232
- if (flattened !== "") {
1233
- res.push(flattened);
1234
- }
1116
+ out.push(newLine);
1117
+ pos = 0;
1235
1118
  }
1119
+ } else {
1120
+ pos -= trim2(out);
1121
+ out.push(newLine + ind.value);
1122
+ pos = ind.length;
1236
1123
  }
1237
- return {
1238
- type: "concat",
1239
- parts: res
1240
- };
1241
- }
1242
- if (doc.type === "if-break") {
1243
- return Object.assign(Object.assign({}, doc), {}, {
1244
- breakContents: flattenDoc(doc.breakContents),
1245
- flatContents: flattenDoc(doc.flatContents)
1246
- });
1247
- }
1248
- if (doc.type === "group") {
1249
- return Object.assign(Object.assign({}, doc), {}, {
1250
- contents: flattenDoc(doc.contents),
1251
- expandedStates: doc.expandedStates && doc.expandedStates.map(flattenDoc)
1252
- });
1253
- }
1254
- if (doc.type === "fill") {
1255
- return {
1256
- type: "fill",
1257
- parts: doc.parts.map(flattenDoc)
1258
- };
1259
- }
1260
- if (doc.contents) {
1261
- return Object.assign(Object.assign({}, doc), {}, {
1262
- contents: flattenDoc(doc.contents)
1263
- });
1264
- }
1265
- return doc;
1124
+ break;
1266
1125
  }
1267
- function printDocToDebug(doc) {
1268
- const printedSymbols = /* @__PURE__ */ Object.create(null);
1269
- const usedKeysForSymbols = /* @__PURE__ */ new Set();
1270
- return printDoc(flattenDoc(doc));
1271
- function printDoc(doc2, index, parentParts) {
1272
- if (typeof doc2 === "string") {
1273
- return JSON.stringify(doc2);
1274
- }
1275
- if (isConcat(doc2)) {
1276
- const printed = getDocParts(doc2).map(printDoc).filter(Boolean);
1277
- return printed.length === 1 ? printed[0] : "[".concat(printed.join(", "), "]");
1278
- }
1279
- if (doc2.type === "line") {
1280
- const withBreakParent = Array.isArray(parentParts) && parentParts[index + 1] && parentParts[index + 1].type === "break-parent";
1281
- if (doc2.literal) {
1282
- return withBreakParent ? "literalline" : "literallineWithoutBreakParent";
1283
- }
1284
- if (doc2.hard) {
1285
- return withBreakParent ? "hardline" : "hardlineWithoutBreakParent";
1286
- }
1287
- if (doc2.soft) {
1288
- return "softline";
1289
- }
1290
- return "line";
1291
- }
1292
- if (doc2.type === "break-parent") {
1293
- const afterHardline = Array.isArray(parentParts) && parentParts[index - 1] && parentParts[index - 1].type === "line" && parentParts[index - 1].hard;
1294
- return afterHardline ? void 0 : "breakParent";
1295
- }
1296
- if (doc2.type === "trim") {
1297
- return "trim";
1298
- }
1299
- if (doc2.type === "indent") {
1300
- return "indent(" + printDoc(doc2.contents) + ")";
1301
- }
1302
- if (doc2.type === "align") {
1303
- return doc2.n === Number.NEGATIVE_INFINITY ? "dedentToRoot(" + printDoc(doc2.contents) + ")" : doc2.n < 0 ? "dedent(" + printDoc(doc2.contents) + ")" : doc2.n.type === "root" ? "markAsRoot(" + printDoc(doc2.contents) + ")" : "align(" + JSON.stringify(doc2.n) + ", " + printDoc(doc2.contents) + ")";
1304
- }
1305
- if (doc2.type === "if-break") {
1306
- return "ifBreak(" + printDoc(doc2.breakContents) + (doc2.flatContents ? ", " + printDoc(doc2.flatContents) : "") + (doc2.groupId ? (!doc2.flatContents ? ', ""' : "") + ", { groupId: ".concat(printGroupId(doc2.groupId), " }") : "") + ")";
1307
- }
1308
- if (doc2.type === "indent-if-break") {
1309
- const optionsParts = [];
1310
- if (doc2.negate) {
1311
- optionsParts.push("negate: true");
1312
- }
1313
- if (doc2.groupId) {
1314
- optionsParts.push("groupId: ".concat(printGroupId(doc2.groupId)));
1315
- }
1316
- const options = optionsParts.length > 0 ? ", { ".concat(optionsParts.join(", "), " }") : "";
1317
- return "indentIfBreak(".concat(printDoc(doc2.contents)).concat(options, ")");
1318
- }
1319
- if (doc2.type === "group") {
1320
- const optionsParts = [];
1321
- if (doc2.break && doc2.break !== "propagated") {
1322
- optionsParts.push("shouldBreak: true");
1323
- }
1324
- if (doc2.id) {
1325
- optionsParts.push("id: ".concat(printGroupId(doc2.id)));
1326
- }
1327
- const options = optionsParts.length > 0 ? ", { ".concat(optionsParts.join(", "), " }") : "";
1328
- if (doc2.expandedStates) {
1329
- return "conditionalGroup([".concat(doc2.expandedStates.map((part) => printDoc(part)).join(","), "]").concat(options, ")");
1330
- }
1331
- return "group(".concat(printDoc(doc2.contents)).concat(options, ")");
1332
- }
1333
- if (doc2.type === "fill") {
1334
- return "fill([".concat(doc2.parts.map((part) => printDoc(part)).join(", "), "])");
1335
- }
1336
- if (doc2.type === "line-suffix") {
1337
- return "lineSuffix(" + printDoc(doc2.contents) + ")";
1338
- }
1339
- if (doc2.type === "line-suffix-boundary") {
1340
- return "lineSuffixBoundary";
1341
- }
1342
- if (doc2.type === "label") {
1343
- return "label(".concat(JSON.stringify(doc2.label), ", ").concat(printDoc(doc2.contents), ")");
1344
- }
1345
- throw new Error("Unknown doc type " + doc2.type);
1346
- }
1347
- function printGroupId(id) {
1348
- if (typeof id !== "symbol") {
1349
- return JSON.stringify(String(id));
1350
- }
1351
- if (id in printedSymbols) {
1352
- return printedSymbols[id];
1353
- }
1354
- const prefix = String(id).slice(7, -1) || "symbol";
1355
- for (let counter = 0; ; counter++) {
1356
- const key = prefix + (counter > 0 ? " #".concat(counter) : "");
1357
- if (!usedKeysForSymbols.has(key)) {
1358
- usedKeysForSymbols.add(key);
1359
- return printedSymbols[id] = "Symbol.for(".concat(JSON.stringify(key), ")");
1360
- }
1361
- }
1362
- }
1126
+ break;
1127
+ case DOC_TYPE_LABEL:
1128
+ cmds.push({ ind, mode, doc: doc2.contents });
1129
+ break;
1130
+ case DOC_TYPE_BREAK_PARENT:
1131
+ break;
1132
+ default:
1133
+ throw new invalid_doc_error_default(doc2);
1134
+ }
1135
+ if (cmds.length === 0 && lineSuffix2.length > 0) {
1136
+ cmds.push(...lineSuffix2.reverse());
1137
+ lineSuffix2.length = 0;
1138
+ }
1139
+ }
1140
+ const cursorPlaceholderIndex = out.indexOf(cursor.placeholder);
1141
+ if (cursorPlaceholderIndex !== -1) {
1142
+ const otherCursorPlaceholderIndex = out.indexOf(
1143
+ cursor.placeholder,
1144
+ cursorPlaceholderIndex + 1
1145
+ );
1146
+ const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
1147
+ const aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
1148
+ const afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
1149
+ return {
1150
+ formatted: beforeCursor + aroundCursor + afterCursor,
1151
+ cursorNodeStart: beforeCursor.length,
1152
+ cursorNodeText: aroundCursor
1153
+ };
1154
+ }
1155
+ return { formatted: out.join("") };
1156
+ }
1157
+
1158
+ // src/document/debug.js
1159
+ var debug_exports = {};
1160
+ __export(debug_exports, {
1161
+ printDocToDebug: () => printDocToDebug
1162
+ });
1163
+ init_define_process();
1164
+ function flattenDoc(doc) {
1165
+ if (!doc) {
1166
+ return "";
1167
+ }
1168
+ if (Array.isArray(doc)) {
1169
+ const res = [];
1170
+ for (const part of doc) {
1171
+ if (Array.isArray(part)) {
1172
+ res.push(...flattenDoc(part));
1173
+ } else {
1174
+ const flattened = flattenDoc(part);
1175
+ if (flattened !== "") {
1176
+ res.push(flattened);
1363
1177
  }
1364
- module2.exports = {
1365
- printDocToDebug
1366
- };
1367
1178
  }
1368
- });
1369
- init_define_process();
1370
- module.exports = {
1371
- builders: require_doc_builders(),
1372
- printer: require_doc_printer(),
1373
- utils: require_doc_utils(),
1374
- debug: require_doc_debug()
1179
+ }
1180
+ return res;
1181
+ }
1182
+ if (doc.type === DOC_TYPE_IF_BREAK) {
1183
+ return {
1184
+ ...doc,
1185
+ breakContents: flattenDoc(doc.breakContents),
1186
+ flatContents: flattenDoc(doc.flatContents)
1375
1187
  };
1376
1188
  }
1377
- });
1378
- "use strict";
1379
- return require_doc();
1189
+ if (doc.type === DOC_TYPE_GROUP) {
1190
+ return {
1191
+ ...doc,
1192
+ contents: flattenDoc(doc.contents),
1193
+ expandedStates: doc.expandedStates && doc.expandedStates.map(flattenDoc)
1194
+ };
1195
+ }
1196
+ if (doc.type === DOC_TYPE_FILL) {
1197
+ return { type: "fill", parts: doc.parts.map(flattenDoc) };
1198
+ }
1199
+ if (doc.contents) {
1200
+ return { ...doc, contents: flattenDoc(doc.contents) };
1201
+ }
1202
+ return doc;
1203
+ }
1204
+ function printDocToDebug(doc) {
1205
+ const printedSymbols = /* @__PURE__ */ Object.create(null);
1206
+ const usedKeysForSymbols = /* @__PURE__ */ new Set();
1207
+ return printDoc(flattenDoc(doc));
1208
+ function printDoc(doc2, index, parentParts) {
1209
+ if (typeof doc2 === "string") {
1210
+ return JSON.stringify(doc2);
1211
+ }
1212
+ if (Array.isArray(doc2)) {
1213
+ const printed = doc2.map(printDoc).filter(Boolean);
1214
+ return printed.length === 1 ? printed[0] : `[${printed.join(", ")}]`;
1215
+ }
1216
+ if (doc2.type === DOC_TYPE_LINE) {
1217
+ const withBreakParent = Array.isArray(parentParts) && parentParts[index + 1] && parentParts[index + 1].type === DOC_TYPE_BREAK_PARENT;
1218
+ if (doc2.literal) {
1219
+ return withBreakParent ? "literalline" : "literallineWithoutBreakParent";
1220
+ }
1221
+ if (doc2.hard) {
1222
+ return withBreakParent ? "hardline" : "hardlineWithoutBreakParent";
1223
+ }
1224
+ if (doc2.soft) {
1225
+ return "softline";
1226
+ }
1227
+ return "line";
1228
+ }
1229
+ if (doc2.type === DOC_TYPE_BREAK_PARENT) {
1230
+ const afterHardline = Array.isArray(parentParts) && parentParts[index - 1] && parentParts[index - 1].type === DOC_TYPE_LINE && parentParts[index - 1].hard;
1231
+ return afterHardline ? void 0 : "breakParent";
1232
+ }
1233
+ if (doc2.type === DOC_TYPE_TRIM) {
1234
+ return "trim";
1235
+ }
1236
+ if (doc2.type === DOC_TYPE_INDENT) {
1237
+ return "indent(" + printDoc(doc2.contents) + ")";
1238
+ }
1239
+ if (doc2.type === DOC_TYPE_ALIGN) {
1240
+ return doc2.n === Number.NEGATIVE_INFINITY ? "dedentToRoot(" + printDoc(doc2.contents) + ")" : doc2.n < 0 ? "dedent(" + printDoc(doc2.contents) + ")" : doc2.n.type === "root" ? "markAsRoot(" + printDoc(doc2.contents) + ")" : "align(" + JSON.stringify(doc2.n) + ", " + printDoc(doc2.contents) + ")";
1241
+ }
1242
+ if (doc2.type === DOC_TYPE_IF_BREAK) {
1243
+ return "ifBreak(" + printDoc(doc2.breakContents) + (doc2.flatContents ? ", " + printDoc(doc2.flatContents) : "") + (doc2.groupId ? (!doc2.flatContents ? ', ""' : "") + `, { groupId: ${printGroupId(doc2.groupId)} }` : "") + ")";
1244
+ }
1245
+ if (doc2.type === DOC_TYPE_INDENT_IF_BREAK) {
1246
+ const optionsParts = [];
1247
+ if (doc2.negate) {
1248
+ optionsParts.push("negate: true");
1249
+ }
1250
+ if (doc2.groupId) {
1251
+ optionsParts.push(`groupId: ${printGroupId(doc2.groupId)}`);
1252
+ }
1253
+ const options = optionsParts.length > 0 ? `, { ${optionsParts.join(", ")} }` : "";
1254
+ return `indentIfBreak(${printDoc(doc2.contents)}${options})`;
1255
+ }
1256
+ if (doc2.type === DOC_TYPE_GROUP) {
1257
+ const optionsParts = [];
1258
+ if (doc2.break && doc2.break !== "propagated") {
1259
+ optionsParts.push("shouldBreak: true");
1260
+ }
1261
+ if (doc2.id) {
1262
+ optionsParts.push(`id: ${printGroupId(doc2.id)}`);
1263
+ }
1264
+ const options = optionsParts.length > 0 ? `, { ${optionsParts.join(", ")} }` : "";
1265
+ if (doc2.expandedStates) {
1266
+ return `conditionalGroup([${doc2.expandedStates.map((part) => printDoc(part)).join(",")}]${options})`;
1267
+ }
1268
+ return `group(${printDoc(doc2.contents)}${options})`;
1269
+ }
1270
+ if (doc2.type === DOC_TYPE_FILL) {
1271
+ return `fill([${doc2.parts.map((part) => printDoc(part)).join(", ")}])`;
1272
+ }
1273
+ if (doc2.type === DOC_TYPE_LINE_SUFFIX) {
1274
+ return "lineSuffix(" + printDoc(doc2.contents) + ")";
1275
+ }
1276
+ if (doc2.type === DOC_TYPE_LINE_SUFFIX_BOUNDARY) {
1277
+ return "lineSuffixBoundary";
1278
+ }
1279
+ if (doc2.type === DOC_TYPE_LABEL) {
1280
+ return `label(${JSON.stringify(doc2.label)}, ${printDoc(doc2.contents)})`;
1281
+ }
1282
+ throw new Error("Unknown doc type " + doc2.type);
1283
+ }
1284
+ function printGroupId(id) {
1285
+ if (typeof id !== "symbol") {
1286
+ return JSON.stringify(String(id));
1287
+ }
1288
+ if (id in printedSymbols) {
1289
+ return printedSymbols[id];
1290
+ }
1291
+ const prefix = id.description || "symbol";
1292
+ for (let counter = 0; ; counter++) {
1293
+ const key = prefix + (counter > 0 ? ` #${counter}` : "");
1294
+ if (!usedKeysForSymbols.has(key)) {
1295
+ usedKeysForSymbols.add(key);
1296
+ return printedSymbols[id] = `Symbol.for(${JSON.stringify(key)})`;
1297
+ }
1298
+ }
1299
+ }
1300
+ }
1301
+ return __toCommonJS(document_exports);
1380
1302
  });