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/comments.cjs CHANGED
@@ -1,64 +1,50 @@
1
- 'use client';"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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 _chunkXA3UEJIWcjs = require('./chunk-XA3UEJIW.cjs');
5
-
6
-
7
- var _chunk73653CJ4cjs = require('./chunk-73653CJ4.cjs');
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
- var _chunkCW3AFJBRcjs = require('./chunk-CW3AFJBR.cjs');
20
-
21
-
22
-
23
-
24
- var _chunkP6KYXFZCcjs = require('./chunk-P6KYXFZC.cjs');
25
- require('./chunk-EH5KXQXY.cjs');
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
- var _chunkZKVOS57Qcjs = require('./chunk-ZKVOS57Q.cjs');
39
- require('./chunk-6V6GGBDK.cjs');
40
-
41
-
42
-
43
-
44
-
45
-
46
- var _chunk4SLJNZSMcjs = require('./chunk-4SLJNZSM.cjs');
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ var chunkRIIXJWBR_cjs = require('./chunk-RIIXJWBR.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');
15
+ var DialogPrimitive = require('@radix-ui/react-dialog');
16
+
17
+ function _interopNamespace(e) {
18
+ if (e && e.__esModule) return e;
19
+ var n = Object.create(null);
20
+ if (e) {
21
+ Object.keys(e).forEach(function (k) {
22
+ if (k !== 'default') {
23
+ var d = Object.getOwnPropertyDescriptor(e, k);
24
+ Object.defineProperty(n, k, d.get ? d : {
25
+ enumerable: true,
26
+ get: function () { return e[k]; }
27
+ });
28
+ }
29
+ });
30
+ }
31
+ n.default = e;
32
+ return Object.freeze(n);
33
+ }
47
34
 
48
- // src/extensions/comments/comments-extension.tsx
49
- var _lucidereact = require('lucide-react');
35
+ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
50
36
 
51
37
  // src/extensions/comments/comment-anchors.ts
52
- var idsOf = (node) => _nullishCoalesce(_optionalChain([node, 'optionalAccess', _2 => _2.marks, 'access', _3 => _3.flatMap, 'call', _4 => _4((mark) => mark.type === "comment" && _optionalChain([mark, 'access', _5 => _5.attrs, 'optionalAccess', _6 => _6.id]) ? [mark.attrs.id] : [])]), () => ( []));
38
+ var idsOf = (node) => node?.marks.flatMap((mark) => mark.type === "comment" && mark.attrs?.id ? [mark.attrs.id] : []) ?? [];
53
39
  function addRegion(anchors, block, region, inline2) {
54
40
  let position = 0;
55
41
  for (const node of inline2) {
56
42
  const from = position;
57
- position += _chunk4SLJNZSMcjs.nodeLength.call(void 0, node);
43
+ position += chunkAIS37SL2_cjs.nodeLength(node);
58
44
  for (const id of idsOf(node)) {
59
- const ranges = _nullishCoalesce(anchors.get(id), () => ( []));
45
+ const ranges = anchors.get(id) ?? [];
60
46
  const last = ranges[ranges.length - 1];
61
- const continues = _optionalChain([last, 'optionalAccess', _7 => _7.block]) === block && last.region === region && last.to === from;
47
+ const continues = last?.block === block && last.region === region && last.to === from;
62
48
  if (continues) ranges[ranges.length - 1] = { ...last, to: position };
63
49
  else ranges.push({ block, region, from, to: position });
64
50
  anchors.set(id, ranges);
@@ -78,28 +64,28 @@ function commentAnchors(doc) {
78
64
  }
79
65
  return anchors;
80
66
  }
81
- var atomLabel = (node) => node.kind === "atom" ? _nullishCoalesce(node.attrs.label, () => ( "")) : "";
67
+ var atomLabel = (node) => node.kind === "atom" ? node.attrs.label ?? "" : "";
82
68
  function anchorText(doc, ranges) {
83
69
  return ranges.map(({ block, region, from, to }) => {
84
- const inline2 = _nullishCoalesce(_optionalChain([_chunk4SLJNZSMcjs.blockById.call(void 0, doc, block), 'optionalAccess', _8 => _8.regions, 'access', _9 => _9[region]]), () => ( []));
85
- return _chunk4SLJNZSMcjs.inlineText.call(void 0, _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline2, from, to), atomLabel);
70
+ const inline2 = chunkAIS37SL2_cjs.blockById(doc, block)?.regions[region] ?? [];
71
+ return chunkAIS37SL2_cjs.inlineText(chunkAIS37SL2_cjs.sliceInline(inline2, from, to), atomLabel);
86
72
  }).join(" ");
87
73
  }
88
74
  function commentIdsAt(doc, { block, region, offset }) {
89
- const inline2 = _nullishCoalesce(_optionalChain([_chunk4SLJNZSMcjs.blockById.call(void 0, doc, block), 'optionalAccess', _10 => _10.regions, 'access', _11 => _11[region]]), () => ( []));
75
+ const inline2 = chunkAIS37SL2_cjs.blockById(doc, block)?.regions[region] ?? [];
90
76
  const ids = /* @__PURE__ */ new Set();
91
77
  let position = 0;
92
78
  for (const node of inline2) {
93
- const end = position + _chunk4SLJNZSMcjs.nodeLength.call(void 0, node);
79
+ const end = position + chunkAIS37SL2_cjs.nodeLength(node);
94
80
  if (position <= offset && offset <= end && end > position) idsOf(node).forEach((id) => ids.add(id));
95
81
  position = end;
96
82
  }
97
83
  return [...ids].sort();
98
84
  }
99
85
  function threadRemoval(state, id) {
100
- const tr = new (0, _chunkZKVOS57Qcjs.Transaction)(state).setOrigin("command");
101
- for (const { block, region, from, to } of _nullishCoalesce(commentAnchors(state.doc).get(id), () => ( []))) {
102
- tr.step(_chunkZKVOS57Qcjs.removeMarkStep.call(void 0, block, region, from, to, { type: "comment", attrs: { id } }));
86
+ const tr = new chunkVFSVN5IQ_cjs.Transaction(state).setOrigin("command");
87
+ for (const { block, region, from, to } of commentAnchors(state.doc).get(id) ?? []) {
88
+ tr.step(chunkVFSVN5IQ_cjs.removeMarkStep(block, region, from, to, { type: "comment", attrs: { id } }));
103
89
  }
104
90
  return tr;
105
91
  }
@@ -110,14 +96,14 @@ function mapPendingRanges(tr, ranges, state) {
110
96
  const from = tr.mapPos({ block: range.block, region: range.region, offset: range.from }, 1);
111
97
  const to = tr.mapPos({ block: range.block, region: range.region, offset: range.to }, -1);
112
98
  const { index } = state.doc;
113
- if (!index.has(from.block) || !index.has(to.block) || _chunkZKVOS57Qcjs.comparePos.call(void 0, state.doc, from, to) >= 0) return [];
114
- return _chunkZKVOS57Qcjs.markRanges.call(void 0, { ...state, selection: _chunkZKVOS57Qcjs.textSelection.call(void 0, from, to) });
99
+ if (!index.has(from.block) || !index.has(to.block) || chunkVFSVN5IQ_cjs.comparePos(state.doc, from, to) >= 0) return [];
100
+ return chunkVFSVN5IQ_cjs.markRanges({ ...state, selection: chunkVFSVN5IQ_cjs.textSelection(from, to) });
115
101
  });
116
102
  }
117
103
 
118
104
  // src/extensions/comments/comments-plugin.ts
