@dudko.dev/agent-web-ui 0.0.0 → 0.0.1

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.
Files changed (273) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +251 -5
  3. package/dist/canvas.cjs +266 -0
  4. package/dist/canvas.cjs.map +1 -0
  5. package/dist/canvas.d.cts +105 -0
  6. package/dist/canvas.d.ts +105 -0
  7. package/dist/canvas.js +200 -0
  8. package/dist/canvas.js.map +1 -0
  9. package/dist/chunk-4EHUITGU.js +342 -0
  10. package/dist/chunk-4EHUITGU.js.map +1 -0
  11. package/dist/chunk-7O64ZI6Z.js +125 -0
  12. package/dist/chunk-7O64ZI6Z.js.map +1 -0
  13. package/dist/chunk-A55Q377T.js +342 -0
  14. package/dist/chunk-A55Q377T.js.map +1 -0
  15. package/dist/chunk-EL2YCROY.js +127 -0
  16. package/dist/chunk-EL2YCROY.js.map +1 -0
  17. package/dist/chunk-GB7RZJMG.js +98 -0
  18. package/dist/chunk-GB7RZJMG.js.map +1 -0
  19. package/dist/chunk-KZQB35LS.js +22 -0
  20. package/dist/chunk-KZQB35LS.js.map +1 -0
  21. package/dist/chunk-P2F2P3JC.js +400 -0
  22. package/dist/chunk-P2F2P3JC.js.map +1 -0
  23. package/dist/chunk-TPK25QGK.js +342 -0
  24. package/dist/chunk-TPK25QGK.js.map +1 -0
  25. package/dist/en-CcNUz2tN.d.cts +342 -0
  26. package/dist/en-CcNUz2tN.d.ts +342 -0
  27. package/dist/index.cjs +4143 -0
  28. package/dist/index.cjs.map +1 -0
  29. package/dist/index.d.cts +919 -0
  30. package/dist/index.d.ts +919 -0
  31. package/dist/index.js +3771 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/labels-B5xpIGf_.d.cts +25 -0
  34. package/dist/labels-B5xpIGf_.d.ts +25 -0
  35. package/dist/labels-D5BrHct4.d.cts +1208 -0
  36. package/dist/labels-UuWI7wPo.d.ts +1208 -0
  37. package/dist/locales/be.cjs +794 -0
  38. package/dist/locales/be.cjs.map +1 -0
  39. package/dist/locales/be.d.cts +14 -0
  40. package/dist/locales/be.d.ts +14 -0
  41. package/dist/locales/be.js +374 -0
  42. package/dist/locales/be.js.map +1 -0
  43. package/dist/locales/bg.cjs +747 -0
  44. package/dist/locales/bg.cjs.map +1 -0
  45. package/dist/locales/bg.d.cts +14 -0
  46. package/dist/locales/bg.d.ts +14 -0
  47. package/dist/locales/bg.js +327 -0
  48. package/dist/locales/bg.js.map +1 -0
  49. package/dist/locales/ca.cjs +773 -0
  50. package/dist/locales/ca.cjs.map +1 -0
  51. package/dist/locales/ca.d.cts +14 -0
  52. package/dist/locales/ca.d.ts +14 -0
  53. package/dist/locales/ca.js +353 -0
  54. package/dist/locales/ca.js.map +1 -0
  55. package/dist/locales/cs.cjs +794 -0
  56. package/dist/locales/cs.cjs.map +1 -0
  57. package/dist/locales/cs.d.cts +14 -0
  58. package/dist/locales/cs.d.ts +14 -0
  59. package/dist/locales/cs.js +374 -0
  60. package/dist/locales/cs.js.map +1 -0
  61. package/dist/locales/da.cjs +747 -0
  62. package/dist/locales/da.cjs.map +1 -0
  63. package/dist/locales/da.d.cts +14 -0
  64. package/dist/locales/da.d.ts +14 -0
  65. package/dist/locales/da.js +327 -0
  66. package/dist/locales/da.js.map +1 -0
  67. package/dist/locales/de.cjs +756 -0
  68. package/dist/locales/de.cjs.map +1 -0
  69. package/dist/locales/de.d.cts +14 -0
  70. package/dist/locales/de.d.ts +14 -0
  71. package/dist/locales/de.js +336 -0
  72. package/dist/locales/de.js.map +1 -0
  73. package/dist/locales/el.cjs +756 -0
  74. package/dist/locales/el.cjs.map +1 -0
  75. package/dist/locales/el.d.cts +14 -0
  76. package/dist/locales/el.d.ts +14 -0
  77. package/dist/locales/el.js +336 -0
  78. package/dist/locales/el.js.map +1 -0
  79. package/dist/locales/en.cjs +753 -0
  80. package/dist/locales/en.cjs.map +1 -0
  81. package/dist/locales/en.d.cts +10 -0
  82. package/dist/locales/en.d.ts +10 -0
  83. package/dist/locales/en.js +333 -0
  84. package/dist/locales/en.js.map +1 -0
  85. package/dist/locales/es-419.cjs +778 -0
  86. package/dist/locales/es-419.cjs.map +1 -0
  87. package/dist/locales/es-419.d.cts +16 -0
  88. package/dist/locales/es-419.d.ts +16 -0
  89. package/dist/locales/es-419.js +23 -0
  90. package/dist/locales/es-419.js.map +1 -0
  91. package/dist/locales/es.cjs +769 -0
  92. package/dist/locales/es.cjs.map +1 -0
  93. package/dist/locales/es.d.cts +14 -0
  94. package/dist/locales/es.d.ts +14 -0
  95. package/dist/locales/es.js +14 -0
  96. package/dist/locales/es.js.map +1 -0
  97. package/dist/locales/fi.cjs +753 -0
  98. package/dist/locales/fi.cjs.map +1 -0
  99. package/dist/locales/fi.d.cts +14 -0
  100. package/dist/locales/fi.d.ts +14 -0
  101. package/dist/locales/fi.js +333 -0
  102. package/dist/locales/fi.js.map +1 -0
  103. package/dist/locales/fr-CA.cjs +777 -0
  104. package/dist/locales/fr-CA.cjs.map +1 -0
  105. package/dist/locales/fr-CA.d.cts +17 -0
  106. package/dist/locales/fr-CA.d.ts +17 -0
  107. package/dist/locales/fr-CA.js +22 -0
  108. package/dist/locales/fr-CA.js.map +1 -0
  109. package/dist/locales/fr.cjs +769 -0
  110. package/dist/locales/fr.cjs.map +1 -0
  111. package/dist/locales/fr.d.cts +14 -0
  112. package/dist/locales/fr.d.ts +14 -0
  113. package/dist/locales/fr.js +14 -0
  114. package/dist/locales/fr.js.map +1 -0
  115. package/dist/locales/gn.cjs +750 -0
  116. package/dist/locales/gn.cjs.map +1 -0
  117. package/dist/locales/gn.d.cts +16 -0
  118. package/dist/locales/gn.d.ts +16 -0
  119. package/dist/locales/gn.js +330 -0
  120. package/dist/locales/gn.js.map +1 -0
  121. package/dist/locales/hr.cjs +769 -0
  122. package/dist/locales/hr.cjs.map +1 -0
  123. package/dist/locales/hr.d.cts +14 -0
  124. package/dist/locales/hr.d.ts +14 -0
  125. package/dist/locales/hr.js +349 -0
  126. package/dist/locales/hr.js.map +1 -0
  127. package/dist/locales/ht.cjs +750 -0
  128. package/dist/locales/ht.cjs.map +1 -0
  129. package/dist/locales/ht.d.cts +16 -0
  130. package/dist/locales/ht.d.ts +16 -0
  131. package/dist/locales/ht.js +330 -0
  132. package/dist/locales/ht.js.map +1 -0
  133. package/dist/locales/hu.cjs +753 -0
  134. package/dist/locales/hu.cjs.map +1 -0
  135. package/dist/locales/hu.d.cts +14 -0
  136. package/dist/locales/hu.d.ts +14 -0
  137. package/dist/locales/hu.js +333 -0
  138. package/dist/locales/hu.js.map +1 -0
  139. package/dist/locales/index.cjs +537 -0
  140. package/dist/locales/index.cjs.map +1 -0
  141. package/dist/locales/index.d.cts +38 -0
  142. package/dist/locales/index.d.ts +38 -0
  143. package/dist/locales/index.js +105 -0
  144. package/dist/locales/index.js.map +1 -0
  145. package/dist/locales/it.cjs +777 -0
  146. package/dist/locales/it.cjs.map +1 -0
  147. package/dist/locales/it.d.cts +14 -0
  148. package/dist/locales/it.d.ts +14 -0
  149. package/dist/locales/it.js +357 -0
  150. package/dist/locales/it.js.map +1 -0
  151. package/dist/locales/nb.cjs +747 -0
  152. package/dist/locales/nb.cjs.map +1 -0
  153. package/dist/locales/nb.d.cts +14 -0
  154. package/dist/locales/nb.d.ts +14 -0
  155. package/dist/locales/nb.js +327 -0
  156. package/dist/locales/nb.js.map +1 -0
  157. package/dist/locales/nl.cjs +753 -0
  158. package/dist/locales/nl.cjs.map +1 -0
  159. package/dist/locales/nl.d.cts +14 -0
  160. package/dist/locales/nl.d.ts +14 -0
  161. package/dist/locales/nl.js +333 -0
  162. package/dist/locales/nl.js.map +1 -0
  163. package/dist/locales/pl.cjs +794 -0
  164. package/dist/locales/pl.cjs.map +1 -0
  165. package/dist/locales/pl.d.cts +14 -0
  166. package/dist/locales/pl.d.ts +14 -0
  167. package/dist/locales/pl.js +374 -0
  168. package/dist/locales/pl.js.map +1 -0
  169. package/dist/locales/pt-BR.cjs +773 -0
  170. package/dist/locales/pt-BR.cjs.map +1 -0
  171. package/dist/locales/pt-BR.d.cts +14 -0
  172. package/dist/locales/pt-BR.d.ts +14 -0
  173. package/dist/locales/pt-BR.js +353 -0
  174. package/dist/locales/pt-BR.js.map +1 -0
  175. package/dist/locales/pt.cjs +777 -0
  176. package/dist/locales/pt.cjs.map +1 -0
  177. package/dist/locales/pt.d.cts +14 -0
  178. package/dist/locales/pt.d.ts +14 -0
  179. package/dist/locales/pt.js +357 -0
  180. package/dist/locales/pt.js.map +1 -0
  181. package/dist/locales/qu.cjs +756 -0
  182. package/dist/locales/qu.cjs.map +1 -0
  183. package/dist/locales/qu.d.cts +16 -0
  184. package/dist/locales/qu.d.ts +16 -0
  185. package/dist/locales/qu.js +336 -0
  186. package/dist/locales/qu.js.map +1 -0
  187. package/dist/locales/ro.cjs +769 -0
  188. package/dist/locales/ro.cjs.map +1 -0
  189. package/dist/locales/ro.d.cts +14 -0
  190. package/dist/locales/ro.d.ts +14 -0
  191. package/dist/locales/ro.js +349 -0
  192. package/dist/locales/ro.js.map +1 -0
  193. package/dist/locales/ru.cjs +789 -0
  194. package/dist/locales/ru.cjs.map +1 -0
  195. package/dist/locales/ru.d.cts +14 -0
  196. package/dist/locales/ru.d.ts +14 -0
  197. package/dist/locales/ru.js +369 -0
  198. package/dist/locales/ru.js.map +1 -0
  199. package/dist/locales/sk.cjs +794 -0
  200. package/dist/locales/sk.cjs.map +1 -0
  201. package/dist/locales/sk.d.cts +14 -0
  202. package/dist/locales/sk.d.ts +14 -0
  203. package/dist/locales/sk.js +374 -0
  204. package/dist/locales/sk.js.map +1 -0
  205. package/dist/locales/sq.cjs +753 -0
  206. package/dist/locales/sq.cjs.map +1 -0
  207. package/dist/locales/sq.d.cts +14 -0
  208. package/dist/locales/sq.d.ts +14 -0
  209. package/dist/locales/sq.js +333 -0
  210. package/dist/locales/sq.js.map +1 -0
  211. package/dist/locales/sr-Latn.cjs +841 -0
  212. package/dist/locales/sr-Latn.cjs.map +1 -0
  213. package/dist/locales/sr-Latn.d.cts +17 -0
  214. package/dist/locales/sr-Latn.d.ts +17 -0
  215. package/dist/locales/sr-Latn.js +86 -0
  216. package/dist/locales/sr-Latn.js.map +1 -0
  217. package/dist/locales/sr.cjs +769 -0
  218. package/dist/locales/sr.cjs.map +1 -0
  219. package/dist/locales/sr.d.cts +14 -0
  220. package/dist/locales/sr.d.ts +14 -0
  221. package/dist/locales/sr.js +14 -0
  222. package/dist/locales/sr.js.map +1 -0
  223. package/dist/locales/sv.cjs +753 -0
  224. package/dist/locales/sv.cjs.map +1 -0
  225. package/dist/locales/sv.d.cts +14 -0
  226. package/dist/locales/sv.d.ts +14 -0
  227. package/dist/locales/sv.js +333 -0
  228. package/dist/locales/sv.js.map +1 -0
  229. package/dist/locales/tr.cjs +750 -0
  230. package/dist/locales/tr.cjs.map +1 -0
  231. package/dist/locales/tr.d.cts +14 -0
  232. package/dist/locales/tr.d.ts +14 -0
  233. package/dist/locales/tr.js +330 -0
  234. package/dist/locales/tr.js.map +1 -0
  235. package/dist/locales/uk.cjs +794 -0
  236. package/dist/locales/uk.cjs.map +1 -0
  237. package/dist/locales/uk.d.cts +14 -0
  238. package/dist/locales/uk.d.ts +14 -0
  239. package/dist/locales/uk.js +374 -0
  240. package/dist/locales/uk.js.map +1 -0
  241. package/dist/markdown.cjs +620 -0
  242. package/dist/markdown.cjs.map +1 -0
  243. package/dist/markdown.d.cts +153 -0
  244. package/dist/markdown.d.ts +153 -0
  245. package/dist/markdown.js +573 -0
  246. package/dist/markdown.js.map +1 -0
  247. package/dist/mcp-app-entry-BA-Ca39z.d.ts +1480 -0
  248. package/dist/mcp-app-entry-tybABaHg.d.cts +1480 -0
  249. package/dist/mcp-app-policy-DXKQ2jjM.d.cts +73 -0
  250. package/dist/mcp-app-policy-DXKQ2jjM.d.ts +73 -0
  251. package/dist/mcp-app-sandbox.cjs +323 -0
  252. package/dist/mcp-app-sandbox.cjs.map +1 -0
  253. package/dist/mcp-app-sandbox.d.cts +70 -0
  254. package/dist/mcp-app-sandbox.d.ts +70 -0
  255. package/dist/mcp-app-sandbox.js +209 -0
  256. package/dist/mcp-app-sandbox.js.map +1 -0
  257. package/dist/mcp-app.cjs +980 -0
  258. package/dist/mcp-app.cjs.map +1 -0
  259. package/dist/mcp-app.d.cts +3 -0
  260. package/dist/mcp-app.d.ts +3 -0
  261. package/dist/mcp-app.js +816 -0
  262. package/dist/mcp-app.js.map +1 -0
  263. package/dist/pipeline.cjs +845 -0
  264. package/dist/pipeline.cjs.map +1 -0
  265. package/dist/pipeline.css +1407 -0
  266. package/dist/pipeline.d.cts +348 -0
  267. package/dist/pipeline.d.ts +348 -0
  268. package/dist/pipeline.js +778 -0
  269. package/dist/pipeline.js.map +1 -0
  270. package/dist/styles.css +4109 -0
  271. package/dist/types-BmvgYUzF.d.cts +19 -0
  272. package/dist/types-Cr5gmUts.d.ts +19 -0
  273. package/package.json +155 -8
