quoin-editor 1.0.2 → 1.1.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 (224) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/ai.cjs +169 -249
  3. package/dist/ai.cjs.map +1 -1
  4. package/dist/ai.js +38 -121
  5. package/dist/ai.js.map +1 -1
  6. package/dist/catalogue.cjs +29 -43
  7. package/dist/catalogue.cjs.map +1 -1
  8. package/dist/catalogue.js +21 -37
  9. package/dist/catalogue.js.map +1 -1
  10. package/dist/{chunk-DUE3HCZD.js → chunk-2EQ6FKSK.js} +19 -28
  11. package/dist/chunk-2EQ6FKSK.js.map +1 -0
  12. package/dist/{chunk-RJRX34BZ.js → chunk-3BXUGX5F.js} +4 -18
  13. package/dist/chunk-3BXUGX5F.js.map +1 -0
  14. package/dist/chunk-3QRVAI53.cjs +27 -0
  15. package/dist/chunk-3QRVAI53.cjs.map +1 -0
  16. package/dist/{chunk-U3LOLYAU.js → chunk-7FAVFJAS.js} +4 -10
  17. package/dist/chunk-7FAVFJAS.js.map +1 -0
  18. package/dist/{chunk-FDRUAL3Z.cjs → chunk-7NAONESM.cjs} +90 -153
  19. package/dist/chunk-7NAONESM.cjs.map +1 -0
  20. package/dist/{chunk-6V6GGBDK.cjs → chunk-7SVKLWDT.cjs} +24 -31
  21. package/dist/chunk-7SVKLWDT.cjs.map +1 -0
  22. package/dist/{chunk-CW3AFJBR.cjs → chunk-7XQGOCUG.cjs} +1332 -1772
  23. package/dist/chunk-7XQGOCUG.cjs.map +1 -0
  24. package/dist/{chunk-EH5KXQXY.cjs → chunk-A6PGQVTR.cjs} +36 -20
  25. package/dist/chunk-A6PGQVTR.cjs.map +1 -0
  26. package/dist/{chunk-4SLJNZSM.cjs → chunk-AIS37SL2.cjs} +201 -198
  27. package/dist/chunk-AIS37SL2.cjs.map +1 -0
  28. package/dist/{chunk-IQBMAE3F.js → chunk-CKHKCPGL.js} +34 -92
  29. package/dist/chunk-CKHKCPGL.js.map +1 -0
  30. package/dist/{chunk-T43RZTUT.js → chunk-DYWU4SQ2.js} +723 -1246
  31. package/dist/chunk-DYWU4SQ2.js.map +1 -0
  32. package/dist/chunk-EFRQMYZ6.cjs +33 -0
  33. package/dist/chunk-EFRQMYZ6.cjs.map +1 -0
  34. package/dist/{chunk-O4Z2WMFF.js → chunk-HDJ653LM.js} +25 -18
  35. package/dist/chunk-HDJ653LM.js.map +1 -0
  36. package/dist/chunk-HQ43EIYO.cjs +94 -0
  37. package/dist/chunk-HQ43EIYO.cjs.map +1 -0
  38. package/dist/{chunk-6NULZPVC.js → chunk-HTLWPSMU.js} +8 -61
  39. package/dist/chunk-HTLWPSMU.js.map +1 -0
  40. package/dist/{chunk-EPARJI4V.js → chunk-IEP7BPFN.js} +122 -267
  41. package/dist/chunk-IEP7BPFN.js.map +1 -0
  42. package/dist/{chunk-P6KYXFZC.cjs → chunk-IGZRZIAF.cjs} +440 -538
  43. package/dist/chunk-IGZRZIAF.cjs.map +1 -0
  44. package/dist/chunk-JCEFSTVG.cjs +483 -0
  45. package/dist/chunk-JCEFSTVG.cjs.map +1 -0
  46. package/dist/chunk-KXRGY5LK.cjs +612 -0
  47. package/dist/chunk-KXRGY5LK.cjs.map +1 -0
  48. package/dist/{chunk-JHQUHFLX.js → chunk-KZ6ZFCGO.js} +38 -120
  49. package/dist/chunk-KZ6ZFCGO.js.map +1 -0
  50. package/dist/{chunk-ADSJ42DO.js → chunk-L2QA2UTY.js} +17 -69
  51. package/dist/chunk-L2QA2UTY.js.map +1 -0
  52. package/dist/{chunk-OBMBSU2S.js → chunk-L4D23LM2.js} +5 -184
  53. package/dist/chunk-L4D23LM2.js.map +1 -0
  54. package/dist/{chunk-4XFXB37X.js → chunk-L6OW2FL3.js} +7 -90
  55. package/dist/chunk-L6OW2FL3.js.map +1 -0
  56. package/dist/chunk-LE5XMIFJ.cjs +4 -3
  57. package/dist/chunk-LE5XMIFJ.cjs.map +1 -1
  58. package/dist/chunk-MQUCCSWG.js +2 -3
  59. package/dist/chunk-MQUCCSWG.js.map +1 -1
  60. package/dist/{chunk-C23RQVRK.js → chunk-MUIPM26J.js} +66 -216
  61. package/dist/chunk-MUIPM26J.js.map +1 -0
  62. package/dist/{chunk-AUOEM3SF.cjs → chunk-OKWER2RV.cjs} +102 -155
  63. package/dist/chunk-OKWER2RV.cjs.map +1 -0
  64. package/dist/{chunk-TLGX43P6.cjs → chunk-OM7E43ZN.cjs} +89 -86
  65. package/dist/chunk-OM7E43ZN.cjs.map +1 -0
  66. package/dist/{chunk-NEZJ7ZP5.js → chunk-QSXPKZ2F.js} +4 -8
  67. package/dist/chunk-QSXPKZ2F.js.map +1 -0
  68. package/dist/{chunk-VCLL5C7J.js → chunk-RFLFRIPV.js} +14 -57
  69. package/dist/chunk-RFLFRIPV.js.map +1 -0
  70. package/dist/chunk-RIIXJWBR.cjs +24 -0
  71. package/dist/chunk-RIIXJWBR.cjs.map +1 -0
  72. package/dist/{chunk-VRS6WCEK.js → chunk-SFMORPWB.js} +60 -167
  73. package/dist/chunk-SFMORPWB.js.map +1 -0
  74. package/dist/{chunk-YBMUEEM5.js → chunk-TYZSB7JT.js} +4 -8
  75. package/dist/chunk-TYZSB7JT.js.map +1 -0
  76. package/dist/{chunk-BQANU5BH.cjs → chunk-U5BSCAMP.cjs} +34 -44
  77. package/dist/chunk-U5BSCAMP.cjs.map +1 -0
  78. package/dist/{chunk-OSHZQR3W.js → chunk-UEVR4B5S.js} +13 -45
  79. package/dist/chunk-UEVR4B5S.js.map +1 -0
  80. package/dist/{chunk-N4FGA3H4.js → chunk-VBJY2CSK.js} +38 -105
  81. package/dist/chunk-VBJY2CSK.js.map +1 -0
  82. package/dist/{chunk-ZKVOS57Q.cjs → chunk-VFSVN5IQ.cjs} +495 -551
  83. package/dist/chunk-VFSVN5IQ.cjs.map +1 -0
  84. package/dist/{chunk-X4HDKFW5.cjs → chunk-VNRI5DAL.cjs} +56 -105
  85. package/dist/chunk-VNRI5DAL.cjs.map +1 -0
  86. package/dist/chunk-W7B4WQ3L.cjs +200 -0
  87. package/dist/chunk-W7B4WQ3L.cjs.map +1 -0
  88. package/dist/{chunk-623AOJM2.js → chunk-WAGBELKA.js} +7 -25
  89. package/dist/chunk-WAGBELKA.js.map +1 -0
  90. package/dist/{chunk-WEYDDIBQ.cjs → chunk-WH56EW3H.cjs} +36 -64
  91. package/dist/chunk-WH56EW3H.cjs.map +1 -0
  92. package/dist/{chunk-5MAYUGTE.cjs → chunk-XAS7LANM.cjs} +233 -363
  93. package/dist/chunk-XAS7LANM.cjs.map +1 -0
  94. package/dist/comments.cjs +210 -290
  95. package/dist/comments.cjs.map +1 -1
  96. package/dist/comments.js +82 -186
  97. package/dist/comments.js.map +1 -1
  98. package/dist/diff.cjs +48 -65
  99. package/dist/diff.cjs.map +1 -1
  100. package/dist/diff.d.cts +2 -2
  101. package/dist/diff.d.ts +2 -2
  102. package/dist/diff.js +8 -32
  103. package/dist/diff.js.map +1 -1
  104. package/dist/docx.cjs +50 -63
  105. package/dist/docx.cjs.map +1 -1
  106. package/dist/docx.js +7 -22
  107. package/dist/docx.js.map +1 -1
  108. package/dist/embed.cjs +19 -12
  109. package/dist/embed.cjs.map +1 -1
  110. package/dist/embed.js +10 -16
  111. package/dist/embed.js.map +1 -1
  112. package/dist/emoji-data.cjs +7 -5
  113. package/dist/emoji-data.cjs.map +1 -1
  114. package/dist/emoji-data.js +3 -5
  115. package/dist/emoji-data.js.map +1 -1
  116. package/dist/emoji.cjs +26 -17
  117. package/dist/emoji.cjs.map +1 -1
  118. package/dist/emoji.js +9 -17
  119. package/dist/emoji.js.map +1 -1
  120. package/dist/engine.cjs +229 -118
  121. package/dist/engine.cjs.map +1 -1
  122. package/dist/engine.js +4 -118
  123. package/dist/engine.js.map +1 -1
  124. package/dist/find.cjs +30 -19
  125. package/dist/find.cjs.map +1 -1
  126. package/dist/find.js +9 -19
  127. package/dist/find.js.map +1 -1
  128. package/dist/headless.cjs +291 -151
  129. package/dist/headless.cjs.map +1 -1
  130. package/dist/headless.d.cts +5 -1
  131. package/dist/headless.d.ts +5 -1
  132. package/dist/headless.js +6 -151
  133. package/dist/headless.js.map +1 -1
  134. package/dist/index.cjs +349 -183
  135. package/dist/index.cjs.map +1 -1
  136. package/dist/index.d.cts +17 -4
  137. package/dist/index.d.ts +17 -4
  138. package/dist/index.js +8 -183
  139. package/dist/index.js.map +1 -1
  140. package/dist/math.cjs +20 -13
  141. package/dist/math.cjs.map +1 -1
  142. package/dist/math.js +11 -17
  143. package/dist/math.js.map +1 -1
  144. package/dist/mention.cjs +20 -13
  145. package/dist/mention.cjs.map +1 -1
  146. package/dist/mention.js +11 -17
  147. package/dist/mention.js.map +1 -1
  148. package/dist/presence.cjs +99 -132
  149. package/dist/presence.cjs.map +1 -1
  150. package/dist/presence.js +22 -78
  151. package/dist/presence.js.map +1 -1
  152. package/dist/{registry-CWBOSAHm.d.ts → registry-CXegaw5k.d.cts} +25 -2
  153. package/dist/{registry-CWBOSAHm.d.cts → registry-CXegaw5k.d.ts} +25 -2
  154. package/dist/stats.cjs +27 -18
  155. package/dist/stats.cjs.map +1 -1
  156. package/dist/stats.js +10 -18
  157. package/dist/stats.js.map +1 -1
  158. package/dist/styles.css +1 -1
  159. package/dist/table.cjs +90 -49
  160. package/dist/table.cjs.map +1 -1
  161. package/dist/table.js +9 -49
  162. package/dist/table.js.map +1 -1
  163. package/dist/toc.cjs +26 -17
  164. package/dist/toc.cjs.map +1 -1
  165. package/dist/toc.js +9 -17
  166. package/dist/toc.js.map +1 -1
  167. package/dist/view.cjs +13 -16
  168. package/dist/view.cjs.map +1 -1
  169. package/dist/view.d.cts +2 -2
  170. package/dist/view.d.ts +2 -2
  171. package/dist/view.js +7 -16
  172. package/dist/view.js.map +1 -1
  173. package/dist/yjs.cjs +186 -228
  174. package/dist/yjs.cjs.map +1 -1
  175. package/dist/yjs.js +12 -80
  176. package/dist/yjs.js.map +1 -1
  177. package/package.json +2 -1
  178. package/dist/chunk-4SLJNZSM.cjs.map +0 -1
  179. package/dist/chunk-4XFXB37X.js.map +0 -1
  180. package/dist/chunk-5MAYUGTE.cjs.map +0 -1
  181. package/dist/chunk-623AOJM2.js.map +0 -1
  182. package/dist/chunk-6NULZPVC.js.map +0 -1
  183. package/dist/chunk-6V6GGBDK.cjs.map +0 -1
  184. package/dist/chunk-73653CJ4.cjs +0 -34
  185. package/dist/chunk-73653CJ4.cjs.map +0 -1
  186. package/dist/chunk-ADSJ42DO.js.map +0 -1
  187. package/dist/chunk-AUOEM3SF.cjs.map +0 -1
  188. package/dist/chunk-BQANU5BH.cjs.map +0 -1
  189. package/dist/chunk-C23RQVRK.js.map +0 -1
  190. package/dist/chunk-CW3AFJBR.cjs.map +0 -1
  191. package/dist/chunk-DUE3HCZD.js.map +0 -1
  192. package/dist/chunk-EH5KXQXY.cjs.map +0 -1
  193. package/dist/chunk-EPARJI4V.js.map +0 -1
  194. package/dist/chunk-FDRUAL3Z.cjs.map +0 -1
  195. package/dist/chunk-IQBMAE3F.js.map +0 -1
  196. package/dist/chunk-JHQUHFLX.js.map +0 -1
  197. package/dist/chunk-KUYZMSMF.cjs +0 -100
  198. package/dist/chunk-KUYZMSMF.cjs.map +0 -1
  199. package/dist/chunk-LLTEGXWZ.cjs +0 -562
  200. package/dist/chunk-LLTEGXWZ.cjs.map +0 -1
  201. package/dist/chunk-N4FGA3H4.js.map +0 -1
  202. package/dist/chunk-NEZJ7ZP5.js.map +0 -1
  203. package/dist/chunk-O4Z2WMFF.js.map +0 -1
  204. package/dist/chunk-OBMBSU2S.js.map +0 -1
  205. package/dist/chunk-OSHZQR3W.js.map +0 -1
  206. package/dist/chunk-P6KYXFZC.cjs.map +0 -1
  207. package/dist/chunk-R2BLBV43.cjs +0 -239
  208. package/dist/chunk-R2BLBV43.cjs.map +0 -1
  209. package/dist/chunk-RJRX34BZ.js.map +0 -1
  210. package/dist/chunk-T43RZTUT.js.map +0 -1
  211. package/dist/chunk-TLGX43P6.cjs.map +0 -1
  212. package/dist/chunk-U3LOLYAU.js.map +0 -1
  213. package/dist/chunk-UEKXVCKC.cjs +0 -716
  214. package/dist/chunk-UEKXVCKC.cjs.map +0 -1
  215. package/dist/chunk-VCLL5C7J.js.map +0 -1
  216. package/dist/chunk-VRS6WCEK.js.map +0 -1
  217. package/dist/chunk-WEYDDIBQ.cjs.map +0 -1
  218. package/dist/chunk-X4HDKFW5.cjs.map +0 -1
  219. package/dist/chunk-X4P4TQXH.cjs +0 -30
  220. package/dist/chunk-X4P4TQXH.cjs.map +0 -1
  221. package/dist/chunk-XA3UEJIW.cjs +0 -25
  222. package/dist/chunk-XA3UEJIW.cjs.map +0 -1
  223. package/dist/chunk-YBMUEEM5.js.map +0 -1
  224. package/dist/chunk-ZKVOS57Q.cjs.map +0 -1