119
- var isEnded = (ended, id, current) => ended.some((thread) => thread.id === id && _optionalChain([thread, 'access', _12 => _12.seen, 'optionalAccess', _13 => _13.resolved]) === _optionalChain([current, 'optionalAccess', _14 => _14.resolved]));
120
- var commentsKey = _chunkZKVOS57Qcjs.createPluginKey.call(void 0, "comments");
105
+ var isEnded = (ended, id, current) => ended.some((thread) => thread.id === id && thread.seen?.resolved === current?.resolved);
106
+ var commentsKey = chunkVFSVN5IQ_cjs.createPluginKey("comments");
121
107
  var COMMENTS = "comments";
122
108
  var IDLE = { pending: [], active: null, open: null, ended: [] };
123
109
  function act(value, action) {
@@ -127,7 +113,7 @@ function act(value, action) {
127
113
  case "settled": {
128
114
  const pending = value.pending.filter(({ key }) => key !== action.key);
129
115
  if (action.open === void 0) return { ...value, pending };
130
- return { ...value, pending, active: _nullishCoalesce(action.open.ids[0], () => ( null)), open: action.open };
116
+ return { ...value, pending, active: action.open.ids[0] ?? null, open: action.open };
131
117
  }
132
118
  case "activate":
133
119
  return value.active === action.id ? value : { ...value, active: action.id };
@@ -137,7 +123,7 @@ function act(value, action) {
137
123
  return value.open === null ? value : { ...value, active: null, open: null };
138
124
  case "forget": {
139
125
  const active = value.active === action.id ? null : value.active;
140
- const open = _optionalChain([value, 'access', _15 => _15.open, 'optionalAccess', _16 => _16.ids, 'access', _17 => _17.includes, 'call', _18 => _18(action.id)]) ? null : value.open;
126
+ const open = value.open?.ids.includes(action.id) ? null : value.open;
141
127
  const ended = [...value.ended.filter(({ id }) => id !== action.id), { id: action.id, seen: action.seen }];
142
128
  return { ...value, active, open, ended };
143
129
  }
@@ -155,7 +141,7 @@ function afterMove(tr, value, state) {
155
141
  const { open } = value;
156
142
  if (open === null || open.focus || !tr.selectionSet || !WRITER_MOVES.includes(tr.origin)) return value;
157
143
  const { selection } = state;
158
- const here = _optionalChain([selection, 'optionalAccess', _19 => _19.kind]) === "text" ? commentIdsAt(state.doc, selection.head) : [];
144
+ const here = selection?.kind === "text" ? commentIdsAt(state.doc, selection.head) : [];
159
145
  return open.ids.some((id) => here.includes(id)) ? value : { ...value, active: null, open: null };
160
146
  }
161
147
  var commentsPlugin = {
@@ -170,26 +156,26 @@ var commentsPlugin = {
170
156
 
171
157
  // src/extensions/comments/comment-create.ts
172
158
  var nextKey = 0;
173
- var hasCommentableText = (state) => _optionalChain([state, 'access', _20 => _20.selection, 'optionalAccess', _21 => _21.kind]) === "text" && _chunkZKVOS57Qcjs.markRanges.call(void 0, state).length > 0;
159
+ var hasCommentableText = (state) => state.selection?.kind === "text" && chunkVFSVN5IQ_cjs.markRanges(state).length > 0;
174
160
  var requestComment = (state, dispatch) => {
175
161
  const { selection } = state;
176
- if (_optionalChain([selection, 'optionalAccess', _22 => _22.kind]) !== "text" || _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey).pending.length > 0) return false;
177
- const ranges = _chunkZKVOS57Qcjs.markRanges.call(void 0, state);
162
+ if (selection?.kind !== "text" || chunkVFSVN5IQ_cjs.getPluginState(state, commentsKey).pending.length > 0) return false;
163
+ const ranges = chunkVFSVN5IQ_cjs.markRanges(state);
178
164
  if (ranges.length === 0) return false;
179
165
  if (dispatch === void 0) return true;
180
166
  const pending = { key: ++nextKey, ranges, selection };
181
167
  const action = { type: "pending", pending };
182
- dispatch(new (0, _chunkZKVOS57Qcjs.Transaction)(state).setMeta(COMMENTS, action).setMeta("addToHistory", false));
168
+ dispatch(new chunkVFSVN5IQ_cjs.Transaction(state).setMeta(COMMENTS, action).setMeta("addToHistory", false));
183
169
  return true;
184
170
  };
185
171
  function settledTransaction(editor, key, id) {
186
- const pending = _chunkZKVOS57Qcjs.getPluginState.call(void 0, editor.state, commentsKey).pending.find((anchor) => anchor.key === key);
172
+ const pending = chunkVFSVN5IQ_cjs.getPluginState(editor.state, commentsKey).pending.find((anchor) => anchor.key === key);
187
173
  const tr = editor.createTransaction().setOrigin("command");
188
- const ranges = id === null ? [] : _nullishCoalesce(_optionalChain([pending, 'optionalAccess', _23 => _23.ranges]), () => ( []));
174
+ const ranges = id === null ? [] : pending?.ranges ?? [];
189
175
  for (const { block, region, from, to } of ranges) {
190
- tr.step(_chunkZKVOS57Qcjs.addMarkStep.call(void 0, block, region, from, to, { type: "comment", attrs: { id } }));
176
+ tr.step(chunkVFSVN5IQ_cjs.addMarkStep(block, region, from, to, { type: "comment", attrs: { id } }));
191
177
  }
192
- const untouched = pending !== void 0 && _chunkZKVOS57Qcjs.sameSelection.call(void 0, editor.state.selection, pending.selection);
178
+ const untouched = pending !== void 0 && chunkVFSVN5IQ_cjs.sameSelection(editor.state.selection, pending.selection);
193
179
  const open = id !== null && ranges.length > 0 && untouched ? { ids: [id], focus: true } : void 0;
194
180
  const action = { type: "settled", key, open };
195
181
  return tr.setMeta(COMMENTS, action);
@@ -200,7 +186,7 @@ function create(editor, pending, onCreate, link) {
200
186
  if (link.mounts === 0) return;
201
187
  const tr = settledTransaction(editor, pending.key, id);
202
188
  editor.dispatch(tr);
203
- if (id === null) link.report(_chunkCW3AFJBRcjs.toError.call(void 0, error));
189
+ if (id === null) link.report(chunk7XQGOCUG_cjs.toError(error));
204
190
  else if (!tr.docChanged) link.report(new Error(`Comment thread ${id} has no text: it was deleted meanwhile`));
205
191
  };
206
192
  new Promise((resolve) => resolve(onCreate(input))).then(
@@ -210,30 +196,30 @@ function create(editor, pending, onCreate, link) {
210
196
  }
211
197
  function watchCreates(editor, onCreate, link) {
212
198
  return editor.subscribe((_, tr) => {
213
- const action = _optionalChain([tr, 'optionalAccess', _24 => _24.getMeta, 'call', _25 => _25(COMMENTS)]);
214
- if (_optionalChain([action, 'optionalAccess', _26 => _26.type]) === "pending") create(editor, action.pending, onCreate, link);
199
+ const action = tr?.getMeta(COMMENTS);
200
+ if (action?.type === "pending") create(editor, action.pending, onCreate, link);
215
201
  });
216
202
  }
217
203
 
218
204
  // src/extensions/comments/comment-open.ts
219
205
  function openIds(state, threads, ids) {
220
- const { ended } = _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey);
206
+ const { ended } = chunkVFSVN5IQ_cjs.getPluginState(state, commentsKey);
221
207
  return ids.filter((id) => {
222
208
  const thread = threads.find(id);
223
- return _optionalChain([thread, 'optionalAccess', _27 => _27.resolved]) === false && !isEnded(ended, id, thread);
209
+ return thread?.resolved === false && !isEnded(ended, id, thread);
224
210
  });
225
211
  }
226
212
  function commentsTransaction(state, action) {
227
- return new (0, _chunkZKVOS57Qcjs.Transaction)(state).setMeta(COMMENTS, action).setMeta("addToHistory", false);
213
+ return new chunkVFSVN5IQ_cjs.Transaction(state).setMeta(COMMENTS, action).setMeta("addToHistory", false);
228
214
  }
229
215
  function commentCommand(threads) {
230
216
  return (state, dispatch) => {
231
217
  if (requestComment(state, dispatch)) return true;
232
218
  const { selection } = state;
233
- if (_optionalChain([selection, 'optionalAccess', _28 => _28.kind]) !== "text" || !_chunkZKVOS57Qcjs.isCollapsed.call(void 0, selection)) return false;
219
+ if (selection?.kind !== "text" || !chunkVFSVN5IQ_cjs.isCollapsed(selection)) return false;
234
220
  const ids = openIds(state, threads, commentIdsAt(state.doc, selection.head));
235
221
  if (ids.length === 0) return false;
236
- _optionalChain([dispatch, 'optionalCall', _29 => _29(commentsTransaction(state, { type: "open", open: { ids, focus: true } }))]);
222
+ dispatch?.(commentsTransaction(state, { type: "open", open: { ids, focus: true } }));
237
223
  return true;
238
224
  };
239
225
  }
@@ -261,7 +247,7 @@ var englishCommentsLabels = {
261
247
  postedAt: englishDate
262
248
  };
263
249
  function resolveCommentsLabels(overrides) {
264
- const given = Object.entries(_nullishCoalesce(overrides, () => ( {}))).filter(([, value]) => value !== void 0);
250
+ const given = Object.entries(overrides ?? {}).filter(([, value]) => value !== void 0);
265
251
  return given.length === 0 ? englishCommentsLabels : { ...englishCommentsLabels, ...Object.fromEntries(given) };
266
252
  }
267
253
 
@@ -276,17 +262,11 @@ function linkOf(editor) {
276
262
  return link;
277
263
  }
278
264
 
279
- // src/extensions/comments/CommentsOverlay.tsx
280
- var _react = require('react');
281
-
282
- // src/extensions/comments/CommentMarkers.tsx
283
-
284
-
285
265
  // src/extensions/comments/rail-layout.ts
286
266
  function stackTops(items, gap) {
287
267
  let next = 0;
288
268
  return items.map(({ top, height }) => {
289
- const placed = Math.max(_nullishCoalesce(top, () => ( next)), next);
269
+ const placed = Math.max(top ?? next, next);
290
270
  next = placed + height + gap;
291
271
  return placed;
292
272
  });
@@ -304,7 +284,7 @@ function place(controller, box, gap) {
304
284
  if (root === null) return;
305
285
  const items = Array.from(box.querySelectorAll("[data-rail-item]"));
306
286
  const tops = stackTops(
307
- items.map((item) => ({ top: topOf(controller, root, _nullishCoalesce(item.dataset.block, () => ( ""))), height: item.offsetHeight })),
287
+ items.map((item) => ({ top: topOf(controller, root, item.dataset.block ?? ""), height: item.offsetHeight })),
308
288
  gap
309
289
  );
310
290
  items.forEach((item, i) => item.style.transform = `translateY(${tops[i]}px)`);
@@ -312,9 +292,9 @@ function place(controller, box, gap) {
312
292
  root.style.setProperty(HEIGHT, `${bottom}px`);
313
293
  }
314
294
  function useBlockAligned(controller, box, gap, key) {
315
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
295
+ chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
316
296
  const element = box.current;
317
- const view = _optionalChain([element, 'optionalAccess', _30 => _30.ownerDocument, 'access', _31 => _31.defaultView]);
297
+ const view = element?.ownerDocument.defaultView;
318
298
  if (!element || !view) return void 0;
319
299
  const update = () => place(controller, element, gap);
320
300
  update();
@@ -331,19 +311,16 @@ function useBlockAligned(controller, box, gap, key) {
331
311
  view.cancelAnimationFrame(frame);
332
312
  unsubscribe();
333
313
  observer.disconnect();
334
- _optionalChain([element, 'access', _32 => _32.parentElement, 'optionalAccess', _33 => _33.style, 'access', _34 => _34.removeProperty, 'call', _35 => _35(HEIGHT)]);
314
+ element.parentElement?.style.removeProperty(HEIGHT);
335
315
  };
336
316
  }, [controller, box, gap, key]);
337
317
  }
338
-
339
- // src/extensions/comments/CommentMarkers.tsx
340
- var _jsxruntime = require('react/jsx-runtime');
341
318
  var GAP = 4;
342
319
  function groupsOf(entries) {
343
320
  const groups = /* @__PURE__ */ new Map();
344
321
  for (const { thread, ranges } of entries) {
345
- const block = _nullishCoalesce(_optionalChain([ranges, 'access', _36 => _36[0], 'optionalAccess', _37 => _37.block]), () => ( ""));
346
- groups.set(block, [..._nullishCoalesce(groups.get(block), () => ( [])), thread.id]);
322
+ const block = ranges[0]?.block ?? "";
323
+ groups.set(block, [...groups.get(block) ?? [], thread.id]);
347
324
  }
348
325
  const removed = groups.get("");
349
326
  groups.delete("");
@@ -352,17 +329,17 @@ function groupsOf(entries) {
352
329
  function CommentMarkers({ env, box, entries, onOpen }) {
353
330
  const groups = groupsOf(entries);
354
331
  useBlockAligned(env.controller, box, GAP, groups.map(({ block, ids }) => `${block}:${ids}`).join(" "));
355
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref: box, className: "quoin-comments-markers", children: groups.map(({ block, ids }) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
332
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: box, className: "quoin-comments-markers", children: groups.map(({ block, ids }) => /* @__PURE__ */ jsxRuntime.jsxs(
356
333
  "button",
357
334
  {
358
335
  type: "button",
359
336
  "data-rail-item": "",
360
337
  "data-block": block,
361
338
  "aria-label": env.labels.showComments(ids.length),
362
- className: _chunkCW3AFJBRcjs.cn.call(void 0, "quoin-comments-marker", _chunkCW3AFJBRcjs.FOCUS_RING),
339
+ className: chunk7XQGOCUG_cjs.cn("quoin-comments-marker", chunk7XQGOCUG_cjs.FOCUS_RING),
363
340
  onClick: (event) => onOpen(ids[0], event.currentTarget),
364
341
  children: [
365
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.MessageSquare, { "aria-hidden": "true" }),
342
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { "aria-hidden": "true" }),
366
343
  ids.length
367
344
  ]
368
345
  },
@@ -370,41 +347,31 @@ function CommentMarkers({ env, box, entries, onOpen }) {
370
347
  )) });
371
348
  }
372
349
 
373
- // src/extensions/comments/ThreadCard.tsx
374
-
375
-
376
- // src/extensions/comments/ThreadView.tsx
377
-
378
-
379
350
  // src/extensions/comments/comment-actions.ts
380
351
  async function called(link, call) {
381
352
  try {
382
353
  await call();
383
354
  return true;
384
355
  } catch (error) {
385
- link.report(_chunkCW3AFJBRcjs.toError.call(void 0, error));
356
+ link.report(chunk7XQGOCUG_cjs.toError(error));
386
357
  return false;
387
358
  }
388
359
  }
389
360
  async function endThread(editor, link, call, id, threads) {
390
361
  if (!await called(link, () => call(id)) || link.mounts === 0) return false;
391
- const action = { type: "forget", id, seen: _optionalChain([threads, 'optionalAccess', _38 => _38.find, 'call', _39 => _39(id)]) };
362
+ const action = { type: "forget", id, seen: threads?.find(id) };
392
363
  editor.dispatch(threadRemoval(editor.state, id).setMeta(COMMENTS, action));
393
364
  return true;
394
365
  }
395
366
  function sendReply(link, call, id, body) {
396
367
  return called(link, () => call(id, body));
397
368
  }
398
-
399
- // src/extensions/comments/CommentAvatar.tsx
400
-
401
-
402
- var initials = (name) => name.trim().split(/\s+/).slice(0, 2).map((word) => _nullishCoalesce(_optionalChain([Array, 'access', _40 => _40.from, 'call', _41 => _41(word), 'access', _42 => _42[0], 'optionalAccess', _43 => _43.toUpperCase, 'call', _44 => _44()]), () => ( ""))).join("");
369
+ var initials = (name) => name.trim().split(/\s+/).slice(0, 2).map((word) => Array.from(word)[0]?.toUpperCase() ?? "").join("");
403
370
  function CommentAvatar({ author }) {
404
- const picture = _chunkXA3UEJIWcjs.webAddress.call(void 0, author.avatarUrl);
405
- const [failed, setFailed] = _react.useState.call(void 0, null);
371
+ const picture = chunkRIIXJWBR_cjs.webAddress(author.avatarUrl);
372
+ const [failed, setFailed] = react.useState(null);
406
373
  if (picture !== null && picture !== failed) {
407
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
374
+ return /* @__PURE__ */ jsxRuntime.jsx(
408
375
  "img",
409
376
  {
410
377
  src: picture,
@@ -417,35 +384,27 @@ function CommentAvatar({ author }) {
417
384
  }
418
385
  );
419
386
  }
420
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "aria-hidden": "true", className: "quoin-comments-initials", children: initials(author.name) });
387
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "quoin-comments-initials", children: initials(author.name) });
421
388
  }
422
-
423
- // src/extensions/comments/CommentItem.tsx
424
-
425
389
  function CommentItem({ comment, labels }) {
426
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { className: "flex gap-2", children: [
427
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CommentAvatar, { author: comment.author }),
428
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "min-w-0 flex-1", children: [
429
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "flex flex-wrap items-baseline gap-x-2 text-sm", children: [
430
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-medium", children: comment.author.name }),
431
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "time", { dateTime: comment.createdAt, className: "text-xs text-muted-foreground", children: labels.postedAt(comment.createdAt) })
390
+ return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex gap-2", children: [
391
+ /* @__PURE__ */ jsxRuntime.jsx(CommentAvatar, { author: comment.author }),
392
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
393
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "flex flex-wrap items-baseline gap-x-2 text-sm", children: [
394
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: comment.author.name }),
395
+ /* @__PURE__ */ jsxRuntime.jsx("time", { dateTime: comment.createdAt, className: "text-xs text-muted-foreground", children: labels.postedAt(comment.createdAt) })
432
396
  ] }),
433
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "quoin-comments-body text-sm", children: comment.body })
397
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "quoin-comments-body text-sm", children: comment.body })
434
398
  ] })