@@ -0,0 +1,620 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/markdown/index.ts
21
+ var markdown_exports = {};
22
+ __export(markdown_exports, {
23
+ MARKDOWN_CACHE_MAX: () => MARKDOWN_CACHE_MAX,
24
+ MARKDOWN_LONG_CELL: () => MARKDOWN_LONG_CELL,
25
+ emptyMarkdownStream: () => emptyMarkdownStream,
26
+ markdownCellIsLong: () => markdownCellIsLong,
27
+ markdownPlainText: () => markdownPlainText,
28
+ markdownSettled: () => markdownSettled,
29
+ parseMarkdown: () => parseMarkdown,
30
+ parseMarkdownCached: () => parseMarkdownCached,
31
+ parseMarkdownInline: () => parseMarkdownInline,
32
+ parseMarkdownStreaming: () => parseMarkdownStreaming,
33
+ safeHref: () => safeHref,
34
+ workspaceLinkPath: () => workspaceLinkPath
35
+ });
36
+ module.exports = __toCommonJS(markdown_exports);
37
+
38
+ // src/named-files.ts
39
+ var PATH_MAX = 512;
40
+ var workspacePathOf = (raw) => {
41
+ if (raw.length < 2 || raw.length > PATH_MAX) return void 0;
42
+ if (raw[0] !== "/" || raw[1] === "/") return void 0;
43
+ if (/[\u0000-\u001f\u007f\\]/.test(raw)) return void 0;
44
+ const segments = raw.slice(1).split("/");
45
+ for (const s of segments) {
46
+ if (!s || s === "." || s === ".." || s.trim() !== s) return void 0;
47
+ }
48
+ return raw;
49
+ };
50
+
51
+ // src/markdown/parse.ts
52
+ var decoded = (s) => {
53
+ if (!s.includes("%")) return s;
54
+ try {
55
+ return decodeURIComponent(s);
56
+ } catch {
57
+ return s;
58
+ }
59
+ };
60
+ var PATH_MAX2 = 512;
61
+ var DEST_MAX = 9 * PATH_MAX2;
62
+ var TITLE_MAX = PATH_MAX2;
63
+ var workspaceLinkPath = (raw) => {
64
+ const runs = parseMarkdownInline(`[x](${raw})`);
65
+ return runs.length === 1 && runs[0].t === "file" ? runs[0].path : void 0;
66
+ };
67
+ var safeHref = (url) => {
68
+ const u = url.trim();
69
+ return /^(https?:\/\/|mailto:)[^\s]+$/i.test(u) ? u : void 0;
70
+ };
71
+ var spaceCode = (code) => code === 32 || code >= 9 && code <= 13 || code > 127 && /\s/.test(String.fromCharCode(code));
72
+ var isSpace = (c) => c === void 0 || spaceCode(c.charCodeAt(0));
73
+ var isWord = (c) => {
74
+ if (c === void 0) return false;
75
+ const code = c.charCodeAt(0);
76
+ if (code < 128)
77
+ return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122;
78
+ return /[\p{L}\p{N}]/u.test(c);
79
+ };
80
+ var URL_START = /^https?:\/\//i;
81
+ var URL_TAIL = /[.,;:!?'")\]]+$/;
82
+ var nextOf = (text, test) => {
83
+ const next = new Int32Array(text.length + 1);
84
+ next[text.length] = text.length;
85
+ for (let i = text.length - 1; i >= 0; i--) next[i] = test(text.charCodeAt(i)) ? i : next[i + 1];
86
+ return next;
87
+ };
88
+ var pushText = (out, v) => {
89
+ if (!v) return;
90
+ const last = out[out.length - 1];
91
+ if (last?.t === "text") last.v += v;
92
+ else out.push({ t: "text", v });
93
+ };
94
+ var parseMarkdownInline = (source, depth = 0, tail = false, words = false) => {
95
+ const text = tail ? source.replace(/[*_~`]+$/, "") : source;
96
+ if (depth > 8) return text ? [{ t: "text", v: text }] : [];
97
+ const n = text.length;
98
+ const closeBracket = nextOf(text, (c) => c === 93);
99
+ const closeParen = nextOf(text, (c) => c === 41);
100
+ const newline = nextOf(text, (c) => c === 10);
101
+ const space = nextOf(text, spaceCode);
102
+ const runs = /* @__PURE__ */ new Map();
103
+ for (let i2 = 0; i2 < n; ) {
104
+ if (text[i2] !== "`") {
105
+ i2++;
106
+ continue;
107
+ }
108
+ let j = i2;
109
+ while (j < n && text[j] === "`") j++;
110
+ const list = runs.get(j - i2) ?? [];
111
+ list.push(i2);
112
+ runs.set(j - i2, list);
113
+ i2 = j;
114
+ }
115
+ const cursor = /* @__PURE__ */ new Map();
116
+ let lookups;
117
+ const look = () => lookups ??= {
118
+ lt: nextOf(text, (c) => c === 60),
119
+ gt: nextOf(text, (c) => c === 62),
120
+ openParen: nextOf(text, (c) => c === 40),
121
+ dq: nextOf(text, (c) => c === 34),
122
+ sq: nextOf(text, (c) => c === 39),
123
+ solid: nextOf(text, (c) => !spaceCode(c))
124
+ };
125
+ let readAt = -1;
126
+ let read;
127
+ const fileLinkAt = (close) => {
128
+ if (close !== readAt) {
129
+ readAt = close;
130
+ read = readFileLink(close + 2);
131
+ }
132
+ return read;
133
+ };
134
+ const readFileLink = (start) => {
135
+ const x = look();
136
+ const line = newline[start];
137
+ const p = x.solid[start];
138
+ if (p >= n || p > line) return void 0;
139
+ let from;
140
+ let to;
141
+ let after;
142
+ if (text[p] === "<") {
143
+ from = p + 1;
144
+ if (from < n && text[from] !== "/") return void 0;
145
+ to = x.gt[from];
146
+ const bad = Math.min(x.lt[from], line);
147
+ if (to >= n) return bad >= n && n - from <= DEST_MAX ? "open" : void 0;
148
+ if (bad < to || to - from > DEST_MAX) return void 0;
149
+ after = to + 1;
150
+ } else if (text[p] === "/") {
151
+ from = p;
152
+ if (text[p + 1] === "/") return void 0;
153
+ to = Math.min(space[p], closeParen[p]);
154
+ const bad = Math.min(x.lt[p], x.gt[p], x.openParen[p]);
155
+ if (to >= n) return bad >= n && n - from <= DEST_MAX ? "open" : void 0;
156
+ if (bad < to || to - from > DEST_MAX) return void 0;
157
+ after = to;
158
+ } else return void 0;
159
+ const path = workspacePathOf(decoded(text.slice(from, to)));
160
+ if (!path) return void 0;
161
+ let q = x.solid[after];
162
+ if (q > line) return void 0;
163
+ if (q >= n) return "open";
164
+ if ((text[q] === '"' || text[q] === "'") && q > after) {
165
+ const shut = (text[q] === '"' ? x.dq : x.sq)[q + 1];
166
+ if (shut >= n) return line >= n && n - q <= TITLE_MAX ? "open" : void 0;
167
+ if (shut > line || shut - q > TITLE_MAX) return void 0;
168
+ q = x.solid[shut + 1];
169
+ if (q > line) return void 0;
170
+ if (q >= n) return "open";
171
+ }
172
+ return text[q] === ")" ? { path, end: q } : void 0;
173
+ };
174
+ const tokens = [];
175
+ const flush = (from, to) => {
176
+ let at = from;
177
+ while (at < to) {
178
+ const nl = Math.min(newline[at], to);
179
+ if (nl > at) tokens.push({ t: "text", v: text.slice(at, nl) });
180
+ if (nl < to) tokens.push({ t: "br" });
181
+ at = nl + 1;
182
+ }
183
+ };
184
+ let plain = 0;
185
+ let i = 0;
186
+ while (i < n) {
187
+ const c = text[i];
188
+ if (c === "`") {
189
+ let j = i;
190
+ while (j < n && text[j] === "`") j++;
191
+ const len = j - i;
192
+ const list = runs.get(len);
193
+ let k = cursor.get(len) ?? 0;
194
+ while (k < list.length && list[k] <= i) k++;
195
+ cursor.set(len, k);
196
+ if (k < list.length) {
197
+ flush(plain, i);
198
+ const end = list[k];
199
+ cursor.set(len, k + 1);
200
+ const body = text.slice(j, end).replace(/\n/g, " ");
201
+ const v = /^ .* $/s.test(body) && body.trim() ? body.slice(1, -1) : body;
202
+ const path = !words && v.includes("/") ? workspacePathOf(v) : void 0;
203
+ tokens.push(path ? { t: "code", v, path } : { t: "code", v });
204
+ i = plain = end + len;
205
+ } else if (tail) {
206
+ flush(plain, i);
207
+ const body = text.slice(j).replace(/\n/g, " ");
208
+ tokens.push({ t: "code", v: body.startsWith(" ") && body.trim() ? body.slice(1) : body });
209
+ i = plain = n;
210
+ } else i = j;
211
+ continue;
212
+ }
213
+ if (c === "[") {
214
+ const close = closeBracket[i + 1];
215
+ if (close < n && close > i + 1 && close < newline[i] && text[close + 1] === "(") {
216
+ const end = closeParen[close + 2];
217
+ const href = end < n && space[close + 2] >= end ? safeHref(text.slice(close + 2, end)) : void 0;
218
+ if (href) {
219
+ flush(plain, i);
220
+ tokens.push({
221
+ t: "link",
222
+ href,
223
+ c: parseMarkdownInline(text.slice(i + 1, close), depth + 1, false, true)
224
+ });
225
+ i = plain = end + 1;
226
+ continue;
227
+ }
228
+ const file = fileLinkAt(close);
229
+ if (file !== void 0 && file !== "open") {
230
+ flush(plain, i);
231
+ tokens.push({
232
+ t: "file",
233
+ path: file.path,
234
+ c: parseMarkdownInline(text.slice(i + 1, close), depth + 1, false, true)
235
+ });
236
+ i = plain = file.end + 1;
237
+ continue;
238
+ }
239
+ if (tail && (file === "open" || end >= n && space[close + 2] >= n)) {
240
+ flush(plain, i);
241
+ tokens.push(...parseMarkdownInline(text.slice(i + 1, close), depth + 1, false, true));
242
+ i = plain = n;
243
+ continue;
244
+ }
245
+ }
246
+ if (tail && newline[i] >= n && (close >= n || close === n - 1)) {
247
+ flush(plain, i);
248
+ if (close >= n) {
249
+ i = plain = i + 1;
250
+ continue;
251
+ }
252
+ tokens.push(...parseMarkdownInline(text.slice(i + 1, close), depth + 1));
253
+ i = plain = n;
254
+ continue;
255
+ }
256
+ i++;
257
+ continue;
258
+ }
259
+ if (!words && (c === "h" || c === "H") && URL_START.test(text.slice(i, i + 8)) && !isWord(text[i - 1])) {
260
+ let end = space[i];
261
+ for (let k = i; k < end; k++) {
262
+ if ("<>()".includes(text[k])) {
263
+ end = k;
264
+ break;
265
+ }
266
+ }
267
+ const url = text.slice(i, end).replace(URL_TAIL, "");
268
+ if (url.length > 8) {
269
+ flush(plain, i);
270
+ tokens.push({ t: "link", href: url, c: [{ t: "text", v: url }] });
271
+ i = plain = i + url.length;
272
+ continue;
273
+ }
274
+ i++;
275
+ continue;
276
+ }
277
+ if (c === "*" || c === "_" || c === "~") {
278
+ let j = i;
279
+ while (j < n && text[j] === c) j++;
280
+ const before = text[i - 1];
281
+ const after = text[j];
282
+ let open = !isSpace(after);
283
+ let close = !isSpace(before);
284
+ if (c === "_" && isWord(before) && isWord(after)) open = close = false;
285
+ const len = j - i;
286
+ if (c === "~" && len !== 2 || !open && !close) {
287
+ i = j;
288
+ continue;
289
+ }
290
+ flush(plain, i);
291
+ const sizes = c === "~" ? [2] : len === 1 ? [1] : len === 2 ? [2] : open && !close ? [2, 1] : [1, 2];
292
+ let used = 0;
293
+ for (const size of sizes) {
294
+ tokens.push({ t: "delim", ch: c, n: size, open, close, lead: !isWord(before) });
295
+ used += size;
296
+ }
297
+ if (len > used) tokens.push({ t: "text", v: c.repeat(len - used) });
298
+ i = plain = j;
299
+ continue;
300
+ }
301
+ i++;
302
+ }
303
+ flush(plain, n);
304
+ const stacks = [[], [], [], [], [], []];
305
+ const kindOf = (tok) => (tok.ch === "*" ? 0 : tok.ch === "_" ? 2 : 4) + tok.n - 1;
306
+ for (let idx = 0; idx < tokens.length; idx++) {
307
+ const tok = tokens[idx];
308
+ if (tok.t !== "delim") continue;
309
+ const own = stacks[kindOf(tok)];
310
+ const top = own.length ? own[own.length - 1] : -1;
311
+ if (tok.close && top >= 0 && top < idx - 1) {
312
+ own.pop();
313
+ tokens[top].match = idx;
314
+ tok.match = top;
315
+ for (const st of stacks) while (st.length && st[st.length - 1] > top) st.pop();
316
+ continue;
317
+ }
318
+ if (tok.open) own.push(idx);
319
+ }
320
+ if (tail) {
321
+ const open = stacks.flat().sort((a, b) => b - a);
322
+ for (const idx of open) {
323
+ const opener = tokens[idx];
324
+ if (!opener.lead) continue;
325
+ opener.match = tokens.length;
326
+ tokens.push({ t: "delim", ch: opener.ch, n: opener.n, open: false, close: true, match: idx });
327
+ }
328
+ }
329
+ const root = [];
330
+ const frames = [{ out: root, until: -1 }];
331
+ tokens.forEach((tok, idx) => {
332
+ const frame = frames[frames.length - 1];
333
+ if (tok.t !== "delim") {
334
+ if (tok.t === "text") pushText(frame.out, tok.v);
335
+ else frame.out.push(tok);
336
+ return;
337
+ }
338
+ if (tok.match !== void 0 && tok.match > idx) {
339
+ const node = {
340
+ t: tok.ch === "~" ? "del" : tok.n === 2 ? "strong" : "em",
341
+ c: []
342
+ };
343
+ frames.push({ out: node.c, node, until: tok.match });
344
+ return;
345
+ }
346
+ if (tok.match !== void 0 && frame.until === idx && frame.node) {
347
+ frames.pop();
348
+ frames[frames.length - 1].out.push(frame.node);
349
+ return;
350
+ }
351
+ pushText(frame.out, tok.ch.repeat(tok.n));
352
+ });
353
+ return root;
354
+ };
355
+ var FENCE = /^([ \t]*)(`{3,}|~{3,})\s*([\w+#.-]*)/;
356
+ var HEADING = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/;
357
+ var HR = /^ {0,3}([-*_])(?:\s*\1){2,}\s*$/;
358
+ var BULLET = /^( *)([-*+])\s+(.*)$/;
359
+ var ORDERED = /^( *)(\d{1,9})[.)]\s+(.*)$/;
360
+ var QUOTE = /^ {0,3}>\s?(.*)$/;
361
+ var TABLE_RULE = /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/;
362
+ var LIST_NESTING_MAX = 8;
363
+ var cells = (line) => {
364
+ let s = line.trim();
365
+ if (s.startsWith("|")) s = s.slice(1);
366
+ if (s.endsWith("|") && !s.endsWith("\\|")) s = s.slice(0, -1);
367
+ const out = [];
368
+ let cur = "";
369
+ for (let i = 0; i < s.length; i++) {
370
+ if (s[i] === "\\" && s[i + 1] === "|") {
371
+ cur += "|";
372
+ i++;
373
+ } else if (s[i] === "|") {
374
+ out.push(cur.trim());
375
+ cur = "";
376
+ } else cur += s[i];
377
+ }
378
+ out.push(cur.trim());
379
+ return out;
380
+ };
381
+ var alignOf = (cell) => {
382
+ const c = cell.trim();
383
+ const left = c.startsWith(":");
384
+ const right = c.endsWith(":");
385
+ return left && right ? "center" : right ? "right" : left ? "left" : void 0;
386
+ };
387
+ var startsBlock = (line, next) => FENCE.test(line) || HEADING.test(line) || HR.test(line) || BULLET.test(line) || ORDERED.test(line) || QUOTE.test(line) || line.includes("|") && next !== void 0 && TABLE_RULE.test(next) && next.includes("-");
388
+ var parseMarkdown = (text, depth = 0, streaming = false) => {
389
+ const lines = text.replace(/\r\n?/g, "\n").split("\n");
390
+ const out = [];
391
+ let i = 0;
392
+ const last = (k) => streaming && k >= lines.length - 1;
393
+ while (i < lines.length) {
394
+ const line = lines[i];
395
+ if (!line.trim()) {
396
+ i++;
397
+ continue;
398
+ }
399
+ const fence = FENCE.exec(line);
400
+ if (fence) {
401
+ const body2 = [];
402
+ const indent = new RegExp(`^[ \\t]{0,${fence[1].length}}`);
403
+ i++;
404
+ while (i < lines.length && !lines[i].trimStart().startsWith(fence[2])) {
405
+ body2.push(lines[i++].replace(indent, ""));
406
+ }
407
+ i++;
408
+ out.push({ t: "code", lang: fence[3], v: body2.join("\n") });
409
+ continue;
410
+ }
411
+ const heading = HEADING.exec(line);
412
+ if (heading) {
413
+ out.push({
414
+ t: "h",
415
+ level: heading[1].length,
416
+ c: parseMarkdownInline(heading[2], 0, last(i))
417
+ });
418
+ i++;
419
+ continue;
420
+ }
421
+ if (HR.test(line)) {
422
+ out.push({ t: "hr" });
423
+ i++;
424
+ continue;
425
+ }
426
+ if (QUOTE.test(line) && depth < 4) {
427
+ const body2 = [];
428
+ while (i < lines.length && QUOTE.test(lines[i])) body2.push(QUOTE.exec(lines[i++])[1]);
429
+ out.push({
430
+ t: "quote",
431
+ c: parseMarkdown(body2.join("\n"), depth + 1, streaming && i >= lines.length)
432
+ });
433
+ continue;
434
+ }
435
+ const next = lines[i + 1];
436
+ if (line.includes("|") && next !== void 0 && TABLE_RULE.test(next) && next.includes("-")) {
437
+ const head = cells(line);
438
+ const align = cells(next).map(alignOf);
439
+ i += 2;
440
+ const rows = [];
441
+ while (i < lines.length && lines[i].trim() && lines[i].includes("|")) {
442
+ const row = cells(lines[i]);
443
+ let open = -1;
444
+ if (last(i)) {
445
+ for (let k = 0; k < row.length; k++) if (row[k] !== "") open = k;
446
+ }
447
+ i++;
448
+ rows.push(head.map((_, k) => parseMarkdownInline(row[k] ?? "", 0, k === open)));
449
+ }
450
+ out.push({ t: "table", align, head: head.map((h) => parseMarkdownInline(h)), rows });
451
+ continue;
452
+ }
453
+ if (BULLET.test(line) || ORDERED.test(line)) {
454
+ const ordered = !BULLET.test(line);
455
+ const first = (ordered ? ORDERED : BULLET).exec(line);
456
+ const indent = first[1].length;
457
+ const list = {
458
+ t: "list",
459
+ ordered,
460
+ start: ordered ? Number(first[2]) : 1,
461
+ items: []
462
+ };
463
+ while (i < lines.length) {
464
+ const l = lines[i];
465
+ const m = (ordered ? ORDERED : BULLET).exec(l);
466
+ if (m && m[1].length <= indent + 1) {
467
+ list.items.push({ c: parseMarkdownInline(m[3], 0, last(i)) });
468
+ i++;
469
+ continue;
470
+ }
471
+ const nested = BULLET.exec(l) ?? ORDERED.exec(l);
472
+ if (nested && nested[1].length > indent + 1 && list.items.length) {
473
+ if (depth >= LIST_NESTING_MAX) {
474
+ list.items.push({ c: parseMarkdownInline(nested[3], 0, last(i)) });
475
+ i++;
476
+ continue;
477
+ }
478
+ const subLines = [];
479
+ while (i < lines.length) {
480
+ const s = BULLET.exec(lines[i]) ?? ORDERED.exec(lines[i]);
481
+ if (!s || s[1].length <= indent + 1) break;
482
+ subLines.push(lines[i++].slice(nested[1].length));
483
+ }
484
+ const sub = parseMarkdown(
485
+ subLines.join("\n"),
486
+ depth + 1,
487
+ streaming && i >= lines.length
488
+ ).find((b) => b.t === "list");
489
+ if (sub) list.items[list.items.length - 1].sub = sub;
490
+ continue;
491
+ }
492
+ if (l.trim() && /^\s+/.test(l) && !startsBlock(l.trim(), lines[i + 1]) && list.items.length) {
493
+ const item = list.items[list.items.length - 1];
494
+ item.c.push({ t: "br" }, ...parseMarkdownInline(l.trim(), 0, last(i)));
495
+ i++;
496
+ continue;
497
+ }
498
+ break;
499
+ }
500
+ out.push(list);
501
+ continue;
502
+ }
503
+ const body = [line];
504
+ i++;
505
+ while (i < lines.length && lines[i].trim() && !startsBlock(lines[i], lines[i + 1])) {
506
+ body.push(lines[i++]);
507
+ }
508
+ out.push({
509
+ t: "p",
510
+ c: parseMarkdownInline(
511
+ body.map((l) => l.trim()).join("\n"),
512
+ 0,
513
+ streaming && i >= lines.length
514
+ )
515
+ });
516
+ }
517
+ return out;
518
+ };
519
+
520
+ // src/markdown/stream.ts
521
+ var FENCE2 = /^[ \t]*(`{3,}|~{3,})/;
522
+ var MARKERS_ONLY = /^[\s#>*+\-_|`~=:\d.)]{0,16}$/;
523
+ var RULE_SO_FAR = /^\s*\|?[\s:|-]*$/;
524
+ var pipes = (line) => line !== void 0 && line.includes("|");
525
+ var blank = (line) => line === void 0 || !line.trim();
526
+ var markdownSettled = (text) => {
527
+ const lines = text.split("\n");
528
+ const n = lines.length;
529
+ let fence;
530
+ for (let i = 0; i < n - 1; i++) {
531
+ const line = lines[i];
532
+ if (fence) {
533
+ if (line.trimStart().startsWith(fence)) fence = void 0;
534
+ } else {
535
+ const m = FENCE2.exec(line);
536
+ if (m) fence = m[1];
537
+ }
538
+ }
539
+ const lastLine = lines[n - 1];
540
+ const cut = (count) => lines.slice(0, n - count).join("\n") + (n > count ? "\n" : "");
541
+ if (fence) {
542
+ const t = lastLine.trim();
543
+ return !t || fence.startsWith(t) ? cut(1) : text;
544
+ }
545
+ const inTable = (k) => pipes(lines[k]) && !blank(lines[k]);
546
+ if (n >= 2 && lines[n - 2].trimStart().startsWith("|") && RULE_SO_FAR.test(lastLine) && !inTable(n - 3))
547
+ return cut(2);
548
+ if (lastLine.trimStart().startsWith("|") && !inTable(n - 2)) return cut(1);
549
+ if (lastLine && MARKERS_ONLY.test(lastLine)) return cut(1);
550
+ return text;
551
+ };
552
+ var finishedEnd = (text, from) => {
553
+ let fence;
554
+ let end = from;
555
+ let at = from;
556
+ while (at < text.length) {
557
+ const nl = text.indexOf("\n", at);
558
+ if (nl < 0) break;
559
+ const line = text.slice(at, nl);
560
+ if (fence) {
561
+ if (line.trimStart().startsWith(fence)) fence = void 0;
562
+ } else {
563
+ const m = FENCE2.exec(line);
564
+ if (m) fence = m[1];
565
+ else if (!line.trim()) end = nl + 1;
566
+ }
567
+ at = nl + 1;
568
+ }
569
+ return end;
570
+ };
571
+ var emptyMarkdownStream = () => ({ done: "", finished: [], blocks: [] });
572
+ var parseMarkdownStreaming = (prev, text) => {
573
+ const source = text.includes("\r") ? text.replace(/\r\n?/g, "\n") : text;
574
+ const base = source.startsWith(prev.done) ? prev : emptyMarkdownStream();
575
+ const end = finishedEnd(source, base.done.length);
576
+ const finished = end > base.done.length ? [...base.finished, ...parseMarkdown(source.slice(base.done.length, end))] : base.finished;
577
+ const tail = parseMarkdown(markdownSettled(source.slice(end)).replace(/\n$/, ""), 0, true);
578
+ return {
579
+ done: source.slice(0, end),
580
+ finished,
581
+ blocks: tail.length ? [...finished, ...tail] : finished
582
+ };
583
+ };
584
+
585
+ // src/markdown/render.ts
586
+ var MARKDOWN_CACHE_MAX = 64;
587
+ var parsed = /* @__PURE__ */ new Map();
588
+ var parseMarkdownCached = (text) => {
589
+ const hit = parsed.get(text);
590
+ if (hit) return hit;
591
+ const blocks = parseMarkdown(text);
592
+ parsed.set(text, blocks);
593
+ if (parsed.size > MARKDOWN_CACHE_MAX) parsed.delete(parsed.keys().next().value);
594
+ return blocks;
595
+ };
596
+ var markdownPlainText = (runs) => runs.map(
597
+ (r) => r.t === "text" || r.t === "code" ? r.v : r.t === "br" ? " " : markdownPlainText(r.c)
598
+ ).join("");
599
+ var MARKDOWN_LONG_CELL = 48;
600
+ var lengthOf = (runs) => runs.reduce(
601
+ (n, r) => n + (r.t === "text" || r.t === "code" ? r.v.length : r.t === "br" ? 1 : lengthOf(r.c)),
602
+ 0
603
+ );
604
+ var markdownCellIsLong = (runs) => lengthOf(runs) > MARKDOWN_LONG_CELL;
605
+ // Annotate the CommonJS export names for ESM import in node:
606
+ 0 && (module.exports = {
607
+ MARKDOWN_CACHE_MAX,
608
+ MARKDOWN_LONG_CELL,
609
+ emptyMarkdownStream,
610
+ markdownCellIsLong,
611
+ markdownPlainText,
612
+ markdownSettled,
613
+ parseMarkdown,
614
+ parseMarkdownCached,
615
+ parseMarkdownInline,
616
+ parseMarkdownStreaming,
617
+ safeHref,
618
+ workspaceLinkPath
619
+ });
620
+ //# sourceMappingURL=markdown.cjs.map