eddyter 1.4.17 → 1.4.19-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/AIChatPlugin-r4Q1CC4S.js +1042 -0
  2. package/dist/CombinedAutocompletGrammarPlugin-BuAfoCfe.js +1829 -0
  3. package/dist/{CommentBubblePlugin-J3r4kNGK.js → CommentBubblePlugin-B8Q5ZxWY.js} +7 -7
  4. package/dist/CommentPlugin-BICzJnwy.js +197 -0
  5. package/dist/{LazySignatureCanvas-D1t8oQDK.js → LazySignatureCanvas-BtcxlSTW.js} +1 -1
  6. package/dist/{NotePanelPlugin-C16G36Jd.js → NotePanelPlugin-igN9zPi_.js} +1 -1
  7. package/dist/{TextEnhancePlugin-BShY1r5J.js → TextEnhancePlugin-q9i0TKCN.js} +14 -13
  8. package/dist/_commonjsHelpers-DaMA6jEr.js +8 -0
  9. package/dist/assets/style.css +1 -1
  10. package/dist/components/AnimatedPlaceholderText.d.ts +2 -0
  11. package/dist/components/CommentToggle/CommentToggle.d.ts +1 -0
  12. package/dist/components/ConfigurableEditorWithAuth.d.ts +2 -0
  13. package/dist/components/DividerPicker/DividerPicker.d.ts +17 -0
  14. package/dist/components/EditorialDivider/EditorialDividerView.d.ts +23 -0
  15. package/dist/components/EmojiPickerWidget/EmojiPickerWidget.d.ts +1 -1
  16. package/dist/components/LockedFeature/LockedFeature.d.ts +4 -0
  17. package/dist/components/Toolbar/styles.d.ts +19 -1
  18. package/dist/components/UnifiedColorPicker/UnifiedColorPicker.d.ts +1 -0
  19. package/dist/components/ui/button.d.ts +1 -1
  20. package/dist/components/ui/separator.d.ts +4 -1
  21. package/dist/constants.d.ts +12 -1
  22. package/dist/editor/components/FloatingToolbarManager.d.ts +2 -1
  23. package/dist/editor/components/ToolbarMount.d.ts +2 -1
  24. package/dist/editorConfig.d.ts +7 -0
  25. package/dist/{generateDocxThumbnail-Ve0zlObJ.js → generateDocxThumbnail-wh4lnFAw.js} +7 -6
  26. package/dist/{generatePdfThumbnail-EuSjdwzm.js → generatePdfThumbnail-DQyYzjOS.js} +1 -1
  27. package/dist/{generateXlsxThumbnail-C10kl6qh.js → generateXlsxThumbnail-DqvyM6q9.js} +1 -1
  28. package/dist/hooks/useEditorToolbar.d.ts +1 -1
  29. package/dist/{html2pdf.bundle.min-BQaO0VTp.js → html2pdf.bundle.min-u-o_L5zA.js} +1 -1
  30. package/dist/{index-B8zPtmsK.js → index-BWs0p6X8.js} +14 -14
  31. package/dist/{index-ClsuXAKJ.js → index-Bzry1HiS.js} +13 -13
  32. package/dist/index-DEW_Wgag.js +1508 -0
  33. package/dist/{index-gPq4n7_a.js → index-DQah7JmS.js} +113 -116
  34. package/dist/{index-CxOOJD40.js → index-jEC_qTLD.js} +18727 -17647
  35. package/dist/{index-BSgLtgyt.js → index-m-NFtIUR.js} +21 -21
  36. package/dist/index-w_DzPr7S.js +796 -0
  37. package/dist/index.js +8 -8
  38. package/dist/nodes/AsterismNode.d.ts +22 -0
  39. package/dist/nodes/ButtonNode.d.ts +37 -0
  40. package/dist/nodes/ColumnNode.d.ts +44 -0
  41. package/dist/nodes/ColumnsNode.d.ts +45 -0
  42. package/dist/nodes/EditorialFieldNode.d.ts +32 -0
  43. package/dist/nodes/FaqNode.d.ts +28 -0
  44. package/dist/nodes/ImagePlaceholderNode.d.ts +15 -0
  45. package/dist/nodes/LabeledRuleNode.d.ts +33 -0
  46. package/dist/nodes/OrnamentDividerNode.d.ts +22 -0
  47. package/dist/nodes/PullQuoteRulesNode.d.ts +32 -0
  48. package/dist/nodes/SectionNumberHeadingNode.d.ts +42 -0
  49. package/dist/pages/ConfigurableEditor/ConfigurableEditor.d.ts +1 -0
  50. package/dist/plugins/BlockLayoutPlugin.d.ts +29 -0
  51. package/dist/plugins/ColumnAddButtonPlugin.d.ts +12 -0
  52. package/dist/plugins/CommentPlugin.commands.d.ts +1 -0
  53. package/dist/plugins/CustomHorizontalRulePlugin/CustomHorizontalRuleNode.d.ts +12 -2
  54. package/dist/plugins/CustomHorizontalRulePlugin/HorizontalRuleCustomizationDialog.d.ts +2 -1
  55. package/dist/plugins/CustomHorizontalRulePlugin/styles.d.ts +38 -0
  56. package/dist/plugins/EditorialFloatingToolbarPlugin.d.ts +8 -0
  57. package/dist/plugins/EditorialTypographyPlugin.d.ts +18 -0
  58. package/dist/plugins/PatternsPlugin.d.ts +12 -0
  59. package/dist/plugins/WordCountPlugin.d.ts +1 -0
  60. package/dist/sparkles-N8q1Rg6P.js +17 -0
  61. package/dist/types.d.ts +12 -0
  62. package/dist/ui/Icons.d.ts +21 -7
  63. package/dist/{useVoiceToText-DCddJzYF.js → useVoiceToText-BSB1QOIb.js} +22 -22
  64. package/package.json +1 -1
  65. package/dist/AIChatPlugin-2pIKhzIw.js +0 -871
  66. package/dist/CommentPlugin-BbuE8_Aj.js +0 -154
  67. package/dist/index-CoLO4gm_.js +0 -719
  68. package/dist/index-D25uusM-.js +0 -1430
  69. package/dist/square-DrMKkLmP.js +0 -7
