@inpageedit/core 0.6.0 → 0.8.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 (81) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +55 -55
  3. package/dist/ActionButton-BgbTKTg7.js.map +1 -1
  4. package/dist/CheckBox-D3rHnX7I.js.map +1 -1
  5. package/dist/IconQuickEdit-YVn1ANbm.js +27 -0
  6. package/dist/IconQuickEdit-YVn1ANbm.js.map +1 -0
  7. package/dist/InPageEdit.d.ts +7 -5
  8. package/dist/InputBox-BV4m05Xs.js.map +1 -1
  9. package/dist/Preferences-Bg3J5Ur9.js.map +1 -1
  10. package/dist/RadioBox-nJqWsxW2.js.map +1 -1
  11. package/dist/__test__/utils/constants.d.ts +1 -1
  12. package/dist/components/Icon/IconEdit.d.ts +2 -0
  13. package/dist/components/Icon/IconQuickEdit.d.ts +2 -0
  14. package/dist/components/MwUserLinks.d.ts +2 -0
  15. package/dist/components/index.js.map +1 -1
  16. package/dist/index--xn9BebC.js +1257 -0
  17. package/dist/{index-5zB57uWM.js.map → index--xn9BebC.js.map} +1 -1
  18. package/dist/{index-SDBp__LY.js → index-BT1mN_St.js} +68 -65
  19. package/dist/{index-SDBp__LY.js.map → index-BT1mN_St.js.map} +1 -1
  20. package/dist/index-Bh70Udzi.js.map +1 -1
  21. package/dist/index-C0V2s48o.js +122 -0
  22. package/dist/index-C0V2s48o.js.map +1 -0
  23. package/dist/index-CvhkVj_L.js.map +1 -1
  24. package/dist/{index-clwjxJi5.js → index-DDWds9Jg.js} +77 -74
  25. package/dist/index-DDWds9Jg.js.map +1 -0
  26. package/dist/index-DDef1ojx.js +166 -0
  27. package/dist/index-DDef1ojx.js.map +1 -0
  28. package/dist/{index-BqqQgaGG.js → index-DTA86mHU.js} +5 -4
  29. package/dist/index-DTA86mHU.js.map +1 -0
  30. package/dist/{index-CPCQc37I.js → index-DlgTb4XY.js} +4 -4
  31. package/dist/index-DlgTb4XY.js.map +1 -0
  32. package/dist/{index-BnRuHI16.js → index-DpLwTw4C.js} +1967 -1693
  33. package/dist/index-DpLwTw4C.js.map +1 -0
  34. package/dist/{index-ClYojws9.js → index-TzKe6Ebm.js} +8 -7
  35. package/dist/index-TzKe6Ebm.js.map +1 -0
  36. package/dist/index-VzP81S7B.js +139 -0
  37. package/dist/index-VzP81S7B.js.map +1 -0
  38. package/dist/index-lZkYoUca.js.map +1 -1
  39. package/dist/index-loWqosf7.js +331 -0
  40. package/dist/index-loWqosf7.js.map +1 -0
  41. package/dist/index.js +1 -1
  42. package/dist/makeCallable-LDU0xZMJ.js.map +1 -1
  43. package/dist/models/WikiPage/index.d.ts +42 -47
  44. package/dist/models/WikiTitle/index.d.ts +3 -2
  45. package/dist/noop-ClDc6zv4.js.map +1 -1
  46. package/dist/plugins/in-article-links/index.d.ts +5 -17
  47. package/dist/plugins/quick-delete/index.d.ts +7 -5
  48. package/dist/plugins/quick-diff/PluginQuickDiffCore.d.ts +2 -0
  49. package/dist/plugins/quick-diff/components/DiffTable.d.ts +17 -0
  50. package/dist/plugins/quick-edit/index.d.ts +12 -10
  51. package/dist/plugins/quick-move/index.d.ts +3 -1
  52. package/dist/plugins/quick-preview/index.d.ts +13 -16
  53. package/dist/plugins/quick-redirect/index.d.ts +3 -1
  54. package/dist/plugins/toolbox/index.d.ts +7 -2
  55. package/dist/services/ApiService.d.ts +2 -2
  56. package/dist/services/ModalService/IPEModal.d.ts +1 -1
  57. package/dist/services/WikiMetadataService.d.ts +108 -0
  58. package/dist/services/WikiPageService.d.ts +8 -7
  59. package/dist/services/WikiTitleService.d.ts +43 -3
  60. package/dist/style.css +1 -1
  61. package/dist/types/{SiteMetadata.d.ts → WikiMetadata.d.ts} +17 -17
  62. package/dist/utils/url.d.ts +24 -0
  63. package/lib/index.umd.js +28 -28
  64. package/lib/index.umd.js.map +1 -1
  65. package/lib/style.css +1 -1
  66. package/package.json +11 -2
  67. package/dist/index-5zB57uWM.js +0 -1142
  68. package/dist/index-B7Ok-t-3.js +0 -128
  69. package/dist/index-B7Ok-t-3.js.map +0 -1
  70. package/dist/index-BHruEVsx.js +0 -319
  71. package/dist/index-BHruEVsx.js.map +0 -1
  72. package/dist/index-BnRuHI16.js.map +0 -1
  73. package/dist/index-BqqQgaGG.js.map +0 -1
  74. package/dist/index-Bs5MFAHs.js +0 -110
  75. package/dist/index-Bs5MFAHs.js.map +0 -1
  76. package/dist/index-C9QOZJ8o.js +0 -167
  77. package/dist/index-C9QOZJ8o.js.map +0 -1
  78. package/dist/index-CPCQc37I.js.map +0 -1
  79. package/dist/index-ClYojws9.js.map +0 -1
  80. package/dist/index-clwjxJi5.js.map +0 -1
  81. package/dist/services/SiteMetadataService.d.ts +0 -58
