@inpageedit/core 0.14.4 → 0.15.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 (71) hide show
  1. package/dist/{BasePlugin-DD7l-5Xw.js → BasePlugin-BCVSn9QJ.js} +2 -2
  2. package/dist/{BasePlugin-DD7l-5Xw.js.map → BasePlugin-BCVSn9QJ.js.map} +1 -1
  3. package/dist/InputBox-CZ1v4_l3.js +50 -0
  4. package/dist/InputBox-CZ1v4_l3.js.map +1 -0
  5. package/dist/PluginImagesUsed-Bq_C_rgg.js +90 -0
  6. package/dist/PluginImagesUsed-Bq_C_rgg.js.map +1 -0
  7. package/dist/{PluginPrefSync-CbFuuC19.js → PluginPrefSync-DP5NyPnI.js} +4 -4
  8. package/dist/{PluginPrefSync-CbFuuC19.js.map → PluginPrefSync-DP5NyPnI.js.map} +1 -1
  9. package/dist/{PluginStoreApp-MbC3G9tu.js → PluginStoreApp-_YWpLgfs.js} +2 -2
  10. package/dist/{PluginStoreApp-MbC3G9tu.js.map → PluginStoreApp-_YWpLgfs.js.map} +1 -1
  11. package/dist/PluginTemplatesUsed-DS_rHctR.js +76 -0
  12. package/dist/PluginTemplatesUsed-DS_rHctR.js.map +1 -0
  13. package/dist/Preferences-DqtjY7XU.js +1541 -0
  14. package/dist/Preferences-DqtjY7XU.js.map +1 -0
  15. package/dist/browser-DR-yCqVg.js +1160 -0
  16. package/dist/browser-DR-yCqVg.js.map +1 -0
  17. package/dist/components/index.js +1 -1
  18. package/dist/{index-BpQ6VGMz.js → index-B9VO3swL.js} +108 -63
  19. package/dist/index-B9VO3swL.js.map +1 -0
  20. package/dist/{index-BanevHQ2.js → index-C3t-Xj3e.js} +85 -82
  21. package/dist/index-C3t-Xj3e.js.map +1 -0
  22. package/dist/{index-WfXtYVMt.js → index-CS1kidKF.js} +149 -117
  23. package/dist/index-CS1kidKF.js.map +1 -0
  24. package/dist/index-Cb2_vqBl.js +44 -0
  25. package/dist/index-Cb2_vqBl.js.map +1 -0
  26. package/dist/{index-B3jld2sl.js → index-CbdkXGs7.js} +4 -4
  27. package/dist/{index-B3jld2sl.js.map → index-CbdkXGs7.js.map} +1 -1
  28. package/dist/{index-BdHmr8jw.js → index-CcAmmXbb.js} +904 -704
  29. package/dist/index-CcAmmXbb.js.map +1 -0
  30. package/dist/index-Cq8xPcEY.js +170 -0
  31. package/dist/index-Cq8xPcEY.js.map +1 -0
  32. package/dist/{index-DensW9qt.js → index-DPA1ptYq.js} +5 -5
  33. package/dist/index-DPA1ptYq.js.map +1 -0
  34. package/dist/{index-BjDTD66_.js → index-DVvsTsLI.js} +29 -15
  35. package/dist/index-DVvsTsLI.js.map +1 -0
  36. package/dist/{index-CnR6CqkM.js → index-DjyjqpeO.js} +2 -2
  37. package/dist/{index-CnR6CqkM.js.map → index-DjyjqpeO.js.map} +1 -1
  38. package/dist/index-FvMu0Ka0.js +342 -0
  39. package/dist/index-FvMu0Ka0.js.map +1 -0
  40. package/dist/index-mFwJhDwE.js +168 -0
  41. package/dist/index-mFwJhDwE.js.map +1 -0
  42. package/dist/{index-De25v1_Q.js → index-n5KKWE9v.js} +6 -6
  43. package/dist/index-n5KKWE9v.js.map +1 -0
  44. package/dist/{index-DKCZDN-Q.js → index-rKL4D_7I.js} +5 -5
  45. package/dist/{index-DKCZDN-Q.js.map → index-rKL4D_7I.js.map} +1 -1
  46. package/dist/index.d.ts +334 -147
  47. package/dist/index.js +5 -5
  48. package/dist/models/index.js +1 -1
  49. package/dist/plugins/index.js +18 -14
  50. package/dist/plugins/index.js.map +1 -1
  51. package/dist/services/index.js +9 -8
  52. package/dist/style.css +1 -1
  53. package/lib/index.umd.js +14 -12
  54. package/lib/index.umd.js.map +1 -1
  55. package/lib/style.css +1 -1
  56. package/package.json +4 -2
  57. package/dist/InputBox-nQKtiWtZ.js +0 -30
  58. package/dist/InputBox-nQKtiWtZ.js.map +0 -1
  59. package/dist/Preferences-C10tZMl1.js +0 -2701
  60. package/dist/Preferences-C10tZMl1.js.map +0 -1
  61. package/dist/index-BXNyXvre.js +0 -116
  62. package/dist/index-BXNyXvre.js.map +0 -1
  63. package/dist/index-BanevHQ2.js.map +0 -1
  64. package/dist/index-BdHmr8jw.js.map +0 -1
  65. package/dist/index-BjDTD66_.js.map +0 -1
  66. package/dist/index-BpQ6VGMz.js.map +0 -1
  67. package/dist/index-DVOc6fB6.js +0 -211
  68. package/dist/index-DVOc6fB6.js.map +0 -1
  69. package/dist/index-De25v1_Q.js.map +0 -1
  70. package/dist/index-DensW9qt.js.map +0 -1
  71. package/dist/index-WfXtYVMt.js.map +0 -1
