@inpageedit/core 0.15.0 → 0.16.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 (100) hide show
  1. package/dist/{ActionButton-CRjo_l3y.js → ActionButton-B6OUgtHx.js} +2 -2
  2. package/dist/{ActionButton-CRjo_l3y.js.map → ActionButton-B6OUgtHx.js.map} +1 -1
  3. package/dist/CheckBox-Dx3r3LQz.js +13 -0
  4. package/dist/CheckBox-Dx3r3LQz.js.map +1 -0
  5. package/dist/IconQuickDiff-BkbxyY-d.js +29 -0
  6. package/dist/IconQuickDiff-BkbxyY-d.js.map +1 -0
  7. package/dist/IconQuickEdit-BiRYADU_.js +68 -0
  8. package/dist/IconQuickEdit-BiRYADU_.js.map +1 -0
  9. package/dist/IconUpload-Bz4BW_nc.js +27 -0
  10. package/dist/IconUpload-Bz4BW_nc.js.map +1 -0
  11. package/dist/InPageEdit.js +20 -0
  12. package/dist/InPageEdit.js.map +1 -0
  13. package/dist/InputBox-D2ZRTMFP.js +42 -0
  14. package/dist/InputBox-D2ZRTMFP.js.map +1 -0
  15. package/dist/{PluginImagesUsed-Bq_C_rgg.js → PluginImagesUsed-BVyvFA1_.js} +7 -7
  16. package/dist/{PluginImagesUsed-Bq_C_rgg.js.map → PluginImagesUsed-BVyvFA1_.js.map} +1 -1
  17. package/dist/{PluginPrefSync-DP5NyPnI.js → PluginPrefSync-CUKkx4Qk.js} +10 -10
  18. package/dist/{PluginPrefSync-DP5NyPnI.js.map → PluginPrefSync-CUKkx4Qk.js.map} +1 -1
  19. package/dist/{PluginStoreApp-_YWpLgfs.js → PluginStoreApp-CoOAw1fr.js} +4 -4
  20. package/dist/{PluginStoreApp-_YWpLgfs.js.map → PluginStoreApp-CoOAw1fr.js.map} +1 -1
  21. package/dist/{PluginTemplatesUsed-DS_rHctR.js → PluginTemplatesUsed-CdjT1wR4.js} +12 -12
  22. package/dist/{PluginTemplatesUsed-DS_rHctR.js.map → PluginTemplatesUsed-CdjT1wR4.js.map} +1 -1
  23. package/dist/{index-CM_6yF2v.js → Promise.withResolvers-C4chhLB1.js} +17 -11
  24. package/dist/Promise.withResolvers-C4chhLB1.js.map +1 -0
  25. package/dist/{RadioBox-0UuxlcWZ.js → RadioBox-B0z9YHQg.js} +2 -2
  26. package/dist/{RadioBox-0UuxlcWZ.js.map → RadioBox-B0z9YHQg.js.map} +1 -1
  27. package/dist/components/index.js +75 -46
  28. package/dist/components/index.js.map +1 -1
  29. package/dist/{BasePlugin-BCVSn9QJ.js → core.js} +28 -10
  30. package/dist/core.js.map +1 -0
  31. package/dist/{index-n5KKWE9v.js → index-1tsXE6ax.js} +9 -8
  32. package/dist/{index-n5KKWE9v.js.map → index-1tsXE6ax.js.map} +1 -1
  33. package/dist/{index-CS1kidKF.js → index-B32tFyLB.js} +57 -57
  34. package/dist/{index-CS1kidKF.js.map → index-B32tFyLB.js.map} +1 -1
  35. package/dist/{index-Cq8xPcEY.js → index-BPTMltVf.js} +35 -35
  36. package/dist/index-BPTMltVf.js.map +1 -0
  37. package/dist/{index-rKL4D_7I.js → index-BYlcHc-O.js} +22 -24
  38. package/dist/index-BYlcHc-O.js.map +1 -0
  39. package/dist/{index-DjyjqpeO.js → index-C4qm_X_A.js} +11 -11
  40. package/dist/{index-DjyjqpeO.js.map → index-C4qm_X_A.js.map} +1 -1
  41. package/dist/index-CAtPo7xJ.js +793 -0
  42. package/dist/index-CAtPo7xJ.js.map +1 -0
  43. package/dist/{index-DPA1ptYq.js → index-CVCy0wPP.js} +8 -7
  44. package/dist/{index-DPA1ptYq.js.map → index-CVCy0wPP.js.map} +1 -1
  45. package/dist/index-CYfkwXRf.js +1631 -0
  46. package/dist/index-CYfkwXRf.js.map +1 -0
  47. package/dist/{index-mFwJhDwE.js → index-DZa9mxN4.js} +11 -11
  48. package/dist/{index-mFwJhDwE.js.map → index-DZa9mxN4.js.map} +1 -1
  49. package/dist/{index-B9VO3swL.js → index-Dm2vgYkZ.js} +58 -81
  50. package/dist/index-Dm2vgYkZ.js.map +1 -0
  51. package/dist/{index-C3t-Xj3e.js → index-NWWeW3tX.js} +10 -10
  52. package/dist/{index-C3t-Xj3e.js.map → index-NWWeW3tX.js.map} +1 -1
  53. package/dist/index-QnWieXQc.js +4932 -0
  54. package/dist/index-QnWieXQc.js.map +1 -0
  55. package/dist/{index-CbdkXGs7.js → index-bQ0CVu3l.js} +13 -17
  56. package/dist/{index-CbdkXGs7.js.map → index-bQ0CVu3l.js.map} +1 -1
  57. package/dist/{index-Cb2_vqBl.js → index-ygc4AMy4.js} +10 -10
  58. package/dist/{index-Cb2_vqBl.js.map → index-ygc4AMy4.js.map} +1 -1
  59. package/dist/{index-DD5CVCfD.js → index-z_qDGCMT.js} +2 -2
  60. package/dist/{index-DD5CVCfD.js.map → index-z_qDGCMT.js.map} +1 -1
  61. package/dist/index.d.ts +98 -36
  62. package/dist/index.js +24 -26
  63. package/dist/index.js.map +1 -1
  64. package/dist/{makeCallable-LDU0xZMJ.js → makeCallable-Cg4zUG4c.js} +2 -2
  65. package/dist/{makeCallable-LDU0xZMJ.js.map → makeCallable-Cg4zUG4c.js.map} +1 -1
  66. package/dist/models/index.js +7 -7
  67. package/dist/models/index.js.map +1 -1
  68. package/dist/plugins/index.js +12 -12
  69. package/dist/services/index.js +5 -4
  70. package/dist/style.css +1 -1
  71. package/dist/{vueHooks-l04s8cIl.js → vueHooks-Bs93iP61.js} +1519 -1492
  72. package/dist/vueHooks-Bs93iP61.js.map +1 -0
  73. package/lib/index.umd.js +19 -15
  74. package/lib/index.umd.js.map +1 -1
  75. package/lib/style.css +1 -1
  76. package/package.json +36 -27
  77. package/dist/BasePlugin-BCVSn9QJ.js.map +0 -1
  78. package/dist/IconQuickEdit-CMCQncyj.js +0 -27
  79. package/dist/IconQuickEdit-CMCQncyj.js.map +0 -1
  80. package/dist/InputBox-CZ1v4_l3.js +0 -50
  81. package/dist/InputBox-CZ1v4_l3.js.map +0 -1
  82. package/dist/Preferences-DqtjY7XU.js +0 -1541
  83. package/dist/Preferences-DqtjY7XU.js.map +0 -1
  84. package/dist/WatchlistAction-BbNAyryN.js +0 -5
  85. package/dist/WatchlistAction-BbNAyryN.js.map +0 -1
  86. package/dist/browser-DR-yCqVg.js +0 -1160
  87. package/dist/browser-DR-yCqVg.js.map +0 -1
  88. package/dist/index-B9VO3swL.js.map +0 -1
  89. package/dist/index-CG38LlAh.js +0 -46
  90. package/dist/index-CG38LlAh.js.map +0 -1
  91. package/dist/index-CM_6yF2v.js.map +0 -1
  92. package/dist/index-CcAmmXbb.js +0 -3290
  93. package/dist/index-CcAmmXbb.js.map +0 -1
  94. package/dist/index-Cq8xPcEY.js.map +0 -1
  95. package/dist/index-DVvsTsLI.js +0 -505
  96. package/dist/index-DVvsTsLI.js.map +0 -1
  97. package/dist/index-FvMu0Ka0.js +0 -342
  98. package/dist/index-FvMu0Ka0.js.map +0 -1
  99. package/dist/index-rKL4D_7I.js.map +0 -1
  100. package/dist/vueHooks-l04s8cIl.js.map +0 -1
