@pixerate/editor 0.23.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/README.md +167 -2
  2. package/THIRD_PARTY_NOTICES.md +80 -0
  3. package/dist/agent/index.cjs +10 -8
  4. package/dist/agent/index.cjs.map +1 -1
  5. package/dist/agent/index.d.cts +4 -3
  6. package/dist/agent/index.d.ts +4 -3
  7. package/dist/agent/index.js +4 -2
  8. package/dist/agent/index.js.map +1 -1
  9. package/dist/canvas/index.cjs +4437 -411
  10. package/dist/canvas/index.cjs.map +1 -1
  11. package/dist/canvas/index.d.cts +934 -4
  12. package/dist/canvas/index.d.ts +934 -4
  13. package/dist/canvas/index.js +4309 -283
  14. package/dist/canvas/index.js.map +1 -1
  15. package/dist/chunk-4BVP64JJ.cjs +1406 -0
  16. package/dist/chunk-4BVP64JJ.cjs.map +1 -0
  17. package/dist/chunk-664LQYFJ.js +115 -0
  18. package/dist/chunk-664LQYFJ.js.map +1 -0
  19. package/dist/chunk-7WISYZFO.cjs +740 -0
  20. package/dist/chunk-7WISYZFO.cjs.map +1 -0
  21. package/dist/chunk-AL6JMGWW.cjs +783 -0
  22. package/dist/chunk-AL6JMGWW.cjs.map +1 -0
  23. package/dist/chunk-BVP3TSLH.cjs +69 -0
  24. package/dist/chunk-BVP3TSLH.cjs.map +1 -0
  25. package/dist/{chunk-RIKBJLS2.cjs → chunk-C7P22VIP.cjs} +2001 -279
  26. package/dist/chunk-C7P22VIP.cjs.map +1 -0
  27. package/dist/chunk-D6FH2YAX.cjs +131 -0
  28. package/dist/chunk-D6FH2YAX.cjs.map +1 -0
  29. package/dist/chunk-ECCCYKGL.js +740 -0
  30. package/dist/chunk-ECCCYKGL.js.map +1 -0
  31. package/dist/{chunk-4SUNJZWB.cjs → chunk-FD4LPFAE.cjs} +48 -200
  32. package/dist/chunk-FD4LPFAE.cjs.map +1 -0
  33. package/dist/{chunk-QBJ22YZR.js → chunk-FH6F67DN.js} +1999 -277
  34. package/dist/chunk-FH6F67DN.js.map +1 -0
  35. package/dist/{chunk-OYXSKQFR.js → chunk-FPENXAEJ.js} +35 -187
  36. package/dist/chunk-FPENXAEJ.js.map +1 -0
  37. package/dist/chunk-HLIMTC6N.js +1 -0
  38. package/dist/chunk-HLIMTC6N.js.map +1 -0
  39. package/dist/chunk-HRMEDT2L.js +1406 -0
  40. package/dist/chunk-HRMEDT2L.js.map +1 -0
  41. package/dist/{chunk-QGHGJ56O.js → chunk-IXHSYOVY.js} +2518 -122
  42. package/dist/chunk-IXHSYOVY.js.map +1 -0
  43. package/dist/chunk-MKA3AHLV.cjs +256 -0
  44. package/dist/chunk-MKA3AHLV.cjs.map +1 -0
  45. package/dist/chunk-NAXVVS5I.js +783 -0
  46. package/dist/chunk-NAXVVS5I.js.map +1 -0
  47. package/dist/chunk-O5RYH2PG.js +69 -0
  48. package/dist/chunk-O5RYH2PG.js.map +1 -0
  49. package/dist/chunk-OXSV64JX.js +689 -0
  50. package/dist/chunk-OXSV64JX.js.map +1 -0
  51. package/dist/chunk-P3RQ5UJE.cjs +689 -0
  52. package/dist/chunk-P3RQ5UJE.cjs.map +1 -0
  53. package/dist/chunk-P6ODPZ4W.js +256 -0
  54. package/dist/chunk-P6ODPZ4W.js.map +1 -0
  55. package/dist/chunk-PL4JB3BF.cjs +1 -0
  56. package/dist/chunk-PL4JB3BF.cjs.map +1 -0
  57. package/dist/{chunk-GVSMRPHB.cjs → chunk-PO6A6QQH.cjs} +2607 -211
  58. package/dist/chunk-PO6A6QQH.cjs.map +1 -0
  59. package/dist/{chunk-JJDLPEWL.js → chunk-QGYDWPRM.js} +2 -2
  60. package/dist/chunk-RR7F5GUM.js +5726 -0
  61. package/dist/chunk-RR7F5GUM.js.map +1 -0
  62. package/dist/chunk-TNNJXF46.cjs +115 -0
  63. package/dist/chunk-TNNJXF46.cjs.map +1 -0
  64. package/dist/chunk-U5HZSFCS.js +131 -0
  65. package/dist/chunk-U5HZSFCS.js.map +1 -0
  66. package/dist/{chunk-MJZBNWG7.js → chunk-UAKDG62Z.js} +309 -581
  67. package/dist/chunk-UAKDG62Z.js.map +1 -0
  68. package/dist/{chunk-CL37JGFW.cjs → chunk-V3CHHWOE.cjs} +4 -4
  69. package/dist/{chunk-CL37JGFW.cjs.map → chunk-V3CHHWOE.cjs.map} +1 -1
  70. package/dist/chunk-WSQKHXW7.cjs +5726 -0
  71. package/dist/chunk-WSQKHXW7.cjs.map +1 -0
  72. package/dist/{chunk-AA4ZEVCC.cjs → chunk-X4N4WUKB.cjs} +336 -608
  73. package/dist/chunk-X4N4WUKB.cjs.map +1 -0
  74. package/dist/commands/index.cjs +74 -1
  75. package/dist/commands/index.cjs.map +1 -1
  76. package/dist/commands/index.d.cts +38 -353
  77. package/dist/commands/index.d.ts +38 -353
  78. package/dist/commands/index.js +73 -0
  79. package/dist/commands/index.js.map +1 -1
  80. package/dist/comment-store-BEMgVlAA.d.cts +135 -0
  81. package/dist/comment-store-BEMgVlAA.d.ts +135 -0
  82. package/dist/compare/index.cjs +15 -0
  83. package/dist/compare/index.cjs.map +1 -0
  84. package/dist/compare/index.d.cts +58 -0
  85. package/dist/compare/index.d.ts +58 -0
  86. package/dist/compare/index.js +15 -0
  87. package/dist/compare/index.js.map +1 -0
  88. package/dist/controller-BIJiNoVs.d.cts +1842 -0
  89. package/dist/controller-BIJiNoVs.d.ts +1842 -0
  90. package/dist/documents-CHT1U5Vs.d.ts +86 -0
  91. package/dist/documents-Gp7wb0Me.d.cts +86 -0
  92. package/dist/extensions/index.cjs +100 -5
  93. package/dist/extensions/index.cjs.map +1 -1
  94. package/dist/extensions/index.d.cts +16 -4
  95. package/dist/extensions/index.d.ts +16 -4
  96. package/dist/extensions/index.js +100 -5
  97. package/dist/generation/index.cjs +2317 -0
  98. package/dist/generation/index.cjs.map +1 -0
  99. package/dist/generation/index.d.cts +1015 -0
  100. package/dist/generation/index.d.ts +1015 -0
  101. package/dist/generation/index.js +2317 -0
  102. package/dist/generation/index.js.map +1 -0
  103. package/dist/grammar/index.cjs +48 -3
  104. package/dist/grammar/index.cjs.map +1 -1
  105. package/dist/grammar/index.d.cts +322 -100
  106. package/dist/grammar/index.d.ts +322 -100
  107. package/dist/grammar/index.js +54 -9
  108. package/dist/image-editor/index.cjs +4392 -481
  109. package/dist/image-editor/index.cjs.map +1 -1
  110. package/dist/image-editor/index.d.cts +1249 -97
  111. package/dist/image-editor/index.d.ts +1249 -97
  112. package/dist/image-editor/index.js +4281 -370
  113. package/dist/image-editor/index.js.map +1 -1
  114. package/dist/index-7a6bHTLy.d.ts +1754 -0
  115. package/dist/index-Csd5qI8u.d.cts +1754 -0
  116. package/dist/index.cjs +1682 -99
  117. package/dist/index.cjs.map +1 -1
  118. package/dist/index.d.cts +118 -21
  119. package/dist/index.d.ts +118 -21
  120. package/dist/index.js +1630 -47
  121. package/dist/index.js.map +1 -1
  122. package/dist/mention-text-CDnCFd3c.d.cts +53 -0
  123. package/dist/mention-text-CDnCFd3c.d.ts +53 -0
  124. package/dist/migrate-iTlm3a8h.d.cts +112 -0
  125. package/dist/migrate-iTlm3a8h.d.ts +112 -0
  126. package/dist/model-C1zApQM8.d.cts +219 -0
  127. package/dist/model-C1zApQM8.d.ts +219 -0
  128. package/dist/persistence/index.cjs +676 -0
  129. package/dist/persistence/index.cjs.map +1 -0
  130. package/dist/persistence/index.d.cts +230 -0
  131. package/dist/persistence/index.d.ts +230 -0
  132. package/dist/persistence/index.js +676 -0
  133. package/dist/persistence/index.js.map +1 -0
  134. package/dist/{registry-D5-R90p0.d.cts → registry-BDe-vlv3.d.ts} +2 -40
  135. package/dist/{registry-GJI4gToU.d.ts → registry-CEgwXED1.d.cts} +12 -1
  136. package/dist/{registry-GJI4gToU.d.cts → registry-CEgwXED1.d.ts} +12 -1
  137. package/dist/registry-D32LpIc4.d.cts +354 -0
  138. package/dist/{registry-D5-R90p0.d.ts → registry-DnzpgY27.d.cts} +2 -40
  139. package/dist/registry-evKTP4ls.d.ts +354 -0
  140. package/dist/schema-DYDGdYL9.d.cts +41 -0
  141. package/dist/schema-DYDGdYL9.d.ts +41 -0
  142. package/dist/serializers/index.cjs +12 -3
  143. package/dist/serializers/index.cjs.map +1 -1
  144. package/dist/serializers/index.d.cts +40 -12
  145. package/dist/serializers/index.d.ts +40 -12
  146. package/dist/serializers/index.js +12 -3
  147. package/dist/sourcemap-C8AH3MBQ.d.cts +91 -0
  148. package/dist/sourcemap-DA1Evhrv.d.ts +91 -0
  149. package/dist/spreadsheet/index.cjs +161 -3
  150. package/dist/spreadsheet/index.cjs.map +1 -1
  151. package/dist/spreadsheet/index.d.cts +611 -20
  152. package/dist/spreadsheet/index.d.ts +611 -20
  153. package/dist/spreadsheet/index.js +168 -10
  154. package/dist/storage-BpFfspHm.d.cts +120 -0
  155. package/dist/storage-BpFfspHm.d.ts +120 -0
  156. package/dist/tokens/index.cjs +115 -0
  157. package/dist/tokens/index.cjs.map +1 -0
  158. package/dist/tokens/index.d.cts +212 -0
  159. package/dist/tokens/index.d.ts +212 -0
  160. package/dist/tokens/index.js +115 -0
  161. package/dist/tokens/index.js.map +1 -0
  162. package/dist/{tokens-CyLZmIei.d.cts → tokens-D7yXvUU6.d.cts} +15 -2
  163. package/dist/{tokens-CyLZmIei.d.ts → tokens-D7yXvUU6.d.ts} +15 -2
  164. package/dist/{track-changes-BSF58RK0.d.cts → track-changes-D_VAPELi.d.cts} +110 -144
  165. package/dist/{track-changes-BSF58RK0.d.ts → track-changes-Db_fGEvx.d.ts} +110 -144
  166. package/package.json +21 -1
  167. package/dist/chunk-4SUNJZWB.cjs.map +0 -1
  168. package/dist/chunk-AA4ZEVCC.cjs.map +0 -1
  169. package/dist/chunk-AXV2ZW34.cjs +0 -118
  170. package/dist/chunk-AXV2ZW34.cjs.map +0 -1
  171. package/dist/chunk-B2ZRLN4S.js +0 -118
  172. package/dist/chunk-B2ZRLN4S.js.map +0 -1
  173. package/dist/chunk-GVSMRPHB.cjs.map +0 -1
  174. package/dist/chunk-K3R5NG2D.js +0 -3100
  175. package/dist/chunk-K3R5NG2D.js.map +0 -1
  176. package/dist/chunk-MJZBNWG7.js.map +0 -1
  177. package/dist/chunk-OYXSKQFR.js.map +0 -1
  178. package/dist/chunk-QBJ22YZR.js.map +0 -1
  179. package/dist/chunk-QGHGJ56O.js.map +0 -1
  180. package/dist/chunk-RIKBJLS2.cjs.map +0 -1
  181. package/dist/chunk-XDMXXC4Z.cjs +0 -3100
  182. package/dist/chunk-XDMXXC4Z.cjs.map +0 -1
  183. package/dist/controller-pePCJLT1.d.cts +0 -959
  184. package/dist/controller-pePCJLT1.d.ts +0 -959
  185. package/dist/index-CCr_z9kF.d.cts +0 -899
  186. package/dist/index-Ck6ajwXh.d.ts +0 -899
  187. /package/dist/{chunk-JJDLPEWL.js.map → chunk-QGYDWPRM.js.map} +0 -0