@@ -0,0 +1,1160 @@
1
+ function N(s) {
2
+ if (typeof globalThis.structuredClone == "function")
3
+ try {
4
+ return globalThis.structuredClone(s);
5
+ } catch {
6
+ }
7
+ return k(s, /* @__PURE__ */ new WeakMap());
8
+ }
9
+ function k(s, r) {
10
+ if (typeof s != "object" || s === null) return s;
11
+ const t = r.get(s);
12
+ if (t) return t;
13
+ if (s instanceof Date) return new Date(s.getTime());
14
+ if (s instanceof RegExp)
15
+ return new RegExp(s.source, s.flags);
16
+ if (s instanceof URL) return new URL(s.toString());
17
+ if (s instanceof URLSearchParams)
18
+ return new URLSearchParams(s.toString());
19
+ if (s instanceof ArrayBuffer) return s.slice(0);
20
+ if (ArrayBuffer.isView(s)) {
21
+ if (s instanceof DataView)
22
+ return new DataView(
23
+ s.buffer.slice(0),
24
+ s.byteOffset,
25
+ s.byteLength
26
+ );
27
+ const o = s, a = o.constructor;
28
+ return new a(o.buffer.slice(0), o.byteOffset, o.length);
29
+ }
30
+ if (s instanceof Map) {
31
+ const o = /* @__PURE__ */ new Map();
32
+ return r.set(s, o), s.forEach((a, c) => {
33
+ o.set(k(c, r), k(a, r));
34
+ }), o;
35
+ }
36
+ if (s instanceof Set) {
37
+ const o = /* @__PURE__ */ new Set();
38
+ return r.set(s, o), s.forEach((a) => o.add(k(a, r))), o;
39
+ }
40
+ if (Array.isArray(s)) {
41
+ const o = new Array(s.length);
42
+ r.set(s, o);
43
+ for (let a = 0; a < o.length; a++)
44
+ o[a] = k(s[a], r);
45
+ return o;
46
+ }
47
+ const e = Object.getPrototypeOf(s), n = Object.create(e);
48
+ r.set(s, n);
49
+ const i = Object.getOwnPropertyDescriptors(s);
50
+ for (const o of Reflect.ownKeys(i)) {
51
+ const a = i[o];
52
+ "value" in a && (a.value = k(a.value, r)), Object.defineProperty(n, o, a);
53
+ }
54
+ return n;
55
+ }
56
+ function L(s) {
57
+ if (typeof s != "object" || s === null)
58
+ return !1;
59
+ const r = Object.getPrototypeOf(s);
60
+ return r === Object.prototype || r === null;
61
+ }
62
+ const B = function(s) {
63
+ const r = this.constructor.prototype, t = Reflect.get(r, s, r);
64
+ function e(...n) {
65
+ return Reflect.apply(t, e, n);
66
+ }
67
+ Reflect.setPrototypeOf(e, r);
68
+ for (const n of Reflect.ownKeys(t)) {
69
+ const i = Reflect.getOwnPropertyDescriptor(t, n);
70
+ i && Reflect.defineProperty(e, n, i);
71
+ }
72
+ return e;
73
+ };
74
+ B.prototype = Object.create(Function.prototype);
75
+ const Y = B;
76
+ function S(s, ...r) {
77
+ const t = N(s || {});
78
+ for (const e of r)
79
+ if (e != null)
80
+ for (const n of Reflect.ownKeys(e)) {
81
+ const i = e[n];
82
+ if (typeof i > "u") continue;
83
+ if (i === null) {
84
+ delete t[n];
85
+ continue;
86
+ }
87
+ const o = t[n];
88
+ L(o) && L(i) ? t[n] = S(o, i) : t[n] = N(i);
89
+ }
90
+ return t;
91
+ }
92
+ var b = /* @__PURE__ */ ((s) => (s.BODY_USED = "BODY_USED", s.NO_BODY_READER = "NO_BODY_READER", s.TIMEOUT = "TIMEOUT", s.NETWORK_ERROR = "NETWORK_ERROR", s.BODY_NOT_ALLOWED = "BODY_NOT_ALLOWED", s.HOOK_CONTEXT_CHANGED = "HOOK_CONTEXT_CHANGED", s.ABORTED_BY_HOOK = "ABORTED_BY_HOOK", s.INVALID_HOOK_CALLBACK = "INVALID_HOOK_CALLBACK", s.UNEXPECTED_HOOK_RETURN = "UNEXPECTED_HOOK_RETURN", s.UNSUPPORTED_RESPONSE_TYPE = "UNSUPPORTED_RESPONSE_TYPE", s.BODY_TRANSFORM_ERROR = "BODY_TRANSFORM_ERROR", s))(b || {});
93
+ class E extends Error {
94
+ constructor(r, t, e, n) {
95
+ super(t, n), this.code = r, this.context = e;
96
+ }
97
+ name = "FexiosError";
98
+ static is(r, t) {
99
+ return !(r instanceof E) || r instanceof _ ? !1 : t ? r.code === t : !0;
100
+ }
101
+ }
102
+ class _ extends E {
103
+ constructor(r, t, e) {
104
+ super(t.statusText, r, void 0, e), this.response = t;
105
+ }
106
+ name = "FexiosResponseError";
107
+ static is(r) {
108
+ return r instanceof _;
109
+ }
110
+ }
111
+ var D;
112
+ ((s) => {
113
+ s.makeHeaders = (r) => {
114
+ if (!r) return new Headers();
115
+ if (r instanceof Headers) return new Headers(r);
116
+ const t = new Headers();
117
+ if (r instanceof Map) {
118
+ for (const [e, n] of r.entries())
119
+ if (n != null)
120
+ if (Array.isArray(n))
121
+ for (const i of n)
122
+ i != null && t.append(e, String(i));
123
+ else
124
+ t.append(e, String(n));
125
+ return t;
126
+ }
127
+ if (L(r)) {
128
+ for (const [e, n] of Object.entries(r))
129
+ if (n != null)
130
+ if (Array.isArray(n))
131
+ for (const i of n)
132
+ i != null && t.append(e, String(i));
133
+ else
134
+ t.append(e, String(n));
135
+ return t;
136
+ }
137
+ throw new TypeError(
138
+ "only plain object, Map/ReadonlyMap, or Headers is supported"
139
+ );
140
+ }, s.toHeaderRecord = (r) => {
141
+ if (r instanceof Headers) {
142
+ const t = {};
143
+ return r.forEach((e, n) => {
144
+ t[n] = t[n] ? [...t[n], e] : [e];
145
+ }), t;
146
+ }
147
+ if (r instanceof Map) {
148
+ const t = {};
149
+ for (const [e, n] of r.entries())
150
+ if (n != null)
151
+ if (Array.isArray(n)) {
152
+ const i = n.filter((o) => o != null).map((o) => String(o));
153
+ i.length && (t[e] = (t[e] ?? []).concat(i));
154
+ } else {
155
+ const i = String(n);
156
+ t[e] = t[e] ? [...t[e], i] : [i];
157
+ }
158
+ return t;
159
+ }
160
+ throw new TypeError(
161
+ `unsupported type transformation, got: ${Object.prototype.toString.call(
162
+ r
163
+ )}`
164
+ );
165
+ }, s.mergeHeaders = (...r) => {
166
+ const t = new Headers(), e = (n) => {
167
+ for (const [i, o] of Object.entries(n))
168
+ if (o !== void 0) {
169
+ if (o === null) {
170
+ t.delete(i);
171
+ continue;
172
+ }
173
+ if (Array.isArray(o)) {
174
+ t.delete(i);
175
+ for (const a of o)
176
+ a != null && t.append(i, String(a));
177
+ } else
178
+ t.set(i, String(o));
179
+ }
180
+ };
181
+ for (const n of r) {
182
+ if (n == null) continue;
183
+ if (n instanceof Headers) {
184
+ n.forEach((o, a) => {
185
+ t.set(a, o);
186
+ });
187
+ continue;
188
+ }
189
+ if (L(n)) {
190
+ e(n);
191
+ continue;
192
+ }
193
+ const i = (0, s.toHeaderRecord)(n);
194
+ for (const [o, a] of Object.entries(i)) {
195
+ t.delete(o);
196
+ for (const c of a) t.append(o, c);
197
+ }
198
+ }
199
+ return t;
200
+ };
201
+ })(D || (D = {}));
202
+ var O;
203
+ ((s) => {
204
+ s.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 n = new URLSearchParams(), i = (c, f) => {
212
+ f != null && n.append(c, f);
213
+ }, o = (c, f) => {
214
+ f != null && n.set(c, f);
215
+ }, a = (c, f) => {
216
+ if (f != null) {
217
+ if (Array.isArray(f)) {
218
+ for (const u of f) i(c, u?.toString());
219
+ return;
220
+ }
221
+ if (typeof f == "object" && f.constructor === Object) {
222
+ for (const [u, l] of Object.entries(f)) {
223
+ if (l == null) continue;
224
+ const d = u.endsWith("[]"), h = d ? u.slice(0, -2) : u, y = `${c}[${h}]`;
225
+ if (d) {
226
+ const w = `${y}[]`;
227
+ if (Array.isArray(l))
228
+ for (const p of l) i(w, p?.toString());
229
+ else typeof l == "object" && l !== null && l.constructor === Object ? a(`${y}[]`, l) : i(w, l?.toString());
230
+ } else if (Array.isArray(l))
231
+ for (const w of l) i(y, w?.toString());
232
+ else typeof l == "object" && l !== null && l.constructor === Object ? a(y, l) : o(y, l?.toString());
233
+ }
234
+ return;
235
+ }
236
+ o(c, f?.toString());
237
+ }
238
+ };
239
+ for (const [c, f] of Object.entries(e))
240
+ a(c, f);
241
+ return n;
242
+ }, s.makeQueryString = (e) => (0, s.makeSearchParams)(e).toString(), s.makeURL = (e, n, 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), f = (0, s.toQueryRecord)(c.searchParams), u = (0, s.mergeQueries)(f, n || {}), l = (0, s.makeSearchParams)(u);
244
+ return c.search = l.toString(), typeof i < "u" && (c.hash = i), c;
245
+ }, s.toQueryRecord = (e) => {
246
+ typeof e == "string" && (e = (0, s.fromString)(e));
247
+ const n = {}, i = (a) => {
248
+ if (!a.includes("[")) return { path: [a], forceArray: !1 };
249
+ const c = [a.slice(0, a.indexOf("["))], f = /\[([^\]]*)\]/g;
250
+ let u, l = !1, d = !1;
251
+ for (; u = f.exec(a); )
252
+ u[1] === "" ? (l = !0, d = !0) : (c.push(u[1]), d = !1);
253
+ return l && d && (c[c.length - 1] = c[c.length - 1] + "[]"), { path: c, forceArray: l };
254
+ }, o = (a, c, f, u) => {
255
+ let l = a;
256
+ for (let d = 0; d < c.length; d++) {
257
+ const h = c[d];
258
+ d === c.length - 1 ? u ? l[h] === void 0 ? l[h] = [f] : Array.isArray(l[h]) ? l[h].push(f) : l[h] = [l[h], f] : l[h] === void 0 ? l[h] = f : Array.isArray(l[h]) ? l[h].push(f) : l[h] = [l[h], f] : ((l[h] === void 0 || typeof l[h] != "object" || Array.isArray(l[h])) && (l[h] = {}), l = l[h]);
259
+ }
260
+ };
261
+ for (const [a, c] of e.entries()) {
262
+ const { path: f, forceArray: u } = i(String(a));
263
+ o(n, f, c?.toString(), u);
264
+ }
265
+ return n;
266
+ }, s.fromString = (e) => {
267
+ const n = e.trim();
268
+ if (!n) return new URLSearchParams();
269
+ if (n.startsWith("?")) return new URLSearchParams(n.slice(1));
270
+ const i = n.indexOf("?");
271
+ if (i >= 0) {
272
+ const o = n.indexOf("#", i + 1), a = n.slice(i + 1, o >= 0 ? o : void 0);
273
+ return new URLSearchParams(a);
274
+ }
275
+ return new URLSearchParams(n);
276
+ }, s.mergeQueries = (...e) => {
277
+ const n = {};
278
+ for (const i of e)
279
+ i != null && t(n, r(i));
280
+ return n;
281
+ };
282
+ function r(e) {
283
+ if (!e) return {};
284
+ if (e instanceof URLSearchParams || e instanceof FormData || e instanceof Map)
285
+ return (0, s.toQueryRecord)(e);
286
+ if (typeof e == "string") return (0, s.toQueryRecord)((0, s.fromString)(e));
287
+ if (L(e)) return e;
288
+ throw new TypeError(
289
+ `unsupported type transformation, got: ${Object.prototype.toString.call(
290
+ e
291
+ )}`
292
+ );
293
+ }
294
+ function t(e, n) {
295
+ for (const [i, o] of Object.entries(n)) {
296
+ if (o === void 0) continue;
297
+ if (o === null) {
298
+ delete e[i];
299
+ continue;
300
+ }
301
+ const a = e[i];
302
+ L(a) && L(o) ? t(a, o) : e[i] = N(o);
303
+ }
304
+ }
305
+ })(O || (O = {}));
306
+ class I {
307
+ constructor(r, t, e) {
308
+ this.rawResponse = r, this.data = t, this.responseType = e, ["ok", "status", "statusText", "headers", "url", "redirected"].forEach(
309
+ (n) => {
310
+ Reflect.defineProperty(this, n, {
311
+ get: () => r[n]
312
+ });
313
+ }
314
+ );
315
+ }
316
+ ok;
317
+ status;
318
+ statusText;
319
+ headers;
320
+ url;
321
+ redirected;
322
+ }
323
+ const P = (s) => {
324
+ const r = s.reduce((n, i) => n + i.length, 0), t = new Uint8Array(r);
325
+ let e = 0;
326
+ for (const n of s)
327
+ t.set(n, e), e += n.length;
328
+ return t;
329
+ };
330
+ async function K(s, r, t) {
331
+ const e = s.getReader();
332
+ if (!e)
333
+ throw new E(
334
+ b.NO_BODY_READER,
335
+ "Failed to get ReadableStream from response body"
336
+ );
337
+ const n = [];
338
+ let i = 0;
339
+ try {
340
+ for (; ; ) {
341
+ const { done: a, value: c } = await e.read();
342
+ if (a) break;
343
+ n.push(c), i += c.length, t && r > 0 && t(i / r, P(n));
344
+ }
345
+ } finally {
346
+ e.releaseLock?.();
347
+ }
348
+ const o = P(n);
349
+ return t?.(1, o), o;
350
+ }
351
+ const $ = (s) => {
352
+ if (s) {
353
+ if (s.includes("application/json") || s.endsWith("+json"))
354
+ return "json";
355
+ if (s.startsWith("text/")) return "text";
356
+ if (s.includes("multipart/form-data") || s.includes("application/x-www-form-urlencoded"))
357
+ return "form";
358
+ if (/^image\//.test(s) || /^video\//.test(s) || /^audio\//.test(s) || s.includes("application/pdf"))
359
+ return "blob";
360
+ if (s.includes("application/octet-stream") || s.includes("application/zip") || s.includes("application/x-tar") || s.includes("application/x-7z-compressed") || s.includes("application/x-gzip"))
361
+ return "arrayBuffer";
362
+ }
363
+ };
364
+ async function x(s, r, t, e, n) {
365
+ const i = s.headers.get("content-type")?.toLowerCase() ?? "", o = s.headers.get("content-length"), a = o ? Number(o) : 0, c = s.headers.get("upgrade")?.toLowerCase(), f = s.headers.get("connection")?.toLowerCase();
366
+ let u = r ?? $(i) ?? "text";
367
+ if (r || (c === "websocket" && f === "upgrade" ? u = "ws" : i.includes("text/event-stream") && (u = "stream")), u === "stream") {
368
+ const p = s.url || s.url || "", g = await Q(
369
+ p,
370
+ s,
371
+ n
372
+ ), T = e?.(g);
373
+ if (typeof T == "boolean" ? T : !g.ok)
374
+ throw new _(g.statusText, g);
375
+ return g;
376
+ }
377
+ if (u === "ws") {
378
+ const p = s.url || s.url || "", g = await H(
379
+ p,
380
+ s,
381
+ n
382
+ ), T = e?.(g);
383
+ if (typeof T == "boolean" ? T : !g.ok)
384
+ throw new _(g.statusText, g);
385
+ return g;
386
+ }
387
+ const l = /\bcharset=([^;]+)/i.exec(i)?.[1]?.trim() || "utf-8", d = new TextDecoder(l);
388
+ let h;
389
+ try {
390
+ if (u === "form")
391
+ h = await s.formData();
392
+ else {
393
+ const p = await K(s.body, a, t);
394
+ if (u === "arrayBuffer")
395
+ h = p.buffer.slice(
396
+ p.byteOffset,
397
+ p.byteOffset + p.byteLength
398
+ );
399
+ else if (u === "blob")
400
+ h = new Blob([p], {
401
+ type: i || "application/octet-stream"
402
+ });
403
+ else if (u === "text") {
404
+ const g = d.decode(p);
405
+ if (r)
406
+ h = g;
407
+ else {
408
+ const T = g.trim();
409
+ if (T.startsWith("{") && T.endsWith("}") || T.startsWith("[") && T.endsWith("]"))
410
+ try {
411
+ h = JSON.parse(T), u = "json";
412
+ } catch {
413
+ h = g;
414
+ }
415
+ else
416
+ h = g;
417
+ }
418
+ } else if (u === "json") {
419
+ const g = d.decode(p);
420
+ h = g.length ? JSON.parse(g) : null;
421
+ } else
422
+ h = p;
423
+ }
424
+ } catch (p) {
425
+ if (!(p instanceof Error)) throw p;
426
+ try {
427
+ h = await s.text(), u = "text";
428
+ } catch {
429
+ throw new E(
430
+ b.BODY_TRANSFORM_ERROR,
431
+ `Failed to transform response body to ${u}`,
432
+ void 0,
433
+ { cause: p }
434
+ );
435
+ }
436
+ }
437
+ const y = new I(
438
+ s,
439
+ h,
440
+ u
441
+ ), w = e?.(y);
442
+ if (typeof w == "boolean" ? w : !y.ok)
443
+ throw new _(y.statusText, y);
444
+ return y;
445
+ }
446
+ async function H(s, r, t) {
447
+ const e = new WebSocket(s.toString()), n = t ?? 6e4;
448
+ return await new Promise((i, o) => {
449
+ const a = n > 0 ? setTimeout(() => {
450
+ e.close(), o(
451
+ new E(
452
+ b.TIMEOUT,
453
+ `WebSocket connection timed out after ${n}ms`
454
+ )
455
+ );
456
+ }, n) : void 0;
457
+ let c = !1;
458
+ const f = () => {
459
+ clearTimeout(a), e.removeEventListener("open", u), e.removeEventListener("error", l), e.removeEventListener("close", d);
460
+ }, u = () => {
461
+ c || (c = !0, f(), i());
462
+ }, l = (h) => {
463
+ c || (c = !0, f(), o(
464
+ new E(
465
+ b.NETWORK_ERROR,
466
+ "WebSocket connection failed",
467
+ void 0,
468
+ { cause: h }
469
+ )
470
+ ));
471
+ }, d = (h) => {
472
+ c || (c = !0, f(), o(
473
+ new E(
474
+ b.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", u), e.addEventListener("error", l), e.addEventListener("close", d);
482
+ }), new I(r || new Response(null), e, "ws");
483
+ }
484
+ async function Q(s, r, t) {
485
+ const e = new EventSource(s.toString()), n = t ?? 6e4;
486
+ return await new Promise((i, o) => {
487
+ const a = n > 0 ? setTimeout(() => {
488
+ e.close(), o(
489
+ new E(
490
+ b.TIMEOUT,
491
+ `EventSource connection timed out after ${n}ms`
492
+ )
493
+ );
494
+ }, n) : void 0;
495
+ let c = !1;
496
+ const f = () => {
497
+ clearTimeout(a), e.removeEventListener("open", u), e.removeEventListener("error", l);
498
+ }, u = () => {
499
+ c || (c = !0, f(), i());
500
+ }, l = (d) => {
501
+ c || (c = !0, f(), o(
502
+ new E(
503
+ b.NETWORK_ERROR,
504
+ "EventSource connection failed",
505
+ void 0,
506
+ { cause: d }
507
+ )
508
+ ));
509
+ };
510
+ e.addEventListener("open", u), e.addEventListener("error", l);
511
+ }), new I(
512
+ r || new Response(null),
513
+ e,
514
+ "stream"
515
+ );
516
+ }
517
+ class m extends Y {
518
+ static version = "5.0.1";
519
+ static FINAL_SYMBOL = Symbol("FEXIOS_FINAL_CONTEXT");
520
+ baseConfigs;
521
+ // for axios compatibility
522
+ get defaults() {
523
+ return this.baseConfigs;
524
+ }
525
+ set defaults(r) {
526
+ this.baseConfigs = r;
527
+ }
528
+ static DEFAULT_CONFIGS = {
529
+ baseURL: "",
530
+ timeout: 0,
531
+ credentials: void 0,
532
+ headers: {},
533
+ query: {},
534
+ responseType: void 0,
535
+ shouldThrow(r) {
536
+ return !r.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(r = {}) {
558
+ super("request"), this.baseConfigs = S(m.DEFAULT_CONFIGS, r), m.ALL_METHODS.forEach(
559
+ (t) => this.createMethodShortcut(t.toLowerCase())
560
+ );
561
+ }
562
+ async request(r, t) {
563
+ let e = t || {};
564
+ if (typeof r == "string" || r instanceof URL ? e.url = r.toString() : typeof r == "object" && (e = r), 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 E(
569
+ b.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 n;
574
+ const i = {};
575
+ if (typeof e.body < "u" && e.body !== null && (e.body instanceof Blob || e.body instanceof FormData || e.body instanceof URLSearchParams ? n = e.body : typeof e.body == "object" && e.body !== null ? (n = JSON.stringify(e.body), e.headers = this.mergeHeaders(e.headers, {
576
+ "Content-Type": "application/json"
577
+ })) : n = e.body), !D.makeHeaders(e.headers || {}).get("content-type") && n && (n instanceof FormData || n instanceof URLSearchParams ? i["content-type"] = null : typeof n == "string" && typeof e.body == "object" ? i["content-type"] = "application/json" : n instanceof Blob && (i["content-type"] = n.type || "application/octet-stream")), e.body = n, e = await this.emit("afterBodyTransformed", e), e[m.FINAL_SYMBOL]) return e;
578
+ const o = e.abortController ?? (globalThis.AbortController ? new AbortController() : void 0), a = globalThis.location?.href || "http://localhost", c = new URL(
579
+ e.baseURL || this.baseConfigs.baseURL || a,
580
+ a
581
+ ), f = new URL(e.url, c), u = O.makeURL(
582
+ f,
583
+ e.query,
584
+ f.hash
585
+ // 保留 hash
586
+ ).toString(), l = new Request(u, {
587
+ method: e.method || "GET",
588
+ credentials: e.credentials,
589
+ cache: e.cache,
590
+ mode: e.mode,
591
+ headers: D.mergeHeaders(
592
+ this.baseConfigs.headers,
593
+ e.headers || {},
594
+ i
595
+ ),
596
+ body: e.body,
597
+ signal: o?.signal
598
+ });
599
+ if (e.rawRequest = l, e = await this.emit("beforeActualFetch", e), e[m.FINAL_SYMBOL]) return e;
600
+ const d = e.timeout ?? this.baseConfigs.timeout ?? 60 * 1e3, h = e.shouldThrow ?? this.baseConfigs.shouldThrow;
601
+ if (e.url.startsWith("ws") || e.responseType === "ws") {
602
+ const w = await H(
603
+ e.url,
604
+ void 0,
605
+ d
606
+ ), p = {
607
+ ...e,
608
+ response: w,
609
+ rawResponse: void 0,
610
+ data: w.data,
611
+ headers: w.headers
612
+ };
613
+ return this.emit("afterResponse", p);
614
+ }
615
+ let y;
616
+ try {
617
+ o && (y = d > 0 ? setTimeout(() => {
618
+ o.abort();
619
+ }, d) : void 0);
620
+ const w = await (e.fetch || this.baseConfigs.fetch || globalThis.fetch)(e.rawRequest).catch((p) => {
621
+ throw y && clearTimeout(y), o?.signal.aborted ? new E(
622
+ b.TIMEOUT,
623
+ `Request timed out after ${d}ms`,
624
+ e
625
+ ) : new E(b.NETWORK_ERROR, p.message, e);
626
+ });
627
+ return y && clearTimeout(y), e.rawResponse = w, e.response = await x(
628
+ w,
629
+ e.responseType,
630
+ (p, g) => {
631
+ t?.onProgress?.(p, g);
632
+ },
633
+ h,
634
+ d
635
+ ), Object.defineProperties(e, {
636
+ url: { get: () => w?.url || u },
637
+ data: { get: () => e.response.data },
638
+ headers: { get: () => w.headers },
639
+ responseType: { get: () => e.response.responseType }
640
+ }), this.emit("afterResponse", e);
641
+ } catch (w) {
642
+ throw y && clearTimeout(y), w;
643
+ }
644
+ }
645
+ mergeQueries = O.mergeQueries;
646
+ mergeHeaders = D.mergeHeaders;
647
+ applyDefaults(r) {
648
+ const t = r;
649
+ "customEnv" in this.baseConfigs && (t.customEnv = S(
650
+ {},
651
+ // ensure we don't mutate baseConfigs
652
+ this.baseConfigs.customEnv,
653
+ t.customEnv
654
+ ));
655
+ const e = globalThis.location?.href || "http://localhost", n = t.baseURL || this.baseConfigs.baseURL || e, i = new URL(n, e), o = new URL(t.url.toString(), i), a = O.toQueryRecord(i.searchParams), c = O.toQueryRecord(o.searchParams), f = O.mergeQueries(
656
+ a,
657
+ c
658
+ );
659
+ o.search = O.makeSearchParams(f).toString(), t.url = o.toString();
660
+ const u = O.mergeQueries(
661
+ this.baseConfigs.query,
662
+ t.query
663
+ );
664
+ return t.query && this.restoreNulls(u, t.query), t.query = u, t;
665
+ }
666
+ restoreNulls(r, t) {
667
+ if (!(!t || typeof t != "object"))
668
+ for (const [e, n] of Object.entries(t))
669
+ n === null ? r[e] = null : L(n) && ((!r[e] || typeof r[e] != "object") && (r[e] = {}), this.restoreNulls(r[e], n));
670
+ }
671
+ async emit(r, t, e = {
672
+ shouldHandleShortCircuitResponse: !0
673
+ }) {
674
+ const n = this.hooks.filter((o) => o.event === r);
675
+ if (n.length === 0) return t;
676
+ const i = async (o, a) => {
677
+ const c = { ...o, rawResponse: a }, f = await x(
678
+ a,
679
+ o.responseType,
680
+ (u, l) => o.onProgress?.(u, l),
681
+ o.shouldThrow ?? this.baseConfigs.shouldThrow,
682
+ o.timeout ?? this.baseConfigs.timeout ?? 60 * 1e3
683
+ );
684
+ if (c.response = f, c.data = f.data, c.headers = f.headers, r !== "afterResponse") {
685
+ const u = await this.emit("afterResponse", c);
686
+ return u[m.FINAL_SYMBOL] = !0, u;
687
+ } else
688
+ return c[m.FINAL_SYMBOL] = !0, c;
689
+ };
690
+ for (let o = 0; o < n.length; o++) {
691
+ const a = n[o], c = `${String(r)}#${a.action.name || `anonymous#${o}`}`, f = Symbol("FEXIOS_HOOK_CTX_MARK");
692
+ try {
693
+ t[f] = f;
694
+ } catch {
695
+ }
696
+ const u = await a.action.call(this, t);
697
+ try {
698
+ delete t[f];
699
+ } catch {
700
+ }
701
+ if (u === !1)
702
+ throw new E(
703
+ b.ABORTED_BY_HOOK,
704
+ `Request aborted by hook "${c}"`,
705
+ t
706
+ );
707
+ if (u instanceof Response) {
708
+ if (e.shouldHandleShortCircuitResponse !== !1)
709
+ return i(t, u);
710
+ t.rawResponse = u;
711
+ } else u && typeof u == "object" && u[f] === f && (t = u);
712
+ }
713
+ return t;
714
+ }
715
+ on(r, t, e = !1) {
716
+ if (typeof t != "function")
717
+ throw new E(
718
+ b.INVALID_HOOK_CALLBACK,
719
+ `Hook should be a function, but got "${typeof t}"`
720
+ );
721
+ return this.hooks[e ? "unshift" : "push"]({
722
+ event: r,
723
+ action: t
724
+ }), this;
725
+ }
726
+ off(r, t) {
727
+ return r === "*" || !r ? this.hooks = this.hooks.filter((e) => e.action !== t) : this.hooks = this.hooks.filter(
728
+ (e) => e.event !== r || e.action !== t
729
+ ), this;
730
+ }
731
+ createInterceptor(r) {
732
+ return {
733
+ handlers: () => this.hooks.filter((t) => t.event === r).map((t) => t.action),
734
+ use: (t, e = !1) => this.on(r, t, e),
735
+ clear: () => {
736
+ this.hooks = this.hooks.filter((t) => t.event !== r);
737
+ }
738
+ };
739
+ }
740
+ interceptors = {
741
+ request: this.createInterceptor("beforeRequest"),
742
+ response: this.createInterceptor("afterResponse")
743
+ };
744
+ createMethodShortcut(r) {
745
+ return Reflect.defineProperty(this, r, {
746
+ get: () => (t, e, n) => (m.METHODS_WITHOUT_BODY.includes(
747
+ r.toLocaleLowerCase()
748
+ ) ? n = e : (n = n || {}, n.body = e), this.request(t, {
749
+ ...n,
750
+ method: r
751
+ }))
752
+ }), this;
753
+ }
754
+ extends(r) {
755
+ const t = new m(S(this.baseConfigs, r));
756
+ return t.hooks = [...this.hooks], t._plugins = new Map(this._plugins), t._plugins.forEach(async (e) => {
757
+ await t.plugin(e);
758
+ }), t;
759
+ }
760
+ create = m.create;
761
+ static create(r) {
762
+ return new m(r);
763
+ }
764
+ _plugins = /* @__PURE__ */ new Map();
765
+ async plugin(r) {
766
+ if (typeof r?.name == "string" && typeof r?.install == "function") {
767
+ if (this._plugins.has(r.name))
768
+ return this;
769
+ const t = await r.install(this);
770
+ if (this._plugins.set(r.name, r), t instanceof m)
771
+ return t;
772
+ }
773
+ return this;
774
+ }
775
+ // 版本弃子们.jpg
776
+ /** @deprecated Use `import { checkIsPlainObject } from 'fexios/utils'` instead */
777
+ checkIsPlainObject = L;
778
+ /** @deprecated Use `mergeQueries` instead */
779
+ mergeQuery = this.mergeQueries;
780
+ }
781
+ const X = m.create, j = X();
782
+ typeof globalThis < "u" ? globalThis.fexios = j : typeof window < "u" && (window.fexios = j);
783
+ var C;
784
+ ((s) => {
785
+ function r(e) {
786
+ return Array.isArray(e) ? e.join("|") : typeof e == "boolean" || e === null ? e ? "1" : void 0 : typeof e == "number" ? "" + e : e;
787
+ }
788
+ s.normalizeParamValue = r;
789
+ function t(e) {
790
+ const n = (o) => o && (o instanceof URLSearchParams || o instanceof FormData);
791
+ if (e == null)
792
+ return;
793
+ const i = new FormData();
794
+ if (n(e))
795
+ return e.forEach((o, a) => {
796
+ const c = r(o);
797
+ c != null && i.append(a, c);
798
+ }), i;
799
+ if (L(e))
800
+ return Object.entries(e).forEach(([o, a]) => {
801
+ const c = r(a);
802
+ c != null && i.append(o, c);
803
+ }), i;
804
+ }
805
+ s.normalizeBody = t;
806
+ })(C || (C = {}));
807
+ var U = /* @__PURE__ */ ((s) => (s.HTTP_ERROR = "HTTP_ERROR", s.LOGIN_FAILED = "LOGIN_FAILED", s.LOGIN_RETRY_LIMIT_EXCEEDED = "LOGIN_RETRY_LIMIT_EXCEEDED", s.TOKEN_RETRY_LIMIT_EXCEEDED = "TOKEN_RETRY_LIMIT_EXCEEDED", s))(U || {});
808
+ class R extends Error {
809
+ constructor(r, t = "", e) {
810
+ super(), this.code = r, this.message = t, this.cause = e, this.name = "WikiSaikouError";
811
+ }
812
+ static is(r, t) {
813
+ return r instanceof this && (t === void 0 || r.code === t);
814
+ }
815
+ }
816
+ class A extends Error {
817
+ constructor(r, t) {
818
+ super(), this.errors = r, this.cause = t, this.name = "MediaWikiApiError", this.errors = A.normalizeErrors(r), this.message = r.map((e) => e.text).filter(Boolean).join(`
819
+ `), this.code = this.isBadTokenError() ? "badtoken" : this.errors[0]?.code || "Unknown Error";
820
+ }
821
+ get firstError() {
822
+ return this.errors[0];
823
+ }
824
+ isBadTokenError() {
825
+ return this.errors.some((r) => r.code === "badtoken") || ["NeedToken", "WrongToken"].includes(this.cause?.data?.login?.result);
826
+ }
827
+ toString() {
828
+ return `[${this.name} ${this.code}]`;
829
+ }
830
+ static is(r) {
831
+ return r instanceof this;
832
+ }
833
+ static normalizeErrors(r) {
834
+ return Array.isArray(r) === !1 ? [] : r.filter((t) => typeof t == "object" && !!t?.code).map((t) => t.text ? t : t.info ? { ...t, text: t.info } : t["*"] ? { ...t, text: t["*"] } : { ...t, text: "" });
835
+ }
836
+ }
837
+ ((s) => {
838
+ function r(i) {
839
+ if (i == null) return;
840
+ if (i?.response?.data !== void 0) return i.response.data;
841
+ if (i?.data !== void 0) return i.data;
842
+ const o = i instanceof Error ? i.cause : void 0;
843
+ return o?.response?.data !== void 0 ? o.response.data : o?.data !== void 0 ? o.data : i || void 0;
844
+ }
845
+ function t(i) {
846
+ return e(i).length > 0;
847
+ }
848
+ s.includesMediaWikiApiError = t, s.normalizeMwApiErrors = A.normalizeErrors;
849
+ function e(i) {
850
+ let o = r(i);
851
+ if (typeof o != "object" || o === null)
852
+ return [];
853
+ const a = o?.error, c = o?.errors, f = [];
854
+ return a && f.push(a), Array.isArray(c) && f.push(...c), (0, s.normalizeMwApiErrors)(f);
855
+ }
856
+ s.extractMediaWikiApiErrors = e;
857
+ function n(i) {
858
+ if (A.is(i))
859
+ return i.isBadTokenError();
860
+ {
861
+ const o = e(i);
862
+ return new A(o).isBadTokenError();
863
+ }
864
+ }
865
+ s.isBadTokenError = n;
866
+ })(R || (R = {}));
867
+ const M = Symbol.for("__FEXIOS_SAIKOU__");
868
+ function q(s) {
869
+ const r = s instanceof m ? s : new m({
870
+ baseURL: s instanceof URL ? s.toString() : String(s),
871
+ responseType: "json"
872
+ });
873
+ return r[M] || (Reflect.defineProperty(r, M, {
874
+ get: () => !0,
875
+ enumerable: !1,
876
+ configurable: !1
877
+ }), r.on("beforeInit", (t) => {
878
+ if (t.method?.toLowerCase() !== "post")
879
+ return t;
880
+ if (t.body === void 0 || t.body === null)
881
+ return t.body = void 0, t;
882
+ const e = t.body = C.normalizeBody(t.body), n = new URLSearchParams(t.query);
883
+ return e.has("format") && n.delete("format"), e.has("formatversion") && n.delete("formatversion"), e.has("action") && n.delete("action"), e.has("origin") && (n.set("origin", "" + e.get("origin")), e.delete("origin")), t.query = Object.fromEntries(n.entries()), t;
884
+ }), r.on("beforeInit", (t) => (t.query = O.mergeQueries(
885
+ {},
886
+ C.normalizeBody(t.query)
887
+ ), t)), r.on("beforeRequest", (t) => {
888
+ const e = new URL(t.url), n = O.mergeQueries(e.searchParams, t.query);
889
+ if (globalThis.location && (!n.origin && location.origin !== e.origin ? (n.origin = location.origin, r.baseConfigs.credentials = "include", r.baseConfigs.mode = "cors") : location.origin === e.origin && (delete n.origin, r.baseConfigs.credentials = void 0, r.baseConfigs.mode = void 0)), n.origin) {
890
+ const i = encodeURIComponent(n.origin).replace(/\./g, "%2E");
891
+ delete n.origin, t.query = n, t.url = `${e.origin}${e.pathname}?origin=${i}`;
892
+ } else
893
+ t.query = n;
894
+ return t;
895
+ }), r._tokens = /* @__PURE__ */ new Map(), r.on("afterResponse", (t) => {
896
+ const { data: e } = t, n = t.customEnv?.mwTokenName;
897
+ n && R.isBadTokenError(e) && r._tokens.delete(n);
898
+ const i = e?.query?.tokens;
899
+ i && typeof i == "object" && Object.entries(i).forEach(([a, c]) => {
900
+ typeof c == "string" && r._tokens.set(a.replace(/token$/i, "").toLowerCase(), c);
901
+ });
902
+ const o = e?.login?.token;
903
+ return typeof o == "string" && r._tokens.set("login", o), t;
904
+ })), r;
905
+ }
906
+ const W = (s, r, t) => {
907
+ let e = { ...F.DEFAULT_CONFIGS };
908
+ if (typeof s == "string" ? e = S(e, {
909
+ baseURL: s,
910
+ fexiosConfigs: r || {},
911
+ defaultParams: t || {},
912
+ throwOnApiError: !1
913
+ // Set a default value for throwOnApiError
914
+ }) : typeof s == "object" && s !== null && (e = S(e, s)), !e.baseURL && typeof window == "object" && window.mediaWiki) {
915
+ const { wgServer: n, wgScriptPath: i } = window.mediaWiki?.config?.get(["wgServer", "wgScriptPath"]) || {};
916
+ typeof n == "string" && typeof i == "string" && (e.baseURL = `${n}${i}/api.php`);
917
+ }
918
+ if (typeof e.baseURL != "string")
919
+ throw new Error("baseURL is required");
920
+ return e;
921
+ }, z = () => {
922
+ }, G = async (s, r) => {
923
+ let t = 0;
924
+ const { retry: e = 3, onRetry: n = z, shouldRetry: i = () => !0 } = r;
925
+ let o;
926
+ do
927
+ try {
928
+ return await s();
929
+ } catch (a) {
930
+ if (o = a, i(a, t))
931
+ n(a, t), t++;
932
+ else
933
+ throw a;
934
+ }
935
+ while (t < e);
936
+ throw o || new Error("Retry failed");
937
+ };
938
+ const v = class {
939
+ constructor(r, t, e) {
940
+ this.version = "7.3.0", this.token = this.getToken;
941
+ const n = this.config = W(
942
+ r,
943
+ t,
944
+ e
945
+ );
946
+ this.request = q(n.baseURL);
947
+ }
948
+ setBaseURL(r) {
949
+ return this.config.baseURL = r, this.request.baseConfigs.baseURL = r, this;
950
+ }
951
+ /** Base methods encapsulation */
952
+ async get(r, t) {
953
+ const e = S(
954
+ {},
955
+ this.config.fexiosConfigs,
956
+ {
957
+ query: O.mergeQueries(
958
+ this.config.defaultParams,
959
+ r
960
+ )
961
+ },
962
+ t
963
+ );
964
+ return this.runRequestWithApiErrorMapping(
965
+ () => this.request.get("", e)
966
+ );
967
+ }
968
+ async post(r, t) {
969
+ return this.runRequestWithApiErrorMapping(
970
+ () => this.request.post(
971
+ "",
972
+ r,
973
+ S(
974
+ {},
975
+ this.config.fexiosConfigs,
976
+ {
977
+ query: this.config.defaultParams
978
+ },
979
+ t
980
+ )
981
+ )
982
+ );
983
+ }
984
+ /**
985
+ * Wrap a request to map non-2xx responses containing MediaWiki API error bodies
986
+ * into MediaWikiApiError when throwOnApiError=true, and then pass 2xx responses
987
+ * through handleApiResponse for unified processing.
988
+ */
989
+ async runRequestWithApiErrorMapping(r) {
990
+ try {
991
+ const t = await r();
992
+ return this.handleApiResponse(t);
993
+ } catch (t) {
994
+ throw this.config.throwOnApiError && R.includesMediaWikiApiError(t) ? new A(
995
+ R.extractMediaWikiApiErrors(t),
996
+ t
997
+ ) : t;
998
+ }
999
+ }
1000
+ throwIfApiError(r) {
1001
+ const t = R.extractMediaWikiApiErrors(r);
1002
+ if (t.length > 0)
1003
+ throw new A(t, r);
1004
+ }
1005
+ handleApiResponse(r) {
1006
+ return this.config.throwOnApiError && this.throwIfApiError(r.data), r;
1007
+ }
1008
+ /** Token Handler */
1009
+ get tokens() {
1010
+ return this.request._tokens;
1011
+ }
1012
+ async fetchTokens(r = ["csrf"]) {
1013
+ return this.config.fexiosConfigs.credentials = "include", await this.get({
1014
+ action: "query",
1015
+ meta: "tokens",
1016
+ type: r
1017
+ }), this.tokens;
1018
+ }
1019
+ async getToken(r = "csrf", t = !1) {
1020
+ return (!this.tokens.get(r) || t) && (this.tokens.delete(r), await this.fetchTokens([r])), this.tokens.get(r);
1021
+ }
1022
+ badToken(r) {
1023
+ return this.tokens.delete(r), this.tokens;
1024
+ }
1025
+ async postWithToken(r, t, e) {
1026
+ const {
1027
+ tokenName: n = "token",
1028
+ retry: i = 3,
1029
+ noCache: o = !1,
1030
+ fexiosOptions: a
1031
+ } = e || {};
1032
+ if (i < 1)
1033
+ throw new R(
1034
+ U.TOKEN_RETRY_LIMIT_EXCEEDED,
1035
+ "The limit of the number of times to automatically re-acquire the token has been exceeded"
1036
+ );
1037
+ let c = 0;
1038
+ return G(
1039
+ async () => {
1040
+ const f = await this.getToken(
1041
+ r,
1042
+ o || c > 0
1043
+ );
1044
+ try {
1045
+ const u = await this.post(
1046
+ {
1047
+ [n]: f,
1048
+ ...t
1049
+ },
1050
+ S(a || {}, {
1051
+ customEnv: {
1052
+ mwTokenName: r
1053
+ }
1054
+ })
1055
+ );
1056
+ if (R.isBadTokenError(u.data))
1057
+ throw u;
1058
+ return u;
1059
+ } catch (u) {
1060
+ throw R.isBadTokenError(u) || u?.ok === !1 || A.is(u) ? u : new R(
1061
+ U.HTTP_ERROR,
1062
+ "Network/transport or SDK-internal error (not a MediaWiki API error)",
1063
+ u
1064
+ );
1065
+ }
1066
+ },
1067
+ {
1068
+ retry: i,
1069
+ onRetry: (f, u) => {
1070
+ c = u + 1;
1071
+ },
1072
+ shouldRetry: (f) => R.isBadTokenError(f) || f?.ok === !1
1073
+ }
1074
+ ).catch((f) => {
1075
+ throw R.isBadTokenError(f) || f?.ok === !1 ? new R(
1076
+ U.TOKEN_RETRY_LIMIT_EXCEEDED,
1077
+ "Retry attempts for acquiring/using token exhausted",
1078
+ f
1079
+ ) : f;
1080
+ });
1081
+ }
1082
+ postWithEditToken(r) {
1083
+ return this.postWithToken("csrf", r);
1084
+ }
1085
+ // for backward compatibility
1086
+ /** @deprecated Use `this.config.baseURL` instead */
1087
+ get baseURL() {
1088
+ return this.config.baseURL;
1089
+ }
1090
+ /** @deprecated Use `this.config.defaultParams` instead */
1091
+ get defaultParams() {
1092
+ return this.config.defaultParams;
1093
+ }
1094
+ /** @deprecated Use `this.config.fexiosConfigs` instead */
1095
+ get defaultOptions() {
1096
+ return this.config.fexiosConfigs;
1097
+ }
1098
+ };
1099
+ v.INIT_DEFAULT_PARAMS = {
1100
+ action: "query",
1101
+ errorformat: "plaintext",
1102
+ format: "json",
1103
+ formatversion: 2
1104
+ }, v.DEFAULT_CONFIGS = {
1105
+ baseURL: void 0,
1106
+ fexiosConfigs: {
1107
+ responseType: "json"
1108
+ },
1109
+ defaultParams: v.INIT_DEFAULT_PARAMS,
1110
+ throwOnApiError: !1
1111
+ }, v.createRequestHandler = q;
1112
+ let F = v;
1113
+ class V extends F {
1114
+ async clientLogin(r, t, e) {
1115
+ e ||= {}, !e.logincontinue && !e.loginreturnurl && (e.loginreturnurl = location?.origin);
1116
+ const n = await this.postWithToken(
1117
+ "login",
1118
+ {
1119
+ action: "clientlogin",
1120
+ username: r,
1121
+ password: t,
1122
+ ...e
1123
+ },
1124
+ {
1125
+ tokenName: "logintoken"
1126
+ }
1127
+ );
1128
+ if (n?.data?.clientlogin?.status === "PASS")
1129
+ return n.data.clientlogin;
1130
+ throw new R(
1131
+ U.LOGIN_FAILED,
1132
+ n.data.clientlogin.message,
1133
+ n
1134
+ );
1135
+ }
1136
+ }
1137
+ class Z extends V {
1138
+ constructor(r, t, e) {
1139
+ const n = W(
1140
+ r,
1141
+ {
1142
+ credentials: "include",
1143
+ mode: "cors",
1144
+ ...t
1145
+ },
1146
+ {
1147
+ origin: location.origin,
1148
+ ...e
1149
+ }
1150
+ );
1151
+ super(n);
1152
+ }
1153
+ }
1154
+ export {
1155
+ S as A,
1156
+ V as J,
1157
+ A as S,
1158
+ Z as e
1159
+ };
1160
+ //# sourceMappingURL=browser-DR-yCqVg.js.map