@inpageedit/core 0.4.1 → 0.5.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.
- package/LICENSE +20 -20
- package/README.md +55 -55
- package/dist/ActionButton-BgbTKTg7.js +24 -0
- package/dist/ActionButton-BgbTKTg7.js.map +1 -0
- package/dist/InputBox-FIzJ-rPN.js.map +1 -1
- package/dist/Preferences-Bg3J5Ur9.js.map +1 -1
- package/dist/{RadioBox-BZFhTEo5.js → RadioBox-CaA8VgLu.js} +16 -16
- package/dist/RadioBox-CaA8VgLu.js.map +1 -0
- package/dist/components/TwinSwapInput/index.d.ts +1 -0
- package/dist/components/index.js +21 -22
- package/dist/components/index.js.map +1 -1
- package/dist/{index-BPsDFq9U.js → index-Bh70Udzi.js} +14 -13
- package/dist/index-Bh70Udzi.js.map +1 -0
- package/dist/index-Bo1hNwWJ.js +96 -0
- package/dist/index-Bo1hNwWJ.js.map +1 -0
- package/dist/{index-Ch5DJDZZ.js → index-BxR7MsNM.js} +105 -102
- package/dist/index-BxR7MsNM.js.map +1 -0
- package/dist/{index-BsYzf3Yw.js → index-CUXLgVhg.js} +11 -11
- package/dist/index-CUXLgVhg.js.map +1 -0
- package/dist/index-CvhkVj_L.js.map +1 -1
- package/dist/{index-BByzm2Fz.js → index-D3yG7jFv.js} +119 -111
- package/dist/{index-BByzm2Fz.js.map → index-D3yG7jFv.js.map} +1 -1
- package/dist/{index-D-zQLFuZ.js → index-K73DMVec.js} +13 -20
- package/dist/index-K73DMVec.js.map +1 -0
- package/dist/index-jKU6cYcH.js +165 -0
- package/dist/index-jKU6cYcH.js.map +1 -0
- package/dist/{index-X1X416tZ.js → index-mMAGhnbR.js} +40 -24
- package/dist/index-mMAGhnbR.js.map +1 -0
- package/dist/index-z5MR2HJ2.js +4820 -0
- package/dist/index-z5MR2HJ2.js.map +1 -0
- package/dist/index.js +2270 -1770
- package/dist/index.js.map +1 -1
- package/dist/plugins/_debug/index.d.ts +1 -1
- package/dist/plugins/quick-diff/PluginQuickDiffCore.d.ts +2 -1
- package/dist/plugins/quick-edit/index.d.ts +2 -1
- package/dist/plugins/quick-move/index.d.ts +1 -1
- package/dist/plugins/quick-preview/index.d.ts +4 -3
- package/dist/plugins/quick-redirect/index.d.ts +1 -1
- package/dist/plugins/toolbox/index.d.ts +2 -2
- package/dist/services/ModalService/IPEModal.d.ts +235 -0
- package/dist/services/ModalService/index.d.ts +35 -0
- package/dist/sleep-DpyIipK-.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/utils/interpolate.d.ts +20 -0
- package/dist/utils/interpolate.spec.d.ts +1 -0
- package/lib/index.umd.js +28 -28
- package/lib/index.umd.js.map +1 -1
- package/lib/style.css +1 -1
- package/package.json +7 -9
- package/dist/ActionButton-ByMKIthQ.js +0 -24
- package/dist/ActionButton-ByMKIthQ.js.map +0 -1
- package/dist/RadioBox-BZFhTEo5.js.map +0 -1
- package/dist/index-BPsDFq9U.js.map +0 -1
- package/dist/index-BTngTj1f.js +0 -4682
- package/dist/index-BTngTj1f.js.map +0 -1
- package/dist/index-BsYzf3Yw.js.map +0 -1
- package/dist/index-Ch5DJDZZ.js.map +0 -1
- package/dist/index-Cq9xxVsu.js +0 -149
- package/dist/index-Cq9xxVsu.js.map +0 -1
- package/dist/index-D-zQLFuZ.js.map +0 -1
- package/dist/index-HyxA2rYz.js +0 -87
- package/dist/index-HyxA2rYz.js.map +0 -1
- package/dist/index-X1X416tZ.js.map +0 -1
- package/dist/services/SsiModalService.d.ts +0 -36
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { j as s } from "./index-CvhkVj_L.js";
|
|
2
2
|
import { BasePlugin as I, Schema as b, InPageEdit as v, Inject as S } from "./index.js";
|
|
3
|
-
import { A as P } from "./ActionButton-
|
|
3
|
+
import { A as P } from "./ActionButton-BgbTKTg7.js";
|
|
4
4
|
var j = Object.create, h = Object.defineProperty, A = Object.getOwnPropertyDescriptor, y = (r, e) => (e = Symbol[r]) ? e : Symbol.for("Symbol." + r), x = (r) => {
|
|
5
5
|
throw TypeError(r);
|
|
6
|
-
}, O = (r, e, t) => e in r ? h(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, R = (r, e) => h(r, "name", { value: e, configurable: !0 }), V = (r) => [, , , j(r?.[y("metadata")] ?? null)], z = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], C = (r) => r !== void 0 && typeof r != "function" ? x("Function expected") : r, G = (r, e, t, n, i) => ({ kind: z[r], name: e, metadata: n, addInitializer: (a) => t._ ? x("Already initialized") : i.push(C(a || null)) }),
|
|
6
|
+
}, O = (r, e, t) => e in r ? h(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, R = (r, e) => h(r, "name", { value: e, configurable: !0 }), V = (r) => [, , , j(r?.[y("metadata")] ?? null)], z = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], C = (r) => r !== void 0 && typeof r != "function" ? x("Function expected") : r, G = (r, e, t, n, i) => ({ kind: z[r], name: e, metadata: n, addInitializer: (a) => t._ ? x("Already initialized") : i.push(C(a || null)) }), N = (r, e) => O(e, y("metadata"), r[3]), k = (r, e, t, n) => {
|
|
7
7
|
for (var i = 0, a = r[e >> 1], o = a && a.length; i < o; i++) a[i].call(t);
|
|
8
8
|
return n;
|
|
9
|
-
},
|
|
9
|
+
}, H = (r, e, t, n, i, a) => {
|
|
10
10
|
var o, g, p, l = e & 7, m = !1, _ = 0, E = r[_] || (r[_] = []), d = l && (i = i.prototype, l < 5 && (l > 3 || !m) && A(i, t));
|
|
11
11
|
R(i, t);
|
|
12
12
|
for (var c = n.length - 1; c >= 0; c--)
|
|
13
13
|
p = G(l, t, g = {}, r[3], E), o = (0, n[c])(i, p), g._ = 1, C(o) && (i = o);
|
|
14
|
-
return
|
|
14
|
+
return N(r, i), d && h(i, t, d), m ? l ^ 4 ? a : d : i;
|
|
15
15
|
}, D, f, w;
|
|
16
16
|
D = [S(["sitemeta", "storage"])];
|
|
17
17
|
class u extends (w = I) {
|
|
@@ -35,8 +35,8 @@ class u extends (w = I) {
|
|
|
35
35
|
}), this.registerCustomConfig(
|
|
36
36
|
"about",
|
|
37
37
|
b.object({
|
|
38
|
-
about: b.
|
|
39
|
-
|
|
38
|
+
about: b.const(
|
|
39
|
+
/* @__PURE__ */ s("div", { className: "prose", children: [
|
|
40
40
|
/* @__PURE__ */ s("h2", { children: "✏️ InPageEdit NEXT" }),
|
|
41
41
|
/* @__PURE__ */ s("i", { children: [
|
|
42
42
|
"v",
|
|
@@ -44,14 +44,7 @@ class u extends (w = I) {
|
|
|
44
44
|
] }),
|
|
45
45
|
/* @__PURE__ */ s("h2", { children: "Portal" }),
|
|
46
46
|
/* @__PURE__ */ s("div", { style: "display: flex; flex-direction: column; gap: 1rem", children: [
|
|
47
|
-
/* @__PURE__ */ s(
|
|
48
|
-
P,
|
|
49
|
-
{
|
|
50
|
-
href: "https://www.ipe.wiki",
|
|
51
|
-
style: { display: "block", width: "100%" },
|
|
52
|
-
children: "Official Website & Help Center"
|
|
53
|
-
}
|
|
54
|
-
),
|
|
47
|
+
/* @__PURE__ */ s(P, { href: "https://www.ipe.wiki", style: { display: "block", width: "100%" }, children: "Official Website & Help Center" }),
|
|
55
48
|
/* @__PURE__ */ s(
|
|
56
49
|
P,
|
|
57
50
|
{
|
|
@@ -77,12 +70,12 @@ class u extends (w = I) {
|
|
|
77
70
|
/* @__PURE__ */ s("hr", {}),
|
|
78
71
|
/* @__PURE__ */ s("p", { children: "🚀 Modular, Extensible Supercharged Plugin for MediaWiki." }),
|
|
79
72
|
/* @__PURE__ */ s("p", { children: "InPageEdit-NEXT Copyright © 2025-present dragon-fish" })
|
|
80
|
-
] })
|
|
81
|
-
).
|
|
73
|
+
] })
|
|
74
|
+
).role("raw-html")
|
|
82
75
|
}).description(""),
|
|
83
76
|
"about",
|
|
84
77
|
{}
|
|
85
|
-
), import("./index-
|
|
78
|
+
), import("./index-z5MR2HJ2.js").then((e) => {
|
|
86
79
|
const t = this.ctx.plugin(e.PluginPreferencesUI);
|
|
87
80
|
this.addDisposeHandler(() => {
|
|
88
81
|
t.dispose();
|
|
@@ -147,9 +140,9 @@ class u extends (w = I) {
|
|
|
147
140
|
}
|
|
148
141
|
}
|
|
149
142
|
f = V(w);
|
|
150
|
-
u =
|
|
151
|
-
|
|
143
|
+
u = H(f, 0, "PluginPreferences", D, u);
|
|
144
|
+
k(f, 1, u);
|
|
152
145
|
export {
|
|
153
146
|
u as PluginPreferences
|
|
154
147
|
};
|
|
155
|
-
//# sourceMappingURL=index-
|
|
148
|
+
//# sourceMappingURL=index-K73DMVec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-K73DMVec.js","sources":["../src/plugins/preferences/index.tsx"],"sourcesContent":["import { Inject, InPageEdit, Schema } from '@/InPageEdit'\nimport { IPEStorageItem, IPEStorageManager } from '@/services/StorageService'\n\ndeclare module '@/InPageEdit' {\n export interface InPageEdit {\n preferences: PluginPreferences\n }\n}\n\nexport interface InPageEditPreferenceUICategory {\n name: string\n label: string\n description?: string\n index?: number\n}\n\nexport interface InPageEditPreferenceUIRegistryItem {\n name: string\n schema: Schema\n defaults: Record<string, any>\n category: string\n}\n\n@Inject(['sitemeta', 'storage'])\nexport class PluginPreferences extends BasePlugin {\n private db: IPEStorageManager<any>\n public customRegistries: InPageEditPreferenceUIRegistryItem[] = []\n public categoryDefinitions: InPageEditPreferenceUICategory[] = []\n private _defaultPreferences: Record<string, any> = {}\n\n constructor(public ctx: InPageEdit) {\n super(ctx, {}, 'preferences')\n this.db = ctx.storage.createDatabse<any>('preferences', Infinity)\n this.ctx.set('preferences', this)\n }\n\n async start() {\n this.defineCategory({\n name: 'general',\n label: 'General',\n description: 'General settings',\n })\n this.defineCategory({\n name: 'edit',\n label: 'Editing',\n description: 'Settings related to editing content',\n })\n this.defineCategory({\n name: 'about',\n label: 'About',\n description: 'About InPageEdit',\n index: 99,\n })\n\n this.registerCustomConfig(\n 'about',\n Schema.object({\n about: Schema.const(\n <div className=\"prose\">\n <h2>✏️ InPageEdit NEXT</h2>\n <i>v{this.ctx.version}</i>\n <h2>Portal</h2>\n <div style=\"display: flex; flex-direction: column; gap: 1rem\">\n <ActionButton href=\"https://www.ipe.wiki\" style={{ display: 'block', width: '100%' }}>\n Official Website & Help Center\n </ActionButton>\n <ActionButton\n href=\"https://www.ipe.wiki/update/\"\n style={{ display: 'block', width: '100%' }}\n >\n Update Logs\n </ActionButton>\n </div>\n <h2>Join us</h2>\n <ul>\n <li>\n <strong>GitHub</strong>:{' '}\n <a href=\"https://github.com/inpageedit/inpageedit-next\" target=\"_blank\">\n inpageedit/inpageedit-next\n </a>\n </li>\n <li>\n <strong>QQ Group</strong>: 1026023666\n </li>\n </ul>\n <hr />\n <p>🚀 Modular, Extensible Supercharged Plugin for MediaWiki.</p>\n <p>InPageEdit-NEXT Copyright © 2025-present dragon-fish</p>\n </div>\n ).role('raw-html'),\n }).description(''),\n 'about',\n {}\n )\n\n import('./ui/index').then((module) => {\n const fork = this.ctx.plugin(module.PluginPreferencesUI)\n this.addDisposeHandler(() => {\n fork.dispose()\n })\n })\n }\n\n get<T = any>(key: string, fallback?: () => T | Promise<T>): Promise<T | null> {\n fallback ||= () => {\n const defaultValue = this.getDefaultValue(key)\n this.logger.info('default value used', defaultValue)\n return defaultValue as T\n }\n const value = this.db.get(key, undefined, fallback)\n return value\n }\n\n getDefaultValue(key: string) {\n return (this._defaultPreferences[key] ??= this.loadDefaultConfigs()[key])\n }\n\n set<T = any>(key: string, value: T): Promise<IPEStorageItem<T> | void> {\n const defaultValue = this.getDefaultValue(key)\n if (value === defaultValue) {\n return this.db.delete(key)\n } else {\n return this.db.set(key, value)\n }\n }\n\n async getAll() {\n const data = this.loadDefaultConfigs()\n await this.db.iterate((value: IPEStorageItem, key: string) => {\n data[key] = value\n })\n return data\n }\n\n private loadDefaultConfigs() {\n const data = {} as Record<string, any>\n this.getConfigRegistries().forEach((item) => {\n item.defaults &&\n Object.entries(item.defaults).forEach(([key, val]) => {\n data[key] = val\n this._defaultPreferences[key] = val\n })\n })\n return data\n }\n\n registerCustomConfig(\n name: string,\n schema: Schema,\n category: string,\n defaults: Record<string, any>\n ) {\n this.customRegistries.push({\n name,\n schema,\n category,\n defaults,\n })\n return this\n }\n\n getConfigRegistries(category?: string): InPageEditPreferenceUIRegistryItem[] {\n return Array.from(this.ctx.registry.entries())\n .map<{\n name: string\n schema: Schema\n defaults: Record<string, any>\n }>(([plugin, fork]) => {\n if (plugin === null) {\n return {\n name: 'root',\n schema: (InPageEdit as any)?.PreferencesSchema || null,\n defaults: (InPageEdit as any)?.PreferencesDefaults || {},\n }\n } else {\n return {\n name: plugin.name,\n schema: (plugin as any)?.PreferencesSchema || null,\n defaults: (plugin as any)?.PreferencesDefaults || {},\n }\n }\n })\n .filter((item) => item.schema !== null)\n .map((item) => {\n return {\n ...item,\n category: item.schema.meta.category || 'general',\n }\n })\n .concat(this.customRegistries)\n .filter((item) => !category || item.category === category)\n }\n\n defineCategory(category: InPageEditPreferenceUICategory) {\n const index = this.categoryDefinitions.findIndex((tab) => tab.name === category.name)\n if (index < 0) {\n this.categoryDefinitions.push(category)\n } else {\n this.categoryDefinitions[index] = category\n }\n this.categoryDefinitions.sort((a, b) => {\n return (a.index ?? 0) - (b.index ?? 0)\n })\n return this\n }\n\n getConfigCategories() {\n return this.categoryDefinitions\n }\n}\n"],"names":["_PluginPreferences_decorators","_init","_a","Inject","PluginPreferences","BasePlugin","ctx","Schema","jsxs","jsx","ActionButton","module","fork","key","fallback","defaultValue","value","data","item","val","name","schema","category","defaults","plugin","InPageEdit","index","tab","a","b","__decoratorStart","__decorateElement","__runInitializers"],"mappings":";;;;;;;;;;;;;;GAAAA,GAAAC,GAAAC;AAuBAF,IAAA,CAACG,EAAO,CAAC,YAAY,SAAS,CAAC,CAAA;AACxB,MAAMC,WAA0BF,IAAAG,GAAW;AAAA,EAMhD,YAAmBC,GAAiB;AAClC,U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AAAA,MACL,GAAGA;AAAA,MACH,UAAUA,EAAK,OAAO,KAAK,YAAY;AAAA,IAAA,EAE1C,EACA,OAAO,KAAK,gBAAgB,EAC5B,OAAO,CAACA,MAAS,CAACI,KAAYJ,EAAK,aAAaI,CAAQ;AAAA,EAC7D;AAAA,EAEA,eAAeA,GAA0C;AACvD,UAAMI,IAAQ,KAAK,oBAAoB,UAAU,CAACC,MAAQA,EAAI,SAASL,EAAS,IAAI;AACpF,WAAII,IAAQ,IACV,KAAK,oBAAoB,KAAKJ,CAAQ,IAEtC,KAAK,oBAAoBI,CAAK,IAAIJ,GAEpC,KAAK,oBAAoB,KAAK,CAACM,GAAGC,OACxBD,EAAE,SAAS,MAAMC,EAAE,SAAS,EACrC,GACM;AAAA,EACT;AAAA,EAEA,sBAAsB;AACpB,WAAO,KAAK;AAAA,EACd;AACF;AAzLO5B,IAAA6B,EAAA5B,CAAA;AAAME,IAAN2B,6BADP/B,GACaI,CAAA;AAAN4B,EAAA/B,GAAA,GAAMG,CAAA;"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { j as i, P as y } from "./index-CvhkVj_L.js";
|
|
2
|
+
import { BasePlugin as S, Inject as q } from "./index.js";
|
|
3
|
+
import { T as F } from "./index-Bh70Udzi.js";
|
|
4
|
+
import { C as u, I as j } from "./InputBox-FIzJ-rPN.js";
|
|
5
|
+
var E = Object.create, h = Object.defineProperty, I = Object.getOwnPropertyDescriptor, w = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), k = (t) => {
|
|
6
|
+
throw TypeError(t);
|
|
7
|
+
}, B = (t, e, o) => e in t ? h(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, C = (t, e) => h(t, "name", { value: e, configurable: !0 }), T = (t) => [, , , E(t?.[w("metadata")] ?? null)], z = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], _ = (t) => t !== void 0 && typeof t != "function" ? k("Function expected") : t, D = (t, e, o, a, r) => ({ kind: z[t], name: e, metadata: a, addInitializer: (n) => o._ ? k("Already initialized") : r.push(_(n || null)) }), O = (t, e) => B(e, w("metadata"), t[3]), N = (t, e, o, a) => {
|
|
8
|
+
for (var r = 0, n = t[e >> 1], s = n && n.length; r < s; r++) n[r].call(o);
|
|
9
|
+
return a;
|
|
10
|
+
}, Q = (t, e, o, a, r, n) => {
|
|
11
|
+
var s, c, p, l = e & 7, f = !1, b = 0, P = t[b] || (t[b] = []), d = l && (r = r.prototype, l < 5 && (l > 3 || !f) && I(r, o));
|
|
12
|
+
C(r, o);
|
|
13
|
+
for (var m = a.length - 1; m >= 0; m--)
|
|
14
|
+
p = D(l, o, c = {}, t[3], P), s = (0, a[m])(r, p), c._ = 1, _(s) && (r = s);
|
|
15
|
+
return O(t, r), d && h(r, o, d), f ? l ^ 4 ? n : d : r;
|
|
16
|
+
}, M, g, x;
|
|
17
|
+
M = [q(["modal", "sitemeta"])];
|
|
18
|
+
class v extends (x = S) {
|
|
19
|
+
constructor(e) {
|
|
20
|
+
super(e, {}, "quick-move"), this.ctx = e, e.set("quickMove", this.quickMove.bind(this)), e.set("movePage", this.movePage.bind(this));
|
|
21
|
+
}
|
|
22
|
+
start() {
|
|
23
|
+
this.ctx.inject(["toolbox"], (e) => {
|
|
24
|
+
this.injectToolbox(e);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
injectToolbox(e) {
|
|
28
|
+
const o = window.mw?.config.get("wgPageName") || "", a = window.mw?.config.get("wgIsProbablyEditable");
|
|
29
|
+
e.toolbox.addButton({
|
|
30
|
+
id: "quick-move",
|
|
31
|
+
icon: /* @__PURE__ */ i(
|
|
32
|
+
"svg",
|
|
33
|
+
{
|
|
34
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
35
|
+
width: "24",
|
|
36
|
+
height: "24",
|
|
37
|
+
viewBox: "0 0 24 24",
|
|
38
|
+
fill: "none",
|
|
39
|
+
stroke: "currentColor",
|
|
40
|
+
"stroke-width": "2",
|
|
41
|
+
"stroke-linecap": "round",
|
|
42
|
+
"stroke-linejoin": "round",
|
|
43
|
+
class: "icon icon-tabler icons-tabler-outline icon-tabler-forms",
|
|
44
|
+
children: [
|
|
45
|
+
/* @__PURE__ */ i("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
46
|
+
/* @__PURE__ */ i("path", { d: "M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3" }),
|
|
47
|
+
/* @__PURE__ */ i("path", { d: "M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3" }),
|
|
48
|
+
/* @__PURE__ */ i("path", { d: "M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7" }),
|
|
49
|
+
/* @__PURE__ */ i("path", { d: "M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1" }),
|
|
50
|
+
/* @__PURE__ */ i("path", { d: "M17 12h.01" }),
|
|
51
|
+
/* @__PURE__ */ i("path", { d: "M13 12h.01" })
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
tooltip: "Quick Move",
|
|
56
|
+
group: "group2",
|
|
57
|
+
onClick: () => {
|
|
58
|
+
this.quickMove(
|
|
59
|
+
a ? {
|
|
60
|
+
lockFromField: !0,
|
|
61
|
+
from: o
|
|
62
|
+
} : {}
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
quickMove(e) {
|
|
68
|
+
const o = this.ctx.modal.createObject({
|
|
69
|
+
title: "Quick Move",
|
|
70
|
+
content: /* @__PURE__ */ i(y, {}),
|
|
71
|
+
className: "quick-move compact-buttons",
|
|
72
|
+
sizeClass: "medium",
|
|
73
|
+
center: !0
|
|
74
|
+
}).init();
|
|
75
|
+
let a = null;
|
|
76
|
+
return o.setContent(
|
|
77
|
+
/* @__PURE__ */ i(
|
|
78
|
+
"form",
|
|
79
|
+
{
|
|
80
|
+
ref: (r) => a = r,
|
|
81
|
+
style: {
|
|
82
|
+
display: "flex",
|
|
83
|
+
flexDirection: "column",
|
|
84
|
+
gap: "1rem"
|
|
85
|
+
},
|
|
86
|
+
onSubmit: (r) => {
|
|
87
|
+
if (r.preventDefault(), a?.checkValidity(), !a?.reportValidity())
|
|
88
|
+
return;
|
|
89
|
+
const n = new FormData(a), s = {
|
|
90
|
+
from: n.get("from")?.toString().trim(),
|
|
91
|
+
to: n.get("to")?.toString().trim(),
|
|
92
|
+
reason: n.get("reason") || "",
|
|
93
|
+
movetalk: n.get("movetalk") === "on",
|
|
94
|
+
movesubpages: n.get("movesubpages") === "on",
|
|
95
|
+
noredirect: n.get("noredirect") === "on"
|
|
96
|
+
};
|
|
97
|
+
if (!s.from || !s.to) {
|
|
98
|
+
this.ctx.modal.notify("error", {
|
|
99
|
+
title: "Failed to move",
|
|
100
|
+
content: "From and to are required."
|
|
101
|
+
});
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
o.setLoadingState(!0), this.movePage(s).then(() => {
|
|
105
|
+
location.reload();
|
|
106
|
+
}).catch((c) => {
|
|
107
|
+
o.setLoadingState(!1), this.ctx.modal.notify("error", {
|
|
108
|
+
title: "Failed to move",
|
|
109
|
+
content: c instanceof Error ? c.message : String(c)
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
children: [
|
|
114
|
+
/* @__PURE__ */ i(
|
|
115
|
+
F,
|
|
116
|
+
{
|
|
117
|
+
inputs: [
|
|
118
|
+
{
|
|
119
|
+
label: "Move from",
|
|
120
|
+
name: "from",
|
|
121
|
+
value: e?.from,
|
|
122
|
+
required: !0
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
label: "Move to",
|
|
126
|
+
name: "to",
|
|
127
|
+
value: e?.to,
|
|
128
|
+
required: !0
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
/* @__PURE__ */ i("div", { children: /* @__PURE__ */ i(u, { name: "movetalk", id: "movetalk", checked: e?.movetalk, children: "Move talk page" }) }),
|
|
134
|
+
/* @__PURE__ */ i("div", { children: /* @__PURE__ */ i(u, { name: "movesubpages", id: "movesubpages", checked: e?.movesubpages, children: "Move subpage(s) (up to 100)" }) }),
|
|
135
|
+
this.ctx.sitemeta.hasRight("suppressredirect") && /* @__PURE__ */ i("div", { children: /* @__PURE__ */ i(u, { name: "noredirect", id: "noredirect", checked: e?.noredirect, children: "Move without leaving a redirect" }) }),
|
|
136
|
+
/* @__PURE__ */ i(j, { label: "Reason", id: "reason", name: "reason", value: e?.reason })
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
), o.setButtons([
|
|
141
|
+
{
|
|
142
|
+
label: "Move",
|
|
143
|
+
className: "is-primary is-ghost",
|
|
144
|
+
method: () => {
|
|
145
|
+
a?.dispatchEvent(new Event("submit"));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
]), o.show();
|
|
149
|
+
}
|
|
150
|
+
async movePage(e) {
|
|
151
|
+
const { from: o, to: a, reason: r = "", ...n } = e;
|
|
152
|
+
if (!o || !a)
|
|
153
|
+
throw new Error("From and to titles are required.");
|
|
154
|
+
if (o === a)
|
|
155
|
+
throw new Error("From and to titles cannot be the same.");
|
|
156
|
+
return (await this.ctx.wikiPage.newFromTitle(o)).moveTo(a, r, n);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
g = T(x);
|
|
160
|
+
v = Q(g, 0, "PluginQuickMove", M, v);
|
|
161
|
+
N(g, 1, v);
|
|
162
|
+
export {
|
|
163
|
+
v as PluginQuickMove
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=index-jKU6cYcH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-jKU6cYcH.js","sources":["../src/plugins/quick-move/index.tsx"],"sourcesContent":["import { Inject, InPageEdit } from '@/InPageEdit'\n\ndeclare module '@/InPageEdit' {\n interface InPageEdit {\n quickMove: PluginQuickMove['quickMove']\n movePage: PluginQuickMove['movePage']\n }\n}\n\nexport interface MovePageOptions {\n from: string\n to: string\n reason?: string\n movetalk?: boolean\n movesubpages?: boolean\n noredirect?: boolean\n}\nexport interface QuickMoveOptions extends Partial<MovePageOptions> {\n lockFromField?: boolean\n lockToField?: boolean\n}\n\n@Inject(['modal', 'sitemeta'])\nexport class PluginQuickMove extends BasePlugin {\n constructor(public ctx: InPageEdit) {\n super(ctx, {}, 'quick-move')\n ctx.set('quickMove', this.quickMove.bind(this))\n ctx.set('movePage', this.movePage.bind(this))\n }\n\n protected start(): Promise<void> | void {\n this.ctx.inject(['toolbox'], (ctx) => {\n this.injectToolbox(ctx)\n })\n }\n\n private injectToolbox(ctx: InPageEdit) {\n const curPageName = window.mw?.config.get('wgPageName') || ''\n const canEdit = window.mw?.config.get('wgIsProbablyEditable')\n ctx.toolbox.addButton({\n id: 'quick-move',\n icon: (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"icon icon-tabler icons-tabler-outline icon-tabler-forms\"\n >\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3\" />\n <path d=\"M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3\" />\n <path d=\"M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7\" />\n <path d=\"M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1\" />\n <path d=\"M17 12h.01\" />\n <path d=\"M13 12h.01\" />\n </svg>\n ),\n tooltip: 'Quick Move',\n group: 'group2',\n onClick: () => {\n this.quickMove(\n canEdit\n ? {\n lockFromField: true,\n from: curPageName,\n }\n : {}\n )\n },\n })\n }\n\n quickMove(options?: Partial<QuickMoveOptions>) {\n const modal = this.ctx.modal\n .createObject({\n title: 'Quick Move',\n content: (<ProgressBar />) as HTMLElement,\n className: 'quick-move compact-buttons',\n sizeClass: 'medium',\n center: true,\n })\n .init()\n\n let formRef: HTMLFormElement | null = null\n modal.setContent(\n (\n <form\n ref={(el) => (formRef = el)}\n style={{\n display: 'flex',\n flexDirection: 'column',\n gap: '1rem',\n }}\n onSubmit={(e) => {\n e.preventDefault()\n formRef?.checkValidity()\n if (!formRef?.reportValidity()) {\n return\n }\n const formData = new FormData(formRef!)\n const options = {\n from: formData.get('from')?.toString().trim()!,\n to: formData.get('to')?.toString().trim()!,\n reason: (formData.get('reason') as string) || '',\n movetalk: formData.get('movetalk') === 'on',\n movesubpages: formData.get('movesubpages') === 'on',\n noredirect: formData.get('noredirect') === 'on',\n }\n if (!options.from || !options.to) {\n this.ctx.modal.notify('error', {\n title: 'Failed to move',\n content: 'From and to are required.',\n })\n return\n }\n modal.setLoadingState(true)\n this.movePage(options)\n .then(() => {\n location.reload()\n })\n .catch((error) => {\n modal.setLoadingState(false)\n this.ctx.modal.notify('error', {\n title: 'Failed to move',\n content: error instanceof Error ? error.message : String(error),\n })\n })\n }}\n >\n <TwinSwapInput\n inputs={[\n {\n label: 'Move from',\n name: 'from',\n value: options?.from,\n required: true,\n },\n {\n label: 'Move to',\n name: 'to',\n value: options?.to,\n required: true,\n },\n ]}\n />\n <div>\n <CheckBox name=\"movetalk\" id=\"movetalk\" checked={options?.movetalk}>\n Move talk page\n </CheckBox>\n </div>\n <div>\n <CheckBox name=\"movesubpages\" id=\"movesubpages\" checked={options?.movesubpages}>\n Move subpage(s) (up to 100)\n </CheckBox>\n </div>\n {this.ctx.sitemeta.hasRight('suppressredirect') && (\n <div>\n <CheckBox name=\"noredirect\" id=\"noredirect\" checked={options?.noredirect}>\n Move without leaving a redirect\n </CheckBox>\n </div>\n )}\n <InputBox label=\"Reason\" id=\"reason\" name=\"reason\" value={options?.reason} />\n </form>\n ) as HTMLElement\n )\n\n modal.setButtons([\n {\n label: 'Move',\n className: 'is-primary is-ghost',\n method: () => {\n formRef?.dispatchEvent(new Event('submit'))\n },\n },\n ])\n\n return modal.show()\n }\n\n async movePage(options: MovePageOptions) {\n const { from, to, reason = '', ...rest } = options\n\n if (!from || !to) {\n throw new Error('From and to titles are required.')\n }\n if (from === to) {\n throw new Error('From and to titles cannot be the same.')\n }\n\n const wikiPage = await this.ctx.wikiPage.newFromTitle(from)\n return wikiPage.moveTo(to, reason, rest)\n }\n}\n"],"names":["_PluginQuickMove_decorators","_init","_a","Inject","PluginQuickMove","BasePlugin","ctx","curPageName","canEdit","jsxs","jsx","options","modal","ProgressBar","formRef","el","e","formData","error","TwinSwapInput","CheckBox","InputBox","from","to","reason","rest","__decoratorStart","__decorateElement","__runInitializers"],"mappings":";;;;;;;;;;;;;;;GAAAA,GAAAC,GAAAC;AAsBAF,IAAA,CAACG,EAAO,CAAC,SAAS,UAAU,CAAC,CAAA;AACtB,MAAMC,WAAwBF,IAAAG,GAAW;AAAA,EAC9C,YAAmBC,GAAiB;AAClC,UAAMA,GAAK,CAAA,GAAI,YAAY,GADV,KAAA,MAAAA,GAEjBA,EAAI,IAAI,aAAa,KAAK,UAAU,KAAK,IAAI,CAAC,GAC9CA,EAAI,IAAI,YAAY,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,EAC9C;AAAA,EAEU,QAA8B;AACtC,SAAK,IAAI,OAAO,CAAC,SAAS,GAAG,CAACA,MAAQ;AACpC,WAAK,cAAcA,CAAG;AAAA,IACxB,CAAC;AAAA,EACH;AAAA,EAEQ,cAAcA,GAAiB;AACrC,UAAMC,IAAc,OAAO,IAAI,OAAO,IAAI,YAAY,KAAK,IACrDC,IAAU,OAAO,IAAI,OAAO,IAAI,sBAAsB;AAC5D,IAAAF,EAAI,QAAQ,UAAU;AAAA,MACpB,IAAI;AAAA,MACJ,MACEG,gBAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,OA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CAAA;AAANwB,EAAA3B,GAAA,GAAMG,CAAA;"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { j as e, P as l } from "./index-CvhkVj_L.js";
|
|
2
2
|
import { BasePlugin as d } from "./index.js";
|
|
3
|
-
import { T as
|
|
4
|
-
import { I as
|
|
5
|
-
|
|
6
|
-
class b extends d {
|
|
3
|
+
import { T as m } from "./index-Bh70Udzi.js";
|
|
4
|
+
import { I as u, C as h } from "./InputBox-FIzJ-rPN.js";
|
|
5
|
+
class v extends d {
|
|
7
6
|
constructor(t) {
|
|
8
7
|
super(t, {}, "quick-redirect"), this.ctx = t;
|
|
9
8
|
}
|
|
@@ -58,7 +57,7 @@ class b extends d {
|
|
|
58
57
|
const r = this.ctx.modal.createObject({
|
|
59
58
|
title: "Quick Redirect",
|
|
60
59
|
content: /* @__PURE__ */ e(l, {}),
|
|
61
|
-
className: "quick-redirect",
|
|
60
|
+
className: "quick-redirect compact-buttons",
|
|
62
61
|
sizeClass: "medium",
|
|
63
62
|
center: !0
|
|
64
63
|
}).init();
|
|
@@ -74,14 +73,22 @@ class b extends d {
|
|
|
74
73
|
gap: "1rem"
|
|
75
74
|
},
|
|
76
75
|
onSubmit: (o) => {
|
|
77
|
-
o.preventDefault()
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
if (o.preventDefault(), i?.checkValidity(), !i?.reportValidity())
|
|
77
|
+
return;
|
|
78
|
+
const a = new FormData(i), s = {
|
|
79
|
+
from: a.get("from")?.toString().trim(),
|
|
80
|
+
to: a.get("to")?.toString().trim(),
|
|
81
81
|
reason: a.get("reason") || "",
|
|
82
82
|
overwrite: a.get("overwrite") === "on"
|
|
83
83
|
};
|
|
84
|
-
|
|
84
|
+
if (!s.from || !s.to) {
|
|
85
|
+
this.ctx.modal.notify("error", {
|
|
86
|
+
title: "Failed to redirect",
|
|
87
|
+
content: "From and to are required."
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
r.setLoadingState(!0), this.redirectPage(s).then((n) => {
|
|
85
92
|
r.close(), this.ctx.modal.notify("success", {
|
|
86
93
|
title: "Redirect successful",
|
|
87
94
|
content: "The redirect has been created."
|
|
@@ -95,34 +102,43 @@ class b extends d {
|
|
|
95
102
|
},
|
|
96
103
|
children: [
|
|
97
104
|
/* @__PURE__ */ e(
|
|
98
|
-
|
|
105
|
+
m,
|
|
99
106
|
{
|
|
100
107
|
inputs: [
|
|
101
108
|
{
|
|
102
109
|
label: "From",
|
|
103
110
|
name: "from",
|
|
104
|
-
value: t?.from
|
|
111
|
+
value: t?.from,
|
|
112
|
+
required: !0
|
|
105
113
|
},
|
|
106
114
|
{
|
|
107
115
|
label: "To",
|
|
108
116
|
name: "to",
|
|
109
|
-
value: t?.to
|
|
117
|
+
value: t?.to,
|
|
118
|
+
required: !0
|
|
110
119
|
}
|
|
111
120
|
]
|
|
112
121
|
}
|
|
113
122
|
),
|
|
114
|
-
/* @__PURE__ */ e(
|
|
115
|
-
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
|
|
116
|
-
/* @__PURE__ */ e(g, { type: "primary", style: { width: "100%" }, children: "Create Redirect" })
|
|
123
|
+
/* @__PURE__ */ e(u, { label: "Reason", id: "reason", name: "reason", value: t?.reason }),
|
|
124
|
+
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(h, { name: "overwrite", id: "overwrite", checked: t?.overwrite, children: "Force create redirect even if the from page already exists" }) })
|
|
117
125
|
]
|
|
118
126
|
}
|
|
119
127
|
)
|
|
120
|
-
), r.
|
|
128
|
+
), r.setButtons([
|
|
129
|
+
{
|
|
130
|
+
label: "Create Redirect",
|
|
131
|
+
className: "is-primary is-ghost",
|
|
132
|
+
method: () => {
|
|
133
|
+
i?.dispatchEvent(new Event("submit"));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
]), r.show();
|
|
121
137
|
}
|
|
122
138
|
async redirectPage(t) {
|
|
123
|
-
const { from: r, to: i, reason: o = "", overwrite: a = !1 } = t,
|
|
139
|
+
const { from: r, to: i, reason: o = "", overwrite: a = !1 } = t, s = await this.ctx.wikiPage.newBlankPage({
|
|
124
140
|
title: r
|
|
125
|
-
}), n = `#REDIRECT [[:${i}]]`,
|
|
141
|
+
}), n = `#REDIRECT [[:${i}]]`, c = await s.edit(
|
|
126
142
|
{
|
|
127
143
|
text: n,
|
|
128
144
|
summary: o
|
|
@@ -131,12 +147,12 @@ class b extends d {
|
|
|
131
147
|
createonly: !a
|
|
132
148
|
}
|
|
133
149
|
);
|
|
134
|
-
if (
|
|
135
|
-
throw new Error(
|
|
136
|
-
return
|
|
150
|
+
if (c.data?.errors)
|
|
151
|
+
throw new Error(c.data.errors[0].text, { cause: c });
|
|
152
|
+
return c;
|
|
137
153
|
}
|
|
138
154
|
}
|
|
139
155
|
export {
|
|
140
|
-
|
|
156
|
+
v as PluginQuickRedirect
|
|
141
157
|
};
|
|
142
|
-
//# sourceMappingURL=index-
|
|
158
|
+
//# sourceMappingURL=index-mMAGhnbR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-mMAGhnbR.js","sources":["../src/plugins/quick-redirect/index.tsx"],"sourcesContent":["import { InPageEdit } from '@/InPageEdit'\n\ndeclare module '@/InPageEdit' {\n interface InPageEdit {\n quickRedirect: PluginQuickRedirect['quickRedirect']\n redirectPage: PluginQuickRedirect['redirectPage']\n }\n}\n\nexport interface RedirectPageOptions {\n from: string\n to: string\n reason?: string\n overwrite?: boolean\n}\nexport interface QuickRedirectOptions extends Partial<RedirectPageOptions> {}\n\nexport class PluginQuickRedirect extends BasePlugin {\n static readonly inject = ['api', 'wikiPage', 'modal']\n\n constructor(public ctx: InPageEdit) {\n super(ctx, {}, 'quick-redirect')\n }\n\n protected start(): Promise<void> | void {\n this.ctx.set('quickRedirect', this.quickRedirect.bind(this))\n this.ctx.set('redirectPage', this.redirectPage.bind(this))\n\n const curPageName = window.mw?.config.get('wgPageName') || ''\n const canEdit = window.mw?.config.get('wgIsProbablyEditable')\n this.ctx.inject(['toolbox'], (ctx) => {\n this.ctx = ctx\n ctx.toolbox.addButton({\n id: 'quick-redirect',\n icon: (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"icon icon-tabler icons-tabler-outline icon-tabler-file-symlink\"\n >\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M4 21v-4a3 3 0 0 1 3 -3h5\" />\n <path d=\"M9 17l3 -3l-3 -3\" />\n <path d=\"M14 3v4a1 1 0 0 0 1 1h4\" />\n <path d=\"M5 11v-6a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-9.5\" />\n </svg>\n ) as HTMLElement,\n tooltip: 'Quick Redirect',\n group: 'group1',\n onClick: () => {\n this.quickRedirect(\n canEdit\n ? {\n to: curPageName,\n }\n : {}\n )\n },\n })\n this.addDisposeHandler((ctx) => {\n ctx.toolbox.removeButton('quick-redirect')\n })\n })\n }\n\n protected stop(): Promise<void> | void {}\n\n quickRedirect(options?: Partial<QuickRedirectOptions>) {\n const modal = this.ctx.modal\n .createObject({\n title: 'Quick Redirect',\n content: (<ProgressBar />) as HTMLElement,\n className: 'quick-redirect compact-buttons',\n sizeClass: 'medium',\n center: true,\n })\n .init()\n\n let formRef: HTMLFormElement | null = null\n modal.setContent(\n (\n <form\n ref={(el) => (formRef = el)}\n style={{\n display: 'flex',\n flexDirection: 'column',\n gap: '1rem',\n }}\n onSubmit={(e) => {\n e.preventDefault()\n formRef?.checkValidity()\n if (!formRef?.reportValidity()) {\n return\n }\n const formData = new FormData(formRef!)\n const options = {\n from: formData.get('from')?.toString().trim()!,\n to: formData.get('to')?.toString().trim()!,\n reason: (formData.get('reason') as string) || '',\n overwrite: formData.get('overwrite') === 'on',\n }\n if (!options.from || !options.to) {\n this.ctx.modal.notify('error', {\n title: 'Failed to redirect',\n content: 'From and to are required.',\n })\n return\n }\n modal.setLoadingState(true)\n this.redirectPage(options)\n .then((res) => {\n modal.close()\n this.ctx.modal.notify('success', {\n title: 'Redirect successful',\n content: 'The redirect has been created.',\n })\n })\n .catch((error) => {\n modal.setLoadingState(false)\n this.ctx.modal.notify('error', {\n title: 'Failed to redirect',\n content: error instanceof Error ? error.message : String(error),\n })\n })\n }}\n >\n <TwinSwapInput\n inputs={[\n {\n label: 'From',\n name: 'from',\n value: options?.from,\n required: true,\n },\n {\n label: 'To',\n name: 'to',\n value: options?.to,\n required: true,\n },\n ]}\n />\n <InputBox label=\"Reason\" id=\"reason\" name=\"reason\" value={options?.reason} />\n <div>\n <CheckBox name=\"overwrite\" id=\"overwrite\" checked={options?.overwrite}>\n Force create redirect even if the from page already exists\n </CheckBox>\n </div>\n </form>\n ) as HTMLFormElement\n )\n modal.setButtons([\n {\n label: 'Create Redirect',\n className: 'is-primary is-ghost',\n method: () => {\n formRef?.dispatchEvent(new Event('submit'))\n },\n },\n ])\n\n return modal.show()\n }\n\n async redirectPage(options: RedirectPageOptions) {\n const { from, to, reason = '', overwrite = false } = options\n const wikiPage = await this.ctx.wikiPage.newBlankPage({\n title: from,\n })\n const content = `#REDIRECT [[:${to}]]`\n const res = await wikiPage.edit(\n {\n text: content,\n summary: reason,\n },\n {\n createonly: !overwrite,\n }\n )\n if (res.data?.errors) {\n throw new Error(res.data.errors[0].text, { cause: res })\n }\n return res\n }\n}\n"],"names":["PluginQuickRedirect","BasePlugin","ctx","curPageName","canEdit","jsxs","jsx","options","modal","ProgressBar","formRef","el","e","formData","res","error","TwinSwapInput","InputBox","CheckBox","from","to","reason","overwrite","wikiPage","content"],"mappings":";;;;AAiBO,MAAMA,UAA4BC,EAAW;AAAA,EAGlD,YAAmBC,GAAiB;AAClC,UAAMA,GAAK,CAAA,GAAI,gBAAgB,GADd,KAAA,MAAAA;AAA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