435
399
  ] });
436
400
  }
437
-
438
- // src/extensions/comments/ReplyBox.tsx
439
-
440
-
441
-
442
401
  var REPLY_FIELD = "data-comments-field";
443
402
  function ReplyBox({ env, threadId, first }) {
444
403
  const { controller, host, labels, link } = env;
445
- const [body, setBody] = _react.useState.call(void 0, "");
446
- const [sending, setSending] = _react.useState.call(void 0, false);
447
- const alive = _react.useRef.call(void 0, true);
448
- _react.useEffect.call(void 0, () => {
404
+ const [body, setBody] = react.useState("");
405
+ const [sending, setSending] = react.useState(false);
406
+ const alive = react.useRef(true);
407
+ react.useEffect(() => {
449
408
  alive.current = true;
450
409
  return () => {
451
410
  alive.current = false;
@@ -471,9 +430,9 @@ function ReplyBox({ env, threadId, first }) {
471
430
  event.preventDefault();
472
431
  void send();
473
432
  };
474
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { className: "flex items-start gap-2", onSubmit, children: [
475
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CommentAvatar, { author: host.currentUser }),
476
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
433
+ return /* @__PURE__ */ jsxRuntime.jsxs("form", { className: "flex items-start gap-2", onSubmit, children: [
434
+ /* @__PURE__ */ jsxRuntime.jsx(CommentAvatar, { author: host.currentUser }),
435
+ /* @__PURE__ */ jsxRuntime.jsx(
477
436
  "textarea",
478
437
  {
479
438
  ...{ [REPLY_FIELD]: "" },
@@ -486,50 +445,47 @@ function ReplyBox({ env, threadId, first }) {
486
445
  className: "quoin-comments-field"
487
446
  }
488
447
  ),
489
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
490
- _chunkCW3AFJBRcjs.Button,
448
+ /* @__PURE__ */ jsxRuntime.jsx(
449
+ chunk7XQGOCUG_cjs.Button,
491
450
  {
492
451
  type: "submit",
493
452
  variant: "ghost",
494
453
  size: "icon-sm",
495
454
  "aria-label": labels.send,
496
455
  "aria-disabled": text === "" || sending || void 0,
497
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.SendHorizontal, {})
456
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SendHorizontal, {})
498
457
  }
499
458
  )
500
459
  ] });
501
460
  }
502
-
503
- // src/extensions/comments/ThreadView.tsx
504
-
505
461
  function ThreadView({ env, id, thread, onEnded }) {
506
462
  const { controller, host, labels, link } = env;
507
- const readOnly = _chunkP6KYXFZCcjs.useReadOnly.call(void 0, controller);
508
- const [busy, setBusy] = _react.useState.call(void 0, false);
509
- const alive = _react.useRef.call(void 0, true);
510
- const root = _react.useRef.call(void 0, null);
511
- _react.useEffect.call(void 0, () => {
463
+ const readOnly = chunkIGZRZIAF_cjs.useReadOnly(controller);
464
+ const [busy, setBusy] = react.useState(false);
465
+ const alive = react.useRef(true);
466
+ const root = react.useRef(null);
467
+ react.useEffect(() => {
512
468
  alive.current = true;
513
469
  return () => {
514
470
  alive.current = false;
515
471
  };
516
472
  }, []);
517
- const comments = _nullishCoalesce(_optionalChain([thread, 'optionalAccess', _45 => _45.comments]), () => ( []));
473
+ const comments = thread?.comments ?? [];
518
474
  const end = async (call) => {
519
475
  if (busy) return;
520
476
  setBusy(true);
521
477
  const ended = await endThread(controller.editor, link, call, id, host.threads);
522
478
  if (alive.current) setBusy(false);
523
479
  const active = document.activeElement;
524
- const stayed = active === null || active === document.body || _optionalChain([root, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.contains, 'call', _48 => _48(active)]) === true;
480
+ const stayed = active === null || active === document.body || root.current?.contains(active) === true;
525
481
  if (ended && stayed) onEnded();
526
482
  };
527
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref: root, className: "flex flex-col gap-3", children: [
528
- comments.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ol", { className: "flex flex-col gap-3", children: comments.map((comment) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CommentItem, { comment, labels }, comment.id)) }),
529
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ReplyBox, { env, threadId: id, first: comments.length === 0 }),
530
- !readOnly && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-1", children: [
531
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
532
- _chunkCW3AFJBRcjs.Button,
483
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: root, className: "flex flex-col gap-3", children: [
484
+ comments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "flex flex-col gap-3", children: comments.map((comment) => /* @__PURE__ */ jsxRuntime.jsx(CommentItem, { comment, labels }, comment.id)) }),
485
+ /* @__PURE__ */ jsxRuntime.jsx(ReplyBox, { env, threadId: id, first: comments.length === 0 }),
486
+ !readOnly && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-1", children: [
487
+ /* @__PURE__ */ jsxRuntime.jsx(
488
+ chunk7XQGOCUG_cjs.Button,
533
489
  {
534
490
  type: "button",
535
491
  variant: "ghost",
@@ -539,8 +495,8 @@ function ThreadView({ env, id, thread, onEnded }) {
539
495
  children: labels.resolve
540
496
  }
541
497
  ),
542
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
543
- _chunkCW3AFJBRcjs.Button,
498
+ /* @__PURE__ */ jsxRuntime.jsx(
499
+ chunk7XQGOCUG_cjs.Button,
544
500
  {
545
501
  type: "button",
546
502
  variant: "ghost",
@@ -553,17 +509,14 @@ function ThreadView({ env, id, thread, onEnded }) {
553
509
  ] })
554
510
  ] });
555
511
  }
556
-
557
- // src/extensions/comments/ThreadCard.tsx
558
-
559
512
  function ThreadCard({ env, entry, active, expanded, onToggle }) {
560
513
  const { labels, controller } = env;
561
514
  const { thread, anchorText: anchorText2, ranges } = entry;
562
- const header = _react.useRef.call(void 0, null);
515
+ const header = react.useRef(null);
563
516
  const [first] = thread.comments;
564
517
  const removed = ranges.length === 0;
565
518
  const backToHeader = () => {
566
- if (_optionalChain([header, 'access', _49 => _49.current, 'optionalAccess', _50 => _50.isConnected])) header.current.focus();
519
+ if (header.current?.isConnected) header.current.focus();
567
520
  else controller.focus();
568
521
  };
569
522
  const onKeyDown = (event) => {
@@ -571,39 +524,36 @@ function ThreadCard({ env, entry, active, expanded, onToggle }) {
571
524
  event.preventDefault();
572
525
  event.stopPropagation();
573
526
  onToggle(null);
574
- _optionalChain([header, 'access', _51 => _51.current, 'optionalAccess', _52 => _52.focus, 'call', _53 => _53()]);
527
+ header.current?.focus();
575
528
  };
576
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "quoin-comments-card", "data-active": active || void 0, onKeyDown, children: [
577
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
529
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-comments-card", "data-active": active || void 0, onKeyDown, children: [
530
+ /* @__PURE__ */ jsxRuntime.jsxs(
578
531
  "button",
579
532
  {
580
533
  ref: header,
581
534
  type: "button",
582
535
  "aria-expanded": expanded,
583
- className: _chunkCW3AFJBRcjs.cn.call(void 0, "flex w-full flex-col items-start gap-1 rounded-sm text-start", _chunkCW3AFJBRcjs.FOCUS_RING),
536
+ className: chunk7XQGOCUG_cjs.cn("flex w-full flex-col items-start gap-1 rounded-sm text-start", chunk7XQGOCUG_cjs.FOCUS_RING),
584
537
  onClick: () => onToggle(expanded ? null : thread.id),
585
538
  children: [
586
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: removed ? "text-xs text-muted-foreground italic" : "quoin-comments-quote", children: removed ? labels.textRemoved : anchorText2 }),
587
- first !== void 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "line-clamp-2 text-sm", children: [
588
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-medium", children: first.author.name }),
539
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: removed ? "text-xs text-muted-foreground italic" : "quoin-comments-quote", children: removed ? labels.textRemoved : anchorText2 }),
540
+ first !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "line-clamp-2 text-sm", children: [
541
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: first.author.name }),
589
542
  " ",
590
543
  first.body
591
544
  ] }),
592
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-xs text-muted-foreground", children: labels.commentCount(thread.comments.length) })
545
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: labels.commentCount(thread.comments.length) })
593
546
  ]
