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