@@ -0,0 +1,1257 @@
1
+ import { j as a, F as Ee, P as Ne } from "./index-CvhkVj_L.js";
2
+ import { B as K, I as Se, S as P } from "./index-DpLwTw4C.js";
3
+ import { I as Pe } from "./IconQuickEdit-YVn1ANbm.js";
4
+ import { R as We } from "./Preferences-Bg3J5Ur9.js";
5
+ import { R as _e } from "./RadioBox-nJqWsxW2.js";
6
+ import { M as Oe } from "./index-lZkYoUca.js";
7
+ class E {
8
+ diff(e, n, i = {}) {
9
+ let s;
10
+ typeof i == "function" ? (s = i, i = {}) : "callback" in i && (s = i.callback);
11
+ const r = this.castInput(e, i), l = this.castInput(n, i), o = this.removeEmpty(this.tokenize(r, i)), f = this.removeEmpty(this.tokenize(l, i));
12
+ return this.diffWithOptionsObj(o, f, i, s);
13
+ }
14
+ diffWithOptionsObj(e, n, i, s) {
15
+ var r;
16
+ const l = (d) => {
17
+ if (d = this.postProcess(d, i), s) {
18
+ setTimeout(function() {
19
+ s(d);
20
+ }, 0);
21
+ return;
22
+ } else
23
+ return d;
24
+ }, o = n.length, f = e.length;
25
+ let h = 1, c = o + f;
26
+ i.maxEditLength != null && (c = Math.min(c, i.maxEditLength));
27
+ const g = (r = i.timeout) !== null && r !== void 0 ? r : 1 / 0, y = Date.now() + g, w = [{ oldPos: -1, lastComponent: void 0 }];
28
+ let m = this.extractCommon(w[0], n, e, 0, i);
29
+ if (w[0].oldPos + 1 >= f && m + 1 >= o)
30
+ return l(this.buildValues(w[0].lastComponent, n, e));
31
+ let v = -1 / 0, x = 1 / 0;
32
+ const C = () => {
33
+ for (let d = Math.max(v, -h); d <= Math.min(x, h); d += 2) {
34
+ let u;
35
+ const p = w[d - 1], k = w[d + 1];
36
+ p && (w[d - 1] = void 0);
37
+ let D = !1;
38
+ if (k) {
39
+ const N = k.oldPos - d;
40
+ D = k && 0 <= N && N < o;
41
+ }
42
+ const b = p && p.oldPos + 1 < f;
43
+ if (!D && !b) {
44
+ w[d] = void 0;
45
+ continue;
46
+ }
47
+ if (!b || D && p.oldPos < k.oldPos ? u = this.addToPath(k, !0, !1, 0, i) : u = this.addToPath(p, !1, !0, 1, i), m = this.extractCommon(u, n, e, d, i), u.oldPos + 1 >= f && m + 1 >= o)
48
+ return l(this.buildValues(u.lastComponent, n, e)) || !0;
49
+ w[d] = u, u.oldPos + 1 >= f && (x = Math.min(x, d - 1)), m + 1 >= o && (v = Math.max(v, d + 1));
50
+ }
51
+ h++;
52
+ };
53
+ if (s)
54
+ (function d() {
55
+ setTimeout(function() {
56
+ if (h > c || Date.now() > y)
57
+ return s(void 0);
58
+ C() || d();
59
+ }, 0);
60
+ })();
61
+ else
62
+ for (; h <= c && Date.now() <= y; ) {
63
+ const d = C();
64
+ if (d)
65
+ return d;
66
+ }
67
+ }
68
+ addToPath(e, n, i, s, r) {
69
+ const l = e.lastComponent;
70
+ return l && !r.oneChangePerToken && l.added === n && l.removed === i ? {
71
+ oldPos: e.oldPos + s,
72
+ lastComponent: { count: l.count + 1, added: n, removed: i, previousComponent: l.previousComponent }
73
+ } : {
74
+ oldPos: e.oldPos + s,
75
+ lastComponent: { count: 1, added: n, removed: i, previousComponent: l }
76
+ };
77
+ }
78
+ extractCommon(e, n, i, s, r) {
79
+ const l = n.length, o = i.length;
80
+ let f = e.oldPos, h = f - s, c = 0;
81
+ for (; h + 1 < l && f + 1 < o && this.equals(i[f + 1], n[h + 1], r); )
82
+ h++, f++, c++, r.oneChangePerToken && (e.lastComponent = { count: 1, previousComponent: e.lastComponent, added: !1, removed: !1 });
83
+ return c && !r.oneChangePerToken && (e.lastComponent = { count: c, previousComponent: e.lastComponent, added: !1, removed: !1 }), e.oldPos = f, h;
84
+ }
85
+ equals(e, n, i) {
86
+ return i.comparator ? i.comparator(e, n) : e === n || !!i.ignoreCase && e.toLowerCase() === n.toLowerCase();
87
+ }
88
+ removeEmpty(e) {
89
+ const n = [];
90
+ for (let i = 0; i < e.length; i++)
91
+ e[i] && n.push(e[i]);
92
+ return n;
93
+ }
94
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
95
+ castInput(e, n) {
96
+ return e;
97
+ }
98
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
99
+ tokenize(e, n) {
100
+ return Array.from(e);
101
+ }
102
+ join(e) {
103
+ return e.join("");
104
+ }
105
+ postProcess(e, n) {
106
+ return e;
107
+ }
108
+ get useLongestToken() {
109
+ return !1;
110
+ }
111
+ buildValues(e, n, i) {
112
+ const s = [];
113
+ let r;
114
+ for (; e; )
115
+ s.push(e), r = e.previousComponent, delete e.previousComponent, e = r;
116
+ s.reverse();
117
+ const l = s.length;
118
+ let o = 0, f = 0, h = 0;
119
+ for (; o < l; o++) {
120
+ const c = s[o];
121
+ if (c.removed)
122
+ c.value = this.join(i.slice(h, h + c.count)), h += c.count;
123
+ else {
124
+ if (!c.added && this.useLongestToken) {
125
+ let g = n.slice(f, f + c.count);
126
+ g = g.map(function(y, w) {
127
+ const m = i[h + w];
128
+ return m.length > y.length ? m : y;
129
+ }), c.value = this.join(g);
130
+ } else
131
+ c.value = this.join(n.slice(f, f + c.count));
132
+ f += c.count, c.added || (h += c.count);
133
+ }
134
+ }
135
+ return s;
136
+ }
137
+ }
138
+ class Te extends E {
139
+ }
140
+ const ee = new Te();
141
+ function te(t, e, n) {
142
+ return ee.diff(t, e, n);
143
+ }
144
+ function V(t, e) {
145
+ let n;
146
+ for (n = 0; n < t.length && n < e.length; n++)
147
+ if (t[n] != e[n])
148
+ return t.slice(0, n);
149
+ return t.slice(0, n);
150
+ }
151
+ function Y(t, e) {
152
+ let n;
153
+ if (!t || !e || t[t.length - 1] != e[e.length - 1])
154
+ return "";
155
+ for (n = 0; n < t.length && n < e.length; n++)
156
+ if (t[t.length - (n + 1)] != e[e.length - (n + 1)])
157
+ return t.slice(-n);
158
+ return t.slice(-n);
159
+ }
160
+ function $(t, e, n) {
161
+ if (t.slice(0, e.length) != e)
162
+ throw Error(`string ${JSON.stringify(t)} doesn't start with prefix ${JSON.stringify(e)}; this is a bug`);
163
+ return n + t.slice(e.length);
164
+ }
165
+ function q(t, e, n) {
166
+ if (!e)
167
+ return t + n;
168
+ if (t.slice(-e.length) != e)
169
+ throw Error(`string ${JSON.stringify(t)} doesn't end with suffix ${JSON.stringify(e)}; this is a bug`);
170
+ return t.slice(0, -e.length) + n;
171
+ }
172
+ function W(t, e) {
173
+ return $(t, e, "");
174
+ }
175
+ function O(t, e) {
176
+ return q(t, e, "");
177
+ }
178
+ function X(t, e) {
179
+ return e.slice(0, Le(t, e));
180
+ }
181
+ function Le(t, e) {
182
+ let n = 0;
183
+ t.length > e.length && (n = t.length - e.length);
184
+ let i = e.length;
185
+ t.length < e.length && (i = t.length);
186
+ const s = Array(i);
187
+ let r = 0;
188
+ s[0] = 0;
189
+ for (let l = 1; l < i; l++) {
190
+ for (e[l] == e[r] ? s[l] = s[r] : s[l] = r; r > 0 && e[l] != e[r]; )
191
+ r = s[r];
192
+ e[l] == e[r] && r++;
193
+ }
194
+ r = 0;
195
+ for (let l = n; l < t.length; l++) {
196
+ for (; r > 0 && t[l] != e[r]; )
197
+ r = s[r];
198
+ t[l] == e[r] && r++;
199
+ }
200
+ return r;
201
+ }
202
+ function Fe(t) {
203
+ return t.includes(`\r
204
+ `) && !t.startsWith(`
205
+ `) && !t.match(/[^\r]\n/);
206
+ }
207
+ function je(t) {
208
+ return !t.includes(`\r
209
+ `) && t.includes(`
210
+ `);
211
+ }
212
+ function _(t) {
213
+ let e;
214
+ for (e = t.length - 1; e >= 0 && t[e].match(/\s/); e--)
215
+ ;
216
+ return t.substring(e + 1);
217
+ }
218
+ function S(t) {
219
+ const e = t.match(/^\s*/);
220
+ return e ? e[0] : "";
221
+ }
222
+ const L = "a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}", Ae = new RegExp(`[${L}]+|\\s+|[^${L}]`, "ug");
223
+ class Ie extends E {
224
+ equals(e, n, i) {
225
+ return i.ignoreCase && (e = e.toLowerCase(), n = n.toLowerCase()), e.trim() === n.trim();
226
+ }
227
+ tokenize(e, n = {}) {
228
+ let i;
229
+ if (n.intlSegmenter) {
230
+ const l = n.intlSegmenter;
231
+ if (l.resolvedOptions().granularity != "word")
232
+ throw new Error('The segmenter passed must have a granularity of "word"');
233
+ i = Array.from(l.segment(e), (o) => o.segment);
234
+ } else
235
+ i = e.match(Ae) || [];
236
+ const s = [];
237
+ let r = null;
238
+ return i.forEach((l) => {
239
+ /\s/.test(l) ? r == null ? s.push(l) : s.push(s.pop() + l) : r != null && /\s/.test(r) ? s[s.length - 1] == r ? s.push(s.pop() + l) : s.push(r + l) : s.push(l), r = l;
240
+ }), s;
241
+ }
242
+ join(e) {
243
+ return e.map((n, i) => i == 0 ? n : n.replace(/^\s+/, "")).join("");
244
+ }
245
+ postProcess(e, n) {
246
+ if (!e || n.oneChangePerToken)
247
+ return e;
248
+ let i = null, s = null, r = null;
249
+ return e.forEach((l) => {
250
+ l.added ? s = l : l.removed ? r = l : ((s || r) && Z(i, r, s, l), i = l, s = null, r = null);
251
+ }), (s || r) && Z(i, r, s, null), e;
252
+ }
253
+ }
254
+ const ne = new Ie();
255
+ function ie(t, e, n) {
256
+ return n?.ignoreWhitespace != null && !n.ignoreWhitespace ? M(t, e, n) : ne.diff(t, e, n);
257
+ }
258
+ function Z(t, e, n, i) {
259
+ if (e && n) {
260
+ const s = S(e.value), r = _(e.value), l = S(n.value), o = _(n.value);
261
+ if (t) {
262
+ const f = V(s, l);
263
+ t.value = q(t.value, l, f), e.value = W(e.value, f), n.value = W(n.value, f);
264
+ }
265
+ if (i) {
266
+ const f = Y(r, o);
267
+ i.value = $(i.value, o, f), e.value = O(e.value, f), n.value = O(n.value, f);
268
+ }
269
+ } else if (n) {
270
+ if (t) {
271
+ const s = S(n.value);
272
+ n.value = n.value.substring(s.length);
273
+ }
274
+ if (i) {
275
+ const s = S(i.value);
276
+ i.value = i.value.substring(s.length);
277
+ }
278
+ } else if (t && i) {
279
+ const s = S(i.value), r = S(e.value), l = _(e.value), o = V(s, r);
280
+ e.value = W(e.value, o);
281
+ const f = Y(W(s, o), l);
282
+ e.value = O(e.value, f), i.value = $(i.value, s, f), t.value = q(t.value, s, s.slice(0, s.length - f.length));
283
+ } else if (i) {
284
+ const s = S(i.value), r = _(e.value), l = X(r, s);
285
+ e.value = O(e.value, l);
286
+ } else if (t) {
287
+ const s = _(t.value), r = S(e.value), l = X(s, r);
288
+ e.value = W(e.value, l);
289
+ }
290
+ }
291
+ class ze extends E {
292
+ tokenize(e) {
293
+ const n = new RegExp(`(\\r?\\n)|[${L}]+|[^\\S\\n\\r]+|[^${L}]`, "ug");
294
+ return e.match(n) || [];
295
+ }
296
+ }
297
+ const re = new ze();
298
+ function M(t, e, n) {
299
+ return re.diff(t, e, n);
300
+ }
301
+ function $e(t, e) {
302
+ if (typeof t == "function")
303
+ e.callback = t;
304
+ else if (t)
305
+ for (const n in t)
306
+ Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
307
+ return e;
308
+ }
309
+ class qe extends E {
310
+ constructor() {
311
+ super(...arguments), this.tokenize = le;
312
+ }
313
+ equals(e, n, i) {
314
+ return i.ignoreWhitespace ? ((!i.newlineIsToken || !e.includes(`
315
+ `)) && (e = e.trim()), (!i.newlineIsToken || !n.includes(`
316
+ `)) && (n = n.trim())) : i.ignoreNewlineAtEof && !i.newlineIsToken && (e.endsWith(`
317
+ `) && (e = e.slice(0, -1)), n.endsWith(`
318
+ `) && (n = n.slice(0, -1))), super.equals(e, n, i);
319
+ }
320
+ }
321
+ const R = new qe();
322
+ function F(t, e, n) {
323
+ return R.diff(t, e, n);
324
+ }
325
+ function se(t, e, n) {
326
+ return n = $e(n, { ignoreWhitespace: !0 }), R.diff(t, e, n);
327
+ }
328
+ function le(t, e) {
329
+ e.stripTrailingCr && (t = t.replace(/\r\n/g, `
330
+ `));
331
+ const n = [], i = t.split(/(\n|\r\n)/);
332
+ i[i.length - 1] || i.pop();
333
+ for (let s = 0; s < i.length; s++) {
334
+ const r = i[s];
335
+ s % 2 && !e.newlineIsToken ? n[n.length - 1] += r : n.push(r);
336
+ }
337
+ return n;
338
+ }
339
+ function He(t) {
340
+ return t == "." || t == "!" || t == "?";
341
+ }
342
+ class Me extends E {
343
+ tokenize(e) {
344
+ var n;
345
+ const i = [];
346
+ let s = 0;
347
+ for (let r = 0; r < e.length; r++) {
348
+ if (r == e.length - 1) {
349
+ i.push(e.slice(s));
350
+ break;
351
+ }
352
+ if (He(e[r]) && e[r + 1].match(/\s/)) {
353
+ for (i.push(e.slice(s, r + 1)), r = s = r + 1; !((n = e[r + 1]) === null || n === void 0) && n.match(/\s/); )
354
+ r++;
355
+ i.push(e.slice(s, r + 1)), s = r + 1;
356
+ }
357
+ }
358
+ return i;
359
+ }
360
+ }
361
+ const oe = new Me();
362
+ function fe(t, e, n) {
363
+ return oe.diff(t, e, n);
364
+ }
365
+ class Re extends E {
366
+ tokenize(e) {
367
+ return e.split(/([{}:;,]|\s+)/);
368
+ }
369
+ }
370
+ const ae = new Re();
371
+ function ce(t, e, n) {
372
+ return ae.diff(t, e, n);
373
+ }
374
+ class Je extends E {
375
+ constructor() {
376
+ super(...arguments), this.tokenize = le;
377
+ }
378
+ get useLongestToken() {
379
+ return !0;
380
+ }
381
+ castInput(e, n) {
382
+ const { undefinedReplacement: i, stringifyReplacer: s = (r, l) => typeof l > "u" ? i : l } = n;
383
+ return typeof e == "string" ? e : JSON.stringify(j(e, null, null, s), null, " ");
384
+ }
385
+ equals(e, n, i) {
386
+ return super.equals(e.replace(/,([\r\n])/g, "$1"), n.replace(/,([\r\n])/g, "$1"), i);
387
+ }
388
+ }
389
+ const ue = new Je();
390
+ function de(t, e, n) {
391
+ return ue.diff(t, e, n);
392
+ }
393
+ function j(t, e, n, i, s) {
394
+ e = e || [], n = n || [], i && (t = i(s === void 0 ? "" : s, t));
395
+ let r;
396
+ for (r = 0; r < e.length; r += 1)
397
+ if (e[r] === t)
398
+ return n[r];
399
+ let l;
400
+ if (Object.prototype.toString.call(t) === "[object Array]") {
401
+ for (e.push(t), l = new Array(t.length), n.push(l), r = 0; r < t.length; r += 1)
402
+ l[r] = j(t[r], e, n, i, String(r));
403
+ return e.pop(), n.pop(), l;
404
+ }
405
+ if (t && t.toJSON && (t = t.toJSON()), typeof t == "object" && t !== null) {
406
+ e.push(t), l = {}, n.push(l);
407
+ const o = [];
408
+ let f;
409
+ for (f in t)
410
+ Object.prototype.hasOwnProperty.call(t, f) && o.push(f);
411
+ for (o.sort(), r = 0; r < o.length; r += 1)
412
+ f = o[r], l[f] = j(t[f], e, n, i, f);
413
+ e.pop(), n.pop();
414
+ } else
415
+ l = t;
416
+ return l;
417
+ }
418
+ class Ue extends E {
419
+ tokenize(e) {
420
+ return e.slice();
421
+ }
422
+ join(e) {
423
+ return e;
424
+ }
425
+ removeEmpty(e) {
426
+ return e;
427
+ }
428
+ }
429
+ const me = new Ue();
430
+ function he(t, e, n) {
431
+ return me.diff(t, e, n);
432
+ }
433
+ function ge(t) {
434
+ return Array.isArray(t) ? t.map((e) => ge(e)) : Object.assign(Object.assign({}, t), { hunks: t.hunks.map((e) => Object.assign(Object.assign({}, e), { lines: e.lines.map((n, i) => {
435
+ var s;
436
+ return n.startsWith("\\") || n.endsWith("\r") || !((s = e.lines[i + 1]) === null || s === void 0) && s.startsWith("\\") ? n : n + "\r";
437
+ }) })) });
438
+ }
439
+ function ve(t) {
440
+ return Array.isArray(t) ? t.map((e) => ve(e)) : Object.assign(Object.assign({}, t), { hunks: t.hunks.map((e) => Object.assign(Object.assign({}, e), { lines: e.lines.map((n) => n.endsWith("\r") ? n.substring(0, n.length - 1) : n) })) });
441
+ }
442
+ function Qe(t) {
443
+ return Array.isArray(t) || (t = [t]), !t.some((e) => e.hunks.some((n) => n.lines.some((i) => !i.startsWith("\\") && i.endsWith("\r"))));
444
+ }
445
+ function Be(t) {
446
+ return Array.isArray(t) || (t = [t]), t.some((e) => e.hunks.some((n) => n.lines.some((i) => i.endsWith("\r")))) && t.every((e) => e.hunks.every((n) => n.lines.every((i, s) => {
447
+ var r;
448
+ return i.startsWith("\\") || i.endsWith("\r") || ((r = n.lines[s + 1]) === null || r === void 0 ? void 0 : r.startsWith("\\"));
449
+ })));
450
+ }
451
+ function J(t) {
452
+ const e = t.split(/\n/), n = [];
453
+ let i = 0;
454
+ function s() {
455
+ const o = {};
456
+ for (n.push(o); i < e.length; ) {
457
+ const f = e[i];
458
+ if (/^(---|\+\+\+|@@)\s/.test(f))
459
+ break;
460
+ const h = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(f);
461
+ h && (o.index = h[1]), i++;
462
+ }
463
+ for (r(o), r(o), o.hunks = []; i < e.length; ) {
464
+ const f = e[i];
465
+ if (/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(f))
466
+ break;
467
+ if (/^@@/.test(f))
468
+ o.hunks.push(l());
469
+ else {
470
+ if (f)
471
+ throw new Error("Unknown line " + (i + 1) + " " + JSON.stringify(f));
472
+ i++;
473
+ }
474
+ }
475
+ }
476
+ function r(o) {
477
+ const f = /^(---|\+\+\+)\s+(.*)\r?$/.exec(e[i]);
478
+ if (f) {
479
+ const h = f[2].split(" ", 2), c = (h[1] || "").trim();
480
+ let g = h[0].replace(/\\\\/g, "\\");
481
+ /^".*"$/.test(g) && (g = g.substr(1, g.length - 2)), f[1] === "---" ? (o.oldFileName = g, o.oldHeader = c) : (o.newFileName = g, o.newHeader = c), i++;
482
+ }
483
+ }
484
+ function l() {
485
+ var o;
486
+ const f = i, h = e[i++], c = h.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/), g = {
487
+ oldStart: +c[1],
488
+ oldLines: typeof c[2] > "u" ? 1 : +c[2],
489
+ newStart: +c[3],
490
+ newLines: typeof c[4] > "u" ? 1 : +c[4],
491
+ lines: []
492
+ };
493
+ g.oldLines === 0 && (g.oldStart += 1), g.newLines === 0 && (g.newStart += 1);
494
+ let y = 0, w = 0;
495
+ for (; i < e.length && (w < g.oldLines || y < g.newLines || !((o = e[i]) === null || o === void 0) && o.startsWith("\\")); i++) {
496
+ const m = e[i].length == 0 && i != e.length - 1 ? " " : e[i][0];
497
+ if (m === "+" || m === "-" || m === " " || m === "\\")
498
+ g.lines.push(e[i]), m === "+" ? y++ : m === "-" ? w++ : m === " " && (y++, w++);
499
+ else
500
+ throw new Error(`Hunk at line ${f + 1} contained invalid line ${e[i]}`);
501
+ }
502
+ if (!y && g.newLines === 1 && (g.newLines = 0), !w && g.oldLines === 1 && (g.oldLines = 0), y !== g.newLines)
503
+ throw new Error("Added line count did not match for hunk at line " + (f + 1));
504
+ if (w !== g.oldLines)
505
+ throw new Error("Removed line count did not match for hunk at line " + (f + 1));
506
+ return g;
507
+ }
508
+ for (; i < e.length; )
509
+ s();
510
+ return n;
511
+ }
512
+ function Ve(t, e, n) {
513
+ let i = !0, s = !1, r = !1, l = 1;
514
+ return function o() {
515
+ if (i && !r) {
516
+ if (s ? l++ : i = !1, t + l <= n)
517
+ return t + l;
518
+ r = !0;
519
+ }
520
+ if (!s)
521
+ return r || (i = !0), e <= t - l ? t - l++ : (s = !0, o());
522
+ };
523
+ }
524
+ function pe(t, e, n = {}) {
525
+ let i;
526
+ if (typeof e == "string" ? i = J(e) : Array.isArray(e) ? i = e : i = [e], i.length > 1)
527
+ throw new Error("applyPatch only works with a single input.");
528
+ return Ye(t, i[0], n);
529
+ }
530
+ function Ye(t, e, n = {}) {
531
+ (n.autoConvertLineEndings || n.autoConvertLineEndings == null) && (Fe(t) && Qe(e) ? e = ge(e) : je(t) && Be(e) && (e = ve(e)));
532
+ const i = t.split(`
533
+ `), s = e.hunks, r = n.compareLine || ((m, v, x, C) => v === C), l = n.fuzzFactor || 0;
534
+ let o = 0;
535
+ if (l < 0 || !Number.isInteger(l))
536
+ throw new Error("fuzzFactor must be a non-negative integer");
537
+ if (!s.length)
538
+ return t;
539
+ let f = "", h = !1, c = !1;
540
+ for (let m = 0; m < s[s.length - 1].lines.length; m++) {
541
+ const v = s[s.length - 1].lines[m];
542
+ v[0] == "\\" && (f[0] == "+" ? h = !0 : f[0] == "-" && (c = !0)), f = v;
543
+ }
544
+ if (h) {
545
+ if (c) {
546
+ if (!l && i[i.length - 1] == "")
547
+ return !1;
548
+ } else if (i[i.length - 1] == "")
549
+ i.pop();
550
+ else if (!l)
551
+ return !1;
552
+ } else if (c) {
553
+ if (i[i.length - 1] != "")
554
+ i.push("");
555
+ else if (!l)
556
+ return !1;
557
+ }
558
+ function g(m, v, x, C = 0, d = !0, u = [], p = 0) {
559
+ let k = 0, D = !1;
560
+ for (; C < m.length; C++) {
561
+ const b = m[C], N = b.length > 0 ? b[0] : " ", z = b.length > 0 ? b.substr(1) : b;
562
+ if (N === "-")
563
+ if (r(v + 1, i[v], N, z))
564
+ v++, k = 0;
565
+ else
566
+ return !x || i[v] == null ? null : (u[p] = i[v], g(m, v + 1, x - 1, C, !1, u, p + 1));
567
+ if (N === "+") {
568
+ if (!d)
569
+ return null;
570
+ u[p] = z, p++, k = 0, D = !0;
571
+ }
572
+ if (N === " ")
573
+ if (k++, u[p] = i[v], r(v + 1, i[v], N, z))
574
+ p++, d = !0, D = !1, v++;
575
+ else
576
+ return D || !x ? null : i[v] && (g(m, v + 1, x - 1, C + 1, !1, u, p + 1) || g(m, v + 1, x - 1, C, !1, u, p + 1)) || g(m, v, x - 1, C + 1, !1, u, p);
577
+ }
578
+ return p -= k, v -= k, u.length = p, {
579
+ patchedLines: u,
580
+ oldLineLastI: v - 1
581
+ };
582
+ }
583
+ const y = [];
584
+ let w = 0;
585
+ for (let m = 0; m < s.length; m++) {
586
+ const v = s[m];
587
+ let x;
588
+ const C = i.length - v.oldLines + l;
589
+ let d;
590
+ for (let u = 0; u <= l; u++) {
591
+ d = v.oldStart + w - 1;
592
+ const p = Ve(d, o, C);
593
+ for (; d !== void 0 && (x = g(v.lines, d, u), !x); d = p())
594
+ ;
595
+ if (x)
596
+ break;
597
+ }
598
+ if (!x)
599
+ return !1;
600
+ for (let u = o; u < d; u++)
601
+ y.push(i[u]);
602
+ for (let u = 0; u < x.patchedLines.length; u++) {
603
+ const p = x.patchedLines[u];
604
+ y.push(p);
605
+ }
606
+ o = x.oldLineLastI + 1, w = d + 1 - v.oldStart;
607
+ }
608
+ for (let m = o; m < i.length; m++)
609
+ y.push(i[m]);
610
+ return y.join(`
611
+ `);
612
+ }
613
+ function Xe(t, e) {
614
+ const n = typeof t == "string" ? J(t) : t;
615
+ let i = 0;
616
+ function s() {
617
+ const r = n[i++];
618
+ if (!r)
619
+ return e.complete();
620
+ e.loadFile(r, function(l, o) {
621
+ if (l)
622
+ return e.complete(l);
623
+ const f = pe(o, r, e);
624
+ e.patched(r, f, function(h) {
625
+ if (h)
626
+ return e.complete(h);
627
+ s();
628
+ });
629
+ });
630
+ }
631
+ s();
632
+ }
633
+ function we(t) {
634
+ return Array.isArray(t) ? t.map((e) => we(e)).reverse() : Object.assign(Object.assign({}, t), { oldFileName: t.newFileName, oldHeader: t.newHeader, newFileName: t.oldFileName, newHeader: t.oldHeader, hunks: t.hunks.map((e) => ({
635
+ oldLines: e.newLines,
636
+ oldStart: e.newStart,
637
+ newLines: e.oldLines,
638
+ newStart: e.oldStart,
639
+ lines: e.lines.map((n) => n.startsWith("-") ? `+${n.slice(1)}` : n.startsWith("+") ? `-${n.slice(1)}` : n)
640
+ })) });
641
+ }
642
+ function H(t, e, n, i, s, r, l) {
643
+ let o;
644
+ l ? typeof l == "function" ? o = { callback: l } : o = l : o = {}, typeof o.context > "u" && (o.context = 4);
645
+ const f = o.context;
646
+ if (o.newlineIsToken)
647
+ throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
648
+ if (o.callback) {
649
+ const { callback: c } = o;
650
+ F(n, i, Object.assign(Object.assign({}, o), { callback: (g) => {
651
+ const y = h(g);
652
+ c(y);
653
+ } }));
654
+ } else
655
+ return h(F(n, i, o));
656
+ function h(c) {
657
+ if (!c)
658
+ return;
659
+ c.push({ value: "", lines: [] });
660
+ function g(d) {
661
+ return d.map(function(u) {
662
+ return " " + u;
663
+ });
664
+ }
665
+ const y = [];
666
+ let w = 0, m = 0, v = [], x = 1, C = 1;
667
+ for (let d = 0; d < c.length; d++) {
668
+ const u = c[d], p = u.lines || Ge(u.value);
669
+ if (u.lines = p, u.added || u.removed) {
670
+ if (!w) {
671
+ const k = c[d - 1];
672
+ w = x, m = C, k && (v = f > 0 ? g(k.lines.slice(-f)) : [], w -= v.length, m -= v.length);
673
+ }
674
+ for (const k of p)
675
+ v.push((u.added ? "+" : "-") + k);
676
+ u.added ? C += p.length : x += p.length;
677
+ } else {
678
+ if (w)
679
+ if (p.length <= f * 2 && d < c.length - 2)
680
+ for (const k of g(p))
681
+ v.push(k);
682
+ else {
683
+ const k = Math.min(p.length, f);
684
+ for (const b of g(p.slice(0, k)))
685
+ v.push(b);
686
+ const D = {
687
+ oldStart: w,
688
+ oldLines: x - w + k,
689
+ newStart: m,
690
+ newLines: C - m + k,
691
+ lines: v
692
+ };
693
+ y.push(D), w = 0, m = 0, v = [];
694
+ }
695
+ x += p.length, C += p.length;
696
+ }
697
+ }
698
+ for (const d of y)
699
+ for (let u = 0; u < d.lines.length; u++)
700
+ d.lines[u].endsWith(`
701
+ `) ? d.lines[u] = d.lines[u].slice(0, -1) : (d.lines.splice(u + 1, 0, "\"), u++);
702
+ return {
703
+ oldFileName: t,
704
+ newFileName: e,
705
+ oldHeader: s,
706
+ newHeader: r,
707
+ hunks: y
708
+ };
709
+ }
710
+ }
711
+ function A(t) {
712
+ if (Array.isArray(t))
713
+ return t.map(A).join(`
714
+ `);
715
+ const e = [];
716
+ t.oldFileName == t.newFileName && e.push("Index: " + t.oldFileName), e.push("==================================================================="), e.push("--- " + t.oldFileName + (typeof t.oldHeader > "u" ? "" : " " + t.oldHeader)), e.push("+++ " + t.newFileName + (typeof t.newHeader > "u" ? "" : " " + t.newHeader));
717
+ for (let n = 0; n < t.hunks.length; n++) {
718
+ const i = t.hunks[n];
719
+ i.oldLines === 0 && (i.oldStart -= 1), i.newLines === 0 && (i.newStart -= 1), e.push("@@ -" + i.oldStart + "," + i.oldLines + " +" + i.newStart + "," + i.newLines + " @@");
720
+ for (const s of i.lines)
721
+ e.push(s);
722
+ }
723
+ return e.join(`
724
+ `) + `
725
+ `;
726
+ }
727
+ function U(t, e, n, i, s, r, l) {
728
+ if (typeof l == "function" && (l = { callback: l }), l?.callback) {
729
+ const { callback: o } = l;
730
+ H(t, e, n, i, s, r, Object.assign(Object.assign({}, l), { callback: (f) => {
731
+ o(f ? A(f) : void 0);
732
+ } }));
733
+ } else {
734
+ const o = H(t, e, n, i, s, r, l);
735
+ return o ? A(o) : void 0;
736
+ }
737
+ }
738
+ function Ze(t, e, n, i, s, r) {
739
+ return U(t, t, e, n, i, s, r);
740
+ }
741
+ function Ge(t) {
742
+ const e = t.endsWith(`
743
+ `), n = t.split(`
744
+ `).map((i) => i + `
745
+ `);
746
+ return e ? n.pop() : n.push(n.pop().slice(0, -1)), n;
747
+ }
748
+ function Ke(t) {
749
+ const e = [];
750
+ let n, i;
751
+ for (let s = 0; s < t.length; s++)
752
+ n = t[s], n.added ? i = 1 : n.removed ? i = -1 : i = 0, e.push([i, n.value]);
753
+ return e;
754
+ }
755
+ function et(t) {
756
+ const e = [];
757
+ for (let n = 0; n < t.length; n++) {
758
+ const i = t[n];
759
+ i.added ? e.push("<ins>") : i.removed && e.push("<del>"), e.push(tt(i.value)), i.added ? e.push("</ins>") : i.removed && e.push("</del>");
760
+ }
761
+ return e.join("");
762
+ }
763
+ function tt(t) {
764
+ let e = t;
765
+ return e = e.replace(/&/g, "&amp;"), e = e.replace(/</g, "&lt;"), e = e.replace(/>/g, "&gt;"), e = e.replace(/"/g, "&quot;"), e;
766
+ }
767
+ const nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
768
+ __proto__: null,
769
+ Diff: E,
770
+ applyPatch: pe,
771
+ applyPatches: Xe,
772
+ arrayDiff: me,
773
+ canonicalize: j,
774
+ characterDiff: ee,
775
+ convertChangesToDMP: Ke,
776
+ convertChangesToXML: et,
777
+ createPatch: Ze,
778
+ createTwoFilesPatch: U,
779
+ cssDiff: ae,
780
+ diffArrays: he,
781
+ diffChars: te,
782
+ diffCss: ce,
783
+ diffJson: de,
784
+ diffLines: F,
785
+ diffSentences: fe,
786
+ diffTrimmedLines: se,
787
+ diffWords: ie,
788
+ diffWordsWithSpace: M,
789
+ formatPatch: A,
790
+ jsonDiff: ue,
791
+ lineDiff: R,
792
+ parsePatch: J,
793
+ reversePatch: we,
794
+ sentenceDiff: oe,
795
+ structuredPatch: H,
796
+ wordDiff: ne,
797
+ wordsWithSpaceDiff: re
798
+ }, Symbol.toStringTag, { value: "Module" }));
799
+ class it {
800
+ constructor(e) {
801
+ this.ctx = e, this.JsDiff = nt, this.diffChars = te, this.diffWords = ie, this.diffWordsWithSpace = M, this.diffLines = F, this.diffTrimmedLines = se, this.diffSentences = fe, this.diffCss = ce, this.diffJson = de, this.diffArrays = he, this.createTwoFilesPatch = U, this.ctx.set("jsdiff", this);
802
+ }
803
+ }
804
+ const rt = {
805
+ "diff-container": "_diff-container_lq0si_2"
806
+ }, st = (t) => {
807
+ let { user: e, target: n, ctx: i } = t;
808
+ const s = i.getUrl.bind(i);
809
+ return /* @__PURE__ */ a("span", { className: "mw-userlinks", children: [
810
+ /* @__PURE__ */ a("a", { href: s(`User:${e}`), className: "mw-userlink", target: n, children: e }),
811
+ " ",
812
+ /* @__PURE__ */ a("span", { className: "mw-usertoollinks", children: [
813
+ "(",
814
+ /* @__PURE__ */ a("a", { href: s(`User_talk:${e}`), className: "mw-usertoollinks-talk", target: n, children: "talk" }),
815
+ " | ",
816
+ /* @__PURE__ */ a(
817
+ "a",
818
+ {
819
+ href: s(`Special:Contributions/${e}`),
820
+ className: "mw-usertoollinks-contribs",
821
+ target: n,
822
+ children: "contribs"
823
+ }
824
+ ),
825
+ " | ",
826
+ /* @__PURE__ */ a(
827
+ "a",
828
+ {
829
+ href: s(`Special:Block/${e}`),
830
+ className: "mw-usertoollinks-block",
831
+ target: n,
832
+ children: "block"
833
+ }
834
+ ),
835
+ ")"
836
+ ] })
837
+ ] });
838
+ };
839
+ var T = /* @__PURE__ */ ((t) => (t.update = "ipe:diff-table/update", t.edit = "ipe:diff-table/edit", t))(T || {});
840
+ const lt = new Intl.DateTimeFormat(void 0, {
841
+ dateStyle: "medium",
842
+ timeStyle: "medium"
843
+ }).format, G = (t) => {
844
+ let e = ["diff-title"];
845
+ if (t.type === "from" ? e.push("diff-otitle") : t.type === "to" && e.push("diff-ntitle"), !t.pageid || !t.userid)
846
+ return /* @__PURE__ */ a("td", { colSpan: 2, className: e, children: /* @__PURE__ */ a("div", { className: "mw-diff-title--title", children: t.type === "from" ? "Original content" : t.type === "to" ? "Your content" : "" }) });
847
+ const n = (i) => {
848
+ i.preventDefault(), i.target.dispatchEvent(
849
+ new CustomEvent("ipe:diff-table/edit", {
850
+ detail: { revid: t.revid },
851
+ bubbles: !0
852
+ })
853
+ );
854
+ };
855
+ return /* @__PURE__ */ a("td", { colSpan: 2, className: e, children: [
856
+ /* @__PURE__ */ a("div", { className: "mw-diff-title--title", children: [
857
+ t.pagetitle || t.timestamp,
858
+ t.revid ? ` (rev#${t.revid})` : ""
859
+ ] }),
860
+ /* @__PURE__ */ a("div", { className: "mw-diff-title--actions", children: /* @__PURE__ */ a(
861
+ "a",
862
+ {
863
+ href: t.ctx.getUrl("", { action: "edit", oldid: t.revid }),
864
+ onClick: n,
865
+ children: [
866
+ /* @__PURE__ */ a(Pe, { style: "width: 1em; height: 1em" }),
867
+ "Quick edit"
868
+ ]
869
+ }
870
+ ) }),
871
+ /* @__PURE__ */ a("div", { className: "mw-diff-title--user", children: t.username && /* @__PURE__ */ a(st, { ctx: t.ctx, user: t.username, target: "_blank" }) }),
872
+ /* @__PURE__ */ a("div", { className: "mw-diff-title--timestamp", children: t.timestamp && lt(new Date(t.timestamp)) }),
873
+ /* @__PURE__ */ a("div", { className: "mw-diff-title--comment", children: t.parsedcomment && /* @__PURE__ */ a(Ee, { children: [
874
+ "(",
875
+ /* @__PURE__ */ a("i", { innerHTML: t.parsedcomment }),
876
+ ")"
877
+ ] }) })
878
+ ] });
879
+ }, ot = (t) => {
880
+ const e = t.data;
881
+ if (!e.prev && !e.next)
882
+ return null;
883
+ const n = (i, s, r) => {
884
+ i.preventDefault(), i.target.dispatchEvent(
885
+ new CustomEvent("ipe:diff-table/update", {
886
+ detail: { fromrev: s, torev: r },
887
+ bubbles: !0
888
+ })
889
+ );
890
+ };
891
+ return /* @__PURE__ */ a("tr", { className: "mw-diff-title--navigation", children: [
892
+ /* @__PURE__ */ a("td", { colSpan: 2, children: e.prev ? /* @__PURE__ */ a(
893
+ "a",
894
+ {
895
+ href: t.ctx.getUrl("", { diff: e.prev, oldid: e.fromrevid }),
896
+ onClick: (i) => n(i, e.prev, e.fromrevid),
897
+ children: "← Previous"
898
+ }
899
+ ) : /* @__PURE__ */ a("i", { children: "Oldest version" }) }),
900
+ /* @__PURE__ */ a("td", { colSpan: 2, children: e.next ? /* @__PURE__ */ a(
901
+ "a",
902
+ {
903
+ href: t.ctx.getUrl("", { diff: e.next, oldid: e.torevid }),
904
+ onClick: (i) => n(i, e.torevid, e.next),
905
+ children: "Next →"
906
+ }
907
+ ) : /* @__PURE__ */ a("i", { children: "Newest version" }) })
908
+ ] });
909
+ }, ft = (t) => {
910
+ const { data: e, ...n } = t, i = /* @__PURE__ */ a("table", { className: "theme-ipe diff diff-type-table", "data-mw": "interface", ...n, children: [
911
+ /* @__PURE__ */ a("colgroup", { children: [
912
+ /* @__PURE__ */ a("col", { className: "diff-marker" }),
913
+ /* @__PURE__ */ a("col", { className: "diff-content" }),
914
+ /* @__PURE__ */ a("col", { className: "diff-marker" }),
915
+ /* @__PURE__ */ a("col", { className: "diff-content" })
916
+ ] }),
917
+ /* @__PURE__ */ a("tbody", { children: [
918
+ /* @__PURE__ */ a("tr", { children: [
919
+ /* @__PURE__ */ a(
920
+ G,
921
+ {
922
+ ctx: t.ctx,
923
+ type: "from",
924
+ pageid: e.fromid,
925
+ pagetitle: e.fromtitle,
926
+ revid: e.fromrevid,
927
+ size: e.fromsize,
928
+ timestamp: e.fromtimestamp,
929
+ username: e.fromuser,
930
+ userid: e.fromuserid,
931
+ comment: e.fromcomment,
932
+ parsedcomment: e.fromparsedcomment
933
+ }
934
+ ),
935
+ /* @__PURE__ */ a(
936
+ G,
937
+ {
938
+ ctx: t.ctx,
939
+ type: "to",
940
+ pageid: e.toid,
941
+ pagetitle: e.totitle,
942
+ revid: e.torevid,
943
+ size: e.tosize,
944
+ timestamp: e.totimestamp,
945
+ username: e.touser,
946
+ userid: e.touserid,
947
+ comment: e.tocomment,
948
+ parsedcomment: e.toparsedcomment
949
+ }
950
+ )
951
+ ] }),
952
+ /* @__PURE__ */ a(ot, { data: e, ctx: t.ctx }),
953
+ /* @__PURE__ */ a("div", { id: "diffbody" }),
954
+ /* @__PURE__ */ a("tr", { className: "diff-size", style: { textAlign: "center" }, children: [
955
+ /* @__PURE__ */ a("td", { colSpan: 2, className: "diff-size-old", children: e.fromsize !== void 0 && `${e.fromsize} bytes` }),
956
+ /* @__PURE__ */ a("td", { colSpan: 2, className: "diff-size-new", children: e.tosize !== void 0 && `${e.tosize} bytes` })
957
+ ] })
958
+ ] })
959
+ ] });
960
+ return i.querySelector("#diffbody").outerHTML = e.body || (/* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a("td", { colSpan: 4, children: /* @__PURE__ */ a(
961
+ "div",
962
+ {
963
+ style: {
964
+ display: "flex",
965
+ justifyContent: "center",
966
+ alignItems: "center",
967
+ height: "5rem"
968
+ },
969
+ children: /* @__PURE__ */ a("i", { children: "No changes" })
970
+ }
971
+ ) }) })).outerHTML, i;
972
+ }, at = (t, e = document) => e.querySelector(t), ct = (t, e = document) => e.querySelectorAll(t);
973
+ var ut = Object.create, Q = Object.defineProperty, dt = Object.getOwnPropertyDescriptor, ye = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), xe = (t) => {
974
+ throw TypeError(t);
975
+ }, mt = (t, e, n) => e in t ? Q(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, ht = (t, e) => Q(t, "name", { value: e, configurable: !0 }), gt = (t) => [, , , ut(t?.[ye("metadata")] ?? null)], vt = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], ke = (t) => t !== void 0 && typeof t != "function" ? xe("Function expected") : t, pt = (t, e, n, i, s) => ({ kind: vt[t], name: e, metadata: i, addInitializer: (r) => n._ ? xe("Already initialized") : s.push(ke(r || null)) }), wt = (t, e) => mt(e, ye("metadata"), t[3]), yt = (t, e, n, i) => {
976
+ for (var s = 0, r = t[e >> 1], l = r && r.length; s < l; s++) r[s].call(n);
977
+ return i;
978
+ }, xt = (t, e, n, i, s, r) => {
979
+ var l, o, f, h = e & 7, c = !1, g = 0, y = t[g] || (t[g] = []), w = h && (s = s.prototype, h < 5 && (h > 3 || !c) && dt(s, n));
980
+ ht(s, n);
981
+ for (var m = i.length - 1; m >= 0; m--)
982
+ f = pt(h, n, o = {}, t[3], y), l = (0, i[m])(s, f), o._ = 1, ke(l) && (s = l);
983
+ return wt(t, s), w && Q(s, n, w), c ? h ^ 4 ? r : w : s;
984
+ }, Ce, B, be;
985
+ const De = [
986
+ "diffChars",
987
+ "diffWords",
988
+ "diffSentences",
989
+ "diffLines",
990
+ "createTwoFilesPatch"
991
+ ];
992
+ Ce = [Se(["jsdiff", "wiki", "getUrl"]), We(
993
+ P.object({
994
+ "quickDiff.preferredCompareMode": P.union([P.const("jsDiff"), P.const("mwApi")]).description("The preferred comparison mode for quick diff").default("mwApi"),
995
+ "quickDiff.jsDiff.defaultType": P.union(De.map((t) => P.const(t))).description("The default diff type for JsDiff").default("diffSentences")
996
+ }).description("Quick Diff Preferences"),
997
+ {
998
+ "quickDiff.preferredCompareMode": "mwApi",
999
+ "quickDiff.jsDiff.defaultType": "diffSentences"
1000
+ }
1001
+ )];
1002
+ class I extends (be = K) {
1003
+ constructor(e) {
1004
+ super(e, {}, "quick-diff"), this.ctx = e, this.VALID_DIFF_TYPES = De, this.COMPARE_API_DEFAULT_OPTIONS = {
1005
+ prop: [
1006
+ "comment",
1007
+ "diff",
1008
+ "diffsize",
1009
+ "ids",
1010
+ "parsedcomment",
1011
+ "size",
1012
+ "timestamp",
1013
+ "title",
1014
+ "user",
1015
+ "rel"
1016
+ ].join("|"),
1017
+ difftype: "table"
1018
+ };
1019
+ }
1020
+ start() {
1021
+ this.ctx.set("quickDiff", this), this.ctx.on("quick-edit/wiki-page", this.injectQuickEdit.bind(this)), window.RLQ.push(this.injectHistoryPage.bind(this));
1022
+ }
1023
+ stop() {
1024
+ this.ctx.off("quick-edit/wiki-page", this.injectQuickEdit.bind(this));
1025
+ }
1026
+ injectHistoryPage() {
1027
+ const e = at("#mw-history-compare");
1028
+ if (!e)
1029
+ return;
1030
+ ct(".mw-history-compareselectedversions-button", e).forEach((i) => {
1031
+ i.after(
1032
+ /* @__PURE__ */ a(
1033
+ "button",
1034
+ {
1035
+ className: "cdx-button",
1036
+ onClick: (s) => {
1037
+ s.preventDefault();
1038
+ const r = new FormData(e), l = Number(r.get("oldid")) || 0, o = Number(r.get("diff")) || 0;
1039
+ if (!r.get("title") || !l || !o)
1040
+ return this.logger.warn("Missing title or revision IDs");
1041
+ this.comparePages({
1042
+ fromrev: l,
1043
+ torev: o
1044
+ });
1045
+ },
1046
+ children: "Quick Diff"
1047
+ }
1048
+ )
1049
+ );
1050
+ });
1051
+ }
1052
+ injectQuickEdit({ modal: e, wikiPage: n }) {
1053
+ if (n.pageid === 0)
1054
+ return;
1055
+ let i;
1056
+ e.addButton(
1057
+ {
1058
+ label: "Diff",
1059
+ side: "left",
1060
+ keyPress: "ctrl-d",
1061
+ className: "btn btn-secondary",
1062
+ method: () => {
1063
+ const s = n.title, r = n.revisions?.[0]?.content || "", l = e.get$content().querySelector('textarea[name="text"]')?.value || "";
1064
+ return r === l ? this.ctx.modal.notify("info", { title: "Quick Diff", content: "No changes" }) : (i = this.comparePages(
1065
+ {
1066
+ fromtitle: s,
1067
+ fromtext: r,
1068
+ totitle: s,
1069
+ totext: l,
1070
+ topst: !0
1071
+ },
1072
+ i,
1073
+ {
1074
+ backdrop: !1,
1075
+ draggable: !0
1076
+ }
1077
+ ), i);
1078
+ }
1079
+ },
1080
+ 2
1081
+ ), e.on(e.Event.Close, () => {
1082
+ i?.destroy(), i = void 0;
1083
+ });
1084
+ }
1085
+ simpleTextDiff(e, n) {
1086
+ const i = this.ctx.modal.show({
1087
+ title: "Quick Diff",
1088
+ className: "in-page-edit ipe-quickDiff"
1089
+ });
1090
+ i.show();
1091
+ const s = /* @__PURE__ */ a("pre", { className: rt["diff-container"] }), r = /* @__PURE__ */ a(
1092
+ "div",
1093
+ {
1094
+ style: {
1095
+ display: "flex",
1096
+ gap: "1em"
1097
+ },
1098
+ children: this.VALID_DIFF_TYPES.map((l, o) => /* @__PURE__ */ a(
1099
+ _e,
1100
+ {
1101
+ name: "diffType",
1102
+ value: l,
1103
+ label: l,
1104
+ inputProps: {
1105
+ checked: o === 0
1106
+ }
1107
+ }
1108
+ ))
1109
+ }
1110
+ );
1111
+ i.setContent(
1112
+ /* @__PURE__ */ a("section", { children: [
1113
+ r,
1114
+ s
1115
+ ] })
1116
+ ), r.querySelectorAll('input[name="diffType"]').forEach((l) => {
1117
+ l.addEventListener("change", () => {
1118
+ const o = this.renderJsDiff(e, n, l.value);
1119
+ s.textContent = "", s.appendChild(o);
1120
+ });
1121
+ }), r.querySelector('input[name="diffType"]').dispatchEvent(new Event("change"));
1122
+ }
1123
+ /**
1124
+ * TODO: 类型体操
1125
+ */
1126
+ renderJsDiff(e, n, i = "diffSentences") {
1127
+ const s = document.createDocumentFragment();
1128
+ let r;
1129
+ if (i === "createTwoFilesPatch") {
1130
+ let l = !1;
1131
+ r = this.ctx.jsdiff.createTwoFilesPatch("original.txt", "modified.txt", e, n).split(`
1132
+ `).map(function(o) {
1133
+ const f = {
1134
+ value: o + `
1135
+ `
1136
+ };
1137
+ return o.startsWith("@@") ? (f.chunkHeader = !0, l = !0) : l && (o.startsWith("-") ? f.removed = !0 : o.startsWith("+") && (f.added = !0)), f;
1138
+ });
1139
+ } else {
1140
+ const l = this.ctx.jsdiff[i];
1141
+ if (!l)
1142
+ throw new Error(`Missing DiffEngine for ${i}`);
1143
+ r = l(e, n);
1144
+ }
1145
+ if (!Array.isArray(r))
1146
+ throw new Error("Missing diff result");
1147
+ for (let l = 0; l < r.length; l++) {
1148
+ if (r[l].added && r[l + 1] && r[l + 1].removed) {
1149
+ const f = r[l];
1150
+ r[l] = r[l + 1], r[l + 1] = f;
1151
+ }
1152
+ let o;
1153
+ r[l].removed ? (o = document.createElement("del"), o.appendChild(document.createTextNode(r[l].value))) : r[l].added ? (o = document.createElement("ins"), o.appendChild(document.createTextNode(r[l].value))) : r[l].chunkHeader ? (o = document.createElement("span"), o.setAttribute("class", "chunk-header"), o.appendChild(document.createTextNode(r[l].value))) : o = document.createTextNode(r[l].value), s.appendChild(o);
1154
+ }
1155
+ return s;
1156
+ }
1157
+ comparePages(e, n, i) {
1158
+ return !n || n.isDestroyed ? n = this.ctx.modal.createObject({
1159
+ title: "Loading diff...",
1160
+ content: "",
1161
+ className: "quick-diff",
1162
+ center: !1,
1163
+ ...i
1164
+ }).init() : n.removeButton("*"), n.setContent(
1165
+ /* @__PURE__ */ a(
1166
+ "section",
1167
+ {
1168
+ style: { height: "70vh", display: "flex", justifyContent: "center", alignItems: "center" },
1169
+ children: /* @__PURE__ */ a(Ne, {})
1170
+ }
1171
+ )
1172
+ ), n.bringToFront(), window.mw && mw.loader.getState("mediawiki.diff.styles") !== "ready" && mw.loader.load(["mediawiki.diff.styles"]), this.ctx.api.post({
1173
+ ...this.COMPARE_API_DEFAULT_OPTIONS,
1174
+ ...e,
1175
+ action: "compare",
1176
+ format: "json",
1177
+ formatversion: 2
1178
+ }).then((s) => {
1179
+ if (s.data?.error || s.data?.errors) {
1180
+ const o = [s.data?.error, ...s.data?.errors || []].filter(
1181
+ Boolean
1182
+ );
1183
+ throw new Error(o.map((f) => f.info).join(`
1184
+ `), { cause: s });
1185
+ }
1186
+ if (!s.data.compare)
1187
+ throw new Error("No compare data received", { cause: s });
1188
+ const {
1189
+ data: { compare: r }
1190
+ } = s;
1191
+ n.setTitle(
1192
+ r.fromtitle && r.totitle ? `${r.fromtitle}${r.fromrevid ? ` (${r.fromrevid})` : ""} ⇔ ${r.totitle}${r.torevid ? ` (${r.torevid})` : ""}` : "Differences"
1193
+ );
1194
+ let l;
1195
+ n.setContent(
1196
+ /* @__PURE__ */ a(
1197
+ "section",
1198
+ {
1199
+ style: {
1200
+ minHeight: "70vh"
1201
+ },
1202
+ children: /* @__PURE__ */ a(ft, { ref: (o) => l = o, data: r, ctx: this.ctx })
1203
+ }
1204
+ )
1205
+ ), l.addEventListener(
1206
+ T.update,
1207
+ (o) => {
1208
+ o.stopPropagation(), this.comparePages(
1209
+ {
1210
+ fromrev: o.detail.fromrev,
1211
+ torev: o.detail.torev
1212
+ },
1213
+ n,
1214
+ i
1215
+ );
1216
+ },
1217
+ { once: !0 }
1218
+ ), this.ctx.inject(["quickEdit"], (o) => {
1219
+ const f = (h) => {
1220
+ h.stopPropagation(), o.quickEdit({ revision: h.detail.revid });
1221
+ };
1222
+ l.addEventListener(T.edit, f), n.on(n.Event.Close, () => {
1223
+ l.removeEventListener(T.edit, f);
1224
+ });
1225
+ }), r.fromrevid && r.torevid && n.addButton({
1226
+ label: "Original Compare Page",
1227
+ side: "right",
1228
+ className: "btn btn-secondary",
1229
+ method: () => {
1230
+ window.location.href = this.ctx.getUrl("", {
1231
+ oldid: r.fromrevid,
1232
+ diff: r.torevid
1233
+ });
1234
+ }
1235
+ });
1236
+ }).catch((s) => {
1237
+ n.setContent(
1238
+ /* @__PURE__ */ a(Oe, { title: "Failed to load diff", type: "error", children: /* @__PURE__ */ a("pre", { children: s instanceof Error ? s.message : String(s) }) })
1239
+ );
1240
+ }), n.show();
1241
+ }
1242
+ }
1243
+ B = gt(be);
1244
+ I = xt(B, 0, "PluginQuickDiffCore", Ce, I);
1245
+ yt(B, 1, I);
1246
+ class St extends K {
1247
+ constructor(e) {
1248
+ super(e, {}, "quick-diff-loader"), this.ctx = e, e.plugin(it), e.plugin(I);
1249
+ }
1250
+ static {
1251
+ this.inject = ["api", "wikiPage", "modal"];
1252
+ }
1253
+ }
1254
+ export {
1255
+ St as PluginQuickDiff
1256
+ };
1257
+ //# sourceMappingURL=index--xn9BebC.js.map