594
547
  }
595
548
  ),
596
- expanded && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mt-3", role: "group", "aria-label": removed ? labels.textRemoved : labels.thread(anchorText2), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadView, { env, id: thread.id, thread, onEnded: backToHeader }) })
549
+ expanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3", role: "group", "aria-label": removed ? labels.textRemoved : labels.thread(anchorText2), children: /* @__PURE__ */ jsxRuntime.jsx(ThreadView, { env, id: thread.id, thread, onEnded: backToHeader }) })
597
550
  ] });
598
551
  }
599
-
600
- // src/extensions/comments/CommentsRail.tsx
601
-
602
552
  var GAP2 = 8;
603
- var layoutKey = (entries, value) => `${value.active} ${value.open !== null} ${entries.map(({ thread, ranges }) => `${thread.id}:${_optionalChain([ranges, 'access', _54 => _54[0], 'optionalAccess', _55 => _55.block])}`)}`;
553
+ var layoutKey = (entries, value) => `${value.active} ${value.open !== null} ${entries.map(({ thread, ranges }) => `${thread.id}:${ranges[0]?.block}`)}`;
604
554
  function CommentsRail({ env, box, entries, value, onToggle }) {
605
555
  useBlockAligned(env.controller, box, GAP2, layoutKey(entries, value));
606
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref: box, className: "quoin-comments-rail", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { "aria-label": env.labels.comments, children: entries.map((entry) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { "data-rail-item": "", "data-block": _nullishCoalesce(_optionalChain([entry, 'access', _56 => _56.ranges, 'access', _57 => _57[0], 'optionalAccess', _58 => _58.block]), () => ( "")), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
556
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: box, className: "quoin-comments-rail", children: /* @__PURE__ */ jsxRuntime.jsx("ul", { "aria-label": env.labels.comments, children: entries.map((entry) => /* @__PURE__ */ jsxRuntime.jsx("li", { "data-rail-item": "", "data-block": entry.ranges[0]?.block ?? "", children: /* @__PURE__ */ jsxRuntime.jsx(
607
557
  ThreadCard,
608
558
  {
609
559
  env,
@@ -614,32 +564,26 @@ function CommentsRail({ env, box, entries, value, onToggle }) {
614
564
  }
615
565
  ) }, entry.thread.id)) }) });
616
566
  }
617
-
618
- // src/extensions/comments/CommentsSheet.tsx
619
- var _reactdialog = require('@radix-ui/react-dialog'); var DialogPrimitive = _interopRequireWildcard(_reactdialog);
620
-
621
-
622
-
623
567
  function CommentsSheet({ env, entries, value, onToggle, onClose, returnFocus }) {
624
568
  const { labels } = env;
625
- const content = _react.useRef.call(void 0, null);
626
- const outside = _react.useRef.call(void 0, false);
569
+ const content = react.useRef(null);
570
+ const outside = react.useRef(false);
627
571
  const focusOpened = (event) => {
628
- const opened = _optionalChain([content, 'access', _59 => _59.current, 'optionalAccess', _60 => _60.querySelector, 'call', _61 => _61('[aria-expanded="true"]')]);
572
+ const opened = content.current?.querySelector('[aria-expanded="true"]');
629
573
  if (!opened) return;
630
574
  event.preventDefault();
631
575
  opened.focus();
632
576
  };
633
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
634
- DialogPrimitive.Root,
577
+ return /* @__PURE__ */ jsxRuntime.jsx(
578
+ DialogPrimitive__namespace.Root,
635
579
  {
636
580
  open: true,
637
581
  modal: false,
638
582
  onOpenChange: (open) => {
639
583
  if (!open) onClose();
640
584
  },
641
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogPrimitive.Portal, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
642
- DialogPrimitive.Content,
585
+ children: /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
586
+ DialogPrimitive__namespace.Content,
643
587
  {
644
588
  ref: content,
645
589
  "aria-describedby": void 0,
@@ -653,11 +597,11 @@ function CommentsSheet({ env, entries, value, onToggle, onClose, returnFocus })
653
597
  if (!outside.current) returnFocus();
654
598
  },
655
599
  children: [
656
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between gap-2", children: [
657
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogPrimitive.Title, { className: "text-sm font-semibold", children: labels.comments }),
658
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogPrimitive.Close, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCW3AFJBRcjs.Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": labels.close, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.XIcon, {}) }) })
600
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
601
+ /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Title, { className: "text-sm font-semibold", children: labels.comments }),
602
+ /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(chunk7XQGOCUG_cjs.Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": labels.close, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, {}) }) })
659
603
  ] }),
660
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { "aria-label": labels.comments, className: "flex flex-col gap-2", children: entries.map((entry) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
604
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { "aria-label": labels.comments, className: "flex flex-col gap-2", children: entries.map((entry) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(
661
605
  ThreadCard,
662
606
  {
663
607
  env,
@@ -679,71 +623,62 @@ var NONE = [];
679
623
  function railEntries(doc, threads, ended = []) {
680
624
  const anchors = commentAnchors(doc);
681
625
  const entries = threads.filter((thread) => !thread.resolved && !isEnded(ended, thread.id, thread)).map((thread) => {
682
- const ranges = _nullishCoalesce(anchors.get(thread.id), () => ( NONE));
626
+ const ranges = anchors.get(thread.id) ?? NONE;
683
627
  return { thread, ranges, anchorText: anchorText(doc, ranges) };
684
628
  });
685
- const place2 = ({ ranges: [first] }) => first === void 0 ? [Infinity, 0] : [_chunk4SLJNZSMcjs.indexOfBlock.call(void 0, doc, first.block), first.from];
629
+ const place2 = ({ ranges: [first] }) => first === void 0 ? [Infinity, 0] : [chunkAIS37SL2_cjs.indexOfBlock(doc, first.block), first.from];
686
630
  return entries.map((entry, order) => ({ entry, order, at: place2(entry) })).sort((a, b) => a.at[0] - b.at[0] || a.at[1] - b.at[1] || a.order - b.order).map(({ entry }) => entry);
687
631
  }
688
-
689
- // src/extensions/comments/ThreadPopover.tsx
690
-
691
-
692
- // src/extensions/comments/ThreadChooser.tsx
693
-
694
632
  function ThreadChooser({ env, choices, onChoose }) {
695
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { "aria-label": env.labels.threadsHere, className: "flex flex-col gap-1", children: choices.map(({ id, anchorText: anchorText2, preview }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
633
+ return /* @__PURE__ */ jsxRuntime.jsx("ul", { "aria-label": env.labels.threadsHere, className: "flex flex-col gap-1", children: choices.map(({ id, anchorText: anchorText2, preview }) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
696
634
  "button",
697
635
  {
698
636
  type: "button",
699
637
  className: "quoin-comments-choice",
700
638
  onClick: () => onChoose(id),
701
639
  children: [
702
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "quoin-comments-quote", children: anchorText2 }),
703
- preview && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "line-clamp-1 text-sm", children: preview })
640
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "quoin-comments-quote", children: anchorText2 }),
641
+ preview && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "line-clamp-1 text-sm", children: preview })
704
642
  ]
705
643
  }
706
644
  ) }, id)) });
707
645
  }