package/dist/ai.cjs CHANGED
@@ -1,61 +1,17 @@
1
- 'use client';"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
-
3
-
4
- var _chunkLE5XMIFJcjs = require('./chunk-LE5XMIFJ.cjs');
5
-
6
-
7
- var _chunk73653CJ4cjs = require('./chunk-73653CJ4.cjs');
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
- var _chunkCW3AFJBRcjs = require('./chunk-CW3AFJBR.cjs');
21
-
22
-
23
-
24
-
25
-
26
- var _chunkP6KYXFZCcjs = require('./chunk-P6KYXFZC.cjs');
27
- require('./chunk-EH5KXQXY.cjs');
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
- var _chunkZKVOS57Qcjs = require('./chunk-ZKVOS57Q.cjs');
51
- require('./chunk-6V6GGBDK.cjs');
52
-
53
-
54
-
55
-
56
-
57
-
58
- var _chunk4SLJNZSMcjs = require('./chunk-4SLJNZSM.cjs');
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ var chunkLE5XMIFJ_cjs = require('./chunk-LE5XMIFJ.cjs');
5
+ var chunkEFRQMYZ6_cjs = require('./chunk-EFRQMYZ6.cjs');
6
+ var chunk7XQGOCUG_cjs = require('./chunk-7XQGOCUG.cjs');
7
+ var chunkIGZRZIAF_cjs = require('./chunk-IGZRZIAF.cjs');
8
+ require('./chunk-A6PGQVTR.cjs');
9
+ var chunkVFSVN5IQ_cjs = require('./chunk-VFSVN5IQ.cjs');
10
+ require('./chunk-7SVKLWDT.cjs');
11
+ var chunkAIS37SL2_cjs = require('./chunk-AIS37SL2.cjs');
12
+ var lucideReact = require('lucide-react');
13
+ var react = require('react');
14
+ var jsxRuntime = require('react/jsx-runtime');
59
15
 
60
16
  // src/extensions/ai/streaming-markdown.ts