@@ -0,0 +1,1829 @@
1
+ import { jsx as v, jsxs as L, Fragment as Ee } from "react/jsx-runtime";
2
+ import { c as ve, a3 as Q, a4 as ye, a5 as be, a6 as ke, a7 as Se, a8 as Me, a0 as Ne, a9 as Vt, aa as Re } from "./index-jEC_qTLD.js";
3
+ import { $isCodeNode as Ie } from "@lexical/code";
4
+ import { useLexicalComposerContext as Oe } from "@lexical/react/LexicalComposerContext";
5
+ import { $getRoot as It, $getSelection as zt, $isRangeSelection as qt, $isTextNode as ut, $getNodeByKey as Gt, $createRangeSelection as Le, $setSelection as Ae, KEY_ARROW_DOWN_COMMAND as Be, COMMAND_PRIORITY_LOW as at, KEY_ARROW_UP_COMMAND as Pe, KEY_ESCAPE_COMMAND as De, KEY_TAB_COMMAND as _e, KEY_ENTER_COMMAND as Te, createCommand as He, $isElementNode as Fe } from "lexical";
6
+ import { g as We } from "./_commonjsHelpers-DaMA6jEr.js";
7
+ import * as st from "react";
8
+ import { useRef as B, useState as q, useEffect as T, useCallback as G } from "react";
9
+ import { createPortal as Xt } from "react-dom";
10
+ import { S as $e } from "./sparkles-N8q1Rg6P.js";
11
+ const Yt = ve("BookOpen", [
12
+ ["path", { d: "M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z", key: "vv98re" }],
13
+ ["path", { d: "M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z", key: "1cyq3y" }]
14
+ ]);
15
+ var yt = { exports: {} }, bt = { exports: {} }, jt;
16
+ function Ke() {
17
+ return jt || (jt = 1, (function() {
18
+ var o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", t = {
19
+ // Bit-wise rotation left
20
+ rotl: function(e, n) {
21
+ return e << n | e >>> 32 - n;
22
+ },
23
+ // Bit-wise rotation right
24
+ rotr: function(e, n) {
25
+ return e << 32 - n | e >>> n;
26
+ },
27
+ // Swap big-endian to little-endian and vice versa
28
+ endian: function(e) {
29
+ if (e.constructor == Number)
30
+ return t.rotl(e, 8) & 16711935 | t.rotl(e, 24) & 4278255360;
31
+ for (var n = 0; n < e.length; n++)
32
+ e[n] = t.endian(e[n]);
33
+ return e;
34
+ },
35
+ // Generate an array of any length of random bytes
36
+ randomBytes: function(e) {
37
+ for (var n = []; e > 0; e--)
38
+ n.push(Math.floor(Math.random() * 256));
39
+ return n;
40
+ },
41
+ // Convert a byte array to big-endian 32-bit words
42
+ bytesToWords: function(e) {
43
+ for (var n = [], c = 0, d = 0; c < e.length; c++, d += 8)
44
+ n[d >>> 5] |= e[c] << 24 - d % 32;
45
+ return n;
46
+ },
47
+ // Convert big-endian 32-bit words to a byte array
48
+ wordsToBytes: function(e) {
49
+ for (var n = [], c = 0; c < e.length * 32; c += 8)
50
+ n.push(e[c >>> 5] >>> 24 - c % 32 & 255);
51
+ return n;
52
+ },
53
+ // Convert a byte array to a hex string
54
+ bytesToHex: function(e) {
55
+ for (var n = [], c = 0; c < e.length; c++)
56
+ n.push((e[c] >>> 4).toString(16)), n.push((e[c] & 15).toString(16));
57
+ return n.join("");
58
+ },
59
+ // Convert a hex string to a byte array
60
+ hexToBytes: function(e) {
61
+ for (var n = [], c = 0; c < e.length; c += 2)
62
+ n.push(parseInt(e.substr(c, 2), 16));
63
+ return n;
64
+ },
65
+ // Convert a byte array to a base-64 string
66
+ bytesToBase64: function(e) {
67
+ for (var n = [], c = 0; c < e.length; c += 3)
68
+ for (var d = e[c] << 16 | e[c + 1] << 8 | e[c + 2], h = 0; h < 4; h++)
69
+ c * 8 + h * 6 <= e.length * 8 ? n.push(o.charAt(d >>> 6 * (3 - h) & 63)) : n.push("=");
70
+ return n.join("");
71
+ },
72
+ // Convert a base-64 string to a byte array
73
+ base64ToBytes: function(e) {
74
+ e = e.replace(/[^A-Z0-9+\/]/ig, "");
75
+ for (var n = [], c = 0, d = 0; c < e.length; d = ++c % 4)
76
+ d != 0 && n.push((o.indexOf(e.charAt(c - 1)) & Math.pow(2, -2 * d + 8) - 1) << d * 2 | o.indexOf(e.charAt(c)) >>> 6 - d * 2);
77
+ return n;
78
+ }
79
+ };
80
+ bt.exports = t;
81
+ })()), bt.exports;
82
+ }
83
+ var kt, Jt;
84
+ function Zt() {
85
+ if (Jt) return kt;
86
+ Jt = 1;
87
+ var o = {
88
+ // UTF-8 encoding
89
+ utf8: {
90
+ // Convert a string to a byte array
91
+ stringToBytes: function(t) {
92
+ return o.bin.stringToBytes(unescape(encodeURIComponent(t)));
93
+ },
94
+ // Convert a byte array to a string
95
+ bytesToString: function(t) {
96
+ return decodeURIComponent(escape(o.bin.bytesToString(t)));
97
+ }
98
+ },
99
+ // Binary encoding
100
+ bin: {
101
+ // Convert a string to a byte array
102
+ stringToBytes: function(t) {
103
+ for (var e = [], n = 0; n < t.length; n++)
104
+ e.push(t.charCodeAt(n) & 255);
105
+ return e;
106
+ },
107
+ // Convert a byte array to a string
108
+ bytesToString: function(t) {
109
+ for (var e = [], n = 0; n < t.length; n++)
110
+ e.push(String.fromCharCode(t[n]));
111
+ return e.join("");
112
+ }
113
+ }
114
+ };
115
+ return kt = o, kt;
116
+ }
117
+ var St, Qt;
118
+ function Ue() {
119
+ if (Qt) return St;
120
+ Qt = 1, St = function(e) {
121
+ return e != null && (o(e) || t(e) || !!e._isBuffer);
122
+ };
123
+ function o(e) {
124
+ return !!e.constructor && typeof e.constructor.isBuffer == "function" && e.constructor.isBuffer(e);
125
+ }
126
+ function t(e) {
127
+ return typeof e.readFloatLE == "function" && typeof e.slice == "function" && o(e.slice(0, 0));
128
+ }
129
+ return St;
130
+ }
131
+ var te;
132
+ function Ve() {
133
+ return te || (te = 1, (function() {
134
+ var o = Ke(), t = Zt().utf8, e = Ue(), n = Zt().bin, c = function(d, h) {
135
+ d.constructor == String ? h && h.encoding === "binary" ? d = n.stringToBytes(d) : d = t.stringToBytes(d) : e(d) ? d = Array.prototype.slice.call(d, 0) : !Array.isArray(d) && d.constructor !== Uint8Array && (d = d.toString());
136
+ for (var r = o.bytesToWords(d), w = d.length * 8, i = 1732584193, s = -271733879, l = -1732584194, a = 271733878, f = 0; f < r.length; f++)
137
+ r[f] = (r[f] << 8 | r[f] >>> 24) & 16711935 | (r[f] << 24 | r[f] >>> 8) & 4278255360;
138
+ r[w >>> 5] |= 128 << w % 32, r[(w + 64 >>> 9 << 4) + 14] = w;
139
+ for (var M = c._ff, k = c._gg, S = c._hh, N = c._ii, f = 0; f < r.length; f += 16) {
140
+ var J = i, P = s, H = l, X = a;
141
+ i = M(i, s, l, a, r[f + 0], 7, -680876936), a = M(a, i, s, l, r[f + 1], 12, -389564586), l = M(l, a, i, s, r[f + 2], 17, 606105819), s = M(s, l, a, i, r[f + 3], 22, -1044525330), i = M(i, s, l, a, r[f + 4], 7, -176418897), a = M(a, i, s, l, r[f + 5], 12, 1200080426), l = M(l, a, i, s, r[f + 6], 17, -1473231341), s = M(s, l, a, i, r[f + 7], 22, -45705983), i = M(i, s, l, a, r[f + 8], 7, 1770035416), a = M(a, i, s, l, r[f + 9], 12, -1958414417), l = M(l, a, i, s, r[f + 10], 17, -42063), s = M(s, l, a, i, r[f + 11], 22, -1990404162), i = M(i, s, l, a, r[f + 12], 7, 1804603682), a = M(a, i, s, l, r[f + 13], 12, -40341101), l = M(l, a, i, s, r[f + 14], 17, -1502002290), s = M(s, l, a, i, r[f + 15], 22, 1236535329), i = k(i, s, l, a, r[f + 1], 5, -165796510), a = k(a, i, s, l, r[f + 6], 9, -1069501632), l = k(l, a, i, s, r[f + 11], 14, 643717713), s = k(s, l, a, i, r[f + 0], 20, -373897302), i = k(i, s, l, a, r[f + 5], 5, -701558691), a = k(a, i, s, l, r[f + 10], 9, 38016083), l = k(l, a, i, s, r[f + 15], 14, -660478335), s = k(s, l, a, i, r[f + 4], 20, -405537848), i = k(i, s, l, a, r[f + 9], 5, 568446438), a = k(a, i, s, l, r[f + 14], 9, -1019803690), l = k(l, a, i, s, r[f + 3], 14, -187363961), s = k(s, l, a, i, r[f + 8], 20, 1163531501), i = k(i, s, l, a, r[f + 13], 5, -1444681467), a = k(a, i, s, l, r[f + 2], 9, -51403784), l = k(l, a, i, s, r[f + 7], 14, 1735328473), s = k(s, l, a, i, r[f + 12], 20, -1926607734), i = S(i, s, l, a, r[f + 5], 4, -378558), a = S(a, i, s, l, r[f + 8], 11, -2022574463), l = S(l, a, i, s, r[f + 11], 16, 1839030562), s = S(s, l, a, i, r[f + 14], 23, -35309556), i = S(i, s, l, a, r[f + 1], 4, -1530992060), a = S(a, i, s, l, r[f + 4], 11, 1272893353), l = S(l, a, i, s, r[f + 7], 16, -155497632), s = S(s, l, a, i, r[f + 10], 23, -1094730640), i = S(i, s, l, a, r[f + 13], 4, 681279174), a = S(a, i, s, l, r[f + 0], 11, -358537222), l = S(l, a, i, s, r[f + 3], 16, -722521979), s = S(s, l, a, i, r[f + 6], 23, 76029189), i = S(i, s, l, a, r[f + 9], 4, -640364487), a = S(a, i, s, l, r[f + 12], 11, -421815835), l = S(l, a, i, s, r[f + 15], 16, 530742520), s = S(s, l, a, i, r[f + 2], 23, -995338651), i = N(i, s, l, a, r[f + 0], 6, -198630844), a = N(a, i, s, l, r[f + 7], 10, 1126891415), l = N(l, a, i, s, r[f + 14], 15, -1416354905), s = N(s, l, a, i, r[f + 5], 21, -57434055), i = N(i, s, l, a, r[f + 12], 6, 1700485571), a = N(a, i, s, l, r[f + 3], 10, -1894986606), l = N(l, a, i, s, r[f + 10], 15, -1051523), s = N(s, l, a, i, r[f + 1], 21, -2054922799), i = N(i, s, l, a, r[f + 8], 6, 1873313359), a = N(a, i, s, l, r[f + 15], 10, -30611744), l = N(l, a, i, s, r[f + 6], 15, -1560198380), s = N(s, l, a, i, r[f + 13], 21, 1309151649), i = N(i, s, l, a, r[f + 4], 6, -145523070), a = N(a, i, s, l, r[f + 11], 10, -1120210379), l = N(l, a, i, s, r[f + 2], 15, 718787259), s = N(s, l, a, i, r[f + 9], 21, -343485551), i = i + J >>> 0, s = s + P >>> 0, l = l + H >>> 0, a = a + X >>> 0;
142
+ }
143
+ return o.endian([i, s, l, a]);
144
+ };
145
+ c._ff = function(d, h, r, w, i, s, l) {
146
+ var a = d + (h & r | ~h & w) + (i >>> 0) + l;
147
+ return (a << s | a >>> 32 - s) + h;
148
+ }, c._gg = function(d, h, r, w, i, s, l) {
149
+ var a = d + (h & w | r & ~w) + (i >>> 0) + l;
150
+ return (a << s | a >>> 32 - s) + h;
151
+ }, c._hh = function(d, h, r, w, i, s, l) {
152
+ var a = d + (h ^ r ^ w) + (i >>> 0) + l;
153
+ return (a << s | a >>> 32 - s) + h;
154
+ }, c._ii = function(d, h, r, w, i, s, l) {
155
+ var a = d + (r ^ (h | ~w)) + (i >>> 0) + l;
156
+ return (a << s | a >>> 32 - s) + h;
157
+ }, c._blocksize = 16, c._digestsize = 16, yt.exports = function(d, h) {
158
+ if (d == null)
159
+ throw new Error("Illegal argument " + d);
160
+ var r = o.wordsToBytes(c(d, h));
161
+ return h && h.asBytes ? r : h && h.asString ? n.bytesToString(r) : o.bytesToHex(r);
162
+ };
163
+ })()), yt.exports;
164
+ }
165
+ var ze = Ve();
166
+ const qe = /* @__PURE__ */ We(ze);
167
+ var ee;
168
+ (function(o) {
169
+ o.Document = "Document", o.DocumentExit = "Document:exit", o.Paragraph = "Paragraph", o.ParagraphExit = "Paragraph:exit", o.BlockQuote = "BlockQuote", o.BlockQuoteExit = "BlockQuote:exit", o.ListItem = "ListItem", o.ListItemExit = "ListItem:exit", o.List = "List", o.ListExit = "List:exit", o.Header = "Header", o.HeaderExit = "Header:exit", o.CodeBlock = "CodeBlock", o.CodeBlockExit = "CodeBlock:exit", o.HtmlBlock = "HtmlBlock", o.HtmlBlockExit = "HtmlBlock:exit", o.HorizontalRule = "HorizontalRule", o.HorizontalRuleExit = "HorizontalRule:exit", o.Comment = "Comment", o.CommentExit = "Comment:exit", o.ReferenceDef = "ReferenceDef", o.ReferenceDefExit = "ReferenceDef:exit", o.Str = "Str", o.StrExit = "Str:exit", o.Break = "Break", o.BreakExit = "Break:exit", o.Emphasis = "Emphasis", o.EmphasisExit = "Emphasis:exit", o.Strong = "Strong", o.StrongExit = "Strong:exit", o.Html = "Html", o.HtmlExit = "Html:exit", o.Link = "Link", o.LinkExit = "Link:exit", o.Image = "Image", o.ImageExit = "Image:exit", o.Code = "Code", o.CodeExit = "Code:exit", o.Delete = "Delete", o.DeleteExit = "Delete:exit", o.Table = "Table", o.TableExit = "Table:exit", o.TableRow = "TableRow", o.TableRowExit = "TableRow:exit", o.TableCell = "TableCell", o.TableCellExit = "TableCell:exit";
170
+ })(ee || (ee = {}));
171
+ var lt = {}, U = {}, re;
172
+ function Ge() {
173
+ if (re) return U;
174
+ re = 1, Object.defineProperty(U, "__esModule", { value: !0 }), U.binarySearch = U.upperBound = U.lowerBound = U.compare = void 0;
175
+ function o(c, d) {
176
+ return c < d;
177
+ }
178
+ U.compare = o;
179
+ function t(c, d, h = o) {
180
+ let r = c.length, w = 0;
181
+ for (; r; ) {
182
+ let i = r >>> 1, s = w + i;
183
+ h(d, c[s]) ? r = i : (w = s + 1, r -= i + 1);
184
+ }
185
+ return w;
186
+ }
187
+ U.upperBound = t;
188
+ function e(c, d, h = o) {
189
+ let r = c.length, w = 0;
190
+ for (; r; ) {
191
+ let i = r >>> 1, s = w + i;
192
+ h(c[s], d) ? (w = s + 1, r -= i + 1) : r = i;
193
+ }
194
+ return w;
195
+ }
196
+ U.lowerBound = e;
197
+ function n(c, d, h = o) {
198
+ let r = e(c, d, h);
199
+ return r !== c.length && !h(d, c[r]);
200
+ }
201
+ return U.binarySearch = n, U;
202
+ }
203
+ var ne;
204
+ function Xe() {
205
+ if (ne) return lt;
206
+ ne = 1, Object.defineProperty(lt, "__esModule", { value: !0 }), lt.StructuredSource = void 0;
207
+ const o = Ge();
208
+ class t {
209
+ /**
210
+ * @constructs StructuredSource
211
+ * @param {string} source - source code text.
212
+ */
213
+ constructor(n) {
214
+ this.indice = [0];
215
+ let c = /[\r\n\u2028\u2029]/g;
216
+ const d = n.length;
217
+ for (c.lastIndex = 0; ; ) {
218
+ let h = c.exec(n);
219
+ if (!h)
220
+ break;
221
+ let r = h.index;
222
+ n.charCodeAt(r) === 13 && n.charCodeAt(r + 1) === 10 && (r += 1);
223
+ let w = r + 1;
224
+ if (d < w)
225
+ break;
226
+ this.indice.push(w), c.lastIndex = w;
227
+ }
228
+ }
229
+ get line() {
230
+ return this.indice.length;
231
+ }
232
+ /**
233
+ * @param {SourceLocation} loc - location indicator.
234
+ * @return {[ number, number ]} range.
235
+ */
236
+ locationToRange(n) {
237
+ return [this.positionToIndex(n.start), this.positionToIndex(n.end)];
238
+ }
239
+ /**
240
+ * @param {[ number, number ]} range - pair of indice.
241
+ * @return {SourceLocation} location.
242
+ */
243
+ rangeToLocation(n) {
244
+ return {
245
+ start: this.indexToPosition(n[0]),
246
+ end: this.indexToPosition(n[1])
247
+ };
248
+ }
249
+ /**
250
+ * @param {SourcePosition} pos - position indicator.
251
+ * @return {number} index.
252
+ */
253
+ positionToIndex(n) {
254
+ return this.indice[n.line - 1] + n.column;
255
+ }
256
+ /**
257
+ * @param {number} index - index to the source code.
258
+ * @return {SourcePosition} position.
259
+ */
260
+ indexToPosition(n) {
261
+ const c = (0, o.upperBound)(this.indice, n);
262
+ return {
263
+ line: c,
264
+ column: n - this.indice[c - 1]
265
+ };
266
+ }
267
+ }
268
+ return lt.StructuredSource = t, lt;
269
+ }
270
+ var oe = Xe();
271
+ const Ye = (o, t) => {
272
+ for (let e = o.length - 1; e >= 0; e--)
273
+ if (t(o[e], e, o))
274
+ return e;
275
+ return -1;
276
+ };
277
+ class je {
278
+ index = 0;
279
+ source;
280
+ textCharacters;
281
+ sourceNode;
282
+ // active context
283
+ contexts = [];
284
+ // These context is consumed
285
+ // It is used for attaching context to AST
286
+ consumedContexts = [];
287
+ contextRanges = [];
288
+ firstChildPadding;
289
+ startOffset;
290
+ constructor(t) {
291
+ if (typeof t == "string")
292
+ this.textCharacters = t.split(""), this.source = new oe.StructuredSource(t), this.startOffset = 0, this.firstChildPadding = 0;
293
+ else {
294
+ this.sourceNode = t, this.startOffset = this.sourceNode.range[0], this.index = this.startOffset;
295
+ const e = Array.from(new Array(this.sourceNode.loc.start.line - 1)).fill(`
296
+ `), n = Array.from(new Array(this.startOffset - e.length)).fill("∯"), c = t.raw.split("");
297
+ this.textCharacters = [...e, ...n, ...c], this.source = new oe.StructuredSource(this.textCharacters.join("")), this.sourceNode.children[0] ? this.firstChildPadding = this.sourceNode.children[0].range[0] - this.startOffset : this.firstChildPadding = 0;
298
+ }
299
+ }
300
+ get length() {
301
+ return this.textCharacters.length;
302
+ }
303
+ // range mark is for abbreviation
304
+ markContextRange(t) {
305
+ this.contextRanges.push(t);
306
+ }
307
+ isInContextRange() {
308
+ const t = this.offset;
309
+ return this.contextRanges.some((e) => e[0] <= t && t < e[1]);
310
+ }
311
+ // context is for pair mark
312
+ enterContext(t) {
313
+ this.contexts.push([t, this.index]);
314
+ }
315
+ isInContext(t) {
316
+ return t ? this.contexts.some((e) => e[0].key === t.key) : this.contexts.length > 0;
317
+ }
318
+ leaveContext(t) {
319
+ const e = Ye(this.contexts, (n) => n[0].key === t.key);
320
+ if (e !== -1) {
321
+ const n = this.contexts[e];
322
+ this.contexts.splice(e, 1);
323
+ const c = [n[1], this.index];
324
+ this.consumedContexts.push({
325
+ pairMark: n[0],
326
+ range: [n[1], this.index],
327
+ loc: this.source.rangeToLocation(c)
328
+ });
329
+ }
330
+ }
331
+ /**
332
+ * Return current offset value
333
+ * @returns {number}
334
+ */
335
+ get offset() {
336
+ return this.index + this.firstChildPadding;
337
+ }
338
+ /**
339
+ * Return current position object.
340
+ * It includes line, column, offset.
341
+ */
342
+ now() {
343
+ const t = this.offset, e = this.source.indexToPosition(t);
344
+ return {
345
+ line: e.line,
346
+ column: e.column,
347
+ offset: t
348
+ };
349
+ }
350
+ /**
351
+ * Return true, no more read char
352
+ */
353
+ get hasEnd() {
354
+ return this.read() === !1;
355
+ }
356
+ /**
357
+ * read char
358
+ * if can not read, return empty string
359
+ * @returns {string}
360
+ */
361
+ read(t = 0) {
362
+ const e = this.offset + t;
363
+ return e < this.startOffset ? !1 : 0 <= e && e < this.textCharacters.length ? this.textCharacters[e] : !1;
364
+ }
365
+ /**
366
+ * read node
367
+ * if can not read, return empty string
368
+ * @returns {node}
369
+ */
370
+ readNode(t = 0) {
371
+ if (!this.sourceNode)
372
+ return !1;
373
+ const e = this.offset + t;
374
+ if (e < this.startOffset)
375
+ return !1;
376
+ const n = this.sourceNode.children.filter((c) => c.range[0] <= e && e < c.range[1]);
377
+ return n.length > 0 ? n[n.length - 1] : !1;
378
+ }
379
+ /**
380
+ * Increment current index
381
+ */
382
+ peek() {
383
+ this.index += 1;
384
+ }
385
+ /**
386
+ * Increment node range
387
+ */
388
+ peekNode(t) {
389
+ this.index += t.range[1] - t.range[0];
390
+ }
391
+ /**
392
+ * Seek and Peek
393
+ */
394
+ seekNext(t) {
395
+ const e = this.now();
396
+ t.seek(this);
397
+ const n = this.now();
398
+ return {
399
+ value: this.sliceRange(e.offset, n.offset),
400
+ startPosition: e,
401
+ endPosition: n
402
+ };
403
+ }
404
+ /**
405
+ * Slice text form the range.
406
+ * @param {number} start
407
+ * @param {number} end
408
+ * @returns {string}
409
+ */
410
+ sliceRange(t, e) {
411
+ return this.textCharacters.slice(t, e).join("");
412
+ }
413
+ }
414
+ class Je {
415
+ test(t) {
416
+ const e = t.read();
417
+ return e ? /[\r\n]/.test(e) : !1;
418
+ }
419
+ seek(t) {
420
+ for (; this.test(t); )
421
+ t.peek();
422
+ }
423
+ }
424
+ class Ze {
425
+ test(t) {
426
+ const e = t.read();
427
+ return e ? /[^\S\n\r]/.test(e) : !1;
428
+ }
429
+ seek(t) {
430
+ for (; this.test(t); )
431
+ t.peek();
432
+ }
433
+ }
434
+ const Qe = {
435
+ separatorCharacters: [
436
+ ".",
437
+ // period
438
+ ".",
439
+ // (ja) zenkaku-period
440
+ "。",
441
+ // (ja) 句点
442
+ "?",
443
+ // question mark
444
+ "!",
445
+ // exclamation mark
446
+ "?",
447
+ // (ja) zenkaku question mark
448
+ "!"
449
+ // (ja) zenkaku exclamation mark
450
+ ]
451
+ };
452
+ class tr {
453
+ options;
454
+ separatorCharacters;
455
+ constructor(t) {
456
+ this.options = t, this.separatorCharacters = t && t.separatorCharacters ? t.separatorCharacters : Qe.separatorCharacters;
457
+ }
458
+ test(t) {
459
+ if (t.isInContext() || t.isInContextRange())
460
+ return !1;
461
+ const e = t.read(), n = t.read(1);
462
+ return !e || !this.separatorCharacters.includes(e) ? !1 : e === "." && n ? /[\s\t\r\n]/.test(n) : !0;
463
+ }
464
+ seek(t) {
465
+ for (; this.test(t); )
466
+ t.peek();
467
+ }
468
+ }
469
+ const ae = typeof process == "object" && process?.env?.DEBUG === "sentence-splitter";
470
+ function er(o, t) {
471
+ ae && console.log("sentence-splitter: " + o, t);
472
+ }
473
+ function ie(...o) {
474
+ ae && console.log("sentence-splitter: ", ...o.map((t) => typeof t == "string" ? t.replace(/\n/g, "\\n") : t));
475
+ }
476
+ class rr {
477
+ parsers;
478
+ markers;
479
+ /**
480
+ * Eat any value without `parsers.test`
481
+ */
482
+ constructor(t) {
483
+ this.parsers = t.parsers, this.markers = t.markers;
484
+ }
485
+ test(t) {
486
+ return t.hasEnd ? !1 : this.parsers.every((e) => !e.test(t));
487
+ }
488
+ seek(t) {
489
+ const e = t.readNode();
490
+ if (!e) {
491
+ for (; this.test(t); )
492
+ this.markers.forEach((c) => c.mark(t)), t.peek();
493
+ return;
494
+ }
495
+ const n = () => {
496
+ const c = t.offset;
497
+ return e.range[0] <= c && c < e.range[1];
498
+ };
499
+ for (; n() && this.test(t); )
500
+ er(t.offset, t.read()), this.markers.forEach((c) => c.mark(t)), t.peek();
501
+ }
502
+ }
503
+ const nr = {
504
+ ABBREVIATIONS: [
505
+ "Adj.",
506
+ "Adm.",
507
+ "Adv.",
508
+ "Al.",
509
+ "Ala.",
510
+ "Alta.",
511
+ "Apr.",
512
+ "Arc.",
513
+ "Ariz.",
514
+ "Ark.",
515
+ "Art.",
516
+ "Assn.",
517
+ "Asst.",
518
+ "Attys.",
519
+ "Aug.",
520
+ "Ave.",
521
+ "Bart.",
522
+ "Bld.",
523
+ "Bldg.",
524
+ "Blvd.",
525
+ "Brig.",
526
+ "Bros.",
527
+ "Btw.",
528
+ "Cal.",
529
+ "Calif.",
530
+ "Capt.",
531
+ "Cl.",
532
+ "Cmdr.",
533
+ "Co.",
534
+ "Col.",
535
+ "Colo.",
536
+ "Comdr.",
537
+ "Con.",
538
+ "Conn.",
539
+ "Corp.",
540
+ "Cpl.",
541
+ "Cres.",
542
+ "Ct.",
543
+ "D.phil.",
544
+ "Dak.",
545
+ "Dec.",
546
+ "Del.",
547
+ "Dept.",
548
+ "Det.",
549
+ "Dist.",
550
+ "Dr.",
551
+ "Dr.phil.",
552
+ "Dr.philos.",
553
+ "Drs.",
554
+ "E.g.",
555
+ "Ens.",
556
+ "Esp.",
557
+ "Esq.",
558
+ "Etc.",
559
+ "Exp.",
560
+ "Expy.",
561
+ "Ext.",
562
+ "Feb.",
563
+ "Fed.",
564
+ "Fla.",
565
+ "Ft.",
566
+ "Fwy.",
567
+ "Fy.",
568
+ "Ga.",
569
+ "Gen.",
570
+ "Gov.",
571
+ "Hon.",
572
+ "Hosp.",
573
+ "Hr.",
574
+ "Hway.",
575
+ "Hwy.",
576
+ "I.e.",
577
+ "Ia.",
578
+ "Id.",
579
+ "Ida.",
580
+ "Ill.",
581
+ "Inc.",
582
+ "Ind.",
583
+ "Ing.",
584
+ "Insp.",
585
+ "Is.",
586
+ "Jan.",
587
+ "Jr.",
588
+ "Jul.",
589
+ "Jun.",
590
+ "Kan.",
591
+ "Kans.",
592
+ "Ken.",
593
+ "Ky.",
594
+ "La.",
595
+ "Lt.",
596
+ "Ltd.",
597
+ "Maj.",
598
+ "Man.",
599
+ "Mar.",
600
+ "Mass.",
601
+ "May.",
602
+ "Md.",
603
+ "Me.",
604
+ "Med.",
605
+ "Messrs.",
606
+ "Mex.",
607
+ "Mfg.",
608
+ "Mich.",
609
+ "Min.",
610
+ "Minn.",
611
+ "Miss.",
612
+ "Mlle.",
613
+ "Mm.",
614
+ "Mme.",
615
+ "Mo.",
616
+ "Mont.",
617
+ "Mr.",
618
+ "Mrs.",
619
+ "Ms.",
620
+ "Msgr.",
621
+ "Mssrs.",
622
+ "Mt.",
623
+ "Mtn.",
624
+ "Neb.",
625
+ "Nebr.",
626
+ "Nev.",
627
+ "No.",
628
+ "Nos.",
629
+ "Nov.",
630
+ "Nr.",
631
+ "Oct.",
632
+ "Ok.",
633
+ "Okla.",
634
+ "Ont.",
635
+ "Op.",
636
+ "Ord.",
637
+ "Ore.",
638
+ "P.",
639
+ "Pa.",
640
+ "Pd.",
641
+ "Pde.",
642
+ "Penn.",
643
+ "Penna.",
644
+ "Pfc.",
645
+ "Ph.",
646
+ "Ph.d.",
647
+ "Pl.",
648
+ "Plz.",
649
+ "Pp.",
650
+ "Prof.",
651
+ "Pvt.",
652
+ "Que.",
653
+ "Rd.",
654
+ "Rs.",
655
+ "Ref.",
656
+ "Rep.",
657
+ "Reps.",
658
+ "Res.",
659
+ "Rev.",
660
+ "Rt.",
661
+ "Sask.",
662
+ "Sec.",
663
+ "Sen.",
664
+ "Sens.",
665
+ "Sep.",
666
+ "Sept.",
667
+ "Sfc.",
668
+ "Sgt.",
669
+ "Sr.",
670
+ "St.",
671
+ "Supt.",
672
+ "Surg.",
673
+ "Tce.",
674
+ "Tenn.",
675
+ "Tex.",
676
+ "Univ.",
677
+ "Usafa.",
678
+ "U.S.",
679
+ "Ut.",
680
+ "Va.",
681
+ "V.",
682
+ "Ver.",
683
+ "Vs.",
684
+ "Vt.",
685
+ "Wash.",
686
+ "Wis.",
687
+ "Wisc.",
688
+ "Wy.",
689
+ "Wyo.",
690
+ "Yuk."
691
+ ],
692
+ PREPOSITIVE_ABBREVIATIONS: [
693
+ "Adm.",
694
+ "Attys.",
695
+ "Brig.",
696
+ "Capt.",
697
+ "Cmdr.",
698
+ "Col.",
699
+ "Cpl.",
700
+ "Det.",
701
+ "Dr.",
702
+ "Gen.",
703
+ "Gov.",
704
+ "Ing.",
705
+ "Lt.",
706
+ "Maj.",
707
+ "Mr.",
708
+ "Mrs.",
709
+ "Ms.",
710
+ "Mt.",
711
+ "Messrs.",
712
+ "Mssrs.",
713
+ "Prof.",
714
+ "Ph.",
715
+ "Rep.",
716
+ "Reps.",
717
+ "Rev.",
718
+ "Sen.",
719
+ "Sens.",
720
+ "Sgt.",
721
+ "St.",
722
+ "Supt.",
723
+ "V.",
724
+ "Vs."
725
+ ],
726
+ EXCLAMATION_WORDS: [
727
+ "!Xũ",
728
+ "!Kung",
729
+ "ǃʼOǃKung",
730
+ "!Xuun",
731
+ "!Kung-Ekoka",
732
+ "ǃHu",
733
+ "ǃKhung",
734
+ "ǃKu",
735
+ "ǃung",
736
+ "ǃXo",
737
+ "ǃXû",
738
+ "ǃXung",
739
+ "ǃXũ",
740
+ "!Xun",
741
+ "Yahoo!",
742
+ "Y!J",
743
+ "Yum!"
744
+ ]
745
+ }, Mt = (o) => !o || o.length === 0 ? !1 : new RegExp("^\\p{Uppercase_Letter}", "u").test(o), Nt = (o, t) => o.toLowerCase() === t.toLowerCase(), or = {
746
+ language: nr
747
+ };
748
+ class ir {
749
+ options;
750
+ lang;
751
+ constructor(t) {
752
+ this.options = t, this.lang = t && t.language ? t.language : or.language;
753
+ }
754
+ /**
755
+ * Get Word
756
+ * word should have left space and right space,
757
+ * @param {SourceCode} sourceCode
758
+ * @param {number} startIndex
759
+ * @returns {string}
760
+ */
761
+ getWord(t, e = 0) {
762
+ const n = /\s/, c = t.read(-1);
763
+ if (c && !n.test(c))
764
+ return "";
765
+ let d = "", h = e, r = "";
766
+ for (; (r = t.read(h)) && !n.test(r); )
767
+ d += r, h++;
768
+ return d;
769
+ }
770
+ getPrevWord(t) {
771
+ const e = /\s/;
772
+ let n = -1, c = "";
773
+ for (; (c = t.read(n)) && e.test(c); )
774
+ n--;
775
+ for (; (c = t.read(n)) && !e.test(c); )
776
+ n--;
777
+ return this.getWord(t, n + 1);
778
+ }
779
+ mark(t) {
780
+ if (t.isInContextRange())
781
+ return;
782
+ const e = this.getWord(t);
783
+ if (e.length === 0)
784
+ return;
785
+ if (/^([a-zA-Z]\.){3,}$/.test(e))
786
+ return t.markContextRange([t.offset, t.offset + e.length]);
787
+ if (this.lang.EXCLAMATION_WORDS.some((i) => Nt(i, e)))
788
+ return t.markContextRange([t.offset, t.offset + e.length]);
789
+ const c = this.lang.PREPOSITIVE_ABBREVIATIONS.some((i) => Nt(i, e)), d = /^\d+\.$/.test(e);
790
+ if (c || d)
791
+ return t.markContextRange([t.offset, t.offset + e.length]);
792
+ const h = this.lang.ABBREVIATIONS.some((i) => Nt(i, e)), r = this.getPrevWord(t), w = this.getWord(t, e.length + 1);
793
+ Mt(r) && new RegExp("^\\p{Uppercase_Letter}\\.", "u").test(e) && Mt(w) ? t.markContextRange([t.offset, t.offset + e.length]) : h && !Mt(w) && t.markContextRange([t.offset, t.offset + e.length]);
794
+ }
795
+ }
796
+ const sr = [
797
+ {
798
+ key: "double quote",
799
+ start: '"',
800
+ end: '"'
801
+ },
802
+ {
803
+ key: "angled bracket",
804
+ start: "[",
805
+ end: "]"
806
+ },
807
+ {
808
+ key: "round bracket",
809
+ start: "(",
810
+ end: ")"
811
+ },
812
+ {
813
+ key: "curly brace",
814
+ start: "{",
815
+ end: "}"
816
+ },
817
+ {
818
+ key: "かぎ括弧",
819
+ start: "「",
820
+ end: "」"
821
+ },
822
+ {
823
+ key: "丸括弧",
824
+ start: "(",
825
+ end: ")"
826
+ },
827
+ {
828
+ key: "二重かぎ括弧",
829
+ start: "『",
830
+ end: "』"
831
+ },
832
+ {
833
+ key: "波括弧",
834
+ start: "{",
835
+ end: "}"
836
+ },
837
+ {
838
+ key: "角括弧",
839
+ start: "[",
840
+ end: "]"
841
+ },
842
+ {
843
+ key: "重角括弧",
844
+ start: "〚",
845
+ end: "〛"
846
+ },
847
+ {
848
+ key: "隅付き括弧",
849
+ start: "【",
850
+ end: "】"
851
+ },
852
+ {
853
+ key: "二重隅付き括弧",
854
+ start: "《",
855
+ end: "》"
856
+ }
857
+ ];
858
+ class cr {
859
+ PAIR_MARKS_KEY_Map = new Map(sr.flatMap((t) => [
860
+ [t.start, t],
861
+ [t.end, t]
862
+ ]));
863
+ mark(t) {
864
+ const e = t.read();
865
+ if (!e)
866
+ return;
867
+ const n = this.PAIR_MARKS_KEY_Map.get(e);
868
+ n && (t.isInContext(n) ? n.end === e && (ie(`PairMaker -> leaveContext: ${e} `), t.leaveContext(n)) : n.start === e && (ie(`PairMaker -> enterContext: ${e} `), t.enterContext(n)));
869
+ }
870
+ }
871
+ const mt = {
872
+ WhiteSpace: "WhiteSpace",
873
+ Punctuation: "Punctuation",
874
+ Sentence: "Sentence",
875
+ Str: "Str"
876
+ };
877
+ class ar {
878
+ sentenceNodeList = [];
879
+ results = [];
880
+ source;
881
+ constructor(t) {
882
+ this.source = new je(t);
883
+ }
884
+ get current() {
885
+ return this.sentenceNodeList[this.sentenceNodeList.length - 1];
886
+ }
887
+ pushNodeToCurrent(t) {
888
+ const e = this.current;
889
+ e ? e.children.push(t) : this.results.push(t);
890
+ }
891
+ // open with ParentNode
892
+ open(t) {
893
+ this.sentenceNodeList.push(t);
894
+ }
895
+ isOpened() {
896
+ return this.sentenceNodeList.length > 0;
897
+ }
898
+ nextLine(t) {
899
+ const { value: e, startPosition: n, endPosition: c } = this.source.seekNext(t);
900
+ return this.pushNodeToCurrent(se(e, n, c)), c;
901
+ }
902
+ nextSpace(t) {
903
+ const { value: e, startPosition: n, endPosition: c } = this.source.seekNext(t);
904
+ this.pushNodeToCurrent(se(e, n, c));
905
+ }
906
+ nextValue(t) {
907
+ const { value: e, startPosition: n, endPosition: c } = this.source.seekNext(t);
908
+ this.pushNodeToCurrent(fr(e, n, c));
909
+ }
910
+ // close current Node and remove it from list
911
+ close(t) {
912
+ const { value: e, startPosition: n, endPosition: c } = this.source.seekNext(t);
913
+ n.offset !== c.offset && !/^\s+$/.test(e) && this.pushNodeToCurrent(ur(e, n, c));
914
+ const d = this.sentenceNodeList.pop();
915
+ if (!d || d.children.length === 0)
916
+ return;
917
+ const h = d.children[0], r = this.source.now(), w = this.source.sliceRange(h.range[0], r.offset), i = this.source.consumedContexts.sort((s, l) => s.range[0] - l.range[0]).map((s) => ({
918
+ type: "PairMark",
919
+ pairMark: s.pairMark,
920
+ range: s.range,
921
+ loc: s.loc
922
+ }));
923
+ this.results.push({
924
+ ...d,
925
+ loc: {
926
+ start: h.loc.start,
927
+ end: {
928
+ line: r.line,
929
+ column: r.column
930
+ }
931
+ },
932
+ range: [h.range[0], r.offset],
933
+ raw: w,
934
+ contexts: i
935
+ });
936
+ }
937
+ toList() {
938
+ return this.results;
939
+ }
940
+ }
941
+ const lr = (o = {}) => {
942
+ const t = new Je(), e = new Ze(), n = new tr(o.SeparatorParser), c = new ir(o.AbbrMarker), d = new cr(), h = new rr({
943
+ parsers: [t, n],
944
+ markers: [c, d]
945
+ });
946
+ return {
947
+ newLine: t,
948
+ space: e,
949
+ separator: n,
950
+ abbrMarker: c,
951
+ anyValueParser: h
952
+ };
953
+ };
954
+ function dr(o, t) {
955
+ const { newLine: e, space: n, separator: c, anyValueParser: d } = lr(t), h = new ar(o), r = h.source;
956
+ for (; !r.hasEnd; )
957
+ e.test(r) ? h.nextLine(e) : n.test(r) ? h.nextSpace(n) : c.test(r) ? h.close(c) : (h.isOpened() || h.open(hr()), h.nextValue(d));
958
+ return h.close(n), h.toList();
959
+ }
960
+ function se(o, t, e) {
961
+ return {
962
+ type: mt.WhiteSpace,
963
+ raw: o,
964
+ value: o,
965
+ loc: {
966
+ start: {
967
+ line: t.line,
968
+ column: t.column
969
+ },
970
+ end: {
971
+ line: e.line,
972
+ column: e.column
973
+ }
974
+ },
975
+ range: [t.offset, e.offset]
976
+ };
977
+ }
978
+ function ur(o, t, e) {
979
+ return {
980
+ type: mt.Punctuation,
981
+ raw: o,
982
+ value: o,
983
+ loc: {
984
+ start: {
985
+ line: t.line,
986
+ column: t.column
987
+ },
988
+ end: {
989
+ line: e.line,
990
+ column: e.column
991
+ }
992
+ },
993
+ range: [t.offset, e.offset]
994
+ };
995
+ }
996
+ function fr(o, t, e) {
997
+ return {
998
+ type: mt.Str,
999
+ raw: o,
1000
+ value: o,
1001
+ loc: {
1002
+ start: {
1003
+ line: t.line,
1004
+ column: t.column
1005
+ },
1006
+ end: {
1007
+ line: e.line,
1008
+ column: e.column
1009
+ }
1010
+ },
1011
+ range: [t.offset, e.offset]
1012
+ };
1013
+ }
1014
+ function hr() {
1015
+ return {
1016
+ type: mt.Sentence,
1017
+ raw: "",
1018
+ loc: {
1019
+ start: { column: NaN, line: NaN },
1020
+ end: { column: NaN, line: NaN }
1021
+ },
1022
+ range: [NaN, NaN],
1023
+ children: [],
1024
+ contexts: []
1025
+ };
1026
+ }
1027
+ const Ot = st.forwardRef(({ className: o, ...t }, e) => /* @__PURE__ */ v(
1028
+ "div",
1029
+ {
1030
+ ref: e,
1031
+ className: Q(
1032
+ "cteditor-rounded-xl cteditor-border cteditor-bg-card cteditor-text-card-foreground cteditor-shadow",
1033
+ o
1034
+ ),
1035
+ ...t
1036
+ }
1037
+ ));
1038
+ Ot.displayName = "Card";
1039
+ const gr = st.forwardRef(({ className: o, ...t }, e) => /* @__PURE__ */ v(
1040
+ "div",
1041
+ {
1042
+ ref: e,
1043
+ className: Q("cteditor-flex cteditor-flex-col cteditor-space-y-1.5 cteditor-p-6", o),
1044
+ ...t
1045
+ }
1046
+ ));
1047
+ gr.displayName = "CardHeader";
1048
+ const pr = st.forwardRef(({ className: o, ...t }, e) => /* @__PURE__ */ v(
1049
+ "div",
1050
+ {
1051
+ ref: e,
1052
+ className: Q("cteditor-font-semibold cteditor-leading-none cteditor-tracking-tight", o),
1053
+ ...t
1054
+ }
1055
+ ));
1056
+ pr.displayName = "CardTitle";
1057
+ const mr = st.forwardRef(({ className: o, ...t }, e) => /* @__PURE__ */ v(
1058
+ "div",
1059
+ {
1060
+ ref: e,
1061
+ className: Q("cteditor-text-sm cteditor-text-muted-foreground", o),
1062
+ ...t
1063
+ }
1064
+ ));
1065
+ mr.displayName = "CardDescription";
1066
+ const Lt = st.forwardRef(({ className: o, ...t }, e) => /* @__PURE__ */ v("div", { ref: e, className: Q("cteditor-p-6 cteditor-pt-0", o), ...t }));
1067
+ Lt.displayName = "CardContent";
1068
+ const xr = st.forwardRef(({ className: o, ...t }, e) => /* @__PURE__ */ v(
1069
+ "div",
1070
+ {
1071
+ ref: e,
1072
+ className: Q("cteditor-flex cteditor-items-center cteditor-p-6 cteditor-pt-0", o),
1073
+ ...t
1074
+ }
1075
+ ));
1076
+ xr.displayName = "CardFooter";
1077
+ const Wr = He(
1078
+ "AUTOCOMPLETE_COMMAND"
1079
+ ), le = "grammarDictionary", wr = [
1080
+ "javascript",
1081
+ "typescript",
1082
+ "lexical",
1083
+ "editor",
1084
+ "autocomplete",
1085
+ "suggestions",
1086
+ "keyboard",
1087
+ "navigation",
1088
+ "development",
1089
+ "programming"
1090
+ ], Cr = 300 * 1e3, Er = 200, vr = 3e4, yr = { padding: 8 }, dt = {
1091
+ width: 340,
1092
+ maxHeight: 280,
1093
+ padding: 16,
1094
+ offsetX: 10,
1095
+ offsetY: 20
1096
+ }, br = 400, de = () => {
1097
+ try {
1098
+ const o = localStorage.getItem(le);
1099
+ return o ? new Set(JSON.parse(o)) : /* @__PURE__ */ new Set();
1100
+ } catch (o) {
1101
+ return console.error("Error reading dictionary from localStorage", o), /* @__PURE__ */ new Set();
1102
+ }
1103
+ }, kr = (o) => {
1104
+ try {
1105
+ const t = de();
1106
+ return t.add(o.toLowerCase()), localStorage.setItem(
1107
+ le,
1108
+ JSON.stringify(Array.from(t))
1109
+ ), t;
1110
+ } catch (t) {
1111
+ return console.error("Error saving to dictionary", t), /* @__PURE__ */ new Set();
1112
+ }
1113
+ }, Rt = (o) => qe(o.trim().toLowerCase());
1114
+ function Sr(o) {
1115
+ return dr(o).filter((e) => e.type === "Sentence").map((e, n) => ({
1116
+ id: `${n}`,
1117
+ text: e.raw,
1118
+ index: n
1119
+ })).filter((e) => e.text.trim().length > 0);
1120
+ }
1121
+ const Mr = (o, t, e, n, c, d, h) => {
1122
+ const r = window.innerWidth, w = window.innerHeight;
1123
+ let i = o + c, s = t + d;
1124
+ return i + e > r - h && (i = o - e - c), i < h && (i = h), s + n > w - h && (s = t - n - d), s < h && (s = h), { left: i, top: s };
1125
+ }, ce = (o) => {
1126
+ let t = "";
1127
+ const e = [];
1128
+ try {
1129
+ o.read(() => {
1130
+ const n = It(), c = (d) => {
1131
+ if (!Ie(d)) {
1132
+ if (ut(d)) {
1133
+ const h = d.getTextContent(), r = t.length;
1134
+ t += h, e.push({
1135
+ start: r,
1136
+ end: r + h.length,
1137
+ key: d.getKey(),
1138
+ text: h
1139
+ });
1140
+ } else if (Fe(d)) {
1141
+ const h = d.getChildren();
1142
+ for (const r of h)
1143
+ c(r);
1144
+ typeof d.isInline == "function" && !d.isInline() && (t += `
1145
+ `);
1146
+ }
1147
+ }
1148
+ };
1149
+ c(n);
1150
+ });
1151
+ } catch (n) {
1152
+ console.error("Critical: Text extraction failed", n);
1153
+ }
1154
+ return { fullText: t, nodeMap: e };
1155
+ };
1156
+ class Nr {
1157
+ apiEndpoint;
1158
+ requestTimeout = vr;
1159
+ sentenceCache = /* @__PURE__ */ new Map();
1160
+ constructor(t = "/api/ai/process") {
1161
+ this.apiEndpoint = Re + t;
1162
+ }
1163
+ isSentenceCached(t) {
1164
+ const e = Rt(t), n = this.sentenceCache.get(e);
1165
+ return n && Date.now() - n.checkedAt < Cr ? n : (n && this.sentenceCache.delete(e), null);
1166
+ }
1167
+ cacheSentence(t, e, n) {
1168
+ const c = Rt(t.text);
1169
+ if (this.sentenceCache.set(c, {
1170
+ id: t.id,
1171
+ text: t.text,
1172
+ hash: c,
1173
+ isClean: n,
1174
+ errors: e,
1175
+ checkedAt: Date.now()
1176
+ }), this.sentenceCache.size > Er) {
1177
+ const d = this.sentenceCache.keys().next().value;
1178
+ d && this.sentenceCache.delete(d);
1179
+ }
1180
+ }
1181
+ async processInChunks(t, e, n, c) {
1182
+ const d = [];
1183
+ let h = 0;
1184
+ const r = [];
1185
+ for (const w of t) {
1186
+ const i = this.isSentenceCached(w.text);
1187
+ i ? (d.push(i), h++, n?.(i)) : r.push(w);
1188
+ }
1189
+ if (r.length === 0)
1190
+ return {
1191
+ results: d,
1192
+ stats: {
1193
+ totalSentences: t.length,
1194
+ cachedSentences: h,
1195
+ apiCalls: 0
1196
+ }
1197
+ };
1198
+ try {
1199
+ const w = new AbortController(), i = setTimeout(
1200
+ () => w.abort(),
1201
+ this.requestTimeout
1202
+ ), s = await fetch(this.apiEndpoint, {
1203
+ method: "POST",
1204
+ headers: { "Content-Type": "application/json" },
1205
+ body: JSON.stringify({
1206
+ mode: "incremental",
1207
+ sentences: r,
1208
+ maxSuggestions: e
1209
+ }),
1210
+ signal: w.signal
1211
+ });
1212
+ if (clearTimeout(i), !s.ok) throw new Error(`Status ${s.status}`);
1213
+ const a = (await s.json()).data;
1214
+ a?.results && a.results.forEach((f, M) => {
1215
+ const k = r[M];
1216
+ if (!k) return;
1217
+ const S = [], N = f.correctedSentence || k.text, J = (H, X) => {
1218
+ Array.isArray(H) && H.forEach((A, ct) => {
1219
+ const Z = Number(A.startOffset ?? -1), F = Number(A.endOffset ?? Z);
1220
+ X === "spelling" && F <= Z || A.original && S.push({
1221
+ type: X,
1222
+ original: A.original,
1223
+ suggestions: A.suggestions || (A.suggestion ? [A.suggestion] : []),
1224
+ index: X === "grammar" ? 1e3 + ct : ct,
1225
+ issue: A.issue,
1226
+ severity: A.severity,
1227
+ sentenceId: k.id,
1228
+ sentenceIndex: k.index,
1229
+ originalSentence: k.text,
1230
+ correctedSentence: N,
1231
+ wordPosition: A.wordPosition ?? 0
1232
+ });
1233
+ });
1234
+ };
1235
+ J(f.errors?.spelling, "spelling"), J(f.errors?.grammar, "grammar");
1236
+ const P = {
1237
+ id: k.id,
1238
+ text: k.text,
1239
+ hash: Rt(k.text),
1240
+ isClean: S.length === 0,
1241
+ errors: S,
1242
+ checkedAt: Date.now()
1243
+ };
1244
+ this.cacheSentence(k, S, S.length === 0), n?.(P), d.push(P), c?.(h + M + 1, t.length);
1245
+ });
1246
+ } catch {
1247
+ }
1248
+ return {
1249
+ results: d,
1250
+ stats: {
1251
+ totalSentences: t.length,
1252
+ cachedSentences: h,
1253
+ apiCalls: 1
1254
+ }
1255
+ };
1256
+ }
1257
+ }
1258
+ function $r({
1259
+ onQueryChange: o,
1260
+ onSelectOption: t,
1261
+ minMatchLength: e = 2,
1262
+ maxSuggestions: n = 10,
1263
+ apiEndpoint: c = "/api/grammar/process",
1264
+ enableAI: d = !0,
1265
+ debounceDelay: h = 800
1266
+ }) {
1267
+ const [r] = Oe(), { toolbarState: w, updateToolbarState: i } = ye(), { isHtmlView: s } = be(), l = B([]), a = B(new Nr(c)), f = B(), M = B(""), k = B(null), S = B(null), N = B(null), J = B(!1), P = B(null), H = B(null), X = B(() => {
1268
+ }), A = B(0), ct = B(async () => {
1269
+ }), Z = B(/* @__PURE__ */ new Set()), [F, tt] = q(null), [W, et] = q([]), [ft, rt] = q(0), [At, ue] = q(
1270
+ null
1271
+ ), [xt, V] = q([]), [Rr, z] = q(/* @__PURE__ */ new Map()), [Ir, nt] = q(
1272
+ /* @__PURE__ */ new Set()
1273
+ ), [Bt, fe] = q(/* @__PURE__ */ new Set()), [Or, he] = q(
1274
+ /* @__PURE__ */ new Set()
1275
+ ), [wt, $] = q(null), ot = ke() ?? null;
1276
+ T(() => {
1277
+ Z.current = de();
1278
+ }, []);
1279
+ const Pt = G(() => {
1280
+ const u = new Set(wr);
1281
+ return r.getEditorState().read(() => {
1282
+ const E = It().getTextContent().match(/\b[a-zA-Z][a-zA-Z0-9_]*\b/g);
1283
+ E && E.forEach((x) => {
1284
+ x.length >= e && u.add(x);
1285
+ });
1286
+ }), Array.from(u);
1287
+ }, [r, e]), Dt = G(
1288
+ (u) => !u || u.length < e ? [] : Pt().filter(
1289
+ (m) => m.toLowerCase().startsWith(u.toLowerCase()) && m.toLowerCase() !== u.toLowerCase()
1290
+ ).slice(0, n).map((m) => ({
1291
+ displayText: m,
1292
+ key: `traditional-${m}`,
1293
+ queryWordStart: 0,
1294
+ queryWordEnd: u.length,
1295
+ type: "suggestion",
1296
+ confidence: "low"
1297
+ })),
1298
+ [Pt, e, n]
1299
+ ), _t = G(() => {
1300
+ tt(null);
1301
+ }, []), ht = G(async () => {
1302
+ if (!w.isAutocompleteEnabled || !d) {
1303
+ V([]), z(/* @__PURE__ */ new Map()), nt(/* @__PURE__ */ new Set());
1304
+ return;
1305
+ }
1306
+ const { fullText: u, nodeMap: m } = ce(r.getEditorState());
1307
+ if (!u) return;
1308
+ if (l.current = m, u.trim().length < 3) {
1309
+ V([]), z(/* @__PURE__ */ new Map()), nt(/* @__PURE__ */ new Set());
1310
+ return;
1311
+ }
1312
+ M.current = u;
1313
+ const E = Sr(u);
1314
+ if (E.length === 0) return;
1315
+ const x = ++A.current, p = new Set(E.map((g) => g.id));
1316
+ nt(new Set(E.map((g) => g.id))), z((g) => {
1317
+ const C = /* @__PURE__ */ new Map();
1318
+ return g.forEach((y, b) => {
1319
+ p.has(b) && C.set(b, y);
1320
+ }), C;
1321
+ });
1322
+ try {
1323
+ await a.current.processInChunks(
1324
+ E.map((g) => ({ id: g.id, text: g.text, index: g.index })),
1325
+ n,
1326
+ (g) => {
1327
+ if (A.current !== x) return;
1328
+ nt((y) => {
1329
+ const b = new Set(y);
1330
+ return b.delete(g.id), b;
1331
+ });
1332
+ const C = g.errors.filter((y) => {
1333
+ const b = `${y.sentenceId}-${y.original.toLowerCase()}`, I = Bt.has(b), K = Z.current.has(
1334
+ y.original.toLowerCase()
1335
+ );
1336
+ return !I && !K;
1337
+ });
1338
+ z((y) => {
1339
+ const b = new Map(y);
1340
+ return C.length > 0 ? b.set(g.id, C) : b.delete(g.id), b;
1341
+ }), V((y) => [...y.filter(
1342
+ (I) => I.sentenceId !== g.id
1343
+ ), ...C]);
1344
+ }
1345
+ );
1346
+ } catch {
1347
+ A.current === x && (V([]), z(/* @__PURE__ */ new Map()), nt(/* @__PURE__ */ new Set()));
1348
+ }
1349
+ }, [r, w, d, n, Bt]);
1350
+ T(() => {
1351
+ ct.current = ht;
1352
+ });
1353
+ const gt = G(
1354
+ (u) => {
1355
+ et((m) => m.filter((E) => E.key !== u.key)), rt(0), J.current = !0, r.update(() => {
1356
+ const m = zt();
1357
+ if (!qt(m)) return;
1358
+ const E = m.anchor, x = E.getNode(), p = x.getTextContent(), g = E.offset;
1359
+ let C = g;
1360
+ for (; C > 0 && /[a-zA-Z0-9_']/.test(p[C - 1]); )
1361
+ C--;
1362
+ if (ut(x)) {
1363
+ const y = p.slice(0, C) + u.displayText + p.slice(g);
1364
+ x.setTextContent(y);
1365
+ const b = C + u.displayText.length;
1366
+ m.anchor.set(x.getKey(), b, "text"), m.focus.set(x.getKey(), b, "text");
1367
+ }
1368
+ }), M.current = "", tt(null), et([]), t?.(u, null, () => tt(null)), setTimeout(ht, 500);
1369
+ },
1370
+ [r, t, ht]
1371
+ ), ge = G(
1372
+ (u, m) => {
1373
+ const E = m.sentenceId || "";
1374
+ z((x) => {
1375
+ const p = new Map(x), C = (p.get(E) || []).filter((y) => y !== m);
1376
+ return C.length > 0 ? p.set(E, C) : p.delete(E), p;
1377
+ }), V((x) => x.filter((p) => p !== m)), $(null), r.update(() => {
1378
+ const { fullText: x, nodeMap: p } = ce(
1379
+ r.getEditorState()
1380
+ );
1381
+ let g = x.indexOf(m.originalSentence || "");
1382
+ if (g === -1 && (g = x.indexOf(m.original)), g === -1) return;
1383
+ const C = x.substring(g).indexOf(m.original);
1384
+ if (C === -1) return;
1385
+ const y = g + C, b = y + m.original.length, I = p.find(
1386
+ (O) => y >= O.start && y < O.end
1387
+ ), K = p.find(
1388
+ (O) => b > O.start && b <= O.end
1389
+ );
1390
+ if (I && K) {
1391
+ const O = Gt(I.key), Y = Gt(K.key);
1392
+ if (ut(O) && ut(Y)) {
1393
+ const D = Le(), it = y - I.start, Wt = b - K.start;
1394
+ D.anchor.set(O.getKey(), it, "text"), D.focus.set(Y.getKey(), Wt, "text"), Ae(D), D.insertText(u);
1395
+ }
1396
+ }
1397
+ }), V(
1398
+ (x) => x.map((p) => p.sentenceId === E && p !== m ? {
1399
+ ...p,
1400
+ originalSentence: p.originalSentence?.replace(
1401
+ m.original,
1402
+ u
1403
+ )
1404
+ } : p)
1405
+ ), window.dispatchEvent(new Event("customUpdateHighlights"));
1406
+ },
1407
+ [r]
1408
+ ), pe = G(
1409
+ (u, m, E) => {
1410
+ he((x) => new Set(x).add(E)), z((x) => {
1411
+ const p = new Map(x);
1412
+ return p.delete(E), p;
1413
+ }), V((x) => x.filter((p) => p.sentenceId !== E)), $(null), r.update(() => {
1414
+ const x = It();
1415
+ let p = !1;
1416
+ const g = (C) => {
1417
+ if (p) return !0;
1418
+ if (ut(C)) {
1419
+ const b = C.getTextContent(), I = b.toLowerCase().indexOf(m.toLowerCase());
1420
+ if (I !== -1) {
1421
+ const K = b.substring(0, I) + u + b.substring(I + m.length);
1422
+ return C.setTextContent(K), p = !0, !0;
1423
+ }
1424
+ }
1425
+ const y = C.getChildren ? C.getChildren() : [];
1426
+ for (const b of y)
1427
+ if (g(b)) return !0;
1428
+ return !1;
1429
+ };
1430
+ g(x);
1431
+ });
1432
+ },
1433
+ [r]
1434
+ ), Tt = G((u) => {
1435
+ const m = `${u.sentenceId}-${u.original.toLowerCase()}`, E = u.sentenceId || "";
1436
+ fe((x) => new Set(x).add(m)), z((x) => {
1437
+ const p = new Map(x), C = (p.get(E) || []).filter(
1438
+ (y) => y.original !== u.original
1439
+ );
1440
+ return C.length > 0 ? p.set(E, C) : p.delete(E), p;
1441
+ }), V((x) => x.filter((p) => p.original !== u.original)), $(null);
1442
+ }, []), Ht = G((u) => {
1443
+ const m = kr(u.original);
1444
+ Z.current = m;
1445
+ const E = u.sentenceId || "";
1446
+ z((x) => {
1447
+ const p = new Map(x), C = (p.get(E) || []).filter(
1448
+ (y) => y.original.toLowerCase() !== u.original.toLowerCase()
1449
+ );
1450
+ return C.length > 0 ? p.set(E, C) : p.delete(E), p;
1451
+ }), V(
1452
+ (x) => x.filter(
1453
+ (p) => p.original.toLowerCase() !== u.original.toLowerCase()
1454
+ )
1455
+ ), $(null), window.dispatchEvent(new Event("customUpdateHighlights"));
1456
+ }, []), Ft = G(() => {
1457
+ S.current && r.getEditorState().read(() => {
1458
+ const u = zt();
1459
+ if (!qt(u)) return;
1460
+ const m = window.getSelection()?.getRangeAt(0);
1461
+ if (!m) return;
1462
+ const E = m.getBoundingClientRect(), x = S.current;
1463
+ if (!x) return;
1464
+ const p = E.bottom + window.scrollY + yr.padding, g = E.left + window.scrollX;
1465
+ x.style.top = `${p}px`, x.style.left = `${g}px`;
1466
+ });
1467
+ }, [r]);
1468
+ T(() => {
1469
+ M.current = "";
1470
+ }, []), T(() => {
1471
+ w.isAutocompleteEnabled ? ht() : (tt(null), et([]), V([]), z(/* @__PURE__ */ new Map()), nt(/* @__PURE__ */ new Set()));
1472
+ }, [w.isAutocompleteEnabled]), T(() => (N.current && clearTimeout(N.current), F && !J.current ? N.current = window.setTimeout(() => {
1473
+ et(Dt(F)), rt(0), o?.(F);
1474
+ }, h) : (et([]), rt(0), o?.(null)), () => {
1475
+ N.current && clearTimeout(N.current);
1476
+ }), [F, Dt, o, h]), T(() => {
1477
+ if (!F || W.length === 0) return;
1478
+ const u = r.registerCommand(
1479
+ Be,
1480
+ (g) => (g?.preventDefault(), rt((C) => (C + 1) % W.length), !0),
1481
+ at
1482
+ ), m = r.registerCommand(
1483
+ Pe,
1484
+ (g) => (g?.preventDefault(), rt(
1485
+ (C) => (C - 1 + W.length) % W.length
1486
+ ), !0),
1487
+ at
1488
+ ), E = r.registerCommand(
1489
+ De,
1490
+ (g) => (g?.preventDefault(), tt(null), !0),
1491
+ at
1492
+ ), x = r.registerCommand(
1493
+ _e,
1494
+ (g) => (g?.preventDefault(), gt(W[ft]), !0),
1495
+ at
1496
+ ), p = r.registerCommand(
1497
+ Te,
1498
+ (g) => (g?.preventDefault(), gt(W[ft]), !0),
1499
+ at
1500
+ );
1501
+ return () => {
1502
+ u(), m(), E(), x(), p();
1503
+ };
1504
+ }, [r, F, W, ft, gt]), T(() => r.registerUpdateListener(({ editorState: u }) => {
1505
+ u.read(() => setTimeout(_t, 0));
1506
+ }), [r, _t]), T(() => {
1507
+ F && W.length > 0 && Ft();
1508
+ }, [F, W, Ft]), T(() => {
1509
+ const u = document.createElement("div");
1510
+ return u.style.position = "absolute", u.style.zIndex = "1000", document.body.appendChild(u), S.current = u, ue(u), () => {
1511
+ S.current && document.body.removeChild(S.current);
1512
+ };
1513
+ }, []), T(() => {
1514
+ if (!w.isAutocompleteEnabled) return;
1515
+ const u = r.registerUpdateListener(() => {
1516
+ clearTimeout(f.current), f.current = window.setTimeout(() => ct.current(), 1e3);
1517
+ });
1518
+ return () => {
1519
+ u(), clearTimeout(f.current);
1520
+ };
1521
+ }, [r, w.isAutocompleteEnabled]), T(() => {
1522
+ const u = () => {
1523
+ const m = r.getRootElement();
1524
+ if (!m) return;
1525
+ if (s) {
1526
+ document.querySelectorAll(".grammar-error-highlight").forEach((g) => g.remove());
1527
+ return;
1528
+ }
1529
+ const E = m.getBoundingClientRect();
1530
+ if (E.width === 0 || E.height === 0) {
1531
+ document.querySelectorAll(".grammar-error-highlight").forEach((g) => g.remove());
1532
+ return;
1533
+ }
1534
+ if (document.querySelectorAll(".grammar-error-highlight").forEach((g) => g.remove()), xt.length === 0) return;
1535
+ const x = l.current, p = M.current;
1536
+ xt.forEach((g) => {
1537
+ if (Z.current.has(g.original.toLowerCase()))
1538
+ return;
1539
+ let C = p.indexOf(g.originalSentence || "");
1540
+ if (C === -1 && (C = p.indexOf(g.original)), C === -1) return;
1541
+ const y = p.substring(C), b = g.original.replace(
1542
+ /[.*+?^${}()|[\]\\]/g,
1543
+ "\\$&"
1544
+ ), I = new RegExp(`\\b${b}\\b`, "g");
1545
+ if (!I.test(p))
1546
+ return;
1547
+ I.lastIndex = 0;
1548
+ const K = new RegExp(`\\b${b}\\b`), O = y.match(K), Y = O ? O.index : -1;
1549
+ if (Y === void 0 || Y === -1) return;
1550
+ const D = C + Y, it = D + g.original.length;
1551
+ x.filter(
1552
+ (_) => _.start <= D && _.end > D || _.start < it && _.end >= it || _.start >= D && _.end <= it
1553
+ ).forEach((_) => {
1554
+ const we = Math.max(_.start, D), Ce = Math.min(_.end, it), $t = we - _.start, Kt = Ce - _.start;
1555
+ if (Kt <= $t) return;
1556
+ const Ut = r.getElementByKey(_.key);
1557
+ if (!Ut) return;
1558
+ const pt = Ut.firstChild;
1559
+ if (!pt || pt.nodeType !== Node.TEXT_NODE) return;
1560
+ const Ct = document.createRange();
1561
+ try {
1562
+ Ct.setStart(pt, $t), Ct.setEnd(pt, Kt);
1563
+ const Et = Ct.getClientRects();
1564
+ for (let vt = 0; vt < Et.length; vt++) {
1565
+ const j = Et[vt];
1566
+ if (j.width === 0 || j.height === 0) continue;
1567
+ const R = document.createElement("div");
1568
+ R.className = "grammar-error-highlight", R.style.position = "absolute", R.style.left = `${j.left + window.scrollX}px`, R.style.top = `${j.bottom + window.scrollY - 8}px`, R.style.width = `${j.width}px`, R.style.height = "2px", R.style.paddingTop = "3px", R.style.paddingBottom = "3px", R.style.zIndex = "10", R.style.cursor = "pointer", R.style.pointerEvents = "auto", R.style.boxSizing = "content-box", g.type === "grammar" ? (R.style.backgroundColor = "rgba(59, 130, 246, 0.1)", R.style.borderBottom = "2.5px solid #3b82f6") : (R.style.backgroundColor = "rgba(239, 68, 68, 0.1)", R.style.borderBottom = "2.5px solid #ef4444"), R.onmouseenter = () => {
1569
+ P.current && (clearTimeout(P.current), P.current = null), H.current && clearTimeout(H.current), H.current = window.setTimeout(() => {
1570
+ $({
1571
+ error: g,
1572
+ x: j.left + j.width / 2,
1573
+ y: j.bottom + 5,
1574
+ isVisible: !0,
1575
+ isLocked: !1
1576
+ });
1577
+ }, 200);
1578
+ }, R.onmouseleave = () => {
1579
+ H.current && (clearTimeout(H.current), H.current = null), P.current = window.setTimeout(() => {
1580
+ $(null);
1581
+ }, 400);
1582
+ }, document.body.appendChild(R);
1583
+ }
1584
+ } catch {
1585
+ }
1586
+ });
1587
+ });
1588
+ };
1589
+ return X.current = u, window.addEventListener("scroll", u, !0), window.addEventListener("resize", u), window.addEventListener("customUpdateHighlights", u), requestAnimationFrame(u), () => {
1590
+ window.removeEventListener("scroll", u, !0), window.removeEventListener("resize", u), window.removeEventListener("customUpdateHighlights", u), document.querySelectorAll(".grammar-error-highlight").forEach((m) => m.remove()), X.current = () => {
1591
+ };
1592
+ };
1593
+ }, [xt, r, s]), T(() => {
1594
+ const u = (m) => {
1595
+ const E = m.target;
1596
+ k.current?.contains(E) || document.querySelector(".grammar-tooltip-card")?.contains(E) || (tt(null), et([]), $(null));
1597
+ };
1598
+ return document.addEventListener("mousedown", u), () => document.removeEventListener("mousedown", u);
1599
+ }, []);
1600
+ const me = () => {
1601
+ if (!wt || !wt.isVisible) return null;
1602
+ const { error: u, x: m, y: E } = wt, x = !!ot, p = ot?.getBoundingClientRect(), { left: g, top: C } = Mr(
1603
+ m,
1604
+ E,
1605
+ dt.width,
1606
+ dt.maxHeight,
1607
+ dt.offsetX,
1608
+ dt.offsetY,
1609
+ dt.padding
1610
+ );
1611
+ let y, b, I;
1612
+ x && p && ot ? (I = "absolute", y = g - p.left + ot.scrollLeft, b = C - p.top + ot.scrollTop) : (I = "fixed", y = g, b = C);
1613
+ const K = /* @__PURE__ */ v(
1614
+ "div",
1615
+ {
1616
+ className: I === "fixed" ? "cteditor-fixed cteditor-z-[10001]" : "cteditor-absolute cteditor-z-[10001]",
1617
+ style: {
1618
+ top: `${b}px`,
1619
+ left: `${y}px`,
1620
+ animation: "fadeIn 0.2s ease-out",
1621
+ pointerEvents: "auto",
1622
+ paddingTop: "10px"
1623
+ },
1624
+ onMouseEnter: () => {
1625
+ P.current && (clearTimeout(P.current), P.current = null);
1626
+ },
1627
+ onMouseLeave: () => {
1628
+ P.current = window.setTimeout(() => {
1629
+ $(null);
1630
+ }, br);
1631
+ },
1632
+ children: /* @__PURE__ */ v(Ot, { className: "cteditor-w-[340px] cteditor-max-w-[calc(100vw-32px)] cteditor-shadow-2xl cteditor-border cteditor-border-foreground/15 cteditor-bg-grammar-tooltip-bg grammar-tooltip-card cteditor-overflow-hidden cteditor-relative", children: /* @__PURE__ */ L(Lt, { className: "!cteditor-p-4 sm:!cteditor-p-5 cteditor-space-y-3 cteditor-font-geist", children: [
1633
+ /* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-items-start cteditor-justify-between cteditor-gap-2 ", children: [
1634
+ /* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-min-w-0 cteditor-flex-1", children: [
1635
+ /* @__PURE__ */ v(
1636
+ "div",
1637
+ {
1638
+ className: `cteditor-w-6 cteditor-h-6 cteditor-rounded-full cteditor-flex cteditor-items-center cteditor-justify-center cteditor-flex-shrink-0 ${u.type === "spelling" ? "cteditor-bg-red-100 dark:cteditor-bg-red-900/30" : "cteditor-bg-blue-100 dark:cteditor-bg-blue-900/30"}`,
1639
+ children: /* @__PURE__ */ v(
1640
+ Se,
1641
+ {
1642
+ className: `cteditor-w-4 cteditor-h-4 ${u.type === "spelling" ? "cteditor-text-red-600 dark:cteditor-text-red-400" : "cteditor-text-blue-600 dark:cteditor-text-blue-400"}`
1643
+ }
1644
+ )
1645
+ }
1646
+ ),
1647
+ /* @__PURE__ */ L("div", { className: "cteditor-min-w-0 cteditor-flex-1", children: [
1648
+ /* @__PURE__ */ v(
1649
+ Me,
1650
+ {
1651
+ variant: u.type === "spelling" ? "destructive" : "default",
1652
+ className: "cteditor-text-xs cteditor-font-bold",
1653
+ children: u.type === "spelling" ? "Spelling" : "Grammar"
1654
+ }
1655
+ ),
1656
+ u.issue && /* @__PURE__ */ v("p", { className: "cteditor-text-xs cteditor-text-foreground/50 cteditor-mt-1 cteditor-break-words", children: u.issue })
1657
+ ] })
1658
+ ] }),
1659
+ /* @__PURE__ */ v(
1660
+ "button",
1661
+ {
1662
+ type: "button",
1663
+ onClick: () => $(null),
1664
+ className: "cteditor-text-gray-400 hover:cteditor-text-gray-600 cteditor-flex-shrink-0 cteditor-p-1 cteditor-absolute cteditor-top-1 cteditor-right-1",
1665
+ children: /* @__PURE__ */ v(Ne, { className: "cteditor-w-4 cteditor-h-4" })
1666
+ }
1667
+ )
1668
+ ] }),
1669
+ /* @__PURE__ */ v("div", { className: "cteditor-p-3 cteditor-bg-incorrect-word-bg cteditor-rounded-lg cteditor-border cteditor-border-incorrect-word-border cteditor-overflow-hidden", children: /* @__PURE__ */ v("p", { className: "cteditor-text-sm cteditor-line-through cteditor-text-incorrect-word-text cteditor-font-semibold cteditor-break-all", children: u.original }) }),
1670
+ u.suggestions.length > 0 ? /* @__PURE__ */ L("div", { className: "cteditor-space-y-3", children: [
1671
+ /* @__PURE__ */ v("p", { className: "cteditor-text-xs cteditor-font-bold cteditor-text-main-foreground cteditor-uppercase cteditor-tracking-wider", children: "Suggestions:" }),
1672
+ /* @__PURE__ */ v("div", { className: "cteditor-space-y-2 cteditor-max-h-[120px] cteditor-overflow-y-auto cteditor-pr-1", children: u.suggestions.map((O, Y) => /* @__PURE__ */ L(
1673
+ "button",
1674
+ {
1675
+ type: "button",
1676
+ onClick: (D) => {
1677
+ D.preventDefault(), D.stopPropagation(), ge(O, u);
1678
+ },
1679
+ className: "cteditor-w-full cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-px-3 cteditor-py-2 cteditor-bg-suggestion-bg cteditor-border cteditor-border-suggestion-border cteditor-rounded-lg cteditor-transition-all",
1680
+ children: [
1681
+ /* @__PURE__ */ v(Vt, { className: "cteditor-w-4 cteditor-h-4 cteditor-flex-shrink-0 cteditor-text-suggestion-text " }),
1682
+ /* @__PURE__ */ v("span", { className: "cteditor-text-sm cteditor-font-semibold cteditor-text-suggestion-text cteditor-break-all cteditor-text-left", children: O })
1683
+ ]
1684
+ },
1685
+ Y
1686
+ )) }),
1687
+ u.type === "grammar" && u.correctedSentence && /* @__PURE__ */ v(
1688
+ "button",
1689
+ {
1690
+ type: "button",
1691
+ onClick: (O) => {
1692
+ O.preventDefault(), pe(
1693
+ u.correctedSentence,
1694
+ u.originalSentence,
1695
+ u.sentenceId
1696
+ );
1697
+ },
1698
+ className: "cteditor-w-full cteditor-px-3 cteditor-py-2 cteditor-bg-explanation-bg cteditor-border-2 cteditor-border-explanation-border cteditor-rounded-lg cteditor-text-left",
1699
+ children: /* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-items-start cteditor-gap-2", children: [
1700
+ /* @__PURE__ */ v(Vt, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-blue-600 cteditor-mt-0.5 cteditor-flex-shrink-0" }),
1701
+ /* @__PURE__ */ L("div", { className: "cteditor-min-w-0 cteditor-flex-1", children: [
1702
+ /* @__PURE__ */ v("p", { className: "cteditor-text-xs cteditor-font-semibold cteditor-text-blue-700", children: "Fix entire sentence" }),
1703
+ /* @__PURE__ */ v("p", { className: "cteditor-text-xs cteditor-text-blue-600 cteditor-break-words cteditor-line-clamp-2", children: u.correctedSentence })
1704
+ ] })
1705
+ ] })
1706
+ }
1707
+ ),
1708
+ /* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-flex-col cteditor-gap-3 cteditor-mt-3 cteditor-pt-3 ", children: [
1709
+ /* @__PURE__ */ v(
1710
+ "button",
1711
+ {
1712
+ type: "button",
1713
+ onClick: () => Tt(u),
1714
+ className: "cteditor-w-full cteditor-px-4 cteditor-py-2.5 cteditor-text-sm cteditor-font-medium cteditor-rounded-lg cteditor-border cteditor-border-foreground/20 hover:cteditor-bg-foreground/10 cteditor-transition-colors",
1715
+ title: "Ignore this suggestion",
1716
+ children: "Dismiss"
1717
+ }
1718
+ ),
1719
+ /* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-gap-2 cteditor-justify-between", children: [
1720
+ /* @__PURE__ */ L(
1721
+ "button",
1722
+ {
1723
+ type: "button",
1724
+ onClick: () => Ht(u),
1725
+ className: "cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-1.5 cteditor-text-xs cteditor-transition-colors cteditor-font-medium hover:cteditor-opacity-90",
1726
+ title: "Add word to your personal dictionary ",
1727
+ children: [
1728
+ /* @__PURE__ */ v(Yt, { className: "cteditor-w-3.5 cteditor-h-3.5" }),
1729
+ "Add to Dictionary"
1730
+ ]
1731
+ }
1732
+ ),
1733
+ /* @__PURE__ */ v(
1734
+ "button",
1735
+ {
1736
+ type: "button",
1737
+ onClick: () => {
1738
+ i("isAutocompleteEnabled", !1), $(null);
1739
+ },
1740
+ className: "cteditor-px-3 cteditor-py-2 hover:cteditor-bg-foreground/10 cteditor-text-xs cteditor-rounded-md cteditor-transition-colors cteditor-font-medium",
1741
+ title: "Turn off grammar checking",
1742
+ children: "Disable"
1743
+ }
1744
+ )
1745
+ ] })
1746
+ ] })
1747
+ ] }) : (
1748
+ /* No suggestions - action buttons only */
1749
+ /* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-flex-col cteditor-gap-3 cteditor-mt-3 cteditor-pt-3 ", children: [
1750
+ /* @__PURE__ */ v(
1751
+ "button",
1752
+ {
1753
+ type: "button",
1754
+ onClick: () => Tt(u),
1755
+ className: "cteditor-flex-1 cteditor-px-3 cteditor-py-2 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-1.5 cteditor-text-xs cteditor-rounded-md cteditor-border cteditor-border-foreground/50 hover:cteditor-bg-foreground/10 cteditor-transition-colors",
1756
+ title: "Ignore this suggestion",
1757
+ children: "Dismiss"
1758
+ }
1759
+ ),
1760
+ /* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-gap-2 cteditor-justify-between", children: [
1761
+ /* @__PURE__ */ L(
1762
+ "button",
1763
+ {
1764
+ type: "button",
1765
+ onClick: () => Ht(u),
1766
+ className: "cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-1.5 cteditor-text-xs cteditor-rounded-md cteditor-transition-colors cteditor-font-medium hover:cteditor-opacity-90 ",
1767
+ title: "Add word to your personal dictionary",
1768
+ children: [
1769
+ /* @__PURE__ */ v(Yt, { className: "cteditor-w-3.5 cteditor-h-3.5" }),
1770
+ "Add to Dictionary"
1771
+ ]
1772
+ }
1773
+ ),
1774
+ /* @__PURE__ */ v(
1775
+ "button",
1776
+ {
1777
+ type: "button",
1778
+ onClick: () => {
1779
+ i("isAutocompleteEnabled", !1), $(null);
1780
+ },
1781
+ className: "cteditor-px-3 cteditor-py-2 hover:cteditor-bg-foreground/10 cteditor-text-xs cteditor-rounded-md cteditor-transition-colors cteditor-font-medium",
1782
+ title: "Turn off grammar checking",
1783
+ children: "Disable"
1784
+ }
1785
+ )
1786
+ ] })
1787
+ ] })
1788
+ )
1789
+ ] }) })
1790
+ }
1791
+ );
1792
+ return Xt(K, ot || document.body);
1793
+ }, xe = () => !At || !F || W.length === 0 ? null : Xt(
1794
+ /* @__PURE__ */ v(
1795
+ Ot,
1796
+ {
1797
+ ref: k,
1798
+ className: "cteditor-w-80 cteditor-max-h-64 cteditor-overflow-hidden cteditor-shadow-xl cteditor-border-2 cteditor-bg-white dark:cteditor-bg-gray-900 autocomplete-menu",
1799
+ children: /* @__PURE__ */ v(Lt, { className: "!cteditor-p-2", children: /* @__PURE__ */ v("div", { className: "cteditor-max-h-56 cteditor-overflow-y-auto cteditor-space-y-1", children: W.map((u, m) => /* @__PURE__ */ L(
1800
+ "button",
1801
+ {
1802
+ type: "button",
1803
+ className: Q(
1804
+ "cteditor-w-full cteditor-flex cteditor-items-center cteditor-gap-3 cteditor-px-3 cteditor-py-2.5 cteditor-rounded-md cteditor-text-left",
1805
+ m === ft ? "cteditor-bg-blue-100" : "hover:cteditor-bg-gray-100"
1806
+ ),
1807
+ onClick: () => gt(u),
1808
+ onMouseEnter: () => rt(m),
1809
+ children: [
1810
+ /* @__PURE__ */ v($e, { className: "cteditor-w-4 cteditor-h-4" }),
1811
+ /* @__PURE__ */ v("span", { className: "cteditor-text-sm cteditor-font-medium", children: u.displayText })
1812
+ ]
1813
+ },
1814
+ u.key
1815
+ )) }) })
1816
+ }
1817
+ ),
1818
+ At
1819
+ );
1820
+ return /* @__PURE__ */ L(Ee, { children: [
1821
+ me(),
1822
+ xe()
1823
+ ] });
1824
+ }
1825
+ export {
1826
+ Wr as AUTOCOMPLETE_COMMAND,
1827
+ $r as default,
1828
+ Sr as splitIntoSentences
1829
+ };