708
-
709
- // src/extensions/comments/ThreadPopover.tsx
710
-
711
646
  var docOf = (state) => state.doc;
712
647
  function focusIsOurs(controller, content) {
713
- const active = _nullishCoalesce(_optionalChain([content, 'optionalAccess', _62 => _62.ownerDocument, 'access', _63 => _63.activeElement]), () => ( null));
714
- return active === null || active === active.ownerDocument.body || _chunk73653CJ4cjs.ownsNode.call(void 0, controller, active);
648
+ const active = content?.ownerDocument.activeElement ?? null;
649
+ return active === null || active === active.ownerDocument.body || chunkEFRQMYZ6_cjs.ownsNode(controller, active);
715
650
  }
716
651
  function ThreadPopover({ env, open, threads, onChoose, onClose }) {
717
652
  const { controller, labels } = env;
718
- const doc = _chunkP6KYXFZCcjs.useEditorState.call(void 0, controller, docOf);
653
+ const doc = chunkIGZRZIAF_cjs.useEditorState(controller, docOf);
719
654
  const anchors = commentAnchors(doc);
720
655
  const { ids } = open;
721
- const first = ids.map((id) => _optionalChain([anchors, 'access', _64 => _64.get, 'call', _65 => _65(id), 'optionalAccess', _66 => _66[0]])).find(Boolean);
722
- const latest = _react.useRef.call(void 0, first);
723
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
656
+ const first = ids.map((id) => anchors.get(id)?.[0]).find(Boolean);
657
+ const latest = react.useRef(first);
658
+ chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
724
659
  if (first) latest.current = first;
725
660
  });