61
17
  var FENCE = /^ {0,3}(`{3,}|~{3,})/;
@@ -70,8 +26,8 @@ var isSpace = (char) => char === void 0 || /\s/.test(char);
70
26
  function openFence(lines) {
71
27
  let open = null;
72
28
  for (const line of lines) {
73
- const fence = _optionalChain([FENCE, 'access', _2 => _2.exec, 'call', _3 => _3(line), 'optionalAccess', _4 => _4[1]]);
74
- if (open === null) open = _nullishCoalesce(fence, () => ( null));
29
+ const fence = FENCE.exec(line)?.[1];
30
+ if (open === null) open = fence ?? null;
75
31
  else if (fence !== void 0 && fence[0] === open[0] && fence.length >= open.length && line.trim() === fence) {
76
32
  open = null;
77
33
  }
@@ -91,7 +47,7 @@ function tokenAt(body, at) {
91
47
  if (DOUBLE.includes(two)) return two;
92
48
  const one = body[at];
93
49
  if (one === "*") return one;
94
- if (one === "_" && !(WORD.test(_nullishCoalesce(body[at - 1], () => ( ""))) && WORD.test(_nullishCoalesce(body[at + 1], () => ( ""))))) return one;
50
+ if (one === "_" && !(WORD.test(body[at - 1] ?? "") && WORD.test(body[at + 1] ?? ""))) return one;
95
51
  return null;
96
52
  }
97
53
  function codeEnd(body, at) {
@@ -124,7 +80,7 @@ function closeInline(source) {
124
80
  }
125
81
  const before = body[at - 1];
126
82
  const after = body[at + token.length];
127
- if (_optionalChain([opened, 'access', _5 => _5.at, 'call', _6 => _6(-1), 'optionalAccess', _7 => _7.token]) === token && !isSpace(before)) opened.pop();
83
+ if (opened.at(-1)?.token === token && !isSpace(before)) opened.pop();
128
84
  else if (after === void 0 || !isSpace(after)) opened.push({ token, at });
129
85
  at += token.length;
130
86
  }
@@ -147,49 +103,49 @@ function closeStreaming(markdown) {
147
103
  }
148
104
  const block = lines.slice(first).join("\n");
149
105
  const head = markdown.slice(0, markdown.length - block.length);
150
- const prefix = _nullishCoalesce(_optionalChain([LINE_PREFIX, 'access', _8 => _8.exec, 'call', _9 => _9(block), 'optionalAccess', _10 => _10[0]]), () => ( ""));
106
+ const prefix = LINE_PREFIX.exec(block)?.[0] ?? "";
151
107
  return head + prefix + closeInline(block.slice(prefix.length));
152
108
  }
153
109
 
154
110
  // src/extensions/ai/ai-target.ts
155
111
  function targetOfBlocks(state, ids) {
156
112
  const { doc, schema } = state;
157
- const first = _chunk4SLJNZSMcjs.blockById.call(void 0, doc, ids[0]);
158
- const last = _chunk4SLJNZSMcjs.blockById.call(void 0, doc, ids[ids.length - 1]);
113
+ const first = chunkAIS37SL2_cjs.blockById(doc, ids[0]);
114
+ const last = chunkAIS37SL2_cjs.blockById(doc, ids[ids.length - 1]);
159
115
  if (first === void 0 || last === void 0) return null;
160
- const start = _chunkZKVOS57Qcjs.primaryRegion.call(void 0, schema, first);
161
- const end = _chunkZKVOS57Qcjs.primaryRegion.call(void 0, schema, last);
116
+ const start = chunkVFSVN5IQ_cjs.primaryRegion(schema, first);
117
+ const end = chunkVFSVN5IQ_cjs.primaryRegion(schema, last);
162
118
  if (start === null || end === null) return null;
163
119
  const from = { block: first.id, region: start, offset: 0 };
164
- return { from, to: { block: last.id, region: end, offset: _chunkZKVOS57Qcjs.regionLength.call(void 0, last, end) }, selected: ids.length > 1 };
120
+ return { from, to: { block: last.id, region: end, offset: chunkVFSVN5IQ_cjs.regionLength(last, end) }, selected: ids.length > 1 };
165
121
  }
166
122
  function targetOfSelection(state) {
167
123
  const { doc, selection } = state;
168
124
  if (selection === null) return null;
169
- if (selection.kind !== "text") return targetOfBlocks(state, _chunkZKVOS57Qcjs.selectedBlockIds.call(void 0, doc, selection));
170
- const { from, to } = _chunkZKVOS57Qcjs.orderedRange.call(void 0, doc, selection.anchor, selection.head);
171
- if (_chunkZKVOS57Qcjs.comparePos.call(void 0, doc, from, to) !== 0) return { from, to, selected: true };
125
+ if (selection.kind !== "text") return targetOfBlocks(state, chunkVFSVN5IQ_cjs.selectedBlockIds(doc, selection));
126
+ const { from, to } = chunkVFSVN5IQ_cjs.orderedRange(doc, selection.anchor, selection.head);
127
+ if (chunkVFSVN5IQ_cjs.comparePos(doc, from, to) !== 0) return { from, to, selected: true };
172
128
  const block = doc.blocks[doc.index.get(from.block)];
173
129
  const whole = { block: from.block, region: from.region };
174
- return { from: { ...whole, offset: 0 }, to: { ...whole, offset: _chunkZKVOS57Qcjs.regionLength.call(void 0, block, from.region) }, selected: false };
130
+ return { from: { ...whole, offset: 0 }, to: { ...whole, offset: chunkVFSVN5IQ_cjs.regionLength(block, from.region) }, selected: false };
175
131
  }
176
132
  function nearestKept(tr, target) {
177
133
  const { doc } = tr.before;
178
- const first = _nullishCoalesce(doc.index.get(target.from.block), () => ( 0));
179
- const last = _nullishCoalesce(doc.index.get(target.to.block), () => ( first));
180
- const kept = (block) => block && _chunk4SLJNZSMcjs.blockById.call(void 0, tr.doc, block.id);
134
+ const first = doc.index.get(target.from.block) ?? 0;
135
+ const last = doc.index.get(target.to.block) ?? first;
136
+ const kept = (block) => block && chunkAIS37SL2_cjs.blockById(tr.doc, block.id);
181
137
  for (let step = 1; first - step >= 0 || last + step < doc.blocks.length; step++) {
182
- const found = _nullishCoalesce(kept(doc.blocks[first - step]), () => ( kept(doc.blocks[last + step])));
138
+ const found = kept(doc.blocks[first - step]) ?? kept(doc.blocks[last + step]);
183
139
  if (found) return found;
184
140
  }
185
141
  return tr.doc.blocks[0];
186
142
  }
187
143
  function edgeOf(tr, target) {
188
144
  const point = tr.mapPos(target.from, -1);
189
- const block = _nullishCoalesce(_chunk4SLJNZSMcjs.blockById.call(void 0, tr.doc, point.block), () => ( nearestKept(tr, target)));
145
+ const block = chunkAIS37SL2_cjs.blockById(tr.doc, point.block) ?? nearestKept(tr, target);
190
146
  if (block === void 0) return null;
191
- const region = _nullishCoalesce(_chunkZKVOS57Qcjs.primaryRegion.call(void 0, tr.before.schema, block), () => ( ""));
192
- const length = region === "" ? 0 : _chunkZKVOS57Qcjs.regionLength.call(void 0, block, region);
147
+ const region = chunkVFSVN5IQ_cjs.primaryRegion(tr.before.schema, block) ?? "";
148
+ const length = region === "" ? 0 : chunkVFSVN5IQ_cjs.regionLength(block, region);
193
149
  const offset = block.id === point.block ? Math.min(point.offset, length) : length;
194
150
  const after = offset > 0 || length === 0;
195
151
  const at = { block: block.id, region, offset: after ? length : 0 };
@@ -201,29 +157,29 @@ function mapTarget(tr, target) {
201
157
  const from = tr.mapPos(target.from, inside);
202
158
  const mapped2 = tr.mapPos(target.to, -inside);
203
159
  if (!tr.doc.index.has(from.block) || !tr.doc.index.has(mapped2.block)) return edgeOf(tr, target);
204
- const to = _chunkZKVOS57Qcjs.comparePos.call(void 0, tr.doc, from, mapped2) > 0 ? from : mapped2;
160
+ const to = chunkVFSVN5IQ_cjs.comparePos(tr.doc, from, mapped2) > 0 ? from : mapped2;
205
161
  return from === target.from && to === target.to ? target : { ...target, from, to };
206
162
  }
207
- var targetGone = (doc, target) => target.lost !== void 0 || target.selected && _chunkZKVOS57Qcjs.comparePos.call(void 0, doc, target.from, target.to) === 0;
163
+ var targetGone = (doc, target) => target.lost !== void 0 || target.selected && chunkVFSVN5IQ_cjs.comparePos(doc, target.from, target.to) === 0;
208
164
  function targetRanges(state, { from, to }) {
209
165
  const { doc, schema } = state;
210
166
  const start = doc.index.get(from.block);
211
167
  const end = doc.index.get(to.block);
212
168
  return doc.blocks.slice(start, end + 1).flatMap((block, i) => {
213
- const region = i === 0 ? from.region : block.id === to.block ? to.region : _chunkZKVOS57Qcjs.primaryRegion.call(void 0, schema, block);
169
+ const region = i === 0 ? from.region : block.id === to.block ? to.region : chunkVFSVN5IQ_cjs.primaryRegion(schema, block);
214
170
  if (region === null || !Object.hasOwn(block.regions, region)) return [];
215
171
  const left = i === 0 ? from.offset : 0;
216
- const right = block.id === to.block ? to.offset : _chunkZKVOS57Qcjs.regionLength.call(void 0, block, region);
172
+ const right = block.id === to.block ? to.offset : chunkVFSVN5IQ_cjs.regionLength(block, region);
217
173
  return right > left ? [{ block: block.id, region, from: left, to: right }] : [];
218
174
  });
219
175
  }
220
176
 
221
177
  // src/extensions/ai/ai-plugin.ts
222
- var aiKey = _chunkZKVOS57Qcjs.createPluginKey.call(void 0, "ai");
178
+ var aiKey = chunkVFSVN5IQ_cjs.createPluginKey("ai");
223
179
  var AI = "ai";
224
180
  var IDLE = { target: null, menu: null, ghost: null, held: [] };
225
- var aiState = (state) => _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, aiKey);
226
- var aiTransaction = (state, act2) => new (0, _chunkZKVOS57Qcjs.Transaction)(state).setMeta(AI, act2).setMeta("addToHistory", false);
181
+ var aiState = (state) => chunkVFSVN5IQ_cjs.getPluginState(state, aiKey);
182
+ var aiTransaction = (state, act2) => new chunkVFSVN5IQ_cjs.Transaction(state).setMeta(AI, act2).setMeta("addToHistory", false);
227
183
  function written(ghost, key, phase, output) {
228
184
  return ghost.key !== key ? ghost : { ...ghost, phase, output, shown: closeStreaming(output) };
229
185
  }
@@ -252,11 +208,11 @@ function act(value, action) {
252
208
  }
253
209
  function caretBlock(state) {
254
210
  const { selection } = state;
255
- return _optionalChain([selection, 'optionalAccess', _11 => _11.kind]) === "text" ? selection.head.block : null;
211
+ return selection?.kind === "text" ? selection.head.block : null;
256
212
  }
257
213
  function hasText(state, id) {
258
- const block = _chunk4SLJNZSMcjs.blockById.call(void 0, state.doc, id);
259
- return block !== void 0 && Object.keys(block.regions).some((region) => _chunkZKVOS57Qcjs.regionLength.call(void 0, block, region) > 0);
214
+ const block = chunkAIS37SL2_cjs.blockById(state.doc, id);
215
+ return block !== void 0 && Object.keys(block.regions).some((region) => chunkVFSVN5IQ_cjs.regionLength(block, region) > 0);
260
216
  }
261
217
  function heldText(tr, value, before, after) {
262
218
  if (!tr.docChanged) return value.held;
@@ -295,15 +251,12 @@ function decorate(state, { target, ghost }) {
295
251
  function aiDecorations(state) {
296
252
  const value = aiState(state);
297
253
  const last = drawn.get(value);
298
- if (_optionalChain([last, 'optionalAccess', _12 => _12.doc]) === state.doc) return last.decorations;
254
+ if (last?.doc === state.doc) return last.decorations;
299
255
  const decorations = decorate(state, value);
300
256
  drawn.set(value, { doc: state.doc, decorations });
301
257
  return decorations;
302
258
  }
303
259
 
304
- // src/extensions/ai/ai-items.ts
305
- var _lucidereact = require('lucide-react');
306
-
307
260
  // src/extensions/ai/ai-actions.ts
308
261
  var MENU_ACTIONS = [
309
262
  "continue",
@@ -357,16 +310,16 @@ function aroundSelection(text, start, end, limit = CONTEXT_LIMIT) {
357
310
  }
358
311
  var WHITESPACE_ENTITY = /(?<!\\)&#(32|9);/g;
359
312
  var plain = (markdown) => markdown.replace(WHITESPACE_ENTITY, (_, code) => code === "32" ? " " : " ");
360
- var markdownOf = (state, blocks) => _chunkZKVOS57Qcjs.toMarkdown.call(void 0, blocks, { schema: state.schema, comments: false });
313
+ var markdownOf = (state, blocks) => chunkVFSVN5IQ_cjs.toMarkdown(blocks, { schema: state.schema, comments: false });
361
314
  function rangeMarkdown(state, from, to) {
362
- const slice = _chunkZKVOS57Qcjs.sliceFromSelection.call(void 0, { ...state, selection: _chunkZKVOS57Qcjs.textSelection.call(void 0, from, to) }, _chunk4SLJNZSMcjs.createBlockCodec.call(void 0, state.schema));
315
+ const slice = chunkVFSVN5IQ_cjs.sliceFromSelection({ ...state, selection: chunkVFSVN5IQ_cjs.textSelection(from, to) }, chunkAIS37SL2_cjs.createBlockCodec(state.schema));
363
316
  return slice === null ? "" : markdownOf(state, slice.blocks).replace(/\n$/, "");
364
317
  }
365
318
  function documentContext(state, target, selection) {
366
- const blocks = _chunk4SLJNZSMcjs.createBlockCodec.call(void 0, state.schema).blocksFromDoc(state.doc);
319
+ const blocks = chunkAIS37SL2_cjs.createBlockCodec(state.schema).blocksFromDoc(state.doc);
367
320
  const full = plain(markdownOf(state, blocks));
368
321
  if (full.length <= CONTEXT_LIMIT) return full;
369
- const index = _nullishCoalesce(state.doc.index.get(target.from.block), () => ( 0));
322
+ const index = state.doc.index.get(target.from.block) ?? 0;
370
323
  const blockStart = index === 0 ? 0 : plain(markdownOf(state, blocks.slice(0, index))).length + 1;
371
324
  const lead = { ...target.from, offset: 0 };
372
325
  const start = blockStart + plain(rangeMarkdown(state, lead, target.from)).length;
@@ -394,7 +347,7 @@ function endRun(link, ended = false) {
394
347
  const { run } = link;
395
348
  if (run === null) return null;
396
349
  link.run = null;
397
- _optionalChain([run, 'access', _13 => _13.cancelFrame, 'optionalCall', _14 => _14()]);
350
+ run.cancelFrame?.();
398
351
  run.cancelFrame = null;
399
352
  if (!ended) run.abort.abort();
400
353
  return run;
@@ -424,7 +377,7 @@ async function read(editor, link, run, stream, request) {
424
377
  } catch (error) {
425
378
  if (!live()) return;
426
379
  end("error");
427
- link.report(_chunkCW3AFJBRcjs.toError.call(void 0, error));
380
+ link.report(chunk7XQGOCUG_cjs.toError(error));
428
381
  }
429
382
  }
430
383
  function startStream(editor, link, stream, request, replace) {
@@ -438,7 +391,7 @@ function startStream(editor, link, stream, request, replace) {
438
391
  }
439
392
  function stopped(editor, link, key, output) {
440
393
  const { ghost } = aiState(editor.state);
441
- if (link.mounts === 0 || _optionalChain([ghost, 'optionalAccess', _15 => _15.key]) !== key || ghost.phase !== "streaming") return;
394
+ if (link.mounts === 0 || ghost?.key !== key || ghost.phase !== "streaming") return;
442
395
  send(editor, { type: "end", key, phase: "stopped", output });
443
396
  link.ended("stopped", output);
444
397
  }
@@ -453,8 +406,8 @@ function watchGhost(editor, link) {
453
406
  const { run } = link;
454
407
  const { ghost, target } = aiState(state);
455
408
  if (run === null) return;
456
- if (_optionalChain([ghost, 'optionalAccess', _16 => _16.key]) !== run.key || ghost.phase !== "streaming") endRun(link);
457
- else if (_optionalChain([target, 'optionalAccess', _17 => _17.lost]) !== void 0 && tr !== null && _optionalChain([aiState, 'call', _18 => _18(tr.before), 'access', _19 => _19.target, 'optionalAccess', _20 => _20.lost]) === void 0) {
409
+ if (ghost?.key !== run.key || ghost.phase !== "streaming") endRun(link);
410
+ else if (target?.lost !== void 0 && tr !== null && aiState(tr.before).target?.lost === void 0) {
458
411
  endRun(link);
459
412
  queueMicrotask(() => stopped(editor, link, run.key, run.output));
460
413
  }
@@ -499,7 +452,7 @@ function discard(editor) {
499
452
 
500
453
  // src/extensions/ai/ai-env.ts
501
454
  function languageOf(controller) {
502
- return _optionalChain([controller, 'access', _21 => _21.root, 'optionalAccess', _22 => _22.closest, 'call', _23 => _23("[lang]"), 'optionalAccess', _24 => _24.getAttribute, 'call', _25 => _25("lang")]) || void 0;
455
+ return controller.root?.closest("[lang]")?.getAttribute("lang") || void 0;
503
456
  }
504
457
  function askFrom(env, action, prompt) {
505
458
  const { controller, stream } = env;
@@ -521,7 +474,7 @@ function aiSlashItems(labels, stream) {
521
474
  title: labels.askAi,
522
475
  description: labels.askAiDescription,
523
476
  group: "ai",
524
- icon: _lucidereact.Sparkles,
477
+ icon: lucideReact.Sparkles,
525
478
  keywords: KEYWORDS,
526
479
  run: ({ controller }) => void openFor(controller)
527
480
  },
@@ -529,10 +482,10 @@ function aiSlashItems(labels, stream) {
529
482
  id: "ai-continue",
530
483
  title: labels.actions.continue,
531
484
  group: "ai",
532
- icon: _lucidereact.PenLine,
485
+ icon: lucideReact.PenLine,
533
486
  keywords: [...KEYWORDS, "continue"],
534
487
  run: ({ controller }) => {
535
- if (openFor(controller)) askFrom({ controller, stream, labels }, "continue");
488
+ if (openFor(controller)) askFrom({ controller, stream}, "continue");
536
489
  }
537
490
  }
538
491
  ];
@@ -540,14 +493,14 @@ function aiSlashItems(labels, stream) {
540
493
  var aiBubbleItem = (labels) => ({
541
494
  id: "ai",
542
495
  title: labels.askAi,
543
- icon: _lucidereact.Sparkles,
496
+ icon: lucideReact.Sparkles,
544
497
  available: (state) => aiState(state).ghost === null,
545
498
  run: (controller) => void openFor(controller)
546
499
  });
547
500
  var aiBlockMenuItem = (labels) => ({
548
501
  id: "ai",
549
502
  label: labels.askAi,
550
- icon: _lucidereact.Sparkles,
503
+ icon: lucideReact.Sparkles,
551
504
  available: (state, blockIds) => targetOfBlocks(state, blockIds) !== null,
552
505
  run: (controller, blockIds) => {
553
506
  const target = targetOfBlocks(controller.editor.state, blockIds);
@@ -591,7 +544,7 @@ var englishAiLabels = {
591
544
  targetGone: "The text this was for was removed, so Accept inserts it where that text was"
592
545
  };
593
546
  function resolveAiLabels(overrides) {
594
- const given = Object.entries(_nullishCoalesce(overrides, () => ( {}))).filter(([, value]) => value !== void 0);
547
+ const given = Object.entries(overrides ?? {}).filter(([, value]) => value !== void 0);
595
548
  return given.length === 0 ? englishAiLabels : { ...englishAiLabels, ...Object.fromEntries(given) };
596
549
  }
597
550
 
@@ -599,31 +552,25 @@ function resolveAiLabels(overrides) {
599
552
  var openOnSpace = (state, dispatch) => {
600
553
  const { selection, doc } = state;
601
554
  const ai = aiState(state);
602
- if (_optionalChain([selection, 'optionalAccess', _26 => _26.kind]) !== "text" || !_chunkZKVOS57Qcjs.isCollapsed.call(void 0, selection) || ai.menu !== null || ai.ghost !== null) return false;
555
+ if (selection?.kind !== "text" || !chunkVFSVN5IQ_cjs.isCollapsed(selection) || ai.menu !== null || ai.ghost !== null) return false;
603
556
  const { head } = selection;
604
557
  const block = doc.blocks[doc.index.get(head.block)];
605
558
  const paragraph = block.type === "MARKDOWN" && block.attrs.kind === "paragraph";
606
- if (!paragraph || _chunkZKVOS57Qcjs.regionLength.call(void 0, block, head.region) > 0 || ai.held.includes(block.id)) return false;
607
- _optionalChain([dispatch, 'optionalCall', _27 => _27(aiTransaction(state, { type: "open", target: { from: head, to: head, selected: false }, fromSpace: true }))]);
559
+ if (!paragraph || chunkVFSVN5IQ_cjs.regionLength(block, head.region) > 0 || ai.held.includes(block.id)) return false;
560
+ dispatch?.(aiTransaction(state, { type: "open", target: { from: head, to: head, selected: false }, fromSpace: true }));
608
561
  return true;
609
562
  };
610
563
 
611
- // src/extensions/ai/AiOverlay.tsx
612
- var _react = require('react');
613
-
614
- // src/extensions/ai/AiBar.tsx
615
-
616
-
617
564
  // src/extensions/ai/ai-accept.ts
618
- var isParagraph = (block) => _optionalChain([block, 'optionalAccess', _28 => _28.type]) === "MARKDOWN" && _chunk4SLJNZSMcjs.parseLine.call(void 0, String(_nullishCoalesce(block.data.markdown, () => ( "")))).kind === "paragraph";
565
+ var isParagraph = (block) => block?.type === "MARKDOWN" && chunkAIS37SL2_cjs.parseLine(String(block.data.markdown ?? "")).kind === "paragraph";
619
566
  var DISCARD = { type: "discard" };
620
567
  function insertBeside(tr, schema, target, pieces, makeId) {
621
568
  const index = tr.doc.index.get(target.to.block);
622
- const at = _optionalChain([target, 'access', _29 => _29.lost, 'optionalAccess', _30 => _30.after]) ? _chunkZKVOS57Qcjs.descendantsEnd.call(void 0, tr.doc, index) : index;
623
- const fresh = _chunkZKVOS57Qcjs.freshBlocks.call(void 0, pieces, tr.doc.blocks[index].indent, makeId);
624
- tr.step(_chunkZKVOS57Qcjs.insertBlocksStep.call(void 0, at, fresh));
625
- _chunkZKVOS57Qcjs.capIndents.call(void 0, tr, at, at + fresh.length);
626
- tr.setSelection(_chunkZKVOS57Qcjs.endOf.call(void 0, tr.doc, schema, fresh[fresh.length - 1].id));
569
+ const at = target.lost?.after ? chunkVFSVN5IQ_cjs.descendantsEnd(tr.doc, index) : index;
570
+ const fresh = chunkVFSVN5IQ_cjs.freshBlocks(pieces, tr.doc.blocks[index].indent, makeId);
571
+ tr.step(chunkVFSVN5IQ_cjs.insertBlocksStep(at, fresh));
572
+ chunkVFSVN5IQ_cjs.capIndents(tr, at, at + fresh.length);
573
+ tr.setSelection(chunkVFSVN5IQ_cjs.endOf(tr.doc, schema, fresh[fresh.length - 1].id));
627
574
  }
628
575
  function acceptAnswer(editor) {
629
576
  const { state } = editor;
@@ -631,7 +578,7 @@ function acceptAnswer(editor) {
631
578
  if (target === null || ghost === null || ghost.phase === "streaming" || ghost.phase === "error") return null;
632
579
  const { codec } = editor;
633
580
  const makeId = codec.context.newId;
634
- const blocks = _chunk4SLJNZSMcjs.fromMarkdown.call(void 0, ghost.output, { newId: makeId });
581
+ const blocks = chunkAIS37SL2_cjs.fromMarkdown(ghost.output, { newId: makeId });
635
582
  const pieces = blocks.flatMap((block) => codec.toEngineBlocks(block));
636
583
  const tr = editor.createTransaction().setOrigin("ai").setMeta(AI, DISCARD);
637
584
  const gone = targetGone(state.doc, target);
@@ -641,37 +588,34 @@ function acceptAnswer(editor) {
641
588
  const { schema } = state;
642
589
  const open = { openStart: isParagraph(blocks[0]), openEnd: isParagraph(blocks[blocks.length - 1]) };
643
590
  if (ghost.replace || gone) {
644
- const caret = ghost.replace && !gone ? _chunkZKVOS57Qcjs.deleteRange.call(void 0, tr, schema, target.from, target.to, makeId) : target.to;
645
- _chunkZKVOS57Qcjs.pasteAtCaret.call(void 0, tr, schema, caret, open, pieces, makeId);
591
+ const caret = ghost.replace && !gone ? chunkVFSVN5IQ_cjs.deleteRange(tr, schema, target.from, target.to, makeId) : target.to;
592
+ chunkVFSVN5IQ_cjs.pasteAtCaret(tr, schema, caret, open, pieces, makeId);
646
593
  } else {
647
594
  const block = tr.doc.blocks[tr.doc.index.get(target.to.block)];
648
- const end = { ...target.to, offset: _chunkZKVOS57Qcjs.regionLength.call(void 0, block, target.to.region) };
649
- _chunkZKVOS57Qcjs.pasteAtCaret.call(void 0, tr, schema, end, { openStart: false, openEnd: false }, pieces, makeId);
595
+ const end = { ...target.to, offset: chunkVFSVN5IQ_cjs.regionLength(block, target.to.region) };
596
+ chunkVFSVN5IQ_cjs.pasteAtCaret(tr, schema, end, { openStart: false, openEnd: false }, pieces, makeId);
650
597
  }
651
598
  }
652
599
  editor.dispatch(tr);
653
600
  return { gone };
654
601
  }
655
-
656
- // src/extensions/ai/AiBar.tsx
657
- var _jsxruntime = require('react/jsx-runtime');
658
602
  var PRIMARY = "data-ai-primary";
659
603
  function AiBar({ env, ghost, gone, barId }) {
660
604
  const { controller, stream, labels } = env;
661
605
  const { editor } = controller;
662
- const content = _react.useRef.call(void 0, null);
663
- const inside = _react.useRef.call(void 0, false);
664
- const [next, setNext] = _react.useState.call(void 0, "");
606
+ const content = react.useRef(null);
607
+ const inside = react.useRef(false);
608
+ const [next, setNext] = react.useState("");
665
609
  const { phase } = ghost;
666
- const focusPrimary = () => _optionalChain([content, 'access', _31 => _31.current, 'optionalAccess', _32 => _32.querySelector, 'call', _33 => _33(`[${PRIMARY}]`), 'optionalAccess', _34 => _34.focus, 'call', _35 => _35()]);
667
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
668
- const active = _optionalChain([content, 'access', _36 => _36.current, 'optionalAccess', _37 => _37.ownerDocument, 'access', _38 => _38.activeElement]);
610
+ const focusPrimary = () => content.current?.querySelector(`[${PRIMARY}]`)?.focus();
611
+ chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
612
+ const active = content.current?.ownerDocument.activeElement;
669
613
  inside.current = active == null || active === active.ownerDocument.body;
670
614
  if (inside.current) focusPrimary();
671
615
  }, []);
672
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
673
- const active = _optionalChain([content, 'access', _39 => _39.current, 'optionalAccess', _40 => _40.ownerDocument, 'access', _41 => _41.activeElement]);
674
- if (inside.current && !_optionalChain([content, 'access', _42 => _42.current, 'optionalAccess', _43 => _43.contains, 'call', _44 => _44(_nullishCoalesce(active, () => ( null)))])) focusPrimary();
616
+ chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
617
+ const active = content.current?.ownerDocument.activeElement;
618
+ if (inside.current && !content.current?.contains(active ?? null)) focusPrimary();
675
619
  }, [phase, ghost.key]);
676
620
  const backToText = () => {
677
621
  if (inside.current) controller.focus();
@@ -681,7 +625,7 @@ function AiBar({ env, ghost, gone, barId }) {
681
625
  let gone2 = false;
682
626
  controller.edit(() => {
683
627
  const result = acceptAnswer(editor);
684
- gone2 = _nullishCoalesce(_optionalChain([result, 'optionalAccess', _45 => _45.gone]), () => ( false));
628
+ gone2 = result?.gone ?? false;
685
629
  return result !== null;
686
630
  });
687
631
  controller.focus();
@@ -698,7 +642,7 @@ function AiBar({ env, ghost, gone, barId }) {
698
642
  setNext("");
699
643
  };
700
644
  const primary = { [PRIMARY]: "" };
701
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
645
+ return /* @__PURE__ */ jsxRuntime.jsxs(
702
646
  "div",
703
647
  {
704
648
  ref: content,
@@ -707,7 +651,7 @@ function AiBar({ env, ghost, gone, barId }) {
707
651
  "aria-label": labels.response,
708
652
  className: "quoin-ai-bar flex flex-wrap items-center gap-2 rounded-md border bg-popover p-2 text-popover-foreground shadow-md",
709
653
  onFocus: () => inside.current = true,
710
- onBlur: (event) => inside.current = _nullishCoalesce(_optionalChain([content, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.contains, 'call', _48 => _48(event.relatedTarget)]), () => ( false)),
654
+ onBlur: (event) => inside.current = content.current?.contains(event.relatedTarget) ?? false,
711
655
  onKeyDown: (event) => {
712
656
  if (event.key !== "Escape" || event.nativeEvent.isComposing) return;
713
657
  event.preventDefault();
@@ -715,23 +659,23 @@ function AiBar({ env, ghost, gone, barId }) {
715
659
  else onDiscard();
716
660
  },
717
661
  children: [
718
- phase === "streaming" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
719
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-muted-foreground", children: labels.writing }),
720
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCW3AFJBRcjs.Button, { ...primary, size: "sm", variant: "outline", onClick: () => stop(editor), children: labels.stop })
662
+ phase === "streaming" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
663
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: labels.writing }),
664
+ /* @__PURE__ */ jsxRuntime.jsx(chunk7XQGOCUG_cjs.Button, { ...primary, size: "sm", variant: "outline", onClick: () => stop(editor), children: labels.stop })
721
665
  ] }),
722
- phase === "error" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
723
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { role: "alert", className: "text-sm text-destructive", children: labels.failed }),
724
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCW3AFJBRcjs.Button, { ...primary, size: "sm", onClick: () => retry(editor, stream), children: labels.retry }),
725
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCW3AFJBRcjs.Button, { size: "sm", variant: "ghost", onClick: onDiscard, children: labels.discard })
666
+ phase === "error" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
667
+ /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: "text-sm text-destructive", children: labels.failed }),
668
+ /* @__PURE__ */ jsxRuntime.jsx(chunk7XQGOCUG_cjs.Button, { ...primary, size: "sm", onClick: () => retry(editor, stream), children: labels.retry }),
669
+ /* @__PURE__ */ jsxRuntime.jsx(chunk7XQGOCUG_cjs.Button, { size: "sm", variant: "ghost", onClick: onDiscard, children: labels.discard })
726
670
  ] }),
727
- (phase === "done" || phase === "stopped") && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
728
- phase === "stopped" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-muted-foreground", children: labels.stopped }),
729
- gone && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "w-full text-xs text-muted-foreground", children: labels.targetGone }),
730
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCW3AFJBRcjs.Button, { ...primary, size: "sm", onClick: onAccept, children: labels.accept }),
731
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCW3AFJBRcjs.Button, { size: "sm", variant: "ghost", onClick: onDiscard, children: labels.discard }),
732
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCW3AFJBRcjs.Button, { size: "sm", variant: "ghost", onClick: () => retry(editor, stream), children: labels.retry }),
733
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "form", { className: "w-full", onSubmit: onFollowUp, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
734
- _chunkCW3AFJBRcjs.Input,
671
+ (phase === "done" || phase === "stopped") && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
672
+ phase === "stopped" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: labels.stopped }),
673
+ gone && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "w-full text-xs text-muted-foreground", children: labels.targetGone }),
674
+ /* @__PURE__ */ jsxRuntime.jsx(chunk7XQGOCUG_cjs.Button, { ...primary, size: "sm", onClick: onAccept, children: labels.accept }),
675
+ /* @__PURE__ */ jsxRuntime.jsx(chunk7XQGOCUG_cjs.Button, { size: "sm", variant: "ghost", onClick: onDiscard, children: labels.discard }),
676
+ /* @__PURE__ */ jsxRuntime.jsx(chunk7XQGOCUG_cjs.Button, { size: "sm", variant: "ghost", onClick: () => retry(editor, stream), children: labels.retry }),
677
+ /* @__PURE__ */ jsxRuntime.jsx("form", { className: "w-full", onSubmit: onFollowUp, children: /* @__PURE__ */ jsxRuntime.jsx(
678
+ chunk7XQGOCUG_cjs.Input,
735
679
  {
736
680
  "aria-label": labels.followUp,
737
681
  placeholder: labels.followUp,
@@ -748,15 +692,12 @@ function AiBar({ env, ghost, gone, barId }) {
748
692
  );
749
693
  }
750
694
 
751
- // src/extensions/ai/AiGhost.tsx
752
-
753
-
754
695
  // src/extensions/ai/ai-ghost-render.ts
755
696
  var reader = null;
756
697
  function readerOf() {
757
698
  if (reader === null) {
758
- const schema = _chunk4SLJNZSMcjs.createSchema.call(void 0, );
759
- reader = { schema, codec: _chunk4SLJNZSMcjs.createBlockCodec.call(void 0, schema) };
699
+ const schema = chunkAIS37SL2_cjs.createSchema();
700
+ reader = { schema, codec: chunkAIS37SL2_cjs.createBlockCodec(schema) };
760
701
  }
761
702
  return reader;
762
703
  }
@@ -764,25 +705,22 @@ function fillGhost(ghost, markdown) {
764
705
  const doc = ghost.ownerDocument;
765
706
  const { schema, codec } = readerOf();
766
707
  const drawn2 = [];
767
- for (const block of _chunk4SLJNZSMcjs.fromMarkdown.call(void 0, markdown)) {
708
+ for (const block of chunkAIS37SL2_cjs.fromMarkdown(markdown)) {
768
709
  for (const piece of codec.toEngineBlocks(block)) {
769
710
  const element = doc.createElement("div");
770
711
  element.className = "quoin-ai-ghost-block";
771
- element.dataset.kind = String(_nullishCoalesce(piece.attrs.kind, () => ( piece.type.toLowerCase())));
712
+ element.dataset.kind = String(piece.attrs.kind ?? piece.type.toLowerCase());
772
713
  if (piece.attrs.level !== void 0) element.dataset.level = String(piece.attrs.level);
773
714
  if (piece.indent > 0) element.style.setProperty("--quoin-ai-indent", String(piece.indent));
774
- const region = _chunkZKVOS57Qcjs.primaryRegion.call(void 0, schema, piece);
775
- if (region === null) element.textContent = _chunkZKVOS57Qcjs.toPlainText.call(void 0, [codec.toQuoin(piece)], { schema });
776
- else _chunkP6KYXFZCcjs.renderInline.call(void 0, element, piece.regions[region], []);
715
+ const region = chunkVFSVN5IQ_cjs.primaryRegion(schema, piece);
716
+ if (region === null) element.textContent = chunkVFSVN5IQ_cjs.toPlainText([codec.toQuoin(piece)], { schema });
717
+ else chunkIGZRZIAF_cjs.renderInline(element, piece.regions[region], []);
777
718
  drawn2.push(element);
778
719
  }
779
720
  }
780
721
  ghost.replaceChildren(...drawn2);
781
722
  }
782
723
 
783
- // src/extensions/ai/use-ghost-place.ts
784
-
785
-
786
724
  // src/extensions/ai/keep-reader-still.ts
787
725
  function scrollerOf(root) {
788
726
  for (let element = root; element !== null; element = element.parentElement) {
@@ -790,7 +728,7 @@ function scrollerOf(root) {
790
728
  return element;
791
729
  }
792
730
  }
793
- return _nullishCoalesce(root.ownerDocument.scrollingElement, () => ( null));
731
+ return root.ownerDocument.scrollingElement ?? null;
794
732
  }
795
733
  function keepReaderStill(root, shell, change) {
796
734
  const scroller = scrollerOf(root);
@@ -808,7 +746,7 @@ function keepReaderStill(root, shell, change) {
808
746
  // src/extensions/ai/space-below.ts
809
747
  function rowGap(shell) {
810
748
  const parent = shell.parentElement;
811
- if (parent === null || !_optionalChain([shell, 'access', _49 => _49.nextElementSibling, 'optionalAccess', _50 => _50.hasAttribute, 'call', _51 => _51("data-block-id")])) return 0;
749
+ if (parent === null || !shell.nextElementSibling?.hasAttribute("data-block-id")) return 0;
812
750
  const { display, flexDirection, rowGap: gap } = getComputedStyle(parent);
813
751
  const column = display.includes("grid") || display.includes("flex") && flexDirection.startsWith("column");
814
752
  return column ? parseFloat(gap) || 0 : 0;
@@ -830,7 +768,7 @@ function place(controller, root, layer, block, region) {
830
768
  return;
831
769
  }
832
770
  layer.style.visibility = "";
833
- const host = _nullishCoalesce(controller.registry.get(block, region), () => ( shell));
771
+ const host = controller.registry.get(block, region) ?? shell;
834
772
  const origin = root.getBoundingClientRect();
835
773
  const scale = origin.width / root.offsetWidth || 1;
836
774
  const below = shell.getBoundingClientRect();
@@ -840,7 +778,7 @@ function place(controller, root, layer, block, region) {
840
778
  const top = (below.bottom - origin.top) / scale - padding - root.clientTop + root.scrollTop + GAP;
841
779
  layer.style.transform = `translate(${left}px, ${top}px)`;
842
780
  layer.style.width = `${text.width / scale}px`;
843
- clipAside(layer, text, _chunkLE5XMIFJcjs.clipBoxes.call(void 0, host, root), scale);
781
+ clipAside(layer, text, chunkLE5XMIFJ_cjs.clipBoxes(host, root), scale);
844
782
  const room = Math.max(0, layer.offsetHeight + 2 * GAP - padding - gap);
845
783
  keepReaderStill(root, shell, () => root.style.setProperty(ROOM2, `${room}px`));
846
784
  }
@@ -851,12 +789,12 @@ function clipAside(layer, text, areas, scale) {
851
789
  if (start + end >= text.width / scale && text.width > 0) layer.style.visibility = "hidden";
852
790
  }
853
791
  function useGhostPlace(controller, layer, block, region) {
854
- const placeNow = _react.useRef.call(void 0, () => {
792
+ const placeNow = react.useRef(() => {
855
793
  });
856
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
794
+ chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
857
795
  const root = controller.root;
858
796
  const element = layer.current;
859
- const view = _optionalChain([root, 'optionalAccess', _52 => _52.ownerDocument, 'access', _53 => _53.defaultView]);
797
+ const view = root?.ownerDocument.defaultView;
860
798
  if (!root || !element || !view) return void 0;
861
799
  const update = () => place(controller, root, element, block, region);
862
800
  let frame = 0;
@@ -874,7 +812,7 @@ function useGhostPlace(controller, layer, block, region) {
874
812
  const unsubscribe = controller.editor.subscribe(later);
875
813
  const fonts = root.ownerDocument.fonts;
876
814
  root.addEventListener("scroll", later, { capture: true, passive: true });
877
- _optionalChain([fonts, 'optionalAccess', _54 => _54.addEventListener, 'call', _55 => _55("loadingdone", later)]);
815
+ fonts?.addEventListener("loadingdone", later);
878
816
  return () => {
879
817
  placeNow.current = () => {
880
818
  };
@@ -882,58 +820,46 @@ function useGhostPlace(controller, layer, block, region) {
882
820
  observer.disconnect();
883
821
  unsubscribe();
884
822
  root.removeEventListener("scroll", later, { capture: true });
885
- _optionalChain([fonts, 'optionalAccess', _56 => _56.removeEventListener, 'call', _57 => _57("loadingdone", later)]);
823
+ fonts?.removeEventListener("loadingdone", later);
886
824
  root.style.removeProperty(ROOM2);
887
825
  };
888
826
  }, [controller, layer, block, region]);
889
- return _react.useCallback.call(void 0, () => placeNow.current(), []);
827
+ return react.useCallback(() => placeNow.current(), []);
890
828
  }
891
-
892
- // src/extensions/ai/AiGhost.tsx
893
-
894
829
  function AiGhost({ env, ghost, target, gone, barId }) {
895
- const layer = _react.useRef.call(void 0, null);
896
- const drawn2 = _react.useRef.call(void 0, null);
830
+ const layer = react.useRef(null);
831
+ const drawn2 = react.useRef(null);
897
832
  const place2 = useGhostPlace(env.controller, layer, target.to.block, target.to.region);
898
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
833
+ chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
899
834
  const element = drawn2.current;
900
835
  if (element === null) return;
901
836
  element.setAttribute("inert", "");
902
837
  fillGhost(element, ghost.shown);
903
838
  place2();
904
839
  }, [ghost.shown, ghost.phase, gone, place2]);
905
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref: layer, className: "quoin-ai-layer", children: [
906
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref: drawn2, className: "quoin-ai-ghost", "aria-hidden": "true", "data-phase": ghost.phase }),
907
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AiBar, { env, ghost, gone, barId })
840
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: layer, className: "quoin-ai-layer", children: [
841
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: drawn2, className: "quoin-ai-ghost", "aria-hidden": "true", "data-phase": ghost.phase }),
842
+ /* @__PURE__ */ jsxRuntime.jsx(AiBar, { env, ghost, gone, barId })
908
843
  ] });
909
844
  }
910
-
911
- // src/extensions/ai/AiMenu.tsx
912
-
913
-
914
- // src/extensions/ai/use-target-anchor.ts
915
-
916
845
  function useTargetAnchor(controller, target) {
917
- const latest = _react.useRef.call(void 0, target);
918
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
846
+ const latest = react.useRef(target);
847
+ chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
919
848
  latest.current = target;
920
849
  });
921
- return _react.useMemo.call(void 0, () => {
850
+ return react.useMemo(() => {
922
851
  const end = () => {
923
852
  const { to } = latest.current;
924
853
  return { block: to.block, region: to.region, from: to.offset, to: to.offset };
925
854
  };
926
855
  return {
927
- current: _chunkCW3AFJBRcjs.virtualAnchor.call(void 0,
928
- () => _chunkCW3AFJBRcjs.rangeRect.call(void 0, controller, end()),
856
+ current: chunk7XQGOCUG_cjs.virtualAnchor(
857
+ () => chunk7XQGOCUG_cjs.rangeRect(controller, end()),
929
858
  () => controller.registry.get(end().block, end().region)
930
859
  )
931
860
  };
932
861
  }, [controller]);
933
862
  }
934
-
935
- // src/extensions/ai/AiMenu.tsx
936
-
937
863
  function choicesFor(env, target, query) {
938
864
  const { labels } = env;
939
865
  const emptyLine = !target.selected && target.to.offset === 0;
@@ -946,12 +872,12 @@ function choicesFor(env, target, query) {
946
872
  }
947
873
  function AiMenu({ env, target, fromSpace }) {
948
874
  const { controller, labels } = env;
949
- const [query, setQuery] = _react.useState.call(void 0, "");
950
- const [asking, setAsking] = _react.useState.call(void 0, null);
951
- const [active, setActive] = _react.useState.call(void 0, 0);
952
- const field = _react.useRef.call(void 0, null);
875
+ const [query, setQuery] = react.useState("");
876
+ const [asking, setAsking] = react.useState(null);
877
+ const [active, setActive] = react.useState(0);
878
+ const field = react.useRef(null);
953
879
  const anchor = useTargetAnchor(controller, target);
954
- const id = _react.useId.call(void 0, );
880
+ const id = react.useId();
955
881
  const choices = asking === null ? choicesFor(env, target, query) : [];
956
882
  const current = Math.min(active, choices.length - 1);
957
883
  const optionId = (index) => `${id}-${index}`;
@@ -981,8 +907,8 @@ function AiMenu({ env, target, fromSpace }) {
981
907
  }
982
908
  };
983
909
  const fieldLabel = asking === "tone" ? labels.tonePrompt : asking === "translate" ? labels.translatePrompt : labels.prompt;
984
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
985
- _chunkCW3AFJBRcjs.Popover,
910
+ return /* @__PURE__ */ jsxRuntime.jsxs(
911
+ chunk7XQGOCUG_cjs.Popover,
986
912
  {
987
913
  open: true,
988
914
  modal: false,
@@ -990,9 +916,9 @@ function AiMenu({ env, target, fromSpace }) {
990
916
  if (!next) closeMenu(controller.editor);
991
917
  },
992
918
  children: [
993
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCW3AFJBRcjs.PopoverAnchor, { virtualRef: anchor }),
994
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
995
- _chunkCW3AFJBRcjs.PopoverContent,
919
+ /* @__PURE__ */ jsxRuntime.jsx(chunk7XQGOCUG_cjs.PopoverAnchor, { virtualRef: anchor }),
920
+ /* @__PURE__ */ jsxRuntime.jsxs(
921
+ chunk7XQGOCUG_cjs.PopoverContent,
996
922
  {
997
923
  "aria-label": labels.askAi,
998
924
  side: "bottom",
@@ -1000,7 +926,7 @@ function AiMenu({ env, target, fromSpace }) {
1000
926
  className: "w-80 p-1",
1001
927
  onOpenAutoFocus: (event) => {
1002
928
  event.preventDefault();
1003
- _optionalChain([field, 'access', _58 => _58.current, 'optionalAccess', _59 => _59.focus, 'call', _60 => _60()]);
929
+ field.current?.focus();
1004
930
  },
1005
931
  onCloseAutoFocus: (event) => event.preventDefault(),
1006
932
  onEscapeKeyDown: (event) => {
@@ -1008,8 +934,8 @@ function AiMenu({ env, target, fromSpace }) {
1008
934
  close(fromSpace);
1009
935
  },
1010
936
  children: [
1011
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1012
- _chunkCW3AFJBRcjs.Input,
937
+ /* @__PURE__ */ jsxRuntime.jsx(
938
+ chunk7XQGOCUG_cjs.Input,
1013
939
  {
1014
940
  ref: field,
1015
941
  role: "combobox",
@@ -1027,13 +953,13 @@ function AiMenu({ env, target, fromSpace }) {
1027
953
  onKeyDown
1028
954
  }
1029
955
  ),
1030
- choices.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { id: `${id}-list`, role: "listbox", "aria-label": labels.menu, className: "mt-1 max-h-72 overflow-y-auto", children: choices.map((choice, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
956
+ choices.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ul", { id: `${id}-list`, role: "listbox", "aria-label": labels.menu, className: "mt-1 max-h-72 overflow-y-auto", children: choices.map((choice, index) => /* @__PURE__ */ jsxRuntime.jsx(
1031
957
  "li",
1032
958
  {
1033
959
  id: optionId(index),
1034
960
  role: "option",
1035
961
  "aria-selected": index === current,
1036
- className: _chunkCW3AFJBRcjs.cn.call(void 0, _chunkCW3AFJBRcjs.MENU_ITEM, index === current && "bg-accent text-accent-foreground"),
962
+ className: chunk7XQGOCUG_cjs.cn(chunk7XQGOCUG_cjs.MENU_ITEM, index === current && "bg-accent text-accent-foreground"),
1037
963
  onMouseDown: (event) => event.preventDefault(),
1038
964
  onClick: () => choose(choice),
1039
965
  children: choice.label
@@ -1047,43 +973,40 @@ function AiMenu({ env, target, fromSpace }) {
1047
973
  }
1048
974
  );
1049
975
  }
1050
-
1051
- // src/extensions/ai/AiOverlay.tsx
1052
-
1053
976
  var goneOf = (state) => {
1054
977
  const { target, ghost } = aiState(state);
1055
978
  return target !== null && ghost !== null && targetGone(state.doc, target);
1056
979
  };
1057
- var plainText = (markdown) => _chunkZKVOS57Qcjs.toPlainText.call(void 0, _chunk4SLJNZSMcjs.fromMarkdown.call(void 0, markdown));
980
+ var plainText = (markdown) => chunkVFSVN5IQ_cjs.toPlainText(chunkAIS37SL2_cjs.fromMarkdown(markdown));
1058
981
  function AiOverlay({ controller, stream, labels }) {
1059
- const { onError } = _chunkCW3AFJBRcjs.useQuoin.call(void 0, );
982
+ const { onError } = chunk7XQGOCUG_cjs.useQuoin();
1060
983
  const link = linkOf(controller.editor);
1061
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
984
+ chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
1062
985
  link.report = onError;
1063
986
  link.ended = (phase, output) => controller.announce((phase === "done" ? labels.written : labels.halted)(plainText(output)));
1064
987
  }, [link, onError, controller, labels]);
1065
- const value = _chunkP6KYXFZCcjs.useEditorState.call(void 0, controller, aiState);
1066
- const gone = _chunkP6KYXFZCcjs.useEditorState.call(void 0, controller, goneOf);
1067
- const readOnly = _chunkP6KYXFZCcjs.useReadOnly.call(void 0, controller);
1068
- const env = _react.useMemo.call(void 0, () => ({ controller, stream, labels }), [controller, stream, labels]);
1069
- const barId = _react.useId.call(void 0, );
988
+ const value = chunkIGZRZIAF_cjs.useEditorState(controller, aiState);
989
+ const gone = chunkIGZRZIAF_cjs.useEditorState(controller, goneOf);
990
+ const readOnly = chunkIGZRZIAF_cjs.useReadOnly(controller);
991
+ const env = react.useMemo(() => ({ controller, stream, labels }), [controller, stream, labels]);
992
+ const barId = react.useId();
1070
993
  const showing = value.ghost !== null;
1071
- _react.useEffect.call(void 0, () => {
994
+ react.useEffect(() => {
1072
995
  if (!showing) return;
1073
996
  const toBar = (event) => {
1074
997
  if (event.key !== "Escape" || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return false;
1075
- const bar = _optionalChain([controller, 'access', _61 => _61.root, 'optionalAccess', _62 => _62.ownerDocument, 'access', _63 => _63.getElementById, 'call', _64 => _64(barId)]);
1076
- _optionalChain([bar, 'optionalAccess', _65 => _65.querySelector, 'call', _66 => _66(`[${PRIMARY}]`), 'optionalAccess', _67 => _67.focus, 'call', _68 => _68()]);
998
+ const bar = controller.root?.ownerDocument.getElementById(barId);
999
+ bar?.querySelector(`[${PRIMARY}]`)?.focus();
1077
1000
  return bar != null;
1078
1001
  };
1079
1002
  controller.keyInterceptors.add(toBar);
1080
1003
  return () => void controller.keyInterceptors.delete(toBar);
1081
1004
  }, [controller, showing, barId]);
1082
- _react.useEffect.call(void 0, () => {
1005
+ react.useEffect(() => {
1083
1006
  const root = controller.root;
1084
1007
  if (!root) return;
1085
1008
  let away = true;
1086
- return _chunk73653CJ4cjs.watchCanvasFocus.call(void 0, controller, root.ownerDocument, (inside, node) => {
1009
+ return chunkEFRQMYZ6_cjs.watchCanvasFocus(controller, root.ownerDocument, (inside, node) => {
1087
1010
  if (!inside) away = true;
1088
1011
  else if (root.contains(node)) {
1089
1012
  if (away) noteFocus(controller.editor);
@@ -1091,7 +1014,7 @@ function AiOverlay({ controller, stream, labels }) {
1091
1014
  }
1092
1015
  });
1093
1016
  }, [controller]);
1094
- _react.useEffect.call(void 0,
1017
+ react.useEffect(
1095
1018
  () => controller.subscribeReadOnly(() => {
1096
1019
  if (!controller.readOnly) return;
1097
1020
  endRun(link);
@@ -1102,19 +1025,16 @@ function AiOverlay({ controller, stream, labels }) {
1102
1025
  [controller, link]
1103
1026
  );
1104
1027
  if (readOnly || value.target === null) return null;
1105
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1106
- value.menu !== null && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AiMenu, { env, target: value.target, fromSpace: value.menu.fromSpace }),
1107
- value.ghost !== null && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AiGhost, { env, ghost: value.ghost, target: value.target, gone, barId })
1028
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1029
+ value.menu !== null && /* @__PURE__ */ jsxRuntime.jsx(AiMenu, { env, target: value.target, fromSpace: value.menu.fromSpace }),
1030
+ value.ghost !== null && /* @__PURE__ */ jsxRuntime.jsx(AiGhost, { env, ghost: value.ghost, target: value.target, gone, barId })
1108
1031
  ] });
1109
1032
  }
1110
-
1111
- // src/extensions/ai/ai-extension.tsx
1112
-
1113
1033
  function aiExtension(options) {
1114
1034
  const { stream } = options;
1115
1035
  const labels = resolveAiLabels(options.labels);
1116
1036
  function Overlay({ controller }) {
1117
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AiOverlay, { controller, stream, labels });
1037
+ return /* @__PURE__ */ jsxRuntime.jsx(AiOverlay, { controller, stream, labels });
1118
1038
  }
1119
1039
  const ui = {
1120
1040
  slashItems: aiSlashItems(labels, stream),
@@ -1122,7 +1042,7 @@ function aiExtension(options) {
1122
1042
  blockMenuItems: [aiBlockMenuItem(labels)],
1123
1043
  overlays: [Overlay]
1124
1044
  };
1125
- return _chunkZKVOS57Qcjs.defineExtension.call(void 0, {
1045
+ return chunkVFSVN5IQ_cjs.defineExtension({
1126
1046
  name: "ai",
1127
1047
  plugins: [aiPlugin],
1128
1048
  decorations: aiDecorations,
@@ -1133,7 +1053,7 @@ function aiExtension(options) {
1133
1053
  if (link.mounts++ === 0) link.stopWatching = watchGhost(editor, link);
1134
1054
  return () => {
1135
1055
  if (--link.mounts > 0) return;
1136
- _optionalChain([link, 'access', _69 => _69.stopWatching, 'optionalCall', _70 => _70()]);
1056
+ link.stopWatching?.();
1137
1057
  link.stopWatching = null;
1138
1058
  endRun(link);
1139
1059
  };
@@ -1142,7 +1062,7 @@ function aiExtension(options) {
1142
1062
  });
1143
1063
  }
1144
1064
 
1145
-
1146
-
1147
- exports.aiExtension = aiExtension; exports.englishAiLabels = englishAiLabels;
1065
+ exports.aiExtension = aiExtension;
1066
+ exports.englishAiLabels = englishAiLabels;
1067
+ //# sourceMappingURL=ai.cjs.map
1148
1068
  //# sourceMappingURL=ai.cjs.map