doc.js 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473
  1. (function (factory) {
  2. if (typeof exports === "object" && typeof module === "object") {
  3. module.exports = factory();
  4. } else if (typeof define === "function" && define.amd) {
  5. define(factory);
  6. } else {
  7. var root =
  8. typeof globalThis !== "undefined"
  9. ? globalThis
  10. : typeof global !== "undefined"
  11. ? global
  12. : typeof self !== "undefined"
  13. ? self
  14. : this || {};
  15. root.doc = factory();
  16. }
  17. })(function() {
  18. "use strict";
  19. var __getOwnPropNames = Object.getOwnPropertyNames;
  20. var __commonJS = (cb, mod) => function __require() {
  21. return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  22. };
  23. // dist/_doc.js.umd.js
  24. var require_doc_js_umd = __commonJS({
  25. "dist/_doc.js.umd.js"(exports, module) {
  26. var __create = Object.create;
  27. var __defProp = Object.defineProperty;
  28. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  29. var __getOwnPropNames2 = Object.getOwnPropertyNames;
  30. var __getProtoOf = Object.getPrototypeOf;
  31. var __hasOwnProp = Object.prototype.hasOwnProperty;
  32. var __esm = (fn, res) => function __init() {
  33. return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
  34. };
  35. var __commonJS2 = (cb, mod) => function __require() {
  36. return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = {
  37. exports: {}
  38. }).exports, mod), mod.exports;
  39. };
  40. var __export = (target, all) => {
  41. for (var name in all)
  42. __defProp(target, name, {
  43. get: all[name],
  44. enumerable: true
  45. });
  46. };
  47. var __copyProps = (to, from, except, desc) => {
  48. if (from && typeof from === "object" || typeof from === "function") {
  49. for (let key of __getOwnPropNames2(from))
  50. if (!__hasOwnProp.call(to, key) && key !== except)
  51. __defProp(to, key, {
  52. get: () => from[key],
  53. enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
  54. });
  55. }
  56. return to;
  57. };
  58. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
  59. value: mod,
  60. enumerable: true
  61. }) : target, mod));
  62. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", {
  63. value: true
  64. }), mod);
  65. var init_define_process = __esm({
  66. "<define:process>"() {
  67. }
  68. });
  69. var require_doc_builders = __commonJS2({
  70. "src/document/doc-builders.js"(exports2, module2) {
  71. "use strict";
  72. init_define_process();
  73. function concat(parts) {
  74. if (false) {
  75. for (const part of parts) {
  76. assertDoc(part);
  77. }
  78. }
  79. return {
  80. type: "concat",
  81. parts
  82. };
  83. }
  84. function indent(contents) {
  85. if (false) {
  86. assertDoc(contents);
  87. }
  88. return {
  89. type: "indent",
  90. contents
  91. };
  92. }
  93. function align(widthOrString, contents) {
  94. if (false) {
  95. assertDoc(contents);
  96. }
  97. return {
  98. type: "align",
  99. contents,
  100. n: widthOrString
  101. };
  102. }
  103. function group(contents) {
  104. let opts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
  105. if (false) {
  106. assertDoc(contents);
  107. }
  108. return {
  109. type: "group",
  110. id: opts.id,
  111. contents,
  112. break: Boolean(opts.shouldBreak),
  113. expandedStates: opts.expandedStates
  114. };
  115. }
  116. function dedentToRoot(contents) {
  117. return align(Number.NEGATIVE_INFINITY, contents);
  118. }
  119. function markAsRoot(contents) {
  120. return align({
  121. type: "root"
  122. }, contents);
  123. }
  124. function dedent(contents) {
  125. return align(-1, contents);
  126. }
  127. function conditionalGroup(states, opts) {
  128. return group(states[0], Object.assign(Object.assign({}, opts), {}, {
  129. expandedStates: states
  130. }));
  131. }
  132. function fill(parts) {
  133. if (false) {
  134. for (const part of parts) {
  135. assertDoc(part);
  136. }
  137. }
  138. return {
  139. type: "fill",
  140. parts
  141. };
  142. }
  143. function ifBreak(breakContents, flatContents) {
  144. let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
  145. if (false) {
  146. if (breakContents) {
  147. assertDoc(breakContents);
  148. }
  149. if (flatContents) {
  150. assertDoc(flatContents);
  151. }
  152. }
  153. return {
  154. type: "if-break",
  155. breakContents,
  156. flatContents,
  157. groupId: opts.groupId
  158. };
  159. }
  160. function indentIfBreak(contents, opts) {
  161. return {
  162. type: "indent-if-break",
  163. contents,
  164. groupId: opts.groupId,
  165. negate: opts.negate
  166. };
  167. }
  168. function lineSuffix(contents) {
  169. if (false) {
  170. assertDoc(contents);
  171. }
  172. return {
  173. type: "line-suffix",
  174. contents
  175. };
  176. }
  177. var lineSuffixBoundary = {
  178. type: "line-suffix-boundary"
  179. };
  180. var breakParent = {
  181. type: "break-parent"
  182. };
  183. var trim = {
  184. type: "trim"
  185. };
  186. var hardlineWithoutBreakParent = {
  187. type: "line",
  188. hard: true
  189. };
  190. var literallineWithoutBreakParent = {
  191. type: "line",
  192. hard: true,
  193. literal: true
  194. };
  195. var line = {
  196. type: "line"
  197. };
  198. var softline = {
  199. type: "line",
  200. soft: true
  201. };
  202. var hardline = concat([hardlineWithoutBreakParent, breakParent]);
  203. var literalline = concat([literallineWithoutBreakParent, breakParent]);
  204. var cursor = {
  205. type: "cursor",
  206. placeholder: Symbol("cursor")
  207. };
  208. function join(sep, arr) {
  209. const res = [];
  210. for (let i = 0; i < arr.length; i++) {
  211. if (i !== 0) {
  212. res.push(sep);
  213. }
  214. res.push(arr[i]);
  215. }
  216. return concat(res);
  217. }
  218. function addAlignmentToDoc(doc, size, tabWidth) {
  219. let aligned = doc;
  220. if (size > 0) {
  221. for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
  222. aligned = indent(aligned);
  223. }
  224. aligned = align(size % tabWidth, aligned);
  225. aligned = align(Number.NEGATIVE_INFINITY, aligned);
  226. }
  227. return aligned;
  228. }
  229. function label(label2, contents) {
  230. return {
  231. type: "label",
  232. label: label2,
  233. contents
  234. };
  235. }
  236. module2.exports = {
  237. concat,
  238. join,
  239. line,
  240. softline,
  241. hardline,
  242. literalline,
  243. group,
  244. conditionalGroup,
  245. fill,
  246. lineSuffix,
  247. lineSuffixBoundary,
  248. cursor,
  249. breakParent,
  250. ifBreak,
  251. trim,
  252. indent,
  253. indentIfBreak,
  254. align,
  255. addAlignmentToDoc,
  256. markAsRoot,
  257. dedentToRoot,
  258. dedent,
  259. hardlineWithoutBreakParent,
  260. literallineWithoutBreakParent,
  261. label
  262. };
  263. }
  264. });
  265. var require_end_of_line = __commonJS2({
  266. "src/common/end-of-line.js"(exports2, module2) {
  267. "use strict";
  268. init_define_process();
  269. function guessEndOfLine(text) {
  270. const index = text.indexOf("\r");
  271. if (index >= 0) {
  272. return text.charAt(index + 1) === "\n" ? "crlf" : "cr";
  273. }
  274. return "lf";
  275. }
  276. function convertEndOfLineToChars(value) {
  277. switch (value) {
  278. case "cr":
  279. return "\r";
  280. case "crlf":
  281. return "\r\n";
  282. default:
  283. return "\n";
  284. }
  285. }
  286. function countEndOfLineChars(text, eol) {
  287. let regex;
  288. switch (eol) {
  289. case "\n":
  290. regex = /\n/g;
  291. break;
  292. case "\r":
  293. regex = /\r/g;
  294. break;
  295. case "\r\n":
  296. regex = /\r\n/g;
  297. break;
  298. default:
  299. throw new Error(`Unexpected "eol" ${JSON.stringify(eol)}.`);
  300. }
  301. const endOfLines = text.match(regex);
  302. return endOfLines ? endOfLines.length : 0;
  303. }
  304. function normalizeEndOfLine(text) {
  305. return text.replace(/\r\n?/g, "\n");
  306. }
  307. module2.exports = {
  308. guessEndOfLine,
  309. convertEndOfLineToChars,
  310. countEndOfLineChars,
  311. normalizeEndOfLine
  312. };
  313. }
  314. });
  315. var require_get_last = __commonJS2({
  316. "src/utils/get-last.js"(exports2, module2) {
  317. "use strict";
  318. init_define_process();
  319. var getLast = (arr) => arr[arr.length - 1];
  320. module2.exports = getLast;
  321. }
  322. });
  323. function ansiRegex() {
  324. let {
  325. onlyFirst = false
  326. } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
  327. 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("|");
  328. return new RegExp(pattern, onlyFirst ? void 0 : "g");
  329. }
  330. var init_ansi_regex = __esm({
  331. "node_modules/strip-ansi/node_modules/ansi-regex/index.js"() {
  332. init_define_process();
  333. }
  334. });
  335. function stripAnsi(string) {
  336. if (typeof string !== "string") {
  337. throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
  338. }
  339. return string.replace(ansiRegex(), "");
  340. }
  341. var init_strip_ansi = __esm({
  342. "node_modules/strip-ansi/index.js"() {
  343. init_define_process();
  344. init_ansi_regex();
  345. }
  346. });
  347. function isFullwidthCodePoint(codePoint) {
  348. if (!Number.isInteger(codePoint)) {
  349. return false;
  350. }
  351. 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);
  352. }
  353. var init_is_fullwidth_code_point = __esm({
  354. "node_modules/is-fullwidth-code-point/index.js"() {
  355. init_define_process();
  356. }
  357. });
  358. var require_emoji_regex = __commonJS2({
  359. "node_modules/emoji-regex/index.js"(exports2, module2) {
  360. "use strict";
  361. init_define_process();
  362. module2.exports = function() {
  363. 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])|\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92]|\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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77\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\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DD])/g;
  364. };
  365. }
  366. });
  367. var string_width_exports = {};
  368. __export(string_width_exports, {
  369. default: () => stringWidth
  370. });
  371. function stringWidth(string) {
  372. if (typeof string !== "string" || string.length === 0) {
  373. return 0;
  374. }
  375. string = stripAnsi(string);
  376. if (string.length === 0) {
  377. return 0;
  378. }
  379. string = string.replace((0, import_emoji_regex.default)(), " ");
  380. let width = 0;
  381. for (let index = 0; index < string.length; index++) {
  382. const codePoint = string.codePointAt(index);
  383. if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
  384. continue;
  385. }
  386. if (codePoint >= 768 && codePoint <= 879) {
  387. continue;
  388. }
  389. if (codePoint > 65535) {
  390. index++;
  391. }
  392. width += isFullwidthCodePoint(codePoint) ? 2 : 1;
  393. }
  394. return width;
  395. }
  396. var import_emoji_regex;
  397. var init_string_width = __esm({
  398. "node_modules/string-width/index.js"() {
  399. init_define_process();
  400. init_strip_ansi();
  401. init_is_fullwidth_code_point();
  402. import_emoji_regex = __toESM(require_emoji_regex());
  403. }
  404. });
  405. var require_get_string_width = __commonJS2({
  406. "src/utils/get-string-width.js"(exports2, module2) {
  407. "use strict";
  408. init_define_process();
  409. var stringWidth2 = (init_string_width(), __toCommonJS(string_width_exports)).default;
  410. var notAsciiRegex = /[^\x20-\x7F]/;
  411. function getStringWidth(text) {
  412. if (!text) {
  413. return 0;
  414. }
  415. if (!notAsciiRegex.test(text)) {
  416. return text.length;
  417. }
  418. return stringWidth2(text);
  419. }
  420. module2.exports = getStringWidth;
  421. }
  422. });
  423. var require_doc_utils = __commonJS2({
  424. "src/document/doc-utils.js"(exports2, module2) {
  425. "use strict";
  426. init_define_process();
  427. var getLast = require_get_last();
  428. var {
  429. literalline,
  430. join
  431. } = require_doc_builders();
  432. var isConcat = (doc) => Array.isArray(doc) || doc && doc.type === "concat";
  433. var getDocParts = (doc) => {
  434. if (Array.isArray(doc)) {
  435. return doc;
  436. }
  437. if (doc.type !== "concat" && doc.type !== "fill") {
  438. throw new Error("Expect doc type to be `concat` or `fill`.");
  439. }
  440. return doc.parts;
  441. };
  442. var traverseDocOnExitStackMarker = {};
  443. function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
  444. const docsStack = [doc];
  445. while (docsStack.length > 0) {
  446. const doc2 = docsStack.pop();
  447. if (doc2 === traverseDocOnExitStackMarker) {
  448. onExit(docsStack.pop());
  449. continue;
  450. }
  451. if (onExit) {
  452. docsStack.push(doc2, traverseDocOnExitStackMarker);
  453. }
  454. if (!onEnter || onEnter(doc2) !== false) {
  455. if (isConcat(doc2) || doc2.type === "fill") {
  456. const parts = getDocParts(doc2);
  457. for (let ic = parts.length, i = ic - 1; i >= 0; --i) {
  458. docsStack.push(parts[i]);
  459. }
  460. } else if (doc2.type === "if-break") {
  461. if (doc2.flatContents) {
  462. docsStack.push(doc2.flatContents);
  463. }
  464. if (doc2.breakContents) {
  465. docsStack.push(doc2.breakContents);
  466. }
  467. } else if (doc2.type === "group" && doc2.expandedStates) {
  468. if (shouldTraverseConditionalGroups) {
  469. for (let ic = doc2.expandedStates.length, i = ic - 1; i >= 0; --i) {
  470. docsStack.push(doc2.expandedStates[i]);
  471. }
  472. } else {
  473. docsStack.push(doc2.contents);
  474. }
  475. } else if (doc2.contents) {
  476. docsStack.push(doc2.contents);
  477. }
  478. }
  479. }
  480. }
  481. function mapDoc(doc, cb) {
  482. const mapped = /* @__PURE__ */ new Map();
  483. return rec(doc);
  484. function rec(doc2) {
  485. if (mapped.has(doc2)) {
  486. return mapped.get(doc2);
  487. }
  488. const result = process2(doc2);
  489. mapped.set(doc2, result);
  490. return result;
  491. }
  492. function process2(doc2) {
  493. if (Array.isArray(doc2)) {
  494. return cb(doc2.map(rec));
  495. }
  496. if (doc2.type === "concat" || doc2.type === "fill") {
  497. const parts = doc2.parts.map(rec);
  498. return cb(Object.assign(Object.assign({}, doc2), {}, {
  499. parts
  500. }));
  501. }
  502. if (doc2.type === "if-break") {
  503. const breakContents = doc2.breakContents && rec(doc2.breakContents);
  504. const flatContents = doc2.flatContents && rec(doc2.flatContents);
  505. return cb(Object.assign(Object.assign({}, doc2), {}, {
  506. breakContents,
  507. flatContents
  508. }));
  509. }
  510. if (doc2.type === "group" && doc2.expandedStates) {
  511. const expandedStates = doc2.expandedStates.map(rec);
  512. const contents = expandedStates[0];
  513. return cb(Object.assign(Object.assign({}, doc2), {}, {
  514. contents,
  515. expandedStates
  516. }));
  517. }
  518. if (doc2.contents) {
  519. const contents = rec(doc2.contents);
  520. return cb(Object.assign(Object.assign({}, doc2), {}, {
  521. contents
  522. }));
  523. }
  524. return cb(doc2);
  525. }
  526. }
  527. function findInDoc(doc, fn, defaultValue) {
  528. let result = defaultValue;
  529. let hasStopped = false;
  530. function findInDocOnEnterFn(doc2) {
  531. const maybeResult = fn(doc2);
  532. if (maybeResult !== void 0) {
  533. hasStopped = true;
  534. result = maybeResult;
  535. }
  536. if (hasStopped) {
  537. return false;
  538. }
  539. }
  540. traverseDoc(doc, findInDocOnEnterFn);
  541. return result;
  542. }
  543. function willBreakFn(doc) {
  544. if (doc.type === "group" && doc.break) {
  545. return true;
  546. }
  547. if (doc.type === "line" && doc.hard) {
  548. return true;
  549. }
  550. if (doc.type === "break-parent") {
  551. return true;
  552. }
  553. }
  554. function willBreak(doc) {
  555. return findInDoc(doc, willBreakFn, false);
  556. }
  557. function breakParentGroup(groupStack) {
  558. if (groupStack.length > 0) {
  559. const parentGroup = getLast(groupStack);
  560. if (!parentGroup.expandedStates && !parentGroup.break) {
  561. parentGroup.break = "propagated";
  562. }
  563. }
  564. return null;
  565. }
  566. function propagateBreaks(doc) {
  567. const alreadyVisitedSet = /* @__PURE__ */ new Set();
  568. const groupStack = [];
  569. function propagateBreaksOnEnterFn(doc2) {
  570. if (doc2.type === "break-parent") {
  571. breakParentGroup(groupStack);
  572. }
  573. if (doc2.type === "group") {
  574. groupStack.push(doc2);
  575. if (alreadyVisitedSet.has(doc2)) {
  576. return false;
  577. }
  578. alreadyVisitedSet.add(doc2);
  579. }
  580. }
  581. function propagateBreaksOnExitFn(doc2) {
  582. if (doc2.type === "group") {
  583. const group = groupStack.pop();
  584. if (group.break) {
  585. breakParentGroup(groupStack);
  586. }
  587. }
  588. }
  589. traverseDoc(doc, propagateBreaksOnEnterFn, propagateBreaksOnExitFn, true);
  590. }
  591. function removeLinesFn(doc) {
  592. if (doc.type === "line" && !doc.hard) {
  593. return doc.soft ? "" : " ";
  594. }
  595. if (doc.type === "if-break") {
  596. return doc.flatContents || "";
  597. }
  598. return doc;
  599. }
  600. function removeLines(doc) {
  601. return mapDoc(doc, removeLinesFn);
  602. }
  603. var isHardline = (doc, nextDoc) => doc && doc.type === "line" && doc.hard && nextDoc && nextDoc.type === "break-parent";
  604. function stripDocTrailingHardlineFromDoc(doc) {
  605. if (!doc) {
  606. return doc;
  607. }
  608. if (isConcat(doc) || doc.type === "fill") {
  609. const parts = getDocParts(doc);
  610. while (parts.length > 1 && isHardline(...parts.slice(-2))) {
  611. parts.length -= 2;
  612. }
  613. if (parts.length > 0) {
  614. const lastPart = stripDocTrailingHardlineFromDoc(getLast(parts));
  615. parts[parts.length - 1] = lastPart;
  616. }
  617. return Array.isArray(doc) ? parts : Object.assign(Object.assign({}, doc), {}, {
  618. parts
  619. });
  620. }
  621. switch (doc.type) {
  622. case "align":
  623. case "indent":
  624. case "indent-if-break":
  625. case "group":
  626. case "line-suffix":
  627. case "label": {
  628. const contents = stripDocTrailingHardlineFromDoc(doc.contents);
  629. return Object.assign(Object.assign({}, doc), {}, {
  630. contents
  631. });
  632. }
  633. case "if-break": {
  634. const breakContents = stripDocTrailingHardlineFromDoc(doc.breakContents);
  635. const flatContents = stripDocTrailingHardlineFromDoc(doc.flatContents);
  636. return Object.assign(Object.assign({}, doc), {}, {
  637. breakContents,
  638. flatContents
  639. });
  640. }
  641. }
  642. return doc;
  643. }
  644. function stripTrailingHardline(doc) {
  645. return stripDocTrailingHardlineFromDoc(cleanDoc(doc));
  646. }
  647. function cleanDocFn(doc) {
  648. switch (doc.type) {
  649. case "fill":
  650. if (doc.parts.every((part) => part === "")) {
  651. return "";
  652. }
  653. break;
  654. case "group":
  655. if (!doc.contents && !doc.id && !doc.break && !doc.expandedStates) {
  656. return "";
  657. }
  658. if (doc.contents.type === "group" && doc.contents.id === doc.id && doc.contents.break === doc.break && doc.contents.expandedStates === doc.expandedStates) {
  659. return doc.contents;
  660. }
  661. break;
  662. case "align":
  663. case "indent":
  664. case "indent-if-break":
  665. case "line-suffix":
  666. if (!doc.contents) {
  667. return "";
  668. }
  669. break;
  670. case "if-break":
  671. if (!doc.flatContents && !doc.breakContents) {
  672. return "";
  673. }
  674. break;
  675. }
  676. if (!isConcat(doc)) {
  677. return doc;
  678. }
  679. const parts = [];
  680. for (const part of getDocParts(doc)) {
  681. if (!part) {
  682. continue;
  683. }
  684. const [currentPart, ...restParts] = isConcat(part) ? getDocParts(part) : [part];
  685. if (typeof currentPart === "string" && typeof getLast(parts) === "string") {
  686. parts[parts.length - 1] += currentPart;
  687. } else {
  688. parts.push(currentPart);
  689. }
  690. parts.push(...restParts);
  691. }
  692. if (parts.length === 0) {
  693. return "";
  694. }
  695. if (parts.length === 1) {
  696. return parts[0];
  697. }
  698. return Array.isArray(doc) ? parts : Object.assign(Object.assign({}, doc), {}, {
  699. parts
  700. });
  701. }
  702. function cleanDoc(doc) {
  703. return mapDoc(doc, (currentDoc) => cleanDocFn(currentDoc));
  704. }
  705. function normalizeParts(parts) {
  706. const newParts = [];
  707. const restParts = parts.filter(Boolean);
  708. while (restParts.length > 0) {
  709. const part = restParts.shift();
  710. if (!part) {
  711. continue;
  712. }
  713. if (isConcat(part)) {
  714. restParts.unshift(...getDocParts(part));
  715. continue;
  716. }
  717. if (newParts.length > 0 && typeof getLast(newParts) === "string" && typeof part === "string") {
  718. newParts[newParts.length - 1] += part;
  719. continue;
  720. }
  721. newParts.push(part);
  722. }
  723. return newParts;
  724. }
  725. function normalizeDoc(doc) {
  726. return mapDoc(doc, (currentDoc) => {
  727. if (Array.isArray(currentDoc)) {
  728. return normalizeParts(currentDoc);
  729. }
  730. if (!currentDoc.parts) {
  731. return currentDoc;
  732. }
  733. return Object.assign(Object.assign({}, currentDoc), {}, {
  734. parts: normalizeParts(currentDoc.parts)
  735. });
  736. });
  737. }
  738. function replaceEndOfLine(doc) {
  739. return mapDoc(doc, (currentDoc) => typeof currentDoc === "string" && currentDoc.includes("\n") ? replaceTextEndOfLine(currentDoc) : currentDoc);
  740. }
  741. function replaceTextEndOfLine(text) {
  742. let replacement = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : literalline;
  743. return join(replacement, text.split("\n")).parts;
  744. }
  745. function canBreakFn(doc) {
  746. if (doc.type === "line") {
  747. return true;
  748. }
  749. }
  750. function canBreak(doc) {
  751. return findInDoc(doc, canBreakFn, false);
  752. }
  753. module2.exports = {
  754. isConcat,
  755. getDocParts,
  756. willBreak,
  757. traverseDoc,
  758. findInDoc,
  759. mapDoc,
  760. propagateBreaks,
  761. removeLines,
  762. stripTrailingHardline,
  763. normalizeParts,
  764. normalizeDoc,
  765. cleanDoc,
  766. replaceTextEndOfLine,
  767. replaceEndOfLine,
  768. canBreak
  769. };
  770. }
  771. });
  772. var require_doc_printer = __commonJS2({
  773. "src/document/doc-printer.js"(exports2, module2) {
  774. "use strict";
  775. init_define_process();
  776. var {
  777. convertEndOfLineToChars
  778. } = require_end_of_line();
  779. var getLast = require_get_last();
  780. var getStringWidth = require_get_string_width();
  781. var {
  782. fill,
  783. cursor,
  784. indent
  785. } = require_doc_builders();
  786. var {
  787. isConcat,
  788. getDocParts
  789. } = require_doc_utils();
  790. var groupModeMap;
  791. var MODE_BREAK = 1;
  792. var MODE_FLAT = 2;
  793. function rootIndent() {
  794. return {
  795. value: "",
  796. length: 0,
  797. queue: []
  798. };
  799. }
  800. function makeIndent(ind, options) {
  801. return generateInd(ind, {
  802. type: "indent"
  803. }, options);
  804. }
  805. function makeAlign(indent2, widthOrDoc, options) {
  806. if (widthOrDoc === Number.NEGATIVE_INFINITY) {
  807. return indent2.root || rootIndent();
  808. }
  809. if (widthOrDoc < 0) {
  810. return generateInd(indent2, {
  811. type: "dedent"
  812. }, options);
  813. }
  814. if (!widthOrDoc) {
  815. return indent2;
  816. }
  817. if (widthOrDoc.type === "root") {
  818. return Object.assign(Object.assign({}, indent2), {}, {
  819. root: indent2
  820. });
  821. }
  822. const alignType = typeof widthOrDoc === "string" ? "stringAlign" : "numberAlign";
  823. return generateInd(indent2, {
  824. type: alignType,
  825. n: widthOrDoc
  826. }, options);
  827. }
  828. function generateInd(ind, newPart, options) {
  829. const queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : [...ind.queue, newPart];
  830. let value = "";
  831. let length = 0;
  832. let lastTabs = 0;
  833. let lastSpaces = 0;
  834. for (const part of queue) {
  835. switch (part.type) {
  836. case "indent":
  837. flush();
  838. if (options.useTabs) {
  839. addTabs(1);
  840. } else {
  841. addSpaces(options.tabWidth);
  842. }
  843. break;
  844. case "stringAlign":
  845. flush();
  846. value += part.n;
  847. length += part.n.length;
  848. break;
  849. case "numberAlign":
  850. lastTabs += 1;
  851. lastSpaces += part.n;
  852. break;
  853. default:
  854. throw new Error(`Unexpected type '${part.type}'`);
  855. }
  856. }
  857. flushSpaces();
  858. return Object.assign(Object.assign({}, ind), {}, {
  859. value,
  860. length,
  861. queue
  862. });
  863. function addTabs(count) {
  864. value += " ".repeat(count);
  865. length += options.tabWidth * count;
  866. }
  867. function addSpaces(count) {
  868. value += " ".repeat(count);
  869. length += count;
  870. }
  871. function flush() {
  872. if (options.useTabs) {
  873. flushTabs();
  874. } else {
  875. flushSpaces();
  876. }
  877. }
  878. function flushTabs() {
  879. if (lastTabs > 0) {
  880. addTabs(lastTabs);
  881. }
  882. resetLast();
  883. }
  884. function flushSpaces() {
  885. if (lastSpaces > 0) {
  886. addSpaces(lastSpaces);
  887. }
  888. resetLast();
  889. }
  890. function resetLast() {
  891. lastTabs = 0;
  892. lastSpaces = 0;
  893. }
  894. }
  895. function trim(out) {
  896. if (out.length === 0) {
  897. return 0;
  898. }
  899. let trimCount = 0;
  900. while (out.length > 0 && typeof getLast(out) === "string" && /^[\t ]*$/.test(getLast(out))) {
  901. trimCount += out.pop().length;
  902. }
  903. if (out.length > 0 && typeof getLast(out) === "string") {
  904. const trimmed = getLast(out).replace(/[\t ]*$/, "");
  905. trimCount += getLast(out).length - trimmed.length;
  906. out[out.length - 1] = trimmed;
  907. }
  908. return trimCount;
  909. }
  910. function fits(next, restCommands, width, hasLineSuffix, mustBeFlat) {
  911. let restIdx = restCommands.length;
  912. const cmds = [next];
  913. const out = [];
  914. while (width >= 0) {
  915. if (cmds.length === 0) {
  916. if (restIdx === 0) {
  917. return true;
  918. }
  919. cmds.push(restCommands[--restIdx]);
  920. continue;
  921. }
  922. const {
  923. mode,
  924. doc
  925. } = cmds.pop();
  926. if (typeof doc === "string") {
  927. out.push(doc);
  928. width -= getStringWidth(doc);
  929. } else if (isConcat(doc) || doc.type === "fill") {
  930. const parts = getDocParts(doc);
  931. for (let i = parts.length - 1; i >= 0; i--) {
  932. cmds.push({
  933. mode,
  934. doc: parts[i]
  935. });
  936. }
  937. } else {
  938. switch (doc.type) {
  939. case "indent":
  940. case "align":
  941. case "indent-if-break":
  942. case "label":
  943. cmds.push({
  944. mode,
  945. doc: doc.contents
  946. });
  947. break;
  948. case "trim":
  949. width += trim(out);
  950. break;
  951. case "group": {
  952. if (mustBeFlat && doc.break) {
  953. return false;
  954. }
  955. const groupMode = doc.break ? MODE_BREAK : mode;
  956. const contents = doc.expandedStates && groupMode === MODE_BREAK ? getLast(doc.expandedStates) : doc.contents;
  957. cmds.push({
  958. mode: groupMode,
  959. doc: contents
  960. });
  961. break;
  962. }
  963. case "if-break": {
  964. const groupMode = doc.groupId ? groupModeMap[doc.groupId] || MODE_FLAT : mode;
  965. const contents = groupMode === MODE_BREAK ? doc.breakContents : doc.flatContents;
  966. if (contents) {
  967. cmds.push({
  968. mode,
  969. doc: contents
  970. });
  971. }
  972. break;
  973. }
  974. case "line":
  975. if (mode === MODE_BREAK || doc.hard) {
  976. return true;
  977. }
  978. if (!doc.soft) {
  979. out.push(" ");
  980. width--;
  981. }
  982. break;
  983. case "line-suffix":
  984. hasLineSuffix = true;
  985. break;
  986. case "line-suffix-boundary":
  987. if (hasLineSuffix) {
  988. return false;
  989. }
  990. break;
  991. }
  992. }
  993. }
  994. return false;
  995. }
  996. function printDocToString(doc, options) {
  997. groupModeMap = {};
  998. const width = options.printWidth;
  999. const newLine = convertEndOfLineToChars(options.endOfLine);
  1000. let pos = 0;
  1001. const cmds = [{
  1002. ind: rootIndent(),
  1003. mode: MODE_BREAK,
  1004. doc
  1005. }];
  1006. const out = [];
  1007. let shouldRemeasure = false;
  1008. const lineSuffix = [];
  1009. while (cmds.length > 0) {
  1010. const {
  1011. ind,
  1012. mode,
  1013. doc: doc2
  1014. } = cmds.pop();
  1015. if (typeof doc2 === "string") {
  1016. const formatted = newLine !== "\n" ? doc2.replace(/\n/g, newLine) : doc2;
  1017. out.push(formatted);
  1018. pos += getStringWidth(formatted);
  1019. } else if (isConcat(doc2)) {
  1020. const parts = getDocParts(doc2);
  1021. for (let i = parts.length - 1; i >= 0; i--) {
  1022. cmds.push({
  1023. ind,
  1024. mode,
  1025. doc: parts[i]
  1026. });
  1027. }
  1028. } else {
  1029. switch (doc2.type) {
  1030. case "cursor":
  1031. out.push(cursor.placeholder);
  1032. break;
  1033. case "indent":
  1034. cmds.push({
  1035. ind: makeIndent(ind, options),
  1036. mode,
  1037. doc: doc2.contents
  1038. });
  1039. break;
  1040. case "align":
  1041. cmds.push({
  1042. ind: makeAlign(ind, doc2.n, options),
  1043. mode,
  1044. doc: doc2.contents
  1045. });
  1046. break;
  1047. case "trim":
  1048. pos -= trim(out);
  1049. break;
  1050. case "group":
  1051. switch (mode) {
  1052. case MODE_FLAT:
  1053. if (!shouldRemeasure) {
  1054. cmds.push({
  1055. ind,
  1056. mode: doc2.break ? MODE_BREAK : MODE_FLAT,
  1057. doc: doc2.contents
  1058. });
  1059. break;
  1060. }
  1061. case MODE_BREAK: {
  1062. shouldRemeasure = false;
  1063. const next = {
  1064. ind,
  1065. mode: MODE_FLAT,
  1066. doc: doc2.contents
  1067. };
  1068. const rem = width - pos;
  1069. const hasLineSuffix = lineSuffix.length > 0;
  1070. if (!doc2.break && fits(next, cmds, rem, hasLineSuffix)) {
  1071. cmds.push(next);
  1072. } else {
  1073. if (doc2.expandedStates) {
  1074. const mostExpanded = getLast(doc2.expandedStates);
  1075. if (doc2.break) {
  1076. cmds.push({
  1077. ind,
  1078. mode: MODE_BREAK,
  1079. doc: mostExpanded
  1080. });
  1081. break;
  1082. } else {
  1083. for (let i = 1; i < doc2.expandedStates.length + 1; i++) {
  1084. if (i >= doc2.expandedStates.length) {
  1085. cmds.push({
  1086. ind,
  1087. mode: MODE_BREAK,
  1088. doc: mostExpanded
  1089. });
  1090. break;
  1091. } else {
  1092. const state = doc2.expandedStates[i];
  1093. const cmd = {
  1094. ind,
  1095. mode: MODE_FLAT,
  1096. doc: state
  1097. };
  1098. if (fits(cmd, cmds, rem, hasLineSuffix)) {
  1099. cmds.push(cmd);
  1100. break;
  1101. }
  1102. }
  1103. }
  1104. }
  1105. } else {
  1106. cmds.push({
  1107. ind,
  1108. mode: MODE_BREAK,
  1109. doc: doc2.contents
  1110. });
  1111. }
  1112. }
  1113. break;
  1114. }
  1115. }
  1116. if (doc2.id) {
  1117. groupModeMap[doc2.id] = getLast(cmds).mode;
  1118. }
  1119. break;
  1120. case "fill": {
  1121. const rem = width - pos;
  1122. const {
  1123. parts
  1124. } = doc2;
  1125. if (parts.length === 0) {
  1126. break;
  1127. }
  1128. const [content, whitespace] = parts;
  1129. const contentFlatCmd = {
  1130. ind,
  1131. mode: MODE_FLAT,
  1132. doc: content
  1133. };
  1134. const contentBreakCmd = {
  1135. ind,
  1136. mode: MODE_BREAK,
  1137. doc: content
  1138. };
  1139. const contentFits = fits(contentFlatCmd, [], rem, lineSuffix.length > 0, true);
  1140. if (parts.length === 1) {
  1141. if (contentFits) {
  1142. cmds.push(contentFlatCmd);
  1143. } else {
  1144. cmds.push(contentBreakCmd);
  1145. }
  1146. break;
  1147. }
  1148. const whitespaceFlatCmd = {
  1149. ind,
  1150. mode: MODE_FLAT,
  1151. doc: whitespace
  1152. };
  1153. const whitespaceBreakCmd = {
  1154. ind,
  1155. mode: MODE_BREAK,
  1156. doc: whitespace
  1157. };
  1158. if (parts.length === 2) {
  1159. if (contentFits) {
  1160. cmds.push(whitespaceFlatCmd, contentFlatCmd);
  1161. } else {
  1162. cmds.push(whitespaceBreakCmd, contentBreakCmd);
  1163. }
  1164. break;
  1165. }
  1166. parts.splice(0, 2);
  1167. const remainingCmd = {
  1168. ind,
  1169. mode,
  1170. doc: fill(parts)
  1171. };
  1172. const secondContent = parts[0];
  1173. const firstAndSecondContentFlatCmd = {
  1174. ind,
  1175. mode: MODE_FLAT,
  1176. doc: [content, whitespace, secondContent]
  1177. };
  1178. const firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], rem, lineSuffix.length > 0, true);
  1179. if (firstAndSecondContentFits) {
  1180. cmds.push(remainingCmd, whitespaceFlatCmd, contentFlatCmd);
  1181. } else if (contentFits) {
  1182. cmds.push(remainingCmd, whitespaceBreakCmd, contentFlatCmd);
  1183. } else {
  1184. cmds.push(remainingCmd, whitespaceBreakCmd, contentBreakCmd);
  1185. }
  1186. break;
  1187. }
  1188. case "if-break":
  1189. case "indent-if-break": {
  1190. const groupMode = doc2.groupId ? groupModeMap[doc2.groupId] : mode;
  1191. if (groupMode === MODE_BREAK) {
  1192. const breakContents = doc2.type === "if-break" ? doc2.breakContents : doc2.negate ? doc2.contents : indent(doc2.contents);
  1193. if (breakContents) {
  1194. cmds.push({
  1195. ind,
  1196. mode,
  1197. doc: breakContents
  1198. });
  1199. }
  1200. }
  1201. if (groupMode === MODE_FLAT) {
  1202. const flatContents = doc2.type === "if-break" ? doc2.flatContents : doc2.negate ? indent(doc2.contents) : doc2.contents;
  1203. if (flatContents) {
  1204. cmds.push({
  1205. ind,
  1206. mode,
  1207. doc: flatContents
  1208. });
  1209. }
  1210. }
  1211. break;
  1212. }
  1213. case "line-suffix":
  1214. lineSuffix.push({
  1215. ind,
  1216. mode,
  1217. doc: doc2.contents
  1218. });
  1219. break;
  1220. case "line-suffix-boundary":
  1221. if (lineSuffix.length > 0) {
  1222. cmds.push({
  1223. ind,
  1224. mode,
  1225. doc: {
  1226. type: "line",
  1227. hard: true
  1228. }
  1229. });
  1230. }
  1231. break;
  1232. case "line":
  1233. switch (mode) {
  1234. case MODE_FLAT:
  1235. if (!doc2.hard) {
  1236. if (!doc2.soft) {
  1237. out.push(" ");
  1238. pos += 1;
  1239. }
  1240. break;
  1241. } else {
  1242. shouldRemeasure = true;
  1243. }
  1244. case MODE_BREAK:
  1245. if (lineSuffix.length > 0) {
  1246. cmds.push({
  1247. ind,
  1248. mode,
  1249. doc: doc2
  1250. }, ...lineSuffix.reverse());
  1251. lineSuffix.length = 0;
  1252. break;
  1253. }
  1254. if (doc2.literal) {
  1255. if (ind.root) {
  1256. out.push(newLine, ind.root.value);
  1257. pos = ind.root.length;
  1258. } else {
  1259. out.push(newLine);
  1260. pos = 0;
  1261. }
  1262. } else {
  1263. pos -= trim(out);
  1264. out.push(newLine + ind.value);
  1265. pos = ind.length;
  1266. }
  1267. break;
  1268. }
  1269. break;
  1270. case "label":
  1271. cmds.push({
  1272. ind,
  1273. mode,
  1274. doc: doc2.contents
  1275. });
  1276. break;
  1277. default:
  1278. }
  1279. }
  1280. if (cmds.length === 0 && lineSuffix.length > 0) {
  1281. cmds.push(...lineSuffix.reverse());
  1282. lineSuffix.length = 0;
  1283. }
  1284. }
  1285. const cursorPlaceholderIndex = out.indexOf(cursor.placeholder);
  1286. if (cursorPlaceholderIndex !== -1) {
  1287. const otherCursorPlaceholderIndex = out.indexOf(cursor.placeholder, cursorPlaceholderIndex + 1);
  1288. const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
  1289. const aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
  1290. const afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
  1291. return {
  1292. formatted: beforeCursor + aroundCursor + afterCursor,
  1293. cursorNodeStart: beforeCursor.length,
  1294. cursorNodeText: aroundCursor
  1295. };
  1296. }
  1297. return {
  1298. formatted: out.join("")
  1299. };
  1300. }
  1301. module2.exports = {
  1302. printDocToString
  1303. };
  1304. }
  1305. });
  1306. var require_doc_debug = __commonJS2({
  1307. "src/document/doc-debug.js"(exports2, module2) {
  1308. "use strict";
  1309. init_define_process();
  1310. var {
  1311. isConcat,
  1312. getDocParts
  1313. } = require_doc_utils();
  1314. function flattenDoc(doc) {
  1315. if (!doc) {
  1316. return "";
  1317. }
  1318. if (isConcat(doc)) {
  1319. const res = [];
  1320. for (const part of getDocParts(doc)) {
  1321. if (isConcat(part)) {
  1322. res.push(...flattenDoc(part).parts);
  1323. } else {
  1324. const flattened = flattenDoc(part);
  1325. if (flattened !== "") {
  1326. res.push(flattened);
  1327. }
  1328. }
  1329. }
  1330. return {
  1331. type: "concat",
  1332. parts: res
  1333. };
  1334. }
  1335. if (doc.type === "if-break") {
  1336. return Object.assign(Object.assign({}, doc), {}, {
  1337. breakContents: flattenDoc(doc.breakContents),
  1338. flatContents: flattenDoc(doc.flatContents)
  1339. });
  1340. }
  1341. if (doc.type === "group") {
  1342. return Object.assign(Object.assign({}, doc), {}, {
  1343. contents: flattenDoc(doc.contents),
  1344. expandedStates: doc.expandedStates && doc.expandedStates.map(flattenDoc)
  1345. });
  1346. }
  1347. if (doc.type === "fill") {
  1348. return {
  1349. type: "fill",
  1350. parts: doc.parts.map(flattenDoc)
  1351. };
  1352. }
  1353. if (doc.contents) {
  1354. return Object.assign(Object.assign({}, doc), {}, {
  1355. contents: flattenDoc(doc.contents)
  1356. });
  1357. }
  1358. return doc;
  1359. }
  1360. function printDocToDebug(doc) {
  1361. const printedSymbols = /* @__PURE__ */ Object.create(null);
  1362. const usedKeysForSymbols = /* @__PURE__ */ new Set();
  1363. return printDoc(flattenDoc(doc));
  1364. function printDoc(doc2, index, parentParts) {
  1365. if (typeof doc2 === "string") {
  1366. return JSON.stringify(doc2);
  1367. }
  1368. if (isConcat(doc2)) {
  1369. const printed = getDocParts(doc2).map(printDoc).filter(Boolean);
  1370. return printed.length === 1 ? printed[0] : `[${printed.join(", ")}]`;
  1371. }
  1372. if (doc2.type === "line") {
  1373. const withBreakParent = Array.isArray(parentParts) && parentParts[index + 1] && parentParts[index + 1].type === "break-parent";
  1374. if (doc2.literal) {
  1375. return withBreakParent ? "literalline" : "literallineWithoutBreakParent";
  1376. }
  1377. if (doc2.hard) {
  1378. return withBreakParent ? "hardline" : "hardlineWithoutBreakParent";
  1379. }
  1380. if (doc2.soft) {
  1381. return "softline";
  1382. }
  1383. return "line";
  1384. }
  1385. if (doc2.type === "break-parent") {
  1386. const afterHardline = Array.isArray(parentParts) && parentParts[index - 1] && parentParts[index - 1].type === "line" && parentParts[index - 1].hard;
  1387. return afterHardline ? void 0 : "breakParent";
  1388. }
  1389. if (doc2.type === "trim") {
  1390. return "trim";
  1391. }
  1392. if (doc2.type === "indent") {
  1393. return "indent(" + printDoc(doc2.contents) + ")";
  1394. }
  1395. if (doc2.type === "align") {
  1396. 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) + ")";
  1397. }
  1398. if (doc2.type === "if-break") {
  1399. return "ifBreak(" + printDoc(doc2.breakContents) + (doc2.flatContents ? ", " + printDoc(doc2.flatContents) : "") + (doc2.groupId ? (!doc2.flatContents ? ', ""' : "") + `, { groupId: ${printGroupId(doc2.groupId)} }` : "") + ")";
  1400. }
  1401. if (doc2.type === "indent-if-break") {
  1402. const optionsParts = [];
  1403. if (doc2.negate) {
  1404. optionsParts.push("negate: true");
  1405. }
  1406. if (doc2.groupId) {
  1407. optionsParts.push(`groupId: ${printGroupId(doc2.groupId)}`);
  1408. }
  1409. const options = optionsParts.length > 0 ? `, { ${optionsParts.join(", ")} }` : "";
  1410. return `indentIfBreak(${printDoc(doc2.contents)}${options})`;
  1411. }
  1412. if (doc2.type === "group") {
  1413. const optionsParts = [];
  1414. if (doc2.break && doc2.break !== "propagated") {
  1415. optionsParts.push("shouldBreak: true");
  1416. }
  1417. if (doc2.id) {
  1418. optionsParts.push(`id: ${printGroupId(doc2.id)}`);
  1419. }
  1420. const options = optionsParts.length > 0 ? `, { ${optionsParts.join(", ")} }` : "";
  1421. if (doc2.expandedStates) {
  1422. return `conditionalGroup([${doc2.expandedStates.map((part) => printDoc(part)).join(",")}]${options})`;
  1423. }
  1424. return `group(${printDoc(doc2.contents)}${options})`;
  1425. }
  1426. if (doc2.type === "fill") {
  1427. return `fill([${doc2.parts.map((part) => printDoc(part)).join(", ")}])`;
  1428. }
  1429. if (doc2.type === "line-suffix") {
  1430. return "lineSuffix(" + printDoc(doc2.contents) + ")";
  1431. }
  1432. if (doc2.type === "line-suffix-boundary") {
  1433. return "lineSuffixBoundary";
  1434. }
  1435. if (doc2.type === "label") {
  1436. return `label(${JSON.stringify(doc2.label)}, ${printDoc(doc2.contents)})`;
  1437. }
  1438. throw new Error("Unknown doc type " + doc2.type);
  1439. }
  1440. function printGroupId(id) {
  1441. if (typeof id !== "symbol") {
  1442. return JSON.stringify(String(id));
  1443. }
  1444. if (id in printedSymbols) {
  1445. return printedSymbols[id];
  1446. }
  1447. const prefix = String(id).slice(7, -1) || "symbol";
  1448. for (let counter = 0; ; counter++) {
  1449. const key = prefix + (counter > 0 ? ` #${counter}` : "");
  1450. if (!usedKeysForSymbols.has(key)) {
  1451. usedKeysForSymbols.add(key);
  1452. return printedSymbols[id] = `Symbol.for(${JSON.stringify(key)})`;
  1453. }
  1454. }
  1455. }
  1456. }
  1457. module2.exports = {
  1458. printDocToDebug
  1459. };
  1460. }
  1461. });
  1462. init_define_process();
  1463. module.exports = {
  1464. builders: require_doc_builders(),
  1465. printer: require_doc_printer(),
  1466. utils: require_doc_utils(),
  1467. debug: require_doc_debug()
  1468. };
  1469. }
  1470. });
  1471. return require_doc_js_umd();
  1472. });