@@ -0,0 +1,783 @@
1
+ "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; }
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ var _chunkX4N4WUKBcjs = require('./chunk-X4N4WUKB.cjs');
11
+
12
+ // src/compare/diff.ts
13
+ var EQUAL = 0;
14
+ var DELETE = 1;
15
+ var INSERT = 2;
16
+ function pushRepeat(out, op, count) {
17
+ for (let i = 0; i < count; i++) out.push(op);
18
+ }
19
+ function myers(aLo, aHi, bLo, bHi, eq, out, maxD) {
20
+ const n = aHi - aLo;
21
+ const m = bHi - bLo;
22
+ if (n === 0 || m === 0) {
23
+ pushRepeat(out, DELETE, n);
24
+ pushRepeat(out, INSERT, m);
25
+ return true;
26
+ }
27
+ const max = n + m;
28
+ const off = max + 1;
29
+ const v = new Int32Array(2 * max + 3);
30
+ const trace = [];
31
+ const limit = Math.min(max, maxD);
32
+ let found = false;
33
+ outer: for (let d = 0; d <= limit; d++) {
34
+ trace.push(v.slice(Math.max(off - d - 1, 0), off + d + 2));
35
+ for (let k = -d; k <= d; k += 2) {
36
+ const i = k + off;
37
+ let x2 = k === -d || k !== d && v[i - 1] < v[i + 1] ? v[i + 1] : v[i - 1] + 1;
38
+ let y2 = x2 - k;
39
+ while (x2 < n && y2 < m && eq(aLo + x2, bLo + y2)) {
40
+ x2++;
41
+ y2++;
42
+ }
43
+ v[i] = x2;
44
+ if (x2 >= n && y2 >= m) {
45
+ found = true;
46
+ break outer;
47
+ }
48
+ }
49
+ }
50
+ if (!found) return false;
51
+ const ops = [];
52
+ let x = n;
53
+ let y = m;
54
+ for (let d = trace.length - 1; d >= 0; d--) {
55
+ const frontier = trace[d];
56
+ const base = Math.max(off - d - 1, 0);
57
+ const at = (k2) => frontier[k2 + off - base];
58
+ const k = x - y;
59
+ const prevK = k === -d || k !== d && at(k - 1) < at(k + 1) ? k + 1 : k - 1;
60
+ const prevX = at(prevK);
61
+ const prevY = prevX - prevK;
62
+ while (x > prevX && y > prevY) {
63
+ ops.push(EQUAL);
64
+ x--;
65
+ y--;
66
+ }
67
+ if (d > 0) ops.push(x === prevX ? INSERT : DELETE);
68
+ x = prevX;
69
+ y = prevY;
70
+ }
71
+ for (let i = ops.length - 1; i >= 0; i--) out.push(ops[i]);
72
+ return true;
73
+ }
74
+ function anchors(ids, aLo, aHi, bLo, bHi) {
75
+ const count = /* @__PURE__ */ new Map();
76
+ for (let i = aLo; i < aHi; i++) {
77
+ const id = ids.a[i];
78
+ const entry = count.get(id);
79
+ if (entry) {
80
+ entry[0]++;
81
+ } else {
82
+ count.set(id, [1, 0, i, -1]);
83
+ }
84
+ }
85
+ for (let j = bLo; j < bHi; j++) {
86
+ const entry = count.get(ids.b[j]);
87
+ if (entry) {
88
+ entry[1]++;
89
+ entry[3] = j;
90
+ }
91
+ }
92
+ const pairs = [];
93
+ count.forEach((entry) => {
94
+ if (entry[0] === 1 && entry[1] === 1) pairs.push([entry[2], entry[3]]);
95
+ });
96
+ pairs.sort((p, q) => p[0] - q[0]);
97
+ const tails = [];
98
+ const prev = new Int32Array(pairs.length).fill(-1);
99
+ for (let k2 = 0; k2 < pairs.length; k2++) {
100
+ const y = pairs[k2][1];
101
+ let lo = 0;
102
+ let hi = tails.length;
103
+ while (lo < hi) {
104
+ const mid = lo + hi >> 1;
105
+ if (pairs[tails[mid]][1] < y) lo = mid + 1;
106
+ else hi = mid;
107
+ }
108
+ if (lo > 0) prev[k2] = tails[lo - 1];
109
+ if (lo === tails.length) tails.push(k2);
110
+ else tails[lo] = k2;
111
+ }
112
+ const result = [];
113
+ let k = tails.length ? tails[tails.length - 1] : -1;
114
+ while (k !== -1) {
115
+ result.push(pairs[k]);
116
+ k = prev[k];
117
+ }
118
+ return result.reverse();
119
+ }
120
+ function diffRange(ctx, aLo, aHi, bLo, bHi, out, depth) {
121
+ const { eq } = ctx;
122
+ let prefix = 0;
123
+ while (aLo + prefix < aHi && bLo + prefix < bHi && eq(aLo + prefix, bLo + prefix)) prefix++;
124
+ let suffix = 0;
125
+ while (aHi - suffix > aLo + prefix && bHi - suffix > bLo + prefix && eq(aHi - suffix - 1, bHi - suffix - 1)) {
126
+ suffix++;
127
+ }
128
+ pushRepeat(out, EQUAL, prefix);
129
+ const ma = aLo + prefix;
130
+ const mb = bLo + prefix;
131
+ const ea = aHi - suffix;
132
+ const eb = bHi - suffix;
133
+ const replace = () => {
134
+ pushRepeat(out, DELETE, ea - ma);
135
+ pushRepeat(out, INSERT, eb - mb);
136
+ };
137
+ if (ea - ma + (eb - mb) <= ctx.direct) {
138
+ myers(ma, ea, mb, eb, eq, out, Infinity);
139
+ } else if (!ctx.ids) {
140
+ if (!myers(ma, ea, mb, eb, eq, out, ctx.direct)) replace();
141
+ } else {
142
+ const found = depth >= ctx.maxDepth ? [] : anchors(ctx.ids, ma, ea, mb, eb);
143
+ if (found.length === 0) {
144
+ replace();
145
+ } else {
146
+ let i = ma;
147
+ let j = mb;
148
+ for (const [x, y] of found) {
149
+ diffRange(ctx, i, x, j, y, out, depth + 1);
150
+ out.push(EQUAL);
151
+ i = x + 1;
152
+ j = y + 1;
153
+ }
154
+ diffRange(ctx, i, ea, j, eb, out, depth + 1);
155
+ }
156
+ }
157
+ pushRepeat(out, EQUAL, suffix);
158
+ }
159
+ var defaultHash = (item) => typeof item === "string" || typeof item === "number" || typeof item === "boolean" ? item : JSON.stringify(item);
160
+ function diffSequences(a, b, options = {}) {
161
+ const direct = Math.max(2, _nullishCoalesce(options.direct, () => ( 3e3)));
162
+ const maxDepth = _nullishCoalesce(options.maxDepth, () => ( 8));
163
+ let ids = null;
164
+ let eq;
165
+ if (options.equals && !options.hash) {
166
+ const equals = options.equals;
167
+ eq = (i2, j2) => equals(a[i2], b[j2]);
168
+ } else {
169
+ const hash = _nullishCoalesce(options.hash, () => ( defaultHash));
170
+ const table = /* @__PURE__ */ new Map();
171
+ const idOf = (item) => {
172
+ const key = hash(item);
173
+ let id = table.get(key);
174
+ if (id === void 0) {
175
+ id = table.size;
176
+ table.set(key, id);
177
+ }
178
+ return id;
179
+ };
180
+ ids = { a: Int32Array.from(a, idOf), b: Int32Array.from(b, idOf) };
181
+ const { a: ia, b: ib } = ids;
182
+ eq = (i2, j2) => ia[i2] === ib[j2];
183
+ }
184
+ const ops = [];
185
+ diffRange({ eq, ids, direct, maxDepth }, 0, a.length, 0, b.length, ops, 0);
186
+ const runs = [];
187
+ const push = (type, aIndex, bIndex, length) => {
188
+ if (length === 0) return;
189
+ const last = runs[runs.length - 1];
190
+ if (last && last.type === type) {
191
+ last.length += length;
192
+ } else {
193
+ runs.push({ type, aIndex, bIndex, length });
194
+ }
195
+ };
196
+ let i = 0;
197
+ let j = 0;
198
+ let k = 0;
199
+ while (k < ops.length) {
200
+ if (ops[k] === EQUAL) {
201
+ let n = 0;
202
+ while (k < ops.length && ops[k] === EQUAL) {
203
+ n++;
204
+ k++;
205
+ }
206
+ push("equal", i, j, n);
207
+ i += n;
208
+ j += n;
209
+ continue;
210
+ }
211
+ let dels = 0;
212
+ let inss = 0;
213
+ while (k < ops.length && ops[k] !== EQUAL) {
214
+ if (ops[k] === DELETE) dels++;
215
+ else inss++;
216
+ k++;
217
+ }
218
+ push("delete", i, j, dels);
219
+ push("insert", i + dels, j, inss);
220
+ i += dels;
221
+ j += inss;
222
+ }
223
+ return runs;
224
+ }
225
+ function diffChanges(a, b, options = {}) {
226
+ const changes = [];
227
+ let current = null;
228
+ for (const run of diffSequences(a, b, options)) {
229
+ if (run.type === "equal") {
230
+ current = null;
231
+ continue;
232
+ }
233
+ if (!current) {
234
+ current = {
235
+ kind: run.type === "delete" ? "deleted" : "inserted",
236
+ aStart: run.aIndex,
237
+ aEnd: run.aIndex,
238
+ bStart: run.bIndex,
239
+ bEnd: run.bIndex
240
+ };
241
+ changes.push(current);
242
+ }
243
+ if (run.type === "delete") {
244
+ current.aEnd = run.aIndex + run.length;
245
+ } else {
246
+ current.bEnd = run.bIndex + run.length;
247
+ }
248
+ if (current.aEnd > current.aStart && current.bEnd > current.bStart) current.kind = "replaced";
249
+ }
250
+ return changes;
251
+ }
252
+
253
+ // src/compare/documents.ts
254
+ var _core = require('@tiptap/core');
255
+
256
+
257
+
258
+ var _model = require('@tiptap/pm/model');
259
+ var REVIEW_MARK_NAMES = /* @__PURE__ */ new Set([
260
+ _chunkX4N4WUKBcjs.INSERTION_MARK_NAME,
261
+ _chunkX4N4WUKBcjs.DELETION_MARK_NAME,
262
+ _chunkX4N4WUKBcjs.FORMAT_CHANGE_MARK_NAME,
263
+ "comment",
264
+ "bookmark"
265
+ ]);
266
+ var LIST_TYPES = /* @__PURE__ */ new Set(["bulletList", "orderedList"]);
267
+ var OBJECT_REPLACEMENT = "\uFFFC";
268
+ function stableStringify(value) {
269
+ if (value === void 0) return "null";
270
+ if (value === null || typeof value !== "object") return JSON.stringify(value);
271
+ if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
272
+ const keys = Object.keys(value).sort();
273
+ return `{${keys.map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`).join(",")}}`;
274
+ }
275
+ function toTime(date) {
276
+ if (date instanceof Date) return date.getTime();
277
+ if (typeof date === "string") {
278
+ const time = Date.parse(date);
279
+ return Number.isNaN(time) ? Date.now() : time;
280
+ }
281
+ return typeof date === "number" ? date : Date.now();
282
+ }
283
+ function toNode(source, schema) {
284
+ if (typeof source === "string") return _core.createDocument.call(void 0, source, schema);
285
+ if (typeof source.descendants === "function") {
286
+ const node = source;
287
+ return node.type.schema === schema ? node : schema.nodeFromJSON(node.toJSON());
288
+ }
289
+ return schema.nodeFromJSON(source);
290
+ }
291
+ function newAttributes(ctx) {
292
+ return {
293
+ changeId: ctx.generateId(),
294
+ authorId: ctx.author.id,
295
+ authorName: ctx.author.name,
296
+ authorColor: _nullishCoalesce(ctx.author.color, () => ( null)),
297
+ createdAt: ctx.createdAt
298
+ };
299
+ }
300
+ function lazyAttributes(ctx) {
301
+ let attrs = null;
302
+ return () => attrs = _nullishCoalesce(attrs, () => ( newAttributes(ctx)));
303
+ }
304
+ function stripBlockChange(attrs) {
305
+ const copy = { ...attrs };
306
+ delete copy[_chunkX4N4WUKBcjs.BLOCK_CHANGE_ATTRIBUTE];
307
+ return copy;
308
+ }
309
+ function wrapperOf(node) {
310
+ return { type: node.type.name, attrs: stripBlockChange(node.attrs) };
311
+ }
312
+ function snapshot(node, wrappers) {
313
+ return { type: node.type.name, attrs: stripBlockChange(node.attrs), wrappers };
314
+ }
315
+ function filteredAttributes(attrs, ctx) {
316
+ return stableStringify(
317
+ Object.fromEntries(
318
+ Object.entries(_nullishCoalesce(attrs, () => ( {}))).filter(
319
+ ([key]) => key !== _chunkX4N4WUKBcjs.BLOCK_CHANGE_ATTRIBUTE && !ctx.ignoredAttributes.has(key)
320
+ )
321
+ )
322
+ );
323
+ }
324
+ function sameBlock(a, b, ctx) {
325
+ if (a.type !== b.type) return false;
326
+ if (filteredAttributes(a.attrs, ctx) !== filteredAttributes(b.attrs, ctx)) return false;
327
+ if (a.wrappers.length !== b.wrappers.length) return false;
328
+ return a.wrappers.every((w, i) => w.type === b.wrappers[i].type);
329
+ }
330
+ var hasBlockChange = (node) => !!node.type.spec.attrs && _chunkX4N4WUKBcjs.BLOCK_CHANGE_ATTRIBUTE in node.type.spec.attrs;
331
+ var label = (node) => node.type.name;
332
+ function normalize(text, ctx) {
333
+ let result = ctx.ignoreWhitespace ? text.replace(/\s+/g, " ") : text;
334
+ if (ctx.ignoreCase) result = result.toLowerCase();
335
+ return result;
336
+ }
337
+ function leafKey(node) {
338
+ return `${node.type.name}${stableStringify(stripBlockChange(node.attrs))}`;
339
+ }
340
+ function group(node) {
341
+ return LIST_TYPES.has(node.type.name) ? "list" : node.type.name;
342
+ }
343
+ function blockKey(node, ctx) {
344
+ const cached = ctx.keys.get(node);
345
+ if (cached !== void 0) return cached;
346
+ let key;
347
+ if (node.isTextblock) {
348
+ let text = "";
349
+ node.forEach((child) => {
350
+ text += child.isText ? child.text : `${OBJECT_REPLACEMENT}${leafKey(child)}${OBJECT_REPLACEMENT}`;
351
+ });
352
+ text = normalize(text, ctx);
353
+ key = `T\0${ctx.ignoreWhitespace ? text.trim() : text}`;
354
+ } else if (node.isLeaf) {
355
+ key = `A\0${leafKey(node)}`;
356
+ } else {
357
+ const parts = [];
358
+ node.forEach((child) => parts.push(blockKey(child, ctx)));
359
+ key = `C\0${group(node)}\0${parts.join("")}`;
360
+ }
361
+ ctx.keys.set(node, key);
362
+ return key;
363
+ }
364
+ function compatible(a, b) {
365
+ if (a.isTextblock || b.isTextblock) return a.isTextblock && b.isTextblock;
366
+ if (a.isLeaf || b.isLeaf) return a.isLeaf && b.isLeaf && a.type === b.type;
367
+ return group(a) === group(b);
368
+ }
369
+ function markInline(content, mark) {
370
+ const nodes = [];
371
+ content.forEach((child) => nodes.push(child.mark(mark.addToSet(child.marks))));
372
+ return _model.Fragment.from(nodes);
373
+ }
374
+ function wholeBlock(node, operation, wrappers, attrs, ctx) {
375
+ const verb = operation === "insert" ? "Inserted" : "Deleted";
376
+ if (node.isTextblock) {
377
+ if (hasBlockChange(node)) {
378
+ const record = {
379
+ ...attrs(),
380
+ previous: snapshot(node, wrappers),
381
+ operation
382
+ };
383
+ return [node.type.create({ ...node.attrs, [_chunkX4N4WUKBcjs.BLOCK_CHANGE_ATTRIBUTE]: record }, node.content, node.marks)];
384
+ }
385
+ const markType = operation === "insert" ? ctx.insertion : ctx.deletion;
386
+ if (markType && node.type.allowsMarkType(markType) && node.content.size > 0) {
387
+ ctx.notes.add(
388
+ `${verb} ${label(node)} blocks have no "${_chunkX4N4WUKBcjs.BLOCK_CHANGE_ATTRIBUTE}" attribute: only their text is tracked, so an empty block remains when the change is ${operation === "insert" ? "rejected" : "accepted"}.`
389
+ );
390
+ return [node.type.create(node.attrs, markInline(node.content, markType.create(attrs())), node.marks)];
391
+ }
392
+ ctx.notes.add(`${verb} ${label(node)} blocks cannot be tracked.`);
393
+ return operation === "insert" ? [node] : [];
394
+ }
395
+ if (node.isLeaf) {
396
+ ctx.notes.add(`${verb} ${label(node)} blocks cannot be tracked.`);
397
+ return operation === "insert" ? [node] : [];
398
+ }
399
+ const inner = [...wrappers, wrapperOf(node)];
400
+ const children = [];
401
+ node.forEach((child) => children.push(...wholeBlock(child, operation, inner, attrs, ctx)));
402
+ try {
403
+ return [node.type.createChecked(node.attrs, children, node.marks)];
404
+ } catch (e) {
405
+ ctx.notes.add(`${verb} ${label(node)} blocks cannot be tracked.`);
406
+ return operation === "insert" ? [node] : [];
407
+ }
408
+ }
409
+ function units(node) {
410
+ const result = [];
411
+ node.forEach((child) => {
412
+ if (child.isText) {
413
+ for (const ch of _nullishCoalesce(child.text, () => ( ""))) result.push({ text: ch, node: null, marks: child.marks });
414
+ } else {
415
+ result.push({ text: "", node: child, marks: child.marks });
416
+ }
417
+ });
418
+ return result;
419
+ }
420
+ var SPACE = /\s/u;
421
+ var WORD = /[\p{L}\p{N}\p{M}_]/u;
422
+ var isSpace = (u) => !u.node && SPACE.test(u.text);
423
+ var isWord = (u) => !u.node && WORD.test(u.text);
424
+ function tokenize(list, chars) {
425
+ const tokens = [];
426
+ if (chars) {
427
+ for (let i2 = 0; i2 < list.length; i2++) tokens.push([i2, i2 + 1]);
428
+ return tokens;
429
+ }
430
+ let i = 0;
431
+ while (i < list.length) {
432
+ const start = i;
433
+ const unit = list[i];
434
+ if (isSpace(unit)) {
435
+ while (i < list.length && isSpace(list[i])) i++;
436
+ } else if (isWord(unit)) {
437
+ while (i < list.length && isWord(list[i])) i++;
438
+ } else {
439
+ i++;
440
+ }
441
+ tokens.push([start, i]);
442
+ }
443
+ return tokens;
444
+ }
445
+ function stretches(runs, list, tokens) {
446
+ const spaceOnly = (bIndex, length) => {
447
+ for (let t = bIndex; t < bIndex + length; t++) {
448
+ const [from, to] = tokens[t];
449
+ for (let k = from; k < to; k++) if (!isSpace(list[k])) return false;
450
+ }
451
+ return true;
452
+ };
453
+ const result = [];
454
+ runs.forEach((run, index) => {
455
+ const prev = runs[index - 1];
456
+ const next = runs[index + 1];
457
+ const absorbed = run.type === "equal" && prev && next && prev.type !== "equal" && next.type !== "equal" && spaceOnly(run.bIndex, run.length);
458
+ if (run.type === "equal" && !absorbed) {
459
+ result.push({ type: "equal", aIndex: run.aIndex, bIndex: run.bIndex, length: run.length });
460
+ return;
461
+ }
462
+ let last = result[result.length - 1];
463
+ if (!last || last.type !== "change") {
464
+ last = { type: "change", aFrom: run.aIndex, aTo: run.aIndex, bFrom: run.bIndex, bTo: run.bIndex };
465
+ result.push(last);
466
+ }
467
+ if (run.type !== "insert") last.aTo = run.aIndex + run.length;
468
+ if (run.type !== "delete") last.bTo = run.bIndex + run.length;
469
+ });
470
+ return result;
471
+ }
472
+ function tokenKey(list, [from, to], ctx) {
473
+ let text = "";
474
+ for (let i = from; i < to; i++) {
475
+ const unit = list[i];
476
+ text += unit.node ? `${OBJECT_REPLACEMENT}${leafKey(unit.node)}${OBJECT_REPLACEMENT}` : unit.text;
477
+ }
478
+ return normalize(text, ctx);
479
+ }
480
+ function formattingOf(marks, ctx) {
481
+ return marks.filter(
482
+ (mark) => !REVIEW_MARK_NAMES.has(mark.type.name) && !ctx.ignoredMarks.has(mark.type.name)
483
+ );
484
+ }
485
+ function withoutReviewMarks(marks) {
486
+ return marks.filter(
487
+ (mark) => mark.type.name !== _chunkX4N4WUKBcjs.INSERTION_MARK_NAME && mark.type.name !== _chunkX4N4WUKBcjs.DELETION_MARK_NAME && mark.type.name !== _chunkX4N4WUKBcjs.FORMAT_CHANGE_MARK_NAME
488
+ );
489
+ }
490
+ function mergeInline(original, revised, parentType, ctx) {
491
+ const a = units(original);
492
+ const b = units(revised);
493
+ let chars = ctx.granularity === "char";
494
+ if (chars && Math.max(a.length, b.length) > ctx.maxCharDiff) {
495
+ chars = false;
496
+ ctx.notes.add(
497
+ `Paragraphs longer than ${ctx.maxCharDiff} characters were compared by words instead of characters.`
498
+ );
499
+ }
500
+ const ta = tokenize(a, chars);
501
+ const tb = tokenize(b, chars);
502
+ const runs = diffSequences(
503
+ ta.map((t) => tokenKey(a, t, ctx)),
504
+ tb.map((t) => tokenKey(b, t, ctx))
505
+ );
506
+ const format = ctx.formatting && ctx.format && parentType.allowsMarkType(ctx.format) ? ctx.format : null;
507
+ const out = [];
508
+ let formatRun = null;
509
+ const emit = (source, tokens, from, to, markType) => {
510
+ if (to <= from) return;
511
+ const mark = markType.create(newAttributes(ctx));
512
+ for (let k = tokens[from][0]; k < tokens[to - 1][1]; k++) {
513
+ const unit = source[k];
514
+ out.push({ ...unit, marks: mark.addToSet(withoutReviewMarks(unit.marks)) });
515
+ }
516
+ };
517
+ for (const run of stretches(runs, b, tb)) {
518
+ if (run.type === "equal") {
519
+ for (let t = 0; t < run.length; t++) {
520
+ const [aFrom, aTo] = ta[run.aIndex + t];
521
+ const [bFrom, bTo] = tb[run.bIndex + t];
522
+ for (let k = bFrom; k < bTo; k++) {
523
+ const unit = b[k];
524
+ const before = a[Math.min(aFrom + (k - bFrom), aTo - 1)];
525
+ const marks = withoutReviewMarks(unit.marks);
526
+ if (!format) {
527
+ formatRun = null;
528
+ out.push({ ...unit, marks });
529
+ continue;
530
+ }
531
+ const oldFormat = formattingOf(before.marks, ctx);
532
+ const newFormat = formattingOf(unit.marks, ctx);
533
+ if (_model.Mark.sameSet(oldFormat, newFormat)) {
534
+ formatRun = null;
535
+ out.push({ ...unit, marks });
536
+ continue;
537
+ }
538
+ const beforeJSON = oldFormat.map((m) => m.toJSON());
539
+ const afterJSON = newFormat.map((m) => m.toJSON());
540
+ const key = stableStringify([beforeJSON, afterJSON]);
541
+ if (!formatRun || formatRun.key !== key) formatRun = { attrs: newAttributes(ctx), key };
542
+ const mark = format.create({ ...formatRun.attrs, before: beforeJSON, after: afterJSON });
543
+ out.push({ ...unit, marks: mark.addToSet(marks) });
544
+ }
545
+ }
546
+ continue;
547
+ }
548
+ formatRun = null;
549
+ emit(a, ta, run.aFrom, run.aTo, ctx.deletion);
550
+ emit(b, tb, run.bFrom, run.bTo, ctx.insertion);
551
+ }
552
+ const nodes = [];
553
+ let i = 0;
554
+ while (i < out.length) {
555
+ const unit = out[i];
556
+ if (unit.node) {
557
+ nodes.push(unit.node.mark(unit.marks));
558
+ i++;
559
+ continue;
560
+ }
561
+ let text = unit.text;
562
+ let j = i + 1;
563
+ while (j < out.length && !out[j].node && _model.Mark.sameSet(out[j].marks, unit.marks)) {
564
+ text += out[j].text;
565
+ j++;
566
+ }
567
+ nodes.push(ctx.schema.text(text, unit.marks));
568
+ i = j;
569
+ }
570
+ return _model.Fragment.from(nodes);
571
+ }
572
+ function mergeTextblocks(original, revised, oPath, rPath, ctx) {
573
+ const replaceWhole = () => [
574
+ ...wholeBlock(original, "delete", rPath, lazyAttributes(ctx), ctx),
575
+ ...wholeBlock(revised, "insert", rPath, lazyAttributes(ctx), ctx)
576
+ ];
577
+ let attrs = { ...revised.attrs };
578
+ const previous = snapshot(original, oPath);
579
+ if (!sameBlock(previous, snapshot(revised, rPath), ctx)) {
580
+ if (hasBlockChange(revised)) {
581
+ const onlyWrappers = ctx.wrapperChange && sameBlock(previous, { ...snapshot(revised, rPath), wrappers: previous.wrappers }, ctx);
582
+ const base = onlyWrappers ? ctx.wrapperChange() : newAttributes(ctx);
583
+ attrs = { ...attrs, [_chunkX4N4WUKBcjs.BLOCK_CHANGE_ATTRIBUTE]: { ...base, previous } };
584
+ } else {
585
+ ctx.notes.add(`Block changes to ${label(revised)} blocks cannot be tracked.`);
586
+ }
587
+ } else if (_chunkX4N4WUKBcjs.BLOCK_CHANGE_ATTRIBUTE in attrs) {
588
+ attrs[_chunkX4N4WUKBcjs.BLOCK_CHANGE_ATTRIBUTE] = null;
589
+ }
590
+ const type = revised.type;
591
+ const inlineTracking = !!ctx.insertion && !!ctx.deletion && type.allowsMarkType(ctx.insertion) && type.allowsMarkType(ctx.deletion);
592
+ if (!inlineTracking) {
593
+ if (!original.content.eq(revised.content)) return replaceWhole();
594
+ return [type.create(attrs, revised.content, revised.marks)];
595
+ }
596
+ const content = mergeInline(original, revised, type, ctx);
597
+ if (!type.validContent(content)) {
598
+ ctx.notes.add(`Changes between ${label(original)} and ${label(revised)} blocks were tracked as whole-block replacements.`);
599
+ return replaceWhole();
600
+ }
601
+ return [type.create(attrs, content, revised.marks)];
602
+ }
603
+ function mergePair(original, revised, oPath, rPath, ctx) {
604
+ if (original.isTextblock) return mergeTextblocks(original, revised, oPath, rPath, ctx);
605
+ const replaceWhole = () => [
606
+ ...wholeBlock(original, "delete", rPath, lazyAttributes(ctx), ctx),
607
+ ...wholeBlock(revised, "insert", rPath, lazyAttributes(ctx), ctx)
608
+ ];
609
+ if (original.isLeaf) {
610
+ return original.eq(revised) ? [revised] : replaceWhole();
611
+ }
612
+ if (original.type === revised.type && filteredAttributes(original.attrs, ctx) !== filteredAttributes(revised.attrs, ctx)) {
613
+ ctx.notes.add(`Attribute changes of ${label(revised)} nodes are not tracked.`);
614
+ }
615
+ const outer = ctx.wrapperChange;
616
+ if (original.type !== revised.type) ctx.wrapperChange = lazyAttributes(ctx);
617
+ let children;
618
+ try {
619
+ children = compareChildren(
620
+ original,
621
+ revised,
622
+ [...oPath, wrapperOf(original)],
623
+ [...rPath, wrapperOf(revised)],
624
+ ctx
625
+ );
626
+ } finally {
627
+ ctx.wrapperChange = outer;
628
+ }
629
+ try {
630
+ return [revised.type.createChecked(revised.attrs, children, revised.marks)];
631
+ } catch (e2) {
632
+ ctx.notes.add(`Changes inside ${label(revised)} nodes were tracked as whole-block replacements.`);
633
+ return replaceWhole();
634
+ }
635
+ }
636
+ function compareChildren(original, revised, oPath, rPath, ctx) {
637
+ const a = [];
638
+ const b = [];
639
+ original.forEach((child) => a.push(child));
640
+ revised.forEach((child) => b.push(child));
641
+ const runs = diffSequences(a, b, { hash: (node) => blockKey(node, ctx) });
642
+ const out = [];
643
+ for (let r = 0; r < runs.length; r++) {
644
+ const run = runs[r];
645
+ if (run.type === "equal") {
646
+ for (let t = 0; t < run.length; t++) {
647
+ out.push(...mergePair(a[run.aIndex + t], b[run.bIndex + t], oPath, rPath, ctx));
648
+ }
649
+ continue;
650
+ }
651
+ let dels = [];
652
+ let inss = [];
653
+ if (run.type === "delete") {
654
+ dels = a.slice(run.aIndex, run.aIndex + run.length);
655
+ const next = runs[r + 1];
656
+ if (_optionalChain([next, 'optionalAccess', _ => _.type]) === "insert") {
657
+ inss = b.slice(next.bIndex, next.bIndex + next.length);
658
+ r++;
659
+ }
660
+ } else {
661
+ inss = b.slice(run.bIndex, run.bIndex + run.length);
662
+ }
663
+ const deleted = lazyAttributes(ctx);
664
+ const inserted = lazyAttributes(ctx);
665
+ for (let x = 0; x < Math.max(dels.length, inss.length); x++) {
666
+ const del = dels[x];
667
+ const ins = inss[x];
668
+ if (del && ins && compatible(del, ins)) {
669
+ out.push(...mergePair(del, ins, oPath, rPath, ctx));
670
+ continue;
671
+ }
672
+ if (del) out.push(...wholeBlock(del, "delete", rPath, deleted, ctx));
673
+ if (ins) out.push(...wholeBlock(ins, "insert", rPath, inserted, ctx));
674
+ }
675
+ }
676
+ return out;
677
+ }
678
+ function detectMovedBlocks(children, ctx) {
679
+ const keyOf = (node) => `${node.type.name}\0${filteredAttributes(node.attrs, ctx)}\0${stableStringify(node.content.toJSON())}`;
680
+ const candidates = /* @__PURE__ */ new Map();
681
+ children.forEach((node, index) => {
682
+ const operation = _optionalChain([node, 'access', _2 => _2.attrs, 'optionalAccess', _3 => _3[_chunkX4N4WUKBcjs.BLOCK_CHANGE_ATTRIBUTE], 'optionalAccess', _4 => _4.operation]);
683
+ if (!operation || !node.isTextblock || !node.textContent.trim()) return;
684
+ if (!node.type.allowsMarkType(ctx.insertion) || !node.type.allowsMarkType(ctx.deletion)) return;
685
+ const key = keyOf(node);
686
+ const entry = _nullishCoalesce(candidates.get(key), () => ( { del: [], ins: [] }));
687
+ (operation === "delete" ? entry.del : entry.ins).push(index);
688
+ candidates.set(key, entry);
689
+ });
690
+ const out = [...children];
691
+ candidates.forEach(({ del, ins }) => {
692
+ if (del.length !== 1 || ins.length !== 1) return;
693
+ const attrs = newAttributes(ctx);
694
+ const moved = { ...attrs, [_chunkX4N4WUKBcjs.MOVE_ID_ATTRIBUTE]: attrs.changeId };
695
+ const relink = (index, markType) => {
696
+ const node = out[index];
697
+ out[index] = node.type.create(
698
+ { ...node.attrs, [_chunkX4N4WUKBcjs.BLOCK_CHANGE_ATTRIBUTE]: null },
699
+ markInline(node.content, markType.create(moved)),
700
+ node.marks
701
+ );
702
+ };
703
+ relink(del[0], ctx.deletion);
704
+ relink(ins[0], ctx.insertion);
705
+ });
706
+ return out;
707
+ }
708
+ function summarize(doc, notes) {
709
+ const summary = {
710
+ insertions: 0,
711
+ deletions: 0,
712
+ formatChanges: 0,
713
+ blockChanges: 0,
714
+ moves: 0,
715
+ notHonoured: [...notes]
716
+ };
717
+ _chunkX4N4WUKBcjs.getTrackedChanges.call(void 0, doc).forEach((change) => {
718
+ if (change.type === "move") summary.moves++;
719
+ else if (change.type === "insertion" || _optionalChain([change, 'access', _5 => _5.block, 'optionalAccess', _6 => _6.operation]) === "insert") summary.insertions++;
720
+ else if (change.type === "deletion" || _optionalChain([change, 'access', _7 => _7.block, 'optionalAccess', _8 => _8.operation]) === "delete") summary.deletions++;
721
+ else if (change.type === "format") summary.formatChanges++;
722
+ else summary.blockChanges++;
723
+ });
724
+ return summary;
725
+ }
726
+ function compareDocuments(original, revised, options = {}) {
727
+ const schema = _nullishCoalesce(options.schema, () => ( (typeof _optionalChain([original, 'optionalAccess', _9 => _9.descendants]) === "function" ? original.type.schema : typeof _optionalChain([revised, 'optionalAccess', _10 => _10.descendants]) === "function" ? revised.type.schema : null)));
728
+ if (!schema) throw new Error("compareDocuments: `schema` is required for JSON or HTML sources.");
729
+ const ctx = {
730
+ schema,
731
+ author: _nullishCoalesce(options.author, () => ( { id: "compare", name: "Compare" })),
732
+ createdAt: toTime(options.date),
733
+ generateId: _nullishCoalesce(options.generateId, () => ( (() => _chunkX4N4WUKBcjs.createReviewId.call(void 0, "change")))),
734
+ granularity: _nullishCoalesce(options.granularity, () => ( "word")),
735
+ ignoreCase: !!options.ignoreCase,
736
+ ignoreWhitespace: !!options.ignoreWhitespace,
737
+ formatting: options.formatting !== false,
738
+ maxCharDiff: _nullishCoalesce(options.maxCharDiff, () => ( 2e3)),
739
+ ignoredMarks: new Set(_nullishCoalesce(options.ignoredMarks, () => ( []))),
740
+ ignoredAttributes: new Set(_nullishCoalesce(options.ignoredBlockAttributes, () => ( ["id"]))),
741
+ insertion: schema.marks[_chunkX4N4WUKBcjs.INSERTION_MARK_NAME],
742
+ deletion: schema.marks[_chunkX4N4WUKBcjs.DELETION_MARK_NAME],
743
+ format: schema.marks[_chunkX4N4WUKBcjs.FORMAT_CHANGE_MARK_NAME],
744
+ notes: /* @__PURE__ */ new Set(),
745
+ keys: /* @__PURE__ */ new Map(),
746
+ wrapperChange: null
747
+ };
748
+ if (!ctx.insertion || !ctx.deletion) {
749
+ throw new Error("compareDocuments: the schema needs the TrackChanges extension (insertion/deletion marks).");
750
+ }
751
+ if (ctx.formatting && !ctx.format) {
752
+ ctx.notes.add("Formatting differences cannot be tracked: the schema has no formatChange mark.");
753
+ }
754
+ const prepare = (source) => {
755
+ const doc2 = toNode(source, schema);
756
+ if (_chunkX4N4WUKBcjs.getTrackedChanges.call(void 0, doc2).length === 0) return doc2;
757
+ ctx.notes.add("Tracked changes already in the documents were accepted before comparing.");
758
+ return _chunkX4N4WUKBcjs.resolveTrackedChanges.call(void 0, doc2, "accepted");
759
+ };
760
+ const a = prepare(original);
761
+ const b = prepare(revised);
762
+ let children = compareChildren(a, b, [], [], ctx);
763
+ if (options.detectMoves) children = detectMovedBlocks(children, ctx);
764
+ let doc;
765
+ try {
766
+ doc = b.type.createChecked(b.attrs, children, b.marks);
767
+ } catch (e3) {
768
+ doc = _nullishCoalesce(b.type.createAndFill(b.attrs, children, b.marks), () => ( b));
769
+ ctx.notes.add("The compared document had to be repaired to fit the schema.");
770
+ }
771
+ return { doc, summary: summarize(doc, ctx.notes) };
772
+ }
773
+ function compareHtml(originalHtml, revisedHtml, options) {
774
+ return compareDocuments(originalHtml, revisedHtml, options);
775
+ }
776
+
777
+
778
+
779
+
780
+
781
+
782
+ exports.diffSequences = diffSequences; exports.diffChanges = diffChanges; exports.compareDocuments = compareDocuments; exports.compareHtml = compareHtml;
783
+ //# sourceMappingURL=chunk-AL6JMGWW.cjs.map