726
- const anchor = _react.useMemo.call(void 0,
661
+ const anchor = react.useMemo(
727
662
  () => ({
728
- current: _chunkCW3AFJBRcjs.virtualAnchor.call(void 0,
729
- () => latest.current ? _chunkCW3AFJBRcjs.rangeRect.call(void 0, controller, latest.current) : null,
663
+ current: chunk7XQGOCUG_cjs.virtualAnchor(
664
+ () => latest.current ? chunk7XQGOCUG_cjs.rangeRect(controller, latest.current) : null,
730
665
  () => latest.current && controller.registry.get(latest.current.block, latest.current.region)
731
666
  )
732
667
  }),
733
668
  [controller]
734
669
  );
735
- const content = _react.useRef.call(void 0, null);
670
+ const content = react.useRef(null);
736
671
  const focusField = () => {
737
- const target = _optionalChain([content, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.querySelector, 'call', _69 => _69(`[${REPLY_FIELD}], button`)]);
738
- if (focusIsOurs(controller, content.current) && !_optionalChain([content, 'access', _70 => _70.current, 'optionalAccess', _71 => _71.contains, 'call', _72 => _72(content.current.ownerDocument.activeElement)])) {
739
- _optionalChain([target, 'optionalAccess', _73 => _73.focus, 'call', _74 => _74()]);
672
+ const target = content.current?.querySelector(`[${REPLY_FIELD}], button`);
673
+ if (focusIsOurs(controller, content.current) && !content.current?.contains(content.current.ownerDocument.activeElement)) {
674
+ target?.focus();
740
675
  }
741
676
  };
742
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
677
+ chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
743
678
  if (open.focus) focusField();
744
679
  }, [open]);
745
680
  if (first === void 0 && latest.current === void 0) return null;
746
- const textOf = (id) => anchorText(doc, _nullishCoalesce(anchors.get(id), () => ( []))) || labels.textRemoved;
681
+ const textOf = (id) => anchorText(doc, anchors.get(id) ?? []) || labels.textRemoved;
747
682
  const single = ids.length === 1;
748
683
  const gone = single && !anchors.has(ids[0]);
749
684
  const backToText = () => controller.focus();
@@ -754,13 +689,13 @@ function ThreadPopover({ env, open, threads, onChoose, onClose }) {
754
689
  const onEscape = (event) => {
755
690
  event.preventDefault();
756
691
  event.stopPropagation();
757
- const inside = _nullishCoalesce(_optionalChain([content, 'access', _75 => _75.current, 'optionalAccess', _76 => _76.contains, 'call', _77 => _77(content.current.ownerDocument.activeElement)]), () => ( false));
692
+ const inside = content.current?.contains(content.current.ownerDocument.activeElement) ?? false;
758
693
  onClose();
759
694
  if (inside) backToText();
760
695
  };
761
- const choices = ids.map((id) => ({ id, anchorText: textOf(id), preview: _nullishCoalesce(_optionalChain([threads, 'access', _78 => _78.find, 'call', _79 => _79(id), 'optionalAccess', _80 => _80.comments, 'access', _81 => _81[0], 'optionalAccess', _82 => _82.body]), () => ( "")) }));
762
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
763
- _chunkCW3AFJBRcjs.Popover,
696
+ const choices = ids.map((id) => ({ id, anchorText: textOf(id), preview: threads.find(id)?.comments[0]?.body ?? "" }));
697
+ return /* @__PURE__ */ jsxRuntime.jsxs(
698
+ chunk7XQGOCUG_cjs.Popover,
764
699
  {
765
700
  open: true,
766
701
  modal: false,
@@ -768,9 +703,9 @@ function ThreadPopover({ env, open, threads, onChoose, onClose }) {
768
703
  if (!next) onClose();
769
704
  },
770
705
  children: [
771
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCW3AFJBRcjs.PopoverAnchor, { virtualRef: anchor }),
772
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
773
- _chunkCW3AFJBRcjs.PopoverContent,
706
+ /* @__PURE__ */ jsxRuntime.jsx(chunk7XQGOCUG_cjs.PopoverAnchor, { virtualRef: anchor }),
707
+ /* @__PURE__ */ jsxRuntime.jsxs(
708
+ chunk7XQGOCUG_cjs.PopoverContent,
774
709
  {
775
710
  ref: content,
776
711
  "aria-label": gone ? labels.textRemoved : single ? labels.thread(textOf(ids[0])) : labels.threadsHere,
@@ -781,8 +716,8 @@ function ThreadPopover({ env, open, threads, onChoose, onClose }) {
781
716
  onCloseAutoFocus: (event) => event.preventDefault(),
782
717
  onEscapeKeyDown: onEscape,
783
718
  children: [
784
- gone && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-2 text-xs text-muted-foreground italic", children: labels.textRemoved }),
785
- single ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadView, { env, id: ids[0], thread: threads.find(ids[0]), onEnded: backToText }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadChooser, { env, choices, onChoose })
719
+ gone && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-2 text-xs text-muted-foreground italic", children: labels.textRemoved }),
720
+ single ? /* @__PURE__ */ jsxRuntime.jsx(ThreadView, { env, id: ids[0], thread: threads.find(ids[0]), onEnded: backToText }) : /* @__PURE__ */ jsxRuntime.jsx(ThreadChooser, { env, choices, onChoose })
786
721
  ]
787
722
  },
788
723
  ids.join(" ")
@@ -791,24 +726,21 @@ function ThreadPopover({ env, open, threads, onChoose, onClose }) {
791
726
  }
792
727
  );
793
728
  }
794
-
795
- // src/extensions/comments/use-anchor-clicks.ts
796
-
797
729
  function idsUnder(root, target) {
798
730
  const ids = [];
799
731
  let element = target instanceof Element ? target.closest("[data-comment]") : null;
800
732
  while (element !== null && root.contains(element)) {
801
733
  const id = element.getAttribute("data-comment");
802
734
  if (id) ids.push(id);
803
- element = _nullishCoalesce(_optionalChain([element, 'access', _83 => _83.parentElement, 'optionalAccess', _84 => _84.closest, 'call', _85 => _85("[data-comment]")]), () => ( null));
735
+ element = element.parentElement?.closest("[data-comment]") ?? null;
804
736
  }
805
737
  return ids;
806
738
  }
807
739
  function useAnchorClicks(controller, threads) {
808
- _react.useEffect.call(void 0, () => {
740
+ react.useEffect(() => {
809
741
  const onClick = (event) => {
810
742
  const root = controller.root;
811
- if (root === null || event.defaultPrevented || !_optionalChain([root, 'access', _86 => _86.ownerDocument, 'access', _87 => _87.getSelection, 'call', _88 => _88(), 'optionalAccess', _89 => _89.isCollapsed])) return;
743
+ if (root === null || event.defaultPrevented || !root.ownerDocument.getSelection()?.isCollapsed) return;
812
744
  const { editor } = controller;
813
745
  const ids = openIds(editor.state, threads, idsUnder(root, event.target));
814
746
  if (ids.length === 0) return;
@@ -818,14 +750,11 @@ function useAnchorClicks(controller, threads) {
818
750
  return () => document.removeEventListener("click", onClick);
819
751
  }, [controller, threads]);
820
752
  }
821
-
822
- // src/extensions/comments/use-canvas-wide.ts
823
-
824
753
  var WIDE_CANVAS = 800;
825
754
  function useCanvasWide(box, initial) {
826
- const [wide, setWide] = _react.useState.call(void 0, initial);
827
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
828
- const canvas = _optionalChain([box, 'access', _90 => _90.current, 'optionalAccess', _91 => _91.parentElement]);
755
+ const [wide, setWide] = react.useState(initial);
756
+ chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
757
+ const canvas = box.current?.parentElement;
829
758
  if (!canvas) return void 0;
830
759
  const measure = () => setWide(canvas.offsetWidth >= WIDE_CANVAS);
831
760
  measure();
@@ -835,57 +764,51 @@ function useCanvasWide(box, initial) {
835
764
  }, [box]);
836
765
  return wide;
837
766
  }
838
-
839
- // src/extensions/comments/use-threads.ts
840
-
841
767
  function useThreads(threads) {
842
- return _react.useSyncExternalStore.call(void 0, threads.subscribe, threads.get, threads.get);
768
+ return react.useSyncExternalStore(threads.subscribe, threads.get, threads.get);
843
769
  }
844
-
845
- // src/extensions/comments/CommentsOverlay.tsx
846
-
847
- var commentsOf = (state) => _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey);
770
+ var commentsOf = (state) => chunkVFSVN5IQ_cjs.getPluginState(state, commentsKey);
848
771
  var docOf2 = (state) => state.doc;
849
772
  function CommentsOverlay({ controller, host, labels }) {
850
- const { onError } = _chunkCW3AFJBRcjs.useQuoin.call(void 0, );
773
+ const { onError } = chunk7XQGOCUG_cjs.useQuoin();
851
774
  const link = linkOf(controller.editor);
852
- _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
775
+ chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
853
776
  link.report = onError;
854
777
  }, [link, onError]);
855
778
  useAnchorClicks(controller, host.threads);
856
779
  const threads = useThreads(host.threads);
857
- const value = _chunkP6KYXFZCcjs.useEditorState.call(void 0, controller, commentsOf);
858
- const doc = _chunkP6KYXFZCcjs.useEditorState.call(void 0, controller, docOf2);
859
- const entries = _react.useMemo.call(void 0, () => railEntries(doc, threads, value.ended), [doc, threads, value.ended]);
860
- const box = _react.useRef.call(void 0, null);
780
+ const value = chunkIGZRZIAF_cjs.useEditorState(controller, commentsOf);
781
+ const doc = chunkIGZRZIAF_cjs.useEditorState(controller, docOf2);
782
+ const entries = react.useMemo(() => railEntries(doc, threads, value.ended), [doc, threads, value.ended]);
783
+ const box = react.useRef(null);
861
784
  const wide = useCanvasWide(box, host.initialLayout === "wide");
862
- const [sheet, setSheet] = _react.useState.call(void 0, false);
863
- const opener = _react.useRef.call(void 0, null);
864
- _react.useEffect.call(void 0, () => {
785
+ const [sheet, setSheet] = react.useState(false);
786
+ const opener = react.useRef(null);
787
+ react.useEffect(() => {
865
788
  if (wide) setSheet(false);
866
789
  }, [wide]);
867
- const env = _react.useMemo.call(void 0, () => ({ controller, host, labels, link }), [controller, host, labels, link]);
868
- const act2 = _react.useCallback.call(void 0,
790
+ const env = react.useMemo(() => ({ controller, host, labels, link }), [controller, host, labels, link]);
791
+ const act2 = react.useCallback(
869
792
  (action) => controller.editor.dispatch(commentsTransaction(controller.editor.state, action)),
870
793
  [controller]
871
794
  );
872
- const toggle = _react.useCallback.call(void 0, (id) => act2({ type: "activate", id }), [act2]);
795
+ const toggle = react.useCallback((id) => act2({ type: "activate", id }), [act2]);
873
796
  const openSheet = (id, marker) => {
874
797
  opener.current = marker;
875
798
  toggle(id);
876
799
  setSheet(true);
877
800
  };
878
801
  const returnFocus = () => {
879
- if (_optionalChain([opener, 'access', _92 => _92.current, 'optionalAccess', _93 => _93.isConnected])) opener.current.focus();
802
+ if (opener.current?.isConnected) opener.current.focus();
880
803
  else controller.focus();
881
804
  };
882
805
  const closeSheet = () => {
883
806
  setSheet(false);
884
807
  toggle(null);
885
808
  };
886
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
887
- wide ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CommentsRail, { env, box, entries, value, onToggle: toggle }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CommentMarkers, { env, box, entries, onOpen: openSheet }),
888
- !wide && sheet && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
809
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
810
+ wide ? /* @__PURE__ */ jsxRuntime.jsx(CommentsRail, { env, box, entries, value, onToggle: toggle }) : /* @__PURE__ */ jsxRuntime.jsx(CommentMarkers, { env, box, entries, onOpen: openSheet }),
811
+ !wide && sheet && /* @__PURE__ */ jsxRuntime.jsx(
889
812
  CommentsSheet,
890
813
  {
891
814
  env,
@@ -896,7 +819,7 @@ function CommentsOverlay({ controller, host, labels }) {
896
819
  returnFocus
897
820
  }
898
821
  ),
899
- value.open && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
822
+ value.open && /* @__PURE__ */ jsxRuntime.jsx(
900
823
  ThreadPopover,
901
824
  {
902
825
  env,
@@ -915,10 +838,10 @@ var ACTIVE = { class: "quoin-comment-active" };
915
838
  var inline = (ranges, attrs) => ranges.map((range) => ({ kind: "inline", ...range, attrs }));
916
839
  var drawn = /* @__PURE__ */ new WeakMap();
917
840
  function commentsDecorations(state) {
918
- const value = _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey);
841
+ const value = chunkVFSVN5IQ_cjs.getPluginState(state, commentsKey);
919
842
  const last = drawn.get(value);
920
- if (_optionalChain([last, 'optionalAccess', _94 => _94.doc]) === state.doc) return last.decorations;
921
- const active = value.active === null ? [] : _nullishCoalesce(commentAnchors(state.doc).get(value.active), () => ( []));
843
+ if (last?.doc === state.doc) return last.decorations;
844
+ const active = value.active === null ? [] : commentAnchors(state.doc).get(value.active) ?? [];
922
845
  const decorations = [...value.pending.flatMap(({ ranges }) => inline(ranges, PENDING)), ...inline(active, ACTIVE)];
923
846
  drawn.set(value, { doc: state.doc, decorations });
924
847
  return decorations;
@@ -927,20 +850,17 @@ function commentsDecorations(state) {
927
850
  // src/extensions/comments/watch-ended.ts
928
851
  function watchEnded(editor, threads) {
929
852
  return threads.subscribe(() => {
930
- const { ended } = _chunkZKVOS57Qcjs.getPluginState.call(void 0, editor.state, commentsKey);
853
+ const { ended } = chunkVFSVN5IQ_cjs.getPluginState(editor.state, commentsKey);
931
854
  const kept = ended.filter(({ id }) => isEnded(ended, id, threads.find(id)));
932
855
  if (kept.length < ended.length) editor.dispatch(commentsTransaction(editor.state, { type: "caught", kept }));
933
856
  });
934
857
  }
935
-
936
- // src/extensions/comments/comments-extension.tsx
937
-
938
858
  var commentItem = (labels) => ({
939
859
  id: "comment",
940
860
  title: labels.comment,
941
- icon: _lucidereact.MessageSquarePlus,
861
+ icon: lucideReact.MessageSquarePlus,
942
862
  shortcut: "Mod-Alt-m",
943
- available: (state) => hasCommentableText(state) && _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey).pending.length === 0,
863
+ available: (state) => hasCommentableText(state) && chunkVFSVN5IQ_cjs.getPluginState(state, commentsKey).pending.length === 0,
944
864
  // Focus goes back to the text first: the button leaves the toolbar while the thread is being asked for.
945
865
  run: (controller) => {
946
866
  controller.focus();
@@ -951,10 +871,10 @@ function commentsExtension(options) {
951
871
  const { labels: overrides, ...host } = options;
952
872
  const labels = resolveCommentsLabels(overrides);
953
873
  function Overlay({ controller }) {
954
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CommentsOverlay, { controller, host, labels });
874
+ return /* @__PURE__ */ jsxRuntime.jsx(CommentsOverlay, { controller, host, labels });
955
875
  }
956
876
  const ui = { bubbleItems: [commentItem(labels)], overlays: [Overlay] };
957
- return _chunkZKVOS57Qcjs.defineExtension.call(void 0, {
877
+ return chunkVFSVN5IQ_cjs.defineExtension({
958
878
  name: "comments",
959
879
  plugins: [commentsPlugin],
960
880
  decorations: commentsDecorations,
@@ -968,7 +888,7 @@ function commentsExtension(options) {
968
888
  }
969
889
  return () => {
970
890
  if (--link.mounts > 0) return;
971
- _optionalChain([link, 'access', _95 => _95.stopWatching, 'optionalCall', _96 => _96()]);
891
+ link.stopWatching?.();
972
892
  link.stopWatching = null;
973
893
  };
974
894
  },
@@ -1001,8 +921,8 @@ function createCommentThreads(initial = NO_THREADS) {
1001
921
  };
1002
922
  }
1003
923
 
1004
-
1005
-
1006
-
1007
- exports.commentsExtension = commentsExtension; exports.createCommentThreads = createCommentThreads; exports.englishCommentsLabels = englishCommentsLabels;
924
+ exports.commentsExtension = commentsExtension;
925
+ exports.createCommentThreads = createCommentThreads;
926
+ exports.englishCommentsLabels = englishCommentsLabels;
927
+ //# sourceMappingURL=comments.cjs.map
1008
928
  //# sourceMappingURL=comments.cjs.map