@@ -0,0 +1,1631 @@
1
+ function M(n) {
2
+ if (typeof globalThis.structuredClone == "function")
3
+ try {
4
+ return globalThis.structuredClone(n);
5
+ } catch {
6
+ }
7
+ return k(n, /* @__PURE__ */ new WeakMap());
8
+ }
9
+ function k(n, t) {
10
+ if (typeof n != "object" || n === null) return n;
11
+ const r = t.get(n);
12
+ if (r) return r;
13
+ if (n instanceof Date) return new Date(n.getTime());
14
+ if (n instanceof RegExp)
15
+ return new RegExp(n.source, n.flags);
16
+ if (n instanceof URL) return new URL(n.toString());
17
+ if (n instanceof URLSearchParams)
18
+ return new URLSearchParams(n.toString());
19
+ if (n instanceof ArrayBuffer) return n.slice(0);
20
+ if (ArrayBuffer.isView(n)) {
21
+ if (n instanceof DataView)
22
+ return new DataView(
23
+ n.buffer.slice(0),
24
+ n.byteOffset,
25
+ n.byteLength
26
+ );
27
+ const o = n, a = o.constructor;
28
+ return new a(o.buffer.slice(0), o.byteOffset, o.length);
29
+ }
30
+ if (n instanceof Map) {
31
+ const o = /* @__PURE__ */ new Map();
32
+ return t.set(n, o), n.forEach((a, c) => {
33
+ o.set(k(c, t), k(a, t));
34
+ }), o;
35
+ }
36
+ if (n instanceof Set) {
37
+ const o = /* @__PURE__ */ new Set();
38
+ return t.set(n, o), n.forEach((a) => o.add(k(a, t))), o;
39
+ }
40
+ if (Array.isArray(n)) {
41
+ const o = new Array(n.length);
42
+ t.set(n, o);
43
+ for (let a = 0; a < o.length; a++)
44
+ o[a] = k(n[a], t);
45
+ return o;
46
+ }
47
+ const e = Object.getPrototypeOf(n), s = Object.create(e);
48
+ t.set(n, s);
49
+ const i = Object.getOwnPropertyDescriptors(n);
50
+ for (const o of Reflect.ownKeys(i)) {
51
+ const a = i[o];
52
+ "value" in a && (a.value = k(a.value, t)), Object.defineProperty(s, o, a);
53
+ }
54
+ return s;
55
+ }
56
+ function I(n) {
57
+ if (typeof n != "object" || n === null)
58
+ return !1;
59
+ const t = Object.getPrototypeOf(n);
60
+ return t === Object.prototype || t === null;
61
+ }
62
+ const H = function(n) {
63
+ const t = this.constructor.prototype, r = Reflect.get(t, n, t);
64
+ function e(...s) {
65
+ return Reflect.apply(r, e, s);
66
+ }
67
+ Reflect.setPrototypeOf(e, t);
68
+ for (const s of Reflect.ownKeys(r)) {
69
+ const i = Reflect.getOwnPropertyDescriptor(r, s);
70
+ i && Reflect.defineProperty(e, s, i);
71
+ }
72
+ return e;
73
+ };
74
+ H.prototype = Object.create(Function.prototype);
75
+ const Y = H;
76
+ function A(n, ...t) {
77
+ const r = M(n || {});
78
+ for (const e of t)
79
+ if (e != null)
80
+ for (const s of Reflect.ownKeys(e)) {
81
+ const i = e[s];
82
+ if (typeof i > "u") continue;
83
+ if (i === null) {
84
+ delete r[s];
85
+ continue;
86
+ }
87
+ const o = r[s];
88
+ I(o) && I(i) ? r[s] = A(o, i) : r[s] = M(i);
89
+ }
90
+ return r;
91
+ }
92
+ var T = /* @__PURE__ */ ((n) => (n.BODY_USED = "BODY_USED", n.NO_BODY_READER = "NO_BODY_READER", n.TIMEOUT = "TIMEOUT", n.NETWORK_ERROR = "NETWORK_ERROR", n.BODY_NOT_ALLOWED = "BODY_NOT_ALLOWED", n.HOOK_CONTEXT_CHANGED = "HOOK_CONTEXT_CHANGED", n.ABORTED_BY_HOOK = "ABORTED_BY_HOOK", n.INVALID_HOOK_CALLBACK = "INVALID_HOOK_CALLBACK", n.UNEXPECTED_HOOK_RETURN = "UNEXPECTED_HOOK_RETURN", n.UNSUPPORTED_RESPONSE_TYPE = "UNSUPPORTED_RESPONSE_TYPE", n.BODY_TRANSFORM_ERROR = "BODY_TRANSFORM_ERROR", n))(T || {});
93
+ class b extends Error {
94
+ constructor(t, r, e, s) {
95
+ super(r, s), this.code = t, this.context = e;
96
+ }
97
+ name = "FexiosError";
98
+ static is(t, r) {
99
+ return !(t instanceof b) || t instanceof N ? !1 : r ? t.code === r : !0;
100
+ }
101
+ }
102
+ class N extends b {
103
+ constructor(t, r, e) {
104
+ super(r.statusText, t, void 0, e), this.response = r;
105
+ }
106
+ name = "FexiosResponseError";
107
+ static is(t) {
108
+ return t instanceof N;
109
+ }
110
+ }
111
+ var _;
112
+ ((n) => {
113
+ n.makeHeaders = (t) => {
114
+ if (!t) return new Headers();
115
+ if (t instanceof Headers) return new Headers(t);
116
+ const r = new Headers();
117
+ if (t instanceof Map) {
118
+ for (const [e, s] of t.entries())
119
+ if (s != null)
120
+ if (Array.isArray(s))
121
+ for (const i of s)
122
+ i != null && r.append(e, String(i));
123
+ else
124
+ r.append(e, String(s));
125
+ return r;
126
+ }
127
+ if (I(t)) {
128
+ for (const [e, s] of Object.entries(t))
129
+ if (s != null)
130
+ if (Array.isArray(s))
131
+ for (const i of s)
132
+ i != null && r.append(e, String(i));
133
+ else
134
+ r.append(e, String(s));
135
+ return r;
136
+ }
137
+ throw new TypeError(
138
+ "only plain object, Map/ReadonlyMap, or Headers is supported"
139
+ );
140
+ }, n.toHeaderRecord = (t) => {
141
+ if (t instanceof Headers) {
142
+ const r = {};
143
+ return t.forEach((e, s) => {
144
+ r[s] = r[s] ? [...r[s], e] : [e];
145
+ }), r;
146
+ }
147
+ if (t instanceof Map) {
148
+ const r = {};
149
+ for (const [e, s] of t.entries())
150
+ if (s != null)
151
+ if (Array.isArray(s)) {
152
+ const i = s.filter((o) => o != null).map((o) => String(o));
153
+ i.length && (r[e] = (r[e] ?? []).concat(i));
154
+ } else {
155
+ const i = String(s);
156
+ r[e] = r[e] ? [...r[e], i] : [i];
157
+ }
158
+ return r;
159
+ }
160
+ throw new TypeError(
161
+ `unsupported type transformation, got: ${Object.prototype.toString.call(
162
+ t
163
+ )}`
164
+ );
165
+ }, n.mergeHeaders = (...t) => {
166
+ const r = new Headers(), e = (s) => {
167
+ for (const [i, o] of Object.entries(s))
168
+ if (o !== void 0) {
169
+ if (o === null) {
170
+ r.delete(i);
171
+ continue;
172
+ }
173
+ if (Array.isArray(o)) {
174
+ r.delete(i);
175
+ for (const a of o)
176
+ a != null && r.append(i, String(a));
177
+ } else
178
+ r.set(i, String(o));
179
+ }
180
+ };
181
+ for (const s of t) {
182
+ if (s == null) continue;
183
+ if (s instanceof Headers) {
184
+ s.forEach((o, a) => {
185
+ r.set(a, o);
186
+ });
187
+ continue;
188
+ }
189
+ if (I(s)) {
190
+ e(s);
191
+ continue;
192
+ }
193
+ const i = (0, n.toHeaderRecord)(s);
194
+ for (const [o, a] of Object.entries(i)) {
195
+ r.delete(o);
196
+ for (const c of a) r.append(o, c);
197
+ }
198
+ }
199
+ return r;
200
+ };
201
+ })(_ || (_ = {}));
202
+ var O;
203
+ ((n) => {
204
+ n.makeSearchParams = (e) => {
205
+ if (!e)
206
+ return new URLSearchParams();
207
+ if (e instanceof URLSearchParams)
208
+ return e;
209
+ if (typeof e != "object" || e?.constructor !== Object)
210
+ throw new TypeError("only plain object is supported");
211
+ const s = new URLSearchParams(), i = (c, l) => {
212
+ l != null && s.append(c, l);
213
+ }, o = (c, l) => {
214
+ l != null && s.set(c, l);
215
+ }, a = (c, l) => {
216
+ if (l != null) {
217
+ if (Array.isArray(l)) {
218
+ for (const f of l) i(c, f?.toString());
219
+ return;
220
+ }
221
+ if (typeof l == "object" && l.constructor === Object) {
222
+ for (const [f, u] of Object.entries(l)) {
223
+ if (u == null) continue;
224
+ const g = f.endsWith("[]"), h = g ? f.slice(0, -2) : f, R = `${c}[${h}]`;
225
+ if (g) {
226
+ const y = `${R}[]`;
227
+ if (Array.isArray(u))
228
+ for (const p of u) i(y, p?.toString());
229
+ else typeof u == "object" && u !== null && u.constructor === Object ? a(`${R}[]`, u) : i(y, u?.toString());
230
+ } else if (Array.isArray(u))
231
+ for (const y of u) i(R, y?.toString());
232
+ else typeof u == "object" && u !== null && u.constructor === Object ? a(R, u) : o(R, u?.toString());
233
+ }
234
+ return;
235
+ }
236
+ o(c, l?.toString());
237
+ }
238
+ };
239
+ for (const [c, l] of Object.entries(e))
240
+ a(c, l);
241
+ return s;
242
+ }, n.makeQueryString = (e) => (0, n.makeSearchParams)(e).toString(), n.makeURL = (e, s, i, o) => {
243
+ const a = typeof window < "u" && window.location?.origin || "http://localhost", c = typeof e == "string" ? new URL(e, o ?? a) : new URL(e), l = (0, n.toQueryRecord)(c.searchParams), f = (0, n.mergeQueries)(l, s || {}), u = (0, n.makeSearchParams)(f);
244
+ return c.search = u.toString(), typeof i < "u" && (c.hash = i), c;
245
+ }, n.toQueryRecord = (e) => {
246
+ typeof e == "string" && (e = (0, n.fromString)(e));
247
+ const s = {}, i = (a) => {
248
+ if (!a.includes("[")) return { path: [a], forceArray: !1 };
249
+ const l = [a.slice(0, a.indexOf("["))], f = /\[([^\]]*)\]/g;
250
+ let u, g = !1, h = !1;
251
+ for (; u = f.exec(a); )
252
+ u[1] === "" ? (g = !0, h = !0) : (l.push(u[1]), h = !1);
253
+ return g && h && (l[l.length - 1] = l[l.length - 1] + "[]"), { path: l, forceArray: g };
254
+ }, o = (a, c, l, f) => {
255
+ let u = a;
256
+ for (let g = 0; g < c.length; g++) {
257
+ const h = c[g];
258
+ g === c.length - 1 ? f ? u[h] === void 0 ? u[h] = [l] : Array.isArray(u[h]) ? u[h].push(l) : u[h] = [u[h], l] : u[h] === void 0 ? u[h] = l : Array.isArray(u[h]) ? u[h].push(l) : u[h] = [u[h], l] : ((u[h] === void 0 || typeof u[h] != "object" || Array.isArray(u[h])) && (u[h] = {}), u = u[h]);
259
+ }
260
+ };
261
+ for (const [a, c] of e.entries()) {
262
+ const { path: l, forceArray: f } = i(String(a));
263
+ o(s, l, c?.toString(), f);
264
+ }
265
+ return s;
266
+ }, n.fromString = (e) => {
267
+ const s = e.trim();
268
+ if (!s) return new URLSearchParams();
269
+ if (s.startsWith("?")) return new URLSearchParams(s.slice(1));
270
+ const i = s.indexOf("?");
271
+ if (i >= 0) {
272
+ const o = s.indexOf("#", i + 1), a = s.slice(i + 1, o >= 0 ? o : void 0);
273
+ return new URLSearchParams(a);
274
+ }
275
+ return new URLSearchParams(s);
276
+ }, n.mergeQueries = (...e) => {
277
+ const s = {};
278
+ for (const i of e)
279
+ i != null && r(s, t(i));
280
+ return s;
281
+ };
282
+ function t(e) {
283
+ if (!e) return {};
284
+ if (e instanceof URLSearchParams || e instanceof FormData || e instanceof Map)
285
+ return (0, n.toQueryRecord)(e);
286
+ if (typeof e == "string") return (0, n.toQueryRecord)((0, n.fromString)(e));
287
+ if (I(e)) return e;
288
+ throw new TypeError(
289
+ `unsupported type transformation, got: ${Object.prototype.toString.call(
290
+ e
291
+ )}`
292
+ );
293
+ }
294
+ function r(e, s) {
295
+ for (const [i, o] of Object.entries(s)) {
296
+ if (o === void 0) continue;
297
+ if (o === null) {
298
+ delete e[i];
299
+ continue;
300
+ }
301
+ const a = e[i];
302
+ I(a) && I(o) ? r(a, o) : e[i] = M(o);
303
+ }
304
+ }
305
+ })(O || (O = {}));
306
+ class C {
307
+ constructor(t, r, e) {
308
+ this.rawResponse = t, this.data = r, this.responseType = e, ["ok", "status", "statusText", "headers", "url", "redirected"].forEach(
309
+ (s) => {
310
+ Reflect.defineProperty(this, s, {
311
+ get: () => t[s]
312
+ });
313
+ }
314
+ );
315
+ }
316
+ ok;
317
+ status;
318
+ statusText;
319
+ headers;
320
+ url;
321
+ redirected;
322
+ }
323
+ const j = (n) => {
324
+ const t = n.reduce((s, i) => s + i.length, 0), r = new Uint8Array(t);
325
+ let e = 0;
326
+ for (const s of n)
327
+ r.set(s, e), e += s.length;
328
+ return r;
329
+ };
330
+ async function $(n, t, r) {
331
+ const e = n.getReader();
332
+ if (!e)
333
+ throw new b(
334
+ T.NO_BODY_READER,
335
+ "Failed to get ReadableStream from response body"
336
+ );
337
+ const s = [];
338
+ let i = 0;
339
+ try {
340
+ for (; ; ) {
341
+ const { done: a, value: c } = await e.read();
342
+ if (a) break;
343
+ s.push(c), i += c.length, r && t > 0 && r(i / t, j(s));
344
+ }
345
+ } finally {
346
+ e.releaseLock?.();
347
+ }
348
+ const o = j(s);
349
+ return r?.(1, o), o;
350
+ }
351
+ const W = (n) => {
352
+ if (n) {
353
+ if (n.includes("application/json") || n.endsWith("+json"))
354
+ return "json";
355
+ if (n.startsWith("text/")) return "text";
356
+ if (n.includes("multipart/form-data") || n.includes("application/x-www-form-urlencoded"))
357
+ return "form";
358
+ if (/^image\//.test(n) || /^video\//.test(n) || /^audio\//.test(n) || n.includes("application/pdf"))
359
+ return "blob";
360
+ if (n.includes("application/octet-stream") || n.includes("application/zip") || n.includes("application/x-tar") || n.includes("application/x-7z-compressed") || n.includes("application/x-gzip"))
361
+ return "arrayBuffer";
362
+ }
363
+ };
364
+ async function x(n, t, r, e, s) {
365
+ const i = n.headers.get("content-type")?.toLowerCase() ?? "", o = n.headers.get("content-length"), a = o ? Number(o) : 0, c = n.headers.get("upgrade")?.toLowerCase(), l = n.headers.get("connection")?.toLowerCase();
366
+ let f = t ?? W(i) ?? "text";
367
+ if (t || (c === "websocket" && l === "upgrade" ? f = "ws" : i.includes("text/event-stream") && (f = "stream")), f === "stream") {
368
+ const p = n.url || n.url || "", d = await X(
369
+ p,
370
+ n,
371
+ s
372
+ ), w = e?.(d);
373
+ if (typeof w == "boolean" ? w : !d.ok)
374
+ throw new N(d.statusText, d);
375
+ return d;
376
+ }
377
+ if (f === "ws") {
378
+ const p = n.url || n.url || "", d = await z(
379
+ p,
380
+ n,
381
+ s
382
+ ), w = e?.(d);
383
+ if (typeof w == "boolean" ? w : !d.ok)
384
+ throw new N(d.statusText, d);
385
+ return d;
386
+ }
387
+ const u = /\bcharset=([^;]+)/i.exec(i)?.[1]?.trim() || "utf-8", g = new TextDecoder(u);
388
+ let h;
389
+ try {
390
+ if (f === "form")
391
+ h = await n.formData();
392
+ else {
393
+ const p = await $(n.body, a, r);
394
+ if (f === "arrayBuffer")
395
+ h = p.buffer.slice(
396
+ p.byteOffset,
397
+ p.byteOffset + p.byteLength
398
+ );
399
+ else if (f === "blob")
400
+ h = new Blob([p], {
401
+ type: i || "application/octet-stream"
402
+ });
403
+ else if (f === "text") {
404
+ const d = g.decode(p);
405
+ if (t)
406
+ h = d;
407
+ else {
408
+ const w = d.trim();
409
+ if (w.startsWith("{") && w.endsWith("}") || w.startsWith("[") && w.endsWith("]"))
410
+ try {
411
+ h = JSON.parse(w), f = "json";
412
+ } catch {
413
+ h = d;
414
+ }
415
+ else
416
+ h = d;
417
+ }
418
+ } else if (f === "json") {
419
+ const d = g.decode(p);
420
+ h = d.length ? JSON.parse(d) : null;
421
+ } else
422
+ h = p;
423
+ }
424
+ } catch (p) {
425
+ if (!(p instanceof Error)) throw p;
426
+ try {
427
+ h = await n.text(), f = "text";
428
+ } catch {
429
+ throw new b(
430
+ T.BODY_TRANSFORM_ERROR,
431
+ `Failed to transform response body to ${f}`,
432
+ void 0,
433
+ { cause: p }
434
+ );
435
+ }
436
+ }
437
+ const R = new C(
438
+ n,
439
+ h,
440
+ f
441
+ ), y = e?.(R);
442
+ if (typeof y == "boolean" ? y : !R.ok)
443
+ throw new N(R.statusText, R);
444
+ return R;
445
+ }
446
+ async function z(n, t, r) {
447
+ const e = new WebSocket(n.toString()), s = r ?? 6e4;
448
+ return await new Promise((i, o) => {
449
+ const a = s > 0 ? setTimeout(() => {
450
+ e.close(), o(
451
+ new b(
452
+ T.TIMEOUT,
453
+ `WebSocket connection timed out after ${s}ms`
454
+ )
455
+ );
456
+ }, s) : void 0;
457
+ let c = !1;
458
+ const l = () => {
459
+ clearTimeout(a), e.removeEventListener("open", f), e.removeEventListener("error", u), e.removeEventListener("close", g);
460
+ }, f = () => {
461
+ c || (c = !0, l(), i());
462
+ }, u = (h) => {
463
+ c || (c = !0, l(), o(
464
+ new b(
465
+ T.NETWORK_ERROR,
466
+ "WebSocket connection failed",
467
+ void 0,
468
+ { cause: h }
469
+ )
470
+ ));
471
+ }, g = (h) => {
472
+ c || (c = !0, l(), o(
473
+ new b(
474
+ T.NETWORK_ERROR,
475
+ `WebSocket connection closed unexpectedly (code: ${h.code}, reason: ${h.reason})`,
476
+ void 0,
477
+ { cause: h }
478
+ )
479
+ ));
480
+ };
481
+ e.addEventListener("open", f), e.addEventListener("error", u), e.addEventListener("close", g);
482
+ }), new C(t || new Response(null), e, "ws");
483
+ }
484
+ async function X(n, t, r) {
485
+ const e = new EventSource(n.toString()), s = r ?? 6e4;
486
+ return await new Promise((i, o) => {
487
+ const a = s > 0 ? setTimeout(() => {
488
+ e.close(), o(
489
+ new b(
490
+ T.TIMEOUT,
491
+ `EventSource connection timed out after ${s}ms`
492
+ )
493
+ );
494
+ }, s) : void 0;
495
+ let c = !1;
496
+ const l = () => {
497
+ clearTimeout(a), e.removeEventListener("open", f), e.removeEventListener("error", u);
498
+ }, f = () => {
499
+ c || (c = !0, l(), i());
500
+ }, u = (g) => {
501
+ c || (c = !0, l(), o(
502
+ new b(
503
+ T.NETWORK_ERROR,
504
+ "EventSource connection failed",
505
+ void 0,
506
+ { cause: g }
507
+ )
508
+ ));
509
+ };
510
+ e.addEventListener("open", f), e.addEventListener("error", u);
511
+ }), new C(
512
+ t || new Response(null),
513
+ e,
514
+ "stream"
515
+ );
516
+ }
517
+ class m extends Y {
518
+ static version = "5.2.0";
519
+ static FINAL_SYMBOL = /* @__PURE__ */ Symbol("FEXIOS_FINAL_CONTEXT");
520
+ baseConfigs;
521
+ // for axios compatibility
522
+ get defaults() {
523
+ return this.baseConfigs;
524
+ }
525
+ set defaults(t) {
526
+ this.baseConfigs = t;
527
+ }
528
+ static DEFAULT_CONFIGS = {
529
+ baseURL: "",
530
+ timeout: 0,
531
+ credentials: void 0,
532
+ headers: {},
533
+ query: {},
534
+ responseType: void 0,
535
+ shouldThrow(t) {
536
+ return !t.ok;
537
+ },
538
+ fetch: globalThis.fetch
539
+ };
540
+ hooks = [];
541
+ static ALL_METHODS = [
542
+ "get",
543
+ "post",
544
+ "put",
545
+ "patch",
546
+ "delete",
547
+ "head",
548
+ "options",
549
+ "trace"
550
+ ];
551
+ static METHODS_WITHOUT_BODY = [
552
+ "get",
553
+ "head",
554
+ "options",
555
+ "trace"
556
+ ];
557
+ constructor(t = {}) {
558
+ super("request"), this.baseConfigs = A(m.DEFAULT_CONFIGS, t), m.ALL_METHODS.forEach(
559
+ (r) => this.createMethodShortcut(r.toLowerCase())
560
+ );
561
+ }
562
+ async request(t, r) {
563
+ let e = r || {};
564
+ if (typeof t == "string" || t instanceof URL ? e.url = t.toString() : typeof t == "object" && (e = t), e = await this.emit("beforeInit", e), e[m.FINAL_SYMBOL]) return e;
565
+ if (e = this.applyDefaults(e), m.METHODS_WITHOUT_BODY.includes(
566
+ e.method?.toLocaleLowerCase()
567
+ ) && e.body)
568
+ throw new b(
569
+ T.BODY_NOT_ALLOWED,
570
+ `Request method "${e.method}" does not allow body`
571
+ );
572
+ if (e = await this.emit("beforeRequest", e), e[m.FINAL_SYMBOL]) return e;
573
+ let s;
574
+ const i = {};
575
+ if (typeof e.body < "u" && e.body !== null && (e.body instanceof Blob || e.body instanceof FormData || e.body instanceof URLSearchParams ? s = e.body : typeof e.body == "object" && e.body !== null ? (s = JSON.stringify(e.body), e.headers = this.mergeHeaders(e.headers, {
576
+ "Content-Type": "application/json"
577
+ })) : s = e.body), !_.makeHeaders(e.headers || {}).get("content-type") && s && (s instanceof FormData || s instanceof URLSearchParams ? i["content-type"] = null : typeof s == "string" && typeof e.body == "object" ? i["content-type"] = "application/json" : s instanceof Blob && (i["content-type"] = s.type || "application/octet-stream")), e.body = s, e = await this.emit("afterBodyTransformed", e), e[m.FINAL_SYMBOL]) return e;
578
+ const a = e.abortController ?? (globalThis.AbortController ? new AbortController() : void 0), c = globalThis.location?.href || "http://localhost", l = new URL(
579
+ e.baseURL || this.baseConfigs.baseURL || c,
580
+ c
581
+ ), f = new URL(e.url, l), u = O.makeURL(
582
+ f,
583
+ e.query,
584
+ f.hash
585
+ // 保留 hash
586
+ ).toString(), g = new Request(u, {
587
+ method: e.method || "GET",
588
+ credentials: e.credentials,
589
+ cache: e.cache,
590
+ mode: e.mode,
591
+ headers: _.mergeHeaders(
592
+ this.baseConfigs.headers,
593
+ e.headers || {},
594
+ i
595
+ ),
596
+ body: e.body,
597
+ signal: a?.signal
598
+ });
599
+ if (e.rawRequest = g, e = await this.emit("beforeActualFetch", e), e[m.FINAL_SYMBOL]) return e;
600
+ const h = e.timeout ?? this.baseConfigs.timeout ?? 60 * 1e3, R = e.shouldThrow ?? this.baseConfigs.shouldThrow;
601
+ if (e.url.startsWith("ws") || e.responseType === "ws") {
602
+ const p = await z(
603
+ e.url,
604
+ void 0,
605
+ h
606
+ ), d = {
607
+ ...e,
608
+ response: p,
609
+ rawResponse: void 0,
610
+ data: p.data,
611
+ headers: p.headers
612
+ };
613
+ return this.emit("afterResponse", d);
614
+ }
615
+ let y;
616
+ try {
617
+ a && (y = h > 0 ? setTimeout(() => {
618
+ a.abort();
619
+ }, h) : void 0);
620
+ const d = await (e.fetch || this.baseConfigs.fetch || globalThis.fetch)(e.rawRequest).catch((w) => {
621
+ throw y && clearTimeout(y), a?.signal.aborted ? new b(
622
+ T.TIMEOUT,
623
+ `Request timed out after ${h}ms`,
624
+ e
625
+ ) : new b(T.NETWORK_ERROR, w.message, e);
626
+ });
627
+ return y && clearTimeout(y), e.rawResponse = d, e.response = await x(
628
+ d,
629
+ e.responseType,
630
+ (w, F) => {
631
+ r?.onProgress?.(w, F);
632
+ },
633
+ R,
634
+ h
635
+ ), Object.defineProperties(e, {
636
+ url: { get: () => d?.url || u },
637
+ data: { get: () => e.response.data },
638
+ headers: { get: () => d.headers },
639
+ responseType: { get: () => e.response.responseType }
640
+ }), this.emit("afterResponse", e);
641
+ } catch (p) {
642
+ throw y && clearTimeout(y), p;
643
+ }
644
+ }
645
+ mergeQueries = O.mergeQueries;
646
+ mergeHeaders = _.mergeHeaders;
647
+ applyDefaults(t) {
648
+ const r = t;
649
+ "customEnv" in this.baseConfigs && (r.customEnv = A(
650
+ {},
651
+ // ensure we don't mutate baseConfigs
652
+ this.baseConfigs.customEnv,
653
+ r.customEnv
654
+ ));
655
+ const e = globalThis.location?.href || "http://localhost", s = r.baseURL || this.baseConfigs.baseURL || e, i = new URL(s, e), o = new URL(r.url.toString(), i), a = O.toQueryRecord(i.searchParams), c = O.toQueryRecord(o.searchParams), l = O.mergeQueries(
656
+ a,
657
+ c
658
+ );
659
+ o.search = O.makeSearchParams(l).toString(), r.url = o.toString();
660
+ const f = O.mergeQueries(
661
+ this.baseConfigs.query,
662
+ r.query
663
+ );
664
+ return r.query && this.restoreNulls(f, r.query), r.query = f, r;
665
+ }
666
+ restoreNulls(t, r) {
667
+ if (!(!r || typeof r != "object"))
668
+ for (const [e, s] of Object.entries(r))
669
+ s === null ? t[e] = null : I(s) && ((!t[e] || typeof t[e] != "object") && (t[e] = {}), this.restoreNulls(t[e], s));
670
+ }
671
+ async emit(t, r, e = {
672
+ shouldHandleShortCircuitResponse: !0
673
+ }) {
674
+ const s = this.hooks.filter((o) => o.event === t);
675
+ if (s.length === 0) return r;
676
+ const i = async (o, a) => {
677
+ const c = { ...o, rawResponse: a }, l = await x(
678
+ a,
679
+ o.responseType,
680
+ (f, u) => o.onProgress?.(f, u),
681
+ o.shouldThrow ?? this.baseConfigs.shouldThrow,
682
+ o.timeout ?? this.baseConfigs.timeout ?? 60 * 1e3
683
+ );
684
+ if (c.response = l, c.data = l.data, c.headers = l.headers, t !== "afterResponse") {
685
+ const f = await this.emit("afterResponse", c);
686
+ return f[m.FINAL_SYMBOL] = !0, f;
687
+ } else
688
+ return c[m.FINAL_SYMBOL] = !0, c;
689
+ };
690
+ for (let o = 0; o < s.length; o++) {
691
+ const a = s[o], c = `${String(t)}#${a.action.name || `anonymous#${o}`}`, l = /* @__PURE__ */ Symbol("FEXIOS_HOOK_CTX_MARK");
692
+ try {
693
+ r[l] = l;
694
+ } catch {
695
+ }
696
+ const f = await a.action.call(this, r);
697
+ try {
698
+ delete r[l];
699
+ } catch {
700
+ }
701
+ if (f === !1)
702
+ throw new b(
703
+ T.ABORTED_BY_HOOK,
704
+ `Request aborted by hook "${c}"`,
705
+ r
706
+ );
707
+ if (f instanceof Response) {
708
+ if (e.shouldHandleShortCircuitResponse !== !1)
709
+ return i(r, f);
710
+ r.rawResponse = f;
711
+ } else f && typeof f == "object" && f[l] === l && (r = f);
712
+ }
713
+ return r;
714
+ }
715
+ on(t, r, e = !1) {
716
+ if (typeof r != "function")
717
+ throw new b(
718
+ T.INVALID_HOOK_CALLBACK,
719
+ `Hook should be a function, but got "${typeof r}"`
720
+ );
721
+ return this.hooks[e ? "unshift" : "push"]({
722
+ event: t,
723
+ action: r
724
+ }), this;
725
+ }
726
+ off(t, r) {
727
+ return t === "*" || !t ? this.hooks = this.hooks.filter((e) => e.action !== r) : this.hooks = this.hooks.filter(
728
+ (e) => e.event !== t || e.action !== r
729
+ ), this;
730
+ }
731
+ createInterceptor(t) {
732
+ return {
733
+ handlers: () => this.hooks.filter((r) => r.event === t).map((r) => r.action),
734
+ use: (r, e = !1) => this.on(t, r, e),
735
+ clear: () => {
736
+ this.hooks = this.hooks.filter((r) => r.event !== t);
737
+ }
738
+ };
739
+ }
740
+ interceptors = {
741
+ request: this.createInterceptor("beforeRequest"),
742
+ response: this.createInterceptor("afterResponse")
743
+ };
744
+ createMethodShortcut(t) {
745
+ return Reflect.defineProperty(this, t, {
746
+ get: () => (r, e, s) => (m.METHODS_WITHOUT_BODY.includes(
747
+ t.toLocaleLowerCase()
748
+ ) ? s = e : (s = s || {}, s.body = e), this.request(r, {
749
+ ...s,
750
+ method: t
751
+ }))
752
+ }), this;
753
+ }
754
+ extends(t) {
755
+ const r = new m(A(this.baseConfigs, t));
756
+ return r.hooks = [...this.hooks], r._plugins = new Map(this._plugins), r._plugins.forEach(async (e) => {
757
+ await r.plugin(e);
758
+ }), r;
759
+ }
760
+ create = m.create;
761
+ static create(t) {
762
+ return new m(t);
763
+ }
764
+ _plugins = /* @__PURE__ */ new Map();
765
+ async plugin(t) {
766
+ if (typeof t?.name == "string" && typeof t?.install == "function") {
767
+ if (this._plugins.has(t.name))
768
+ return this;
769
+ const r = await t.install(this);
770
+ if (this._plugins.set(t.name, t), r instanceof m)
771
+ return r;
772
+ }
773
+ return this;
774
+ }
775
+ // 版本弃子们.jpg
776
+ /** @deprecated Use `import { checkIsPlainObject } from 'fexios/utils'` instead */
777
+ checkIsPlainObject = I;
778
+ /** @deprecated Use `mergeQueries` instead */
779
+ mergeQuery = this.mergeQueries;
780
+ }
781
+ const G = m.create;
782
+ G();
783
+ var U;
784
+ ((n) => {
785
+ function t(e) {
786
+ return Array.isArray(e) ? e.join("|") : typeof e == "boolean" || e === null ? e ? "1" : void 0 : typeof e == "number" ? "" + e : e;
787
+ }
788
+ n.normalizeParamValue = t;
789
+ function r(e) {
790
+ const s = (o) => o && (o instanceof URLSearchParams || o instanceof FormData);
791
+ if (e == null)
792
+ return;
793
+ const i = new FormData();
794
+ if (s(e))
795
+ return e.forEach((o, a) => {
796
+ const c = t(o);
797
+ c != null && i.append(a, c);
798
+ }), i;
799
+ if (I(e))
800
+ return Object.entries(e).forEach(([o, a]) => {
801
+ const c = t(a);
802
+ c != null && i.append(o, c);
803
+ }), i;
804
+ }
805
+ n.normalizeBody = r;
806
+ })(U || (U = {}));
807
+ var D = /* @__PURE__ */ ((n) => (n.HTTP_ERROR = "HTTP_ERROR", n.LOGIN_FAILED = "LOGIN_FAILED", n.LOGIN_RETRY_LIMIT_EXCEEDED = "LOGIN_RETRY_LIMIT_EXCEEDED", n.TOKEN_RETRY_LIMIT_EXCEEDED = "TOKEN_RETRY_LIMIT_EXCEEDED", n))(D || {});
808
+ class E extends Error {
809
+ constructor(t, r = "", e) {
810
+ super(), this.code = t, this.message = r, this.cause = e;
811
+ }
812
+ name = "WikiSaikouError";
813
+ static is(t, r) {
814
+ return t instanceof this && (r === void 0 || t.code === r);
815
+ }
816
+ }
817
+ class L extends Error {
818
+ constructor(t, r) {
819
+ super(), this.errors = t, this.cause = r, this.errors = L.normalizeErrors(t), this.message = t.map((e) => e.text).filter(Boolean).join(`
820
+ `), this.code = this.isBadTokenError() ? "badtoken" : this.errors[0]?.code || "Unknown Error";
821
+ }
822
+ name = "MediaWikiApiError";
823
+ code;
824
+ get firstError() {
825
+ return this.errors[0];
826
+ }
827
+ isBadTokenError() {
828
+ return this.errors.some((t) => t.code === "badtoken") || ["NeedToken", "WrongToken"].includes(this.cause?.data?.login?.result);
829
+ }
830
+ toString() {
831
+ return `[${this.name} ${this.code}]`;
832
+ }
833
+ static is(t) {
834
+ return t instanceof this;
835
+ }
836
+ static normalizeErrors(t) {
837
+ return Array.isArray(t) === !1 ? [] : t.filter((r) => typeof r == "object" && !!r?.code).map((r) => r.text ? r : r.info ? { ...r, text: r.info } : r["*"] ? { ...r, text: r["*"] } : { ...r, text: "" });
838
+ }
839
+ }
840
+ ((n) => {
841
+ function t(i) {
842
+ if (i == null) return;
843
+ if (i?.response?.data !== void 0) return i.response.data;
844
+ if (i?.data !== void 0) return i.data;
845
+ const o = i instanceof Error ? i.cause : void 0;
846
+ return o?.response?.data !== void 0 ? o.response.data : o?.data !== void 0 ? o.data : i || void 0;
847
+ }
848
+ function r(i) {
849
+ return e(i).length > 0;
850
+ }
851
+ n.includesMediaWikiApiError = r, n.normalizeMwApiErrors = L.normalizeErrors;
852
+ function e(i) {
853
+ let o = t(i);
854
+ if (typeof o != "object" || o === null)
855
+ return [];
856
+ const a = o?.error, c = o?.errors, l = [];
857
+ return a && l.push(a), Array.isArray(c) && l.push(...c), (0, n.normalizeMwApiErrors)(l);
858
+ }
859
+ n.extractMediaWikiApiErrors = e;
860
+ function s(i) {
861
+ if (L.is(i))
862
+ return i.isBadTokenError();
863
+ {
864
+ const o = e(i);
865
+ return new L(o).isBadTokenError();
866
+ }
867
+ }
868
+ n.isBadTokenError = s;
869
+ })(E || (E = {}));
870
+ const q = /* @__PURE__ */ Symbol.for("__FEXIOS_SAIKOU__");
871
+ function B(n) {
872
+ const t = n instanceof m ? n : new m({
873
+ baseURL: n instanceof URL ? n.toString() : String(n),
874
+ responseType: "json"
875
+ });
876
+ return t[q] || (Reflect.defineProperty(t, q, {
877
+ get: () => !0,
878
+ enumerable: !1,
879
+ configurable: !1
880
+ }), t.on("beforeInit", (r) => {
881
+ if (r.method?.toLowerCase() !== "post")
882
+ return r;
883
+ if (r.body === void 0 || r.body === null)
884
+ return r.body = void 0, r;
885
+ const e = r.body = U.normalizeBody(r.body), s = new URLSearchParams(r.query);
886
+ return e.has("format") && s.delete("format"), e.has("formatversion") && s.delete("formatversion"), e.has("action") && s.delete("action"), e.has("origin") && (s.set("origin", "" + e.get("origin")), e.delete("origin")), r.query = Object.fromEntries(s.entries()), r;
887
+ }), t.on("beforeInit", (r) => (r.query = O.mergeQueries(
888
+ {},
889
+ U.normalizeBody(r.query)
890
+ ), r)), t.on("beforeRequest", (r) => {
891
+ const e = new URL(r.url), s = O.mergeQueries(e.searchParams, r.query);
892
+ if (globalThis.location && (!s.origin && location.origin !== e.origin ? (s.origin = location.origin, t.baseConfigs.credentials = "include", t.baseConfigs.mode = "cors") : location.origin === e.origin && (delete s.origin, t.baseConfigs.credentials = void 0, t.baseConfigs.mode = void 0)), s.origin) {
893
+ const i = encodeURIComponent(s.origin).replace(/\./g, "%2E");
894
+ delete s.origin, r.query = s, r.url = `${e.origin}${e.pathname}?origin=${i}`;
895
+ } else
896
+ r.query = s;
897
+ return r;
898
+ }), t._tokens = /* @__PURE__ */ new Map(), t.on("afterResponse", (r) => {
899
+ const { data: e } = r, s = r.customEnv?.mwTokenName;
900
+ s && E.isBadTokenError(e) && t._tokens.delete(s);
901
+ const i = e?.query?.tokens;
902
+ i && typeof i == "object" && Object.entries(i).forEach(([a, c]) => {
903
+ typeof c == "string" && t._tokens.set(a.replace(/token$/i, "").toLowerCase(), c);
904
+ });
905
+ const o = e?.login?.token;
906
+ return typeof o == "string" && t._tokens.set("login", o), r;
907
+ })), t;
908
+ }
909
+ const V = (n, t, r) => {
910
+ let e = { ...Z.DEFAULT_CONFIGS };
911
+ if (typeof n == "string" ? e = A(e, {
912
+ baseURL: n,
913
+ fexiosConfigs: t || {},
914
+ defaultParams: r || {},
915
+ throwOnApiError: !1
916
+ // Set a default value for throwOnApiError
917
+ }) : typeof n == "object" && n !== null && (e = A(e, n)), !e.baseURL && typeof window == "object" && window.mediaWiki) {
918
+ const { wgServer: s, wgScriptPath: i } = window.mediaWiki?.config?.get(["wgServer", "wgScriptPath"]) || {};
919
+ typeof s == "string" && typeof i == "string" && (e.baseURL = `${s}${i}/api.php`);
920
+ }
921
+ if (typeof e.baseURL != "string")
922
+ throw new Error("baseURL is required");
923
+ return e;
924
+ }, Q = () => {
925
+ }, J = async (n, t) => {
926
+ let r = 0;
927
+ const { retry: e = 3, onRetry: s = Q, shouldRetry: i = () => !0 } = t;
928
+ let o;
929
+ do
930
+ try {
931
+ return await n();
932
+ } catch (a) {
933
+ if (o = a, i(a, r))
934
+ s(a, r), r++;
935
+ else
936
+ throw a;
937
+ }
938
+ while (r < e);
939
+ throw o || new Error("Retry failed");
940
+ };
941
+ class Z {
942
+ config;
943
+ version = "7.4.1";
944
+ request;
945
+ static INIT_DEFAULT_PARAMS = {
946
+ action: "query",
947
+ errorformat: "plaintext",
948
+ format: "json",
949
+ formatversion: 2
950
+ };
951
+ static DEFAULT_CONFIGS = {
952
+ baseURL: void 0,
953
+ fexiosConfigs: {
954
+ responseType: "json"
955
+ },
956
+ defaultParams: this.INIT_DEFAULT_PARAMS,
957
+ throwOnApiError: !1
958
+ };
959
+ constructor(t, r, e) {
960
+ const s = this.config = V(
961
+ t,
962
+ r,
963
+ e
964
+ );
965
+ this.request = B(s.baseURL);
966
+ }
967
+ setBaseURL(t) {
968
+ return this.config.baseURL = t, this.request.baseConfigs.baseURL = t, this;
969
+ }
970
+ /** Base methods encapsulation */
971
+ async get(t, r) {
972
+ const e = A(
973
+ {},
974
+ this.config.fexiosConfigs,
975
+ {
976
+ query: O.mergeQueries(
977
+ this.config.defaultParams,
978
+ t
979
+ )
980
+ },
981
+ r
982
+ );
983
+ return this.runRequestWithApiErrorMapping(
984
+ () => this.request.get("", e)
985
+ );
986
+ }
987
+ async post(t, r) {
988
+ return this.runRequestWithApiErrorMapping(
989
+ () => this.request.post(
990
+ "",
991
+ t,
992
+ A(
993
+ {},
994
+ this.config.fexiosConfigs,
995
+ {
996
+ query: this.config.defaultParams
997
+ },
998
+ r
999
+ )
1000
+ )
1001
+ );
1002
+ }
1003
+ /**
1004
+ * Wrap a request to map non-2xx responses containing MediaWiki API error bodies
1005
+ * into MediaWikiApiError when throwOnApiError=true, and then pass 2xx responses
1006
+ * through handleApiResponse for unified processing.
1007
+ */
1008
+ async runRequestWithApiErrorMapping(t) {
1009
+ try {
1010
+ const r = await t();
1011
+ return this.handleApiResponse(r);
1012
+ } catch (r) {
1013
+ throw this.config.throwOnApiError && E.includesMediaWikiApiError(r) ? new L(
1014
+ E.extractMediaWikiApiErrors(r),
1015
+ r
1016
+ ) : r;
1017
+ }
1018
+ }
1019
+ throwIfApiError(t) {
1020
+ const r = E.extractMediaWikiApiErrors(t);
1021
+ if (r.length > 0)
1022
+ throw new L(r, t);
1023
+ }
1024
+ handleApiResponse(t) {
1025
+ return this.config.throwOnApiError && this.throwIfApiError(t.data), t;
1026
+ }
1027
+ /** Token Handler */
1028
+ get tokens() {
1029
+ return this.request._tokens;
1030
+ }
1031
+ async fetchTokens(t = ["csrf"]) {
1032
+ return this.config.fexiosConfigs.credentials = "include", await this.get({
1033
+ action: "query",
1034
+ meta: "tokens",
1035
+ type: t
1036
+ }), this.tokens;
1037
+ }
1038
+ async getToken(t = "csrf", r = !1) {
1039
+ return (!this.tokens.get(t) || r) && (this.tokens.delete(t), await this.fetchTokens([t])), this.tokens.get(t);
1040
+ }
1041
+ badToken(t) {
1042
+ return this.tokens.delete(t), this.tokens;
1043
+ }
1044
+ async postWithToken(t, r, e) {
1045
+ const {
1046
+ tokenName: s = "token",
1047
+ retry: i = 3,
1048
+ noCache: o = !1,
1049
+ fexiosOptions: a
1050
+ } = e || {};
1051
+ if (i < 1)
1052
+ throw new E(
1053
+ D.TOKEN_RETRY_LIMIT_EXCEEDED,
1054
+ "The limit of the number of times to automatically re-acquire the token has been exceeded"
1055
+ );
1056
+ let c = 0;
1057
+ return J(
1058
+ async () => {
1059
+ const l = await this.getToken(
1060
+ t,
1061
+ o || c > 0
1062
+ );
1063
+ try {
1064
+ const f = await this.post(
1065
+ {
1066
+ [s]: l,
1067
+ ...r
1068
+ },
1069
+ A(a || {}, {
1070
+ customEnv: {
1071
+ mwTokenName: t
1072
+ }
1073
+ })
1074
+ );
1075
+ if (E.isBadTokenError(f.data))
1076
+ throw f;
1077
+ return f;
1078
+ } catch (f) {
1079
+ throw E.isBadTokenError(f) || f?.ok === !1 || L.is(f) ? f : new E(
1080
+ D.HTTP_ERROR,
1081
+ "Network/transport or SDK-internal error (not a MediaWiki API error)",
1082
+ f
1083
+ );
1084
+ }
1085
+ },
1086
+ {
1087
+ retry: i,
1088
+ onRetry: (l, f) => {
1089
+ c = f + 1;
1090
+ },
1091
+ shouldRetry: (l) => E.isBadTokenError(l) || l?.ok === !1
1092
+ }
1093
+ ).catch((l) => {
1094
+ throw E.isBadTokenError(l) || l?.ok === !1 ? new E(
1095
+ D.TOKEN_RETRY_LIMIT_EXCEEDED,
1096
+ "Retry attempts for acquiring/using token exhausted",
1097
+ l
1098
+ ) : l;
1099
+ });
1100
+ }
1101
+ postWithEditToken(t) {
1102
+ return this.postWithToken("csrf", t);
1103
+ }
1104
+ // for backward compatibility
1105
+ /** @deprecated Use `this.config.baseURL` instead */
1106
+ get baseURL() {
1107
+ return this.config.baseURL;
1108
+ }
1109
+ /** @deprecated Use `this.config.defaultParams` instead */
1110
+ get defaultParams() {
1111
+ return this.config.defaultParams;
1112
+ }
1113
+ /** @deprecated Use `this.config.fexiosConfigs` instead */
1114
+ get defaultOptions() {
1115
+ return this.config.fexiosConfigs;
1116
+ }
1117
+ /** @deprecated Use `createFexiosSaikou` instead */
1118
+ static createRequestHandler = B;
1119
+ /** @deprecated Use `this.getToken` instead */
1120
+ token = this.getToken;
1121
+ }
1122
+ class ee {
1123
+ constructor() {
1124
+ this.values = {};
1125
+ }
1126
+ get length() {
1127
+ return Object.keys(this.values).length;
1128
+ }
1129
+ clear() {
1130
+ this.values = {};
1131
+ }
1132
+ getItem(t) {
1133
+ return this.values[t] ?? null;
1134
+ }
1135
+ setItem(t, r) {
1136
+ this.values[t] = typeof r == "string" ? r : String(r);
1137
+ }
1138
+ removeItem(t) {
1139
+ delete this.values[t];
1140
+ }
1141
+ key(t) {
1142
+ return Object.keys(this.values)[t] ?? null;
1143
+ }
1144
+ }
1145
+ const te = () => new Proxy(new ee(), {
1146
+ set(n, t, r) {
1147
+ return typeof t == "string" && n.setItem(t, r), !0;
1148
+ },
1149
+ get(n, t) {
1150
+ return typeof t == "string" && !(t in n) ? n.getItem(t) : Reflect.get(n, t);
1151
+ }
1152
+ });
1153
+ function re(n) {
1154
+ class t {
1155
+ constructor(e, s = !0) {
1156
+ this._loaded = s, this.api = n, e.revisions?.forEach((i) => {
1157
+ typeof i?.slots?.main == "object" && Object.assign(i, i.slots.main);
1158
+ }), this.pageInfo = {
1159
+ ...t.DEFAULT_PAGE_INFO,
1160
+ ...e
1161
+ };
1162
+ }
1163
+ static {
1164
+ this.api = n;
1165
+ }
1166
+ static {
1167
+ this.DEFAULT_QUERY_PARAMS = {
1168
+ action: "query",
1169
+ prop: "info|templates|transcludedin|images|pageimages|revisions",
1170
+ inprop: "protection|url|varianttitles",
1171
+ intestactions: "edit|move|delete",
1172
+ tllimit: "max",
1173
+ tilimit: "max",
1174
+ imlimit: "max",
1175
+ piprop: "thumbnail|name|original",
1176
+ pithumbsize: "200",
1177
+ pilimit: "max",
1178
+ rvprop: "ids|timestamp|flags|comment|user|content",
1179
+ rvslots: "main"
1180
+ };
1181
+ }
1182
+ static {
1183
+ this.DEFAULT_PAGE_INFO = {
1184
+ pageid: 0,
1185
+ ns: 0,
1186
+ title: "",
1187
+ contentmodel: "wikitext",
1188
+ pagelanguage: "",
1189
+ pagelanguagehtmlcode: "",
1190
+ pagelanguagedir: "ltr",
1191
+ touched: (/* @__PURE__ */ new Date()).toISOString(),
1192
+ lastrevid: 0,
1193
+ length: 0,
1194
+ protection: [],
1195
+ restrictiontypes: [],
1196
+ fullurl: "",
1197
+ canonicalurl: "",
1198
+ editurl: "",
1199
+ varianttitles: {},
1200
+ actions: {
1201
+ edit: !0,
1202
+ move: !1,
1203
+ delete: !1
1204
+ },
1205
+ revisions: [],
1206
+ templates: [],
1207
+ images: []
1208
+ };
1209
+ }
1210
+ // Utils
1211
+ static async newFromApi(e) {
1212
+ const { data: s } = await this.api.get({
1213
+ ...t.DEFAULT_QUERY_PARAMS,
1214
+ ...e
1215
+ }), i = s?.query?.pages?.[0];
1216
+ if (!i || !i.title)
1217
+ throw new Error("Invalid page info", { cause: s });
1218
+ return new t(i, !0);
1219
+ }
1220
+ static newBlankPage(e = {}) {
1221
+ return new t(e, !1);
1222
+ }
1223
+ static async newFromAnyKind(e) {
1224
+ const { title: s, pageId: i, revisionId: o } = e || {};
1225
+ return o ? this.newFromApi({ revids: parseInt(o.toString(), 10) }) : i ? this.newFromApi({ pageids: parseInt(i.toString(), 10) }) : s ? this.newFromApi({ titles: s.toString() }) : null;
1226
+ }
1227
+ static async newBatchFromApi(e) {
1228
+ const { titles: s, pageids: i, revids: o, ...a } = e || {}, { data: c } = await this.api.post({
1229
+ ...t.DEFAULT_QUERY_PARAMS,
1230
+ titles: s?.join("|") ?? void 0,
1231
+ pageids: i?.join("|") ?? void 0,
1232
+ revids: o?.join("|") ?? void 0,
1233
+ ...a
1234
+ });
1235
+ return c?.query?.pages?.map((l) => new t(l, !0)) || [];
1236
+ }
1237
+ // Page actions
1238
+ async parse(e) {
1239
+ return this.api.post({
1240
+ action: "parse",
1241
+ page: this.pageInfo.title,
1242
+ prop: "text|langlinks|categories|links|templates|images|externallinks|sections|revid|displaytitle|iwlinks|properties|parsewarnings",
1243
+ ...e
1244
+ });
1245
+ }
1246
+ async preview(e, s) {
1247
+ return this.parse({
1248
+ action: "parse",
1249
+ page: void 0,
1250
+ title: this.title,
1251
+ text: e,
1252
+ pst: 1,
1253
+ preview: 1,
1254
+ disableeditsection: 1,
1255
+ disablelimitreport: 1,
1256
+ ...s
1257
+ });
1258
+ }
1259
+ async edit(e, s) {
1260
+ const i = await this.api.postWithEditToken({
1261
+ action: "edit",
1262
+ title: this.title,
1263
+ starttimestamp: this.pageInfo.touched,
1264
+ basetimestamp: this.revisions[0]?.timestamp,
1265
+ ...e,
1266
+ ...s
1267
+ });
1268
+ if (i.data?.edit?.result === "Success")
1269
+ return i;
1270
+ throw new L(
1271
+ [
1272
+ {
1273
+ module: "edit",
1274
+ code: "editfailure",
1275
+ text: "Unknown edit failure. Please try again.",
1276
+ docref: "https://www.mediawiki.org/wiki/API:Edit"
1277
+ }
1278
+ ],
1279
+ i
1280
+ );
1281
+ }
1282
+ async createOnly(e, s) {
1283
+ return this.edit(e, { createonly: 1, recreate: e.recreate, ...s });
1284
+ }
1285
+ async delete(e, s) {
1286
+ return this.api.postWithEditToken({
1287
+ action: "delete",
1288
+ title: this.pageInfo.title || void 0,
1289
+ pageid: this.pageInfo.pageid || void 0,
1290
+ reason: e,
1291
+ deletetalk: s?.deletetalk,
1292
+ ...s
1293
+ });
1294
+ }
1295
+ async moveTo(e, s, i) {
1296
+ return this.api.postWithEditToken({
1297
+ action: "move",
1298
+ from: this.pageInfo.title,
1299
+ to: e,
1300
+ reason: s,
1301
+ movetalk: 1,
1302
+ movesubpages: 1,
1303
+ ...i
1304
+ });
1305
+ }
1306
+ // === utilities ===
1307
+ userCan(e) {
1308
+ return !!this.pageInfo?.actions?.[e];
1309
+ }
1310
+ userCanEdit() {
1311
+ return this.userCan("edit");
1312
+ }
1313
+ async reloadSelfInfo() {
1314
+ const e = await t.newFromApi({
1315
+ pageids: this.pageInfo.pageid,
1316
+ titles: this.pageInfo.title
1317
+ }), s = (this.pageInfo.revisions || []).concat(e.revisions || []).sort((i, o) => i.revid - o.revid).reduce(
1318
+ (i, o) => (i.find((a) => a.revid === o.revid) || i.push(o), i),
1319
+ []
1320
+ );
1321
+ return this.pageInfo = e.pageInfo, this.pageInfo.revisions = s, this._loaded = !0, this;
1322
+ }
1323
+ // === sugar getters ===
1324
+ get pageid() {
1325
+ return this.pageInfo.pageid;
1326
+ }
1327
+ get title() {
1328
+ return this.pageInfo.title;
1329
+ }
1330
+ get ns() {
1331
+ return this.pageInfo.ns;
1332
+ }
1333
+ get contentmodel() {
1334
+ return this.pageInfo.contentmodel;
1335
+ }
1336
+ get fullurl() {
1337
+ return this.pageInfo.fullurl;
1338
+ }
1339
+ get canonicalurl() {
1340
+ return this.pageInfo.canonicalurl;
1341
+ }
1342
+ get editurl() {
1343
+ return this.pageInfo.editurl;
1344
+ }
1345
+ get revisions() {
1346
+ return this.pageInfo.revisions || [];
1347
+ }
1348
+ get lastrevid() {
1349
+ return this.pageInfo.lastrevid;
1350
+ }
1351
+ get templates() {
1352
+ return this.pageInfo.templates || [];
1353
+ }
1354
+ get images() {
1355
+ return this.pageInfo.images || [];
1356
+ }
1357
+ }
1358
+ return t;
1359
+ }
1360
+ const K = /* @__PURE__ */ new WeakMap(), P = {
1361
+ toDBKey: (n) => n.replace(/ /g, "_"),
1362
+ toNormalText: (n) => n.replace(/_/g, " "),
1363
+ ensureCase: (n, t) => t === "first-letter" ? n.charAt(0).toUpperCase() + n.slice(1) : n
1364
+ }, v = {
1365
+ /**
1366
+ * 标准化特殊页面名称:转换为全小写
1367
+ */
1368
+ normalizeSpecialPageName: (n) => n.toLowerCase(),
1369
+ /**
1370
+ * 构建特殊页面别名索引
1371
+ */
1372
+ buildSpecialPageIndex: (n) => {
1373
+ const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map();
1374
+ for (const s of n.specialpagealiases) {
1375
+ const i = s.realname;
1376
+ t.set(i, i);
1377
+ const o = v.normalizeSpecialPageName(i);
1378
+ e.set(o, i);
1379
+ for (const a of s.aliases) {
1380
+ r.set(a, i);
1381
+ const c = v.normalizeSpecialPageName(a);
1382
+ e.set(c, i);
1383
+ }
1384
+ }
1385
+ return { byRealName: t, byAlias: r, byNormalized: e };
1386
+ },
1387
+ /**
1388
+ * 查找特殊页面的真实名称
1389
+ */
1390
+ findSpecialPageRealName: (n, t) => {
1391
+ const r = n.split("/")[0];
1392
+ let e = t.byRealName.get(r) ?? t.byAlias.get(r);
1393
+ if (e !== void 0)
1394
+ return e;
1395
+ const s = v.normalizeSpecialPageName(r);
1396
+ return t.byNormalized.get(s) ?? null;
1397
+ }
1398
+ }, S = {
1399
+ /**
1400
+ * 标准化命名空间文本:转换为全小写+下划线格式
1401
+ */
1402
+ normalizeNamespaceText: (n) => n.replace(/[_\s]+/g, "_").toLowerCase().replace(/^_+|_+$/g, ""),
1403
+ buildIndex: (n) => {
1404
+ const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
1405
+ for (const [i, o] of Object.entries(n.namespaces)) {
1406
+ const a = parseInt(i);
1407
+ t.set(o.name, a), r.set(o.canonical ?? "", a);
1408
+ const c = S.normalizeNamespaceText(o.name), l = S.normalizeNamespaceText(o.canonical ?? "");
1409
+ s.set(c, a), s.set(l, a);
1410
+ }
1411
+ for (const i of n.namespacealiases) {
1412
+ e.set(i.alias, i.id);
1413
+ const o = S.normalizeNamespaceText(i.alias);
1414
+ s.set(o, i.id);
1415
+ }
1416
+ return { byName: t, byCanonical: r, byAlias: e, byNormalized: s };
1417
+ },
1418
+ findNamespaceId: (n, t) => {
1419
+ let r = t.byName.get(n) ?? t.byCanonical.get(n) ?? t.byAlias.get(n);
1420
+ if (r !== void 0)
1421
+ return r;
1422
+ const e = S.normalizeNamespaceText(n);
1423
+ return t.byNormalized.get(e) ?? null;
1424
+ },
1425
+ isTalkPage: (n) => n % 2 === 1 && n > 0,
1426
+ getDefaultNamespaceInfo: (n) => ({
1427
+ id: n,
1428
+ name: "",
1429
+ canonical: "",
1430
+ case: "first-letter",
1431
+ content: !1,
1432
+ nonincludable: !1,
1433
+ subpages: !1
1434
+ })
1435
+ };
1436
+ function se(n) {
1437
+ const t = K.get(n);
1438
+ if (t)
1439
+ return t;
1440
+ const r = S.buildIndex(n), e = v.buildSpecialPageIndex(n);
1441
+ class s {
1442
+ constructor(o, a) {
1443
+ if (this.newTitle = s.create.bind(s), this.toText = this.getPrefixedText.bind(this), this.toString = this.getPrefixedDBKey.bind(this), this.#t = o || "", this.#e = a ?? 0, a === void 0)
1444
+ this.fixNSByTitle();
1445
+ else {
1446
+ const c = this.parseTitlePrefix(this.#t);
1447
+ c && c.namespaceId === this.#e && (this.#t = c.mainTitle);
1448
+ }
1449
+ if (this.getMainText() === "")
1450
+ throw new Error("Invalid title");
1451
+ }
1452
+ static {
1453
+ this._meta = n;
1454
+ }
1455
+ static {
1456
+ this._namespaceIndex = r;
1457
+ }
1458
+ static {
1459
+ this._specialPageIndex = e;
1460
+ }
1461
+ /** 缓存的 main title,不包含命名空间前缀,大小写和空格状态不确定 */
1462
+ #t;
1463
+ /** 缓存的 namespace ID */
1464
+ #e;
1465
+ static create(o, a) {
1466
+ return new s(o, a);
1467
+ }
1468
+ /**
1469
+ * 解析标题前缀,返回匹配到的命名空间 ID 与剥离后的主标题
1470
+ */
1471
+ parseTitlePrefix(o) {
1472
+ const a = o.indexOf(":");
1473
+ if (a <= 0)
1474
+ return null;
1475
+ const c = o.substring(0, a), l = o.substring(a + 1), f = S.findNamespaceId(
1476
+ c,
1477
+ s._namespaceIndex
1478
+ );
1479
+ return f === null ? null : { namespaceId: f, mainTitle: l };
1480
+ }
1481
+ /**
1482
+ * 如果标题包含可识别命名空间,则采用该命名空间并剥离前缀
1483
+ */
1484
+ adoptNamespaceFromTitle() {
1485
+ const o = this.parseTitlePrefix(this.#t);
1486
+ o && (this.#t = o.mainTitle, this.#e = o.namespaceId);
1487
+ }
1488
+ fixNSByTitle() {
1489
+ const o = this.#t.indexOf(":");
1490
+ if (o !== -1) {
1491
+ if (o === 0) {
1492
+ this.#t = this.#t.substring(1);
1493
+ return;
1494
+ }
1495
+ this.adoptNamespaceFromTitle();
1496
+ }
1497
+ }
1498
+ getNamespaceInfo() {
1499
+ return s._meta.namespaces[this.#e] ?? S.getDefaultNamespaceInfo(this.#e);
1500
+ }
1501
+ /**
1502
+ * 若为特殊页面,返回解析后的真实主名(含子页面);否则返回 null
1503
+ */
1504
+ resolveSpecialFullTitle() {
1505
+ if (this.#e !== -1) return null;
1506
+ const o = v.findSpecialPageRealName(
1507
+ this.#t,
1508
+ s._specialPageIndex
1509
+ );
1510
+ if (!o) return null;
1511
+ const a = this.#t.includes("/") ? this.#t.substring(this.#t.indexOf("/")) : "";
1512
+ return o + a;
1513
+ }
1514
+ /**
1515
+ * 将主标题格式化为输出内容(文本或 DBKey),并做大小写规范化
1516
+ */
1517
+ formatMainForOutput(o) {
1518
+ const a = this.getNamespaceInfo(), l = this.resolveSpecialFullTitle() ?? this.#t, f = o === "db" ? P.toDBKey(l) : P.toNormalText(l);
1519
+ return P.ensureCase(f, a.case);
1520
+ }
1521
+ getMainDBKey() {
1522
+ return this.formatMainForOutput("db");
1523
+ }
1524
+ getMainText() {
1525
+ return this.formatMainForOutput("text");
1526
+ }
1527
+ getMainRootText() {
1528
+ return this.getMainText().split("/")[0];
1529
+ }
1530
+ getPrefixedDBKey() {
1531
+ return this.#e === 0 ? this.getMainDBKey() : `${this.getNamespaceDBKey()}:${this.getMainDBKey()}`;
1532
+ }
1533
+ getPrefixedText() {
1534
+ return this.#e === 0 ? this.getMainText() : `${this.getNamespaceText()}:${this.getMainText()}`;
1535
+ }
1536
+ getNamespaceId() {
1537
+ return this.#e;
1538
+ }
1539
+ getNamespaceText() {
1540
+ return this.getNamespaceInfo().name ?? "";
1541
+ }
1542
+ getNamespaceDBKey() {
1543
+ const o = this.getNamespaceInfo();
1544
+ return P.ensureCase(P.toDBKey(this.getNamespaceText()), o.case);
1545
+ }
1546
+ getSubjectPage() {
1547
+ if (S.isTalkPage(this.#e)) {
1548
+ const o = this.#e - 1;
1549
+ return new s(this.#t, o);
1550
+ }
1551
+ return this;
1552
+ }
1553
+ getTalkPage() {
1554
+ if (S.isTalkPage(this.#e))
1555
+ return this;
1556
+ if (this.#e < 0)
1557
+ return null;
1558
+ const o = this.#e + 1;
1559
+ return s._meta.namespaces[o.toString()] ? new s(this.#t, o) : null;
1560
+ }
1561
+ getURL(o) {
1562
+ const a = this.getPrefixedDBKey();
1563
+ return this.buildArticleURL(a, o);
1564
+ }
1565
+ /**
1566
+ * 构建文章 URL 并附加查询参数
1567
+ */
1568
+ buildArticleURL(o, a) {
1569
+ const l = s._meta.general.articlepath.replace("$1", o), f = new URL(l, location.origin);
1570
+ return a && (a instanceof URLSearchParams ? a : new URLSearchParams(a)).forEach((g, h) => {
1571
+ f.searchParams.set(h, g);
1572
+ }), f;
1573
+ }
1574
+ /**
1575
+ * 设置标题,重置当前实例的 dbkey 和 ns
1576
+ * 行为:
1577
+ * - 如果标题包含可识别的命名空间前缀,则以该前缀为准更新 ns,并移除前缀
1578
+ * - 如果标题前缀与当前 ns 相同,则仅移除冗余前缀并保留当前 ns
1579
+ * - 否则(无前缀),重置为主命名空间
1580
+ */
1581
+ setTitle(o) {
1582
+ this.#t = o;
1583
+ const a = this.#e;
1584
+ this.#e = 0;
1585
+ const c = this.parseTitlePrefix(this.#t);
1586
+ return c ? (a !== 0 && c.namespaceId === a ? (this.#t = c.mainTitle, this.#e = a) : (this.#t = c.mainTitle, this.#e = c.namespaceId), this) : this;
1587
+ }
1588
+ setMainText(o) {
1589
+ return this.#t = o, this;
1590
+ }
1591
+ setNamespaceText(o) {
1592
+ const a = S.findNamespaceId(o, s._namespaceIndex);
1593
+ return a !== null && (this.#e = a), this;
1594
+ }
1595
+ setNamespaceId(o) {
1596
+ return this.#e = o, this;
1597
+ }
1598
+ equals(o) {
1599
+ return typeof o == "string" && (o = new s(o)), this.getPrefixedDBKey() === o.getPrefixedDBKey();
1600
+ }
1601
+ isSpecial(o) {
1602
+ if (this.#e !== -1)
1603
+ return !1;
1604
+ const a = new s(o, -1);
1605
+ return this.getMainRootText() === a.getMainRootText();
1606
+ }
1607
+ toJSON() {
1608
+ return {
1609
+ ns: this.#e,
1610
+ text: this.getMainText(),
1611
+ title: this.getPrefixedText(),
1612
+ url: this.getURL().toString(),
1613
+ isSpecial: this.#e < 0
1614
+ };
1615
+ }
1616
+ }
1617
+ return K.set(n, s), s;
1618
+ }
1619
+ export {
1620
+ L as M,
1621
+ Z as W,
1622
+ se as a,
1623
+ ee as b,
1624
+ re as c,
1625
+ E as d,
1626
+ D as e,
1627
+ A as f,
1628
+ V as r,
1629
+ te as u
1630
+ };
1631
+ //# sourceMappingURL=index-CYfkwXRf.js.map